import{r as e}from"./channel-ByUzMNR5.js";var t=(()=>{try{return new URL(`.`,``+import.meta.url).href}catch{return``}})();function n(e){if(!e)return!1;if(/^(chrome|moz|safari-web|ms-browser)-extension:/i.test(e))return!0;try{let n=new URL(e,window.location.href).href;return t&&n.startsWith(t)?!1:n!==window.location.href.split(`#`)[0]}catch{return!1}}function r(e=`crazygames`,t=typeof window>`u`?``:window.location.hostname){if(e===`crazygames`)return`portal`;let n=t.toLowerCase();return n===`itch.io`||n.endsWith(`.itch.io`)||n===`itch.zone`||n.endsWith(`.itch.zone`)?`itch`:`web`}function i(e=typeof navigator>`u`?``:navigator.userAgent,t=typeof navigator>`u`?!1:navigator.userAgentData?.mobile===!0,n=typeof navigator>`u`?0:navigator.maxTouchPoints){return t||/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile/i.test(e)||/Macintosh/i.test(e)&&n>1?`mobile`:`desktop`}var a=`https://thornlock.pages.dev`.replace(/\/+$/,``),o=r()!==`web`,s=o?a:``,c=(!o||s.length>0)&&e(`analytics`)&&!(()=>{if(typeof navigator>`u`)return!1;let e=navigator;return e.doNotTrack===`1`||e.globalPrivacyControl===!0})()&&!(typeof navigator<`u`&&navigator.webdriver===!0),l=i(),u=[],d=new Set,f,p=!1,m=!1,h=typeof performance>`u`?0:performance.now();function g(){m=!0,u.length=0,f!==void 0&&(clearTimeout(f),f=void 0)}function _(e){if(!(!c||m))try{u.push(e),u.length>=20?H():f===void 0&&(f=setTimeout(H,5e3))}catch{g()}}function v(e){!c||m||d.has(e)||(d.add(e),_(e))}function y(e=r()){return e===`portal`?`host.portal`:e===`itch`?`host.itch`:`host.web`}function b(){P(`boot`),v(`funnel.boot`),v(y())}function x(){if(v(`funnel.gameplay`),typeof performance>`u`)return;let e=performance.now()-h;e<=6e4&&v(`funnel.gameplay.under60`),e<=1e4&&v(`funnel.gameplay.under10`)}var S=[`boot`,`mount`,`ready`,`paint`],C=S.indexOf(`paint`),w=S.indexOf(`ready`),T={mount:`funnel.mount`,ready:`funnel.ready`,paint:`funnel.paint`},E={boot:`funnel.exit.boot`,mount:`funnel.exit.mount`,ready:`funnel.exit.ready`},D={save:`funnel.save`,assets:`funnel.assets`},O={save:`funnel.exit.wait.save`,assets:`funnel.exit.wait.assets`},k=-1,A=!1,j=!1,M={save:!1,assets:!1};function N(){return typeof document>`u`||document.visibilityState!==`hidden`||k<w||k>=C?!1:(k=C,j=!0,v(`funnel.paint.hidden`),A&&v(`funnel.exit.returned`),!0)}function P(e){if(e===`paint`&&j)return;let t=S.indexOf(e);t>k&&(k=t);let n=T[e];n&&v(n),!(e===`ready`&&N())&&e===`paint`&&(typeof performance<`u`&&performance.now()-h>5e3&&v(`funnel.paint.over5s`),A&&v(`funnel.exit.returned`))}function F(e){M[e]=!0,v(D[e])}function I(e){v(e===`save`?`funnel.save.error`:`funnel.assets.timeout`)}function L(){if(A||k<0||k>=C)return;A=!0;let e=S[k];v(E[e]),e===`mount`&&[`save`,`assets`].forEach(e=>{M[e]||v(O[e])})}function R(e){if(!e)return!1;try{return new URL(e,window.location.href).origin===window.location.origin}catch{return!1}}function z(e){if(k>=C)return;let t=e.target;if(t instanceof Element){R(t.getAttribute(`src`)??t.getAttribute(`href`))&&v(`funnel.error.asset`);return}n(e.filename)||v(`funnel.error.load`)}function B(){k>=C||v(`funnel.error.load`)}function V(){let e=()=>{L(),H()},t=()=>{document.visibilityState===`hidden`&&(N(),H())};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`pagehide`,e),window.addEventListener(`error`,z,!0),window.addEventListener(`unhandledrejection`,B),()=>{document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`pagehide`,e),window.removeEventListener(`error`,z,!0),window.removeEventListener(`unhandledrejection`,B)}}function H(){if(f!==void 0&&(clearTimeout(f),f=void 0),!(!c||m||u.length===0))try{let e=JSON.stringify({e:u.splice(0,u.length),d:l}),t=`${s}/api/events`,n=new Blob([e],{type:`text/plain`});if(navigator.sendBeacon?.(t,n))return;fetch(t,{method:`POST`,body:e,keepalive:!0,headers:{"content-type":`text/plain`}}).catch(g)}catch{g()}}function U(){if(!(!c||m||p)){p=!0;try{[[6e4,`session.m1`],[3e5,`session.m5`],[6e5,`session.m10`],[12e5,`session.m20`]].forEach(([e,t])=>setTimeout(()=>v(t),e))}catch{g()}}}c&&typeof document<`u`&&typeof window<`u`&&V();export{I as a,U as c,v as d,r as f,F as i,_ as l,s as n,P as o,n as p,H as r,b as s,c as t,x as u};