(()=>{const e=document.getElementById("yasr-user-log-page-navigation-buttons"),t=document.getElementById("yasr-admin-log-page-navigation-buttons");function n(e="yasr-user"){let t=!1;"yasr-admin"===e&&(t=!0);const n=document.getElementById(`${e}-log-total-pages`).dataset.yasrLogTotalPages,o=`${e}_change_log_page`,r=document.getElementById(`${e}-log-nonce-page`).value;let s=[],l=[],u=[],i=[],c=!1,d=!1,g=[];!0===t&&(c=[],d=[]);for(let n=0;n<8;n++)s[n]=document.getElementById(`${e}-log-div-child-${n}`),l[n]=document.getElementById(`${e}-log-vote-${n}`),u[n]=document.getElementById(`${e}-log-post-${n}`),i[n]=document.getElementById(`${e}-log-date-${n}`),!0===t&&(c[n]=document.getElementById(`${e}-log-user-${n}`),d[n]=document.getElementById(`${e}-log-avatar-${n}`),g[n]=document.getElementById(`${e}-log-ip-${n}`)||!1);a(s,l,u,i,n,c,d,e,g,o,r)}function a(n,o,r,s,l,u,i,c,d,g,m){document.querySelectorAll(`.${c}-log-page-num`).forEach((function(p){p.addEventListener("click",(function(){const p=parseInt(this.value);!function(n,a,o){n=parseInt(n);let r="";n>=3&&a>3&&(r+=`<button class="${o}-log-page-num" value="1">\n            &laquo; First </button>&nbsp;&nbsp;...&nbsp;&nbsp;`);let s=n-1;s<=0&&(s=1);let l=n+1;l>=a&&(l=a);for(let e=s;e<=l;e++)r+=e===n?`<button class="button-primary" value="${e}">${e}</button>&nbsp;&nbsp;`:`<button class="${o}-log-page-num" value="${e}">${e}</button>&nbsp;&nbsp;`;a>3&&n<a&&(r+=`...&nbsp;&nbsp;\n            <button class="${o}-log-page-num" value="${a}"> Last &raquo;</button>&nbsp;&nbsp;`);if("yasr-admin"===o)return t.innerHTML=r;e.innerHTML=r}(p,l,c),function(e,t,n,o,r,s,l,u,i,c,d,g){const m=document.getElementById(`${c}-log-loader-metabox`);m.style.display="inline";const p={action:d,pagenum:e,totalpages:l,yasr_user_log_nonce:g};fetch(yasrWindowVar.ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(p).toString()}).then((e=>{if(!0===e.ok)return e.json();throw new Error("Ajax Call Failed.")})).then((e=>{if("object"!=typeof e||Array.isArray(e)||null===e)throw new Error(`The response is not an object, response is: ${e}`);if(Object.hasOwn(e,"status")){if("success"!==e.status)throw new Error(e.message);y(e),a(t,n,o,r,l,u,i,c,s,d,g)}})).catch((e=>{console.error("Fetch network error",e)})).catch((e=>{console.error("Error with the Query",e)})).finally((()=>{m.style.display="none"}));const y=e=>{let a;for(let l=0;l<8;l++)e.data[l]?(t[l].style.display="block",n[l].innerText=parseInt(e.data[l].vote),Array.isArray(u)&&(u[l].innerText=e.data[l].user_nicename),Array.isArray(i)&&(i[l].src=e.data[l].avatar_url),l in s&&(s[l].innerText=e.data[l].ip),a=`<a href="${e.data[l].permalink}">${e.data[l].post_title}</a>`,o[l].innerHTML=a,r[l].innerText=e.data[l].date):t[l].style.display="none"}}(p,n,o,r,s,d,l,u,i,c,g,m)}))}))}e&&n(),t&&n("yasr-admin")})();