!function(){let e,t;const n=new Set,o={init:function(a){let r=a.lastElementChild;for(;r&&"TBODY"!==r.tagName;)r=r.previousElementSibling;const c=r.querySelector("tr:first-child").cloneNode(!0);return a.dataset.form=a.closest("form"),a.dataset.tbody=r,a.dataset.row=c,a.dataset.currentRow=c,e=document.getElementById("nova-menu-tax"),t=document.getElementById("_wpnonce"),a.addEventListener("keypress",function(e){13===e.which&&(e.preventDefault(),"function"==typeof FormData&&o.submitRow.call(a),o.addRow.call(a))}),a.addEventListener("focusin",function(e){"INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName||(a.dataset.currentRow=e.target.closest("tr"))}),n.add(a),a},destroy:function(e){return this.observer&&this.observer.disconnect(),e.removeEventListener("keypress",o.keypressHandler),e.removeEventListener("focusin",o.focusinHandler),n.delete(e),e},submitRow:function(n){const o=n.dataset.currentRow,a=o.querySelectorAll("input, textarea, select"),r=document.querySelector(n.dataset.form),c=Array.from(r.querySelectorAll("input, textarea, select"));a.forEach(e=>e.disabled=!0),c.filter(e=>!a.includes(e)).forEach(e=>e.disabled=!0);const s=new FormData(r);return s.append("ajax","1"),s.append("nova_menu_tax",e.value),s.append("_wpnonce",t.value),fetch("",{method:"POST",body:s}).then(e=>e.text()).then(e=>{o.innerHTML=e}),c.forEach(e=>e.disabled=!1),n},addRow:function(e){const t=e.dataset.row.cloneNode(!0);e.dataset.tbody.appendChild(t);const n=t.querySelector("input, textarea, select");return n&&n.focus(),e},clickAddRow:function(e){let t=e.lastElementChild;for(;t&&"TBODY"!==t.tagName;)t=t.previousElementSibling;const n=t.querySelector("tr:first-child").cloneNode(!0);n.querySelectorAll("input, textarea").forEach(e=>{e.value=""}),t.appendChild(n)}};document.addEventListener("focusin",e=>{const t=e.target.closest(".many-items-table");t&&!n.has(t)&&o.init(t)}),document.addEventListener("click",e=>{if(e.target.matches("a.nova-new-row")){const t=e.target.closest(".many-items-table");t&&(e.preventDefault(),o.clickAddRow(t))}});const a=document.querySelector("#the-list");a&&function(e){new MutationObserver(e=>{e.forEach(e=>{e.removedNodes.forEach(e=>{e.matches&&e.matches(".many-items-table")&&o.destroy(e)})})}).observe(e,{childList:!0,subtree:!0})}(a)}();