// Kept in sync with Document::ALLOWED_EXTENSIONS on the backend.
export const ACCEPTED_FILE_EXTENSIONS = '.jpeg,.jpg,.png,.pdf,.doc,.docx';

// Sentinel option: the select cannot hold an empty string as a value.
export const ALL_TYPES_VALUE = 'all';

/**
 * Format a size in bytes into a short human readable string.
 */
export function formatFileSize(bytes: number): string {
    if (bytes < 1024) {
        return `${bytes} B`;
    }
    if (bytes < 1024 * 1024) {
        return `${Math.round(bytes / 1024)} KB`;
    }
    return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
}
