Liferay.Loader.define("layout-admin-web@4.0.136/js/EditLayout", ['module', 'exports', 'require', './checkFriendlyURL'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = EditLayout;

    var _checkFriendlyURL = require("./checkFriendlyURL");

    /**
     * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
     * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
     */

    /**
     * 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 EditLayout(_ref) {
      var getFriendlyURLWarningURL = _ref.getFriendlyURLWarningURL,
          namespace = _ref.namespace,
          shouldCheckFriendlyURL = _ref.shouldCheckFriendlyURL;
      var form = document.getElementById("".concat(namespace, "editLayoutFm"));

      var onSubmit = function onSubmit(event) {
        event.preventDefault();
        event.stopPropagation();

        if (shouldCheckFriendlyURL) {
          (0, _checkFriendlyURL.checkFriendlyURL)(getFriendlyURLWarningURL, new FormData(form)).then(function (resp) {
            if (!resp.shouldSubmit) {
              return;
            }

            var applyLayoutPrototype = document.getElementById("".concat(namespace, "applyLayoutPrototype"));

            if (!applyLayoutPrototype || applyLayoutPrototype.value === 'false') {
              return submitForm(form);
            } else if (applyLayoutPrototype && applyLayoutPrototype.value === 'true') {
              if (confirm(Liferay.Language.get('reactivating-inherited-changes-may-update-the-page-with-the-possible-changes-that-could-have-been-made-in-the-original-template'))) {
                return submitForm(form);
              }
            }
          });
        } else {
          var applyLayoutPrototype = document.getElementById("".concat(namespace, "applyLayoutPrototype"));

          if (!applyLayoutPrototype || applyLayoutPrototype.value === 'false') {
            submitForm(form);
          } else if (applyLayoutPrototype && applyLayoutPrototype.value === 'true') {
            if (confirm(Liferay.Language.get('reactivating-inherited-changes-may-update-the-page-with-the-possible-changes-that-could-have-been-made-in-the-original-template'))) {
              submitForm(form);
            }
          }
        }
      };

      form.addEventListener('submit', onSubmit);
      return {
        dispose: function dispose() {
          form.removeEventListener('submit', onSubmit);
        }
      };
    }
    //# sourceMappingURL=EditLayout.js.map
  }
});
//# sourceMappingURL=EditLayout.js.map