import * as a from "react";
import Y from "../../../@ant-design/icons/es/icons/CloseOutlined.mjs";
import f from "../../../classnames/index.mjs";
import q from "../../../rc-dialog/es/DialogWrap.mjs";
import "../../../rc-dialog/es/Dialog/Content/Panel.mjs";
import B from "../_util/hooks/useClosable.mjs";
import { getTransitionName as N } from "../_util/motion.mjs";
import { canUseDocElement as G } from "../_util/styleChecker.mjs";
import { devUseWarning as H } from "../_util/warning.mjs";
import J from "../_util/zindexContext.mjs";
import "../config-provider/index.mjs";
import { NoFormStyle as K } from "../form/context.mjs";
import { NoCompactStyle as Q } from "../space/Compact.mjs";
import { usePanelRef as ee } from "../watermark/context.mjs";
import { Footer as oe, renderCloseIcon as te } from "./shared.mjs";
import se from "./style/index.mjs";
import { useZIndex as ne } from "../_util/hooks/useZIndex.mjs";
import le from "../config-provider/hooks/useCSSVarCls.mjs";
import { ConfigContext as re } from "../config-provider/context.mjs";
var ae = globalThis && globalThis.__rest || function(e, i) {
  var c = {};
  for (var o in e)
    Object.prototype.hasOwnProperty.call(e, o) && i.indexOf(o) < 0 && (c[o] = e[o]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var n = 0, o = Object.getOwnPropertySymbols(e); n < o.length; n++)
      i.indexOf(o[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[n]) && (c[o[n]] = e[o[n]]);
  return c;
};
let u;
const ie = (e) => {
  u = {
    x: e.pageX,
    y: e.pageY
  }, setTimeout(() => {
    u = null;
  }, 100);
};
G() && document.documentElement.addEventListener("click", ie, !0);
const ce = (e) => {
  var i;
  const {
    getPopupContainer: c,
    getPrefixCls: o,
    direction: n,
    modal: t
  } = a.useContext(re), p = (r) => {
    const {
      onCancel: s
    } = e;
    s == null || s(r);
  }, x = (r) => {
    const {
      onOk: s
    } = e;
    s == null || s(r);
  };
  if (process.env.NODE_ENV !== "production") {
    const r = H("Modal");
    [["visible", "open"], ["bodyStyle", "styles.body"], ["maskStyle", "styles.mask"]].forEach((s) => {
      let [y, X] = s;
      r.deprecated(!(y in e), y, X);
    });
  }
  const {
    prefixCls: O,
    className: P,
    rootClassName: w,
    open: m,
    wrapClassName: E,
    centered: I,
    getContainer: C,
    closeIcon: h,
    closable: j,
    focusTriggerAfterClose: S = !0,
    style: k,
    // Deprecated
    visible: T,
    width: z = 520,
    footer: _,
    classNames: M,
    styles: R
  } = e, d = ae(e, ["prefixCls", "className", "rootClassName", "open", "wrapClassName", "centered", "getContainer", "closeIcon", "closable", "focusTriggerAfterClose", "style", "visible", "width", "footer", "classNames", "styles"]), l = o("modal", O), g = o(), v = le(l), [V, b, $] = se(l, v), A = f(E, {
    [`${l}-centered`]: !!I,
    [`${l}-wrap-rtl`]: n === "rtl"
  }), D = _ !== null && /* @__PURE__ */ a.createElement(oe, Object.assign({}, e, {
    onOk: x,
    onCancel: p
  })), [F, U] = B(j, h, (r) => te(l, r), /* @__PURE__ */ a.createElement(Y, {
    className: `${l}-close-icon`
  }), !0), W = ee(`.${l}-content`), [Z, L] = ne("Modal", d.zIndex);
  return V(/* @__PURE__ */ a.createElement(Q, null, /* @__PURE__ */ a.createElement(K, {
    status: !0,
    override: !0
  }, /* @__PURE__ */ a.createElement(J.Provider, {
    value: L
  }, /* @__PURE__ */ a.createElement(q, Object.assign({
    width: z
  }, d, {
    zIndex: Z,
    getContainer: C === void 0 ? c : C,
    prefixCls: l,
    rootClassName: f(b, w, $, v),
    footer: D,
    visible: m ?? T,
    mousePosition: (i = d.mousePosition) !== null && i !== void 0 ? i : u,
    onClose: p,
    closable: F,
    closeIcon: U,
    focusTriggerAfterClose: S,
    transitionName: N(g, "zoom", e.transitionName),
    maskTransitionName: N(g, "fade", e.maskTransitionName),
    className: f(b, P, t == null ? void 0 : t.className),
    style: Object.assign(Object.assign({}, t == null ? void 0 : t.style), k),
    classNames: Object.assign(Object.assign({
      wrapper: A
    }, t == null ? void 0 : t.classNames), M),
    styles: Object.assign(Object.assign({}, t == null ? void 0 : t.styles), R),
    panelRef: W
  }))))));
}, je = ce;
export {
  je as default
};
