"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxDevRuntime = require("react/jsx-dev-runtime");
const reactBinding = require("@contember/react-binding");
const reactClient = require("@contember/react-client");
const ui = require("@contember/ui");
const reactI18n = require("@contember/react-i18n");
const OutdatedApplicationChecker = require("./Application/OutdatedApplicationChecker.cjs");
const DevBar = require("./Dev/DevBar.cjs");
const DataViewPageNameKeyProvider = require("./DataViewPageNameKeyProvider.cjs");
const reactIdentity = require("@contember/react-identity");
const NavigationProvider = require("./NavigationProvider/NavigationProvider.cjs");
const IdentityProvider = require("./Identity/IdentityProvider.cjs");
const reactRouting = require("@contember/react-routing");
const validateProps = (props) => {
  if (typeof props.apiBaseUrl !== "string") {
    throw new Error(`The ENV variables haven't been set. Check your \`.env.development.local\` file.`);
  }
};
const ApplicationEntrypoint = (props) => {
  validateProps(props);
  const projectSlug = props.project === "__PROJECT_SLUG__" ? window.location.pathname.split("/")[1] : props.project;
  const basePath = props.basePath === "./" ? `/${projectSlug}/` : props.basePath ?? "/";
  const routing = {
    basePath,
    routes: props.routes ?? { index: { path: "/" } },
    defaultDimensions: props.defaultDimensions
  };
  const rootEnv = reactBinding.Environment.create().withVariables(props.envVariables).withDimensions(props.defaultDimensions ?? {});
  const Providers = props.providers ?? ui.Providers;
  return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.EnvironmentContext.Provider, { value: rootEnv, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactI18n.I18nProvider, { localeCode: props.defaultLocale, dictionaries: props.dictionaries, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactRouting.RoutingContext.Provider, { value: routing, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactRouting.RequestProvider, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(
    reactClient.ContemberClient,
    {
      apiBaseUrl: props.apiBaseUrl,
      sessionToken: props.sessionToken,
      loginToken: props.loginToken,
      project: projectSlug,
      stage: props.stage,
      children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.EnvironmentExtensionProvider, { extension: reactIdentity.projectEnvironmentExtension, state: projectSlug ?? null, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(DataViewPageNameKeyProvider.DataViewPageNameKeyProvider, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(NavigationProvider.NavigationProvider, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(IdentityProvider.IdentityProvider, { onInvalidIdentity: props.onInvalidIdentity, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(Providers, { portalProviderProps: props.portalProviderProps, styleProviderProps: props.styleProviderProps, children: [
        /* @__PURE__ */ jsxDevRuntime.jsxDEV(OutdatedApplicationChecker.OutdatedApplicationChecker, {}, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/components/ApplicationEntrypoint.tsx",
          lineNumber: 75,
          columnNumber: 13
        }, void 0),
        props.children,
        /* @__PURE__ */ jsxDevRuntime.jsxDEV(DevBar.ApplicationDevBar, { panels: props.devBarPanels }, void 0, false, {
          fileName: "/__w/interface/interface/packages/admin/src/components/ApplicationEntrypoint.tsx",
          lineNumber: 77,
          columnNumber: 13
        }, void 0)
      ] }, void 0, true, {
        fileName: "/__w/interface/interface/packages/admin/src/components/ApplicationEntrypoint.tsx",
        lineNumber: 74,
        columnNumber: 12
      }, void 0) }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/components/ApplicationEntrypoint.tsx",
        lineNumber: 73,
        columnNumber: 11
      }, void 0) }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/components/ApplicationEntrypoint.tsx",
        lineNumber: 72,
        columnNumber: 10
      }, void 0) }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/components/ApplicationEntrypoint.tsx",
        lineNumber: 71,
        columnNumber: 9
      }, void 0) }, void 0, false, {
        fileName: "/__w/interface/interface/packages/admin/src/components/ApplicationEntrypoint.tsx",
        lineNumber: 70,
        columnNumber: 8
      }, void 0)
    },
    void 0,
    false,
    {
      fileName: "/__w/interface/interface/packages/admin/src/components/ApplicationEntrypoint.tsx",
      lineNumber: 63,
      columnNumber: 7
    },
    void 0
  ) }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/ApplicationEntrypoint.tsx",
    lineNumber: 62,
    columnNumber: 6
  }, void 0) }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/ApplicationEntrypoint.tsx",
    lineNumber: 61,
    columnNumber: 5
  }, void 0) }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/ApplicationEntrypoint.tsx",
    lineNumber: 60,
    columnNumber: 4
  }, void 0) }, void 0, false, {
    fileName: "/__w/interface/interface/packages/admin/src/components/ApplicationEntrypoint.tsx",
    lineNumber: 59,
    columnNumber: 3
  }, void 0);
};
exports.ApplicationEntrypoint = ApplicationEntrypoint;
//# sourceMappingURL=ApplicationEntrypoint.cjs.map
