4. As shown in Figure 2, the diameter $A B=2 R$ of the semicircle $\odot O$, a moving point $C$ is on the semicircle. A circle is drawn with $C$ as the center and is tangent to $A B$. Then the maximum value of the shaded area $S$ enclosed by the circle, $A B$, $A C$, and $B C$ is $\qquad$
4. $\frac{R^{2}}{\pi}$.

As shown in Figure 6, let $A C = b, B C = a$, and construct $C D \perp A B$ at $D$. Then
$$
C D = \frac{a b}{2 R}.
$$

Thus, $S = \frac{1}{2} a b - \frac{1}{4} \pi \left( \frac{a b}{2 R} \right)^{2}$
$$
= -\frac{\pi}{16 R^{2}} (a b)^{2} + \frac{1}{2} a b.
$$

When $a b = -\frac{\frac{1}{2}}{2 \left( -\frac{\pi}{16 R^{2}} \right)} = \frac{4 R^{2}}{\pi}$,
$$
S_{\max} = \frac{R^{2}}{\pi}.
$$