@dahawa/hawa-code 1.38.9 → 1.38.10

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.
package/cli.js CHANGED
@@ -15,7 +15,7 @@ var c5r=Object.create;var nJ=Object.defineProperty;var l5r=Object.getOwnProperty
15
15
  `);for(let o of n){if(!o)continue;let i=o.indexOf(":");if(i===-1)continue;let s=o.substring(0,i).toLowerCase(),a=o.substring(i+1).trim(),c=r.get(s);c&&Array.isArray(c)?c.push(a):c?r.set(s,[c,a]):r.set(s,a)}}return r}onRequestCreated({request:t}){let r=this.getConfig(),n=r.enabled!==!1;if((0,KH.safeExecuteInTheMiddle)(()=>!n||t.method==="CONNECT"||r.ignoreRequestHook?.(t),B=>B&&this._diag.error("caught ignoreRequestHook error: ",B),!0))return;let i=(0,cee.hrTime)(),s;try{s=new h7r.URL(t.path,t.origin)}catch(B){this._diag.warn("could not determine url.full:",B);return}let a=s.protocol.replace(":",""),c=this.getRequestMethod(t.method),l={[wl.ATTR_HTTP_REQUEST_METHOD]:c,[wl.ATTR_HTTP_REQUEST_METHOD_ORIGINAL]:t.method,[wl.ATTR_URL_FULL]:s.toString(),[wl.ATTR_URL_PATH]:s.pathname,[wl.ATTR_URL_QUERY]:s.search,[wl.ATTR_URL_SCHEME]:a},u={https:"443",http:"80"},d=s.hostname,p=s.port||u[a];l[wl.ATTR_SERVER_ADDRESS]=d,p&&!isNaN(Number(p))&&(l[wl.ATTR_SERVER_PORT]=Number(p));let A=this.parseRequestHeaders(t).get("user-agent");if(A){let B=Array.isArray(A)?A[A.length-1]:A;l[wl.ATTR_USER_AGENT_ORIGINAL]=B}let h=(0,KH.safeExecuteInTheMiddle)(()=>r.startSpanHook?.(t),B=>B&&this._diag.error("caught startSpanHook error: ",B),!0);h&&Object.entries(h).forEach(([B,F])=>{l[B]=F});let _=Og.context.active(),T=Og.trace.getSpan(_),y;r.requireParentforSpans&&(!T||!Og.trace.isSpanContextValid(T.spanContext()))?y=Og.trace.wrapSpanContext(Og.INVALID_SPAN_CONTEXT):y=this.tracer.startSpan(c==="_OTHER"?"HTTP":c,{kind:Og.SpanKind.CLIENT,attributes:l},_),(0,KH.safeExecuteInTheMiddle)(()=>r.requestHook?.(y,t),B=>B&&this._diag.error("caught requestHook error: ",B),!0);let I=Og.trace.setSpan(Og.context.active(),y),v={};Og.propagation.inject(I,v);let x=Object.entries(v);for(let B=0;B<x.length;B++){let[F,L]=x[B];typeof t.addHeader=="function"?t.addHeader(F,L):typeof t.headers=="string"?t.headers+=`${F}: ${L}\r
16
16
  `:Array.isArray(t.headers)&&t.headers.push(F,L)}this._recordFromReq.set(t,{span:y,attributes:l,startTime:i})}onRequestHeaders({request:t,socket:r}){let n=this._recordFromReq.get(t);if(!n)return;let o=this.getConfig(),{span:i}=n,{remoteAddress:s,remotePort:a}=r,c={[wl.ATTR_NETWORK_PEER_ADDRESS]:s,[wl.ATTR_NETWORK_PEER_PORT]:a};if(o.headersToSpanAttributes?.requestHeaders){let l=new Set(o.headersToSpanAttributes.requestHeaders.map(d=>d.toLowerCase())),u=this.parseRequestHeaders(t);for(let[d,p]of u.entries())if(l.has(d)){let f=Array.isArray(p)?p.join(", "):p;c[`http.request.header.${d}`]=f}}i.setAttributes(c)}onResponseHeaders({request:t,response:r}){let n=this._recordFromReq.get(t);if(!n)return;let{span:o,attributes:i}=n,s={[wl.ATTR_HTTP_RESPONSE_STATUS_CODE]:r.statusCode},a=this.getConfig();(0,KH.safeExecuteInTheMiddle)(()=>a.responseHook?.(o,{request:t,response:r}),l=>l&&this._diag.error("caught responseHook error: ",l),!0);let c=new Set;a.headersToSpanAttributes?.responseHeaders&&a.headersToSpanAttributes?.responseHeaders.forEach(l=>c.add(l.toLowerCase()));for(let l=0;l<r.headers.length;l=l+2){let u=r.headers[l].toString().toLowerCase(),d=r.headers[l+1];if(c.has(u)&&(s[`http.response.header.${u}`]=d.toString()),u==="content-length"){let p=Number(d.toString());isNaN(p)||(s["http.response.header.content-length"]=p)}}o.setAttributes(s),o.setStatus({code:r.statusCode>=400?Og.SpanStatusCode.ERROR:Og.SpanStatusCode.UNSET}),n.attributes=Object.assign(i,s)}onDone({request:t}){let r=this._recordFromReq.get(t);if(!r)return;let{span:n,attributes:o,startTime:i}=r;n.end(),this._recordFromReq.delete(t),this.recordRequestDuration(o,i)}onError({request:t,error:r}){let n=this._recordFromReq.get(t);if(!n)return;let{span:o,attributes:i,startTime:s}=n;o.recordException(r),o.setStatus({code:Og.SpanStatusCode.ERROR,message:r.message}),o.end(),this._recordFromReq.delete(t),i[wl.ATTR_ERROR_TYPE]=r.message,this.recordRequestDuration(i,s)}recordRequestDuration(t,r){let n={};[wl.ATTR_HTTP_RESPONSE_STATUS_CODE,wl.ATTR_HTTP_REQUEST_METHOD,wl.ATTR_SERVER_ADDRESS,wl.ATTR_SERVER_PORT,wl.ATTR_URL_SCHEME,wl.ATTR_ERROR_TYPE].forEach(s=>{s in t&&(n[s]=t[s])});let i=(0,cee.hrTimeToMilliseconds)((0,cee.hrTimeDuration)(r,(0,cee.hrTime)()))/1e3;this._httpClientDurationHistogram.record(i,n)}getRequestMethod(t){let r={CONNECT:!0,OPTIONS:!0,HEAD:!0,GET:!0,POST:!0,PUT:!0,PATCH:!0,DELETE:!0,TRACE:!0};return t.toUpperCase()in r?t.toUpperCase():"_OTHER"}};lee.UndiciInstrumentation=bRe});var iEt=S(uee=>{"use strict";Object.defineProperty(uee,"__esModule",{value:!0});uee.UndiciInstrumentation=void 0;var _7r=oEt();Object.defineProperty(uee,"UndiciInstrumentation",{enumerable:!0,get:function(){return _7r.UndiciInstrumentation}})});var dee=S(JH=>{"use strict";Object.defineProperty(JH,"__esModule",{value:!0});JH.ExpressLayerType=void 0;var I7r;(function(e){e.ROUTER="router",e.MIDDLEWARE="middleware",e.REQUEST_HANDLER="request_handler"})(I7r=JH.ExpressLayerType||(JH.ExpressLayerType={}))});var pee=S(ZH=>{"use strict";Object.defineProperty(ZH,"__esModule",{value:!0});ZH.AttributeNames=void 0;var v7r;(function(e){e.EXPRESS_TYPE="express.type",e.EXPRESS_NAME="express.name"})(v7r=ZH.AttributeNames||(ZH.AttributeNames={}))});var yRe=S(rL=>{"use strict";Object.defineProperty(rL,"__esModule",{value:!0});rL._LAYERS_STORE_PROPERTY=rL.kLayerPatched=void 0;rL.kLayerPatched=Symbol("express-layer-patched");rL._LAYERS_STORE_PROPERTY="__ot_middlewares"});var dEt=S(Ml=>{"use strict";Object.defineProperty(Ml,"__esModule",{value:!0});Ml.getActualMatchedRoute=Ml.getConstructedRoute=Ml.getLayerPath=Ml.asErrorAndMessage=Ml.isLayerIgnored=Ml.getLayerMetadata=Ml.getRouterPath=Ml.storeLayerPath=void 0;var CRe=dee(),nL=pee(),B1=yRe(),R7r=(e,t)=>(Array.isArray(e[B1._LAYERS_STORE_PROPERTY])===!1&&Object.defineProperty(e,B1._LAYERS_STORE_PROPERTY,{enumerable:!1,value:[]}),t===void 0?{isLayerPathStored:!1}:(e[B1._LAYERS_STORE_PROPERTY].push(t),{isLayerPathStored:!0}));Ml.storeLayerPath=R7r;var D7r=(e,t)=>{let r=t.handle?.stack?.[0];return r?.route?.path?`${e}${r.route.path}`:r?.handle?.stack?(0,Ml.getRouterPath)(e,r):e};Ml.getRouterPath=D7r;var N7r=(e,t,r)=>{if(t.name==="router"){let n=(0,Ml.getRouterPath)("",t),o=n||r||e||"/";return{attributes:{[nL.AttributeNames.EXPRESS_NAME]:o,[nL.AttributeNames.EXPRESS_TYPE]:CRe.ExpressLayerType.ROUTER},name:`router - ${o}`}}else return t.name==="bound dispatch"||t.name==="handle"?{attributes:{[nL.AttributeNames.EXPRESS_NAME]:(e||r)??"request handler",[nL.AttributeNames.EXPRESS_TYPE]:CRe.ExpressLayerType.REQUEST_HANDLER},name:`request handler${t.path?` - ${e||r}`:""}`}:{attributes:{[nL.AttributeNames.EXPRESS_NAME]:t.name,[nL.AttributeNames.EXPRESS_TYPE]:CRe.ExpressLayerType.MIDDLEWARE},name:`middleware - ${t.name}`}};Ml.getLayerMetadata=N7r;var x7r=(e,t)=>{if(typeof t=="string")return t===e;if(t instanceof RegExp)return t.test(e);if(typeof t=="function")return t(e);throw new TypeError("Pattern is in unsupported datatype")},O7r=(e,t,r)=>{if(Array.isArray(r?.ignoreLayersType)&&r?.ignoreLayersType?.includes(t))return!0;if(Array.isArray(r?.ignoreLayers)===!1)return!1;try{for(let n of r.ignoreLayers)if(x7r(e,n))return!0}catch{}return!1};Ml.isLayerIgnored=O7r;var w7r=e=>e instanceof Error?[e,e.message]:[String(e),String(e)];Ml.asErrorAndMessage=w7r;var M7r=e=>{let t=e[0];return Array.isArray(t)?t.map(r=>lEt(r)||"").join(","):lEt(t)};Ml.getLayerPath=M7r;var lEt=e=>{if(typeof e=="string")return e;if(e instanceof RegExp||typeof e=="number")return e.toString()};function uEt(e){let r=(Array.isArray(e[B1._LAYERS_STORE_PROPERTY])?e[B1._LAYERS_STORE_PROPERTY]:[]).filter(n=>n!=="/"&&n!=="/*");return r.length===1&&r[0]==="*"?"*":r.join("").replace(/\/{2,}/g,"/")}Ml.getConstructedRoute=uEt;function B7r(e){let t=Array.isArray(e[B1._LAYERS_STORE_PROPERTY])?e[B1._LAYERS_STORE_PROPERTY]:[];if(t.length===0)return;if(t.every(i=>i==="/"))return e.originalUrl==="/"?"/":void 0;let r=uEt(e);if(r==="*"||r.includes("/")&&(r.includes(",")||r.includes("\\")||r.includes("*")||r.includes("[")))return r;let n=r.startsWith("/")?r:`/${r}`;return n.length>0&&(e.originalUrl===n||e.originalUrl.startsWith(n)||k7r(n))?n:void 0}Ml.getActualMatchedRoute=B7r;function k7r(e){return e.includes(":")||e.includes("*")}});var pEt=S(oL=>{"use strict";Object.defineProperty(oL,"__esModule",{value:!0});oL.PACKAGE_NAME=oL.PACKAGE_VERSION=void 0;oL.PACKAGE_VERSION="0.57.0";oL.PACKAGE_NAME="@opentelemetry/instrumentation-express"});var hEt=S(mee=>{"use strict";Object.defineProperty(mee,"__esModule",{value:!0});mee.ExpressInstrumentation=void 0;var fEt=(Ys(),Hn(XA)),SE=zt(),mEt=dee(),gEt=pee(),_T=dEt(),AEt=pEt(),iL=(Nn(),Hn(Xi)),P7r=Ss(),fee=yRe(),IRe=class extends iL.InstrumentationBase{constructor(t={}){super(AEt.PACKAGE_NAME,AEt.PACKAGE_VERSION,t)}init(){return[new iL.InstrumentationNodeModuleDefinition("express",[">=4.0.0 <6"],t=>{let r=typeof t?.Router?.prototype?.route=="function",n=r?t.Router.prototype:t.Router;return(0,iL.isWrapped)(n.route)&&this._unwrap(n,"route"),this._wrap(n,"route",this._getRoutePatch()),(0,iL.isWrapped)(n.use)&&this._unwrap(n,"use"),this._wrap(n,"use",this._getRouterUsePatch()),(0,iL.isWrapped)(t.application.use)&&this._unwrap(t.application,"use"),this._wrap(t.application,"use",this._getAppUsePatch(r)),t},t=>{if(t===void 0)return;let n=typeof t?.Router?.prototype?.route=="function"?t.Router.prototype:t.Router;this._unwrap(n,"route"),this._unwrap(n,"use"),this._unwrap(t.application,"use")})]}_getRoutePatch(){let t=this;return function(r){return function(...o){let i=r.apply(this,o),s=this.stack[this.stack.length-1];return t._applyPatch(s,(0,_T.getLayerPath)(o)),i}}}_getRouterUsePatch(){let t=this;return function(r){return function(...o){let i=r.apply(this,o),s=this.stack[this.stack.length-1];return t._applyPatch(s,(0,_T.getLayerPath)(o)),i}}}_getAppUsePatch(t){let r=this;return function(n){return function(...i){let s=t?this.router:this._router,a=n.apply(this,i);if(s){let c=s.stack[s.stack.length-1];r._applyPatch(c,(0,_T.getLayerPath)(i))}return a}}}_applyPatch(t,r){let n=this;t[fee.kLayerPatched]!==!0&&(t[fee.kLayerPatched]=!0,this._wrap(t,"handle",o=>{if(o.length===4)return o;let i=function(s,a){let{isLayerPathStored:c}=(0,_T.storeLayerPath)(s,r),l=(0,_T.getConstructedRoute)(s),u=(0,_T.getActualMatchedRoute)(s),d={[P7r.ATTR_HTTP_ROUTE]:u},p=(0,_T.getLayerMetadata)(l,t,r),f=p.attributes[gEt.AttributeNames.EXPRESS_TYPE],A=(0,fEt.getRPCMetadata)(SE.context.active());if(A?.type===fEt.RPCType.HTTP&&(A.route=u),(0,_T.isLayerIgnored)(p.name,f,n.getConfig()))return f===mEt.ExpressLayerType.MIDDLEWARE&&s[fee._LAYERS_STORE_PROPERTY].pop(),o.apply(this,arguments);if(SE.trace.getSpan(SE.context.active())===void 0)return o.apply(this,arguments);let h=n._getSpanName({request:s,layerType:f,route:l},p.name),_=n.tracer.startSpan(h,{attributes:Object.assign(d,p.attributes)}),T=SE.context.active(),y=SE.trace.setSpan(T,_),{requestHook:I}=n.getConfig();I&&(0,iL.safeExecuteInTheMiddle)(()=>I(_,{request:s,layerType:f,route:l}),L=>{L&&SE.diag.error("express instrumentation: request hook failed",L)},!0);let v=!1;p.attributes[gEt.AttributeNames.EXPRESS_TYPE]===mEt.ExpressLayerType.ROUTER&&(_.end(),v=!0,y=T);let x=()=>{v===!1&&(v=!0,_.end())},B=Array.from(arguments),F=B.findIndex(L=>typeof L=="function");F>=0&&(arguments[F]=function(){let L=arguments[0],P=![void 0,null,"route","router"].includes(L);if(!v&&P){let[z,fe]=(0,_T.asErrorAndMessage)(L);_.recordException(z),_.setStatus({code:SE.SpanStatusCode.ERROR,message:fe})}v===!1&&(v=!0,s.res?.removeListener("finish",x),_.end()),!(s.route&&P)&&c&&s[fee._LAYERS_STORE_PROPERTY].pop();let q=B[F];return SE.context.bind(T,q).apply(this,arguments)});try{return SE.context.bind(y,o).apply(this,arguments)}catch(L){let[P,q]=(0,_T.asErrorAndMessage)(L);throw _.recordException(P),_.setStatus({code:SE.SpanStatusCode.ERROR,message:q}),L}finally{v||a.once("finish",x)}};for(let s in o)Object.defineProperty(i,s,{get(){return o[s]},set(a){o[s]=a}});return i}))}_getSpanName(t,r){let{spanNameHook:n}=this.getConfig();if(!(n instanceof Function))return r;try{return n(t,r)??r}catch(o){return SE.diag.error("express instrumentation: error calling span name rewrite hook",o),r}}};mee.ExpressInstrumentation=IRe});var _Et=S(Mv=>{"use strict";Object.defineProperty(Mv,"__esModule",{value:!0});Mv.AttributeNames=Mv.ExpressLayerType=Mv.ExpressInstrumentation=void 0;var L7r=hEt();Object.defineProperty(Mv,"ExpressInstrumentation",{enumerable:!0,get:function(){return L7r.ExpressInstrumentation}});var F7r=dee();Object.defineProperty(Mv,"ExpressLayerType",{enumerable:!0,get:function(){return F7r.ExpressLayerType}});var U7r=pee();Object.defineProperty(Mv,"AttributeNames",{enumerable:!0,get:function(){return U7r.AttributeNames}})});var REt=S((Wfi,vEt)=>{"use strict";vEt.exports=CEt;function CEt(e,t,r){e instanceof RegExp&&(e=yEt(e,r)),t instanceof RegExp&&(t=yEt(t,r));var n=IEt(e,t,r);return n&&{start:n[0],end:n[1],pre:r.slice(0,n[0]),body:r.slice(n[0]+e.length,n[1]),post:r.slice(n[1]+t.length)}}function yEt(e,t){var r=t.match(e);return r?r[0]:null}CEt.range=IEt;function IEt(e,t,r){var n,o,i,s,a,c=r.indexOf(e),l=r.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(n=[],i=r.length;u>=0&&!a;)u==c?(n.push(u),c=r.indexOf(e,u+1)):n.length==1?a=[n.pop(),l]:(o=n.pop(),o<i&&(i=o,s=l),l=r.indexOf(t,u+1)),u=c<l&&c>=0?c:l;n.length&&(a=[i,s])}return a}});var kEt=S((jfi,BEt)=>{var DEt=REt();BEt.exports=Y7r;var NEt="\0SLASH"+Math.random()+"\0",xEt="\0OPEN"+Math.random()+"\0",RRe="\0CLOSE"+Math.random()+"\0",OEt="\0COMMA"+Math.random()+"\0",wEt="\0PERIOD"+Math.random()+"\0";function vRe(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function q7r(e){return e.split("\\\\").join(NEt).split("\\{").join(xEt).split("\\}").join(RRe).split("\\,").join(OEt).split("\\.").join(wEt)}function $7r(e){return e.split(NEt).join("\\").split(xEt).join("{").split(RRe).join("}").split(OEt).join(",").split(wEt).join(".")}function MEt(e){if(!e)return[""];var t=[],r=DEt("{","}",e);if(!r)return e.split(",");var n=r.pre,o=r.body,i=r.post,s=n.split(",");s[s.length-1]+="{"+o+"}";var a=MEt(i);return i.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function Y7r(e){return e?(e.substr(0,2)==="{}"&&(e="\\{\\}"+e.substr(2)),XH(q7r(e),!0).map($7r)):[]}function V7r(e){return"{"+e+"}"}function z7r(e){return/^-?0\d/.test(e)}function W7r(e,t){return e<=t}function j7r(e,t){return e>=t}function XH(e,t){var r=[],n=DEt("{","}",e);if(!n)return[e];var o=n.pre,i=n.post.length?XH(n.post,!1):[""];if(/\$$/.test(n.pre))for(var s=0;s<i.length;s++){var a=o+"{"+n.body+"}"+i[s];r.push(a)}else{var c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),u=c||l,d=n.body.indexOf(",")>=0;if(!u&&!d)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+RRe+n.post,XH(e)):[e];var p;if(u)p=n.body.split(/\.\./);else if(p=MEt(n.body),p.length===1&&(p=XH(p[0],!1).map(V7r),p.length===1))return i.map(function(q){return n.pre+p[0]+q});var f;if(u){var A=vRe(p[0]),h=vRe(p[1]),_=Math.max(p[0].length,p[1].length),T=p.length==3?Math.abs(vRe(p[2])):1,y=W7r,I=h<A;I&&(T*=-1,y=j7r);var v=p.some(z7r);f=[];for(var x=A;y(x,h);x+=T){var B;if(l)B=String.fromCharCode(x),B==="\\"&&(B="");else if(B=String(x),v){var F=_-B.length;if(F>0){var L=new Array(F+1).join("0");x<0?B="-"+L+B.slice(1):B=L+B}}f.push(B)}}else{f=[];for(var P=0;P<p.length;P++)f.push.apply(f,XH(p[P],!1))}for(var P=0;P<f.length;P++)for(var s=0;s<i.length;s++){var a=o+f[P]+i[s];(!t||u||a)&&r.push(a)}}return r}});var wRe=S(bE=>{"use strict";Object.defineProperty(bE,"__esModule",{value:!0});bE.SpanNames=bE.TokenKind=bE.AllowedOperationTypes=void 0;var qKr;(function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"})(qKr=bE.AllowedOperationTypes||(bE.AllowedOperationTypes={}));var $Kr;(function(e){e.SOF="<SOF>",e.EOF="<EOF>",e.BANG="!",e.DOLLAR="$",e.AMP="&",e.PAREN_L="(",e.PAREN_R=")",e.SPREAD="...",e.COLON=":",e.EQUALS="=",e.AT="@",e.BRACKET_L="[",e.BRACKET_R="]",e.BRACE_L="{",e.PIPE="|",e.BRACE_R="}",e.NAME="Name",e.INT="Int",e.FLOAT="Float",e.STRING="String",e.BLOCK_STRING="BlockString",e.COMMENT="Comment"})($Kr=bE.TokenKind||(bE.TokenKind={}));var YKr;(function(e){e.EXECUTE="graphql.execute",e.PARSE="graphql.parse",e.RESOLVE="graphql.resolve",e.VALIDATE="graphql.validate",e.SCHEMA_VALIDATE="graphql.validateSchema",e.SCHEMA_PARSE="graphql.parseSchema"})(YKr=bE.SpanNames||(bE.SpanNames={}))});var MRe=S(sq=>{"use strict";Object.defineProperty(sq,"__esModule",{value:!0});sq.AttributeNames=void 0;var VKr;(function(e){e.SOURCE="graphql.source",e.FIELD_NAME="graphql.field.name",e.FIELD_PATH="graphql.field.path",e.FIELD_TYPE="graphql.field.type",e.OPERATION_TYPE="graphql.operation.type",e.OPERATION_NAME="graphql.operation.name",e.VARIABLES="graphql.variables.",e.ERROR_VALIDATION_NAME="graphql.validation.error"})(VKr=sq.AttributeNames||(sq.AttributeNames={}))});var bee=S(cL=>{"use strict";Object.defineProperty(cL,"__esModule",{value:!0});cL.OTEL_GRAPHQL_DATA_SYMBOL=cL.OTEL_PATCHED_SYMBOL=void 0;cL.OTEL_PATCHED_SYMBOL=Symbol.for("opentelemetry.patched");cL.OTEL_GRAPHQL_DATA_SYMBOL=Symbol.for("opentelemetry.graphql_data")});var dSt=S(yee=>{"use strict";Object.defineProperty(yee,"__esModule",{value:!0});yee.OPERATION_NOT_SUPPORTED=void 0;var kmi=bee();yee.OPERATION_NOT_SUPPORTED="Operation$operationName$not supported"});var ISt=S(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});uu.wrapFieldResolver=uu.wrapFields=uu.getSourceFromLocation=uu.getOperation=uu.endSpan=uu.addSpanSource=uu.addInputVariableAttributes=uu.isPromise=void 0;var uL=zt(),Lv=wRe(),lL=MRe(),eC=bee(),pSt=Object.values(Lv.AllowedOperationTypes),zKr=e=>typeof e?.then=="function";uu.isPromise=zKr;var WKr=e=>typeof e=="object"&&e!==null;function BRe(e,t,r){Array.isArray(r)?r.forEach((n,o)=>{BRe(e,`${t}.${o}`,n)}):r instanceof Object?Object.entries(r).forEach(([n,o])=>{BRe(e,`${t}.${n}`,o)}):e.setAttribute(`${lL.AttributeNames.VARIABLES}${String(t)}`,r)}function jKr(e,t){Object.entries(t).forEach(([r,n])=>{BRe(e,r,n)})}uu.addInputVariableAttributes=jKr;function ASt(e,t,r,n,o){let i=TSt(t,r,n,o);e.setAttribute(lL.AttributeNames.SOURCE,i)}uu.addSpanSource=ASt;function KKr(e,t,r,n,o){let i=hSt(r,o);if(i)return{field:i,spanAdded:!1};let a=t().flatResolveSpans?ESt(r):_St(r,o);return i={span:JKr(e,t,r,n,o,a)},eJr(r,o,i),{field:i,spanAdded:!0}}function JKr(e,t,r,n,o,i){let s={[lL.AttributeNames.FIELD_NAME]:n.fieldName,[lL.AttributeNames.FIELD_PATH]:o.join("."),[lL.AttributeNames.FIELD_TYPE]:n.returnType.toString()},a=e.startSpan(`${Lv.SpanNames.RESOLVE} ${s[lL.AttributeNames.FIELD_PATH]}`,{attributes:s},i?uL.trace.setSpan(uL.context.active(),i):void 0),c=r[eC.OTEL_GRAPHQL_DATA_SYMBOL].source,l=n.fieldNodes.find(u=>u.kind==="Field");return l&&ASt(a,c.loc,t().allowValues,l.loc?.start,l.loc?.end),a}function ZKr(e,t){t&&e.recordException(t),e.end()}uu.endSpan=ZKr;function XKr(e,t){if(!(!e||!Array.isArray(e.definitions)))return t?e.definitions.filter(r=>pSt.indexOf(r?.operation)!==-1).find(r=>t===r?.name?.value):e.definitions.find(r=>pSt.indexOf(r?.operation)!==-1)}uu.getOperation=XKr;function eJr(e,t,r){return e[eC.OTEL_GRAPHQL_DATA_SYMBOL].fields[t.join(".")]=r}function hSt(e,t){return e[eC.OTEL_GRAPHQL_DATA_SYMBOL].fields[t.join(".")]}function _St(e,t){for(let r=t.length-1;r>0;r--){let n=hSt(e,t.slice(0,r));if(n)return n.span}return ESt(e)}function ESt(e){return e[eC.OTEL_GRAPHQL_DATA_SYMBOL].span}function tJr(e,t){let r=[],n=t;for(;n;){let o=n.key;e&&typeof o=="number"&&(o="*"),r.push(String(o)),n=n.prev}return r.reverse()}function rJr(e){return SSt(`
17
17
  `,e)}function fSt(e){return SSt(" ",e)}function SSt(e,t){let r="";for(let n=0;n<t;n++)r+=e;return r}var nJr=[Lv.TokenKind.FLOAT,Lv.TokenKind.STRING,Lv.TokenKind.INT,Lv.TokenKind.BLOCK_STRING];function TSt(e,t=!1,r,n){let o="";if(e?.startToken){let i=typeof r=="number"?r:e.start,s=typeof n=="number"?n:e.end,a=e.startToken.next,c=1;for(;a;){if(a.start<i){a=a.next,c=a?.line;continue}if(a.end>s){a=a.next,c=a?.line;continue}let l=a.value||a.kind,u="";!t&&nJr.indexOf(a.kind)>=0&&(l="*"),a.kind===Lv.TokenKind.STRING&&(l=`"${l}"`),a.kind===Lv.TokenKind.EOF&&(l=""),a.line>c?(o+=rJr(a.line-c),c=a.line,u=fSt(a.column-1)):a.line===a.prev?.line&&(u=fSt(a.start-(a.prev?.end||0))),o+=u+l,a&&(a=a.next)}}return o}uu.getSourceFromLocation=TSt;function bSt(e,t,r){if(!e||e[eC.OTEL_PATCHED_SYMBOL])return;let n=e.getFields();e[eC.OTEL_PATCHED_SYMBOL]=!0,Object.keys(n).forEach(o=>{let i=n[o];if(i&&(i.resolve&&(i.resolve=CSt(t,r,i.resolve)),i.type)){let s=ySt(i.type);for(let a of s)bSt(a,t,r)}})}uu.wrapFields=bSt;function ySt(e){return"ofType"in e?ySt(e.ofType):oJr(e)?e.getTypes():iJr(e)?[e]:[]}function oJr(e){return"getTypes"in e&&typeof e.getTypes=="function"}function iJr(e){return"getFields"in e&&typeof e.getFields=="function"}var mSt=(e,t,r)=>{r&&(e.recordException(t),e.setStatus({code:uL.SpanStatusCode.ERROR,message:t.message}),e.end())},gSt=(e,t)=>{t&&e.end()};function CSt(e,t,r,n=!1){if(o[eC.OTEL_PATCHED_SYMBOL]||typeof r!="function")return r;function o(i,s,a,c){if(!r)return;let l=t();if(l.ignoreTrivialResolveSpans&&n&&(WKr(i)||typeof i=="function")&&typeof i[c.fieldName]!="function")return r.call(this,i,s,a,c);if(!a[eC.OTEL_GRAPHQL_DATA_SYMBOL])return r.call(this,i,s,a,c);let u=tJr(l.mergeItems,c&&c.path),d=u.filter(A=>typeof A=="string").length,p,f=!1;if(l.depth>=0&&l.depth<d)p=_St(a,u);else{let{field:A,spanAdded:h}=KKr(e,t,a,c,u);p=A.span,f=h}return uL.context.with(uL.trace.setSpan(uL.context.active(),p),()=>{try{let A=r.call(this,i,s,a,c);return(0,uu.isPromise)(A)?A.then(h=>(gSt(p,f),h),h=>{throw mSt(p,h,f),h}):(gSt(p,f),A)}catch(A){throw mSt(p,A,f),A}})}return o[eC.OTEL_PATCHED_SYMBOL]=!0,o}uu.wrapFieldResolver=CSt});var vSt=S(dL=>{"use strict";Object.defineProperty(dL,"__esModule",{value:!0});dL.PACKAGE_NAME=dL.PACKAGE_VERSION=void 0;dL.PACKAGE_VERSION="0.56.0";dL.PACKAGE_NAME="@opentelemetry/instrumentation-graphql"});var NSt=S(vee=>{"use strict";Object.defineProperty(vee,"__esModule",{value:!0});vee.GraphQLInstrumentation=void 0;var tC=zt(),ah=(Nn(),Hn(Xi)),aq=wRe(),Cee=MRe(),kRe=bee(),sJr=dSt(),fp=ISt(),RSt=vSt(),DSt={mergeItems:!1,depth:-1,allowValues:!1,ignoreResolveSpans:!1},Iee=[">=14.0.0 <17"],PRe=class extends ah.InstrumentationBase{constructor(t={}){super(RSt.PACKAGE_NAME,RSt.PACKAGE_VERSION,{...DSt,...t})}setConfig(t={}){super.setConfig({...DSt,...t})}init(){let t=new ah.InstrumentationNodeModuleDefinition("graphql",Iee);return t.files.push(this._addPatchingExecute()),t.files.push(this._addPatchingParser()),t.files.push(this._addPatchingValidate()),t}_addPatchingExecute(){return new ah.InstrumentationNodeModuleFile("graphql/execution/execute.js",Iee,t=>((0,ah.isWrapped)(t.execute)&&this._unwrap(t,"execute"),this._wrap(t,"execute",this._patchExecute(t.defaultFieldResolver)),t),t=>{t&&this._unwrap(t,"execute")})}_addPatchingParser(){return new ah.InstrumentationNodeModuleFile("graphql/language/parser.js",Iee,t=>((0,ah.isWrapped)(t.parse)&&this._unwrap(t,"parse"),this._wrap(t,"parse",this._patchParse()),t),t=>{t&&this._unwrap(t,"parse")})}_addPatchingValidate(){return new ah.InstrumentationNodeModuleFile("graphql/validation/validate.js",Iee,t=>((0,ah.isWrapped)(t.validate)&&this._unwrap(t,"validate"),this._wrap(t,"validate",this._patchValidate()),t),t=>{t&&this._unwrap(t,"validate")})}_patchExecute(t){let r=this;return function(o){return function(){let s;if(arguments.length>=2){let l=arguments;s=r._wrapExecuteArgs(l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7],t)}else{let l=arguments[0];s=r._wrapExecuteArgs(l.schema,l.document,l.rootValue,l.contextValue,l.variableValues,l.operationName,l.fieldResolver,l.typeResolver,t)}let a=(0,fp.getOperation)(s.document,s.operationName),c=r._createExecuteSpan(a,s);return s.contextValue[kRe.OTEL_GRAPHQL_DATA_SYMBOL]={source:s.document?s.document||s.document[kRe.OTEL_GRAPHQL_DATA_SYMBOL]:void 0,span:c,fields:{}},tC.context.with(tC.trace.setSpan(tC.context.active(),c),()=>(0,ah.safeExecuteInTheMiddle)(()=>o.apply(this,[s]),(l,u)=>{r._handleExecutionResult(c,l,u)}))}}}_handleExecutionResult(t,r,n){let o=this.getConfig();if(n===void 0||r){(0,fp.endSpan)(t,r);return}if((0,fp.isPromise)(n))n.then(i=>{if(typeof o.responseHook!="function"){(0,fp.endSpan)(t);return}this._executeResponseHook(t,i)},i=>{(0,fp.endSpan)(t,i)});else{if(typeof o.responseHook!="function"){(0,fp.endSpan)(t);return}this._executeResponseHook(t,n)}}_executeResponseHook(t,r){let{responseHook:n}=this.getConfig();n&&(0,ah.safeExecuteInTheMiddle)(()=>{n(t,r)},o=>{o&&this._diag.error("Error running response hook",o),(0,fp.endSpan)(t,void 0)},!0)}_patchParse(){let t=this;return function(n){return function(i,s){return t._parse(this,n,i,s)}}}_patchValidate(){let t=this;return function(n){return function(i,s,a,c,l){return t._validate(this,n,i,s,a,l,c)}}}_parse(t,r,n,o){let i=this.getConfig(),s=this.tracer.startSpan(aq.SpanNames.PARSE);return tC.context.with(tC.trace.setSpan(tC.context.active(),s),()=>(0,ah.safeExecuteInTheMiddle)(()=>r.call(t,n,o),(a,c)=>{c&&((0,fp.getOperation)(c)?c.loc&&(0,fp.addSpanSource)(s,c.loc,i.allowValues):s.updateName(aq.SpanNames.SCHEMA_PARSE)),(0,fp.endSpan)(s,a)}))}_validate(t,r,n,o,i,s,a){let c=this.tracer.startSpan(aq.SpanNames.VALIDATE,{});return tC.context.with(tC.trace.setSpan(tC.context.active(),c),()=>(0,ah.safeExecuteInTheMiddle)(()=>r.call(t,n,o,i,a,s),(l,u)=>{o.loc||c.updateName(aq.SpanNames.SCHEMA_VALIDATE),u&&u.length&&c.recordException({name:Cee.AttributeNames.ERROR_VALIDATION_NAME,message:JSON.stringify(u)}),(0,fp.endSpan)(c,l)}))}_createExecuteSpan(t,r){let n=this.getConfig(),o=this.tracer.startSpan(aq.SpanNames.EXECUTE,{});if(t){let{operation:i,name:s}=t;o.setAttribute(Cee.AttributeNames.OPERATION_TYPE,i);let a=s?.value;a?(o.setAttribute(Cee.AttributeNames.OPERATION_NAME,a),o.updateName(`${i} ${a}`)):o.updateName(i)}else{let i=" ";r.operationName&&(i=` "${r.operationName}" `),i=sJr.OPERATION_NOT_SUPPORTED.replace("$operationName$",i),o.setAttribute(Cee.AttributeNames.OPERATION_NAME,i)}return r.document?.loc&&(0,fp.addSpanSource)(o,r.document.loc,n.allowValues),r.variableValues&&n.allowValues&&(0,fp.addInputVariableAttributes)(o,r.variableValues),o}_wrapExecuteArgs(t,r,n,o,i,s,a,c,l){if(o||(o={}),o[kRe.OTEL_GRAPHQL_DATA_SYMBOL]||this.getConfig().ignoreResolveSpans)return{schema:t,document:r,rootValue:n,contextValue:o,variableValues:i,operationName:s,fieldResolver:a,typeResolver:c};let u=a==null,d=a??l;return a=(0,fp.wrapFieldResolver)(this.tracer,()=>this.getConfig(),d,u),t&&((0,fp.wrapFields)(t.getQueryType(),this.tracer,()=>this.getConfig()),(0,fp.wrapFields)(t.getMutationType(),this.tracer,()=>this.getConfig())),{schema:t,document:r,rootValue:n,contextValue:o,variableValues:i,operationName:s,fieldResolver:a,typeResolver:c}}};vee.GraphQLInstrumentation=PRe});var xSt=S(Ree=>{"use strict";Object.defineProperty(Ree,"__esModule",{value:!0});Ree.GraphQLInstrumentation=void 0;var aJr=NSt();Object.defineProperty(Ree,"GraphQLInstrumentation",{enumerable:!0,get:function(){return aJr.GraphQLInstrumentation}})});var LSt=S(Dee=>{"use strict";Object.defineProperty(Dee,"__esModule",{value:!0});Dee.EVENT_LISTENERS_SET=void 0;Dee.EVENT_LISTENERS_SET=Symbol("opentelemetry.instrumentation.kafkajs.eventListenersSet")});var FSt=S(Nee=>{"use strict";Object.defineProperty(Nee,"__esModule",{value:!0});Nee.bufferTextMapGetter=void 0;Nee.bufferTextMapGetter={get(e,t){if(!e)return;let r=Object.keys(e);for(let n of r)if(n===t||n.toLowerCase()===t)return e[n]?.toString()},keys(e){return e?Object.keys(e):[]}}});var USt=S(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.METRIC_MESSAGING_PROCESS_DURATION=Vo.METRIC_MESSAGING_CLIENT_SENT_MESSAGES=Vo.METRIC_MESSAGING_CLIENT_OPERATION_DURATION=Vo.METRIC_MESSAGING_CLIENT_CONSUMED_MESSAGES=Vo.MESSAGING_SYSTEM_VALUE_KAFKA=Vo.MESSAGING_OPERATION_TYPE_VALUE_SEND=Vo.MESSAGING_OPERATION_TYPE_VALUE_RECEIVE=Vo.MESSAGING_OPERATION_TYPE_VALUE_PROCESS=Vo.ATTR_MESSAGING_SYSTEM=Vo.ATTR_MESSAGING_OPERATION_TYPE=Vo.ATTR_MESSAGING_OPERATION_NAME=Vo.ATTR_MESSAGING_KAFKA_OFFSET=Vo.ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE=Vo.ATTR_MESSAGING_KAFKA_MESSAGE_KEY=Vo.ATTR_MESSAGING_DESTINATION_PARTITION_ID=Vo.ATTR_MESSAGING_DESTINATION_NAME=Vo.ATTR_MESSAGING_BATCH_MESSAGE_COUNT=void 0;Vo.ATTR_MESSAGING_BATCH_MESSAGE_COUNT="messaging.batch.message_count";Vo.ATTR_MESSAGING_DESTINATION_NAME="messaging.destination.name";Vo.ATTR_MESSAGING_DESTINATION_PARTITION_ID="messaging.destination.partition.id";Vo.ATTR_MESSAGING_KAFKA_MESSAGE_KEY="messaging.kafka.message.key";Vo.ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE="messaging.kafka.message.tombstone";Vo.ATTR_MESSAGING_KAFKA_OFFSET="messaging.kafka.offset";Vo.ATTR_MESSAGING_OPERATION_NAME="messaging.operation.name";Vo.ATTR_MESSAGING_OPERATION_TYPE="messaging.operation.type";Vo.ATTR_MESSAGING_SYSTEM="messaging.system";Vo.MESSAGING_OPERATION_TYPE_VALUE_PROCESS="process";Vo.MESSAGING_OPERATION_TYPE_VALUE_RECEIVE="receive";Vo.MESSAGING_OPERATION_TYPE_VALUE_SEND="send";Vo.MESSAGING_SYSTEM_VALUE_KAFKA="kafka";Vo.METRIC_MESSAGING_CLIENT_CONSUMED_MESSAGES="messaging.client.consumed.messages";Vo.METRIC_MESSAGING_CLIENT_OPERATION_DURATION="messaging.client.operation.duration";Vo.METRIC_MESSAGING_CLIENT_SENT_MESSAGES="messaging.client.sent.messages";Vo.METRIC_MESSAGING_PROCESS_DURATION="messaging.process.duration"});var QSt=S(pL=>{"use strict";Object.defineProperty(pL,"__esModule",{value:!0});pL.PACKAGE_NAME=pL.PACKAGE_VERSION=void 0;pL.PACKAGE_VERSION="0.18.0";pL.PACKAGE_NAME="@opentelemetry/instrumentation-kafkajs"});var VSt=S(Oee=>{"use strict";Object.defineProperty(Oee,"__esModule",{value:!0});Oee.KafkaJsInstrumentation=void 0;var Ts=zt(),ch=(Nn(),Hn(Xi)),fL=Ss(),GSt=LSt(),HSt=FSt(),Ir=USt(),qSt=QSt();function xee(e,t,r){return n=>{e.add(t,{...r,...n?{[fL.ATTR_ERROR_TYPE]:n}:{}})}}function $St(e,t,r){return n=>{e.record((Date.now()-t)/1e3,{...r,...n?{[fL.ATTR_ERROR_TYPE]:n}:{}})}}var YSt=[.005,.01,.025,.05,.075,.1,.25,.5,.75,1,2.5,5,7.5,10],LRe=class extends ch.InstrumentationBase{constructor(t={}){super(qSt.PACKAGE_NAME,qSt.PACKAGE_VERSION,t)}_updateMetricInstruments(){this._clientDuration=this.meter.createHistogram(Ir.METRIC_MESSAGING_CLIENT_OPERATION_DURATION,{advice:{explicitBucketBoundaries:YSt}}),this._sentMessages=this.meter.createCounter(Ir.METRIC_MESSAGING_CLIENT_SENT_MESSAGES),this._consumedMessages=this.meter.createCounter(Ir.METRIC_MESSAGING_CLIENT_CONSUMED_MESSAGES),this._processDuration=this.meter.createHistogram(Ir.METRIC_MESSAGING_PROCESS_DURATION,{advice:{explicitBucketBoundaries:YSt}})}init(){let t=n=>{(0,ch.isWrapped)(n?.Kafka?.prototype.producer)&&this._unwrap(n.Kafka.prototype,"producer"),(0,ch.isWrapped)(n?.Kafka?.prototype.consumer)&&this._unwrap(n.Kafka.prototype,"consumer")};return new ch.InstrumentationNodeModuleDefinition("kafkajs",[">=0.3.0 <3"],n=>(t(n),this._wrap(n?.Kafka?.prototype,"producer",this._getProducerPatch()),this._wrap(n?.Kafka?.prototype,"consumer",this._getConsumerPatch()),n),t)}_getConsumerPatch(){let t=this;return r=>function(...o){let i=r.apply(this,o);return(0,ch.isWrapped)(i.run)&&t._unwrap(i,"run"),t._wrap(i,"run",t._getConsumerRunPatch()),t._setKafkaEventListeners(i),i}}_setKafkaEventListeners(t){t[GSt.EVENT_LISTENERS_SET]||(t.events?.REQUEST&&t.on(t.events.REQUEST,this._recordClientDurationMetric.bind(this)),t[GSt.EVENT_LISTENERS_SET]=!0)}_recordClientDurationMetric(t){let[r,n]=t.payload.broker.split(":");this._clientDuration.record(t.payload.duration/1e3,{[Ir.ATTR_MESSAGING_SYSTEM]:Ir.MESSAGING_SYSTEM_VALUE_KAFKA,[Ir.ATTR_MESSAGING_OPERATION_NAME]:`${t.payload.apiName}`,[fL.ATTR_SERVER_ADDRESS]:r,[fL.ATTR_SERVER_PORT]:Number.parseInt(n,10)})}_getProducerPatch(){let t=this;return r=>function(...o){let i=r.apply(this,o);return(0,ch.isWrapped)(i.sendBatch)&&t._unwrap(i,"sendBatch"),t._wrap(i,"sendBatch",t._getSendBatchPatch()),(0,ch.isWrapped)(i.send)&&t._unwrap(i,"send"),t._wrap(i,"send",t._getSendPatch()),(0,ch.isWrapped)(i.transaction)&&t._unwrap(i,"transaction"),t._wrap(i,"transaction",t._getProducerTransactionPatch()),t._setKafkaEventListeners(i),i}}_getConsumerRunPatch(){let t=this;return r=>function(...o){let i=o[0];return i?.eachMessage&&((0,ch.isWrapped)(i.eachMessage)&&t._unwrap(i,"eachMessage"),t._wrap(i,"eachMessage",t._getConsumerEachMessagePatch())),i?.eachBatch&&((0,ch.isWrapped)(i.eachBatch)&&t._unwrap(i,"eachBatch"),t._wrap(i,"eachBatch",t._getConsumerEachBatchPatch())),r.call(this,i)}}_getConsumerEachMessagePatch(){let t=this;return r=>function(...o){let i=o[0],s=Ts.propagation.extract(Ts.ROOT_CONTEXT,i.message.headers,HSt.bufferTextMapGetter),a=t._startConsumerSpan({topic:i.topic,message:i.message,operationType:Ir.MESSAGING_OPERATION_TYPE_VALUE_PROCESS,ctx:s,attributes:{[Ir.ATTR_MESSAGING_DESTINATION_PARTITION_ID]:String(i.partition)}}),c=[$St(t._processDuration,Date.now(),{[Ir.ATTR_MESSAGING_SYSTEM]:Ir.MESSAGING_SYSTEM_VALUE_KAFKA,[Ir.ATTR_MESSAGING_OPERATION_NAME]:"process",[Ir.ATTR_MESSAGING_DESTINATION_NAME]:i.topic,[Ir.ATTR_MESSAGING_DESTINATION_PARTITION_ID]:String(i.partition)}),xee(t._consumedMessages,1,{[Ir.ATTR_MESSAGING_SYSTEM]:Ir.MESSAGING_SYSTEM_VALUE_KAFKA,[Ir.ATTR_MESSAGING_OPERATION_NAME]:"process",[Ir.ATTR_MESSAGING_DESTINATION_NAME]:i.topic,[Ir.ATTR_MESSAGING_DESTINATION_PARTITION_ID]:String(i.partition)})],l=Ts.context.with(Ts.trace.setSpan(s,a),()=>r.apply(this,o));return t._endSpansOnPromise([a],c,l)}}_getConsumerEachBatchPatch(){return t=>{let r=this;return function(...o){let i=o[0],s=r._startConsumerSpan({topic:i.batch.topic,message:void 0,operationType:Ir.MESSAGING_OPERATION_TYPE_VALUE_RECEIVE,ctx:Ts.ROOT_CONTEXT,attributes:{[Ir.ATTR_MESSAGING_BATCH_MESSAGE_COUNT]:i.batch.messages.length,[Ir.ATTR_MESSAGING_DESTINATION_PARTITION_ID]:String(i.batch.partition)}});return Ts.context.with(Ts.trace.setSpan(Ts.context.active(),s),()=>{let a=Date.now(),c=[],l=[xee(r._consumedMessages,i.batch.messages.length,{[Ir.ATTR_MESSAGING_SYSTEM]:Ir.MESSAGING_SYSTEM_VALUE_KAFKA,[Ir.ATTR_MESSAGING_OPERATION_NAME]:"process",[Ir.ATTR_MESSAGING_DESTINATION_NAME]:i.batch.topic,[Ir.ATTR_MESSAGING_DESTINATION_PARTITION_ID]:String(i.batch.partition)})];i.batch.messages.forEach(d=>{let p=Ts.propagation.extract(Ts.ROOT_CONTEXT,d.headers,HSt.bufferTextMapGetter),f=Ts.trace.getSpan(p)?.spanContext(),A;f&&(A={context:f}),c.push(r._startConsumerSpan({topic:i.batch.topic,message:d,operationType:Ir.MESSAGING_OPERATION_TYPE_VALUE_PROCESS,link:A,attributes:{[Ir.ATTR_MESSAGING_DESTINATION_PARTITION_ID]:String(i.batch.partition)}})),l.push($St(r._processDuration,a,{[Ir.ATTR_MESSAGING_SYSTEM]:Ir.MESSAGING_SYSTEM_VALUE_KAFKA,[Ir.ATTR_MESSAGING_OPERATION_NAME]:"process",[Ir.ATTR_MESSAGING_DESTINATION_NAME]:i.batch.topic,[Ir.ATTR_MESSAGING_DESTINATION_PARTITION_ID]:String(i.batch.partition)}))});let u=t.apply(this,o);return c.unshift(s),r._endSpansOnPromise(c,l,u)})}}}_getProducerTransactionPatch(){let t=this;return r=>function(...o){let i=t.tracer.startSpan("transaction"),s=r.apply(this,o);return s.then(a=>{let c=a.send;a.send=function(...f){return Ts.context.with(Ts.trace.setSpan(Ts.context.active(),i),()=>t._getSendPatch()(c).apply(this,f).catch(h=>{throw i.setStatus({code:Ts.SpanStatusCode.ERROR,message:h?.message}),i.recordException(h),h}))};let l=a.sendBatch;a.sendBatch=function(...f){return Ts.context.with(Ts.trace.setSpan(Ts.context.active(),i),()=>t._getSendBatchPatch()(l).apply(this,f).catch(h=>{throw i.setStatus({code:Ts.SpanStatusCode.ERROR,message:h?.message}),i.recordException(h),h}))};let u=a.commit;a.commit=function(...f){let A=u.apply(this,f).then(()=>{i.setStatus({code:Ts.SpanStatusCode.OK})});return t._endSpansOnPromise([i],[],A)};let d=a.abort;a.abort=function(...f){let A=d.apply(this,f);return t._endSpansOnPromise([i],[],A)}}).catch(a=>{i.setStatus({code:Ts.SpanStatusCode.ERROR,message:a?.message}),i.recordException(a),i.end()}),s}}_getSendBatchPatch(){let t=this;return r=>function(...o){let s=o[0].topicMessages||[],a=[],c=[];s.forEach(u=>{u.messages.forEach(d=>{a.push(t._startProducerSpan(u.topic,d)),c.push(xee(t._sentMessages,1,{[Ir.ATTR_MESSAGING_SYSTEM]:Ir.MESSAGING_SYSTEM_VALUE_KAFKA,[Ir.ATTR_MESSAGING_OPERATION_NAME]:"send",[Ir.ATTR_MESSAGING_DESTINATION_NAME]:u.topic,...d.partition!==void 0?{[Ir.ATTR_MESSAGING_DESTINATION_PARTITION_ID]:String(d.partition)}:{}}))})});let l=r.apply(this,o);return t._endSpansOnPromise(a,c,l)}}_getSendPatch(){let t=this;return r=>function(...o){let i=o[0],s=i.messages.map(l=>t._startProducerSpan(i.topic,l)),a=i.messages.map(l=>xee(t._sentMessages,1,{[Ir.ATTR_MESSAGING_SYSTEM]:Ir.MESSAGING_SYSTEM_VALUE_KAFKA,[Ir.ATTR_MESSAGING_OPERATION_NAME]:"send",[Ir.ATTR_MESSAGING_DESTINATION_NAME]:i.topic,...l.partition!==void 0?{[Ir.ATTR_MESSAGING_DESTINATION_PARTITION_ID]:String(l.partition)}:{}})),c=r.apply(this,o);return t._endSpansOnPromise(s,a,c)}}_endSpansOnPromise(t,r,n){return Promise.resolve(n).then(o=>(r.forEach(i=>i()),o)).catch(o=>{let i,s=fL.ERROR_TYPE_VALUE_OTHER;throw typeof o=="string"||o===void 0?i=o:typeof o=="object"&&Object.prototype.hasOwnProperty.call(o,"message")&&(i=o.message,s=o.constructor.name),r.forEach(a=>a(s)),t.forEach(a=>{a.setAttribute(fL.ATTR_ERROR_TYPE,s),a.setStatus({code:Ts.SpanStatusCode.ERROR,message:i})}),o}).finally(()=>{t.forEach(o=>o.end())})}_startConsumerSpan({topic:t,message:r,operationType:n,ctx:o,link:i,attributes:s}){let a=n===Ir.MESSAGING_OPERATION_TYPE_VALUE_RECEIVE?"poll":n,c=this.tracer.startSpan(`${a} ${t}`,{kind:n===Ir.MESSAGING_OPERATION_TYPE_VALUE_RECEIVE?Ts.SpanKind.CLIENT:Ts.SpanKind.CONSUMER,attributes:{...s,[Ir.ATTR_MESSAGING_SYSTEM]:Ir.MESSAGING_SYSTEM_VALUE_KAFKA,[Ir.ATTR_MESSAGING_DESTINATION_NAME]:t,[Ir.ATTR_MESSAGING_OPERATION_TYPE]:n,[Ir.ATTR_MESSAGING_OPERATION_NAME]:a,[Ir.ATTR_MESSAGING_KAFKA_MESSAGE_KEY]:r?.key?String(r.key):void 0,[Ir.ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE]:r?.key&&r.value===null?!0:void 0,[Ir.ATTR_MESSAGING_KAFKA_OFFSET]:r?.offset},links:i?[i]:[]},o),{consumerHook:l}=this.getConfig();return l&&r&&(0,ch.safeExecuteInTheMiddle)(()=>l(c,{topic:t,message:r}),u=>{u&&this._diag.error("consumerHook error",u)},!0),c}_startProducerSpan(t,r){let n=this.tracer.startSpan(`send ${t}`,{kind:Ts.SpanKind.PRODUCER,attributes:{[Ir.ATTR_MESSAGING_SYSTEM]:Ir.MESSAGING_SYSTEM_VALUE_KAFKA,[Ir.ATTR_MESSAGING_DESTINATION_NAME]:t,[Ir.ATTR_MESSAGING_KAFKA_MESSAGE_KEY]:r.key?String(r.key):void 0,[Ir.ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE]:r.key&&r.value===null?!0:void 0,[Ir.ATTR_MESSAGING_DESTINATION_PARTITION_ID]:r.partition!==void 0?String(r.partition):void 0,[Ir.ATTR_MESSAGING_OPERATION_NAME]:"send",[Ir.ATTR_MESSAGING_OPERATION_TYPE]:Ir.MESSAGING_OPERATION_TYPE_VALUE_SEND}});r.headers=r.headers??{},Ts.propagation.inject(Ts.trace.setSpan(Ts.context.active(),n),r.headers);let{producerHook:o}=this.getConfig();return o&&(0,ch.safeExecuteInTheMiddle)(()=>o(n,{topic:t,message:r}),i=>{i&&this._diag.error("producerHook error",i)},!0),n}};Oee.KafkaJsInstrumentation=LRe});var zSt=S(wee=>{"use strict";Object.defineProperty(wee,"__esModule",{value:!0});wee.KafkaJsInstrumentation=void 0;var uJr=VSt();Object.defineProperty(wee,"KafkaJsInstrumentation",{enumerable:!0,get:function(){return uJr.KafkaJsInstrumentation}})});var ZSt=S(mL=>{"use strict";Object.defineProperty(mL,"__esModule",{value:!0});mL.PACKAGE_NAME=mL.PACKAGE_VERSION=void 0;mL.PACKAGE_VERSION="0.53.0";mL.PACKAGE_NAME="@opentelemetry/instrumentation-lru-memoizer"});var rTt=S(Mee=>{"use strict";Object.defineProperty(Mee,"__esModule",{value:!0});Mee.LruMemoizerInstrumentation=void 0;var XSt=zt(),eTt=(Nn(),Hn(Xi)),tTt=ZSt(),FRe=class extends eTt.InstrumentationBase{constructor(t={}){super(tTt.PACKAGE_NAME,tTt.PACKAGE_VERSION,t)}init(){return[new eTt.InstrumentationNodeModuleDefinition("lru-memoizer",[">=1.3 <3"],t=>{let r=function(){let n=t.apply(this,arguments);return function(){let o=[...arguments],i=o.pop(),s=typeof i=="function"?XSt.context.bind(XSt.context.active(),i):i;return o.push(s),n.apply(this,o)}};return r.sync=t.sync,r},void 0)]}};Mee.LruMemoizerInstrumentation=FRe});var nTt=S(Bee=>{"use strict";Object.defineProperty(Bee,"__esModule",{value:!0});Bee.LruMemoizerInstrumentation=void 0;var pJr=rTt();Object.defineProperty(Bee,"LruMemoizerInstrumentation",{enumerable:!0,get:function(){return pJr.LruMemoizerInstrumentation}})});var cTt=S(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});Sc.METRIC_DB_CLIENT_CONNECTIONS_USAGE=Sc.DB_SYSTEM_VALUE_MONGODB=Sc.ATTR_NET_PEER_PORT=Sc.ATTR_NET_PEER_NAME=Sc.ATTR_DB_SYSTEM=Sc.ATTR_DB_STATEMENT=Sc.ATTR_DB_OPERATION=Sc.ATTR_DB_NAME=Sc.ATTR_DB_MONGODB_COLLECTION=Sc.ATTR_DB_CONNECTION_STRING=void 0;Sc.ATTR_DB_CONNECTION_STRING="db.connection_string";Sc.ATTR_DB_MONGODB_COLLECTION="db.mongodb.collection";Sc.ATTR_DB_NAME="db.name";Sc.ATTR_DB_OPERATION="db.operation";Sc.ATTR_DB_STATEMENT="db.statement";Sc.ATTR_DB_SYSTEM="db.system";Sc.ATTR_NET_PEER_NAME="net.peer.name";Sc.ATTR_NET_PEER_PORT="net.peer.port";Sc.DB_SYSTEM_VALUE_MONGODB="mongodb";Sc.METRIC_DB_CLIENT_CONNECTIONS_USAGE="db.client.connections.usage"});var lTt=S(cq=>{"use strict";Object.defineProperty(cq,"__esModule",{value:!0});cq.MongodbCommandType=void 0;var mJr;(function(e){e.CREATE_INDEXES="createIndexes",e.FIND_AND_MODIFY="findAndModify",e.IS_MASTER="isMaster",e.COUNT="count",e.AGGREGATE="aggregate",e.UNKNOWN="unknown"})(mJr=cq.MongodbCommandType||(cq.MongodbCommandType={}))});var uTt=S(gL=>{"use strict";Object.defineProperty(gL,"__esModule",{value:!0});gL.PACKAGE_NAME=gL.PACKAGE_VERSION=void 0;gL.PACKAGE_VERSION="0.61.0";gL.PACKAGE_NAME="@opentelemetry/instrumentation-mongodb"});var fTt=S(kee=>{"use strict";Object.defineProperty(kee,"__esModule",{value:!0});kee.MongoDBInstrumentation=void 0;var tc=zt(),oa=(Nn(),Hn(Xi)),ET=cTt(),Fv=lTt(),dTt=uTt(),pTt={requireParentSpan:!0},URe=class e extends oa.InstrumentationBase{constructor(t={}){super(dTt.PACKAGE_NAME,dTt.PACKAGE_VERSION,{...pTt,...t})}setConfig(t={}){super.setConfig({...pTt,...t})}_updateMetricInstruments(){this._connectionsUsage=this.meter.createUpDownCounter(ET.METRIC_DB_CLIENT_CONNECTIONS_USAGE,{description:"The number of connections that are currently in state described by the state attribute.",unit:"{connection}"})}init(){let{v3PatchConnection:t,v3UnpatchConnection:r}=this._getV3ConnectionPatches(),{v4PatchConnect:n,v4UnpatchConnect:o}=this._getV4ConnectPatches(),{v4PatchConnectionCallback:i,v4PatchConnectionPromise:s,v4UnpatchConnection:a}=this._getV4ConnectionPatches(),{v4PatchConnectionPool:c,v4UnpatchConnectionPool:l}=this._getV4ConnectionPoolPatches(),{v4PatchSessions:u,v4UnpatchSessions:d}=this._getV4SessionsPatches();return[new oa.InstrumentationNodeModuleDefinition("mongodb",[">=3.3.0 <4"],void 0,void 0,[new oa.InstrumentationNodeModuleFile("mongodb/lib/core/wireprotocol/index.js",[">=3.3.0 <4"],t,r)]),new oa.InstrumentationNodeModuleDefinition("mongodb",[">=4.0.0 <7"],void 0,void 0,[new oa.InstrumentationNodeModuleFile("mongodb/lib/cmap/connection.js",[">=4.0.0 <6.4"],i,a),new oa.InstrumentationNodeModuleFile("mongodb/lib/cmap/connection.js",[">=6.4.0 <7"],s,a),new oa.InstrumentationNodeModuleFile("mongodb/lib/cmap/connection_pool.js",[">=4.0.0 <6.4"],c,l),new oa.InstrumentationNodeModuleFile("mongodb/lib/cmap/connect.js",[">=4.0.0 <7"],n,o),new oa.InstrumentationNodeModuleFile("mongodb/lib/sessions.js",[">=4.0.0 <7"],u,d)])]}_getV3ConnectionPatches(){return{v3PatchConnection:t=>((0,oa.isWrapped)(t.insert)&&this._unwrap(t,"insert"),this._wrap(t,"insert",this._getV3PatchOperation("insert")),(0,oa.isWrapped)(t.remove)&&this._unwrap(t,"remove"),this._wrap(t,"remove",this._getV3PatchOperation("remove")),(0,oa.isWrapped)(t.update)&&this._unwrap(t,"update"),this._wrap(t,"update",this._getV3PatchOperation("update")),(0,oa.isWrapped)(t.command)&&this._unwrap(t,"command"),this._wrap(t,"command",this._getV3PatchCommand()),(0,oa.isWrapped)(t.query)&&this._unwrap(t,"query"),this._wrap(t,"query",this._getV3PatchFind()),(0,oa.isWrapped)(t.getMore)&&this._unwrap(t,"getMore"),this._wrap(t,"getMore",this._getV3PatchCursor()),t),v3UnpatchConnection:t=>{t!==void 0&&(this._unwrap(t,"insert"),this._unwrap(t,"remove"),this._unwrap(t,"update"),this._unwrap(t,"command"),this._unwrap(t,"query"),this._unwrap(t,"getMore"))}}}_getV4SessionsPatches(){return{v4PatchSessions:t=>((0,oa.isWrapped)(t.acquire)&&this._unwrap(t,"acquire"),this._wrap(t.ServerSessionPool.prototype,"acquire",this._getV4AcquireCommand()),(0,oa.isWrapped)(t.release)&&this._unwrap(t,"release"),this._wrap(t.ServerSessionPool.prototype,"release",this._getV4ReleaseCommand()),t),v4UnpatchSessions:t=>{t!==void 0&&((0,oa.isWrapped)(t.acquire)&&this._unwrap(t,"acquire"),(0,oa.isWrapped)(t.release)&&this._unwrap(t,"release"))}}}_getV4AcquireCommand(){let t=this;return r=>function(){let o=this.sessions.length,i=r.call(this),s=this.sessions.length;return o===s?t._connectionsUsage.add(1,{state:"used","pool.name":t._poolName}):o-1===s&&(t._connectionsUsage.add(-1,{state:"idle","pool.name":t._poolName}),t._connectionsUsage.add(1,{state:"used","pool.name":t._poolName})),i}}_getV4ReleaseCommand(){let t=this;return r=>function(o){let i=r.call(this,o);return t._connectionsUsage.add(-1,{state:"used","pool.name":t._poolName}),t._connectionsUsage.add(1,{state:"idle","pool.name":t._poolName}),i}}_getV4ConnectionPoolPatches(){return{v4PatchConnectionPool:t=>{let r=t.ConnectionPool.prototype;return(0,oa.isWrapped)(r.checkOut)&&this._unwrap(r,"checkOut"),this._wrap(r,"checkOut",this._getV4ConnectionPoolCheckOut()),t},v4UnpatchConnectionPool:t=>{t!==void 0&&this._unwrap(t.ConnectionPool.prototype,"checkOut")}}}_getV4ConnectPatches(){return{v4PatchConnect:t=>((0,oa.isWrapped)(t.connect)&&this._unwrap(t,"connect"),this._wrap(t,"connect",this._getV4ConnectCommand()),t),v4UnpatchConnect:t=>{t!==void 0&&this._unwrap(t,"connect")}}}_getV4ConnectionPoolCheckOut(){return t=>function(n){let o=tc.context.bind(tc.context.active(),n);return t.call(this,o)}}_getV4ConnectCommand(){let t=this;return r=>function(o,i){if(r.length===1){let a=r.call(this,o);return a&&typeof a.then=="function"&&a.then(()=>t.setPoolName(o),()=>{}),a}let s=function(a,c){if(a||!c){i(a,c);return}t.setPoolName(o),i(a,c)};return r.call(this,o,s)}}_getV4ConnectionPatches(){return{v4PatchConnectionCallback:t=>((0,oa.isWrapped)(t.Connection.prototype.command)&&this._unwrap(t.Connection.prototype,"command"),this._wrap(t.Connection.prototype,"command",this._getV4PatchCommandCallback()),t),v4PatchConnectionPromise:t=>((0,oa.isWrapped)(t.Connection.prototype.command)&&this._unwrap(t.Connection.prototype,"command"),this._wrap(t.Connection.prototype,"command",this._getV4PatchCommandPromise()),t),v4UnpatchConnection:t=>{t!==void 0&&this._unwrap(t.Connection.prototype,"command")}}}_getV3PatchOperation(t){let r=this;return n=>function(i,s,a,c,l){let u=tc.trace.getSpan(tc.context.active()),d=r._checkSkipInstrumentation(u),p=typeof c=="function"?c:l;if(d||typeof p!="function"||typeof a!="object")return typeof c=="function"?n.call(this,i,s,a,c):n.call(this,i,s,a,c,l);let f=r.tracer.startSpan(`mongodb.${t}`,{kind:tc.SpanKind.CLIENT});r._populateV3Attributes(f,s,i,a[0],t);let A=r._patchEnd(f,p);return typeof c=="function"?n.call(this,i,s,a,A):n.call(this,i,s,a,c,A)}}_getV3PatchCommand(){let t=this;return r=>function(o,i,s,a,c){let l=tc.trace.getSpan(tc.context.active()),u=t._checkSkipInstrumentation(l),d=typeof a=="function"?a:c;if(u||typeof d!="function"||typeof s!="object")return typeof a=="function"?r.call(this,o,i,s,a):r.call(this,o,i,s,a,c);let p=e._getCommandType(s),f=p===Fv.MongodbCommandType.UNKNOWN?"command":p,A=t.tracer.startSpan(`mongodb.${f}`,{kind:tc.SpanKind.CLIENT}),h=p===Fv.MongodbCommandType.UNKNOWN?void 0:p;t._populateV3Attributes(A,i,o,s,h);let _=t._patchEnd(A,d);return typeof a=="function"?r.call(this,o,i,s,_):r.call(this,o,i,s,a,_)}}_getV4PatchCommandCallback(){let t=this;return r=>function(o,i,s,a){let c=tc.trace.getSpan(tc.context.active()),l=t._checkSkipInstrumentation(c),u=a,d=Object.keys(i)[0];if(typeof i!="object"||i.ismaster||i.hello)return r.call(this,o,i,s,a);let p;l||(p=t.tracer.startSpan(`mongodb.${d}`,{kind:tc.SpanKind.CLIENT}),t._populateV4Attributes(p,this,o,i,d));let f=t._patchEnd(p,u,this.id,d);return r.call(this,o,i,s,f)}}_getV4PatchCommandPromise(){let t=this;return r=>function(...o){let[i,s]=o,a=tc.trace.getSpan(tc.context.active()),c=t._checkSkipInstrumentation(a),l=Object.keys(s)[0],u=()=>{};if(typeof s!="object"||s.ismaster||s.hello)return r.apply(this,o);let d;c||(d=t.tracer.startSpan(`mongodb.${l}`,{kind:tc.SpanKind.CLIENT}),t._populateV4Attributes(d,this,i,s,l));let p=t._patchEnd(d,u,this.id,l),f=r.apply(this,o);return f.then(A=>p(null,A),A=>p(A)),f}}_getV3PatchFind(){let t=this;return r=>function(o,i,s,a,c,l){let u=tc.trace.getSpan(tc.context.active()),d=t._checkSkipInstrumentation(u),p=typeof c=="function"?c:l;if(d||typeof p!="function"||typeof s!="object")return typeof c=="function"?r.call(this,o,i,s,a,c):r.call(this,o,i,s,a,c,l);let f=t.tracer.startSpan("mongodb.find",{kind:tc.SpanKind.CLIENT});t._populateV3Attributes(f,i,o,s,"find");let A=t._patchEnd(f,p);return typeof c=="function"?r.call(this,o,i,s,a,A):r.call(this,o,i,s,a,c,A)}}_getV3PatchCursor(){let t=this;return r=>function(o,i,s,a,c,l){let u=tc.trace.getSpan(tc.context.active()),d=t._checkSkipInstrumentation(u),p=typeof c=="function"?c:l;if(d||typeof p!="function")return typeof c=="function"?r.call(this,o,i,s,a,c):r.call(this,o,i,s,a,c,l);let f=t.tracer.startSpan("mongodb.getMore",{kind:tc.SpanKind.CLIENT});t._populateV3Attributes(f,i,o,s.cmd,"getMore");let A=t._patchEnd(f,p);return typeof c=="function"?r.call(this,o,i,s,a,A):r.call(this,o,i,s,a,c,A)}}static _getCommandType(t){return t.createIndexes!==void 0?Fv.MongodbCommandType.CREATE_INDEXES:t.findandmodify!==void 0?Fv.MongodbCommandType.FIND_AND_MODIFY:t.ismaster!==void 0?Fv.MongodbCommandType.IS_MASTER:t.count!==void 0?Fv.MongodbCommandType.COUNT:t.aggregate!==void 0?Fv.MongodbCommandType.AGGREGATE:Fv.MongodbCommandType.UNKNOWN}_populateV4Attributes(t,r,n,o,i){let s,a;if(r){let l=typeof r.address=="string"?r.address.split(":"):"";l.length===2&&(s=l[0],a=l[1])}let c;o?.documents&&o.documents[0]?c=o.documents[0]:o?.cursors?c=o.cursors:c=o,this._addAllSpanAttributes(t,n.db,n.collection,s,a,c,i)}_populateV3Attributes(t,r,n,o,i){let s,a;if(n&&n.s&&(s=n.s.options?.host??n.s.host,a=(n.s.options?.port??n.s.port)?.toString(),s==null||a==null)){let d=n.description?.address;if(d){let p=d.split(":");s=p[0],a=p[1]}}let[c,l]=r.toString().split("."),u=o?.query??o?.q??o;this._addAllSpanAttributes(t,c,l,s,a,u,i)}_addAllSpanAttributes(t,r,n,o,i,s,a){if(t.setAttributes({[ET.ATTR_DB_SYSTEM]:ET.DB_SYSTEM_VALUE_MONGODB,[ET.ATTR_DB_NAME]:r,[ET.ATTR_DB_MONGODB_COLLECTION]:n,[ET.ATTR_DB_OPERATION]:a,[ET.ATTR_DB_CONNECTION_STRING]:`mongodb://${o}:${i}/${r}`}),o&&i){t.setAttribute(ET.ATTR_NET_PEER_NAME,o);let u=parseInt(i,10);isNaN(u)||t.setAttribute(ET.ATTR_NET_PEER_PORT,u)}if(!s)return;let{dbStatementSerializer:c}=this.getConfig(),l=typeof c=="function"?c:this._defaultDbStatementSerializer.bind(this);(0,oa.safeExecuteInTheMiddle)(()=>{let u=l(s);t.setAttribute(ET.ATTR_DB_STATEMENT,u)},u=>{u&&this._diag.error("Error running dbStatementSerializer hook",u)},!0)}_getDefaultDbStatementReplacer(){let t=new WeakSet;return(r,n)=>typeof n!="object"||!n?"?":t.has(n)?"[Circular]":(t.add(n),n)}_defaultDbStatementSerializer(t){let{enhancedDatabaseReporting:r}=this.getConfig();return r?JSON.stringify(t):JSON.stringify(t,this._getDefaultDbStatementReplacer())}_handleExecutionResult(t,r){let{responseHook:n}=this.getConfig();typeof n=="function"&&(0,oa.safeExecuteInTheMiddle)(()=>{n(t,{data:r})},o=>{o&&this._diag.error("Error running response hook",o)},!0)}_patchEnd(t,r,n,o){let i=tc.context.active(),s=this;return function(...c){let l=c[0];if(t){if(l instanceof Error)t?.setStatus({code:tc.SpanStatusCode.ERROR,message:l.message});else{let u=c[1];s._handleExecutionResult(t,u)}t.end()}return tc.context.with(i,()=>(o==="endSessions"&&s._connectionsUsage.add(-1,{state:"idle","pool.name":s._poolName}),r.apply(this,c)))}}setPoolName(t){let r=t.hostAddress?.host,n=t.hostAddress?.port,o=t.dbName,i=`mongodb://${r}:${n}/${o}`;this._poolName=i}_checkSkipInstrumentation(t){return this.getConfig().requireParentSpan===!0&&t===void 0}};kee.MongoDBInstrumentation=URe});var mTt=S(lq=>{"use strict";Object.defineProperty(lq,"__esModule",{value:!0});lq.MongodbCommandType=void 0;var gJr;(function(e){e.CREATE_INDEXES="createIndexes",e.FIND_AND_MODIFY="findAndModify",e.IS_MASTER="isMaster",e.COUNT="count",e.UNKNOWN="unknown"})(gJr=lq.MongodbCommandType||(lq.MongodbCommandType={}))});var gTt=S(AL=>{"use strict";Object.defineProperty(AL,"__esModule",{value:!0});AL.MongodbCommandType=AL.MongoDBInstrumentation=void 0;var AJr=fTt();Object.defineProperty(AL,"MongoDBInstrumentation",{enumerable:!0,get:function(){return AJr.MongoDBInstrumentation}});var hJr=mTt();Object.defineProperty(AL,"MongodbCommandType",{enumerable:!0,get:function(){return hJr.MongodbCommandType}})});var GRe=S(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});Qu.ATTR_NET_PEER_PORT=Qu.ATTR_NET_PEER_NAME=Qu.ATTR_DB_USER=Qu.ATTR_DB_SYSTEM=Qu.ATTR_DB_STATEMENT=Qu.ATTR_DB_OPERATION=Qu.ATTR_DB_NAME=Qu.ATTR_DB_MONGODB_COLLECTION=void 0;Qu.ATTR_DB_MONGODB_COLLECTION="db.mongodb.collection";Qu.ATTR_DB_NAME="db.name";Qu.ATTR_DB_OPERATION="db.operation";Qu.ATTR_DB_STATEMENT="db.statement";Qu.ATTR_DB_SYSTEM="db.system";Qu.ATTR_DB_USER="db.user";Qu.ATTR_NET_PEER_NAME="net.peer.name";Qu.ATTR_NET_PEER_PORT="net.peer.port"});var bTt=S(Uv=>{"use strict";Object.defineProperty(Uv,"__esModule",{value:!0});Uv.handleCallbackResponse=Uv.handlePromiseResponse=Uv.getAttributesFromCollection=void 0;var STt=zt(),yJr=(Nn(),Hn(Xi)),uq=GRe();function CJr(e){return{[uq.ATTR_DB_MONGODB_COLLECTION]:e.name,[uq.ATTR_DB_NAME]:e.conn.name,[uq.ATTR_DB_USER]:e.conn.user,[uq.ATTR_NET_PEER_NAME]:e.conn.host,[uq.ATTR_NET_PEER_PORT]:e.conn.port}}Uv.getAttributesFromCollection=CJr;function TTt(e,t={}){e.recordException(t),e.setStatus({code:STt.SpanStatusCode.ERROR,message:`${t.message} ${t.code?`
18
- Mongoose Error Code: ${t.code}`:""}`})}function HRe(e,t,r,n=void 0){r&&(0,yJr.safeExecuteInTheMiddle)(()=>r(e,{moduleVersion:n,response:t}),o=>{o&&STt.diag.error("mongoose instrumentation: responseHook error",o)},!0)}function IJr(e,t,r,n=void 0){return e instanceof Promise?e.then(o=>(HRe(t,o,r,n),o)).catch(o=>{throw TTt(t,o),o}).finally(()=>t.end()):(HRe(t,e,r,n),t.end(),e)}Uv.handlePromiseResponse=IJr;function vJr(e,t,r,n,o,i,s=void 0){let a=0;return o.length===2?a=1:o.length===3&&(a=2),o[a]=(c,l)=>(c?TTt(n,c):HRe(n,l,i,s),n.end(),e(c,l)),t.apply(r,o)}Uv.handleCallbackResponse=vJr});var yTt=S(hL=>{"use strict";Object.defineProperty(hL,"__esModule",{value:!0});hL.PACKAGE_NAME=hL.PACKAGE_VERSION=void 0;hL.PACKAGE_VERSION="0.55.0";hL.PACKAGE_NAME="@opentelemetry/instrumentation-mongoose"});var DTt=S(ST=>{"use strict";Object.defineProperty(ST,"__esModule",{value:!0});ST.MongooseInstrumentation=ST._STORED_PARENT_SPAN=void 0;var Sd=zt(),RJr=(Ys(),Hn(XA)),qRe=bTt(),CTt=(Nn(),Hn(Xi)),ITt=yTt(),_L=GRe(),Pee=["deleteOne","deleteMany","find","findOne","estimatedDocumentCount","countDocuments","distinct","where","$where","findOneAndUpdate","findOneAndDelete","findOneAndReplace"],DJr=["remove","count","findOneAndRemove",...Pee],NJr=["count","findOneAndRemove",...Pee],xJr=[...Pee];function vTt(e){return e?e.startsWith("6.")||e.startsWith("5.")?DJr:e.startsWith("7.")?NJr:xJr:Pee}function RTt(e){return e&&(e.startsWith("5.")||e.startsWith("6."))||!1}ST._STORED_PARENT_SPAN=Symbol("stored-parent-span");var $Re=class extends CTt.InstrumentationBase{constructor(t={}){super(ITt.PACKAGE_NAME,ITt.PACKAGE_VERSION,t)}init(){return new CTt.InstrumentationNodeModuleDefinition("mongoose",[">=5.9.7 <9"],this.patch.bind(this),this.unpatch.bind(this))}patch(t,r){let n=t[Symbol.toStringTag]==="Module"?t.default:t;return this._wrap(n.Model.prototype,"save",this.patchOnModelMethods("save",r)),n.Model.prototype.$save=n.Model.prototype.save,RTt(r)&&this._wrap(n.Model.prototype,"remove",this.patchOnModelMethods("remove",r)),this._wrap(n.Query.prototype,"exec",this.patchQueryExec(r)),this._wrap(n.Aggregate.prototype,"exec",this.patchAggregateExec(r)),vTt(r).forEach(i=>{this._wrap(n.Query.prototype,i,this.patchAndCaptureSpanContext(i))}),this._wrap(n.Model,"aggregate",this.patchModelAggregate()),this._wrap(n.Model,"insertMany",this.patchModelStatic("insertMany",r)),this._wrap(n.Model,"bulkWrite",this.patchModelStatic("bulkWrite",r)),n}unpatch(t,r){let n=t[Symbol.toStringTag]==="Module"?t.default:t,o=vTt(r);this._unwrap(n.Model.prototype,"save"),n.Model.prototype.$save=n.Model.prototype.save,RTt(r)&&this._unwrap(n.Model.prototype,"remove"),this._unwrap(n.Query.prototype,"exec"),this._unwrap(n.Aggregate.prototype,"exec"),o.forEach(i=>{this._unwrap(n.Query.prototype,i)}),this._unwrap(n.Model,"aggregate"),this._unwrap(n.Model,"insertMany"),this._unwrap(n.Model,"bulkWrite")}patchAggregateExec(t){let r=this;return n=>function(i){if(r.getConfig().requireParentSpan&&Sd.trace.getSpan(Sd.context.active())===void 0)return n.apply(this,arguments);let s=this[ST._STORED_PARENT_SPAN],a={},{dbStatementSerializer:c}=r.getConfig();c&&(a[_L.ATTR_DB_STATEMENT]=c("aggregate",{options:this.options,aggregatePipeline:this._pipeline}));let l=r._startSpan(this._model.collection,this._model?.modelName,"aggregate",a,s);return r._handleResponse(l,n,this,arguments,i,t)}}patchQueryExec(t){let r=this;return n=>function(i){if(r.getConfig().requireParentSpan&&Sd.trace.getSpan(Sd.context.active())===void 0)return n.apply(this,arguments);let s=this[ST._STORED_PARENT_SPAN],a={},{dbStatementSerializer:c}=r.getConfig();c&&(a[_L.ATTR_DB_STATEMENT]=c(this.op,{condition:this._conditions,updates:this._update,options:this.options,fields:this._fields}));let l=r._startSpan(this.mongooseCollection,this.model.modelName,this.op,a,s);return r._handleResponse(l,n,this,arguments,i,t)}}patchOnModelMethods(t,r){let n=this;return o=>function(s,a){if(n.getConfig().requireParentSpan&&Sd.trace.getSpan(Sd.context.active())===void 0)return o.apply(this,arguments);let c={document:this};s&&!(s instanceof Function)&&(c.options=s);let l={},{dbStatementSerializer:u}=n.getConfig();u&&(l[_L.ATTR_DB_STATEMENT]=u(t,c));let d=n._startSpan(this.constructor.collection,this.constructor.modelName,t,l);return s instanceof Function&&(a=s,s=void 0),n._handleResponse(d,o,this,arguments,a,r)}}patchModelStatic(t,r){let n=this;return o=>function(s,a,c){if(n.getConfig().requireParentSpan&&Sd.trace.getSpan(Sd.context.active())===void 0)return o.apply(this,arguments);typeof a=="function"&&(c=a,a=void 0);let l={};switch(t){case"insertMany":l.documents=s;break;case"bulkWrite":l.operations=s;break;default:l.document=s;break}a!==void 0&&(l.options=a);let u={},{dbStatementSerializer:d}=n.getConfig();d&&(u[_L.ATTR_DB_STATEMENT]=d(t,l));let p=n._startSpan(this.collection,this.modelName,t,u);return n._handleResponse(p,o,this,arguments,c,r)}}patchModelAggregate(){let t=this;return r=>function(){let o=Sd.trace.getSpan(Sd.context.active()),i=t._callOriginalFunction(()=>r.apply(this,arguments));return i&&(i[ST._STORED_PARENT_SPAN]=o),i}}patchAndCaptureSpanContext(t){let r=this;return n=>function(){return this[ST._STORED_PARENT_SPAN]=Sd.trace.getSpan(Sd.context.active()),r._callOriginalFunction(()=>n.apply(this,arguments))}}_startSpan(t,r,n,o,i){return this.tracer.startSpan(`mongoose.${r}.${n}`,{kind:Sd.SpanKind.CLIENT,attributes:{...o,...(0,qRe.getAttributesFromCollection)(t),[_L.ATTR_DB_OPERATION]:n,[_L.ATTR_DB_SYSTEM]:"mongoose"}},i?Sd.trace.setSpan(Sd.context.active(),i):void 0)}_handleResponse(t,r,n,o,i,s=void 0){let a=this;if(i instanceof Function)return a._callOriginalFunction(()=>(0,qRe.handleCallbackResponse)(i,r,n,t,o,a.getConfig().responseHook,s));{let c=a._callOriginalFunction(()=>r.apply(n,o));return(0,qRe.handlePromiseResponse)(c,t,a.getConfig().responseHook,s)}}_callOriginalFunction(t){return this.getConfig().suppressInternalInstrumentation?Sd.context.with((0,RJr.suppressTracing)(Sd.context.active()),t):t()}};ST.MongooseInstrumentation=$Re});var NTt=S(Lee=>{"use strict";Object.defineProperty(Lee,"__esModule",{value:!0});Lee.MongooseInstrumentation=void 0;var OJr=DTt();Object.defineProperty(Lee,"MongooseInstrumentation",{enumerable:!0,get:function(){return OJr.MongooseInstrumentation}})});var YRe=S(kl=>{"use strict";Object.defineProperty(kl,"__esModule",{value:!0});kl.METRIC_DB_CLIENT_CONNECTIONS_USAGE=kl.DB_SYSTEM_VALUE_MYSQL=kl.ATTR_NET_PEER_PORT=kl.ATTR_NET_PEER_NAME=kl.ATTR_DB_USER=kl.ATTR_DB_SYSTEM=kl.ATTR_DB_STATEMENT=kl.ATTR_DB_NAME=kl.ATTR_DB_CONNECTION_STRING=void 0;kl.ATTR_DB_CONNECTION_STRING="db.connection_string";kl.ATTR_DB_NAME="db.name";kl.ATTR_DB_STATEMENT="db.statement";kl.ATTR_DB_SYSTEM="db.system";kl.ATTR_DB_USER="db.user";kl.ATTR_NET_PEER_NAME="net.peer.name";kl.ATTR_NET_PEER_PORT="net.peer.port";kl.DB_SYSTEM_VALUE_MYSQL="mysql";kl.METRIC_DB_CLIENT_CONNECTIONS_USAGE="db.client.connections.usage"});var BTt=S(dq=>{"use strict";Object.defineProperty(dq,"__esModule",{value:!0});dq.AttributeNames=void 0;var MJr;(function(e){e.MYSQL_VALUES="db.mysql.values"})(MJr=dq.AttributeNames||(dq.AttributeNames={}))});var PTt=S(fm=>{"use strict";Object.defineProperty(fm,"__esModule",{value:!0});fm.getPoolName=fm.arrayStringifyHelper=fm.getSpanName=fm.getDbValues=fm.getDbStatement=fm.getConnectionAttributes=void 0;var rC=YRe();function BJr(e){let{host:t,port:r,database:n,user:o}=kJr(e),i=parseInt(r,10);return isNaN(i)?{[rC.ATTR_NET_PEER_NAME]:t,[rC.ATTR_DB_CONNECTION_STRING]:kTt(t,r,n),[rC.ATTR_DB_NAME]:n,[rC.ATTR_DB_USER]:o}:{[rC.ATTR_NET_PEER_NAME]:t,[rC.ATTR_NET_PEER_PORT]:i,[rC.ATTR_DB_CONNECTION_STRING]:kTt(t,r,n),[rC.ATTR_DB_NAME]:n,[rC.ATTR_DB_USER]:o}}fm.getConnectionAttributes=BJr;function kJr(e){let{host:t,port:r,database:n,user:o}=e&&e.connectionConfig||e||{};return{host:t,port:r,database:n,user:o}}function kTt(e,t,r){let n=`jdbc:mysql://${e||"localhost"}`;return typeof t=="number"&&(n+=`:${t}`),typeof r=="string"&&(n+=`/${r}`),n}function PJr(e){return typeof e=="string"?e:e.sql}fm.getDbStatement=PJr;function LJr(e,t){return VRe(typeof e=="string"?t:t||e.values)}fm.getDbValues=LJr;function FJr(e){let t=typeof e=="object"?e.sql:e,r=t?.indexOf(" ");return typeof r=="number"&&r!==-1?t?.substring(0,r):t}fm.getSpanName=FJr;function VRe(e){return e?`[${e.toString()}]`:""}fm.arrayStringifyHelper=VRe;function UJr(e){let t=e.config.connectionConfig,r="";return r+=t.host?`host: '${t.host}', `:"",r+=t.port?`port: ${t.port}, `:"",r+=t.database?`database: '${t.database}', `:"",r+=t.user?`user: '${t.user}'`:"",t.user||(r=r.substring(0,r.length-2)),r.trim()}fm.getPoolName=UJr});var LTt=S(EL=>{"use strict";Object.defineProperty(EL,"__esModule",{value:!0});EL.PACKAGE_NAME=EL.PACKAGE_VERSION=void 0;EL.PACKAGE_VERSION="0.54.0";EL.PACKAGE_NAME="@opentelemetry/instrumentation-mysql"});var UTt=S(Uee=>{"use strict";Object.defineProperty(Uee,"__esModule",{value:!0});Uee.MySQLInstrumentation=void 0;var mm=zt(),SL=(Nn(),Hn(Xi)),Fee=YRe(),QJr=BTt(),TL=PTt(),FTt=LTt(),zRe=class e extends SL.InstrumentationBase{static COMMON_ATTRIBUTES={[Fee.ATTR_DB_SYSTEM]:Fee.DB_SYSTEM_VALUE_MYSQL};constructor(t={}){super(FTt.PACKAGE_NAME,FTt.PACKAGE_VERSION,t)}_updateMetricInstruments(){this._connectionsUsage=this.meter.createUpDownCounter(Fee.METRIC_DB_CLIENT_CONNECTIONS_USAGE,{description:"The number of connections that are currently in state described by the state attribute.",unit:"{connection}"})}init(){return[new SL.InstrumentationNodeModuleDefinition("mysql",[">=2.0.0 <3"],t=>((0,SL.isWrapped)(t.createConnection)&&this._unwrap(t,"createConnection"),this._wrap(t,"createConnection",this._patchCreateConnection()),(0,SL.isWrapped)(t.createPool)&&this._unwrap(t,"createPool"),this._wrap(t,"createPool",this._patchCreatePool()),(0,SL.isWrapped)(t.createPoolCluster)&&this._unwrap(t,"createPoolCluster"),this._wrap(t,"createPoolCluster",this._patchCreatePoolCluster()),t),t=>{t!==void 0&&(this._unwrap(t,"createConnection"),this._unwrap(t,"createPool"),this._unwrap(t,"createPoolCluster"))})]}_patchCreateConnection(){return t=>{let r=this;return function(o){let i=t(...arguments);return r._wrap(i,"query",r._patchQuery(i)),i}}}_patchCreatePool(){return t=>{let r=this;return function(o){let i=t(...arguments);return r._wrap(i,"query",r._patchQuery(i)),r._wrap(i,"getConnection",r._patchGetConnection(i)),r._wrap(i,"end",r._patchPoolEnd(i)),r._setPoolcallbacks(i,r,""),i}}}_patchPoolEnd(t){return r=>{let n=this;return function(i){let s=t._allConnections.length,a=t._freeConnections.length,c=s-a,l=(0,TL.getPoolName)(t);n._connectionsUsage.add(-c,{state:"used",name:l}),n._connectionsUsage.add(-a,{state:"idle",name:l}),r.apply(t,arguments)}}}_patchCreatePoolCluster(){return t=>{let r=this;return function(o){let i=t(...arguments);return r._wrap(i,"getConnection",r._patchGetConnection(i)),r._wrap(i,"add",r._patchAdd(i)),i}}}_patchAdd(t){return r=>{let n=this;return function(i,s){if(!n._enabled)return n._unwrap(t,"add"),r.apply(t,arguments);r.apply(t,arguments);let a=t._nodes;if(a){let c=typeof i=="object"?"CLUSTER::"+t._lastId:String(i),l=a[c].pool;n._setPoolcallbacks(l,n,i)}}}}_patchGetConnection(t){return r=>{let n=this;return function(i,s,a){if(!n._enabled)return n._unwrap(t,"getConnection"),r.apply(t,arguments);if(arguments.length===1&&typeof i=="function"){let c=n._getConnectionCallbackPatchFn(i);return r.call(t,c)}if(arguments.length===2&&typeof s=="function"){let c=n._getConnectionCallbackPatchFn(s);return r.call(t,i,c)}if(arguments.length===3&&typeof a=="function"){let c=n._getConnectionCallbackPatchFn(a);return r.call(t,i,s,c)}return r.apply(t,arguments)}}}_getConnectionCallbackPatchFn(t){let r=this,n=mm.context.active();return function(o,i){i&&((0,SL.isWrapped)(i.query)||r._wrap(i,"query",r._patchQuery(i))),typeof t=="function"&&mm.context.with(n,t,this,o,i)}}_patchQuery(t){return r=>{let n=this;return function(o,i,s){if(!n._enabled)return n._unwrap(t,"query"),r.apply(t,arguments);let a=n.tracer.startSpan((0,TL.getSpanName)(o),{kind:mm.SpanKind.CLIENT,attributes:{...e.COMMON_ATTRIBUTES,...(0,TL.getConnectionAttributes)(t.config)}});if(a.setAttribute(Fee.ATTR_DB_STATEMENT,(0,TL.getDbStatement)(o)),n.getConfig().enhancedDatabaseReporting){let u;Array.isArray(i)?u=i:arguments[2]&&(u=[i]),a.setAttribute(QJr.AttributeNames.MYSQL_VALUES,(0,TL.getDbValues)(o,u))}let c=Array.from(arguments).findIndex(u=>typeof u=="function"),l=mm.context.active();if(c===-1){let u=mm.context.with(mm.trace.setSpan(mm.context.active(),a),()=>r.apply(t,arguments));return mm.context.bind(l,u),u.on("error",d=>a.setStatus({code:mm.SpanStatusCode.ERROR,message:d.message})).on("end",()=>{a.end()})}else return n._wrap(arguments,c,n._patchCallbackQuery(a,l)),mm.context.with(mm.trace.setSpan(mm.context.active(),a),()=>r.apply(t,arguments))}}}_patchCallbackQuery(t,r){return n=>function(o,i,s){return o&&t.setStatus({code:mm.SpanStatusCode.ERROR,message:o.message}),t.end(),mm.context.with(r,()=>n(...arguments))}}_setPoolcallbacks(t,r,n){let o=n||(0,TL.getPoolName)(t);t.on("connection",i=>{r._connectionsUsage.add(1,{state:"idle",name:o})}),t.on("acquire",i=>{r._connectionsUsage.add(-1,{state:"idle",name:o}),r._connectionsUsage.add(1,{state:"used",name:o})}),t.on("release",i=>{r._connectionsUsage.add(-1,{state:"used",name:o}),r._connectionsUsage.add(1,{state:"idle",name:o})})}};Uee.MySQLInstrumentation=zRe});var QTt=S(Qee=>{"use strict";Object.defineProperty(Qee,"__esModule",{value:!0});Qee.MySQLInstrumentation=void 0;var GJr=UTt();Object.defineProperty(Qee,"MySQLInstrumentation",{enumerable:!0,get:function(){return GJr.MySQLInstrumentation}})});var WRe=S(Gu=>{"use strict";Object.defineProperty(Gu,"__esModule",{value:!0});Gu.DB_SYSTEM_VALUE_MYSQL=Gu.ATTR_NET_PEER_PORT=Gu.ATTR_NET_PEER_NAME=Gu.ATTR_DB_USER=Gu.ATTR_DB_SYSTEM=Gu.ATTR_DB_STATEMENT=Gu.ATTR_DB_NAME=Gu.ATTR_DB_CONNECTION_STRING=void 0;Gu.ATTR_DB_CONNECTION_STRING="db.connection_string";Gu.ATTR_DB_NAME="db.name";Gu.ATTR_DB_STATEMENT="db.statement";Gu.ATTR_DB_SYSTEM="db.system";Gu.ATTR_DB_USER="db.user";Gu.ATTR_NET_PEER_NAME="net.peer.name";Gu.ATTR_NET_PEER_PORT="net.peer.port";Gu.DB_SYSTEM_VALUE_MYSQL="mysql"});var KRe=S(Gee=>{"use strict";Object.defineProperty(Gee,"__esModule",{value:!0});Gee.addSqlCommenterComment=void 0;var jRe=zt(),qJr=(Ys(),Hn(XA));function $Jr(e){let t=e.indexOf("--");if(t>=0)return!0;if(e.indexOf("/*")<0)return!1;let n=e.indexOf("*/");return t<n}function YJr(e){return encodeURIComponent(e).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`)}function VJr(e,t){if(typeof t!="string"||t.length===0||$Jr(t))return t;let r=new qJr.W3CTraceContextPropagator,n={};r.inject(jRe.trace.setSpan(jRe.ROOT_CONTEXT,e),n,jRe.defaultTextMapSetter);let o=Object.keys(n).sort();if(o.length===0)return t;let i=o.map(s=>{let a=YJr(n[s]);return`${s}='${a}'`}).join(",");return`${t} /*${i}*/`}Gee.addSqlCommenterComment=VJr});var YTt=S(lh=>{"use strict";Object.defineProperty(lh,"__esModule",{value:!0});lh.getConnectionPrototypeToInstrument=lh.once=lh.getSpanName=lh.getQueryText=lh.getConnectionAttributes=void 0;var pq=WRe(),Hee=(Nn(),Hn(Xi)),JRe=Ss();function zJr(e,t,r){let{host:n,port:o,database:i,user:s}=WJr(e),a={};t&Hee.SemconvStability.OLD&&(a[pq.ATTR_DB_CONNECTION_STRING]=jJr(n,o,i),a[pq.ATTR_DB_NAME]=i,a[pq.ATTR_DB_USER]=s),t&Hee.SemconvStability.STABLE&&(a[JRe.ATTR_DB_NAMESPACE]=i);let c=parseInt(o,10);return r&Hee.SemconvStability.OLD&&(a[pq.ATTR_NET_PEER_NAME]=n,isNaN(c)||(a[pq.ATTR_NET_PEER_PORT]=c)),r&Hee.SemconvStability.STABLE&&(a[JRe.ATTR_SERVER_ADDRESS]=n,isNaN(c)||(a[JRe.ATTR_SERVER_PORT]=c)),a}lh.getConnectionAttributes=zJr;function WJr(e){let{host:t,port:r,database:n,user:o}=e&&e.connectionConfig||e||{};return{host:t,port:r,database:n,user:o}}function jJr(e,t,r){let n=`jdbc:mysql://${e||"localhost"}`;return typeof t=="number"&&(n+=`:${t}`),typeof r=="string"&&(n+=`/${r}`),n}function KJr(e,t,r,n=!1,o=JJr){let[i,s]=typeof e=="string"?[e,r]:[e.sql,ZJr(e)?r||e.values:r];try{return n?o(i):t&&s?t(i,s):i}catch{return"Could not determine the query due to an error in masking or formatting"}}lh.getQueryText=KJr;function JJr(e){return e.replace(/\b\d+\b/g,"?").replace(/(["'])(?:(?=(\\?))\2.)*?\1/g,"?")}function ZJr(e){return"values"in e}function XJr(e){let t=typeof e=="object"?e.sql:e,r=t?.indexOf(" ");return typeof r=="number"&&r!==-1?t?.substring(0,r):t}lh.getSpanName=XJr;var eZr=e=>{let t=!1;return(...r)=>{if(!t)return t=!0,e(...r)}};lh.once=eZr;function tZr(e){let t=e.prototype,r=Object.getPrototypeOf(t);return typeof r?.query=="function"&&typeof r?.execute=="function"?r:t}lh.getConnectionPrototypeToInstrument=tZr});var VTt=S(bL=>{"use strict";Object.defineProperty(bL,"__esModule",{value:!0});bL.PACKAGE_NAME=bL.PACKAGE_VERSION=void 0;bL.PACKAGE_VERSION="0.55.0";bL.PACKAGE_NAME="@opentelemetry/instrumentation-mysql2"});var KTt=S(qee=>{"use strict";Object.defineProperty(qee,"__esModule",{value:!0});qee.MySQL2Instrumentation=void 0;var zTt=zt(),yE=(Nn(),Hn(Xi)),ZRe=WRe(),WTt=KRe(),yL=YTt(),jTt=VTt(),XRe=Ss(),eDe=[">=1.4.2 <4"],tDe=class extends yE.InstrumentationBase{_netSemconvStability;_dbSemconvStability;constructor(t={}){super(jTt.PACKAGE_NAME,jTt.PACKAGE_VERSION,t),this._setSemconvStabilityFromEnv()}_setSemconvStabilityFromEnv(){this._netSemconvStability=(0,yE.semconvStabilityFromStr)("http",process.env.OTEL_SEMCONV_STABILITY_OPT_IN),this._dbSemconvStability=(0,yE.semconvStabilityFromStr)("database",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}init(){let t;function r(i){!t&&i.format&&(t=i.format)}let n=i=>{(0,yE.isWrapped)(i.query)&&this._unwrap(i,"query"),this._wrap(i,"query",this._patchQuery(t,!1)),(0,yE.isWrapped)(i.execute)&&this._unwrap(i,"execute"),this._wrap(i,"execute",this._patchQuery(t,!0))},o=i=>{this._unwrap(i,"query"),this._unwrap(i,"execute")};return[new yE.InstrumentationNodeModuleDefinition("mysql2",eDe,i=>(r(i),i),()=>{},[new yE.InstrumentationNodeModuleFile("mysql2/promise.js",eDe,i=>(r(i),i),()=>{}),new yE.InstrumentationNodeModuleFile("mysql2/lib/connection.js",eDe,i=>{let s=(0,yL.getConnectionPrototypeToInstrument)(i);return n(s),i},i=>{if(i===void 0)return;let s=(0,yL.getConnectionPrototypeToInstrument)(i);o(s)})])]}_patchQuery(t,r){return n=>{let o=this;return function(i,s,a){let c;Array.isArray(s)?c=s:arguments[2]&&(c=[s]);let{maskStatement:l,maskStatementHook:u,responseHook:d}=o.getConfig(),p=(0,yL.getConnectionAttributes)(this.config,o._dbSemconvStability,o._netSemconvStability),f=(0,yL.getQueryText)(i,t,c,l,u);o._dbSemconvStability&yE.SemconvStability.OLD&&(p[ZRe.ATTR_DB_SYSTEM]=ZRe.DB_SYSTEM_VALUE_MYSQL,p[ZRe.ATTR_DB_STATEMENT]=f),o._dbSemconvStability&yE.SemconvStability.STABLE&&(p[XRe.ATTR_DB_SYSTEM_NAME]=XRe.DB_SYSTEM_NAME_VALUE_MYSQL,p[XRe.ATTR_DB_QUERY_TEXT]=f);let A=o.tracer.startSpan((0,yL.getSpanName)(i),{kind:zTt.SpanKind.CLIENT,attributes:p});!r&&o.getConfig().addSqlCommenterCommentToQueries&&(arguments[0]=i=typeof i=="string"?(0,WTt.addSqlCommenterComment)(A,i):Object.assign(i,{sql:(0,WTt.addSqlCommenterComment)(A,i.sql)}));let h=(0,yL.once)((_,T)=>{_?A.setStatus({code:zTt.SpanStatusCode.ERROR,message:_.message}):typeof d=="function"&&(0,yE.safeExecuteInTheMiddle)(()=>{d(A,{queryResults:T})},y=>{y&&o._diag.warn("Failed executing responseHook",y)},!0),A.end()});if(arguments.length===1){typeof i.onResult=="function"&&o._wrap(i,"onResult",o._patchCallbackQuery(h));let _=n.apply(this,arguments);return _.once("error",T=>{h(T)}).once("result",T=>{h(void 0,T)}),_}return typeof arguments[1]=="function"?o._wrap(arguments,1,o._patchCallbackQuery(h)):typeof arguments[2]=="function"&&o._wrap(arguments,2,o._patchCallbackQuery(h)),n.apply(this,arguments)}}}_patchCallbackQuery(t){return r=>function(n,o,i){return t(n,o),r(...arguments)}}};qee.MySQL2Instrumentation=tDe});var JTt=S($ee=>{"use strict";Object.defineProperty($ee,"__esModule",{value:!0});$ee.MySQL2Instrumentation=void 0;var rZr=KTt();Object.defineProperty($ee,"MySQL2Instrumentation",{enumerable:!0,get:function(){return rZr.MySQL2Instrumentation}})});var rbt=S(gm=>{"use strict";Object.defineProperty(gm,"__esModule",{value:!0});gm.DB_SYSTEM_VALUE_REDIS=gm.ATTR_NET_PEER_PORT=gm.ATTR_NET_PEER_NAME=gm.ATTR_DB_SYSTEM=gm.ATTR_DB_STATEMENT=gm.ATTR_DB_CONNECTION_STRING=void 0;gm.ATTR_DB_CONNECTION_STRING="db.connection_string";gm.ATTR_DB_STATEMENT="db.statement";gm.ATTR_DB_SYSTEM="db.system";gm.ATTR_NET_PEER_NAME="net.peer.name";gm.ATTR_NET_PEER_PORT="net.peer.port";gm.DB_SYSTEM_VALUE_REDIS="redis"});var nbt=S(Yee=>{"use strict";Object.defineProperty(Yee,"__esModule",{value:!0});Yee.endSpan=void 0;var oZr=zt(),iZr=(e,t)=>{t&&(e.recordException(t),e.setStatus({code:oZr.SpanStatusCode.ERROR,message:t.message})),e.end()};Yee.endSpan=iZr});var zee=S(Vee=>{"use strict";Object.defineProperty(Vee,"__esModule",{value:!0});Vee.defaultDbStatementSerializer=void 0;var sZr=[{regex:/^ECHO/i,args:0},{regex:/^(LPUSH|MSET|PFA|PUBLISH|RPUSH|SADD|SET|SPUBLISH|XADD|ZADD)/i,args:1},{regex:/^(HSET|HMSET|LSET|LINSERT)/i,args:2},{regex:/^(ACL|BIT|B[LRZ]|CLIENT|CLUSTER|CONFIG|COMMAND|DECR|DEL|EVAL|EX|FUNCTION|GEO|GET|HINCR|HMGET|HSCAN|INCR|L[TRLM]|MEMORY|P[EFISTU]|RPOP|S[CDIMORSU]|XACK|X[CDGILPRT]|Z[CDILMPRS])/i,args:-1}],aZr=(e,t)=>{if(Array.isArray(t)&&t.length){let r=sZr.find(({regex:o})=>o.test(e))?.args??0,n=r>=0?t.slice(0,r):t;return t.length>n.length&&n.push(`[${t.length-r} other arguments]`),`${e} ${n.join(" ")}`}return e};Vee.defaultDbStatementSerializer=aZr});var obt=S(CL=>{"use strict";Object.defineProperty(CL,"__esModule",{value:!0});CL.PACKAGE_NAME=CL.PACKAGE_VERSION=void 0;CL.PACKAGE_VERSION="0.56.0";CL.PACKAGE_NAME="@opentelemetry/instrumentation-ioredis"});var cbt=S(jee=>{"use strict";Object.defineProperty(jee,"__esModule",{value:!0});jee.IORedisInstrumentation=void 0;var Qv=zt(),Wee=(Nn(),Hn(Xi)),uh=rbt(),ibt=(Nn(),Hn(Xi)),fq=nbt(),cZr=zee(),sbt=obt(),abt={requireParentSpan:!0},rDe=class extends Wee.InstrumentationBase{constructor(t={}){super(sbt.PACKAGE_NAME,sbt.PACKAGE_VERSION,{...abt,...t})}setConfig(t={}){super.setConfig({...abt,...t})}init(){return[new Wee.InstrumentationNodeModuleDefinition("ioredis",[">=2.0.0 <6"],(t,r)=>{let n=t[Symbol.toStringTag]==="Module"?t.default:t;return(0,Wee.isWrapped)(n.prototype.sendCommand)&&this._unwrap(n.prototype,"sendCommand"),this._wrap(n.prototype,"sendCommand",this._patchSendCommand(r)),(0,Wee.isWrapped)(n.prototype.connect)&&this._unwrap(n.prototype,"connect"),this._wrap(n.prototype,"connect",this._patchConnection()),t},t=>{if(t===void 0)return;let r=t[Symbol.toStringTag]==="Module"?t.default:t;this._unwrap(r.prototype,"sendCommand"),this._unwrap(r.prototype,"connect")})]}_patchSendCommand(t){return r=>this._traceSendCommand(r,t)}_patchConnection(){return t=>this._traceConnection(t)}_traceSendCommand(t,r){let n=this;return function(o){if(arguments.length<1||typeof o!="object")return t.apply(this,arguments);let i=n.getConfig(),s=i.dbStatementSerializer||cZr.defaultDbStatementSerializer,a=Qv.trace.getSpan(Qv.context.active())===void 0;if(i.requireParentSpan===!0&&a)return t.apply(this,arguments);let c=n.tracer.startSpan(o.name,{kind:Qv.SpanKind.CLIENT,attributes:{[uh.ATTR_DB_SYSTEM]:uh.DB_SYSTEM_VALUE_REDIS,[uh.ATTR_DB_STATEMENT]:s(o.name,o.args)}}),{requestHook:l}=i;l&&(0,ibt.safeExecuteInTheMiddle)(()=>l(c,{moduleVersion:r,cmdName:o.name,cmdArgs:o.args}),p=>{p&&Qv.diag.error("ioredis instrumentation: request hook failed",p)},!0);let{host:u,port:d}=this.options;c.setAttributes({[uh.ATTR_NET_PEER_NAME]:u,[uh.ATTR_NET_PEER_PORT]:d,[uh.ATTR_DB_CONNECTION_STRING]:`redis://${u}:${d}`});try{let p=t.apply(this,arguments),f=o.resolve;o.resolve=function(h){(0,ibt.safeExecuteInTheMiddle)(()=>i.responseHook?.(c,o.name,o.args,h),_=>{_&&Qv.diag.error("ioredis instrumentation: response hook failed",_)},!0),(0,fq.endSpan)(c,null),f(h)};let A=o.reject;return o.reject=function(h){(0,fq.endSpan)(c,h),A(h)},p}catch(p){throw(0,fq.endSpan)(c,p),p}}}_traceConnection(t){let r=this;return function(){let n=Qv.trace.getSpan(Qv.context.active())===void 0;if(r.getConfig().requireParentSpan===!0&&n)return t.apply(this,arguments);let o=r.tracer.startSpan("connect",{kind:Qv.SpanKind.CLIENT,attributes:{[uh.ATTR_DB_SYSTEM]:uh.DB_SYSTEM_VALUE_REDIS,[uh.ATTR_DB_STATEMENT]:"connect"}}),{host:i,port:s}=this.options;o.setAttributes({[uh.ATTR_NET_PEER_NAME]:i,[uh.ATTR_NET_PEER_PORT]:s,[uh.ATTR_DB_CONNECTION_STRING]:`redis://${i}:${s}`});try{let a=t.apply(this,arguments);return(0,fq.endSpan)(o,null),a}catch(a){throw(0,fq.endSpan)(o,a),a}}}};jee.IORedisInstrumentation=rDe});var lbt=S(Kee=>{"use strict";Object.defineProperty(Kee,"__esModule",{value:!0});Kee.IORedisInstrumentation=void 0;var lZr=cbt();Object.defineProperty(Kee,"IORedisInstrumentation",{enumerable:!0,get:function(){return lZr.IORedisInstrumentation}})});var Jee=S(IL=>{"use strict";Object.defineProperty(IL,"__esModule",{value:!0});IL.PACKAGE_NAME=IL.PACKAGE_VERSION=void 0;IL.PACKAGE_VERSION="0.57.0";IL.PACKAGE_NAME="@opentelemetry/instrumentation-redis"});var ubt=S(Gv=>{"use strict";Object.defineProperty(Gv,"__esModule",{value:!0});Gv.getTracedCreateStreamTrace=Gv.getTracedCreateClient=Gv.endSpan=void 0;var mq=zt(),uZr=(e,t)=>{t&&e.setStatus({code:mq.SpanStatusCode.ERROR,message:t.message}),e.end()};Gv.endSpan=uZr;var dZr=e=>function(){let r=e.apply(this,arguments);return mq.context.bind(mq.context.active(),r)};Gv.getTracedCreateClient=dZr;var pZr=e=>function(){return Object.prototype.hasOwnProperty.call(this,"stream")||Object.defineProperty(this,"stream",{get(){return this._patched_redis_stream},set(r){mq.context.bind(mq.context.active(),r),this._patched_redis_stream=r}}),e.apply(this,arguments)};Gv.getTracedCreateStreamTrace=pZr});var Zee=S(mp=>{"use strict";Object.defineProperty(mp,"__esModule",{value:!0});mp.DB_SYSTEM_VALUE_REDIS=mp.DB_SYSTEM_NAME_VALUE_REDIS=mp.ATTR_NET_PEER_PORT=mp.ATTR_NET_PEER_NAME=mp.ATTR_DB_SYSTEM=mp.ATTR_DB_STATEMENT=mp.ATTR_DB_CONNECTION_STRING=void 0;mp.ATTR_DB_CONNECTION_STRING="db.connection_string";mp.ATTR_DB_STATEMENT="db.statement";mp.ATTR_DB_SYSTEM="db.system";mp.ATTR_NET_PEER_NAME="net.peer.name";mp.ATTR_NET_PEER_PORT="net.peer.port";mp.DB_SYSTEM_NAME_VALUE_REDIS="redis";mp.DB_SYSTEM_VALUE_REDIS="redis"});var pbt=S(ete=>{"use strict";Object.defineProperty(ete,"__esModule",{value:!0});ete.RedisInstrumentationV2_V3=void 0;var wg=(Nn(),Hn(Xi)),Xee=ubt(),dbt=Jee(),gq=zt(),Aq=Ss(),k1=Zee(),fZr=zee(),nDe=class e extends wg.InstrumentationBase{static COMPONENT="redis";_semconvStability;constructor(t={}){super(dbt.PACKAGE_NAME,dbt.PACKAGE_VERSION,t),this._semconvStability=t.semconvStability?t.semconvStability:(0,wg.semconvStabilityFromStr)("database",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}setConfig(t={}){super.setConfig(t),this._semconvStability=t.semconvStability?t.semconvStability:(0,wg.semconvStabilityFromStr)("database",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}init(){return[new wg.InstrumentationNodeModuleDefinition("redis",[">=2.6.0 <4"],t=>((0,wg.isWrapped)(t.RedisClient.prototype.internal_send_command)&&this._unwrap(t.RedisClient.prototype,"internal_send_command"),this._wrap(t.RedisClient.prototype,"internal_send_command",this._getPatchInternalSendCommand()),(0,wg.isWrapped)(t.RedisClient.prototype.create_stream)&&this._unwrap(t.RedisClient.prototype,"create_stream"),this._wrap(t.RedisClient.prototype,"create_stream",this._getPatchCreateStream()),(0,wg.isWrapped)(t.createClient)&&this._unwrap(t,"createClient"),this._wrap(t,"createClient",this._getPatchCreateClient()),t),t=>{t!==void 0&&(this._unwrap(t.RedisClient.prototype,"internal_send_command"),this._unwrap(t.RedisClient.prototype,"create_stream"),this._unwrap(t,"createClient"))})]}_getPatchInternalSendCommand(){let t=this;return function(n){return function(i){if(arguments.length!==1||typeof i!="object")return n.apply(this,arguments);let s=t.getConfig(),a=gq.trace.getSpan(gq.context.active())===void 0;if(s.requireParentSpan===!0&&a)return n.apply(this,arguments);let c=s?.dbStatementSerializer||fZr.defaultDbStatementSerializer,l={};t._semconvStability&wg.SemconvStability.OLD&&Object.assign(l,{[k1.ATTR_DB_SYSTEM]:k1.DB_SYSTEM_VALUE_REDIS,[k1.ATTR_DB_STATEMENT]:c(i.command,i.args)}),t._semconvStability&wg.SemconvStability.STABLE&&Object.assign(l,{[Aq.ATTR_DB_SYSTEM_NAME]:k1.DB_SYSTEM_NAME_VALUE_REDIS,[Aq.ATTR_DB_OPERATION_NAME]:i.command,[Aq.ATTR_DB_QUERY_TEXT]:c(i.command,i.args)});let u=t.tracer.startSpan(`${e.COMPONENT}-${i.command}`,{kind:gq.SpanKind.CLIENT,attributes:l});if(this.connection_options){let p={};t._semconvStability&wg.SemconvStability.OLD&&Object.assign(p,{[k1.ATTR_NET_PEER_NAME]:this.connection_options.host,[k1.ATTR_NET_PEER_PORT]:this.connection_options.port}),t._semconvStability&wg.SemconvStability.STABLE&&Object.assign(p,{[Aq.ATTR_SERVER_ADDRESS]:this.connection_options.host,[Aq.ATTR_SERVER_PORT]:this.connection_options.port}),u.setAttributes(p)}this.address&&t._semconvStability&wg.SemconvStability.OLD&&u.setAttribute(k1.ATTR_DB_CONNECTION_STRING,`redis://${this.address}`);let d=arguments[0].callback;if(d){let p=gq.context.active();arguments[0].callback=function(A,h){if(s?.responseHook){let _=s.responseHook;(0,wg.safeExecuteInTheMiddle)(()=>{_(u,i.command,i.args,h)},T=>{T&&t._diag.error("Error executing responseHook",T)},!0)}return(0,Xee.endSpan)(u,A),gq.context.with(p,d,this,...arguments)}}try{return n.apply(this,arguments)}catch(p){throw(0,Xee.endSpan)(u,p),p}}}}_getPatchCreateClient(){return function(r){return(0,Xee.getTracedCreateClient)(r)}}_getPatchCreateStream(){return function(r){return(0,Xee.getTracedCreateStreamTrace)(r)}}};ete.RedisInstrumentationV2_V3=nDe});var mbt=S(tte=>{"use strict";Object.defineProperty(tte,"__esModule",{value:!0});tte.getClientAttributes=void 0;var oDe=Ss(),vL=Zee(),fbt=(Nn(),Hn(Xi));function mZr(e,t,r){let n={};return r&fbt.SemconvStability.OLD&&Object.assign(n,{[vL.ATTR_DB_SYSTEM]:vL.DB_SYSTEM_VALUE_REDIS,[vL.ATTR_NET_PEER_NAME]:t?.socket?.host,[vL.ATTR_NET_PEER_PORT]:t?.socket?.port,[vL.ATTR_DB_CONNECTION_STRING]:gZr(e,t?.url)}),r&fbt.SemconvStability.STABLE&&Object.assign(n,{[oDe.ATTR_DB_SYSTEM_NAME]:vL.DB_SYSTEM_NAME_VALUE_REDIS,[oDe.ATTR_SERVER_ADDRESS]:t?.socket?.host,[oDe.ATTR_SERVER_PORT]:t?.socket?.port}),n}tte.getClientAttributes=mZr;function gZr(e,t){if(!(typeof t!="string"||!t))try{let r=new URL(t);return r.searchParams.delete("user_pwd"),r.username="",r.password="",r.href}catch(r){e.error("failed to sanitize redis connection url",r)}}});var Ebt=S(rte=>{"use strict";Object.defineProperty(rte,"__esModule",{value:!0});rte.RedisInstrumentationV4_V5=void 0;var dh=zt(),rc=(Nn(),Hn(Xi)),gbt=mbt(),AZr=zee(),Abt=Jee(),hbt=Ss(),hZr=Zee(),hq=Symbol("opentelemetry.instrumentation.redis.open_spans"),_bt=Symbol("opentelemetry.instrumentation.redis.multi_command_options"),iDe=class e extends rc.InstrumentationBase{static COMPONENT="redis";_semconvStability;constructor(t={}){super(Abt.PACKAGE_NAME,Abt.PACKAGE_VERSION,t),this._semconvStability=t.semconvStability?t.semconvStability:(0,rc.semconvStabilityFromStr)("database",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}setConfig(t={}){super.setConfig(t),this._semconvStability=t.semconvStability?t.semconvStability:(0,rc.semconvStabilityFromStr)("database",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}init(){return[this._getInstrumentationNodeModuleDefinition("@redis/client"),this._getInstrumentationNodeModuleDefinition("@node-redis/client")]}_getInstrumentationNodeModuleDefinition(t){let r=new rc.InstrumentationNodeModuleFile(`${t}/dist/lib/commander.js`,["^1.0.0"],(i,s)=>{let a=i.transformCommandArguments;if(!a)return this._diag.error("internal instrumentation error, missing transformCommandArguments function"),i;let c=s?.startsWith("1.0.")?"extendWithCommands":"attachCommands";return(0,rc.isWrapped)(i?.[c])&&this._unwrap(i,c),this._wrap(i,c,this._getPatchExtendWithCommands(a)),i},i=>{(0,rc.isWrapped)(i?.extendWithCommands)&&this._unwrap(i,"extendWithCommands"),(0,rc.isWrapped)(i?.attachCommands)&&this._unwrap(i,"attachCommands")}),n=new rc.InstrumentationNodeModuleFile(`${t}/dist/lib/client/multi-command.js`,["^1.0.0","^5.0.0"],i=>{let s=i?.default?.prototype;return(0,rc.isWrapped)(s?.exec)&&this._unwrap(s,"exec"),this._wrap(s,"exec",this._getPatchMultiCommandsExec()),(0,rc.isWrapped)(s?.addCommand)&&this._unwrap(s,"addCommand"),this._wrap(s,"addCommand",this._getPatchMultiCommandsAddCommand()),i},i=>{let s=i?.default?.prototype;(0,rc.isWrapped)(s?.exec)&&this._unwrap(s,"exec"),(0,rc.isWrapped)(s?.addCommand)&&this._unwrap(s,"addCommand")}),o=new rc.InstrumentationNodeModuleFile(`${t}/dist/lib/client/index.js`,["^1.0.0","^5.0.0"],i=>{let s=i?.default?.prototype;return s?.multi&&((0,rc.isWrapped)(s?.multi)&&this._unwrap(s,"multi"),this._wrap(s,"multi",this._getPatchRedisClientMulti())),s?.MULTI&&((0,rc.isWrapped)(s?.MULTI)&&this._unwrap(s,"MULTI"),this._wrap(s,"MULTI",this._getPatchRedisClientMulti())),(0,rc.isWrapped)(s?.sendCommand)&&this._unwrap(s,"sendCommand"),this._wrap(s,"sendCommand",this._getPatchRedisClientSendCommand()),this._wrap(s,"connect",this._getPatchedClientConnect()),i},i=>{let s=i?.default?.prototype;(0,rc.isWrapped)(s?.multi)&&this._unwrap(s,"multi"),(0,rc.isWrapped)(s?.MULTI)&&this._unwrap(s,"MULTI"),(0,rc.isWrapped)(s?.sendCommand)&&this._unwrap(s,"sendCommand")});return new rc.InstrumentationNodeModuleDefinition(t,["^1.0.0","^5.0.0"],i=>i,()=>{},[r,n,o])}_getPatchExtendWithCommands(t){let r=this;return function(o){return function(s){if(s?.BaseClass?.name!=="RedisClient")return o.apply(this,arguments);let a=s.executor;return s.executor=function(c,l){let u=t(c,l).args;return r._traceClientCommand(a,this,arguments,u)},o.apply(this,arguments)}}}_getPatchMultiCommandsExec(){let t=this;return function(n){return function(){let i=n.apply(this,arguments);return typeof i?.then!="function"?(t._diag.error("got non promise result when patching RedisClientMultiCommand.exec"),i):i.then(s=>{let a=this[hq];return t._endSpansWithRedisReplies(a,s),s}).catch(s=>{let a=this[hq];if(!a)t._diag.error("cannot find open spans to end for redis multi command");else{let c=s.constructor.name==="MultiErrorReply"?s.replies:new Array(a.length).fill(s);t._endSpansWithRedisReplies(a,c)}return Promise.reject(s)})}}}_getPatchMultiCommandsAddCommand(){let t=this;return function(n){return function(i){return t._traceClientCommand(n,this,arguments,i)}}}_getPatchRedisClientMulti(){return function(r){return function(){let o=r.apply(this,arguments);return o[_bt]=this.options,o}}}_getPatchRedisClientSendCommand(){let t=this;return function(n){return function(i){return t._traceClientCommand(n,this,arguments,i)}}}_getPatchedClientConnect(){let t=this;return function(n){return function(){let i=this.options,s=(0,gbt.getClientAttributes)(t._diag,i,t._semconvStability),a=t.tracer.startSpan(`${e.COMPONENT}-connect`,{kind:dh.SpanKind.CLIENT,attributes:s});return dh.context.with(dh.trace.setSpan(dh.context.active(),a),()=>n.apply(this)).then(l=>(a.end(),l)).catch(l=>(a.recordException(l),a.setStatus({code:dh.SpanStatusCode.ERROR,message:l.message}),a.end(),Promise.reject(l)))}}}_traceClientCommand(t,r,n,o){if(dh.trace.getSpan(dh.context.active())===void 0&&this.getConfig().requireParentSpan)return t.apply(r,n);let s=r.options||r[_bt],a=o[0],c=o.slice(1),l=this.getConfig().dbStatementSerializer||AZr.defaultDbStatementSerializer,u=(0,gbt.getClientAttributes)(this._diag,s,this._semconvStability);this._semconvStability&rc.SemconvStability.STABLE&&(u[hbt.ATTR_DB_OPERATION_NAME]=a);try{let f=l(a,c);f!=null&&(this._semconvStability&rc.SemconvStability.OLD&&(u[hZr.ATTR_DB_STATEMENT]=f),this._semconvStability&rc.SemconvStability.STABLE&&(u[hbt.ATTR_DB_QUERY_TEXT]=f))}catch(f){this._diag.error("dbStatementSerializer throw an exception",f,{commandName:a})}let d=this.tracer.startSpan(`${e.COMPONENT}-${a}`,{kind:dh.SpanKind.CLIENT,attributes:u}),p=dh.context.with(dh.trace.setSpan(dh.context.active(),d),()=>t.apply(r,n));if(typeof p?.then=="function")p.then(f=>{this._endSpanWithResponse(d,a,c,f,void 0)},f=>{this._endSpanWithResponse(d,a,c,null,f)});else{let f=p;f[hq]=f[hq]||[],f[hq].push({span:d,commandName:a,commandArgs:c})}return p}_endSpansWithRedisReplies(t,r){if(!t)return this._diag.error("cannot find open spans to end for redis multi command");if(r.length!==t.length)return this._diag.error("number of multi command spans does not match response from redis");for(let n=0;n<t.length;n++){let{span:o,commandName:i,commandArgs:s}=t[n],a=r[n],[c,l]=a instanceof Error?[null,a]:[a,void 0];this._endSpanWithResponse(o,i,s,c,l)}}_endSpanWithResponse(t,r,n,o,i){let{responseHook:s}=this.getConfig();if(!i&&s)try{s(t,r,n,o)}catch(a){this._diag.error("responseHook throw an exception",a)}i&&(t.recordException(i),t.setStatus({code:dh.SpanStatusCode.ERROR,message:i?.message})),t.end()}};rte.RedisInstrumentationV4_V5=iDe});var bbt=S(nte=>{"use strict";Object.defineProperty(nte,"__esModule",{value:!0});nte.RedisInstrumentation=void 0;var _Zr=(Nn(),Hn(Xi)),Sbt=Jee(),EZr=pbt(),SZr=Ebt(),Tbt={requireParentSpan:!1},sDe=class extends _Zr.InstrumentationBase{instrumentationV2_V3;instrumentationV4_V5;initialized=!1;constructor(t={}){let r={...Tbt,...t};super(Sbt.PACKAGE_NAME,Sbt.PACKAGE_VERSION,r),this.instrumentationV2_V3=new EZr.RedisInstrumentationV2_V3(this.getConfig()),this.instrumentationV4_V5=new SZr.RedisInstrumentationV4_V5(this.getConfig()),this.initialized=!0}setConfig(t={}){let r={...Tbt,...t};super.setConfig(r),this.initialized&&(this.instrumentationV2_V3.setConfig(r),this.instrumentationV4_V5.setConfig(r))}init(){}getModuleDefinitions(){return[...this.instrumentationV2_V3.getModuleDefinitions(),...this.instrumentationV4_V5.getModuleDefinitions()]}setTracerProvider(t){super.setTracerProvider(t),this.initialized&&(this.instrumentationV2_V3.setTracerProvider(t),this.instrumentationV4_V5.setTracerProvider(t))}enable(){super.enable(),this.initialized&&(this.instrumentationV2_V3.enable(),this.instrumentationV4_V5.enable())}disable(){super.disable(),this.initialized&&(this.instrumentationV2_V3.disable(),this.instrumentationV4_V5.disable())}};nte.RedisInstrumentation=sDe});var ybt=S(ote=>{"use strict";Object.defineProperty(ote,"__esModule",{value:!0});ote.RedisInstrumentation=void 0;var TZr=bbt();Object.defineProperty(ote,"RedisInstrumentation",{enumerable:!0,get:function(){return TZr.RedisInstrumentation}})});var Mbt=S(ste=>{"use strict";Object.defineProperty(ste,"__esModule",{value:!0});ste.EVENT_LISTENERS_SET=void 0;ste.EVENT_LISTENERS_SET=Symbol("opentelemetry.instrumentation.pg.eventListenersSet")});var lDe=S(Sq=>{"use strict";Object.defineProperty(Sq,"__esModule",{value:!0});Sq.AttributeNames=void 0;var DZr;(function(e){e.PG_VALUES="db.postgresql.values",e.PG_PLAN="db.postgresql.plan",e.IDLE_TIMEOUT_MILLIS="db.postgresql.idle.timeout.millis",e.MAX_CLIENT="db.postgresql.max.client"})(DZr=Sq.AttributeNames||(Sq.AttributeNames={}))});var uDe=S(Ui=>{"use strict";Object.defineProperty(Ui,"__esModule",{value:!0});Ui.METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS=Ui.METRIC_DB_CLIENT_CONNECTION_COUNT=Ui.DB_SYSTEM_VALUE_POSTGRESQL=Ui.DB_CLIENT_CONNECTION_STATE_VALUE_USED=Ui.DB_CLIENT_CONNECTION_STATE_VALUE_IDLE=Ui.ATTR_NET_PEER_PORT=Ui.ATTR_NET_PEER_NAME=Ui.ATTR_DB_USER=Ui.ATTR_DB_SYSTEM=Ui.ATTR_DB_STATEMENT=Ui.ATTR_DB_NAME=Ui.ATTR_DB_CONNECTION_STRING=Ui.ATTR_DB_CLIENT_CONNECTION_STATE=Ui.ATTR_DB_CLIENT_CONNECTION_POOL_NAME=void 0;Ui.ATTR_DB_CLIENT_CONNECTION_POOL_NAME="db.client.connection.pool.name";Ui.ATTR_DB_CLIENT_CONNECTION_STATE="db.client.connection.state";Ui.ATTR_DB_CONNECTION_STRING="db.connection_string";Ui.ATTR_DB_NAME="db.name";Ui.ATTR_DB_STATEMENT="db.statement";Ui.ATTR_DB_SYSTEM="db.system";Ui.ATTR_DB_USER="db.user";Ui.ATTR_NET_PEER_NAME="net.peer.name";Ui.ATTR_NET_PEER_PORT="net.peer.port";Ui.DB_CLIENT_CONNECTION_STATE_VALUE_IDLE="idle";Ui.DB_CLIENT_CONNECTION_STATE_VALUE_USED="used";Ui.DB_SYSTEM_VALUE_POSTGRESQL="postgresql";Ui.METRIC_DB_CLIENT_CONNECTION_COUNT="db.client.connection.count";Ui.METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS="db.client.connection.pending_requests"});var dDe=S(Tq=>{"use strict";Object.defineProperty(Tq,"__esModule",{value:!0});Tq.SpanNames=void 0;var NZr;(function(e){e.QUERY_PREFIX="pg.query",e.CONNECT="pg.connect",e.POOL_CONNECT="pg-pool.connect"})(NZr=Tq.SpanNames||(Tq.SpanNames={}))});var Qbt=S(zo=>{"use strict";Object.defineProperty(zo,"__esModule",{value:!0});zo.sanitizedErrorMessage=zo.isObjectWithTextString=zo.getErrorMessage=zo.patchClientConnectCallback=zo.patchCallbackPGPool=zo.updateCounter=zo.getPoolName=zo.patchCallback=zo.handleExecutionResult=zo.handleConfigQuery=zo.shouldSkipInstrumentation=zo.getSemanticAttributesFromPoolConnection=zo.getSemanticAttributesFromConnection=zo.getConnectionString=zo.parseAndMaskConnectionString=zo.parseNormalizedOperationName=zo.getQuerySpanName=void 0;var Hv=zt(),ate=lDe(),ph=Ss(),Tc=uDe(),P1=(Nn(),Hn(Xi)),Bbt=dDe();function kbt(e,t){if(!t)return Bbt.SpanNames.QUERY_PREFIX;let r=typeof t.name=="string"&&t.name?t.name:Pbt(t.text);return`${Bbt.SpanNames.QUERY_PREFIX}:${r}${e?` ${e}`:""}`}zo.getQuerySpanName=kbt;function Pbt(e){let t=e.indexOf(" "),r=t===-1?e:e.slice(0,t);return r=r.toUpperCase(),r.endsWith(";")?r.slice(0,-1):r}zo.parseNormalizedOperationName=Pbt;function Lbt(e){try{let t=new URL(e);return t.username="",t.password="",t.toString()}catch{return"postgresql://localhost:5432/"}}zo.parseAndMaskConnectionString=Lbt;function pDe(e){if("connectionString"in e&&e.connectionString)return Lbt(e.connectionString);let t=e.host||"localhost",r=e.port||5432,n=e.database||"";return`postgresql://${t}:${r}/${n}`}zo.getConnectionString=pDe;function cte(e){if(Number.isInteger(e))return e}function Fbt(e,t){let r={};return t&P1.SemconvStability.OLD&&(r={...r,[Tc.ATTR_DB_SYSTEM]:Tc.DB_SYSTEM_VALUE_POSTGRESQL,[Tc.ATTR_DB_NAME]:e.database,[Tc.ATTR_DB_CONNECTION_STRING]:pDe(e),[Tc.ATTR_DB_USER]:e.user,[Tc.ATTR_NET_PEER_NAME]:e.host,[Tc.ATTR_NET_PEER_PORT]:cte(e.port)}),t&P1.SemconvStability.STABLE&&(r={...r,[ph.ATTR_DB_SYSTEM_NAME]:ph.DB_SYSTEM_NAME_VALUE_POSTGRESQL,[ph.ATTR_DB_NAMESPACE]:e.namespace,[ph.ATTR_SERVER_ADDRESS]:e.host,[ph.ATTR_SERVER_PORT]:cte(e.port)}),r}zo.getSemanticAttributesFromConnection=Fbt;function xZr(e,t){let r;try{r=e.connectionString?new URL(e.connectionString):void 0}catch{r=void 0}let n={[ate.AttributeNames.IDLE_TIMEOUT_MILLIS]:e.idleTimeoutMillis,[ate.AttributeNames.MAX_CLIENT]:e.maxClient};return t&P1.SemconvStability.OLD&&(n={...n,[Tc.ATTR_DB_SYSTEM]:Tc.DB_SYSTEM_VALUE_POSTGRESQL,[Tc.ATTR_DB_NAME]:r?.pathname.slice(1)??e.database,[Tc.ATTR_DB_CONNECTION_STRING]:pDe(e),[Tc.ATTR_NET_PEER_NAME]:r?.hostname??e.host,[Tc.ATTR_NET_PEER_PORT]:Number(r?.port)||cte(e.port),[Tc.ATTR_DB_USER]:r?.username??e.user}),t&P1.SemconvStability.STABLE&&(n={...n,[ph.ATTR_DB_SYSTEM_NAME]:ph.DB_SYSTEM_NAME_VALUE_POSTGRESQL,[ph.ATTR_DB_NAMESPACE]:e.namespace,[ph.ATTR_SERVER_ADDRESS]:r?.hostname??e.host,[ph.ATTR_SERVER_PORT]:Number(r?.port)||cte(e.port)}),n}zo.getSemanticAttributesFromPoolConnection=xZr;function OZr(e){return e.requireParentSpan===!0&&Hv.trace.getSpan(Hv.context.active())===void 0}zo.shouldSkipInstrumentation=OZr;function wZr(e,t,r,n){let{connectionParameters:o}=this,i=o.database,s=kbt(i,n),a=e.startSpan(s,{kind:Hv.SpanKind.CLIENT,attributes:Fbt(o,r)});if(!n)return a;if(n.text&&(r&P1.SemconvStability.OLD&&a.setAttribute(Tc.ATTR_DB_STATEMENT,n.text),r&P1.SemconvStability.STABLE&&a.setAttribute(ph.ATTR_DB_QUERY_TEXT,n.text)),t.enhancedDatabaseReporting&&Array.isArray(n.values))try{let c=n.values.map(l=>l==null?"null":l instanceof Buffer?l.toString():typeof l=="object"?typeof l.toPostgres=="function"?l.toPostgres():JSON.stringify(l):l.toString());a.setAttribute(ate.AttributeNames.PG_VALUES,c)}catch(c){Hv.diag.error("failed to stringify ",n.values,c)}return typeof n.name=="string"&&a.setAttribute(ate.AttributeNames.PG_PLAN,n.name),a}zo.handleConfigQuery=wZr;function Ubt(e,t,r){typeof e.responseHook=="function"&&(0,P1.safeExecuteInTheMiddle)(()=>{e.responseHook(t,{data:r})},n=>{n&&Hv.diag.error("Error running response hook",n)},!0)}zo.handleExecutionResult=Ubt;function MZr(e,t,r,n,o){return function(s,a){s?(Object.prototype.hasOwnProperty.call(s,"code")&&(n[ph.ATTR_ERROR_TYPE]=s.code),s instanceof Error&&t.recordException(lte(s)),t.setStatus({code:Hv.SpanStatusCode.ERROR,message:s.message})):Ubt(e,t,a),o(),t.end(),r.call(this,s,a)}}zo.patchCallback=MZr;function BZr(e){let t="";return t+=(e?.host?`${e.host}`:"unknown_host")+":",t+=(e?.port?`${e.port}`:"unknown_port")+"/",t+=e?.database?`${e.database}`:"unknown_database",t.trim()}zo.getPoolName=BZr;function kZr(e,t,r,n,o){let i=t.totalCount,s=t.waitingCount,a=t.idleCount,c=i-a;return r.add(c-o.used,{[Tc.ATTR_DB_CLIENT_CONNECTION_STATE]:Tc.DB_CLIENT_CONNECTION_STATE_VALUE_USED,[Tc.ATTR_DB_CLIENT_CONNECTION_POOL_NAME]:e}),r.add(a-o.idle,{[Tc.ATTR_DB_CLIENT_CONNECTION_STATE]:Tc.DB_CLIENT_CONNECTION_STATE_VALUE_IDLE,[Tc.ATTR_DB_CLIENT_CONNECTION_POOL_NAME]:e}),n.add(s-o.pending,{[Tc.ATTR_DB_CLIENT_CONNECTION_POOL_NAME]:e}),{used:c,idle:a,pending:s}}zo.updateCounter=kZr;function PZr(e,t){return function(n,o,i){n&&(n instanceof Error&&e.recordException(lte(n)),e.setStatus({code:Hv.SpanStatusCode.ERROR,message:n.message})),e.end(),t.call(this,n,o,i)}}zo.patchCallbackPGPool=PZr;function LZr(e,t){return function(n){n&&(n instanceof Error&&e.recordException(lte(n)),e.setStatus({code:Hv.SpanStatusCode.ERROR,message:n.message})),e.end(),t.apply(this,arguments)}}zo.patchClientConnectCallback=LZr;function FZr(e){return typeof e=="object"&&e!==null&&"message"in e?String(e.message):void 0}zo.getErrorMessage=FZr;function UZr(e){return typeof e=="object"&&typeof e?.text=="string"}zo.isObjectWithTextString=UZr;function lte(e){let t=e?.name??"PostgreSQLError",r=e?.code??"UNKNOWN";return`PostgreSQL error of type '${t}' occurred (code: ${r})`}zo.sanitizedErrorMessage=lte});var Gbt=S(RL=>{"use strict";Object.defineProperty(RL,"__esModule",{value:!0});RL.PACKAGE_NAME=RL.PACKAGE_VERSION=void 0;RL.PACKAGE_VERSION="0.61.0";RL.PACKAGE_NAME="@opentelemetry/instrumentation-pg"});var zbt=S(dte=>{"use strict";Object.defineProperty(dte,"__esModule",{value:!0});dte.PgInstrumentation=void 0;var sf=(Nn(),Hn(Xi)),bs=zt(),Hbt=Mbt(),nc=Qbt(),qbt=KRe(),$bt=Gbt(),Ybt=dDe(),ute=(Ys(),Hn(XA)),CE=Ss(),bq=uDe();function DL(e){return e[Symbol.toStringTag]==="Module"?e.default:e}var fDe=class extends sf.InstrumentationBase{_connectionsCounter={used:0,idle:0,pending:0};_semconvStability;constructor(t={}){super($bt.PACKAGE_NAME,$bt.PACKAGE_VERSION,t),this._semconvStability=(0,sf.semconvStabilityFromStr)("database",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}_updateMetricInstruments(){this._operationDuration=this.meter.createHistogram(CE.METRIC_DB_CLIENT_OPERATION_DURATION,{description:"Duration of database client operations.",unit:"s",valueType:bs.ValueType.DOUBLE,advice:{explicitBucketBoundaries:[.001,.005,.01,.05,.1,.5,1,5,10]}}),this._connectionsCounter={idle:0,pending:0,used:0},this._connectionsCount=this.meter.createUpDownCounter(bq.METRIC_DB_CLIENT_CONNECTION_COUNT,{description:"The number of connections that are currently in state described by the state attribute.",unit:"{connection}"}),this._connectionPendingRequests=this.meter.createUpDownCounter(bq.METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS,{description:"The number of current pending requests for an open connection.",unit:"{connection}"})}init(){let t=[">=8.0.3 <9"],r=[">=2.0.0 <4"],n=new sf.InstrumentationNodeModuleFile("pg/lib/native/client.js",t,this._patchPgClient.bind(this),this._unpatchPgClient.bind(this)),o=new sf.InstrumentationNodeModuleFile("pg/lib/client.js",t,this._patchPgClient.bind(this),this._unpatchPgClient.bind(this)),i=new sf.InstrumentationNodeModuleDefinition("pg",t,a=>{let c=DL(a);return this._patchPgClient(c.Client),a},a=>{let c=DL(a);return this._unpatchPgClient(c.Client),a},[o,n]),s=new sf.InstrumentationNodeModuleDefinition("pg-pool",r,a=>{let c=DL(a);return(0,sf.isWrapped)(c.prototype.connect)&&this._unwrap(c.prototype,"connect"),this._wrap(c.prototype,"connect",this._getPoolConnectPatch()),c},a=>{let c=DL(a);(0,sf.isWrapped)(c.prototype.connect)&&this._unwrap(c.prototype,"connect")});return[i,s]}_patchPgClient(t){if(!t)return;let r=DL(t);return(0,sf.isWrapped)(r.prototype.query)&&this._unwrap(r.prototype,"query"),(0,sf.isWrapped)(r.prototype.connect)&&this._unwrap(r.prototype,"connect"),this._wrap(r.prototype,"query",this._getClientQueryPatch()),this._wrap(r.prototype,"connect",this._getClientConnectPatch()),t}_unpatchPgClient(t){let r=DL(t);return(0,sf.isWrapped)(r.prototype.query)&&this._unwrap(r.prototype,"query"),(0,sf.isWrapped)(r.prototype.connect)&&this._unwrap(r.prototype,"connect"),t}_getClientConnectPatch(){let t=this;return r=>function(o){if(nc.shouldSkipInstrumentation(t.getConfig()))return r.call(this,o);let i=t.tracer.startSpan(Ybt.SpanNames.CONNECT,{kind:bs.SpanKind.CLIENT,attributes:nc.getSemanticAttributesFromConnection(this,t._semconvStability)});if(o){let a=bs.trace.getSpan(bs.context.active());o=nc.patchClientConnectCallback(i,o),a&&(o=bs.context.bind(bs.context.active(),o))}let s=bs.context.with(bs.trace.setSpan(bs.context.active(),i),()=>r.call(this,o));return Vbt(i,s)}}recordOperationDuration(t,r){let n={},o=[CE.ATTR_DB_NAMESPACE,CE.ATTR_ERROR_TYPE,CE.ATTR_SERVER_PORT,CE.ATTR_SERVER_ADDRESS,CE.ATTR_DB_OPERATION_NAME];this._semconvStability&sf.SemconvStability.OLD&&o.push(bq.ATTR_DB_SYSTEM),this._semconvStability&sf.SemconvStability.STABLE&&o.push(CE.ATTR_DB_SYSTEM_NAME),o.forEach(s=>{s in t&&(n[s]=t[s])});let i=(0,ute.hrTimeToMilliseconds)((0,ute.hrTimeDuration)(r,(0,ute.hrTime)()))/1e3;this._operationDuration.record(i,n)}_getClientQueryPatch(){let t=this;return r=>(this._diag.debug("Patching pg.Client.prototype.query"),function(...o){if(nc.shouldSkipInstrumentation(t.getConfig()))return r.apply(this,o);let i=(0,ute.hrTime)(),s=o[0],a=typeof s=="string",c=nc.isObjectWithTextString(s),l=a?{text:s,values:Array.isArray(o[1])?o[1]:void 0}:c?s:void 0,u={[bq.ATTR_DB_SYSTEM]:bq.DB_SYSTEM_VALUE_POSTGRESQL,[CE.ATTR_DB_NAMESPACE]:this.database,[CE.ATTR_SERVER_PORT]:this.connectionParameters.port,[CE.ATTR_SERVER_ADDRESS]:this.connectionParameters.host};l?.text&&(u[CE.ATTR_DB_OPERATION_NAME]=nc.parseNormalizedOperationName(l?.text));let d=()=>{t.recordOperationDuration(u,i)},p=t.getConfig(),f=nc.handleConfigQuery.call(this,t.tracer,p,t._semconvStability,l);if(p.addSqlCommenterCommentToQueries&&(a?o[0]=(0,qbt.addSqlCommenterComment)(f,s):c&&!("name"in s)&&(o[0]={...s,text:(0,qbt.addSqlCommenterComment)(f,s.text)})),o.length>0){let _=bs.trace.getSpan(bs.context.active());if(typeof o[o.length-1]=="function")o[o.length-1]=nc.patchCallback(p,f,o[o.length-1],u,d),_&&(o[o.length-1]=bs.context.bind(bs.context.active(),o[o.length-1]));else if(typeof l?.callback=="function"){let T=nc.patchCallback(t.getConfig(),f,l.callback,u,d);_&&(T=bs.context.bind(bs.context.active(),T)),o[0].callback=T}}let{requestHook:A}=p;typeof A=="function"&&l&&(0,sf.safeExecuteInTheMiddle)(()=>{let{database:_,host:T,port:y,user:I}=this.connectionParameters;A(f,{connection:{database:_,host:T,port:y,user:I},query:{text:l.text,values:l.values,name:l.name}})},_=>{_&&t._diag.error("Error running query hook",_)},!0);let h;try{h=r.apply(this,o)}catch(_){throw _ instanceof Error&&f.recordException(nc.sanitizedErrorMessage(_)),f.setStatus({code:bs.SpanStatusCode.ERROR,message:nc.getErrorMessage(_)}),f.end(),_}return h instanceof Promise?h.then(_=>new Promise(T=>{nc.handleExecutionResult(t.getConfig(),f,_),d(),f.end(),T(_)})).catch(_=>new Promise((T,y)=>{_ instanceof Error&&f.recordException(nc.sanitizedErrorMessage(_)),f.setStatus({code:bs.SpanStatusCode.ERROR,message:_.message}),d(),f.end(),y(_)})):h})}_setPoolConnectEventListeners(t){if(t[Hbt.EVENT_LISTENERS_SET])return;let r=nc.getPoolName(t.options);t.on("connect",()=>{this._connectionsCounter=nc.updateCounter(r,t,this._connectionsCount,this._connectionPendingRequests,this._connectionsCounter)}),t.on("acquire",()=>{this._connectionsCounter=nc.updateCounter(r,t,this._connectionsCount,this._connectionPendingRequests,this._connectionsCounter)}),t.on("remove",()=>{this._connectionsCounter=nc.updateCounter(r,t,this._connectionsCount,this._connectionPendingRequests,this._connectionsCounter)}),t.on("release",()=>{this._connectionsCounter=nc.updateCounter(r,t,this._connectionsCount,this._connectionPendingRequests,this._connectionsCounter)}),t[Hbt.EVENT_LISTENERS_SET]=!0}_getPoolConnectPatch(){let t=this;return r=>function(o){if(nc.shouldSkipInstrumentation(t.getConfig()))return r.call(this,o);let i=t.tracer.startSpan(Ybt.SpanNames.POOL_CONNECT,{kind:bs.SpanKind.CLIENT,attributes:nc.getSemanticAttributesFromPoolConnection(this.options,t._semconvStability)});if(t._setPoolConnectEventListeners(this),o){let a=bs.trace.getSpan(bs.context.active());o=nc.patchCallbackPGPool(i,o),a&&(o=bs.context.bind(bs.context.active(),o))}let s=bs.context.with(bs.trace.setSpan(bs.context.active(),i),()=>r.call(this,o));return Vbt(i,s)}}};dte.PgInstrumentation=fDe;function Vbt(e,t){if(!(t instanceof Promise))return t;let r=t;return bs.context.bind(bs.context.active(),r.then(n=>(e.end(),n)).catch(n=>(n instanceof Error&&e.recordException(nc.sanitizedErrorMessage(n)),e.setStatus({code:bs.SpanStatusCode.ERROR,message:nc.getErrorMessage(n)}),e.end(),Promise.reject(n))))}});var Wbt=S(NL=>{"use strict";Object.defineProperty(NL,"__esModule",{value:!0});NL.AttributeNames=NL.PgInstrumentation=void 0;var QZr=zbt();Object.defineProperty(NL,"PgInstrumentation",{enumerable:!0,get:function(){return QZr.PgInstrumentation}});var GZr=lDe();Object.defineProperty(NL,"AttributeNames",{enumerable:!0,get:function(){return GZr.AttributeNames}})});var fyt=S(xL=>{"use strict";Object.defineProperty(xL,"__esModule",{value:!0});xL.PACKAGE_NAME=xL.PACKAGE_VERSION=void 0;xL.PACKAGE_VERSION="0.55.0";xL.PACKAGE_NAME="@opentelemetry/instrumentation-hapi"});var EDe=S(TT=>{"use strict";Object.defineProperty(TT,"__esModule",{value:!0});TT.HapiLifecycleMethodNames=TT.HapiLayerType=TT.handlerPatched=TT.HapiComponentName=void 0;TT.HapiComponentName="@hapi/hapi";TT.handlerPatched=Symbol("hapi-handler-patched");TT.HapiLayerType={ROUTER:"router",PLUGIN:"plugin",EXT:"server.ext"};TT.HapiLifecycleMethodNames=new Set(["onPreAuth","onCredentials","onPostAuth","onPreHandler","onPostHandler","onPreResponse","onRequest"])});var myt=S(gte=>{"use strict";Object.defineProperty(gte,"__esModule",{value:!0});gte.ATTR_HTTP_METHOD=void 0;gte.ATTR_HTTP_METHOD="http.method"});var SDe=S(yq=>{"use strict";Object.defineProperty(yq,"__esModule",{value:!0});yq.AttributeNames=void 0;var rXr;(function(e){e.HAPI_TYPE="hapi.type",e.PLUGIN_NAME="hapi.plugin.name",e.EXT_TYPE="server.ext.type"})(rXr=yq.AttributeNames||(yq.AttributeNames={}))});var hyt=S(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});Pl.getPluginFromInput=Pl.getExtMetadata=Pl.getRouteMetadata=Pl.isPatchableExtMethod=Pl.isDirectExtInput=Pl.isLifecycleExtEventObj=Pl.isLifecycleExtType=Pl.getPluginName=void 0;var gyt=Ss(),nXr=myt(),Cq=EDe(),$v=SDe(),Ayt=(Nn(),Hn(Xi));function oXr(e){return e.name?e.name:e.pkg.name}Pl.getPluginName=oXr;var iXr=e=>typeof e=="string"&&Cq.HapiLifecycleMethodNames.has(e);Pl.isLifecycleExtType=iXr;var sXr=e=>{let t=e?.type;return t!==void 0&&(0,Pl.isLifecycleExtType)(t)};Pl.isLifecycleExtEventObj=sXr;var aXr=e=>Array.isArray(e)&&e.length<=3&&(0,Pl.isLifecycleExtType)(e[0])&&typeof e[1]=="function";Pl.isDirectExtInput=aXr;var cXr=e=>!Array.isArray(e);Pl.isPatchableExtMethod=cXr;var lXr=(e,t,r)=>{let n={[gyt.ATTR_HTTP_ROUTE]:e.path};t&Ayt.SemconvStability.OLD&&(n[nXr.ATTR_HTTP_METHOD]=e.method),t&Ayt.SemconvStability.STABLE&&(n[gyt.ATTR_HTTP_REQUEST_METHOD]=e.method);let o;return r?(n[$v.AttributeNames.HAPI_TYPE]=Cq.HapiLayerType.PLUGIN,n[$v.AttributeNames.PLUGIN_NAME]=r,o=`${r}: route - ${e.path}`):(n[$v.AttributeNames.HAPI_TYPE]=Cq.HapiLayerType.ROUTER,o=`route - ${e.path}`),{attributes:n,name:o}};Pl.getRouteMetadata=lXr;var uXr=(e,t)=>t?{attributes:{[$v.AttributeNames.EXT_TYPE]:e,[$v.AttributeNames.HAPI_TYPE]:Cq.HapiLayerType.EXT,[$v.AttributeNames.PLUGIN_NAME]:t},name:`${t}: ext - ${e}`}:{attributes:{[$v.AttributeNames.EXT_TYPE]:e,[$v.AttributeNames.HAPI_TYPE]:Cq.HapiLayerType.EXT},name:`ext - ${e}`};Pl.getExtMetadata=uXr;var dXr=e=>"plugin"in e?"plugin"in e.plugin?e.plugin.plugin:e.plugin:e;Pl.getPluginFromInput=dXr});var Syt=S(Ate=>{"use strict";Object.defineProperty(Ate,"__esModule",{value:!0});Ate.HapiInstrumentation=void 0;var Mg=zt(),_yt=(Ys(),Hn(XA)),Iq=(Nn(),Hn(Xi)),Eyt=fyt(),vq=EDe(),nC=hyt(),TDe=class extends Iq.InstrumentationBase{_semconvStability;constructor(t={}){super(Eyt.PACKAGE_NAME,Eyt.PACKAGE_VERSION,t),this._semconvStability=(0,Iq.semconvStabilityFromStr)("http",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}init(){return new Iq.InstrumentationNodeModuleDefinition(vq.HapiComponentName,[">=17.0.0 <22"],t=>{let r=t[Symbol.toStringTag]==="Module"?t.default:t;return(0,Iq.isWrapped)(r.server)||this._wrap(r,"server",this._getServerPatch.bind(this)),(0,Iq.isWrapped)(r.Server)||this._wrap(r,"Server",this._getServerPatch.bind(this)),r},t=>{let r=t[Symbol.toStringTag]==="Module"?t.default:t;this._massUnwrap([r],["server","Server"])})}_getServerPatch(t){let r=this,n=this;return function(i){let s=t.apply(this,[i]);return n._wrap(s,"route",a=>r._getServerRoutePatch.bind(r)(a)),n._wrap(s,"ext",a=>r._getServerExtPatch.bind(r)(a)),n._wrap(s,"register",r._getServerRegisterPatch.bind(r)),s}}_getServerRegisterPatch(t){let r=this;return function(o,i){if(Array.isArray(o))for(let s of o){let a=(0,nC.getPluginFromInput)(s);r._wrapRegisterHandler(a)}else{let s=(0,nC.getPluginFromInput)(o);r._wrapRegisterHandler(s)}return t.apply(this,[o,i])}}_getServerExtPatch(t,r){let n=this;return function(...i){if(Array.isArray(i[0])){let s=i[0];for(let a=0;a<s.length;a++){let c=s[a];if((0,nC.isLifecycleExtType)(c.type)){let l=c,u=n._wrapExtMethods(l.method,c.type,r);l.method=u,s[a]=l}}return t.apply(this,i)}else if((0,nC.isDirectExtInput)(i)){let s=i,a=s[1],c=n._wrapExtMethods(a,s[0],r);return t.apply(this,[s[0],c,s[2]])}else if((0,nC.isLifecycleExtEventObj)(i[0])){let s=i[0],a=n._wrapExtMethods(s.method,s.type,r);return s.method=a,t.call(this,s)}return t.apply(this,i)}}_getServerRoutePatch(t,r){let n=this;return function(o){if(Array.isArray(o))for(let i=0;i<o.length;i++){let s=n._wrapRouteHandler.call(n,o[i],r);o[i]=s}else o=n._wrapRouteHandler.call(n,o,r);return t.apply(this,[o])}}_wrapRegisterHandler(t){let r=this,n=(0,nC.getPluginName)(t),o=t.register,i=this,s=function(a,c){return i._wrap(a,"route",l=>r._getServerRoutePatch.bind(r)(l,n)),i._wrap(a,"ext",l=>r._getServerExtPatch.bind(r)(l,n)),o.call(this,a,c)};t.register=s}_wrapExtMethods(t,r,n){let o=this;if(t instanceof Array){for(let i=0;i<t.length;i++)t[i]=o._wrapExtMethods(t[i],r);return t}else if((0,nC.isPatchableExtMethod)(t))return t[vq.handlerPatched]===!0?t:(t[vq.handlerPatched]=!0,async function(...s){if(Mg.trace.getSpan(Mg.context.active())===void 0)return await t.apply(this,s);let a=(0,nC.getExtMetadata)(r,n),c=o.tracer.startSpan(a.name,{attributes:a.attributes});try{return await Mg.context.with(Mg.trace.setSpan(Mg.context.active(),c),t,void 0,...s)}catch(l){throw c.recordException(l),c.setStatus({code:Mg.SpanStatusCode.ERROR,message:l.message}),l}finally{c.end()}});return t}_wrapRouteHandler(t,r){let n=this;if(t[vq.handlerPatched]===!0)return t;t[vq.handlerPatched]=!0;let o=i=>async function(...s){if(Mg.trace.getSpan(Mg.context.active())===void 0)return await i.call(this,...s);let a=(0,_yt.getRPCMetadata)(Mg.context.active());a?.type===_yt.RPCType.HTTP&&(a.route=t.path);let c=(0,nC.getRouteMetadata)(t,n._semconvStability,r),l=n.tracer.startSpan(c.name,{attributes:c.attributes});try{return await Mg.context.with(Mg.trace.setSpan(Mg.context.active(),l),()=>i.call(this,...s))}catch(u){throw l.recordException(u),l.setStatus({code:Mg.SpanStatusCode.ERROR,message:u.message}),u}finally{l.end()}};if(typeof t.handler=="function")t.handler=o(t.handler);else if(typeof t.options=="function"){let i=t.options;t.options=function(s){let a=i(s);return typeof a.handler=="function"&&(a.handler=o(a.handler)),a}}else typeof t.options?.handler=="function"&&(t.options.handler=o(t.options.handler));return t}};Ate.HapiInstrumentation=TDe});var Tyt=S(OL=>{"use strict";Object.defineProperty(OL,"__esModule",{value:!0});OL.AttributeNames=OL.HapiInstrumentation=void 0;var pXr=Syt();Object.defineProperty(OL,"HapiInstrumentation",{enumerable:!0,get:function(){return pXr.HapiInstrumentation}});var fXr=SDe();Object.defineProperty(OL,"AttributeNames",{enumerable:!0,get:function(){return fXr.AttributeNames}})});var Ete=S(Dq=>{"use strict";Object.defineProperty(Dq,"__esModule",{value:!0});Dq.KoaLayerType=void 0;var EXr;(function(e){e.ROUTER="router",e.MIDDLEWARE="middleware"})(EXr=Dq.KoaLayerType||(Dq.KoaLayerType={}))});var Nyt=S(wL=>{"use strict";Object.defineProperty(wL,"__esModule",{value:!0});wL.PACKAGE_NAME=wL.PACKAGE_VERSION=void 0;wL.PACKAGE_VERSION="0.57.0";wL.PACKAGE_NAME="@opentelemetry/instrumentation-koa"});var bDe=S(Nq=>{"use strict";Object.defineProperty(Nq,"__esModule",{value:!0});Nq.AttributeNames=void 0;var SXr;(function(e){e.KOA_TYPE="koa.type",e.KOA_NAME="koa.name"})(SXr=Nq.AttributeNames||(Nq.AttributeNames={}))});var Oyt=S(ML=>{"use strict";Object.defineProperty(ML,"__esModule",{value:!0});ML.isLayerIgnored=ML.getMiddlewareMetadata=void 0;var xyt=Ete(),Ste=bDe(),TXr=Ss(),bXr=(e,t,r,n)=>r?{attributes:{[Ste.AttributeNames.KOA_NAME]:n?.toString(),[Ste.AttributeNames.KOA_TYPE]:xyt.KoaLayerType.ROUTER,[TXr.ATTR_HTTP_ROUTE]:n?.toString()},name:e._matchedRouteName||`router - ${n}`}:{attributes:{[Ste.AttributeNames.KOA_NAME]:t.name??"middleware",[Ste.AttributeNames.KOA_TYPE]:xyt.KoaLayerType.MIDDLEWARE},name:`middleware - ${t.name}`};ML.getMiddlewareMetadata=bXr;var yXr=(e,t)=>!!(Array.isArray(t?.ignoreLayersType)&&t?.ignoreLayersType?.includes(e));ML.isLayerIgnored=yXr});var wyt=S(Tte=>{"use strict";Object.defineProperty(Tte,"__esModule",{value:!0});Tte.kLayerPatched=void 0;Tte.kLayerPatched=Symbol("koa-layer-patched")});var Fyt=S(bte=>{"use strict";Object.defineProperty(bte,"__esModule",{value:!0});bte.KoaInstrumentation=void 0;var bT=zt(),xq=(Nn(),Hn(Xi)),Myt=Ete(),Byt=Nyt(),kyt=Oyt(),Pyt=(Ys(),Hn(XA)),Lyt=wyt(),yDe=class extends xq.InstrumentationBase{constructor(t={}){super(Byt.PACKAGE_NAME,Byt.PACKAGE_VERSION,t)}init(){return new xq.InstrumentationNodeModuleDefinition("koa",[">=2.0.0 <4"],t=>{let r=t[Symbol.toStringTag]==="Module"?t.default:t;return r==null?r:((0,xq.isWrapped)(r.prototype.use)&&this._unwrap(r.prototype,"use"),this._wrap(r.prototype,"use",this._getKoaUsePatch.bind(this)),t)},t=>{let r=t[Symbol.toStringTag]==="Module"?t.default:t;(0,xq.isWrapped)(r.prototype.use)&&this._unwrap(r.prototype,"use")})}_getKoaUsePatch(t){let r=this;return function(o){let i;return o.router?i=r._patchRouterDispatch(o):i=r._patchLayer(o,!1),t.apply(this,[i])}}_patchRouterDispatch(t){bT.diag.debug("Patching @koa/router dispatch");let n=t.router?.stack??[];for(let o of n){let i=o.path,s=o.stack;for(let a=0;a<s.length;a++){let c=s[a];s[a]=this._patchLayer(c,!0,i)}}return t}_patchLayer(t,r,n){let o=r?Myt.KoaLayerType.ROUTER:Myt.KoaLayerType.MIDDLEWARE;return t[Lyt.kLayerPatched]===!0||(0,kyt.isLayerIgnored)(o,this.getConfig())?t:t.constructor.name==="GeneratorFunction"||t.constructor.name==="AsyncGeneratorFunction"?(bT.diag.debug("ignoring generator-based Koa middleware layer"),t):(t[Lyt.kLayerPatched]=!0,bT.diag.debug("patching Koa middleware layer"),async(i,s)=>{if(bT.trace.getSpan(bT.context.active())===void 0)return t(i,s);let c=(0,kyt.getMiddlewareMetadata)(i,t,r,n),l=this.tracer.startSpan(c.name,{attributes:c.attributes}),u=(0,Pyt.getRPCMetadata)(bT.context.active());u?.type===Pyt.RPCType.HTTP&&i._matchedRoute&&(u.route=i._matchedRoute.toString());let{requestHook:d}=this.getConfig();d&&(0,xq.safeExecuteInTheMiddle)(()=>d(l,{context:i,middlewareLayer:t,layerType:o}),f=>{f&&bT.diag.error("koa instrumentation: request hook failed",f)},!0);let p=bT.trace.setSpan(bT.context.active(),l);return bT.context.with(p,async()=>{try{return await t(i,s)}catch(f){throw l.recordException(f),f}finally{l.end()}})})}};bte.KoaInstrumentation=yDe});var Uyt=S(Vv=>{"use strict";Object.defineProperty(Vv,"__esModule",{value:!0});Vv.KoaLayerType=Vv.AttributeNames=Vv.KoaInstrumentation=void 0;var CXr=Fyt();Object.defineProperty(Vv,"KoaInstrumentation",{enumerable:!0,get:function(){return CXr.KoaInstrumentation}});var IXr=bDe();Object.defineProperty(Vv,"AttributeNames",{enumerable:!0,get:function(){return IXr.AttributeNames}});var vXr=Ete();Object.defineProperty(Vv,"KoaLayerType",{enumerable:!0,get:function(){return vXr.KoaLayerType}})});var CDe=S(IE=>{"use strict";Object.defineProperty(IE,"__esModule",{value:!0});IE.ConnectNames=IE.ConnectTypes=IE.AttributeNames=void 0;var DXr;(function(e){e.CONNECT_TYPE="connect.type",e.CONNECT_NAME="connect.name"})(DXr=IE.AttributeNames||(IE.AttributeNames={}));var NXr;(function(e){e.MIDDLEWARE="middleware",e.REQUEST_HANDLER="request_handler"})(NXr=IE.ConnectTypes||(IE.ConnectTypes={}));var xXr;(function(e){e.MIDDLEWARE="middleware",e.REQUEST_HANDLER="request handler"})(xXr=IE.ConnectNames||(IE.ConnectNames={}))});var Yyt=S(BL=>{"use strict";Object.defineProperty(BL,"__esModule",{value:!0});BL.PACKAGE_NAME=BL.PACKAGE_VERSION=void 0;BL.PACKAGE_VERSION="0.52.0";BL.PACKAGE_NAME="@opentelemetry/instrumentation-connect"});var Vyt=S(yte=>{"use strict";Object.defineProperty(yte,"__esModule",{value:!0});yte._LAYERS_STORE_PROPERTY=void 0;yte._LAYERS_STORE_PROPERTY=Symbol("opentelemetry.instrumentation-connect.request-route-stack")});var zyt=S(Wv=>{"use strict";Object.defineProperty(Wv,"__esModule",{value:!0});Wv.generateRoute=Wv.replaceCurrentStackRoute=Wv.addNewStackLayer=void 0;var OXr=zt(),zv=Vyt(),wXr=e=>{Array.isArray(e[zv._LAYERS_STORE_PROPERTY])===!1&&Object.defineProperty(e,zv._LAYERS_STORE_PROPERTY,{enumerable:!1,value:[]}),e[zv._LAYERS_STORE_PROPERTY].push("/");let t=e[zv._LAYERS_STORE_PROPERTY].length;return()=>{t===e[zv._LAYERS_STORE_PROPERTY].length?e[zv._LAYERS_STORE_PROPERTY].pop():OXr.diag.warn("Connect: Trying to pop the stack multiple time")}};Wv.addNewStackLayer=wXr;var MXr=(e,t)=>{t&&e[zv._LAYERS_STORE_PROPERTY].splice(-1,1,t)};Wv.replaceCurrentStackRoute=MXr;var BXr=e=>e[zv._LAYERS_STORE_PROPERTY].reduce((t,r)=>t.replace(/\/+$/,"")+r);Wv.generateRoute=BXr});var Kyt=S(jv=>{"use strict";Object.defineProperty(jv,"__esModule",{value:!0});jv.ConnectInstrumentation=jv.ANONYMOUS_NAME=void 0;var kXr=zt(),Wyt=(Ys(),Hn(XA)),kL=CDe(),jyt=Yyt(),Cte=(Nn(),Hn(Xi)),PXr=Ss(),IDe=zyt();jv.ANONYMOUS_NAME="anonymous";var vDe=class extends Cte.InstrumentationBase{constructor(t={}){super(jyt.PACKAGE_NAME,jyt.PACKAGE_VERSION,t)}init(){return[new Cte.InstrumentationNodeModuleDefinition("connect",[">=3.0.0 <4"],t=>this._patchConstructor(t))]}_patchApp(t){(0,Cte.isWrapped)(t.use)||this._wrap(t,"use",this._patchUse.bind(this)),(0,Cte.isWrapped)(t.handle)||this._wrap(t,"handle",this._patchHandle.bind(this))}_patchConstructor(t){let r=this;return function(...n){let o=t.apply(this,n);return r._patchApp(o),o}}_patchNext(t,r){return function(o){let i=t.apply(this,[o]);return r(),i}}_startSpan(t,r){let n,o,i;t?(n=kL.ConnectTypes.REQUEST_HANDLER,i=kL.ConnectNames.REQUEST_HANDLER,o=t):(n=kL.ConnectTypes.MIDDLEWARE,i=kL.ConnectNames.MIDDLEWARE,o=r.name||jv.ANONYMOUS_NAME);let s=`${i} - ${o}`,a={attributes:{[PXr.ATTR_HTTP_ROUTE]:t.length>0?t:"/",[kL.AttributeNames.CONNECT_TYPE]:n,[kL.AttributeNames.CONNECT_NAME]:o}};return this.tracer.startSpan(s,a)}_patchMiddleware(t,r){let n=this,o=r.length===4;function i(){if(!n.isEnabled())return r.apply(this,arguments);let[s,a,c]=o?[1,2,3]:[0,1,2],l=arguments[s],u=arguments[a],d=arguments[c];(0,IDe.replaceCurrentStackRoute)(l,t);let p=(0,Wyt.getRPCMetadata)(kXr.context.active());t&&p?.type===Wyt.RPCType.HTTP&&(p.route=(0,IDe.generateRoute)(l));let f="";t?f=`request handler - ${t}`:f=`middleware - ${r.name||jv.ANONYMOUS_NAME}`;let A=n._startSpan(t,r);n._diag.debug("start span",f);let h=!1;function _(){h?n._diag.debug(`span ${A.name} - already finished`):(h=!0,n._diag.debug(`finishing span ${A.name}`),A.end()),u.removeListener("close",_)}return u.addListener("close",_),arguments[c]=n._patchNext(d,_),r.apply(this,arguments)}return Object.defineProperty(i,"length",{value:r.length,writable:!1,configurable:!0}),i}_patchUse(t){let r=this;return function(...n){let o=n[n.length-1],i=n[n.length-2]||"";return n[n.length-1]=r._patchMiddleware(i,o),t.apply(this,n)}}_patchHandle(t){let r=this;return function(){let[n,o]=[0,2],i=arguments[n],s=arguments[o],a=(0,IDe.addNewStackLayer)(i);return typeof s=="function"&&(arguments[o]=r._patchOut(s,a)),t.apply(this,arguments)}}_patchOut(t,r){return function(...o){return r(),Reflect.apply(t,this,o)}}};jv.ConnectInstrumentation=vDe});var Zyt=S(mh=>{"use strict";Object.defineProperty(mh,"__esModule",{value:!0});mh.ConnectTypes=mh.ConnectNames=mh.AttributeNames=mh.ANONYMOUS_NAME=mh.ConnectInstrumentation=void 0;var Jyt=Kyt();Object.defineProperty(mh,"ConnectInstrumentation",{enumerable:!0,get:function(){return Jyt.ConnectInstrumentation}});Object.defineProperty(mh,"ANONYMOUS_NAME",{enumerable:!0,get:function(){return Jyt.ANONYMOUS_NAME}});var RDe=CDe();Object.defineProperty(mh,"AttributeNames",{enumerable:!0,get:function(){return RDe.AttributeNames}});Object.defineProperty(mh,"ConnectNames",{enumerable:!0,get:function(){return RDe.ConnectNames}});Object.defineProperty(mh,"ConnectTypes",{enumerable:!0,get:function(){return RDe.ConnectTypes}})});var nCt=S(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});Hu.DB_SYSTEM_VALUE_MSSQL=Hu.ATTR_NET_PEER_PORT=Hu.ATTR_NET_PEER_NAME=Hu.ATTR_DB_USER=Hu.ATTR_DB_SYSTEM=Hu.ATTR_DB_STATEMENT=Hu.ATTR_DB_SQL_TABLE=Hu.ATTR_DB_NAME=void 0;Hu.ATTR_DB_NAME="db.name";Hu.ATTR_DB_SQL_TABLE="db.sql.table";Hu.ATTR_DB_STATEMENT="db.statement";Hu.ATTR_DB_SYSTEM="db.system";Hu.ATTR_DB_USER="db.user";Hu.ATTR_NET_PEER_NAME="net.peer.name";Hu.ATTR_NET_PEER_PORT="net.peer.port";Hu.DB_SYSTEM_VALUE_MSSQL="mssql"});var oCt=S(PL=>{"use strict";Object.defineProperty(PL,"__esModule",{value:!0});PL.once=PL.getSpanName=void 0;function FXr(e,t,r,n){return e==="execBulkLoad"&&n&&t?`${e} ${n} ${t}`:e==="callProcedure"?t?`${e} ${r} ${t}`:`${e} ${r}`:t?`${e} ${t}`:`${e}`}PL.getSpanName=FXr;var UXr=e=>{let t=!1;return(...r)=>{if(!t)return t=!0,e(...r)}};PL.once=UXr});var iCt=S(LL=>{"use strict";Object.defineProperty(LL,"__esModule",{value:!0});LL.PACKAGE_NAME=LL.PACKAGE_VERSION=void 0;LL.PACKAGE_VERSION="0.27.0";LL.PACKAGE_NAME="@opentelemetry/instrumentation-tedious"});var uCt=S(Jv=>{"use strict";Object.defineProperty(Jv,"__esModule",{value:!0});Jv.TediousInstrumentation=Jv.INJECTED_CTX=void 0;var FL=zt(),QXr=se("events"),Ite=(Nn(),Hn(Xi)),Kv=nCt(),sCt=oCt(),aCt=iCt(),lCt=Symbol("opentelemetry.instrumentation-tedious.current-database");Jv.INJECTED_CTX=Symbol("opentelemetry.instrumentation-tedious.context-info-injected");var cCt=["callProcedure","execSql","execSqlBatch","execBulkLoad","prepare","execute"];function vte(e){Object.defineProperty(this,lCt,{value:e,writable:!0})}var DDe=class e extends Ite.InstrumentationBase{static COMPONENT="tedious";constructor(t={}){super(aCt.PACKAGE_NAME,aCt.PACKAGE_VERSION,t)}init(){return[new Ite.InstrumentationNodeModuleDefinition(e.COMPONENT,[">=1.11.0 <20"],t=>{let r=t.Connection.prototype;for(let n of cCt)(0,Ite.isWrapped)(r[n])&&this._unwrap(r,n),this._wrap(r,n,this._patchQuery(n,t));return(0,Ite.isWrapped)(r.connect)&&this._unwrap(r,"connect"),this._wrap(r,"connect",this._patchConnect),t},t=>{if(t===void 0)return;let r=t.Connection.prototype;for(let n of cCt)this._unwrap(r,n);this._unwrap(r,"connect")})]}_patchConnect(t){return function(){return vte.call(this,this.config?.options?.database),this.removeListener("databaseChange",vte),this.on("databaseChange",vte),this.once("end",()=>{this.removeListener("databaseChange",vte)}),t.apply(this,arguments)}}_buildTraceparent(t){let r=t.spanContext();return`00-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||FL.TraceFlags.NONE).toString(16)}`}_injectContextInfo(t,r,n){return new Promise(o=>{try{let i="set context_info @opentelemetry_traceparent",s=new r.Request(i,c=>{o()});Object.defineProperty(s,Jv.INJECTED_CTX,{value:!0});let a=Buffer.from(n,"utf8");s.addParameter("opentelemetry_traceparent",r.TYPES.VarBinary,a,{length:a.length}),t.execSql(s)}catch{o()}})}_shouldInjectFor(t){return t==="execSql"||t==="execSqlBatch"||t==="callProcedure"||t==="execute"}_patchQuery(t,r){return n=>{let o=this;function i(s){if(s?.[Jv.INJECTED_CTX])return n.apply(this,arguments);if(!(s instanceof QXr.EventEmitter))return o._diag.warn(`Unexpected invocation of patched ${t} method. Span not recorded`),n.apply(this,arguments);let a=0,c=0,l=()=>c++,u=()=>a++,d=this[lCt],p=(I=>I.sqlTextOrProcedure==="sp_prepare"&&I.parametersByName?.stmt?.value?I.parametersByName.stmt.value:I.sqlTextOrProcedure)(s),f=o.tracer.startSpan((0,sCt.getSpanName)(t,d,p,s.table),{kind:FL.SpanKind.CLIENT,attributes:{[Kv.ATTR_DB_SYSTEM]:Kv.DB_SYSTEM_VALUE_MSSQL,[Kv.ATTR_DB_NAME]:d,[Kv.ATTR_NET_PEER_PORT]:this.config?.options?.port,[Kv.ATTR_NET_PEER_NAME]:this.config?.server,[Kv.ATTR_DB_USER]:this.config?.userName??this.config?.authentication?.options?.userName,[Kv.ATTR_DB_STATEMENT]:p,[Kv.ATTR_DB_SQL_TABLE]:s.table}}),A=(0,sCt.once)(I=>{s.removeListener("done",l),s.removeListener("doneInProc",l),s.removeListener("doneProc",u),s.removeListener("error",A),this.removeListener("end",A),f.setAttribute("tedious.procedure_count",a),f.setAttribute("tedious.statement_count",c),I&&f.setStatus({code:FL.SpanStatusCode.ERROR,message:I.message}),f.end()});s.on("done",l),s.on("doneInProc",l),s.on("doneProc",u),s.once("error",A),this.on("end",A),typeof s.callback=="function"?o._wrap(s,"callback",o._patchCallbackQuery(A)):o._diag.error("Expected request.callback to be a function");let h=()=>FL.context.with(FL.trace.setSpan(FL.context.active(),f),n,this,...arguments);if(!(o.getConfig().enableTraceContextPropagation&&o._shouldInjectFor(t)))return h();let y=o._buildTraceparent(f);o._injectContextInfo(this,r,y).finally(h)}return Object.defineProperty(i,"length",{value:n.length,writable:!1}),i}}_patchCallbackQuery(t){return r=>function(n,o,i){return t(n),r.apply(this,arguments)}}};Jv.TediousInstrumentation=DDe});var dCt=S(Rte=>{"use strict";Object.defineProperty(Rte,"__esModule",{value:!0});Rte.TediousInstrumentation=void 0;var GXr=uCt();Object.defineProperty(Rte,"TediousInstrumentation",{enumerable:!0,get:function(){return GXr.TediousInstrumentation}})});var ACt=S(UL=>{"use strict";Object.defineProperty(UL,"__esModule",{value:!0});UL.PACKAGE_NAME=UL.PACKAGE_VERSION=void 0;UL.PACKAGE_VERSION="0.52.0";UL.PACKAGE_NAME="@opentelemetry/instrumentation-generic-pool"});var _Ct=S(Dte=>{"use strict";Object.defineProperty(Dte,"__esModule",{value:!0});Dte.GenericPoolInstrumentation=void 0;var QL=zt(),F1=(Nn(),Hn(Xi)),hCt=ACt(),NDe="generic-pool",xDe=class extends F1.InstrumentationBase{_isDisabled=!1;constructor(t={}){super(hCt.PACKAGE_NAME,hCt.PACKAGE_VERSION,t)}init(){return[new F1.InstrumentationNodeModuleDefinition(NDe,[">=3.0.0 <4"],t=>{let r=t.Pool;return(0,F1.isWrapped)(r.prototype.acquire)&&this._unwrap(r.prototype,"acquire"),this._wrap(r.prototype,"acquire",this._acquirePatcher.bind(this)),t},t=>{let r=t.Pool;return this._unwrap(r.prototype,"acquire"),t}),new F1.InstrumentationNodeModuleDefinition(NDe,[">=2.4.0 <3"],t=>{let r=t.Pool;return(0,F1.isWrapped)(r.prototype.acquire)&&this._unwrap(r.prototype,"acquire"),this._wrap(r.prototype,"acquire",this._acquireWithCallbacksPatcher.bind(this)),t},t=>{let r=t.Pool;return this._unwrap(r.prototype,"acquire"),t}),new F1.InstrumentationNodeModuleDefinition(NDe,[">=2.0.0 <2.4"],t=>(this._isDisabled=!1,(0,F1.isWrapped)(t.Pool)&&this._unwrap(t,"Pool"),this._wrap(t,"Pool",this._poolWrapper.bind(this)),t),t=>(this._isDisabled=!0,t))]}_acquirePatcher(t){let r=this;return function(...o){let i=QL.context.active(),s=r.tracer.startSpan("generic-pool.acquire",{},i);return QL.context.with(QL.trace.setSpan(i,s),()=>t.call(this,...o).then(a=>(s.end(),a),a=>{throw s.recordException(a),s.end(),a}))}}_poolWrapper(t){let r=this;return function(){let o=t.apply(this,arguments);return r._wrap(o,"acquire",r._acquireWithCallbacksPatcher.bind(r)),o}}_acquireWithCallbacksPatcher(t){let r=this;return function(o,i){if(r._isDisabled)return t.call(this,o,i);let s=QL.context.active(),a=r.tracer.startSpan("generic-pool.acquire",{},s);return QL.context.with(QL.trace.setSpan(s,a),()=>{t.call(this,(c,l)=>{if(a.end(),o)return o(c,l)},i)})}}};Dte.GenericPoolInstrumentation=xDe});var ECt=S(Nte=>{"use strict";Object.defineProperty(Nte,"__esModule",{value:!0});Nte.GenericPoolInstrumentation=void 0;var $Xr=_Ct();Object.defineProperty(Nte,"GenericPoolInstrumentation",{enumerable:!0,get:function(){return $Xr.GenericPoolInstrumentation}})});var ODe=S(yT=>{"use strict";Object.defineProperty(yT,"__esModule",{value:!0});yT.ATTR_NET_PEER_PORT=yT.ATTR_NET_PEER_NAME=yT.ATTR_MESSAGING_SYSTEM=yT.ATTR_MESSAGING_OPERATION=void 0;yT.ATTR_MESSAGING_OPERATION="messaging.operation";yT.ATTR_MESSAGING_SYSTEM="messaging.system";yT.ATTR_NET_PEER_NAME="net.peer.name";yT.ATTR_NET_PEER_PORT="net.peer.port"});var wDe=S(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});bc.ATTR_MESSAGING_CONVERSATION_ID=bc.OLD_ATTR_MESSAGING_MESSAGE_ID=bc.MESSAGING_DESTINATION_KIND_VALUE_TOPIC=bc.ATTR_MESSAGING_URL=bc.ATTR_MESSAGING_PROTOCOL_VERSION=bc.ATTR_MESSAGING_PROTOCOL=bc.MESSAGING_OPERATION_VALUE_PROCESS=bc.ATTR_MESSAGING_RABBITMQ_ROUTING_KEY=bc.ATTR_MESSAGING_DESTINATION_KIND=bc.ATTR_MESSAGING_DESTINATION=void 0;bc.ATTR_MESSAGING_DESTINATION="messaging.destination";bc.ATTR_MESSAGING_DESTINATION_KIND="messaging.destination_kind";bc.ATTR_MESSAGING_RABBITMQ_ROUTING_KEY="messaging.rabbitmq.routing_key";bc.MESSAGING_OPERATION_VALUE_PROCESS="process";bc.ATTR_MESSAGING_PROTOCOL="messaging.protocol";bc.ATTR_MESSAGING_PROTOCOL_VERSION="messaging.protocol_version";bc.ATTR_MESSAGING_URL="messaging.url";bc.MESSAGING_DESTINATION_KIND_VALUE_TOPIC="topic";bc.OLD_ATTR_MESSAGING_MESSAGE_ID="messaging.message_id";bc.ATTR_MESSAGING_CONVERSATION_ID="messaging.conversation_id"});var MDe=S(U1=>{"use strict";Object.defineProperty(U1,"__esModule",{value:!0});U1.DEFAULT_CONFIG=U1.EndOperation=void 0;var VXr;(function(e){e.AutoAck="auto ack",e.Ack="ack",e.AckAll="ackAll",e.Reject="reject",e.Nack="nack",e.NackAll="nackAll",e.ChannelClosed="channel closed",e.ChannelError="channel error",e.InstrumentationTimeout="instrumentation timeout"})(VXr=U1.EndOperation||(U1.EndOperation={}));U1.DEFAULT_CONFIG={consumeTimeoutMs:1e3*60,useLinksForConsume:!1}});var RCt=S(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});yc.isConfirmChannelTracing=yc.unmarkConfirmChannelTracing=yc.markConfirmChannelTracing=yc.getConnectionAttributesFromUrl=yc.getConnectionAttributesFromServer=yc.normalizeExchange=yc.CONNECTION_ATTRIBUTES=yc.CHANNEL_CONSUME_TIMEOUT_TIMER=yc.CHANNEL_SPANS_NOT_ENDED=yc.MESSAGE_STORED_SPAN=void 0;var BDe=zt(),Oq=ODe(),xte=wDe();yc.MESSAGE_STORED_SPAN=Symbol("opentelemetry.amqplib.message.stored-span");yc.CHANNEL_SPANS_NOT_ENDED=Symbol("opentelemetry.amqplib.channel.spans-not-ended");yc.CHANNEL_CONSUME_TIMEOUT_TIMER=Symbol("opentelemetry.amqplib.channel.consumer-timeout-timer");yc.CONNECTION_ATTRIBUTES=Symbol("opentelemetry.amqplib.connection.attributes");var kDe=(0,BDe.createContextKey)("opentelemetry.amqplib.channel.is-confirm-channel"),zXr=e=>e!==""?e:"<default>";yc.normalizeExchange=zXr;var WXr=e=>e.replace(/:[^:@/]*@/,":***@"),CCt=(e,t)=>e||(t==="AMQP"?5672:5671),ICt=e=>{let t=e||"amqp";return(t.endsWith(":")?t.substring(0,t.length-1):t).toUpperCase()},vCt=e=>e||"localhost",GL=(e,t,r,n)=>r?{[t]:r}:(BDe.diag.error(`amqplib instrumentation: could not extract connection attribute ${n} from user supplied url`,{url:e}),{}),jXr=e=>{let t=e.serverProperties.product?.toLowerCase?.();return t?{[Oq.ATTR_MESSAGING_SYSTEM]:t}:{}};yc.getConnectionAttributesFromServer=jXr;var KXr=e=>{let t={[xte.ATTR_MESSAGING_PROTOCOL_VERSION]:"0.9.1"};if(e=e||"amqp://localhost",typeof e=="object"){let r=e,n=ICt(r?.protocol);Object.assign(t,{...GL(e,xte.ATTR_MESSAGING_PROTOCOL,n,"protocol")});let o=vCt(r?.hostname);Object.assign(t,{...GL(e,Oq.ATTR_NET_PEER_NAME,o,"hostname")});let i=CCt(r.port,n);Object.assign(t,{...GL(e,Oq.ATTR_NET_PEER_PORT,i,"port")})}else{let r=WXr(e);t[xte.ATTR_MESSAGING_URL]=r;try{let n=new URL(r),o=ICt(n.protocol);Object.assign(t,{...GL(r,xte.ATTR_MESSAGING_PROTOCOL,o,"protocol")});let i=vCt(n.hostname);Object.assign(t,{...GL(r,Oq.ATTR_NET_PEER_NAME,i,"hostname")});let s=CCt(n.port?parseInt(n.port):void 0,o);Object.assign(t,{...GL(r,Oq.ATTR_NET_PEER_PORT,s,"port")})}catch(n){BDe.diag.error("amqplib instrumentation: error while extracting connection details from connection url",{censoredUrl:r,err:n})}}return t};yc.getConnectionAttributesFromUrl=KXr;var JXr=e=>e.setValue(kDe,!0);yc.markConfirmChannelTracing=JXr;var ZXr=e=>e.deleteValue(kDe);yc.unmarkConfirmChannelTracing=ZXr;var XXr=e=>e.getValue(kDe)===!0;yc.isConfirmChannelTracing=XXr});var DCt=S(HL=>{"use strict";Object.defineProperty(HL,"__esModule",{value:!0});HL.PACKAGE_NAME=HL.PACKAGE_VERSION=void 0;HL.PACKAGE_VERSION="0.55.0";HL.PACKAGE_NAME="@opentelemetry/instrumentation-amqplib"});var xCt=S(Mte=>{"use strict";Object.defineProperty(Mte,"__esModule",{value:!0});Mte.AmqplibInstrumentation=void 0;var oc=zt(),Ote=(Ys(),Hn(XA)),Qi=(Nn(),Hn(Xi)),een=ODe(),Bg=wDe(),af=MDe(),Cc=RCt(),NCt=DCt(),wte=[">=0.5.5 <1"],PDe=class extends Qi.InstrumentationBase{constructor(t={}){super(NCt.PACKAGE_NAME,NCt.PACKAGE_VERSION,{...af.DEFAULT_CONFIG,...t})}setConfig(t={}){super.setConfig({...af.DEFAULT_CONFIG,...t})}init(){let t=new Qi.InstrumentationNodeModuleFile("amqplib/lib/channel_model.js",wte,this.patchChannelModel.bind(this),this.unpatchChannelModel.bind(this)),r=new Qi.InstrumentationNodeModuleFile("amqplib/lib/callback_model.js",wte,this.patchChannelModel.bind(this),this.unpatchChannelModel.bind(this)),n=new Qi.InstrumentationNodeModuleFile("amqplib/lib/connect.js",wte,this.patchConnect.bind(this),this.unpatchConnect.bind(this));return new Qi.InstrumentationNodeModuleDefinition("amqplib",wte,void 0,void 0,[t,n,r])}patchConnect(t){return t=this.unpatchConnect(t),(0,Qi.isWrapped)(t.connect)||this._wrap(t,"connect",this.getConnectPatch.bind(this)),t}unpatchConnect(t){return(0,Qi.isWrapped)(t.connect)&&this._unwrap(t,"connect"),t}patchChannelModel(t,r){return(0,Qi.isWrapped)(t.Channel.prototype.publish)||this._wrap(t.Channel.prototype,"publish",this.getPublishPatch.bind(this,r)),(0,Qi.isWrapped)(t.Channel.prototype.consume)||this._wrap(t.Channel.prototype,"consume",this.getConsumePatch.bind(this,r)),(0,Qi.isWrapped)(t.Channel.prototype.ack)||this._wrap(t.Channel.prototype,"ack",this.getAckPatch.bind(this,!1,af.EndOperation.Ack)),(0,Qi.isWrapped)(t.Channel.prototype.nack)||this._wrap(t.Channel.prototype,"nack",this.getAckPatch.bind(this,!0,af.EndOperation.Nack)),(0,Qi.isWrapped)(t.Channel.prototype.reject)||this._wrap(t.Channel.prototype,"reject",this.getAckPatch.bind(this,!0,af.EndOperation.Reject)),(0,Qi.isWrapped)(t.Channel.prototype.ackAll)||this._wrap(t.Channel.prototype,"ackAll",this.getAckAllPatch.bind(this,!1,af.EndOperation.AckAll)),(0,Qi.isWrapped)(t.Channel.prototype.nackAll)||this._wrap(t.Channel.prototype,"nackAll",this.getAckAllPatch.bind(this,!0,af.EndOperation.NackAll)),(0,Qi.isWrapped)(t.Channel.prototype.emit)||this._wrap(t.Channel.prototype,"emit",this.getChannelEmitPatch.bind(this)),(0,Qi.isWrapped)(t.ConfirmChannel.prototype.publish)||this._wrap(t.ConfirmChannel.prototype,"publish",this.getConfirmedPublishPatch.bind(this,r)),t}unpatchChannelModel(t){return(0,Qi.isWrapped)(t.Channel.prototype.publish)&&this._unwrap(t.Channel.prototype,"publish"),(0,Qi.isWrapped)(t.Channel.prototype.consume)&&this._unwrap(t.Channel.prototype,"consume"),(0,Qi.isWrapped)(t.Channel.prototype.ack)&&this._unwrap(t.Channel.prototype,"ack"),(0,Qi.isWrapped)(t.Channel.prototype.nack)&&this._unwrap(t.Channel.prototype,"nack"),(0,Qi.isWrapped)(t.Channel.prototype.reject)&&this._unwrap(t.Channel.prototype,"reject"),(0,Qi.isWrapped)(t.Channel.prototype.ackAll)&&this._unwrap(t.Channel.prototype,"ackAll"),(0,Qi.isWrapped)(t.Channel.prototype.nackAll)&&this._unwrap(t.Channel.prototype,"nackAll"),(0,Qi.isWrapped)(t.Channel.prototype.emit)&&this._unwrap(t.Channel.prototype,"emit"),(0,Qi.isWrapped)(t.ConfirmChannel.prototype.publish)&&this._unwrap(t.ConfirmChannel.prototype,"publish"),t}getConnectPatch(t){return function(n,o,i){return t.call(this,n,o,function(s,a){if(s==null){let c=(0,Cc.getConnectionAttributesFromUrl)(n),l=(0,Cc.getConnectionAttributesFromServer)(a);a[Cc.CONNECTION_ATTRIBUTES]={...c,...l}}i.apply(this,arguments)})}}getChannelEmitPatch(t){let r=this;return function(o){if(o==="close"){r.endAllSpansOnChannel(this,!0,af.EndOperation.ChannelClosed,void 0);let i=this[Cc.CHANNEL_CONSUME_TIMEOUT_TIMER];i&&clearInterval(i),this[Cc.CHANNEL_CONSUME_TIMEOUT_TIMER]=void 0}else o==="error"&&r.endAllSpansOnChannel(this,!0,af.EndOperation.ChannelError,void 0);return t.apply(this,arguments)}}getAckAllPatch(t,r,n){let o=this;return function(s){return o.endAllSpansOnChannel(this,t,r,s),n.apply(this,arguments)}}getAckPatch(t,r,n){let o=this;return function(s,a,c){let l=this,u=r===af.EndOperation.Reject?a:c,d=l[Cc.CHANNEL_SPANS_NOT_ENDED]??[],p=d.findIndex(f=>f.msg===s);if(p<0)o.endConsumerSpan(s,t,r,u);else if(r!==af.EndOperation.Reject&&a){for(let f=0;f<=p;f++)o.endConsumerSpan(d[f].msg,t,r,u);d.splice(0,p+1)}else o.endConsumerSpan(s,t,r,u),d.splice(p,1);return n.apply(this,arguments)}}getConsumePatch(t,r){let n=this;return function(i,s,a){let c=this;if(!Object.prototype.hasOwnProperty.call(c,Cc.CHANNEL_SPANS_NOT_ENDED)){let{consumeTimeoutMs:u}=n.getConfig();if(u){let d=setInterval(()=>{n.checkConsumeTimeoutOnChannel(c)},u);d.unref(),c[Cc.CHANNEL_CONSUME_TIMEOUT_TIMER]=d}c[Cc.CHANNEL_SPANS_NOT_ENDED]=[]}let l=function(u){if(!u)return s.call(this,u);let d=u.properties.headers??{},p=oc.propagation.extract(oc.ROOT_CONTEXT,d),f=u.fields?.exchange,A;if(n._config.useLinksForConsume){let y=p?oc.trace.getSpan(p)?.spanContext():void 0;p=void 0,y&&(A=[{context:y}])}let h=n.tracer.startSpan(`${i} process`,{kind:oc.SpanKind.CONSUMER,attributes:{...c?.connection?.[Cc.CONNECTION_ATTRIBUTES],[Bg.ATTR_MESSAGING_DESTINATION]:f,[Bg.ATTR_MESSAGING_DESTINATION_KIND]:Bg.MESSAGING_DESTINATION_KIND_VALUE_TOPIC,[Bg.ATTR_MESSAGING_RABBITMQ_ROUTING_KEY]:u.fields?.routingKey,[een.ATTR_MESSAGING_OPERATION]:Bg.MESSAGING_OPERATION_VALUE_PROCESS,[Bg.OLD_ATTR_MESSAGING_MESSAGE_ID]:u?.properties.messageId,[Bg.ATTR_MESSAGING_CONVERSATION_ID]:u?.properties.correlationId},links:A},p),{consumeHook:_}=n.getConfig();_&&(0,Qi.safeExecuteInTheMiddle)(()=>_(h,{moduleVersion:t,msg:u}),y=>{y&&oc.diag.error("amqplib instrumentation: consumerHook error",y)},!0),a?.noAck||(c[Cc.CHANNEL_SPANS_NOT_ENDED].push({msg:u,timeOfConsume:(0,Ote.hrTime)()}),u[Cc.MESSAGE_STORED_SPAN]=h);let T=p||oc.ROOT_CONTEXT;oc.context.with(oc.trace.setSpan(T,h),()=>{s.call(this,u)}),a?.noAck&&(n.callConsumeEndHook(h,u,!1,af.EndOperation.AutoAck),h.end())};return arguments[1]=l,r.apply(this,arguments)}}getConfirmedPublishPatch(t,r){let n=this;return function(i,s,a,c,l){let u=this,{span:d,modifiedOptions:p}=n.createPublishSpan(n,i,s,u,c),{publishHook:f}=n.getConfig();f&&(0,Qi.safeExecuteInTheMiddle)(()=>f(d,{moduleVersion:t,exchange:i,routingKey:s,content:a,options:p,isConfirmChannel:!0}),T=>{T&&oc.diag.error("amqplib instrumentation: publishHook error",T)},!0);let A=function(T,y){try{l?.call(this,T,y)}finally{let{publishConfirmHook:I}=n.getConfig();I&&(0,Qi.safeExecuteInTheMiddle)(()=>I(d,{moduleVersion:t,exchange:i,routingKey:s,content:a,options:c,isConfirmChannel:!0,confirmError:T}),v=>{v&&oc.diag.error("amqplib instrumentation: publishConfirmHook error",v)},!0),T&&d.setStatus({code:oc.SpanStatusCode.ERROR,message:"message confirmation has been nack'ed"}),d.end()}},h=(0,Cc.markConfirmChannelTracing)(oc.context.active()),_=[...arguments];return _[3]=p,_[4]=oc.context.bind((0,Cc.unmarkConfirmChannelTracing)(oc.trace.setSpan(h,d)),A),oc.context.with(h,r.bind(this,..._))}}getPublishPatch(t,r){let n=this;return function(i,s,a,c){if((0,Cc.isConfirmChannelTracing)(oc.context.active()))return r.apply(this,arguments);{let l=this,{span:u,modifiedOptions:d}=n.createPublishSpan(n,i,s,l,c),{publishHook:p}=n.getConfig();p&&(0,Qi.safeExecuteInTheMiddle)(()=>p(u,{moduleVersion:t,exchange:i,routingKey:s,content:a,options:d,isConfirmChannel:!1}),h=>{h&&oc.diag.error("amqplib instrumentation: publishHook error",h)},!0);let f=[...arguments];f[3]=d;let A=r.apply(this,f);return u.end(),A}}}createPublishSpan(t,r,n,o,i){let s=(0,Cc.normalizeExchange)(r),a=t.tracer.startSpan(`publish ${s}`,{kind:oc.SpanKind.PRODUCER,attributes:{...o.connection[Cc.CONNECTION_ATTRIBUTES],[Bg.ATTR_MESSAGING_DESTINATION]:r,[Bg.ATTR_MESSAGING_DESTINATION_KIND]:Bg.MESSAGING_DESTINATION_KIND_VALUE_TOPIC,[Bg.ATTR_MESSAGING_RABBITMQ_ROUTING_KEY]:n,[Bg.OLD_ATTR_MESSAGING_MESSAGE_ID]:i?.messageId,[Bg.ATTR_MESSAGING_CONVERSATION_ID]:i?.correlationId}}),c=i??{};return c.headers=c.headers??{},oc.propagation.inject(oc.trace.setSpan(oc.context.active(),a),c.headers),{span:a,modifiedOptions:c}}endConsumerSpan(t,r,n,o){let i=t[Cc.MESSAGE_STORED_SPAN];i&&(r!==!1&&i.setStatus({code:oc.SpanStatusCode.ERROR,message:n!==af.EndOperation.ChannelClosed&&n!==af.EndOperation.ChannelError?`${n} called on message${o===!0?" with requeue":o===!1?" without requeue":""}`:n}),this.callConsumeEndHook(i,t,r,n),i.end(),t[Cc.MESSAGE_STORED_SPAN]=void 0)}endAllSpansOnChannel(t,r,n,o){(t[Cc.CHANNEL_SPANS_NOT_ENDED]??[]).forEach(s=>{this.endConsumerSpan(s.msg,r,n,o)}),t[Cc.CHANNEL_SPANS_NOT_ENDED]=[]}callConsumeEndHook(t,r,n,o){let{consumeEndHook:i}=this.getConfig();i&&(0,Qi.safeExecuteInTheMiddle)(()=>i(t,{msg:r,rejected:n,endOperation:o}),s=>{s&&oc.diag.error("amqplib instrumentation: consumerEndHook error",s)},!0)}checkConsumeTimeoutOnChannel(t){let r=(0,Ote.hrTime)(),n=t[Cc.CHANNEL_SPANS_NOT_ENDED]??[],o,{consumeTimeoutMs:i}=this.getConfig();for(o=0;o<n.length;o++){let s=n[o],a=(0,Ote.hrTimeDuration)(s.timeOfConsume,r);if((0,Ote.hrTimeToMilliseconds)(a)<i)break;this.endConsumerSpan(s.msg,null,af.EndOperation.InstrumentationTimeout,!0)}n.splice(0,o)}};Mte.AmqplibInstrumentation=PDe});var wCt=S(Zv=>{"use strict";Object.defineProperty(Zv,"__esModule",{value:!0});Zv.EndOperation=Zv.DEFAULT_CONFIG=Zv.AmqplibInstrumentation=void 0;var ten=xCt();Object.defineProperty(Zv,"AmqplibInstrumentation",{enumerable:!0,get:function(){return ten.AmqplibInstrumentation}});var OCt=MDe();Object.defineProperty(Zv,"DEFAULT_CONFIG",{enumerable:!0,get:function(){return OCt.DEFAULT_CONFIG}});Object.defineProperty(Zv,"EndOperation",{enumerable:!0,get:function(){return OCt.EndOperation}})});var Men,$te,UDe=Q(()=>{Men=typeof global=="object"&&global&&global.Object===Object&&global,$te=Men});var Ben,ken,Ll,vE=Q(()=>{UDe();Ben=typeof self=="object"&&self&&self.Object===Object&&self,ken=$te||Ben||Function("return this")(),Ll=ken});var Pen,qu,Q1=Q(()=>{vE();Pen=Ll.Symbol,qu=Pen});function Uen(e){var t=Len.call(e,Mq),r=e[Mq];try{e[Mq]=void 0;var n=!0}catch{}var o=Fen.call(e);return n&&(t?e[Mq]=r:delete e[Mq]),o}var p0t,Len,Fen,Mq,f0t,m0t=Q(()=>{Q1();p0t=Object.prototype,Len=p0t.hasOwnProperty,Fen=p0t.toString,Mq=qu?qu.toStringTag:void 0;f0t=Uen});function Hen(e){return Gen.call(e)}var Qen,Gen,g0t,A0t=Q(()=>{Qen=Object.prototype,Gen=Qen.toString;g0t=Hen});function Yen(e){return e==null?e===void 0?$en:qen:h0t&&h0t in Object(e)?f0t(e):g0t(e)}var qen,$en,h0t,kg,G1=Q(()=>{Q1();m0t();A0t();qen="[object Null]",$en="[object Undefined]",h0t=qu?qu.toStringTag:void 0;kg=Yen});function Ven(e){return e!=null&&typeof e=="object"}var du,IT=Q(()=>{du=Ven});function Wen(e){return typeof e=="symbol"||du(e)&&kg(e)==zen}var zen,YL,Yte=Q(()=>{G1();IT();zen="[object Symbol]";YL=Wen});function jen(e,t){for(var r=-1,n=e==null?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var vT,VL=Q(()=>{vT=jen});var Ken,ia,Pg=Q(()=>{Ken=Array.isArray,ia=Ken});function S0t(e){if(typeof e=="string")return e;if(ia(e))return vT(e,S0t)+"";if(YL(e))return E0t?E0t.call(e):"";var t=e+"";return t=="0"&&1/e==-Jen?"-0":t}var Jen,_0t,E0t,T0t,b0t=Q(()=>{Q1();VL();Pg();Yte();Jen=1/0,_0t=qu?qu.prototype:void 0,E0t=_0t?_0t.toString:void 0;T0t=S0t});function Zen(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var lf,Xv=Q(()=>{lf=Zen});function Xen(e){return e}var zL,Vte=Q(()=>{zL=Xen});function otn(e){if(!lf(e))return!1;var t=kg(e);return t==ttn||t==rtn||t==etn||t==ntn}var etn,ttn,rtn,ntn,zte,QDe=Q(()=>{G1();Xv();etn="[object AsyncFunction]",ttn="[object Function]",rtn="[object GeneratorFunction]",ntn="[object Proxy]";zte=otn});var itn,Wte,y0t=Q(()=>{vE();itn=Ll["__core-js_shared__"],Wte=itn});function stn(e){return!!C0t&&C0t in e}var C0t,I0t,v0t=Q(()=>{y0t();C0t=(function(){var e=/[^.]+$/.exec(Wte&&Wte.keys&&Wte.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();I0t=stn});function ltn(e){if(e!=null){try{return ctn.call(e)}catch{}try{return e+""}catch{}}return""}var atn,ctn,iC,GDe=Q(()=>{atn=Function.prototype,ctn=atn.toString;iC=ltn});function htn(e){if(!lf(e)||I0t(e))return!1;var t=zte(e)?Atn:dtn;return t.test(iC(e))}var utn,dtn,ptn,ftn,mtn,gtn,Atn,R0t,D0t=Q(()=>{QDe();v0t();Xv();GDe();utn=/[\\^$.*+?()[\]{}|]/g,dtn=/^\[object .+?Constructor\]$/,ptn=Function.prototype,ftn=Object.prototype,mtn=ptn.toString,gtn=ftn.hasOwnProperty,Atn=RegExp("^"+mtn.call(gtn).replace(utn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");R0t=htn});function _tn(e,t){return e?.[t]}var N0t,x0t=Q(()=>{N0t=_tn});function Etn(e,t){var r=N0t(e,t);return R0t(r)?r:void 0}var Am,eR=Q(()=>{D0t();x0t();Am=Etn});var Stn,jte,O0t=Q(()=>{eR();vE();Stn=Am(Ll,"WeakMap"),jte=Stn});var w0t,Ttn,M0t,B0t=Q(()=>{Xv();w0t=Object.create,Ttn=(function(){function e(){}return function(t){if(!lf(t))return{};if(w0t)return w0t(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}})(),M0t=Ttn});function btn(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var k0t,P0t=Q(()=>{k0t=btn});function ytn(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var L0t,F0t=Q(()=>{L0t=ytn});function Rtn(e){var t=0,r=0;return function(){var n=vtn(),o=Itn-(n-r);if(r=n,o>0){if(++t>=Ctn)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Ctn,Itn,vtn,U0t,Q0t=Q(()=>{Ctn=800,Itn=16,vtn=Date.now;U0t=Rtn});function Dtn(e){return function(){return e}}var G0t,H0t=Q(()=>{G0t=Dtn});var Ntn,WL,HDe=Q(()=>{eR();Ntn=(function(){try{var e=Am(Object,"defineProperty");return e({},"",{}),e}catch{}})(),WL=Ntn});var xtn,q0t,$0t=Q(()=>{H0t();HDe();Vte();xtn=WL?function(e,t){return WL(e,"toString",{configurable:!0,enumerable:!1,value:G0t(t),writable:!0})}:zL,q0t=xtn});var Otn,Kte,qDe=Q(()=>{$0t();Q0t();Otn=U0t(q0t),Kte=Otn});function wtn(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var Y0t,V0t=Q(()=>{Y0t=wtn});function ktn(e,t){var r=typeof e;return t=t??Mtn,!!t&&(r=="number"||r!="symbol"&&Btn.test(e))&&e>-1&&e%1==0&&e<t}var Mtn,Btn,jL,Jte=Q(()=>{Mtn=9007199254740991,Btn=/^(?:0|[1-9]\d*)$/;jL=ktn});function Ptn(e,t,r){t=="__proto__"&&WL?WL(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var KL,Zte=Q(()=>{HDe();KL=Ptn});function Ltn(e,t){return e===t||e!==e&&t!==t}var JL,Xte=Q(()=>{JL=Ltn});function Qtn(e,t,r){var n=e[t];(!(Utn.call(e,t)&&JL(n,r))||r===void 0&&!(t in e))&&KL(e,t,r)}var Ftn,Utn,tR,Bq=Q(()=>{Zte();Xte();Ftn=Object.prototype,Utn=Ftn.hasOwnProperty;tR=Qtn});function Gtn(e,t,r,n){var o=!r;r||(r={});for(var i=-1,s=t.length;++i<s;){var a=t[i],c=n?n(r[a],e[a],a,r,e):void 0;c===void 0&&(c=e[a]),o?KL(r,a,c):tR(r,a,c)}return r}var RT,ZL=Q(()=>{Bq();Zte();RT=Gtn});function Htn(e,t,r){return t=z0t(t===void 0?e.length-1:t,0),function(){for(var n=arguments,o=-1,i=z0t(n.length-t,0),s=Array(i);++o<i;)s[o]=n[t+o];o=-1;for(var a=Array(t+1);++o<t;)a[o]=n[o];return a[t]=r(s),k0t(e,this,a)}}var z0t,ere,$De=Q(()=>{P0t();z0t=Math.max;ere=Htn});function qtn(e,t){return Kte(ere(e,t,zL),e+"")}var W0t,j0t=Q(()=>{Vte();$De();qDe();W0t=qtn});function Ytn(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=$tn}var $tn,XL,tre=Q(()=>{$tn=9007199254740991;XL=Ytn});function Vtn(e){return e!=null&&XL(e.length)&&!zte(e)}var rR,kq=Q(()=>{QDe();tre();rR=Vtn});function Wtn(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||ztn;return e===r}var ztn,e2,rre=Q(()=>{ztn=Object.prototype;e2=Wtn});function jtn(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var nre,YDe=Q(()=>{nre=jtn});function Jtn(e){return du(e)&&kg(e)==Ktn}var Ktn,VDe,K0t=Q(()=>{G1();IT();Ktn="[object Arguments]";VDe=Jtn});var J0t,Ztn,Xtn,ern,t2,ore=Q(()=>{K0t();IT();J0t=Object.prototype,Ztn=J0t.hasOwnProperty,Xtn=J0t.propertyIsEnumerable,ern=VDe((function(){return arguments})())?VDe:function(e){return du(e)&&Ztn.call(e,"callee")&&!Xtn.call(e,"callee")},t2=ern});function trn(){return!1}var Z0t,X0t=Q(()=>{Z0t=trn});var rIt,eIt,rrn,tIt,nrn,orn,H1,ire=Q(()=>{vE();X0t();rIt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,eIt=rIt&&typeof module=="object"&&module&&!module.nodeType&&module,rrn=eIt&&eIt.exports===rIt,tIt=rrn?Ll.Buffer:void 0,nrn=tIt?tIt.isBuffer:void 0,orn=nrn||Z0t,H1=orn});function Nrn(e){return du(e)&&XL(e.length)&&!!sa[kg(e)]}var irn,srn,arn,crn,lrn,urn,drn,prn,frn,mrn,grn,Arn,hrn,_rn,Ern,Srn,Trn,brn,yrn,Crn,Irn,vrn,Rrn,Drn,sa,nIt,oIt=Q(()=>{G1();tre();IT();irn="[object Arguments]",srn="[object Array]",arn="[object Boolean]",crn="[object Date]",lrn="[object Error]",urn="[object Function]",drn="[object Map]",prn="[object Number]",frn="[object Object]",mrn="[object RegExp]",grn="[object Set]",Arn="[object String]",hrn="[object WeakMap]",_rn="[object ArrayBuffer]",Ern="[object DataView]",Srn="[object Float32Array]",Trn="[object Float64Array]",brn="[object Int8Array]",yrn="[object Int16Array]",Crn="[object Int32Array]",Irn="[object Uint8Array]",vrn="[object Uint8ClampedArray]",Rrn="[object Uint16Array]",Drn="[object Uint32Array]",sa={};sa[Srn]=sa[Trn]=sa[brn]=sa[yrn]=sa[Crn]=sa[Irn]=sa[vrn]=sa[Rrn]=sa[Drn]=!0;sa[irn]=sa[srn]=sa[_rn]=sa[arn]=sa[Ern]=sa[crn]=sa[lrn]=sa[urn]=sa[drn]=sa[prn]=sa[frn]=sa[mrn]=sa[grn]=sa[Arn]=sa[hrn]=!1;nIt=Nrn});function xrn(e){return function(t){return e(t)}}var r2,sre=Q(()=>{r2=xrn});var iIt,Pq,Orn,zDe,wrn,sC,are=Q(()=>{UDe();iIt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Pq=iIt&&typeof module=="object"&&module&&!module.nodeType&&module,Orn=Pq&&Pq.exports===iIt,zDe=Orn&&$te.process,wrn=(function(){try{var e=Pq&&Pq.require&&Pq.require("util").types;return e||zDe&&zDe.binding&&zDe.binding("util")}catch{}})(),sC=wrn});var sIt,Mrn,cre,WDe=Q(()=>{oIt();sre();are();sIt=sC&&sC.isTypedArray,Mrn=sIt?r2(sIt):nIt,cre=Mrn});function Prn(e,t){var r=ia(e),n=!r&&t2(e),o=!r&&!n&&H1(e),i=!r&&!n&&!o&&cre(e),s=r||n||o||i,a=s?nre(e.length,String):[],c=a.length;for(var l in e)(t||krn.call(e,l))&&!(s&&(l=="length"||o&&(l=="offset"||l=="parent")||i&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||jL(l,c)))&&a.push(l);return a}var Brn,krn,lre,jDe=Q(()=>{YDe();ore();Pg();ire();Jte();WDe();Brn=Object.prototype,krn=Brn.hasOwnProperty;lre=Prn});function Lrn(e,t){return function(r){return e(t(r))}}var ure,KDe=Q(()=>{ure=Lrn});var Frn,aIt,cIt=Q(()=>{KDe();Frn=ure(Object.keys,Object),aIt=Frn});function Grn(e){if(!e2(e))return aIt(e);var t=[];for(var r in Object(e))Qrn.call(e,r)&&r!="constructor"&&t.push(r);return t}var Urn,Qrn,lIt,uIt=Q(()=>{rre();cIt();Urn=Object.prototype,Qrn=Urn.hasOwnProperty;lIt=Grn});function Hrn(e){return rR(e)?lre(e):lIt(e)}var Ah,q1=Q(()=>{jDe();uIt();kq();Ah=Hrn});function qrn(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var dIt,pIt=Q(()=>{dIt=qrn});function Vrn(e){if(!lf(e))return dIt(e);var t=e2(e),r=[];for(var n in e)n=="constructor"&&(t||!Yrn.call(e,n))||r.push(n);return r}var $rn,Yrn,fIt,mIt=Q(()=>{Xv();rre();pIt();$rn=Object.prototype,Yrn=$rn.hasOwnProperty;fIt=Vrn});function zrn(e){return rR(e)?lre(e,!0):fIt(e)}var n2,dre=Q(()=>{jDe();mIt();kq();n2=zrn});function Krn(e,t){if(ia(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||YL(e)?!0:jrn.test(e)||!Wrn.test(e)||t!=null&&e in Object(t)}var Wrn,jrn,o2,pre=Q(()=>{Pg();Yte();Wrn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,jrn=/^\w*$/;o2=Krn});var Jrn,aC,Lq=Q(()=>{eR();Jrn=Am(Object,"create"),aC=Jrn});function Zrn(){this.__data__=aC?aC(null):{},this.size=0}var gIt,AIt=Q(()=>{Lq();gIt=Zrn});function Xrn(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var hIt,_It=Q(()=>{hIt=Xrn});function nnn(e){var t=this.__data__;if(aC){var r=t[e];return r===enn?void 0:r}return rnn.call(t,e)?t[e]:void 0}var enn,tnn,rnn,EIt,SIt=Q(()=>{Lq();enn="__lodash_hash_undefined__",tnn=Object.prototype,rnn=tnn.hasOwnProperty;EIt=nnn});function snn(e){var t=this.__data__;return aC?t[e]!==void 0:inn.call(t,e)}var onn,inn,TIt,bIt=Q(()=>{Lq();onn=Object.prototype,inn=onn.hasOwnProperty;TIt=snn});function cnn(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=aC&&t===void 0?ann:t,this}var ann,yIt,CIt=Q(()=>{Lq();ann="__lodash_hash_undefined__";yIt=cnn});function i2(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}var JDe,IIt=Q(()=>{AIt();_It();SIt();bIt();CIt();i2.prototype.clear=gIt;i2.prototype.delete=hIt;i2.prototype.get=EIt;i2.prototype.has=TIt;i2.prototype.set=yIt;JDe=i2});function lnn(){this.__data__=[],this.size=0}var vIt,RIt=Q(()=>{vIt=lnn});function unn(e,t){for(var r=e.length;r--;)if(JL(e[r][0],t))return r;return-1}var nR,Fq=Q(()=>{Xte();nR=unn});function fnn(e){var t=this.__data__,r=nR(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():pnn.call(t,r,1),--this.size,!0}var dnn,pnn,DIt,NIt=Q(()=>{Fq();dnn=Array.prototype,pnn=dnn.splice;DIt=fnn});function mnn(e){var t=this.__data__,r=nR(t,e);return r<0?void 0:t[r][1]}var xIt,OIt=Q(()=>{Fq();xIt=mnn});function gnn(e){return nR(this.__data__,e)>-1}var wIt,MIt=Q(()=>{Fq();wIt=gnn});function Ann(e,t){var r=this.__data__,n=nR(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var BIt,kIt=Q(()=>{Fq();BIt=Ann});function s2(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}var oR,Uq=Q(()=>{RIt();NIt();OIt();MIt();kIt();s2.prototype.clear=vIt;s2.prototype.delete=DIt;s2.prototype.get=xIt;s2.prototype.has=wIt;s2.prototype.set=BIt;oR=s2});var hnn,iR,fre=Q(()=>{eR();vE();hnn=Am(Ll,"Map"),iR=hnn});function _nn(){this.size=0,this.__data__={hash:new JDe,map:new(iR||oR),string:new JDe}}var PIt,LIt=Q(()=>{IIt();Uq();fre();PIt=_nn});function Enn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var FIt,UIt=Q(()=>{FIt=Enn});function Snn(e,t){var r=e.__data__;return FIt(t)?r[typeof t=="string"?"string":"hash"]:r.map}var sR,Qq=Q(()=>{UIt();sR=Snn});function Tnn(e){var t=sR(this,e).delete(e);return this.size-=t?1:0,t}var QIt,GIt=Q(()=>{Qq();QIt=Tnn});function bnn(e){return sR(this,e).get(e)}var HIt,qIt=Q(()=>{Qq();HIt=bnn});function ynn(e){return sR(this,e).has(e)}var $It,YIt=Q(()=>{Qq();$It=ynn});function Cnn(e,t){var r=sR(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var VIt,zIt=Q(()=>{Qq();VIt=Cnn});function a2(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}var $1,mre=Q(()=>{LIt();GIt();qIt();YIt();zIt();a2.prototype.clear=PIt;a2.prototype.delete=QIt;a2.prototype.get=HIt;a2.prototype.has=$It;a2.prototype.set=VIt;$1=a2});function ZDe(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Inn);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=e.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(ZDe.Cache||$1),r}var Inn,ze,XDe=Q(()=>{mre();Inn="Expected a function";ZDe.Cache=$1;ze=ZDe});function Rnn(e){var t=ze(e,function(n){return r.size===vnn&&r.clear(),n}),r=t.cache;return t}var vnn,WIt,jIt=Q(()=>{XDe();vnn=500;WIt=Rnn});var Dnn,Nnn,xnn,KIt,JIt=Q(()=>{jIt();Dnn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Nnn=/\\(\\)?/g,xnn=WIt(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Dnn,function(r,n,o,i){t.push(o?i.replace(Nnn,"$1"):n||r)}),t}),KIt=xnn});function Onn(e){return e==null?"":T0t(e)}var ZIt,XIt=Q(()=>{b0t();ZIt=Onn});function wnn(e,t){return ia(e)?e:o2(e,t)?[e]:KIt(ZIt(e))}var hh,Y1=Q(()=>{Pg();pre();JIt();XIt();hh=wnn});function Bnn(e){if(typeof e=="string"||YL(e))return e;var t=e+"";return t=="0"&&1/e==-Mnn?"-0":t}var Mnn,Lg,V1=Q(()=>{Yte();Mnn=1/0;Lg=Bnn});function knn(e,t){t=hh(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[Lg(t[r++])];return r&&r==n?e:void 0}var aR,Gq=Q(()=>{Y1();V1();aR=knn});function Pnn(e,t,r){var n=e==null?void 0:aR(e,t);return n===void 0?r:n}var evt,tvt=Q(()=>{Gq();evt=Pnn});function Lnn(e,t){for(var r=-1,n=t.length,o=e.length;++r<n;)e[o+r]=t[r];return e}var c2,gre=Q(()=>{c2=Lnn});function Fnn(e){return ia(e)||t2(e)||!!(rvt&&e&&e[rvt])}var rvt,nvt,ovt=Q(()=>{Q1();ore();Pg();rvt=qu?qu.isConcatSpreadable:void 0;nvt=Fnn});function ivt(e,t,r,n,o){var i=-1,s=e.length;for(r||(r=nvt),o||(o=[]);++i<s;){var a=e[i];t>0&&r(a)?t>1?ivt(a,t-1,r,n,o):c2(o,a):n||(o[o.length]=a)}return o}var svt,avt=Q(()=>{gre();ovt();svt=ivt});function Unn(e){var t=e==null?0:e.length;return t?svt(e,1):[]}var cvt,lvt=Q(()=>{avt();cvt=Unn});function Qnn(e){return Kte(ere(e,void 0,cvt),e+"")}var Are,eNe=Q(()=>{lvt();$De();qDe();Are=Qnn});var Gnn,l2,hre=Q(()=>{KDe();Gnn=ure(Object.getPrototypeOf,Object),l2=Gnn});function znn(e){if(!du(e)||kg(e)!=Hnn)return!1;var t=l2(e);if(t===null)return!0;var r=Ynn.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&uvt.call(r)==Vnn}var Hnn,qnn,$nn,uvt,Ynn,Vnn,dvt,pvt=Q(()=>{G1();hre();IT();Hnn="[object Object]",qnn=Function.prototype,$nn=Object.prototype,uvt=qnn.toString,Ynn=$nn.hasOwnProperty,Vnn=uvt.call(Object);dvt=znn});function Wnn(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),r=r>o?o:r,r<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}var fvt,mvt=Q(()=>{fvt=Wnn});function jnn(){this.__data__=new oR,this.size=0}var gvt,Avt=Q(()=>{Uq();gvt=jnn});function Knn(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var hvt,_vt=Q(()=>{hvt=Knn});function Jnn(e){return this.__data__.get(e)}var Evt,Svt=Q(()=>{Evt=Jnn});function Znn(e){return this.__data__.has(e)}var Tvt,bvt=Q(()=>{Tvt=Znn});function eon(e,t){var r=this.__data__;if(r instanceof oR){var n=r.__data__;if(!iR||n.length<Xnn-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new $1(n)}return r.set(e,t),this.size=r.size,this}var Xnn,yvt,Cvt=Q(()=>{Uq();fre();mre();Xnn=200;yvt=eon});function u2(e){var t=this.__data__=new oR(e);this.size=t.size}var cR,_re=Q(()=>{Uq();Avt();_vt();Svt();bvt();Cvt();u2.prototype.clear=gvt;u2.prototype.delete=hvt;u2.prototype.get=Evt;u2.prototype.has=Tvt;u2.prototype.set=yvt;cR=u2});function ton(e,t){return e&&RT(t,Ah(t),e)}var Ivt,vvt=Q(()=>{ZL();q1();Ivt=ton});function ron(e,t){return e&&RT(t,n2(t),e)}var Rvt,Dvt=Q(()=>{ZL();dre();Rvt=ron});function oon(e,t){if(t)return e.slice();var r=e.length,n=Ovt?Ovt(r):new e.constructor(r);return e.copy(n),n}var wvt,Nvt,non,xvt,Ovt,Mvt,Bvt=Q(()=>{vE();wvt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Nvt=wvt&&typeof module=="object"&&module&&!module.nodeType&&module,non=Nvt&&Nvt.exports===wvt,xvt=non?Ll.Buffer:void 0,Ovt=xvt?xvt.allocUnsafe:void 0;Mvt=oon});function ion(e,t){for(var r=-1,n=e==null?0:e.length,o=0,i=[];++r<n;){var s=e[r];t(s,r,e)&&(i[o++]=s)}return i}var Ere,tNe=Q(()=>{Ere=ion});function son(){return[]}var Sre,rNe=Q(()=>{Sre=son});var aon,con,kvt,lon,d2,Tre=Q(()=>{tNe();rNe();aon=Object.prototype,con=aon.propertyIsEnumerable,kvt=Object.getOwnPropertySymbols,lon=kvt?function(e){return e==null?[]:(e=Object(e),Ere(kvt(e),function(t){return con.call(e,t)}))}:Sre,d2=lon});function uon(e,t){return RT(e,d2(e),t)}var Pvt,Lvt=Q(()=>{ZL();Tre();Pvt=uon});var don,pon,bre,nNe=Q(()=>{gre();hre();Tre();rNe();don=Object.getOwnPropertySymbols,pon=don?function(e){for(var t=[];e;)c2(t,d2(e)),e=l2(e);return t}:Sre,bre=pon});function fon(e,t){return RT(e,bre(e),t)}var Fvt,Uvt=Q(()=>{ZL();nNe();Fvt=fon});function mon(e,t,r){var n=t(e);return ia(e)?n:c2(n,r(e))}var yre,oNe=Q(()=>{gre();Pg();yre=mon});function gon(e){return yre(e,Ah,d2)}var Hq,iNe=Q(()=>{oNe();Tre();q1();Hq=gon});function Aon(e){return yre(e,n2,bre)}var p2,Cre=Q(()=>{oNe();nNe();dre();p2=Aon});var hon,Ire,Qvt=Q(()=>{eR();vE();hon=Am(Ll,"DataView"),Ire=hon});var _on,vre,Gvt=Q(()=>{eR();vE();_on=Am(Ll,"Promise"),vre=_on});var Eon,Rre,Hvt=Q(()=>{eR();vE();Eon=Am(Ll,"Set"),Rre=Eon});var qvt,Son,$vt,Yvt,Vvt,zvt,Ton,bon,yon,Con,Ion,z1,cC,qq=Q(()=>{Qvt();fre();Gvt();Hvt();O0t();G1();GDe();qvt="[object Map]",Son="[object Object]",$vt="[object Promise]",Yvt="[object Set]",Vvt="[object WeakMap]",zvt="[object DataView]",Ton=iC(Ire),bon=iC(iR),yon=iC(vre),Con=iC(Rre),Ion=iC(jte),z1=kg;(Ire&&z1(new Ire(new ArrayBuffer(1)))!=zvt||iR&&z1(new iR)!=qvt||vre&&z1(vre.resolve())!=$vt||Rre&&z1(new Rre)!=Yvt||jte&&z1(new jte)!=Vvt)&&(z1=function(e){var t=kg(e),r=t==Son?e.constructor:void 0,n=r?iC(r):"";if(n)switch(n){case Ton:return zvt;case bon:return qvt;case yon:return $vt;case Con:return Yvt;case Ion:return Vvt}return t});cC=z1});function Don(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&Ron.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var von,Ron,Wvt,jvt=Q(()=>{von=Object.prototype,Ron=von.hasOwnProperty;Wvt=Don});var Non,f2,sNe=Q(()=>{vE();Non=Ll.Uint8Array,f2=Non});function xon(e){var t=new e.constructor(e.byteLength);return new f2(t).set(new f2(e)),t}var m2,Dre=Q(()=>{sNe();m2=xon});function Oon(e,t){var r=t?m2(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var Kvt,Jvt=Q(()=>{Dre();Kvt=Oon});function Mon(e){var t=new e.constructor(e.source,won.exec(e));return t.lastIndex=e.lastIndex,t}var won,Zvt,Xvt=Q(()=>{won=/\w*$/;Zvt=Mon});function Bon(e){return tRt?Object(tRt.call(e)):{}}var eRt,tRt,rRt,nRt=Q(()=>{Q1();eRt=qu?qu.prototype:void 0,tRt=eRt?eRt.valueOf:void 0;rRt=Bon});function kon(e,t){var r=t?m2(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var oRt,iRt=Q(()=>{Dre();oRt=kon});function tin(e,t,r){var n=e.constructor;switch(t){case $on:return m2(e);case Pon:case Lon:return new n(+e);case Yon:return Kvt(e,r);case Von:case zon:case Won:case jon:case Kon:case Jon:case Zon:case Xon:case ein:return oRt(e,r);case Fon:return new n;case Uon:case Hon:return new n(e);case Qon:return Zvt(e);case Gon:return new n;case qon:return rRt(e)}}var Pon,Lon,Fon,Uon,Qon,Gon,Hon,qon,$on,Yon,Von,zon,Won,jon,Kon,Jon,Zon,Xon,ein,sRt,aRt=Q(()=>{Dre();Jvt();Xvt();nRt();iRt();Pon="[object Boolean]",Lon="[object Date]",Fon="[object Map]",Uon="[object Number]",Qon="[object RegExp]",Gon="[object Set]",Hon="[object String]",qon="[object Symbol]",$on="[object ArrayBuffer]",Yon="[object DataView]",Von="[object Float32Array]",zon="[object Float64Array]",Won="[object Int8Array]",jon="[object Int16Array]",Kon="[object Int32Array]",Jon="[object Uint8Array]",Zon="[object Uint8ClampedArray]",Xon="[object Uint16Array]",ein="[object Uint32Array]";sRt=tin});function rin(e){return typeof e.constructor=="function"&&!e2(e)?M0t(l2(e)):{}}var cRt,lRt=Q(()=>{B0t();hre();rre();cRt=rin});function oin(e){return du(e)&&cC(e)==nin}var nin,uRt,dRt=Q(()=>{qq();IT();nin="[object Map]";uRt=oin});var pRt,iin,fRt,mRt=Q(()=>{dRt();sre();are();pRt=sC&&sC.isMap,iin=pRt?r2(pRt):uRt,fRt=iin});function ain(e){return du(e)&&cC(e)==sin}var sin,gRt,ARt=Q(()=>{qq();IT();sin="[object Set]";gRt=ain});var hRt,cin,_Rt,ERt=Q(()=>{ARt();sre();are();hRt=sC&&sC.isSet,cin=hRt?r2(hRt):gRt,_Rt=cin});function Nre(e,t,r,n,o,i){var s,a=t&lin,c=t&uin,l=t&din;if(r&&(s=o?r(e,n,o,i):r(e)),s!==void 0)return s;if(!lf(e))return e;var u=ia(e);if(u){if(s=Wvt(e),!a)return L0t(e,s)}else{var d=cC(e),p=d==TRt||d==Ain;if(H1(e))return Mvt(e,a);if(d==bRt||d==SRt||p&&!o){if(s=c||p?{}:cRt(e),!a)return c?Fvt(e,Rvt(s,e)):Pvt(e,Ivt(s,e))}else{if(!Vs[d])return o?e:{};s=sRt(e,d,a)}}i||(i=new cR);var f=i.get(e);if(f)return f;i.set(e,s),_Rt(e)?e.forEach(function(_){s.add(Nre(_,t,r,_,e,i))}):fRt(e)&&e.forEach(function(_,T){s.set(T,Nre(_,t,r,T,e,i))});var A=l?c?p2:Hq:c?n2:Ah,h=u?void 0:A(e);return Y0t(h||e,function(_,T){h&&(T=_,_=e[T]),tR(s,T,Nre(_,t,r,T,e,i))}),s}var lin,uin,din,SRt,pin,fin,min,gin,TRt,Ain,hin,_in,bRt,Ein,Sin,Tin,bin,yin,Cin,Iin,vin,Rin,Din,Nin,xin,Oin,win,Min,Bin,Vs,xre,aNe=Q(()=>{_re();V0t();Bq();vvt();Dvt();Bvt();F0t();Lvt();Uvt();iNe();Cre();qq();jvt();aRt();lRt();Pg();ire();mRt();Xv();ERt();q1();dre();lin=1,uin=2,din=4,SRt="[object Arguments]",pin="[object Array]",fin="[object Boolean]",min="[object Date]",gin="[object Error]",TRt="[object Function]",Ain="[object GeneratorFunction]",hin="[object Map]",_in="[object Number]",bRt="[object Object]",Ein="[object RegExp]",Sin="[object Set]",Tin="[object String]",bin="[object Symbol]",yin="[object WeakMap]",Cin="[object ArrayBuffer]",Iin="[object DataView]",vin="[object Float32Array]",Rin="[object Float64Array]",Din="[object Int8Array]",Nin="[object Int16Array]",xin="[object Int32Array]",Oin="[object Uint8Array]",win="[object Uint8ClampedArray]",Min="[object Uint16Array]",Bin="[object Uint32Array]",Vs={};Vs[SRt]=Vs[pin]=Vs[Cin]=Vs[Iin]=Vs[fin]=Vs[min]=Vs[vin]=Vs[Rin]=Vs[Din]=Vs[Nin]=Vs[xin]=Vs[hin]=Vs[_in]=Vs[bRt]=Vs[Ein]=Vs[Sin]=Vs[Tin]=Vs[bin]=Vs[Oin]=Vs[win]=Vs[Min]=Vs[Bin]=!0;Vs[gin]=Vs[TRt]=Vs[yin]=!1;xre=Nre});function Lin(e){return xre(e,kin|Pin)}var kin,Pin,W1,yRt=Q(()=>{aNe();kin=1,Pin=4;W1=Lin});function Uin(e){return this.__data__.set(e,Fin),this}var Fin,CRt,IRt=Q(()=>{Fin="__lodash_hash_undefined__";CRt=Uin});function Qin(e){return this.__data__.has(e)}var vRt,RRt=Q(()=>{vRt=Qin});function Ore(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new $1;++t<r;)this.add(e[t])}var DRt,NRt=Q(()=>{mre();IRt();RRt();Ore.prototype.add=Ore.prototype.push=CRt;Ore.prototype.has=vRt;DRt=Ore});function Gin(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var xRt,ORt=Q(()=>{xRt=Gin});function Hin(e,t){return e.has(t)}var wRt,MRt=Q(()=>{wRt=Hin});function Yin(e,t,r,n,o,i){var s=r&qin,a=e.length,c=t.length;if(a!=c&&!(s&&c>a))return!1;var l=i.get(e),u=i.get(t);if(l&&u)return l==t&&u==e;var d=-1,p=!0,f=r&$in?new DRt:void 0;for(i.set(e,t),i.set(t,e);++d<a;){var A=e[d],h=t[d];if(n)var _=s?n(h,A,d,t,e,i):n(A,h,d,e,t,i);if(_!==void 0){if(_)continue;p=!1;break}if(f){if(!xRt(t,function(T,y){if(!wRt(f,y)&&(A===T||o(A,T,r,n,i)))return f.push(y)})){p=!1;break}}else if(!(A===h||o(A,h,r,n,i))){p=!1;break}}return i.delete(e),i.delete(t),p}var qin,$in,wre,cNe=Q(()=>{NRt();ORt();MRt();qin=1,$in=2;wre=Yin});function Vin(e){var t=-1,r=Array(e.size);return e.forEach(function(n,o){r[++t]=[o,n]}),r}var BRt,kRt=Q(()=>{BRt=Vin});function zin(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var PRt,LRt=Q(()=>{PRt=zin});function asn(e,t,r,n,o,i,s){switch(r){case ssn:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case isn:return!(e.byteLength!=t.byteLength||!i(new f2(e),new f2(t)));case Kin:case Jin:case esn:return JL(+e,+t);case Zin:return e.name==t.name&&e.message==t.message;case tsn:case nsn:return e==t+"";case Xin:var a=BRt;case rsn:var c=n&Win;if(a||(a=PRt),e.size!=t.size&&!c)return!1;var l=s.get(e);if(l)return l==t;n|=jin,s.set(e,t);var u=wre(a(e),a(t),n,o,i,s);return s.delete(e),u;case osn:if(lNe)return lNe.call(e)==lNe.call(t)}return!1}var Win,jin,Kin,Jin,Zin,Xin,esn,tsn,rsn,nsn,osn,isn,ssn,FRt,lNe,URt,QRt=Q(()=>{Q1();sNe();Xte();cNe();kRt();LRt();Win=1,jin=2,Kin="[object Boolean]",Jin="[object Date]",Zin="[object Error]",Xin="[object Map]",esn="[object Number]",tsn="[object RegExp]",rsn="[object Set]",nsn="[object String]",osn="[object Symbol]",isn="[object ArrayBuffer]",ssn="[object DataView]",FRt=qu?qu.prototype:void 0,lNe=FRt?FRt.valueOf:void 0;URt=asn});function dsn(e,t,r,n,o,i){var s=r&csn,a=Hq(e),c=a.length,l=Hq(t),u=l.length;if(c!=u&&!s)return!1;for(var d=c;d--;){var p=a[d];if(!(s?p in t:usn.call(t,p)))return!1}var f=i.get(e),A=i.get(t);if(f&&A)return f==t&&A==e;var h=!0;i.set(e,t),i.set(t,e);for(var _=s;++d<c;){p=a[d];var T=e[p],y=t[p];if(n)var I=s?n(y,T,p,t,e,i):n(T,y,p,e,t,i);if(!(I===void 0?T===y||o(T,y,r,n,i):I)){h=!1;break}_||(_=p=="constructor")}if(h&&!_){var v=e.constructor,x=t.constructor;v!=x&&"constructor"in e&&"constructor"in t&&!(typeof v=="function"&&v instanceof v&&typeof x=="function"&&x instanceof x)&&(h=!1)}return i.delete(e),i.delete(t),h}var csn,lsn,usn,GRt,HRt=Q(()=>{iNe();csn=1,lsn=Object.prototype,usn=lsn.hasOwnProperty;GRt=dsn});function msn(e,t,r,n,o,i){var s=ia(e),a=ia(t),c=s?$Rt:cC(e),l=a?$Rt:cC(t);c=c==qRt?Mre:c,l=l==qRt?Mre:l;var u=c==Mre,d=l==Mre,p=c==l;if(p&&H1(e)){if(!H1(t))return!1;s=!0,u=!1}if(p&&!u)return i||(i=new cR),s||cre(e)?wre(e,t,r,n,o,i):URt(e,t,c,r,n,o,i);if(!(r&psn)){var f=u&&YRt.call(e,"__wrapped__"),A=d&&YRt.call(t,"__wrapped__");if(f||A){var h=f?e.value():e,_=A?t.value():t;return i||(i=new cR),o(h,_,r,n,i)}}return p?(i||(i=new cR),GRt(e,t,r,n,o,i)):!1}var psn,qRt,$Rt,Mre,fsn,YRt,VRt,zRt=Q(()=>{_re();cNe();QRt();HRt();qq();Pg();ire();WDe();psn=1,qRt="[object Arguments]",$Rt="[object Array]",Mre="[object Object]",fsn=Object.prototype,YRt=fsn.hasOwnProperty;VRt=msn});function WRt(e,t,r,n,o){return e===t?!0:e==null||t==null||!du(e)&&!du(t)?e!==e&&t!==t:VRt(e,t,r,n,WRt,o)}var g2,Bre=Q(()=>{zRt();IT();g2=WRt});function hsn(e,t,r,n){var o=r.length,i=o,s=!n;if(e==null)return!i;for(e=Object(e);o--;){var a=r[o];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++o<i;){a=r[o];var c=a[0],l=e[c],u=a[1];if(s&&a[2]){if(l===void 0&&!(c in e))return!1}else{var d=new cR;if(n)var p=n(l,u,c,e,t,d);if(!(p===void 0?g2(u,l,gsn|Asn,n,d):p))return!1}}return!0}var gsn,Asn,jRt,KRt=Q(()=>{_re();Bre();gsn=1,Asn=2;jRt=hsn});function _sn(e){return e===e&&!lf(e)}var kre,uNe=Q(()=>{Xv();kre=_sn});function Esn(e){for(var t=Ah(e),r=t.length;r--;){var n=t[r],o=e[n];t[r]=[n,o,kre(o)]}return t}var JRt,ZRt=Q(()=>{uNe();q1();JRt=Esn});function Ssn(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}var Pre,dNe=Q(()=>{Pre=Ssn});function Tsn(e){var t=JRt(e);return t.length==1&&t[0][2]?Pre(t[0][0],t[0][1]):function(r){return r===e||jRt(r,e,t)}}var XRt,eDt=Q(()=>{KRt();ZRt();dNe();XRt=Tsn});function bsn(e,t){return e!=null&&t in Object(e)}var tDt,rDt=Q(()=>{tDt=bsn});function ysn(e,t,r){t=hh(t,e);for(var n=-1,o=t.length,i=!1;++n<o;){var s=Lg(t[n]);if(!(i=e!=null&&r(e,s)))break;e=e[s]}return i||++n!=o?i:(o=e==null?0:e.length,!!o&&XL(o)&&jL(s,o)&&(ia(e)||t2(e)))}var nDt,oDt=Q(()=>{Y1();ore();Pg();Jte();tre();V1();nDt=ysn});function Csn(e,t){return e!=null&&nDt(e,t,tDt)}var Lre,pNe=Q(()=>{rDt();oDt();Lre=Csn});function Rsn(e,t){return o2(e)&&kre(t)?Pre(Lg(e),t):function(r){var n=evt(r,e);return n===void 0&&n===t?Lre(r,e):g2(t,n,Isn|vsn)}}var Isn,vsn,iDt,sDt=Q(()=>{Bre();tvt();pNe();pre();uNe();dNe();V1();Isn=1,vsn=2;iDt=Rsn});function Dsn(e){return function(t){return t?.[e]}}var Fre,fNe=Q(()=>{Fre=Dsn});function Nsn(e){return function(t){return aR(t,e)}}var aDt,cDt=Q(()=>{Gq();aDt=Nsn});function xsn(e){return o2(e)?Fre(Lg(e)):aDt(e)}var lDt,uDt=Q(()=>{fNe();cDt();pre();V1();lDt=xsn});function Osn(e){return typeof e=="function"?e:e==null?zL:typeof e=="object"?ia(e)?iDt(e[0],e[1]):XRt(e):lDt(e)}var A2,Ure=Q(()=>{eDt();sDt();Vte();Pg();uDt();A2=Osn});function wsn(e,t,r,n){for(var o=-1,i=e==null?0:e.length;++o<i;){var s=e[o];t(n,s,r(s),e)}return n}var dDt,pDt=Q(()=>{dDt=wsn});function Msn(e){return function(t,r,n){for(var o=-1,i=Object(t),s=n(t),a=s.length;a--;){var c=s[e?a:++o];if(r(i[c],c,i)===!1)break}return t}}var fDt,mDt=Q(()=>{fDt=Msn});var Bsn,gDt,ADt=Q(()=>{mDt();Bsn=fDt(),gDt=Bsn});function ksn(e,t){return e&&gDt(e,t,Ah)}var Qre,mNe=Q(()=>{ADt();q1();Qre=ksn});function Psn(e,t){return function(r,n){if(r==null)return r;if(!rR(r))return e(r,n);for(var o=r.length,i=t?o:-1,s=Object(r);(t?i--:++i<o)&&n(s[i],i,s)!==!1;);return r}}var hDt,_Dt=Q(()=>{kq();hDt=Psn});var Lsn,EDt,SDt=Q(()=>{mNe();_Dt();Lsn=hDt(Qre),EDt=Lsn});function Fsn(e,t,r,n){return EDt(e,function(o,i,s){t(n,o,r(o),s)}),n}var TDt,bDt=Q(()=>{SDt();TDt=Fsn});function Usn(e,t){return function(r,n){var o=ia(r)?dDt:TDt,i=t?t():{};return o(r,e,A2(n,2),i)}}var yDt,CDt=Q(()=>{pDt();bDt();Ure();Pg();yDt=Usn});function Qsn(e){return du(e)&&rR(e)}var IDt,vDt=Q(()=>{kq();IT();IDt=Qsn});function Gsn(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var gp,gNe=Q(()=>{gp=Gsn});function Hsn(e,t){return vT(t,function(r){return e[r]})}var RDt,DDt=Q(()=>{VL();RDt=Hsn});function qsn(e){return e==null?[]:RDt(e,Ah(e))}var NDt,xDt=Q(()=>{DDt();q1();NDt=qsn});function $sn(e,t){return t.length<2?e:aR(e,fvt(t,0,-1))}var ODt,wDt=Q(()=>{Gq();mvt();ODt=$sn});function Ysn(e,t){return g2(e,t)}var ANe,MDt=Q(()=>{Bre();ANe=Ysn});function Vsn(e,t){var r={};return t=A2(t,3),Qre(e,function(n,o,i){KL(r,o,t(n,o,i))}),r}var Gre,BDt=Q(()=>{Zte();mNe();Ure();Gre=Vsn});function jsn(e,t){t=hh(t,e);var r=-1,n=t.length;if(!n)return!0;for(;++r<n;){var o=Lg(t[r]);if(o==="__proto__"&&!Wsn.call(e,"__proto__")||(o==="constructor"||o==="prototype")&&r<n-1)return!1}var i=ODt(e,t);return i==null||delete i[Lg(gp(t))]}var zsn,Wsn,kDt,PDt=Q(()=>{Y1();gNe();wDt();V1();zsn=Object.prototype,Wsn=zsn.hasOwnProperty;kDt=jsn});function Ksn(e){return dvt(e)?void 0:e}var LDt,FDt=Q(()=>{pvt();LDt=Ksn});var Jsn,Zsn,Xsn,ean,j1,UDt=Q(()=>{VL();aNe();PDt();Y1();ZL();FDt();eNe();Cre();Jsn=1,Zsn=2,Xsn=4,ean=Are(function(e,t){var r={};if(e==null)return r;var n=!1;t=vT(t,function(i){return i=hh(i,e),n||(n=i.length>1),i}),RT(e,p2(e),r),n&&(r=xre(r,Jsn|Zsn|Xsn,LDt));for(var o=t.length;o--;)kDt(r,t[o]);return r}),j1=ean});function tan(e,t,r,n){if(!lf(e))return e;t=hh(t,e);for(var o=-1,i=t.length,s=i-1,a=e;a!=null&&++o<i;){var c=Lg(t[o]),l=r;if(c==="__proto__"||c==="constructor"||c==="prototype")return e;if(o!=s){var u=a[c];l=n?n(u,c,a):void 0,l===void 0&&(l=lf(u)?u:jL(t[o+1])?[]:{})}tR(a,c,l),a=a[c]}return e}var QDt,GDt=Q(()=>{Bq();Y1();Jte();Xv();V1();QDt=tan});function ran(e,t,r){for(var n=-1,o=t.length,i={};++n<o;){var s=t[n],a=aR(e,s);r(a,s)&&QDt(i,hh(s,e),a)}return i}var Hre,hNe=Q(()=>{Gq();GDt();Y1();Hre=ran});function nan(e,t){if(e==null)return{};var r=vT(p2(e),function(n){return[n]});return t=A2(t),Hre(e,r,function(n,o){return t(n,o[0])})}var qre,HDt=Q(()=>{VL();Ure();hNe();Cre();qre=nan});var oan,_Ne,qDt=Q(()=>{CDt();oan=yDt(function(e,t,r){e[r?0:1].push(t)},function(){return[[],[]]}),_Ne=oan});function ian(e,t){return Hre(e,t,function(r,n){return Lre(e,n)})}var $Dt,YDt=Q(()=>{hNe();pNe();$Dt=ian});var san,$re,VDt=Q(()=>{YDt();eNe();san=Are(function(e,t){return e==null?{}:$Dt(e,t)}),$re=san});function lan(e,t){return e+aan(can()*(t-e+1))}var aan,can,zDt,WDt=Q(()=>{aan=Math.floor,can=Math.random;zDt=lan});function uan(e){var t=e.length;return t?e[zDt(0,t-1)]:void 0}var Yre,ENe=Q(()=>{WDt();Yre=uan});function dan(e){return Yre(NDt(e))}var jDt,KDt=Q(()=>{ENe();xDt();jDt=dan});function pan(e){var t=ia(e)?Yre:jDt;return t(e)}var K1,JDt=Q(()=>{ENe();KDt();Pg();K1=pan});function man(e){if(!(e&&e.length))return[];var t=0;return e=Ere(e,function(r){if(IDt(r))return t=fan(r.length,t),!0}),nre(t,function(r){return vT(e,Fre(r))})}var fan,ZDt,XDt=Q(()=>{tNe();VL();fNe();YDe();vDt();fan=Math.max;ZDt=man});var gan,SNe,eNt=Q(()=>{j0t();XDt();gan=W0t(ZDt),SNe=gan});function Aan(e,t,r){for(var n=-1,o=e.length,i=t.length,s={};++n<o;){var a=n<i?t[n]:void 0;r(s,e[n],a)}return s}var tNt,rNt=Q(()=>{tNt=Aan});function han(e,t){return tNt(e||[],t||[],tR)}var TNe,nNt=Q(()=>{Bq();rNt();TNe=han});var hr=Q(()=>{yRt();MDt();gNe();BDt();XDe();UDt();qDt();VDt();HDt();JDt();eNt();nNt();});function Wq(){return process.platform!=="win32"?!1:process.env.HAWA_CODE_POWER_SHELL_ENABLE==="true"||process.env.HAWA_CODE_POWER_SHELL_ENABLE==="1"?!0:!(process.env.HAWA_CODE_POWER_SHELL_ENABLE==="false"||process.env.HAWA_CODE_POWER_SHELL_ENABLE==="0"||process.env[jre])}var Je,$q,Vre,oNt,_i,Gi,lo,zre,Wre,RE,iNt,Yq,jre,hm,J1,DE,Vq,NE,Kre,sNt,Ap,lC,Di,cl,rs,aa,ca,en,uf,Jre,h2,Zre,Xre,lR,aNt,ene,uC,_2,tne,DT,Fg,df,_m,pf,ff,_h,cNt,lNt,uNt,_an,Ean,Z1,zq,Eh,dNt,pNt,fNt,mNt,gNt,uR,E2,NT,He=Q(()=>{Je="Hawa Code",$q="Dahawa",Vre="https://www.hawacode.com",oNt="https://github.com/italking/hawa-code/issues",_i="HAWA.md",Gi="hcode",lo=".hcode",zre="HAWA_CODE_GIT_BASH_PATH",Wre="*-* ",RE="Backgrounded agent",iNt="ANTHROPIC_AUTH_TOKEN",Yq="HAWA_CODE_FIX_SCHEMA",jre="HAWA_CODE_GIT_BASH_PATH",hm="LOADED_TOOLS",J1="SELECTION_CHANGED",DE="CONTEXT_MAIN_STOP_TIMES",Vq="allowedTools",NE="tast:completed",Kre="query:suggestion",sNt="WebSearch",Ap="Bash",lC="PowerShell",Di="Read",cl="Write",rs="Edit",aa="Glob",ca="Grep",en="Agent",uf="TodoWrite",Jre="AskUserQuestion",h2="NotebookEdit",Zre="EnterPlanMode",Xre="ExitPlanMode",lR="Skill",aNt="SlashCommand",ene="Think",uC="WebFetch",_2="TaskOutput",tne="TaskStop",DT="ToolLoader",Fg="ToolUnLoader",df="TaskCreate",_m="TaskGet",pf="TaskList",ff="TaskUpdate",_h=Wq()?lC:Ap,cNt="CronCreate",lNt="CronDelete",uNt="CronList",_an="EnterWorktreeTool",Ean="ExitWorktreeTool",Z1="TeamCreate",zq="TeamDelete",Eh="SendMessage",dNt="Sleep",pNt="ToolSearch",fNt="ListMcpResources",mNt="ReadMcpResource",gNt="classify_result",uR="team-lead",E2=[Z1,zq,_an,Ean],NT=[DT,Fg,uf,lR,df,ff,pf]});import{randomUUID as San}from"crypto";function dC(e){return e.type==="compact_boundary"}function S2(e,t,r,n,o){return{type:"compact_boundary",uuid:San(),timestamp:new Date().toISOString(),content:"Conversation compacted",level:"info",compactMetadata:{trigger:e,preTokens:t,...n!==void 0?{userContext:n}:{},...o!==void 0?{messagesSummarized:o}:{}},...r?{logicalParentUuid:r}:{}}}function dR(e){return[e.boundaryMarker,e.summaryMessage]}function ANt(e){let t=-1;for(let r=e.length-1;r>=0;r--)if(dC(e[r])){t=r;break}return t===-1?e:e.slice(t+1)}function rne(e){return e.length===0?void 0:e[e.length-1].uuid}var X1=Q(()=>{});var bNe,Nr,va=Q(()=>{Be();bNe=class{listeners=new Map;registry=new FinalizationRegistry(t=>{for(let[r,n]of this.listeners.entries()){for(let o of Array.from(n))o.token===t&&n.delete(o);n.size===0&&this.listeners.delete(r)}});on(t,r,n){let o=this.listeners.get(t);o||(o=new Set,this.listeners.set(t,o));let i={callback:r,thisRef:n?new WeakRef(n):void 0};if(n){let s={};i.token=s,this.registry.register(n,s,s)}return o.add(i),()=>{this.off(t,r,n)}}off(t,r,n){let o=this.listeners.get(t);if(o){if(!r&&n===void 0){for(let i of o)i.token&&this.registry.unregister(i.token);this.listeners.delete(t);return}for(let i of Array.from(o)){let s=r?i.callback===r:!0,a=!0;n!==void 0&&(a=i.thisRef?.deref()===n),s&&a&&(i.token&&this.registry.unregister(i.token),o.delete(i))}o.size===0&&this.listeners.delete(t)}}emit(t,r){let n=this.listeners.get(t);if(n)for(let o of Array.from(n)){let i;if(o.thisRef&&(i=o.thisRef.deref(),!i)){n.delete(o);continue}try{let s=o.callback.call(i,r);s instanceof Promise&&s.catch(a=>{he(`Async error in listener for "${t}"`,a)})}catch(s){he(`Error in listener for "${t}"`,s)}}}},Nr=new bNe});var CNe={};ra(CNe,{HawaSessionContext:()=>one,InQueryContext:()=>T2,appendAllowedTools:()=>b2,hawaContext:()=>Ye});import{randomUUID as Tan}from"crypto";function b2(e,t){if(e&&e.length>0){let r=Ye.getQueryContext(t)[Vq];r||(r=[]),Ye.getQueryContext(t)[Vq]=[...r,...e]}}var nne,T2,hNt,one,yNe,Ye,Zo=Q(()=>{He();va();nne=class{datas={};setData(t,r){this.datas[t]=r}getData(t){return this.datas[t]}takeData(t){let r=this.datas[t];return delete this.datas[t],r}clear(){this.datas={}}},T2=class extends nne{startTime;constructor(t=null){super(),this.startTime=t}},hNt=Tan(),one=class extends nne{PENDING_PROMPTS_KEY="pendingPrompts";addPendingPrompt(t){let r=this.getPendingPrompts();r.push(t),this.setData(this.PENDING_PROMPTS_KEY,r)}getPendingPrompts(){let t=this.getData(this.PENDING_PROMPTS_KEY);return Array.isArray(t)?t:[]}takePendingPrompts(){let t=this.getPendingPrompts();return this.setData(this.PENDING_PROMPTS_KEY,[]),t}async waitGetPendingPrompts(t){let n=Date.now(),o=t*1e3;for(;Date.now()-n<o;){let i=this.getPendingPrompts();if(i.length>0)return i;await new Promise(s=>setTimeout(s,200))}return[]}getSessionId(){return hNt}switchSessionId(t){hNt=t}},yNe=class e{static sessionContext={};static inQueryContextHolder={};static queryContext={};onQueryStart(t="defalt"){t||(t="defalt");let r=e.inQueryContextHolder[t+""];r&&r.startTime&&r.startTime>0||(e.inQueryContextHolder[t+""]=new T2(Date.now()),Nr.emit("webserver:agent_status",{agentId:t,status:"started",timestamp:Date.now()}))}onQueryEnd(t="defalt",r=!1){t||(t="defalt"),e.inQueryContextHolder[t+""]=new T2(-1),r||(e.queryContext[t+""]={}),Nr.emit("webserver:agent_status",{agentId:t,status:"ended",timestamp:Date.now()})}getSessionContext(t="defalt"){t||(t="defalt");let r=e.sessionContext[t+""];return r||(r=new one,e.sessionContext[t+""]=r),r}getInQueryContext(t="defalt"){t||(t="defalt");let r=e.inQueryContextHolder[t+""];return r||(r=new T2,e.inQueryContextHolder[t+""]=r),r}getQueryContext(t="defalt"){t||(t="defalt");let r=e.queryContext[t+""];return r||(r={},e.queryContext[t+""]=r),r}isQuerying(t="defalt"){return t||(t="defalt"),this.getInQueryContext(t).startTime>0}},Ye=new yNe});var xNt={};ra(xNt,{CACHE_PATHS:()=>oo,SESSION_ID:()=>xE,dateToFilename:()=>CNt,debug:()=>qt,error:()=>he,event:()=>Me,formatDate:()=>R2,getCurrentSessionMessagePath:()=>ul,getErrorsLog:()=>Nan,getInMemoryErrors:()=>xan,getPersistedMessageIds:()=>yNt,loadLog:()=>eO,loadLogFromFile:()=>wan,loadLogList:()=>tO,loadMessages:()=>C2,loadMessagesFromFile:()=>NNt,log:()=>be,logAPI:()=>lne,logAPIFull:()=>cne,logError:()=>Re,logMCPError:()=>fR,parseISOString:()=>ine,parseLogFilename:()=>une,resetPersistedIdsCache:()=>Ian,sortLogs:()=>DNt,writeCurrentSessionMessages:()=>Qg});import{existsSync as Ug,mkdirSync as INe}from"fs";import{dirname as vNe,join as ll}from"path";import{writeFileSync as sne,readFileSync as SNt,appendFileSync as TNt}from"fs";import{randomUUID as ban}from"crypto";import{promises as y2}from"fs";import{homedir as yan}from"os";import*as bNt from"os";function yNt(e){if(!jq.has(e)){let t=new Set;if(Ug(e))try{SNt(e,"utf8").split(`
18
+ Mongoose Error Code: ${t.code}`:""}`})}function HRe(e,t,r,n=void 0){r&&(0,yJr.safeExecuteInTheMiddle)(()=>r(e,{moduleVersion:n,response:t}),o=>{o&&STt.diag.error("mongoose instrumentation: responseHook error",o)},!0)}function IJr(e,t,r,n=void 0){return e instanceof Promise?e.then(o=>(HRe(t,o,r,n),o)).catch(o=>{throw TTt(t,o),o}).finally(()=>t.end()):(HRe(t,e,r,n),t.end(),e)}Uv.handlePromiseResponse=IJr;function vJr(e,t,r,n,o,i,s=void 0){let a=0;return o.length===2?a=1:o.length===3&&(a=2),o[a]=(c,l)=>(c?TTt(n,c):HRe(n,l,i,s),n.end(),e(c,l)),t.apply(r,o)}Uv.handleCallbackResponse=vJr});var yTt=S(hL=>{"use strict";Object.defineProperty(hL,"__esModule",{value:!0});hL.PACKAGE_NAME=hL.PACKAGE_VERSION=void 0;hL.PACKAGE_VERSION="0.55.0";hL.PACKAGE_NAME="@opentelemetry/instrumentation-mongoose"});var DTt=S(ST=>{"use strict";Object.defineProperty(ST,"__esModule",{value:!0});ST.MongooseInstrumentation=ST._STORED_PARENT_SPAN=void 0;var Sd=zt(),RJr=(Ys(),Hn(XA)),qRe=bTt(),CTt=(Nn(),Hn(Xi)),ITt=yTt(),_L=GRe(),Pee=["deleteOne","deleteMany","find","findOne","estimatedDocumentCount","countDocuments","distinct","where","$where","findOneAndUpdate","findOneAndDelete","findOneAndReplace"],DJr=["remove","count","findOneAndRemove",...Pee],NJr=["count","findOneAndRemove",...Pee],xJr=[...Pee];function vTt(e){return e?e.startsWith("6.")||e.startsWith("5.")?DJr:e.startsWith("7.")?NJr:xJr:Pee}function RTt(e){return e&&(e.startsWith("5.")||e.startsWith("6."))||!1}ST._STORED_PARENT_SPAN=Symbol("stored-parent-span");var $Re=class extends CTt.InstrumentationBase{constructor(t={}){super(ITt.PACKAGE_NAME,ITt.PACKAGE_VERSION,t)}init(){return new CTt.InstrumentationNodeModuleDefinition("mongoose",[">=5.9.7 <9"],this.patch.bind(this),this.unpatch.bind(this))}patch(t,r){let n=t[Symbol.toStringTag]==="Module"?t.default:t;return this._wrap(n.Model.prototype,"save",this.patchOnModelMethods("save",r)),n.Model.prototype.$save=n.Model.prototype.save,RTt(r)&&this._wrap(n.Model.prototype,"remove",this.patchOnModelMethods("remove",r)),this._wrap(n.Query.prototype,"exec",this.patchQueryExec(r)),this._wrap(n.Aggregate.prototype,"exec",this.patchAggregateExec(r)),vTt(r).forEach(i=>{this._wrap(n.Query.prototype,i,this.patchAndCaptureSpanContext(i))}),this._wrap(n.Model,"aggregate",this.patchModelAggregate()),this._wrap(n.Model,"insertMany",this.patchModelStatic("insertMany",r)),this._wrap(n.Model,"bulkWrite",this.patchModelStatic("bulkWrite",r)),n}unpatch(t,r){let n=t[Symbol.toStringTag]==="Module"?t.default:t,o=vTt(r);this._unwrap(n.Model.prototype,"save"),n.Model.prototype.$save=n.Model.prototype.save,RTt(r)&&this._unwrap(n.Model.prototype,"remove"),this._unwrap(n.Query.prototype,"exec"),this._unwrap(n.Aggregate.prototype,"exec"),o.forEach(i=>{this._unwrap(n.Query.prototype,i)}),this._unwrap(n.Model,"aggregate"),this._unwrap(n.Model,"insertMany"),this._unwrap(n.Model,"bulkWrite")}patchAggregateExec(t){let r=this;return n=>function(i){if(r.getConfig().requireParentSpan&&Sd.trace.getSpan(Sd.context.active())===void 0)return n.apply(this,arguments);let s=this[ST._STORED_PARENT_SPAN],a={},{dbStatementSerializer:c}=r.getConfig();c&&(a[_L.ATTR_DB_STATEMENT]=c("aggregate",{options:this.options,aggregatePipeline:this._pipeline}));let l=r._startSpan(this._model.collection,this._model?.modelName,"aggregate",a,s);return r._handleResponse(l,n,this,arguments,i,t)}}patchQueryExec(t){let r=this;return n=>function(i){if(r.getConfig().requireParentSpan&&Sd.trace.getSpan(Sd.context.active())===void 0)return n.apply(this,arguments);let s=this[ST._STORED_PARENT_SPAN],a={},{dbStatementSerializer:c}=r.getConfig();c&&(a[_L.ATTR_DB_STATEMENT]=c(this.op,{condition:this._conditions,updates:this._update,options:this.options,fields:this._fields}));let l=r._startSpan(this.mongooseCollection,this.model.modelName,this.op,a,s);return r._handleResponse(l,n,this,arguments,i,t)}}patchOnModelMethods(t,r){let n=this;return o=>function(s,a){if(n.getConfig().requireParentSpan&&Sd.trace.getSpan(Sd.context.active())===void 0)return o.apply(this,arguments);let c={document:this};s&&!(s instanceof Function)&&(c.options=s);let l={},{dbStatementSerializer:u}=n.getConfig();u&&(l[_L.ATTR_DB_STATEMENT]=u(t,c));let d=n._startSpan(this.constructor.collection,this.constructor.modelName,t,l);return s instanceof Function&&(a=s,s=void 0),n._handleResponse(d,o,this,arguments,a,r)}}patchModelStatic(t,r){let n=this;return o=>function(s,a,c){if(n.getConfig().requireParentSpan&&Sd.trace.getSpan(Sd.context.active())===void 0)return o.apply(this,arguments);typeof a=="function"&&(c=a,a=void 0);let l={};switch(t){case"insertMany":l.documents=s;break;case"bulkWrite":l.operations=s;break;default:l.document=s;break}a!==void 0&&(l.options=a);let u={},{dbStatementSerializer:d}=n.getConfig();d&&(u[_L.ATTR_DB_STATEMENT]=d(t,l));let p=n._startSpan(this.collection,this.modelName,t,u);return n._handleResponse(p,o,this,arguments,c,r)}}patchModelAggregate(){let t=this;return r=>function(){let o=Sd.trace.getSpan(Sd.context.active()),i=t._callOriginalFunction(()=>r.apply(this,arguments));return i&&(i[ST._STORED_PARENT_SPAN]=o),i}}patchAndCaptureSpanContext(t){let r=this;return n=>function(){return this[ST._STORED_PARENT_SPAN]=Sd.trace.getSpan(Sd.context.active()),r._callOriginalFunction(()=>n.apply(this,arguments))}}_startSpan(t,r,n,o,i){return this.tracer.startSpan(`mongoose.${r}.${n}`,{kind:Sd.SpanKind.CLIENT,attributes:{...o,...(0,qRe.getAttributesFromCollection)(t),[_L.ATTR_DB_OPERATION]:n,[_L.ATTR_DB_SYSTEM]:"mongoose"}},i?Sd.trace.setSpan(Sd.context.active(),i):void 0)}_handleResponse(t,r,n,o,i,s=void 0){let a=this;if(i instanceof Function)return a._callOriginalFunction(()=>(0,qRe.handleCallbackResponse)(i,r,n,t,o,a.getConfig().responseHook,s));{let c=a._callOriginalFunction(()=>r.apply(n,o));return(0,qRe.handlePromiseResponse)(c,t,a.getConfig().responseHook,s)}}_callOriginalFunction(t){return this.getConfig().suppressInternalInstrumentation?Sd.context.with((0,RJr.suppressTracing)(Sd.context.active()),t):t()}};ST.MongooseInstrumentation=$Re});var NTt=S(Lee=>{"use strict";Object.defineProperty(Lee,"__esModule",{value:!0});Lee.MongooseInstrumentation=void 0;var OJr=DTt();Object.defineProperty(Lee,"MongooseInstrumentation",{enumerable:!0,get:function(){return OJr.MongooseInstrumentation}})});var YRe=S(kl=>{"use strict";Object.defineProperty(kl,"__esModule",{value:!0});kl.METRIC_DB_CLIENT_CONNECTIONS_USAGE=kl.DB_SYSTEM_VALUE_MYSQL=kl.ATTR_NET_PEER_PORT=kl.ATTR_NET_PEER_NAME=kl.ATTR_DB_USER=kl.ATTR_DB_SYSTEM=kl.ATTR_DB_STATEMENT=kl.ATTR_DB_NAME=kl.ATTR_DB_CONNECTION_STRING=void 0;kl.ATTR_DB_CONNECTION_STRING="db.connection_string";kl.ATTR_DB_NAME="db.name";kl.ATTR_DB_STATEMENT="db.statement";kl.ATTR_DB_SYSTEM="db.system";kl.ATTR_DB_USER="db.user";kl.ATTR_NET_PEER_NAME="net.peer.name";kl.ATTR_NET_PEER_PORT="net.peer.port";kl.DB_SYSTEM_VALUE_MYSQL="mysql";kl.METRIC_DB_CLIENT_CONNECTIONS_USAGE="db.client.connections.usage"});var BTt=S(dq=>{"use strict";Object.defineProperty(dq,"__esModule",{value:!0});dq.AttributeNames=void 0;var MJr;(function(e){e.MYSQL_VALUES="db.mysql.values"})(MJr=dq.AttributeNames||(dq.AttributeNames={}))});var PTt=S(fm=>{"use strict";Object.defineProperty(fm,"__esModule",{value:!0});fm.getPoolName=fm.arrayStringifyHelper=fm.getSpanName=fm.getDbValues=fm.getDbStatement=fm.getConnectionAttributes=void 0;var rC=YRe();function BJr(e){let{host:t,port:r,database:n,user:o}=kJr(e),i=parseInt(r,10);return isNaN(i)?{[rC.ATTR_NET_PEER_NAME]:t,[rC.ATTR_DB_CONNECTION_STRING]:kTt(t,r,n),[rC.ATTR_DB_NAME]:n,[rC.ATTR_DB_USER]:o}:{[rC.ATTR_NET_PEER_NAME]:t,[rC.ATTR_NET_PEER_PORT]:i,[rC.ATTR_DB_CONNECTION_STRING]:kTt(t,r,n),[rC.ATTR_DB_NAME]:n,[rC.ATTR_DB_USER]:o}}fm.getConnectionAttributes=BJr;function kJr(e){let{host:t,port:r,database:n,user:o}=e&&e.connectionConfig||e||{};return{host:t,port:r,database:n,user:o}}function kTt(e,t,r){let n=`jdbc:mysql://${e||"localhost"}`;return typeof t=="number"&&(n+=`:${t}`),typeof r=="string"&&(n+=`/${r}`),n}function PJr(e){return typeof e=="string"?e:e.sql}fm.getDbStatement=PJr;function LJr(e,t){return VRe(typeof e=="string"?t:t||e.values)}fm.getDbValues=LJr;function FJr(e){let t=typeof e=="object"?e.sql:e,r=t?.indexOf(" ");return typeof r=="number"&&r!==-1?t?.substring(0,r):t}fm.getSpanName=FJr;function VRe(e){return e?`[${e.toString()}]`:""}fm.arrayStringifyHelper=VRe;function UJr(e){let t=e.config.connectionConfig,r="";return r+=t.host?`host: '${t.host}', `:"",r+=t.port?`port: ${t.port}, `:"",r+=t.database?`database: '${t.database}', `:"",r+=t.user?`user: '${t.user}'`:"",t.user||(r=r.substring(0,r.length-2)),r.trim()}fm.getPoolName=UJr});var LTt=S(EL=>{"use strict";Object.defineProperty(EL,"__esModule",{value:!0});EL.PACKAGE_NAME=EL.PACKAGE_VERSION=void 0;EL.PACKAGE_VERSION="0.54.0";EL.PACKAGE_NAME="@opentelemetry/instrumentation-mysql"});var UTt=S(Uee=>{"use strict";Object.defineProperty(Uee,"__esModule",{value:!0});Uee.MySQLInstrumentation=void 0;var mm=zt(),SL=(Nn(),Hn(Xi)),Fee=YRe(),QJr=BTt(),TL=PTt(),FTt=LTt(),zRe=class e extends SL.InstrumentationBase{static COMMON_ATTRIBUTES={[Fee.ATTR_DB_SYSTEM]:Fee.DB_SYSTEM_VALUE_MYSQL};constructor(t={}){super(FTt.PACKAGE_NAME,FTt.PACKAGE_VERSION,t)}_updateMetricInstruments(){this._connectionsUsage=this.meter.createUpDownCounter(Fee.METRIC_DB_CLIENT_CONNECTIONS_USAGE,{description:"The number of connections that are currently in state described by the state attribute.",unit:"{connection}"})}init(){return[new SL.InstrumentationNodeModuleDefinition("mysql",[">=2.0.0 <3"],t=>((0,SL.isWrapped)(t.createConnection)&&this._unwrap(t,"createConnection"),this._wrap(t,"createConnection",this._patchCreateConnection()),(0,SL.isWrapped)(t.createPool)&&this._unwrap(t,"createPool"),this._wrap(t,"createPool",this._patchCreatePool()),(0,SL.isWrapped)(t.createPoolCluster)&&this._unwrap(t,"createPoolCluster"),this._wrap(t,"createPoolCluster",this._patchCreatePoolCluster()),t),t=>{t!==void 0&&(this._unwrap(t,"createConnection"),this._unwrap(t,"createPool"),this._unwrap(t,"createPoolCluster"))})]}_patchCreateConnection(){return t=>{let r=this;return function(o){let i=t(...arguments);return r._wrap(i,"query",r._patchQuery(i)),i}}}_patchCreatePool(){return t=>{let r=this;return function(o){let i=t(...arguments);return r._wrap(i,"query",r._patchQuery(i)),r._wrap(i,"getConnection",r._patchGetConnection(i)),r._wrap(i,"end",r._patchPoolEnd(i)),r._setPoolcallbacks(i,r,""),i}}}_patchPoolEnd(t){return r=>{let n=this;return function(i){let s=t._allConnections.length,a=t._freeConnections.length,c=s-a,l=(0,TL.getPoolName)(t);n._connectionsUsage.add(-c,{state:"used",name:l}),n._connectionsUsage.add(-a,{state:"idle",name:l}),r.apply(t,arguments)}}}_patchCreatePoolCluster(){return t=>{let r=this;return function(o){let i=t(...arguments);return r._wrap(i,"getConnection",r._patchGetConnection(i)),r._wrap(i,"add",r._patchAdd(i)),i}}}_patchAdd(t){return r=>{let n=this;return function(i,s){if(!n._enabled)return n._unwrap(t,"add"),r.apply(t,arguments);r.apply(t,arguments);let a=t._nodes;if(a){let c=typeof i=="object"?"CLUSTER::"+t._lastId:String(i),l=a[c].pool;n._setPoolcallbacks(l,n,i)}}}}_patchGetConnection(t){return r=>{let n=this;return function(i,s,a){if(!n._enabled)return n._unwrap(t,"getConnection"),r.apply(t,arguments);if(arguments.length===1&&typeof i=="function"){let c=n._getConnectionCallbackPatchFn(i);return r.call(t,c)}if(arguments.length===2&&typeof s=="function"){let c=n._getConnectionCallbackPatchFn(s);return r.call(t,i,c)}if(arguments.length===3&&typeof a=="function"){let c=n._getConnectionCallbackPatchFn(a);return r.call(t,i,s,c)}return r.apply(t,arguments)}}}_getConnectionCallbackPatchFn(t){let r=this,n=mm.context.active();return function(o,i){i&&((0,SL.isWrapped)(i.query)||r._wrap(i,"query",r._patchQuery(i))),typeof t=="function"&&mm.context.with(n,t,this,o,i)}}_patchQuery(t){return r=>{let n=this;return function(o,i,s){if(!n._enabled)return n._unwrap(t,"query"),r.apply(t,arguments);let a=n.tracer.startSpan((0,TL.getSpanName)(o),{kind:mm.SpanKind.CLIENT,attributes:{...e.COMMON_ATTRIBUTES,...(0,TL.getConnectionAttributes)(t.config)}});if(a.setAttribute(Fee.ATTR_DB_STATEMENT,(0,TL.getDbStatement)(o)),n.getConfig().enhancedDatabaseReporting){let u;Array.isArray(i)?u=i:arguments[2]&&(u=[i]),a.setAttribute(QJr.AttributeNames.MYSQL_VALUES,(0,TL.getDbValues)(o,u))}let c=Array.from(arguments).findIndex(u=>typeof u=="function"),l=mm.context.active();if(c===-1){let u=mm.context.with(mm.trace.setSpan(mm.context.active(),a),()=>r.apply(t,arguments));return mm.context.bind(l,u),u.on("error",d=>a.setStatus({code:mm.SpanStatusCode.ERROR,message:d.message})).on("end",()=>{a.end()})}else return n._wrap(arguments,c,n._patchCallbackQuery(a,l)),mm.context.with(mm.trace.setSpan(mm.context.active(),a),()=>r.apply(t,arguments))}}}_patchCallbackQuery(t,r){return n=>function(o,i,s){return o&&t.setStatus({code:mm.SpanStatusCode.ERROR,message:o.message}),t.end(),mm.context.with(r,()=>n(...arguments))}}_setPoolcallbacks(t,r,n){let o=n||(0,TL.getPoolName)(t);t.on("connection",i=>{r._connectionsUsage.add(1,{state:"idle",name:o})}),t.on("acquire",i=>{r._connectionsUsage.add(-1,{state:"idle",name:o}),r._connectionsUsage.add(1,{state:"used",name:o})}),t.on("release",i=>{r._connectionsUsage.add(-1,{state:"used",name:o}),r._connectionsUsage.add(1,{state:"idle",name:o})})}};Uee.MySQLInstrumentation=zRe});var QTt=S(Qee=>{"use strict";Object.defineProperty(Qee,"__esModule",{value:!0});Qee.MySQLInstrumentation=void 0;var GJr=UTt();Object.defineProperty(Qee,"MySQLInstrumentation",{enumerable:!0,get:function(){return GJr.MySQLInstrumentation}})});var WRe=S(Gu=>{"use strict";Object.defineProperty(Gu,"__esModule",{value:!0});Gu.DB_SYSTEM_VALUE_MYSQL=Gu.ATTR_NET_PEER_PORT=Gu.ATTR_NET_PEER_NAME=Gu.ATTR_DB_USER=Gu.ATTR_DB_SYSTEM=Gu.ATTR_DB_STATEMENT=Gu.ATTR_DB_NAME=Gu.ATTR_DB_CONNECTION_STRING=void 0;Gu.ATTR_DB_CONNECTION_STRING="db.connection_string";Gu.ATTR_DB_NAME="db.name";Gu.ATTR_DB_STATEMENT="db.statement";Gu.ATTR_DB_SYSTEM="db.system";Gu.ATTR_DB_USER="db.user";Gu.ATTR_NET_PEER_NAME="net.peer.name";Gu.ATTR_NET_PEER_PORT="net.peer.port";Gu.DB_SYSTEM_VALUE_MYSQL="mysql"});var KRe=S(Gee=>{"use strict";Object.defineProperty(Gee,"__esModule",{value:!0});Gee.addSqlCommenterComment=void 0;var jRe=zt(),qJr=(Ys(),Hn(XA));function $Jr(e){let t=e.indexOf("--");if(t>=0)return!0;if(e.indexOf("/*")<0)return!1;let n=e.indexOf("*/");return t<n}function YJr(e){return encodeURIComponent(e).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`)}function VJr(e,t){if(typeof t!="string"||t.length===0||$Jr(t))return t;let r=new qJr.W3CTraceContextPropagator,n={};r.inject(jRe.trace.setSpan(jRe.ROOT_CONTEXT,e),n,jRe.defaultTextMapSetter);let o=Object.keys(n).sort();if(o.length===0)return t;let i=o.map(s=>{let a=YJr(n[s]);return`${s}='${a}'`}).join(",");return`${t} /*${i}*/`}Gee.addSqlCommenterComment=VJr});var YTt=S(lh=>{"use strict";Object.defineProperty(lh,"__esModule",{value:!0});lh.getConnectionPrototypeToInstrument=lh.once=lh.getSpanName=lh.getQueryText=lh.getConnectionAttributes=void 0;var pq=WRe(),Hee=(Nn(),Hn(Xi)),JRe=Ss();function zJr(e,t,r){let{host:n,port:o,database:i,user:s}=WJr(e),a={};t&Hee.SemconvStability.OLD&&(a[pq.ATTR_DB_CONNECTION_STRING]=jJr(n,o,i),a[pq.ATTR_DB_NAME]=i,a[pq.ATTR_DB_USER]=s),t&Hee.SemconvStability.STABLE&&(a[JRe.ATTR_DB_NAMESPACE]=i);let c=parseInt(o,10);return r&Hee.SemconvStability.OLD&&(a[pq.ATTR_NET_PEER_NAME]=n,isNaN(c)||(a[pq.ATTR_NET_PEER_PORT]=c)),r&Hee.SemconvStability.STABLE&&(a[JRe.ATTR_SERVER_ADDRESS]=n,isNaN(c)||(a[JRe.ATTR_SERVER_PORT]=c)),a}lh.getConnectionAttributes=zJr;function WJr(e){let{host:t,port:r,database:n,user:o}=e&&e.connectionConfig||e||{};return{host:t,port:r,database:n,user:o}}function jJr(e,t,r){let n=`jdbc:mysql://${e||"localhost"}`;return typeof t=="number"&&(n+=`:${t}`),typeof r=="string"&&(n+=`/${r}`),n}function KJr(e,t,r,n=!1,o=JJr){let[i,s]=typeof e=="string"?[e,r]:[e.sql,ZJr(e)?r||e.values:r];try{return n?o(i):t&&s?t(i,s):i}catch{return"Could not determine the query due to an error in masking or formatting"}}lh.getQueryText=KJr;function JJr(e){return e.replace(/\b\d+\b/g,"?").replace(/(["'])(?:(?=(\\?))\2.)*?\1/g,"?")}function ZJr(e){return"values"in e}function XJr(e){let t=typeof e=="object"?e.sql:e,r=t?.indexOf(" ");return typeof r=="number"&&r!==-1?t?.substring(0,r):t}lh.getSpanName=XJr;var eZr=e=>{let t=!1;return(...r)=>{if(!t)return t=!0,e(...r)}};lh.once=eZr;function tZr(e){let t=e.prototype,r=Object.getPrototypeOf(t);return typeof r?.query=="function"&&typeof r?.execute=="function"?r:t}lh.getConnectionPrototypeToInstrument=tZr});var VTt=S(bL=>{"use strict";Object.defineProperty(bL,"__esModule",{value:!0});bL.PACKAGE_NAME=bL.PACKAGE_VERSION=void 0;bL.PACKAGE_VERSION="0.55.0";bL.PACKAGE_NAME="@opentelemetry/instrumentation-mysql2"});var KTt=S(qee=>{"use strict";Object.defineProperty(qee,"__esModule",{value:!0});qee.MySQL2Instrumentation=void 0;var zTt=zt(),yE=(Nn(),Hn(Xi)),ZRe=WRe(),WTt=KRe(),yL=YTt(),jTt=VTt(),XRe=Ss(),eDe=[">=1.4.2 <4"],tDe=class extends yE.InstrumentationBase{_netSemconvStability;_dbSemconvStability;constructor(t={}){super(jTt.PACKAGE_NAME,jTt.PACKAGE_VERSION,t),this._setSemconvStabilityFromEnv()}_setSemconvStabilityFromEnv(){this._netSemconvStability=(0,yE.semconvStabilityFromStr)("http",process.env.OTEL_SEMCONV_STABILITY_OPT_IN),this._dbSemconvStability=(0,yE.semconvStabilityFromStr)("database",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}init(){let t;function r(i){!t&&i.format&&(t=i.format)}let n=i=>{(0,yE.isWrapped)(i.query)&&this._unwrap(i,"query"),this._wrap(i,"query",this._patchQuery(t,!1)),(0,yE.isWrapped)(i.execute)&&this._unwrap(i,"execute"),this._wrap(i,"execute",this._patchQuery(t,!0))},o=i=>{this._unwrap(i,"query"),this._unwrap(i,"execute")};return[new yE.InstrumentationNodeModuleDefinition("mysql2",eDe,i=>(r(i),i),()=>{},[new yE.InstrumentationNodeModuleFile("mysql2/promise.js",eDe,i=>(r(i),i),()=>{}),new yE.InstrumentationNodeModuleFile("mysql2/lib/connection.js",eDe,i=>{let s=(0,yL.getConnectionPrototypeToInstrument)(i);return n(s),i},i=>{if(i===void 0)return;let s=(0,yL.getConnectionPrototypeToInstrument)(i);o(s)})])]}_patchQuery(t,r){return n=>{let o=this;return function(i,s,a){let c;Array.isArray(s)?c=s:arguments[2]&&(c=[s]);let{maskStatement:l,maskStatementHook:u,responseHook:d}=o.getConfig(),p=(0,yL.getConnectionAttributes)(this.config,o._dbSemconvStability,o._netSemconvStability),f=(0,yL.getQueryText)(i,t,c,l,u);o._dbSemconvStability&yE.SemconvStability.OLD&&(p[ZRe.ATTR_DB_SYSTEM]=ZRe.DB_SYSTEM_VALUE_MYSQL,p[ZRe.ATTR_DB_STATEMENT]=f),o._dbSemconvStability&yE.SemconvStability.STABLE&&(p[XRe.ATTR_DB_SYSTEM_NAME]=XRe.DB_SYSTEM_NAME_VALUE_MYSQL,p[XRe.ATTR_DB_QUERY_TEXT]=f);let A=o.tracer.startSpan((0,yL.getSpanName)(i),{kind:zTt.SpanKind.CLIENT,attributes:p});!r&&o.getConfig().addSqlCommenterCommentToQueries&&(arguments[0]=i=typeof i=="string"?(0,WTt.addSqlCommenterComment)(A,i):Object.assign(i,{sql:(0,WTt.addSqlCommenterComment)(A,i.sql)}));let h=(0,yL.once)((_,T)=>{_?A.setStatus({code:zTt.SpanStatusCode.ERROR,message:_.message}):typeof d=="function"&&(0,yE.safeExecuteInTheMiddle)(()=>{d(A,{queryResults:T})},y=>{y&&o._diag.warn("Failed executing responseHook",y)},!0),A.end()});if(arguments.length===1){typeof i.onResult=="function"&&o._wrap(i,"onResult",o._patchCallbackQuery(h));let _=n.apply(this,arguments);return _.once("error",T=>{h(T)}).once("result",T=>{h(void 0,T)}),_}return typeof arguments[1]=="function"?o._wrap(arguments,1,o._patchCallbackQuery(h)):typeof arguments[2]=="function"&&o._wrap(arguments,2,o._patchCallbackQuery(h)),n.apply(this,arguments)}}}_patchCallbackQuery(t){return r=>function(n,o,i){return t(n,o),r(...arguments)}}};qee.MySQL2Instrumentation=tDe});var JTt=S($ee=>{"use strict";Object.defineProperty($ee,"__esModule",{value:!0});$ee.MySQL2Instrumentation=void 0;var rZr=KTt();Object.defineProperty($ee,"MySQL2Instrumentation",{enumerable:!0,get:function(){return rZr.MySQL2Instrumentation}})});var rbt=S(gm=>{"use strict";Object.defineProperty(gm,"__esModule",{value:!0});gm.DB_SYSTEM_VALUE_REDIS=gm.ATTR_NET_PEER_PORT=gm.ATTR_NET_PEER_NAME=gm.ATTR_DB_SYSTEM=gm.ATTR_DB_STATEMENT=gm.ATTR_DB_CONNECTION_STRING=void 0;gm.ATTR_DB_CONNECTION_STRING="db.connection_string";gm.ATTR_DB_STATEMENT="db.statement";gm.ATTR_DB_SYSTEM="db.system";gm.ATTR_NET_PEER_NAME="net.peer.name";gm.ATTR_NET_PEER_PORT="net.peer.port";gm.DB_SYSTEM_VALUE_REDIS="redis"});var nbt=S(Yee=>{"use strict";Object.defineProperty(Yee,"__esModule",{value:!0});Yee.endSpan=void 0;var oZr=zt(),iZr=(e,t)=>{t&&(e.recordException(t),e.setStatus({code:oZr.SpanStatusCode.ERROR,message:t.message})),e.end()};Yee.endSpan=iZr});var zee=S(Vee=>{"use strict";Object.defineProperty(Vee,"__esModule",{value:!0});Vee.defaultDbStatementSerializer=void 0;var sZr=[{regex:/^ECHO/i,args:0},{regex:/^(LPUSH|MSET|PFA|PUBLISH|RPUSH|SADD|SET|SPUBLISH|XADD|ZADD)/i,args:1},{regex:/^(HSET|HMSET|LSET|LINSERT)/i,args:2},{regex:/^(ACL|BIT|B[LRZ]|CLIENT|CLUSTER|CONFIG|COMMAND|DECR|DEL|EVAL|EX|FUNCTION|GEO|GET|HINCR|HMGET|HSCAN|INCR|L[TRLM]|MEMORY|P[EFISTU]|RPOP|S[CDIMORSU]|XACK|X[CDGILPRT]|Z[CDILMPRS])/i,args:-1}],aZr=(e,t)=>{if(Array.isArray(t)&&t.length){let r=sZr.find(({regex:o})=>o.test(e))?.args??0,n=r>=0?t.slice(0,r):t;return t.length>n.length&&n.push(`[${t.length-r} other arguments]`),`${e} ${n.join(" ")}`}return e};Vee.defaultDbStatementSerializer=aZr});var obt=S(CL=>{"use strict";Object.defineProperty(CL,"__esModule",{value:!0});CL.PACKAGE_NAME=CL.PACKAGE_VERSION=void 0;CL.PACKAGE_VERSION="0.56.0";CL.PACKAGE_NAME="@opentelemetry/instrumentation-ioredis"});var cbt=S(jee=>{"use strict";Object.defineProperty(jee,"__esModule",{value:!0});jee.IORedisInstrumentation=void 0;var Qv=zt(),Wee=(Nn(),Hn(Xi)),uh=rbt(),ibt=(Nn(),Hn(Xi)),fq=nbt(),cZr=zee(),sbt=obt(),abt={requireParentSpan:!0},rDe=class extends Wee.InstrumentationBase{constructor(t={}){super(sbt.PACKAGE_NAME,sbt.PACKAGE_VERSION,{...abt,...t})}setConfig(t={}){super.setConfig({...abt,...t})}init(){return[new Wee.InstrumentationNodeModuleDefinition("ioredis",[">=2.0.0 <6"],(t,r)=>{let n=t[Symbol.toStringTag]==="Module"?t.default:t;return(0,Wee.isWrapped)(n.prototype.sendCommand)&&this._unwrap(n.prototype,"sendCommand"),this._wrap(n.prototype,"sendCommand",this._patchSendCommand(r)),(0,Wee.isWrapped)(n.prototype.connect)&&this._unwrap(n.prototype,"connect"),this._wrap(n.prototype,"connect",this._patchConnection()),t},t=>{if(t===void 0)return;let r=t[Symbol.toStringTag]==="Module"?t.default:t;this._unwrap(r.prototype,"sendCommand"),this._unwrap(r.prototype,"connect")})]}_patchSendCommand(t){return r=>this._traceSendCommand(r,t)}_patchConnection(){return t=>this._traceConnection(t)}_traceSendCommand(t,r){let n=this;return function(o){if(arguments.length<1||typeof o!="object")return t.apply(this,arguments);let i=n.getConfig(),s=i.dbStatementSerializer||cZr.defaultDbStatementSerializer,a=Qv.trace.getSpan(Qv.context.active())===void 0;if(i.requireParentSpan===!0&&a)return t.apply(this,arguments);let c=n.tracer.startSpan(o.name,{kind:Qv.SpanKind.CLIENT,attributes:{[uh.ATTR_DB_SYSTEM]:uh.DB_SYSTEM_VALUE_REDIS,[uh.ATTR_DB_STATEMENT]:s(o.name,o.args)}}),{requestHook:l}=i;l&&(0,ibt.safeExecuteInTheMiddle)(()=>l(c,{moduleVersion:r,cmdName:o.name,cmdArgs:o.args}),p=>{p&&Qv.diag.error("ioredis instrumentation: request hook failed",p)},!0);let{host:u,port:d}=this.options;c.setAttributes({[uh.ATTR_NET_PEER_NAME]:u,[uh.ATTR_NET_PEER_PORT]:d,[uh.ATTR_DB_CONNECTION_STRING]:`redis://${u}:${d}`});try{let p=t.apply(this,arguments),f=o.resolve;o.resolve=function(h){(0,ibt.safeExecuteInTheMiddle)(()=>i.responseHook?.(c,o.name,o.args,h),_=>{_&&Qv.diag.error("ioredis instrumentation: response hook failed",_)},!0),(0,fq.endSpan)(c,null),f(h)};let A=o.reject;return o.reject=function(h){(0,fq.endSpan)(c,h),A(h)},p}catch(p){throw(0,fq.endSpan)(c,p),p}}}_traceConnection(t){let r=this;return function(){let n=Qv.trace.getSpan(Qv.context.active())===void 0;if(r.getConfig().requireParentSpan===!0&&n)return t.apply(this,arguments);let o=r.tracer.startSpan("connect",{kind:Qv.SpanKind.CLIENT,attributes:{[uh.ATTR_DB_SYSTEM]:uh.DB_SYSTEM_VALUE_REDIS,[uh.ATTR_DB_STATEMENT]:"connect"}}),{host:i,port:s}=this.options;o.setAttributes({[uh.ATTR_NET_PEER_NAME]:i,[uh.ATTR_NET_PEER_PORT]:s,[uh.ATTR_DB_CONNECTION_STRING]:`redis://${i}:${s}`});try{let a=t.apply(this,arguments);return(0,fq.endSpan)(o,null),a}catch(a){throw(0,fq.endSpan)(o,a),a}}}};jee.IORedisInstrumentation=rDe});var lbt=S(Kee=>{"use strict";Object.defineProperty(Kee,"__esModule",{value:!0});Kee.IORedisInstrumentation=void 0;var lZr=cbt();Object.defineProperty(Kee,"IORedisInstrumentation",{enumerable:!0,get:function(){return lZr.IORedisInstrumentation}})});var Jee=S(IL=>{"use strict";Object.defineProperty(IL,"__esModule",{value:!0});IL.PACKAGE_NAME=IL.PACKAGE_VERSION=void 0;IL.PACKAGE_VERSION="0.57.0";IL.PACKAGE_NAME="@opentelemetry/instrumentation-redis"});var ubt=S(Gv=>{"use strict";Object.defineProperty(Gv,"__esModule",{value:!0});Gv.getTracedCreateStreamTrace=Gv.getTracedCreateClient=Gv.endSpan=void 0;var mq=zt(),uZr=(e,t)=>{t&&e.setStatus({code:mq.SpanStatusCode.ERROR,message:t.message}),e.end()};Gv.endSpan=uZr;var dZr=e=>function(){let r=e.apply(this,arguments);return mq.context.bind(mq.context.active(),r)};Gv.getTracedCreateClient=dZr;var pZr=e=>function(){return Object.prototype.hasOwnProperty.call(this,"stream")||Object.defineProperty(this,"stream",{get(){return this._patched_redis_stream},set(r){mq.context.bind(mq.context.active(),r),this._patched_redis_stream=r}}),e.apply(this,arguments)};Gv.getTracedCreateStreamTrace=pZr});var Zee=S(mp=>{"use strict";Object.defineProperty(mp,"__esModule",{value:!0});mp.DB_SYSTEM_VALUE_REDIS=mp.DB_SYSTEM_NAME_VALUE_REDIS=mp.ATTR_NET_PEER_PORT=mp.ATTR_NET_PEER_NAME=mp.ATTR_DB_SYSTEM=mp.ATTR_DB_STATEMENT=mp.ATTR_DB_CONNECTION_STRING=void 0;mp.ATTR_DB_CONNECTION_STRING="db.connection_string";mp.ATTR_DB_STATEMENT="db.statement";mp.ATTR_DB_SYSTEM="db.system";mp.ATTR_NET_PEER_NAME="net.peer.name";mp.ATTR_NET_PEER_PORT="net.peer.port";mp.DB_SYSTEM_NAME_VALUE_REDIS="redis";mp.DB_SYSTEM_VALUE_REDIS="redis"});var pbt=S(ete=>{"use strict";Object.defineProperty(ete,"__esModule",{value:!0});ete.RedisInstrumentationV2_V3=void 0;var wg=(Nn(),Hn(Xi)),Xee=ubt(),dbt=Jee(),gq=zt(),Aq=Ss(),k1=Zee(),fZr=zee(),nDe=class e extends wg.InstrumentationBase{static COMPONENT="redis";_semconvStability;constructor(t={}){super(dbt.PACKAGE_NAME,dbt.PACKAGE_VERSION,t),this._semconvStability=t.semconvStability?t.semconvStability:(0,wg.semconvStabilityFromStr)("database",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}setConfig(t={}){super.setConfig(t),this._semconvStability=t.semconvStability?t.semconvStability:(0,wg.semconvStabilityFromStr)("database",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}init(){return[new wg.InstrumentationNodeModuleDefinition("redis",[">=2.6.0 <4"],t=>((0,wg.isWrapped)(t.RedisClient.prototype.internal_send_command)&&this._unwrap(t.RedisClient.prototype,"internal_send_command"),this._wrap(t.RedisClient.prototype,"internal_send_command",this._getPatchInternalSendCommand()),(0,wg.isWrapped)(t.RedisClient.prototype.create_stream)&&this._unwrap(t.RedisClient.prototype,"create_stream"),this._wrap(t.RedisClient.prototype,"create_stream",this._getPatchCreateStream()),(0,wg.isWrapped)(t.createClient)&&this._unwrap(t,"createClient"),this._wrap(t,"createClient",this._getPatchCreateClient()),t),t=>{t!==void 0&&(this._unwrap(t.RedisClient.prototype,"internal_send_command"),this._unwrap(t.RedisClient.prototype,"create_stream"),this._unwrap(t,"createClient"))})]}_getPatchInternalSendCommand(){let t=this;return function(n){return function(i){if(arguments.length!==1||typeof i!="object")return n.apply(this,arguments);let s=t.getConfig(),a=gq.trace.getSpan(gq.context.active())===void 0;if(s.requireParentSpan===!0&&a)return n.apply(this,arguments);let c=s?.dbStatementSerializer||fZr.defaultDbStatementSerializer,l={};t._semconvStability&wg.SemconvStability.OLD&&Object.assign(l,{[k1.ATTR_DB_SYSTEM]:k1.DB_SYSTEM_VALUE_REDIS,[k1.ATTR_DB_STATEMENT]:c(i.command,i.args)}),t._semconvStability&wg.SemconvStability.STABLE&&Object.assign(l,{[Aq.ATTR_DB_SYSTEM_NAME]:k1.DB_SYSTEM_NAME_VALUE_REDIS,[Aq.ATTR_DB_OPERATION_NAME]:i.command,[Aq.ATTR_DB_QUERY_TEXT]:c(i.command,i.args)});let u=t.tracer.startSpan(`${e.COMPONENT}-${i.command}`,{kind:gq.SpanKind.CLIENT,attributes:l});if(this.connection_options){let p={};t._semconvStability&wg.SemconvStability.OLD&&Object.assign(p,{[k1.ATTR_NET_PEER_NAME]:this.connection_options.host,[k1.ATTR_NET_PEER_PORT]:this.connection_options.port}),t._semconvStability&wg.SemconvStability.STABLE&&Object.assign(p,{[Aq.ATTR_SERVER_ADDRESS]:this.connection_options.host,[Aq.ATTR_SERVER_PORT]:this.connection_options.port}),u.setAttributes(p)}this.address&&t._semconvStability&wg.SemconvStability.OLD&&u.setAttribute(k1.ATTR_DB_CONNECTION_STRING,`redis://${this.address}`);let d=arguments[0].callback;if(d){let p=gq.context.active();arguments[0].callback=function(A,h){if(s?.responseHook){let _=s.responseHook;(0,wg.safeExecuteInTheMiddle)(()=>{_(u,i.command,i.args,h)},T=>{T&&t._diag.error("Error executing responseHook",T)},!0)}return(0,Xee.endSpan)(u,A),gq.context.with(p,d,this,...arguments)}}try{return n.apply(this,arguments)}catch(p){throw(0,Xee.endSpan)(u,p),p}}}}_getPatchCreateClient(){return function(r){return(0,Xee.getTracedCreateClient)(r)}}_getPatchCreateStream(){return function(r){return(0,Xee.getTracedCreateStreamTrace)(r)}}};ete.RedisInstrumentationV2_V3=nDe});var mbt=S(tte=>{"use strict";Object.defineProperty(tte,"__esModule",{value:!0});tte.getClientAttributes=void 0;var oDe=Ss(),vL=Zee(),fbt=(Nn(),Hn(Xi));function mZr(e,t,r){let n={};return r&fbt.SemconvStability.OLD&&Object.assign(n,{[vL.ATTR_DB_SYSTEM]:vL.DB_SYSTEM_VALUE_REDIS,[vL.ATTR_NET_PEER_NAME]:t?.socket?.host,[vL.ATTR_NET_PEER_PORT]:t?.socket?.port,[vL.ATTR_DB_CONNECTION_STRING]:gZr(e,t?.url)}),r&fbt.SemconvStability.STABLE&&Object.assign(n,{[oDe.ATTR_DB_SYSTEM_NAME]:vL.DB_SYSTEM_NAME_VALUE_REDIS,[oDe.ATTR_SERVER_ADDRESS]:t?.socket?.host,[oDe.ATTR_SERVER_PORT]:t?.socket?.port}),n}tte.getClientAttributes=mZr;function gZr(e,t){if(!(typeof t!="string"||!t))try{let r=new URL(t);return r.searchParams.delete("user_pwd"),r.username="",r.password="",r.href}catch(r){e.error("failed to sanitize redis connection url",r)}}});var Ebt=S(rte=>{"use strict";Object.defineProperty(rte,"__esModule",{value:!0});rte.RedisInstrumentationV4_V5=void 0;var dh=zt(),rc=(Nn(),Hn(Xi)),gbt=mbt(),AZr=zee(),Abt=Jee(),hbt=Ss(),hZr=Zee(),hq=Symbol("opentelemetry.instrumentation.redis.open_spans"),_bt=Symbol("opentelemetry.instrumentation.redis.multi_command_options"),iDe=class e extends rc.InstrumentationBase{static COMPONENT="redis";_semconvStability;constructor(t={}){super(Abt.PACKAGE_NAME,Abt.PACKAGE_VERSION,t),this._semconvStability=t.semconvStability?t.semconvStability:(0,rc.semconvStabilityFromStr)("database",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}setConfig(t={}){super.setConfig(t),this._semconvStability=t.semconvStability?t.semconvStability:(0,rc.semconvStabilityFromStr)("database",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}init(){return[this._getInstrumentationNodeModuleDefinition("@redis/client"),this._getInstrumentationNodeModuleDefinition("@node-redis/client")]}_getInstrumentationNodeModuleDefinition(t){let r=new rc.InstrumentationNodeModuleFile(`${t}/dist/lib/commander.js`,["^1.0.0"],(i,s)=>{let a=i.transformCommandArguments;if(!a)return this._diag.error("internal instrumentation error, missing transformCommandArguments function"),i;let c=s?.startsWith("1.0.")?"extendWithCommands":"attachCommands";return(0,rc.isWrapped)(i?.[c])&&this._unwrap(i,c),this._wrap(i,c,this._getPatchExtendWithCommands(a)),i},i=>{(0,rc.isWrapped)(i?.extendWithCommands)&&this._unwrap(i,"extendWithCommands"),(0,rc.isWrapped)(i?.attachCommands)&&this._unwrap(i,"attachCommands")}),n=new rc.InstrumentationNodeModuleFile(`${t}/dist/lib/client/multi-command.js`,["^1.0.0","^5.0.0"],i=>{let s=i?.default?.prototype;return(0,rc.isWrapped)(s?.exec)&&this._unwrap(s,"exec"),this._wrap(s,"exec",this._getPatchMultiCommandsExec()),(0,rc.isWrapped)(s?.addCommand)&&this._unwrap(s,"addCommand"),this._wrap(s,"addCommand",this._getPatchMultiCommandsAddCommand()),i},i=>{let s=i?.default?.prototype;(0,rc.isWrapped)(s?.exec)&&this._unwrap(s,"exec"),(0,rc.isWrapped)(s?.addCommand)&&this._unwrap(s,"addCommand")}),o=new rc.InstrumentationNodeModuleFile(`${t}/dist/lib/client/index.js`,["^1.0.0","^5.0.0"],i=>{let s=i?.default?.prototype;return s?.multi&&((0,rc.isWrapped)(s?.multi)&&this._unwrap(s,"multi"),this._wrap(s,"multi",this._getPatchRedisClientMulti())),s?.MULTI&&((0,rc.isWrapped)(s?.MULTI)&&this._unwrap(s,"MULTI"),this._wrap(s,"MULTI",this._getPatchRedisClientMulti())),(0,rc.isWrapped)(s?.sendCommand)&&this._unwrap(s,"sendCommand"),this._wrap(s,"sendCommand",this._getPatchRedisClientSendCommand()),this._wrap(s,"connect",this._getPatchedClientConnect()),i},i=>{let s=i?.default?.prototype;(0,rc.isWrapped)(s?.multi)&&this._unwrap(s,"multi"),(0,rc.isWrapped)(s?.MULTI)&&this._unwrap(s,"MULTI"),(0,rc.isWrapped)(s?.sendCommand)&&this._unwrap(s,"sendCommand")});return new rc.InstrumentationNodeModuleDefinition(t,["^1.0.0","^5.0.0"],i=>i,()=>{},[r,n,o])}_getPatchExtendWithCommands(t){let r=this;return function(o){return function(s){if(s?.BaseClass?.name!=="RedisClient")return o.apply(this,arguments);let a=s.executor;return s.executor=function(c,l){let u=t(c,l).args;return r._traceClientCommand(a,this,arguments,u)},o.apply(this,arguments)}}}_getPatchMultiCommandsExec(){let t=this;return function(n){return function(){let i=n.apply(this,arguments);return typeof i?.then!="function"?(t._diag.error("got non promise result when patching RedisClientMultiCommand.exec"),i):i.then(s=>{let a=this[hq];return t._endSpansWithRedisReplies(a,s),s}).catch(s=>{let a=this[hq];if(!a)t._diag.error("cannot find open spans to end for redis multi command");else{let c=s.constructor.name==="MultiErrorReply"?s.replies:new Array(a.length).fill(s);t._endSpansWithRedisReplies(a,c)}return Promise.reject(s)})}}}_getPatchMultiCommandsAddCommand(){let t=this;return function(n){return function(i){return t._traceClientCommand(n,this,arguments,i)}}}_getPatchRedisClientMulti(){return function(r){return function(){let o=r.apply(this,arguments);return o[_bt]=this.options,o}}}_getPatchRedisClientSendCommand(){let t=this;return function(n){return function(i){return t._traceClientCommand(n,this,arguments,i)}}}_getPatchedClientConnect(){let t=this;return function(n){return function(){let i=this.options,s=(0,gbt.getClientAttributes)(t._diag,i,t._semconvStability),a=t.tracer.startSpan(`${e.COMPONENT}-connect`,{kind:dh.SpanKind.CLIENT,attributes:s});return dh.context.with(dh.trace.setSpan(dh.context.active(),a),()=>n.apply(this)).then(l=>(a.end(),l)).catch(l=>(a.recordException(l),a.setStatus({code:dh.SpanStatusCode.ERROR,message:l.message}),a.end(),Promise.reject(l)))}}}_traceClientCommand(t,r,n,o){if(dh.trace.getSpan(dh.context.active())===void 0&&this.getConfig().requireParentSpan)return t.apply(r,n);let s=r.options||r[_bt],a=o[0],c=o.slice(1),l=this.getConfig().dbStatementSerializer||AZr.defaultDbStatementSerializer,u=(0,gbt.getClientAttributes)(this._diag,s,this._semconvStability);this._semconvStability&rc.SemconvStability.STABLE&&(u[hbt.ATTR_DB_OPERATION_NAME]=a);try{let f=l(a,c);f!=null&&(this._semconvStability&rc.SemconvStability.OLD&&(u[hZr.ATTR_DB_STATEMENT]=f),this._semconvStability&rc.SemconvStability.STABLE&&(u[hbt.ATTR_DB_QUERY_TEXT]=f))}catch(f){this._diag.error("dbStatementSerializer throw an exception",f,{commandName:a})}let d=this.tracer.startSpan(`${e.COMPONENT}-${a}`,{kind:dh.SpanKind.CLIENT,attributes:u}),p=dh.context.with(dh.trace.setSpan(dh.context.active(),d),()=>t.apply(r,n));if(typeof p?.then=="function")p.then(f=>{this._endSpanWithResponse(d,a,c,f,void 0)},f=>{this._endSpanWithResponse(d,a,c,null,f)});else{let f=p;f[hq]=f[hq]||[],f[hq].push({span:d,commandName:a,commandArgs:c})}return p}_endSpansWithRedisReplies(t,r){if(!t)return this._diag.error("cannot find open spans to end for redis multi command");if(r.length!==t.length)return this._diag.error("number of multi command spans does not match response from redis");for(let n=0;n<t.length;n++){let{span:o,commandName:i,commandArgs:s}=t[n],a=r[n],[c,l]=a instanceof Error?[null,a]:[a,void 0];this._endSpanWithResponse(o,i,s,c,l)}}_endSpanWithResponse(t,r,n,o,i){let{responseHook:s}=this.getConfig();if(!i&&s)try{s(t,r,n,o)}catch(a){this._diag.error("responseHook throw an exception",a)}i&&(t.recordException(i),t.setStatus({code:dh.SpanStatusCode.ERROR,message:i?.message})),t.end()}};rte.RedisInstrumentationV4_V5=iDe});var bbt=S(nte=>{"use strict";Object.defineProperty(nte,"__esModule",{value:!0});nte.RedisInstrumentation=void 0;var _Zr=(Nn(),Hn(Xi)),Sbt=Jee(),EZr=pbt(),SZr=Ebt(),Tbt={requireParentSpan:!1},sDe=class extends _Zr.InstrumentationBase{instrumentationV2_V3;instrumentationV4_V5;initialized=!1;constructor(t={}){let r={...Tbt,...t};super(Sbt.PACKAGE_NAME,Sbt.PACKAGE_VERSION,r),this.instrumentationV2_V3=new EZr.RedisInstrumentationV2_V3(this.getConfig()),this.instrumentationV4_V5=new SZr.RedisInstrumentationV4_V5(this.getConfig()),this.initialized=!0}setConfig(t={}){let r={...Tbt,...t};super.setConfig(r),this.initialized&&(this.instrumentationV2_V3.setConfig(r),this.instrumentationV4_V5.setConfig(r))}init(){}getModuleDefinitions(){return[...this.instrumentationV2_V3.getModuleDefinitions(),...this.instrumentationV4_V5.getModuleDefinitions()]}setTracerProvider(t){super.setTracerProvider(t),this.initialized&&(this.instrumentationV2_V3.setTracerProvider(t),this.instrumentationV4_V5.setTracerProvider(t))}enable(){super.enable(),this.initialized&&(this.instrumentationV2_V3.enable(),this.instrumentationV4_V5.enable())}disable(){super.disable(),this.initialized&&(this.instrumentationV2_V3.disable(),this.instrumentationV4_V5.disable())}};nte.RedisInstrumentation=sDe});var ybt=S(ote=>{"use strict";Object.defineProperty(ote,"__esModule",{value:!0});ote.RedisInstrumentation=void 0;var TZr=bbt();Object.defineProperty(ote,"RedisInstrumentation",{enumerable:!0,get:function(){return TZr.RedisInstrumentation}})});var Mbt=S(ste=>{"use strict";Object.defineProperty(ste,"__esModule",{value:!0});ste.EVENT_LISTENERS_SET=void 0;ste.EVENT_LISTENERS_SET=Symbol("opentelemetry.instrumentation.pg.eventListenersSet")});var lDe=S(Sq=>{"use strict";Object.defineProperty(Sq,"__esModule",{value:!0});Sq.AttributeNames=void 0;var DZr;(function(e){e.PG_VALUES="db.postgresql.values",e.PG_PLAN="db.postgresql.plan",e.IDLE_TIMEOUT_MILLIS="db.postgresql.idle.timeout.millis",e.MAX_CLIENT="db.postgresql.max.client"})(DZr=Sq.AttributeNames||(Sq.AttributeNames={}))});var uDe=S(Ui=>{"use strict";Object.defineProperty(Ui,"__esModule",{value:!0});Ui.METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS=Ui.METRIC_DB_CLIENT_CONNECTION_COUNT=Ui.DB_SYSTEM_VALUE_POSTGRESQL=Ui.DB_CLIENT_CONNECTION_STATE_VALUE_USED=Ui.DB_CLIENT_CONNECTION_STATE_VALUE_IDLE=Ui.ATTR_NET_PEER_PORT=Ui.ATTR_NET_PEER_NAME=Ui.ATTR_DB_USER=Ui.ATTR_DB_SYSTEM=Ui.ATTR_DB_STATEMENT=Ui.ATTR_DB_NAME=Ui.ATTR_DB_CONNECTION_STRING=Ui.ATTR_DB_CLIENT_CONNECTION_STATE=Ui.ATTR_DB_CLIENT_CONNECTION_POOL_NAME=void 0;Ui.ATTR_DB_CLIENT_CONNECTION_POOL_NAME="db.client.connection.pool.name";Ui.ATTR_DB_CLIENT_CONNECTION_STATE="db.client.connection.state";Ui.ATTR_DB_CONNECTION_STRING="db.connection_string";Ui.ATTR_DB_NAME="db.name";Ui.ATTR_DB_STATEMENT="db.statement";Ui.ATTR_DB_SYSTEM="db.system";Ui.ATTR_DB_USER="db.user";Ui.ATTR_NET_PEER_NAME="net.peer.name";Ui.ATTR_NET_PEER_PORT="net.peer.port";Ui.DB_CLIENT_CONNECTION_STATE_VALUE_IDLE="idle";Ui.DB_CLIENT_CONNECTION_STATE_VALUE_USED="used";Ui.DB_SYSTEM_VALUE_POSTGRESQL="postgresql";Ui.METRIC_DB_CLIENT_CONNECTION_COUNT="db.client.connection.count";Ui.METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS="db.client.connection.pending_requests"});var dDe=S(Tq=>{"use strict";Object.defineProperty(Tq,"__esModule",{value:!0});Tq.SpanNames=void 0;var NZr;(function(e){e.QUERY_PREFIX="pg.query",e.CONNECT="pg.connect",e.POOL_CONNECT="pg-pool.connect"})(NZr=Tq.SpanNames||(Tq.SpanNames={}))});var Qbt=S(zo=>{"use strict";Object.defineProperty(zo,"__esModule",{value:!0});zo.sanitizedErrorMessage=zo.isObjectWithTextString=zo.getErrorMessage=zo.patchClientConnectCallback=zo.patchCallbackPGPool=zo.updateCounter=zo.getPoolName=zo.patchCallback=zo.handleExecutionResult=zo.handleConfigQuery=zo.shouldSkipInstrumentation=zo.getSemanticAttributesFromPoolConnection=zo.getSemanticAttributesFromConnection=zo.getConnectionString=zo.parseAndMaskConnectionString=zo.parseNormalizedOperationName=zo.getQuerySpanName=void 0;var Hv=zt(),ate=lDe(),ph=Ss(),Tc=uDe(),P1=(Nn(),Hn(Xi)),Bbt=dDe();function kbt(e,t){if(!t)return Bbt.SpanNames.QUERY_PREFIX;let r=typeof t.name=="string"&&t.name?t.name:Pbt(t.text);return`${Bbt.SpanNames.QUERY_PREFIX}:${r}${e?` ${e}`:""}`}zo.getQuerySpanName=kbt;function Pbt(e){let t=e.indexOf(" "),r=t===-1?e:e.slice(0,t);return r=r.toUpperCase(),r.endsWith(";")?r.slice(0,-1):r}zo.parseNormalizedOperationName=Pbt;function Lbt(e){try{let t=new URL(e);return t.username="",t.password="",t.toString()}catch{return"postgresql://localhost:5432/"}}zo.parseAndMaskConnectionString=Lbt;function pDe(e){if("connectionString"in e&&e.connectionString)return Lbt(e.connectionString);let t=e.host||"localhost",r=e.port||5432,n=e.database||"";return`postgresql://${t}:${r}/${n}`}zo.getConnectionString=pDe;function cte(e){if(Number.isInteger(e))return e}function Fbt(e,t){let r={};return t&P1.SemconvStability.OLD&&(r={...r,[Tc.ATTR_DB_SYSTEM]:Tc.DB_SYSTEM_VALUE_POSTGRESQL,[Tc.ATTR_DB_NAME]:e.database,[Tc.ATTR_DB_CONNECTION_STRING]:pDe(e),[Tc.ATTR_DB_USER]:e.user,[Tc.ATTR_NET_PEER_NAME]:e.host,[Tc.ATTR_NET_PEER_PORT]:cte(e.port)}),t&P1.SemconvStability.STABLE&&(r={...r,[ph.ATTR_DB_SYSTEM_NAME]:ph.DB_SYSTEM_NAME_VALUE_POSTGRESQL,[ph.ATTR_DB_NAMESPACE]:e.namespace,[ph.ATTR_SERVER_ADDRESS]:e.host,[ph.ATTR_SERVER_PORT]:cte(e.port)}),r}zo.getSemanticAttributesFromConnection=Fbt;function xZr(e,t){let r;try{r=e.connectionString?new URL(e.connectionString):void 0}catch{r=void 0}let n={[ate.AttributeNames.IDLE_TIMEOUT_MILLIS]:e.idleTimeoutMillis,[ate.AttributeNames.MAX_CLIENT]:e.maxClient};return t&P1.SemconvStability.OLD&&(n={...n,[Tc.ATTR_DB_SYSTEM]:Tc.DB_SYSTEM_VALUE_POSTGRESQL,[Tc.ATTR_DB_NAME]:r?.pathname.slice(1)??e.database,[Tc.ATTR_DB_CONNECTION_STRING]:pDe(e),[Tc.ATTR_NET_PEER_NAME]:r?.hostname??e.host,[Tc.ATTR_NET_PEER_PORT]:Number(r?.port)||cte(e.port),[Tc.ATTR_DB_USER]:r?.username??e.user}),t&P1.SemconvStability.STABLE&&(n={...n,[ph.ATTR_DB_SYSTEM_NAME]:ph.DB_SYSTEM_NAME_VALUE_POSTGRESQL,[ph.ATTR_DB_NAMESPACE]:e.namespace,[ph.ATTR_SERVER_ADDRESS]:r?.hostname??e.host,[ph.ATTR_SERVER_PORT]:Number(r?.port)||cte(e.port)}),n}zo.getSemanticAttributesFromPoolConnection=xZr;function OZr(e){return e.requireParentSpan===!0&&Hv.trace.getSpan(Hv.context.active())===void 0}zo.shouldSkipInstrumentation=OZr;function wZr(e,t,r,n){let{connectionParameters:o}=this,i=o.database,s=kbt(i,n),a=e.startSpan(s,{kind:Hv.SpanKind.CLIENT,attributes:Fbt(o,r)});if(!n)return a;if(n.text&&(r&P1.SemconvStability.OLD&&a.setAttribute(Tc.ATTR_DB_STATEMENT,n.text),r&P1.SemconvStability.STABLE&&a.setAttribute(ph.ATTR_DB_QUERY_TEXT,n.text)),t.enhancedDatabaseReporting&&Array.isArray(n.values))try{let c=n.values.map(l=>l==null?"null":l instanceof Buffer?l.toString():typeof l=="object"?typeof l.toPostgres=="function"?l.toPostgres():JSON.stringify(l):l.toString());a.setAttribute(ate.AttributeNames.PG_VALUES,c)}catch(c){Hv.diag.error("failed to stringify ",n.values,c)}return typeof n.name=="string"&&a.setAttribute(ate.AttributeNames.PG_PLAN,n.name),a}zo.handleConfigQuery=wZr;function Ubt(e,t,r){typeof e.responseHook=="function"&&(0,P1.safeExecuteInTheMiddle)(()=>{e.responseHook(t,{data:r})},n=>{n&&Hv.diag.error("Error running response hook",n)},!0)}zo.handleExecutionResult=Ubt;function MZr(e,t,r,n,o){return function(s,a){s?(Object.prototype.hasOwnProperty.call(s,"code")&&(n[ph.ATTR_ERROR_TYPE]=s.code),s instanceof Error&&t.recordException(lte(s)),t.setStatus({code:Hv.SpanStatusCode.ERROR,message:s.message})):Ubt(e,t,a),o(),t.end(),r.call(this,s,a)}}zo.patchCallback=MZr;function BZr(e){let t="";return t+=(e?.host?`${e.host}`:"unknown_host")+":",t+=(e?.port?`${e.port}`:"unknown_port")+"/",t+=e?.database?`${e.database}`:"unknown_database",t.trim()}zo.getPoolName=BZr;function kZr(e,t,r,n,o){let i=t.totalCount,s=t.waitingCount,a=t.idleCount,c=i-a;return r.add(c-o.used,{[Tc.ATTR_DB_CLIENT_CONNECTION_STATE]:Tc.DB_CLIENT_CONNECTION_STATE_VALUE_USED,[Tc.ATTR_DB_CLIENT_CONNECTION_POOL_NAME]:e}),r.add(a-o.idle,{[Tc.ATTR_DB_CLIENT_CONNECTION_STATE]:Tc.DB_CLIENT_CONNECTION_STATE_VALUE_IDLE,[Tc.ATTR_DB_CLIENT_CONNECTION_POOL_NAME]:e}),n.add(s-o.pending,{[Tc.ATTR_DB_CLIENT_CONNECTION_POOL_NAME]:e}),{used:c,idle:a,pending:s}}zo.updateCounter=kZr;function PZr(e,t){return function(n,o,i){n&&(n instanceof Error&&e.recordException(lte(n)),e.setStatus({code:Hv.SpanStatusCode.ERROR,message:n.message})),e.end(),t.call(this,n,o,i)}}zo.patchCallbackPGPool=PZr;function LZr(e,t){return function(n){n&&(n instanceof Error&&e.recordException(lte(n)),e.setStatus({code:Hv.SpanStatusCode.ERROR,message:n.message})),e.end(),t.apply(this,arguments)}}zo.patchClientConnectCallback=LZr;function FZr(e){return typeof e=="object"&&e!==null&&"message"in e?String(e.message):void 0}zo.getErrorMessage=FZr;function UZr(e){return typeof e=="object"&&typeof e?.text=="string"}zo.isObjectWithTextString=UZr;function lte(e){let t=e?.name??"PostgreSQLError",r=e?.code??"UNKNOWN";return`PostgreSQL error of type '${t}' occurred (code: ${r})`}zo.sanitizedErrorMessage=lte});var Gbt=S(RL=>{"use strict";Object.defineProperty(RL,"__esModule",{value:!0});RL.PACKAGE_NAME=RL.PACKAGE_VERSION=void 0;RL.PACKAGE_VERSION="0.61.0";RL.PACKAGE_NAME="@opentelemetry/instrumentation-pg"});var zbt=S(dte=>{"use strict";Object.defineProperty(dte,"__esModule",{value:!0});dte.PgInstrumentation=void 0;var sf=(Nn(),Hn(Xi)),bs=zt(),Hbt=Mbt(),nc=Qbt(),qbt=KRe(),$bt=Gbt(),Ybt=dDe(),ute=(Ys(),Hn(XA)),CE=Ss(),bq=uDe();function DL(e){return e[Symbol.toStringTag]==="Module"?e.default:e}var fDe=class extends sf.InstrumentationBase{_connectionsCounter={used:0,idle:0,pending:0};_semconvStability;constructor(t={}){super($bt.PACKAGE_NAME,$bt.PACKAGE_VERSION,t),this._semconvStability=(0,sf.semconvStabilityFromStr)("database",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}_updateMetricInstruments(){this._operationDuration=this.meter.createHistogram(CE.METRIC_DB_CLIENT_OPERATION_DURATION,{description:"Duration of database client operations.",unit:"s",valueType:bs.ValueType.DOUBLE,advice:{explicitBucketBoundaries:[.001,.005,.01,.05,.1,.5,1,5,10]}}),this._connectionsCounter={idle:0,pending:0,used:0},this._connectionsCount=this.meter.createUpDownCounter(bq.METRIC_DB_CLIENT_CONNECTION_COUNT,{description:"The number of connections that are currently in state described by the state attribute.",unit:"{connection}"}),this._connectionPendingRequests=this.meter.createUpDownCounter(bq.METRIC_DB_CLIENT_CONNECTION_PENDING_REQUESTS,{description:"The number of current pending requests for an open connection.",unit:"{connection}"})}init(){let t=[">=8.0.3 <9"],r=[">=2.0.0 <4"],n=new sf.InstrumentationNodeModuleFile("pg/lib/native/client.js",t,this._patchPgClient.bind(this),this._unpatchPgClient.bind(this)),o=new sf.InstrumentationNodeModuleFile("pg/lib/client.js",t,this._patchPgClient.bind(this),this._unpatchPgClient.bind(this)),i=new sf.InstrumentationNodeModuleDefinition("pg",t,a=>{let c=DL(a);return this._patchPgClient(c.Client),a},a=>{let c=DL(a);return this._unpatchPgClient(c.Client),a},[o,n]),s=new sf.InstrumentationNodeModuleDefinition("pg-pool",r,a=>{let c=DL(a);return(0,sf.isWrapped)(c.prototype.connect)&&this._unwrap(c.prototype,"connect"),this._wrap(c.prototype,"connect",this._getPoolConnectPatch()),c},a=>{let c=DL(a);(0,sf.isWrapped)(c.prototype.connect)&&this._unwrap(c.prototype,"connect")});return[i,s]}_patchPgClient(t){if(!t)return;let r=DL(t);return(0,sf.isWrapped)(r.prototype.query)&&this._unwrap(r.prototype,"query"),(0,sf.isWrapped)(r.prototype.connect)&&this._unwrap(r.prototype,"connect"),this._wrap(r.prototype,"query",this._getClientQueryPatch()),this._wrap(r.prototype,"connect",this._getClientConnectPatch()),t}_unpatchPgClient(t){let r=DL(t);return(0,sf.isWrapped)(r.prototype.query)&&this._unwrap(r.prototype,"query"),(0,sf.isWrapped)(r.prototype.connect)&&this._unwrap(r.prototype,"connect"),t}_getClientConnectPatch(){let t=this;return r=>function(o){if(nc.shouldSkipInstrumentation(t.getConfig()))return r.call(this,o);let i=t.tracer.startSpan(Ybt.SpanNames.CONNECT,{kind:bs.SpanKind.CLIENT,attributes:nc.getSemanticAttributesFromConnection(this,t._semconvStability)});if(o){let a=bs.trace.getSpan(bs.context.active());o=nc.patchClientConnectCallback(i,o),a&&(o=bs.context.bind(bs.context.active(),o))}let s=bs.context.with(bs.trace.setSpan(bs.context.active(),i),()=>r.call(this,o));return Vbt(i,s)}}recordOperationDuration(t,r){let n={},o=[CE.ATTR_DB_NAMESPACE,CE.ATTR_ERROR_TYPE,CE.ATTR_SERVER_PORT,CE.ATTR_SERVER_ADDRESS,CE.ATTR_DB_OPERATION_NAME];this._semconvStability&sf.SemconvStability.OLD&&o.push(bq.ATTR_DB_SYSTEM),this._semconvStability&sf.SemconvStability.STABLE&&o.push(CE.ATTR_DB_SYSTEM_NAME),o.forEach(s=>{s in t&&(n[s]=t[s])});let i=(0,ute.hrTimeToMilliseconds)((0,ute.hrTimeDuration)(r,(0,ute.hrTime)()))/1e3;this._operationDuration.record(i,n)}_getClientQueryPatch(){let t=this;return r=>(this._diag.debug("Patching pg.Client.prototype.query"),function(...o){if(nc.shouldSkipInstrumentation(t.getConfig()))return r.apply(this,o);let i=(0,ute.hrTime)(),s=o[0],a=typeof s=="string",c=nc.isObjectWithTextString(s),l=a?{text:s,values:Array.isArray(o[1])?o[1]:void 0}:c?s:void 0,u={[bq.ATTR_DB_SYSTEM]:bq.DB_SYSTEM_VALUE_POSTGRESQL,[CE.ATTR_DB_NAMESPACE]:this.database,[CE.ATTR_SERVER_PORT]:this.connectionParameters.port,[CE.ATTR_SERVER_ADDRESS]:this.connectionParameters.host};l?.text&&(u[CE.ATTR_DB_OPERATION_NAME]=nc.parseNormalizedOperationName(l?.text));let d=()=>{t.recordOperationDuration(u,i)},p=t.getConfig(),f=nc.handleConfigQuery.call(this,t.tracer,p,t._semconvStability,l);if(p.addSqlCommenterCommentToQueries&&(a?o[0]=(0,qbt.addSqlCommenterComment)(f,s):c&&!("name"in s)&&(o[0]={...s,text:(0,qbt.addSqlCommenterComment)(f,s.text)})),o.length>0){let _=bs.trace.getSpan(bs.context.active());if(typeof o[o.length-1]=="function")o[o.length-1]=nc.patchCallback(p,f,o[o.length-1],u,d),_&&(o[o.length-1]=bs.context.bind(bs.context.active(),o[o.length-1]));else if(typeof l?.callback=="function"){let T=nc.patchCallback(t.getConfig(),f,l.callback,u,d);_&&(T=bs.context.bind(bs.context.active(),T)),o[0].callback=T}}let{requestHook:A}=p;typeof A=="function"&&l&&(0,sf.safeExecuteInTheMiddle)(()=>{let{database:_,host:T,port:y,user:I}=this.connectionParameters;A(f,{connection:{database:_,host:T,port:y,user:I},query:{text:l.text,values:l.values,name:l.name}})},_=>{_&&t._diag.error("Error running query hook",_)},!0);let h;try{h=r.apply(this,o)}catch(_){throw _ instanceof Error&&f.recordException(nc.sanitizedErrorMessage(_)),f.setStatus({code:bs.SpanStatusCode.ERROR,message:nc.getErrorMessage(_)}),f.end(),_}return h instanceof Promise?h.then(_=>new Promise(T=>{nc.handleExecutionResult(t.getConfig(),f,_),d(),f.end(),T(_)})).catch(_=>new Promise((T,y)=>{_ instanceof Error&&f.recordException(nc.sanitizedErrorMessage(_)),f.setStatus({code:bs.SpanStatusCode.ERROR,message:_.message}),d(),f.end(),y(_)})):h})}_setPoolConnectEventListeners(t){if(t[Hbt.EVENT_LISTENERS_SET])return;let r=nc.getPoolName(t.options);t.on("connect",()=>{this._connectionsCounter=nc.updateCounter(r,t,this._connectionsCount,this._connectionPendingRequests,this._connectionsCounter)}),t.on("acquire",()=>{this._connectionsCounter=nc.updateCounter(r,t,this._connectionsCount,this._connectionPendingRequests,this._connectionsCounter)}),t.on("remove",()=>{this._connectionsCounter=nc.updateCounter(r,t,this._connectionsCount,this._connectionPendingRequests,this._connectionsCounter)}),t.on("release",()=>{this._connectionsCounter=nc.updateCounter(r,t,this._connectionsCount,this._connectionPendingRequests,this._connectionsCounter)}),t[Hbt.EVENT_LISTENERS_SET]=!0}_getPoolConnectPatch(){let t=this;return r=>function(o){if(nc.shouldSkipInstrumentation(t.getConfig()))return r.call(this,o);let i=t.tracer.startSpan(Ybt.SpanNames.POOL_CONNECT,{kind:bs.SpanKind.CLIENT,attributes:nc.getSemanticAttributesFromPoolConnection(this.options,t._semconvStability)});if(t._setPoolConnectEventListeners(this),o){let a=bs.trace.getSpan(bs.context.active());o=nc.patchCallbackPGPool(i,o),a&&(o=bs.context.bind(bs.context.active(),o))}let s=bs.context.with(bs.trace.setSpan(bs.context.active(),i),()=>r.call(this,o));return Vbt(i,s)}}};dte.PgInstrumentation=fDe;function Vbt(e,t){if(!(t instanceof Promise))return t;let r=t;return bs.context.bind(bs.context.active(),r.then(n=>(e.end(),n)).catch(n=>(n instanceof Error&&e.recordException(nc.sanitizedErrorMessage(n)),e.setStatus({code:bs.SpanStatusCode.ERROR,message:nc.getErrorMessage(n)}),e.end(),Promise.reject(n))))}});var Wbt=S(NL=>{"use strict";Object.defineProperty(NL,"__esModule",{value:!0});NL.AttributeNames=NL.PgInstrumentation=void 0;var QZr=zbt();Object.defineProperty(NL,"PgInstrumentation",{enumerable:!0,get:function(){return QZr.PgInstrumentation}});var GZr=lDe();Object.defineProperty(NL,"AttributeNames",{enumerable:!0,get:function(){return GZr.AttributeNames}})});var fyt=S(xL=>{"use strict";Object.defineProperty(xL,"__esModule",{value:!0});xL.PACKAGE_NAME=xL.PACKAGE_VERSION=void 0;xL.PACKAGE_VERSION="0.55.0";xL.PACKAGE_NAME="@opentelemetry/instrumentation-hapi"});var EDe=S(TT=>{"use strict";Object.defineProperty(TT,"__esModule",{value:!0});TT.HapiLifecycleMethodNames=TT.HapiLayerType=TT.handlerPatched=TT.HapiComponentName=void 0;TT.HapiComponentName="@hapi/hapi";TT.handlerPatched=Symbol("hapi-handler-patched");TT.HapiLayerType={ROUTER:"router",PLUGIN:"plugin",EXT:"server.ext"};TT.HapiLifecycleMethodNames=new Set(["onPreAuth","onCredentials","onPostAuth","onPreHandler","onPostHandler","onPreResponse","onRequest"])});var myt=S(gte=>{"use strict";Object.defineProperty(gte,"__esModule",{value:!0});gte.ATTR_HTTP_METHOD=void 0;gte.ATTR_HTTP_METHOD="http.method"});var SDe=S(yq=>{"use strict";Object.defineProperty(yq,"__esModule",{value:!0});yq.AttributeNames=void 0;var rXr;(function(e){e.HAPI_TYPE="hapi.type",e.PLUGIN_NAME="hapi.plugin.name",e.EXT_TYPE="server.ext.type"})(rXr=yq.AttributeNames||(yq.AttributeNames={}))});var hyt=S(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});Pl.getPluginFromInput=Pl.getExtMetadata=Pl.getRouteMetadata=Pl.isPatchableExtMethod=Pl.isDirectExtInput=Pl.isLifecycleExtEventObj=Pl.isLifecycleExtType=Pl.getPluginName=void 0;var gyt=Ss(),nXr=myt(),Cq=EDe(),$v=SDe(),Ayt=(Nn(),Hn(Xi));function oXr(e){return e.name?e.name:e.pkg.name}Pl.getPluginName=oXr;var iXr=e=>typeof e=="string"&&Cq.HapiLifecycleMethodNames.has(e);Pl.isLifecycleExtType=iXr;var sXr=e=>{let t=e?.type;return t!==void 0&&(0,Pl.isLifecycleExtType)(t)};Pl.isLifecycleExtEventObj=sXr;var aXr=e=>Array.isArray(e)&&e.length<=3&&(0,Pl.isLifecycleExtType)(e[0])&&typeof e[1]=="function";Pl.isDirectExtInput=aXr;var cXr=e=>!Array.isArray(e);Pl.isPatchableExtMethod=cXr;var lXr=(e,t,r)=>{let n={[gyt.ATTR_HTTP_ROUTE]:e.path};t&Ayt.SemconvStability.OLD&&(n[nXr.ATTR_HTTP_METHOD]=e.method),t&Ayt.SemconvStability.STABLE&&(n[gyt.ATTR_HTTP_REQUEST_METHOD]=e.method);let o;return r?(n[$v.AttributeNames.HAPI_TYPE]=Cq.HapiLayerType.PLUGIN,n[$v.AttributeNames.PLUGIN_NAME]=r,o=`${r}: route - ${e.path}`):(n[$v.AttributeNames.HAPI_TYPE]=Cq.HapiLayerType.ROUTER,o=`route - ${e.path}`),{attributes:n,name:o}};Pl.getRouteMetadata=lXr;var uXr=(e,t)=>t?{attributes:{[$v.AttributeNames.EXT_TYPE]:e,[$v.AttributeNames.HAPI_TYPE]:Cq.HapiLayerType.EXT,[$v.AttributeNames.PLUGIN_NAME]:t},name:`${t}: ext - ${e}`}:{attributes:{[$v.AttributeNames.EXT_TYPE]:e,[$v.AttributeNames.HAPI_TYPE]:Cq.HapiLayerType.EXT},name:`ext - ${e}`};Pl.getExtMetadata=uXr;var dXr=e=>"plugin"in e?"plugin"in e.plugin?e.plugin.plugin:e.plugin:e;Pl.getPluginFromInput=dXr});var Syt=S(Ate=>{"use strict";Object.defineProperty(Ate,"__esModule",{value:!0});Ate.HapiInstrumentation=void 0;var Mg=zt(),_yt=(Ys(),Hn(XA)),Iq=(Nn(),Hn(Xi)),Eyt=fyt(),vq=EDe(),nC=hyt(),TDe=class extends Iq.InstrumentationBase{_semconvStability;constructor(t={}){super(Eyt.PACKAGE_NAME,Eyt.PACKAGE_VERSION,t),this._semconvStability=(0,Iq.semconvStabilityFromStr)("http",process.env.OTEL_SEMCONV_STABILITY_OPT_IN)}init(){return new Iq.InstrumentationNodeModuleDefinition(vq.HapiComponentName,[">=17.0.0 <22"],t=>{let r=t[Symbol.toStringTag]==="Module"?t.default:t;return(0,Iq.isWrapped)(r.server)||this._wrap(r,"server",this._getServerPatch.bind(this)),(0,Iq.isWrapped)(r.Server)||this._wrap(r,"Server",this._getServerPatch.bind(this)),r},t=>{let r=t[Symbol.toStringTag]==="Module"?t.default:t;this._massUnwrap([r],["server","Server"])})}_getServerPatch(t){let r=this,n=this;return function(i){let s=t.apply(this,[i]);return n._wrap(s,"route",a=>r._getServerRoutePatch.bind(r)(a)),n._wrap(s,"ext",a=>r._getServerExtPatch.bind(r)(a)),n._wrap(s,"register",r._getServerRegisterPatch.bind(r)),s}}_getServerRegisterPatch(t){let r=this;return function(o,i){if(Array.isArray(o))for(let s of o){let a=(0,nC.getPluginFromInput)(s);r._wrapRegisterHandler(a)}else{let s=(0,nC.getPluginFromInput)(o);r._wrapRegisterHandler(s)}return t.apply(this,[o,i])}}_getServerExtPatch(t,r){let n=this;return function(...i){if(Array.isArray(i[0])){let s=i[0];for(let a=0;a<s.length;a++){let c=s[a];if((0,nC.isLifecycleExtType)(c.type)){let l=c,u=n._wrapExtMethods(l.method,c.type,r);l.method=u,s[a]=l}}return t.apply(this,i)}else if((0,nC.isDirectExtInput)(i)){let s=i,a=s[1],c=n._wrapExtMethods(a,s[0],r);return t.apply(this,[s[0],c,s[2]])}else if((0,nC.isLifecycleExtEventObj)(i[0])){let s=i[0],a=n._wrapExtMethods(s.method,s.type,r);return s.method=a,t.call(this,s)}return t.apply(this,i)}}_getServerRoutePatch(t,r){let n=this;return function(o){if(Array.isArray(o))for(let i=0;i<o.length;i++){let s=n._wrapRouteHandler.call(n,o[i],r);o[i]=s}else o=n._wrapRouteHandler.call(n,o,r);return t.apply(this,[o])}}_wrapRegisterHandler(t){let r=this,n=(0,nC.getPluginName)(t),o=t.register,i=this,s=function(a,c){return i._wrap(a,"route",l=>r._getServerRoutePatch.bind(r)(l,n)),i._wrap(a,"ext",l=>r._getServerExtPatch.bind(r)(l,n)),o.call(this,a,c)};t.register=s}_wrapExtMethods(t,r,n){let o=this;if(t instanceof Array){for(let i=0;i<t.length;i++)t[i]=o._wrapExtMethods(t[i],r);return t}else if((0,nC.isPatchableExtMethod)(t))return t[vq.handlerPatched]===!0?t:(t[vq.handlerPatched]=!0,async function(...s){if(Mg.trace.getSpan(Mg.context.active())===void 0)return await t.apply(this,s);let a=(0,nC.getExtMetadata)(r,n),c=o.tracer.startSpan(a.name,{attributes:a.attributes});try{return await Mg.context.with(Mg.trace.setSpan(Mg.context.active(),c),t,void 0,...s)}catch(l){throw c.recordException(l),c.setStatus({code:Mg.SpanStatusCode.ERROR,message:l.message}),l}finally{c.end()}});return t}_wrapRouteHandler(t,r){let n=this;if(t[vq.handlerPatched]===!0)return t;t[vq.handlerPatched]=!0;let o=i=>async function(...s){if(Mg.trace.getSpan(Mg.context.active())===void 0)return await i.call(this,...s);let a=(0,_yt.getRPCMetadata)(Mg.context.active());a?.type===_yt.RPCType.HTTP&&(a.route=t.path);let c=(0,nC.getRouteMetadata)(t,n._semconvStability,r),l=n.tracer.startSpan(c.name,{attributes:c.attributes});try{return await Mg.context.with(Mg.trace.setSpan(Mg.context.active(),l),()=>i.call(this,...s))}catch(u){throw l.recordException(u),l.setStatus({code:Mg.SpanStatusCode.ERROR,message:u.message}),u}finally{l.end()}};if(typeof t.handler=="function")t.handler=o(t.handler);else if(typeof t.options=="function"){let i=t.options;t.options=function(s){let a=i(s);return typeof a.handler=="function"&&(a.handler=o(a.handler)),a}}else typeof t.options?.handler=="function"&&(t.options.handler=o(t.options.handler));return t}};Ate.HapiInstrumentation=TDe});var Tyt=S(OL=>{"use strict";Object.defineProperty(OL,"__esModule",{value:!0});OL.AttributeNames=OL.HapiInstrumentation=void 0;var pXr=Syt();Object.defineProperty(OL,"HapiInstrumentation",{enumerable:!0,get:function(){return pXr.HapiInstrumentation}});var fXr=SDe();Object.defineProperty(OL,"AttributeNames",{enumerable:!0,get:function(){return fXr.AttributeNames}})});var Ete=S(Dq=>{"use strict";Object.defineProperty(Dq,"__esModule",{value:!0});Dq.KoaLayerType=void 0;var EXr;(function(e){e.ROUTER="router",e.MIDDLEWARE="middleware"})(EXr=Dq.KoaLayerType||(Dq.KoaLayerType={}))});var Nyt=S(wL=>{"use strict";Object.defineProperty(wL,"__esModule",{value:!0});wL.PACKAGE_NAME=wL.PACKAGE_VERSION=void 0;wL.PACKAGE_VERSION="0.57.0";wL.PACKAGE_NAME="@opentelemetry/instrumentation-koa"});var bDe=S(Nq=>{"use strict";Object.defineProperty(Nq,"__esModule",{value:!0});Nq.AttributeNames=void 0;var SXr;(function(e){e.KOA_TYPE="koa.type",e.KOA_NAME="koa.name"})(SXr=Nq.AttributeNames||(Nq.AttributeNames={}))});var Oyt=S(ML=>{"use strict";Object.defineProperty(ML,"__esModule",{value:!0});ML.isLayerIgnored=ML.getMiddlewareMetadata=void 0;var xyt=Ete(),Ste=bDe(),TXr=Ss(),bXr=(e,t,r,n)=>r?{attributes:{[Ste.AttributeNames.KOA_NAME]:n?.toString(),[Ste.AttributeNames.KOA_TYPE]:xyt.KoaLayerType.ROUTER,[TXr.ATTR_HTTP_ROUTE]:n?.toString()},name:e._matchedRouteName||`router - ${n}`}:{attributes:{[Ste.AttributeNames.KOA_NAME]:t.name??"middleware",[Ste.AttributeNames.KOA_TYPE]:xyt.KoaLayerType.MIDDLEWARE},name:`middleware - ${t.name}`};ML.getMiddlewareMetadata=bXr;var yXr=(e,t)=>!!(Array.isArray(t?.ignoreLayersType)&&t?.ignoreLayersType?.includes(e));ML.isLayerIgnored=yXr});var wyt=S(Tte=>{"use strict";Object.defineProperty(Tte,"__esModule",{value:!0});Tte.kLayerPatched=void 0;Tte.kLayerPatched=Symbol("koa-layer-patched")});var Fyt=S(bte=>{"use strict";Object.defineProperty(bte,"__esModule",{value:!0});bte.KoaInstrumentation=void 0;var bT=zt(),xq=(Nn(),Hn(Xi)),Myt=Ete(),Byt=Nyt(),kyt=Oyt(),Pyt=(Ys(),Hn(XA)),Lyt=wyt(),yDe=class extends xq.InstrumentationBase{constructor(t={}){super(Byt.PACKAGE_NAME,Byt.PACKAGE_VERSION,t)}init(){return new xq.InstrumentationNodeModuleDefinition("koa",[">=2.0.0 <4"],t=>{let r=t[Symbol.toStringTag]==="Module"?t.default:t;return r==null?r:((0,xq.isWrapped)(r.prototype.use)&&this._unwrap(r.prototype,"use"),this._wrap(r.prototype,"use",this._getKoaUsePatch.bind(this)),t)},t=>{let r=t[Symbol.toStringTag]==="Module"?t.default:t;(0,xq.isWrapped)(r.prototype.use)&&this._unwrap(r.prototype,"use")})}_getKoaUsePatch(t){let r=this;return function(o){let i;return o.router?i=r._patchRouterDispatch(o):i=r._patchLayer(o,!1),t.apply(this,[i])}}_patchRouterDispatch(t){bT.diag.debug("Patching @koa/router dispatch");let n=t.router?.stack??[];for(let o of n){let i=o.path,s=o.stack;for(let a=0;a<s.length;a++){let c=s[a];s[a]=this._patchLayer(c,!0,i)}}return t}_patchLayer(t,r,n){let o=r?Myt.KoaLayerType.ROUTER:Myt.KoaLayerType.MIDDLEWARE;return t[Lyt.kLayerPatched]===!0||(0,kyt.isLayerIgnored)(o,this.getConfig())?t:t.constructor.name==="GeneratorFunction"||t.constructor.name==="AsyncGeneratorFunction"?(bT.diag.debug("ignoring generator-based Koa middleware layer"),t):(t[Lyt.kLayerPatched]=!0,bT.diag.debug("patching Koa middleware layer"),async(i,s)=>{if(bT.trace.getSpan(bT.context.active())===void 0)return t(i,s);let c=(0,kyt.getMiddlewareMetadata)(i,t,r,n),l=this.tracer.startSpan(c.name,{attributes:c.attributes}),u=(0,Pyt.getRPCMetadata)(bT.context.active());u?.type===Pyt.RPCType.HTTP&&i._matchedRoute&&(u.route=i._matchedRoute.toString());let{requestHook:d}=this.getConfig();d&&(0,xq.safeExecuteInTheMiddle)(()=>d(l,{context:i,middlewareLayer:t,layerType:o}),f=>{f&&bT.diag.error("koa instrumentation: request hook failed",f)},!0);let p=bT.trace.setSpan(bT.context.active(),l);return bT.context.with(p,async()=>{try{return await t(i,s)}catch(f){throw l.recordException(f),f}finally{l.end()}})})}};bte.KoaInstrumentation=yDe});var Uyt=S(Vv=>{"use strict";Object.defineProperty(Vv,"__esModule",{value:!0});Vv.KoaLayerType=Vv.AttributeNames=Vv.KoaInstrumentation=void 0;var CXr=Fyt();Object.defineProperty(Vv,"KoaInstrumentation",{enumerable:!0,get:function(){return CXr.KoaInstrumentation}});var IXr=bDe();Object.defineProperty(Vv,"AttributeNames",{enumerable:!0,get:function(){return IXr.AttributeNames}});var vXr=Ete();Object.defineProperty(Vv,"KoaLayerType",{enumerable:!0,get:function(){return vXr.KoaLayerType}})});var CDe=S(IE=>{"use strict";Object.defineProperty(IE,"__esModule",{value:!0});IE.ConnectNames=IE.ConnectTypes=IE.AttributeNames=void 0;var DXr;(function(e){e.CONNECT_TYPE="connect.type",e.CONNECT_NAME="connect.name"})(DXr=IE.AttributeNames||(IE.AttributeNames={}));var NXr;(function(e){e.MIDDLEWARE="middleware",e.REQUEST_HANDLER="request_handler"})(NXr=IE.ConnectTypes||(IE.ConnectTypes={}));var xXr;(function(e){e.MIDDLEWARE="middleware",e.REQUEST_HANDLER="request handler"})(xXr=IE.ConnectNames||(IE.ConnectNames={}))});var Yyt=S(BL=>{"use strict";Object.defineProperty(BL,"__esModule",{value:!0});BL.PACKAGE_NAME=BL.PACKAGE_VERSION=void 0;BL.PACKAGE_VERSION="0.52.0";BL.PACKAGE_NAME="@opentelemetry/instrumentation-connect"});var Vyt=S(yte=>{"use strict";Object.defineProperty(yte,"__esModule",{value:!0});yte._LAYERS_STORE_PROPERTY=void 0;yte._LAYERS_STORE_PROPERTY=Symbol("opentelemetry.instrumentation-connect.request-route-stack")});var zyt=S(Wv=>{"use strict";Object.defineProperty(Wv,"__esModule",{value:!0});Wv.generateRoute=Wv.replaceCurrentStackRoute=Wv.addNewStackLayer=void 0;var OXr=zt(),zv=Vyt(),wXr=e=>{Array.isArray(e[zv._LAYERS_STORE_PROPERTY])===!1&&Object.defineProperty(e,zv._LAYERS_STORE_PROPERTY,{enumerable:!1,value:[]}),e[zv._LAYERS_STORE_PROPERTY].push("/");let t=e[zv._LAYERS_STORE_PROPERTY].length;return()=>{t===e[zv._LAYERS_STORE_PROPERTY].length?e[zv._LAYERS_STORE_PROPERTY].pop():OXr.diag.warn("Connect: Trying to pop the stack multiple time")}};Wv.addNewStackLayer=wXr;var MXr=(e,t)=>{t&&e[zv._LAYERS_STORE_PROPERTY].splice(-1,1,t)};Wv.replaceCurrentStackRoute=MXr;var BXr=e=>e[zv._LAYERS_STORE_PROPERTY].reduce((t,r)=>t.replace(/\/+$/,"")+r);Wv.generateRoute=BXr});var Kyt=S(jv=>{"use strict";Object.defineProperty(jv,"__esModule",{value:!0});jv.ConnectInstrumentation=jv.ANONYMOUS_NAME=void 0;var kXr=zt(),Wyt=(Ys(),Hn(XA)),kL=CDe(),jyt=Yyt(),Cte=(Nn(),Hn(Xi)),PXr=Ss(),IDe=zyt();jv.ANONYMOUS_NAME="anonymous";var vDe=class extends Cte.InstrumentationBase{constructor(t={}){super(jyt.PACKAGE_NAME,jyt.PACKAGE_VERSION,t)}init(){return[new Cte.InstrumentationNodeModuleDefinition("connect",[">=3.0.0 <4"],t=>this._patchConstructor(t))]}_patchApp(t){(0,Cte.isWrapped)(t.use)||this._wrap(t,"use",this._patchUse.bind(this)),(0,Cte.isWrapped)(t.handle)||this._wrap(t,"handle",this._patchHandle.bind(this))}_patchConstructor(t){let r=this;return function(...n){let o=t.apply(this,n);return r._patchApp(o),o}}_patchNext(t,r){return function(o){let i=t.apply(this,[o]);return r(),i}}_startSpan(t,r){let n,o,i;t?(n=kL.ConnectTypes.REQUEST_HANDLER,i=kL.ConnectNames.REQUEST_HANDLER,o=t):(n=kL.ConnectTypes.MIDDLEWARE,i=kL.ConnectNames.MIDDLEWARE,o=r.name||jv.ANONYMOUS_NAME);let s=`${i} - ${o}`,a={attributes:{[PXr.ATTR_HTTP_ROUTE]:t.length>0?t:"/",[kL.AttributeNames.CONNECT_TYPE]:n,[kL.AttributeNames.CONNECT_NAME]:o}};return this.tracer.startSpan(s,a)}_patchMiddleware(t,r){let n=this,o=r.length===4;function i(){if(!n.isEnabled())return r.apply(this,arguments);let[s,a,c]=o?[1,2,3]:[0,1,2],l=arguments[s],u=arguments[a],d=arguments[c];(0,IDe.replaceCurrentStackRoute)(l,t);let p=(0,Wyt.getRPCMetadata)(kXr.context.active());t&&p?.type===Wyt.RPCType.HTTP&&(p.route=(0,IDe.generateRoute)(l));let f="";t?f=`request handler - ${t}`:f=`middleware - ${r.name||jv.ANONYMOUS_NAME}`;let A=n._startSpan(t,r);n._diag.debug("start span",f);let h=!1;function _(){h?n._diag.debug(`span ${A.name} - already finished`):(h=!0,n._diag.debug(`finishing span ${A.name}`),A.end()),u.removeListener("close",_)}return u.addListener("close",_),arguments[c]=n._patchNext(d,_),r.apply(this,arguments)}return Object.defineProperty(i,"length",{value:r.length,writable:!1,configurable:!0}),i}_patchUse(t){let r=this;return function(...n){let o=n[n.length-1],i=n[n.length-2]||"";return n[n.length-1]=r._patchMiddleware(i,o),t.apply(this,n)}}_patchHandle(t){let r=this;return function(){let[n,o]=[0,2],i=arguments[n],s=arguments[o],a=(0,IDe.addNewStackLayer)(i);return typeof s=="function"&&(arguments[o]=r._patchOut(s,a)),t.apply(this,arguments)}}_patchOut(t,r){return function(...o){return r(),Reflect.apply(t,this,o)}}};jv.ConnectInstrumentation=vDe});var Zyt=S(mh=>{"use strict";Object.defineProperty(mh,"__esModule",{value:!0});mh.ConnectTypes=mh.ConnectNames=mh.AttributeNames=mh.ANONYMOUS_NAME=mh.ConnectInstrumentation=void 0;var Jyt=Kyt();Object.defineProperty(mh,"ConnectInstrumentation",{enumerable:!0,get:function(){return Jyt.ConnectInstrumentation}});Object.defineProperty(mh,"ANONYMOUS_NAME",{enumerable:!0,get:function(){return Jyt.ANONYMOUS_NAME}});var RDe=CDe();Object.defineProperty(mh,"AttributeNames",{enumerable:!0,get:function(){return RDe.AttributeNames}});Object.defineProperty(mh,"ConnectNames",{enumerable:!0,get:function(){return RDe.ConnectNames}});Object.defineProperty(mh,"ConnectTypes",{enumerable:!0,get:function(){return RDe.ConnectTypes}})});var nCt=S(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});Hu.DB_SYSTEM_VALUE_MSSQL=Hu.ATTR_NET_PEER_PORT=Hu.ATTR_NET_PEER_NAME=Hu.ATTR_DB_USER=Hu.ATTR_DB_SYSTEM=Hu.ATTR_DB_STATEMENT=Hu.ATTR_DB_SQL_TABLE=Hu.ATTR_DB_NAME=void 0;Hu.ATTR_DB_NAME="db.name";Hu.ATTR_DB_SQL_TABLE="db.sql.table";Hu.ATTR_DB_STATEMENT="db.statement";Hu.ATTR_DB_SYSTEM="db.system";Hu.ATTR_DB_USER="db.user";Hu.ATTR_NET_PEER_NAME="net.peer.name";Hu.ATTR_NET_PEER_PORT="net.peer.port";Hu.DB_SYSTEM_VALUE_MSSQL="mssql"});var oCt=S(PL=>{"use strict";Object.defineProperty(PL,"__esModule",{value:!0});PL.once=PL.getSpanName=void 0;function FXr(e,t,r,n){return e==="execBulkLoad"&&n&&t?`${e} ${n} ${t}`:e==="callProcedure"?t?`${e} ${r} ${t}`:`${e} ${r}`:t?`${e} ${t}`:`${e}`}PL.getSpanName=FXr;var UXr=e=>{let t=!1;return(...r)=>{if(!t)return t=!0,e(...r)}};PL.once=UXr});var iCt=S(LL=>{"use strict";Object.defineProperty(LL,"__esModule",{value:!0});LL.PACKAGE_NAME=LL.PACKAGE_VERSION=void 0;LL.PACKAGE_VERSION="0.27.0";LL.PACKAGE_NAME="@opentelemetry/instrumentation-tedious"});var uCt=S(Jv=>{"use strict";Object.defineProperty(Jv,"__esModule",{value:!0});Jv.TediousInstrumentation=Jv.INJECTED_CTX=void 0;var FL=zt(),QXr=se("events"),Ite=(Nn(),Hn(Xi)),Kv=nCt(),sCt=oCt(),aCt=iCt(),lCt=Symbol("opentelemetry.instrumentation-tedious.current-database");Jv.INJECTED_CTX=Symbol("opentelemetry.instrumentation-tedious.context-info-injected");var cCt=["callProcedure","execSql","execSqlBatch","execBulkLoad","prepare","execute"];function vte(e){Object.defineProperty(this,lCt,{value:e,writable:!0})}var DDe=class e extends Ite.InstrumentationBase{static COMPONENT="tedious";constructor(t={}){super(aCt.PACKAGE_NAME,aCt.PACKAGE_VERSION,t)}init(){return[new Ite.InstrumentationNodeModuleDefinition(e.COMPONENT,[">=1.11.0 <20"],t=>{let r=t.Connection.prototype;for(let n of cCt)(0,Ite.isWrapped)(r[n])&&this._unwrap(r,n),this._wrap(r,n,this._patchQuery(n,t));return(0,Ite.isWrapped)(r.connect)&&this._unwrap(r,"connect"),this._wrap(r,"connect",this._patchConnect),t},t=>{if(t===void 0)return;let r=t.Connection.prototype;for(let n of cCt)this._unwrap(r,n);this._unwrap(r,"connect")})]}_patchConnect(t){return function(){return vte.call(this,this.config?.options?.database),this.removeListener("databaseChange",vte),this.on("databaseChange",vte),this.once("end",()=>{this.removeListener("databaseChange",vte)}),t.apply(this,arguments)}}_buildTraceparent(t){let r=t.spanContext();return`00-${r.traceId}-${r.spanId}-0${Number(r.traceFlags||FL.TraceFlags.NONE).toString(16)}`}_injectContextInfo(t,r,n){return new Promise(o=>{try{let i="set context_info @opentelemetry_traceparent",s=new r.Request(i,c=>{o()});Object.defineProperty(s,Jv.INJECTED_CTX,{value:!0});let a=Buffer.from(n,"utf8");s.addParameter("opentelemetry_traceparent",r.TYPES.VarBinary,a,{length:a.length}),t.execSql(s)}catch{o()}})}_shouldInjectFor(t){return t==="execSql"||t==="execSqlBatch"||t==="callProcedure"||t==="execute"}_patchQuery(t,r){return n=>{let o=this;function i(s){if(s?.[Jv.INJECTED_CTX])return n.apply(this,arguments);if(!(s instanceof QXr.EventEmitter))return o._diag.warn(`Unexpected invocation of patched ${t} method. Span not recorded`),n.apply(this,arguments);let a=0,c=0,l=()=>c++,u=()=>a++,d=this[lCt],p=(I=>I.sqlTextOrProcedure==="sp_prepare"&&I.parametersByName?.stmt?.value?I.parametersByName.stmt.value:I.sqlTextOrProcedure)(s),f=o.tracer.startSpan((0,sCt.getSpanName)(t,d,p,s.table),{kind:FL.SpanKind.CLIENT,attributes:{[Kv.ATTR_DB_SYSTEM]:Kv.DB_SYSTEM_VALUE_MSSQL,[Kv.ATTR_DB_NAME]:d,[Kv.ATTR_NET_PEER_PORT]:this.config?.options?.port,[Kv.ATTR_NET_PEER_NAME]:this.config?.server,[Kv.ATTR_DB_USER]:this.config?.userName??this.config?.authentication?.options?.userName,[Kv.ATTR_DB_STATEMENT]:p,[Kv.ATTR_DB_SQL_TABLE]:s.table}}),A=(0,sCt.once)(I=>{s.removeListener("done",l),s.removeListener("doneInProc",l),s.removeListener("doneProc",u),s.removeListener("error",A),this.removeListener("end",A),f.setAttribute("tedious.procedure_count",a),f.setAttribute("tedious.statement_count",c),I&&f.setStatus({code:FL.SpanStatusCode.ERROR,message:I.message}),f.end()});s.on("done",l),s.on("doneInProc",l),s.on("doneProc",u),s.once("error",A),this.on("end",A),typeof s.callback=="function"?o._wrap(s,"callback",o._patchCallbackQuery(A)):o._diag.error("Expected request.callback to be a function");let h=()=>FL.context.with(FL.trace.setSpan(FL.context.active(),f),n,this,...arguments);if(!(o.getConfig().enableTraceContextPropagation&&o._shouldInjectFor(t)))return h();let y=o._buildTraceparent(f);o._injectContextInfo(this,r,y).finally(h)}return Object.defineProperty(i,"length",{value:n.length,writable:!1}),i}}_patchCallbackQuery(t){return r=>function(n,o,i){return t(n),r.apply(this,arguments)}}};Jv.TediousInstrumentation=DDe});var dCt=S(Rte=>{"use strict";Object.defineProperty(Rte,"__esModule",{value:!0});Rte.TediousInstrumentation=void 0;var GXr=uCt();Object.defineProperty(Rte,"TediousInstrumentation",{enumerable:!0,get:function(){return GXr.TediousInstrumentation}})});var ACt=S(UL=>{"use strict";Object.defineProperty(UL,"__esModule",{value:!0});UL.PACKAGE_NAME=UL.PACKAGE_VERSION=void 0;UL.PACKAGE_VERSION="0.52.0";UL.PACKAGE_NAME="@opentelemetry/instrumentation-generic-pool"});var _Ct=S(Dte=>{"use strict";Object.defineProperty(Dte,"__esModule",{value:!0});Dte.GenericPoolInstrumentation=void 0;var QL=zt(),F1=(Nn(),Hn(Xi)),hCt=ACt(),NDe="generic-pool",xDe=class extends F1.InstrumentationBase{_isDisabled=!1;constructor(t={}){super(hCt.PACKAGE_NAME,hCt.PACKAGE_VERSION,t)}init(){return[new F1.InstrumentationNodeModuleDefinition(NDe,[">=3.0.0 <4"],t=>{let r=t.Pool;return(0,F1.isWrapped)(r.prototype.acquire)&&this._unwrap(r.prototype,"acquire"),this._wrap(r.prototype,"acquire",this._acquirePatcher.bind(this)),t},t=>{let r=t.Pool;return this._unwrap(r.prototype,"acquire"),t}),new F1.InstrumentationNodeModuleDefinition(NDe,[">=2.4.0 <3"],t=>{let r=t.Pool;return(0,F1.isWrapped)(r.prototype.acquire)&&this._unwrap(r.prototype,"acquire"),this._wrap(r.prototype,"acquire",this._acquireWithCallbacksPatcher.bind(this)),t},t=>{let r=t.Pool;return this._unwrap(r.prototype,"acquire"),t}),new F1.InstrumentationNodeModuleDefinition(NDe,[">=2.0.0 <2.4"],t=>(this._isDisabled=!1,(0,F1.isWrapped)(t.Pool)&&this._unwrap(t,"Pool"),this._wrap(t,"Pool",this._poolWrapper.bind(this)),t),t=>(this._isDisabled=!0,t))]}_acquirePatcher(t){let r=this;return function(...o){let i=QL.context.active(),s=r.tracer.startSpan("generic-pool.acquire",{},i);return QL.context.with(QL.trace.setSpan(i,s),()=>t.call(this,...o).then(a=>(s.end(),a),a=>{throw s.recordException(a),s.end(),a}))}}_poolWrapper(t){let r=this;return function(){let o=t.apply(this,arguments);return r._wrap(o,"acquire",r._acquireWithCallbacksPatcher.bind(r)),o}}_acquireWithCallbacksPatcher(t){let r=this;return function(o,i){if(r._isDisabled)return t.call(this,o,i);let s=QL.context.active(),a=r.tracer.startSpan("generic-pool.acquire",{},s);return QL.context.with(QL.trace.setSpan(s,a),()=>{t.call(this,(c,l)=>{if(a.end(),o)return o(c,l)},i)})}}};Dte.GenericPoolInstrumentation=xDe});var ECt=S(Nte=>{"use strict";Object.defineProperty(Nte,"__esModule",{value:!0});Nte.GenericPoolInstrumentation=void 0;var $Xr=_Ct();Object.defineProperty(Nte,"GenericPoolInstrumentation",{enumerable:!0,get:function(){return $Xr.GenericPoolInstrumentation}})});var ODe=S(yT=>{"use strict";Object.defineProperty(yT,"__esModule",{value:!0});yT.ATTR_NET_PEER_PORT=yT.ATTR_NET_PEER_NAME=yT.ATTR_MESSAGING_SYSTEM=yT.ATTR_MESSAGING_OPERATION=void 0;yT.ATTR_MESSAGING_OPERATION="messaging.operation";yT.ATTR_MESSAGING_SYSTEM="messaging.system";yT.ATTR_NET_PEER_NAME="net.peer.name";yT.ATTR_NET_PEER_PORT="net.peer.port"});var wDe=S(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});bc.ATTR_MESSAGING_CONVERSATION_ID=bc.OLD_ATTR_MESSAGING_MESSAGE_ID=bc.MESSAGING_DESTINATION_KIND_VALUE_TOPIC=bc.ATTR_MESSAGING_URL=bc.ATTR_MESSAGING_PROTOCOL_VERSION=bc.ATTR_MESSAGING_PROTOCOL=bc.MESSAGING_OPERATION_VALUE_PROCESS=bc.ATTR_MESSAGING_RABBITMQ_ROUTING_KEY=bc.ATTR_MESSAGING_DESTINATION_KIND=bc.ATTR_MESSAGING_DESTINATION=void 0;bc.ATTR_MESSAGING_DESTINATION="messaging.destination";bc.ATTR_MESSAGING_DESTINATION_KIND="messaging.destination_kind";bc.ATTR_MESSAGING_RABBITMQ_ROUTING_KEY="messaging.rabbitmq.routing_key";bc.MESSAGING_OPERATION_VALUE_PROCESS="process";bc.ATTR_MESSAGING_PROTOCOL="messaging.protocol";bc.ATTR_MESSAGING_PROTOCOL_VERSION="messaging.protocol_version";bc.ATTR_MESSAGING_URL="messaging.url";bc.MESSAGING_DESTINATION_KIND_VALUE_TOPIC="topic";bc.OLD_ATTR_MESSAGING_MESSAGE_ID="messaging.message_id";bc.ATTR_MESSAGING_CONVERSATION_ID="messaging.conversation_id"});var MDe=S(U1=>{"use strict";Object.defineProperty(U1,"__esModule",{value:!0});U1.DEFAULT_CONFIG=U1.EndOperation=void 0;var VXr;(function(e){e.AutoAck="auto ack",e.Ack="ack",e.AckAll="ackAll",e.Reject="reject",e.Nack="nack",e.NackAll="nackAll",e.ChannelClosed="channel closed",e.ChannelError="channel error",e.InstrumentationTimeout="instrumentation timeout"})(VXr=U1.EndOperation||(U1.EndOperation={}));U1.DEFAULT_CONFIG={consumeTimeoutMs:1e3*60,useLinksForConsume:!1}});var RCt=S(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});yc.isConfirmChannelTracing=yc.unmarkConfirmChannelTracing=yc.markConfirmChannelTracing=yc.getConnectionAttributesFromUrl=yc.getConnectionAttributesFromServer=yc.normalizeExchange=yc.CONNECTION_ATTRIBUTES=yc.CHANNEL_CONSUME_TIMEOUT_TIMER=yc.CHANNEL_SPANS_NOT_ENDED=yc.MESSAGE_STORED_SPAN=void 0;var BDe=zt(),Oq=ODe(),xte=wDe();yc.MESSAGE_STORED_SPAN=Symbol("opentelemetry.amqplib.message.stored-span");yc.CHANNEL_SPANS_NOT_ENDED=Symbol("opentelemetry.amqplib.channel.spans-not-ended");yc.CHANNEL_CONSUME_TIMEOUT_TIMER=Symbol("opentelemetry.amqplib.channel.consumer-timeout-timer");yc.CONNECTION_ATTRIBUTES=Symbol("opentelemetry.amqplib.connection.attributes");var kDe=(0,BDe.createContextKey)("opentelemetry.amqplib.channel.is-confirm-channel"),zXr=e=>e!==""?e:"<default>";yc.normalizeExchange=zXr;var WXr=e=>e.replace(/:[^:@/]*@/,":***@"),CCt=(e,t)=>e||(t==="AMQP"?5672:5671),ICt=e=>{let t=e||"amqp";return(t.endsWith(":")?t.substring(0,t.length-1):t).toUpperCase()},vCt=e=>e||"localhost",GL=(e,t,r,n)=>r?{[t]:r}:(BDe.diag.error(`amqplib instrumentation: could not extract connection attribute ${n} from user supplied url`,{url:e}),{}),jXr=e=>{let t=e.serverProperties.product?.toLowerCase?.();return t?{[Oq.ATTR_MESSAGING_SYSTEM]:t}:{}};yc.getConnectionAttributesFromServer=jXr;var KXr=e=>{let t={[xte.ATTR_MESSAGING_PROTOCOL_VERSION]:"0.9.1"};if(e=e||"amqp://localhost",typeof e=="object"){let r=e,n=ICt(r?.protocol);Object.assign(t,{...GL(e,xte.ATTR_MESSAGING_PROTOCOL,n,"protocol")});let o=vCt(r?.hostname);Object.assign(t,{...GL(e,Oq.ATTR_NET_PEER_NAME,o,"hostname")});let i=CCt(r.port,n);Object.assign(t,{...GL(e,Oq.ATTR_NET_PEER_PORT,i,"port")})}else{let r=WXr(e);t[xte.ATTR_MESSAGING_URL]=r;try{let n=new URL(r),o=ICt(n.protocol);Object.assign(t,{...GL(r,xte.ATTR_MESSAGING_PROTOCOL,o,"protocol")});let i=vCt(n.hostname);Object.assign(t,{...GL(r,Oq.ATTR_NET_PEER_NAME,i,"hostname")});let s=CCt(n.port?parseInt(n.port):void 0,o);Object.assign(t,{...GL(r,Oq.ATTR_NET_PEER_PORT,s,"port")})}catch(n){BDe.diag.error("amqplib instrumentation: error while extracting connection details from connection url",{censoredUrl:r,err:n})}}return t};yc.getConnectionAttributesFromUrl=KXr;var JXr=e=>e.setValue(kDe,!0);yc.markConfirmChannelTracing=JXr;var ZXr=e=>e.deleteValue(kDe);yc.unmarkConfirmChannelTracing=ZXr;var XXr=e=>e.getValue(kDe)===!0;yc.isConfirmChannelTracing=XXr});var DCt=S(HL=>{"use strict";Object.defineProperty(HL,"__esModule",{value:!0});HL.PACKAGE_NAME=HL.PACKAGE_VERSION=void 0;HL.PACKAGE_VERSION="0.55.0";HL.PACKAGE_NAME="@opentelemetry/instrumentation-amqplib"});var xCt=S(Mte=>{"use strict";Object.defineProperty(Mte,"__esModule",{value:!0});Mte.AmqplibInstrumentation=void 0;var oc=zt(),Ote=(Ys(),Hn(XA)),Qi=(Nn(),Hn(Xi)),een=ODe(),Bg=wDe(),af=MDe(),Cc=RCt(),NCt=DCt(),wte=[">=0.5.5 <1"],PDe=class extends Qi.InstrumentationBase{constructor(t={}){super(NCt.PACKAGE_NAME,NCt.PACKAGE_VERSION,{...af.DEFAULT_CONFIG,...t})}setConfig(t={}){super.setConfig({...af.DEFAULT_CONFIG,...t})}init(){let t=new Qi.InstrumentationNodeModuleFile("amqplib/lib/channel_model.js",wte,this.patchChannelModel.bind(this),this.unpatchChannelModel.bind(this)),r=new Qi.InstrumentationNodeModuleFile("amqplib/lib/callback_model.js",wte,this.patchChannelModel.bind(this),this.unpatchChannelModel.bind(this)),n=new Qi.InstrumentationNodeModuleFile("amqplib/lib/connect.js",wte,this.patchConnect.bind(this),this.unpatchConnect.bind(this));return new Qi.InstrumentationNodeModuleDefinition("amqplib",wte,void 0,void 0,[t,n,r])}patchConnect(t){return t=this.unpatchConnect(t),(0,Qi.isWrapped)(t.connect)||this._wrap(t,"connect",this.getConnectPatch.bind(this)),t}unpatchConnect(t){return(0,Qi.isWrapped)(t.connect)&&this._unwrap(t,"connect"),t}patchChannelModel(t,r){return(0,Qi.isWrapped)(t.Channel.prototype.publish)||this._wrap(t.Channel.prototype,"publish",this.getPublishPatch.bind(this,r)),(0,Qi.isWrapped)(t.Channel.prototype.consume)||this._wrap(t.Channel.prototype,"consume",this.getConsumePatch.bind(this,r)),(0,Qi.isWrapped)(t.Channel.prototype.ack)||this._wrap(t.Channel.prototype,"ack",this.getAckPatch.bind(this,!1,af.EndOperation.Ack)),(0,Qi.isWrapped)(t.Channel.prototype.nack)||this._wrap(t.Channel.prototype,"nack",this.getAckPatch.bind(this,!0,af.EndOperation.Nack)),(0,Qi.isWrapped)(t.Channel.prototype.reject)||this._wrap(t.Channel.prototype,"reject",this.getAckPatch.bind(this,!0,af.EndOperation.Reject)),(0,Qi.isWrapped)(t.Channel.prototype.ackAll)||this._wrap(t.Channel.prototype,"ackAll",this.getAckAllPatch.bind(this,!1,af.EndOperation.AckAll)),(0,Qi.isWrapped)(t.Channel.prototype.nackAll)||this._wrap(t.Channel.prototype,"nackAll",this.getAckAllPatch.bind(this,!0,af.EndOperation.NackAll)),(0,Qi.isWrapped)(t.Channel.prototype.emit)||this._wrap(t.Channel.prototype,"emit",this.getChannelEmitPatch.bind(this)),(0,Qi.isWrapped)(t.ConfirmChannel.prototype.publish)||this._wrap(t.ConfirmChannel.prototype,"publish",this.getConfirmedPublishPatch.bind(this,r)),t}unpatchChannelModel(t){return(0,Qi.isWrapped)(t.Channel.prototype.publish)&&this._unwrap(t.Channel.prototype,"publish"),(0,Qi.isWrapped)(t.Channel.prototype.consume)&&this._unwrap(t.Channel.prototype,"consume"),(0,Qi.isWrapped)(t.Channel.prototype.ack)&&this._unwrap(t.Channel.prototype,"ack"),(0,Qi.isWrapped)(t.Channel.prototype.nack)&&this._unwrap(t.Channel.prototype,"nack"),(0,Qi.isWrapped)(t.Channel.prototype.reject)&&this._unwrap(t.Channel.prototype,"reject"),(0,Qi.isWrapped)(t.Channel.prototype.ackAll)&&this._unwrap(t.Channel.prototype,"ackAll"),(0,Qi.isWrapped)(t.Channel.prototype.nackAll)&&this._unwrap(t.Channel.prototype,"nackAll"),(0,Qi.isWrapped)(t.Channel.prototype.emit)&&this._unwrap(t.Channel.prototype,"emit"),(0,Qi.isWrapped)(t.ConfirmChannel.prototype.publish)&&this._unwrap(t.ConfirmChannel.prototype,"publish"),t}getConnectPatch(t){return function(n,o,i){return t.call(this,n,o,function(s,a){if(s==null){let c=(0,Cc.getConnectionAttributesFromUrl)(n),l=(0,Cc.getConnectionAttributesFromServer)(a);a[Cc.CONNECTION_ATTRIBUTES]={...c,...l}}i.apply(this,arguments)})}}getChannelEmitPatch(t){let r=this;return function(o){if(o==="close"){r.endAllSpansOnChannel(this,!0,af.EndOperation.ChannelClosed,void 0);let i=this[Cc.CHANNEL_CONSUME_TIMEOUT_TIMER];i&&clearInterval(i),this[Cc.CHANNEL_CONSUME_TIMEOUT_TIMER]=void 0}else o==="error"&&r.endAllSpansOnChannel(this,!0,af.EndOperation.ChannelError,void 0);return t.apply(this,arguments)}}getAckAllPatch(t,r,n){let o=this;return function(s){return o.endAllSpansOnChannel(this,t,r,s),n.apply(this,arguments)}}getAckPatch(t,r,n){let o=this;return function(s,a,c){let l=this,u=r===af.EndOperation.Reject?a:c,d=l[Cc.CHANNEL_SPANS_NOT_ENDED]??[],p=d.findIndex(f=>f.msg===s);if(p<0)o.endConsumerSpan(s,t,r,u);else if(r!==af.EndOperation.Reject&&a){for(let f=0;f<=p;f++)o.endConsumerSpan(d[f].msg,t,r,u);d.splice(0,p+1)}else o.endConsumerSpan(s,t,r,u),d.splice(p,1);return n.apply(this,arguments)}}getConsumePatch(t,r){let n=this;return function(i,s,a){let c=this;if(!Object.prototype.hasOwnProperty.call(c,Cc.CHANNEL_SPANS_NOT_ENDED)){let{consumeTimeoutMs:u}=n.getConfig();if(u){let d=setInterval(()=>{n.checkConsumeTimeoutOnChannel(c)},u);d.unref(),c[Cc.CHANNEL_CONSUME_TIMEOUT_TIMER]=d}c[Cc.CHANNEL_SPANS_NOT_ENDED]=[]}let l=function(u){if(!u)return s.call(this,u);let d=u.properties.headers??{},p=oc.propagation.extract(oc.ROOT_CONTEXT,d),f=u.fields?.exchange,A;if(n._config.useLinksForConsume){let y=p?oc.trace.getSpan(p)?.spanContext():void 0;p=void 0,y&&(A=[{context:y}])}let h=n.tracer.startSpan(`${i} process`,{kind:oc.SpanKind.CONSUMER,attributes:{...c?.connection?.[Cc.CONNECTION_ATTRIBUTES],[Bg.ATTR_MESSAGING_DESTINATION]:f,[Bg.ATTR_MESSAGING_DESTINATION_KIND]:Bg.MESSAGING_DESTINATION_KIND_VALUE_TOPIC,[Bg.ATTR_MESSAGING_RABBITMQ_ROUTING_KEY]:u.fields?.routingKey,[een.ATTR_MESSAGING_OPERATION]:Bg.MESSAGING_OPERATION_VALUE_PROCESS,[Bg.OLD_ATTR_MESSAGING_MESSAGE_ID]:u?.properties.messageId,[Bg.ATTR_MESSAGING_CONVERSATION_ID]:u?.properties.correlationId},links:A},p),{consumeHook:_}=n.getConfig();_&&(0,Qi.safeExecuteInTheMiddle)(()=>_(h,{moduleVersion:t,msg:u}),y=>{y&&oc.diag.error("amqplib instrumentation: consumerHook error",y)},!0),a?.noAck||(c[Cc.CHANNEL_SPANS_NOT_ENDED].push({msg:u,timeOfConsume:(0,Ote.hrTime)()}),u[Cc.MESSAGE_STORED_SPAN]=h);let T=p||oc.ROOT_CONTEXT;oc.context.with(oc.trace.setSpan(T,h),()=>{s.call(this,u)}),a?.noAck&&(n.callConsumeEndHook(h,u,!1,af.EndOperation.AutoAck),h.end())};return arguments[1]=l,r.apply(this,arguments)}}getConfirmedPublishPatch(t,r){let n=this;return function(i,s,a,c,l){let u=this,{span:d,modifiedOptions:p}=n.createPublishSpan(n,i,s,u,c),{publishHook:f}=n.getConfig();f&&(0,Qi.safeExecuteInTheMiddle)(()=>f(d,{moduleVersion:t,exchange:i,routingKey:s,content:a,options:p,isConfirmChannel:!0}),T=>{T&&oc.diag.error("amqplib instrumentation: publishHook error",T)},!0);let A=function(T,y){try{l?.call(this,T,y)}finally{let{publishConfirmHook:I}=n.getConfig();I&&(0,Qi.safeExecuteInTheMiddle)(()=>I(d,{moduleVersion:t,exchange:i,routingKey:s,content:a,options:c,isConfirmChannel:!0,confirmError:T}),v=>{v&&oc.diag.error("amqplib instrumentation: publishConfirmHook error",v)},!0),T&&d.setStatus({code:oc.SpanStatusCode.ERROR,message:"message confirmation has been nack'ed"}),d.end()}},h=(0,Cc.markConfirmChannelTracing)(oc.context.active()),_=[...arguments];return _[3]=p,_[4]=oc.context.bind((0,Cc.unmarkConfirmChannelTracing)(oc.trace.setSpan(h,d)),A),oc.context.with(h,r.bind(this,..._))}}getPublishPatch(t,r){let n=this;return function(i,s,a,c){if((0,Cc.isConfirmChannelTracing)(oc.context.active()))return r.apply(this,arguments);{let l=this,{span:u,modifiedOptions:d}=n.createPublishSpan(n,i,s,l,c),{publishHook:p}=n.getConfig();p&&(0,Qi.safeExecuteInTheMiddle)(()=>p(u,{moduleVersion:t,exchange:i,routingKey:s,content:a,options:d,isConfirmChannel:!1}),h=>{h&&oc.diag.error("amqplib instrumentation: publishHook error",h)},!0);let f=[...arguments];f[3]=d;let A=r.apply(this,f);return u.end(),A}}}createPublishSpan(t,r,n,o,i){let s=(0,Cc.normalizeExchange)(r),a=t.tracer.startSpan(`publish ${s}`,{kind:oc.SpanKind.PRODUCER,attributes:{...o.connection[Cc.CONNECTION_ATTRIBUTES],[Bg.ATTR_MESSAGING_DESTINATION]:r,[Bg.ATTR_MESSAGING_DESTINATION_KIND]:Bg.MESSAGING_DESTINATION_KIND_VALUE_TOPIC,[Bg.ATTR_MESSAGING_RABBITMQ_ROUTING_KEY]:n,[Bg.OLD_ATTR_MESSAGING_MESSAGE_ID]:i?.messageId,[Bg.ATTR_MESSAGING_CONVERSATION_ID]:i?.correlationId}}),c=i??{};return c.headers=c.headers??{},oc.propagation.inject(oc.trace.setSpan(oc.context.active(),a),c.headers),{span:a,modifiedOptions:c}}endConsumerSpan(t,r,n,o){let i=t[Cc.MESSAGE_STORED_SPAN];i&&(r!==!1&&i.setStatus({code:oc.SpanStatusCode.ERROR,message:n!==af.EndOperation.ChannelClosed&&n!==af.EndOperation.ChannelError?`${n} called on message${o===!0?" with requeue":o===!1?" without requeue":""}`:n}),this.callConsumeEndHook(i,t,r,n),i.end(),t[Cc.MESSAGE_STORED_SPAN]=void 0)}endAllSpansOnChannel(t,r,n,o){(t[Cc.CHANNEL_SPANS_NOT_ENDED]??[]).forEach(s=>{this.endConsumerSpan(s.msg,r,n,o)}),t[Cc.CHANNEL_SPANS_NOT_ENDED]=[]}callConsumeEndHook(t,r,n,o){let{consumeEndHook:i}=this.getConfig();i&&(0,Qi.safeExecuteInTheMiddle)(()=>i(t,{msg:r,rejected:n,endOperation:o}),s=>{s&&oc.diag.error("amqplib instrumentation: consumerEndHook error",s)},!0)}checkConsumeTimeoutOnChannel(t){let r=(0,Ote.hrTime)(),n=t[Cc.CHANNEL_SPANS_NOT_ENDED]??[],o,{consumeTimeoutMs:i}=this.getConfig();for(o=0;o<n.length;o++){let s=n[o],a=(0,Ote.hrTimeDuration)(s.timeOfConsume,r);if((0,Ote.hrTimeToMilliseconds)(a)<i)break;this.endConsumerSpan(s.msg,null,af.EndOperation.InstrumentationTimeout,!0)}n.splice(0,o)}};Mte.AmqplibInstrumentation=PDe});var wCt=S(Zv=>{"use strict";Object.defineProperty(Zv,"__esModule",{value:!0});Zv.EndOperation=Zv.DEFAULT_CONFIG=Zv.AmqplibInstrumentation=void 0;var ten=xCt();Object.defineProperty(Zv,"AmqplibInstrumentation",{enumerable:!0,get:function(){return ten.AmqplibInstrumentation}});var OCt=MDe();Object.defineProperty(Zv,"DEFAULT_CONFIG",{enumerable:!0,get:function(){return OCt.DEFAULT_CONFIG}});Object.defineProperty(Zv,"EndOperation",{enumerable:!0,get:function(){return OCt.EndOperation}})});var Men,$te,UDe=Q(()=>{Men=typeof global=="object"&&global&&global.Object===Object&&global,$te=Men});var Ben,ken,Ll,vE=Q(()=>{UDe();Ben=typeof self=="object"&&self&&self.Object===Object&&self,ken=$te||Ben||Function("return this")(),Ll=ken});var Pen,qu,Q1=Q(()=>{vE();Pen=Ll.Symbol,qu=Pen});function Uen(e){var t=Len.call(e,Mq),r=e[Mq];try{e[Mq]=void 0;var n=!0}catch{}var o=Fen.call(e);return n&&(t?e[Mq]=r:delete e[Mq]),o}var p0t,Len,Fen,Mq,f0t,m0t=Q(()=>{Q1();p0t=Object.prototype,Len=p0t.hasOwnProperty,Fen=p0t.toString,Mq=qu?qu.toStringTag:void 0;f0t=Uen});function Hen(e){return Gen.call(e)}var Qen,Gen,g0t,A0t=Q(()=>{Qen=Object.prototype,Gen=Qen.toString;g0t=Hen});function Yen(e){return e==null?e===void 0?$en:qen:h0t&&h0t in Object(e)?f0t(e):g0t(e)}var qen,$en,h0t,kg,G1=Q(()=>{Q1();m0t();A0t();qen="[object Null]",$en="[object Undefined]",h0t=qu?qu.toStringTag:void 0;kg=Yen});function Ven(e){return e!=null&&typeof e=="object"}var du,IT=Q(()=>{du=Ven});function Wen(e){return typeof e=="symbol"||du(e)&&kg(e)==zen}var zen,YL,Yte=Q(()=>{G1();IT();zen="[object Symbol]";YL=Wen});function jen(e,t){for(var r=-1,n=e==null?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var vT,VL=Q(()=>{vT=jen});var Ken,ia,Pg=Q(()=>{Ken=Array.isArray,ia=Ken});function S0t(e){if(typeof e=="string")return e;if(ia(e))return vT(e,S0t)+"";if(YL(e))return E0t?E0t.call(e):"";var t=e+"";return t=="0"&&1/e==-Jen?"-0":t}var Jen,_0t,E0t,T0t,b0t=Q(()=>{Q1();VL();Pg();Yte();Jen=1/0,_0t=qu?qu.prototype:void 0,E0t=_0t?_0t.toString:void 0;T0t=S0t});function Zen(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var lf,Xv=Q(()=>{lf=Zen});function Xen(e){return e}var zL,Vte=Q(()=>{zL=Xen});function otn(e){if(!lf(e))return!1;var t=kg(e);return t==ttn||t==rtn||t==etn||t==ntn}var etn,ttn,rtn,ntn,zte,QDe=Q(()=>{G1();Xv();etn="[object AsyncFunction]",ttn="[object Function]",rtn="[object GeneratorFunction]",ntn="[object Proxy]";zte=otn});var itn,Wte,y0t=Q(()=>{vE();itn=Ll["__core-js_shared__"],Wte=itn});function stn(e){return!!C0t&&C0t in e}var C0t,I0t,v0t=Q(()=>{y0t();C0t=(function(){var e=/[^.]+$/.exec(Wte&&Wte.keys&&Wte.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})();I0t=stn});function ltn(e){if(e!=null){try{return ctn.call(e)}catch{}try{return e+""}catch{}}return""}var atn,ctn,iC,GDe=Q(()=>{atn=Function.prototype,ctn=atn.toString;iC=ltn});function htn(e){if(!lf(e)||I0t(e))return!1;var t=zte(e)?Atn:dtn;return t.test(iC(e))}var utn,dtn,ptn,ftn,mtn,gtn,Atn,R0t,D0t=Q(()=>{QDe();v0t();Xv();GDe();utn=/[\\^$.*+?()[\]{}|]/g,dtn=/^\[object .+?Constructor\]$/,ptn=Function.prototype,ftn=Object.prototype,mtn=ptn.toString,gtn=ftn.hasOwnProperty,Atn=RegExp("^"+mtn.call(gtn).replace(utn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");R0t=htn});function _tn(e,t){return e?.[t]}var N0t,x0t=Q(()=>{N0t=_tn});function Etn(e,t){var r=N0t(e,t);return R0t(r)?r:void 0}var Am,eR=Q(()=>{D0t();x0t();Am=Etn});var Stn,jte,O0t=Q(()=>{eR();vE();Stn=Am(Ll,"WeakMap"),jte=Stn});var w0t,Ttn,M0t,B0t=Q(()=>{Xv();w0t=Object.create,Ttn=(function(){function e(){}return function(t){if(!lf(t))return{};if(w0t)return w0t(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}})(),M0t=Ttn});function btn(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var k0t,P0t=Q(()=>{k0t=btn});function ytn(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var L0t,F0t=Q(()=>{L0t=ytn});function Rtn(e){var t=0,r=0;return function(){var n=vtn(),o=Itn-(n-r);if(r=n,o>0){if(++t>=Ctn)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Ctn,Itn,vtn,U0t,Q0t=Q(()=>{Ctn=800,Itn=16,vtn=Date.now;U0t=Rtn});function Dtn(e){return function(){return e}}var G0t,H0t=Q(()=>{G0t=Dtn});var Ntn,WL,HDe=Q(()=>{eR();Ntn=(function(){try{var e=Am(Object,"defineProperty");return e({},"",{}),e}catch{}})(),WL=Ntn});var xtn,q0t,$0t=Q(()=>{H0t();HDe();Vte();xtn=WL?function(e,t){return WL(e,"toString",{configurable:!0,enumerable:!1,value:G0t(t),writable:!0})}:zL,q0t=xtn});var Otn,Kte,qDe=Q(()=>{$0t();Q0t();Otn=U0t(q0t),Kte=Otn});function wtn(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var Y0t,V0t=Q(()=>{Y0t=wtn});function ktn(e,t){var r=typeof e;return t=t??Mtn,!!t&&(r=="number"||r!="symbol"&&Btn.test(e))&&e>-1&&e%1==0&&e<t}var Mtn,Btn,jL,Jte=Q(()=>{Mtn=9007199254740991,Btn=/^(?:0|[1-9]\d*)$/;jL=ktn});function Ptn(e,t,r){t=="__proto__"&&WL?WL(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var KL,Zte=Q(()=>{HDe();KL=Ptn});function Ltn(e,t){return e===t||e!==e&&t!==t}var JL,Xte=Q(()=>{JL=Ltn});function Qtn(e,t,r){var n=e[t];(!(Utn.call(e,t)&&JL(n,r))||r===void 0&&!(t in e))&&KL(e,t,r)}var Ftn,Utn,tR,Bq=Q(()=>{Zte();Xte();Ftn=Object.prototype,Utn=Ftn.hasOwnProperty;tR=Qtn});function Gtn(e,t,r,n){var o=!r;r||(r={});for(var i=-1,s=t.length;++i<s;){var a=t[i],c=n?n(r[a],e[a],a,r,e):void 0;c===void 0&&(c=e[a]),o?KL(r,a,c):tR(r,a,c)}return r}var RT,ZL=Q(()=>{Bq();Zte();RT=Gtn});function Htn(e,t,r){return t=z0t(t===void 0?e.length-1:t,0),function(){for(var n=arguments,o=-1,i=z0t(n.length-t,0),s=Array(i);++o<i;)s[o]=n[t+o];o=-1;for(var a=Array(t+1);++o<t;)a[o]=n[o];return a[t]=r(s),k0t(e,this,a)}}var z0t,ere,$De=Q(()=>{P0t();z0t=Math.max;ere=Htn});function qtn(e,t){return Kte(ere(e,t,zL),e+"")}var W0t,j0t=Q(()=>{Vte();$De();qDe();W0t=qtn});function Ytn(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=$tn}var $tn,XL,tre=Q(()=>{$tn=9007199254740991;XL=Ytn});function Vtn(e){return e!=null&&XL(e.length)&&!zte(e)}var rR,kq=Q(()=>{QDe();tre();rR=Vtn});function Wtn(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||ztn;return e===r}var ztn,e2,rre=Q(()=>{ztn=Object.prototype;e2=Wtn});function jtn(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var nre,YDe=Q(()=>{nre=jtn});function Jtn(e){return du(e)&&kg(e)==Ktn}var Ktn,VDe,K0t=Q(()=>{G1();IT();Ktn="[object Arguments]";VDe=Jtn});var J0t,Ztn,Xtn,ern,t2,ore=Q(()=>{K0t();IT();J0t=Object.prototype,Ztn=J0t.hasOwnProperty,Xtn=J0t.propertyIsEnumerable,ern=VDe((function(){return arguments})())?VDe:function(e){return du(e)&&Ztn.call(e,"callee")&&!Xtn.call(e,"callee")},t2=ern});function trn(){return!1}var Z0t,X0t=Q(()=>{Z0t=trn});var rIt,eIt,rrn,tIt,nrn,orn,H1,ire=Q(()=>{vE();X0t();rIt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,eIt=rIt&&typeof module=="object"&&module&&!module.nodeType&&module,rrn=eIt&&eIt.exports===rIt,tIt=rrn?Ll.Buffer:void 0,nrn=tIt?tIt.isBuffer:void 0,orn=nrn||Z0t,H1=orn});function Nrn(e){return du(e)&&XL(e.length)&&!!sa[kg(e)]}var irn,srn,arn,crn,lrn,urn,drn,prn,frn,mrn,grn,Arn,hrn,_rn,Ern,Srn,Trn,brn,yrn,Crn,Irn,vrn,Rrn,Drn,sa,nIt,oIt=Q(()=>{G1();tre();IT();irn="[object Arguments]",srn="[object Array]",arn="[object Boolean]",crn="[object Date]",lrn="[object Error]",urn="[object Function]",drn="[object Map]",prn="[object Number]",frn="[object Object]",mrn="[object RegExp]",grn="[object Set]",Arn="[object String]",hrn="[object WeakMap]",_rn="[object ArrayBuffer]",Ern="[object DataView]",Srn="[object Float32Array]",Trn="[object Float64Array]",brn="[object Int8Array]",yrn="[object Int16Array]",Crn="[object Int32Array]",Irn="[object Uint8Array]",vrn="[object Uint8ClampedArray]",Rrn="[object Uint16Array]",Drn="[object Uint32Array]",sa={};sa[Srn]=sa[Trn]=sa[brn]=sa[yrn]=sa[Crn]=sa[Irn]=sa[vrn]=sa[Rrn]=sa[Drn]=!0;sa[irn]=sa[srn]=sa[_rn]=sa[arn]=sa[Ern]=sa[crn]=sa[lrn]=sa[urn]=sa[drn]=sa[prn]=sa[frn]=sa[mrn]=sa[grn]=sa[Arn]=sa[hrn]=!1;nIt=Nrn});function xrn(e){return function(t){return e(t)}}var r2,sre=Q(()=>{r2=xrn});var iIt,Pq,Orn,zDe,wrn,sC,are=Q(()=>{UDe();iIt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Pq=iIt&&typeof module=="object"&&module&&!module.nodeType&&module,Orn=Pq&&Pq.exports===iIt,zDe=Orn&&$te.process,wrn=(function(){try{var e=Pq&&Pq.require&&Pq.require("util").types;return e||zDe&&zDe.binding&&zDe.binding("util")}catch{}})(),sC=wrn});var sIt,Mrn,cre,WDe=Q(()=>{oIt();sre();are();sIt=sC&&sC.isTypedArray,Mrn=sIt?r2(sIt):nIt,cre=Mrn});function Prn(e,t){var r=ia(e),n=!r&&t2(e),o=!r&&!n&&H1(e),i=!r&&!n&&!o&&cre(e),s=r||n||o||i,a=s?nre(e.length,String):[],c=a.length;for(var l in e)(t||krn.call(e,l))&&!(s&&(l=="length"||o&&(l=="offset"||l=="parent")||i&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||jL(l,c)))&&a.push(l);return a}var Brn,krn,lre,jDe=Q(()=>{YDe();ore();Pg();ire();Jte();WDe();Brn=Object.prototype,krn=Brn.hasOwnProperty;lre=Prn});function Lrn(e,t){return function(r){return e(t(r))}}var ure,KDe=Q(()=>{ure=Lrn});var Frn,aIt,cIt=Q(()=>{KDe();Frn=ure(Object.keys,Object),aIt=Frn});function Grn(e){if(!e2(e))return aIt(e);var t=[];for(var r in Object(e))Qrn.call(e,r)&&r!="constructor"&&t.push(r);return t}var Urn,Qrn,lIt,uIt=Q(()=>{rre();cIt();Urn=Object.prototype,Qrn=Urn.hasOwnProperty;lIt=Grn});function Hrn(e){return rR(e)?lre(e):lIt(e)}var Ah,q1=Q(()=>{jDe();uIt();kq();Ah=Hrn});function qrn(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var dIt,pIt=Q(()=>{dIt=qrn});function Vrn(e){if(!lf(e))return dIt(e);var t=e2(e),r=[];for(var n in e)n=="constructor"&&(t||!Yrn.call(e,n))||r.push(n);return r}var $rn,Yrn,fIt,mIt=Q(()=>{Xv();rre();pIt();$rn=Object.prototype,Yrn=$rn.hasOwnProperty;fIt=Vrn});function zrn(e){return rR(e)?lre(e,!0):fIt(e)}var n2,dre=Q(()=>{jDe();mIt();kq();n2=zrn});function Krn(e,t){if(ia(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||YL(e)?!0:jrn.test(e)||!Wrn.test(e)||t!=null&&e in Object(t)}var Wrn,jrn,o2,pre=Q(()=>{Pg();Yte();Wrn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,jrn=/^\w*$/;o2=Krn});var Jrn,aC,Lq=Q(()=>{eR();Jrn=Am(Object,"create"),aC=Jrn});function Zrn(){this.__data__=aC?aC(null):{},this.size=0}var gIt,AIt=Q(()=>{Lq();gIt=Zrn});function Xrn(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var hIt,_It=Q(()=>{hIt=Xrn});function nnn(e){var t=this.__data__;if(aC){var r=t[e];return r===enn?void 0:r}return rnn.call(t,e)?t[e]:void 0}var enn,tnn,rnn,EIt,SIt=Q(()=>{Lq();enn="__lodash_hash_undefined__",tnn=Object.prototype,rnn=tnn.hasOwnProperty;EIt=nnn});function snn(e){var t=this.__data__;return aC?t[e]!==void 0:inn.call(t,e)}var onn,inn,TIt,bIt=Q(()=>{Lq();onn=Object.prototype,inn=onn.hasOwnProperty;TIt=snn});function cnn(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=aC&&t===void 0?ann:t,this}var ann,yIt,CIt=Q(()=>{Lq();ann="__lodash_hash_undefined__";yIt=cnn});function i2(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}var JDe,IIt=Q(()=>{AIt();_It();SIt();bIt();CIt();i2.prototype.clear=gIt;i2.prototype.delete=hIt;i2.prototype.get=EIt;i2.prototype.has=TIt;i2.prototype.set=yIt;JDe=i2});function lnn(){this.__data__=[],this.size=0}var vIt,RIt=Q(()=>{vIt=lnn});function unn(e,t){for(var r=e.length;r--;)if(JL(e[r][0],t))return r;return-1}var nR,Fq=Q(()=>{Xte();nR=unn});function fnn(e){var t=this.__data__,r=nR(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():pnn.call(t,r,1),--this.size,!0}var dnn,pnn,DIt,NIt=Q(()=>{Fq();dnn=Array.prototype,pnn=dnn.splice;DIt=fnn});function mnn(e){var t=this.__data__,r=nR(t,e);return r<0?void 0:t[r][1]}var xIt,OIt=Q(()=>{Fq();xIt=mnn});function gnn(e){return nR(this.__data__,e)>-1}var wIt,MIt=Q(()=>{Fq();wIt=gnn});function Ann(e,t){var r=this.__data__,n=nR(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var BIt,kIt=Q(()=>{Fq();BIt=Ann});function s2(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}var oR,Uq=Q(()=>{RIt();NIt();OIt();MIt();kIt();s2.prototype.clear=vIt;s2.prototype.delete=DIt;s2.prototype.get=xIt;s2.prototype.has=wIt;s2.prototype.set=BIt;oR=s2});var hnn,iR,fre=Q(()=>{eR();vE();hnn=Am(Ll,"Map"),iR=hnn});function _nn(){this.size=0,this.__data__={hash:new JDe,map:new(iR||oR),string:new JDe}}var PIt,LIt=Q(()=>{IIt();Uq();fre();PIt=_nn});function Enn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var FIt,UIt=Q(()=>{FIt=Enn});function Snn(e,t){var r=e.__data__;return FIt(t)?r[typeof t=="string"?"string":"hash"]:r.map}var sR,Qq=Q(()=>{UIt();sR=Snn});function Tnn(e){var t=sR(this,e).delete(e);return this.size-=t?1:0,t}var QIt,GIt=Q(()=>{Qq();QIt=Tnn});function bnn(e){return sR(this,e).get(e)}var HIt,qIt=Q(()=>{Qq();HIt=bnn});function ynn(e){return sR(this,e).has(e)}var $It,YIt=Q(()=>{Qq();$It=ynn});function Cnn(e,t){var r=sR(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var VIt,zIt=Q(()=>{Qq();VIt=Cnn});function a2(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}var $1,mre=Q(()=>{LIt();GIt();qIt();YIt();zIt();a2.prototype.clear=PIt;a2.prototype.delete=QIt;a2.prototype.get=HIt;a2.prototype.has=$It;a2.prototype.set=VIt;$1=a2});function ZDe(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Inn);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=e.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(ZDe.Cache||$1),r}var Inn,ze,XDe=Q(()=>{mre();Inn="Expected a function";ZDe.Cache=$1;ze=ZDe});function Rnn(e){var t=ze(e,function(n){return r.size===vnn&&r.clear(),n}),r=t.cache;return t}var vnn,WIt,jIt=Q(()=>{XDe();vnn=500;WIt=Rnn});var Dnn,Nnn,xnn,KIt,JIt=Q(()=>{jIt();Dnn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Nnn=/\\(\\)?/g,xnn=WIt(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(Dnn,function(r,n,o,i){t.push(o?i.replace(Nnn,"$1"):n||r)}),t}),KIt=xnn});function Onn(e){return e==null?"":T0t(e)}var ZIt,XIt=Q(()=>{b0t();ZIt=Onn});function wnn(e,t){return ia(e)?e:o2(e,t)?[e]:KIt(ZIt(e))}var hh,Y1=Q(()=>{Pg();pre();JIt();XIt();hh=wnn});function Bnn(e){if(typeof e=="string"||YL(e))return e;var t=e+"";return t=="0"&&1/e==-Mnn?"-0":t}var Mnn,Lg,V1=Q(()=>{Yte();Mnn=1/0;Lg=Bnn});function knn(e,t){t=hh(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[Lg(t[r++])];return r&&r==n?e:void 0}var aR,Gq=Q(()=>{Y1();V1();aR=knn});function Pnn(e,t,r){var n=e==null?void 0:aR(e,t);return n===void 0?r:n}var evt,tvt=Q(()=>{Gq();evt=Pnn});function Lnn(e,t){for(var r=-1,n=t.length,o=e.length;++r<n;)e[o+r]=t[r];return e}var c2,gre=Q(()=>{c2=Lnn});function Fnn(e){return ia(e)||t2(e)||!!(rvt&&e&&e[rvt])}var rvt,nvt,ovt=Q(()=>{Q1();ore();Pg();rvt=qu?qu.isConcatSpreadable:void 0;nvt=Fnn});function ivt(e,t,r,n,o){var i=-1,s=e.length;for(r||(r=nvt),o||(o=[]);++i<s;){var a=e[i];t>0&&r(a)?t>1?ivt(a,t-1,r,n,o):c2(o,a):n||(o[o.length]=a)}return o}var svt,avt=Q(()=>{gre();ovt();svt=ivt});function Unn(e){var t=e==null?0:e.length;return t?svt(e,1):[]}var cvt,lvt=Q(()=>{avt();cvt=Unn});function Qnn(e){return Kte(ere(e,void 0,cvt),e+"")}var Are,eNe=Q(()=>{lvt();$De();qDe();Are=Qnn});var Gnn,l2,hre=Q(()=>{KDe();Gnn=ure(Object.getPrototypeOf,Object),l2=Gnn});function znn(e){if(!du(e)||kg(e)!=Hnn)return!1;var t=l2(e);if(t===null)return!0;var r=Ynn.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&uvt.call(r)==Vnn}var Hnn,qnn,$nn,uvt,Ynn,Vnn,dvt,pvt=Q(()=>{G1();hre();IT();Hnn="[object Object]",qnn=Function.prototype,$nn=Object.prototype,uvt=qnn.toString,Ynn=$nn.hasOwnProperty,Vnn=uvt.call(Object);dvt=znn});function Wnn(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),r=r>o?o:r,r<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}var fvt,mvt=Q(()=>{fvt=Wnn});function jnn(){this.__data__=new oR,this.size=0}var gvt,Avt=Q(()=>{Uq();gvt=jnn});function Knn(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var hvt,_vt=Q(()=>{hvt=Knn});function Jnn(e){return this.__data__.get(e)}var Evt,Svt=Q(()=>{Evt=Jnn});function Znn(e){return this.__data__.has(e)}var Tvt,bvt=Q(()=>{Tvt=Znn});function eon(e,t){var r=this.__data__;if(r instanceof oR){var n=r.__data__;if(!iR||n.length<Xnn-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new $1(n)}return r.set(e,t),this.size=r.size,this}var Xnn,yvt,Cvt=Q(()=>{Uq();fre();mre();Xnn=200;yvt=eon});function u2(e){var t=this.__data__=new oR(e);this.size=t.size}var cR,_re=Q(()=>{Uq();Avt();_vt();Svt();bvt();Cvt();u2.prototype.clear=gvt;u2.prototype.delete=hvt;u2.prototype.get=Evt;u2.prototype.has=Tvt;u2.prototype.set=yvt;cR=u2});function ton(e,t){return e&&RT(t,Ah(t),e)}var Ivt,vvt=Q(()=>{ZL();q1();Ivt=ton});function ron(e,t){return e&&RT(t,n2(t),e)}var Rvt,Dvt=Q(()=>{ZL();dre();Rvt=ron});function oon(e,t){if(t)return e.slice();var r=e.length,n=Ovt?Ovt(r):new e.constructor(r);return e.copy(n),n}var wvt,Nvt,non,xvt,Ovt,Mvt,Bvt=Q(()=>{vE();wvt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Nvt=wvt&&typeof module=="object"&&module&&!module.nodeType&&module,non=Nvt&&Nvt.exports===wvt,xvt=non?Ll.Buffer:void 0,Ovt=xvt?xvt.allocUnsafe:void 0;Mvt=oon});function ion(e,t){for(var r=-1,n=e==null?0:e.length,o=0,i=[];++r<n;){var s=e[r];t(s,r,e)&&(i[o++]=s)}return i}var Ere,tNe=Q(()=>{Ere=ion});function son(){return[]}var Sre,rNe=Q(()=>{Sre=son});var aon,con,kvt,lon,d2,Tre=Q(()=>{tNe();rNe();aon=Object.prototype,con=aon.propertyIsEnumerable,kvt=Object.getOwnPropertySymbols,lon=kvt?function(e){return e==null?[]:(e=Object(e),Ere(kvt(e),function(t){return con.call(e,t)}))}:Sre,d2=lon});function uon(e,t){return RT(e,d2(e),t)}var Pvt,Lvt=Q(()=>{ZL();Tre();Pvt=uon});var don,pon,bre,nNe=Q(()=>{gre();hre();Tre();rNe();don=Object.getOwnPropertySymbols,pon=don?function(e){for(var t=[];e;)c2(t,d2(e)),e=l2(e);return t}:Sre,bre=pon});function fon(e,t){return RT(e,bre(e),t)}var Fvt,Uvt=Q(()=>{ZL();nNe();Fvt=fon});function mon(e,t,r){var n=t(e);return ia(e)?n:c2(n,r(e))}var yre,oNe=Q(()=>{gre();Pg();yre=mon});function gon(e){return yre(e,Ah,d2)}var Hq,iNe=Q(()=>{oNe();Tre();q1();Hq=gon});function Aon(e){return yre(e,n2,bre)}var p2,Cre=Q(()=>{oNe();nNe();dre();p2=Aon});var hon,Ire,Qvt=Q(()=>{eR();vE();hon=Am(Ll,"DataView"),Ire=hon});var _on,vre,Gvt=Q(()=>{eR();vE();_on=Am(Ll,"Promise"),vre=_on});var Eon,Rre,Hvt=Q(()=>{eR();vE();Eon=Am(Ll,"Set"),Rre=Eon});var qvt,Son,$vt,Yvt,Vvt,zvt,Ton,bon,yon,Con,Ion,z1,cC,qq=Q(()=>{Qvt();fre();Gvt();Hvt();O0t();G1();GDe();qvt="[object Map]",Son="[object Object]",$vt="[object Promise]",Yvt="[object Set]",Vvt="[object WeakMap]",zvt="[object DataView]",Ton=iC(Ire),bon=iC(iR),yon=iC(vre),Con=iC(Rre),Ion=iC(jte),z1=kg;(Ire&&z1(new Ire(new ArrayBuffer(1)))!=zvt||iR&&z1(new iR)!=qvt||vre&&z1(vre.resolve())!=$vt||Rre&&z1(new Rre)!=Yvt||jte&&z1(new jte)!=Vvt)&&(z1=function(e){var t=kg(e),r=t==Son?e.constructor:void 0,n=r?iC(r):"";if(n)switch(n){case Ton:return zvt;case bon:return qvt;case yon:return $vt;case Con:return Yvt;case Ion:return Vvt}return t});cC=z1});function Don(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&Ron.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var von,Ron,Wvt,jvt=Q(()=>{von=Object.prototype,Ron=von.hasOwnProperty;Wvt=Don});var Non,f2,sNe=Q(()=>{vE();Non=Ll.Uint8Array,f2=Non});function xon(e){var t=new e.constructor(e.byteLength);return new f2(t).set(new f2(e)),t}var m2,Dre=Q(()=>{sNe();m2=xon});function Oon(e,t){var r=t?m2(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var Kvt,Jvt=Q(()=>{Dre();Kvt=Oon});function Mon(e){var t=new e.constructor(e.source,won.exec(e));return t.lastIndex=e.lastIndex,t}var won,Zvt,Xvt=Q(()=>{won=/\w*$/;Zvt=Mon});function Bon(e){return tRt?Object(tRt.call(e)):{}}var eRt,tRt,rRt,nRt=Q(()=>{Q1();eRt=qu?qu.prototype:void 0,tRt=eRt?eRt.valueOf:void 0;rRt=Bon});function kon(e,t){var r=t?m2(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var oRt,iRt=Q(()=>{Dre();oRt=kon});function tin(e,t,r){var n=e.constructor;switch(t){case $on:return m2(e);case Pon:case Lon:return new n(+e);case Yon:return Kvt(e,r);case Von:case zon:case Won:case jon:case Kon:case Jon:case Zon:case Xon:case ein:return oRt(e,r);case Fon:return new n;case Uon:case Hon:return new n(e);case Qon:return Zvt(e);case Gon:return new n;case qon:return rRt(e)}}var Pon,Lon,Fon,Uon,Qon,Gon,Hon,qon,$on,Yon,Von,zon,Won,jon,Kon,Jon,Zon,Xon,ein,sRt,aRt=Q(()=>{Dre();Jvt();Xvt();nRt();iRt();Pon="[object Boolean]",Lon="[object Date]",Fon="[object Map]",Uon="[object Number]",Qon="[object RegExp]",Gon="[object Set]",Hon="[object String]",qon="[object Symbol]",$on="[object ArrayBuffer]",Yon="[object DataView]",Von="[object Float32Array]",zon="[object Float64Array]",Won="[object Int8Array]",jon="[object Int16Array]",Kon="[object Int32Array]",Jon="[object Uint8Array]",Zon="[object Uint8ClampedArray]",Xon="[object Uint16Array]",ein="[object Uint32Array]";sRt=tin});function rin(e){return typeof e.constructor=="function"&&!e2(e)?M0t(l2(e)):{}}var cRt,lRt=Q(()=>{B0t();hre();rre();cRt=rin});function oin(e){return du(e)&&cC(e)==nin}var nin,uRt,dRt=Q(()=>{qq();IT();nin="[object Map]";uRt=oin});var pRt,iin,fRt,mRt=Q(()=>{dRt();sre();are();pRt=sC&&sC.isMap,iin=pRt?r2(pRt):uRt,fRt=iin});function ain(e){return du(e)&&cC(e)==sin}var sin,gRt,ARt=Q(()=>{qq();IT();sin="[object Set]";gRt=ain});var hRt,cin,_Rt,ERt=Q(()=>{ARt();sre();are();hRt=sC&&sC.isSet,cin=hRt?r2(hRt):gRt,_Rt=cin});function Nre(e,t,r,n,o,i){var s,a=t&lin,c=t&uin,l=t&din;if(r&&(s=o?r(e,n,o,i):r(e)),s!==void 0)return s;if(!lf(e))return e;var u=ia(e);if(u){if(s=Wvt(e),!a)return L0t(e,s)}else{var d=cC(e),p=d==TRt||d==Ain;if(H1(e))return Mvt(e,a);if(d==bRt||d==SRt||p&&!o){if(s=c||p?{}:cRt(e),!a)return c?Fvt(e,Rvt(s,e)):Pvt(e,Ivt(s,e))}else{if(!Vs[d])return o?e:{};s=sRt(e,d,a)}}i||(i=new cR);var f=i.get(e);if(f)return f;i.set(e,s),_Rt(e)?e.forEach(function(_){s.add(Nre(_,t,r,_,e,i))}):fRt(e)&&e.forEach(function(_,T){s.set(T,Nre(_,t,r,T,e,i))});var A=l?c?p2:Hq:c?n2:Ah,h=u?void 0:A(e);return Y0t(h||e,function(_,T){h&&(T=_,_=e[T]),tR(s,T,Nre(_,t,r,T,e,i))}),s}var lin,uin,din,SRt,pin,fin,min,gin,TRt,Ain,hin,_in,bRt,Ein,Sin,Tin,bin,yin,Cin,Iin,vin,Rin,Din,Nin,xin,Oin,win,Min,Bin,Vs,xre,aNe=Q(()=>{_re();V0t();Bq();vvt();Dvt();Bvt();F0t();Lvt();Uvt();iNe();Cre();qq();jvt();aRt();lRt();Pg();ire();mRt();Xv();ERt();q1();dre();lin=1,uin=2,din=4,SRt="[object Arguments]",pin="[object Array]",fin="[object Boolean]",min="[object Date]",gin="[object Error]",TRt="[object Function]",Ain="[object GeneratorFunction]",hin="[object Map]",_in="[object Number]",bRt="[object Object]",Ein="[object RegExp]",Sin="[object Set]",Tin="[object String]",bin="[object Symbol]",yin="[object WeakMap]",Cin="[object ArrayBuffer]",Iin="[object DataView]",vin="[object Float32Array]",Rin="[object Float64Array]",Din="[object Int8Array]",Nin="[object Int16Array]",xin="[object Int32Array]",Oin="[object Uint8Array]",win="[object Uint8ClampedArray]",Min="[object Uint16Array]",Bin="[object Uint32Array]",Vs={};Vs[SRt]=Vs[pin]=Vs[Cin]=Vs[Iin]=Vs[fin]=Vs[min]=Vs[vin]=Vs[Rin]=Vs[Din]=Vs[Nin]=Vs[xin]=Vs[hin]=Vs[_in]=Vs[bRt]=Vs[Ein]=Vs[Sin]=Vs[Tin]=Vs[bin]=Vs[Oin]=Vs[win]=Vs[Min]=Vs[Bin]=!0;Vs[gin]=Vs[TRt]=Vs[yin]=!1;xre=Nre});function Lin(e){return xre(e,kin|Pin)}var kin,Pin,W1,yRt=Q(()=>{aNe();kin=1,Pin=4;W1=Lin});function Uin(e){return this.__data__.set(e,Fin),this}var Fin,CRt,IRt=Q(()=>{Fin="__lodash_hash_undefined__";CRt=Uin});function Qin(e){return this.__data__.has(e)}var vRt,RRt=Q(()=>{vRt=Qin});function Ore(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new $1;++t<r;)this.add(e[t])}var DRt,NRt=Q(()=>{mre();IRt();RRt();Ore.prototype.add=Ore.prototype.push=CRt;Ore.prototype.has=vRt;DRt=Ore});function Gin(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var xRt,ORt=Q(()=>{xRt=Gin});function Hin(e,t){return e.has(t)}var wRt,MRt=Q(()=>{wRt=Hin});function Yin(e,t,r,n,o,i){var s=r&qin,a=e.length,c=t.length;if(a!=c&&!(s&&c>a))return!1;var l=i.get(e),u=i.get(t);if(l&&u)return l==t&&u==e;var d=-1,p=!0,f=r&$in?new DRt:void 0;for(i.set(e,t),i.set(t,e);++d<a;){var A=e[d],h=t[d];if(n)var _=s?n(h,A,d,t,e,i):n(A,h,d,e,t,i);if(_!==void 0){if(_)continue;p=!1;break}if(f){if(!xRt(t,function(T,y){if(!wRt(f,y)&&(A===T||o(A,T,r,n,i)))return f.push(y)})){p=!1;break}}else if(!(A===h||o(A,h,r,n,i))){p=!1;break}}return i.delete(e),i.delete(t),p}var qin,$in,wre,cNe=Q(()=>{NRt();ORt();MRt();qin=1,$in=2;wre=Yin});function Vin(e){var t=-1,r=Array(e.size);return e.forEach(function(n,o){r[++t]=[o,n]}),r}var BRt,kRt=Q(()=>{BRt=Vin});function zin(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var PRt,LRt=Q(()=>{PRt=zin});function asn(e,t,r,n,o,i,s){switch(r){case ssn:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case isn:return!(e.byteLength!=t.byteLength||!i(new f2(e),new f2(t)));case Kin:case Jin:case esn:return JL(+e,+t);case Zin:return e.name==t.name&&e.message==t.message;case tsn:case nsn:return e==t+"";case Xin:var a=BRt;case rsn:var c=n&Win;if(a||(a=PRt),e.size!=t.size&&!c)return!1;var l=s.get(e);if(l)return l==t;n|=jin,s.set(e,t);var u=wre(a(e),a(t),n,o,i,s);return s.delete(e),u;case osn:if(lNe)return lNe.call(e)==lNe.call(t)}return!1}var Win,jin,Kin,Jin,Zin,Xin,esn,tsn,rsn,nsn,osn,isn,ssn,FRt,lNe,URt,QRt=Q(()=>{Q1();sNe();Xte();cNe();kRt();LRt();Win=1,jin=2,Kin="[object Boolean]",Jin="[object Date]",Zin="[object Error]",Xin="[object Map]",esn="[object Number]",tsn="[object RegExp]",rsn="[object Set]",nsn="[object String]",osn="[object Symbol]",isn="[object ArrayBuffer]",ssn="[object DataView]",FRt=qu?qu.prototype:void 0,lNe=FRt?FRt.valueOf:void 0;URt=asn});function dsn(e,t,r,n,o,i){var s=r&csn,a=Hq(e),c=a.length,l=Hq(t),u=l.length;if(c!=u&&!s)return!1;for(var d=c;d--;){var p=a[d];if(!(s?p in t:usn.call(t,p)))return!1}var f=i.get(e),A=i.get(t);if(f&&A)return f==t&&A==e;var h=!0;i.set(e,t),i.set(t,e);for(var _=s;++d<c;){p=a[d];var T=e[p],y=t[p];if(n)var I=s?n(y,T,p,t,e,i):n(T,y,p,e,t,i);if(!(I===void 0?T===y||o(T,y,r,n,i):I)){h=!1;break}_||(_=p=="constructor")}if(h&&!_){var v=e.constructor,x=t.constructor;v!=x&&"constructor"in e&&"constructor"in t&&!(typeof v=="function"&&v instanceof v&&typeof x=="function"&&x instanceof x)&&(h=!1)}return i.delete(e),i.delete(t),h}var csn,lsn,usn,GRt,HRt=Q(()=>{iNe();csn=1,lsn=Object.prototype,usn=lsn.hasOwnProperty;GRt=dsn});function msn(e,t,r,n,o,i){var s=ia(e),a=ia(t),c=s?$Rt:cC(e),l=a?$Rt:cC(t);c=c==qRt?Mre:c,l=l==qRt?Mre:l;var u=c==Mre,d=l==Mre,p=c==l;if(p&&H1(e)){if(!H1(t))return!1;s=!0,u=!1}if(p&&!u)return i||(i=new cR),s||cre(e)?wre(e,t,r,n,o,i):URt(e,t,c,r,n,o,i);if(!(r&psn)){var f=u&&YRt.call(e,"__wrapped__"),A=d&&YRt.call(t,"__wrapped__");if(f||A){var h=f?e.value():e,_=A?t.value():t;return i||(i=new cR),o(h,_,r,n,i)}}return p?(i||(i=new cR),GRt(e,t,r,n,o,i)):!1}var psn,qRt,$Rt,Mre,fsn,YRt,VRt,zRt=Q(()=>{_re();cNe();QRt();HRt();qq();Pg();ire();WDe();psn=1,qRt="[object Arguments]",$Rt="[object Array]",Mre="[object Object]",fsn=Object.prototype,YRt=fsn.hasOwnProperty;VRt=msn});function WRt(e,t,r,n,o){return e===t?!0:e==null||t==null||!du(e)&&!du(t)?e!==e&&t!==t:VRt(e,t,r,n,WRt,o)}var g2,Bre=Q(()=>{zRt();IT();g2=WRt});function hsn(e,t,r,n){var o=r.length,i=o,s=!n;if(e==null)return!i;for(e=Object(e);o--;){var a=r[o];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++o<i;){a=r[o];var c=a[0],l=e[c],u=a[1];if(s&&a[2]){if(l===void 0&&!(c in e))return!1}else{var d=new cR;if(n)var p=n(l,u,c,e,t,d);if(!(p===void 0?g2(u,l,gsn|Asn,n,d):p))return!1}}return!0}var gsn,Asn,jRt,KRt=Q(()=>{_re();Bre();gsn=1,Asn=2;jRt=hsn});function _sn(e){return e===e&&!lf(e)}var kre,uNe=Q(()=>{Xv();kre=_sn});function Esn(e){for(var t=Ah(e),r=t.length;r--;){var n=t[r],o=e[n];t[r]=[n,o,kre(o)]}return t}var JRt,ZRt=Q(()=>{uNe();q1();JRt=Esn});function Ssn(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}var Pre,dNe=Q(()=>{Pre=Ssn});function Tsn(e){var t=JRt(e);return t.length==1&&t[0][2]?Pre(t[0][0],t[0][1]):function(r){return r===e||jRt(r,e,t)}}var XRt,eDt=Q(()=>{KRt();ZRt();dNe();XRt=Tsn});function bsn(e,t){return e!=null&&t in Object(e)}var tDt,rDt=Q(()=>{tDt=bsn});function ysn(e,t,r){t=hh(t,e);for(var n=-1,o=t.length,i=!1;++n<o;){var s=Lg(t[n]);if(!(i=e!=null&&r(e,s)))break;e=e[s]}return i||++n!=o?i:(o=e==null?0:e.length,!!o&&XL(o)&&jL(s,o)&&(ia(e)||t2(e)))}var nDt,oDt=Q(()=>{Y1();ore();Pg();Jte();tre();V1();nDt=ysn});function Csn(e,t){return e!=null&&nDt(e,t,tDt)}var Lre,pNe=Q(()=>{rDt();oDt();Lre=Csn});function Rsn(e,t){return o2(e)&&kre(t)?Pre(Lg(e),t):function(r){var n=evt(r,e);return n===void 0&&n===t?Lre(r,e):g2(t,n,Isn|vsn)}}var Isn,vsn,iDt,sDt=Q(()=>{Bre();tvt();pNe();pre();uNe();dNe();V1();Isn=1,vsn=2;iDt=Rsn});function Dsn(e){return function(t){return t?.[e]}}var Fre,fNe=Q(()=>{Fre=Dsn});function Nsn(e){return function(t){return aR(t,e)}}var aDt,cDt=Q(()=>{Gq();aDt=Nsn});function xsn(e){return o2(e)?Fre(Lg(e)):aDt(e)}var lDt,uDt=Q(()=>{fNe();cDt();pre();V1();lDt=xsn});function Osn(e){return typeof e=="function"?e:e==null?zL:typeof e=="object"?ia(e)?iDt(e[0],e[1]):XRt(e):lDt(e)}var A2,Ure=Q(()=>{eDt();sDt();Vte();Pg();uDt();A2=Osn});function wsn(e,t,r,n){for(var o=-1,i=e==null?0:e.length;++o<i;){var s=e[o];t(n,s,r(s),e)}return n}var dDt,pDt=Q(()=>{dDt=wsn});function Msn(e){return function(t,r,n){for(var o=-1,i=Object(t),s=n(t),a=s.length;a--;){var c=s[e?a:++o];if(r(i[c],c,i)===!1)break}return t}}var fDt,mDt=Q(()=>{fDt=Msn});var Bsn,gDt,ADt=Q(()=>{mDt();Bsn=fDt(),gDt=Bsn});function ksn(e,t){return e&&gDt(e,t,Ah)}var Qre,mNe=Q(()=>{ADt();q1();Qre=ksn});function Psn(e,t){return function(r,n){if(r==null)return r;if(!rR(r))return e(r,n);for(var o=r.length,i=t?o:-1,s=Object(r);(t?i--:++i<o)&&n(s[i],i,s)!==!1;);return r}}var hDt,_Dt=Q(()=>{kq();hDt=Psn});var Lsn,EDt,SDt=Q(()=>{mNe();_Dt();Lsn=hDt(Qre),EDt=Lsn});function Fsn(e,t,r,n){return EDt(e,function(o,i,s){t(n,o,r(o),s)}),n}var TDt,bDt=Q(()=>{SDt();TDt=Fsn});function Usn(e,t){return function(r,n){var o=ia(r)?dDt:TDt,i=t?t():{};return o(r,e,A2(n,2),i)}}var yDt,CDt=Q(()=>{pDt();bDt();Ure();Pg();yDt=Usn});function Qsn(e){return du(e)&&rR(e)}var IDt,vDt=Q(()=>{kq();IT();IDt=Qsn});function Gsn(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var gp,gNe=Q(()=>{gp=Gsn});function Hsn(e,t){return vT(t,function(r){return e[r]})}var RDt,DDt=Q(()=>{VL();RDt=Hsn});function qsn(e){return e==null?[]:RDt(e,Ah(e))}var NDt,xDt=Q(()=>{DDt();q1();NDt=qsn});function $sn(e,t){return t.length<2?e:aR(e,fvt(t,0,-1))}var ODt,wDt=Q(()=>{Gq();mvt();ODt=$sn});function Ysn(e,t){return g2(e,t)}var ANe,MDt=Q(()=>{Bre();ANe=Ysn});function Vsn(e,t){var r={};return t=A2(t,3),Qre(e,function(n,o,i){KL(r,o,t(n,o,i))}),r}var Gre,BDt=Q(()=>{Zte();mNe();Ure();Gre=Vsn});function jsn(e,t){t=hh(t,e);var r=-1,n=t.length;if(!n)return!0;for(;++r<n;){var o=Lg(t[r]);if(o==="__proto__"&&!Wsn.call(e,"__proto__")||(o==="constructor"||o==="prototype")&&r<n-1)return!1}var i=ODt(e,t);return i==null||delete i[Lg(gp(t))]}var zsn,Wsn,kDt,PDt=Q(()=>{Y1();gNe();wDt();V1();zsn=Object.prototype,Wsn=zsn.hasOwnProperty;kDt=jsn});function Ksn(e){return dvt(e)?void 0:e}var LDt,FDt=Q(()=>{pvt();LDt=Ksn});var Jsn,Zsn,Xsn,ean,j1,UDt=Q(()=>{VL();aNe();PDt();Y1();ZL();FDt();eNe();Cre();Jsn=1,Zsn=2,Xsn=4,ean=Are(function(e,t){var r={};if(e==null)return r;var n=!1;t=vT(t,function(i){return i=hh(i,e),n||(n=i.length>1),i}),RT(e,p2(e),r),n&&(r=xre(r,Jsn|Zsn|Xsn,LDt));for(var o=t.length;o--;)kDt(r,t[o]);return r}),j1=ean});function tan(e,t,r,n){if(!lf(e))return e;t=hh(t,e);for(var o=-1,i=t.length,s=i-1,a=e;a!=null&&++o<i;){var c=Lg(t[o]),l=r;if(c==="__proto__"||c==="constructor"||c==="prototype")return e;if(o!=s){var u=a[c];l=n?n(u,c,a):void 0,l===void 0&&(l=lf(u)?u:jL(t[o+1])?[]:{})}tR(a,c,l),a=a[c]}return e}var QDt,GDt=Q(()=>{Bq();Y1();Jte();Xv();V1();QDt=tan});function ran(e,t,r){for(var n=-1,o=t.length,i={};++n<o;){var s=t[n],a=aR(e,s);r(a,s)&&QDt(i,hh(s,e),a)}return i}var Hre,hNe=Q(()=>{Gq();GDt();Y1();Hre=ran});function nan(e,t){if(e==null)return{};var r=vT(p2(e),function(n){return[n]});return t=A2(t),Hre(e,r,function(n,o){return t(n,o[0])})}var qre,HDt=Q(()=>{VL();Ure();hNe();Cre();qre=nan});var oan,_Ne,qDt=Q(()=>{CDt();oan=yDt(function(e,t,r){e[r?0:1].push(t)},function(){return[[],[]]}),_Ne=oan});function ian(e,t){return Hre(e,t,function(r,n){return Lre(e,n)})}var $Dt,YDt=Q(()=>{hNe();pNe();$Dt=ian});var san,$re,VDt=Q(()=>{YDt();eNe();san=Are(function(e,t){return e==null?{}:$Dt(e,t)}),$re=san});function lan(e,t){return e+aan(can()*(t-e+1))}var aan,can,zDt,WDt=Q(()=>{aan=Math.floor,can=Math.random;zDt=lan});function uan(e){var t=e.length;return t?e[zDt(0,t-1)]:void 0}var Yre,ENe=Q(()=>{WDt();Yre=uan});function dan(e){return Yre(NDt(e))}var jDt,KDt=Q(()=>{ENe();xDt();jDt=dan});function pan(e){var t=ia(e)?Yre:jDt;return t(e)}var K1,JDt=Q(()=>{ENe();KDt();Pg();K1=pan});function man(e){if(!(e&&e.length))return[];var t=0;return e=Ere(e,function(r){if(IDt(r))return t=fan(r.length,t),!0}),nre(t,function(r){return vT(e,Fre(r))})}var fan,ZDt,XDt=Q(()=>{tNe();VL();fNe();YDe();vDt();fan=Math.max;ZDt=man});var gan,SNe,eNt=Q(()=>{j0t();XDt();gan=W0t(ZDt),SNe=gan});function Aan(e,t,r){for(var n=-1,o=e.length,i=t.length,s={};++n<o;){var a=n<i?t[n]:void 0;r(s,e[n],a)}return s}var tNt,rNt=Q(()=>{tNt=Aan});function han(e,t){return tNt(e||[],t||[],tR)}var TNe,nNt=Q(()=>{Bq();rNt();TNe=han});var hr=Q(()=>{yRt();MDt();gNe();BDt();XDe();UDt();qDt();VDt();HDt();JDt();eNt();nNt();});function Wq(){return process.platform!=="win32"?!1:process.env.HAWA_CODE_POWER_SHELL_ENABLE==="true"||process.env.HAWA_CODE_POWER_SHELL_ENABLE==="1"?!0:!(process.env.HAWA_CODE_POWER_SHELL_ENABLE==="false"||process.env.HAWA_CODE_POWER_SHELL_ENABLE==="0"||process.env[jre])}var Je,$q,Vre,oNt,_i,Gi,lo,zre,Wre,RE,iNt,Yq,jre,hm,J1,DE,Vq,NE,Kre,sNt,Ap,lC,Di,cl,rs,aa,ca,en,uf,Jre,h2,Zre,Xre,lR,aNt,ene,uC,_2,tne,DT,Fg,df,_m,pf,ff,_h,cNt,lNt,uNt,_an,Ean,Z1,zq,Eh,dNt,pNt,fNt,mNt,gNt,uR,E2,NT,He=Q(()=>{Je="Hawa Code",$q="Dahawa",Vre="https://www.hawacode.com",oNt="https://github.com/italking/hawa-code/issues",_i="HAWA.md",Gi="hcode",lo=".hcode",zre="HAWA_CODE_GIT_BASH_PATH",Wre="*-* ",RE="Backgrounded agent",iNt="ANTHROPIC_AUTH_TOKEN",Yq="HAWA_CODE_FIX_SCHEMA",jre="HAWA_CODE_GIT_BASH_PATH",hm="LOADED_TOOLS",J1="SELECTION_CHANGED",DE="CONTEXT_MAIN_STOP_TIMES",Vq="allowedTools",NE="tast:completed",Kre="query:suggestion",sNt="WebSearch",Ap="Bash",lC="PowerShell",Di="Read",cl="Write",rs="Edit",aa="Glob",ca="Grep",en="Agent",uf="TodoWrite",Jre="AskUserQuestion",h2="NotebookEdit",Zre="EnterPlanMode",Xre="ExitPlanMode",lR="Skill",aNt="SlashCommand",ene="Think",uC="WebFetch",_2="TaskOutput",tne="TaskStop",DT="ToolLoader",Fg="ToolUnLoader",df="TaskCreate",_m="TaskGet",pf="TaskList",ff="TaskUpdate",_h=Wq()?lC:Ap,cNt="CronCreate",lNt="CronDelete",uNt="CronList",_an="EnterWorktreeTool",Ean="ExitWorktreeTool",Z1="TeamCreate",zq="TeamDelete",Eh="SendMessage",dNt="Sleep",pNt="ToolSearch",fNt="ListMcpResources",mNt="ReadMcpResource",gNt="classify_result",uR="team-lead",E2=[Z1,zq,_an,Ean],NT=[DT,Fg,uf,lR,df,ff,pf]});import{randomUUID as San}from"crypto";function dC(e){return e.type==="compact_boundary"}function S2(e,t,r,n,o){return{type:"compact_boundary",uuid:San(),timestamp:new Date().toISOString(),content:"Conversation compacted",level:"info",compactMetadata:{trigger:e,preTokens:t,...n!==void 0?{userContext:n}:{},...o!==void 0?{messagesSummarized:o}:{}},...r?{logicalParentUuid:r}:{}}}function dR(e){return[e.boundaryMarker,e.summaryMessage]}function ANt(e){let t=-1;for(let r=e.length-1;r>=0;r--)if(dC(e[r])){t=r;break}return t===-1?e:e.slice(t+1)}function rne(e){return e.length===0?void 0:e[e.length-1].uuid}var X1=Q(()=>{});var bNe,Nr,va=Q(()=>{Be();bNe=class{listeners=new Map;registry=new FinalizationRegistry(t=>{for(let[r,n]of this.listeners.entries()){for(let o of Array.from(n))o.token===t&&n.delete(o);n.size===0&&this.listeners.delete(r)}});on(t,r,n){let o=this.listeners.get(t);o||(o=new Set,this.listeners.set(t,o));let i={callback:r,thisRef:n?new WeakRef(n):void 0};if(n){let s={};i.token=s,this.registry.register(n,s,s)}return o.add(i),()=>{this.off(t,r,n)}}off(t,r,n){let o=this.listeners.get(t);if(o){if(!r&&n===void 0){for(let i of o)i.token&&this.registry.unregister(i.token);this.listeners.delete(t);return}for(let i of Array.from(o)){let s=r?i.callback===r:!0,a=!0;n!==void 0&&(a=i.thisRef?.deref()===n),s&&a&&(i.token&&this.registry.unregister(i.token),o.delete(i))}o.size===0&&this.listeners.delete(t)}}emit(t,r){let n=this.listeners.get(t);if(n)for(let o of Array.from(n)){let i;if(o.thisRef&&(i=o.thisRef.deref(),!i)){n.delete(o);continue}try{let s=o.callback.call(i,r);s instanceof Promise&&s.catch(a=>{he(`Async error in listener for "${t}"`,a)})}catch(s){he(`Error in listener for "${t}"`,s)}}}},Nr=new bNe});var CNe={};ra(CNe,{HawaSessionContext:()=>one,InQueryContext:()=>T2,appendAllowedTools:()=>b2,hawaContext:()=>Ye});import{randomUUID as Tan}from"crypto";function b2(e,t){if(e&&e.length>0){let r=Ye.getQueryContext(t)[Vq];r||(r=[]),Ye.getQueryContext(t)[Vq]=[...r,...e]}}var nne,T2,hNt,one,yNe,Ye,Zo=Q(()=>{He();va();nne=class{datas={};setData(t,r){this.datas[t]=r}getData(t){return this.datas[t]}takeData(t){let r=this.datas[t];return delete this.datas[t],r}clear(){this.datas={}}},T2=class extends nne{startTime;constructor(t=null){super(),this.startTime=t}},hNt=Tan(),one=class extends nne{PENDING_PROMPTS_KEY="pendingPrompts";addPendingPrompt(t){let r=this.getPendingPrompts();r.push(t),this.setData(this.PENDING_PROMPTS_KEY,r)}getPendingPrompts(){let t=this.getData(this.PENDING_PROMPTS_KEY);return Array.isArray(t)?t:[]}takePendingPrompts(){let t=this.getPendingPrompts();return this.setData(this.PENDING_PROMPTS_KEY,[]),t}async waitGetPendingPrompts(t){let n=Date.now(),o=t*1e3;for(;Date.now()-n<o;){let i=this.getPendingPrompts();if(i.length>0)return i;await new Promise(s=>setTimeout(s,200))}return[]}getSessionId(){return hNt}switchSessionId(t){hNt=t}},yNe=class e{static sessionContext={};static inQueryContextHolder={};static queryContext={};onQueryStart(t="defalt",r){t||(t="defalt");let n=e.inQueryContextHolder[t+""];n&&n.startTime&&n.startTime>0||(e.inQueryContextHolder[t+""]=new T2(Date.now()),Nr.emit("webserver:agent_status",{agentId:t,status:"started",agentType:r?.agentType,agentName:r?.agentName,description:r?.description,timestamp:Date.now()}))}onQueryEnd(t="defalt",r=!1){t||(t="defalt"),e.inQueryContextHolder[t+""]=new T2(-1),r||(e.queryContext[t+""]={}),Nr.emit("webserver:agent_status",{agentId:t,status:"ended",timestamp:Date.now()})}getSessionContext(t="defalt"){t||(t="defalt");let r=e.sessionContext[t+""];return r||(r=new one,e.sessionContext[t+""]=r),r}getInQueryContext(t="defalt"){t||(t="defalt");let r=e.inQueryContextHolder[t+""];return r||(r=new T2,e.inQueryContextHolder[t+""]=r),r}getQueryContext(t="defalt"){t||(t="defalt");let r=e.queryContext[t+""];return r||(r={},e.queryContext[t+""]=r),r}isQuerying(t="defalt"){return t||(t="defalt"),this.getInQueryContext(t).startTime>0}},Ye=new yNe});var xNt={};ra(xNt,{CACHE_PATHS:()=>oo,SESSION_ID:()=>xE,dateToFilename:()=>CNt,debug:()=>qt,error:()=>he,event:()=>Me,formatDate:()=>R2,getCurrentSessionMessagePath:()=>ul,getErrorsLog:()=>Nan,getInMemoryErrors:()=>xan,getPersistedMessageIds:()=>yNt,loadLog:()=>eO,loadLogFromFile:()=>wan,loadLogList:()=>tO,loadMessages:()=>C2,loadMessagesFromFile:()=>NNt,log:()=>be,logAPI:()=>lne,logAPIFull:()=>cne,logError:()=>Re,logMCPError:()=>fR,parseISOString:()=>ine,parseLogFilename:()=>une,resetPersistedIdsCache:()=>Ian,sortLogs:()=>DNt,writeCurrentSessionMessages:()=>Qg});import{existsSync as Ug,mkdirSync as INe}from"fs";import{dirname as vNe,join as ll}from"path";import{writeFileSync as sne,readFileSync as SNt,appendFileSync as TNt}from"fs";import{randomUUID as ban}from"crypto";import{promises as y2}from"fs";import{homedir as yan}from"os";import*as bNt from"os";function yNt(e){if(!jq.has(e)){let t=new Set;if(Ug(e))try{SNt(e,"utf8").split(`
19
19
  `).filter(n=>n.trim()).forEach(n=>{try{let o=JSON.parse(n);o.uuid&&t.add(o.uuid)}catch{}})}catch{}jq.set(e,t)}return jq.get(e)}function Ian(e){e?jq.delete(e):jq.clear()}function pR(e){return e.replace(/[^a-zA-Z0-9]/g,"-")}function ane(){return Ye.getSessionContext().getSessionId()||I2}function CNt(e){return e.toISOString().replace(/[:.]/g,"-")}function van(){return ll(oo.errors(),I2+".txt")}function INt(){return ll(oo.log(),I2+".log")}function Ran(){return ll(oo.log(),"event-"+I2+".log")}function Dan(){return ll(oo.log(),"error-"+I2+".log")}function vNt(e,t){let r=t?`-${t}`:"",n=e?"-full":"";return ll(oo.apis(),ane(),"api-"+r+n+".log")}function ul(e){return e?ll(oo.messages(),ane(),"subagents",`agent-${e}.jsonl`):ll(oo.messages(),ane()+".jsonl")}function v2(e,t,...r){let n=r.map(o=>o instanceof Error?`${o.name}: ${o.message}
20
20
  ${o.stack.replace(/^/gm," ")}`:o);Oan(t,{level:e,message:n.length==1?n[0]:n})}function cne(e="default",...t){process.env.USER_TYPE_HAVA_CODE==="DAHAWA_DEBUG"&&v2("info",vNt(!0,e),...t)}function lne(e="default",...t){process.env.USER_TYPE_HAVA_CODE==="DAHAWA_DEBUG"&&v2("info",vNt(!1,e),...t)}function be(...e){v2("info",INt(),...e)}function he(...e){v2("error",Dan(),...e)}function qt(...e){v2("debug",INt(),...e)}function Me(...e){v2("debug",Ran(),...e)}function Re(...e){he(...e)}function Nan(){return RNt(van())}function xan(){return[...Can]}function RNt(e){if(!Ug(e))return[];try{return SNt(e,"utf8").split(`
21
21
  `).filter(r=>r.trim()).map(r=>{try{return JSON.parse(r)}catch{return null}}).filter(r=>r!==null)}catch{return[]}}function Oan(e,t){let r=vNe(e);Ug(r)||INe(r,{recursive:!0});let o=(typeof t=="string"?t:JSON.stringify(t))+`
@@ -368,7 +368,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
368
368
  `);i&&(o+=i+`
369
369
  `)}o.trim().length!=0&&await Bc.appendFile(n,o,"utf8")}getTaskOutputFile(t){return ls.join(Ud,`agent_${t}_output`)}filterTaskOutput(t){return t&&t.split(`
370
370
  `).filter(o=>{let i=o.trim();return!/^\[Tool \w+\]/.test(i)}).join(`
371
- `)}async getTaskOutput(t,r=!0){let n=this.getTaskOutputFile(t);try{if(Wl(n)){let o=await Bc.readFile(n,"utf8");return r?this.filterTaskOutput(o):o}return null}catch(o){return he(`Failed to get task output for task ${t}:`,o),null}finally{let o=await this.getTaskStatus(t);(o==="completed"||o==="status")&&this.removeTaskFromNotificationQueue(t)}}async saveTaskError(t,r){let n=ls.join(Ud,`agent_${t}_error`);await Bc.mkdir(Ud,{recursive:!0});try{let o=typeof r=="string"?r:r instanceof Error?r.stack||r.message:JSON.stringify(r);await Bc.writeFile(n,o,"utf8")}catch(o){throw he(`Failed to save task error for task ${t}:`,o),o}}async getTaskError(t){let r=ls.join(Ud,`agent_${t}_error`);try{return Wl(r)?(await Bc.readFile(r,"utf8")).trim():null}catch(n){return he(`Failed to get task error for task ${t}:`,n),null}}async cleanupTask(t){let r=ls.join(Ud,`agent_${t}_state`),n=ls.join(Ud,`agent_${t}_output`),o=ls.join(Ud,`agent_${t}_error`);try{Wl(r)&&await Bc.unlink(r),Wl(n)&&await Bc.unlink(n),Wl(o)&&await Bc.unlink(o)}catch(i){he(`Failed to cleanup task files for task ${t}:`,i)}}async waitTaskEnd(t,r=0,n){let o=Date.now(),i=!1,s=null,a=null;n&&(s=new Promise((c,l)=>{let u=()=>{a&&a(),l(new Error("Operation aborted"))};n.addEventListener("abort",u),a=()=>{n.removeEventListener("abort",u)},i=!0}));try{for(;;){if(n?.aborted)return!1;let c=await this.getTaskStatus(t);if(c==="completed"||c==="failed")return!0;if(r>0&&Date.now()-o>=r)return!1;let l=new Promise(u=>setTimeout(u,100));try{s?await Promise.race([l,s]):await l}catch(u){if(u instanceof Error&&u.message==="Operation aborted")return!1;throw u}}}finally{i&&a&&a()}}async taskExists(t){let r=ls.join(Ud,`agent_${t}_state`);return Wl(r)}async saveTaskConfig(t,r){let n=ls.join(Ud,`agent_${t}_config`);await Bc.mkdir(Ud,{recursive:!0});try{let o=JSON.stringify(r);await Bc.writeFile(n,o,"utf8")}catch(o){throw he(`Failed to save task config for task ${t}:`,o),o}}async getTaskConfig(t){let r=ls.join(Ud,`agent_${t}_config`);try{if(Wl(r)){let n=await Bc.readFile(r,"utf8"),o=JSON.parse(n);return{isBackGround:o.isBackGround||!1,isTeamMember:o.isTeamMember||!1}}return null}catch(n){return he(`Failed to get task config for task ${t}:`,n),null}}async onTaskCompleted(t){if(t.runInBackgroud&&!t.isStoped()&&!t.isTeamMember){let r=t.parentId||"default";this.backgroundNotificationQueue.has(r)||this.backgroundNotificationQueue.set(r,[]),this.backgroundNotificationQueue.get(r).push(t)}t.parentId&&Nr.emit(NE)}async takeNotificationMessages(t="default"){let r=[],n=this.backgroundNotificationQueue.get(t);if(!n||n.length===0)return null;for(let o of n)r.push({type:"text",text:`<task-notification>
371
+ `)}async getTaskOutput(t,r=!0){let n=this.getTaskOutputFile(t);try{if(Wl(n)){let o=await Bc.readFile(n,"utf8");return r?this.filterTaskOutput(o):o}return null}catch(o){return he(`Failed to get task output for task ${t}:`,o),null}finally{let o=await this.getTaskStatus(t);(o==="completed"||o==="status")&&this.removeTaskFromNotificationQueue(t)}}async saveTaskError(t,r){let n=ls.join(Ud,`agent_${t}_error`);await Bc.mkdir(Ud,{recursive:!0});try{let o=typeof r=="string"?r:r instanceof Error?r.stack||r.message:JSON.stringify(r);await Bc.writeFile(n,o,"utf8")}catch(o){throw he(`Failed to save task error for task ${t}:`,o),o}}async getTaskError(t){let r=ls.join(Ud,`agent_${t}_error`);try{return Wl(r)?(await Bc.readFile(r,"utf8")).trim():null}catch(n){return he(`Failed to get task error for task ${t}:`,n),null}}async cleanupTask(t){let r=ls.join(Ud,`agent_${t}_state`),n=ls.join(Ud,`agent_${t}_output`),o=ls.join(Ud,`agent_${t}_error`);try{Wl(r)&&await Bc.unlink(r),Wl(n)&&await Bc.unlink(n),Wl(o)&&await Bc.unlink(o)}catch(i){he(`Failed to cleanup task files for task ${t}:`,i)}}async waitTaskEnd(t,r=0,n){let o=Date.now(),i=!1,s=null,a=null;n&&(s=new Promise((c,l)=>{let u=()=>{a&&a(),l(new Error("Operation aborted"))};n.addEventListener("abort",u),a=()=>{n.removeEventListener("abort",u)},i=!0}));try{for(;;){if(n?.aborted)return!1;let c=await this.getTaskStatus(t);if(c==="completed"||c==="failed")return!0;if(r>0&&Date.now()-o>=r)return!1;let l=new Promise(u=>setTimeout(u,100));try{s?await Promise.race([l,s]):await l}catch(u){if(u instanceof Error&&u.message==="Operation aborted")return!1;throw u}}}finally{i&&a&&a()}}async taskExists(t){let r=ls.join(Ud,`agent_${t}_state`);return Wl(r)}async saveTaskConfig(t,r){let n=ls.join(Ud,`agent_${t}_config`);await Bc.mkdir(Ud,{recursive:!0});try{let o=JSON.stringify(r);await Bc.writeFile(n,o,"utf8")}catch(o){throw he(`Failed to save task config for task ${t}:`,o),o}}async getTaskConfig(t){let r=ls.join(Ud,`agent_${t}_config`);try{if(Wl(r)){let n=await Bc.readFile(r,"utf8"),o=JSON.parse(n);return{isBackGround:o.isBackGround||!1,isTeamMember:o.isTeamMember||!1}}return null}catch(n){return he(`Failed to get task config for task ${t}:`,n),null}}async onTaskCompleted(t){if(t.runInBackgroud&&!t.isStoped()&&!t.isTeamMember){let n=t.parentId||"default";this.backgroundNotificationQueue.has(n)||this.backgroundNotificationQueue.set(n,[]),this.backgroundNotificationQueue.get(n).push(t)}(t.parentId||"default")==="default"&&Nr.emit(NE)}async takeNotificationMessages(t="default"){let r=[],n=this.backgroundNotificationQueue.get(t);if(!n||n.length===0)return null;for(let o of n)r.push({type:"text",text:`<task-notification>
372
372
  <task-id>${o.id}</task-id>
373
373
  <status>completed</status>
374
374
  <summary>Agent "${o.description}" completed</summary>
@@ -676,7 +676,7 @@ globstar while`,t,p,r,f,A),this.matchOne(t.slice(p),r.slice(f),n))return this.de
676
676
  `)),BFn(e,o,{encoding:r,flush:!0})}var nGt=new lle.default({fetchMethod:e=>GFn(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});async function dGt(e){let t=L$(e);return nGt.get(t)||nGt.fetchMethod?.(t)}async function GFn(e){let t=new AbortController;setTimeout(()=>{t.abort()},1e3);let r=await nMt(e,t.signal,15),n=0;for(let o of r)pw(o)==="CRLF"&&n++;return n>3?"CRLF":"LF"}function pGt(e,t,r){if(e.has(t))return e.get(t);let n=r();return e.set(t,n),n}var HFn=new lle.default({fetchMethod:e=>fGt(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function Rm(e){let t=L$(e);return pGt(HFn,t,()=>fGt(t))}function fGt(e){let r=Buffer.alloc(4096),n;try{n=oGt(e,"r");let o=iGt(n,r,0,4096,0);return o===0?"utf8":o>=2&&r[0]===255&&r[1]===254?"utf16le":o>=3&&r[0]===239&&r[1]===187&&r[2]===191||r.slice(0,o).toString("utf8").length>0?"utf8":"ascii"}catch(o){return Re(`Error detecting encoding for file ${e}: ${o}`),"utf8"}finally{n&&sGt(n)}}var qFn=new lle.default({fetchMethod:e=>mGt(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function pw(e){let t=L$(e);return pGt(qFn,t,()=>mGt(t))}function mGt(e,t="utf8"){try{if(!aGt(e).isFile())return"LF";let n=Buffer.alloc(4096),o=oGt(e,"r"),i=iGt(o,n,0,4096,0);sGt(o);let s=n.toString(t,0,i),a=0,c=0;for(let l=0;l<s.length;l++)s[l]===`
677
677
  `&&(l>0&&s[l-1]==="\r"?a++:c++);return a>c?"CRLF":"LF"}catch(r){return Re(`Error detecting line endings for file ${e}: ${r}`),"LF"}}function kBe(e){let t=cGt(e)?e:L$(Le(),e);return t.endsWith(" AM.png")?t.replace(" AM.png","\u202FAM.png"):t.endsWith(" PM.png")?t.replace(" PM.png","\u202FPM.png"):t}function PBe(e){return e?cGt(e)?e:L$(Le(),e):void 0}function gGt(e){try{let t=PBe(e),r=t?FFn(Le(),t):void 0;return{absolutePath:t,relativePath:r}}catch(t){return he("getAbsoluteAndRelativePaths error ",t),{absolutePath:null,relativePath:null}}}function dle(e){try{let t=UFn(e),r=eGt(e,tGt(e));if(!kFn(t))return;let i=PFn(t).filter(s=>eGt(s,tGt(s))===r&&QFn(t,s)!==e)[0];return i||void 0}catch(t){Re(`Error finding similar file for ${e}: ${t}`);return}}function LBe(){let e=process.env.HAWA_CODE_COMPACT_LINE_PREFIX;return!(e==="0"||e==="false")}function cD({content:e,startLine:t}){if(!e)return"";let r=e.split(/\r?\n/);return LBe()?r.map((n,o)=>`${o+t} ${n}`).join(`
678
678
  `):r.map((n,o)=>{let i=String(o+t);return i.length>=6?`${i}\u2192${n}`:`${i.padStart(6," ")}\u2192${n}`}).join(`
679
- `)}function AGt(e){try{let t=LFn(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return Re(`Error checking directory: ${t}`),!1}}He();function oD(){let e=Qn();e.hasCompletedProjectOnboarding||xi({...e,hasCompletedProjectOnboarding:!0})}function zFn(){let e=_r();bo({...e,lastReleaseNotesSeen:MACRO.VERSION})}function FBe({workspaceDir:e}){let r=!Qn().hasCompletedProjectOnboarding,o=_r().lastReleaseNotesSeen,i=[];(!o||(0,hGt.gt)(MACRO.VERSION,o))&&(i=Nce[MACRO.VERSION]||[]);let s=i.length>0;if(Hi.useEffect(()=>{s&&!r&&zFn()},[s,r]),!r&&!s)return null;let a=$Fn(YFn(e,_i)),c=AGt(e),l=!a&&!c,u=_U.isEnabled&&!_r().shiftEnterKeyBindingInstalled,d=X();return Hi.createElement(D,{flexDirection:"column",gap:1,padding:1,paddingBottom:0},r&&Hi.createElement(Hi.Fragment,null,Hi.createElement(C,{color:d.secondaryText},"Tips for getting started:"),Hi.createElement(vd,{children:[]},(()=>{let p=[];return c&&p.push(Hi.createElement(vd.Item,{key:"workspace"},Hi.createElement(C,{color:d.secondaryText},"Ask ",Je," to create a new app or clone a repository."))),l&&p.push(Hi.createElement(vd.Item,{key:"claudemd"},Hi.createElement(C,{color:d.secondaryText},"Run ",Hi.createElement(C,{color:d.text},"/init")," to create a",_i," file with instructions for Hawa code."))),u&&p.push(Hi.createElement(vd.Item,{key:"terminal"},Hi.createElement(C,{color:d.secondaryText},"Run ",Hi.createElement(C,{color:d.text},"/terminal-setup"),Hi.createElement(C,{bold:!1}," to set up terminal integration")))),p.push(Hi.createElement(vd.Item,{key:"questions"},Hi.createElement(C,{color:d.secondaryText},"Ask ",Je," questions about your codebase."))),p.push(Hi.createElement(vd.Item,{key:"changes"},Hi.createElement(C,{color:d.secondaryText},"Ask ",Je," to implement changes to your codebase."))),p})())),!r&&s&&Hi.createElement(D,{borderColor:X().secondaryBorder,flexDirection:"column",marginRight:1},Hi.createElement(D,{flexDirection:"column",gap:0},Hi.createElement(D,{marginBottom:1},Hi.createElement(C,null,"\u{1F195} What's new in v",MACRO.VERSION,":")),Hi.createElement(D,{flexDirection:"column",marginLeft:1},i.map((p,f)=>Hi.createElement(C,{key:f,color:X().secondaryText},"\u2022 ",p))))),e===VFn()&&Hi.createElement(C,{color:X().warning},"Note: You have launched ",Hi.createElement(C,{bold:!0},Je)," in your home directory. For the best experience, launch it in a project directory instead."))}var BU=G(ce(),1);var MU=G(ce(),1);var F$=G(ce(),1);function UBe({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:o}=is("Select");return F$.default.createElement(D,{...o.option({isFocused:e})},e&&F$.default.createElement(C,{...o.focusIndicator()},r?tn.triangleDownSmall:tn.pointer),F$.default.createElement(C,{...o.label({isFocused:e,isSelected:t})},n),t&&F$.default.createElement(C,{...o.selectedIndicator()},tn.tick))}var Dm=G(ce(),1);import{isDeepStrictEqual as WFn}from"node:util";var U$=class extends Map{first;constructor(t){let r=[],n,o,i=0;for(let s of t){let a={...s,previous:o,next:void 0,index:i};o&&(o.next=a),n||=a;let c="value"in s?s.value:QBe(s);r.push([c,a]),i++,o=a}super(r),this.first=n}};var jFn=(e,t)=>{switch(t.type){case"focus-next-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.next;for(;n&&!("value"in n);)n=n.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let i=Math.min(e.optionMap.size,e.visibleToIndex+1),s=i-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:i}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;for(;n&&!("value"in n);)n=n.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let i=Math.max(0,e.visibleFromIndex-1),s=i+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:i,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state;case"set-focus":return{...e,focusedValue:t.value}}},GBe=e=>e.flatMap(t=>{if("options"in t){let r=GBe(t.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),_Gt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=GBe(r),o=typeof e=="number"?Math.min(e,n.length):n.length,i=new U$(n),s=i.first,a=s&&"value"in s?s.value:void 0;return{optionMap:i,visibleOptionCount:o,focusedValue:a,visibleFromIndex:0,visibleToIndex:o,previousValue:t,value:t}},HBe=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=GBe(t),[a,c]=(0,Dm.useReducer)(jFn,{visibleOptionCount:e,defaultValue:r,options:t},_Gt),[l,u]=(0,Dm.useState)(s);s!==l&&!WFn(s,l)&&(c({type:"reset",state:_Gt({visibleOptionCount:e,defaultValue:r,options:t})}),u(s));let d=(0,Dm.useCallback)(()=>{c({type:"focus-next-option"})},[]),p=(0,Dm.useCallback)(()=>{c({type:"focus-previous-option"})},[]),f=(0,Dm.useCallback)(()=>{c({type:"select-focused-option"})},[]),A=(0,Dm.useMemo)(()=>s.map((h,_)=>({...h,index:_})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,Dm.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,t,n]),(0,Dm.useEffect)(()=>{a.focusedValue&&o?.(a.focusedValue)},[a.focusedValue,o]),(0,Dm.useEffect)(()=>{i&&c({type:"set-focus",value:i})},[i]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:A,focusNextOption:d,focusPreviousOption:p,selectFocusedOption:f}};var qBe=({isDisabled:e=!1,state:t})=>{Nt((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var QBe=e=>`HEADER-${e.optionValues.join(",")}`;function $C({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let c=HBe({visibleOptionCount:t,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});qBe({isDisabled:e,state:c});let{styles:l}=is("Select");return MU.default.createElement(D,{...l.container()},c.visibleOptions.map(u=>{let d="value"in u?u.value:QBe(u),p=!e&&c.focusedValue!==void 0&&("value"in u?c.focusedValue===u.value:u.optionValues.includes(c.focusedValue)),f=!!c.value&&("value"in u?c.value===u.value:u.optionValues.includes(c.value)),A="header"in u,h="label"in u?u.label:u.header,_=h;if(r&&h.includes(r)){let T=h.indexOf(r);_=MU.default.createElement(MU.default.Fragment,null,h.slice(0,T),MU.default.createElement(C,{...l.highlightedText()},r),h.slice(T+r.length))}return MU.default.createElement(UBe,{key:d,isFocused:p,isSelected:f,smallPointer:A},_)}))}function EGt({onDone:e}){return Nt((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),BU.default.createElement(D,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:X().secondaryBorder},BU.default.createElement(D,{marginBottom:1,flexDirection:"column"},BU.default.createElement(C,{bold:!0},"You've spent $5 this session.")),BU.default.createElement(D,null,BU.default.createElement($C,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})))}var Mn=G(ce(),1),Sr=G(ce(),1);var Ef=G(ce(),1);He();xr();He();Be();import KFn from"os";import JFn from"path";import Q$ from"fs";var ZFn={sources:{},routing:{}};function bGt(){let e=KFn.homedir();return JFn.join(e,lo,"config.json")}function SGt(){try{let e=bGt();if(!Q$.existsSync(e))return ZFn;let t=Q$.readFileSync(e,"utf-8"),r=JSON.parse(t);return r.sources&&r.routing?r:XFn(r)}catch(e){throw Re(e),e}}function XFn(e){let t={},r={};for(let[n,o]of Object.entries(e))if(o?.enable===!0&&o?.env){let i=o.env,s=n;t[s]={base_url:i.BASE_URL||"",auth_token:i.AUTH_TOKEN||"",api_type:i.API_TYPE||"anthropic",models:[]},i.MODEL&&(r.MODEL=[{source:s,model:i.MODEL,weight:100}],t[s].models.push(i.MODEL)),i.SMALL_FAST_MODEL&&(r.SMALL_FAST_MODEL=[{source:s,model:i.SMALL_FAST_MODEL,weight:100}],t[s].models.includes(i.SMALL_FAST_MODEL)||t[s].models.push(i.SMALL_FAST_MODEL));break}return{sources:t,routing:r}}function TGt(e){if(e.length===0)throw new Error("No items to select from");if(e.length===1)return e[0];let t=e.reduce((n,o)=>n+(o.weight??100),0),r=Math.random()*t;for(let n of e){let o=n.weight??100;if(r-=o,r<=0)return n}return e[e.length-1]}var $Be=class{config;constructor(){try{this.config=SGt()}catch(t){console.log(t)}}reload(){this.config=SGt()}getConfig(){return this.config}hasModelRouting(){return!!(this.config.routing?.MODEL&&this.config.routing.MODEL.length>0)}getModelRoutingModels(){let t=this.config.routing?.MODEL;return!t||t.length===0?[]:t.map(r=>r.model)}hasSmallFastModelRouting(){return!!(this.config.routing?.SMALL_FAST_MODEL&&this.config.routing.SMALL_FAST_MODEL.length>0)}getModel(){let t=this.config.routing?.MODEL;if(!t||t.length===0)throw new Error("No MODEL routing configuration found");let r=TGt(t);return`${r.source}__${r.model}`}getSmallFastModel(){let t=this.config.routing?.SMALL_FAST_MODEL;if(!t||t.length===0)throw new Error("No SMALL_FAST_MODEL routing configuration found");let r=TGt(t);return`${r.source}__${r.model}`}getSourceConfig(t){return this.config.sources?.[t]}parseModelKey(t){let r=t.indexOf("__");return r===-1?{source:"",model:t}:{source:t.slice(0,r),model:t.slice(r+2)}}getModelSourceConfig(t){let{source:r}=this.parseModelKey(t);if(r)return this.getSourceConfig(r)}setModelRouting(t){this.config.routing.MODEL=t,this.saveConfig()}setSmallFastModelRouting(t){this.config.routing.SMALL_FAST_MODEL=t,this.saveConfig()}getAvailableModels(){let t=[];for(let[r,n]of Object.entries(this.config.sources||{}))for(let o of n.models||[])t.push(`${r}__${o}`);return t}saveConfig(){try{let t=bGt(),r={};if(Q$.existsSync(t)){let o=Q$.readFileSync(t,"utf-8");r=JSON.parse(o)}let n={...r,sources:this.config.sources,routing:this.config.routing};Q$.writeFileSync(t,JSON.stringify(n,null,2))}catch(t){Re(t)}}},Wo=new $Be;var eUn="1.38.9",JT={VERSION:eUn,PACKAGE_URL:"@dahawa/hawa-code",README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var YBe=46,yGt=["(\u2740\u2579\u25E1\u2579)","(\u25D5\u072B\u25D5)","\u239D(\u25D5u\u25D5)\u23A0","\u10DA(\u25C9\u25DE\u0C6A\u25DF\u25C9 )\u10DA","(\xB4\u25C9\u203F\u25C9\uFF40)","\u0E01\u0E47\u0295\u2022\u0361\u1D25\u2022\u0294 \u0E01\u0E49","\uFF0F/( \u25D5\u203F\u203F\u25D5 )\uFF3C"];function ple({isDefaultModel:e=!1}){let t=Math.max(YBe,Le().length+12),r=X(),n=yGt[Math.floor(Math.random()*yGt.length)];return Ef.createElement(D,{flexDirection:"column"},Ef.createElement(D,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%"},Ef.createElement(C,null,Ef.createElement(C,null,n)," Welcome to"," ",Ef.createElement(C,{bold:!0},Je),Ef.createElement(C,{color:r.secondaryText}," v",JT.VERSION)),Ef.createElement(Ef.Fragment,null,Ef.createElement(D,{paddingLeft:2,flexDirection:"column",gap:1},Ef.createElement(C,{color:r.secondaryText,italic:!0},"/help for help"),Ef.createElement(C,{color:r.secondaryText},"cwd: ",Le()),Ef.createElement(C,{color:r.secondaryText},"model: ",Wo.getConfig().routing.MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"),Ef.createElement(C,{color:r.secondaryText},"small fast model: ",Wo.getConfig().routing.SMALL_FAST_MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A")))))}var qS=G(ce(),1);Be();var q7=G(ce(),1);import{randomUUID as US}from"crypto";var CGt=()=>[],IGt=()=>{};function vGt(e){CGt=e}function fle(){return CGt}function RGt(e){IGt=e}function DGt(){return IGt}Be();hr();xr();Be();He();import{existsSync as zC,readdirSync as y3n,statSync as C3n}from"fs";import{join as dD,relative as I3n}from"path";import{homedir as t4t}from"os";import{platform as v3n}from"process";import{readFile as pD}from"fs/promises";xr();ZT();Yr();import{join as sUn,sep as aUn}from"path";function Sf(){if(!Nm())return!1;try{let e=wt();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function xm(){return(sUn(Le(),".hcode","team-memory")+aUn).normalize("NFC")}function LU(e){let t=e.normalize("NFC"),r=xm();return t.startsWith(r)}var r4t=G(Ile(),1);Zo();var J9t=G(Ile(),1);xr();He();Be();vm();import{readFile as j9t}from"fs/promises";import{existsSync as lke,readdirSync as E3n,statSync as S3n}from"fs";import{join as uke,relative as Z9t}from"path";import{homedir as T3n}from"os";function K9t(e){try{let t=(0,J9t.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(o=>o.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(o=>typeof o=="string")),{paths:n,content:t.content.trim()}}catch(t){return Re(t),{paths:[],content:e.trim()}}}function b3n(e,t){return t.length===0?!0:t.some(r=>{try{return Dd(e,r,{matchBase:!0,dot:!0})}catch(n){return Re(n),!1}})}function dke(e){let t=[];try{if(!lke(e))return t;let r=E3n(e);for(let n of r){let o=uke(e,n),i=S3n(o);i.isDirectory()?t.push(...dke(o)):i.isFile()&&n.endsWith(".md")&&t.push(o)}}catch(r){Re(r)}return t}async function X9t(){let e=[];try{let t=uke(T3n(),lo,"rules");if(lke(t)){let r=dke(t);for(let n of r)try{let o=await j9t(n,"utf-8"),{paths:i,content:s}=K9t(o);i.length>0&&e.push({filePath:n,content:s,paths:i,isProjectRule:!1})}catch(o){Re(o)}}}catch(t){Re(t)}try{let t=uke(Le(),lo,"rules");if(lke(t)){let r=dke(t);for(let n of r)try{let o=await j9t(n,"utf-8"),{paths:i,content:s}=K9t(o);i.length>0&&e.push({filePath:Z9t(Le(),n),content:s,paths:i,isProjectRule:!0})}catch(o){Re(o)}}}catch(t){Re(t)}return e}function e4t(e,t){e=uae(e);let r=uae(Le()),n=e.startsWith(r)?Z9t(r,e):e;return t.filter(o=>b3n(n,o.paths))}var R3n=`# hawaCodeMd
679
+ `)}function AGt(e){try{let t=LFn(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return Re(`Error checking directory: ${t}`),!1}}He();function oD(){let e=Qn();e.hasCompletedProjectOnboarding||xi({...e,hasCompletedProjectOnboarding:!0})}function zFn(){let e=_r();bo({...e,lastReleaseNotesSeen:MACRO.VERSION})}function FBe({workspaceDir:e}){let r=!Qn().hasCompletedProjectOnboarding,o=_r().lastReleaseNotesSeen,i=[];(!o||(0,hGt.gt)(MACRO.VERSION,o))&&(i=Nce[MACRO.VERSION]||[]);let s=i.length>0;if(Hi.useEffect(()=>{s&&!r&&zFn()},[s,r]),!r&&!s)return null;let a=$Fn(YFn(e,_i)),c=AGt(e),l=!a&&!c,u=_U.isEnabled&&!_r().shiftEnterKeyBindingInstalled,d=X();return Hi.createElement(D,{flexDirection:"column",gap:1,padding:1,paddingBottom:0},r&&Hi.createElement(Hi.Fragment,null,Hi.createElement(C,{color:d.secondaryText},"Tips for getting started:"),Hi.createElement(vd,{children:[]},(()=>{let p=[];return c&&p.push(Hi.createElement(vd.Item,{key:"workspace"},Hi.createElement(C,{color:d.secondaryText},"Ask ",Je," to create a new app or clone a repository."))),l&&p.push(Hi.createElement(vd.Item,{key:"claudemd"},Hi.createElement(C,{color:d.secondaryText},"Run ",Hi.createElement(C,{color:d.text},"/init")," to create a",_i," file with instructions for Hawa code."))),u&&p.push(Hi.createElement(vd.Item,{key:"terminal"},Hi.createElement(C,{color:d.secondaryText},"Run ",Hi.createElement(C,{color:d.text},"/terminal-setup"),Hi.createElement(C,{bold:!1}," to set up terminal integration")))),p.push(Hi.createElement(vd.Item,{key:"questions"},Hi.createElement(C,{color:d.secondaryText},"Ask ",Je," questions about your codebase."))),p.push(Hi.createElement(vd.Item,{key:"changes"},Hi.createElement(C,{color:d.secondaryText},"Ask ",Je," to implement changes to your codebase."))),p})())),!r&&s&&Hi.createElement(D,{borderColor:X().secondaryBorder,flexDirection:"column",marginRight:1},Hi.createElement(D,{flexDirection:"column",gap:0},Hi.createElement(D,{marginBottom:1},Hi.createElement(C,null,"\u{1F195} What's new in v",MACRO.VERSION,":")),Hi.createElement(D,{flexDirection:"column",marginLeft:1},i.map((p,f)=>Hi.createElement(C,{key:f,color:X().secondaryText},"\u2022 ",p))))),e===VFn()&&Hi.createElement(C,{color:X().warning},"Note: You have launched ",Hi.createElement(C,{bold:!0},Je)," in your home directory. For the best experience, launch it in a project directory instead."))}var BU=G(ce(),1);var MU=G(ce(),1);var F$=G(ce(),1);function UBe({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:o}=is("Select");return F$.default.createElement(D,{...o.option({isFocused:e})},e&&F$.default.createElement(C,{...o.focusIndicator()},r?tn.triangleDownSmall:tn.pointer),F$.default.createElement(C,{...o.label({isFocused:e,isSelected:t})},n),t&&F$.default.createElement(C,{...o.selectedIndicator()},tn.tick))}var Dm=G(ce(),1);import{isDeepStrictEqual as WFn}from"node:util";var U$=class extends Map{first;constructor(t){let r=[],n,o,i=0;for(let s of t){let a={...s,previous:o,next:void 0,index:i};o&&(o.next=a),n||=a;let c="value"in s?s.value:QBe(s);r.push([c,a]),i++,o=a}super(r),this.first=n}};var jFn=(e,t)=>{switch(t.type){case"focus-next-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.next;for(;n&&!("value"in n);)n=n.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let i=Math.min(e.optionMap.size,e.visibleToIndex+1),s=i-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:i}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;for(;n&&!("value"in n);)n=n.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let i=Math.max(0,e.visibleFromIndex-1),s=i+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:i,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state;case"set-focus":return{...e,focusedValue:t.value}}},GBe=e=>e.flatMap(t=>{if("options"in t){let r=GBe(t.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),_Gt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=GBe(r),o=typeof e=="number"?Math.min(e,n.length):n.length,i=new U$(n),s=i.first,a=s&&"value"in s?s.value:void 0;return{optionMap:i,visibleOptionCount:o,focusedValue:a,visibleFromIndex:0,visibleToIndex:o,previousValue:t,value:t}},HBe=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=GBe(t),[a,c]=(0,Dm.useReducer)(jFn,{visibleOptionCount:e,defaultValue:r,options:t},_Gt),[l,u]=(0,Dm.useState)(s);s!==l&&!WFn(s,l)&&(c({type:"reset",state:_Gt({visibleOptionCount:e,defaultValue:r,options:t})}),u(s));let d=(0,Dm.useCallback)(()=>{c({type:"focus-next-option"})},[]),p=(0,Dm.useCallback)(()=>{c({type:"focus-previous-option"})},[]),f=(0,Dm.useCallback)(()=>{c({type:"select-focused-option"})},[]),A=(0,Dm.useMemo)(()=>s.map((h,_)=>({...h,index:_})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,Dm.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,t,n]),(0,Dm.useEffect)(()=>{a.focusedValue&&o?.(a.focusedValue)},[a.focusedValue,o]),(0,Dm.useEffect)(()=>{i&&c({type:"set-focus",value:i})},[i]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:A,focusNextOption:d,focusPreviousOption:p,selectFocusedOption:f}};var qBe=({isDisabled:e=!1,state:t})=>{Nt((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var QBe=e=>`HEADER-${e.optionValues.join(",")}`;function $C({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let c=HBe({visibleOptionCount:t,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});qBe({isDisabled:e,state:c});let{styles:l}=is("Select");return MU.default.createElement(D,{...l.container()},c.visibleOptions.map(u=>{let d="value"in u?u.value:QBe(u),p=!e&&c.focusedValue!==void 0&&("value"in u?c.focusedValue===u.value:u.optionValues.includes(c.focusedValue)),f=!!c.value&&("value"in u?c.value===u.value:u.optionValues.includes(c.value)),A="header"in u,h="label"in u?u.label:u.header,_=h;if(r&&h.includes(r)){let T=h.indexOf(r);_=MU.default.createElement(MU.default.Fragment,null,h.slice(0,T),MU.default.createElement(C,{...l.highlightedText()},r),h.slice(T+r.length))}return MU.default.createElement(UBe,{key:d,isFocused:p,isSelected:f,smallPointer:A},_)}))}function EGt({onDone:e}){return Nt((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),BU.default.createElement(D,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:X().secondaryBorder},BU.default.createElement(D,{marginBottom:1,flexDirection:"column"},BU.default.createElement(C,{bold:!0},"You've spent $5 this session.")),BU.default.createElement(D,null,BU.default.createElement($C,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})))}var Mn=G(ce(),1),Sr=G(ce(),1);var Ef=G(ce(),1);He();xr();He();Be();import KFn from"os";import JFn from"path";import Q$ from"fs";var ZFn={sources:{},routing:{}};function bGt(){let e=KFn.homedir();return JFn.join(e,lo,"config.json")}function SGt(){try{let e=bGt();if(!Q$.existsSync(e))return ZFn;let t=Q$.readFileSync(e,"utf-8"),r=JSON.parse(t);return r.sources&&r.routing?r:XFn(r)}catch(e){throw Re(e),e}}function XFn(e){let t={},r={};for(let[n,o]of Object.entries(e))if(o?.enable===!0&&o?.env){let i=o.env,s=n;t[s]={base_url:i.BASE_URL||"",auth_token:i.AUTH_TOKEN||"",api_type:i.API_TYPE||"anthropic",models:[]},i.MODEL&&(r.MODEL=[{source:s,model:i.MODEL,weight:100}],t[s].models.push(i.MODEL)),i.SMALL_FAST_MODEL&&(r.SMALL_FAST_MODEL=[{source:s,model:i.SMALL_FAST_MODEL,weight:100}],t[s].models.includes(i.SMALL_FAST_MODEL)||t[s].models.push(i.SMALL_FAST_MODEL));break}return{sources:t,routing:r}}function TGt(e){if(e.length===0)throw new Error("No items to select from");if(e.length===1)return e[0];let t=e.reduce((n,o)=>n+(o.weight??100),0),r=Math.random()*t;for(let n of e){let o=n.weight??100;if(r-=o,r<=0)return n}return e[e.length-1]}var $Be=class{config;constructor(){try{this.config=SGt()}catch(t){console.log(t)}}reload(){this.config=SGt()}getConfig(){return this.config}hasModelRouting(){return!!(this.config.routing?.MODEL&&this.config.routing.MODEL.length>0)}getModelRoutingModels(){let t=this.config.routing?.MODEL;return!t||t.length===0?[]:t.map(r=>r.model)}hasSmallFastModelRouting(){return!!(this.config.routing?.SMALL_FAST_MODEL&&this.config.routing.SMALL_FAST_MODEL.length>0)}getModel(){let t=this.config.routing?.MODEL;if(!t||t.length===0)throw new Error("No MODEL routing configuration found");let r=TGt(t);return`${r.source}__${r.model}`}getSmallFastModel(){let t=this.config.routing?.SMALL_FAST_MODEL;if(!t||t.length===0)throw new Error("No SMALL_FAST_MODEL routing configuration found");let r=TGt(t);return`${r.source}__${r.model}`}getSourceConfig(t){return this.config.sources?.[t]}parseModelKey(t){let r=t.indexOf("__");return r===-1?{source:"",model:t}:{source:t.slice(0,r),model:t.slice(r+2)}}getModelSourceConfig(t){let{source:r}=this.parseModelKey(t);if(r)return this.getSourceConfig(r)}setModelRouting(t){this.config.routing.MODEL=t,this.saveConfig()}setSmallFastModelRouting(t){this.config.routing.SMALL_FAST_MODEL=t,this.saveConfig()}getAvailableModels(){let t=[];for(let[r,n]of Object.entries(this.config.sources||{}))for(let o of n.models||[])t.push(`${r}__${o}`);return t}saveConfig(){try{let t=bGt(),r={};if(Q$.existsSync(t)){let o=Q$.readFileSync(t,"utf-8");r=JSON.parse(o)}let n={...r,sources:this.config.sources,routing:this.config.routing};Q$.writeFileSync(t,JSON.stringify(n,null,2))}catch(t){Re(t)}}},Wo=new $Be;var eUn="1.38.10",JT={VERSION:eUn,PACKAGE_URL:"@dahawa/hawa-code",README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var YBe=46,yGt=["(\u2740\u2579\u25E1\u2579)","(\u25D5\u072B\u25D5)","\u239D(\u25D5u\u25D5)\u23A0","\u10DA(\u25C9\u25DE\u0C6A\u25DF\u25C9 )\u10DA","(\xB4\u25C9\u203F\u25C9\uFF40)","\u0E01\u0E47\u0295\u2022\u0361\u1D25\u2022\u0294 \u0E01\u0E49","\uFF0F/( \u25D5\u203F\u203F\u25D5 )\uFF3C"];function ple({isDefaultModel:e=!1}){let t=Math.max(YBe,Le().length+12),r=X(),n=yGt[Math.floor(Math.random()*yGt.length)];return Ef.createElement(D,{flexDirection:"column"},Ef.createElement(D,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%"},Ef.createElement(C,null,Ef.createElement(C,null,n)," Welcome to"," ",Ef.createElement(C,{bold:!0},Je),Ef.createElement(C,{color:r.secondaryText}," v",JT.VERSION)),Ef.createElement(Ef.Fragment,null,Ef.createElement(D,{paddingLeft:2,flexDirection:"column",gap:1},Ef.createElement(C,{color:r.secondaryText,italic:!0},"/help for help"),Ef.createElement(C,{color:r.secondaryText},"cwd: ",Le()),Ef.createElement(C,{color:r.secondaryText},"model: ",Wo.getConfig().routing.MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"),Ef.createElement(C,{color:r.secondaryText},"small fast model: ",Wo.getConfig().routing.SMALL_FAST_MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A")))))}var qS=G(ce(),1);Be();var q7=G(ce(),1);import{randomUUID as US}from"crypto";var CGt=()=>[],IGt=()=>{};function vGt(e){CGt=e}function fle(){return CGt}function RGt(e){IGt=e}function DGt(){return IGt}Be();hr();xr();Be();He();import{existsSync as zC,readdirSync as y3n,statSync as C3n}from"fs";import{join as dD,relative as I3n}from"path";import{homedir as t4t}from"os";import{platform as v3n}from"process";import{readFile as pD}from"fs/promises";xr();ZT();Yr();import{join as sUn,sep as aUn}from"path";function Sf(){if(!Nm())return!1;try{let e=wt();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function xm(){return(sUn(Le(),".hcode","team-memory")+aUn).normalize("NFC")}function LU(e){let t=e.normalize("NFC"),r=xm();return t.startsWith(r)}var r4t=G(Ile(),1);Zo();var J9t=G(Ile(),1);xr();He();Be();vm();import{readFile as j9t}from"fs/promises";import{existsSync as lke,readdirSync as E3n,statSync as S3n}from"fs";import{join as uke,relative as Z9t}from"path";import{homedir as T3n}from"os";function K9t(e){try{let t=(0,J9t.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(o=>o.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(o=>typeof o=="string")),{paths:n,content:t.content.trim()}}catch(t){return Re(t),{paths:[],content:e.trim()}}}function b3n(e,t){return t.length===0?!0:t.some(r=>{try{return Dd(e,r,{matchBase:!0,dot:!0})}catch(n){return Re(n),!1}})}function dke(e){let t=[];try{if(!lke(e))return t;let r=E3n(e);for(let n of r){let o=uke(e,n),i=S3n(o);i.isDirectory()?t.push(...dke(o)):i.isFile()&&n.endsWith(".md")&&t.push(o)}}catch(r){Re(r)}return t}async function X9t(){let e=[];try{let t=uke(T3n(),lo,"rules");if(lke(t)){let r=dke(t);for(let n of r)try{let o=await j9t(n,"utf-8"),{paths:i,content:s}=K9t(o);i.length>0&&e.push({filePath:n,content:s,paths:i,isProjectRule:!1})}catch(o){Re(o)}}}catch(t){Re(t)}try{let t=uke(Le(),lo,"rules");if(lke(t)){let r=dke(t);for(let n of r)try{let o=await j9t(n,"utf-8"),{paths:i,content:s}=K9t(o);i.length>0&&e.push({filePath:Z9t(Le(),n),content:s,paths:i,isProjectRule:!0})}catch(o){Re(o)}}}catch(t){Re(t)}return e}function e4t(e,t){e=uae(e);let r=uae(Le()),n=e.startsWith(r)?Z9t(r,e):e;return t.filter(o=>b3n(n,o.paths))}var R3n=`# hawaCodeMd
680
680
  Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.`;function D3n(e="default"){let r=Ye.getSessionContext(e).getData("matchedPathRules");return!r||r.length===0?"":r.map(o=>{let i=o.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${o.filePath} (${i}):
681
681
 
682
682
  ${o.content}`}).join(`
@@ -774,7 +774,7 @@ data: ${JSON.stringify(F)}
774
774
  Stack trace: `+d.stack)),new Response(c.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var ife=null,VQe=!1;function uno(){ife=null,VQe=!1}Nr.on("proxy:changed",uno);function dno(){if(VQe)return ife;if(VQe=!0,wt().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(ife=new djt.ProxyAgent({uri:e}),qt(`[proxy] using proxy: ${e}`)),ife}function pno(){let e=dno();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function afe(e){let t=e||process.env.API_TYPE,r=pno();switch(t){case"openai":return sno(r);case"openai-responses":return ano(r);case"gemini":return cno(r);default:return lno(r)}}var fjt=G(ce(),1);function pjt(e,t){let r=[],n=Math.max(1,Math.floor(t)),o="",i=0;for(let s of e){let a=fno(s);o&&i+a>n?(r.push(o),o=s,i=a):(o+=s,i+=a)}return o&&r.push(o),r}function fno(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||mno(t)?0:gno(t)?2:1}function mno(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function gno(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function rS(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function jQe(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let r=Math.floor(t/3600),n=Math.floor(t%3600/60),o=t%60;return r>0?`${r}h ${n}m ${o}s`:`${n}m ${o}s`}function m0(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}function cfe(e,t,r){let n=[];return typeof e=="number"&&n.push(jQe(e)),typeof t=="number"&&n.push(`${t} ${t===1?"turn":"turns"}`),typeof r=="number"&&n.push(`${m0(r)} tokens`),n.length>0?` (${n.join(" \xB7 ")})`:""}Be();va();var pA={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0};function lfe(e,t){pA.totalCost+=e,pA.totalAPIDuration+=t}function ufe(e,t){pA.inputTokens+=e,pA.outputTokens+=t,Nr.emit("token:change",{inputTokens:pA.inputTokens,outputTokens:pA.outputTokens})}function VY(){return{inputTokens:pA.inputTokens,outputTokens:pA.outputTokens}}function dfe(){return pA.totalCost}function mjt(){return Date.now()-pA.startTime}function KQe(){return Ct.grey(`Total duration (API): ${rS(pA.totalAPIDuration)}
775
775
  Total duration (wall): ${rS(mjt())}`)}function gjt(){(0,fjt.useEffect)(()=>{let e=()=>{process.stdout.write(`
776
776
  `+KQe()+`
777
- `);let t=Qn();xi({...t,lastCost:pA.totalCost,lastAPIDuration:pA.totalAPIDuration,lastDuration:mjt(),lastSessionId:xE})};return process.on("exit",e),()=>{process.off("exit",e)}},[])}Be();He();He();var JQe="1.38.9";globalThis.MACRO={VERSION:JQe,PACKAGE_URL:`@dahawa/${Gi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var pfe=process.env.HAWA_CODE_USER_AGENT||`${Gi}/${JQe} (${process.env.USER_TYPE})`;Be();Be();hr();function xp(e){let t=[];return e.filter(r=>r.type!=="progress"&&r.type!=="reminder").forEach(r=>{switch(r.type){case"user":{let n=gp(t);if(n?.type==="user"){t[t.length-1]=Eno(n,r);return}t.push(r);return}case"assistant":t.push(r);return;case"insert":{let n=gp(t);n?.type==="user"&&(t[t.length-1]=Ano(n,r));return}}}),t}function Ano(e,t){return{...e,message:{...e.message,content:_no(e.message.content,hno(t.content.content))}}}function hno(e){return`
777
+ `);let t=Qn();xi({...t,lastCost:pA.totalCost,lastAPIDuration:pA.totalAPIDuration,lastDuration:mjt(),lastSessionId:xE})};return process.on("exit",e),()=>{process.off("exit",e)}},[])}Be();He();He();var JQe="1.38.10";globalThis.MACRO={VERSION:JQe,PACKAGE_URL:`@dahawa/${Gi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var pfe=process.env.HAWA_CODE_USER_AGENT||`${Gi}/${JQe} (${process.env.USER_TYPE})`;Be();Be();hr();function xp(e){let t=[];return e.filter(r=>r.type!=="progress"&&r.type!=="reminder").forEach(r=>{switch(r.type){case"user":{let n=gp(t);if(n?.type==="user"){t[t.length-1]=Eno(n,r);return}t.push(r);return}case"assistant":t.push(r);return;case"insert":{let n=gp(t);n?.type==="user"&&(t[t.length-1]=Ano(n,r));return}}}),t}function Ano(e,t){return{...e,message:{...e.message,content:_no(e.message.content,hno(t.content.content))}}}function hno(e){return`
778
778
  <system-reminder>
779
779
  The user sent the following message:
780
780
  ${e}
@@ -2645,7 +2645,7 @@ ${await UM()}
2645
2645
  ${await QM()}`,location:"built-in"};function t9o(e){if(!e||e==="*")return"*";if(Array.isArray(e)){let t=e.filter(r=>typeof r=="string");return t.length>0?t:"*"}return typeof e=="string"?[e]:"*"}async function yxr(e,t){if(!V3o(e))return[];let r=[];try{let n=W3o(e);for(let o of n){if(!o.endsWith(".md"))continue;let i=yZe(e,o);if(j3o(i).isFile())try{let a=z3o(i,"utf-8"),{data:c,content:l}=(0,Cxr.default)(a);if(!c.name||!c.description){console.warn(`Skipping ${i}: missing required fields (name, description)`);continue}c.model&&!c.model_name&&!bxr.has(c.name)&&process.env.UCODE_DEBUG_AGENTS&&(console.warn(`\u26A0\uFE0F Agent ${c.name}: 'model' field is deprecated and ignored. Use 'model_name' instead, or omit to use default 'task' model.`),bxr.add(c.name));let u={agentType:c.name,whenToUse:c.description.replace(/\\n/g,`
2646
2646
  `),tools:t9o(c.tools),getSystemPrompt:()=>l.trim(),location:t,...c.color&&{color:c.color},...c.model_name&&{model_name:c.model_name},...c.background!==void 0&&{background:!!c.background},...c.isolation!==void 0&&{isolation:String(c.isolation)}};r.push(u)}catch(a){console.warn(`Failed to parse agent file ${i}:`,a)}}}catch(n){console.warn(`Failed to scan directory ${e}:`,n)}return r}async function Ixr(){try{let e=yZe(K3o(),lo,"agents"),t=yZe(Le(),lo,"agents"),[r,n]=await Promise.all([yxr(e,"user"),yxr(t,"project")]),o=[bZe,J3o,Z3o,X3o,e9o],i=new Map;for(let c of o)i.set(c.agentType,c);for(let c of r)i.set(c.agentType,c);for(let c of n)i.set(c.agentType,c);let s=Array.from(i.values()),a=[...o,...r,...n];return{activeAgents:s,allAgents:a}}catch(e){return console.error("Failed to load agents, falling back to built-in:",e),{activeAgents:[bZe],allAgents:[bZe]}}}var bI=ze(async()=>{let{activeAgents:e}=await Ixr();return e}),XBs=ze(async()=>{let{allAgents:e}=await Ixr();return e});var mx=ze(async e=>(await bI()).find(r=>r.agentType.toLowerCase()===e.toLowerCase())),dy=ze(async()=>(await bI()).map(t=>t.agentType));gA();He();xr();LT();import{mkdir as r9o}from"fs/promises";import{join as Rxr}from"path";xr();Be();var n9o=/^[a-zA-Z0-9._-]+$/,vxr=64;function E7(e){if(e.length>vxr)throw new Error(`Invalid worktree name: must be ${vxr} characters or fewer (got ${e.length})`);for(let t of e.split("/")){if(t==="."||t==="..")throw new Error(`Invalid worktree name "${e}": must not contain "." or ".." path segments`);if(!n9o.test(t))throw new Error(`Invalid worktree name "${e}": each "/"-separated segment must be non-empty and contain only letters, digits, dots, underscores, and dashes`)}}var yI=null;function S7(){return yI}function Dxr(e){return e.replaceAll("/","+")}function o9o(e){return`worktree-${Dxr(e)}`}function Nxr(e){return Rxr(e,".claude","worktrees")}function i9o(e,t){return Rxr(Nxr(e),Dxr(t))}async function xxr(e){let{stdout:t,code:r}=await Sn("git",["rev-parse","--show-toplevel"],void 0,void 0,!1);return r!==0?null:t.trim()}async function s9o(){let e=["main","master","develop","trunk"];for(let t of e){let{code:r}=await Sn("git",["show-ref","--verify","--quiet",`refs/heads/${t}`],void 0,void 0,!1);if(r===0)return t}return kF()}async function Oxr(e,t){let r=i9o(e,t),n=o9o(t),{stdout:o}=await Sn("git",["worktree","list","--porcelain"],void 0,void 0,!1);if(o.split(`
2647
2647
  `).filter(h=>h.startsWith("worktree ")).map(h=>h.slice(9)).find(h=>h===r)){let{stdout:h}=await Sn("git",["-C",r,"rev-parse","HEAD"],void 0,void 0,!1);return{worktreePath:r,worktreeBranch:n,headCommit:h.trim(),existed:!0}}await r9o(Nxr(e),{recursive:!0});let s=await s9o(),a=`origin/${s}`,{code:c}=await Sn("git",["fetch","origin",s],void 0,void 0,!1),l=c===0?a:"HEAD",{stdout:u,code:d}=await Sn("git",["rev-parse",l],void 0,void 0,!1);if(d!==0)throw new Error(`Failed to resolve base branch "${l}": git rev-parse failed`);let p=u.trim(),{code:f,stderr:A}=await Sn("git",["worktree","add","-B",n,r,l],void 0,void 0,!1);if(f!==0)throw new Error(`Failed to create worktree: ${A}`);return{worktreePath:r,worktreeBranch:n,headCommit:p,baseBranch:l,existed:!1}}async function wxr(e,t){E7(t);let r=Le(),n=await xxr(r);if(!n)throw new Error("Cannot create a worktree: not in a git repository. Please run this command from within a git repository.");let o=await kF(),i=await JOe(),{worktreePath:s,worktreeBranch:a,existed:c}=await Oxr(n,t);return c?be(`Resuming existing worktree at: ${s}`):be(`Created worktree at: ${s} on branch: ${a}`),yI={originalCwd:r,worktreePath:s,worktreeName:t,worktreeBranch:a,originalBranch:o,originalHeadCommit:i,sessionId:e},yI}async function Mxr(){if(yI)try{let{worktreePath:e,originalCwd:t}=yI;process.chdir(t),await Da(t),yI=null,be(`Worktree preserved at: ${e}`),be(`You can continue working there by running: cd ${e}`)}catch(e){be(`Error keeping worktree: ${e}`,"error")}}async function Bxr(){if(yI)try{let{worktreePath:e,originalCwd:t,worktreeBranch:r}=yI;process.chdir(t),await Da(t);let{code:n,stderr:o}=await Sn("git",["worktree","remove","--force",e],void 0,void 0,!1);if(n!==0?be(`Failed to remove worktree: ${o}`,"error"):be(`Removed worktree at: ${e}`),yI=null,r){let{code:i,stderr:s}=await Sn("git",["branch","-D",r],void 0,void 0,!1);i!==0?be(`Could not delete worktree branch: ${s}`,"error"):be(`Deleted worktree branch: ${r}`)}be("Worktree cleaned up completely")}catch(e){be(`Error cleaning up worktree: ${e}`,"error")}}async function CZe(e,t){let r=await Sn("git",["-C",e,"status","--porcelain"],void 0,void 0,!1);if(r.code!==0)return null;let n=r.stdout.split(`
2648
- `).filter(s=>s.trim()!=="").length;if(!t)return null;let o=await Sn("git",["-C",e,"rev-list","--count",`${t}..HEAD`],void 0,void 0,!1);if(o.code!==0)return null;let i=parseInt(o.stdout.trim(),10)||0;return{changedFiles:n,commits:i}}async function a4(e){E7(e);let t=Le(),r=await xxr(t);if(!r)throw new Error("\u65E0\u6CD5\u521B\u5EFA agent worktree\uFF1A\u5F53\u524D\u4E0D\u5728 git \u4ED3\u5E93\u4E2D\u3002\u8BF7\u5728 git \u4ED3\u5E93\u5185\u8FD0\u884C\u6B64\u547D\u4EE4\u3002");let{worktreePath:n,worktreeBranch:o,headCommit:i,existed:s}=await Oxr(r,e);return s?be(`\u6062\u590D\u5DF2\u5B58\u5728\u7684 agent worktree\uFF1A${n}`):be(`\u521B\u5EFA agent worktree\uFF1A${n}\uFF0C\u5206\u652F\uFF1A${o}`),{worktreePath:n,worktreeBranch:o,headCommit:i,gitRoot:r}}async function c4(e,t){let{code:r,stdout:n}=await Sn("git",["-C",e,"status","--porcelain"],void 0,void 0,!1);if(r!==0||n.trim().length>0)return!0;let{code:o,stdout:i}=await Sn("git",["-C",e,"rev-list","--count",`${t}..HEAD`],void 0,void 0,!1);return o!==0||parseInt(i.trim(),10)>0}async function l4(e,t,r){if(!r)return be("\u65E0\u6CD5\u5220\u9664 agent worktree\uFF1A\u672A\u63D0\u4F9B git root"),!1;let{code:n,stderr:o}=await Sn("git",["worktree","remove","--force",e],void 0,void 0,!1);if(n!==0)return be(`\u5220\u9664 agent worktree \u5931\u8D25\uFF1A${o}`),!1;if(be(`\u5DF2\u5220\u9664 agent worktree\uFF1A${e}`),!t)return!0;let{code:i,stderr:s}=await Sn("git",["branch","-D",t],void 0,void 0,!1);return i!==0?be(`\u5220\u9664 agent worktree \u5206\u652F\u5931\u8D25\uFF1A${s}`):be(`\u5DF2\u5220\u9664 agent worktree \u5206\u652F\uFF1A${t}`),!0}mA();Zo();Yr();var a9o=ze(()=>oe.object({description:oe.string().describe("A short (3-5 word) description of the task"),prompt:oe.string().describe("The task for the agent to perform"),model_name:oe.string().optional().describe("Optional: Specific model name to use for this task. If not provided, uses the default task model pointer."),subagent_type:oe.string().optional().describe("The type of specialized agent to use for this task"),resume:oe.string().optional().describe("Optional agent ID to resume from. If provided, the agent will continue from the previous execution transcript."),run_in_background:oe.boolean().optional().describe("Set to true to run this agent in the background. Use TaskOutput to read the output later."),isolation:oe.enum(["worktree"]).optional().describe('Isolation mode. "worktree" creates a temporary git worktree so the agent works on an isolated copy of the repo.')})),kxr={async prompt({dangerouslySkipPermissions:e}){return await Lxr(e)},name:en,async description(){return Pxr},get inputSchema(){return a9o()},async*call(e,t,r){let{run_in_background:n,description:o,prompt:i,resume:s,isolation:a}=e,c=this,l=new Ob(o,n);l.prompt=i||"",s&&l.setId(s),l.link(t.abortController),t.abortController=l.controller;let u=async function*(){for await(let d of c.callT(e,t,r,l.id,s!==void 0))yield d};l.callable=u,l=await kc.submitTask(l),yield*l.getResult()},async*callT({description:e,prompt:t,model_name:r,subagent_type:n,run_in_background:o,isolation:i},{abortController:s,options:{dangerouslySkipPermissions:a=!1,verbose:c},readFileTimestamps:l,hookContext:u},d,p,f){let A=null;Ye.onQueryStart(p);let h=Date.now(),_=n||"general-purpose",T=t,y,I=r||"task",v=null,x;if(_){let le=await mx(_);if(!le){let Ue=await dy(),Te=`Agent type '${_}' not found.
2648
+ `).filter(s=>s.trim()!=="").length;if(!t)return null;let o=await Sn("git",["-C",e,"rev-list","--count",`${t}..HEAD`],void 0,void 0,!1);if(o.code!==0)return null;let i=parseInt(o.stdout.trim(),10)||0;return{changedFiles:n,commits:i}}async function a4(e){E7(e);let t=Le(),r=await xxr(t);if(!r)throw new Error("\u65E0\u6CD5\u521B\u5EFA agent worktree\uFF1A\u5F53\u524D\u4E0D\u5728 git \u4ED3\u5E93\u4E2D\u3002\u8BF7\u5728 git \u4ED3\u5E93\u5185\u8FD0\u884C\u6B64\u547D\u4EE4\u3002");let{worktreePath:n,worktreeBranch:o,headCommit:i,existed:s}=await Oxr(r,e);return s?be(`\u6062\u590D\u5DF2\u5B58\u5728\u7684 agent worktree\uFF1A${n}`):be(`\u521B\u5EFA agent worktree\uFF1A${n}\uFF0C\u5206\u652F\uFF1A${o}`),{worktreePath:n,worktreeBranch:o,headCommit:i,gitRoot:r}}async function c4(e,t){let{code:r,stdout:n}=await Sn("git",["-C",e,"status","--porcelain"],void 0,void 0,!1);if(r!==0||n.trim().length>0)return!0;let{code:o,stdout:i}=await Sn("git",["-C",e,"rev-list","--count",`${t}..HEAD`],void 0,void 0,!1);return o!==0||parseInt(i.trim(),10)>0}async function l4(e,t,r){if(!r)return be("\u65E0\u6CD5\u5220\u9664 agent worktree\uFF1A\u672A\u63D0\u4F9B git root"),!1;let{code:n,stderr:o}=await Sn("git",["worktree","remove","--force",e],void 0,void 0,!1);if(n!==0)return be(`\u5220\u9664 agent worktree \u5931\u8D25\uFF1A${o}`),!1;if(be(`\u5DF2\u5220\u9664 agent worktree\uFF1A${e}`),!t)return!0;let{code:i,stderr:s}=await Sn("git",["branch","-D",t],void 0,void 0,!1);return i!==0?be(`\u5220\u9664 agent worktree \u5206\u652F\u5931\u8D25\uFF1A${s}`):be(`\u5DF2\u5220\u9664 agent worktree \u5206\u652F\uFF1A${t}`),!0}mA();Zo();Yr();var a9o=ze(()=>oe.object({description:oe.string().describe("A short (3-5 word) description of the task"),prompt:oe.string().describe("The task for the agent to perform"),model_name:oe.string().optional().describe("Optional: Specific model name to use for this task. If not provided, uses the default task model pointer."),subagent_type:oe.string().optional().describe("The type of specialized agent to use for this task"),resume:oe.string().optional().describe("Optional agent ID to resume from. If provided, the agent will continue from the previous execution transcript."),run_in_background:oe.boolean().optional().describe("Set to true to run this agent in the background. Use TaskOutput to read the output later."),isolation:oe.enum(["worktree"]).optional().describe('Isolation mode. "worktree" creates a temporary git worktree so the agent works on an isolated copy of the repo.')})),kxr={async prompt({dangerouslySkipPermissions:e}){return await Lxr(e)},name:en,async description(){return Pxr},get inputSchema(){return a9o()},async*call(e,t,r){let{run_in_background:n,description:o,prompt:i,resume:s,isolation:a}=e,c=this,l=new Ob(o,n);l.prompt=i||"",s&&l.setId(s),l.link(t.abortController),t.abortController=l.controller;let u=async function*(){for await(let d of c.callT(e,t,r,l.id,s!==void 0))yield d};l.callable=u,l=await kc.submitTask(l),yield*l.getResult()},async*callT({description:e,prompt:t,model_name:r,subagent_type:n,run_in_background:o,isolation:i},{abortController:s,options:{dangerouslySkipPermissions:a=!1,verbose:c},readFileTimestamps:l,hookContext:u},d,p,f){let A=null;Ye.onQueryStart(p,{agentType:n||"task-agent",agentName:e||p,description:e});let h=Date.now(),_=n||"general-purpose",T=t,y,I=r||"task",v=null,x;if(_){let le=await mx(_);if(!le){let Ue=await dy(),Te=`Agent type '${_}' not found.
2649
2649
 
2650
2650
  Available agents:
2651
2651
  ${Ue.map(re=>` \u2022 ${re}`).join(`
@@ -3129,7 +3129,7 @@ user: "Hello"
3129
3129
  Since the user is greeting, use the greeting-responder agent to respond with a friendly joke
3130
3130
  </commentary>
3131
3131
  assistant: "I'm going to use the ${en} tool to launch the greeting-responder agent"
3132
- </example>`}gA();He();xr();mA();Zo();f_();va();Yr();var y9o=ze(()=>oe.object({description:oe.string().describe("A short (3-5 word) description of the task"),prompt:oe.string().describe("The task for the agent to perform"),model_name:oe.string().optional().describe("Optional: Specific model name to use for this task. If not provided, uses the default task model pointer."),subagent_type:oe.string().optional().describe("The type of specialized agent to use for this task"),resume:oe.string().optional().describe("Optional agent ID to resume from. If provided, the agent will continue from the previous execution transcript."),run_in_background:oe.boolean().optional().describe("Set to true to run this agent in the background. Use TaskOutput to read the output later."),name:oe.string().optional().describe("Name for the spawned agent"),team_name:oe.string().optional().describe("Team name for spawning. Uses current team context if omitted."),mode:oe.enum(["acceptEdits","bypassPermissions","default","dontAsk","plan"]).optional().describe('Permission mode for spawned teammate (e.g., "plan" to require plan approval).'),isolation:oe.enum(["worktree"]).optional().describe('Isolation mode. "worktree" creates a temporary git worktree so the agent works on an isolated copy of the repo.')})),PTe={async prompt({dangerouslySkipPermissions:e}){return await v1r(e)},name:y1r,async description(){return C1r},get inputSchema(){return y9o()},async*call(e,t,r){let{run_in_background:n,description:o,prompt:i,resume:s,name:a,team_name:c,mode:l="default",isolation:u}=e,d=this,p=c,f=a,A=new Ob(o,n).id,h=!!(p?.trim()&&f?.trim());if(h){n=!0;try{await On.getTeam(p)&&(await On.getMember(p,a)||await On.addMember(p,{name:a,taskId:A,agentType:e.subagent_type||"general-purpose",model:e.model_name||"inherit",prompt:i,color:"blue",planModeRequired:l==="plan",subscriptions:[],cwd:Le(),backendType:"in-process",state:"running"}))}catch(y){console.warn(`Failed to register agent ${a} to team ${p}:`,y)}}let _=new Ob(o,n);_.id=A,_.isTeamMember=h,_.teamName=c,_.memberName=a,_.prompt=i||"",s&&_.setId(s),_.link(t.abortController),t.abortController=_.controller;let T=async function*(){for await(let y of d.runTeamAgent(e,t,r,_.id,s!==void 0,p,f,h))yield y};_.callable=T,_=await kc.submitTask(_),yield*_.getResult()},async*runTeamAgent({description:e,prompt:t,model_name:r,subagent_type:n,run_in_background:o,name:i,team_name:s,mode:a,isolation:c},{abortController:l,options:{dangerouslySkipPermissions:u=!1,verbose:d},readFileTimestamps:p,hookContext:f},A,h,_,T,y,I){Ye.onQueryStart(h);let v=null,x=Date.now(),B=n||"general-purpose",F=t,L,P=r||"task",q=null,z;if(B){let nt=await mx(B);if(!nt){let et=await dy(),Xe=`Agent type '${B}' not found.
3132
+ </example>`}gA();He();xr();mA();Zo();f_();va();Yr();var y9o=ze(()=>oe.object({description:oe.string().describe("A short (3-5 word) description of the task"),prompt:oe.string().describe("The task for the agent to perform"),model_name:oe.string().optional().describe("Optional: Specific model name to use for this task. If not provided, uses the default task model pointer."),subagent_type:oe.string().optional().describe("The type of specialized agent to use for this task"),resume:oe.string().optional().describe("Optional agent ID to resume from. If provided, the agent will continue from the previous execution transcript."),run_in_background:oe.boolean().optional().describe("Set to true to run this agent in the background. Use TaskOutput to read the output later."),name:oe.string().optional().describe("Name for the spawned agent"),team_name:oe.string().optional().describe("Team name for spawning. Uses current team context if omitted."),mode:oe.enum(["acceptEdits","bypassPermissions","default","dontAsk","plan"]).optional().describe('Permission mode for spawned teammate (e.g., "plan" to require plan approval).'),isolation:oe.enum(["worktree"]).optional().describe('Isolation mode. "worktree" creates a temporary git worktree so the agent works on an isolated copy of the repo.')})),PTe={async prompt({dangerouslySkipPermissions:e}){return await v1r(e)},name:y1r,async description(){return C1r},get inputSchema(){return y9o()},async*call(e,t,r){let{run_in_background:n,description:o,prompt:i,resume:s,name:a,team_name:c,mode:l="default",isolation:u}=e,d=this,p=c,f=a,A=new Ob(o,n).id,h=!!(p?.trim()&&f?.trim());if(h){n=!0;try{await On.getTeam(p)&&(await On.getMember(p,a)||await On.addMember(p,{name:a,taskId:A,agentType:e.subagent_type||"general-purpose",model:e.model_name||"inherit",prompt:i,color:"blue",planModeRequired:l==="plan",subscriptions:[],cwd:Le(),backendType:"in-process",state:"running"}))}catch(y){console.warn(`Failed to register agent ${a} to team ${p}:`,y)}}let _=new Ob(o,n);_.id=A,_.isTeamMember=h,_.teamName=c,_.memberName=a,_.prompt=i||"",s&&_.setId(s),_.link(t.abortController),t.abortController=_.controller;let T=async function*(){for await(let y of d.runTeamAgent(e,t,r,_.id,s!==void 0,p,f,h))yield y};_.callable=T,_=await kc.submitTask(_),yield*_.getResult()},async*runTeamAgent({description:e,prompt:t,model_name:r,subagent_type:n,run_in_background:o,name:i,team_name:s,mode:a,isolation:c},{abortController:l,options:{dangerouslySkipPermissions:u=!1,verbose:d},readFileTimestamps:p,hookContext:f},A,h,_,T,y,I){Ye.onQueryStart(h,{agentType:n||"team-agent",agentName:i||e||h,description:e});let v=null,x=Date.now(),B=n||"general-purpose",F=t,L,P=r||"task",q=null,z;if(B){let nt=await mx(B);if(!nt){let et=await dy(),Xe=`Agent type '${B}' not found.
3133
3133
 
3134
3134
  Available agents:
3135
3135
  ${et.map(lt=>` \u2022 ${lt}`).join(`
@@ -3359,7 +3359,7 @@ user: "Hello"
3359
3359
  Since the user is greeting, use the greeting-responder agent to respond with a friendly joke
3360
3360
  </commentary>
3361
3361
  assistant: "I'm going to use the ${en} tool to launch the greeting-responder agent"
3362
- </example>`}He();xr();mA();Zo();Yr();vm();f_();va();gA();var bXe={fixToolsDisabled:!1},B7=class{input;context;canUseTool;runInBackground;options;constructor(t,r,n,o=!1,i){this.input=t,this.context=r,this.canUseTool=n,this.runInBackground=o,this.options={...bXe,...i}}},k7=class{prompt;systemPromt;context;canUseTool;runInBackground;options;constructor(t,r,n,o,i=!1,s){this.prompt=t,this.systemPromt=r,this.context=n,this.canUseTool=o,this.runInBackground=i,this.options={...bXe,...s}}toAgentInfo(){let t={description:"",prompt:this.prompt,model_name:null,subagent_type:null,run_in_background:!1,isolation:null,resume:null},r={...this.context,freezeSystemPrompt:this.systemPromt,historyMessages:[]};return new B7(t,r,this.canUseTool,this.runInBackground,this.options)}},D4=class{config;runInBackground=!1;backgroundResolver=null;backgroundPromise=null;id;inTaskExecutor=!1;constructor(t,r=null){t instanceof k7?this.config=t.toAgentInfo():this.config=t,this.runInBackground=this.config.runInBackground||!1,this.config.input.resume&&(this.id=this.config.input.resume),r&&(this.id=r),this.id||(this.id=VR())}async*runAgent(){this.inTaskExecutor=!0;for await(let t of this.call(this.config.input,this.config.context,this.config.canUseTool,this.config.options))yield t}async*call(t,r,n,o={...bXe}){let{description:i,team_name:s,name:a,prompt:c,model_name:l,subagent_type:u,run_in_background:d,isolation:p}=t,{abortController:f,options:{dangerouslySkipPermissions:A=!1,verbose:h},readFileTimestamps:_,hookContext:T}=r,y=this.id,I=t.resume!==void 0,v=s&&a;if(v){let{success:et,message:Xe}=await vHo(t,y);if(!et){yield{type:"result",data:[{type:"text",text:Xe}],resultForAssistant:Xe},Ye.onQueryEnd(y);return}}let x=null;(d||v)&&this.switchRunInBackground(),Ye.onQueryStart(y);let B=Date.now(),F=u,L=c,P,q=l||"task",z=null,fe,te=[],U=[];if(F){let et=await mx(F);if(!et){let Xe=await dy(),lt=`Agent type '${F}' not found.
3362
+ </example>`}He();xr();mA();Zo();Yr();vm();f_();va();gA();var bXe={fixToolsDisabled:!1},B7=class{input;context;canUseTool;runInBackground;options;constructor(t,r,n,o=!1,i){this.input=t,this.context=r,this.canUseTool=n,this.runInBackground=o,this.options={...bXe,...i}}},k7=class{prompt;systemPromt;context;canUseTool;runInBackground;options;constructor(t,r,n,o,i=!1,s){this.prompt=t,this.systemPromt=r,this.context=n,this.canUseTool=o,this.runInBackground=i,this.options={...bXe,...s}}toAgentInfo(){let t={description:"",prompt:this.prompt,model_name:null,subagent_type:null,run_in_background:!1,isolation:null,resume:null},r={...this.context,freezeSystemPrompt:this.systemPromt,historyMessages:[]};return new B7(t,r,this.canUseTool,this.runInBackground,this.options)}},D4=class{config;runInBackground=!1;backgroundResolver=null;backgroundPromise=null;id;inTaskExecutor=!1;constructor(t,r=null){t instanceof k7?this.config=t.toAgentInfo():this.config=t,this.runInBackground=this.config.runInBackground||!1,this.config.input.resume&&(this.id=this.config.input.resume),r&&(this.id=r),this.id||(this.id=VR())}async*runAgent(){this.inTaskExecutor=!0;for await(let t of this.call(this.config.input,this.config.context,this.config.canUseTool,this.config.options))yield t}async*call(t,r,n,o={...bXe}){let{description:i,team_name:s,name:a,prompt:c,model_name:l,subagent_type:u,run_in_background:d,isolation:p}=t,{abortController:f,options:{dangerouslySkipPermissions:A=!1,verbose:h},readFileTimestamps:_,hookContext:T}=r,y=this.id,I=t.resume!==void 0,v=s&&a;if(v){let{success:et,message:Xe}=await vHo(t,y);if(!et){yield{type:"result",data:[{type:"text",text:Xe}],resultForAssistant:Xe},Ye.onQueryEnd(y);return}}let x=null;(d||v)&&this.switchRunInBackground(),Ye.onQueryStart(y,{agentType:u||(v?"team-agent":void 0),agentName:a||i||y,description:i});let B=Date.now(),F=u,L=c,P,q=l||"task",z=null,fe,te=[],U=[];if(F){let et=await mx(F);if(!et){let Xe=await dy(),lt=`Agent type '${F}' not found.
3363
3363
 
3364
3364
  Available agents:
3365
3365
  ${Xe.map(Ot=>` \u2022 ${Ot}`).join(`
@@ -3475,7 +3475,7 @@ ARGUMENTS: ${t.join(" ")}`);let s=/!`([^`]+)`/g,a=[...r.matchAll(s)];for(let c=a
3475
3475
  ${l}`],data:x}}catch(v){let F={message:`<error>${n.signal.aborted?"Skill execution was cancelled":`Skill execution failed: ${v instanceof Error?v.message:String(v)}`}</error>`,skillName:e,baseDirectory:null};yield{type:"result",resultForAssistant:this.renderResultForAssistant(F),data:F}}return}let u=Date.now(),d=`Base directory for this skill: ${c.path}
3476
3476
 
3477
3477
  ${l}
3478
- `,p=[At(d)];yield{type:"progress",content:pr(Ct.dim("Initializing\u2026")),normalizedMessages:ao(p),tools:i};let A=[await(await mx(c.metadata.agent||"general-purpos")).getSystemPrompt()],[h,_]=await Promise.all([Ti(),Pc()]),T=0,y=ze(()=>0),I=VR();Ye.onQueryStart(I),b2(c.metadata.allowedTools,I);try{for await(let P of x_(p,A,h,ex,{abortController:n,options:{dangerouslySkipPermissions:o,tools:i,commands:[],verbose:s,slowAndCapableModel:_,thinking:wt().thinking},readFileTimestamps:a,agentId:I})){if(p.push(P),Qg(p.filter(z=>z.type!=="progress"),I),P.type!=="assistant")continue;let q=ao(p);for(let z of P.message.content)z.type==="tool_use"&&(T++,yield{type:"progress",content:q.find(fe=>fe.type==="assistant"&&fe.message.content[0]?.type==="tool_use"&&fe.message.content[0].id===z.id),normalizedMessages:q,tools:i})}let v=ao(p),x=gp(p);if(x?.type!=="assistant")throw new Error("Last message was not an assistant message");if(x.message.content.some(P=>P.type==="text"&&P.text===Vc))yield{type:"progress",content:x,normalizedMessages:v,tools:i};else{let P=[T===1?"1 tool use":`${T} tool uses`,m0((x.message.usage.cache_creation_input_tokens??0)+(x.message.usage.cache_read_input_tokens??0)+x.message.usage.input_tokens+x.message.usage.output_tokens)+" tokens",rS(Date.now()-u)];yield{type:"progress",content:pr(`Done (${P.join(" \xB7 ")})`),normalizedMessages:v,tools:i}}let F=x.message.content.filter(P=>P.type==="text").map(P=>P.text).join(`
3478
+ `,p=[At(d)];yield{type:"progress",content:pr(Ct.dim("Initializing\u2026")),normalizedMessages:ao(p),tools:i};let A=[await(await mx(c.metadata.agent||"general-purpos")).getSystemPrompt()],[h,_]=await Promise.all([Ti(),Pc()]),T=0,y=ze(()=>0),I=VR();Ye.onQueryStart(I,{agentType:c.metadata.agent||"skill-agent",agentName:`skill:${e}`,description:c.metadata.description||`Skill: ${e}`}),b2(c.metadata.allowedTools,I);try{for await(let P of x_(p,A,h,ex,{abortController:n,options:{dangerouslySkipPermissions:o,tools:i,commands:[],verbose:s,slowAndCapableModel:_,thinking:wt().thinking},readFileTimestamps:a,agentId:I})){if(p.push(P),Qg(p.filter(z=>z.type!=="progress"),I),P.type!=="assistant")continue;let q=ao(p);for(let z of P.message.content)z.type==="tool_use"&&(T++,yield{type:"progress",content:q.find(fe=>fe.type==="assistant"&&fe.message.content[0]?.type==="tool_use"&&fe.message.content[0].id===z.id),normalizedMessages:q,tools:i})}let v=ao(p),x=gp(p);if(x?.type!=="assistant")throw new Error("Last message was not an assistant message");if(x.message.content.some(P=>P.type==="text"&&P.text===Vc))yield{type:"progress",content:x,normalizedMessages:v,tools:i};else{let P=[T===1?"1 tool use":`${T} tool uses`,m0((x.message.usage.cache_creation_input_tokens??0)+(x.message.usage.cache_read_input_tokens??0)+x.message.usage.input_tokens+x.message.usage.output_tokens)+" tokens",rS(Date.now()-u)];yield{type:"progress",content:pr(`Done (${P.join(" \xB7 ")})`),normalizedMessages:v,tools:i}}let F=x.message.content.filter(P=>P.type==="text").map(P=>P.text).join(`
3479
3479
  `),L={fork:!0,message:`Skill "${e}" completed (forked execution).
3480
3480
 
3481
3481
  Result: