"use strict";

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

exports.__esModule = true;
exports.MobileMenuItem = void 0;

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

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

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _link = _interopRequireDefault(require("next/link"));

var _lib = require("@sentecacommerce-theme/lib");

var _Common = require("../../../../Common");

var _MobileMenuSectionList = require("../MobileMenuSectionList");

var _MobileBrandSection = require("../MobileBrandSection");

var _templateObject;

var MobileMenuItem = function MobileMenuItem(_ref) {
  var _data$tags, _data$linkUrl, _data$sections, _data$sections2;

  var data = _ref.data,
      onItemClick = _ref.onItemClick,
      slideLeft = _ref.slideLeft,
      reset = _ref.reset;

  var _useBoolean = (0, _lib.useBoolean)(),
      isExpanded = _useBoolean[0],
      setIsExpanded = _useBoolean[1];

  var openSections = function openSections(e) {
    e.preventDefault();
    slideLeft();
    setIsExpanded.on();
  };

  var isBrand = Boolean((_data$tags = data.tags) == null ? void 0 : _data$tags.includes('brands'));
  return /*#__PURE__*/_react["default"].createElement("li", null, /*#__PURE__*/_react["default"].createElement(_link["default"], {
    href: (_data$linkUrl = data.linkUrl) != null ? _data$linkUrl : '#',
    passHref: true
  }, /*#__PURE__*/_react["default"].createElement(Name, {
    onClick: (_data$sections = data.sections) != null && _data$sections.length ? openSections : onItemClick
  }, data.name, /*#__PURE__*/_react["default"].createElement(_Common.ArrowRight, null))), Boolean(isExpanded && ((_data$sections2 = data.sections) == null ? void 0 : _data$sections2.length)) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, isBrand ? /*#__PURE__*/_react["default"].createElement(_MobileBrandSection.MobileBrandSection, {
    data: data,
    handleClose: setIsExpanded.off,
    onCloseStart: reset
  }) : /*#__PURE__*/_react["default"].createElement(_MobileMenuSectionList.MobileMenuSectionList, {
    parentName: data.name,
    data: data.sections,
    handleClose: setIsExpanded.off,
    onCloseStart: reset
  })));
};

exports.MobileMenuItem = MobileMenuItem;

var Name = _styledComponents["default"].a.attrs({
  className: 'py-2 d-flex align-items-center justify-content-between'
})(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2["default"])(["\n  font-size: 2.4rem;\n  line-height: 1.3;\n"])));
//# sourceMappingURL=index.js.map