;
{
  try {
    let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
    n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "5d757496-66d0-414d-a887-4113c47ab91a", e._sentryDebugIdIdentifier = "sentry-dbid-5d757496-66d0-414d-a887-4113c47ab91a");
  } catch (e) {
  }
}
;
import { jsx, jsxs } from "preact/jsx-runtime";
import { useState, useEffect } from "preact/hooks";
import { u as useTranslation, p as useAnalyticsContext, z as Typography, V as Button } from "./StoreProvider-CqQrndhS.js";
import { M as Modal } from "./Modal-1lLoobr9.js";
const confirm = "adyen-kyc-confirm";
const confirmMessage = "adyen-kyc-confirm-message";
const confirmActions = "adyen-kyc-confirm-actions";
const styles = {
  confirm,
  confirmMessage,
  confirmActions
};
const Confirm = ({
  description,
  cancelText,
  confirmText,
  critical = false,
  onCancel,
  onConfirm,
  title,
  analyticsEventLabel
}) => {
  const { t } = useTranslation("ui");
  const userEvents = useAnalyticsContext();
  const [isInFlight, setIsInFlight] = useState(false);
  const showCancelButton = onCancel !== void 0;
  const buttonVariant = critical ? "critical" : "primary";
  useEffect(() => {
    userEvents.addTaskEvent("Opened modal", {
      actionType: "open",
      label: analyticsEventLabel
    });
  }, []);
  const handleConfirm = async () => {
    setIsInFlight(true);
    try {
      await onConfirm();
    } finally {
      setIsInFlight(false);
    }
  };
  return /* @__PURE__ */ jsx(Modal, { size: "small", transition: "dropIn", showCloseButton: false, ariaLabel: title, children: /* @__PURE__ */ jsxs("div", { className: styles.confirm, children: [
    /* @__PURE__ */ jsxs("div", { className: styles.confirmMessage, children: [
      /* @__PURE__ */ jsx(Typography, { variant: "title", el: "h3", children: title }),
      description && /* @__PURE__ */ jsx(Typography, { variant: "body", el: "p", children: description })
    ] }),
    /* @__PURE__ */ jsxs("div", { className: styles.confirmActions, children: [
      showCancelButton && /* @__PURE__ */ jsx(Button, { onClick: onCancel, variant: "secondary", disabled: isInFlight, children: cancelText ?? t(($) => $["cancel"]) }),
      /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, variant: buttonVariant, loading: isInFlight, children: confirmText ?? t(($) => $["confirm"]) })
    ] })
  ] }) });
};
export {
  Confirm as C
};
