// BUG-05 FIX: sanitize() removed from components.js -- defined once in app.js. // Both files previously defined it; second definition silently overwrote the first. // app.js loads last, so its sanitize() was always the active one, but this was fragile. const Components = { Spinner: (size = "sm") => { const el = document.createElement("div"); el.className = "spinner"; if (size === "lg") { el.style.width = "40px"; el.style.height = "40px"; } return el; }, Toast: (message, type = "info") => { const el = document.createElement("div"); el.className = "toast"; el.style.borderLeftColor = type === "error" ? "var(--color-risk-very-high)" : type === "success" ? "var(--color-green)" : "var(--color-saffron)"; el.textContent = message; const container = document.getElementById("toast-container"); if (container) { container.appendChild(el); setTimeout(() => el.remove(), 4000); } return el; }, RiskBadge: (level) => { const el = document.createElement("span"); el.className = `risk-badge risk-badge--${level}`; el.textContent = level.replace("_", " "); return el; }, RiskBar: (score, level) => { const wrapper = document.createElement("div"); wrapper.className = "risk-score-bar"; wrapper.innerHTML = `
${score}/100 `; return wrapper; }, EntityBadge: (type) => { const el = document.createElement("span"); const t = (type || "").toLowerCase(); el.className = `badge badge--${t}`; el.textContent = type; return el; }, ResultCard: (entity, onClick) => { const el = document.createElement("div"); el.className = "result-card"; el.setAttribute("role", "button"); el.setAttribute("tabindex", "0"); const type = (entity.entity_type || "").toLowerCase(); // BUG-16 FIX: removed duplicate ministry: "M" key const icons = { politician: "P", company: "C", contract: "K", tender: "T", regulatory: "R", enforcement: "E", electoralbond: "B", insolvency: "I", ngo: "N", ministry: "M", party: "W", scheme: "S", auditreport: "A", courtcase: "J", localbody: "L", pressrelease: "PR", parliamentquestion: "Q" }; const icon = icons[type] || "?"; el.innerHTML = `