import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { createRequire } from "node:module";
import { resolve } from "node:path";
import { test } from "node:test";
const root = resolve(import.meta.dirname, "../..");
const require = createRequire(resolve(root, "govoplan-core/webui/package.json"));
const { buildSync } = require("esbuild");
const labels = {
approvals: { "Approval requests": "Genehmigungsanträge" },
forms: { "Form meaning": "Formularbedeutung" },
"forms-runtime": { "Form instance": "Formularinstanz", "Forms runtime": "Formularlaufzeit" },
helpdesk: { "Helpdesk profiles": "Helpdesk-Profile" },
portal: { "Service directory": "Leistungsverzeichnis" },
projects: { Projects: "Projekte" },
reporting: { Reporting: "Reporting" },
"risk-compliance": { "Risk Compliance": "Risiko und Compliance" },
scheduling: { Scheduling: "Terminplanung" },
tickets: { Tickets: "Tickets" },
voting: { Ballots: "Abstimmungen" },
wiki: { Wiki: "Wiki" },
workflow: { Workflows: "Workflows", Workflow: "Workflow" },
idm: {
"Direct changes to this governed function are": "Direkte Änderungen an dieser gesteuerten Funktion sind",
"emergency overrides": "Notfallübersteuerungen",
". Use a request or grant above for the normal process.": ". Verwenden Sie für den regulären Prozess einen Antrag oder eine Vergabe.",
},
};
// Render the actual Core heading/locale contract with one owning module at a
// time. The in-memory bundle creates no shared component-build artifacts.
const names = Object.keys(labels);
const imports = names.map((name, index) => `import { generatedTranslations as t${index} } from ${JSON.stringify(resolve(root, `govoplan-${name}/webui/src/i18n/generatedTranslations.ts`))};`).join("\n");
const { outputFiles } = buildSync({
stdin: {
contents: `${imports}
import { renderToStaticMarkup } from 'react-dom/server';
import { PlatformLanguageProvider } from ${JSON.stringify(resolve(root, "govoplan-core/webui/src/i18n/LanguageContext.tsx"))};
import PageTitle from ${JSON.stringify(resolve(root, "govoplan-core/webui/src/components/PageTitle.tsx"))};
import DocumentationHelpLink from ${JSON.stringify(resolve(root, "govoplan-core/webui/src/components/help/DocumentationHelpLink.tsx"))};
export const catalogs = [${names.map((_, index) => `t${index}`).join(",")}];
export function heading(index, language, label) {
return renderToStaticMarkup(