@sailfish-ai/sf-veritas 0.1.34 → 0.1.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var Te=Object.defineProperty;var Me=(i,r,s)=>r in i?Te(i,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[r]=s;var y=(i,r,s)=>Me(i,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _e=require("async_hooks"),Le=require("fs"),De=require("worker_threads"),G=[];for(let i=0;i<256;++i)G.push((i+256).toString(16).slice(1));let ee;const xe=new Uint8Array(16),ue={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function E(i,r,s){if(ue.randomUUID&&!i)return ue.randomUUID();const g=(i=i||{}).random??i.rng?.()??(function(){if(!ee){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ee=crypto.getRandomValues.bind(crypto)}return ee(xe)})();if(g.length<16)throw new Error("Random bytes length must be >= 16");return g[6]=15&g[6]|64,g[8]=63&g[8]|128,(function(a,t=0){return(G[a[t+0]]+G[a[t+1]]+G[a[t+2]]+G[a[t+3]]+"-"+G[a[t+4]]+G[a[t+5]]+"-"+G[a[t+6]]+G[a[t+7]]+"-"+G[a[t+8]]+G[a[t+9]]+"-"+G[a[t+10]]+G[a[t+11]]+G[a[t+12]]+G[a[t+13]]+G[a[t+14]]+G[a[t+15]]).toLowerCase()})(g)}class Oe{constructor(r){y(this,"apiKey");y(this,"apiGraphqlEndpoint");y(this,"sfDebug");y(this,"serviceIdentifier");y(this,"serviceVersion");y(this,"serviceUUID");y(this,"serviceAdditionalMetadata");y(this,"profilingModeEnabled");y(this,"profilingMaxDepth");y(this,"profilingMaxVariableSizeKb");y(this,"domainsToNotPropagateHeadersTo");y(this,"nodeModulesToCollectLocalVariablesOn");y(this,"printConfigurationStatuses");y(this,"logLevel");y(this,"stackDepthLocals");y(this,"stackDepthCodeTraceDepth");y(this,"packageLibraryType");y(this,"version");y(this,"gitSha");y(this,"_serviceIdentificationReceived",!1);this.apiKey=r.apiKey,this.apiGraphqlEndpoint=r?.apiGraphqlEndpoint||process.env.SAILFISH_GRAPHQL_ENDPOINT||"https://api-service.sailfishqa.com/graphql/",this.sfDebug=r?.debug===!0||process.env.SF_DEBUG==="true",this.serviceIdentifier=r?.serviceIdentifier||process.env.SERVICE_IDENTIFIER,this.serviceUUID=E(),this.serviceVersion=r?.serviceVersion||process.env.SERVICE_VERSION,this.gitSha=r?.gitSha||process.env.GIT_SHA||process.env.VERCEL_GIT_COMMIT_SHA,this.serviceAdditionalMetadata=r?.serviceAdditionalMetadata||{},this.profilingModeEnabled=r?.profilingModeEnabled??!1,this.profilingMaxDepth=r?.profilingMaxDepth??5,this.profilingMaxVariableSizeKb=r?.profilingMaxVariableSizeKb??25,this.domainsToNotPropagateHeadersTo=r?.domainsToNotPropagateHeadersTo||[],this.nodeModulesToCollectLocalVariablesOn=r?.nodeModulesToCollectLocalVariablesOn||["_all_"],this.printConfigurationStatuses=process.env.PRINT_CONFIGURATION_STATUSES||"true",this.logLevel=process.env.LOG_LEVEL||"INFO",this.stackDepthLocals=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS,10):5,isNaN(this.stackDepthLocals)&&(this.stackDepthLocals=-1),this.stackDepthCodeTraceDepth=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH,10):-1,isNaN(this.stackDepthCodeTraceDepth)&&(this.stackDepthCodeTraceDepth=-1),this.packageLibraryType="JS/TS BACKEND",this.version=this.getPackageVersion()}getPackageVersion(){return"0.1.15"}get serviceIdentificationReceived(){return this._serviceIdentificationReceived}setServiceIdentificationReceived(r){this._serviceIdentificationReceived=r}}const Ye=Symbol.for("sailfish.sf_config");function Ke(){return globalThis[Ye]}function ze(i){const r=Ke();if(r)return{config:r};const s=new Oe(i);return(function(g){globalThis[Ye]=g})(s),s.sfDebug&&console.log("[[getOrCreateConfig]] Created global config:",s),{config:s}}function A(){const i=Ke();if(!i)throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");return i}const de=Symbol.for("sf.ctx.storeAls"),V=globalThis,te=V[de]??(V[de]=new _e.AsyncLocalStorage),Ue=["identitytoolkit.googleapis.com","t.co","*.twitter.com","*.gravatar.com","*.googleapis.com","*.amazonaws.com","*.smooch.io","*.zendesk.com"],Ie=Symbol.for("sf.ctx.als"),J=V[Ie]??(V[Ie]=new _e.AsyncLocalStorage),pe=Symbol.for("sf.ctx.sessionRegistry"),K=V[pe]??(V[pe]=new Map),O={handledExceptions:new Set,reentrancyGuardLoggingActive:!1,reentrancyGuardLoggingPreActive:!1,reentrancyGuardPrintActive:!1,reentrancyGuardPrintPreActive:!1,reentrancyGuardExceptionActive:!1,reentrancyGuardExceptionPreActive:!1,excludedDomains:new Set(Ue),supportedDomains:new Set},_=class _{constructor(){}current(){return te.getStore()}ensureStore(){const r=this.current();if(r)return r;const s=new Map;return te.enterWith(s),s}runWith(r,s){const g=this.current()??new Map,a=new Map(g);for(const[t,o]of Object.entries(r))a.set(t,o);return te.run(a,s)}static getInstance(){return V[_.GLOBAL_MANAGER_SYMBOL]||(V[_.GLOBAL_MANAGER_SYMBOL]=new _),V[_.GLOBAL_MANAGER_SYMBOL]}getCurrentContext(){return J.getStore()||O}setCurrentContext(r){const s=J.getStore()||O;J.enterWith({...s,...r})}ensureSession(r){let s=K.get(r);return s||(s={...O},K.set(r,s)),s}getContextFor(r){return K.get(r)??O}updateContextFor(r,s){const g=this.ensureSession(r);K.set(r,{...g,...s})}runWithSession(r,s){const g={...this.ensureSession(r)};return J.run(g,s)}deleteSession(r){K.delete(r)}getTraceId(){return this.getCurrentContext().traceId}getPageVisitUUID(){return this.getCurrentContext().pageVisitUUID}setTraceId(r){this.setCurrentContext({traceId:r})}setPageVisitUUID(r){this.setCurrentContext({pageVisitUUID:r})}getOrSetSfTraceId(r,s=!1){let g=this.getTraceId();return g||(g=r||(s?E():`nonsession-applogs-v3/${A().apiKey}/${E()}`),this.setTraceId(g),A().sfDebug&&console.log(" Created new trace ID:",g),g)}getOrSetPageVisitUUID(){let r=this.getPageVisitUUID();return r||(r=E(),this.setPageVisitUUID(r),A().sfDebug&&console.log(" Created new page visit UUID:",r),r)}getHandledExceptions(){return this.getCurrentContext().handledExceptions}markExceptionHandled(r){const s=this.getHandledExceptions();s.add(r),this.setCurrentContext({handledExceptions:s})}hasHandledException(r){return this.getHandledExceptions().has(r)}resetHandledExceptions(){this.setCurrentContext({handledExceptions:new Set})}getExcludedDomains(){return this.getCurrentContext().excludedDomains}getSupportedDomains(){return this.getCurrentContext().supportedDomains}addSupportedDomains(r){this.getCurrentContext().supportedDomains.add(r.toLowerCase().trim())}setTraceIdFor(r,s){this.updateContextFor(r,{traceId:s})}setPageVisitUUIDFor(r,s){this.updateContextFor(r,{pageVisitUUID:s})}};y(_,"GLOBAL_MANAGER_SYMBOL",Symbol.for("sf.ctx.manager"));let w=_;class L{constructor(){y(this,"apiKey");y(this,"endpoint");y(this,"queryType","mutation");y(this,"operationName","");y(this,"serviceUUID",A().serviceUUID);y(this,"contextManager");this.apiKey=A().apiKey,this.endpoint=A().apiGraphqlEndpoint,this.contextManager=w.getInstance()}get queryName(){return this.operationName?this.operationName.charAt(0).toLowerCase()+this.operationName.slice(1):""}getDefaultVariables(){const r=Date.now().toString(),s=this.contextManager.getOrSetSfTraceId();return{apiKey:this.apiKey,serviceUuid:this.serviceUUID,sessionId:s,timestampMs:r}}getVariables(r={}){return{...this.getDefaultVariables(),...r}}setOperationName(r){this.operationName=r}setEndpoint(r){this.endpoint=r}setServiceUUID(r){this.serviceUUID=r}}const ke=fetch;async function H(i,r,s,g){try{const a=A();let t;try{t=JSON.stringify({query:s,variables:g,operationName:r})}catch{t=JSON.stringify({query:s,operationName:r})}ke(i,{method:"POST",headers:{"Content-Type":"application/json"},body:t}).then(async o=>{if(!o.ok)return void(a.sfDebug&&console.error(`GraphQL request failed with status ${o.status} for ${r}`));const c=await o.json();c.errors?.length?(function(I,p,C){const l=I&&typeof I=="object"&&!Array.isArray(I)?Object.keys(I)[0]:void 0;console.error(l==="identifyServiceDetails"?`IdentifyServiceDetails NOT sent successfully for service: UUID=${C.serviceUUID}`:`GraphQL request failed with errors: ${JSON.stringify(p)} for operation key ${l}`)})(c.data,c.errors,a):a.sfDebug&&(function(I,p,C){const l=I&&typeof I=="object"&&!Array.isArray(I)?Object.keys(I)[0]:void 0,d=I[l]||!1;l==="identifyServiceDetails"&&(C.setServiceIdentificationReceived(d),A().sfDebug&&console.log(`IdentifyServiceDetails sent successfully for service: UUID=${C.serviceUUID}; serviceIdentificationReceived=${l==="identifyServiceDetails"?d:"N/A"}`))})(c.data,0,a)}).catch(o=>{a.sfDebug&&console.error("Fetch error:",o)})}catch(a){A().sfDebug&&console.error("Error sending data to GraphQL server:",a)}}class M extends L{constructor(){super(),this.setOperationName("IdentifyServiceDetails")}async doSend(r){if(!A().serviceIdentificationReceived)try{this.send()}catch(s){A().sfDebug&&console.error(" Error during service identification:",s)}}async send(){const r=`
1
+ "use strict";var xe=Object.defineProperty;var ze=(i,t,s)=>t in i?xe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var y=(i,t,s)=>ze(i,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ue=require("async_hooks"),Fe=require("fs"),ke=require("worker_threads"),G=[];for(let i=0;i<256;++i)G.push((i+256).toString(16).slice(1));let ne;const $e=new Uint8Array(16),Ie={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function T(i,t,s){if(Ie.randomUUID&&!i)return Ie.randomUUID();const l=(i=i||{}).random??i.rng?.()??(function(){if(!ne){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ne=crypto.getRandomValues.bind(crypto)}return ne($e)})();if(l.length<16)throw new Error("Random bytes length must be >= 16");return l[6]=15&l[6]|64,l[8]=63&l[8]|128,(function(a,n=0){return(G[a[n+0]]+G[a[n+1]]+G[a[n+2]]+G[a[n+3]]+"-"+G[a[n+4]]+G[a[n+5]]+"-"+G[a[n+6]]+G[a[n+7]]+"-"+G[a[n+8]]+G[a[n+9]]+"-"+G[a[n+10]]+G[a[n+11]]+G[a[n+12]]+G[a[n+13]]+G[a[n+14]]+G[a[n+15]]).toLowerCase()})(l)}class Pe{constructor(t){y(this,"apiKey");y(this,"apiGraphqlEndpoint");y(this,"sfDebug");y(this,"serviceIdentifier");y(this,"serviceVersion");y(this,"serviceUUID");y(this,"serviceAdditionalMetadata");y(this,"profilingModeEnabled");y(this,"profilingMaxDepth");y(this,"profilingMaxVariableSizeKb");y(this,"domainsToNotPropagateHeadersTo");y(this,"nodeModulesToCollectLocalVariablesOn");y(this,"printConfigurationStatuses");y(this,"logLevel");y(this,"stackDepthLocals");y(this,"stackDepthCodeTraceDepth");y(this,"packageLibraryType");y(this,"version");y(this,"gitSha");y(this,"_serviceIdentificationReceived",!1);this.apiKey=t.apiKey,this.apiGraphqlEndpoint=t?.apiGraphqlEndpoint||process.env.SAILFISH_GRAPHQL_ENDPOINT||"https://api-service.sailfishqa.com/graphql/",this.sfDebug=t?.debug===!0||process.env.SF_DEBUG==="true",this.serviceIdentifier=t?.serviceIdentifier||process.env.SERVICE_IDENTIFIER,this.serviceUUID=T(),this.serviceVersion=t?.serviceVersion||process.env.SERVICE_VERSION,this.gitSha=t?.gitSha||process.env.GIT_SHA||process.env.VERCEL_GIT_COMMIT_SHA,this.serviceAdditionalMetadata=t?.serviceAdditionalMetadata||{},this.profilingModeEnabled=t?.profilingModeEnabled??!1,this.profilingMaxDepth=t?.profilingMaxDepth??5,this.profilingMaxVariableSizeKb=t?.profilingMaxVariableSizeKb??25,this.domainsToNotPropagateHeadersTo=t?.domainsToNotPropagateHeadersTo||[],this.nodeModulesToCollectLocalVariablesOn=t?.nodeModulesToCollectLocalVariablesOn||["_all_"],this.printConfigurationStatuses=process.env.PRINT_CONFIGURATION_STATUSES||"true",this.logLevel=process.env.LOG_LEVEL||"INFO",this.stackDepthLocals=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS,10):5,isNaN(this.stackDepthLocals)&&(this.stackDepthLocals=-1),this.stackDepthCodeTraceDepth=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH,10):-1,isNaN(this.stackDepthCodeTraceDepth)&&(this.stackDepthCodeTraceDepth=-1),this.packageLibraryType="JS/TS BACKEND",this.version=this.getPackageVersion()}getPackageVersion(){return"0.1.15"}get serviceIdentificationReceived(){return this._serviceIdentificationReceived}setServiceIdentificationReceived(t){this._serviceIdentificationReceived=t}}const Ke=Symbol.for("sailfish.sf_config");function Xe(){return globalThis[Ke]}function je(i){const t=Xe();if(t)return{config:t};const s=new Pe(i);return(function(l){globalThis[Ke]=l})(s),s.sfDebug&&console.log("[[getOrCreateConfig]] Created global config:",s),{config:s}}function A(){const i=Xe();if(!i)throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");return i}const pe=Symbol.for("sf.ctx.storeAls"),_=globalThis,te=_[pe]??(_[pe]=new Ue.AsyncLocalStorage),Te=["identitytoolkit.googleapis.com","t.co","*.twitter.com","*.gravatar.com","*.googleapis.com","*.amazonaws.com","*.smooch.io","*.zendesk.com"],he=Symbol.for("sf.ctx.als"),X=_[he]??(_[he]=new Ue.AsyncLocalStorage),Ce=Symbol.for("sf.ctx.sessionRegistry"),U=_[Ce]??(_[Ce]=new Map),z={handledExceptions:new Set,reentrancyGuardLoggingActive:!1,reentrancyGuardLoggingPreActive:!1,reentrancyGuardPrintActive:!1,reentrancyGuardPrintPreActive:!1,reentrancyGuardExceptionActive:!1,reentrancyGuardExceptionPreActive:!1,excludedDomains:new Set(Te),supportedDomains:new Set},L=class L{constructor(){}current(){return te.getStore()}ensureStore(){const t=this.current();if(t)return t;const s=new Map;return te.enterWith(s),s}runWith(t,s){const l=this.current()??new Map,a=new Map(l);for(const[n,o]of Object.entries(t))a.set(n,o);return te.run(a,s)}static getInstance(){return _[L.GLOBAL_MANAGER_SYMBOL]||(_[L.GLOBAL_MANAGER_SYMBOL]=new L),_[L.GLOBAL_MANAGER_SYMBOL]}getCurrentContext(){return X.getStore()||z}setCurrentContext(t){const s=X.getStore()||z;X.enterWith({...s,...t})}ensureSession(t){let s=U.get(t);return s||(s={...z},U.set(t,s)),s}getContextFor(t){return U.get(t)??z}updateContextFor(t,s){const l=this.ensureSession(t);U.set(t,{...l,...s})}runWithSession(t,s){const l={...this.ensureSession(t)};return X.run(l,s)}deleteSession(t){U.delete(t)}getTraceId(){return this.getCurrentContext().traceId}getPageVisitUUID(){return this.getCurrentContext().pageVisitUUID}setTraceId(t){this.setCurrentContext({traceId:t})}setPageVisitUUID(t){this.setCurrentContext({pageVisitUUID:t})}getOrSetSfTraceId(t,s=!1){let l=this.getTraceId();return l||(l=t||(s?T():`nonsession-applogs-v3/${A().apiKey}/${T()}`),this.setTraceId(l),A().sfDebug&&console.log(" Created new trace ID:",l),l)}getOrSetPageVisitUUID(){let t=this.getPageVisitUUID();return t||(t=T(),this.setPageVisitUUID(t),A().sfDebug&&console.log(" Created new page visit UUID:",t),t)}getHandledExceptions(){return this.getCurrentContext().handledExceptions}markExceptionHandled(t){const s=this.getHandledExceptions();s.add(t),this.setCurrentContext({handledExceptions:s})}hasHandledException(t){return this.getHandledExceptions().has(t)}resetHandledExceptions(){this.setCurrentContext({handledExceptions:new Set})}getExcludedDomains(){return this.getCurrentContext().excludedDomains}getSupportedDomains(){return this.getCurrentContext().supportedDomains}addSupportedDomains(t){this.getCurrentContext().supportedDomains.add(t.toLowerCase().trim())}setTraceIdFor(t,s){this.updateContextFor(t,{traceId:s})}setPageVisitUUIDFor(t,s){this.updateContextFor(t,{pageVisitUUID:s})}};y(L,"GLOBAL_MANAGER_SYMBOL",Symbol.for("sf.ctx.manager"));let w=L;class E{constructor(){y(this,"apiKey");y(this,"endpoint");y(this,"queryType","mutation");y(this,"operationName","");y(this,"serviceUUID",A().serviceUUID);y(this,"contextManager");this.apiKey=A().apiKey,this.endpoint=A().apiGraphqlEndpoint,this.contextManager=w.getInstance()}get queryName(){return this.operationName?this.operationName.charAt(0).toLowerCase()+this.operationName.slice(1):""}getDefaultVariables(){const t=Date.now().toString(),s=this.contextManager.getOrSetSfTraceId();return{apiKey:this.apiKey,serviceUuid:this.serviceUUID,sessionId:s,timestampMs:t}}getVariables(t={}){return{...this.getDefaultVariables(),...t}}setOperationName(t){this.operationName=t}setEndpoint(t){this.endpoint=t}setServiceUUID(t){this.serviceUUID=t}}const Qe=fetch;async function H(i,t,s,l){try{const a=A();let n;try{n=JSON.stringify({query:s,variables:l,operationName:t})}catch{n=JSON.stringify({query:s,operationName:t})}Qe(i,{method:"POST",headers:{"Content-Type":"application/json"},body:n}).then(async o=>{if(!o.ok)return void(a.sfDebug&&console.error(`GraphQL request failed with status ${o.status} for ${t}`));const c=await o.json();c.errors?.length?(function(d,p,C){const g=d&&typeof d=="object"&&!Array.isArray(d)?Object.keys(d)[0]:void 0;console.error(g==="identifyServiceDetails"?`IdentifyServiceDetails NOT sent successfully for service: UUID=${C.serviceUUID}`:`GraphQL request failed with errors: ${JSON.stringify(p)} for operation key ${g}`)})(c.data,c.errors,a):a.sfDebug&&(function(d,p,C){const g=d&&typeof d=="object"&&!Array.isArray(d)?Object.keys(d)[0]:void 0,I=d[g]||!1;g==="identifyServiceDetails"&&(C.setServiceIdentificationReceived(I),A().sfDebug&&console.log(`IdentifyServiceDetails sent successfully for service: UUID=${C.serviceUUID}; serviceIdentificationReceived=${g==="identifyServiceDetails"?I:"N/A"}`))})(c.data,0,a)}).catch(o=>{a.sfDebug&&console.error("Fetch error:",o)})}catch(a){A().sfDebug&&console.error("Error sending data to GraphQL server:",a)}}class D extends E{constructor(){super(),this.setOperationName("IdentifyServiceDetails")}async doSend(t){if(!A().serviceIdentificationReceived)try{this.send()}catch(s){A().sfDebug&&console.error(" Error during service identification:",s)}}async send(){const t=`
2
2
  ${this.queryType} ${this.operationName}(
3
3
  $apiKey: String!,
4
4
  $timestampMs: String!,
@@ -22,23 +22,45 @@
22
22
  gitSha: $gitSha,
23
23
  )
24
24
  }
25
- `,s=this.getVariables({serviceIdentifier:A().serviceIdentifier,serviceVersion:A().serviceVersion,library:A().packageLibraryType,version:A().version,serviceAdditionalMetadata:A().serviceAdditionalMetadata,gitSha:A().gitSha||""});H(this.endpoint,this.operationName,r,s)}}function $e(i){try{return JSON.stringify(i),!0}catch{return!1}}class Pe extends L{constructor(){super();y(this,"serviceIdentifier",new M);this.setOperationName("CollectMetadata")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s,g,a,t){this.sendAppIdentifier(),this.send(s,g,a,t)}async send(s,g,a,t){if(!g&&!t)throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');let o=[];if(!t){const I=(function(p){const C={},l=[];if(p)for(const[d,e]of Object.entries(p))$e(e)?C[d]=e:l.push(d);return{traitsJson:JSON.stringify(C),excludedFields:l}})(g);t=I.traitsJson,o=I.excludedFields}const c=this.getVariables({userId:s,traitsJson:t,excludedFields:o,override:a,library:A().packageLibraryType,version:A().version});H(this.endpoint,this.operationName,this.getQuery(),c)}getQuery(){return`
25
+ `,s=this.getVariables({serviceIdentifier:A().serviceIdentifier,serviceVersion:A().serviceVersion,library:A().packageLibraryType,version:A().version,serviceAdditionalMetadata:A().serviceAdditionalMetadata,gitSha:A().gitSha||""});H(this.endpoint,this.operationName,t,s)}}function qe(i){try{return JSON.stringify(i),!0}catch{return!1}}class en extends E{constructor(){super();y(this,"serviceIdentifier",new D);this.setOperationName("CollectMetadata")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s,l,a,n){this.sendAppIdentifier(),this.send(s,l,a,n)}async send(s,l,a,n){if(!l&&!n)throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');let o=[];if(!n){const d=(function(p){const C={},g=[];if(p)for(const[I,e]of Object.entries(p))qe(e)?C[I]=e:g.push(I);return{traitsJson:JSON.stringify(C),excludedFields:g}})(l);n=d.traitsJson,o=d.excludedFields}const c=this.getVariables({userId:s,traitsJson:n,excludedFields:o,override:a,library:A().packageLibraryType,version:A().version});H(this.endpoint,this.operationName,this.getQuery(),c)}getQuery(){return`
26
26
  mutation ${this.operationName}($apiKey: String!, $serviceUuid: String!, $sessionId: String!, $userId: String!, $traitsJson: String!, $excludedFields: [String!]!, $library: String!, $timestampMs: String!, $version: String!, $override: Boolean!) {
27
27
  ${this.queryName}(apiKey: $apiKey, serviceUuid: $serviceUuid, sessionId: $sessionId, userId: $userId, traitsJson: $traitsJson, excludedFields: $excludedFields, library: $library, timestampMs: $timestampMs, version: $version, override: $override)
28
28
  }
29
- `}}class he{constructor(r){y(this,"metadataTransmitter");this.apiKey=r,this.metadataTransmitter=new Pe}identify(r,s,g,a=!1){s||g?this.addOrUpdateMetadata(r,s,g,a):this.addOrUpdateMetadata(r,{},void 0,a)}addOrUpdateMetadata(r,s={},g,a=!1){if(!s&&!g)throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');A().sfDebug&&console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"),A().sfDebug&&console.log(" addOrUpdateMetadata...SENDING DATA...",r,s,g),this.metadataTransmitter.doSend(r,s,a,g)}}class le extends L{constructor(){super();y(this,"serviceIdentifier",new M)}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s){this.sendAppIdentifier(),this.send(s)}async send(s){try{const g=Array.isArray(s)?s:[s,"default"],a=this.getVariables({contents:g[0],level:g[1]});H(this.endpoint,this.operationName,this.getQuery(),a)}catch(g){A().sfDebug&&console.error("🚨 Error in send():",g)}}getQuery(){return`
29
+ `}}class me{constructor(t){y(this,"metadataTransmitter");this.apiKey=t,this.metadataTransmitter=new en}identify(t,s,l,a=!1){s||l?this.addOrUpdateMetadata(t,s,l,a):this.addOrUpdateMetadata(t,{},void 0,a)}addOrUpdateMetadata(t,s={},l,a=!1){if(!s&&!l)throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');A().sfDebug&&console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"),A().sfDebug&&console.log(" addOrUpdateMetadata...SENDING DATA...",t,s,l),this.metadataTransmitter.doSend(t,s,a,l)}}class de extends E{constructor(){super();y(this,"serviceIdentifier",new D)}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s){this.sendAppIdentifier(),this.send(s)}async send(s){try{const l=Array.isArray(s)?s:[s,"default"],a=this.getVariables({contents:l[0],level:l[1]});H(this.endpoint,this.operationName,this.getQuery(),a)}catch(l){A().sfDebug&&console.error("🚨 Error in send():",l)}}getQuery(){return`
30
30
  ${this.queryType} ${this.operationName}($apiKey: String!, $serviceUuid: String!, $sessionId: String!, $timestampMs: String!, $level: String!, $contents: String!) {
31
31
  ${this.queryName}(apiKey: $apiKey, serviceUuid: $serviceUuid, sessionId: $sessionId, timestampMs: $timestampMs, level: $level, contents: $contents)
32
32
  }
33
- `}}var Ce,me,z={},ne={},k={},$={};function je(){if(Ce)return $;Ce=1;var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return $.encode=function(r){if(0<=r&&r<i.length)return i[r];throw new TypeError("Must be between 0 and 63: "+r)},$.decode=function(r){return 65<=r&&r<=90?r-65:97<=r&&r<=122?r-97+26:48<=r&&r<=57?r-48+52:r==43?62:r==47?63:-1},$}function Xe(){if(me)return k;me=1;var i=je();return k.encode=function(r){var s,g="",a=(function(t){return t<0?1+(-t<<1):0+(t<<1)})(r);do s=31&a,(a>>>=5)>0&&(s|=32),g+=i.encode(s);while(a>0);return g},k.decode=function(r,s,g){var a,t,o,c,I=r.length,p=0,C=0;do{if(s>=I)throw new Error("Expected more digits in base 64 VLQ value.");if((t=i.decode(r.charCodeAt(s++)))===-1)throw new Error("Invalid base64 digit: "+r.charAt(s-1));a=!!(32&t),p+=(t&=31)<<C,C+=5}while(a);g.value=(c=(o=p)>>1,1&~o?c:-c),g.rest=s},k}var Ae,fe={};function T(){return Ae||(Ae=1,(function(i){i.getArg=function(e,n,h){if(n in e)return e[n];if(arguments.length===3)return h;throw new Error('"'+n+'" is a required argument.')};var r=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,s=/^data:.+\,.+$/;function g(e){var n=e.match(r);return n?{scheme:n[1],auth:n[2],host:n[3],port:n[4],path:n[5]}:null}function a(e){var n="";return e.scheme&&(n+=e.scheme+":"),n+="//",e.auth&&(n+=e.auth+"@"),e.host&&(n+=e.host),e.port&&(n+=":"+e.port),e.path&&(n+=e.path),n}i.urlParse=g,i.urlGenerate=a;var t,o,c=(t=function(e){var n=e,h=g(e);if(h){if(!h.path)return e;n=h.path}for(var u=i.isAbsolute(n),m=[],f=0,b=0;;){if(f=b,(b=n.indexOf("/",f))===-1){m.push(n.slice(f));break}for(m.push(n.slice(f,b));b<n.length&&n[b]==="/";)b++}var v,S=0;for(b=m.length-1;b>=0;b--)(v=m[b])==="."?m.splice(b,1):v===".."?S++:S>0&&(v===""?(m.splice(b+1,S),S=0):(m.splice(b,2),S--));return(n=m.join("/"))===""&&(n=u?"/":"."),h?(h.path=n,a(h)):n},o=[],function(e){for(var n=0;n<o.length;n++)if(o[n].input===e){var h=o[0];return o[0]=o[n],o[n]=h,o[0].result}var u=t(e);return o.unshift({input:e,result:u}),o.length>32&&o.pop(),u});function I(e,n){e===""&&(e="."),n===""&&(n=".");var h=g(n),u=g(e);if(u&&(e=u.path||"/"),h&&!h.scheme)return u&&(h.scheme=u.scheme),a(h);if(h||n.match(s))return n;if(u&&!u.host&&!u.path)return u.host=n,a(u);var m=n.charAt(0)==="/"?n:c(e.replace(/\/+$/,"")+"/"+n);return u?(u.path=m,a(u)):m}i.normalize=c,i.join=I,i.isAbsolute=function(e){return e.charAt(0)==="/"||r.test(e)},i.relative=function(e,n){e===""&&(e="."),e=e.replace(/\/$/,"");for(var h=0;n.indexOf(e+"/")!==0;){var u=e.lastIndexOf("/");if(u<0||(e=e.slice(0,u)).match(/^([^\/]+:\/)?\/*$/))return n;++h}return Array(h+1).join("../")+n.substr(e.length+1)};var p=!("__proto__"in Object.create(null));function C(e){return e}function l(e){if(!e)return!1;var n=e.length;if(n<9||e.charCodeAt(n-1)!==95||e.charCodeAt(n-2)!==95||e.charCodeAt(n-3)!==111||e.charCodeAt(n-4)!==116||e.charCodeAt(n-5)!==111||e.charCodeAt(n-6)!==114||e.charCodeAt(n-7)!==112||e.charCodeAt(n-8)!==95||e.charCodeAt(n-9)!==95)return!1;for(var h=n-10;h>=0;h--)if(e.charCodeAt(h)!==36)return!1;return!0}function d(e,n){return e===n?0:e===null?1:n===null?-1:e>n?1:-1}i.toSetString=p?C:function(e){return l(e)?"$"+e:e},i.fromSetString=p?C:function(e){return l(e)?e.slice(1):e},i.compareByOriginalPositions=function(e,n,h){var u=d(e.source,n.source);return u!==0||(u=e.originalLine-n.originalLine)!==0||(u=e.originalColumn-n.originalColumn)!==0||h||(u=e.generatedColumn-n.generatedColumn)!==0||(u=e.generatedLine-n.generatedLine)!==0?u:d(e.name,n.name)},i.compareByOriginalPositionsNoSource=function(e,n,h){var u;return(u=e.originalLine-n.originalLine)!==0||(u=e.originalColumn-n.originalColumn)!==0||h||(u=e.generatedColumn-n.generatedColumn)!==0||(u=e.generatedLine-n.generatedLine)!==0?u:d(e.name,n.name)},i.compareByGeneratedPositionsDeflated=function(e,n,h){var u=e.generatedLine-n.generatedLine;return u!==0||(u=e.generatedColumn-n.generatedColumn)!==0||h||(u=d(e.source,n.source))!==0||(u=e.originalLine-n.originalLine)!==0||(u=e.originalColumn-n.originalColumn)!==0?u:d(e.name,n.name)},i.compareByGeneratedPositionsDeflatedNoLine=function(e,n,h){var u=e.generatedColumn-n.generatedColumn;return u!==0||h||(u=d(e.source,n.source))!==0||(u=e.originalLine-n.originalLine)!==0||(u=e.originalColumn-n.originalColumn)!==0?u:d(e.name,n.name)},i.compareByGeneratedPositionsInflated=function(e,n){var h=e.generatedLine-n.generatedLine;return h!==0||(h=e.generatedColumn-n.generatedColumn)!==0||(h=d(e.source,n.source))!==0||(h=e.originalLine-n.originalLine)!==0||(h=e.originalColumn-n.originalColumn)!==0?h:d(e.name,n.name)},i.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},i.computeSourceURL=function(e,n,h){if(n=n||"",e&&(e[e.length-1]!=="/"&&n[0]!=="/"&&(e+="/"),n=e+n),h){var u=g(h);if(!u)throw new Error("sourceMapURL could not be parsed");if(u.path){var m=u.path.lastIndexOf("/");m>=0&&(u.path=u.path.substring(0,m+1))}n=I(a(u),n)}return c(n)}})(fe)),fe}var be,re={};function Je(){if(be)return re;be=1;var i=T(),r=Object.prototype.hasOwnProperty,s=typeof Map<"u";function g(){this._array=[],this._set=s?new Map:Object.create(null)}return g.fromArray=function(a,t){for(var o=new g,c=0,I=a.length;c<I;c++)o.add(a[c],t);return o},g.prototype.size=function(){return s?this._set.size:Object.getOwnPropertyNames(this._set).length},g.prototype.add=function(a,t){var o=s?a:i.toSetString(a),c=s?this.has(a):r.call(this._set,o),I=this._array.length;c&&!t||this._array.push(a),c||(s?this._set.set(a,I):this._set[o]=I)},g.prototype.has=function(a){if(s)return this._set.has(a);var t=i.toSetString(a);return r.call(this._set,t)},g.prototype.indexOf=function(a){if(s){var t=this._set.get(a);if(t>=0)return t}else{var o=i.toSetString(a);if(r.call(this._set,o))return this._set[o]}throw new Error('"'+a+'" is not in the set.')},g.prototype.at=function(a){if(a>=0&&a<this._array.length)return this._array[a];throw new Error("No element indexed by "+a)},g.prototype.toArray=function(){return this._array.slice()},re.ArraySet=g,re}var ye,ve,oe={};function Qe(){if(ye)return oe;ye=1;var i=T();function r(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}return r.prototype.unsortedForEach=function(s,g){this._array.forEach(s,g)},r.prototype.add=function(s){var g,a,t,o,c,I;g=this._last,a=s,t=g.generatedLine,o=a.generatedLine,c=g.generatedColumn,I=a.generatedColumn,o>t||o==t&&I>=c||i.compareByGeneratedPositionsInflated(g,a)<=0?(this._last=s,this._array.push(s)):(this._sorted=!1,this._array.push(s))},r.prototype.toArray=function(){return this._sorted||(this._array.sort(i.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},oe.MappingList=r,oe}function Se(){if(ve)return ne;ve=1;var i=Xe(),r=T(),s=Je().ArraySet,g=Qe().MappingList;function a(t){t||(t={}),this._file=r.getArg(t,"file",null),this._sourceRoot=r.getArg(t,"sourceRoot",null),this._skipValidation=r.getArg(t,"skipValidation",!1),this._ignoreInvalidMapping=r.getArg(t,"ignoreInvalidMapping",!1),this._sources=new s,this._names=new s,this._mappings=new g,this._sourcesContents=null}return a.prototype._version=3,a.fromSourceMap=function(t,o){var c=t.sourceRoot,I=new a(Object.assign(o||{},{file:t.file,sourceRoot:c}));return t.eachMapping(function(p){var C={generated:{line:p.generatedLine,column:p.generatedColumn}};p.source!=null&&(C.source=p.source,c!=null&&(C.source=r.relative(c,C.source)),C.original={line:p.originalLine,column:p.originalColumn},p.name!=null&&(C.name=p.name)),I.addMapping(C)}),t.sources.forEach(function(p){var C=p;c!==null&&(C=r.relative(c,p)),I._sources.has(C)||I._sources.add(C);var l=t.sourceContentFor(p);l!=null&&I.setSourceContent(p,l)}),I},a.prototype.addMapping=function(t){var o=r.getArg(t,"generated"),c=r.getArg(t,"original",null),I=r.getArg(t,"source",null),p=r.getArg(t,"name",null);(this._skipValidation||this._validateMapping(o,c,I,p)!==!1)&&(I!=null&&(I=String(I),this._sources.has(I)||this._sources.add(I)),p!=null&&(p=String(p),this._names.has(p)||this._names.add(p)),this._mappings.add({generatedLine:o.line,generatedColumn:o.column,originalLine:c!=null&&c.line,originalColumn:c!=null&&c.column,source:I,name:p}))},a.prototype.setSourceContent=function(t,o){var c=t;this._sourceRoot!=null&&(c=r.relative(this._sourceRoot,c)),o!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[r.toSetString(c)]=o):this._sourcesContents&&(delete this._sourcesContents[r.toSetString(c)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},a.prototype.applySourceMap=function(t,o,c){var I=o;if(o==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);I=t.file}var p=this._sourceRoot;p!=null&&(I=r.relative(p,I));var C=new s,l=new s;this._mappings.unsortedForEach(function(d){if(d.source===I&&d.originalLine!=null){var e=t.originalPositionFor({line:d.originalLine,column:d.originalColumn});e.source!=null&&(d.source=e.source,c!=null&&(d.source=r.join(c,d.source)),p!=null&&(d.source=r.relative(p,d.source)),d.originalLine=e.line,d.originalColumn=e.column,e.name!=null&&(d.name=e.name))}var n=d.source;n==null||C.has(n)||C.add(n);var h=d.name;h==null||l.has(h)||l.add(h)},this),this._sources=C,this._names=l,t.sources.forEach(function(d){var e=t.sourceContentFor(d);e!=null&&(c!=null&&(d=r.join(c,d)),p!=null&&(d=r.relative(p,d)),this.setSourceContent(d,e))},this)},a.prototype._validateMapping=function(t,o,c,I){if(o&&typeof o.line!="number"&&typeof o.column!="number"){var p="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(p),!1;throw new Error(p)}if((!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0)||o||c||I)&&!(t&&"line"in t&&"column"in t&&o&&"line"in o&&"column"in o&&t.line>0&&t.column>=0&&o.line>0&&o.column>=0&&c)){if(p="Invalid mapping: "+JSON.stringify({generated:t,source:c,original:o,name:I}),this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(p),!1;throw new Error(p)}},a.prototype._serializeMappings=function(){for(var t,o,c,I,p=0,C=1,l=0,d=0,e=0,n=0,h="",u=this._mappings.toArray(),m=0,f=u.length;m<f;m++){if(t="",(o=u[m]).generatedLine!==C)for(p=0;o.generatedLine!==C;)t+=";",C++;else if(m>0){if(!r.compareByGeneratedPositionsInflated(o,u[m-1]))continue;t+=","}t+=i.encode(o.generatedColumn-p),p=o.generatedColumn,o.source!=null&&(I=this._sources.indexOf(o.source),t+=i.encode(I-n),n=I,t+=i.encode(o.originalLine-1-d),d=o.originalLine-1,t+=i.encode(o.originalColumn-l),l=o.originalColumn,o.name!=null&&(c=this._names.indexOf(o.name),t+=i.encode(c-e),e=c)),h+=t}return h},a.prototype._generateSourcesContent=function(t,o){return t.map(function(c){if(!this._sourcesContents)return null;o!=null&&(c=r.relative(o,c));var I=r.toSetString(c);return Object.prototype.hasOwnProperty.call(this._sourcesContents,I)?this._sourcesContents[I]:null},this)},a.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t},a.prototype.toString=function(){return JSON.stringify(this.toJSON())},ne.SourceMapGenerator=a,ne}var Ge,U={},Ze={};function qe(){return Ge||(Ge=1,(function(i){function r(s,g,a,t,o,c){var I=Math.floor((g-s)/2)+s,p=o(a,t[I],!0);return p===0?I:p>0?g-I>1?r(I,g,a,t,o,c):c==i.LEAST_UPPER_BOUND?g<t.length?g:-1:I:I-s>1?r(s,I,a,t,o,c):c==i.LEAST_UPPER_BOUND?I:s<0?-1:s}i.GREATEST_LOWER_BOUND=1,i.LEAST_UPPER_BOUND=2,i.search=function(s,g,a,t){if(g.length===0)return-1;var o=r(-1,g.length,s,g,a,t||i.GREATEST_LOWER_BOUND);if(o<0)return-1;for(;o-1>=0&&a(g[o],g[o-1],!0)===0;)--o;return o}})(Ze)),Ze}var Be,We,ie={};function et(){if(Be)return ie;function i(s){function g(a,t,o){var c=a[t];a[t]=a[o],a[o]=c}return function a(t,o,c,I){if(c<I){var p=c-1;g(t,(e=c,n=I,Math.round(e+Math.random()*(n-e))),I);for(var C=t[I],l=c;l<I;l++)o(t[l],C,!1)<=0&&g(t,p+=1,l);g(t,p+1,l);var d=p+1;a(t,o,c,d-1),a(t,o,d+1,I)}var e,n}}Be=1;let r=new WeakMap;return ie.quickSort=function(s,g,a=0){let t=r.get(g);t===void 0&&(t=(function(o){let c=i.toString();return new Function(`return ${c}`)()(o)})(g),r.set(g,t)),t(s,g,a,s.length-1)},ie}var we,Ne,se={},Ee=(Ne||(Ne=1,z.SourceMapGenerator=Se().SourceMapGenerator,z.SourceMapConsumer=(function(){if(We)return U;We=1;var i=T(),r=qe(),s=Je().ArraySet,g=Xe(),a=et().quickSort;function t(l,d){var e=l;return typeof l=="string"&&(e=i.parseSourceMapInput(l)),e.sections!=null?new C(e,d):new o(e,d)}function o(l,d){var e=l;typeof l=="string"&&(e=i.parseSourceMapInput(l));var n=i.getArg(e,"version"),h=i.getArg(e,"sources"),u=i.getArg(e,"names",[]),m=i.getArg(e,"sourceRoot",null),f=i.getArg(e,"sourcesContent",null),b=i.getArg(e,"mappings"),v=i.getArg(e,"file",null);if(n!=this._version)throw new Error("Unsupported version: "+n);m&&(m=i.normalize(m)),h=h.map(String).map(i.normalize).map(function(S){return m&&i.isAbsolute(m)&&i.isAbsolute(S)?i.relative(m,S):S}),this._names=s.fromArray(u.map(String),!0),this._sources=s.fromArray(h,!0),this._absoluteSources=this._sources.toArray().map(function(S){return i.computeSourceURL(m,S,d)}),this.sourceRoot=m,this.sourcesContent=f,this._mappings=b,this._sourceMapURL=d,this.file=v}function c(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}t.fromSourceMap=function(l,d){return o.fromSourceMap(l,d)},t.prototype._version=3,t.prototype.__generatedMappings=null,Object.defineProperty(t.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),t.prototype.__originalMappings=null,Object.defineProperty(t.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),t.prototype._charIsMappingSeparator=function(l,d){var e=l.charAt(d);return e===";"||e===","},t.prototype._parseMappings=function(l,d){throw new Error("Subclasses must implement _parseMappings")},t.GENERATED_ORDER=1,t.ORIGINAL_ORDER=2,t.GREATEST_LOWER_BOUND=1,t.LEAST_UPPER_BOUND=2,t.prototype.eachMapping=function(l,d,e){var n,h=d||null;switch(e||t.GENERATED_ORDER){case t.GENERATED_ORDER:n=this._generatedMappings;break;case t.ORIGINAL_ORDER:n=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}for(var u=this.sourceRoot,m=l.bind(h),f=this._names,b=this._sources,v=this._sourceMapURL,S=0,B=n.length;S<B;S++){var W=n[S],Z=W.source===null?null:b.at(W.source);Z!==null&&(Z=i.computeSourceURL(u,Z,v)),m({source:Z,generatedLine:W.generatedLine,generatedColumn:W.generatedColumn,originalLine:W.originalLine,originalColumn:W.originalColumn,name:W.name===null?null:f.at(W.name)})}},t.prototype.allGeneratedPositionsFor=function(l){var d=i.getArg(l,"line"),e={source:i.getArg(l,"source"),originalLine:d,originalColumn:i.getArg(l,"column",0)};if(e.source=this._findSourceIndex(e.source),e.source<0)return[];var n=[],h=this._findMapping(e,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions,r.LEAST_UPPER_BOUND);if(h>=0){var u=this._originalMappings[h];if(l.column===void 0)for(var m=u.originalLine;u&&u.originalLine===m;)n.push({line:i.getArg(u,"generatedLine",null),column:i.getArg(u,"generatedColumn",null),lastColumn:i.getArg(u,"lastGeneratedColumn",null)}),u=this._originalMappings[++h];else for(var f=u.originalColumn;u&&u.originalLine===d&&u.originalColumn==f;)n.push({line:i.getArg(u,"generatedLine",null),column:i.getArg(u,"generatedColumn",null),lastColumn:i.getArg(u,"lastGeneratedColumn",null)}),u=this._originalMappings[++h]}return n},U.SourceMapConsumer=t,o.prototype=Object.create(t.prototype),o.prototype.consumer=t,o.prototype._findSourceIndex=function(l){var d,e=l;if(this.sourceRoot!=null&&(e=i.relative(this.sourceRoot,e)),this._sources.has(e))return this._sources.indexOf(e);for(d=0;d<this._absoluteSources.length;++d)if(this._absoluteSources[d]==l)return d;return-1},o.fromSourceMap=function(l,d){var e=Object.create(o.prototype),n=e._names=s.fromArray(l._names.toArray(),!0),h=e._sources=s.fromArray(l._sources.toArray(),!0);e.sourceRoot=l._sourceRoot,e.sourcesContent=l._generateSourcesContent(e._sources.toArray(),e.sourceRoot),e.file=l._file,e._sourceMapURL=d,e._absoluteSources=e._sources.toArray().map(function(W){return i.computeSourceURL(e.sourceRoot,W,d)});for(var u=l._mappings.toArray().slice(),m=e.__generatedMappings=[],f=e.__originalMappings=[],b=0,v=u.length;b<v;b++){var S=u[b],B=new c;B.generatedLine=S.generatedLine,B.generatedColumn=S.generatedColumn,S.source&&(B.source=h.indexOf(S.source),B.originalLine=S.originalLine,B.originalColumn=S.originalColumn,S.name&&(B.name=n.indexOf(S.name)),f.push(B)),m.push(B)}return a(e.__originalMappings,i.compareByOriginalPositions),e},o.prototype._version=3,Object.defineProperty(o.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});const I=i.compareByGeneratedPositionsDeflatedNoLine;function p(l,d){let e=l.length,n=l.length-d;if(!(n<=1))if(n==2){let h=l[d],u=l[d+1];I(h,u)>0&&(l[d]=u,l[d+1]=h)}else if(n<20)for(let h=d;h<e;h++)for(let u=h;u>d;u--){let m=l[u-1],f=l[u];if(I(m,f)<=0)break;l[u-1]=f,l[u]=m}else a(l,I,d)}function C(l,d){var e=l;typeof l=="string"&&(e=i.parseSourceMapInput(l));var n=i.getArg(e,"version"),h=i.getArg(e,"sections");if(n!=this._version)throw new Error("Unsupported version: "+n);this._sources=new s,this._names=new s;var u={line:-1,column:0};this._sections=h.map(function(m){if(m.url)throw new Error("Support for url field in sections not implemented.");var f=i.getArg(m,"offset"),b=i.getArg(f,"line"),v=i.getArg(f,"column");if(b<u.line||b===u.line&&v<u.column)throw new Error("Section offsets must be ordered and non-overlapping.");return u=f,{generatedOffset:{generatedLine:b+1,generatedColumn:v+1},consumer:new t(i.getArg(m,"map"),d)}})}return o.prototype._parseMappings=function(l,d){var e,n,h,u,m=1,f=0,b=0,v=0,S=0,B=0,W=l.length,Z=0,Q={},N=[],Y=[];let q=0;for(;Z<W;)if(l.charAt(Z)===";")m++,Z++,f=0,p(Y,q),q=Y.length;else if(l.charAt(Z)===",")Z++;else{for((e=new c).generatedLine=m,h=Z;h<W&&!this._charIsMappingSeparator(l,h);h++);for(l.slice(Z,h),n=[];Z<h;)g.decode(l,Z,Q),u=Q.value,Z=Q.rest,n.push(u);if(n.length===2)throw new Error("Found a source, but no line and column");if(n.length===3)throw new Error("Found a source and line, but no column");if(e.generatedColumn=f+n[0],f=e.generatedColumn,n.length>1&&(e.source=S+n[1],S+=n[1],e.originalLine=b+n[2],b=e.originalLine,e.originalLine+=1,e.originalColumn=v+n[3],v=e.originalColumn,n.length>4&&(e.name=B+n[4],B+=n[4])),Y.push(e),typeof e.originalLine=="number"){let x=e.source;for(;N.length<=x;)N.push(null);N[x]===null&&(N[x]=[]),N[x].push(e)}}p(Y,q),this.__generatedMappings=Y;for(var D=0;D<N.length;D++)N[D]!=null&&a(N[D],i.compareByOriginalPositionsNoSource);this.__originalMappings=[].concat(...N)},o.prototype._findMapping=function(l,d,e,n,h,u){if(l[e]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+l[e]);if(l[n]<0)throw new TypeError("Column must be greater than or equal to 0, got "+l[n]);return r.search(l,d,h,u)},o.prototype.computeColumnSpans=function(){for(var l=0;l<this._generatedMappings.length;++l){var d=this._generatedMappings[l];if(l+1<this._generatedMappings.length){var e=this._generatedMappings[l+1];if(d.generatedLine===e.generatedLine){d.lastGeneratedColumn=e.generatedColumn-1;continue}}d.lastGeneratedColumn=1/0}},o.prototype.originalPositionFor=function(l){var d={generatedLine:i.getArg(l,"line"),generatedColumn:i.getArg(l,"column")},e=this._findMapping(d,this._generatedMappings,"generatedLine","generatedColumn",i.compareByGeneratedPositionsDeflated,i.getArg(l,"bias",t.GREATEST_LOWER_BOUND));if(e>=0){var n=this._generatedMappings[e];if(n.generatedLine===d.generatedLine){var h=i.getArg(n,"source",null);h!==null&&(h=this._sources.at(h),h=i.computeSourceURL(this.sourceRoot,h,this._sourceMapURL));var u=i.getArg(n,"name",null);return u!==null&&(u=this._names.at(u)),{source:h,line:i.getArg(n,"originalLine",null),column:i.getArg(n,"originalColumn",null),name:u}}}return{source:null,line:null,column:null,name:null}},o.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(l){return l==null})},o.prototype.sourceContentFor=function(l,d){if(!this.sourcesContent)return null;var e=this._findSourceIndex(l);if(e>=0)return this.sourcesContent[e];var n,h=l;if(this.sourceRoot!=null&&(h=i.relative(this.sourceRoot,h)),this.sourceRoot!=null&&(n=i.urlParse(this.sourceRoot))){var u=h.replace(/^file:\/\//,"");if(n.scheme=="file"&&this._sources.has(u))return this.sourcesContent[this._sources.indexOf(u)];if((!n.path||n.path=="/")&&this._sources.has("/"+h))return this.sourcesContent[this._sources.indexOf("/"+h)]}if(d)return null;throw new Error('"'+h+'" is not in the SourceMap.')},o.prototype.generatedPositionFor=function(l){var d=i.getArg(l,"source");if((d=this._findSourceIndex(d))<0)return{line:null,column:null,lastColumn:null};var e={source:d,originalLine:i.getArg(l,"line"),originalColumn:i.getArg(l,"column")},n=this._findMapping(e,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions,i.getArg(l,"bias",t.GREATEST_LOWER_BOUND));if(n>=0){var h=this._originalMappings[n];if(h.source===e.source)return{line:i.getArg(h,"generatedLine",null),column:i.getArg(h,"generatedColumn",null),lastColumn:i.getArg(h,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},U.BasicSourceMapConsumer=o,C.prototype=Object.create(t.prototype),C.prototype.constructor=t,C.prototype._version=3,Object.defineProperty(C.prototype,"sources",{get:function(){for(var l=[],d=0;d<this._sections.length;d++)for(var e=0;e<this._sections[d].consumer.sources.length;e++)l.push(this._sections[d].consumer.sources[e]);return l}}),C.prototype.originalPositionFor=function(l){var d={generatedLine:i.getArg(l,"line"),generatedColumn:i.getArg(l,"column")},e=r.search(d,this._sections,function(h,u){return h.generatedLine-u.generatedOffset.generatedLine||h.generatedColumn-u.generatedOffset.generatedColumn}),n=this._sections[e];return n?n.consumer.originalPositionFor({line:d.generatedLine-(n.generatedOffset.generatedLine-1),column:d.generatedColumn-(n.generatedOffset.generatedLine===d.generatedLine?n.generatedOffset.generatedColumn-1:0),bias:l.bias}):{source:null,line:null,column:null,name:null}},C.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(l){return l.consumer.hasContentsOfAllSources()})},C.prototype.sourceContentFor=function(l,d){for(var e=0;e<this._sections.length;e++){var n=this._sections[e].consumer.sourceContentFor(l,!0);if(n||n==="")return n}if(d)return null;throw new Error('"'+l+'" is not in the SourceMap.')},C.prototype.generatedPositionFor=function(l){for(var d=0;d<this._sections.length;d++){var e=this._sections[d];if(e.consumer._findSourceIndex(i.getArg(l,"source"))!==-1){var n=e.consumer.generatedPositionFor(l);if(n)return{line:n.line+(e.generatedOffset.generatedLine-1),column:n.column+(e.generatedOffset.generatedLine===n.line?e.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}},C.prototype._parseMappings=function(l,d){this.__generatedMappings=[],this.__originalMappings=[];for(var e=0;e<this._sections.length;e++)for(var n=this._sections[e],h=n.consumer._generatedMappings,u=0;u<h.length;u++){var m=h[u],f=n.consumer._sources.at(m.source);f!==null&&(f=i.computeSourceURL(n.consumer.sourceRoot,f,this._sourceMapURL)),this._sources.add(f),f=this._sources.indexOf(f);var b=null;m.name&&(b=n.consumer._names.at(m.name),this._names.add(b),b=this._names.indexOf(b));var v={source:f,generatedLine:m.generatedLine+(n.generatedOffset.generatedLine-1),generatedColumn:m.generatedColumn+(n.generatedOffset.generatedLine===m.generatedLine?n.generatedOffset.generatedColumn-1:0),originalLine:m.originalLine,originalColumn:m.originalColumn,name:b};this.__generatedMappings.push(v),typeof v.originalLine=="number"&&this.__originalMappings.push(v)}a(this.__generatedMappings,i.compareByGeneratedPositionsDeflated),a(this.__originalMappings,i.compareByOriginalPositions)},U.IndexedSourceMapConsumer=C,U})().SourceMapConsumer,z.SourceNode=(function(){if(we)return se;we=1;var i=Se().SourceMapGenerator,r=T(),s=/(\r?\n)/,g="$$$isSourceNode$$$";function a(t,o,c,I,p){this.children=[],this.sourceContents={},this.line=t??null,this.column=o??null,this.source=c??null,this.name=p??null,this[g]=!0,I!=null&&this.add(I)}return a.fromStringWithSourceMap=function(t,o,c){var I=new a,p=t.split(s),C=0,l=function(){return u()+(u()||"");function u(){return C<p.length?p[C++]:void 0}},d=1,e=0,n=null;return o.eachMapping(function(u){if(n!==null){if(!(d<u.generatedLine)){var m=(f=p[C]||"").substr(0,u.generatedColumn-e);return p[C]=f.substr(u.generatedColumn-e),e=u.generatedColumn,h(n,m),void(n=u)}h(n,l()),d++,e=0}for(;d<u.generatedLine;)I.add(l()),d++;if(e<u.generatedColumn){var f=p[C]||"";I.add(f.substr(0,u.generatedColumn)),p[C]=f.substr(u.generatedColumn),e=u.generatedColumn}n=u},this),C<p.length&&(n&&h(n,l()),I.add(p.splice(C).join(""))),o.sources.forEach(function(u){var m=o.sourceContentFor(u);m!=null&&(c!=null&&(u=r.join(c,u)),I.setSourceContent(u,m))}),I;function h(u,m){if(u===null||u.source===void 0)I.add(m);else{var f=c?r.join(c,u.source):u.source;I.add(new a(u.originalLine,u.originalColumn,f,m,u.name))}}},a.prototype.add=function(t){if(Array.isArray(t))t.forEach(function(o){this.add(o)},this);else{if(!t[g]&&typeof t!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+t);t&&this.children.push(t)}return this},a.prototype.prepend=function(t){if(Array.isArray(t))for(var o=t.length-1;o>=0;o--)this.prepend(t[o]);else{if(!t[g]&&typeof t!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+t);this.children.unshift(t)}return this},a.prototype.walk=function(t){for(var o,c=0,I=this.children.length;c<I;c++)(o=this.children[c])[g]?o.walk(t):o!==""&&t(o,{source:this.source,line:this.line,column:this.column,name:this.name})},a.prototype.join=function(t){var o,c,I=this.children.length;if(I>0){for(o=[],c=0;c<I-1;c++)o.push(this.children[c]),o.push(t);o.push(this.children[c]),this.children=o}return this},a.prototype.replaceRight=function(t,o){var c=this.children[this.children.length-1];return c[g]?c.replaceRight(t,o):typeof c=="string"?this.children[this.children.length-1]=c.replace(t,o):this.children.push("".replace(t,o)),this},a.prototype.setSourceContent=function(t,o){this.sourceContents[r.toSetString(t)]=o},a.prototype.walkSourceContents=function(t){for(var o=0,c=this.children.length;o<c;o++)this.children[o][g]&&this.children[o].walkSourceContents(t);var I=Object.keys(this.sourceContents);for(o=0,c=I.length;o<c;o++)t(r.fromSetString(I[o]),this.sourceContents[I[o]])},a.prototype.toString=function(){var t="";return this.walk(function(o){t+=o}),t},a.prototype.toStringWithSourceMap=function(t){var o={code:"",line:1,column:0},c=new i(t),I=!1,p=null,C=null,l=null,d=null;return this.walk(function(e,n){o.code+=e,n.source!==null&&n.line!==null&&n.column!==null?(p===n.source&&C===n.line&&l===n.column&&d===n.name||c.addMapping({source:n.source,original:{line:n.line,column:n.column},generated:{line:o.line,column:o.column},name:n.name}),p=n.source,C=n.line,l=n.column,d=n.name,I=!0):I&&(c.addMapping({generated:{line:o.line,column:o.column}}),p=null,I=!1);for(var h=0,u=e.length;h<u;h++)e.charCodeAt(h)===10?(o.line++,o.column=0,h+1===u?(p=null,I=!1):I&&c.addMapping({source:n.source,original:{line:n.line,column:n.column},generated:{line:o.line,column:o.column},name:n.name})):o.column++}),this.walkSourceContents(function(e,n){c.setSourceContent(e,n)}),{code:o.code,map:c}},se.SourceNode=a,se})().SourceNode),z);class F{constructor({file:r,line:s,function:g,code:a,locals:t={},offender:o=!1,column:c}){y(this,"file");y(this,"line");y(this,"function");y(this,"code");y(this,"locals");y(this,"offender");y(this,"column");this.file=r,this.line=s,this.function=g,this.code=a,this.locals=t,this.offender=o,this.column=c}toDict(){const r={file:this.file,line:this.line,function:this.function,code:this.code,locals:Object.fromEntries(Object.entries(this.locals).map(([s,g])=>[s,String(g)]))};return this.offender&&(r.offender=this.offender),this.column!==void 0&&(r.column=this.column),r}toJson(){return JSON.stringify(this.toDict())}}class j{static encode(r){return r instanceof F?r.toDict():Array.isArray(r)?r.map(s=>j.encode(s)):typeof r=="object"&&r!==null?JSON.stringify(r):r}static stringify(r){return JSON.stringify(j.encode(r),(s,g)=>g instanceof F?g.toDict():g)}}let X=0;function tt(i){A().sfDebug&&console.log("Initializing Exception Interceptor...");const r=new De.Worker(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5ub2RlTW9kdWxlc1RvQ29sbGVjdExvY2FsVm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lYnVnZ2VyLmdldFNjcmlwdFNvdXJjZSIsCiAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc2NyaXB0SWQsCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgKTsKICAgICAgICAgICAgY29uc3Qgc291cmNlTGluZXMgPSBzY3JpcHRTb3VyY2Uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmt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VNb2R1bGVzTGlzdC5zb21lKChtb2R1bGVOYW1lKSA9PgogICAgICAgICAgZmlyc3RGcmFtZUxpbmUuaW5jbHVkZXMoYCR7bW9kdWxlTmFtZX1gKSwKICAgICAgICApOwoKICAgICAgICBpZiAoIWlzRnJvbUFsbG93ZWROb2RlTW9kdWxlKSB7CiAgICAgICAgICAvLyBOb3QgZnJvbSBhbiBhbGxvd2VkIG5vZGUgbW9kdWxlID0+IHJldHVybiBlYXJseQogICAgICAgICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgICAgICAgIGNvbnNvbGUubG9nKAogICAgICAgICAgICAgICJbV29ya2VyXSBFcnJvciBhcHBlYXJzIHRvIGJlIHRyaWdnZXJlZCBmcm9tIG5vbi1hcHBsaWNhdGlvbiBzb3VyY2VzOyBpZ25vcmluZy4iLAogICAgICAgICAgICApOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICAvLyBPdGhlcndpc2UsIGl0J3MgZnJvbSBhbiBhbGxvd2VkIG5vZGUgbW9kdWxlLCBzbyBjb250aW51ZQogICAgICB9IGVsc2UgewogICAgICAgIC8vIElmIHRoZSBsaXN0IGlzIGVtcHR5LCBwcmVzZXJ2ZSBleGlzdGluZyBiZWhhdmlvciBhbmQgaWdub3JlIG5vbi1hcHBsaWNhdGlvbiBlcnJvcnMKICAgICAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgICAgIGNvbnNvbGUubG9nKAogICAgICAgICAgICAiW1dvcmtlcl0gRXJyb3IgYXBwZWFycyB0byBiZSB0cmlnZ2VyZWQgZnJvbSBub24tYXBwbGljYXRpb24gc291cmNlczsgaWdub3JpbmcuIiwKICAgICAgICAgICk7CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgfQoKICAgIC8vIElmIHdlIHJlYWNoIHRoaXMgcG9pbnQsIHRoZSBlcnJvciBpcyBlaXRoZXIgZnJvbSBhcHAgY29kZSwgb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S5jYXRjaCgoZXJyb3IpID0+IHsKICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlcjoiLCBlcnJvcik7CiAgfQp9KTsKCi8vIEtlZXAgdGhlIHdvcmtlciBhbGl2ZQpzZXRJbnRlcnZhbCgoKSA9PiB7fSwgMTAwMDApOwo="),{workerData:{captureAllExceptions:!0}});let s=null;const g=new WeakMap;r.on("message",c=>{if(typeof c=="string"&&A().sfDebug&&console.log(`[Worker] ${c}`),c.readyToGetParameters&&r.postMessage({sfDebug:A().sfDebug,stackDepthLocals:A().stackDepthLocals,nodeModulesToCollectLocalVariablesOn:A().nodeModulesToCollectLocalVariablesOn}),c.type==="exception"){const{frames:I}=c,p=s;if(!p)return;const C=g.get(p),l=(function(e){return e?e.split(`
34
- `).slice(1).map(n=>{const h=/at (.+?) \((.+):(\d+):(\d+)\)/.exec(n)||/at (.+):(\d+):(\d+)/.exec(n);if(h){const[,u,m,f,b]=h;return new F({function:u||"<anonymous>",locals:{},file:m||"<unknown>",line:parseInt(f,10)||0,code:"<not captured>",column:parseInt(b)||0})}return new F({function:"<unknown>",locals:{},file:"<unknown>",line:0,code:"<not captured>",column:0})}):[]})(p.stack),d=(function(e,n){const h=[];let u=-1,m=-1;for(let f=0;f<e.length;f++){const b=rt(e[f].file);if(m=f,b!=="<unknown>"){for(let v=0;v<n.length;v++){const S=n[v];if(Fe(S,b)||typeof S.file=="string"&&S.file.includes(b)){u=v,X=0,A().sfDebug&&console.log(`✅ Matched Frame Found: ${b} @ Debugger Frame ${v}`);break}}if(u!==-1)break}}if(u===-1)return X===10?(X=0,e):(++X,A().sfDebug&&console.log(`"❌ No matching frame found. Checking once again, Attempt N ${X}"`),[]);A().sfDebug&&console.log(`🔄 Merging from matched index ${u} onward...`);for(let f=0;f<n.length;f++){const b=e[m+f],v=n[u+f];h.push(new F({function:v?.function||b?.function||"<anonymous>",locals:v?.locals||b?.locals||{},file:b?.file||v?.file||"<unknown>",line:v?.line||b?.line||0,code:v?.code||b?.code||"<not captured>"}))}return h})(l,I||[]);if(d.length!==0){s=null;const e=A().stackDepthCodeTraceDepth,n=e===-1?d:d.slice(0,e+1),h=Math.min(n.length,l.length);for(let b=0;b<h;b++)(async()=>{const v=nt(n[b].file,l[b].line,l[b].column);v&&(v.content!=null&&(n[b].code=v.content),v.file!=null&&(n[b].file=v.file))})();i.setOperationName("CollectExceptions");const u=p.message?`${p.name}: ${p.message}`:p.name;A().sfDebug&&console.log("error message is : ",u);const m=w.getInstance(),f=g.get(p);f?(m.setTraceIdFor(f,f),m.runWithSession(f,()=>{m.setTraceId(f),i.doSend(u,n)})):i.doSend(u,n),C?w.getInstance().runWithSession(C,()=>{i.doSend(u,n)}):i.doSend(u,n)}}}),r.on("error",c=>{console.error("[Worker Error]",c)}),r.on("exit",c=>{console.error(`[Worker] Exited with code ${c}`)}),r.unref();const a=Error,t=new Set;function o(...c){const I=Reflect.construct(a,c);Reflect.setPrototypeOf(I,o.prototype);try{const C=w.getInstance().getTraceId();g.set(I,C)}catch{}a.captureStackTrace&&a.captureStackTrace(I,o);const p=`${I.message}:${I.stack?.split(`
35
- `)[1]?.trim()}`;if(!t.has(p)){t.add(p),s=I;const C=w.getInstance().getTraceId();g.set(I,C),r.postMessage({type:"processException",error:I.message})}return I}o.prototype=Object.create(a.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf(o,a),globalThis.Error=o}function Ve(i){return i=(i=(i=i.replace(/^webpack:\/\/[^\/]+\/\.?\//,"")).replace(/^.*\/pages\//,"pages/")).replace(/\.(js|ts)$/,"")}function nt(i,r,s){const g=(function(t){t.startsWith("at ")&&(t=t.slice(3).trim());const o=t.match(/^(.*?)(:\d+)+(\.map)?$/);return o?o[1]:t})(i);if(!g||g==="<unknown>")return null;const a=g+".map";try{const t=Le.readFileSync(a,"utf-8");if(t){const o=JSON.parse(t);let c=new Ee.SourceMapConsumer(o).originalPositionFor({line:r,column:s});if(g&&c.source){const I=Ve(g),p=o.sources.findIndex(C=>Ve(C)===I);if(p===-1)A().sfDebug&&console.log(`Source file "${g}" not found in the source map.`);else{const C=o.sourcesContent[p],l=o.names.join(",");if(C)return{content:C.split(`
33
+ `}}const N={};var Ae,fe,k={},re={},$={},P={};function nn(){if(Ae)return P;Ae=1;var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return P.encode=function(t){if(0<=t&&t<i.length)return i[t];throw new TypeError("Must be between 0 and 63: "+t)},P.decode=function(t){return 65<=t&&t<=90?t-65:97<=t&&t<=122?t-97+26:48<=t&&t<=57?t-48+52:t==43?62:t==47?63:-1},P}function Je(){if(fe)return $;fe=1;var i=nn();return $.encode=function(t){var s,l="",a=(function(n){return n<0?1+(-n<<1):0+(n<<1)})(t);do s=31&a,(a>>>=5)>0&&(s|=32),l+=i.encode(s);while(a>0);return l},$.decode=function(t,s,l){var a,n,o,c,d=t.length,p=0,C=0;do{if(s>=d)throw new Error("Expected more digits in base 64 VLQ value.");if((n=i.decode(t.charCodeAt(s++)))===-1)throw new Error("Invalid base64 digit: "+t.charAt(s-1));a=!!(32&n),p+=(n&=31)<<C,C+=5}while(a);l.value=(c=(o=p)>>1,1&~o?c:-c),l.rest=s},$}var be,ye={};function M(){return be||(be=1,(function(i){i.getArg=function(e,r,h){if(r in e)return e[r];if(arguments.length===3)return h;throw new Error('"'+r+'" is a required argument.')};var t=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,s=/^data:.+\,.+$/;function l(e){var r=e.match(t);return r?{scheme:r[1],auth:r[2],host:r[3],port:r[4],path:r[5]}:null}function a(e){var r="";return e.scheme&&(r+=e.scheme+":"),r+="//",e.auth&&(r+=e.auth+"@"),e.host&&(r+=e.host),e.port&&(r+=":"+e.port),e.path&&(r+=e.path),r}i.urlParse=l,i.urlGenerate=a;var n,o,c=(n=function(e){var r=e,h=l(e);if(h){if(!h.path)return e;r=h.path}for(var u=i.isAbsolute(r),m=[],f=0,b=0;;){if(f=b,(b=r.indexOf("/",f))===-1){m.push(r.slice(f));break}for(m.push(r.slice(f,b));b<r.length&&r[b]==="/";)b++}var v,S=0;for(b=m.length-1;b>=0;b--)(v=m[b])==="."?m.splice(b,1):v===".."?S++:S>0&&(v===""?(m.splice(b+1,S),S=0):(m.splice(b,2),S--));return(r=m.join("/"))===""&&(r=u?"/":"."),h?(h.path=r,a(h)):r},o=[],function(e){for(var r=0;r<o.length;r++)if(o[r].input===e){var h=o[0];return o[0]=o[r],o[r]=h,o[0].result}var u=n(e);return o.unshift({input:e,result:u}),o.length>32&&o.pop(),u});function d(e,r){e===""&&(e="."),r===""&&(r=".");var h=l(r),u=l(e);if(u&&(e=u.path||"/"),h&&!h.scheme)return u&&(h.scheme=u.scheme),a(h);if(h||r.match(s))return r;if(u&&!u.host&&!u.path)return u.host=r,a(u);var m=r.charAt(0)==="/"?r:c(e.replace(/\/+$/,"")+"/"+r);return u?(u.path=m,a(u)):m}i.normalize=c,i.join=d,i.isAbsolute=function(e){return e.charAt(0)==="/"||t.test(e)},i.relative=function(e,r){e===""&&(e="."),e=e.replace(/\/$/,"");for(var h=0;r.indexOf(e+"/")!==0;){var u=e.lastIndexOf("/");if(u<0||(e=e.slice(0,u)).match(/^([^\/]+:\/)?\/*$/))return r;++h}return Array(h+1).join("../")+r.substr(e.length+1)};var p=!("__proto__"in Object.create(null));function C(e){return e}function g(e){if(!e)return!1;var r=e.length;if(r<9||e.charCodeAt(r-1)!==95||e.charCodeAt(r-2)!==95||e.charCodeAt(r-3)!==111||e.charCodeAt(r-4)!==116||e.charCodeAt(r-5)!==111||e.charCodeAt(r-6)!==114||e.charCodeAt(r-7)!==112||e.charCodeAt(r-8)!==95||e.charCodeAt(r-9)!==95)return!1;for(var h=r-10;h>=0;h--)if(e.charCodeAt(h)!==36)return!1;return!0}function I(e,r){return e===r?0:e===null?1:r===null?-1:e>r?1:-1}i.toSetString=p?C:function(e){return g(e)?"$"+e:e},i.fromSetString=p?C:function(e){return g(e)?e.slice(1):e},i.compareByOriginalPositions=function(e,r,h){var u=I(e.source,r.source);return u!==0||(u=e.originalLine-r.originalLine)!==0||(u=e.originalColumn-r.originalColumn)!==0||h||(u=e.generatedColumn-r.generatedColumn)!==0||(u=e.generatedLine-r.generatedLine)!==0?u:I(e.name,r.name)},i.compareByOriginalPositionsNoSource=function(e,r,h){var u;return(u=e.originalLine-r.originalLine)!==0||(u=e.originalColumn-r.originalColumn)!==0||h||(u=e.generatedColumn-r.generatedColumn)!==0||(u=e.generatedLine-r.generatedLine)!==0?u:I(e.name,r.name)},i.compareByGeneratedPositionsDeflated=function(e,r,h){var u=e.generatedLine-r.generatedLine;return u!==0||(u=e.generatedColumn-r.generatedColumn)!==0||h||(u=I(e.source,r.source))!==0||(u=e.originalLine-r.originalLine)!==0||(u=e.originalColumn-r.originalColumn)!==0?u:I(e.name,r.name)},i.compareByGeneratedPositionsDeflatedNoLine=function(e,r,h){var u=e.generatedColumn-r.generatedColumn;return u!==0||h||(u=I(e.source,r.source))!==0||(u=e.originalLine-r.originalLine)!==0||(u=e.originalColumn-r.originalColumn)!==0?u:I(e.name,r.name)},i.compareByGeneratedPositionsInflated=function(e,r){var h=e.generatedLine-r.generatedLine;return h!==0||(h=e.generatedColumn-r.generatedColumn)!==0||(h=I(e.source,r.source))!==0||(h=e.originalLine-r.originalLine)!==0||(h=e.originalColumn-r.originalColumn)!==0?h:I(e.name,r.name)},i.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},i.computeSourceURL=function(e,r,h){if(r=r||"",e&&(e[e.length-1]!=="/"&&r[0]!=="/"&&(e+="/"),r=e+r),h){var u=l(h);if(!u)throw new Error("sourceMapURL could not be parsed");if(u.path){var m=u.path.lastIndexOf("/");m>=0&&(u.path=u.path.substring(0,m+1))}r=d(a(u),r)}return c(r)}})(ye)),ye}var ve,oe={};function Me(){if(ve)return oe;ve=1;var i=M(),t=Object.prototype.hasOwnProperty,s=typeof Map<"u";function l(){this._array=[],this._set=s?new Map:Object.create(null)}return l.fromArray=function(a,n){for(var o=new l,c=0,d=a.length;c<d;c++)o.add(a[c],n);return o},l.prototype.size=function(){return s?this._set.size:Object.getOwnPropertyNames(this._set).length},l.prototype.add=function(a,n){var o=s?a:i.toSetString(a),c=s?this.has(a):t.call(this._set,o),d=this._array.length;c&&!n||this._array.push(a),c||(s?this._set.set(a,d):this._set[o]=d)},l.prototype.has=function(a){if(s)return this._set.has(a);var n=i.toSetString(a);return t.call(this._set,n)},l.prototype.indexOf=function(a){if(s){var n=this._set.get(a);if(n>=0)return n}else{var o=i.toSetString(a);if(t.call(this._set,o))return this._set[o]}throw new Error('"'+a+'" is not in the set.')},l.prototype.at=function(a){if(a>=0&&a<this._array.length)return this._array[a];throw new Error("No element indexed by "+a)},l.prototype.toArray=function(){return this._array.slice()},oe.ArraySet=l,oe}var Se,Ge,ie={};function tn(){if(Se)return ie;Se=1;var i=M();function t(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}return t.prototype.unsortedForEach=function(s,l){this._array.forEach(s,l)},t.prototype.add=function(s){var l,a,n,o,c,d;l=this._last,a=s,n=l.generatedLine,o=a.generatedLine,c=l.generatedColumn,d=a.generatedColumn,o>n||o==n&&d>=c||i.compareByGeneratedPositionsInflated(l,a)<=0?(this._last=s,this._array.push(s)):(this._sorted=!1,this._array.push(s))},t.prototype.toArray=function(){return this._sorted||(this._array.sort(i.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},ie.MappingList=t,ie}function Ze(){if(Ge)return re;Ge=1;var i=Je(),t=M(),s=Me().ArraySet,l=tn().MappingList;function a(n){n||(n={}),this._file=t.getArg(n,"file",null),this._sourceRoot=t.getArg(n,"sourceRoot",null),this._skipValidation=t.getArg(n,"skipValidation",!1),this._ignoreInvalidMapping=t.getArg(n,"ignoreInvalidMapping",!1),this._sources=new s,this._names=new s,this._mappings=new l,this._sourcesContents=null}return a.prototype._version=3,a.fromSourceMap=function(n,o){var c=n.sourceRoot,d=new a(Object.assign(o||{},{file:n.file,sourceRoot:c}));return n.eachMapping(function(p){var C={generated:{line:p.generatedLine,column:p.generatedColumn}};p.source!=null&&(C.source=p.source,c!=null&&(C.source=t.relative(c,C.source)),C.original={line:p.originalLine,column:p.originalColumn},p.name!=null&&(C.name=p.name)),d.addMapping(C)}),n.sources.forEach(function(p){var C=p;c!==null&&(C=t.relative(c,p)),d._sources.has(C)||d._sources.add(C);var g=n.sourceContentFor(p);g!=null&&d.setSourceContent(p,g)}),d},a.prototype.addMapping=function(n){var o=t.getArg(n,"generated"),c=t.getArg(n,"original",null),d=t.getArg(n,"source",null),p=t.getArg(n,"name",null);(this._skipValidation||this._validateMapping(o,c,d,p)!==!1)&&(d!=null&&(d=String(d),this._sources.has(d)||this._sources.add(d)),p!=null&&(p=String(p),this._names.has(p)||this._names.add(p)),this._mappings.add({generatedLine:o.line,generatedColumn:o.column,originalLine:c!=null&&c.line,originalColumn:c!=null&&c.column,source:d,name:p}))},a.prototype.setSourceContent=function(n,o){var c=n;this._sourceRoot!=null&&(c=t.relative(this._sourceRoot,c)),o!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[t.toSetString(c)]=o):this._sourcesContents&&(delete this._sourcesContents[t.toSetString(c)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))},a.prototype.applySourceMap=function(n,o,c){var d=o;if(o==null){if(n.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);d=n.file}var p=this._sourceRoot;p!=null&&(d=t.relative(p,d));var C=new s,g=new s;this._mappings.unsortedForEach(function(I){if(I.source===d&&I.originalLine!=null){var e=n.originalPositionFor({line:I.originalLine,column:I.originalColumn});e.source!=null&&(I.source=e.source,c!=null&&(I.source=t.join(c,I.source)),p!=null&&(I.source=t.relative(p,I.source)),I.originalLine=e.line,I.originalColumn=e.column,e.name!=null&&(I.name=e.name))}var r=I.source;r==null||C.has(r)||C.add(r);var h=I.name;h==null||g.has(h)||g.add(h)},this),this._sources=C,this._names=g,n.sources.forEach(function(I){var e=n.sourceContentFor(I);e!=null&&(c!=null&&(I=t.join(c,I)),p!=null&&(I=t.relative(p,I)),this.setSourceContent(I,e))},this)},a.prototype._validateMapping=function(n,o,c,d){if(o&&typeof o.line!="number"&&typeof o.column!="number"){var p="original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";if(this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(p),!1;throw new Error(p)}if((!(n&&"line"in n&&"column"in n&&n.line>0&&n.column>=0)||o||c||d)&&!(n&&"line"in n&&"column"in n&&o&&"line"in o&&"column"in o&&n.line>0&&n.column>=0&&o.line>0&&o.column>=0&&c)){if(p="Invalid mapping: "+JSON.stringify({generated:n,source:c,original:o,name:d}),this._ignoreInvalidMapping)return typeof console<"u"&&console.warn&&console.warn(p),!1;throw new Error(p)}},a.prototype._serializeMappings=function(){for(var n,o,c,d,p=0,C=1,g=0,I=0,e=0,r=0,h="",u=this._mappings.toArray(),m=0,f=u.length;m<f;m++){if(n="",(o=u[m]).generatedLine!==C)for(p=0;o.generatedLine!==C;)n+=";",C++;else if(m>0){if(!t.compareByGeneratedPositionsInflated(o,u[m-1]))continue;n+=","}n+=i.encode(o.generatedColumn-p),p=o.generatedColumn,o.source!=null&&(d=this._sources.indexOf(o.source),n+=i.encode(d-r),r=d,n+=i.encode(o.originalLine-1-I),I=o.originalLine-1,n+=i.encode(o.originalColumn-g),g=o.originalColumn,o.name!=null&&(c=this._names.indexOf(o.name),n+=i.encode(c-e),e=c)),h+=n}return h},a.prototype._generateSourcesContent=function(n,o){return n.map(function(c){if(!this._sourcesContents)return null;o!=null&&(c=t.relative(o,c));var d=t.toSetString(c);return Object.prototype.hasOwnProperty.call(this._sourcesContents,d)?this._sourcesContents[d]:null},this)},a.prototype.toJSON=function(){var n={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(n.file=this._file),this._sourceRoot!=null&&(n.sourceRoot=this._sourceRoot),this._sourcesContents&&(n.sourcesContent=this._generateSourcesContent(n.sources,n.sourceRoot)),n},a.prototype.toString=function(){return JSON.stringify(this.toJSON())},re.SourceMapGenerator=a,re}var Be,F={},We={};function rn(){return Be||(Be=1,(function(i){function t(s,l,a,n,o,c){var d=Math.floor((l-s)/2)+s,p=o(a,n[d],!0);return p===0?d:p>0?l-d>1?t(d,l,a,n,o,c):c==i.LEAST_UPPER_BOUND?l<n.length?l:-1:d:d-s>1?t(s,d,a,n,o,c):c==i.LEAST_UPPER_BOUND?d:s<0?-1:s}i.GREATEST_LOWER_BOUND=1,i.LEAST_UPPER_BOUND=2,i.search=function(s,l,a,n){if(l.length===0)return-1;var o=t(-1,l.length,s,l,a,n||i.GREATEST_LOWER_BOUND);if(o<0)return-1;for(;o-1>=0&&a(l[o],l[o-1],!0)===0;)--o;return o}})(We)),We}var we,Ne,se={};function on(){if(we)return se;function i(s){function l(a,n,o){var c=a[n];a[n]=a[o],a[o]=c}return function a(n,o,c,d){if(c<d){var p=c-1;l(n,(e=c,r=d,Math.round(e+Math.random()*(r-e))),d);for(var C=n[d],g=c;g<d;g++)o(n[g],C,!1)<=0&&l(n,p+=1,g);l(n,p+1,g);var I=p+1;a(n,o,c,I-1),a(n,o,I+1,d)}var e,r}}we=1;let t=new WeakMap;return se.quickSort=function(s,l,a=0){let n=t.get(l);n===void 0&&(n=(function(o){let c=i.toString();return new Function(`return ${c}`)()(o)})(l),t.set(l,n)),n(s,l,a,s.length-1)},se}var Re,Ve,ae={},De=(Ve||(Ve=1,k.SourceMapGenerator=Ze().SourceMapGenerator,k.SourceMapConsumer=(function(){if(Ne)return F;Ne=1;var i=M(),t=rn(),s=Me().ArraySet,l=Je(),a=on().quickSort;function n(g,I){var e=g;return typeof g=="string"&&(e=i.parseSourceMapInput(g)),e.sections!=null?new C(e,I):new o(e,I)}function o(g,I){var e=g;typeof g=="string"&&(e=i.parseSourceMapInput(g));var r=i.getArg(e,"version"),h=i.getArg(e,"sources"),u=i.getArg(e,"names",[]),m=i.getArg(e,"sourceRoot",null),f=i.getArg(e,"sourcesContent",null),b=i.getArg(e,"mappings"),v=i.getArg(e,"file",null);if(r!=this._version)throw new Error("Unsupported version: "+r);m&&(m=i.normalize(m)),h=h.map(String).map(i.normalize).map(function(S){return m&&i.isAbsolute(m)&&i.isAbsolute(S)?i.relative(m,S):S}),this._names=s.fromArray(u.map(String),!0),this._sources=s.fromArray(h,!0),this._absoluteSources=this._sources.toArray().map(function(S){return i.computeSourceURL(m,S,I)}),this.sourceRoot=m,this.sourcesContent=f,this._mappings=b,this._sourceMapURL=I,this.file=v}function c(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}n.fromSourceMap=function(g,I){return o.fromSourceMap(g,I)},n.prototype._version=3,n.prototype.__generatedMappings=null,Object.defineProperty(n.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),n.prototype.__originalMappings=null,Object.defineProperty(n.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),n.prototype._charIsMappingSeparator=function(g,I){var e=g.charAt(I);return e===";"||e===","},n.prototype._parseMappings=function(g,I){throw new Error("Subclasses must implement _parseMappings")},n.GENERATED_ORDER=1,n.ORIGINAL_ORDER=2,n.GREATEST_LOWER_BOUND=1,n.LEAST_UPPER_BOUND=2,n.prototype.eachMapping=function(g,I,e){var r,h=I||null;switch(e||n.GENERATED_ORDER){case n.GENERATED_ORDER:r=this._generatedMappings;break;case n.ORIGINAL_ORDER:r=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}for(var u=this.sourceRoot,m=g.bind(h),f=this._names,b=this._sources,v=this._sourceMapURL,S=0,B=r.length;S<B;S++){var W=r[S],Z=W.source===null?null:b.at(W.source);Z!==null&&(Z=i.computeSourceURL(u,Z,v)),m({source:Z,generatedLine:W.generatedLine,generatedColumn:W.generatedColumn,originalLine:W.originalLine,originalColumn:W.originalColumn,name:W.name===null?null:f.at(W.name)})}},n.prototype.allGeneratedPositionsFor=function(g){var I=i.getArg(g,"line"),e={source:i.getArg(g,"source"),originalLine:I,originalColumn:i.getArg(g,"column",0)};if(e.source=this._findSourceIndex(e.source),e.source<0)return[];var r=[],h=this._findMapping(e,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions,t.LEAST_UPPER_BOUND);if(h>=0){var u=this._originalMappings[h];if(g.column===void 0)for(var m=u.originalLine;u&&u.originalLine===m;)r.push({line:i.getArg(u,"generatedLine",null),column:i.getArg(u,"generatedColumn",null),lastColumn:i.getArg(u,"lastGeneratedColumn",null)}),u=this._originalMappings[++h];else for(var f=u.originalColumn;u&&u.originalLine===I&&u.originalColumn==f;)r.push({line:i.getArg(u,"generatedLine",null),column:i.getArg(u,"generatedColumn",null),lastColumn:i.getArg(u,"lastGeneratedColumn",null)}),u=this._originalMappings[++h]}return r},F.SourceMapConsumer=n,o.prototype=Object.create(n.prototype),o.prototype.consumer=n,o.prototype._findSourceIndex=function(g){var I,e=g;if(this.sourceRoot!=null&&(e=i.relative(this.sourceRoot,e)),this._sources.has(e))return this._sources.indexOf(e);for(I=0;I<this._absoluteSources.length;++I)if(this._absoluteSources[I]==g)return I;return-1},o.fromSourceMap=function(g,I){var e=Object.create(o.prototype),r=e._names=s.fromArray(g._names.toArray(),!0),h=e._sources=s.fromArray(g._sources.toArray(),!0);e.sourceRoot=g._sourceRoot,e.sourcesContent=g._generateSourcesContent(e._sources.toArray(),e.sourceRoot),e.file=g._file,e._sourceMapURL=I,e._absoluteSources=e._sources.toArray().map(function(W){return i.computeSourceURL(e.sourceRoot,W,I)});for(var u=g._mappings.toArray().slice(),m=e.__generatedMappings=[],f=e.__originalMappings=[],b=0,v=u.length;b<v;b++){var S=u[b],B=new c;B.generatedLine=S.generatedLine,B.generatedColumn=S.generatedColumn,S.source&&(B.source=h.indexOf(S.source),B.originalLine=S.originalLine,B.originalColumn=S.originalColumn,S.name&&(B.name=r.indexOf(S.name)),f.push(B)),m.push(B)}return a(e.__originalMappings,i.compareByOriginalPositions),e},o.prototype._version=3,Object.defineProperty(o.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});const d=i.compareByGeneratedPositionsDeflatedNoLine;function p(g,I){let e=g.length,r=g.length-I;if(!(r<=1))if(r==2){let h=g[I],u=g[I+1];d(h,u)>0&&(g[I]=u,g[I+1]=h)}else if(r<20)for(let h=I;h<e;h++)for(let u=h;u>I;u--){let m=g[u-1],f=g[u];if(d(m,f)<=0)break;g[u-1]=f,g[u]=m}else a(g,d,I)}function C(g,I){var e=g;typeof g=="string"&&(e=i.parseSourceMapInput(g));var r=i.getArg(e,"version"),h=i.getArg(e,"sections");if(r!=this._version)throw new Error("Unsupported version: "+r);this._sources=new s,this._names=new s;var u={line:-1,column:0};this._sections=h.map(function(m){if(m.url)throw new Error("Support for url field in sections not implemented.");var f=i.getArg(m,"offset"),b=i.getArg(f,"line"),v=i.getArg(f,"column");if(b<u.line||b===u.line&&v<u.column)throw new Error("Section offsets must be ordered and non-overlapping.");return u=f,{generatedOffset:{generatedLine:b+1,generatedColumn:v+1},consumer:new n(i.getArg(m,"map"),I)}})}return o.prototype._parseMappings=function(g,I){var e,r,h,u,m=1,f=0,b=0,v=0,S=0,B=0,W=g.length,Z=0,q={},R=[],Y=[];let ee=0;for(;Z<W;)if(g.charAt(Z)===";")m++,Z++,f=0,p(Y,ee),ee=Y.length;else if(g.charAt(Z)===",")Z++;else{for((e=new c).generatedLine=m,h=Z;h<W&&!this._charIsMappingSeparator(g,h);h++);for(g.slice(Z,h),r=[];Z<h;)l.decode(g,Z,q),u=q.value,Z=q.rest,r.push(u);if(r.length===2)throw new Error("Found a source, but no line and column");if(r.length===3)throw new Error("Found a source and line, but no column");if(e.generatedColumn=f+r[0],f=e.generatedColumn,r.length>1&&(e.source=S+r[1],S+=r[1],e.originalLine=b+r[2],b=e.originalLine,e.originalLine+=1,e.originalColumn=v+r[3],v=e.originalColumn,r.length>4&&(e.name=B+r[4],B+=r[4])),Y.push(e),typeof e.originalLine=="number"){let x=e.source;for(;R.length<=x;)R.push(null);R[x]===null&&(R[x]=[]),R[x].push(e)}}p(Y,ee),this.__generatedMappings=Y;for(var O=0;O<R.length;O++)R[O]!=null&&a(R[O],i.compareByOriginalPositionsNoSource);this.__originalMappings=[].concat(...R)},o.prototype._findMapping=function(g,I,e,r,h,u){if(g[e]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+g[e]);if(g[r]<0)throw new TypeError("Column must be greater than or equal to 0, got "+g[r]);return t.search(g,I,h,u)},o.prototype.computeColumnSpans=function(){for(var g=0;g<this._generatedMappings.length;++g){var I=this._generatedMappings[g];if(g+1<this._generatedMappings.length){var e=this._generatedMappings[g+1];if(I.generatedLine===e.generatedLine){I.lastGeneratedColumn=e.generatedColumn-1;continue}}I.lastGeneratedColumn=1/0}},o.prototype.originalPositionFor=function(g){var I={generatedLine:i.getArg(g,"line"),generatedColumn:i.getArg(g,"column")},e=this._findMapping(I,this._generatedMappings,"generatedLine","generatedColumn",i.compareByGeneratedPositionsDeflated,i.getArg(g,"bias",n.GREATEST_LOWER_BOUND));if(e>=0){var r=this._generatedMappings[e];if(r.generatedLine===I.generatedLine){var h=i.getArg(r,"source",null);h!==null&&(h=this._sources.at(h),h=i.computeSourceURL(this.sourceRoot,h,this._sourceMapURL));var u=i.getArg(r,"name",null);return u!==null&&(u=this._names.at(u)),{source:h,line:i.getArg(r,"originalLine",null),column:i.getArg(r,"originalColumn",null),name:u}}}return{source:null,line:null,column:null,name:null}},o.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(g){return g==null})},o.prototype.sourceContentFor=function(g,I){if(!this.sourcesContent)return null;var e=this._findSourceIndex(g);if(e>=0)return this.sourcesContent[e];var r,h=g;if(this.sourceRoot!=null&&(h=i.relative(this.sourceRoot,h)),this.sourceRoot!=null&&(r=i.urlParse(this.sourceRoot))){var u=h.replace(/^file:\/\//,"");if(r.scheme=="file"&&this._sources.has(u))return this.sourcesContent[this._sources.indexOf(u)];if((!r.path||r.path=="/")&&this._sources.has("/"+h))return this.sourcesContent[this._sources.indexOf("/"+h)]}if(I)return null;throw new Error('"'+h+'" is not in the SourceMap.')},o.prototype.generatedPositionFor=function(g){var I=i.getArg(g,"source");if((I=this._findSourceIndex(I))<0)return{line:null,column:null,lastColumn:null};var e={source:I,originalLine:i.getArg(g,"line"),originalColumn:i.getArg(g,"column")},r=this._findMapping(e,this._originalMappings,"originalLine","originalColumn",i.compareByOriginalPositions,i.getArg(g,"bias",n.GREATEST_LOWER_BOUND));if(r>=0){var h=this._originalMappings[r];if(h.source===e.source)return{line:i.getArg(h,"generatedLine",null),column:i.getArg(h,"generatedColumn",null),lastColumn:i.getArg(h,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},F.BasicSourceMapConsumer=o,C.prototype=Object.create(n.prototype),C.prototype.constructor=n,C.prototype._version=3,Object.defineProperty(C.prototype,"sources",{get:function(){for(var g=[],I=0;I<this._sections.length;I++)for(var e=0;e<this._sections[I].consumer.sources.length;e++)g.push(this._sections[I].consumer.sources[e]);return g}}),C.prototype.originalPositionFor=function(g){var I={generatedLine:i.getArg(g,"line"),generatedColumn:i.getArg(g,"column")},e=t.search(I,this._sections,function(h,u){return h.generatedLine-u.generatedOffset.generatedLine||h.generatedColumn-u.generatedOffset.generatedColumn}),r=this._sections[e];return r?r.consumer.originalPositionFor({line:I.generatedLine-(r.generatedOffset.generatedLine-1),column:I.generatedColumn-(r.generatedOffset.generatedLine===I.generatedLine?r.generatedOffset.generatedColumn-1:0),bias:g.bias}):{source:null,line:null,column:null,name:null}},C.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(g){return g.consumer.hasContentsOfAllSources()})},C.prototype.sourceContentFor=function(g,I){for(var e=0;e<this._sections.length;e++){var r=this._sections[e].consumer.sourceContentFor(g,!0);if(r||r==="")return r}if(I)return null;throw new Error('"'+g+'" is not in the SourceMap.')},C.prototype.generatedPositionFor=function(g){for(var I=0;I<this._sections.length;I++){var e=this._sections[I];if(e.consumer._findSourceIndex(i.getArg(g,"source"))!==-1){var r=e.consumer.generatedPositionFor(g);if(r)return{line:r.line+(e.generatedOffset.generatedLine-1),column:r.column+(e.generatedOffset.generatedLine===r.line?e.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}},C.prototype._parseMappings=function(g,I){this.__generatedMappings=[],this.__originalMappings=[];for(var e=0;e<this._sections.length;e++)for(var r=this._sections[e],h=r.consumer._generatedMappings,u=0;u<h.length;u++){var m=h[u],f=r.consumer._sources.at(m.source);f!==null&&(f=i.computeSourceURL(r.consumer.sourceRoot,f,this._sourceMapURL)),this._sources.add(f),f=this._sources.indexOf(f);var b=null;m.name&&(b=r.consumer._names.at(m.name),this._names.add(b),b=this._names.indexOf(b));var v={source:f,generatedLine:m.generatedLine+(r.generatedOffset.generatedLine-1),generatedColumn:m.generatedColumn+(r.generatedOffset.generatedLine===m.generatedLine?r.generatedOffset.generatedColumn-1:0),originalLine:m.originalLine,originalColumn:m.originalColumn,name:b};this.__generatedMappings.push(v),typeof v.originalLine=="number"&&this.__originalMappings.push(v)}a(this.__generatedMappings,i.compareByGeneratedPositionsDeflated),a(this.__originalMappings,i.compareByOriginalPositions)},F.IndexedSourceMapConsumer=C,F})().SourceMapConsumer,k.SourceNode=(function(){if(Re)return ae;Re=1;var i=Ze().SourceMapGenerator,t=M(),s=/(\r?\n)/,l="$$$isSourceNode$$$";function a(n,o,c,d,p){this.children=[],this.sourceContents={},this.line=n??null,this.column=o??null,this.source=c??null,this.name=p??null,this[l]=!0,d!=null&&this.add(d)}return a.fromStringWithSourceMap=function(n,o,c){var d=new a,p=n.split(s),C=0,g=function(){return u()+(u()||"");function u(){return C<p.length?p[C++]:void 0}},I=1,e=0,r=null;return o.eachMapping(function(u){if(r!==null){if(!(I<u.generatedLine)){var m=(f=p[C]||"").substr(0,u.generatedColumn-e);return p[C]=f.substr(u.generatedColumn-e),e=u.generatedColumn,h(r,m),void(r=u)}h(r,g()),I++,e=0}for(;I<u.generatedLine;)d.add(g()),I++;if(e<u.generatedColumn){var f=p[C]||"";d.add(f.substr(0,u.generatedColumn)),p[C]=f.substr(u.generatedColumn),e=u.generatedColumn}r=u},this),C<p.length&&(r&&h(r,g()),d.add(p.splice(C).join(""))),o.sources.forEach(function(u){var m=o.sourceContentFor(u);m!=null&&(c!=null&&(u=t.join(c,u)),d.setSourceContent(u,m))}),d;function h(u,m){if(u===null||u.source===void 0)d.add(m);else{var f=c?t.join(c,u.source):u.source;d.add(new a(u.originalLine,u.originalColumn,f,m,u.name))}}},a.prototype.add=function(n){if(Array.isArray(n))n.forEach(function(o){this.add(o)},this);else{if(!n[l]&&typeof n!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+n);n&&this.children.push(n)}return this},a.prototype.prepend=function(n){if(Array.isArray(n))for(var o=n.length-1;o>=0;o--)this.prepend(n[o]);else{if(!n[l]&&typeof n!="string")throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+n);this.children.unshift(n)}return this},a.prototype.walk=function(n){for(var o,c=0,d=this.children.length;c<d;c++)(o=this.children[c])[l]?o.walk(n):o!==""&&n(o,{source:this.source,line:this.line,column:this.column,name:this.name})},a.prototype.join=function(n){var o,c,d=this.children.length;if(d>0){for(o=[],c=0;c<d-1;c++)o.push(this.children[c]),o.push(n);o.push(this.children[c]),this.children=o}return this},a.prototype.replaceRight=function(n,o){var c=this.children[this.children.length-1];return c[l]?c.replaceRight(n,o):typeof c=="string"?this.children[this.children.length-1]=c.replace(n,o):this.children.push("".replace(n,o)),this},a.prototype.setSourceContent=function(n,o){this.sourceContents[t.toSetString(n)]=o},a.prototype.walkSourceContents=function(n){for(var o=0,c=this.children.length;o<c;o++)this.children[o][l]&&this.children[o].walkSourceContents(n);var d=Object.keys(this.sourceContents);for(o=0,c=d.length;o<c;o++)n(t.fromSetString(d[o]),this.sourceContents[d[o]])},a.prototype.toString=function(){var n="";return this.walk(function(o){n+=o}),n},a.prototype.toStringWithSourceMap=function(n){var o={code:"",line:1,column:0},c=new i(n),d=!1,p=null,C=null,g=null,I=null;return this.walk(function(e,r){o.code+=e,r.source!==null&&r.line!==null&&r.column!==null?(p===r.source&&C===r.line&&g===r.column&&I===r.name||c.addMapping({source:r.source,original:{line:r.line,column:r.column},generated:{line:o.line,column:o.column},name:r.name}),p=r.source,C=r.line,g=r.column,I=r.name,d=!0):d&&(c.addMapping({generated:{line:o.line,column:o.column}}),p=null,d=!1);for(var h=0,u=e.length;h<u;h++)e.charCodeAt(h)===10?(o.line++,o.column=0,h+1===u?(p=null,d=!1):d&&c.addMapping({source:r.source,original:{line:r.line,column:r.column},generated:{line:o.line,column:o.column},name:r.name})):o.column++}),this.walkSourceContents(function(e,r){c.setSourceContent(e,r)}),{code:o.code,map:c}},ae.SourceNode=a,ae})().SourceNode),k);class J{constructor({file:t,line:s,function:l,code:a,locals:n={},offender:o=!1,column:c}){y(this,"file");y(this,"line");y(this,"function");y(this,"code");y(this,"locals");y(this,"offender");y(this,"column");this.file=t,this.line=s,this.function=l,this.code=a,this.locals=n,this.offender=o,this.column=c}toDict(){const t={file:this.file,line:this.line,function:this.function,code:this.code,locals:Object.fromEntries(Object.entries(this.locals).map(([s,l])=>[s,String(l)]))};return this.offender&&(t.offender=this.offender),this.column!==void 0&&(t.column=this.column),t}toJson(){return JSON.stringify(this.toDict())}}class Q{static encode(t){return t instanceof J?t.toDict():Array.isArray(t)?t.map(s=>Q.encode(s)):typeof t=="object"&&t!==null?JSON.stringify(t):t}static stringify(t){return JSON.stringify(Q.encode(t),(s,l)=>l instanceof J?l.toDict():l)}}let V,K=0;function sn(i){A().sfDebug&&console.log("Initializing Exception Interceptor...");try{const c=(function(){if(V!==void 0)return V;const d=process.env||{},p=Le(d.SF_IS_LOCAL);if(p!==void 0)return V=p;const C=(d.SF_ENV||d.NODE_ENV||"").toLowerCase();if(["local","dev","development"].includes(C))return V=!0;if(["KUBERNETES_SERVICE_HOST","AWS_EXECUTION_ENV","ECS_CONTAINER_METADATA_URI","ECS_CONTAINER_METADATA_URI_V4","GAE_ENV","K_SERVICE","GOOGLE_CLOUD_PROJECT","WEBSITE_INSTANCE_ID","VERCEL","NETLIFY","DYNO","RENDER","FLY_APP_NAME","RAILWAY_STATIC_URL","CF_PAGES","CLOUDFLARE"].some(I=>!!d[I]))return V=!1;const g=(N.hostname?.()||d.HOSTNAME||"").toLowerCase();return g==="localhost"||g.endsWith(".local")||g.includes("local")?V=!0:V=!1})();i?.setSupplementalFields?.({isFromLocalService:c}),(async function(d){if(He)return;He=!0;const p=process.env||{};if(Le(p.SF_IS_LOCAL)===void 0)try{await(async function(C){const g=ce("http://169.254.169.254/latest/meta-data/",{},C),I=ce("http://metadata.google.internal/computeMetadata/v1/instance/",{"Metadata-Flavor":"Google"},C),e=ce("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{Metadata:"true"},C);return(await Promise.allSettled([g,I,e])).some(r=>r.status==="fulfilled"&&(r.value==="ok"||r.value==="http_error"))})(150)&&V&&(V=!1,d?.setSupplementalFields?.({isFromLocalService:!1}))}catch{}})(i).catch(()=>{})}catch{}const t=new ke.Worker(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsK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yeSB7CiAgICAgICAgICAgIGNvbnN0IHsgc2NyaXB0U291cmNlIH0gPSBhd2FpdCBzZXNzaW9uLnBvc3QoCiAgICAgICAgICAgICAgIkRlYnVnZ2VyLmdldFNjcmlwdFNvdXJjZSIsCiAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc2NyaXB0SWQsCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgKTsKICAgICAgICAgICAgY29uc3Qgc291cmNlTGluZXMgPSBzY3JpcHRTb3VyY2Uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogIC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1vZHVsZXMgd2UgYWxsb3cgY2FwdHVyaW5nIGZyb20KICAgICAgICBjb25zdCBpc0Zyb21BbGxvd2VkTm9kZU1vZHVsZSA9IG5vZGVNb2R1bGVzTGlzdC5zb21lKChtb2R1bGVOYW1lKSA9PgogICAgICAgICAgZmlyc3RGcmFtZUxpbmUuaW5jbHVkZXMoYCR7bW9kdWxlTmFtZX1gKSwKICAgICAgICApOwoKICAgICAgICBpZiAoIWlzRnJvbUFsbG93ZWROb2RlTW9kdWxlKSB7CiAgICAgICAgICAvLyBOb3QgZnJvbSBhbiBhbGxvd2VkIG5vZGUgbW9kdWxlID0+IHJldHVybiBlYXJseQogICAgICAgICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgICAgICAgIGNvbnNvbGUubG9nKAogICAgICAgICAgICAgICJbV29ya2VyXSBFcnJvciBhcHBlYXJzIHRvIGJlIHRyaWdnZXJlZCBmcm9tIG5vbi1hcHBsaWNhdGlvbiBzb3VyY2VzOyBpZ25vcmluZy4iLAogICAgICAgICAgICApOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICAvLyBPdGhlcndpc2UsIGl0J3MgZnJvbSBhbiBhbGxvd2VkIG5vZGUgbW9kdWxlLCBzbyBjb250aW51ZQogICAgICB9IGVsc2UgewogICAgICAgIC8vIElmIHRoZSBsaXN0IGlzIGVtcHR5LCBwcmVzZXJ2ZSBleGlzdGluZyBiZWhhdmlvciBhbmQgaWdub3JlIG5vbi1hcHBsaWNhdGlvbiBlcnJvcnMKICAgICAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgICAgIGNvbnNvbGUubG9nKAogICAgICAgICAgICAiW1dvcmtlcl0gRXJyb3IgYXBwZWFycyB0byBiZSB0cmlnZ2VyZWQgZnJvbSBub24tYXBwbGljYXRpb24gc291cmNlczsgaWdub3JpbmcuIiwKICAgICAgICAgICk7CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAg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BmZXRjaCBsb2NhbCB2YXJpYWJsZXM6IiwgZXJyKTsKICAgIH0KICAgIHJldHVybiB7fTsKICB9Cn0KCnN0YXJ0RGVidWdnZXIoKS5jYXRjaCgoZXJyb3IpID0+IHsKICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlcjoiLCBlcnJvcik7CiAgfQp9KTsKCi8vIEtlZXAgdGhlIHdvcmtlciBhbGl2ZQpzZXRJbnRlcnZhbCgoKSA9PiB7fSwgMTAwMDApOwo="),{workerData:{captureAllExceptions:!0}});let s=null;const l=new WeakMap;t.on("message",c=>{if(typeof c=="string"&&A().sfDebug&&console.log(`[Worker] ${c}`),c.readyToGetParameters&&t.postMessage({sfDebug:A().sfDebug,stackDepthLocals:A().stackDepthLocals,nodeModulesToCollectLocalVariablesOn:A().nodeModulesToCollectLocalVariablesOn}),c.type==="exception"){const{frames:d}=c,p=s;if(!p)return;const C=l.get(p),g=(function(e){return e?e.split(`
34
+ `).slice(1).map(r=>{const h=/at (.+?) \((.+):(\d+):(\d+)\)/.exec(r)||/at (.+):(\d+):(\d+)/.exec(r);if(h){const[,u,m,f,b]=h;return new J({function:u||"<anonymous>",locals:{},file:m||"<unknown>",line:parseInt(f,10)||0,code:"<not captured>",column:parseInt(b)||0})}return new J({function:"<unknown>",locals:{},file:"<unknown>",line:0,code:"<not captured>",column:0})}):[]})(p.stack),I=(function(e,r){const h=[];let u=-1,m=-1;for(let f=0;f<e.length;f++){const b=cn(e[f].file);if(m=f,b!=="<unknown>"){for(let v=0;v<r.length;v++){const S=r[v];if(Oe(S,b)||typeof S.file=="string"&&S.file.includes(b)){u=v,K=0,A().sfDebug&&console.log(`✅ Matched Frame Found: ${b} @ Debugger Frame ${v}`);break}}if(u!==-1)break}}if(u===-1)return K===10?(K=0,e):(++K,A().sfDebug&&console.log(`"❌ No matching frame found. Checking once again, Attempt N ${K}"`),[]);A().sfDebug&&console.log(`🔄 Merging from matched index ${u} onward...`);for(let f=0;f<r.length;f++){const b=e[m+f],v=r[u+f];h.push(new J({function:v?.function||b?.function||"<anonymous>",locals:v?.locals||b?.locals||{},file:b?.file||v?.file||"<unknown>",line:v?.line||b?.line||0,code:v?.code||b?.code||"<not captured>"}))}return h})(g,d||[]);if(I.length!==0){s=null;const e=A().stackDepthCodeTraceDepth,r=e===-1?I:I.slice(0,e+1),h=Math.min(r.length,g.length);for(let b=0;b<h;b++)(async()=>{const v=an(r[b].file,g[b].line,g[b].column);v&&(v.content!=null&&(r[b].code=v.content),v.file!=null&&(r[b].file=v.file))})();i.setOperationName("CollectExceptions");const u=p.message?`${p.name}: ${p.message}`:p.name;A().sfDebug&&console.log("error message is : ",u);const m=w.getInstance(),f=l.get(p);f?(m.setTraceIdFor(f,f),m.runWithSession(f,()=>{m.setTraceId(f),i.doSend(u,r)})):i.doSend(u,r),C?w.getInstance().runWithSession(C,()=>{i.doSend(u,r)}):i.doSend(u,r)}}}),t.on("error",c=>{console.error("[Worker Error]",c)}),t.on("exit",c=>{console.error(`[Worker] Exited with code ${c}`)}),t.unref();const a=Error,n=new Set;function o(...c){const d=Reflect.construct(a,c);Reflect.setPrototypeOf(d,o.prototype);try{const C=w.getInstance().getTraceId();l.set(d,C)}catch{}a.captureStackTrace&&a.captureStackTrace(d,o);const p=`${d.message}:${d.stack?.split(`
35
+ `)[1]?.trim()}`;if(!n.has(p)){n.add(p),s=d;const C=w.getInstance().getTraceId();l.set(d,C),t.postMessage({type:"processException",error:d.message})}return d}o.prototype=Object.create(a.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf(o,a),globalThis.Error=o}function _e(i){return i=(i=(i=i.replace(/^webpack:\/\/[^\/]+\/\.?\//,"")).replace(/^.*\/pages\//,"pages/")).replace(/\.(js|ts)$/,"")}function an(i,t,s){const l=(function(n){n.startsWith("at ")&&(n=n.slice(3).trim());const o=n.match(/^(.*?)(:\d+)+(\.map)?$/);return o?o[1]:n})(i);if(!l||l==="<unknown>")return null;const a=l+".map";try{const n=Fe.readFileSync(a,"utf-8");if(n){const o=JSON.parse(n);let c=new De.SourceMapConsumer(o).originalPositionFor({line:t,column:s});if(l&&c.source){const d=_e(l),p=o.sources.findIndex(C=>_e(C)===d);if(p===-1)A().sfDebug&&console.log(`Source file "${l}" not found in the source map.`);else{const C=o.sourcesContent[p],g=o.names.join(",");if(C)return{content:C.split(`
36
36
  `).slice(c.line-1,c.line+20).join(`
37
- `),name:l,file:c.source};A().sfDebug&&console.log(`No source content available for file "${g}".`)}}return{content:o.sourcesContent[0],name:o.names[0],file:o.file}}}catch(t){A().sfDebug&&console.log(`Cant read/parse "${a}: Error - ".`,t)}return null}function rt(i){return i?.split("/").pop()||"<unknown>"}function Fe(i,r){if(!i||typeof i!="object")return!1;for(const s of Object.values(i))if(typeof s=="string"&&s.includes(r)||typeof s=="object"&&Fe(s,r))return!0;return!1}class ot extends L{constructor(){super();y(this,"serviceIdentifier",new M);this.setOperationName("CollectExceptions")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s,g){this.sendAppIdentifier(),this.send(s,g)}async send(s,g){A().sfDebug&&console.log(" SENDING EXCEPTION...");const a=JSON.stringify(j.encode(g)),t=this.getVariables({exceptionMessage:s,traceJson:a,reentrancyGuardPreactive:!1,library:A().packageLibraryType,version:A().version});H(this.endpoint,this.operationName,this.getQuery(),t)}getQuery(){return`
38
- mutation ${this.operationName}($apiKey: String!, $serviceUuid: String!, $sessionId: String!, $exceptionMessage: String!, $traceJson: String!, $reentrancyGuardPreactive: Boolean!, $library: String!, $timestampMs: String!, $version: String!) {
39
- ${this.queryName}(apiKey: $apiKey, serviceUuid: $serviceUuid, sessionId: $sessionId, exceptionMessage: $exceptionMessage, traceJson: $traceJson, reentrancyGuardPreactive: $reentrancyGuardPreactive, library: $library, timestampMs: $timestampMs, version: $version)
40
- }
41
- `}}const Re="getting request source code";var P=(i=>(i.UNKNOWN="unknown",i.ANONYMOUS="anonymous",i.NOT_CAPTURED="not captured",i))(P||{});const ae="http:",ce="https:";let He=!1;function it(){const i=A().sfDebug;if(He)return void(i&&console.log("[patchNodeHttpInbound] Already installed, skipping."));let r;He=!0;try{r=require("node:http"),i&&console.log("[patchNodeHttpInbound] node:http required successfully.")}catch(a){return void console.error("Failed to require node:http:",a)}if(!r?.Server?.prototype)return void(i&&console.log("[patchNodeHttpInbound] http.Server.prototype not found."));const s=r.Server.prototype,g=s.emit;g&&!s.__sf_inbound_patched__?(Object.defineProperty(s,"__sf_inbound_patched__",{value:!0,enumerable:!1,configurable:!1,writable:!1}),i&&console.log("[patchNodeHttpInbound] Patching http.Server.prototype.emit."),s.emit=function(a,...t){if(a!=="request")return i&&console.log(`[patchNodeHttpInbound] Passing through event: ${a}`),g.call(this,a,...t);const o=t[0],c=t[1],I=(function(d){const e={};if(!d)return e;for(const[n,h]of Object.entries(d))h!=null&&(Array.isArray(h)?e[n.toLowerCase()]=h.join(", "):e[n.toLowerCase()]=String(h));return e})(o?.headers),p=I["x-sf3-rid"];i&&(console.log("[patchNodeHttpInbound] Intercepted request event."),console.log("[patchNodeHttpInbound] Inbound headers:",I),console.log("[patchNodeHttpInbound] Trace header:",p));const C=w.getInstance();C.setTraceId(p);const l=C.getTraceId();return i&&console.log("[patchNodeHttpInbound] Context traceId set:",l),C.runWith({inboundHeaders:I,...p?{traceId:p}:{}},()=>{p&&C.setTraceId(p),i&&console.log("[patchNodeHttpInbound] Running request handler in context.");const d=()=>{i&&console.log("[patchNodeHttpInbound] Response finished/closed for traceId:",C.getTraceId())};return c.on("finish",d),c.on("close",d),g.call(this,a,o,c)})}):i&&console.log("[patchNodeHttpInbound] Already patched, skipping.")}const R={};class st extends le{constructor(){super(),this.setOperationName("DomainsToNotPassHeaderTo")}async doSend(r){this.sendAppIdentifier(),this.send(r)}async send(r){const s=`
37
+ `),name:g,file:c.source};A().sfDebug&&console.log(`No source content available for file "${l}".`)}}return{content:o.sourcesContent[0],name:o.names[0],file:o.file}}}catch(n){A().sfDebug&&console.log(`Cant read/parse "${a}: Error - ".`,n)}return null}function cn(i){return i?.split("/").pop()||"<unknown>"}function Oe(i,t){if(!i||typeof i!="object")return!1;for(const s of Object.values(i))if(typeof s=="string"&&s.includes(t)||typeof s=="object"&&Oe(s,t))return!0;return!1}let He=!1;function Le(i){if(!i)return;const t=i.toLowerCase().trim();return!!["1","true","yes","on"].includes(t)||!["0","false","no","off"].includes(t)&&void 0}function ce(i,t,s){return new Promise(l=>{try{const a=new URL(i),n=(a.protocol,N).request({method:"GET",hostname:a.hostname,port:a.port||(a.protocol==="https:"?443:80),path:a.pathname+(a.search||""),headers:t},o=>{o.resume(),o.statusCode&&o.statusCode>=200&&o.statusCode<400?l("ok"):l("http_error")});n.on("error",()=>l("error")),n.setTimeout(s,()=>{n.destroy(),l("timeout")}),n.end()}catch{l("error")}})}class ln extends E{constructor(){super();y(this,"serviceIdentifier",new D);y(this,"supplementalFields",{});this.setOperationName("CollectExceptions")}setSupplementalFields(s){this.supplementalFields={...this.supplementalFields,...s}}normalizedSupplementalForGraphQL(){const{isFromLocalService:s}=this.supplementalFields,l={};return s!==void 0&&(l.isFromLocalService=s),l}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s,l){this.sendAppIdentifier(),this.send(s,l)}async send(s,l){A().sfDebug&&console.log(" SENDING EXCEPTION...");const a=JSON.stringify(Q.encode(l)),n=this.normalizedSupplementalForGraphQL(),o=this.getVariables({exceptionMessage:s,traceJson:a,reentrancyGuardPreactive:!1,library:A().packageLibraryType,version:A().version,...n});H(this.endpoint,this.operationName,this.getQuery(),o)}getQuery(){return`
38
+ mutation ${this.operationName}(
39
+ $apiKey: String!,
40
+ $serviceUuid: String!,
41
+ $sessionId: String!,
42
+ $exceptionMessage: String!,
43
+ $traceJson: String!,
44
+ $reentrancyGuardPreactive: Boolean!,
45
+ $library: String!,
46
+ $timestampMs: String!,
47
+ $version: String!,
48
+ $isFromLocalService: Boolean
49
+ ) {
50
+ ${this.queryName}(
51
+ apiKey: $apiKey,
52
+ serviceUuid: $serviceUuid,
53
+ sessionId: $sessionId,
54
+ exceptionMessage: $exceptionMessage,
55
+ traceJson: $traceJson,
56
+ reentrancyGuardPreactive: $reentrancyGuardPreactive,
57
+ library: $library,
58
+ timestampMs: $timestampMs,
59
+ version: $version,
60
+ isFromLocalService: $isFromLocalService
61
+ )
62
+ }
63
+ `}}const Ee="getting request source code";var j=(i=>(i.UNKNOWN="unknown",i.ANONYMOUS="anonymous",i.NOT_CAPTURED="not captured",i))(j||{});const le="http:",ge="https:";let Ye=!1;function gn(){const i=A().sfDebug;if(Ye)return void(i&&console.log("[patchNodeHttpInbound] Already installed, skipping."));let t;Ye=!0;try{t=require("node:http"),i&&console.log("[patchNodeHttpInbound] node:http required successfully.")}catch(a){return void console.error("Failed to require node:http:",a)}if(!t?.Server?.prototype)return void(i&&console.log("[patchNodeHttpInbound] http.Server.prototype not found."));const s=t.Server.prototype,l=s.emit;l&&!s.__sf_inbound_patched__?(Object.defineProperty(s,"__sf_inbound_patched__",{value:!0,enumerable:!1,configurable:!1,writable:!1}),i&&console.log("[patchNodeHttpInbound] Patching http.Server.prototype.emit."),s.emit=function(a,...n){if(a!=="request")return i&&console.log(`[patchNodeHttpInbound] Passing through event: ${a}`),l.call(this,a,...n);const o=n[0],c=n[1],d=(function(I){const e={};if(!I)return e;for(const[r,h]of Object.entries(I))h!=null&&(Array.isArray(h)?e[r.toLowerCase()]=h.join(", "):e[r.toLowerCase()]=String(h));return e})(o?.headers),p=d["x-sf3-rid"];i&&(console.log("[patchNodeHttpInbound] Intercepted request event."),console.log("[patchNodeHttpInbound] Inbound headers:",d),console.log("[patchNodeHttpInbound] Trace header:",p));const C=w.getInstance();C.setTraceId(p);const g=C.getTraceId();return i&&console.log("[patchNodeHttpInbound] Context traceId set:",g),C.runWith({inboundHeaders:d,...p?{traceId:p}:{}},()=>{p&&C.setTraceId(p),i&&console.log("[patchNodeHttpInbound] Running request handler in context.");const I=()=>{i&&console.log("[patchNodeHttpInbound] Response finished/closed for traceId:",C.getTraceId())};return c.on("finish",I),c.on("close",I),l.call(this,a,o,c)})}):i&&console.log("[patchNodeHttpInbound] Already patched, skipping.")}class un extends de{constructor(){super(),this.setOperationName("DomainsToNotPassHeaderTo")}async doSend(t){this.sendAppIdentifier(),this.send(t)}async send(t){const s=`
42
64
  ${this.queryType} ${this.operationName}(
43
65
  $apiKey: String!,
44
66
  $serviceUuid: String!,
@@ -50,7 +72,7 @@
50
72
  domains: $domains
51
73
  )
52
74
  }
53
- `,g={apiKey:this.apiKey,serviceUuid:this.serviceUUID,domains:r};H(this.endpoint,this.operationName,s,g)}}class at extends L{constructor(){super();y(this,"serviceIdentifier",new M);this.setOperationName("CollectNetworkHops")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s){this.sendAppIdentifier(),this.send(s)}async send(s){const{name:g,column:a,line:t,entrypoint:o,retryWithoutTraceId:c}=s,I=this.getVariables({name:g,column:a,line:t,entrypoint:o,retryWithoutTraceId:c});H(this.endpoint,this.operationName,this.getQuery(),I)}getQuery(){return`
75
+ `,l={apiKey:this.apiKey,serviceUuid:this.serviceUUID,domains:t};H(this.endpoint,this.operationName,s,l)}}class dn extends E{constructor(){super();y(this,"serviceIdentifier",new D);this.setOperationName("CollectNetworkHops")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s){this.sendAppIdentifier(),this.send(s)}async send(s){const{name:l,column:a,line:n,entrypoint:o,retryWithoutTraceId:c}=s,d=this.getVariables({name:l,column:a,line:n,entrypoint:o,retryWithoutTraceId:c});H(this.endpoint,this.operationName,this.getQuery(),d)}getQuery(){return`
54
76
  mutation ${this.operationName}(
55
77
  $apiKey: String!,
56
78
  $sessionId: String!,
@@ -74,15 +96,15 @@
74
96
  ${this.operationName==="CollectNetworkHops"?", retryWithoutTraceId: $retryWithoutTraceId":""}
75
97
  )
76
98
  }
