/** The size of a file for a person: bytes under a kilobyte, then KB and MB to one decimal; empty when unknown. */ export const formatFileSize = (bytes?: number): string => { if (!bytes) return ''; if (bytes < 1024) return `${bytes} B`; if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; };