/**
 * Format a byte count into a human-readable file size string.
 * Uses binary units (1 KB = 1024 bytes).
 */
const formatFileSize = (bytes) => {
    if (bytes === 0)
        return "0 Bytes";
    const k = 1024;
    const sizes = ["Bytes", "KB", "MB", "GB"];
    const i = Math.floor(Math.log(bytes) / Math.log(k));
    return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + " " + sizes[i];
};
/**
 * Extract the file extension from a filename, lowercase.
 * Returns null if no extension is present.
 */
const getFileExtension = (filename) => {
    const dotIndex = filename.lastIndexOf(".");
    if (dotIndex === -1 || dotIndex === filename.length - 1)
        return null;
    return filename.slice(dotIndex + 1).toLowerCase();
};

export { formatFileSize, getFileExtension };
