Liferay.Loader.define("commerce-frontend-js@3.0.33/utilities/modals/index", ['module', 'exports', 'require', '../eventsDefinitions', '../notifications', './constants'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.resolveModalSize = resolveModalSize;
    exports.resolveModalHeight = resolveModalHeight;
    exports.openPermissionsModal = openPermissionsModal;
    exports.closeAndRedirect = closeAndRedirect;
    exports.isSubmitting = isSubmitting;
    exports.onSubmitFail = onSubmitFail;

    var _eventsDefinitions = require("../eventsDefinitions");

    var _notifications = require("../notifications");

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

    /**
     * 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.
     */
    function resolveModalSize(modalTarget) {
      var modalSize = modalTarget.split('-')[1];

      if (!modalSize) {
        return _constants.CLAY_MODAL_SIZES_MAP.DEFAULT;
      }

      if (modalSize in _constants.CLAY_MODAL_SIZES_MAP) {
        return _constants.CLAY_MODAL_SIZES_MAP[modalSize];
      }

      return _constants.CLAY_MODAL_SIZES_MAP.FULL_SCREEN;
    }

    function resolveModalHeight(size) {
      return !size || !(size in _constants.MODAL_HEIGHT_MAP) ? _constants.MODAL_HEIGHT_MAP.INITIAL : _constants.MODAL_HEIGHT_MAP[size];
    }

    function openPermissionsModal(uri) {
      Liferay.Util.openWindow({
        dialog: {
          destroyOnHide: true
        },
        dialogIframe: {
          bodyCssClass: 'dialog-with-footer'
        },
        title: Liferay.Language.get('permissions'),
        uri: uri
      });
    }

    function closeAndRedirect(redirectURL) {
      var t_Liferay = window.top.Liferay;
      var modalSettings = {
        successNotification: {
          message: Liferay.Language.get('your-request-completed-successfully'),
          showSuccessNotification: true
        }
      };

      if (redirectURL) {
        modalSettings.redirectURL = redirectURL.toString();
      }

      t_Liferay.fire(_eventsDefinitions.CLOSE_MODAL, modalSettings);
    }

    function isSubmitting() {
      var t_Liferay = window.top.Liferay;
      t_Liferay.fire(_eventsDefinitions.IS_LOADING_MODAL, {
        isLoading: true
      });
    }

    function onSubmitFail() {
      var reason = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var t_Liferay = window.top.Liferay,
          _reason$title = reason.title,
          title = _reason$title === void 0 ? '' : _reason$title,
          errorMessage = title || Liferay.Language.get('an-unexpected-error-occurred');
      t_Liferay.fire(_eventsDefinitions.IS_LOADING_MODAL, {
        isLoading: false
      });
      (0, _notifications.showErrorNotification)(errorMessage);
    }
    //# sourceMappingURL=index.js.map
  }
});
//# sourceMappingURL=index.js.map