5. Let $\alpha, \beta, \gamma \in \mathbf{R}$, and satisfy $\sin \alpha \cdot \cos \beta+|\cos \alpha \cdot \sin \beta|=\sin \alpha \cdot|\cos \alpha|+|\sin \beta| \cdot \cos \beta$, then the minimum value of $(\tan \gamma-\sin \alpha)^{2}+(\cot \gamma-\cos \beta)^{2}$ is $\qquad$.
$$
\begin{array}{l}
\sin \alpha \cdot \cos \beta+|\cos \alpha \cdot \sin \beta|=\sin \alpha \cdot|\cos \alpha|+|\sin \beta| \cdot \cos \beta \\
\Rightarrow(\sin \alpha-|\sin \beta|)(\cos \beta-|\cos \alpha|)=0,
\end{array}
$$

Assume $x=\cos \beta, y=\sin \alpha$, then the original equation becomes $\left(y-\sqrt{1-x^{2}}\right)\left(x-\sqrt{1-y^{2}}\right)=0$. As shown in the figure, point $M(x, y)$ lies on the major arc $\overparen{A B C}$, which is part of the unit circle. Therefore, the minimum distance from point $P(\cot \gamma, \tan \gamma)$ to point $M$ is $|O P|_{\text {min }}-1$.
And $|O P|^{2}=\cot ^{2} \gamma+\tan ^{2} \gamma \geqslant 2$
$\Rightarrow|O P|_{\text {min }}=\sqrt{2}$, equality holds when $P(1,1)$.
Thus, $(\tan \gamma-\sin \alpha)^{2}+(\cot \gamma-\cos \beta)^{2}$
$$
=|P M|^{2} \geqslant(\sqrt{2}-1)^{2}=3-2 \sqrt{2} .
$$

In summary, the minimum value of $(\tan \gamma-\sin \alpha)^{2}+(\cot \gamma-\cos \beta)^{2}$
is $3-2 \sqrt{2}$.