Liferay.Loader.define("data-engine-js-components-web@1.0.112/js/custom/form/reducers/pageReducer.es",["module","exports","require","../../../utils/FormSupport.es","../../../utils/formId.es","../eventTypes"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function pageReducer(e,t){switch(t.type){case a.EVENT_TYPES.SUCCESS_PAGE:{const{defaultLanguageId:r,pages:n,paginationMode:a}=e,{enabled:i}=t.payload,c=n[n.length-1];let s=n.filter((({contentRenderer:e})=>"success"!==e));if(i){const e="success"===c.contentRenderer?c:{id:(0,o.getUid)()};s=[...s,_objectSpread(_objectSpread({},e),{},{contentRenderer:"success",defaultLanguageId:r,paginationItemRenderer:"".concat(a,"_success"),rows:[],successPageSettings:t.payload})]}return{pages:s,successPageSettings:t.payload}}case a.EVENT_TYPES.PAGE.ADD:{const{pageIndex:r}=t.payload,{editingLanguageId:a,pages:i}=e;return{activePage:r+1,pages:[...i.slice(0,r+1),_objectSpread(_objectSpread({description:"",enabled:!0,headerRenderer:"editable",id:(0,o.getUid)(),rows:[n.implAddRow(12,[])],showRequiredFieldsWarning:!0,title:""},getLocalizedValue(a,"title","")),getLocalizedValue(a,"description","")),...i.slice(r+1)]}}case a.EVENT_TYPES.PAGE.DELETE:{const{pages:r}=e,{pageIndex:n}=t.payload;return{activePage:Math.max(0,n-1),pages:r.filter(((e,t)=>t!==n))}}case a.EVENT_TYPES.PAGE.RESET:{const{pageIndex:r}=t.payload,{editingLanguageId:o,pages:a}=e;return a[r]=_objectSpread(_objectSpread(_objectSpread({},a[r]),{},{description:"",enabled:!0,rows:[n.implAddRow(12,[])],showRequiredFieldsWarning:!0,title:""},getLocalizedValue(o,"title","")),getLocalizedValue(o,"description","")),{pages:[...a]}}case a.EVENT_TYPES.PAGE.SWAP:{const{pages:r}=e,{firstIndex:n,secondIndex:o}=t.payload,[a,i]=[r[n],r[o]];return{pages:r.map(((e,t)=>t===n?i:t===o?a:e))}}case a.EVENT_TYPES.PAGE.TITLE_CHANGE:{const{pageIndex:r,value:n}=t.payload,{editingLanguageId:o,pages:a}=e,i=a[r],{localizedTitle:c}=i,s=_objectWithoutProperties(i,["localizedTitle"]);return a[r]=_objectSpread(_objectSpread({},s),{},{localizedTitle:_objectSpread(_objectSpread({},c),{},{[o]:n}),title:n}),{pages:[...a]}}case a.EVENT_TYPES.PAGE.DESCRIPTION_CHANGE:{const{pageIndex:r,value:n}=t.payload,{editingLanguageId:o,pages:a}=e,i=a[r],{localizedDescription:c}=i,s=_objectWithoutProperties(i,["localizedDescription"]);return a[r]=_objectSpread(_objectSpread({},s),{},{description:n,localizedDescription:_objectSpread(_objectSpread({},c),{},{[o]:n})}),{pages:[...a]}}default:return e}};var n=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=n?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r("../../../utils/FormSupport.es")),o=r("../../../utils/formId.es"),a=r("../eventTypes");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,o=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const getLocalizedValue=(e,t,r)=>({["localized".concat(t.replace(/^\w/,(e=>e.toUpperCase())))]:{[e]:r}})}}));
//# sourceMappingURL=pageReducer.es.js.map