77
- `}}class ct extends L{constructor(){super();y(this,"serviceIdentifier",new M);this.setOperationName("CollectNetworkRequest")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s){this.sendAppIdentifier(),this.send(s)}getQuery(){return`
99
+ `}}class In extends E{constructor(){super();y(this,"serviceIdentifier",new D);this.setOperationName("CollectNetworkRequest")}async sendAppIdentifier(){this.serviceIdentifier.doSend({})}async doSend(s){this.sendAppIdentifier(),this.send(s)}getQuery(){return`
78
100
  mutation ${this.operationName}(
79
101
  $data: NetworkRequestInput!
80
102
  ) {
81
103
  ${this.queryName}(
82
104
  data: $data)
83
105
  }
84
- `}async send(s){const g={data:{...s}};await H(this.endpoint,this.operationName,this.getQuery(),g)}}const ge=[400,403];class gt{constructor(r=[]){y(this,"HEADER_TRACING","X-Sf3-Rid");y(this,"HEADER_LOG_GUARD","reentrancy_guard_logging_preactive");y(this,"HEADER_PRINT_GUARD","reentrancy_guard_print_preactive");y(this,"HEADER_EXCEPTION_GUARD","reentrancy_guard_exception_preactive");y(this,"contextManager");this.contextManager=w.getInstance(),r?.forEach(s=>{typeof s=="string"&&s.trim()&&this.contextManager.getExcludedDomains().add(s)}),A().sfDebug&&console.log("[RequestInterceptor] Initialized with static excluded domains.")}extractIdsFromTraceHeader(r,s=this.HEADER_TRACING){let g;if(r instanceof Headers)g=r.get(s)??void 0;else{const t=s.toLowerCase();for(const[o,c]of Object.entries(r))if(o.toLowerCase()===t){g=c;break}}if(!g)return{};const a=g.split("/").filter(Boolean);return a.length<3?{}:{sessionId:a[0],pageVisitId:a[1],requestId:a[a.length-1]}}parseStackFrame(r){const s=/\((.*):(\d+):(\d+)\)$/.exec(r.trim());if(!s)return null;const[,g,a,t]=s;return{filePath:g,line:parseInt(a,10),column:parseInt(t,10)}}async getOriginalPosition(r,s,g){let a={source:r,line:s,column:g,name:null};const t=r+".map";try{const o=JSON.parse(Le.readFileSync(t,"utf-8"));let c=(await new Ee.SourceMapConsumer(o)).originalPositionFor({line:s,column:g});c.source&&(a=c)}catch(o){A().sfDebug&&console.error(`Could not read/parse map file at ${t}:`,o)}return{originalPos:a}}captureFirstUserLines(r,s=10,g=!1){const a=A().sfDebug?10:s,t=Error.stackTraceLimit;Error.stackTraceLimit=Math.max(t,a);const o=new Error(Re);Re in Error&&Error.captureStackTrace(o,this.captureFirstUserLines);const c=o.stack||"";Error.stackTraceLimit=t;const I=c.split(`
85
- `).slice(1),p=[];for(const C of I)if(!(C.includes("node:internal")||C.includes("internal/modules")||C.includes("internal/process")||C.includes("node_modules")||C.includes(".next/server/chunks")||C.includes("RequestInterceptor")||C.includes("contextManager")||C.includes("setupConfig"))&&(p.push(C.trim()),p.length>=s))break;for(const C of p){const l=this.parseStackFrame(C);l?(async()=>{const{originalPos:d}=await this.getOriginalPosition(l.filePath,l.line,l.column);if(d){A().sfDebug&&console.log("[RequestInterceptor] First user code line:",d);const e={line:d.line?.toString()||P.UNKNOWN,column:d.column?.toString()||P.NOT_CAPTURED,name:d.name||P.NOT_CAPTURED,entrypoint:d.source,retryWithoutTraceId:g};r.doSend(e)}})():A().sfDebug&&console.error("Could not parse stack line:",C)}}addReentrancyGuardHeaders(r){r.set(this.HEADER_LOG_GUARD,"true"),r.set(this.HEADER_PRINT_GUARD,"true"),r.set(this.HEADER_EXCEPTION_GUARD,"true")}shouldPropagateHeaders(r){return!Ue.some(s=>new RegExp(`^${s.replace(/\*/g,".*")}$`).test(r))}addTracingHeaders(r,s){const g=new URL(s).hostname,a=this.shouldPropagateHeaders(g);return a?this.addTracingHeader(r,s):A().sfDebug&&console.error(`[RequestInterceptor] Excluded domain: ${g}`),a}addTracingHeader(r,s){const g=this.contextManager.getOrSetSfTraceId(),a=this.contextManager.getOrSetPageVisitUUID(),t=E();r.set(this.HEADER_TRACING,`${g}/${a}/${t}`),A().sfDebug&&console.log(`[RequestInterceptor] Added tracing header for ${s}`)}patchFetch(r,s){const g=globalThis.fetch;typeof g=="function"?globalThis.fetch=async(a,t)=>{this.captureFirstUserLines(r);const o=Date.now(),c=new Headers(t?.headers);let I;typeof a=="string"||a instanceof URL?I=a.toString():a instanceof Request?(I=a.url,a.headers.forEach((n,h)=>{c.set(h,n)})):A().sfDebug&&console.error("[Sailfish RequestInterceptor] Invalid fetch input."),A().sfDebug&&console.log("[RequestInterceptor] Fetching request to:",I);const p=new URL(I).hostname,C=new Headers(c),l=this.addTracingHeaders(c,I),d={...t,headers:c};let e;try{let n=!1;this.addTracingHeaders(C,I),e=await g(I,d),l&&ge.includes(e.status)?(e=await g(I,{...t,headers:C}),n=!0,this.captureFirstUserLines(r,10,n)):this.contextManager.addSupportedDomains(p);const h=Date.now();A().sfDebug&&console.log(`[RequestInterceptor] Fetch completed: ${I}, Status: ${e.status}, Duration: ${h-o}ms`);const{sessionId:u,pageVisitId:m,requestId:f}=this.extractIdsFromTraceHeader(c);return s.doSend({apiKey:A().apiKey,requestId:f,pageVisitId:m,recordingSessionId:u,serviceUuid:A().serviceUUID,timestampStart:o.toString(),timestampEnd:h.toString(),responseCode:e.status,success:!0,error:null,url:I,method:d.method||"GET",retryWithoutTraceId:n}),e}catch(n){const h=Date.now();A().sfDebug&&console.error(`[RequestInterceptor] Fetch failed: ${I}, Error: ${n}, Duration: ${h-o}ms`)}}:A().sfDebug&&console.error("[RequestInterceptor] Fetch not available.")}patchHttp(r,s){if(A().sfDebug&&console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."),!R||typeof R.request!="function")return void(A().sfDebug&&console.log("[RequestInterceptor] HTTP/HTTPS not available."));const g=R.request.bind(R),a=R.request.bind(R);R.request=function(t,o){let c;try{if(typeof t=="string"){const p=new URL(t);c={protocol:p.protocol||ae,hostname:p.hostname,path:p.pathname+p.search,headers:{}}}else t instanceof URL?c={protocol:t.protocol||ae,hostname:t.hostname,path:t.pathname+t.search,headers:{}}:(c={...t},c.protocol||(c.protocol=ae));if(c.headers){const p=`${c.protocol}//${c.hostname}`;this.addTracingHeaders(c.headers,p),this.captureFirstUserLines(r)}else A().sfDebug&&console.warn("[RequestInterceptor] No headers found in HTTP request options. Skipping header addition.")}catch(p){throw A().sfDebug&&console.error("[RequestInterceptor] Error while processing HTTP request options:",p),p}let I=!1;return g(c,p=>{const C=`${c.protocol}//${c.hostname}`;if(c.headers&&this.shouldPropagateHeaders(new URL(C).hostname)&&ge.includes(p.statusCode||0)){c.hostname;const n={...c,headers:{...c.headers}};delete n.headers[this.HEADER_TRACING],g(n,o),I=!0,this.captureFirstUserLines(r,10,I)}const{sessionId:l,pageVisitId:d,requestId:e}=this.extractIdsFromTraceHeader(c.headers);s.doSend({apiKey:A().apiKey,requestId:e,pageVisitId:d,recordingSessionId:l,serviceUuid:A().serviceUUID,timestampStart:Date.now().toString(),timestampEnd:Date.now().toString(),responseCode:p.statusCode||0,success:!!p.statusCode&&p.statusCode<400,error:null,url:C,method:c.method||"GET",retryWithoutTraceId:I}),o?.(p)})},R.request=function(t,o){let c;try{if(typeof t=="string"){const p=new URL(t);c={protocol:p.protocol||ce,hostname:p.hostname,path:p.pathname+p.search,headers:{}}}else t instanceof URL?c={protocol:t.protocol||ce,hostname:t.hostname,path:t.pathname+t.search,headers:{}}:(c={...t},c.protocol||(c.protocol=ce));if(c.headers){const p=`${c.protocol}//${c.hostname}`;this.addTracingHeaders(c.headers,p)}else A().sfDebug&&console.warn("[RequestInterceptor] No headers found in HTTPS request options. Skipping header addition.")}catch(p){throw A().sfDebug&&console.error("[RequestInterceptor] Error while processing HTTPS request options:",p),p}let I=!1;return a(c,p=>{const C=`${c.protocol}//${c.hostname}`;if(c.headers&&this.shouldPropagateHeaders(new URL(C).hostname)&&ge.includes(p.statusCode||0)){const n={...c,headers:{...c.headers}};delete n.headers[this.HEADER_TRACING],a(n,o),I=!0,this.captureFirstUserLines(r,10,I)}const{sessionId:l,pageVisitId:d,requestId:e}=this.extractIdsFromTraceHeader(c.headers);s.doSend({apiKey:A().apiKey,requestId:e,pageVisitId:d,recordingSessionId:l,serviceUuid:A().serviceUUID,timestampStart:Date.now().toString(),timestampEnd:Date.now().toString(),responseCode:p.statusCode||0,success:!!p.statusCode&&p.statusCode<400,error:null,url:C,method:c.method||"GET",retryWithoutTraceId:I}),o?.(p)})},A().sfDebug&&console.log("✅ HTTP and HTTPS request methods patched globally.")}tryPatch(r,s){try{require.resolve(s),r(),console.log(`[RequestInterceptor] Patched ${s}`)}catch(g){console.warn(`[RequestInterceptor] Could not patch ${s}: ${g.message}`)}}getExcludedDomains(){return[...this.contextManager.getExcludedDomains()]}}class lt extends le{constructor(){super(),this.setOperationName("UpdateServiceDetails")}async doSend(){this.sendAppIdentifier(),this.send()}async send(){const r=`
106
+ `}async send(s){const l={data:{...s}};await H(this.endpoint,this.operationName,this.getQuery(),l)}}const ue=[400,403];class pn{constructor(t=[]){y(this,"HEADER_TRACING","X-Sf3-Rid");y(this,"HEADER_LOG_GUARD","reentrancy_guard_logging_preactive");y(this,"HEADER_PRINT_GUARD","reentrancy_guard_print_preactive");y(this,"HEADER_EXCEPTION_GUARD","reentrancy_guard_exception_preactive");y(this,"contextManager");this.contextManager=w.getInstance(),t?.forEach(s=>{typeof s=="string"&&s.trim()&&this.contextManager.getExcludedDomains().add(s)}),A().sfDebug&&console.log("[RequestInterceptor] Initialized with static excluded domains.")}extractIdsFromTraceHeader(t,s=this.HEADER_TRACING){let l;if(t instanceof Headers)l=t.get(s)??void 0;else{const n=s.toLowerCase();for(const[o,c]of Object.entries(t))if(o.toLowerCase()===n){l=c;break}}if(!l)return{};const a=l.split("/").filter(Boolean);return a.length<3?{}:{sessionId:a[0],pageVisitId:a[1],requestId:a[a.length-1]}}parseStackFrame(t){const s=/\((.*):(\d+):(\d+)\)$/.exec(t.trim());if(!s)return null;const[,l,a,n]=s;return{filePath:l,line:parseInt(a,10),column:parseInt(n,10)}}async getOriginalPosition(t,s,l){let a={source:t,line:s,column:l,name:null};const n=t+".map";try{const o=JSON.parse(Fe.readFileSync(n,"utf-8"));let c=(await new De.SourceMapConsumer(o)).originalPositionFor({line:s,column:l});c.source&&(a=c)}catch(o){A().sfDebug&&console.error(`Could not read/parse map file at ${n}:`,o)}return{originalPos:a}}captureFirstUserLines(t,s=10,l=!1){const a=A().sfDebug?10:s,n=Error.stackTraceLimit;Error.stackTraceLimit=Math.max(n,a);const o=new Error(Ee);Ee in Error&&Error.captureStackTrace(o,this.captureFirstUserLines);const c=o.stack||"";Error.stackTraceLimit=n;const d=c.split(`
107
+ `).slice(1),p=[];for(const C of d)if(!(C.includes("node:internal")||C.includes("internal/modules")||C.includes("internal/process")||C.includes("node_modules")||C.includes(".next/server/chunks")||C.includes("RequestInterceptor")||C.includes("contextManager")||C.includes("setupConfig"))&&(p.push(C.trim()),p.length>=s))break;for(const C of p){const g=this.parseStackFrame(C);g?(async()=>{const{originalPos:I}=await this.getOriginalPosition(g.filePath,g.line,g.column);if(I){A().sfDebug&&console.log("[RequestInterceptor] First user code line:",I);const e={line:I.line?.toString()||j.UNKNOWN,column:I.column?.toString()||j.NOT_CAPTURED,name:I.name||j.NOT_CAPTURED,entrypoint:I.source,retryWithoutTraceId:l};t.doSend(e)}})():A().sfDebug&&console.error("Could not parse stack line:",C)}}addReentrancyGuardHeaders(t){t.set(this.HEADER_LOG_GUARD,"true"),t.set(this.HEADER_PRINT_GUARD,"true"),t.set(this.HEADER_EXCEPTION_GUARD,"true")}shouldPropagateHeaders(t){return!Te.some(s=>new RegExp(`^${s.replace(/\*/g,".*")}$`).test(t))}addTracingHeaders(t,s){const l=new URL(s).hostname,a=this.shouldPropagateHeaders(l);return a?this.addTracingHeader(t,s):A().sfDebug&&console.error(`[RequestInterceptor] Excluded domain: ${l}`),a}addTracingHeader(t,s){const l=this.contextManager.getOrSetSfTraceId(),a=this.contextManager.getOrSetPageVisitUUID(),n=T();t.set(this.HEADER_TRACING,`${l}/${a}/${n}`),A().sfDebug&&console.log(`[RequestInterceptor] Added tracing header for ${s}`)}patchFetch(t,s){const l=globalThis.fetch;typeof l=="function"?globalThis.fetch=async(a,n)=>{this.captureFirstUserLines(t);const o=Date.now(),c=new Headers(n?.headers);let d;typeof a=="string"||a instanceof URL?d=a.toString():a instanceof Request?(d=a.url,a.headers.forEach((r,h)=>{c.set(h,r)})):A().sfDebug&&console.error("[Sailfish RequestInterceptor] Invalid fetch input."),A().sfDebug&&console.log("[RequestInterceptor] Fetching request to:",d);const p=new URL(d).hostname,C=new Headers(c),g=this.addTracingHeaders(c,d),I={...n,headers:c};let e;try{let r=!1;this.addTracingHeaders(C,d),e=await l(d,I),g&&ue.includes(e.status)?(e=await l(d,{...n,headers:C}),r=!0,this.captureFirstUserLines(t,10,r)):this.contextManager.addSupportedDomains(p);const h=Date.now();A().sfDebug&&console.log(`[RequestInterceptor] Fetch completed: ${d}, Status: ${e.status}, Duration: ${h-o}ms`);const{sessionId:u,pageVisitId:m,requestId:f}=this.extractIdsFromTraceHeader(c);return s.doSend({apiKey:A().apiKey,requestId:f,pageVisitId:m,recordingSessionId:u,serviceUuid:A().serviceUUID,timestampStart:o.toString(),timestampEnd:h.toString(),responseCode:e.status,success:!0,error:null,url:d,method:I.method||"GET",retryWithoutTraceId:r}),e}catch(r){const h=Date.now();A().sfDebug&&console.error(`[RequestInterceptor] Fetch failed: ${d}, Error: ${r}, Duration: ${h-o}ms`)}}:A().sfDebug&&console.error("[RequestInterceptor] Fetch not available.")}patchHttp(t,s){if(A().sfDebug&&console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."),!N||typeof N.request!="function")return void(A().sfDebug&&console.log("[RequestInterceptor] HTTP/HTTPS not available."));const l=N.request.bind(N),a=N.request.bind(N);N.request=function(n,o){let c;try{if(typeof n=="string"){const p=new URL(n);c={protocol:p.protocol||le,hostname:p.hostname,path:p.pathname+p.search,headers:{}}}else n instanceof URL?c={protocol:n.protocol||le,hostname:n.hostname,path:n.pathname+n.search,headers:{}}:(c={...n},c.protocol||(c.protocol=le));if(c.headers){const p=`${c.protocol}//${c.hostname}`;this.addTracingHeaders(c.headers,p),this.captureFirstUserLines(t)}else A().sfDebug&&console.warn("[RequestInterceptor] No headers found in HTTP request options. Skipping header addition.")}catch(p){throw A().sfDebug&&console.error("[RequestInterceptor] Error while processing HTTP request options:",p),p}let d=!1;return l(c,p=>{const C=`${c.protocol}//${c.hostname}`;if(c.headers&&this.shouldPropagateHeaders(new URL(C).hostname)&&ue.includes(p.statusCode||0)){c.hostname;const r={...c,headers:{...c.headers}};delete r.headers[this.HEADER_TRACING],l(r,o),d=!0,this.captureFirstUserLines(t,10,d)}const{sessionId:g,pageVisitId:I,requestId:e}=this.extractIdsFromTraceHeader(c.headers);s.doSend({apiKey:A().apiKey,requestId:e,pageVisitId:I,recordingSessionId:g,serviceUuid:A().serviceUUID,timestampStart:Date.now().toString(),timestampEnd:Date.now().toString(),responseCode:p.statusCode||0,success:!!p.statusCode&&p.statusCode<400,error:null,url:C,method:c.method||"GET",retryWithoutTraceId:d}),o?.(p)})},N.request=function(n,o){let c;try{if(typeof n=="string"){const p=new URL(n);c={protocol:p.protocol||ge,hostname:p.hostname,path:p.pathname+p.search,headers:{}}}else n instanceof URL?c={protocol:n.protocol||ge,hostname:n.hostname,path:n.pathname+n.search,headers:{}}:(c={...n},c.protocol||(c.protocol=ge));if(c.headers){const p=`${c.protocol}//${c.hostname}`;this.addTracingHeaders(c.headers,p)}else A().sfDebug&&console.warn("[RequestInterceptor] No headers found in HTTPS request options. Skipping header addition.")}catch(p){throw A().sfDebug&&console.error("[RequestInterceptor] Error while processing HTTPS request options:",p),p}let d=!1;return a(c,p=>{const C=`${c.protocol}//${c.hostname}`;if(c.headers&&this.shouldPropagateHeaders(new URL(C).hostname)&&ue.includes(p.statusCode||0)){const r={...c,headers:{...c.headers}};delete r.headers[this.HEADER_TRACING],a(r,o),d=!0,this.captureFirstUserLines(t,10,d)}const{sessionId:g,pageVisitId:I,requestId:e}=this.extractIdsFromTraceHeader(c.headers);s.doSend({apiKey:A().apiKey,requestId:e,pageVisitId:I,recordingSessionId:g,serviceUuid:A().serviceUUID,timestampStart:Date.now().toString(),timestampEnd:Date.now().toString(),responseCode:p.statusCode||0,success:!!p.statusCode&&p.statusCode<400,error:null,url:C,method:c.method||"GET",retryWithoutTraceId:d}),o?.(p)})},A().sfDebug&&console.log("✅ HTTP and HTTPS request methods patched globally.")}tryPatch(t,s){try{require.resolve(s),t(),console.log(`[RequestInterceptor] Patched ${s}`)}catch(l){console.warn(`[RequestInterceptor] Could not patch ${s}: ${l.message}`)}}getExcludedDomains(){return[...this.contextManager.getExcludedDomains()]}}class hn extends de{constructor(){super(),this.setOperationName("UpdateServiceDetails")}async doSend(){this.sendAppIdentifier(),this.send()}async send(){const t=`
86
108
  ${this.queryType} ${this.operationName}(
87
109
  $apiKey: String!,
88
110
  $serviceUuid: String!,
@@ -102,4 +124,4 @@
102
124
 
103
125
  )
