/** * rFlows applet definition — Flow Summary card. */ import type { AppletDefinition, AppletLiveData } from "../../shared/applet-types"; const flowSummary: AppletDefinition = { id: "flow-summary", label: "Flow Summary", icon: "💧", accentColor: "#0891b2", ports: [ { name: "transfer-in", type: "json", direction: "input" }, { name: "balance-out", type: "number", direction: "output" }, ], renderCompact(data: AppletLiveData): string { const { snapshot } = data; const inflowRate = (snapshot.inflowRate as number) || 0; const balance = (snapshot.balance as number) || 0; const capacity = (snapshot.capacity as number) || 1; const fillPct = Math.min(100, Math.round((balance / capacity) * 100)); const sufficiency = fillPct >= 80 ? "Sufficient" : fillPct >= 40 ? "Moderate" : "Low"; const suffColor = fillPct >= 80 ? "#22c55e" : fillPct >= 40 ? "#f59e0b" : "#ef4444"; return `