Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.130/page_editor/app/components/undo/undoUpdateFormItemConfig",["module","exports","require","../../actions/updateFormItemConfig","../../actions/updateItemLocalConfig","../../services/LayoutService","../../utils/getFragmentItem"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.undoAction=function({action:e,store:t}){const{config:n,deletedItems:d,isMapping:s,itemId:m,removedFragmentEntryLinkIds:u,restoredFragmentEntryLinkIds:g}=e,{layoutData:l}=t,p=u.map((e=>({itemId:(0,a.default)(l,e).itemId}))),f=g.map((e=>(0,a.default)(l,e).itemId)),y=l.items[m],I=c(c({},l),{},{deletedItems:[...d,...p],items:c(c({},l.items),{},{[m]:c(c({},y),{},{children:s?f:y.children,config:n})})});return e=>(s&&e((0,i.default)({disableUndo:!0,itemConfig:{loading:!0},itemId:m})),o.default.updateLayoutData({layoutData:I,onNetworkStatus:e,segmentsExperienceId:t.segmentsExperienceId}).then((()=>{e((0,r.default)({deletedItems:d,isMapping:s,itemId:m,layoutData:I,removedFragmentEntryLinkIds:u,restoredFragmentEntryLinkIds:g}))})))},t.getDerivedStateForUndo=function({action:e,state:t}){const{addedFragmentEntryLinks:n,isMapping:r,itemId:i,removedFragmentEntryLinkIds:o,restoredFragmentEntryLinkIds:a}=e,{layoutData:d}=t;return{config:c(c({},d.items[i].config),{},{loading:!1}),deletedItems:d.deletedItems,isMapping:r,itemId:i,removedFragmentEntryLinkIds:n?Object.keys(n):a,restoredFragmentEntryLinkIds:o}};var r=d(n("../../actions/updateFormItemConfig")),i=d(n("../../actions/updateItemLocalConfig")),o=d(n("../../services/LayoutService")),a=d(n("../../utils/getFragmentItem"));function d(e){return e&&e.__esModule?e:{default:e}}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){m(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}}}));
//# sourceMappingURL=undoUpdateFormItemConfig.js.map