Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/page_editor/app/thunks/deleteItem",["module","exports","require","frontend-js-web","../actions/deleteItem","../config/constants/freemarkerFragmentEntryProcessor","../config/constants/layoutDataItemTypes","../selectors/selectEditableValue","../selectors/selectFormConfiguration","../services/FormService","../services/LayoutService","../utils/cache","../utils/getFormErrorDescription","../utils/getFragmentEntryLinkIdsFromItemId","../utils/hasFormParent","../utils/isRequiredFormInput"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({itemId:e,selectItem:t=(()=>{})}){return(r,y)=>{const{fragmentEntryLinks:I,layoutData:F,segmentsExperienceId:_}=y();return function({fragmentEntryLinks:e,itemId:t,layoutData:r,onNetworkStatus:n,segmentsExperienceId:o}){const s=b(t,r,e);return u.default.markItemForDeletion({itemId:t,onNetworkStatus:n,portletIds:s,segmentsExperienceId:o}).then((e=>E(E({},e),{},{portletIds:s})))}({fragmentEntryLinks:I,itemId:e,layoutData:F,onNetworkStatus:r,segmentsExperienceId:_}).then((({pageContents:u,portletIds:y=[],layoutData:E})=>{t(null);const b=(0,f.default)({itemId:e,layoutData:E});r((0,o.default)({fragmentEntryLinkIds:b,itemId:e,layoutData:E,pageContents:u,portletIds:y})),function(e,t,r){var o;const u=null==e||null===(o=e.items)||void 0===o?void 0:o[t];if(!u||u.type!==a.LAYOUT_DATA_ITEM_TYPES.fragment||!(0,p.hasFormParent)(u,e))return null;const{classNameId:f,classTypeId:y}=(0,c.default)(u,e),I=(0,d.getCacheKey)([d.CACHE_KEYS.formFields,f,y]),{data:E}=(0,d.getCacheItem)(I);(E?Promise.resolve(E):l.default.getFormFields({classNameId:f,classTypeId:y})).then((e=>{if(u.type===a.LAYOUT_DATA_ITEM_TYPES.fragment&&(0,g.isRequiredFormInput)(u,r,e)){const t=(0,i.default)({fragmentEntryLinks:r},u.config.fragmentEntryLinkId,"inputFieldId",s.FREEMARKER_FRAGMENT_ENTRY_PROCESSOR),{message:o}=(0,m.getFormErrorDescription)({name:O(t,e),type:m.FORM_ERROR_TYPES.deletedFragment});(0,n.openToast)({message:o,type:"warning"})}}))}(F,e,I)}))}};var n=r("frontend-js-web"),o=y(r("../actions/deleteItem")),s=r("../config/constants/freemarkerFragmentEntryProcessor"),a=r("../config/constants/layoutDataItemTypes"),i=y(r("../selectors/selectEditableValue")),c=y(r("../selectors/selectFormConfiguration")),l=y(r("../services/FormService")),u=y(r("../services/LayoutService")),d=r("../utils/cache"),m=r("../utils/getFormErrorDescription"),f=y(r("../utils/getFragmentEntryLinkIdsFromItemId")),p=r("../utils/hasFormParent"),g=r("../utils/isRequiredFormInput");function y(e){return e&&e.__esModule?e:{default:e}}function I(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 E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach((function(t){F(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function F(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(e,t,r){const n=t.items[e],{config:o={},children:s=[]}=n;if(n.type===a.LAYOUT_DATA_ITEM_TYPES.fragment&&o.fragmentEntryLinkId){const{editableValues:e={}}=r[o.fragmentEntryLinkId];if(e.portletId)return[e.instanceId?"".concat(e.portletId,"_INSTANCE_").concat(e.instanceId):e.portletId]}const i=[];return s.forEach((e=>{i.push(...b(e,t,r))})),i}function O(e,t){return t.flatMap((e=>e.fields)).find((t=>t.key===e)).label}}}));
//# sourceMappingURL=deleteItem.js.map