import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { fmtBytes } from '../lib/api'; /// Big horizontal storage bar. Read-only. Renders green (pinned, /// safe) + amber (used, evictable) + slate (free). Health color /// on the label based on fill %. export function StorageBar({ label, used, total, pinned }) { const safeTotal = Math.max(total, 1); const pct = Math.min(100, Math.round((used / safeTotal) * 100)); const pinnedPct = pinned ? Math.min(100, Math.round((pinned / safeTotal) * 100)) : 0; const evictablePct = Math.max(0, pct - pinnedPct); const bar = pct < 60 ? 'ok' : pct < 85 ? 'warn' : 'err'; const barText = { ok: 'text-emerald-300', warn: 'text-amber-300', err: 'text-red-300', }[bar]; return (_jsxs("div", { children: [_jsxs("div", { className: "flex items-baseline justify-between text-xs mb-1", children: [_jsx("span", { className: "text-slate-500 uppercase tracking-wider", children: label }), _jsxs("span", { className: `font-mono ${barText}`, children: [fmtBytes(used), " / ", fmtBytes(total), " \u00B7 ", pct, "%"] })] }), _jsxs("div", { className: "h-2.5 w-full rounded-full bg-slate-800 overflow-hidden flex", children: [pinnedPct > 0 && (_jsx("div", { className: "bg-emerald-500 h-full", style: { width: `${pinnedPct}%` }, title: `Pinned: ${fmtBytes(pinned)}` })), evictablePct > 0 && (_jsx("div", { className: `h-full ${bar === 'err' ? 'bg-red-500' : bar === 'warn' ? 'bg-amber-500' : 'bg-emerald-600'}`, style: { width: `${evictablePct}%` }, title: `Used: ${fmtBytes(used - (pinned ?? 0))}` }))] })] })); }