Liferay.Loader.define("portal-workflow-metrics-web@2.0.46/js/components/instance-list-page/modal/shared/select-tasks-step/SelectTasksStepTable.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/form', '@frontend-taglib-clay$clayui/table', 'frontend-js-react-web$react', '../../ModalProvider.es'], 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.Table = void 0;

    var _form = require("@frontend-taglib-clay$clayui/form");

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

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

    var _ModalProvider = require("../../ModalProvider.es");

    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 _extends() {
      _extends = Object.assign || function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }return target;
      };return _extends.apply(this, arguments);
    }

    function _toConsumableArray(arr) {
      return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
    }

    function _nonIterableSpread() {
      throw new TypeError("Invalid attempt to spread non-iterable instance");
    }

    function _iterableToArray(iter) {
      if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
    }

    function _arrayWithoutHoles(arr) {
      if (Array.isArray(arr)) {
        for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
          arr2[i] = arr[i];
        }return arr2;
      }
    }

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

    var Item = function Item(_ref) {
      var totalCount = _ref.totalCount,
          task = _objectWithoutProperties(_ref, ["totalCount"]);

      var _useContext = (0, _react.useContext)(_ModalProvider.ModalContext),
          tasks = _useContext.selectTasks.tasks,
          setSelectTasks = _useContext.setSelectTasks;

      var assetTitle = task.assetTitle,
          assetType = task.assetType,
          assignee = task.assignee,
          id = task.id,
          instanceId = task.instanceId,
          label = task.label;
      var checked = !!tasks.find(function (item) {
        return item.id === id;
      });

      return (/*#__PURE__*/_react.default.createElement(_table.default.Row, {
          className: checked ? 'table-active' : ''
        }, /*#__PURE__*/_react.default.createElement(_table.default.Cell, null, /*#__PURE__*/_react.default.createElement(_form.ClayCheckbox, {
          checked: checked,
          onChange: function handleCheck(_ref2) {
            var target = _ref2.target;
            var updatedItems = target.checked ? [].concat(_toConsumableArray(tasks), [task]) : tasks.filter(function (task) {
              return task.id !== id;
            });
            setSelectTasks({
              selectAll: totalCount > 0 && totalCount === updatedItems.length,
              tasks: updatedItems
            });
          }
        })), /*#__PURE__*/_react.default.createElement(_table.default.Cell, {
          className: "font-weight-bold"
        }, instanceId), /*#__PURE__*/_react.default.createElement(_table.default.Cell, null, "".concat(assetType, ": ").concat(assetTitle)), /*#__PURE__*/_react.default.createElement(_table.default.Cell, null, label), /*#__PURE__*/_react.default.createElement(_table.default.Cell, null, assignee ? assignee.name : Liferay.Language.get('unassigned')))
      );
    };

    var Table = function Table(_ref3) {
      var items = _ref3.items,
          totalCount = _ref3.totalCount;
      return (/*#__PURE__*/_react.default.createElement(_table.default, null, /*#__PURE__*/_react.default.createElement(_table.default.Head, null, /*#__PURE__*/_react.default.createElement(_table.default.Row, null, /*#__PURE__*/_react.default.createElement(_table.default.Cell, {
          headingCell: true,
          style: {
            color: 'inherit',
            fontWeight: 'bold',
            width: '5%'
          }
        }), /*#__PURE__*/_react.default.createElement(_table.default.Cell, {
          headingCell: true,
          style: {
            color: 'inherit',
            fontWeight: 'bold',
            width: '10%'
          }
        }, Liferay.Language.get('id')), /*#__PURE__*/_react.default.createElement(_table.default.Cell, {
          headingCell: true,
          style: {
            color: 'inherit',
            fontWeight: 'bold',
            width: '30%'
          }
        }, Liferay.Language.get('item-subject')), /*#__PURE__*/_react.default.createElement(_table.default.Cell, {
          headingCell: true,
          style: {
            color: 'inherit',
            fontWeight: 'bold',
            width: '25%'
          }
        }, Liferay.Language.get('process-step')), /*#__PURE__*/_react.default.createElement(_table.default.Cell, {
          style: {
            color: 'inherit',
            fontWeight: 'bold',
            width: '30%'
          }
        }, Liferay.Language.get('current-assignee')))), /*#__PURE__*/_react.default.createElement(_table.default.Body, null, items && items.length > 0 && items.map(function (item, index) {
          return (/*#__PURE__*/_react.default.createElement(Table.Item, _extends({}, item, {
              key: index,
              totalCount: totalCount
            }))
          );
        })))
      );
    };

    exports.Table = Table;
    Table.Item = Item;
    //# sourceMappingURL=SelectTasksStepTable.es.js.map
  }
});
//# sourceMappingURL=SelectTasksStepTable.es.js.map