Liferay.Loader.define("frontend-taglib-clay@6.6.5/data_set_display/views/cards/Cards", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/card', 'frontend-taglib-clay$classnames', 'frontend-taglib-clay$prop-types', 'frontend-js-react-web$react', '../../data_renderers/ActionsDropdownRenderer'], 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 _card = require("@frontend-taglib-clay$clayui/card");

    var _classnames = _interopRequireDefault(require("frontend-taglib-clay$classnames"));

    var _propTypes = _interopRequireDefault(require("frontend-taglib-clay$prop-types"));

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

    var _ActionsDropdownRenderer = require("../../data_renderers/ActionsDropdownRenderer");

    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 };
    }

    function ownKeys(object, enumerableOnly) {
      var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);if (enumerableOnly) symbols = symbols.filter(function (sym) {
          return Object.getOwnPropertyDescriptor(object, sym).enumerable;
        });keys.push.apply(keys, symbols);
      }return keys;
    }

    function _objectSpread(target) {
      for (var i = 1; i < arguments.length; i++) {
        var source = arguments[i] != null ? arguments[i] : {};if (i % 2) {
          ownKeys(Object(source), true).forEach(function (key) {
            _defineProperty(target, key, source[key]);
          });
        } else if (Object.getOwnPropertyDescriptors) {
          Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
        } else {
          ownKeys(Object(source)).forEach(function (key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
          });
        }
      }return target;
    }

    function _defineProperty(obj, key, value) {
      if (key in obj) {
        Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
      } else {
        obj[key] = value;
      }return obj;
    }

    function _objectWithoutProperties(source, excluded) {
      if (source == null) return {};var target = _objectWithoutPropertiesLoose(source, excluded);var key, i;if (Object.getOwnPropertySymbols) {
        var sourceSymbolKeys = Object.getOwnPropertySymbols(source);for (i = 0; i < sourceSymbolKeys.length; i++) {
          key = sourceSymbolKeys[i];if (excluded.indexOf(key) >= 0) continue;if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;target[key] = source[key];
        }
      }return target;
    }

    function _objectWithoutPropertiesLoose(source, excluded) {
      if (source == null) return {};var target = {};var sourceKeys = Object.keys(source);var key, i;for (i = 0; i < sourceKeys.length; i++) {
        key = sourceKeys[i];if (excluded.indexOf(key) >= 0) continue;target[key] = source[key];
      }return target;
    }

    function Cards(_ref) {
      var dataSetDisplayContext = _ref.dataSetDisplayContext,
          items = _ref.items,
          schema = _ref.schema;

      var _useContext = (0, _react.useContext)(dataSetDisplayContext),
          executeAsyncItemAction = _useContext.executeAsyncItemAction,
          highlightItems = _useContext.highlightItems,
          openModal = _useContext.openModal,
          openSidePanel = _useContext.openSidePanel,
          selectItems = _useContext.selectItems,
          selectable = _useContext.selectable,
          selectedItemsKey = _useContext.selectedItemsKey,
          selectedItemsValue = _useContext.selectedItemsValue,
          style = _useContext.style;

      return (/*#__PURE__*/_react.default.createElement("div", {
          className: (0, _classnames.default)('cards-container mb-n4', style === 'default' && 'px-3 pt-4')
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: "row"
        }, items.map(function (item) {
          return (/*#__PURE__*/_react.default.createElement("div", {
              className: "col-md-3",
              key: item[selectedItemsKey]
            }, /*#__PURE__*/_react.default.createElement(_card.ClayCardWithInfo, {
              actions: item.actionDropdownItems.map(function (_ref2) {
                var href = _ref2.href,
                    action = _objectWithoutProperties(_ref2, ["href"]);

                return _objectSpread(_objectSpread({}, action), {}, {
                  href: (0, _ActionsDropdownRenderer.isLink)(action.target, action.onClick) ? href : null,
                  onClick: function onClick(event) {
                    var _action$data;

                    (0, _ActionsDropdownRenderer.handleAction)(_objectSpread({
                      event: event,
                      itemId: item[selectedItemsKey],
                      method: (_action$data = action.data) === null || _action$data === void 0 ? void 0 : _action$data.method,
                      url: href
                    }, action), {
                      executeAsyncItemAction: executeAsyncItemAction,
                      highlightItems: highlightItems,
                      openModal: openModal,
                      openSidePanel: openSidePanel
                    });
                  }
                });
              }),
              description: schema.description && item[schema.description],
              href: schema.href && item[schema.href] || null,
              imgProps: schema.image && item[schema.image],
              onSelectChange: selectable && function () {
                return selectItems(item[selectedItemsKey]);
              },
              selected: selectable && !!selectedItemsValue.find(function (element) {
                return element === item[selectedItemsKey];
              }),
              stickerProps: schema.sticker && item[schema.sticker],
              symbol: schema.symbol && item[schema.symbol],
              title: schema.title && item[schema.title]
            }))
          );
        })))
      );
    }

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