hud-sdk 1.8.1 → 1.8.2-rc.451c8fe.0

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,2 +1,2 @@
1
- !function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t=n();for(var i in t)("object"==typeof exports?exports:e)[i]=t[i]}}(global,()=>(()=>{"use strict";var e={1569:e=>{e.exports=require("zod")},2210:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SDK_MODULE_NAME=void 0,n.SDK_MODULE_NAME="hud-sdk"},2509:function(e,n,t){var i=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t);var a=Object.getOwnPropertyDescriptor(n,t);a&&!("get"in a?!n.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,i,a)}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),a=this&&this.__exportStar||function(e,n){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(n,t)||i(n,e,t)};Object.defineProperty(n,"__esModule",{value:!0}),n.SDK_VERSION=n.SDK_MODULE_NAME=void 0,a(t(2887),n),a(t(2570),n);var o=t(2210);Object.defineProperty(n,"SDK_MODULE_NAME",{enumerable:!0,get:function(){return o.SDK_MODULE_NAME}}),a(t(7089),n);var r=t(5453);Object.defineProperty(n,"SDK_VERSION",{enumerable:!0,get:function(){return r.SDK_VERSION}})},2570:(e,n,t)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.refreshInvestigationEnabled=function(e,n,t){if(null==e)return;const a=i.HudDynamicConfigSchema.deepPartial().safeParse(e);if(!a.success)return;const o=a.data?.enableInvestigation;if(void 0===o)return;o!==globalThis.hudEnableInvestigation&&(n.isInvestigationEnabledByEnv||(globalThis.hudEnableInvestigation=o,t.info("Periodic refresh - Dynamic configuration updated - enableInvestigation",{hudEnableInvestigation:o})))},n.updateDynamicConfig=function(e,n,t){const o=i.HudDynamicConfigSchema.deepPartial().safeParse(e);if(!o.success)return t.error("Dynamic configuration not updated - Invalid configuration override",{remoteConfigParseResult:o,remoteConfig:e}),n.dynamicConfig;const r=a(n.dynamicConfig,o.data);return void 0!==r.enableInvestigation&&r.enableInvestigation!==n.dynamicConfig.enableInvestigation&&(t.info("Dynamic configuration updated - enableInvestigation",{hudEnableInvestigation:r.enableInvestigation}),n.isInvestigationEnabledByEnv||(globalThis.hudEnableInvestigation=r.enableInvestigation)),void 0!==r.enableInvestigationArgsSending&&r.enableInvestigationArgsSending!==n.dynamicConfig.enableInvestigationArgsSending&&(t.info("Dynamic configuration updated - enableInvestigationArgsSending",{hudEnableInvestigationArgsSending:r.enableInvestigationArgsSending}),globalThis.hudEnableInvestigationArgsSending=r.enableInvestigationArgsSending),void 0!==r?.investigationRateLimits?.executionFlowMaxLength&&r?.investigationRateLimits?.executionFlowMaxLength!==n.dynamicConfig.investigationRateLimits.executionFlowMaxLength&&(globalThis.hudExecutionFlowMaxLength=r.investigationRateLimits.executionFlowMaxLength),void 0!==r?.investigationRateLimits?.exceptionMaxLength&&r?.investigationRateLimits?.exceptionMaxLength!==n.dynamicConfig.investigationRateLimits.exceptionMaxLength&&(globalThis.hudExceptionMaxLength=r.investigationRateLimits.exceptionMaxLength),r};const i=t(2887);function a(e,n){if(null===n||"object"!=typeof n)return n;if(Array.isArray(e)&&Array.isArray(n))return n;const t={...e};for(const i in n){const o=e[i],r=n[i];t[i]=a(o,r)}return t}},2887:function(e,n,t){var i,a=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t);var a=Object.getOwnPropertyDescriptor(n,t);a&&!("get"in a?!n.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,i,a)}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),o=this&&this.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),r=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var n=[];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[n.length]=t);return n},i(e)},function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var t=i(e),r=0;r<t.length;r++)"default"!==t[r]&&a(n,e,t[r]);return o(n,e),n});Object.defineProperty(n,"__esModule",{value:!0}),n.HudFailedReadConfigError=n.loggerConfig=n.hudConfig=n.HudDynamicConfigSchema=void 0,n.functionUuidToBase64=c,n.getModulesToTraceFromEnv=function(){const e=process.env.HUD_MONITOR_MODULES||process.env.HUD_INCLUDE_MODULES;if(e)return e.split(",")},n.getExcludeDirsFromEnv=function(){const e=process.env.HUD_EXCLUDE_DIRS;if(e)return e.split(",")},n.getFrameworksToEnableFromEnv=function(){const e=process.env.HUD_ENABLE_FRAMEWORKS;let n;if(e)try{n=s.availableFrameworksSchema.parse(JSON.parse(e))}catch{n=new Map}return n},n.isValidParam=function(e){return null!=e&&""!==e&&"string"==typeof e},n.updateInvestigationRateLimitGlobals=function(){globalThis.hudMaxSameInvestigations=n.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations,globalThis.hudMaxTotalInvestigations=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations,globalThis.hudSameInvestigationTimeWindowNs=BigInt(n.hudConfig.dynamicConfig.investigationRateLimits.sameInvestigationTimeWindowMs)*BigInt(1e6),globalThis.hudTotalInvestigationTimeWindowNs=BigInt(n.hudConfig.dynamicConfig.investigationRateLimits.totalInvestigationTimeWindowMs)*BigInt(1e6)};const s=t(8528),l=r(t(6928)),u=t(3903),d=t(1569);function c(e){return Buffer.from((0,u.parse)(e)).toString("base64").slice(0,22)}const m="globalThis._hudMark";n.HudDynamicConfigSchema=d.z.object({aggregationInterval:d.z.number(),aggregationFirstSendTimeout:d.z.number(),investigationInterval:d.z.number(),investigationFirstSendTimeout:d.z.number(),enableInvestigation:d.z.boolean(),enableInvestigationArgsSending:d.z.boolean(),investigationRateLimits:d.z.object({maxSameInvestigations:d.z.number().int().positive(),sameInvestigationTimeWindowMs:d.z.number().int().positive(),maxTotalInvestigations:d.z.number().int().positive(),maxTotalInvestigationsErrorBased:d.z.number().int().positive(),maxTotalInvestigationsDurationBased:d.z.number().int().positive(),totalInvestigationTimeWindowMs:d.z.number().int().positive(),maxUniqLogs:d.z.number().int().positive(),maxStringLength:d.z.number().int().positive(),maxArrayLength:d.z.number().int().positive(),maxObjectDepth:d.z.number().int().positive(),maxKeyLength:d.z.number().int().positive(),executionFlowMaxLength:d.z.number().int().positive(),exceptionMaxLength:d.z.number().int().positive(),maxUniqueSetFailureErrors:d.z.number().int().positive()}),machineMetricsInterval:d.z.number().int().positive(),blacklistParams:d.z.array(d.z.string()),forensicsBlacklistFields:d.z.array(d.z.string()),forensicsWhitelistFields:d.z.array(d.z.string()),censorshipRegexes:d.z.array(d.z.object({regex:d.z.string(),replacement:d.z.string()})),reingestInterval:d.z.number().int().positive(),extraHeaders:d.z.array(d.z.string()),performanceMetricsInterval:d.z.number().int().positive(),enableOutboundData:d.z.boolean(),maxTotalOutbounds:d.z.number().int().positive(),maxOutboundCountWithData:d.z.number().int().positive(),maxHTTPRequestBodySize:d.z.number().int().positive(),maxHTTPResponseBodySize:d.z.number().int().positive(),functionDetachEnabled:d.z.boolean(),functionDetachThresholdPerSecond:d.z.number().int().positive()});const g=process.env.HUD_ENABLE_INVESTIGATION,v="_HUD",p="94a210f3-861c-4e18-ab27-6b6c19437c9d",b={sink:{url:process.env.HUD_HOST||"https://api-prod.hud.io",timeout:5e3,session_attr:"X-Session-ID"},endpoints:{init:"sink/init",send:"sink/send",batch:"sink/batch",logs:"sink/logs",sessionslessLogs:"sink/sessionless-logs",fatalError:"sink/redline",getMode:"sink/getMode",getRemoteConfig:"sink/remote-config/get",fileDeclarations:"sink/file-declarations",sourceMap:"sink/sourcemap",storeObject:"sink/objects/store",getUploadUrls:"sink/registry/get-upload-urls",triggerReingest:"sink/registry/reingest",validateToken:"sink/registry/validate",fileDeclarationsCi:"sink/registry/file-declarations",completed:"sink/registry/completed",endpointsDurationsInvestigationThresholds:"sink/endpoint-configuration",getKnownDetachedFunctions:"sink/known-detached-functions/get",setDetachedFunctions:"sink/known-detached-functions/set"},logger:{default:{levels:{app:"warning",worker:"warning",instrument:"warning"}},debug:{levels:{app:"debug",worker:"debug",instrument:"debug"}}},investigation:{objectVersion:"1.0.2",store:{type:"s3"}},userConfig:{lean:{value:!1,source:"DEFAULT"},minPodMemoryMB:{value:250,source:"DEFAULT"},maxMappedFunctions:{value:5e4,source:"DEFAULT"},maxFileSizeBytes:{value:2831155,source:"DEFAULT"},maxTimeUntilInitSessionMs:{value:3e4,source:"DEFAULT"},includeModules:{value:[],source:"DEFAULT"},excludeDirs:{value:[],source:"DEFAULT"},disableRuntimeInstrumentation:{value:!1,source:"DEFAULT"},disableParametersExtraction:{value:!1,source:"DEFAULT"},disableDetachedFunctions:{value:!1,source:"DEFAULT"},enableVarHoisting:{value:!1,source:"DEFAULT"},instrumentOneLiners:{value:!0,source:"DEFAULT"}},loggerWorkerPortSizeLimit:1e4,customerLoggerLevel:"info",logDirectory:process.env.HUD_LOG_DIR,invocationSampling:new Map([[[300n,null],100],[[200n,300n],50],[[100n,200n],25],[[0n,100n],10]]),callerResetInterval:36e5,modeInterval:3e5,logsSendInterval:6e4,endpointsInterval:3e4,endpointsFirstSendWaitTime:12e4,lazyEndpointsInterval:18e5,staticNextJsEndpointsInterval:1e4,staticNextJsEndpointsMaxAttempts:12,huddBinWidth:1.2,endpointsDurationsInvestigationThresholdsInterval:6e5,remoteConfigRefreshInterval:3e5,workerStateCollectionDelay:6e5,workerGrace:6e4,workerTimeout:2e4,timeoutOnRegister:6e4,timeoutOnMetrics:6e4,workerMessageTimeout:1e4,communicationBatchSize:100,writePatched:!1,defaultOff:!0,disableOnBadApiKey:!0,disableOnBadServiceName:!0,cpuTimeCollection:!1,workloadMetadata:{sendInterval:3e5,aws:{imds:{baseURL:"http://169.254.169.254/latest",tokenURI:"/api/token",identityURI:"/dynamic/instance-identity/document",lifeCycleURI:"/meta-data/instance-life-cycle",requestTimeout:5e3},metadataFile:"/run/cloud-init/instance-data.json"},kubernetes:{namespaceFile:"/var/run/secrets/kubernetes.io/serviceaccount/namespace",uuidFile:"/sys/class/dmi/id/product_uuid",podMemoryLimitFile:"/sys/fs/cgroup/memory/memory.stat",podCPULimitFile:"/sys/fs/cgroup/cpuacct/cpu.shares"}},deleteLogsAfterSending:!0,supportSourceMap:!0,editInline:!0,bundlerBuildIdVarName:"hudFileBuildID",bundlerBuildUuidNamespace:"00c1e90b-af75-4d8e-9935-68485877f759",functionUuidNamespace:p,wrapVarPrefix:v,functionInitFunctionName:`${v}i`,functionCatchFunctionName:`${v}c`,functionFinallyFunctionName:`${v}n`,callContextVarName:`${v}x`,fixStackFunctionName:`${v}s`,asyncIteratorWrapperFunctionName:`${v}w`,wrapperUserCatchFunctionName:`${v}u`,asyncWrapperFunctionName:`${v}a`,internalAsyncWrapperFunctionName:`${v}b`,frameworksToPatch:new Map([["express",{framework:s.availableFrameworks.express,enable:!0,version:"<=5",patcher:"express",enableEsbuild:!0}],[l.join("express","lib","application.js"),{framework:s.availableFrameworks.express,enable:!0,version:"<=5",patcher:"expressApplication",enableEsbuild:!0}],["router",{framework:s.availableFrameworks.express,enable:!0,version:"^2.0.0",patcher:"router",enableEsbuild:!0}],["koa",{framework:s.availableFrameworks.koa,enable:!0,version:"^2.0.0",patcher:"koa"}],["graphql/execution/execute",{framework:s.availableFrameworks.graphql,enable:!1,version:"14 - 16",patcher:"graphql"}],["http",{framework:s.availableFrameworks.http,enable:!0,version:"*",patcher:"http"}],["https",{framework:s.availableFrameworks.https,enable:!0,version:"*",patcher:"http"}],["next/dist/server/base-server",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextjs"}],["next/dist/server/lib/module-loader/route-module-loader",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextJsModuleLoader"}],["next/dist/compiled/next-server/pages-api.runtime.prod",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextJsRouteModule"}],["next/dist/server/config",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextJsConfig"}],["@nestjs/core/router/router-execution-context",{framework:s.availableFrameworks.nestjs,enable:!0,version:"*",patcher:"nestjsRouterExecutionContext"}],["kafkajs",{framework:s.availableFrameworks.kafkajs,enable:"win32"!==process.platform,version:">=1.4.0",patcher:"kafkajs"}],["@confluentinc/kafka-javascript",{framework:s.availableFrameworks.confluentKafkaJs,enable:!1,version:">=1.4.0",patcher:"confluentKafkaJs"}],["@nestjs/microservices/context/rpc-context-creator",{framework:s.availableFrameworks.nestjs,enable:"win32"!==process.platform,version:">=7.0.0",patcher:"nestjsRpcContextCreator"}],[["@codegenie/serverless-express","src","frameworks","express.js"].join(l.sep),{framework:s.availableFrameworks.codegenieServerlessExpress,enable:!0,version:"^4.1.0",patcher:"codeGenieServerlessExpress",enableEsbuild:!0}],["@codegenie/serverless-express",{framework:s.availableFrameworks.codegenieServerlessExpress,enable:!0,enableEsbuild:!0}],["sqs-consumer",{framework:s.availableFrameworks.sqs,enable:!0,version:"*",patcher:"sqsConsumer",extraInfo:{mondayVersion:">=6.1.0",bbcVersion:">=7.5.0"}}],["serverless-http",{framework:s.availableFrameworks.serverlessHttp,enable:!0,enableEsbuild:!0}],[l.join("serverless-http","lib","framework","get-framework.js"),{framework:s.availableFrameworks.serverlessHttp,enable:!0,version:"^2.7.0",patcher:"serverlessHttp",enableEsbuild:!0}],["axios",{framework:s.availableFrameworks.axios,enable:!0,version:">0.18.0 <1.0.0 || ^1.0.0",patcher:"outbound/axios",mainFilePath:"axios/dist/node/axios.cjs",extraInfo:{isOutbound:!0}}],["node-fetch",{framework:s.availableFrameworks.nodeFetch,enable:!0,version:"^2.0.0",patcher:"outbound/nodeFetch",mainFilePath:"node-fetch/lib/index.js",extraInfo:{isOutbound:!0}}],["request",{framework:s.availableFrameworks.request,enable:!0,version:"2.88.2",patcher:"outbound/request",extraInfo:{isOutbound:!0}}],["pg",{framework:s.availableFrameworks.pg,enable:!0,version:"^8.8.0",patcher:"outbound/pg",extraInfo:{isOutbound:!0}}],["ioredis",{framework:s.availableFrameworks.ioredis,enable:!0,version:"^4.0.0 || ^5.0.0",patcher:"outbound/ioredis",extraInfo:{isOutbound:!0}}],["p-limit",{framework:"p-limit",enable:!0,version:"^3.0.0",patcher:"internal/pLimit"}]]),communicationKeepalive:!1,communicationKeepaliveGrace:5e3,express:{routeNamesSymbol:Symbol.for("hudRoutes"),layerStateSymbol:Symbol.for("hudState"),markedSymbol:Symbol.for("hudMarked"),wrapAllCallbacks:!0},supportedNodeVersions:["18","20","21","22","24"],hudPatchedName:"hudPatched",metricSymbol:Symbol.for("hudMetric"),dynamicConfig:{aggregationInterval:3e5,aggregationFirstSendTimeout:3e4,investigationInterval:5e3,investigationFirstSendTimeout:3e4,enableInvestigation:"true"===g,enableInvestigationArgsSending:!1,investigationRateLimits:{maxSameInvestigations:2,sameInvestigationTimeWindowMs:36e5,maxTotalInvestigations:25,maxTotalInvestigationsErrorBased:25,maxTotalInvestigationsDurationBased:20,totalInvestigationTimeWindowMs:216e5,maxUniqLogs:2,executionFlowMaxLength:20,exceptionMaxLength:20,maxStringLength:1024,maxArrayLength:10,maxObjectDepth:3,maxKeyLength:30,maxUniqueSetFailureErrors:100},machineMetricsInterval:1e4,performanceMetricsInterval:6e4,reingestInterval:3e4,extraHeaders:[],enableOutboundData:"true"===process.env.HUD_ENABLE_OUTBOUND_DATA,maxHTTPRequestBodySize:1024,maxHTTPResponseBodySize:5120,blacklistParams:[],censorshipRegexes:[],forensicsBlacklistFields:[],forensicsWhitelistFields:[],maxOutboundCountWithData:process.env.HUD_MAX_OUTBOUND_WITH_DATA?parseInt(process.env.HUD_MAX_OUTBOUND_WITH_DATA):10,maxTotalOutbounds:20,functionDetachEnabled:!1,functionDetachThresholdPerSecond:5833},machineMetricsSavedLength:2,isInvestigationEnabledByEnv:void 0!==g,suppressTraces:"true"!==process.env.HUD_DISABLE_SUPPRESS_TRACES,lambdaMinimunMemory:1024,lambdaBaseGivenTime:400,lambdaExtraGivenTimePerRequest:50,lambdaMaxGivenTime:700,throttleStatusCode:202,axiosFunctionId:c((0,u.v5)("axios",p)),nodeFetchFunctionId:c((0,u.v5)("node-fetch",p)),nodeFetchBodiesFunctionIds:{json:c((0,u.v5)("node-fetch-body-json",p)),text:c((0,u.v5)("node-fetch-body-text",p)),arrayBuffer:c((0,u.v5)("node-fetch-body-arrayBuffer",p)),blob:c((0,u.v5)("node-fetch-body-blob",p))},requestFunctionId:c((0,u.v5)("request-request",p)),requestMethodFunctionIds:{get:c((0,u.v5)("request-get",p)),head:c((0,u.v5)("request-head",p)),options:c((0,u.v5)("request-options",p)),post:c((0,u.v5)("request-post",p)),put:c((0,u.v5)("request-put",p)),patch:c((0,u.v5)("request-patch",p)),del:c((0,u.v5)("request-del",p)),delete:c((0,u.v5)("request-delete",p))},pgConnectFunctionId:c((0,u.v5)("pg-connect",p)),pgQueryFunctionId:c((0,u.v5)("pg-query",p)),pgEndFunctionId:c((0,u.v5)("pg-end",p)),functionsToInstrument:[{moduleName:"typeorm",fileToFunctionsMapping:{[l.join(l.sep,"typeorm","repository","Repository.js")]:["hasId","getId","create","merge","preload","save","remove","softRemove","recover","insert","update","upsert","delete","softDelete","restore","exist","exists","existsBy","count","countBy","sum","average","minimum","maximum","find","findBy","findAndCount","findAndCountBy","findByIds","findOne","findOneBy","findOneById","findOneOrFail","findOneByOrFail","query","clear","increment","decrement","extend"]}}],esbuildGlobalVar:"hudSGV",esbuildFunctionIdVar:"hudFI",esbuildPluginMessagePrefix:"ESBuild plugin ",esbuildMark:"modifiedByHudESBuildPlugin-",esbuildMarkLength:67,esbuildUploadSourceMapTimeout:15e3,esbuildPluginLogsChunkSize:100,esbuildPluginLogsBatchSize:10,pluginsLogEndpoint:"https://yqp37dddrsewm6wdwwpwfraxqm0shdmx.lambda-url.eu-central-1.on.aws/",uninstrumentedFilesLogThreshold:2,tsNodeConfigTimeout:1e4,allowedEditExtensions:[".ts",".cts",".mts",".js",".cjs",".mjs"],nextJsMarkVarName:m,nextJsMarkStatement:`${m} = "a"`,timeoutOnNextJsPlugin:3e4,logIntervals:{instrumentedFilesCount:5e3,sentEventsCount:12e4},cliBuildIdVarName:"hudCliBuildId",cliSdkVersionVarName:"hudCliSdkVersion"};n.hudConfig=function(e={}){return{...b,...e}}({logger:{default:{levels:{app:"info",worker:"info",instrument:"info"}},debug:{levels:{app:"debug",worker:"debug",instrument:"debug"}}},deleteLogsAfterSending:!1,communicationKeepalive:!0}),n.default=n.hudConfig;const f=process.env.HUD_DEBUG?n.hudConfig.logger.debug:n.hudConfig.logger.default;n.loggerConfig={...f,console:"true"===process.env.HUD_VERBOSE};class h extends Error{path;code;constructor(e,n){super(),this.path=e,this.code=n}}n.HudFailedReadConfigError=h},3903:e=>{e.exports=require("uuid")},5453:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SDK_VERSION=void 0,n.SDK_VERSION="1.8.1"},6928:e=>{e.exports=require("path")},7089:(e,n,t)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ObjectStoreConfigSchema=void 0;const i=t(1569),a=i.z.object({type:i.z.literal("s3")}),o=i.z.object({type:i.z.literal("disk"),path:i.z.string()});n.ObjectStoreConfigSchema=i.z.union([a,o])},8528:e=>{e.exports=require("./dto")}},n={};return function t(i){var a=n[i];if(void 0!==a)return a.exports;var o=n[i]={exports:{}};return e[i].call(o.exports,o,o.exports,t),o.exports}(2509)})());
1
+ !function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t=n();for(var i in t)("object"==typeof exports?exports:e)[i]=t[i]}}(global,()=>(()=>{"use strict";var e={1569:e=>{e.exports=require("zod")},2210:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SDK_MODULE_NAME=void 0,n.SDK_MODULE_NAME="hud-sdk"},2509:function(e,n,t){var i=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t);var a=Object.getOwnPropertyDescriptor(n,t);a&&!("get"in a?!n.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,i,a)}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),a=this&&this.__exportStar||function(e,n){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(n,t)||i(n,e,t)};Object.defineProperty(n,"__esModule",{value:!0}),n.SDK_VERSION=n.SDK_MODULE_NAME=void 0,a(t(2887),n),a(t(2570),n);var o=t(2210);Object.defineProperty(n,"SDK_MODULE_NAME",{enumerable:!0,get:function(){return o.SDK_MODULE_NAME}}),a(t(7089),n);var r=t(5453);Object.defineProperty(n,"SDK_VERSION",{enumerable:!0,get:function(){return r.SDK_VERSION}})},2570:(e,n,t)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.refreshInvestigationEnabled=function(e,n,t){if(null==e)return;const a=i.HudDynamicConfigSchema.deepPartial().safeParse(e);if(!a.success)return;const o=a.data?.enableInvestigation;if(void 0===o)return;o!==globalThis.hudEnableInvestigation&&(n.isInvestigationEnabledByEnv||(globalThis.hudEnableInvestigation=o,t.info("Periodic refresh - Dynamic configuration updated - enableInvestigation",{hudEnableInvestigation:o})))},n.updateDynamicConfig=function(e,n,t){const o=i.HudDynamicConfigSchema.deepPartial().safeParse(e);if(!o.success)return t.error("Dynamic configuration not updated - Invalid configuration override",{remoteConfigParseResult:o,remoteConfig:e}),n.dynamicConfig;const r=a(n.dynamicConfig,o.data);return void 0!==r.enableInvestigation&&r.enableInvestigation!==n.dynamicConfig.enableInvestigation&&(t.info("Dynamic configuration updated - enableInvestigation",{hudEnableInvestigation:r.enableInvestigation}),n.isInvestigationEnabledByEnv||(globalThis.hudEnableInvestigation=r.enableInvestigation)),void 0!==r.enableInvestigationArgsSending&&r.enableInvestigationArgsSending!==n.dynamicConfig.enableInvestigationArgsSending&&(t.info("Dynamic configuration updated - enableInvestigationArgsSending",{hudEnableInvestigationArgsSending:r.enableInvestigationArgsSending}),globalThis.hudEnableInvestigationArgsSending=r.enableInvestigationArgsSending),void 0!==r?.investigationRateLimits?.executionFlowMaxLength&&r?.investigationRateLimits?.executionFlowMaxLength!==n.dynamicConfig.investigationRateLimits.executionFlowMaxLength&&(globalThis.hudExecutionFlowMaxLength=r.investigationRateLimits.executionFlowMaxLength),void 0!==r?.investigationRateLimits?.exceptionMaxLength&&r?.investigationRateLimits?.exceptionMaxLength!==n.dynamicConfig.investigationRateLimits.exceptionMaxLength&&(globalThis.hudExceptionMaxLength=r.investigationRateLimits.exceptionMaxLength),r};const i=t(2887);function a(e,n){if(null===n||"object"!=typeof n)return n;if(Array.isArray(e)&&Array.isArray(n))return n;const t={...e};for(const i in n){const o=e[i],r=n[i];t[i]=a(o,r)}return t}},2887:function(e,n,t){var i,a=this&&this.__createBinding||(Object.create?function(e,n,t,i){void 0===i&&(i=t);var a=Object.getOwnPropertyDescriptor(n,t);a&&!("get"in a?!n.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,i,a)}:function(e,n,t,i){void 0===i&&(i=t),e[i]=n[t]}),o=this&&this.__setModuleDefault||(Object.create?function(e,n){Object.defineProperty(e,"default",{enumerable:!0,value:n})}:function(e,n){e.default=n}),r=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var n=[];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[n.length]=t);return n},i(e)},function(e){if(e&&e.__esModule)return e;var n={};if(null!=e)for(var t=i(e),r=0;r<t.length;r++)"default"!==t[r]&&a(n,e,t[r]);return o(n,e),n});Object.defineProperty(n,"__esModule",{value:!0}),n.HudFailedReadConfigError=n.loggerConfig=n.hudConfig=n.HudDynamicConfigSchema=void 0,n.functionUuidToBase64=c,n.getModulesToTraceFromEnv=function(){const e=process.env.HUD_MONITOR_MODULES||process.env.HUD_INCLUDE_MODULES;if(e)return e.split(",")},n.getExcludeDirsFromEnv=function(){const e=process.env.HUD_EXCLUDE_DIRS;if(e)return e.split(",")},n.getFrameworksToEnableFromEnv=function(){const e=process.env.HUD_ENABLE_FRAMEWORKS;let n;if(e)try{n=s.availableFrameworksSchema.parse(JSON.parse(e))}catch{n=new Map}return n},n.isValidParam=function(e){return null!=e&&""!==e&&"string"==typeof e},n.updateInvestigationRateLimitGlobals=function(){globalThis.hudMaxSameInvestigations=n.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations,globalThis.hudMaxTotalInvestigations=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations,globalThis.hudSameInvestigationTimeWindowNs=BigInt(n.hudConfig.dynamicConfig.investigationRateLimits.sameInvestigationTimeWindowMs)*BigInt(1e6),globalThis.hudTotalInvestigationTimeWindowNs=BigInt(n.hudConfig.dynamicConfig.investigationRateLimits.totalInvestigationTimeWindowMs)*BigInt(1e6)};const s=t(8528),l=r(t(6928)),u=t(3903),d=t(1569);function c(e){return Buffer.from((0,u.parse)(e)).toString("base64").slice(0,22)}const m="globalThis._hudMark";n.HudDynamicConfigSchema=d.z.object({aggregationInterval:d.z.number(),aggregationFirstSendTimeout:d.z.number(),investigationInterval:d.z.number(),investigationFirstSendTimeout:d.z.number(),enableInvestigation:d.z.boolean(),enableInvestigationArgsSending:d.z.boolean(),investigationRateLimits:d.z.object({maxSameInvestigations:d.z.number().int().positive(),sameInvestigationTimeWindowMs:d.z.number().int().positive(),maxTotalInvestigations:d.z.number().int().positive(),maxTotalInvestigationsErrorBased:d.z.number().int().positive(),maxTotalInvestigationsDurationBased:d.z.number().int().positive(),totalInvestigationTimeWindowMs:d.z.number().int().positive(),maxUniqLogs:d.z.number().int().positive(),maxStringLength:d.z.number().int().positive(),maxArrayLength:d.z.number().int().positive(),maxObjectDepth:d.z.number().int().positive(),maxKeyLength:d.z.number().int().positive(),executionFlowMaxLength:d.z.number().int().positive(),exceptionMaxLength:d.z.number().int().positive(),maxUniqueSetFailureErrors:d.z.number().int().positive()}),machineMetricsInterval:d.z.number().int().positive(),blacklistParams:d.z.array(d.z.string()),forensicsBlacklistFields:d.z.array(d.z.string()),forensicsWhitelistFields:d.z.array(d.z.string()),censorshipRegexes:d.z.array(d.z.object({regex:d.z.string(),replacement:d.z.string()})),reingestInterval:d.z.number().int().positive(),extraHeaders:d.z.array(d.z.string()),performanceMetricsInterval:d.z.number().int().positive(),enableOutboundData:d.z.boolean(),maxTotalOutbounds:d.z.number().int().positive(),maxOutboundCountWithData:d.z.number().int().positive(),maxHTTPRequestBodySize:d.z.number().int().positive(),maxHTTPResponseBodySize:d.z.number().int().positive(),functionDetachEnabled:d.z.boolean(),functionDetachThresholdPerSecond:d.z.number().int().positive(),enableMongoDocumentData:d.z.boolean()});const g=process.env.HUD_ENABLE_INVESTIGATION,v="_HUD",b="94a210f3-861c-4e18-ab27-6b6c19437c9d",p={sink:{url:process.env.HUD_HOST||"https://api-prod.hud.io",timeout:5e3,session_attr:"X-Session-ID"},endpoints:{init:"sink/init",send:"sink/send",batch:"sink/batch",logs:"sink/logs",sessionslessLogs:"sink/sessionless-logs",fatalError:"sink/redline",getMode:"sink/getMode",getRemoteConfig:"sink/remote-config/get",fileDeclarations:"sink/file-declarations",sourceMap:"sink/sourcemap",storeObject:"sink/objects/store",getUploadUrls:"sink/registry/get-upload-urls",triggerReingest:"sink/registry/reingest",validateToken:"sink/registry/validate",fileDeclarationsCi:"sink/registry/file-declarations",completed:"sink/registry/completed",endpointsDurationsInvestigationThresholds:"sink/endpoint-configuration",getKnownDetachedFunctions:"sink/known-detached-functions/get",setDetachedFunctions:"sink/known-detached-functions/set"},logger:{default:{levels:{app:"warning",worker:"warning",instrument:"warning"}},debug:{levels:{app:"debug",worker:"debug",instrument:"debug"}}},investigation:{objectVersion:"1.0.2",store:{type:"s3"}},userConfig:{lean:{value:!1,source:"DEFAULT"},minPodMemoryMB:{value:250,source:"DEFAULT"},maxMappedFunctions:{value:5e4,source:"DEFAULT"},maxFileSizeBytes:{value:2831155,source:"DEFAULT"},maxTimeUntilInitSessionMs:{value:3e4,source:"DEFAULT"},includeModules:{value:[],source:"DEFAULT"},excludeDirs:{value:[],source:"DEFAULT"},disableRuntimeInstrumentation:{value:!1,source:"DEFAULT"},disableParametersExtraction:{value:!1,source:"DEFAULT"},disableDetachedFunctions:{value:!1,source:"DEFAULT"},enableVarHoisting:{value:!1,source:"DEFAULT"},instrumentOneLiners:{value:!0,source:"DEFAULT"}},loggerWorkerPortSizeLimit:1e4,customerLoggerLevel:"info",logDirectory:process.env.HUD_LOG_DIR,invocationSampling:new Map([[[300n,null],100],[[200n,300n],50],[[100n,200n],25],[[0n,100n],10]]),callerResetInterval:36e5,modeInterval:3e5,logsSendInterval:6e4,endpointsInterval:3e4,endpointsFirstSendWaitTime:12e4,lazyEndpointsInterval:18e5,staticNextJsEndpointsInterval:1e4,staticNextJsEndpointsMaxAttempts:12,huddBinWidth:1.2,endpointsDurationsInvestigationThresholdsInterval:6e5,remoteConfigRefreshInterval:3e5,workerStateCollectionDelay:6e5,workerGrace:6e4,workerTimeout:2e4,timeoutOnRegister:6e4,timeoutOnMetrics:6e4,workerMessageTimeout:1e4,communicationBatchSize:100,writePatched:!1,defaultOff:!0,disableOnBadApiKey:!0,disableOnBadServiceName:!0,cpuTimeCollection:!1,workloadMetadata:{sendInterval:3e5,aws:{imds:{baseURL:"http://169.254.169.254/latest",tokenURI:"/api/token",identityURI:"/dynamic/instance-identity/document",lifeCycleURI:"/meta-data/instance-life-cycle",requestTimeout:5e3},metadataFile:"/run/cloud-init/instance-data.json"},kubernetes:{namespaceFile:"/var/run/secrets/kubernetes.io/serviceaccount/namespace",uuidFile:"/sys/class/dmi/id/product_uuid",podMemoryLimitFile:"/sys/fs/cgroup/memory/memory.stat",podCPULimitFile:"/sys/fs/cgroup/cpuacct/cpu.shares"}},deleteLogsAfterSending:!0,supportSourceMap:!0,editInline:!0,bundlerBuildIdVarName:"hudFileBuildID",bundlerBuildUuidNamespace:"00c1e90b-af75-4d8e-9935-68485877f759",functionUuidNamespace:b,wrapVarPrefix:v,functionInitFunctionName:`${v}i`,functionCatchFunctionName:`${v}c`,functionFinallyFunctionName:`${v}n`,callContextVarName:`${v}x`,fixStackFunctionName:`${v}s`,asyncIteratorWrapperFunctionName:`${v}w`,wrapperUserCatchFunctionName:`${v}u`,asyncWrapperFunctionName:`${v}a`,internalAsyncWrapperFunctionName:`${v}b`,frameworksToPatch:new Map([["express",{framework:s.availableFrameworks.express,enable:!0,version:"<=5",patcher:"express",enableEsbuild:!0}],[l.join("express","lib","application.js"),{framework:s.availableFrameworks.express,enable:!0,version:"<=5",patcher:"expressApplication",enableEsbuild:!0}],["router",{framework:s.availableFrameworks.express,enable:!0,version:"^2.0.0",patcher:"router",enableEsbuild:!0}],["koa",{framework:s.availableFrameworks.koa,enable:!0,version:"^2.0.0",patcher:"koa"}],["graphql/execution/execute",{framework:s.availableFrameworks.graphql,enable:!1,version:"14 - 16",patcher:"graphql"}],["http",{framework:s.availableFrameworks.http,enable:!0,version:"*",patcher:"http"}],["https",{framework:s.availableFrameworks.https,enable:!0,version:"*",patcher:"http"}],["next/dist/server/base-server",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextjs"}],["next/dist/server/lib/module-loader/route-module-loader",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextJsModuleLoader"}],["next/dist/compiled/next-server/pages-api.runtime.prod",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextJsRouteModule"}],["next/dist/server/config",{framework:s.availableFrameworks.nextjs,enable:!1,version:">=13.4.0",patcher:"nextJsConfig"}],["@nestjs/core/router/router-execution-context",{framework:s.availableFrameworks.nestjs,enable:!0,version:"*",patcher:"nestjsRouterExecutionContext"}],["kafkajs",{framework:s.availableFrameworks.kafkajs,enable:"win32"!==process.platform,version:">=1.4.0",patcher:"kafkajs"}],["@confluentinc/kafka-javascript",{framework:s.availableFrameworks.confluentKafkaJs,enable:!1,version:">=1.4.0",patcher:"confluentKafkaJs"}],["@nestjs/microservices/context/rpc-context-creator",{framework:s.availableFrameworks.nestjs,enable:"win32"!==process.platform,version:">=7.0.0",patcher:"nestjsRpcContextCreator"}],[["@codegenie/serverless-express","src","frameworks","express.js"].join(l.sep),{framework:s.availableFrameworks.codegenieServerlessExpress,enable:!0,version:"^4.1.0",patcher:"codeGenieServerlessExpress",enableEsbuild:!0}],["@codegenie/serverless-express",{framework:s.availableFrameworks.codegenieServerlessExpress,enable:!0,enableEsbuild:!0}],["sqs-consumer",{framework:s.availableFrameworks.sqs,enable:!0,version:">=7.5.0",patcher:"sqsConsumer"}],["@mondaydotcomorg/monday-sqs-consumer",{framework:s.availableFrameworks.sqs,enable:!0,version:">=5.2.2 <6",patcher:"sqsConsumer",extraInfo:{isMondayVersion:!0,srcHash:"bd9064befbf3abb9ad0e6a53b0cf721d5612d5b8d8790875c994b7ff40b951c5"}}],["serverless-http",{framework:s.availableFrameworks.serverlessHttp,enable:!0,enableEsbuild:!0}],[l.join("serverless-http","lib","framework","get-framework.js"),{framework:s.availableFrameworks.serverlessHttp,enable:!0,version:"^2.7.0",patcher:"serverlessHttp",enableEsbuild:!0}],["axios",{framework:s.availableFrameworks.axios,enable:!0,version:">0.18.0 <1.0.0 || ^1.0.0",patcher:"outbound/axios",mainFilePath:"axios/dist/node/axios.cjs",extraInfo:{isOutbound:!0}}],["node-fetch",{framework:s.availableFrameworks.nodeFetch,enable:!0,version:"^2.0.0",patcher:"outbound/nodeFetch",mainFilePath:"node-fetch/lib/index.js",extraInfo:{isOutbound:!0}}],["request",{framework:s.availableFrameworks.request,enable:!0,version:"2.88.2",patcher:"outbound/request",extraInfo:{isOutbound:!0}}],["pg",{framework:s.availableFrameworks.pg,enable:!0,version:"^8.8.0",patcher:"outbound/pg",extraInfo:{isOutbound:!0}}],["ioredis",{framework:s.availableFrameworks.ioredis,enable:!0,version:"^4.0.0 || ^5.0.0",patcher:"outbound/ioredis",extraInfo:{isOutbound:!0}}],["mongodb",{framework:s.availableFrameworks.mongodb,enable:!0,version:">=5.0.0 <8.0.0",patcher:"outbound/mongodb",extraInfo:{isOutbound:!0}}],["mongoose",{framework:s.availableFrameworks.mongoose,enable:!0,version:">=5.0.0 <7.0.0",patcher:"outbound/mongoose",extraInfo:{isOutbound:!0}}],["p-limit",{framework:"p-limit",enable:!0,version:"^3.0.0",patcher:"internal/pLimit"}]]),communicationKeepalive:!1,communicationKeepaliveGrace:5e3,express:{routeNamesSymbol:Symbol.for("hudRoutes"),layerStateSymbol:Symbol.for("hudState"),markedSymbol:Symbol.for("hudMarked"),wrapAllCallbacks:!0},supportedNodeVersions:["18","20","21","22","24"],hudPatchedName:"hudPatched",metricSymbol:Symbol.for("hudMetric"),dynamicConfig:{aggregationInterval:3e5,aggregationFirstSendTimeout:3e4,investigationInterval:5e3,investigationFirstSendTimeout:3e4,enableInvestigation:"true"===g,enableInvestigationArgsSending:!1,investigationRateLimits:{maxSameInvestigations:2,sameInvestigationTimeWindowMs:36e5,maxTotalInvestigations:25,maxTotalInvestigationsErrorBased:25,maxTotalInvestigationsDurationBased:20,totalInvestigationTimeWindowMs:216e5,maxUniqLogs:2,executionFlowMaxLength:20,exceptionMaxLength:20,maxStringLength:1024,maxArrayLength:10,maxObjectDepth:3,maxKeyLength:30,maxUniqueSetFailureErrors:100},machineMetricsInterval:1e4,performanceMetricsInterval:6e4,reingestInterval:3e4,extraHeaders:[],enableOutboundData:"true"===process.env.HUD_ENABLE_OUTBOUND_DATA,maxHTTPRequestBodySize:1024,maxHTTPResponseBodySize:5120,blacklistParams:[],censorshipRegexes:[],forensicsBlacklistFields:[],forensicsWhitelistFields:[],maxOutboundCountWithData:process.env.HUD_MAX_OUTBOUND_WITH_DATA?parseInt(process.env.HUD_MAX_OUTBOUND_WITH_DATA):10,maxTotalOutbounds:20,functionDetachEnabled:!1,functionDetachThresholdPerSecond:5833,enableMongoDocumentData:!1},machineMetricsSavedLength:2,isInvestigationEnabledByEnv:void 0!==g,suppressTraces:"true"!==process.env.HUD_DISABLE_SUPPRESS_TRACES,lambdaMinimunMemory:1024,lambdaBaseGivenTime:400,lambdaExtraGivenTimePerRequest:50,lambdaMaxGivenTime:700,throttleStatusCode:202,axiosFunctionId:c((0,u.v5)("axios",b)),nodeFetchFunctionId:c((0,u.v5)("node-fetch",b)),nodeFetchBodiesFunctionIds:{json:c((0,u.v5)("node-fetch-body-json",b)),text:c((0,u.v5)("node-fetch-body-text",b)),arrayBuffer:c((0,u.v5)("node-fetch-body-arrayBuffer",b)),blob:c((0,u.v5)("node-fetch-body-blob",b))},requestFunctionId:c((0,u.v5)("request-request",b)),requestMethodFunctionIds:{get:c((0,u.v5)("request-get",b)),head:c((0,u.v5)("request-head",b)),options:c((0,u.v5)("request-options",b)),post:c((0,u.v5)("request-post",b)),put:c((0,u.v5)("request-put",b)),patch:c((0,u.v5)("request-patch",b)),del:c((0,u.v5)("request-del",b)),delete:c((0,u.v5)("request-delete",b))},pgConnectFunctionId:c((0,u.v5)("pg-connect",b)),pgQueryFunctionId:c((0,u.v5)("pg-query",b)),pgEndFunctionId:c((0,u.v5)("pg-end",b)),functionsToInstrument:[{moduleName:"typeorm",fileToFunctionsMapping:{[l.join(l.sep,"typeorm","repository","Repository.js")]:["hasId","getId","create","merge","preload","save","remove","softRemove","recover","insert","update","upsert","delete","softDelete","restore","exist","exists","existsBy","count","countBy","sum","average","minimum","maximum","find","findBy","findAndCount","findAndCountBy","findByIds","findOne","findOneBy","findOneById","findOneOrFail","findOneByOrFail","query","clear","increment","decrement","extend"]}}],esbuildGlobalVar:"hudSGV",esbuildFunctionIdVar:"hudFI",esbuildPluginMessagePrefix:"ESBuild plugin ",esbuildMark:"modifiedByHudESBuildPlugin-",esbuildMarkLength:67,esbuildUploadSourceMapTimeout:15e3,esbuildPluginLogsChunkSize:100,esbuildPluginLogsBatchSize:10,pluginsLogEndpoint:"https://yqp37dddrsewm6wdwwpwfraxqm0shdmx.lambda-url.eu-central-1.on.aws/",uninstrumentedFilesLogThreshold:2,tsNodeConfigTimeout:1e4,allowedEditExtensions:[".ts",".cts",".mts",".js",".cjs",".mjs"],nextJsMarkVarName:m,nextJsMarkStatement:`${m} = "a"`,timeoutOnNextJsPlugin:3e4,logIntervals:{instrumentedFilesCount:5e3,sentEventsCount:12e4},cliBuildIdVarName:"hudCliBuildId",cliSdkVersionVarName:"hudCliSdkVersion"};n.hudConfig=function(e={}){return{...p,...e}}({logger:{default:{levels:{app:"info",worker:"info",instrument:"info"}},debug:{levels:{app:"debug",worker:"debug",instrument:"debug"}}},deleteLogsAfterSending:!1,communicationKeepalive:!0}),n.default=n.hudConfig;const f=process.env.HUD_DEBUG?n.hudConfig.logger.debug:n.hudConfig.logger.default;n.loggerConfig={...f,console:"true"===process.env.HUD_VERBOSE};class h extends Error{path;code;constructor(e,n){super(),this.path=e,this.code=n}}n.HudFailedReadConfigError=h},3903:e=>{e.exports=require("uuid")},5453:(e,n)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.SDK_VERSION=void 0,n.SDK_VERSION="1.8.2-rc.451c8fe.0"},6928:e=>{e.exports=require("path")},7089:(e,n,t)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ObjectStoreConfigSchema=void 0;const i=t(1569),a=i.z.object({type:i.z.literal("s3")}),o=i.z.object({type:i.z.literal("disk"),path:i.z.string()});n.ObjectStoreConfigSchema=i.z.union([a,o])},8528:e=>{e.exports=require("./dto")}},n={};return function t(i){var a=n[i];if(void 0!==a)return a.exports;var o=n[i]={exports:{}};return e[i].call(o.exports,o,o.exports,t),o.exports}(2509)})());
2
2
  //# sourceMappingURL=config.js.map
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(global,()=>(()=>{"use strict";var e={523:e=>{e.exports=require("./logger")},1145:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createOutboundDeclarations=void 0,t.createAxiosDeclaration=a,t.createNodeFetchDeclaration=c,t.createRequestDeclaration=l,t.createPgDeclaration=u,t.createIoRedisDeclaration=d,t.generateIoRedisFunctionId=p;const i=n(5809),o=n(8528),r=n(3903),s=n(9850);function a(){return[f("axios","Axios","request",i.hudConfig.axiosFunctionId)]}function c(){return[f("node-fetch","node-fetch","fetch",i.hudConfig.nodeFetchFunctionId),...Object.entries(i.hudConfig.nodeFetchBodiesFunctionIds).map(([e,t])=>f("node-fetch","node-fetch",e,t))]}function l(){return[f("request","request","request",i.hudConfig.requestFunctionId),...Object.entries(i.hudConfig.requestMethodFunctionIds).map(([e,t])=>f("request","request",e,t))]}function u(){return[f("pg","Client","connect",i.hudConfig.pgConnectFunctionId),f("pg","Client","query",i.hudConfig.pgQueryFunctionId),f("pg","Client","end",i.hudConfig.pgEndFunctionId)]}function d(e){return e&&0!==e.length?e.map(e=>f("ioredis","Redis",e,p(e))):[]}function p(e){return(0,i.functionUuidToBase64)((0,r.v5)(`ioredis-${e}`,i.hudConfig.functionUuidNamespace))}function f(e,t,n,i){return{id_generated:!0,module:e,third_party_module:e,file:`${e}.js`,format:"commonjs",async:!0,runtime_function_id:(0,s.rawFunctionIdToUuidFunctionId)(i),type:o.EntityType.ClassMethod,methodKind:"method",symbol:{sourcemap_location_hints:[{name:n,line:0,column:0,source:`${e}.js`}],name:n,format:"%s"},scope_chain:[{type:o.EntityType.Program,symbol:{sourcemap_location_hints:[]},context:{},childrenCount:{},siblingIndex:0},{type:o.EntityType.ClassDeclaration,symbol:{sourcemap_location_hints:[{name:t,line:0,column:0,source:`${e}.js`}],name:t,format:"%s"},context:{},childrenCount:{},siblingIndex:0}],original_location:{file:`${e}.js`,start_line:0,end_line:0,start_column:0,end_column:0},parameters:[],start_line:0,end_line:0,start_column:0,source_code_hash:"1",bundler_build_id:"1",was_bundler_build_id_generated:!0,has_input_map:!0,sourcemap_crc:1,file_path_checksum:1,file_checksum:1,declarations_count:1,childrenCount:{},siblingIndex:0,context:{}}}t.createOutboundDeclarations={axios:a,"node-fetch":c,request:l,pg:u,ioredis:d}},1498:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getDeclarationsBatchRequest=function(e){const t=(new Date).toISOString();return{...o.HudClient.defaultRequest,type:"FunctionDeclaration",arr:e,send_time:t,event_version:i.FUNCTION_DECLARATION_VERSION}};const i=n(8528),o=n(4672)},1602:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getScope=function(e,t,n){const r=(0,i.getEntityType)(e);if(r){const s=(0,i.getEntityIdentity)(e.node),a=(0,o.getContextualData)(e,n),c=s?s.loc?[n(s.loc.start,s.name,s.loc.filename??t)]:[]:e.node.loc?[n(e.node.loc.start,void 0,e.node.loc.filename??t)]:[],l=c[0]?.name??s?.name;return{type:r,context:a,symbol:{name:l,sourcemap_location_hints:c,format:l?"%s":void 0},methodKind:(0,o.getMethodKind)(e.node)}}};const i=n(5203),o=n(9127)},2535:function(e,t,n){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSymbolName=function(e){let t=e.name;const n=e.sourcemap_location_hints;if(n.length>0&&n.every(e=>e.name)){const i=n.map(e=>e.name?.startsWith("#")?e.name?.slice(1):e.name);e.format?Array.from(e.format.matchAll(/%s/g)).length!==i.length?o.worker_logger.warning("Format string does not match number of location hints",{format:e.format,locationHints:i}):t=r.default.format(e.format,...i):t=i.join(".")}return t??""},t.getNodeLocation=function(e,t,n=void 0){const i=e.loc?.start,r=e.loc?.end;if(!i||!r)return o.worker_logger.info("Node without location",{filename:n,type:e.type}),{start:{source:null,line:-1,column:-1},end:{source:null,line:-1,column:-1}};const s=t({line:i.line,column:i.column}),a=t({line:r.line,column:r.column});return null!==s.line&&null!==s.column&&null!==a.line&&null!==a.column||(o.worker_logger.debug("Could not find location for function",{filename:n,type:e.type,locStart:i,locEnd:r}),s.line=-1,s.column=-1,a.line=-1,a.column=-1),{start:{source:s.source,line:s.line,column:s.column},end:{source:a.source,line:a.line,column:a.column}}};const o=n(523),r=i(n(9023))},2546:e=>{e.exports=require("./lib")},2784:e=>{e.exports=require("../native/_index")},3176:e=>{e.exports=require("buffer-crc32")},3903:e=>{e.exports=require("uuid")},4634:e=>{e.exports=require("source-map")},4672:e=>{e.exports=require("./client")},5203:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getEntityType=function(e){const{node:t}=e;return i.types.isFunctionDeclaration(t)?o.EntityType.FunctionDeclaration:i.types.isFunctionExpression(t)?o.EntityType.FunctionExpression:i.types.isArrowFunctionExpression(t)?o.EntityType.FunctionArrow:i.types.isObjectMethod(t)?o.EntityType.ObjectMethod:i.types.isStaticBlock(t)||i.types.isClassMethod(t)?o.EntityType.ClassMethod:i.types.isClassPrivateMethod(t)?o.EntityType.ClassPrivateMethod:i.types.isClassDeclaration(t)?o.EntityType.ClassDeclaration:i.types.isClassExpression(t)?o.EntityType.ClassExpression:i.types.isForInStatement(t)||i.types.isForOfStatement(t)||i.types.isForStatement(t)?o.EntityType.ForLoop:i.types.isBlockStatement(t)?function(e){const t=e.parentPath.node;if(!(i.types.isFunctionDeclaration(t)||i.types.isFunctionExpression(t)||i.types.isArrowFunctionExpression(t)||i.types.isClassMethod(t)||i.types.isObjectMethod(t)||i.types.isClassPrivateMethod(t)))if(i.types.isIfStatement(t)){if("consequent"===e.parentKey)return o.EntityType.IfConsequent;if("alternate"===e.parentKey)return o.EntityType.IfAlternate;if("test"===e.parentKey)return o.EntityType.IfTest}else{if(i.types.isBlockStatement(t)||i.types.isProgram(t))return o.EntityType.Block;if(i.types.isTryStatement(t)){if("block"===e.parentKey)return o.EntityType.Try;if("finalizer"===e.parentKey)return o.EntityType.Finally}else{if(i.types.isCatchClause(t))return;if(i.types.isWhileStatement(t))return"test"===e.parentKey?o.EntityType.WhileTest:o.EntityType.Do;if(i.types.isDoWhileStatement(t))return"test"===e.parentKey?o.EntityType.WhileTest:o.EntityType.Do;if(!(i.types.isForStatement(t)||i.types.isForInStatement(t)||i.types.isForOfStatement(t)))return;if("test"===e.parentKey)return o.EntityType.ForTest;if("body"===e.parentKey)return o.EntityType.ForBlock}}}(e):i.types.isProgram(t)?o.EntityType.Program:i.types.isDoWhileStatement(t)?o.EntityType.DoWhile:i.types.isWhileStatement(t)?o.EntityType.While:i.types.isCatchClause(t)?o.EntityType.Catch:i.types.isObjectExpression(t)?o.EntityType.ObjectExpression:i.types.isWithStatement(t)?o.EntityType.With:i.types.isSwitchStatement(t)?o.EntityType.Switch:i.types.isSwitchCase(t)?o.EntityType.SwitchCase:i.types.isTryStatement(t)?o.EntityType.TryCatch:i.types.isIfStatement(t)?o.EntityType.If:o.EntityType.Other},t.getEntityIdentity=function(e){return i.types.isFunctionDeclaration(e)?i.types.isIdentifier(e.id)?e.id:void r.worker_logger.info("Function declaration without an identifier"):i.types.isClassDeclaration(e)?i.types.isIdentifier(e.id)?e.id:void r.worker_logger.info("Class declaration without an identifier"):i.types.isFunctionExpression(e)||i.types.isClassExpression(e)?i.types.isIdentifier(e.id)?e.id:void 0:i.types.isClassMethod(e)?i.types.isIdentifier(e.key)?e.key:void r.worker_logger.info("Class method without an identifier"):i.types.isObjectMethod(e)?i.types.isIdentifier(e.key)?e.key:void r.worker_logger.info("Object method without an identifier"):i.types.isClassPrivateMethod(e)?i.types.isIdentifier(e.key.id)?e.key.id:void r.worker_logger.info("Class private method without an identifier"):void 0};const i=n(6346),o=n(8528),r=n(523)},5809:e=>{e.exports=require("./config")},6066:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,o)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(1498),t),o(n(9850),t),o(n(1145),t),o(n(9127),t)},6346:e=>{e.exports=require("@babel/core")},6760:e=>{e.exports=require("node:path")},6864:function(e,t,n){var i,o=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,o)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),s=0;s<n.length;s++)"default"!==n[s]&&o(t,e,n[s]);return r(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.getParameterInfo=function(e,t){return e.node.params.map(e=>{try{return d(e,t)}catch{return}}).filter(e=>void 0!==e)};const a=s(n(6346)),c=n(8528),l=n(523);function u(e,t){if(a.types.isIdentifier(e.argument)){const n=e.argument.loc?t(e.argument.loc.start):void 0;return{name:n?.name??e.argument.name,type:c.ParameterTypes[e.type],sourcemap_location_hint:n}}{l.worker_logger.warning("Unsupported rest element",{type:e.argument.type});const n=e.loc?t(e.loc.start):void 0;return{type:c.ParameterTypes[e.type],sourcemap_location_hint:n}}}function d(e,t){if(e)switch(e?.type){case"Identifier":return function(e,t){const n=e.loc?t(e.loc.start,e.name):void 0;return{name:n?.name??e.name,type:c.ParameterTypes[e.type],sourcemap_location_hint:n}}(e,t);case"AssignmentPattern":return function(e,t,n,i){const o=e.loc?n(e.loc.start):void 0;return{type:c.ParameterTypes[e.type],sourcemap_location_hint:o,left:t,right:i}}(e,d(e.left,t),t,function(e){switch(e.type){case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":case"BigIntLiteral":case"DecimalLiteral":return{type:e.type,value:e.value};case"RegExpLiteral":return{type:e.type,value:e.pattern}}return{type:e.type}}(e.right));case"ArrayPattern":return function(e,t,n){const i=e.loc?n(e.loc.start):void 0;return{type:c.ParameterTypes[e.type],sourcemap_location_hint:i,elements:t}}(e,e.elements.map(e=>d(e,t)).filter(e=>void 0!==e),t);case"RestElement":return u(e,t);case"ObjectPattern":{const n=[];return e.properties.forEach(e=>{if(a.types.isObjectProperty(e)){const i=a.types.isIdentifier(e.key)&&a.types.isIdentifier(e.value)||a.types.isAssignmentPattern(e.value)?void 0:d(e.key,t);n.push(function(e,t,n,i){const o=e.loc?t(e.loc.start):void 0;return{type:c.ParameterTypes[e.type],sourcemap_location_hint:o,key:n,value:i}}(e,t,i,d(e.value,t)))}else a.types.isRestElement(e)&&n.push(u(e,t))}),function(e,t,n){const i=e.loc?n(e.loc.start):void 0;return{type:c.ParameterTypes[e.type],sourcemap_location_hint:i,properties:t}}(e,n,t)}default:l.worker_logger.warning("Unsupported parameter type",{type:e.type})}}},8528:e=>{e.exports=require("./dto")},9011:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NamespaceScopeAlias=t.ScopableAlias=void 0,t.isHudScopeable=function(e){return i.types.isArrowFunctionExpression(e)||i.types.isBlockStatement(e)||i.types.isCatchClause(e)||i.types.isClassMethod(e)||i.types.isClassPrivateMethod(e)||i.types.isDeclareModule(e)||i.types.isDoExpression(e)||i.types.isDoWhileStatement(e)||i.types.isForInStatement(e)||i.types.isForOfStatement(e)||i.types.isForStatement(e)||i.types.isFunctionDeclaration(e)||i.types.isFunctionExpression(e)||i.types.isIfStatement(e)||i.types.isLabeledStatement(e)||i.types.isObjectMethod(e)||i.types.isProgram(e)||i.types.isStaticBlock(e)||i.types.isSwitchCase(e)||i.types.isTSModuleBlock(e)||i.types.isTryStatement(e)||i.types.isWhileStatement(e)||i.types.isWithStatement(e)||i.types.isClassDeclaration(e)||i.types.isClassExpression(e)||i.types.isObjectExpression(e)||i.types.isSwitchStatement(e)},t.isNamespaceScopeable=function(e){return i.types.isFunction(e)||i.types.isClass(e)||i.types.isObjectExpression(e)};const i=n(6346);t.ScopableAlias="ArrowFunctionExpression|BlockStatement|CatchClause|ClassMethod|ClassPrivateMethod|DeclareModule|DoExpression|DoWhileStatement|ForInStatement|ForOfStatement|ForStatement|FunctionDeclaration|FunctionExpression|IfStatement|LabeledStatement|ObjectMethod|StaticBlock|SwitchCase|TSModuleBlock|TryStatement|WhileStatement|WithStatement|ClassDeclaration|ClassExpression|ObjectExpression|SwitchStatement",t.NamespaceScopeAlias="FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod|ClassMethod|ClassPrivateMethod|ClassDeclaration|ClassExpression|ObjectExpression"},9023:e=>{e.exports=require("util")},9127:function(e,t,n){var i,o=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,o)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),s=0;s<n.length;s++)"default"!==n[s]&&o(t,e,n[s]);return r(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.getFunctionIdentifier=function(e){const{node:t}=e;if(c.types.isFunctionDeclaration(t)||c.types.isFunctionExpression(t)){if(c.types.isIdentifier(t.id))return t.id}else if(c.types.isClassMethod(t)){if(c.types.isIdentifier(t.key))return t.key}else if(c.types.isClassPrivateMethod(t)){if(c.types.isIdentifier(t.key.id))return t.key.id}else if(c.types.isObjectMethod(t)&&c.types.isIdentifier(t.key))return t.key},t.getContextSymbol=h,t.getContextualData=function(e,t){let n,i;(e.isFunctionExpression()||e.isArrowFunctionExpression()||e.isClassExpression())&&(n=function(e,t){const n=e.parentPath;if(n.isCallExpression())for(const[i,o]of n.node.arguments.entries())if(o===e.node){const o=n.node.callee;let r;try{r=m(o,t)}catch(t){if(!(t instanceof u.HudUnsupportedError))throw t;{const n=`${o.type}-${e.node.type}`;b.has(n)||(d.worker_logger.warning("could not get callee symbol recursively",{error:t,errorMessage:t.message,calleType:o.type,nodeType:e.node.type}),b.add(n))}}const s=g(n.node,t);return{callee:{symbol:r,argsCount:n.node.arguments.length,args:s},index:i}}}(e,t)),(e.isFunctionExpression()||e.isArrowFunctionExpression())&&(i=function(e){const t=e.parentPath;return!!t.isCallExpression()&&t.node.callee===e.node}(e));const o=h(e,t);return o&&(o.name=(0,p.getSymbolName)(o)),{symbol:o,callback:n,immediatelyInvoked:i}},t.getMethodKind=function(e){if(a.types.isClassMethod(e)||a.types.isObjectMethod(e)||a.types.isClassPrivateMethod(e))return e.kind};const a=s(n(6346)),c=n(6346),l=n(8528),u=n(2546),d=n(523),p=n(2535);function f(e,t,n){const i=e.loc?n(e.loc.start,t,e.loc.filename):void 0;return{name:i?.name??t,sourcemap_location_hints:i?[i]:[],format:"%s"}}function m(e,t){if(c.types.isIdentifier(e)){const n=e.loc?[t(e.loc.start,e.name,e.loc.filename)]:[];return{name:n[0]?.name??e.name,sourcemap_location_hints:n,format:"%s"}}if(c.types.isMemberExpression(e)||c.types.isOptionalMemberExpression(e)){let n;n=c.types.isThisExpression(e.object)?{name:"this",sourcemap_location_hints:e.object.loc?[t(e.object.loc.start,"this",e.object.loc.filename)]:[]}:m(e.object,t);const i=m(e.property,t),o=e.computed?n.name+"["+i.name+"]":n.name+"."+i.name,r=n.format??"%s",s=i.format??"%s",a=e.computed?`${r}[${s}]`:`${r}.${s}`;return{name:o,sourcemap_location_hints:[...n.sourcemap_location_hints,...i.sourcemap_location_hints],format:a}}if(c.types.isOptionalCallExpression(e)||c.types.isCallExpression(e))return m(e.callee,t);if(c.types.isSequenceExpression(e))return m(e.expressions[e.expressions.length-1],t);if(c.types.isArrayExpression(e))return{name:"[]",sourcemap_location_hints:e.loc?[t(e.loc.start,"[]",e.loc.filename)]:[],format:"%s"};if(c.types.isObjectExpression(e))return{name:"{}",sourcemap_location_hints:e.loc?[t(e.loc.start,"{}",e.loc.filename)]:[],format:"%s"};if(c.types.isStringLiteral(e)){const n=e.loc?[t(e.loc.start,e.value,e.loc.filename)]:[];return{name:`"${n[0]?.name??e.value}"`,sourcemap_location_hints:n,format:'"%s"'}}throw new u.HudUnsupportedError("Unsupported left side of assignment - "+e.type+"loc - "+JSON.stringify(e.loc))}const y=new Set;function h(e,t){const{node:n}=e;if(e.isExpression())try{return function(e,t){const{parent:n}=e;if(c.types.isVariableDeclarator(n)&&c.types.isIdentifier(n.id))return f(n,n.id.name,t);if(c.types.isObjectProperty(n)&&c.types.isIdentifier(n.key))return f(n,n.key.name,t);if(c.types.isClassProperty(n)&&c.types.isIdentifier(n.key))return f(n,n.key.name,t);if(c.types.isAssignmentExpression(n))return m(n.left,t);if(c.types.isAssignmentPattern(n))return m(n.left,t);throw new u.HudUnsupportedError(`Unsupported parent type - ${n.type} for me ${e.node.type}`)}(e,t)}catch(t){if(t instanceof u.HudUnsupportedError){const n=`${e.parentPath?.node.type}`;return void(y.has(n)||(d.worker_logger.warning("getContextSymbol: Unsupported parent node type",{parentType:e.parentPath?.node.type,error:t,errorMessage:t.message}),y.add(n)))}throw t}d.worker_logger.debug("getContextSymbol; Unsupported node type",{type:n.type})}function g(e,t){const n=[];return e.arguments.forEach((e,i)=>{let o,r;if(c.types.isStringLiteral(e)?(o=l.ArgumentTypes.StringLiteral,r=e.value):c.types.isTemplateLiteral(e)?(o=l.ArgumentTypes.TemplateString,r=function(e){let t="";const n=e.quasis,i=e.expressions;for(let e=0;e<n.length;e++)t+=n[e].value.cooked,e<i.length&&(t+=`\${${_(i[e])}}`);return t=`\`${t}\``,t}(e)):c.types.isIdentifier(e)&&(o=l.ArgumentTypes.Identifier,r=e.name),o&&r){const s=c.types.isIdentifier(e)?e.name:void 0,a=e.loc?t(e.loc.start,s):void 0;n.push({index:i,type:o,value:a?.name??r,sourcemap_location_hint:a})}}),n}function _(e){if(c.types.isIdentifier(e))return e.name;if(c.types.isStringLiteral(e))return e.value;if(c.types.isCallExpression(e)||c.types.isOptionalCallExpression(e)){const t=e;if(c.types.isIdentifier(t.callee))return t.callee.name;if(c.types.isMemberExpression(t.callee)||c.types.isOptionalMemberExpression(t.callee)){let e="";const n=t.callee;if(c.types.isThisExpression(n.object)?e+="this.":c.types.isIdentifier(n.object)&&(e+=`${n.object.name}.`),""!==e&&c.types.isIdentifier(n.property))return e+=`${n.property.name}`,e}}return""}const b=new Set},9850:function(e,t,n){var i,o=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,o)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),s=0;s<n.length;s++)"default"!==n[s]&&o(t,e,n[s]);return r(t,e),t}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fixSourceMap=F,t.getRealPositionNothingFunc=O,t.getRealPositionOffsetsFunc=I,t.getRealPositionSourceMapFunc=M,t.parseDeclarations=async function(e,t,n=null,i,o=!1){const{filename:r,bundlerBuildId:s,bundlerBuildIdGenerated:a,lineOffset:O,columnOffset:D,file_path_checksum:A,file_checksum:B,functionIds:q,sourceCodeHash:N,moduleBase:$,isNextJsApp:R,marksCount:L,prebundle_file_checksum:U}=e,W=U??B;if(g.worker_logger.debug("Parsing code",{filename:r}),i)try{if(!T){const e=(0,h.myRequire)("ts-node");T=e.create({...i,transpileOnly:!0,typeCheck:!1})}const e=function(e,t,n){try{return n.compile(e,t)}catch(e){return void g.worker_logger.warning("ts file pass, but failed to compile with ts-node",{filename:t,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(t,r,T);if(!e)return{declarations:[],blacklist:{file_path_checksum:A,file_checksum:W,uuids:q},generatedAsyncFunctions:[]};t=e}catch(e){return g.worker_logger.error("Failed to require and compile ts file",{filename:r,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0}),{declarations:[],blacklist:{file_path_checksum:A,file_checksum:W,uuids:q},generatedAsyncFunctions:[]}}else if(r.endsWith(".ts")||r.endsWith(".mts"))return g.worker_logger.error("ts file pass, but not found ts-options"),{declarations:[],blacklist:{file_path_checksum:A,file_checksum:W,uuids:q},generatedAsyncFunctions:[]};const K=(0,_.default)(t).readUInt32BE();if(K!==B)return g.worker_logger.warning("File checksum mismatch",{filename:r,file_path_checksum:A,diskFileChecksum:K,file_checksum:B,functionIds:q}),{declarations:[],blacklist:{file_path_checksum:A,file_checksum:W,uuids:q},generatedAsyncFunctions:[]};let H,J,V=(e,t,n)=>({name:t??void 0,line:e.line,column:e.column,source:n??void 0});if(function(e){return void 0!==e.lineOffset&&void 0!==e.columnOffset&&(0!==e.lineOffset||0!==e.columnOffset)}(e))V=I(O,D);else{const e=(0,b.getSourceMap)(r,t);try{null!==e&&(J=(0,_.default)(e).readUInt32BE(),f.hudConfig.userConfig.disableSourceMapsResolution?.value||(H=JSON.parse(e),H&&(V=M(await new u.SourceMapConsumer(F(H))))))}catch(e){g.worker_logger.error("Failed to parse source map",{filename:r,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}g.worker_logger.debug("Parsing code",{filename:r});const z=[],G=new S(t,$),Q=G.getRemainingMarksCount(),X=await c.parseAsync(t,C);if(null===X)return g.worker_logger.warning("Failed parsing code to tree",{filename:r,file_path_checksum:A,diskFileChecksum:K,file_checksum:W,functionIds:q}),{declarations:[],blacklist:{file_path_checksum:A,file_checksum:W,uuids:q},generatedAsyncFunctions:[]};g.worker_logger.debug("Parsed code to tree",{filename:r});const Y=[{type:l.EntityType.Program,symbol:{sourcemap_location_hints:[]},context:{},childrenCount:{},siblingIndex:0}],Z=new Set,ee=[];g.worker_logger.debug("Traversing declarations",{filename:r}),n?.postMessage("eventlooptime"),c.traverse(X,{AssignmentExpression:{enter(e){const t=function(e){try{const{node:t}=e,n=t.left;if("MemberExpression"!==n.type)return;const i=n.object;if("Identifier"!==i.type)return;if("globalThis"!==i.name)return;const o=n.property;if("Identifier"!==o.type)return;if(o.name!==f.hudConfig.esbuildFunctionIdVar)return;const r=t.right;if("StringLiteral"!==r.type)return;const s=r.value.split(":");if(2!==s.length)return;return{functionId:j(s[0]),functionHash:s[1]}}catch{return}}(e);t&&(ee[ee.length-1]=t)}},[w.NamespaceScopeAlias]:{enter(e){const{node:t}=e;if(!(0,w.isNamespaceScopeable)(t))return;const n=Y[Y.length-1],i=(0,E.getScope)(e,r,V);if(!i)return;const o=n.childrenCount[i.type]||0,s={...i,childrenCount:{},siblingIndex:o};n.childrenCount[i.type]=o+1,Y.push(s),Z.add(t),e.isFunction()&&ee.push(null)},exit(e){const{node:n}=e;!function(){if(e.isFunction()){const n=ee.pop()??null,i=function(e,t,n,i,o,r,s,a){try{const l=(0,h.getInstrumentedThirdPartyModuleInfo)(n);let u;if(l){if(!function(e,t){const n=(0,p.getFunctionIdentifier)(e);if(!n)return!1;const i=n.name;return t.functions.includes(i)}(e,l))return;u=l.moduleName}if(!1===f.hudConfig.userConfig.instrumentOneLiners?.value&&function(e){const t=e.node;if("ArrowFunctionExpression"!==t.type)return!1;if(t.async||t.generator)return!1;if("BlockStatement"!==t.body.type)return!0;const n=t.body;return 1===n.body.length&&"ReturnStatement"===n.body[0].type}(e))return;const b=P(e);if(!b)throw new Error("Function node has no block start location");const E=e;if(void 0===e.node.start||null===e.node.start||void 0===e.node.end||null===e.node.end)throw new Error("Function node has no start or end location");let w=a?.functionId??null;const C=null===w;null===w&&(w=function(e,t,n,i){const o=i.slice(0,n),r=`${e}_${t}_${Buffer.byteLength(o,"utf8")}`;return d.v5(r,f.hudConfig.functionUuidNamespace).toString()}(t,n,b.start-(o-1),r));const S=a?.functionHash??(c=r.slice(e.node.start,e.node.end),(0,_.default)(c).readUInt32BE().toString());if(!S)return void g.worker_logger.warning("Function hash not found",{functionId:w,filename:n});const F=E.node.async||!1,O=E.node.loc?s(E.node.loc.start,void 0,n):void 0,I=E.node.loc?s(E.node.loc.end,void 0,n):void 0,M=O?.source??n,T=(0,v.getEntityType)(E),j=(0,p.getMethodKind)(E.node),D=(0,p.getContextualData)(E,s),A=(0,k.getParameterInfo)(E,s),{siblingIndex:B,childrenCount:q}=i[i.length-1],N=i.slice(0,-1),$=(0,p.getFunctionIdentifier)(E),R=$?$.loc?[s($.loc.start,$.name,M)]:[]:E.node.loc?[s(E.node.loc.start,void 0,M)]:[],L=R[0]?.name??$?.name,U={name:L,sourcemap_location_hints:R,format:L?"%s":void 0};return U.name&&(U.name=(0,x.getSymbolName)(U)),{module:m.default.parse(M).name,symbol:U,context:D,file:M,type:T,format:y.Format.cjs,parameters:A,async:F,start_line:O?.line??-1,end_line:I?.line??-1,start_column:O?.column??-1,source_code_hash:S,runtime_function_id:w,scope_chain:N,methodKind:j,siblingIndex:B,childrenCount:q,third_party_module:u,original_location:{file:n,start_line:e.node.loc?.start?.line,end_line:e.node.loc?.end?.line,start_column:e.node.loc?.start?.column,end_column:e.node.loc?.end?.column},id_generated:C}}catch(e){g.worker_logger.error("Failed to handle function",{filename:n,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}var c}(e,N,r,Y,$,t,V,n);if(!i)return;if(!R)return void z.push(i);const o=P(e);if(!o)return;G.functionContainsMark(o.start,o.end)&&z.push(i)}}(),Z.has(n)&&(Y.pop(),Z.delete(n))}}}),g.worker_logger.debug("Traversed declarations",{filename:r}),R&&L!==z.length&&g.worker_logger.warning("Marks count mismatch while parsing declarations",{filename:r,marksCount:L,declarationsCount:z.length,remainingMarks:G.getRemainingMarksCount(),initialMarkCount:Q});const{declarations:te,blacklist:ne,generatedAsyncFunctions:ie}=function(e,t,n,i,o,r,s,a,c,l){t=t.map(j);const u=new Set(t),d=new Set(e.map(e=>e.runtime_function_id));let p=[];const f=[],m=[];e.forEach(e=>{u.has(e.runtime_function_id)?p.push({...e,declarations_count:0,bundler_build_id:n,was_bundler_build_id_generated:i,has_input_map:void 0!==o,sourcemap_crc:r,file_path_checksum:s,file_checksum:a}):l&&e.id_generated?e.async&&m.push(e):f.push(e)}),p=p.map(e=>({...e,declarations_count:p.length})),f.length>0&&g.worker_logger.warning("Function IDs mismatch, missing instrumentation",{filename:c,runtimeFunctionIds:t,missingInstrumentation:f});const y=new Set;u.forEach(e=>{d.has(e)||y.add(e)});const h=y.size>0;return h&&g.worker_logger.error("Function IDs mismatch, missing declarations",{filename:c,missingRuntimeFunctionIds:[...y]}),{declarations:p,blacklist:h?{file_path_checksum:s,file_checksum:a,uuids:[...y]}:void 0,generatedAsyncFunctions:m}}(z,q,s,a,H,J,A,W,r,o);return{declarations:te,blacklist:ne,generatedAsyncFunctions:ie}},t.rawFunctionIdToUuidFunctionId=j;const c=s(n(6346)),l=n(8528),u=n(4634),d=s(n(3903)),p=n(9127),f=n(5809),m=a(n(6760)),y=n(8528),h=n(2546),g=n(523),_=a(n(3176)),b=n(2784),v=n(5203),k=n(6864),E=n(1602),x=n(2535),w=n(9011),C={babelrc:!1,configFile:!1};class S{markPositions=[];moduleBase;constructor(e,t){this.moduleBase=t,this.findMarkPositions(e)}findMarkPositions(e){const t=f.hudConfig.nextJsMarkVarName;let n=0,i=e.indexOf(t,n);for(;-1!==i;)this.markPositions.push(i),n=i+t.length,i=e.indexOf(t,n)}functionContainsMark(e,t){const n=e-this.moduleBase,i=t-this.moduleBase;let o=!1,r=0;for(let e=0;e<this.markPositions.length;e++){const t=this.markPositions[e];if(t>=n&&t<=i){o=!0,r=e;break}}return o&&this.markPositions.splice(r,1),o}getRemainingMarksCount(){return this.markPositions.length}}function F(e){let t;return t="string"==typeof e?JSON.parse(e):e,t.sources=t.sources.map(e=>e.replace(/^webpack:\/\/(?:@[^/]+?[/])?[^/]+\//,"")),t}function O(){return(e,t,n)=>({name:t??void 0,line:e.line,column:e.column,source:n??void 0})}function I(e,t){return(n,i,o)=>({name:i??void 0,line:n.line+(e||0),column:n.column+(1===n.line&&t||0),source:o??void 0})}function M(e){return(t,n,i)=>{const o=e.originalPositionFor({line:t.line,column:t.column});return o?{name:o.name??n,line:o.line??-1,column:o.column??-1,source:o.source??i,resolved:!0,server:{name:n,line:t.line,column:t.column,source:i}}:{name:n??void 0,line:t.line,column:t.column,source:i??void 0,resolved:!1}}}function P(e){let t=e.node.body.loc?.start?.index;if(void 0===t)return null;"ArrowFunctionExpression"===e.node.type&&e.node.body.extra?.parenthesized&&e.node.body.extra?.parenStart&&Number.isInteger(e.node.body.extra.parenStart)&&(t=e.node.body.extra.parenStart);const n=e.node.end;return null==n?null:{start:t,end:n}}let T;function j(e){try{return d.stringify(Buffer.from(e+"==","base64"))}catch(t){throw g.worker_logger.error("Failed to convert raw function id to uuid function id",{rawFunctionId:e,error:t instanceof Error?t.message:void 0,stack:t instanceof Error?t.stack:void 0}),t}}}},t={};return function n(i){var o=t[i];if(void 0!==o)return o.exports;var r=t[i]={exports:{}};return e[i].call(r.exports,r,r.exports,n),r.exports}(6066)})());
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(global,()=>(()=>{"use strict";var e={523:e=>{e.exports=require("./logger")},1145:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MONGOOSE_QUERY_OPS=t.MONGO_COLLECTION_METHODS=t.createOutboundDeclarations=void 0,t.createAxiosDeclaration=a,t.createNodeFetchDeclaration=c,t.createRequestDeclaration=l,t.createPgDeclaration=u,t.createIoRedisDeclaration=d,t.generateOutboundFunctionId=p,t.createMongoDeclaration=f,t.createMongooseDeclaration=m;const o=n(5809),i=n(8528),r=n(3903),s=n(9850);function a(){return[y("axios","Axios","request",o.hudConfig.axiosFunctionId)]}function c(){return[y("node-fetch","node-fetch","fetch",o.hudConfig.nodeFetchFunctionId),...Object.entries(o.hudConfig.nodeFetchBodiesFunctionIds).map(([e,t])=>y("node-fetch","node-fetch",e,t))]}function l(){return[y("request","request","request",o.hudConfig.requestFunctionId),...Object.entries(o.hudConfig.requestMethodFunctionIds).map(([e,t])=>y("request","request",e,t))]}function u(){return[y("pg","Client","connect",o.hudConfig.pgConnectFunctionId),y("pg","Client","query",o.hudConfig.pgQueryFunctionId),y("pg","Client","end",o.hudConfig.pgEndFunctionId)]}function d(e){return e&&0!==e.length?e.map(e=>y("ioredis","Redis",e,p("ioredis",e))):[]}function p(e,t){return(0,o.functionUuidToBase64)((0,r.v5)(`${e}-${t}`,o.hudConfig.functionUuidNamespace))}function f(){return[y("mongodb","MongoClient","connect",p("mongodb","connect")),...t.MONGO_COLLECTION_METHODS.map(e=>y("mongodb","Collection",e,p("mongodb",e)))]}function m(){return[y("mongoose","mongoose","connect",p("mongoose","connect")),y("mongoose","mongoose","createConnection",p("mongoose","createConnection")),...t.MONGOOSE_QUERY_OPS.map(e=>y("mongoose","Query",e,p("mongoose",e))),y("mongoose","Aggregate","aggregate",p("mongoose","aggregate")),y("mongoose","Model","insertMany",p("mongoose","insertMany")),y("mongoose","Model","save",p("mongoose","save"))]}function y(e,t,n,o){return{id_generated:!0,module:e,third_party_module:e,file:`${e}.js`,format:"commonjs",async:!0,runtime_function_id:(0,s.rawFunctionIdToUuidFunctionId)(o),type:i.EntityType.ClassMethod,methodKind:"method",symbol:{sourcemap_location_hints:[{name:n,line:0,column:0,source:`${e}.js`}],name:n,format:"%s"},scope_chain:[{type:i.EntityType.Program,symbol:{sourcemap_location_hints:[]},context:{},childrenCount:{},siblingIndex:0},{type:i.EntityType.ClassDeclaration,symbol:{sourcemap_location_hints:[{name:t,line:0,column:0,source:`${e}.js`}],name:t,format:"%s"},context:{},childrenCount:{},siblingIndex:0}],original_location:{file:`${e}.js`,start_line:0,end_line:0,start_column:0,end_column:0},parameters:[],start_line:0,end_line:0,start_column:0,source_code_hash:"1",bundler_build_id:"1",was_bundler_build_id_generated:!0,has_input_map:!0,sourcemap_crc:1,file_path_checksum:1,file_checksum:1,declarations_count:1,childrenCount:{},siblingIndex:0,context:{}}}t.createOutboundDeclarations={axios:a,"node-fetch":c,request:l,pg:u,ioredis:d,mongodb:f,mongoose:m},t.MONGO_COLLECTION_METHODS=["findOne","countDocuments","distinct","insertOne","insertMany","updateOne","updateMany","replaceOne","deleteOne","deleteMany","findOneAndUpdate","findOneAndDelete","find","aggregate"],t.MONGOOSE_QUERY_OPS=["find","findOne","count","countDocuments","estimatedDocumentCount","deleteOne","deleteMany","findOneAndDelete","updateOne","updateMany","replaceOne","findOneAndUpdate","findOneAndReplace","distinct"]},1498:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getDeclarationsBatchRequest=function(e){const t=(new Date).toISOString();return{...i.HudClient.defaultRequest,type:"FunctionDeclaration",arr:e,send_time:t,event_version:o.FUNCTION_DECLARATION_VERSION}};const o=n(8528),i=n(4672)},1602:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getScope=function(e,t,n){const r=(0,o.getEntityType)(e);if(r){const s=(0,o.getEntityIdentity)(e.node),a=(0,i.getContextualData)(e,n),c=s?s.loc?[n(s.loc.start,s.name,s.loc.filename??t)]:[]:e.node.loc?[n(e.node.loc.start,void 0,e.node.loc.filename??t)]:[],l=c[0]?.name??s?.name;return{type:r,context:a,symbol:{name:l,sourcemap_location_hints:c,format:l?"%s":void 0},methodKind:(0,i.getMethodKind)(e.node)}}};const o=n(5203),i=n(9127)},2535:function(e,t,n){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSymbolName=function(e){let t=e.name;const n=e.sourcemap_location_hints;if(n.length>0&&n.every(e=>e.name)){const o=n.map(e=>e.name?.startsWith("#")?e.name?.slice(1):e.name);e.format?Array.from(e.format.matchAll(/%s/g)).length!==o.length?i.worker_logger.warning("Format string does not match number of location hints",{format:e.format,locationHints:o}):t=r.default.format(e.format,...o):t=o.join(".")}return t??""},t.getNodeLocation=function(e,t,n=void 0){const o=e.loc?.start,r=e.loc?.end;if(!o||!r)return i.worker_logger.info("Node without location",{filename:n,type:e.type}),{start:{source:null,line:-1,column:-1},end:{source:null,line:-1,column:-1}};const s=t({line:o.line,column:o.column}),a=t({line:r.line,column:r.column});return null!==s.line&&null!==s.column&&null!==a.line&&null!==a.column||(i.worker_logger.debug("Could not find location for function",{filename:n,type:e.type,locStart:o,locEnd:r}),s.line=-1,s.column=-1,a.line=-1,a.column=-1),{start:{source:s.source,line:s.line,column:s.column},end:{source:a.source,line:a.line,column:a.column}}};const i=n(523),r=o(n(9023))},2546:e=>{e.exports=require("./lib")},2784:e=>{e.exports=require("../native/_index")},3176:e=>{e.exports=require("buffer-crc32")},3903:e=>{e.exports=require("uuid")},4634:e=>{e.exports=require("source-map")},4672:e=>{e.exports=require("./client")},5203:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getEntityType=function(e){const{node:t}=e;return o.types.isFunctionDeclaration(t)?i.EntityType.FunctionDeclaration:o.types.isFunctionExpression(t)?i.EntityType.FunctionExpression:o.types.isArrowFunctionExpression(t)?i.EntityType.FunctionArrow:o.types.isObjectMethod(t)?i.EntityType.ObjectMethod:o.types.isStaticBlock(t)||o.types.isClassMethod(t)?i.EntityType.ClassMethod:o.types.isClassPrivateMethod(t)?i.EntityType.ClassPrivateMethod:o.types.isClassDeclaration(t)?i.EntityType.ClassDeclaration:o.types.isClassExpression(t)?i.EntityType.ClassExpression:o.types.isForInStatement(t)||o.types.isForOfStatement(t)||o.types.isForStatement(t)?i.EntityType.ForLoop:o.types.isBlockStatement(t)?function(e){const t=e.parentPath.node;if(!(o.types.isFunctionDeclaration(t)||o.types.isFunctionExpression(t)||o.types.isArrowFunctionExpression(t)||o.types.isClassMethod(t)||o.types.isObjectMethod(t)||o.types.isClassPrivateMethod(t)))if(o.types.isIfStatement(t)){if("consequent"===e.parentKey)return i.EntityType.IfConsequent;if("alternate"===e.parentKey)return i.EntityType.IfAlternate;if("test"===e.parentKey)return i.EntityType.IfTest}else{if(o.types.isBlockStatement(t)||o.types.isProgram(t))return i.EntityType.Block;if(o.types.isTryStatement(t)){if("block"===e.parentKey)return i.EntityType.Try;if("finalizer"===e.parentKey)return i.EntityType.Finally}else{if(o.types.isCatchClause(t))return;if(o.types.isWhileStatement(t))return"test"===e.parentKey?i.EntityType.WhileTest:i.EntityType.Do;if(o.types.isDoWhileStatement(t))return"test"===e.parentKey?i.EntityType.WhileTest:i.EntityType.Do;if(!(o.types.isForStatement(t)||o.types.isForInStatement(t)||o.types.isForOfStatement(t)))return;if("test"===e.parentKey)return i.EntityType.ForTest;if("body"===e.parentKey)return i.EntityType.ForBlock}}}(e):o.types.isProgram(t)?i.EntityType.Program:o.types.isDoWhileStatement(t)?i.EntityType.DoWhile:o.types.isWhileStatement(t)?i.EntityType.While:o.types.isCatchClause(t)?i.EntityType.Catch:o.types.isObjectExpression(t)?i.EntityType.ObjectExpression:o.types.isWithStatement(t)?i.EntityType.With:o.types.isSwitchStatement(t)?i.EntityType.Switch:o.types.isSwitchCase(t)?i.EntityType.SwitchCase:o.types.isTryStatement(t)?i.EntityType.TryCatch:o.types.isIfStatement(t)?i.EntityType.If:i.EntityType.Other},t.getEntityIdentity=function(e){return o.types.isFunctionDeclaration(e)?o.types.isIdentifier(e.id)?e.id:void r.worker_logger.info("Function declaration without an identifier"):o.types.isClassDeclaration(e)?o.types.isIdentifier(e.id)?e.id:void r.worker_logger.info("Class declaration without an identifier"):o.types.isFunctionExpression(e)||o.types.isClassExpression(e)?o.types.isIdentifier(e.id)?e.id:void 0:o.types.isClassMethod(e)?o.types.isIdentifier(e.key)?e.key:void r.worker_logger.info("Class method without an identifier"):o.types.isObjectMethod(e)?o.types.isIdentifier(e.key)?e.key:void r.worker_logger.info("Object method without an identifier"):o.types.isClassPrivateMethod(e)?o.types.isIdentifier(e.key.id)?e.key.id:void r.worker_logger.info("Class private method without an identifier"):void 0};const o=n(6346),i=n(8528),r=n(523)},5809:e=>{e.exports=require("./config")},6066:function(e,t,n){var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(1498),t),i(n(9850),t),i(n(1145),t),i(n(9127),t)},6346:e=>{e.exports=require("@babel/core")},6760:e=>{e.exports=require("node:path")},6864:function(e,t,n){var o,i=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),s=0;s<n.length;s++)"default"!==n[s]&&i(t,e,n[s]);return r(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.getParameterInfo=function(e,t){return e.node.params.map(e=>{try{return d(e,t)}catch{return}}).filter(e=>void 0!==e)};const a=s(n(6346)),c=n(8528),l=n(523);function u(e,t){if(a.types.isIdentifier(e.argument)){const n=e.argument.loc?t(e.argument.loc.start):void 0;return{name:n?.name??e.argument.name,type:c.ParameterTypes[e.type],sourcemap_location_hint:n}}{l.worker_logger.warning("Unsupported rest element",{type:e.argument.type});const n=e.loc?t(e.loc.start):void 0;return{type:c.ParameterTypes[e.type],sourcemap_location_hint:n}}}function d(e,t){if(e)switch(e?.type){case"Identifier":return function(e,t){const n=e.loc?t(e.loc.start,e.name):void 0;return{name:n?.name??e.name,type:c.ParameterTypes[e.type],sourcemap_location_hint:n}}(e,t);case"AssignmentPattern":return function(e,t,n,o){const i=e.loc?n(e.loc.start):void 0;return{type:c.ParameterTypes[e.type],sourcemap_location_hint:i,left:t,right:o}}(e,d(e.left,t),t,function(e){switch(e.type){case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":case"BigIntLiteral":case"DecimalLiteral":return{type:e.type,value:e.value};case"RegExpLiteral":return{type:e.type,value:e.pattern}}return{type:e.type}}(e.right));case"ArrayPattern":return function(e,t,n){const o=e.loc?n(e.loc.start):void 0;return{type:c.ParameterTypes[e.type],sourcemap_location_hint:o,elements:t}}(e,e.elements.map(e=>d(e,t)).filter(e=>void 0!==e),t);case"RestElement":return u(e,t);case"ObjectPattern":{const n=[];return e.properties.forEach(e=>{if(a.types.isObjectProperty(e)){const o=a.types.isIdentifier(e.key)&&a.types.isIdentifier(e.value)||a.types.isAssignmentPattern(e.value)?void 0:d(e.key,t);n.push(function(e,t,n,o){const i=e.loc?t(e.loc.start):void 0;return{type:c.ParameterTypes[e.type],sourcemap_location_hint:i,key:n,value:o}}(e,t,o,d(e.value,t)))}else a.types.isRestElement(e)&&n.push(u(e,t))}),function(e,t,n){const o=e.loc?n(e.loc.start):void 0;return{type:c.ParameterTypes[e.type],sourcemap_location_hint:o,properties:t}}(e,n,t)}default:l.worker_logger.warning("Unsupported parameter type",{type:e.type})}}},8528:e=>{e.exports=require("./dto")},9011:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NamespaceScopeAlias=t.ScopableAlias=void 0,t.isHudScopeable=function(e){return o.types.isArrowFunctionExpression(e)||o.types.isBlockStatement(e)||o.types.isCatchClause(e)||o.types.isClassMethod(e)||o.types.isClassPrivateMethod(e)||o.types.isDeclareModule(e)||o.types.isDoExpression(e)||o.types.isDoWhileStatement(e)||o.types.isForInStatement(e)||o.types.isForOfStatement(e)||o.types.isForStatement(e)||o.types.isFunctionDeclaration(e)||o.types.isFunctionExpression(e)||o.types.isIfStatement(e)||o.types.isLabeledStatement(e)||o.types.isObjectMethod(e)||o.types.isProgram(e)||o.types.isStaticBlock(e)||o.types.isSwitchCase(e)||o.types.isTSModuleBlock(e)||o.types.isTryStatement(e)||o.types.isWhileStatement(e)||o.types.isWithStatement(e)||o.types.isClassDeclaration(e)||o.types.isClassExpression(e)||o.types.isObjectExpression(e)||o.types.isSwitchStatement(e)},t.isNamespaceScopeable=function(e){return o.types.isFunction(e)||o.types.isClass(e)||o.types.isObjectExpression(e)};const o=n(6346);t.ScopableAlias="ArrowFunctionExpression|BlockStatement|CatchClause|ClassMethod|ClassPrivateMethod|DeclareModule|DoExpression|DoWhileStatement|ForInStatement|ForOfStatement|ForStatement|FunctionDeclaration|FunctionExpression|IfStatement|LabeledStatement|ObjectMethod|StaticBlock|SwitchCase|TSModuleBlock|TryStatement|WhileStatement|WithStatement|ClassDeclaration|ClassExpression|ObjectExpression|SwitchStatement",t.NamespaceScopeAlias="FunctionDeclaration|FunctionExpression|ArrowFunctionExpression|ObjectMethod|ClassMethod|ClassPrivateMethod|ClassDeclaration|ClassExpression|ObjectExpression"},9023:e=>{e.exports=require("util")},9127:function(e,t,n){var o,i=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),s=0;s<n.length;s++)"default"!==n[s]&&i(t,e,n[s]);return r(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.getFunctionIdentifier=function(e){const{node:t}=e;if(c.types.isFunctionDeclaration(t)||c.types.isFunctionExpression(t)){if(c.types.isIdentifier(t.id))return t.id}else if(c.types.isClassMethod(t)){if(c.types.isIdentifier(t.key))return t.key}else if(c.types.isClassPrivateMethod(t)){if(c.types.isIdentifier(t.key.id))return t.key.id}else if(c.types.isObjectMethod(t)&&c.types.isIdentifier(t.key))return t.key},t.getContextSymbol=g,t.getContextualData=function(e,t){let n,o;(e.isFunctionExpression()||e.isArrowFunctionExpression()||e.isClassExpression())&&(n=function(e,t){const n=e.parentPath;if(n.isCallExpression())for(const[o,i]of n.node.arguments.entries())if(i===e.node){const i=n.node.callee;let r;try{r=m(i,t)}catch(t){if(!(t instanceof u.HudUnsupportedError))throw t;{const n=`${i.type}-${e.node.type}`;b.has(n)||(d.worker_logger.warning("could not get callee symbol recursively",{error:t,errorMessage:t.message,calleType:i.type,nodeType:e.node.type}),b.add(n))}}const s=h(n.node,t);return{callee:{symbol:r,argsCount:n.node.arguments.length,args:s},index:o}}}(e,t)),(e.isFunctionExpression()||e.isArrowFunctionExpression())&&(o=function(e){const t=e.parentPath;return!!t.isCallExpression()&&t.node.callee===e.node}(e));const i=g(e,t);return i&&(i.name=(0,p.getSymbolName)(i)),{symbol:i,callback:n,immediatelyInvoked:o}},t.getMethodKind=function(e){if(a.types.isClassMethod(e)||a.types.isObjectMethod(e)||a.types.isClassPrivateMethod(e))return e.kind};const a=s(n(6346)),c=n(6346),l=n(8528),u=n(2546),d=n(523),p=n(2535);function f(e,t,n){const o=e.loc?n(e.loc.start,t,e.loc.filename):void 0;return{name:o?.name??t,sourcemap_location_hints:o?[o]:[],format:"%s"}}function m(e,t){if(c.types.isIdentifier(e)){const n=e.loc?[t(e.loc.start,e.name,e.loc.filename)]:[];return{name:n[0]?.name??e.name,sourcemap_location_hints:n,format:"%s"}}if(c.types.isMemberExpression(e)||c.types.isOptionalMemberExpression(e)){let n;n=c.types.isThisExpression(e.object)?{name:"this",sourcemap_location_hints:e.object.loc?[t(e.object.loc.start,"this",e.object.loc.filename)]:[]}:m(e.object,t);const o=m(e.property,t),i=e.computed?n.name+"["+o.name+"]":n.name+"."+o.name,r=n.format??"%s",s=o.format??"%s",a=e.computed?`${r}[${s}]`:`${r}.${s}`;return{name:i,sourcemap_location_hints:[...n.sourcemap_location_hints,...o.sourcemap_location_hints],format:a}}if(c.types.isOptionalCallExpression(e)||c.types.isCallExpression(e))return m(e.callee,t);if(c.types.isSequenceExpression(e))return m(e.expressions[e.expressions.length-1],t);if(c.types.isArrayExpression(e))return{name:"[]",sourcemap_location_hints:e.loc?[t(e.loc.start,"[]",e.loc.filename)]:[],format:"%s"};if(c.types.isObjectExpression(e))return{name:"{}",sourcemap_location_hints:e.loc?[t(e.loc.start,"{}",e.loc.filename)]:[],format:"%s"};if(c.types.isStringLiteral(e)){const n=e.loc?[t(e.loc.start,e.value,e.loc.filename)]:[];return{name:`"${n[0]?.name??e.value}"`,sourcemap_location_hints:n,format:'"%s"'}}throw new u.HudUnsupportedError("Unsupported left side of assignment - "+e.type+"loc - "+JSON.stringify(e.loc))}const y=new Set;function g(e,t){const{node:n}=e;if(e.isExpression())try{return function(e,t){const{parent:n}=e;if(c.types.isVariableDeclarator(n)&&c.types.isIdentifier(n.id))return f(n,n.id.name,t);if(c.types.isObjectProperty(n)&&c.types.isIdentifier(n.key))return f(n,n.key.name,t);if(c.types.isClassProperty(n)&&c.types.isIdentifier(n.key))return f(n,n.key.name,t);if(c.types.isAssignmentExpression(n))return m(n.left,t);if(c.types.isAssignmentPattern(n))return m(n.left,t);throw new u.HudUnsupportedError(`Unsupported parent type - ${n.type} for me ${e.node.type}`)}(e,t)}catch(t){if(t instanceof u.HudUnsupportedError){const n=`${e.parentPath?.node.type}`;return void(y.has(n)||(d.worker_logger.warning("getContextSymbol: Unsupported parent node type",{parentType:e.parentPath?.node.type,error:t,errorMessage:t.message}),y.add(n)))}throw t}d.worker_logger.debug("getContextSymbol; Unsupported node type",{type:n.type})}function h(e,t){const n=[];return e.arguments.forEach((e,o)=>{let i,r;if(c.types.isStringLiteral(e)?(i=l.ArgumentTypes.StringLiteral,r=e.value):c.types.isTemplateLiteral(e)?(i=l.ArgumentTypes.TemplateString,r=function(e){let t="";const n=e.quasis,o=e.expressions;for(let e=0;e<n.length;e++)t+=n[e].value.cooked,e<o.length&&(t+=`\${${_(o[e])}}`);return t=`\`${t}\``,t}(e)):c.types.isIdentifier(e)&&(i=l.ArgumentTypes.Identifier,r=e.name),i&&r){const s=c.types.isIdentifier(e)?e.name:void 0,a=e.loc?t(e.loc.start,s):void 0;n.push({index:o,type:i,value:a?.name??r,sourcemap_location_hint:a})}}),n}function _(e){if(c.types.isIdentifier(e))return e.name;if(c.types.isStringLiteral(e))return e.value;if(c.types.isCallExpression(e)||c.types.isOptionalCallExpression(e)){const t=e;if(c.types.isIdentifier(t.callee))return t.callee.name;if(c.types.isMemberExpression(t.callee)||c.types.isOptionalMemberExpression(t.callee)){let e="";const n=t.callee;if(c.types.isThisExpression(n.object)?e+="this.":c.types.isIdentifier(n.object)&&(e+=`${n.object.name}.`),""!==e&&c.types.isIdentifier(n.property))return e+=`${n.property.name}`,e}}return""}const b=new Set},9850:function(e,t,n){var o,i=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(o=function(e){return o=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},o(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=o(e),s=0;s<n.length;s++)"default"!==n[s]&&i(t,e,n[s]);return r(t,e),t}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fixSourceMap=w,t.getRealPositionNothingFunc=M,t.getRealPositionOffsetsFunc=F,t.getRealPositionSourceMapFunc=I,t.parseDeclarations=async function(e,t,n=null,o,i=!1){const{filename:r,bundlerBuildId:s,bundlerBuildIdGenerated:a,lineOffset:M,columnOffset:D,file_path_checksum:A,file_checksum:N,functionIds:B,sourceCodeHash:q,moduleBase:L,isNextJsApp:R,marksCount:U,prebundle_file_checksum:$}=e,W=$??N;if(h.worker_logger.debug("Parsing code",{filename:r}),o)try{if(!T){const e=(0,g.myRequire)("ts-node");T=e.create({...o,transpileOnly:!0,typeCheck:!1})}const e=function(e,t,n){try{return n.compile(e,t)}catch(e){return void h.worker_logger.warning("ts file pass, but failed to compile with ts-node",{filename:t,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(t,r,T);if(!e)return{declarations:[],blacklist:{file_path_checksum:A,file_checksum:W,uuids:B},generatedAsyncFunctions:[]};t=e}catch(e){return h.worker_logger.error("Failed to require and compile ts file",{filename:r,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0}),{declarations:[],blacklist:{file_path_checksum:A,file_checksum:W,uuids:B},generatedAsyncFunctions:[]}}else if(r.endsWith(".ts")||r.endsWith(".mts"))return h.worker_logger.error("ts file pass, but not found ts-options"),{declarations:[],blacklist:{file_path_checksum:A,file_checksum:W,uuids:B},generatedAsyncFunctions:[]};const K=(0,_.default)(t).readUInt32BE();if(K!==N)return h.worker_logger.warning("File checksum mismatch",{filename:r,file_path_checksum:A,diskFileChecksum:K,file_checksum:N,functionIds:B}),{declarations:[],blacklist:{file_path_checksum:A,file_checksum:W,uuids:B},generatedAsyncFunctions:[]};let H,G,J=(e,t,n)=>({name:t??void 0,line:e.line,column:e.column,source:n??void 0});if(function(e){return void 0!==e.lineOffset&&void 0!==e.columnOffset&&(0!==e.lineOffset||0!==e.columnOffset)}(e))J=F(M,D);else{const e=(0,b.getSourceMap)(r,t);try{null!==e&&(G=(0,_.default)(e).readUInt32BE(),f.hudConfig.userConfig.disableSourceMapsResolution?.value||(H=JSON.parse(e),H&&(J=I(await new u.SourceMapConsumer(w(H))))))}catch(e){h.worker_logger.error("Failed to parse source map",{filename:r,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}h.worker_logger.debug("Parsing code",{filename:r});const Q=[],V=new S(t,L),z=V.getRemainingMarksCount(),Y=await c.parseAsync(t,x);if(null===Y)return h.worker_logger.warning("Failed parsing code to tree",{filename:r,file_path_checksum:A,diskFileChecksum:K,file_checksum:W,functionIds:B}),{declarations:[],blacklist:{file_path_checksum:A,file_checksum:W,uuids:B},generatedAsyncFunctions:[]};h.worker_logger.debug("Parsed code to tree",{filename:r});const X=[{type:l.EntityType.Program,symbol:{sourcemap_location_hints:[]},context:{},childrenCount:{},siblingIndex:0}],Z=new Set,ee=[];h.worker_logger.debug("Traversing declarations",{filename:r}),n?.postMessage("eventlooptime"),c.traverse(Y,{AssignmentExpression:{enter(e){const t=function(e){try{const{node:t}=e,n=t.left;if("MemberExpression"!==n.type)return;const o=n.object;if("Identifier"!==o.type)return;if("globalThis"!==o.name)return;const i=n.property;if("Identifier"!==i.type)return;if(i.name!==f.hudConfig.esbuildFunctionIdVar)return;const r=t.right;if("StringLiteral"!==r.type)return;const s=r.value.split(":");if(2!==s.length)return;return{functionId:j(s[0]),functionHash:s[1]}}catch{return}}(e);t&&(ee[ee.length-1]=t)}},[C.NamespaceScopeAlias]:{enter(e){const{node:t}=e;if(!(0,C.isNamespaceScopeable)(t))return;const n=X[X.length-1],o=(0,E.getScope)(e,r,J);if(!o)return;const i=n.childrenCount[o.type]||0,s={...o,childrenCount:{},siblingIndex:i};n.childrenCount[o.type]=i+1,X.push(s),Z.add(t),e.isFunction()&&ee.push(null)},exit(e){const{node:n}=e;!function(){if(e.isFunction()){const n=ee.pop()??null,o=function(e,t,n,o,i,r,s,a){try{const l=(0,g.getInstrumentedThirdPartyModuleInfo)(n);let u;if(l){if(!function(e,t){const n=(0,p.getFunctionIdentifier)(e);if(!n)return!1;const o=n.name;return t.functions.includes(o)}(e,l))return;u=l.moduleName}if(!1===f.hudConfig.userConfig.instrumentOneLiners?.value&&function(e){const t=e.node;if("ArrowFunctionExpression"!==t.type)return!1;if(t.async||t.generator)return!1;if("BlockStatement"!==t.body.type)return!0;const n=t.body;return 1===n.body.length&&"ReturnStatement"===n.body[0].type}(e))return;const b=P(e);if(!b)throw new Error("Function node has no block start location");const E=e;if(void 0===e.node.start||null===e.node.start||void 0===e.node.end||null===e.node.end)throw new Error("Function node has no start or end location");let C=a?.functionId??null;const x=null===C;null===C&&(C=function(e,t,n,o){const i=o.slice(0,n),r=`${e}_${t}_${Buffer.byteLength(i,"utf8")}`;return d.v5(r,f.hudConfig.functionUuidNamespace).toString()}(t,n,b.start-(i-1),r));const S=a?.functionHash??(c=r.slice(e.node.start,e.node.end),(0,_.default)(c).readUInt32BE().toString());if(!S)return void h.worker_logger.warning("Function hash not found",{functionId:C,filename:n});const w=E.node.async||!1,M=E.node.loc?s(E.node.loc.start,void 0,n):void 0,F=E.node.loc?s(E.node.loc.end,void 0,n):void 0,I=M?.source??n,T=(0,v.getEntityType)(E),j=(0,p.getMethodKind)(E.node),D=(0,p.getContextualData)(E,s),A=(0,O.getParameterInfo)(E,s),{siblingIndex:N,childrenCount:B}=o[o.length-1],q=o.slice(0,-1),L=(0,p.getFunctionIdentifier)(E),R=L?L.loc?[s(L.loc.start,L.name,I)]:[]:E.node.loc?[s(E.node.loc.start,void 0,I)]:[],U=R[0]?.name??L?.name,$={name:U,sourcemap_location_hints:R,format:U?"%s":void 0};return $.name&&($.name=(0,k.getSymbolName)($)),{module:m.default.parse(I).name,symbol:$,context:D,file:I,type:T,format:y.Format.cjs,parameters:A,async:w,start_line:M?.line??-1,end_line:F?.line??-1,start_column:M?.column??-1,source_code_hash:S,runtime_function_id:C,scope_chain:q,methodKind:j,siblingIndex:N,childrenCount:B,third_party_module:u,original_location:{file:n,start_line:e.node.loc?.start?.line,end_line:e.node.loc?.end?.line,start_column:e.node.loc?.start?.column,end_column:e.node.loc?.end?.column},id_generated:x}}catch(e){h.worker_logger.error("Failed to handle function",{filename:n,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}var c}(e,q,r,X,L,t,J,n);if(!o)return;if(!R)return void Q.push(o);const i=P(e);if(!i)return;V.functionContainsMark(i.start,i.end)&&Q.push(o)}}(),Z.has(n)&&(X.pop(),Z.delete(n))}}}),h.worker_logger.debug("Traversed declarations",{filename:r}),R&&U!==Q.length&&h.worker_logger.warning("Marks count mismatch while parsing declarations",{filename:r,marksCount:U,declarationsCount:Q.length,remainingMarks:V.getRemainingMarksCount(),initialMarkCount:z});const{declarations:te,blacklist:ne,generatedAsyncFunctions:oe}=function(e,t,n,o,i,r,s,a,c,l){t=t.map(j);const u=new Set(t),d=new Set(e.map(e=>e.runtime_function_id));let p=[];const f=[],m=[];e.forEach(e=>{u.has(e.runtime_function_id)?p.push({...e,declarations_count:0,bundler_build_id:n,was_bundler_build_id_generated:o,has_input_map:void 0!==i,sourcemap_crc:r,file_path_checksum:s,file_checksum:a}):l&&e.id_generated?e.async&&m.push(e):f.push(e)}),p=p.map(e=>({...e,declarations_count:p.length})),f.length>0&&h.worker_logger.warning("Function IDs mismatch, missing instrumentation",{filename:c,runtimeFunctionIds:t,missingInstrumentation:f});const y=new Set;u.forEach(e=>{d.has(e)||y.add(e)});const g=y.size>0;return g&&h.worker_logger.error("Function IDs mismatch, missing declarations",{filename:c,missingRuntimeFunctionIds:[...y]}),{declarations:p,blacklist:g?{file_path_checksum:s,file_checksum:a,uuids:[...y]}:void 0,generatedAsyncFunctions:m}}(Q,B,s,a,H,G,A,W,r,i);return{declarations:te,blacklist:ne,generatedAsyncFunctions:oe}},t.rawFunctionIdToUuidFunctionId=j;const c=s(n(6346)),l=n(8528),u=n(4634),d=s(n(3903)),p=n(9127),f=n(5809),m=a(n(6760)),y=n(8528),g=n(2546),h=n(523),_=a(n(3176)),b=n(2784),v=n(5203),O=n(6864),E=n(1602),k=n(2535),C=n(9011),x={babelrc:!1,configFile:!1};class S{markPositions=[];moduleBase;constructor(e,t){this.moduleBase=t,this.findMarkPositions(e)}findMarkPositions(e){const t=f.hudConfig.nextJsMarkVarName;let n=0,o=e.indexOf(t,n);for(;-1!==o;)this.markPositions.push(o),n=o+t.length,o=e.indexOf(t,n)}functionContainsMark(e,t){const n=e-this.moduleBase,o=t-this.moduleBase;let i=!1,r=0;for(let e=0;e<this.markPositions.length;e++){const t=this.markPositions[e];if(t>=n&&t<=o){i=!0,r=e;break}}return i&&this.markPositions.splice(r,1),i}getRemainingMarksCount(){return this.markPositions.length}}function w(e){let t;return t="string"==typeof e?JSON.parse(e):e,t.sources=t.sources.map(e=>e.replace(/^webpack:\/\/(?:@[^/]+?[/])?[^/]+\//,"")),t}function M(){return(e,t,n)=>({name:t??void 0,line:e.line,column:e.column,source:n??void 0})}function F(e,t){return(n,o,i)=>({name:o??void 0,line:n.line+(e||0),column:n.column+(1===n.line&&t||0),source:i??void 0})}function I(e){return(t,n,o)=>{const i=e.originalPositionFor({line:t.line,column:t.column});return i?{name:i.name??n,line:i.line??-1,column:i.column??-1,source:i.source??o,resolved:!0,server:{name:n,line:t.line,column:t.column,source:o}}:{name:n??void 0,line:t.line,column:t.column,source:o??void 0,resolved:!1}}}function P(e){let t=e.node.body.loc?.start?.index;if(void 0===t)return null;"ArrowFunctionExpression"===e.node.type&&e.node.body.extra?.parenthesized&&e.node.body.extra?.parenStart&&Number.isInteger(e.node.body.extra.parenStart)&&(t=e.node.body.extra.parenStart);const n=e.node.end;return null==n?null:{start:t,end:n}}let T;function j(e){try{return d.stringify(Buffer.from(e+"==","base64"))}catch(t){throw h.worker_logger.error("Failed to convert raw function id to uuid function id",{rawFunctionId:e,error:t instanceof Error?t.message:void 0,stack:t instanceof Error?t.stack:void 0}),t}}}},t={};return function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o].call(r.exports,r,r.exports,n),r.exports}(6066)})());
2
2
  //# sourceMappingURL=declarations.js.map
package/dist/cjs/dto.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(global,()=>(()=>{"use strict";var e={765:(e,t)=>{var o,r;Object.defineProperty(t,"__esModule",{value:!0}),t.HudSessionInitStatus=t.HudRunningMode=t.KeepAliveMessage=void 0,t.KeepAliveMessage={msg:"keep-alive"},function(e){e[e.detached=0]="detached",e[e.disabled=1]="disabled",e[e.enabled=2]="enabled"}(o||(t.HudRunningMode=o={})),function(e){e[e.success=0]="success",e[e.throttled=1]="throttled"}(r||(t.HudSessionInitStatus=r={}))},878:(e,t)=>{var o;Object.defineProperty(t,"__esModule",{value:!0}),t.GraphQLSupportedOperations=void 0,function(e){e.query="query",e.mutation="mutation",e.subscription="subscription"}(o||(t.GraphQLSupportedOperations=o={}))},1569:e=>{e.exports=require("zod")},2176:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},3487:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var n=Object.getOwnPropertyDescriptor(t,o);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,n)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),n=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||r(t,e,o)};Object.defineProperty(t,"__esModule",{value:!0}),n(o(7789),t),n(o(8086),t),n(o(7935),t),n(o(6910),t),n(o(2176),t),n(o(9107),t),n(o(7022),t),n(o(6604),t),n(o(4909),t),n(o(878),t),n(o(8377),t),n(o(8054),t),n(o(6328),t),n(o(6413),t),n(o(6364),t),n(o(765),t)},4909:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},6328:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},6364:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HudSessionOptionsSchema=t.HudOptionsSchema=void 0;const r=o(1569),n=o(7789);t.HudOptionsSchema=r.z.object({includeModules:r.z.array(r.z.string()).optional(),excludeDirs:r.z.array(r.z.string()).optional(),enableFrameworks:n.availableFrameworksSchema.optional(),maxMappedFunctions:r.z.number().optional(),minPodMemoryMB:r.z.number().optional(),maxFileSizeBytes:r.z.number().optional(),maxTimeUntilInitSessionMs:r.z.number().optional(),verbose:r.z.boolean().optional(),disableSourceMapsResolution:r.z.boolean().optional(),disableRuntimeInstrumentation:r.z.boolean().optional(),disableParametersExtraction:r.z.boolean().optional(),disableDetachedFunctions:r.z.boolean().optional(),customOptions:r.z.record(r.z.string(),r.z.string()).optional()}),t.HudSessionOptionsSchema=r.z.object({tags:r.z.record(r.z.string(),r.z.string()).optional()})},6413:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},6604:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},6910:(e,t)=>{var o,r,n;Object.defineProperty(t,"__esModule",{value:!0}),t.EntityType=t.ArgumentTypes=t.ParameterTypes=void 0,function(e){e.Identifier="Identifier",e.RestElement="RestElement",e.ArrayPattern="ArrayPattern",e.AssignmentPattern="AssignmentPattern",e.ObjectPattern="ObjectPattern",e.ObjectProperty="ObjectProperty"}(o||(t.ParameterTypes=o={})),function(e){e.StringLiteral="StringLiteral",e.Identifier="Identifier",e.TemplateString="TemplateString"}(r||(t.ArgumentTypes=r={})),function(e){e.FunctionDeclaration="functionDeclaration",e.FunctionExpression="functionExpression",e.FunctionArrow="functionArrow",e.ClassMethod="classMethod",e.ObjectMethod="objectMethod",e.ClassPrivateMethod="classPrivateMethod",e.ClassDeclaration="classDeclaration",e.ClassExpression="classExpression",e.ObjectExpression="objectExpression",e.Program="program",e.ForLoop="forLoop",e.ForBlock="forBlock",e.ForTest="forTest",e.Block="block",e.While="while",e.DoWhile="doWhile",e.Do="Do",e.WhileTest="whileTest",e.Switch="switch",e.SwitchCase="switchCase",e.Catch="catch",e.With="with",e.If="if",e.IfTest="ifTest",e.IfConsequent="ifConsequent",e.IfAlternate="ifAlternate",e.TryCatch="tryCatch",e.Try="try",e.Finally="finally",e.Other="other",e.File="file"}(n||(t.EntityType=n={}))},7022:(e,t)=>{var o;Object.defineProperty(t,"__esModule",{value:!0}),t.Format=t.FUNCTION_DECLARATION_VERSION=void 0,t.isSupportedFormat=function(e){return Object.values(o).includes(e)},t.FUNCTION_DECLARATION_VERSION="1.1.3",function(e){e.cjs="commonjs",e.esm="module",e.ts="typescript",e.moduleTypescript="module-typescript",e.commonjsTypescript="commonjs-typescript"}(o||(t.Format=o={}))},7789:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.availableFrameworksSchema=t.availableFrameworks=void 0;const r=o(1569);t.availableFrameworks={axios:"axios",pg:"pg",ioredis:"ioredis",nodeFetch:"nodeFetch",request:"request",express:"express",koa:"koa",graphql:"graphql",http:"http",https:"https",nextjs:"nextjs",nestjs:"nestjs",kafkajs:"kafkajs",confluentKafkaJs:"confluentKafkaJs",codegenieServerlessExpress:"codegenieServerlessExpress",sqs:"sqs",serverlessHttp:"serverlessHttp"},t.availableFrameworksSchema=r.z.union([r.z.map(r.z.nativeEnum(t.availableFrameworks),r.z.boolean()),r.z.record(r.z.nativeEnum(t.availableFrameworks),r.z.boolean())]).transform(e=>e instanceof Map?e:new Map(Object.entries(e)))},7935:(e,t)=>{function o(e,t){return t?t instanceof RegExp?e+t.toString():("/"===t[t.length-1]&&t.length>1&&(t=t.slice(0,-1)),(t=e+t).replace(/\/{2,}/g,"/")):t}Object.defineProperty(t,"__esModule",{value:!0}),t.EndpointDeclaration=void 0,t.EndpointDeclaration=class{flow_id;methods;framework;partial_path;path;constructor(e,t,r,n,i,a){this.flow_id=e,this.methods=t,this.framework=r,this.partial_path=a,n||(n=""),this.path=o(n,i),this.partial_path=o(n,a)}}},8054:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},8086:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},8377:(e,t)=>{var o,r,n;Object.defineProperty(t,"__esModule",{value:!0}),t.OutboundType=t.InvestigationType=t.InvestigationStatus=void 0,function(e){e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Cleared=3]="Cleared"}(o||(t.InvestigationStatus=o={})),function(e){e.HTTP="http",e.SQS="sqs",e.Kafka="kafka",e.GraphQL="graphql"}(r||(t.InvestigationType=r={})),function(e){e.HTTP="http",e.DB="db",e.REDIS="redis"}(n||(t.OutboundType=n={}))},9107:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})}},t={};return function o(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,o),i.exports}(3487)})());
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(global,()=>(()=>{"use strict";var e={765:(e,t)=>{var o,n;Object.defineProperty(t,"__esModule",{value:!0}),t.HudSessionInitStatus=t.HudRunningMode=t.KeepAliveMessage=void 0,t.KeepAliveMessage={msg:"keep-alive"},function(e){e[e.detached=0]="detached",e[e.disabled=1]="disabled",e[e.enabled=2]="enabled"}(o||(t.HudRunningMode=o={})),function(e){e[e.success=0]="success",e[e.throttled=1]="throttled"}(n||(t.HudSessionInitStatus=n={}))},878:(e,t)=>{var o;Object.defineProperty(t,"__esModule",{value:!0}),t.GraphQLSupportedOperations=void 0,function(e){e.query="query",e.mutation="mutation",e.subscription="subscription"}(o||(t.GraphQLSupportedOperations=o={}))},1569:e=>{e.exports=require("zod")},2176:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},3487:function(e,t,o){var n=this&&this.__createBinding||(Object.create?function(e,t,o,n){void 0===n&&(n=o);var r=Object.getOwnPropertyDescriptor(t,o);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,n,r)}:function(e,t,o,n){void 0===n&&(n=o),e[n]=t[o]}),r=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||n(t,e,o)};Object.defineProperty(t,"__esModule",{value:!0}),r(o(7789),t),r(o(8086),t),r(o(7935),t),r(o(6910),t),r(o(2176),t),r(o(9107),t),r(o(7022),t),r(o(6604),t),r(o(4909),t),r(o(878),t),r(o(8377),t),r(o(8054),t),r(o(6328),t),r(o(6413),t),r(o(6364),t),r(o(765),t)},4909:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},6328:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},6364:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HudSessionOptionsSchema=t.HudOptionsSchema=void 0;const n=o(1569),r=o(7789);t.HudOptionsSchema=n.z.object({includeModules:n.z.array(n.z.string()).optional(),excludeDirs:n.z.array(n.z.string()).optional(),enableFrameworks:r.availableFrameworksSchema.optional(),maxMappedFunctions:n.z.number().optional(),minPodMemoryMB:n.z.number().optional(),maxFileSizeBytes:n.z.number().optional(),maxTimeUntilInitSessionMs:n.z.number().optional(),verbose:n.z.boolean().optional(),disableSourceMapsResolution:n.z.boolean().optional(),disableRuntimeInstrumentation:n.z.boolean().optional(),disableParametersExtraction:n.z.boolean().optional(),disableDetachedFunctions:n.z.boolean().optional(),customOptions:n.z.record(n.z.string(),n.z.string()).optional()}),t.HudSessionOptionsSchema=n.z.object({tags:n.z.record(n.z.string(),n.z.string()).optional()})},6413:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},6604:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},6910:(e,t)=>{var o,n,r;Object.defineProperty(t,"__esModule",{value:!0}),t.EntityType=t.ArgumentTypes=t.ParameterTypes=void 0,function(e){e.Identifier="Identifier",e.RestElement="RestElement",e.ArrayPattern="ArrayPattern",e.AssignmentPattern="AssignmentPattern",e.ObjectPattern="ObjectPattern",e.ObjectProperty="ObjectProperty"}(o||(t.ParameterTypes=o={})),function(e){e.StringLiteral="StringLiteral",e.Identifier="Identifier",e.TemplateString="TemplateString"}(n||(t.ArgumentTypes=n={})),function(e){e.FunctionDeclaration="functionDeclaration",e.FunctionExpression="functionExpression",e.FunctionArrow="functionArrow",e.ClassMethod="classMethod",e.ObjectMethod="objectMethod",e.ClassPrivateMethod="classPrivateMethod",e.ClassDeclaration="classDeclaration",e.ClassExpression="classExpression",e.ObjectExpression="objectExpression",e.Program="program",e.ForLoop="forLoop",e.ForBlock="forBlock",e.ForTest="forTest",e.Block="block",e.While="while",e.DoWhile="doWhile",e.Do="Do",e.WhileTest="whileTest",e.Switch="switch",e.SwitchCase="switchCase",e.Catch="catch",e.With="with",e.If="if",e.IfTest="ifTest",e.IfConsequent="ifConsequent",e.IfAlternate="ifAlternate",e.TryCatch="tryCatch",e.Try="try",e.Finally="finally",e.Other="other",e.File="file"}(r||(t.EntityType=r={}))},7022:(e,t)=>{var o;Object.defineProperty(t,"__esModule",{value:!0}),t.Format=t.FUNCTION_DECLARATION_VERSION=void 0,t.isSupportedFormat=function(e){return Object.values(o).includes(e)},t.FUNCTION_DECLARATION_VERSION="1.1.3",function(e){e.cjs="commonjs",e.esm="module",e.ts="typescript",e.moduleTypescript="module-typescript",e.commonjsTypescript="commonjs-typescript"}(o||(t.Format=o={}))},7789:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.availableFrameworksSchema=t.availableFrameworks=void 0;const n=o(1569);t.availableFrameworks={axios:"axios",pg:"pg",ioredis:"ioredis",nodeFetch:"nodeFetch",request:"request",express:"express",koa:"koa",graphql:"graphql",http:"http",https:"https",nextjs:"nextjs",nestjs:"nestjs",kafkajs:"kafkajs",confluentKafkaJs:"confluentKafkaJs",codegenieServerlessExpress:"codegenieServerlessExpress",sqs:"sqs",serverlessHttp:"serverlessHttp",mongodb:"mongodb",mongoose:"mongoose"},t.availableFrameworksSchema=n.z.union([n.z.map(n.z.nativeEnum(t.availableFrameworks),n.z.boolean()),n.z.record(n.z.nativeEnum(t.availableFrameworks),n.z.boolean())]).transform(e=>e instanceof Map?e:new Map(Object.entries(e)))},7935:(e,t)=>{function o(e,t){return t?t instanceof RegExp?e+t.toString():("/"===t[t.length-1]&&t.length>1&&(t=t.slice(0,-1)),(t=e+t).replace(/\/{2,}/g,"/")):t}Object.defineProperty(t,"__esModule",{value:!0}),t.EndpointDeclaration=void 0,t.EndpointDeclaration=class{flow_id;methods;framework;partial_path;path;constructor(e,t,n,r,i,a){this.flow_id=e,this.methods=t,this.framework=n,this.partial_path=a,r||(r=""),this.path=o(r,i),this.partial_path=o(r,a)}}},8054:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},8086:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},8377:(e,t)=>{var o,n,r;Object.defineProperty(t,"__esModule",{value:!0}),t.OutboundType=t.InvestigationType=t.InvestigationStatus=void 0,function(e){e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Cleared=3]="Cleared"}(o||(t.InvestigationStatus=o={})),function(e){e.HTTP="http",e.SQS="sqs",e.Kafka="kafka",e.GraphQL="graphql"}(n||(t.InvestigationType=n={})),function(e){e.HTTP="http",e.DB="db",e.REDIS="redis",e.MONGO="mongo"}(r||(t.OutboundType=r={}))},9107:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})}},t={};return function o(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,o),i.exports}(3487)})());
2
2
  //# sourceMappingURL=dto.js.map
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,()=>(()=>{var e={290:e=>{"use strict";e.exports=require("async_hooks")},336:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(2822),s=r(8949),a=r(4393),u=r(714);class c extends u.FrameworkPatcher{_patch(e){return this._patchSendRequest(e),n.instrument_logger.info("Patched @codegenie/serverless-express/src/frameworks/express.js successfully"),e}_patchSendRequest(e){const t=e.sendRequest;e.sendRequest=function(e){const r=e?.request,u=e?.response;if(!r||!u)return t.call(this,e);const c=a.HttpEndpointMetric.createUsableMetric(),d=(0,o.getFlowStateStorage)(),l={httpMetric:c},f=()=>{try{c.start(),c.setRequestAttributes(r)}catch(e){n.instrument_logger.error("Failed to start flowMetric during sendRequest patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{u.once("finish",function(){try{c.calculateDuration(),(0,i.finishHttpInvestigation)(r,u,c),c.setResponseAttributes(u),c.end()}catch(e){n.instrument_logger.error("Failed to end flowMetric during sendRequest patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),u.once("close",()=>{(0,i.clearInvestigationDataFromStorage)(),(0,s.clearFlowStateData)(l)})}catch(e){n.instrument_logger.error("Failed to end flowMetric during sendRequest patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return(0,i.runWithInvestigation)(()=>t.call(this,e))};return d?d.run(l,f):f()},(0,s.copyPropertiesToTarget)(t,e.sendRequest)}}t.default=c},392:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.patchAllSetIntervalFunctions=function(){if(u)return;u=!0;const e=function(e){const t=function(t,...r){let s="";try{const e=(0,i.executionAsyncResource)()[o.kHudCaller]??globalThis.hudStack[globalThis.hudStackIndex.value];s="function"==typeof t?function(...r){try{(0,i.executionAsyncResource)()[o.kHudCaller]=e}catch{(0,n.limitedLogger)("wrappedHandler failed")}return t.apply(this,r)}:t}catch{(0,n.limitedLogger)("patchedSetInterval failed")}return e(s,...r)};return(0,s.copyPropertiesToTarget)(e,t),t}(a.setInterval);a.setInterval=e,globalThis.setInterval=e};const n=r(523),o=r(7131),i=r(6698),s=r(8949),a=r(7997);let u=!1},486:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8544);class o extends n.BaseKafkaJSPatcher{getExportsRoot(e){return e}getGroupId(e){return e[0].groupId}moduleName(){return"KafkaJS"}}t.default=o},523:e=>{"use strict";e.exports=require("./logger")},646:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(8949),i=r(5128),s=r(714);class a extends s.FrameworkPatcher{_patch(e){return this._patchCreate(e),n.instrument_logger.info("Patched NestJS RouterExecutionContext successfully"),e}_patchCreate(e){const t=e.RouterExecutionContext.prototype.create;e.RouterExecutionContext.prototype.create=function(...e){try{const t=e[0],r=e[1];"function"==typeof t.constructor&&"function"==typeof r?e[1]=(0,i.wrapLinkedFunction)(r):n.instrument_logger.error("Invalid args in NestJS RouterExecutionContext.create",{args:e})}catch(e){n.instrument_logger.error("Error in NestJS RouterExecutionContext patcher",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,e)},(0,o.copyPropertiesToTarget)(t,e.RouterExecutionContext.prototype.create)}}t.default=a},714:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.FrameworkPatcher=void 0,t.isSupportedVersion=l,t.extractModuleVersion=f,t.getFrameworkPatcher=function(e){return new(r(2828)(`./${e}`).default)};const a=r(2546),u=r(523),c=s(r(6928)),d=r(8064);function l(e,t){return""===e||d.satisfies(d.coerce(e),t)}function f(e){try{const t=a.suppressTracesFS.readFileSync(c.join(e,"package.json"),{encoding:"utf8"}),r=JSON.parse(t).version;return"string"==typeof r?r:""}catch{u.instrument_logger.info("Failed extracting version",{baseDir:e})}return""}t.FrameworkPatcher=class{patch(e,t,r,n,o=this.constructor.name){try{if(this.isSupported(t,o,r,n))return this._patch(e)}catch(e){u.instrument_logger.error("Unhandled error during patching framework",{framework:o,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}isSupported(e,t,r,n){const o=f(e);return!!l(o,r)||(u.instrument_logger.warning("Unsupported version",{framework:t,version:o,supportedVersion:r,basedir:e}),n&&n.isOutbound||u.customer_logger.logEntry(a.UserErrorLogs.UnsupportedFrameworkVersion(t)),!1)}}},828:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KafkaJSMetric=void 0;const n=r(523),o=r(7131),i=r(9873);class s extends i.FlowMetric{partition;error;producedTimestamp;totalConsumeDuration;constructor(e){super(e)}_createUsableMetric(e){return this}end(){this.producedTimestamp&&(this.totalConsumeDuration=Number(Date.now()-this.producedTimestamp)*Number(1e6)),super.end()}addProducedTimestamp(e){void 0!==e&&(this.producedTimestamp=Number(e))}addPartition(e){this.partition=e}setError(e){this.error=(0,o.extractName)(e)}setUserError(e){this.error=e}toRaw(){if(void 0!==this.partition)return{flow_id:this.flowId,type:"KafkaJSMetric",duration:this.duration,partition:this.partition,error:this.error,total_consume_duration:this.totalConsumeDuration,error_breakdown:this.errorBreakdown};n.instrument_logger.warning("No partition found for message",{flowId:this.flowId})}}t.KafkaJSMetric=s},857:e=>{"use strict";e.exports=require("os")},932:e=>{"use strict";e.exports=require("process")},1326:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),i=r(523),s=r(8949),a=r(714),u=n(r(9589));class c extends a.FrameworkPatcher{static nextJSHudMarked=Symbol.for("hudNextJSMarked");_patch(e){return(0,o.setIsNextJsApp)(!0),this._pathLoad(e),i.instrument_logger.info("Patched Next.js successfully"),e}_pathLoad(e){try{const t=e.RouteModuleLoader;if(t[c.nextJSHudMarked])return e;const r=t.load;t.load=async function(...e){const t=await r.apply(this,e);try{if(t){const e=t.definition?.pathname;e&&!t[c.nextJSHudMarked]&&(u.default._detectAndPatchSupportedMethods(t,e),t[c.nextJSHudMarked]=!0)}}catch(e){i.instrument_logger.error("Failed to patch Next.js route module",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t},t[c.nextJSHudMarked]=!0,(0,s.copyPropertiesToTarget)(r,t.load)}catch(e){i.instrument_logger.error("Failed to patch Next.js base server",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}}t.default=c},1427:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSystemInfo=function(){return{pod_name:c(),node_name:d()}};const o=r(2546),i=n(r(857)),s=Symbol("not found");let a,u;function c(){if(a!==s){if(a)return a;try{return a=i.default.hostname(),a}catch{return void(a=s)}}}function d(){if(u!==s){if(u)return u;try{const e=o.suppressTracesFS.readFileSync("/etc/machine-id","utf8").trim();return u=e,u}catch{return void(u=s)}}}},1502:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5809),o=r(8528),i=r(8269),s=r(2546),a=r(523),u=r(8949),c=r(714);class d extends c.FrameworkPatcher{static koaModuleName="koa";static koaPatchedSymbol=Symbol.for(n.hudConfig.hudPatchedName);_patch(e){return this._patchAppUse(e),a.instrument_logger.info("Patched koa successfully"),e}_patchAppUse(e){const t=e.prototype.use;e.prototype.use=function(e){const r=t.apply(this,arguments);try{if(!arguments[0].router)return r;const e=arguments[0].router.stack;for(let t=0;t<e.length;t++)d._wrapRoute(e[t])}catch(e){a.instrument_logger.error("Failed to patch koa.use function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r},(0,u.copyPropertiesToTarget)(t,e.prototype.use)}static _wrapRoute(e){if(e.methods&&0===e.methods.length)return;if(!e.stack[0][d.koaPatchedSymbol]){const t=(0,u.wrapFlow)(p,e.stack[0],!0);e.stack[0]=t,e.stack[0][d.koaPatchedSymbol]=!0}const t=(0,s.generateEndpointFlowId)(e.path,e.methods);(0,i.storeEndpointDeclaration)(new o.EndpointDeclaration(t,e.methods,"koa",void 0,e.path));for(const r of e.methods)g(t,e.path,r)}}function l(e,t){return e+"|"+t}t.default=d;const f=new Map;function g(e,t,r){f.set(l(t,r),e)}function p(e,t){if(0===t.length)return;const r=t[0]._matchedRoute,n=t[0].req?.method;return function(e,t){return f.get(l(e,t))}(r,n)}},2080:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqsMetric=void 0;const n=r(9873);class o extends n.FlowMetric{errors;msgCount;e2eEpocStartTimeMS;e2eDurationNS;_finishedMessageCount;constructor(e){super(e),this._finishedMessageCount=0,this.errors={}}addError(e,t=1){this.errors[e]=(this.errors[e]??0)+t}setUserError(e){this.addError(e,1)}increaseAndShouldEnd(e=1){return this._finishedMessageCount+=e,!(this.msgCount&&this._finishedMessageCount<this.msgCount)}end(){this.e2eEpocStartTimeMS&&(this.e2eDurationNS=Number(Date.now()-this.e2eEpocStartTimeMS)*Number(1e6)),super.end()}_createUsableMetric(e){return this}toRaw(){return{flow_id:this.flowId,type:"SqsMetric",duration:this.duration,e2e_duration:this.e2eDurationNS,msg_count:this.msgCount,errors:this.errors,error_breakdown:this.errorBreakdown}}}t.SqsMetric=o},2197:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)},a=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.serializableInvestigation=t.koa=t.express=t.safeLog=t.registerHook=t.hudRITM=void 0;var u=r(5688);Object.defineProperty(t,"hudRITM",{enumerable:!0,get:function(){return u.hudRITM}}),Object.defineProperty(t,"registerHook",{enumerable:!0,get:function(){return u.registerHook}}),Object.defineProperty(t,"safeLog",{enumerable:!0,get:function(){return u.safeLog}}),s(r(3901),t),t.express=a(r(7127)),s(r(714),t),t.koa=a(r(1502)),s(r(7166),t),s(r(3073),t),s(r(392),t);var c=r(2822);Object.defineProperty(t,"serializableInvestigation",{enumerable:!0,get:function(){return c.serializableInvestigation}})},2546:e=>{"use strict";e.exports=require("./lib")},2729:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(2822),s=r(8949),a=r(4393),u=r(714);class c extends u.FrameworkPatcher{_patch(e){const t=this._patchGetFramework(e);return n.instrument_logger.info("Patched serverless-http/lib/framework/get-framework.js successfully"),t}_patchGetFramework(e){const t=e;return e=function(...e){const r=t.apply(t.this,e);async function u(e,...t){const u=a.HttpEndpointMetric.createUsableMetric(),c=(0,o.getFlowStateStorage)(),d={httpMetric:u},l=async()=>{try{u.start(),u.setRequestAttributes(e)}catch(e){n.instrument_logger.error("Failed to start flowMetric during framework serverless request handler patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const o=await(0,i.runWithInvestigation)(()=>r.apply(r.this,[e,...t]));return o.once("finish",function(){try{u.calculateDuration(),(0,i.finishHttpInvestigation)(e,o,u),u.setResponseAttributes(o),u.end()}catch(e){n.instrument_logger.error("Failed to end flowMetric during framework serverless request handler patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),o.once("close",()=>{(0,i.clearInvestigationDataFromStorage)(),(0,s.clearFlowStateData)(d)}),o};return c?await c.run(d,l):await l()}return(0,s.copyPropertiesToTarget)(r,u),u},(0,s.copyPropertiesToTarget)(t,e),e}}t.default=c},2741:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(6730),i=r(4815),s=r(7225),a=r(714);class u extends a.FrameworkPatcher{_patch(e){return s.isVerboseLoggingEnabled?((0,o.patchMethods)(e,"application_export"),(0,i.patchUse)(e,"application",!1),(0,s.logLazyRouter)(e),n.instrument_logger.info("Patched express.Application successfully"),e):(n.instrument_logger.info("Skipping express.Application patching, verbose logging is not enabled"),e)}}t.default=u},2784:e=>{"use strict";e.exports=require("../native/_index")},2822:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStackTraceWithoutMessage=f,t.serializableInvestigation=g,t.getBaseInvestigationStorage=p,t.createNewInvestigation=function(){if(!globalThis.hudEnableInvestigation)return;const e=(0,a.getInvestigationStorage)();void 0!==e&&e.enterWith(p())},t.runWithInvestigation=function(e){if(!globalThis.hudEnableInvestigation)return e();const t=(0,a.getInvestigationStorage)();return void 0===t?e():t.run(p(),e)},t.closeInvestigation=h,t.clearInvestigationDataFromStorage=m,t.storeInvestigation=y,t.getInvestigationDedupingKey=_,t.minimizeObject=k,t.finishHttpInvestigation=function(e,t,r){try{if(r.apiProtocol===u.ApiProtocol.GraphQL)return void function(e,t,r){const i=function(e,t){const r=t.apiProtocolAttributes;return e.statusCode>=500||r&&r.errorOccurred||S()?"Error":!!x(t,o.InvestigationType.GraphQL)&&"Duration"}(t,r);if(!1===i)return;const u=w(r,i,o.InvestigationType.GraphQL);if(void 0===u)return void(0,s.limitedLogger)("finishHttpInvestigation: base investigation return undefined");const g=r.getFlowId(),p=r.getMsStartTime();if(void 0===g||void 0===p)return void(0,s.limitedLogger)("flowId or reqTimestamp are undefined even though they shouldn't",{flowId:g,reqTimestamp:p});const h=r.apiProtocolAttributes?.errors;y(u,{type:o.InvestigationType.GraphQL,flow_id:g,timestamp:p,request_body:k(e.body,Math.max(n.hudConfig.dynamicConfig.investigationRateLimits.maxObjectDepth,4)),graphql_errors:h?.map(e=>({name:(0,a.extractName)(e),message:k((0,a.extractMessage)(e)),stackTrace:e instanceof Error?f(e.message,e.stack):void 0})),status_code:t.statusCode,machine_metrics:(0,c.getMachineMetrics)(),observability_identifiers:(0,d.getObservabilityIdentifiersHttp)(e),system_info:(0,l.getSystemInfo)()})}(e,t,r);!function(e,t,r){const n=function(e,t){return e.statusCode>=500||S()?"Error":!!x(t,o.InvestigationType.HTTP)&&"Duration"}(t,r);if(!1===n)return;const i=w(r,n,o.InvestigationType.HTTP);if(void 0===i)return;try{(0,s.limitedLogger)("http requests headers",{headers:Object.keys(e.headers)})}catch{(0,s.limitedLogger)("failed to log http requests headers")}const a=r.getFlowId(),u=r.getMsStartTime(),f=r.apiProtocolAttributes;if(void 0===a||!f||void 0===f.method||void 0===u)return void(0,s.limitedLogger)("route, method, or reqTimestamp are undefined even though they shouldn't",{flowId:a,method:f.method,reqTimestamp:u});const g=e.url||e.path,p=g?.split("?")[0];y(i,{type:o.InvestigationType.HTTP,endpoint_uuid:a,route:p,method:f.method,timestamp:u,params:k(e.params),query:k(e.query),request_body:k(e.body),status_code:t.statusCode,machine_metrics:(0,c.getMachineMetrics)(),observability_identifiers:(0,d.getObservabilityIdentifiersHttp)(e),extra_headers:(0,d.getExtraHeaders)(e),system_info:(0,l.getSystemInfo)()})}(e,t,r)}catch(e){(0,s.limitedLogger)("Failed to finish http investigation",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}finally{m()}},t.finishSqsInvestigation=function(e,t){try{const r=function(e){return Object.keys(e.errors).length>0||S()?"Error":!!x(e,o.InvestigationType.SQS)&&"Duration"}(t);if(!1===r)return;const n=w(t,r,o.InvestigationType.SQS);if(void 0===n)return;const i=t.getFlowId(),a=t.getMsStartTime();if(void 0===a||void 0===i)return void(0,s.limitedLogger)("reqTimestamp is undefined even though it shouldn't",{flowId:i});y(n,{type:o.InvestigationType.SQS,timestamp:a,flow_id:i,messages:k(e),machine_metrics:(0,c.getMachineMetrics)(),system_info:(0,l.getSystemInfo)()})}catch(e){(0,s.limitedLogger)("Failed to finish sqs investigation",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}finally{m()}},t.finishKafkaJSInvestigation=function(e,t,r,n){try{const i=function(e){return void 0!==e.error||S()?"Error":!!x(e,o.InvestigationType.Kafka)&&"Duration"}(t);if(!1===i)return;const a=w(t,i,o.InvestigationType.Kafka);if(void 0===a)return;const u=t.getFlowId(),f=t.getMsStartTime();if(void 0===f||void 0===u)return void(0,s.limitedLogger)("reqTimestamp is undefined even though it shouldn't",{flowId:u});const g=e.map(e=>{let t=e.value;t instanceof Buffer&&(t=t.toString());try{t=JSON.parse(t)}catch{}return{key:e.key,value:t,timestamp:e.timestamp,offset:e.offset,headers:e.headers,attributes:e.attributes}});y(a,{type:o.InvestigationType.Kafka,timestamp:f,topic:r,partition:n,flow_id:u,messages:k(g),machine_metrics:(0,c.getMachineMetrics)(),system_info:(0,l.getSystemInfo)(),observability_identifiers:(0,d.getObservabilityIdentifiers)()})}catch(e){(0,s.limitedLogger)("Failed to finish kafkajs investigation",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}finally{m()}},t.getErrorRecordsFromInvestigation=E;const n=r(5809),o=r(8528),i=r(8269),s=r(523),a=r(7131),u=r(4393),c=r(7808),d=r(7603),l=r(1427);function f(e,t){if(void 0===t)return;const r=function(e){if(void 0===e)return 0;let t=0;for(let r=0;r<e.length;r++)"\n"===e[r]&&t++;return t}(e)+1;let n=-1;for(let e=0;e<r;e++)if(n=t.indexOf("\n",n+1)??-1,-1===n)return;return-1!==n?t.slice(n+1):void 0}function g(e){const{data:t}=e;return{status:e.status,context:t.context,exceptions:Array.from(t.exceptions.values()).map(({exception:e,executionFlow:t,caught:r})=>({name:(0,a.extractName)(e),message:(0,a.extractMessage)(e),stackTrace:e instanceof Error?f(e.message,e.stack):void 0,executionFlow:t.map(e=>({function_id:e.function_id,caller_id:e.caller_id,args:void 0!==e.args?k(e.args,n.hudConfig.dynamicConfig.investigationRateLimits.maxObjectDepth+2):void 0})),caught:r})),userContext:t.userContext,userDefinedError:t.userDefinedError,caught:t.caught,triggerType:t.triggerType,duration:t.duration,durationThreshold:t.durationThreshold,outbounds:t.outbounds.map(e=>function(e){try{return{function_id:e.function_id,caller_id:e.caller_id,type:e.type,duration:e.duration?Number(e.duration):void 0,timestamp:e.timestamp,args:k(e.args),result:k(e.result),error:e.error?{type:"string"==typeof e.error?e.error:(0,a.extractName)(e.error),message:(0,a.extractMessage)(e.error)}:void 0,...e.type===o.OutboundType.HTTP?{bodyDuration:e.bodyDuration,bodyError:e.bodyError?{type:"string"==typeof e.bodyError?e.bodyError:(0,a.extractName)(e.bodyError),message:(0,a.extractMessage)(e.bodyError)}:void 0}:{}}}catch(e){return void(0,s.limitedLogger)("error serializing outbound",e)}}(e)).filter(e=>void 0!==e)}}function p(){return{status:o.InvestigationStatus.Open,data:{triggerType:void 0,duration:0,caught:!0,exceptions:new Map,outbounds:[]}}}function h(){const e=(0,a.getInvestigationStorage)();if(void 0===e)return void(0,s.limitedLogger)("closeInvestigation: getStorage() is undefined");const t=e.getStore();if(void 0!==t&&t.status===o.InvestigationStatus.Open)return t.status=o.InvestigationStatus.Closed,t;(0,s.limitedLogger)(`closeInvestigation: investigation is undefined or not open, is undefined: ${void 0===t}`)}function m(){try{const e=(0,a.getInvestigationStorage)();if(void 0===e)return;const t=e.getStore();if(void 0===t||t.status===o.InvestigationStatus.Cleared)return;!function(e){try{e.data.exceptions.clear(),e.data.outbounds.length=0,e.data=void 0,e.status=o.InvestigationStatus.Cleared}catch{}}(t)}catch{}}function y(e,t){e.data.context=t,(0,i.storeClosedInvestigation)(g(e))}function b(e){for(const t of e)if(!t.is_outbound_function)return t.function_id}function _(e,t,r){let n="";for(const t of e)n+=`${t.error_type}-${t.function_id}|`;return n+=`${t}`,void 0!==r&&(n+=`|${r}`),n}let v=null;function k(e,t=n.hudConfig.dynamicConfig.investigationRateLimits.maxObjectDepth,o=new WeakSet){try{if(null===v&&(v=r(8611).IncomingMessage),null!==e&&"object"==typeof e){if(o.has(e))return"[Circular Reference]";if(v&&e instanceof v)return"[Http Request]";o.add(e)}if(null==e||["number","boolean"].includes(typeof e))return e;if("string"==typeof e)return e.length>n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength?e.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength)+"...":e;if(e instanceof Buffer)return e.length>n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength?e.subarray(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength).toString()+"...":e.toString();if(e instanceof ArrayBuffer){const t=Buffer.from(e);return t.length>n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength?t.subarray(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength).toString()+"...":t.toString()}if(["bigint","symbol"].includes(typeof e))return k(e.toString(),t-1,o);if("function"==typeof e)return`[Function: ${e.name||"anonymous"}]`;if(void 0===e)return;if(Array.isArray(e))return t<=0?"[Array]":e.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength).map(e=>k(e,t-1,o));if(e instanceof Map)return t<=0?"[Map]":{"[Map]":Array.from(e.entries()).slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength).map(([e,r])=>[k(e,t-1,o),k(r,t-1,o)])};if(e instanceof Set)return t<=0?"[Set]":{"[Set]":Array.from(e.values()).slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength).map(e=>k(e,t-1,o))};if(e instanceof Date){let r;try{r=e.toISOString()}catch{}return k(r,t-1,o)}if(e instanceof RegExp)return k(e.toString(),t-1,o);if(e&&"Proxy"===e[Symbol.toStringTag])return k(e.target||e,t-1,o);if(e&&e[Symbol.toStringTag])return`[${e[Symbol.toStringTag]}]`;if("object"==typeof e){if(t<=0)return"[Object]";const r={},i=Object.getOwnPropertyNames(e),s=Object.getOwnPropertySymbols(e);for(const s of i.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength))try{r[s.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxKeyLength)]=k(e[s],t-1,o)}catch{}for(const i of s.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength))try{r[i.toString()]=k(e[i],t-1,o)}catch{}return r}}catch{}}function w(e,t,r){let o;if(o="Error"===t?function(e){const t=h();if(void 0===t)return void(0,s.limitedLogger)("finishErrorInvestigation: investigation is undefined");const r=e.getFlowId();if(void 0===r)return void(0,s.limitedLogger)("finishErrorInvestigation: flowId is undefined");const o=E(t),a=_(o,t.data.caught,t.data.userDefinedError);if(e.setErrorBreakdown({key:a,errors:o,caught:t.data.caught,failure_type:t.data.userDefinedError}),t.data.userDefinedError&&e.setUserError(t.data.userDefinedError),(0,i.getGlobalInvestigationTracking)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations)return void(0,s.limitedLogger)("finishErrorInvestigation: globalInvestigationTracking is greater than maxTotalInvestigations",{globalInvestigationTracking:(0,i.getGlobalInvestigationTracking)(),maxTotalInvestigations:n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations});if((0,i.getTotalInvestigationsErrorBased)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigationsErrorBased)return void(0,s.limitedLogger)("finishErrorInvestigation: currentTotalInvestigationsErrorBased is greater than maxTotalInvestigationsErrorBased");const u=(0,i.getInvestigationDedupingCache)(r).get(a)??0;if(!(u>=n.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations))return(0,i.increaseGlobalInvestigationTracking)(),(0,i.increaseTotalInvestigationsErrorBased)(),(0,i.increaseInvestigationDedupingCache)(r,a),t;(0,s.limitedLogger)("finishErrorInvestigation: investigationCount is greater than maxSameInvestigations",{flowId:r,investigationDedupKey:a,investigationCount:u,maxSameInvestigations:n.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations},a)}(e):function(e,t){const r=e.getFlowId();if(void 0===r)return void(0,s.limitedLogger)("finishDurationInvestigation: flowId is undefined");if((0,i.getGlobalInvestigationTracking)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations)return void(0,s.limitedLogger)("finishDurationInvestigation: currentTotalInvestigationsGlobal is greater than maxTotalInvestigations");if((0,i.getTotalInvestigationsDurationBased)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigationsDurationBased)return void(0,s.limitedLogger)("finishDurationInvestigation: currentTotalInvestigationsDurationBased is greater than maxTotalInvestigationsDurationBased");const o=C(r,t);if(void 0!==o)return(0,i.getInvestigationDurationCount)(r)>=o.number_of_dumps?((0,s.limitedLogger)("finishDurationInvestigation: currentInvestigationCount is greater than durationThresholdAndCount.count"),void s.app_logger.debug("finishDurationInvestigation: currentInvestigationCount is greater than durationThresholdAndCount.count")):((0,i.increaseInvestigationDurationCount)(r),(0,i.increaseGlobalInvestigationTracking)(),(0,i.increaseTotalInvestigationsDurationBased)(),h());(0,s.limitedLogger)("finishDurationInvestigation: durationThresholdAndCount is undefined")}(e,r),void 0!==o)return o.data.triggerType=t,o.data.duration=e.duration,o.data.durationThreshold=C(e.getFlowId()??"",r)?.duration,o;(0,s.limitedLogger)("finishInvestigation: investigation return undefined")}function C(e,t){const r=(0,i.getFlowIdDurationThresholdAndCount)(e);return void 0===r?(0,i.getFlowIdDurationThresholdAndCount)(`default-${t}`):r}function S(){const e=(0,a.getInvestigationStorage)();if(void 0===e)return!1;const t=e.getStore();return void 0!==t?.data?.userDefinedError}function x(e,t){const r=e.getFlowId();if(void 0===r)return!1;const n=C(r,t);return void 0!==n&&n.duration<e.duration}function E(e){const t=new Set,r=[];for(const n of e.data.exceptions.values()){const e=(0,a.extractName)(n.exception),o=b(n.executionFlow)??"",i=`${e}-${o}`;if(t.has(i))continue;t.add(i);const s={error_type:e,function_id:o};r.push(s)}return r}},2828:(e,t,r)=>{var n={"./baseKafkaJsPatcher":8544,"./baseKafkaJsPatcher.ts":8544,"./codeGenieServerlessExpress":336,"./codeGenieServerlessExpress.ts":336,"./confluentKafkaJs":7276,"./confluentKafkaJs.ts":7276,"./express":7127,"./express.ts":7127,"./express/methods":6730,"./express/methods.ts":6730,"./express/route":2977,"./express/route.ts":2977,"./express/router":4815,"./express/router.ts":4815,"./express/verbosity":7225,"./express/verbosity.ts":7225,"./expressApplication":2741,"./expressApplication.ts":2741,"./flows/flow":9873,"./flows/flow.ts":9873,"./flows/http":4393,"./flows/http.ts":4393,"./flows/kafkajs":828,"./flows/kafkajs.ts":828,"./flows/sqs":2080,"./flows/sqs.ts":2080,"./frameworkPatcher":714,"./frameworkPatcher.ts":714,"./graphql":7214,"./graphql.ts":7214,"./http":5459,"./http.ts":5459,"./internal/pLimit":4986,"./internal/pLimit.ts":4986,"./kafkajs":486,"./kafkajs.ts":486,"./koa":1502,"./koa.ts":1502,"./nestjsRouterExecutionContext":646,"./nestjsRouterExecutionContext.ts":646,"./nestjsRpcContextCreator":4290,"./nestjsRpcContextCreator.ts":4290,"./nextJsConfig":9723,"./nextJsConfig.ts":9723,"./nextJsModuleLoader":1326,"./nextJsModuleLoader.ts":1326,"./nextJsRouteModule":8840,"./nextJsRouteModule.ts":8840,"./nextjs":9589,"./nextjs.ts":9589,"./outbound/axios":5354,"./outbound/axios.ts":5354,"./outbound/ioredis":7535,"./outbound/ioredis.ts":7535,"./outbound/nodeFetch":8564,"./outbound/nodeFetch.ts":8564,"./outbound/pg":7427,"./outbound/pg.ts":7427,"./outbound/request":4349,"./outbound/request.ts":4349,"./outbound/wrapOutbound":9938,"./outbound/wrapOutbound.ts":9938,"./router":5946,"./router.ts":5946,"./serverlessHttp":2729,"./serverlessHttp.ts":2729,"./sqsConsumer":5150,"./sqsConsumer.ts":5150};function o(e){var t=i(e);return r(t)}function i(e){if(!r.o(n,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return n[e]}o.keys=function(){return Object.keys(n)},o.resolve=i,e.exports=o,o.id=2828},2977:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.patchRoute=function(e){const t=(0,g.getMethods)();t.concat("all").forEach(function(r){const n=e.prototype[r];e.prototype[r]=function(){let e;try{e=p(Array.prototype.slice.call(arguments));let n=function(e){const t=e[0][a.hudConfig.express.layerStateSymbol];if(t)return t.flowId}(e);const o=function(e){const t=e[0][a.hudConfig.express.layerStateSymbol];if(t)return t.kind}(e),i=function(e){const t=e[0][a.hudConfig.express.layerStateSymbol];return!!t&&t.allMethod}(e);if(n||(n=[l.randomUUID()]),"application"===o)if(Array.isArray(this.path)){y(e,void 0);for(let e=0;e<this.path.length;e++)m(n[e],i?t:[r],this.path[e])}else y(e,n[0]),m(n[0],i?t:[r],this.path);else if("router"===o)if(Array.isArray(this.path)){y(e,void 0);for(let e=0;e<this.path.length;e++)h(this,n[e],r,this.path[e])}else y(e,n[0]),h(this,n[0],r,this.path);else y(e,n[0]),h(this,n[0],r,this.path)}catch(e){d.instrument_logger.error("Failed to patch express.Route.route",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n.apply(this,e||arguments)}})};const a=r(5809),u=r(8528),c=r(8269),d=r(523),l=s(r(6982)),f=r(8949),g=r(6730),p=r(5673);function h(e,t,r,n){!function(e,t,r,n){e[a.hudConfig.express.layerStateSymbol]||(e[a.hudConfig.express.layerStateSymbol]={}),e[a.hudConfig.express.layerStateSymbol][t]?e[a.hudConfig.express.layerStateSymbol][t].methods.push(r):e[a.hudConfig.express.layerStateSymbol][t]={layerPath:n,methods:[r]}}(e,t,r,n),function(e,t,r){const n=new u.EndpointDeclaration(e,[t],"express",void 0,void 0,r);(0,c.storePartialEndpointDeclaration)(n),(0,c.storeExpressEndpointDeclaration)(n)}(t,r,n)}function m(e,t,r){const n=new u.EndpointDeclaration(e,t,"express",void 0,r,void 0);(0,c.storeExpressEndpointDeclaration)(n)}function y(e,t){if(e&&!(e.length<1)){if(a.hudConfig.express.wrapAllCallbacks)for(let r=0;r<e.length;r++){const n=(0,f.wrapFlow)(_(t),e[r],!0);e[r]=n}else{const r=(0,f.wrapFlow)(_(t),e[e.length-1],!0);e[e.length-1]=r}return t}}function b(e){return(0,c.getLinkedConsistentFlowId)(e,!1)||(d.instrument_logger.warning("No consistent flowId found, returning temporary flow id",{flowId:e}),e)}function _(e){return e?function(){return b(e)}:function(e,t){const r=t[0]?.route[a.hudConfig.express.layerStateSymbol],n=t[0]?.url;if(r)for(const[e,t]of Object.entries(r)){if(t.layerPath instanceof RegExp&&t.layerPath.test(n))return b(e);if(n.includes(t.layerPath))return b(e)}d.instrument_logger.warning("No flowId found for path",{states:r,url:n.split("?")[0]})}}},2987:e=>{"use strict";e.exports=require("perf_hooks")},3073:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.registerStackHooks=function(){const e=(0,n.getAsyncHook)();if(e)return e.enable(),e;(0,o.setHudExecutionAsyncResource)(i.executionAsyncResource);const t=(0,i.createHook)({init:a});return t.enable(),(0,n.setAsyncHook)(t),t};const n=r(8269),o=r(7131),i=r(290),s=["Timeout","Immediate","TickObject","PROMISE","Microtask"];function a(e,t,r,n){if(!s.includes(t))return void(n[o.kHudCaller]="");const a=(0,i.executionAsyncResource)();if(void 0===a)return;if(void 0!==a[o.kHudCaller])return void(n[o.kHudCaller]=a[o.kHudCaller]);const u=globalThis.hudStack[globalThis.hudStackIndex.value];n[o.kHudCaller]=u,globalThis.hudStackPop&&(globalThis.hudStackPop=!1,globalThis.hudStackIndex.value--)}},3176:e=>{"use strict";e.exports=require("buffer-crc32")},3339:e=>{"use strict";e.exports=require("module")},3868:e=>{"use strict";e.exports=require("@jridgewell/sourcemap-codec")},3901:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.destructuredImportObj=t.defaultImportObj=void 0,t.getFunctionWrapperTemplate=S,t.splitCode=P,t.getEsbuildMark=O,t.getBundlerBuildIdForMarkedFile=T,t.editInSplits=R,t.appendCiBuildId=D,t.editWithCliBuildId=function(e,t,r,n){let{transformedCode:o,metadatas:i}=A(e,t,r,[],!0);return o+=`\n//# sourceMappingURL=${_.default.basename(t)}.map`,o=D(o,n),{transformedCode:o,metadatas:i}},t.edit=A,t.incrementInstrumentedFunctionsCount=H;const u=a(r(3176)),c=r(3903),d=r(5809),l=r(2546),f=r(523),g=r(8528),p=r(8269),h=r(2546),m=r(7131),y=r(3868),b=s(r(2784)),_=a(r(6928)),v=/([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/;function k(){return d.SDK_MODULE_NAME+"/wrap"}function w(e,t){return`\n ${d.hudConfig.internalAsyncWrapperFunctionName}(\n ${e} ${d.hudConfig.internalAsyncWrapperFunctionName}(\n ${t}, ${d.hudConfig.callContextVarName}, ${(0,m.getWrapperTypeFromPrefix)(e,!0)}\n ),\n ${d.hudConfig.callContextVarName},\n ${(0,m.getWrapperTypeFromPrefix)(e,!1)}\n )\n `}function C(e){return"true"===process.env.HUD_DO_NOT_WRAP_WITH_TRY_CATCH?e:`\n try {\n ${e}\n } catch {}\n `}function S(e,r,n=!1,o=!1,i=!1){const s="BODY_PLACEHOLDER",a="FUNCTION_ID_PLACEHOLDER",u="AWAITABLE_PLACEHOLDER",c="EXCEPTION_VARIABLE_PLACEHOLDER",l="ARGS_ARRAY_PLACEHOLDER",f=function(e,r,n=!1,o=!1){const i=[];if(n)return i;let s;r===g.Format.cjs?s="require":r===g.Format.esm&&(i.push(`import { createRequire as ${e}_createRequire } from "module";`,`const ${e}_require = ${e}_createRequire(import.meta.url);`),s=`${e}_require`);const a=o?`"${k()}"`:`String.raw\`${h.myRequire.resolve(k())}\``;return i.push(`let ${e}_temp = ${t.defaultImportObj};`,`try {\n let ${e}_module = ${s}(${a});\n const ${e}_assert = (x) => {\n if (!x) {\n throw new Error();\n }\n };\n ${e}_assert(${e}_module._hudVersion === "${d.SDK_VERSION}");\n Object.keys(${e}_temp).forEach((key) => {\n ${e}_assert(typeof ${e}_temp[key] === typeof ${e}_module[key]);\n }); \n ${e}_assert(typeof ${e}_module.asyncIteratorWrapper === "function");\n ${e}_temp = ${e}_module;\n } catch {}`,`const ${t.destructuredImportObj} = ${e}_temp;`),i}(e,r,n,i),p=o?", true":"";return{functionWrapper:`{\n let ${d.hudConfig.callContextVarName}; \n const ${d.hudConfig.internalAsyncWrapperFunctionName} = (x, y, z) => {\n ${C(`${d.hudConfig.asyncWrapperFunctionName}(y, z);`)}\n return x;\n };\n \n ${C(`${d.hudConfig.callContextVarName} = ${d.hudConfig.functionInitFunctionName}(${a} ${p});`)}\n\n try {\n ${s}\n } catch (e) {\n ${C(`${d.hudConfig.functionCatchFunctionName}(e, ${d.hudConfig.callContextVarName}, ${l});`)}\n throw e;\n } finally {\n ${C(`${d.hudConfig.functionFinallyFunctionName}(${d.hudConfig.callContextVarName});`)}\n }\n }`,awaitWrapper:`(\n ${w("await",u)}\n )`,yieldWrapper:`\n function* ${e}_generatorWrapper() {\n return (\n ${w("yield",u)}\n )\n }`,yieldStarWrapper:`\n function* ${e}_generatorWrapper() {\n return (\n ${w("yield*",u)}\n )\n }`,initialStatements:f,bodyPlaceholder:s,functionIdPlaceholder:a,awaitablePlaceholder:u,argsArrayPlaceholder:l,fixStackFunction:`\n try {\n ${d.hudConfig.fixStackFunctionName}(${d.hudConfig.callContextVarName})\n } catch {}`,exceptionVariablePlaceholder:c,wrapperUserCatch:C(`${d.hudConfig.wrapperUserCatchFunctionName}(${c}, ${d.hudConfig.callContextVarName}, ${l});`),asyncIteratorWrapper:`${d.hudConfig.asyncIteratorWrapperFunctionName}`}}function x(e,t,r,n,o,i,s){const a=Error.prepareStackTrace;let l=!1,g=function(e){const t=e.match(`${d.hudConfig.bundlerBuildIdVarName}="${v.source}"`);if(t&&t.length>0)return t[1]}(e);g||(g=function(e){return(0,c.v5)(e,d.hudConfig.bundlerBuildUuidNamespace)}(e),l=!0);const p=(0,c.v5)(e,d.hudConfig.functionUuidNamespace),m=(0,u.default)(t.filename).readUInt32BE(),y=(0,u.default)(e).readUInt32BE(),_=(0,h.isNextJsApp)(),k=d.hudConfig.userConfig.enableVarHoisting?.value??!1,w={data:t,bundlerBuildId:g,prefix:d.hudConfig.wrapVarPrefix,...S(d.hudConfig.wrapVarPrefix,t.format,o,r.length>0,i),uuidNamespace:d.hudConfig.functionUuidNamespace,fileHash:p,functionsToInstrument:r,useInputSourcemap:n,isNextJsFile:_,markCode:d.hudConfig.nextJsMarkVarName,enableForAwaitInstrumentation:!i,enableVarHoisting:k,disableParametersExtraction:d.hudConfig.userConfig.disableParametersExtraction?.value??!1,functionIdVar:s?d.hudConfig.esbuildFunctionIdVar:void 0,instrumentOneLiners:d.hudConfig.userConfig.instrumentOneLiners?.value??!0};let C;try{C=b.transform(e,w)}catch(e){throw e instanceof Error&&e.message.includes("Conflicting vars detected")&&f.instrument_logger.error("Conflicting vars detected",{filename:t.filename}),e}return H(C.functionsIds.length,i),C.detectedVarConflicts>0&&f.instrument_logger.warning("Variable conflicts detected during transformation",{filename:t.filename,conflictCount:C.detectedVarConflicts,varHoistingEnabled:k}),_&&C.marksCount!==C.functionsIds.length&&f.instrument_logger.warning("Marks count mismatch while instrumenting functions",{marksCount:C.marksCount,functionsIdsLength:C.functionsIds.length,filename:t.filename}),Error.prepareStackTrace=a,f.instrument_logger.debug(`Successfully transformed ${t.filename}`),{code:C.code,map:C.map,functionIds:C.functionsIds,totalFunctionsCountIncludeUninstrumented:C.totalFunctionsCountIncludeUninstrumented,filename:t.filename,hasInputMap:C.isInputSourcemap,bundlerBuildId:g,bundlerBuildIdGenerated:l,file_path_checksum:m,file_checksum:y,sourceCodeHash:p,moduleBase:C.moduleBase,isNextJsApp:_,marksCount:C.marksCount,detectedForAwaitLoops:C.detectedForAwaitLoops,detectedVarConflicts:C.detectedVarConflicts,failedToRemoveFunctionIdCount:C.failedToRemoveFunctionIdCount,functionsWithMultipleFunctionIdMarks:C.functionsWithMultipleFunctionIdMarks}}t.defaultImportObj="\n {\n wrapperInitial: () => {\n return {};\n },\n wrapperCatch: () => {},\n wrapperFinally: () => {},\n fixStack: () => {},\n wrapperUserCatch: () => {},\n asyncWrapper: (x) => x,\n }\n",t.destructuredImportObj=`\n {\n wrapperInitial: ${d.hudConfig.functionInitFunctionName},\n wrapperCatch: ${d.hudConfig.functionCatchFunctionName},\n wrapperFinally: ${d.hudConfig.functionFinallyFunctionName},\n fixStack: ${d.hudConfig.fixStackFunctionName},\n asyncIteratorWrapper: ${d.hudConfig.asyncIteratorWrapperFunctionName},\n wrapperUserCatch: ${d.hudConfig.wrapperUserCatchFunctionName},\n asyncWrapper: ${d.hudConfig.asyncWrapperFunctionName},\n }\n`;class E extends Error{}function I(e,t){if(e&&t)throw new E("Start mark found inside mark");if(!e&&!t)throw new E("End mark found outside mark")}function M(e,t,r,n){const o=e.split("\n");let i=r,s=n;return i+=o.length-1,i+=t.split("\n").length-1,i===r?s+=o.pop()?.length||0:s=o.pop()?.length||0,{lineOffset:i,columnOffset:s}}function*P(e){let t=!1,r=0,n=0,o=!1,i=0,s=0;const a=new RegExp(`globalThis\\s*?&&\\s*?\\(globalThis\\.${d.hudConfig.esbuildGlobalVar}\\s*?=\\s*?"(Start|End):(?<fileName>.*?):(?<fileHash>.*?)"\\);?`,"g");let u="",c="";for(const d of e.matchAll(a)){if(o=!0,!d.groups)throw new E("No groups found in match");const[a,l]=d,f="Start"===l;I(f,t);let g="";if(t){const t=d.index+a.length;g=e.slice(r,t);const o=n+Buffer.byteLength(g,"utf8"),l=Number(c);yield{edit:!0,code:g,fileName:u,fileChecksum:isNaN(l)?void 0:l,lineOffset:i,columnOffset:s,indexOffset:n,indexOffsetEnd:o},r=t,n=o}else{u=d.groups?.fileName,c=d.groups?.fileHash;const t=d.index;g=e.slice(r,t),n+=Buffer.byteLength(g,"utf8"),r=t,yield{edit:!1,code:g}}t=!!f,({lineOffset:i,columnOffset:s}=M(g,a,i,s))}if(t)throw new E("End mark found outside mark");o?r<e.length&&(yield{edit:!1,code:e.slice(r)}):yield{edit:!1,code:e}}function O(e){const t=e.trim().slice(-d.hudConfig.esbuildMarkLength);if(t.startsWith("/*"+d.hudConfig.esbuildMark))return t}function T(e){const t=O(e);if(t)return t.slice(2+d.hudConfig.esbuildMark.length,2+d.hudConfig.esbuildMark.length+36)}function F(e,t,r){f.instrument_logger.debug("Edit chunk",{fileName:e.fileName,size:e.code.length,edit:t}),r?.push({fileName:e.fileName,size:e.code.length,edit:t})}function N(e,t,r,n){const o=x(e.code,{filename:t,format:r},[],!1,!0,n,!0),i=o.code;return o.mapRelativeToChunk=o.map,o.map=function(e,t,r){"string"==typeof e&&(e=JSON.parse(e));const n=(0,y.decode)(e.mappings);return n.forEach(e=>{e.forEach(e=>{e.length>=4&&"number"==typeof e[2]&&("number"==typeof e[3]&&0===e[2]&&(e[3]+=r),e[2]+=t)})}),JSON.stringify({...e,mappings:(0,y.encode)(n),sourcesContent:void 0})}(o.map,e.lineOffset,e.columnOffset),{codeToAppend:i,metadata:{...o,filename:t,lineOffset:e.lineOffset,columnOffset:e.columnOffset}}}function R(e,t,r,n=!1,o=!1,i=!1,s=()=>!0){const a=e.slice(-1e3);if(!o&&null!==b.getSourceMap(t,a))return f.instrument_logger.error("Source map found for esbuild split",{filename:t}),f.customer_logger.logEntry(l.UserErrorLogs.EsbuildSourceMapFound()),(0,p.detachHud)(!1,!1),{transformedCode:e,metadatas:[],editedChunksSizes:void 0};let c="",g=0,h=0;const m=[];let y=0;const _=n?[]:void 0,v=S(d.hudConfig.wrapVarPrefix,r,!1,!1,i).initialStatements.join("\n"),k=T(e);for(const n of P(e)){y++;try{let e="",o=!1;if(n.edit&&(o=s(n.fileName),_&&F(n,o,_)),n.edit&&o){const o=N(n,t,r,i);e=o.codeToAppend,m.push({...o.metadata,prebundle_file_checksum:n.fileChecksum,file_path_checksum:(0,u.default)(n.fileName).readUInt32BE(),bundlerBuildId:k??o.metadata.bundlerBuildId,transformedLineOffset:g,transformedColumnOffset:h,indexOffset:n.indexOffset,indexOffsetEnd:n.indexOffsetEnd})}else e=0===c.length?j(n.code,v):n.code;({transformedCodeLineOffset:g,transformedCodeColumnOffset:h}=L(e,g,h)),c+=e}catch(r){return f.instrument_logger.error("Failed to patch index",{index:y,filename:t,msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),{transformedCode:e,metadatas:[],editedChunksSizes:_}}}return{transformedCode:c,metadatas:m,editedChunksSizes:_}}function j(e,t){let r="";return e.startsWith('"use strict";')?(r+='"use strict";',r+=t,r+=e.slice(13),r):(r+=t,r+=e,r)}function L(e,t,r){const n=e.split("\n");return n.length>1?(t+=n.length-1,r=n.pop()?.length||0):r+=e.length,{transformedCodeLineOffset:t,transformedCodeColumnOffset:r}}function D(e,t){return e+`\n//"${t}";${d.hudConfig.cliSdkVersionVarName}="${d.SDK_VERSION}";${d.hudConfig.cliBuildIdVarName}`}function A(e,t,r,n,o){if(O(e))return f.instrument_logger.info("Editing in splits"),R(e,t,r,!1,void 0,o);{const i=x(e,{filename:t,format:r},n,d.hudConfig.userConfig.disableSourceMapsResolution?.value??!0,!1,o,!1);return{transformedCode:i.code,metadatas:[i]}}}let q=0;function H(e,t){q+=e;const r=d.hudConfig.userConfig?.maxMappedFunctions?.value??0;q>=r&&(t||f.customer_logger.logEntry(l.UserErrorLogs.InstrumentedFunctionCountExceeded(r)),f.app_logger.error("Instrumented function count exceeded",{instrumentedFunctionsCount:q,maxMappedFunctions:r}),(0,p.detachHud)(!1,!1))}},3903:e=>{"use strict";e.exports=require("uuid")},4290:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(8949),i=r(5128),s=r(714);class a extends s.FrameworkPatcher{_patch(e){return this._patchCreate(e),n.instrument_logger.info("Patched NestJS RpcContextCreator successfully"),e}_patchCreate(e){const t=e.RpcContextCreator.prototype.create;e.RpcContextCreator.prototype.create=function(...e){try{const t=e[0],r=e[1];"function"==typeof t.constructor&&"function"==typeof r?e[1]=(0,i.wrapLinkedFunction)(r):n.instrument_logger.error("Invalid args in NestJS RpcContextCreator.create",{args:e})}catch(e){n.instrument_logger.error("Error in NestJS RpcContextCreator patcher",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,e)},(0,o.copyPropertiesToTarget)(t,e.RpcContextCreator.prototype.create)}}t.default=a},4349:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(8949),c=r(9938);class d extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching request"),e=this._patchRequest(e),this._patchMethods(e),this._createRequestDeclaration(),n.instrument_logger.info("Patched request successfully"),e}_patchRequest(e){return(0,c.wrapOutboundFunction)(e,i.hudConfig.requestFunctionId,l,f,s.OutboundType.HTTP,!0)}_patchMethods(e){for(const[t,r]of Object.entries(i.hudConfig.requestMethodFunctionIds)){const n=e[t];e[t]=(0,c.wrapOutboundFunction)(n,r,(e,r,n)=>l(e,r,n,t),f,s.OutboundType.HTTP,!0)}}_createRequestDeclaration(){(0,a.storeLoadedOutbound)("request")}}function l(e,t,r,o){const i=function(e,t,r){const o=function(e){return"function"==typeof e[1]?{callback:e[1],setCallback:(e,t)=>{e[1]=t}}:"function"==typeof e[2]?{callback:e[2],setCallback:(e,t)=>{e[2]=t}}:null!==e[1]&&"object"==typeof e[1]?{callback:e[1].callback,setCallback:(e,t)=>{e[1].callback=t}}:null!==e[0]&&"object"==typeof e[0]?{callback:e[0].callback,setCallback:(e,t)=>{e[0].callback=t}}:void 0}(e);if(void 0===o)return(0,n.limitedLogger)("Request callback not found - outbound won't closed"),!1;const i=o.callback,s=function(e,n,o){try{null!=e?e instanceof AggregateError&&e.errors.length>0?t(e.errors[0]):t(e):r({response:n,body:o})}catch{}i(e,n,o)};return(0,u.copyPropertiesToTarget)(i,s),o.setCallback(e,s),!0}(e,t,r),s=function(e,t,r){"function"==typeof t&&(r=t);let n={};return n=null!==t&&"object"==typeof t?{...t,uri:e}:"string"==typeof e?{uri:e}:{...e},n.callback=r||n.callback,n}(e[0],e[1],e[2]);return{url:s.url??s.uri,method:o??s.method?.toLowerCase()??"get",body:s.form,...i?{}:{hasCallback:!1}}}function f(e,t,r){(0,c.reduceRequestArgsIfNeeded)(e,r,e=>Number.parseInt(e?.response?.request?.getHeader("content-length")));const n=Number.parseInt(e.response.headers["content-length"]),o=isNaN(n)||0===n?void 0:n;return{status_code:e.response.statusCode,bodySize:o,body:(0,c.getReducedBody)(e.body,o,i.hudConfig.dynamicConfig.maxHTTPResponseBodySize)}}t.default=d},4393:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpEndpointMetric=t.ApiProtocol=void 0;const n=r(9873);var o;!function(e){e.REST="rest",e.GraphQL="graphql"}(o||(t.ApiProtocol=o={}));class i extends n.FlowMetric{statusCode;apiProtocol;apiProtocolAttributes;error;constructor(e){super(e)}_createUsableMetric(e){return this}setRequestAttributes(e){this.apiProtocol=o.REST,this.apiProtocolAttributes={method:e.method}}setGraphQLAttributes(e,t){this.apiProtocol=o.GraphQL,this.apiProtocolAttributes={errorOccurred:e,errors:t}}setResponseAttributes(e){this.statusCode=e.statusCode}setUserError(e){this.error=e}toRaw(){if(!this.statusCode)return;if(this.apiProtocol===o.GraphQL){const e=this.apiProtocolAttributes;return{flow_id:this.flowId,type:"GraphQLMetric",duration:this.duration,status_code:this.statusCode,error_occurred:e.errorOccurred,error_breakdown:this.errorBreakdown}}if(this.apiProtocol!==o.REST)return;const e=this.apiProtocolAttributes;return e.method?{flow_id:this.flowId,type:"EndpointMetric",duration:this.duration,status_code:this.statusCode,method:e.method,error_breakdown:this.errorBreakdown,error:this.error}:void 0}}t.HttpEndpointMetric=i},4815:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.patchUse=function(e,t,r=!0){const n=e.use;e.use=function(e){const o=n.apply(this,arguments);try{let n=this[f.uuidSymbol];!n&&f.isVerboseLoggingEnabled&&(n=d.randomUUID(),this[f.uuidSymbol]=n,c.instrument_logger.info("Express use setting uuid",{kind:t,uuid:n})),"application"===t?function(e,t,r,n){try{r&&(e._router?p(e._router):e.router?p(e.router):c.instrument_logger.warning("Express application doesn't have router or _router")),n&&f.isVerboseLoggingEnabled&&c.instrument_logger.info("Express use app",{parent:n,child:t[1]?.[f.uuidSymbol]||"no uuid",path:t[0]})}catch(e){c.instrument_logger.error("Failed to save express app router",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(this,arguments,r,n):"router"===t&&function(e,t,r,n,o){try{if(!e.stack)return void c.instrument_logger.error("Express router without stack");if(0===e.stack.length)return void c.instrument_logger.warning("Express router with an empty stack");"query"===e.stack[0].name?p(e):f.isVerboseLoggingEnabled&&!f.skipLayerNamesLogs.has(e.stack[0].name)&&(f.skipLayerNamesLogs.add(e.stack[0].name),c.instrument_logger.warning("Found unknown stack name",{stack:e.stack[0].name}));const{path:i,offset:s}=function(e){let t=0,r="/";if("function"!=typeof e){let n=e;for(;Array.isArray(n)&&0!==n.length;)n=n[0];"function"!=typeof n&&(t=1,r=e)}return{path:r,offset:t}}(o),u=g(Array.prototype.slice.call(t,s));for(let t=0;t<u.length&&t<e.stack.length;t++){const o=e.stack[e.stack.length-t-1],s=u[u.length-t-1];"router"===o.name?(s&&!s[f.uuidSymbol]&&f.isVerboseLoggingEnabled&&(s[f.uuidSymbol]=d.randomUUID(),c.instrument_logger.info("Express handle router setting uuid",{uuid:s[f.uuidSymbol]})),r&&(o[a.hudConfig.express.routeNamesSymbol]=i)):f.isVerboseLoggingEnabled&&!f.skipLayerNamesLogs.has(o.name)&&(f.skipLayerNamesLogs.add(o.name),c.instrument_logger.warning("Found unknown layer name",{layer:o.name,parent:n,child:s[f.uuidSymbol]||"no uuid",path:i}))}}catch(e){c.instrument_logger.error("Failed to patch router.use function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(this,arguments,r,n,e)}catch(e){c.instrument_logger.error("Failed to patch express.use function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return o},(0,l.copyPropertiesToTarget)(n,e.use)},t.extractEndpointsFromRouter=function e(t,r){let n=[];if(!r.stack)return c.instrument_logger.error("Router without stack - bad OTEL version",{router:r}),n;for(const o of r.stack)if("router"===o.name){if(!o[a.hudConfig.express.routeNamesSymbol]){c.instrument_logger.error("Router layer without routes",{layer:o});continue}const r=t+o[a.hudConfig.express.routeNamesSymbol];n=n.concat(e(r,o.handle))}else o.route&&o.route[a.hudConfig.express.layerStateSymbol]?n=n.concat(h(o,t)):f.isVerboseLoggingEnabled&&!f.skipLayerNamesLogs.has(o.name)&&(f.skipLayerNamesLogs.add(o.name),c.instrument_logger.warning("Found unknown layer name when extracting endpoints",{layer:o.name}));return n};const a=r(5809),u=r(8528),c=r(523),d=s(r(6982)),l=r(8949),f=r(7225),g=r(5673);function p(e){e[a.hudConfig.express.markedSymbol]||(globalThis.hudExpressState.push(e),e[a.hudConfig.express.markedSymbol]=!0)}function h(e,t){const r=[];for(const[n,o]of Object.entries(e.route[a.hudConfig.express.layerStateSymbol]))r.push(new u.EndpointDeclaration(n,o.methods,"express",t,o.layerPath));return Array.from(r.values())}},4986:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(6698),s=r(8949),a=r(714);class u extends a.FrameworkPatcher{_patch(e){return e=this._patchPlimit(e),n.instrument_logger.info("Patched p-limit successfully"),e}_patchPlimit(e){if("function"!=typeof e)return n.instrument_logger.error("p-limit is not a function"),e;const t=e,r=function(...e){const r=t.apply(this,e);try{return function(e){const t=function(...t){try{if(void 0!==globalThis.hudStackIndex&&void 0!==globalThis.hudStackIndex.value&&void 0!==globalThis.hudStack&&t.length>0&&"function"==typeof t[0]){const e=(0,i.executionAsyncResource)()[o.kHudCaller]??globalThis.hudStack[globalThis.hudStackIndex.value];t[0]=function(e,t){const r=function(...r){try{const e=(0,i.executionAsyncResource)();e&&(e[o.kHudCaller]=t)}catch{(0,n.limitedLogger)("patchedArgs0 failed")}return e.apply(this,r)};return(0,s.copyPropertiesToTarget)(e,r),r}(t[0],e)}}catch{(0,n.limitedLogger)("patchedLimiter failed")}return e.apply(this,t)};return(0,s.copyPropertiesToTarget)(e,t),t}(r)}catch{return(0,n.limitedLogger)("patchedPLimit failed"),r}};return(0,s.copyPropertiesToTarget)(t,r),r}}t.default=u},5128:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHudLfMarked=void 0,t.wrapLinkedFunction=function(e){if(e[t.isHudLfMarked])return e;let r;e[t.isHudLfMarked]=!0;const a=(0,i.getFlowStateStorage)();return a?(r=e instanceof s.AsyncFunction?async function(...t){if(hudRunningMode!==n.HudRunningMode.enabled)return await e.apply(this,t);let r;try{r=a.getStore()}catch(r){return o.instrument_logger.error("Failed to get flowState",{msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),await e.apply(this,t)}return r?(r.shouldLinkFunction=!0,await e.apply(this,t)):await e.apply(this,t)}:function(...t){if(hudRunningMode!==n.HudRunningMode.enabled)return e.apply(this,t);let r;try{r=a.getStore()}catch(r){return o.instrument_logger.error("Failed to get flowState",{msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),e.apply(this,t)}return r?(r.shouldLinkFunction=!0,e.apply(this,t)):e.apply(this,t)},(0,s.copyPropertiesToTarget)(e,r),r):e};const n=r(8528),o=r(523),i=r(7131),s=r(8949);t.isHudLfMarked=Symbol.for("isHudLfMarked")},5150:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5809),o=r(8269),i=r(2546),s=r(523),a=r(7131),u=r(2822),c=r(8949),d=r(2080),l=r(714);class f extends l.FrameworkPatcher{isSupported(e,t,r,o){const a=n.hudConfig.userConfig.enableDapulse?.value?o.mondayVersion:o.bbcVersion,u=(0,l.extractModuleVersion)(e);return!!(0,l.isSupportedVersion)(u,a)||(s.instrument_logger.warning("Unsupported sqs-consumer version",{framework:"SqsConsumer",version:u,supportedVersion:a,basedir:e,isDapulse:n.hudConfig.userConfig.enableDapulse?.value}),s.customer_logger.logEntry(i.UserErrorLogs.UnsupportedFrameworkVersion("sqs-consumer")),!1)}_patch(e){return function(e){const t=e.Consumer.create;e.Consumer.create=function(...e){const r=t.apply(this,e);try{!function(e){const t=e.queueUrl;if(!t)throw new i.HudNoQueueUrlInSqsConsumer;const r=h(t);if(e.handleMessageBatch&&"function"==typeof e.handleMessageBatch){const t="handleMessageBatch",n=(0,i.generateSqsFlowId)(r,t);(0,o.storeSqsQueueDeclaration)({flow_id:n,queue_name:r,handle_type:t,batch_size:e.batchSize});const s=e.handleMessageBatch,a=(0,c.wrapFlow)(()=>n,s,!0,m);return void(e.handleMessageBatch=a)}if(e.handleMessage&&"function"==typeof e.handleMessage){const t="handleMessage",n=(0,i.generateSqsFlowId)(r,t);(0,o.storeSqsQueueDeclaration)({flow_id:n,queue_name:r,handle_type:t});const s=e.handleMessage,a=(0,c.wrapFlow)(()=>n,s,!0,m);return void(e.handleMessage=a)}s.instrument_logger.warning("Unable to getFlowId - No handleMessage or handleMessageBatch found in SqsConsumer.Consumer",{queueName:r})}(r),function(e){const t=e.on;e.on=function(...r){try{const t=r[0];if(!t||"string"!=typeof t)throw new i.HudNoEventTypeInSqsConsumerOn;const n=r[1];if(!n||"function"!=typeof n)throw new i.HudNoCallbackInSqsConsumerOn;const s=h(e.queueUrl),a="event",u=(0,i.generateSqsFlowId)(s,a,t);(0,o.storeSqsQueueDeclaration)({flow_id:u,queue_name:s,handle_type:a,event_type:t}),r[1]=(0,c.wrapFlow)(()=>u,n,!0,y,b,_)}catch(e){s.instrument_logger.error("Error in SqsConsumer.Consumer.on patched logic",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,r)},(0,c.copyPropertiesToTarget)(t,e.on)}(r),function(e){const t=e.emit;e.emit=function(...e){return function(e){try{const t=e[0];if(!t||"string"!=typeof t)throw new i.HudNoEventTypeInSqsConsumerEmit;let r,o;if("message_processed"===t&&(r=1),["error","timeout_error","processing_error"].includes(t)&&(o=1,r=2),void 0===r)return;const c=e[r];if(!c)throw new i.HudNoMessageInSqsConsumerEmit;let d;if(void 0!==o){const t=e[o];if(!(t&&t instanceof Error))throw new i.HudNoErrorInSqsConsumerEmit;d=(0,a.extractName)(t),"StandardError"===d&&t.cause&&t.cause instanceof Error&&(d=(0,a.extractName)(t.cause))}const l=(e,t)=>{const r=e[n.hudConfig.metricSymbol];if(r){if(d&&r.addError(d,t),r.increaseAndShouldEnd(t)){r.calculateDuration();try{(0,u.finishSqsInvestigation)(Array.isArray(c)?c:[c],r)}catch(e){(0,s.limitedLogger)("Failed to finish sqs investigation",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}r.end()}}else p||(p=!0,s.instrument_logger.warning("No metric found for message"))};Array.isArray(c)&&c.length>=1?l(c[0],c.length):l(c,1)}catch(e){g||(g=!0,s.instrument_logger.error("Error in SqsConsumer.Consumer.emit patched logic",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0}))}}(e),t.apply(this,e)},(0,c.copyPropertiesToTarget)(t,e.emit)}(r)}catch(e){s.instrument_logger.error("Error in patching SqsConsumer.Consumer",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r},(0,c.copyPropertiesToTarget)(t,e.Consumer.create)}(e),s.instrument_logger.info("Patched sqs-consumer successfully",{isDapulse:n.hudConfig.userConfig.enableDapulse?.value}),e}}t.default=f;let g=!1,p=!1;function h(e){const t=e.split("/").pop();if(!t)throw new i.HudFailExtractSqsQueueName(`Url: ${e}`);return t}function m(e,t,r){const o=d.SqsMetric.createUsableMetric(e);o.start();const i=r[0];if(!i)return s.instrument_logger.warning("No messages pass to sqs handler",{flowId:e}),void(t.flowMetric=o);if(Array.isArray(i)){if(o.msgCount=i.length,i.forEach(e=>{e[n.hudConfig.metricSymbol]=o}),i[0]?.Attributes?.SentTimestamp){const t=i.reduce((e,t)=>{const r=Number.parseInt(t?.Attributes?.SentTimestamp);return isNaN(r)?e:Math.min(e,r)},1/0);t!==1/0?o.e2eEpocStartTimeMS=t:s.instrument_logger.warning("No valid SentTimestamp found eventhough the first element had SentTimestamp",{flowId:e})}}else o.msgCount=1,i[n.hudConfig.metricSymbol]=o,i?.Attributes?.SentTimestamp&&(o.e2eEpocStartTimeMS=i.Attributes.SentTimestamp);t.flowMetric=o,(0,u.createNewInvestigation)()}function y(e,t,r){const n=d.SqsMetric.createUsableMetric(e);n.start(),t.flowMetric=n}function b(e,t){const r=t.flowMetric;r?r.end():s.instrument_logger.warning("No flowMetric found for message during catch",{flowId:e})}function _(e,t,r){const n=t.flowMetric;n?(n.addError((0,a.extractName)(r)),n.end()):s.instrument_logger.warning("No flowMetric found for message during catch",{flowId:e})}},5354:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(9938);class c extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching axios"),this._patchRequest(e),this._createAxiosDeclaration(),n.instrument_logger.info("Patched axios successfully"),e}_patchRequest(e){const t=e.Axios.prototype.request;e.Axios.prototype.request=(0,u.wrapOutboundFunction)(t,i.hudConfig.axiosFunctionId,e=>{const t=e[0];return{url:"string"==typeof t.url?t.url:void 0,method:t.method,body:t.data}},(e,t,r)=>{(0,u.reduceRequestArgsIfNeeded)(e,r,e=>Number.parseInt(e?.request?._contentLength));const n=Number.parseInt("function"==typeof e?.headers?.get?e?.headers?.get("content-length"):e?.headers["content-length"]),o=isNaN(n)||0===n?void 0:n;return{status_code:e.status,body:(0,u.getReducedBody)(e.data,o,i.hudConfig.dynamicConfig.maxHTTPResponseBodySize),bodySize:o}},s.OutboundType.HTTP)}_createAxiosDeclaration(){(0,a.storeLoadedOutbound)("axios")}}t.default=c},5459:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(2822),s=r(8949),a=r(4393),u=r(714);class c extends u.FrameworkPatcher{_patch(e){return this._patchEmit(e),n.instrument_logger.info("Patched http successfully"),e}_patchEmit(e){const t=e.Server.prototype.emit;e.Server.prototype.emit=function(e,...r){if("request"!==e)return t.apply(this,[e,...r]);const u=(0,o.getFlowStateStorage)(),c=r?.[0],d=r?.[1],l=a.HttpEndpointMetric.createUsableMetric(),f={httpMetric:l},g=()=>{try{l.start(),(0,i.createNewInvestigation)(),l.setRequestAttributes(c),d.once("finish",function(){try{l.calculateDuration(),(0,i.finishHttpInvestigation)(c,d,l),l.setResponseAttributes(d),l.end()}catch(e){(0,n.limitedLogger)("Failed to set response attributes",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),d.once("close",()=>{(0,i.clearInvestigationDataFromStorage)(),(0,s.clearFlowStateData)(f)})}catch(e){n.instrument_logger.error("Failed to patch http.Server.prototype.emit",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,[e,...r])};return u?u.run(f,g):g()},(0,s.copyPropertiesToTarget)(t,e.Server.prototype.emit)}}t.default=c},5673:e=>{"use strict";e.exports=require("array-flatten")},5688:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hudRITM=void 0,t.safeLog=function(e){try{s.app_logger.debug(e)}catch{return}},t.registerHook=function(){if((0,o.initGlobals)(),s.app_logger.debug("InitGlobals done"),(0,a.registerStackHooks)(),s.app_logger.debug("registerStackHooks done"),(0,c.patchAllSetIntervalFunctions)(),s.app_logger.debug("patchAllSetIntervalFunctions done"),s.app_logger.info("HUD is required"),process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE){if(s.app_logger.info("Running in Lambda environment"),parseInt(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE)<n.hudConfig.lambdaMinimunMemory){const e=process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE;return s.app_logger.warning("Lambda function memory size is less than required, Hud will not run",{memorySize:e,requiredMemory:n.hudConfig.lambdaMinimunMemory}),s.customer_logger.logEntry(i.UserErrorLogs.UnsupportedLambdaMemory(n.hudConfig.lambdaMinimunMemory)),!1}globalThis.hudRuningInsideLambda=!0}return!(globalThis.hudStartFromAutoInit&&!(0,o.validateAndGetUserInput)())&&(globalThis.hudRanOnRequire?(s.instrument_logger.warning("Already ran onRequire!"),!1):(globalThis.hudRanOnRequire=!0,s.instrument_logger.info("Using module",{name:n.SDK_MODULE_NAME}),n.hudConfig.userConfig.enableFrameworks&&s.instrument_logger.info("User enabled frameworks",{frameworks:(0,u.getEnabledFrameworks)()}),(0,u.onRequire)(),(0,i.detectNextJsApp)(),s.instrument_logger.debug("onRequire done"),globalThis.hudInitGuard=setTimeout(d,n.hudConfig.userConfig.maxTimeUntilInitSessionMs?.value??0),globalThis.hudInitGuard.unref(),!0))};const n=r(5809),o=r(8269),i=r(2546),s=r(523),a=r(3073),u=r(7166),c=r(392);function d(){s.instrument_logger.critical("Init timeout reached - disabling hud"),s.customer_logger.logEntry(i.UserErrorLogs.InitTimeout(globalThis.hudIsRunningFromSetup)),(0,o.detachHud)(!1)}t.hudRITM=u.onRequireFn},5809:e=>{"use strict";e.exports=require("./config")},5946:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(6730),i=r(4815),s=r(714);class a extends s.FrameworkPatcher{_patch(e){return(0,i.patchUse)(e.prototype,"router"),(0,o.patchMethods)(e.prototype,"router"),n.instrument_logger.info("Patched router successfully"),e}}t.default=a},6093:e=>{"use strict";e.exports=require("@cspotcode/source-map-support")},6698:e=>{"use strict";e.exports=require("node:async_hooks")},6730:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.getMethods=f,t.patchMethods=function(e,t){f().concat("all").forEach(function(r){const n=e[r];if(!n)return void(l.isVerboseLoggingEnabled&&u.instrument_logger.warning("Method not found",{method:r}));const o="all"===r;e[r]=function(){try{if(arguments.length<2)return n.apply(this,arguments);let e=this[l.uuidSymbol];l.isVerboseLoggingEnabled&&(e||(e=c.randomUUID(),this[l.uuidSymbol]=e,u.instrument_logger.info("Express method setting uuid",{uuid:e,kind:t})),u.instrument_logger.info("Express added new method",{method:r,uuid:e,path:arguments[0]}));const i=Array.prototype.slice.call(arguments);if(i[1][a.hudConfig.express.layerStateSymbol]={flowId:[],kind:t,allMethod:o},Array.isArray(i[0]))for(const e of i[0]){const e=c.randomUUID();i[1][a.hudConfig.express.layerStateSymbol].flowId.push(e)}else i[1][a.hudConfig.express.layerStateSymbol].flowId.push(c.randomUUID());const s=n.apply(this,i);try{delete i[1][a.hudConfig.express.layerStateSymbol]}catch{}return s}catch(e){u.instrument_logger.error("Failed to patch method",{kind:t,method:r,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n.apply(this,arguments)},(0,d.copyPropertiesToTarget)(n,e[r])})};const a=r(5809),u=r(523),c=s(r(6982)),d=r(8949),l=r(7225);function f(){const e=r(8611);return e.METHODS&&e.METHODS.map(function(e){return e.toLowerCase()})||["get","post","put","head","delete","options","trace","copy","lock","mkcol","move","purge","propfind","proppatch","unlock","report","mkactivity","checkout","merge","m-search","notify","subscribe","unsubscribe","patch","search","connect"]}},6928:e=>{"use strict";e.exports=require("path")},6982:e=>{"use strict";e.exports=require("crypto")},7127:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(6730),i=r(2977),s=r(4815),a=r(7225),u=r(714);class c extends u.FrameworkPatcher{_patch(e){return(0,i.patchRoute)(e.Route),(0,s.patchUse)(e.application,"application"),(0,o.patchMethods)(e.application,"application"),a.isVerboseLoggingEnabled&&(0,a.logLazyRouter)(e.application),e.Router.use?((0,s.patchUse)(e.Router,"router"),(0,o.patchMethods)(e.Router,"router")):n.instrument_logger.warning("Skipping express.Router patching"),n.instrument_logger.info("Patched express successfully"),e}}t.default=c},7131:e=>{"use strict";e.exports=require("./wrap")},7166:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.parseCliInstrumentationPattern=C,t.supportSourceMapInstall=S,t.patch=I,t.patchCompile=T,t.onRequireFn=F,t.patchRequire=N,t.isFrameworkEnabled=R,t.getEnabledFrameworks=function(){const e=new Map;for(const[t,r]of g.hudConfig.frameworksToPatch)e.set(r.framework,R(r,g.hudConfig.userConfig.enableFrameworks));return Object.fromEntries(e)},t.getFunctionsToInstrument=q,t.createCheckers=H,t.updateModuleChecker=$,t.skip=U,t.onRequire=function(){try{(0,d.setInstrumentedFilesCountInterval)(),$();try{T()}catch(e){l.instrument_logger.error("Failed to patch compile",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{(0,d.shouldSupportSourceMap)()&&S()}catch(e){l.instrument_logger.error("Failed to install source map support",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{N()}catch(e){l.instrument_logger.error("Failed to patch require",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}catch(e){l.instrument_logger.error("Something went wrong in onRequire",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{(0,h.saveMachineMetric)()}catch(e){l.instrument_logger.error("Failed to add metric",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}};const a=r(2546),u=s(r(6928)),c=r(8528),d=r(2546),l=r(523),f=r(3901),g=r(5809),p=r(8528),h=r(8269),m=r(2546),y=r(9063),b=r(714),_=r(8949),v=function(){const e=g.SDK_MODULE_NAME;try{return u.dirname(u.dirname(m.myRequire.resolve(e)))}catch(t){return l.instrument_logger.error("Failed to resolve own path",{moduleName:e,msg:t instanceof Error?t.message:void 0,stack:t instanceof Error?t.stack:void 0}),null}}();function k(e){const t=globalThis.HudSourceMapCache.get(e);return t?{map:JSON.parse(t)}:null}const w=new RegExp(`//"([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})";${g.hudConfig.cliSdkVersionVarName}="([^"]+)";${g.hudConfig.cliBuildIdVarName}`);function C(e){if(e.slice(-g.hudConfig.cliBuildIdVarName.length)!==g.hudConfig.cliBuildIdVarName)return null;const t=Math.min(100,e.length),r=e.slice(-t).match(w);return r?{buildId:r[1],sdkVersion:r[2],fullPattern:r[0]}:null}function S(){r(6093).install({handleUncaughtExceptions:!1,hookRequire:!1,environment:"node",retrieveSourceMap:k})}let x=!1,E=!1;function I(e,t,r,n){const o={code:e,map:void 0};try{if(globalThis.hudRunningMode===p.HudRunningMode.detached)return o;if(r===c.Format.esm&&!n)throw new m.HudError("MessagePort is required for patching ESM modules");const i=C(e);if(i)return E||(E=!0,l.instrument_logger.info("CI instrumentation detected, skipping instrumentation",{filename:t,cliSdkVersion:i.sdkVersion,currentSdkVersion:g.SDK_VERSION})),i.sdkVersion!==g.SDK_VERSION?(l.instrument_logger.critical("SDK version mismatch detected, disabling SDK",{filename:t,cliSdkVersion:i.sdkVersion,currentSdkVersion:g.SDK_VERSION}),(0,h.detachHud)(!1,!1),o):((0,h.addReingestValue)(i.buildId),globalThis.hudInstrumentationIndicator&&(0,h.clearInstrumentationIndicator)(),o);if(g.hudConfig.userConfig.disableRuntimeInstrumentation?.value)return x||(x=!0,l.instrument_logger.info("Skipping instrumentation due to disableRuntimeInstrumentation")),o;const s=q(t);if(U(t,void 0,r,s))return o;if(e.length>(g.hudConfig.userConfig.maxFileSizeBytes?.value??0)&&!e.startsWith(g.hudConfig.esbuildMark))return l.instrument_logger.info("Skipping large file",{filename:t,size:e.length}),o;const a=(0,f.edit)(e,t,r,s,!1),u=a.metadatas;if(o.code=a.transformedCode,o.map=u,n)for(const e of u)n.postMessage({key:"HudModulePatch",hudPatched:t,hudProcessedFiles:(0,d.sourceFileMetadataToTransferSourceFileMetadata)(e)});else globalThis.hudPatched.add(t),globalThis.hudProcessedFiles.push(...u.map(e=>(0,d.sourceFileMetadataToTransferSourceFileMetadata)(e)));for(const e of u)e.functionIds.length>0&&(globalThis.hudInstrumentationOccured=!0,globalThis.hudInstrumentationIndicator&&(0,h.clearInstrumentationIndicator)());g.hudConfig.writePatched&&(j(t,a.transformedCode),a.metadatas&&j(t+".map",JSON.stringify(JSON.parse(a.metadatas[0].map),null,2)))}catch(e){l.instrument_logger.error("Failed to patch",{filename:t,format:r,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return o}let M="",P=!0,O=!1;function T(){if(!(0,m.isSupportedNative)())return;const e=r(3339),t=(0,d.shouldSupportSourceMap)();O&&l.instrument_logger.warning("PatchCompile ran twice"),0===Object.keys(globalThis.hudLoadedModules).length&&(globalThis.hudLoadedModules=Object.keys(m.myRequire.cache));const n=e.prototype._compile;e.prototype._compile=function(e,r,...o){const i=process.hrtime.bigint();let s=0,a=0,u=0,f=!1;try{if(r===M){try{const e=P?l.instrument_logger.warning.bind(l.instrument_logger):l.instrument_logger.debug.bind(l.instrument_logger);P=!1,e("Skipping compile since already ran",{filename:r})}catch{}const t=process.hrtime.bigint(),i=n.call(this,e,r,...o);return s=Number(process.hrtime.bigint()-t),i}M=r,l.instrument_logger.debug("Compiling requirement",{filename:r});const i=I(e,r,o[0]?o[0]:c.Format.cjs);i.map&&(f=!0),a=i.map?.reduce((e,t)=>e+t.functionIds.length,0)??0,u=i.map?.reduce((e,t)=>e+t.totalFunctionsCountIncludeUninstrumented,0)??0;try{if(t&&i.map){const e=(0,d.combineSourceMaps)(i.map,r);e&&globalThis.HudSourceMapCache.set(r,e)}}catch(e){l.instrument_logger.error("Failed to combine source maps",{filename:r,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const g=process.hrtime.bigint(),p=n.call(this,i.code,r,...o);return s=Number(process.hrtime.bigint()-g),M="",p}finally{const t=Number(process.hrtime.bigint()-i)-s;f&&l.instrument_logger.debug("Patched",{filename:r,time:t}),(0,d.incrementInstrumentedStats)(f,t,s,e.length,a,u)}},(0,_.copyPropertiesToTarget)(n,e.prototype._compile),O=!0,l.instrument_logger.debug("Patched _compile")}function F(e,t,r){try{const n=g.hudConfig.frameworksToPatch.get(t);return R(n,g.hudConfig.userConfig.enableFrameworks)&&n?.patcher&&n.version?(0,b.getFrameworkPatcher)(n.patcher).patch(e,r,n.version,n.extraInfo,t):e}catch(e){l.instrument_logger.error("Failed to patch framework",{name:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}function N(){const e=Array.from(g.hudConfig.frameworksToPatch.entries()).filter(([e,t])=>R(t,g.hudConfig.userConfig.enableFrameworks)).map(([e])=>e);new y.Hook(Array.from(e),{internals:!0},F)}function R(e,t){return!!e&&(t&&t.value?.has(e.framework)?t.value.get(e.framework)||!1:e.enable)}function j(e,t){const r=u.parse(e);let n=`${r.dir}/patched.${r.base}`;r.dir.includes("dist")&&(n=u.join(`${r.dir.replace("dist","patched")}`,r.base)),a.suppressTracesFS.existsSync(u.dirname(n))||a.suppressTracesFS.mkdirSync(u.dirname(n),{recursive:!0}),a.suppressTracesFS.writeFileSync(n,t,"utf8"),l.instrument_logger.debug("Dumped patched file",{filename:e,patchedPath:n})}function L(e){const t=u.sep.replace(/\\/g,"\\\\"),r=u.join(e).split(".").join("\\.").split("*").join(".*?"),n=t+"node_modules"+t;return{isAllowdModule:new RegExp(n+r+`(?:${t}|$)`),isAllowdModuleSubModule:new RegExp(n+r+n)}}function D(e,t){return!!t.isAllowdModule.test(e)&&!t.isAllowdModuleSubModule.test(e)}function A(e,t){const r=t.replace(/\//g,u.sep);return e.includes(`node_modules${u.sep}${r}${u.sep}`)&&!e.includes(`node_modules${u.sep}${r}${u.sep}node_modules`)}function q(e){return(0,m.getInstrumentedThirdPartyModuleInfo)(e)?.functions||[]}function H(e){const t=[];for(const r of e){let e;if(r.includes("*")){const t=L(r);e=e=>D(e,t)}else e=e=>A(e,r);t.push(e)}return t}let B=[];function $(){B=H(g.hudConfig.userConfig.includeModules?.value??[])}function U(e,t,r,n=[]){if(!g.hudConfig.allowedEditExtensions.includes(u.extname(e))&&!e.endsWith(u.sep))return l.instrument_logger.warning("Skipping non-allowed extension",{filename:e}),!0;if(r&&(r===c.Format.ts||r===c.Format.moduleTypescript||r===c.Format.commonjsTypescript))return l.instrument_logger.warning("Skipping typescript module",{filename:e}),!0;const o=g.hudConfig.userConfig.excludeDirs?.value;if(o&&o.length>0)for(const t of o)if(e.includes(`${t}`))return l.instrument_logger.debug("Skipping file in excluded directory",{filename:e,excludeDir:t}),!0;const i=t??B;return"/var/runtime/index.mjs"===e?(l.instrument_logger.debug("Skipping lambda runtime",{filename:e}),!0):e.includes("node_modules")&&!function(e,t){for(const r of t)if(r(e))return!0;return!1}(e,i)&&0===n.length||e.includes(".yarn")?(l.instrument_logger.debug("Skipping non-monitored imported module",{filename:e}),!0):!(v&&!e.includes(v)||(l.instrument_logger.debug("Skipping hud internal module",{filename:e}),0))}},7214:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5809),o=r(8269),i=r(2546),s=r(523),a=r(7131),u=r(8949),c=r(714);class d extends c.FrameworkPatcher{static graphQLPatchedSymbol=Symbol.for(n.hudConfig.hudPatchedName);_patch(e){return this.patchExecute(e),s.instrument_logger.info("Patched GraphQL successfully"),e}patchExecute(e){const t=e.execute,r=(0,u.wrapFlow)(function(e,t){let r;if(e.operation)return e.operation.flow_id;try{if(t.length<1)return;const n=t[0];if(n.document.definitions.length>1){if(n.operationName)for(const t of n.document.definitions)if(r=l(e,t,n.operationName),r)break}else r=l(e,n.document.definitions[0])}catch(e){s.instrument_logger.error("Failed to store graphql operations",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r?.flow_id},t,!1,void 0,function(e,t,r){return function(e,t){return"function"==typeof e.then?e.then(e=>(f(e,t),e)):(f(e,t),e)}(r,t.operation)});e.execute=r}}function l(e,t,r){const n=function(e){return e&&e.name?e.name.value:"anonymous"}(t),s=function(e){return e&&e.operation?e.operation:"query"}(t);if(!r||r===n){const t={flow_id:(0,i.generateGraphqlFlowId)(n,s),operation_name:n,operation_type:s};return(0,o.storeGraphQLOperation)(t),e.operation=t,t}}function f(e,t){try{if(!t)return;const r=(0,a.getFlowState)();if(!r)return void s.instrument_logger.warning("No flow state found for graphql operation",{operation_name:t.operation_name,operation_type:t.operation_type});const n=r.httpMetric;if(!n)return void s.instrument_logger.warning("No http metric found for graphql operation",{operation_name:t.operation_name,operation_type:t.operation_type});n.setFlowId(t.flow_id),n.setGraphQLAttributes(!!e.errors&&e.errors.length>0,e.errors)}catch(e){s.instrument_logger.error("Failed to set flowId and graphql attributes in http metric",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}t.default=d},7225:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.skipStackNamesLogs=t.skipLayerNamesLogs=t.isVerboseLoggingEnabled=t.uuidSymbol=void 0,t.logLazyRouter=function(e){const r=e.lazyrouter;e.lazyrouter=function(){let e=!1;try{this._router||(e=!0)}catch(e){a.instrument_logger.error("Failed to check this._router",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const n=r.apply(this,arguments);try{if(e){let e=this[t.uuidSymbol];e||(e=u.randomUUID(),this[t.uuidSymbol]=e,a.instrument_logger.info("Express lazy router setting uuid",{uuid:e})),a.instrument_logger.info("Express lazy router",{parent:e,child:this._router?.[t.uuidSymbol]})}}catch(e){a.instrument_logger.error("Failed to patch express.lazyRouter function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n},(0,d.copyPropertiesToTarget)(r,e.lazyrouter)};const a=r(523),u=s(r(6982)),c=r(932),d=r(8949);t.uuidSymbol=Symbol.for("__hud_uuid__"),t.isVerboseLoggingEnabled="true"===c.env.HUD_LOG_EXPRESS,t.skipLayerNamesLogs=new Set(["query","expressInit","mounted_app"]),t.skipStackNamesLogs=new Set(["router"])},7276:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8544);class o extends n.BaseKafkaJSPatcher{getExportsRoot(e){return e.KafkaJS}getGroupId(e){return e[0].kafkaJS.groupId}moduleName(){return"@confluentinc/kafka-javascript.KafkaJS"}}t.default=o},7427:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(9938);class c extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching pg"),this._patchConnect(e),this._patchQuery(e),this._patchEnd(e),this._createPgDeclaration(),n.instrument_logger.info("Patched pg successfully"),e}_patchConnect(e){const t=e.Client.prototype.connect;e.Client.prototype.connect=(0,u.wrapOutboundFunction)(t,i.hudConfig.pgConnectFunctionId,void 0,void 0,s.OutboundType.DB)}_patchEnd(e){const t=e.Client.prototype.end;e.Client.prototype.end=(0,u.wrapOutboundFunction)(t,i.hudConfig.pgEndFunctionId,void 0,void 0,s.OutboundType.DB)}_patchQuery(e){const t=e.Client.prototype.query;e.Client.prototype.query=(0,u.wrapOutboundFunction)(t,i.hudConfig.pgQueryFunctionId,e=>({query:e[0],params:e[1]}),e=>({rowsCount:e.rowCount}),s.OutboundType.DB)}_createPgDeclaration(){(0,a.storeLoadedOutbound)("pg")}}t.default=c},7535:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(3903),c=r(9938);class d extends o.FrameworkPatcher{static commandsToSkip=["auth","client","select","info","readonly","monitor","subscribe","psubscribe","ssubscribe","cluster"];_patch(e){return n.instrument_logger.info("Patching ioredis"),this._patchConnect(e),this._patchSendCommand(e),n.instrument_logger.info("Patched ioredis successfully"),e}_patchConnect(e){const t=e.prototype.connect;if(!t)return void n.instrument_logger.warning("prototype.connect not found");const r=d.generateFunctionId("connect");e.prototype.connect=(0,c.wrapOutboundFunction)(t,r,void 0,void 0,s.OutboundType.REDIS),(0,a.storeIoredisCommand)("connect",r),n.instrument_logger.debug("Wrapped prototype.connect")}_patchSendCommand(e){const t=e.prototype.sendCommand;t?(e.prototype.sendCommand=(0,c.wrapOutboundFunction)(t,e=>{const t=e[0]?.name?.toLowerCase();if(t){if(!d.commandsToSkip.includes(t))return d._getFunctionId(t)}else(0,n.limitedLogger)("Redis command name not found, skipping instrumentation")},e=>d._parseCommandArgs(e),e=>d._parseCommandResult(e),s.OutboundType.REDIS),n.instrument_logger.debug("Wrapped prototype.sendCommand")):n.instrument_logger.warning("prototype.sendCommand not found")}static _getFunctionId(e){let t=(0,a.getIoredisFunctionId)(e);return t||(t=d.generateFunctionId(e)),(0,a.storeIoredisCommand)(e,t),t}static _parseCommandArgs(e){try{const t=e[0];if(!t||"object"!=typeof t)return;const r=t.name,n=t.args||[];return{command:r,key:n[0],args:n.slice(1),argsCount:n.length}}catch(e){return void n.instrument_logger.debug("Error parsing Redis command args",{error:e instanceof Error?e.message:void 0})}}static _parseCommandResult(e){try{let t,r;return t=null==e?"null":Buffer.isBuffer(e)?"buffer":Array.isArray(e)?"array":typeof e,("string"==typeof e||Buffer.isBuffer(e))&&(r=e.length),{valueType:t,valueSize:r}}catch(e){return void n.instrument_logger.debug("Error parsing Redis command result",{error:e instanceof Error?e.message:void 0})}}static generateFunctionId(e){return(0,i.functionUuidToBase64)((0,u.v5)(`ioredis-${e}`,i.hudConfig.functionUuidNamespace))}}t.default=d},7603:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getObservabilityIdentifiers=s,t.getObservabilityIdentifiersHttp=function(e){return{...s(),w3c_trace_context:a(e),w3c_baggage:c(e,"baggage"),amazon_trace_id:c(e,"x-amzn-trace-id"),b3_propagation:u(e),jaeger_trace_id:c(e,"uber-trace-id")}},t.getExtraHeaders=function(e){const t={};for(const r of n.hudConfig.dynamicConfig.extraHeaders){const n=c(e,r);void 0!==n&&(t[r]=n)}return t},t.getDatadogIds=l,t.getOtelTraceId=g;const n=r(5809),o=r(2546),i=r(523);function s(){const e=l();return{datadog_trace_id:e?.trace_id,datadog_span_id:e?.span_id,otel_trace_id:g()}}function a(e){try{return{traceparent:c(e,"traceparent"),tracestate:c(e,"tracestate")}}catch{return}}function u(e){try{return{full:c(e,"b3"),trace_id:c(e,"x-b3-traceid"),span_id:c(e,"x-b3-spanid"),parent_span_id:c(e,"x-b3-parentspanid")}}catch{return}}function c(e,t){try{return e.headers[t]}catch{return}}const d=(0,o.requireWithInternalCache)("dd-trace/packages/datadog-core",i.instrument_logger.debug.bind(i.instrument_logger));function l(){try{const e=d();if(null===e)return;const{storage:t}=e,r=t("legacy").getStore();return{trace_id:r.span._spanContext.toTraceId(),span_id:r.span._spanContext.toSpanId()}}catch{return}}const f=(0,o.requireWithInternalCache)("@opentelemetry/api",i.instrument_logger.debug.bind(i.instrument_logger));function g(){try{const e=f();if(null===e)return;const{trace:t}=e;return t.getActiveSpan()?.spanContext().traceId}catch{return}}},7808:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getMachineMetrics=function(){try{const e=(0,o.getLastMetrics)();return{cpu_usage:e.cpuUsage?l(e.cpuUsage,e.timestamp):void 0,memory_usage:d(),event_loop_utilization:e.elu?c(e.elu):void 0}}catch(e){return void s.app_logger.error("Error getting machine metrics",e)}},t.getCpuUsage=l;const o=r(8269),i=r(2546),s=r(523),a=n(r(857)),u=r(2987);function c(e){try{return u.performance.eventLoopUtilization(e).utilization}catch(e){return void s.app_logger.error("Error getting event loop utilization",e)}}function d(){try{const e=process.memoryUsage(),t=(0,i.getPodMemoryLimit)(s.app_logger).podMemoryLimitMB;let r;return r=null===t?a.default.totalmem():1024*t*1024,{rss:e.rss,heap_total:e.heapTotal,heap_used:e.heapUsed,external:e.external,system_memory:r,rss_percentage:e.rss/r*100}}catch(e){return void s.app_logger.error("Error getting memory usage",e)}}function l(e,t){try{const r=process.cpuUsage(),n=1e3*(Date.now()-t),o=(0,i.getCpuLimit)(s.app_logger),a=(r.user-e.user)/n,u=(r.system-e.system)/n;return{user_time:a,system_time:u,limit:o,user_percent_of_limit:"number"==typeof o?a/o*100:void 0,system_percent_of_limit:"number"==typeof o?u/o*100:void 0}}catch(e){return void s.app_logger.error("Error getting cpu usage",e)}}},7997:e=>{"use strict";e.exports=require("node:timers")},8064:e=>{"use strict";e.exports=require("semver")},8269:e=>{"use strict";e.exports=require("./globalstate")},8528:e=>{"use strict";e.exports=require("./dto")},8544:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseKafkaJSPatcher=void 0;const n=r(8269),o=r(2546),i=r(523),s=r(2822),a=r(8949),u=r(828),c=r(714);class d extends c.FrameworkPatcher{_patch(e){const t=this.getExportsRoot(e);return this._patchConsumer(t),i.instrument_logger.info(`Patched ${this.moduleName()} successfully`),e}_patchConsumer(e){const t=e.Kafka.prototype.consumer;if(!t)return void i.instrument_logger.error("DD presumably ran before HUD - exports.Kafka.prototype.consumer is undefined");const r=this.getGroupId.bind(this);e.Kafka.prototype.consumer=function(...e){const n=t.apply(this,e);try{const t=new Map,o=[],c=[];!function(e,t){const r=e.subscribe;e.subscribe=async function(...e){const n=await r.apply(this,e);try{const r=e[0].topics;r?r.forEach(e=>{t.push(e)}):e[0].topic?t.push(e[0].topic):i.instrument_logger.warning("No topic found in KafkaJS.Consumer.subscribe",{args:e[0]})}catch(e){i.instrument_logger.error("Error in patching KafkaJS.Consumer.subscribe",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n},(0,a.copyPropertiesToTarget)(r,e.subscribe)}(n,c),function(e,t,r,n,o){const c=e.run;function d(e,c){const d="eachBatch"===c;for(const e of o)p(e,n,t,r,c);const h=function(e,t,r){return(n,o)=>{const s=o[0],a=r?s.batch.topic:s.topic;return function(e,t,r,n){const o=e.get(g(r,n));if(o)return o;for(const e of t)if(e.isBatch===n&&e.pattern.test(r))return e.flowId;i.instrument_logger.warning("No flowId found for topic",{topicName:r,isBatch:n})}(e,t,a,r)}}(t,r,d),m=function(e){return(t,r,n)=>{const o=u.KafkaJSMetric.createUsableMetric();o.start(),o.setFlowId(t),(0,s.createNewInvestigation)();const i=n[0],a=e?i.batch.partition:i.partition,c=e?i.batch.messages[0]?.timestamp:i.message?.timestamp;o.addPartition(a),o.addProducedTimestamp(c),r.topic=e?i.batch.topic:i.topic,r.partition=e?i.batch.partition:i.partition,r.messages=e?i.batch.messages:[i.message],r.flowMetric=o}}(d),y=(0,a.wrapFlow)(h,e[c],!0,m,l,f);e[c]=y}e.run=async function(...e){try{const t=e[0];t.eachMessage&&d(t,"eachMessage"),t.eachBatch&&d(t,"eachBatch")}catch(e){i.instrument_logger.error("Error in patching KafkaJS.Consumer.run",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return await c.apply(this,e)},(0,a.copyPropertiesToTarget)(c,e.run)}(n,t,o,r(e),c)}catch(e){i.instrument_logger.error("Error in patching KafkaJS.Consumer",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n},(0,a.copyPropertiesToTarget)(t,e.Kafka.prototype.consumer)}}function l(e,t){const r=t.flowMetric;r?(r.calculateDuration(),(0,s.finishKafkaJSInvestigation)(t.messages,r,t.topic,t.partition),r.end()):i.instrument_logger.warning("No flowMetric found for message",{flowId:e})}function f(e,t,r){const n=t.flowMetric;n?(n.setError(r),n.calculateDuration(),(0,s.finishKafkaJSInvestigation)(t.messages,n,t.topic,t.partition),n.end()):i.instrument_logger.warning("No flowMetric found for message",{flowId:e})}function g(e,t){return e+"|"+t}function p(e,t,r,i,s){const a=(0,o.generateKafkaFlowId)(e,t,s),u={flow_id:a,topic_name:e.toString(),group_id:t,pulling_type:s};(0,n.storeKafkaJSTopicDeclaration)(u),function(e,t,r,n,o){"string"==typeof r?e.set(g(r,n),o):t.push({pattern:r,isBatch:n,flowId:o})}(r,i,e,"eachBatch"===s,a)}t.BaseKafkaJSPatcher=d},8564:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(9938),c=Symbol.for("_HUD_outboundIndex");class d extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching node-fetch"),e=this._patchFetch(e),this._patchBody(e),this._createNodeFetchDeclaration(),n.instrument_logger.info("Patched node-fetch successfully"),e}_patchFetch(e){return(0,u.wrapOutboundFunction)(e,i.hudConfig.nodeFetchFunctionId,e=>{const t=e[1]?.body,r=(0,u.getBodySize)(t);return{url:e[0],method:e[1]?.method?.toLowerCase()??"get",body:(0,u.getReducedBody)(t,r,i.hudConfig.dynamicConfig.maxHTTPRequestBodySize),bodySize:r}},(e,t)=>(e[c]=t,{status_code:e.status}),s.OutboundType.HTTP)}_patchBody(e){for(const[t,r]of Object.entries(i.hudConfig.nodeFetchBodiesFunctionIds)){const n=e.Response.prototype[t];e.Response.prototype[t]=(0,u.wrapOutboundBodyFunction)(n,r,(e,t)=>e[c],(e,t)=>{const r=Number.parseInt(e.headers.get("content-length")),n=isNaN(r)||0===r?void 0:r;return{body:(0,u.getReducedBody)(t,n,i.hudConfig.dynamicConfig.maxHTTPResponseBodySize),bodySize:n}})}}_createNodeFetchDeclaration(){(0,a.storeLoadedOutbound)("node-fetch")}}t.default=d},8611:e=>{"use strict";e.exports=require("http")},8840:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(523),i=r(8949),s=r(714),a=n(r(9589));class u extends s.FrameworkPatcher{static nextJSHudMarked=Symbol.for("hudNextJSMarked");_patch(e){const t=e.PagesAPIRouteModule||e.default;if(!t||t[u.nextJSHudMarked])return e;const r=this._wrapConstructor(t);t[u.nextJSHudMarked]=!0,o.instrument_logger.info("Patched Next.js route module constructor successfully");const n=Object.create(Object.getPrototypeOf(e));return Object.defineProperty(n,"PagesAPIRouteModule",{enumerable:!0,get:function(){return r}}),e.default===t&&Object.defineProperty(n,"default",{enumerable:!0,get:function(){return r}}),(0,i.copyPropertiesToTarget)(e,n),n}_wrapConstructor(e){const t=function(...t){const r=new e(...t);try{const e=r.definition?.pathname;e&&!r[u.nextJSHudMarked]&&(a.default._detectAndPatchSupportedMethods(r,e),r[u.nextJSHudMarked]=!0)}catch(e){o.instrument_logger.error("Failed to patch Next.js Pages API route module instance",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r};return(0,i.copyPropertiesToTarget)(e,t),t}}t.default=u},8949:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncFunction=void 0,t.wrapFlow=function(e,r,u=!0,c,d,l){let f;const g=(0,i.getFlowStateStorage)();if(!g)return r;try{if(r[s])return r}catch{return r}return f=r instanceof t.AsyncFunction?async function(...t){let s;const a={};try{s=e(a,t)}catch(e){o.instrument_logger.error("Failed to get flowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(!s||hudRunningMode!==n.HudRunningMode.enabled)return await r.apply(this,t);if(c)try{c(s,a,t)}catch(e){o.instrument_logger.error("Failed to execute beforeCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}let f=(0,i.getFlowState)();f||(f={}),f.httpMetric?.setFlowId(s),f.flowId=s,f.shouldLinkFunction=u;try{const e=g.run(f,Reflect.apply,r,this,t),n=await e;if(d)try{d(s,a,n)}catch(e){o.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n}catch(e){if(l)try{l(s,a,e)}catch(e){o.instrument_logger.error("Failed to execute catchCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}throw e}}:function(...t){let s;const a={};try{s=e(a,t)}catch(e){o.instrument_logger.error("Failed to get flowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(!s||hudRunningMode!==n.HudRunningMode.enabled)return r.apply(this,t);if(c)try{c(s,a,t)}catch(e){o.instrument_logger.error("Failed to execute beforeCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}let f=(0,i.getFlowState)();f||(f={}),f.httpMetric?.setFlowId(s),f.flowId=s,f.shouldLinkFunction=u;try{const e=g.run(f,Reflect.apply,r,this,t);if(d||l){if(e instanceof Promise)return e.catch(e=>{try{l&&l(s,a,e)}catch(e){o.instrument_logger.error("Failed to execute catchCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}throw e}).then(e=>{try{d&&d(s,a,e)}catch(e){o.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e});try{d&&d(s,a,e)}catch(e){o.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}return e}catch(e){if(l)try{l(s,a,e)}catch(e){o.instrument_logger.error("Failed to execute catchCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}throw e}},a(r,f),f[s]=!0,f},t.copyPropertiesToTarget=a,t.clearFlowStateData=function(e){try{e.httpMetric=void 0,e.flowId=void 0,e.shouldLinkFunction=void 0}catch{}};const n=r(8528),o=r(523),i=r(7131);t.AsyncFunction=(async()=>{}).constructor;const s=Symbol.for("hudMarked");function a(e,t){const r=Object.getOwnPropertyDescriptors(e),n=Reflect.ownKeys(r);Object.setPrototypeOf(t,e),n.forEach(e=>{try{Object.defineProperty(t,e,r[e])}catch{}})}},9063:e=>{"use strict";e.exports=require("require-in-the-middle")},9589:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8528),o=r(8269),i=r(2546),s=r(523),a=r(8949),u=r(714);class c extends u.FrameworkPatcher{static nextJSHudMarked=Symbol.for("hudNextJSMarked");static routeInfoSymbol=Symbol.for("hudNextJSRouteInfo");static standardMethods=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"];_patch(e){return(0,i.setIsNextJsApp)(!0),this._patchBaseServer(e),s.instrument_logger.info("Patched Next.js successfully"),e}_patchBaseServer(e){try{const t=e.default;if(t[c.nextJSHudMarked])return e;const r=t.prototype.renderToResponseWithComponentsImpl;if(!r)return s.instrument_logger.error("Could not find renderToResponseWithComponentsImpl on BaseServer.prototype"),e;t.prototype.renderToResponseWithComponentsImpl=async function(e,t,...n){try{const r=t.components;if(r&&r.routeModule&&!r.routeModule[c.nextJSHudMarked]){const t=r.routeModule,n=t.definition?.pathname||e.pathname;c._detectAndPatchSupportedMethods(t,n),t[c.nextJSHudMarked]=!0}}catch(e){s.instrument_logger.error("Failed to patch Next.js route module",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return await r.apply(this,[e,t,...n])},t[c.nextJSHudMarked]=!0,(0,a.copyPropertiesToTarget)(r,t.prototype.renderToResponseWithComponentsImpl)}catch(e){s.instrument_logger.error("Failed to patch Next.js base server",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}static _detectAndPatchSupportedMethods(e,t){try{if(t.startsWith("/_"))return;switch(s.instrument_logger.debug("Patching Next.js route module",{pathname:t,kind:e.definition?.kind||"unknown"}),e.definition.kind){case"APP_ROUTE":case"PAGES_API":c._patchApiModule(e,t);break;case"PAGES":case"APP_PAGE":c._patchPageModule(e,t);break;default:s.instrument_logger.warning("Unknown Next.js route module kind",{pathname:t,kind:e.definition?.kind||"unknown"})}}catch(e){s.instrument_logger.error("Error detecting and patching supported methods",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}static _patchApiModule(e,t){if(e.methods)for(const r of c.standardMethods)if("function"==typeof e.methods[r]&&"function"==typeof e.userland?.[r]){const u=(0,i.generateEndpointFlowId)(t,[r]);(0,o.storeEndpointDeclaration)(new n.EndpointDeclaration(u,[r],"nextjs","",t));try{const t=e.methods[r];e.methods[r]=(0,a.wrapFlow)(()=>u,t,!0)}catch(e){s.instrument_logger.error("Failed to patch Next.js App Route method",{method:r,pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}if(e.userland?.default){const r=c.standardMethods.filter(t=>!e.methods?.[t]),s=(0,i.generateEndpointFlowId)(t,r);(0,o.storeEndpointDeclaration)(new n.EndpointDeclaration(s,r,"nextjs","",t));const u=e.userland.default;e.userland={...e.userland,default:(0,a.wrapFlow)(()=>s,u,!0)}}}static _patchPageModule(e,t){const r=(0,i.generateEndpointFlowId)(t,["GET"]);if((0,o.storeEndpointDeclaration)(new n.EndpointDeclaration(r,["GET"],"nextjs","",t)),e.render&&"function"==typeof e.render&&!e.render[this.nextJSHudMarked])try{const n=e.render;e.render=function(...e){try{const n=e[2]?.renderOpts;for(const e of["Component","getServerSideProps","getStaticProps"])try{n?.[e]&&"function"==typeof n[e]&&!n[e].prototype?.isReactComponent&&(n[e]=(0,a.wrapFlow)(()=>r,n[e],!0))}catch(r){s.instrument_logger.error("Failed to patch Next.js Page renderOpts",{pathname:t,key:e,msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0})}}catch(e){s.instrument_logger.error("Failed to patch Next.js Page render method",{pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n.apply(this,e)},(0,a.copyPropertiesToTarget)(n,e.render),e.render[this.nextJSHudMarked]=!0}catch(e){s.instrument_logger.error("Failed to patch Next.js Page render method",{pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(e.userland?.loaderTree)try{l(e.userland.loaderTree,r)}catch(e){s.instrument_logger.error("Failed to patch App Router page component",{pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}else s.instrument_logger.info("No loader tree found on Next.js page component, functions will be patched by the render function",{pathname:t})}}function d(e,t,r){return(...n)=>{const o=e(...n),i=e=>{if(e&&"function"==typeof e.default){try{e.default.a}catch{return e}if(e.default.prototype?.isReactComponent)return e;const n=(0,a.wrapFlow)(()=>r,e.default,t);e={...e,default:n}}return e};return o&&"function"==typeof o.then?o.then(i):i(o)}}function l(e,t){const[,r,n]=e;for(const e of Object.keys(n))try{const r=n[e];if(Array.isArray(r)&&"function"==typeof r[0]){const n="page"===e,o=r[0];r[0]=d(o,n,t),(0,a.copyPropertiesToTarget)(o,r[0])}}catch(e){s.instrument_logger.error("Failed to iterate on Next.js components",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}for(const e of Object.values(r))try{l(e,t)}catch(e){s.instrument_logger.error("Failed to walk on Next.js parallel routes",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}t.default=c},9723:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0});const a=r(8269),u=r(2546),c=r(523),d=s(r(6928)),l=r(8949),f=r(714);class g extends f.FrameworkPatcher{_patch(e){(0,u.setIsNextJsApp)(!0);const t=this._patchLoadConfig(e);return c.instrument_logger.info("Patched next.js config successfully"),t}_patchLoadConfig(e){const t=e.default,r=async function(...e){const r=await t.call(this,...e);if(!r)return r;try{const t=e[1],n=d.join(t,r.distDir||".next"),o=d.join(n,a.apiManifest),i=d.join(n,a.pageManifest),s=await u.suppressTracesPromiseFS.access(o).then(()=>!0).catch(()=>!1),l=await u.suppressTracesPromiseFS.access(i).then(()=>!0).catch(()=>!1);(0,a.isNextConfigExtracted)()||!s&&!l||(c.instrument_logger.info("Extracted next.js config successfully"),(0,a.setNextConfig)(r))}catch(e){c.instrument_logger.error("Failed to patch next.js loadConfig",{msg:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0})}return r};(0,l.copyPropertiesToTarget)(t,r);const n=Object.create(Object.getPrototypeOf(e));return Object.defineProperty(n,"default",{enumerable:!0,get:function(){return r}}),(0,l.copyPropertiesToTarget)(e,n),n}}t.default=g},9873:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FlowMetric=void 0;const o=r(8528),i=r(8269),s=n(r(932));t.FlowMetric=class{_state;flowId;duration;_startTime;_msStartTime;errorBreakdown;constructor(e){this.flowId=e,this.duration=-1,this._state="usable"}static createUsableMetric(e){return new this(e)._createUsableMetric(e)}setFlowId(e){this.flowId=e}getFlowId(){return this.flowId}getMsStartTime(){return this._msStartTime}start(){hudRunningMode===o.HudRunningMode.enabled&&(this._startTime=s.default.hrtime.bigint(),this._msStartTime=Date.now())}setErrorBreakdown(e){this.errorBreakdown=e}end(){hudRunningMode===o.HudRunningMode.enabled&&(-1===this.duration&&this.calculateDuration(),this.#e(),this._state="unusable")}calculateDuration(){this._startTime&&(this.duration=Number(s.default.hrtime.bigint()-this._startTime))}#e(){if(hudRunningMode===o.HudRunningMode.enabled){const e=this.toRaw();e&&(0,i.storeFlowMetric)(e)}}}},9938:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wrapOutboundFunction=function(e,t,r,n,o,i=!1){let u;if(e instanceof a.AsyncFunction){const a=(0,s.getWrapperTypeFromPrefix)("await",!0),c=(0,s.getWrapperTypeFromPrefix)("await",!1);u=async function(...u){let g,p,h,m;const y="function"==typeof t?t(u):t;if(void 0===y)return await e.apply(this,u);try{g=(0,s.wrapperInitial)(y,!0);const e=d(u,g,r,n,o,y);p=e?.outboundInvocation,h=e?.outboundIndex}catch{}try{const t=e.apply(this,u);try{(0,s.asyncWrapper)(g,a)}catch{}m=await t;try{(0,s.asyncWrapper)(g,c)}catch{}}catch(e){try{(0,s.wrapperCatch)(e,g,[]),i||f(e,h,p,g)}catch{}throw e}finally{try{(0,s.wrapperFinally)(g)}catch{}}if(!i){if(!g||2!==hudRunningMode)return m;l(m,h,p,g.start,n)}return m}}else u=function(...a){let u,c,g,p={};const h="function"==typeof t?t(a):t;if(void 0===h)return e.apply(this,a);try{p=(0,s.wrapperInitial)(h,!0);const e=d(a,p,r,n,o,h);u=e?.outboundInvocation,c=e?.outboundIndex}catch{}try{g=e.apply(this,a)}catch(e){try{(0,s.wrapperCatch)(e,p,[]),i||f(e,c,u,p)}catch{}throw e}finally{try{(0,s.wrapperFinally)(p)}catch{}}if(g instanceof Promise)return i?g:g.catch(e=>{throw f(e,c,u,p),e}).then(e=>p&&2===hudRunningMode?(l(e,c,u,p.start,n),e):e);if(!i){if(!p||2!==hudRunningMode)return g;l(g,c,u,p.start,n)}return g};return(0,a.copyPropertiesToTarget)(e,u),u},t.wrapOutboundBodyFunction=function(e,t,r,n){if(e instanceof a.AsyncFunction)return i.instrument_logger.warning("Wrap outbound body function doesn't support async functions"),e;const u=function(...i){let a,u,c,d;try{if(a=(0,s.wrapperInitial)(t,!0),u=r(this,i),void 0!==u){const e=(0,s.getInvestigationStorage)()?.getStore();void 0!==e&&e.status!==o.InvestigationStatus.Cleared&&(c=e.data.outbounds[u])}}catch{}try{d=e.apply(this,i)}catch(e){try{(0,s.wrapperCatch)(e,a,[]),p(e,c,u,a)}catch{}throw e}finally{try{(0,s.wrapperFinally)(a)}catch{}}return d instanceof Promise?d.catch(e=>{throw p(e,c,u,a),e}).then(e=>a&&2===hudRunningMode?(g(this,e,u,c,a.start,n),e):e):a&&2===hudRunningMode?(g(this,d,u,c,a.start,n),d):d};return(0,a.copyPropertiesToTarget)(e,u),u},t.getBodySize=function(e){if(e&&("string"==typeof e||e instanceof Buffer)&&e.length>0)return e.length},t.getReducedBody=y,t.reduceRequestArgsIfNeeded=function(e,t,r){try{const o=t.args;if(void 0===o)return;const i=r(e),s=isNaN(i)||0===i?void 0:i;o.bodySize=s,o.body=y(o.body,s,n.hudConfig.dynamicConfig.maxHTTPRequestBodySize)}catch(e){(0,i.limitedLogger)("Error reducing request args",{error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}};const n=r(5809),o=r(8528),i=r(523),s=r(7131),a=r(8949),u={[o.OutboundType.HTTP]:e=>{void 0!==e&&(e.url=void 0,e.body=void 0)},[o.OutboundType.DB]:e=>{void 0!==e&&(e.query=void 0,e.params=void 0)},[o.OutboundType.REDIS]:e=>{void 0!==e&&(e.key=void 0,e.args=void 0)}},c={[o.OutboundType.HTTP]:e=>{void 0!==e&&(e.body=void 0)},[o.OutboundType.DB]:e=>{},[o.OutboundType.REDIS]:e=>{}};function d(e,t,r,a,c,d){if(!t||2!==hudRunningMode)return;const g=(0,s.getInvestigationStorage)()?.getStore();if(void 0===g||g.status!==o.InvestigationStatus.Open)return;if(g.data.outbounds.length>=n.hudConfig.dynamicConfig.maxTotalOutbounds)return void(0,i.limitedLogger)("max outbound calls reached");const p=g.data.outbounds.length;let h;try{void 0!==r&&p<n.hudConfig.dynamicConfig.maxOutboundCountWithData&&(h=r(e,e=>f(e,p,m,t),e=>l(e,p,m,t.start,a)))}catch(e){(0,i.limitedLogger)("error parsing args",{error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const m={function_id:d,caller_id:t.wrappedCaller,type:c,args:h,timestamp:Date.now()};return(p>=n.hudConfig.dynamicConfig.maxOutboundCountWithData||!n.hudConfig.dynamicConfig.enableOutboundData)&&u[m.type](m.args),g.data.outbounds.push(m),{outboundInvocation:m,outboundIndex:p}}function l(e,t,r,o,s){try{if(void 0===t||void 0===r)return;if(void 0!==s&&t<n.hudConfig.dynamicConfig.maxOutboundCountWithData){let o;try{o=s(e,t,r)}catch(e){(0,i.limitedLogger)("error parsing result",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}(t>=n.hudConfig.dynamicConfig.maxOutboundCountWithData||!n.hudConfig.dynamicConfig.enableOutboundData)&&c[r.type](o),r.result=o}const a=process.hrtime.bigint();r.duration=Number(a-o)}catch{}}function f(e,t,r,o){if(o&&2===hudRunningMode)try{if(void 0===r||void 0===t)return;r.error=t<n.hudConfig.dynamicConfig.maxOutboundCountWithData&&n.hudConfig.dynamicConfig.enableOutboundData?e:(0,s.extractName)(e),r.duration=Number(process.hrtime.bigint()-o.start)}catch{}}function g(e,t,r,s,a,u){try{if(void 0===r||void 0===s||s.type!==o.OutboundType.HTTP||void 0===s.result)return;try{const r=u(e,t);s.result.body=r?.body,s.result.bodySize=r?.bodySize}catch(e){(0,i.limitedLogger)("error getting body",{error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const d=process.hrtime.bigint();s.bodyDuration=Number(d-a),(r>=n.hudConfig.dynamicConfig.maxOutboundCountWithData||!n.hudConfig.dynamicConfig.enableOutboundData)&&c[o.OutboundType.HTTP](s.result)}catch{}}function p(e,t,r,o){if(o&&2===hudRunningMode)try{if(void 0===t||void 0===r)return;t.bodyError=r<n.hudConfig.dynamicConfig.maxOutboundCountWithData&&n.hudConfig.dynamicConfig.enableOutboundData?e:(0,s.extractName)(e),t.bodyDuration=Number(process.hrtime.bigint()-o.start)}catch{}}const h="[HUD_BODY_TOO_LONG]",m="[HUD_NO_CONTENT_LENGTH_HEADER]";function y(e,t,r){return void 0!==t&&t>r?h:void 0===t&&null!=e&&""!==e?m:e}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}return r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r(2197)})());
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,()=>(()=>{var e={290:e=>{"use strict";e.exports=require("async_hooks")},336:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(2822),s=r(8949),a=r(4393),u=r(714);class c extends u.FrameworkPatcher{_patch(e){return this._patchSendRequest(e),n.instrument_logger.info("Patched @codegenie/serverless-express/src/frameworks/express.js successfully"),e}_patchSendRequest(e){const t=e.sendRequest;e.sendRequest=function(e){const r=e?.request,u=e?.response;if(!r||!u)return t.call(this,e);const c=a.HttpEndpointMetric.createUsableMetric(),d=(0,o.getFlowStateStorage)(),l={httpMetric:c},f=()=>{try{c.start(),c.setRequestAttributes(r)}catch(e){n.instrument_logger.error("Failed to start flowMetric during sendRequest patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{u.once("finish",function(){try{c.calculateDuration(),(0,i.finishHttpInvestigation)(r,u,c),c.setResponseAttributes(u),c.end()}catch(e){n.instrument_logger.error("Failed to end flowMetric during sendRequest patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),u.once("close",()=>{(0,i.clearInvestigationDataFromStorage)(),(0,s.clearFlowStateData)(l)})}catch(e){n.instrument_logger.error("Failed to end flowMetric during sendRequest patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return(0,i.runWithInvestigation)(()=>t.call(this,e))};return d?d.run(l,f):f()},(0,s.copyPropertiesToTarget)(t,e.sendRequest)}}t.default=c},392:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.patchAllSetIntervalFunctions=function(){if(u)return;u=!0;const e=function(e){const t=function(t,...r){let s="";try{const e=(0,i.executionAsyncResource)()[o.kHudCaller]??globalThis.hudStack[globalThis.hudStackIndex.value];s="function"==typeof t?function(...r){try{(0,i.executionAsyncResource)()[o.kHudCaller]=e}catch{(0,n.limitedLogger)("wrappedHandler failed")}return t.apply(this,r)}:t}catch{(0,n.limitedLogger)("patchedSetInterval failed")}return e(s,...r)};return(0,s.copyPropertiesToTarget)(e,t),t}(a.setInterval);a.setInterval=e,globalThis.setInterval=e};const n=r(523),o=r(7131),i=r(6698),s=r(8949),a=r(7997);let u=!1},486:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8544);class o extends n.BaseKafkaJSPatcher{getExportsRoot(e){return e}getGroupId(e){return e[0].groupId}moduleName(){return"KafkaJS"}}t.default=o},523:e=>{"use strict";e.exports=require("./logger")},646:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(8949),i=r(5128),s=r(714);class a extends s.FrameworkPatcher{_patch(e){return this._patchCreate(e),n.instrument_logger.info("Patched NestJS RouterExecutionContext successfully"),e}_patchCreate(e){const t=e.RouterExecutionContext.prototype.create;e.RouterExecutionContext.prototype.create=function(...e){try{const t=e[0],r=e[1];"function"==typeof t.constructor&&"function"==typeof r?e[1]=(0,i.wrapLinkedFunction)(r):n.instrument_logger.error("Invalid args in NestJS RouterExecutionContext.create",{args:e})}catch(e){n.instrument_logger.error("Error in NestJS RouterExecutionContext patcher",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,e)},(0,o.copyPropertiesToTarget)(t,e.RouterExecutionContext.prototype.create)}}t.default=a},714:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.FrameworkPatcher=void 0,t.isSupportedVersion=l,t.extractModuleVersion=f,t.getFrameworkPatcher=function(e){return new(r(2828)(`./${e}`).default)};const a=r(2546),u=r(523),c=s(r(6928)),d=r(8064);function l(e,t){return""===e||d.satisfies(d.coerce(e),t)}function f(e){try{const t=a.suppressTracesFS.readFileSync(c.join(e,"package.json"),{encoding:"utf8"}),r=JSON.parse(t).version;return"string"==typeof r?r:""}catch{u.instrument_logger.info("Failed extracting version",{baseDir:e})}return""}t.FrameworkPatcher=class{patch(e,t,r,n,o=this.constructor.name){try{if(this.isSupported(t,o,r,n))return this._patch(e)}catch(e){u.instrument_logger.error("Unhandled error during patching framework",{framework:o,error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}isSupported(e,t,r,n){const o=f(e);return!!l(o,r)||(u.instrument_logger.warning("Unsupported version",{framework:t,version:o,supportedVersion:r,basedir:e}),n&&n.isOutbound||u.customer_logger.logEntry(a.UserErrorLogs.UnsupportedFrameworkVersion(t)),!1)}}},828:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KafkaJSMetric=void 0;const n=r(523),o=r(7131),i=r(9873);class s extends i.FlowMetric{partition;error;producedTimestamp;totalConsumeDuration;constructor(e){super(e)}_createUsableMetric(e){return this}end(){this.producedTimestamp&&(this.totalConsumeDuration=Number(Date.now()-this.producedTimestamp)*Number(1e6)),super.end()}addProducedTimestamp(e){void 0!==e&&(this.producedTimestamp=Number(e))}addPartition(e){this.partition=e}setError(e){this.error=(0,o.extractName)(e)}setUserError(e){this.error=e}toRaw(){if(void 0!==this.partition)return{flow_id:this.flowId,type:"KafkaJSMetric",duration:this.duration,partition:this.partition,error:this.error,total_consume_duration:this.totalConsumeDuration,error_breakdown:this.errorBreakdown};n.instrument_logger.warning("No partition found for message",{flowId:this.flowId})}}t.KafkaJSMetric=s},857:e=>{"use strict";e.exports=require("os")},932:e=>{"use strict";e.exports=require("process")},1326:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(2546),i=r(523),s=r(8949),a=r(714),u=n(r(9589));class c extends a.FrameworkPatcher{static nextJSHudMarked=Symbol.for("hudNextJSMarked");_patch(e){return(0,o.setIsNextJsApp)(!0),this._pathLoad(e),i.instrument_logger.info("Patched Next.js successfully"),e}_pathLoad(e){try{const t=e.RouteModuleLoader;if(t[c.nextJSHudMarked])return e;const r=t.load;t.load=async function(...e){const t=await r.apply(this,e);try{if(t){const e=t.definition?.pathname;e&&!t[c.nextJSHudMarked]&&(u.default._detectAndPatchSupportedMethods(t,e),t[c.nextJSHudMarked]=!0)}}catch(e){i.instrument_logger.error("Failed to patch Next.js route module",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t},t[c.nextJSHudMarked]=!0,(0,s.copyPropertiesToTarget)(r,t.load)}catch(e){i.instrument_logger.error("Failed to patch Next.js base server",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}}t.default=c},1427:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSystemInfo=function(){return{pod_name:c(),node_name:d()}};const o=r(2546),i=n(r(857)),s=Symbol("not found");let a,u;function c(){if(a!==s){if(a)return a;try{return a=i.default.hostname(),a}catch{return void(a=s)}}}function d(){if(u!==s){if(u)return u;try{const e=o.suppressTracesFS.readFileSync("/etc/machine-id","utf8").trim();return u=e,u}catch{return void(u=s)}}}},1502:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5809),o=r(8528),i=r(8269),s=r(2546),a=r(523),u=r(8949),c=r(714);class d extends c.FrameworkPatcher{static koaModuleName="koa";static koaPatchedSymbol=Symbol.for(n.hudConfig.hudPatchedName);_patch(e){return this._patchAppUse(e),a.instrument_logger.info("Patched koa successfully"),e}_patchAppUse(e){const t=e.prototype.use;e.prototype.use=function(e){const r=t.apply(this,arguments);try{if(!arguments[0].router)return r;const e=arguments[0].router.stack;for(let t=0;t<e.length;t++)d._wrapRoute(e[t])}catch(e){a.instrument_logger.error("Failed to patch koa.use function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r},(0,u.copyPropertiesToTarget)(t,e.prototype.use)}static _wrapRoute(e){if(e.methods&&0===e.methods.length)return;if(!e.stack[0][d.koaPatchedSymbol]){const t=(0,u.wrapFlow)(p,e.stack[0],!0);e.stack[0]=t,e.stack[0][d.koaPatchedSymbol]=!0}const t=(0,s.generateEndpointFlowId)(e.path,e.methods);(0,i.storeEndpointDeclaration)(new o.EndpointDeclaration(t,e.methods,"koa",void 0,e.path));for(const r of e.methods)g(t,e.path,r)}}function l(e,t){return e+"|"+t}t.default=d;const f=new Map;function g(e,t,r){f.set(l(t,r),e)}function p(e,t){if(0===t.length)return;const r=t[0]._matchedRoute,n=t[0].req?.method;return function(e,t){return f.get(l(e,t))}(r,n)}},2080:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SqsMetric=void 0;const n=r(9873);class o extends n.FlowMetric{errors;msgCount;e2eEpocStartTimeMS;e2eDurationNS;_finishedMessageCount;constructor(e){super(e),this._finishedMessageCount=0,this.errors={}}addError(e,t=1){this.errors[e]=(this.errors[e]??0)+t}setUserError(e){this.addError(e,1)}increaseAndShouldEnd(e=1){return this._finishedMessageCount+=e,!(this.msgCount&&this._finishedMessageCount<this.msgCount)}end(){this.e2eEpocStartTimeMS&&(this.e2eDurationNS=Number(Date.now()-this.e2eEpocStartTimeMS)*Number(1e6)),super.end()}_createUsableMetric(e){return this}toRaw(){return{flow_id:this.flowId,type:"SqsMetric",duration:this.duration,e2e_duration:this.e2eDurationNS,msg_count:this.msgCount,errors:this.errors,error_breakdown:this.errorBreakdown}}}t.SqsMetric=o},2197:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)},a=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.serializableInvestigation=t.koa=t.express=t.safeLog=t.registerHook=t.hudRITM=void 0;var u=r(5688);Object.defineProperty(t,"hudRITM",{enumerable:!0,get:function(){return u.hudRITM}}),Object.defineProperty(t,"registerHook",{enumerable:!0,get:function(){return u.registerHook}}),Object.defineProperty(t,"safeLog",{enumerable:!0,get:function(){return u.safeLog}}),s(r(3901),t),t.express=a(r(7127)),s(r(714),t),t.koa=a(r(1502)),s(r(7166),t),s(r(3073),t),s(r(392),t);var c=r(2822);Object.defineProperty(t,"serializableInvestigation",{enumerable:!0,get:function(){return c.serializableInvestigation}})},2546:e=>{"use strict";e.exports=require("./lib")},2729:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(2822),s=r(8949),a=r(4393),u=r(714);class c extends u.FrameworkPatcher{_patch(e){const t=this._patchGetFramework(e);return n.instrument_logger.info("Patched serverless-http/lib/framework/get-framework.js successfully"),t}_patchGetFramework(e){const t=e;return e=function(...e){const r=t.apply(t.this,e);async function u(e,...t){const u=a.HttpEndpointMetric.createUsableMetric(),c=(0,o.getFlowStateStorage)(),d={httpMetric:u},l=async()=>{try{u.start(),u.setRequestAttributes(e)}catch(e){n.instrument_logger.error("Failed to start flowMetric during framework serverless request handler patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const o=await(0,i.runWithInvestigation)(()=>r.apply(r.this,[e,...t]));return o.once("finish",function(){try{u.calculateDuration(),(0,i.finishHttpInvestigation)(e,o,u),u.setResponseAttributes(o),u.end()}catch(e){n.instrument_logger.error("Failed to end flowMetric during framework serverless request handler patching",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),o.once("close",()=>{(0,i.clearInvestigationDataFromStorage)(),(0,s.clearFlowStateData)(d)}),o};return c?await c.run(d,l):await l()}return(0,s.copyPropertiesToTarget)(r,u),u},(0,s.copyPropertiesToTarget)(t,e),e}}t.default=c},2741:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(6730),i=r(4815),s=r(7225),a=r(714);class u extends a.FrameworkPatcher{_patch(e){return s.isVerboseLoggingEnabled?((0,o.patchMethods)(e,"application_export"),(0,i.patchUse)(e,"application",!1),(0,s.logLazyRouter)(e),n.instrument_logger.info("Patched express.Application successfully"),e):(n.instrument_logger.info("Skipping express.Application patching, verbose logging is not enabled"),e)}}t.default=u},2784:e=>{"use strict";e.exports=require("../native/_index")},2822:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getStackTraceWithoutMessage=f,t.serializableInvestigation=g,t.getBaseInvestigationStorage=p,t.createNewInvestigation=function(){if(!globalThis.hudEnableInvestigation)return;const e=(0,a.getInvestigationStorage)();void 0!==e&&e.enterWith(p())},t.runWithInvestigation=function(e){if(!globalThis.hudEnableInvestigation)return e();const t=(0,a.getInvestigationStorage)();return void 0===t?e():t.run(p(),e)},t.closeInvestigation=m,t.clearInvestigationDataFromStorage=h,t.storeInvestigation=y,t.getInvestigationDedupingKey=_,t.minimizeObject=k,t.finishHttpInvestigation=function(e,t,r){try{if(r.apiProtocol===u.ApiProtocol.GraphQL)return void function(e,t,r){const i=function(e,t){const r=t.apiProtocolAttributes;return e.statusCode>=500||r&&r.errorOccurred||S()?"Error":!!x(t,o.InvestigationType.GraphQL)&&"Duration"}(t,r);if(!1===i)return;const u=C(r,i,o.InvestigationType.GraphQL);if(void 0===u)return void(0,s.limitedLogger)("finishHttpInvestigation: base investigation return undefined");const g=r.getFlowId(),p=r.getMsStartTime();if(void 0===g||void 0===p)return void(0,s.limitedLogger)("flowId or reqTimestamp are undefined even though they shouldn't",{flowId:g,reqTimestamp:p});const m=r.apiProtocolAttributes?.errors;y(u,{type:o.InvestigationType.GraphQL,flow_id:g,timestamp:p,request_body:k(e.body,Math.max(n.hudConfig.dynamicConfig.investigationRateLimits.maxObjectDepth,4)),graphql_errors:m?.map(e=>({name:(0,a.extractName)(e),message:k((0,a.extractMessage)(e)),stackTrace:e instanceof Error?f(e.message,e.stack):void 0})),status_code:t.statusCode,machine_metrics:(0,c.getMachineMetrics)(),observability_identifiers:(0,d.getObservabilityIdentifiersHttp)(e),system_info:(0,l.getSystemInfo)()})}(e,t,r);!function(e,t,r){const n=function(e,t){return e.statusCode>=500||S()?"Error":!!x(t,o.InvestigationType.HTTP)&&"Duration"}(t,r);if(!1===n)return;const i=C(r,n,o.InvestigationType.HTTP);if(void 0===i)return;try{(0,s.limitedLogger)("http requests headers",{headers:Object.keys(e.headers)})}catch{(0,s.limitedLogger)("failed to log http requests headers")}const a=r.getFlowId(),u=r.getMsStartTime(),f=r.apiProtocolAttributes;if(void 0===a||!f||void 0===f.method||void 0===u)return void(0,s.limitedLogger)("route, method, or reqTimestamp are undefined even though they shouldn't",{flowId:a,method:f.method,reqTimestamp:u});const g=e.url||e.path,p=g?.split("?")[0];y(i,{type:o.InvestigationType.HTTP,endpoint_uuid:a,route:p,method:f.method,timestamp:u,params:k(e.params),query:k(e.query),request_body:k(e.body),status_code:t.statusCode,machine_metrics:(0,c.getMachineMetrics)(),observability_identifiers:(0,d.getObservabilityIdentifiersHttp)(e),extra_headers:(0,d.getExtraHeaders)(e),system_info:(0,l.getSystemInfo)()})}(e,t,r)}catch(e){(0,s.limitedLogger)("Failed to finish http investigation",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}finally{h()}},t.finishSqsInvestigation=function(e,t){try{const r=function(e){return Object.keys(e.errors).length>0||S()?"Error":!!x(e,o.InvestigationType.SQS)&&"Duration"}(t);if(!1===r)return;const n=C(t,r,o.InvestigationType.SQS);if(void 0===n)return;const i=t.getFlowId(),a=t.getMsStartTime();if(void 0===a||void 0===i)return void(0,s.limitedLogger)("reqTimestamp is undefined even though it shouldn't",{flowId:i});y(n,{type:o.InvestigationType.SQS,timestamp:a,flow_id:i,messages:k(e),machine_metrics:(0,c.getMachineMetrics)(),system_info:(0,l.getSystemInfo)()})}catch(e){(0,s.limitedLogger)("Failed to finish sqs investigation",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}finally{h()}},t.finishKafkaJSInvestigation=function(e,t,r,n){try{const i=function(e){return void 0!==e.error||S()?"Error":!!x(e,o.InvestigationType.Kafka)&&"Duration"}(t);if(!1===i)return;const a=C(t,i,o.InvestigationType.Kafka);if(void 0===a)return;const u=t.getFlowId(),f=t.getMsStartTime();if(void 0===f||void 0===u)return void(0,s.limitedLogger)("reqTimestamp is undefined even though it shouldn't",{flowId:u});const g=e.map(e=>{let t=e.value;t instanceof Buffer&&(t=t.toString());try{t=JSON.parse(t)}catch{}return{key:e.key,value:t,timestamp:e.timestamp,offset:e.offset,headers:e.headers,attributes:e.attributes}});y(a,{type:o.InvestigationType.Kafka,timestamp:f,topic:r,partition:n,flow_id:u,messages:k(g),machine_metrics:(0,c.getMachineMetrics)(),system_info:(0,l.getSystemInfo)(),observability_identifiers:(0,d.getObservabilityIdentifiers)()})}catch(e){(0,s.limitedLogger)("Failed to finish kafkajs investigation",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}finally{h()}},t.getErrorRecordsFromInvestigation=E;const n=r(5809),o=r(8528),i=r(8269),s=r(523),a=r(7131),u=r(4393),c=r(7808),d=r(7603),l=r(1427);function f(e,t){if(void 0===t)return;const r=function(e){if(void 0===e)return 0;let t=0;for(let r=0;r<e.length;r++)"\n"===e[r]&&t++;return t}(e)+1;let n=-1;for(let e=0;e<r;e++)if(n=t.indexOf("\n",n+1)??-1,-1===n)return;return-1!==n?t.slice(n+1):void 0}function g(e){const{data:t}=e;return{status:e.status,context:t.context,exceptions:Array.from(t.exceptions.values()).map(({exception:e,executionFlow:t,caught:r})=>({name:(0,a.extractName)(e),message:(0,a.extractMessage)(e),stackTrace:e instanceof Error?f(e.message,e.stack):void 0,executionFlow:t.map(e=>({function_id:e.function_id,caller_id:e.caller_id,args:void 0!==e.args?k(e.args,n.hudConfig.dynamicConfig.investigationRateLimits.maxObjectDepth+2):void 0})),caught:r})),userContext:t.userContext,userDefinedError:t.userDefinedError,caught:t.caught,triggerType:t.triggerType,duration:t.duration,durationThreshold:t.durationThreshold,outbounds:t.outbounds.map(e=>function(e){try{return{function_id:e.function_id,caller_id:e.caller_id,type:e.type,duration:e.duration?Number(e.duration):void 0,timestamp:e.timestamp,args:k(e.args),result:k(e.result),error:e.error?{type:"string"==typeof e.error?e.error:(0,a.extractName)(e.error),message:(0,a.extractMessage)(e.error)}:void 0,...e.type===o.OutboundType.HTTP?{bodyDuration:e.bodyDuration,bodyError:e.bodyError?{type:"string"==typeof e.bodyError?e.bodyError:(0,a.extractName)(e.bodyError),message:(0,a.extractMessage)(e.bodyError)}:void 0}:{}}}catch(e){return void(0,s.limitedLogger)("error serializing outbound",e)}}(e)).filter(e=>void 0!==e)}}function p(){return{status:o.InvestigationStatus.Open,data:{triggerType:void 0,duration:0,caught:!0,exceptions:new Map,outbounds:[]}}}function m(){const e=(0,a.getInvestigationStorage)();if(void 0===e)return void(0,s.limitedLogger)("closeInvestigation: getStorage() is undefined");const t=e.getStore();if(void 0!==t&&t.status===o.InvestigationStatus.Open)return t.status=o.InvestigationStatus.Closed,t;(0,s.limitedLogger)(`closeInvestigation: investigation is undefined or not open, is undefined: ${void 0===t}`)}function h(){try{const e=(0,a.getInvestigationStorage)();if(void 0===e)return;const t=e.getStore();if(void 0===t||t.status===o.InvestigationStatus.Cleared)return;!function(e){try{e.data.exceptions.clear(),e.data.outbounds.length=0,e.data=void 0,e.status=o.InvestigationStatus.Cleared}catch{}}(t)}catch{}}function y(e,t){e.data.context=t,(0,i.storeClosedInvestigation)(g(e))}function b(e){for(const t of e)if(!t.is_outbound_function)return t.function_id}function _(e,t,r){let n="";for(const t of e)n+=`${t.error_type}-${t.function_id}|`;return n+=`${t}`,void 0!==r&&(n+=`|${r}`),n}let v=null;function k(e,t=n.hudConfig.dynamicConfig.investigationRateLimits.maxObjectDepth,o=new WeakSet){try{if(null===v&&(v=r(8611).IncomingMessage),null!==e&&"object"==typeof e){if(o.has(e))return"[Circular Reference]";if(v&&e instanceof v)return"[Http Request]";o.add(e)}if(null==e||["number","boolean"].includes(typeof e))return e;if("string"==typeof e)return e.length>n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength?e.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength)+"...":e;if(e instanceof Buffer)return e.length>n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength?e.subarray(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength).toString()+"...":e.toString();if(e instanceof ArrayBuffer){const t=Buffer.from(e);return t.length>n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength?t.subarray(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxStringLength).toString()+"...":t.toString()}if(["bigint","symbol"].includes(typeof e))return k(e.toString(),t-1,o);if("function"==typeof e)return`[Function: ${e.name||"anonymous"}]`;if(void 0===e)return;if(Array.isArray(e))return t<=0?"[Array]":e.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength).map(e=>k(e,t-1,o));if(e instanceof Map)return t<=0?"[Map]":{"[Map]":Array.from(e.entries()).slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength).map(([e,r])=>[k(e,t-1,o),k(r,t-1,o)])};if(e instanceof Set)return t<=0?"[Set]":{"[Set]":Array.from(e.values()).slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength).map(e=>k(e,t-1,o))};if(e instanceof Date){let r;try{r=e.toISOString()}catch{}return k(r,t-1,o)}if(e instanceof RegExp)return k(e.toString(),t-1,o);if(e&&"Proxy"===e[Symbol.toStringTag])return k(e.target||e,t-1,o);if(e&&e[Symbol.toStringTag])return`[${e[Symbol.toStringTag]}]`;if("object"==typeof e){if(t<=0)return"[Object]";const r={},i=Object.getOwnPropertyNames(e),s=Object.getOwnPropertySymbols(e);for(const s of i.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength))try{r[s.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxKeyLength)]=k(e[s],t-1,o)}catch{}for(const i of s.slice(0,n.hudConfig.dynamicConfig.investigationRateLimits.maxArrayLength))try{r[i.toString()]=k(e[i],t-1,o)}catch{}return r}}catch{}}function C(e,t,r){let o;if(o="Error"===t?function(e){const t=m();if(void 0===t)return void(0,s.limitedLogger)("finishErrorInvestigation: investigation is undefined");const r=e.getFlowId();if(void 0===r)return void(0,s.limitedLogger)("finishErrorInvestigation: flowId is undefined");const o=E(t),a=_(o,t.data.caught,t.data.userDefinedError);if(e.setErrorBreakdown({key:a,errors:o,caught:t.data.caught,failure_type:t.data.userDefinedError}),t.data.userDefinedError&&e.setUserError(t.data.userDefinedError),(0,i.getGlobalInvestigationTracking)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations)return void(0,s.limitedLogger)("finishErrorInvestigation: globalInvestigationTracking is greater than maxTotalInvestigations",{globalInvestigationTracking:(0,i.getGlobalInvestigationTracking)(),maxTotalInvestigations:n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations});if((0,i.getTotalInvestigationsErrorBased)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigationsErrorBased)return void(0,s.limitedLogger)("finishErrorInvestigation: currentTotalInvestigationsErrorBased is greater than maxTotalInvestigationsErrorBased");const u=(0,i.getInvestigationDedupingCache)(r).get(a)??0;if(!(u>=n.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations))return(0,i.increaseGlobalInvestigationTracking)(),(0,i.increaseTotalInvestigationsErrorBased)(),(0,i.increaseInvestigationDedupingCache)(r,a),t;(0,s.limitedLogger)("finishErrorInvestigation: investigationCount is greater than maxSameInvestigations",{flowId:r,investigationDedupKey:a,investigationCount:u,maxSameInvestigations:n.hudConfig.dynamicConfig.investigationRateLimits.maxSameInvestigations},a)}(e):function(e,t){const r=e.getFlowId();if(void 0===r)return void(0,s.limitedLogger)("finishDurationInvestigation: flowId is undefined");if((0,i.getGlobalInvestigationTracking)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigations)return void(0,s.limitedLogger)("finishDurationInvestigation: currentTotalInvestigationsGlobal is greater than maxTotalInvestigations");if((0,i.getTotalInvestigationsDurationBased)()>=n.hudConfig.dynamicConfig.investigationRateLimits.maxTotalInvestigationsDurationBased)return void(0,s.limitedLogger)("finishDurationInvestigation: currentTotalInvestigationsDurationBased is greater than maxTotalInvestigationsDurationBased");const o=w(r,t);if(void 0!==o)return(0,i.getInvestigationDurationCount)(r)>=o.number_of_dumps?((0,s.limitedLogger)("finishDurationInvestigation: currentInvestigationCount is greater than durationThresholdAndCount.count"),void s.app_logger.debug("finishDurationInvestigation: currentInvestigationCount is greater than durationThresholdAndCount.count")):((0,i.increaseInvestigationDurationCount)(r),(0,i.increaseGlobalInvestigationTracking)(),(0,i.increaseTotalInvestigationsDurationBased)(),m());(0,s.limitedLogger)("finishDurationInvestigation: durationThresholdAndCount is undefined")}(e,r),void 0!==o)return o.data.triggerType=t,o.data.duration=e.duration,o.data.durationThreshold=w(e.getFlowId()??"",r)?.duration,o;(0,s.limitedLogger)("finishInvestigation: investigation return undefined")}function w(e,t){const r=(0,i.getFlowIdDurationThresholdAndCount)(e);return void 0===r?(0,i.getFlowIdDurationThresholdAndCount)(`default-${t}`):r}function S(){const e=(0,a.getInvestigationStorage)();if(void 0===e)return!1;const t=e.getStore();return void 0!==t?.data?.userDefinedError}function x(e,t){const r=e.getFlowId();if(void 0===r)return!1;const n=w(r,t);return void 0!==n&&n.duration<e.duration}function E(e){const t=new Set,r=[];for(const n of e.data.exceptions.values()){const e=(0,a.extractName)(n.exception),o=b(n.executionFlow)??"",i=`${e}-${o}`;if(t.has(i))continue;t.add(i);const s={error_type:e,function_id:o};r.push(s)}return r}},2828:(e,t,r)=>{var n={"./baseKafkaJsPatcher":8544,"./baseKafkaJsPatcher.ts":8544,"./codeGenieServerlessExpress":336,"./codeGenieServerlessExpress.ts":336,"./confluentKafkaJs":7276,"./confluentKafkaJs.ts":7276,"./express":7127,"./express.ts":7127,"./express/methods":6730,"./express/methods.ts":6730,"./express/route":2977,"./express/route.ts":2977,"./express/router":4815,"./express/router.ts":4815,"./express/verbosity":7225,"./express/verbosity.ts":7225,"./expressApplication":2741,"./expressApplication.ts":2741,"./flows/flow":9873,"./flows/flow.ts":9873,"./flows/http":4393,"./flows/http.ts":4393,"./flows/kafkajs":828,"./flows/kafkajs.ts":828,"./flows/sqs":2080,"./flows/sqs.ts":2080,"./frameworkPatcher":714,"./frameworkPatcher.ts":714,"./graphql":7214,"./graphql.ts":7214,"./http":5459,"./http.ts":5459,"./internal/pLimit":4986,"./internal/pLimit.ts":4986,"./kafkajs":486,"./kafkajs.ts":486,"./koa":1502,"./koa.ts":1502,"./nestjsRouterExecutionContext":646,"./nestjsRouterExecutionContext.ts":646,"./nestjsRpcContextCreator":4290,"./nestjsRpcContextCreator.ts":4290,"./nextJsConfig":9723,"./nextJsConfig.ts":9723,"./nextJsModuleLoader":1326,"./nextJsModuleLoader.ts":1326,"./nextJsRouteModule":8840,"./nextJsRouteModule.ts":8840,"./nextjs":9589,"./nextjs.ts":9589,"./outbound/axios":5354,"./outbound/axios.ts":5354,"./outbound/ioredis":7535,"./outbound/ioredis.ts":7535,"./outbound/mongoHelpers":7255,"./outbound/mongoHelpers.ts":7255,"./outbound/mongodb":9702,"./outbound/mongodb.ts":9702,"./outbound/mongoose":9803,"./outbound/mongoose.ts":9803,"./outbound/nodeFetch":8564,"./outbound/nodeFetch.ts":8564,"./outbound/pg":7427,"./outbound/pg.ts":7427,"./outbound/request":4349,"./outbound/request.ts":4349,"./outbound/wrapOutbound":9938,"./outbound/wrapOutbound.ts":9938,"./router":5946,"./router.ts":5946,"./serverlessHttp":2729,"./serverlessHttp.ts":2729,"./sqsConsumer":5150,"./sqsConsumer.ts":5150};function o(e){var t=i(e);return r(t)}function i(e){if(!r.o(n,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return n[e]}o.keys=function(){return Object.keys(n)},o.resolve=i,e.exports=o,o.id=2828},2977:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.patchRoute=function(e){const t=(0,g.getMethods)();t.concat("all").forEach(function(r){const n=e.prototype[r];e.prototype[r]=function(){let e;try{e=p(Array.prototype.slice.call(arguments));let n=function(e){const t=e[0][a.hudConfig.express.layerStateSymbol];if(t)return t.flowId}(e);const o=function(e){const t=e[0][a.hudConfig.express.layerStateSymbol];if(t)return t.kind}(e),i=function(e){const t=e[0][a.hudConfig.express.layerStateSymbol];return!!t&&t.allMethod}(e);if(n||(n=[l.randomUUID()]),"application"===o)if(Array.isArray(this.path)){y(e,void 0);for(let e=0;e<this.path.length;e++)h(n[e],i?t:[r],this.path[e])}else y(e,n[0]),h(n[0],i?t:[r],this.path);else if("router"===o)if(Array.isArray(this.path)){y(e,void 0);for(let e=0;e<this.path.length;e++)m(this,n[e],r,this.path[e])}else y(e,n[0]),m(this,n[0],r,this.path);else y(e,n[0]),m(this,n[0],r,this.path)}catch(e){d.instrument_logger.error("Failed to patch express.Route.route",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n.apply(this,e||arguments)}})};const a=r(5809),u=r(8528),c=r(8269),d=r(523),l=s(r(6982)),f=r(8949),g=r(6730),p=r(5673);function m(e,t,r,n){!function(e,t,r,n){e[a.hudConfig.express.layerStateSymbol]||(e[a.hudConfig.express.layerStateSymbol]={}),e[a.hudConfig.express.layerStateSymbol][t]?e[a.hudConfig.express.layerStateSymbol][t].methods.push(r):e[a.hudConfig.express.layerStateSymbol][t]={layerPath:n,methods:[r]}}(e,t,r,n),function(e,t,r){const n=new u.EndpointDeclaration(e,[t],"express",void 0,void 0,r);(0,c.storePartialEndpointDeclaration)(n),(0,c.storeExpressEndpointDeclaration)(n)}(t,r,n)}function h(e,t,r){const n=new u.EndpointDeclaration(e,t,"express",void 0,r,void 0);(0,c.storeExpressEndpointDeclaration)(n)}function y(e,t){if(e&&!(e.length<1)){if(a.hudConfig.express.wrapAllCallbacks)for(let r=0;r<e.length;r++){const n=(0,f.wrapFlow)(_(t),e[r],!0);e[r]=n}else{const r=(0,f.wrapFlow)(_(t),e[e.length-1],!0);e[e.length-1]=r}return t}}function b(e){return(0,c.getLinkedConsistentFlowId)(e,!1)||(d.instrument_logger.warning("No consistent flowId found, returning temporary flow id",{flowId:e}),e)}function _(e){return e?function(){return b(e)}:function(e,t){const r=t[0]?.route[a.hudConfig.express.layerStateSymbol],n=t[0]?.url;if(r)for(const[e,t]of Object.entries(r)){if(t.layerPath instanceof RegExp&&t.layerPath.test(n))return b(e);if(n.includes(t.layerPath))return b(e)}d.instrument_logger.warning("No flowId found for path",{states:r,url:n.split("?")[0]})}}},2987:e=>{"use strict";e.exports=require("perf_hooks")},3073:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.registerStackHooks=function(){const e=(0,n.getAsyncHook)();if(e)return e.enable(),e;(0,o.setHudExecutionAsyncResource)(i.executionAsyncResource);const t=(0,i.createHook)({init:a});return t.enable(),(0,n.setAsyncHook)(t),t};const n=r(8269),o=r(7131),i=r(290),s=["Timeout","Immediate","TickObject","PROMISE","Microtask"];function a(e,t,r,n){if(!s.includes(t))return void(n[o.kHudCaller]="");const a=(0,i.executionAsyncResource)();if(void 0===a)return;if(void 0!==a[o.kHudCaller])return void(n[o.kHudCaller]=a[o.kHudCaller]);const u=globalThis.hudStack[globalThis.hudStackIndex.value];n[o.kHudCaller]=u,globalThis.hudStackPop&&(globalThis.hudStackPop=!1,globalThis.hudStackIndex.value--)}},3176:e=>{"use strict";e.exports=require("buffer-crc32")},3339:e=>{"use strict";e.exports=require("module")},3868:e=>{"use strict";e.exports=require("@jridgewell/sourcemap-codec")},3901:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.destructuredImportObj=t.defaultImportObj=void 0,t.getFunctionWrapperTemplate=S,t.splitCode=I,t.getEsbuildMark=P,t.getBundlerBuildIdForMarkedFile=T,t.editInSplits=j,t.appendCiBuildId=A,t.editWithCliBuildId=function(e,t,r,n){let{transformedCode:o,metadatas:i}=L(e,t,r,[],!0);return o+=`\n//# sourceMappingURL=${_.default.basename(t)}.map`,o=A(o,n),{transformedCode:o,metadatas:i}},t.edit=L,t.incrementInstrumentedFunctionsCount=H;const u=a(r(3176)),c=r(3903),d=r(5809),l=r(2546),f=r(523),g=r(8528),p=r(8269),m=r(2546),h=r(7131),y=r(3868),b=s(r(2784)),_=a(r(6928)),v=/([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/;function k(){return d.SDK_MODULE_NAME+"/wrap"}function C(e,t){return`\n ${d.hudConfig.internalAsyncWrapperFunctionName}(\n ${e} ${d.hudConfig.internalAsyncWrapperFunctionName}(\n ${t}, ${d.hudConfig.callContextVarName}, ${(0,h.getWrapperTypeFromPrefix)(e,!0)}\n ),\n ${d.hudConfig.callContextVarName},\n ${(0,h.getWrapperTypeFromPrefix)(e,!1)}\n )\n `}function w(e){return"true"===process.env.HUD_DO_NOT_WRAP_WITH_TRY_CATCH?e:`\n try {\n ${e}\n } catch {}\n `}function S(e,r,n=!1,o=!1,i=!1){const s="BODY_PLACEHOLDER",a="FUNCTION_ID_PLACEHOLDER",u="AWAITABLE_PLACEHOLDER",c="EXCEPTION_VARIABLE_PLACEHOLDER",l="ARGS_ARRAY_PLACEHOLDER",f=function(e,r,n=!1,o=!1){const i=[];if(n)return i;let s;r===g.Format.cjs?s="require":r===g.Format.esm&&(i.push(`import { createRequire as ${e}_createRequire } from "module";`,`const ${e}_require = ${e}_createRequire(import.meta.url);`),s=`${e}_require`);const a=o?`"${k()}"`:`String.raw\`${m.myRequire.resolve(k())}\``;return i.push(`let ${e}_temp = ${t.defaultImportObj};`,`try {\n let ${e}_module = ${s}(${a});\n const ${e}_assert = (x) => {\n if (!x) {\n throw new Error();\n }\n };\n ${e}_assert(${e}_module._hudVersion === "${d.SDK_VERSION}");\n Object.keys(${e}_temp).forEach((key) => {\n ${e}_assert(typeof ${e}_temp[key] === typeof ${e}_module[key]);\n }); \n ${e}_assert(typeof ${e}_module.asyncIteratorWrapper === "function");\n ${e}_temp = ${e}_module;\n } catch {}`,`const ${t.destructuredImportObj} = ${e}_temp;`),i}(e,r,n,i),p=o?", true":"";return{functionWrapper:`{\n let ${d.hudConfig.callContextVarName}; \n const ${d.hudConfig.internalAsyncWrapperFunctionName} = (x, y, z) => {\n ${w(`${d.hudConfig.asyncWrapperFunctionName}(y, z);`)}\n return x;\n };\n \n ${w(`${d.hudConfig.callContextVarName} = ${d.hudConfig.functionInitFunctionName}(${a} ${p});`)}\n\n try {\n ${s}\n } catch (e) {\n ${w(`${d.hudConfig.functionCatchFunctionName}(e, ${d.hudConfig.callContextVarName}, ${l});`)}\n throw e;\n } finally {\n ${w(`${d.hudConfig.functionFinallyFunctionName}(${d.hudConfig.callContextVarName});`)}\n }\n }`,awaitWrapper:`(\n ${C("await",u)}\n )`,yieldWrapper:`\n function* ${e}_generatorWrapper() {\n return (\n ${C("yield",u)}\n )\n }`,yieldStarWrapper:`\n function* ${e}_generatorWrapper() {\n return (\n ${C("yield*",u)}\n )\n }`,initialStatements:f,bodyPlaceholder:s,functionIdPlaceholder:a,awaitablePlaceholder:u,argsArrayPlaceholder:l,fixStackFunction:`\n try {\n ${d.hudConfig.fixStackFunctionName}(${d.hudConfig.callContextVarName})\n } catch {}`,exceptionVariablePlaceholder:c,wrapperUserCatch:w(`${d.hudConfig.wrapperUserCatchFunctionName}(${c}, ${d.hudConfig.callContextVarName}, ${l});`),asyncIteratorWrapper:`${d.hudConfig.asyncIteratorWrapperFunctionName}`}}function x(e,t,r,n,o,i,s){const a=Error.prepareStackTrace;let l=!1,g=function(e){const t=e.match(`${d.hudConfig.bundlerBuildIdVarName}="${v.source}"`);if(t&&t.length>0)return t[1]}(e);g||(g=function(e){return(0,c.v5)(e,d.hudConfig.bundlerBuildUuidNamespace)}(e),l=!0);const p=(0,c.v5)(e,d.hudConfig.functionUuidNamespace),h=(0,u.default)(t.filename).readUInt32BE(),y=(0,u.default)(e).readUInt32BE(),_=(0,m.isNextJsApp)(),k=d.hudConfig.userConfig.enableVarHoisting?.value??!1,C={data:t,bundlerBuildId:g,prefix:d.hudConfig.wrapVarPrefix,...S(d.hudConfig.wrapVarPrefix,t.format,o,r.length>0,i),uuidNamespace:d.hudConfig.functionUuidNamespace,fileHash:p,functionsToInstrument:r,useInputSourcemap:n,isNextJsFile:_,markCode:d.hudConfig.nextJsMarkVarName,enableForAwaitInstrumentation:!i,enableVarHoisting:k,disableParametersExtraction:d.hudConfig.userConfig.disableParametersExtraction?.value??!1,functionIdVar:s?d.hudConfig.esbuildFunctionIdVar:void 0,instrumentOneLiners:d.hudConfig.userConfig.instrumentOneLiners?.value??!0};let w;try{w=b.transform(e,C)}catch(e){throw e instanceof Error&&e.message.includes("Conflicting vars detected")&&f.instrument_logger.error("Conflicting vars detected",{filename:t.filename}),e}return H(w.functionsIds.length,i),w.detectedVarConflicts>0&&f.instrument_logger.warning("Variable conflicts detected during transformation",{filename:t.filename,conflictCount:w.detectedVarConflicts,varHoistingEnabled:k}),_&&w.marksCount!==w.functionsIds.length&&f.instrument_logger.warning("Marks count mismatch while instrumenting functions",{marksCount:w.marksCount,functionsIdsLength:w.functionsIds.length,filename:t.filename}),Error.prepareStackTrace=a,f.instrument_logger.debug(`Successfully transformed ${t.filename}`),{code:w.code,map:w.map,functionIds:w.functionsIds,totalFunctionsCountIncludeUninstrumented:w.totalFunctionsCountIncludeUninstrumented,filename:t.filename,hasInputMap:w.isInputSourcemap,bundlerBuildId:g,bundlerBuildIdGenerated:l,file_path_checksum:h,file_checksum:y,sourceCodeHash:p,moduleBase:w.moduleBase,isNextJsApp:_,marksCount:w.marksCount,detectedForAwaitLoops:w.detectedForAwaitLoops,detectedVarConflicts:w.detectedVarConflicts,failedToRemoveFunctionIdCount:w.failedToRemoveFunctionIdCount,functionsWithMultipleFunctionIdMarks:w.functionsWithMultipleFunctionIdMarks}}t.defaultImportObj="\n {\n wrapperInitial: () => {\n return {};\n },\n wrapperCatch: () => {},\n wrapperFinally: () => {},\n fixStack: () => {},\n wrapperUserCatch: () => {},\n asyncWrapper: (x) => x,\n }\n",t.destructuredImportObj=`\n {\n wrapperInitial: ${d.hudConfig.functionInitFunctionName},\n wrapperCatch: ${d.hudConfig.functionCatchFunctionName},\n wrapperFinally: ${d.hudConfig.functionFinallyFunctionName},\n fixStack: ${d.hudConfig.fixStackFunctionName},\n asyncIteratorWrapper: ${d.hudConfig.asyncIteratorWrapperFunctionName},\n wrapperUserCatch: ${d.hudConfig.wrapperUserCatchFunctionName},\n asyncWrapper: ${d.hudConfig.asyncWrapperFunctionName},\n }\n`;class E extends Error{}function O(e,t){if(e&&t)throw new E("Start mark found inside mark");if(!e&&!t)throw new E("End mark found outside mark")}function M(e,t,r,n){const o=e.split("\n");let i=r,s=n;return i+=o.length-1,i+=t.split("\n").length-1,i===r?s+=o.pop()?.length||0:s=o.pop()?.length||0,{lineOffset:i,columnOffset:s}}function*I(e){let t=!1,r=0,n=0,o=!1,i=0,s=0;const a=new RegExp(`globalThis\\s*?&&\\s*?\\(globalThis\\.${d.hudConfig.esbuildGlobalVar}\\s*?=\\s*?"(Start|End):(?<fileName>.*?):(?<fileHash>.*?)"\\);?`,"g");let u="",c="";for(const d of e.matchAll(a)){if(o=!0,!d.groups)throw new E("No groups found in match");const[a,l]=d,f="Start"===l;O(f,t);let g="";if(t){const t=d.index+a.length;g=e.slice(r,t);const o=n+Buffer.byteLength(g,"utf8"),l=Number(c);yield{edit:!0,code:g,fileName:u,fileChecksum:isNaN(l)?void 0:l,lineOffset:i,columnOffset:s,indexOffset:n,indexOffsetEnd:o},r=t,n=o}else{u=d.groups?.fileName,c=d.groups?.fileHash;const t=d.index;g=e.slice(r,t),n+=Buffer.byteLength(g,"utf8"),r=t,yield{edit:!1,code:g}}t=!!f,({lineOffset:i,columnOffset:s}=M(g,a,i,s))}if(t)throw new E("End mark found outside mark");o?r<e.length&&(yield{edit:!1,code:e.slice(r)}):yield{edit:!1,code:e}}function P(e){const t=e.trim().slice(-d.hudConfig.esbuildMarkLength);if(t.startsWith("/*"+d.hudConfig.esbuildMark))return t}function T(e){const t=P(e);if(t)return t.slice(2+d.hudConfig.esbuildMark.length,2+d.hudConfig.esbuildMark.length+36)}function F(e,t,r){f.instrument_logger.debug("Edit chunk",{fileName:e.fileName,size:e.code.length,edit:t}),r?.push({fileName:e.fileName,size:e.code.length,edit:t})}function N(e,t,r,n){const o=x(e.code,{filename:t,format:r},[],!1,!0,n,!0),i=o.code;return o.mapRelativeToChunk=o.map,o.map=function(e,t,r){"string"==typeof e&&(e=JSON.parse(e));const n=(0,y.decode)(e.mappings);return n.forEach(e=>{e.forEach(e=>{e.length>=4&&"number"==typeof e[2]&&("number"==typeof e[3]&&0===e[2]&&(e[3]+=r),e[2]+=t)})}),JSON.stringify({...e,mappings:(0,y.encode)(n),sourcesContent:void 0})}(o.map,e.lineOffset,e.columnOffset),{codeToAppend:i,metadata:{...o,filename:t,lineOffset:e.lineOffset,columnOffset:e.columnOffset}}}function j(e,t,r,n=!1,o=!1,i=!1,s=()=>!0){const a=e.slice(-1e3);if(!o&&null!==b.getSourceMap(t,a))return f.instrument_logger.error("Source map found for esbuild split",{filename:t}),f.customer_logger.logEntry(l.UserErrorLogs.EsbuildSourceMapFound()),(0,p.detachHud)(!1,!1),{transformedCode:e,metadatas:[],editedChunksSizes:void 0};let c="",g=0,m=0;const h=[];let y=0;const _=n?[]:void 0,v=S(d.hudConfig.wrapVarPrefix,r,!1,!1,i).initialStatements.join("\n"),k=T(e);for(const n of I(e)){y++;try{let e="",o=!1;if(n.edit&&(o=s(n.fileName),_&&F(n,o,_)),n.edit&&o){const o=N(n,t,r,i);e=o.codeToAppend,h.push({...o.metadata,prebundle_file_checksum:n.fileChecksum,file_path_checksum:(0,u.default)(n.fileName).readUInt32BE(),bundlerBuildId:k??o.metadata.bundlerBuildId,transformedLineOffset:g,transformedColumnOffset:m,indexOffset:n.indexOffset,indexOffsetEnd:n.indexOffsetEnd})}else e=0===c.length?R(n.code,v):n.code;({transformedCodeLineOffset:g,transformedCodeColumnOffset:m}=D(e,g,m)),c+=e}catch(r){return f.instrument_logger.error("Failed to patch index",{index:y,filename:t,msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),{transformedCode:e,metadatas:[],editedChunksSizes:_}}}return{transformedCode:c,metadatas:h,editedChunksSizes:_}}function R(e,t){let r="";return e.startsWith('"use strict";')?(r+='"use strict";',r+=t,r+=e.slice(13),r):(r+=t,r+=e,r)}function D(e,t,r){const n=e.split("\n");return n.length>1?(t+=n.length-1,r=n.pop()?.length||0):r+=e.length,{transformedCodeLineOffset:t,transformedCodeColumnOffset:r}}function A(e,t){return e+`\n//"${t}";${d.hudConfig.cliSdkVersionVarName}="${d.SDK_VERSION}";${d.hudConfig.cliBuildIdVarName}`}function L(e,t,r,n,o){if(P(e))return f.instrument_logger.info("Editing in splits"),j(e,t,r,!1,void 0,o);{const i=x(e,{filename:t,format:r},n,d.hudConfig.userConfig.disableSourceMapsResolution?.value??!0,!1,o,!1);return{transformedCode:i.code,metadatas:[i]}}}let q=0;function H(e,t){q+=e;const r=d.hudConfig.userConfig?.maxMappedFunctions?.value??0;q>=r&&(t||f.customer_logger.logEntry(l.UserErrorLogs.InstrumentedFunctionCountExceeded(r)),f.app_logger.error("Instrumented function count exceeded",{instrumentedFunctionsCount:q,maxMappedFunctions:r}),(0,p.detachHud)(!1,!1))}},3903:e=>{"use strict";e.exports=require("uuid")},4290:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(8949),i=r(5128),s=r(714);class a extends s.FrameworkPatcher{_patch(e){return this._patchCreate(e),n.instrument_logger.info("Patched NestJS RpcContextCreator successfully"),e}_patchCreate(e){const t=e.RpcContextCreator.prototype.create;e.RpcContextCreator.prototype.create=function(...e){try{const t=e[0],r=e[1];"function"==typeof t.constructor&&"function"==typeof r?e[1]=(0,i.wrapLinkedFunction)(r):n.instrument_logger.error("Invalid args in NestJS RpcContextCreator.create",{args:e})}catch(e){n.instrument_logger.error("Error in NestJS RpcContextCreator patcher",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,e)},(0,o.copyPropertiesToTarget)(t,e.RpcContextCreator.prototype.create)}}t.default=a},4349:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(8949),c=r(9938);class d extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching request"),e=this._patchRequest(e),this._patchMethods(e),this._createRequestDeclaration(),n.instrument_logger.info("Patched request successfully"),e}_patchRequest(e){return(0,c.wrapOutboundFunction)(e,i.hudConfig.requestFunctionId,l,f,s.OutboundType.HTTP,!0)}_patchMethods(e){for(const[t,r]of Object.entries(i.hudConfig.requestMethodFunctionIds)){const n=e[t];e[t]=(0,c.wrapOutboundFunction)(n,r,(e,r,n)=>l(e,r,n,t),f,s.OutboundType.HTTP,!0)}}_createRequestDeclaration(){(0,a.storeLoadedOutbound)("request")}}function l(e,t,r,o){const i=function(e,t,r){const o=function(e){return"function"==typeof e[1]?{callback:e[1],setCallback:(e,t)=>{e[1]=t}}:"function"==typeof e[2]?{callback:e[2],setCallback:(e,t)=>{e[2]=t}}:null!==e[1]&&"object"==typeof e[1]?{callback:e[1].callback,setCallback:(e,t)=>{e[1].callback=t}}:null!==e[0]&&"object"==typeof e[0]?{callback:e[0].callback,setCallback:(e,t)=>{e[0].callback=t}}:void 0}(e);if(void 0===o)return(0,n.limitedLogger)("Request callback not found - outbound won't closed"),!1;const i=o.callback,s=function(e,n,o){try{null!=e?e instanceof AggregateError&&e.errors.length>0?t(e.errors[0]):t(e):r({response:n,body:o})}catch{}i(e,n,o)};return(0,u.copyPropertiesToTarget)(i,s),o.setCallback(e,s),!0}(e,t,r),s=function(e,t,r){"function"==typeof t&&(r=t);let n={};return n=null!==t&&"object"==typeof t?{...t,uri:e}:"string"==typeof e?{uri:e}:{...e},n.callback=r||n.callback,n}(e[0],e[1],e[2]);return{url:s.url??s.uri,method:o??s.method?.toLowerCase()??"get",body:s.form,...i?{}:{hasCallback:!1}}}function f(e,t,r){(0,c.reduceRequestArgsIfNeeded)(e,r,e=>Number.parseInt(e?.response?.request?.getHeader("content-length")));const n=Number.parseInt(e.response.headers["content-length"]),o=isNaN(n)||0===n?void 0:n;return{status_code:e.response.statusCode,bodySize:o,body:(0,c.getReducedBody)(e.body,o,i.hudConfig.dynamicConfig.maxHTTPResponseBodySize)}}t.default=d},4393:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HttpEndpointMetric=t.ApiProtocol=void 0;const n=r(9873);var o;!function(e){e.REST="rest",e.GraphQL="graphql"}(o||(t.ApiProtocol=o={}));class i extends n.FlowMetric{statusCode;apiProtocol;apiProtocolAttributes;error;constructor(e){super(e)}_createUsableMetric(e){return this}setRequestAttributes(e){this.apiProtocol=o.REST,this.apiProtocolAttributes={method:e.method}}setGraphQLAttributes(e,t){this.apiProtocol=o.GraphQL,this.apiProtocolAttributes={errorOccurred:e,errors:t}}setResponseAttributes(e){this.statusCode=e.statusCode}setUserError(e){this.error=e}toRaw(){if(!this.statusCode)return;if(this.apiProtocol===o.GraphQL){const e=this.apiProtocolAttributes;return{flow_id:this.flowId,type:"GraphQLMetric",duration:this.duration,status_code:this.statusCode,error_occurred:e.errorOccurred,error_breakdown:this.errorBreakdown}}if(this.apiProtocol!==o.REST)return;const e=this.apiProtocolAttributes;return e.method?{flow_id:this.flowId,type:"EndpointMetric",duration:this.duration,status_code:this.statusCode,method:e.method,error_breakdown:this.errorBreakdown,error:this.error}:void 0}}t.HttpEndpointMetric=i},4815:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.patchUse=function(e,t,r=!0){const n=e.use;e.use=function(e){const o=n.apply(this,arguments);try{let n=this[f.uuidSymbol];!n&&f.isVerboseLoggingEnabled&&(n=d.randomUUID(),this[f.uuidSymbol]=n,c.instrument_logger.info("Express use setting uuid",{kind:t,uuid:n})),"application"===t?function(e,t,r,n){try{r&&(e._router?p(e._router):e.router?p(e.router):c.instrument_logger.warning("Express application doesn't have router or _router")),n&&f.isVerboseLoggingEnabled&&c.instrument_logger.info("Express use app",{parent:n,child:t[1]?.[f.uuidSymbol]||"no uuid",path:t[0]})}catch(e){c.instrument_logger.error("Failed to save express app router",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(this,arguments,r,n):"router"===t&&function(e,t,r,n,o){try{if(!e.stack)return void c.instrument_logger.error("Express router without stack");if(0===e.stack.length)return void c.instrument_logger.warning("Express router with an empty stack");"query"===e.stack[0].name?p(e):f.isVerboseLoggingEnabled&&!f.skipLayerNamesLogs.has(e.stack[0].name)&&(f.skipLayerNamesLogs.add(e.stack[0].name),c.instrument_logger.warning("Found unknown stack name",{stack:e.stack[0].name}));const{path:i,offset:s}=function(e){let t=0,r="/";if("function"!=typeof e){let n=e;for(;Array.isArray(n)&&0!==n.length;)n=n[0];"function"!=typeof n&&(t=1,r=e)}return{path:r,offset:t}}(o),u=g(Array.prototype.slice.call(t,s));for(let t=0;t<u.length&&t<e.stack.length;t++){const o=e.stack[e.stack.length-t-1],s=u[u.length-t-1];"router"===o.name?(s&&!s[f.uuidSymbol]&&f.isVerboseLoggingEnabled&&(s[f.uuidSymbol]=d.randomUUID(),c.instrument_logger.info("Express handle router setting uuid",{uuid:s[f.uuidSymbol]})),r&&(o[a.hudConfig.express.routeNamesSymbol]=i)):f.isVerboseLoggingEnabled&&!f.skipLayerNamesLogs.has(o.name)&&(f.skipLayerNamesLogs.add(o.name),c.instrument_logger.warning("Found unknown layer name",{layer:o.name,parent:n,child:s[f.uuidSymbol]||"no uuid",path:i}))}}catch(e){c.instrument_logger.error("Failed to patch router.use function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}(this,arguments,r,n,e)}catch(e){c.instrument_logger.error("Failed to patch express.use function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return o},(0,l.copyPropertiesToTarget)(n,e.use)},t.extractEndpointsFromRouter=function e(t,r){let n=[];if(!r.stack)return c.instrument_logger.error("Router without stack - bad OTEL version",{router:r}),n;for(const o of r.stack)if("router"===o.name){if(!o[a.hudConfig.express.routeNamesSymbol]){c.instrument_logger.error("Router layer without routes",{layer:o});continue}const r=t+o[a.hudConfig.express.routeNamesSymbol];n=n.concat(e(r,o.handle))}else o.route&&o.route[a.hudConfig.express.layerStateSymbol]?n=n.concat(m(o,t)):f.isVerboseLoggingEnabled&&!f.skipLayerNamesLogs.has(o.name)&&(f.skipLayerNamesLogs.add(o.name),c.instrument_logger.warning("Found unknown layer name when extracting endpoints",{layer:o.name}));return n};const a=r(5809),u=r(8528),c=r(523),d=s(r(6982)),l=r(8949),f=r(7225),g=r(5673);function p(e){e[a.hudConfig.express.markedSymbol]||(globalThis.hudExpressState.push(e),e[a.hudConfig.express.markedSymbol]=!0)}function m(e,t){const r=[];for(const[n,o]of Object.entries(e.route[a.hudConfig.express.layerStateSymbol]))r.push(new u.EndpointDeclaration(n,o.methods,"express",t,o.layerPath));return Array.from(r.values())}},4986:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(6698),s=r(8949),a=r(714);class u extends a.FrameworkPatcher{_patch(e){return e=this._patchPlimit(e),n.instrument_logger.info("Patched p-limit successfully"),e}_patchPlimit(e){if("function"!=typeof e)return n.instrument_logger.error("p-limit is not a function"),e;const t=e,r=function(...e){const r=t.apply(this,e);try{return function(e){const t=function(...t){try{if(void 0!==globalThis.hudStackIndex&&void 0!==globalThis.hudStackIndex.value&&void 0!==globalThis.hudStack&&t.length>0&&"function"==typeof t[0]){const e=(0,i.executionAsyncResource)()[o.kHudCaller]??globalThis.hudStack[globalThis.hudStackIndex.value];t[0]=function(e,t){const r=function(...r){try{const e=(0,i.executionAsyncResource)();e&&(e[o.kHudCaller]=t)}catch{(0,n.limitedLogger)("patchedArgs0 failed")}return e.apply(this,r)};return(0,s.copyPropertiesToTarget)(e,r),r}(t[0],e)}}catch{(0,n.limitedLogger)("patchedLimiter failed")}return e.apply(this,t)};return(0,s.copyPropertiesToTarget)(e,t),t}(r)}catch{return(0,n.limitedLogger)("patchedPLimit failed"),r}};return(0,s.copyPropertiesToTarget)(t,r),r}}t.default=u},5128:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isHudLfMarked=void 0,t.wrapLinkedFunction=function(e){if(e[t.isHudLfMarked])return e;let r;e[t.isHudLfMarked]=!0;const a=(0,i.getFlowStateStorage)();return a?(r=e instanceof s.AsyncFunction?async function(...t){if(hudRunningMode!==n.HudRunningMode.enabled)return await e.apply(this,t);let r;try{r=a.getStore()}catch(r){return o.instrument_logger.error("Failed to get flowState",{msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),await e.apply(this,t)}return r?(r.shouldLinkFunction=!0,await e.apply(this,t)):await e.apply(this,t)}:function(...t){if(hudRunningMode!==n.HudRunningMode.enabled)return e.apply(this,t);let r;try{r=a.getStore()}catch(r){return o.instrument_logger.error("Failed to get flowState",{msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0}),e.apply(this,t)}return r?(r.shouldLinkFunction=!0,e.apply(this,t)):e.apply(this,t)},(0,s.copyPropertiesToTarget)(e,r),r):e};const n=r(8528),o=r(523),i=r(7131),s=r(8949);t.isHudLfMarked=Symbol.for("isHudLfMarked")},5150:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0});const a=r(5809),u=r(8269),c=r(2546),d=r(523),l=r(7131),f=s(r(6982)),g=s(r(6928)),p=r(2822),m=r(8949),h=r(2080),y=r(714);class b extends y.FrameworkPatcher{isSupported(e,t,r,n){if(!n?.isMondayVersion)return super.isSupported(e,t,r,n);if(!a.hudConfig.userConfig.enableDapulse?.value)return d.instrument_logger.warning("monday-sqs-consumer detected but enableDapulse flag is not set — skipping patch",{basedir:e}),!1;const o=(0,y.extractModuleVersion)(e);if(!(0,y.isSupportedVersion)(o,r))return d.instrument_logger.warning("Unsupported monday-sqs-consumer version",{framework:t,version:o,basedir:e}),d.customer_logger.logEntry(c.UserErrorLogs.UnsupportedFrameworkVersion(t)),!1;const i=n.srcHash,{combined:s,perFile:u}=function(e){try{const t=f.createHash("sha256"),r={};for(const n of _){const o=c.suppressTracesFS.readFileSync(g.join(e,n));r[n]=f.createHash("sha256").update(o).digest("hex"),t.update(o)}return{combined:t.digest("hex"),perFile:r}}catch(e){return d.instrument_logger.warning("Failed to compute monday-sqs-consumer hash — one or more source files not found or unreadable",{srcFiles:_,msg:e instanceof Error?e.message:void 0}),{combined:"",perFile:{}}}}(e);return""!==s&&s===i||(d.instrument_logger.warning("monday-sqs-consumer hash mismatch — skipping patch",{basedir:e,version:o,actualHash:s,expectedHash:i,perFileHashes:u}),!1)}_patch(e){return function(e){const t=e.Consumer.create;e.Consumer.create=function(...e){const r=t.apply(this,e);try{!function(e){const t=e.queueUrl;if(!t)throw new c.HudNoQueueUrlInSqsConsumer;const r=C(t);if(e.handleMessageBatch&&"function"==typeof e.handleMessageBatch){const t="handleMessageBatch",n=(0,c.generateSqsFlowId)(r,t);(0,u.storeSqsQueueDeclaration)({flow_id:n,queue_name:r,handle_type:t,batch_size:e.batchSize});const o=e.handleMessageBatch,i=(0,m.wrapFlow)(()=>n,o,!0,w);return void(e.handleMessageBatch=i)}if(e.handleMessage&&"function"==typeof e.handleMessage){const t="handleMessage",n=(0,c.generateSqsFlowId)(r,t);(0,u.storeSqsQueueDeclaration)({flow_id:n,queue_name:r,handle_type:t});const o=e.handleMessage,i=(0,m.wrapFlow)(()=>n,o,!0,w);return void(e.handleMessage=i)}d.instrument_logger.warning("Unable to getFlowId - No handleMessage or handleMessageBatch found in SqsConsumer.Consumer",{queueName:r})}(r),function(e){const t=e.on;e.on=function(...r){try{const t=r[0];if(!t||"string"!=typeof t)throw new c.HudNoEventTypeInSqsConsumerOn;const n=r[1];if(!n||"function"!=typeof n)throw new c.HudNoCallbackInSqsConsumerOn;const o=C(e.queueUrl),i="event",s=(0,c.generateSqsFlowId)(o,i,t);(0,u.storeSqsQueueDeclaration)({flow_id:s,queue_name:o,handle_type:i,event_type:t}),r[1]=(0,m.wrapFlow)(()=>s,n,!0,S,x,E)}catch(e){d.instrument_logger.error("Error in SqsConsumer.Consumer.on patched logic",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,r)},(0,m.copyPropertiesToTarget)(t,e.on)}(r),function(e){const t=e.emit;e.emit=function(...e){return function(e){try{const t=e[0];if(!t||"string"!=typeof t)throw new c.HudNoEventTypeInSqsConsumerEmit;let r,n;if("message_processed"===t&&(r=1),["error","timeout_error","processing_error"].includes(t)&&(n=1,r=2),void 0===r)return;const o=e[r];if(!o)throw new c.HudNoMessageInSqsConsumerEmit;let i;if(void 0!==n){const t=e[n];if(!(t&&t instanceof Error))throw new c.HudNoErrorInSqsConsumerEmit;i=(0,l.extractName)(t),"StandardError"===i&&t.cause&&t.cause instanceof Error&&(i=(0,l.extractName)(t.cause))}const s=(e,t)=>{const r=e[a.hudConfig.metricSymbol];if(r){if(i&&r.addError(i,t),r.increaseAndShouldEnd(t)){r.calculateDuration();try{(0,p.finishSqsInvestigation)(Array.isArray(o)?o:[o],r)}catch(e){(0,d.limitedLogger)("Failed to finish sqs investigation",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}r.end()}}else k||(k=!0,d.instrument_logger.warning("No metric found for message"))};Array.isArray(o)&&o.length>=1?s(o[0],o.length):s(o,1)}catch(e){v||(v=!0,d.instrument_logger.error("Error in SqsConsumer.Consumer.emit patched logic",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0}))}}(e),t.apply(this,e)},(0,m.copyPropertiesToTarget)(t,e.emit)}(r)}catch(e){d.instrument_logger.error("Error in patching SqsConsumer.Consumer",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r},(0,m.copyPropertiesToTarget)(t,e.Consumer.create)}(e),d.instrument_logger.info("Patched sqs-consumer successfully",{isDapulse:a.hudConfig.userConfig.enableDapulse?.value}),e}}t.default=b;const _=[g.join("sqs-consumer","consumer.js"),g.join("sqs-consumer","bind.js"),g.join("sqs-consumer","errors","sqs.js"),g.join("sqs-consumer","errors","timeout.js")];let v=!1,k=!1;function C(e){const t=e.split("/").pop();if(!t)throw new c.HudFailExtractSqsQueueName(`Url: ${e}`);return t}function w(e,t,r){const n=h.SqsMetric.createUsableMetric(e);n.start();const o=r[0];if(!o)return d.instrument_logger.warning("No messages pass to sqs handler",{flowId:e}),void(t.flowMetric=n);if(Array.isArray(o)){if(n.msgCount=o.length,o.forEach(e=>{e[a.hudConfig.metricSymbol]=n}),o[0]?.Attributes?.SentTimestamp){const t=o.reduce((e,t)=>{const r=Number.parseInt(t?.Attributes?.SentTimestamp);return isNaN(r)?e:Math.min(e,r)},1/0);t!==1/0?n.e2eEpocStartTimeMS=t:d.instrument_logger.warning("No valid SentTimestamp found eventhough the first element had SentTimestamp",{flowId:e})}}else n.msgCount=1,o[a.hudConfig.metricSymbol]=n,o?.Attributes?.SentTimestamp&&(n.e2eEpocStartTimeMS=o.Attributes.SentTimestamp);t.flowMetric=n,(0,p.createNewInvestigation)()}function S(e,t,r){const n=h.SqsMetric.createUsableMetric(e);n.start(),t.flowMetric=n}function x(e,t){const r=t.flowMetric;r?r.end():d.instrument_logger.warning("No flowMetric found for message during catch",{flowId:e})}function E(e,t,r){const n=t.flowMetric;n?(n.addError((0,l.extractName)(r)),n.end()):d.instrument_logger.warning("No flowMetric found for message during catch",{flowId:e})}},5354:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(9938);class c extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching axios"),this._patchRequest(e),this._createAxiosDeclaration(),n.instrument_logger.info("Patched axios successfully"),e}_patchRequest(e){const t=e.Axios.prototype.request;e.Axios.prototype.request=(0,u.wrapOutboundFunction)(t,i.hudConfig.axiosFunctionId,e=>{const t=e[0];return{url:"string"==typeof t.url?t.url:void 0,method:t.method,body:t.data}},(e,t,r)=>{(0,u.reduceRequestArgsIfNeeded)(e,r,e=>Number.parseInt(e?.request?._contentLength));const n=Number.parseInt("function"==typeof e?.headers?.get?e?.headers?.get("content-length"):e?.headers["content-length"]),o=isNaN(n)||0===n?void 0:n;return{status_code:e.status,body:(0,u.getReducedBody)(e.data,o,i.hudConfig.dynamicConfig.maxHTTPResponseBodySize),bodySize:o}},s.OutboundType.HTTP)}_createAxiosDeclaration(){(0,a.storeLoadedOutbound)("axios")}}t.default=c},5459:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(7131),i=r(2822),s=r(8949),a=r(4393),u=r(714);class c extends u.FrameworkPatcher{_patch(e){return this._patchEmit(e),n.instrument_logger.info("Patched http successfully"),e}_patchEmit(e){const t=e.Server.prototype.emit;e.Server.prototype.emit=function(e,...r){if("request"!==e)return t.apply(this,[e,...r]);const u=(0,o.getFlowStateStorage)(),c=r?.[0],d=r?.[1],l=a.HttpEndpointMetric.createUsableMetric(),f={httpMetric:l},g=()=>{try{l.start(),(0,i.createNewInvestigation)(),l.setRequestAttributes(c),d.once("finish",function(){try{l.calculateDuration(),(0,i.finishHttpInvestigation)(c,d,l),l.setResponseAttributes(d),l.end()}catch(e){(0,n.limitedLogger)("Failed to set response attributes",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}),d.once("close",()=>{(0,i.clearInvestigationDataFromStorage)(),(0,s.clearFlowStateData)(f)})}catch(e){n.instrument_logger.error("Failed to patch http.Server.prototype.emit",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return t.apply(this,[e,...r])};return u?u.run(f,g):g()},(0,s.copyPropertiesToTarget)(t,e.Server.prototype.emit)}}t.default=c},5673:e=>{"use strict";e.exports=require("array-flatten")},5688:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hudRITM=void 0,t.safeLog=function(e){try{s.app_logger.debug(e)}catch{return}},t.registerHook=function(){if((0,o.initGlobals)(),s.app_logger.debug("InitGlobals done"),(0,a.registerStackHooks)(),s.app_logger.debug("registerStackHooks done"),(0,c.patchAllSetIntervalFunctions)(),s.app_logger.debug("patchAllSetIntervalFunctions done"),s.app_logger.info("HUD is required"),process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE){if(s.app_logger.info("Running in Lambda environment"),parseInt(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE)<n.hudConfig.lambdaMinimunMemory){const e=process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE;return s.app_logger.warning("Lambda function memory size is less than required, Hud will not run",{memorySize:e,requiredMemory:n.hudConfig.lambdaMinimunMemory}),s.customer_logger.logEntry(i.UserErrorLogs.UnsupportedLambdaMemory(n.hudConfig.lambdaMinimunMemory)),!1}globalThis.hudRuningInsideLambda=!0}return!(globalThis.hudStartFromAutoInit&&!(0,o.validateAndGetUserInput)())&&(globalThis.hudRanOnRequire?(s.instrument_logger.warning("Already ran onRequire!"),!1):(globalThis.hudRanOnRequire=!0,s.instrument_logger.info("Using module",{name:n.SDK_MODULE_NAME}),n.hudConfig.userConfig.enableFrameworks&&s.instrument_logger.info("User enabled frameworks",{frameworks:(0,u.getEnabledFrameworks)()}),(0,u.onRequire)(),(0,i.detectNextJsApp)(),s.instrument_logger.debug("onRequire done"),globalThis.hudInitGuard=setTimeout(d,n.hudConfig.userConfig.maxTimeUntilInitSessionMs?.value??0),globalThis.hudInitGuard.unref(),!0))};const n=r(5809),o=r(8269),i=r(2546),s=r(523),a=r(3073),u=r(7166),c=r(392);function d(){s.instrument_logger.critical("Init timeout reached - disabling hud"),s.customer_logger.logEntry(i.UserErrorLogs.InitTimeout(globalThis.hudIsRunningFromSetup)),(0,o.detachHud)(!1)}t.hudRITM=u.onRequireFn},5809:e=>{"use strict";e.exports=require("./config")},5946:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(6730),i=r(4815),s=r(714);class a extends s.FrameworkPatcher{_patch(e){return(0,i.patchUse)(e.prototype,"router"),(0,o.patchMethods)(e.prototype,"router"),n.instrument_logger.info("Patched router successfully"),e}}t.default=a},6093:e=>{"use strict";e.exports=require("@cspotcode/source-map-support")},6698:e=>{"use strict";e.exports=require("node:async_hooks")},6730:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.getMethods=f,t.patchMethods=function(e,t){f().concat("all").forEach(function(r){const n=e[r];if(!n)return void(l.isVerboseLoggingEnabled&&u.instrument_logger.warning("Method not found",{method:r}));const o="all"===r;e[r]=function(){try{if(arguments.length<2)return n.apply(this,arguments);let e=this[l.uuidSymbol];l.isVerboseLoggingEnabled&&(e||(e=c.randomUUID(),this[l.uuidSymbol]=e,u.instrument_logger.info("Express method setting uuid",{uuid:e,kind:t})),u.instrument_logger.info("Express added new method",{method:r,uuid:e,path:arguments[0]}));const i=Array.prototype.slice.call(arguments);if(i[1][a.hudConfig.express.layerStateSymbol]={flowId:[],kind:t,allMethod:o},Array.isArray(i[0]))for(const e of i[0]){const e=c.randomUUID();i[1][a.hudConfig.express.layerStateSymbol].flowId.push(e)}else i[1][a.hudConfig.express.layerStateSymbol].flowId.push(c.randomUUID());const s=n.apply(this,i);try{delete i[1][a.hudConfig.express.layerStateSymbol]}catch{}return s}catch(e){u.instrument_logger.error("Failed to patch method",{kind:t,method:r,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n.apply(this,arguments)},(0,d.copyPropertiesToTarget)(n,e[r])})};const a=r(5809),u=r(523),c=s(r(6982)),d=r(8949),l=r(7225);function f(){const e=r(8611);return e.METHODS&&e.METHODS.map(function(e){return e.toLowerCase()})||["get","post","put","head","delete","options","trace","copy","lock","mkcol","move","purge","propfind","proppatch","unlock","report","mkactivity","checkout","merge","m-search","notify","subscribe","unsubscribe","patch","search","connect"]}},6928:e=>{"use strict";e.exports=require("path")},6982:e=>{"use strict";e.exports=require("crypto")},7127:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(6730),i=r(2977),s=r(4815),a=r(7225),u=r(714);class c extends u.FrameworkPatcher{_patch(e){return(0,i.patchRoute)(e.Route),(0,s.patchUse)(e.application,"application"),(0,o.patchMethods)(e.application,"application"),a.isVerboseLoggingEnabled&&(0,a.logLazyRouter)(e.application),e.Router.use?((0,s.patchUse)(e.Router,"router"),(0,o.patchMethods)(e.Router,"router")):n.instrument_logger.warning("Skipping express.Router patching"),n.instrument_logger.info("Patched express successfully"),e}}t.default=c},7131:e=>{"use strict";e.exports=require("./wrap")},7166:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.parseCliInstrumentationPattern=w,t.supportSourceMapInstall=S,t.patch=O,t.patchCompile=T,t.onRequireFn=F,t.patchRequire=N,t.isFrameworkEnabled=j,t.getEnabledFrameworks=function(){const e=new Map;for(const[t,r]of g.hudConfig.frameworksToPatch)e.set(r.framework,j(r,g.hudConfig.userConfig.enableFrameworks));return Object.fromEntries(e)},t.getFunctionsToInstrument=q,t.createCheckers=H,t.updateModuleChecker=U,t.skip=$,t.onRequire=function(){try{(0,d.setInstrumentedFilesCountInterval)(),U();try{T()}catch(e){l.instrument_logger.error("Failed to patch compile",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{(0,d.shouldSupportSourceMap)()&&S()}catch(e){l.instrument_logger.error("Failed to install source map support",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{N()}catch(e){l.instrument_logger.error("Failed to patch require",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}catch(e){l.instrument_logger.error("Something went wrong in onRequire",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}try{(0,m.saveMachineMetric)()}catch(e){l.instrument_logger.error("Failed to add metric",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}};const a=r(2546),u=s(r(6928)),c=r(8528),d=r(2546),l=r(523),f=r(3901),g=r(5809),p=r(8528),m=r(8269),h=r(2546),y=r(9063),b=r(714),_=r(8949),v=function(){const e=g.SDK_MODULE_NAME;try{return u.dirname(u.dirname(h.myRequire.resolve(e)))}catch(t){return l.instrument_logger.error("Failed to resolve own path",{moduleName:e,msg:t instanceof Error?t.message:void 0,stack:t instanceof Error?t.stack:void 0}),null}}();function k(e){const t=globalThis.HudSourceMapCache.get(e);return t?{map:JSON.parse(t)}:null}const C=new RegExp(`//"([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})";${g.hudConfig.cliSdkVersionVarName}="([^"]+)";${g.hudConfig.cliBuildIdVarName}`);function w(e){if(e.slice(-g.hudConfig.cliBuildIdVarName.length)!==g.hudConfig.cliBuildIdVarName)return null;const t=Math.min(100,e.length),r=e.slice(-t).match(C);return r?{buildId:r[1],sdkVersion:r[2],fullPattern:r[0]}:null}function S(){r(6093).install({handleUncaughtExceptions:!1,hookRequire:!1,environment:"node",retrieveSourceMap:k})}let x=!1,E=!1;function O(e,t,r,n){const o={code:e,map:void 0};try{if(globalThis.hudRunningMode===p.HudRunningMode.detached)return o;if(r===c.Format.esm&&!n)throw new h.HudError("MessagePort is required for patching ESM modules");const i=w(e);if(i)return E||(E=!0,l.instrument_logger.info("CI instrumentation detected, skipping instrumentation",{filename:t,cliSdkVersion:i.sdkVersion,currentSdkVersion:g.SDK_VERSION})),i.sdkVersion!==g.SDK_VERSION?(l.instrument_logger.critical("SDK version mismatch detected, disabling SDK",{filename:t,cliSdkVersion:i.sdkVersion,currentSdkVersion:g.SDK_VERSION}),(0,m.detachHud)(!1,!1),o):((0,m.addReingestValue)(i.buildId),globalThis.hudInstrumentationIndicator&&(0,m.clearInstrumentationIndicator)(),o);if(g.hudConfig.userConfig.disableRuntimeInstrumentation?.value)return x||(x=!0,l.instrument_logger.info("Skipping instrumentation due to disableRuntimeInstrumentation")),o;const s=q(t);if($(t,void 0,r,s))return o;if(e.length>(g.hudConfig.userConfig.maxFileSizeBytes?.value??0)&&!e.startsWith(g.hudConfig.esbuildMark))return l.instrument_logger.info("Skipping large file",{filename:t,size:e.length}),o;const a=(0,f.edit)(e,t,r,s,!1),u=a.metadatas;if(o.code=a.transformedCode,o.map=u,n)for(const e of u)n.postMessage({key:"HudModulePatch",hudPatched:t,hudProcessedFiles:(0,d.sourceFileMetadataToTransferSourceFileMetadata)(e)});else globalThis.hudPatched.add(t),globalThis.hudProcessedFiles.push(...u.map(e=>(0,d.sourceFileMetadataToTransferSourceFileMetadata)(e)));for(const e of u)e.functionIds.length>0&&(globalThis.hudInstrumentationOccured=!0,globalThis.hudInstrumentationIndicator&&(0,m.clearInstrumentationIndicator)());g.hudConfig.writePatched&&(R(t,a.transformedCode),a.metadatas&&R(t+".map",JSON.stringify(JSON.parse(a.metadatas[0].map),null,2)))}catch(e){l.instrument_logger.error("Failed to patch",{filename:t,format:r,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return o}let M="",I=!0,P=!1;function T(){if(!(0,h.isSupportedNative)())return;const e=r(3339),t=(0,d.shouldSupportSourceMap)();P&&l.instrument_logger.warning("PatchCompile ran twice"),0===Object.keys(globalThis.hudLoadedModules).length&&(globalThis.hudLoadedModules=Object.keys(h.myRequire.cache));const n=e.prototype._compile;e.prototype._compile=function(e,r,...o){const i=process.hrtime.bigint();let s=0,a=0,u=0,f=!1;try{if(r===M){try{const e=I?l.instrument_logger.warning.bind(l.instrument_logger):l.instrument_logger.debug.bind(l.instrument_logger);I=!1,e("Skipping compile since already ran",{filename:r})}catch{}const t=process.hrtime.bigint(),i=n.call(this,e,r,...o);return s=Number(process.hrtime.bigint()-t),i}M=r,l.instrument_logger.debug("Compiling requirement",{filename:r});const i=O(e,r,o[0]?o[0]:c.Format.cjs);i.map&&(f=!0),a=i.map?.reduce((e,t)=>e+t.functionIds.length,0)??0,u=i.map?.reduce((e,t)=>e+t.totalFunctionsCountIncludeUninstrumented,0)??0;try{if(t&&i.map){const e=(0,d.combineSourceMaps)(i.map,r);e&&globalThis.HudSourceMapCache.set(r,e)}}catch(e){l.instrument_logger.error("Failed to combine source maps",{filename:r,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const g=process.hrtime.bigint(),p=n.call(this,i.code,r,...o);return s=Number(process.hrtime.bigint()-g),M="",p}finally{const t=Number(process.hrtime.bigint()-i)-s;f&&l.instrument_logger.debug("Patched",{filename:r,time:t}),(0,d.incrementInstrumentedStats)(f,t,s,e.length,a,u)}},(0,_.copyPropertiesToTarget)(n,e.prototype._compile),P=!0,l.instrument_logger.debug("Patched _compile")}function F(e,t,r){try{const n=g.hudConfig.frameworksToPatch.get(t);return j(n,g.hudConfig.userConfig.enableFrameworks)&&n?.patcher&&n.version?(0,b.getFrameworkPatcher)(n.patcher).patch(e,r,n.version,n.extraInfo,t):e}catch(e){l.instrument_logger.error("Failed to patch framework",{name:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}function N(){const e=Array.from(g.hudConfig.frameworksToPatch.entries()).filter(([e,t])=>j(t,g.hudConfig.userConfig.enableFrameworks)).map(([e])=>e);new y.Hook(Array.from(e),{internals:!0},F)}function j(e,t){return!!e&&(t&&t.value?.has(e.framework)?t.value.get(e.framework)||!1:e.enable)}function R(e,t){const r=u.parse(e);let n=`${r.dir}/patched.${r.base}`;r.dir.includes("dist")&&(n=u.join(`${r.dir.replace("dist","patched")}`,r.base)),a.suppressTracesFS.existsSync(u.dirname(n))||a.suppressTracesFS.mkdirSync(u.dirname(n),{recursive:!0}),a.suppressTracesFS.writeFileSync(n,t,"utf8"),l.instrument_logger.debug("Dumped patched file",{filename:e,patchedPath:n})}function D(e){const t=u.sep.replace(/\\/g,"\\\\"),r=u.join(e).split(".").join("\\.").split("*").join(".*?"),n=t+"node_modules"+t;return{isAllowdModule:new RegExp(n+r+`(?:${t}|$)`),isAllowdModuleSubModule:new RegExp(n+r+n)}}function A(e,t){return!!t.isAllowdModule.test(e)&&!t.isAllowdModuleSubModule.test(e)}function L(e,t){const r=t.replace(/\//g,u.sep);return e.includes(`node_modules${u.sep}${r}${u.sep}`)&&!e.includes(`node_modules${u.sep}${r}${u.sep}node_modules`)}function q(e){return(0,h.getInstrumentedThirdPartyModuleInfo)(e)?.functions||[]}function H(e){const t=[];for(const r of e){let e;if(r.includes("*")){const t=D(r);e=e=>A(e,t)}else e=e=>L(e,r);t.push(e)}return t}let B=[];function U(){B=H(g.hudConfig.userConfig.includeModules?.value??[])}function $(e,t,r,n=[]){if(!g.hudConfig.allowedEditExtensions.includes(u.extname(e))&&!e.endsWith(u.sep))return l.instrument_logger.warning("Skipping non-allowed extension",{filename:e}),!0;if(r&&(r===c.Format.ts||r===c.Format.moduleTypescript||r===c.Format.commonjsTypescript))return l.instrument_logger.warning("Skipping typescript module",{filename:e}),!0;const o=g.hudConfig.userConfig.excludeDirs?.value;if(o&&o.length>0)for(const t of o)if(e.includes(`${t}`))return l.instrument_logger.debug("Skipping file in excluded directory",{filename:e,excludeDir:t}),!0;const i=t??B;return"/var/runtime/index.mjs"===e?(l.instrument_logger.debug("Skipping lambda runtime",{filename:e}),!0):e.includes("node_modules")&&!function(e,t){for(const r of t)if(r(e))return!0;return!1}(e,i)&&0===n.length||e.includes(".yarn")?(l.instrument_logger.debug("Skipping non-monitored imported module",{filename:e}),!0):!(v&&!e.includes(v)||(l.instrument_logger.debug("Skipping hud internal module",{filename:e}),0))}},7214:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5809),o=r(8269),i=r(2546),s=r(523),a=r(7131),u=r(8949),c=r(714);class d extends c.FrameworkPatcher{static graphQLPatchedSymbol=Symbol.for(n.hudConfig.hudPatchedName);_patch(e){return this.patchExecute(e),s.instrument_logger.info("Patched GraphQL successfully"),e}patchExecute(e){const t=e.execute,r=(0,u.wrapFlow)(function(e,t){let r;if(e.operation)return e.operation.flow_id;try{if(t.length<1)return;const n=t[0];if(n.document.definitions.length>1){if(n.operationName)for(const t of n.document.definitions)if(r=l(e,t,n.operationName),r)break}else r=l(e,n.document.definitions[0])}catch(e){s.instrument_logger.error("Failed to store graphql operations",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r?.flow_id},t,!1,void 0,function(e,t,r){return function(e,t){return"function"==typeof e.then?e.then(e=>(f(e,t),e)):(f(e,t),e)}(r,t.operation)});e.execute=r}}function l(e,t,r){const n=function(e){return e&&e.name?e.name.value:"anonymous"}(t),s=function(e){return e&&e.operation?e.operation:"query"}(t);if(!r||r===n){const t={flow_id:(0,i.generateGraphqlFlowId)(n,s),operation_name:n,operation_type:s};return(0,o.storeGraphQLOperation)(t),e.operation=t,t}}function f(e,t){try{if(!t)return;const r=(0,a.getFlowState)();if(!r)return void s.instrument_logger.warning("No flow state found for graphql operation",{operation_name:t.operation_name,operation_type:t.operation_type});const n=r.httpMetric;if(!n)return void s.instrument_logger.warning("No http metric found for graphql operation",{operation_name:t.operation_name,operation_type:t.operation_type});n.setFlowId(t.flow_id),n.setGraphQLAttributes(!!e.errors&&e.errors.length>0,e.errors)}catch(e){s.instrument_logger.error("Failed to set flowId and graphql attributes in http metric",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}t.default=d},7225:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.skipStackNamesLogs=t.skipLayerNamesLogs=t.isVerboseLoggingEnabled=t.uuidSymbol=void 0,t.logLazyRouter=function(e){const r=e.lazyrouter;e.lazyrouter=function(){let e=!1;try{this._router||(e=!0)}catch(e){a.instrument_logger.error("Failed to check this._router",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const n=r.apply(this,arguments);try{if(e){let e=this[t.uuidSymbol];e||(e=u.randomUUID(),this[t.uuidSymbol]=e,a.instrument_logger.info("Express lazy router setting uuid",{uuid:e})),a.instrument_logger.info("Express lazy router",{parent:e,child:this._router?.[t.uuidSymbol]})}}catch(e){a.instrument_logger.error("Failed to patch express.lazyRouter function",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n},(0,d.copyPropertiesToTarget)(r,e.lazyrouter)};const a=r(523),u=s(r(6982)),c=r(932),d=r(8949);t.uuidSymbol=Symbol.for("__hud_uuid__"),t.isVerboseLoggingEnabled="true"===c.env.HUD_LOG_EXPRESS,t.skipLayerNamesLogs=new Set(["query","expressInit","mounted_app"]),t.skipStackNamesLogs=new Set(["router"])},7255:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseOptions=function(e){if(null==e||"object"!=typeof e)return;const t={};return"string"==typeof e.comment&&(t.comment=e.comment),"number"==typeof e.maxTimeMS&&(t.maxTimeMS=e.maxTimeMS),"number"==typeof e.timeoutMS&&(t.timeoutMS=e.timeoutMS),"number"==typeof e.limit&&(t.limit=e.limit),"number"==typeof e.batchSize&&(t.batchSize=e.batchSize),"boolean"==typeof e.ordered&&(t.ordered=e.ordered),"boolean"==typeof e.upsert&&(t.upsert=e.upsert),Object.keys(t).length>0?t:void 0},t.parseDbFromUrl=function(e){if(!e||"string"!=typeof e)return;const t=e.split(/[?#]/)[0].replace(/\/+$/,""),r=t.indexOf("://");if(-1===r)return;const n=t.indexOf("/",r+3);return-1===n?void 0:t.slice(n+1)||void 0},t.getDocument=function(e){if(n.hudConfig.dynamicConfig.enableMongoDocumentData)return null!=e&&"object"==typeof e?e:void 0};const n=r(5809)},7276:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8544);class o extends n.BaseKafkaJSPatcher{getExportsRoot(e){return e.KafkaJS}getGroupId(e){return e[0].kafkaJS.groupId}moduleName(){return"@confluentinc/kafka-javascript.KafkaJS"}}t.default=o},7427:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(9938);class c extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching pg"),this._patchConnect(e),this._patchQuery(e),this._patchEnd(e),this._createPgDeclaration(),n.instrument_logger.info("Patched pg successfully"),e}_patchConnect(e){const t=e.Client.prototype.connect;e.Client.prototype.connect=(0,u.wrapOutboundFunction)(t,i.hudConfig.pgConnectFunctionId,void 0,void 0,s.OutboundType.DB)}_patchEnd(e){const t=e.Client.prototype.end;e.Client.prototype.end=(0,u.wrapOutboundFunction)(t,i.hudConfig.pgEndFunctionId,void 0,void 0,s.OutboundType.DB)}_patchQuery(e){const t=e.Client.prototype.query;e.Client.prototype.query=(0,u.wrapOutboundFunction)(t,i.hudConfig.pgQueryFunctionId,e=>({query:e[0],params:e[1]}),e=>({rowsCount:e.rowCount}),s.OutboundType.DB)}_createPgDeclaration(){(0,a.storeLoadedOutbound)("pg")}}t.default=c},7535:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(3903),c=r(9938);class d extends o.FrameworkPatcher{static commandsToSkip=["auth","client","select","info","readonly","monitor","subscribe","psubscribe","ssubscribe","cluster"];_patch(e){return n.instrument_logger.info("Patching ioredis"),this._patchConnect(e),this._patchSendCommand(e),n.instrument_logger.info("Patched ioredis successfully"),e}_patchConnect(e){const t=e.prototype.connect;if(!t)return void n.instrument_logger.warning("prototype.connect not found");const r=d.generateFunctionId("connect");e.prototype.connect=(0,c.wrapOutboundFunction)(t,r,void 0,void 0,s.OutboundType.REDIS),(0,a.storeIoredisCommand)("connect",r),n.instrument_logger.debug("Wrapped prototype.connect")}_patchSendCommand(e){const t=e.prototype.sendCommand;t?(e.prototype.sendCommand=(0,c.wrapOutboundFunction)(t,e=>{const t=e[0]?.name?.toLowerCase();if(t){if(!d.commandsToSkip.includes(t))return d._getFunctionId(t)}else(0,n.limitedLogger)("Redis command name not found, skipping instrumentation")},e=>d._parseCommandArgs(e),e=>d._parseCommandResult(e),s.OutboundType.REDIS),n.instrument_logger.debug("Wrapped prototype.sendCommand")):n.instrument_logger.warning("prototype.sendCommand not found")}static _getFunctionId(e){let t=(0,a.getIoredisFunctionId)(e);return t||(t=d.generateFunctionId(e)),(0,a.storeIoredisCommand)(e,t),t}static _parseCommandArgs(e){try{const t=e[0];if(!t||"object"!=typeof t)return;const r=t.name,n=t.args||[];return{command:r,key:n[0],args:n.slice(1),argsCount:n.length}}catch(e){return void n.instrument_logger.debug("Error parsing Redis command args",{error:e instanceof Error?e.message:void 0})}}static _parseCommandResult(e){try{let t,r;return t=null==e?"null":Buffer.isBuffer(e)?"buffer":Array.isArray(e)?"array":typeof e,("string"==typeof e||Buffer.isBuffer(e))&&(r=e.length),{valueType:t,valueSize:r}}catch(e){return void n.instrument_logger.debug("Error parsing Redis command result",{error:e instanceof Error?e.message:void 0})}}static generateFunctionId(e){return(0,i.functionUuidToBase64)((0,u.v5)(`ioredis-${e}`,i.hudConfig.functionUuidNamespace))}}t.default=d},7603:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getObservabilityIdentifiers=s,t.getObservabilityIdentifiersHttp=function(e){return{...s(),w3c_trace_context:a(e),w3c_baggage:c(e,"baggage"),amazon_trace_id:c(e,"x-amzn-trace-id"),b3_propagation:u(e),jaeger_trace_id:c(e,"uber-trace-id")}},t.getExtraHeaders=function(e){const t={};for(const r of n.hudConfig.dynamicConfig.extraHeaders){const n=c(e,r);void 0!==n&&(t[r]=n)}return t},t.getDatadogIds=l,t.getOtelTraceId=g;const n=r(5809),o=r(2546),i=r(523);function s(){const e=l();return{datadog_trace_id:e?.trace_id,datadog_span_id:e?.span_id,otel_trace_id:g()}}function a(e){try{return{traceparent:c(e,"traceparent"),tracestate:c(e,"tracestate")}}catch{return}}function u(e){try{return{full:c(e,"b3"),trace_id:c(e,"x-b3-traceid"),span_id:c(e,"x-b3-spanid"),parent_span_id:c(e,"x-b3-parentspanid")}}catch{return}}function c(e,t){try{return e.headers[t]}catch{return}}const d=(0,o.requireWithInternalCache)("dd-trace/packages/datadog-core",i.instrument_logger.debug.bind(i.instrument_logger));function l(){try{const e=d();if(null===e)return;const{storage:t}=e,r=t("legacy").getStore();return{trace_id:r.span._spanContext.toTraceId(),span_id:r.span._spanContext.toSpanId()}}catch{return}}const f=(0,o.requireWithInternalCache)("@opentelemetry/api",i.instrument_logger.debug.bind(i.instrument_logger));function g(){try{const e=f();if(null===e)return;const{trace:t}=e;return t.getActiveSpan()?.spanContext().traceId}catch{return}}},7808:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getMachineMetrics=function(){try{const e=(0,o.getLastMetrics)();return{cpu_usage:e.cpuUsage?l(e.cpuUsage,e.timestamp):void 0,memory_usage:d(),event_loop_utilization:e.elu?c(e.elu):void 0}}catch(e){return void s.app_logger.error("Error getting machine metrics",e)}},t.getCpuUsage=l;const o=r(8269),i=r(2546),s=r(523),a=n(r(857)),u=r(2987);function c(e){try{return u.performance.eventLoopUtilization(e).utilization}catch(e){return void s.app_logger.error("Error getting event loop utilization",e)}}function d(){try{const e=process.memoryUsage(),t=(0,i.getPodMemoryLimit)(s.app_logger).podMemoryLimitMB;let r;return r=null===t?a.default.totalmem():1024*t*1024,{rss:e.rss,heap_total:e.heapTotal,heap_used:e.heapUsed,external:e.external,system_memory:r,rss_percentage:e.rss/r*100}}catch(e){return void s.app_logger.error("Error getting memory usage",e)}}function l(e,t){try{const r=process.cpuUsage(),n=1e3*(Date.now()-t),o=(0,i.getCpuLimit)(s.app_logger),a=(r.user-e.user)/n,u=(r.system-e.system)/n;return{user_time:a,system_time:u,limit:o,user_percent_of_limit:"number"==typeof o?a/o*100:void 0,system_percent_of_limit:"number"==typeof o?u/o*100:void 0}}catch(e){return void s.app_logger.error("Error getting cpu usage",e)}}},7997:e=>{"use strict";e.exports=require("node:timers")},8064:e=>{"use strict";e.exports=require("semver")},8269:e=>{"use strict";e.exports=require("./globalstate")},8528:e=>{"use strict";e.exports=require("./dto")},8544:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseKafkaJSPatcher=void 0;const n=r(8269),o=r(2546),i=r(523),s=r(2822),a=r(8949),u=r(828),c=r(714);class d extends c.FrameworkPatcher{_patch(e){const t=this.getExportsRoot(e);return this._patchConsumer(t),i.instrument_logger.info(`Patched ${this.moduleName()} successfully`),e}_patchConsumer(e){const t=e.Kafka.prototype.consumer;if(!t)return void i.instrument_logger.error("DD presumably ran before HUD - exports.Kafka.prototype.consumer is undefined");const r=this.getGroupId.bind(this);e.Kafka.prototype.consumer=function(...e){const n=t.apply(this,e);try{const t=new Map,o=[],c=[];!function(e,t){const r=e.subscribe;e.subscribe=async function(...e){const n=await r.apply(this,e);try{const r=e[0].topics;r?r.forEach(e=>{t.push(e)}):e[0].topic?t.push(e[0].topic):i.instrument_logger.warning("No topic found in KafkaJS.Consumer.subscribe",{args:e[0]})}catch(e){i.instrument_logger.error("Error in patching KafkaJS.Consumer.subscribe",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n},(0,a.copyPropertiesToTarget)(r,e.subscribe)}(n,c),function(e,t,r,n,o){const c=e.run;function d(e,c){const d="eachBatch"===c;for(const e of o)p(e,n,t,r,c);const m=function(e,t,r){return(n,o)=>{const s=o[0],a=r?s.batch.topic:s.topic;return function(e,t,r,n){const o=e.get(g(r,n));if(o)return o;for(const e of t)if(e.isBatch===n&&e.pattern.test(r))return e.flowId;i.instrument_logger.warning("No flowId found for topic",{topicName:r,isBatch:n})}(e,t,a,r)}}(t,r,d),h=function(e){return(t,r,n)=>{const o=u.KafkaJSMetric.createUsableMetric();o.start(),o.setFlowId(t),(0,s.createNewInvestigation)();const i=n[0],a=e?i.batch.partition:i.partition,c=e?i.batch.messages[0]?.timestamp:i.message?.timestamp;o.addPartition(a),o.addProducedTimestamp(c),r.topic=e?i.batch.topic:i.topic,r.partition=e?i.batch.partition:i.partition,r.messages=e?i.batch.messages:[i.message],r.flowMetric=o}}(d),y=(0,a.wrapFlow)(m,e[c],!0,h,l,f);e[c]=y}e.run=async function(...e){try{const t=e[0];t.eachMessage&&d(t,"eachMessage"),t.eachBatch&&d(t,"eachBatch")}catch(e){i.instrument_logger.error("Error in patching KafkaJS.Consumer.run",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return await c.apply(this,e)},(0,a.copyPropertiesToTarget)(c,e.run)}(n,t,o,r(e),c)}catch(e){i.instrument_logger.error("Error in patching KafkaJS.Consumer",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n},(0,a.copyPropertiesToTarget)(t,e.Kafka.prototype.consumer)}}function l(e,t){const r=t.flowMetric;r?(r.calculateDuration(),(0,s.finishKafkaJSInvestigation)(t.messages,r,t.topic,t.partition),r.end()):i.instrument_logger.warning("No flowMetric found for message",{flowId:e})}function f(e,t,r){const n=t.flowMetric;n?(n.setError(r),n.calculateDuration(),(0,s.finishKafkaJSInvestigation)(t.messages,n,t.topic,t.partition),n.end()):i.instrument_logger.warning("No flowMetric found for message",{flowId:e})}function g(e,t){return e+"|"+t}function p(e,t,r,i,s){const a=(0,o.generateKafkaFlowId)(e,t,s),u={flow_id:a,topic_name:e.toString(),group_id:t,pulling_type:s};(0,n.storeKafkaJSTopicDeclaration)(u),function(e,t,r,n,o){"string"==typeof r?e.set(g(r,n),o):t.push({pattern:r,isBatch:n,flowId:o})}(r,i,e,"eachBatch"===s,a)}t.BaseKafkaJSPatcher=d},8564:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(9938),c=Symbol.for("_HUD_outboundIndex");class d extends o.FrameworkPatcher{_patch(e){return n.instrument_logger.info("Patching node-fetch"),e=this._patchFetch(e),this._patchBody(e),this._createNodeFetchDeclaration(),n.instrument_logger.info("Patched node-fetch successfully"),e}_patchFetch(e){return(0,u.wrapOutboundFunction)(e,i.hudConfig.nodeFetchFunctionId,e=>{const t=e[1]?.body,r=(0,u.getBodySize)(t);return{url:e[0],method:e[1]?.method?.toLowerCase()??"get",body:(0,u.getReducedBody)(t,r,i.hudConfig.dynamicConfig.maxHTTPRequestBodySize),bodySize:r}},(e,t)=>(e[c]=t,{status_code:e.status}),s.OutboundType.HTTP)}_patchBody(e){for(const[t,r]of Object.entries(i.hudConfig.nodeFetchBodiesFunctionIds)){const n=e.Response.prototype[t];e.Response.prototype[t]=(0,u.wrapOutboundBodyFunction)(n,r,(e,t)=>e[c],(e,t)=>{const r=Number.parseInt(e.headers.get("content-length")),n=isNaN(r)||0===r?void 0:r;return{body:(0,u.getReducedBody)(t,n,i.hudConfig.dynamicConfig.maxHTTPResponseBodySize),bodySize:n}})}}_createNodeFetchDeclaration(){(0,a.storeLoadedOutbound)("node-fetch")}}t.default=d},8611:e=>{"use strict";e.exports=require("http")},8840:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(523),i=r(8949),s=r(714),a=n(r(9589));class u extends s.FrameworkPatcher{static nextJSHudMarked=Symbol.for("hudNextJSMarked");_patch(e){const t=e.PagesAPIRouteModule||e.default;if(!t||t[u.nextJSHudMarked])return e;const r=this._wrapConstructor(t);t[u.nextJSHudMarked]=!0,o.instrument_logger.info("Patched Next.js route module constructor successfully");const n=Object.create(Object.getPrototypeOf(e));return Object.defineProperty(n,"PagesAPIRouteModule",{enumerable:!0,get:function(){return r}}),e.default===t&&Object.defineProperty(n,"default",{enumerable:!0,get:function(){return r}}),(0,i.copyPropertiesToTarget)(e,n),n}_wrapConstructor(e){const t=function(...t){const r=new e(...t);try{const e=r.definition?.pathname;e&&!r[u.nextJSHudMarked]&&(a.default._detectAndPatchSupportedMethods(r,e),r[u.nextJSHudMarked]=!0)}catch(e){o.instrument_logger.error("Failed to patch Next.js Pages API route module instance",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return r};return(0,i.copyPropertiesToTarget)(e,t),t}}t.default=u},8949:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncFunction=void 0,t.wrapFlow=function(e,r,u=!0,c,d,l){let f;const g=(0,i.getFlowStateStorage)();if(!g)return r;try{if(r[s])return r}catch{return r}return f=r instanceof t.AsyncFunction?async function(...t){let s;const a={};try{s=e(a,t)}catch(e){o.instrument_logger.error("Failed to get flowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(!s||hudRunningMode!==n.HudRunningMode.enabled)return await r.apply(this,t);if(c)try{c(s,a,t)}catch(e){o.instrument_logger.error("Failed to execute beforeCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}let f=(0,i.getFlowState)();f||(f={}),f.httpMetric?.setFlowId(s),f.flowId=s,f.shouldLinkFunction=u;try{const e=g.run(f,Reflect.apply,r,this,t),n=await e;if(d)try{d(s,a,n)}catch(e){o.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n}catch(e){if(l)try{l(s,a,e)}catch(e){o.instrument_logger.error("Failed to execute catchCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}throw e}}:function(...t){let s;const a={};try{s=e(a,t)}catch(e){o.instrument_logger.error("Failed to get flowId",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(!s||hudRunningMode!==n.HudRunningMode.enabled)return r.apply(this,t);if(c)try{c(s,a,t)}catch(e){o.instrument_logger.error("Failed to execute beforeCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}let f=(0,i.getFlowState)();f||(f={}),f.httpMetric?.setFlowId(s),f.flowId=s,f.shouldLinkFunction=u;try{const e=g.run(f,Reflect.apply,r,this,t);if(d||l){if(e instanceof Promise)return e.catch(e=>{try{l&&l(s,a,e)}catch(e){o.instrument_logger.error("Failed to execute catchCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}throw e}).then(e=>{try{d&&d(s,a,e)}catch(e){o.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e});try{d&&d(s,a,e)}catch(e){o.instrument_logger.error("Failed to execute afterCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}return e}catch(e){if(l)try{l(s,a,e)}catch(e){o.instrument_logger.error("Failed to execute catchCallbackHook",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}throw e}},a(r,f),f[s]=!0,f},t.copyPropertiesToTarget=a,t.clearFlowStateData=function(e){try{e.httpMetric=void 0,e.flowId=void 0,e.shouldLinkFunction=void 0}catch{}};const n=r(8528),o=r(523),i=r(7131);t.AsyncFunction=(async()=>{}).constructor;const s=Symbol.for("hudMarked");function a(e,t){const r=Object.getOwnPropertyDescriptors(e),n=Reflect.ownKeys(r);Object.setPrototypeOf(t,e),n.forEach(e=>{try{Object.defineProperty(t,e,r[e])}catch{}})}},9063:e=>{"use strict";e.exports=require("require-in-the-middle")},9589:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8528),o=r(8269),i=r(2546),s=r(523),a=r(8949),u=r(714);class c extends u.FrameworkPatcher{static nextJSHudMarked=Symbol.for("hudNextJSMarked");static routeInfoSymbol=Symbol.for("hudNextJSRouteInfo");static standardMethods=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"];_patch(e){return(0,i.setIsNextJsApp)(!0),this._patchBaseServer(e),s.instrument_logger.info("Patched Next.js successfully"),e}_patchBaseServer(e){try{const t=e.default;if(t[c.nextJSHudMarked])return e;const r=t.prototype.renderToResponseWithComponentsImpl;if(!r)return s.instrument_logger.error("Could not find renderToResponseWithComponentsImpl on BaseServer.prototype"),e;t.prototype.renderToResponseWithComponentsImpl=async function(e,t,...n){try{const r=t.components;if(r&&r.routeModule&&!r.routeModule[c.nextJSHudMarked]){const t=r.routeModule,n=t.definition?.pathname||e.pathname;c._detectAndPatchSupportedMethods(t,n),t[c.nextJSHudMarked]=!0}}catch(e){s.instrument_logger.error("Failed to patch Next.js route module",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return await r.apply(this,[e,t,...n])},t[c.nextJSHudMarked]=!0,(0,a.copyPropertiesToTarget)(r,t.prototype.renderToResponseWithComponentsImpl)}catch(e){s.instrument_logger.error("Failed to patch Next.js base server",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return e}static _detectAndPatchSupportedMethods(e,t){try{if(t.startsWith("/_"))return;switch(s.instrument_logger.debug("Patching Next.js route module",{pathname:t,kind:e.definition?.kind||"unknown"}),e.definition.kind){case"APP_ROUTE":case"PAGES_API":c._patchApiModule(e,t);break;case"PAGES":case"APP_PAGE":c._patchPageModule(e,t);break;default:s.instrument_logger.warning("Unknown Next.js route module kind",{pathname:t,kind:e.definition?.kind||"unknown"})}}catch(e){s.instrument_logger.error("Error detecting and patching supported methods",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}static _patchApiModule(e,t){if(e.methods)for(const r of c.standardMethods)if("function"==typeof e.methods[r]&&"function"==typeof e.userland?.[r]){const u=(0,i.generateEndpointFlowId)(t,[r]);(0,o.storeEndpointDeclaration)(new n.EndpointDeclaration(u,[r],"nextjs","",t));try{const t=e.methods[r];e.methods[r]=(0,a.wrapFlow)(()=>u,t,!0)}catch(e){s.instrument_logger.error("Failed to patch Next.js App Route method",{method:r,pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}if(e.userland?.default){const r=c.standardMethods.filter(t=>!e.methods?.[t]),s=(0,i.generateEndpointFlowId)(t,r);(0,o.storeEndpointDeclaration)(new n.EndpointDeclaration(s,r,"nextjs","",t));const u=e.userland.default;e.userland={...e.userland,default:(0,a.wrapFlow)(()=>s,u,!0)}}}static _patchPageModule(e,t){const r=(0,i.generateEndpointFlowId)(t,["GET"]);if((0,o.storeEndpointDeclaration)(new n.EndpointDeclaration(r,["GET"],"nextjs","",t)),e.render&&"function"==typeof e.render&&!e.render[this.nextJSHudMarked])try{const n=e.render;e.render=function(...e){try{const n=e[2]?.renderOpts;for(const e of["Component","getServerSideProps","getStaticProps"])try{n?.[e]&&"function"==typeof n[e]&&!n[e].prototype?.isReactComponent&&(n[e]=(0,a.wrapFlow)(()=>r,n[e],!0))}catch(r){s.instrument_logger.error("Failed to patch Next.js Page renderOpts",{pathname:t,key:e,msg:r instanceof Error?r.message:void 0,stack:r instanceof Error?r.stack:void 0})}}catch(e){s.instrument_logger.error("Failed to patch Next.js Page render method",{pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}return n.apply(this,e)},(0,a.copyPropertiesToTarget)(n,e.render),e.render[this.nextJSHudMarked]=!0}catch(e){s.instrument_logger.error("Failed to patch Next.js Page render method",{pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}if(e.userland?.loaderTree)try{l(e.userland.loaderTree,r)}catch(e){s.instrument_logger.error("Failed to patch App Router page component",{pathname:t,msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}else s.instrument_logger.info("No loader tree found on Next.js page component, functions will be patched by the render function",{pathname:t})}}function d(e,t,r){return(...n)=>{const o=e(...n),i=e=>{if(e&&"function"==typeof e.default){try{e.default.a}catch{return e}if(e.default.prototype?.isReactComponent)return e;const n=(0,a.wrapFlow)(()=>r,e.default,t);e={...e,default:n}}return e};return o&&"function"==typeof o.then?o.then(i):i(o)}}function l(e,t){const[,r,n]=e;for(const e of Object.keys(n))try{const r=n[e];if(Array.isArray(r)&&"function"==typeof r[0]){const n="page"===e,o=r[0];r[0]=d(o,n,t),(0,a.copyPropertiesToTarget)(o,r[0])}}catch(e){s.instrument_logger.error("Failed to iterate on Next.js components",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}for(const e of Object.values(r))try{l(e,t)}catch(e){s.instrument_logger.error("Failed to walk on Next.js parallel routes",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}}t.default=c},9702:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(3903),c=r(8949),d=r(7255),l=r(9938);function f(e){return{query:e[0],options:(0,d.parseOptions)(e[1])}}function g(e){return{query:e[0],update:(0,d.getDocument)(e[1]),options:(0,d.parseOptions)(e[2])}}function p(e){return{key:e[0],query:e[1],options:(0,d.parseOptions)(e[2])}}function m(e){return{documentCount:1,insert:(0,d.getDocument)(e[0]),options:(0,d.parseOptions)(e[1])}}function h(e){return{documentCount:Array.isArray(e[0])?e[0].length:void 0,insert:(0,d.getDocument)(e[0]?.[0]),options:(0,d.parseOptions)(e[1])}}function y(e){return{pipeline:e[0],options:(0,d.parseOptions)(e[1])}}function b(e){return{documentCount:null!=e?1:0}}function _(e){return{documentCount:Array.isArray(e)?e.length:void 0}}function v(e){return{documentCount:e}}function k(e){return{acknowledged:e?.acknowledged,documentCount:void 0!==e?.insertedId?1:0}}function C(e){return{acknowledged:e?.acknowledged,documentCount:e?.insertedCount}}function w(e){return{acknowledged:e?.acknowledged,modifiedCount:e?.modifiedCount,upsertedCount:e?.upsertedCount}}function S(e){return{acknowledged:e?.acknowledged,deletedCount:e?.deletedCount}}function x(e){return{documentCount:null!=e?1:0}}const E=Symbol.for("hudMarked");function O(e,t,r){return void 0!==r&&function(e,t){const r=e.fetchBatch;if("function"!=typeof r)return;if(r[E])return;const n=new WeakRef(t),o=async function(...e){const t=n.deref();if(!t)return await r.apply(this,e);const o=process.hrtime.bigint();let i;try{i=await r.apply(this,e)}catch(e){try{t.error=e,t.duration=(t.duration??0)+Number(process.hrtime.bigint()-o)}catch{}throw e}try{if(void 0!==t.result){const e=t.result;e.documentCount=(e.documentCount??0)+(this.documents?.length??0)}t.duration=(t.duration??0)+Number(process.hrtime.bigint()-o)}catch{}return i};(0,c.copyPropertiesToTarget)(r,o),o[E]=!0,e.fetchBatch=o}(e,r),{}}class M extends o.FrameworkPatcher{static COLLECTION_METHOD_CONFIG={find:{argsExtract:f,resultParser:O},aggregate:{argsExtract:y,resultParser:O},findOne:{argsExtract:f,resultParser:b},countDocuments:{argsExtract:f,resultParser:v},distinct:{argsExtract:p,resultParser:_},insertOne:{argsExtract:m,resultParser:k},insertMany:{argsExtract:h,resultParser:C},updateOne:{argsExtract:g,resultParser:w},updateMany:{argsExtract:g,resultParser:w},replaceOne:{argsExtract:g,resultParser:w},deleteOne:{argsExtract:f,resultParser:S},deleteMany:{argsExtract:f,resultParser:S},findOneAndUpdate:{argsExtract:g,resultParser:x},findOneAndDelete:{argsExtract:f,resultParser:x}};_patch(e){n.instrument_logger.info("Patching mongodb");const t=["connect",...Object.keys(M.COLLECTION_METHOD_CONFIG)],r=new Map(t.map(e=>[e,M.generateFunctionId(e)]));return M._patchConnect(e,r),M._patchCollectionMethods(e,r),(0,a.storeLoadedOutbound)("mongodb"),n.instrument_logger.info("Patched mongodb successfully"),e}static _patchConnect(e,t){const r=e.MongoClient?.prototype?.connect;if(!r)return void n.instrument_logger.warning("MongoClient.prototype.connect not found");const o=new Set(t.values());e.MongoClient.prototype.connect=(0,l.wrapOutboundFunction)(r,t.get("connect"),(e,t,r,n)=>({operation:"connect",db:(0,d.parseDbFromUrl)(n?.s?.url)}),void 0,s.OutboundType.MONGO,!1,o),n.instrument_logger.debug("Wrapped MongoClient.prototype.connect")}static _patchCollectionMethods(e,t){const r=e.Collection?.prototype;if(!r)return void n.instrument_logger.warning("Collection.prototype not found");const o=new Set(t.values());for(const[e,{argsExtract:i,resultParser:s}]of Object.entries(M.COLLECTION_METHOD_CONFIG))try{M._patchCollectionMethod(r,e,i,s,o,t.get(e))}catch(t){n.instrument_logger.warning(`Failed to patch Collection.prototype.${e}`,t)}}static _patchCollectionMethod(e,t,r,o,i,a){const u=e[t];u?(e[t]=(0,l.wrapOutboundFunction)(u,a,function(e,t){return(r,n,o,i)=>({operation:e,collection:i?.collectionName,db:i?.dbName,...Array.isArray(r)?t(r):{}})}(t,r),o,s.OutboundType.MONGO,!1,i),n.instrument_logger.debug(`Wrapped Collection.prototype.${t}`)):n.instrument_logger.warning(`Collection.prototype.${t} not found`)}static generateFunctionId(e){return(0,i.functionUuidToBase64)((0,u.v5)(`mongodb-${e}`,i.hudConfig.functionUuidNamespace))}}t.default=M},9723:function(e,t,r){"use strict";var n,o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&o(t,e,r[s]);return i(t,e),t});Object.defineProperty(t,"__esModule",{value:!0});const a=r(8269),u=r(2546),c=r(523),d=s(r(6928)),l=r(8949),f=r(714);class g extends f.FrameworkPatcher{_patch(e){(0,u.setIsNextJsApp)(!0);const t=this._patchLoadConfig(e);return c.instrument_logger.info("Patched next.js config successfully"),t}_patchLoadConfig(e){const t=e.default,r=async function(...e){const r=await t.call(this,...e);if(!r)return r;try{const t=e[1],n=d.join(t,r.distDir||".next"),o=d.join(n,a.apiManifest),i=d.join(n,a.pageManifest),s=await u.suppressTracesPromiseFS.access(o).then(()=>!0).catch(()=>!1),l=await u.suppressTracesPromiseFS.access(i).then(()=>!0).catch(()=>!1);(0,a.isNextConfigExtracted)()||!s&&!l||(c.instrument_logger.info("Extracted next.js config successfully"),(0,a.setNextConfig)(r))}catch(e){c.instrument_logger.error("Failed to patch next.js loadConfig",{msg:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0})}return r};(0,l.copyPropertiesToTarget)(t,r);const n=Object.create(Object.getPrototypeOf(e));return Object.defineProperty(n,"default",{enumerable:!0,get:function(){return r}}),(0,l.copyPropertiesToTarget)(e,n),n}}t.default=g},9803:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(523),o=r(714),i=r(5809),s=r(8528),a=r(8269),u=r(3903),c=r(7255),d=r(9938);function l(e){return{query:e._conditions,options:(0,c.parseOptions)(e.options)}}function f(e){return{query:e._conditions,update:(0,c.getDocument)(e._update),options:(0,c.parseOptions)(e.options)}}function g(e){return{key:e._distinct,query:e._conditions,options:(0,c.parseOptions)(e.options)}}function p(e){return{documentCount:null!=e?1:0}}function m(e){return{documentCount:Array.isArray(e)?e.length:void 0}}function h(e){return{documentCount:Array.isArray(e)?e.length:void 0}}function y(e){return{documentCount:"number"==typeof e?e:void 0}}function b(e){return{modifiedCount:e?.modifiedCount??e?.nModified,upsertedCount:e?.upsertedCount??(null!=e?.upsertedId?1:0),acknowledged:e?.acknowledged??(1===e?.ok||void 0)}}function _(e){return{deletedCount:e?.deletedCount??e?.n,acknowledged:e?.acknowledged??(1===e?.ok||void 0)}}function v(e,t,r,n){const o=n?.op;if(!o)return;const i=C.QUERY_METHOD_CONFIG[o];if(i){if("function"==typeof e[0]){const n=e[0];e[0]=(e,o)=>{try{null!=e?t(e):r(o)}catch{}n(e,o)}}return{operation:o,collection:n?.mongooseCollection?.collectionName,db:n?.mongooseCollection?.conn?.name,...i.argsExtract(n)}}}function k(e,t,r,n){const o=n?.$isNew??n?.isNew,i=n?.constructor?.collection?.collectionName,s=n?.constructor?.db?.name;return o?{operation:"insertOne",collection:i,db:s,documentCount:1,insert:(0,c.getDocument)(n?.toObject?.())}:{operation:"saveUpdate",collection:i,db:s,query:null!=n?._doc?._id?{_id:n._doc._id}:void 0}}class C extends o.FrameworkPatcher{static QUERY_METHOD_CONFIG={find:{argsExtract:l,resultParser:h},findOne:{argsExtract:l,resultParser:p},count:{argsExtract:l,resultParser:y},countDocuments:{argsExtract:l,resultParser:y},estimatedDocumentCount:{argsExtract:()=>({}),resultParser:y},deleteOne:{argsExtract:l,resultParser:_},deleteMany:{argsExtract:l,resultParser:_},findOneAndDelete:{argsExtract:l,resultParser:p},updateOne:{argsExtract:f,resultParser:b},updateMany:{argsExtract:f,resultParser:b},replaceOne:{argsExtract:f,resultParser:b},findOneAndUpdate:{argsExtract:f,resultParser:p},findOneAndReplace:{argsExtract:f,resultParser:p},distinct:{argsExtract:g,resultParser:m}};_patch(e){return n.instrument_logger.info("Patching mongoose"),C._patchConnect(e),C._patchQueryExec(e),C._patchAggregateExec(e),C._patchInsertMany(e),C._patchSave(e),(0,a.storeLoadedOutbound)("mongoose"),n.instrument_logger.info("Patched mongoose successfully"),e}static _patchConnect(e){const t=e.connect;t?(e.connect=(0,d.wrapOutboundFunction)(t,C.generateFunctionId("connect"),e=>({operation:"connect",db:(0,c.parseDbFromUrl)(e[0])}),void 0,s.OutboundType.MONGO),n.instrument_logger.debug("Wrapped mongoose.connect")):n.instrument_logger.warning("mongoose.connect not found");const r=e.createConnection;r?(e.createConnection=(0,d.wrapOutboundFunction)(r,C.generateFunctionId("createConnection"),e=>({operation:"createConnection",db:(0,c.parseDbFromUrl)(e[0])}),void 0,s.OutboundType.MONGO),n.instrument_logger.debug("Wrapped mongoose.createConnection")):n.instrument_logger.warning("mongoose.createConnection not found")}static _patchQueryExec(e){const t=e.Query?.prototype;if(!t)return void n.instrument_logger.warning("Query.prototype not found");const r=t.exec;"function"==typeof r?(t.exec=(0,d.wrapOutboundFunction)(r,(e,t)=>{const r=t?.op;if(r&&r in C.QUERY_METHOD_CONFIG)return C.generateFunctionId(r)},v,(e,t,r)=>{const n=r.args?.operation;if(!n)return;const o=C.QUERY_METHOD_CONFIG[n];return o?o.resultParser(e):void 0},s.OutboundType.MONGO),n.instrument_logger.debug("Wrapped Query.prototype.exec")):n.instrument_logger.warning("Query.prototype.exec not found")}static _patchAggregateExec(e){const t=e.Aggregate?.prototype;if(!t)return void n.instrument_logger.warning("Aggregate.prototype not found");const r=t.exec;if("function"!=typeof r)return void n.instrument_logger.warning("Aggregate.prototype.exec not found");const o=C.generateFunctionId("aggregate");t.exec=(0,d.wrapOutboundFunction)(r,o,(e,t,r,n)=>({operation:"aggregate",collection:n?._model?.collection?.collectionName,db:n?._model?.db?.name,pipeline:n?._pipeline,options:(0,c.parseOptions)(n?.options)}),e=>({documentCount:Array.isArray(e)?e.length:void 0}),s.OutboundType.MONGO),n.instrument_logger.debug("Wrapped Aggregate.prototype.exec")}static _patchInsertMany(e){const t=e.Model;if(!t)return void n.instrument_logger.warning("Model not found");const r=t.insertMany;if("function"!=typeof r)return void n.instrument_logger.warning("Model.insertMany not found");const o=C.generateFunctionId("insertMany");t.insertMany=(0,d.wrapOutboundFunction)(r,o,(e,t,r,n)=>{const o=e[0],i=e[1];return{operation:"insertMany",collection:n?.collection?.collectionName,db:n?.db?.name,documentCount:Array.isArray(o)?o.length:1,insert:(0,c.getDocument)(Array.isArray(o)?o[0]:o),options:(0,c.parseOptions)(i)}},e=>Array.isArray(e)?{documentCount:e.length,acknowledged:!0}:{documentCount:e?.insertedCount,acknowledged:e?.acknowledged},s.OutboundType.MONGO),n.instrument_logger.debug("Wrapped Model.insertMany")}static _patchSave(e){const t=e.Model?.prototype;if(!t)return void n.instrument_logger.warning("Model.prototype not found");const r=t.save;if("function"!=typeof r)return void n.instrument_logger.warning("Model.prototype.save not found");const o=C.generateFunctionId("save");t.save=(0,d.wrapOutboundFunction)(r,o,k,(e,t,r)=>"insertOne"===r.args?.operation?{documentCount:1,acknowledged:!0}:{modifiedCount:void 0},s.OutboundType.MONGO),void 0!==t.$save&&(t.$save=t.save),n.instrument_logger.debug("Wrapped Model.prototype.save")}static generateFunctionId(e){return(0,i.functionUuidToBase64)((0,u.v5)(`mongoose-${e}`,i.hudConfig.functionUuidNamespace))}}t.default=C},9873:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FlowMetric=void 0;const o=r(8528),i=r(8269),s=n(r(932));t.FlowMetric=class{_state;flowId;duration;_startTime;_msStartTime;errorBreakdown;constructor(e){this.flowId=e,this.duration=-1,this._state="usable"}static createUsableMetric(e){return new this(e)._createUsableMetric(e)}setFlowId(e){this.flowId=e}getFlowId(){return this.flowId}getMsStartTime(){return this._msStartTime}start(){hudRunningMode===o.HudRunningMode.enabled&&(this._startTime=s.default.hrtime.bigint(),this._msStartTime=Date.now())}setErrorBreakdown(e){this.errorBreakdown=e}end(){hudRunningMode===o.HudRunningMode.enabled&&(-1===this.duration&&this.calculateDuration(),this.#e(),this._state="unusable")}calculateDuration(){this._startTime&&(this.duration=Number(s.default.hrtime.bigint()-this._startTime))}#e(){if(hudRunningMode===o.HudRunningMode.enabled){const e=this.toRaw();e&&(0,i.storeFlowMetric)(e)}}}},9938:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.redactOutboundResult=t.redactOutboundArgs=void 0,t.wrapOutboundFunction=function(e,t,r,n,o,i=!1,l){let f;if(e instanceof a.AsyncFunction){const a=(0,s.getWrapperTypeFromPrefix)("await",!0),g=(0,s.getWrapperTypeFromPrefix)("await",!1);f=async function(...f){let p,m,h,y;const b="function"==typeof t?t(f,this):t;if(void 0===b)return await e.apply(this,f);try{p=(0,s.wrapperInitial)(b,!0);const e=u(f,p,r,n,o,b,this,l);m=e?.outboundInvocation,h=e?.outboundIndex}catch{}try{const t=e.apply(this,f);try{(0,s.asyncWrapper)(p,a)}catch{}y=await t;try{(0,s.asyncWrapper)(p,g)}catch{}}catch(e){try{(0,s.wrapperCatch)(e,p,[]),i||d(e,h,m,p)}catch{}throw e}finally{try{(0,s.wrapperFinally)(p)}catch{}}if(!i){if(!p||2!==hudRunningMode)return y;c(y,h,m,p.start,n)}return y}}else f=function(...a){let f,g,p,m={};const h="function"==typeof t?t(a,this):t;if(void 0===h)return e.apply(this,a);try{m=(0,s.wrapperInitial)(h,!0);const e=u(a,m,r,n,o,h,this,l);f=e?.outboundInvocation,g=e?.outboundIndex}catch{}try{p=e.apply(this,a)}catch(e){try{(0,s.wrapperCatch)(e,m,[]),i||d(e,g,f,m)}catch{}throw e}finally{try{(0,s.wrapperFinally)(m)}catch{}}if(p instanceof Promise)return i?p:p.catch(e=>{throw d(e,g,f,m),e}).then(e=>m&&2===hudRunningMode?(c(e,g,f,m.start,n),e):e);if(!i){if(!m||2!==hudRunningMode)return p;c(p,g,f,m.start,n)}return p};return(0,a.copyPropertiesToTarget)(e,f),f},t.wrapOutboundBodyFunction=function(e,t,r,n){if(e instanceof a.AsyncFunction)return i.instrument_logger.warning("Wrap outbound body function doesn't support async functions"),e;const u=function(...i){let a,u,c,d;try{if(a=(0,s.wrapperInitial)(t,!0),u=r(this,i),void 0!==u){const e=(0,s.getInvestigationStorage)()?.getStore();void 0!==e&&e.status!==o.InvestigationStatus.Cleared&&(c=e.data.outbounds[u])}}catch{}try{d=e.apply(this,i)}catch(e){try{(0,s.wrapperCatch)(e,a,[]),f(e,c,u,a)}catch{}throw e}finally{try{(0,s.wrapperFinally)(a)}catch{}}return d instanceof Promise?d.catch(e=>{throw f(e,c,u,a),e}).then(e=>a&&2===hudRunningMode?(l(this,e,u,c,a.start,n),e):e):a&&2===hudRunningMode?(l(this,d,u,c,a.start,n),d):d};return(0,a.copyPropertiesToTarget)(e,u),u},t.getBodySize=function(e){if(e&&("string"==typeof e||e instanceof Buffer)&&e.length>0)return e.length},t.getReducedBody=m,t.reduceRequestArgsIfNeeded=function(e,t,r){try{const o=t.args;if(void 0===o)return;const i=r(e),s=isNaN(i)||0===i?void 0:i;o.bodySize=s,o.body=m(o.body,s,n.hudConfig.dynamicConfig.maxHTTPRequestBodySize)}catch(e){(0,i.limitedLogger)("Error reducing request args",{error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}};const n=r(5809),o=r(8528),i=r(523),s=r(7131),a=r(8949);function u(e,r,a,u,l,f,g,p){if(!r||2!==hudRunningMode)return;if(p?.has(r.wrappedCaller))return;const m=(0,s.getInvestigationStorage)()?.getStore();if(void 0===m||m.status!==o.InvestigationStatus.Open)return;if(m.data.outbounds.length>=n.hudConfig.dynamicConfig.maxTotalOutbounds)return void(0,i.limitedLogger)("max outbound calls reached");const h=m.data.outbounds.length;let y;try{void 0!==a&&h<n.hudConfig.dynamicConfig.maxOutboundCountWithData&&(y=a(e,e=>d(e,h,b,r),e=>c(e,h,b,r.start,u),g))}catch(e){(0,i.limitedLogger)("error parsing args",{error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const b={function_id:f,caller_id:r.wrappedCaller,type:l,args:y,timestamp:Date.now()};return(h>=n.hudConfig.dynamicConfig.maxOutboundCountWithData||!n.hudConfig.dynamicConfig.enableOutboundData)&&t.redactOutboundArgs[b.type](b.args),m.data.outbounds.push(b),{outboundInvocation:b,outboundIndex:h}}function c(e,r,o,s,a){try{if(void 0===r||void 0===o)return;if(void 0!==a&&r<n.hudConfig.dynamicConfig.maxOutboundCountWithData){let s;try{s=a(e,r,o)}catch(e){(0,i.limitedLogger)("error parsing result",{msg:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}(r>=n.hudConfig.dynamicConfig.maxOutboundCountWithData||!n.hudConfig.dynamicConfig.enableOutboundData)&&t.redactOutboundResult[o.type](s),o.result=s}const u=process.hrtime.bigint();o.duration=Number(u-s)}catch{}}function d(e,t,r,o){if(o&&2===hudRunningMode)try{if(void 0===r||void 0===t)return;r.error=t<n.hudConfig.dynamicConfig.maxOutboundCountWithData&&n.hudConfig.dynamicConfig.enableOutboundData?e:(0,s.extractName)(e),r.duration=Number(process.hrtime.bigint()-o.start)}catch{}}function l(e,r,s,a,u,c){try{if(void 0===s||void 0===a||a.type!==o.OutboundType.HTTP||void 0===a.result)return;try{const t=c(e,r);a.result.body=t?.body,a.result.bodySize=t?.bodySize}catch(e){(0,i.limitedLogger)("error getting body",{error:e instanceof Error?e.message:void 0,stack:e instanceof Error?e.stack:void 0})}const d=process.hrtime.bigint();a.bodyDuration=Number(d-u),(s>=n.hudConfig.dynamicConfig.maxOutboundCountWithData||!n.hudConfig.dynamicConfig.enableOutboundData)&&t.redactOutboundResult[o.OutboundType.HTTP](a.result)}catch{}}function f(e,t,r,o){if(o&&2===hudRunningMode)try{if(void 0===t||void 0===r)return;t.bodyError=r<n.hudConfig.dynamicConfig.maxOutboundCountWithData&&n.hudConfig.dynamicConfig.enableOutboundData?e:(0,s.extractName)(e),t.bodyDuration=Number(process.hrtime.bigint()-o.start)}catch{}}t.redactOutboundArgs={[o.OutboundType.HTTP]:e=>{void 0!==e&&(e.url=void 0,e.body=void 0)},[o.OutboundType.DB]:e=>{void 0!==e&&(e.query=void 0,e.params=void 0)},[o.OutboundType.REDIS]:e=>{void 0!==e&&(e.key=void 0,e.args=void 0)},[o.OutboundType.MONGO]:e=>{void 0!==e&&(e.query=void 0,e.pipeline=void 0,e.update=void 0,e.insert=void 0,e.key=void 0,void 0!==e.options&&(e.options.comment=void 0))}},t.redactOutboundResult={[o.OutboundType.HTTP]:e=>{void 0!==e&&(e.body=void 0)},[o.OutboundType.DB]:e=>{},[o.OutboundType.REDIS]:e=>{},[o.OutboundType.MONGO]:()=>{}};const g="[HUD_BODY_TOO_LONG]",p="[HUD_NO_CONTENT_LENGTH_HEADER]";function m(e,t,r){return void 0!==t&&t>r?g:void 0===t&&null!=e&&""!==e?p:e}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}return r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r(2197)})());
2
2
  //# sourceMappingURL=instrument.js.map
package/dist/cjs/wrap.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(global,()=>(()=>{"use strict";var t={4403:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SketchManager=void 0;const i=n(4602);e.SketchManager=class{binWidth;logBinWidth;constructor(t){this.binWidth=t,this.logBinWidth=Math.log(t)}binIndex(t){return Math.floor(Math.log(t)/this.logBinWidth)}indexToBinStart(t){return this.binWidth**t}newSketchDataWithValue(t){const e=this.binIndex(t),n=new i.SketchData;return n.indexShift=e,n[0]=1,n}add(t,e){const n=this.binIndex(e);let i=n-t.indexShift;i<0?(t.unshift(...new Array(-i).fill(0)),t.indexShift=n,i=n-t.indexShift):i>=t.length&&t.push(...new Array(i-t.length+1).fill(0)),t[i]+=1}zero(t){t.fill(0)}copy(t){const e=new i.SketchData;return e.indexShift=t.indexShift,e.push(...t),e}mergeIntoNoChecks(t,e){const n=e.indexShift-t.indexShift;for(let i=0;i<e.length;i++)t[i+n]+=e[i]}mergeInto(t,e){e.indexShift<t.indexShift&&(t.unshift(...new Array(t.indexShift-e.indexShift).fill(0)),t.indexShift=e.indexShift),e.indexShift+e.length>t.indexShift+t.length&&t.push(...new Array(e.indexShift+e.length-(t.indexShift+t.length)).fill(0)),this.mergeIntoNoChecks(t,e)}mergeMany(t){if(0===t.length)throw new Error("Cannot merge empty list of SketchData.");if(1===t.length)return this.copy(t[0]);let e=1/0,n=-1/0;for(const i of t)e=Math.min(e,i.indexShift),n=Math.max(n,i.indexShift+i.length-1);const r=new i.SketchData;r.indexShift=e,r.push(...new Array(n-e+1).fill(0));for(const e of t)this.mergeIntoNoChecks(r,e);return r}getQuantile(t,e){const n=t.reduce((t,e)=>t+e,0);if(0===n)throw new Error("Cannot get quantile of empty SketchData.");const i=n*e;let r,o=0;for(r=0;r<t.length&&(o+=t[r],!(o>=i));r++);const a=this.indexToBinStart(r+t.indexShift),u=(o-i)/t[r];return a*this.binWidth**(1-u)}encode(t){return{binWidth:this.binWidth,indexShift:t.indexShift,data:Array.from(t)}}decode(t){if(t.binWidth!==this.binWidth)throw new Error(`Should not decode sketch data with bin width ${t.binWidth} using SketchManager with bin width ${this.binWidth}.`);const e=new i.SketchData;return e.indexShift=t.indexShift,e.push(...t.data),e}}},4602:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SketchData=void 0,e.SketchData=class extends Array{indexShift=0;constructor(){super()}}},6042:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e._hudVersion=e.getWrapperTypeFromPrefix=e.asyncWrapper=e.wrapperUserCatch=e.fixStack=e.wrapperFinally=e.wrapperCatch=e.wrapperInitial=e.InvestigationStatus=e.kHudCaller=void 0,e.setHudExecutionAsyncResource=function(t){s=t},e.setFlowStateStorage=function(t){void 0===c&&(c=t)},e.getFlowStateStorage=l,e.getFlowState=function(){return c?.getStore()},e.setInvestigationStorage=function(t){void 0===d&&(d=t)},e.getInvestigationStorage=function(){return d},e.investigateError=f,e.extractName=g,e.extractMessage=function(t){if(t instanceof Error)return t.message?t.message:void 0},e.extractStackTrace=function(t){if(t instanceof Error)return t.stack?t.stack:void 0},e.asyncIteratorWrapper=function(t){if(t&&t[Symbol.asyncIterator])return t[Symbol.asyncIterator]();if(t&&t[Symbol.iterator])return new x(t[Symbol.iterator]());if(t&&t["@@asyncIterator"])return t["@@asyncIterator"]();if(t&&t["@@iterator"])return t["@@iterator"]();throw new TypeError("Object is not async iterable")};const o=n(4403),a=n(7830),u=new o.SketchManager(1.2);e.kHudCaller=Symbol.for("hudCaller");let c,s=()=>({});function l(){return c}var h;let d;function f(t,e,n,i){if(!globalThis.hudEnableInvestigation)return;if(void 0===d)return;const r=d.getStore();if(void 0===r||r.status!==h.Open||void 0===r.data)return;const o=globalThis.hudExceptionMaxLength??20;let a=r.data.exceptions.get(i);if(void 0===a){if(r.data.exceptions.size>=o)return;a={exception:i,executionFlow:[],caught:e},r.data.exceptions.set(i,a)}a.caught=e,r.data.caught=e;const u=globalThis.hudExecutionFlowMaxLength??20;a.executionFlow.length>=u||a.executionFlow.push({function_id:t.functionId,caller_id:t.wrappedCaller,args:globalThis.hudEnableInvestigationArgsSending?n:void 0,is_outbound_function:t.isOutbound??!1})}function g(t){return t instanceof Error?t.constructor?t.constructor.name:t.name?t.name:"Non-Deducible-Name-Exception":"Non-Error-Exception"}function S(t){t&&2===globalThis.hudRunningMode&&t.fixFlag&&(void 0!==s()[e.kHudCaller]?(globalThis.hudStack[1]=t.functionId,globalThis.hudStackIndex.value=1,s()[e.kHudCaller]=void 0):globalThis.hudStack[++globalThis.hudStackIndex.value]=t.functionId,t.fixFlag=!1)}var p;!function(t){t[t.Open=1]="Open",t[t.Closed=2]="Closed",t[t.Cleared=3]="Cleared"}(h||(e.InvestigationStatus=h={})),function(t){t[t.AWAIT_BEFORE=1]="AWAIT_BEFORE",t[t.AWAIT_AFTER=2]="AWAIT_AFTER",t[t.YIELD_BEFORE=3]="YIELD_BEFORE",t[t.YIELD_AFTER=4]="YIELD_AFTER"}(p||(p={}));class x{iterator;n;constructor(t){this.iterator=t,this.n=t.next}static AsyncFromSyncIteratorContinuation(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));const e=t.done;return Promise.resolve(t.value).then(function(t){return{value:t,done:e}})}next(...t){return x.AsyncFromSyncIteratorContinuation(this.n.call(this.iterator,...t))}return(t){const e=this.iterator.return;return void 0===e?Promise.resolve({value:t,done:!0}):x.AsyncFromSyncIteratorContinuation(e.call(this.iterator,t))}throw(t){const e=this.iterator.throw;return void 0===e?Promise.reject(t):x.AsyncFromSyncIteratorContinuation(e.call(this.iterator,t))}[Symbol.asyncIterator](){return this}}e.wrapperInitial=function(t,n){if(2===globalThis.hudRunningMode)try{const i=hudCalls[t]??={shouldDetach:!1};if(i.shouldDetach)return;const r=s(),o=r[e.kHudCaller];void 0!==o&&(r[e.kHudCaller]=void 0);const a=o??(globalThis.hudStackIndex.value<0?"":globalThis.hudStack[globalThis.hudStackIndex.value]),u=i[a]??={},c=l()?.getStore(),h=u[c?.flowId||""]??={count:0,samplingCounter:0,sampledCount:0,sum:0,exceptions:{},squareSum:0,sketch:null,isLinkedFunction:!1},d=h.samplingCounter++,f=!!n||(d>=5e3?d%103==0:hudSampleTable[d]),g=f?process.hrtime.bigint():0n;return c?.shouldLinkFunction&&(c.shouldLinkFunction=!1,h.isLinkedFunction=!0),hudStack[++hudStackIndex.value]=t,{functionId:t,callObj:h,wrappedCaller:a,sampleFlag:f,start:g,fixFlag:!1,isOutbound:n}}catch{return}},e.wrapperCatch=function(t,e,n){if(!e||2!==globalThis.hudRunningMode)return;const i=g(t),r=e.callObj;r.exceptions[i]??=0,r.exceptions[i]++,f(e,!1,n,t)},e.wrapperFinally=function(t){if(!t||2!==globalThis.hudRunningMode)return;t.fixFlag||hudStackIndex.value--;const e=t.callObj;if(e.count++,t.sampleFlag){const n=process.hrtime.bigint(),i=Number(n-t.start);i>0&&(e.sampledCount++,e.sum+=i,e.squareSum+=i*i,null===e.sketch?e.sketch=u.newSketchDataWithValue(i):u.add(e.sketch,i))}},e.fixStack=S,e.wrapperUserCatch=function(t,e,n){e&&2===globalThis.hudRunningMode&&(S(e),f(e,!0,n,t))},e.asyncWrapper=function(t,n){if(t&&2===globalThis.hudRunningMode)switch(n){case p.AWAIT_BEFORE:return function(t){globalThis.hudStackPop=!0,t.fixFlag=!0}(t);case p.AWAIT_AFTER:return function(t){globalThis.hudStack[1]=t.functionId,globalThis.hudStackIndex.value=1,s()[e.kHudCaller]=void 0,t.fixFlag=!1}(t);case p.YIELD_BEFORE:return function(t){globalThis.hudStackIndex.value--,t.fixFlag=!0}(t);case p.YIELD_AFTER:return function(t){globalThis.hudStack[++globalThis.hudStackIndex.value]=t.functionId,t.fixFlag=!1}(t)}},e.getWrapperTypeFromPrefix=function(t,e){return"await"===t?e?p.AWAIT_BEFORE:p.AWAIT_AFTER:e?p.YIELD_BEFORE:p.YIELD_AFTER},e._hudVersion=a.SDK_VERSION,r(n(4602),e),r(n(4403),e)},7830:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SDK_VERSION=void 0,e.SDK_VERSION="1.8.1"}},e={};return function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(6042)})());
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(global,()=>(()=>{"use strict";var t={4403:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SketchManager=void 0;const i=n(4602);e.SketchManager=class{binWidth;logBinWidth;constructor(t){this.binWidth=t,this.logBinWidth=Math.log(t)}binIndex(t){return Math.floor(Math.log(t)/this.logBinWidth)}indexToBinStart(t){return this.binWidth**t}newSketchDataWithValue(t){const e=this.binIndex(t),n=new i.SketchData;return n.indexShift=e,n[0]=1,n}add(t,e){const n=this.binIndex(e);let i=n-t.indexShift;i<0?(t.unshift(...new Array(-i).fill(0)),t.indexShift=n,i=n-t.indexShift):i>=t.length&&t.push(...new Array(i-t.length+1).fill(0)),t[i]+=1}zero(t){t.fill(0)}copy(t){const e=new i.SketchData;return e.indexShift=t.indexShift,e.push(...t),e}mergeIntoNoChecks(t,e){const n=e.indexShift-t.indexShift;for(let i=0;i<e.length;i++)t[i+n]+=e[i]}mergeInto(t,e){e.indexShift<t.indexShift&&(t.unshift(...new Array(t.indexShift-e.indexShift).fill(0)),t.indexShift=e.indexShift),e.indexShift+e.length>t.indexShift+t.length&&t.push(...new Array(e.indexShift+e.length-(t.indexShift+t.length)).fill(0)),this.mergeIntoNoChecks(t,e)}mergeMany(t){if(0===t.length)throw new Error("Cannot merge empty list of SketchData.");if(1===t.length)return this.copy(t[0]);let e=1/0,n=-1/0;for(const i of t)e=Math.min(e,i.indexShift),n=Math.max(n,i.indexShift+i.length-1);const r=new i.SketchData;r.indexShift=e,r.push(...new Array(n-e+1).fill(0));for(const e of t)this.mergeIntoNoChecks(r,e);return r}getQuantile(t,e){const n=t.reduce((t,e)=>t+e,0);if(0===n)throw new Error("Cannot get quantile of empty SketchData.");const i=n*e;let r,o=0;for(r=0;r<t.length&&(o+=t[r],!(o>=i));r++);const a=this.indexToBinStart(r+t.indexShift),c=(o-i)/t[r];return a*this.binWidth**(1-c)}encode(t){return{binWidth:this.binWidth,indexShift:t.indexShift,data:Array.from(t)}}decode(t){if(t.binWidth!==this.binWidth)throw new Error(`Should not decode sketch data with bin width ${t.binWidth} using SketchManager with bin width ${this.binWidth}.`);const e=new i.SketchData;return e.indexShift=t.indexShift,e.push(...t.data),e}}},4602:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SketchData=void 0,e.SketchData=class extends Array{indexShift=0;constructor(){super()}}},6042:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e._hudVersion=e.getWrapperTypeFromPrefix=e.asyncWrapper=e.wrapperUserCatch=e.fixStack=e.wrapperFinally=e.wrapperCatch=e.wrapperInitial=e.InvestigationStatus=e.kHudCaller=void 0,e.setHudExecutionAsyncResource=function(t){s=t},e.setFlowStateStorage=function(t){void 0===u&&(u=t)},e.getFlowStateStorage=l,e.getFlowState=function(){return u?.getStore()},e.setInvestigationStorage=function(t){void 0===d&&(d=t)},e.getInvestigationStorage=function(){return d},e.investigateError=f,e.extractName=g,e.extractMessage=function(t){if(t instanceof Error)return t.message?t.message:void 0},e.extractStackTrace=function(t){if(t instanceof Error)return t.stack?t.stack:void 0},e.asyncIteratorWrapper=function(t){if(t&&t[Symbol.asyncIterator])return t[Symbol.asyncIterator]();if(t&&t[Symbol.iterator])return new x(t[Symbol.iterator]());if(t&&t["@@asyncIterator"])return t["@@asyncIterator"]();if(t&&t["@@iterator"])return t["@@iterator"]();throw new TypeError("Object is not async iterable")};const o=n(4403),a=n(7830),c=new o.SketchManager(1.2);e.kHudCaller=Symbol.for("hudCaller");let u,s=()=>({});function l(){return u}var h;let d;function f(t,e,n,i){if(!globalThis.hudEnableInvestigation)return;if(void 0===d)return;const r=d.getStore();if(void 0===r||r.status!==h.Open||void 0===r.data)return;const o=globalThis.hudExceptionMaxLength??20;let a=r.data.exceptions.get(i);if(void 0===a){if(r.data.exceptions.size>=o)return;a={exception:i,executionFlow:[],caught:e},r.data.exceptions.set(i,a)}a.caught=e,r.data.caught=e;const c=globalThis.hudExecutionFlowMaxLength??20;a.executionFlow.length>=c||a.executionFlow.push({function_id:t.functionId,caller_id:t.wrappedCaller,args:globalThis.hudEnableInvestigationArgsSending?n:void 0,is_outbound_function:t.isOutbound??!1})}function g(t){return t instanceof Error?t.constructor?t.constructor.name:t.name?t.name:"Non-Deducible-Name-Exception":"Non-Error-Exception"}function S(t){t&&2===globalThis.hudRunningMode&&t.fixFlag&&(void 0!==s()[e.kHudCaller]?(globalThis.hudStack[1]=t.functionId,globalThis.hudStackIndex.value=1,s()[e.kHudCaller]=void 0):globalThis.hudStack[++globalThis.hudStackIndex.value]=t.functionId,t.fixFlag=!1)}var p;!function(t){t[t.Open=1]="Open",t[t.Closed=2]="Closed",t[t.Cleared=3]="Cleared"}(h||(e.InvestigationStatus=h={})),function(t){t[t.AWAIT_BEFORE=1]="AWAIT_BEFORE",t[t.AWAIT_AFTER=2]="AWAIT_AFTER",t[t.YIELD_BEFORE=3]="YIELD_BEFORE",t[t.YIELD_AFTER=4]="YIELD_AFTER"}(p||(p={}));class x{iterator;n;constructor(t){this.iterator=t,this.n=t.next}static AsyncFromSyncIteratorContinuation(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));const e=t.done;return Promise.resolve(t.value).then(function(t){return{value:t,done:e}})}next(...t){return x.AsyncFromSyncIteratorContinuation(this.n.call(this.iterator,...t))}return(t){const e=this.iterator.return;return void 0===e?Promise.resolve({value:t,done:!0}):x.AsyncFromSyncIteratorContinuation(e.call(this.iterator,t))}throw(t){const e=this.iterator.throw;return void 0===e?Promise.reject(t):x.AsyncFromSyncIteratorContinuation(e.call(this.iterator,t))}[Symbol.asyncIterator](){return this}}e.wrapperInitial=function(t,n){if(2===globalThis.hudRunningMode)try{const i=hudCalls[t]??={shouldDetach:!1};if(i.shouldDetach)return;const r=s(),o=r[e.kHudCaller];void 0!==o&&(r[e.kHudCaller]=void 0);const a=o??(globalThis.hudStackIndex.value<0?"":globalThis.hudStack[globalThis.hudStackIndex.value]),c=i[a]??={},u=l()?.getStore(),h=c[u?.flowId||""]??={count:0,samplingCounter:0,sampledCount:0,sum:0,exceptions:{},squareSum:0,sketch:null,isLinkedFunction:!1},d=h.samplingCounter++,f=!!n||(d>=5e3?d%103==0:hudSampleTable[d]),g=f?process.hrtime.bigint():0n;return u?.shouldLinkFunction&&(u.shouldLinkFunction=!1,h.isLinkedFunction=!0),hudStack[++hudStackIndex.value]=t,{functionId:t,callObj:h,wrappedCaller:a,sampleFlag:f,start:g,fixFlag:!1,isOutbound:n}}catch{return}},e.wrapperCatch=function(t,e,n){if(!e||2!==globalThis.hudRunningMode)return;const i=g(t),r=e.callObj;r.exceptions[i]??=0,r.exceptions[i]++,f(e,!1,n,t)},e.wrapperFinally=function(t){if(!t||2!==globalThis.hudRunningMode)return;t.fixFlag||hudStackIndex.value--;const e=t.callObj;if(e.count++,t.sampleFlag){const n=process.hrtime.bigint(),i=Number(n-t.start);i>0&&(e.sampledCount++,e.sum+=i,e.squareSum+=i*i,null===e.sketch?e.sketch=c.newSketchDataWithValue(i):c.add(e.sketch,i))}},e.fixStack=S,e.wrapperUserCatch=function(t,e,n){e&&2===globalThis.hudRunningMode&&(S(e),f(e,!0,n,t))},e.asyncWrapper=function(t,n){if(t&&2===globalThis.hudRunningMode)switch(n){case p.AWAIT_BEFORE:return function(t){globalThis.hudStackPop=!0,t.fixFlag=!0}(t);case p.AWAIT_AFTER:return function(t){globalThis.hudStack[1]=t.functionId,globalThis.hudStackIndex.value=1,s()[e.kHudCaller]=void 0,t.fixFlag=!1}(t);case p.YIELD_BEFORE:return function(t){globalThis.hudStackIndex.value--,t.fixFlag=!0}(t);case p.YIELD_AFTER:return function(t){globalThis.hudStack[++globalThis.hudStackIndex.value]=t.functionId,t.fixFlag=!1}(t)}},e.getWrapperTypeFromPrefix=function(t,e){return"await"===t?e?p.AWAIT_BEFORE:p.AWAIT_AFTER:e?p.YIELD_BEFORE:p.YIELD_AFTER},e._hudVersion=a.SDK_VERSION,r(n(4602),e),r(n(4403),e)},7830:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SDK_VERSION=void 0,e.SDK_VERSION="1.8.2-rc.451c8fe.0"}},e={};return function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(6042)})());
2
2
  //# sourceMappingURL=wrap.js.map
@@ -24,6 +24,8 @@ declare const HudOptionsSchema: z.ZodObject<{
24
24
  codegenieServerlessExpress: string;
25
25
  sqs: string;
26
26
  serverlessHttp: string;
27
+ mongodb: string;
28
+ mongoose: string;
27
29
  }>, z.ZodBoolean>,
28
30
  z.ZodRecord<z.ZodNativeEnum<{
29
31
  axios: string;
@@ -43,6 +45,8 @@ declare const HudOptionsSchema: z.ZodObject<{
43
45
  codegenieServerlessExpress: string;
44
46
  sqs: string;
45
47
  serverlessHttp: string;
48
+ mongodb: string;
49
+ mongoose: string;
46
50
  }>, z.ZodBoolean>
47
51
  ]>, Map<string, boolean>, Map<string, boolean> | Record<string, boolean>>>;
48
52
  maxMappedFunctions: z.ZodOptional<z.ZodNumber>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hud-sdk",
3
- "version": "1.8.1",
3
+ "version": "1.8.2-rc.451c8fe.0",
4
4
  "description": "Hud's Node SDK",
5
5
  "homepage": "https://www.hud.io/",
6
6
  "keywords": [
@@ -199,7 +199,7 @@
199
199
  "npm-run-all": "^4.1.5",
200
200
  "prettier": "3.2.5",
201
201
  "prettier-plugin-organize-imports": "^4.1.0",
202
- "rollup": "4.52.5",
202
+ "rollup": "4.59.0",
203
203
  "ts-loader": "9.5.1",
204
204
  "ts-node": "10.9.2",
205
205
  "typescript-eslint": "^8.38.0",
package/setup.d.ts CHANGED
@@ -24,6 +24,8 @@ declare const HudOptionsSchema: z.ZodObject<{
24
24
  codegenieServerlessExpress: string;
25
25
  sqs: string;
26
26
  serverlessHttp: string;
27
+ mongodb: string;
28
+ mongoose: string;
27
29
  }>, z.ZodBoolean>,
28
30
  z.ZodRecord<z.ZodNativeEnum<{
29
31
  axios: string;
@@ -43,6 +45,8 @@ declare const HudOptionsSchema: z.ZodObject<{
43
45
  codegenieServerlessExpress: string;
44
46
  sqs: string;
45
47
  serverlessHttp: string;
48
+ mongodb: string;
49
+ mongoose: string;
46
50
  }>, z.ZodBoolean>
47
51
  ]>, Map<string, boolean>, Map<string, boolean> | Record<string, boolean>>>;
48
52
  maxMappedFunctions: z.ZodOptional<z.ZodNumber>;