104
126
  }
105
- `,s=this.getVariables({serviceIdentifier:A().serviceIdentifier,serviceVersion:A().serviceVersion,serviceAdditionalMetadata:A().serviceAdditionalMetadata});H(this.endpoint,this.operationName,r,s)}}exports.ContextManager=w,exports.addOrUpdateMetadata=function(i,r={},s,g=!1){const a=A();new he(a.apiKey).addOrUpdateMetadata(i,r,s,g)},exports.identify=function(i,r,s,g=!1){const a=A();new he(a.apiKey).identify(i,r,s,g)},exports.runWithContext=function(i){const r={...w.getInstance().getCurrentContext()};J.run(r,()=>{i()})},exports.setupInterceptors=function(i){if(!i||!i.apiKey){const a=`The required API Key is not provided: ${JSON.stringify(i)}`;console.error(a)}const{config:r}=ze(i);if(r.sfDebug&&console.log("Updated configuration after applying options:",r),!r.apiKey||!r.apiGraphqlEndpoint){const a=`The required config is not provided: ${JSON.stringify(r)}`;throw console.error(a),new Error(a)}const s=new le;s.setServiceUUID(r.serviceUUID),(function(a){function t(l,d){a.setOperationName("CollectLogs"),a.doSend([d,l])}const o=console.log.bind(console),c=console.error.bind(console),I=console.warn.bind(console),p=console.info.bind(console),C=console.debug.bind(console);console.log=(...l)=>{t("INFO",l.join(" ")),o(...l)},console.error=(...l)=>{t("ERROR",l.join(" ")),c(...l)},console.warn=(...l)=>{t("WARN",l.join(" ")),I(...l)},console.info=(...l)=>{t("INFO",l.join(" ")),p(...l)},A().logLevel==="DEBUG"&&(console.debug=(...l)=>{t("DEBUG",l.join(" ")),C(...l)})})(s),(function(a=[]){const t=new gt(a);new st().doSend(t.getExcludedDomains());const o=new at,c=new ct;t.patchFetch(o,c),t.patchHttp(o,c)})(r.domainsToNotPropagateHeadersTo);const g=new ot;g.setServiceUUID(r.serviceUUID),tt(g),it(),new lt().send()};
127
+ `,s=this.getVariables({serviceIdentifier:A().serviceIdentifier,serviceVersion:A().serviceVersion,serviceAdditionalMetadata:A().serviceAdditionalMetadata});H(this.endpoint,this.operationName,t,s)}}exports.ContextManager=w,exports.addOrUpdateMetadata=function(i,t={},s,l=!1){const a=A();new me(a.apiKey).addOrUpdateMetadata(i,t,s,l)},exports.identify=function(i,t,s,l=!1){const a=A();new me(a.apiKey).identify(i,t,s,l)},exports.runWithContext=function(i){const t={...w.getInstance().getCurrentContext()};X.run(t,()=>{i()})},exports.setupInterceptors=function(i){if(!i||!i.apiKey){const a=`The required API Key is not provided: ${JSON.stringify(i)}`;console.error(a)}const{config:t}=je(i);if(t.sfDebug&&console.log("Updated configuration after applying options:",t),!t.apiKey||!t.apiGraphqlEndpoint){const a=`The required config is not provided: ${JSON.stringify(t)}`;throw console.error(a),new Error(a)}const s=new de;s.setServiceUUID(t.serviceUUID),(function(a){function n(g,I){a.setOperationName("CollectLogs"),a.doSend([I,g])}const o=console.log.bind(console),c=console.error.bind(console),d=console.warn.bind(console),p=console.info.bind(console),C=console.debug.bind(console);console.log=(...g)=>{n("INFO",g.join(" ")),o(...g)},console.error=(...g)=>{n("ERROR",g.join(" ")),c(...g)},console.warn=(...g)=>{n("WARN",g.join(" ")),d(...g)},console.info=(...g)=>{n("INFO",g.join(" ")),p(...g)},A().logLevel==="DEBUG"&&(console.debug=(...g)=>{n("DEBUG",g.join(" ")),C(...g)})})(s),(function(a=[]){const n=new pn(a);new un().doSend(n.getExcludedDomains());const o=new dn,c=new In;n.patchFetch(o,c),n.patchHttp(o,c)})(t.domainsToNotPropagateHeadersTo);const l=new ln;l.setServiceUUID(t.serviceUUID),sn(l),gn(),new hn().send()};