Liferay.Loader.define("@liferay/commerce-product-definitions-web@7.0.46/js/EditDisplayLayout",["module","exports","require","frontend-js-web"],(function(e,t,a){window;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({displayPageItemSelectorUrl:e,portletNamespace:t,productItemSelectorUrl:a,removeIcon:o,searchContainerId:c}){const d=Liferay.Util.getOpener();Liferay.componentReady("".concat(t).concat(c)).then((e=>{(e=>{const c=document.getElementById("".concat(t,"selectProduct"));if(!c)return;c.addEventListener("click",(n=>{n.preventDefault(),d.Liferay.Util.openSelectionModal({onSelect:a=>{if(!a)return;const n=e.getData(),c=document.querySelector('a[data-rowid="'.concat(n,'"]'));if(c){const t=c.closest("tr");t&&e.deleteRow(t,c.dataset.rowid)}const d=[];d.push(a.name),d.push('<a class="float-right modify-link" data-rowId="'.concat(a.id,'" href="javascript:;">').concat(o,"</a>"));const i=document.getElementById("".concat(t,"classPK"));i&&(i.value=a.id),e.addRow(d,a.id),e.updateDataStore()},selectEventName:"productDefinitionsSelectItem",title:Liferay.Util.sub(Liferay.Language.get("select-x"),Liferay.Language.get("product")),url:a})}));const i=e.get("contentBox");(0,n.delegate)(i.getDOMNode(),"click",".modify-link",(a=>{const n=a.delegateTarget,o=n.closest("tr");e.deleteRow(o,n.dataset.rowid);const c=document.getElementById("".concat(t,"classPK"));c&&(c.value=0)}))})(e)})),(()=>{const a=document.getElementById("".concat(t,"chooseDisplayPage")),n=document.getElementById("".concat(t,"displayPageItemRemove")),o=document.getElementById("".concat(t,"pagesContainerInput")),c=document.getElementById("".concat(t,"displayPageNameInput"));a&&n&&o&&c&&(a.addEventListener("click",(()=>{d.Liferay.Util.openSelectionModal({buttonAddLabel:Liferay.Language.get("done"),multiple:!0,onSelect:e=>{e&&(o.value=e.id,c.innerHTML=e.name,n.classList.remove("hide"))},selectEventName:"selectDisplayPage",title:Liferay.Language.get("select-product-display-page"),url:e})})),n.addEventListener("click",(()=>{c.innerHTML=Liferay.Language.get("none"),o.value="",n.classList.add("hide")})))})()};var n=a("frontend-js-web")}));
//# sourceMappingURL=EditDisplayLayout.js.map