Liferay.Loader.define("journal-web@5.0.100/js/DataEngineLayoutBuilderHandler.es",["module","exports","require","frontend-js-web"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({namespace:t}){const n=document.getElementById("".concat(t,"fm")),r=()=>Liferay.componentReady("".concat(t,"dataLayoutBuilder")),i=e=>{const n=Liferay.component("".concat(t).concat(e)),a={};if(n){n.get("translatedLanguages").values().forEach((e=>{a[e]=n.getValue(e)}))}return a},c=async()=>{const e=await r(),{dataDefinition:c,dataLayout:u}=e.current.state,{defaultLanguageId:d}=c,s=document.getElementById("".concat(t,"name")),l=i("name"),f=i("description");if(!s.value&&!l[d])return(0,a.openToast)({message:(0,a.sub)(Liferay.Language.get("please-enter-a-valid-title-for-the-default-language-x"),d.replace("_","-")),title:Liferay.Language.get("error"),type:"danger"}),void s.focus();(e=>{const n=Liferay.component("".concat(t,"name"));if(n){const a=document.getElementById("".concat(t,"languageId")).value;if(!n.get("translatedLanguages").has(a)&&a!==e){n.updateInput("");const e=Liferay.Form.get("".concat(t,"fm"));e&&e.removeRule("".concat(t,"name"),"required")}}})(d),(0,a.postForm)(n,{data:{dataDefinition:JSON.stringify(o(o({},c.serialize()),{},{description:f,name:l})),dataLayout:JSON.stringify(o(o({},u.serialize()),{},{description:f,name:l}))}})};n.addEventListener("submit",c);const u=async({target:n})=>{if(e(n,".ddm-form-builder-wrapper",".multi-panel-sidebar",".lfr-icon-menu-open",".input-localized-content")){(await r()).current.dispatch({submitButtonId:"".concat(t,"submitButton"),type:"sidebar_field_blur"})}};return window.addEventListener("mousedown",u,!0),Liferay.after("inputLocalized:localeChanged",(async e=>{const t=e.item.getAttribute("data-value"),n=await r();n.current.dispatch({payload:{languageId:t},type:"language_add"}),n.current.dispatch({payload:{editingLanguageId:t},type:"language_change"})})),{dispose(){n.removeEventListener("submit",c),window.removeEventListener("mousedown",u,!0)}}};var a=n("frontend-js-web");function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const e=(e,...t)=>!t.some((t=>e.closest(t)))}}));
//# sourceMappingURL=DataEngineLayoutBuilderHandler.es.js.map