"use strict"; const STATUS_LABELS = { integrated: "integriert", software_verified: "Software verifiziert", pending: "Hardware ausstehend", passed: "physisch akzeptiert", failed: "fehlgeschlagen", blocked: "blockiert", contract_draft: "Semantikvertrag in Arbeit", preflight_ready: "Preflight bereit", unavailable: "nicht verfügbar", }; function escapeHtml(value) { return String(value ?? "").replace(/[&<>"']/g, (character) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'", }[character])); } async function readJson(url) { const response = await fetch(url, { cache: "no-store" }); if (!response.ok) throw new Error(`${url}: HTTP ${response.status}`); return response.json(); } function statusClass(status) { if (status === "integrated" || status === "software_verified" || status === "passed") return "ok"; if (status === "failed" || status === "unavailable") return "bad"; return "pending"; } function injectStyles() { if (document.getElementById("mhrn-acceleration-integration-styles")) return; const style = document.createElement("style"); style.id = "mhrn-acceleration-integration-styles"; style.textContent = ` .mhrn-accel-panel{margin:14px 0;padding:14px;border:1px solid var(--rule);border-radius:var(--r-md);background:var(--paper-2)} .mhrn-accel-head{display:flex;justify-content:space-between;gap:16px;align-items:flex-start;margin-bottom:12px} .mhrn-accel-head h3{margin:.2rem 0}.mhrn-accel-head p{margin:.2rem 0;max-width:88ch} .mhrn-accel-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:9px} .mhrn-accel-card{padding:10px;border:1px solid var(--rule);border-radius:8px;background:var(--paper)} .mhrn-accel-card h4{margin:0 0 6px}.mhrn-accel-card p{margin:4px 0} .mhrn-accel-state{display:inline-flex;padding:2px 7px;border-radius:999px;border:1px solid var(--rule);font-size:.78rem} .mhrn-accel-state.ok{font-weight:700}.mhrn-accel-state.bad{font-weight:700} .mhrn-accel-meta{display:grid;grid-template-columns:max-content 1fr;gap:4px 10px;margin-top:10px;font-size:.85rem} .mhrn-accel-meta dt{font-weight:700}.mhrn-accel-meta dd{margin:0;overflow-wrap:anywhere} .mhrn-accel-actions{display:flex;flex-wrap:wrap;gap:7px;margin-top:10px} .mhrn-accel-boundary{padding:9px;border-left:3px solid var(--accent);background:var(--paper)} `; document.head.append(style); } function panel(id, parent, title, intro, routeTag = null) { if (!parent) return null; let node = document.getElementById(id); if (node) return node; node = document.createElement("section"); node.id = id; node.className = "mhrn-accel-panel"; if (routeTag) node.dataset.mhrnRoute = routeTag; node.innerHTML = `
${escapeHtml(intro)}
${routes.length} Integrations-/Kompatibilitätsrouten sind im Promotion-Katalog ausdrücklich als OLD markiert.
${escapeHtml(routes.join(", ") || "Keine expliziten OLD-Routen gemeldet.")}
`; } async function refresh(panels) { const [integration, catalog] = await Promise.all([ readJson("/api/integration/status"), readJson("/api/playground/integration"), ]); const acceleration = integration.acceleration; if (!acceleration) throw new Error("/api/integration/status enthält keinen acceleration-Block"); if (panels.playground) panels.playground.querySelector("[data-accel-body]").innerHTML = hardwareMarkup(acceleration); if (panels.release) panels.release.querySelector("[data-accel-body]").innerHTML = hardwareMarkup(acceleration); if (panels.science) panels.science.querySelector("[data-accel-body]").innerHTML = scienceMarkup(acceleration); if (panels.old) panels.old.querySelector("[data-accel-body]").innerHTML = oldMarkup(catalog); } export function initAccelerationIntegrationStatus() { injectStyles(); const panels = ensurePanels(); const roots = Object.values(panels).filter(Boolean); if (!roots.length) return; document.addEventListener("click", (event) => { const button = event.target.closest("[data-accel-refresh]"); if (button && roots.some((root) => root.contains(button))) { refresh(panels).catch((error) => { roots.forEach((root) => { const body = root.querySelector("[data-accel-body]"); if (body) body.textContent = `Integrationsstatus nicht verfügbar: ${error.message || error}`; }); }); } }); refresh(panels).catch((error) => { roots.forEach((root) => { const body = root.querySelector("[data-accel-body]"); if (body) body.textContent = `Integrationsstatus nicht verfügbar: ${error.message || error}`; }); }); }