!function(){if(!document)return;const e=document.currentScript,t=e.getAttribute("data-api")?`${location.protocol}//${e.getAttribute("data-api")}/`:e.src.replace(/[^\/]+$/,"api/"),n=()=>Date.now().toString(36)+Math.random().toString(36).substr(2);let a=n(),o=!0,i=Date.now(),r=!1;const s=history.pushState,d=history.replaceState,p=()=>{o=!1,a=n(),i=Date.now(),r=!1},c=e=>function(t,n,a){a&&location.pathname!==new URL(a,location.href).pathname?(l(),p(),e.apply(this,arguments),u()):e.apply(this,arguments)},h=e=>new Promise((t=>{const n=new XMLHttpRequest;n.onload=()=>{t(0==n.responseText)},n.open("GET",e),n.setRequestHeader("Content-Type","text/plain"),n.send()})),u=async()=>{h(t+"event/ping?u="+encodeURIComponent(location.host+location.pathname)).then((e=>{fetch(t+"event/hit",{method:"POST",body:JSON.stringify({b:a,e:"load",u:location.href,r:document.referrer,p:o,q:e,t:Intl.DateTimeFormat().resolvedOptions().timeZone}),mode:"no-cors"})}))},l=()=>{r||navigator.sendBeacon(t+"event/hit",JSON.stringify({b:a,e:"unload",m:Date.now()-i})),r=!0};"onpagehide"in self?addEventListener("pagehide",l,{capture:!0}):(addEventListener("beforeunload",l,{capture:!0}),addEventListener("unload",l,{capture:!0})),addEventListener("visibilitychange",(()=>{document.hidden&&l()}),{capture:!0}),h(t+"event/ping").then((t=>{o=t,u(),e.getAttribute("data-hash")?addEventListener("hashchange",u,{capture:!0}):(history.pushState=c(s),history.replaceState=c(d),addEventListener("popstate",(()=>{l(),p(),u()}),{capture:!0}))}))}();