Liferay.Loader.define("portal-workflow-metrics-web@2.0.46/js/components/filter/ProcessStepFilter.es", ['module', 'exports', 'require', 'frontend-js-react-web$react', '../../shared/components/filter/Filter.es', '../../shared/components/filter/hooks/useFilterFetch.es', '../../shared/components/filter/hooks/useFilterName.es', '../../shared/components/filter/util/filterConstants.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.default = void 0;

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

    var _Filter = _interopRequireDefault(require("../../shared/components/filter/Filter.es"));

    var _useFilterFetch2 = require("../../shared/components/filter/hooks/useFilterFetch.es");

    var _useFilterName = require("../../shared/components/filter/hooks/useFilterName.es");

    var _filterConstants = _interopRequireDefault(require("../../shared/components/filter/util/filterConstants.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 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 allStepsItem = {
      dividerAfter: true,
      label: Liferay.Language.get('all-steps'),
      name: 'allSteps'
    };

    var ProcessStepFilter = function ProcessStepFilter(_ref) {
      var className = _ref.className,
          disabled = _ref.disabled,
          _ref$filterKey = _ref.filterKey,
          filterKey = _ref$filterKey === void 0 ? _filterConstants.default.processStep.key : _ref$filterKey,
          _ref$options = _ref.options,
          options = _ref$options === void 0 ? {} : _ref$options,
          _ref$prefixKey = _ref.prefixKey,
          prefixKey = _ref$prefixKey === void 0 ? '' : _ref$prefixKey,
          processId = _ref.processId;
      options = _objectSpread({
        hideControl: false,
        multiple: true,
        position: 'left',
        requestUrl: "/processes/".concat(processId, "/tasks?page=0&pageSize=0"),
        withAllSteps: false,
        withSelectionTitle: false,
        withoutRouteParams: false
      }, options);

      var _useFilterFetch = (0, _useFilterFetch2.useFilterFetch)(_objectSpread({
        filterKey: filterKey,
        prefixKey: prefixKey,
        propertyKey: 'name',
        staticItems: options.withAllSteps ? [allStepsItem] : []
      }, options)),
          items = _useFilterFetch.items,
          selectedItems = _useFilterFetch.selectedItems;

      var defaultItem = (0, _react.useMemo)(function () {
        return items[0];
      }, [items]);

      if (defaultItem && options.withSelectionTitle && !selectedItems.length) {
        selectedItems[0] = defaultItem;
      }

      var filterName = (0, _useFilterName.useFilterNameWithLabel)(_objectSpread({
        labelPropertyName: 'label',
        selectedItems: selectedItems,
        title: Liferay.Language.get('process-step'),
        withSelectionTitle: options.withSelectionTitle
      }, options));
      return (/*#__PURE__*/_react.default.createElement(_Filter.default, _extends({
          defaultItem: defaultItem,
          disabled: disabled,
          elementClasses: className,
          filterKey: filterKey,
          items: items,
          labelPropertyName: "label",
          name: filterName,
          prefixKey: prefixKey
        }, options))
      );
    };

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