import { marked } from 'marked'; /** LegalDoc is one language variant of a legal document: its markdown source and page title. */ export interface LegalDoc { md: string; title: string; } /** * renderLegalHtml renders a bilingual (RU + EN) legal document as a standalone, self-contained HTML * page with a header language + theme switcher, mirroring the landing: a 🌐 language toggle and a * ☼/☾ theme toggle, no "back". Both language bodies are rendered into the page; a small inline * ES5 script toggles between them client-side (no reload), defaults to Russian (never the browser * language, like the landing) and persists the choice, and applies the theme (system default plus a * persisted manual override). On the offer page (`bodyClass === 'offer'`) it also transliterates the * Cyrillic left in the EN body — the live price list is spliced in Russian, so the product names are * transliterated for the English view. It backs every public legal page — the offer at `/offer/`, the * privacy policy at `/privacy/`, the EULA at `/eula/` — served by the render sidecar. * * The markdown is trusted repository content plus the backend's own catalog projection, not user * input, so the rendered HTML is deliberately not sanitised. The page carries its own minimal styling * and script, so it needs neither the app bundle nor `app.css`. */ export function renderLegalHtml(doc: { ru: LegalDoc; en: LegalDoc; canonical: string; bodyClass?: string }): string { const ruBody = marked.parse(doc.ru.md, { async: false }) as string; const enBody = marked.parse(doc.en.md, { async: false }) as string; return `