/** Compact stack counts: 1500 → 1.5k, 1000000 → 1M, etc. */ export function formatQuantity (value) { const n = Math.max(0, Math.floor(Number(value) || 0)); if (n < 1000) { return String(n); } const units = [ [1_000_000_000_000, "T"], [1_000_000_000, "B"], [1_000_000, "M"], [1_000, "k"] ]; for (const [divisor, suffix] of units) { if (n < divisor) { continue; } const scaled = n / divisor; if (Number.isInteger(scaled)) { return `${scaled}${suffix}`; } return `${Math.round(scaled * 10) / 10}${suffix}`; } return String(n); }