@oracle-agent/oracle 0.24.9 → 0.24.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -16
- package/dist/assets/skills/oracle-desk-product/SKILL.md +3 -3
- package/dist/bin/desk-server.mjs +49 -49
- package/dist/bin/oracle-data-mcp.mjs +2 -2
- package/dist/bin/oracle-public-server.mjs +22 -22
- package/dist/bin/oracle-route.mjs +1 -1
- package/dist/bin/oracle-scan.mjs +1 -1
- package/dist/bin/oracle-upgrade.mjs +9 -9
- package/dist/bin/oracle.mjs +6 -6
- package/dist/cli/commands/chat.mjs +84 -84
- package/dist/cli/commands/doctor.mjs +4 -4
- package/dist/cli/commands/model.mjs +89 -89
- package/dist/cli/commands/receipt.mjs +3 -3
- package/dist/cli/commands/sign.mjs +11 -11
- package/dist/cli/commands/signer.mjs +13 -11
- package/dist/cli/commands/swap.mjs +1 -1
- package/dist/cli/commands/venues.mjs +2 -2
- package/dist/data/desk-data.mjs +41 -41
- package/dist/index.mjs +56 -56
- package/dist/local-signer/index.mjs +3 -1
- package/dist/scanner/index.mjs +2 -2
- package/package.json +2 -1
- package/public/oracle-splash/downloads/index.html +3 -3
- package/public/oracle-splash/index.html +3 -3
package/dist/scanner/index.mjs
CHANGED
|
@@ -44,5 +44,5 @@ ${A.format(t)}
|
|
|
44
44
|
`.trim())}};uC.exports=Xa});var Ds=f((nM,yC)=>{"use strict";var dC=Symbol.for("undici.globalDispatcher.1"),{InvalidArgumentError:nk}=v(),sk=vt();wC()===void 0&&fC(new sk);function fC(e){if(!e||typeof e.dispatch!="function")throw new nk("Argument agent must implement Agent");Object.defineProperty(globalThis,dC,{value:e,writable:!0,enumerable:!1,configurable:!1})}function wC(){return globalThis[dC]}yC.exports={setGlobalDispatcher:fC,getGlobalDispatcher:wC}});var ms=f((iM,pC)=>{"use strict";pC.exports=class{#A;constructor(A){if(typeof A!="object"||A===null)throw new TypeError("handler must be an object");this.#A=A}onConnect(...A){return this.#A.onConnect?.(...A)}onError(...A){return this.#A.onError?.(...A)}onUpgrade(...A){return this.#A.onUpgrade?.(...A)}onResponseStarted(...A){return this.#A.onResponseStarted?.(...A)}onHeaders(...A){return this.#A.onHeaders?.(...A)}onData(...A){return this.#A.onData?.(...A)}onComplete(...A){return this.#A.onComplete?.(...A)}onBodySent(...A){return this.#A.onBodySent?.(...A)}}});var mC=f((oM,DC)=>{"use strict";var ik=rs();DC.exports=e=>{let A=e?.maxRedirections;return t=>function(n,s){let{maxRedirections:i=A,...o}=n;if(!i)return t(n,s);let a=new ik(t,i,n,s);return t(o,a)}}});var FC=f((aM,kC)=>{"use strict";var ok=Is();kC.exports=e=>A=>function(r,n){return A(r,new ok({...r,retryOptions:{...e,...r.retryOptions}},{handler:n,dispatch:A}))}});var bC=f((cM,RC)=>{"use strict";var ak=T(),{InvalidArgumentError:ck,RequestAbortedError:gk}=v(),Qk=ms(),_a=class extends Qk{#A=1024*1024;#e=null;#t=!1;#s=!1;#n=0;#r=null;#i=null;constructor({maxSize:A},t){if(super(t),A!=null&&(!Number.isFinite(A)||A<1))throw new ck("maxSize must be a number greater than 0");this.#A=A??this.#A,this.#i=t}onConnect(A){this.#e=A,this.#i.onConnect(this.#o.bind(this))}#o(A){this.#s=!0,this.#r=A}onHeaders(A,t,r,n){let i=ak.parseHeaders(t)["content-length"];if(i!=null&&i>this.#A)throw new gk(`Response size (${i}) larger than maxSize (${this.#A})`);return this.#s?!0:this.#i.onHeaders(A,t,r,n)}onError(A){this.#t||(A=this.#r??A,this.#i.onError(A))}onData(A){return this.#n=this.#n+A.length,this.#n>=this.#A&&(this.#t=!0,this.#s?this.#i.onError(this.#r):this.#i.onComplete([])),!0}onComplete(A){if(!this.#t){if(this.#s){this.#i.onError(this.reason);return}this.#i.onComplete(A)}}};function Ek({maxSize:e}={maxSize:1024*1024}){return A=>function(r,n){let{dumpMaxSize:s=e}=r,i=new _a({maxSize:s},n);return A(r,i)}}RC.exports=Ek});var UC=f((gM,SC)=>{"use strict";var{isIP:Bk}=d("node:net"),{lookup:Ik}=d("node:dns"),Ck=ms(),{InvalidArgumentError:_t,InformationalError:lk}=v(),NC=Math.pow(2,31)-1,ja=class{#A=0;#e=0;#t=new Map;dualStack=!0;affinity=null;lookup=null;pick=null;constructor(A){this.#A=A.maxTTL,this.#e=A.maxItems,this.dualStack=A.dualStack,this.affinity=A.affinity,this.lookup=A.lookup??this.#s,this.pick=A.pick??this.#n}get full(){return this.#t.size===this.#e}runLookup(A,t,r){let n=this.#t.get(A.hostname);if(n==null&&this.full){r(null,A.origin);return}let s={affinity:this.affinity,dualStack:this.dualStack,lookup:this.lookup,pick:this.pick,...t.dns,maxTTL:this.#A,maxItems:this.#e};if(n==null)this.lookup(A,s,(i,o)=>{if(i||o==null||o.length===0){r(i??new lk("No DNS entries found"));return}this.setRecords(A,o);let a=this.#t.get(A.hostname),c=this.pick(A,a,s.affinity),g;typeof c.port=="number"?g=`:${c.port}`:A.port!==""?g=`:${A.port}`:g="",r(null,`${A.protocol}//${c.family===6?`[${c.address}]`:c.address}${g}`)});else{let i=this.pick(A,n,s.affinity);if(i==null){this.#t.delete(A.hostname),this.runLookup(A,t,r);return}let o;typeof i.port=="number"?o=`:${i.port}`:A.port!==""?o=`:${A.port}`:o="",r(null,`${A.protocol}//${i.family===6?`[${i.address}]`:i.address}${o}`)}}#s(A,t,r){Ik(A.hostname,{all:!0,family:this.dualStack===!1?this.affinity:0,order:"ipv4first"},(n,s)=>{if(n)return r(n);let i=new Map;for(let o of s)i.set(`${o.address}:${o.family}`,o);r(null,i.values())})}#n(A,t,r){let n=null,{records:s,offset:i}=t,o;if(this.dualStack?(r==null&&(i==null||i===NC?(t.offset=0,r=4):(t.offset++,r=(t.offset&1)===1?6:4)),s[r]!=null&&s[r].ips.length>0?o=s[r]:o=s[r===4?6:4]):o=s[r],o==null||o.ips.length===0)return n;o.offset==null||o.offset===NC?o.offset=0:o.offset++;let a=o.offset%o.ips.length;return n=o.ips[a]??null,n==null?n:Date.now()-n.timestamp>n.ttl?(o.ips.splice(a,1),this.pick(A,t,r)):n}setRecords(A,t){let r=Date.now(),n={records:{4:null,6:null}};for(let s of t){s.timestamp=r,typeof s.ttl=="number"?s.ttl=Math.min(s.ttl,this.#A):s.ttl=this.#A;let i=n.records[s.family]??{ips:[]};i.ips.push(s),n.records[s.family]=i}this.#t.set(A.hostname,n)}getHandler(A,t){return new $a(this,A,t)}},$a=class extends Ck{#A=null;#e=null;#t=null;#s=null;#n=null;constructor(A,{origin:t,handler:r,dispatch:n},s){super(r),this.#n=t,this.#s=r,this.#e={...s},this.#A=A,this.#t=n}onError(A){switch(A.code){case"ETIMEDOUT":case"ECONNREFUSED":{if(this.#A.dualStack){this.#A.runLookup(this.#n,this.#e,(t,r)=>{if(t)return this.#s.onError(t);let n={...this.#e,origin:r};this.#t(n,this)});return}this.#s.onError(A);return}case"ENOTFOUND":this.#A.deleteRecord(this.#n);default:this.#s.onError(A);break}}};SC.exports=e=>{if(e?.maxTTL!=null&&(typeof e?.maxTTL!="number"||e?.maxTTL<0))throw new _t("Invalid maxTTL. Must be a positive number");if(e?.maxItems!=null&&(typeof e?.maxItems!="number"||e?.maxItems<1))throw new _t("Invalid maxItems. Must be a positive number and greater than zero");if(e?.affinity!=null&&e?.affinity!==4&&e?.affinity!==6)throw new _t("Invalid affinity. Must be either 4 or 6");if(e?.dualStack!=null&&typeof e?.dualStack!="boolean")throw new _t("Invalid dualStack. Must be a boolean");if(e?.lookup!=null&&typeof e?.lookup!="function")throw new _t("Invalid lookup. Must be a function");if(e?.pick!=null&&typeof e?.pick!="function")throw new _t("Invalid pick. Must be a function");let A=e?.dualStack??!0,t;A?t=e?.affinity??null:t=e?.affinity??4;let r={maxTTL:e?.maxTTL??1e4,lookup:e?.lookup??null,pick:e?.pick??null,dualStack:A,affinity:t,maxItems:e?.maxItems??1/0},n=new ja(r);return s=>function(o,a){let c=o.origin.constructor===URL?o.origin:new URL(o.origin);return Bk(c.hostname)!==0?s(o,a):(n.runLookup(c,o,(g,Q)=>{if(g)return a.onError(g);let E=null;E={...o,servername:c.hostname,origin:Q,headers:{host:c.hostname,...o.headers}},s(E,n.getHandler({origin:c,dispatch:s,handler:a},o))}),!0)}}});var nt=f((QM,JC)=>{"use strict";var{kConstruct:uk}=X(),{kEnumerableProperty:jt}=T(),{iteratorMixin:hk,isValidHeaderName:Kr,isValidHeaderValue:LC}=yA(),{webidl:J}=cA(),Ac=d("node:assert"),ks=d("node:util"),sA=Symbol("headers map"),kA=Symbol("headers map sorted");function MC(e){return e===10||e===13||e===9||e===32}function TC(e){let A=0,t=e.length;for(;t>A&&MC(e.charCodeAt(t-1));)--t;for(;t>A&&MC(e.charCodeAt(A));)++A;return A===0&&t===e.length?e:e.substring(A,t)}function YC(e,A){if(Array.isArray(A))for(let t=0;t<A.length;++t){let r=A[t];if(r.length!==2)throw J.errors.exception({header:"Headers constructor",message:`expected name/value pair to be length 2, found ${r.length}.`});ec(e,r[0],r[1])}else if(typeof A=="object"&&A!==null){let t=Object.keys(A);for(let r=0;r<t.length;++r)ec(e,t[r],A[t[r]])}else throw J.errors.conversionFailed({prefix:"Headers constructor",argument:"Argument 1",types:["sequence<sequence<ByteString>>","record<ByteString, ByteString>"]})}function ec(e,A,t){if(t=TC(t),Kr(A)){if(!LC(t))throw J.errors.invalidArgument({prefix:"Headers.append",value:t,type:"header value"})}else throw J.errors.invalidArgument({prefix:"Headers.append",value:A,type:"header name"});if(GC(e)==="immutable")throw new TypeError("immutable");return tc(e).append(A,t,!1)}function xC(e,A){return e[0]<A[0]?-1:1}var Fs=class e{cookies=null;constructor(A){A instanceof e?(this[sA]=new Map(A[sA]),this[kA]=A[kA],this.cookies=A.cookies===null?null:[...A.cookies]):(this[sA]=new Map(A),this[kA]=null)}contains(A,t){return this[sA].has(t?A:A.toLowerCase())}clear(){this[sA].clear(),this[kA]=null,this.cookies=null}append(A,t,r){this[kA]=null;let n=r?A:A.toLowerCase(),s=this[sA].get(n);if(s){let i=n==="cookie"?"; ":", ";this[sA].set(n,{name:s.name,value:`${s.value}${i}${t}`})}else this[sA].set(n,{name:A,value:t});n==="set-cookie"&&(this.cookies??=[]).push(t)}set(A,t,r){this[kA]=null;let n=r?A:A.toLowerCase();n==="set-cookie"&&(this.cookies=[t]),this[sA].set(n,{name:A,value:t})}delete(A,t){this[kA]=null,t||(A=A.toLowerCase()),A==="set-cookie"&&(this.cookies=null),this[sA].delete(A)}get(A,t){return this[sA].get(t?A:A.toLowerCase())?.value??null}*[Symbol.iterator](){for(let{0:A,1:{value:t}}of this[sA])yield[A,t]}get entries(){let A={};if(this[sA].size!==0)for(let{name:t,value:r}of this[sA].values())A[t]=r;return A}rawValues(){return this[sA].values()}get entriesList(){let A=[];if(this[sA].size!==0)for(let{0:t,1:{name:r,value:n}}of this[sA])if(t==="set-cookie")for(let s of this.cookies)A.push([r,s]);else A.push([r,n]);return A}toSortedArray(){let A=this[sA].size,t=new Array(A);if(A<=32){if(A===0)return t;let r=this[sA][Symbol.iterator](),n=r.next().value;t[0]=[n[0],n[1].value],Ac(n[1].value!==null);for(let s=1,i=0,o=0,a=0,c=0,g,Q;s<A;++s){for(Q=r.next().value,g=t[s]=[Q[0],Q[1].value],Ac(g[1]!==null),a=0,o=s;a<o;)c=a+(o-a>>1),t[c][0]<=g[0]?a=c+1:o=c;if(s!==c){for(i=s;i>a;)t[i]=t[--i];t[a]=g}}if(!r.next().done)throw new TypeError("Unreachable");return t}else{let r=0;for(let{0:n,1:{value:s}}of this[sA])t[r++]=[n,s],Ac(s!==null);return t.sort(xC)}}},PA=class e{#A;#e;constructor(A=void 0){J.util.markAsUncloneable(this),A!==uk&&(this.#e=new Fs,this.#A="none",A!==void 0&&(A=J.converters.HeadersInit(A,"Headers contructor","init"),YC(this,A)))}append(A,t){J.brandCheck(this,e),J.argumentLengthCheck(arguments,2,"Headers.append");let r="Headers.append";return A=J.converters.ByteString(A,r,"name"),t=J.converters.ByteString(t,r,"value"),ec(this,A,t)}delete(A){if(J.brandCheck(this,e),J.argumentLengthCheck(arguments,1,"Headers.delete"),A=J.converters.ByteString(A,"Headers.delete","name"),!Kr(A))throw J.errors.invalidArgument({prefix:"Headers.delete",value:A,type:"header name"});if(this.#A==="immutable")throw new TypeError("immutable");this.#e.contains(A,!1)&&this.#e.delete(A,!1)}get(A){J.brandCheck(this,e),J.argumentLengthCheck(arguments,1,"Headers.get");let t="Headers.get";if(A=J.converters.ByteString(A,t,"name"),!Kr(A))throw J.errors.invalidArgument({prefix:t,value:A,type:"header name"});return this.#e.get(A,!1)}has(A){J.brandCheck(this,e),J.argumentLengthCheck(arguments,1,"Headers.has");let t="Headers.has";if(A=J.converters.ByteString(A,t,"name"),!Kr(A))throw J.errors.invalidArgument({prefix:t,value:A,type:"header name"});return this.#e.contains(A,!1)}set(A,t){J.brandCheck(this,e),J.argumentLengthCheck(arguments,2,"Headers.set");let r="Headers.set";if(A=J.converters.ByteString(A,r,"name"),t=J.converters.ByteString(t,r,"value"),t=TC(t),Kr(A)){if(!LC(t))throw J.errors.invalidArgument({prefix:r,value:t,type:"header value"})}else throw J.errors.invalidArgument({prefix:r,value:A,type:"header name"});if(this.#A==="immutable")throw new TypeError("immutable");this.#e.set(A,t,!1)}getSetCookie(){J.brandCheck(this,e);let A=this.#e.cookies;return A?[...A]:[]}get[kA](){if(this.#e[kA])return this.#e[kA];let A=[],t=this.#e.toSortedArray(),r=this.#e.cookies;if(r===null||r.length===1)return this.#e[kA]=t;for(let n=0;n<t.length;++n){let{0:s,1:i}=t[n];if(s==="set-cookie")for(let o=0;o<r.length;++o)A.push([s,r[o]]);else A.push([s,i])}return this.#e[kA]=A}[ks.inspect.custom](A,t){return t.depth??=A,`Headers ${ks.formatWithOptions(t,this.#e.entries)}`}static getHeadersGuard(A){return A.#A}static setHeadersGuard(A,t){A.#A=t}static getHeadersList(A){return A.#e}static setHeadersList(A,t){A.#e=t}},{getHeadersGuard:GC,setHeadersGuard:dk,getHeadersList:tc,setHeadersList:fk}=PA;Reflect.deleteProperty(PA,"getHeadersGuard");Reflect.deleteProperty(PA,"setHeadersGuard");Reflect.deleteProperty(PA,"getHeadersList");Reflect.deleteProperty(PA,"setHeadersList");hk("Headers",PA,kA,0,1);Object.defineProperties(PA.prototype,{append:jt,delete:jt,get:jt,has:jt,set:jt,getSetCookie:jt,[Symbol.toStringTag]:{value:"Headers",configurable:!0},[ks.inspect.custom]:{enumerable:!1}});J.converters.HeadersInit=function(e,A,t){if(J.util.Type(e)==="Object"){let r=Reflect.get(e,Symbol.iterator);if(!ks.types.isProxy(e)&&r===PA.prototype.entries)try{return tc(e).entriesList}catch{}return typeof r=="function"?J.converters["sequence<sequence<ByteString>>"](e,A,t,r.bind(e)):J.converters["record<ByteString, ByteString>"](e,A,t)}throw J.errors.conversionFailed({prefix:"Headers constructor",argument:"Argument 1",types:["sequence<sequence<ByteString>>","record<ByteString, ByteString>"]})};JC.exports={fill:YC,compareHeaderName:xC,Headers:PA,HeadersList:Fs,getHeadersGuard:GC,setHeadersGuard:dk,setHeadersList:fk,getHeadersList:tc}});var Xr=f((EM,_C)=>{"use strict";var{Headers:OC,HeadersList:vC,fill:wk,getHeadersGuard:yk,setHeadersGuard:PC,setHeadersList:ZC}=nt(),{extractBody:HC,cloneBody:pk,mixinBody:Dk,hasFinalizationRegistry:KC,streamRegistry:zC,bodyUnusable:mk}=St(),rc=T(),VC=d("node:util"),{kEnumerableProperty:FA}=rc,{isValidReasonPhrase:kk,isCancelled:Fk,isAborted:Rk,isBlobLike:bk,serializeJavascriptValueToJSONString:Nk,isErrorLike:Sk,isomorphicEncode:Uk,environmentSettingsObject:Mk}=yA(),{redirectStatusSet:Lk,nullBodyStatus:Tk}=fr(),{kState:j,kHeaders:he}=pe(),{webidl:M}=cA(),{FormData:Yk}=kr(),{URLSerializer:qC}=lA(),{kConstruct:bs}=X(),nc=d("node:assert"),{types:xk}=d("node:util"),Gk=new TextEncoder("utf-8"),st=class e{static error(){return zr(Ns(),"immutable")}static json(A,t={}){M.argumentLengthCheck(arguments,1,"Response.json"),t!==null&&(t=M.converters.ResponseInit(t));let r=Gk.encode(Nk(A)),n=HC(r),s=zr($t({}),"response");return WC(s,t,{body:n[0],type:"application/json"}),s}static redirect(A,t=302){M.argumentLengthCheck(arguments,1,"Response.redirect"),A=M.converters.USVString(A),t=M.converters["unsigned short"](t);let r;try{r=new URL(A,Mk.settingsObject.baseUrl)}catch(i){throw new TypeError(`Failed to parse URL from ${A}`,{cause:i})}if(!Lk.has(t))throw new RangeError(`Invalid status code ${t}`);let n=zr($t({}),"immutable");n[j].status=t;let s=Uk(qC(r));return n[j].headersList.append("location",s,!0),n}constructor(A=null,t={}){if(M.util.markAsUncloneable(this),A===bs)return;A!==null&&(A=M.converters.BodyInit(A)),t=M.converters.ResponseInit(t),this[j]=$t({}),this[he]=new OC(bs),PC(this[he],"response"),ZC(this[he],this[j].headersList);let r=null;if(A!=null){let[n,s]=HC(A);r={body:n,type:s}}WC(this,t,r)}get type(){return M.brandCheck(this,e),this[j].type}get url(){M.brandCheck(this,e);let A=this[j].urlList,t=A[A.length-1]??null;return t===null?"":qC(t,!0)}get redirected(){return M.brandCheck(this,e),this[j].urlList.length>1}get status(){return M.brandCheck(this,e),this[j].status}get ok(){return M.brandCheck(this,e),this[j].status>=200&&this[j].status<=299}get statusText(){return M.brandCheck(this,e),this[j].statusText}get headers(){return M.brandCheck(this,e),this[he]}get body(){return M.brandCheck(this,e),this[j].body?this[j].body.stream:null}get bodyUsed(){return M.brandCheck(this,e),!!this[j].body&&rc.isDisturbed(this[j].body.stream)}clone(){if(M.brandCheck(this,e),mk(this))throw M.errors.exception({header:"Response.clone",message:"Body has already been consumed."});let A=sc(this[j]);return KC&&this[j].body?.stream&&zC.register(this,new WeakRef(this[j].body.stream)),zr(A,yk(this[he]))}[VC.inspect.custom](A,t){t.depth===null&&(t.depth=2),t.colors??=!0;let r={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 ${VC.formatWithOptions(t,r)}`}};Dk(st);Object.defineProperties(st.prototype,{type:FA,url:FA,status:FA,ok:FA,redirected:FA,statusText:FA,headers:FA,clone:FA,body:FA,bodyUsed:FA,[Symbol.toStringTag]:{value:"Response",configurable:!0}});Object.defineProperties(st,{json:FA,redirect:FA,error:FA});function sc(e){if(e.internalResponse)return XC(sc(e.internalResponse),e.type);let A=$t({...e,body:null});return e.body!=null&&(A.body=pk(A,e.body)),A}function $t(e){return{aborted:!1,rangeRequested:!1,timingAllowPassed:!1,requestIncludesCredentials:!1,type:"default",status:200,timingInfo:null,cacheState:"",statusText:"",...e,headersList:e?.headersList?new vC(e?.headersList):new vC,urlList:e?.urlList?[...e.urlList]:[]}}function Ns(e){let A=Sk(e);return $t({type:"error",status:0,error:A?e:new Error(e&&String(e)),aborted:e&&e.name==="AbortError"})}function Jk(e){return e.type==="error"&&e.status===0}function Rs(e,A){return A={internalResponse:e,...A},new Proxy(e,{get(t,r){return r in A?A[r]:t[r]},set(t,r,n){return nc(!(r in A)),t[r]=n,!0}})}function XC(e,A){if(A==="basic")return Rs(e,{type:"basic",headersList:e.headersList});if(A==="cors")return Rs(e,{type:"cors",headersList:e.headersList});if(A==="opaque")return Rs(e,{type:"opaque",urlList:Object.freeze([]),status:0,statusText:"",body:null});if(A==="opaqueredirect")return Rs(e,{type:"opaqueredirect",status:0,statusText:"",headersList:[],body:null});nc(!1)}function vk(e,A=null){return nc(Fk(e)),Rk(e)?Ns(Object.assign(new DOMException("The operation was aborted.","AbortError"),{cause:A})):Ns(Object.assign(new DOMException("Request was cancelled."),{cause:A}))}function WC(e,A,t){if(A.status!==null&&(A.status<200||A.status>599))throw new RangeError('init["status"] must be in the range of 200 to 599, inclusive.');if("statusText"in A&&A.statusText!=null&&!kk(String(A.statusText)))throw new TypeError("Invalid statusText");if("status"in A&&A.status!=null&&(e[j].status=A.status),"statusText"in A&&A.statusText!=null&&(e[j].statusText=A.statusText),"headers"in A&&A.headers!=null&&wk(e[he],A.headers),t){if(Tk.includes(e.status))throw M.errors.exception({header:"Response constructor",message:`Invalid response status code ${e.status}`});e[j].body=t.body,t.type!=null&&!e[j].headersList.contains("content-type",!0)&&e[j].headersList.append("content-type",t.type,!0)}}function zr(e,A){let t=new st(bs);return t[j]=e,t[he]=new OC(bs),ZC(t[he],e.headersList),PC(t[he],A),KC&&e.body?.stream&&zC.register(t,new WeakRef(e.body.stream)),t}M.converters.ReadableStream=M.interfaceConverter(ReadableStream);M.converters.FormData=M.interfaceConverter(Yk);M.converters.URLSearchParams=M.interfaceConverter(URLSearchParams);M.converters.XMLHttpRequestBodyInit=function(e,A,t){return typeof e=="string"?M.converters.USVString(e,A,t):bk(e)?M.converters.Blob(e,A,t,{strict:!1}):ArrayBuffer.isView(e)||xk.isArrayBuffer(e)?M.converters.BufferSource(e,A,t):rc.isFormDataLike(e)?M.converters.FormData(e,A,t,{strict:!1}):e instanceof URLSearchParams?M.converters.URLSearchParams(e,A,t):M.converters.DOMString(e,A,t)};M.converters.BodyInit=function(e,A,t){return e instanceof ReadableStream?M.converters.ReadableStream(e,A,t):e?.[Symbol.asyncIterator]?e:M.converters.XMLHttpRequestBodyInit(e,A,t)};M.converters.ResponseInit=M.dictionaryConverter([{key:"status",converter:M.converters["unsigned short"],defaultValue:()=>200},{key:"statusText",converter:M.converters.ByteString,defaultValue:()=>""},{key:"headers",converter:M.converters.HeadersInit}]);_C.exports={isNetworkError:Jk,makeNetworkError:Ns,makeResponse:$t,makeAppropriateNetworkError:vk,filterResponse:XC,Response:st,cloneResponse:sc,fromInnerResponse:zr}});var el=f((BM,Al)=>{"use strict";var{kConnected:jC,kSize:$C}=X(),ic=class{constructor(A){this.value=A}deref(){return this.value[jC]===0&&this.value[$C]===0?void 0:this.value}},oc=class{constructor(A){this.finalizer=A}register(A,t){A.on&&A.on("disconnect",()=>{A[jC]===0&&A[$C]===0&&this.finalizer(t)})}unregister(A){}};Al.exports=function(){return process.env.NODE_V8_COVERAGE&&process.version.startsWith("v18")?(process._rawDebug("Using compatibility WeakRef and FinalizationRegistry"),{WeakRef:ic,FinalizationRegistry:oc}):{WeakRef,FinalizationRegistry}}});var Ar=f((IM,ll)=>{"use strict";var{extractBody:Hk,mixinBody:Vk,cloneBody:qk,bodyUnusable:tl}=St(),{Headers:Ql,fill:Wk,HeadersList:Ls,setHeadersGuard:cc,getHeadersGuard:Ok,setHeadersList:El,getHeadersList:rl}=nt(),{FinalizationRegistry:Pk}=el()(),Us=T(),nl=d("node:util"),{isValidHTTPToken:Zk,sameOrigin:sl,environmentSettingsObject:Ss}=yA(),{forbiddenMethodsSet:Kk,corsSafeListedMethodsSet:zk,referrerPolicy:Xk,requestRedirect:_k,requestMode:jk,requestCredentials:$k,requestCache:AF,requestDuplex:eF}=fr(),{kEnumerableProperty:iA,normalizedMethodRecordsBase:tF,normalizedMethodRecords:rF}=Us,{kHeaders:RA,kSignal:Ms,kState:z,kDispatcher:ac}=pe(),{webidl:N}=cA(),{URLSerializer:nF}=lA(),{kConstruct:Ts}=X(),sF=d("node:assert"),{getMaxListeners:il,setMaxListeners:ol,getEventListeners:iF,defaultMaxListeners:al}=d("node:events"),oF=Symbol("abortController"),Bl=new Pk(({signal:e,abort:A})=>{e.removeEventListener("abort",A)}),Ys=new WeakMap;function cl(e){return A;function A(){let t=e.deref();if(t!==void 0){Bl.unregister(A),this.removeEventListener("abort",A),t.abort(this.reason);let r=Ys.get(t.signal);if(r!==void 0){if(r.size!==0){for(let n of r){let s=n.deref();s!==void 0&&s.abort(this.reason)}r.clear()}Ys.delete(t.signal)}}}}var gl=!1,Le=class e{constructor(A,t={}){if(N.util.markAsUncloneable(this),A===Ts)return;let r="Request constructor";N.argumentLengthCheck(arguments,1,r),A=N.converters.RequestInfo(A,r,"input"),t=N.converters.RequestInit(t,r,"init");let n=null,s=null,i=Ss.settingsObject.baseUrl,o=null;if(typeof A=="string"){this[ac]=t.dispatcher;let C;try{C=new URL(A,i)}catch(h){throw new TypeError("Failed to parse URL from "+A,{cause:h})}if(C.username||C.password)throw new TypeError("Request cannot be constructed from a URL that includes credentials: "+A);n=xs({urlList:[C]}),s="cors"}else this[ac]=t.dispatcher||A[ac],sF(A instanceof e),n=A[z],o=A[Ms];let a=Ss.settingsObject.origin,c="client";if(n.window?.constructor?.name==="EnvironmentSettingsObject"&&sl(n.window,a)&&(c=n.window),t.window!=null)throw new TypeError(`'window' option '${c}' must be null`);"window"in t&&(c="no-window"),n=xs({method:n.method,headersList:n.headersList,unsafeRequest:n.unsafeRequest,client:Ss.settingsObject,window:c,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]});let g=Object.keys(t).length!==0;if(g&&(n.mode==="navigate"&&(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]),t.referrer!==void 0){let C=t.referrer;if(C==="")n.referrer="no-referrer";else{let h;try{h=new URL(C,i)}catch(D){throw new TypeError(`Referrer "${C}" is not a valid URL.`,{cause:D})}h.protocol==="about:"&&h.hostname==="client"||a&&!sl(h,Ss.settingsObject.baseUrl)?n.referrer="client":n.referrer=h}}t.referrerPolicy!==void 0&&(n.referrerPolicy=t.referrerPolicy);let Q;if(t.mode!==void 0?Q=t.mode:Q=s,Q==="navigate")throw N.errors.exception({header:"Request constructor",message:"invalid request mode navigate."});if(Q!=null&&(n.mode=Q),t.credentials!==void 0&&(n.credentials=t.credentials),t.cache!==void 0&&(n.cache=t.cache),n.cache==="only-if-cached"&&n.mode!=="same-origin")throw new TypeError("'only-if-cached' can be set only with 'same-origin' mode");if(t.redirect!==void 0&&(n.redirect=t.redirect),t.integrity!=null&&(n.integrity=String(t.integrity)),t.keepalive!==void 0&&(n.keepalive=!!t.keepalive),t.method!==void 0){let C=t.method,h=rF[C];if(h!==void 0)n.method=h;else{if(!Zk(C))throw new TypeError(`'${C}' is not a valid HTTP method.`);let D=C.toUpperCase();if(Kk.has(D))throw new TypeError(`'${C}' HTTP method is unsupported.`);C=tF[D]??C,n.method=C}!gl&&n.method==="patch"&&(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"}),gl=!0)}t.signal!==void 0&&(o=t.signal),this[z]=n;let E=new AbortController;if(this[Ms]=E.signal,o!=null){if(!o||typeof o.aborted!="boolean"||typeof o.addEventListener!="function")throw new TypeError("Failed to construct 'Request': member signal is not of type AbortSignal.");if(o.aborted)E.abort(o.reason);else{this[oF]=E;let C=new WeakRef(E),h=cl(C);try{(typeof il=="function"&&il(o)===al||iF(o,"abort").length>=al)&&ol(1500,o)}catch{}Us.addAbortListener(o,h),Bl.register(E,{signal:o,abort:h},h)}}if(this[RA]=new Ql(Ts),El(this[RA],n.headersList),cc(this[RA],"request"),Q==="no-cors"){if(!zk.has(n.method))throw new TypeError(`'${n.method} is unsupported in no-cors mode.`);cc(this[RA],"request-no-cors")}if(g){let C=rl(this[RA]),h=t.headers!==void 0?t.headers:new Ls(C);if(C.clear(),h instanceof Ls){for(let{name:D,value:p}of h.rawValues())C.append(D,p,!1);C.cookies=h.cookies}else Wk(this[RA],h)}let B=A instanceof e?A[z].body:null;if((t.body!=null||B!=null)&&(n.method==="GET"||n.method==="HEAD"))throw new TypeError("Request with GET/HEAD method cannot have body.");let I=null;if(t.body!=null){let[C,h]=Hk(t.body,n.keepalive);I=C,h&&!rl(this[RA]).contains("content-type",!0)&&this[RA].append("content-type",h)}let l=I??B;if(l!=null&&l.source==null){if(I!=null&&t.duplex==null)throw new TypeError("RequestInit: duplex option is required when sending a body.");if(n.mode!=="same-origin"&&n.mode!=="cors")throw new TypeError('If request is made from ReadableStream, mode should be "same-origin" or "cors"');n.useCORSPreflightFlag=!0}let u=l;if(I==null&&B!=null){if(tl(A))throw new TypeError("Cannot construct a Request with a Request object that has already been used.");let C=new TransformStream;B.stream.pipeThrough(C),u={source:B.source,length:B.length,stream:C.readable}}this[z].body=u}get method(){return N.brandCheck(this,e),this[z].method}get url(){return N.brandCheck(this,e),nF(this[z].url)}get headers(){return N.brandCheck(this,e),this[RA]}get destination(){return N.brandCheck(this,e),this[z].destination}get referrer(){return N.brandCheck(this,e),this[z].referrer==="no-referrer"?"":this[z].referrer==="client"?"about:client":this[z].referrer.toString()}get referrerPolicy(){return N.brandCheck(this,e),this[z].referrerPolicy}get mode(){return N.brandCheck(this,e),this[z].mode}get credentials(){return this[z].credentials}get cache(){return N.brandCheck(this,e),this[z].cache}get redirect(){return N.brandCheck(this,e),this[z].redirect}get integrity(){return N.brandCheck(this,e),this[z].integrity}get keepalive(){return N.brandCheck(this,e),this[z].keepalive}get isReloadNavigation(){return N.brandCheck(this,e),this[z].reloadNavigation}get isHistoryNavigation(){return N.brandCheck(this,e),this[z].historyNavigation}get signal(){return N.brandCheck(this,e),this[Ms]}get body(){return N.brandCheck(this,e),this[z].body?this[z].body.stream:null}get bodyUsed(){return N.brandCheck(this,e),!!this[z].body&&Us.isDisturbed(this[z].body.stream)}get duplex(){return N.brandCheck(this,e),"half"}clone(){if(N.brandCheck(this,e),tl(this))throw new TypeError("unusable");let A=Il(this[z]),t=new AbortController;if(this.signal.aborted)t.abort(this.signal.reason);else{let r=Ys.get(this.signal);r===void 0&&(r=new Set,Ys.set(this.signal,r));let n=new WeakRef(t);r.add(n),Us.addAbortListener(t.signal,cl(n))}return Cl(A,t.signal,Ok(this[RA]))}[nl.inspect.custom](A,t){t.depth===null&&(t.depth=2),t.colors??=!0;let r={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 ${nl.formatWithOptions(t,r)}`}};Vk(Le);function xs(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,urlList:e.urlList,url:e.urlList[0],headersList:e.headersList?new Ls(e.headersList):new Ls}}function Il(e){let A=xs({...e,body:null});return e.body!=null&&(A.body=qk(A,e.body)),A}function Cl(e,A,t){let r=new Le(Ts);return r[z]=e,r[Ms]=A,r[RA]=new Ql(Ts),El(r[RA],e.headersList),cc(r[RA],t),r}Object.defineProperties(Le.prototype,{method:iA,url:iA,headers:iA,redirect:iA,clone:iA,signal:iA,duplex:iA,destination:iA,body:iA,bodyUsed:iA,isHistoryNavigation:iA,isReloadNavigation:iA,keepalive:iA,integrity:iA,cache:iA,credentials:iA,attribute:iA,referrerPolicy:iA,referrer:iA,mode:iA,[Symbol.toStringTag]:{value:"Request",configurable:!0}});N.converters.Request=N.interfaceConverter(Le);N.converters.RequestInfo=function(e,A,t){return typeof e=="string"?N.converters.USVString(e,A,t):e instanceof Le?N.converters.Request(e,A,t):N.converters.USVString(e,A,t)};N.converters.AbortSignal=N.interfaceConverter(AbortSignal);N.converters.RequestInit=N.dictionaryConverter([{key:"method",converter:N.converters.ByteString},{key:"headers",converter:N.converters.HeadersInit},{key:"body",converter:N.nullableConverter(N.converters.BodyInit)},{key:"referrer",converter:N.converters.USVString},{key:"referrerPolicy",converter:N.converters.DOMString,allowedValues:Xk},{key:"mode",converter:N.converters.DOMString,allowedValues:jk},{key:"credentials",converter:N.converters.DOMString,allowedValues:$k},{key:"cache",converter:N.converters.DOMString,allowedValues:AF},{key:"redirect",converter:N.converters.DOMString,allowedValues:_k},{key:"integrity",converter:N.converters.DOMString},{key:"keepalive",converter:N.converters.boolean},{key:"signal",converter:N.nullableConverter(e=>N.converters.AbortSignal(e,"RequestInit","signal",{strict:!1}))},{key:"window",converter:N.converters.any},{key:"duplex",converter:N.converters.DOMString,allowedValues:eF},{key:"dispatcher",converter:N.converters.any}]);ll.exports={Request:Le,makeRequest:xs,fromInnerRequest:Cl,cloneRequest:Il}});var jr=f((CM,Sl)=>{"use strict";var{makeNetworkError:W,makeAppropriateNetworkError:Gs,filterResponse:gc,makeResponse:Js,fromInnerResponse:aF}=Xr(),{HeadersList:ul}=nt(),{Request:cF,cloneRequest:gF}=Ar(),Te=d("node:zlib"),{bytesMatch:QF,makePolicyContainer:EF,clonePolicyContainer:BF,requestBadPort:IF,TAOCheck:CF,appendRequestOriginHeader:lF,responseLocationURL:uF,requestCurrentURL:se,setRequestReferrerPolicyOnRedirect:hF,tryUpgradeRequestToAPotentiallyTrustworthyURL:dF,createOpaqueTimingInfo:Cc,appendFetchMetadata:fF,corsCheck:wF,crossOriginResourcePolicyCheck:yF,determineRequestsReferrer:pF,coarsenedSharedCurrentTime:_r,createDeferredPromise:DF,isBlobLike:mF,sameOrigin:Ic,isCancelled:it,isAborted:hl,isErrorLike:kF,fullyReadBody:FF,readableStreamClose:RF,isomorphicEncode:vs,urlIsLocal:bF,urlIsHttpHttpsScheme:lc,urlHasHttpsScheme:NF,clampAndCoarsenConnectionTimingInfo:SF,simpleRangeHeaderValue:UF,buildContentRange:MF,createInflate:LF,extractMimeType:TF}=yA(),{kState:yl,kDispatcher:YF}=pe(),ot=d("node:assert"),{safelyExtractBody:uc,extractBody:dl}=St(),{redirectStatusSet:pl,nullBodyStatus:Dl,safeMethodsSet:xF,requestBodyHeader:GF,subresourceSet:JF}=fr(),vF=d("node:events"),{Readable:HF,pipeline:VF,finished:qF}=d("node:stream"),{addAbortListener:WF,isErrored:OF,isReadable:Hs,bufferToLowerCasedHeaderName:fl}=T(),{dataURLProcessor:PF,serializeAMimeType:ZF,minimizeSupportedMimeType:KF}=lA(),{getGlobalDispatcher:zF}=Ds(),{webidl:XF}=cA(),{STATUS_CODES:_F}=d("node:http"),jF=["GET","HEAD"],$F=typeof __UNDICI_IS_NODE__<"u"||typeof esbuildDetection<"u"?"node":"undici",Qc,Vs=class extends vF{constructor(A){super(),this.dispatcher=A,this.connection=null,this.dump=!1,this.state="ongoing"}terminate(A){this.state==="ongoing"&&(this.state="terminated",this.connection?.destroy(A),this.emit("terminated",A))}abort(A){this.state==="ongoing"&&(this.state="aborted",A||(A=new DOMException("The operation was aborted.","AbortError")),this.serializedAbortReason=A,this.connection?.destroy(A),this.emit("terminated",A))}};function AR(e){ml(e,"fetch")}function eR(e,A=void 0){XF.argumentLengthCheck(arguments,1,"globalThis.fetch");let t=DF(),r;try{r=new cF(e,A)}catch(g){return t.reject(g),t.promise}let n=r[yl];if(r.signal.aborted)return Ec(t,n,null,r.signal.reason),t.promise;n.client.globalObject?.constructor?.name==="ServiceWorkerGlobalScope"&&(n.serviceWorkers="none");let i=null,o=!1,a=null;return WF(r.signal,()=>{o=!0,ot(a!=null),a.abort(r.signal.reason);let g=i?.deref();Ec(t,n,g,r.signal.reason)}),a=Fl({request:n,processResponseEndOfBody:AR,processResponse:g=>{if(!o){if(g.aborted){Ec(t,n,i,a.serializedAbortReason);return}if(g.type==="error"){t.reject(new TypeError("fetch failed",{cause:g.error}));return}i=new WeakRef(aF(g,"immutable")),t.resolve(i.deref()),t=null}},dispatcher:r[YF]}),t.promise}function ml(e,A="other"){if(e.type==="error"&&e.aborted||!e.urlList?.length)return;let t=e.urlList[0],r=e.timingInfo,n=e.cacheState;lc(t)&&r!==null&&(e.timingAllowPassed||(r=Cc({startTime:r.startTime}),n=""),r.endTime=_r(),e.timingInfo=r,kl(r,t.href,A,globalThis,n))}var kl=performance.markResourceTiming;function Ec(e,A,t,r){if(e&&e.reject(r),A.body!=null&&Hs(A.body?.stream)&&A.body.stream.cancel(r).catch(s=>{if(s.code!=="ERR_INVALID_STATE")throw s}),t==null)return;let n=t[yl];n.body!=null&&Hs(n.body?.stream)&&n.body.stream.cancel(r).catch(s=>{if(s.code!=="ERR_INVALID_STATE")throw s})}function Fl({request:e,processRequestBodyChunkLength:A,processRequestEndOfBody:t,processResponse:r,processResponseEndOfBody:n,processResponseConsumeBody:s,useParallelQueue:i=!1,dispatcher:o=zF()}){ot(o);let a=null,c=!1;e.client!=null&&(a=e.client.globalObject,c=e.client.crossOriginIsolatedCapability);let g=_r(c),Q=Cc({startTime:g}),E={controller:new Vs(o),request:e,timingInfo:Q,processRequestBodyChunkLength:A,processRequestEndOfBody:t,processResponse:r,processResponseConsumeBody:s,processResponseEndOfBody:n,taskDestination:a,crossOriginIsolatedCapability:c};return ot(!e.body||e.body.stream),e.window==="client"&&(e.window=e.client?.globalObject?.constructor?.name==="Window"?e.client:"no-window"),e.origin==="client"&&(e.origin=e.client.origin),e.policyContainer==="client"&&(e.client!=null?e.policyContainer=BF(e.client.policyContainer):e.policyContainer=EF()),e.headersList.contains("accept",!0)||e.headersList.append("accept","*/*",!0),e.headersList.contains("accept-language",!0)||e.headersList.append("accept-language","*",!0),e.priority,JF.has(e.destination),Rl(E).catch(B=>{E.controller.terminate(B)}),E.controller}async function Rl(e,A=!1){let t=e.request,r=null;if(t.localURLsOnly&&!bF(se(t))&&(r=W("local URLs only")),dF(t),IF(t)==="blocked"&&(r=W("bad port")),t.referrerPolicy===""&&(t.referrerPolicy=t.policyContainer.referrerPolicy),t.referrer!=="no-referrer"&&(t.referrer=pF(t)),r===null&&(r=await(async()=>{let s=se(t);return Ic(s,t.url)&&t.responseTainting==="basic"||s.protocol==="data:"||t.mode==="navigate"||t.mode==="websocket"?(t.responseTainting="basic",await wl(e)):t.mode==="same-origin"?W('request mode cannot be "same-origin"'):t.mode==="no-cors"?t.redirect!=="follow"?W('redirect mode cannot be "follow" for "no-cors" request'):(t.responseTainting="opaque",await wl(e)):lc(se(t))?(t.responseTainting="cors",await bl(e)):W("URL scheme must be a HTTP(S) scheme")})()),A)return r;r.status!==0&&!r.internalResponse&&(t.responseTainting,t.responseTainting==="basic"?r=gc(r,"basic"):t.responseTainting==="cors"?r=gc(r,"cors"):t.responseTainting==="opaque"?r=gc(r,"opaque"):ot(!1));let n=r.status===0?r:r.internalResponse;if(n.urlList.length===0&&n.urlList.push(...t.urlList),t.timingAllowFailed||(r.timingAllowPassed=!0),r.type==="opaque"&&n.status===206&&n.rangeRequested&&!t.headers.contains("range",!0)&&(r=n=W()),r.status!==0&&(t.method==="HEAD"||t.method==="CONNECT"||Dl.includes(n.status))&&(n.body=null,e.controller.dump=!0),t.integrity){let s=o=>Bc(e,W(o));if(t.responseTainting==="opaque"||r.body==null){s(r.error);return}let i=o=>{if(!QF(o,t.integrity)){s("integrity mismatch");return}r.body=uc(o)[0],Bc(e,r)};await FF(r.body,i,s)}else Bc(e,r)}function wl(e){if(it(e)&&e.request.redirectCount===0)return Promise.resolve(Gs(e));let{request:A}=e,{protocol:t}=se(A);switch(t){case"about:":return Promise.resolve(W("about scheme is not supported"));case"blob:":{Qc||(Qc=d("node:buffer").resolveObjectURL);let r=se(A);if(r.search.length!==0)return Promise.resolve(W("NetworkError when attempting to fetch resource."));let n=Qc(r.toString());if(A.method!=="GET"||!mF(n))return Promise.resolve(W("invalid method"));let s=Js(),i=n.size,o=vs(`${i}`),a=n.type;if(A.headersList.contains("range",!0)){s.rangeRequested=!0;let c=A.headersList.get("range",!0),g=UF(c,!0);if(g==="failure")return Promise.resolve(W("failed to fetch the data URL"));let{rangeStartValue:Q,rangeEndValue:E}=g;if(Q===null)Q=i-E,E=Q+E-1;else{if(Q>=i)return Promise.resolve(W("Range start is greater than the blob's size."));(E===null||E>=i)&&(E=i-1)}let B=n.slice(Q,E,a),I=dl(B);s.body=I[0];let l=vs(`${B.size}`),u=MF(Q,E,i);s.status=206,s.statusText="Partial Content",s.headersList.set("content-length",l,!0),s.headersList.set("content-type",a,!0),s.headersList.set("content-range",u,!0)}else{let c=dl(n);s.statusText="OK",s.body=c[0],s.headersList.set("content-length",o,!0),s.headersList.set("content-type",a,!0)}return Promise.resolve(s)}case"data:":{let r=se(A),n=PF(r);if(n==="failure")return Promise.resolve(W("failed to fetch the data URL"));let s=ZF(n.mimeType);return Promise.resolve(Js({statusText:"OK",headersList:[["content-type",{name:"Content-Type",value:s}]],body:uc(n.body)[0]}))}case"file:":return Promise.resolve(W("not implemented... yet..."));case"http:":case"https:":return bl(e).catch(r=>W(r));default:return Promise.resolve(W("unknown scheme"))}}function tR(e,A){e.request.done=!0,e.processResponseDone!=null&&queueMicrotask(()=>e.processResponseDone(A))}function Bc(e,A){let t=e.timingInfo,r=()=>{let s=Date.now();e.request.destination==="document"&&(e.controller.fullTimingInfo=t),e.controller.reportTimingSteps=()=>{if(e.request.url.protocol!=="https:")return;t.endTime=s;let o=A.cacheState,a=A.bodyInfo;A.timingAllowPassed||(t=Cc(t),o="");let c=0;if(e.request.mode!=="navigator"||!A.hasCrossOriginRedirects){c=A.status;let g=TF(A.headersList);g!=="failure"&&(a.contentType=KF(g))}e.request.initiatorType!=null&&kl(t,e.request.url.href,e.request.initiatorType,globalThis,o,a,c)};let i=()=>{e.request.done=!0,e.processResponseEndOfBody!=null&&queueMicrotask(()=>e.processResponseEndOfBody(A)),e.request.initiatorType!=null&&e.controller.reportTimingSteps()};queueMicrotask(()=>i())};e.processResponse!=null&&queueMicrotask(()=>{e.processResponse(A),e.processResponse=null});let n=A.type==="error"?A:A.internalResponse??A;n.body==null?r():qF(n.body.stream,()=>{r()})}async function bl(e){let A=e.request,t=null,r=null,n=e.timingInfo;if(A.serviceWorkers,t===null){if(A.redirect==="follow"&&(A.serviceWorkers="none"),r=t=await Nl(e),A.responseTainting==="cors"&&wF(A,t)==="failure")return W("cors failure");CF(A,t)==="failure"&&(A.timingAllowFailed=!0)}return(A.responseTainting==="opaque"||t.type==="opaque")&&yF(A.origin,A.client,A.destination,r)==="blocked"?W("blocked"):(pl.has(r.status)&&(A.redirect!=="manual"&&e.controller.connection.destroy(void 0,!1),A.redirect==="error"?t=W("unexpected redirect"):A.redirect==="manual"?t=r:A.redirect==="follow"?t=await rR(e,t):ot(!1)),t.timingInfo=n,t)}function rR(e,A){let t=e.request,r=A.internalResponse?A.internalResponse:A,n;try{if(n=uF(r,se(t).hash),n==null)return A}catch(i){return Promise.resolve(W(i))}if(!lc(n))return Promise.resolve(W("URL scheme must be a HTTP(S) scheme"));if(t.redirectCount===20)return Promise.resolve(W("redirect count exceeded"));if(t.redirectCount+=1,t.mode==="cors"&&(n.username||n.password)&&!Ic(t,n))return Promise.resolve(W('cross origin not allowed for request mode "cors"'));if(t.responseTainting==="cors"&&(n.username||n.password))return Promise.resolve(W('URL cannot contain credentials for request mode "cors"'));if(r.status!==303&&t.body!=null&&t.body.source==null)return Promise.resolve(W());if([301,302].includes(r.status)&&t.method==="POST"||r.status===303&&!jF.includes(t.method)){t.method="GET",t.body=null;for(let i of GF)t.headersList.delete(i)}Ic(se(t),n)||(t.headersList.delete("authorization",!0),t.headersList.delete("proxy-authorization",!0),t.headersList.delete("cookie",!0),t.headersList.delete("host",!0)),t.body!=null&&(ot(t.body.source!=null),t.body=uc(t.body.source)[0]);let s=e.timingInfo;return s.redirectEndTime=s.postRedirectStartTime=_r(e.crossOriginIsolatedCapability),s.redirectStartTime===0&&(s.redirectStartTime=s.startTime),t.urlList.push(n),hF(t,r),Rl(e,!0)}async function Nl(e,A=!1,t=!1){let r=e.request,n=null,s=null,i=null,o=null,a=!1;r.window==="no-window"&&r.redirect==="error"?(n=e,s=r):(s=gF(r),n={...e},n.request=s);let c=r.credentials==="include"||r.credentials==="same-origin"&&r.responseTainting==="basic",g=s.body?s.body.length:null,Q=null;if(s.body==null&&["POST","PUT"].includes(s.method)&&(Q="0"),g!=null&&(Q=vs(`${g}`)),Q!=null&&s.headersList.append("content-length",Q,!0),g!=null&&s.keepalive,s.referrer instanceof URL&&s.headersList.append("referer",vs(s.referrer.href),!0),lF(s),fF(s),s.headersList.contains("user-agent",!0)||s.headersList.append("user-agent",$F),s.cache==="default"&&(s.headersList.contains("if-modified-since",!0)||s.headersList.contains("if-none-match",!0)||s.headersList.contains("if-unmodified-since",!0)||s.headersList.contains("if-match",!0)||s.headersList.contains("if-range",!0))&&(s.cache="no-store"),s.cache==="no-cache"&&!s.preventNoCacheCacheControlHeaderModification&&!s.headersList.contains("cache-control",!0)&&s.headersList.append("cache-control","max-age=0",!0),(s.cache==="no-store"||s.cache==="reload")&&(s.headersList.contains("pragma",!0)||s.headersList.append("pragma","no-cache",!0),s.headersList.contains("cache-control",!0)||s.headersList.append("cache-control","no-cache",!0)),s.headersList.contains("range",!0)&&s.headersList.append("accept-encoding","identity",!0),s.headersList.contains("accept-encoding",!0)||(NF(se(s))?s.headersList.append("accept-encoding","br, gzip, deflate",!0):s.headersList.append("accept-encoding","gzip, deflate",!0)),s.headersList.delete("host",!0),o==null&&(s.cache="no-store"),s.cache!=="no-store"&&s.cache,i==null){if(s.cache==="only-if-cached")return W("only if cached");let E=await nR(n,c,t);!xF.has(s.method)&&E.status>=200&&E.status<=399,a&&E.status,i==null&&(i=E)}if(i.urlList=[...s.urlList],s.headersList.contains("range",!0)&&(i.rangeRequested=!0),i.requestIncludesCredentials=c,i.status===407)return r.window==="no-window"?W():it(e)?Gs(e):W("proxy authentication required");if(i.status===421&&!t&&(r.body==null||r.body.source!=null)){if(it(e))return Gs(e);e.controller.connection.destroy(),i=await Nl(e,A,!0)}return i}async function nR(e,A=!1,t=!1){ot(!e.controller.connection||e.controller.connection.destroyed),e.controller.connection={abort:null,destroyed:!1,destroy(I,l=!0){this.destroyed||(this.destroyed=!0,l&&this.abort?.(I??new DOMException("The operation was aborted.","AbortError")))}};let r=e.request,n=null,s=e.timingInfo;null==null&&(r.cache="no-store");let o=t?"yes":"no";r.mode;let a=null;if(r.body==null&&e.processRequestEndOfBody)queueMicrotask(()=>e.processRequestEndOfBody());else if(r.body!=null){let I=async function*(C){it(e)||(yield C,e.processRequestBodyChunkLength?.(C.byteLength))},l=()=>{it(e)||e.processRequestEndOfBody&&e.processRequestEndOfBody()},u=C=>{it(e)||(C.name==="AbortError"?e.controller.abort():e.controller.terminate(C))};a=(async function*(){try{for await(let C of r.body.stream)yield*I(C);l()}catch(C){u(C)}})()}try{let{body:I,status:l,statusText:u,headersList:C,socket:h}=await B({body:a});if(h)n=Js({status:l,statusText:u,headersList:C,socket:h});else{let D=I[Symbol.asyncIterator]();e.controller.next=()=>D.next(),n=Js({status:l,statusText:u,headersList:C})}}catch(I){return I.name==="AbortError"?(e.controller.connection.destroy(),Gs(e,I)):W(I)}let c=async()=>{await e.controller.resume()},g=I=>{it(e)||e.controller.abort(I)},Q=new ReadableStream({async start(I){e.controller.controller=I},async pull(I){await c(I)},async cancel(I){await g(I)},type:"bytes"});n.body={stream:Q,source:null,length:null},e.controller.onAborted=E,e.controller.on("terminated",E),e.controller.resume=async()=>{for(;;){let I,l;try{let{done:C,value:h}=await e.controller.next();if(hl(e))break;I=C?void 0:h}catch(C){e.controller.ended&&!s.encodedBodySize?I=void 0:(I=C,l=!0)}if(I===void 0){RF(e.controller.controller),tR(e,n);return}if(s.decodedBodySize+=I?.byteLength??0,l){e.controller.terminate(I);return}let u=new Uint8Array(I);if(u.byteLength&&e.controller.controller.enqueue(u),OF(Q)){e.controller.terminate();return}if(e.controller.controller.desiredSize<=0)return}};function E(I){hl(e)?(n.aborted=!0,Hs(Q)&&e.controller.controller.error(e.controller.serializedAbortReason)):Hs(Q)&&e.controller.controller.error(new TypeError("terminated",{cause:kF(I)?I:void 0})),e.controller.connection.destroy()}return n;function B({body:I}){let l=se(r),u=e.controller.dispatcher;return new Promise((C,h)=>u.dispatch({path:l.pathname+l.search,origin:l.origin,method:r.method,body:u.isMockActive?r.body&&(r.body.source||r.body.stream):I,headers:r.headersList.entries,maxRedirections:0,upgrade:r.mode==="websocket"?"websocket":void 0},{body:null,abort:null,onConnect(D){let{connection:p}=e.controller;s.finalConnectionTimingInfo=SF(void 0,s.postRedirectStartTime,e.crossOriginIsolatedCapability),p.destroyed?D(new DOMException("The operation was aborted.","AbortError")):(e.controller.on("terminated",D),this.abort=p.abort=D),s.finalNetworkRequestStartTime=_r(e.crossOriginIsolatedCapability)},onResponseStarted(){s.finalNetworkResponseStartTime=_r(e.crossOriginIsolatedCapability)},onHeaders(D,p,H,eA){if(D<200)return;let $="",zA=new ul;for(let CA=0;CA<p.length;CA+=2)zA.append(fl(p[CA]),p[CA+1].toString("latin1"),!0);$=zA.get("location",!0),this.body=new HF({read:H});let oe=[],Bt=$&&r.redirect==="follow"&&pl.has(D);if(r.method!=="HEAD"&&r.method!=="CONNECT"&&!Dl.includes(D)&&!Bt){let CA=zA.get("content-encoding",!0),It=CA?CA.toLowerCase().split(","):[],Ct=5;if(It.length>Ct)return h(new Error(`too many content-encodings in response: ${It.length}, maximum allowed is ${Ct}`)),!0;for(let li=It.length-1;li>=0;--li){let hn=It[li].trim();if(hn==="x-gzip"||hn==="gzip")oe.push(Te.createGunzip({flush:Te.constants.Z_SYNC_FLUSH,finishFlush:Te.constants.Z_SYNC_FLUSH}));else if(hn==="deflate")oe.push(LF({flush:Te.constants.Z_SYNC_FLUSH,finishFlush:Te.constants.Z_SYNC_FLUSH}));else if(hn==="br")oe.push(Te.createBrotliDecompress({flush:Te.constants.BROTLI_OPERATION_FLUSH,finishFlush:Te.constants.BROTLI_OPERATION_FLUSH}));else{oe.length=0;break}}}let ye=this.onError.bind(this);return C({status:D,statusText:eA,headersList:zA,body:oe.length?VF(this.body,...oe,CA=>{CA&&this.onError(CA)}).on("error",ye):this.body.on("error",ye)}),!0},onData(D){if(e.controller.dump)return;let p=D;return s.encodedBodySize+=p.byteLength,this.body.push(p)},onComplete(){this.abort&&e.controller.off("terminated",this.abort),e.controller.onAborted&&e.controller.off("terminated",e.controller.onAborted),e.controller.ended=!0,this.body.push(null)},onError(D){this.abort&&e.controller.off("terminated",this.abort),this.body?.destroy(D),e.controller.terminate(D),h(D)},onUpgrade(D,p,H){if(D!==101)return;let eA=new ul;for(let $=0;$<p.length;$+=2)eA.append(fl(p[$]),p[$+1].toString("latin1"),!0);return C({status:D,statusText:_F[D],headersList:eA,socket:H}),!0}}))}}Sl.exports={fetch:eR,Fetch:Vs,fetching:Fl,finalizeAndReportTiming:ml}});var hc=f((lM,Ul)=>{"use strict";Ul.exports={kState:Symbol("FileReader state"),kResult:Symbol("FileReader result"),kError:Symbol("FileReader error"),kLastProgressEventFired:Symbol("FileReader last progress event fired timestamp"),kEvents:Symbol("FileReader events"),kAborted:Symbol("FileReader aborted")}});var Ll=f((uM,Ml)=>{"use strict";var{webidl:bA}=cA(),qs=Symbol("ProgressEvent state"),dc=class e extends Event{constructor(A,t={}){A=bA.converters.DOMString(A,"ProgressEvent constructor","type"),t=bA.converters.ProgressEventInit(t??{}),super(A,t),this[qs]={lengthComputable:t.lengthComputable,loaded:t.loaded,total:t.total}}get lengthComputable(){return bA.brandCheck(this,e),this[qs].lengthComputable}get loaded(){return bA.brandCheck(this,e),this[qs].loaded}get total(){return bA.brandCheck(this,e),this[qs].total}};bA.converters.ProgressEventInit=bA.dictionaryConverter([{key:"lengthComputable",converter:bA.converters.boolean,defaultValue:()=>!1},{key:"loaded",converter:bA.converters["unsigned long long"],defaultValue:()=>0},{key:"total",converter:bA.converters["unsigned long long"],defaultValue:()=>0},{key:"bubbles",converter:bA.converters.boolean,defaultValue:()=>!1},{key:"cancelable",converter:bA.converters.boolean,defaultValue:()=>!1},{key:"composed",converter:bA.converters.boolean,defaultValue:()=>!1}]);Ml.exports={ProgressEvent:dc}});var Yl=f((hM,Tl)=>{"use strict";function sR(e){if(!e)return"failure";switch(e.trim().toLowerCase()){case"unicode-1-1-utf-8":case"unicode11utf8":case"unicode20utf8":case"utf-8":case"utf8":case"x-unicode20utf8":return"UTF-8";case"866":case"cp866":case"csibm866":case"ibm866":return"IBM866";case"csisolatin2":case"iso-8859-2":case"iso-ir-101":case"iso8859-2":case"iso88592":case"iso_8859-2":case"iso_8859-2:1987":case"l2":case"latin2":return"ISO-8859-2";case"csisolatin3":case"iso-8859-3":case"iso-ir-109":case"iso8859-3":case"iso88593":case"iso_8859-3":case"iso_8859-3:1988":case"l3":case"latin3":return"ISO-8859-3";case"csisolatin4":case"iso-8859-4":case"iso-ir-110":case"iso8859-4":case"iso88594":case"iso_8859-4":case"iso_8859-4:1988":case"l4":case"latin4":return"ISO-8859-4";case"csisolatincyrillic":case"cyrillic":case"iso-8859-5":case"iso-ir-144":case"iso8859-5":case"iso88595":case"iso_8859-5":case"iso_8859-5:1988":return"ISO-8859-5";case"arabic":case"asmo-708":case"csiso88596e":case"csiso88596i":case"csisolatinarabic":case"ecma-114":case"iso-8859-6":case"iso-8859-6-e":case"iso-8859-6-i":case"iso-ir-127":case"iso8859-6":case"iso88596":case"iso_8859-6":case"iso_8859-6:1987":return"ISO-8859-6";case"csisolatingreek":case"ecma-118":case"elot_928":case"greek":case"greek8":case"iso-8859-7":case"iso-ir-126":case"iso8859-7":case"iso88597":case"iso_8859-7":case"iso_8859-7:1987":case"sun_eu_greek":return"ISO-8859-7";case"csiso88598e":case"csisolatinhebrew":case"hebrew":case"iso-8859-8":case"iso-8859-8-e":case"iso-ir-138":case"iso8859-8":case"iso88598":case"iso_8859-8":case"iso_8859-8:1988":case"visual":return"ISO-8859-8";case"csiso88598i":case"iso-8859-8-i":case"logical":return"ISO-8859-8-I";case"csisolatin6":case"iso-8859-10":case"iso-ir-157":case"iso8859-10":case"iso885910":case"l6":case"latin6":return"ISO-8859-10";case"iso-8859-13":case"iso8859-13":case"iso885913":return"ISO-8859-13";case"iso-8859-14":case"iso8859-14":case"iso885914":return"ISO-8859-14";case"csisolatin9":case"iso-8859-15":case"iso8859-15":case"iso885915":case"iso_8859-15":case"l9":return"ISO-8859-15";case"iso-8859-16":return"ISO-8859-16";case"cskoi8r":case"koi":case"koi8":case"koi8-r":case"koi8_r":return"KOI8-R";case"koi8-ru":case"koi8-u":return"KOI8-U";case"csmacintosh":case"mac":case"macintosh":case"x-mac-roman":return"macintosh";case"iso-8859-11":case"iso8859-11":case"iso885911":case"tis-620":case"windows-874":return"windows-874";case"cp1250":case"windows-1250":case"x-cp1250":return"windows-1250";case"cp1251":case"windows-1251":case"x-cp1251":return"windows-1251";case"ansi_x3.4-1968":case"ascii":case"cp1252":case"cp819":case"csisolatin1":case"ibm819":case"iso-8859-1":case"iso-ir-100":case"iso8859-1":case"iso88591":case"iso_8859-1":case"iso_8859-1:1987":case"l1":case"latin1":case"us-ascii":case"windows-1252":case"x-cp1252":return"windows-1252";case"cp1253":case"windows-1253":case"x-cp1253":return"windows-1253";case"cp1254":case"csisolatin5":case"iso-8859-9":case"iso-ir-148":case"iso8859-9":case"iso88599":case"iso_8859-9":case"iso_8859-9:1989":case"l5":case"latin5":case"windows-1254":case"x-cp1254":return"windows-1254";case"cp1255":case"windows-1255":case"x-cp1255":return"windows-1255";case"cp1256":case"windows-1256":case"x-cp1256":return"windows-1256";case"cp1257":case"windows-1257":case"x-cp1257":return"windows-1257";case"cp1258":case"windows-1258":case"x-cp1258":return"windows-1258";case"x-mac-cyrillic":case"x-mac-ukrainian":return"x-mac-cyrillic";case"chinese":case"csgb2312":case"csiso58gb231280":case"gb2312":case"gb_2312":case"gb_2312-80":case"gbk":case"iso-ir-58":case"x-gbk":return"GBK";case"gb18030":return"gb18030";case"big5":case"big5-hkscs":case"cn-big5":case"csbig5":case"x-x-big5":return"Big5";case"cseucpkdfmtjapanese":case"euc-jp":case"x-euc-jp":return"EUC-JP";case"csiso2022jp":case"iso-2022-jp":return"ISO-2022-JP";case"csshiftjis":case"ms932":case"ms_kanji":case"shift-jis":case"shift_jis":case"sjis":case"windows-31j":case"x-sjis":return"Shift_JIS";case"cseuckr":case"csksc56011987":case"euc-kr":case"iso-ir-149":case"korean":case"ks_c_5601-1987":case"ks_c_5601-1989":case"ksc5601":case"ksc_5601":case"windows-949":return"EUC-KR";case"csiso2022kr":case"hz-gb-2312":case"iso-2022-cn":case"iso-2022-cn-ext":case"iso-2022-kr":case"replacement":return"replacement";case"unicodefffe":case"utf-16be":return"UTF-16BE";case"csunicode":case"iso-10646-ucs-2":case"ucs-2":case"unicode":case"unicodefeff":case"utf-16":case"utf-16le":return"UTF-16LE";case"x-user-defined":return"x-user-defined";default:return"failure"}}Tl.exports={getEncoding:sR}});var Wl=f((dM,ql)=>{"use strict";var{kState:er,kError:fc,kResult:xl,kAborted:$r,kLastProgressEventFired:wc}=hc(),{ProgressEvent:iR}=Ll(),{getEncoding:Gl}=Yl(),{serializeAMimeType:oR,parseMIMEType:Jl}=lA(),{types:aR}=d("node:util"),{StringDecoder:vl}=d("string_decoder"),{btoa:Hl}=d("node:buffer"),cR={enumerable:!0,writable:!1,configurable:!1};function gR(e,A,t,r){if(e[er]==="loading")throw new DOMException("Invalid state","InvalidStateError");e[er]="loading",e[xl]=null,e[fc]=null;let s=A.stream().getReader(),i=[],o=s.read(),a=!0;(async()=>{for(;!e[$r];)try{let{done:c,value:g}=await o;if(a&&!e[$r]&&queueMicrotask(()=>{Ye("loadstart",e)}),a=!1,!c&&aR.isUint8Array(g))i.push(g),(e[wc]===void 0||Date.now()-e[wc]>=50)&&!e[$r]&&(e[wc]=Date.now(),queueMicrotask(()=>{Ye("progress",e)})),o=s.read();else if(c){queueMicrotask(()=>{e[er]="done";try{let Q=QR(i,t,A.type,r);if(e[$r])return;e[xl]=Q,Ye("load",e)}catch(Q){e[fc]=Q,Ye("error",e)}e[er]!=="loading"&&Ye("loadend",e)});break}}catch(c){if(e[$r])return;queueMicrotask(()=>{e[er]="done",e[fc]=c,Ye("error",e),e[er]!=="loading"&&Ye("loadend",e)});break}})()}function Ye(e,A){let t=new iR(e,{bubbles:!1,cancelable:!1});A.dispatchEvent(t)}function QR(e,A,t,r){switch(A){case"DataURL":{let n="data:",s=Jl(t||"application/octet-stream");s!=="failure"&&(n+=oR(s)),n+=";base64,";let i=new vl("latin1");for(let o of e)n+=Hl(i.write(o));return n+=Hl(i.end()),n}case"Text":{let n="failure";if(r&&(n=Gl(r)),n==="failure"&&t){let s=Jl(t);s!=="failure"&&(n=Gl(s.parameters.get("charset")))}return n==="failure"&&(n="UTF-8"),ER(e,n)}case"ArrayBuffer":return Vl(e).buffer;case"BinaryString":{let n="",s=new vl("latin1");for(let i of e)n+=s.write(i);return n+=s.end(),n}}}function ER(e,A){let t=Vl(e),r=BR(t),n=0;r!==null&&(A=r,n=r==="UTF-8"?3:2);let s=t.slice(n);return new TextDecoder(A).decode(s)}function BR(e){let[A,t,r]=e;return A===239&&t===187&&r===191?"UTF-8":A===254&&t===255?"UTF-16BE":A===255&&t===254?"UTF-16LE":null}function Vl(e){let A=e.reduce((r,n)=>r+n.byteLength,0),t=0;return e.reduce((r,n)=>(r.set(n,t),t+=n.byteLength,r),new Uint8Array(A))}ql.exports={staticPropertyDescriptors:cR,readOperation:gR,fireAProgressEvent:Ye}});var Kl=f((fM,Zl)=>{"use strict";var{staticPropertyDescriptors:tr,readOperation:Ws,fireAProgressEvent:Ol}=Wl(),{kState:at,kError:Pl,kResult:Os,kEvents:V,kAborted:IR}=hc(),{webidl:P}=cA(),{kEnumerableProperty:dA}=T(),ZA=class e extends EventTarget{constructor(){super(),this[at]="empty",this[Os]=null,this[Pl]=null,this[V]={loadend:null,error:null,abort:null,load:null,progress:null,loadstart:null}}readAsArrayBuffer(A){P.brandCheck(this,e),P.argumentLengthCheck(arguments,1,"FileReader.readAsArrayBuffer"),A=P.converters.Blob(A,{strict:!1}),Ws(this,A,"ArrayBuffer")}readAsBinaryString(A){P.brandCheck(this,e),P.argumentLengthCheck(arguments,1,"FileReader.readAsBinaryString"),A=P.converters.Blob(A,{strict:!1}),Ws(this,A,"BinaryString")}readAsText(A,t=void 0){P.brandCheck(this,e),P.argumentLengthCheck(arguments,1,"FileReader.readAsText"),A=P.converters.Blob(A,{strict:!1}),t!==void 0&&(t=P.converters.DOMString(t,"FileReader.readAsText","encoding")),Ws(this,A,"Text",t)}readAsDataURL(A){P.brandCheck(this,e),P.argumentLengthCheck(arguments,1,"FileReader.readAsDataURL"),A=P.converters.Blob(A,{strict:!1}),Ws(this,A,"DataURL")}abort(){if(this[at]==="empty"||this[at]==="done"){this[Os]=null;return}this[at]==="loading"&&(this[at]="done",this[Os]=null),this[IR]=!0,Ol("abort",this),this[at]!=="loading"&&Ol("loadend",this)}get readyState(){switch(P.brandCheck(this,e),this[at]){case"empty":return this.EMPTY;case"loading":return this.LOADING;case"done":return this.DONE}}get result(){return P.brandCheck(this,e),this[Os]}get error(){return P.brandCheck(this,e),this[Pl]}get onloadend(){return P.brandCheck(this,e),this[V].loadend}set onloadend(A){P.brandCheck(this,e),this[V].loadend&&this.removeEventListener("loadend",this[V].loadend),typeof A=="function"?(this[V].loadend=A,this.addEventListener("loadend",A)):this[V].loadend=null}get onerror(){return P.brandCheck(this,e),this[V].error}set onerror(A){P.brandCheck(this,e),this[V].error&&this.removeEventListener("error",this[V].error),typeof A=="function"?(this[V].error=A,this.addEventListener("error",A)):this[V].error=null}get onloadstart(){return P.brandCheck(this,e),this[V].loadstart}set onloadstart(A){P.brandCheck(this,e),this[V].loadstart&&this.removeEventListener("loadstart",this[V].loadstart),typeof A=="function"?(this[V].loadstart=A,this.addEventListener("loadstart",A)):this[V].loadstart=null}get onprogress(){return P.brandCheck(this,e),this[V].progress}set onprogress(A){P.brandCheck(this,e),this[V].progress&&this.removeEventListener("progress",this[V].progress),typeof A=="function"?(this[V].progress=A,this.addEventListener("progress",A)):this[V].progress=null}get onload(){return P.brandCheck(this,e),this[V].load}set onload(A){P.brandCheck(this,e),this[V].load&&this.removeEventListener("load",this[V].load),typeof A=="function"?(this[V].load=A,this.addEventListener("load",A)):this[V].load=null}get onabort(){return P.brandCheck(this,e),this[V].abort}set onabort(A){P.brandCheck(this,e),this[V].abort&&this.removeEventListener("abort",this[V].abort),typeof A=="function"?(this[V].abort=A,this.addEventListener("abort",A)):this[V].abort=null}};ZA.EMPTY=ZA.prototype.EMPTY=0;ZA.LOADING=ZA.prototype.LOADING=1;ZA.DONE=ZA.prototype.DONE=2;Object.defineProperties(ZA.prototype,{EMPTY:tr,LOADING:tr,DONE:tr,readAsArrayBuffer:dA,readAsBinaryString:dA,readAsText:dA,readAsDataURL:dA,abort:dA,readyState:dA,result:dA,error:dA,onloadstart:dA,onprogress:dA,onload:dA,onabort:dA,onerror:dA,onloadend:dA,[Symbol.toStringTag]:{value:"FileReader",writable:!1,enumerable:!1,configurable:!0}});Object.defineProperties(ZA,{EMPTY:tr,LOADING:tr,DONE:tr});Zl.exports={FileReader:ZA}});var Ps=f((wM,zl)=>{"use strict";zl.exports={kConstruct:X().kConstruct}});var jl=f((yM,_l)=>{"use strict";var CR=d("node:assert"),{URLSerializer:Xl}=lA(),{isValidHeaderName:lR}=yA();function uR(e,A,t=!1){let r=Xl(e,t),n=Xl(A,t);return r===n}function hR(e){CR(e!==null);let A=[];for(let t of e.split(","))t=t.trim(),lR(t)&&A.push(t);return A}_l.exports={urlEquals:uR,getFieldValues:hR}});var eu=f((pM,Au)=>{"use strict";var{kConstruct:dR}=Ps(),{urlEquals:fR,getFieldValues:yc}=jl(),{kEnumerableProperty:ct,isDisturbed:wR}=T(),{webidl:k}=cA(),{Response:yR,cloneResponse:pR,fromInnerResponse:DR}=Xr(),{Request:de,fromInnerRequest:mR}=Ar(),{kState:KA}=pe(),{fetching:kR}=jr(),{urlIsHttpHttpsScheme:Zs,createDeferredPromise:rr,readAllBytes:FR}=yA(),pc=d("node:assert"),Ks=class e{#A;constructor(){arguments[0]!==dR&&k.illegalConstructor(),k.util.markAsUncloneable(this),this.#A=arguments[1]}async match(A,t={}){k.brandCheck(this,e);let r="Cache.match";k.argumentLengthCheck(arguments,1,r),A=k.converters.RequestInfo(A,r,"request"),t=k.converters.CacheQueryOptions(t,r,"options");let n=this.#n(A,t,1);if(n.length!==0)return n[0]}async matchAll(A=void 0,t={}){k.brandCheck(this,e);let r="Cache.matchAll";return A!==void 0&&(A=k.converters.RequestInfo(A,r,"request")),t=k.converters.CacheQueryOptions(t,r,"options"),this.#n(A,t)}async add(A){k.brandCheck(this,e);let t="Cache.add";k.argumentLengthCheck(arguments,1,t),A=k.converters.RequestInfo(A,t,"request");let r=[A];return await this.addAll(r)}async addAll(A){k.brandCheck(this,e);let t="Cache.addAll";k.argumentLengthCheck(arguments,1,t);let r=[],n=[];for(let E of A){if(E===void 0)throw k.errors.conversionFailed({prefix:t,argument:"Argument 1",types:["undefined is not allowed"]});if(E=k.converters.RequestInfo(E),typeof E=="string")continue;let B=E[KA];if(!Zs(B.url)||B.method!=="GET")throw k.errors.exception({header:t,message:"Expected http/s scheme when method is not GET."})}let s=[];for(let E of A){let B=new de(E)[KA];if(!Zs(B.url))throw k.errors.exception({header:t,message:"Expected http/s scheme."});B.initiator="fetch",B.destination="subresource",n.push(B);let I=rr();s.push(kR({request:B,processResponse(l){if(l.type==="error"||l.status===206||l.status<200||l.status>299)I.reject(k.errors.exception({header:"Cache.addAll",message:"Received an invalid status code or the request failed."}));else if(l.headersList.contains("vary")){let u=yc(l.headersList.get("vary"));for(let C of u)if(C==="*"){I.reject(k.errors.exception({header:"Cache.addAll",message:"invalid vary field value"}));for(let h of s)h.abort();return}}},processResponseEndOfBody(l){if(l.aborted){I.reject(new DOMException("aborted","AbortError"));return}I.resolve(l)}})),r.push(I.promise)}let o=await Promise.all(r),a=[],c=0;for(let E of o){let B={type:"put",request:n[c],response:E};a.push(B),c++}let g=rr(),Q=null;try{this.#e(a)}catch(E){Q=E}return queueMicrotask(()=>{Q===null?g.resolve(void 0):g.reject(Q)}),g.promise}async put(A,t){k.brandCheck(this,e);let r="Cache.put";k.argumentLengthCheck(arguments,2,r),A=k.converters.RequestInfo(A,r,"request"),t=k.converters.Response(t,r,"response");let n=null;if(A instanceof de?n=A[KA]:n=new de(A)[KA],!Zs(n.url)||n.method!=="GET")throw k.errors.exception({header:r,message:"Expected an http/s scheme when method is not GET"});let s=t[KA];if(s.status===206)throw k.errors.exception({header:r,message:"Got 206 status"});if(s.headersList.contains("vary")){let B=yc(s.headersList.get("vary"));for(let I of B)if(I==="*")throw k.errors.exception({header:r,message:"Got * vary field value"})}if(s.body&&(wR(s.body.stream)||s.body.stream.locked))throw k.errors.exception({header:r,message:"Response body is locked or disturbed"});let i=pR(s),o=rr();if(s.body!=null){let I=s.body.stream.getReader();FR(I).then(o.resolve,o.reject)}else o.resolve(void 0);let a=[],c={type:"put",request:n,response:i};a.push(c);let g=await o.promise;i.body!=null&&(i.body.source=g);let Q=rr(),E=null;try{this.#e(a)}catch(B){E=B}return queueMicrotask(()=>{E===null?Q.resolve():Q.reject(E)}),Q.promise}async delete(A,t={}){k.brandCheck(this,e);let r="Cache.delete";k.argumentLengthCheck(arguments,1,r),A=k.converters.RequestInfo(A,r,"request"),t=k.converters.CacheQueryOptions(t,r,"options");let n=null;if(A instanceof de){if(n=A[KA],n.method!=="GET"&&!t.ignoreMethod)return!1}else pc(typeof A=="string"),n=new de(A)[KA];let s=[],i={type:"delete",request:n,options:t};s.push(i);let o=rr(),a=null,c;try{c=this.#e(s)}catch(g){a=g}return queueMicrotask(()=>{a===null?o.resolve(!!c?.length):o.reject(a)}),o.promise}async keys(A=void 0,t={}){k.brandCheck(this,e);let r="Cache.keys";A!==void 0&&(A=k.converters.RequestInfo(A,r,"request")),t=k.converters.CacheQueryOptions(t,r,"options");let n=null;if(A!==void 0)if(A instanceof de){if(n=A[KA],n.method!=="GET"&&!t.ignoreMethod)return[]}else typeof A=="string"&&(n=new de(A)[KA]);let s=rr(),i=[];if(A===void 0)for(let o of this.#A)i.push(o[0]);else{let o=this.#t(n,t);for(let a of o)i.push(a[0])}return queueMicrotask(()=>{let o=[];for(let a of i){let c=mR(a,new AbortController().signal,"immutable");o.push(c)}s.resolve(Object.freeze(o))}),s.promise}#e(A){let t=this.#A,r=[...t],n=[],s=[];try{for(let i of A){if(i.type!=="delete"&&i.type!=="put")throw k.errors.exception({header:"Cache.#batchCacheOperations",message:'operation type does not match "delete" or "put"'});if(i.type==="delete"&&i.response!=null)throw k.errors.exception({header:"Cache.#batchCacheOperations",message:"delete operation should not have an associated response"});if(this.#t(i.request,i.options,n).length)throw new DOMException("???","InvalidStateError");let o;if(i.type==="delete"){if(o=this.#t(i.request,i.options),o.length===0)return[];for(let a of o){let c=t.indexOf(a);pc(c!==-1),t.splice(c,1)}}else if(i.type==="put"){if(i.response==null)throw k.errors.exception({header:"Cache.#batchCacheOperations",message:"put operation should have an associated response"});let a=i.request;if(!Zs(a.url))throw k.errors.exception({header:"Cache.#batchCacheOperations",message:"expected http or https scheme"});if(a.method!=="GET")throw k.errors.exception({header:"Cache.#batchCacheOperations",message:"not get method"});if(i.options!=null)throw k.errors.exception({header:"Cache.#batchCacheOperations",message:"options must not be defined"});o=this.#t(i.request);for(let c of o){let g=t.indexOf(c);pc(g!==-1),t.splice(g,1)}t.push([i.request,i.response]),n.push([i.request,i.response])}s.push([i.request,i.response])}return s}catch(i){throw this.#A.length=0,this.#A=r,i}}#t(A,t,r){let n=[],s=r??this.#A;for(let i of s){let[o,a]=i;this.#s(A,o,a,t)&&n.push(i)}return n}#s(A,t,r=null,n){let s=new URL(A.url),i=new URL(t.url);if(n?.ignoreSearch&&(i.search="",s.search=""),!fR(s,i,!0))return!1;if(r==null||n?.ignoreVary||!r.headersList.contains("vary"))return!0;let o=yc(r.headersList.get("vary"));for(let a of o){if(a==="*")return!1;let c=t.headersList.get(a),g=A.headersList.get(a);if(c!==g)return!1}return!0}#n(A,t,r=1/0){let n=null;if(A!==void 0)if(A instanceof de){if(n=A[KA],n.method!=="GET"&&!t.ignoreMethod)return[]}else typeof A=="string"&&(n=new de(A)[KA]);let s=[];if(A===void 0)for(let o of this.#A)s.push(o[1]);else{let o=this.#t(n,t);for(let a of o)s.push(a[1])}let i=[];for(let o of s){let a=DR(o,"immutable");if(i.push(a.clone()),i.length>=r)break}return Object.freeze(i)}};Object.defineProperties(Ks.prototype,{[Symbol.toStringTag]:{value:"Cache",configurable:!0},match:ct,matchAll:ct,add:ct,addAll:ct,put:ct,delete:ct,keys:ct});var $l=[{key:"ignoreSearch",converter:k.converters.boolean,defaultValue:()=>!1},{key:"ignoreMethod",converter:k.converters.boolean,defaultValue:()=>!1},{key:"ignoreVary",converter:k.converters.boolean,defaultValue:()=>!1}];k.converters.CacheQueryOptions=k.dictionaryConverter($l);k.converters.MultiCacheQueryOptions=k.dictionaryConverter([...$l,{key:"cacheName",converter:k.converters.DOMString}]);k.converters.Response=k.interfaceConverter(yR);k.converters["sequence<RequestInfo>"]=k.sequenceConverter(k.converters.RequestInfo);Au.exports={Cache:Ks}});var ru=f((DM,tu)=>{"use strict";var{kConstruct:An}=Ps(),{Cache:zs}=eu(),{webidl:QA}=cA(),{kEnumerableProperty:en}=T(),Xs=class e{#A=new Map;constructor(){arguments[0]!==An&&QA.illegalConstructor(),QA.util.markAsUncloneable(this)}async match(A,t={}){if(QA.brandCheck(this,e),QA.argumentLengthCheck(arguments,1,"CacheStorage.match"),A=QA.converters.RequestInfo(A),t=QA.converters.MultiCacheQueryOptions(t),t.cacheName!=null){if(this.#A.has(t.cacheName)){let r=this.#A.get(t.cacheName);return await new zs(An,r).match(A,t)}}else for(let r of this.#A.values()){let s=await new zs(An,r).match(A,t);if(s!==void 0)return s}}async has(A){QA.brandCheck(this,e);let t="CacheStorage.has";return QA.argumentLengthCheck(arguments,1,t),A=QA.converters.DOMString(A,t,"cacheName"),this.#A.has(A)}async open(A){QA.brandCheck(this,e);let t="CacheStorage.open";if(QA.argumentLengthCheck(arguments,1,t),A=QA.converters.DOMString(A,t,"cacheName"),this.#A.has(A)){let n=this.#A.get(A);return new zs(An,n)}let r=[];return this.#A.set(A,r),new zs(An,r)}async delete(A){QA.brandCheck(this,e);let t="CacheStorage.delete";return QA.argumentLengthCheck(arguments,1,t),A=QA.converters.DOMString(A,t,"cacheName"),this.#A.delete(A)}async keys(){return QA.brandCheck(this,e),[...this.#A.keys()]}};Object.defineProperties(Xs.prototype,{[Symbol.toStringTag]:{value:"CacheStorage",configurable:!0},match:en,has:en,open:en,delete:en,keys:en});tu.exports={CacheStorage:Xs}});var su=f((mM,nu)=>{"use strict";nu.exports={maxAttributeValueSize:1024,maxNameValuePairSize:4096}});var kc=f((kM,cu)=>{"use strict";function RR(e){for(let A=0;A<e.length;++A){let t=e.charCodeAt(A);if(t>=0&&t<=8||t>=10&&t<=31||t===127)return!0}return!1}function Dc(e){for(let A=0;A<e.length;++A){let t=e.charCodeAt(A);if(t<33||t>126||t===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)throw new Error("Invalid cookie name")}}function mc(e){let A=e.length,t=0;if(e[0]==='"'){if(A===1||e[A-1]!=='"')throw new Error("Invalid cookie value");--A,++t}for(;t<A;){let r=e.charCodeAt(t++);if(r<33||r>126||r===34||r===44||r===59||r===92)throw new Error("Invalid cookie value")}}function ou(e){for(let A=0;A<e.length;++A){let t=e.charCodeAt(A);if(t<32||t>126||t===59)throw new Error("Invalid cookie path")}}function iu(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122}function bR(e){if(e===" ")return;if(e.length>255)throw new Error("Invalid cookie domain");let A=0;for(let t=0;t<e.length;++t){let r=e.charCodeAt(t);if(r===46){if(A===0)throw new Error("Invalid cookie domain");if(e.charCodeAt(t-1)===45)throw new Error("Invalid cookie domain");A=0;continue}if(A===0&&!iu(r))throw new Error("Invalid cookie domain");if(!iu(r)&&r!==45)throw new Error("Invalid cookie domain");if(++A>63)throw new Error("Invalid cookie domain")}if(A===0||e.charCodeAt(e.length-1)===45)throw new Error("Invalid cookie domain")}var NR=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],SR=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],_s=Array(61).fill(0).map((e,A)=>A.toString().padStart(2,"0"));function au(e){return typeof e=="number"&&(e=new Date(e)),`${NR[e.getUTCDay()]}, ${_s[e.getUTCDate()]} ${SR[e.getUTCMonth()]} ${e.getUTCFullYear()} ${_s[e.getUTCHours()]}:${_s[e.getUTCMinutes()]}:${_s[e.getUTCSeconds()]} GMT`}function UR(e){if(e<0)throw new Error("Invalid cookie max-age")}function MR(e){if(e.name.length===0)return null;Dc(e.name),mc(e.value);let A=[`${e.name}=${e.value}`];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"),typeof e.maxAge=="number"&&(UR(e.maxAge),A.push(`Max-Age=${e.maxAge}`)),e.domain&&(bR(e.domain),A.push(`Domain=${e.domain}`)),e.path&&(ou(e.path),A.push(`Path=${e.path}`)),e.expires&&e.expires.toString()!=="Invalid Date"&&A.push(`Expires=${au(e.expires)}`),e.sameSite&&A.push(`SameSite=${e.sameSite}`);for(let t of e.unparsed){if(!t.includes("="))throw new Error("Invalid unparsed");let[r,...n]=t.split("="),s=r.trim(),i=n.join("=");Dc(s),mc(i),A.push(`${s}=${i}`)}return A.join("; ")}cu.exports={isCTLExcludingHtab:RR,validateCookieName:Dc,validateCookiePath:ou,validateCookieValue:mc,toIMFDate:au,stringify:MR}});var Qu=f((FM,gu)=>{"use strict";var{maxNameValuePairSize:LR,maxAttributeValueSize:TR}=su(),{isCTLExcludingHtab:YR}=kc(),{collectASequenceOfCodePointsFast:js}=lA(),xR=d("node:assert");function GR(e){if(YR(e))return null;let A="",t="",r="",n="";if(e.includes(";")){let s={position:0};A=js(";",e,s),t=e.slice(s.position)}else A=e;if(!A.includes("="))n=A;else{let s={position:0};r=js("=",A,s),n=A.slice(s.position+1)}return r=r.trim(),n=n.trim(),r.length+n.length>LR?null:{name:r,value:n,...nr(t)}}function nr(e,A={}){if(e.length===0)return A;xR(e[0]===";"),e=e.slice(1);let t="";e.includes(";")?(t=js(";",e,{position:0}),e=e.slice(t.length)):(t=e,e="");let r="",n="";if(t.includes("=")){let i={position:0};r=js("=",t,i),n=t.slice(i.position+1)}else r=t;if(r=r.trim(),n=n.trim(),n.length>TR)return nr(e,A);let s=r.toLowerCase();if(s==="expires"){let i=new Date(n);A.expires=i}else if(s==="max-age"){let i=n.charCodeAt(0);if((i<48||i>57)&&n[0]!=="-"||!/^\d+$/.test(n))return nr(e,A);let o=Number(n);A.maxAge=o}else if(s==="domain"){let i=n;i[0]==="."&&(i=i.slice(1)),i=i.toLowerCase(),A.domain=i}else if(s==="path"){let i="";n.length===0||n[0]!=="/"?i="/":i=n,A.path=i}else if(s==="secure")A.secure=!0;else if(s==="httponly")A.httpOnly=!0;else if(s==="samesite"){let i=n.toLowerCase();i==="none"?A.sameSite="None":i==="strict"?A.sameSite="Strict":i==="lax"&&(A.sameSite="Lax")}else A.unparsed??=[],A.unparsed.push(`${r}=${n}`);return nr(e,A)}gu.exports={parseSetCookie:GR,parseUnparsedAttributes:nr}});var Iu=f((RM,Bu)=>{"use strict";var{parseSetCookie:JR}=Qu(),{stringify:vR}=kc(),{webidl:x}=cA(),{Headers:$s}=nt();function HR(e){x.argumentLengthCheck(arguments,1,"getCookies"),x.brandCheck(e,$s,{strict:!1});let A=e.get("cookie"),t={};if(!A)return t;for(let r of A.split(";")){let[n,...s]=r.split("=");t[n.trim()]=s.join("=")}return t}function VR(e,A,t){x.brandCheck(e,$s,{strict:!1});let r="deleteCookie";x.argumentLengthCheck(arguments,2,r),A=x.converters.DOMString(A,r,"name"),t=x.converters.DeleteCookieAttributes(t),Eu(e,{name:A,value:"",expires:new Date(0),...t})}function qR(e){x.argumentLengthCheck(arguments,1,"getSetCookies"),x.brandCheck(e,$s,{strict:!1});let A=e.getSetCookie();return A?A.map(t=>JR(t)):[]}function Eu(e,A){x.argumentLengthCheck(arguments,2,"setCookie"),x.brandCheck(e,$s,{strict:!1}),A=x.converters.Cookie(A);let t=vR(A);t&&e.append("Set-Cookie",t)}x.converters.DeleteCookieAttributes=x.dictionaryConverter([{converter:x.nullableConverter(x.converters.DOMString),key:"path",defaultValue:()=>null},{converter:x.nullableConverter(x.converters.DOMString),key:"domain",defaultValue:()=>null}]);x.converters.Cookie=x.dictionaryConverter([{converter:x.converters.DOMString,key:"name"},{converter:x.converters.DOMString,key:"value"},{converter:x.nullableConverter(e=>typeof e=="number"?x.converters["unsigned long long"](e):new Date(e)),key:"expires",defaultValue:()=>null},{converter:x.nullableConverter(x.converters["long long"]),key:"maxAge",defaultValue:()=>null},{converter:x.nullableConverter(x.converters.DOMString),key:"domain",defaultValue:()=>null},{converter:x.nullableConverter(x.converters.DOMString),key:"path",defaultValue:()=>null},{converter:x.nullableConverter(x.converters.boolean),key:"secure",defaultValue:()=>null},{converter:x.nullableConverter(x.converters.boolean),key:"httpOnly",defaultValue:()=>null},{converter:x.converters.USVString,key:"sameSite",allowedValues:["Strict","Lax","None"]},{converter:x.sequenceConverter(x.converters.DOMString),key:"unparsed",defaultValue:()=>new Array(0)}]);Bu.exports={getCookies:HR,deleteCookie:VR,getSetCookies:qR,setCookie:Eu}});var ir=f((bM,lu)=>{"use strict";var{webidl:m}=cA(),{kEnumerableProperty:fA}=T(),{kConstruct:Cu}=X(),{MessagePort:WR}=d("node:worker_threads"),sr=class e extends Event{#A;constructor(A,t={}){if(A===Cu){super(arguments[1],arguments[2]),m.util.markAsUncloneable(this);return}let r="MessageEvent constructor";m.argumentLengthCheck(arguments,1,r),A=m.converters.DOMString(A,r,"type"),t=m.converters.MessageEventInit(t,r,"eventInitDict"),super(A,t),this.#A=t,m.util.markAsUncloneable(this)}get data(){return m.brandCheck(this,e),this.#A.data}get origin(){return m.brandCheck(this,e),this.#A.origin}get lastEventId(){return m.brandCheck(this,e),this.#A.lastEventId}get source(){return m.brandCheck(this,e),this.#A.source}get ports(){return m.brandCheck(this,e),Object.isFrozen(this.#A.ports)||Object.freeze(this.#A.ports),this.#A.ports}initMessageEvent(A,t=!1,r=!1,n=null,s="",i="",o=null,a=[]){return m.brandCheck(this,e),m.argumentLengthCheck(arguments,1,"MessageEvent.initMessageEvent"),new e(A,{bubbles:t,cancelable:r,data:n,origin:s,lastEventId:i,source:o,ports:a})}static createFastMessageEvent(A,t){let r=new e(Cu,A,t);return r.#A=t,r.#A.data??=null,r.#A.origin??="",r.#A.lastEventId??="",r.#A.source??=null,r.#A.ports??=[],r}},{createFastMessageEvent:OR}=sr;delete sr.createFastMessageEvent;var Ai=class e extends Event{#A;constructor(A,t={}){let r="CloseEvent constructor";m.argumentLengthCheck(arguments,1,r),A=m.converters.DOMString(A,r,"type"),t=m.converters.CloseEventInit(t),super(A,t),this.#A=t,m.util.markAsUncloneable(this)}get wasClean(){return m.brandCheck(this,e),this.#A.wasClean}get code(){return m.brandCheck(this,e),this.#A.code}get reason(){return m.brandCheck(this,e),this.#A.reason}},ei=class e extends Event{#A;constructor(A,t){let r="ErrorEvent constructor";m.argumentLengthCheck(arguments,1,r),super(A,t),m.util.markAsUncloneable(this),A=m.converters.DOMString(A,r,"type"),t=m.converters.ErrorEventInit(t??{}),this.#A=t}get message(){return m.brandCheck(this,e),this.#A.message}get filename(){return m.brandCheck(this,e),this.#A.filename}get lineno(){return m.brandCheck(this,e),this.#A.lineno}get colno(){return m.brandCheck(this,e),this.#A.colno}get error(){return m.brandCheck(this,e),this.#A.error}};Object.defineProperties(sr.prototype,{[Symbol.toStringTag]:{value:"MessageEvent",configurable:!0},data:fA,origin:fA,lastEventId:fA,source:fA,ports:fA,initMessageEvent:fA});Object.defineProperties(Ai.prototype,{[Symbol.toStringTag]:{value:"CloseEvent",configurable:!0},reason:fA,code:fA,wasClean:fA});Object.defineProperties(ei.prototype,{[Symbol.toStringTag]:{value:"ErrorEvent",configurable:!0},message:fA,filename:fA,lineno:fA,colno:fA,error:fA});m.converters.MessagePort=m.interfaceConverter(WR);m.converters["sequence<MessagePort>"]=m.sequenceConverter(m.converters.MessagePort);var Fc=[{key:"bubbles",converter:m.converters.boolean,defaultValue:()=>!1},{key:"cancelable",converter:m.converters.boolean,defaultValue:()=>!1},{key:"composed",converter:m.converters.boolean,defaultValue:()=>!1}];m.converters.MessageEventInit=m.dictionaryConverter([...Fc,{key:"data",converter:m.converters.any,defaultValue:()=>null},{key:"origin",converter:m.converters.USVString,defaultValue:()=>""},{key:"lastEventId",converter:m.converters.DOMString,defaultValue:()=>""},{key:"source",converter:m.nullableConverter(m.converters.MessagePort),defaultValue:()=>null},{key:"ports",converter:m.converters["sequence<MessagePort>"],defaultValue:()=>new Array(0)}]);m.converters.CloseEventInit=m.dictionaryConverter([...Fc,{key:"wasClean",converter:m.converters.boolean,defaultValue:()=>!1},{key:"code",converter:m.converters["unsigned short"],defaultValue:()=>0},{key:"reason",converter:m.converters.USVString,defaultValue:()=>""}]);m.converters.ErrorEventInit=m.dictionaryConverter([...Fc,{key:"message",converter:m.converters.DOMString,defaultValue:()=>""},{key:"filename",converter:m.converters.USVString,defaultValue:()=>""},{key:"lineno",converter:m.converters["unsigned long"],defaultValue:()=>0},{key:"colno",converter:m.converters["unsigned long"],defaultValue:()=>0},{key:"error",converter:m.converters.any}]);lu.exports={MessageEvent:sr,CloseEvent:Ai,ErrorEvent:ei,createFastMessageEvent:OR}});var gt=f((NM,uu)=>{"use strict";var PR="258EAFA5-E914-47DA-95CA-C5AB0DC85B11",ZR={enumerable:!0,writable:!1,configurable:!1},KR={CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},zR={NOT_SENT:0,PROCESSING:1,SENT:2},XR={CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},_R=2**16-1,jR={INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},$R=Buffer.allocUnsafe(0),Ab={string:1,typedArray:2,arrayBuffer:3,blob:4};uu.exports={uid:PR,sentCloseFrameState:zR,staticPropertyDescriptors:ZR,states:KR,opcodes:XR,maxUnsigned16Bit:_R,parserStates:jR,emptyBuffer:$R,sendHints:Ab}});var tn=f((SM,hu)=>{"use strict";hu.exports={kWebSocketURL:Symbol("url"),kReadyState:Symbol("ready state"),kController:Symbol("controller"),kResponse:Symbol("response"),kBinaryType:Symbol("binary type"),kSentClose:Symbol("sent close"),kReceivedClose:Symbol("received close"),kByteParser:Symbol("byte parser")}});var sn=f((UM,Fu)=>{"use strict";var{kReadyState:rn,kController:eb,kResponse:tb,kBinaryType:rb,kWebSocketURL:nb}=tn(),{states:nn,opcodes:xe}=gt(),{ErrorEvent:sb,createFastMessageEvent:ib}=ir(),{isUtf8:ob}=d("node:buffer"),{collectASequenceOfCodePointsFast:ab,removeHTTPWhitespace:du}=lA();function cb(e){return e[rn]===nn.CONNECTING}function gb(e){return e[rn]===nn.OPEN}function Qb(e){return e[rn]===nn.CLOSING}function Eb(e){return e[rn]===nn.CLOSED}function Rc(e,A,t=(n,s)=>new Event(n,s),r={}){let n=t(e,r);A.dispatchEvent(n)}function Bb(e,A,t){if(e[rn]!==nn.OPEN)return;let r;if(A===xe.TEXT)try{r=ku(t)}catch{wu(e,"Received invalid UTF-8 in text frame.");return}else A===xe.BINARY&&(e[rb]==="blob"?r=new Blob([t]):r=Ib(t));Rc("message",e,ib,{origin:e[nb].origin,data:r})}function Ib(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function Cb(e){if(e.length===0)return!1;for(let A=0;A<e.length;++A){let t=e.charCodeAt(A);if(t<33||t>126||t===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)return!1}return!0}function lb(e){return e>=1e3&&e<1015?e!==1004&&e!==1005&&e!==1006:e>=3e3&&e<=4999}function wu(e,A){let{[eb]:t,[tb]:r}=e;t.abort(),r?.socket&&!r.socket.destroyed&&r.socket.destroy(),A&&Rc("error",e,(n,s)=>new sb(n,s),{error:new Error(A),message:A})}function yu(e){return e===xe.CLOSE||e===xe.PING||e===xe.PONG}function pu(e){return e===xe.CONTINUATION}function Du(e){return e===xe.TEXT||e===xe.BINARY}function ub(e){return Du(e)||pu(e)||yu(e)}function hb(e){let A={position:0},t=new Map;for(;A.position<e.length;){let r=ab(";",e,A),[n,s=""]=r.split("=");t.set(du(n,!0,!1),du(s,!1,!0)),A.position++}return t}function db(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r<48||r>57)return!1}let A=Number.parseInt(e,10);return A>=8&&A<=15}var mu=typeof process.versions.icu=="string",fu=mu?new TextDecoder("utf-8",{fatal:!0}):void 0,ku=mu?fu.decode.bind(fu):function(e){if(ob(e))return e.toString("utf-8");throw new TypeError("Invalid utf-8 received.")};Fu.exports={isConnecting:cb,isEstablished:gb,isClosing:Qb,isClosed:Eb,fireEvent:Rc,isValidSubprotocol:Cb,isValidStatusCode:lb,failWebsocketConnection:wu,websocketMessageReceived:Bb,utf8Decode:ku,isControlFrame:yu,isContinuationFrame:pu,isTextBinaryFrame:Du,isValidOpcode:ub,parseExtensions:hb,isValidClientWindowBits:db}});var ri=f((MM,Ru)=>{"use strict";var{maxUnsigned16Bit:fb}=gt(),ti=16386,bc,on=null,or=ti;try{bc=d("node:crypto")}catch{bc={randomFillSync:function(A,t,r){for(let n=0;n<A.length;++n)A[n]=Math.random()*255|0;return A}}}function wb(){return or===ti&&(or=0,bc.randomFillSync(on??=Buffer.allocUnsafe(ti),0,ti)),[on[or++],on[or++],on[or++],on[or++]]}var Nc=class{constructor(A){this.frameData=A}createFrame(A){let t=this.frameData,r=wb(),n=t?.byteLength??0,s=n,i=6;n>fb?(i+=8,s=127):n>125&&(i+=2,s=126);let o=Buffer.allocUnsafe(n+i);o[0]=o[1]=0,o[0]|=128,o[0]=(o[0]&240)+A;o[i-4]=r[0],o[i-3]=r[1],o[i-2]=r[2],o[i-1]=r[3],o[1]=s,s===126?o.writeUInt16BE(n,2):s===127&&(o[2]=o[3]=0,o.writeUIntBE(n,4,6)),o[1]|=128;for(let a=0;a<n;++a)o[i+a]=t[a]^r[a&3];return o}};Ru.exports={WebsocketFrameSend:Nc}});var Uc=f((LM,Tu)=>{"use strict";var{uid:yb,states:an,sentCloseFrameState:ni,emptyBuffer:pb,opcodes:Db}=gt(),{kReadyState:cn,kSentClose:si,kByteParser:Nu,kReceivedClose:bu,kResponse:Su}=tn(),{fireEvent:mb,failWebsocketConnection:Ge,isClosing:kb,isClosed:Fb,isEstablished:Rb,parseExtensions:bb}=sn(),{channels:ar}=ht(),{CloseEvent:Nb}=ir(),{makeRequest:Sb}=Ar(),{fetching:Ub}=jr(),{Headers:Mb,getHeadersList:Lb}=nt(),{getDecodeSplit:Tb}=yA(),{WebsocketFrameSend:Yb}=ri(),Sc;try{Sc=d("node:crypto")}catch{}function xb(e,A,t,r,n,s){let i=e;i.protocol=e.protocol==="ws:"?"http:":"https:";let o=Sb({urlList:[i],client:t,serviceWorkers:"none",referrer:"no-referrer",mode:"websocket",credentials:"include",cache:"no-store",redirect:"error"});if(s.headers){let Q=Lb(new Mb(s.headers));o.headersList=Q}let a=Sc.randomBytes(16).toString("base64");o.headersList.append("sec-websocket-key",a),o.headersList.append("sec-websocket-version","13");for(let Q of A)o.headersList.append("sec-websocket-protocol",Q);return o.headersList.append("sec-websocket-extensions","permessage-deflate; client_max_window_bits"),Ub({request:o,useParallelQueue:!0,dispatcher:s.dispatcher,processResponse(Q){if(Q.type==="error"||Q.status!==101){Ge(r,"Received network error or non-101 status code.");return}if(A.length!==0&&!Q.headersList.get("Sec-WebSocket-Protocol")){Ge(r,"Server did not respond with sent protocols.");return}if(Q.headersList.get("Upgrade")?.toLowerCase()!=="websocket"){Ge(r,'Server did not set Upgrade header to "websocket".');return}if(Q.headersList.get("Connection")?.toLowerCase()!=="upgrade"){Ge(r,'Server did not set Connection header to "upgrade".');return}let E=Q.headersList.get("Sec-WebSocket-Accept"),B=Sc.createHash("sha1").update(a+yb).digest("base64");if(E!==B){Ge(r,"Incorrect hash received in Sec-WebSocket-Accept header.");return}let I=Q.headersList.get("Sec-WebSocket-Extensions"),l;if(I!==null&&(l=bb(I),!l.has("permessage-deflate"))){Ge(r,"Sec-WebSocket-Extensions header does not match.");return}let u=Q.headersList.get("Sec-WebSocket-Protocol");if(u!==null&&!Tb("sec-websocket-protocol",o.headersList).includes(u)){Ge(r,"Protocol was not set in the opening handshake.");return}Q.socket.on("data",Uu),Q.socket.on("close",Mu),Q.socket.on("error",Lu),ar.open.hasSubscribers&&ar.open.publish({address:Q.socket.address(),protocol:u,extensions:I}),n(Q,l)}})}function Gb(e,A,t,r){if(!(kb(e)||Fb(e)))if(!Rb(e))Ge(e,"Connection was closed before it was established."),e[cn]=an.CLOSING;else if(e[si]===ni.NOT_SENT){e[si]=ni.PROCESSING;let n=new Yb;A!==void 0&&t===void 0?(n.frameData=Buffer.allocUnsafe(2),n.frameData.writeUInt16BE(A,0)):A!==void 0&&t!==void 0?(n.frameData=Buffer.allocUnsafe(2+r),n.frameData.writeUInt16BE(A,0),n.frameData.write(t,2,"utf-8")):n.frameData=pb,e[Su].socket.write(n.createFrame(Db.CLOSE)),e[si]=ni.SENT,e[cn]=an.CLOSING}else e[cn]=an.CLOSING}function Uu(e){this.ws[Nu].write(e)||this.pause()}function Mu(){let{ws:e}=this,{[Su]:A}=e;A.socket.off("data",Uu),A.socket.off("close",Mu),A.socket.off("error",Lu);let t=e[si]===ni.SENT&&e[bu],r=1005,n="",s=e[Nu].closingInfo;s&&!s.error?(r=s.code??1005,n=s.reason):e[bu]||(r=1006),e[cn]=an.CLOSED,mb("close",e,(i,o)=>new Nb(i,o),{wasClean:t,code:r,reason:n}),ar.close.hasSubscribers&&ar.close.publish({websocket:e,code:r,reason:n})}function Lu(e){let{ws:A}=this;A[cn]=an.CLOSING,ar.socketError.hasSubscribers&&ar.socketError.publish(e),this.destroy()}Tu.exports={establishWebSocketConnection:xb,closeWebSocketConnection:Gb}});var xu=f((TM,Yu)=>{"use strict";var{createInflateRaw:Jb,Z_DEFAULT_WINDOWBITS:vb}=d("node:zlib"),{isValidClientWindowBits:Hb}=sn(),{MessageSizeExceededError:Vb}=v(),qb=Buffer.from([0,0,255,255]),ii=Symbol("kBuffer"),gn=Symbol("kLength"),Mc=class{#A;#e={};#t=0;constructor(A,t){this.#e.serverNoContextTakeover=A.has("server_no_context_takeover"),this.#e.serverMaxWindowBits=A.get("server_max_window_bits"),this.#t=t.maxPayloadSize}decompress(A,t,r){if(!this.#A){let n=vb;if(this.#e.serverMaxWindowBits){if(!Hb(this.#e.serverMaxWindowBits)){r(new Error("Invalid server_max_window_bits"));return}n=Number.parseInt(this.#e.serverMaxWindowBits)}try{this.#A=Jb({windowBits:n})}catch(s){r(s);return}this.#A[ii]=[],this.#A[gn]=0,this.#A.on("data",s=>{if(this.#A[gn]+=s.length,this.#t>0&&this.#A[gn]>this.#t){r(new Vb),this.#A.removeAllListeners(),this.#A=null;return}this.#A[ii].push(s)}),this.#A.on("error",s=>{this.#A=null,r(s)})}this.#A.write(A),t&&this.#A.write(qb),this.#A.flush(()=>{if(!this.#A)return;let n=Buffer.concat(this.#A[ii],this.#A[gn]);this.#A[ii].length=0,this.#A[gn]=0,r(null,n)})}};Yu.exports={PerMessageDeflate:Mc}});var Zu=f((YM,Pu)=>{"use strict";var{Writable:Wb}=d("node:stream"),Ob=d("node:assert"),{parserStates:wA,opcodes:cr,states:Pb,emptyBuffer:Gu,sentCloseFrameState:Ju}=gt(),{kReadyState:Zb,kSentClose:vu,kResponse:Hu,kReceivedClose:Vu}=tn(),{channels:oi}=ht(),{isValidStatusCode:Kb,isValidOpcode:zb,failWebsocketConnection:NA,websocketMessageReceived:qu,utf8Decode:Xb,isControlFrame:Lc,isTextBinaryFrame:Tc,isContinuationFrame:_b}=sn(),{WebsocketFrameSend:Wu}=ri(),{closeWebSocketConnection:Ou}=Uc(),{PerMessageDeflate:jb}=xu(),{MessageSizeExceededError:Yc}=v();function Qn(e,A,t){Ou(e,A,t,Buffer.byteLength(t)),NA(e,t)}var xc=class extends Wb{#A=[];#e=0;#t=0;#s=!1;#n=wA.INFO;#r={};#i=[];#o;#c;#a;constructor(A,t,r={}){super(),this.ws=A,this.#o=t??new Map,this.#c=r.maxFragments??0,this.#a=r.maxPayloadSize??0,this.#o.has("permessage-deflate")&&this.#o.set("permessage-deflate",new jb(t,r))}_write(A,t,r){this.#A.push(A),this.#t+=A.length,this.#s=!0,this.run(r)}#g(){return this.#a>0&&!Lc(this.#r.opcode)&&this.#r.payloadLength+this.#e>this.#a?(Qn(this.ws,1009,"Payload size exceeds maximum allowed size"),!1):!0}run(A){for(;this.#s;)if(this.#n===wA.INFO){if(this.#t<2)return A();let t=this.consume(2),r=(t[0]&128)!==0,n=t[0]&15,s=(t[1]&128)===128,i=!r&&n!==cr.CONTINUATION,o=t[1]&127,a=t[0]&64,c=t[0]&32,g=t[0]&16;if(!zb(n))return NA(this.ws,"Invalid opcode received"),A();if(s)return NA(this.ws,"Frame cannot be masked"),A();if(a!==0&&!this.#o.has("permessage-deflate")){NA(this.ws,"Expected RSV1 to be clear.");return}if(c!==0||g!==0){NA(this.ws,"RSV1, RSV2, RSV3 must be clear");return}if(i&&!Tc(n)){NA(this.ws,"Invalid frame type was fragmented.");return}if(Tc(n)&&this.#i.length>0){NA(this.ws,"Expected continuation frame");return}if(this.#r.fragmented&&i){NA(this.ws,"Fragmented frame exceeded 125 bytes.");return}if((o>125||i)&&Lc(n)){NA(this.ws,"Control frame either too large or fragmented");return}if(_b(n)&&this.#i.length===0&&!this.#r.compressed){NA(this.ws,"Unexpected continuation frame");return}if(o<=125){if(this.#r.payloadLength=o,this.#n=wA.READ_DATA,!this.#g())return}else o===126?this.#n=wA.PAYLOADLENGTH_16:o===127&&(this.#n=wA.PAYLOADLENGTH_64);Tc(n)&&(this.#r.binaryType=n,this.#r.compressed=a!==0),this.#r.opcode=n,this.#r.masked=s,this.#r.fin=r,this.#r.fragmented=i}else if(this.#n===wA.PAYLOADLENGTH_16){if(this.#t<2)return A();let t=this.consume(2);if(this.#r.payloadLength=t.readUInt16BE(0),this.#n=wA.READ_DATA,!this.#g())return}else if(this.#n===wA.PAYLOADLENGTH_64){if(this.#t<8)return A();let t=this.consume(8),r=t.readUInt32BE(0),n=t.readUInt32BE(4);if(r!==0||n>2**31-1){NA(this.ws,"Received payload length > 2^31 bytes.");return}if(this.#r.payloadLength=n,this.#n=wA.READ_DATA,!this.#g())return}else if(this.#n===wA.READ_DATA){if(this.#t<this.#r.payloadLength)return A();let t=this.consume(this.#r.payloadLength);if(Lc(this.#r.opcode))this.#s=this.parseControlFrame(t),this.#n=wA.INFO;else if(this.#r.compressed){this.#o.get("permessage-deflate").decompress(t,this.#r.fin,(r,n)=>{if(r){let s=r instanceof Yc?1009:1007;Qn(this.ws,s,r.message);return}if(this.writeFragments(n)){if(this.#a>0&&this.#e>this.#a){Qn(this.ws,1009,new Yc().message);return}if(!this.#r.fin){this.#n=wA.INFO,this.#s=!0,this.run(A);return}qu(this.ws,this.#r.binaryType,this.consumeFragments()),this.#s=!0,this.#n=wA.INFO,this.run(A)}}),this.#s=!1;break}else{if(!this.writeFragments(t))return;if(this.#a>0&&this.#e>this.#a){Qn(this.ws,1009,new Yc().message);return}!this.#r.fragmented&&this.#r.fin&&qu(this.ws,this.#r.binaryType,this.consumeFragments()),this.#n=wA.INFO}}}consume(A){if(A>this.#t)throw new Error("Called consume() before buffers satiated.");if(A===0)return Gu;if(this.#A[0].length===A)return this.#t-=this.#A[0].length,this.#A.shift();let t=Buffer.allocUnsafe(A),r=0;for(;r!==A;){let n=this.#A[0],{length:s}=n;if(s+r===A){t.set(this.#A.shift(),r);break}else if(s+r>A){t.set(n.subarray(0,A-r),r),this.#A[0]=n.subarray(A-r);break}else t.set(this.#A.shift(),r),r+=n.length}return this.#t-=A,t}writeFragments(A){return this.#c>0&&this.#i.length===this.#c?(Qn(this.ws,1008,"Too many message fragments"),!1):(this.#e+=A.length,this.#i.push(A),!0)}consumeFragments(){let A=this.#i;if(A.length===1)return this.#e=0,A.shift();let t=Buffer.concat(A,this.#e);return this.#i=[],this.#e=0,t}parseCloseBody(A){Ob(A.length!==1);let t;if(A.length>=2&&(t=A.readUInt16BE(0)),t!==void 0&&!Kb(t))return{code:1002,reason:"Invalid status code",error:!0};let r=A.subarray(2);r[0]===239&&r[1]===187&&r[2]===191&&(r=r.subarray(3));try{r=Xb(r)}catch{return{code:1007,reason:"Invalid UTF-8",error:!0}}return{code:t,reason:r,error:!1}}parseControlFrame(A){let{opcode:t,payloadLength:r}=this.#r;if(t===cr.CLOSE){if(r===1)return NA(this.ws,"Received close frame with a 1-byte body."),!1;if(this.#r.closeInfo=this.parseCloseBody(A),this.#r.closeInfo.error){let{code:n,reason:s}=this.#r.closeInfo;return Ou(this.ws,n,s,s.length),NA(this.ws,s),!1}if(this.ws[vu]!==Ju.SENT){let n=Gu;this.#r.closeInfo.code&&(n=Buffer.allocUnsafe(2),n.writeUInt16BE(this.#r.closeInfo.code,0));let s=new Wu(n);this.ws[Hu].socket.write(s.createFrame(cr.CLOSE),i=>{i||(this.ws[vu]=Ju.SENT)})}return this.ws[Zb]=Pb.CLOSING,this.ws[Vu]=!0,!1}else if(t===cr.PING){if(!this.ws[Vu]){let n=new Wu(A);this.ws[Hu].socket.write(n.createFrame(cr.PONG)),oi.ping.hasSubscribers&&oi.ping.publish({payload:A})}}else t===cr.PONG&&oi.pong.hasSubscribers&&oi.pong.publish({payload:A});return!0}get closingInfo(){return this.#r.closeInfo}};Pu.exports={ByteParser:xc}});var ju=f((xM,_u)=>{"use strict";var{WebsocketFrameSend:$b}=ri(),{opcodes:Ku,sendHints:gr}=gt(),AN=qo(),zu=Buffer[Symbol.species],Gc=class{#A=new AN;#e=!1;#t;constructor(A){this.#t=A}add(A,t,r){if(r!==gr.blob){let s=Xu(A,r);if(!this.#e)this.#t.write(s,t);else{let i={promise:null,callback:t,frame:s};this.#A.push(i)}return}let n={promise:A.arrayBuffer().then(s=>{n.promise=null,n.frame=Xu(s,r)}),callback:t,frame:null};this.#A.push(n),this.#e||this.#s()}async#s(){this.#e=!0;let A=this.#A;for(;!A.isEmpty();){let t=A.shift();t.promise!==null&&await t.promise,this.#t.write(t.frame,t.callback),t.callback=t.frame=null}this.#e=!1}};function Xu(e,A){return new $b(eN(e,A)).createFrame(A===gr.string?Ku.TEXT:Ku.BINARY)}function eN(e,A){switch(A){case gr.string:return Buffer.from(e);case gr.arrayBuffer:case gr.blob:return new zu(e);case gr.typedArray:return new zu(e.buffer,e.byteOffset,e.byteLength)}}_u.exports={SendQueue:Gc}});var ah=f((GM,oh)=>{"use strict";var{webidl:U}=cA(),{URLSerializer:tN}=lA(),{environmentSettingsObject:$u}=yA(),{staticPropertyDescriptors:Je,states:En,sentCloseFrameState:rN,sendHints:ai}=gt(),{kWebSocketURL:Ah,kReadyState:Jc,kController:eh,kBinaryType:ci,kResponse:th,kSentClose:nN,kByteParser:sN}=tn(),{isConnecting:iN,isEstablished:oN,isClosing:aN,isValidSubprotocol:cN,fireEvent:rh}=sn(),{establishWebSocketConnection:gN,closeWebSocketConnection:nh}=Uc(),{ByteParser:QN}=Zu(),{kEnumerableProperty:xA,isBlobLike:sh}=T(),{getGlobalDispatcher:EN}=Ds(),{types:ih}=d("node:util"),{ErrorEvent:BN,CloseEvent:IN}=ir(),{SendQueue:CN}=ju(),SA=class e extends EventTarget{#A={open:null,error:null,close:null,message:null};#e=0;#t="";#s="";#n;constructor(A,t=[]){super(),U.util.markAsUncloneable(this);let r="WebSocket constructor";U.argumentLengthCheck(arguments,1,r);let n=U.converters["DOMString or sequence<DOMString> or WebSocketInit"](t,r,"options");A=U.converters.USVString(A,r,"url"),t=n.protocols;let s=$u.settingsObject.baseUrl,i;try{i=new URL(A,s)}catch(a){throw new DOMException(a,"SyntaxError")}if(i.protocol==="http:"?i.protocol="ws:":i.protocol==="https:"&&(i.protocol="wss:"),i.protocol!=="ws:"&&i.protocol!=="wss:")throw new DOMException(`Expected a ws: or wss: protocol, got ${i.protocol}`,"SyntaxError");if(i.hash||i.href.endsWith("#"))throw new DOMException("Got fragment","SyntaxError");if(typeof t=="string"&&(t=[t]),t.length!==new Set(t.map(a=>a.toLowerCase())).size)throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(t.length>0&&!t.every(a=>cN(a)))throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");this[Ah]=new URL(i.href);let o=$u.settingsObject;this[eh]=gN(i,t,o,this,(a,c)=>this.#r(a,c),n),this[Jc]=e.CONNECTING,this[nN]=rN.NOT_SENT,this[ci]="blob"}close(A=void 0,t=void 0){U.brandCheck(this,e);let r="WebSocket.close";if(A!==void 0&&(A=U.converters["unsigned short"](A,r,"code",{clamp:!0})),t!==void 0&&(t=U.converters.USVString(t,r,"reason")),A!==void 0&&A!==1e3&&(A<3e3||A>4999))throw new DOMException("invalid code","InvalidAccessError");let n=0;if(t!==void 0&&(n=Buffer.byteLength(t),n>123))throw new DOMException(`Reason must be less than 123 bytes; received ${n}`,"SyntaxError");nh(this,A,t,n)}send(A){U.brandCheck(this,e);let t="WebSocket.send";if(U.argumentLengthCheck(arguments,1,t),A=U.converters.WebSocketSendData(A,t,"data"),iN(this))throw new DOMException("Sent before connected.","InvalidStateError");if(!(!oN(this)||aN(this)))if(typeof A=="string"){let r=Buffer.byteLength(A);this.#e+=r,this.#n.add(A,()=>{this.#e-=r},ai.string)}else ih.isArrayBuffer(A)?(this.#e+=A.byteLength,this.#n.add(A,()=>{this.#e-=A.byteLength},ai.arrayBuffer)):ArrayBuffer.isView(A)?(this.#e+=A.byteLength,this.#n.add(A,()=>{this.#e-=A.byteLength},ai.typedArray)):sh(A)&&(this.#e+=A.size,this.#n.add(A,()=>{this.#e-=A.size},ai.blob))}get readyState(){return U.brandCheck(this,e),this[Jc]}get bufferedAmount(){return U.brandCheck(this,e),this.#e}get url(){return U.brandCheck(this,e),tN(this[Ah])}get extensions(){return U.brandCheck(this,e),this.#s}get protocol(){return U.brandCheck(this,e),this.#t}get onopen(){return U.brandCheck(this,e),this.#A.open}set onopen(A){U.brandCheck(this,e),this.#A.open&&this.removeEventListener("open",this.#A.open),typeof A=="function"?(this.#A.open=A,this.addEventListener("open",A)):this.#A.open=null}get onerror(){return U.brandCheck(this,e),this.#A.error}set onerror(A){U.brandCheck(this,e),this.#A.error&&this.removeEventListener("error",this.#A.error),typeof A=="function"?(this.#A.error=A,this.addEventListener("error",A)):this.#A.error=null}get onclose(){return U.brandCheck(this,e),this.#A.close}set onclose(A){U.brandCheck(this,e),this.#A.close&&this.removeEventListener("close",this.#A.close),typeof A=="function"?(this.#A.close=A,this.addEventListener("close",A)):this.#A.close=null}get onmessage(){return U.brandCheck(this,e),this.#A.message}set onmessage(A){U.brandCheck(this,e),this.#A.message&&this.removeEventListener("message",this.#A.message),typeof A=="function"?(this.#A.message=A,this.addEventListener("message",A)):this.#A.message=null}get binaryType(){return U.brandCheck(this,e),this[ci]}set binaryType(A){U.brandCheck(this,e),A!=="blob"&&A!=="arraybuffer"?this[ci]="blob":this[ci]=A}#r(A,t){this[th]=A;let r=this[eh]?.dispatcher?.webSocketOptions,n=r?.maxFragments,s=r?.maxPayloadSize,i=new QN(this,t,{maxFragments:n,maxPayloadSize:s});i.on("drain",lN),i.on("error",uN.bind(this)),A.socket.ws=this,this[sN]=i,this.#n=new CN(A.socket),this[Jc]=En.OPEN;let o=A.headersList.get("sec-websocket-extensions");o!==null&&(this.#s=o);let a=A.headersList.get("sec-websocket-protocol");a!==null&&(this.#t=a),rh("open",this)}};SA.CONNECTING=SA.prototype.CONNECTING=En.CONNECTING;SA.OPEN=SA.prototype.OPEN=En.OPEN;SA.CLOSING=SA.prototype.CLOSING=En.CLOSING;SA.CLOSED=SA.prototype.CLOSED=En.CLOSED;Object.defineProperties(SA.prototype,{CONNECTING:Je,OPEN:Je,CLOSING:Je,CLOSED:Je,url:xA,readyState:xA,bufferedAmount:xA,onopen:xA,onerror:xA,onclose:xA,close:xA,onmessage:xA,binaryType:xA,send:xA,extensions:xA,protocol:xA,[Symbol.toStringTag]:{value:"WebSocket",writable:!1,enumerable:!1,configurable:!0}});Object.defineProperties(SA,{CONNECTING:Je,OPEN:Je,CLOSING:Je,CLOSED:Je});U.converters["sequence<DOMString>"]=U.sequenceConverter(U.converters.DOMString);U.converters["DOMString or sequence<DOMString>"]=function(e,A,t){return U.util.Type(e)==="Object"&&Symbol.iterator in e?U.converters["sequence<DOMString>"](e):U.converters.DOMString(e,A,t)};U.converters.WebSocketInit=U.dictionaryConverter([{key:"protocols",converter:U.converters["DOMString or sequence<DOMString>"],defaultValue:()=>new Array(0)},{key:"dispatcher",converter:U.converters.any,defaultValue:()=>EN()},{key:"headers",converter:U.nullableConverter(U.converters.HeadersInit)}]);U.converters["DOMString or sequence<DOMString> or WebSocketInit"]=function(e){return U.util.Type(e)==="Object"&&!(Symbol.iterator in e)?U.converters.WebSocketInit(e):{protocols:U.converters["DOMString or sequence<DOMString>"](e)}};U.converters.WebSocketSendData=function(e){if(U.util.Type(e)==="Object"){if(sh(e))return U.converters.Blob(e,{strict:!1});if(ArrayBuffer.isView(e)||ih.isArrayBuffer(e))return U.converters.BufferSource(e)}return U.converters.USVString(e)};function lN(){this.ws[th].socket.resume()}function uN(e){let A,t;e instanceof IN?(A=e.reason,t=e.code):A=e.message,rh("error",this,()=>new BN("error",{error:e,message:A})),nh(this,t)}oh.exports={WebSocket:SA}});var vc=f((JM,ch)=>{"use strict";function hN(e){return e.indexOf("\0")===-1}function dN(e){if(e.length===0)return!1;for(let A=0;A<e.length;A++)if(e.charCodeAt(A)<48||e.charCodeAt(A)>57)return!1;return!0}function fN(e){return new Promise(A=>{setTimeout(A,e).unref()})}ch.exports={isValidLastEventId:hN,isASCIINumber:dN,delay:fN}});var Bh=f((vM,Eh)=>{"use strict";var{Transform:wN}=d("node:stream"),{isASCIINumber:gh,isValidLastEventId:Qh}=vc(),fe=[239,187,191],Hc=10,gi=13,yN=58,pN=32,Vc=class extends wN{state=null;checkBOM=!0;crlfCheck=!1;eventEndCheck=!1;buffer=null;pos=0;event={data:void 0,event:void 0,id:void 0,retry:void 0};constructor(A={}){A.readableObjectMode=!0,super(A),this.state=A.eventSourceSettings||{},A.push&&(this.push=A.push)}_transform(A,t,r){if(A.length===0){r();return}if(this.buffer?this.buffer=Buffer.concat([this.buffer,A]):this.buffer=A,this.checkBOM)switch(this.buffer.length){case 1:if(this.buffer[0]===fe[0]){r();return}this.checkBOM=!1,r();return;case 2:if(this.buffer[0]===fe[0]&&this.buffer[1]===fe[1]){r();return}this.checkBOM=!1;break;case 3:if(this.buffer[0]===fe[0]&&this.buffer[1]===fe[1]&&this.buffer[2]===fe[2]){this.buffer=Buffer.alloc(0),this.checkBOM=!1,r();return}this.checkBOM=!1;break;default:this.buffer[0]===fe[0]&&this.buffer[1]===fe[1]&&this.buffer[2]===fe[2]&&(this.buffer=this.buffer.subarray(3)),this.checkBOM=!1;break}for(;this.pos<this.buffer.length;){if(this.eventEndCheck){if(this.crlfCheck){if(this.buffer[this.pos]===Hc){this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.crlfCheck=!1;continue}this.crlfCheck=!1}if(this.buffer[this.pos]===Hc||this.buffer[this.pos]===gi){this.buffer[this.pos]===gi&&(this.crlfCheck=!0),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,(this.event.data!==void 0||this.event.event||this.event.id||this.event.retry)&&this.processEvent(this.event),this.clearEvent();continue}this.eventEndCheck=!1;continue}if(this.buffer[this.pos]===Hc||this.buffer[this.pos]===gi){this.buffer[this.pos]===gi&&(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++}r()}parseLine(A,t){if(A.length===0)return;let r=A.indexOf(yN);if(r===0)return;let n="",s="";if(r!==-1){n=A.subarray(0,r).toString("utf8");let i=r+1;A[i]===pN&&++i,s=A.subarray(i).toString("utf8")}else n=A.toString("utf8"),s="";switch(n){case"data":t[n]===void 0?t[n]=s:t[n]+=`
|
|
45
45
|
${s}`;break;case"retry":gh(s)&&(t[n]=s);break;case"id":Qh(s)&&(t[n]=s);break;case"event":s.length>0&&(t[n]=s);break}}processEvent(A){A.retry&&gh(A.retry)&&(this.state.reconnectionTime=parseInt(A.retry,10)),A.id&&Qh(A.id)&&(this.state.lastEventId=A.id),A.data!==void 0&&this.push({type:A.event||"message",options:{data:A.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}};Eh.exports={EventSourceStream:Vc}});var wh=f((HM,fh)=>{"use strict";var{pipeline:DN}=d("node:stream"),{fetching:mN}=jr(),{makeRequest:kN}=Ar(),{webidl:we}=cA(),{EventSourceStream:FN}=Bh(),{parseMIMEType:RN}=lA(),{createFastMessageEvent:bN}=ir(),{isNetworkError:Ih}=Xr(),{delay:NN}=vc(),{kEnumerableProperty:Qt}=T(),{environmentSettingsObject:Ch}=yA(),lh=!1,uh=3e3,Bn=0,hh=1,In=2,SN="anonymous",UN="use-credentials",Qr=class e extends EventTarget{#A={open:null,error:null,message:null};#e=null;#t=!1;#s=Bn;#n=null;#r=null;#i;#o;constructor(A,t={}){super(),we.util.markAsUncloneable(this);let r="EventSource constructor";we.argumentLengthCheck(arguments,1,r),lh||(lh=!0,process.emitWarning("EventSource is experimental, expect them to change at any time.",{code:"UNDICI-ES"})),A=we.converters.USVString(A,r,"url"),t=we.converters.EventSourceInitDict(t,r,"eventSourceInitDict"),this.#i=t.dispatcher,this.#o={lastEventId:"",reconnectionTime:uh};let n=Ch,s;try{s=new URL(A,n.settingsObject.baseUrl),this.#o.origin=s.origin}catch(a){throw new DOMException(a,"SyntaxError")}this.#e=s.href;let i=SN;t.withCredentials&&(i=UN,this.#t=!0);let o={redirect:"follow",keepalive:!0,mode:"cors",credentials:i==="anonymous"?"same-origin":"omit",referrer:"no-referrer"};o.client=Ch.settingsObject,o.headersList=[["accept",{name:"accept",value:"text/event-stream"}]],o.cache="no-store",o.initiator="other",o.urlList=[new URL(this.#e)],this.#n=kN(o),this.#c()}get readyState(){return this.#s}get url(){return this.#e}get withCredentials(){return this.#t}#c(){if(this.#s===In)return;this.#s=Bn;let A={request:this.#n,dispatcher:this.#i},t=r=>{Ih(r)&&(this.dispatchEvent(new Event("error")),this.close()),this.#a()};A.processResponseEndOfBody=t,A.processResponse=r=>{if(Ih(r))if(r.aborted){this.close(),this.dispatchEvent(new Event("error"));return}else{this.#a();return}let n=r.headersList.get("content-type",!0),s=n!==null?RN(n):"failure",i=s!=="failure"&&s.essence==="text/event-stream";if(r.status!==200||i===!1){this.close(),this.dispatchEvent(new Event("error"));return}this.#s=hh,this.dispatchEvent(new Event("open")),this.#o.origin=r.urlList[r.urlList.length-1].origin;let o=new FN({eventSourceSettings:this.#o,push:a=>{this.dispatchEvent(bN(a.type,a.options))}});DN(r.body.stream,o,a=>{a?.aborted===!1&&(this.close(),this.dispatchEvent(new Event("error")))})},this.#r=mN(A)}async#a(){this.#s!==In&&(this.#s=Bn,this.dispatchEvent(new Event("error")),await NN(this.#o.reconnectionTime),this.#s===Bn&&(this.#o.lastEventId.length&&this.#n.headersList.set("last-event-id",this.#o.lastEventId,!0),this.#c()))}close(){we.brandCheck(this,e),this.#s!==In&&(this.#s=In,this.#r.abort(),this.#n=null)}get onopen(){return this.#A.open}set onopen(A){this.#A.open&&this.removeEventListener("open",this.#A.open),typeof A=="function"?(this.#A.open=A,this.addEventListener("open",A)):this.#A.open=null}get onmessage(){return this.#A.message}set onmessage(A){this.#A.message&&this.removeEventListener("message",this.#A.message),typeof A=="function"?(this.#A.message=A,this.addEventListener("message",A)):this.#A.message=null}get onerror(){return this.#A.error}set onerror(A){this.#A.error&&this.removeEventListener("error",this.#A.error),typeof A=="function"?(this.#A.error=A,this.addEventListener("error",A)):this.#A.error=null}},dh={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:Bn,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:hh,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:In,writable:!1}};Object.defineProperties(Qr,dh);Object.defineProperties(Qr.prototype,dh);Object.defineProperties(Qr.prototype,{close:Qt,onerror:Qt,onmessage:Qt,onopen:Qt,readyState:Qt,url:Qt,withCredentials:Qt});we.converters.EventSourceInitDict=we.dictionaryConverter([{key:"withCredentials",converter:we.converters.boolean,defaultValue:()=>!1},{key:"dispatcher",converter:we.converters.any}]);fh.exports={EventSource:Qr,defaultReconnectionTime:uh}});var mh=f((VM,S)=>{"use strict";var MN=Gt(),yh=ur(),LN=Jt(),TN=dB(),YN=vt(),xN=ca(),GN=qB(),JN=XB(),ph=v(),Ei=T(),{InvalidArgumentError:Qi}=ph,Er=YI(),vN=dr(),HN=Wa(),VN=hC(),qN=Za(),WN=Sa(),ON=Is(),{getGlobalDispatcher:Dh,setGlobalDispatcher:PN}=Ds(),ZN=ms(),KN=rs(),zN=ns();Object.assign(yh.prototype,Er);S.exports.Dispatcher=yh;S.exports.Client=MN;S.exports.Pool=LN;S.exports.BalancedPool=TN;S.exports.Agent=YN;S.exports.ProxyAgent=xN;S.exports.EnvHttpProxyAgent=GN;S.exports.RetryAgent=JN;S.exports.RetryHandler=ON;S.exports.DecoratorHandler=ZN;S.exports.RedirectHandler=KN;S.exports.createRedirectInterceptor=zN;S.exports.interceptors={redirect:mC(),retry:FC(),dump:bC(),dns:UC()};S.exports.buildConnector=vN;S.exports.errors=ph;S.exports.util={parseHeaders:Ei.parseHeaders,headerNameToString:Ei.headerNameToString};function Cn(e){return(A,t,r)=>{if(typeof t=="function"&&(r=t,t=null),!A||typeof A!="string"&&typeof A!="object"&&!(A instanceof URL))throw new Qi("invalid url");if(t!=null&&typeof t!="object")throw new Qi("invalid opts");if(t&&t.path!=null){if(typeof t.path!="string")throw new Qi("invalid opts.path");let i=t.path;t.path.startsWith("/")||(i=`/${i}`),A=new URL(Ei.parseOrigin(A).origin+i)}else t||(t=typeof A=="object"?A:{}),A=Ei.parseURL(A);let{agent:n,dispatcher:s=Dh()}=t;if(n)throw new Qi("unsupported opts.agent. Did you mean opts.client?");return e.call(s,{...t,origin:A.origin,path:A.search?`${A.pathname}${A.search}`:A.pathname,method:t.method||(t.body?"PUT":"GET")},r)}}S.exports.setGlobalDispatcher=PN;S.exports.getGlobalDispatcher=Dh;var XN=jr().fetch;S.exports.fetch=async function(A,t=void 0){try{return await XN(A,t)}catch(r){throw r&&typeof r=="object"&&Error.captureStackTrace(r),r}};S.exports.Headers=nt().Headers;S.exports.Response=Xr().Response;S.exports.Request=Ar().Request;S.exports.FormData=kr().FormData;S.exports.File=globalThis.File??d("node:buffer").File;S.exports.FileReader=Kl().FileReader;var{setGlobalOrigin:_N,getGlobalOrigin:jN}=co();S.exports.setGlobalOrigin=_N;S.exports.getGlobalOrigin=jN;var{CacheStorage:$N}=ru(),{kConstruct:AS}=Ps();S.exports.caches=new $N(AS);var{deleteCookie:eS,getCookies:tS,getSetCookies:rS,setCookie:nS}=Iu();S.exports.deleteCookie=eS;S.exports.getCookies=tS;S.exports.getSetCookies=rS;S.exports.setCookie=nS;var{parseMIMEType:sS,serializeAMimeType:iS}=lA();S.exports.parseMIMEType=sS;S.exports.serializeAMimeType=iS;var{CloseEvent:oS,ErrorEvent:aS,MessageEvent:cS}=ir();S.exports.WebSocket=ah().WebSocket;S.exports.CloseEvent=oS;S.exports.ErrorEvent=aS;S.exports.MessageEvent=cS;S.exports.request=Cn(Er.request);S.exports.stream=Cn(Er.stream);S.exports.pipeline=Cn(Er.pipeline);S.exports.connect=Cn(Er.connect);S.exports.upgrade=Cn(Er.upgrade);S.exports.MockClient=HN;S.exports.MockPool=qN;S.exports.MockAgent=VN;S.exports.mockErrors=WN;var{EventSource:gS}=wh();S.exports.EventSource=gS});var Ir=Object.freeze(["blockNumber","nativeBalance","tokenBalance","resolveToken","resolvePools","scanBlocks","scoreRisk","quote","sellSimulation","prepareUnsignedTx"]),G=Object.freeze({LIVE:"LIVE",CACHED:"CACHED",STALE:"STALE",UNKNOWN:"UNKNOWN",UNAVAILABLE:"UNAVAILABLE"}),L=Object.freeze({PASS:"PASS",CAUTION:"CAUTION",FAIL:"FAIL",UNKNOWN:"UNKNOWN"}),ed=/^0x[0-9a-fA-F]{40}$/;function td(e={}){let A=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:["definition must be an object"],warnings:t};if((!Number.isInteger(e.chainId)||e.chainId<=0)&&A.push("chainId must be a positive integer"),(typeof e.key!="string"||!/^[a-z][a-z0-9-]*$/.test(e.key||""))&&A.push('key must be a lowercase slug (e.g. "base")'),(typeof e.name!="string"||!e.name.trim())&&A.push("name is required"),!Array.isArray(e.rpcEnv)||e.rpcEnv.length===0)A.push("rpcEnv must list at least one environment variable name");else for(let n of e.rpcEnv)(typeof n!="string"||!/^[A-Z][A-Z0-9_]*$/.test(n))&&A.push(`rpcEnv entry "${n}" should be an UPPER_SNAKE env var name`);if(e.nativeCurrency){let n=e.nativeCurrency;(typeof n.symbol!="string"||!n.symbol)&&A.push("nativeCurrency.symbol is required when nativeCurrency is set"),Number.isInteger(n.decimals)||A.push("nativeCurrency.decimals must be an integer")}for(let[n,s]of(e.venues||[]).entries()){let i=`venues[${n}]`;if(!s||typeof s!="object"){A.push(`${i} must be an object`);continue}ed.test(s.address||"")||A.push(`${i}.address is not a valid 20-byte address`),/^0x0{40}$/.test(s.address||"")&&A.push(`${i}.address is the zero address -- placeholder left in place?`),s.kind||A.push(`${i}.kind is required (router|quoter|factory|...)`),s.verified?(s.verified.method||A.push(`${i}.verified.method is required`),s.verified.source||A.push(`${i}.verified.source is required`),s.verified.date||t.push(`${i}.verified.date missing -- add one so staleness is visible`)):A.push(`${i} must record verification: { verified: { method, source, date } }. An unverified venue stays blocked.`)}let r=e.capabilities||{};for(let n of Object.keys(r))Ir.includes(n)?typeof r[n]!="function"&&A.push(`capability "${n}" must be a function`):A.push(`unknown capability "${n}"`);return Object.keys(r).length===0&&t.push("scanner implements no capabilities -- it can only be registered, not used"),r.prepareUnsignedTx&&!r.quote&&t.push("prepareUnsignedTx without quote: no priced expectation to validate the built tx against"),r.prepareUnsignedTx&&!r.sellSimulation&&t.push("prepareUnsignedTx without sellSimulation: cannot prove an asset is exitable before buying"),{ok:A.length===0,errors:A,warnings:t}}function rd(e){let{ok:A,errors:t,warnings:r}=td(e);if(!A)throw new Error(`invalid scanner for ${e?.key??"<unknown>"}:
|
|
46
46
|
- ${t.join(`
|
|
47
|
-
- `)}`);let n=e.capabilities||{},s=Ir.filter(o=>typeof n[o]=="function"),i={key:e.key,chainId:e.chainId,name:e.name,rpcEnv:[...e.rpcEnv],nativeCurrency:e.nativeCurrency?{...e.nativeCurrency}:null,explorer:e.explorer||null,venues:(e.venues||[]).map(o=>({...o})),warnings:r,capabilities(){return{chainId:e.chainId,key:e.key,supported:[...s],unsupported:Ir.filter(o=>!s.includes(o))}},supports(o){return s.includes(o)}};for(let o of Ir)s.includes(o)?i[o]=async(...a)=>n[o](...a,{scanner:i}):i[o]=async()=>{throw new Error(`${e.key} (chain ${e.chainId}) does not implement "${o}". Supported: ${s.join(", ")||"none"}. An unimplemented capability is absent, not assumed -- implement it or treat this chain as fail-closed for that operation.`)};return Object.freeze(i)}var lt=new Map;function ui(e){let A=rd(e);return lt.set(A.chainId,A),A}function WS(e){return lt.get(Number(e))||null}function OS(){return[...lt.values()]}function PS(){lt.clear()}function ZS(){let e={};for(let A of lt.values())e[A.chainId]={key:A.key,name:A.name,...A.capabilities(),venueCount:A.venues.length,failClosed:A.venues.length===0};return{generatedAt:new Date().toISOString(),chainCount:lt.size,capabilities:[...Ir],chains:e}}import{createHash as IS}from"node:crypto";import Br from"node:net";import QS from"node:dns";var ES=new Set(["localhost","metadata.google.internal","metadata.goog"]);function Bi(e){let A=String(e).toLowerCase().split("%")[0];if((A.match(/::/g)||[]).length>1)return null;let t=g=>{if(!g)return[];let Q=g.split(":"),E=Q.at(-1);if(E?.includes(".")){let B=E.split(".").map(Number);if(B.length!==4||B.some(I=>!Number.isInteger(I)||I<0||I>255))return null;Q.splice(Q.length-1,1,(B[0]<<8|B[1]).toString(16),(B[2]<<8|B[3]).toString(16))}return Q.some(B=>!/^[0-9a-f]{1,4}$/.test(B))?null:Q.map(B=>Number.parseInt(B,16))},[r,n]=A.split("::"),s=t(r),i=t(n);if(!s||!i)return null;let o=A.includes("::"),a=8-s.length-i.length;if(!o&&a!==0||o&&a<1)return null;let c=[...s,...Array(Math.max(0,a)).fill(0),...i];return c.length!==8?null:Uint8Array.from(c.flatMap(g=>[g>>8,g&255]))}function qc(e,A,t){let r=Math.floor(t/8),n=t%8;for(let i=0;i<r;i+=1)if(e[i]!==A[i])return!1;if(!n)return!0;let s=255<<8-n;return(e[r]&s)===(A[r]&s)}function Wc(e){if(Br.isIPv4(e)){let A=e.split(".").map(Number);return!(A[0]===0||A[0]===10||A[0]===127||A[0]>=224||A[0]===100&&A[1]>=64&&A[1]<=127||A[0]===169&&A[1]===254||A[0]===172&&A[1]>=16&&A[1]<=31||A[0]===192&&(A[1]===0||A[1]===2||A[1]===168)||A[0]===192&&A[1]===88&&A[2]===99||A[0]===198&&(A[1]===18||A[1]===19||A[1]===51)||A[0]===203&&A[1]===0&&A[2]===113)}if(Br.isIPv6(e)){let A=Bi(e);if(!A)return!1;let t=Bi("::ffff:0:0");return qc(A,t,96)?Wc([...A.slice(12)].join(".")):qc(A,Bi("2000::"),3)?![["2001::",23],["2001:db8::",32],["2001:10::",28],["2001:2::",48],["2002::",16],["3fff::",20]].some(([n,s])=>qc(A,Bi(n),s)):!1}return!1}function BS(e){let A;try{A=new URL(String(e))}catch{return{ok:!1,error:`not a valid URL: ${String(e).slice(0,120)}`}}if(A.protocol!=="http:"&&A.protocol!=="https:")return{ok:!1,error:`refused protocol ${A.protocol} (only http/https)`};let t=A.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,"");if(ES.has(t)||t.endsWith(".localhost")||t.endsWith(".internal"))return{ok:!1,error:`refused internal host ${t}`};let r=Br.isIP(t);return r!==0&&!Wc(t)?{ok:!1,error:`refused private address ${t}`}:{ok:!0,url:A,host:t,isLiteralIp:r!==0}}async function kh(e,{lookupFn:A=QS.promises.lookup}={}){let t=BS(e);if(!t.ok)return t;if(t.isLiteralIp)return{ok:!0,url:t.url};let r;try{r=await A(t.host,{all:!0,verbatim:!0})}catch{return{ok:!1,error:`refused: ${t.host} did not resolve`}}return!Array.isArray(r)||r.length===0||r.some(n=>!Wc(n.address))?{ok:!1,error:`refused: ${t.host} resolves to a non-public address`}:{ok:!0,url:t.url,addresses:r}}async function Fh(){let e,A;try{let o=await Promise.resolve().then(()=>Ad(mh(),1));e=o.Agent,A=o.fetch}catch{return null}if(typeof e!="function"||typeof A!="function")return null;let t=o=>String(o).toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,""),r=new Map,n=o=>(Array.isArray(o)?o:[o]).map(a=>typeof a=="string"?{address:a}:a).filter(a=>a&&a.address).map(a=>({address:a.address,family:a.family||(Br.isIPv6(a.address)?6:4)})),s=o=>{let a=t(o);if(Br.isIP(a))return[{address:a,family:Br.isIPv6(a)?6:4}];let c=r.get(a);if(!c||!c.length)throw new Error(`refused: unpinned host ${o} during pinned fetch`);return c},i=new e({connect:{lookup(o,a,c){let g;try{g=s(o)}catch(Q){return c(Q)}return a?.all?c(null,g):c(null,g[0].address,g[0].family)}}});return{dispatcher:i,fetch:(o,a={})=>A(o,{...a,dispatcher:i}),pin(o,a,c){r.set(t(o),n(typeof a=="string"?[{address:a,family:c}]:a))},resolve:s,async close(){try{await i.destroy()}catch{}}}}var CS=new Set([408,425,429,500,502,503,504]),Rh=new Set(["GET","HEAD","OPTIONS","PUT","DELETE"]),lS=2,bh=4e3,Sh=["authorization","x-api-key","x-tensor-api-key","0x-api-key","api-key","cookie","proxy-authorization"],uS=new Set([301,302,303,307,308]),Nh=3;function hS(e){let A=String(e||"").toLowerCase();return Sh.includes(A)||/(^|-)(api[-_]?key|key|token|secret|auth|authorization|session|cookie|signature|access)(-|$)/.test(A)}function dS(e){let A={};for(let[t,r]of Object.entries(e||{}))hS(t)||(A[t]=r);return A}function fS(e,A){if(!e)throw new Error(`HTTP redirect from ${A} missing Location`);let t=new URL(String(e),String(A));if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error(`HTTP redirect from ${A} used unsupported protocol ${t.protocol}`);return t.toString()}function wS(e,A){return new URL(String(e)).origin===new URL(String(A)).origin}var Oc=new Map;function yS(e,A,t){let r={};for(let[a,c]of Object.entries(t||{}))r[a.toLowerCase()]=c;let n=Object.keys(r).filter(a=>/(^|-)(api[-_]?key|key|token|secret|auth|authorization|session|cookie|signature|access)(-|$)/.test(a)),i=[...new Set([...Sh,...n])].sort().map(a=>`${a}=${r[a]??""}`).join(`
|
|
48
|
-
`),o=IS("sha256").update(i).digest("hex").slice(0,32);return`${e} ${A} ${o}`}function pS(e,A){let t=Number(A);return Number.isFinite(t)&&t>0?Math.min(t*1e3,bh):Math.min(250*2**e,bh)+Math.floor(Math.random()*100)}var DS=e=>new Promise(A=>setTimeout(A,e));async function mS(e,{fetchImpl:A,method:t,headers:r,body:n,timeoutMs:s,lookupFn:i,realFetch:o}){let a=new AbortController,c=setTimeout(()=>a.abort(),s),g=null,Q=A;try{let E=String(e),B={...r||{}};for(let I=0;I<=Nh;I+=1){let l=await Q(E,{method:t,headers:B,body:n,signal:a.signal,redirect:"manual"}),u=await l.text(),C=null;if(u)try{C=JSON.parse(u)}catch{C=null}if(uS.has(l.status)){if(t!=="GET"&&t!=="HEAD"){let p=new Error(`HTTP ${l.status} ${t} ${E} redirected non-idempotent request`);throw p.status=l.status,p.body=C??u.slice(0,300),p}if(I===Nh)throw new Error(`HTTP redirect loop for ${e}`);let h=fS(l.headers?.get?.("location"),E);if(!wS(h,E)){let p=await kh(h,i?{lookupFn:i}:{});if(!p.ok){let H=new Error(`HTTP redirect from ${E} ${p.error}`);throw H.status=l.status,H}B=dS(B),o&&p.addresses?.length&&(g||(g=await Fh()),g&&(g.pin(new URL(h).hostname,p.addresses[0].address,p.addresses[0].family),Q=g.fetch))}E=h;continue}if(!l.ok){let h=new Error(`HTTP ${l.status} ${t} ${E}`);throw h.status=l.status,h.retryAfter=l.headers?.get?.("retry-after")??null,h.body=C??u.slice(0,300),h}return C??u}throw new Error(`HTTP redirect loop for ${e}`)}finally{clearTimeout(c),g&&await g.close()}}async function Ii(e,A={}){let t=A.fetchImpl||globalThis.fetch;if(typeof t!="function")throw new Error("fetch unavailable \u2014 pass opts.fetchImpl");let r=A.timeoutMs??12e3,n=(A.method||"GET").toUpperCase(),s={Accept:"application/json",...A.headers||{}},i=A.body;i!=null&&typeof i!="string"&&(s["Content-Type"]=s["Content-Type"]||"application/json",i=JSON.stringify(i));let o=Number.isInteger(A.retries)?Math.max(A.retries,0):lS,a=A.lookupFn,c=!A.fetchImpl,g=async()=>{let l;for(let u=0;u<=o;u++)try{return await mS(e,{fetchImpl:t,method:n,headers:s,body:i,timeoutMs:r,lookupFn:a,realFetch:c})}catch(C){l=C;let h=C?.status,D=C?.name==="AbortError",p=new Set([408,425,429]),H=h!=null?p.has(h)||CS.has(h)&&Rh.has(n):!D&&Rh.has(n);if(u===o||!H)throw C;await DS(pS(u,C?.retryAfter))}throw l};if(!(A.dedupe!==!1&&n==="GET"&&i==null))return g();let E=yS(n,e,s),B=Oc.get(E);if(B)return B;let I=g().finally(()=>Oc.delete(E));return Oc.set(E,I),I}var Uh={robinhood:{chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC"],evm:!0},ethereum:{chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],evm:!0},polygon:{chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],evm:!0},arbitrum:{chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],evm:!0},base:{chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],evm:!0},hyperevm:{chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],evm:!0},bsc:{chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],evm:!0},avalanche:{chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],evm:!0},optimism:{chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],evm:!0},abstract:{chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],evm:!0},stable:{chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],evm:!0}},kS=new Map(Object.values(Uh).map(e=>[e.chainId,e]));function Mh(e){return kS.get(Number(e))||null}function Lh(e,A=process.env){let t=Mh(e);if(!t)return null;for(let r of t.rpcEnv){let n=(A[r]||"").trim();if(n)return n}return null}import{Interface as FS,getAddress as RS}from"ethers";var Th=new FS(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);function Yh(e,A){try{return RS(e).toLowerCase()}catch{throw new Error(`${A} must be a valid EVM address`)}}var bS={1:"https://ethereum.publicnode.com",137:"https://polygon-bor-rpc.publicnode.com",42161:"https://arbitrum-one-rpc.publicnode.com",8453:"https://base-rpc.publicnode.com",10:"https://optimism-rpc.publicnode.com",988:"https://rpc.stable.xyz",56:"https://bsc-rpc.publicnode.com",43114:"https://avalanche-c-chain-rpc.publicnode.com",999:"https://rpc.hyperliquid.xyz/evm",2741:"https://api.mainnet.abs.xyz",4663:"https://rpc.mainnet.chain.robinhood.com"};function NS(e,{rpcUrl:A,env:t=process.env}={}){if(A)return A;let r=Lh(e,t);return r||bS[Number(e)]||null}var SS=/^(?:eth_(?:call|blocknumber|chainid|get[a-z0-9]+|feehistory|gasprice|maxpriorityfeepergas|syncing|protocolversion|estimategas|createaccesslist)|net_(?:version|listening|peercount)|web3_(?:clientversion|sha3))$/;function US(e){let A=String(e||""),t=A.toLowerCase();if(A!==A.trim()||!/^[a-zA-Z0-9_]+$/.test(A)||!SS.test(t))throw new Error(`evm-rpc: ${A} refused \u2014 @oracle-agent/oracle is prepare-only (read RPC only; no broadcast/sign)`);return t}async function ie(e,A,t=[],r={}){let n=String(A||"");US(n);let s=NS(e,r);if(!s)throw new Error(`No RPC URL for chainId ${e} (set env from chain registry rpcEnv or pass rpcUrl)`);let o=await Ii(s,{method:"POST",body:{jsonrpc:"2.0",id:1,method:A,params:t},fetchImpl:r.fetchImpl,timeoutMs:r.timeoutMs??12e3});if(o?.error){let a=new Error(o.error.message||JSON.stringify(o.error));throw a.code=o.error.code,a}return o.result}async function xh(e,A={}){let t=await ie(e,"eth_blockNumber",[],A);return parseInt(t,16)}async function Gh(e,A,t={}){if(!A)throw new Error("rpcGetBalance requires address");let r=await ie(e,"eth_getBalance",[A,"latest"],t);return{chainId:Number(e),address:A,balanceWei:BigInt(r).toString(),balanceHex:r}}async function Jh(e={},A={}){let t=Number(e.chainId??A.chainId??1),r=Yh(e.token||e.tokenAddress,"token"),n=Yh(e.account||e.owner||e.address,"account"),s=Th.encodeFunctionData("balanceOf",[n]),i=await ie(t,"eth_call",[{to:r,data:s},e.blockTag||"latest"],A),o=Th.decodeFunctionResult("balanceOf",i),a=BigInt(o[0]);return{chainId:t,token:r,account:n,balance:a.toString(),balanceHex:`0x${a.toString(16)}`,blockTag:e.blockTag||"latest"}}var MS="https://api.dexscreener.com",tL=Object.freeze({1:"ethereum",10:"optimism",56:"bsc",137:"polygon",8453:"base",42161:"arbitrum",43114:"avalanche",999:"hyperevm",4663:"robinhood"});function LS(e={}){return(e.baseUrl||process.env.DEXSCREENER_API_URL||MS).replace(/\/$/,"")}async function vh(e,A={}){if(!e)throw new Error("tokenAddress required");return Ii(`${LS(A)}/latest/dex/tokens/${e}`,{fetchImpl:A.fetchImpl,timeoutMs:A.timeoutMs??12e3})}var Zc={getAmountsOut:"d06ca61f",swapExactTokensForTokens:"38ed1739",swapExactETHForTokens:"7ff36ab5"},GA=e=>BigInt(e).toString(16).padStart(64,"0"),ln=e=>e.slice(2).toLowerCase().padStart(64,"0");function TS(e,A){return`0x${Zc.getAmountsOut}`+GA(e)+GA(64)+GA(A.length)+A.map(ln).join("")}function YS(e){if(!e||e==="0x")return null;let A=e.slice(2);if(A.length<128)return null;let t=Number(BigInt(`0x${A.slice(64,128)}`));if(!Number.isFinite(t)||t<1||t>16)return null;let r=[];for(let n=0;n<t;n++){let s=128+n*64;if(A.length<s+64)return null;r.push(BigInt(`0x${A.slice(s,s+64)}`))}return r}function Pc(e,A="router"){return(e?.venues||[]).find(r=>r.kind===A)?.address??null}var Kc=100;function xS(e,A){let t=Number(A);if(!Number.isFinite(t)||t<0)throw new Error("slippageBps must be a non-negative number");if(t>Kc)throw new Error(`slippageBps ${t} exceeds the ${Kc} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(e)*BigInt(1e4-Math.floor(t))/10000n}function Hh(e){let{chainId:A,wrappedNative:t}=e;async function r(n,s,i,o){let a=await ie(A,"eth_call",[{to:n,data:TS(s,i)},"latest"],o);return YS(a?.result??a)}return{async quote({tokenIn:n,tokenOut:s,amountIn:i,path:o},a={}){let c=Pc(a.scanner);if(!c)return{chainId:A,evidence:G.UNAVAILABLE,reason:"no verified router configured for this chain; quoting stays fail-closed rather than guessing a venue address"};let g=o||[n,s];if(g.some(E=>!/^0x[0-9a-fA-F]{40}$/.test(E||"")))throw new Error("quote requires valid 20-byte addresses");let Q=await r(c,i,g,a);return Q?{chainId:A,router:c,path:g,amountIn:String(i),amountOut:Q[Q.length-1].toString(),hops:g.length-1,evidence:G.LIVE,note:"exact-input quote at current reserves; not a guaranteed fill"}:{chainId:A,router:c,path:g,evidence:G.UNKNOWN,reason:"router returned no amounts -- no pool for this path, or the call reverted"}},async sellSimulation({token:n,amountIn:s,base:i},o={}){let a=Pc(o.scanner),c=i||t;if(c&&String(n).toLowerCase()===String(c).toLowerCase())return{chainId:A,token:n,verdict:L.UNKNOWN,evidence:G.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};if(!a||!c)return{chainId:A,token:n,verdict:L.UNKNOWN,evidence:G.UNAVAILABLE,reason:a?"no wrappedNative configured for this chain, so no base asset to round-trip against":"no verified router configured for this chain"};let g=await r(a,s,[c,n],o);if(!g)return{chainId:A,token:n,verdict:L.FAIL,evidence:G.LIVE,leg:"buy",reason:"buy leg returned no amounts -- no route in"};let Q=g[g.length-1];if(Q===0n)return{chainId:A,token:n,verdict:L.FAIL,evidence:G.LIVE,leg:"buy",reason:"buy leg quotes zero output"};let E=await r(a,Q,[n,c],o);if(!E)return{chainId:A,token:n,verdict:L.FAIL,evidence:G.LIVE,leg:"sell",bought:Q.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let B=E[E.length-1],I=Number(B*10000n/BigInt(s)),l=L.PASS,u="round trip completes with expected fee/impact loss";return I<5e3?(l=L.FAIL,u=`round trip returns only ${(I/100).toFixed(2)}% -- punitive tax or no real liquidity`):I<9e3&&(l=L.CAUTION,u=`round trip returns ${(I/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:A,token:n,base:c,router:a,verdict:l,reason:u,amountIn:String(s),bought:Q.toString(),returned:B.toString(),retentionBps:I,evidence:G.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:n,tokenOut:s,amountIn:i,recipient:o,slippageBps:a=50,deadlineSeconds:c=900,path:g},Q={}){let E=Q.scanner,B=Pc(E);if(!B)throw new Error(`chain ${A} has no verified router; preparing a swap stays fail-closed. Add a venue with recorded provenance first (see docs/adding-a-chain.md).`);if(!/^0x[0-9a-fA-F]{40}$/.test(o||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let I=g||[n,s],l=await this.quote({tokenIn:n,tokenOut:s,amountIn:i,path:I},Q);if(l.evidence!==G.LIVE)throw new Error(`cannot prepare without a live quote (${l.evidence}: ${l.reason??"no reason given"})`);let u=xS(l.amountOut,a);if(u<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let C=BigInt(Math.floor(Date.now()/1e3)+Number(c)),h=t&&I[0].toLowerCase()===t.toLowerCase()&&Q.useNative,D=h?`0x${Zc.swapExactETHForTokens}`+GA(u)+GA(128)+ln(o)+GA(C)+GA(I.length)+I.map(ln).join(""):`0x${Zc.swapExactTokensForTokens}`+GA(i)+GA(u)+GA(160)+ln(o)+GA(C)+GA(I.length)+I.map(ln).join("");return{unsigned:!0,signedBy:"user-wallet",chainId:A,tx:{to:B,data:D,value:h?`0x${BigInt(i).toString(16)}`:"0x0"},guard:{quotedOut:l.amountOut,minOut:u.toString(),slippageBps:a,maxSlippageBps:Kc,deadline:C.toString()},requires:h?[]:[{step:"approve",token:I[0],spender:B,amount:String(i)}],note:"UNSIGNED. Re-verify the guard against a fresh quote immediately before signing -- a quote-time minimum is not a minimum at broadcast time."}}}}var GS=[100,500,3e3,1e4],Vh={quoteExactInputSingle:"c6a5026a",exactInputSingle:"04e45aaf"},Et=e=>BigInt(e).toString(16).padStart(64,"0"),un=e=>e.slice(2).toLowerCase().padStart(64,"0"),qh=/^0x[0-9a-fA-F]{40}$/,Xc=100;function JS(e,A){let t=Number(A);if(!Number.isFinite(t)||t<0)throw new Error("slippageBps must be a non-negative number");if(t>Xc)throw new Error(`slippageBps ${t} exceeds the ${Xc} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(e)*BigInt(1e4-Math.floor(t))/10000n}function zc(e,A){return(e?.venues||[]).find(t=>t.kind===A)?.address??null}function Wh(e){let{chainId:A,wrappedNative:t}=e;async function r({quoter:s,tokenIn:i,tokenOut:o,amountIn:a,fee:c},g){let Q=`0x${Vh.quoteExactInputSingle}`+un(i)+un(o)+Et(a)+Et(c)+Et(0),E=await ie(A,"eth_call",[{to:s,data:Q},"latest"],g).catch(()=>null),B=E?.result??E;if(!B||B==="0x"||B.length<66)return null;let I=BigInt(`0x${B.slice(2,66)}`);return I>0n?I:null}async function n({quoter:s,tokenIn:i,tokenOut:o,amountIn:a},c){let g=[],Q=null;for(let E of GS){let B=await r({quoter:s,tokenIn:i,tokenOut:o,amountIn:a,fee:E},c);g.push({fee:E,amountOut:B?B.toString():null}),B&&(!Q||B>Q.amountOut)&&(Q={fee:E,amountOut:B})}return{best:Q,tried:g}}return{async quote({tokenIn:s,tokenOut:i,amountIn:o},a={}){let c=zc(a.scanner,"quoter");if(!c)return{chainId:A,evidence:G.UNAVAILABLE,reason:"no verified quoter configured for this chain; quoting stays fail-closed rather than guessing a venue address"};for(let E of[s,i])if(!qh.test(E||""))throw new Error("quote requires valid 20-byte addresses");let{best:g,tried:Q}=await n({quoter:c,tokenIn:s,tokenOut:i,amountIn:o},a);return g?{chainId:A,venue:"uniswap-v3",quoter:c,tokenIn:s,tokenOut:i,amountIn:String(o),amountOut:g.amountOut.toString(),fee:g.fee,triedFeeTiers:Q,evidence:G.LIVE,note:"exact-input single-hop quote at current tick; not a guaranteed fill"}:{chainId:A,quoter:c,tokenIn:s,tokenOut:i,triedFeeTiers:Q,evidence:G.UNKNOWN,reason:"no fee tier returned a quote -- no V3 pool for this pair, or no liquidity"}},async sellSimulation({token:s,amountIn:i,base:o},a={}){let c=zc(a.scanner,"quoter"),g=o||t;if(g&&String(s).toLowerCase()===String(g).toLowerCase())return{chainId:A,token:s,verdict:L.UNKNOWN,evidence:G.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};if(!c||!g)return{chainId:A,token:s,verdict:L.UNKNOWN,evidence:G.UNAVAILABLE,reason:c?"no wrappedNative configured, so there is no base asset to round-trip against":"no verified quoter configured for this chain"};let Q=await n({quoter:c,tokenIn:g,tokenOut:s,amountIn:i},a);if(!Q.best)return{chainId:A,token:s,verdict:L.FAIL,evidence:G.LIVE,leg:"buy",reason:"no V3 pool priced the buy leg on any fee tier"};let E=await n({quoter:c,tokenIn:s,tokenOut:g,amountIn:Q.best.amountOut},a);if(!E.best)return{chainId:A,token:s,verdict:L.FAIL,evidence:G.LIVE,leg:"sell",bought:Q.best.amountOut.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let B=E.best.amountOut,I=Number(B*10000n/BigInt(i)),l=L.PASS,u="round trip completes with expected fee/impact loss";return I<5e3?(l=L.FAIL,u=`round trip returns only ${(I/100).toFixed(2)}% -- punitive tax or no real liquidity`):I<9e3&&(l=L.CAUTION,u=`round trip returns ${(I/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:A,venue:"uniswap-v3",token:s,base:g,verdict:l,reason:u,amountIn:String(i),bought:Q.best.amountOut.toString(),returned:B.toString(),retentionBps:I,buyFee:Q.best.fee,sellFee:E.best.fee,evidence:G.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:s,tokenOut:i,amountIn:o,recipient:a,slippageBps:c=50,fee:g},Q={}){let E=zc(Q.scanner,"router");if(!E)throw new Error(`chain ${A} has no verified V3 router; preparing a swap stays fail-closed. Add a venue with recorded provenance first (see docs/adding-a-chain.md).`);if(!qh.test(a||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let B=await this.quote({tokenIn:s,tokenOut:i,amountIn:o},Q);if(B.evidence!==G.LIVE)throw new Error(`cannot prepare without a live quote (${B.evidence}: ${B.reason??"no reason given"})`);let I=g??B.fee,l=JS(B.amountOut,c);if(l<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let u=`0x${Vh.exactInputSingle}`+un(s)+un(i)+Et(I)+un(a)+Et(o)+Et(l)+Et(0);return{unsigned:!0,signedBy:"user-wallet",chainId:A,venue:"uniswap-v3",tx:{to:E,data:u,value:"0x0"},guard:{quotedOut:B.amountOut,minOut:l.toString(),slippageBps:c,maxSlippageBps:Xc,fee:I},requires:[{step:"approve",token:s,spender:E,amount:String(o)}],note:"UNSIGNED. Re-verify the guard against a fresh quote immediately before signing -- a quote-time minimum is not a minimum at broadcast time."}}}}var Ci={decimals:"0x313ce567",symbol:"0x95d89b41",name:"0x06fdde03",totalSupply:"0x18160ddd",owner:"0x8da5cb5b"};function Oh(e){if(!e||e==="0x")return null;try{return BigInt(e)}catch{return null}}function Ph(e){if(!e||e==="0x")return null;let A=e.slice(2);if(A.length>=128){let r=Number(BigInt(`0x${A.slice(64,128)}`));if(r>0&&r<=256&&A.length>=128+r*2){let n=A.slice(128,128+r*2),s=Buffer.from(n,"hex").toString("utf8").replace(/\0+$/,"");if(s)return s}}return Buffer.from(A.slice(0,64),"hex").toString("utf8").replace(/\0+$/,"")||null}function vS(e){let{chainId:A}=e;async function t(r,n,s){return ie(A,"eth_call",[{to:r,data:n},"latest"],s)}return{async blockNumber(r={}){let n=await xh(A,r);return{chainId:A,blockNumber:n?.blockNumber??n,evidence:G.LIVE}},async nativeBalance(r,n={}){let s=await Gh(A,r,n);return{chainId:A,address:r,wei:s?.wei??s?.balance??null,symbol:e.nativeCurrency?.symbol??null,decimals:e.nativeCurrency?.decimals??18,evidence:G.LIVE}},async tokenBalance({token:r,owner:n},s={}){let i=await Jh({chainId:A,token:r,owner:n},s);return{chainId:A,token:r,owner:n,raw:i?.balance??i,evidence:G.LIVE}},async resolveToken(r,n={}){if(!/^0x[0-9a-fA-F]{40}$/.test(r||""))return{chainId:A,token:r,evidence:G.UNKNOWN,error:"resolveToken needs a 20-byte address; symbol lookup is a market-data concern"};let[s,i,o,a]=await Promise.all([t(r,Ci.decimals,n).catch(()=>null),t(r,Ci.symbol,n).catch(()=>null),t(r,Ci.name,n).catch(()=>null),t(r,Ci.totalSupply,n).catch(()=>null)]),c=Oh(s?.result??s),g=c!==null||i?.result||o?.result;return{chainId:A,address:r,decimals:c===null?null:Number(c),symbol:Ph(i?.result??i),name:Ph(o?.result??o),totalSupply:(Oh(a?.result??a)??null)?.toString()??null,evidence:g?G.LIVE:G.UNKNOWN,warning:g?void 0:"no ERC-20 metadata returned -- may not be a token contract"}},async resolvePools(r,n={}){let s=e.dexscreenerSlug;if(!s)return{chainId:A,token:r,pools:[],evidence:G.UNAVAILABLE,reason:"no dexscreenerSlug configured for this chain; pool discovery is unavailable rather than guessed"};let i=await vh(r,n).catch(()=>null),a=(i?.pairs||i?.data?.pairs||[]).filter(c=>String(c.chainId).toLowerCase()===String(s).toLowerCase()).map(c=>({pair:c.pairAddress,dex:c.dexId,base:c.baseToken?.address,quote:c.quoteToken?.address,liquidityUsd:c.liquidity?.usd??null,priceUsd:c.priceUsd??null,volume24hUsd:c.volume?.h24??null,createdAt:c.pairCreatedAt??null})).sort((c,g)=>(g.liquidityUsd??0)-(c.liquidityUsd??0));return{chainId:A,token:r,pools:a,evidence:a.length?G.LIVE:G.UNKNOWN}},async scanBlocks({fromBlock:r,toBlock:n,address:s,topics:i,chunkSize:o=2e3}={},a={}){if(!Number.isInteger(r)||!Number.isInteger(n))throw new Error("scanBlocks requires integer fromBlock and toBlock");if(n<r)throw new Error("toBlock must be >= fromBlock");let c=[],g=[];for(let Q=r;Q<=n;Q+=o){let E=Math.min(Q+o-1,n);g.push([Q,E])}for(let[Q,E]of g){let B={fromBlock:`0x${Q.toString(16)}`,toBlock:`0x${E.toString(16)}`};s&&(B.address=s),i&&(B.topics=i);let I=await ie(A,"eth_getLogs",[B],a).catch(l=>({error:String(l?.message||l)}));if(I?.error)return{chainId:A,fromBlock:r,toBlock:n,logs:c,complete:!1,failedAt:[Q,E],error:I.error,evidence:G.UNKNOWN};for(let l of I?.result??I??[])c.push(l)}return{chainId:A,fromBlock:r,toBlock:n,logs:c,complete:!0,chunks:g.length,evidence:G.LIVE}},async scoreRisk(r,n={}){let s=[],i=L.PASS,o=g=>{let Q={[L.PASS]:0,[L.CAUTION]:1,[L.UNKNOWN]:2,[L.FAIL]:3};Q[g]>Q[i]&&(i=g)},a=await this.resolveToken(r,n);a.evidence!==G.LIVE?(s.push({check:"erc20-metadata",result:L.UNKNOWN,detail:a.warning}),o(L.UNKNOWN)):s.push({check:"erc20-metadata",result:L.PASS,detail:`${a.symbol} / ${a.decimals}d`});let c=await this.resolvePools(r,n);if(c.evidence===G.UNAVAILABLE)s.push({check:"liquidity",result:L.UNKNOWN,detail:c.reason}),o(L.UNKNOWN);else if(!c.pools.length)s.push({check:"liquidity",result:L.FAIL,detail:"no pool with liquidity found"}),o(L.FAIL);else{let g=c.pools[0],Q=g.liquidityUsd??0;Q<5e3?(s.push({check:"liquidity",result:L.CAUTION,detail:`top pool only $${Q}`}),o(L.CAUTION)):s.push({check:"liquidity",result:L.PASS,detail:`$${Q} on ${g.dex}`}),g.createdAt&&Date.now()-g.createdAt<24*3600*1e3&&(s.push({check:"age",result:L.CAUTION,detail:"pool under 24h old"}),o(L.CAUTION))}if(typeof this.sellSimulation=="function"){let g=await this.sellSimulation({token:r,amountIn:(10n**16n).toString()},n).catch(Q=>({verdict:L.UNKNOWN,reason:String(Q?.message||Q)}));s.push({check:"sellability",result:g.verdict,detail:g.retentionBps!=null?`round trip returns ${(g.retentionBps/100).toFixed(2)}% -- ${g.reason}`:g.reason}),o(g.verdict)}else s.push({check:"sellability",result:L.UNKNOWN,detail:"no verified router on this chain, so a round-trip sell simulation cannot run. Treat as unproven -- a buy path is not an exit path."}),o(L.UNKNOWN);return{chainId:A,token:r,verdict:i,checks:s,note:"Structural checks only. UNKNOWN is not PASS. A token is not tradeable until a sell simulation succeeds."}}}}function _c(e){let t={...vS(e)},r=new Set((e.venues||[]).map(s=>s.kind));e.venueKind==="uniswap-v3"&&r.has("quoter")&&r.has("router")?Object.assign(t,Wh({chainId:e.chainId,wrappedNative:e.wrappedNative})):e.venueKind==="uniswap-v2"&&r.has("router")&&Object.assign(t,Hh({chainId:e.chainId,wrappedNative:e.wrappedNative}));let n={};for(let[s,i]of Object.entries(t))n[s]=i.bind(t);return{key:e.key,chainId:e.chainId,name:e.name,rpcEnv:e.rpcEnv,nativeCurrency:e.nativeCurrency,explorer:e.explorer,venues:e.venues||[],capabilities:n}}var Zh=Object.freeze([{key:"ethereum",chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://etherscan.io",dexscreenerSlug:"ethereum",venueKind:"uniswap-v3",wrappedNative:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.71 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}}]},{key:"optimism",chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://optimistic.etherscan.io",dexscreenerSlug:"optimism",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1905.23 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}}]},{key:"bsc",chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],nativeCurrency:{symbol:"BNB",decimals:18},explorer:"https://bscscan.com",dexscreenerSlug:"bsc",venueKind:"uniswap-v3",wrappedNative:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",venues:[{kind:"quoter",address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WBNB->USDC fee 500 quoted 413.86 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}},{kind:"router",address:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}}]},{key:"polygon",chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],nativeCurrency:{symbol:"POL",decimals:18},explorer:"https://polygonscan.com",dexscreenerSlug:"polygon",venueKind:"uniswap-v3",wrappedNative:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WMATIC->USDC fee 500 quoted 0.0720 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}}]},{key:"stable",chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],nativeCurrency:{symbol:"USDT0",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x5d442b349590a6048Eb2dC0eC346cAA5F47A9ab5",venues:[{kind:"quoter",address:"0xb070179E7032CdA868b53e6C1742F80c9e940d1A",label:"Uniswap V3 QuoterV2 (canonical)",verified:{method:"Stable is on the OFFICIAL Uniswap v3 Deployments List (governance-recognised 2026-05-12, UAC process completed 2026-04, deployed by Protofire), so this is a canonical deployment rather than a fork. eth_getCode returned 8273 bytes, the same size as the canonical quoter on the seven already-verified chains. Functional probe on a live pool (TOAST -> USDT0, fee 10000): 100 in -> 0.000003, 1000 -> 0.000031, 10000 -> 0.000319 USDT0. Output scales monotonically with input, which is a working quoter answering, not a revert. Two of three sampled pools carry non-zero liquidity. NOTE: the pools discovered so far are thin, so real routing size is limited -- the venue is proved, deep liquidity is not.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:988}},{kind:"router",address:"0x32eaf9B5d5F2CD7361c5012890C943D7de84C22a",label:"Uniswap SwapRouter02 (canonical)",verified:{method:"eth_getCode returned 24497 bytes. Cross-checked on-chain rather than trusted from docs: router.factory() returns 0x88f0a512ef09175d456bc9547f914f48c013e4aa, the same v3 core factory that created the pools quoted above, and router.WETH9() returns the wrappedNative recorded on this chain entry. Address published in the Stable docs DEX reference and the Uniswap deployments list.",source:"docs.stable.xyz/en/reference/dexes + on-chain factory()/WETH9() round-trip",date:"2026-08-05",chainId:988}}]},{key:"hyperevm",chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],nativeCurrency:{symbol:"HYPE",decimals:18},dexscreenerSlug:"hyperevm",venueKind:"uniswap-v3",wrappedNative:"0x5555555555555555555555555555555555555555",venues:[{kind:"quoter",address:"0x03A918028f22D9E1473B7959C927AD7425A45C7C",label:"HyperSwap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle(1 WHYPE -> USDT0) returned live output on all four fee tiers (100: 57.3385, 500: 57.4187, 3000: 57.3237, 10000: 56.1963 USDT0). Decimals read on-chain: WHYPE 18, USDT0 6. Best tier checked against an INDEPENDENT control the same minute -- Hyperliquid allMids put HYPE at 57.3205, so the pool is 0.171% from the perp mid, which is the right shape for fee plus impact rather than a wrong contract or a decimals bug.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}},{kind:"router",address:"0x4E2960a8cd19B467b82d26D83fAcb0fAE26b094D",label:"HyperSwap V3 SwapRouter",verified:{method:"eth_getCode returned 12070 bytes, and it is the router paired with the quoter proved above -- the same pair already shipped in UNI_V3_VENUES[999].hyperswap, which is the map the quote/prepare path actually routes through.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}}]},{key:"abstract",chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x3439153EB7AF838Ad19d56E1571FBD09333C2809",venues:[{kind:"quoter",address:"0x728BD3eC25D5EDBafebB84F3d67367Cd9EBC7693",label:"Uniswap V3 QuoterV2 (Abstract deployment)",verified:{method:"Abstract is a ZK-stack chain, so CREATE2 addresses differ and the canonical Uniswap addresses are NOT valid here -- probing them returns codesize 0, which is what previously made this chain look like it had no V3 at all. Found the real deployment from live traffic instead: scanned recent Swap(...) logs, took the busiest pool, read pool.factory() = 0xa1160e73b63f322ae88cc2d8e700833e71d0b2a1, then enumerated that factory's deployer (0xf3d63166F0Ca56C3c1A3508FcE03Ff0Cf3Fb691e) and probed each of its 56 contracts with a real quoteExactInputSingle call. Exactly one answered: 1 WETH -> 1846.475731 USDC.e at fee 500. Independent sanity check: the pool's own slot0() spot price is 1873.11 USDC.e per WETH, so the quoter sits ~1.4% below spot, the right shape for fee plus price impact on this size.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:2741}},{kind:"router",address:"0x7712FA47387542819d4E35A23f8116C90C18767C",label:"Uniswap SwapRouter02 (Abstract deployment)",verified:{method:"eth_getCode returned 167392 bytes and the runtime contains the exactInputSingle selector. router.factory() matches the factory proved above and router.WETH9() matches the wrappedNative on this entry. Chosen over its byte-identical twin (0xfD6257F4...) because this is the address real users actually route through: it appeared as tx.to on live swaps against the WETH/USDC.e pool.",source:"on-chain factory()/WETH9() round-trip + live swap tx.to sampling",date:"2026-08-05",chainId:2741}}]},{key:"robinhood",chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC","ROBINHOOD_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},dexscreenerSlug:"robinhood",venueKind:"uniswap-v3",wrappedNative:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",venues:[{kind:"quoter",address:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDG fee 100 quoted 1866.58 USDG, and USDG->CASHCAT fee 10000 quoted a live amount). A contract that correctly prices known pairs IS a working V3 quoter",source:"live eth_call against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"router",address:"0xcaf681a66d020601342297493863e78c959e5cb2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode (24497 bytes) on this chain and the paired quoter at the same deployment passed a live functional quote",source:"live eth_getCode against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"factory",address:"0x1f7d7550b1b028f7571e69a784071f0205fd2efa",label:"Uniswap V3 Factory",verified:{method:"eth_getCode returned real bytecode (24535 bytes) and a PoolCreated log scan over this factory returned 76 pools in ~9000 recent blocks",source:"live eth_getLogs against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}}]},{key:"base",chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://basescan.org",dexscreenerSlug:"base",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",venues:[{kind:"quoter",address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",label:"Uniswap V3 QuoterV2 (Base)",verified:{method:"functional probe: quoteExactInputSingle returned WETH->USDC at fee 500 = 1908.44 USDC, a live sane price. The canonical mainnet quoter address also has bytecode on Base but does NOT price this pair, which is exactly the false positive a codesize-only check accepts",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router",address:"0x2626664c2603336E57B271c5C0b26F421741e481",label:"Uniswap V3 SwapRouter02 (Base)",verified:{method:"eth_getCode returned real bytecode and the paired Base quoter passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router-v2",address:"0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",label:"Uniswap V2 Router02 (Base)",verified:{method:"eth_getCode returned 17891 bytes; live getAmountsOut on WETH->USDC round-tripped to 98.75% (2x0.30% fee + impact)",source:"https://docs.uniswap.org/contracts/v2/reference/smart-contracts/v2-deployments",date:"2026-07-30",chainId:8453}}]},{key:"arbitrum",chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://arbiscan.io",dexscreenerSlug:"arbitrum",venueKind:"uniswap-v3",wrappedNative:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.72 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}}]},{key:"avalanche",chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],nativeCurrency:{symbol:"AVAX",decimals:18},explorer:"https://snowtrace.io",dexscreenerSlug:"avalanche",venueKind:"uniswap-v3",wrappedNative:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",venues:[{kind:"quoter",address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WAVAX->USDC fee 500 quoted 6.48 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}},{kind:"router",address:"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}}]}]);function HS(){return Zh.map(e=>ui(_c(e)))}function VS(e){return ui(_c(e))}export{Zh as CHAIN_CONFIGS,G as EVIDENCE,L as RISK,Ir as SCANNER_CAPABILITIES,PS as __clearScanners,rd as createScanner,WS as getScanner,OS as listScanners,HS as registerBuiltinScanners,VS as registerCustomChain,ui as registerScanner,ZS as scannerCoverage,td as validateScanner};
|
|
47
|
+
- `)}`);let n=e.capabilities||{},s=Ir.filter(o=>typeof n[o]=="function"),i={key:e.key,chainId:e.chainId,name:e.name,rpcEnv:[...e.rpcEnv],nativeCurrency:e.nativeCurrency?{...e.nativeCurrency}:null,wrappedNative:e.wrappedNative||null,explorer:e.explorer||null,venues:(e.venues||[]).map(o=>({...o})),warnings:r,capabilities(){return{chainId:e.chainId,key:e.key,supported:[...s],unsupported:Ir.filter(o=>!s.includes(o))}},supports(o){return s.includes(o)}};for(let o of Ir)s.includes(o)?i[o]=async(...a)=>n[o](...a,{scanner:i}):i[o]=async()=>{throw new Error(`${e.key} (chain ${e.chainId}) does not implement "${o}". Supported: ${s.join(", ")||"none"}. An unimplemented capability is absent, not assumed -- implement it or treat this chain as fail-closed for that operation.`)};return Object.freeze(i)}var lt=new Map;function ui(e){let A=rd(e);return lt.set(A.chainId,A),A}function WS(e){return lt.get(Number(e))||null}function OS(){return[...lt.values()]}function PS(){lt.clear()}function ZS(){let e={};for(let A of lt.values())e[A.chainId]={key:A.key,name:A.name,...A.capabilities(),venueCount:A.venues.length,failClosed:A.venues.length===0};return{generatedAt:new Date().toISOString(),chainCount:lt.size,capabilities:[...Ir],chains:e}}import{createHash as IS}from"node:crypto";import Br from"node:net";import QS from"node:dns";var ES=new Set(["localhost","metadata.google.internal","metadata.goog"]);function Bi(e){let A=String(e).toLowerCase().split("%")[0];if((A.match(/::/g)||[]).length>1)return null;let t=g=>{if(!g)return[];let Q=g.split(":"),E=Q.at(-1);if(E?.includes(".")){let B=E.split(".").map(Number);if(B.length!==4||B.some(I=>!Number.isInteger(I)||I<0||I>255))return null;Q.splice(Q.length-1,1,(B[0]<<8|B[1]).toString(16),(B[2]<<8|B[3]).toString(16))}return Q.some(B=>!/^[0-9a-f]{1,4}$/.test(B))?null:Q.map(B=>Number.parseInt(B,16))},[r,n]=A.split("::"),s=t(r),i=t(n);if(!s||!i)return null;let o=A.includes("::"),a=8-s.length-i.length;if(!o&&a!==0||o&&a<1)return null;let c=[...s,...Array(Math.max(0,a)).fill(0),...i];return c.length!==8?null:Uint8Array.from(c.flatMap(g=>[g>>8,g&255]))}function qc(e,A,t){let r=Math.floor(t/8),n=t%8;for(let i=0;i<r;i+=1)if(e[i]!==A[i])return!1;if(!n)return!0;let s=255<<8-n;return(e[r]&s)===(A[r]&s)}function Wc(e){if(Br.isIPv4(e)){let A=e.split(".").map(Number);return!(A[0]===0||A[0]===10||A[0]===127||A[0]>=224||A[0]===100&&A[1]>=64&&A[1]<=127||A[0]===169&&A[1]===254||A[0]===172&&A[1]>=16&&A[1]<=31||A[0]===192&&(A[1]===0||A[1]===2||A[1]===168)||A[0]===192&&A[1]===88&&A[2]===99||A[0]===198&&(A[1]===18||A[1]===19||A[1]===51)||A[0]===203&&A[1]===0&&A[2]===113)}if(Br.isIPv6(e)){let A=Bi(e);if(!A)return!1;let t=Bi("::ffff:0:0");return qc(A,t,96)?Wc([...A.slice(12)].join(".")):qc(A,Bi("2000::"),3)?![["2001::",23],["2001:db8::",32],["2001:10::",28],["2001:2::",48],["2002::",16],["3fff::",20]].some(([n,s])=>qc(A,Bi(n),s)):!1}return!1}function BS(e){let A;try{A=new URL(String(e))}catch{return{ok:!1,error:`not a valid URL: ${String(e).slice(0,120)}`}}if(A.protocol!=="http:"&&A.protocol!=="https:")return{ok:!1,error:`refused protocol ${A.protocol} (only http/https)`};let t=A.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,"");if(ES.has(t)||t.endsWith(".localhost")||t.endsWith(".internal"))return{ok:!1,error:`refused internal host ${t}`};let r=Br.isIP(t);return r!==0&&!Wc(t)?{ok:!1,error:`refused private address ${t}`}:{ok:!0,url:A,host:t,isLiteralIp:r!==0}}async function kh(e,{lookupFn:A=QS.promises.lookup}={}){let t=BS(e);if(!t.ok)return t;if(t.isLiteralIp)return{ok:!0,url:t.url};let r;try{r=await A(t.host,{all:!0,verbatim:!0})}catch{return{ok:!1,error:`refused: ${t.host} did not resolve`}}return!Array.isArray(r)||r.length===0||r.some(n=>!Wc(n.address))?{ok:!1,error:`refused: ${t.host} resolves to a non-public address`}:{ok:!0,url:t.url,addresses:r}}async function Fh(){let e,A;try{let o=await Promise.resolve().then(()=>Ad(mh(),1));e=o.Agent,A=o.fetch}catch{return null}if(typeof e!="function"||typeof A!="function")return null;let t=o=>String(o).toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,""),r=new Map,n=o=>(Array.isArray(o)?o:[o]).map(a=>typeof a=="string"?{address:a}:a).filter(a=>a&&a.address).map(a=>({address:a.address,family:a.family||(Br.isIPv6(a.address)?6:4)})),s=o=>{let a=t(o);if(Br.isIP(a))return[{address:a,family:Br.isIPv6(a)?6:4}];let c=r.get(a);if(!c||!c.length)throw new Error(`refused: unpinned host ${o} during pinned fetch`);return c},i=new e({connect:{lookup(o,a,c){let g;try{g=s(o)}catch(Q){return c(Q)}return a?.all?c(null,g):c(null,g[0].address,g[0].family)}}});return{dispatcher:i,fetch:(o,a={})=>A(o,{...a,dispatcher:i}),pin(o,a,c){r.set(t(o),n(typeof a=="string"?[{address:a,family:c}]:a))},resolve:s,async close(){try{await i.destroy()}catch{}}}}var CS=new Set([408,425,429,500,502,503,504]),Rh=new Set(["GET","HEAD","OPTIONS","PUT","DELETE"]),lS=2,bh=4e3,Sh=["authorization","x-api-key","x-tensor-api-key","0x-api-key","api-key","cookie","proxy-authorization"],uS=new Set([301,302,303,307,308]),Nh=3;function hS(e){let A=String(e||"").toLowerCase();return Sh.includes(A)||/(^|-)(api[-_]?key|key|token|secret|auth|authorization|session|cookie|signature|access)(-|$)/.test(A)}function dS(e){let A={};for(let[t,r]of Object.entries(e||{}))hS(t)||(A[t]=r);return A}function fS(e,A){if(!e)throw new Error(`HTTP redirect from ${A} missing Location`);let t=new URL(String(e),String(A));if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error(`HTTP redirect from ${A} used unsupported protocol ${t.protocol}`);return t.toString()}function wS(e,A){return new URL(String(e)).origin===new URL(String(A)).origin}var Oc=new Map;function yS(e,A,t){let r={};for(let[a,c]of Object.entries(t||{}))r[a.toLowerCase()]=c;let n=Object.keys(r).filter(a=>/(^|-)(api[-_]?key|key|token|secret|auth|authorization|session|cookie|signature|access)(-|$)/.test(a)),i=[...new Set([...Sh,...n])].sort().map(a=>`${a}=${r[a]??""}`).join(`
|
|
48
|
+
`),o=IS("sha256").update(i).digest("hex").slice(0,32);return`${e} ${A} ${o}`}function pS(e,A){let t=Number(A);return Number.isFinite(t)&&t>0?Math.min(t*1e3,bh):Math.min(250*2**e,bh)+Math.floor(Math.random()*100)}var DS=e=>new Promise(A=>setTimeout(A,e));async function mS(e,{fetchImpl:A,method:t,headers:r,body:n,timeoutMs:s,lookupFn:i,realFetch:o}){let a=new AbortController,c=setTimeout(()=>a.abort(),s),g=null,Q=A;try{let E=String(e),B={...r||{}};for(let I=0;I<=Nh;I+=1){let l=await Q(E,{method:t,headers:B,body:n,signal:a.signal,redirect:"manual"}),u=await l.text(),C=null;if(u)try{C=JSON.parse(u)}catch{C=null}if(uS.has(l.status)){if(t!=="GET"&&t!=="HEAD"){let p=new Error(`HTTP ${l.status} ${t} ${E} redirected non-idempotent request`);throw p.status=l.status,p.body=C??u.slice(0,300),p}if(I===Nh)throw new Error(`HTTP redirect loop for ${e}`);let h=fS(l.headers?.get?.("location"),E);if(!wS(h,E)){let p=await kh(h,i?{lookupFn:i}:{});if(!p.ok){let H=new Error(`HTTP redirect from ${E} ${p.error}`);throw H.status=l.status,H}B=dS(B),o&&p.addresses?.length&&(g||(g=await Fh()),g&&(g.pin(new URL(h).hostname,p.addresses[0].address,p.addresses[0].family),Q=g.fetch))}E=h;continue}if(!l.ok){let h=new Error(`HTTP ${l.status} ${t} ${E}`);throw h.status=l.status,h.retryAfter=l.headers?.get?.("retry-after")??null,h.body=C??u.slice(0,300),h}return C??u}throw new Error(`HTTP redirect loop for ${e}`)}finally{clearTimeout(c),g&&await g.close()}}async function Ii(e,A={}){let t=A.fetchImpl||globalThis.fetch;if(typeof t!="function")throw new Error("fetch unavailable \u2014 pass opts.fetchImpl");let r=A.timeoutMs??12e3,n=(A.method||"GET").toUpperCase(),s={Accept:"application/json",...A.headers||{}},i=A.body;i!=null&&typeof i!="string"&&(s["Content-Type"]=s["Content-Type"]||"application/json",i=JSON.stringify(i));let o=Number.isInteger(A.retries)?Math.max(A.retries,0):lS,a=A.lookupFn,c=!A.fetchImpl,g=async()=>{let l;for(let u=0;u<=o;u++)try{return await mS(e,{fetchImpl:t,method:n,headers:s,body:i,timeoutMs:r,lookupFn:a,realFetch:c})}catch(C){l=C;let h=C?.status,D=C?.name==="AbortError",p=new Set([408,425,429]),H=h!=null?p.has(h)||CS.has(h)&&Rh.has(n):!D&&Rh.has(n);if(u===o||!H)throw C;await DS(pS(u,C?.retryAfter))}throw l};if(!(A.dedupe!==!1&&n==="GET"&&i==null))return g();let E=yS(n,e,s),B=Oc.get(E);if(B)return B;let I=g().finally(()=>Oc.delete(E));return Oc.set(E,I),I}var Uh={robinhood:{chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC"],evm:!0},ethereum:{chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],evm:!0},polygon:{chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],evm:!0},arbitrum:{chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],evm:!0},base:{chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],evm:!0},hyperevm:{chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],evm:!0},bsc:{chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],evm:!0},avalanche:{chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],evm:!0},optimism:{chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],evm:!0},abstract:{chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],evm:!0},stable:{chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],evm:!0}},kS=new Map(Object.values(Uh).map(e=>[e.chainId,e]));function Mh(e){return kS.get(Number(e))||null}function Lh(e,A=process.env){let t=Mh(e);if(!t)return null;for(let r of t.rpcEnv){let n=(A[r]||"").trim();if(n)return n}return null}import{Interface as FS,getAddress as RS}from"ethers";var Th=new FS(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);function Yh(e,A){try{return RS(e).toLowerCase()}catch{throw new Error(`${A} must be a valid EVM address`)}}var bS={1:"https://ethereum.publicnode.com",137:"https://polygon-bor-rpc.publicnode.com",42161:"https://arbitrum-one-rpc.publicnode.com",8453:"https://base-rpc.publicnode.com",10:"https://optimism-rpc.publicnode.com",988:"https://rpc.stable.xyz",56:"https://bsc-rpc.publicnode.com",43114:"https://avalanche-c-chain-rpc.publicnode.com",999:"https://rpc.hyperliquid.xyz/evm",2741:"https://api.mainnet.abs.xyz",4663:"https://rpc.mainnet.chain.robinhood.com"};function NS(e,{rpcUrl:A,env:t=process.env}={}){if(A)return A;let r=Lh(e,t);return r||bS[Number(e)]||null}var SS=/^(?:eth_(?:call|blocknumber|chainid|get[a-z0-9]+|feehistory|gasprice|maxpriorityfeepergas|syncing|protocolversion|estimategas|createaccesslist)|net_(?:version|listening|peercount)|web3_(?:clientversion|sha3))$/;function US(e){let A=String(e||""),t=A.toLowerCase();if(A!==A.trim()||!/^[a-zA-Z0-9_]+$/.test(A)||!SS.test(t))throw new Error(`evm-rpc: ${A} refused \u2014 @oracle-agent/oracle is prepare-only (read RPC only; no broadcast/sign)`);return t}async function ie(e,A,t=[],r={}){let n=String(A||"");US(n);let s=NS(e,r);if(!s)throw new Error(`No RPC URL for chainId ${e} (set env from chain registry rpcEnv or pass rpcUrl)`);let o=await Ii(s,{method:"POST",body:{jsonrpc:"2.0",id:1,method:A,params:t},fetchImpl:r.fetchImpl,timeoutMs:r.timeoutMs??12e3});if(o?.error){let a=new Error(o.error.message||JSON.stringify(o.error));throw a.code=o.error.code,a}return o.result}async function xh(e,A={}){let t=await ie(e,"eth_blockNumber",[],A);return parseInt(t,16)}async function Gh(e,A,t={}){if(!A)throw new Error("rpcGetBalance requires address");let r=await ie(e,"eth_getBalance",[A,"latest"],t);return{chainId:Number(e),address:A,balanceWei:BigInt(r).toString(),balanceHex:r}}async function Jh(e={},A={}){let t=Number(e.chainId??A.chainId??1),r=Yh(e.token||e.tokenAddress,"token"),n=Yh(e.account||e.owner||e.address,"account"),s=Th.encodeFunctionData("balanceOf",[n]),i=await ie(t,"eth_call",[{to:r,data:s},e.blockTag||"latest"],A),o=Th.decodeFunctionResult("balanceOf",i),a=BigInt(o[0]);return{chainId:t,token:r,account:n,balance:a.toString(),balanceHex:`0x${a.toString(16)}`,blockTag:e.blockTag||"latest"}}var MS="https://api.dexscreener.com",tL=Object.freeze({1:"ethereum",10:"optimism",56:"bsc",137:"polygon",8453:"base",42161:"arbitrum",43114:"avalanche",999:"hyperevm",4663:"robinhood"});function LS(e={}){return(e.baseUrl||process.env.DEXSCREENER_API_URL||MS).replace(/\/$/,"")}async function vh(e,A={}){if(!e)throw new Error("tokenAddress required");return Ii(`${LS(A)}/latest/dex/tokens/${e}`,{fetchImpl:A.fetchImpl,timeoutMs:A.timeoutMs??12e3})}var Zc={getAmountsOut:"d06ca61f",swapExactTokensForTokens:"38ed1739",swapExactETHForTokens:"7ff36ab5"},GA=e=>BigInt(e).toString(16).padStart(64,"0"),ln=e=>e.slice(2).toLowerCase().padStart(64,"0");function TS(e,A){return`0x${Zc.getAmountsOut}`+GA(e)+GA(64)+GA(A.length)+A.map(ln).join("")}function YS(e){if(!e||e==="0x")return null;let A=e.slice(2);if(A.length<128)return null;let t=Number(BigInt(`0x${A.slice(64,128)}`));if(!Number.isFinite(t)||t<1||t>16)return null;let r=[];for(let n=0;n<t;n++){let s=128+n*64;if(A.length<s+64)return null;r.push(BigInt(`0x${A.slice(s,s+64)}`))}return r}function Pc(e,A="router"){return(e?.venues||[]).find(r=>r.kind===A)?.address??null}var Kc=100;function xS(e,A){let t=Number(A);if(!Number.isFinite(t)||t<0)throw new Error("slippageBps must be a non-negative number");if(t>Kc)throw new Error(`slippageBps ${t} exceeds the ${Kc} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(e)*BigInt(1e4-Math.floor(t))/10000n}function Hh(e){let{chainId:A,wrappedNative:t}=e;async function r(n,s,i,o){let a=await ie(A,"eth_call",[{to:n,data:TS(s,i)},"latest"],o);return YS(a?.result??a)}return{async quote({tokenIn:n,tokenOut:s,amountIn:i,path:o},a={}){let c=Pc(a.scanner);if(!c)return{chainId:A,evidence:G.UNAVAILABLE,reason:"no verified router configured for this chain; quoting stays fail-closed rather than guessing a venue address"};let g=o||[n,s];if(g.some(E=>!/^0x[0-9a-fA-F]{40}$/.test(E||"")))throw new Error("quote requires valid 20-byte addresses");let Q=await r(c,i,g,a);return Q?{chainId:A,router:c,path:g,amountIn:String(i),amountOut:Q[Q.length-1].toString(),hops:g.length-1,evidence:G.LIVE,note:"exact-input quote at current reserves; not a guaranteed fill"}:{chainId:A,router:c,path:g,evidence:G.UNKNOWN,reason:"router returned no amounts -- no pool for this path, or the call reverted"}},async sellSimulation({token:n,amountIn:s,base:i},o={}){let a=Pc(o.scanner),c=i||t;if(c&&String(n).toLowerCase()===String(c).toLowerCase())return{chainId:A,token:n,verdict:L.UNKNOWN,evidence:G.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};if(!a||!c)return{chainId:A,token:n,verdict:L.UNKNOWN,evidence:G.UNAVAILABLE,reason:a?"no wrappedNative configured for this chain, so no base asset to round-trip against":"no verified router configured for this chain"};let g=await r(a,s,[c,n],o);if(!g)return{chainId:A,token:n,verdict:L.FAIL,evidence:G.LIVE,leg:"buy",reason:"buy leg returned no amounts -- no route in"};let Q=g[g.length-1];if(Q===0n)return{chainId:A,token:n,verdict:L.FAIL,evidence:G.LIVE,leg:"buy",reason:"buy leg quotes zero output"};let E=await r(a,Q,[n,c],o);if(!E)return{chainId:A,token:n,verdict:L.FAIL,evidence:G.LIVE,leg:"sell",bought:Q.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let B=E[E.length-1],I=Number(B*10000n/BigInt(s)),l=L.PASS,u="round trip completes with expected fee/impact loss";return I<5e3?(l=L.FAIL,u=`round trip returns only ${(I/100).toFixed(2)}% -- punitive tax or no real liquidity`):I<9e3&&(l=L.CAUTION,u=`round trip returns ${(I/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:A,token:n,base:c,router:a,verdict:l,reason:u,amountIn:String(s),bought:Q.toString(),returned:B.toString(),retentionBps:I,evidence:G.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:n,tokenOut:s,amountIn:i,recipient:o,slippageBps:a=50,deadlineSeconds:c=900,path:g},Q={}){let E=Q.scanner,B=Pc(E);if(!B)throw new Error(`chain ${A} has no verified router; preparing a swap stays fail-closed. Add a venue with recorded provenance first (see docs/adding-a-chain.md).`);if(!/^0x[0-9a-fA-F]{40}$/.test(o||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let I=g||[n,s],l=await this.quote({tokenIn:n,tokenOut:s,amountIn:i,path:I},Q);if(l.evidence!==G.LIVE)throw new Error(`cannot prepare without a live quote (${l.evidence}: ${l.reason??"no reason given"})`);let u=xS(l.amountOut,a);if(u<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let C=BigInt(Math.floor(Date.now()/1e3)+Number(c)),h=t&&I[0].toLowerCase()===t.toLowerCase()&&Q.useNative,D=h?`0x${Zc.swapExactETHForTokens}`+GA(u)+GA(128)+ln(o)+GA(C)+GA(I.length)+I.map(ln).join(""):`0x${Zc.swapExactTokensForTokens}`+GA(i)+GA(u)+GA(160)+ln(o)+GA(C)+GA(I.length)+I.map(ln).join("");return{unsigned:!0,signedBy:"user-wallet",chainId:A,tx:{to:B,data:D,value:h?`0x${BigInt(i).toString(16)}`:"0x0"},guard:{quotedOut:l.amountOut,minOut:u.toString(),slippageBps:a,maxSlippageBps:Kc,deadline:C.toString()},requires:h?[]:[{step:"approve",token:I[0],spender:B,amount:String(i)}],note:"UNSIGNED. Re-verify the guard against a fresh quote immediately before signing -- a quote-time minimum is not a minimum at broadcast time."}}}}var GS=[100,500,3e3,1e4],Vh={quoteExactInputSingle:"c6a5026a",exactInputSingle:"04e45aaf"},Et=e=>BigInt(e).toString(16).padStart(64,"0"),un=e=>e.slice(2).toLowerCase().padStart(64,"0"),qh=/^0x[0-9a-fA-F]{40}$/,Xc=100;function JS(e,A){let t=Number(A);if(!Number.isFinite(t)||t<0)throw new Error("slippageBps must be a non-negative number");if(t>Xc)throw new Error(`slippageBps ${t} exceeds the ${Xc} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(e)*BigInt(1e4-Math.floor(t))/10000n}function zc(e,A){return(e?.venues||[]).find(t=>t.kind===A)?.address??null}function Wh(e){let{chainId:A,wrappedNative:t}=e;async function r({quoter:s,tokenIn:i,tokenOut:o,amountIn:a,fee:c},g){let Q=`0x${Vh.quoteExactInputSingle}`+un(i)+un(o)+Et(a)+Et(c)+Et(0),E=await ie(A,"eth_call",[{to:s,data:Q},"latest"],g).catch(()=>null),B=E?.result??E;if(!B||B==="0x"||B.length<66)return null;let I=BigInt(`0x${B.slice(2,66)}`);return I>0n?I:null}async function n({quoter:s,tokenIn:i,tokenOut:o,amountIn:a},c){let g=[],Q=null;for(let E of GS){let B=await r({quoter:s,tokenIn:i,tokenOut:o,amountIn:a,fee:E},c);g.push({fee:E,amountOut:B?B.toString():null}),B&&(!Q||B>Q.amountOut)&&(Q={fee:E,amountOut:B})}return{best:Q,tried:g}}return{async quote({tokenIn:s,tokenOut:i,amountIn:o},a={}){let c=zc(a.scanner,"quoter");if(!c)return{chainId:A,evidence:G.UNAVAILABLE,reason:"no verified quoter configured for this chain; quoting stays fail-closed rather than guessing a venue address"};for(let E of[s,i])if(!qh.test(E||""))throw new Error("quote requires valid 20-byte addresses");let{best:g,tried:Q}=await n({quoter:c,tokenIn:s,tokenOut:i,amountIn:o},a);return g?{chainId:A,venue:"uniswap-v3",quoter:c,tokenIn:s,tokenOut:i,amountIn:String(o),amountOut:g.amountOut.toString(),fee:g.fee,useNative:!!t&&String(s).toLowerCase()===String(t).toLowerCase(),triedFeeTiers:Q,evidence:G.LIVE,note:"exact-input single-hop quote at current tick; not a guaranteed fill"}:{chainId:A,quoter:c,tokenIn:s,tokenOut:i,triedFeeTiers:Q,evidence:G.UNKNOWN,reason:"no fee tier returned a quote -- no V3 pool for this pair, or no liquidity"}},async sellSimulation({token:s,amountIn:i,base:o},a={}){let c=zc(a.scanner,"quoter"),g=o||t;if(g&&String(s).toLowerCase()===String(g).toLowerCase())return{chainId:A,token:s,verdict:L.UNKNOWN,evidence:G.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};if(!c||!g)return{chainId:A,token:s,verdict:L.UNKNOWN,evidence:G.UNAVAILABLE,reason:c?"no wrappedNative configured, so there is no base asset to round-trip against":"no verified quoter configured for this chain"};let Q=await n({quoter:c,tokenIn:g,tokenOut:s,amountIn:i},a);if(!Q.best)return{chainId:A,token:s,verdict:L.FAIL,evidence:G.LIVE,leg:"buy",reason:"no V3 pool priced the buy leg on any fee tier"};let E=await n({quoter:c,tokenIn:s,tokenOut:g,amountIn:Q.best.amountOut},a);if(!E.best)return{chainId:A,token:s,verdict:L.FAIL,evidence:G.LIVE,leg:"sell",bought:Q.best.amountOut.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let B=E.best.amountOut,I=Number(B*10000n/BigInt(i)),l=L.PASS,u="round trip completes with expected fee/impact loss";return I<5e3?(l=L.FAIL,u=`round trip returns only ${(I/100).toFixed(2)}% -- punitive tax or no real liquidity`):I<9e3&&(l=L.CAUTION,u=`round trip returns ${(I/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:A,venue:"uniswap-v3",token:s,base:g,verdict:l,reason:u,amountIn:String(i),bought:Q.best.amountOut.toString(),returned:B.toString(),retentionBps:I,buyFee:Q.best.fee,sellFee:E.best.fee,evidence:G.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:s,tokenOut:i,amountIn:o,recipient:a,slippageBps:c=50,fee:g},Q={}){let E=zc(Q.scanner,"router");if(!E)throw new Error(`chain ${A} has no verified V3 router; preparing a swap stays fail-closed. Add a venue with recorded provenance first (see docs/adding-a-chain.md).`);if(!qh.test(a||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let B=await this.quote({tokenIn:s,tokenOut:i,amountIn:o},Q);if(B.evidence!==G.LIVE)throw new Error(`cannot prepare without a live quote (${B.evidence}: ${B.reason??"no reason given"})`);let I=g??B.fee,l=JS(B.amountOut,c);if(l<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let u=!!(Q.useNative||B.useNative)&&t&&String(s).toLowerCase()===String(t).toLowerCase(),C=`0x${Vh.exactInputSingle}`+un(s)+un(i)+Et(I)+un(a)+Et(o)+Et(l)+Et(0);return{unsigned:!0,signedBy:"user-wallet",chainId:A,venue:"uniswap-v3",tx:{to:E,data:C,value:u?String(o):"0x0"},guard:{quotedOut:B.amountOut,minOut:l.toString(),slippageBps:c,maxSlippageBps:Xc,fee:I},requires:u?[]:[{step:"approve",token:s,spender:E,amount:String(o)}],note:"UNSIGNED. Re-verify the guard against a fresh quote immediately before signing -- a quote-time minimum is not a minimum at broadcast time."}}}}var Ci={decimals:"0x313ce567",symbol:"0x95d89b41",name:"0x06fdde03",totalSupply:"0x18160ddd",owner:"0x8da5cb5b"};function Oh(e){if(!e||e==="0x")return null;try{return BigInt(e)}catch{return null}}function Ph(e){if(!e||e==="0x")return null;let A=e.slice(2);if(A.length>=128){let r=Number(BigInt(`0x${A.slice(64,128)}`));if(r>0&&r<=256&&A.length>=128+r*2){let n=A.slice(128,128+r*2),s=Buffer.from(n,"hex").toString("utf8").replace(/\0+$/,"");if(s)return s}}return Buffer.from(A.slice(0,64),"hex").toString("utf8").replace(/\0+$/,"")||null}function vS(e){let{chainId:A}=e;async function t(r,n,s){return ie(A,"eth_call",[{to:r,data:n},"latest"],s)}return{async blockNumber(r={}){let n=await xh(A,r);return{chainId:A,blockNumber:n?.blockNumber??n,evidence:G.LIVE}},async nativeBalance(r,n={}){let s=await Gh(A,r,n);return{chainId:A,address:r,wei:s?.wei??s?.balance??null,symbol:e.nativeCurrency?.symbol??null,decimals:e.nativeCurrency?.decimals??18,evidence:G.LIVE}},async tokenBalance({token:r,owner:n},s={}){let i=await Jh({chainId:A,token:r,owner:n},s);return{chainId:A,token:r,owner:n,raw:i?.balance??i,evidence:G.LIVE}},async resolveToken(r,n={}){if(!/^0x[0-9a-fA-F]{40}$/.test(r||""))return{chainId:A,token:r,evidence:G.UNKNOWN,error:"resolveToken needs a 20-byte address; symbol lookup is a market-data concern"};let[s,i,o,a]=await Promise.all([t(r,Ci.decimals,n).catch(()=>null),t(r,Ci.symbol,n).catch(()=>null),t(r,Ci.name,n).catch(()=>null),t(r,Ci.totalSupply,n).catch(()=>null)]),c=Oh(s?.result??s),g=c!==null||i?.result||o?.result;return{chainId:A,address:r,decimals:c===null?null:Number(c),symbol:Ph(i?.result??i),name:Ph(o?.result??o),totalSupply:(Oh(a?.result??a)??null)?.toString()??null,evidence:g?G.LIVE:G.UNKNOWN,warning:g?void 0:"no ERC-20 metadata returned -- may not be a token contract"}},async resolvePools(r,n={}){let s=e.dexscreenerSlug;if(!s)return{chainId:A,token:r,pools:[],evidence:G.UNAVAILABLE,reason:"no dexscreenerSlug configured for this chain; pool discovery is unavailable rather than guessed"};let i=await vh(r,n).catch(()=>null),a=(i?.pairs||i?.data?.pairs||[]).filter(c=>String(c.chainId).toLowerCase()===String(s).toLowerCase()).map(c=>({pair:c.pairAddress,dex:c.dexId,base:c.baseToken?.address,quote:c.quoteToken?.address,liquidityUsd:c.liquidity?.usd??null,priceUsd:c.priceUsd??null,volume24hUsd:c.volume?.h24??null,createdAt:c.pairCreatedAt??null})).sort((c,g)=>(g.liquidityUsd??0)-(c.liquidityUsd??0));return{chainId:A,token:r,pools:a,evidence:a.length?G.LIVE:G.UNKNOWN}},async scanBlocks({fromBlock:r,toBlock:n,address:s,topics:i,chunkSize:o=2e3}={},a={}){if(!Number.isInteger(r)||!Number.isInteger(n))throw new Error("scanBlocks requires integer fromBlock and toBlock");if(n<r)throw new Error("toBlock must be >= fromBlock");let c=[],g=[];for(let Q=r;Q<=n;Q+=o){let E=Math.min(Q+o-1,n);g.push([Q,E])}for(let[Q,E]of g){let B={fromBlock:`0x${Q.toString(16)}`,toBlock:`0x${E.toString(16)}`};s&&(B.address=s),i&&(B.topics=i);let I=await ie(A,"eth_getLogs",[B],a).catch(l=>({error:String(l?.message||l)}));if(I?.error)return{chainId:A,fromBlock:r,toBlock:n,logs:c,complete:!1,failedAt:[Q,E],error:I.error,evidence:G.UNKNOWN};for(let l of I?.result??I??[])c.push(l)}return{chainId:A,fromBlock:r,toBlock:n,logs:c,complete:!0,chunks:g.length,evidence:G.LIVE}},async scoreRisk(r,n={}){let s=[],i=L.PASS,o=g=>{let Q={[L.PASS]:0,[L.CAUTION]:1,[L.UNKNOWN]:2,[L.FAIL]:3};Q[g]>Q[i]&&(i=g)},a=await this.resolveToken(r,n);a.evidence!==G.LIVE?(s.push({check:"erc20-metadata",result:L.UNKNOWN,detail:a.warning}),o(L.UNKNOWN)):s.push({check:"erc20-metadata",result:L.PASS,detail:`${a.symbol} / ${a.decimals}d`});let c=await this.resolvePools(r,n);if(c.evidence===G.UNAVAILABLE)s.push({check:"liquidity",result:L.UNKNOWN,detail:c.reason}),o(L.UNKNOWN);else if(!c.pools.length)s.push({check:"liquidity",result:L.FAIL,detail:"no pool with liquidity found"}),o(L.FAIL);else{let g=c.pools[0],Q=g.liquidityUsd??0;Q<5e3?(s.push({check:"liquidity",result:L.CAUTION,detail:`top pool only $${Q}`}),o(L.CAUTION)):s.push({check:"liquidity",result:L.PASS,detail:`$${Q} on ${g.dex}`}),g.createdAt&&Date.now()-g.createdAt<24*3600*1e3&&(s.push({check:"age",result:L.CAUTION,detail:"pool under 24h old"}),o(L.CAUTION))}if(typeof this.sellSimulation=="function"){let g=await this.sellSimulation({token:r,amountIn:(10n**16n).toString()},n).catch(Q=>({verdict:L.UNKNOWN,reason:String(Q?.message||Q)}));s.push({check:"sellability",result:g.verdict,detail:g.retentionBps!=null?`round trip returns ${(g.retentionBps/100).toFixed(2)}% -- ${g.reason}`:g.reason}),o(g.verdict)}else s.push({check:"sellability",result:L.UNKNOWN,detail:"no verified router on this chain, so a round-trip sell simulation cannot run. Treat as unproven -- a buy path is not an exit path."}),o(L.UNKNOWN);return{chainId:A,token:r,verdict:i,checks:s,note:"Structural checks only. UNKNOWN is not PASS. A token is not tradeable until a sell simulation succeeds."}}}}function _c(e){let t={...vS(e)},r=new Set((e.venues||[]).map(s=>s.kind));e.venueKind==="uniswap-v3"&&r.has("quoter")&&r.has("router")?Object.assign(t,Wh({chainId:e.chainId,wrappedNative:e.wrappedNative})):e.venueKind==="uniswap-v2"&&r.has("router")&&Object.assign(t,Hh({chainId:e.chainId,wrappedNative:e.wrappedNative}));let n={};for(let[s,i]of Object.entries(t))n[s]=i.bind(t);return{key:e.key,chainId:e.chainId,name:e.name,rpcEnv:e.rpcEnv,nativeCurrency:e.nativeCurrency,explorer:e.explorer,venues:e.venues||[],capabilities:n}}var Zh=Object.freeze([{key:"ethereum",chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://etherscan.io",dexscreenerSlug:"ethereum",venueKind:"uniswap-v3",wrappedNative:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.71 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}}]},{key:"optimism",chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://optimistic.etherscan.io",dexscreenerSlug:"optimism",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1905.23 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}}]},{key:"bsc",chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],nativeCurrency:{symbol:"BNB",decimals:18},explorer:"https://bscscan.com",dexscreenerSlug:"bsc",venueKind:"uniswap-v3",wrappedNative:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",venues:[{kind:"quoter",address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WBNB->USDC fee 500 quoted 413.86 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}},{kind:"router",address:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}}]},{key:"polygon",chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],nativeCurrency:{symbol:"POL",decimals:18},explorer:"https://polygonscan.com",dexscreenerSlug:"polygon",venueKind:"uniswap-v3",wrappedNative:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WMATIC->USDC fee 500 quoted 0.0720 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}}]},{key:"stable",chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],nativeCurrency:{symbol:"USDT0",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x5d442b349590a6048Eb2dC0eC346cAA5F47A9ab5",venues:[{kind:"quoter",address:"0xb070179E7032CdA868b53e6C1742F80c9e940d1A",label:"Uniswap V3 QuoterV2 (canonical)",verified:{method:"Stable is on the OFFICIAL Uniswap v3 Deployments List (governance-recognised 2026-05-12, UAC process completed 2026-04, deployed by Protofire), so this is a canonical deployment rather than a fork. eth_getCode returned 8273 bytes, the same size as the canonical quoter on the seven already-verified chains. Functional probe on a live pool (TOAST -> USDT0, fee 10000): 100 in -> 0.000003, 1000 -> 0.000031, 10000 -> 0.000319 USDT0. Output scales monotonically with input, which is a working quoter answering, not a revert. Two of three sampled pools carry non-zero liquidity. NOTE: the pools discovered so far are thin, so real routing size is limited -- the venue is proved, deep liquidity is not.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:988}},{kind:"router",address:"0x32eaf9B5d5F2CD7361c5012890C943D7de84C22a",label:"Uniswap SwapRouter02 (canonical)",verified:{method:"eth_getCode returned 24497 bytes. Cross-checked on-chain rather than trusted from docs: router.factory() returns 0x88f0a512ef09175d456bc9547f914f48c013e4aa, the same v3 core factory that created the pools quoted above, and router.WETH9() returns the wrappedNative recorded on this chain entry. Address published in the Stable docs DEX reference and the Uniswap deployments list.",source:"docs.stable.xyz/en/reference/dexes + on-chain factory()/WETH9() round-trip",date:"2026-08-05",chainId:988}}]},{key:"hyperevm",chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],nativeCurrency:{symbol:"HYPE",decimals:18},dexscreenerSlug:"hyperevm",venueKind:"uniswap-v3",wrappedNative:"0x5555555555555555555555555555555555555555",venues:[{kind:"quoter",address:"0x03A918028f22D9E1473B7959C927AD7425A45C7C",label:"HyperSwap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle(1 WHYPE -> USDT0) returned live output on all four fee tiers (100: 57.3385, 500: 57.4187, 3000: 57.3237, 10000: 56.1963 USDT0). Decimals read on-chain: WHYPE 18, USDT0 6. Best tier checked against an INDEPENDENT control the same minute -- Hyperliquid allMids put HYPE at 57.3205, so the pool is 0.171% from the perp mid, which is the right shape for fee plus impact rather than a wrong contract or a decimals bug.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}},{kind:"router",address:"0x4E2960a8cd19B467b82d26D83fAcb0fAE26b094D",label:"HyperSwap V3 SwapRouter",verified:{method:"eth_getCode returned 12070 bytes, and it is the router paired with the quoter proved above -- the same pair already shipped in UNI_V3_VENUES[999].hyperswap, which is the map the quote/prepare path actually routes through.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}}]},{key:"abstract",chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x3439153EB7AF838Ad19d56E1571FBD09333C2809",venues:[{kind:"quoter",address:"0x728BD3eC25D5EDBafebB84F3d67367Cd9EBC7693",label:"Uniswap V3 QuoterV2 (Abstract deployment)",verified:{method:"Abstract is a ZK-stack chain, so CREATE2 addresses differ and the canonical Uniswap addresses are NOT valid here -- probing them returns codesize 0, which is what previously made this chain look like it had no V3 at all. Found the real deployment from live traffic instead: scanned recent Swap(...) logs, took the busiest pool, read pool.factory() = 0xa1160e73b63f322ae88cc2d8e700833e71d0b2a1, then enumerated that factory's deployer (0xf3d63166F0Ca56C3c1A3508FcE03Ff0Cf3Fb691e) and probed each of its 56 contracts with a real quoteExactInputSingle call. Exactly one answered: 1 WETH -> 1846.475731 USDC.e at fee 500. Independent sanity check: the pool's own slot0() spot price is 1873.11 USDC.e per WETH, so the quoter sits ~1.4% below spot, the right shape for fee plus price impact on this size.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:2741}},{kind:"router",address:"0x7712FA47387542819d4E35A23f8116C90C18767C",label:"Uniswap SwapRouter02 (Abstract deployment)",verified:{method:"eth_getCode returned 167392 bytes and the runtime contains the exactInputSingle selector. router.factory() matches the factory proved above and router.WETH9() matches the wrappedNative on this entry. Chosen over its byte-identical twin (0xfD6257F4...) because this is the address real users actually route through: it appeared as tx.to on live swaps against the WETH/USDC.e pool.",source:"on-chain factory()/WETH9() round-trip + live swap tx.to sampling",date:"2026-08-05",chainId:2741}}]},{key:"robinhood",chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC","ROBINHOOD_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},dexscreenerSlug:"robinhood",venueKind:"uniswap-v3",wrappedNative:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",venues:[{kind:"quoter",address:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDG fee 100 quoted 1866.58 USDG, and USDG->CASHCAT fee 10000 quoted a live amount). A contract that correctly prices known pairs IS a working V3 quoter",source:"live eth_call against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"router",address:"0xcaf681a66d020601342297493863e78c959e5cb2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode (24497 bytes) on this chain and the paired quoter at the same deployment passed a live functional quote",source:"live eth_getCode against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"factory",address:"0x1f7d7550b1b028f7571e69a784071f0205fd2efa",label:"Uniswap V3 Factory",verified:{method:"eth_getCode returned real bytecode (24535 bytes) and a PoolCreated log scan over this factory returned 76 pools in ~9000 recent blocks",source:"live eth_getLogs against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}}]},{key:"base",chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://basescan.org",dexscreenerSlug:"base",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",venues:[{kind:"quoter",address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",label:"Uniswap V3 QuoterV2 (Base)",verified:{method:"functional probe: quoteExactInputSingle returned WETH->USDC at fee 500 = 1908.44 USDC, a live sane price. The canonical mainnet quoter address also has bytecode on Base but does NOT price this pair, which is exactly the false positive a codesize-only check accepts",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router",address:"0x2626664c2603336E57B271c5C0b26F421741e481",label:"Uniswap V3 SwapRouter02 (Base)",verified:{method:"eth_getCode returned real bytecode and the paired Base quoter passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router-v2",address:"0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",label:"Uniswap V2 Router02 (Base)",verified:{method:"eth_getCode returned 17891 bytes; live getAmountsOut on WETH->USDC round-tripped to 98.75% (2x0.30% fee + impact)",source:"https://docs.uniswap.org/contracts/v2/reference/smart-contracts/v2-deployments",date:"2026-07-30",chainId:8453}}]},{key:"arbitrum",chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://arbiscan.io",dexscreenerSlug:"arbitrum",venueKind:"uniswap-v3",wrappedNative:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.72 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}}]},{key:"avalanche",chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],nativeCurrency:{symbol:"AVAX",decimals:18},explorer:"https://snowtrace.io",dexscreenerSlug:"avalanche",venueKind:"uniswap-v3",wrappedNative:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",venues:[{kind:"quoter",address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WAVAX->USDC fee 500 quoted 6.48 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}},{kind:"router",address:"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}}]}]);function HS(){return Zh.map(e=>ui(_c(e)))}function VS(e){return ui(_c(e))}export{Zh as CHAIN_CONFIGS,G as EVIDENCE,L as RISK,Ir as SCANNER_CAPABILITIES,PS as __clearScanners,rd as createScanner,WS as getScanner,OS as listScanners,HS as registerBuiltinScanners,VS as registerCustomChain,ui as registerScanner,ZS as scannerCoverage,td as validateScanner};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oracle-agent/oracle",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.10",
|
|
4
4
|
"description": "Oracle: standalone multichain agent control plane with an optional encrypted, loopback-only self-hosted signer.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"type": "module",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"@noble/hashes": "^2.2.0",
|
|
68
68
|
"@scure/base": "^2.2.0",
|
|
69
69
|
"@scure/btc-signer": "2.3.0",
|
|
70
|
+
"@solana/addresses": "^7.0.0",
|
|
70
71
|
"@solana/transaction-messages": "7.0.0",
|
|
71
72
|
"ethers": "^6.16.0",
|
|
72
73
|
"sharp": "^0.35.3",
|
|
@@ -26,16 +26,16 @@ section{padding-top:72px;scroll-margin-top:90px}.sub{color:var(--muted);line-hei
|
|
|
26
26
|
<nav class="nav"><div class="nav-inner"><a class="brand" href="/"><span class="mark" aria-hidden="true"></span>oracle</a><a class="back" href="/">Back to site</a></div></nav>
|
|
27
27
|
<main class="wrap">
|
|
28
28
|
<header><p class="eyebrow">Public release</p><h1>Install Oracle.<br><em>Hosted wallets sign outside Oracle.</em></h1><p class="lede">The CLI, desktop beta, source, research tools, and unsigned transaction preparation are public to everyone. No wallet connection or NFT is required to download or run Oracle.</p></header>
|
|
29
|
-
<aside class="policy"><h2>Locals Only means 0% Oracle fees</h2><p>A Locals Only NFT waives the <b>Oracle integrator fee</b>. It does not unlock the product,
|
|
29
|
+
<aside class="policy"><h2>Locals Only means 0% Oracle fees</h2><p>A Locals Only NFT waives the <b>Oracle integrator fee</b>. It does not unlock the product, waive provider or network costs, or change the hosted/keyless custody boundary. Self-host execution uses the local signer.</p></aside>
|
|
30
30
|
<section id="cli"><p class="eyebrow">Oracle CLI</p><h2>Install with curl</h2><p class="sub">One line. Linux and macOS. Requires Node 20.19+ (the script checks and tells you how to get it). Installs into <code>~/.local</code> — no sudo, no global npm.</p><div class="install"><div class="cmd"><code id="cmd">curl -fsSL https://oracle.demi.la/install.sh | bash</code><button class="copy" id="copy" type="button">Copy</button></div><div class="meta"><span>curl install</span><span>hosted keyless</span><span>hosted wallet signs</span><span>user prefix</span></div></div><p class="sub" style="margin-top:18px">npm still works if you prefer: <code>npm i -g @oracle-agent/oracle</code></p></section>
|
|
31
31
|
<section id="windows"><p class="eyebrow">Oracle app · Windows</p><h2>Install with PowerShell</h2><p class="sub">Same shape as Hermes: one line. Installs the CLI (<code>npm i -g @oracle-agent/oracle</code>) and the desktop NSIS build. SHA-256 checked. Never asks for a key or seed.</p><div class="install"><div class="cmd"><code id="cmd-win">iex (irm https://oracle.demi.la/install.ps1)</code><button class="copy" id="copy-win" type="button">Copy</button></div><div class="meta"><span>irm | iex</span><span>desktop app</span><span>SHA-256 checked</span></div></div></section>
|
|
32
32
|
<section id="desktop"><p class="eyebrow">Desktop beta · 0.4.3</p><h2>Native installers</h2><p class="sub">Each installer bundles the same public runtime. Download directly, then verify it against the published SHA-256 manifest.</p><div class="artifacts">
|
|
33
33
|
<div class="artifact" data-artifact="Oracle-0.4.3.AppImage"><div><h3>Linux</h3><small>AppImage · x64</small></div><div class="artifact-meta"><span class="build">Oracle 0.4.3 beta</span></div><code class="hash" data-hash>checksum loading</code><a class="dl-btn" href="/downloads/artifacts/Oracle-0.4.3.AppImage" download>Download</a></div>
|
|
34
34
|
<div class="artifact" data-artifact="Oracle-0.4.3-arm64.dmg"><div><h3>macOS</h3><small>DMG · Apple silicon</small></div><div class="artifact-meta"><span class="build">Oracle 0.4.3 beta</span></div><code class="hash" data-hash>checksum loading</code><a class="dl-btn" href="/downloads/artifacts/Oracle-0.4.3-arm64.dmg" download>Download</a></div>
|
|
35
35
|
<div class="artifact" data-artifact="Oracle-Setup-0.4.3.exe"><div><h3>Windows</h3><small>NSIS installer · x64</small></div><div class="artifact-meta"><span class="build">Oracle 0.4.3 beta</span></div><code class="hash" data-hash>checksum loading</code><a class="dl-btn" href="/downloads/artifacts/Oracle-Setup-0.4.3.exe" download>Download</a></div>
|
|
36
|
-
</div><p class="platform-note">Checksums: <a class="checksum" href="/downloads/artifacts/SHA256SUMS.txt">SHA256SUMS.txt</a>. Beta installers may trigger macOS Gatekeeper or Windows SmartScreen when a build is not notarized or CA-signed. The installer never asks for a private key or seed. Hosted/
|
|
36
|
+
</div><p class="platform-note">Checksums: <a class="checksum" href="/downloads/artifacts/SHA256SUMS.txt">SHA256SUMS.txt</a>. Beta installers may trigger macOS Gatekeeper or Windows SmartScreen when a build is not notarized or CA-signed. The installer never asks for a private key or seed. Hosted/keyless cannot hold keys. Self-host signer setup is a separate command.</p></section>
|
|
37
37
|
</main>
|
|
38
|
-
<footer><div class="nav-inner"><span>oracle · locals only labs</span><span>public / self-custody /
|
|
38
|
+
<footer><div class="nav-inner"><span>oracle · locals only labs</span><span>public / self-custody / local signer</span></div></footer>
|
|
39
39
|
<script>
|
|
40
40
|
document.getElementById("copy").addEventListener("click",async function(){try{await navigator.clipboard.writeText(document.getElementById("cmd").textContent.trim());this.textContent="Copied";var button=this;setTimeout(function(){button.textContent="Copy"},1400)}catch(_){this.textContent="Select command"}});
|
|
41
41
|
document.getElementById("copy-win").addEventListener("click",async function(){try{await navigator.clipboard.writeText(document.getElementById("cmd-win").textContent.trim());this.textContent="Copied";var button=this;setTimeout(function(){button.textContent="Copy"},1400)}catch(_){this.textContent="Select command"}});
|