// Shared primitive components for the SEIS+ Internals dashboard. const fmtMoney = (n, dp = 4) => { const sign = n < 0 ? "-" : ""; const v = Math.abs(n).toFixed(dp); const [int, dec] = v.split("."); const intGrouped = int.replace(/\B(?=(\d{3})+(?!\d))/g, ","); return { sign, int: intGrouped, dec }; }; const fmtInt = (n) => n.toLocaleString("en-US"); function MoneyBig({ value, of, prefix = "$", small }) { const { sign, int, dec } = fmtMoney(value); return (
{prefix} {sign}{int}.{dec} {of != null && / ${fmtMoney(of).int}.{fmtMoney(of).dec}}
); } function Bar({ value, max, tone = "default", thin }) { const pct = Math.min(100, Math.max(0, (value / max) * 100)); const cls = tone === "warn" ? "warn" : tone === "danger" ? "danger" : ""; return (
); } function Pill({ children, live, dotColor }) { return ( {dotColor === "pulse" && } {dotColor && dotColor !== "pulse" && } {children} ); } function PanelHead({ idx, title, right, live }) { return (
{idx} {title} {live && LIVE} {right}
); } function Panel({ idx, title, right, live, children, style }) { return (
{children}
); } function SectionHead({ sigil, num, title, sub, right }) { return (
§

{num} {title} {sub && — {sub}}

{right}
); } // Sparkline using inline SVG. function Sparkline({ data, height = 36, color = "var(--ink)", fill = false }) { const w = 100, h = 100; const max = Math.max(...data), min = Math.min(...data); const range = max - min || 1; const pts = data.map((v, i) => { const x = (i / (data.length - 1)) * w; const y = h - ((v - min) / range) * h; return [x, y]; }); const d = pts.map(([x, y], i) => `${i === 0 ? "M" : "L"}${x.toFixed(2)},${y.toFixed(2)}`).join(" "); const dFill = `${d} L ${w},${h} L 0,${h} Z`; return ( {fill && } ); } // Vertical bar chart for daily spend. function BarsDaily({ data, height = 64, color = "var(--ink)" }) { const max = Math.max(...data, 1); return (
{data.map((v, i) => (
))}
); } // Status dot function StatusDot({ status }) { const map = { online: { c: "var(--ok)" }, focus: { c: "var(--warn)" }, away: { c: "var(--muted)" }, offline: { c: "transparent", border: true }, running: { c: "var(--ok)" }, "spinning-up": { c: "var(--warn)" }, stopped: { c: "var(--muted)" }, }; const { c, border } = map[status] || { c: "var(--muted)" }; return ( ); } window.SEIS_PRIM = { fmtMoney, fmtInt, MoneyBig, Bar, Pill, Panel, PanelHead, SectionHead, Sparkline, BarsDaily, StatusDot };