Liferay.Loader.define("portal-workflow-metrics-web@2.0.46/js/components/process-metrics/workload-by-assignee-card/WorkloadByAssigneeCardTable.es", ['module', 'exports', 'require', 'frontend-js-react-web$react', '../../../shared/components/filter/util/filterConstants.es', '../../../shared/components/router/ChildLink.es', '../../../shared/util/util.es', '../../AppContext.es', '../../filter/ProcessStatusFilter.es', '../../filter/SLAStatusFilter.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 _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _filterConstants = _interopRequireDefault(require("../../../shared/components/filter/util/filterConstants.es"));

    var _ChildLink = _interopRequireDefault(require("../../../shared/components/router/ChildLink.es"));

    var _util = require("../../../shared/util/util.es");

    var _AppContext = require("../../AppContext.es");

    var _ProcessStatusFilter = require("../../filter/ProcessStatusFilter.es");

    var _SLAStatusFilter = require("../../filter/SLAStatusFilter.es");

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

    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 _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 _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 _ref$assignee = _ref.assignee,
          id = _ref$assignee.id,
          name = _ref$assignee.name,
          currentTab = _ref.currentTab,
          onTimeTaskCount = _ref.onTimeTaskCount,
          overdueTaskCount = _ref.overdueTaskCount,
          processId = _ref.processId,
          processStepKey = _ref.processStepKey,
          taskCount = _ref.taskCount;

      var _useContext = (0, _react.useContext)(_AppContext.AppContext),
          defaultDelta = _useContext.defaultDelta;

      var counts = (0, _react.useMemo)(function () {
        return {
          onTime: onTimeTaskCount,
          overdue: overdueTaskCount,
          total: taskCount
        };
      }, [onTimeTaskCount, overdueTaskCount, taskCount]);
      var filters = (0, _react.useMemo)(function () {
        var _ref2;

        return _ref2 = {}, _defineProperty(_ref2, _filterConstants.default.assignee.key, [id]), _defineProperty(_ref2, _filterConstants.default.processStatus.key, [_ProcessStatusFilter.processStatusConstants.pending]), _defineProperty(_ref2, _filterConstants.default.processStep.key, [processStepKey]), _defineProperty(_ref2, _filterConstants.default.slaStatus.key, [_SLAStatusFilter.slaStatusConstants[currentTab]]), _ref2;
      }, [currentTab, id, processStepKey]);
      var formattedPercentage = (0, _react.useMemo)(function () {
        return (0, _util.getFormattedPercentage)(counts[currentTab], taskCount);
      }, [counts, currentTab, taskCount]);
      var instancesListPath = (0, _react.useMemo)(function () {
        return "/instance/".concat(processId, "/").concat(defaultDelta, "/1");
      }, [defaultDelta, processId]);
      return (/*#__PURE__*/_react.default.createElement("tr", null, /*#__PURE__*/_react.default.createElement("td", {
          className: "assignee-name border-0"
        }, /*#__PURE__*/_react.default.createElement(_ChildLink.default, {
          className: 'workload-by-assignee-link',
          query: {
            filters: filters
          },
          to: instancesListPath
        }, /*#__PURE__*/_react.default.createElement("span", null, name))), /*#__PURE__*/_react.default.createElement("td", {
          className: "border-0 text-right"
        }, /*#__PURE__*/_react.default.createElement("span", {
          className: "task-count-value"
        }, counts[currentTab]), currentTab !== 'total' && /*#__PURE__*/_react.default.createElement("span", {
          className: "task-count-percentage"
        }, ' / ', formattedPercentage)))
      );
    };

    var Table = function Table(_ref3) {
      var currentTab = _ref3.currentTab,
          _ref3$items = _ref3.items,
          items = _ref3$items === void 0 ? [] : _ref3$items,
          processId = _ref3.processId,
          processStepKey = _ref3.processStepKey;
      return (/*#__PURE__*/_react.default.createElement("div", {
          className: "mb-3 table-fit-panel"
        }, /*#__PURE__*/_react.default.createElement("table", {
          className: "table table-autofit table-hover"
        }, /*#__PURE__*/_react.default.createElement("tbody", null, items.map(function (item, index) {
          return (/*#__PURE__*/_react.default.createElement(Table.Item, _extends({}, item, {
              currentTab: currentTab,
              key: index,
              processId: processId,
              processStepKey: processStepKey
            }))
          );
        }))))
      );
    };

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