Liferay.Loader.define("product-navigation-control-menu@5.0.35/js/TabItem", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/button', '@frontend-taglib-clay$clayui/icon', 'frontend-js-react-web$classnames', 'frontend-js-react-web$prop-types', 'frontend-js-react-web$react', './AddPanel', './addPortlet', './constants/layoutDataItemTypes', './useDragAndDrop'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = void 0;

    var _button = _interopRequireDefault(require("@frontend-taglib-clay$clayui/button"));

    var _icon = _interopRequireDefault(require("@frontend-taglib-clay$clayui/icon"));

    var _classnames = _interopRequireDefault(require("frontend-js-react-web$classnames"));

    var _propTypes = _interopRequireDefault(require("frontend-js-react-web$prop-types"));

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _AddPanel = require("./AddPanel");

    var _addPortlet = _interopRequireDefault(require("./addPortlet"));

    var _layoutDataItemTypes = require("./constants/layoutDataItemTypes");

    var _useDragAndDrop = require("./useDragAndDrop");

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj.default = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * This library is free software; you can redistribute it and/or modify it under
     * the terms of the GNU Lesser General Public License as published by the Free
     * Software Foundation; either version 2.1 of the License, or (at your option)
     * any later version.
     *
     * This library is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
     * details.
     */
    var addItem = function addItem(_ref) {
      var item = _ref.item,
          plid = _ref.plid,
          setWidgets = _ref.setWidgets,
          widgets = _ref.widgets;
      var targetItem = document.querySelector('.portlet-dropzone');
      (0, _addPortlet.default)({
        item: item,
        plid: plid,
        targetItem: targetItem
      });

      if (!item.data.instanceable) {
        var updatedWidgets = (0, _AddPanel.updateUsedWidget)({
          item: item,
          widgets: widgets
        });
        setWidgets(updatedWidgets);
      }
    };

    var TabItem = function TabItem(_ref2) {
      var item = _ref2.item;

      var _useContext = (0, _react.useContext)(_AddPanel.AddPanelContext),
          plid = _useContext.plid,
          setWidgets = _useContext.setWidgets,
          widgets = _useContext.widgets;

      var isContent = item.type === _layoutDataItemTypes.LAYOUT_DATA_ITEM_TYPES.content;

      var _useDragSymbol = (0, _useDragAndDrop.useDragSymbol)({
        data: item.data,
        icon: item.icon,
        label: item.label,
        portletId: item.itemId,
        type: item.type
      }),
          sourceRef = _useDragSymbol.sourceRef;

      return (/*#__PURE__*/_react.default.createElement("li", {
          className: (0, _classnames.default)('sidebar-body__add-panel__tab-item', {
            disabled: item.disabled,
            multiline: isContent,
            'sidebar-body__add-panel__tab-portlet-item': item.data.portletItemId
          }),
          ref: item.disabled ? null : sourceRef
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: "sidebar-body__add-panel__tab-item-body"
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: "icon"
        }, /*#__PURE__*/_react.default.createElement(_icon.default, {
          symbol: item.icon
        })), /*#__PURE__*/_react.default.createElement("div", {
          className: "text"
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: "text-truncate title"
        }, item.label), isContent && /*#__PURE__*/_react.default.createElement("div", {
          className: "subtitle text-truncate"
        }, item.category))), !item.disabled && /*#__PURE__*/_react.default.createElement(_button.default, {
          className: "btn-monospaced sidebar-body__add-panel__tab-item-add",
          displayType: "unstyled",
          onClick: function onClick() {
            return addItem({
              item: item,
              plid: plid,
              setWidgets: setWidgets,
              widgets: widgets
            });
          },
          small: true,
          title: item.name
        }, /*#__PURE__*/_react.default.createElement(_icon.default, {
          symbol: "plus"
        }), /*#__PURE__*/_react.default.createElement("span", {
          className: "sr-only"
        }, item.name)))
      );
    };

    var _default = TabItem;
    exports.default = _default;
    //# sourceMappingURL=TabItem.js.map
  }
});
//# sourceMappingURL=TabItem.js.map