import { jsx as n } from "../../../../../preact@10.29.0/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import m from "classnames";
import { useRef as k, useLayoutEffect as I } from "../../../../../preact@10.29.0/node_modules/preact/hooks/dist/hooks.module.js";
import { C as v } from "./StoreProvider-CBB99upB.js";
import { Fragment as E } from "../../../../../preact@10.29.0/node_modules/preact/dist/preact.module.js";
try {
  let a = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {}, t = new a.Error().stack;
  t && (a._sentryDebugIds = a._sentryDebugIds || {}, a._sentryDebugIds[t] = "afc7bf04-4e17-406f-8df8-1a2318b7349d", a._sentryDebugIdIdentifier = "sentry-dbid-afc7bf04-4e17-406f-8df8-1a2318b7349d");
} catch {
}
const D = {
  arrowDown: "ArrowDown",
  arrowUp: "ArrowUp",
  enter: "Enter",
  escape: "Escape",
  space: " ",
  tab: "Tab",
  backspace: "Backspace",
  home: "Home",
  end: "End"
}, B = "adyen-kyc-modal", L = "adyen-kyc-modal-small", S = "adyen-kyc-modal-medium", T = "adyen-kyc-modal-large", M = "adyen-kyc-modal-body", _ = "adyen-kyc-modal-body-height", A = "adyen-kyc-modal-transition-slide-in", C = "adyen-kyc-modal-transition-drop-in", K = "adyen-kyc-modal-inset", x = "adyen-kyc-modal-button", e = {
  modal: B,
  modalSmall: L,
  modalMedium: S,
  modalLarge: T,
  modalBody: M,
  modalBodyHeight: _,
  modalTransitionSlideIn: A,
  modalTransitionDropIn: C,
  modalInset: K,
  modalButton: x
}, j = ({
  ariaLabel: a,
  children: t,
  inset: y = !1,
  onClose: d,
  showCloseButton: u = !0,
  size: s = "medium",
  transition: f = "slideIn"
}) => {
  const r = k(null), b = d !== void 0 && u;
  I(() => {
    const o = r.current;
    if (!o) return;
    const c = (l) => {
      l.preventDefault(), d?.();
    }, i = (l) => {
      l.key === D.escape && (l.preventDefault(), d?.());
    };
    try {
      o.addEventListener("keydown", i), o.addEventListener("cancel", c), o.showModal();
    } catch {
      console.warn(
        "Could not call `showModal()` on the <dialog>; likely it was already removed from the document."
      );
      return;
    }
    return o.focus(), o.blur(), () => {
      o.removeEventListener("cancel", c), o.removeEventListener("keydown", i), o.close();
    };
  }, []);
  const p = {
    slideIn: e.modalTransitionSlideIn,
    dropIn: e.modalTransitionDropIn
  }, h = {
    small: e.modalSmall,
    medium: e.modalMedium,
    large: e.modalLarge,
    fullscreen: null
  }, g = m(e.modal, p[f], h[s]), w = m(e.modalBody, {
    [e.modalInset]: y,
    [e.modalBodyHeight]: s !== "small"
  });
  return /* @__PURE__ */ n(E, { children: [
    /* @__PURE__ */ n("style", { children: "html,body { overflow: hidden !important; }" }),
    /* @__PURE__ */ n("dialog", { "aria-label": a, className: g, onClose: d, ref: r, children: [
      b && /* @__PURE__ */ n("div", { className: e.modalButton, children: /* @__PURE__ */ n(
        v,
        {
          ariaLabel: "Close",
          circle: !0,
          icon: "cross",
          onClick: d,
          variant: "surface"
        }
      ) }),
      /* @__PURE__ */ n("div", { className: w, "data-testid": "modal-body", children: t })
    ] })
  ] });
};
export {
  D as K,
  j as M
};
