import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } /** 1536 -> "1.5 KB"; 43.2e9 -> "40.2 GB" (binary units, as drive sizes are shown). */ export function formatBytes(n: number): string { const units = ["B", "KB", "MB", "GB", "TB"]; let v = Math.max(0, n); let i = 0; while (v >= 1024 && i < units.length - 1) { v /= 1024; i++; } return `${i === 0 || v >= 100 ? Math.round(v) : v.toFixed(1)} ${units[i]}`; } export function formatUptime(secs: number | null | undefined): string { if (secs == null) return "—"; const d = Math.floor(secs / 86400); const h = Math.floor((secs % 86400) / 3600); const m = Math.floor((secs % 3600) / 60); if (d > 0) return `${d}d ${h}h`; if (h > 0) return `${h}h ${m}m`; return `${m}m ${secs % 60}s`; }