document.addEventListener("DOMContentLoaded",(function(){const e=document.querySelector(".edd-invoices-bulk__actions");if(e){const n=document.querySelector("#doaction");n&&(n.insertAdjacentElement("afterend",e),e.classList.remove("edd-hidden"));const o=document.querySelectorAll("th.check-column input"),s=document.querySelector("#cb-select-all-1"),c=document.querySelector(".edd-invoices-bulk");function t(){const e=Array.from(o).some((e=>e.checked));c.disabled=!e,c.disabled?(c.classList.remove("button-primary"),c.classList.add("button-secondary")):(c.classList.remove("button-secondary"),c.classList.add("button-primary"))}s.addEventListener("change",(function(){o.forEach((e=>{e.dispatchEvent(new Event("change"))}))})),o.forEach((e=>{e.addEventListener("change",t)})),c.addEventListener("click",(function(e){e.preventDefault();const t=c.nextElementSibling;t&&t.classList.contains("edd-help-tip")&&t.remove(),c.classList.add("updating-message"),c.classList.add("button-secondary"),c.classList.remove("button-primary"),c.setAttribute("disabled",!0),c.textContent=EDDInvoices.running;const n=document.querySelectorAll("th.check-column input:checked");let i=[];if(n.forEach((function(e){i.push(e.value)})),0===i.length)return c.classList.remove("updating-message"),void(c.textContent=EDDInvoices.text);const a=new FormData;a.append("action","edd_invoices_bulk"),a.append("ids",i),a.append("nonce",EDDInvoices.nonce),fetch(EDDInvoices.ajaxurl,{method:"POST",body:a}).then((function(e){return e.json()})).then((function(e){var t=window.open("","_blank","popup=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=1024,height=768");t.document.write(e.data),setTimeout((function(){t.window.print()}),500)})).then((function(){!function(e,t,n){e.classList.remove("updating-message"),e.classList.add("updated-message"),setTimeout((function(){e.classList.remove("updated-message"),e.textContent=EDDInvoices.text,t.forEach((e=>{e.checked=!1})),n.checked=!1}),2e3)}(c,o,s)}))}))}}));