import { forwardRef, useContext, useEffect } from "react";
import SubMenuInline from "./inline.js";
import SubMenuPop from "./pop.js";
import MenuContext from "../context.js";
import { jsx } from "../../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js";
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
function SubMenu(props, ref) {
  var children = props.children, popup = props.popup, level = props.level;
  var _a = useContext(MenuContext), mode = _a.mode, collapse = _a.collapse, inDropdown = _a.inDropdown, collectInlineMenuKeys = _a.collectInlineMenuKeys;
  var forcePopup = !!(typeof popup === "function" ? popup(level) : popup);
  var mergedPopup = forcePopup || collapse || inDropdown || mode !== "vertical";
  var MergedMenu = mergedPopup ? SubMenuPop : SubMenuInline;
  useEffect(function() {
    collectInlineMenuKeys(props._key);
    return function() {
      collectInlineMenuKeys(props._key, true);
    };
  }, []);
  return /* @__PURE__ */ jsx(MergedMenu, {
    ...__assign({
      forwardedRef: ref
    }, props),
    children
  });
}
var ForwardRefSubMenu = forwardRef(SubMenu);
var SubMenuComponent = ForwardRefSubMenu;
SubMenuComponent.displayName = "SubMenu";
SubMenuComponent.menuType = "SubMenu";
const SubMenu$1 = SubMenuComponent;
export {
  SubMenu$1 as default
};
//# sourceMappingURL=index.js.map
