Liferay.Loader.define("portal-workflow-metrics-web@2.0.42/js/components/instance-list-page/modal/reassign/bulk/select-assignees-step/SelectAssigneesStepTable.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/icon', '@frontend-taglib-clay$clayui/table', '@frontend-taglib-clay$clayui/tooltip', 'frontend-js-react-web$react', '../../../../../../shared/components/autocomplete/Autocomplete.es', '../../../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 _icon = _interopRequireDefault(require("@frontend-taglib-clay$clayui/icon"));

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

    var _tooltip = require("@frontend-taglib-clay$clayui/tooltip");

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

    var _Autocomplete = require("../../../../../../shared/components/autocomplete/Autocomplete.es");

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

    var Item = function Item(_ref) {
      var assetTitle = _ref.assetTitle,
          assetType = _ref.assetType,
          assignee = _ref.assignee,
          _ref$data = _ref.data,
          data = _ref$data === void 0 ? {} : _ref$data,
          id = _ref.id,
          instanceId = _ref.instanceId,
          label = _ref.label;

      var _useContext = (0, _react.useContext)(_ModalProvider.ModalContext),
          bulkReassign = _useContext.bulkReassign,
          setBulkReassign = _useContext.setBulkReassign;

      var reassignedTasks = bulkReassign.reassignedTasks,
          reassigning = bulkReassign.reassigning,
          useSameAssignee = bulkReassign.useSameAssignee;

      var _ref2 = reassignedTasks.find(function (_ref3) {
        var workflowTaskId = _ref3.workflowTaskId;
        return workflowTaskId === id;
      }) || {},
          assigneeId = _ref2.assigneeId;

      var _data$workflowTaskAss = data.workflowTaskAssignableUsers,
          users = _data$workflowTaskAss === void 0 ? [] : _data$workflowTaskAss;

      var _ref4 = users.find(function (_ref5) {
        var workflowTaskId = _ref5.workflowTaskId;
        return workflowTaskId === id;
      }) || {},
          _ref4$assignableUsers = _ref4.assignableUsers,
          assignableUsers = _ref4$assignableUsers === void 0 ? [] : _ref4$assignableUsers;

      var _ref6 = assignableUsers.find(function (assignee) {
        return assignee.id === assigneeId;
      }) || {},
          assigneeName = _ref6.name;

      return _react["default"].createElement(_table["default"].Row, null, _react["default"].createElement(_table["default"].Cell, {
        className: "font-weight-bold"
      }, instanceId), _react["default"].createElement(_table["default"].Cell, null, "".concat(assetType, ": ").concat(assetTitle), " "), _react["default"].createElement(_table["default"].Cell, null, label), _react["default"].createElement(_table["default"].Cell, null, assignee ? assignee.name : Liferay.Language.get('unassigned')), _react["default"].createElement(_table["default"].Cell, null, _react["default"].createElement(_Autocomplete.Autocomplete, {
        defaultValue: assigneeName,
        disabled: reassigning || useSameAssignee,
        items: assignableUsers,
        onSelect: function handleSelect(newAssignee) {
          var filteredTasks = reassignedTasks.filter(function (task) {
            return task.id !== id;
          });

          if (newAssignee) {
            filteredTasks.push({
              assigneeId: newAssignee.id,
              workflowTaskId: id
            });
          }

          setBulkReassign(function (prevBulkReassign) {
            return _objectSpread({}, prevBulkReassign, {
              reassignedTasks: filteredTasks
            });
          });
        }
      })));
    };

    var Table = function Table(_ref7) {
      var data = _ref7.data,
          items = _ref7.items;
      return _react["default"].createElement(_table["default"], {
        "data-testid": "bulkReassignModalTable"
      }, _react["default"].createElement(_table["default"].Head, null, _react["default"].createElement(_table["default"].Row, null, _react["default"].createElement(_table["default"].Cell, {
        headingCell: true,
        style: {
          color: 'inherit',
          fontWeight: 'bold',
          width: '10%'
        }
      }, Liferay.Language.get('id')), _react["default"].createElement(_table["default"].Cell, {
        headingCell: true,
        style: {
          color: 'inherit',
          fontWeight: 'bold',
          width: '25%'
        }
      }, Liferay.Language.get('item-subject')), _react["default"].createElement(_table["default"].Cell, {
        headingCell: true,
        style: {
          color: 'inherit',
          fontWeight: 'bold',
          width: '20%'
        }
      }, Liferay.Language.get('process-step')), _react["default"].createElement(_table["default"].Cell, {
        style: {
          color: 'inherit',
          fontWeight: 'bold',
          width: '20%'
        }
      }, Liferay.Language.get('current-assignee')), _react["default"].createElement(_table["default"].Cell, {
        style: {
          color: 'inherit',
          fontWeight: 'bold',
          width: '25%'
        }
      }, "".concat(Liferay.Language.get('new-assignee')), ' ', _react["default"].createElement(_tooltip.ClayTooltipProvider, null, _react["default"].createElement(_icon["default"], {
        "data-tooltip-align": "top",
        style: {
          color: '#6B6C7E'
        },
        symbol: "question-circle-full",
        title: Liferay.Language.get('possible-assignees-must-have-permissions-to-be-assigned-to-the-corresponding-step')
      }))))), _react["default"].createElement(_table["default"].Body, null, items && items.length > 0 && items.map(function (item) {
        return _react["default"].createElement(Table.Item, _extends({
          data: data
        }, item, {
          key: item.id
        }));
      })));
    };

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