"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
exports.__esModule = true;
exports.SidebarItem = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = _interopRequireWildcard(require("react"));
var _SidebarAPI = require("../SidebarAPI");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/Sidebar/SidebarItem/SidebarItem.jsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var SidebarItem = exports.SidebarItem = /*#__PURE__*/function (_PureComponent) {
  function SidebarItem() {
    var _this;
    (0, _classCallCheck2["default"])(this, SidebarItem);
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _callSuper(this, SidebarItem, [].concat(args));
    _this.displayName = 'SidebarItem';
    return _this;
  }
  (0, _inherits2["default"])(SidebarItem, _PureComponent);
  return (0, _createClass2["default"])(SidebarItem, [{
    key: "render",
    value: function render() {
      var _this2 = this;
      var dataHook = this.props.dataHook;
      return /*#__PURE__*/_react["default"].createElement(_SidebarAPI.SidebarContext.Consumer, {
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 10,
          columnNumber: 7
        }
      }, function (context) {
        return /*#__PURE__*/_react["default"].createElement("div", {
          "data-hook": dataHook,
          onClick: function onClick(e) {
            if (!_this2.props.disable) {
              if (_this2.props.onClick) {
                _this2.props.onClick(_this2.props.itemKey, e);
              }
              if (!e.defaultPrevented) {
                context.itemClicked(_this2.props.itemKey);
              }
            }
          },
          __self: _this2,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 12,
            columnNumber: 11
          }
        }, /*#__PURE__*/_react["default"].createElement(_SidebarAPI.SidebarItemContext.Provider, {
          value: {
            selected: function selected() {
              return context.getSelectedKey() === _this2.props.itemKey;
            },
            getIsMenuExpanded: function getIsMenuExpanded() {
              return context.getIsMenuExpanded();
            }
          },
          __self: _this2,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 25,
            columnNumber: 13
          }
        }, _this2.props.children));
      });
    }
  }]);
}(_react.PureComponent);