(()=>{"use strict";function e(e){return new Promise((t,n)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>n(e.error)})}let t;function n(){return t||(t=function(t,n){let i;return(s,o)=>(()=>{if(i)return i;const s=indexedDB.open(t);return s.onupgradeneeded=()=>s.result.createObjectStore(n),i=e(s),i.then(e=>{e.onclose=()=>i=void 0},()=>{}),i})().then(e=>o(e.transaction(n,s).objectStore(n)))}("keyval-store","keyval")),t}function i(t,i,s=n()){return s("readwrite",n=>(n.put(i,t),e(n.transaction)))}function s(t,i=n()){return i("readwrite",n=>(t.forEach(e=>n.put(e[1],e[0])),e(n.transaction)))}function o(t,i=n()){return i("readonly",n=>Promise.all(t.map(t=>e(n.get(t)))))}!function(){const e=crypto.randomUUID(),t=new URL(document.currentScript.src);t.pathname="/e";const n=[],r=new URLSearchParams(location.search),a=r.get("session_uuid");a&&o(["session_uuid","session_started_at_ts"]).then(([e,t])=>{e&&e===a||(e&&n.push(e),i("session_uuid",a),t||i("session_started_at_ts",new Date))});let d=!1;function c(e,t){const n=new URL(t.href);n.searchParams.append("session_uuid",e),t.href=n}function u(e,t,n){if(!n&&!d){d=!0;for(const n of document.links)if(""!==n.host&&n.host!==location.host)if(t.includes(n.host))c(e,n);else for(const i of t)if(n.host.endsWith(`.${i}`)){c(e,n);break}}}!function(){const i={action:"pageview"},d=document.getElementsByTagName("h1");if(d.length>0)i.page_title=d[0].textContent.trim();else{const e=document.getElementsByTagName("title");e.length>0&&(i.page_title=e[0].textContent.trim())}i.domain=location.host,i.page_path=location.pathname,i.query_params=Object.fromEntries(r),i.referrer=document.referrer,i.group_uuid=e,"object"==typeof di_config&&(i.tag_uuids=di_config?.tag_uuids,i.wp_page_id=parseInt(di_config?.page_id,10),i.target_id=di_config?.target_id,i.stringer_match_uuid=di_config?.stringer_match_uuid),i.viewport_width=window.innerWidth,i.viewport_height=window.innerHeight,i.screen_width=window.screen.width,i.screen_height=window.screen.height,o(["session_uuid","session_started_at_ts","domains","domains_fetched_at"]).then(([e,o,r,d,c])=>{if(a)i.session_uuid=a;else if(e)i.session_uuid=e;else{const e=crypto.randomUUID();s([["session_uuid",e],["session_started_at_ts",Date.now()]]),i.session_uuid=e}r?(u(e,r,c),(!d||(Date.now()-d)/1e3>300)&&(i.get_domains=!0)):i.get_domains=!0,i.old_session_uuids=n,i.session_started_at_ts=o,fetch(t,{method:"POST",credentials:"include",keepalive:!0,headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}).then(e=>e.json()).then(e=>{i.get_domains&&(u(i.session_uuid,e.domains,e.is_blocked_cidr),s([["domains",e.domains],["domains_fetched_at",Date.now()],["is_blocked_cidr",i.is_blocked_cidr]]))})})}()}()})();