(()=>{var e={1669:e=>{"use strict";e.exports=jQuery}},t={},n=function n(d){var s=t[d];if(void 0!==s)return s.exports;var a=t[d]={exports:{}};return e[d](a,a.exports,n),a.exports}(1669);document.addEventListener("DOMContentLoaded",(function(){document.addEventListener("click",(function(e){const t=e.target.closest("#edd-confirm-prune-logs");if(!t)return;e.preventDefault();const n=document.querySelector(".edd-promo-notice"),d=n?.querySelector("#edd-prune-logs-result"),s=t.dataset.logType,a=t.dataset.days,o=t.dataset.defaultText,i=t.dataset.updatingText;let r=0;function c(){t.disabled=!1,t.classList.remove("updating-message"),t.textContent=o}function l(e,t){d&&(d.innerHTML=`<span style="color: ${t};">${e}</span>`,d.classList.remove("edd-hidden"))}function u(){n&&n.classList.remove("edd-promo-notice--is-visible"),location.reload()}t.disabled=!0,t.classList.add("updating-message"),t.textContent=i,d&&(d.innerHTML="",d.classList.add("edd-hidden")),function e(){fetch(wpApiSettings.root+"edd/v3/logs/prune",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":wpApiSettings.nonce},credentials:"same-origin",body:JSON.stringify({log_type:s,days:a})}).then((e=>e.json())).then((t=>{if(t.success&&t.count>0)r+=t.count,l(`${eddLogSettings.i18n.deleting} ${r} ${eddLogSettings.i18n.deletedSoFar}`,"#46b450"),e();else if(t.success&&0===t.count){const e=n?.querySelector(".edd-promo-notice__actions");e&&e.classList.add("edd-hidden"),l(r>0?1===r?eddLogSettings.i18n.oneDeleted:eddLogSettings.i18n.manyDeleted.replace("%d",r):eddLogSettings.i18n.noLogsFound,"#46b450"),setTimeout(u,2e3)}else c(),l(t.message||eddLogSettings.i18n.errorOccurred,"#dc3232")})).catch((()=>{c(),l(eddLogSettings.i18n.errorTryAgain,"#dc3232")}))}()})),document.querySelectorAll(".edd-log-pruning-number").forEach((e=>{e.dataset.originalValue=e.value})),document.querySelectorAll('input[type="number"]').forEach((e=>{e.addEventListener("change",(function(){const e=this.closest("tr"),t=e?.querySelector(".edd-prune-now");t&&(t.dataset.value=this.value)}))})),document.querySelectorAll(".edd-log-pruning-number").forEach((e=>{e.addEventListener("blur",(function(){const e=this.dataset.setting,t=this.dataset.nonce,d=this.value;if(d===this.dataset.originalValue)return;this.dataset.originalValue=d,this.classList.add("updating");const s=new FormData;s.append("action","edd_update_log_pruning_number"),s.append("setting",e),s.append("value",d),s.append("nonce",t),fetch(ajaxurl,{method:"POST",credentials:"same-origin",body:s}).then((e=>e.json())).then((e=>{if(this.classList.remove("updating"),e.success){this.value=e.data.value,this.dataset.originalValue=e.data.value;const t=this.closest("tr"),d=t?.querySelector(".edd-prune-now");d&&(d.dataset.value=e.data.value,void 0!==n&&n(d).data("value",e.data.value)),this.classList.add("edd-saved"),setTimeout((()=>{this.classList.remove("edd-saved")}),1e3)}})).catch((()=>{this.classList.remove("updating")}))}))})),function(){const e=document.querySelector('input[name="log_pruning_enabled"]');e&&e.addEventListener("change",(function(){var e;e=this.checked,document.querySelectorAll('.edd-log-type-toggle input[type="checkbox"]').forEach((t=>{"1"===t.dataset.prunable&&(t.disabled=!e)})),document.querySelectorAll(".edd-log-type-days").forEach((t=>{"1"===t.dataset.prunable&&(t.disabled=!e)}))}))}()}))})();