"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _menu = _interopRequireDefault(require("antd/lib/menu"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _react = _interopRequireDefault(require("react"));
var icons = _interopRequireWildcard(require("@ant-design/icons"));
var _excluded = ["icon", "type"]; // import Icon from '@ant-design/icons/lib/components/Icon';
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
var CustomNav = function CustomNav(props, ref) {
  var icon = props.icon,
    type = props.type,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded);
  var data = [].concat(otherProps === null || otherProps === void 0 ? void 0 : otherProps.items);
  function processMenuItems(menuItems) {
    return menuItems === null || menuItems === void 0 ? void 0 : menuItems.map(function (item) {
      var menuItem = (0, _extends2["default"])({}, item);
      // 处理当前菜单项
      if (menuItem !== null && menuItem !== void 0 && menuItem.icon) {
        var IconComp = (icons || {})[menuItem === null || menuItem === void 0 ? void 0 : menuItem.icon];
        if (IconComp) {
          menuItem.icon = /*#__PURE__*/_react["default"].createElement(IconComp, icon);
        } else {
          menuItem.icon = '';
        }
      }
      // 处理子菜单项
      if (menuItem !== null && menuItem !== void 0 && menuItem.children) {
        menuItem.children = processMenuItems(menuItem.children);
      }
      return menuItem;
    });
  }
  var newdata = processMenuItems(data);
  otherProps.items = newdata;
  return /*#__PURE__*/_react["default"].createElement(_menu["default"], otherProps);
};
var _default = exports["default"] = CustomNav;