import { jsx as o } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useCallback as L, useMemo as u } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { TypographyElement as a, TypographyVariant as p } from "../../../../internal/Typography/types.js";
import s from "../../../../internal/Typography/Typography.js";
import g from "../../../../internal/Button/ButtonActions/ButtonActions.js";
import k from "../../../../../hooks/useMutation/useMutation.js";
import { ButtonVariant as m } from "../../../../internal/Button/types.js";
import { useModalContext as x } from "../../../../internal/Modal/Modal.js";
/* empty css                           */
import { Alert as B } from "../../../../internal/Alert/Alert.js";
import { AlertTypeOption as C } from "../../../../internal/Alert/types.js";
import T from "../../../../../core/Context/preact/useCoreContext.js";
import { useConfigContext as E } from "../../../../../core/ConfigContext/preact/context.js";
import { EMPTY_OBJECT as I } from "../../../../../utils/value/constants.js";
const h = {
  root: "adyen-pe-payment-link-expiration"
}, w = ({ paymentLink: n, onCancel: e, onExpirationSuccess: l }) => {
  const { i18n: t } = T(), { withinModal: d } = x(), y = d ? a.H2 : a.DIV, { expirePayByLinkPaymentLink: c } = E().endpoints, i = k({
    queryFn: c,
    options: {
      onSuccess: l
    }
  }), r = L(
    () => i.mutate(I, { path: { paymentLinkId: n.linkInformation.paymentLinkId } }),
    [i, n.linkInformation.paymentLinkId]
  ), f = u(
    () => [
      {
        title: t.get("payByLink.details.expiration.actions.confirmExpiration"),
        event: r,
        variant: m.PRIMARY,
        disabled: i.isLoading,
        state: i.isLoading ? "loading" : "default"
      },
      {
        title: t.get("payByLink.details.expiration.actions.goBack"),
        event: e,
        variant: m.SECONDARY,
        disabled: i.isLoading
      }
    ],
    [i.isLoading, r, t, e]
  );
  return /* @__PURE__ */ o("div", { className: h.root, children: [
    /* @__PURE__ */ o(s, { el: y, variant: p.SUBTITLE, stronger: !0, children: t.get("payByLink.details.expiration.title") }),
    /* @__PURE__ */ o(s, { variant: p.BODY, children: t.get("payByLink.details.expiration.description") }),
    i.error && /* @__PURE__ */ o(
      B,
      {
        type: C.CRITICAL,
        title: t.get("payByLink.details.expiration.errorTitle"),
        description: t.get("payByLink.details.expiration.errorDescription")
      }
    ),
    /* @__PURE__ */ o(g, { actions: f })
  ] });
};
export {
  w as PaymentLinkExpiration
};
