Liferay.Loader.define("dynamic-data-mapping-form-renderer@5.0.47/js/components/Pages.es", ['module', 'exports', 'require', './PageRenderer.soy', '@frontend-taglib-clay$clayui/icon', 'frontend-js-react-web$classnames', 'frontend-js-react-web$react', 'frontend-js-react-web$react-dnd', 'frontend-js-react-web$react-dnd-html5-backend', '../hooks/useResource.es', './PageRenderer/index'], 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;

    require("./PageRenderer.soy");

    var _icon = require("@frontend-taglib-clay$clayui/icon");

    var _classnames = _interopRequireDefault(require("frontend-js-react-web$classnames"));

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

    var _reactDnd = require("frontend-js-react-web$react-dnd");

    var _reactDndHtml5Backend = require("frontend-js-react-web$react-dnd-html5-backend");

    var _useResource = require("../hooks/useResource.es");

    var _index = _interopRequireDefault(require("./PageRenderer/index"));

    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 _extends() {
      _extends = Object.assign || function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }return target;
      };return _extends.apply(this, arguments);
    }

    function _objectWithoutProperties(source, excluded) {
      if (source == null) return {};var target = _objectWithoutPropertiesLoose(source, excluded);var key, i;if (Object.getOwnPropertySymbols) {
        var sourceSymbolKeys = Object.getOwnPropertySymbols(source);for (i = 0; i < sourceSymbolKeys.length; i++) {
          key = sourceSymbolKeys[i];if (excluded.indexOf(key) >= 0) continue;if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;target[key] = source[key];
        }
      }return target;
    }

    function _objectWithoutPropertiesLoose(source, excluded) {
      if (source == null) return {};var target = {};var sourceKeys = Object.keys(source);var key, i;for (i = 0; i < sourceKeys.length; i++) {
        key = sourceKeys[i];if (excluded.indexOf(key) >= 0) continue;target[key] = source[key];
      }return target;
    }

    function getDisplayableValue(_ref) {
      var containerId = _ref.containerId,
          readOnly = _ref.readOnly,
          viewMode = _ref.viewMode;
      return readOnly || !viewMode || document.getElementById(containerId) !== null;
    }

    var Pages = /*#__PURE__*/_react.default.forwardRef(function (_ref2, ref) {
      var _ref2$activePage = _ref2.activePage,
          activePage = _ref2$activePage === void 0 ? 0 : _ref2$activePage,
          _ref2$cancelLabel = _ref2.cancelLabel,
          cancelLabel = _ref2$cancelLabel === void 0 ? Liferay.Language.get('cancel') : _ref2$cancelLabel,
          containerId = _ref2.containerId,
          initialDisplayableValue = _ref2.displayable,
          editable = _ref2.editable,
          _ref2$editingLanguage = _ref2.editingLanguageId,
          editingLanguageId = _ref2$editingLanguage === void 0 ? themeDisplay.getLanguageId() : _ref2$editingLanguage,
          _ref2$pages = _ref2.pages,
          pages = _ref2$pages === void 0 ? [] : _ref2$pages,
          _ref2$paginationMode = _ref2.paginationMode,
          paginationMode = _ref2$paginationMode === void 0 ? 'wizard' : _ref2$paginationMode,
          readOnly = _ref2.readOnly,
          _ref2$submitLabel = _ref2.submitLabel,
          submitLabel = _ref2$submitLabel === void 0 ? Liferay.Language.get('submit') : _ref2$submitLabel,
          view = _ref2.view,
          viewMode = _ref2.viewMode,
          otherProps = _objectWithoutProperties(_ref2, ["activePage", "cancelLabel", "containerId", "displayable", "editable", "editingLanguageId", "pages", "paginationMode", "readOnly", "submitLabel", "view", "viewMode"]);

      var _useFieldTypesResourc = (0, _useResource.useFieldTypesResource)(),
          fieldTypes = _useFieldTypesResourc.resource;

      var containerFallbackRef = (0, _react.useRef)();
      var displayable = initialDisplayableValue || getDisplayableValue({
        containerId: containerId,
        readOnly: readOnly,
        viewMode: viewMode
      });

      if (!displayable) {
        return null;
      }

      var containerElementRef = ref !== null && ref !== void 0 ? ref : containerFallbackRef;
      return (/*#__PURE__*/_react.default.createElement("div", {
          className: (0, _classnames.default)({
            sheet: view === 'fieldSets'
          }),
          ref: containerElementRef
        }, /*#__PURE__*/_react.default.createElement("div", {
          className: (0, _classnames.default)('lfr-ddm-form-container position-relative', {
            'ddm-user-view-content': !editable
          })
        }, pages.map(function (page, index) {
          return (/*#__PURE__*/_react.default.createElement(_index.default, _extends({}, otherProps, {
              activePage: activePage,
              cancelLabel: cancelLabel,
              containerElement: containerElementRef,
              editable: editable,
              editingLanguageId: editingLanguageId,
              fieldTypes: fieldTypes,
              key: index,
              page: page,
              pageIndex: index,
              pages: pages,
              paginationMode: paginationMode,
              readOnly: readOnly,
              submitLabel: submitLabel,
              total: pages.length,
              view: view,
              viewMode: viewMode
            }))
          );
        })))
      );
    });

    Pages.displayName = 'Pages';

    var PagesWithProviders = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
      return (/*#__PURE__*/_react.default.createElement(_reactDnd.DndProvider, {
          backend: _reactDndHtml5Backend.HTML5Backend,
          context: window
        }, /*#__PURE__*/_react.default.createElement(_icon.ClayIconSpriteContext.Provider, {
          value: props.spritemap
        }, /*#__PURE__*/_react.default.createElement(Pages, _extends({}, props, {
          ref: ref
        }))))
      );
    });

    PagesWithProviders.displayName = 'PagesWithProviders';

    var _default = /*#__PURE__*/_react.default.memo(PagesWithProviders);

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