export function formatBytes(bytes: number, decimals = 2): string { if (bytes === 0) return "0 Bytes" const k = 1024 const dm = decimals < 0 ? 0 : decimals const sizes = ["Bytes", "KB", "MB", "GB", "TB"] const i = Math.floor(Math.log(bytes) / Math.log(k)) return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i] } export function formatPercent(used: number, total: number): string { if (total === 0) return "0%" return ((used / total) * 100).toFixed(1) + "%" } export function formatUptime(seconds: number): string { const days = Math.floor(seconds / 86400) const hours = Math.floor((seconds % 86400) / 3600) const minutes = Math.floor((seconds % 3600) / 60) if (days > 0) { return `${days}d ${hours}h ${minutes}m` } else if (hours > 0) { return `${hours}h ${minutes}m` } else { return `${minutes}m` } } export function formatDate(timestamp: number): string { const date = new Date(timestamp * 1000) return date.toLocaleDateString() + " " + date.toLocaleTimeString() } export function getPoolHealthColor(health: string): string { switch (health) { case "ONLINE": return "text-green-600" case "DEGRADED": return "text-yellow-600" case "FAULTED": case "OFFLINE": case "UNAVAIL": return "text-red-600" default: return "text-gray-600" } } export function getPoolHealthBgColor(health: string): string { switch (health) { case "ONLINE": return "bg-green-100" case "DEGRADED": return "bg-yellow-100" case "FAULTED": case "OFFLINE": case "UNAVAIL": return "bg-red-100" default: return "bg-gray-100" } } export function cn(...classes: (string | undefined | null | false)[]): string { return classes.filter(Boolean).join(" ") }