omniroute 3.0.3 → 3.0.4
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/app/.next/BUILD_ID +1 -1
- package/app/.next/build-manifest.json +2 -2
- package/app/.next/prerender-manifest.json +3 -3
- package/app/.next/server/app/(dashboard)/dashboard/a2a/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/agents/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/audit-log/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mcp/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/search-tools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/400/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/401/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/403/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/408/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/429/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/500/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/502/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/503/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error.html +2 -2
- package/app/.next/server/app/_global-error.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/maintenance/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/offline/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/status/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__051203a6._.js +2 -2
- package/app/.next/server/chunks/[root-of-the-server]__0891af92._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__1f2b0d89._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__46e00e59._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__6e52619e._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__7ace0fcd._.js +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__7fa4d14e._.js +1 -1
- package/app/.next/server/chunks/_05c48915._.js +1 -1
- package/app/.next/server/chunks/_06515a8a._.js +1 -1
- package/app/.next/server/chunks/_2115d8de._.js +1 -1
- package/app/.next/server/chunks/_3ac953eb._.js +1 -1
- package/app/.next/server/chunks/_4b8fd853._.js +1 -1
- package/app/.next/server/chunks/_68683848._.js +1 -1
- package/app/.next/server/chunks/_6f1b3c3f._.js +1 -1
- package/app/.next/server/chunks/_ee9b677b._.js +1 -1
- package/app/.next/server/chunks/_ffda39da._.js +1 -1
- package/app/.next/server/chunks/open-sse_services_826884e1._.js +2 -2
- package/app/.next/server/chunks/ssr/[root-of-the-server]__9ef96d20._.js +1 -1
- package/app/.next/server/chunks/ssr/[root-of-the-server]__a6942102._.js +1 -1
- package/app/.next/server/chunks/ssr/src_a82a42f9._.js +1 -1
- package/app/.next/server/chunks/ssr/src_app_(dashboard)_dashboard_settings_9e20fb8d._.js +1 -1
- package/app/.next/server/pages/500.html +2 -2
- package/app/.next/server/server-reference-manifest.js +1 -1
- package/app/.next/server/server-reference-manifest.json +1 -1
- package/app/.next/static/chunks/b7c366e286771d50.js +1 -0
- package/app/.next/static/chunks/{ebab37f6ad33bd4e.js → dbc46fb277f133dc.js} +1 -1
- package/app/.next/static/chunks/{5651f455237ec3f2.js → e3b6aa5804426dc9.js} +1 -1
- package/app/CHANGELOG.md +11 -0
- package/app/docs/openapi.yaml +1 -1
- package/app/open-sse/services/combo.ts +24 -10
- package/app/open-sse/services/usage.ts +1 -1
- package/app/package-lock.json +2 -2
- package/app/package.json +1 -1
- package/app/src/app/(dashboard)/dashboard/providers/[id]/page.tsx +3 -4
- package/app/src/app/(dashboard)/dashboard/settings/components/ProxyRegistryManager.tsx +4 -0
- package/package.json +1 -1
- package/app/.next/static/chunks/d188e358e1ec0a7d.js +0 -1
- /package/app/.next/static/{ZWCtX2yltDveGFFw3HCFk → TZMQMpHs8mN-4BNVBHMGq}/_buildManifest.js +0 -0
- /package/app/.next/static/{ZWCtX2yltDveGFFw3HCFk → TZMQMpHs8mN-4BNVBHMGq}/_clientMiddlewareManifest.json +0 -0
- /package/app/.next/static/{ZWCtX2yltDveGFFw3HCFk → TZMQMpHs8mN-4BNVBHMGq}/_ssgManifest.js +0 -0
|
@@ -117,6 +117,6 @@ ${e.format(A)}`.trim())}}},45380,(e,A,t)=>{"use strict";let{InvalidArgumentError
|
|
|
117
117
|
)
|
|
118
118
|
`)}close(){this.#eV.close()}get(e){n(e);let A=this.#eX(e);return A?{body:A.body?Buffer.from(A.body.buffer,A.body.byteOffset,A.body.byteLength):void 0,statusCode:A.statusCode,statusMessage:A.statusMessage,headers:A.headers?JSON.parse(A.headers):void 0,etag:A.etag?A.etag:void 0,vary:A.vary?JSON.parse(A.vary):void 0,cacheControlDirectives:A.cacheControlDirectives?JSON.parse(A.cacheControlDirectives):void 0,cachedAt:A.cachedAt,staleAt:A.staleAt,deleteAt:A.deleteAt}:void 0}set(e,A){n(e);let t=this.#ez(e),r=Array.isArray(A.body)?Buffer.concat(A.body):A.body,s=r?.byteLength;if(s&&s>this.#ec)return;let o=this.#eX(e,!0);o?this.#e_.run(r,A.deleteAt,A.statusCode,A.statusMessage,A.headers?JSON.stringify(A.headers):null,A.etag?A.etag:null,A.cacheControlDirectives?JSON.stringify(A.cacheControlDirectives):null,A.cachedAt,A.staleAt,o.id):(this.#eK(),this.#eP.run(t,e.method,r,A.deleteAt,A.statusCode,A.statusMessage,A.headers?JSON.stringify(A.headers):null,A.etag?A.etag:null,A.cacheControlDirectives?JSON.stringify(A.cacheControlDirectives):null,A.vary?JSON.stringify(A.vary):null,A.cachedAt,A.staleAt))}createWriteStream(e,A){n(e),o(A);let t=0,r=[],i=this;return new s({decodeStrings:!0,write(e,A,s){(t+=e.byteLength)<i.#ec?r.push(e):this.destroy(),s()},final(t){i.set(e,{...A,body:r}),t()}})}delete(e){if("object"!=typeof e)throw TypeError(`expected key to be object, got ${typeof e}`);this.#eq.run(this.#ez(e))}#eK(){if(Number.isFinite(this.#eh)&&this.size<=this.#eh)return 0;{let e=this.#eW.run(Date.now()).changes;if(e)return e}{let e=this.#ej?.run(Math.max(Math.floor(.1*this.#eh),1)).changes;if(e)return e}return 0}get size(){let{total:e}=this.#eZ.get();return e}#ez(e){return`${e.origin}/${e.path}`}#eX(e,A=!1){let t=this.#ez(e),{headers:r,method:s}=e,n=this.#eJ.all(t,s);if(0===n.length)return;let o=Date.now();for(let e of n){if(o>=e.deleteAt&&!A)break;let t=!0;if(e.vary){let A=JSON.parse(e.vary);for(let e in A)if(!function(e,A){return null==e&&null==A||(null!=e||null==A)&&(null==e||null!=A)&&(Array.isArray(e)&&Array.isArray(A)?e.length===A.length&&e.every((e,t)=>e===A[t]):e===A)}(r[e],A[e])){t=!1;break}}if(t)return e}}}},700419,(e,A,t)=>{"use strict";let{kConstruct:r}=e.r(227235),{kEnumerableProperty:s}=e.r(504021),{iteratorMixin:n,isValidHeaderName:o,isValidHeaderValue:i}=e.r(88435),{webidl:a}=e.r(499095),l=e.r(57328),g=e.r(812057);function h(e){return 10===e||13===e||9===e||32===e}function c(e){let A=0,t=e.length;for(;t>A&&h(e.charCodeAt(t-1));)--t;for(;t>A&&h(e.charCodeAt(A));)++A;return 0===A&&t===e.length?e:e.substring(A,t)}function E(e,A){if(Array.isArray(A))for(let t=0;t<A.length;++t){let r=A[t];if(2!==r.length)throw a.errors.exception({header:"Headers constructor",message:`expected name/value pair to be length 2, found ${r.length}.`});Q(e,r[0],r[1])}else if("object"==typeof A&&null!==A){let t=Object.keys(A);for(let r=0;r<t.length;++r)Q(e,t[r],A[t[r]])}else throw a.errors.conversionFailed({prefix:"Headers constructor",argument:"Argument 1",types:["sequence<sequence<ByteString>>","record<ByteString, ByteString>"]})}function Q(e,A,t){if(t=c(t),o(A)){if(!i(t))throw a.errors.invalidArgument({prefix:"Headers.append",value:t,type:"header value"})}else throw a.errors.invalidArgument({prefix:"Headers.append",value:A,type:"header name"});if("immutable"===C(e))throw TypeError("immutable");return f(e).append(A,t,!1)}function u(e,A){return e[0]<A[0]?-1:1}class I{cookies=null;sortedMap;headersMap;constructor(e){e instanceof I?(this.headersMap=new Map(e.headersMap),this.sortedMap=e.sortedMap,this.cookies=null===e.cookies?null:[...e.cookies]):(this.headersMap=new Map(e),this.sortedMap=null)}contains(e,A){return this.headersMap.has(A?e:e.toLowerCase())}clear(){this.headersMap.clear(),this.sortedMap=null,this.cookies=null}append(e,A,t){this.sortedMap=null;let r=t?e:e.toLowerCase(),s=this.headersMap.get(r);if(s){let e="cookie"===r?"; ":", ";this.headersMap.set(r,{name:s.name,value:`${s.value}${e}${A}`})}else this.headersMap.set(r,{name:e,value:A});"set-cookie"===r&&(this.cookies??=[]).push(A)}set(e,A,t){this.sortedMap=null;let r=t?e:e.toLowerCase();"set-cookie"===r&&(this.cookies=[A]),this.headersMap.set(r,{name:e,value:A})}delete(e,A){this.sortedMap=null,A||(e=e.toLowerCase()),"set-cookie"===e&&(this.cookies=null),this.headersMap.delete(e)}get(e,A){return this.headersMap.get(A?e:e.toLowerCase())?.value??null}*[Symbol.iterator](){for(let{0:e,1:{value:A}}of this.headersMap)yield[e,A]}get entries(){let e={};if(0!==this.headersMap.size)for(let{name:A,value:t}of this.headersMap.values())e[A]=t;return e}rawValues(){return this.headersMap.values()}get entriesList(){let e=[];if(0!==this.headersMap.size)for(let{0:A,1:{name:t,value:r}}of this.headersMap)if("set-cookie"===A)for(let A of this.cookies)e.push([t,A]);else e.push([t,r]);return e}toSortedArray(){let e=this.headersMap.size,A=Array(e);if(e<=32){if(0===e)return A;let t=this.headersMap[Symbol.iterator](),r=t.next().value;A[0]=[r[0],r[1].value],l(null!==r[1].value);for(let r=1,s=0,n=0,o=0,i=0,a,g;r<e;++r){for(g=t.next().value,l(null!==(a=A[r]=[g[0],g[1].value])[1]),o=0,n=r;o<n;)A[i=o+(n-o>>1)][0]<=a[0]?o=i+1:n=i;if(r!==i){for(s=r;s>o;)A[s]=A[--s];A[o]=a}}if(!t.next().done)throw TypeError("Unreachable");return A}{let e=0;for(let{0:t,1:{value:r}}of this.headersMap)A[e++]=[t,r],l(null!==r);return A.sort(u)}}}class B{#e$;#e0;constructor(e){if(a.util.markAsUncloneable(this),e===r)return;this.#e0=new I,this.#e$="none",void 0!==e&&E(this,e=a.converters.HeadersInit(e,"Headers constructor","init"))}append(e,A){a.brandCheck(this,B),a.argumentLengthCheck(arguments,2,"Headers.append");let t="Headers.append";return e=a.converters.ByteString(e,t,"name"),A=a.converters.ByteString(A,t,"value"),Q(this,e,A)}delete(e){if(a.brandCheck(this,B),a.argumentLengthCheck(arguments,1,"Headers.delete"),!o(e=a.converters.ByteString(e,"Headers.delete","name")))throw a.errors.invalidArgument({prefix:"Headers.delete",value:e,type:"header name"});if("immutable"===this.#e$)throw TypeError("immutable");this.#e0.contains(e,!1)&&this.#e0.delete(e,!1)}get(e){a.brandCheck(this,B),a.argumentLengthCheck(arguments,1,"Headers.get");let A="Headers.get";if(!o(e=a.converters.ByteString(e,A,"name")))throw a.errors.invalidArgument({prefix:A,value:e,type:"header name"});return this.#e0.get(e,!1)}has(e){a.brandCheck(this,B),a.argumentLengthCheck(arguments,1,"Headers.has");let A="Headers.has";if(!o(e=a.converters.ByteString(e,A,"name")))throw a.errors.invalidArgument({prefix:A,value:e,type:"header name"});return this.#e0.contains(e,!1)}set(e,A){a.brandCheck(this,B),a.argumentLengthCheck(arguments,2,"Headers.set");let t="Headers.set";if(e=a.converters.ByteString(e,t,"name"),A=c(A=a.converters.ByteString(A,t,"value")),o(e)){if(!i(A))throw a.errors.invalidArgument({prefix:t,value:A,type:"header value"})}else throw a.errors.invalidArgument({prefix:t,value:e,type:"header name"});if("immutable"===this.#e$)throw TypeError("immutable");this.#e0.set(e,A,!1)}getSetCookie(){a.brandCheck(this,B);let e=this.#e0.cookies;return e?[...e]:[]}[g.inspect.custom](e,A){return A.depth??=e,`Headers ${g.formatWithOptions(A,this.#e0.entries)}`}static getHeadersGuard(e){return e.#e$}static setHeadersGuard(e,A){e.#e$=A}static getHeadersList(e){return e.#e0}static setHeadersList(e,A){e.#e0=A}}let{getHeadersGuard:C,setHeadersGuard:d,getHeadersList:f,setHeadersList:p}=B;Reflect.deleteProperty(B,"getHeadersGuard"),Reflect.deleteProperty(B,"setHeadersGuard"),Reflect.deleteProperty(B,"getHeadersList"),Reflect.deleteProperty(B,"setHeadersList"),n("Headers",B,function(e){let A=f(e);if(!A)return[];if(A.sortedMap)return A.sortedMap;let t=[],r=A.toSortedArray(),s=A.cookies;if(null===s||1===s.length)return A.sortedMap=r;for(let e=0;e<r.length;++e){let{0:A,1:n}=r[e];if("set-cookie"===A)for(let e=0;e<s.length;++e)t.push([A,s[e]]);else t.push([A,n])}return A.sortedMap=t},0,1),Object.defineProperties(B.prototype,{append:s,delete:s,get:s,has:s,set:s,getSetCookie:s,[Symbol.toStringTag]:{value:"Headers",configurable:!0},[g.inspect.custom]:{enumerable:!1}}),a.converters.HeadersInit=function(e,A,t){if(a.util.Type(e)===a.util.Types.OBJECT){let r=Reflect.get(e,Symbol.iterator);if(!g.types.isProxy(e)&&r===B.prototype.entries)try{return f(e).entriesList}catch{}return"function"==typeof r?a.converters["sequence<sequence<ByteString>>"](e,A,t,r.bind(e)):a.converters["record<ByteString, ByteString>"](e,A,t)}throw a.errors.conversionFailed({prefix:"Headers constructor",argument:"Argument 1",types:["sequence<sequence<ByteString>>","record<ByteString, ByteString>"]})},A.exports={fill:E,compareHeaderName:u,Headers:B,HeadersList:I,getHeadersGuard:C,setHeadersGuard:d,setHeadersList:p,getHeadersList:f}},312148,(e,A,t)=>{"use strict";let{Headers:r,HeadersList:s,fill:n,getHeadersGuard:o,setHeadersGuard:i,setHeadersList:a}=e.r(700419),{extractBody:l,cloneBody:g,mixinBody:h,streamRegistry:c,bodyUnusable:E}=e.r(818719),Q=e.r(504021),u=e.r(812057),{kEnumerableProperty:I}=Q,{isValidReasonPhrase:B,isCancelled:C,isAborted:d,isErrorLike:f,environmentSettingsObject:p}=e.r(88435),{redirectStatusSet:y,nullBodyStatus:D}=e.r(208309),{webidl:S}=e.r(499095),{URLSerializer:w}=e.r(997726),{kConstruct:m}=e.r(227235),N=e.r(57328),{isomorphicEncode:R,serializeJavascriptValueToJSONString:b}=e.r(279869),U=new TextEncoder("utf-8");class F{#P;#c;static error(){return V(Y(),"immutable")}static json(e,A){S.argumentLengthCheck(arguments,1,"Response.json"),null!==A&&(A=S.converters.ResponseInit(A));let t=l(U.encode(b(e))),r=V(H({}),"response");return G(r,A,{body:t[0],type:"application/json"}),r}static redirect(e,A=302){let t;S.argumentLengthCheck(arguments,1,"Response.redirect"),e=S.converters.USVString(e),A=S.converters["unsigned short"](A);try{t=new URL(e,p.settingsObject.baseUrl)}catch(A){throw TypeError(`Failed to parse URL from ${e}`,{cause:A})}if(!y.has(A))throw RangeError(`Invalid status code ${A}`);let r=V(H({}),"immutable");r.#c.status=A;let s=R(w(t));return r.#c.headersList.append("location",s,!0),r}constructor(e=null,A){if(S.util.markAsUncloneable(this),e===m)return;null!==e&&(e=S.converters.BodyInit(e,"Response","body")),A=S.converters.ResponseInit(A),this.#c=H({}),this.#P=new r(m),i(this.#P,"response"),a(this.#P,this.#c.headersList);let t=null;if(null!=e){const[A,r]=l(e);t={body:A,type:r}}G(this,A,t)}get type(){return S.brandCheck(this,F),this.#c.type}get url(){S.brandCheck(this,F);let e=this.#c.urlList,A=e[e.length-1]??null;return null===A?"":w(A,!0)}get redirected(){return S.brandCheck(this,F),this.#c.urlList.length>1}get status(){return S.brandCheck(this,F),this.#c.status}get ok(){return S.brandCheck(this,F),this.#c.status>=200&&this.#c.status<=299}get statusText(){return S.brandCheck(this,F),this.#c.statusText}get headers(){return S.brandCheck(this,F),this.#P}get body(){return S.brandCheck(this,F),this.#c.body?this.#c.body.stream:null}get bodyUsed(){return S.brandCheck(this,F),!!this.#c.body&&Q.isDisturbed(this.#c.body.stream)}clone(){if(S.brandCheck(this,F),E(this.#c))throw S.errors.exception({header:"Response.clone",message:"Body has already been consumed."});let e=v(this.#c);return 0!==this.#c.urlList.length&&this.#c.body?.stream&&c.register(this,new WeakRef(this.#c.body.stream)),V(e,o(this.#P))}[u.inspect.custom](e,A){null===A.depth&&(A.depth=2),A.colors??=!0;let t={status:this.status,statusText:this.statusText,headers:this.headers,body:this.body,bodyUsed:this.bodyUsed,ok:this.ok,redirected:this.redirected,type:this.type,url:this.url};return`Response ${u.formatWithOptions(A,t)}`}static getResponseHeaders(e){return e.#P}static setResponseHeaders(e,A){e.#P=A}static getResponseState(e){return e.#c}static setResponseState(e,A){e.#c=A}}let{getResponseHeaders:k,setResponseHeaders:M,getResponseState:T,setResponseState:L}=F;function v(e){if(e.internalResponse)return x(v(e.internalResponse),e.type);let A=H({...e,body:null});return null!=e.body&&(A.body=g(e.body)),A}function H(e){return{aborted:!1,rangeRequested:!1,timingAllowPassed:!1,requestIncludesCredentials:!1,type:"default",status:200,timingInfo:null,cacheState:"",statusText:"",...e,headersList:e?.headersList?new s(e?.headersList):new s,urlList:e?.urlList?[...e.urlList]:[]}}function Y(e){return H({type:"error",status:0,error:f(e)?e:Error(e?String(e):e),aborted:e&&"AbortError"===e.name})}function O(e,A){return A={internalResponse:e,...A},new Proxy(e,{get:(e,t)=>t in A?A[t]:e[t],set:(e,t,r)=>(N(!(t in A)),e[t]=r,!0)})}function x(e,A){return"basic"===A?O(e,{type:"basic",headersList:e.headersList}):"cors"===A?O(e,{type:"cors",headersList:e.headersList}):"opaque"===A?O(e,{type:"opaque",urlList:[],status:0,statusText:"",body:null}):"opaqueredirect"===A?O(e,{type:"opaqueredirect",status:0,statusText:"",headersList:[],body:null}):void N(!1)}function G(e,A,t){if(null!==A.status&&(A.status<200||A.status>599))throw RangeError('init["status"] must be in the range of 200 to 599, inclusive.');if("statusText"in A&&null!=A.statusText&&!B(String(A.statusText)))throw TypeError("Invalid statusText");if("status"in A&&null!=A.status&&(T(e).status=A.status),"statusText"in A&&null!=A.statusText&&(T(e).statusText=A.statusText),"headers"in A&&null!=A.headers&&n(k(e),A.headers),t){if(D.includes(e.status))throw S.errors.exception({header:"Response constructor",message:`Invalid response status code ${e.status}`});T(e).body=t.body,null==t.type||T(e).headersList.contains("content-type",!0)||T(e).headersList.append("content-type",t.type,!0)}}function V(e,A){let t=new F(m);L(t,e);let s=new r(m);return M(t,s),a(s,e.headersList),i(s,A),0!==e.urlList.length&&e.body?.stream&&c.register(t,new WeakRef(e.body.stream)),t}Reflect.deleteProperty(F,"getResponseHeaders"),Reflect.deleteProperty(F,"setResponseHeaders"),Reflect.deleteProperty(F,"getResponseState"),Reflect.deleteProperty(F,"setResponseState"),h(F,T),Object.defineProperties(F.prototype,{type:I,url:I,status:I,ok:I,redirected:I,statusText:I,headers:I,clone:I,body:I,bodyUsed:I,[Symbol.toStringTag]:{value:"Response",configurable:!0}}),Object.defineProperties(F,{json:I,redirect:I,error:I}),S.converters.XMLHttpRequestBodyInit=function(e,A,t){return"string"==typeof e?S.converters.USVString(e,A,t):S.is.Blob(e)||S.is.BufferSource(e)||S.is.FormData(e)||S.is.URLSearchParams(e)?e:S.converters.DOMString(e,A,t)},S.converters.BodyInit=function(e,A,t){return S.is.ReadableStream(e)||e?.[Symbol.asyncIterator]?e:S.converters.XMLHttpRequestBodyInit(e,A,t)},S.converters.ResponseInit=S.dictionaryConverter([{key:"status",converter:S.converters["unsigned short"],defaultValue:()=>200},{key:"statusText",converter:S.converters.ByteString,defaultValue:()=>""},{key:"headers",converter:S.converters.HeadersInit}]),S.is.Response=S.util.MakeTypeAssertion(F),A.exports={isNetworkError:function(e){return"error"===e.type&&0===e.status},makeNetworkError:Y,makeResponse:H,makeAppropriateNetworkError:function(e,A=null){return N(C(e)),d(e)?Y(Object.assign(new DOMException("The operation was aborted.","AbortError"),{cause:A})):Y(Object.assign(new DOMException("Request was cancelled."),{cause:A}))},filterResponse:x,Response:F,cloneResponse:v,fromInnerResponse:V,getResponseState:T}},440796,(e,A,t)=>{"use strict";let r,{extractBody:s,mixinBody:n,cloneBody:o,bodyUnusable:i}=e.r(818719),{Headers:a,fill:l,HeadersList:g,setHeadersGuard:h,getHeadersGuard:c,setHeadersList:E,getHeadersList:Q}=e.r(700419),u=e.r(504021),I=e.r(812057),{isValidHTTPToken:B,sameOrigin:C,environmentSettingsObject:d}=e.r(88435),{forbiddenMethodsSet:f,corsSafeListedMethodsSet:p,referrerPolicy:y,requestRedirect:D,requestMode:S,requestCredentials:w,requestCache:m,requestDuplex:N}=e.r(208309),{kEnumerableProperty:R,normalizedMethodRecordsBase:b,normalizedMethodRecords:U}=u,{webidl:F}=e.r(499095),{URLSerializer:k}=e.r(997726),{kConstruct:M}=e.r(227235),T=e.r(57328),{getMaxListeners:L,setMaxListeners:v,defaultMaxListeners:H}=e.r(687769),Y=Symbol("abortController"),O=new FinalizationRegistry(({signal:e,abort:A})=>{e.removeEventListener("abort",A)}),x=new WeakMap;try{r=L(new AbortController().signal)>0}catch{r=!1}function G(e){return function A(){let t=e.deref();if(void 0!==t){O.unregister(A),this.removeEventListener("abort",A),t.abort(this.reason);let e=x.get(t.signal);if(void 0!==e){if(0!==e.size){for(let A of e){let e=A.deref();void 0!==e&&e.abort(this.reason)}e.clear()}x.delete(t.signal)}}}}let V=!1;class J{#e1;#e2;#P;#c;constructor(e,A){let t;if(F.util.markAsUncloneable(this),e===M)return;F.argumentLengthCheck(arguments,1,"Request constructor"),e=F.converters.RequestInfo(e),A=F.converters.RequestInit(A);let n=null,o=null;const c=d.settingsObject.baseUrl;let I=null;if("string"==typeof e){let t;this.#e2=A.dispatcher;try{t=new URL(e,c)}catch(A){throw TypeError("Failed to parse URL from "+e,{cause:A})}if(t.username||t.password)throw TypeError("Request cannot be constructed from a URL that includes credentials: "+e);n=X({urlList:[t]}),o="cors"}else T(F.is.Request(e)),n=e.#c,I=e.#e1,this.#e2=A.dispatcher||e.#e2;const y=d.settingsObject.origin;let D="client";if(n.window?.constructor?.name==="EnvironmentSettingsObject"&&C(n.window,y)&&(D=n.window),null!=A.window)throw TypeError(`'window' option '${D}' must be null`);"window"in A&&(D="no-window"),n=X({method:n.method,headersList:n.headersList,unsafeRequest:n.unsafeRequest,client:d.settingsObject,window:D,priority:n.priority,origin:n.origin,referrer:n.referrer,referrerPolicy:n.referrerPolicy,mode:n.mode,credentials:n.credentials,cache:n.cache,redirect:n.redirect,integrity:n.integrity,keepalive:n.keepalive,reloadNavigation:n.reloadNavigation,historyNavigation:n.historyNavigation,urlList:[...n.urlList]});const S=0!==Object.keys(A).length;if(S&&("navigate"===n.mode&&(n.mode="same-origin"),n.reloadNavigation=!1,n.historyNavigation=!1,n.origin="client",n.referrer="client",n.referrerPolicy="",n.url=n.urlList[n.urlList.length-1],n.urlList=[n.url]),void 0!==A.referrer){const e=A.referrer;if(""===e)n.referrer="no-referrer";else{let A;try{A=new URL(e,c)}catch(A){throw TypeError(`Referrer "${e}" is not a valid URL.`,{cause:A})}"about:"===A.protocol&&"client"===A.hostname||y&&!C(A,d.settingsObject.baseUrl)?n.referrer="client":n.referrer=A}}if(void 0!==A.referrerPolicy&&(n.referrerPolicy=A.referrerPolicy),"navigate"===(t=void 0!==A.mode?A.mode:o))throw F.errors.exception({header:"Request constructor",message:"invalid request mode navigate."});if(null!=t&&(n.mode=t),void 0!==A.credentials&&(n.credentials=A.credentials),void 0!==A.cache&&(n.cache=A.cache),"only-if-cached"===n.cache&&"same-origin"!==n.mode)throw TypeError("'only-if-cached' can be set only with 'same-origin' mode");if(void 0!==A.redirect&&(n.redirect=A.redirect),null!=A.integrity&&(n.integrity=String(A.integrity)),void 0!==A.keepalive&&(n.keepalive=!!A.keepalive),void 0!==A.method){let e=A.method;const t=U[e];if(void 0!==t)n.method=t;else{if(!B(e))throw TypeError(`'${e}' is not a valid HTTP method.`);const A=e.toUpperCase();if(f.has(A))throw TypeError(`'${e}' HTTP method is unsupported.`);e=b[A]??e,n.method=e}V||"patch"!==n.method||(process.emitWarning("Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.",{code:"UNDICI-FETCH-patch"}),V=!0)}void 0!==A.signal&&(I=A.signal),this.#c=n;const w=new AbortController;if(this.#e1=w.signal,null!=I)if(I.aborted)w.abort(I.reason);else{this[Y]=w;const e=G(new WeakRef(w));r&&L(I)===H&&v(1500,I),u.addAbortListener(I,e),O.register(w,{signal:I,abort:e},e)}if(this.#P=new a(M),E(this.#P,n.headersList),h(this.#P,"request"),"no-cors"===t){if(!p.has(n.method))throw TypeError(`'${n.method} is unsupported in no-cors mode.`);h(this.#P,"request-no-cors")}if(S){const e=Q(this.#P),t=void 0!==A.headers?A.headers:new g(e);if(e.clear(),t instanceof g){for(const{name:A,value:r}of t.rawValues())e.append(A,r,!1);e.cookies=t.cookies}else l(this.#P,t)}const m=F.is.Request(e)?e.#c.body:null;if((null!=A.body||null!=m)&&("GET"===n.method||"HEAD"===n.method))throw TypeError("Request with GET/HEAD method cannot have body.");let N=null;if(null!=A.body){const[e,t]=s(A.body,n.keepalive);N=e,t&&!Q(this.#P).contains("content-type",!0)&&this.#P.append("content-type",t,!0)}const R=N??m;if(null!=R&&null==R.source){if(null!=N&&null==A.duplex)throw TypeError("RequestInit: duplex option is required when sending a body.");if("same-origin"!==n.mode&&"cors"!==n.mode)throw TypeError('If request is made from ReadableStream, mode should be "same-origin" or "cors"');n.useCORSPreflightFlag=!0}let k=R;if(null==N&&null!=m){if(i(e.#c))throw TypeError("Cannot construct a Request with a Request object that has already been used.");const A=new TransformStream;m.stream.pipeThrough(A),k={source:m.source,length:m.length,stream:A.readable}}this.#c.body=k}get method(){return F.brandCheck(this,J),this.#c.method}get url(){return F.brandCheck(this,J),k(this.#c.url)}get headers(){return F.brandCheck(this,J),this.#P}get destination(){return F.brandCheck(this,J),this.#c.destination}get referrer(){return(F.brandCheck(this,J),"no-referrer"===this.#c.referrer)?"":"client"===this.#c.referrer?"about:client":this.#c.referrer.toString()}get referrerPolicy(){return F.brandCheck(this,J),this.#c.referrerPolicy}get mode(){return F.brandCheck(this,J),this.#c.mode}get credentials(){return F.brandCheck(this,J),this.#c.credentials}get cache(){return F.brandCheck(this,J),this.#c.cache}get redirect(){return F.brandCheck(this,J),this.#c.redirect}get integrity(){return F.brandCheck(this,J),this.#c.integrity}get keepalive(){return F.brandCheck(this,J),this.#c.keepalive}get isReloadNavigation(){return F.brandCheck(this,J),this.#c.reloadNavigation}get isHistoryNavigation(){return F.brandCheck(this,J),this.#c.historyNavigation}get signal(){return F.brandCheck(this,J),this.#e1}get body(){return F.brandCheck(this,J),this.#c.body?this.#c.body.stream:null}get bodyUsed(){return F.brandCheck(this,J),!!this.#c.body&&u.isDisturbed(this.#c.body.stream)}get duplex(){return F.brandCheck(this,J),"half"}clone(){if(F.brandCheck(this,J),i(this.#c))throw TypeError("unusable");let e=z(this.#c),A=new AbortController;if(this.signal.aborted)A.abort(this.signal.reason);else{let e=x.get(this.signal);void 0===e&&(e=new Set,x.set(this.signal,e));let t=new WeakRef(A);e.add(t),u.addAbortListener(A.signal,G(t))}return K(e,this.#e2,A.signal,c(this.#P))}[I.inspect.custom](e,A){null===A.depth&&(A.depth=2),A.colors??=!0;let t={method:this.method,url:this.url,headers:this.headers,destination:this.destination,referrer:this.referrer,referrerPolicy:this.referrerPolicy,mode:this.mode,credentials:this.credentials,cache:this.cache,redirect:this.redirect,integrity:this.integrity,keepalive:this.keepalive,isReloadNavigation:this.isReloadNavigation,isHistoryNavigation:this.isHistoryNavigation,signal:this.signal};return`Request ${I.formatWithOptions(A,t)}`}static setRequestSignal(e,A){return e.#e1=A,e}static getRequestDispatcher(e){return e.#e2}static setRequestDispatcher(e,A){e.#e2=A}static setRequestHeaders(e,A){e.#P=A}static getRequestState(e){return e.#c}static setRequestState(e,A){e.#c=A}}let{setRequestSignal:_,getRequestDispatcher:P,setRequestDispatcher:W,setRequestHeaders:q,getRequestState:Z,setRequestState:j}=J;function X(e){return{method:e.method??"GET",localURLsOnly:e.localURLsOnly??!1,unsafeRequest:e.unsafeRequest??!1,body:e.body??null,client:e.client??null,reservedClient:e.reservedClient??null,replacesClientId:e.replacesClientId??"",window:e.window??"client",keepalive:e.keepalive??!1,serviceWorkers:e.serviceWorkers??"all",initiator:e.initiator??"",destination:e.destination??"",priority:e.priority??null,origin:e.origin??"client",policyContainer:e.policyContainer??"client",referrer:e.referrer??"client",referrerPolicy:e.referrerPolicy??"",mode:e.mode??"no-cors",useCORSPreflightFlag:e.useCORSPreflightFlag??!1,credentials:e.credentials??"same-origin",useCredentials:e.useCredentials??!1,cache:e.cache??"default",redirect:e.redirect??"follow",integrity:e.integrity??"",cryptoGraphicsNonceMetadata:e.cryptoGraphicsNonceMetadata??"",parserMetadata:e.parserMetadata??"",reloadNavigation:e.reloadNavigation??!1,historyNavigation:e.historyNavigation??!1,userActivation:e.userActivation??!1,taintedOrigin:e.taintedOrigin??!1,redirectCount:e.redirectCount??0,responseTainting:e.responseTainting??"basic",preventNoCacheCacheControlHeaderModification:e.preventNoCacheCacheControlHeaderModification??!1,done:e.done??!1,timingAllowFailed:e.timingAllowFailed??!1,useURLCredentials:e.useURLCredentials??void 0,traversableForUserPrompts:e.traversableForUserPrompts??"client",urlList:e.urlList,url:e.urlList[0],headersList:e.headersList?new g(e.headersList):new g}}function z(e){let A=X({...e,body:null});return null!=e.body&&(A.body=o(e.body)),A}function K(e,A,t,r){let s=new J(M);j(s,e),W(s,A),_(s,t);let n=new a(M);return q(s,n),E(n,e.headersList),h(n,r),s}Reflect.deleteProperty(J,"setRequestSignal"),Reflect.deleteProperty(J,"getRequestDispatcher"),Reflect.deleteProperty(J,"setRequestDispatcher"),Reflect.deleteProperty(J,"setRequestHeaders"),Reflect.deleteProperty(J,"getRequestState"),Reflect.deleteProperty(J,"setRequestState"),n(J,Z),Object.defineProperties(J.prototype,{method:R,url:R,headers:R,redirect:R,clone:R,signal:R,duplex:R,destination:R,body:R,bodyUsed:R,isHistoryNavigation:R,isReloadNavigation:R,keepalive:R,integrity:R,cache:R,credentials:R,attribute:R,referrerPolicy:R,referrer:R,mode:R,[Symbol.toStringTag]:{value:"Request",configurable:!0}}),F.is.Request=F.util.MakeTypeAssertion(J),F.converters.RequestInfo=function(e){return"string"==typeof e?F.converters.USVString(e):F.is.Request(e)?e:F.converters.USVString(e)},F.converters.RequestInit=F.dictionaryConverter([{key:"method",converter:F.converters.ByteString},{key:"headers",converter:F.converters.HeadersInit},{key:"body",converter:F.nullableConverter(F.converters.BodyInit)},{key:"referrer",converter:F.converters.USVString},{key:"referrerPolicy",converter:F.converters.DOMString,allowedValues:y},{key:"mode",converter:F.converters.DOMString,allowedValues:S},{key:"credentials",converter:F.converters.DOMString,allowedValues:w},{key:"cache",converter:F.converters.DOMString,allowedValues:m},{key:"redirect",converter:F.converters.DOMString,allowedValues:D},{key:"integrity",converter:F.converters.DOMString},{key:"keepalive",converter:F.converters.boolean},{key:"signal",converter:F.nullableConverter(e=>F.converters.AbortSignal(e,"RequestInit","signal"))},{key:"window",converter:F.converters.any},{key:"duplex",converter:F.converters.DOMString,allowedValues:N},{key:"dispatcher",converter:F.converters.any},{key:"priority",converter:F.converters.DOMString,allowedValues:["high","low","auto"],defaultValue:()=>"auto"}]),A.exports={Request:J,makeRequest:X,fromInnerRequest:K,cloneRequest:z,getRequestDispatcher:P,getRequestState:Z}},220149,(e,A,t)=>{"use strict";let r,s=e.r(57328),{runtimeFeatures:n}=e.r(738493),o=new Map([["sha256",0],["sha384",1],["sha512",2]]);if(n.has("crypto")){let A=(r=e.r(666680)).getHashes();for(let e of(0===A.length&&o.clear(),o.keys()))!1===A.includes(e)&&o.delete(e)}else o.clear();let i=Map.prototype.get.bind(o),a=Map.prototype.has.bind(o),l=!1===n.has("crypto")||0===o.size?()=>!0:(e,A)=>{let t=h(A);if(0===t.length)return!0;for(let A of g(t)){let t=A.alg,r=A.val;if(E(c(t,e),r))return!0}return!1};function g(e){let A=[],t=null;for(let r of e){if(s(a(r.alg),"Invalid SRI hash algorithm token"),0===A.length){A.push(r),t=r;continue}let e=i(t.alg),n=i(r.alg);n<e||(n>e?(t=r,A[0]=r,A.length=1):A.push(r))}return A}function h(e){let A=[];for(let t of e.split(" ")){let e=t.split("?",1)[0],r="",s=[e.slice(0,6),e.slice(7)],n=s[0];if(!a(n))continue;s[1]&&(r=s[1]);let o={alg:n,val:r};A.push(o)}return A}let c=(e,A)=>r.hash(e,A,"base64");function E(e,A){let t=e.length;0!==t&&"="===e[t-1]&&(t-=1),0!==t&&"="===e[t-1]&&(t-=1);let r=A.length;if(0!==r&&"="===A[r-1]&&(r-=1),0!==r&&"="===A[r-1]&&(r-=1),t!==r)return!1;for(let r=0;r<t;++r)if(e[r]!==A[r]&&("+"!==e[r]||"-"!==A[r])&&("/"!==e[r]||"_"!==A[r]))return!1;return!0}A.exports={applyAlgorithmToBytes:c,bytesMatch:l,caseSensitiveMatch:E,isValidSRIHashAlgorithm:a,getStrongestMetadata:g,parseMetadata:h}},486355,(e,A,t)=>{"use strict";let r,{makeNetworkError:s,makeAppropriateNetworkError:n,filterResponse:o,makeResponse:i,fromInnerResponse:a,getResponseState:l}=e.r(312148),{HeadersList:g}=e.r(700419),{Request:h,cloneRequest:c,getRequestDispatcher:E,getRequestState:Q}=e.r(440796),u=e.r(727028),{makePolicyContainer:I,clonePolicyContainer:B,requestBadPort:C,TAOCheck:d,appendRequestOriginHeader:f,responseLocationURL:p,requestCurrentURL:y,setRequestReferrerPolicyOnRedirect:D,tryUpgradeRequestToAPotentiallyTrustworthyURL:S,createOpaqueTimingInfo:w,appendFetchMetadata:m,corsCheck:N,crossOriginResourcePolicyCheck:R,determineRequestsReferrer:b,coarsenedSharedCurrentTime:U,sameOrigin:F,isCancelled:k,isAborted:M,isErrorLike:T,fullyReadBody:L,readableStreamClose:v,urlIsLocal:H,urlIsHttpHttpsScheme:Y,urlHasHttpsScheme:O,clampAndCoarsenConnectionTimingInfo:x,simpleRangeHeaderValue:G,buildContentRange:V,createInflate:J,extractMimeType:_,hasAuthenticationEntry:P,includesCredentials:W,isTraversableNavigable:q}=e.r(88435),Z=e.r(57328),{safelyExtractBody:j,extractBody:X}=e.r(818719),{redirectStatusSet:z,nullBodyStatus:K,safeMethodsSet:$,requestBodyHeader:ee,subresourceSet:eA}=e.r(208309),et=e.r(687769),{Readable:er,pipeline:es,finished:en,isErrored:eo,isReadable:ei}=e.r(81111),{addAbortListener:ea,bufferToLowerCasedHeaderName:el}=e.r(504021),{dataURLProcessor:eg,serializeAMimeType:eh,minimizeSupportedMimeType:ec}=e.r(997726),{getGlobalDispatcher:eE}=e.r(979590),{webidl:eQ}=e.r(499095),{STATUS_CODES:eu}=e.r(347299),{bytesMatch:eI}=e.r(220149),{createDeferredPromise:eB}=e.r(899779),{isomorphicEncode:eC}=e.r(279869),{runtimeFeatures:ed}=e.r(738493),ef=ed.has("zstd"),ep=["GET","HEAD"],ey="u">typeof __UNDICI_IS_NODE__||"u">typeof esbuildDetection?"node":"undici";class eD extends et{constructor(e){super(),this.dispatcher=e,this.connection=null,this.dump=!1,this.state="ongoing"}terminate(e){"ongoing"===this.state&&(this.state="terminated",this.connection?.destroy(e),this.emit("terminated",e))}abort(e){"ongoing"===this.state&&(this.state="aborted",e||(e=new DOMException("The operation was aborted.","AbortError")),this.serializedAbortReason=e,this.connection?.destroy(e),this.emit("terminated",e))}}function eS(e){ew(e,"fetch")}function ew(e,A="other"){if("error"===e.type&&e.aborted||!e.urlList?.length)return;let t=e.urlList[0],r=e.timingInfo,s=e.cacheState;Y(t)&&null!==r&&(e.timingAllowPassed||(r=w({startTime:r.startTime}),s=""),r.endTime=U(),e.timingInfo=r,em(r,t.href,A,globalThis,s,"",e.status))}let em=performance.markResourceTiming;function eN(e,A,t,r,s){if(e&&e.reject(r),A.body?.stream!=null&&ei(A.body.stream)&&A.body.stream.cancel(r).catch(e=>{if("ERR_INVALID_STATE"!==e.code)throw e}),null==t)return;let n=l(t);n.body?.stream!=null&&ei(n.body.stream)&&s.error(r)}function eR({request:e,processRequestBodyChunkLength:A,processRequestEndOfBody:t,processResponse:r,processResponseEndOfBody:s,processResponseConsumeBody:n,useParallelQueue:o=!1,dispatcher:i=eE(),requestObject:a=null}){Z(i);let l=null,g=!1;null!=e.client&&(l=e.client.globalObject,g=e.client.crossOriginIsolatedCapability);let h=w({startTime:U(g)}),c={controller:new eD(i),request:e,timingInfo:h,processRequestBodyChunkLength:A,processRequestEndOfBody:t,processResponse:r,processResponseConsumeBody:n,processResponseEndOfBody:s,taskDestination:l,crossOriginIsolatedCapability:g,requestObject:a};return Z(!e.body||e.body.stream),"client"===e.window&&(e.window=e.client?.globalObject?.constructor?.name==="Window"?e.client:"no-window"),"client"===e.origin&&(e.origin=e.client.origin),"client"===e.policyContainer&&(null!=e.client?e.policyContainer=B(e.client.policyContainer):e.policyContainer=I()),e.headersList.contains("accept",!0)||e.headersList.append("accept","*/*",!0),e.headersList.contains("accept-language",!0)||e.headersList.append("accept-language","*",!0),e.priority,eA.has(e.destination),eb(c,!1),c.controller}async function eb(e,A){try{let t=e.request,r=null;if(t.localURLsOnly&&!H(y(t))&&(r=s("local URLs only")),S(t),"blocked"===C(t)&&(r=s("bad port")),""===t.referrerPolicy&&(t.referrerPolicy=t.policyContainer.referrerPolicy),"no-referrer"!==t.referrer&&(t.referrer=b(t)),null===r){let A=y(t);F(A,t.url)&&"basic"===t.responseTainting||"data:"===A.protocol||"navigate"===t.mode||"websocket"===t.mode?(t.responseTainting="basic",r=await eU(e)):"same-origin"===t.mode?r=s('request mode cannot be "same-origin"'):"no-cors"===t.mode?"follow"!==t.redirect?r=s('redirect mode cannot be "follow" for "no-cors" request'):(t.responseTainting="opaque",r=await eU(e)):Y(y(t))?(t.responseTainting="cors",r=await ek(e)):r=s("URL scheme must be a HTTP(S) scheme")}if(A)return r;0===r.status||r.internalResponse||(t.responseTainting,"basic"===t.responseTainting?r=o(r,"basic"):"cors"===t.responseTainting?r=o(r,"cors"):"opaque"===t.responseTainting?r=o(r,"opaque"):Z(!1));let n=0===r.status?r:r.internalResponse;if(0===n.urlList.length&&n.urlList.push(...t.urlList),t.timingAllowFailed||(r.timingAllowPassed=!0),"opaque"===r.type&&206===n.status&&n.rangeRequested&&!t.headers.contains("range",!0)&&(r=n=s()),0!==r.status&&("HEAD"===t.method||"CONNECT"===t.method||K.includes(n.status))&&(n.body=null,e.controller.dump=!0),t.integrity){let A=A=>eF(e,s(A));if("opaque"===t.responseTainting||null==r.body)return void A(r.error);L(r.body,s=>{eI(s,t.integrity)?(r.body=j(s)[0],eF(e,r)):A("integrity mismatch")},A)}else eF(e,r)}catch(A){e.controller.terminate(A)}}function eU(A){if(k(A)&&0===A.request.redirectCount)return Promise.resolve(n(A));let{request:t}=A,{protocol:o}=y(t);switch(o){case"about:":return Promise.resolve(s("about scheme is not supported"));case"blob:":{r||(r=e.r(951615).resolveObjectURL);let A=y(t);if(0!==A.search.length)return Promise.resolve(s("NetworkError when attempting to fetch resource."));let n=r(A.toString());if("GET"!==t.method||!eQ.is.Blob(n))return Promise.resolve(s("invalid method"));let o=i(),a=n.size,l=eC(`${a}`),g=n.type;if(t.headersList.contains("range",!0)){o.rangeRequested=!0;let e=G(t.headersList.get("range",!0),!0);if("failure"===e)return Promise.resolve(s("failed to fetch the data URL"));let{rangeStartValue:A,rangeEndValue:r}=e;if(null===A)r=(A=a-r)+r-1;else{if(A>=a)return Promise.resolve(s("Range start is greater than the blob's size."));(null===r||r>=a)&&(r=a-1)}let i=n.slice(A,r+1,g);o.body=X(i)[0];let l=eC(`${i.size}`),h=V(A,r,a);o.status=206,o.statusText="Partial Content",o.headersList.set("content-length",l,!0),o.headersList.set("content-type",g,!0),o.headersList.set("content-range",h,!0)}else{let e=X(n);o.statusText="OK",o.body=e[0],o.headersList.set("content-length",l,!0),o.headersList.set("content-type",g,!0)}return Promise.resolve(o)}case"data:":{let e=eg(y(t));if("failure"===e)return Promise.resolve(s("failed to fetch the data URL"));return Promise.resolve(i({statusText:"OK",headersList:[["content-type",{name:"Content-Type",value:eh(e.mimeType)}]],body:j(e.body)[0]}))}case"file:":return Promise.resolve(s("not implemented... yet..."));case"http:":case"https:":return ek(A).catch(e=>s(e));default:return Promise.resolve(s("unknown scheme"))}}function eF(e,A){let t=e.timingInfo,r=()=>{let r=Date.now();"document"===e.request.destination&&(e.controller.fullTimingInfo=t),e.controller.reportTimingSteps=()=>{if(!Y(e.request.url))return;t.endTime=r;let s=A.cacheState,n=A.bodyInfo;A.timingAllowPassed||(t=w(t),s="");let o=0;if("navigator"!==e.request.mode||!A.hasCrossOriginRedirects){o=A.status;let e=_(A.headersList);"failure"!==e&&(n.contentType=ec(e))}null!=e.request.initiatorType&&em(t,e.request.url.href,e.request.initiatorType,globalThis,s,n,o)},queueMicrotask(()=>void(e.request.done=!0,null!=e.processResponseEndOfBody&&queueMicrotask(()=>e.processResponseEndOfBody(A)),null!=e.request.initiatorType&&e.controller.reportTimingSteps()))};null!=e.processResponse&&queueMicrotask(()=>{e.processResponse(A),e.processResponse=null});let s="error"===A.type?A:A.internalResponse??A;null==s.body?r():en(s.body.stream,()=>{r()})}async function ek(e){let A=e.request,t=null,r=null,n=e.timingInfo;if(A.serviceWorkers,null===t){if("follow"===A.redirect&&(A.serviceWorkers="none"),r=t=await eM(e),"cors"===A.responseTainting&&"failure"===N(A,t))return s("cors failure");"failure"===d(A,t)&&(A.timingAllowFailed=!0)}return("opaque"===A.responseTainting||"opaque"===t.type)&&"blocked"===R(A.origin,A.client,A.destination,r)?s("blocked"):(z.has(r.status)&&("manual"!==A.redirect&&e.controller.connection.destroy(void 0,!1),"error"===A.redirect?t=s("unexpected redirect"):"manual"===A.redirect?t=r:"follow"===A.redirect?t=await function(e,A){let t,r=e.request,n=A.internalResponse?A.internalResponse:A;try{if(t=p(n,y(r).hash),null==t)return A}catch(e){return Promise.resolve(s(e))}if(!Y(t))return Promise.resolve(s("URL scheme must be a HTTP(S) scheme"));if(20===r.redirectCount)return Promise.resolve(s("redirect count exceeded"));if(r.redirectCount+=1,"cors"===r.mode&&(t.username||t.password)&&!F(r,t))return Promise.resolve(s('cross origin not allowed for request mode "cors"'));if("cors"===r.responseTainting&&(t.username||t.password))return Promise.resolve(s('URL cannot contain credentials for request mode "cors"'));if(303!==n.status&&null!=r.body&&null==r.body.source)return Promise.resolve(s());if([301,302].includes(n.status)&&"POST"===r.method||303===n.status&&!ep.includes(r.method))for(let e of(r.method="GET",r.body=null,ee))r.headersList.delete(e);F(y(r),t)||(r.headersList.delete("authorization",!0),r.headersList.delete("proxy-authorization",!0),r.headersList.delete("cookie",!0),r.headersList.delete("host",!0)),null!=r.body&&(Z(null!=r.body.source),r.body=j(r.body.source)[0]);let o=e.timingInfo;return o.redirectEndTime=o.postRedirectStartTime=U(e.crossOriginIsolatedCapability),0===o.redirectStartTime&&(o.redirectStartTime=o.startTime),r.urlList.push(t),D(r,n),eb(e,!0)}(e,t):Z(!1)),t.timingInfo=n,t)}async function eM(e,A=!1,t=!1){let r=e.request,o=null,i=null,a=null;"no-window"===r.window&&"error"===r.redirect?(o=e,i=r):(i=c(r),(o={...e}).request=i);let l="include"===r.credentials||"same-origin"===r.credentials&&"basic"===r.responseTainting,g=i.body?i.body.length:null,h=null;if(null==i.body&&["POST","PUT"].includes(i.method)&&(h="0"),null!=g&&(h=eC(`${g}`)),null!=h&&i.headersList.append("content-length",h,!0),null!=g&&i.keepalive,eQ.is.URL(i.referrer)&&i.headersList.append("referer",eC(i.referrer.href),!0),f(i),m(i),i.headersList.contains("user-agent",!0)||i.headersList.append("user-agent",ey,!0),"default"===i.cache&&(i.headersList.contains("if-modified-since",!0)||i.headersList.contains("if-none-match",!0)||i.headersList.contains("if-unmodified-since",!0)||i.headersList.contains("if-match",!0)||i.headersList.contains("if-range",!0))&&(i.cache="no-store"),"no-cache"!==i.cache||i.preventNoCacheCacheControlHeaderModification||i.headersList.contains("cache-control",!0)||i.headersList.append("cache-control","max-age=0",!0),("no-store"===i.cache||"reload"===i.cache)&&(i.headersList.contains("pragma",!0)||i.headersList.append("pragma","no-cache",!0),i.headersList.contains("cache-control",!0)||i.headersList.append("cache-control","no-cache",!0)),i.headersList.contains("range",!0)&&i.headersList.append("accept-encoding","identity",!0),i.headersList.contains("accept-encoding",!0)||(O(y(i))?i.headersList.append("accept-encoding","br, gzip, deflate",!0):i.headersList.append("accept-encoding","gzip, deflate",!0)),i.headersList.delete("host",!0),l&&!i.headersList.contains("authorization",!0)){let e=null;if(P(i)&&(void 0===i.useURLCredentials||!W(y(i))));else if(W(y(i))&&A){let{username:A,password:t}=y(i);e=`Basic ${Buffer.from(`${A}:${t}`).toString("base64")}`}null!==e&&i.headersList.append("Authorization",e,!1)}if(i.cache="no-store","no-store"!==i.cache&&i.cache,null==a){if("only-if-cached"===i.cache)return s("only if cached");let e=await eT(o,l,t);!$.has(i.method)&&e.status>=200&&e.status,null==a&&(a=e)}if(a.urlList=[...i.urlList],i.headersList.contains("range",!0)&&(a.rangeRequested=!0),a.requestIncludesCredentials=l,401===a.status&&"cors"!==i.responseTainting&&l&&q(r.traversableForUserPrompts)){if(null!=r.body){if(null==r.body.source)return s("expected non-null body source");r.body=j(r.body.source)[0]}if(void 0===r.useURLCredentials||A)return k(e)?n(e):a;e.controller.connection.destroy(),a=await eM(e,!0)}if(407===a.status)return"no-window"===r.window?s():k(e)?n(e):s("proxy authentication required");if(421===a.status&&!t&&(null==r.body||null!=r.body.source)){if(k(e))return n(e);e.controller.connection.destroy(),a=await eM(e,A,!0)}return a}async function eT(e,A=!1,t=!1){Z(!e.controller.connection||e.controller.connection.destroyed),e.controller.connection={abort:null,destroyed:!1,destroy(e,A=!0){!this.destroyed&&(this.destroyed=!0,A&&this.abort?.(e??new DOMException("The operation was aborted.","AbortError")))}};let r=e.request,o=null,a=e.timingInfo;r.cache="no-store",r.mode;let l=null;if(null==r.body&&e.processRequestEndOfBody)queueMicrotask(()=>e.processRequestEndOfBody());else if(null!=r.body){let A=async function*(A){k(e)||(yield A,e.processRequestBodyChunkLength?.(A.byteLength))};l=async function*(){try{for await(let e of r.body.stream)yield*A(e);!k(e)&&e.processRequestEndOfBody&&e.processRequestEndOfBody()}catch(A){k(e)||("AbortError"===A.name?e.controller.abort():e.controller.terminate(A))}}()}try{let{body:A,status:t,statusText:s,headersList:n,socket:h}=await function({body:A}){let t=y(r),s=e.controller.dispatcher,n=t.pathname+t.search,o=0===t.search.length&&"?"===t.href[t.href.length-t.hash.length-1];return new Promise((i,l)=>s.dispatch({path:o?`${n}?`:n,origin:t.origin,method:r.method,body:s.isMockActive?r.body&&(r.body.source||r.body.stream):A,headers:r.headersList.entries,maxRedirections:0,upgrade:"websocket"===r.mode?"websocket":void 0},{body:null,abort:null,onConnect(A){let{connection:t}=e.controller;a.finalConnectionTimingInfo=x(void 0,a.postRedirectStartTime,e.crossOriginIsolatedCapability),t.destroyed?A(new DOMException("The operation was aborted.","AbortError")):(e.controller.on("terminated",A),this.abort=t.abort=A),a.finalNetworkRequestStartTime=U(e.crossOriginIsolatedCapability)},onResponseStarted(){a.finalNetworkResponseStartTime=U(e.crossOriginIsolatedCapability)},onHeaders(e,A,t,s){if(e<200)return!1;let n=new g;for(let e=0;e<A.length;e+=2)n.append(el(A[e]),A[e+1].toString("latin1"),!0);let o=n.get("location",!0);this.body=new er({read:t});let a=o&&"follow"===r.redirect&&z.has(e),h=[];if("HEAD"!==r.method&&"CONNECT"!==r.method&&!K.includes(e)&&!a){let e=n.get("content-encoding",!0),A=e?e.toLowerCase().split(","):[];if(A.length>5)return l(Error(`too many content-encodings in response: ${A.length}, maximum allowed is 5`)),!0;for(let e=A.length-1;e>=0;--e){let t=A[e].trim();if("x-gzip"===t||"gzip"===t)h.push(u.createGunzip({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if("deflate"===t)h.push(J({flush:u.constants.Z_SYNC_FLUSH,finishFlush:u.constants.Z_SYNC_FLUSH}));else if("br"===t)h.push(u.createBrotliDecompress({flush:u.constants.BROTLI_OPERATION_FLUSH,finishFlush:u.constants.BROTLI_OPERATION_FLUSH}));else if("zstd"===t&&ef)h.push(u.createZstdDecompress({flush:u.constants.ZSTD_e_continue,finishFlush:u.constants.ZSTD_e_end}));else{h.length=0;break}}}let c=this.onError.bind(this);return i({status:e,statusText:s,headersList:n,body:h.length?es(this.body,...h,e=>{e&&this.onError(e)}).on("error",c):this.body.on("error",c)}),!0},onData(A){if(!e.controller.dump)return a.encodedBodySize+=A.byteLength,this.body.push(A)},onComplete(){this.abort&&e.controller.off("terminated",this.abort),e.controller.ended=!0,this.body.push(null)},onError(A){this.abort&&e.controller.off("terminated",this.abort),this.body?.destroy(A),e.controller.terminate(A),l(A)},onRequestUpgrade(e,A,t,r){if(null!=r.session&&200!==A||null==r.session&&101!==A)return!1;let s=new g;for(let[e,A]of Object.entries(t)){if(null==A)continue;let t=e.toLowerCase();if(Array.isArray(A))for(let e of A)s.append(t,String(e),!0);else s.append(t,String(A),!0)}return i({status:A,statusText:eu[A],headersList:s,socket:r}),!0},onUpgrade(e,A,t){if(null!=t.session&&200!==e||null==t.session&&101!==e)return!1;let r=new g;for(let e=0;e<A.length;e+=2)r.append(el(A[e]),A[e+1].toString("latin1"),!0);return i({status:e,statusText:eu[e],headersList:r,socket:t}),!0}}))}({body:l});if(h)o=i({status:t,statusText:s,headersList:n,socket:h});else{let r=A[Symbol.asyncIterator]();e.controller.next=()=>r.next(),o=i({status:t,statusText:s,headersList:n})}}catch(A){if("AbortError"===A.name)return e.controller.connection.destroy(),n(e,A);return s(A)}let h=new ReadableStream({start(A){e.controller.controller=A},pull:()=>e.controller.resume(),cancel:A=>{k(e)||e.controller.abort(A)},type:"bytes"});return o.body={stream:h,source:null,length:null},e.controller.resume||e.controller.on("terminated",function(A){M(e)?(o.aborted=!0,ei(h)&&e.controller.controller.error(e.controller.serializedAbortReason)):ei(h)&&e.controller.controller.error(TypeError("terminated",{cause:T(A)?A:void 0})),e.controller.connection.destroy()}),e.controller.resume=async()=>{for(;;){let A,t;try{let{done:t,value:r}=await e.controller.next();if(M(e))break;A=t?void 0:r}catch(r){e.controller.ended&&!a.encodedBodySize?A=void 0:(A=r,t=!0)}if(void 0===A){v(e.controller.controller),function(e,A){e.request.done=!0,null!=e.processResponseDone&&queueMicrotask(()=>e.processResponseDone(A))}(e,o);return}if(a.decodedBodySize+=A?.byteLength??0,t)return void e.controller.terminate(A);let r=new Uint8Array(A);if(r.byteLength&&e.controller.controller.enqueue(r),eo(h))return void e.controller.terminate();if(e.controller.controller.desiredSize<=0)return}},o}A.exports={fetch:function(e,A){let t;eQ.argumentLengthCheck(arguments,1,"globalThis.fetch");let r=eB();try{t=new h(e,A)}catch(e){return r.reject(e),r.promise}let s=Q(t);if(t.signal.aborted)return eN(r,s,null,t.signal.reason,null),r.promise;let n=s.client.globalObject;n?.constructor?.name==="ServiceWorkerGlobalScope"&&(s.serviceWorkers="none");let o=null,i=!1,l=null;return ea(t.signal,()=>{i=!0,Z(null!=l),l.abort(t.signal.reason);let e=o?.deref();eN(r,s,e,t.signal.reason,l.controller)}),l=eR({request:s,processResponseEndOfBody:eS,processResponse:e=>{if(!i){if(e.aborted)return void eN(r,s,o,l.serializedAbortReason,l.controller);if("error"===e.type)return void r.reject(TypeError("fetch failed",{cause:e.error}));o=new WeakRef(a(e,"immutable")),r.resolve(o.deref()),r=null}},dispatcher:E(t),requestObject:t}),r.promise},Fetch:eD,fetching:eR,finalizeAndReportTiming:ew}},409301,(e,A,t)=>{"use strict";let r=e.r(57328),{URLSerializer:s}=e.r(997726),{isValidHeaderName:n}=e.r(88435);A.exports={urlEquals:function(e,A,t=!1){return s(e,t)===s(A,t)},getFieldValues:function(e){r(null!==e);let A=[];for(let t of e.split(","))n(t=t.trim())&&A.push(t);return A}}},950877,(e,A,t)=>{"use strict";let r=e.r(57328),{kConstruct:s}=e.r(227235),{urlEquals:n,getFieldValues:o}=e.r(409301),{kEnumerableProperty:i,isDisturbed:a}=e.r(504021),{webidl:l}=e.r(499095),{cloneResponse:g,fromInnerResponse:h,getResponseState:c}=e.r(312148),{Request:E,fromInnerRequest:Q,getRequestState:u}=e.r(440796),{fetching:I}=e.r(486355),{urlIsHttpHttpsScheme:B,readAllBytes:C}=e.r(88435),{createDeferredPromise:d}=e.r(899779);class f{#e9;constructor(){arguments[0]!==s&&l.illegalConstructor(),l.util.markAsUncloneable(this),this.#e9=arguments[1]}async match(e,A={}){l.brandCheck(this,f);let t="Cache.match";l.argumentLengthCheck(arguments,1,t),e=l.converters.RequestInfo(e),A=l.converters.CacheQueryOptions(A,t,"options");let r=this.#e4(e,A,1);if(0!==r.length)return r[0]}async matchAll(e,A={}){return l.brandCheck(this,f),void 0!==e&&(e=l.converters.RequestInfo(e)),A=l.converters.CacheQueryOptions(A,"Cache.matchAll","options"),this.#e4(e,A)}async add(e){l.brandCheck(this,f),l.argumentLengthCheck(arguments,1,"Cache.add");let A=[e=l.converters.RequestInfo(e)],t=this.addAll(A);return await t}async addAll(e){l.brandCheck(this,f);let A="Cache.addAll";l.argumentLengthCheck(arguments,1,A);let t=[],r=[];for(let t of e){if(void 0===t)throw l.errors.conversionFailed({prefix:A,argument:"Argument 1",types:["undefined is not allowed"]});if("string"==typeof(t=l.converters.RequestInfo(t)))continue;let e=u(t);if(!B(e.url)||"GET"!==e.method)throw l.errors.exception({header:A,message:"Expected http/s scheme when method is not GET."})}let s=[];for(let n of e){let e=u(new E(n));if(!B(e.url))throw l.errors.exception({header:A,message:"Expected http/s scheme."});e.initiator="fetch",e.destination="subresource",r.push(e);let i=d();s.push(I({request:e,processResponse(e){if("error"===e.type||206===e.status||e.status<200||e.status>299)i.reject(l.errors.exception({header:"Cache.addAll",message:"Received an invalid status code or the request failed."}));else if(e.headersList.contains("vary")){for(let A of o(e.headersList.get("vary")))if("*"===A){for(let e of(i.reject(l.errors.exception({header:"Cache.addAll",message:"invalid vary field value"})),s))e.abort();return}}},processResponseEndOfBody(e){e.aborted?i.reject(new DOMException("aborted","AbortError")):i.resolve(e)}})),t.push(i.promise)}let n=Promise.all(t),i=await n,a=[],g=0;for(let e of i){let A={type:"put",request:r[g],response:e};a.push(A),g++}let h=d(),c=null;try{this.#e5(a)}catch(e){c=e}return queueMicrotask(()=>{null===c?h.resolve(void 0):h.reject(c)}),h.promise}async put(e,A){l.brandCheck(this,f);let t="Cache.put";l.argumentLengthCheck(arguments,2,t),e=l.converters.RequestInfo(e),A=l.converters.Response(A,t,"response");let r=null;if(!B((r=l.is.Request(e)?u(e):u(new E(e))).url)||"GET"!==r.method)throw l.errors.exception({header:t,message:"Expected an http/s scheme when method is not GET"});let s=c(A);if(206===s.status)throw l.errors.exception({header:t,message:"Got 206 status"});if(s.headersList.contains("vary")){for(let e of o(s.headersList.get("vary")))if("*"===e)throw l.errors.exception({header:t,message:"Got * vary field value"})}if(s.body&&(a(s.body.stream)||s.body.stream.locked))throw l.errors.exception({header:t,message:"Response body is locked or disturbed"});let n=g(s),i=d();null!=s.body?C(s.body.stream.getReader(),i.resolve,i.reject):i.resolve(void 0);let h=[],Q={type:"put",request:r,response:n};h.push(Q);let I=await i.promise;null!=n.body&&(n.body.source=I);let p=d(),y=null;try{this.#e5(h)}catch(e){y=e}return queueMicrotask(()=>{null===y?p.resolve():p.reject(y)}),p.promise}async delete(e,A={}){let t;l.brandCheck(this,f);let s="Cache.delete";l.argumentLengthCheck(arguments,1,s),e=l.converters.RequestInfo(e),A=l.converters.CacheQueryOptions(A,s,"options");let n=null;if(l.is.Request(e)){if("GET"!==(n=u(e)).method&&!A.ignoreMethod)return!1}else r("string"==typeof e),n=u(new E(e));let o=[],i={type:"delete",request:n,options:A};o.push(i);let a=d(),g=null;try{t=this.#e5(o)}catch(e){g=e}return queueMicrotask(()=>{null===g?a.resolve(!!t?.length):a.reject(g)}),a.promise}async keys(e,A={}){l.brandCheck(this,f),void 0!==e&&(e=l.converters.RequestInfo(e)),A=l.converters.CacheQueryOptions(A,"Cache.keys","options");let t=null;if(void 0!==e)if(l.is.Request(e)){if("GET"!==(t=u(e)).method&&!A.ignoreMethod)return[]}else"string"==typeof e&&(t=u(new E(e)));let r=d(),s=[];if(void 0===e)for(let e of this.#e9)s.push(e[0]);else for(let e of this.#e8(t,A))s.push(e[0]);return queueMicrotask(()=>{let e=[];for(let A of s){let t=Q(A,void 0,new AbortController().signal,"immutable");e.push(t)}r.resolve(Object.freeze(e))}),r.promise}#e5(e){let A=this.#e9,t=[...A],s=[],n=[];try{for(let t of e){let e;if("delete"!==t.type&&"put"!==t.type)throw l.errors.exception({header:"Cache.#batchCacheOperations",message:'operation type does not match "delete" or "put"'});if("delete"===t.type&&null!=t.response)throw l.errors.exception({header:"Cache.#batchCacheOperations",message:"delete operation should not have an associated response"});if(this.#e8(t.request,t.options,s).length)throw new DOMException("???","InvalidStateError");if("delete"===t.type){if(e=this.#e8(t.request,t.options),0===e.length)return[];for(let t of e){let e=A.indexOf(t);r(-1!==e),A.splice(e,1)}}else if("put"===t.type){if(null==t.response)throw l.errors.exception({header:"Cache.#batchCacheOperations",message:"put operation should have an associated response"});let n=t.request;if(!B(n.url))throw l.errors.exception({header:"Cache.#batchCacheOperations",message:"expected http or https scheme"});if("GET"!==n.method)throw l.errors.exception({header:"Cache.#batchCacheOperations",message:"not get method"});if(null!=t.options)throw l.errors.exception({header:"Cache.#batchCacheOperations",message:"options must not be defined"});for(let s of e=this.#e8(t.request)){let e=A.indexOf(s);r(-1!==e),A.splice(e,1)}A.push([t.request,t.response]),s.push([t.request,t.response])}n.push([t.request,t.response])}return n}catch(e){throw this.#e9.length=0,this.#e9=t,e}}#e8(e,A,t){let r=[];for(let s of t??this.#e9){let[t,n]=s;this.#e3(e,t,n,A)&&r.push(s)}return r}#e3(e,A,t=null,r){let s=new URL(e.url),i=new URL(A.url);if(r?.ignoreSearch&&(i.search="",s.search=""),!n(s,i,!0))return!1;if(null==t||r?.ignoreVary||!t.headersList.contains("vary"))return!0;for(let r of o(t.headersList.get("vary")))if("*"===r||A.headersList.get(r)!==e.headersList.get(r))return!1;return!0}#e4(e,A,t=1/0){let r=null;if(void 0!==e)if(l.is.Request(e)){if("GET"!==(r=u(e)).method&&!A.ignoreMethod)return[]}else"string"==typeof e&&(r=u(new E(e)));let s=[];if(void 0===e)for(let e of this.#e9)s.push(e[1]);else for(let e of this.#e8(r,A))s.push(e[1]);let n=[];for(let e of s){let A=h(g(e),"immutable");if(n.push(A),n.length>=t)break}return Object.freeze(n)}}Object.defineProperties(f.prototype,{[Symbol.toStringTag]:{value:"Cache",configurable:!0},match:i,matchAll:i,add:i,addAll:i,put:i,delete:i,keys:i});let p=[{key:"ignoreSearch",converter:l.converters.boolean,defaultValue:()=>!1},{key:"ignoreMethod",converter:l.converters.boolean,defaultValue:()=>!1},{key:"ignoreVary",converter:l.converters.boolean,defaultValue:()=>!1}];l.converters.CacheQueryOptions=l.dictionaryConverter(p),l.converters.MultiCacheQueryOptions=l.dictionaryConverter([...p,{key:"cacheName",converter:l.converters.DOMString}]),l.converters.Response=l.interfaceConverter(l.is.Response,"Response"),l.converters["sequence<RequestInfo>"]=l.sequenceConverter(l.converters.RequestInfo),A.exports={Cache:f}},80599,(e,A,t)=>{"use strict";let{Cache:r}=e.r(950877),{webidl:s}=e.r(499095),{kEnumerableProperty:n}=e.r(504021),{kConstruct:o}=e.r(227235);class i{#e6=new Map;constructor(){arguments[0]!==o&&s.illegalConstructor(),s.util.markAsUncloneable(this)}async match(e,A={}){if(s.brandCheck(this,i),s.argumentLengthCheck(arguments,1,"CacheStorage.match"),e=s.converters.RequestInfo(e),null!=(A=s.converters.MultiCacheQueryOptions(A)).cacheName){if(this.#e6.has(A.cacheName)){let t=new r(o,this.#e6.get(A.cacheName));return await t.match(e,A)}}else for(let t of this.#e6.values()){let s=new r(o,t),n=await s.match(e,A);if(void 0!==n)return n}}async has(e){s.brandCheck(this,i);let A="CacheStorage.has";return s.argumentLengthCheck(arguments,1,A),e=s.converters.DOMString(e,A,"cacheName"),this.#e6.has(e)}async open(e){s.brandCheck(this,i);let A="CacheStorage.open";if(s.argumentLengthCheck(arguments,1,A),e=s.converters.DOMString(e,A,"cacheName"),this.#e6.has(e))return new r(o,this.#e6.get(e));let t=[];return this.#e6.set(e,t),new r(o,t)}async delete(e){s.brandCheck(this,i);let A="CacheStorage.delete";return s.argumentLengthCheck(arguments,1,A),e=s.converters.DOMString(e,A,"cacheName"),this.#e6.delete(e)}async keys(){return s.brandCheck(this,i),[...this.#e6.keys()]}}Object.defineProperties(i.prototype,{[Symbol.toStringTag]:{value:"CacheStorage",configurable:!0},match:n,has:n,open:n,delete:n,keys:n}),A.exports={CacheStorage:i}},107130,(e,A,t)=>{"use strict";A.exports={maxAttributeValueSize:1024,maxNameValuePairSize:4096}},384809,(e,A,t)=>{"use strict";function r(e){for(let A=0;A<e.length;++A){let t=e.charCodeAt(A);if(t<33||t>126||34===t||40===t||41===t||60===t||62===t||64===t||44===t||59===t||58===t||92===t||47===t||91===t||93===t||63===t||61===t||123===t||125===t)throw Error("Invalid cookie name")}}function s(e){let A=e.length,t=0;if('"'===e[0]){if(1===A||'"'!==e[A-1])throw Error("Invalid cookie value");--A,++t}for(;t<A;){let A=e.charCodeAt(t++);if(A<33||A>126||34===A||44===A||59===A||92===A)throw Error("Invalid cookie value")}}function n(e){for(let A=0;A<e.length;++A){let t=e.charCodeAt(A);if(t<32||127===t||59===t)throw Error("Invalid cookie path")}}let o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],a=Array(61).fill(0).map((e,A)=>A.toString().padStart(2,"0"));function l(e){return"number"==typeof e&&(e=new Date(e)),`${o[e.getUTCDay()]}, ${a[e.getUTCDate()]} ${i[e.getUTCMonth()]} ${e.getUTCFullYear()} ${a[e.getUTCHours()]}:${a[e.getUTCMinutes()]}:${a[e.getUTCSeconds()]} GMT`}A.exports={isCTLExcludingHtab:function(e){for(let A=0;A<e.length;++A){let t=e.charCodeAt(A);if(t>=0&&t<=8||t>=10&&t<=31||127===t)return!0}return!1},validateCookieName:r,validateCookiePath:n,validateCookieValue:s,toIMFDate:l,stringify:function(e){if(0===e.name.length)return null;r(e.name),s(e.value);let A=[`${e.name}=${e.value}`];if(e.name.startsWith("__Secure-")&&(e.secure=!0),e.name.startsWith("__Host-")&&(e.secure=!0,e.domain=null,e.path="/"),e.secure&&A.push("Secure"),e.httpOnly&&A.push("HttpOnly"),"number"==typeof e.maxAge){if(e.maxAge<0)throw Error("Invalid cookie max-age");A.push(`Max-Age=${e.maxAge}`)}if(e.domain){var t=e.domain;if(t.startsWith("-")||t.endsWith(".")||t.endsWith("-"))throw Error("Invalid cookie domain");A.push(`Domain=${e.domain}`)}for(let t of(e.path&&(n(e.path),A.push(`Path=${e.path}`)),e.expires&&"Invalid Date"!==e.expires.toString()&&A.push(`Expires=${l(e.expires)}`),e.sameSite&&A.push(`SameSite=${e.sameSite}`),e.unparsed)){if(!t.includes("="))throw Error("Invalid unparsed");let[e,...r]=t.split("=");A.push(`${e.trim()}=${r.join("=")}`)}return A.join("; ")}}},205390,(e,A,t)=>{"use strict";let{collectASequenceOfCodePointsFast:r}=e.r(279869),{maxNameValuePairSize:s,maxAttributeValueSize:n}=e.r(107130),{isCTLExcludingHtab:o}=e.r(384809),i=e.r(57328),{unescape:a}=e.r(483324);function l(e,A={}){if(0===e.length)return A;i(";"===e[0]);let t="";(e=e.slice(1)).includes(";")?(t=r(";",e,{position:0}),e=e.slice(t.length)):(t=e,e="");let s="",o="";if(t.includes("=")){let e={position:0};s=r("=",t,e),o=t.slice(e.position+1)}else s=t;if(s=s.trim(),(o=o.trim()).length>n)return l(e,A);let a=s.toLowerCase();if("expires"===a)A.expires=new Date(o);else if("max-age"===a){let t=o.charCodeAt(0);if((t<48||t>57)&&"-"!==o[0]||!/^\d+$/.test(o))return l(e,A);A.maxAge=Number(o)}else if("domain"===a){let e=o;"."===e[0]&&(e=e.slice(1)),A.domain=e=e.toLowerCase()}else if("path"===a)A.path=0===o.length||"/"!==o[0]?"/":o;else if("secure"===a)A.secure=!0;else if("httponly"===a)A.httpOnly=!0;else if("samesite"===a){let e="Default",t=o.toLowerCase();t.includes("none")&&(e="None"),t.includes("strict")&&(e="Strict"),t.includes("lax")&&(e="Lax"),A.sameSite=e}else A.unparsed??=[],A.unparsed.push(`${s}=${o}`);return l(e,A)}A.exports={parseSetCookie:function(e){if(o(e))return null;let A="",t="",n="",i="";if(e.includes(";")){let s={position:0};A=r(";",e,s),t=e.slice(s.position)}else A=e;if(A.includes("=")){let e={position:0};n=r("=",A,e),i=A.slice(e.position+1)}else i=A;return(n=n.trim(),i=i.trim(),n.length+i.length>s)?null:{name:n,value:a(i),...l(t)}},parseUnparsedAttributes:l}},115689,(e,A,t)=>{"use strict";let{parseSetCookie:r}=e.r(205390),{stringify:s}=e.r(384809),{webidl:n}=e.r(499095),{Headers:o}=e.r(700419),i=n.brandCheckMultiple([o,globalThis.Headers].filter(Boolean));function a(e,A){n.argumentLengthCheck(arguments,2,"setCookie"),i(e);let t=s(A=n.converters.Cookie(A));t&&e.append("set-cookie",t,!0)}n.converters.DeleteCookieAttributes=n.dictionaryConverter([{converter:n.nullableConverter(n.converters.DOMString),key:"path",defaultValue:()=>null},{converter:n.nullableConverter(n.converters.DOMString),key:"domain",defaultValue:()=>null}]),n.converters.Cookie=n.dictionaryConverter([{converter:n.converters.DOMString,key:"name"},{converter:n.converters.DOMString,key:"value"},{converter:n.nullableConverter(e=>"number"==typeof e?n.converters["unsigned long long"](e):new Date(e)),key:"expires",defaultValue:()=>null},{converter:n.nullableConverter(n.converters["long long"]),key:"maxAge",defaultValue:()=>null},{converter:n.nullableConverter(n.converters.DOMString),key:"domain",defaultValue:()=>null},{converter:n.nullableConverter(n.converters.DOMString),key:"path",defaultValue:()=>null},{converter:n.nullableConverter(n.converters.boolean),key:"secure",defaultValue:()=>null},{converter:n.nullableConverter(n.converters.boolean),key:"httpOnly",defaultValue:()=>null},{converter:n.converters.USVString,key:"sameSite",allowedValues:["Strict","Lax","None"]},{converter:n.sequenceConverter(n.converters.DOMString),key:"unparsed",defaultValue:()=>[]}]),A.exports={getCookies:function(e){n.argumentLengthCheck(arguments,1,"getCookies"),i(e);let A=e.get("cookie"),t={};if(!A)return t;for(let e of A.split(";")){let[A,...r]=e.split("=");t[A.trim()]=r.join("=")}return t},deleteCookie:function(e,A,t){i(e);let r="deleteCookie";n.argumentLengthCheck(arguments,2,r),A=n.converters.DOMString(A,r,"name"),t=n.converters.DeleteCookieAttributes(t),a(e,{name:A,value:"",expires:new Date(0),...t})},getSetCookies:function(e){n.argumentLengthCheck(arguments,1,"getSetCookies"),i(e);let A=e.getSetCookie();return A?A.map(e=>r(e)):[]},setCookie:a,parseCookie:function(e){return r(e=n.converters.DOMString(e))}}},823164,(e,A,t)=>{"use strict";let{webidl:r}=e.r(499095),{kEnumerableProperty:s}=e.r(504021),{kConstruct:n}=e.r(227235);class o extends Event{#e7;constructor(e,A={}){if(e===n){super(arguments[1],arguments[2]),r.util.markAsUncloneable(this);return}const t="MessageEvent constructor";r.argumentLengthCheck(arguments,1,t),super(e=r.converters.DOMString(e,t,"type"),A=r.converters.MessageEventInit(A,t,"eventInitDict")),this.#e7=A,r.util.markAsUncloneable(this)}get data(){return r.brandCheck(this,o),this.#e7.data}get origin(){return r.brandCheck(this,o),this.#e7.origin}get lastEventId(){return r.brandCheck(this,o),this.#e7.lastEventId}get source(){return r.brandCheck(this,o),this.#e7.source}get ports(){return r.brandCheck(this,o),Object.isFrozen(this.#e7.ports)||Object.freeze(this.#e7.ports),this.#e7.ports}initMessageEvent(e,A=!1,t=!1,s=null,n="",i="",a=null,l=[]){return r.brandCheck(this,o),r.argumentLengthCheck(arguments,1,"MessageEvent.initMessageEvent"),new o(e,{bubbles:A,cancelable:t,data:s,origin:n,lastEventId:i,source:a,ports:l})}static createFastMessageEvent(e,A){let t=new o(n,e,A);return t.#e7=A,t.#e7.data??=null,t.#e7.origin??="",t.#e7.lastEventId??="",t.#e7.source??=null,t.#e7.ports??=[],t}}let{createFastMessageEvent:i}=o;delete o.createFastMessageEvent;class a extends Event{#e7;constructor(e,A={}){const t="CloseEvent constructor";r.argumentLengthCheck(arguments,1,t),super(e=r.converters.DOMString(e,t,"type"),A=r.converters.CloseEventInit(A)),this.#e7=A,r.util.markAsUncloneable(this)}get wasClean(){return r.brandCheck(this,a),this.#e7.wasClean}get code(){return r.brandCheck(this,a),this.#e7.code}get reason(){return r.brandCheck(this,a),this.#e7.reason}}class l extends Event{#e7;constructor(e,A){const t="ErrorEvent constructor";r.argumentLengthCheck(arguments,1,t),super(e,A),r.util.markAsUncloneable(this),e=r.converters.DOMString(e,t,"type"),A=r.converters.ErrorEventInit(A??{}),this.#e7=A}get message(){return r.brandCheck(this,l),this.#e7.message}get filename(){return r.brandCheck(this,l),this.#e7.filename}get lineno(){return r.brandCheck(this,l),this.#e7.lineno}get colno(){return r.brandCheck(this,l),this.#e7.colno}get error(){return r.brandCheck(this,l),this.#e7.error}}Object.defineProperties(o.prototype,{[Symbol.toStringTag]:{value:"MessageEvent",configurable:!0},data:s,origin:s,lastEventId:s,source:s,ports:s,initMessageEvent:s}),Object.defineProperties(a.prototype,{[Symbol.toStringTag]:{value:"CloseEvent",configurable:!0},reason:s,code:s,wasClean:s}),Object.defineProperties(l.prototype,{[Symbol.toStringTag]:{value:"ErrorEvent",configurable:!0},message:s,filename:s,lineno:s,colno:s,error:s}),r.converters.MessagePort=r.interfaceConverter(r.is.MessagePort,"MessagePort"),r.converters["sequence<MessagePort>"]=r.sequenceConverter(r.converters.MessagePort);let g=[{key:"bubbles",converter:r.converters.boolean,defaultValue:()=>!1},{key:"cancelable",converter:r.converters.boolean,defaultValue:()=>!1},{key:"composed",converter:r.converters.boolean,defaultValue:()=>!1}];r.converters.MessageEventInit=r.dictionaryConverter([...g,{key:"data",converter:r.converters.any,defaultValue:()=>null},{key:"origin",converter:r.converters.USVString,defaultValue:()=>""},{key:"lastEventId",converter:r.converters.DOMString,defaultValue:()=>""},{key:"source",converter:r.nullableConverter(r.converters.MessagePort),defaultValue:()=>null},{key:"ports",converter:r.converters["sequence<MessagePort>"],defaultValue:()=>[]}]),r.converters.CloseEventInit=r.dictionaryConverter([...g,{key:"wasClean",converter:r.converters.boolean,defaultValue:()=>!1},{key:"code",converter:r.converters["unsigned short"],defaultValue:()=>0},{key:"reason",converter:r.converters.USVString,defaultValue:()=>""}]),r.converters.ErrorEventInit=r.dictionaryConverter([...g,{key:"message",converter:r.converters.DOMString,defaultValue:()=>""},{key:"filename",converter:r.converters.USVString,defaultValue:()=>""},{key:"lineno",converter:r.converters["unsigned long"],defaultValue:()=>0},{key:"colno",converter:r.converters["unsigned long"],defaultValue:()=>0},{key:"error",converter:r.converters.any}]),A.exports={MessageEvent:o,CloseEvent:a,ErrorEvent:l,createFastMessageEvent:i}},84879,(e,A,t)=>{"use strict";A.exports={uid:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",sentCloseFrameState:{SENT:1,RECEIVED:2},staticPropertyDescriptors:{enumerable:!0,writable:!1,configurable:!1},states:{CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},opcodes:{CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},maxUnsigned16Bit:65535,parserStates:{INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},emptyBuffer:Buffer.allocUnsafe(0),sendHints:{text:1,typedArray:2,arrayBuffer:3,blob:4}}},74912,(e,A,t)=>{"use strict";let{states:r,opcodes:s}=e.r(84879),{isUtf8:n}=e.r(951615),{removeHTTPWhitespace:o}=e.r(997726),{collectASequenceOfCodePointsFast:i}=e.r(279869);function a(e){return e===s.CLOSE||e===s.PING||e===s.PONG}function l(e){return e===s.CONTINUATION}function g(e){return e===s.TEXT||e===s.BINARY}A.exports={isConnecting:function(e){return e===r.CONNECTING},isEstablished:function(e){return e===r.OPEN},isClosing:function(e){return e===r.CLOSING},isClosed:function(e){return e===r.CLOSED},fireEvent:function(e,A,t=(e,A)=>new Event(e,A),r={}){let s=t(e,r);A.dispatchEvent(s)},isValidSubprotocol:function(e){if(0===e.length)return!1;for(let A=0;A<e.length;++A){let t=e.charCodeAt(A);if(t<33||t>126||34===t||40===t||41===t||44===t||47===t||58===t||59===t||60===t||61===t||62===t||63===t||64===t||91===t||92===t||93===t||123===t||125===t)return!1}return!0},isValidStatusCode:function(e){return e>=1e3&&e<1015?1004!==e&&1005!==e&&1006!==e:e>=3e3&&e<=4999},websocketMessageReceived:function(e,A,t){e.onMessage(A,t)},utf8Decode:(()=>{if("string"==typeof process.versions.icu){let e=new TextDecoder("utf-8",{fatal:!0});return e.decode.bind(e)}return function(e){if(n(e))return e.toString("utf-8");throw TypeError("Invalid utf-8 received.")}})(),isControlFrame:a,isContinuationFrame:l,isTextBinaryFrame:g,isValidOpcode:function(e){return g(e)||l(e)||a(e)},parseExtensions:function(e){let A={position:0},t=new Map;for(;A.position<e.length;){let[r,s=""]=i(";",e,A).split("=",2);t.set(o(r,!0,!1),o(s,!1,!0)),A.position++}return t},isValidClientWindowBits:function(e){if(0===e.length)return!1;for(let A=0;A<e.length;A++){let t=e.charCodeAt(A);if(t<48||t>57)return!1}let A=Number.parseInt(e,10);return A>=8&&A<=15},toArrayBuffer:function(e){return e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer},getURLRecord:function(e,A){let t;try{t=new URL(e,A)}catch(e){throw new DOMException(e,"SyntaxError")}if("http:"===t.protocol?t.protocol="ws:":"https:"===t.protocol&&(t.protocol="wss:"),"ws:"!==t.protocol&&"wss:"!==t.protocol)throw new DOMException("expected a ws: or wss: url","SyntaxError");if(t.hash.length||t.href.endsWith("#"))throw new DOMException("hash","SyntaxError");return t},validateCloseCodeAndReason:function(e,A){if(null!==e&&1e3!==e&&(e<3e3||e>4999))throw new DOMException("invalid code","InvalidAccessError");if(null!==A){let e=Buffer.byteLength(A);if(e>123)throw new DOMException(`Reason must be less than 123 bytes; received ${e}`,"SyntaxError")}}}},591709,(e,A,t)=>{"use strict";let{runtimeFeatures:r}=e.r(738493),{maxUnsigned16Bit:s,opcodes:n}=e.r(84879),o=null,i=8192,a=r.has("crypto")?e.r(666680).randomFillSync:function(e,A,t){for(let A=0;A<e.length;++A)e[A]=255*Math.random()|0;return e};function l(){return 8192===i&&(i=0,a(o??=Buffer.allocUnsafeSlow(8192),0,8192)),[o[i++],o[i++],o[i++],o[i++]]}A.exports={WebsocketFrameSend:class{constructor(e){this.frameData=e}createFrame(e){let A=this.frameData,t=l(),r=A?.byteLength??0,n=r,o=6;r>s?(o+=8,n=127):r>125&&(o+=2,n=126);let i=Buffer.allocUnsafe(r+o);i[0]=i[1]=0,i[0]|=128,i[0]=(240&i[0])+e,i[o-4]=t[0],i[o-3]=t[1],i[o-2]=t[2],i[o-1]=t[3],i[1]=n,126===n?i.writeUInt16BE(r,2):127===n&&(i[2]=i[3]=0,i.writeUIntBE(r,4,6)),i[1]|=128;for(let e=0;e<r;++e)i[o+e]=A[e]^t[3&e];return i}static createFastTextFrame(e){let A=l(),t=e.length;for(let r=0;r<t;++r)e[r]^=A[3&r];let r=t,o=6;t>s?(o+=8,r=127):t>125&&(o+=2,r=126);let i=Buffer.allocUnsafeSlow(o);return i[0]=128|n.TEXT,i[1]=128|r,i[o-4]=A[0],i[o-3]=A[1],i[o-2]=A[2],i[o-1]=A[3],126===r?i.writeUInt16BE(t,2):127===r&&(i[2]=i[3]=0,i.writeUIntBE(t,4,6)),[i,e]}},generateMask:l}},52978,(e,A,t)=>{"use strict";let{uid:r,states:s,sentCloseFrameState:n,emptyBuffer:o,opcodes:i}=e.r(84879),{parseExtensions:a,isClosed:l,isClosing:g,isEstablished:h,isConnecting:c,validateCloseCodeAndReason:E}=e.r(74912),{makeRequest:Q}=e.r(440796),{fetching:u}=e.r(486355),{Headers:I,getHeadersList:B}=e.r(700419),{getDecodeSplit:C}=e.r(88435),{WebsocketFrameSend:d}=e.r(591709),f=e.r(57328),{runtimeFeatures:p}=e.r(738493),y=p.has("crypto")?e.r(666680):null,D=!1;function S(e,A,t,r=!1){if(A??=null,t??="",r&&E(A,t),l(e.readyState)||g(e.readyState));else if(h(e.readyState))if(e.closeState.has(n.SENT)||e.closeState.has(n.RECEIVED))e.readyState=s.CLOSING;else{let r=new d;0!==t.length&&null===A&&(A=1e3),f(null===A||Number.isInteger(A)),null===A&&0===t.length?r.frameData=o:null!==A&&null===t?(r.frameData=Buffer.allocUnsafe(2),r.frameData.writeUInt16BE(A,0)):null!==A&&null!==t?(r.frameData=Buffer.allocUnsafe(2+Buffer.byteLength(t)),r.frameData.writeUInt16BE(A,0),r.frameData.write(t,2,"utf-8")):r.frameData=o,e.socket.write(r.createFrame(i.CLOSE)),e.closeState.add(n.SENT),e.readyState=s.CLOSING}else w(e),e.readyState=s.CLOSING}function w(e,A,t,r){h(e.readyState)&&S(e,A,t,!1),e.controller.abort(),c(e.readyState)?e.onSocketClose():e.socket?.destroyed===!1&&e.socket.destroy()}A.exports={establishWebSocketConnection:function(e,A,t,s,n){e.protocol="ws:"===e.protocol?"http:":"https:";let o=Q({urlList:[e],client:t,serviceWorkers:"none",referrer:"no-referrer",mode:"websocket",credentials:"include",cache:"no-store",redirect:"error",useURLCredentials:!0});n.headers&&(o.headersList=B(new I(n.headers)));let i=y.randomBytes(16).toString("base64");for(let e of(o.headersList.append("sec-websocket-key",i,!0),o.headersList.append("sec-websocket-version","13",!0),A))o.headersList.append("sec-websocket-protocol",e,!0);return o.headersList.append("sec-websocket-extensions","permessage-deflate; client_max_window_bits",!0),u({request:o,useParallelQueue:!0,dispatcher:n.dispatcher,processResponse(e){let t;if("error"===e.type||101!==e.status){if(e.socket?.session==null)return void w(s,1002,"Received network error or non-101 status code.",e.error);if(200!==e.status)return void w(s,1002,"Received network error or non-200 status code.",e.error)}if(!1===D&&e.socket?.session!=null&&(process.emitWarning("WebSocket over HTTP2 is experimental, and subject to change.","ExperimentalWarning"),D=!0),0!==A.length&&!e.headersList.get("Sec-WebSocket-Protocol"))return void w(s,1002,"Server did not respond with sent protocols.");if(null==e.socket.session&&e.headersList.get("Upgrade")?.toLowerCase()!=="websocket")return void w(s,1002,'Server did not set Upgrade header to "websocket".');if(null==e.socket.session&&e.headersList.get("Connection")?.toLowerCase()!=="upgrade")return void w(s,1002,'Server did not set Connection header to "upgrade".');if(e.headersList.get("Sec-WebSocket-Accept")!==y.hash("sha1",i+r,"base64"))return void w(s,1002,"Incorrect hash received in Sec-WebSocket-Accept header.");let n=e.headersList.get("Sec-WebSocket-Extensions");if(null!==n&&!(t=a(n)).has("permessage-deflate"))return void w(s,1002,"Sec-WebSocket-Extensions header does not match.");let l=e.headersList.get("Sec-WebSocket-Protocol");null===l||C("sec-websocket-protocol",o.headersList).includes(l)?(e.socket.on("data",s.onSocketData),e.socket.on("close",s.onSocketClose),e.socket.on("error",s.onSocketError),s.wasEverConnected=!0,s.onConnectionEstablished(e,t)):w(s,1002,"Protocol was not set in the opening handshake.")}})},failWebsocketConnection:w,closeWebSocketConnection:S}},489086,(e,A,t)=>{"use strict";let{createInflateRaw:r,Z_DEFAULT_WINDOWBITS:s}=e.r(727028),{isValidClientWindowBits:n}=e.r(74912),{MessageSizeExceededError:o}=e.r(792901),i=Buffer.from([0,0,255,255]),a=Symbol("kBuffer"),l=Symbol("kLength");A.exports={PerMessageDeflate:class{#Ae;#S={};#r=!1;#AA=null;constructor(e){this.#S.serverNoContextTakeover=e.has("server_no_context_takeover"),this.#S.serverMaxWindowBits=e.get("server_max_window_bits")}decompress(e,A,t){if(this.#r)return void t(new o);if(!this.#Ae){let e=s;if(this.#S.serverMaxWindowBits){if(!n(this.#S.serverMaxWindowBits))return void t(Error("Invalid server_max_window_bits"));e=Number.parseInt(this.#S.serverMaxWindowBits)}try{this.#Ae=r({windowBits:e})}catch(e){t(e);return}this.#Ae[a]=[],this.#Ae[l]=0,this.#Ae.on("data",e=>{if(!this.#r){if(this.#Ae[l]+=e.length,this.#Ae[l]>4194304){if(this.#r=!0,this.#Ae.removeAllListeners(),this.#Ae.destroy(),this.#Ae=null,this.#AA){let e=this.#AA;this.#AA=null,e(new o)}return}this.#Ae[a].push(e)}}),this.#Ae.on("error",e=>{this.#Ae=null,t(e)})}this.#AA=t,this.#Ae.write(e),A&&this.#Ae.write(i),this.#Ae.flush(()=>{if(this.#r||!this.#Ae)return;let e=Buffer.concat(this.#Ae[a],this.#Ae[l]);this.#Ae[a].length=0,this.#Ae[l]=0,this.#AA=null,t(null,e)})}}}},688187,(e,A,t)=>{"use strict";let{Writable:r}=e.r(81111),s=e.r(57328),{parserStates:n,opcodes:o,states:i,emptyBuffer:a,sentCloseFrameState:l}=e.r(84879),{isValidStatusCode:g,isValidOpcode:h,websocketMessageReceived:c,utf8Decode:E,isControlFrame:Q,isTextBinaryFrame:u,isContinuationFrame:I}=e.r(74912),{failWebsocketConnection:B}=e.r(52978),{WebsocketFrameSend:C}=e.r(591709),{PerMessageDeflate:d}=e.r(489086),{MessageSizeExceededError:f}=e.r(792901);class p extends r{#At=[];#Ar=0;#As=0;#An=!1;#c=n.INFO;#Ao={};#Ai=[];#Aa;#e;constructor(e,A){super(),this.#e=e,this.#Aa=null==A?new Map:A,this.#Aa.has("permessage-deflate")&&this.#Aa.set("permessage-deflate",new d(A))}_write(e,A,t){this.#At.push(e),this.#As+=e.length,this.#An=!0,this.run(t)}run(e){for(;this.#An;)if(this.#c===n.INFO){if(this.#As<2)return e();let A=this.consume(2),t=(128&A[0])!=0,r=15&A[0],s=(128&A[1])==128,i=!t&&r!==o.CONTINUATION,a=127&A[1],l=64&A[0],g=32&A[0],c=16&A[0];if(!h(r))return B(this.#e,1002,"Invalid opcode received"),e();if(s)return B(this.#e,1002,"Frame cannot be masked"),e();if(0!==l&&!this.#Aa.has("permessage-deflate"))return void B(this.#e,1002,"Expected RSV1 to be clear.");if(0!==g||0!==c)return void B(this.#e,1002,"RSV1, RSV2, RSV3 must be clear");if(i&&!u(r))return void B(this.#e,1002,"Invalid frame type was fragmented.");if(u(r)&&this.#Ai.length>0)return void B(this.#e,1002,"Expected continuation frame");if(this.#Ao.fragmented&&i)return void B(this.#e,1002,"Fragmented frame exceeded 125 bytes.");if((a>125||i)&&Q(r))return void B(this.#e,1002,"Control frame either too large or fragmented");if(I(r)&&0===this.#Ai.length&&!this.#Ao.compressed)return void B(this.#e,1002,"Unexpected continuation frame");a<=125?(this.#Ao.payloadLength=a,this.#c=n.READ_DATA):126===a?this.#c=n.PAYLOADLENGTH_16:127===a&&(this.#c=n.PAYLOADLENGTH_64),u(r)&&(this.#Ao.binaryType=r,this.#Ao.compressed=0!==l),this.#Ao.opcode=r,this.#Ao.masked=s,this.#Ao.fin=t,this.#Ao.fragmented=i}else if(this.#c===n.PAYLOADLENGTH_16){if(this.#As<2)return e();let A=this.consume(2);this.#Ao.payloadLength=A.readUInt16BE(0),this.#c=n.READ_DATA}else if(this.#c===n.PAYLOADLENGTH_64){if(this.#As<8)return e();let A=this.consume(8),t=A.readUInt32BE(0),r=A.readUInt32BE(4);if(0!==t||r>0x80000000-1)return void B(this.#e,1009,"Received payload length > 2^31 bytes.");this.#Ao.payloadLength=r,this.#c=n.READ_DATA}else if(this.#c===n.READ_DATA){if(this.#As<this.#Ao.payloadLength)return e();let A=this.consume(this.#Ao.payloadLength);if(Q(this.#Ao.opcode))this.#An=this.parseControlFrame(A),this.#c=n.INFO;else if(this.#Ao.compressed){this.#Aa.get("permessage-deflate").decompress(A,this.#Ao.fin,(A,t)=>{if(A){let e=A instanceof f?1009:1007;B(this.#e,e,A.message);return}if(this.writeFragments(t),!this.#Ao.fin){this.#c=n.INFO,this.#An=!0,this.run(e);return}c(this.#e,this.#Ao.binaryType,this.consumeFragments()),this.#An=!0,this.#c=n.INFO,this.run(e)}),this.#An=!1;break}else this.writeFragments(A),!this.#Ao.fragmented&&this.#Ao.fin&&c(this.#e,this.#Ao.binaryType,this.consumeFragments()),this.#c=n.INFO}}consume(e){if(e>this.#As)throw Error("Called consume() before buffers satiated.");if(0===e)return a;this.#As-=e;let A=this.#At[0];if(A.length>e)return this.#At[0]=A.subarray(e,A.length),A.subarray(0,e);{if(A.length===e)return this.#At.shift();let t=0,r=Buffer.allocUnsafeSlow(e);for(;t!==e;){let A=this.#At[0],s=A.length;if(s+t===e){r.set(this.#At.shift(),t);break}if(s+t>e){r.set(A.subarray(0,e-t),t),this.#At[0]=A.subarray(e-t);break}r.set(this.#At.shift(),t),t+=s}return r}}writeFragments(e){this.#Ar+=e.length,this.#Ai.push(e)}consumeFragments(){let e=this.#Ai;if(1===e.length)return this.#Ar=0,e.shift();let A=0,t=Buffer.allocUnsafeSlow(this.#Ar);for(let r=0;r<e.length;++r){let s=e[r];t.set(s,A),A+=s.length}return this.#Ai=[],this.#Ar=0,t}parseCloseBody(e){let A;if(s(1!==e.length),e.length>=2&&(A=e.readUInt16BE(0)),void 0!==A&&!g(A))return{code:1002,reason:"Invalid status code",error:!0};let t=e.subarray(2);239===t[0]&&187===t[1]&&191===t[2]&&(t=t.subarray(3));try{t=E(t)}catch{return{code:1007,reason:"Invalid UTF-8",error:!0}}return{code:A,reason:t,error:!1}}parseControlFrame(e){let{opcode:A,payloadLength:t}=this.#Ao;if(A===o.CLOSE){if(1===t)return B(this.#e,1002,"Received close frame with a 1-byte body."),!1;if(this.#Ao.closeInfo=this.parseCloseBody(e),this.#Ao.closeInfo.error){let{code:e,reason:A}=this.#Ao.closeInfo;return B(this.#e,e,A),!1}if(!this.#e.closeState.has(l.SENT)&&!this.#e.closeState.has(l.RECEIVED)){let e=a;this.#Ao.closeInfo.code&&(e=Buffer.allocUnsafe(2)).writeUInt16BE(this.#Ao.closeInfo.code,0);let A=new C(e);this.#e.socket.write(A.createFrame(o.CLOSE)),this.#e.closeState.add(l.SENT)}return this.#e.readyState=i.CLOSING,this.#e.closeState.add(l.RECEIVED),!1}if(A===o.PING){if(!this.#e.closeState.has(l.RECEIVED)){let A=new C(e);this.#e.socket.write(A.createFrame(o.PONG)),this.#e.onPing(e)}}else A===o.PONG&&this.#e.onPong(e);return!0}get closingInfo(){return this.#Ao.closeInfo}}A.exports={ByteParser:p}},71536,(e,A,t)=>{"use strict";let{WebsocketFrameSend:r}=e.r(591709),{opcodes:s,sendHints:n}=e.r(84879),o=e.r(326185);class i{#Al=new o;#Ag=!1;#Ah;constructor(e){this.#Ah=e}add(e,A,t){if(t!==n.blob){if(this.#Ag){let r={promise:null,callback:A,frame:a(e,t)};this.#Al.push(r)}else if(t===n.text){let{0:t,1:s}=r.createFastTextFrame(e);this.#Ah.cork(),this.#Ah.write(t),this.#Ah.write(s,A),this.#Ah.uncork()}else this.#Ah.write(a(e,t),A);return}let s={promise:e.arrayBuffer().then(e=>{s.promise=null,s.frame=a(e,t)}),callback:A,frame:null};this.#Al.push(s),this.#Ag||this.#Ac()}async #Ac(){this.#Ag=!0;let e=this.#Al;for(;!e.isEmpty();){let A=e.shift();null!==A.promise&&await A.promise,this.#Ah.write(A.frame,A.callback),A.callback=A.frame=null}this.#Ag=!1}}function a(e,A){return new r(function(e,A){switch(A){case n.text:case n.typedArray:return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);case n.arrayBuffer:case n.blob:return new Uint8Array(e)}}(e,A)).createFrame(A===n.text?s.TEXT:s.BINARY)}A.exports={SendQueue:i}},337557,(e,A,t)=>{"use strict";let{isArrayBuffer:r}=e.r(107417),{webidl:s}=e.r(499095),{URLSerializer:n}=e.r(997726),{environmentSettingsObject:o}=e.r(88435),{staticPropertyDescriptors:i,states:a,sentCloseFrameState:l,sendHints:g,opcodes:h}=e.r(84879),{isConnecting:c,isEstablished:E,isClosing:Q,isClosed:u,isValidSubprotocol:I,fireEvent:B,utf8Decode:C,toArrayBuffer:d,getURLRecord:f}=e.r(74912),{establishWebSocketConnection:p,closeWebSocketConnection:y,failWebsocketConnection:D}=e.r(52978),{ByteParser:S}=e.r(688187),{kEnumerableProperty:w}=e.r(504021),{getGlobalDispatcher:m}=e.r(979590),{ErrorEvent:N,CloseEvent:R,createFastMessageEvent:b}=e.r(823164),{SendQueue:U}=e.r(71536),{WebsocketFrameSend:F}=e.r(591709),{channels:k}=e.r(851749);class M extends EventTarget{#AE={open:null,error:null,close:null,message:null};#AQ=0;#Au="";#Aa="";#AI;#e={onConnectionEstablished:(e,A)=>this.#AB(e,A),onMessage:(e,A)=>this.#AC(e,A),onParserError:e=>D(this.#e,null,e.message),onParserDrain:()=>this.#Ad(),onSocketData:e=>{this.#Af.write(e)||this.#e.socket.pause()},onSocketError:e=>{this.#e.readyState=a.CLOSING,k.socketError.hasSubscribers&&k.socketError.publish(e),this.#e.socket.destroy()},onSocketClose:()=>this.#Ap(),onPing:e=>{k.ping.hasSubscribers&&k.ping.publish({payload:e,websocket:this})},onPong:e=>{k.pong.hasSubscribers&&k.pong.publish({payload:e,websocket:this})},readyState:a.CONNECTING,socket:null,closeState:new Set,controller:null,wasEverConnected:!1};#Ay;#AD;#Af;constructor(e,A=[]){super(),s.util.markAsUncloneable(this);const t="WebSocket constructor";s.argumentLengthCheck(arguments,1,t);const r=s.converters["DOMString or sequence<DOMString> or WebSocketInit"](A,t,"options");e=s.converters.USVString(e),A=r.protocols;const n=f(e,o.settingsObject.baseUrl);if("string"==typeof A&&(A=[A]),A.length!==new Set(A.map(e=>e.toLowerCase())).size||A.length>0&&!A.every(e=>I(e)))throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");this.#Ay=new URL(n.href);const i=o.settingsObject;this.#e.controller=p(n,A,i,this.#e,r),this.#e.readyState=M.CONNECTING,this.#AD="blob"}close(e,A){s.brandCheck(this,M),void 0!==e&&(e=s.converters["unsigned short"](e,"WebSocket.close","code",s.attributes.Clamp)),void 0!==A&&(A=s.converters.USVString(A)),e??=null,A??="",y(this.#e,e,A,!0)}send(e){s.brandCheck(this,M);let A="WebSocket.send";if(s.argumentLengthCheck(arguments,1,A),e=s.converters.WebSocketSendData(e,A,"data"),c(this.#e.readyState))throw new DOMException("Sent before connected.","InvalidStateError");if(!(!E(this.#e.readyState)||Q(this.#e.readyState)))if("string"==typeof e){let A=Buffer.from(e);this.#AQ+=A.byteLength,this.#AI.add(A,()=>{this.#AQ-=A.byteLength},g.text)}else r(e)?(this.#AQ+=e.byteLength,this.#AI.add(e,()=>{this.#AQ-=e.byteLength},g.arrayBuffer)):ArrayBuffer.isView(e)?(this.#AQ+=e.byteLength,this.#AI.add(e,()=>{this.#AQ-=e.byteLength},g.typedArray)):s.is.Blob(e)&&(this.#AQ+=e.size,this.#AI.add(e,()=>{this.#AQ-=e.size},g.blob))}get readyState(){return s.brandCheck(this,M),this.#e.readyState}get bufferedAmount(){return s.brandCheck(this,M),this.#AQ}get url(){return s.brandCheck(this,M),n(this.#Ay)}get extensions(){return s.brandCheck(this,M),this.#Aa}get protocol(){return s.brandCheck(this,M),this.#Au}get onopen(){return s.brandCheck(this,M),this.#AE.open}set onopen(e){s.brandCheck(this,M),this.#AE.open&&this.removeEventListener("open",this.#AE.open);let A=s.converters.EventHandlerNonNull(e);null!==A?(this.addEventListener("open",A),this.#AE.open=e):this.#AE.open=null}get onerror(){return s.brandCheck(this,M),this.#AE.error}set onerror(e){s.brandCheck(this,M),this.#AE.error&&this.removeEventListener("error",this.#AE.error);let A=s.converters.EventHandlerNonNull(e);null!==A?(this.addEventListener("error",A),this.#AE.error=e):this.#AE.error=null}get onclose(){return s.brandCheck(this,M),this.#AE.close}set onclose(e){s.brandCheck(this,M),this.#AE.close&&this.removeEventListener("close",this.#AE.close);let A=s.converters.EventHandlerNonNull(e);null!==A?(this.addEventListener("close",A),this.#AE.close=e):this.#AE.close=null}get onmessage(){return s.brandCheck(this,M),this.#AE.message}set onmessage(e){s.brandCheck(this,M),this.#AE.message&&this.removeEventListener("message",this.#AE.message);let A=s.converters.EventHandlerNonNull(e);null!==A?(this.addEventListener("message",A),this.#AE.message=e):this.#AE.message=null}get binaryType(){return s.brandCheck(this,M),this.#AD}set binaryType(e){s.brandCheck(this,M),"blob"!==e&&"arraybuffer"!==e?this.#AD="blob":this.#AD=e}#AB(e,A){this.#e.socket=e.socket;let t=new S(this.#e,A);t.on("drain",()=>this.#e.onParserDrain()),t.on("error",e=>this.#e.onParserError(e)),this.#Af=t,this.#AI=new U(e.socket),this.#e.readyState=a.OPEN;let r=e.headersList.get("sec-websocket-extensions");null!==r&&(this.#Aa=r);let s=e.headersList.get("sec-websocket-protocol");if(null!==s&&(this.#Au=s),B("open",this),k.open.hasSubscribers){let A=e.headersList.entries;k.open.publish({address:e.socket.address(),protocol:this.#Au,extensions:this.#Aa,websocket:this,handshakeResponse:{status:e.status,statusText:e.statusText,headers:A}})}}#AC(e,A){let t;if(this.#e.readyState===a.OPEN){if(e===h.TEXT)try{t=C(A)}catch{D(this.#e,1007,"Received invalid UTF-8 in text frame.");return}else e===h.BINARY&&(t="blob"===this.#AD?new Blob([A]):d(A));B("message",this,b,{origin:this.#Ay.origin,data:t})}}#Ad(){this.#e.socket.resume()}#Ap(){let e=this.#e.closeState.has(l.SENT)&&this.#e.closeState.has(l.RECEIVED),A=1005,t="",r=this.#Af?.closingInfo;r&&!r.error&&(A=r.code??1005,t=r.reason),this.#e.readyState=a.CLOSED,this.#e.closeState.has(l.RECEIVED)||(A=1006,B("error",this,(e,A)=>new N(e,A),{error:TypeError(t)})),B("close",this,(e,A)=>new R(e,A),{wasClean:e,code:A,reason:t}),k.close.hasSubscribers&&k.close.publish({websocket:this,code:A,reason:t})}static ping(e,A){if(Buffer.isBuffer(A)){if(A.length>125)throw TypeError("A PING frame cannot have a body larger than 125 bytes.")}else if(void 0!==A)throw TypeError("Expected buffer payload");let t=e.#e.readyState;if(E(t)&&!Q(t)&&!u(t)){let t=new F(A);e.#e.socket.write(t.createFrame(h.PING))}}}let{ping:T}=M;Reflect.deleteProperty(M,"ping"),M.CONNECTING=M.prototype.CONNECTING=a.CONNECTING,M.OPEN=M.prototype.OPEN=a.OPEN,M.CLOSING=M.prototype.CLOSING=a.CLOSING,M.CLOSED=M.prototype.CLOSED=a.CLOSED,Object.defineProperties(M.prototype,{CONNECTING:i,OPEN:i,CLOSING:i,CLOSED:i,url:w,readyState:w,bufferedAmount:w,onopen:w,onerror:w,onclose:w,close:w,onmessage:w,binaryType:w,send:w,extensions:w,protocol:w,[Symbol.toStringTag]:{value:"WebSocket",writable:!1,enumerable:!1,configurable:!0}}),Object.defineProperties(M,{CONNECTING:i,OPEN:i,CLOSING:i,CLOSED:i}),s.converters["sequence<DOMString>"]=s.sequenceConverter(s.converters.DOMString),s.converters["DOMString or sequence<DOMString>"]=function(e,A,t){return s.util.Type(e)===s.util.Types.OBJECT&&Symbol.iterator in e?s.converters["sequence<DOMString>"](e):s.converters.DOMString(e,A,t)},s.converters.WebSocketInit=s.dictionaryConverter([{key:"protocols",converter:s.converters["DOMString or sequence<DOMString>"],defaultValue:()=>[]},{key:"dispatcher",converter:s.converters.any,defaultValue:()=>m()},{key:"headers",converter:s.nullableConverter(s.converters.HeadersInit)}]),s.converters["DOMString or sequence<DOMString> or WebSocketInit"]=function(e){return s.util.Type(e)!==s.util.Types.OBJECT||Symbol.iterator in e?{protocols:s.converters["DOMString or sequence<DOMString>"](e)}:s.converters.WebSocketInit(e)},s.converters.WebSocketSendData=function(e){return s.util.Type(e)===s.util.Types.OBJECT&&(s.is.Blob(e)||s.is.BufferSource(e))?e:s.converters.USVString(e)},A.exports={WebSocket:M,ping:T}},208890,(e,A,t)=>{"use strict";let{webidl:r}=e.r(499095),{validateCloseCodeAndReason:s}=e.r(74912),{kConstruct:n}=e.r(227235),{kEnumerableProperty:o}=e.r(504021);function i(){class e extends DOMException{get reason(){return""}}return void 0!==new e().reason?DOMException:new Proxy(DOMException,{construct(e,A,t){let r=Reflect.construct(e,A,e);return Object.setPrototypeOf(r,t.prototype),r}})}class a extends i(){#AS;#t;constructor(e="",A){if(super(e=r.converters.DOMString(e,"WebSocketError","message"),"WebSocketError"),A===n)return;null!==A&&(A=r.converters.WebSocketCloseInfo(A));let t=A.closeCode??null;const o=A.reason??"";s(t,o),0!==o.length&&null===t&&(t=1e3),this.#AS=t,this.#t=o}get closeCode(){return this.#AS}get reason(){return this.#t}static createUnvalidatedWebSocketError(e,A,t){let r=new a(e,n);return r.#AS=A,r.#t=t,r}}let{createUnvalidatedWebSocketError:l}=a;delete a.createUnvalidatedWebSocketError,Object.defineProperties(a.prototype,{closeCode:o,reason:o,[Symbol.toStringTag]:{value:"WebSocketError",writable:!1,enumerable:!1,configurable:!0}}),r.is.WebSocketError=r.util.MakeTypeAssertion(a),A.exports={WebSocketError:a,createUnvalidatedWebSocketError:l}},233032,(e,A,t)=>{"use strict";let{createDeferredPromise:r}=e.r(899779),{environmentSettingsObject:s}=e.r(88435),{states:n,opcodes:o,sentCloseFrameState:i}=e.r(84879),{webidl:a}=e.r(499095),{getURLRecord:l,isValidSubprotocol:g,isEstablished:h,utf8Decode:c}=e.r(74912),{establishWebSocketConnection:E,failWebsocketConnection:Q,closeWebSocketConnection:u}=e.r(52978),{channels:I}=e.r(851749),{WebsocketFrameSend:B}=e.r(591709),{ByteParser:C}=e.r(688187),{WebSocketError:d,createUnvalidatedWebSocketError:f}=e.r(208890),{kEnumerableProperty:p}=e.r(504021),{utf8DecodeBytes:y}=e.r(557674),D=!1;class S{#Ay;#Aw;#Am;#AN;#AR;#Ab;#AU=!1;#e={onConnectionEstablished:(e,A)=>this.#AB(e,A),onMessage:(e,A)=>this.#AC(e,A),onParserError:e=>Q(this.#e,null,e.message),onParserDrain:()=>this.#e.socket.resume(),onSocketData:e=>{this.#Af.write(e)||this.#e.socket.pause()},onSocketError:e=>{this.#e.readyState=n.CLOSING,I.socketError.hasSubscribers&&I.socketError.publish(e),this.#e.socket.destroy()},onSocketClose:()=>this.#Ap(),onPing:()=>{},onPong:()=>{},readyState:n.CONNECTING,socket:null,closeState:new Set,controller:null,wasEverConnected:!1};#Af;constructor(e,A){D||(process.emitWarning("WebSocketStream is experimental! Expect it to change at any time.",{code:"UNDICI-WSS"}),D=!0),a.argumentLengthCheck(arguments,1,"WebSocket"),e=a.converters.USVString(e),null!==A&&(A=a.converters.WebSocketStreamOptions(A));const t=l(e,s.settingsObject.baseUrl),o=A.protocols;if(o.length!==new Set(o.map(e=>e.toLowerCase())).size||o.length>0&&!o.every(e=>g(e)))throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(this.#Ay=t.toString(),this.#Aw=r(),this.#Am=r(),null!=A.signal){const e=A.signal;if(e.aborted){this.#Aw.reject(e.reason),this.#Am.reject(e.reason);return}e.addEventListener("abort",()=>{h(this.#e.readyState)||(Q(this.#e),this.#e.readyState=n.CLOSING,this.#Aw.reject(e.reason),this.#Am.reject(e.reason),this.#AU=!0)},{once:!0})}const i=s.settingsObject;this.#e.controller=E(t,o,i,this.#e,A)}get url(){return this.#Ay.toString()}get opened(){return this.#Aw.promise}get closed(){return this.#Am.promise}close(e){null!==e&&(e=a.converters.WebSocketCloseInfo(e));let A=e.closeCode??null,t=e.reason;u(this.#e,A,t,!0)}#AF(e){e=a.converters.WebSocketStreamWrite(e);let A=r(),t=null,s=null;if(a.is.BufferSource(e))t=new Uint8Array(ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e.slice()),s=o.BINARY;else{let r;try{r=a.converters.DOMString(e)}catch(e){return A.reject(e),A.promise}t=new TextEncoder().encode(r),s=o.TEXT}if(!this.#e.closeState.has(i.SENT)&&!this.#e.closeState.has(i.RECEIVED)){let e=new B(t);this.#e.socket.write(e.createFrame(s),()=>{A.resolve(void 0)})}return A.promise}#AB(e,A){this.#e.socket=e.socket;let t=new C(this.#e,A);t.on("drain",()=>this.#e.onParserDrain()),t.on("error",e=>this.#e.onParserError(e)),this.#Af=t,this.#e.readyState=n.OPEN;let r=A??"",s=e.headersList.get("sec-websocket-protocol")??"",o=new ReadableStream({start:e=>{this.#AR=e},pull(A){let t;for(;A.desiredSize>0&&null!==(t=e.socket.read());)A.enqueue(t)},cancel:e=>this.#Ak(e)}),i=new WritableStream({write:e=>this.#AF(e),close:()=>u(this.#e,null,null),abort:e=>this.#AM(e)});this.#AN=o,this.#Ab=i,this.#Aw.resolve({extensions:r,protocol:s,readable:o,writable:i})}#AC(e,A){let t;if(this.#e.readyState===n.OPEN){if(e===o.TEXT)try{t=c(A)}catch{Q(this.#e,"Received invalid UTF-8 in text frame.");return}else e===o.BINARY&&(t=new Uint8Array(A.buffer,A.byteOffset,A.byteLength));this.#AR.enqueue(t)}}#Ap(){let e=this.#e.closeState.has(i.SENT)&&this.#e.closeState.has(i.RECEIVED);if(this.#e.readyState=n.CLOSED,this.#AU)return;this.#e.wasEverConnected||this.#Aw.reject(new d("Socket never opened"));let A=this.#Af?.closingInfo,t=A?.code??1005;this.#e.closeState.has(i.SENT)||this.#e.closeState.has(i.RECEIVED)||(t=1006);let r=A?.reason==null?"":y(Buffer.from(A.reason));if(e)this.#AR.close(),this.#Ab.locked||this.#Ab.abort(new DOMException("A closed WebSocketStream cannot be written to","InvalidStateError")),this.#Am.resolve({closeCode:t,reason:r});else{let e=f("unclean close",t,r);this.#AR?.error(e),this.#Ab?.abort(e),this.#Am.reject(e)}}#AM(e){let A=null,t="";a.is.WebSocketError(e)&&(A=e.closeCode,t=e.reason),u(this.#e,A,t)}#Ak(e){this.#AM(e)}}Object.defineProperties(S.prototype,{url:p,opened:p,closed:p,close:p,[Symbol.toStringTag]:{value:"WebSocketStream",writable:!1,enumerable:!1,configurable:!0}}),a.converters.WebSocketStreamOptions=a.dictionaryConverter([{key:"protocols",converter:a.sequenceConverter(a.converters.USVString),defaultValue:()=>[]},{key:"signal",converter:a.nullableConverter(a.converters.AbortSignal),defaultValue:()=>null}]),a.converters.WebSocketCloseInfo=a.dictionaryConverter([{key:"closeCode",converter:e=>a.converters["unsigned short"](e,a.attributes.EnforceRange)},{key:"reason",converter:a.converters.USVString,defaultValue:()=>""}]),a.converters.WebSocketStreamWrite=function(e){return"string"==typeof e?a.converters.USVString(e):a.converters.BufferSource(e)},A.exports={WebSocketStream:S}},739579,(e,A,t)=>{"use strict";A.exports={isValidLastEventId:function(e){return -1===e.indexOf("\0")},isASCIINumber:function(e){if(0===e.length)return!1;for(let A=0;A<e.length;A++)if(48>e.charCodeAt(A)||e.charCodeAt(A)>57)return!1;return!0}}},499060,(e,A,t)=>{"use strict";let{Transform:r}=e.r(81111),{isASCIINumber:s,isValidLastEventId:n}=e.r(739579);A.exports={EventSourceStream:class extends r{state;checkBOM=!0;crlfCheck=!1;eventEndCheck=!1;buffer=null;pos=0;event={data:void 0,event:void 0,id:void 0,retry:void 0};constructor(e={}){e.readableObjectMode=!0,super(e),this.state=e.eventSourceSettings||{},e.push&&(this.push=e.push)}_transform(e,A,t){if(0===e.length)return void t();if(this.buffer?this.buffer=Buffer.concat([this.buffer,e]):this.buffer=e,this.checkBOM)switch(this.buffer.length){case 1:if(239===this.buffer[0])return void t();this.checkBOM=!1,t();return;case 2:if(239===this.buffer[0]&&187===this.buffer[1])return void t();this.checkBOM=!1;break;case 3:if(239===this.buffer[0]&&187===this.buffer[1]&&191===this.buffer[2]){this.buffer=Buffer.alloc(0),this.checkBOM=!1,t();return}this.checkBOM=!1;break;default:239===this.buffer[0]&&187===this.buffer[1]&&191===this.buffer[2]&&(this.buffer=this.buffer.subarray(3)),this.checkBOM=!1}for(;this.pos<this.buffer.length;){if(this.eventEndCheck){if(this.crlfCheck){if(10===this.buffer[this.pos]){this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.crlfCheck=!1;continue}this.crlfCheck=!1}if(10===this.buffer[this.pos]||13===this.buffer[this.pos]){13===this.buffer[this.pos]&&(this.crlfCheck=!0),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,(void 0!==this.event.data||this.event.event||void 0!==this.event.id||this.event.retry)&&this.processEvent(this.event),this.clearEvent();continue}this.eventEndCheck=!1;continue}if(10===this.buffer[this.pos]||13===this.buffer[this.pos]){13===this.buffer[this.pos]&&(this.crlfCheck=!0),this.parseLine(this.buffer.subarray(0,this.pos),this.event),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.eventEndCheck=!0;continue}this.pos++}t()}parseLine(e,A){if(0===e.length)return;let t=e.indexOf(58);if(0===t)return;let r="",o="";if(-1!==t){r=e.subarray(0,t).toString("utf8");let A=t+1;32===e[A]&&++A,o=e.subarray(A).toString("utf8")}else r=e.toString("utf8"),o="";switch(r){case"data":void 0===A[r]?A[r]=o:A[r]+=`
|
|
119
119
|
${o}`;break;case"retry":s(o)&&(A[r]=o);break;case"id":n(o)&&(A[r]=o);break;case"event":o.length>0&&(A[r]=o)}}processEvent(e){e.retry&&s(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),void 0!==e.id&&n(e.id)&&(this.state.lastEventId=e.id),void 0!==e.data&&this.push({type:e.event||"message",options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}}}},960854,(e,A,t)=>{"use strict";let{pipeline:r}=e.r(81111),{fetching:s}=e.r(486355),{makeRequest:n}=e.r(440796),{webidl:o}=e.r(499095),{EventSourceStream:i}=e.r(499060),{parseMIMEType:a}=e.r(997726),{createFastMessageEvent:l}=e.r(823164),{isNetworkError:g}=e.r(312148),{kEnumerableProperty:h}=e.r(504021),{environmentSettingsObject:c}=e.r(88435),E=!1;class Q extends EventTarget{#AE={open:null,error:null,message:null};#Ay;#AT=!1;#AL=0;#Av=null;#n=null;#e2;#c;constructor(e,A={}){let t;super(),o.util.markAsUncloneable(this);const r="EventSource constructor";o.argumentLengthCheck(arguments,1,r),E||(E=!0,process.emitWarning("EventSource is experimental, expect them to change at any time.",{code:"UNDICI-ES"})),e=o.converters.USVString(e),A=o.converters.EventSourceInitDict(A,r,"eventSourceInitDict"),this.#e2=A.node.dispatcher||A.dispatcher,this.#c={lastEventId:"",reconnectionTime:A.node.reconnectionTime};try{t=new URL(e,c.settingsObject.baseUrl),this.#c.origin=t.origin}catch(e){throw new DOMException(e,"SyntaxError")}this.#Ay=t.href;let s="anonymous";!0===A.withCredentials&&(s="use-credentials",this.#AT=!0);const i={redirect:"follow",keepalive:!0,mode:"cors",credentials:"anonymous"===s?"same-origin":"omit",referrer:"no-referrer"};i.client=c.settingsObject,i.headersList=[["accept",{name:"accept",value:"text/event-stream"}]],i.cache="no-store",i.initiator="other",i.urlList=[new URL(this.#Ay)],this.#Av=n(i),this.#AH()}get readyState(){return this.#AL}get url(){return this.#Ay}get withCredentials(){return this.#AT}#AH(){if(2===this.#AL)return;this.#AL=0;let e={request:this.#Av,dispatcher:this.#e2};e.processResponseEndOfBody=e=>{if(!g(e))return this.#AY()},e.processResponse=e=>{if(g(e))if(!e.aborted)return void this.#AY();else{this.close(),this.dispatchEvent(new Event("error"));return}let A=e.headersList.get("content-type",!0),t=null!==A?a(A):"failure",s="failure"!==t&&"text/event-stream"===t.essence;if(200!==e.status||!1===s){this.close(),this.dispatchEvent(new Event("error"));return}this.#AL=1,this.dispatchEvent(new Event("open")),this.#c.origin=e.urlList[e.urlList.length-1].origin;let n=new i({eventSourceSettings:this.#c,push:e=>{this.dispatchEvent(l(e.type,e.options))}});r(e.body.stream,n,e=>{e?.aborted===!1&&(this.close(),this.dispatchEvent(new Event("error")))})},this.#n=s(e)}#AY(){2!==this.#AL&&(this.#AL=0,this.dispatchEvent(new Event("error")),setTimeout(()=>{0===this.#AL&&(this.#c.lastEventId.length&&this.#Av.headersList.set("last-event-id",this.#c.lastEventId,!0),this.#AH())},this.#c.reconnectionTime)?.unref())}close(){o.brandCheck(this,Q),2!==this.#AL&&(this.#AL=2,this.#n.abort(),this.#Av=null)}get onopen(){return this.#AE.open}set onopen(e){this.#AE.open&&this.removeEventListener("open",this.#AE.open);let A=o.converters.EventHandlerNonNull(e);null!==A?(this.addEventListener("open",A),this.#AE.open=e):this.#AE.open=null}get onmessage(){return this.#AE.message}set onmessage(e){this.#AE.message&&this.removeEventListener("message",this.#AE.message);let A=o.converters.EventHandlerNonNull(e);null!==A?(this.addEventListener("message",A),this.#AE.message=e):this.#AE.message=null}get onerror(){return this.#AE.error}set onerror(e){this.#AE.error&&this.removeEventListener("error",this.#AE.error);let A=o.converters.EventHandlerNonNull(e);null!==A?(this.addEventListener("error",A),this.#AE.error=e):this.#AE.error=null}}let u={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:0,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:1,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:2,writable:!1}};Object.defineProperties(Q,u),Object.defineProperties(Q.prototype,u),Object.defineProperties(Q.prototype,{close:h,onerror:h,onmessage:h,onopen:h,readyState:h,url:h,withCredentials:h}),o.converters.EventSourceInitDict=o.dictionaryConverter([{key:"withCredentials",converter:o.converters.boolean,defaultValue:()=>!1},{key:"dispatcher",converter:o.converters.any},{key:"node",converter:o.dictionaryConverter([{key:"reconnectionTime",converter:o.converters["unsigned long"],defaultValue:()=>3e3},{key:"dispatcher",converter:o.converters.any}]),defaultValue:()=>({})}]),A.exports={EventSource:Q,defaultReconnectionTime:3e3}},724055,(e,A,t)=>{"use strict";let r=e.r(419820),s=e.r(963806),n=e.r(605654),o=e.r(449990),i=e.r(525160),a=e.r(497797),l=e.r(684465),g=e.r(217420),h=e.r(90328),c=e.r(84760),E=e.r(287596),Q=e.r(792901),u=e.r(504021),{InvalidArgumentError:I}=Q,B=e.r(974062),C=e.r(876203),d=e.r(965636),{MockCallHistory:f,MockCallHistoryLog:p}=e.r(910762),y=e.r(839058),D=e.r(260469),S=e.r(541064),w=e.r(644540),m=e.r(765081),{getGlobalDispatcher:N,setGlobalDispatcher:R}=e.r(979590),b=e.r(596094),U=e.r(168922);Object.assign(s.prototype,B),A.exports.Dispatcher=s,A.exports.Client=r,A.exports.Pool=n,A.exports.BalancedPool=o,A.exports.RoundRobinPool=i,A.exports.Agent=a,A.exports.ProxyAgent=l,A.exports.Socks5ProxyAgent=g,A.exports.EnvHttpProxyAgent=h,A.exports.RetryAgent=c,A.exports.H2CClient=E,A.exports.RetryHandler=m,A.exports.DecoratorHandler=b,A.exports.RedirectHandler=U,A.exports.interceptors={redirect:e.r(763376),responseError:e.r(687749),retry:e.r(73547),dump:e.r(37909),dns:e.r(693764),cache:e.r(576538),decompress:e.r(699865),deduplicate:e.r(201169)},A.exports.cacheStores={MemoryCacheStore:e.r(462671)};let F=e.r(302879);function k(e){return(A,t,r)=>{if("function"==typeof t&&(r=t,t=null),!A||"string"!=typeof A&&"object"!=typeof A&&!(A instanceof URL))throw new I("invalid url");if(null!=t&&"object"!=typeof t)throw new I("invalid opts");if(t&&null!=t.path){if("string"!=typeof t.path)throw new I("invalid opts.path");let e=t.path;t.path.startsWith("/")||(e=`/${e}`),A=new URL(u.parseOrigin(A).origin+e)}else t||(t="object"==typeof A?A:{}),A=u.parseURL(A);let{agent:s,dispatcher:n=N()}=t;if(s)throw new I("unsupported opts.agent. Did you mean opts.client?");return e.call(n,{...t,origin:A.origin,path:A.search?`${A.pathname}${A.search}`:A.pathname,method:t.method||(t.body?"PUT":"GET")},r)}}A.exports.cacheStores.SqliteCacheStore=F,A.exports.buildConnector=C,A.exports.errors=Q,A.exports.util={parseHeaders:u.parseHeaders,headerNameToString:u.headerNameToString},A.exports.setGlobalDispatcher=R,A.exports.getGlobalDispatcher=N;let M=e.r(486355).fetch,T="/ROOT/node_modules/undici/index.js";A.exports.fetch=function(e,t){return M(e,t).catch(e=>{throw T?!function e(A,t){if(!A||"object"!=typeof A)return;let r="string"==typeof A.stack?A.stack:"",s=t.replace(/\\/g,"/");if(r&&(r.includes(t)||r.includes(s)))return;let n={};if(Error.captureStackTrace(n,e),!n.stack)return;let o=n.stack.split("\n").slice(1).join("\n");A.stack=r?`${r}
|
|
120
|
-
${o}`:n.stack}(e,T):e&&"object"==typeof e&&Error.captureStackTrace(e,A.exports.fetch),e})},A.exports.Headers=e.r(700419).Headers,A.exports.Response=e.r(312148).Response,A.exports.Request=e.r(440796).Request,A.exports.FormData=e.r(695905).FormData;let{setGlobalOrigin:L,getGlobalOrigin:v}=e.r(498319);A.exports.setGlobalOrigin=L,A.exports.getGlobalOrigin=v;let{CacheStorage:H}=e.r(80599),{kConstruct:Y}=e.r(227235);A.exports.caches=new H(Y);let{deleteCookie:O,getCookies:x,getSetCookies:G,setCookie:V,parseCookie:J}=e.r(115689);A.exports.deleteCookie=O,A.exports.getCookies=x,A.exports.getSetCookies=G,A.exports.setCookie=V,A.exports.parseCookie=J;let{parseMIMEType:_,serializeAMimeType:P}=e.r(997726);A.exports.parseMIMEType=_,A.exports.serializeAMimeType=P;let{CloseEvent:W,ErrorEvent:q,MessageEvent:Z}=e.r(823164),{WebSocket:j,ping:X}=e.r(337557);A.exports.WebSocket=j,A.exports.CloseEvent=W,A.exports.ErrorEvent=q,A.exports.MessageEvent=Z,A.exports.ping=X,A.exports.WebSocketStream=e.r(233032).WebSocketStream,A.exports.WebSocketError=e.r(208890).WebSocketError,A.exports.request=k(B.request),A.exports.stream=k(B.stream),A.exports.pipeline=k(B.pipeline),A.exports.connect=k(B.connect),A.exports.upgrade=k(B.upgrade),A.exports.MockClient=d,A.exports.MockCallHistory=f,A.exports.MockCallHistoryLog=p,A.exports.MockPool=D,A.exports.MockAgent=y,A.exports.SnapshotAgent=S,A.exports.mockErrors=w;let{EventSource:z}=e.r(960854);A.exports.EventSource=z,A.exports.install=function(){globalThis.fetch=A.exports.fetch,globalThis.Headers=A.exports.Headers,globalThis.Response=A.exports.Response,globalThis.Request=A.exports.Request,globalThis.FormData=A.exports.FormData,globalThis.WebSocket=A.exports.WebSocket,globalThis.CloseEvent=A.exports.CloseEvent,globalThis.ErrorEvent=A.exports.ErrorEvent,globalThis.MessageEvent=A.exports.MessageEvent,globalThis.EventSource=A.exports.EventSource}},841380,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let r=e.r(500874),s={INVALID_ENCODING:"Invalid encoding provided. Please specify a valid encoding the internal Node.js Buffer supports.",INVALID_SMARTBUFFER_SIZE:"Invalid size provided. Size must be a valid integer greater than zero.",INVALID_SMARTBUFFER_BUFFER:"Invalid Buffer provided in SmartBufferOptions.",INVALID_SMARTBUFFER_OBJECT:"Invalid SmartBufferOptions object supplied to SmartBuffer constructor or factory methods.",INVALID_OFFSET:"An invalid offset value was provided.",INVALID_OFFSET_NON_NUMBER:"An invalid offset value was provided. A numeric value is required.",INVALID_LENGTH:"An invalid length value was provided.",INVALID_LENGTH_NON_NUMBER:"An invalid length value was provived. A numeric value is required.",INVALID_TARGET_OFFSET:"Target offset is beyond the bounds of the internal SmartBuffer data.",INVALID_TARGET_LENGTH:"Specified length value moves cursor beyong the bounds of the internal SmartBuffer data.",INVALID_READ_BEYOND_BOUNDS:"Attempted to read beyond the bounds of the managed data.",INVALID_WRITE_BEYOND_BOUNDS:"Attempted to write beyond the bounds of the managed data."};function n(e){var A;return"number"==typeof e&&isFinite(e)&&"number"==typeof(A=e)&&isFinite(A)&&Math.floor(A)===A}function o(e,A){if("number"==typeof e){if(!n(e)||e<0)throw Error(A?s.INVALID_OFFSET:s.INVALID_LENGTH)}else throw Error(A?s.INVALID_OFFSET_NON_NUMBER:s.INVALID_LENGTH_NON_NUMBER)}t.ERRORS=s,t.checkEncoding=function(e){if(!r.Buffer.isEncoding(e))throw Error(s.INVALID_ENCODING)},t.isFiniteInteger=n,t.checkLengthValue=function(e){o(e,!1)},t.checkOffsetValue=function(e){o(e,!0)},t.checkTargetOffset=function(e,A){if(e<0||e>A.length)throw Error(s.INVALID_TARGET_OFFSET)},t.bigIntAndBufferInt64Check=function(e){if("u"<typeof BigInt)throw Error("Platform does not support JS BigInt type.");if(void 0===r.Buffer.prototype[e])throw Error(`Platform does not support Buffer.prototype.${e}.`)}},102372,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let r=e.r(841380);class s{constructor(e){if(this.length=0,this._encoding="utf8",this._writeOffset=0,this._readOffset=0,s.isSmartBufferOptions(e))if(e.encoding&&(r.checkEncoding(e.encoding),this._encoding=e.encoding),e.size)if(r.isFiniteInteger(e.size)&&e.size>0)this._buff=Buffer.allocUnsafe(e.size);else throw Error(r.ERRORS.INVALID_SMARTBUFFER_SIZE);else if(e.buff)if(Buffer.isBuffer(e.buff))this._buff=e.buff,this.length=e.buff.length;else throw Error(r.ERRORS.INVALID_SMARTBUFFER_BUFFER);else this._buff=Buffer.allocUnsafe(4096);else{if(void 0!==e)throw Error(r.ERRORS.INVALID_SMARTBUFFER_OBJECT);this._buff=Buffer.allocUnsafe(4096)}}static fromSize(e,A){return new this({size:e,encoding:A})}static fromBuffer(e,A){return new this({buff:e,encoding:A})}static fromOptions(e){return new this(e)}static isSmartBufferOptions(e){return e&&(void 0!==e.encoding||void 0!==e.size||void 0!==e.buff)}readInt8(e){return this._readNumberValue(Buffer.prototype.readInt8,1,e)}readInt16BE(e){return this._readNumberValue(Buffer.prototype.readInt16BE,2,e)}readInt16LE(e){return this._readNumberValue(Buffer.prototype.readInt16LE,2,e)}readInt32BE(e){return this._readNumberValue(Buffer.prototype.readInt32BE,4,e)}readInt32LE(e){return this._readNumberValue(Buffer.prototype.readInt32LE,4,e)}readBigInt64BE(e){return r.bigIntAndBufferInt64Check("readBigInt64BE"),this._readNumberValue(Buffer.prototype.readBigInt64BE,8,e)}readBigInt64LE(e){return r.bigIntAndBufferInt64Check("readBigInt64LE"),this._readNumberValue(Buffer.prototype.readBigInt64LE,8,e)}writeInt8(e,A){return this._writeNumberValue(Buffer.prototype.writeInt8,1,e,A),this}insertInt8(e,A){return this._insertNumberValue(Buffer.prototype.writeInt8,1,e,A)}writeInt16BE(e,A){return this._writeNumberValue(Buffer.prototype.writeInt16BE,2,e,A)}insertInt16BE(e,A){return this._insertNumberValue(Buffer.prototype.writeInt16BE,2,e,A)}writeInt16LE(e,A){return this._writeNumberValue(Buffer.prototype.writeInt16LE,2,e,A)}insertInt16LE(e,A){return this._insertNumberValue(Buffer.prototype.writeInt16LE,2,e,A)}writeInt32BE(e,A){return this._writeNumberValue(Buffer.prototype.writeInt32BE,4,e,A)}insertInt32BE(e,A){return this._insertNumberValue(Buffer.prototype.writeInt32BE,4,e,A)}writeInt32LE(e,A){return this._writeNumberValue(Buffer.prototype.writeInt32LE,4,e,A)}insertInt32LE(e,A){return this._insertNumberValue(Buffer.prototype.writeInt32LE,4,e,A)}writeBigInt64BE(e,A){return r.bigIntAndBufferInt64Check("writeBigInt64BE"),this._writeNumberValue(Buffer.prototype.writeBigInt64BE,8,e,A)}insertBigInt64BE(e,A){return r.bigIntAndBufferInt64Check("writeBigInt64BE"),this._insertNumberValue(Buffer.prototype.writeBigInt64BE,8,e,A)}writeBigInt64LE(e,A){return r.bigIntAndBufferInt64Check("writeBigInt64LE"),this._writeNumberValue(Buffer.prototype.writeBigInt64LE,8,e,A)}insertBigInt64LE(e,A){return r.bigIntAndBufferInt64Check("writeBigInt64LE"),this._insertNumberValue(Buffer.prototype.writeBigInt64LE,8,e,A)}readUInt8(e){return this._readNumberValue(Buffer.prototype.readUInt8,1,e)}readUInt16BE(e){return this._readNumberValue(Buffer.prototype.readUInt16BE,2,e)}readUInt16LE(e){return this._readNumberValue(Buffer.prototype.readUInt16LE,2,e)}readUInt32BE(e){return this._readNumberValue(Buffer.prototype.readUInt32BE,4,e)}readUInt32LE(e){return this._readNumberValue(Buffer.prototype.readUInt32LE,4,e)}readBigUInt64BE(e){return r.bigIntAndBufferInt64Check("readBigUInt64BE"),this._readNumberValue(Buffer.prototype.readBigUInt64BE,8,e)}readBigUInt64LE(e){return r.bigIntAndBufferInt64Check("readBigUInt64LE"),this._readNumberValue(Buffer.prototype.readBigUInt64LE,8,e)}writeUInt8(e,A){return this._writeNumberValue(Buffer.prototype.writeUInt8,1,e,A)}insertUInt8(e,A){return this._insertNumberValue(Buffer.prototype.writeUInt8,1,e,A)}writeUInt16BE(e,A){return this._writeNumberValue(Buffer.prototype.writeUInt16BE,2,e,A)}insertUInt16BE(e,A){return this._insertNumberValue(Buffer.prototype.writeUInt16BE,2,e,A)}writeUInt16LE(e,A){return this._writeNumberValue(Buffer.prototype.writeUInt16LE,2,e,A)}insertUInt16LE(e,A){return this._insertNumberValue(Buffer.prototype.writeUInt16LE,2,e,A)}writeUInt32BE(e,A){return this._writeNumberValue(Buffer.prototype.writeUInt32BE,4,e,A)}insertUInt32BE(e,A){return this._insertNumberValue(Buffer.prototype.writeUInt32BE,4,e,A)}writeUInt32LE(e,A){return this._writeNumberValue(Buffer.prototype.writeUInt32LE,4,e,A)}insertUInt32LE(e,A){return this._insertNumberValue(Buffer.prototype.writeUInt32LE,4,e,A)}writeBigUInt64BE(e,A){return r.bigIntAndBufferInt64Check("writeBigUInt64BE"),this._writeNumberValue(Buffer.prototype.writeBigUInt64BE,8,e,A)}insertBigUInt64BE(e,A){return r.bigIntAndBufferInt64Check("writeBigUInt64BE"),this._insertNumberValue(Buffer.prototype.writeBigUInt64BE,8,e,A)}writeBigUInt64LE(e,A){return r.bigIntAndBufferInt64Check("writeBigUInt64LE"),this._writeNumberValue(Buffer.prototype.writeBigUInt64LE,8,e,A)}insertBigUInt64LE(e,A){return r.bigIntAndBufferInt64Check("writeBigUInt64LE"),this._insertNumberValue(Buffer.prototype.writeBigUInt64LE,8,e,A)}readFloatBE(e){return this._readNumberValue(Buffer.prototype.readFloatBE,4,e)}readFloatLE(e){return this._readNumberValue(Buffer.prototype.readFloatLE,4,e)}writeFloatBE(e,A){return this._writeNumberValue(Buffer.prototype.writeFloatBE,4,e,A)}insertFloatBE(e,A){return this._insertNumberValue(Buffer.prototype.writeFloatBE,4,e,A)}writeFloatLE(e,A){return this._writeNumberValue(Buffer.prototype.writeFloatLE,4,e,A)}insertFloatLE(e,A){return this._insertNumberValue(Buffer.prototype.writeFloatLE,4,e,A)}readDoubleBE(e){return this._readNumberValue(Buffer.prototype.readDoubleBE,8,e)}readDoubleLE(e){return this._readNumberValue(Buffer.prototype.readDoubleLE,8,e)}writeDoubleBE(e,A){return this._writeNumberValue(Buffer.prototype.writeDoubleBE,8,e,A)}insertDoubleBE(e,A){return this._insertNumberValue(Buffer.prototype.writeDoubleBE,8,e,A)}writeDoubleLE(e,A){return this._writeNumberValue(Buffer.prototype.writeDoubleLE,8,e,A)}insertDoubleLE(e,A){return this._insertNumberValue(Buffer.prototype.writeDoubleLE,8,e,A)}readString(e,A){let t;"number"==typeof e?(r.checkLengthValue(e),t=Math.min(e,this.length-this._readOffset)):(A=e,t=this.length-this._readOffset),void 0!==A&&r.checkEncoding(A);let s=this._buff.slice(this._readOffset,this._readOffset+t).toString(A||this._encoding);return this._readOffset+=t,s}insertString(e,A,t){return r.checkOffsetValue(A),this._handleString(e,!0,A,t)}writeString(e,A,t){return this._handleString(e,!1,A,t)}readStringNT(e){void 0!==e&&r.checkEncoding(e);let A=this.length;for(let e=this._readOffset;e<this.length;e++)if(0===this._buff[e]){A=e;break}let t=this._buff.slice(this._readOffset,A);return this._readOffset=A+1,t.toString(e||this._encoding)}insertStringNT(e,A,t){return r.checkOffsetValue(A),this.insertString(e,A,t),this.insertUInt8(0,A+e.length),this}writeStringNT(e,A,t){return this.writeString(e,A,t),this.writeUInt8(0,"number"==typeof A?A+e.length:this.writeOffset),this}readBuffer(e){void 0!==e&&r.checkLengthValue(e);let A="number"==typeof e?e:this.length,t=Math.min(this.length,this._readOffset+A),s=this._buff.slice(this._readOffset,t);return this._readOffset=t,s}insertBuffer(e,A){return r.checkOffsetValue(A),this._handleBuffer(e,!0,A)}writeBuffer(e,A){return this._handleBuffer(e,!1,A)}readBufferNT(){let e=this.length;for(let A=this._readOffset;A<this.length;A++)if(0===this._buff[A]){e=A;break}let A=this._buff.slice(this._readOffset,e);return this._readOffset=e+1,A}insertBufferNT(e,A){return r.checkOffsetValue(A),this.insertBuffer(e,A),this.insertUInt8(0,A+e.length),this}writeBufferNT(e,A){return void 0!==A&&r.checkOffsetValue(A),this.writeBuffer(e,A),this.writeUInt8(0,"number"==typeof A?A+e.length:this._writeOffset),this}clear(){return this._writeOffset=0,this._readOffset=0,this.length=0,this}remaining(){return this.length-this._readOffset}get readOffset(){return this._readOffset}set readOffset(e){r.checkOffsetValue(e),r.checkTargetOffset(e,this),this._readOffset=e}get writeOffset(){return this._writeOffset}set writeOffset(e){r.checkOffsetValue(e),r.checkTargetOffset(e,this),this._writeOffset=e}get encoding(){return this._encoding}set encoding(e){r.checkEncoding(e),this._encoding=e}get internalBuffer(){return this._buff}toBuffer(){return this._buff.slice(0,this.length)}toString(e){let A="string"==typeof e?e:this._encoding;return r.checkEncoding(A),this._buff.toString(A,0,this.length)}destroy(){return this.clear(),this}_handleString(e,A,t,s){let n=this._writeOffset,o=this._encoding;"number"==typeof t?n=t:"string"==typeof t&&(r.checkEncoding(t),o=t),"string"==typeof s&&(r.checkEncoding(s),o=s);let i=Buffer.byteLength(e,o);return A?this.ensureInsertable(i,n):this._ensureWriteable(i,n),this._buff.write(e,n,i,o),A?this._writeOffset+=i:"number"==typeof t?this._writeOffset=Math.max(this._writeOffset,n+i):this._writeOffset+=i,this}_handleBuffer(e,A,t){let r="number"==typeof t?t:this._writeOffset;return A?this.ensureInsertable(e.length,r):this._ensureWriteable(e.length,r),e.copy(this._buff,r),A?this._writeOffset+=e.length:"number"==typeof t?this._writeOffset=Math.max(this._writeOffset,r+e.length):this._writeOffset+=e.length,this}ensureReadable(e,A){let t=this._readOffset;if(void 0!==A&&(r.checkOffsetValue(A),t=A),t<0||t+e>this.length)throw Error(r.ERRORS.INVALID_READ_BEYOND_BOUNDS)}ensureInsertable(e,A){r.checkOffsetValue(A),this._ensureCapacity(this.length+e),A<this.length&&this._buff.copy(this._buff,A+e,A,this._buff.length),A+e>this.length?this.length=A+e:this.length+=e}_ensureWriteable(e,A){let t="number"==typeof A?A:this._writeOffset;this._ensureCapacity(t+e),t+e>this.length&&(this.length=t+e)}_ensureCapacity(e){let A=this._buff.length;if(e>A){let t=this._buff,r=3*A/2+1;r<e&&(r=e),this._buff=Buffer.allocUnsafe(r),t.copy(this._buff,0,0,A)}}_readNumberValue(e,A,t){this.ensureReadable(A,t);let r=e.call(this._buff,"number"==typeof t?t:this._readOffset);return void 0===t&&(this._readOffset+=A),r}_insertNumberValue(e,A,t,s){return r.checkOffsetValue(s),this.ensureInsertable(A,s),e.call(this._buff,t,s),this._writeOffset+=A,this}_writeNumberValue(e,A,t,s){if("number"==typeof s){if(s<0)throw Error(r.ERRORS.INVALID_WRITE_BEYOND_BOUNDS);r.checkOffsetValue(s)}let n="number"==typeof s?s:this._writeOffset;return this._ensureWriteable(A,n),e.call(this._buff,t,n),"number"==typeof s?this._writeOffset=Math.max(this._writeOffset,n+A):this._writeOffset+=A,this}}t.SmartBuffer=s},81762,(e,A,t)=>{"use strict";var r,s,n,o,i,a,l,g,h,c,E,Q;Object.defineProperty(t,"__esModule",{value:!0}),t.SOCKS5_NO_ACCEPTABLE_AUTH=t.SOCKS5_CUSTOM_AUTH_END=t.SOCKS5_CUSTOM_AUTH_START=t.SOCKS_INCOMING_PACKET_SIZES=t.SocksClientState=t.Socks5Response=t.Socks5HostType=t.Socks5Auth=t.Socks4Response=t.SocksCommand=t.ERRORS=t.DEFAULT_TIMEOUT=void 0,t.DEFAULT_TIMEOUT=3e4,t.ERRORS={InvalidSocksCommand:"An invalid SOCKS command was provided. Valid options are connect, bind, and associate.",InvalidSocksCommandForOperation:"An invalid SOCKS command was provided. Only a subset of commands are supported for this operation.",InvalidSocksCommandChain:"An invalid SOCKS command was provided. Chaining currently only supports the connect command.",InvalidSocksClientOptionsDestination:"An invalid destination host was provided.",InvalidSocksClientOptionsExistingSocket:"An invalid existing socket was provided. This should be an instance of stream.Duplex.",InvalidSocksClientOptionsProxy:"Invalid SOCKS proxy details were provided.",InvalidSocksClientOptionsTimeout:"An invalid timeout value was provided. Please enter a value above 0 (in ms).",InvalidSocksClientOptionsProxiesLength:"At least two socks proxies must be provided for chaining.",InvalidSocksClientOptionsCustomAuthRange:"Custom auth must be a value between 0x80 and 0xFE.",InvalidSocksClientOptionsCustomAuthOptions:"When a custom_auth_method is provided, custom_auth_request_handler, custom_auth_response_size, and custom_auth_response_handler must also be provided and valid.",NegotiationError:"Negotiation error",SocketClosed:"Socket closed",ProxyConnectionTimedOut:"Proxy connection timed out",InternalError:"SocksClient internal error (this should not happen)",InvalidSocks4HandshakeResponse:"Received invalid Socks4 handshake response",Socks4ProxyRejectedConnection:"Socks4 Proxy rejected connection",InvalidSocks4IncomingConnectionResponse:"Socks4 invalid incoming connection response",Socks4ProxyRejectedIncomingBoundConnection:"Socks4 Proxy rejected incoming bound connection",InvalidSocks5InitialHandshakeResponse:"Received invalid Socks5 initial handshake response",InvalidSocks5IntiailHandshakeSocksVersion:"Received invalid Socks5 initial handshake (invalid socks version)",InvalidSocks5InitialHandshakeNoAcceptedAuthType:"Received invalid Socks5 initial handshake (no accepted authentication type)",InvalidSocks5InitialHandshakeUnknownAuthType:"Received invalid Socks5 initial handshake (unknown authentication type)",Socks5AuthenticationFailed:"Socks5 Authentication failed",InvalidSocks5FinalHandshake:"Received invalid Socks5 final handshake response",InvalidSocks5FinalHandshakeRejected:"Socks5 proxy rejected connection",InvalidSocks5IncomingConnectionResponse:"Received invalid Socks5 incoming connection response",Socks5ProxyRejectedIncomingBoundConnection:"Socks5 Proxy rejected incoming bound connection"},t.SOCKS_INCOMING_PACKET_SIZES={Socks5InitialHandshakeResponse:2,Socks5UserPassAuthenticationResponse:2,Socks5ResponseHeader:5,Socks5ResponseIPv4:10,Socks5ResponseIPv6:22,Socks5ResponseHostname:e=>e+7,Socks4Response:8},(l=r||(t.SocksCommand=r={}))[l.connect=1]="connect",l[l.bind=2]="bind",l[l.associate=3]="associate",(g=s||(t.Socks4Response=s={}))[g.Granted=90]="Granted",g[g.Failed=91]="Failed",g[g.Rejected=92]="Rejected",g[g.RejectedIdent=93]="RejectedIdent",(h=n||(t.Socks5Auth=n={}))[h.NoAuth=0]="NoAuth",h[h.GSSApi=1]="GSSApi",h[h.UserPass=2]="UserPass",t.SOCKS5_CUSTOM_AUTH_START=128,t.SOCKS5_CUSTOM_AUTH_END=254,t.SOCKS5_NO_ACCEPTABLE_AUTH=255,(c=o||(t.Socks5Response=o={}))[c.Granted=0]="Granted",c[c.Failure=1]="Failure",c[c.NotAllowed=2]="NotAllowed",c[c.NetworkUnreachable=3]="NetworkUnreachable",c[c.HostUnreachable=4]="HostUnreachable",c[c.ConnectionRefused=5]="ConnectionRefused",c[c.TTLExpired=6]="TTLExpired",c[c.CommandNotSupported=7]="CommandNotSupported",c[c.AddressNotSupported=8]="AddressNotSupported",(E=i||(t.Socks5HostType=i={}))[E.IPv4=1]="IPv4",E[E.Hostname=3]="Hostname",E[E.IPv6=4]="IPv6",(Q=a||(t.SocksClientState=a={}))[Q.Created=0]="Created",Q[Q.Connecting=1]="Connecting",Q[Q.Connected=2]="Connected",Q[Q.SentInitialHandshake=3]="SentInitialHandshake",Q[Q.ReceivedInitialHandshakeResponse=4]="ReceivedInitialHandshakeResponse",Q[Q.SentAuthentication=5]="SentAuthentication",Q[Q.ReceivedAuthenticationResponse=6]="ReceivedAuthenticationResponse",Q[Q.SentFinalHandshake=7]="SentFinalHandshake",Q[Q.ReceivedFinalResponse=8]="ReceivedFinalResponse",Q[Q.BoundWaitingForConnection=9]="BoundWaitingForConnection",Q[Q.Established=10]="Established",Q[Q.Disconnected=11]="Disconnected",Q[Q.Error=99]="Error"},188286,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shuffleArray=t.SocksClientError=void 0,t.SocksClientError=class extends Error{constructor(e,A){super(e),this.options=A}},t.shuffleArray=function(e){for(let A=e.length-1;A>0;A--){let t=Math.floor(Math.random()*(A+1));[e[A],e[t]]=[e[t],e[A]]}}},923764,(e,A,t)=>{"use strict";function r(e){return e.toString(16).padStart(2,"0")}Object.defineProperty(t,"__esModule",{value:!0}),t.isInSubnet=function(e){return!(this.subnetMask<e.subnetMask)&&this.mask(e.subnetMask)===e.mask()},t.isCorrect=function(e){return function(){return this.addressMinusSuffix===this.correctForm()&&(this.subnetMask===e&&!this.parsedSubnet||this.parsedSubnet===String(this.subnetMask))}},t.numberToPaddedHex=r,t.stringToPaddedHex=function(e){return r(parseInt(e,10))},t.testBit=function(e,A){let{length:t}=e;if(A>t)return!1;let r=t-A;return"1"===e.substring(r,r+1)}},103696,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RE_SUBNET_STRING=t.RE_ADDRESS=t.GROUPS=t.BITS=void 0,t.BITS=32,t.GROUPS=4,t.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g,t.RE_SUBNET_STRING=/\/\d{1,2}$/},157271,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AddressError=void 0,t.AddressError=class extends Error{constructor(e,A){super(e),this.name="AddressError",this.parseMessage=A}}},6860,(e,A,t)=>{"use strict";var r=e.e&&e.e.__createBinding||(Object.create?function(e,A,t,r){void 0===r&&(r=t);var s=Object.getOwnPropertyDescriptor(A,t);(!s||("get"in s?!A.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,s)}:function(e,A,t,r){void 0===r&&(r=t),e[r]=A[t]}),s=e.e&&e.e.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),n=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&r(A,e,t);return s(A,e),A};Object.defineProperty(t,"__esModule",{value:!0}),t.Address4=void 0;let o=n(e.r(923764)),i=n(e.r(103696)),a=e.r(157271);class l{constructor(e){this.groups=i.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=o.isCorrect(i.BITS),this.isInSubnet=o.isInSubnet,this.address=e;const A=i.RE_SUBNET_STRING.exec(e);if(A){if(this.parsedSubnet=A[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>i.BITS)throw new a.AddressError("Invalid subnet mask.");e=e.replace(i.RE_SUBNET_STRING,"")}this.addressMinusSuffix=e,this.parsedAddress=this.parse(e)}static isValid(e){try{return new l(e),!0}catch(e){return!1}}parse(e){let A=e.split(".");if(!e.match(i.RE_ADDRESS))throw new a.AddressError("Invalid IPv4 address.");return A}correctForm(){return this.parsedAddress.map(e=>parseInt(e,10)).join(".")}static fromHex(e){let A,t=e.replace(/:/g,"").padStart(8,"0"),r=[];for(A=0;A<8;A+=2){let e=t.slice(A,A+2);r.push(parseInt(e,16))}return new l(r.join("."))}static fromInteger(e){return l.fromHex(e.toString(16))}static fromArpa(e){return new l(e.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join("."))}toHex(){return this.parsedAddress.map(e=>o.stringToPaddedHex(e)).join(":")}toArray(){return this.parsedAddress.map(e=>parseInt(e,10))}toGroup6(){let e,A=[];for(e=0;e<i.GROUPS;e+=2)A.push(`${o.stringToPaddedHex(this.parsedAddress[e])}${o.stringToPaddedHex(this.parsedAddress[e+1])}`);return A.join(":")}bigInt(){return BigInt(`0x${this.parsedAddress.map(e=>o.stringToPaddedHex(e)).join("")}`)}_startAddress(){return BigInt(`0b${this.mask()+"0".repeat(i.BITS-this.subnetMask)}`)}startAddress(){return l.fromBigInt(this._startAddress())}startAddressExclusive(){let e=BigInt("1");return l.fromBigInt(this._startAddress()+e)}_endAddress(){return BigInt(`0b${this.mask()+"1".repeat(i.BITS-this.subnetMask)}`)}endAddress(){return l.fromBigInt(this._endAddress())}endAddressExclusive(){let e=BigInt("1");return l.fromBigInt(this._endAddress()-e)}static fromBigInt(e){return l.fromHex(e.toString(16))}static fromByteArray(e){if(4!==e.length)throw new a.AddressError("IPv4 addresses require exactly 4 bytes");for(let A=0;A<e.length;A++)if(!Number.isInteger(e[A])||e[A]<0||e[A]>255)throw new a.AddressError("All bytes must be integers between 0 and 255");return this.fromUnsignedByteArray(e)}static fromUnsignedByteArray(e){if(4!==e.length)throw new a.AddressError("IPv4 addresses require exactly 4 bytes");return new l(e.join("."))}mask(e){return void 0===e&&(e=this.subnetMask),this.getBitsBase2(0,e)}getBitsBase2(e,A){return this.binaryZeroPad().slice(e,A)}reverseForm(e){e||(e={});let A=this.correctForm().split(".").reverse().join(".");return e.omitSuffix?A:`${A}.in-addr.arpa.`}isMulticast(){return this.isInSubnet(new l("224.0.0.0/4"))}binaryZeroPad(){return this.bigInt().toString(2).padStart(i.BITS,"0")}groupForV6(){let e=this.parsedAddress;return this.address.replace(i.RE_ADDRESS,`<span class="hover-group group-v4 group-6">${e.slice(0,2).join(".")}</span>.<span class="hover-group group-v4 group-7">${e.slice(2,4).join(".")}</span>`)}}t.Address4=l},419123,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RE_URL_WITH_PORT=t.RE_URL=t.RE_ZONE_STRING=t.RE_SUBNET_STRING=t.RE_BAD_ADDRESS=t.RE_BAD_CHARACTERS=t.TYPES=t.SCOPES=t.GROUPS=t.BITS=void 0,t.BITS=128,t.GROUPS=8,t.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},t.TYPES={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"},t.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi,t.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,t.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/,t.RE_ZONE_STRING=/%.*$/,t.RE_URL=/^\[{0,1}([0-9a-f:]+)\]{0,1}/,t.RE_URL_WITH_PORT=/\[([0-9a-f:]+)\]:([0-9]{1,5})/},204767,(e,A,t)=>{"use strict";function r(e){return e.replace(/(0+)/g,'<span class="zero">$1</span>')}function s(e){return e.replace(/^(0+)/,'<span class="zero">$1</span>')}Object.defineProperty(t,"__esModule",{value:!0}),t.spanAllZeroes=r,t.spanAll=function(e,A=0){return e.split("").map((e,t)=>`<span class="digit value-${e} position-${t+A}">${r(e)}</span>`).join("")},t.spanLeadingZeroes=function(e){return e.split(":").map(e=>s(e)).join(":")},t.simpleGroup=function(e,A=0){return e.split(":").map((e,t)=>/group-v4/.test(e)?e:`<span class="hover-group group-${t+A}">${s(e)}</span>`)}},137019,(e,A,t)=>{"use strict";var r=e.e&&e.e.__createBinding||(Object.create?function(e,A,t,r){void 0===r&&(r=t);var s=Object.getOwnPropertyDescriptor(A,t);(!s||("get"in s?!A.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,s)}:function(e,A,t,r){void 0===r&&(r=t),e[r]=A[t]}),s=e.e&&e.e.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),n=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&r(A,e,t);return s(A,e),A};Object.defineProperty(t,"__esModule",{value:!0}),t.ADDRESS_BOUNDARY=void 0,t.groupPossibilities=i,t.padGroup=a,t.simpleRegularExpression=function(e){let A=[];e.forEach((e,t)=>{0===parseInt(e,16)&&A.push(t)});let t=A.map(A=>e.map((e,t)=>{if(t===A){let A=0===t||t===o.GROUPS-1?":":"";return i([a(e),A])}return a(e)}).join(":"));return t.push(e.map(a).join(":")),i(t)},t.possibleElisions=function(e,A,t){let r=[];A||t||r.push("::"),A&&t&&r.push(""),(t&&!A||!t&&A)&&r.push(":"),r.push(`${A?"":":"}(:0{1,4}){1,${e-1}}`),r.push(`(0{1,4}:){1,${e-1}}${t?"":":"}`),r.push(`(0{1,4}:){${e-1}}0{1,4}`);for(let A=1;A<e-1;A++)for(let t=1;t<e-A;t++)r.push(`(0{1,4}:){${t}}:(0{1,4}:){${e-t-A-1}}0{1,4}`);return i(r)};let o=n(e.r(419123));function i(e){return`(${e.join("|")})`}function a(e){return e.length<4?`0{0,${4-e.length}}${e}`:e}t.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]"},707875,(e,A,t)=>{"use strict";var r=e.e&&e.e.__createBinding||(Object.create?function(e,A,t,r){void 0===r&&(r=t);var s=Object.getOwnPropertyDescriptor(A,t);(!s||("get"in s?!A.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,s)}:function(e,A,t,r){void 0===r&&(r=t),e[r]=A[t]}),s=e.e&&e.e.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),n=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&r(A,e,t);return s(A,e),A};Object.defineProperty(t,"__esModule",{value:!0}),t.Address6=void 0;let o=n(e.r(923764)),i=n(e.r(103696)),a=n(e.r(419123)),l=n(e.r(204767)),g=e.r(6860),h=e.r(137019),c=e.r(157271),E=e.r(923764);function Q(e){if(!e)throw Error("Assertion failed.")}function u(e){return(e=e.replace(/^(0{1,})([1-9]+)$/,'<span class="parse-error">$1</span>$2')).replace(/^(0{1,})(0)$/,'<span class="parse-error">$1</span>$2')}function I(e){return parseInt(e,16).toString(16).padStart(4,"0")}function B(e){return 255&e}class C{constructor(e,A){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=o.isInSubnet,this.isCorrect=o.isCorrect(a.BITS),void 0===A?this.groups=a.GROUPS:this.groups=A,this.address=e;const t=a.RE_SUBNET_STRING.exec(e);if(t){if(this.parsedSubnet=t[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>a.BITS)throw new c.AddressError("Invalid subnet mask.");e=e.replace(a.RE_SUBNET_STRING,"")}else if(/\//.test(e))throw new c.AddressError("Invalid subnet mask.");const r=a.RE_ZONE_STRING.exec(e);r&&(this.zone=r[0],e=e.replace(a.RE_ZONE_STRING,"")),this.addressMinusSuffix=e,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(e){try{return new C(e),!0}catch(e){return!1}}static fromBigInt(e){let A,t=e.toString(16).padStart(32,"0"),r=[];for(A=0;A<a.GROUPS;A++)r.push(t.slice(4*A,(A+1)*4));return new C(r.join(":"))}static fromURL(e){let A,t,r=null;if(-1!==e.indexOf("[")&&-1!==e.indexOf("]:")){if(null===(t=a.RE_URL_WITH_PORT.exec(e)))return{error:"failed to parse address with port",address:null,port:null};A=t[1],r=t[2]}else if(-1!==e.indexOf("/")){if(e=e.replace(/^[a-z0-9]+:\/\//,""),null===(t=a.RE_URL.exec(e)))return{error:"failed to parse address from URL",address:null,port:null};A=t[1]}else A=e;return r?((r=parseInt(r,10))<0||r>65536)&&(r=null):r=null,{address:new C(A),port:r}}static fromAddress4(e){let A=new g.Address4(e),t=a.BITS-(i.BITS-A.subnetMask);return new C(`::ffff:${A.correctForm()}/${t}`)}static fromArpa(e){let A=e.replace(/(\.ip6\.arpa)?\.$/,"");if(63!==A.length)throw new c.AddressError("Invalid 'ip6.arpa' form.");let t=A.split(".").reverse();for(let e=7;e>0;e--){let A=4*e;t.splice(A,0,":")}return new C(A=t.join(""))}microsoftTranscription(){return`${this.correctForm().replace(/:/g,"-")}.ipv6-literal.net`}mask(e=this.subnetMask){return this.getBitsBase2(0,e)}possibleSubnets(e=128){let A=a.BITS-this.subnetMask-Math.abs(e-a.BITS);if(A<0)return"0";var t=(BigInt("2")**BigInt(A)).toString(10);let r=/(\d+)(\d{3})/;for(;r.test(t);)t=t.replace(r,"$1,$2");return t}_startAddress(){return BigInt(`0b${this.mask()+"0".repeat(a.BITS-this.subnetMask)}`)}startAddress(){return C.fromBigInt(this._startAddress())}startAddressExclusive(){let e=BigInt("1");return C.fromBigInt(this._startAddress()+e)}_endAddress(){return BigInt(`0b${this.mask()+"1".repeat(a.BITS-this.subnetMask)}`)}endAddress(){return C.fromBigInt(this._endAddress())}endAddressExclusive(){let e=BigInt("1");return C.fromBigInt(this._endAddress()-e)}getScope(){let e=a.SCOPES[parseInt(this.getBits(12,16).toString(10),10)];return"Global unicast"===this.getType()&&"Link local"!==e&&(e="Global"),e||"Unknown"}getType(){for(let e of Object.keys(a.TYPES))if(this.isInSubnet(new C(e)))return a.TYPES[e];return"Global unicast"}getBits(e,A){return BigInt(`0b${this.getBitsBase2(e,A)}`)}getBitsBase2(e,A){return this.binaryZeroPad().slice(e,A)}getBitsBase16(e,A){let t=A-e;if(t%4!=0)throw Error("Length of bits to retrieve must be divisible by four");return this.getBits(e,A).toString(16).padStart(t/4,"0")}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,a.BITS)}reverseForm(e){e||(e={});let A=Math.floor(this.subnetMask/4),t=this.canonicalForm().replace(/:/g,"").split("").slice(0,A).reverse().join(".");return A>0?e.omitSuffix?t:`${t}.ip6.arpa.`:e.omitSuffix?"":"ip6.arpa."}correctForm(){let e,A=[],t=0,r=[];for(e=0;e<this.parsedAddress.length;e++){let A=parseInt(this.parsedAddress[e],16);0===A&&t++,0!==A&&t>0&&(t>1&&r.push([e-t,e-1]),t=0)}t>1&&r.push([this.parsedAddress.length-t,this.parsedAddress.length-1]);let s=r.map(e=>e[1]-e[0]+1);if(r.length>0){let e=s.indexOf(Math.max(...s));A=function(e,A){let t,r=[],s=[];for(t=0;t<e.length;t++)t<A[0]?r.push(e[t]):t>A[1]&&s.push(e[t]);return r.concat(["compact"]).concat(s)}(this.parsedAddress,r[e])}else A=this.parsedAddress;for(e=0;e<A.length;e++)"compact"!==A[e]&&(A[e]=parseInt(A[e],16).toString(16));let n=A.join(":");return(n=(n=n.replace(/^compact$/,"::")).replace(/(^compact)|(compact$)/,":")).replace(/compact/,"")}binaryZeroPad(){return this.bigInt().toString(2).padStart(a.BITS,"0")}parse4in6(e){let A=e.split(":"),t=A.slice(-1)[0].match(i.RE_ADDRESS);if(t){this.parsedAddress4=t[0],this.address4=new g.Address4(this.parsedAddress4);for(let A=0;A<this.address4.groups;A++)if(/^0[0-9]+/.test(this.address4.parsedAddress[A]))throw new c.AddressError("IPv4 addresses can't have leading zeroes.",e.replace(i.RE_ADDRESS,this.address4.parsedAddress.map(u).join(".")));this.v4=!0,A[A.length-1]=this.address4.toGroup6(),e=A.join(":")}return e}parse(e){let A=(e=this.parse4in6(e)).match(a.RE_BAD_CHARACTERS);if(A)throw new c.AddressError(`Bad character${A.length>1?"s":""} detected in address: ${A.join("")}`,e.replace(a.RE_BAD_CHARACTERS,'<span class="parse-error">$1</span>'));let t=e.match(a.RE_BAD_ADDRESS);if(t)throw new c.AddressError(`Address failed regex: ${t.join("")}`,e.replace(a.RE_BAD_ADDRESS,'<span class="parse-error">$1</span>'));let r=[],s=e.split("::");if(2===s.length){let e=s[0].split(":"),A=s[1].split(":");1===e.length&&""===e[0]&&(e=[]),1===A.length&&""===A[0]&&(A=[]);let t=this.groups-(e.length+A.length);if(!t)throw new c.AddressError("Error parsing groups");this.elidedGroups=t,this.elisionBegin=e.length,this.elisionEnd=e.length+this.elidedGroups,r=r.concat(e);for(let e=0;e<t;e++)r.push("0");r=r.concat(A)}else if(1===s.length)r=e.split(":"),this.elidedGroups=0;else throw new c.AddressError("Too many :: groups found");if((r=r.map(e=>parseInt(e,16).toString(16))).length!==this.groups)throw new c.AddressError("Incorrect number of groups found");return r}canonicalForm(){return this.parsedAddress.map(I).join(":")}decimal(){return this.parsedAddress.map(e=>parseInt(e,16).toString(10).padStart(5,"0")).join(":")}bigInt(){return BigInt(`0x${this.parsedAddress.map(I).join("")}`)}to4(){let e=this.binaryZeroPad().split("");return g.Address4.fromHex(BigInt(`0b${e.slice(96,128).join("")}`).toString(16))}to4in6(){let e=this.to4(),A=new C(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),t="";return/:$/.test(A)||(t=":"),A+t+e.address}inspectTeredo(){let e=this.getBitsBase16(0,32),A=(this.getBits(80,96)^BigInt("0xffff")).toString(),t=g.Address4.fromHex(this.getBitsBase16(32,64)),r=this.getBits(96,128),s=g.Address4.fromHex((r^BigInt("0xffffffff")).toString(16)),n=this.getBitsBase2(64,80),o=(0,E.testBit)(n,15),i=(0,E.testBit)(n,14),a=(0,E.testBit)(n,8),l=(0,E.testBit)(n,9),h=BigInt(`0b${n.slice(2,6)+n.slice(8,16)}`).toString(10);return{prefix:`${e.slice(0,4)}:${e.slice(4,8)}`,server4:t.address,client4:s.address,flags:n,coneNat:o,microsoft:{reserved:i,universalLocal:l,groupIndividual:a,nonce:h},udpPort:A}}inspect6to4(){let e=this.getBitsBase16(0,16),A=g.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:e.slice(0,4),gateway:A.address}}to6to4(){return this.is4()?new C(["2002",this.getBitsBase16(96,112),this.getBitsBase16(112,128),":/16"].join(":")):null}toByteArray(){let e=this.bigInt().toString(16),A="0".repeat(e.length%2),t=`${A}${e}`,r=[];for(let e=0,A=t.length;e<A;e+=2)r.push(parseInt(t.substring(e,e+2),16));return r}toUnsignedByteArray(){return this.toByteArray().map(B)}static fromByteArray(e){return this.fromUnsignedByteArray(e.map(B))}static fromUnsignedByteArray(e){let A=BigInt("256"),t=BigInt("0"),r=BigInt("1");for(let s=e.length-1;s>=0;s--)t+=r*BigInt(e[s].toString(10)),r*=A;return C.fromBigInt(t)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return"1111111010000000000000000000000000000000000000000000000000000000"===this.getBitsBase2(0,64)}isMulticast(){return"Multicast"===this.getType()}is4(){return this.v4}isTeredo(){return this.isInSubnet(new C("2001::/32"))}is6to4(){return this.isInSubnet(new C("2002::/16"))}isLoopback(){return"Loopback"===this.getType()}href(e){return e=void 0===e?"":`:${e}`,`http://[${this.correctForm()}]${e}/`}link(e){e||(e={}),void 0===e.className&&(e.className=""),void 0===e.prefix&&(e.prefix="/#address="),void 0===e.v4&&(e.v4=!1);let A=this.correctForm;e.v4&&(A=this.to4in6);let t=A.call(this);return e.className?`<a href="${e.prefix}${t}" class="${e.className}">${t}</a>`:`<a href="${e.prefix}${t}">${t}</a>`}group(){if(0===this.elidedGroups)return l.simpleGroup(this.address).join(":");Q("number"==typeof this.elidedGroups),Q("number"==typeof this.elisionBegin);let e=[],[A,t]=this.address.split("::");A.length?e.push(...l.simpleGroup(A)):e.push("");let r=["hover-group"];for(let e=this.elisionBegin;e<this.elisionBegin+this.elidedGroups;e++)r.push(`group-${e}`);return e.push(`<span class="${r.join(" ")}"></span>`),t.length?e.push(...l.simpleGroup(t,this.elisionEnd)):e.push(""),this.is4()&&(Q(this.address4 instanceof g.Address4),e.pop(),e.push(this.address4.groupForV6())),e.join(":")}regularExpressionString(e=!1){let A=[],t=new C(this.correctForm());if(0===t.elidedGroups)A.push((0,h.simpleRegularExpression)(t.parsedAddress));else if(t.elidedGroups===a.GROUPS)A.push((0,h.possibleElisions)(a.GROUPS));else{let e=t.address.split("::");e[0].length&&A.push((0,h.simpleRegularExpression)(e[0].split(":"))),Q("number"==typeof t.elidedGroups),A.push((0,h.possibleElisions)(t.elidedGroups,0!==e[0].length,0!==e[1].length)),e[1].length&&A.push((0,h.simpleRegularExpression)(e[1].split(":"))),A=[A.join(":")]}return e||(A=["(?=^|",h.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...A,")(?=[^\\w\\:]|",h.ADDRESS_BOUNDARY,"|$)"]),A.join("")}regularExpression(e=!1){return RegExp(this.regularExpressionString(e),"i")}}t.Address6=C},855389,(e,A,t)=>{"use strict";var r=e.e&&e.e.__createBinding||(Object.create?function(e,A,t,r){void 0===r&&(r=t);var s=Object.getOwnPropertyDescriptor(A,t);(!s||("get"in s?!A.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,s)}:function(e,A,t,r){void 0===r&&(r=t),e[r]=A[t]}),s=e.e&&e.e.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),n=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&r(A,e,t);return s(A,e),A};Object.defineProperty(t,"__esModule",{value:!0}),t.v6=t.AddressError=t.Address6=t.Address4=void 0;var o=e.r(6860);Object.defineProperty(t,"Address4",{enumerable:!0,get:function(){return o.Address4}});var i=e.r(707875);Object.defineProperty(t,"Address6",{enumerable:!0,get:function(){return i.Address6}});var a=e.r(157271);Object.defineProperty(t,"AddressError",{enumerable:!0,get:function(){return a.AddressError}}),t.v6={helpers:n(e.r(204767))}},667906,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ipToBuffer=t.int32ToIpv4=t.ipv4ToInt32=t.validateSocksClientChainOptions=t.validateSocksClientOptions=void 0;let r=e.r(188286),s=e.r(81762),n=e.r(688947),o=e.r(855389),i=e.r(504446);function a(e,A){if(void 0!==e.custom_auth_method){if(e.custom_auth_method<s.SOCKS5_CUSTOM_AUTH_START||e.custom_auth_method>s.SOCKS5_CUSTOM_AUTH_END)throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsCustomAuthRange,A);if(void 0===e.custom_auth_request_handler||"function"!=typeof e.custom_auth_request_handler||void 0===e.custom_auth_response_size||void 0===e.custom_auth_response_handler||"function"!=typeof e.custom_auth_response_handler)throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsCustomAuthOptions,A)}}function l(e){return e&&"string"==typeof e.host&&256>Buffer.byteLength(e.host)&&"number"==typeof e.port&&e.port>=0&&e.port<=65535}function g(e){return e&&("string"==typeof e.host||"string"==typeof e.ipaddress)&&"number"==typeof e.port&&e.port>=0&&e.port<=65535&&(4===e.type||5===e.type)}function h(e){return"number"==typeof e&&e>0}t.validateSocksClientOptions=function(e,A=["connect","bind","associate"]){if(!s.SocksCommand[e.command])throw new r.SocksClientError(s.ERRORS.InvalidSocksCommand,e);if(-1===A.indexOf(e.command))throw new r.SocksClientError(s.ERRORS.InvalidSocksCommandForOperation,e);if(!l(e.destination))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsDestination,e);if(!g(e.proxy))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsProxy,e);if(a(e.proxy,e),e.timeout&&!h(e.timeout))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsTimeout,e);if(e.existing_socket&&!(e.existing_socket instanceof n.Duplex))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsExistingSocket,e)},t.validateSocksClientChainOptions=function(e){if("connect"!==e.command)throw new r.SocksClientError(s.ERRORS.InvalidSocksCommandChain,e);if(!l(e.destination))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsDestination,e);if(!(e.proxies&&Array.isArray(e.proxies)&&e.proxies.length>=2))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsProxiesLength,e);if(e.proxies.forEach(A=>{if(!g(A))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsProxy,e);a(A,e)}),e.timeout&&!h(e.timeout))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsTimeout,e)},t.ipv4ToInt32=function(e){return new o.Address4(e).toArray().reduce((e,A)=>(e<<8)+A,0)>>>0},t.int32ToIpv4=function(e){return[e>>>24&255,e>>>16&255,e>>>8&255,255&e].join(".")},t.ipToBuffer=function(e){if(i.isIPv4(e)){let A=new o.Address4(e);return Buffer.from(A.toArray())}if(i.isIPv6(e)){let A=new o.Address6(e);return Buffer.from(A.canonicalForm().split(":").map(e=>e.padStart(4,"0")).join(""),"hex")}throw Error("Invalid IP address format")}},801900,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReceiveBuffer=void 0,t.ReceiveBuffer=class{constructor(e=4096){this.buffer=Buffer.allocUnsafe(e),this.offset=0,this.originalSize=e}get length(){return this.offset}append(e){if(!Buffer.isBuffer(e))throw Error("Attempted to append a non-buffer instance to ReceiveBuffer.");if(this.offset+e.length>=this.buffer.length){let A=this.buffer;this.buffer=Buffer.allocUnsafe(Math.max(this.buffer.length+this.originalSize,this.buffer.length+e.length)),A.copy(this.buffer)}return e.copy(this.buffer,this.offset),this.offset+=e.length}peek(e){if(e>this.offset)throw Error("Attempted to read beyond the bounds of the managed internal data.");return this.buffer.slice(0,e)}get(e){if(e>this.offset)throw Error("Attempted to read beyond the bounds of the managed internal data.");let A=Buffer.allocUnsafe(e);return this.buffer.slice(0,e).copy(A),this.buffer.copyWithin(0,e,e+this.offset-e),this.offset-=e,A}}},23052,(e,A,t)=>{"use strict";var r=e.e&&e.e.__awaiter||function(e,A,t,r){return new(t||(t=Promise))(function(s,n){function o(e){try{a(r.next(e))}catch(e){n(e)}}function i(e){try{a(r.throw(e))}catch(e){n(e)}}function a(e){var A;e.done?s(e.value):((A=e.value)instanceof t?A:new t(function(e){e(A)})).then(o,i)}a((r=r.apply(e,A||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.SocksClientError=t.SocksClient=void 0;let s=e.r(427699),n=e.r(504446),o=e.r(102372),i=e.r(81762),a=e.r(667906),l=e.r(801900),g=e.r(188286);Object.defineProperty(t,"SocksClientError",{enumerable:!0,get:function(){return g.SocksClientError}});let h=e.r(855389);class c extends s.EventEmitter{constructor(e){super(),this.options=Object.assign({},e),(0,a.validateSocksClientOptions)(e),this.setState(i.SocksClientState.Created)}static createConnection(e,A){return new Promise((t,r)=>{try{(0,a.validateSocksClientOptions)(e,["connect"])}catch(e){if("function"==typeof A)return A(e),t(e);return r(e)}let s=new c(e);s.connect(e.existing_socket),s.once("established",e=>{s.removeAllListeners(),"function"==typeof A&&A(null,e),t(e)}),s.once("error",e=>{s.removeAllListeners(),"function"==typeof A?(A(e),t(e)):r(e)})})}static createConnectionChain(e,A){return new Promise((t,s)=>r(this,void 0,void 0,function*(){try{(0,a.validateSocksClientChainOptions)(e)}catch(e){if("function"==typeof A)return A(e),t(e);return s(e)}e.randomizeChain&&(0,g.shuffleArray)(e.proxies);try{let r;for(let A=0;A<e.proxies.length;A++){let t=e.proxies[A],s=A===e.proxies.length-1?e.destination:{host:e.proxies[A+1].host||e.proxies[A+1].ipaddress,port:e.proxies[A+1].port},n=yield c.createConnection({command:"connect",proxy:t,destination:s,existing_socket:r});r=r||n.socket}"function"==typeof A&&A(null,{socket:r}),t({socket:r})}catch(e){"function"==typeof A?(A(e),t(e)):s(e)}}))}static createUDPFrame(e){let A=new o.SmartBuffer;return A.writeUInt16BE(0),A.writeUInt8(e.frameNumber||0),n.isIPv4(e.remoteHost.host)?(A.writeUInt8(i.Socks5HostType.IPv4),A.writeUInt32BE((0,a.ipv4ToInt32)(e.remoteHost.host))):n.isIPv6(e.remoteHost.host)?(A.writeUInt8(i.Socks5HostType.IPv6),A.writeBuffer((0,a.ipToBuffer)(e.remoteHost.host))):(A.writeUInt8(i.Socks5HostType.Hostname),A.writeUInt8(Buffer.byteLength(e.remoteHost.host)),A.writeString(e.remoteHost.host)),A.writeUInt16BE(e.remoteHost.port),A.writeBuffer(e.data),A.toBuffer()}static parseUDPFrame(e){let A=o.SmartBuffer.fromBuffer(e);A.readOffset=2;let t=A.readUInt8(),r=A.readUInt8();return{frameNumber:t,remoteHost:{host:r===i.Socks5HostType.IPv4?(0,a.int32ToIpv4)(A.readUInt32BE()):r===i.Socks5HostType.IPv6?h.Address6.fromByteArray(Array.from(A.readBuffer(16))).canonicalForm():A.readString(A.readUInt8()),port:A.readUInt16BE()},data:A.readBuffer()}}setState(e){this.state!==i.SocksClientState.Error&&(this.state=e)}connect(e){this.onDataReceived=e=>this.onDataReceivedHandler(e),this.onClose=()=>this.onCloseHandler(),this.onError=e=>this.onErrorHandler(e),this.onConnect=()=>this.onConnectHandler();let A=setTimeout(()=>this.onEstablishedTimeout(),this.options.timeout||i.DEFAULT_TIMEOUT);A.unref&&"function"==typeof A.unref&&A.unref(),e?this.socket=e:this.socket=new n.Socket,this.socket.once("close",this.onClose),this.socket.once("error",this.onError),this.socket.once("connect",this.onConnect),this.socket.on("data",this.onDataReceived),this.setState(i.SocksClientState.Connecting),this.receiveBuffer=new l.ReceiveBuffer,e?this.socket.emit("connect"):(this.socket.connect(this.getSocketOptions()),void 0!==this.options.set_tcp_nodelay&&null!==this.options.set_tcp_nodelay&&this.socket.setNoDelay(!!this.options.set_tcp_nodelay)),this.prependOnceListener("established",e=>{setImmediate(()=>{if(this.receiveBuffer.length>0){let A=this.receiveBuffer.get(this.receiveBuffer.length);e.socket.emit("data",A)}e.socket.resume()})})}getSocketOptions(){return Object.assign(Object.assign({},this.options.socket_options),{host:this.options.proxy.host||this.options.proxy.ipaddress,port:this.options.proxy.port})}onEstablishedTimeout(){this.state!==i.SocksClientState.Established&&this.state!==i.SocksClientState.BoundWaitingForConnection&&this.closeSocket(i.ERRORS.ProxyConnectionTimedOut)}onConnectHandler(){this.setState(i.SocksClientState.Connected),4===this.options.proxy.type?this.sendSocks4InitialHandshake():this.sendSocks5InitialHandshake(),this.setState(i.SocksClientState.SentInitialHandshake)}onDataReceivedHandler(e){this.receiveBuffer.append(e),this.processData()}processData(){for(;this.state!==i.SocksClientState.Established&&this.state!==i.SocksClientState.Error&&this.receiveBuffer.length>=this.nextRequiredPacketBufferSize;)if(this.state===i.SocksClientState.SentInitialHandshake)4===this.options.proxy.type?this.handleSocks4FinalHandshakeResponse():this.handleInitialSocks5HandshakeResponse();else if(this.state===i.SocksClientState.SentAuthentication)this.handleInitialSocks5AuthenticationHandshakeResponse();else if(this.state===i.SocksClientState.SentFinalHandshake)this.handleSocks5FinalHandshakeResponse();else if(this.state===i.SocksClientState.BoundWaitingForConnection)4===this.options.proxy.type?this.handleSocks4IncomingConnectionResponse():this.handleSocks5IncomingConnectionResponse();else{this.closeSocket(i.ERRORS.InternalError);break}}onCloseHandler(){this.closeSocket(i.ERRORS.SocketClosed)}onErrorHandler(e){this.closeSocket(e.message)}removeInternalSocketHandlers(){this.socket.pause(),this.socket.removeListener("data",this.onDataReceived),this.socket.removeListener("close",this.onClose),this.socket.removeListener("error",this.onError),this.socket.removeListener("connect",this.onConnect)}closeSocket(e){this.state!==i.SocksClientState.Error&&(this.setState(i.SocksClientState.Error),this.socket.destroy(),this.removeInternalSocketHandlers(),this.emit("error",new g.SocksClientError(e,this.options)))}sendSocks4InitialHandshake(){let e=this.options.proxy.userId||"",A=new o.SmartBuffer;A.writeUInt8(4),A.writeUInt8(i.SocksCommand[this.options.command]),A.writeUInt16BE(this.options.destination.port),n.isIPv4(this.options.destination.host)?(A.writeBuffer((0,a.ipToBuffer)(this.options.destination.host)),A.writeStringNT(e)):(A.writeUInt8(0),A.writeUInt8(0),A.writeUInt8(0),A.writeUInt8(1),A.writeStringNT(e),A.writeStringNT(this.options.destination.host)),this.nextRequiredPacketBufferSize=i.SOCKS_INCOMING_PACKET_SIZES.Socks4Response,this.socket.write(A.toBuffer())}handleSocks4FinalHandshakeResponse(){let e=this.receiveBuffer.get(8);if(e[1]!==i.Socks4Response.Granted)this.closeSocket(`${i.ERRORS.Socks4ProxyRejectedConnection} - (${i.Socks4Response[e[1]]})`);else if(i.SocksCommand[this.options.command]===i.SocksCommand.bind){let A=o.SmartBuffer.fromBuffer(e);A.readOffset=2;let t={port:A.readUInt16BE(),host:(0,a.int32ToIpv4)(A.readUInt32BE())};"0.0.0.0"===t.host&&(t.host=this.options.proxy.ipaddress),this.setState(i.SocksClientState.BoundWaitingForConnection),this.emit("bound",{remoteHost:t,socket:this.socket})}else this.setState(i.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{socket:this.socket})}handleSocks4IncomingConnectionResponse(){let e=this.receiveBuffer.get(8);if(e[1]!==i.Socks4Response.Granted)this.closeSocket(`${i.ERRORS.Socks4ProxyRejectedIncomingBoundConnection} - (${i.Socks4Response[e[1]]})`);else{let A=o.SmartBuffer.fromBuffer(e);A.readOffset=2;let t={port:A.readUInt16BE(),host:(0,a.int32ToIpv4)(A.readUInt32BE())};this.setState(i.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{remoteHost:t,socket:this.socket})}}sendSocks5InitialHandshake(){let e=new o.SmartBuffer,A=[i.Socks5Auth.NoAuth];for(let t of((this.options.proxy.userId||this.options.proxy.password)&&A.push(i.Socks5Auth.UserPass),void 0!==this.options.proxy.custom_auth_method&&A.push(this.options.proxy.custom_auth_method),e.writeUInt8(5),e.writeUInt8(A.length),A))e.writeUInt8(t);this.nextRequiredPacketBufferSize=i.SOCKS_INCOMING_PACKET_SIZES.Socks5InitialHandshakeResponse,this.socket.write(e.toBuffer()),this.setState(i.SocksClientState.SentInitialHandshake)}handleInitialSocks5HandshakeResponse(){let e=this.receiveBuffer.get(2);5!==e[0]?this.closeSocket(i.ERRORS.InvalidSocks5IntiailHandshakeSocksVersion):e[1]===i.SOCKS5_NO_ACCEPTABLE_AUTH?this.closeSocket(i.ERRORS.InvalidSocks5InitialHandshakeNoAcceptedAuthType):e[1]===i.Socks5Auth.NoAuth?(this.socks5ChosenAuthType=i.Socks5Auth.NoAuth,this.sendSocks5CommandRequest()):e[1]===i.Socks5Auth.UserPass?(this.socks5ChosenAuthType=i.Socks5Auth.UserPass,this.sendSocks5UserPassAuthentication()):e[1]===this.options.proxy.custom_auth_method?(this.socks5ChosenAuthType=this.options.proxy.custom_auth_method,this.sendSocks5CustomAuthentication()):this.closeSocket(i.ERRORS.InvalidSocks5InitialHandshakeUnknownAuthType)}sendSocks5UserPassAuthentication(){let e=this.options.proxy.userId||"",A=this.options.proxy.password||"",t=new o.SmartBuffer;t.writeUInt8(1),t.writeUInt8(Buffer.byteLength(e)),t.writeString(e),t.writeUInt8(Buffer.byteLength(A)),t.writeString(A),this.nextRequiredPacketBufferSize=i.SOCKS_INCOMING_PACKET_SIZES.Socks5UserPassAuthenticationResponse,this.socket.write(t.toBuffer()),this.setState(i.SocksClientState.SentAuthentication)}sendSocks5CustomAuthentication(){return r(this,void 0,void 0,function*(){this.nextRequiredPacketBufferSize=this.options.proxy.custom_auth_response_size,this.socket.write((yield this.options.proxy.custom_auth_request_handler())),this.setState(i.SocksClientState.SentAuthentication)})}handleSocks5CustomAuthHandshakeResponse(e){return r(this,void 0,void 0,function*(){return yield this.options.proxy.custom_auth_response_handler(e)})}handleSocks5AuthenticationNoAuthHandshakeResponse(e){return r(this,void 0,void 0,function*(){return 0===e[1]})}handleSocks5AuthenticationUserPassHandshakeResponse(e){return r(this,void 0,void 0,function*(){return 0===e[1]})}handleInitialSocks5AuthenticationHandshakeResponse(){return r(this,void 0,void 0,function*(){this.setState(i.SocksClientState.ReceivedAuthenticationResponse);let e=!1;this.socks5ChosenAuthType===i.Socks5Auth.NoAuth?e=yield this.handleSocks5AuthenticationNoAuthHandshakeResponse(this.receiveBuffer.get(2)):this.socks5ChosenAuthType===i.Socks5Auth.UserPass?e=yield this.handleSocks5AuthenticationUserPassHandshakeResponse(this.receiveBuffer.get(2)):this.socks5ChosenAuthType===this.options.proxy.custom_auth_method&&(e=yield this.handleSocks5CustomAuthHandshakeResponse(this.receiveBuffer.get(this.options.proxy.custom_auth_response_size))),e?this.sendSocks5CommandRequest():this.closeSocket(i.ERRORS.Socks5AuthenticationFailed)})}sendSocks5CommandRequest(){let e=new o.SmartBuffer;e.writeUInt8(5),e.writeUInt8(i.SocksCommand[this.options.command]),e.writeUInt8(0),n.isIPv4(this.options.destination.host)?(e.writeUInt8(i.Socks5HostType.IPv4),e.writeBuffer((0,a.ipToBuffer)(this.options.destination.host))):n.isIPv6(this.options.destination.host)?(e.writeUInt8(i.Socks5HostType.IPv6),e.writeBuffer((0,a.ipToBuffer)(this.options.destination.host))):(e.writeUInt8(i.Socks5HostType.Hostname),e.writeUInt8(this.options.destination.host.length),e.writeString(this.options.destination.host)),e.writeUInt16BE(this.options.destination.port),this.nextRequiredPacketBufferSize=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader,this.socket.write(e.toBuffer()),this.setState(i.SocksClientState.SentFinalHandshake)}handleSocks5FinalHandshakeResponse(){let e=this.receiveBuffer.peek(5);if(5!==e[0]||e[1]!==i.Socks5Response.Granted)this.closeSocket(`${i.ERRORS.InvalidSocks5FinalHandshakeRejected} - ${i.Socks5Response[e[1]]}`);else{let A,t,r=e[3];if(r===i.Socks5HostType.IPv4){let e=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4;if(this.receiveBuffer.length<e){this.nextRequiredPacketBufferSize=e;return}t=o.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(4)),"0.0.0.0"===(A={host:(0,a.int32ToIpv4)(t.readUInt32BE()),port:t.readUInt16BE()}).host&&(A.host=this.options.proxy.ipaddress)}else if(r===i.Socks5HostType.Hostname){let r=e[4],s=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(r);if(this.receiveBuffer.length<s){this.nextRequiredPacketBufferSize=s;return}A={host:(t=o.SmartBuffer.fromBuffer(this.receiveBuffer.get(s).slice(5))).readString(r),port:t.readUInt16BE()}}else if(r===i.Socks5HostType.IPv6){let e=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6;if(this.receiveBuffer.length<e){this.nextRequiredPacketBufferSize=e;return}t=o.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(4)),A={host:h.Address6.fromByteArray(Array.from(t.readBuffer(16))).canonicalForm(),port:t.readUInt16BE()}}this.setState(i.SocksClientState.ReceivedFinalResponse),i.SocksCommand[this.options.command]===i.SocksCommand.connect?(this.setState(i.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{remoteHost:A,socket:this.socket})):i.SocksCommand[this.options.command]===i.SocksCommand.bind?(this.setState(i.SocksClientState.BoundWaitingForConnection),this.nextRequiredPacketBufferSize=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader,this.emit("bound",{remoteHost:A,socket:this.socket})):i.SocksCommand[this.options.command]===i.SocksCommand.associate&&(this.setState(i.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{remoteHost:A,socket:this.socket}))}}handleSocks5IncomingConnectionResponse(){let e=this.receiveBuffer.peek(5);if(5!==e[0]||e[1]!==i.Socks5Response.Granted)this.closeSocket(`${i.ERRORS.Socks5ProxyRejectedIncomingBoundConnection} - ${i.Socks5Response[e[1]]}`);else{let A,t,r=e[3];if(r===i.Socks5HostType.IPv4){let e=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4;if(this.receiveBuffer.length<e){this.nextRequiredPacketBufferSize=e;return}t=o.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(4)),"0.0.0.0"===(A={host:(0,a.int32ToIpv4)(t.readUInt32BE()),port:t.readUInt16BE()}).host&&(A.host=this.options.proxy.ipaddress)}else if(r===i.Socks5HostType.Hostname){let r=e[4],s=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(r);if(this.receiveBuffer.length<s){this.nextRequiredPacketBufferSize=s;return}A={host:(t=o.SmartBuffer.fromBuffer(this.receiveBuffer.get(s).slice(5))).readString(r),port:t.readUInt16BE()}}else if(r===i.Socks5HostType.IPv6){let e=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6;if(this.receiveBuffer.length<e){this.nextRequiredPacketBufferSize=e;return}t=o.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(4)),A={host:h.Address6.fromByteArray(Array.from(t.readBuffer(16))).canonicalForm(),port:t.readUInt16BE()}}this.setState(i.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{remoteHost:A,socket:this.socket})}}get socksClientOptions(){return Object.assign({},this.options)}}t.SocksClient=c},771193,(e,A,t)=>{"use strict";var r=e.e&&e.e.__createBinding||(Object.create?function(e,A,t,r){void 0===r&&(r=t);var s=Object.getOwnPropertyDescriptor(A,t);(!s||("get"in s?!A.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,s)}:function(e,A,t,r){void 0===r&&(r=t),e[r]=A[t]}),s=e.e&&e.e.__exportStar||function(e,A){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(A,t)||r(A,e,t)};Object.defineProperty(t,"__esModule",{value:!0}),s(e.r(23052),t)},425842,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.socksConnector=n,t.socksDispatcher=function(e,A={}){let{connect:t,...r}=A;return new s.Agent({...r,connect:n(e,t)})};let r=e.r(771193),s=e.r(724055);function n(e,A={}){let t=Array.isArray(e)?e:[e],{timeout:o=1e4}=A,i=(0,s.buildConnector)(A);return async(e,A)=>{let{protocol:s,hostname:n,port:a,httpSocket:l}=e;for(let e=0;e<t.length;e++){let i=t[e+1],g=e===t.length-1?{host:n,port:a?Number.parseInt(a):"http:"===s?80:443}:{port:i.port,host:i.host??i.ipaddress},h={command:"connect",proxy:t[e],timeout:o,destination:g,existing_socket:l};try{l=(await r.SocksClient.createConnection(h)).socket}catch(e){return A(e,null)}}return l&&"https:"!==s?A(null,l.setNoDelay()):i({...e,httpSocket:l},A)}}},621213,(e,A,t)=>{"use strict";var r,s,n,o,i,a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,h=Object.prototype.hasOwnProperty,c={},E={Headers:()=>F,RequestError:()=>f,Response:()=>O,Session:()=>G,Transport:()=>x,WebSocket:()=>eF,createSession:()=>eC,createTransport:()=>eB,default:()=>eM,fetch:()=>eI,get:()=>eD,getOperatingSystems:()=>ey,getProfiles:()=>ep,post:()=>eS,request:()=>ef,websocket:()=>ek,withSession:()=>ed};for(var Q in E)a(c,Q,{get:E[Q],enumerable:!0});A.exports=((e,A,t,r)=>{if(A&&"object"==typeof A||"function"==typeof A)for(let s of g(A))h.call(e,s)||s===t||a(e,s,{get:()=>A[s],enumerable:!(r=l(A,s))||r.enumerable});return e})(a({},"__esModule",{value:!0}),c);var u=e.r(254799),I=e.r(921517),B=e.r(362562),C=e.r(688947),d=e.r(363890),f=class extends TypeError{constructor(e){super(e),this.name="RequestError"}},p={},y=p.url?(0,B.createRequire)(p.url):(0,B.createRequire)("/ROOT/node_modules/wreq-js/dist/wreq-js.cjs");r=function(){let e=process.platform,A=process.arch,t=function(){let e=process.env.LIBC??process.env.npm_config_libc;if(e)return e.toLowerCase().includes("musl")?"musl":"gnu";try{let e=process.report?.getReport?.();if(e?.header?.glibcVersionRuntime)return"gnu";return"musl"}catch{return"gnu"}}(),r={darwin:{x64:"darwin-x64",arm64:"darwin-arm64"},linux:{x64:{gnu:"linux-x64-gnu",musl:"linux-x64-musl"},arm64:"linux-arm64-gnu"},win32:{x64:"win32-x64-msvc"}}[e]?.[A],s="string"==typeof r?r:r?.[t??"gnu"];if(!s)throw Error(`Unsupported platform: ${e}-${A}${t?`-${t}`:""}. Supported platforms: darwin-x64, darwin-arm64, linux-x64-gnu, linux-x64-musl, linux-arm64-gnu, win32-x64-msvc`);let n=`wreq-js.${s}.node`;try{return y(`../rust/${n}`)}catch{try{return y("../rust/wreq-js.node")}catch{throw Error(`Failed to load native module for ${e}-${A}. Tried: ../rust/${n} and ../rust/wreq-js.node. Make sure the package is installed correctly and the native module is built for your platform.`)}}}();var D="function"==typeof FinalizationRegistry?new FinalizationRegistry(e=>{r.websocketClose(e).catch(()=>void 0)}):void 0,S="function"==typeof FinalizationRegistry?new FinalizationRegistry(e=>{if(!e.released){e.released=!0;try{r.cancelBody(e.id)}catch{}}}):void 0,w="chrome_142",m="macos",N=["windows","macos","linux","android","ios"],R=new TextDecoder("utf-8"),b=0;function U(e){if("object"!=typeof e||null===e)return!1;let A=Object.getPrototypeOf(e);return A===Object.prototype||null===A}var F=class e{store=new Map;constructor(e){e&&this.applyInit(e)}applyInit(A){if(A instanceof e){for(let[e,t]of A)this.append(e,t);return}if(Array.isArray(A)||A&&"function"==typeof A[Symbol.iterator]){for(let e of A){if(!e)continue;let[A,t]=e;this.append(A,t)}return}if(U(A))for(let[e,t]of Object.entries(A))null!=t&&this.set(e,String(t))}normalizeName(e){if("string"!=typeof e)throw TypeError("Header name must be a string");let A=e.trim();if(!A)throw TypeError("Header name must not be empty");return{key:A.toLowerCase(),display:A}}assertValue(e){if(null==e)throw TypeError("Header value must not be null or undefined");return String(e)}append(e,A){let t=this.normalizeName(e),r=this.store.get(t.key),s=this.assertValue(A);r?r.values.push(s):this.store.set(t.key,{name:t.display,values:[s]})}set(e,A){let t=this.normalizeName(e),r=this.assertValue(A);this.store.set(t.key,{name:t.display,values:[r]})}get(e){let A=this.normalizeName(e),t=this.store.get(A.key);return t?t.values.join(", "):null}has(e){let A=this.normalizeName(e);return this.store.has(A.key)}delete(e){let A=this.normalizeName(e);this.store.delete(A.key)}entries(){return this[Symbol.iterator]()}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}forEach(e,A){for(let[t,r]of this)e.call(A,r,t,this)}[Symbol.iterator](){return function*(e){for(let A of e.values())yield[A.name,A.values.join(", ")]}(this.store)}toObject(){let e={};for(let[A,t]of this)e[A]=t;return e}toTuples(){let e=[];for(let[A,t]of this)e.push([A,t]);return e}};function k(e){return new F(e).toTuples()}function M(e,A){if(!e)return!1;let t=A.toLowerCase();for(let[A]of e)if(A.toLowerCase()===t)return!0;return!1}function T(e){if(e&&M(k(e),"Sec-WebSocket-Protocol"))throw new f("Do not set `Sec-WebSocket-Protocol` header manually; use the `protocols` option instead.")}function L(e){if(void 0!==e)return"string"==typeof e?[e]:[...e]}function v(e){return{status:e.status,headers:e.headers.map(([e,A])=>[e,A]),bodyHandle:e.bodyHandle,bodyBytes:e.bodyBytes,contentLength:e.contentLength,cookies:e.cookies.map(([e,A])=>[e,A]),url:e.url}}function H(e){if(!e.released){e.released=!0;try{r.cancelBody(e.id)}catch{}S?.unregister(e)}}function Y(e){let A=new d.ReadableStream({async pull(A){try{let t=await r.readBodyChunk(e.id);if(null===t){H(e),A.close();return}A.enqueue(t)}catch(t){H(e),A.error(t)}},cancel(){H(e)}});return S?.register(A,e,e),A}var O=class e{status;ok;contentLength;url;type="basic";bodyUsed=!1;payload;requestUrl;redirectedMemo;headersInit;headersInstance;cookiesInit;cookiesRecord;inlineBody;bodySource;bodyStream;nativeHandleAvailable;nativeHandle;constructor(e,A,t){this.payload=e,this.requestUrl=A,this.status=this.payload.status,this.ok=this.status>=200&&this.status<300,this.headersInit=this.payload.headers,this.headersInstance=null,this.url=this.payload.url,this.cookiesInit=this.payload.cookies,this.cookiesRecord=null,this.contentLength=this.payload.contentLength??null,this.inlineBody=this.payload.bodyBytes??null,this.nativeHandle=null,void 0!==t?(this.bodySource=t,this.nativeHandleAvailable=!1):null!==this.inlineBody?(this.bodySource=null,this.nativeHandleAvailable=!1):null!==this.payload.bodyHandle?(this.bodySource=null,this.nativeHandleAvailable=!0,this.nativeHandle={id:this.payload.bodyHandle,released:!1},S?.register(this,this.nativeHandle,this.nativeHandle)):(this.bodySource=null,this.nativeHandleAvailable=!1),this.bodyStream=void 0}get redirected(){if(void 0!==this.redirectedMemo)return this.redirectedMemo;if(this.url===this.requestUrl)return this.redirectedMemo=!1,!1;let e=function(e){try{return new URL(e).toString()}catch{return null}}(this.requestUrl);return this.redirectedMemo=!e||this.url!==e,this.redirectedMemo}get statusText(){return I.STATUS_CODES[this.status]??""}get headers(){return this.headersInstance||(this.headersInstance=new F(this.headersInit)),this.headersInstance}get cookies(){if(!this.cookiesRecord){let e=Object.create(null);for(let[A,t]of this.cookiesInit){let r=e[A];void 0===r?e[A]=t:Array.isArray(r)?r.push(t):e[A]=[r,t]}this.cookiesRecord=e}return this.cookiesRecord}get body(){var e,A;let t,r;if(this.inlineBody&&null===this.bodySource){let e=this.inlineBody;this.inlineBody=null,this.bodySource=new d.ReadableStream({start(A){A.enqueue(e),A.close()}})}if(null===this.inlineBody&&null===this.payload.bodyHandle&&null===this.bodySource)return null;if(null===this.bodySource&&this.nativeHandleAvailable&&null!==this.payload.bodyHandle){this.nativeHandle&&S?.unregister(this.nativeHandle);let e=this.nativeHandle??{id:this.payload.bodyHandle,released:!1};this.nativeHandle=e,this.bodySource=Y(e),this.nativeHandleAvailable=!1}return null===this.bodySource?null:(void 0===this.bodyStream&&(this.bodyStream=(e=this.bodySource,A=()=>{this.bodyUsed=!0},t=!1,r=null,new d.ReadableStream({async pull(s){t||(t=!0,A()),r||(r=e.getReader());try{let{done:e,value:A}=await r.read();if(e)return void s.close();s.enqueue(A)}catch(e){s.error(e)}},cancel:A=>r?r.cancel(A):e.cancel(A)}))),this.bodyStream)}async json(){return JSON.parse(await this.text())}async arrayBuffer(){let e=await this.consumeBody(),{buffer:A,byteOffset:t,byteLength:r}=e;if(A instanceof ArrayBuffer)return 0===t&&r===A.byteLength?A:A.slice(t,t+r);let s=new Uint8Array(r);return s.set(e),s.buffer}async text(){let e=await this.consumeBody();return R.decode(e)}async blob(){let e=await this.consumeBody(),A=this.headers.get("content-type")??"";return new Blob([e],A?{type:A}:void 0)}async formData(){let e=await this.consumeBody(),A=this.headers.get("content-type");return new globalThis.Response(e,A?{headers:{"content-type":A}}:void 0).formData()}readable(){this.assertBodyAvailable(),this.bodyUsed=!0;let e=this.body;return null===e?C.Readable.from([]):C.Readable.fromWeb(e)}clone(){if(this.bodyUsed)throw TypeError("Cannot clone a Response whose body is already used");if(this.nativeHandleAvailable&&null!==this.payload.bodyHandle){this.nativeHandle&&S?.unregister(this.nativeHandle);let e=this.nativeHandle??{id:this.payload.bodyHandle,released:!1};this.nativeHandle=e,this.bodySource=Y(e),this.nativeHandleAvailable=!1}if(null===this.bodySource)return new e(v(this.payload),this.requestUrl,null);let[A,t]=this.bodySource.tee();return this.bodySource=A,this.bodyStream=void 0,new e(v(this.payload),this.requestUrl,t)}assertBodyAvailable(){if(this.bodyUsed)throw TypeError("Response body is already used")}async consumeBody(){if(this.assertBodyAvailable(),this.bodyUsed=!0,this.inlineBody){let e=this.inlineBody;return this.inlineBody=null,e}if(this.nativeHandleAvailable&&null!==this.payload.bodyHandle){this.nativeHandleAvailable=!1;try{return await r.readBodyAll(this.payload.bodyHandle)}catch(e){if(String(e).includes("Body handle")&&String(e).includes("not found"))return Buffer.alloc(0);throw e}finally{var e;this.nativeHandle&&((e=this.nativeHandle).released||(e.released=!0,S?.unregister(e)))}}let A=this.body;if(!A)return Buffer.alloc(0);let t=A.getReader(),s=[];for(;;){let{done:e,value:A}=await t.read();if(e)break;A&&A.byteLength>0&&(Buffer.isBuffer(A)?s.push(A):s.push(Buffer.from(A.buffer,A.byteOffset,A.byteLength)))}return 0===s.length?Buffer.alloc(0):Buffer.concat(s)}},x=class{id;disposed=!1;constructor(e){this.id=e}get closed(){return this.disposed}async close(){if(!this.disposed){this.disposed=!0;try{r.dropTransport(this.id)}catch(e){throw new f(String(e))}}}},G=class{id;disposed=!1;defaults;constructor(e,A){this.id=e,this.defaults=A}get closed(){return this.disposed}ensureActive(){if(this.disposed)throw new f("Session has been closed")}getDefaults(){let e={...this.defaults};return this.defaults.defaultHeaders&&(e.defaultHeaders=[...this.defaults.defaultHeaders]),e}_defaultsRef(){return this.defaults}async fetch(e,A){return this.ensureActive(),eI(e,A?{...A,session:this}:{session:this})}async clearCookies(){this.ensureActive();try{r.clearSession(this.id)}catch(e){throw new f(String(e))}}getCookies(e){this.ensureActive();try{return r.getCookies(this.id,String(e))}catch(e){throw new f(String(e))}}setCookie(e,A,t){this.ensureActive();try{r.setCookie(this.id,e,A,String(t))}catch(e){throw new f(String(e))}}async websocket(e,A){this.ensureActive();let t=function(e,A){if("string"==typeof e||e instanceof URL){let t=eR(A);return{url:ew(e),options:t,legacyCallbacks:eb(A)}}let t=eR(e);return{url:ew(e.url),options:t,legacyCallbacks:eb(e)}}(e,A);em(t.options.protocols),T(t.options.headers);let s=L(t.options.protocols),n=this.defaults.transportId;if(!n)throw new f("Session has no transport. Create the session with browser/os options or pass a transport to use session.websocket().");return eF._connectWithInit({_internal:!0,url:t.url,options:t.options,openDispatchMode:"deferred",connect:e=>r.websocketConnectSession({url:t.url,sessionId:this.id,transportId:n,headers:k(t.options.headers??{}),...s&&s.length>0&&{protocols:s},onMessage:e.onMessage,onClose:e.onClose,onError:e.onError}),legacyCallbacks:t.legacyCallbacks})}async close(){if(this.disposed)return;this.disposed=!0;let e=this.defaults.transportId,A=this.defaults.ownsTransport;try{r.dropSession(this.id)}catch(t){if(!A||!e)throw new f(String(t));try{r.dropTransport(e)}catch{}throw new f(String(t))}if(A&&e)try{r.dropTransport(e)}catch(e){throw new f(String(e))}}};function V(e){let A="string"==typeof e?e:"The operation was aborted";if("u">typeof DOMException&&e instanceof DOMException)return"AbortError"===e.name?e:new DOMException(e.message||A,"AbortError");if(e instanceof Error){let A=Error(e.message);return A.name="AbortError",A.cause=e,A}if("u">typeof DOMException)return new DOMException(A,"AbortError");let t=Error(A);return t.name="AbortError",t}var J=Math.trunc(Number(process.hrtime.bigint()%BigInt(0x1000000000000-1)))+1;function _(){return(J+=1)>=0x1000000000000&&(J=1),J}function P(e){if(e instanceof URL)return e.href;if(0===e.length)throw new f("URL is required");if(e.charCodeAt(0)>32&&e.charCodeAt(e.length-1)>32)return e;let A=e.trim();if(0===A.length)throw new f("URL is required");return A}async function W(e,A){if(!(e&&"object"==typeof e&&("u">typeof Request&&e instanceof Request||"string"==typeof e.url&&"string"==typeof e.method&&"function"==typeof e.arrayBuffer&&"string"==typeof e.redirect)))return{url:P(e),init:A??{}};let t=A?{...A}:{};if(void 0===t.method&&(t.method=e.method),void 0===t.headers&&(t.headers=e.headers),void 0===t.redirect&&("follow"===e.redirect||"manual"===e.redirect||"error"===e.redirect)&&(t.redirect=e.redirect),void 0===t.signal&&(t.signal=e.signal),void 0===t.body&&null!==e.body){if(e.bodyUsed)throw TypeError("Request body is already used");t.body=Buffer.from(await e.arrayBuffer())}return{url:P(e.url),init:t}}async function q(e){if(null==e)return{};if("string"==typeof e)return{body:Buffer.from(e,"utf8")};if(Buffer.isBuffer(e))return{body:e};if(e instanceof URLSearchParams)return{body:Buffer.from(e.toString(),"utf8"),contentType:"application/x-www-form-urlencoded;charset=UTF-8"};if(e instanceof ArrayBuffer)return{body:Buffer.from(e)};if(ArrayBuffer.isView(e))return{body:Buffer.from(e.buffer,e.byteOffset,e.byteLength)};if("u">typeof Blob&&e instanceof Blob)return{body:Buffer.from(await e.arrayBuffer()),...e.type?{contentType:e.type}:{}};if("u">typeof FormData&&e instanceof FormData){let A=new globalThis.Response(e),t=A.headers.get("content-type")??void 0;return{body:Buffer.from(await A.arrayBuffer()),...t?{contentType:t}:{}}}throw TypeError("Unsupported body type; expected string, Buffer, ArrayBuffer, ArrayBufferView, URLSearchParams, Blob, or FormData")}function Z(e){if(void 0!==e){if("string"!=typeof e||0===e.trim().length)throw new f("Browser profile must not be empty");if(!(n||(n=new Set(ep())),n).has(e))throw new f(`Invalid browser profile: ${e}. Available profiles: ${ep().join(", ")}`)}}function j(e){if(void 0!==e){if("string"!=typeof e||0===e.trim().length)throw new f("Operating system must not be empty");if(!(i||(i=new Set(ey())),i).has(e))throw new f(`Invalid operating system: ${e}. Available options: ${ey().join(", ")}`)}}function X(e){if(void 0!==e){if("number"!=typeof e||!Number.isFinite(e))throw new f("Timeout must be a finite number");if(e<0)throw new f("Timeout must be 0 (no timeout) or a positive number")}}function z(e,A){if("number"!=typeof e||!Number.isFinite(e))throw new f(`${A} must be a finite number`);if(e<=0)throw new f(`${A} must be greater than 0`)}function K(e,A){if("number"!=typeof e||!Number.isFinite(e)||!Number.isInteger(e))throw new f(`${A} must be an integer`);if(e<0)throw new f(`${A} must be greater than or equal to 0`)}function $(e,A){if("number"!=typeof e||!Number.isFinite(e)||!Number.isInteger(e))throw new f(`${A} must be an integer`);if(e<=0)throw new f(`${A} must be greater than 0`)}function ee(e,A,t,r){if(K(e,r),e<A||e>t)throw new f(`${r} must be between ${A} and ${t}`)}var eA=new Set(["HTTP1","HTTP2","HTTP3"]),et=new Set(["HTTP1","HTTP2","HTTP3"]),er=new Set(["zlib","brotli","zstd"]),es=new Set(["HeaderTableSize","EnablePush","MaxConcurrentStreams","InitialWindowSize","MaxFrameSize","MaxHeaderListSize","EnableConnectProtocol","NoRfc7540Priorities"]),en=new Set(["Method","Scheme","Authority","Path","Protocol"]),eo=new Set([1,2,3,4,5,6,8,9]),ei=new Map([["1.0","1.0"],["1.1","1.1"],["1.2","1.2"],["1.3","1.3"],["tls1.0","1.0"],["tls1.1","1.1"],["tls1.2","1.2"],["tls1.3","1.3"]]);function ea(e){for(let A in e)return!0;return!1}function el(e,A,t){if(void 0!==e){if(!Array.isArray(e))throw new f(`${A} must be an array`);for(let r of e)if(!t.has(r))throw new f(`${A} values must be one of: HTTP1, HTTP2, HTTP3`);return[...e]}}function eg(e,A){if(void 0===e)return;if("string"!=typeof e)throw new f(`${A} must be a string`);let t=ei.get(e.trim().toLowerCase());if(!t)throw new f(`${A} must be one of: 1.0, 1.1, 1.2, 1.3`);return t}function eh(e,A){if(!U(e))throw new f(`${A} must be an object`);ee(e.dependencyId,0,0x7fffffff,`${A}.dependencyId`),ee(e.weight,0,255,`${A}.weight`);let t={dependencyId:e.dependencyId,weight:e.weight};return void 0!==e.exclusive&&(t.exclusive=e.exclusive),t}function ec(e,A){let t=function(e,A){if(void 0===e)return;if(!U(e))throw new f("emulation must be an object");let t={},r=function(e){if(void 0===e)return;let A={},t=el(e.alpnProtocols,"emulation.tlsOptions.alpnProtocols",eA);void 0!==t&&(A.alpnProtocols=t);let r=el(e.alpsProtocols,"emulation.tlsOptions.alpsProtocols",et);void 0!==r&&(A.alpsProtocols=r);let s=eg(e.minTlsVersion,"emulation.tlsOptions.minTlsVersion");void 0!==s&&(A.minTlsVersion=s);let n=eg(e.maxTlsVersion,"emulation.tlsOptions.maxTlsVersion");if(void 0!==n&&(A.maxTlsVersion=n),void 0!==e.alpsUseNewCodepoint&&(A.alpsUseNewCodepoint=e.alpsUseNewCodepoint),void 0!==e.sessionTicket&&(A.sessionTicket=e.sessionTicket),void 0!==e.preSharedKey&&(A.preSharedKey=e.preSharedKey),void 0!==e.enableEchGrease&&(A.enableEchGrease=e.enableEchGrease),void 0!==e.permuteExtensions&&(A.permuteExtensions=e.permuteExtensions),void 0!==e.greaseEnabled&&(A.greaseEnabled=e.greaseEnabled),void 0!==e.enableOcspStapling&&(A.enableOcspStapling=e.enableOcspStapling),void 0!==e.enableSignedCertTimestamps&&(A.enableSignedCertTimestamps=e.enableSignedCertTimestamps),void 0!==e.pskSkipSessionTicket&&(A.pskSkipSessionTicket=e.pskSkipSessionTicket),void 0!==e.pskDheKe&&(A.pskDheKe=e.pskDheKe),void 0!==e.renegotiation&&(A.renegotiation=e.renegotiation),void 0!==e.aesHwOverride&&(A.aesHwOverride=e.aesHwOverride),void 0!==e.preserveTls13CipherList&&(A.preserveTls13CipherList=e.preserveTls13CipherList),void 0!==e.randomAesHwOverride&&(A.randomAesHwOverride=e.randomAesHwOverride),void 0!==e.delegatedCredentials&&(A.delegatedCredentials=e.delegatedCredentials),void 0!==e.curvesList&&(A.curvesList=e.curvesList),void 0!==e.cipherList&&(A.cipherList=e.cipherList),void 0!==e.sigalgsList&&(A.sigalgsList=e.sigalgsList),void 0!==e.recordSizeLimit&&(ee(e.recordSizeLimit,0,65535,"emulation.tlsOptions.recordSizeLimit"),A.recordSizeLimit=e.recordSizeLimit),void 0!==e.keySharesLimit&&(ee(e.keySharesLimit,0,255,"emulation.tlsOptions.keySharesLimit"),A.keySharesLimit=e.keySharesLimit),void 0!==e.certificateCompressionAlgorithms){if(!Array.isArray(e.certificateCompressionAlgorithms))throw new f("emulation.tlsOptions.certificateCompressionAlgorithms must be an array");let t=[],r=new Set;for(let A of e.certificateCompressionAlgorithms){if(!er.has(A))throw new f("emulation.tlsOptions.certificateCompressionAlgorithms values must be one of: zlib, brotli, zstd");if(r.has(A))throw new f(`Duplicate emulation.tlsOptions.certificateCompressionAlgorithms entry: ${A}`);r.add(A),t.push(A)}A.certificateCompressionAlgorithms=t}if(void 0!==e.extensionPermutation){if(!Array.isArray(e.extensionPermutation))throw new f("emulation.tlsOptions.extensionPermutation must be an array");let t=[],r=new Set;for(let A of e.extensionPermutation){if(ee(A,0,65535,"emulation.tlsOptions.extensionPermutation"),r.has(A))throw new f(`Duplicate emulation.tlsOptions.extensionPermutation entry: ${A}`);r.add(A),t.push(A)}A.extensionPermutation=t}return ea(A)?A:void 0}(e.tlsOptions);void 0!==r&&(t.tlsOptions=r);let s=function(e){if(void 0===e)return;let A={};if(void 0!==e.http09Responses&&(A.http09Responses=e.http09Responses),void 0!==e.writev&&(A.writev=e.writev),void 0!==e.ignoreInvalidHeadersInResponses&&(A.ignoreInvalidHeadersInResponses=e.ignoreInvalidHeadersInResponses),void 0!==e.allowSpacesAfterHeaderNameInResponses&&(A.allowSpacesAfterHeaderNameInResponses=e.allowSpacesAfterHeaderNameInResponses),void 0!==e.allowObsoleteMultilineHeadersInResponses&&(A.allowObsoleteMultilineHeadersInResponses=e.allowObsoleteMultilineHeadersInResponses),void 0!==e.maxHeaders&&(K(e.maxHeaders,"emulation.http1Options.maxHeaders"),A.maxHeaders=e.maxHeaders),void 0!==e.readBufExactSize&&(K(e.readBufExactSize,"emulation.http1Options.readBufExactSize"),A.readBufExactSize=e.readBufExactSize),void 0!==e.maxBufSize){if(K(e.maxBufSize,"emulation.http1Options.maxBufSize"),e.maxBufSize<8192)throw new f("emulation.http1Options.maxBufSize must be greater than or equal to 8192");A.maxBufSize=e.maxBufSize}if(void 0!==A.readBufExactSize&&void 0!==A.maxBufSize)throw new f("emulation.http1Options.readBufExactSize and maxBufSize cannot both be set");return ea(A)?A:void 0}(e.http1Options);void 0!==s&&(t.http1Options=s);let n=function(e){if(void 0===e)return;let A={};if(void 0!==e.adaptiveWindow&&(A.adaptiveWindow=e.adaptiveWindow),void 0!==e.keepAliveWhileIdle&&(A.keepAliveWhileIdle=e.keepAliveWhileIdle),void 0!==e.enablePush&&(A.enablePush=e.enablePush),void 0!==e.enableConnectProtocol&&(A.enableConnectProtocol=e.enableConnectProtocol),void 0!==e.noRfc7540Priorities&&(A.noRfc7540Priorities=e.noRfc7540Priorities),void 0!==e.initialStreamId&&(K(e.initialStreamId,"emulation.http2Options.initialStreamId"),A.initialStreamId=e.initialStreamId),void 0!==e.initialConnectionWindowSize&&(K(e.initialConnectionWindowSize,"emulation.http2Options.initialConnectionWindowSize"),A.initialConnectionWindowSize=e.initialConnectionWindowSize),void 0!==e.initialWindowSize&&(K(e.initialWindowSize,"emulation.http2Options.initialWindowSize"),A.initialWindowSize=e.initialWindowSize),void 0!==e.initialMaxSendStreams&&(K(e.initialMaxSendStreams,"emulation.http2Options.initialMaxSendStreams"),A.initialMaxSendStreams=e.initialMaxSendStreams),void 0!==e.maxFrameSize&&(K(e.maxFrameSize,"emulation.http2Options.maxFrameSize"),A.maxFrameSize=e.maxFrameSize),void 0!==e.keepAliveInterval&&(K(e.keepAliveInterval,"emulation.http2Options.keepAliveInterval"),A.keepAliveInterval=e.keepAliveInterval),void 0!==e.keepAliveTimeout&&(K(e.keepAliveTimeout,"emulation.http2Options.keepAliveTimeout"),A.keepAliveTimeout=e.keepAliveTimeout),void 0!==e.maxConcurrentResetStreams&&(K(e.maxConcurrentResetStreams,"emulation.http2Options.maxConcurrentResetStreams"),A.maxConcurrentResetStreams=e.maxConcurrentResetStreams),void 0!==e.maxSendBufferSize&&(K(e.maxSendBufferSize,"emulation.http2Options.maxSendBufferSize"),A.maxSendBufferSize=e.maxSendBufferSize),void 0!==e.maxConcurrentStreams&&(K(e.maxConcurrentStreams,"emulation.http2Options.maxConcurrentStreams"),A.maxConcurrentStreams=e.maxConcurrentStreams),void 0!==e.maxHeaderListSize&&(K(e.maxHeaderListSize,"emulation.http2Options.maxHeaderListSize"),A.maxHeaderListSize=e.maxHeaderListSize),void 0!==e.maxPendingAcceptResetStreams&&(K(e.maxPendingAcceptResetStreams,"emulation.http2Options.maxPendingAcceptResetStreams"),A.maxPendingAcceptResetStreams=e.maxPendingAcceptResetStreams),void 0!==e.headerTableSize&&(K(e.headerTableSize,"emulation.http2Options.headerTableSize"),A.headerTableSize=e.headerTableSize),void 0!==e.settingsOrder){if(!Array.isArray(e.settingsOrder))throw new f("emulation.http2Options.settingsOrder must be an array");let t=[],r=new Set;for(let A of e.settingsOrder){if(!es.has(A))throw new f("emulation.http2Options.settingsOrder contains an unsupported setting id");if(r.has(A))throw new f(`Duplicate emulation.http2Options.settingsOrder entry: ${A}`);r.add(A),t.push(A)}A.settingsOrder=t}if(void 0!==e.headersPseudoOrder){if(!Array.isArray(e.headersPseudoOrder))throw new f("emulation.http2Options.headersPseudoOrder must be an array");let t=[],r=new Set;for(let A of e.headersPseudoOrder){if(!en.has(A))throw new f("emulation.http2Options.headersPseudoOrder contains an unsupported pseudo-header id");if(r.has(A))throw new f(`Duplicate emulation.http2Options.headersPseudoOrder entry: ${A}`);r.add(A),t.push(A)}A.headersPseudoOrder=t}if(void 0!==e.headersStreamDependency&&(A.headersStreamDependency=eh(e.headersStreamDependency,"emulation.http2Options.headersStreamDependency")),void 0!==e.priorities){if(!Array.isArray(e.priorities))throw new f("emulation.http2Options.priorities must be an array");let t=[],r=new Set;for(let[A,s]of e.priorities.entries()){if(!U(s))throw new f(`emulation.http2Options.priorities[${A}] must be an object`);if($(s.streamId,`emulation.http2Options.priorities[${A}].streamId`),r.has(s.streamId))throw new f(`Duplicate emulation.http2Options.priorities streamId: ${s.streamId}`);r.add(s.streamId),t.push({streamId:s.streamId,dependency:eh(s.dependency,`emulation.http2Options.priorities[${A}].dependency`)})}A.priorities=t}if(void 0!==e.experimentalSettings){if(!Array.isArray(e.experimentalSettings))throw new f("emulation.http2Options.experimentalSettings must be an array");let t=[],r=new Set;for(let[A,s]of e.experimentalSettings.entries()){if(!U(s))throw new f(`emulation.http2Options.experimentalSettings[${A}] must be an object`);if(ee(s.id,1,15,`emulation.http2Options.experimentalSettings[${A}].id`),eo.has(s.id))throw new f(`emulation.http2Options.experimentalSettings[${A}].id must not be a standard HTTP/2 setting id`);if(r.has(s.id))throw new f(`Duplicate emulation.http2Options.experimentalSettings id: ${s.id}`);r.add(s.id),ee(s.value,0,0xffffffff,`emulation.http2Options.experimentalSettings[${A}].value`),t.push({id:s.id,value:s.value})}A.experimentalSettings=t}return ea(A)?A:void 0}(e.http2Options);if(void 0!==n&&(t.http2Options=n),void 0!==e.headers){let A=k(e.headers);A.length>0&&(t.headers=A)}let o=function(e){if(void 0===e)return;if(!Array.isArray(e))throw new f("emulation.origHeaders must be an array of strings");let A=[],t=new Set;for(let r of e){if("string"!=typeof r||0===r.trim().length)throw new f("emulation.origHeaders entries must be non-empty strings");let e=r.trim(),s=e.toLowerCase();if(t.has(s))throw new f(`Duplicate emulation.origHeaders entry: ${e}`);t.add(s),A.push(e)}return A.length>0?A:void 0}(e.origHeaders);if(void 0!==o&&(t.origHeaders=o),!A&&!ea(t))throw new f("Standalone custom emulation requires at least one of tlsOptions, http1Options, http2Options, headers, or origHeaders");return ea(t)?t:void 0}(e,A);return t?JSON.stringify(t):void 0}function eE(e,A,t){if(void 0!==e){Z(e),void 0!==A&&j(A);let r=ec(t,!0);return{kind:"preset",browser:e,os:A??m,...void 0!==r&&{emulationJson:r}}}if(void 0!==A){j(A);let e=ec(t,!0);return{kind:"preset",browser:w,os:A,...void 0!==e&&{emulationJson:e}}}if(void 0!==t){let e=ec(t,!1);if(void 0===e)throw new f("Standalone custom emulation requires at least one of tlsOptions, http1Options, http2Options, headers, or origHeaders");return{kind:"custom",emulationJson:e}}return{kind:"preset",browser:w,os:m}}function eQ(e,A){if("custom"===A.kind){e.emulationJson=A.emulationJson;return}e.browser=A.browser,e.os=A.os,void 0!==A.emulationJson&&(e.emulationJson=A.emulationJson)}async function eu(e,A,t){let s;if(!t){let t,s=_();try{t=await r.request(e,s,!1)}catch(e){if(e instanceof f)throw e;throw new f(String(e))}return new O(t,A)}let n=_(),o=function(e,A){let t;if(!e)return null;if(e.aborted)throw A(),V(e.reason);return{promise:new Promise((r,s)=>{t=()=>{A(),s(V(e.reason))},e.addEventListener("abort",t,{once:!0})}),cleanup:()=>{t&&(e.removeEventListener("abort",t),t=void 0)}}}(t,()=>{try{r.cancelRequest(n)}catch{}}),i=Promise.race([r.request(e,n,!0),o.promise]);try{s=await i}catch(e){if(e&&"string"==typeof e.name&&"AbortError"===e.name||e instanceof f)throw e;throw new f(String(e))}finally{o.cleanup()}return new O(s,A)}async function eI(e,A){let t=await W(e,A),r=t.url,s=t.init,n=function(e){let A=e.cookieMode??"ephemeral",t=e.session,r="string"==typeof e.sessionId?e.sessionId.trim():void 0;if(t&&r)throw new f("Provide either `session` or `sessionId`, not both.");if(t){if(!(t instanceof G))throw new f("`session` must be created via createSession()");if(t.closed)throw new f("Session has been closed");return{sessionId:t.id,cookieMode:"session",dropAfterRequest:!1,defaults:t._defaultsRef()}}if(r){if(!r)throw new f("sessionId must not be empty");if("ephemeral"===A)throw new f("cookieMode 'ephemeral' cannot be combined with sessionId");return{sessionId:r,cookieMode:"session",dropAfterRequest:!1}}if("session"===A)throw new f("cookieMode 'session' requires a session or sessionId");return{sessionId:`_e${++b}`,cookieMode:"ephemeral",dropAfterRequest:!0}}(s),o=n.defaults;var i=s.redirect;if(void 0!==i&&"follow"!==i&&"manual"!==i&&"error"!==i)throw new f(`Redirect mode '${i}' is not supported`);void 0!==s.timeout&&X(s.timeout);let a=function(e){if(void 0===e||0===e.length)return"GET";switch(e){case"GET":case"POST":case"PUT":case"DELETE":case"PATCH":case"HEAD":case"OPTIONS":return e}let A=e.trim().toUpperCase();return A.length>0?A:"GET"}(s.method),l=await q(s.body??null),g=l.body;if(void 0!==g&&("GET"===a||"HEAD"===a))throw new f(`Request with ${a} method cannot have a body`);let h=function(e,A){if(!e)return void 0===A?void 0:k(A);if(void 0===A)return e;let t=k(A);if(0===t.length)return e;let r=new Set;for(let e of t)r.add(e[0].toLowerCase());let s=[];for(let A of e)r.has(A[0].toLowerCase())||s.push(A);for(let e of t)s.push(e);return s}(o?.defaultHeaders,s.headers);l.contentType&&!M(h,"content-type")&&(h||(h=[]),h.push(["Content-Type",l.contentType]));let c=function(e,A){if(void 0!==e.transport){if(!(e.transport instanceof x))throw new f("`transport` must be created via createTransport()");if(e.transport.closed)throw new f("Transport has been closed");let A=void 0!==e.proxy;if(void 0!==e.browser||void 0!==e.os||void 0!==e.emulation||A||void 0!==e.insecure)throw new f("`transport` cannot be combined with browser/os/emulation/proxy/insecure options");return{transportId:e.transport.id}}if(A?.transportId){if(void 0!==e.emulation)throw new f("Session emulation cannot be changed after creation");if(void 0!==e.browser){Z(e.browser);let t="custom"===A.transportMode.kind?void 0:A.transportMode.browser;if(e.browser!==t)throw new f("Session browser cannot be changed after creation")}if(void 0!==e.os){j(e.os);let t="custom"===A.transportMode.kind?void 0:A.transportMode.os;if(e.os!==t)throw new f("Session operating system cannot be changed after creation")}let t=Object.hasOwn(e,"proxy"),r=t?e.proxy:void 0;if(t&&void 0!==r&&(A.proxy??null)!==(r??null))throw new f("Session proxy cannot be changed after creation");if(void 0!==e.insecure){let t=A.insecure??!1;if(e.insecure!==t)throw new f("Session insecure setting cannot be changed after creation")}return{transportId:A.transportId}}let t={mode:eE(e.browser,e.os,e.emulation)};return void 0!==e.proxy&&(t.proxy=e.proxy),void 0!==e.insecure&&(t.insecure=e.insecure),t}(s,o),E=s.timeout??o?.timeout??3e5,Q={url:r,method:a,sessionId:n.sessionId,ephemeral:n.dropAfterRequest};return void 0!==g&&(Q.body=g),c.transportId?Q.transportId=c.transportId:(void 0!==c.mode&&eQ(Q,c.mode),void 0!==c.proxy&&(Q.proxy=c.proxy),void 0!==c.insecure&&(Q.insecure=c.insecure)),Q.timeout=E,void 0!==s.redirect&&(Q.redirect=s.redirect),void 0!==s.disableDefaultHeaders&&(Q.disableDefaultHeaders=s.disableDefaultHeaders),void 0!==s.compress&&(Q.compress=s.compress),h&&h.length>0&&(Q.headers=h),eu(Q,r,s.signal??null)}async function eB(e){let A=eE(e?.browser,e?.os,e?.emulation);e?.poolIdleTimeout!==void 0&&z(e.poolIdleTimeout,"poolIdleTimeout"),e?.poolMaxIdlePerHost!==void 0&&K(e.poolMaxIdlePerHost,"poolMaxIdlePerHost"),e?.poolMaxSize!==void 0&&$(e.poolMaxSize,"poolMaxSize"),e?.connectTimeout!==void 0&&z(e.connectTimeout,"connectTimeout"),e?.readTimeout!==void 0&&z(e.readTimeout,"readTimeout");try{let t={...e?.proxy!==void 0&&{proxy:e.proxy},...e?.insecure!==void 0&&{insecure:e.insecure},...e?.poolIdleTimeout!==void 0&&{poolIdleTimeout:e.poolIdleTimeout},...e?.poolMaxIdlePerHost!==void 0&&{poolMaxIdlePerHost:e.poolMaxIdlePerHost},...e?.poolMaxSize!==void 0&&{poolMaxSize:e.poolMaxSize},...e?.connectTimeout!==void 0&&{connectTimeout:e.connectTimeout},...e?.readTimeout!==void 0&&{readTimeout:e.readTimeout}};eQ(t,A);let s=r.createTransport(t);return new x(s)}catch(e){throw new f(String(e))}}async function eC(e){let A,t,s,n,{sessionId:o,defaults:i}=(s=e?.sessionId??(0,u.randomUUID)(),n={transportMode:eE(e?.browser,e?.os,e?.emulation)},e?.proxy!==void 0&&(n.proxy=e.proxy),e?.timeout!==void 0&&(X(e.timeout),n.timeout=e.timeout),e?.insecure!==void 0&&(n.insecure=e.insecure),e?.defaultHeaders!==void 0&&(n.defaultHeaders=k(e.defaultHeaders)),{sessionId:s,defaults:n});try{let e={...void 0!==i.proxy&&{proxy:i.proxy},...void 0!==i.insecure&&{insecure:i.insecure}};eQ(e,i.transportMode),t=r.createTransport(e)}catch(e){throw new f(String(e))}try{A=r.createSession({sessionId:o})}catch(e){try{r.dropTransport(t)}catch{}throw new f(String(e))}return i.transportId=t,i.ownsTransport=!0,new G(A,i)}async function ed(e,A){let t=await eC(A);try{return await e(t)}finally{await t.close()}}async function ef(e){if(!e.url)throw new f("URL is required");let{url:A,...t}=e,r={};return void 0!==t.method&&(r.method=t.method),void 0!==t.headers&&(r.headers=t.headers),void 0!==t.body&&(r.body=t.body),void 0!==t.browser&&(r.browser=t.browser),void 0!==t.os&&(r.os=t.os),void 0!==t.emulation&&(r.emulation=t.emulation),void 0!==t.proxy&&(r.proxy=t.proxy),void 0!==t.timeout&&(r.timeout=t.timeout),void 0!==t.sessionId&&(r.sessionId=t.sessionId),void 0!==t.transport&&(r.transport=t.transport),void 0!==t.insecure&&(r.insecure=t.insecure),void 0!==t.disableDefaultHeaders&&(r.disableDefaultHeaders=t.disableDefaultHeaders),void 0!==t.redirect&&(r.redirect=t.redirect),void 0!==t.signal&&(r.signal=t.signal),void 0!==t.session&&(r.session=t.session),void 0!==t.cookieMode?r.cookieMode=t.cookieMode:!0===t.ephemeral&&(r.cookieMode="ephemeral"),eI(A,r)}function ep(){return s||(s=r.getProfiles()),s}function ey(){if(!o){let e=r.getOperatingSystems?.();o=e&&e.length>0?e:[...N]}return o}async function eD(e,A){let t={};return A&&Object.assign(t,A),t.method="GET",eI(e,t)}async function eS(e,A,t){let r={};return t&&Object.assign(r,t),r.method="POST",void 0!==A&&(r.body=A),eI(e,r)}function ew(e){let A,t=String(e).trim();if(!t)throw new f("URL is required");try{A=new URL(t)}catch(e){throw new f(String(e))}if(A.hash)throw new f("WebSocket URL must not include a hash fragment");if("http:"===A.protocol?A.protocol="ws:":"https:"===A.protocol&&(A.protocol="wss:"),"ws:"!==A.protocol&&"wss:"!==A.protocol)throw new f("expected a ws: or wss: url");return A.toString()}function em(e){if(void 0===e)return;let A=new Set,t=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;for(let r of"string"==typeof e?[e]:e){if("string"!=typeof r||0===r.length)throw new f("WebSocket protocol values must be non-empty strings");if(!t.test(r))throw new f(`Invalid WebSocket protocol value: ${r}`);if(A.has(r))throw new f(`Duplicate WebSocket protocol: ${r}`);A.add(r)}}function eN(e){let A={};if(!e)return A;if(void 0!==e.browser&&(A.browser=e.browser),void 0!==e.os&&(A.os=e.os),void 0!==e.emulation&&(A.emulation=e.emulation),void 0!==e.headers&&(A.headers=e.headers),void 0!==e.proxy&&(A.proxy=e.proxy),void 0!==e.protocols&&(A.protocols=e.protocols),void 0!==e.binaryType){if("nodebuffer"!==e.binaryType&&"arraybuffer"!==e.binaryType&&"blob"!==e.binaryType)throw new f("binaryType must be one of: 'nodebuffer', 'arraybuffer', 'blob'");A.binaryType=e.binaryType}return A}function eR(e){let A={};if(!e)return A;if(void 0!==e.browser)throw new f("`browser` is not supported in session.websocket(); the session controls browser emulation.");if(void 0!==e.os)throw new f("`os` is not supported in session.websocket(); the session controls OS emulation.");if(void 0!==e.emulation)throw new f("`emulation` is not supported in session.websocket(); the session transport controls emulation.");if(void 0!==e.proxy)throw new f("`proxy` is not supported in session.websocket(); the session transport controls proxying.");if(void 0!==e.headers&&(A.headers=e.headers),void 0!==e.protocols&&(A.protocols=e.protocols),void 0!==e.binaryType){if("nodebuffer"!==e.binaryType&&"arraybuffer"!==e.binaryType&&"blob"!==e.binaryType)throw new f("binaryType must be one of: 'nodebuffer', 'arraybuffer', 'blob'");A.binaryType=e.binaryType}return A}function eb(e){if(!U(e))return;let A={};return"function"==typeof e.onMessage&&(A.onMessage=e.onMessage),"function"==typeof e.onClose&&(A.onClose=e.onClose),"function"==typeof e.onError&&(A.onError=e.onError),Object.keys(A).length>0?A:void 0}function eU(e){return"open"===e||"message"===e||"close"===e||"error"===e}var eF=class e{static CONNECTING=0;static OPEN=1;static CLOSING=2;static CLOSED=3;url;protocol="";extensions="";readyState=e.CONNECTING;_binaryType="nodebuffer";_bufferedAmount=0;_onopen=null;_onmessage=null;_onclose=null;_onerror=null;_onHandlerOrder={open:-1,message:-1,close:-1,error:-1};_listenerOrderCounter=0;_listeners={open:new Map,message:new Map,close:new Map,error:new Map};_legacyCallbacks;_openDispatchMode;_connection;_connectPromise;_closeOptions;_finalizerToken;_openEventDispatched=!1;_openEventQueued=!1;_closeEventDispatched=!1;_nativeCloseStarted=!1;_pendingMessages=[];_sendChain=Promise.resolve();constructor(A,t,r){let s;s=!function(e){return!!U(e)&&!0===e._internal&&"string"==typeof e.url&&"function"==typeof e.connect}(A)?e.buildStandaloneInit(A,t,r):A,this.url=s.url,this.binaryType=s.options.binaryType??"nodebuffer",this._legacyCallbacks=s.legacyCallbacks,this._openDispatchMode=s.openDispatchMode,this._connectPromise=this.connect(s.connect),this._connectPromise.catch(()=>void 0)}get binaryType(){return this._binaryType}set binaryType(e){("arraybuffer"===e||"blob"===e||"nodebuffer"===e)&&(this._binaryType=e)}get bufferedAmount(){return this._bufferedAmount}get onopen(){return this._onopen}set onopen(e){this._onopen=e,this._onHandlerOrder.open=e?++this._listenerOrderCounter:-1}get onmessage(){return this._onmessage}set onmessage(e){this._onmessage=e,this._onHandlerOrder.message=e?++this._listenerOrderCounter:-1}get onclose(){return this._onclose}set onclose(e){this._onclose=e,this._onHandlerOrder.close=e?++this._listenerOrderCounter:-1}get onerror(){return this._onerror}set onerror(e){this._onerror=e,this._onHandlerOrder.error=e?++this._listenerOrderCounter:-1}static async _connectWithInit(A){let t=new e(A);return await t._waitUntilConnected(),t.scheduleOpenEventAfterAwait(),t}static buildStandaloneInit(e,A,t){let s="string"==typeof A||Array.isArray(A)?t:A??t,n=eN(s);em("string"==typeof A||Array.isArray(A)?A:n.protocols),T(n.headers);let o=eE(n.browser,n.os,n.emulation),i=L("string"==typeof A||Array.isArray(A)?A:n.protocols);return{_internal:!0,url:ew(e),options:n,openDispatchMode:"automatic",connect:A=>{let t={url:ew(e),headers:k(n.headers??{}),...i&&i.length>0&&{protocols:i},...void 0!==n.proxy&&{proxy:n.proxy},onMessage:A.onMessage,onClose:A.onClose,onError:A.onError};return eQ(t,o),r.websocketConnect(t)},legacyCallbacks:eb(s)}}async connect(A){try{let t=await A({onMessage:e=>{this.handleNativeMessage(e)},onClose:e=>{this.handleNativeClose(e)},onError:e=>{this.handleNativeError(e)}});if(this._connection=t,this.protocol=t.protocol??"",this.extensions=t.extensions??"",D&&(this._finalizerToken=t,D.register(this,t,t)),this.readyState===e.CLOSING)return void this.startNativeClose();this.readyState=e.OPEN,"automatic"===this._openDispatchMode&&this.scheduleOpenEventAfterConnect()}catch(e){throw this.handleNativeError(String(e)),this.finalizeClosed({code:1006,reason:""},!1),new f(String(e))}}_waitUntilConnected(){return this._connectPromise}scheduleOpenEventAfterConnect(){this.scheduleOpenEventWithDepth(2)}scheduleOpenEventAfterAwait(){this.scheduleOpenEventWithDepth(3)}scheduleOpenEventWithDepth(A){if(this._openEventDispatched||this._openEventQueued||this.readyState!==e.OPEN)return;this._openEventQueued=!0;let t=A=>{if(0===A){if(this._openEventQueued=!1,this._openEventDispatched||this.readyState!==e.OPEN)return;this._openEventDispatched=!0,this.dispatchOpenEvent();return}queueMicrotask(()=>{t(A-1)})};t(A)}releaseConnectionTracking(){this._finalizerToken&&D&&(D.unregister(this._finalizerToken),this._finalizerToken=void 0)}toMessageEventData(e){if("string"==typeof e)return e;if("arraybuffer"===this._binaryType){let A=new ArrayBuffer(e.byteLength);return new Uint8Array(A).set(e),A}return"blob"===this._binaryType?new Blob([e]):e}invokeListener(e,A){try{"function"==typeof e?e.call(this,A):e.handleEvent(A)}catch{}}createBaseEvent(e){return{type:e,isTrusted:!1,timeStamp:Date.now(),target:this,currentTarget:this}}getOnHandler(e){switch(e){case"open":return this._onopen;case"message":return this._onmessage;case"close":return this._onclose;case"error":return this._onerror;default:return null}}getOnHandlerOrder(e){return this._onHandlerOrder[e]}getListenerMap(e){return this._listeners[e]}dispatchEvent(e,A){let t=this.getListenerMap(e),r=this.getOnHandler(e);if(0===t.size&&!r)return;let s=[];for(let e of t.values())s.push({order:e.order,listener:e.listener,once:e.once});for(let t of(r&&s.push({order:this.getOnHandlerOrder(e),listener:r,once:!1}),s.sort((e,A)=>e.order-A.order),s))t.once&&this.removeEventListener(e,t.listener),this.invokeListener(t.listener,A)}dispatchOpenEvent(){let e=this.createBaseEvent("open");if(this.dispatchEvent("open",e),!this._closeEventDispatched&&this._pendingMessages.length>0){let e=this._pendingMessages;for(let A of(this._pendingMessages=[],e))this.dispatchMessageEvent(this.toMessageEventData(A))}}dispatchMessageEvent(e){let A={...this.createBaseEvent("message"),data:e};this.dispatchEvent("message",A)}dispatchCloseEvent(e){this.dispatchEvent("close",e)}dispatchErrorEvent(e){let A={...this.createBaseEvent("error"),...void 0!==e&&{message:e}};this.dispatchEvent("error",A)}handleNativeMessage(A){if(!this._closeEventDispatched){if(this._legacyCallbacks?.onMessage?.(A),!this._openEventDispatched&&this.readyState===e.OPEN)return void this._pendingMessages.push(A);this.dispatchMessageEvent(this.toMessageEventData(A))}}handleNativeError(e){this._legacyCallbacks?.onError?.(e),this.dispatchErrorEvent(e)}handleNativeClose(A){let t=this.readyState===e.CLOSING||1e3===A.code;this.finalizeClosed(A,t)}finalizeClosed(A,t){if(this._closeEventDispatched)return;this.readyState=e.CLOSED,this._closeEventDispatched=!0,this._pendingMessages=[],this.releaseConnectionTracking();let r={...this.createBaseEvent("close"),code:A.code,reason:A.reason,wasClean:t};this._legacyCallbacks?.onClose?.(r),this.dispatchCloseEvent(r)}startNativeClose(){if(this._nativeCloseStarted||!this._connection)return;this._nativeCloseStarted=!0;let e=this._connection,A=this._closeOptions;r.websocketClose(e,A).catch(e=>{this.handleNativeError(String(e)),this.finalizeClosed({code:1006,reason:""},!1)})}addEventListener(e,A,t){if(!A||!eU(e)||"function"!=typeof A&&("object"!=typeof A||null===A||"function"!=typeof A.handleEvent))return;let r=this.getListenerMap(e);if(r.has(A))return;let s="boolean"==typeof t?{}:t??{},n=!0===s.once,o=s.signal;if(o?.aborted)return;let i={listener:A,order:++this._listenerOrderCounter,once:n};if(o){let t=()=>{this.removeEventListener(e,A)};i.abortSignal=o,i.abortHandler=t,o.addEventListener("abort",t,{once:!0})}r.set(A,i)}removeEventListener(e,A){if(!A||!eU(e)||"function"!=typeof A&&"object"!=typeof A)return;let t=this.getListenerMap(e),r=t.get(A);r&&(r.abortSignal&&r.abortHandler&&r.abortSignal.removeEventListener("abort",r.abortHandler),t.delete(A))}getSendByteLength(e){if("string"==typeof e)return Buffer.byteLength(e);if(Buffer.isBuffer(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;if("u">typeof Blob&&e instanceof Blob)return e.size;throw TypeError("WebSocket data must be a string, Buffer, ArrayBuffer, ArrayBufferView, or Blob")}async normalizeSendPayload(e){if("string"==typeof e||Buffer.isBuffer(e))return e;if(e instanceof ArrayBuffer)return Buffer.from(e);if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);if("u">typeof Blob&&e instanceof Blob)return Buffer.from(await e.arrayBuffer());throw TypeError("WebSocket data must be a string, Buffer, ArrayBuffer, ArrayBufferView, or Blob")}send(A){if(this.readyState!==e.OPEN||!this._connection)throw new f("WebSocket is not open");let t=this.getSendByteLength(A),s=this._connection;this._bufferedAmount+=t;let n=async()=>{try{let e=await this.normalizeSendPayload(A);await r.websocketSend(s,e)}catch(e){this.handleNativeError(String(e)),this.finalizeClosed({code:1006,reason:""},!1)}finally{this._bufferedAmount=Math.max(0,this._bufferedAmount-t)}};this._sendChain=this._sendChain.then(n,n)}close(A,t){this.readyState!==e.CLOSING&&this.readyState!==e.CLOSED&&(this._closeOptions=function(e,A){if(void 0===e&&void 0===A)return;if(void 0===e)throw new f("A close code is required when providing a close reason");if(!Number.isInteger(e))throw new f("Close code must be an integer");if(1e3!==e&&(e<3e3||e>4999))throw new f("Close code must be 1000 or in range 3000-4999");let t=A??"";if(Buffer.byteLength(t,"utf8")>123)throw new f("Close reason must be 123 bytes or fewer");return{code:e,reason:t}}(A,t),this.readyState=e.CLOSING,this.startNativeClose())}};async function ek(e,A){let t=function(e,A){if("string"==typeof e||e instanceof URL){let t=eN(A);return{url:ew(e),options:t,legacyCallbacks:eb(A)}}let t=eN(e);return{url:ew(e.url),options:t,legacyCallbacks:eb(e)}}(e,A);em(t.options.protocols),T(t.options.headers);let s=eE(t.options.browser,t.options.os,t.options.emulation),n=L(t.options.protocols);return eF._connectWithInit({_internal:!0,url:t.url,options:t.options,openDispatchMode:"deferred",connect:e=>{let A={url:t.url,headers:k(t.options.headers??{}),...n&&n.length>0&&{protocols:n},...void 0!==t.options.proxy&&{proxy:t.options.proxy},onMessage:e.onMessage,onClose:e.onClose,onError:e.onError};return eQ(A,s),r.websocketConnect(A)},legacyCallbacks:t.legacyCallbacks})}var eM={fetch:eI,request:ef,get:eD,post:eS,getProfiles:ep,getOperatingSystems:ey,createTransport:eB,createSession:eC,withSession:ed,websocket:ek,WebSocket:eF,Headers:F,Response:O,Transport:x,Session:G,RequestError:f}},435005,e=>{"use strict";let A,t;var r=e.i(359281);function s(e){return"number"==typeof e&&isFinite(e)?e:void 0}let n={quotaApiUrl:"https://cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels",loadProjectApiUrl:"https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",tokenUrl:"https://oauth2.googleapis.com/token",get clientId(){return r.PROVIDERS.antigravity.clientId},get clientSecret(){return r.PROVIDERS.antigravity.clientSecret},userAgent:"antigravity/1.11.3 Darwin/arm64"},o="2023-06-01";function i(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function a(e,A=0){let t="number"==typeof e?e:"string"==typeof e&&e.trim().length>0?Number(e):NaN;return Number.isFinite(t)?t:A}function l(e,A,t){let r=i(e);return r[A]??r[t]??null}function g(e){return Math.max(0,Math.min(100,e))}function h(e){return e.replace(/^copilot[_\s-]*/i,"").split(/[\s_-]+/).filter(Boolean).map(e=>/^pro\+$/i.test(e)?"Pro+":/^[a-z]{2,}$/.test(e)?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e).join(" ").trim()}function c(e){return!!e&&(!e.unlimited||!(e.total<=0))&&(e.total>0||void 0!==e.remainingPercentage)}async function E(e){let{provider:A,accessToken:t,providerSpecificData:r}=e;switch(A){case"github":return await u(t,r);case"gemini-cli":return await C(t);case"antigravity":return await f(t,void 0);case"claude":return await D(t);case"codex":return await w(t,r);case"kiro":return await m(t,r);case"kimi-coding":return await R(t);case"qwen":return await b(t,r);case"iflow":return await U(t);default:return{message:`Usage API not implemented for ${A}`}}}function Q(e){if(!e)return null;try{if(e instanceof Date)return e.toISOString();if("number"==typeof e||"string"==typeof e)return new Date(e).toISOString();return null}catch(A){return console.warn(`Failed to parse reset time: ${e}`,A),null}}async function u(e,A){try{if(!e)throw Error("No GitHub access token available. Please re-authorize the connection.");let A=await fetch("https://api.github.com/copilot_internal/user",{headers:{Authorization:`token ${e}`,Accept:"application/json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"GitHubCopilotChat/0.26.7","Editor-Version":"vscode/1.100.0","Editor-Plugin-Version":"copilot-chat/0.26.7"}});if(!A.ok){let e=await A.text();if(401===A.status||403===A.status)return{message:"GitHub token expired or permission denied. Please re-authenticate the connection."};throw Error(`GitHub API error: ${e}`)}let t=await A.json(),r=i(t);if(r.quota_snapshots){let e=i(r.quota_snapshots),A=Q(l(r,"quota_reset_date","quotaResetDate")),t=I(e.premium_interactions,A),s=I(e.chat,A),n=I(e.completions,A),o={};return c(t)&&(o.premium_interactions=t),c(s)&&(o.chat=s),c(n)&&(o.completions=n),{plan:B(r,t),resetDate:l(r,"quota_reset_date","quotaResetDate"),quotas:o}}if(r.monthly_quotas||r.limited_user_quotas){let e=i(r.monthly_quotas),A=i(r.limited_user_quotas),t=l(r,"limited_user_reset_date","limitedUserResetDate"),s=Q(t),n={},o=t=>{let r=a(l(e,t,t),0),o=Math.max(0,a(l(A,t,t),0));if(r<=0)return null;let i=Math.min(o,r);return n[t]={used:i,total:r,remaining:Math.max(r-i,0),remainingPercentage:g((r-i)/r*100),unlimited:!1,resetAt:s},n[t]},h=o("premium_interactions");return o("chat"),o("completions"),{plan:B(r,h),resetDate:t,quotas:n}}return{message:"GitHub Copilot connected. Unable to parse quota data."}}catch(e){throw Error(`Failed to fetch GitHub usage: ${e.message}`)}}function I(e,A=null){let t=i(e);if(0===Object.keys(t).length)return null;let r=!0===t.unlimited,s=a(t.entitlement,NaN),n=a(t.total,NaN),o=a(t.remaining,NaN),h=a(t.used,NaN),c=a(l(t,"percent_remaining","percentRemaining"),NaN),E=Number.isFinite(n)?Math.max(0,n):Number.isFinite(s)?Math.max(0,s):0,Q=Number.isFinite(o)?Math.max(0,o):void 0,u=Number.isFinite(h)?Math.max(0,h):void 0,B=Number.isFinite(c)?g(c):void 0;return void 0===u&&E>0&&void 0!==Q&&(u=Math.max(E-Q,0)),void 0===Q&&E>0&&void 0!==u&&(Q=Math.max(E-u,0)),void 0===B&&E>0&&void 0!==Q&&(B=g(Q/E*100)),E<=0&&void 0!==B&&(E=100,u=100-B,Q=B),{used:Math.max(0,u??0),total:E,remaining:Q,remainingPercentage:B,resetAt:A,unlimited:r}}function B(e,A){let t=l(e,"copilot_plan","copilotPlan"),r=l(e,"access_type_sku","accessTypeSku"),s="string"==typeof t?t.trim():"",n="string"==typeof r?r.trim():"",o=`${n} ${s}`.trim().toUpperCase(),g=i(l(e,"monthly_quotas","monthlyQuotas")),c=A?.total||a(l(g,"premium_interactions","premiumInteractions"),0),E=a(l(g,"chat","chat"),0);if(o.includes("PRO+")||o.includes("PRO_PLUS")||o.includes("PROPLUS"))return"Copilot Pro+";if(o.includes("ENTERPRISE"))return"Copilot Enterprise";if(o.includes("BUSINESS"))return"Copilot Business";if(o.includes("STUDENT"))return"Copilot Student";if(o.includes("FREE"))return"Copilot Free";if(o.includes("PRO"))return"Copilot Pro";if(c>=1400)return"Copilot Pro+";if(c>=900)return"Copilot Enterprise";if(c>=250)return o.includes("INDIVIDUAL")?"Copilot Pro":"Copilot Business";if(c>0||50===E)return"Copilot Free";if(n){let e=h(n);return e?`Copilot ${e}`:"GitHub Copilot"}if(s){let e=h(s);return e?`Copilot ${e}`:"GitHub Copilot"}return"GitHub Copilot"}async function C(e){try{if(!(await fetch("https://cloudresourcemanager.googleapis.com/v1/projects?filter=lifecycleState:ACTIVE",{headers:{Authorization:`Bearer ${e}`,Accept:"application/json"}})).ok)return{message:"Gemini CLI uses Google Cloud quotas. Check Google Cloud Console for details."};return{message:"Gemini CLI connected. Usage tracked via Google Cloud Console."}}catch(e){return{message:"Unable to fetch Gemini usage. Check Google Cloud Console."}}}let d=new Map;async function f(e,A){try{let A=await p(e),t=A?.cloudaicompanionProject||null,r=await fetch(n.quotaApiUrl,{method:"POST",headers:{Authorization:`Bearer ${e}`,"User-Agent":n.userAgent,"Content-Type":"application/json"},body:JSON.stringify(t?{project:t}:{})});if(403===r.status)return{message:"Antigravity access forbidden. Check subscription."};if(!r.ok)throw Error(`Antigravity API error: ${r.status}`);let s=await r.json(),o=i(s),l=i(o.models),g={};if(Object.keys(l).length>0){let e=["claude-opus-4-6-thinking","claude-sonnet-4-6","gemini-3.1-pro-high","gemini-3.1-pro-low","gemini-3-flash","gpt-oss-120b-medium"];for(let[A,t]of Object.entries(l)){let r=i(t),s=i(r.quotaInfo);if(0===Object.keys(s).length||!0===r.isInternal||!e.includes(A))continue;let n=a(s.remainingFraction,0),o=100*n,l=Math.round(1e3*n),h=1e3-l;g[A]={used:h,total:1e3,resetAt:Q(s.resetTime),remainingPercentage:o,unlimited:!1,displayName:"string"==typeof r.displayName?r.displayName:A}}}return{plan:function(e){if(!e||0===Object.keys(e).length)return"Free";let A="";if(Array.isArray(e.allowedTiers)){for(let t of e.allowedTiers)if(t.isDefault&&t.id){A=t.id.trim().toUpperCase();break}}if(A||(A=(e.currentTier?.id||"").toUpperCase()),A){if(A.includes("ULTRA"))return"Ultra";if(A.includes("PRO"))return"Pro";if(A.includes("ENTERPRISE"))return"Enterprise";if(A.includes("BUSINESS")||A.includes("STANDARD"))return"Business";if(A.includes("FREE")||A.includes("INDIVIDUAL")||A.includes("LEGACY"))return"Free"}let t=e.currentTier?.name||e.currentTier?.displayName||e.subscriptionType||e.tier||"",r=t.toUpperCase();return r.includes("ULTRA")?"Ultra":r.includes("PRO")?"Pro":r.includes("ENTERPRISE")?"Enterprise":r.includes("STANDARD")||r.includes("BUSINESS")?"Business":r.includes("INDIVIDUAL")||r.includes("FREE")||e.currentTier?.upgradeSubscriptionType?"Free":t?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():"Free"}(A),quotas:g,subscriptionInfo:A}}catch(e){return{message:`Antigravity error: ${e.message}`}}}async function p(e){let A=e.substring(0,16),t=d.get(A);if(t&&Date.now()-t.fetchedAt<3e5)return t.data;let r=await y(e);return d.set(A,{data:r,fetchedAt:Date.now()}),r}async function y(e){try{let A=await fetch(n.loadProjectApiUrl,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","User-Agent":"google-api-nodejs-client/9.15.1","X-Goog-Api-Client":"google-cloud-sdk vscode_cloudshelleditor/0.1","Client-Metadata":JSON.stringify({ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"})},body:JSON.stringify({metadata:{ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"}})});if(!A.ok)return null;return await A.json()}catch{return null}}async function D(e){try{let A=await fetch("https://api.anthropic.com/api/oauth/usage",{method:"GET",headers:{Authorization:`Bearer ${e}`,"anthropic-beta":"oauth-2025-04-20","anthropic-version":o}});if(A.ok){let e=await A.json(),t={},r=e=>e&&"object"==typeof e&&void 0!==s(e.utilization),n=e=>{let A=s(e.utilization),t=Math.max(0,100-A);return{used:A,total:100,remaining:t,resetAt:Q(e.resets_at),remainingPercentage:t,unlimited:!1}};for(let[A,s]of(r(e.five_hour)&&(t["session (5h)"]=n(e.five_hour)),r(e.seven_day)&&(t["weekly (7d)"]=n(e.seven_day)),Object.entries(e))){let e=i(s);if(A.startsWith("seven_day_")&&"seven_day"!==A&&r(e)){let r=A.replace("seven_day_","");t[`weekly ${r} (7d)`]=n(e)}}return{plan:("string"==typeof e.tier?e.tier:"string"==typeof e.plan?e.plan:"string"==typeof e.subscription_type?e.subscription_type:null)||"Claude Code",quotas:t,extraUsage:e.extra_usage??null}}return console.warn(`[Claude Usage] OAuth endpoint returned ${A.status}, falling back to legacy`),await S(e)}catch(e){return{message:`Claude connected. Unable to fetch usage: ${e.message}`}}}async function S(e){try{let A=await fetch("https://api.anthropic.com/v1/settings",{method:"GET",headers:{Authorization:`Bearer ${e}`,"anthropic-version":o}});if(A.ok){let t=await A.json();if(t.organization_id){let A=await fetch("https://api.anthropic.com/v1/organizations/{org_id}/usage".replace("{org_id}",t.organization_id),{method:"GET",headers:{Authorization:`Bearer ${e}`,"anthropic-version":o}});if(A.ok){let e=await A.json();return{plan:t.plan||"Unknown",organization:t.organization_name,quotas:e}}}return{plan:t.plan||"Unknown",organization:t.organization_name,message:"Claude connected. Usage details require admin access."}}return{message:"Claude connected. Usage API requires admin permissions."}}catch(e){return{message:`Claude connected. Unable to fetch usage: ${e.message}`}}}async function w(e,A={}){try{let t="string"==typeof A.workspaceId?A.workspaceId:null,r={Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"};t&&(r["chatgpt-account-id"]=t);let s=await fetch("https://chatgpt.com/backend-api/wham/usage",{method:"GET",headers:r});if(!s.ok){if(401===s.status||403===s.status)return{message:"Codex token expired or access denied. Please re-authenticate the connection."};throw Error(`Codex API error: ${s.status}`)}let n=await s.json(),o=i(l(n,"rate_limit","rateLimit")),g=i(l(o,"primary_window","primaryWindow")),h=i(l(o,"secondary_window","secondaryWindow")),c=e=>{let A=a(l(e,"reset_at","resetAt"),0),t=a(l(e,"reset_after_seconds","resetAfterSeconds"),0);return A>0?Q(1e3*A):t>0?Q(Date.now()+1e3*t):null},E={};if(Object.keys(g).length>0){let e=a(l(g,"used_percent","usedPercent"),0);E.session={used:e,total:100,remaining:100-e,resetAt:c(g),unlimited:!1}}if(Object.keys(h).length>0){let e=a(l(h,"used_percent","usedPercent"),0);E.weekly={used:e,total:100,remaining:100-e,resetAt:c(h),unlimited:!1}}let u=i(l(n,"code_review_rate_limit","codeReviewRateLimit")),I=i(l(u,"primary_window","primaryWindow")),B=l(I,"used_percent","usedPercent"),C=l(I,"remaining_count","remainingCount");if(null!==B||null!==C){let e=a(B,0);E.code_review={used:e,total:100,remaining:100-e,resetAt:c(I),unlimited:!1}}return{plan:String(l(n,"plan_type","planType")||"unknown"),limitReached:!!l(o,"limit_reached","limitReached"),quotas:E}}catch(e){throw Error(`Failed to fetch Codex usage: ${e.message}`)}}async function m(e,A){try{let t=A?.profileArn;if(!t)return{message:"Kiro connected. Profile ARN not available for quota tracking."};let r=await fetch("https://codewhisperer.us-east-1.amazonaws.com",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/x-amz-json-1.0","x-amz-target":"AmazonCodeWhispererService.GetUsageLimits",Accept:"application/json"},body:JSON.stringify({origin:"AI_EDITOR",profileArn:t,resourceType:"AGENTIC_REQUEST"})});if(!r.ok){let e=await r.text();throw Error(`Kiro API error (${r.status}): ${e}`)}let s=await r.json(),n=s.usageBreakdownList||[],o={},i=Q(s.nextDateReset||s.resetDate);return n.forEach(e=>{let A=e.resourceType?.toLowerCase()||"unknown",t=e.currentUsageWithPrecision||0,r=e.usageLimitWithPrecision||0;if(o[A]={used:t,total:r,remaining:r-t,resetAt:i,unlimited:!1},e.freeTrialInfo){let t=e.freeTrialInfo.currentUsageWithPrecision||0,r=e.freeTrialInfo.usageLimitWithPrecision||0;o[`${A}_freetrial`]={used:t,total:r,remaining:r-t,resetAt:i,unlimited:!1}}}),{plan:s.subscriptionInfo?.subscriptionTitle||"Kiro",quotas:o}}catch(e){throw Error(`Failed to fetch Kiro usage: ${e.message}`)}}function N(e){return e?({LEVEL_BASIC:"Moderato",LEVEL_INTERMEDIATE:"Allegretto",LEVEL_ADVANCED:"Allegro",LEVEL_STANDARD:"Vivace"})[e]||e.replace("LEVEL_","").toLowerCase():""}async function R(e){let A="kimi-usage-"+Date.now(),t="u">typeof process?`${process.platform} ${process.arch}`:"unknown";try{let r,n=await fetch("https://api.kimi.com/coding/v1/usages",{method:"GET",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-Msh-Platform":"omniroute","X-Msh-Version":"2.1.2","X-Msh-Device-Model":t,"X-Msh-Device-Id":A}}),o=await n.text();if(!n.ok)return{plan:"Kimi Coding",message:`Kimi Coding connected. API Error ${n.status}: ${o.slice(0,100)}`};try{r=JSON.parse(o)}catch{return{plan:"Kimi Coding",message:"Kimi Coding connected. Invalid JSON response from API."}}let l={},g=i(r),h=i(g.usage),c=a(h.limit||h.Limit,0),E=a(h.used||h.Used,0),u=a(h.remaining||h.Remaining,0),I=h.resetTime||h.ResetTime||h.reset_at||h.resetAt;c>0&&(l.Weekly={used:E,total:c,remaining:u,remainingPercentage:c>0?u/c*100:0,resetAt:Q(I),unlimited:!1});let B=Array.isArray(g.limits)?g.limits:[];for(let e=0;e<B.length;e++){let A=i(B[e]);i(A.window);let t=i(A.detail),r=a(t.limit||t.Limit,0),s=a(t.remaining||t.Remaining,0),n=t.resetTime||t.reset_at||t.resetAt;r>0&&(l.Ratelimit={used:r-s,total:r,remaining:s,remainingPercentage:r>0?s/r*100:0,resetAt:Q(n),unlimited:!1})}let C=e=>e&&"object"==typeof e&&void 0!==s(e.utilization),d=e=>{let A=s(e.utilization);return{used:100-A,total:100,remaining:A,resetAt:Q(e.resets_at),remainingPercentage:A,unlimited:!1}};for(let[e,A]of(C(i(g.five_hour))&&(l["session (5h)"]=d(i(g.five_hour))),C(i(g.seven_day))&&(l["weekly (7d)"]=d(i(g.seven_day))),Object.entries(g))){let t=i(A);if(e.startsWith("seven_day_")&&"seven_day"!==e&&C(t)){let A=e.replace("seven_day_","");l[`weekly ${A} (7d)`]=d(t)}}if(Object.keys(l).length>0){let e=i(g.user),A=i(e.membership).level;return{plan:N(A)||"Kimi Coding",quotas:l}}let f=i(g.user),p=i(f.membership).level;return{plan:N(p)||"Kimi Coding",message:"Kimi Coding connected. Usage tracked per request."}}catch(e){return{message:`Kimi Coding connected. Unable to fetch usage: ${e.message}`}}}async function b(e,A){try{if(!A?.resourceUrl)return{message:"Qwen connected. No resource URL available."};return{message:"Qwen connected. Usage tracked per request."}}catch(e){return{message:"Unable to fetch Qwen usage."}}}async function U(e){try{return{message:"iFlow connected. Usage tracked per request."}}catch(e){return{message:"Unable to fetch iFlow usage."}}}var F=e.i(543125);e.i(196039),e.i(335273),["host","connection","content-length","keep-alive","proxy-connection","transfer-encoding","te","trailer","upgrade"].map(e=>e.toLowerCase());var k=e.i(799537);e.i(896596);let M=new Map,T=new Map,L=new Map,v=new Map;(0,k.registerDbStateResetter)(function(){M.clear(),T.clear(),v.clear(),v.clear(),L.clear()});var H=e.i(974210);e.i(946393),e.i(687267);let Y=["litellm"];Number.isFinite(parseInt(process.env.PRICING_SYNC_INTERVAL||"86400",10)),(process.env.PRICING_SYNC_SOURCES||"litellm").split(",").map(e=>e.trim()).filter(e=>Y.includes(e)),e.i(254799);var O=e.i(478500),x=e.i(724055),G=e.i(425842);let V=Symbol.for("omniroute.proxyDispatcher.cache"),J=new Set(["http:","https:","socks5:"]);function _(e){try{let A=e.match(/:\/\/(?:[^@]*@)?[^:/\s]+:(\d+)/);if(A){let e=Number(A[1]);if(Number.isInteger(e)&&e>=1&&e<=65535)return String(e)}}catch{}return null}function P(e){return"https:"===e||"wss:"===e?"443":"socks5:"===e?"1080":"8080"}function W(e,A){if(!e)return P(A);let t=Number(e);if(!Number.isInteger(t)||t<1||t>65535)throw Error("[ProxyDispatcher] Invalid proxy port");return String(t)}function q(){return"true"===process.env.ENABLE_SOCKS5_PROXY}function Z(e){let A=_(e),t=new URL(e),r=A||t.port||P(t.protocol);return`${t.protocol}//${t.hostname}:${r}`}function j(e,A="proxy",{allowSocks5:t=q()}={}){var r;let s,n,o=_(e);try{s=new URL(e)}catch{throw Error(`[ProxyDispatcher] Invalid ${A} URL`)}if(!J.has(s.protocol))throw Error(`[ProxyDispatcher] Unsupported ${A} protocol: ${s.protocol.replace(":","")}`);if("socks5:"===s.protocol&&!t)throw Error("[ProxyDispatcher] SOCKS5 proxy is disabled (set ENABLE_SOCKS5_PROXY=true to enable)");if(!s.hostname)throw Error(`[ProxyDispatcher] Invalid ${A} host`);let i=o||W(s.port,s.protocol);return n=(r=s).username?`${r.username}${r.password?`:${r.password}`:""}@`:"",`${r.protocol}//${n}${r.hostname}:${i}`}function X(e,{allowSocks5:A=q()}={}){if(!e)return null;if("string"==typeof e)return j(e,"context proxy",{allowSocks5:A});if("object"!=typeof e||Array.isArray(e))throw Error("[ProxyDispatcher] Invalid context proxy config");let t=String(e.type||"http").toLowerCase(),r=`${t}:`;if(!J.has(r))throw Error(`[ProxyDispatcher] Unsupported context proxy protocol: ${t}`);if("socks5:"===r&&!A)throw Error("[ProxyDispatcher] SOCKS5 proxy is disabled (set ENABLE_SOCKS5_PROXY=true to enable)");if(!e.host)throw Error("[ProxyDispatcher] Context proxy host is required");let s=W(e.port,r),n=e.username?`${encodeURIComponent(e.username)}:${e.password?encodeURIComponent(e.password):""}@`:"";return j(`${t}://${n}${e.host}:${s}`,"context proxy",{allowSocks5:A})}(0,e.i(362562).createRequire)({get url(){return`file://${e.P("open-sse/utils/tlsClient.ts")}`}}.url);try{let t=e.r(621213);A="function"==typeof t.createSession?t.createSession:null}catch{A=null}let z=new class{session=null;available;constructor(){this.available=!!A}async getSession(){if(!this.available)return null;if(this.session)return this.session;let e=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy||void 0,t={browser:"chrome_124",os:"macos"};return e&&(t.proxy=e,console.log(`[TlsClient] Using proxy: ${e}`)),this.session=await A(t),console.log("[TlsClient] Session created (Chrome 124 TLS fingerprint)"),this.session}async fetch(e,A={}){let t=await this.getSession();if(!t)throw Error("wreq-js not available");let r={method:(A.method||"GET").toUpperCase(),headers:function(e){if(!e)return;if(e instanceof Headers)return Object.fromEntries(e.entries());if(Array.isArray(e))return Object.fromEntries(e.map(([e,A])=>[e,String(A)]));let A={};for(let[t,r]of Object.entries(e))"string"==typeof r&&(A[t]=r);return A}(A.headers),body:A.body,redirect:"manual"===A.redirect?"manual":"follow"};return A.signal&&(r.signal=A.signal),await t.fetch(e,r)}async exit(){this.session&&(await this.session.close(),this.session=null)}};var K=e.i(761095);let $=parseInt(process.env.PROXY_FAST_FAIL_TIMEOUT_MS??"2000",10),ee=parseInt(process.env.PROXY_HEALTH_CACHE_TTL_MS??"30000",10),eA=new Map;async function et(e,A=$,t=ee){var r,s,n;let o,i=eA.get(e);if(i&&Date.now()-i.checkedAt<i.ttlMs)return i.healthy;try{o=new URL(e)}catch{return eA.set(e,{healthy:!1,checkedAt:Date.now(),ttlMs:t}),!1}let a=o.hostname,l=parseInt(o.port||function(e){switch(e.replace(":","").toLowerCase()){case"https":return"443";case"socks5":case"socks5h":return"1080";default:return"8080"}}(o.protocol),10);if(!a||isNaN(l))return eA.set(e,{healthy:!1,checkedAt:Date.now(),ttlMs:t}),!1;let g=await (r=a,s=l,n=A,new Promise(e=>{let A=(0,K.createConnection)({host:r,port:s},()=>{A.destroy(),e(!0)});A.setTimeout(n),A.on("error",()=>e(!1)),A.on("timeout",()=>{A.destroy(),e(!1)})}));return eA.set(e,{healthy:g,checkedAt:Date.now(),ttlMs:t}),g}let er=new O.AsyncLocalStorage,es="u">typeof caches&&"object"==typeof caches,en=Symbol.for("omniroute.proxyFetch.state"),eo=((t=globalThis)[en]||(t[en]={originalFetch:globalThis.fetch,proxyContext:new O.AsyncLocalStorage,isPatched:!1}),t[en]),ei=eo.originalFetch,ea=eo.proxyContext;async function el(e,A){if("function"!=typeof A)throw TypeError("runWithProxyContext requires a callback function");let t=e?X(e):null;if(t&&!await et(t)){let e=Z(t),A=Error(`[Proxy Fast-Fail] Proxy unreachable: ${e}`);throw A.code="PROXY_UNREACHABLE",A.statusCode=503,A}return ea.run(e||null,async()=>(t&&console.log(`[ProxyFetch] Applied request proxy context: ${Z(t)}`),A()))}async function eg(e,A={}){let t;if(A?.dispatcher)return ei(e,A);let r="string"==typeof e?e:e&&"string"==typeof e.url?e.url:String(e);try{t=function(e){let A=ea.getStore();if(A)return{source:"context",proxyUrl:X(A)};let t=function(e){let A;if(function(e){let A,t=process.env.NO_PROXY||process.env.no_proxy;if(!t)return!1;try{A=new URL(e)}catch{return!1}let r=A.hostname.toLowerCase(),s=A.port||("https:"===A.protocol?"443":"80");return t.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean).some(e=>{if("*"===e)return!0;let[A,t]=e.split(":");return(!t||t===s)&&!!A&&(A.startsWith(".")?r.endsWith(A)||r===A.slice(1):r===A||r.endsWith(`.${A}`))})}(e))return null;try{A=new URL(e).protocol}catch{return null}let t="https:"===A?process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy:process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy;return t?j(t,"environment proxy"):null}(e);return t?{source:"env",proxyUrl:t}:{source:"direct",proxyUrl:null}}(r)}catch(A){let e=A instanceof Error?A.message:String(A);throw console.error(`[ProxyFetch] Proxy configuration error: ${e}`),A}let{source:s,proxyUrl:n}=t;if(!n){if("true"===process.env.ENABLE_TLS_FINGERPRINT&&z.available)try{let e=er.getStore();return e&&(e.used=!0),await z.fetch(r,{...A,headers:A.headers})}catch(t){let e=t instanceof Error?t.message:String(t);console.warn(`[ProxyFetch] TLS fingerprint failed, falling back to native fetch: ${e}`);let A=er.getStore();A&&(A.used=!1)}return ei(e,A)}try{let t=function(e){let A,t=j(e,"proxy dispatcher"),r=((A=globalThis)[V]||(A[V]=new Map),A[V]),s=r.get(t);if(s)return s;let n=new URL(t),o=_(t)||W(n.port,n.protocol);if("socks5:"===n.protocol){let e={type:5,host:n.hostname,port:Number(o)};n.username&&(e.userId=decodeURIComponent(n.username)),n.password&&(e.password=decodeURIComponent(n.password)),s=(0,G.socksDispatcher)(e)}else s=new x.ProxyAgent(t);return r.set(t,s),s}(n);return await ei(e,{...A,dispatcher:t})}catch(A){let e=A instanceof Error?A.message:String(A);throw console.error(`[ProxyFetch] Proxy request failed (${s}, fail-closed): ${e}`),A}}es||eo.isPatched||(globalThis.fetch=eg,eo.isPatched=!0);let eh=new Map,ec=null,eE=!1;function eQ(e){let A=new Date(e).getTime();return Number.isNaN(A)?null:A}function eu(e){return Number.isFinite(e)?Math.max(0,Math.min(100,e)):0}function eI(e){return"string"!=typeof e?"":e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function eB(e,A,t){let r,n=function(e){let A={};for(let[t,r]of Object.entries(e))r&&"object"==typeof r&&(A[t]={remainingPercentage:s(r.remainingPercentage)??(r.total>0?Math.round((r.total-(r.used||0))/r.total*100):0),resetAt:r.resetAt||null});return A}(t),o=0!==(r=Object.values(n)).length&&r.every(e=>e.remainingPercentage<=0);eh.set(e,{connectionId:e,provider:A,quotas:n,fetchedAt:Date.now(),exhausted:o,nextResetAt:o?function(e){let A=null,t=1/0;for(let r of Object.values(e)){if(!r.resetAt)continue;let e=eQ(r.resetAt);null!==e&&e<t&&(t=e,A=r.resetAt)}return A}(n):null})}function eC(e){return eh.get(e)||null}function ed(e){let A=eh.get(e);if(!A||!A.exhausted)return!1;let t=Date.now();if(function(e,A){if(!e.nextResetAt)return null;let t=eQ(e.nextResetAt);return null===t?null:t<=A||e.windowDurationMs&&e.windowDurationMs>0&&A-t>=0?{exhausted:!1}:null}(A,t))return A.exhausted=!1,!1;let r=t-A.fetchedAt;return!!A.nextResetAt||!(r>3e5)}function ef(e,A,t=90){let r=eh.get(e);if(!r)return null;let s=Date.now(),n=function(e,A){let t=e[A];if(t)return t;let r=eI(A);if(!r)return null;let s=[];for(let[A,t]of Object.entries(e)){let e=eI(A);if(e){if(e===r)return t;e.startsWith(`${r} `)&&s.push({key:A,quota:t})}}return s.length>0?(s.sort((e,A)=>e.key.localeCompare(A.key)),s[0].quota):null}(r.quotas,A);if(!n)return null;let o=eu(n.remainingPercentage),i=eu(100-o),a=n.resetAt||null,l=!1;if(a){let e=eQ(a);null!==e&&e<=s&&(a=null,l=!0)}return{remainingPercentage:o,usedPercentage:i,resetAt:a,reachedThreshold:!l&&i>=t}}function ep(e,A){eh.set(e,{connectionId:e,provider:A,quotas:{},fetchedAt:Date.now(),exhausted:!0,nextResetAt:null})}let ey=new Set;async function eD(e){if(!ey.has(e.connectionId)){ey.add(e.connectionId);try{let A=await (0,F.getProviderConnectionById)(e.connectionId);if(!A||"oauth"!==A.authType||!A.isActive)return void eh.delete(e.connectionId);let t=await (0,H.resolveProxyForConnection)(e.connectionId),r=await el(t?.proxy||null,()=>E(A));r?.quotas&&eB(e.connectionId,e.provider,r.quotas)}catch(A){console.warn(`[QuotaCache] Refresh failed for ${e.connectionId.slice(0,8)}:`,A?.message||A)}finally{ey.delete(e.connectionId)}}}async function eS(){if(!eE){eE=!0;try{let e=Date.now(),A=[...eh.values()].filter(A=>(function(e,A){let t=A-e.fetchedAt;if(e.exhausted&&e.nextResetAt){let t=eQ(e.nextResetAt);if(null!==t&&t<=A)return!0}return t>=3e5})(A,e));for(let e=0;e<A.length;e+=5){let t=A.slice(e,e+5);await Promise.allSettled(t.map(eD))}}finally{eE=!1}}}function ew(){ec||(ec=setInterval(eS,6e4),ec?.unref?.())}function em(){ec&&(clearInterval(ec),ec=null)}function eN(){let e=[];for(let A of eh.values())e.push({connectionId:A.connectionId.slice(0,8)+"...",provider:A.provider,exhausted:A.exhausted,nextResetAt:A.nextResetAt,ageMs:Date.now()-A.fetchedAt});return{total:eh.size,entries:e}}e.s(["getQuotaCache",()=>eC,"getQuotaCacheStats",()=>eN,"getQuotaWindowStatus",()=>ef,"isAccountQuotaExhausted",()=>ed,"markAccountExhaustedFrom429",()=>ep,"setQuotaCache",()=>eB,"startBackgroundRefresh",()=>ew,"stopBackgroundRefresh",()=>em],435005)}];
|
|
120
|
+
${o}`:n.stack}(e,T):e&&"object"==typeof e&&Error.captureStackTrace(e,A.exports.fetch),e})},A.exports.Headers=e.r(700419).Headers,A.exports.Response=e.r(312148).Response,A.exports.Request=e.r(440796).Request,A.exports.FormData=e.r(695905).FormData;let{setGlobalOrigin:L,getGlobalOrigin:v}=e.r(498319);A.exports.setGlobalOrigin=L,A.exports.getGlobalOrigin=v;let{CacheStorage:H}=e.r(80599),{kConstruct:Y}=e.r(227235);A.exports.caches=new H(Y);let{deleteCookie:O,getCookies:x,getSetCookies:G,setCookie:V,parseCookie:J}=e.r(115689);A.exports.deleteCookie=O,A.exports.getCookies=x,A.exports.getSetCookies=G,A.exports.setCookie=V,A.exports.parseCookie=J;let{parseMIMEType:_,serializeAMimeType:P}=e.r(997726);A.exports.parseMIMEType=_,A.exports.serializeAMimeType=P;let{CloseEvent:W,ErrorEvent:q,MessageEvent:Z}=e.r(823164),{WebSocket:j,ping:X}=e.r(337557);A.exports.WebSocket=j,A.exports.CloseEvent=W,A.exports.ErrorEvent=q,A.exports.MessageEvent=Z,A.exports.ping=X,A.exports.WebSocketStream=e.r(233032).WebSocketStream,A.exports.WebSocketError=e.r(208890).WebSocketError,A.exports.request=k(B.request),A.exports.stream=k(B.stream),A.exports.pipeline=k(B.pipeline),A.exports.connect=k(B.connect),A.exports.upgrade=k(B.upgrade),A.exports.MockClient=d,A.exports.MockCallHistory=f,A.exports.MockCallHistoryLog=p,A.exports.MockPool=D,A.exports.MockAgent=y,A.exports.SnapshotAgent=S,A.exports.mockErrors=w;let{EventSource:z}=e.r(960854);A.exports.EventSource=z,A.exports.install=function(){globalThis.fetch=A.exports.fetch,globalThis.Headers=A.exports.Headers,globalThis.Response=A.exports.Response,globalThis.Request=A.exports.Request,globalThis.FormData=A.exports.FormData,globalThis.WebSocket=A.exports.WebSocket,globalThis.CloseEvent=A.exports.CloseEvent,globalThis.ErrorEvent=A.exports.ErrorEvent,globalThis.MessageEvent=A.exports.MessageEvent,globalThis.EventSource=A.exports.EventSource}},841380,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let r=e.r(500874),s={INVALID_ENCODING:"Invalid encoding provided. Please specify a valid encoding the internal Node.js Buffer supports.",INVALID_SMARTBUFFER_SIZE:"Invalid size provided. Size must be a valid integer greater than zero.",INVALID_SMARTBUFFER_BUFFER:"Invalid Buffer provided in SmartBufferOptions.",INVALID_SMARTBUFFER_OBJECT:"Invalid SmartBufferOptions object supplied to SmartBuffer constructor or factory methods.",INVALID_OFFSET:"An invalid offset value was provided.",INVALID_OFFSET_NON_NUMBER:"An invalid offset value was provided. A numeric value is required.",INVALID_LENGTH:"An invalid length value was provided.",INVALID_LENGTH_NON_NUMBER:"An invalid length value was provived. A numeric value is required.",INVALID_TARGET_OFFSET:"Target offset is beyond the bounds of the internal SmartBuffer data.",INVALID_TARGET_LENGTH:"Specified length value moves cursor beyong the bounds of the internal SmartBuffer data.",INVALID_READ_BEYOND_BOUNDS:"Attempted to read beyond the bounds of the managed data.",INVALID_WRITE_BEYOND_BOUNDS:"Attempted to write beyond the bounds of the managed data."};function n(e){var A;return"number"==typeof e&&isFinite(e)&&"number"==typeof(A=e)&&isFinite(A)&&Math.floor(A)===A}function o(e,A){if("number"==typeof e){if(!n(e)||e<0)throw Error(A?s.INVALID_OFFSET:s.INVALID_LENGTH)}else throw Error(A?s.INVALID_OFFSET_NON_NUMBER:s.INVALID_LENGTH_NON_NUMBER)}t.ERRORS=s,t.checkEncoding=function(e){if(!r.Buffer.isEncoding(e))throw Error(s.INVALID_ENCODING)},t.isFiniteInteger=n,t.checkLengthValue=function(e){o(e,!1)},t.checkOffsetValue=function(e){o(e,!0)},t.checkTargetOffset=function(e,A){if(e<0||e>A.length)throw Error(s.INVALID_TARGET_OFFSET)},t.bigIntAndBufferInt64Check=function(e){if("u"<typeof BigInt)throw Error("Platform does not support JS BigInt type.");if(void 0===r.Buffer.prototype[e])throw Error(`Platform does not support Buffer.prototype.${e}.`)}},102372,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});let r=e.r(841380);class s{constructor(e){if(this.length=0,this._encoding="utf8",this._writeOffset=0,this._readOffset=0,s.isSmartBufferOptions(e))if(e.encoding&&(r.checkEncoding(e.encoding),this._encoding=e.encoding),e.size)if(r.isFiniteInteger(e.size)&&e.size>0)this._buff=Buffer.allocUnsafe(e.size);else throw Error(r.ERRORS.INVALID_SMARTBUFFER_SIZE);else if(e.buff)if(Buffer.isBuffer(e.buff))this._buff=e.buff,this.length=e.buff.length;else throw Error(r.ERRORS.INVALID_SMARTBUFFER_BUFFER);else this._buff=Buffer.allocUnsafe(4096);else{if(void 0!==e)throw Error(r.ERRORS.INVALID_SMARTBUFFER_OBJECT);this._buff=Buffer.allocUnsafe(4096)}}static fromSize(e,A){return new this({size:e,encoding:A})}static fromBuffer(e,A){return new this({buff:e,encoding:A})}static fromOptions(e){return new this(e)}static isSmartBufferOptions(e){return e&&(void 0!==e.encoding||void 0!==e.size||void 0!==e.buff)}readInt8(e){return this._readNumberValue(Buffer.prototype.readInt8,1,e)}readInt16BE(e){return this._readNumberValue(Buffer.prototype.readInt16BE,2,e)}readInt16LE(e){return this._readNumberValue(Buffer.prototype.readInt16LE,2,e)}readInt32BE(e){return this._readNumberValue(Buffer.prototype.readInt32BE,4,e)}readInt32LE(e){return this._readNumberValue(Buffer.prototype.readInt32LE,4,e)}readBigInt64BE(e){return r.bigIntAndBufferInt64Check("readBigInt64BE"),this._readNumberValue(Buffer.prototype.readBigInt64BE,8,e)}readBigInt64LE(e){return r.bigIntAndBufferInt64Check("readBigInt64LE"),this._readNumberValue(Buffer.prototype.readBigInt64LE,8,e)}writeInt8(e,A){return this._writeNumberValue(Buffer.prototype.writeInt8,1,e,A),this}insertInt8(e,A){return this._insertNumberValue(Buffer.prototype.writeInt8,1,e,A)}writeInt16BE(e,A){return this._writeNumberValue(Buffer.prototype.writeInt16BE,2,e,A)}insertInt16BE(e,A){return this._insertNumberValue(Buffer.prototype.writeInt16BE,2,e,A)}writeInt16LE(e,A){return this._writeNumberValue(Buffer.prototype.writeInt16LE,2,e,A)}insertInt16LE(e,A){return this._insertNumberValue(Buffer.prototype.writeInt16LE,2,e,A)}writeInt32BE(e,A){return this._writeNumberValue(Buffer.prototype.writeInt32BE,4,e,A)}insertInt32BE(e,A){return this._insertNumberValue(Buffer.prototype.writeInt32BE,4,e,A)}writeInt32LE(e,A){return this._writeNumberValue(Buffer.prototype.writeInt32LE,4,e,A)}insertInt32LE(e,A){return this._insertNumberValue(Buffer.prototype.writeInt32LE,4,e,A)}writeBigInt64BE(e,A){return r.bigIntAndBufferInt64Check("writeBigInt64BE"),this._writeNumberValue(Buffer.prototype.writeBigInt64BE,8,e,A)}insertBigInt64BE(e,A){return r.bigIntAndBufferInt64Check("writeBigInt64BE"),this._insertNumberValue(Buffer.prototype.writeBigInt64BE,8,e,A)}writeBigInt64LE(e,A){return r.bigIntAndBufferInt64Check("writeBigInt64LE"),this._writeNumberValue(Buffer.prototype.writeBigInt64LE,8,e,A)}insertBigInt64LE(e,A){return r.bigIntAndBufferInt64Check("writeBigInt64LE"),this._insertNumberValue(Buffer.prototype.writeBigInt64LE,8,e,A)}readUInt8(e){return this._readNumberValue(Buffer.prototype.readUInt8,1,e)}readUInt16BE(e){return this._readNumberValue(Buffer.prototype.readUInt16BE,2,e)}readUInt16LE(e){return this._readNumberValue(Buffer.prototype.readUInt16LE,2,e)}readUInt32BE(e){return this._readNumberValue(Buffer.prototype.readUInt32BE,4,e)}readUInt32LE(e){return this._readNumberValue(Buffer.prototype.readUInt32LE,4,e)}readBigUInt64BE(e){return r.bigIntAndBufferInt64Check("readBigUInt64BE"),this._readNumberValue(Buffer.prototype.readBigUInt64BE,8,e)}readBigUInt64LE(e){return r.bigIntAndBufferInt64Check("readBigUInt64LE"),this._readNumberValue(Buffer.prototype.readBigUInt64LE,8,e)}writeUInt8(e,A){return this._writeNumberValue(Buffer.prototype.writeUInt8,1,e,A)}insertUInt8(e,A){return this._insertNumberValue(Buffer.prototype.writeUInt8,1,e,A)}writeUInt16BE(e,A){return this._writeNumberValue(Buffer.prototype.writeUInt16BE,2,e,A)}insertUInt16BE(e,A){return this._insertNumberValue(Buffer.prototype.writeUInt16BE,2,e,A)}writeUInt16LE(e,A){return this._writeNumberValue(Buffer.prototype.writeUInt16LE,2,e,A)}insertUInt16LE(e,A){return this._insertNumberValue(Buffer.prototype.writeUInt16LE,2,e,A)}writeUInt32BE(e,A){return this._writeNumberValue(Buffer.prototype.writeUInt32BE,4,e,A)}insertUInt32BE(e,A){return this._insertNumberValue(Buffer.prototype.writeUInt32BE,4,e,A)}writeUInt32LE(e,A){return this._writeNumberValue(Buffer.prototype.writeUInt32LE,4,e,A)}insertUInt32LE(e,A){return this._insertNumberValue(Buffer.prototype.writeUInt32LE,4,e,A)}writeBigUInt64BE(e,A){return r.bigIntAndBufferInt64Check("writeBigUInt64BE"),this._writeNumberValue(Buffer.prototype.writeBigUInt64BE,8,e,A)}insertBigUInt64BE(e,A){return r.bigIntAndBufferInt64Check("writeBigUInt64BE"),this._insertNumberValue(Buffer.prototype.writeBigUInt64BE,8,e,A)}writeBigUInt64LE(e,A){return r.bigIntAndBufferInt64Check("writeBigUInt64LE"),this._writeNumberValue(Buffer.prototype.writeBigUInt64LE,8,e,A)}insertBigUInt64LE(e,A){return r.bigIntAndBufferInt64Check("writeBigUInt64LE"),this._insertNumberValue(Buffer.prototype.writeBigUInt64LE,8,e,A)}readFloatBE(e){return this._readNumberValue(Buffer.prototype.readFloatBE,4,e)}readFloatLE(e){return this._readNumberValue(Buffer.prototype.readFloatLE,4,e)}writeFloatBE(e,A){return this._writeNumberValue(Buffer.prototype.writeFloatBE,4,e,A)}insertFloatBE(e,A){return this._insertNumberValue(Buffer.prototype.writeFloatBE,4,e,A)}writeFloatLE(e,A){return this._writeNumberValue(Buffer.prototype.writeFloatLE,4,e,A)}insertFloatLE(e,A){return this._insertNumberValue(Buffer.prototype.writeFloatLE,4,e,A)}readDoubleBE(e){return this._readNumberValue(Buffer.prototype.readDoubleBE,8,e)}readDoubleLE(e){return this._readNumberValue(Buffer.prototype.readDoubleLE,8,e)}writeDoubleBE(e,A){return this._writeNumberValue(Buffer.prototype.writeDoubleBE,8,e,A)}insertDoubleBE(e,A){return this._insertNumberValue(Buffer.prototype.writeDoubleBE,8,e,A)}writeDoubleLE(e,A){return this._writeNumberValue(Buffer.prototype.writeDoubleLE,8,e,A)}insertDoubleLE(e,A){return this._insertNumberValue(Buffer.prototype.writeDoubleLE,8,e,A)}readString(e,A){let t;"number"==typeof e?(r.checkLengthValue(e),t=Math.min(e,this.length-this._readOffset)):(A=e,t=this.length-this._readOffset),void 0!==A&&r.checkEncoding(A);let s=this._buff.slice(this._readOffset,this._readOffset+t).toString(A||this._encoding);return this._readOffset+=t,s}insertString(e,A,t){return r.checkOffsetValue(A),this._handleString(e,!0,A,t)}writeString(e,A,t){return this._handleString(e,!1,A,t)}readStringNT(e){void 0!==e&&r.checkEncoding(e);let A=this.length;for(let e=this._readOffset;e<this.length;e++)if(0===this._buff[e]){A=e;break}let t=this._buff.slice(this._readOffset,A);return this._readOffset=A+1,t.toString(e||this._encoding)}insertStringNT(e,A,t){return r.checkOffsetValue(A),this.insertString(e,A,t),this.insertUInt8(0,A+e.length),this}writeStringNT(e,A,t){return this.writeString(e,A,t),this.writeUInt8(0,"number"==typeof A?A+e.length:this.writeOffset),this}readBuffer(e){void 0!==e&&r.checkLengthValue(e);let A="number"==typeof e?e:this.length,t=Math.min(this.length,this._readOffset+A),s=this._buff.slice(this._readOffset,t);return this._readOffset=t,s}insertBuffer(e,A){return r.checkOffsetValue(A),this._handleBuffer(e,!0,A)}writeBuffer(e,A){return this._handleBuffer(e,!1,A)}readBufferNT(){let e=this.length;for(let A=this._readOffset;A<this.length;A++)if(0===this._buff[A]){e=A;break}let A=this._buff.slice(this._readOffset,e);return this._readOffset=e+1,A}insertBufferNT(e,A){return r.checkOffsetValue(A),this.insertBuffer(e,A),this.insertUInt8(0,A+e.length),this}writeBufferNT(e,A){return void 0!==A&&r.checkOffsetValue(A),this.writeBuffer(e,A),this.writeUInt8(0,"number"==typeof A?A+e.length:this._writeOffset),this}clear(){return this._writeOffset=0,this._readOffset=0,this.length=0,this}remaining(){return this.length-this._readOffset}get readOffset(){return this._readOffset}set readOffset(e){r.checkOffsetValue(e),r.checkTargetOffset(e,this),this._readOffset=e}get writeOffset(){return this._writeOffset}set writeOffset(e){r.checkOffsetValue(e),r.checkTargetOffset(e,this),this._writeOffset=e}get encoding(){return this._encoding}set encoding(e){r.checkEncoding(e),this._encoding=e}get internalBuffer(){return this._buff}toBuffer(){return this._buff.slice(0,this.length)}toString(e){let A="string"==typeof e?e:this._encoding;return r.checkEncoding(A),this._buff.toString(A,0,this.length)}destroy(){return this.clear(),this}_handleString(e,A,t,s){let n=this._writeOffset,o=this._encoding;"number"==typeof t?n=t:"string"==typeof t&&(r.checkEncoding(t),o=t),"string"==typeof s&&(r.checkEncoding(s),o=s);let i=Buffer.byteLength(e,o);return A?this.ensureInsertable(i,n):this._ensureWriteable(i,n),this._buff.write(e,n,i,o),A?this._writeOffset+=i:"number"==typeof t?this._writeOffset=Math.max(this._writeOffset,n+i):this._writeOffset+=i,this}_handleBuffer(e,A,t){let r="number"==typeof t?t:this._writeOffset;return A?this.ensureInsertable(e.length,r):this._ensureWriteable(e.length,r),e.copy(this._buff,r),A?this._writeOffset+=e.length:"number"==typeof t?this._writeOffset=Math.max(this._writeOffset,r+e.length):this._writeOffset+=e.length,this}ensureReadable(e,A){let t=this._readOffset;if(void 0!==A&&(r.checkOffsetValue(A),t=A),t<0||t+e>this.length)throw Error(r.ERRORS.INVALID_READ_BEYOND_BOUNDS)}ensureInsertable(e,A){r.checkOffsetValue(A),this._ensureCapacity(this.length+e),A<this.length&&this._buff.copy(this._buff,A+e,A,this._buff.length),A+e>this.length?this.length=A+e:this.length+=e}_ensureWriteable(e,A){let t="number"==typeof A?A:this._writeOffset;this._ensureCapacity(t+e),t+e>this.length&&(this.length=t+e)}_ensureCapacity(e){let A=this._buff.length;if(e>A){let t=this._buff,r=3*A/2+1;r<e&&(r=e),this._buff=Buffer.allocUnsafe(r),t.copy(this._buff,0,0,A)}}_readNumberValue(e,A,t){this.ensureReadable(A,t);let r=e.call(this._buff,"number"==typeof t?t:this._readOffset);return void 0===t&&(this._readOffset+=A),r}_insertNumberValue(e,A,t,s){return r.checkOffsetValue(s),this.ensureInsertable(A,s),e.call(this._buff,t,s),this._writeOffset+=A,this}_writeNumberValue(e,A,t,s){if("number"==typeof s){if(s<0)throw Error(r.ERRORS.INVALID_WRITE_BEYOND_BOUNDS);r.checkOffsetValue(s)}let n="number"==typeof s?s:this._writeOffset;return this._ensureWriteable(A,n),e.call(this._buff,t,n),"number"==typeof s?this._writeOffset=Math.max(this._writeOffset,n+A):this._writeOffset+=A,this}}t.SmartBuffer=s},81762,(e,A,t)=>{"use strict";var r,s,n,o,i,a,l,g,h,c,E,Q;Object.defineProperty(t,"__esModule",{value:!0}),t.SOCKS5_NO_ACCEPTABLE_AUTH=t.SOCKS5_CUSTOM_AUTH_END=t.SOCKS5_CUSTOM_AUTH_START=t.SOCKS_INCOMING_PACKET_SIZES=t.SocksClientState=t.Socks5Response=t.Socks5HostType=t.Socks5Auth=t.Socks4Response=t.SocksCommand=t.ERRORS=t.DEFAULT_TIMEOUT=void 0,t.DEFAULT_TIMEOUT=3e4,t.ERRORS={InvalidSocksCommand:"An invalid SOCKS command was provided. Valid options are connect, bind, and associate.",InvalidSocksCommandForOperation:"An invalid SOCKS command was provided. Only a subset of commands are supported for this operation.",InvalidSocksCommandChain:"An invalid SOCKS command was provided. Chaining currently only supports the connect command.",InvalidSocksClientOptionsDestination:"An invalid destination host was provided.",InvalidSocksClientOptionsExistingSocket:"An invalid existing socket was provided. This should be an instance of stream.Duplex.",InvalidSocksClientOptionsProxy:"Invalid SOCKS proxy details were provided.",InvalidSocksClientOptionsTimeout:"An invalid timeout value was provided. Please enter a value above 0 (in ms).",InvalidSocksClientOptionsProxiesLength:"At least two socks proxies must be provided for chaining.",InvalidSocksClientOptionsCustomAuthRange:"Custom auth must be a value between 0x80 and 0xFE.",InvalidSocksClientOptionsCustomAuthOptions:"When a custom_auth_method is provided, custom_auth_request_handler, custom_auth_response_size, and custom_auth_response_handler must also be provided and valid.",NegotiationError:"Negotiation error",SocketClosed:"Socket closed",ProxyConnectionTimedOut:"Proxy connection timed out",InternalError:"SocksClient internal error (this should not happen)",InvalidSocks4HandshakeResponse:"Received invalid Socks4 handshake response",Socks4ProxyRejectedConnection:"Socks4 Proxy rejected connection",InvalidSocks4IncomingConnectionResponse:"Socks4 invalid incoming connection response",Socks4ProxyRejectedIncomingBoundConnection:"Socks4 Proxy rejected incoming bound connection",InvalidSocks5InitialHandshakeResponse:"Received invalid Socks5 initial handshake response",InvalidSocks5IntiailHandshakeSocksVersion:"Received invalid Socks5 initial handshake (invalid socks version)",InvalidSocks5InitialHandshakeNoAcceptedAuthType:"Received invalid Socks5 initial handshake (no accepted authentication type)",InvalidSocks5InitialHandshakeUnknownAuthType:"Received invalid Socks5 initial handshake (unknown authentication type)",Socks5AuthenticationFailed:"Socks5 Authentication failed",InvalidSocks5FinalHandshake:"Received invalid Socks5 final handshake response",InvalidSocks5FinalHandshakeRejected:"Socks5 proxy rejected connection",InvalidSocks5IncomingConnectionResponse:"Received invalid Socks5 incoming connection response",Socks5ProxyRejectedIncomingBoundConnection:"Socks5 Proxy rejected incoming bound connection"},t.SOCKS_INCOMING_PACKET_SIZES={Socks5InitialHandshakeResponse:2,Socks5UserPassAuthenticationResponse:2,Socks5ResponseHeader:5,Socks5ResponseIPv4:10,Socks5ResponseIPv6:22,Socks5ResponseHostname:e=>e+7,Socks4Response:8},(l=r||(t.SocksCommand=r={}))[l.connect=1]="connect",l[l.bind=2]="bind",l[l.associate=3]="associate",(g=s||(t.Socks4Response=s={}))[g.Granted=90]="Granted",g[g.Failed=91]="Failed",g[g.Rejected=92]="Rejected",g[g.RejectedIdent=93]="RejectedIdent",(h=n||(t.Socks5Auth=n={}))[h.NoAuth=0]="NoAuth",h[h.GSSApi=1]="GSSApi",h[h.UserPass=2]="UserPass",t.SOCKS5_CUSTOM_AUTH_START=128,t.SOCKS5_CUSTOM_AUTH_END=254,t.SOCKS5_NO_ACCEPTABLE_AUTH=255,(c=o||(t.Socks5Response=o={}))[c.Granted=0]="Granted",c[c.Failure=1]="Failure",c[c.NotAllowed=2]="NotAllowed",c[c.NetworkUnreachable=3]="NetworkUnreachable",c[c.HostUnreachable=4]="HostUnreachable",c[c.ConnectionRefused=5]="ConnectionRefused",c[c.TTLExpired=6]="TTLExpired",c[c.CommandNotSupported=7]="CommandNotSupported",c[c.AddressNotSupported=8]="AddressNotSupported",(E=i||(t.Socks5HostType=i={}))[E.IPv4=1]="IPv4",E[E.Hostname=3]="Hostname",E[E.IPv6=4]="IPv6",(Q=a||(t.SocksClientState=a={}))[Q.Created=0]="Created",Q[Q.Connecting=1]="Connecting",Q[Q.Connected=2]="Connected",Q[Q.SentInitialHandshake=3]="SentInitialHandshake",Q[Q.ReceivedInitialHandshakeResponse=4]="ReceivedInitialHandshakeResponse",Q[Q.SentAuthentication=5]="SentAuthentication",Q[Q.ReceivedAuthenticationResponse=6]="ReceivedAuthenticationResponse",Q[Q.SentFinalHandshake=7]="SentFinalHandshake",Q[Q.ReceivedFinalResponse=8]="ReceivedFinalResponse",Q[Q.BoundWaitingForConnection=9]="BoundWaitingForConnection",Q[Q.Established=10]="Established",Q[Q.Disconnected=11]="Disconnected",Q[Q.Error=99]="Error"},188286,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shuffleArray=t.SocksClientError=void 0,t.SocksClientError=class extends Error{constructor(e,A){super(e),this.options=A}},t.shuffleArray=function(e){for(let A=e.length-1;A>0;A--){let t=Math.floor(Math.random()*(A+1));[e[A],e[t]]=[e[t],e[A]]}}},923764,(e,A,t)=>{"use strict";function r(e){return e.toString(16).padStart(2,"0")}Object.defineProperty(t,"__esModule",{value:!0}),t.isInSubnet=function(e){return!(this.subnetMask<e.subnetMask)&&this.mask(e.subnetMask)===e.mask()},t.isCorrect=function(e){return function(){return this.addressMinusSuffix===this.correctForm()&&(this.subnetMask===e&&!this.parsedSubnet||this.parsedSubnet===String(this.subnetMask))}},t.numberToPaddedHex=r,t.stringToPaddedHex=function(e){return r(parseInt(e,10))},t.testBit=function(e,A){let{length:t}=e;if(A>t)return!1;let r=t-A;return"1"===e.substring(r,r+1)}},103696,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RE_SUBNET_STRING=t.RE_ADDRESS=t.GROUPS=t.BITS=void 0,t.BITS=32,t.GROUPS=4,t.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g,t.RE_SUBNET_STRING=/\/\d{1,2}$/},157271,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AddressError=void 0,t.AddressError=class extends Error{constructor(e,A){super(e),this.name="AddressError",this.parseMessage=A}}},6860,(e,A,t)=>{"use strict";var r=e.e&&e.e.__createBinding||(Object.create?function(e,A,t,r){void 0===r&&(r=t);var s=Object.getOwnPropertyDescriptor(A,t);(!s||("get"in s?!A.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,s)}:function(e,A,t,r){void 0===r&&(r=t),e[r]=A[t]}),s=e.e&&e.e.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),n=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&r(A,e,t);return s(A,e),A};Object.defineProperty(t,"__esModule",{value:!0}),t.Address4=void 0;let o=n(e.r(923764)),i=n(e.r(103696)),a=e.r(157271);class l{constructor(e){this.groups=i.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=o.isCorrect(i.BITS),this.isInSubnet=o.isInSubnet,this.address=e;const A=i.RE_SUBNET_STRING.exec(e);if(A){if(this.parsedSubnet=A[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>i.BITS)throw new a.AddressError("Invalid subnet mask.");e=e.replace(i.RE_SUBNET_STRING,"")}this.addressMinusSuffix=e,this.parsedAddress=this.parse(e)}static isValid(e){try{return new l(e),!0}catch(e){return!1}}parse(e){let A=e.split(".");if(!e.match(i.RE_ADDRESS))throw new a.AddressError("Invalid IPv4 address.");return A}correctForm(){return this.parsedAddress.map(e=>parseInt(e,10)).join(".")}static fromHex(e){let A,t=e.replace(/:/g,"").padStart(8,"0"),r=[];for(A=0;A<8;A+=2){let e=t.slice(A,A+2);r.push(parseInt(e,16))}return new l(r.join("."))}static fromInteger(e){return l.fromHex(e.toString(16))}static fromArpa(e){return new l(e.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join("."))}toHex(){return this.parsedAddress.map(e=>o.stringToPaddedHex(e)).join(":")}toArray(){return this.parsedAddress.map(e=>parseInt(e,10))}toGroup6(){let e,A=[];for(e=0;e<i.GROUPS;e+=2)A.push(`${o.stringToPaddedHex(this.parsedAddress[e])}${o.stringToPaddedHex(this.parsedAddress[e+1])}`);return A.join(":")}bigInt(){return BigInt(`0x${this.parsedAddress.map(e=>o.stringToPaddedHex(e)).join("")}`)}_startAddress(){return BigInt(`0b${this.mask()+"0".repeat(i.BITS-this.subnetMask)}`)}startAddress(){return l.fromBigInt(this._startAddress())}startAddressExclusive(){let e=BigInt("1");return l.fromBigInt(this._startAddress()+e)}_endAddress(){return BigInt(`0b${this.mask()+"1".repeat(i.BITS-this.subnetMask)}`)}endAddress(){return l.fromBigInt(this._endAddress())}endAddressExclusive(){let e=BigInt("1");return l.fromBigInt(this._endAddress()-e)}static fromBigInt(e){return l.fromHex(e.toString(16))}static fromByteArray(e){if(4!==e.length)throw new a.AddressError("IPv4 addresses require exactly 4 bytes");for(let A=0;A<e.length;A++)if(!Number.isInteger(e[A])||e[A]<0||e[A]>255)throw new a.AddressError("All bytes must be integers between 0 and 255");return this.fromUnsignedByteArray(e)}static fromUnsignedByteArray(e){if(4!==e.length)throw new a.AddressError("IPv4 addresses require exactly 4 bytes");return new l(e.join("."))}mask(e){return void 0===e&&(e=this.subnetMask),this.getBitsBase2(0,e)}getBitsBase2(e,A){return this.binaryZeroPad().slice(e,A)}reverseForm(e){e||(e={});let A=this.correctForm().split(".").reverse().join(".");return e.omitSuffix?A:`${A}.in-addr.arpa.`}isMulticast(){return this.isInSubnet(new l("224.0.0.0/4"))}binaryZeroPad(){return this.bigInt().toString(2).padStart(i.BITS,"0")}groupForV6(){let e=this.parsedAddress;return this.address.replace(i.RE_ADDRESS,`<span class="hover-group group-v4 group-6">${e.slice(0,2).join(".")}</span>.<span class="hover-group group-v4 group-7">${e.slice(2,4).join(".")}</span>`)}}t.Address4=l},419123,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RE_URL_WITH_PORT=t.RE_URL=t.RE_ZONE_STRING=t.RE_SUBNET_STRING=t.RE_BAD_ADDRESS=t.RE_BAD_CHARACTERS=t.TYPES=t.SCOPES=t.GROUPS=t.BITS=void 0,t.BITS=128,t.GROUPS=8,t.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},t.TYPES={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"},t.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi,t.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,t.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/,t.RE_ZONE_STRING=/%.*$/,t.RE_URL=/^\[{0,1}([0-9a-f:]+)\]{0,1}/,t.RE_URL_WITH_PORT=/\[([0-9a-f:]+)\]:([0-9]{1,5})/},204767,(e,A,t)=>{"use strict";function r(e){return e.replace(/(0+)/g,'<span class="zero">$1</span>')}function s(e){return e.replace(/^(0+)/,'<span class="zero">$1</span>')}Object.defineProperty(t,"__esModule",{value:!0}),t.spanAllZeroes=r,t.spanAll=function(e,A=0){return e.split("").map((e,t)=>`<span class="digit value-${e} position-${t+A}">${r(e)}</span>`).join("")},t.spanLeadingZeroes=function(e){return e.split(":").map(e=>s(e)).join(":")},t.simpleGroup=function(e,A=0){return e.split(":").map((e,t)=>/group-v4/.test(e)?e:`<span class="hover-group group-${t+A}">${s(e)}</span>`)}},137019,(e,A,t)=>{"use strict";var r=e.e&&e.e.__createBinding||(Object.create?function(e,A,t,r){void 0===r&&(r=t);var s=Object.getOwnPropertyDescriptor(A,t);(!s||("get"in s?!A.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,s)}:function(e,A,t,r){void 0===r&&(r=t),e[r]=A[t]}),s=e.e&&e.e.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),n=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&r(A,e,t);return s(A,e),A};Object.defineProperty(t,"__esModule",{value:!0}),t.ADDRESS_BOUNDARY=void 0,t.groupPossibilities=i,t.padGroup=a,t.simpleRegularExpression=function(e){let A=[];e.forEach((e,t)=>{0===parseInt(e,16)&&A.push(t)});let t=A.map(A=>e.map((e,t)=>{if(t===A){let A=0===t||t===o.GROUPS-1?":":"";return i([a(e),A])}return a(e)}).join(":"));return t.push(e.map(a).join(":")),i(t)},t.possibleElisions=function(e,A,t){let r=[];A||t||r.push("::"),A&&t&&r.push(""),(t&&!A||!t&&A)&&r.push(":"),r.push(`${A?"":":"}(:0{1,4}){1,${e-1}}`),r.push(`(0{1,4}:){1,${e-1}}${t?"":":"}`),r.push(`(0{1,4}:){${e-1}}0{1,4}`);for(let A=1;A<e-1;A++)for(let t=1;t<e-A;t++)r.push(`(0{1,4}:){${t}}:(0{1,4}:){${e-t-A-1}}0{1,4}`);return i(r)};let o=n(e.r(419123));function i(e){return`(${e.join("|")})`}function a(e){return e.length<4?`0{0,${4-e.length}}${e}`:e}t.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]"},707875,(e,A,t)=>{"use strict";var r=e.e&&e.e.__createBinding||(Object.create?function(e,A,t,r){void 0===r&&(r=t);var s=Object.getOwnPropertyDescriptor(A,t);(!s||("get"in s?!A.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,s)}:function(e,A,t,r){void 0===r&&(r=t),e[r]=A[t]}),s=e.e&&e.e.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),n=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&r(A,e,t);return s(A,e),A};Object.defineProperty(t,"__esModule",{value:!0}),t.Address6=void 0;let o=n(e.r(923764)),i=n(e.r(103696)),a=n(e.r(419123)),l=n(e.r(204767)),g=e.r(6860),h=e.r(137019),c=e.r(157271),E=e.r(923764);function Q(e){if(!e)throw Error("Assertion failed.")}function u(e){return(e=e.replace(/^(0{1,})([1-9]+)$/,'<span class="parse-error">$1</span>$2')).replace(/^(0{1,})(0)$/,'<span class="parse-error">$1</span>$2')}function I(e){return parseInt(e,16).toString(16).padStart(4,"0")}function B(e){return 255&e}class C{constructor(e,A){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=o.isInSubnet,this.isCorrect=o.isCorrect(a.BITS),void 0===A?this.groups=a.GROUPS:this.groups=A,this.address=e;const t=a.RE_SUBNET_STRING.exec(e);if(t){if(this.parsedSubnet=t[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>a.BITS)throw new c.AddressError("Invalid subnet mask.");e=e.replace(a.RE_SUBNET_STRING,"")}else if(/\//.test(e))throw new c.AddressError("Invalid subnet mask.");const r=a.RE_ZONE_STRING.exec(e);r&&(this.zone=r[0],e=e.replace(a.RE_ZONE_STRING,"")),this.addressMinusSuffix=e,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(e){try{return new C(e),!0}catch(e){return!1}}static fromBigInt(e){let A,t=e.toString(16).padStart(32,"0"),r=[];for(A=0;A<a.GROUPS;A++)r.push(t.slice(4*A,(A+1)*4));return new C(r.join(":"))}static fromURL(e){let A,t,r=null;if(-1!==e.indexOf("[")&&-1!==e.indexOf("]:")){if(null===(t=a.RE_URL_WITH_PORT.exec(e)))return{error:"failed to parse address with port",address:null,port:null};A=t[1],r=t[2]}else if(-1!==e.indexOf("/")){if(e=e.replace(/^[a-z0-9]+:\/\//,""),null===(t=a.RE_URL.exec(e)))return{error:"failed to parse address from URL",address:null,port:null};A=t[1]}else A=e;return r?((r=parseInt(r,10))<0||r>65536)&&(r=null):r=null,{address:new C(A),port:r}}static fromAddress4(e){let A=new g.Address4(e),t=a.BITS-(i.BITS-A.subnetMask);return new C(`::ffff:${A.correctForm()}/${t}`)}static fromArpa(e){let A=e.replace(/(\.ip6\.arpa)?\.$/,"");if(63!==A.length)throw new c.AddressError("Invalid 'ip6.arpa' form.");let t=A.split(".").reverse();for(let e=7;e>0;e--){let A=4*e;t.splice(A,0,":")}return new C(A=t.join(""))}microsoftTranscription(){return`${this.correctForm().replace(/:/g,"-")}.ipv6-literal.net`}mask(e=this.subnetMask){return this.getBitsBase2(0,e)}possibleSubnets(e=128){let A=a.BITS-this.subnetMask-Math.abs(e-a.BITS);if(A<0)return"0";var t=(BigInt("2")**BigInt(A)).toString(10);let r=/(\d+)(\d{3})/;for(;r.test(t);)t=t.replace(r,"$1,$2");return t}_startAddress(){return BigInt(`0b${this.mask()+"0".repeat(a.BITS-this.subnetMask)}`)}startAddress(){return C.fromBigInt(this._startAddress())}startAddressExclusive(){let e=BigInt("1");return C.fromBigInt(this._startAddress()+e)}_endAddress(){return BigInt(`0b${this.mask()+"1".repeat(a.BITS-this.subnetMask)}`)}endAddress(){return C.fromBigInt(this._endAddress())}endAddressExclusive(){let e=BigInt("1");return C.fromBigInt(this._endAddress()-e)}getScope(){let e=a.SCOPES[parseInt(this.getBits(12,16).toString(10),10)];return"Global unicast"===this.getType()&&"Link local"!==e&&(e="Global"),e||"Unknown"}getType(){for(let e of Object.keys(a.TYPES))if(this.isInSubnet(new C(e)))return a.TYPES[e];return"Global unicast"}getBits(e,A){return BigInt(`0b${this.getBitsBase2(e,A)}`)}getBitsBase2(e,A){return this.binaryZeroPad().slice(e,A)}getBitsBase16(e,A){let t=A-e;if(t%4!=0)throw Error("Length of bits to retrieve must be divisible by four");return this.getBits(e,A).toString(16).padStart(t/4,"0")}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,a.BITS)}reverseForm(e){e||(e={});let A=Math.floor(this.subnetMask/4),t=this.canonicalForm().replace(/:/g,"").split("").slice(0,A).reverse().join(".");return A>0?e.omitSuffix?t:`${t}.ip6.arpa.`:e.omitSuffix?"":"ip6.arpa."}correctForm(){let e,A=[],t=0,r=[];for(e=0;e<this.parsedAddress.length;e++){let A=parseInt(this.parsedAddress[e],16);0===A&&t++,0!==A&&t>0&&(t>1&&r.push([e-t,e-1]),t=0)}t>1&&r.push([this.parsedAddress.length-t,this.parsedAddress.length-1]);let s=r.map(e=>e[1]-e[0]+1);if(r.length>0){let e=s.indexOf(Math.max(...s));A=function(e,A){let t,r=[],s=[];for(t=0;t<e.length;t++)t<A[0]?r.push(e[t]):t>A[1]&&s.push(e[t]);return r.concat(["compact"]).concat(s)}(this.parsedAddress,r[e])}else A=this.parsedAddress;for(e=0;e<A.length;e++)"compact"!==A[e]&&(A[e]=parseInt(A[e],16).toString(16));let n=A.join(":");return(n=(n=n.replace(/^compact$/,"::")).replace(/(^compact)|(compact$)/,":")).replace(/compact/,"")}binaryZeroPad(){return this.bigInt().toString(2).padStart(a.BITS,"0")}parse4in6(e){let A=e.split(":"),t=A.slice(-1)[0].match(i.RE_ADDRESS);if(t){this.parsedAddress4=t[0],this.address4=new g.Address4(this.parsedAddress4);for(let A=0;A<this.address4.groups;A++)if(/^0[0-9]+/.test(this.address4.parsedAddress[A]))throw new c.AddressError("IPv4 addresses can't have leading zeroes.",e.replace(i.RE_ADDRESS,this.address4.parsedAddress.map(u).join(".")));this.v4=!0,A[A.length-1]=this.address4.toGroup6(),e=A.join(":")}return e}parse(e){let A=(e=this.parse4in6(e)).match(a.RE_BAD_CHARACTERS);if(A)throw new c.AddressError(`Bad character${A.length>1?"s":""} detected in address: ${A.join("")}`,e.replace(a.RE_BAD_CHARACTERS,'<span class="parse-error">$1</span>'));let t=e.match(a.RE_BAD_ADDRESS);if(t)throw new c.AddressError(`Address failed regex: ${t.join("")}`,e.replace(a.RE_BAD_ADDRESS,'<span class="parse-error">$1</span>'));let r=[],s=e.split("::");if(2===s.length){let e=s[0].split(":"),A=s[1].split(":");1===e.length&&""===e[0]&&(e=[]),1===A.length&&""===A[0]&&(A=[]);let t=this.groups-(e.length+A.length);if(!t)throw new c.AddressError("Error parsing groups");this.elidedGroups=t,this.elisionBegin=e.length,this.elisionEnd=e.length+this.elidedGroups,r=r.concat(e);for(let e=0;e<t;e++)r.push("0");r=r.concat(A)}else if(1===s.length)r=e.split(":"),this.elidedGroups=0;else throw new c.AddressError("Too many :: groups found");if((r=r.map(e=>parseInt(e,16).toString(16))).length!==this.groups)throw new c.AddressError("Incorrect number of groups found");return r}canonicalForm(){return this.parsedAddress.map(I).join(":")}decimal(){return this.parsedAddress.map(e=>parseInt(e,16).toString(10).padStart(5,"0")).join(":")}bigInt(){return BigInt(`0x${this.parsedAddress.map(I).join("")}`)}to4(){let e=this.binaryZeroPad().split("");return g.Address4.fromHex(BigInt(`0b${e.slice(96,128).join("")}`).toString(16))}to4in6(){let e=this.to4(),A=new C(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),t="";return/:$/.test(A)||(t=":"),A+t+e.address}inspectTeredo(){let e=this.getBitsBase16(0,32),A=(this.getBits(80,96)^BigInt("0xffff")).toString(),t=g.Address4.fromHex(this.getBitsBase16(32,64)),r=this.getBits(96,128),s=g.Address4.fromHex((r^BigInt("0xffffffff")).toString(16)),n=this.getBitsBase2(64,80),o=(0,E.testBit)(n,15),i=(0,E.testBit)(n,14),a=(0,E.testBit)(n,8),l=(0,E.testBit)(n,9),h=BigInt(`0b${n.slice(2,6)+n.slice(8,16)}`).toString(10);return{prefix:`${e.slice(0,4)}:${e.slice(4,8)}`,server4:t.address,client4:s.address,flags:n,coneNat:o,microsoft:{reserved:i,universalLocal:l,groupIndividual:a,nonce:h},udpPort:A}}inspect6to4(){let e=this.getBitsBase16(0,16),A=g.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:e.slice(0,4),gateway:A.address}}to6to4(){return this.is4()?new C(["2002",this.getBitsBase16(96,112),this.getBitsBase16(112,128),":/16"].join(":")):null}toByteArray(){let e=this.bigInt().toString(16),A="0".repeat(e.length%2),t=`${A}${e}`,r=[];for(let e=0,A=t.length;e<A;e+=2)r.push(parseInt(t.substring(e,e+2),16));return r}toUnsignedByteArray(){return this.toByteArray().map(B)}static fromByteArray(e){return this.fromUnsignedByteArray(e.map(B))}static fromUnsignedByteArray(e){let A=BigInt("256"),t=BigInt("0"),r=BigInt("1");for(let s=e.length-1;s>=0;s--)t+=r*BigInt(e[s].toString(10)),r*=A;return C.fromBigInt(t)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return"1111111010000000000000000000000000000000000000000000000000000000"===this.getBitsBase2(0,64)}isMulticast(){return"Multicast"===this.getType()}is4(){return this.v4}isTeredo(){return this.isInSubnet(new C("2001::/32"))}is6to4(){return this.isInSubnet(new C("2002::/16"))}isLoopback(){return"Loopback"===this.getType()}href(e){return e=void 0===e?"":`:${e}`,`http://[${this.correctForm()}]${e}/`}link(e){e||(e={}),void 0===e.className&&(e.className=""),void 0===e.prefix&&(e.prefix="/#address="),void 0===e.v4&&(e.v4=!1);let A=this.correctForm;e.v4&&(A=this.to4in6);let t=A.call(this);return e.className?`<a href="${e.prefix}${t}" class="${e.className}">${t}</a>`:`<a href="${e.prefix}${t}">${t}</a>`}group(){if(0===this.elidedGroups)return l.simpleGroup(this.address).join(":");Q("number"==typeof this.elidedGroups),Q("number"==typeof this.elisionBegin);let e=[],[A,t]=this.address.split("::");A.length?e.push(...l.simpleGroup(A)):e.push("");let r=["hover-group"];for(let e=this.elisionBegin;e<this.elisionBegin+this.elidedGroups;e++)r.push(`group-${e}`);return e.push(`<span class="${r.join(" ")}"></span>`),t.length?e.push(...l.simpleGroup(t,this.elisionEnd)):e.push(""),this.is4()&&(Q(this.address4 instanceof g.Address4),e.pop(),e.push(this.address4.groupForV6())),e.join(":")}regularExpressionString(e=!1){let A=[],t=new C(this.correctForm());if(0===t.elidedGroups)A.push((0,h.simpleRegularExpression)(t.parsedAddress));else if(t.elidedGroups===a.GROUPS)A.push((0,h.possibleElisions)(a.GROUPS));else{let e=t.address.split("::");e[0].length&&A.push((0,h.simpleRegularExpression)(e[0].split(":"))),Q("number"==typeof t.elidedGroups),A.push((0,h.possibleElisions)(t.elidedGroups,0!==e[0].length,0!==e[1].length)),e[1].length&&A.push((0,h.simpleRegularExpression)(e[1].split(":"))),A=[A.join(":")]}return e||(A=["(?=^|",h.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...A,")(?=[^\\w\\:]|",h.ADDRESS_BOUNDARY,"|$)"]),A.join("")}regularExpression(e=!1){return RegExp(this.regularExpressionString(e),"i")}}t.Address6=C},855389,(e,A,t)=>{"use strict";var r=e.e&&e.e.__createBinding||(Object.create?function(e,A,t,r){void 0===r&&(r=t);var s=Object.getOwnPropertyDescriptor(A,t);(!s||("get"in s?!A.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,s)}:function(e,A,t,r){void 0===r&&(r=t),e[r]=A[t]}),s=e.e&&e.e.__setModuleDefault||(Object.create?function(e,A){Object.defineProperty(e,"default",{enumerable:!0,value:A})}:function(e,A){e.default=A}),n=e.e&&e.e.__importStar||function(e){if(e&&e.__esModule)return e;var A={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&r(A,e,t);return s(A,e),A};Object.defineProperty(t,"__esModule",{value:!0}),t.v6=t.AddressError=t.Address6=t.Address4=void 0;var o=e.r(6860);Object.defineProperty(t,"Address4",{enumerable:!0,get:function(){return o.Address4}});var i=e.r(707875);Object.defineProperty(t,"Address6",{enumerable:!0,get:function(){return i.Address6}});var a=e.r(157271);Object.defineProperty(t,"AddressError",{enumerable:!0,get:function(){return a.AddressError}}),t.v6={helpers:n(e.r(204767))}},667906,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ipToBuffer=t.int32ToIpv4=t.ipv4ToInt32=t.validateSocksClientChainOptions=t.validateSocksClientOptions=void 0;let r=e.r(188286),s=e.r(81762),n=e.r(688947),o=e.r(855389),i=e.r(504446);function a(e,A){if(void 0!==e.custom_auth_method){if(e.custom_auth_method<s.SOCKS5_CUSTOM_AUTH_START||e.custom_auth_method>s.SOCKS5_CUSTOM_AUTH_END)throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsCustomAuthRange,A);if(void 0===e.custom_auth_request_handler||"function"!=typeof e.custom_auth_request_handler||void 0===e.custom_auth_response_size||void 0===e.custom_auth_response_handler||"function"!=typeof e.custom_auth_response_handler)throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsCustomAuthOptions,A)}}function l(e){return e&&"string"==typeof e.host&&256>Buffer.byteLength(e.host)&&"number"==typeof e.port&&e.port>=0&&e.port<=65535}function g(e){return e&&("string"==typeof e.host||"string"==typeof e.ipaddress)&&"number"==typeof e.port&&e.port>=0&&e.port<=65535&&(4===e.type||5===e.type)}function h(e){return"number"==typeof e&&e>0}t.validateSocksClientOptions=function(e,A=["connect","bind","associate"]){if(!s.SocksCommand[e.command])throw new r.SocksClientError(s.ERRORS.InvalidSocksCommand,e);if(-1===A.indexOf(e.command))throw new r.SocksClientError(s.ERRORS.InvalidSocksCommandForOperation,e);if(!l(e.destination))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsDestination,e);if(!g(e.proxy))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsProxy,e);if(a(e.proxy,e),e.timeout&&!h(e.timeout))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsTimeout,e);if(e.existing_socket&&!(e.existing_socket instanceof n.Duplex))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsExistingSocket,e)},t.validateSocksClientChainOptions=function(e){if("connect"!==e.command)throw new r.SocksClientError(s.ERRORS.InvalidSocksCommandChain,e);if(!l(e.destination))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsDestination,e);if(!(e.proxies&&Array.isArray(e.proxies)&&e.proxies.length>=2))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsProxiesLength,e);if(e.proxies.forEach(A=>{if(!g(A))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsProxy,e);a(A,e)}),e.timeout&&!h(e.timeout))throw new r.SocksClientError(s.ERRORS.InvalidSocksClientOptionsTimeout,e)},t.ipv4ToInt32=function(e){return new o.Address4(e).toArray().reduce((e,A)=>(e<<8)+A,0)>>>0},t.int32ToIpv4=function(e){return[e>>>24&255,e>>>16&255,e>>>8&255,255&e].join(".")},t.ipToBuffer=function(e){if(i.isIPv4(e)){let A=new o.Address4(e);return Buffer.from(A.toArray())}if(i.isIPv6(e)){let A=new o.Address6(e);return Buffer.from(A.canonicalForm().split(":").map(e=>e.padStart(4,"0")).join(""),"hex")}throw Error("Invalid IP address format")}},801900,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ReceiveBuffer=void 0,t.ReceiveBuffer=class{constructor(e=4096){this.buffer=Buffer.allocUnsafe(e),this.offset=0,this.originalSize=e}get length(){return this.offset}append(e){if(!Buffer.isBuffer(e))throw Error("Attempted to append a non-buffer instance to ReceiveBuffer.");if(this.offset+e.length>=this.buffer.length){let A=this.buffer;this.buffer=Buffer.allocUnsafe(Math.max(this.buffer.length+this.originalSize,this.buffer.length+e.length)),A.copy(this.buffer)}return e.copy(this.buffer,this.offset),this.offset+=e.length}peek(e){if(e>this.offset)throw Error("Attempted to read beyond the bounds of the managed internal data.");return this.buffer.slice(0,e)}get(e){if(e>this.offset)throw Error("Attempted to read beyond the bounds of the managed internal data.");let A=Buffer.allocUnsafe(e);return this.buffer.slice(0,e).copy(A),this.buffer.copyWithin(0,e,e+this.offset-e),this.offset-=e,A}}},23052,(e,A,t)=>{"use strict";var r=e.e&&e.e.__awaiter||function(e,A,t,r){return new(t||(t=Promise))(function(s,n){function o(e){try{a(r.next(e))}catch(e){n(e)}}function i(e){try{a(r.throw(e))}catch(e){n(e)}}function a(e){var A;e.done?s(e.value):((A=e.value)instanceof t?A:new t(function(e){e(A)})).then(o,i)}a((r=r.apply(e,A||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.SocksClientError=t.SocksClient=void 0;let s=e.r(427699),n=e.r(504446),o=e.r(102372),i=e.r(81762),a=e.r(667906),l=e.r(801900),g=e.r(188286);Object.defineProperty(t,"SocksClientError",{enumerable:!0,get:function(){return g.SocksClientError}});let h=e.r(855389);class c extends s.EventEmitter{constructor(e){super(),this.options=Object.assign({},e),(0,a.validateSocksClientOptions)(e),this.setState(i.SocksClientState.Created)}static createConnection(e,A){return new Promise((t,r)=>{try{(0,a.validateSocksClientOptions)(e,["connect"])}catch(e){if("function"==typeof A)return A(e),t(e);return r(e)}let s=new c(e);s.connect(e.existing_socket),s.once("established",e=>{s.removeAllListeners(),"function"==typeof A&&A(null,e),t(e)}),s.once("error",e=>{s.removeAllListeners(),"function"==typeof A?(A(e),t(e)):r(e)})})}static createConnectionChain(e,A){return new Promise((t,s)=>r(this,void 0,void 0,function*(){try{(0,a.validateSocksClientChainOptions)(e)}catch(e){if("function"==typeof A)return A(e),t(e);return s(e)}e.randomizeChain&&(0,g.shuffleArray)(e.proxies);try{let r;for(let A=0;A<e.proxies.length;A++){let t=e.proxies[A],s=A===e.proxies.length-1?e.destination:{host:e.proxies[A+1].host||e.proxies[A+1].ipaddress,port:e.proxies[A+1].port},n=yield c.createConnection({command:"connect",proxy:t,destination:s,existing_socket:r});r=r||n.socket}"function"==typeof A&&A(null,{socket:r}),t({socket:r})}catch(e){"function"==typeof A?(A(e),t(e)):s(e)}}))}static createUDPFrame(e){let A=new o.SmartBuffer;return A.writeUInt16BE(0),A.writeUInt8(e.frameNumber||0),n.isIPv4(e.remoteHost.host)?(A.writeUInt8(i.Socks5HostType.IPv4),A.writeUInt32BE((0,a.ipv4ToInt32)(e.remoteHost.host))):n.isIPv6(e.remoteHost.host)?(A.writeUInt8(i.Socks5HostType.IPv6),A.writeBuffer((0,a.ipToBuffer)(e.remoteHost.host))):(A.writeUInt8(i.Socks5HostType.Hostname),A.writeUInt8(Buffer.byteLength(e.remoteHost.host)),A.writeString(e.remoteHost.host)),A.writeUInt16BE(e.remoteHost.port),A.writeBuffer(e.data),A.toBuffer()}static parseUDPFrame(e){let A=o.SmartBuffer.fromBuffer(e);A.readOffset=2;let t=A.readUInt8(),r=A.readUInt8();return{frameNumber:t,remoteHost:{host:r===i.Socks5HostType.IPv4?(0,a.int32ToIpv4)(A.readUInt32BE()):r===i.Socks5HostType.IPv6?h.Address6.fromByteArray(Array.from(A.readBuffer(16))).canonicalForm():A.readString(A.readUInt8()),port:A.readUInt16BE()},data:A.readBuffer()}}setState(e){this.state!==i.SocksClientState.Error&&(this.state=e)}connect(e){this.onDataReceived=e=>this.onDataReceivedHandler(e),this.onClose=()=>this.onCloseHandler(),this.onError=e=>this.onErrorHandler(e),this.onConnect=()=>this.onConnectHandler();let A=setTimeout(()=>this.onEstablishedTimeout(),this.options.timeout||i.DEFAULT_TIMEOUT);A.unref&&"function"==typeof A.unref&&A.unref(),e?this.socket=e:this.socket=new n.Socket,this.socket.once("close",this.onClose),this.socket.once("error",this.onError),this.socket.once("connect",this.onConnect),this.socket.on("data",this.onDataReceived),this.setState(i.SocksClientState.Connecting),this.receiveBuffer=new l.ReceiveBuffer,e?this.socket.emit("connect"):(this.socket.connect(this.getSocketOptions()),void 0!==this.options.set_tcp_nodelay&&null!==this.options.set_tcp_nodelay&&this.socket.setNoDelay(!!this.options.set_tcp_nodelay)),this.prependOnceListener("established",e=>{setImmediate(()=>{if(this.receiveBuffer.length>0){let A=this.receiveBuffer.get(this.receiveBuffer.length);e.socket.emit("data",A)}e.socket.resume()})})}getSocketOptions(){return Object.assign(Object.assign({},this.options.socket_options),{host:this.options.proxy.host||this.options.proxy.ipaddress,port:this.options.proxy.port})}onEstablishedTimeout(){this.state!==i.SocksClientState.Established&&this.state!==i.SocksClientState.BoundWaitingForConnection&&this.closeSocket(i.ERRORS.ProxyConnectionTimedOut)}onConnectHandler(){this.setState(i.SocksClientState.Connected),4===this.options.proxy.type?this.sendSocks4InitialHandshake():this.sendSocks5InitialHandshake(),this.setState(i.SocksClientState.SentInitialHandshake)}onDataReceivedHandler(e){this.receiveBuffer.append(e),this.processData()}processData(){for(;this.state!==i.SocksClientState.Established&&this.state!==i.SocksClientState.Error&&this.receiveBuffer.length>=this.nextRequiredPacketBufferSize;)if(this.state===i.SocksClientState.SentInitialHandshake)4===this.options.proxy.type?this.handleSocks4FinalHandshakeResponse():this.handleInitialSocks5HandshakeResponse();else if(this.state===i.SocksClientState.SentAuthentication)this.handleInitialSocks5AuthenticationHandshakeResponse();else if(this.state===i.SocksClientState.SentFinalHandshake)this.handleSocks5FinalHandshakeResponse();else if(this.state===i.SocksClientState.BoundWaitingForConnection)4===this.options.proxy.type?this.handleSocks4IncomingConnectionResponse():this.handleSocks5IncomingConnectionResponse();else{this.closeSocket(i.ERRORS.InternalError);break}}onCloseHandler(){this.closeSocket(i.ERRORS.SocketClosed)}onErrorHandler(e){this.closeSocket(e.message)}removeInternalSocketHandlers(){this.socket.pause(),this.socket.removeListener("data",this.onDataReceived),this.socket.removeListener("close",this.onClose),this.socket.removeListener("error",this.onError),this.socket.removeListener("connect",this.onConnect)}closeSocket(e){this.state!==i.SocksClientState.Error&&(this.setState(i.SocksClientState.Error),this.socket.destroy(),this.removeInternalSocketHandlers(),this.emit("error",new g.SocksClientError(e,this.options)))}sendSocks4InitialHandshake(){let e=this.options.proxy.userId||"",A=new o.SmartBuffer;A.writeUInt8(4),A.writeUInt8(i.SocksCommand[this.options.command]),A.writeUInt16BE(this.options.destination.port),n.isIPv4(this.options.destination.host)?(A.writeBuffer((0,a.ipToBuffer)(this.options.destination.host)),A.writeStringNT(e)):(A.writeUInt8(0),A.writeUInt8(0),A.writeUInt8(0),A.writeUInt8(1),A.writeStringNT(e),A.writeStringNT(this.options.destination.host)),this.nextRequiredPacketBufferSize=i.SOCKS_INCOMING_PACKET_SIZES.Socks4Response,this.socket.write(A.toBuffer())}handleSocks4FinalHandshakeResponse(){let e=this.receiveBuffer.get(8);if(e[1]!==i.Socks4Response.Granted)this.closeSocket(`${i.ERRORS.Socks4ProxyRejectedConnection} - (${i.Socks4Response[e[1]]})`);else if(i.SocksCommand[this.options.command]===i.SocksCommand.bind){let A=o.SmartBuffer.fromBuffer(e);A.readOffset=2;let t={port:A.readUInt16BE(),host:(0,a.int32ToIpv4)(A.readUInt32BE())};"0.0.0.0"===t.host&&(t.host=this.options.proxy.ipaddress),this.setState(i.SocksClientState.BoundWaitingForConnection),this.emit("bound",{remoteHost:t,socket:this.socket})}else this.setState(i.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{socket:this.socket})}handleSocks4IncomingConnectionResponse(){let e=this.receiveBuffer.get(8);if(e[1]!==i.Socks4Response.Granted)this.closeSocket(`${i.ERRORS.Socks4ProxyRejectedIncomingBoundConnection} - (${i.Socks4Response[e[1]]})`);else{let A=o.SmartBuffer.fromBuffer(e);A.readOffset=2;let t={port:A.readUInt16BE(),host:(0,a.int32ToIpv4)(A.readUInt32BE())};this.setState(i.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{remoteHost:t,socket:this.socket})}}sendSocks5InitialHandshake(){let e=new o.SmartBuffer,A=[i.Socks5Auth.NoAuth];for(let t of((this.options.proxy.userId||this.options.proxy.password)&&A.push(i.Socks5Auth.UserPass),void 0!==this.options.proxy.custom_auth_method&&A.push(this.options.proxy.custom_auth_method),e.writeUInt8(5),e.writeUInt8(A.length),A))e.writeUInt8(t);this.nextRequiredPacketBufferSize=i.SOCKS_INCOMING_PACKET_SIZES.Socks5InitialHandshakeResponse,this.socket.write(e.toBuffer()),this.setState(i.SocksClientState.SentInitialHandshake)}handleInitialSocks5HandshakeResponse(){let e=this.receiveBuffer.get(2);5!==e[0]?this.closeSocket(i.ERRORS.InvalidSocks5IntiailHandshakeSocksVersion):e[1]===i.SOCKS5_NO_ACCEPTABLE_AUTH?this.closeSocket(i.ERRORS.InvalidSocks5InitialHandshakeNoAcceptedAuthType):e[1]===i.Socks5Auth.NoAuth?(this.socks5ChosenAuthType=i.Socks5Auth.NoAuth,this.sendSocks5CommandRequest()):e[1]===i.Socks5Auth.UserPass?(this.socks5ChosenAuthType=i.Socks5Auth.UserPass,this.sendSocks5UserPassAuthentication()):e[1]===this.options.proxy.custom_auth_method?(this.socks5ChosenAuthType=this.options.proxy.custom_auth_method,this.sendSocks5CustomAuthentication()):this.closeSocket(i.ERRORS.InvalidSocks5InitialHandshakeUnknownAuthType)}sendSocks5UserPassAuthentication(){let e=this.options.proxy.userId||"",A=this.options.proxy.password||"",t=new o.SmartBuffer;t.writeUInt8(1),t.writeUInt8(Buffer.byteLength(e)),t.writeString(e),t.writeUInt8(Buffer.byteLength(A)),t.writeString(A),this.nextRequiredPacketBufferSize=i.SOCKS_INCOMING_PACKET_SIZES.Socks5UserPassAuthenticationResponse,this.socket.write(t.toBuffer()),this.setState(i.SocksClientState.SentAuthentication)}sendSocks5CustomAuthentication(){return r(this,void 0,void 0,function*(){this.nextRequiredPacketBufferSize=this.options.proxy.custom_auth_response_size,this.socket.write((yield this.options.proxy.custom_auth_request_handler())),this.setState(i.SocksClientState.SentAuthentication)})}handleSocks5CustomAuthHandshakeResponse(e){return r(this,void 0,void 0,function*(){return yield this.options.proxy.custom_auth_response_handler(e)})}handleSocks5AuthenticationNoAuthHandshakeResponse(e){return r(this,void 0,void 0,function*(){return 0===e[1]})}handleSocks5AuthenticationUserPassHandshakeResponse(e){return r(this,void 0,void 0,function*(){return 0===e[1]})}handleInitialSocks5AuthenticationHandshakeResponse(){return r(this,void 0,void 0,function*(){this.setState(i.SocksClientState.ReceivedAuthenticationResponse);let e=!1;this.socks5ChosenAuthType===i.Socks5Auth.NoAuth?e=yield this.handleSocks5AuthenticationNoAuthHandshakeResponse(this.receiveBuffer.get(2)):this.socks5ChosenAuthType===i.Socks5Auth.UserPass?e=yield this.handleSocks5AuthenticationUserPassHandshakeResponse(this.receiveBuffer.get(2)):this.socks5ChosenAuthType===this.options.proxy.custom_auth_method&&(e=yield this.handleSocks5CustomAuthHandshakeResponse(this.receiveBuffer.get(this.options.proxy.custom_auth_response_size))),e?this.sendSocks5CommandRequest():this.closeSocket(i.ERRORS.Socks5AuthenticationFailed)})}sendSocks5CommandRequest(){let e=new o.SmartBuffer;e.writeUInt8(5),e.writeUInt8(i.SocksCommand[this.options.command]),e.writeUInt8(0),n.isIPv4(this.options.destination.host)?(e.writeUInt8(i.Socks5HostType.IPv4),e.writeBuffer((0,a.ipToBuffer)(this.options.destination.host))):n.isIPv6(this.options.destination.host)?(e.writeUInt8(i.Socks5HostType.IPv6),e.writeBuffer((0,a.ipToBuffer)(this.options.destination.host))):(e.writeUInt8(i.Socks5HostType.Hostname),e.writeUInt8(this.options.destination.host.length),e.writeString(this.options.destination.host)),e.writeUInt16BE(this.options.destination.port),this.nextRequiredPacketBufferSize=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader,this.socket.write(e.toBuffer()),this.setState(i.SocksClientState.SentFinalHandshake)}handleSocks5FinalHandshakeResponse(){let e=this.receiveBuffer.peek(5);if(5!==e[0]||e[1]!==i.Socks5Response.Granted)this.closeSocket(`${i.ERRORS.InvalidSocks5FinalHandshakeRejected} - ${i.Socks5Response[e[1]]}`);else{let A,t,r=e[3];if(r===i.Socks5HostType.IPv4){let e=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4;if(this.receiveBuffer.length<e){this.nextRequiredPacketBufferSize=e;return}t=o.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(4)),"0.0.0.0"===(A={host:(0,a.int32ToIpv4)(t.readUInt32BE()),port:t.readUInt16BE()}).host&&(A.host=this.options.proxy.ipaddress)}else if(r===i.Socks5HostType.Hostname){let r=e[4],s=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(r);if(this.receiveBuffer.length<s){this.nextRequiredPacketBufferSize=s;return}A={host:(t=o.SmartBuffer.fromBuffer(this.receiveBuffer.get(s).slice(5))).readString(r),port:t.readUInt16BE()}}else if(r===i.Socks5HostType.IPv6){let e=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6;if(this.receiveBuffer.length<e){this.nextRequiredPacketBufferSize=e;return}t=o.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(4)),A={host:h.Address6.fromByteArray(Array.from(t.readBuffer(16))).canonicalForm(),port:t.readUInt16BE()}}this.setState(i.SocksClientState.ReceivedFinalResponse),i.SocksCommand[this.options.command]===i.SocksCommand.connect?(this.setState(i.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{remoteHost:A,socket:this.socket})):i.SocksCommand[this.options.command]===i.SocksCommand.bind?(this.setState(i.SocksClientState.BoundWaitingForConnection),this.nextRequiredPacketBufferSize=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader,this.emit("bound",{remoteHost:A,socket:this.socket})):i.SocksCommand[this.options.command]===i.SocksCommand.associate&&(this.setState(i.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{remoteHost:A,socket:this.socket}))}}handleSocks5IncomingConnectionResponse(){let e=this.receiveBuffer.peek(5);if(5!==e[0]||e[1]!==i.Socks5Response.Granted)this.closeSocket(`${i.ERRORS.Socks5ProxyRejectedIncomingBoundConnection} - ${i.Socks5Response[e[1]]}`);else{let A,t,r=e[3];if(r===i.Socks5HostType.IPv4){let e=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4;if(this.receiveBuffer.length<e){this.nextRequiredPacketBufferSize=e;return}t=o.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(4)),"0.0.0.0"===(A={host:(0,a.int32ToIpv4)(t.readUInt32BE()),port:t.readUInt16BE()}).host&&(A.host=this.options.proxy.ipaddress)}else if(r===i.Socks5HostType.Hostname){let r=e[4],s=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(r);if(this.receiveBuffer.length<s){this.nextRequiredPacketBufferSize=s;return}A={host:(t=o.SmartBuffer.fromBuffer(this.receiveBuffer.get(s).slice(5))).readString(r),port:t.readUInt16BE()}}else if(r===i.Socks5HostType.IPv6){let e=i.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6;if(this.receiveBuffer.length<e){this.nextRequiredPacketBufferSize=e;return}t=o.SmartBuffer.fromBuffer(this.receiveBuffer.get(e).slice(4)),A={host:h.Address6.fromByteArray(Array.from(t.readBuffer(16))).canonicalForm(),port:t.readUInt16BE()}}this.setState(i.SocksClientState.Established),this.removeInternalSocketHandlers(),this.emit("established",{remoteHost:A,socket:this.socket})}}get socksClientOptions(){return Object.assign({},this.options)}}t.SocksClient=c},771193,(e,A,t)=>{"use strict";var r=e.e&&e.e.__createBinding||(Object.create?function(e,A,t,r){void 0===r&&(r=t);var s=Object.getOwnPropertyDescriptor(A,t);(!s||("get"in s?!A.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return A[t]}}),Object.defineProperty(e,r,s)}:function(e,A,t,r){void 0===r&&(r=t),e[r]=A[t]}),s=e.e&&e.e.__exportStar||function(e,A){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(A,t)||r(A,e,t)};Object.defineProperty(t,"__esModule",{value:!0}),s(e.r(23052),t)},425842,(e,A,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.socksConnector=n,t.socksDispatcher=function(e,A={}){let{connect:t,...r}=A;return new s.Agent({...r,connect:n(e,t)})};let r=e.r(771193),s=e.r(724055);function n(e,A={}){let t=Array.isArray(e)?e:[e],{timeout:o=1e4}=A,i=(0,s.buildConnector)(A);return async(e,A)=>{let{protocol:s,hostname:n,port:a,httpSocket:l}=e;for(let e=0;e<t.length;e++){let i=t[e+1],g=e===t.length-1?{host:n,port:a?Number.parseInt(a):"http:"===s?80:443}:{port:i.port,host:i.host??i.ipaddress},h={command:"connect",proxy:t[e],timeout:o,destination:g,existing_socket:l};try{l=(await r.SocksClient.createConnection(h)).socket}catch(e){return A(e,null)}}return l&&"https:"!==s?A(null,l.setNoDelay()):i({...e,httpSocket:l},A)}}},621213,(e,A,t)=>{"use strict";var r,s,n,o,i,a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,h=Object.prototype.hasOwnProperty,c={},E={Headers:()=>F,RequestError:()=>f,Response:()=>O,Session:()=>G,Transport:()=>x,WebSocket:()=>eF,createSession:()=>eC,createTransport:()=>eB,default:()=>eM,fetch:()=>eI,get:()=>eD,getOperatingSystems:()=>ey,getProfiles:()=>ep,post:()=>eS,request:()=>ef,websocket:()=>ek,withSession:()=>ed};for(var Q in E)a(c,Q,{get:E[Q],enumerable:!0});A.exports=((e,A,t,r)=>{if(A&&"object"==typeof A||"function"==typeof A)for(let s of g(A))h.call(e,s)||s===t||a(e,s,{get:()=>A[s],enumerable:!(r=l(A,s))||r.enumerable});return e})(a({},"__esModule",{value:!0}),c);var u=e.r(254799),I=e.r(921517),B=e.r(362562),C=e.r(688947),d=e.r(363890),f=class extends TypeError{constructor(e){super(e),this.name="RequestError"}},p={},y=p.url?(0,B.createRequire)(p.url):(0,B.createRequire)("/ROOT/node_modules/wreq-js/dist/wreq-js.cjs");r=function(){let e=process.platform,A=process.arch,t=function(){let e=process.env.LIBC??process.env.npm_config_libc;if(e)return e.toLowerCase().includes("musl")?"musl":"gnu";try{let e=process.report?.getReport?.();if(e?.header?.glibcVersionRuntime)return"gnu";return"musl"}catch{return"gnu"}}(),r={darwin:{x64:"darwin-x64",arm64:"darwin-arm64"},linux:{x64:{gnu:"linux-x64-gnu",musl:"linux-x64-musl"},arm64:"linux-arm64-gnu"},win32:{x64:"win32-x64-msvc"}}[e]?.[A],s="string"==typeof r?r:r?.[t??"gnu"];if(!s)throw Error(`Unsupported platform: ${e}-${A}${t?`-${t}`:""}. Supported platforms: darwin-x64, darwin-arm64, linux-x64-gnu, linux-x64-musl, linux-arm64-gnu, win32-x64-msvc`);let n=`wreq-js.${s}.node`;try{return y(`../rust/${n}`)}catch{try{return y("../rust/wreq-js.node")}catch{throw Error(`Failed to load native module for ${e}-${A}. Tried: ../rust/${n} and ../rust/wreq-js.node. Make sure the package is installed correctly and the native module is built for your platform.`)}}}();var D="function"==typeof FinalizationRegistry?new FinalizationRegistry(e=>{r.websocketClose(e).catch(()=>void 0)}):void 0,S="function"==typeof FinalizationRegistry?new FinalizationRegistry(e=>{if(!e.released){e.released=!0;try{r.cancelBody(e.id)}catch{}}}):void 0,w="chrome_142",m="macos",N=["windows","macos","linux","android","ios"],R=new TextDecoder("utf-8"),b=0;function U(e){if("object"!=typeof e||null===e)return!1;let A=Object.getPrototypeOf(e);return A===Object.prototype||null===A}var F=class e{store=new Map;constructor(e){e&&this.applyInit(e)}applyInit(A){if(A instanceof e){for(let[e,t]of A)this.append(e,t);return}if(Array.isArray(A)||A&&"function"==typeof A[Symbol.iterator]){for(let e of A){if(!e)continue;let[A,t]=e;this.append(A,t)}return}if(U(A))for(let[e,t]of Object.entries(A))null!=t&&this.set(e,String(t))}normalizeName(e){if("string"!=typeof e)throw TypeError("Header name must be a string");let A=e.trim();if(!A)throw TypeError("Header name must not be empty");return{key:A.toLowerCase(),display:A}}assertValue(e){if(null==e)throw TypeError("Header value must not be null or undefined");return String(e)}append(e,A){let t=this.normalizeName(e),r=this.store.get(t.key),s=this.assertValue(A);r?r.values.push(s):this.store.set(t.key,{name:t.display,values:[s]})}set(e,A){let t=this.normalizeName(e),r=this.assertValue(A);this.store.set(t.key,{name:t.display,values:[r]})}get(e){let A=this.normalizeName(e),t=this.store.get(A.key);return t?t.values.join(", "):null}has(e){let A=this.normalizeName(e);return this.store.has(A.key)}delete(e){let A=this.normalizeName(e);this.store.delete(A.key)}entries(){return this[Symbol.iterator]()}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}forEach(e,A){for(let[t,r]of this)e.call(A,r,t,this)}[Symbol.iterator](){return function*(e){for(let A of e.values())yield[A.name,A.values.join(", ")]}(this.store)}toObject(){let e={};for(let[A,t]of this)e[A]=t;return e}toTuples(){let e=[];for(let[A,t]of this)e.push([A,t]);return e}};function k(e){return new F(e).toTuples()}function M(e,A){if(!e)return!1;let t=A.toLowerCase();for(let[A]of e)if(A.toLowerCase()===t)return!0;return!1}function T(e){if(e&&M(k(e),"Sec-WebSocket-Protocol"))throw new f("Do not set `Sec-WebSocket-Protocol` header manually; use the `protocols` option instead.")}function L(e){if(void 0!==e)return"string"==typeof e?[e]:[...e]}function v(e){return{status:e.status,headers:e.headers.map(([e,A])=>[e,A]),bodyHandle:e.bodyHandle,bodyBytes:e.bodyBytes,contentLength:e.contentLength,cookies:e.cookies.map(([e,A])=>[e,A]),url:e.url}}function H(e){if(!e.released){e.released=!0;try{r.cancelBody(e.id)}catch{}S?.unregister(e)}}function Y(e){let A=new d.ReadableStream({async pull(A){try{let t=await r.readBodyChunk(e.id);if(null===t){H(e),A.close();return}A.enqueue(t)}catch(t){H(e),A.error(t)}},cancel(){H(e)}});return S?.register(A,e,e),A}var O=class e{status;ok;contentLength;url;type="basic";bodyUsed=!1;payload;requestUrl;redirectedMemo;headersInit;headersInstance;cookiesInit;cookiesRecord;inlineBody;bodySource;bodyStream;nativeHandleAvailable;nativeHandle;constructor(e,A,t){this.payload=e,this.requestUrl=A,this.status=this.payload.status,this.ok=this.status>=200&&this.status<300,this.headersInit=this.payload.headers,this.headersInstance=null,this.url=this.payload.url,this.cookiesInit=this.payload.cookies,this.cookiesRecord=null,this.contentLength=this.payload.contentLength??null,this.inlineBody=this.payload.bodyBytes??null,this.nativeHandle=null,void 0!==t?(this.bodySource=t,this.nativeHandleAvailable=!1):null!==this.inlineBody?(this.bodySource=null,this.nativeHandleAvailable=!1):null!==this.payload.bodyHandle?(this.bodySource=null,this.nativeHandleAvailable=!0,this.nativeHandle={id:this.payload.bodyHandle,released:!1},S?.register(this,this.nativeHandle,this.nativeHandle)):(this.bodySource=null,this.nativeHandleAvailable=!1),this.bodyStream=void 0}get redirected(){if(void 0!==this.redirectedMemo)return this.redirectedMemo;if(this.url===this.requestUrl)return this.redirectedMemo=!1,!1;let e=function(e){try{return new URL(e).toString()}catch{return null}}(this.requestUrl);return this.redirectedMemo=!e||this.url!==e,this.redirectedMemo}get statusText(){return I.STATUS_CODES[this.status]??""}get headers(){return this.headersInstance||(this.headersInstance=new F(this.headersInit)),this.headersInstance}get cookies(){if(!this.cookiesRecord){let e=Object.create(null);for(let[A,t]of this.cookiesInit){let r=e[A];void 0===r?e[A]=t:Array.isArray(r)?r.push(t):e[A]=[r,t]}this.cookiesRecord=e}return this.cookiesRecord}get body(){var e,A;let t,r;if(this.inlineBody&&null===this.bodySource){let e=this.inlineBody;this.inlineBody=null,this.bodySource=new d.ReadableStream({start(A){A.enqueue(e),A.close()}})}if(null===this.inlineBody&&null===this.payload.bodyHandle&&null===this.bodySource)return null;if(null===this.bodySource&&this.nativeHandleAvailable&&null!==this.payload.bodyHandle){this.nativeHandle&&S?.unregister(this.nativeHandle);let e=this.nativeHandle??{id:this.payload.bodyHandle,released:!1};this.nativeHandle=e,this.bodySource=Y(e),this.nativeHandleAvailable=!1}return null===this.bodySource?null:(void 0===this.bodyStream&&(this.bodyStream=(e=this.bodySource,A=()=>{this.bodyUsed=!0},t=!1,r=null,new d.ReadableStream({async pull(s){t||(t=!0,A()),r||(r=e.getReader());try{let{done:e,value:A}=await r.read();if(e)return void s.close();s.enqueue(A)}catch(e){s.error(e)}},cancel:A=>r?r.cancel(A):e.cancel(A)}))),this.bodyStream)}async json(){return JSON.parse(await this.text())}async arrayBuffer(){let e=await this.consumeBody(),{buffer:A,byteOffset:t,byteLength:r}=e;if(A instanceof ArrayBuffer)return 0===t&&r===A.byteLength?A:A.slice(t,t+r);let s=new Uint8Array(r);return s.set(e),s.buffer}async text(){let e=await this.consumeBody();return R.decode(e)}async blob(){let e=await this.consumeBody(),A=this.headers.get("content-type")??"";return new Blob([e],A?{type:A}:void 0)}async formData(){let e=await this.consumeBody(),A=this.headers.get("content-type");return new globalThis.Response(e,A?{headers:{"content-type":A}}:void 0).formData()}readable(){this.assertBodyAvailable(),this.bodyUsed=!0;let e=this.body;return null===e?C.Readable.from([]):C.Readable.fromWeb(e)}clone(){if(this.bodyUsed)throw TypeError("Cannot clone a Response whose body is already used");if(this.nativeHandleAvailable&&null!==this.payload.bodyHandle){this.nativeHandle&&S?.unregister(this.nativeHandle);let e=this.nativeHandle??{id:this.payload.bodyHandle,released:!1};this.nativeHandle=e,this.bodySource=Y(e),this.nativeHandleAvailable=!1}if(null===this.bodySource)return new e(v(this.payload),this.requestUrl,null);let[A,t]=this.bodySource.tee();return this.bodySource=A,this.bodyStream=void 0,new e(v(this.payload),this.requestUrl,t)}assertBodyAvailable(){if(this.bodyUsed)throw TypeError("Response body is already used")}async consumeBody(){if(this.assertBodyAvailable(),this.bodyUsed=!0,this.inlineBody){let e=this.inlineBody;return this.inlineBody=null,e}if(this.nativeHandleAvailable&&null!==this.payload.bodyHandle){this.nativeHandleAvailable=!1;try{return await r.readBodyAll(this.payload.bodyHandle)}catch(e){if(String(e).includes("Body handle")&&String(e).includes("not found"))return Buffer.alloc(0);throw e}finally{var e;this.nativeHandle&&((e=this.nativeHandle).released||(e.released=!0,S?.unregister(e)))}}let A=this.body;if(!A)return Buffer.alloc(0);let t=A.getReader(),s=[];for(;;){let{done:e,value:A}=await t.read();if(e)break;A&&A.byteLength>0&&(Buffer.isBuffer(A)?s.push(A):s.push(Buffer.from(A.buffer,A.byteOffset,A.byteLength)))}return 0===s.length?Buffer.alloc(0):Buffer.concat(s)}},x=class{id;disposed=!1;constructor(e){this.id=e}get closed(){return this.disposed}async close(){if(!this.disposed){this.disposed=!0;try{r.dropTransport(this.id)}catch(e){throw new f(String(e))}}}},G=class{id;disposed=!1;defaults;constructor(e,A){this.id=e,this.defaults=A}get closed(){return this.disposed}ensureActive(){if(this.disposed)throw new f("Session has been closed")}getDefaults(){let e={...this.defaults};return this.defaults.defaultHeaders&&(e.defaultHeaders=[...this.defaults.defaultHeaders]),e}_defaultsRef(){return this.defaults}async fetch(e,A){return this.ensureActive(),eI(e,A?{...A,session:this}:{session:this})}async clearCookies(){this.ensureActive();try{r.clearSession(this.id)}catch(e){throw new f(String(e))}}getCookies(e){this.ensureActive();try{return r.getCookies(this.id,String(e))}catch(e){throw new f(String(e))}}setCookie(e,A,t){this.ensureActive();try{r.setCookie(this.id,e,A,String(t))}catch(e){throw new f(String(e))}}async websocket(e,A){this.ensureActive();let t=function(e,A){if("string"==typeof e||e instanceof URL){let t=eR(A);return{url:ew(e),options:t,legacyCallbacks:eb(A)}}let t=eR(e);return{url:ew(e.url),options:t,legacyCallbacks:eb(e)}}(e,A);em(t.options.protocols),T(t.options.headers);let s=L(t.options.protocols),n=this.defaults.transportId;if(!n)throw new f("Session has no transport. Create the session with browser/os options or pass a transport to use session.websocket().");return eF._connectWithInit({_internal:!0,url:t.url,options:t.options,openDispatchMode:"deferred",connect:e=>r.websocketConnectSession({url:t.url,sessionId:this.id,transportId:n,headers:k(t.options.headers??{}),...s&&s.length>0&&{protocols:s},onMessage:e.onMessage,onClose:e.onClose,onError:e.onError}),legacyCallbacks:t.legacyCallbacks})}async close(){if(this.disposed)return;this.disposed=!0;let e=this.defaults.transportId,A=this.defaults.ownsTransport;try{r.dropSession(this.id)}catch(t){if(!A||!e)throw new f(String(t));try{r.dropTransport(e)}catch{}throw new f(String(t))}if(A&&e)try{r.dropTransport(e)}catch(e){throw new f(String(e))}}};function V(e){let A="string"==typeof e?e:"The operation was aborted";if("u">typeof DOMException&&e instanceof DOMException)return"AbortError"===e.name?e:new DOMException(e.message||A,"AbortError");if(e instanceof Error){let A=Error(e.message);return A.name="AbortError",A.cause=e,A}if("u">typeof DOMException)return new DOMException(A,"AbortError");let t=Error(A);return t.name="AbortError",t}var J=Math.trunc(Number(process.hrtime.bigint()%BigInt(0x1000000000000-1)))+1;function _(){return(J+=1)>=0x1000000000000&&(J=1),J}function P(e){if(e instanceof URL)return e.href;if(0===e.length)throw new f("URL is required");if(e.charCodeAt(0)>32&&e.charCodeAt(e.length-1)>32)return e;let A=e.trim();if(0===A.length)throw new f("URL is required");return A}async function W(e,A){if(!(e&&"object"==typeof e&&("u">typeof Request&&e instanceof Request||"string"==typeof e.url&&"string"==typeof e.method&&"function"==typeof e.arrayBuffer&&"string"==typeof e.redirect)))return{url:P(e),init:A??{}};let t=A?{...A}:{};if(void 0===t.method&&(t.method=e.method),void 0===t.headers&&(t.headers=e.headers),void 0===t.redirect&&("follow"===e.redirect||"manual"===e.redirect||"error"===e.redirect)&&(t.redirect=e.redirect),void 0===t.signal&&(t.signal=e.signal),void 0===t.body&&null!==e.body){if(e.bodyUsed)throw TypeError("Request body is already used");t.body=Buffer.from(await e.arrayBuffer())}return{url:P(e.url),init:t}}async function q(e){if(null==e)return{};if("string"==typeof e)return{body:Buffer.from(e,"utf8")};if(Buffer.isBuffer(e))return{body:e};if(e instanceof URLSearchParams)return{body:Buffer.from(e.toString(),"utf8"),contentType:"application/x-www-form-urlencoded;charset=UTF-8"};if(e instanceof ArrayBuffer)return{body:Buffer.from(e)};if(ArrayBuffer.isView(e))return{body:Buffer.from(e.buffer,e.byteOffset,e.byteLength)};if("u">typeof Blob&&e instanceof Blob)return{body:Buffer.from(await e.arrayBuffer()),...e.type?{contentType:e.type}:{}};if("u">typeof FormData&&e instanceof FormData){let A=new globalThis.Response(e),t=A.headers.get("content-type")??void 0;return{body:Buffer.from(await A.arrayBuffer()),...t?{contentType:t}:{}}}throw TypeError("Unsupported body type; expected string, Buffer, ArrayBuffer, ArrayBufferView, URLSearchParams, Blob, or FormData")}function Z(e){if(void 0!==e){if("string"!=typeof e||0===e.trim().length)throw new f("Browser profile must not be empty");if(!(n||(n=new Set(ep())),n).has(e))throw new f(`Invalid browser profile: ${e}. Available profiles: ${ep().join(", ")}`)}}function j(e){if(void 0!==e){if("string"!=typeof e||0===e.trim().length)throw new f("Operating system must not be empty");if(!(i||(i=new Set(ey())),i).has(e))throw new f(`Invalid operating system: ${e}. Available options: ${ey().join(", ")}`)}}function X(e){if(void 0!==e){if("number"!=typeof e||!Number.isFinite(e))throw new f("Timeout must be a finite number");if(e<0)throw new f("Timeout must be 0 (no timeout) or a positive number")}}function z(e,A){if("number"!=typeof e||!Number.isFinite(e))throw new f(`${A} must be a finite number`);if(e<=0)throw new f(`${A} must be greater than 0`)}function K(e,A){if("number"!=typeof e||!Number.isFinite(e)||!Number.isInteger(e))throw new f(`${A} must be an integer`);if(e<0)throw new f(`${A} must be greater than or equal to 0`)}function $(e,A){if("number"!=typeof e||!Number.isFinite(e)||!Number.isInteger(e))throw new f(`${A} must be an integer`);if(e<=0)throw new f(`${A} must be greater than 0`)}function ee(e,A,t,r){if(K(e,r),e<A||e>t)throw new f(`${r} must be between ${A} and ${t}`)}var eA=new Set(["HTTP1","HTTP2","HTTP3"]),et=new Set(["HTTP1","HTTP2","HTTP3"]),er=new Set(["zlib","brotli","zstd"]),es=new Set(["HeaderTableSize","EnablePush","MaxConcurrentStreams","InitialWindowSize","MaxFrameSize","MaxHeaderListSize","EnableConnectProtocol","NoRfc7540Priorities"]),en=new Set(["Method","Scheme","Authority","Path","Protocol"]),eo=new Set([1,2,3,4,5,6,8,9]),ei=new Map([["1.0","1.0"],["1.1","1.1"],["1.2","1.2"],["1.3","1.3"],["tls1.0","1.0"],["tls1.1","1.1"],["tls1.2","1.2"],["tls1.3","1.3"]]);function ea(e){for(let A in e)return!0;return!1}function el(e,A,t){if(void 0!==e){if(!Array.isArray(e))throw new f(`${A} must be an array`);for(let r of e)if(!t.has(r))throw new f(`${A} values must be one of: HTTP1, HTTP2, HTTP3`);return[...e]}}function eg(e,A){if(void 0===e)return;if("string"!=typeof e)throw new f(`${A} must be a string`);let t=ei.get(e.trim().toLowerCase());if(!t)throw new f(`${A} must be one of: 1.0, 1.1, 1.2, 1.3`);return t}function eh(e,A){if(!U(e))throw new f(`${A} must be an object`);ee(e.dependencyId,0,0x7fffffff,`${A}.dependencyId`),ee(e.weight,0,255,`${A}.weight`);let t={dependencyId:e.dependencyId,weight:e.weight};return void 0!==e.exclusive&&(t.exclusive=e.exclusive),t}function ec(e,A){let t=function(e,A){if(void 0===e)return;if(!U(e))throw new f("emulation must be an object");let t={},r=function(e){if(void 0===e)return;let A={},t=el(e.alpnProtocols,"emulation.tlsOptions.alpnProtocols",eA);void 0!==t&&(A.alpnProtocols=t);let r=el(e.alpsProtocols,"emulation.tlsOptions.alpsProtocols",et);void 0!==r&&(A.alpsProtocols=r);let s=eg(e.minTlsVersion,"emulation.tlsOptions.minTlsVersion");void 0!==s&&(A.minTlsVersion=s);let n=eg(e.maxTlsVersion,"emulation.tlsOptions.maxTlsVersion");if(void 0!==n&&(A.maxTlsVersion=n),void 0!==e.alpsUseNewCodepoint&&(A.alpsUseNewCodepoint=e.alpsUseNewCodepoint),void 0!==e.sessionTicket&&(A.sessionTicket=e.sessionTicket),void 0!==e.preSharedKey&&(A.preSharedKey=e.preSharedKey),void 0!==e.enableEchGrease&&(A.enableEchGrease=e.enableEchGrease),void 0!==e.permuteExtensions&&(A.permuteExtensions=e.permuteExtensions),void 0!==e.greaseEnabled&&(A.greaseEnabled=e.greaseEnabled),void 0!==e.enableOcspStapling&&(A.enableOcspStapling=e.enableOcspStapling),void 0!==e.enableSignedCertTimestamps&&(A.enableSignedCertTimestamps=e.enableSignedCertTimestamps),void 0!==e.pskSkipSessionTicket&&(A.pskSkipSessionTicket=e.pskSkipSessionTicket),void 0!==e.pskDheKe&&(A.pskDheKe=e.pskDheKe),void 0!==e.renegotiation&&(A.renegotiation=e.renegotiation),void 0!==e.aesHwOverride&&(A.aesHwOverride=e.aesHwOverride),void 0!==e.preserveTls13CipherList&&(A.preserveTls13CipherList=e.preserveTls13CipherList),void 0!==e.randomAesHwOverride&&(A.randomAesHwOverride=e.randomAesHwOverride),void 0!==e.delegatedCredentials&&(A.delegatedCredentials=e.delegatedCredentials),void 0!==e.curvesList&&(A.curvesList=e.curvesList),void 0!==e.cipherList&&(A.cipherList=e.cipherList),void 0!==e.sigalgsList&&(A.sigalgsList=e.sigalgsList),void 0!==e.recordSizeLimit&&(ee(e.recordSizeLimit,0,65535,"emulation.tlsOptions.recordSizeLimit"),A.recordSizeLimit=e.recordSizeLimit),void 0!==e.keySharesLimit&&(ee(e.keySharesLimit,0,255,"emulation.tlsOptions.keySharesLimit"),A.keySharesLimit=e.keySharesLimit),void 0!==e.certificateCompressionAlgorithms){if(!Array.isArray(e.certificateCompressionAlgorithms))throw new f("emulation.tlsOptions.certificateCompressionAlgorithms must be an array");let t=[],r=new Set;for(let A of e.certificateCompressionAlgorithms){if(!er.has(A))throw new f("emulation.tlsOptions.certificateCompressionAlgorithms values must be one of: zlib, brotli, zstd");if(r.has(A))throw new f(`Duplicate emulation.tlsOptions.certificateCompressionAlgorithms entry: ${A}`);r.add(A),t.push(A)}A.certificateCompressionAlgorithms=t}if(void 0!==e.extensionPermutation){if(!Array.isArray(e.extensionPermutation))throw new f("emulation.tlsOptions.extensionPermutation must be an array");let t=[],r=new Set;for(let A of e.extensionPermutation){if(ee(A,0,65535,"emulation.tlsOptions.extensionPermutation"),r.has(A))throw new f(`Duplicate emulation.tlsOptions.extensionPermutation entry: ${A}`);r.add(A),t.push(A)}A.extensionPermutation=t}return ea(A)?A:void 0}(e.tlsOptions);void 0!==r&&(t.tlsOptions=r);let s=function(e){if(void 0===e)return;let A={};if(void 0!==e.http09Responses&&(A.http09Responses=e.http09Responses),void 0!==e.writev&&(A.writev=e.writev),void 0!==e.ignoreInvalidHeadersInResponses&&(A.ignoreInvalidHeadersInResponses=e.ignoreInvalidHeadersInResponses),void 0!==e.allowSpacesAfterHeaderNameInResponses&&(A.allowSpacesAfterHeaderNameInResponses=e.allowSpacesAfterHeaderNameInResponses),void 0!==e.allowObsoleteMultilineHeadersInResponses&&(A.allowObsoleteMultilineHeadersInResponses=e.allowObsoleteMultilineHeadersInResponses),void 0!==e.maxHeaders&&(K(e.maxHeaders,"emulation.http1Options.maxHeaders"),A.maxHeaders=e.maxHeaders),void 0!==e.readBufExactSize&&(K(e.readBufExactSize,"emulation.http1Options.readBufExactSize"),A.readBufExactSize=e.readBufExactSize),void 0!==e.maxBufSize){if(K(e.maxBufSize,"emulation.http1Options.maxBufSize"),e.maxBufSize<8192)throw new f("emulation.http1Options.maxBufSize must be greater than or equal to 8192");A.maxBufSize=e.maxBufSize}if(void 0!==A.readBufExactSize&&void 0!==A.maxBufSize)throw new f("emulation.http1Options.readBufExactSize and maxBufSize cannot both be set");return ea(A)?A:void 0}(e.http1Options);void 0!==s&&(t.http1Options=s);let n=function(e){if(void 0===e)return;let A={};if(void 0!==e.adaptiveWindow&&(A.adaptiveWindow=e.adaptiveWindow),void 0!==e.keepAliveWhileIdle&&(A.keepAliveWhileIdle=e.keepAliveWhileIdle),void 0!==e.enablePush&&(A.enablePush=e.enablePush),void 0!==e.enableConnectProtocol&&(A.enableConnectProtocol=e.enableConnectProtocol),void 0!==e.noRfc7540Priorities&&(A.noRfc7540Priorities=e.noRfc7540Priorities),void 0!==e.initialStreamId&&(K(e.initialStreamId,"emulation.http2Options.initialStreamId"),A.initialStreamId=e.initialStreamId),void 0!==e.initialConnectionWindowSize&&(K(e.initialConnectionWindowSize,"emulation.http2Options.initialConnectionWindowSize"),A.initialConnectionWindowSize=e.initialConnectionWindowSize),void 0!==e.initialWindowSize&&(K(e.initialWindowSize,"emulation.http2Options.initialWindowSize"),A.initialWindowSize=e.initialWindowSize),void 0!==e.initialMaxSendStreams&&(K(e.initialMaxSendStreams,"emulation.http2Options.initialMaxSendStreams"),A.initialMaxSendStreams=e.initialMaxSendStreams),void 0!==e.maxFrameSize&&(K(e.maxFrameSize,"emulation.http2Options.maxFrameSize"),A.maxFrameSize=e.maxFrameSize),void 0!==e.keepAliveInterval&&(K(e.keepAliveInterval,"emulation.http2Options.keepAliveInterval"),A.keepAliveInterval=e.keepAliveInterval),void 0!==e.keepAliveTimeout&&(K(e.keepAliveTimeout,"emulation.http2Options.keepAliveTimeout"),A.keepAliveTimeout=e.keepAliveTimeout),void 0!==e.maxConcurrentResetStreams&&(K(e.maxConcurrentResetStreams,"emulation.http2Options.maxConcurrentResetStreams"),A.maxConcurrentResetStreams=e.maxConcurrentResetStreams),void 0!==e.maxSendBufferSize&&(K(e.maxSendBufferSize,"emulation.http2Options.maxSendBufferSize"),A.maxSendBufferSize=e.maxSendBufferSize),void 0!==e.maxConcurrentStreams&&(K(e.maxConcurrentStreams,"emulation.http2Options.maxConcurrentStreams"),A.maxConcurrentStreams=e.maxConcurrentStreams),void 0!==e.maxHeaderListSize&&(K(e.maxHeaderListSize,"emulation.http2Options.maxHeaderListSize"),A.maxHeaderListSize=e.maxHeaderListSize),void 0!==e.maxPendingAcceptResetStreams&&(K(e.maxPendingAcceptResetStreams,"emulation.http2Options.maxPendingAcceptResetStreams"),A.maxPendingAcceptResetStreams=e.maxPendingAcceptResetStreams),void 0!==e.headerTableSize&&(K(e.headerTableSize,"emulation.http2Options.headerTableSize"),A.headerTableSize=e.headerTableSize),void 0!==e.settingsOrder){if(!Array.isArray(e.settingsOrder))throw new f("emulation.http2Options.settingsOrder must be an array");let t=[],r=new Set;for(let A of e.settingsOrder){if(!es.has(A))throw new f("emulation.http2Options.settingsOrder contains an unsupported setting id");if(r.has(A))throw new f(`Duplicate emulation.http2Options.settingsOrder entry: ${A}`);r.add(A),t.push(A)}A.settingsOrder=t}if(void 0!==e.headersPseudoOrder){if(!Array.isArray(e.headersPseudoOrder))throw new f("emulation.http2Options.headersPseudoOrder must be an array");let t=[],r=new Set;for(let A of e.headersPseudoOrder){if(!en.has(A))throw new f("emulation.http2Options.headersPseudoOrder contains an unsupported pseudo-header id");if(r.has(A))throw new f(`Duplicate emulation.http2Options.headersPseudoOrder entry: ${A}`);r.add(A),t.push(A)}A.headersPseudoOrder=t}if(void 0!==e.headersStreamDependency&&(A.headersStreamDependency=eh(e.headersStreamDependency,"emulation.http2Options.headersStreamDependency")),void 0!==e.priorities){if(!Array.isArray(e.priorities))throw new f("emulation.http2Options.priorities must be an array");let t=[],r=new Set;for(let[A,s]of e.priorities.entries()){if(!U(s))throw new f(`emulation.http2Options.priorities[${A}] must be an object`);if($(s.streamId,`emulation.http2Options.priorities[${A}].streamId`),r.has(s.streamId))throw new f(`Duplicate emulation.http2Options.priorities streamId: ${s.streamId}`);r.add(s.streamId),t.push({streamId:s.streamId,dependency:eh(s.dependency,`emulation.http2Options.priorities[${A}].dependency`)})}A.priorities=t}if(void 0!==e.experimentalSettings){if(!Array.isArray(e.experimentalSettings))throw new f("emulation.http2Options.experimentalSettings must be an array");let t=[],r=new Set;for(let[A,s]of e.experimentalSettings.entries()){if(!U(s))throw new f(`emulation.http2Options.experimentalSettings[${A}] must be an object`);if(ee(s.id,1,15,`emulation.http2Options.experimentalSettings[${A}].id`),eo.has(s.id))throw new f(`emulation.http2Options.experimentalSettings[${A}].id must not be a standard HTTP/2 setting id`);if(r.has(s.id))throw new f(`Duplicate emulation.http2Options.experimentalSettings id: ${s.id}`);r.add(s.id),ee(s.value,0,0xffffffff,`emulation.http2Options.experimentalSettings[${A}].value`),t.push({id:s.id,value:s.value})}A.experimentalSettings=t}return ea(A)?A:void 0}(e.http2Options);if(void 0!==n&&(t.http2Options=n),void 0!==e.headers){let A=k(e.headers);A.length>0&&(t.headers=A)}let o=function(e){if(void 0===e)return;if(!Array.isArray(e))throw new f("emulation.origHeaders must be an array of strings");let A=[],t=new Set;for(let r of e){if("string"!=typeof r||0===r.trim().length)throw new f("emulation.origHeaders entries must be non-empty strings");let e=r.trim(),s=e.toLowerCase();if(t.has(s))throw new f(`Duplicate emulation.origHeaders entry: ${e}`);t.add(s),A.push(e)}return A.length>0?A:void 0}(e.origHeaders);if(void 0!==o&&(t.origHeaders=o),!A&&!ea(t))throw new f("Standalone custom emulation requires at least one of tlsOptions, http1Options, http2Options, headers, or origHeaders");return ea(t)?t:void 0}(e,A);return t?JSON.stringify(t):void 0}function eE(e,A,t){if(void 0!==e){Z(e),void 0!==A&&j(A);let r=ec(t,!0);return{kind:"preset",browser:e,os:A??m,...void 0!==r&&{emulationJson:r}}}if(void 0!==A){j(A);let e=ec(t,!0);return{kind:"preset",browser:w,os:A,...void 0!==e&&{emulationJson:e}}}if(void 0!==t){let e=ec(t,!1);if(void 0===e)throw new f("Standalone custom emulation requires at least one of tlsOptions, http1Options, http2Options, headers, or origHeaders");return{kind:"custom",emulationJson:e}}return{kind:"preset",browser:w,os:m}}function eQ(e,A){if("custom"===A.kind){e.emulationJson=A.emulationJson;return}e.browser=A.browser,e.os=A.os,void 0!==A.emulationJson&&(e.emulationJson=A.emulationJson)}async function eu(e,A,t){let s;if(!t){let t,s=_();try{t=await r.request(e,s,!1)}catch(e){if(e instanceof f)throw e;throw new f(String(e))}return new O(t,A)}let n=_(),o=function(e,A){let t;if(!e)return null;if(e.aborted)throw A(),V(e.reason);return{promise:new Promise((r,s)=>{t=()=>{A(),s(V(e.reason))},e.addEventListener("abort",t,{once:!0})}),cleanup:()=>{t&&(e.removeEventListener("abort",t),t=void 0)}}}(t,()=>{try{r.cancelRequest(n)}catch{}}),i=Promise.race([r.request(e,n,!0),o.promise]);try{s=await i}catch(e){if(e&&"string"==typeof e.name&&"AbortError"===e.name||e instanceof f)throw e;throw new f(String(e))}finally{o.cleanup()}return new O(s,A)}async function eI(e,A){let t=await W(e,A),r=t.url,s=t.init,n=function(e){let A=e.cookieMode??"ephemeral",t=e.session,r="string"==typeof e.sessionId?e.sessionId.trim():void 0;if(t&&r)throw new f("Provide either `session` or `sessionId`, not both.");if(t){if(!(t instanceof G))throw new f("`session` must be created via createSession()");if(t.closed)throw new f("Session has been closed");return{sessionId:t.id,cookieMode:"session",dropAfterRequest:!1,defaults:t._defaultsRef()}}if(r){if(!r)throw new f("sessionId must not be empty");if("ephemeral"===A)throw new f("cookieMode 'ephemeral' cannot be combined with sessionId");return{sessionId:r,cookieMode:"session",dropAfterRequest:!1}}if("session"===A)throw new f("cookieMode 'session' requires a session or sessionId");return{sessionId:`_e${++b}`,cookieMode:"ephemeral",dropAfterRequest:!0}}(s),o=n.defaults;var i=s.redirect;if(void 0!==i&&"follow"!==i&&"manual"!==i&&"error"!==i)throw new f(`Redirect mode '${i}' is not supported`);void 0!==s.timeout&&X(s.timeout);let a=function(e){if(void 0===e||0===e.length)return"GET";switch(e){case"GET":case"POST":case"PUT":case"DELETE":case"PATCH":case"HEAD":case"OPTIONS":return e}let A=e.trim().toUpperCase();return A.length>0?A:"GET"}(s.method),l=await q(s.body??null),g=l.body;if(void 0!==g&&("GET"===a||"HEAD"===a))throw new f(`Request with ${a} method cannot have a body`);let h=function(e,A){if(!e)return void 0===A?void 0:k(A);if(void 0===A)return e;let t=k(A);if(0===t.length)return e;let r=new Set;for(let e of t)r.add(e[0].toLowerCase());let s=[];for(let A of e)r.has(A[0].toLowerCase())||s.push(A);for(let e of t)s.push(e);return s}(o?.defaultHeaders,s.headers);l.contentType&&!M(h,"content-type")&&(h||(h=[]),h.push(["Content-Type",l.contentType]));let c=function(e,A){if(void 0!==e.transport){if(!(e.transport instanceof x))throw new f("`transport` must be created via createTransport()");if(e.transport.closed)throw new f("Transport has been closed");let A=void 0!==e.proxy;if(void 0!==e.browser||void 0!==e.os||void 0!==e.emulation||A||void 0!==e.insecure)throw new f("`transport` cannot be combined with browser/os/emulation/proxy/insecure options");return{transportId:e.transport.id}}if(A?.transportId){if(void 0!==e.emulation)throw new f("Session emulation cannot be changed after creation");if(void 0!==e.browser){Z(e.browser);let t="custom"===A.transportMode.kind?void 0:A.transportMode.browser;if(e.browser!==t)throw new f("Session browser cannot be changed after creation")}if(void 0!==e.os){j(e.os);let t="custom"===A.transportMode.kind?void 0:A.transportMode.os;if(e.os!==t)throw new f("Session operating system cannot be changed after creation")}let t=Object.hasOwn(e,"proxy"),r=t?e.proxy:void 0;if(t&&void 0!==r&&(A.proxy??null)!==(r??null))throw new f("Session proxy cannot be changed after creation");if(void 0!==e.insecure){let t=A.insecure??!1;if(e.insecure!==t)throw new f("Session insecure setting cannot be changed after creation")}return{transportId:A.transportId}}let t={mode:eE(e.browser,e.os,e.emulation)};return void 0!==e.proxy&&(t.proxy=e.proxy),void 0!==e.insecure&&(t.insecure=e.insecure),t}(s,o),E=s.timeout??o?.timeout??3e5,Q={url:r,method:a,sessionId:n.sessionId,ephemeral:n.dropAfterRequest};return void 0!==g&&(Q.body=g),c.transportId?Q.transportId=c.transportId:(void 0!==c.mode&&eQ(Q,c.mode),void 0!==c.proxy&&(Q.proxy=c.proxy),void 0!==c.insecure&&(Q.insecure=c.insecure)),Q.timeout=E,void 0!==s.redirect&&(Q.redirect=s.redirect),void 0!==s.disableDefaultHeaders&&(Q.disableDefaultHeaders=s.disableDefaultHeaders),void 0!==s.compress&&(Q.compress=s.compress),h&&h.length>0&&(Q.headers=h),eu(Q,r,s.signal??null)}async function eB(e){let A=eE(e?.browser,e?.os,e?.emulation);e?.poolIdleTimeout!==void 0&&z(e.poolIdleTimeout,"poolIdleTimeout"),e?.poolMaxIdlePerHost!==void 0&&K(e.poolMaxIdlePerHost,"poolMaxIdlePerHost"),e?.poolMaxSize!==void 0&&$(e.poolMaxSize,"poolMaxSize"),e?.connectTimeout!==void 0&&z(e.connectTimeout,"connectTimeout"),e?.readTimeout!==void 0&&z(e.readTimeout,"readTimeout");try{let t={...e?.proxy!==void 0&&{proxy:e.proxy},...e?.insecure!==void 0&&{insecure:e.insecure},...e?.poolIdleTimeout!==void 0&&{poolIdleTimeout:e.poolIdleTimeout},...e?.poolMaxIdlePerHost!==void 0&&{poolMaxIdlePerHost:e.poolMaxIdlePerHost},...e?.poolMaxSize!==void 0&&{poolMaxSize:e.poolMaxSize},...e?.connectTimeout!==void 0&&{connectTimeout:e.connectTimeout},...e?.readTimeout!==void 0&&{readTimeout:e.readTimeout}};eQ(t,A);let s=r.createTransport(t);return new x(s)}catch(e){throw new f(String(e))}}async function eC(e){let A,t,s,n,{sessionId:o,defaults:i}=(s=e?.sessionId??(0,u.randomUUID)(),n={transportMode:eE(e?.browser,e?.os,e?.emulation)},e?.proxy!==void 0&&(n.proxy=e.proxy),e?.timeout!==void 0&&(X(e.timeout),n.timeout=e.timeout),e?.insecure!==void 0&&(n.insecure=e.insecure),e?.defaultHeaders!==void 0&&(n.defaultHeaders=k(e.defaultHeaders)),{sessionId:s,defaults:n});try{let e={...void 0!==i.proxy&&{proxy:i.proxy},...void 0!==i.insecure&&{insecure:i.insecure}};eQ(e,i.transportMode),t=r.createTransport(e)}catch(e){throw new f(String(e))}try{A=r.createSession({sessionId:o})}catch(e){try{r.dropTransport(t)}catch{}throw new f(String(e))}return i.transportId=t,i.ownsTransport=!0,new G(A,i)}async function ed(e,A){let t=await eC(A);try{return await e(t)}finally{await t.close()}}async function ef(e){if(!e.url)throw new f("URL is required");let{url:A,...t}=e,r={};return void 0!==t.method&&(r.method=t.method),void 0!==t.headers&&(r.headers=t.headers),void 0!==t.body&&(r.body=t.body),void 0!==t.browser&&(r.browser=t.browser),void 0!==t.os&&(r.os=t.os),void 0!==t.emulation&&(r.emulation=t.emulation),void 0!==t.proxy&&(r.proxy=t.proxy),void 0!==t.timeout&&(r.timeout=t.timeout),void 0!==t.sessionId&&(r.sessionId=t.sessionId),void 0!==t.transport&&(r.transport=t.transport),void 0!==t.insecure&&(r.insecure=t.insecure),void 0!==t.disableDefaultHeaders&&(r.disableDefaultHeaders=t.disableDefaultHeaders),void 0!==t.redirect&&(r.redirect=t.redirect),void 0!==t.signal&&(r.signal=t.signal),void 0!==t.session&&(r.session=t.session),void 0!==t.cookieMode?r.cookieMode=t.cookieMode:!0===t.ephemeral&&(r.cookieMode="ephemeral"),eI(A,r)}function ep(){return s||(s=r.getProfiles()),s}function ey(){if(!o){let e=r.getOperatingSystems?.();o=e&&e.length>0?e:[...N]}return o}async function eD(e,A){let t={};return A&&Object.assign(t,A),t.method="GET",eI(e,t)}async function eS(e,A,t){let r={};return t&&Object.assign(r,t),r.method="POST",void 0!==A&&(r.body=A),eI(e,r)}function ew(e){let A,t=String(e).trim();if(!t)throw new f("URL is required");try{A=new URL(t)}catch(e){throw new f(String(e))}if(A.hash)throw new f("WebSocket URL must not include a hash fragment");if("http:"===A.protocol?A.protocol="ws:":"https:"===A.protocol&&(A.protocol="wss:"),"ws:"!==A.protocol&&"wss:"!==A.protocol)throw new f("expected a ws: or wss: url");return A.toString()}function em(e){if(void 0===e)return;let A=new Set,t=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;for(let r of"string"==typeof e?[e]:e){if("string"!=typeof r||0===r.length)throw new f("WebSocket protocol values must be non-empty strings");if(!t.test(r))throw new f(`Invalid WebSocket protocol value: ${r}`);if(A.has(r))throw new f(`Duplicate WebSocket protocol: ${r}`);A.add(r)}}function eN(e){let A={};if(!e)return A;if(void 0!==e.browser&&(A.browser=e.browser),void 0!==e.os&&(A.os=e.os),void 0!==e.emulation&&(A.emulation=e.emulation),void 0!==e.headers&&(A.headers=e.headers),void 0!==e.proxy&&(A.proxy=e.proxy),void 0!==e.protocols&&(A.protocols=e.protocols),void 0!==e.binaryType){if("nodebuffer"!==e.binaryType&&"arraybuffer"!==e.binaryType&&"blob"!==e.binaryType)throw new f("binaryType must be one of: 'nodebuffer', 'arraybuffer', 'blob'");A.binaryType=e.binaryType}return A}function eR(e){let A={};if(!e)return A;if(void 0!==e.browser)throw new f("`browser` is not supported in session.websocket(); the session controls browser emulation.");if(void 0!==e.os)throw new f("`os` is not supported in session.websocket(); the session controls OS emulation.");if(void 0!==e.emulation)throw new f("`emulation` is not supported in session.websocket(); the session transport controls emulation.");if(void 0!==e.proxy)throw new f("`proxy` is not supported in session.websocket(); the session transport controls proxying.");if(void 0!==e.headers&&(A.headers=e.headers),void 0!==e.protocols&&(A.protocols=e.protocols),void 0!==e.binaryType){if("nodebuffer"!==e.binaryType&&"arraybuffer"!==e.binaryType&&"blob"!==e.binaryType)throw new f("binaryType must be one of: 'nodebuffer', 'arraybuffer', 'blob'");A.binaryType=e.binaryType}return A}function eb(e){if(!U(e))return;let A={};return"function"==typeof e.onMessage&&(A.onMessage=e.onMessage),"function"==typeof e.onClose&&(A.onClose=e.onClose),"function"==typeof e.onError&&(A.onError=e.onError),Object.keys(A).length>0?A:void 0}function eU(e){return"open"===e||"message"===e||"close"===e||"error"===e}var eF=class e{static CONNECTING=0;static OPEN=1;static CLOSING=2;static CLOSED=3;url;protocol="";extensions="";readyState=e.CONNECTING;_binaryType="nodebuffer";_bufferedAmount=0;_onopen=null;_onmessage=null;_onclose=null;_onerror=null;_onHandlerOrder={open:-1,message:-1,close:-1,error:-1};_listenerOrderCounter=0;_listeners={open:new Map,message:new Map,close:new Map,error:new Map};_legacyCallbacks;_openDispatchMode;_connection;_connectPromise;_closeOptions;_finalizerToken;_openEventDispatched=!1;_openEventQueued=!1;_closeEventDispatched=!1;_nativeCloseStarted=!1;_pendingMessages=[];_sendChain=Promise.resolve();constructor(A,t,r){let s;s=!function(e){return!!U(e)&&!0===e._internal&&"string"==typeof e.url&&"function"==typeof e.connect}(A)?e.buildStandaloneInit(A,t,r):A,this.url=s.url,this.binaryType=s.options.binaryType??"nodebuffer",this._legacyCallbacks=s.legacyCallbacks,this._openDispatchMode=s.openDispatchMode,this._connectPromise=this.connect(s.connect),this._connectPromise.catch(()=>void 0)}get binaryType(){return this._binaryType}set binaryType(e){("arraybuffer"===e||"blob"===e||"nodebuffer"===e)&&(this._binaryType=e)}get bufferedAmount(){return this._bufferedAmount}get onopen(){return this._onopen}set onopen(e){this._onopen=e,this._onHandlerOrder.open=e?++this._listenerOrderCounter:-1}get onmessage(){return this._onmessage}set onmessage(e){this._onmessage=e,this._onHandlerOrder.message=e?++this._listenerOrderCounter:-1}get onclose(){return this._onclose}set onclose(e){this._onclose=e,this._onHandlerOrder.close=e?++this._listenerOrderCounter:-1}get onerror(){return this._onerror}set onerror(e){this._onerror=e,this._onHandlerOrder.error=e?++this._listenerOrderCounter:-1}static async _connectWithInit(A){let t=new e(A);return await t._waitUntilConnected(),t.scheduleOpenEventAfterAwait(),t}static buildStandaloneInit(e,A,t){let s="string"==typeof A||Array.isArray(A)?t:A??t,n=eN(s);em("string"==typeof A||Array.isArray(A)?A:n.protocols),T(n.headers);let o=eE(n.browser,n.os,n.emulation),i=L("string"==typeof A||Array.isArray(A)?A:n.protocols);return{_internal:!0,url:ew(e),options:n,openDispatchMode:"automatic",connect:A=>{let t={url:ew(e),headers:k(n.headers??{}),...i&&i.length>0&&{protocols:i},...void 0!==n.proxy&&{proxy:n.proxy},onMessage:A.onMessage,onClose:A.onClose,onError:A.onError};return eQ(t,o),r.websocketConnect(t)},legacyCallbacks:eb(s)}}async connect(A){try{let t=await A({onMessage:e=>{this.handleNativeMessage(e)},onClose:e=>{this.handleNativeClose(e)},onError:e=>{this.handleNativeError(e)}});if(this._connection=t,this.protocol=t.protocol??"",this.extensions=t.extensions??"",D&&(this._finalizerToken=t,D.register(this,t,t)),this.readyState===e.CLOSING)return void this.startNativeClose();this.readyState=e.OPEN,"automatic"===this._openDispatchMode&&this.scheduleOpenEventAfterConnect()}catch(e){throw this.handleNativeError(String(e)),this.finalizeClosed({code:1006,reason:""},!1),new f(String(e))}}_waitUntilConnected(){return this._connectPromise}scheduleOpenEventAfterConnect(){this.scheduleOpenEventWithDepth(2)}scheduleOpenEventAfterAwait(){this.scheduleOpenEventWithDepth(3)}scheduleOpenEventWithDepth(A){if(this._openEventDispatched||this._openEventQueued||this.readyState!==e.OPEN)return;this._openEventQueued=!0;let t=A=>{if(0===A){if(this._openEventQueued=!1,this._openEventDispatched||this.readyState!==e.OPEN)return;this._openEventDispatched=!0,this.dispatchOpenEvent();return}queueMicrotask(()=>{t(A-1)})};t(A)}releaseConnectionTracking(){this._finalizerToken&&D&&(D.unregister(this._finalizerToken),this._finalizerToken=void 0)}toMessageEventData(e){if("string"==typeof e)return e;if("arraybuffer"===this._binaryType){let A=new ArrayBuffer(e.byteLength);return new Uint8Array(A).set(e),A}return"blob"===this._binaryType?new Blob([e]):e}invokeListener(e,A){try{"function"==typeof e?e.call(this,A):e.handleEvent(A)}catch{}}createBaseEvent(e){return{type:e,isTrusted:!1,timeStamp:Date.now(),target:this,currentTarget:this}}getOnHandler(e){switch(e){case"open":return this._onopen;case"message":return this._onmessage;case"close":return this._onclose;case"error":return this._onerror;default:return null}}getOnHandlerOrder(e){return this._onHandlerOrder[e]}getListenerMap(e){return this._listeners[e]}dispatchEvent(e,A){let t=this.getListenerMap(e),r=this.getOnHandler(e);if(0===t.size&&!r)return;let s=[];for(let e of t.values())s.push({order:e.order,listener:e.listener,once:e.once});for(let t of(r&&s.push({order:this.getOnHandlerOrder(e),listener:r,once:!1}),s.sort((e,A)=>e.order-A.order),s))t.once&&this.removeEventListener(e,t.listener),this.invokeListener(t.listener,A)}dispatchOpenEvent(){let e=this.createBaseEvent("open");if(this.dispatchEvent("open",e),!this._closeEventDispatched&&this._pendingMessages.length>0){let e=this._pendingMessages;for(let A of(this._pendingMessages=[],e))this.dispatchMessageEvent(this.toMessageEventData(A))}}dispatchMessageEvent(e){let A={...this.createBaseEvent("message"),data:e};this.dispatchEvent("message",A)}dispatchCloseEvent(e){this.dispatchEvent("close",e)}dispatchErrorEvent(e){let A={...this.createBaseEvent("error"),...void 0!==e&&{message:e}};this.dispatchEvent("error",A)}handleNativeMessage(A){if(!this._closeEventDispatched){if(this._legacyCallbacks?.onMessage?.(A),!this._openEventDispatched&&this.readyState===e.OPEN)return void this._pendingMessages.push(A);this.dispatchMessageEvent(this.toMessageEventData(A))}}handleNativeError(e){this._legacyCallbacks?.onError?.(e),this.dispatchErrorEvent(e)}handleNativeClose(A){let t=this.readyState===e.CLOSING||1e3===A.code;this.finalizeClosed(A,t)}finalizeClosed(A,t){if(this._closeEventDispatched)return;this.readyState=e.CLOSED,this._closeEventDispatched=!0,this._pendingMessages=[],this.releaseConnectionTracking();let r={...this.createBaseEvent("close"),code:A.code,reason:A.reason,wasClean:t};this._legacyCallbacks?.onClose?.(r),this.dispatchCloseEvent(r)}startNativeClose(){if(this._nativeCloseStarted||!this._connection)return;this._nativeCloseStarted=!0;let e=this._connection,A=this._closeOptions;r.websocketClose(e,A).catch(e=>{this.handleNativeError(String(e)),this.finalizeClosed({code:1006,reason:""},!1)})}addEventListener(e,A,t){if(!A||!eU(e)||"function"!=typeof A&&("object"!=typeof A||null===A||"function"!=typeof A.handleEvent))return;let r=this.getListenerMap(e);if(r.has(A))return;let s="boolean"==typeof t?{}:t??{},n=!0===s.once,o=s.signal;if(o?.aborted)return;let i={listener:A,order:++this._listenerOrderCounter,once:n};if(o){let t=()=>{this.removeEventListener(e,A)};i.abortSignal=o,i.abortHandler=t,o.addEventListener("abort",t,{once:!0})}r.set(A,i)}removeEventListener(e,A){if(!A||!eU(e)||"function"!=typeof A&&"object"!=typeof A)return;let t=this.getListenerMap(e),r=t.get(A);r&&(r.abortSignal&&r.abortHandler&&r.abortSignal.removeEventListener("abort",r.abortHandler),t.delete(A))}getSendByteLength(e){if("string"==typeof e)return Buffer.byteLength(e);if(Buffer.isBuffer(e)||e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;if("u">typeof Blob&&e instanceof Blob)return e.size;throw TypeError("WebSocket data must be a string, Buffer, ArrayBuffer, ArrayBufferView, or Blob")}async normalizeSendPayload(e){if("string"==typeof e||Buffer.isBuffer(e))return e;if(e instanceof ArrayBuffer)return Buffer.from(e);if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);if("u">typeof Blob&&e instanceof Blob)return Buffer.from(await e.arrayBuffer());throw TypeError("WebSocket data must be a string, Buffer, ArrayBuffer, ArrayBufferView, or Blob")}send(A){if(this.readyState!==e.OPEN||!this._connection)throw new f("WebSocket is not open");let t=this.getSendByteLength(A),s=this._connection;this._bufferedAmount+=t;let n=async()=>{try{let e=await this.normalizeSendPayload(A);await r.websocketSend(s,e)}catch(e){this.handleNativeError(String(e)),this.finalizeClosed({code:1006,reason:""},!1)}finally{this._bufferedAmount=Math.max(0,this._bufferedAmount-t)}};this._sendChain=this._sendChain.then(n,n)}close(A,t){this.readyState!==e.CLOSING&&this.readyState!==e.CLOSED&&(this._closeOptions=function(e,A){if(void 0===e&&void 0===A)return;if(void 0===e)throw new f("A close code is required when providing a close reason");if(!Number.isInteger(e))throw new f("Close code must be an integer");if(1e3!==e&&(e<3e3||e>4999))throw new f("Close code must be 1000 or in range 3000-4999");let t=A??"";if(Buffer.byteLength(t,"utf8")>123)throw new f("Close reason must be 123 bytes or fewer");return{code:e,reason:t}}(A,t),this.readyState=e.CLOSING,this.startNativeClose())}};async function ek(e,A){let t=function(e,A){if("string"==typeof e||e instanceof URL){let t=eN(A);return{url:ew(e),options:t,legacyCallbacks:eb(A)}}let t=eN(e);return{url:ew(e.url),options:t,legacyCallbacks:eb(e)}}(e,A);em(t.options.protocols),T(t.options.headers);let s=eE(t.options.browser,t.options.os,t.options.emulation),n=L(t.options.protocols);return eF._connectWithInit({_internal:!0,url:t.url,options:t.options,openDispatchMode:"deferred",connect:e=>{let A={url:t.url,headers:k(t.options.headers??{}),...n&&n.length>0&&{protocols:n},...void 0!==t.options.proxy&&{proxy:t.options.proxy},onMessage:e.onMessage,onClose:e.onClose,onError:e.onError};return eQ(A,s),r.websocketConnect(A)},legacyCallbacks:t.legacyCallbacks})}var eM={fetch:eI,request:ef,get:eD,post:eS,getProfiles:ep,getOperatingSystems:ey,createTransport:eB,createSession:eC,withSession:ed,websocket:ek,WebSocket:eF,Headers:F,Response:O,Transport:x,Session:G,RequestError:f}},435005,e=>{"use strict";let A,t;var r=e.i(359281);function s(e){return"number"==typeof e&&isFinite(e)?e:void 0}let n={quotaApiUrl:"https://cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels",loadProjectApiUrl:"https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",tokenUrl:"https://oauth2.googleapis.com/token",get clientId(){return r.PROVIDERS.antigravity.clientId},get clientSecret(){return r.PROVIDERS.antigravity.clientSecret},userAgent:"antigravity/1.11.3 Darwin/arm64"},o="2023-06-01";function i(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function a(e,A=0){let t="number"==typeof e?e:"string"==typeof e&&e.trim().length>0?Number(e):NaN;return Number.isFinite(t)?t:A}function l(e,A,t){let r=i(e);return r[A]??r[t]??null}function g(e){return Math.max(0,Math.min(100,e))}function h(e){return e.replace(/^copilot[_\s-]*/i,"").split(/[\s_-]+/).filter(Boolean).map(e=>/^pro\+$/i.test(e)?"Pro+":/^[a-z]{2,}$/.test(e)?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e).join(" ").trim()}function c(e){return!!e&&(!e.unlimited||!(e.total<=0))&&(e.total>0||void 0!==e.remainingPercentage)}async function E(e){let{provider:A,accessToken:t,providerSpecificData:r}=e;switch(A){case"github":return await u(t,r);case"gemini-cli":return await C(t);case"antigravity":return await f(t,void 0);case"claude":return await D(t);case"codex":return await w(t,r);case"kiro":return await m(t,r);case"kimi-coding":return await R(t);case"qwen":return await b(t,r);case"iflow":return await U(t);default:return{message:`Usage API not implemented for ${A}`}}}function Q(e){if(!e)return null;try{if(e instanceof Date)return e.toISOString();if("number"==typeof e||"string"==typeof e)return new Date(e).toISOString();return null}catch(A){return console.warn(`Failed to parse reset time: ${e}`,A),null}}async function u(e,A){try{if(!e)throw Error("No GitHub access token available. Please re-authorize the connection.");let A=await fetch("https://api.github.com/copilot_internal/user",{headers:{Authorization:`token ${e}`,Accept:"application/json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"GitHubCopilotChat/0.26.7","Editor-Version":"vscode/1.100.0","Editor-Plugin-Version":"copilot-chat/0.26.7"}});if(!A.ok){let e=await A.text();if(401===A.status||403===A.status)return{message:"GitHub token expired or permission denied. Please re-authenticate the connection."};throw Error(`GitHub API error: ${e}`)}let t=await A.json(),r=i(t);if(r.quota_snapshots){let e=i(r.quota_snapshots),A=Q(l(r,"quota_reset_date","quotaResetDate")),t=I(e.premium_interactions,A),s=I(e.chat,A),n=I(e.completions,A),o={};return c(t)&&(o.premium_interactions=t),c(s)&&(o.chat=s),c(n)&&(o.completions=n),{plan:B(r,t),resetDate:l(r,"quota_reset_date","quotaResetDate"),quotas:o}}if(r.monthly_quotas||r.limited_user_quotas){let e=i(r.monthly_quotas),A=i(r.limited_user_quotas),t=l(r,"limited_user_reset_date","limitedUserResetDate"),s=Q(t),n={},o=t=>{let r=a(l(e,t,t),0),o=Math.max(0,a(l(A,t,t),0));if(r<=0)return null;let i=Math.min(o,r);return n[t]={used:i,total:r,remaining:Math.max(r-i,0),remainingPercentage:g((r-i)/r*100),unlimited:!1,resetAt:s},n[t]},h=o("premium_interactions");return o("chat"),o("completions"),{plan:B(r,h),resetDate:t,quotas:n}}return{message:"GitHub Copilot connected. Unable to parse quota data."}}catch(e){throw Error(`Failed to fetch GitHub usage: ${e.message}`)}}function I(e,A=null){let t=i(e);if(0===Object.keys(t).length)return null;let r=!0===t.unlimited,s=a(t.entitlement,NaN),n=a(t.total,NaN),o=a(t.remaining,NaN),h=a(t.used,NaN),c=a(l(t,"percent_remaining","percentRemaining"),NaN),E=Number.isFinite(n)?Math.max(0,n):Number.isFinite(s)?Math.max(0,s):0,Q=Number.isFinite(o)?Math.max(0,o):void 0,u=Number.isFinite(h)?Math.max(0,h):void 0,B=Number.isFinite(c)?g(c):void 0;return void 0===u&&E>0&&void 0!==Q&&(u=Math.max(E-Q,0)),void 0===Q&&E>0&&void 0!==u&&(Q=Math.max(E-u,0)),void 0===B&&E>0&&void 0!==Q&&(B=g(Q/E*100)),E<=0&&void 0!==B&&(E=100,u=100-B,Q=B),{used:Math.max(0,u??0),total:E,remaining:Q,remainingPercentage:B,resetAt:A,unlimited:r}}function B(e,A){let t=l(e,"copilot_plan","copilotPlan"),r=l(e,"access_type_sku","accessTypeSku"),s="string"==typeof t?t.trim():"",n="string"==typeof r?r.trim():"",o=`${n} ${s}`.trim().toUpperCase(),g=i(l(e,"monthly_quotas","monthlyQuotas")),c=A?.total||a(l(g,"premium_interactions","premiumInteractions"),0),E=a(l(g,"chat","chat"),0);if(o.includes("PRO+")||o.includes("PRO_PLUS")||o.includes("PROPLUS"))return"Copilot Pro+";if(o.includes("ENTERPRISE"))return"Copilot Enterprise";if(o.includes("BUSINESS"))return"Copilot Business";if(o.includes("STUDENT"))return"Copilot Student";if(o.includes("FREE"))return"Copilot Free";if(o.includes("PRO"))return"Copilot Pro";if(c>=1400)return"Copilot Pro+";if(c>=900)return"Copilot Enterprise";if(c>=250)return o.includes("INDIVIDUAL")?"Copilot Pro":"Copilot Business";if(c>0||50===E)return"Copilot Free";if(n){let e=h(n);return e?`Copilot ${e}`:"GitHub Copilot"}if(s){let e=h(s);return e?`Copilot ${e}`:"GitHub Copilot"}return"GitHub Copilot"}async function C(e){try{if(!(await fetch("https://cloudresourcemanager.googleapis.com/v1/projects?filter=lifecycleState:ACTIVE",{headers:{Authorization:`Bearer ${e}`,Accept:"application/json"}})).ok)return{message:"Gemini CLI uses Google Cloud quotas. Check Google Cloud Console for details."};return{message:"Gemini CLI connected. Usage tracked via Google Cloud Console."}}catch(e){return{message:"Unable to fetch Gemini usage. Check Google Cloud Console."}}}let d=new Map;async function f(e,A){try{let A=await p(e),t=A?.cloudaicompanionProject||null,r=await fetch(n.quotaApiUrl,{method:"POST",headers:{Authorization:`Bearer ${e}`,"User-Agent":n.userAgent,"Content-Type":"application/json"},body:JSON.stringify(t?{project:t}:{})});if(403===r.status)return{message:"Antigravity access forbidden. Check subscription."};if(!r.ok)throw Error(`Antigravity API error: ${r.status}`);let s=await r.json(),o=i(s),l=i(o.models),g={};if(Object.keys(l).length>0){let e=["claude-opus-4-6-thinking","claude-sonnet-4-6","gemini-3.1-pro-high","gemini-3.1-pro-low","gemini-3-flash","gpt-oss-120b-medium"];for(let[A,t]of Object.entries(l)){let r=i(t),s=i(r.quotaInfo);if(0===Object.keys(s).length||!0===r.isInternal||!e.includes(A))continue;let n=a(s.remainingFraction,0),o=100*n,l=Math.round(1e3*n),h=1e3-l;g[A]={used:h,total:1e3,resetAt:Q(s.resetTime),remainingPercentage:o,unlimited:!1,displayName:"string"==typeof r.displayName?r.displayName:A}}}return{plan:function(e){if(!e||0===Object.keys(e).length)return"Free";let A="";if(Array.isArray(e.allowedTiers)){for(let t of e.allowedTiers)if(t.isDefault&&t.id){A=t.id.trim().toUpperCase();break}}if(A||(A=(e.currentTier?.id||"").toUpperCase()),A){if(A.includes("ULTRA"))return"Ultra";if(A.includes("PRO"))return"Pro";if(A.includes("ENTERPRISE"))return"Enterprise";if(A.includes("BUSINESS")||A.includes("STANDARD"))return"Business";if(A.includes("FREE")||A.includes("INDIVIDUAL")||A.includes("LEGACY"))return"Free"}let t=e.currentTier?.name||e.currentTier?.displayName||e.subscriptionType||e.tier||"",r=t.toUpperCase();return r.includes("ULTRA")?"Ultra":r.includes("PRO")?"Pro":r.includes("ENTERPRISE")?"Enterprise":r.includes("STANDARD")||r.includes("BUSINESS")?"Business":r.includes("INDIVIDUAL")||r.includes("FREE")||e.currentTier?.upgradeSubscriptionType?"Free":t?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():"Free"}(A),quotas:g,subscriptionInfo:A}}catch(e){return{message:`Antigravity error: ${e.message}`}}}async function p(e){let A=e.substring(0,16),t=d.get(A);if(t&&Date.now()-t.fetchedAt<3e5)return t.data;let r=await y(e);return d.set(A,{data:r,fetchedAt:Date.now()}),r}async function y(e){try{let A=await fetch(n.loadProjectApiUrl,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","User-Agent":"google-api-nodejs-client/9.15.1","X-Goog-Api-Client":"google-cloud-sdk vscode_cloudshelleditor/0.1","Client-Metadata":JSON.stringify({ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"})},body:JSON.stringify({metadata:{ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"}})});if(!A.ok)return null;return await A.json()}catch{return null}}async function D(e){try{let A=await fetch("https://api.anthropic.com/api/oauth/usage",{method:"GET",headers:{Authorization:`Bearer ${e}`,"anthropic-beta":"oauth-2025-04-20","anthropic-version":o}});if(A.ok){let e=await A.json(),t={},r=e=>e&&"object"==typeof e&&void 0!==s(e.utilization),n=e=>{let A=s(e.utilization),t=Math.max(0,100-A);return{used:A,total:100,remaining:t,resetAt:Q(e.resets_at),remainingPercentage:t,unlimited:!1}};for(let[A,s]of(r(e.five_hour)&&(t["session (5h)"]=n(e.five_hour)),r(e.seven_day)&&(t["weekly (7d)"]=n(e.seven_day)),Object.entries(e))){let e=i(s);if(A.startsWith("seven_day_")&&"seven_day"!==A&&r(e)){let r=A.replace("seven_day_","");t[`weekly ${r} (7d)`]=n(e)}}return{plan:("string"==typeof e.tier?e.tier:"string"==typeof e.plan?e.plan:"string"==typeof e.subscription_type?e.subscription_type:null)||"Claude Code",quotas:t,extraUsage:e.extra_usage??null}}return console.warn(`[Claude Usage] OAuth endpoint returned ${A.status}, falling back to legacy`),await S(e)}catch(e){return{message:`Claude connected. Unable to fetch usage: ${e.message}`}}}async function S(e){try{let A=await fetch("https://api.anthropic.com/v1/settings",{method:"GET",headers:{Authorization:`Bearer ${e}`,"anthropic-version":o}});if(A.ok){let t=await A.json();if(t.organization_id){let A=await fetch("https://api.anthropic.com/v1/organizations/{org_id}/usage".replace("{org_id}",t.organization_id),{method:"GET",headers:{Authorization:`Bearer ${e}`,"anthropic-version":o}});if(A.ok){let e=await A.json();return{plan:t.plan||"Unknown",organization:t.organization_name,quotas:e}}}return{plan:t.plan||"Unknown",organization:t.organization_name,message:"Claude connected. Usage details require admin access."}}return{message:"Claude connected. Usage API requires admin permissions."}}catch(e){return{message:`Claude connected. Unable to fetch usage: ${e.message}`}}}async function w(e,A={}){try{let t="string"==typeof A.workspaceId?A.workspaceId:null,r={Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"};t&&(r["chatgpt-account-id"]=t);let s=await fetch("https://chatgpt.com/backend-api/wham/usage",{method:"GET",headers:r});if(!s.ok){if(401===s.status||403===s.status)return{message:"Codex token expired or access denied. Please re-authenticate the connection."};throw Error(`Codex API error: ${s.status}`)}let n=await s.json(),o=i(l(n,"rate_limit","rateLimit")),g=i(l(o,"primary_window","primaryWindow")),h=i(l(o,"secondary_window","secondaryWindow")),c=e=>{let A=a(l(e,"reset_at","resetAt"),0),t=a(l(e,"reset_after_seconds","resetAfterSeconds"),0);return A>0?Q(1e3*A):t>0?Q(Date.now()+1e3*t):null},E={};if(Object.keys(g).length>0){let e=a(l(g,"used_percent","usedPercent"),0);E.session={used:e,total:100,remaining:100-e,resetAt:c(g),unlimited:!1}}if(Object.keys(h).length>0){let e=a(l(h,"used_percent","usedPercent"),0);E.weekly={used:e,total:100,remaining:100-e,resetAt:c(h),unlimited:!1}}let u=i(l(n,"code_review_rate_limit","codeReviewRateLimit")),I=i(l(u,"primary_window","primaryWindow")),B=l(I,"used_percent","usedPercent"),C=l(I,"remaining_count","remainingCount");if(null!==B||null!==C){let e=a(B,0);E.code_review={used:e,total:100,remaining:100-e,resetAt:c(I),unlimited:!1}}return{plan:String(l(n,"plan_type","planType")||"unknown"),limitReached:!!l(o,"limit_reached","limitReached"),quotas:E}}catch(e){return{message:`Failed to fetch Codex usage: ${e.message}`}}}async function m(e,A){try{let t=A?.profileArn;if(!t)return{message:"Kiro connected. Profile ARN not available for quota tracking."};let r=await fetch("https://codewhisperer.us-east-1.amazonaws.com",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/x-amz-json-1.0","x-amz-target":"AmazonCodeWhispererService.GetUsageLimits",Accept:"application/json"},body:JSON.stringify({origin:"AI_EDITOR",profileArn:t,resourceType:"AGENTIC_REQUEST"})});if(!r.ok){let e=await r.text();throw Error(`Kiro API error (${r.status}): ${e}`)}let s=await r.json(),n=s.usageBreakdownList||[],o={},i=Q(s.nextDateReset||s.resetDate);return n.forEach(e=>{let A=e.resourceType?.toLowerCase()||"unknown",t=e.currentUsageWithPrecision||0,r=e.usageLimitWithPrecision||0;if(o[A]={used:t,total:r,remaining:r-t,resetAt:i,unlimited:!1},e.freeTrialInfo){let t=e.freeTrialInfo.currentUsageWithPrecision||0,r=e.freeTrialInfo.usageLimitWithPrecision||0;o[`${A}_freetrial`]={used:t,total:r,remaining:r-t,resetAt:i,unlimited:!1}}}),{plan:s.subscriptionInfo?.subscriptionTitle||"Kiro",quotas:o}}catch(e){throw Error(`Failed to fetch Kiro usage: ${e.message}`)}}function N(e){return e?({LEVEL_BASIC:"Moderato",LEVEL_INTERMEDIATE:"Allegretto",LEVEL_ADVANCED:"Allegro",LEVEL_STANDARD:"Vivace"})[e]||e.replace("LEVEL_","").toLowerCase():""}async function R(e){let A="kimi-usage-"+Date.now(),t="u">typeof process?`${process.platform} ${process.arch}`:"unknown";try{let r,n=await fetch("https://api.kimi.com/coding/v1/usages",{method:"GET",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-Msh-Platform":"omniroute","X-Msh-Version":"2.1.2","X-Msh-Device-Model":t,"X-Msh-Device-Id":A}}),o=await n.text();if(!n.ok)return{plan:"Kimi Coding",message:`Kimi Coding connected. API Error ${n.status}: ${o.slice(0,100)}`};try{r=JSON.parse(o)}catch{return{plan:"Kimi Coding",message:"Kimi Coding connected. Invalid JSON response from API."}}let l={},g=i(r),h=i(g.usage),c=a(h.limit||h.Limit,0),E=a(h.used||h.Used,0),u=a(h.remaining||h.Remaining,0),I=h.resetTime||h.ResetTime||h.reset_at||h.resetAt;c>0&&(l.Weekly={used:E,total:c,remaining:u,remainingPercentage:c>0?u/c*100:0,resetAt:Q(I),unlimited:!1});let B=Array.isArray(g.limits)?g.limits:[];for(let e=0;e<B.length;e++){let A=i(B[e]);i(A.window);let t=i(A.detail),r=a(t.limit||t.Limit,0),s=a(t.remaining||t.Remaining,0),n=t.resetTime||t.reset_at||t.resetAt;r>0&&(l.Ratelimit={used:r-s,total:r,remaining:s,remainingPercentage:r>0?s/r*100:0,resetAt:Q(n),unlimited:!1})}let C=e=>e&&"object"==typeof e&&void 0!==s(e.utilization),d=e=>{let A=s(e.utilization);return{used:100-A,total:100,remaining:A,resetAt:Q(e.resets_at),remainingPercentage:A,unlimited:!1}};for(let[e,A]of(C(i(g.five_hour))&&(l["session (5h)"]=d(i(g.five_hour))),C(i(g.seven_day))&&(l["weekly (7d)"]=d(i(g.seven_day))),Object.entries(g))){let t=i(A);if(e.startsWith("seven_day_")&&"seven_day"!==e&&C(t)){let A=e.replace("seven_day_","");l[`weekly ${A} (7d)`]=d(t)}}if(Object.keys(l).length>0){let e=i(g.user),A=i(e.membership).level;return{plan:N(A)||"Kimi Coding",quotas:l}}let f=i(g.user),p=i(f.membership).level;return{plan:N(p)||"Kimi Coding",message:"Kimi Coding connected. Usage tracked per request."}}catch(e){return{message:`Kimi Coding connected. Unable to fetch usage: ${e.message}`}}}async function b(e,A){try{if(!A?.resourceUrl)return{message:"Qwen connected. No resource URL available."};return{message:"Qwen connected. Usage tracked per request."}}catch(e){return{message:"Unable to fetch Qwen usage."}}}async function U(e){try{return{message:"iFlow connected. Usage tracked per request."}}catch(e){return{message:"Unable to fetch iFlow usage."}}}var F=e.i(543125);e.i(196039),e.i(335273),["host","connection","content-length","keep-alive","proxy-connection","transfer-encoding","te","trailer","upgrade"].map(e=>e.toLowerCase());var k=e.i(799537);e.i(896596);let M=new Map,T=new Map,L=new Map,v=new Map;(0,k.registerDbStateResetter)(function(){M.clear(),T.clear(),v.clear(),v.clear(),L.clear()});var H=e.i(974210);e.i(946393),e.i(687267);let Y=["litellm"];Number.isFinite(parseInt(process.env.PRICING_SYNC_INTERVAL||"86400",10)),(process.env.PRICING_SYNC_SOURCES||"litellm").split(",").map(e=>e.trim()).filter(e=>Y.includes(e)),e.i(254799);var O=e.i(478500),x=e.i(724055),G=e.i(425842);let V=Symbol.for("omniroute.proxyDispatcher.cache"),J=new Set(["http:","https:","socks5:"]);function _(e){try{let A=e.match(/:\/\/(?:[^@]*@)?[^:/\s]+:(\d+)/);if(A){let e=Number(A[1]);if(Number.isInteger(e)&&e>=1&&e<=65535)return String(e)}}catch{}return null}function P(e){return"https:"===e||"wss:"===e?"443":"socks5:"===e?"1080":"8080"}function W(e,A){if(!e)return P(A);let t=Number(e);if(!Number.isInteger(t)||t<1||t>65535)throw Error("[ProxyDispatcher] Invalid proxy port");return String(t)}function q(){return"true"===process.env.ENABLE_SOCKS5_PROXY}function Z(e){let A=_(e),t=new URL(e),r=A||t.port||P(t.protocol);return`${t.protocol}//${t.hostname}:${r}`}function j(e,A="proxy",{allowSocks5:t=q()}={}){var r;let s,n,o=_(e);try{s=new URL(e)}catch{throw Error(`[ProxyDispatcher] Invalid ${A} URL`)}if(!J.has(s.protocol))throw Error(`[ProxyDispatcher] Unsupported ${A} protocol: ${s.protocol.replace(":","")}`);if("socks5:"===s.protocol&&!t)throw Error("[ProxyDispatcher] SOCKS5 proxy is disabled (set ENABLE_SOCKS5_PROXY=true to enable)");if(!s.hostname)throw Error(`[ProxyDispatcher] Invalid ${A} host`);let i=o||W(s.port,s.protocol);return n=(r=s).username?`${r.username}${r.password?`:${r.password}`:""}@`:"",`${r.protocol}//${n}${r.hostname}:${i}`}function X(e,{allowSocks5:A=q()}={}){if(!e)return null;if("string"==typeof e)return j(e,"context proxy",{allowSocks5:A});if("object"!=typeof e||Array.isArray(e))throw Error("[ProxyDispatcher] Invalid context proxy config");let t=String(e.type||"http").toLowerCase(),r=`${t}:`;if(!J.has(r))throw Error(`[ProxyDispatcher] Unsupported context proxy protocol: ${t}`);if("socks5:"===r&&!A)throw Error("[ProxyDispatcher] SOCKS5 proxy is disabled (set ENABLE_SOCKS5_PROXY=true to enable)");if(!e.host)throw Error("[ProxyDispatcher] Context proxy host is required");let s=W(e.port,r),n=e.username?`${encodeURIComponent(e.username)}:${e.password?encodeURIComponent(e.password):""}@`:"";return j(`${t}://${n}${e.host}:${s}`,"context proxy",{allowSocks5:A})}(0,e.i(362562).createRequire)({get url(){return`file://${e.P("open-sse/utils/tlsClient.ts")}`}}.url);try{let t=e.r(621213);A="function"==typeof t.createSession?t.createSession:null}catch{A=null}let z=new class{session=null;available;constructor(){this.available=!!A}async getSession(){if(!this.available)return null;if(this.session)return this.session;let e=process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy||void 0,t={browser:"chrome_124",os:"macos"};return e&&(t.proxy=e,console.log(`[TlsClient] Using proxy: ${e}`)),this.session=await A(t),console.log("[TlsClient] Session created (Chrome 124 TLS fingerprint)"),this.session}async fetch(e,A={}){let t=await this.getSession();if(!t)throw Error("wreq-js not available");let r={method:(A.method||"GET").toUpperCase(),headers:function(e){if(!e)return;if(e instanceof Headers)return Object.fromEntries(e.entries());if(Array.isArray(e))return Object.fromEntries(e.map(([e,A])=>[e,String(A)]));let A={};for(let[t,r]of Object.entries(e))"string"==typeof r&&(A[t]=r);return A}(A.headers),body:A.body,redirect:"manual"===A.redirect?"manual":"follow"};return A.signal&&(r.signal=A.signal),await t.fetch(e,r)}async exit(){this.session&&(await this.session.close(),this.session=null)}};var K=e.i(761095);let $=parseInt(process.env.PROXY_FAST_FAIL_TIMEOUT_MS??"2000",10),ee=parseInt(process.env.PROXY_HEALTH_CACHE_TTL_MS??"30000",10),eA=new Map;async function et(e,A=$,t=ee){var r,s,n;let o,i=eA.get(e);if(i&&Date.now()-i.checkedAt<i.ttlMs)return i.healthy;try{o=new URL(e)}catch{return eA.set(e,{healthy:!1,checkedAt:Date.now(),ttlMs:t}),!1}let a=o.hostname,l=parseInt(o.port||function(e){switch(e.replace(":","").toLowerCase()){case"https":return"443";case"socks5":case"socks5h":return"1080";default:return"8080"}}(o.protocol),10);if(!a||isNaN(l))return eA.set(e,{healthy:!1,checkedAt:Date.now(),ttlMs:t}),!1;let g=await (r=a,s=l,n=A,new Promise(e=>{let A=(0,K.createConnection)({host:r,port:s},()=>{A.destroy(),e(!0)});A.setTimeout(n),A.on("error",()=>e(!1)),A.on("timeout",()=>{A.destroy(),e(!1)})}));return eA.set(e,{healthy:g,checkedAt:Date.now(),ttlMs:t}),g}let er=new O.AsyncLocalStorage,es="u">typeof caches&&"object"==typeof caches,en=Symbol.for("omniroute.proxyFetch.state"),eo=((t=globalThis)[en]||(t[en]={originalFetch:globalThis.fetch,proxyContext:new O.AsyncLocalStorage,isPatched:!1}),t[en]),ei=eo.originalFetch,ea=eo.proxyContext;async function el(e,A){if("function"!=typeof A)throw TypeError("runWithProxyContext requires a callback function");let t=e?X(e):null;if(t&&!await et(t)){let e=Z(t),A=Error(`[Proxy Fast-Fail] Proxy unreachable: ${e}`);throw A.code="PROXY_UNREACHABLE",A.statusCode=503,A}return ea.run(e||null,async()=>(t&&console.log(`[ProxyFetch] Applied request proxy context: ${Z(t)}`),A()))}async function eg(e,A={}){let t;if(A?.dispatcher)return ei(e,A);let r="string"==typeof e?e:e&&"string"==typeof e.url?e.url:String(e);try{t=function(e){let A=ea.getStore();if(A)return{source:"context",proxyUrl:X(A)};let t=function(e){let A;if(function(e){let A,t=process.env.NO_PROXY||process.env.no_proxy;if(!t)return!1;try{A=new URL(e)}catch{return!1}let r=A.hostname.toLowerCase(),s=A.port||("https:"===A.protocol?"443":"80");return t.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean).some(e=>{if("*"===e)return!0;let[A,t]=e.split(":");return(!t||t===s)&&!!A&&(A.startsWith(".")?r.endsWith(A)||r===A.slice(1):r===A||r.endsWith(`.${A}`))})}(e))return null;try{A=new URL(e).protocol}catch{return null}let t="https:"===A?process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy:process.env.HTTP_PROXY||process.env.http_proxy||process.env.ALL_PROXY||process.env.all_proxy;return t?j(t,"environment proxy"):null}(e);return t?{source:"env",proxyUrl:t}:{source:"direct",proxyUrl:null}}(r)}catch(A){let e=A instanceof Error?A.message:String(A);throw console.error(`[ProxyFetch] Proxy configuration error: ${e}`),A}let{source:s,proxyUrl:n}=t;if(!n){if("true"===process.env.ENABLE_TLS_FINGERPRINT&&z.available)try{let e=er.getStore();return e&&(e.used=!0),await z.fetch(r,{...A,headers:A.headers})}catch(t){let e=t instanceof Error?t.message:String(t);console.warn(`[ProxyFetch] TLS fingerprint failed, falling back to native fetch: ${e}`);let A=er.getStore();A&&(A.used=!1)}return ei(e,A)}try{let t=function(e){let A,t=j(e,"proxy dispatcher"),r=((A=globalThis)[V]||(A[V]=new Map),A[V]),s=r.get(t);if(s)return s;let n=new URL(t),o=_(t)||W(n.port,n.protocol);if("socks5:"===n.protocol){let e={type:5,host:n.hostname,port:Number(o)};n.username&&(e.userId=decodeURIComponent(n.username)),n.password&&(e.password=decodeURIComponent(n.password)),s=(0,G.socksDispatcher)(e)}else s=new x.ProxyAgent(t);return r.set(t,s),s}(n);return await ei(e,{...A,dispatcher:t})}catch(A){let e=A instanceof Error?A.message:String(A);throw console.error(`[ProxyFetch] Proxy request failed (${s}, fail-closed): ${e}`),A}}es||eo.isPatched||(globalThis.fetch=eg,eo.isPatched=!0);let eh=new Map,ec=null,eE=!1;function eQ(e){let A=new Date(e).getTime();return Number.isNaN(A)?null:A}function eu(e){return Number.isFinite(e)?Math.max(0,Math.min(100,e)):0}function eI(e){return"string"!=typeof e?"":e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function eB(e,A,t){let r,n=function(e){let A={};for(let[t,r]of Object.entries(e))r&&"object"==typeof r&&(A[t]={remainingPercentage:s(r.remainingPercentage)??(r.total>0?Math.round((r.total-(r.used||0))/r.total*100):0),resetAt:r.resetAt||null});return A}(t),o=0!==(r=Object.values(n)).length&&r.every(e=>e.remainingPercentage<=0);eh.set(e,{connectionId:e,provider:A,quotas:n,fetchedAt:Date.now(),exhausted:o,nextResetAt:o?function(e){let A=null,t=1/0;for(let r of Object.values(e)){if(!r.resetAt)continue;let e=eQ(r.resetAt);null!==e&&e<t&&(t=e,A=r.resetAt)}return A}(n):null})}function eC(e){return eh.get(e)||null}function ed(e){let A=eh.get(e);if(!A||!A.exhausted)return!1;let t=Date.now();if(function(e,A){if(!e.nextResetAt)return null;let t=eQ(e.nextResetAt);return null===t?null:t<=A||e.windowDurationMs&&e.windowDurationMs>0&&A-t>=0?{exhausted:!1}:null}(A,t))return A.exhausted=!1,!1;let r=t-A.fetchedAt;return!!A.nextResetAt||!(r>3e5)}function ef(e,A,t=90){let r=eh.get(e);if(!r)return null;let s=Date.now(),n=function(e,A){let t=e[A];if(t)return t;let r=eI(A);if(!r)return null;let s=[];for(let[A,t]of Object.entries(e)){let e=eI(A);if(e){if(e===r)return t;e.startsWith(`${r} `)&&s.push({key:A,quota:t})}}return s.length>0?(s.sort((e,A)=>e.key.localeCompare(A.key)),s[0].quota):null}(r.quotas,A);if(!n)return null;let o=eu(n.remainingPercentage),i=eu(100-o),a=n.resetAt||null,l=!1;if(a){let e=eQ(a);null!==e&&e<=s&&(a=null,l=!0)}return{remainingPercentage:o,usedPercentage:i,resetAt:a,reachedThreshold:!l&&i>=t}}function ep(e,A){eh.set(e,{connectionId:e,provider:A,quotas:{},fetchedAt:Date.now(),exhausted:!0,nextResetAt:null})}let ey=new Set;async function eD(e){if(!ey.has(e.connectionId)){ey.add(e.connectionId);try{let A=await (0,F.getProviderConnectionById)(e.connectionId);if(!A||"oauth"!==A.authType||!A.isActive)return void eh.delete(e.connectionId);let t=await (0,H.resolveProxyForConnection)(e.connectionId),r=await el(t?.proxy||null,()=>E(A));r?.quotas&&eB(e.connectionId,e.provider,r.quotas)}catch(A){console.warn(`[QuotaCache] Refresh failed for ${e.connectionId.slice(0,8)}:`,A?.message||A)}finally{ey.delete(e.connectionId)}}}async function eS(){if(!eE){eE=!0;try{let e=Date.now(),A=[...eh.values()].filter(A=>(function(e,A){let t=A-e.fetchedAt;if(e.exhausted&&e.nextResetAt){let t=eQ(e.nextResetAt);if(null!==t&&t<=A)return!0}return t>=3e5})(A,e));for(let e=0;e<A.length;e+=5){let t=A.slice(e,e+5);await Promise.allSettled(t.map(eD))}}finally{eE=!1}}}function ew(){ec||(ec=setInterval(eS,6e4),ec?.unref?.())}function em(){ec&&(clearInterval(ec),ec=null)}function eN(){let e=[];for(let A of eh.values())e.push({connectionId:A.connectionId.slice(0,8)+"...",provider:A.provider,exhausted:A.exhausted,nextResetAt:A.nextResetAt,ageMs:Date.now()-A.fetchedAt});return{total:eh.size,entries:e}}e.s(["getQuotaCache",()=>eC,"getQuotaCacheStats",()=>eN,"getQuotaWindowStatus",()=>ef,"isAccountQuotaExhausted",()=>ed,"markAccountExhaustedFrom429",()=>ep,"setQuotaCache",()=>eB,"startBackgroundRefresh",()=>ew,"stopBackgroundRefresh",()=>em],435005)}];
|
|
121
121
|
|
|
122
122
|
//# sourceMappingURL=_ffda39da._.js.map
|