Liferay.Loader.define("@liferay/document-library-web@6.0.112/document_library/js/data-engine/DataEngineLayoutBuilderHandler.es",["module","exports","require","frontend-js-web","../saveDDMStructure.es"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({namespace:t}){const a=document.getElementById("".concat(t,"fm")),r=()=>Liferay.componentReady("".concat(t,"dataLayoutBuilder")),o=async({target:a})=>{if(e(a,".clay-color-dropdown-menu",".date-picker-dropdown-menu",".ddm-form-builder-wrapper",".ddm-select-dropdown",".input-localized-content",".lfr-icon-menu-open",".multi-panel-sidebar")){(await r()).current.dispatch({submitButtonId:"".concat(t,"submitButton"),type:"sidebar_field_blur"})}};window.addEventListener("mousedown",o,!0);const i=async()=>{const e=await r(),o=document.getElementById("".concat(t,"name")),i=(0,d.getInputLocalizedValues)(t,"name"),{defaultLanguageId:u}=e.current.state.dataDefinition;if(!o.value||!i[u])return(0,n.openToast)({message:(0,n.sub)(Liferay.Language.get("please-enter-a-valid-title-for-the-default-language-x"),u.replace("_","-")),title:Liferay.Language.get("error"),type:"danger"}),void o.focus();(0,n.postForm)(a,{data:(0,d.getDataEngineStructure)({dataLayoutBuilder:e,namespace:t})})};return a.addEventListener("submit",i),Liferay.after("inputLocalized:localeChanged",(async e=>{const t=e.item.getAttribute("data-value"),a=await r();a.current.dispatch({payload:{languageId:t},type:"language_add"}),a.current.dispatch({payload:{editingLanguageId:t},type:"language_change"})})),{dispose(){a.removeEventListener("submit",i),window.removeEventListener("mousedown",o,!0)}}};var n=a("frontend-js-web"),d=a("../saveDDMStructure.es");const e=(e,...t)=>!t.some((t=>e.closest(t)))}}));
//# sourceMappingURL=DataEngineLayoutBuilderHandler.es.js.map