Liferay.Loader.define("asset-categories-admin-web@5.0.69/js/ItemSelectorAddCategory",["module","exports","require","frontend-js-web"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function _default({currentURL:e,namespace:t,redirect:a}){document.querySelector(".lfr-form-content .sheet").classList.add("border-0");const n=(0,o.getOpener)(),d=n.document.querySelector(".modal-title"),c=d.textContent;d.textContent="".concat(d.textContent," - ").concat(Liferay.Language.get("add-new"));const r=n.document.querySelectorAll(".liferay-modal .modal-footer .btn-group-item");r.forEach((e=>{e.classList.add("hide")}));const s=n.document.querySelector(".modal-footer .btn-group"),l=s.querySelectorAll(".add-category-toolbar-button");if(l.length)l.forEach((e=>{e.parentElement.classList.remove("hide")}));else{[createButton({action:"cancel",buttonClasses:["btn-outline-borderless","btn-outline-secondary"],label:Liferay.Language.get("cancel"),type:"button"}),createButton({action:"saveAndAddNew",buttonClasses:["btn-secondary"],label:Liferay.Language.get("save-and-add-a-new-one")}),createButton({action:"save",buttonClasses:["btn-primary"],label:Liferay.Language.get("save")})].forEach((e=>s.appendChild(e)))}const i=(0,o.delegate)(s,"click",".add-category-toolbar-button",(n=>{const d=n.delegateTarget.dataset.action;"cancel"===d?(0,o.navigate)(a):"saveAndAddNew"===d?(document.getElementById("".concat(t,"redirect")).value=e,submitForm(document.getElementById("".concat(t,"fm")))):"save"===d&&submitForm(document.getElementById("".concat(t,"fm")))}));return{dispose:()=>{r.forEach((e=>{e.classList.remove("hide")})),s.querySelectorAll(".add-category-toolbar-button").forEach((e=>e.parentElement.classList.add("hide"))),d.textContent=c,i.dispose()}}};var o=a("frontend-js-web");const createButton=({action:e,buttonClasses:t,label:a,type:o="submit"})=>{const n=document.createElement("div");n.classList.add("btn-group-item");const d=document.createElement("button");d.classList.add("add-category-toolbar-button","btn");for(const e of t)d.classList.add(e);return d.dataset.action=e,d.textContent=a,d.type=o,n.appendChild(d),n}}}));
//# sourceMappingURL=ItemSelectorAddCategory.js.map