"""The generator description of the two invariant rows, Theorems 23.2–23.3. CC0."""
from pathlib import Path
from html import escape

parts = ['<svg xmlns="http://www.w3.org/2000/svg" width="540" height="490" viewBox="0 0 540 490" role="img" aria-labelledby="title desc">',
         '<title id="title">The two rows for a path principal graph</title>',
         '<desc id="desc">For endpoint-rooted A_l, at level k at least one, A_k is generated by e0 through e_(k-1) and equals path algebra P_(k+1). B_k is the subalgebra generated by e1 through e_(k-1) and equals P_k. The expectation from the upper to the lower row fixes the latter generators and takes e0 to lambda times the identity. Generator descriptions specify the inclusions.</desc>',
         '<rect width="540" height="490" fill="#fbfcff"/>',
         '<style>text{font-family:Arial,sans-serif;fill:#172c45}.title{font-size:20px;font-weight:bold}.heading{font-size:21px;font-weight:bold}.label{font-size:16px}.small{font-size:14px}.box{fill:#edf3fb;stroke:#7c9bbd;stroke-width:1.5}</style>',
         '<defs><marker id="arrow" markerWidth="8" markerHeight="8" refX="7" refY="4" orient="auto"><path d="M0,0 L8,4 L0,8" fill="#426987"/></marker></defs>']

def text(x, y, value, cls='label', anchor='start'):
    parts.append(f'<text x="{x}" y="{y}" class="{cls}" text-anchor="{anchor}">{escape(value)}</text>')

text(24, 34, 'A path graph fills both rows', 'title')
text(24, 65, 'Endpoint root;   k ≥ 1;   λ = δ⁻²', 'label')
parts.append('<rect x="24" y="92" width="492" height="109" rx="8" class="box"/>')
text(270, 123, 'Aₖ = Pₖ₊₁', 'heading', 'middle')
text(270, 158, 'Generated by e₀, e₁, …, eₖ₋₁', 'label', 'middle')
text(270, 185, 'Equal dimensions force equality (23.4–5).', 'small', 'middle')
parts.append('<line x1="270" y1="209" x2="270" y2="277" stroke="#426987" stroke-width="2" marker-end="url(#arrow)"/>')
text(290, 246, 'F', 'label')
text(251, 229, 'F(e₀) = λ1', 'small', 'end')
text(251, 257, 'F(eᵢ) = eᵢ, i ≥ 1', 'small', 'end')
parts.append('<rect x="24" y="286" width="492" height="109" rx="8" class="box"/>')
text(270, 317, 'Bₖ = Pₖ', 'heading', 'middle')
text(270, 351, 'Generated by e₁, …, eₖ₋₁', 'label', 'middle')
text(270, 379, 'The image of F, by reversed word reduction.', 'small', 'middle')
text(24, 433, 'The lower row is a subalgebra of the upper row.', 'small')
text(24, 465, 'Theorems 23.2–23.4 preserve generators and traces.', 'small')
parts.append('</svg>')
Path(__file__).with_suffix('.svg').write_text('\n'.join(parts) + '\n', encoding='utf-8')
