// Tiny primitive components.
const fmtTs = (t, opt = {}) => {
const d = new Date(t);
const pad = n => String(n).padStart(2, '0');
if (opt.short) return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
if (opt.dateOnly) return `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())}`;
return `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
};
const fmtNum = (n, dp = 2) => {
if (n == null || isNaN(n)) return '—';
const sign = n < 0 ? '-' : '';
const a = Math.abs(n);
return sign + a.toLocaleString('en-US', { minimumFractionDigits: dp, maximumFractionDigits: dp });
};
const fmtPct = (n, dp = 2) => `${n >= 0 ? '+' : ''}${(n*100).toFixed(dp)}%`;
const since = (t) => {
const d = Math.floor((Date.now() - t)/1000);
if (d < 60) return `${d}s ago`;
if (d < 3600) return `${Math.floor(d/60)}m ago`;
if (d < 86400) return `${Math.floor(d/3600)}h ago`;
return `${Math.floor(d/86400)}d ago`;
};
// Pill — used everywhere for state/severity/mode tags.
function Pill({ tone = 'ink', children, dot = false, className = '' }) {
const tones = {
ink: 'text-ink-1 bg-bg-2 border-line-1',
pos: 'text-pos-0 bg-pos-2/30 border-pos-1/40',
neg: 'text-neg-0 bg-neg-2/30 border-neg-1/40',
amb: 'text-amb-0 bg-amb-1/15 border-amb-1/40',
inf: 'text-inf-0 bg-inf-1/15 border-inf-1/40',
live: 'text-neg-0 bg-neg-2/30 border-neg-1/50',
paper: 'text-amb-0 bg-amb-1/15 border-amb-1/40',
testnet:'text-inf-0 bg-inf-1/15 border-inf-1/40',
};
return (
{dot && }
{children}
);
}
// Card — every panel uses this. Hairline border, dim header.
function Card({ title, sub, action, children, padded = true, className = '' }) {
return (
{title}
}
{sub && {sub}}