"use strict";var LightSDK=(()=>{var G=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var et=Object.prototype.hasOwnProperty;var tt=(s,e)=>{for(var t in e)G(s,t,{get:e[t],enumerable:!0})},nt=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ze(e))!et.call(s,r)&&r!==t&&G(s,r,{get:()=>e[r],enumerable:!(n=Ye(e,r))||n.enumerable});return s};var rt=s=>nt(G({},"__esModule",{value:!0}),s);var ft={};tt(ft,{BehaviorPlugin:()=>de,Client:()=>re,ErrorPlugin:()=>se,InteractionPlugin:()=>be,NetworkPlugin:()=>ue,OfflinePlugin:()=>ge,PerformancePlugin:()=>ae,RouterPlugin:()=>ye,SamplingPlugin:()=>me,Span:()=>C,Transaction:()=>L,addBreadcrumb:()=>Ve,captureEvent:()=>Oe,captureException:()=>De,captureMessage:()=>Be,clearAnonymousId:()=>He,createBaggageFromTransaction:()=>W,dbStatusToSpanStatus:()=>te,default:()=>gt,disable:()=>Ge,enable:()=>Je,flush:()=>Qe,getAnonymousId:()=>qe,getClient:()=>Me,getCurrentSpan:()=>Ae,getCurrentTransaction:()=>$e,httpStatusToSpanStatus:()=>_,init:()=>_e,parseBaggage:()=>Ie,serializeBaggage:()=>X,setAnonymousId:()=>Ne,setExtra:()=>We,setSpan:()=>je,setTag:()=>ze,setTags:()=>Xe,setUser:()=>Fe,startSpan:()=>Ke,startTransaction:()=>Ue,statusToSpanStatus:()=>V});function Ee(s){try{let e=s.match(/^(https?):\/\/([^@]+)@([^/]+)\/(.+)$/);if(!e)throw new Error("Invalid DSN format");let[,t,n,r,i]=e;return{protocol:t,publicKey:n,host:r,projectId:i}}catch(e){throw new Error(`Failed to parse DSN: ${e.message}`)}}function P(s){return`${s.protocol}://${s.host}/api/${s.projectId}/envelope/?sentry_key=${s.publicKey}`}function J(){return"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".replace(/[x]/g,()=>(Math.random()*16|0).toString(16))}function p(){return Date.now()}function I(){return typeof crypto!="undefined"&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,""):J()}function y(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function M(s,e){return!e||e.length===0?!1:e.some(t=>typeof t=="string"?s.includes(t):t.test(s))}function it(s){let e=5381,t=s.length;for(;t;)e=e*33^s.charCodeAt(--t);return e>>>0}function Y(s){return it(s).toString(16)}function D(s,e,t=[]){let n=t.slice(0,3).map(i=>`${i.filename}:${i.lineno||0}`).join("|"),r=e.replace(/['"]?\d+['"]?/g,"").replace(/\s+/g," ").trim();return Y(`${s}:${r}:${n}`)}function B(s,e={}){if(!s)return[];let{captureNodeModules:t=!1,captureColumn:n=!0,relativePathOnly:r=!1,maxFrames:i}=e,o=[],a=s.split(` `),c=typeof location!="undefined"?`${location.protocol}//${location.host}`:"";for(let f of a){let E=f.match(/^\s*at\s*(.+?)\s*\((.+?):(\d+):(\d+)\)\s*$/);if(E){let[,h,g,m,v]=E,S=g.includes("node_modules");if(!t&&S)continue;let b=g;r&&c&&g.startsWith(c)&&(b=g.substring(c.length)),o.push({filename:b,function:h,lineno:parseInt(m,10),colno:n?parseInt(v,10):void 0,in_app:!S})}else{let h=f.match(/^\s*at\s*(.+?)@(.+?):(\d+):(\d+)\s*$/);if(h){let[,m,v,S,b]=h,x=v.includes("node_modules");if(!t&&x)continue;let Te=v;r&&c&&v.startsWith(c)&&(Te=v.substring(c.length)),o.push({filename:Te,function:m||"",lineno:parseInt(S,10),colno:n?parseInt(b,10):void 0,in_app:!x});continue}let g=f.match(/^\s*at\s*(.+?):(\d+):(\d+)\s*$/);if(g){let[,m,v,S]=g,b=m.includes("node_modules");if(!t&&b)continue;let x=m;r&&c&&m.startsWith(c)&&(x=m.substring(c.length)),o.push({filename:x,lineno:parseInt(v,10),colno:n?parseInt(S,10):void 0,in_app:!b})}}}let d=o.reverse();return i!==void 0&&i>0?d.slice(0,i):d}var Z=!1;function O(s){Z=s}function u(s,e,t){if(!Z)return;let n=new Date().toISOString(),r=`[LightSDK][${s}]`;t!==void 0?console.log(`${r} ${n} ${e}`,t):console.log(`${r} ${n} ${e}`)}function R(s,e,t){if(!Z)return;let n=new Date().toISOString(),r=`[LightSDK][${s}][ERROR]`;t!==void 0?console.error(`${r} ${n} ${e}`,t):console.error(`${r} ${n} ${e}`)}var F="light_sentry_aid";function N(){if(typeof localStorage=="undefined")return null;try{let s=localStorage.getItem(F);return s||(s=I(),localStorage.setItem(F,s)),s}catch(s){return null}}function H(s){if(typeof localStorage=="undefined")return!1;try{return localStorage.setItem(F,s),!0}catch(e){return!1}}function we(){if(typeof localStorage=="undefined")return!1;try{return localStorage.removeItem(F),!0}catch(s){return!1}}function xe(s){return s.trackAnonymousUsers!==!1}function st(s){let e=[{name:"WeChat",pattern:/MicroMessenger\/([\d.]+)/i},{name:"QQ Browser",pattern:/QIBrowser\/([\d.]+)/i},{name:"UC Browser",pattern:/UCBrowser\/([\d.]+)/i},{name:"Edge",pattern:/Edg\/([\d.]+)/i},{name:"Edge",pattern:/Edge\/([\d.]+)/i},{name:"Opera",pattern:/OPR\/([\d.]+)/i},{name:"Opera",pattern:/Opera\/([\d.]+)/i},{name:"Firefox",pattern:/Firefox\/([\d.]+)/i},{name:"Safari",pattern:/Version\/([\d.]+).*Safari/i},{name:"Chrome",pattern:/Chrome\/([\d.]+)/i},{name:"IE",pattern:/MSIE ([\d.]+)/i},{name:"IE",pattern:/Trident.*rv:([\d.]+)/i}];for(let t of e){let n=s.match(t.pattern);if(n){let r=n[1]||"",i=r.split(".")[0]||"";return{name:t.name,version:r,major:i}}}return{name:"Unknown",version:"",major:""}}function ot(s){let e=[{name:"Windows 11",pattern:/Windows NT 10\.0.*Win64.*x64/i},{name:"Windows 10",pattern:/Windows NT 10\.0/i},{name:"Windows 8.1",pattern:/Windows NT 6\.3/i},{name:"Windows 8",pattern:/Windows NT 6\.2/i},{name:"Windows 7",pattern:/Windows NT 6\.1/i},{name:"Windows Vista",pattern:/Windows NT 6\.0/i},{name:"Windows XP",pattern:/Windows NT 5\.1/i},{name:"macOS",pattern:/Mac OS X ([\d_.]+)/i},{name:"iOS",pattern:/OS ([\d_.]+) like Mac OS X/i},{name:"Android",pattern:/Android ([\d.]+)/i},{name:"Android",pattern:/Android/i},{name:"Linux",pattern:/Linux/i}];for(let t of e){let n=s.match(t.pattern);if(n){let r=n[1]||"";return r&&(r=r.replace(/_/g,".")),{name:t.name,version:r}}}return{name:"Unknown",version:""}}function at(s){let e=/Mobile|Android|iPhone|iPod|BlackBerry|Windows Phone|Opera Mini/i.test(s),t=/Tablet|iPad|PlayBook|Kindle|Silk/i.test(s),n="desktop";t?n="tablet":e&&(n="mobile");let r="",i="",o=s.match(/iPhone/i),a=s.match(/iPad/i),c=s.match(/SM-([A-Z0-9]+)/i),d=s.match(/Pixel ([0-9A-Z]+)/i),f=s.match(/HUAWEI ([A-Z0-9]+)/i);return o?(r="Apple",i="iPhone"):a?(r="Apple",i="iPad"):c?(r="Samsung",i=c[1]):d?(r="Google",i=`Pixel ${d[1]}`):f&&(r="Huawei",i=f[1]),{type:n,vendor:r,model:i}}function ke(){let s=typeof navigator!="undefined"?navigator.userAgent:"",e=st(s),t=ot(s),n=at(s);return{browser:e,os:t,device:n,url:typeof location!="undefined"?location.href:"",referrer:typeof document!="undefined"?document.referrer:"",title:typeof document!="undefined"?document.title:"",language:typeof navigator!="undefined"?navigator.language:"",user_agent:s,screen_width:typeof screen!="undefined"?screen.width:0,screen_height:typeof screen!="undefined"?screen.height:0,viewport_width:typeof window!="undefined"?window.innerWidth:0,viewport_height:typeof window!="undefined"?window.innerHeight:0}}function w(){return typeof location!="undefined"?location.href:""}function Ce(){return typeof document!="undefined"?document.referrer:""}function k(s){if(!s)return s;if(/^\s*javascript:/i.test(s))return"javascript:[filtered]";try{let e=new URL(s),t=["password","passwd","pwd","token","access_token","refresh_token","api_key","apikey","key","secret","private_key","code","auth","id_token","idToken","session","session_id"],n=e.searchParams,r=!1;for(let i of Array.from(n.keys())){let o=i.toLowerCase().replace(/[-_]/g,"_");t.some(a=>o.includes(a))&&(n.set(i,"[Filtered]"),r=!0)}if(e.hash&&e.hash.length>1){let i=e.hash.substring(1);if(i.includes("=")){let o=new URLSearchParams(i),a=!1;for(let c of Array.from(o.keys())){let d=c.toLowerCase().replace(/[-_]/g,"_");t.some(f=>d.includes(f))&&(o.set(c,"[Filtered]"),a=!0)}a&&(e.hash="#"+o.toString(),r=!0)}}return r?e.toString():s}catch(e){return s}}function q(s,e=[]){return!e||e.length===0?!1:e.some(t=>{if(typeof t=="string"){if(t.includes("*")){let n=t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(n).test(s)}return s.includes(t)}return t.test(s)})}var ct={Chrome:"c",Safari:"s",Firefox:"f",Edge:"e",Opera:"o",IE:"i",WeChat:"w","QQ Browser":"q","UC Browser":"u","Mobile Chrome":"cm","Mobile Safari":"sm"},ut={"Windows 11":"w11","Windows 10":"w10","Windows 8.1":"w81","Windows 8":"w8","Windows 7":"w7","Windows Vista":"wv","Windows XP":"wxp",macOS:"m",iOS:"i",Android:"a",Linux:"l"};function ee(){let s=ke(),e=ct[s.browser.name]||s.browser.name.toLowerCase(),t=ut[s.os.name]||s.os.name.toLowerCase();return{browser:{name:e,version:s.browser.major},os:{name:t,version:s.os.version.split(".")[0]},device:{type:s.device.type,brand:s.device.vendor||void 0,model:s.device.model||void 0}}}function Re(){let s=ke(),e=`${s.browser.name}|${s.browser.major}|${s.os.name}|${s.os.version.split(".")[0]}|${s.device.type}|${s.device.vendor}|${s.device.model}|${s.language}`;return Y(e).substring(0,16)}var lt={enabled:!0,sampleRate:1,maxQueueSize:100,flushInterval:5e3,maxRetries:3,retryDelay:1e3,environment:"production",contextLevel:{fatal:{maxStackFrames:5,maxBreadcrumbs:20},error:{maxStackFrames:5,maxBreadcrumbs:10},warning:{maxStackFrames:3,maxBreadcrumbs:5},info:{maxStackFrames:0,maxBreadcrumbs:0},debug:{maxStackFrames:0,maxBreadcrumbs:0}}},U=class{constructor(e){this.contexts=null;this.contextId=null;this.contextReported=!1;this.config={...lt,...e}}markContextReported(){this.contextReported=!0}get(e){return this.config[e]}getAll(){return{...this.config}}set(e,t){this.config[e]=t}setUser(e){this.config.user=e||void 0}setTags(e){this.config.tags={...this.config.tags||{},...e}}setTag(e,t){this.config.tags||(this.config.tags={}),this.config.tags[e]=t}setExtra(e,t){this.config.extra||(this.config.extra={}),this.config.extra[e]=t}isIgnoredError(e){return M(e,this.config.ignoreErrors||[])}shouldSample(){var t;let e=(t=this.config.sampleRate)!=null?t:1;return e>=1?!0:e<=0?!1:Math.random()({...g})):void 0}:void 0}}if(e.breadcrumbs&&(n.breadcrumbs=e.breadcrumbs.map(h=>({...h}))),e.user&&(n.user={...e.user}),e.contexts&&(n.contexts={...e.contexts}),this.config.release&&(n.release=this.config.release),this.config.environment&&(n.environment=this.config.environment),n.platform="javascript",this.config.user&&(n.user=this.config.user),this.config.tags&&(n.tags={...this.config.tags,...e.tags||{}}),n.request?n.request.url||(n.request.url=w()):n.request={url:w(),referrer:Ce()},this.contextId||(this.contextId=Re()),n.context_id=this.contextId,!(((o=this.config.user)==null?void 0:o.id)||((a=e.user)==null?void 0:a.id))&&xe(this.config)){let h=N();h&&(n.anonymousId=h)}let i=this.applyContextLevel(n);return t&&!this.contextReported&&(this.contexts||(this.contexts=ee()),i.contexts=this.contexts,i.env={b:(c=this.contexts.browser)==null?void 0:c.name,bv:(d=this.contexts.browser)==null?void 0:d.version,os:(f=this.contexts.os)==null?void 0:f.name,osv:(E=this.contexts.os)==null?void 0:E.version}),i}applyContextLevel(e){let t=this.config.contextLevel;if(!t)return e;let n=e.level||"error",r=t[n]||t.error,i={...e};if("exception"in e&&e.exception&&typeof e.exception=="object"){let o=e.exception;if(o.stacktrace&&typeof o.stacktrace=="object"){let a=o.stacktrace;Array.isArray(a.frames)&&(r.maxStackFrames===0?delete i.exception:i.exception={...o,stacktrace:{...a,frames:a.frames.slice(0,r.maxStackFrames)}})}}return e.breadcrumbs&&Array.isArray(e.breadcrumbs)&&(r.maxBreadcrumbs===0?delete i.breadcrumbs:i.breadcrumbs=e.breadcrumbs.slice(-r.maxBreadcrumbs)),i}};var $=class{constructor(){this.handlers=new Map}on(e,t){this.handlers.has(e)||this.handlers.set(e,[]),this.handlers.get(e).push(t)}off(e,t){let n=this.handlers.get(e);if(n){let r=n.indexOf(t);r>-1&&n.splice(r,1)}}emit(e,...t){let n=this.handlers.get(e);if(n)for(let r of n)try{r(...t)}catch(i){console.error("[LightSDK] EventBus handler error:",i)}}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}destroy(){this.handlers.clear()}};var A=class{constructor(e,t,n,r,i){this.queue=[];this.timer=null;this.lastFlushTime=0;this.isFlushing=!1;this.dedupeMap=new Map;this.pendingCounts=new Map;this.errorRateWindow={};this.paused=!1;this.pauseTimer=null;this.maxSize=e,this.flushInterval=t,this.eventBus=n,this.flushCallback=r,this.syncFlushCallback=i}start(){this.startTimer(),this.setupVisibilityListener()}startTimer(){this.timer||(this.timer=setInterval(()=>{(this.queue.length>0||this.pendingCounts.size>0)&&this.flush()},this.flushInterval))}setupVisibilityListener(){this.onVisibilityChange=()=>{document.hidden&&(this.queue.length>0||this.pendingCounts.size>0)&&this.flushSync()},typeof document!="undefined"&&document.addEventListener("visibilitychange",this.onVisibilityChange),this.onBeforeUnload=()=>{(this.queue.length>0||this.pendingCounts.size>0)&&this.flushSync()},this.onPagehide=()=>{(this.queue.length>0||this.pendingCounts.size>0)&&this.flushSync()},typeof window!="undefined"&&(window.addEventListener("beforeunload",this.onBeforeUnload),window.addEventListener("pagehide",this.onPagehide))}checkInfiniteLoop(e){let t=p(),n=t-1e3;this.errorRateWindow[e]||(this.errorRateWindow[e]=[]);let r=this.errorRateWindow[e];for(r.push(t);r.length>0&&r[0]10?(this.paused||(console.warn("[LightSDK] Infinite loop detected, pausing SDK for 60s",{fingerprint:e,count:r.length}),this.eventBus.emit("error",new Error("Infinite loop detected")),this.paused=!0,this.pauseTimer&&clearTimeout(this.pauseTimer),this.pauseTimer=setTimeout(()=>{this.paused=!1,this.errorRateWindow={},console.info("[LightSDK] Resumed after infinite loop detection")},6e4)),!0):!1}enqueue(e){if(u("EventQueue","enqueue called",{type:e.type,level:e.level,message:"message"in e?e.message:void 0}),this.paused){u("EventQueue","enqueue skipped: queue paused (infinite loop detected)");return}this.cleanupExpiredDedupeEntries();let t=this.getDedupeKey(e);if(t){if(this.checkInfiniteLoop(t)){u("EventQueue","enqueue skipped: infinite loop detected",{fingerprint:t});return}let n=p(),r=this.dedupeMap.get(t);if(r)if(n-r.lastTime<6e4){if(r.count>=3){if(!this.pendingCounts.has(t))this.pendingCounts.set(t,{count:1,ts_start:n,ts_end:n});else{let i=this.pendingCounts.get(t);i.count++,i.ts_end=n}u("EventQueue","enqueue skipped: deduped (count >= 3)",{fingerprint:t,count:r.count});return}r.count++,r.lastTime=n,u("EventQueue","Dedup count incremented",{fingerprint:t,count:r.count})}else this.dedupeMap.set(t,{count:1,lastTime:n,firstReported:!0}),this.pendingCounts.delete(t),u("EventQueue","Dedup entry reset (expired)",{fingerprint:t});else this.dedupeMap.set(t,{count:1,lastTime:n,firstReported:!1}),u("EventQueue","New dedup entry created",{fingerprint:t})}this.queue.push(e),u("EventQueue","Event added to queue",{queueSize:this.queue.length}),this.eventBus.emit("event",e),this.queue.length>=this.maxSize&&(u("EventQueue","Queue reached maxSize, triggering flush",{maxSize:this.maxSize}),this.flush())}cleanupExpiredDedupeEntries(){if(Math.random()>.1)return;let e=p(),t=6e4;for(let[n,r]of this.dedupeMap)e-r.lastTime>t&&this.dedupeMap.delete(n)}buildCountEvents(){let e=[];for(let[t,n]of this.pendingCounts.entries()){let r={type:"count",fingerprint:t,count:n.count,ts_start:n.ts_start,ts_end:n.ts_end,timestamp:p(),level:"info"};e.push(r)}return e}getDedupeKey(e){if(e.type==="error"){let t=e;return t.fingerprint||t.message}return null}async flush(){if(u("EventQueue","flush called",{queueSize:this.queue.length,pendingCounts:this.pendingCounts.size,isFlushing:this.isFlushing}),this.queue.length===0&&this.pendingCounts.size===0){u("EventQueue","flush skipped: queue is empty");return}if(this.isFlushing){u("EventQueue","flush skipped: already flushing");return}this.isFlushing=!0;let e=this.queue.splice(0,this.queue.length),t=this.buildCountEvents(),n=[...e,...t];u("EventQueue","flush events to callback",{total:n.length,events:e.length,countEvents:t.length}),this.lastFlushTime=p(),this.eventBus.emit("report",n);try{await this.flushCallback(n),this.pendingCounts.clear(),u("EventQueue","flush completed successfully"),this.eventBus.emit("reported",n)}catch(r){throw u("EventQueue","flush failed, returning events to queue",{error:r instanceof Error?r.message:String(r)}),e.forEach(i=>this.queue.unshift(i)),r}finally{this.isFlushing=!1}}flushSync(){if(this.queue.length===0&&this.pendingCounts.size===0)return;let e=this.queue.splice(0,this.queue.length),t=new Map(this.pendingCounts),n=this.buildCountEvents(),r=[...e,...n];this.lastFlushTime=p(),this.eventBus.emit("report",r);try{this.syncFlushCallback(r),this.pendingCounts.clear(),this.eventBus.emit("reported",r)}catch(i){console.error("[LightSDK] Sync flush failed",i),e.forEach(o=>this.queue.unshift(o));for(let[o,a]of t)this.pendingCounts.has(o)||this.pendingCounts.set(o,a)}}size(){return this.queue.length}destroy(){this.timer&&(clearInterval(this.timer),this.timer=null),this.pauseTimer&&(clearTimeout(this.pauseTimer),this.pauseTimer=null),typeof document!="undefined"&&this.onVisibilityChange&&document.removeEventListener("visibilitychange",this.onVisibilityChange),typeof window!="undefined"&&(this.onBeforeUnload&&window.removeEventListener("beforeunload",this.onBeforeUnload),this.onPagehide&&window.removeEventListener("pagehide",this.onPagehide)),this.queue=[],this.dedupeMap.clear(),this.pendingCounts.clear(),this.errorRateWindow={}}};var Le={event_id:"eid",timestamp:"ts",start_timestamp:"sts",type:"t",level:"l",message:"m",platform:"p",release:"r",environment:"e",fingerprint:"fp",context_id:"cid",user:"u",tags:"tg",exception:"ex",request:"req",contexts:"ctx",breadcrumbs:"bc",transaction:"tx",duration:"d",spans:"sp",extra:"xt"},Bt=Object.fromEntries(Object.entries(Le).map(([s,e])=>[e,s]));function Pe(s){if(!s||typeof s!="object")return s;let e={};for(let[t,n]of Object.entries(s)){let r=Le[t]||t;e[r]=n}return e}var j=class{constructor(e,t,n){this.useShortFields=!0;this.dsn=e,this.maxRetries=t,this.retryDelay=n}async report(e){if(u("Reporter","report called",{eventCount:e.length}),e.length===0){u("Reporter","report skipped: empty events");return}let t=this.buildEnvelope(e),n=P(this.dsn);u("Reporter","Envelope built",{envelopeSize:t.length,url:n});let r=0;for(;r<=this.maxRetries;)try{u("Reporter",`Sending request (attempt ${r+1}/${this.maxRetries+1})`),await this.send(t,!1),u("Reporter","Request succeeded");return}catch(i){let o=i.status;if(R("Reporter",`Request failed (attempt ${r+1})`,{status:o,error:i}),o&&o>=400&&o<500)throw i;if(r++,r>this.maxRetries)throw R("Reporter","All retries exhausted"),i;let a=Math.min(this.retryDelay*Math.pow(2,r-1),5e3);u("Reporter",`Retrying in ${a}ms`),await this.delay(a)}}reportSync(e){if(e.length===0)return;let t=this.buildEnvelope(e);try{if(this.sendSync(t))return}catch(n){}this.sendViaImage(t)}buildEnvelope(e){let t=this.extractSharedMeta(e),n={event_id:J(),sent_at:new Date().toISOString(),meta:t};this.useShortFields&&(n._sf=1);let r=this.applyRelativeTimestamps(e,n),o=[JSON.stringify(n)];for(let a of r){let c=this.stripSharedFields(a,t);this.useShortFields&&(c=Pe(c));let d=JSON.stringify(c),f=JSON.stringify({type:this.getEnvelopeType(a),length:d.length});o.push(f,d)}return o.join(` `)}applyRelativeTimestamps(e,t){if(e.length<=1)return e;let n=[],r=e[0].timestamp?new Date(e[0].timestamp).getTime():Date.now();t._rt=1,t._bt=r;for(let i=0;io.release===t.release)&&(n.release=t.release),t.environment&&e.every(o=>o.environment===t.environment)&&(n.environment=t.environment),t.user&&e.every(o=>JSON.stringify(o.user)===JSON.stringify(t.user))&&(n.user=t.user);let r=t.env;return r&&(n.env=r),n}stripSharedFields(e,t){let n={...e};return t.release&&n.release===t.release&&delete n.release,t.environment&&n.environment===t.environment&&delete n.environment,t.user&&JSON.stringify(n.user)===JSON.stringify(t.user)&&delete n.user,t.env&&delete n.env,n}getEnvelopeType(e){switch(e.type){case"error":return"event";default:return e.type}}async send(e,t=!1){let n=P(this.dsn);if(navigator.sendBeacon)try{let r=new Blob([e],{type:"application/x-sentry-envelope"});if(navigator.sendBeacon(n,r))return}catch(r){}if(typeof fetch=="function")try{let r=new AbortController,i=setTimeout(()=>r.abort(),1e4),o=await fetch(n,{method:"POST",body:e,headers:{"Content-Type":"application/x-sentry-envelope"},keepalive:!0,signal:r.signal});if(clearTimeout(i),o.ok)return;let a=new Error(`HTTP ${o.status}`);throw a.status=o.status,a}catch(r){throw r}if(typeof XMLHttpRequest!="undefined")return new Promise((r,i)=>{let o=new XMLHttpRequest;o.open("POST",n,!t),o.setRequestHeader("Content-Type","application/x-sentry-envelope"),o.timeout=1e4,o.onload=()=>{if(o.status>=200&&o.status<300)r();else{let a=new Error(`HTTP ${o.status}`);a.status=o.status,i(a)}},o.onerror=()=>i(new Error("Network error")),o.ontimeout=()=>i(new Error("Request timeout")),o.send(e)});throw new Error("No transport available")}sendSync(e){let t=P(this.dsn);if(navigator.sendBeacon)try{let n=new Blob([e],{type:"application/x-sentry-envelope"});return navigator.sendBeacon(t,n)}catch(n){return!1}if(typeof XMLHttpRequest!="undefined")try{let n=new XMLHttpRequest;return n.open("POST",t,!1),n.setRequestHeader("Content-Type","application/x-sentry-envelope"),n.send(e),n.status>=200&&n.status<300}catch(n){return!1}return!1}sendViaImage(e){try{let t=P(this.dsn),n=new Image,r=encodeURIComponent(btoa(e)),i=t.includes("?")?"&":"?";return n.src=t+i+"sentry_data="+r.substring(0,2e3),!0}catch(t){return!1}}delay(e){return new Promise(t=>setTimeout(t,e))}};var K=class{constructor(e){this.plugins=new Map;this.client=e}add(e){if(!this.plugins.has(e.name)){this.plugins.set(e.name,e);try{e.setup(this.client)}catch(t){console.error(`[LightSDK] Plugin "${e.name}" setup error:`,t)}}}remove(e){let t=this.plugins.get(e);if(t){if(t.destroy)try{t.destroy()}catch(n){console.error(`[LightSDK] Plugin "${e}" destroy error:`,n)}this.plugins.delete(e)}}get(e){return this.plugins.get(e)}has(e){return this.plugins.has(e)}applyBeforeReport(e){let t=e;for(let n of this.plugins.values())if(n.beforeReport)try{let r=n.beforeReport(t);if(r===null)return null;t=r}catch(r){console.error(`[LightSDK] Plugin "${n.name}" beforeReport error:`,r)}return t}applyAfterReport(e){for(let t of this.plugins.values())if(t.afterReport)try{t.afterReport(e)}catch(n){console.error(`[LightSDK] Plugin "${t.name}" afterReport error:`,n)}}destroy(){for(let e of this.plugins.values())if(e.destroy)try{e.destroy()}catch(t){console.error(`[LightSDK] Plugin "${e.name}" destroy error:`,t)}this.plugins.clear()}};var z="sentry-";function X(s){let e=[];for(let[n,r]of Object.entries(s)){if(r==null||r==="")continue;let i=n.startsWith(z)?n:`${z}${n}`;e.push(`${i}=${encodeURIComponent(String(r))}`)}let t=e.join(",");if(t.length>8192){t=t.substring(0,8192);let n=t.lastIndexOf(",");n>0&&(t=t.substring(0,n))}return t}function Ie(s){let e={};if(!s)return e;let t=s.split(",");for(let n of t){let r=n.indexOf("=");if(r===-1)continue;let i=n.substring(0,r).trim(),o=decodeURIComponent(n.substring(r+1).trim()),a=i;i.startsWith(z)&&(a=i.substring(z.length)),a&&(e[a]=o)}return e}function W(s,e){let t={trace_id:s};return e!=null&&e.dsnPublicKey&&(t.public_key=e.dsnPublicKey),(e==null?void 0:e.sampled)!==void 0&&(t.sampled=e.sampled?"true":"false"),(e==null?void 0:e.sampleRate)!==void 0&&(t.sample_rate=String(e.sampleRate)),e!=null&&e.user&&(e.user.id&&(t.user_id=e.user.id),e.user.segment&&(t.user_segment=e.user.segment)),e!=null&&e.release&&(t.release=e.release),e!=null&&e.environment&&(t.environment=e.environment),t}function dt(){return I().replace(/-/g,"")}function pt(){return I().replace(/-/g,"").substring(0,16)}function _(s){return s>=200&&s<300?"ok":s===400?"invalid_argument":s===401?"unauthenticated":s===403?"permission_denied":s===404?"not_found":s===409?"already_exists":s===429?"resource_exhausted":s>=400&&s<500?"invalid_argument":s>=500&&s<600?"internal_error":"unknown_error"}function te(s){if(s==null||s==="")return"unknown_error";let e=typeof s=="string"?parseInt(s,10):s;return e===0||e===1?"ok":e>=10&&e<20?"invalid_argument":e>=20&&e<30?"not_found":e>=30&&e<40?"already_exists":e>=50?"internal_error":"unknown_error"}function V(s,e){if(s===void 0)return"unknown_error";if(typeof s=="string"){let t=s.toLowerCase();if(t==="ok"||t==="success")return"ok";if(t==="cancelled"||t==="canceled")return"cancelled";if(t==="deadline_exceeded")return"deadline_exceeded";if(t==="not_found")return"not_found";if(t==="already_exists")return"already_exists";if(t==="permission_denied")return"permission_denied";if(t==="resource_exhausted")return"resource_exhausted";if(t==="failed_precondition")return"failed_precondition";if(t==="invalid_argument")return"invalid_argument";if(t==="unauthenticated")return"unauthenticated";if(t==="internal_error")return"internal_error";let n=parseInt(s,10);return isNaN(n)?"unknown_error":V(n,e)}if(typeof s=="number"){if(s>=200&&s<600)return _(s);if(e!=null&&e.startsWith("db"))return te(s);if(s===0)return"ok";if(s>0)return"unknown_error"}return"unknown_error"}var C=class s{constructor(e,t,n){this.tags={};this.data={};this._isFinished=!1;this.traceId=e.traceId||dt(),this.spanId=e.spanId||pt(),this.parentSpanId=e.parentSpanId,this.op=e.op,this.description=e.description,this.status=e.status,this.tags={...e.tags},this.data={...e.data},this.startTimestamp=e.startTimestamp||p(),this.transaction=t,this._client=n}setTag(e,t){return this.tags[e]=t,this}setData(e,t){return this.data[e]=t,this}setStatus(e){return this.status=e,this}setHttpStatus(e){return this.setStatus(_(e)),this.setTag("http.status_code",String(e)),this}setStatusFromResponse(e,t){let n=V(e,this.op);return this.setStatus(n),t&&e!==void 0&&this.setTag(t,String(e)),this}startChild(e={}){let t=this.transaction,n=(t==null?void 0:t.sampled)!==!1,r=new s({...e,traceId:this.traceId,parentSpanId:this.spanId},t,this._client);return t&&n&&t._addSpan(r),r}finish(e){var t;if(!this._isFinished&&(this._isFinished=!0,this.endTimestamp=e||p(),this._client)){let n=this._client;(t=n.tracingManager)!=null&&t.onSpanFinished&&n.tracingManager.onSpanFinished(this)}}toTraceparent(){var n;let e=(n=this.transaction)==null?void 0:n.sampled,t=e===void 0?"":e?"1":"0";return t?`${this.traceId}-${this.spanId}-${t}`:`${this.traceId}-${this.spanId}`}toJSON(){return{trace_id:this.traceId,span_id:this.spanId,parent_span_id:this.parentSpanId,op:this.op,description:this.description,status:this.status,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,data:Object.keys(this.data).length>0?{...this.data}:void 0,start_timestamp:this.startTimestamp,timestamp:this.endTimestamp||this.startTimestamp}}},L=class extends C{constructor(t,n,r,i,o,a){super(t,void 0,n);this.spans=[];this.maxSpans=1e3;this._droppedSpans=0;this.name=t.name,this.type=t.type,this.sampled=t.sampled,this.transaction=this,this._dsnPublicKey=r,this._release=i,this._environment=o,a!==void 0&&(this.maxSpans=a)}_addSpan(t){if(this.spans.length>=this.maxSpans){this._droppedSpans++;return}this.spans.push(t)}_ensureBaggage(){return this._baggage||(this._baggage=W(this.traceId,{dsnPublicKey:this._dsnPublicKey,sampled:this.sampled,release:this._release,environment:this._environment})),this._baggage}setBaggage(t,n){let r=this._ensureBaggage();return r[t]=n,this}setUserBaggage(t,n){let r=this._ensureBaggage();return t!==void 0?r.user_id=t:delete r.user_id,n!==void 0?r.user_segment=n:delete r.user_segment,this}toBaggage(){let t=this._ensureBaggage();return X(t)}getBaggage(){return this._baggage}finish(t){var n;if(!this._isFinished){if(super.finish(t),this._client&&this.sampled){let r=this.toEvent();this._client.captureEvent(r)}if(this._client){let r=this._client;(n=r.tracingManager)!=null&&n.onTransactionFinished&&r.tracingManager.onTransactionFinished(this)}}}_getSource(){switch(this.type){case"pageload":return"url";case"navigation":return"route";case"user-interaction":return"ui";default:return"custom"}}toEvent(){let t=this.toJSON(),n={...t.data},r=n.measurements;return delete n.measurements,{type:"transaction",transaction:this.name,transaction_info:{source:this._getSource()},level:"info",timestamp:t.timestamp,start_timestamp:t.start_timestamp,spans:this.spans.map(i=>i.toJSON()),contexts:{trace:{trace_id:this.traceId,span_id:this.spanId,parent_span_id:this.parentSpanId,op:this.op,status:this.status}},tags:t.tags,extra:Object.keys(n).length>0?n:void 0,measurements:r,platform:"javascript"}}toJSON(){return{...super.toJSON(),transaction:this.name,type:this.type,spans:this.spans.map(n=>n.toJSON()),sampled:this.sampled}}};var Q=class{constructor(e,t,n){this.currentTransaction=null;this.spanStack=[];this.config=e,this._client=t,this.dsnPublicKey=n}updateConfig(e){var t,n;this.config=e,this.currentTransaction&&this.currentTransaction.setUserBaggage((t=e.user)==null?void 0:t.id,(n=e.user)==null?void 0:n.segment)}shouldSample(e,t){var i;let n=this.config.tracesSampler;if(n){let o={...e,parentSampled:t},a=n(o);if(typeof a=="boolean")return a;let c=Math.max(0,Math.min(1,a));return c===0?!1:c===1?!0:Math.random()=1?!0:r<=0?!1:Math.random()0?this.spanStack[this.spanStack.length-1]:null}setCurrentSpan(e){e===null?this.spanStack.length>1&&this.spanStack.pop():this.spanStack.push(e)}startSpan(e){let t=this.getCurrentSpan();if(!t&&!e.traceId)return u("TracingManager","startSpan skipped: no active span and no traceId"),null;let n;return t?n=t.startChild(e):(n=new C({...e,parentSpanId:e.parentSpanId}),this.currentTransaction&&(this.currentTransaction.sampled!==!1&&this.currentTransaction._addSpan(n),n.transaction=this.currentTransaction)),this.spanStack.push(n),u("TracingManager","Span started",{op:n.op,description:n.description,spanId:n.spanId,parentSpanId:n.parentSpanId,stackDepth:this.spanStack.length}),n}onSpanFinished(e){let t=this.spanStack.lastIndexOf(e);t!==-1&&this.spanStack.splice(t,1),this.spanStack.length===0&&this.currentTransaction&&(this.spanStack=[this.currentTransaction]),u("TracingManager","Span finished",{op:e.op,description:e.description,spanId:e.spanId,stackDepth:this.spanStack.length})}onTransactionFinished(e){this.currentTransaction===e&&(this.currentTransaction=null,this.spanStack=[]),u("TracingManager","Transaction finished",{name:e.name,traceId:e.traceId,spanCount:e.spans.length,sampled:e.sampled})}finishSpan(e){e.finish()}finishTransaction(e){e.finish()}destroy(){if(this.currentTransaction)try{this.currentTransaction.setStatus("aborted"),this.currentTransaction.finish()}catch(e){}this.currentTransaction=null,this.spanStack=[]}};var ne=class{constructor(e){this.breadcrumbs=[];this.enabled=!0;var t,n,r,i;if(!e.dsn)throw new Error("DSN is required");O(e.debug===!0),u("Client","Initializing SDK",{dsn:e.dsn,debug:e.debug,enabled:e.enabled!==!1}),this.dsn=Ee(e.dsn),this.configManager=new U(e),this.eventBus=new $,this.reporter=new j(this.dsn,(t=this.configManager.get("maxRetries"))!=null?t:3,(n=this.configManager.get("retryDelay"))!=null?n:1e3),this.pluginManager=new K(this),this.tracingManager=new Q(e,this,this.dsn.publicKey),this.queue=new A((r=this.configManager.get("maxQueueSize"))!=null?r:100,(i=this.configManager.get("flushInterval"))!=null?i:5e3,this.eventBus,async o=>this.flushEvents(o),o=>this.syncFlushEvents(o)),this.enabled=this.configManager.get("enabled")!==!1,u("Client","SDK initialized",{enabled:this.enabled})}get maxBreadcrumbs(){var e;return(e=this.configManager.get("maxBreadcrumbs"))!=null?e:20}get config(){return this.configManager.getAll()}init(){this.enabled&&(this.queue.start(),this.emit("ready"))}async flushEvents(e){u("Client","flushEvents start",{eventCount:e.length});let t=[];for(let i of e){let o=this.pluginManager.applyBeforeReport(i);o?t.push(o):u("Client","Event filtered by beforeReport plugin",{type:i.type,message:"message"in i?i.message:void 0})}if(t.length===0){u("Client","flushEvents: all events filtered by beforeReport");return}let n=!0,r=[];for(let i of t){let o=this.configManager.applyToEvent(i,n);n=!1;let a=this.configManager.get("beforeSend"),c=a?a(o):o;if(!c){u("Client","Event filtered by beforeSend",{type:i.type});continue}r.push(c)}if(r.length===0){u("Client","flushEvents: all events filtered by beforeSend");return}u("Client","Reporting events",{count:r.length}),await this.reporter.report(r),u("Client","Report completed successfully"),this.configManager.markContextReported();for(let i of r)this.pluginManager.applyAfterReport(i)}syncFlushEvents(e){let t=[];for(let i of e){let o=this.pluginManager.applyBeforeReport(i);o&&t.push(o)}if(t.length===0)return;let n=!0,r=[];for(let i of t){let o=this.configManager.applyToEvent(i,n);n=!1;let a=this.configManager.get("beforeSend"),c=a?a(o):o;c&&r.push(c)}r.length!==0&&(this.reporter.reportSync(r),this.configManager.markContextReported())}on(e,t){this.eventBus.on(e,t)}off(e,t){this.eventBus.off(e,t)}emit(e,...t){this.eventBus.emit(e,...t)}captureException(e){if(u("Client","captureException called",{error:e instanceof Error?e.message:String(e)}),!this.enabled){u("Client","captureException skipped: SDK disabled");return}let t=this.buildErrorEvent(e);if(u("Client","Error event built",{type:t.type,message:t.message,fingerprint:t.fingerprint}),this.configManager.isIgnoredError(t.message)){u("Client","captureException skipped: error ignored by ignoreErrors");return}this.attachTraceContext(t),t.breadcrumbs=[...this.breadcrumbs],u("Client","Enqueue error event",{breadcrumbs:this.breadcrumbs.length}),this.queue.enqueue(t)}captureMessage(e,t="info"){if(!this.enabled)return;let n={type:"error",level:t,message:e,timestamp:p(),breadcrumbs:[...this.breadcrumbs]};this.configManager.isIgnoredError(e)||(this.attachTraceContext(n),this.queue.enqueue(n))}captureEvent(e){if(!this.enabled)return;let t={timestamp:p(),level:"info",breadcrumbs:[...this.breadcrumbs],...e};this.attachTraceContext(t),this.queue.enqueue(t)}attachTraceContext(e){let t=this.tracingManager.getCurrentSpan(),n=this.tracingManager.getCurrentTransaction();if(t||n){let r=(t==null?void 0:t.traceId)||(n==null?void 0:n.traceId),i=(t==null?void 0:t.spanId)||(n==null?void 0:n.spanId),o=t==null?void 0:t.parentSpanId,a=(t==null?void 0:t.op)||(n==null?void 0:n.op),c=(t==null?void 0:t.status)||(n==null?void 0:n.status);e.contexts={...e.contexts,trace:{trace_id:r||"",span_id:i||"",parent_span_id:o,op:a,status:c}}}}buildErrorEvent(e){let t=p();if(e instanceof Error){let r=B(e.stack,{maxFrames:5}),i=D(e.name,e.message,r);return{type:"error",level:"error",message:e.message,timestamp:t,exception:{type:e.name,value:e.message,stacktrace:{frames:r}},fingerprint:i}}return{type:"error",level:"error",message:String(e),timestamp:t}}setUser(e){this.configManager.setUser(e),this.tracingManager.updateConfig(this.configManager.getAll())}setAnonymousId(e){H(e)}startTransaction(e){if(!this.enabled)return null;let t=this.tracingManager.startTransaction(e);return t&&t.sampled&&u("Client","Transaction started and sampled",{name:t.name,traceId:t.traceId}),t}getCurrentTransaction(){return this.tracingManager.getCurrentTransaction()}getCurrentSpan(){return this.tracingManager.getCurrentSpan()}setSpan(e){this.tracingManager.setCurrentSpan(e)}startSpan(e){return this.enabled?this.tracingManager.startSpan(e):null}setTag(e,t){this.configManager.setTag(e,t)}setTags(e){this.configManager.setTags(e)}setExtra(e,t){this.configManager.setExtra(e,t)}addBreadcrumb(e){let t={...e,timestamp:p()};this.breadcrumbs.push(t),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}async flush(){await this.queue.flush()}disable(){this.enabled=!1}enable(){this.enabled=!0}use(e){this.pluginManager.add(e)}destroy(){this.pluginManager.destroy(),this.tracingManager.destroy(),this.queue.destroy(),this.eventBus.destroy(),this.breadcrumbs=[]}},re=ne;var ie=class{constructor(){this.name="error";this.version="1.0.0";this.config={maxStackFrames:5,captureNodeModules:!1,captureColumn:!0,relativePathOnly:!1,resourceSampleRate:.1}}setup(e){this.client=e,this.loadConfig(),this.setupGlobalError(),this.setupUnhandledRejection(),this.setupResourceError()}loadConfig(){let e=this.client.config;e&&y(e.error)&&(this.config={...this.config,...e.error}),e.ignoreErrors&&(this.config.ignoreErrors=[...this.config.ignoreErrors||[],...e.ignoreErrors]),e.ignoreUrls&&(this.config.ignoreUrls=[...this.config.ignoreUrls||[],...e.ignoreUrls]),e.includePaths&&(this.config.includePaths=[...this.config.includePaths||[],...e.includePaths])}shouldIgnoreError(e){return e?M(e,this.config.ignoreErrors||[]):!1}shouldIgnoreScriptUrl(e){return q(e,this.config.ignoreUrls||[])}shouldIncludePath(e){let t=this.config.includePaths||[];return t.length===0?!0:e.some(n=>t.some(r=>{var i;return typeof r=="string"?(i=n.filename)==null?void 0:i.includes(r):r.test(n.filename||"")}))}shouldSample(){var t;let e=(t=this.config.sampleRate)!=null?t:1;return e>=1?!0:e<=0?!1:Math.random()=1?!0:e<=0?!1:Math.random(){try{if(this.originalOnError&&this.originalOnError.call(window,e,t,n,r,i),t&&this.shouldIgnoreScriptUrl(t))return!1;let o=this.buildErrorEvent(i||e,t,n,r);o&&this.client.captureEvent(o)}catch(o){R("ErrorPlugin","Global error handler error",o)}return!1})}setupUnhandledRejection(){typeof window!="undefined"&&(this.onUnhandledRejection=e=>{try{let t=e.reason,n=this.extractUrlFromReason(t);if(n&&this.shouldIgnoreScriptUrl(n))return;let r=this.buildErrorEvent(t);r&&(r.type==="error"&&(r.tags={...r.tags||{},unhandled:"true",promise:"true"}),this.client.captureEvent(r))}catch(t){R("ErrorPlugin","Unhandledrejection handler error",t)}},window.addEventListener("unhandledrejection",this.onUnhandledRejection))}extractUrlFromReason(e){if(e instanceof Error&&e.stack){let t=e.stack.match(/at\s+(?:.+?\s+)?\((https?:\/\/[^:]+):\d+:\d+\)/);if(t)return t[1];let n=e.stack.match(/(https?:\/\/[^\s)]+):\d+:\d+/);if(n)return n[1]}return null}setupResourceError(){typeof window!="undefined"&&(this.onResourceError=e=>{var i;let t=e.target;if(!t)return;let n=(i=t.tagName)==null?void 0:i.toLowerCase(),r=t.src||t.href;if(n&&r&&["img","script","link","audio","video"].includes(n))try{if(this.shouldIgnoreScriptUrl(r)||!this.shouldSampleResource())return;let o=`resource:${n}`,a=k(r);this.client.captureEvent({type:"error",level:"warning",message:`Resource load failed: ${n} ${a}`,timestamp:p(),fingerprint:o,tags:{resource_type:n,resource_url:a},exception:{type:"ResourceError",value:`Failed to load ${n} resource`}})}catch(o){R("ErrorPlugin","Resource error handler error",o)}},window.addEventListener("error",this.onResourceError,!0))}buildErrorEvent(e,t,n,r){let i=p();if(e instanceof Error){if(this.shouldIgnoreError(e.message))return null;let c=B(e.stack,{captureNodeModules:this.config.captureNodeModules,captureColumn:this.config.captureColumn,relativePathOnly:this.config.relativePathOnly,maxFrames:this.config.maxStackFrames});if(!this.shouldIncludePath(c)||!this.shouldSample())return null;let d=D(e.name,e.message,c);return{type:"error",level:"error",message:e.message,timestamp:i,exception:{type:e.name,value:e.message,stacktrace:{frames:c}},fingerprint:d}}let o=String(e);if(this.shouldIgnoreError(o))return null;let a=[];return t&&a.push({filename:t,lineno:n,colno:this.config.captureColumn?r:void 0,in_app:!0}),!this.shouldIncludePath(a)||!this.shouldSample()?null:{type:"error",level:"error",message:o,timestamp:i,exception:{type:"Error",value:o,stacktrace:{frames:a}}}}destroy(){typeof window!="undefined"&&(this.originalOnError!==void 0&&(window.onerror=this.originalOnError),this.onUnhandledRejection&&window.removeEventListener("unhandledrejection",this.onUnhandledRejection),this.onResourceError&&window.removeEventListener("error",this.onResourceError,!0))}},se=ie;var oe=class{constructor(){this.name="performance";this.version="2.0.0";this.config={sampleRate:.1,captureLongTasks:!0,captureResources:!1,resourceSampleRate:.01,longTaskSampleRate:.05,captureNavigation:!0,captureFP:!0,enablePageLoadTracing:!1,maxResourceSpans:50};this.observers=[];this.navLoadTimer=null;this.totalBlockingTime=0;this.fcpTime=null;this.lastLongTaskEndTime=0;this.ttiReported=!1;this.ttiTimer=null;this.pageLoadTransaction=null;this.measurements={};this.resourceSpanCount=0}setup(e){this.client=e,this.loadConfig(),this.config.enablePageLoadTracing&&this.startPageLoadTransaction(),this.observeWebVitals(),this.observeLongTasks(),this.observeNavigation(),this.observeResources()}startPageLoadTransaction(){var n;if(typeof window=="undefined")return;let e=typeof location!="undefined"?location.pathname:"/",t=typeof performance!="undefined"&&((n=performance.timing)!=null&&n.navigationStart)?performance.timing.navigationStart:p();this.pageLoadTransaction=this.client.startTransaction({name:e,op:"pageload",description:`Page load - ${e}`,startTimestamp:t,type:"pageload",tags:{"page.url":e}})}loadConfig(){let e=this.client.config;e&&y(e.performance)&&(this.config={...this.config,...e.performance})}shouldSample(e="default"){var n,r,i;let t=(n=this.config.sampleRate)!=null?n:.1;return e==="resource"?t=(r=this.config.resourceSampleRate)!=null?r:.01:e==="longtask"?t=(i=this.config.longTaskSampleRate)!=null?i:.05:e==="vitals"&&(t=1),t>=1?!0:t<=0?!1:Math.random(){let n=t.getEntriesByName("first-paint");n.length>0&&this.config.captureFP&&this.reportMetric("FP",n[0].startTime,"ms",{},"vitals");let r=t.getEntriesByName("first-contentful-paint");r.length>0&&(this.fcpTime=r[0].startTime,this.lastLongTaskEndTime=r[0].startTime,this.reportMetric("FCP",r[0].startTime,"ms",{},"vitals"),this.scheduleTTI())});e.observe({type:"paint",buffered:!0}),this.observers.push(e)}catch(e){}}observeLCP(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries(),r=n[n.length-1];if(r){let i=r.renderTime||r.loadTime||r.startTime;this.reportMetric("LCP",i,"ms",{},"vitals")}});e.observe({type:"largest-contentful-paint",buffered:!0}),this.observers.push(e)}catch(e){}}observeFID(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();if(n.length>0){let r=n[0],i=r.processingStart-r.startTime;this.reportMetric("FID",i,"ms",{},"vitals")}});e.observe({type:"first-input",buffered:!0}),this.observers.push(e)}catch(e){}}observeCLS(){try{let e=0,t=0,n=[],r=new PerformanceObserver(i=>{let o=i.getEntries();for(let a of o)if(!a.hadRecentInput){let c=n[0],d=n[n.length-1];t&&a.startTime-((d==null?void 0:d.duration)||0)<1e3&&a.startTime-c.startTime<5e3?(t+=a.value||0,n.push(a)):(t=a.value||0,n=[a]),t>e&&(e=t,this.reportMetric("CLS",e,"",{},"vitals"))}});r.observe({type:"layout-shift",buffered:!0}),this.observers.push(r)}catch(e){}}observeTTFB(){try{let e=new PerformanceObserver(t=>{let n=t.getEntriesByType("navigation");if(n.length>0){let r=n[0],i=r.responseStart-r.requestStart;this.reportMetric("TTFB",Math.max(0,i),"ms",{},"vitals")}});e.observe({type:"navigation",buffered:!0}),this.observers.push(e)}catch(e){}}observeLongTasks(){if(this.config.captureLongTasks)try{let e=new PerformanceObserver(t=>{let n=t.getEntries();for(let r of n){let i=r.startTime+r.duration;if(i>this.lastLongTaskEndTime&&(this.lastLongTaskEndTime=i),this.fcpTime!==null&&r.startTime>=this.fcpTime){let o=r.duration-50;o>0&&(this.totalBlockingTime+=o)}this.reportMetric("longtask",r.duration,"ms",{},"longtask"),this.scheduleTTI()}});e.observe({type:"longtask",buffered:!0}),this.observers.push(e)}catch(e){}}scheduleTTI(){this.ttiReported||(this.ttiTimer&&clearTimeout(this.ttiTimer),this.ttiTimer=setTimeout(()=>{if(this.ttiReported)return;this.ttiReported=!0;let e=Math.max(this.lastLongTaskEndTime,this.fcpTime||0);this.reportMetric("TTI",e,"ms",{},"vitals"),this.reportMetric("TBT",this.totalBlockingTime,"ms",{},"vitals")},5e3))}observeNavigation(){this.config.captureNavigation&&typeof performance!="undefined"&&(this.onLoad=()=>{this.navLoadTimer=setTimeout(()=>{let e=performance.timing;if(!e)return;let t=e.navigationStart,n={dom_ready:e.domContentLoadedEventEnd-t,load_time:e.loadEventEnd-t,dns:e.domainLookupEnd-e.domainLookupStart,tcp:e.connectEnd-e.connectStart,ssl:e.secureConnectionStart>0?e.connectEnd-e.secureConnectionStart:0,ttfb:e.responseStart-e.requestStart,download:e.responseEnd-e.responseStart,dom_parse:e.domInteractive-e.responseEnd};for(let[r,i]of Object.entries(n))i>0&&this.reportMetric(r,i,"ms");this.pageLoadTransaction&&this.pageLoadTransaction.sampled!==!1&&(this.buildNavigationSpans(e,t),this.finishPageLoadTransaction(e.loadEventEnd||p())),this.navLoadTimer=null},0)},window.addEventListener("load",this.onLoad))}buildNavigationSpans(e,t){let n=[{op:"dns",desc:"DNS Lookup",start:e.domainLookupStart,end:e.domainLookupEnd},{op:"tcp",desc:"TCP Connection",start:e.connectStart,end:e.connectEnd},{op:"ssl",desc:"SSL/TLS Negotiation",start:e.secureConnectionStart,end:e.connectEnd},{op:"ttfb",desc:"Time to First Byte",start:e.requestStart,end:e.responseStart},{op:"response",desc:"Response Download",start:e.responseStart,end:e.responseEnd},{op:"dom_parse",desc:"DOM Parsing",start:e.responseEnd,end:e.domInteractive},{op:"dom_content_loaded",desc:"DOM Content Loaded",start:e.domLoading,end:e.domContentLoadedEventEnd},{op:"load",desc:"Page Load",start:e.navigationStart,end:e.loadEventEnd}];for(let r of n)r.start>0&&r.end>0&&r.end>r.start&&this.createNavigationSpan(r.op,r.desc,r.start,r.end)}finishPageLoadTransaction(e){this.pageLoadTransaction&&(Object.keys(this.measurements).length>0&&this.pageLoadTransaction.setData("measurements",this.measurements),this.pageLoadTransaction.setStatus("ok"),this.pageLoadTransaction.finish(e),this.pageLoadTransaction=null)}observeResources(){if(!(!this.config.captureResources&&!this.config.enablePageLoadTracing)&&typeof performance!="undefined")try{let e=new PerformanceObserver(t=>{let n=t.getEntriesByType("resource");for(let r of n)r.duration>1e3&&this.config.captureResources&&this.reportMetric("resource_slow",r.duration,"ms",{resource_name:r.name.substring(0,200),resource_type:r.initiatorType},"resource"),this.config.enablePageLoadTracing&&this.pageLoadTransaction&&this.createResourceSpan(r)});e.observe({type:"resource",buffered:!0}),this.observers.push(e)}catch(e){}}getRating(e,t){let r={LCP:{good:2500,poor:4e3},FCP:{good:1800,poor:3e3},FP:{good:1800,poor:3e3},FID:{good:100,poor:300},CLS:{good:.1,poor:.25},TTFB:{good:800,poor:1800}}[e];return!r||t<=r.good?"good":t<=r.poor?"needs-improvement":"poor"}reportMetric(e,t,n,r={},i="default"){if(!this.shouldSample(i))return;let o=this.getRating(e,t),a={type:"performance",level:"info",metric:e,value:Math.round(t*100)/100,unit:n,rating:o,timestamp:p(),tags:{metric:e,rating:o,...r}};this.client.captureEvent(a),this.pageLoadTransaction&&this.pageLoadTransaction.sampled!==!1&&this.recordMeasurement(e,t,n,o)}recordMeasurement(e,t,n,r){this.pageLoadTransaction&&(this.measurements[e]={value:Math.round(t*100)/100,unit:n,rating:r},this.pageLoadTransaction.setTag(`measurement.${e}.rating`,r||"unknown"))}createNavigationSpan(e,t,n,r,i){if(!this.pageLoadTransaction||this.pageLoadTransaction.sampled===!1||r<=n)return;this.pageLoadTransaction.startChild({op:`browser.${e}`,description:t,startTimestamp:n,tags:i}).finish(r)}createResourceSpan(e){var c,d;if(!this.pageLoadTransaction||this.pageLoadTransaction.sampled===!1)return;let t=(c=this.config.maxResourceSpans)!=null?c:50;if(this.resourceSpanCount>=t)return;this.resourceSpanCount++;let n=typeof performance!="undefined"&&performance.timeOrigin?performance.timeOrigin:((d=performance.timing)==null?void 0:d.navigationStart)||0,r=n+e.startTime,i=n+(e.responseEnd||e.duration||e.startTime);if(i<=r)return;let o=e.name.substring(0,200);this.pageLoadTransaction.startChild({op:`resource.${e.initiatorType||"other"}`,description:o,startTimestamp:r,tags:{"resource.type":e.initiatorType||"other","resource.url":o,"resource.transfer_size":String(e.transferSize||0),"resource.decoded_size":String(e.decodedBodySize||0)},data:{transferSize:e.transferSize,decodedSize:e.decodedBodySize,encodedSize:e.encodedBodySize}}).finish(i)}destroy(){for(let e of this.observers)try{e.disconnect()}catch(t){}this.observers=[],this.ttiTimer&&(clearTimeout(this.ttiTimer),this.ttiTimer=null),this.navLoadTimer&&(clearTimeout(this.navLoadTimer),this.navLoadTimer=null),typeof window!="undefined"&&this.onLoad&&window.removeEventListener("load",this.onLoad),this.pageLoadTransaction&&(this.pageLoadTransaction.setStatus("internal_error"),this.pageLoadTransaction.finish(),this.pageLoadTransaction=null),this.measurements={},this.resourceSpanCount=0}},ae=oe;var ce=class{constructor(){this.name="network";this.version="1.1.0";this.config={captureXHR:!0,captureFetch:!0,captureSuccess:!1,captureBody:!1,captureRequestBody:!1,captureResponseBody:!1,captureRequestHeaders:["content-type","user-agent"],captureResponseHeaders:["content-type","content-length"],errorSampleRate:1,successSampleRate:.01,slowThreshold:3e3,slowSampleRate:1,ignoreStatusCodes:[]}}setup(e){this.client=e,this.loadConfig(),this.config.captureFetch&&this.patchFetch(),this.config.captureXHR&&this.patchXHR()}loadConfig(){let e=this.client.config;e&&y(e.network)&&(this.config={...this.config,...e.network}),e.ignoreUrls&&(this.config.ignoreUrls=[...this.config.ignoreUrls||[],...e.ignoreUrls]),e.tracePropagationTargets?this.config.tracePropagationTargets=[...this.config.tracePropagationTargets||[],...e.tracePropagationTargets]:e.tracingOrigins&&(this.config.tracePropagationTargets=[...this.config.tracePropagationTargets||[],...e.tracingOrigins])}shouldIgnore(e){return q(e,this.config.ignoreUrls||[])}shouldTracePropagate(e){let t=this.config.tracePropagationTargets;return!t||t.length===0?this.isSameOrigin(e):t.some(n=>typeof n=="string"?e.includes(n):n.test(e))}isSameOrigin(e){if(typeof location=="undefined")return!1;try{return new URL(e,location.origin).origin===location.origin}catch(t){return!1}}getBaggageHeader(){var r,i;if(!this.client)return;let t=(i=(r=this.client.tracingManager)==null?void 0:r.getCurrentTransaction)==null?void 0:i.call(r);if(!t)return;let n=t;if(n.toBaggage)return n.toBaggage()}shouldSample(e,t){var r,i,o,a;let n=e?(r=this.config.errorSampleRate)!=null?r:1:(i=this.config.successSampleRate)!=null?i:.01;return!e&&t>=((o=this.config.slowThreshold)!=null?o:3e3)&&(n=(a=this.config.slowSampleRate)!=null?a:1),n>=1?!0:n<=0?!1:Math.random()0?e.setHttpStatus(t):r&&e.setStatus("internal_error"),e.finish()}patchFetch(){if(typeof fetch=="undefined")return;this.originalFetch=window.fetch;let e=this;window.fetch=function(t,n){let r=p(),i=typeof t=="string"?t:t instanceof URL?t.toString():t.url,o=(n==null?void 0:n.method)||"GET";if(e.shouldIgnore(i))return e.originalFetch.call(window,t,n);let a=k(i),c=e.createHttpSpan(o,a),d=e.shouldTracePropagate(i)&&!!c,f=n;if(d&&c){let h=c.toTraceparent(),g=e.getBaggageHeader();f={...n,headers:{...(n==null?void 0:n.headers)||{},"sentry-trace":h,...g?{baggage:g}:{}}}}let E=e.originalFetch.call(window,t,f);return E.then(h=>{var S;let g=p()-r,m=h.ok,v=h.status;return c&&e.finishHttpSpan(c,v,g,!m),(S=e.config.ignoreStatusCodes)!=null&&S.includes(v)||!e.shouldSample(!m,g)||(!m||e.config.captureSuccess)&&e.reportNetwork({sub_type:"fetch",method:o.toUpperCase(),url:a,status_code:v,duration:g,success:m,error:m?void 0:`HTTP ${v}`}),h},h=>{let g=p()-r;throw c&&e.finishHttpSpan(c,0,g,!0),e.shouldSample(!0,g)&&e.reportNetwork({sub_type:"fetch",method:o.toUpperCase(),url:a,duration:g,success:!1,error:(h==null?void 0:h.message)||"Network error"}),h}),E}}patchXHR(){if(typeof XMLHttpRequest=="undefined")return;this.originalXHROpen=XMLHttpRequest.prototype.open,this.originalXHRSend=XMLHttpRequest.prototype.send;let e=this;XMLHttpRequest.prototype.open=function(t,n){return this._lightMethod=t,this._lightUrl=typeof n=="string"?n:n.toString(),this._lightTracked=!1,e.originalXHROpen.apply(this,arguments)},XMLHttpRequest.prototype.send=function(t){let n=p(),r=this._lightMethod||"GET",i=this._lightUrl||"",o=this._lightTracked;if(e.shouldIgnore(i)||o)return e.originalXHRSend.apply(this,arguments);this._lightTracked=!0;let a=k(i),c=0;t&&typeof t=="string"&&(c=t.length);let d=e.createHttpSpan(r,a);if(e.shouldTracePropagate(i)&&!!d&&d)try{let h=d.toTraceparent(),g=e.getBaggageHeader();this.setRequestHeader("sentry-trace",h),g&&this.setRequestHeader("baggage",g)}catch(h){}let E=this.onloadend;return this.onloadend=function(h){var S;let g=p()-n,m=this.status,v=m>=200&&m<300;if(d&&e.finishHttpSpan(d,m,g,!v),!((S=e.config.ignoreStatusCodes)!=null&&S.includes(m))&&e.shouldSample(!v,g)&&(!v||e.config.captureSuccess)){let b=0;try{let x=this.getResponseHeader("content-length");x&&(b=parseInt(x,10)),!b&&this.responseText&&(b=this.responseText.length)}catch(x){}e.reportNetwork({sub_type:"xhr",method:r.toUpperCase(),url:a,status_code:m,duration:g,request_size:c||void 0,response_size:b||void 0,success:v,error:v?void 0:`HTTP ${m}`})}if(E)return E.call(this,h)},e.originalXHRSend.apply(this,arguments)}}reportNetwork(e){let t={type:"network",level:e.success?"info":"error",timestamp:p(),tags:{method:e.method,sub_type:e.sub_type,success:String(e.success)},...e};this.client.captureEvent(t)}destroy(){this.originalFetch&&(window.fetch=this.originalFetch),this.originalXHROpen&&(XMLHttpRequest.prototype.open=this.originalXHROpen),this.originalXHRSend&&(XMLHttpRequest.prototype.send=this.originalXHRSend)}},ue=ce;var le=class{constructor(){this.name="behavior";this.version="1.0.0";this.config={capturePV:!0,captureClick:!0,captureRoute:!0,captureDuration:!0,captureScroll:!0,clickThrottle:300,scrollThrottle:1e3,sampleRate:.01};this.lastClickTime=0;this.lastScrollTime=0;this.maxScrollDepth=0;this.pageEnterTime=0;this.scrollReported=!1}setup(e){this.client=e,this.loadConfig(),this.config.capturePV&&this.trackPV(),this.config.captureClick&&this.trackClick(),this.config.captureRoute&&this.trackRoute(),this.config.captureDuration&&this.trackPageDuration(),this.config.captureScroll&&this.trackScroll()}loadConfig(){let e=this.client.config;e&&y(e.behavior)&&(this.config={...this.config,...e.behavior})}shouldSample(){var t;let e=(t=this.config.sampleRate)!=null?t:.01;return e>=1?!0:e<=0?!1:Math.random(){var a,c,d;let t=p(),n=(a=this.config.clickThrottle)!=null?a:300;if(t-this.lastClickTime{let r=w();if(r!==e){let i=e,o=r;e=r,this.reportBehavior({sub_type:"route",page_url:o,referrer:i,properties:{from:i,to:o}}),this.pageEnterTime=p(),this.maxScrollDepth=0,this.scrollReported=!1}};this.originalPushState=history.pushState,this.originalReplaceState=history.replaceState;let n=this;history.pushState=function(){let r=n.originalPushState.apply(this,arguments);return setTimeout(t,0),r},history.replaceState=function(){let r=n.originalReplaceState.apply(this,arguments);return setTimeout(t,0),r},this.onPopState=()=>{setTimeout(t,0)},this.onHashchange=()=>{setTimeout(t,0)},window.addEventListener("popstate",this.onPopState),window.addEventListener("hashchange",this.onHashchange)}trackPageDuration(){if(typeof window=="undefined")return;this.pageEnterTime=p();let e=()=>{let t=p()-this.pageEnterTime;t>1e3&&(this.config.captureScroll&&!this.scrollReported&&this.reportScroll(),this.reportBehavior({sub_type:"duration",page_url:w(),properties:{duration:t,max_scroll_depth:this.maxScrollDepth}}))};this.onVisibilityChange=()=>{document.hidden?e():this.pageEnterTime=p()},this.onBeforeUnload=e,this.onPagehide=e,document.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("beforeunload",this.onBeforeUnload),window.addEventListener("pagehide",this.onPagehide)}trackScroll(){typeof window!="undefined"&&(this.onScroll=()=>{var r;let e=p(),t=(r=this.config.scrollThrottle)!=null?r:1e3;if(e-this.lastScrollTimethis.maxScrollDepth&&(this.maxScrollDepth=n)},window.addEventListener("scroll",this.onScroll,{passive:!0}))}reportScroll(){this.scrollReported||(this.scrollReported=!0,this.reportBehavior({sub_type:"scroll",page_url:w(),properties:{max_depth:this.maxScrollDepth}}))}reportBehavior(e){if(!this.shouldSample())return;let t={type:"behavior",level:"info",timestamp:p(),tags:{sub_type:e.sub_type,page_url:w()},...e};this.client.captureEvent(t)}destroy(){typeof window!="undefined"&&(this.originalPushState&&(history.pushState=this.originalPushState),this.originalReplaceState&&(history.replaceState=this.originalReplaceState),this.onPopState&&window.removeEventListener("popstate",this.onPopState),this.onHashchange&&window.removeEventListener("hashchange",this.onHashchange),this.onBeforeUnload&&window.removeEventListener("beforeunload",this.onBeforeUnload),this.onPagehide&&window.removeEventListener("pagehide",this.onPagehide),this.onScroll&&window.removeEventListener("scroll",this.onScroll)),typeof document!="undefined"&&(this.onClick&&document.removeEventListener("click",this.onClick,!0),this.onVisibilityChange&&document.removeEventListener("visibilitychange",this.onVisibilityChange))}},de=le;var ht="light-sentry-offline",T="events",pe=1e3,he=class{constructor(){this.name="offline";this.version="1.0.0";this.config={maxEvents:pe};this.db=null;this.isOnline=!0;this.isSyncing=!1;this.pendingEvents=[]}setup(e){this.client=e,this.loadConfig(),this.initDatabase(),this.setupNetworkListeners()}loadConfig(){let e=this.client.config;e&&typeof e.offline=="object"&&(this.config={...this.config,...e.offline})}async initDatabase(){if(typeof indexedDB=="undefined"){console.warn("[LightSDK] OfflinePlugin: IndexedDB not available");return}return new Promise((e,t)=>{let n=indexedDB.open(ht,1);n.onerror=()=>{console.warn("[LightSDK] OfflinePlugin: Failed to open IndexedDB"),t(n.error)},n.onsuccess=()=>{this.db=n.result,e()},n.onupgradeneeded=r=>{let i=r.target.result,o=r.oldVersion;i.objectStoreNames.contains(T)||i.createObjectStore(T,{keyPath:"id"}).createIndex("timestamp","timestamp",{unique:!1})}})}setupNetworkListeners(){typeof window!="undefined"&&(this.isOnline=navigator.onLine,this.onOnline=()=>{console.info("[LightSDK] OfflinePlugin: Network online"),this.isOnline=!0,this.syncPendingEvents()},this.onOffline=()=>{console.info("[LightSDK] OfflinePlugin: Network offline"),this.isOnline=!1},window.addEventListener("online",this.onOnline),window.addEventListener("offline",this.onOffline))}generateId(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}async saveToIndexedDB(e){if(!this.db)return;let t=this.config.maxEvents||pe,n=await this.getEventCount();return n>=t&&await this.deleteOldestEvents(n-t+1),new Promise((r,i)=>{let a=this.db.transaction([T],"readwrite").objectStore(T),c={id:this.generateId(),event:{...e,offline:!0},timestamp:p()},d=a.add(c);d.onsuccess=()=>r(),d.onerror=()=>i(d.error)})}getEventCount(){return this.db?new Promise((e,t)=>{let i=this.db.transaction([T],"readonly").objectStore(T).count();i.onsuccess=()=>e(i.result),i.onerror=()=>t(i.error)}):Promise.resolve(0)}async deleteOldestEvents(e){if(!(!this.db||e<=0))return new Promise((t,n)=>{let a=this.db.transaction([T],"readwrite").objectStore(T).index("timestamp").openCursor(),c=0;a.onsuccess=d=>{let f=d.target.result;f&&cn(a.error)})}async getAllStoredEvents(){return this.db?new Promise((e,t)=>{let o=this.db.transaction([T],"readonly").objectStore(T).index("timestamp").getAll();o.onsuccess=()=>{let a=o.result||[];a.sort((c,d)=>c.timestamp-d.timestamp),e(a)},o.onerror=()=>t(o.error)}):[]}async clearStoredEvents(){if(this.db)return new Promise((e,t)=>{let i=this.db.transaction([T],"readwrite").objectStore(T).clear();i.onsuccess=()=>e(),i.onerror=()=>t(i.error)})}async syncPendingEvents(){if(!(!this.isOnline||this.isSyncing)){this.isSyncing=!0,console.info("[LightSDK] OfflinePlugin: Syncing pending events");try{let e=0;for(;this.pendingEvents.length>0;){let n=this.pendingEvents.shift();try{this.client.captureEvent(n),e++}catch(r){console.error("[LightSDK] OfflinePlugin: Failed to re-enqueue memory event",r)}}let t=await this.getAllStoredEvents();if(t.length>0)for(let n of t)try{let r=n.event;this.client.captureEvent(r),e++}catch(r){console.error("[LightSDK] OfflinePlugin: Failed to re-enqueue event",r)}try{await this.client.flush()}catch(n){}await this.clearStoredEvents(),console.info(`[LightSDK] OfflinePlugin: Synced ${e} events`)}catch(e){console.error("[LightSDK] OfflinePlugin: Sync failed",e)}finally{this.isSyncing=!1}}}beforeReport(e){if(!this.isOnline){let n=this.config.maxEvents||pe;return this.pendingEvents.length>=n&&this.pendingEvents.shift(),this.pendingEvents.push(e),this.savePendingEventsToDB(),null}let t={...e};return delete t.offline,t}savePendingEventsToDB(){if(this.pendingEvents.length===0)return;let e=this.pendingEvents.splice(0,this.pendingEvents.length),t=0,n=()=>{if(t>=e.length)return;let r=e[t];this.saveToIndexedDB(r).then(()=>{t++,n()}).catch(i=>{console.error("[LightSDK] OfflinePlugin: Failed to save event offline",i),this.pendingEvents.unshift(...e.slice(t))})};n()}destroy(){typeof window!="undefined"&&(this.onOnline&&window.removeEventListener("online",this.onOnline),this.onOffline&&window.removeEventListener("offline",this.onOffline)),this.db&&(this.db.close(),this.db=null)}},ge=he;var fe=class{constructor(){this.name="sampling";this.version="1.0.0";this.config={rates:{error:1,performance:1,network:1,behavior:1}}}setup(e){this.client=e,this.loadConfig()}loadConfig(){let e=this.client.config;if(e&&y(e.sampling)){let t=e.sampling;"rates"in t&&y(t.rates)&&(this.config.rates={...this.config.rates,...t.rates})}}shouldSample(e){var r;let t=(r=this.client.config.sampleRate)!=null?r:1;if(t<=0)return!1;let n=this.getTypeRate(e);return t>=1?this.randomCheck(n):this.randomCheck(t*n)}getTypeRate(e){let t=this.config.rates||{},n=e.type;if(n==="count")return 1;let r=t[n];return r!==void 0?r:1}randomCheck(e){return e>=1?!0:e<=0?!1:Math.random(){this.handleRouteChange(location.pathname+location.search,"popstate")};this.handleHashChange=()=>{this.handleRouteChange(location.hash||"#/","hashchange")}}setup(e){this.client=e,this.loadConfig(),typeof window!="undefined"&&this.config.enable&&(this.config.instrumentHistory&&this.instrumentHistory(),this.config.instrumentHash&&this.instrumentHash())}loadConfig(){let e=this.client.config;e&&y(e.router)&&(this.config={...this.config,...e.router})}instrumentHistory(){typeof history=="undefined"||!history.pushState||(this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history),history.pushState=(e,t,n)=>{this.originalPushState(e,t,n),this.handleRouteChange(n||location.pathname+location.search,"pushState")},history.replaceState=(e,t,n)=>{this.originalReplaceState(e,t,n),this.handleRouteChange(n||location.pathname+location.search,"replaceState")},window.addEventListener("popstate",this.handlePopState))}instrumentHash(){window.addEventListener("hashchange",this.handleHashChange)}handleRouteChange(e,t){this.routeChangeTimer&&clearTimeout(this.routeChangeTimer),this.routeChangeTimer=setTimeout(()=>{this.routeChangeTimer=null,this.processRouteChange(e,t)},50)}processRouteChange(e,t){let n=this.config.routeNameFormatter?this.config.routeNameFormatter(e):e.split("?")[0];n!==this.lastRoute&&(this.lastRoute=n,this.finishCurrentTransaction("ok"),this.startNavigationTransaction(n,t))}startNavigationTransaction(e,t){if(!this.client)return;let n=this.client.startTransaction({name:e,op:"navigation",description:`Navigation to ${e}`,type:"navigation",tags:{"route.name":e,"route.source":t}});n&&(this.currentTransaction=n,this.startMaxDurationTimer())}startMaxDurationTimer(){var t;this.maxDurationTimer&&clearTimeout(this.maxDurationTimer);let e=(t=this.config.maxTransactionDurationMs)!=null?t:3e4;this.maxDurationTimer=setTimeout(()=>{this.currentTransaction&&(this.currentTransaction.setStatus("deadline_exceeded"),this.finishCurrentTransaction("deadline_exceeded"))},e)}finishCurrentTransaction(e="ok"){this.maxDurationTimer&&(clearTimeout(this.maxDurationTimer),this.maxDurationTimer=null),this.currentTransaction&&(this.currentTransaction.setStatus(e),this.currentTransaction.finish(),this.currentTransaction=null)}destroy(){this.originalPushState&&typeof history!="undefined"&&(history.pushState=this.originalPushState),this.originalReplaceState&&typeof history!="undefined"&&(history.replaceState=this.originalReplaceState),typeof window!="undefined"&&(window.removeEventListener("popstate",this.handlePopState),window.removeEventListener("hashchange",this.handleHashChange)),this.maxDurationTimer&&(clearTimeout(this.maxDurationTimer),this.maxDurationTimer=null),this.routeChangeTimer&&(clearTimeout(this.routeChangeTimer),this.routeChangeTimer=null),this.finishCurrentTransaction("aborted")}},ye=ve;var Se=class{constructor(){this.name="interaction";this.version="1.0.0";this.config={enable:!0,elementAttribute:"data-sentry-component",maxTransactionDurationMs:3e4,idleTimeoutMs:1e3,trackClick:!0,trackSubmit:!0,trackKeypress:!1};this.currentTransaction=null;this.idleTimer=null;this.maxDurationTimer=null;this.debounceTimer=null;this.handleClick=e=>{if(this.isEventIgnored(e))return;let t=e.target,n=this.getElementName(t,"click");this.scheduleInteractionTransaction(n,"click",t)};this.handleSubmit=e=>{if(this.isEventIgnored(e))return;let t=e.target,n=this.getElementName(t,"submit");this.scheduleInteractionTransaction(n,"submit",t)}}setup(e){this.client=e,this.loadConfig(),typeof window!="undefined"&&this.config.enable&&(this.config.trackClick&&document.addEventListener("click",this.handleClick,!0),this.config.trackSubmit&&document.addEventListener("submit",this.handleSubmit,!0))}loadConfig(){let e=this.client.config;e&&y(e.interaction)&&(this.config={...this.config,...e.interaction})}isEventIgnored(e){let t=e.target;return!!(!t||t.hasAttribute&&t.hasAttribute("data-sentry-ignore"))}scheduleInteractionTransaction(e,t,n){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.startInteractionTransaction(e,t,n)},0)}getElementName(e,t){var c;if(!e)return t;let n=this.config.elementAttribute||"data-sentry-component",r=e.getAttribute(n);if(r)return r;let i=((c=e.tagName)==null?void 0:c.toLowerCase())||"element",o=e.id?`#${e.id}`:"",a=e.className&&typeof e.className=="string"?`.${e.className.split(" ").slice(0,3).join(".")}`:"";return`${t}@${i}${o}${a}`}startInteractionTransaction(e,t,n){var i,o;if(!this.client)return;this.currentTransaction&&this.finishCurrentTransaction("ok");let r=this.client.startTransaction({name:e,op:`ui.${t}`,description:`User ${t} on ${e}`,type:"user-interaction",tags:{"interaction.type":t,"interaction.target":e},data:{tag:(i=n.tagName)==null?void 0:i.toLowerCase(),id:n.id||void 0,text:((o=n.textContent)==null?void 0:o.substring(0,100))||void 0}});r&&(this.currentTransaction=r,this.scheduleIdleFinish(),this.scheduleMaxDuration())}scheduleIdleFinish(){var t;this.idleTimer&&clearTimeout(this.idleTimer);let e=(t=this.config.idleTimeoutMs)!=null?t:1e3;this.idleTimer=setTimeout(()=>{this.finishCurrentTransaction("ok")},e)}scheduleMaxDuration(){var t;this.maxDurationTimer&&clearTimeout(this.maxDurationTimer);let e=(t=this.config.maxTransactionDurationMs)!=null?t:3e4;this.maxDurationTimer=setTimeout(()=>{this.finishCurrentTransaction("deadline_exceeded")},e)}finishCurrentTransaction(e="ok"){this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null),this.maxDurationTimer&&(clearTimeout(this.maxDurationTimer),this.maxDurationTimer=null),this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.currentTransaction&&(this.currentTransaction.setStatus(e),this.currentTransaction.finish(),this.currentTransaction=null)}destroy(){typeof document!="undefined"&&(document.removeEventListener("click",this.handleClick,!0),document.removeEventListener("submit",this.handleSubmit,!0)),this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null),this.maxDurationTimer&&(clearTimeout(this.maxDurationTimer),this.maxDurationTimer=null),this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.finishCurrentTransaction("aborted")}},be=Se;var l=null;function _e(s){var r;O(s.debug===!0),u("Index","init called",{dsn:s.dsn,debug:s.debug});let e=new re(s),t=[new ge,new me,new se],n=((r=s.plugins)==null?void 0:r.filter(i=>typeof i=="string"))||[];(n.includes("performance")||n.includes("all"))&&t.push(new ae),(n.includes("network")||n.includes("all"))&&t.push(new ue),(n.includes("behavior")||n.includes("all"))&&t.push(new de),(n.includes("router")||n.includes("all"))&&t.push(new ye),(n.includes("interaction")||n.includes("all"))&&t.push(new be),u("Index","Registering plugins",{count:t.length,plugins:t.map(i=>i.name)});for(let i of t)e.use(i);if(s.plugins)for(let i of s.plugins)typeof i=="object"&&i!==null&&"name"in i&&"setup"in i&&e.use(i);return e.init(),l=e,u("Index","init completed, globalClient set"),e}function Me(){return l}function De(s){if(u("Index","captureException called",{hasClient:!!l}),!l){console.warn("[LightSDK] SDK not initialized. Call LightSentry.init() first.");return}l.captureException(s)}function Be(s,e){if(u("Index","captureMessage called",{hasClient:!!l}),!l){console.warn("[LightSDK] SDK not initialized. Call LightSentry.init() first.");return}l.captureMessage(s,e)}function Oe(s){if(u("Index","captureEvent called",{hasClient:!!l}),!l){console.warn("[LightSDK] SDK not initialized. Call LightSentry.init() first.");return}l.captureEvent(s)}function Fe(s){l==null||l.setUser(s)}function Ne(s){H(s)}function He(){we()}function qe(){return N()}function Ue(s){return(l==null?void 0:l.startTransaction(s))||null}function $e(){return(l==null?void 0:l.getCurrentTransaction())||null}function Ae(){return(l==null?void 0:l.getCurrentSpan())||null}function je(s){l==null||l.setSpan(s)}function Ke(s){return(l==null?void 0:l.startSpan(s))||null}function ze(s,e){l==null||l.setTag(s,e)}function Xe(s){l==null||l.setTags(s)}function We(s,e){l==null||l.setExtra(s,e)}function Ve(s){l==null||l.addBreadcrumb(s)}async function Qe(){await(l==null?void 0:l.flush())}function Ge(){l==null||l.disable()}function Je(){l==null||l.enable()}var gt={init:_e,getClient:Me,captureException:De,captureMessage:Be,captureEvent:Oe,setUser:Fe,setAnonymousId:Ne,clearAnonymousId:He,getAnonymousId:qe,startTransaction:Ue,getCurrentTransaction:$e,getCurrentSpan:Ae,setSpan:je,startSpan:Ke,setTag:ze,setTags:Xe,setExtra:We,addBreadcrumb:Ve,flush:Qe,disable:Ge,enable:Je,Span:C,Transaction:L,httpStatusToSpanStatus:_};return rt(ft);})();