12. As shown in Figure 3, the side length of the equilateral $\triangle ABC$ is 5. Extend $BA$ to point $P$ such that $|AP|=9$. Let $D$ be a point on segment $BC$ (including endpoints), and let the line $AD$ intersect the circumcircle of $\triangle BPC$ at points $E$ and $F$, where $|EA|<|ED|$.
(1) Let $|BD|=x$. Express $|EA|-|DF|$ as a function $f(x)$ of $x$;
(2) Find the minimum value of $f(x)$.
12. (1) Let $u=|E A|, v=|A D|, w=|D F|$.

Then $f(x)=u-w$.
In the equilateral $\triangle A B C$, by the cosine rule we get
$$
\begin{aligned}
v & =\sqrt{|A B|^{2}+|B D|^{2}-2|A B||B D| \cos \angle A B D} \\
& =\sqrt{x^{2}-5 x+25} .
\end{aligned}
$$

Applying the intersecting chords theorem to the circumcircle of $\triangle P B C$, we get
$$
\begin{array}{l}
E A \cdot A F=B A \cdot A P, E D \cdot D F=B D \cdot D C \\
\Rightarrow u(v+w)=45,(u+v) w=x(5-x) \\
\Rightarrow v(u-w)=x^{2}-5 x+45 \\
\Rightarrow f(x)=u-w=\frac{x^{2}-5 x+45}{v} \\
=\frac{x^{2}-5 x+45}{\sqrt{x^{2}-5 x+45}}(0 \leqslant x \leqslant 5) .
\end{array}
$$
(2) Let $t=\sqrt{x^{2}-5 x+25} \geqslant 0$. Then
$$
f(x)=t+\frac{20}{t} \geqslant 2 \sqrt{t \cdot \frac{20}{t}}=4 \sqrt{5} \text {. }
$$

When and only when $t=\sqrt{x^{2}-5 x+25}=2 \sqrt{5}$, i.e., $x=$ $\frac{5 \pm \sqrt{5}}{2}$, $f(x)$ reaches its minimum value $4 \sqrt{5}$.