import M from "../../@babel/runtime/helpers/esm/defineProperty.mjs";
import y from "../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import re from "../../@babel/runtime/helpers/esm/toConsumableArray.mjs";
import w from "../../@babel/runtime/helpers/esm/extends.mjs";
import R from "../../@babel/runtime/helpers/esm/objectWithoutProperties.mjs";
import oe from "../../@babel/runtime/helpers/esm/classCallCheck.mjs";
import ae from "../../@babel/runtime/helpers/esm/createClass.mjs";
import ie from "../../@babel/runtime/helpers/esm/inherits.mjs";
import le from "../../@babel/runtime/helpers/esm/createSuper.mjs";
import ce from "../../classnames/index.mjs";
import me from "../../rc-overflow/es/Overflow.mjs";
import se from "../../rc-util/es/KeyCode.mjs";
import ue from "../../rc-util/es/omit.mjs";
import { useComposeRef as fe } from "../../rc-util/es/ref.mjs";
import { warningOnce as S } from "../../rc-util/es/warning.mjs";
import * as n from "react";
import { useMenuId as de } from "./context/IdContext.mjs";
import { MenuContext as ve } from "./context/MenuContext.mjs";
import { useMeasure as ye, useFullPath as O } from "./context/PathContext.mjs";
import Ie from "./context/PrivateContext.mjs";
import pe from "./hooks/useActive.mjs";
import Ce from "./hooks/useDirectionStyle.mjs";
import _e from "./Icon.mjs";
import { warnItemProp as L } from "./utils/warnUtil.mjs";
var Ke = ["title", "attribute", "elementRef"], be = ["style", "className", "eventKey", "warnKey", "disabled", "itemIcon", "children", "role", "onMouseEnter", "onMouseLeave", "onClick", "onKeyDown", "onFocus"], he = ["active"], Me = /* @__PURE__ */ function(e) {
  ie(t, e);
  var m = le(t);
  function t() {
    return oe(this, t), m.apply(this, arguments);
  }
  return ae(t, [{
    key: "render",
    value: function() {
      var r = this.props, o = r.title, f = r.attribute, s = r.elementRef, I = R(r, Ke), p = ue(I, ["eventKey", "popupClassName", "popupOffset", "onTitleClick"]);
      return S(!f, "`attribute` of Menu.Item is deprecated. Please pass attribute directly."), /* @__PURE__ */ n.createElement(me.Item, w({}, f, {
        title: typeof o == "string" ? o : void 0
      }, p, {
        ref: s
      }));
    }
  }]), t;
}(n.Component), Re = /* @__PURE__ */ n.forwardRef(function(e, m) {
  var t, i = e.style, r = e.className, o = e.eventKey, f = e.warnKey, s = e.disabled, I = e.itemIcon, p = e.children, x = e.role, $ = e.onMouseEnter, j = e.onMouseLeave, c = e.onClick, C = e.onKeyDown, _ = e.onFocus, T = R(e, be), E = de(o), l = n.useContext(ve), V = l.prefixCls, P = l.onItemClick, W = l.disabled, q = l.overflowDisabled, z = l.itemIcon, B = l.selectedKeys, G = l.onActive, H = n.useContext(Ie), g = H._internalRenderMenuItem, d = "".concat(V, "-item"), k = n.useRef(), J = n.useRef(), K = W || s, Q = fe(m, J), D = O(o);
  process.env.NODE_ENV !== "production" && f && S(!1, "MenuItem should not leave undefined `key`.");
  var N = function(a) {
    return {
      key: o,
      // Note: For legacy code is reversed which not like other antd component
      keyPath: re(D).reverse(),
      item: k.current,
      domEvent: a
    };
  }, U = I || z, F = pe(o, K, $, j), X = F.active, Y = R(F, he), v = B.includes(o), Z = Ce(D.length), ee = function(a) {
    if (!K) {
      var u = N(a);
      c == null || c(L(u)), P(u);
    }
  }, te = function(a) {
    if (C == null || C(a), a.which === se.ENTER) {
      var u = N(a);
      c == null || c(L(u)), P(u);
    }
  }, ne = function(a) {
    G(o), _ == null || _(a);
  }, A = {};
  e.role === "option" && (A["aria-selected"] = v);
  var b = /* @__PURE__ */ n.createElement(Me, w({
    ref: k,
    elementRef: Q,
    role: x === null ? "none" : x || "menuitem",
    tabIndex: s ? null : -1,
    "data-menu-id": q && E ? null : E
  }, T, Y, A, {
    component: "li",
    "aria-disabled": s,
    style: y(y({}, Z), i),
    className: ce(d, (t = {}, M(t, "".concat(d, "-active"), X), M(t, "".concat(d, "-selected"), v), M(t, "".concat(d, "-disabled"), K), t), r),
    onClick: ee,
    onKeyDown: te,
    onFocus: ne
  }), p, /* @__PURE__ */ n.createElement(_e, {
    props: y(y({}, e), {}, {
      isSelected: v
    }),
    icon: U
  }));
  return g && (b = g(b, e, {
    selected: v
  })), b;
});
function we(e, m) {
  var t = e.eventKey, i = ye(), r = O(t);
  return n.useEffect(function() {
    if (i)
      return i.registerPath(t, r), function() {
        i.unregisterPath(t, r);
      };
  }, [r]), i ? null : /* @__PURE__ */ n.createElement(Re, w({}, e, {
    ref: m
  }));
}
const Qe = /* @__PURE__ */ n.forwardRef(we);
export {
  Qe as default
};
