import G from "../../../../@babel/runtime/helpers/esm/extends.mjs";
import i from "../../../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import d from "../../../../classnames/index.mjs";
import { useComposeRef as J } from "../../../../rc-util/es/ref.mjs";
import t, { useRef as g } from "react";
import { RefContext as K } from "../../context.mjs";
import L from "./MemoChildren.mjs";
var w = {
  width: 0,
  height: 0,
  overflow: "hidden",
  outline: "none"
}, Q = /* @__PURE__ */ t.forwardRef(function(e, x) {
  var n = e.prefixCls, S = e.className, _ = e.style, r = e.title, m = e.ariaId, u = e.footer, I = e.closable, M = e.closeIcon, D = e.onClose, P = e.children, U = e.bodyStyle, k = e.bodyProps, v = e.modalRender, A = e.onMouseDown, $ = e.onMouseUp, j = e.holderRef, H = e.visible, O = e.forceRender, h = e.width, y = e.height, o = e.classNames, l = e.styles, V = t.useContext(K), q = V.panel, z = J(j, q), c = g(), s = g();
  t.useImperativeHandle(x, function() {
    return {
      focus: function() {
        var a;
        (a = c.current) === null || a === void 0 || a.focus();
      },
      changeActive: function(a) {
        var F = document, C = F.activeElement;
        a && C === s.current ? c.current.focus() : !a && C === c.current && s.current.focus();
      }
    };
  });
  var f = {};
  h !== void 0 && (f.width = h), y !== void 0 && (f.height = y);
  var b;
  u && (b = /* @__PURE__ */ t.createElement("div", {
    className: d("".concat(n, "-footer"), o == null ? void 0 : o.footer),
    style: i({}, l == null ? void 0 : l.footer)
  }, u));
  var N;
  r && (N = /* @__PURE__ */ t.createElement("div", {
    className: d("".concat(n, "-header"), o == null ? void 0 : o.header),
    style: i({}, l == null ? void 0 : l.header)
  }, /* @__PURE__ */ t.createElement("div", {
    className: "".concat(n, "-title"),
    id: m
  }, r)));
  var R;
  I && (R = /* @__PURE__ */ t.createElement("button", {
    type: "button",
    onClick: D,
    "aria-label": "Close",
    className: "".concat(n, "-close")
  }, M || /* @__PURE__ */ t.createElement("span", {
    className: "".concat(n, "-close-x")
  })));
  var E = /* @__PURE__ */ t.createElement("div", {
    className: d("".concat(n, "-content"), o == null ? void 0 : o.content),
    style: l == null ? void 0 : l.content
  }, R, N, /* @__PURE__ */ t.createElement("div", G({
    className: d("".concat(n, "-body"), o == null ? void 0 : o.body),
    style: i(i({}, U), l == null ? void 0 : l.body)
  }, k), P), b);
  return /* @__PURE__ */ t.createElement("div", {
    key: "dialog-element",
    role: "dialog",
    "aria-labelledby": r ? m : null,
    "aria-modal": "true",
    ref: z,
    style: i(i({}, _), f),
    className: d(n, S),
    onMouseDown: A,
    onMouseUp: $
  }, /* @__PURE__ */ t.createElement("div", {
    tabIndex: 0,
    ref: c,
    style: w,
    "aria-hidden": "true"
  }), /* @__PURE__ */ t.createElement(L, {
    shouldUpdate: H || O
  }, v ? v(E) : E), /* @__PURE__ */ t.createElement("div", {
    tabIndex: 0,
    ref: s,
    style: w,
    "aria-hidden": "true"
  }));
});
process.env.NODE_ENV !== "production" && (Q.displayName = "Panel");
export {
  Q as default
};
