import React__default, { useMemo } from 'react';
import { SideMenuWrapper, SideMenuHeaderWrapper, SideMenuBodyWrapper, SideMenuFooterWrapper } from './style.js';
import Tooltip from '../../Tooltip/Tooltip/index.js';
import Item from '../Item/index.js';
import theme from '../../../Globals/theme.js';
import { ThemeProvider } from 'styled-components';
import globalStyle from '../../../Globals/global-styles.js';

var SideMenuComponent = function SideMenuComponent(_ref) {
  var items = _ref.items,
      _ref$footerAvailable = _ref.footerAvailable,
      footerAvailable = _ref$footerAvailable === void 0 ? false : _ref$footerAvailable,
      _ref$footerItems = _ref.footerItems,
      footerItems = _ref$footerItems === void 0 ? [] : _ref$footerItems,
      headerIcon = _ref.headerIcon,
      width = _ref.width,
      _ref$onItemClick = _ref.onItemClick,
      onItemClick = _ref$onItemClick === void 0 ? function () {} : _ref$onItemClick;
  var menuItems = useMemo(function () {
    return items;
  }, [items]);

  var handleClick = function handleClick(e, index) {
    onItemClick(e.target, index);
  };

  var renderItems = function renderItems() {
    return menuItems.map(function (item, index) {
      return /*#__PURE__*/React__default.createElement(Item, {
        item: item,
        key: index,
        onClick: function onClick(e) {
          return handleClick(e, index);
        }
      });
    });
  };

  return /*#__PURE__*/React__default.createElement(ThemeProvider, {
    theme: theme
  }, /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(globalStyle, null), /*#__PURE__*/React__default.createElement(SideMenuWrapper, {
    width: width
  }, /*#__PURE__*/React__default.createElement(SideMenuHeaderWrapper, null, headerIcon), /*#__PURE__*/React__default.createElement(SideMenuBodyWrapper, null, renderItems()), footerAvailable && /*#__PURE__*/React__default.createElement(SideMenuFooterWrapper, null, footerItems.map(function (item, index) {
    return /*#__PURE__*/React__default.createElement(Tooltip, {
      key: index,
      title: item.name,
      placement: "right"
    }, /*#__PURE__*/React__default.createElement("div", null, item.icon));
  })))));
};

export { SideMenuComponent as default };
//# sourceMappingURL=index.js.map
