node-fetch-native
Version:
better fetch for Node.js. Works on any JavaScript runtime!
1 lines • 464 kB
JavaScript
"use strict";var le=Object.defineProperty;var e=(A,p)=>le(A,"name",{value:p,configurable:!0});const http=require("node:http"),https=require("node:https"),require$$1$1=require("node:url"),require$$0=require("node:assert"),require$$0$1=require("node:net"),Stream=require("node:stream"),require$$0$2=require("node:buffer"),require$$0$3=require("node:util"),require$$7=require("node:querystring"),require$$8=require("node:events"),require$$0$4=require("node:diagnostics_channel"),_commonjsHelpers=require("./shared/node-fetch-native.DhEqb06g.cjs"),require$$5=require("node:tls"),zlib=require("node:zlib"),require$$5$1=require("node:perf_hooks"),require$$8$1=require("node:util/types"),require$$1=require("node:worker_threads"),require$$5$2=require("node:async_hooks"),require$$1$2=require("node:console"),require$$1$3=require("node:dns"),require$$5$3=require("string_decoder"),require$$0$6=require("net"),require$$0$5=require("http"),require$$1$4=require("https"),require$$1$7=require("tls"),require$$1$5=require("tty"),require$$1$6=require("util"),require$$0$7=require("os"),require$$3=require("events"),require$$5$4=require("url"),require$$2=require("assert"),nodeFetchNative=require("node-fetch-native");function _interopDefaultCompat(A){return A&&typeof A=="object"&&"default"in A?A.default:A}e(_interopDefaultCompat,"_interopDefaultCompat");function _interopNamespaceCompat(A){if(A&&typeof A=="object"&&"default"in A)return A;const p=Object.create(null);if(A)for(const c in A)p[c]=A[c];return p.default=A,p}e(_interopNamespaceCompat,"_interopNamespaceCompat");const http__default=_interopDefaultCompat(http),http__namespace=_interopNamespaceCompat(http),https__namespace=_interopNamespaceCompat(https),require$$1__default$1=_interopDefaultCompat(require$$1$1),require$$0__default=_interopDefaultCompat(require$$0),require$$0__default$1=_interopDefaultCompat(require$$0$1),Stream__default=_interopDefaultCompat(Stream),require$$0__default$2=_interopDefaultCompat(require$$0$2),require$$0__default$3=_interopDefaultCompat(require$$0$3),require$$7__default=_interopDefaultCompat(require$$7),require$$8__default=_interopDefaultCompat(require$$8),require$$0__default$4=_interopDefaultCompat(require$$0$4),require$$5__default=_interopDefaultCompat(require$$5),zlib__default=_interopDefaultCompat(zlib),require$$5__default$1=_interopDefaultCompat(require$$5$1),require$$8__default$1=_interopDefaultCompat(require$$8$1),require$$1__default=_interopDefaultCompat(require$$1),require$$5__default$2=_interopDefaultCompat(require$$5$2),require$$1__default$2=_interopDefaultCompat(require$$1$2),require$$1__default$3=_interopDefaultCompat(require$$1$3),require$$5__default$3=_interopDefaultCompat(require$$5$3),require$$0__default$6=_interopDefaultCompat(require$$0$6),require$$0__default$5=_interopDefaultCompat(require$$0$5),require$$1__default$4=_interopDefaultCompat(require$$1$4),require$$1__default$7=_interopDefaultCompat(require$$1$7),require$$1__default$5=_interopDefaultCompat(require$$1$5),require$$1__default$6=_interopDefaultCompat(require$$1$6),require$$0__default$7=_interopDefaultCompat(require$$0$7),require$$3__default=_interopDefaultCompat(require$$3),require$$5__default$4=_interopDefaultCompat(require$$5$4),require$$2__default=_interopDefaultCompat(require$$2);var undici={},symbols$4,hasRequiredSymbols$4;function requireSymbols$4(){return hasRequiredSymbols$4||(hasRequiredSymbols$4=1,symbols$4={kClose:Symbol("close"),kDestroy:Symbol("destroy"),kDispatch:Symbol("dispatch"),kUrl:Symbol("url"),kWriting:Symbol("writing"),kResuming:Symbol("resuming"),kQueue:Symbol("queue"),kConnect:Symbol("connect"),kConnecting:Symbol("connecting"),kKeepAliveDefaultTimeout:Symbol("default keep alive timeout"),kKeepAliveMaxTimeout:Symbol("max keep alive timeout"),kKeepAliveTimeoutThreshold:Symbol("keep alive timeout threshold"),kKeepAliveTimeoutValue:Symbol("keep alive timeout"),kKeepAlive:Symbol("keep alive"),kHeadersTimeout:Symbol("headers timeout"),kBodyTimeout:Symbol("body timeout"),kServerName:Symbol("server name"),kLocalAddress:Symbol("local address"),kHost:Symbol("host"),kNoRef:Symbol("no ref"),kBodyUsed:Symbol("used"),kBody:Symbol("abstracted request body"),kRunning:Symbol("running"),kBlocking:Symbol("blocking"),kPending:Symbol("pending"),kSize:Symbol("size"),kBusy:Symbol("busy"),kQueued:Symbol("queued"),kFree:Symbol("free"),kConnected:Symbol("connected"),kClosed:Symbol("closed"),kNeedDrain:Symbol("need drain"),kReset:Symbol("reset"),kDestroyed:Symbol.for("nodejs.stream.destroyed"),kResume:Symbol("resume"),kOnError:Symbol("on error"),kMaxHeadersSize:Symbol("max headers size"),kRunningIdx:Symbol("running index"),kPendingIdx:Symbol("pending index"),kError:Symbol("error"),kClients:Symbol("clients"),kClient:Symbol("client"),kParser:Symbol("parser"),kOnDestroyed:Symbol("destroy callbacks"),kPipelining:Symbol("pipelining"),kSocket:Symbol("socket"),kHostHeader:Symbol("host header"),kConnector:Symbol("connector"),kStrictContentLength:Symbol("strict content length"),kMaxRedirections:Symbol("maxRedirections"),kMaxRequests:Symbol("maxRequestsPerClient"),kProxy:Symbol("proxy agent options"),kCounter:Symbol("socket request counter"),kInterceptors:Symbol("dispatch interceptors"),kMaxResponseSize:Symbol("max response size"),kHTTP2Session:Symbol("http2Session"),kHTTP2SessionState:Symbol("http2Session state"),kRetryHandlerDefaultRetry:Symbol("retry agent default retry"),kConstruct:Symbol("constructable"),kListeners:Symbol("listeners"),kHTTPContext:Symbol("http context"),kMaxConcurrentStreams:Symbol("max concurrent streams"),kNoProxyAgent:Symbol("no proxy agent"),kHttpProxyAgent:Symbol("http proxy agent"),kHttpsProxyAgent:Symbol("https proxy agent")}),symbols$4}e(requireSymbols$4,"requireSymbols$4");var errors,hasRequiredErrors;function requireErrors(){if(hasRequiredErrors)return errors;hasRequiredErrors=1;class A extends Error{static{e(this,"UndiciError")}constructor(k){super(k),this.name="UndiciError",this.code="UND_ERR"}}class p extends A{static{e(this,"ConnectTimeoutError")}constructor(k){super(k),this.name="ConnectTimeoutError",this.message=k||"Connect Timeout Error",this.code="UND_ERR_CONNECT_TIMEOUT"}}class c extends A{static{e(this,"HeadersTimeoutError")}constructor(k){super(k),this.name="HeadersTimeoutError",this.message=k||"Headers Timeout Error",this.code="UND_ERR_HEADERS_TIMEOUT"}}class E extends A{static{e(this,"HeadersOverflowError")}constructor(k){super(k),this.name="HeadersOverflowError",this.message=k||"Headers Overflow Error",this.code="UND_ERR_HEADERS_OVERFLOW"}}class t extends A{static{e(this,"BodyTimeoutError")}constructor(k){super(k),this.name="BodyTimeoutError",this.message=k||"Body Timeout Error",this.code="UND_ERR_BODY_TIMEOUT"}}class B extends A{static{e(this,"ResponseStatusCodeError")}constructor(k,i,F,m){super(k),this.name="ResponseStatusCodeError",this.message=k||"Response Status Code Error",this.code="UND_ERR_RESPONSE_STATUS_CODE",this.body=m,this.status=i,this.statusCode=i,this.headers=F}}class f extends A{static{e(this,"InvalidArgumentError")}constructor(k){super(k),this.name="InvalidArgumentError",this.message=k||"Invalid Argument Error",this.code="UND_ERR_INVALID_ARG"}}class l extends A{static{e(this,"InvalidReturnValueError")}constructor(k){super(k),this.name="InvalidReturnValueError",this.message=k||"Invalid Return Value Error",this.code="UND_ERR_INVALID_RETURN_VALUE"}}class Q extends A{static{e(this,"AbortError")}constructor(k){super(k),this.name="AbortError",this.message=k||"The operation was aborted"}}class u extends Q{static{e(this,"RequestAbortedError")}constructor(k){super(k),this.name="AbortError",this.message=k||"Request aborted",this.code="UND_ERR_ABORTED"}}class n extends A{static{e(this,"InformationalError")}constructor(k){super(k),this.name="InformationalError",this.message=k||"Request information",this.code="UND_ERR_INFO"}}class r extends A{static{e(this,"RequestContentLengthMismatchError")}constructor(k){super(k),this.name="RequestContentLengthMismatchError",this.message=k||"Request body length does not match content-length header",this.code="UND_ERR_REQ_CONTENT_LENGTH_MISMATCH"}}class o extends A{static{e(this,"ResponseContentLengthMismatchError")}constructor(k){super(k),this.name="ResponseContentLengthMismatchError",this.message=k||"Response body length does not match content-length header",this.code="UND_ERR_RES_CONTENT_LENGTH_MISMATCH"}}class a extends A{static{e(this,"ClientDestroyedError")}constructor(k){super(k),this.name="ClientDestroyedError",this.message=k||"The client is destroyed",this.code="UND_ERR_DESTROYED"}}class g extends A{static{e(this,"ClientClosedError")}constructor(k){super(k),this.name="ClientClosedError",this.message=k||"The client is closed",this.code="UND_ERR_CLOSED"}}class d extends A{static{e(this,"SocketError")}constructor(k,i){super(k),this.name="SocketError",this.message=k||"Socket error",this.code="UND_ERR_SOCKET",this.socket=i}}class N extends A{static{e(this,"NotSupportedError")}constructor(k){super(k),this.name="NotSupportedError",this.message=k||"Not supported error",this.code="UND_ERR_NOT_SUPPORTED"}}class M extends A{static{e(this,"BalancedPoolMissingUpstreamError")}constructor(k){super(k),this.name="MissingUpstreamError",this.message=k||"No upstream has been added to the BalancedPool",this.code="UND_ERR_BPL_MISSING_UPSTREAM"}}class Y extends Error{static{e(this,"HTTPParserError")}constructor(k,i,F){super(k),this.name="HTTPParserError",this.code=i?`HPE_${i}`:void 0,this.data=F?F.toString():void 0}}class J extends A{static{e(this,"ResponseExceededMaxSizeError")}constructor(k){super(k),this.name="ResponseExceededMaxSizeError",this.message=k||"Response content exceeded max size",this.code="UND_ERR_RES_EXCEEDED_MAX_SIZE"}}class V extends A{static{e(this,"RequestRetryError")}constructor(k,i,{headers:F,data:m}){super(k),this.name="RequestRetryError",this.message=k||"Request retry error",this.code="UND_ERR_REQ_RETRY",this.statusCode=i,this.data=m,this.headers=F}}class H extends A{static{e(this,"ResponseError")}constructor(k,i,{headers:F,data:m}){super(k),this.name="ResponseError",this.message=k||"Response error",this.code="UND_ERR_RESPONSE",this.statusCode=i,this.data=m,this.headers=F}}class h extends A{static{e(this,"SecureProxyConnectionError")}constructor(k,i,F){super(i,{cause:k,...F??{}}),this.name="SecureProxyConnectionError",this.message=i||"Secure Proxy Connection failed",this.code="UND_ERR_PRX_TLS",this.cause=k}}return errors={AbortError:Q,HTTPParserError:Y,UndiciError:A,HeadersTimeoutError:c,HeadersOverflowError:E,BodyTimeoutError:t,RequestContentLengthMismatchError:r,ConnectTimeoutError:p,ResponseStatusCodeError:B,InvalidArgumentError:f,InvalidReturnValueError:l,RequestAbortedError:u,ClientDestroyedError:a,ClientClosedError:g,InformationalError:n,SocketError:d,NotSupportedError:N,ResponseContentLengthMismatchError:o,BalancedPoolMissingUpstreamError:M,ResponseExceededMaxSizeError:J,RequestRetryError:V,ResponseError:H,SecureProxyConnectionError:h},errors}e(requireErrors,"requireErrors");var constants$4,hasRequiredConstants$4;function requireConstants$4(){if(hasRequiredConstants$4)return constants$4;hasRequiredConstants$4=1;const A={},p=["Accept","Accept-Encoding","Accept-Language","Accept-Ranges","Access-Control-Allow-Credentials","Access-Control-Allow-Headers","Access-Control-Allow-Methods","Access-Control-Allow-Origin","Access-Control-Expose-Headers","Access-Control-Max-Age","Access-Control-Request-Headers","Access-Control-Request-Method","Age","Allow","Alt-Svc","Alt-Used","Authorization","Cache-Control","Clear-Site-Data","Connection","Content-Disposition","Content-Encoding","Content-Language","Content-Length","Content-Location","Content-Range","Content-Security-Policy","Content-Security-Policy-Report-Only","Content-Type","Cookie","Cross-Origin-Embedder-Policy","Cross-Origin-Opener-Policy","Cross-Origin-Resource-Policy","Date","Device-Memory","Downlink","ECT","ETag","Expect","Expect-CT","Expires","Forwarded","From","Host","If-Match","If-Modified-Since","If-None-Match","If-Range","If-Unmodified-Since","Keep-Alive","Last-Modified","Link","Location","Max-Forwards","Origin","Permissions-Policy","Pragma","Proxy-Authenticate","Proxy-Authorization","RTT","Range","Referer","Referrer-Policy","Refresh","Retry-After","Sec-WebSocket-Accept","Sec-WebSocket-Extensions","Sec-WebSocket-Key","Sec-WebSocket-Protocol","Sec-WebSocket-Version","Server","Server-Timing","Service-Worker-Allowed","Service-Worker-Navigation-Preload","Set-Cookie","SourceMap","Strict-Transport-Security","Supports-Loading-Mode","TE","Timing-Allow-Origin","Trailer","Transfer-Encoding","Upgrade","Upgrade-Insecure-Requests","User-Agent","Vary","Via","WWW-Authenticate","X-Content-Type-Options","X-DNS-Prefetch-Control","X-Frame-Options","X-Permitted-Cross-Domain-Policies","X-Powered-By","X-Requested-With","X-XSS-Protection"];for(let c=0;c<p.length;++c){const E=p[c],t=E.toLowerCase();A[E]=A[t]=t}return Object.setPrototypeOf(A,null),constants$4={wellknownHeaderNames:p,headerNameLowerCasedRecord:A},constants$4}e(requireConstants$4,"requireConstants$4");var tree_1,hasRequiredTree;function requireTree(){if(hasRequiredTree)return tree_1;hasRequiredTree=1;const{wellknownHeaderNames:A,headerNameLowerCasedRecord:p}=requireConstants$4();class c{static{e(this,"TstNode")}value=null;left=null;middle=null;right=null;code;constructor(f,l,Q){if(Q===void 0||Q>=f.length)throw new TypeError("Unreachable");if((this.code=f.charCodeAt(Q))>127)throw new TypeError("key must be ascii string");f.length!==++Q?this.middle=new c(f,l,Q):this.value=l}add(f,l){const Q=f.length;if(Q===0)throw new TypeError("Unreachable");let u=0,n=this;for(;;){const r=f.charCodeAt(u);if(r>127)throw new TypeError("key must be ascii string");if(n.code===r)if(Q===++u){n.value=l;break}else if(n.middle!==null)n=n.middle;else{n.middle=new c(f,l,u);break}else if(n.code<r)if(n.left!==null)n=n.left;else{n.left=new c(f,l,u);break}else if(n.right!==null)n=n.right;else{n.right=new c(f,l,u);break}}}search(f){const l=f.length;let Q=0,u=this;for(;u!==null&&Q<l;){let n=f[Q];for(n<=90&&n>=65&&(n|=32);u!==null;){if(n===u.code){if(l===++Q)return u;u=u.middle;break}u=u.code<n?u.left:u.right}}return null}}class E{static{e(this,"TernarySearchTree")}node=null;insert(f,l){this.node===null?this.node=new c(f,l,0):this.node.add(f,l)}lookup(f){return this.node?.search(f)?.value??null}}const t=new E;for(let B=0;B<A.length;++B){const f=p[A[B]];t.insert(f,f)}return tree_1={TernarySearchTree:E,tree:t},tree_1}e(requireTree,"requireTree");var util$7,hasRequiredUtil$7;function requireUtil$7(){if(hasRequiredUtil$7)return util$7;hasRequiredUtil$7=1;const A=require$$0__default,{kDestroyed:p,kBodyUsed:c,kListeners:E,kBody:t}=requireSymbols$4(),{IncomingMessage:B}=http__default,f=Stream__default,l=require$$0__default$1,{Blob:Q}=require$$0__default$2,u=require$$0__default$3,{stringify:n}=require$$7__default,{EventEmitter:r}=require$$8__default,{InvalidArgumentError:o}=requireErrors(),{headerNameLowerCasedRecord:a}=requireConstants$4(),{tree:g}=requireTree(),[d,N]=process.versions.node.split(".").map(L=>Number(L));class M{static{e(this,"BodyAsyncIterable")}constructor(AA){this[t]=AA,this[c]=!1}async*[Symbol.asyncIterator](){A(!this[c],"disturbed"),this[c]=!0,yield*this[t]}}function Y(L){return V(L)?(O(L)===0&&L.on("data",function(){A(!1)}),typeof L.readableDidRead!="boolean"&&(L[c]=!1,r.prototype.on.call(L,"data",function(){this[c]=!0})),L):L&&typeof L.pipeTo=="function"?new M(L):L&&typeof L!="string"&&!ArrayBuffer.isView(L)&&q(L)?new M(L):L}e(Y,"wrapRequestBody");function J(){}e(J,"nop");function V(L){return L&&typeof L=="object"&&typeof L.pipe=="function"&&typeof L.on=="function"}e(V,"isStream");function H(L){if(L===null)return!1;if(L instanceof Q)return!0;if(typeof L!="object")return!1;{const AA=L[Symbol.toStringTag];return(AA==="Blob"||AA==="File")&&("stream"in L&&typeof L.stream=="function"||"arrayBuffer"in L&&typeof L.arrayBuffer=="function")}}e(H,"isBlobLike");function h(L,AA){if(L.includes("?")||L.includes("#"))throw new Error('Query params cannot be passed when url already contains "?" or "#".');const IA=n(AA);return IA&&(L+="?"+IA),L}e(h,"buildURL");function I(L){const AA=parseInt(L,10);return AA===Number(L)&&AA>=0&&AA<=65535}e(I,"isValidPort");function k(L){return L!=null&&L[0]==="h"&&L[1]==="t"&&L[2]==="t"&&L[3]==="p"&&(L[4]===":"||L[4]==="s"&&L[5]===":")}e(k,"isHttpOrHttpsPrefixed");function i(L){if(typeof L=="string"){if(L=new URL(L),!k(L.origin||L.protocol))throw new o("Invalid URL protocol: the URL must start with `http:` or `https:`.");return L}if(!L||typeof L!="object")throw new o("Invalid URL: The URL argument must be a non-null object.");if(!(L instanceof URL)){if(L.port!=null&&L.port!==""&&I(L.port)===!1)throw new o("Invalid URL: port must be a valid integer or a string representation of an integer.");if(L.path!=null&&typeof L.path!="string")throw new o("Invalid URL path: the path must be a string or null/undefined.");if(L.pathname!=null&&typeof L.pathname!="string")throw new o("Invalid URL pathname: the pathname must be a string or null/undefined.");if(L.hostname!=null&&typeof L.hostname!="string")throw new o("Invalid URL hostname: the hostname must be a string or null/undefined.");if(L.origin!=null&&typeof L.origin!="string")throw new o("Invalid URL origin: the origin must be a string or null/undefined.");if(!k(L.origin||L.protocol))throw new o("Invalid URL protocol: the URL must start with `http:` or `https:`.");const AA=L.port!=null?L.port:L.protocol==="https:"?443:80;let IA=L.origin!=null?L.origin:`${L.protocol||""}//${L.hostname||""}:${AA}`,wA=L.path!=null?L.path:`${L.pathname||""}${L.search||""}`;return IA[IA.length-1]==="/"&&(IA=IA.slice(0,IA.length-1)),wA&&wA[0]!=="/"&&(wA=`/${wA}`),new URL(`${IA}${wA}`)}if(!k(L.origin||L.protocol))throw new o("Invalid URL protocol: the URL must start with `http:` or `https:`.");return L}e(i,"parseURL");function F(L){if(L=i(L),L.pathname!=="/"||L.search||L.hash)throw new o("invalid url");return L}e(F,"parseOrigin");function m(L){if(L[0]==="["){const IA=L.indexOf("]");return A(IA!==-1),L.substring(1,IA)}const AA=L.indexOf(":");return AA===-1?L:L.substring(0,AA)}e(m,"getHostname");function D(L){if(!L)return null;A(typeof L=="string");const AA=m(L);return l.isIP(AA)?"":AA}e(D,"getServerName");function S(L){return JSON.parse(JSON.stringify(L))}e(S,"deepClone");function W(L){return L!=null&&typeof L[Symbol.asyncIterator]=="function"}e(W,"isAsyncIterable");function q(L){return L!=null&&(typeof L[Symbol.iterator]=="function"||typeof L[Symbol.asyncIterator]=="function")}e(q,"isIterable");function O(L){if(L==null)return 0;if(V(L)){const AA=L._readableState;return AA&&AA.objectMode===!1&&AA.ended===!0&&Number.isFinite(AA.length)?AA.length:null}else{if(H(L))return L.size!=null?L.size:null;if(DA(L))return L.byteLength}return null}e(O,"bodyLength");function P(L){return L&&!!(L.destroyed||L[p]||f.isDestroyed?.(L))}e(P,"isDestroyed");function Z(L,AA){L==null||!V(L)||P(L)||(typeof L.destroy=="function"?(Object.getPrototypeOf(L).constructor===B&&(L.socket=null),L.destroy(AA)):AA&&queueMicrotask(()=>{L.emit("error",AA)}),L.destroyed!==!0&&(L[p]=!0))}e(Z,"destroy");const cA=/timeout=(\d+)/;function EA(L){const AA=L.toString().match(cA);return AA?parseInt(AA[1],10)*1e3:null}e(EA,"parseKeepAliveTimeout");function fA(L){return typeof L=="string"?a[L]??L.toLowerCase():g.lookup(L)??L.toString("latin1").toLowerCase()}e(fA,"headerNameToString");function uA(L){return g.lookup(L)??L.toString("latin1").toLowerCase()}e(uA,"bufferToLowerCasedHeaderName");function pA(L,AA){AA===void 0&&(AA={});for(let IA=0;IA<L.length;IA+=2){const wA=fA(L[IA]);let FA=AA[wA];if(FA)typeof FA=="string"&&(FA=[FA],AA[wA]=FA),FA.push(L[IA+1].toString("utf8"));else{const MA=L[IA+1];typeof MA=="string"?AA[wA]=MA:AA[wA]=Array.isArray(MA)?MA.map(OA=>OA.toString("utf8")):MA.toString("utf8")}}return"content-length"in AA&&"content-disposition"in AA&&(AA["content-disposition"]=Buffer.from(AA["content-disposition"]).toString("latin1")),AA}e(pA,"parseHeaders");function RA(L){const AA=L.length,IA=new Array(AA);let wA=!1,FA=-1,MA,OA,_A=0;for(let $A=0;$A<L.length;$A+=2)MA=L[$A],OA=L[$A+1],typeof MA!="string"&&(MA=MA.toString()),typeof OA!="string"&&(OA=OA.toString("utf8")),_A=MA.length,_A===14&&MA[7]==="-"&&(MA==="content-length"||MA.toLowerCase()==="content-length")?wA=!0:_A===19&&MA[7]==="-"&&(MA==="content-disposition"||MA.toLowerCase()==="content-disposition")&&(FA=$A+1),IA[$A]=MA,IA[$A+1]=OA;return wA&&FA!==-1&&(IA[FA]=Buffer.from(IA[FA]).toString("latin1")),IA}e(RA,"parseRawHeaders");function DA(L){return L instanceof Uint8Array||Buffer.isBuffer(L)}e(DA,"isBuffer");function TA(L,AA,IA){if(!L||typeof L!="object")throw new o("handler must be an object");if(typeof L.onConnect!="function")throw new o("invalid onConnect method");if(typeof L.onError!="function")throw new o("invalid onError method");if(typeof L.onBodySent!="function"&&L.onBodySent!==void 0)throw new o("invalid onBodySent method");if(IA||AA==="CONNECT"){if(typeof L.onUpgrade!="function")throw new o("invalid onUpgrade method")}else{if(typeof L.onHeaders!="function")throw new o("invalid onHeaders method");if(typeof L.onData!="function")throw new o("invalid onData method");if(typeof L.onComplete!="function")throw new o("invalid onComplete method")}}e(TA,"validateHandler");function UA(L){return!!(L&&(f.isDisturbed(L)||L[c]))}e(UA,"isDisturbed");function QA(L){return!!(L&&f.isErrored(L))}e(QA,"isErrored");function eA(L){return!!(L&&f.isReadable(L))}e(eA,"isReadable");function lA(L){return{localAddress:L.localAddress,localPort:L.localPort,remoteAddress:L.remoteAddress,remotePort:L.remotePort,remoteFamily:L.remoteFamily,timeout:L.timeout,bytesWritten:L.bytesWritten,bytesRead:L.bytesRead}}e(lA,"getSocketInfo");function YA(L){let AA;return new ReadableStream({async start(){AA=L[Symbol.asyncIterator]()},async pull(IA){const{done:wA,value:FA}=await AA.next();if(wA)queueMicrotask(()=>{IA.close(),IA.byobRequest?.respond(0)});else{const MA=Buffer.isBuffer(FA)?FA:Buffer.from(FA);MA.byteLength&&IA.enqueue(new Uint8Array(MA))}return IA.desiredSize>0},async cancel(IA){await AA.return()},type:"bytes"})}e(YA,"ReadableStreamFrom");function nA(L){return L&&typeof L=="object"&&typeof L.append=="function"&&typeof L.delete=="function"&&typeof L.get=="function"&&typeof L.getAll=="function"&&typeof L.has=="function"&&typeof L.set=="function"&&L[Symbol.toStringTag]==="FormData"}e(nA,"isFormDataLike");function $(L,AA){return"addEventListener"in L?(L.addEventListener("abort",AA,{once:!0}),()=>L.removeEventListener("abort",AA)):(L.addListener("abort",AA),()=>L.removeListener("abort",AA))}e($,"addAbortListener");const sA=typeof String.prototype.toWellFormed=="function",BA=typeof String.prototype.isWellFormed=="function";function dA(L){return sA?`${L}`.toWellFormed():u.toUSVString(L)}e(dA,"toUSVString");function CA(L){return BA?`${L}`.isWellFormed():dA(L)===`${L}`}e(CA,"isUSVString");function mA(L){switch(L){case 34:case 40:case 41:case 44:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 123:case 125:return!1;default:return L>=33&&L<=126}}e(mA,"isTokenCharCode");function xA(L){if(L.length===0)return!1;for(let AA=0;AA<L.length;++AA)if(!mA(L.charCodeAt(AA)))return!1;return!0}e(xA,"isValidHTTPToken");const bA=/[^\t\x20-\x7e\x80-\xff]/;function WA(L){return!bA.test(L)}e(WA,"isValidHeaderValue");function LA(L){if(L==null||L==="")return{start:0,end:null,size:null};const AA=L?L.match(/^bytes (\d+)-(\d+)\/(\d+)?$/):null;return AA?{start:parseInt(AA[1]),end:AA[2]?parseInt(AA[2]):null,size:AA[3]?parseInt(AA[3]):null}:null}e(LA,"parseRangeHeader");function GA(L,AA,IA){return(L[E]??=[]).push([AA,IA]),L.on(AA,IA),L}e(GA,"addListener");function NA(L){for(const[AA,IA]of L[E]??[])L.removeListener(AA,IA);L[E]=null}e(NA,"removeAllListeners");function KA(L,AA,IA){try{AA.onError(IA),A(AA.aborted)}catch(wA){L.emit("error",wA)}}e(KA,"errorRequest");const ZA=Object.create(null);ZA.enumerable=!0;const PA={delete:"DELETE",DELETE:"DELETE",get:"GET",GET:"GET",head:"HEAD",HEAD:"HEAD",options:"OPTIONS",OPTIONS:"OPTIONS",post:"POST",POST:"POST",put:"PUT",PUT:"PUT"},oA={...PA,patch:"patch",PATCH:"PATCH"};return Object.setPrototypeOf(PA,null),Object.setPrototypeOf(oA,null),util$7={kEnumerableProperty:ZA,nop:J,isDisturbed:UA,isErrored:QA,isReadable:eA,toUSVString:dA,isUSVString:CA,isBlobLike:H,parseOrigin:F,parseURL:i,getServerName:D,isStream:V,isIterable:q,isAsyncIterable:W,isDestroyed:P,headerNameToString:fA,bufferToLowerCasedHeaderName:uA,addListener:GA,removeAllListeners:NA,errorRequest:KA,parseRawHeaders:RA,parseHeaders:pA,parseKeepAliveTimeout:EA,destroy:Z,bodyLength:O,deepClone:S,ReadableStreamFrom:YA,isBuffer:DA,validateHandler:TA,getSocketInfo:lA,isFormDataLike:nA,buildURL:h,addAbortListener:$,isValidHTTPToken:xA,isValidHeaderValue:WA,isTokenCharCode:mA,parseRangeHeader:LA,normalizedMethodRecordsBase:PA,normalizedMethodRecords:oA,isValidPort:I,isHttpOrHttpsPrefixed:k,nodeMajor:d,nodeMinor:N,safeHTTPMethods:["GET","HEAD","OPTIONS","TRACE"],wrapRequestBody:Y},util$7}e(requireUtil$7,"requireUtil$7");var diagnostics,hasRequiredDiagnostics;function requireDiagnostics(){if(hasRequiredDiagnostics)return diagnostics;hasRequiredDiagnostics=1;const A=require$$0__default$4,p=require$$0__default$3,c=p.debuglog("undici"),E=p.debuglog("fetch"),t=p.debuglog("websocket");let B=!1;const f={beforeConnect:A.channel("undici:client:beforeConnect"),connected:A.channel("undici:client:connected"),connectError:A.channel("undici:client:connectError"),sendHeaders:A.channel("undici:client:sendHeaders"),create:A.channel("undici:request:create"),bodySent:A.channel("undici:request:bodySent"),headers:A.channel("undici:request:headers"),trailers:A.channel("undici:request:trailers"),error:A.channel("undici:request:error"),open:A.channel("undici:websocket:open"),close:A.channel("undici:websocket:close"),socketError:A.channel("undici:websocket:socket_error"),ping:A.channel("undici:websocket:ping"),pong:A.channel("undici:websocket:pong")};if(c.enabled||E.enabled){const l=E.enabled?E:c;A.channel("undici:client:beforeConnect").subscribe(Q=>{const{connectParams:{version:u,protocol:n,port:r,host:o}}=Q;l("connecting to %s using %s%s",`${o}${r?`:${r}`:""}`,n,u)}),A.channel("undici:client:connected").subscribe(Q=>{const{connectParams:{version:u,protocol:n,port:r,host:o}}=Q;l("connected to %s using %s%s",`${o}${r?`:${r}`:""}`,n,u)}),A.channel("undici:client:connectError").subscribe(Q=>{const{connectParams:{version:u,protocol:n,port:r,host:o},error:a}=Q;l("connection to %s using %s%s errored - %s",`${o}${r?`:${r}`:""}`,n,u,a.message)}),A.channel("undici:client:sendHeaders").subscribe(Q=>{const{request:{method:u,path:n,origin:r}}=Q;l("sending request to %s %s/%s",u,r,n)}),A.channel("undici:request:headers").subscribe(Q=>{const{request:{method:u,path:n,origin:r},response:{statusCode:o}}=Q;l("received response to %s %s/%s - HTTP %d",u,r,n,o)}),A.channel("undici:request:trailers").subscribe(Q=>{const{request:{method:u,path:n,origin:r}}=Q;l("trailers received from %s %s/%s",u,r,n)}),A.channel("undici:request:error").subscribe(Q=>{const{request:{method:u,path:n,origin:r},error:o}=Q;l("request to %s %s/%s errored - %s",u,r,n,o.message)}),B=!0}if(t.enabled){if(!B){const l=c.enabled?c:t;A.channel("undici:client:beforeConnect").subscribe(Q=>{const{connectParams:{version:u,protocol:n,port:r,host:o}}=Q;l("connecting to %s%s using %s%s",o,r?`:${r}`:"",n,u)}),A.channel("undici:client:connected").subscribe(Q=>{const{connectParams:{version:u,protocol:n,port:r,host:o}}=Q;l("connected to %s%s using %s%s",o,r?`:${r}`:"",n,u)}),A.channel("undici:client:connectError").subscribe(Q=>{const{connectParams:{version:u,protocol:n,port:r,host:o},error:a}=Q;l("connection to %s%s using %s%s errored - %s",o,r?`:${r}`:"",n,u,a.message)}),A.channel("undici:client:sendHeaders").subscribe(Q=>{const{request:{method:u,path:n,origin:r}}=Q;l("sending request to %s %s/%s",u,r,n)})}A.channel("undici:websocket:open").subscribe(l=>{const{address:{address:Q,port:u}}=l;t("connection opened %s%s",Q,u?`:${u}`:"")}),A.channel("undici:websocket:close").subscribe(l=>{const{websocket:Q,code:u,reason:n}=l;t("closed connection to %s - %s %s",Q.url,u,n)}),A.channel("undici:websocket:socket_error").subscribe(l=>{t("connection errored - %s",l.message)}),A.channel("undici:websocket:ping").subscribe(l=>{t("ping received")}),A.channel("undici:websocket:pong").subscribe(l=>{t("pong received")})}return diagnostics={channels:f},diagnostics}e(requireDiagnostics,"requireDiagnostics");var request$1,hasRequiredRequest$1;function requireRequest$1(){if(hasRequiredRequest$1)return request$1;hasRequiredRequest$1=1;const{InvalidArgumentError:A,NotSupportedError:p}=requireErrors(),c=require$$0__default,{isValidHTTPToken:E,isValidHeaderValue:t,isStream:B,destroy:f,isBuffer:l,isFormDataLike:Q,isIterable:u,isBlobLike:n,buildURL:r,validateHandler:o,getServerName:a,normalizedMethodRecords:g}=requireUtil$7(),{channels:d}=requireDiagnostics(),{headerNameLowerCasedRecord:N}=requireConstants$4(),M=/[^\u0021-\u00ff]/,Y=Symbol("handler");class J{static{e(this,"Request")}constructor(h,{path:I,method:k,body:i,headers:F,query:m,idempotent:D,blocking:S,upgrade:W,headersTimeout:q,bodyTimeout:O,reset:P,throwOnError:Z,expectContinue:cA,servername:EA},fA){if(typeof I!="string")throw new A("path must be a string");if(I[0]!=="/"&&!(I.startsWith("http://")||I.startsWith("https://"))&&k!=="CONNECT")throw new A("path must be an absolute URL or start with a slash");if(M.test(I))throw new A("invalid request path");if(typeof k!="string")throw new A("method must be a string");if(g[k]===void 0&&!E(k))throw new A("invalid request method");if(W&&typeof W!="string")throw new A("upgrade must be a string");if(q!=null&&(!Number.isFinite(q)||q<0))throw new A("invalid headersTimeout");if(O!=null&&(!Number.isFinite(O)||O<0))throw new A("invalid bodyTimeout");if(P!=null&&typeof P!="boolean")throw new A("invalid reset");if(cA!=null&&typeof cA!="boolean")throw new A("invalid expectContinue");if(this.headersTimeout=q,this.bodyTimeout=O,this.throwOnError=Z===!0,this.method=k,this.abort=null,i==null)this.body=null;else if(B(i)){this.body=i;const uA=this.body._readableState;(!uA||!uA.autoDestroy)&&(this.endHandler=e(function(){f(this)},"autoDestroy"),this.body.on("end",this.endHandler)),this.errorHandler=pA=>{this.abort?this.abort(pA):this.error=pA},this.body.on("error",this.errorHandler)}else if(l(i))this.body=i.byteLength?i:null;else if(ArrayBuffer.isView(i))this.body=i.buffer.byteLength?Buffer.from(i.buffer,i.byteOffset,i.byteLength):null;else if(i instanceof ArrayBuffer)this.body=i.byteLength?Buffer.from(i):null;else if(typeof i=="string")this.body=i.length?Buffer.from(i):null;else if(Q(i)||u(i)||n(i))this.body=i;else throw new A("body must be a string, a Buffer, a Readable stream, an iterable, or an async iterable");if(this.completed=!1,this.aborted=!1,this.upgrade=W||null,this.path=m?r(I,m):I,this.origin=h,this.idempotent=D??(k==="HEAD"||k==="GET"),this.blocking=S??!1,this.reset=P??null,this.host=null,this.contentLength=null,this.contentType=null,this.headers=[],this.expectContinue=cA??!1,Array.isArray(F)){if(F.length%2!==0)throw new A("headers array must be even");for(let uA=0;uA<F.length;uA+=2)V(this,F[uA],F[uA+1])}else if(F&&typeof F=="object")if(F[Symbol.iterator])for(const uA of F){if(!Array.isArray(uA)||uA.length!==2)throw new A("headers must be in key-value pair format");V(this,uA[0],uA[1])}else{const uA=Object.keys(F);for(let pA=0;pA<uA.length;++pA)V(this,uA[pA],F[uA[pA]])}else if(F!=null)throw new A("headers must be an object or an array");o(fA,k,W),this.servername=EA||a(this.host),this[Y]=fA,d.create.hasSubscribers&&d.create.publish({request:this})}onBodySent(h){if(this[Y].onBodySent)try{return this[Y].onBodySent(h)}catch(I){this.abort(I)}}onRequestSent(){if(d.bodySent.hasSubscribers&&d.bodySent.publish({request:this}),this[Y].onRequestSent)try{return this[Y].onRequestSent()}catch(h){this.abort(h)}}onConnect(h){if(c(!this.aborted),c(!this.completed),this.error)h(this.error);else return this.abort=h,this[Y].onConnect(h)}onResponseStarted(){return this[Y].onResponseStarted?.()}onHeaders(h,I,k,i){c(!this.aborted),c(!this.completed),d.headers.hasSubscribers&&d.headers.publish({request:this,response:{statusCode:h,headers:I,statusText:i}});try{return this[Y].onHeaders(h,I,k,i)}catch(F){this.abort(F)}}onData(h){c(!this.aborted),c(!this.completed);try{return this[Y].onData(h)}catch(I){return this.abort(I),!1}}onUpgrade(h,I,k){return c(!this.aborted),c(!this.completed),this[Y].onUpgrade(h,I,k)}onComplete(h){this.onFinally(),c(!this.aborted),this.completed=!0,d.trailers.hasSubscribers&&d.trailers.publish({request:this,trailers:h});try{return this[Y].onComplete(h)}catch(I){this.onError(I)}}onError(h){if(this.onFinally(),d.error.hasSubscribers&&d.error.publish({request:this,error:h}),!this.aborted)return this.aborted=!0,this[Y].onError(h)}onFinally(){this.errorHandler&&(this.body.off("error",this.errorHandler),this.errorHandler=null),this.endHandler&&(this.body.off("end",this.endHandler),this.endHandler=null)}addHeader(h,I){return V(this,h,I),this}}function V(H,h,I){if(I&&typeof I=="object"&&!Array.isArray(I))throw new A(`invalid ${h} header`);if(I===void 0)return;let k=N[h];if(k===void 0&&(k=h.toLowerCase(),N[k]===void 0&&!E(k)))throw new A("invalid header key");if(Array.isArray(I)){const i=[];for(let F=0;F<I.length;F++)if(typeof I[F]=="string"){if(!t(I[F]))throw new A(`invalid ${h} header`);i.push(I[F])}else if(I[F]===null)i.push("");else{if(typeof I[F]=="object")throw new A(`invalid ${h} header`);i.push(`${I[F]}`)}I=i}else if(typeof I=="string"){if(!t(I))throw new A(`invalid ${h} header`)}else I===null?I="":I=`${I}`;if(H.host===null&&k==="host"){if(typeof I!="string")throw new A("invalid host header");H.host=I}else if(H.contentLength===null&&k==="content-length"){if(H.contentLength=parseInt(I,10),!Number.isFinite(H.contentLength))throw new A("invalid content-length header")}else if(H.contentType===null&&k==="content-type")H.contentType=I,H.headers.push(h,I);else{if(k==="transfer-encoding"||k==="keep-alive"||k==="upgrade")throw new A(`invalid ${k} header`);if(k==="connection"){const i=typeof I=="string"?I.toLowerCase():null;if(i!=="close"&&i!=="keep-alive")throw new A("invalid connection header");i==="close"&&(H.reset=!0)}else{if(k==="expect")throw new p("expect header not supported");H.headers.push(h,I)}}}return e(V,"processHeader"),request$1=J,request$1}e(requireRequest$1,"requireRequest$1");var dispatcher,hasRequiredDispatcher;function requireDispatcher(){if(hasRequiredDispatcher)return dispatcher;hasRequiredDispatcher=1;const A=require$$8__default;class p extends A{static{e(this,"Dispatcher")}dispatch(){throw new Error("not implemented")}close(){throw new Error("not implemented")}destroy(){throw new Error("not implemented")}compose(...t){const B=Array.isArray(t[0])?t[0]:t;let f=this.dispatch.bind(this);for(const l of B)if(l!=null){if(typeof l!="function")throw new TypeError(`invalid interceptor, expected function received ${typeof l}`);if(f=l(f),f==null||typeof f!="function"||f.length!==2)throw new TypeError("invalid interceptor")}return new c(this,f)}}class c extends p{static{e(this,"ComposedDispatcher")}#A=null;#e=null;constructor(t,B){super(),this.#A=t,this.#e=B}dispatch(...t){this.#e(...t)}close(...t){return this.#A.close(...t)}destroy(...t){return this.#A.destroy(...t)}}return dispatcher=p,dispatcher}e(requireDispatcher,"requireDispatcher");var dispatcherBase,hasRequiredDispatcherBase;function requireDispatcherBase(){if(hasRequiredDispatcherBase)return dispatcherBase;hasRequiredDispatcherBase=1;const A=requireDispatcher(),{ClientDestroyedError:p,ClientClosedError:c,InvalidArgumentError:E}=requireErrors(),{kDestroy:t,kClose:B,kClosed:f,kDestroyed:l,kDispatch:Q,kInterceptors:u}=requireSymbols$4(),n=Symbol("onDestroyed"),r=Symbol("onClosed"),o=Symbol("Intercepted Dispatch");class a extends A{static{e(this,"DispatcherBase")}constructor(){super(),this[l]=!1,this[n]=null,this[f]=!1,this[r]=[]}get destroyed(){return this[l]}get closed(){return this[f]}get interceptors(){return this[u]}set interceptors(d){if(d){for(let N=d.length-1;N>=0;N--)if(typeof this[u][N]!="function")throw new E("interceptor must be an function")}this[u]=d}close(d){if(d===void 0)return new Promise((M,Y)=>{this.close((J,V)=>J?Y(J):M(V))});if(typeof d!="function")throw new E("invalid callback");if(this[l]){queueMicrotask(()=>d(new p,null));return}if(this[f]){this[r]?this[r].push(d):queueMicrotask(()=>d(null,null));return}this[f]=!0,this[r].push(d);const N=e(()=>{const M=this[r];this[r]=null;for(let Y=0;Y<M.length;Y++)M[Y](null,null)},"onClosed");this[B]().then(()=>this.destroy()).then(()=>{queueMicrotask(N)})}destroy(d,N){if(typeof d=="function"&&(N=d,d=null),N===void 0)return new Promise((Y,J)=>{this.destroy(d,(V,H)=>V?J(V):Y(H))});if(typeof N!="function")throw new E("invalid callback");if(this[l]){this[n]?this[n].push(N):queueMicrotask(()=>N(null,null));return}d||(d=new p),this[l]=!0,this[n]=this[n]||[],this[n].push(N);const M=e(()=>{const Y=this[n];this[n]=null;for(let J=0;J<Y.length;J++)Y[J](null,null)},"onDestroyed");this[t](d).then(()=>{queueMicrotask(M)})}[o](d,N){if(!this[u]||this[u].length===0)return this[o]=this[Q],this[Q](d,N);let M=this[Q].bind(this);for(let Y=this[u].length-1;Y>=0;Y--)M=this[u][Y](M);return this[o]=M,M(d,N)}dispatch(d,N){if(!N||typeof N!="object")throw new E("handler must be an object");try{if(!d||typeof d!="object")throw new E("opts must be an object.");if(this[l]||this[n])throw new p;if(this[f])throw new c;return this[o](d,N)}catch(M){if(typeof N.onError!="function")throw new E("invalid onError method");return N.onError(M),!1}}}return dispatcherBase=a,dispatcherBase}e(requireDispatcherBase,"requireDispatcherBase");var timers,hasRequiredTimers;function requireTimers(){if(hasRequiredTimers)return timers;hasRequiredTimers=1;let A=0;const p=1e3,c=(p>>1)-1;let E;const t=Symbol("kFastTimer"),B=[],f=-2,l=-1,Q=0,u=1;function n(){A+=c;let a=0,g=B.length;for(;a<g;){const d=B[a];d._state===Q?(d._idleStart=A-c,d._state=u):d._state===u&&A>=d._idleStart+d._idleTimeout&&(d._state=l,d._idleStart=-1,d._onTimeout(d._timerArg)),d._state===l?(d._state=f,--g!==0&&(B[a]=B[g])):++a}B.length=g,B.length!==0&&r()}e(n,"onTick");function r(){E?E.refresh():(clearTimeout(E),E=setTimeout(n,c),E.unref&&E.unref())}e(r,"refreshTimeout");class o{static{e(this,"FastTimer")}[t]=!0;_state=f;_idleTimeout=-1;_idleStart=-1;_onTimeout;_timerArg;constructor(g,d,N){this._onTimeout=g,this._idleTimeout=d,this._timerArg=N,this.refresh()}refresh(){this._state===f&&B.push(this),(!E||B.length===1)&&r(),this._state=Q}clear(){this._state=l,this._idleStart=-1}}return timers={setTimeout(a,g,d){return g<=p?setTimeout(a,g,d):new o(a,g,d)},clearTimeout(a){a[t]?a.clear():clearTimeout(a)},setFastTimeout(a,g,d){return new o(a,g,d)},clearFastTimeout(a){a.clear()},now(){return A},tick(a=0){A+=a-p+1,n(),n()},reset(){A=0,B.length=0,clearTimeout(E),E=null},kFastTimer:t},timers}e(requireTimers,"requireTimers");var connect,hasRequiredConnect;function requireConnect(){if(hasRequiredConnect)return connect;hasRequiredConnect=1;const A=require$$0__default$1,p=require$$0__default,c=requireUtil$7(),{InvalidArgumentError:E,ConnectTimeoutError:t}=requireErrors(),B=requireTimers();function f(){}e(f,"noop");let l,Q;_commonjsHelpers.commonjsGlobal.FinalizationRegistry&&!(process.env.NODE_V8_COVERAGE||process.env.UNDICI_NO_FG)?Q=class{static{e(this,"WeakSessionCache")}constructor(a){this._maxCachedSessions=a,this._sessionCache=new Map,this._sessionRegistry=new _commonjsHelpers.commonjsGlobal.FinalizationRegistry(g=>{if(this._sessionCache.size<this._maxCachedSessions)return;const d=this._sessionCache.get(g);d!==void 0&&d.deref()===void 0&&this._sessionCache.delete(g)})}get(a){const g=this._sessionCache.get(a);return g?g.deref():null}set(a,g){this._maxCachedSessions!==0&&(this._sessionCache.set(a,new WeakRef(g)),this._sessionRegistry.register(g,a))}}:Q=class{static{e(this,"SimpleSessionCache")}constructor(a){this._maxCachedSessions=a,this._sessionCache=new Map}get(a){return this._sessionCache.get(a)}set(a,g){if(this._maxCachedSessions!==0){if(this._sessionCache.size>=this._maxCachedSessions){const{value:d}=this._sessionCache.keys().next();this._sessionCache.delete(d)}this._sessionCache.set(a,g)}}};function u({allowH2:o,maxCachedSessions:a,socketPath:g,timeout:d,session:N,...M}){if(a!=null&&(!Number.isInteger(a)||a<0))throw new E("maxCachedSessions must be a positive integer or zero");const Y={path:g,...M},J=new Q(a??100);return d=d??1e4,o=o??!1,e(function({hostname:H,host:h,protocol:I,port:k,servername:i,localAddress:F,httpSocket:m},D){let S;if(I==="https:"){l||(l=require$$5__default),i=i||Y.servername||c.getServerName(h)||null;const q=i||H;p(q);const O=N||J.get(q)||null;k=k||443,S=l.connect({highWaterMark:16384,...Y,servername:i,session:O,localAddress:F,ALPNProtocols:o?["http/1.1","h2"]:["http/1.1"],socket:m,port:k,host:H}),S.on("session",function(P){J.set(q,P)})}else p(!m,"httpSocket can only be sent on TLS update"),k=k||80,S=A.connect({highWaterMark:64*1024,...Y,localAddress:F,port:k,host:H});if(Y.keepAlive==null||Y.keepAlive){const q=Y.keepAliveInitialDelay===void 0?6e4:Y.keepAliveInitialDelay;S.setKeepAlive(!0,q)}const W=n(new WeakRef(S),{timeout:d,hostname:H,port:k});return S.setNoDelay(!0).once(I==="https:"?"secureConnect":"connect",function(){if(queueMicrotask(W),D){const q=D;D=null,q(null,this)}}).on("error",function(q){if(queueMicrotask(W),D){const O=D;D=null,O(q)}}),S},"connect")}e(u,"buildConnector");const n=process.platform==="win32"?(o,a)=>{if(!a.timeout)return f;let g=null,d=null;const N=B.setFastTimeout(()=>{g=setImmediate(()=>{d=setImmediate(()=>r(o.deref(),a))})},a.timeout);return()=>{B.clearFastTimeout(N),clearImmediate(g),clearImmediate(d)}}:(o,a)=>{if(!a.timeout)return f;let g=null;const d=B.setFastTimeout(()=>{g=setImmediate(()=>{r(o.deref(),a)})},a.timeout);return()=>{B.clearFastTimeout(d),clearImmediate(g)}};function r(o,a){if(o==null)return;let g="Connect Timeout Error";Array.isArray(o.autoSelectFamilyAttemptedAddresses)?g+=` (attempted addresses: ${o.autoSelectFamilyAttemptedAddresses.join(", ")},`:g+=` (attempted address: ${a.hostname}:${a.port},`,g+=` timeout: ${a.timeout}ms)`,c.destroy(o,new t(g))}return e(r,"onConnectTimeout"),connect=u,connect}e(requireConnect,"requireConnect");var constants$3={},utils={},hasRequiredUtils;function requireUtils(){if(hasRequiredUtils)return utils;hasRequiredUtils=1,Object.defineProperty(utils,"__esModule",{value:!0}),utils.enumToMap=void 0;function A(p){const c={};return Object.keys(p).forEach(E=>{const t=p[E];typeof t=="number"&&(c[E]=t)}),c}return e(A,"enumToMap"),utils.enumToMap=A,utils}e(requireUtils,"requireUtils");var hasRequiredConstants$3;function requireConstants$3(){return hasRequiredConstants$3||(hasRequiredConstants$3=1,function(A){Object.defineProperty(A,"__esModule",{value:!0}),A.SPECIAL_HEADERS=A.HEADER_STATE=A.MINOR=A.MAJOR=A.CONNECTION_TOKEN_CHARS=A.HEADER_CHARS=A.TOKEN=A.STRICT_TOKEN=A.HEX=A.URL_CHAR=A.STRICT_URL_CHAR=A.USERINFO_CHARS=A.MARK=A.ALPHANUM=A.NUM=A.HEX_MAP=A.NUM_MAP=A.ALPHA=A.FINISH=A.H_METHOD_MAP=A.METHOD_MAP=A.METHODS_RTSP=A.METHODS_ICE=A.METHODS_HTTP=A.METHODS=A.LENIENT_FLAGS=A.FLAGS=A.TYPE=A.ERROR=void 0;const p=requireUtils();(function(t){t[t.OK=0]="OK",t[t.INTERNAL=1]="INTERNAL",t[t.STRICT=2]="STRICT",t[t.LF_EXPECTED=3]="LF_EXPECTED",t[t.UNEXPECTED_CONTENT_LENGTH=4]="UNEXPECTED_CONTENT_LENGTH",t[t.CLOSED_CONNECTION=5]="CLOSED_CONNECTION",t[t.INVALID_METHOD=6]="INVALID_METHOD",t[t.INVALID_URL=7]="INVALID_URL",t[t.INVALID_CONSTANT=8]="INVALID_CONSTANT",t[t.INVALID_VERSION=9]="INVALID_VERSION",t[t.INVALID_HEADER_TOKEN=10]="INVALID_HEADER_TOKEN",t[t.INVALID_CONTENT_LENGTH=11]="INVALID_CONTENT_LENGTH",t[t.INVALID_CHUNK_SIZE=12]="INVALID_CHUNK_SIZE",t[t.INVALID_STATUS=13]="INVALID_STATUS",t[t.INVALID_EOF_STATE=14]="INVALID_EOF_STATE",t[t.INVALID_TRANSFER_ENCODING=15]="INVALID_TRANSFER_ENCODING",t[t.CB_MESSAGE_BEGIN=16]="CB_MESSAGE_BEGIN",t[t.CB_HEADERS_COMPLETE=17]="CB_HEADERS_COMPLETE",t[t.CB_MESSAGE_COMPLETE=18]="CB_MESSAGE_COMPLETE",t[t.CB_CHUNK_HEADER=19]="CB_CHUNK_HEADER",t[t.CB_CHUNK_COMPLETE=20]="CB_CHUNK_COMPLETE",t[t.PAUSED=21]="PAUSED",t[t.PAUSED_UPGRADE=22]="PAUSED_UPGRADE",t[t.PAUSED_H2_UPGRADE=23]="PAUSED_H2_UPGRADE",t[t.USER=24]="USER"})(A.ERROR||(A.ERROR={})),function(t){t[t.BOTH=0]="BOTH",t[t.REQUEST=1]="REQUEST",t[t.RESPONSE=2]="RESPONSE"}(A.TYPE||(A.TYPE={})),function(t){t[t.CONNECTION_KEEP_ALIVE=1]="CONNECTION_KEEP_ALIVE",t[t.CONNECTION_CLOSE=2]="CONNECTION_CLOSE",t[t.CONNECTION_UPGRADE=4]="CONNECTION_UPGRADE",t[t.CHUNKED=8]="CHUNKED",t[t.UPGRADE=16]="UPGRADE",t[t.CONTENT_LENGTH=32]="CONTENT_LENGTH",t[t.SKIPBODY=64]="SKIPBODY",t[t.TRAILING=128]="TRAILING",t[t.TRANSFER_ENCODING=512]="TRANSFER_ENCODING"}(A.FLAGS||(A.FLAGS={})),function(t){t[t.HEADERS=1]="HEADERS",t[t.CHUNKED_LENGTH=2]="CHUNKED_LENGTH",t[t.KEEP_ALIVE=4]="KEEP_ALIVE"}(A.LENIENT_FLAGS||(A.LENIENT_FLAGS={}));var c;(function(t){t[t.DELETE=0]="DELETE",t[t.GET=1]="GET",t[t.HEAD=2]="HEAD",t[t.POST=3]="POST",t[t.PUT=4]="PUT",t[t.CONNECT=5]="CONNECT",t[t.OPTIONS=6]="OPTIONS",t[t.TRACE=7]="TRACE",t[t.COPY=8]="COPY",t[t.LOCK=9]="LOCK",t[t.MKCOL=10]="MKCOL",t[t.MOVE=11]="MOVE",t[t.PROPFIND=12]="PROPFIND",t[t.PROPPATCH=13]="PROPPATCH",t[t.SEARCH=14]="SEARCH",t[t.UNLOCK=15]="UNLOCK",t[t.BIND=16]="BIND",t[t.REBIND=17]="REBIND",t[t.UNBIND=18]="UNBIND",t[t.ACL=19]="ACL",t[t.REPORT=20]="REPORT",t[t.MKACTIVITY=21]="MKACTIVITY",t[t.CHECKOUT=22]="CHECKOUT",t[t.MERGE=23]="MERGE",t[t["M-SEARCH"]=24]="M-SEARCH",t[t.NOTIFY=25]="NOTIFY",t[t.SUBSCRIBE=26]="SUBSCRIBE",t[t.UNSUBSCRIBE=27]="UNSUBSCRIBE",t[t.PATCH=28]="PATCH",t[t.PURGE=29]="PURGE",t[t.MKCALENDAR=30]="MKCALENDAR",t[t.LINK=31]="LINK",t[t.UNLINK=32]="UNLINK",t[t.SOURCE=33]="SOURCE",t[t.PRI=34]="PRI",t[t.DESCRIBE=35]="DESCRIBE",t[t.ANNOUNCE=36]="ANNOUNCE",t[t.SETUP=37]="SETUP",t[t.PLAY=38]="PLAY",t[t.PAUSE=39]="PAUSE",t[t.TEARDOWN=40]="TEARDOWN",t[t.GET_PARAMETER=41]="GET_PARAMETER",t[t.SET_PARAMETER=42]="SET_PARAMETER",t[t.REDIRECT=43]="REDIRECT",t[t.RECORD=44]="RECORD",t[t.FLUSH=45]="FLUSH"})(c=A.METHODS||(A.METHODS={})),A.METHODS_HTTP=[c.DELETE,c.GET,c.HEAD,c.POST,c.PUT,c.CONNECT,c.OPTIONS,c.TRACE,c.COPY,c.LOCK,c.MKCOL,c.MOVE,c.PROPFIND,c.PROPPATCH,c.SEARCH,c.UNLOCK,c.BIND,c.REBIND,c.UNBIND,c.ACL,c.REPORT,c.MKACTIVITY,c.CHECKOUT,c.MERGE,c["M-SEARCH"],c.NOTIFY,c.SUBSCRIBE,c.UNSUBSCRIBE,c.PATCH,c.PURGE,c.MKCALENDAR,c.LINK,c.UNLINK,c.PRI,c.SOURCE],A.METHODS_ICE=[c.SOURCE],A.METHODS_RTSP=[c.OPTIONS,c.DESCRIBE,c.ANNOUNCE,c.SETUP,c.PLAY,c.PAUSE,c.TEARDOWN,c.GET_PARAMETER,c.SET_PARAMETER,c.REDIRECT,c.RECORD,c.FLUSH,c.GET,c.POST],A.METHOD_MAP=p.enumToMap(c),A.H_METHOD_MAP={},Object.keys(A.METHOD_MAP).forEach(t=>{/^H/.test(t)&&(A.H_METHOD_MAP[t]=A.METHOD_MAP[t])}),function(t){t[t.SAFE=0]="SAFE",t[t.SAFE_WITH_CB=1]="SAFE_WITH_CB",t[t.UNSAFE=2]="UNSAFE"}(A.FINISH||(A.FINISH={})),A.ALPHA=[];for(let t=65;t<=90;t++)A.ALPHA.push(String.fromCharCode(t)),A.ALPHA.push(String.fromCharCode(t+32));A.NUM_MAP={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9},A.HEX_MAP={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},A.NUM=["0","1","2","3","4","5","6","7","8","9"],A.ALPHANUM=A.ALPHA.concat(A.NUM),A.MARK=["-","_",".","!","~","*","'","(",")"],A.USERINFO_CHARS=A.ALPHANUM.concat(A.MARK).concat(["%",";",":","&","=","+","$",","]),A.STRICT_URL_CHAR=["!",'"',"$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","@","[","\\","]","^","_","`","{","|","}","~"].concat(A.ALPHANUM),A.URL_CHAR=A.STRICT_URL_CHAR.concat([" ","\f"]);for(let t=128;t<=255;t++)A.URL_CHAR.push(t);A.HEX=A.NUM.concat(["a","b","c","d","e","f","A","B","C","D","E","F"]),A.STRICT_TOKEN=["!","#","$","%","&","'","*","+","-",".","^","_","`","|","~"].concat(A.ALPHANUM),A.TOKEN=A.STRICT_TOKEN.concat([" "]),A.HEADER_CHARS=[" "];for(let t=32;t<=255;t++)t!==127&&A.HEADER_CHARS.push(t);A.CONNECTION_TOKEN_CHARS=A.HEADER_CHARS.filter(t=>t!==44),A.MAJOR=A.NUM_MAP,A.MINOR=A.MAJOR;var E;(function(t){t[t.GENERAL=0]="GENERAL",t[t.CONNECTION=1]="CONNECTION",t[t.CONTENT_LENGTH=2]="CONTENT_LENGTH",t[t.TRANSFER_ENCODING=3]="TRANSFER_ENCODING",t[t.UPGRADE=4]="UPGRADE",t[t.CONNECTION_KEEP_ALIVE=5]="CONNECTION_KEEP_ALIVE",t[t.CONNECTION_CLOSE=6]="CONNECTION_CLOSE",t[t.CONNECTION_UPGRADE=7]="CONNECTION_UPGRADE",t[t.TRANSFER_ENCODING_CHUNKED=8]="TRANSFER_ENCODING_CHUNKED"})(E=A.HEADER_STATE||(A.HEADER_STATE={})),A.SPECIAL_HEADERS={connection:E.CONNECTION,"content-length":E.CONTENT_LENGTH,"proxy-connection":E.CONNECTION,"transfer-encoding":E.TRANSFER_ENCODING,upgrade:E.UPGRADE}}(constants$3)),constants$3}e(requireConstants$3,"requireConstants$3");var llhttpWasm,hasRequiredLlhttpWasm;function requireLlhttpWasm(){if(hasRequiredLlhttpWasm)return llhttpWasm;hasRequiredLlhttpWasm=1;const{Buffer:A}=require$$0__default$2;return llhttpWasm=A.from("AGFzbQEAAAABJwdgAX8Bf2ADf39/AX9gAX8AYAJ/fwBgBH9/f38Bf2AAAGADf39/AALLAQgDZW52GHdhc21fb25faGVhZGVyc19jb21wbGV0ZQAEA2VudhV3YXNtX29uX21lc3NhZ2VfYmVnaW4AAANlbnYLd2FzbV9vbl91cmwAAQNlbnYOd2FzbV9vbl9zdGF0dXMAAQNlbnYUd2FzbV9vbl9oZWFkZXJfZmllbGQAAQNlbnYUd2FzbV9vbl9oZWFkZXJfdmFsdWUAAQNlbnYMd2FzbV9vbl9ib2R5AAEDZW52GHdhc21fb25fbWVzc2FnZV9jb21wbGV0ZQAAAy0sBQYAAAIAAAAAAAACAQIAAgICAAADAAAAAAMDAwMBAQEBAQEBAQEAAAIAAAAEBQFwARISBQMBAAIGCAF/AUGA1AQLB9EFIgZtZW1vcnkCAAtfaW5pdGlhbGl6ZQAIGV9faW5kaXJlY3RfZnVuY3Rpb25fdGFibGUBAAtsbGh0dHBfaW5pdAAJGGxsaHR0cF9zaG91bGRfa2VlcF9hbGl2ZQAvDGxsaHR0cF9hbGxvYwALBm1hbGxvYwAxC2xsaHR0cF9mcmVlAAwEZnJlZQAMD2xsaHR0cF9nZXRfdHlwZQANFWxsaHR0cF9nZXRfaHR0cF9tYWpvcgAOFWxsaHR0cF9nZXRfaHR0cF9taW5vcgAPEWxsaHR0cF9nZXRfbWV0aG9kABAWbGxodHRwX2dldF9zdGF0dXNfY29kZQAREmxsaHR0cF9nZXRfdXBncmFkZQASDGxsaHR0cF9yZXNldAATDmxsaHR0cF9leGVjdXRlABQUbGxodHRwX3NldHRpbmdzX2luaXQAFQ1sbGh0dHBfZmluaXNoABYMbGxodHRwX3BhdXNlABcNbGxodHRwX3Jlc3VtZQAYG2xsaHR0cF9yZXN1bWVfYWZ0ZXJfdXBncmFkZQAZEGxsaHR0cF9nZXRfZXJybm8AGhdsbGh0dHBfZ2V0X2Vycm9yX3JlYXNvbgAbF2xsaHR0cF9zZXRf