"use strict";(function(){"use strict";try{let O=function(e){const t=new Uint8Array(e);if(window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(t);else for(let o=0;o<e;o++)t[o]=Math.floor(Math.random()*256);let i="";for(let o=0;o<t.length;o++)i+=String.fromCharCode(t[o]);return"v3."+btoa(i).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},u=function(e){if(d)try{return d.getItem(e)}catch{d=null}return e in A?A[e]:null},C=function(e,t){if(d)try{d.setItem(e,t);return}catch{d=null}A[e]=t},B=function(){try{const e=Date.now(),t=parseInt(u(P)||"0",10);let i=u(D);if(!i||!t||e-t>L){i=O(16),C(D,i);const o=u(D);o&&o!==i&&(i=o),N&&me()}return N=!0,C(P,String(e)),i}catch{return""}},se=function(){const e=navigator;return{userAgent:e.userAgent,language:e.language,languages:e.languages,platform:e.platform,cookiesEnabled:e.cookieEnabled,doNotTrack:e.doNotTrack||"unspecified",vendor:e.vendor,onLine:e.onLine,webdriver:e.webdriver||!1}},le=function(){const e=window.screen;return{screenResolution:`${e.width}x${e.height}`,availableResolution:`${e.availWidth}x${e.availHeight}`,viewportSize:`${window.innerWidth}x${window.innerHeight}`,colorDepth:e.colorDepth,pixelDepth:e.pixelDepth,pixelRatio:window.devicePixelRatio||1,orientation:e.orientation?e.orientation.type:"unknown",touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,deviceMemory:navigator.deviceMemory||"unknown",hardwareConcurrency:navigator.hardwareConcurrency||"unknown"}},de=function(){const e=new URLSearchParams(window.location.search),t={};return["utm_source","utm_medium","utm_campaign","utm_term","utm_content"].forEach(o=>{const l=e.get(o);l&&(t[o]=l)}),t},U=function(){return{url:window.location.href,hostname:window.location.hostname,path:window.location.pathname,query:window.location.search,hash:window.location.hash,title:document.title,referrer:document.referrer||null,charset:document.characterSet,utm:de()}},ue=function(){const e=new Date;return{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:e.getTimezoneOffset(),locale:Intl.DateTimeFormat().resolvedOptions().locale,timestamp:e.toISOString()}},pe=function(){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;return e?{effectiveType:e.effectiveType,downlink:e.downlink,rtt:e.rtt,saveData:e.saveData}:null},fe=function(){if(!window.performance||!window.performance.timing)return null;const e=window.performance.timing,t=window.performance.navigation,i=e.loadEventEnd-e.navigationStart,o=e.domContentLoadedEventEnd-e.navigationStart;let l=null,h=null;return window.performance.getEntriesByType&&window.performance.getEntriesByType("paint").forEach(a=>{a.name==="first-paint"?l=Math.round(a.startTime):a.name==="first-contentful-paint"&&(h=Math.round(a.startTime))}),{loadTime:i>0?i:null,domReady:o>0?o:null,firstPaint:l,firstContentfulPaint:h,navigationType:t?t.type:null,redirectCount:t?t.redirectCount:null}},ge=function(){return R+(s!==null?Date.now()-s:0)},me=function(){R=0,s=document.hidden?null:Date.now(),c.mouseMovements=0,c.clicks=0,c.maxScrollDepth=0},we=function(){return{timeOnPage:Math.round(ge()/1e3),mouseMovements:c.mouseMovements,clicks:c.clicks,scrollDepth:c.maxScrollDepth}},he=function(){const e=window.innerHeight,t=document.documentElement.scrollHeight,i=window.pageYOffset||document.documentElement.scrollTop,o=Math.round(i/(t-e)*100);return Math.min(100,Math.max(0,o||0))},ve=function(){x||(c.mouseMovements++,m=!0,x=window.setTimeout(()=>{x=null},100))},Se=function(e){c.clicks++,m=!0},Te=function(){if(!b){const e=he();e>c.maxScrollDepth&&(c.maxScrollDepth=e),m=!0,b=window.setTimeout(()=>{b=null},200)}},p=function(e,t={},i=!1,o=!1){const l=!I&&e==="page_view"?E:e;r("sendTrackingData called, eventType:",l,"pixelId:",T);const h=Date.now();if(!i&&I&&h-M<500){r("Skipping send -- another send happened within 500ms");return}!I&&e==="page_view"&&(I=!0),M=h,m=!1;const v={pixelId:T,userId:k||void 0,sessionId:B()||void 0,browser:se(),device:le(),page:U(),location:ue(),connection:pe(),performance:fe(),behavior:we(),timestamp:new Date().toISOString(),customData:t,scriptEventType:l,scriptA1:H,scriptA2:j,scriptA3:K,scriptA4:V,scriptA5:Y,scriptA6:q,scriptA7:J,scriptA8:X,scriptA9:G,scriptA10:W,scriptA11:Z,scriptA12:Q,scriptA13:ee,scriptA14:te,scriptA15:ne,scriptA16:ie,scriptA17:oe,scriptA18:re,scriptA19:ae,scriptA20:ce};if(v.scriptEventType&&r("Sending tracking with scriptEventType:",v.scriptEventType),r("Sending tracking data to:",_,"useBeacon:",o),o&&navigator.sendBeacon){const a=new Blob([JSON.stringify(v)],{type:"application/json"});navigator.sendBeacon(_,a)}else fetch(_,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v),credentials:"include",keepalive:!0}).then(a=>(r("Fetch response status:",a.status),a.json())).then(a=>{r("Fetch response:",a)}).catch(a=>{console.error("[Pixel] Tracking error:",a)})},$=function(e,t={}){fetch(z,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pixelId:T,userId:k||void 0,sessionId:B()||void 0,page:U(),scriptEventType:e,timestamp:new Date().toISOString(),eventName:e,eventData:t}),credentials:"include",keepalive:!0}).catch(i=>console.error("Event tracking error:",i))},Ie=function(){r("Initializing pixel script, readyState:",document.readyState),document.addEventListener("mousemove",ve),document.addEventListener("click",Se),window.addEventListener("scroll",Te),document.readyState==="loading"?(r("DOM still loading, waiting for DOMContentLoaded"),document.addEventListener("DOMContentLoaded",()=>{r("DOMContentLoaded fired, calling sendTrackingData"),w||(w=!0,p("page_view"))})):(r("DOM already loaded, calling sendTrackingData immediately"),w=!0,p("page_view"));let e=!1;const t=()=>{if(e)return;if(e=!0,!w){w=!0,p("page_view",{},!0,!0);return}if(Date.now()-M<500)return;const i=parseInt(u(P)||"0",10);i&&Date.now()-i>L||p("page_ping",{},!0,!0)};document.addEventListener("visibilitychange",()=>{document.hidden?t():e=!1}),window.addEventListener("pagehide",t),window.addEventListener("beforeunload",t),setInterval(()=>{!document.hidden&&m&&p("page_ping")},3e4),window.goq=window.goq||$,window.pixelTrack=$,window.pixelSend=(i,o={})=>p(i,o,!0)};const f="https://pixel.wrango.io",_=`${f}/track`,z=`${f}/event`;let S=document.currentScript,g="";if(S&&S.src)g=S.src;else{const e=document.getElementsByTagName("script");for(let t=e.length-1;t>=0;t--)if(e[t].src&&e[t].src.includes("pixel.js")){S=e[t],g=e[t].src;break}}const n=g?new URL(g).searchParams:new URLSearchParams,T=n.get("id")||"",E=n.get("eventType")||void 0,F=n.get("debug")==="true"||n.get("debug")==="1",r=(...e)=>{F&&console.log("[Pixel]",...e)};r("Script starting to execute"),r("Script src:",g),r("Extracted parameters - pixelId:",T,"eventType:",E);const H=n.get("a1")||void 0,j=n.get("a2")||void 0,K=n.get("a3")||void 0,V=n.get("a4")||void 0,Y=n.get("a5")||void 0,q=n.get("a6")||void 0,J=n.get("a7")||void 0,X=n.get("a8")||void 0,G=n.get("a9")||void 0,W=n.get("a10")||void 0,Z=n.get("a11")||void 0,Q=n.get("a12")||void 0,ee=n.get("a13")||void 0,te=n.get("a14")||void 0,ne=n.get("a15")||void 0,ie=n.get("a16")||void 0,oe=n.get("a17")||void 0,re=n.get("a18")||void 0,ae=n.get("a19")||void 0,ce=n.get("a20")||void 0,L=1800*1e3,y="_wrango_uid",D="_wrango_sid",P="_wrango_sid_ts";let d=(()=>{try{const e="__wrango_probe__";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),window.localStorage}catch{return null}})();const A={},k=(()=>{try{let e=u(y);if(!e){e=O(32),C(y,e);const t=u(y);t&&t!==e&&(e=t)}return e}catch(e){return r("First-party identity unavailable:",e),""}})();let N=!1;r("First-party identity - userId:",k,"storage:",d?"localStorage":"memory");let c={pageLoadTime:Date.now(),mouseMovements:0,clicks:0,maxScrollDepth:0},R=0,s=document.hidden?null:Date.now();document.addEventListener("visibilitychange",()=>{document.hidden?s!==null&&(R+=Date.now()-s,s=null):s===null&&(s=Date.now())});let x=null,b=null,M=0,m=!1,I=!E,w=!1;r("Calling init()"),Ie()}catch(f){console.error("[Pixel] Error during script initialization:",f),console.error("[Pixel] Error stack:",f.stack)}})();
