UNPKG

@cloudflare/workers-shared

Version:

Package that is used at Cloudflare to power some internal features of Cloudflare Workers.

8 lines • 67.7 kB
import{WorkerEntrypoint as Us}from"cloudflare:workers";var ee=class{constructor(e){this.performanceTimer=e}now(){return this.performanceTimer?this.performanceTimer.timeOrigin+this.performanceTimer.now():Date.now()}};var _e=class extends Response{constructor(e,n){super(e,{...n,status:200})}},te=class extends Response{constructor(...[e,n]){super(e,{...n,status:404,statusText:"Not Found"})}},Ee=class extends Response{constructor(...[e,n]){super(e,{...n,status:405,statusText:"Method Not Allowed"})}},$=class extends Response{constructor(e,n){super(null,{...n,status:500})}},Se=class extends Response{constructor(...[e,n]){super(null,{...n,status:304,statusText:"Not Modified"})}},ye=class extends Response{constructor(e,n){super(null,{...n,status:307,statusText:"Temporary Redirect",headers:{...n?.headers,Location:e}})}};var Gt=Object.prototype.toString;function B(t){switch(Gt.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return v(t,Error)}}function Ze(t,e){return Gt.call(t)===`[object ${e}]`}function Xe(t){return Ze(t,"ErrorEvent")}function Qe(t){return Ze(t,"String")}function J(t){return typeof t=="object"&&t!==null&&"__sentry_template_string__"in t&&"__sentry_template_values__"in t}function Te(t){return t===null||J(t)||typeof t!="object"&&typeof t!="function"}function R(t){return Ze(t,"Object")}function et(t){return typeof Event<"u"&&v(t,Event)}function tt(t){return typeof Element<"u"&&v(t,Element)}function O(t){return!!(t&&t.then&&typeof t.then=="function")}function nt(t){return R(t)&&"nativeEvent"in t&&"preventDefault"in t&&"stopPropagation"in t}function v(t,e){try{return t instanceof e}catch{return!1}}function rt(t){return!!(typeof t=="object"&&t!==null&&(t.__isVue||t._isVue))}function D(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}var M="8.9.2";var m=globalThis;function V(t,e,n){let r=n||m,s=r.__SENTRY__=r.__SENTRY__||{},o=s[M]=s[M]||{};return o[t]||(o[t]=e())}var Zn=m,Xn=80;function qt(t,e={}){if(!t)return"<unknown>";try{let n=t,r=5,s=[],o=0,i=0,a=" > ",c=a.length,u,p=Array.isArray(e)?e:e.keyAttrs,l=!Array.isArray(e)&&e.maxStringLength||Xn;for(;n&&o++<r&&(u=Qn(n,p),!(u==="html"||o>1&&i+s.length*c+u.length>=l));)s.push(u),i+=u.length,n=n.parentNode;return s.reverse().join(a)}catch{return"<unknown>"}}function Qn(t,e){let n=t,r=[],s,o,i,a,c;if(!n||!n.tagName)return"";if(Zn.HTMLElement&&n instanceof HTMLElement&&n.dataset){if(n.dataset.sentryComponent)return n.dataset.sentryComponent;if(n.dataset.sentryElement)return n.dataset.sentryElement}r.push(n.tagName.toLowerCase());let u=e&&e.length?e.filter(l=>n.getAttribute(l)).map(l=>[l,n.getAttribute(l)]):null;if(u&&u.length)u.forEach(l=>{r.push(`[${l[0]}="${l[1]}"]`)});else if(n.id&&r.push(`#${n.id}`),s=n.className,s&&Qe(s))for(o=s.split(/\s+/),c=0;c<o.length;c++)r.push(`.${o[c]}`);let p=["aria-label","type","name","title","alt"];for(c=0;c<p.length;c++)i=p[c],a=n.getAttribute(i),a&&r.push(`[${i}="${a}"]`);return r.join("")}var P=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var er="Sentry Logger ",st=["debug","info","warn","error","log","assert","trace"],ot={};function Ie(t){if(!("console"in m))return t();let e=m.console,n={},r=Object.keys(ot);r.forEach(s=>{let o=ot[s];n[s]=e[s],e[s]=o});try{return t()}finally{r.forEach(s=>{e[s]=n[s]})}}function tr(){let t=!1,e={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return P?st.forEach(n=>{e[n]=(...r)=>{t&&Ie(()=>{m.console[n](`${er}[${n}]:`,...r)})}}):st.forEach(n=>{e[n]=()=>{}}),e}var d=tr();var nr=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)([\w.-]+)(?::(\d+))?\/(.+)/;function rr(t){return t==="http"||t==="https"}function k(t,e=!1){let{host:n,path:r,pass:s,port:o,projectId:i,protocol:a,publicKey:c}=t;return`${a}://${c}${e&&s?`:${s}`:""}@${n}${o?`:${o}`:""}/${r&&`${r}/`}${i}`}function zt(t){let e=nr.exec(t);if(!e){Ie(()=>{console.error(`Invalid Sentry Dsn: ${t}`)});return}let[n,r,s="",o,i="",a]=e.slice(1),c="",u=a,p=u.split("/");if(p.length>1&&(c=p.slice(0,-1).join("/"),u=p.pop()),u){let l=u.match(/^\d+/);l&&(u=l[0])}return Yt({host:o,pass:s,path:c,projectId:u,port:i,protocol:n,publicKey:r})}function Yt(t){return{protocol:t.protocol,publicKey:t.publicKey||"",pass:t.pass||"",host:t.host,port:t.port||"",path:t.path||"",projectId:t.projectId}}function sr(t){if(!P)return!0;let{port:e,projectId:n,protocol:r}=t;return["protocol","publicKey","host","projectId"].find(i=>t[i]?!1:(d.error(`Invalid Sentry Dsn: ${i} missing`),!0))?!1:n.match(/^\d+$/)?rr(r)?e&&isNaN(parseInt(e,10))?(d.error(`Invalid Sentry Dsn: Invalid port ${e}`),!1):!0:(d.error(`Invalid Sentry Dsn: Invalid protocol ${r}`),!1):(d.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),!1)}function xe(t){let e=typeof t=="string"?zt(t):Yt(t);if(!(!e||!sr(e)))return e}var x=class extends Error{constructor(e,n="warn"){super(e),this.message=e,this.name=new.target.prototype.constructor.name,Object.setPrototypeOf(this,new.target.prototype),this.logLevel=n}};function H(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch{P&&d.log(`Failed to add non-enumerable property "${e}" to object`,t)}}function at(t){return Object.keys(t).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`).join("&")}function Ae(t){if(B(t))return{message:t.message,name:t.name,stack:t.stack,...Vt(t)};if(et(t)){let e={type:t.type,target:Jt(t.target),currentTarget:Jt(t.currentTarget),...Vt(t)};return typeof CustomEvent<"u"&&v(t,CustomEvent)&&(e.detail=t.detail),e}else return t}function Jt(t){try{return tt(t)?qt(t):Object.prototype.toString.call(t)}catch{return"<unknown>"}}function Vt(t){if(typeof t=="object"&&t!==null){let e={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}else return{}}function ne(t,e=40){let n=Object.keys(Ae(t));if(n.sort(),!n.length)return"[object has no keys]";if(n[0].length>=e)return D(n[0],e);for(let r=n.length;r>0;r--){let s=n.slice(0,r).join(", ");if(!(s.length>e))return r===n.length?s:D(s,e)}return""}function S(t){return it(t,new Map)}function it(t,e){if(or(t)){let n=e.get(t);if(n!==void 0)return n;let r={};e.set(t,r);for(let s of Object.keys(t))typeof t[s]<"u"&&(r[s]=it(t[s],e));return r}if(Array.isArray(t)){let n=e.get(t);if(n!==void 0)return n;let r=[];return e.set(t,r),t.forEach(s=>{r.push(it(s,e))}),r}return t}function or(t){if(!R(t))return!1;try{let e=Object.getPrototypeOf(t).constructor.name;return!e||e==="Object"}catch{return!0}}var be="?",Wt=/\(error: (.*)\)/,Kt=/captureMessage|captureException/;function Ce(...t){let e=t.sort((n,r)=>n[0]-r[0]).map(n=>n[1]);return(n,r=0,s=0)=>{let o=[],i=n.split(` `);for(let a=r;a<i.length;a++){let c=i[a];if(c.length>1024)continue;let u=Wt.test(c)?c.replace(Wt,"$1"):c;if(!u.match(/\S*Error: /)){for(let p of e){let l=p(u);if(l){o.push(l);break}}if(o.length>=50+s)break}}return Zt(o.slice(s))}}function ut(t){return Array.isArray(t)?Ce(...t):t}function Zt(t){if(!t.length)return[];let e=Array.from(t);return/sentryWrapped/.test(e[e.length-1].function||"")&&e.pop(),e.reverse(),Kt.test(e[e.length-1].function||"")&&(e.pop(),Kt.test(e[e.length-1].function||"")&&e.pop()),e.slice(0,50).map(n=>({...n,filename:n.filename||e[e.length-1].filename,function:n.function||be}))}var ct="<anonymous>";function re(t){try{return!t||typeof t!="function"?ct:t.name||ct}catch{return ct}}var Re={},Xt={};function Ne(t,e){Re[t]=Re[t]||[],Re[t].push(e)}function Oe(t,e){Xt[t]||(e(),Xt[t]=!0)}function ve(t,e){let n=t&&Re[t];if(n)for(let r of n)try{r(e)}catch(s){P&&d.error(`Error while triggering instrumentation handler. Type: ${t} Name: ${re(r)} Error:`,s)}}var Qt=1e3;function W(){return Date.now()/Qt}function ir(){let{performance:t}=m;if(!t||!t.now)return W;let e=Date.now()-t.now(),n=t.timeOrigin==null?e:t.timeOrigin;return()=>(n+t.now())/Qt}var oe=ir(),se,ar=(()=>{let{performance:t}=m;if(!t||!t.now){se="none";return}let e=3600*1e3,n=t.now(),r=Date.now(),s=t.timeOrigin?Math.abs(t.timeOrigin+n-r):e,o=s<e,i=t.timing&&t.timing.navigationStart,c=typeof i=="number"?Math.abs(i+n-r):e,u=c<e;return o||u?s<=c?(se="timeOrigin",t.timeOrigin):(se="navigationStart",i):(se="dateNow",r)})();var we=null;function lt(t){let e="error";Ne(e,t),Oe(e,cr)}function cr(){we=m.onerror,m.onerror=function(t,e,n,r,s){return ve("error",{column:r,error:s,line:n,msg:t,url:e}),we&&!we.__SENTRY_LOADER__?we.apply(this,arguments):!1},m.onerror.__SENTRY_INSTRUMENTED__=!0}var De=null;function pt(t){let e="unhandledrejection";Ne(e,t),Oe(e,ur)}function ur(){De=m.onunhandledrejection,m.onunhandledrejection=function(t){return ve("unhandledrejection",t),De&&!De.__SENTRY_LOADER__?De.apply(this,arguments):!0},m.onunhandledrejection.__SENTRY_INSTRUMENTED__=!0}function en(){let t=typeof WeakSet=="function",e=t?new WeakSet:[];function n(s){if(t)return e.has(s)?!0:(e.add(s),!1);for(let o=0;o<e.length;o++)if(e[o]===s)return!0;return e.push(s),!1}function r(s){if(t)e.delete(s);else for(let o=0;o<e.length;o++)if(e[o]===s){e.splice(o,1);break}}return[n,r]}function T(){let t=m,e=t.crypto||t.msCrypto,n=()=>Math.random()*16;try{if(e&&e.randomUUID)return e.randomUUID().replace(/-/g,"");e&&e.getRandomValues&&(n=()=>{let r=new Uint8Array(1);return e.getRandomValues(r),r[0]})}catch{}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,r=>(r^(n()&15)>>r/4).toString(16))}function lr(t){return t.exception&&t.exception.values?t.exception.values[0]:void 0}function ie(t,e,n){let r=t.exception=t.exception||{},s=r.values=r.values||[],o=s[0]=s[0]||{};o.value||(o.value=e||""),o.type||(o.type=n||"Error")}function j(t,e){let n=lr(t);if(!n)return;let r={type:"generic",handled:!0},s=n.mechanism;if(n.mechanism={...r,...s,...e},e&&"data"in e){let o={...s&&s.data,...e.data};n.mechanism.data=o}}function Me(t){if(t&&t.__sentry_captured__)return!0;try{H(t,"__sentry_captured__",!0)}catch{}return!1}function ae(t){return Array.isArray(t)?t:[t]}function N(t,e=100,n=1/0){try{return dt("",t,e,n)}catch(r){return{ERROR:`**non-serializable** (${r})`}}}function K(t,e=3,n=100*1024){let r=N(t,e);return mr(r)>n?K(t,e-1,n):r}function dt(t,e,n=1/0,r=1/0,s=en()){let[o,i]=s;if(e==null||["number","boolean","string"].includes(typeof e)&&!Number.isNaN(e))return e;let a=pr(t,e);if(!a.startsWith("[object "))return a;if(e.__sentry_skip_normalization__)return e;let c=typeof e.__sentry_override_normalization_depth__=="number"?e.__sentry_override_normalization_depth__:n;if(c===0)return a.replace("object ","");if(o(e))return"[Circular ~]";let u=e;if(u&&typeof u.toJSON=="function")try{let f=u.toJSON();return dt("",f,c-1,r,s)}catch{}let p=Array.isArray(e)?[]:{},l=0,g=Ae(e);for(let f in g){if(!Object.prototype.hasOwnProperty.call(g,f))continue;if(l>=r){p[f]="[MaxProperties ~]";break}let h=g[f];p[f]=dt(f,h,c-1,r,s),l++}return i(e),p}function pr(t,e){try{if(t==="domain"&&e&&typeof e=="object"&&e._events)return"[Domain]";if(t==="domainEmitter")return"[DomainEmitter]";if(typeof global<"u"&&e===global)return"[Global]";if(typeof window<"u"&&e===window)return"[Window]";if(typeof document<"u"&&e===document)return"[Document]";if(rt(e))return"[VueViewModel]";if(nt(e))return"[SyntheticEvent]";if(typeof e=="number"&&e!==e)return"[NaN]";if(typeof e=="function")return`[Function: ${re(e)}]`;if(typeof e=="symbol")return`[${String(e)}]`;if(typeof e=="bigint")return`[BigInt: ${String(e)}]`;let n=dr(e);return/^HTML(\w*)Element$/.test(n)?`[HTMLElement: ${n}]`:`[object ${n}]`}catch(n){return`**non-serializable** (${n})`}}function dr(t){let e=Object.getPrototypeOf(t);return e?e.constructor.name:"null prototype"}function fr(t){return~-encodeURI(t).split(/%..|./).length}function mr(t){return fr(JSON.stringify(t))}function gr(t,e){let n=0;for(let r=t.length-1;r>=0;r--){let s=t[r];s==="."?t.splice(r,1):s===".."?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}var hr=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function _r(t){let e=t.length>1024?`<truncated>${t.slice(-1024)}`:t,n=hr.exec(e);return n?n.slice(1):[]}function ft(...t){let e="",n=!1;for(let r=t.length-1;r>=-1&&!n;r--){let s=r>=0?t[r]:"/";s&&(e=`${s}/${e}`,n=s.charAt(0)==="/")}return e=gr(e.split("/").filter(r=>!!r),!n).join("/"),(n?"/":"")+e||"."}function tn(t){let e=0;for(;e<t.length&&t[e]==="";e++);let n=t.length-1;for(;n>=0&&t[n]==="";n--);return e>n?[]:t.slice(e,n-e+1)}function mt(t,e){t=ft(t).slice(1),e=ft(e).slice(1);let n=tn(t.split("/")),r=tn(e.split("/")),s=Math.min(n.length,r.length),o=s;for(let a=0;a<s;a++)if(n[a]!==r[a]){o=a;break}let i=[];for(let a=o;a<n.length;a++)i.push("..");return i=i.concat(r.slice(o)),i.join("/")}function ce(t,e){let n=_r(t)[2];return e&&n.slice(e.length*-1)===e&&(n=n.slice(0,n.length-e.length)),n}var w;(function(t){t[t.PENDING=0]="PENDING";let n=1;t[t.RESOLVED=n]="RESOLVED";let r=2;t[t.REJECTED=r]="REJECTED"})(w||(w={}));function b(t){return new I(e=>{e(t)})}function G(t){return new I((e,n)=>{n(t)})}var I=class{constructor(e){I.prototype.__init.call(this),I.prototype.__init2.call(this),I.prototype.__init3.call(this),I.prototype.__init4.call(this),this._state=w.PENDING,this._handlers=[];try{e(this._resolve,this._reject)}catch(n){this._reject(n)}}then(e,n){return new I((r,s)=>{this._handlers.push([!1,o=>{if(!e)r(o);else try{r(e(o))}catch(i){s(i)}},o=>{if(!n)s(o);else try{r(n(o))}catch(i){s(i)}}]),this._executeHandlers()})}catch(e){return this.then(n=>n,e)}finally(e){return new I((n,r)=>{let s,o;return this.then(i=>{o=!1,s=i,e&&e()},i=>{o=!0,s=i,e&&e()}).then(()=>{if(o){r(s);return}n(s)})})}__init(){this._resolve=e=>{this._setResult(w.RESOLVED,e)}}__init2(){this._reject=e=>{this._setResult(w.REJECTED,e)}}__init3(){this._setResult=(e,n)=>{if(this._state===w.PENDING){if(O(n)){n.then(this._resolve,this._reject);return}this._state=e,this._value=n,this._executeHandlers()}}}__init4(){this._executeHandlers=()=>{if(this._state===w.PENDING)return;let e=this._handlers.slice();this._handlers=[],e.forEach(n=>{n[0]||(this._state===w.RESOLVED&&n[1](this._value),this._state===w.REJECTED&&n[2](this._value),n[0]=!0)})}}};function gt(t){let e=[];function n(){return t===void 0||e.length<t}function r(i){return e.splice(e.indexOf(i),1)[0]}function s(i){if(!n())return G(new x("Not adding Promise because buffer limit was reached."));let a=i();return e.indexOf(a)===-1&&e.push(a),a.then(()=>r(a)).then(null,()=>r(a).then(null,()=>{})),a}function o(i){return new I((a,c)=>{let u=e.length;if(!u)return a(!0);let p=setTimeout(()=>{i&&i>0&&a(!1)},i);e.forEach(l=>{b(l).then(()=>{--u||(clearTimeout(p),a(!0))},c)})})}return{$:e,add:s,drain:o}}function nn(t,e=!1){return!(e||t&&!t.startsWith("/")&&!t.match(/^[A-Z]:/)&&!t.startsWith(".")&&!t.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&t!==void 0&&!t.includes("node_modules/")}function rn(t){let e=/^\s*[-]{4,}$/,n=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return r=>{let s=r.match(n);if(s){let o,i,a,c,u;if(s[1]){a=s[1];let g=a.lastIndexOf(".");if(a[g-1]==="."&&g--,g>0){o=a.slice(0,g),i=a.slice(g+1);let f=o.indexOf(".Module");f>0&&(a=a.slice(f+1),o=o.slice(0,f))}c=void 0}i&&(c=o,u=i),i==="<anonymous>"&&(u=void 0,a=void 0),a===void 0&&(u=u||be,a=c?`${c}.${u}`:u);let p=s[2]&&s[2].startsWith("file://")?s[2].slice(7):s[2],l=s[5]==="native";return p&&p.match(/\/[A-Z]:/)&&(p=p.slice(1)),!p&&s[5]&&!l&&(p=s[5]),{filename:p,module:t?t(p):void 0,function:a,lineno:parseInt(s[3],10)||void 0,colno:parseInt(s[4],10)||void 0,in_app:nn(p,l)}}if(r.match(e))return{filename:r}}}function ht(t){return[90,rn(t)]}function L(t,e=[]){return[t,e]}function Et(t,e){let[n,r]=t;return[n,[...r,e]]}function Pe(t,e){let n=t[1];for(let r of n){let s=r[0].type;if(e(r,s))return!0}return!1}function _t(t){return m.__SENTRY__&&m.__SENTRY__.encodePolyfill?m.__SENTRY__.encodePolyfill(t):new TextEncoder().encode(t)}function St(t){let[e,n]=t,r=JSON.stringify(e);function s(o){typeof r=="string"?r=typeof o=="string"?r+o:[_t(r),o]:r.push(typeof o=="string"?_t(o):o)}for(let o of n){let[i,a]=o;if(s(` ${JSON.stringify(i)} `),typeof a=="string"||a instanceof Uint8Array)s(a);else{let c;try{c=JSON.stringify(a)}catch{c=JSON.stringify(N(a))}s(c)}}return typeof r=="string"?r:Er(r)}function Er(t){let e=t.reduce((s,o)=>s+o.length,0),n=new Uint8Array(e),r=0;for(let s of t)n.set(s,r),r+=s.length;return n}function yt(t){let e=typeof t.data=="string"?_t(t.data):t.data;return[S({type:"attachment",length:e.length,filename:t.filename,content_type:t.contentType,attachment_type:t.attachmentType}),e]}var Sr={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",feedback:"feedback",span:"span",statsd:"metric_bucket"};function ke(t){return Sr[t]}function Le(t){if(!t||!t.sdk)return;let{name:e,version:n}=t.sdk;return{name:e,version:n}}function Tt(t,e,n,r){let s=t.sdkProcessingMetadata&&t.sdkProcessingMetadata.dynamicSamplingContext;return{event_id:t.event_id,sent_at:new Date().toISOString(),...e&&{sdk:e},...!!n&&r&&{dsn:k(r)},...s&&{trace:S({...s})}}}function sn(t,e=Date.now()){let n=parseInt(`${t}`,10);if(!isNaN(n))return n*1e3;let r=Date.parse(`${t}`);return isNaN(r)?6e4:r-e}function on(t,e){return t[e]||t.all||0}function It(t,e,n=Date.now()){return on(t,e)>n}function xt(t,{statusCode:e,headers:n},r=Date.now()){let s={...t},o=n&&n["x-sentry-rate-limits"],i=n&&n["retry-after"];if(o)for(let a of o.trim().split(",")){let[c,u,,,p]=a.split(":",5),l=parseInt(c,10),g=(isNaN(l)?60:l)*1e3;if(!u)s.all=r+g;else for(let f of u.split(";"))f==="metric_bucket"?(!p||p.split(";").includes("custom"))&&(s[f]=r+g):s[f]=r+g}else i?s.all=r+sn(i,r):e===429&&(s.all=r+60*1e3);return s}function At(t,e){return t(e.stack||"",1)}function an(t,e){let n={type:e.name||e.constructor.name,value:e.message},r=At(t,e);return r.length&&(n.stacktrace={frames:r}),n}function yr(t){for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let n=t[e];if(n instanceof Error)return n}}function Tr(t){if("name"in t&&typeof t.name=="string"){let r=`'${t.name}' captured as exception`;return"message"in t&&typeof t.message=="string"&&(r+=` with message '${t.message}'`),r}else if("message"in t&&typeof t.message=="string")return t.message;let e=ne(t);if(Xe(t))return`Event \`ErrorEvent\` captured as exception with message \`${t.message}\``;let n=Ir(t);return`${n&&n!=="Object"?`'${n}'`:"Object"} captured as exception with keys: ${e}`}function Ir(t){try{let e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch{}}function xr(t,e,n,r){if(B(n))return[n,void 0];if(e.synthetic=!0,R(n)){let o=t&&t.getOptions().normalizeDepth,i={__serialized__:K(n,o)},a=yr(n);if(a)return[a,i];let c=Tr(n),u=r&&r.syntheticException||new Error(c);return u.message=c,[u,i]}let s=r&&r.syntheticException||new Error(n);return s.message=`${n}`,[s,void 0]}function bt(t,e,n,r){let o=r&&r.data&&r.data.mechanism||{handled:!0,type:"generic"},[i,a]=xr(t,o,n,r),c={exception:{values:[an(e,i)]}};return a&&(c.extra=a),ie(c,void 0,void 0),j(c,o),{...c,event_id:r&&r.event_id}}function Ct(t,e,n="info",r,s){let o={event_id:r&&r.event_id,level:n};if(s&&r&&r.syntheticException){let i=At(t,r.syntheticException);i.length&&(o.exception={values:[{value:e,stacktrace:{frames:i}}]})}if(J(e)){let{__sentry_template_string__:i,__sentry_template_values__:a}=e;return o.logentry={message:i,params:a},o}return o.message=e,o}function Fe(){return{traceId:T(),spanId:T().substring(16)}}var _=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;function F(){return ue(m),m}function ue(t){let e=t.__SENTRY__=t.__SENTRY__||{};return e.version=e.version||M,e[M]=e[M]||{}}function le(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),!t.did&&!e.did&&(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||oe(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=e.sid.length===32?e.sid:T()),e.init!==void 0&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),typeof e.started=="number"&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if(typeof e.duration=="number")t.duration=e.duration;else{let n=t.timestamp-t.started;t.duration=n>=0?n:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),typeof e.errors=="number"&&(t.errors=e.errors),e.status&&(t.status=e.status)}var Rt="_sentrySpan";function Nt(t,e){e?H(t,Rt,e):delete t[Rt]}function q(t){return t[Rt]}var br=100,pe=class{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext=Fe()}clone(){let e=new pe;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._extra={...this._extra},e._contexts={...this._contexts},e._user=this._user,e._level=this._level,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._requestSession=this._requestSession,e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e._lastEventId=this._lastEventId,Nt(e,q(this)),e}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&le(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(e){return this._requestSession=e,this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,n){return this._tags={...this._tags,[e]:n},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,n){return this._extra={...this._extra,[e]:n},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,n){return n===null?delete this._contexts[e]:this._contexts[e]=n,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;let n=typeof e=="function"?e(this):e,[r,s]=n instanceof C?[n.getScopeData(),n.getRequestSession()]:R(n)?[e,e.requestSession]:[],{tags:o,extra:i,user:a,contexts:c,level:u,fingerprint:p=[],propagationContext:l}=r||{};return this._tags={...this._tags,...o},this._extra={...this._extra,...i},this._contexts={...this._contexts,...c},a&&Object.keys(a).length&&(this._user=a),u&&(this._level=u),p.length&&(this._fingerprint=p),l&&(this._propagationContext=l),s&&(this._requestSession=s),this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._session=void 0,Nt(this,void 0),this._attachments=[],this._propagationContext=Fe(),this._notifyScopeListeners(),this}addBreadcrumb(e,n){let r=typeof n=="number"?n:br;if(r<=0)return this;let s={timestamp:W(),...e},o=this._breadcrumbs;return o.push(s),this._breadcrumbs=o.length>r?o.slice(-r):o,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:q(this)}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata={...this._sdkProcessingMetadata,...e},this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,n){let r=n&&n.event_id?n.event_id:T();if(!this._client)return d.warn("No client configured on scope - will not capture exception!"),r;let s=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:s,...n,event_id:r},this),r}captureMessage(e,n,r){let s=r&&r.event_id?r.event_id:T();if(!this._client)return d.warn("No client configured on scope - will not capture message!"),s;let o=new Error(e);return this._client.captureMessage(e,n,{originalException:e,syntheticException:o,...r,event_id:s},this),s}captureEvent(e,n){let r=n&&n.event_id?n.event_id:T();return this._client?(this._client.captureEvent(e,{...n,event_id:r},this),r):(d.warn("No client configured on scope - will not capture event!"),r)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}},C=pe;function cn(){return V("defaultCurrentScope",()=>new C)}function un(){return V("defaultIsolationScope",()=>new C)}var Ot=class{constructor(e,n){let r;e?r=e:r=new C;let s;n?s=n:s=new C,this._stack=[{scope:r}],this._isolationScope=s}withScope(e){let n=this._pushScope(),r;try{r=e(n)}catch(s){throw this._popScope(),s}return O(r)?r.then(s=>(this._popScope(),s),s=>{throw this._popScope(),s}):(this._popScope(),r)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStack(){return this._stack}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){let e=this.getScope().clone();return this.getStack().push({client:this.getClient(),scope:e}),e}_popScope(){return this.getStack().length<=1?!1:!!this.getStack().pop()}};function Z(){let t=F(),e=ue(t);return e.stack=e.stack||new Ot(cn(),un())}function Cr(t){return Z().withScope(t)}function Rr(t,e){let n=Z();return n.withScope(()=>(n.getStackTop().scope=t,e(t)))}function ln(t){return Z().withScope(()=>t(Z().getIsolationScope()))}function pn(){return{withIsolationScope:ln,withScope:Cr,withSetScope:Rr,withSetIsolationScope:(t,e)=>ln(e),getCurrentScope:()=>Z().getScope(),getIsolationScope:()=>Z().getIsolationScope()}}function de(t){let e=ue(t);return e.acs?e.acs:pn()}function vt(){let t=F();return de(t).getCurrentScope()}function z(){let t=F();return de(t).getIsolationScope()}function dn(){return V("globalScope",()=>new C)}function fn(){return vt().getClient()}var Nr="_sentryMetrics";function mn(t){let e=t[Nr];if(!e)return;let n={};for(let[,[r,s]]of e)n[r]||(n[r]=[]),n[r].push(S(s));return n}var gn="sentry.source",hn="sentry.sample_rate",_n="sentry.op",En="sentry.origin";var Or=1;function Ue(t){let{spanId:e,traceId:n}=t.spanContext(),{parent_span_id:r}=X(t);return S({parent_span_id:r,span_id:e,trace_id:n})}function Sn(t){return typeof t=="number"?yn(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?yn(t.getTime()):oe()}function yn(t){return t>9999999999?t/1e3:t}function X(t){if(wr(t))return t.getSpanJSON();try{let{spanId:e,traceId:n}=t.spanContext();if(vr(t)){let{attributes:r,startTime:s,name:o,endTime:i,parentSpanId:a,status:c}=t;return S({span_id:e,trace_id:n,data:r,description:o,parent_span_id:a,start_timestamp:Sn(s),timestamp:Sn(i)||void 0,status:Dr(c),op:r[_n],origin:r[En],_metrics_summary:mn(t)})}return{span_id:e,trace_id:n}}catch{return{}}}function vr(t){let e=t;return!!e.attributes&&!!e.startTime&&!!e.name&&!!e.endTime&&!!e.status}function wr(t){return typeof t.getSpanJSON=="function"}function Tn(t){let{traceFlags:e}=t.spanContext();return e===Or}function Dr(t){if(!(!t||t.code===0))return t.code===1?"ok":t.message||"unknown_error"}var Mr="_sentryRootSpan";function U(t){return t[Mr]||t}function In(){let t=F(),e=de(t);return e.getActiveSpan?e.getActiveSpan():q(vt())}var xn=!1;function An(){xn||(xn=!0,lt(wt),pt(wt))}function wt(){let t=In(),e=t&&U(t);if(e){let n="internal_error";_&&d.log(`[Tracing] Root span: ${n} -> Global error occured`),e.setStatus({code:2,message:n})}}wt.tag="sentry_tracingErrorCallback";var $e="production";var Pr="_frozenDsc";function fe(t,e){let n=e.getOptions(),{publicKey:r}=e.getDsn()||{},s=S({environment:n.environment||$e,release:n.release,public_key:r,trace_id:t});return e.emit("createDsc",s),s}function Be(t){let e=fn();if(!e)return{};let n=fe(X(t).trace_id||"",e),r=U(t);if(!r)return n;let s=r[Pr];if(s)return s;let o=X(r),i=o.data||{},a=i[hn];a!=null&&(n.sample_rate=`${a}`);let c=i[gn];return c&&c!=="url"&&(n.transaction=o.description),n.sampled=String(Tn(r)),e.emit("createDsc",n),n}function bn(t){if(typeof t=="boolean")return Number(t);let e=typeof t=="string"?parseFloat(t):t;if(typeof e!="number"||isNaN(e)||e<0||e>1){_&&d.warn(`[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(t)} of type ${JSON.stringify(typeof t)}.`);return}return e}function kr(t,e){return e&&(t.sdk=t.sdk||{},t.sdk.name=t.sdk.name||e.name,t.sdk.version=t.sdk.version||e.version,t.sdk.integrations=[...t.sdk.integrations||[],...e.integrations||[]],t.sdk.packages=[...t.sdk.packages||[],...e.packages||[]]),t}function Cn(t,e,n,r){let s=Le(n),o={sent_at:new Date().toISOString(),...s&&{sdk:s},...!!r&&e&&{dsn:k(e)}},i="aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()];return L(o,[i])}function Rn(t,e,n,r){let s=Le(n),o=t.type&&t.type!=="replay_event"?t.type:"event";kr(t,n&&n.sdk);let i=Tt(t,s,r,e);return delete t.sdkProcessingMetadata,L(i,[[{type:o},t]])}function He(t,e,n,r=0){return new I((s,o)=>{let i=t[r];if(e===null||typeof i!="function")s(e);else{let a=i({...e},n);_&&i.id&&a===null&&d.log(`Event processor "${i.id}" dropped event`),O(a)?a.then(c=>He(t,c,n,r+1).then(s)).then(null,o):He(t,a,n,r+1).then(s).then(null,o)}})}function Nn(t,e){let{fingerprint:n,span:r,breadcrumbs:s,sdkProcessingMetadata:o}=e;Lr(t,e),r&&$r(t,r),Br(t,n),Fr(t,s),Ur(t,o)}function Dt(t,e){let{extra:n,tags:r,user:s,contexts:o,level:i,sdkProcessingMetadata:a,breadcrumbs:c,fingerprint:u,eventProcessors:p,attachments:l,propagationContext:g,transactionName:f,span:h}=e;me(t,"extra",n),me(t,"tags",r),me(t,"user",s),me(t,"contexts",o),me(t,"sdkProcessingMetadata",a),i&&(t.level=i),f&&(t.transactionName=f),h&&(t.span=h),c.length&&(t.breadcrumbs=[...t.breadcrumbs,...c]),u.length&&(t.fingerprint=[...t.fingerprint,...u]),p.length&&(t.eventProcessors=[...t.eventProcessors,...p]),l.length&&(t.attachments=[...t.attachments,...l]),t.propagationContext={...t.propagationContext,...g}}function me(t,e,n){if(n&&Object.keys(n).length){t[e]={...t[e]};for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[e][r]=n[r])}}function Lr(t,e){let{extra:n,tags:r,user:s,contexts:o,level:i,transactionName:a}=e,c=S(n);c&&Object.keys(c).length&&(t.extra={...c,...t.extra});let u=S(r);u&&Object.keys(u).length&&(t.tags={...u,...t.tags});let p=S(s);p&&Object.keys(p).length&&(t.user={...p,...t.user});let l=S(o);l&&Object.keys(l).length&&(t.contexts={...l,...t.contexts}),i&&(t.level=i),a&&t.type!=="transaction"&&(t.transaction=a)}function Fr(t,e){let n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}function Ur(t,e){t.sdkProcessingMetadata={...t.sdkProcessingMetadata,...e}}function $r(t,e){t.contexts={trace:Ue(e),...t.contexts},t.sdkProcessingMetadata={dynamicSamplingContext:Be(e),...t.sdkProcessingMetadata};let n=U(e),r=X(n).description;r&&!t.transaction&&t.type==="transaction"&&(t.transaction=r)}function Br(t,e){t.fingerprint=t.fingerprint?ae(t.fingerprint):[],e&&(t.fingerprint=t.fingerprint.concat(e)),t.fingerprint&&!t.fingerprint.length&&delete t.fingerprint}function vn(t,e,n,r,s,o){let{normalizeDepth:i=3,normalizeMaxBreadth:a=1e3}=t,c={...e,event_id:e.event_id||n.event_id||T(),timestamp:e.timestamp||W()},u=n.integrations||t.integrations.map(y=>y.name);Hr(c,t),qr(c,u),e.type===void 0&&jr(c,t.stackParser);let p=Yr(r,n.captureContext);n.mechanism&&j(c,n.mechanism);let l=s?s.getEventProcessors():[],g=dn().getScopeData();if(o){let y=o.getScopeData();Dt(g,y)}if(p){let y=p.getScopeData();Dt(g,y)}let f=[...n.attachments||[],...g.attachments];f.length&&(n.attachments=f),Nn(c,g);let h=[...l,...g.eventProcessors];return He(h,c,n).then(y=>(y&&Gr(y),typeof i=="number"&&i>0?zr(y,i,a):y))}function Hr(t,e){let{environment:n,release:r,dist:s,maxValueLength:o=250}=e;"environment"in t||(t.environment="environment"in e?n:$e),t.release===void 0&&r!==void 0&&(t.release=r),t.dist===void 0&&s!==void 0&&(t.dist=s),t.message&&(t.message=D(t.message,o));let i=t.exception&&t.exception.values&&t.exception.values[0];i&&i.value&&(i.value=D(i.value,o));let a=t.request;a&&a.url&&(a.url=D(a.url,o))}var On=new WeakMap;function jr(t,e){let n=m._sentryDebugIds;if(!n)return;let r,s=On.get(e);s?r=s:(r=new Map,On.set(e,r));let o=Object.keys(n).reduce((i,a)=>{let c,u=r.get(a);u?c=u:(c=e(a),r.set(a,c));for(let p=c.length-1;p>=0;p--){let l=c[p];if(l.filename){i[l.filename]=n[a];break}}return i},{});try{t.exception.values.forEach(i=>{i.stacktrace.frames.forEach(a=>{a.filename&&(a.debug_id=o[a.filename])})})}catch{}}function Gr(t){let e={};try{t.exception.values.forEach(r=>{r.stacktrace.frames.forEach(s=>{s.debug_id&&(s.abs_path?e[s.abs_path]=s.debug_id:s.filename&&(e[s.filename]=s.debug_id),delete s.debug_id)})})}catch{}if(Object.keys(e).length===0)return;t.debug_meta=t.debug_meta||{},t.debug_meta.images=t.debug_meta.images||[];let n=t.debug_meta.images;Object.keys(e).forEach(r=>{n.push({type:"sourcemap",code_file:r,debug_id:e[r]})})}function qr(t,e){e.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=[...t.sdk.integrations||[],...e])}function zr(t,e,n){if(!t)return null;let r={...t,...t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map(s=>({...s,...s.data&&{data:N(s.data,e,n)}}))},...t.user&&{user:N(t.user,e,n)},...t.contexts&&{contexts:N(t.contexts,e,n)},...t.extra&&{extra:N(t.extra,e,n)}};return t.contexts&&t.contexts.trace&&r.contexts&&(r.contexts.trace=t.contexts.trace,t.contexts.trace.data&&(r.contexts.trace.data=N(t.contexts.trace.data,e,n))),t.spans&&(r.spans=t.spans.map(s=>({...s,...s.data&&{data:N(s.data,e,n)}}))),r}function Yr(t,e){if(!e)return t;let n=t?t.clone():new C;return n.update(e),n}var je=class{constructor(e,n){this._client=e,this.flushTimeout=60,this._pendingAggregates={},this._isEnabled=!0,this._intervalId=setInterval(()=>this.flush(),this.flushTimeout*1e3),this._intervalId.unref&&this._intervalId.unref(),this._sessionAttrs=n}flush(){let e=this.getSessionAggregates();e.aggregates.length!==0&&(this._pendingAggregates={},this._client.sendSession(e))}getSessionAggregates(){let e=Object.keys(this._pendingAggregates).map(r=>this._pendingAggregates[parseInt(r)]),n={attrs:this._sessionAttrs,aggregates:e};return S(n)}close(){clearInterval(this._intervalId),this._isEnabled=!1,this.flush()}incrementSessionStatusCount(){if(!this._isEnabled)return;let e=z(),n=e.getRequestSession();n&&n.status&&(this._incrementSessionStatusCount(n.status,new Date),e.setRequestSession(void 0))}_incrementSessionStatusCount(e,n){let r=new Date(n).setSeconds(0,0);this._pendingAggregates[r]=this._pendingAggregates[r]||{};let s=this._pendingAggregates[r];switch(s.started||(s.started=new Date(r).toISOString()),e){case"errored":return s.errored=(s.errored||0)+1,s.errored;case"ok":return s.exited=(s.exited||0)+1,s.exited;default:return s.crashed=(s.crashed||0)+1,s.crashed}}};var Jr="7";function Vr(t){let e=t.protocol?`${t.protocol}:`:"",n=t.port?`:${t.port}`:"";return`${e}//${t.host}${n}${t.path?`/${t.path}`:""}/api/`}function Wr(t){return`${Vr(t)}${t.projectId}/envelope/`}function Kr(t,e){return at({sentry_key:t.publicKey,sentry_version:Jr,...e&&{sentry_client:`${e.name}/${e.version}`}})}function wn(t,e,n){return e||`${Wr(t)}?${Kr(t,n)}`}var Dn=[];function Zr(t){let e={};return t.forEach(n=>{let{name:r}=n,s=e[r];s&&!s.isDefaultInstance&&n.isDefaultInstance||(e[r]=n)}),Object.keys(e).map(n=>e[n])}function Mt(t){let e=t.defaultIntegrations||[],n=t.integrations;e.forEach(i=>{i.isDefaultInstance=!0});let r;Array.isArray(n)?r=[...e,...n]:typeof n=="function"?r=ae(n(e)):r=e;let s=Zr(r),o=Xr(s,i=>i.name==="Debug");if(o!==-1){let[i]=s.splice(o,1);s.push(i)}return s}function Mn(t,e){let n={};return e.forEach(r=>{r&&kt(t,r,n)}),n}function Pt(t,e){for(let n of e)n&&n.afterAllSetup&&n.afterAllSetup(t)}function kt(t,e,n){if(n[e.name]){_&&d.log(`Integration skipped because it was already installed: ${e.name}`);return}if(n[e.name]=e,Dn.indexOf(e.name)===-1&&typeof e.setupOnce=="function"&&(e.setupOnce(),Dn.push(e.name)),e.setup&&typeof e.setup=="function"&&e.setup(t),typeof e.preprocessEvent=="function"){let r=e.preprocessEvent.bind(e);t.on("preprocessEvent",(s,o)=>r(s,o,t))}if(typeof e.processEvent=="function"){let r=e.processEvent.bind(e),s=Object.assign((o,i)=>r(o,i,t),{id:e.name});t.addEventProcessor(s)}_&&d.log(`Integration installed: ${e.name}`)}function Xr(t,e){for(let n=0;n<t.length;n++)if(e(t[n])===!0)return n;return-1}var Pn="Not capturing exception because it's already been captured.",Ge=class{constructor(e){if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],e.dsn?this._dsn=xe(e.dsn):_&&d.warn("No DSN provided, client will not send events."),this._dsn){let n=wn(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:n})}}captureException(e,n,r){let s=T();if(Me(e))return _&&d.log(Pn),s;let o={event_id:s,...n};return this._process(this.eventFromException(e,o).then(i=>this._captureEvent(i,o,r))),o.event_id}captureMessage(e,n,r,s){let o={event_id:T(),...r},i=J(e)?e:String(e),a=Te(e)?this.eventFromMessage(i,n,o):this.eventFromException(e,o);return this._process(a.then(c=>this._captureEvent(c,o,s))),o.event_id}captureEvent(e,n,r){let s=T();if(n&&n.originalException&&Me(n.originalException))return _&&d.log(Pn),s;let o={event_id:s,...n},a=(e.sdkProcessingMetadata||{}).capturedSpanScope;return this._process(this._captureEvent(e,o,a||r)),o.event_id}captureSession(e){typeof e.release!="string"?_&&d.warn("Discarded session because of missing or non-string release"):(this.sendSession(e),le(e,{init:!1}))}getDsn(){return this._dsn}getOptions(){return this._options}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}flush(e){let n=this._transport;return n?(this.emit("flush"),this._isClientDoneProcessing(e).then(r=>n.flush(e).then(s=>r&&s))):b(!0)}close(e){return this.flush(e).then(n=>(this.getOptions().enabled=!1,this.emit("close"),n))}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){this._isEnabled()&&this._setupIntegrations()}getIntegrationByName(e){return this._integrations[e]}addIntegration(e){let n=this._integrations[e.name];kt(this,e,this._integrations),n||Pt(this,[e])}sendEvent(e,n={}){this.emit("beforeSendEvent",e,n);let r=Rn(e,this._dsn,this._options._metadata,this._options.tunnel);for(let o of n.attachments||[])r=Et(r,yt(o));let s=this.sendEnvelope(r);s&&s.then(o=>this.emit("afterSendEvent",e,o),null)}sendSession(e){let n=Cn(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(n)}recordDroppedEvent(e,n,r){if(this._options.sendClientReports){let s=`${e}:${n}`;_&&d.log(`Adding outcome: "${s}"`),this._outcomes[s]=this._outcomes[s]+1||1}}on(e,n){this._hooks[e]||(this._hooks[e]=[]),this._hooks[e].push(n)}emit(e,...n){this._hooks[e]&&this._hooks[e].forEach(r=>r(...n))}sendEnvelope(e){return this.emit("beforeEnvelope",e),this._isEnabled()&&this._transport?this._transport.send(e).then(null,n=>(_&&d.error("Error while sending event:",n),n)):(_&&d.error("Transport disabled"),b({}))}_setupIntegrations(){let{integrations:e}=this._options;this._integrations=Mn(this,e),Pt(this,e)}_updateSessionFromEvent(e,n){let r=!1,s=!1,o=n.exception&&n.exception.values;if(o){s=!0;for(let c of o){let u=c.mechanism;if(u&&u.handled===!1){r=!0;break}}}let i=e.status==="ok";(i&&e.errors===0||i&&r)&&(le(e,{...r&&{status:"crashed"},errors:e.errors||Number(s||r)}),this.captureSession(e))}_isClientDoneProcessing(e){return new I(n=>{let r=0,s=1,o=setInterval(()=>{this._numProcessing==0?(clearInterval(o),n(!0)):(r+=s,e&&r>=e&&(clearInterval(o),n(!1)))},s)})}_isEnabled(){return this.getOptions().enabled!==!1&&this._transport!==void 0}_prepareEvent(e,n,r,s=z()){let o=this.getOptions(),i=Object.keys(this._integrations);return!n.integrations&&i.length>0&&(n.integrations=i),this.emit("preprocessEvent",e,n),e.type||s.setLastEventId(e.event_id||n.event_id),vn(o,e,n,r,this,s).then(a=>{if(a===null)return a;let c={...s.getPropagationContext(),...r?r.getPropagationContext():void 0};if(!(a.contexts&&a.contexts.trace)&&c){let{traceId:p,spanId:l,parentSpanId:g,dsc:f}=c;a.contexts={trace:S({trace_id:p,span_id:l,parent_span_id:g}),...a.contexts};let h=f||fe(p,this);a.sdkProcessingMetadata={dynamicSamplingContext:h,...a.sdkProcessingMetadata}}return a})}_captureEvent(e,n={},r){return this._processEvent(e,n,r).then(s=>s.event_id,s=>{if(_){let o=s;o.logLevel==="log"?d.log(o.message):d.warn(o)}})}_processEvent(e,n,r){let s=this.getOptions(),{sampleRate:o}=s,i=Ln(e),a=kn(e),c=e.type||"error",u=`before send for type \`${c}\``,p=typeof o>"u"?void 0:bn(o);if(a&&typeof p=="number"&&Math.random()>p)return this.recordDroppedEvent("sample_rate","error",e),G(new x(`Discarding event because it's not included in the random sample (sampling rate = ${o})`,"log"));let l=c==="replay_event"?"replay":c,f=(e.sdkProcessingMetadata||{}).capturedSpanIsolationScope;return this._prepareEvent(e,n,r,f).then(h=>{if(h===null)throw this.recordDroppedEvent("event_processor",l,e),new x("An event processor returned `null`, will not send event.","log");if(n.data&&n.data.__sentry__===!0)return h;let y=es(s,h,n);return Qr(y,u)}).then(h=>{if(h===null)throw this.recordDroppedEvent("before_send",l,e),new x(`${u} returned \`null\`, will not send event.`,"log");let Y=r&&r.getSession();!i&&Y&&this._updateSessionFromEvent(Y,h);let y=h.transaction_info;if(i&&y&&h.transaction!==e.transaction){let A="custom";h.transaction_info={...y,source:A}}return this.sendEvent(h,n),h}).then(null,h=>{throw h instanceof x?h:(this.captureException(h,{data:{__sentry__:!0},originalException:h}),new x(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event. Reason: ${h}`))})}_process(e){this._numProcessing++,e.then(n=>(this._numProcessing--,n),n=>(this._numProcessing--,n))}_clearOutcomes(){let e=this._outcomes;return this._outcomes={},Object.keys(e).map(n=>{let[r,s]=n.split(":");return{reason:r,category:s,quantity:e[n]}})}};function Qr(t,e){let n=`${e} must return \`null\` or a valid event.`;if(O(t))return t.then(r=>{if(!R(r)&&r!==null)throw new x(n);return r},r=>{throw new x(`${e} rejected with ${r}`)});if(!R(t)&&t!==null)throw new x(n);return t}function es(t,e,n){let{beforeSend:r,beforeSendTransaction:s,beforeSendSpan:o}=t;if(kn(e)&&r)return r(e,n);if(Ln(e)){if(e.spans&&o){let i=[];for(let a of e.spans){let c=o(a);c&&i.push(c)}e.spans=i}if(s)return s(e,n)}return e}function kn(t){return t.type===void 0}function Ln(t){return t.type==="transaction"}function Fn(t,e,n,r,s){let o={sent_at:new Date().toISOString()};n&&n.sdk&&(o.sdk={name:n.sdk.name,version:n.sdk.version}),r&&s&&(o.dsn=k(s)),e&&(o.trace=S(e));let i=ts(t);return L(o,[i])}function ts(t){return[{type:"check_in"},t]}var ge=class extends Ge{constructor(e){An(),super(e)}eventFromException(e,n){return b(bt(this,this._options.stackParser,e,n))}eventFromMessage(e,n="info",r){return b(Ct(this._options.stackParser,e,n,r,this._options.attachStacktrace))}captureException(e,n,r){if(this._options.autoSessionTracking&&this._sessionFlusher){let s=z().getRequestSession();s&&s.status==="ok"&&(s.status="errored")}return super.captureException(e,n,r)}captureEvent(e,n,r){if(this._options.autoSessionTracking&&this._sessionFlusher&&(e.type||"exception")==="exception"&&e.exception&&e.exception.values&&e.exception.values.length>0){let i=z().getRequestSession();i&&i.status==="ok"&&(i.status="errored")}return super.captureEvent(e,n,r)}close(e){return this._sessionFlusher&&this._sessionFlusher.close(),super.close(e)}initSessionFlusher(){let{release:e,environment:n}=this._options;e?this._sessionFlusher=new je(this,{release:e,environment:n}):_&&d.warn("Cannot initialise an instance of SessionFlusher if no release is provided!")}captureCheckIn(e,n,r){let s="checkInId"in e&&e.checkInId?e.checkInId:T();if(!this._isEnabled())return _&&d.warn("SDK not enabled, will not capture checkin."),s;let o=this.getOptions(),{release:i,environment:a,tunnel:c}=o,u={check_in_id:s,monitor_slug:e.monitorSlug,status:e.status,release:i,environment:a};"duration"in e&&(u.duration=e.duration),n&&(u.monitor_config={schedule:n.schedule,checkin_margin:n.checkinMargin,max_runtime:n.maxRuntime,timezone:n.timezone,failure_issue_threshold:n.failureIssueThreshold,recovery_threshold:n.recoveryThreshold});let[p,l]=this._getTraceInfoFromScope(r);l&&(u.contexts={trace:l});let g=Fn(u,p,this.getSdkMetadata(),c,this.getDsn());return _&&d.info("Sending checkin:",e.monitorSlug,e.status),this.sendEnvelope(g),s}_captureRequestSession(){this._sessionFlusher?this._sessionFlusher.incrementSessionStatusCount():_&&d.warn("Discarded request mode session because autoSessionTracking option was disabled")}_prepareEvent(e,n,r,s){return this._options.platform&&(e.platform=e.platform||this._options.platform),this._options.runtime&&(e.contexts={...e.contexts,runtime:(e.contexts||{}).runtime||this._options.runtime}),this._options.serverName&&(e.server_name=e.server_name||this._options.serverName),super._prepareEvent(e,n,r,s)}_getTraceInfoFromScope(e){if(!e)return[void 0,void 0];let n=q(e);if(n){let c=U(n);return[Be(c),Ue(c)]}let{traceId:r,spanId:s,parentSpanId:o,dsc:i}=e.getPropagationContext(),a={trace_id:r,span_id:s,parent_span_id:o};return i?[i,a]:[fe(r,this),a]}};var ns=64;function Lt(t,e,n=gt(t.bufferSize||ns)){let r={},s=i=>n.drain(i);function o(i){let a=[];if(Pe(i,(l,g)=>{let f=ke(g);if(It(r,f)){let h=Un(l,g);t.recordDroppedEvent("ratelimit_backoff",f,h)}else a.push(l)}),a.length===0)return b({});let c=L(i[0],a),u=l=>{Pe(c,(g,f)=>{let h=Un(g,f);t.recordDroppedEvent(l,ke(f),h)})},p=()=>e({body:St(c)}).then(l=>(l.statusCode!==void 0&&(l.statusCode<200||l.statusCode>=300)&&_&&d.warn(`Sentry responded with status code ${l.statusCode} to sent event.`),r=xt(r,l),l),l=>{throw u("network_error"),l});return n.add(p).then(l=>l,l=>{if(l instanceof x)return _&&d.error("Skipped sending event because buffer is full."),u("queue_overflow"),b({});throw l})}return{send:o,flush:s}}function Un(t,e){if(!(e!=="event"&&e!=="transaction"))return Array.isArray(t)?t[1]:void 0}var rs="RewriteFrames",qe=(t={})=>{let e=t.root,n=t.prefix||"app:///",r="window"in m&&m.window!==void 0,s=t.iteratee||ss({isBrowser:r,root:e,prefix:n});function o(a){try{return{...a,exception:{...a.exception,values:a.exception.values.map(c=>({...c,...c.stacktrace&&{stacktrace:i(c.stacktrace)}}))}}}catch{return a}}function i(a){return{...a,frames:a&&a.frames&&a.frames.map(c=>s(c))}}return{name:rs,processEvent(a){let c=a;return a.exception&&Array.isArray(a.exception.values)&&(c=o(c)),c}}};function ss({isBrowser:t,root:e,prefix:n}){return r=>{if(!r.filename)return r;let s=/^[a-zA-Z]:\\/.test(r.filename)||r.filename.includes("\\")&&!r.filename.includes("/"),o=/^\//.test(r.filename);if(t){if(e){let i=r.filename;i.indexOf(e)===0&&(r.filename=i.replace(e,n))}}else if(s||o){let i=s?r.filename.replace(/^[a-zA-Z]:/,"").replace(/\\/g,"/"):r.filename,a=e?mt(e,i):ce(i);r.filename=`${n}${a}`}return r}}function Bn(t){return typeof t=="object"&&t!==null}function is(t){return Bn(t)&&"handled"in t&&typeof t.handled=="boolean"&&"type"in t&&typeof t.type=="string"}function as(t){return Bn(t)&&"mechanism"in t&&is(t.mechanism)}function cs(){if(m.SENTRY_RELEASE&&m.SENTRY_RELEASE.id)return m.SENTRY_RELEASE.id}function $n(t,e){return t!==void 0?(t[e[0]]=e[1],t):{[e[0]]:e[1]}}function Hn(t,e){return t(e.stack||"",1)}function us(t){let e=t&&t.message;return e?e.error&&typeof e.error.message=="string"?e.error.message:e:"No error message"}function jn(t,e){let n={type:e.name||e.constructor.name,value:us(e)},r=Hn(t,e);return r.length&&(n.stacktrace={frames:r}),n.type===void 0&&n.value===""&&(n.value="Unrecoverable error caught"),n}function ls(t,e,n,r){let s,i=(r&&r.data&&as(r.data)?r.data.mechanism:void 0)??{handled:!0,type:"generic"};if(B(n))s=n;else{if(R(n)){let c=`Non-Error exception captured with keys: ${ne(n)}`,u=t?.getClient(),p=u&&u.getOptions().normalizeDepth;t?.setExtra("__serialized__",K(n,p)),s=r&&r.syntheticException||new Error(c),s.message=c}else s=r&&r.syntheticException||new Error(n),s.message=n;i.synthetic=!0}let a={exception:{values:[jn(e,s)]}};return ie(a,void 0,void 0),j(a,i),{...a,event_id:r&&r.event_id}}function ps(t,e,n="info",r,s){let o={event_id:r&&r.event_id,level:n,message:e};if(s&&r&&r.syntheticException){let i=Hn(t,r.syntheticException);i.length&&(o.exception={values:[{value:e,stacktrace:{frames:i}}]})}return o}var ds=5,fs=(t={limit:ds})=>({name:"LinkedErrors",processEvent:(e,n,r)=>ms(r.getOptions().stackParser,t.limit,e,n)});function ms(t,e,n,r){if(!n.exception||!n.exception.values||!r||!v(r.originalException,Er