import * as s from "react";
import { forwardRef as G } from "react";
import H from "../../../@ant-design/icons/es/icons/EllipsisOutlined.mjs";
import u from "../../../classnames/index.mjs";
import J from "../../../rc-menu/es/index.mjs";
import K from "../../../rc-util/es/hooks/useEvent.mjs";
import "../../../rc-util/es/hooks/useLayoutEffect.mjs";
import "../../../rc-util/node_modules/react-is/index.mjs";
import "../../../rc-util/es/warning.mjs";
import Q from "../../../rc-util/es/omit.mjs";
import X from "../_util/motion.mjs";
import { cloneElement as Y, isValidElement as Z } from "../_util/reactNode.mjs";
import { devUseWarning as ee } from "../_util/warning.mjs";
import "../config-provider/index.mjs";
import oe from "./hooks/useItems.mjs";
import le from "./MenuContext.mjs";
import P from "./OverrideContext.mjs";
import ne from "./style/index.mjs";
import te from "../config-provider/hooks/useCSSVarCls.mjs";
import { ConfigContext as ie } from "../config-provider/context.mjs";
var se = globalThis && globalThis.__rest || function(e, c) {
  var r = {};
  for (var o in e)
    Object.prototype.hasOwnProperty.call(e, o) && c.indexOf(o) < 0 && (r[o] = e[o]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var t = 0, o = Object.getOwnPropertySymbols(e); t < o.length; t++)
      c.indexOf(o[t]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[t]) && (r[o[t]] = e[o[t]]);
  return r;
};
const re = /* @__PURE__ */ G((e, c) => {
  var r, o;
  const t = s.useContext(P), l = t || {}, {
    getPrefixCls: I,
    getPopupContainer: _,
    direction: f,
    menu: d
  } = s.useContext(ie), C = I(), {
    prefixCls: w,
    className: S,
    style: j,
    theme: p = "light",
    expandIcon: a,
    _internalDisableMenuItemTitleTooltip: h,
    inlineCollapsed: O,
    siderCollapsed: v,
    items: T,
    children: y,
    rootClassName: V,
    mode: b,
    selectable: x,
    onClick: g,
    overflowedIndicatorPopupClassName: $
  } = e, k = se(e, ["prefixCls", "className", "style", "theme", "expandIcon", "_internalDisableMenuItemTitleTooltip", "inlineCollapsed", "siderCollapsed", "items", "children", "rootClassName", "mode", "selectable", "onClick", "overflowedIndicatorPopupClassName"]), D = Q(k, ["collapsedWidth"]), z = oe(T) || y;
  if (process.env.NODE_ENV !== "production") {
    const n = ee("Menu");
    process.env.NODE_ENV !== "production" && n(!("inlineCollapsed" in e && b !== "inline"), "usage", "`inlineCollapsed` should only be used when `mode` is inline."), process.env.NODE_ENV !== "production" && n(!(e.siderCollapsed !== void 0 && "inlineCollapsed" in e), "usage", "`inlineCollapsed` not control Menu under Sider. Should set `collapsed` on Sider instead."), n.deprecated("items" in e && !y, "children", "items");
  }
  (r = l.validator) === null || r === void 0 || r.call(l, {
    mode: b
  });
  const R = K(function() {
    var n;
    g == null || g.apply(void 0, arguments), (n = l.onClick) === null || n === void 0 || n.call(l);
  }), E = l.mode || b, W = x ?? l.selectable, N = s.useMemo(() => v !== void 0 ? v : O, [O, v]), L = {
    horizontal: {
      motionName: `${C}-slide-up`
    },
    inline: X(C),
    other: {
      motionName: `${C}-zoom-big`
    }
  }, i = I("menu", w || l.prefixCls), M = te(i), [U, q, A] = ne(i, M, !t), B = u(`${i}-${p}`, d == null ? void 0 : d.className, S);
  let m;
  if (typeof a == "function")
    m = a;
  else if (a === null || a === !1)
    m = null;
  else if (l.expandIcon === null || l.expandIcon === !1)
    m = null;
  else {
    const n = a ?? l.expandIcon;
    m = Y(n, {
      className: u(`${i}-submenu-expand-icon`, Z(n) ? (o = n.props) === null || o === void 0 ? void 0 : o.className : "")
    });
  }
  const F = s.useMemo(() => ({
    prefixCls: i,
    inlineCollapsed: N || !1,
    direction: f,
    firstLevel: !0,
    theme: p,
    mode: E,
    disableMenuItemTitleTooltip: h
  }), [i, N, f, h, p]);
  return U(/* @__PURE__ */ s.createElement(P.Provider, {
    value: null
  }, /* @__PURE__ */ s.createElement(le.Provider, {
    value: F
  }, /* @__PURE__ */ s.createElement(J, Object.assign({
    getPopupContainer: _,
    overflowedIndicator: /* @__PURE__ */ s.createElement(H, null),
    overflowedIndicatorPopupClassName: u(i, `${i}-${p}`, $),
    mode: E,
    selectable: W,
    onClick: R
  }, D, {
    inlineCollapsed: N,
    style: Object.assign(Object.assign({}, d == null ? void 0 : d.style), j),
    className: B,
    prefixCls: i,
    direction: f,
    defaultMotions: L,
    expandIcon: m,
    ref: c,
    rootClassName: u(V, q, l.rootClassName, A, M)
  }), z))));
}), Pe = re;
export {
  Pe as default
};
