import { jsx } from 'react/jsx-runtime';
import { t as themeStyles, T as ThemeProvider } from './ThemeProvider-D4KdGCaP.js';
import { createContext, useState, useMemo } from 'react';
import { c as cx } from './index-De1g9FRV.js';
import { u as useBreakpoint } from './useBreakpoint-CeaUyHxh.js';
import { a as useTranslations, L as LocalizationContext } from './LocalizationContext-UsmB5mnR.js';
import { T as TrackingProvider } from './TrackingProvider-Co4lyoI9.js';
import { u as useLayoutPropsUtil } from './useLayoutPropsUtil-CB_zHDbW.js';

import './AnvilProvider.css';const AnvilProviderContext = createContext(
  {}
);
const TooltipLegacyGroupContext = createContext(null);

const AnvilProvider = (props) => {
  const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
  const {
    themeData,
    localizationData,
    trackingIdData,
    children,
    className,
    style,
    ...rest
  } = componentProps;
  const {
    locale = "en",
    dir = "ltr",
    translations = {}
  } = localizationData ?? {};
  const { scope = "ST", optOut } = trackingIdData ?? {};
  const classNameCombined = cx(
    className,
    "anvil2",
    [themeStyles["theme-core"]],
    {
      [themeStyles["mode-dark"]]: themeData?.mode === "dark",
      [themeStyles["mode-light"]]: themeData?.mode === "light"
    }
  );
  const styleCombined = {
    ...style,
    ...layoutStyles
  };
  const breakpoint = useBreakpoint();
  const [disableDelayGroup, setDisableDelayGroup] = useState(false);
  const { translations: t } = useTranslations(translations);
  const localizationContextValue = useMemo(() => ({ locale, t }), [locale, t]);
  const tooltipLegacyGroupContextValue = useMemo(
    () => ({ disableDelayGroup: setDisableDelayGroup }),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [disableDelayGroup]
  );
  return /* @__PURE__ */ jsx(AnvilProviderContext.Provider, { value: { breakpoint }, children: /* @__PURE__ */ jsx(
    ThemeProvider,
    {
      className: classNameCombined,
      style: styleCombined,
      theme: themeData?.theme,
      mode: themeData?.mode,
      dir,
      ...rest,
      children: /* @__PURE__ */ jsx(
        TooltipLegacyGroupContext.Provider,
        {
          value: tooltipLegacyGroupContextValue,
          children: /* @__PURE__ */ jsx(LocalizationContext.Provider, { value: localizationContextValue, children: /* @__PURE__ */ jsx(TrackingProvider, { scope, optOut, children }) })
        }
      )
    }
  ) });
};

export { AnvilProvider as A, AnvilProviderContext as a };
//# sourceMappingURL=AnvilProvider-JXEbeQjR.js.map
