;
{
  try {
    let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
    n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "85ddc323-9284-4dcb-bbf7-5bcd20139dcd", e._sentryDebugIdIdentifier = "sentry-dbid-85ddc323-9284-4dcb-bbf7-5bcd20139dcd");
  } catch (e) {
  }
}
;
import { jsxs, jsx } from "preact/jsx-runtime";
import { ag as refreshSession, V as Button, L as Loader, S as SettingsProvider, Q as QueryClientProvider, A as ApiProvider, E as ExperimentsContextProvider, d as StoreProvider, e as AnalyticsProvider, I as I18nProvider, D as DebugListener, T as ToastContextProvider, f as StateProvider, h as setSdkTokenHandler, n as normalizeEnvironment } from "./StoreProvider-CqQrndhS.js";
import { useState, useEffect } from "preact/hooks";
const sheet = new CSSStyleSheet();
const stylesheets = [sheet];
{
  import("./styles-CLV89_hH.js").then(({ css }) => {
    sheet.replaceSync(css);
  }).catch((err) => console.error("Error loading styles", err));
}
const EmbedShell = ({
  children,
  rootLegalEntityId,
  settings,
  experiments,
  // HO-only
  refreshExperiments,
  // HO-only
  baseUrl,
  getSdkToken,
  componentName,
  locale
}) => {
  const [isLoading, setIsLoading] = useState(true);
  const [hasError, setHasError] = useState(false);
  setSdkTokenHandler(getSdkToken);
  useEffect(() => {
    refreshSession().then((hasRefreshed) => {
      if (!hasRefreshed) {
        setHasError(true);
      }
      setIsLoading(false);
    });
  }, []);
  if (hasError) {
    return /* @__PURE__ */ jsxs("div", { children: [
      "Something went wrong, please",
      /* @__PURE__ */ jsx(Button, { onClick: () => location.reload(), children: "refresh the page." })
    ] });
  }
  if (isLoading) {
    return /* @__PURE__ */ jsx(Loader, {});
  }
  return /* @__PURE__ */ jsx(SettingsProvider, { settings, children: /* @__PURE__ */ jsx(QueryClientProvider, { children: /* @__PURE__ */ jsx(ApiProvider, { rootLegalEntityId, baseUrl, children: /* @__PURE__ */ jsx(
    ExperimentsContextProvider,
    {
      experiments,
      refreshExperiments,
      children: /* @__PURE__ */ jsxs(StoreProvider, { children: [
        /* @__PURE__ */ jsx("span", { className: "adyen-kyc__sdk-version", hidden: true, children: "3.95.1" }),
        /* @__PURE__ */ jsx(
          AnalyticsProvider,
          {
            componentName,
            rootLegalEntityId,
            children: /* @__PURE__ */ jsxs(I18nProvider, { locale, children: [
              /* @__PURE__ */ jsx(DebugListener, {}),
              /* @__PURE__ */ jsx("div", { className: "adyen-kyc-ui-element-container-wrapper", children: /* @__PURE__ */ jsx("div", { className: "adyen-kyc-ui-element-container", children: /* @__PURE__ */ jsx(ToastContextProvider, { children: /* @__PURE__ */ jsx(StateProvider, { children }) }) }) })
            ] })
          }
        )
      ] })
    }
  ) }) }) });
};
const environmentMap = Object.freeze({
  live: "https://onboardingcomponents-live.adyen.com/",
  test: "https://test.adyen.com/"
});
const resolveEnvironment = (environment) => environmentMap[environment] ?? normalizeEnvironment(environment);
export {
  EmbedShell as E,
  resolveEnvironment as r,
  stylesheets as s
};
