"use strict";

exports.__esModule = true;
exports.default = void 0;
var _isNil2 = _interopRequireDefault(require("lodash/fp/isNil"));
var _keys2 = _interopRequireDefault(require("lodash/fp/keys"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _ssmenuList = _interopRequireDefault(require("../ssmenu-list"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const buttonStyle = {
  primary: _style.default.primary,
  secondary: _style.default.secondary
};
const MenuList = props => {
  const {
    menuItems = []
  } = props;
  const MenuitemDiv = menuItems.map((item, index) => {
    const {
      title,
      href,
      type,
      subItems,
      outgoing = false,
      onClick
    } = item;
    const subItemsView = !(0, _isNil2.default)(subItems) ? /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.subNav
    }, /*#__PURE__*/_react.default.createElement(_ssmenuList.default, {
      items: item.subItems
    })) : null;
    return /*#__PURE__*/_react.default.createElement("li", {
      key: index,
      className: type ? buttonStyle[type] : _style.default.item
    }, /*#__PURE__*/_react.default.createElement("a", {
      href: href,
      target: outgoing ? '_blank' : '_self',
      onClick: onClick,
      rel: "noreferrer"
    }, title), subItemsView);
  });
  return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("input", {
    type: "checkbox",
    id: "toggle",
    className: _style.default.toggleBox
  }), /*#__PURE__*/_react.default.createElement("label", {
    htmlFor: "toggle",
    className: _style.default.toggler
  }, "\u2261"), /*#__PURE__*/_react.default.createElement("ul", {
    className: _style.default.list
  }, MenuitemDiv));
};
MenuList.propTypes = process.env.NODE_ENV !== "production" ? {
  menuItems: _propTypes.default.arrayOf(_propTypes.default.shape({
    href: _propTypes.default.string,
    title: _propTypes.default.string,
    type: _propTypes.default.oneOf((0, _keys2.default)(buttonStyle)),
    outgoing: _propTypes.default.bool
  }))
} : {};
var _default = exports.default = MenuList;
//# sourceMappingURL=index.js.map