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