\(=\left(a^2+b^2+2ab\right)-c^2+b^2-c^2+ab+ac\)
\(=\left(a+b\right)^2-c^2+\left(b-c\right)\left(b+c\right)+a\left(b+c\right)\)
\(=\left(a+b-c\right)\left(a+b+c\right)+\left(a+b-c\right)\left(b+c\right)\)
\(=\left(a+b-c\right)\left(a+2b+2c\right)\)