(function(c,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(c=typeof globalThis<"u"?globalThis:c||self,l(c.SentryNetSDK={}))})(this,(function(c){"use strict";function l(n){for(var t=1;t"u")){i=l({},t,i),typeof i.expires=="number"&&(i.expires=new Date(Date.now()+i.expires*864e5)),i.expires&&(i.expires=i.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var d in i)i[d]&&(s+="; "+d,i[d]!==!0&&(s+="="+i[d].split(";")[0]));return document.cookie=r+"="+n.write(a,r)+s}}function o(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var a=document.cookie?document.cookie.split("; "):[],i={},s=0;s{const o=new Date;o.setTime(e),g.set(n,t,{expires:o})},v=(n,t)=>{w(m,n,t)};class C{appId;token="";expiresAt=0;constructor(t){if(!t||t.length===0)throw new Error("Missing appId");this.appId=t}async setToken(t,e,o,r){if(await this.fetchToken(t,e,o,r),this.token.length===0)throw new Error("Failed to fetch token");v(this.token,this.expiresAt*1e3)}getToken(){return this.token}async fetchToken(t,e,o,r){const a=await fetch("https://api.sentrynet.io/v1/tokens",{method:"POST",credentials:"omit",headers:{"Content-Type":"application/json","X-App-Id":this.appId},body:JSON.stringify({sdk:{port:t,token:e,fingerprint:o,capabilities:r}})});if(!a.ok)throw new Error("Failed to fetch token");const i=await a.json();this.token=i.token,this.expiresAt=i.expires}}function y(){const n=window,t=navigator,e=Intl,o="userAgentData"in navigator;let r=null,a=null;return o&&t.userAgentData?.brands&&(r=t.userAgentData.brands.map(i=>`${i.brand}/${i.version}`),a=t.userAgentData.mobile??null),{hasChrome:"chrome"in window&&n.chrome!==void 0,hasCsi:!!n.chrome?.csi,hasLoadTimes:!!n.chrome?.loadTimes,hasApp:!!n.chrome?.app,hasUserAgentData:o,brands:r,mobile:a,hasV8BreakIterator:"v8BreakIterator"in Intl&&e.v8BreakIterator!==void 0,hasPaintWorklet:!!n.CSS?.paintWorklet}}function T(){const n=window,t=navigator;let e=!1;try{e=CSS.supports("-moz-appearance","none")}catch{}return{hasInstallTrigger:"InstallTrigger"in window,hasBuildID:"buildID"in navigator,buildID:t.buildID??null,hasMozInnerScreenX:"mozInnerScreenX"in window&&n.mozInnerScreenX!==void 0,hasMozAppearance:e}}function I(){const n=window,t=navigator;return{hasSafari:"safari"in window&&n.safari!==void 0,hasPushNotification:!!n.safari?.pushNotification,hasStandalone:"standalone"in navigator&&t.standalone!==void 0}}function S(){const n=window;return{hasOpr:"opr"in window&&n.opr!==void 0,hasOpera:"opera"in window&&n.opera!==void 0}}function k(){let n="";try{n=eval.toString().length.toString()}catch{}return{evalToString:n,navigatorVendor:navigator.vendor,navigatorProduct:navigator.product,navigatorProductSub:navigator.productSub}}function A(){return{chrome:y(),firefox:T(),safari:I(),opera:S(),general:k()}}const x=2166136261,b=16777619;function D(n){let t=x;for(let e=0;e>>0;return t.toString(16).padStart(8,"0")}function B(n){try{const t=document.createElement("canvas");t.width=200,t.height=50;const e=t.getContext("2d");return e?(e.textBaseline="top",e.font="14px Arial",e.fillStyle="#f60",e.fillRect(10,1,62,20),e.fillStyle="#069",e.fillText("SentryNet,😀",2,15),e.fillStyle="rgba(102, 204, 0, 0.7)",e.fillText("SentryNet,😀",4,17),e.fillStyle="rgba(0, 0, 0, 0.01)",e.font="6px monospace",e.fillText(n,100,40),e.globalCompositeOperation="multiply",e.fillStyle="rgb(255,0,255)",e.beginPath(),e.arc(50,30,20,0,Math.PI*2,!0),e.closePath(),e.fill(),e.fillStyle="rgb(0,255,255)",e.beginPath(),e.arc(75,30,20,0,Math.PI*2,!0),e.closePath(),e.fill(),t.toDataURL()):""}catch{return""}}async function O(){try{if(!(window.AudioContext||window.webkitAudioContext))return"";const t=new OfflineAudioContext(1,44100,44100),e=t.createOscillator();e.type="triangle",e.frequency.setValueAtTime(1e4,t.currentTime);const o=t.createDynamicsCompressor();o.threshold.setValueAtTime(-50,t.currentTime),o.knee.setValueAtTime(40,t.currentTime),o.ratio.setValueAtTime(12,t.currentTime),o.attack.setValueAtTime(0,t.currentTime),o.release.setValueAtTime(.25,t.currentTime),e.connect(o),o.connect(t.destination),e.start(0),e.stop(.1);const a=(await t.startRendering()).getChannelData(0).slice(4500,5e3);let i=0;for(let s=0;s{window.SentryChallenge&&window.SentryChallenge.createWidget(n,t,e,o)},document.body.appendChild(r)}c.init=F,c.renderChallenge=R,c.setToken=j,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));