"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "Item", {
  enumerable: true,
  get: function get() {
    return _MenuItem.default;
  }
});
Object.defineProperty(exports, "SubMenu", {
  enumerable: true,
  get: function get() {
    return _SubMenuItem.SubMenu;
  }
});
exports.default = exports.ItemGroup = void 0;

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _react = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _components = require("../components");

var _context = require("../config-provider/context");

var _ReactNodeValidate = require("../utils/ReactNodeValidate");

var _MenuContext = _interopRequireDefault(require("./MenuContext"));

var _MenuItem = _interopRequireDefault(require("./MenuItem"));

var _SubMenuItem = require("./SubMenuItem");

var MenuRC = _components.Menu.default;
var ItemGroup = _components.Menu.ItemGroup;
exports.ItemGroup = ItemGroup;

var Menu = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
  var theme = props.theme,
      prefixCls = props.prefixCls,
      className = props.className,
      expandIcon = props.expandIcon,
      restProps = (0, _objectWithoutProperties2.default)(props, ["theme", "prefixCls", "className", "expandIcon"]);

  var _React$useContext = _react.default.useContext(_context.ConfigContext),
      getPrefixClassName = _React$useContext.getPrefixClassName;

  var menuRef = ref || (0, _react.useRef)(null);
  var menuCls = getPrefixClassName('menu', prefixCls);

  var getInlineCollapsed = function getInlineCollapsed() {
    var inlineCollapsed = props.inlineCollapsed,
        siderCollapsed = props.siderCollapsed;

    if (siderCollapsed !== undefined) {
      return siderCollapsed;
    }

    return inlineCollapsed;
  };

  var endCls = (0, _classnames.default)("".concat(menuCls, "-").concat(theme), (0, _defineProperty2.default)({}, "".concat(prefixCls, "-inline-collapsed"), getInlineCollapsed()), className);
  var comProps = (0, _objectSpread2.default)({
    ref: menuRef,
    className: endCls
  }, restProps);
  return /*#__PURE__*/_react.default.createElement(_MenuContext.default.Provider, {
    value: {
      kleinMenuTheme: theme,
      inlineCollapsed: getInlineCollapsed() || false
    }
  }, /*#__PURE__*/_react.default.createElement(MenuRC, Object.assign({
    prefixCls: menuCls
  }, comProps, {
    expandIcon: (0, _ReactNodeValidate.cloneElement)(expandIcon, {
      className: "".concat(prefixCls, "-submenu-expand-icon")
    })
  })));
});

Menu.displayName = 'Menu';
Menu.defaultProps = {
  theme: 'light',
  mode: 'vertical',
  inlineIndent: 26,
  multiple: false
};
var _default = Menu;
exports.default = _default;