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

    var _index = require("../../utilities/index");

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

    var _index2 = require("../modals/index");

    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.
     */
    var EVENT = _constants.ACTION_ITEM_TARGETS.EVENT,
        MODAL = _constants.ACTION_ITEM_TARGETS.MODAL,
        MODAL_FULL_SCREEN = _constants.ACTION_ITEM_TARGETS.MODAL_FULL_SCREEN,
        MODAL_LARGE = _constants.ACTION_ITEM_TARGETS.MODAL_LARGE,
        MODAL_SMALL = _constants.ACTION_ITEM_TARGETS.MODAL_SMALL,
        SIDE_PANEL = _constants.ACTION_ITEM_TARGETS.SIDE_PANEL;

    function triggerAction(item, context) {
      var actionTargetURL = item.href,
          actionTarget = item.target,
          loadData = context.loadData,
          modalId = context.modalId,
          sidePanelId = context.sidePanelId;

      switch (actionTarget) {
        case MODAL:
        case MODAL_FULL_SCREEN:
        case MODAL_LARGE:
        case MODAL_SMALL:
          Liferay.fire(_eventsDefinitions.OPEN_MODAL, {
            id: modalId,
            onClose: loadData,
            size: (0, _index2.resolveModalSize)(actionTarget),
            url: actionTargetURL
          });
          break;

        case SIDE_PANEL:
          Liferay.fire(_eventsDefinitions.OPEN_SIDE_PANEL, {
            id: sidePanelId,
            onAfterSubmit: loadData,
            url: actionTargetURL
          });
          break;

        case EVENT:
          Liferay.fire(actionTargetURL);
          break;

        default:
          (0, _index.liferayNavigate)(actionTargetURL);
          break;
      }
    }
    //# sourceMappingURL=index.js.map
  }
});
//# sourceMappingURL=index.js.map