Liferay.Loader.define("commerce-frontend-js@3.0.33/components/mini_cart/util/views", ['module', 'exports', 'require', '../../../utilities/modules', '../../summary/Summary', '../CartItem', '../CartItemsList', '../CartItemsListActions', '../Header', '../Opener', '../OrderButton', '../Wrapper', './constants'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.resolveCartViews = resolveCartViews;
    exports.DEFAULT_VIEWS = void 0;

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

    var _Summary = _interopRequireDefault(require("../../summary/Summary"));

    var _CartItem = _interopRequireDefault(require("../CartItem"));

    var _CartItemsList = _interopRequireDefault(require("../CartItemsList"));

    var _CartItemsListActions = _interopRequireDefault(require("../CartItemsListActions"));

    var _Header = _interopRequireDefault(require("../Header"));

    var _Opener = _interopRequireDefault(require("../Opener"));

    var _OrderButton = _interopRequireDefault(require("../OrderButton"));

    var _Wrapper = _interopRequireDefault(require("../Wrapper"));

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

    var _DEFAULT_VIEWS;

    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 _toArray(arr) {
      return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest();
    }

    function _nonIterableRest() {
      throw new TypeError("Invalid attempt to destructure non-iterable instance");
    }

    function _iterableToArray(iter) {
      if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
    }

    function _arrayWithHoles(arr) {
      if (Array.isArray(arr)) return arr;
    }

    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 DEFAULT_VIEWS = (_DEFAULT_VIEWS = {}, _defineProperty(_DEFAULT_VIEWS, _constants.CART, {
      component: _Wrapper.default
    }), _defineProperty(_DEFAULT_VIEWS, _constants.HEADER, {
      component: _Header.default
    }), _defineProperty(_DEFAULT_VIEWS, _constants.ITEM, {
      component: _CartItem.default
    }), _defineProperty(_DEFAULT_VIEWS, _constants.ITEMS_LIST, {
      component: _CartItemsList.default
    }), _defineProperty(_DEFAULT_VIEWS, _constants.ITEMS_LIST_ACTIONS, {
      component: _CartItemsListActions.default
    }), _defineProperty(_DEFAULT_VIEWS, _constants.OPENER, {
      component: _Opener.default
    }), _defineProperty(_DEFAULT_VIEWS, _constants.ORDER_BUTTON, {
      component: _OrderButton.default
    }), _defineProperty(_DEFAULT_VIEWS, _constants.SUMMARY, {
      component: _Summary.default
    }), _DEFAULT_VIEWS);
    exports.DEFAULT_VIEWS = DEFAULT_VIEWS;

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

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

      return (0, _modules.getJsModule)(contentRendererModuleUrl);
    }

    function resolveCartViews() {
      var views = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_VIEWS;

      var _Object$keys$sort = Object.keys(DEFAULT_VIEWS).sort(),
          _Object$keys$sort2 = _toArray(_Object$keys$sort),
          viewTypes = _Object$keys$sort2.slice(0);

      return Promise.all(viewTypes.map(function (viewType) {
        return resolveView(views[viewType]).catch(function () {
          return resolveView(DEFAULT_VIEWS[viewType]);
        });
      })).then(function (resolvedViews) {
        return Promise.resolve(viewTypes.reduce(function (views, type) {
          return _objectSpread(_objectSpread({}, views), {}, _defineProperty({}, type, resolvedViews.shift()));
        }, {}));
      });
    }
    //# sourceMappingURL=views.js.map
  }
});
//# sourceMappingURL=views.js.map