import { jsx as e } from "../../../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import S from "../../../TermsAndConditions/TermsAndConditionsContainer.js";
import f from "../../../PaymentLinkThemeContainer/PaymentLinkThemeContainer.js";
import { MenuItem as i } from "../../context/constants.js";
import { useResponsiveContainer as C, containerQueries as E } from "../../../../../../../hooks/useResponsiveContainer.js";
import { Alert as m } from "../../../../../../internal/Alert/Alert.js";
import { AlertVariantOption as a, AlertTypeOption as p } from "../../../../../../internal/Alert/types.js";
import g from "../../context/context.js";
import _ from "../PaymentLinkSettingsContentLoading/PaymentLinkSettingsContentLoading.js";
import { useSettingsPermission as k } from "../../../../hooks/useSettingsPermission.js";
import c from "../SettingsError/SettingsError.js";
import { useMemo as L } from "../../../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { PERMISSION_ERROR as R } from "../../utils/getSettingsErrorMessage.js";
import I from "../../../../../../../core/Context/preact/useCoreContext.js";
const A = "payByLink.settings.theme.errors.couldNotLoad", v = "payByLink.settings.termsAndConditions.errors.couldNotLoad", T = ({ activeMenuItem: o, isLoadingContent: s }) => {
  const { themeEnabled: t, termsAndConditionsEnabled: n } = k(), r = L(() => {
    if (!(t && n))
      return {
        errorCode: R,
        type: "error",
        requestId: ""
      };
  }, [t, n]);
  if (s)
    return /* @__PURE__ */ e(_, { activeMenuItem: o });
  switch (o) {
    case i.theme:
      return t ? /* @__PURE__ */ e(f, {}) : /* @__PURE__ */ e(c, { error: r, errorMessage: A });
    case i.termsAndConditions:
      return n ? /* @__PURE__ */ e(S, {}) : /* @__PURE__ */ e(c, { error: r, errorMessage: v });
    default:
      return null;
  }
}, q = ({ activeMenuItem: o, isLoadingContent: s, navigateBack: t }) => {
  const n = C(E.down.xs), { i18n: r } = I(), { isSaveSuccess: d, isSaveError: l, setIsSaveSuccess: u, setIsSaveError: y } = g();
  return /* @__PURE__ */ e("div", { className: n ? "adyen-pe-payment-link-settings__content-item--mobile" : "adyen-pe-payment-link-settings__content-item", children: [
    /* @__PURE__ */ e(T, { activeMenuItem: o, isLoadingContent: s }),
    d && !t && /* @__PURE__ */ e(
      m,
      {
        type: p.SUCCESS,
        variant: a.TIP,
        onClose: () => u(!1),
        description: r.get("payByLink.settings.common.alerts.saveSuccess"),
        className: "adyen-pe-payment-link-settings__content-item--alert"
      }
    ),
    l && /* @__PURE__ */ e(
      m,
      {
        type: p.CRITICAL,
        variant: a.TIP,
        onClose: () => y(!1),
        description: r.get("payByLink.settings.common.alerts.saveError"),
        className: "adyen-pe-payment-link-settings__content-item--alert"
      }
    )
  ] });
};
export {
  q as default
};
