Liferay.Loader.define("@liferay/commerce-product-asset-categories-web@4.0.48/js/EditAssetCategoryCPDisplayLayout",["module","exports","require","@liferay/frontend-icons-web","frontend-js-web"],(function(e,t,n){window;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function _default({assetCategory:e,categorySelectorUrl:t,itemSelectorUrl:n,portletNamespace:c,title:o}){const s=document.getElementById("".concat(c,"displayPageItemRemove")),i=document.getElementById("".concat(c,"displayPageNameInput")),d=document.getElementById("".concat(c,"pagesContainerInput")),r=document.getElementById("".concat(c,"chooseDisplayPage"));null==r||r.addEventListener("click",(()=>{(0,l.openSelectionModal)({onSelect:e=>{e&&i&&d&&(d.value=e.id,i.innerHTML=e.name,null==s||s.classList.remove("hide"))},selectEventName:"selectDisplayPage",title:Liferay.Language.get("select-category-display-page"),url:n})})),s&&i&&d&&s.addEventListener("click",(()=>{i.innerHTML=Liferay.Language.get("none"),d.value="",s.classList.add("hide")}));function createLabel(e,t){const n=document.createElement("span");n.classList.add("label","label-dismissible","label-secondary"),n.setAttribute("id",e);const l=document.createElement("span");l.classList.add("label-item","label-item-expand");const c=document.createElement("a");c.setAttribute("href","#"+e),c.innerText=t,l.appendChild(c);const o=document.createElement("span");o.classList.add("label-item","label-item-after");const s=document.createElement("button");s.classList.add("close"),s.setAttribute("aria-label","Close"),s.setAttribute("type","button"),s.addEventListener("click",handleCloseButtonClick);const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.classList.add("lexicon-icon","lexicon-icon-times"),i.setAttribute("focusable",!1),i.setAttribute("role","presentation");const d=document.createElementNS("http://www.w3.org/2000/svg","use");return d.setAttribute("href","".concat((0,a.getSpritemap)(),"#times")),i.appendChild(d),s.appendChild(i),o.appendChild(s),n.appendChild(l),n.appendChild(o),n}const u=document.getElementById("".concat(c,"categoriesContainer"));function handleCloseButtonClick(e){const t=e.currentTarget;null==u||u.removeChild(t.parentElement.parentElement)}const m=document.getElementById("".concat(c,"classPK")),g=null==e?void 0:e.categoryId;if(g){const e=createLabel("category-".concat(g),o);null==u||u.appendChild(e),m.value=g}const p=document.getElementById("".concat(c,"selectCategories"));null==p||p.addEventListener("click",(()=>{(0,l.openSelectionModal)({buttonAddLabel:Liferay.Language.get("done"),multiple:!0,onSelect:e=>{e&&Object.keys(e).forEach((t=>{const n=e[t];if(n.unchecked&&!u)return;const a=u.children;if(a.length)for(let e=0;e<a.length;e++)u.removeChild(a.item(e));delete e[t];const l=createLabel("category-".concat(n.categoryId),n.value);u.appendChild(l),m.value=n.categoryId}))},selectEventName:"".concat(c,"selectCategory"),title:Liferay.Language.get("select-category-display-page"),url:t})}))};var a=n("@liferay/frontend-icons-web"),l=n("frontend-js-web")}));
//# sourceMappingURL=EditAssetCategoryCPDisplayLayout.js.map