Japanese Temple Problem From 1844

I recently learnt a Japanese geometry temple problem.

The problem is the following:

Five squares are arranged as the image shows. Prove that the area of triangle T and the area of square S are equal.

I am thinking about law of cosines, but I have not been able to prove the theorem. Any hints would be appreciated.

We will, first of all, prove a very interesting property

$$Lemma1\mathbf{Lemma\;1}$$

Given two squares PQRS and PTUV (as shown on the picture), the triangles $$ΔSTP\Delta STP$$ and $$ΔPVQ\Delta PVQ$$ have equal area.

$$Proof\mathbf {Proof}$$

Denote by $$α\alpha$$ the angle SPT and by $$[...][...]$$ the area of the polygon “…”. Hence
$$[ΔSTP]=¯PS⋅¯PT⋅sin(α)2[\Delta STP]=\frac{\overline {PS}\cdot\overline {PT}\cdot \sin(\alpha)}{2}$$ $$[\Delta PVQ]=\frac{\overline {QP}*\overline {PV}\cdot\sin\Bigl(360°-(90°+90+\alpha)\Bigr)}{2}=\frac{\overline {QP}\cdot\overline {PV}\cdot\sin\Bigl(180°-\alpha\Bigr)}{2}=\frac{\overline {QP}\cdot\overline {PV}\cdot\sin(\alpha)}{2}[\Delta PVQ]=\frac{\overline {QP}*\overline {PV}\cdot\sin\Bigl(360°-(90°+90+\alpha)\Bigr)}{2}=\frac{\overline {QP}\cdot\overline {PV}\cdot\sin\Bigl(180°-\alpha\Bigr)}{2}=\frac{\overline {QP}\cdot\overline {PV}\cdot\sin(\alpha)}{2}$$

Since $$\overline {PS}=\overline {PQ}\overline {PS}=\overline {PQ}$$ and $$\overline {PT}=\overline {PV}\overline {PT}=\overline {PV}$$ $$[\Delta STP]=[\Delta PVQ][\Delta STP]=[\Delta PVQ]$$

Now, back to the problem

Let $$\overline {AB}=a\overline {AB}=a$$ and $$\overline {IJ}=b\overline {IJ}=b$$. Note first of all that $$\Delta BEC \cong \Delta EIF\Delta BEC \cong \Delta EIF$$
See why? $$\mathbf {Hint:}\mathbf {Hint:}$$

It is obvious that $$\overline {CE}=\overline {EF}\overline {CE}=\overline {EF}$$. Use the properties of right triangles in order to show that all angles are equal.

Thus $${(\overline{CE})^2}={a^2}+{b^2}=S{(\overline{CE})^2}={a^2}+{b^2}=S$$

Note furthermore that $$[\Delta BEC]=[\Delta EIF]=\frac{ab}{2}[\Delta BEC]=[\Delta EIF]=\frac{ab}{2}$$
By Lemma 1:
$$[\Delta DCG]=[\Delta BEC]=\frac{ab}{2}=[\Delta EIF]=[\Delta GFK][\Delta DCG]=[\Delta BEC]=\frac{ab}{2}=[\Delta EIF]=[\Delta GFK]$$
The area of the polygon AJKGD is thus
$$[AJKGD]=[ABCD]+[CEFG]+[FIJK]+4[\Delta DCG]=2\Bigl({a^2}+{b^2}\Bigr)+2ab[AJKGD]=[ABCD]+[CEFG]+[FIJK]+4[\Delta DCG]=2\Bigl({a^2}+{b^2}\Bigr)+2ab$$

The area of the trapezoid AJKD is moreover
$$[AJKD]=\frac{(a+b)(2a+2b)}{2}={a^2}+2ab+{b^2}[AJKD]=\frac{(a+b)(2a+2b)}{2}={a^2}+2ab+{b^2}$$

Finally
$$T=[\Delta DKG]=[AJKGD]-[AJKD]={a^2}+{b^2}=S \Rightarrow S=TT=[\Delta DKG]=[AJKGD]-[AJKD]={a^2}+{b^2}=S \Rightarrow S=T$$