import { jsx as _jsx } from "react/jsx-runtime";
import { useContext, useMemo } from 'react';
import { windowIsAvailable } from '../../utils';
import { ConfigurationContext } from './Configuration';
const LocaleOverride = ({ children, calendar }) => {
    const context = windowIsAvailable
        ? window.cosmos.configurationContext ?? ConfigurationContext
        : ConfigurationContext;
    const ctx = useContext(context);
    const override = useMemo(() => {
        if (!calendar) {
            return ctx.locale;
        }
        return new Intl.Locale(ctx.locale, { calendar }).toString();
    }, [ctx.locale, calendar]);
    return (_jsx(context.Provider
    // eslint-disable-next-line react/jsx-no-constructed-context-values
    , { 
        // eslint-disable-next-line react/jsx-no-constructed-context-values
        value: { ...ctx, locale: override }, children: children }));
};
export default LocaleOverride;
//# sourceMappingURL=LocaleOverride.js.map