Liferay.Loader.define("journal-web@5.0.81/js/article/Template",["module","exports","require","frontend-js-web"],(function(e,t,a){window;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({currentURL:e,ddmTemplateId:t,editDDMTemplateURL:a,namespace:d,previewArticleContentTemplateURL:c,selectDDMTemplateURL:l}){const i=[],r=e=>"".concat(d).concat(e),m=a=>{if((!a||a.ddmtemplateid!==t)&&confirm(Liferay.Language.get("editing-the-current-template-deletes-all-unsaved-content"))){const t=a&&a.ddmtemplateid||-1,d=(0,n.addParams)("".concat(r("ddmTemplateId"),"=").concat(t),e),c=document.getElementById(r("fm1"));c&&(Liferay.Util.setFormValues(c,{ddmTemplateId:t,ddmTemplateKey:a&&a.ddmtemplatekey||"",ddmTemplateName:a&&a.name||""}),c.action=d,c.submit())}},o=document.getElementById(r("previewWithTemplate"));if(o){const e=()=>{const e=new URL(c);e.searchParams.append(r("ddmTemplateId"),t),e.searchParams.append(r("languageId"),function(e){var t=Liferay.component("".concat(e,"titleMapAsXML"));if(t)return t.getSelectedLanguageId();return themeDisplay.getLanguageId()}(d)),(0,n.openSelectionModal)({iframeBodyCssClass:"",onSelect:e=>m(e),selectEventName:r("preview"),title:Liferay.Language.get("title"),url:e.href})};o.addEventListener("click",e),i.push({detach:()=>{o.removeEventListener("click",e)}})}const s=document.getElementById(r("clearDDMTemplate"));if(s){const e=()=>{m(null)};s.addEventListener("click",e),i.push({detach:()=>{s.removeEventListener("click",e)}})}const p=document.getElementById(r("editDDMTemplate"));p&&(p.addEventListener("click",(()=>{confirm(Liferay.Language.get("editing-the-current-template-deletes-all-unsaved-content"))&&Liferay.Util.navigate(a)})),i.push({detach:()=>{p.removeEventListener("click",p)}}));const u=document.getElementById(r("selectDDMTemplate"));u&&(u.addEventListener("click",(()=>{(0,n.openSelectionModal)({onSelect:e=>m(e),selectEventName:r("selectDDMTemplate"),title:Liferay.Language.get("templates"),url:l})})),i.push({detach:()=>{u.removeEventListener("click",u)}}));return{dispose:()=>{i.forEach((e=>e.detach()))}}};var n=a("frontend-js-web")}));
//# sourceMappingURL=Template.js.map