Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.169/page_editor/app/thunks/multipleUndo",["module","exports","require","../actions/index","../actions/types","../components/undo/undoActions","../config/constants/serviceNetworkStatusTypes","../config/constants/undoTypes","../reducers/index","./../components/undo/undoActions"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function multipleUndo({numberOfActions:e,store:t,type:r}){return a=>{if(!t.undoHistory&&!t.redoHistory)return;let p,y,f,O,l=t;return r===c.UNDO_TYPES.undo?(p={isUndo:!0},f=t.undoHistory.slice(0,e),y=t.undoHistory.slice(e,t.undoHistory.length),O={type:n.UPDATE_UNDO_ACTIONS,undoHistory:y}):(p={isRedo:!0},f=t.redoHistory.slice(0,e),y=t.redoHistory.slice(e,t.redoHistory.length),O={redoHistory:y,type:n.UPDATE_REDO_ACTIONS}),a((0,o.updateNetwork)({status:s.SERVICE_NETWORK_STATUS_TYPES.savingDraft})),f.reduce(((e,t)=>e.then((()=>{return(0,i.undoAction)({action:t,store:l})((e=t.originalType||t.type,t=>{(0,d.canUndoAction)(t)&&(l=(0,u.reducer)(l,_objectSpread(_objectSpread({},t),{},{actionType:t.type,originalType:e,type:r===c.UNDO_TYPES.undo?n.ADD_REDO_ACTION:n.ADD_UNDO_ACTION})),l=(0,u.reducer)(l,_objectSpread(_objectSpread(_objectSpread({},t),p),{},{originalType:e})))}),(()=>l));var e}))),Promise.resolve()).then((()=>{a((0,o.updateNetwork)({requestGenerateDraft:!1,status:s.SERVICE_NETWORK_STATUS_TYPES.draftSaved})),l=(0,u.reducer)(l,O),a({store:l,type:"UPDATE_STORE"})})).catch((e=>{a((0,o.updateNetwork)({error:Liferay.Language.get("an-unexpected-error-occurred"),status:s.SERVICE_NETWORK_STATUS_TYPES.error}))}))}};var o=r("../actions/index"),n=r("../actions/types"),i=r("../components/undo/undoActions"),s=r("../config/constants/serviceNetworkStatusTypes"),c=r("../config/constants/undoTypes"),u=r("../reducers/index"),d=r("./../components/undo/undoActions");function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}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}}}));
//# sourceMappingURL=multipleUndo.js.map