Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.169/page_editor/plugins/page_content/components/ImageEditorModal",["module","exports","require","@frontend-taglib-clay$clayui/loading-indicator","@frontend-taglib-clay$clayui/modal","item-selector-taglib","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../app/actions/updatePreviewImage","../../../app/config/index","../../../app/contexts/StoreContext","../../../app/selectors/selectLanguageId","../../../app/services/FragmentService","../../../app/services/ImageService"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.updateFragmentsPreviewImage=updateFragmentsPreviewImage,t.default=function ImageEditorModal({editImageURL:e,fileEntryId:t,fragmentEntryLinks:a,onCloseModal:o,previewURL:d}){const s=(0,u.useDispatch)(),f=(0,u.useSelector)(c.default),{observer:p,onClose:g}=(0,n.useModal)({onClose:o});return l.default.createElement(n.default,{className:"image-editor-modal",containerProps:{className:"cadmin"},observer:p,size:"full-screen"},l.default.createElement(n.default.Header,null,Liferay.Language.get("edit-image")),l.default.createElement(n.default.Body,null,d?l.default.createElement(i.ImageEditor,{imageId:t,imageSrc:d,onCancel:g,onSave:e=>{(null==e?void 0:e.success)&&(g(),updateFragmentsPreviewImage({dispatch:s,fileEntryId:t,fragmentEntryLinks:a,languageId:f}))},saveURL:e}):l.default.createElement(r.default,null)))};var r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/loading-indicator")),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 a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var i=r?Object.getOwnPropertyDescriptor(e,n):null;i&&(i.get||i.set)?Object.defineProperty(a,n,i):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("@frontend-taglib-clay$clayui/modal")),i=a("item-selector-taglib"),l=(_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),_interopRequireDefault(a("liferay!frontend-js-react-web$react"))),o=_interopRequireDefault(a("../../../app/actions/updatePreviewImage")),d=a("../../../app/config/index"),u=a("../../../app/contexts/StoreContext"),c=_interopRequireDefault(a("../../../app/selectors/selectLanguageId")),s=_interopRequireDefault(a("../../../app/services/FragmentService")),f=_interopRequireDefault(a("../../../app/services/ImageService"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function updateFragmentsPreviewImage({dispatch:e,fileEntryId:t,fragmentEntryLinks:a,languageId:r}){const n=Object.values(a).filter((e=>Object.values(e.editableValues).reduce(((e,t)=>[...e,...Object.entries(t)]),[]).some((([,a])=>{var n,i;return!e.removed&&"object"==typeof a&&(a.classPK===t||(null===(n=a[r])||void 0===n?void 0:n.classPK)===t||(null===(i=a[d.config.defaultLanguageId])||void 0===i?void 0:i.classPK)===t)})))),i=f.default.getFileEntry({fileEntryId:t}),l=n.map((({fragmentEntryLinkId:e})=>s.default.renderFragmentEntryLinkContent({fragmentEntryLinkId:e}).then((({content:t})=>({content:t,fragmentEntryLinkId:e})))));return Promise.all([i,...l]).then((([{fileEntryURL:a},...r])=>{e((0,o.default)({contents:r,fileEntryId:t,previewURL:a}))}))}}}));
//# sourceMappingURL=ImageEditorModal.js.map