UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

35 lines (34 loc) 1.62 kB
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 };