Liferay.Loader.define("portal-workflow-metrics-web@2.0.42/js/components/filter/VelocityUnitFilter.es", ['module', 'exports', 'require', 'frontend-js-react-web$react', '../../shared/components/filter/Filter.es', '../../shared/components/filter/hooks/useFilterName.es', '../../shared/components/filter/hooks/useFilterStatic.es', '../../shared/components/filter/util/filterConstants.es', './util/velocityUnitUtil.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 _useFilterName = require("../../shared/components/filter/hooks/useFilterName.es");

    var _useFilterStatic2 = require("../../shared/components/filter/hooks/useFilterStatic.es");

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

    var _velocityUnitUtil = require("./util/velocityUnitUtil.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 VelocityUnitFilter = function VelocityUnitFilter(_ref) {
      var disabled = _ref.disabled,
          className = _ref.className,
          _ref$filterKey = _ref.filterKey,
          filterKey = _ref$filterKey === void 0 ? _filterConstants["default"].velocityUnit.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,
          timeRange = _ref.timeRange;
      options = _objectSpread({
        hideControl: true,
        multiple: false,
        position: 'right',
        withSelectionTitle: true,
        withoutRouteParams: false
      }, options);
      var velocityUnits = (0, _react.useMemo)(function () {
        return (0, _velocityUnitUtil.getVelocityUnits)(timeRange);
      }, [timeRange]);

      var _useFilterStatic = (0, _useFilterStatic2.useFilterStatic)(_objectSpread({
        filterKey: filterKey,
        prefixKey: prefixKey,
        staticItems: velocityUnits
      }, options)),
          items = _useFilterStatic.items,
          selectedItems = _useFilterStatic.selectedItems;

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

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

      var filterName = (0, _useFilterName.useFilterName)(options.multiple, selectedItems, Liferay.Language.get('velocity-unit'), options.withSelectionTitle);
      return _react["default"].createElement(_Filter["default"], _extends({
        defaultItem: defaultItem,
        disabled: disabled,
        elementClasses: className,
        filterKey: filterKey,
        items: items,
        name: filterName,
        prefixKey: prefixKey
      }, options));
    };

    var _default = VelocityUnitFilter;
    exports["default"] = _default;
    //# sourceMappingURL=VelocityUnitFilter.es.js.map
  }
});
//# sourceMappingURL=VelocityUnitFilter.es.js.map