import { jsx as n } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { toChildArray as p, createContext as l } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/dist/preact.module.js";
import { useContext as u, useState as g, useMemo as C, useEffect as d } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { ErrorMessageDisplay as h } from "../../../components/internal/ErrorMessageDisplay/ErrorMessageDisplay.js";
import { createConfigController as x } from "../setupConfig.js";
import E from "../session/utils/sessionAwareComponentAvailability/helpers/componentAvailabilityErrors.js";
import { noop as v, asyncNoop as P } from "../../../utils/common.js";
import { isUndefined as S } from "../../../utils/value/is.js";
import { EMPTY_OBJECT as s } from "../../../utils/value/constants.js";
const i = l({
  endpoints: s,
  extraConfig: s,
  hasError: !1,
  http: P,
  isExpired: void 0,
  isFrozen: !1,
  refresh: v,
  refreshing: !1
}), z = ({ children: a, session: e, type: o }) => {
  const [, m] = g(0), r = C(() => x(e, o), [e, o]), { contextValue: f, hasPermission: t } = r.getSnapshot();
  return d(() => r.connect(() => m((c) => c + 1)), [r]), /* @__PURE__ */ n(i.Provider, { value: f, children: !S(t) && (t ? p(a) : /* @__PURE__ */ n(
    h,
    {
      withImage: !0,
      centered: !0,
      title: "common.errors.somethingWentWrong",
      message: [E(o), "common.errors.contactSupport"]
    }
  )) });
}, B = () => u(i);
export {
  z as ConfigProvider,
  B as useConfigContext
};
