Liferay.Loader.define("commerce-frontend-taglib@10.1.5/quantity_selector/util/index", ['module', 'exports', 'require'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = exports.UPDATE_AFTER = void 0;

    function _classCallCheck(instance, Constructor) {
      if (!(instance instanceof Constructor)) {
        throw new TypeError("Cannot call a class as a function");
      }
    }

    function _defineProperties(target, props) {
      for (var i = 0; i < props.length; i++) {
        var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
      }
    }

    function _createClass(Constructor, protoProps, staticProps) {
      if (protoProps) _defineProperties(Constructor.prototype, protoProps);if (staticProps) _defineProperties(Constructor, staticProps);return Constructor;
    }

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * This library is free software; you can redistribute it and/or modify it under
     * the terms of the GNU Lesser General Public License as published by the Free
     * Software Foundation; either version 2.1 of the License, or (at your option)
     * any later version.
     *
     * This library is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
     * details.
     */
    var UPDATE_AFTER = 350;
    exports.UPDATE_AFTER = UPDATE_AFTER;

    var QuantityControls = /*#__PURE__*/function () {
      function QuantityControls(_ref) {
        var maxQuantity = _ref.maxQuantity,
            minQuantity = _ref.minQuantity,
            multipleQuantity = _ref.multipleQuantity;

        _classCallCheck(this, QuantityControls);

        this.max = maxQuantity;
        this.step = multipleQuantity;
        this.min = this.step > 1 ? this._getUpperBound(minQuantity, this.step) : minQuantity;
      }
      /**
       * If this.step > 1,
       * value will always be floored to the
       * closest lower multiple value.
       */

      _createClass(QuantityControls, [{
        key: "getLowerBound",
        value: function getLowerBound() {
          var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : NaN;
          return value > this.min ? value - value % this.step : this.min;
        }
      }, {
        key: "_getUpperBound",
        value: function _getUpperBound(min) {
          if (min > this.step) {
            var remainder = min % this.step;
            return remainder ?
            /**
            * min is *not* a multiple of this.step
            */
            min + this.step - remainder :
            /**
            * and min *is* a multiple of this.step
            */
            min;
          }

          return this.step;
        }
      }]);

      return QuantityControls;
    }();

    exports.default = QuantityControls;
    //# sourceMappingURL=index.js.map
  }
});
//# sourceMappingURL=index.js.map