2. If the function
$$
f(x)=x^{2}-2 a x-2 a|x-a|+1
$$

has exactly three zeros, then the value of the real number $a$ is $\qquad$.
2. 1.

Let $t=|x-a|(t \geqslant 0)$.
Then the original problem is equivalent to the equation $t^{2}-2 a t+1-a^{2}=0$ having two roots $t_{1}=0, t_{2}>0$.
Upon verification, $a=1$.