Liferay.Loader.define("commerce-frontend-js@3.0.15/components/mini_cart/util/index", ['module', 'exports', 'require', '../../../utilities/modules', './constants'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.isNonnull = isNonnull;
    exports.collectDiscountLevels = collectDiscountLevels;
    exports.parseOptions = parseOptions;
    exports.regenerateOrderDetailURL = regenerateOrderDetailURL;
    exports.resolveView = resolveView;
    exports.summaryDataMapper = summaryDataMapper;

    var _modules = _interopRequireDefault(require("../../../utilities/modules"));

    var _constants = require("./constants");

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

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

    function isNonnull() {
      for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
        values[_key] = arguments[_key];
      }

      return !!values.find(function (value) {
        return parseFloat(value) > 0;
      });
    }

    function collectDiscountLevels(price) {
      return Object.keys(price).reduce(function (levels, key) {
        if (key.startsWith(_constants.DISCOUNT_LEVEL_PREFIX)) {
          levels.push(price[key].toFixed(2));
        }

        return levels;
      }, []);
    }

    function parseOptions(stringifiedJSON) {
      var options;

      try {
        options = JSON.parse(stringifiedJSON);
      } catch (ignore) {
        options = '';
      }

      return Array.isArray(options) ? options.map(function (_ref) {
        var value = _ref.value;
        return "".concat(value);
      }).join(', ') : options;
    }

    function regenerateOrderDetailURL(orderDetailURL, orderUUID) {
      var originalURL = new URL(orderDetailURL);
      originalURL.searchParams.set(_constants.ORDER_UUID_PARAMETER, orderUUID);
      return originalURL.toString();
    }

    function resolveView(_ref2) {
      var component = _ref2.component,
          contentRendererModuleUrl = _ref2.contentRendererModuleUrl;

      if (component) {
        return Promise.resolve(function (props) {
          return component(props);
        });
      }

      return (0, _modules["default"])(contentRendererModuleUrl);
    }

    function summaryDataMapper(summary) {
      return Object.keys(summary).reduce(function (values, key) {
        var summaryItem = {
          value: summary[key]
        };

        switch (key) {
          case 'itemsQuantity':
            values.push(_objectSpread({
              label: Liferay.Language.get('quantity')
            }, summaryItem));
            break;

          case 'subtotalFormatted':
            values.push(_objectSpread({
              label: Liferay.Language.get('subtotal')
            }, summaryItem));
            break;

          case 'totalDiscountValueFormatted':
            values.push(_objectSpread({
              label: Liferay.Language.get('order-discount')
            }, summaryItem));
            break;

          case 'totalFormatted':
            values.push(_objectSpread({
              label: Liferay.Language.get('total'),
              style: 'big'
            }, summaryItem));
            break;

          default:
            break;
        }

        return values;
      }, []);
    }
    //# sourceMappingURL=index.js.map
  }
});
//# sourceMappingURL=index.js.map