export function formatElapsedMs(ms) {
    if (!Number.isFinite(ms) || ms < 0)
        return "unknown";
    const totalSeconds = Math.max(0, Math.floor(ms / 1000));
    if (totalSeconds < 10)
        return `${(ms / 1000).toFixed(1)}s`;
    if (totalSeconds < 60)
        return `${totalSeconds}s`;
    const hours = Math.floor(totalSeconds / 3600);
    const minutes = Math.floor((totalSeconds % 3600) / 60);
    const seconds = totalSeconds % 60;
    const parts = [];
    if (hours > 0)
        parts.push(`${hours}h`);
    if (minutes > 0 || hours > 0)
        parts.push(`${minutes}m`);
    parts.push(`${seconds}s`);
    return parts.join(" ");
}
export function formatBytes(bytes) {
    if (!Number.isFinite(bytes) || bytes < 0)
        return "unknown";
    const rounded = Math.floor(bytes);
    if (rounded < 1024)
        return `${rounded} B`;
    const units = ["KB", "MB", "GB", "TB"];
    let value = rounded / 1024;
    let unitIndex = 0;
    while (value >= 1024 && unitIndex < units.length - 1) {
        value /= 1024;
        unitIndex += 1;
    }
    return `${value.toFixed(value >= 10 ? 0 : 1)} ${units[unitIndex]}`;
}
export function formatBytesPerSecond(bytesPerSecond) {
    if (!Number.isFinite(bytesPerSecond) || bytesPerSecond < 0)
        return "unknown";
    return `${formatBytes(Math.round(bytesPerSecond))}/s`;
}
export function formatMinutesSmart(valueMinutes) {
    if (!Number.isFinite(valueMinutes))
        return "unknown";
    const minutes = Math.max(0, valueMinutes);
    const decimals = minutes >= 10 ? 0 : 1;
    const formatted = minutes.toFixed(decimals);
    const trimmed = formatted.endsWith(".0") ? formatted.slice(0, -2) : formatted;
    return `${trimmed} min`;
}
export function formatDurationSecondsSmart(value) {
    if (!Number.isFinite(value))
        return "unknown";
    const totalSeconds = Math.max(0, Math.round(value));
    const hours = Math.floor(totalSeconds / 3600);
    const minutes = Math.floor((totalSeconds % 3600) / 60);
    const seconds = totalSeconds % 60;
    const parts = [];
    if (hours > 0)
        parts.push(`${hours}h`);
    if (minutes > 0 || hours > 0)
        parts.push(`${minutes}m`);
    if (seconds > 0 || parts.length === 0)
        parts.push(`${seconds}s`);
    return parts.join(" ");
}
export { formatCompactCount } from "../shared/format-count.js";
//# sourceMappingURL=format.js.map