Liferay.Loader.define("@liferay/document-library-web@6.0.135/document_library/js/data-engine/DataEngineLayoutBuilderHandler.es",["module","exports","require","frontend-js-web","../saveDDMStructure.es"],(function(e,a,t){window;{Object.defineProperty(a,"__esModule",{value:!0}),a.default=function DataEngineLayoutBuilderHandler({namespace:e}){const a=document.getElementById("".concat(e,"fm")),getDataLayoutBuilder=()=>Liferay.componentReady("".concat(e,"dataLayoutBuilder")),detectClickOutside=async({target:a})=>{if(isElementInnerSelector(a,".cke_dialog",".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 getDataLayoutBuilder()).current.dispatch({submitButtonId:"".concat(e,"submitButton"),type:"sidebar_field_blur"})}};window.addEventListener("mousedown",detectClickOutside,!0);const saveDataEngineStructure=async()=>{const t=await getDataLayoutBuilder(),r=document.getElementById("".concat(e,"name")),o=(0,d.getInputLocalizedValues)(e,"name"),{defaultLanguageId:i}=t.current.state.dataDefinition;if(!r.value||!o[i])return(0,n.openToast)({message:(0,n.sub)(Liferay.Language.get("please-enter-a-valid-title-for-the-default-language-x"),i.replace("_","-")),title:Liferay.Language.get("error"),type:"danger"}),void r.focus();(0,n.postForm)(a,{data:(0,d.getDataEngineStructure)({dataLayoutBuilder:t,namespace:e})})};return a.addEventListener("submit",saveDataEngineStructure),Liferay.after("inputLocalized:localeChanged",(async e=>{const a=e.item.getAttribute("data-value"),t=await getDataLayoutBuilder();t.current.dispatch({payload:{languageId:a},type:"language_add"}),t.current.dispatch({payload:{editingLanguageId:a},type:"language_change"})})),{dispose(){a.removeEventListener("submit",saveDataEngineStructure),window.removeEventListener("mousedown",detectClickOutside,!0)}}};var n=t("frontend-js-web"),d=t("../saveDDMStructure.es");const isElementInnerSelector=(e,...a)=>!a.some((a=>e.closest(a)))}}));
//# sourceMappingURL=DataEngineLayoutBuilderHandler.es.js.map