import { jsx } from "react/jsx-runtime";
import { StrictMode, Fragment } from "react";
import { Provider } from "react-redux";
import { ThemeProvider } from "styled-components";
import { getDefaultTheme } from "@elliemae/pui-theme";
import { AppRouter } from "../app-router.js";
import { isStandAloneGuest, isHost } from "../../utils/micro-frontend/index.js";
import { ErrorBoundary } from "../error-boundary/index.js";
import { StandAloneApp } from "./stand-alone-app.js";
import { HostedApp } from "./hosted-app.js";
const AppToRender = (props) => {
  const isParent = isStandAloneGuest() || isHost();
  return isParent ? /* @__PURE__ */ jsx(StandAloneApp, { ...props }) : /* @__PURE__ */ jsx(HostedApp, { ...props });
};
const AppRoot = ({
  store,
  history,
  basename,
  theme = getDefaultTheme(),
  manageSession = false,
  WaitMessage,
  errorTemplate,
  children,
  strictMode = true
}) => {
  const ParentEle = strictMode ? StrictMode : Fragment;
  return /* @__PURE__ */ jsx(ParentEle, { children: /* @__PURE__ */ jsx(ErrorBoundary, { errorTemplate, children: /* @__PURE__ */ jsx(Provider, { store, children: /* @__PURE__ */ jsx(AppRouter, { history, basename, children: /* @__PURE__ */ jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsx(
    AppToRender,
    {
      manageSession,
      WaitMessage,
      children
    }
  ) }) }) }) }) });
};
export {
  AppRoot
};
