// (C) 2025-2026 GoodData Corporation
import { useEffect } from "react";
const DEFAULT_CURRENCY_FORMAT = "$#,##0.00";
/**
 * @internal
 *
 * Bootstraps a default format for currency metrics when no format is set.
 * - When no format is set yet (`shouldBootstrap` is true), it applies the inherited override
 *   or the standard currency preset.
 * - Custom formats are always preserved and never coerced.
 */
export function useCurrencyFormatDefaults({ metricType, currencyFormatOverride, onFormatChange, shouldBootstrap, fallbackFormat = DEFAULT_CURRENCY_FORMAT, }) {
    useEffect(() => {
        if (metricType !== "CURRENCY" || !shouldBootstrap) {
            return;
        }
        onFormatChange(resolveDefaultFormat(currencyFormatOverride, fallbackFormat));
    }, [currencyFormatOverride, fallbackFormat, metricType, onFormatChange, shouldBootstrap]);
}
function resolveDefaultFormat(currencyFormatOverride, fallbackFormat) {
    return currencyFormatOverride ? null : fallbackFormat;
}
