Liferay.Loader.define("app-builder-web@1.0.76/js/pages/apps/NewAppPopover.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/button', 'app-builder-web$path-to-regexp', 'frontend-js-react-web$react', '../../components/popover/Popover.es', '../../hooks/useBackUrl.es', './SelectObjectsDropDown.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = void 0;

    var _button = _interopRequireDefault(require("@frontend-taglib-clay$clayui/button"));

    var _pathToRegexp = require("app-builder-web$path-to-regexp");

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _Popover = _interopRequireDefault(require("../../components/popover/Popover.es"));

    var _useBackUrl = _interopRequireDefault(require("../../hooks/useBackUrl.es"));

    var _SelectObjectsDropDown = _interopRequireDefault(require("./SelectObjectsDropDown.es"));

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj.default = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

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

    function _slicedToArray(arr, i) {
      return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
    }

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

    function _iterableToArrayLimit(arr, i) {
      if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
        return;
      }var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
        for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
          _arr.push(_s.value);if (i && _arr.length === i) break;
        }
      } catch (err) {
        _d = true;_e = err;
      } finally {
        try {
          if (!_n && _i["return"] != null) _i["return"]();
        } finally {
          if (_d) throw _e;
        }
      }return _arr;
    }

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

    var NewAppPopover = function NewAppPopover(_ref, forwardRef) {
      var alignElement = _ref.alignElement,
          editPath = _ref.editPath,
          history = _ref.history,
          onCancel = _ref.onCancel,
          visible = _ref.visible;

      var _useState = (0, _react.useState)({}),
          _useState2 = _slicedToArray(_useState, 2),
          selectedObject = _useState2[0],
          setSelectedObject = _useState2[1];

      var withBackUrl = (0, _useBackUrl.default)();

      var onClick = function onClick() {
        history.push(withBackUrl((0, _pathToRegexp.compile)(editPath[0])({
          dataDefinitionId: selectedObject.id
        })));
      };

      return (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Popover.default, {
          alignElement: alignElement,
          className: "apps-popover",
          content: function content() {
            return (/*#__PURE__*/_react.default.createElement("div", {
                className: "px-2"
              }, /*#__PURE__*/_react.default.createElement("label", null, Liferay.Language.get('object')), /*#__PURE__*/_react.default.createElement(_SelectObjectsDropDown.default, {
                alignElement: alignElement,
                label: Liferay.Language.get('select-object'),
                onSelect: setSelectedObject,
                selectedValue: selectedObject,
                visible: visible
              }))
            );
          },
          footer: function footer() {
            return (/*#__PURE__*/_react.default.createElement("div", {
                className: "border-top mt-3 px-4 py-3",
                style: {
                  width: 450
                }
              }, /*#__PURE__*/_react.default.createElement("div", {
                className: "d-flex justify-content-end"
              }, /*#__PURE__*/_react.default.createElement(_button.default, {
                className: "mr-3",
                displayType: "secondary",
                onClick: function onClick() {
                  setSelectedObject({});
                  onCancel();
                },
                small: true
              }, Liferay.Language.get('cancel')), /*#__PURE__*/_react.default.createElement(_button.default, {
                disabled: !selectedObject.id,
                onClick: onClick,
                small: true
              }, Liferay.Language.get('continue'))))
            );
          },
          ref: forwardRef,
          showArrow: false,
          title: function title() {
            return (/*#__PURE__*/_react.default.createElement("div", {
                className: "pt-2 px-2"
              }, /*#__PURE__*/_react.default.createElement("h4", {
                className: "mb-3"
              }, Liferay.Language.get('new-app')), /*#__PURE__*/_react.default.createElement("span", {
                className: "font-weight-light text-secondary"
              }, Liferay.Language.get('create-an-app-to-collect-and-manage-an-objects-data')))
            );
          },
          visible: visible
        }))
      );
    };

    var _default = /*#__PURE__*/_react.default.forwardRef(NewAppPopover);

    exports.default = _default;
    //# sourceMappingURL=NewAppPopover.es.js.map
  }
});
//# sourceMappingURL=NewAppPopover.es.js.map