@direct.dev/sdk 1.0.0 → 1.0.2

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/lib/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- var m0=Object.defineProperty;var o=(t,e)=>m0(t,"name",{value:e,configurable:!0});var Bi,Za,eo,to,ro,so,no,io,ao,oo,co,lo,ho,uo,fo,po,mo,go,wo,vo,_o,yo,bo,$o,ko,Co,So,Ao,Eo,Mo,To,Ro,Bo,Io,qo,Po,xo,Wo,Uo,Do,Oo,jo,No,Ii,Lo,Fo,zo,Ho,Ko,Go,Vo,Yo,Jo,Xo,Qo,Zo,ec,tc,rc,sc,nc,ic,ac,qi;const g0={"content-type":"application/json"},w0="x-direct-timing-ms",v0=new Set(["rpc.direct.dev","staging.rpc.direct.dev","prod.rpc.direct.dev"]),tw=typeof TextEncoder<"u"?new TextEncoder:null,_0="direct/sdk requires a global fetch implementation.",y0="direct/sdk requires a global Response implementation.",b0="direct/sdk requires a global Request implementation.";var $0=Object.defineProperty,af=o((t,e)=>$0(t,"name",{value:e,configurable:!0}),"r$B");function Zl(t,e){const r=t.length,s=r-e.length;if(s!==0)return s>0?1:-1;for(let n=2;n<r;n++){const i=(t.charCodeAt(n)|32)-(e.charCodeAt(n)|32);if(i!==0)return i>0?1:-1}return 0}o(Zl,"i$v"),af(Zl,"compareBlockHeights");function xn(t,e){return Zl(t,e)===1}o(xn,"u$I"),af(xn,"isBlockHeightAhead");function rw(t,e){return Zl(t,e)===-1}o(rw,"l$K"),af(rw,"isBlockHeightBehind");var k0=Object.defineProperty,sw=o((t,e)=>k0(t,"name",{value:e,configurable:!0}),"l$J");const C0=4294967295;function of(t,e,r=C0){const s=Zl(t,e);if(s===0)return 0;if(s===1)return-of(e,t,r);let n=0,i=1;const a=e.length-t.length;for(let c=e.length-1;c>=2;c--){const h=cf(e.charCodeAt(c)),u=c-a>=2?cf(t.charCodeAt(c-a)):0;if(n+=(h-u)*i,i*=16,n>r)return r}return n}o(of,"f$C"),sw(of,"getBlockHeightDiff");function cf(t){return t>=48&&t<=57?t-48:(t|32)-97+10}o(cf,"h$A"),sw(cf,"hexCharToValue");var S0=Object.defineProperty,A0=o((t,e)=>S0(t,"name",{value:e,configurable:!0}),"E$A");function lf(t){if(t.length<3||t.charCodeAt(0)!==48||t.charCodeAt(1)!==120)return!1;if(t==="0x0")return!0;if(t.charCodeAt(2)===48)return!1;for(let e=2,r=t.length;e<r;e++){const s=t.charCodeAt(e);if(s>=48&&s<=57)continue;const n=s|32;if(!(n>=97&&n<=102))return!1}return!0}o(lf,"R$m"),A0(lf,"isBlockHeight");var E0=Object.defineProperty,Ar=o((t,e)=>E0(t,"name",{value:e,configurable:!0}),"i$u");function hf(t,e){const r=nw(t);if(r)return r;if(!(!("error"in e)||!e.error))return iw(e.error)}o(hf,"d$y"),Ar(hf,"classifyResponseError");function nw(t){if(!(t>=200&&t<300))return t===408||t===504?"timeout":t===429?"rate_limit":t>=500?"node_error":t>=400&&t<500?"client_error":"unknown"}o(nw,"f$B"),Ar(nw,"classifyHttpStatus");function iw(t){const{code:e,message:r}=t,s=r.toLowerCase();if(cw(s))return"node_error";if(e>=-32099&&e<=-32e3)return aw(s);switch(e){case-32700:case-32600:case-32601:case-32602:return"client_error";case-32603:return"node_error";case 26:return"node_error"}return e<=-84e3&&e>=-84999?"client_error":e<=-85e3&&e>=-85999?e===-85040?"timeout":"node_error":uf(s)?"timeout":df(s)?"rate_limit":ow(s)?"node_error":ff(s)?"client_error":"unknown"}o(iw,"a$F"),Ar(iw,"classifyRpcError");function aw(t){return uf(t)?"timeout":df(t)?"rate_limit":ff(t)?"client_error":"node_error"}o(aw,"_$u"),Ar(aw,"classifyServerError");function uf(t){return t.includes("timeout")||t.includes("timed out")||t.includes("deadline exceeded")}o(uf,"u$H"),Ar(uf,"isTimeoutMessage");function df(t){return t.includes("rate limit")||t.includes("too many requests")||t.includes("throttl")||t.includes("capacity exceeded")}o(df,"o$z"),Ar(df,"isRateLimitMessage");function ow(t){return t.includes("syncing")||t.includes("not synced")||t.includes("unavailable")||t.includes("service unavailable")||t.includes("connection refused")||t.includes("connection reset")||t.includes("internal error")||t.includes("backend error")}o(ow,"s$B"),Ar(ow,"isNodeErrorMessage");function cw(t){return t.includes("greater than latest block")||t.includes("please limit the query")||t.includes("reduce your block range")||t.includes("max block range")||t.includes("block range")&&(t.includes("too wide")||t.includes("exceed")||t.includes("limit"))}o(cw,"h$z"),Ar(cw,"isProviderCapabilityMessage");function ff(t){return t.includes("nonce too low")||t.includes("nonce too high")||t.includes("insufficient funds")||t.includes("gas too low")||t.includes("intrinsic gas")||t.includes("execution reverted")||t.includes("invalid params")||t.includes("invalid argument")||t.includes("missing argument")||t.includes("too many logs")||t.includes("response size exceeded")||t.includes("query returned more than")||t.includes("limit exceeded: more than")||t.includes("unknown block")||t.includes("block not found")}o(ff,"c$O"),Ar(ff,"isClientErrorMessage");function lw(t){return t==="rate_limit"||t==="node_error"}o(lw,"k$j"),Ar(lw,"shouldRetry");function hw(t){return t==="timeout"||t==="rate_limit"||t==="node_error"}o(hw,"y$s"),Ar(hw,"shouldTripBreaker");var M0=Object.defineProperty,pf=o((t,e)=>M0(t,"name",{value:e,configurable:!0}),"l$H");const rt=10,eh={lo32:0,hi32:0};function mf(t){const e=t.length;let r=52210,s=40164,n=33826,i=8997;for(let a=0;a<e;a++){const c=t.charCodeAt(a);i^=c,r=Math.imul(r,435)+(n<<8),s=Math.imul(s,435)+(i<<8),n=Math.imul(n,435),i=Math.imul(i,435),r=r+(s>>>16)&65535,s=s+(n>>>16)&65535,n=n+(i>>>16)&65535,i&=65535}eh.lo32=(n<<16|i)>>>0,eh.hi32=(r<<16|s)>>>0}o(mf,"i$t"),pf(mf,"fnv1a_raw");function ys(t){mf(t);const{lo32:e,hi32:r}=eh;return String.fromCharCode(e&15,e>>>4&127,e>>>11&127,e>>>18&127,e>>>25&127,r&127,r>>>7&127,r>>>14&127,r>>>21&127,r>>>28)}o(ys,"M$m"),pf(ys,"fnv1a");const Er="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function uw(t){mf(t);const{lo32:e,hi32:r}=eh;return Er.charAt(e&63)+Er.charAt(e>>>6&63)+Er.charAt(e>>>12&63)+Er.charAt(e>>>18&63)+Er.charAt(e>>>24&63)+Er.charAt((e>>>30|r<<2)&63)+Er.charAt(r>>>4&63)+Er.charAt(r>>>10&63)+Er.charAt(r>>>16&63)+Er.charAt(r>>>22&63)+Er.charAt(r>>>28&15)}o(uw,"_$t"),pf(uw,"fnv1a_b64");const cc=new TextEncoder,gf=new TextDecoder;var T0=Object.defineProperty,R0=o((t,e)=>T0(t,"name",{value:e,configurable:!0}),"r$A");const dw=16,Mt=37;async function fw(t){const e=await crypto.subtle.digest("SHA-256",cc.encode(t)),r=new Uint8Array(e);return String.fromCharCode(dw|r[0]>>4,(r[0]<<3|r[1]>>5)&127,(r[1]<<2|r[2]>>6)&127,(r[2]<<1|r[3]>>7)&127,r[3]&127,r[4]>>1,(r[4]<<6|r[5]>>2)&127,(r[5]<<5|r[6]>>3)&127,(r[6]<<4|r[7]>>4)&127,(r[7]<<3|r[8]>>5)&127,(r[8]<<2|r[9]>>6)&127,(r[9]<<1|r[10]>>7)&127,r[10]&127,r[11]>>1,(r[11]<<6|r[12]>>2)&127,(r[12]<<5|r[13]>>3)&127,(r[13]<<4|r[14]>>4)&127,(r[14]<<3|r[15]>>5)&127,(r[15]<<2|r[16]>>6)&127,(r[16]<<1|r[17]>>7)&127,r[17]&127,r[18]>>1,(r[18]<<6|r[19]>>2)&127,(r[19]<<5|r[20]>>3)&127,(r[20]<<4|r[21]>>4)&127,(r[21]<<3|r[22]>>5)&127,(r[22]<<2|r[23]>>6)&127,(r[23]<<1|r[24]>>7)&127,r[24]&127,r[25]>>1,(r[25]<<6|r[26]>>2)&127,(r[26]<<5|r[27]>>3)&127,(r[27]<<4|r[28]>>4)&127,(r[28]<<3|r[29]>>5)&127,(r[29]<<2|r[30]>>6)&127,(r[30]<<1|r[31]>>7)&127,r[31]&127)}o(fw,"i$s"),R0(fw,"sha256");var B0=Object.defineProperty,I0=o((t,e)=>B0(t,"name",{value:e,configurable:!0}),"u$G");function xi(t){if(t==null)return t===void 0?"undefined":"null";switch(typeof t){case"boolean":case"undefined":case"number":return""+t;case"string":return t;case"object":{if(Array.isArray(t)){let s="";for(let n=0,i=t.length;n<i;n++)s+=(n>0?",":"")+xi(t[n]);return s}const e=[];for(const s in t)t[s]!==void 0&&e.push(s);e.sort();let r="";for(let s=0,n=e.length;s<n;s++){const i=e[s];r+=(s>0?"|":"")+i+":"+xi(t[i])}return r}}throw new Error("sortObject(): Only JSON serializeable structures are allowed")}o(xi,"l$G"),I0(xi,"sortObject");var q0=Object.defineProperty,pw=o((t,e)=>q0(t,"name",{value:e,configurable:!0}),"r$z");function mw(t,e){switch(e){case"eth_getBlockByNumber":case"eth_getBlockTransactionCountByNumber":case"eth_getTransactionByBlockNumberAndIndex":case"eth_getUncleByBlockNumberAndIndex":case"eth_getUncleCountByBlockNumber":return t.params[0];case"eth_call":case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":return t.params[1];case"eth_getStorageAt":return t.params[2];default:return}}o(mw,"h$y"),pw(mw,"getBlockHeightParam");function gw(t,e,r){const s=e,n=t.params;switch(s){case"eth_getBlockByNumber":case"eth_getBlockTransactionCountByNumber":case"eth_getTransactionByBlockNumberAndIndex":case"eth_getUncleByBlockNumberAndIndex":case"eth_getUncleCountByBlockNumber":{const i=n.slice();return i[0]=r,{...t,params:i}}case"eth_call":case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":{const i=n.slice();return i[1]=r,{...t,params:i}}case"eth_getStorageAt":{const i=n.slice();return i[2]=r,{...t,params:i}}default:return t}}o(gw,"l$F"),pw(gw,"setBlockHeightParam");var P0=Object.defineProperty,wf=o((t,e)=>P0(t,"name",{value:e,configurable:!0}),"o$x");function Wi(t){if(Array.isArray(t)){const e=t.length;if(e===0)return th;let r=th+e-1;for(let s=0;s<e;s++)r+=vf(t[s]);return r}return vf(t)}o(Wi,"R$l"),wf(Wi,"estimateJsonRpcSize");function vf(t){if(t===void 0)return 0;if("result"in t){let r=W0;return r+=String(t.id).length,r+=Ui(t.result),r}if("error"in t){let r=U0;return r+=String(t.id).length,r+=String(t.error.code).length,r+=String(t.error.message).length,r+=t.error.data?D0+Ui(t.error.data):0,r}let e=x0;return e+=t.method.length,e+=String(t.id).length,e+=Ui(t.params),e}o(vf,"c$K"),wf(vf,"estimateObjectSize");function Ui(t){switch(t){case null:return 4;case!0:return 4;case!1:return 5}switch(typeof t){case"number":return String(t).length;case"string":return t.length+N0}if(Array.isArray(t)){const e=t.length;if(e===0)return th;let r=th+e-1;for(let s=0;s<e;s++)r+=Ui(t[s]);return r}if(typeof t=="object"&&t!==null){let e=0,r=O0;for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r+=j0+s.length+Ui(t[s]),e++);return e>0&&r--,r}return 0}o(Ui,"s$z"),wf(Ui,"estimateJsonSize");const x0=45,W0=33,U0=54,D0=8,th=2,O0=2,j0=4,N0=2;var L0=Object.defineProperty,je=o((t,e)=>L0(t,"name",{value:e,configurable:!0}),"n$z");const F0=25e4,ww=12,bs=1+rt,$s=1+Mt+rt,rh=rt,Di=bs+rh,Oi=$s+rh,vw=new Set(["eth_call","eth_chainId","eth_gasPrice","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleByBlockHashAndIndex","eth_getUncleByBlockNumberAndIndex","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","net_version"]),_w=new Set(["eth_gasPrice"]),yw=new Set([...vw,"direct_getTransactionReceipt","eth_accounts","eth_blockNumber","eth_coinbase","eth_estimateGas","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_hashrate","eth_mining","eth_protocolVersion","eth_syncing","net_listening","net_peerCount","net_version","web3_clientVersion","web3_sha3","debug_traceTransaction","debug_traceCall","debug_traceBlockByNumber","debug_traceBlockByHash","debug_getBadBlocks","debug_storageRangeAt","debug_getModifiedAccountsByNumber","debug_getModifiedAccountsByHash","trace_call","trace_callMany","trace_rawTransaction","trace_replayBlockTransactions","trace_replayTransaction","trace_block","trace_filter","trace_get","trace_transaction"]),z0=new Set([...yw,"eth_sendRawTransaction"]),Tt=1,sh=1,bw=0<<sh,H0=1<<sh,$w=2<<sh,_f=3<<sh,yf=6,Xs=8,kw=16,Cw=32,Sw=64,kt={flags:0,isTiedToBlock:!1,hashInput:""};function nh(t,e,r,s=ww){const{flags:n,hashInput:i}=bf(t,e,r,s);return String.fromCharCode(n)+ys(i)}o(nh,"Y$8"),je(nh,"makeRequestFingerprint");async function Aw(t,e,r,s=ww){const{flags:n,hashInput:i}=bf(t,e,r,s),a=await fw(i),c=ys(i);return String.fromCharCode(n|Tt)+a+c}o(Aw,"X$c"),je(Aw,"makeRequestFingerprintWithChecksum");function bf(t,e,r,s){const n=mw(t,e);kt.flags=bw,kt.isTiedToBlock=!1;let i;switch(n){case"latest":case"finalized":case"safe":{kt.flags|=Xs,kt.isTiedToBlock=!0;break}case"pending":case"earliest":case void 0:break;case r:kt.flags|=Xs,kt.isTiedToBlock=!0,i="latest";break;default:{if(r){const c=of(n,r,s+1);c>0&&c<=s&&(kt.flags|=Xs,kt.isTiedToBlock=!0,i="latest")}break}}if(yw.has(e)&&(kt.flags|=Cw),z0.has(e)&&(kt.flags|=Sw),vw.has(e)&&n!=="pending"){if(Ew(e,t,i??n)){const c=Mw(e,i??n);kt.flags|=c?_f:$w}else kt.flags|=H0;_w.has(e)&&(kt.flags|=kw)}const a=i!==void 0?gw(t,e,i):t;return kt.hashInput=a.method+xi(a.params),kt}o(bf,"U$i"),je(bf,"analyzeRequest");function Ft(t,e){return!lc(t)||e===void 0?t:t+e}o(Ft,"j$g"),je(Ft,"hydrateRequestFingerprint");function Ew(t,e,r){var s;if(Wi(e)>F0)return!1;if(t==="eth_getBlockByNumber"){const n=r==="latest"||r==="pending",i=((s=e.params)==null?void 0:s[1])===!0;return!(n&&i)}return!0}o(Ew,"J$d"),je(Ew,"analyzeRevalidationEligibility");function Mw(t,e){return t==="eth_getBlockByNumber"?e!=="latest"&&e!=="pending":!_w.has(t)}o(Mw,"Z$8"),je(Mw,"analyzeSyncEligibility");function ih(t){return(t.charCodeAt(0)&Tt)!==0}o(ih,"C$o"),je(ih,"hasRequestChecksum");function K0(t){if(ih(t))return t.slice(1,1+Mt)}o(K0,"$$g"),je(K0,"extractRequestChecksum");function $f(t){if(!ih(t))return t;const e=t.charCodeAt(0)&~Tt;return String.fromCharCode(e)+t.slice(1+Mt)}o($f,"ee$6"),je($f,"stripRequestChecksum");function G0(t,e){const r=t.charCodeAt(0)|Tt,s=t.slice(1);return String.fromCharCode(r)+e+s}o(G0,"te$6"),je(G0,"addRequestChecksum");function kf(t){return(t.charCodeAt(0)&yf)!==bw}o(kf,"ne$7"),je(kf,"isRequestCacheable");function V0(t){return(t.charCodeAt(0)&kw)!==0}o(V0,"ae$3"),je(V0,"isRequestVolatile");function Y0(t){const e=t.charCodeAt(0)&yf;return e===$w||e===_f}o(Y0,"ce$3"),je(Y0,"isEligibleForRevalidation");function J0(t){return(t.charCodeAt(0)&yf)===_f}o(J0,"se$5"),je(J0,"isEligibleForSync");function lc(t){return(t.charCodeAt(0)&Xs)!==0}o(lc,"E$y"),je(lc,"isRequestTiedToBlock");function ah(t){return(t.charCodeAt(0)&Cw)!==0}o(ah,"oe$3"),je(ah,"isRequestDeduplicatable");function X0(t){return(t.charCodeAt(0)&Sw)!==0}o(X0,"re$3"),je(X0,"isRequestRaceable");function Cf(t){return ih(t)?$s:bs}o(Cf,"H$f"),je(Cf,"getFingerprintLength");function Tw(t){const e=Cf(t);return lc(t)?e+rh:e}o(Tw,"K$c"),je(Tw,"getExpectedKeyLength");function Mr(t){return t.length===Tw(t)}o(Mr,"ie$7"),je(Mr,"isRequestKey");function oh(t){return t.slice(0,Cf(t))}o(oh,"le$3"),je(oh,"extractRequestFingerprint");function Sf(t){if(lc(t))return t.slice(-rh)}o(Sf,"ue$1"),je(Sf,"extractBlockDigest");var Q0=Object.defineProperty,Z0=o((t,e)=>Q0(t,"name",{value:e,configurable:!0}),"e$l");function ji(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}o(ji,"t$g"),Z0(ji,"isRecord");var eC=Object.defineProperty,hc=o((t,e)=>eC(t,"name",{value:e,configurable:!0}),"r$y");const tC=25e4,ch=1+rt,Rw=1;function Af(t){return"result"in t?typeof t.result=="string"?ys("string:"+t.result):ys("result:"+xi(t.result)):ys("error:"+xi(t.error))}o(Af,"s$y"),hc(Af,"makeResponseDigest");function Bw(t){return t.slice(1)}o(Bw,"B$l"),hc(Bw,"extractResponseKeyDigest");function Ef(t,e,r){const s=Iw(t,e,r),n=Af(t);return String.fromCharCode(s?Rw:0)+n}o(Ef,"E$x"),hc(Ef,"makeResponseKey");function Iw(t,e,r){if(!("result"in t)||t.result==="0x"||((r==null?void 0:r.length)??Wi(t))>=tC)return!1;if(!e)return!0;switch(e){case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getUncleByBlockHashAndIndex":case"eth_getUncleByBlockNumberAndIndex":return ji(t.result)&&t.result.number!=null&&t.result.hash!=null&&t.result.nonce!=null;case"eth_getTransactionByHash":case"eth_getTransactionByBlockHashAndIndex":case"eth_getTransactionByBlockNumberAndIndex":return ji(t.result)&&t.result.blockNumber!=null&&t.result.blockHash!=null&&t.result.nonce!=null;case"eth_getTransactionReceipt":return t.result!=null}return!0}o(Iw,"y$q"),hc(Iw,"analyzeResponseEligibility");function Mf(t){return(t.charCodeAt(0)&Rw)!==0}o(Mf,"A$q"),hc(Mf,"isResponseCacheable");var rC=Object.defineProperty,qw=o((t,e)=>rC(t,"name",{value:e,configurable:!0}),"r$x");function Wn(t){switch(t.method){case"eth_getLogs":return!0;case"eth_getBlockByNumber":case"eth_getBlockByHash":return Array.isArray(t.params)&&t.params[1]===!0;case"eth_getCode":case"eth_getProof":return!0}const e=t.method.slice(0,6);return e==="trace_"||e==="debug_"}o(Wn,"s$x"),qw(Wn,"isSlowRPCRequest");function Pw(t){return Wn(t)}o(Pw,"o$w"),qw(Pw,"shouldBypassWireRPCRequest");var sC=Object.defineProperty,nC=o((t,e)=>sC(t,"name",{value:e,configurable:!0}),"i$q");function xw(t){const e=new Set;for(const r of t)if(r.id!==void 0){if(e.has(r.id))return!0;e.add(r.id)}return!1}o(xw,"r$w"),nC(xw,"hasDuplicateIds");var iC=Object.defineProperty,aC=o((t,e)=>iC(t,"name",{value:e,configurable:!0}),"o$u");const oC={BAD_REQUEST:{code:-84e3,message:"Invalid request signature (Direct.dev)"},BAD_DIRECT_METHOD:{code:-84001,message:"Request method not supported (Direct.dev)"},REQUEST_LIMIT_EXCEEDED:{code:-84002,message:"Request exceeds configured limits (Direct.dev)"},NO_RESPONSE:{code:-85e3,message:"Failed to receive response (Direct.dev)"},SERVER_ERROR:{code:-85001,message:"An internal server error occurred (Direct.dev)"},UPSTREAM_ERROR:{code:-85020,message:"Upstream JSON-RPC node failed (Direct.dev)"},UPSTREAM_TIMEOUT:{code:-85040,message:"JSON-RPC reqiest timed out (Direct.dev)"}};function ks(t,e,r){const s=oC[e];return{id:t,error:{code:s.code,message:s.message,data:r}}}o(ks,"E$w"),aC(ks,"makeErrorResponse");var cC=Object.defineProperty,lC=o((t,e)=>cC(t,"name",{value:e,configurable:!0}),"c$H");const Tf=new Set(["direct_getTransactionReceipt","eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_coinbase","eth_estimateGas","eth_gasPrice","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleByBlockHashAndIndex","eth_getUncleByBlockNumberAndIndex","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_hashrate","eth_mining","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_protocolVersion","eth_sendRawTransaction","eth_sendTransaction","eth_sign","eth_signTransaction","eth_syncing","eth_uninstallFilter","net_listening","net_peerCount","net_version","web3_clientVersion","web3_sha3","debug_traceTransaction","debug_traceCall","debug_traceBlockByNumber","debug_traceBlockByHash","debug_getBadBlocks","debug_storageRangeAt","debug_getModifiedAccountsByNumber","debug_getModifiedAccountsByHash","trace_call","trace_callMany","trace_rawTransaction","trace_replayBlockTransactions","trace_replayTransaction","trace_block","trace_filter","trace_get","trace_transaction","other"]);function lh(t){if(Tf.has(t))return t;const e=t.indexOf("_");if(e>0){const r="eth"+t.slice(e);if(Tf.has(r))return r}return"other"}o(lh,"o$t"),lC(lh,"normalizeRPCMethod");var hC=Object.defineProperty,Rf=o((t,e)=>hC(t,"name",{value:e,configurable:!0}),"r$u");function Ww(t,e){var r,s;const n=new AbortController,i=setTimeout(()=>n.abort(),t.timeoutMs),a=Rf(()=>n.abort(),"onParentAbort");(r=t.parentSignal)!=null&&r.aborted?n.abort():(s=t.parentSignal)==null||s.addEventListener("abort",a);const c=Rf(()=>{var h;clearTimeout(i),(h=t.parentSignal)==null||h.removeEventListener("abort",a),n.signal.removeEventListener("abort",c)},"cleanup");return n.signal.addEventListener("abort",c),e(n).finally(c)}o(Ww,"u$E"),Rf(Ww,"withAbortController");var uC=Object.defineProperty,Un=o((t,e)=>uC(t,"name",{value:e,configurable:!0}),"r$t");const Bf=Symbol("deferred not resolved"),dC=Symbol("deferred not rejected");function Ge(){let t,e,r="pending",s=Bf,n=dC;const i=new Promise((a,c)=>{t=a,e=c});return Object.assign(i,{__state:Un(()=>r,"__state"),__resolvedWith:Un(()=>s,"__resolvedWith"),__rejectedWith:Un(()=>n,"__rejectedWith"),__isFulfilled:Un(()=>r!=="pending","__isFulfilled"),__resolve:Un(a=>{if(r!=="pending")throw new Error(`makeDeferred(): Cannot resolve a promise that is already ${r}`);return r="resolved",s=a,t(a),i},"__resolve"),__reject:Un(a=>{if(r!=="pending")throw new Error(`makeDeferred(): Cannot reject a promise that is already ${r}`);return r="rejected",n=a,e(a),i},"__reject")})}o(Ge,"f$x"),Un(Ge,"makeDeferred");var fC=Object.defineProperty,Uw=o((t,e)=>fC(t,"name",{value:e,configurable:!0}),"u$D");function Rt(t,e,r){return typeof t=="object"&&t!=null&&"then"in t?r!=null?t.then(e,r):t.then(e):e(t)}o(Rt,"h$w"),Uw(Rt,"mapMaybePromise");function Ni(t,e,r){if(r==null)return Rt(t(),e);let s;try{s=t()}catch(n){return r(n)}return Rt(s,e,r)}o(Ni,"M$k"),Uw(Ni,"mapMaybeAsync");var pC=Object.defineProperty,Dw=o(t=>{throw TypeError(t)},"z$i"),hh=o((t,e)=>pC(t,"name",{value:e,configurable:!0}),"g$q"),If=o((t,e,r)=>e.has(t)||Dw("Cannot "+r),"m$y"),T=o((t,e,r)=>(If(t,e,"read from private field"),r?r.call(t):e.get(t)),"s$v"),ar=o((t,e,r)=>e.has(t)?Dw("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"f$v"),Zr=o((t,e,r,s)=>(If(t,e,"write to private field"),e.set(t,r),r),"d$v"),mC=o((t,e,r)=>(If(t,e,"access private method"),r),"A$p"),Ow=o((t,e,r,s)=>({set _(n){Zr(t,e,n)},get _(){return T(t,e,s)}}),"B$k"),uc,zt,ht,Qs,es,Ht,uh,Kt,dh,fh,Li,qf,jw;const Nw=16,gC=Nw-1,Lw=(Bi=class{constructor(e,r){if(ar(this,qf),ar(this,uc),ar(this,zt,Ge()),ar(this,ht,new Array(Nw)),ar(this,Qs,gC),ar(this,es,0),ar(this,Ht,0),ar(this,uh,null),ar(this,Kt,null),ar(this,dh),ar(this,fh),ar(this,Li),Zr(this,uc,e.maxBufferSize??512),Zr(this,dh,e.onEarlyDisposal),Zr(this,fh,e.onBackpressure??Pf),r){const s=new AbortController;Zr(this,Li,()=>{var n;s.abort(),(n=e.onClose)==null||n.call(e)}),r(n=>this.push(n),s.signal).then(n=>{this.isClosed||this.close(n)}).catch(n=>{this.isClosed||this.throw(n)})}else Zr(this,Li,()=>{var s;(s=e.onClose)==null||s.call(e)});T(this,zt).catch(()=>{})}tap(e){Zr(this,uh,e)}push(e){var r;if(T(this,zt).__isFulfilled())throw new Error("PushableAsyncGenerator.push(): Generator is already closed");if((r=T(this,uh))==null||r.call(this,e),T(this,Ht)>=T(this,es)+T(this,ht).length){if(T(this,ht).length>=T(this,uc)){this.close(null),T(this,fh).call(this);return}mC(this,qf,jw).call(this)}const s=Ow(this,Ht)._++&T(this,Qs);if(T(this,Ht)>T(this,es)&&(T(this,ht)[s]=Ge()),T(this,ht)[s].__resolve({done:!1,value:e}),T(this,Kt)){const n=T(this,Kt);for(let i=0,a=n.length;i<a;i++)n[i].push(e)}}close(e){if(T(this,zt).__isFulfilled())throw new Error("PushableAsyncGenerator.close(): Generator is already closed");const r={done:!0,value:e};if(T(this,es)>T(this,Ht)&&T(this,ht)[T(this,Ht)&T(this,Qs)].__resolve(r),T(this,zt).__resolve(r),T(this,Kt)){const s=T(this,Kt);for(let n=0,i=s.length;n<i;n++){const a=s[n];a.isClosed||a.close(e)}}T(this,Li).call(this)}tee(e){const r=typeof e=="function"?{onEarlyDisposal:e}:e,s=new Bi({maxBufferSize:T(this,uc),onClose:hh(()=>{var n,i;Zr(this,Kt,((n=T(this,Kt))==null?void 0:n.filter(a=>a!==s))??[]),(i=r==null?void 0:r.onClose)==null||i.call(r)},"onClose"),onEarlyDisposal:(r==null?void 0:r.onEarlyDisposal)??Pf,onBackpressure:(r==null?void 0:r.onBackpressure)??Pf});return T(this,Kt)??Zr(this,Kt,[]),T(this,Kt).push(s),s}async wait(){await T(this,zt)}get size(){return T(this,Ht)}get isClosed(){return T(this,zt).__isFulfilled()}async next(){if(T(this,es)>=T(this,Ht)&&T(this,zt).__isFulfilled())return T(this,zt);const e=Ow(this,es)._++&T(this,Qs);T(this,es)>T(this,Ht)&&(T(this,ht)[e]=Ge());const r=T(this,ht)[e],s=await r;return T(this,ht)[e]===r&&(T(this,ht)[e]=null),s}async return(e){return T(this,zt).__isFulfilled()||(this.close(e),T(this,dh).call(this)),{done:!0,value:e}}throw(e){if(T(this,zt).__isFulfilled()){const s=Promise.reject(e);return s.catch(()=>{}),s}let r;if(T(this,es)>T(this,Ht)?r=T(this,ht)[T(this,Ht)&T(this,Qs)].__reject(e):r=Promise.reject(e),r.catch(()=>{}),T(this,Kt)){const s=T(this,Kt);for(let n=0,i=s.length;n<i;n++){const a=s[n];a.isClosed||a.throw(e).catch(()=>{})}}return T(this,zt).__reject(e),T(this,Li).call(this),r}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){throw new Error("PushableAsyncGenerator[asyncDispose]: await using pattern not supported")}},o(Bi,"b"),Bi);uc=new WeakMap,zt=new WeakMap,ht=new WeakMap,Qs=new WeakMap,es=new WeakMap,Ht=new WeakMap,uh=new WeakMap,Kt=new WeakMap,dh=new WeakMap,fh=new WeakMap,Li=new WeakMap,qf=new WeakSet,jw=hh(function(){const t=T(this,ht).length,e=T(this,Qs),r=t*2,s=r-1;T(this,ht).length=r,Zr(this,Qs,s);for(let n=T(this,es);n<T(this,Ht);n++){const i=n&e,a=n&s;i!==a&&(T(this,ht)[a]=T(this,ht)[i],T(this,ht)[i]=null)}},"#growBuffer"),hh(Lw,"PushableAsyncGenerator");let Cs=Lw;const Pf=hh(()=>{},"noop");var wC=Object.defineProperty,vC=o((t,e)=>wC(t,"name",{value:e,configurable:!0}),"s$u");function xf(){let t;return Object.assign(async(e,r)=>{const s=Promise.resolve(t).then(e).catch(r);return t=s.catch(()=>{}),s},{then(e,r){return(t??Promise.resolve()).then(()=>{}).then(e,r)}})}o(xf,"u$B"),vC(xf,"makeAsyncQueue");var _C=Object.defineProperty,Fw=o((t,e)=>_C(t,"name",{value:e,configurable:!0}),"o$s");function dc(t,e){return new Promise(r=>setTimeout(()=>r(e),t))}o(dc,"c$E"),Fw(dc,"wait");const fc=Symbol("race_timeout");function pc(t,...e){let r;const s=new Promise(n=>{r=setTimeout(()=>n(fc),t)});return Promise.race([s,...e]).finally(()=>{clearTimeout(r)})}o(pc,"s$t"),Fw(pc,"raceWithTimeout");var yC=Object.defineProperty,bC=o((t,e)=>yC(t,"name",{value:e,configurable:!0}),"o$r");function y(t=0){return Date.now()+t}o(y,"r$q"),bC(y,"now");var $C=Object.defineProperty,zw=o(t=>{throw TypeError(t)},"m$x"),Hw=o((t,e)=>$C(t,"name",{value:e,configurable:!0}),"a$y"),Wf=o((t,e,r)=>e.has(t)||zw("Cannot "+r),"w$p"),Gt=o((t,e,r)=>(Wf(t,e,"read from private field"),r?r.call(t):e.get(t)),"i$p"),ph=o((t,e,r)=>e.has(t)?zw("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"n$w"),mh=o((t,e,r,s)=>(Wf(t,e,"write to private field"),e.set(t,r),r),"u$z"),kC=o((t,e,r)=>(Wf(t,e,"access private method"),r),"E$u"),Vt,Fi,gh,Uf,Kw;const Gw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Vw=(Za=class{constructor(e=1){if(ph(this,Uf),ph(this,Vt),ph(this,Fi,0),ph(this,gh),e>>>0!==e)throw new Error("maxTokenLength must be an integer");if(e<1)throw new Error("maxTokenLength must be at least 1");if(e>6)throw new Error("maxTokenLength must be at most 6");mh(this,gh,64**e),mh(this,Vt,new Array(64).fill(void 0))}static encodeIndex(e){if(e===void 0||e>>>0!==e)return;let r="";do r=Gw[e%64]+r,e>>=6;while(e>0);return r}static decodeIndex(e){if(!e||e.length===0)return;let r=0;for(const s of e){const n=Gw.indexOf(s);if(n===-1)return;r<<=6,r+=n}return r}store(e){const r=Gt(this,Fi);if(Gt(this,Vt)[r]!==void 0){if(kC(this,Uf,Kw).call(this))return this.store(e);Gt(this,Vt)[r]=void 0;return}return Gt(this,Vt)[r]=e,mh(this,Fi,(Gt(this,Fi)+1)%Gt(this,Vt).length),r}consume(e){if(e<0||e>=Gt(this,Vt).length)return;const r=Gt(this,Vt)[e];return Gt(this,Vt)[e]=void 0,r}},o(Za,"v"),Za);Vt=new WeakMap,Fi=new WeakMap,gh=new WeakMap,Uf=new WeakSet,Kw=Hw(function(){const t=Gt(this,Vt).length,e=t*64;if(e>Gt(this,gh))return!1;Gt(this,Vt).length=e;for(let r=t,s=e;r<s;r++)Gt(this,Vt)[r]=void 0;return mh(this,Fi,t),!0},"#tryGrow"),Hw(Vw,"TokenRingBuffer");let zi=Vw;var Yw=Object.defineProperty,Jw=o(t=>{throw TypeError(t)},"I$j"),CC=o((t,e,r)=>e in t?Yw(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"w$o"),Df=o((t,e)=>Yw(t,"name",{value:e,configurable:!0}),"o$q"),SC=o((t,e,r)=>CC(t,e+"",r),"x$i"),Xw=o((t,e,r)=>e.has(t)||Jw("Cannot "+r),"E$t"),ue=o((t,e,r)=>(Xw(t,e,"read from private field"),r?r.call(t):e.get(t)),"s$s"),Dn=o((t,e,r)=>e.has(t)?Jw("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"a$x"),On=o((t,e,r,s)=>(Xw(t,e,"write to private field"),e.set(t,r),r),"n$v"),Ve,wh,Tr,vh,Hi,Of,jf;const Qw=(eo=class{constructor(e,r){Dn(this,Ve,new Map),Dn(this,wh),Dn(this,Tr,0),Dn(this,vh),Dn(this,Hi),SC(this,"get"),Dn(this,Of,Df(s=>{const n=ue(this,Ve).get(s);if(n!==void 0)return ue(this,Ve).delete(s),ue(this,Ve).set(s,n),n.value},"#getWithRecencyUpdate")),Dn(this,jf,Df(s=>{var n;return(n=ue(this,Ve).get(s))==null?void 0:n.value},"#getWithoutRecencyUpdate")),On(this,wh,e),On(this,vh,(r==null?void 0:r.onInsert)??(()=>{})),On(this,Hi,(r==null?void 0:r.onEvict)??(()=>{})),this.get=(r==null?void 0:r.updateRecencyOnAccess)===!1?ue(this,jf):ue(this,Of)}get estimatedSizeInBytes(){return ue(this,Tr)}get size(){return ue(this,Ve).size}set(e,r,s){for(ue(this,Ve).has(e)?this.delete(e):ue(this,vh).call(this,e,r),ue(this,Ve).set(e,{value:r,estimatedByteSize:s}),On(this,Tr,ue(this,Tr)+s);ue(this,Tr)>ue(this,wh)&&ue(this,Ve).size>1;){const[n,i]=ue(this,Ve).entries().next().value;ue(this,Ve).delete(n),On(this,Tr,ue(this,Tr)-i.estimatedByteSize),ue(this,Hi).call(this,n,i.value)}}has(e){return ue(this,Ve).has(e)}delete(e){const r=ue(this,Ve).get(e);r!==void 0&&(ue(this,Ve).delete(e),On(this,Tr,ue(this,Tr)-r.estimatedByteSize),ue(this,Hi).call(this,e,r.value))}clear(){ue(this,Ve).entries().forEach(([e,r])=>{ue(this,Hi).call(this,e,r.value)}),ue(this,Ve).clear(),On(this,Tr,0)}keys(){return ue(this,Ve).keys()}*values(){for(const e of ue(this,Ve).values())yield e.value}*entries(){for(const[e,r]of ue(this,Ve).entries())yield[e,r.value]}},o(eo,"f"),eo);Ve=new WeakMap,wh=new WeakMap,Tr=new WeakMap,vh=new WeakMap,Hi=new WeakMap,Of=new WeakMap,jf=new WeakMap,Df(Qw,"LRUByteSizeCache");let Zw=Qw;var ev=Object.defineProperty,tv=o(t=>{throw TypeError(t)},"x$h"),AC=o((t,e,r)=>e in t?ev(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"f$s"),Nf=o((t,e)=>ev(t,"name",{value:e,configurable:!0}),"u$y"),EC=o((t,e,r)=>AC(t,e+"",r),"y$n"),rv=o((t,e,r)=>e.has(t)||tv("Cannot "+r),"E$s"),Fe=o((t,e,r)=>(rv(t,e,"read from private field"),r?r.call(t):e.get(t)),"i$o"),mc=o((t,e,r)=>e.has(t)?tv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"l$B"),sv=o((t,e,r,s)=>(rv(t,e,"write to private field"),e.set(t,r),r),"o$p"),Qe,_h,yh,Lf,Ff;const nv=(to=class{constructor(e,r){mc(this,Qe,new Map),mc(this,_h),mc(this,yh),EC(this,"get"),mc(this,Lf,Nf(s=>{const n=Fe(this,Qe).get(s);if(n!==void 0)return Fe(this,Qe).delete(s),Fe(this,Qe).set(s,n),n},"#getWithRecencyUpdate")),mc(this,Ff,Nf(s=>Fe(this,Qe).get(s),"#getWithoutRecencyUpdate")),sv(this,_h,e),sv(this,yh,r==null?void 0:r.onEvict),this.get=(r==null?void 0:r.updateRecencyOnAccess)===!1?Fe(this,Ff):Fe(this,Lf)}get size(){return Fe(this,Qe).size}set(e,r){var s;if(Fe(this,Qe).has(e))Fe(this,Qe).delete(e);else if(Fe(this,Qe).size>=Fe(this,_h)){const[n,i]=Fe(this,Qe).entries().next().value;Fe(this,Qe).delete(n),(s=Fe(this,yh))==null||s.call(this,n,i)}Fe(this,Qe).set(e,r)}has(e){return Fe(this,Qe).has(e)}delete(e){Fe(this,Qe).delete(e)}clear(){Fe(this,Qe).clear()}keys(){return Fe(this,Qe).keys()}values(){return Fe(this,Qe).values()}entries(){return Fe(this,Qe).entries()}},o(to,"p"),to);Qe=new WeakMap,_h=new WeakMap,yh=new WeakMap,Lf=new WeakMap,Ff=new WeakMap,Nf(nv,"LRUCache");let gc=nv;var iv=Object.defineProperty,av=o(t=>{throw TypeError(t)},"it$1"),MC=o((t,e,r)=>e in t?iv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"at$1"),or=o((t,e)=>iv(t,"name",{value:e,configurable:!0}),"p$p"),bh=o((t,e,r)=>MC(t,typeof e!="symbol"?e+"":e,r),"F$h"),zf=o((t,e,r)=>e.has(t)||av("Cannot "+r),"G$b"),E=o((t,e,r)=>(zf(t,e,"read from private field"),r?r.call(t):e.get(t)),"t$f"),Ye=o((t,e,r)=>e.has(t)?av("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"a$v"),Ne=o((t,e,r,s)=>(zf(t,e,"write to private field"),e.set(t,r),r),"o$o"),Zs=o((t,e,r)=>(zf(t,e,"access private method"),r),"g$p"),cr,wc,en,ut,Ss,Ki,tn,vc,rn,Gi,As,ov,_c,Hf,jn,yc,$h,kh,Kf,cv,bc,ts,Ch,Sh;const lv={current:!1};(async()=>{try{return new Request("http://localhost/",{method:"POST",body:new ReadableStream,duplex:"half"}).duplex!=="half"?!1:fetch("data:a/a;charset=utf-8,",{method:"POST",body:new ReadableStream({start(t){t.enqueue("duplex"),t.close()}}),duplex:"half"}).then(()=>!0,()=>!1)}catch{return!1}})().then(t=>{lv.current=t});const Ah=Symbol("early_abort"),hv=new WeakSet;function Rr(t){return t?t instanceof AbortSignal?hv.has(t):t===Ah:!1}o(Rr,"E$r"),or(Rr,"isEarlyAbort");const TC={prefix:new Uint8Array([91]),suffix:new Uint8Array([93]),separator:new Uint8Array([44])},uv=(ro=class{constructor(e,r,s){Ye(this,As),Ye(this,cr),Ye(this,wc),Ye(this,en),Ye(this,ut),Ye(this,Ss),Ye(this,Ki,new Set),Ye(this,tn),Ye(this,vc),Ye(this,rn),Ye(this,Gi,!1),Ne(this,cr,e),Ne(this,wc,r),Ne(this,en,s??{})}get isClosed(){return E(this,Gi)}get batchSizeInBytes(){var e;return((e=E(this,ut))==null?void 0:e.sizeInBytes)??0}write(e,r,s){var n,i;if(E(this,Gi))throw new Error("[direct.dev/shared] BatchStreamOrchestrator is closed");const a=E(this,cr).framing,c=a?a.separator.byteLength+a.suffix.byteLength:0;if(E(this,ut)&&E(this,ut).sizeInBytes+e.byteLength+c>E(this,cr).maxSizeInBytes&&Zs(this,As,_c).call(this,r),!E(this,ut)||!E(this,Ss))try{const[p,f]=Zs(this,As,ov).call(this,r);Ne(this,ut,p),Ne(this,Ss,f)}catch(p){(i=(n=E(this,en)).onBatchError)==null||i.call(n,void 0,p);return}const h=E(this,ut),u=E(this,Ss),d=E(this,tn);return a&&(h.sizeInBytes===0?h.append(a.prefix.slice(0)):h.append(a.separator.slice(0))),h.write(e,s),E(this,cr).windowMs===0&&Zs(this,As,_c).call(this,r),[d,u]}async flush(e){var r;const s=(r=E(this,rn))==null?void 0:r.signal,n=Zs(this,As,_c).call(this,e);try{await n}catch(i){if(!Rr(i)&&!Rr(s))throw i}}async close(e){if(!E(this,Gi)&&(Ne(this,Gi,!0),await this.flush(e),E(this,Ki).size>0)){const r=await Promise.allSettled(E(this,Ki));for(const s of r)if(s.status==="rejected"&&!Rr(s.reason))throw s.reason}}},o(ro,"V"),ro);cr=new WeakMap,wc=new WeakMap,en=new WeakMap,ut=new WeakMap,Ss=new WeakMap,Ki=new WeakMap,tn=new WeakMap,vc=new WeakMap,rn=new WeakMap,Gi=new WeakMap,As=new WeakSet,ov=or(function(t){const e=E(this,cr).disableDuplex||!lv.current?new wv:E(this,cr).isolateSafe?new BC:new RC,r=E(this,wc).prepareContext(t),s=Ge();return s.catch(()=>{}),Ww({timeoutMs:E(this,cr).timeoutMs},async n=>{var i,a;Ne(this,rn,n),Ne(this,Ss,r),Ne(this,ut,e),Ne(this,tn,s);const c=e.maybeConsume();return c&&Zs(this,As,Hf).call(this,e,r,t,c,s,n.signal).catch(h=>{var u,d;if(Rr(n.signal)){s.__isFulfilled()||s.__reject(Ah).catch(()=>{});return}s.__isFulfilled()||s.__reject(h).catch(()=>{}),!(h instanceof Error&&h.name==="AbortError")&&((d=(u=E(this,en)).onBatchError)==null||d.call(u,r,h))}),(a=(i=E(this,en)).onBatchOpen)==null||a.call(i,r),E(this,cr).windowMs>0&&Ne(this,vc,setTimeout(()=>{E(this,ut)===e&&Zs(this,As,_c).call(this,t)},E(this,cr).windowMs)),s.catch(()=>{})}).catch(()=>{}),[e,r]},"#openBatch"),_c=or(function(t){var e;if(E(this,ut)===void 0||E(this,Ss)===void 0||E(this,tn)===void 0||E(this,rn)===void 0)return;clearTimeout(E(this,vc)),Ne(this,vc,void 0);const r=(e=E(this,cr).framing)==null?void 0:e.suffix;r&&E(this,ut).append(r.slice(0));const s=E(this,ut).flush(E(this,rn),E(this,ut)instanceof wv),n=E(this,ut).maybeConsume();if(n){const a=E(this,ut),c=E(this,Ss),h=E(this,tn),u=E(this,rn).signal;s?h.__isFulfilled()||h.__reject(Ah).catch(()=>{}):Zs(this,As,Hf).call(this,a,c,t,n,h,u).catch(d=>{var p,f;if(Rr(u)){h.__isFulfilled()||h.__reject(Ah).catch(()=>{});return}h.__isFulfilled()||h.__reject(d).catch(()=>{}),!(d instanceof Error&&d.name==="AbortError")&&((f=(p=E(this,en)).onBatchError)==null||f.call(p,c,d))})}const i=E(this,tn);return Ne(this,ut,void 0),Ne(this,Ss,void 0),Ne(this,tn,void 0),Ne(this,rn,void 0),i},"#closeBatch"),Hf=or(async function(t,e,r,s,n,i){var a,c;const h=E(this,wc).openRequest(s,e,r,i).finally(()=>{E(this,Ki).delete(h)});E(this,Ki).add(h);const u=await h;n.__resolve(u),(c=(a=E(this,en)).onBatchClose)==null||c.call(a,e,u,t.sizeInBytes,y()-t.startedAt)},"#emitRequest"),or(uv,"BatchStreamOrchestrator");let dv=uv;const fv=(so=class{constructor(){Ye(this,Kf),bh(this,"startedAt",y()),Ye(this,jn,0),Ye(this,yc,new Set),Ye(this,$h,!1),Ye(this,kh,!1)}get sizeInBytes(){return E(this,jn)}maybeConsume(){if(!E(this,kh)&&this.requestInit!==void 0)return Ne(this,kh,!0),this.requestInit}write(e,r){r?E(this,yc).add(r):Ne(this,$h,!0),Ne(this,jn,E(this,jn)+e.byteLength),this.enqueue(e)}append(e){Ne(this,jn,E(this,jn)+e.byteLength),this.enqueue(e)}flush(e,r=!1){return this.close(),Zs(this,Kf,cv).call(this,e,r)}},o(so,"X"),so);jn=new WeakMap,yc=new WeakMap,$h=new WeakMap,kh=new WeakMap,Kf=new WeakSet,cv=or(function(t,e){if(E(this,yc).size===0||E(this,$h))return!1;try{const r=new Set(Array.from(E(this,yc)).filter(n=>!n.aborted));if(e&&r.size===0)return!0;const s=or(()=>{r.size===0&&(hv.add(t.signal),t.abort())},"checkAllAborted");for(const n of r)n.addEventListener("abort",()=>{r.delete(n),s()},{once:!0});s()}catch{}return!1},"#applyEarlyAbort"),or(fv,"BatchBody");let Gf=fv;const pv=(no=class extends Gf{constructor(){super(),bh(this,"requestInit"),Ye(this,bc);let e;const r=new ReadableStream({start(s){e=s}});Ne(this,bc,e),this.requestInit={body:r,duplex:"half"}}enqueue(e){E(this,bc).enqueue(e)}close(){E(this,bc).close()}},o(no,"Z"),no);bc=new WeakMap,or(pv,"StreamBatch");let RC=pv;const mv=(io=class extends Gf{constructor(){super(),bh(this,"requestInit"),Ye(this,ts,[]),Ye(this,Ch,!1);const e=new ReadableStream({pull:or(async r=>{if(E(this,ts).length===1)r.enqueue(E(this,ts)[0]),E(this,ts).length=0;else if(E(this,ts).length>0){const s=E(this,ts).reduce((a,c)=>a+c.length,0),n=new Uint8Array(s);let i=0;for(const a of E(this,ts))n.set(a,i),i+=a.length;r.enqueue(n),E(this,ts).length=0}E(this,Ch)?r.close():await dc(10)},"pull")});this.requestInit={body:e,duplex:"half"}}enqueue(e){E(this,ts).push(e)}close(){Ne(this,Ch,!0)}},o(io,"$"),io);ts=new WeakMap,Ch=new WeakMap,or(mv,"IsolateStreamBatch");let BC=mv;const gv=(ao=class extends Gf{constructor(){super(...arguments),bh(this,"requestInit"),Ye(this,Sh,[])}enqueue(e){E(this,Sh).push(e)}close(){const e=new Uint8Array(this.sizeInBytes);let r=0;for(const s of E(this,Sh))e.set(s,r),r+=s.length;this.requestInit={body:e}}},o(ao,"tt"),ao);Sh=new WeakMap,or(gv,"BufferBatch");let wv=gv;var IC=Object.defineProperty,vv=o(t=>{throw TypeError(t)},"L$i"),Vf=o((t,e)=>IC(t,"name",{value:e,configurable:!0}),"w$m"),Yf=o((t,e,r)=>e.has(t)||vv("Cannot "+r),"C$l"),we=o((t,e,r)=>(Yf(t,e,"read from private field"),r?r.call(t):e.get(t)),"s$r"),Br=o((t,e,r)=>e.has(t)?vv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"n$t"),ve=o((t,e,r,s)=>(Yf(t,e,"write to private field"),e.set(t,r),r),"i$n"),lr=o((t,e,r)=>(Yf(t,e,"access private method"),r),"c$z"),_v=o((t,e,r,s)=>({set _(n){ve(t,e,n)},get _(){return we(t,e,s)}}),"F$g"),Eh,Mh,Vi,$c,Th,kc,Bt,st,Es,Nn,It,Ms,Cc;const yv=(oo=class{constructor(e,r){Br(this,It),Br(this,Eh),Br(this,Mh),Br(this,Vi),Br(this,$c),Br(this,Th),Br(this,kc),Br(this,Bt,"half_closed"),Br(this,st,0),Br(this,Es),Br(this,Nn,y()),ve(this,Eh,e.halfOpenAttempts??3),ve(this,Mh,e.halfClosedAttempts??8),ve(this,$c,e.backoff??(s=>250*2**s)),ve(this,Vi,e.cooldownMs??3e4),ve(this,Th,(r==null?void 0:r.onFailure)??(()=>{})),ve(this,kc,(r==null?void 0:r.onTransition)??(()=>{}))}recordSuccess(){switch(ve(this,Nn,y()),we(this,Bt)){case"half_closed":lr(this,It,Ms).call(this,"closed"),ve(this,st,0);break;case"closed":ve(this,st,0);break;case"half_open":_v(this,st)._++,we(this,st)>=we(this,Eh)&&(lr(this,It,Ms).call(this,"closed"),ve(this,st,0));break;case"open":lr(this,It,Ms).call(this,"closed"),ve(this,st,0);break}}recordFailure(){ve(this,Nn,y()),lr(this,It,Cc).call(this);let e=0,r=!0;switch(we(this,Bt)){case"half_closed":{_v(this,st)._++,we(this,st)>=we(this,Mh)?(ve(this,Es,y(+we(this,Vi))),lr(this,It,Ms).call(this,"open"),ve(this,st,0),r=!1):e=we(this,$c).call(this,we(this,st)-1);break}case"closed":{lr(this,It,Ms).call(this,"half_closed"),ve(this,st,1),e=we(this,$c).call(this,0);break}case"half_open":{ve(this,Es,y(+we(this,Vi))),lr(this,It,Ms).call(this,"open"),ve(this,st,0),r=!1;break}case"open":{r=!1;break}}return we(this,Th).call(this,we(this,Bt),e),e===0?Promise.resolve(r):dc(e).then(()=>r)}check(){return lr(this,It,Cc).call(this),we(this,Bt)!=="open"}reset(){const e=we(this,Bt);ve(this,Bt,"half_closed"),ve(this,st,0),ve(this,Es,void 0),ve(this,Nn,y()),e!=="half_closed"&&we(this,kc).call(this,e,"half_closed")}getState(){return lr(this,It,Cc).call(this),we(this,Bt)}getAttemptCount(){return lr(this,It,Cc).call(this),we(this,st)}},o(oo,"S"),oo);Eh=new WeakMap,Mh=new WeakMap,Vi=new WeakMap,$c=new WeakMap,Th=new WeakMap,kc=new WeakMap,Bt=new WeakMap,st=new WeakMap,Es=new WeakMap,Nn=new WeakMap,It=new WeakSet,Ms=Vf(function(t){if(we(this,Bt)===t)return;const e=we(this,Bt);ve(this,Bt,t),t==="closed"&&ve(this,Es,void 0),we(this,kc).call(this,e,t)},"#transition"),Cc=Vf(function(){const t=y();we(this,Bt)==="open"?(!we(this,Es)||t>we(this,Es))&&(lr(this,It,Ms).call(this,"half_open"),ve(this,st,0),ve(this,Nn,t)):t-we(this,Nn)>=we(this,Vi)&&(we(this,Bt)!=="half_closed"&&lr(this,It,Ms).call(this,"half_closed"),ve(this,st,0),ve(this,Es,void 0))},"#checkCooldown"),Vf(yv,"CircuitBreaker");let Rh=yv;var bv=Object.defineProperty,$v=o(t=>{throw TypeError(t)},"Pe"),qC=o((t,e,r)=>e in t?bv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"Le$1"),z=o((t,e)=>bv(t,"name",{value:e,configurable:!0}),"a$t"),Jf=o((t,e,r)=>qC(t,typeof e!="symbol"?e+"":e,r),"ie$6"),Xf=o((t,e,r)=>e.has(t)||$v("Cannot "+r),"fe$2"),_e=o((t,e,r)=>(Xf(t,e,"read from private field"),e.get(t)),"h$s"),hr=o((t,e,r)=>e.has(t)?$v("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"b$s"),Ir=o((t,e,r,s)=>(Xf(t,e,"write to private field"),e.set(t,r),r),"g$o"),qr=o((t,e,r)=>(Xf(t,e,"access private method"),r),"C$k"),Sc,Ac,Ec,Yi,Bh,Ih,ur,Mc,Ln,qh,Ph,Yt,Fn,Qf,Zf,kv;const Cv=2048,zn={closed:0,half_closed:1,half_open:2,open:3},Pr=z(()=>{},"noop"),PC={getState:z(()=>"closed","getState"),check:z(()=>!0,"check"),recordSuccess:z(()=>{},"recordSuccess"),recordFailure:z(()=>Promise.resolve(!1),"recordFailure")},xC=z(()=>!0,"ALWAYS_RACE"),WC=z(()=>!0,"ALWAYS_ACCEPT_OUTPUT"),xh=z(()=>{},"CATCH_NOOP"),UC=new Error("Pipeline timeout exceeded"),Tc=z((t,e)=>t!==void 0&&t>e?t:e,"getTimingBaseline");function ep(t,e,r,s){return new Cs({maxBufferSize:s,onEarlyDisposal:Pr,onBackpressure:Pr},async(n,i)=>{const a=[];let c;const h=z(()=>{if(c&&(clearTimeout(c),c=void 0),a.length===0||i.aborted)return;const u=r(a);for(const d of u)n(d);a.length=0},"flush");for await(const u of t){if(i.aborted)break;a.push(u),e<0||a.length>=s?h():c||(c=setTimeout(()=>{c=void 0,h()},e))}h()})}o(ep,"Re$3"),z(ep,"createBatchedAsyncIterable");const Sv=(co=class{constructor(e){Jf(this,"name"),Jf(this,"racing"),Jf(this,"check"),hr(this,Sc),hr(this,Ac),hr(this,Ec),hr(this,Yi),this.name=e.name,this.racing=e.racing??{},this.check=e.check,Ir(this,Sc,e.claim),Ir(this,Ac,e.fulfill),Ir(this,Ec,e.batchWindowMs??0),Ir(this,Yi,e.circuitBreaker===!1?PC:new Rh(e.circuitBreaker??{}))}claimSync(e,r,s){return _e(this,Sc).call(this,e,r,s)}claimAsync(e,r,s,n){return ep(e,_e(this,Ec),i=>_e(this,Sc).call(this,i,r,s),n??Cv)}fulfillSync(e,r,s){return _e(this,Ac).call(this,e,r,s)}fulfillAsync(e,r,s,n){return ep(e,_e(this,Ec),i=>_e(this,Ac).call(this,i,r,s),n??Cv)}getHealth(){return _e(this,Yi).getState()}recordSuccess(){_e(this,Yi).recordSuccess()}recordFailure(){_e(this,Yi).recordFailure()}},o(co,"Ae"),co);Sc=new WeakMap,Ac=new WeakMap,Ec=new WeakMap,Yi=new WeakMap,z(Sv,"RequestHandler");let sn=Sv;const Av=(lo=class{constructor(e,r){hr(this,Yt),hr(this,Bh),hr(this,Ih),hr(this,ur),hr(this,Mc),hr(this,Ln),hr(this,qh),hr(this,Ph);const s=(r==null?void 0:r.acceptOutput)??WC;Ir(this,qh,(r==null?void 0:r.canRace)??xC),Ir(this,Ph,r==null?void 0:r.onTelemetry),Ir(this,Ih,(r==null?void 0:r.timeoutMs)??1e4),Ir(this,ur,(r==null?void 0:r.maxBatchSize)??2048),Ir(this,Mc,r==null?void 0:r.transformInput),Ir(this,Ln,r==null?void 0:r.transformError),Ir(this,Bh,e.map(n=>{var i;return{name:n.name,type:n.type,origin:n.origin,handlers:n.handlers,strategy:n.strategy,failover:{...n.failover,acceptOutput:((i=n.failover)==null?void 0:i.acceptOutput)??s}}}))}request(e,r){const s=Array.isArray(e),n=s?e:[e],i=n.length;if(i>_e(this,ur))throw new Error(`RequestPipeline.request(): batch size exceeds limits (${i} > ${_e(this,ur)})`);const a=new Array(i),c=y();for(let g=0;g<i;g++){const m=n[g],w=_e(this,Mc)?_e(this,Mc).call(this,m,r):m;a[g]={index:g,input:w,canRace:_e(this,qh).call(this,w),deferred:Ge(),lastError:void 0,lastHandler:void 0,executions:[],startedAt:c,latencyMs:0}}const h=new Set,u=new AbortController,d=setTimeout(()=>{for(const g of a)g.deferred.__isFulfilled()||(g.lastError??=UC);u.abort()},_e(this,Ih)),p=z(()=>{var g;clearTimeout(d),u.abort();const m=y();for(const w of a){for(const _ of w.executions)_.result==="pending"&&(_.result="timeout");if(!w.deferred.__isFulfilled()){const _=w.executions.at(-1),S=_?` (last: stage="${_.stageName}", handler="${_.handlerName}")`:"";w.lastError??=new Error(`No handler available for item at index ${w.index}${S}`),w.latencyMs=m-w.startedAt,_e(this,Ln)?w.deferred.__resolve(_e(this,Ln).call(this,w.input,w.lastError)):(w.deferred.catch(xh),w.deferred.__reject(w.lastError))}}(g=_e(this,Ph))==null||g.call(this,a,r)},"finalize"),f=qr(this,Yt,Fn).call(this,a,r,u.signal,h,0);if(f instanceof Promise){const g=qr(this,Yt,Zf).call(this,a,s,u),m=g instanceof Cs?g.wait():Promise.resolve(g);return Promise.race([f,m]).catch(xh).finally(p),g}else return p(),qr(this,Yt,Zf).call(this,a,s,u)}},o(lo,"me"),lo);Bh=new WeakMap,Ih=new WeakMap,ur=new WeakMap,Mc=new WeakMap,Ln=new WeakMap,qh=new WeakMap,Ph=new WeakMap,Yt=new WeakSet,Fn=z(function(t,e,r,s,n){if(r.aborted)return;const i=_e(this,Bh)[n];if(!i)return;const a=qr(this,Yt,Qf).call(this,i,s);if(!a)return qr(this,Yt,Fn).call(this,t,e,r,s,n+1);s.add(a);const c=a.getHealth(),h=i.failover??{};let u;const d=new Map;let p,f,g=!1,m,w,_,S=[],b=[],D=!1,O=!1,x=Array.isArray(t)?[]:new Cs({onEarlyDisposal:Pr,onBackpressure:Pr,maxBufferSize:_e(this,ur)});const K=Array.isArray(x)?x:[],I=[],Pe=[];let Oe,Se,Ke;const Nt=z(()=>{w=qr(this,Yt,Fn).call(this,S,e,r,s,n)},"triggerDeclinedContinuation"),Lt=z(()=>{_=qr(this,Yt,Fn).call(this,b,e,r,s,i.strategy==="exhaustive"?n:n+1)},"triggerClaimedContinuation"),ir=z(k=>{r.aborted||g||k.deferred.__isFulfilled()||k.lastHandler!==a||(!Array.isArray(b)&&b.size===0&&Lt(),b.push(k))},"continueClaimedToNextStage"),Xr=i.strategy==="first_eligible"&&qr(this,Yt,Qf).call(this,i,s)!==void 0?k=>{r.aborted||g||k.deferred.__isFulfilled()||k.lastHandler!==a||(!Array.isArray(S)&&S.size===0&&Nt(),S.push(k))}:ir,Qr=z(()=>{if(Array.isArray(S)){const k=S;if(S=new Cs({onEarlyDisposal:Pr,onBackpressure:Pr,maxBufferSize:_e(this,ur)}),k.length>0){Nt();for(const q of k)S.push(q)}}if(Array.isArray(b)){const k=b;if(b=new Cs({onEarlyDisposal:Pr,onBackpressure:Pr,maxBufferSize:_e(this,ur)}),k.length>0){Lt();for(const q of k)b.push(q)}}},"transitionToAsyncContinuation"),Ql=z(()=>{for(const k of u)k.lastHandler===a&&k.canRace&&!k.deferred.__isFulfilled()&&ir(k)},"raceEligibleItems"),Vg=z((k,q)=>{const M={stageIndex:n,stageName:i.name,stageType:i.type,stageOrigin:i.origin,handlerName:a.name,health:c,claimMs:0,checkMs:f,fulfillMs:0,result:"pending",meta:void 0};if(k.executions.push(M),q instanceof Promise){if(Array.isArray(x)){x=new Cs({onEarlyDisposal:Pr,onBackpressure:Pr,maxBufferSize:_e(this,ur)});for(const ee of K)x.push(ee)}I.push(q.then(ee=>Yg(k,ee,M),ee=>Pi(k,ee,M,"claim")))}else Yg(k,q,M)},"processClaim"),Yg=z((k,q,M)=>{if(M.claimMs=y()-Tc(d.get(k),p),M.meta=q==null?void 0:q[1],r.aborted||k.deferred.__isFulfilled()){M.result==="pending"&&(M.result="superseded");return}if(q===void 0){M.result==="pending"&&(M.result="unclaimed"),Xr(k);return}const ee=[k,q[0],M];x.push(ee),Array.isArray(x)||K.push(ee)},"handleClaim"),Jg=z((k,q,M)=>{q instanceof Promise?Pe.push(q.then(ee=>Xg(k,ee,M)).catch(ee=>Pi(k,ee,M,"fulfill"))):Xg(k,q,M)},"processOutput"),Xg=z((k,q,M)=>{if(r.aborted||k.deferred.__isFulfilled()){M.result==="pending"&&(M.fulfillMs=y()-Tc(d.get(k),p)-M.claimMs,M.result="superseded");return}M.fulfillMs=y()-Tc(d.get(k),p)-M.claimMs,h.acceptOutput(q,M.meta)?(D=!0,M.result="fulfilled",k.latencyMs=y()-k.startedAt,k.deferred.__resolve(q)):(M.result="rejected",ir(k))},"handleOutput"),Pi=z((k,q,M,ee)=>{if(r.aborted||k.deferred.__isFulfilled()){M&&M.result==="pending"&&(M.claimMs=y()-Tc(d.get(k),p),M.result="superseded");return}M||(M=k.executions.findLast(oc=>oc.stageIndex===n&&oc.handlerName===a.name&&oc.result==="pending"));const _s=y()-Tc(d.get(k),p);M?(ee==="claim"?(M.claimMs=_s,M.fulfillMs=0):M.fulfillMs=_s-M.claimMs,M.result="error"):(M={stageIndex:n,stageName:i.name,stageType:i.type,stageOrigin:i.origin,handlerName:a.name,health:c,claimMs:_s,checkMs:f,fulfillMs:0,result:"error",meta:void 0},k.executions.push(M)),k.lastError=q instanceof Error?q:new Error(String(q)),O=!0,!(g||k.lastHandler!==a)&&(h.continueOnError!==!1?ir(k):_e(this,Ln)?(k.latencyMs=y()-k.startedAt,k.deferred.__resolve(_e(this,Ln).call(this,k.input,k.lastError))):k.deferred.__reject(k.lastError))},"handleError");if(Array.isArray(t)){u=t;const k=y();for(const q of u)q.lastHandler=a,d.set(q,k)}else u=[],t.tap(k=>{k.lastHandler=a,u.push(k),d.set(k,y())});const sf=y(),h0=z(()=>{var k;if(!a.check)return p=sf,f=0,!0;((k=a.racing)==null?void 0:k.checkMs)!==void 0&&(Oe=setTimeout(()=>{if(r.aborted)return;const ee=Array.isArray(S)||S.size===0,_s=Array.isArray(b)||b.size===0;ee&&_s&&(g=!0,m=qr(this,Yt,Fn).call(this,Array.isArray(t)?t:t.tee(),e,r,s,n))},a.racing.checkMs),r.addEventListener("abort",()=>{clearTimeout(Oe)},{once:!0}));const q=z(ee=>(clearTimeout(Oe),p=y(),f=p-sf,ee),"handleCheckResult"),M=z(()=>(clearTimeout(Oe),p=y(),f=p-sf,!1),"handleCheckError");try{const ee=a.check(e,r);return ee instanceof Promise?ee.then(q,M):q(ee)}catch{return M()}},"runCheck"),u0=z(()=>{const k=z(()=>{!Array.isArray(x)&&!x.isClosed&&x.close(null),clearTimeout(Se)},"cleanup");if(Array.isArray(t))try{const q=a.claimSync(t,e,r);for(let M=0;M<t.length;M++)Vg(t[M],q[M]);if(I.length>0)return Promise.allSettled(I).then(k);k()}catch(q){for(const M of u)Pi(M,q,void 0,"claim");k()}else return(async()=>{try{const q=a.claimAsync(t,e,r,_e(this,ur))[Symbol.asyncIterator]();let M=0;for(;;){const ee=await q.next();if(ee.done||r.aborted)break;Vg(u[M++],ee.value)}await Promise.allSettled(I)}catch(q){for(const M of u)Pi(M,q,void 0,"claim")}finally{k()}})()},"runClaimLoop"),d0=z(()=>{const k=z(()=>{clearTimeout(Ke)},"cleanup");if(Array.isArray(x))try{const q=a.fulfillSync(x,e,r);for(let M=0;M<x.length;M++){const[ee,,_s]=K[M];Jg(ee,q[M],_s)}if(Pe.length>0)return Promise.allSettled(Pe).then(k);k()}catch(q){for(const[M,,ee]of K)Pi(M,q,ee,"fulfill");k()}else return(async()=>{try{const q=a.fulfillAsync(x,e,r,_e(this,ur))[Symbol.asyncIterator]();let M=0;for(;;){const ee=await q.next();if(ee.done||r.aborted)break;const _s=M++,[oc,,p0]=K[_s];Jg(oc,ee.value,p0)}await Promise.allSettled(Pe)}catch(q){for(const[M,,ee]of K)Pi(M,q,ee,"fulfill")}finally{k()}})()},"runFulfillLoop"),Qg=z(()=>{r.aborted||(a.racing.claimMs!==void 0&&(a.racing.claimMs>0?Se=setTimeout(Ql,a.racing.claimMs):Ql()),a.racing.timeoutMs!==void 0&&(a.racing.timeoutMs>0?Ke=setTimeout(Ql,a.racing.timeoutMs):Ql()),r.addEventListener("abort",()=>{clearTimeout(Se),clearTimeout(Ke)},{once:!0}))},"startRaceTimers");Array.isArray(t)?Qg():t.wait().then(Qg);const Zg=z(()=>{if(clearTimeout(Oe),clearTimeout(Se),clearTimeout(Ke),O?a.recordFailure():D&&a.recordSuccess(),Array.isArray(S)?S.length>0&&Nt():S.isClosed||S.close(null),Array.isArray(b)?b.length>0&&Lt():b.isClosed||b.close(null),w instanceof Promise||_ instanceof Promise)return Promise.all([w,_]).then(()=>{})},"finalize"),f0=z(()=>{if(r.aborted)return;const k=u0(),q=d0();return k instanceof Promise||q instanceof Promise?(Qr(),Promise.allSettled([k,q]).then(Zg)):Zg()},"runLoops"),ew=z(k=>k?f0():(clearTimeout(Oe),clearTimeout(Se),clearTimeout(Ke),g?m:qr(this,Yt,Fn).call(this,t,e,r,s,n)),"dispatch"),nf=h0();return nf instanceof Promise?(Qr(),nf.then(ew)):ew(nf)},"#execute"),Qf=z(function(t,e){const r=t.handlers.filter(s=>!e.has(s)&&s.getHealth()!=="open");if(r.length!==0)switch(t.strategy){case"first_eligible":return r[0];case"load_balanced":return r[Math.floor(Math.random()*r.length)];case"exhaustive":{const s=r.reduce((i,a)=>{const c=zn[a.getHealth()];return i[c]??=[],i[c].push(a),i},{}),n=Math.random()<.8?s[zn.closed]??s[zn.half_closed]??s[zn.half_open]:s[zn.half_closed]??s[zn.closed]??s[zn.half_open];return n!=null&&n.length?n[Math.floor(Math.random()*n.length)]:void 0}default:return}},"#selectHandler"),Zf=z(function(t,e,r){if(!e){const n=t[0].deferred;switch(n.__state()){case"resolved":return n.__resolvedWith();case"rejected":throw n.catch(xh),n.__rejectedWith();default:return n}}const s=new Array(t.length);for(let n=0;n<t.length;n++){const i=t[n].deferred;switch(i.__state()){case"resolved":s[n]=i.__resolvedWith();break;case"rejected":throw t[n].deferred.catch(xh),i.__rejectedWith();default:return qr(this,Yt,kv).call(this,t,r)}}return s},"#resolveResult"),kv=z(function(t,e){const r=new Cs({onEarlyDisposal:z(()=>e.abort(),"onEarlyDisposal"),onBackpressure:Pr,maxBufferSize:_e(this,ur)}),s=t.length;let n=0;for(const i of t)i.deferred.then(a=>{r.isClosed||r.push(a),++n===s&&!r.isClosed&&r.close(void 0)},a=>{r.isClosed||r.throw(a instanceof Error?a:new Error(String(a)))});return r},"#makeAsyncIterable"),z(Av,"RequestPipeline");let DC=Av;const dt=globalThis.__wireCheckpointParseRef??={lastCtx:"",lastError:""},pe=globalThis.__wireCheckpointDecodeRef??={arrayBudget:0,byteBudget:0,offset:0};var OC=Object.defineProperty,xe=o((t,e)=>OC(t,"name",{value:e,configurable:!0}),"r$n");function ne(t){const e=xe(f=>{if(!r(f,dt))throw new Error(`${dt.lastCtx} ${dt.lastError}`);return f},"parse"),r=t.safeParse,s=t.encode,n=t.decodeUntrusted,i=t.decodeTrusted;let a,c,h;function u(){return a??={_parse:xe(f=>{if(f===void 0)return f;if(!r(f,dt))throw new Error(dt.lastError);return f},"_parse"),_safeParse:xe(f=>f===void 0||r(f,dt),"_safeParse"),_encode:xe(f=>f===void 0?"\u07FE":s(f),"_encode"),_decodeTrusted:xe(f=>{if(f.charCodeAt(pe.offset)===2046){pe.offset++;return}return i(f,pe)},"_decodeTrusted"),_decodeUntrusted:xe(f=>{if(f.charCodeAt(pe.offset)===2046){pe.offset++;return}return n(f,pe)},"_decodeUntrusted"),get optional(){return a},get nullable(){return p()}},a}o(u,"C"),xe(u,"makeOptional");function d(){return c??={_parse:xe(f=>{if(f===null)return f;if(!r(f,dt))throw new Error(dt.lastError);return f},"_parse"),_safeParse:xe(f=>f===null||r(f,dt),"_safeParse"),_encode:xe(f=>f===null?"\u07FF":s(f),"_encode"),_decodeTrusted:xe(f=>f.charCodeAt(pe.offset)===2047?(pe.offset++,null):i(f,pe),"_decodeTrusted"),_decodeUntrusted:xe(f=>f.charCodeAt(pe.offset)===2047?(pe.offset++,null):n(f,pe),"_decodeUntrusted"),get optional(){return p()},get nullable(){return c}},c}o(d,"g"),xe(d,"makeNullable");function p(){return h??={_parse:xe(f=>{if(f==null)return f;if(!r(f,dt))throw new Error(dt.lastError);return f},"_parse"),_safeParse:xe(f=>f==null||r(f,dt),"_safeParse"),_encode:xe(f=>f==null?String.fromCharCode(f===void 0?2046:2047):s(f),"_encode"),_decodeTrusted:xe(f=>{const g=f.charCodeAt(pe.offset);if(g===2046){pe.offset++;return}return g===2047?(pe.offset++,null):i(f,pe)},"_decodeTrusted"),_decodeUntrusted:xe(f=>{const g=f.charCodeAt(pe.offset);if(g===2046){pe.offset++;return}return g===2047?(pe.offset++,null):n(f,pe)},"_decodeUntrusted"),get optional(){return h},get nullable(){return h}},h}return o(p,"h"),xe(p,"makeOptionalAndNullable"),{_parse:e,_safeParse:xe(f=>r(f,dt),"_safeParse"),_encode:s,_decodeTrusted:xe(f=>i(f,pe),"_decodeTrusted"),_decodeUntrusted:xe(f=>n(f,pe),"_decodeUntrusted"),get optional(){return u()},get nullable(){return d()}}}o(ne,"b$r"),xe(ne,"makeType");var Ev=Object.defineProperty,jC=o((t,e,r)=>e in t?Ev(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"O$j"),tp=o((t,e)=>Ev(t,"name",{value:e,configurable:!0}),"d$q"),Rc=o((t,e,r)=>jC(t,typeof e!="symbol"?e+"":e,r),"a$s");const rp=(ho=class extends Error{constructor(e){super(`[direct.dev/wire/checkpoint.parse] ${e}`)}},o(ho,"u"),ho);tp(rp,"CheckpointParseError"),Rc(rp,"lastMessage","");let Wh=rp;const Mv=(uo=class extends Error{constructor(e){super(`[direct.dev/wire/checkpoint.encode] ${e}`)}},o(uo,"w"),uo);tp(Mv,"CheckpointEncodeError");let Tv=Mv;const rs=(fo=class extends Error{constructor(e){super(`[direct.dev/wire/checkpoint.decode] ${e}`)}},o(fo,"t"),fo);tp(rs,"CheckpointDecodeError"),Rc(rs,"PAYLOAD_TRUNCATED",Object.freeze(new rs("payload truncated"))),Rc(rs,"BYTE_BUDGET_EXHAUSTED",Object.freeze(new rs("byteBudget exhausted"))),Rc(rs,"ARRAY_BUDGET_EXHAUSTED",Object.freeze(new rs("arrayBudget exhausted"))),Rc(rs,"JSON_PARSE",Object.freeze(new rs("JSON.parse failed")));let $=rs;const Bc=Symbol("[direct.dev/wire/checkpoint.safeParse] invalid input");var NC=Object.defineProperty,Hn=o((t,e)=>NC(t,"name",{value:e,configurable:!0}),"h$r");const nt=Hn((t,e)=>{const r=e.offset,s=t.charCodeAt(r);if(s<64)return e.offset=r+1,s;const n=t.charCodeAt(r+1);if(n<64)return e.offset=r+2,s&63|n<<6;const i=t.charCodeAt(r+2);if(i<64)return e.offset=r+3,s&63|(n&63)<<6|i<<12;const a=t.charCodeAt(r+3);if(a<64)return e.offset=r+4,s&63|(n&63)<<6|(i&63)<<12|a<<18;const c=t.charCodeAt(r+4);if(c<64)return e.offset=r+5,s&63|(n&63)<<6|(i&63)<<12|(a&63)<<18|c<<24;const h=t.charCodeAt(r+5);return e.offset=r+6,(s&63|(n&63)<<6|(i&63)<<12|(a&63)<<18|(c&63)<<24|(h&3)<<30)>>>0},"uint32"),Ts=Hn((t,e,r)=>{const s=r.offset,n=(e&112)>>4,i=t.charCodeAt(s);if(n<2)return r.offset=s+1,i;const a=t.charCodeAt(s+1);if(n<3)return r.offset=s+2,i&127|a<<7;const c=t.charCodeAt(s+2);if(n<4)return r.offset=s+3,i&127|(a&127)<<7|c<<14;const h=t.charCodeAt(s+3);if(n<5)return r.offset=s+4,i&127|(a&127)<<7|(c&127)<<14|h<<21;const u=t.charCodeAt(s+4);return r.offset=s+5,(i&127|(a&127)<<7|(c&127)<<14|(h&127)<<21|(u&15)<<28)>>>0},"uint32_base128"),Rv=Hn((t,e)=>{const r=e.offset,s=t.charCodeAt(r),n=t.charCodeAt(r+1),i=t.charCodeAt(r+2),a=t.charCodeAt(r+3),c=t.charCodeAt(r+4),h=t.charCodeAt(r+5);e.offset=r+6;const u=s|n<<7|i<<14|a<<21,d=c|h<<7;return u+d*268435456},"timestamp");Hn((t,e)=>{const r=t.charCodeAt(e.offset++);return Rs(t,r,e)},"num");const Rs=Hn((t,e,r)=>{const s=r.offset,n=s+((e&124)>>2),i=+t.slice(s,n);return r.offset=n,i},"num_header"),nn=Hn((t,e)=>{const r=nt(t,e);return t.slice(e.offset,e.offset+=r)},"str"),an=Hn((t,e,r)=>{const s=Ts(t,e,r);return t.slice(r.offset,r.offset+=s)},"str_base128");var LC=Object.defineProperty,Ji=o((t,e)=>LC(t,"name",{value:e,configurable:!0}),"t$c");const dr=Ji(t=>{let e="",r=t&63;return t>>>=6,t>0&&(e+=String.fromCharCode(r|64),r=t&63,t>>=6,t>0&&(e+=String.fromCharCode(r|64),r=t&63,t>>=6,t>0&&(e+=String.fromCharCode(r|64),r=t&63,t>>=6,t>0&&(e+=String.fromCharCode(r|64),r=t&63,t>>=6,t>0&&(e+=String.fromCharCode(r|64),r=t&63))))),e+String.fromCharCode(r)},"uint32"),Ic=Ji((t,e=0)=>{let r="",s=t&127;return t>>>=7,t>0&&(r+=String.fromCharCode(s),s=t&127,t>>=7,t>0&&(r+=String.fromCharCode(s),s=t&127,t>>=7,t>0&&(r+=String.fromCharCode(s),s=t&127,t>>=7,t>0&&(r+=String.fromCharCode(s),s=t&127)))),String.fromCharCode(e|r.length+1<<4)+r+String.fromCharCode(s)},"uint32_base128"),FC=Ji(t=>{const e=t&268435455,r=Math.floor(t/268435456),s=e&127,n=e>>7&127,i=e>>14&127,a=e>>21&127,c=r&127,h=r>>7&127;return String.fromCharCode(s)+String.fromCharCode(n)+String.fromCharCode(i)+String.fromCharCode(a)+String.fromCharCode(c)+String.fromCharCode(h)},"timestamp"),Uh=Ji((t,e=0)=>{const r=""+t;return String.fromCharCode(e|r.length<<2)+r},"num"),Dh=Ji(t=>dr(t.length)+t,"str"),Oh=Ji((t,e=0)=>Ic(t.length,e)+t,"str_base128");var zC=Object.defineProperty,me=o((t,e)=>zC(t,"name",{value:e,configurable:!0}),"l$x");function qc(t,e){const r=Object.entries(t).sort(([p],[f])=>p===f?0:p>f?1:-1),s=[],n=[];for(const p of r)p[1]._safeParse(void 0)?s.push(p):n.push(p);const i=s.length>0&&s.length<12,a=new Set(e==null?void 0:e.ignoredProps),c=e==null?void 0:e.ignoreExtraProps,h=r.length,u=s.length,d=ne({safeParse(p,f){if(!ji(p))return f.lastCtx="",f.lastError="must be a record",!1;for(let g=0;g<h;g++){const[m,w]=r[g];if(!w._safeParse(p[m]))return f.lastCtx=`.${m}${f.lastCtx}`,!1}if(!c){for(const g in p)if(!(g in t)&&!a.has(g))return f.lastCtx=`.${g}${f.lastCtx}`,f.lastError="not in schema",!1}return!0},encode:me(p=>{if(i){let g="",m=0;for(let w=0;w<u;w++){const[_,S]=s[w];p[_]!==void 0?g+=S._encode(p[_]):m|=1<<w}for(const[w,_]of n)g+=_._encode(p[w]);return m>0||g.charCodeAt(0)&2048?String.fromCharCode(m|2048)+g:g}let f="";for(const[g,m]of s)f+=m._encode(p[g]);for(const[g,m]of n)f+=m._encode(p[g]);return f},"encode"),decodeTrusted:me((p,f)=>{const g={};if(i){let m=0;const w=p.charCodeAt(f.offset);w&2048&&(f.offset++,m=w);for(let _=0;_<u;_++){const[S,b]=s[_];(m&1<<_)===0?g[S]=b._decodeTrusted(p):g[S]=void 0}}else for(const[m,w]of s)g[m]=w._decodeTrusted(p);for(const[m,w]of n)g[m]=w._decodeTrusted(p);return g},"decodeTrusted"),decodeUntrusted:me((p,f)=>{const g={};if(i){let m=0;const w=p.charCodeAt(f.offset);w&2048&&(f.offset++,m=w);for(let _=0;_<u;_++){const[S,b]=s[_];(m&1<<_)===0?g[S]=b._decodeUntrusted(p):g[S]=void 0}}else for(const[m,w]of s)g[m]=w._decodeUntrusted(p);for(const[m,w]of n)g[m]=w._decodeUntrusted(p);return g},"decodeUntrusted")});return Object.assign(d,{keys:Object.keys(t)})}o(qc,"P$g"),me(qc,"shape");function Bv(t,e){const r=(e==null?void 0:e.minLength)??0,s=(e==null?void 0:e.maxLength)??16384;return ne({safeParse:me((n,i)=>{if(!Array.isArray(n))return i.lastCtx="",i.lastError="must be an array",!1;const a=n.length;if(a<r)return i.lastCtx="",i.lastError=`must contain >= ${r} items`,!1;if(a>s)return i.lastCtx="",i.lastError=`must contain <= ${s} items`,!1;for(let c=0;c<a;c++)if(!t._safeParse(n[c]))return i.lastCtx=`[${c}]${i.lastCtx}`,!1;return!0},"safeParse"),encode:me(n=>{const i=n.length;let a=dr(i);for(let c=0;c<i;c++)a+=t._encode(n[c]);return a},"encode"),decodeTrusted:me((n,i)=>{const a=nt(n,i),c=new Array(a);for(let h=0;h<a;h++)c[h]=t._decodeTrusted(n);return c},"decodeTrusted"),decodeUntrusted:me((n,i)=>{const a=nt(n,i);if(a>i.arrayBudget)throw $.ARRAY_BUDGET_EXHAUSTED;i.arrayBudget-=a;const c=new Array(a);for(let h=0;h<a;h++)if(c[h]=t._decodeUntrusted(n),i.offset>i.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return c},"decodeUntrusted")})}o(Bv,"B$h"),me(Bv,"arr");function Iv(t){const e=t.length;return ne({safeParse:me((r,s)=>{if(!Array.isArray(r))return s.lastCtx="",s.lastError="must be an array",!1;if(r.length!==e)return s.lastCtx="",s.lastError=`must contain exactly ${e} elements`,!1;for(let n=0;n<e;n++)if(!t[n]._safeParse(r[n]))return s.lastCtx=`[${n}]${s.lastCtx}`,!1;return!0},"safeParse"),encode:me(r=>{let s="";for(let n=0;n<e;n++)s+=t[n]._encode(r[n]);return s},"encode"),decodeTrusted:me(r=>{const s=new Array(e);for(let n=0;n<e;n++)s[n]=t[n]._decodeTrusted(r);return s},"decodeTrusted"),decodeUntrusted:me((r,s)=>{const n=new Array(e);for(let i=0;i<e;i++)if(n[i]=t[i]._decodeUntrusted(r),s.offset>s.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return n},"decodeUntrusted")})}o(Iv,"b$o"),me(Iv,"tuple");function qv(t,e){return ne({safeParse:me((r,s)=>{if(!ji(r))return s.lastCtx="",s.lastError="must be a record",!1;for(const n in r){if(!t._safeParse(n))return s.lastCtx=`[key=${n}]${s.lastCtx}`,!1;const i=r[n];if(!e._safeParse(i))return s.lastCtx=`.${n}${s.lastCtx}`,!1}return!0},"safeParse"),encode:me(r=>{let s=0,n="";for(const i in r)s++,n+=t._encode(i)+e._encode(r[i]);return dr(s)+n},"encode"),decodeTrusted:me((r,s)=>{const n=nt(r,s),i={};for(let a=0;a<n;a++){const c=t._decodeTrusted(r),h=e._decodeTrusted(r);i[c]=h}return i},"decodeTrusted"),decodeUntrusted:me((r,s)=>{const n=nt(r,s);if(n>s.arrayBudget)throw $.ARRAY_BUDGET_EXHAUSTED;s.arrayBudget-=n;const i={};for(let a=0;a<n;a++){const c=t._decodeUntrusted(r),h=e._decodeUntrusted(r);i[c]=h}return i},"decodeUntrusted")})}o(qv,"D$j"),me(qv,"record");function Pv(...t){const e=t.length;return ne({safeParse:me((r,s)=>{let n="";for(let i=0;i<e;i++){if(s.lastCtx="",t[i]._safeParse(r))return!0;n+=s.lastCtx?`
1
+ var k0=Object.defineProperty;var o=(t,e)=>k0(t,"name",{value:e,configurable:!0});var Pi,to,ro,so,no,io,ao,oo,co,lo,ho,uo,fo,po,mo,go,wo,vo,_o,yo,bo,$o,ko,Co,So,Ao,Eo,Mo,To,Ro,Bo,Io,qo,Po,xo,Wo,Uo,Do,Oo,jo,No,Lo,Fo,xi,zo,Ho,Ko,Go,Vo,Yo,Jo,Xo,Qo,Zo,ec,tc,rc,sc,nc,ic,ac,oc,cc,Wi;const C0={"content-type":"application/json"},S0="x-direct-timing-ms",A0=new Set(["rpc.direct.dev","staging.rpc.direct.dev","prod.rpc.direct.dev"]),cw=typeof TextEncoder<"u"?new TextEncoder:null,E0="direct/sdk requires a global fetch implementation.",M0="direct/sdk requires a global Response implementation.",T0="direct/sdk requires a global Request implementation.";var R0=Object.defineProperty,hf=o((t,e)=>R0(t,"name",{value:e,configurable:!0}),"r$B");function th(t,e){const r=t.length,s=r-e.length;if(s!==0)return s>0?1:-1;for(let n=2;n<r;n++){const i=(t.charCodeAt(n)|32)-(e.charCodeAt(n)|32);if(i!==0)return i>0?1:-1}return 0}o(th,"i$v"),hf(th,"compareBlockHeights");function Wn(t,e){return th(t,e)===1}o(Wn,"u$H"),hf(Wn,"isBlockHeightAhead");function lw(t,e){return th(t,e)===-1}o(lw,"l$K"),hf(lw,"isBlockHeightBehind");var B0=Object.defineProperty,hw=o((t,e)=>B0(t,"name",{value:e,configurable:!0}),"l$J");const I0=4294967295;function uf(t,e,r=I0){const s=th(t,e);if(s===0)return 0;if(s===1)return-uf(e,t,r);let n=0,i=1;const a=e.length-t.length;for(let c=e.length-1;c>=2;c--){const h=df(e.charCodeAt(c)),u=c-a>=2?df(t.charCodeAt(c-a)):0;if(n+=(h-u)*i,i*=16,n>r)return r}return n}o(uf,"f$C"),hw(uf,"getBlockHeightDiff");function df(t){return t>=48&&t<=57?t-48:(t|32)-97+10}o(df,"h$A"),hw(df,"hexCharToValue");var q0=Object.defineProperty,P0=o((t,e)=>q0(t,"name",{value:e,configurable:!0}),"E$A");function ff(t){if(t.length<3||t.charCodeAt(0)!==48||t.charCodeAt(1)!==120)return!1;if(t==="0x0")return!0;if(t.charCodeAt(2)===48)return!1;for(let e=2,r=t.length;e<r;e++){const s=t.charCodeAt(e);if(s>=48&&s<=57)continue;const n=s|32;if(!(n>=97&&n<=102))return!1}return!0}o(ff,"R$n"),P0(ff,"isBlockHeight");var x0=Object.defineProperty,Mr=o((t,e)=>x0(t,"name",{value:e,configurable:!0}),"i$u");function pf(t,e){const r=uw(t);if(r)return r;if(!(!("error"in e)||!e.error))return dw(e.error)}o(pf,"d$z"),Mr(pf,"classifyResponseError");function uw(t){if(!(t>=200&&t<300))return t===408||t===504?"timeout":t===429?"rate_limit":t>=500?"node_error":t>=400&&t<500?"client_error":"unknown"}o(uw,"f$B"),Mr(uw,"classifyHttpStatus");function dw(t){const{code:e,message:r}=t,s=r.toLowerCase();if(mw(s))return"node_error";if(e>=-32099&&e<=-32e3)return fw(s);switch(e){case-32700:case-32600:case-32601:case-32602:return"client_error";case-32603:return"node_error";case 14:case 26:return"node_error"}return e<=-84e3&&e>=-84999?"client_error":e<=-85e3&&e>=-85999?e===-85040?"timeout":"node_error":mf(s)?"timeout":gf(s)?"rate_limit":pw(s)?"node_error":wf(s)?"client_error":"unknown"}o(dw,"a$F"),Mr(dw,"classifyRpcError");function fw(t){return mf(t)?"timeout":gf(t)?"rate_limit":wf(t)?"client_error":"node_error"}o(fw,"_$v"),Mr(fw,"classifyServerError");function mf(t){return t.includes("timeout")||t.includes("timed out")||t.includes("deadline exceeded")}o(mf,"u$G"),Mr(mf,"isTimeoutMessage");function gf(t){return t.includes("rate limit")||t.includes("too many requests")||t.includes("throttl")||t.includes("capacity exceeded")}o(gf,"o$z"),Mr(gf,"isRateLimitMessage");function pw(t){return t.includes("syncing")||t.includes("not synced")||t.includes("unavailable")||t.includes("service unavailable")||t.includes("connection refused")||t.includes("connection reset")||t.includes("internal error")||t.includes("backend error")}o(pw,"s$B"),Mr(pw,"isNodeErrorMessage");function mw(t){return t.includes("greater than latest block")||t.includes("please limit the query")||t.includes("reduce your block range")||t.includes("max block range")||t.includes("block range")&&(t.includes("too wide")||t.includes("exceed")||t.includes("limit"))}o(mw,"h$z"),Mr(mw,"isProviderCapabilityMessage");function wf(t){return t.includes("nonce too low")||t.includes("nonce too high")||t.includes("insufficient funds")||t.includes("gas too low")||t.includes("intrinsic gas")||t.includes("execution reverted")||t.includes("invalid params")||t.includes("invalid argument")||t.includes("missing argument")||t.includes("too many logs")||t.includes("response size exceeded")||t.includes("query returned more than")||t.includes("limit exceeded: more than")||t.includes("unknown block")||t.includes("block not found")}o(wf,"c$O"),Mr(wf,"isClientErrorMessage");function gw(t){return t==="rate_limit"||t==="node_error"}o(gw,"k$k"),Mr(gw,"shouldRetry");function ww(t){return t==="timeout"||t==="rate_limit"||t==="node_error"}o(ww,"y$s"),Mr(ww,"shouldTripBreaker");var W0=Object.defineProperty,vf=o((t,e)=>W0(t,"name",{value:e,configurable:!0}),"l$H");const nt=10,rh={lo32:0,hi32:0};function _f(t){const e=t.length;let r=52210,s=40164,n=33826,i=8997;for(let a=0;a<e;a++){const c=t.charCodeAt(a);i^=c,r=Math.imul(r,435)+(n<<8),s=Math.imul(s,435)+(i<<8),n=Math.imul(n,435),i=Math.imul(i,435),r=r+(s>>>16)&65535,s=s+(n>>>16)&65535,n=n+(i>>>16)&65535,i&=65535}rh.lo32=(n<<16|i)>>>0,rh.hi32=(r<<16|s)>>>0}o(_f,"i$t"),vf(_f,"fnv1a_raw");function bs(t){_f(t);const{lo32:e,hi32:r}=rh;return String.fromCharCode(e&15,e>>>4&127,e>>>11&127,e>>>18&127,e>>>25&127,r&127,r>>>7&127,r>>>14&127,r>>>21&127,r>>>28)}o(bs,"M$m"),vf(bs,"fnv1a");const Tr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function vw(t){_f(t);const{lo32:e,hi32:r}=rh;return Tr.charAt(e&63)+Tr.charAt(e>>>6&63)+Tr.charAt(e>>>12&63)+Tr.charAt(e>>>18&63)+Tr.charAt(e>>>24&63)+Tr.charAt((e>>>30|r<<2)&63)+Tr.charAt(r>>>4&63)+Tr.charAt(r>>>10&63)+Tr.charAt(r>>>16&63)+Tr.charAt(r>>>22&63)+Tr.charAt(r>>>28&15)}o(vw,"_$u"),vf(vw,"fnv1a_b64");const hc=new TextEncoder,yf=new TextDecoder;var U0=Object.defineProperty,D0=o((t,e)=>U0(t,"name",{value:e,configurable:!0}),"r$A");const _w=16,Rt=37;async function yw(t){const e=await crypto.subtle.digest("SHA-256",hc.encode(t)),r=new Uint8Array(e);return String.fromCharCode(_w|r[0]>>4,(r[0]<<3|r[1]>>5)&127,(r[1]<<2|r[2]>>6)&127,(r[2]<<1|r[3]>>7)&127,r[3]&127,r[4]>>1,(r[4]<<6|r[5]>>2)&127,(r[5]<<5|r[6]>>3)&127,(r[6]<<4|r[7]>>4)&127,(r[7]<<3|r[8]>>5)&127,(r[8]<<2|r[9]>>6)&127,(r[9]<<1|r[10]>>7)&127,r[10]&127,r[11]>>1,(r[11]<<6|r[12]>>2)&127,(r[12]<<5|r[13]>>3)&127,(r[13]<<4|r[14]>>4)&127,(r[14]<<3|r[15]>>5)&127,(r[15]<<2|r[16]>>6)&127,(r[16]<<1|r[17]>>7)&127,r[17]&127,r[18]>>1,(r[18]<<6|r[19]>>2)&127,(r[19]<<5|r[20]>>3)&127,(r[20]<<4|r[21]>>4)&127,(r[21]<<3|r[22]>>5)&127,(r[22]<<2|r[23]>>6)&127,(r[23]<<1|r[24]>>7)&127,r[24]&127,r[25]>>1,(r[25]<<6|r[26]>>2)&127,(r[26]<<5|r[27]>>3)&127,(r[27]<<4|r[28]>>4)&127,(r[28]<<3|r[29]>>5)&127,(r[29]<<2|r[30]>>6)&127,(r[30]<<1|r[31]>>7)&127,r[31]&127)}o(yw,"i$s"),D0(yw,"sha256");var O0=Object.defineProperty,j0=o((t,e)=>O0(t,"name",{value:e,configurable:!0}),"u$F");function Di(t){if(t==null)return t===void 0?"undefined":"null";switch(typeof t){case"boolean":case"undefined":case"number":return""+t;case"string":return t;case"object":{if(Array.isArray(t)){let s="";for(let n=0,i=t.length;n<i;n++)s+=(n>0?",":"")+Di(t[n]);return s}const e=[];for(const s in t)t[s]!==void 0&&e.push(s);e.sort();let r="";for(let s=0,n=e.length;s<n;s++){const i=e[s];r+=(s>0?"|":"")+i+":"+Di(t[i])}return r}}throw new Error("sortObject(): Only JSON serializeable structures are allowed")}o(Di,"l$G"),j0(Di,"sortObject");var N0=Object.defineProperty,bw=o((t,e)=>N0(t,"name",{value:e,configurable:!0}),"r$z");function $w(t,e){switch(e){case"eth_getBlockByNumber":case"eth_getBlockTransactionCountByNumber":case"eth_getTransactionByBlockNumberAndIndex":case"eth_getUncleByBlockNumberAndIndex":case"eth_getUncleCountByBlockNumber":return t.params[0];case"eth_call":case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":return t.params[1];case"eth_getStorageAt":return t.params[2];default:return}}o($w,"h$y"),bw($w,"getBlockHeightParam");function kw(t,e,r){const s=e,n=t.params;switch(s){case"eth_getBlockByNumber":case"eth_getBlockTransactionCountByNumber":case"eth_getTransactionByBlockNumberAndIndex":case"eth_getUncleByBlockNumberAndIndex":case"eth_getUncleCountByBlockNumber":{const i=n.slice();return i[0]=r,{...t,params:i}}case"eth_call":case"eth_getBalance":case"eth_getCode":case"eth_getTransactionCount":{const i=n.slice();return i[1]=r,{...t,params:i}}case"eth_getStorageAt":{const i=n.slice();return i[2]=r,{...t,params:i}}default:return t}}o(kw,"l$F"),bw(kw,"setBlockHeightParam");var L0=Object.defineProperty,bf=o((t,e)=>L0(t,"name",{value:e,configurable:!0}),"o$x");function Oi(t){if(Array.isArray(t)){const e=t.length;if(e===0)return sh;let r=sh+e-1;for(let s=0;s<e;s++)r+=$f(t[s]);return r}return $f(t)}o(Oi,"R$m"),bf(Oi,"estimateJsonRpcSize");function $f(t){if(t===void 0)return 0;if("result"in t){let r=z0;return r+=String(t.id).length,r+=ji(t.result),r}if("error"in t){let r=H0;return r+=String(t.id).length,r+=String(t.error.code).length,r+=String(t.error.message).length,r+=t.error.data?K0+ji(t.error.data):0,r}let e=F0;return e+=t.method.length,e+=String(t.id).length,e+=ji(t.params),e}o($f,"c$K"),bf($f,"estimateObjectSize");function ji(t){switch(t){case null:return 4;case!0:return 4;case!1:return 5}switch(typeof t){case"number":return String(t).length;case"string":return t.length+Y0}if(Array.isArray(t)){const e=t.length;if(e===0)return sh;let r=sh+e-1;for(let s=0;s<e;s++)r+=ji(t[s]);return r}if(typeof t=="object"&&t!==null){let e=0,r=G0;for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r+=V0+s.length+ji(t[s]),e++);return e>0&&r--,r}return 0}o(ji,"s$z"),bf(ji,"estimateJsonSize");const F0=45,z0=33,H0=54,K0=8,sh=2,G0=2,V0=4,Y0=2;var J0=Object.defineProperty,Ne=o((t,e)=>J0(t,"name",{value:e,configurable:!0}),"n$z");const X0=25e4,Cw=12,$s=1+nt,ks=1+Rt+nt,nh=nt,Ni=$s+nh,Li=ks+nh,Sw=new Set(["eth_call","eth_chainId","eth_gasPrice","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleByBlockHashAndIndex","eth_getUncleByBlockNumberAndIndex","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","net_version"]),Aw=new Set(["eth_gasPrice"]),Ew=new Set([...Sw,"direct_getTransactionReceipt","eth_accounts","eth_blockNumber","eth_coinbase","eth_estimateGas","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_hashrate","eth_mining","eth_protocolVersion","eth_syncing","net_listening","net_peerCount","net_version","web3_clientVersion","web3_sha3","debug_traceTransaction","debug_traceCall","debug_traceBlockByNumber","debug_traceBlockByHash","debug_getBadBlocks","debug_storageRangeAt","debug_getModifiedAccountsByNumber","debug_getModifiedAccountsByHash","trace_call","trace_callMany","trace_rawTransaction","trace_replayBlockTransactions","trace_replayTransaction","trace_block","trace_filter","trace_get","trace_transaction"]),Q0=new Set([...Ew,"eth_sendRawTransaction"]),Bt=1,ih=1,Mw=0<<ih,Z0=1<<ih,Tw=2<<ih,kf=3<<ih,Cf=6,Xs=8,Rw=16,Bw=32,Iw=64,St={flags:0,isTiedToBlock:!1,hashInput:""};function ah(t,e,r,s=Cw){const{flags:n,hashInput:i}=Sf(t,e,r,s);return String.fromCharCode(n)+bs(i)}o(ah,"Y$8"),Ne(ah,"makeRequestFingerprint");async function qw(t,e,r,s=Cw){const{flags:n,hashInput:i}=Sf(t,e,r,s),a=await yw(i),c=bs(i);return String.fromCharCode(n|Bt)+a+c}o(qw,"X$c"),Ne(qw,"makeRequestFingerprintWithChecksum");function Sf(t,e,r,s){const n=$w(t,e);St.flags=Mw,St.isTiedToBlock=!1;let i;switch(n){case"latest":case"finalized":case"safe":{St.flags|=Xs,St.isTiedToBlock=!0;break}case"pending":case"earliest":case void 0:break;case r:St.flags|=Xs,St.isTiedToBlock=!0,i="latest";break;default:{if(r){const c=uf(n,r,s+1);c>0&&c<=s&&(St.flags|=Xs,St.isTiedToBlock=!0,i="latest")}break}}if(Ew.has(e)&&(St.flags|=Bw),Q0.has(e)&&(St.flags|=Iw),Sw.has(e)&&n!=="pending"){if(Pw(e,t,i??n)){const c=xw(e,i??n);St.flags|=c?kf:Tw}else St.flags|=Z0;Aw.has(e)&&(St.flags|=Rw)}const a=i!==void 0?kw(t,e,i):t;return St.hashInput=a.method+Di(a.params),St}o(Sf,"U$i"),Ne(Sf,"analyzeRequest");function Ht(t,e){return!uc(t)||e===void 0?t:t+e}o(Ht,"j$g"),Ne(Ht,"hydrateRequestFingerprint");function Pw(t,e,r){var s;if(Oi(e)>X0)return!1;if(t==="eth_getBlockByNumber"){const n=r==="latest"||r==="pending",i=((s=e.params)==null?void 0:s[1])===!0;return!(n&&i)}return!0}o(Pw,"J$d"),Ne(Pw,"analyzeRevalidationEligibility");function xw(t,e){return t==="eth_getBlockByNumber"?e!=="latest"&&e!=="pending":!Aw.has(t)}o(xw,"Z$8"),Ne(xw,"analyzeSyncEligibility");function oh(t){return(t.charCodeAt(0)&Bt)!==0}o(oh,"C$n"),Ne(oh,"hasRequestChecksum");function eC(t){if(oh(t))return t.slice(1,1+Rt)}o(eC,"$$h"),Ne(eC,"extractRequestChecksum");function Af(t){if(!oh(t))return t;const e=t.charCodeAt(0)&~Bt;return String.fromCharCode(e)+t.slice(1+Rt)}o(Af,"ee$7"),Ne(Af,"stripRequestChecksum");function tC(t,e){const r=t.charCodeAt(0)|Bt,s=t.slice(1);return String.fromCharCode(r)+e+s}o(tC,"te$6"),Ne(tC,"addRequestChecksum");function Ef(t){return(t.charCodeAt(0)&Cf)!==Mw}o(Ef,"ne$8"),Ne(Ef,"isRequestCacheable");function rC(t){return(t.charCodeAt(0)&Rw)!==0}o(rC,"ae$4"),Ne(rC,"isRequestVolatile");function sC(t){const e=t.charCodeAt(0)&Cf;return e===Tw||e===kf}o(sC,"ce$3"),Ne(sC,"isEligibleForRevalidation");function nC(t){return(t.charCodeAt(0)&Cf)===kf}o(nC,"se$6"),Ne(nC,"isEligibleForSync");function uc(t){return(t.charCodeAt(0)&Xs)!==0}o(uc,"E$y"),Ne(uc,"isRequestTiedToBlock");function ch(t){return(t.charCodeAt(0)&Bw)!==0}o(ch,"oe$4"),Ne(ch,"isRequestDeduplicatable");function iC(t){return(t.charCodeAt(0)&Iw)!==0}o(iC,"re$4"),Ne(iC,"isRequestRaceable");function Mf(t){return oh(t)?ks:$s}o(Mf,"H$f"),Ne(Mf,"getFingerprintLength");function Ww(t){const e=Mf(t);return uc(t)?e+nh:e}o(Ww,"K$b"),Ne(Ww,"getExpectedKeyLength");function Rr(t){return t.length===Ww(t)}o(Rr,"ie$8"),Ne(Rr,"isRequestKey");function lh(t){return t.slice(0,Mf(t))}o(lh,"le$3"),Ne(lh,"extractRequestFingerprint");function Tf(t){if(uc(t))return t.slice(-nh)}o(Tf,"ue$1"),Ne(Tf,"extractBlockDigest");var aC=Object.defineProperty,oC=o((t,e)=>aC(t,"name",{value:e,configurable:!0}),"e$l");function Fi(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}o(Fi,"t$g"),oC(Fi,"isRecord");var cC=Object.defineProperty,dc=o((t,e)=>cC(t,"name",{value:e,configurable:!0}),"r$y");const lC=25e4,hh=1+nt,Uw=1;function Rf(t){return"result"in t?typeof t.result=="string"?bs("string:"+t.result):bs("result:"+Di(t.result)):bs("error:"+Di(t.error))}o(Rf,"s$y"),dc(Rf,"makeResponseDigest");function Dw(t){return t.slice(1)}o(Dw,"B$l"),dc(Dw,"extractResponseKeyDigest");function Bf(t,e,r){const s=Ow(t,e,r),n=Rf(t);return String.fromCharCode(s?Uw:0)+n}o(Bf,"E$x"),dc(Bf,"makeResponseKey");function Ow(t,e,r){if(!("result"in t)||t.result==="0x"||((r==null?void 0:r.length)??Oi(t))>=lC)return!1;if(!e)return!0;switch(e){case"eth_getBlockByHash":case"eth_getBlockByNumber":case"eth_getUncleByBlockHashAndIndex":case"eth_getUncleByBlockNumberAndIndex":return Fi(t.result)&&t.result.number!=null&&t.result.hash!=null&&t.result.nonce!=null;case"eth_getTransactionByHash":case"eth_getTransactionByBlockHashAndIndex":case"eth_getTransactionByBlockNumberAndIndex":return Fi(t.result)&&t.result.blockNumber!=null&&t.result.blockHash!=null&&t.result.nonce!=null;case"eth_getTransactionReceipt":return t.result!=null}return!0}o(Ow,"y$q"),dc(Ow,"analyzeResponseEligibility");function If(t){return(t.charCodeAt(0)&Uw)!==0}o(If,"A$q"),dc(If,"isResponseCacheable");var hC=Object.defineProperty,jw=o((t,e)=>hC(t,"name",{value:e,configurable:!0}),"r$x");function Un(t){switch(t.method){case"eth_getLogs":return!0;case"eth_getBlockByNumber":case"eth_getBlockByHash":return Array.isArray(t.params)&&t.params[1]===!0;case"eth_getCode":case"eth_getProof":return!0}const e=t.method.slice(0,6);return e==="trace_"||e==="debug_"}o(Un,"s$x"),jw(Un,"isSlowRPCRequest");function Nw(t){return Un(t)}o(Nw,"o$w"),jw(Nw,"shouldBypassWireRPCRequest");var uC=Object.defineProperty,dC=o((t,e)=>uC(t,"name",{value:e,configurable:!0}),"i$q");function Lw(t){const e=new Set;for(const r of t)if(r.id!==void 0){if(e.has(r.id))return!0;e.add(r.id)}return!1}o(Lw,"r$w"),dC(Lw,"hasDuplicateIds");var fC=Object.defineProperty,pC=o((t,e)=>fC(t,"name",{value:e,configurable:!0}),"o$u");const mC={BAD_REQUEST:{code:-84e3,message:"Invalid request signature (Direct.dev)"},BAD_DIRECT_METHOD:{code:-84001,message:"Request method not supported (Direct.dev)"},REQUEST_LIMIT_EXCEEDED:{code:-84002,message:"Request exceeds configured limits (Direct.dev)"},NO_RESPONSE:{code:-85e3,message:"Failed to receive response (Direct.dev)"},SERVER_ERROR:{code:-85001,message:"An internal server error occurred (Direct.dev)"},UPSTREAM_ERROR:{code:-85020,message:"Upstream JSON-RPC node failed (Direct.dev)"},UPSTREAM_TIMEOUT:{code:-85040,message:"JSON-RPC reqiest timed out (Direct.dev)"}};function Cs(t,e,r){const s=mC[e];return{id:t,error:{code:s.code,message:s.message,data:r}}}o(Cs,"E$w"),pC(Cs,"makeErrorResponse");var gC=Object.defineProperty,wC=o((t,e)=>gC(t,"name",{value:e,configurable:!0}),"c$H");const qf=new Set(["direct_getTransactionReceipt","eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_coinbase","eth_estimateGas","eth_gasPrice","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleByBlockHashAndIndex","eth_getUncleByBlockNumberAndIndex","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_hashrate","eth_mining","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_protocolVersion","eth_sendRawTransaction","eth_sendTransaction","eth_sign","eth_signTransaction","eth_syncing","eth_uninstallFilter","net_listening","net_peerCount","net_version","web3_clientVersion","web3_sha3","debug_traceTransaction","debug_traceCall","debug_traceBlockByNumber","debug_traceBlockByHash","debug_getBadBlocks","debug_storageRangeAt","debug_getModifiedAccountsByNumber","debug_getModifiedAccountsByHash","trace_call","trace_callMany","trace_rawTransaction","trace_replayBlockTransactions","trace_replayTransaction","trace_block","trace_filter","trace_get","trace_transaction","other"]);function uh(t){if(qf.has(t))return t;const e=t.indexOf("_");if(e>0){const r="eth"+t.slice(e);if(qf.has(r))return r}return"other"}o(uh,"o$t"),wC(uh,"normalizeRPCMethod");var vC=Object.defineProperty,Pf=o((t,e)=>vC(t,"name",{value:e,configurable:!0}),"r$u");function Fw(t,e){var r,s;const n=new AbortController,i=setTimeout(()=>n.abort(),t.timeoutMs),a=Pf(()=>n.abort(),"onParentAbort");(r=t.parentSignal)!=null&&r.aborted?n.abort():(s=t.parentSignal)==null||s.addEventListener("abort",a);const c=Pf(()=>{var h;clearTimeout(i),(h=t.parentSignal)==null||h.removeEventListener("abort",a),n.signal.removeEventListener("abort",c)},"cleanup");return n.signal.addEventListener("abort",c),e(n).finally(c)}o(Fw,"u$D"),Pf(Fw,"withAbortController");var _C=Object.defineProperty,Dn=o((t,e)=>_C(t,"name",{value:e,configurable:!0}),"r$t");const xf=Symbol("deferred not resolved"),yC=Symbol("deferred not rejected");function Ye(){let t,e,r="pending",s=xf,n=yC;const i=new Promise((a,c)=>{t=a,e=c});return Object.assign(i,{__state:Dn(()=>r,"__state"),__resolvedWith:Dn(()=>s,"__resolvedWith"),__rejectedWith:Dn(()=>n,"__rejectedWith"),__isFulfilled:Dn(()=>r!=="pending","__isFulfilled"),__resolve:Dn(a=>{if(r!=="pending")throw new Error(`makeDeferred(): Cannot resolve a promise that is already ${r}`);return r="resolved",s=a,t(a),i},"__resolve"),__reject:Dn(a=>{if(r!=="pending")throw new Error(`makeDeferred(): Cannot reject a promise that is already ${r}`);return r="rejected",n=a,e(a),i},"__reject")})}o(Ye,"f$x"),Dn(Ye,"makeDeferred");var bC=Object.defineProperty,zw=o((t,e)=>bC(t,"name",{value:e,configurable:!0}),"u$C");function It(t,e,r){return typeof t=="object"&&t!=null&&"then"in t?r!=null?t.then(e,r):t.then(e):e(t)}o(It,"h$w"),zw(It,"mapMaybePromise");function zi(t,e,r){if(r==null)return It(t(),e);let s;try{s=t()}catch(n){return r(n)}return It(s,e,r)}o(zi,"M$k"),zw(zi,"mapMaybeAsync");var $C=Object.defineProperty,Hw=o(t=>{throw TypeError(t)},"z$i"),dh=o((t,e)=>$C(t,"name",{value:e,configurable:!0}),"g$r"),Wf=o((t,e,r)=>e.has(t)||Hw("Cannot "+r),"m$x"),T=o((t,e,r)=>(Wf(t,e,"read from private field"),r?r.call(t):e.get(t)),"s$v"),cr=o((t,e,r)=>e.has(t)?Hw("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"f$v"),es=o((t,e,r,s)=>(Wf(t,e,"write to private field"),e.set(t,r),r),"d$w"),kC=o((t,e,r)=>(Wf(t,e,"access private method"),r),"A$p"),Kw=o((t,e,r,s)=>({set _(n){es(t,e,n)},get _(){return T(t,e,s)}}),"B$k"),fc,Kt,ut,Qs,ts,Gt,fh,Vt,ph,mh,Hi,Uf,Gw;const Vw=16,CC=Vw-1,Yw=(Pi=class{constructor(e,r){if(cr(this,Uf),cr(this,fc),cr(this,Kt,Ye()),cr(this,ut,new Array(Vw)),cr(this,Qs,CC),cr(this,ts,0),cr(this,Gt,0),cr(this,fh,null),cr(this,Vt,null),cr(this,ph),cr(this,mh),cr(this,Hi),es(this,fc,e.maxBufferSize??512),es(this,ph,e.onEarlyDisposal),es(this,mh,e.onBackpressure??Df),r){const s=new AbortController;es(this,Hi,()=>{var n;s.abort(),(n=e.onClose)==null||n.call(e)}),r(n=>this.push(n),s.signal).then(n=>{this.isClosed||this.close(n)}).catch(n=>{this.isClosed||this.throw(n)})}else es(this,Hi,()=>{var s;(s=e.onClose)==null||s.call(e)});T(this,Kt).catch(()=>{})}tap(e){es(this,fh,e)}push(e){var r;if(T(this,Kt).__isFulfilled())throw new Error("PushableAsyncGenerator.push(): Generator is already closed");if((r=T(this,fh))==null||r.call(this,e),T(this,Gt)>=T(this,ts)+T(this,ut).length){if(T(this,ut).length>=T(this,fc)){this.close(null),T(this,mh).call(this);return}kC(this,Uf,Gw).call(this)}const s=Kw(this,Gt)._++&T(this,Qs);if(T(this,Gt)>T(this,ts)&&(T(this,ut)[s]=Ye()),T(this,ut)[s].__resolve({done:!1,value:e}),T(this,Vt)){const n=T(this,Vt);for(let i=0,a=n.length;i<a;i++)n[i].push(e)}}close(e){if(T(this,Kt).__isFulfilled())throw new Error("PushableAsyncGenerator.close(): Generator is already closed");const r={done:!0,value:e};if(T(this,ts)>T(this,Gt)&&T(this,ut)[T(this,Gt)&T(this,Qs)].__resolve(r),T(this,Kt).__resolve(r),T(this,Vt)){const s=T(this,Vt);for(let n=0,i=s.length;n<i;n++){const a=s[n];a.isClosed||a.close(e)}}T(this,Hi).call(this)}tee(e){const r=typeof e=="function"?{onEarlyDisposal:e}:e,s=new Pi({maxBufferSize:T(this,fc),onClose:dh(()=>{var n,i;es(this,Vt,((n=T(this,Vt))==null?void 0:n.filter(a=>a!==s))??[]),(i=r==null?void 0:r.onClose)==null||i.call(r)},"onClose"),onEarlyDisposal:(r==null?void 0:r.onEarlyDisposal)??Df,onBackpressure:(r==null?void 0:r.onBackpressure)??Df});return T(this,Vt)??es(this,Vt,[]),T(this,Vt).push(s),s}async wait(){await T(this,Kt)}get size(){return T(this,Gt)}get isClosed(){return T(this,Kt).__isFulfilled()}async next(){if(T(this,ts)>=T(this,Gt)&&T(this,Kt).__isFulfilled())return T(this,Kt);const e=Kw(this,ts)._++&T(this,Qs);T(this,ts)>T(this,Gt)&&(T(this,ut)[e]=Ye());const r=T(this,ut)[e],s=await r;return T(this,ut)[e]===r&&(T(this,ut)[e]=null),s}async return(e){return T(this,Kt).__isFulfilled()||(this.close(e),T(this,ph).call(this)),{done:!0,value:e}}throw(e){if(T(this,Kt).__isFulfilled()){const s=Promise.reject(e);return s.catch(()=>{}),s}let r;if(T(this,ts)>T(this,Gt)?r=T(this,ut)[T(this,Gt)&T(this,Qs)].__reject(e):r=Promise.reject(e),r.catch(()=>{}),T(this,Vt)){const s=T(this,Vt);for(let n=0,i=s.length;n<i;n++){const a=s[n];a.isClosed||a.throw(e).catch(()=>{})}}return T(this,Kt).__reject(e),T(this,Hi).call(this),r}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){throw new Error("PushableAsyncGenerator[asyncDispose]: await using pattern not supported")}},o(Pi,"b"),Pi);fc=new WeakMap,Kt=new WeakMap,ut=new WeakMap,Qs=new WeakMap,ts=new WeakMap,Gt=new WeakMap,fh=new WeakMap,Vt=new WeakMap,ph=new WeakMap,mh=new WeakMap,Hi=new WeakMap,Uf=new WeakSet,Gw=dh(function(){const t=T(this,ut).length,e=T(this,Qs),r=t*2,s=r-1;T(this,ut).length=r,es(this,Qs,s);for(let n=T(this,ts);n<T(this,Gt);n++){const i=n&e,a=n&s;i!==a&&(T(this,ut)[a]=T(this,ut)[i],T(this,ut)[i]=null)}},"#growBuffer"),dh(Yw,"PushableAsyncGenerator");let Ss=Yw;const Df=dh(()=>{},"noop");var SC=Object.defineProperty,AC=o((t,e)=>SC(t,"name",{value:e,configurable:!0}),"s$u");function Of(){let t;return Object.assign(async(e,r)=>{const s=Promise.resolve(t).then(e).catch(r);return t=s.catch(()=>{}),s},{then(e,r){return(t??Promise.resolve()).then(()=>{}).then(e,r)}})}o(Of,"u$A"),AC(Of,"makeAsyncQueue");var EC=Object.defineProperty,Jw=o((t,e)=>EC(t,"name",{value:e,configurable:!0}),"o$s");function pc(t,e){return new Promise(r=>setTimeout(()=>r(e),t))}o(pc,"c$E"),Jw(pc,"wait");const mc=Symbol("race_timeout");function gc(t,...e){let r;const s=new Promise(n=>{r=setTimeout(()=>n(mc),t)});return Promise.race([s,...e]).finally(()=>{clearTimeout(r)})}o(gc,"s$t"),Jw(gc,"raceWithTimeout");var MC=Object.defineProperty,TC=o((t,e)=>MC(t,"name",{value:e,configurable:!0}),"o$r");function y(t=0){return Date.now()+t}o(y,"r$q"),TC(y,"now");var RC=Object.defineProperty,Xw=o(t=>{throw TypeError(t)},"m$w"),Qw=o((t,e)=>RC(t,"name",{value:e,configurable:!0}),"a$y"),jf=o((t,e,r)=>e.has(t)||Xw("Cannot "+r),"w$p"),Yt=o((t,e,r)=>(jf(t,e,"read from private field"),r?r.call(t):e.get(t)),"i$p"),gh=o((t,e,r)=>e.has(t)?Xw("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"n$w"),wh=o((t,e,r,s)=>(jf(t,e,"write to private field"),e.set(t,r),r),"u$y"),BC=o((t,e,r)=>(jf(t,e,"access private method"),r),"E$u"),Jt,Ki,vh,Nf,Zw;const ev="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",tv=(to=class{constructor(e=1){if(gh(this,Nf),gh(this,Jt),gh(this,Ki,0),gh(this,vh),e>>>0!==e)throw new Error("maxTokenLength must be an integer");if(e<1)throw new Error("maxTokenLength must be at least 1");if(e>6)throw new Error("maxTokenLength must be at most 6");wh(this,vh,64**e),wh(this,Jt,new Array(64).fill(void 0))}static encodeIndex(e){if(e===void 0||e>>>0!==e)return;let r="";do r=ev[e%64]+r,e>>=6;while(e>0);return r}static decodeIndex(e){if(!e||e.length===0)return;let r=0;for(const s of e){const n=ev.indexOf(s);if(n===-1)return;r<<=6,r+=n}return r}store(e){const r=Yt(this,Ki);if(Yt(this,Jt)[r]!==void 0){if(BC(this,Nf,Zw).call(this))return this.store(e);Yt(this,Jt)[r]=void 0;return}return Yt(this,Jt)[r]=e,wh(this,Ki,(Yt(this,Ki)+1)%Yt(this,Jt).length),r}consume(e){if(e<0||e>=Yt(this,Jt).length)return;const r=Yt(this,Jt)[e];return Yt(this,Jt)[e]=void 0,r}},o(to,"v"),to);Jt=new WeakMap,Ki=new WeakMap,vh=new WeakMap,Nf=new WeakSet,Zw=Qw(function(){const t=Yt(this,Jt).length,e=t*64;if(e>Yt(this,vh))return!1;Yt(this,Jt).length=e;for(let r=t,s=e;r<s;r++)Yt(this,Jt)[r]=void 0;return wh(this,Ki,t),!0},"#tryGrow"),Qw(tv,"TokenRingBuffer");let Gi=tv;var rv=Object.defineProperty,sv=o(t=>{throw TypeError(t)},"I$k"),IC=o((t,e,r)=>e in t?rv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"w$o"),Lf=o((t,e)=>rv(t,"name",{value:e,configurable:!0}),"o$q"),qC=o((t,e,r)=>IC(t,e+"",r),"x$i"),nv=o((t,e,r)=>e.has(t)||sv("Cannot "+r),"E$t"),ue=o((t,e,r)=>(nv(t,e,"read from private field"),r?r.call(t):e.get(t)),"s$s"),On=o((t,e,r)=>e.has(t)?sv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"a$x"),jn=o((t,e,r,s)=>(nv(t,e,"write to private field"),e.set(t,r),r),"n$v"),Je,_h,Br,yh,Vi,Ff,zf;const iv=(ro=class{constructor(e,r){On(this,Je,new Map),On(this,_h),On(this,Br,0),On(this,yh),On(this,Vi),qC(this,"get"),On(this,Ff,Lf(s=>{const n=ue(this,Je).get(s);if(n!==void 0)return ue(this,Je).delete(s),ue(this,Je).set(s,n),n.value},"#getWithRecencyUpdate")),On(this,zf,Lf(s=>{var n;return(n=ue(this,Je).get(s))==null?void 0:n.value},"#getWithoutRecencyUpdate")),jn(this,_h,e),jn(this,yh,(r==null?void 0:r.onInsert)??(()=>{})),jn(this,Vi,(r==null?void 0:r.onEvict)??(()=>{})),this.get=(r==null?void 0:r.updateRecencyOnAccess)===!1?ue(this,zf):ue(this,Ff)}get estimatedSizeInBytes(){return ue(this,Br)}get size(){return ue(this,Je).size}set(e,r,s){for(ue(this,Je).has(e)?this.delete(e):ue(this,yh).call(this,e,r),ue(this,Je).set(e,{value:r,estimatedByteSize:s}),jn(this,Br,ue(this,Br)+s);ue(this,Br)>ue(this,_h)&&ue(this,Je).size>1;){const[n,i]=ue(this,Je).entries().next().value;ue(this,Je).delete(n),jn(this,Br,ue(this,Br)-i.estimatedByteSize),ue(this,Vi).call(this,n,i.value)}}has(e){return ue(this,Je).has(e)}delete(e){const r=ue(this,Je).get(e);r!==void 0&&(ue(this,Je).delete(e),jn(this,Br,ue(this,Br)-r.estimatedByteSize),ue(this,Vi).call(this,e,r.value))}clear(){ue(this,Je).entries().forEach(([e,r])=>{ue(this,Vi).call(this,e,r.value)}),ue(this,Je).clear(),jn(this,Br,0)}keys(){return ue(this,Je).keys()}*values(){for(const e of ue(this,Je).values())yield e.value}*entries(){for(const[e,r]of ue(this,Je).entries())yield[e,r.value]}},o(ro,"f"),ro);Je=new WeakMap,_h=new WeakMap,Br=new WeakMap,yh=new WeakMap,Vi=new WeakMap,Ff=new WeakMap,zf=new WeakMap,Lf(iv,"LRUByteSizeCache");let av=iv;var ov=Object.defineProperty,cv=o(t=>{throw TypeError(t)},"x$h"),PC=o((t,e,r)=>e in t?ov(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"f$s"),Hf=o((t,e)=>ov(t,"name",{value:e,configurable:!0}),"u$x"),xC=o((t,e,r)=>PC(t,e+"",r),"y$n"),lv=o((t,e,r)=>e.has(t)||cv("Cannot "+r),"E$s"),ze=o((t,e,r)=>(lv(t,e,"read from private field"),r?r.call(t):e.get(t)),"i$o"),wc=o((t,e,r)=>e.has(t)?cv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"l$B"),hv=o((t,e,r,s)=>(lv(t,e,"write to private field"),e.set(t,r),r),"o$p"),et,bh,$h,Kf,Gf;const uv=(so=class{constructor(e,r){wc(this,et,new Map),wc(this,bh),wc(this,$h),xC(this,"get"),wc(this,Kf,Hf(s=>{const n=ze(this,et).get(s);if(n!==void 0)return ze(this,et).delete(s),ze(this,et).set(s,n),n},"#getWithRecencyUpdate")),wc(this,Gf,Hf(s=>ze(this,et).get(s),"#getWithoutRecencyUpdate")),hv(this,bh,e),hv(this,$h,r==null?void 0:r.onEvict),this.get=(r==null?void 0:r.updateRecencyOnAccess)===!1?ze(this,Gf):ze(this,Kf)}get size(){return ze(this,et).size}set(e,r){var s;if(ze(this,et).has(e))ze(this,et).delete(e);else if(ze(this,et).size>=ze(this,bh)){const[n,i]=ze(this,et).entries().next().value;ze(this,et).delete(n),(s=ze(this,$h))==null||s.call(this,n,i)}ze(this,et).set(e,r)}has(e){return ze(this,et).has(e)}delete(e){ze(this,et).delete(e)}clear(){ze(this,et).clear()}keys(){return ze(this,et).keys()}values(){return ze(this,et).values()}entries(){return ze(this,et).entries()}},o(so,"p"),so);et=new WeakMap,bh=new WeakMap,$h=new WeakMap,Kf=new WeakMap,Gf=new WeakMap,Hf(uv,"LRUCache");let vc=uv;var dv=Object.defineProperty,fv=o(t=>{throw TypeError(t)},"it$1"),WC=o((t,e,r)=>e in t?dv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"at$2"),lr=o((t,e)=>dv(t,"name",{value:e,configurable:!0}),"p$p"),kh=o((t,e,r)=>WC(t,typeof e!="symbol"?e+"":e,r),"F$h"),Vf=o((t,e,r)=>e.has(t)||fv("Cannot "+r),"G$b"),E=o((t,e,r)=>(Vf(t,e,"read from private field"),r?r.call(t):e.get(t)),"t$f"),Xe=o((t,e,r)=>e.has(t)?fv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"a$v"),Le=o((t,e,r,s)=>(Vf(t,e,"write to private field"),e.set(t,r),r),"o$o"),Zs=o((t,e,r)=>(Vf(t,e,"access private method"),r),"g$q"),hr,_c,en,dt,As,Yi,tn,yc,rn,Ji,Es,pv,bc,Yf,Nn,$c,Ch,Sh,Jf,mv,kc,rs,Ah,Eh;const gv={current:!1};(async()=>{try{return new Request("http://localhost/",{method:"POST",body:new ReadableStream,duplex:"half"}).duplex!=="half"?!1:fetch("data:a/a;charset=utf-8,",{method:"POST",body:new ReadableStream({start(t){t.enqueue("duplex"),t.close()}}),duplex:"half"}).then(()=>!0,()=>!1)}catch{return!1}})().then(t=>{gv.current=t});const Mh=Symbol("early_abort"),wv=new WeakSet;function Ir(t){return t?t instanceof AbortSignal?wv.has(t):t===Mh:!1}o(Ir,"E$r"),lr(Ir,"isEarlyAbort");const UC={prefix:new Uint8Array([91]),suffix:new Uint8Array([93]),separator:new Uint8Array([44])},vv=(no=class{constructor(e,r,s){Xe(this,Es),Xe(this,hr),Xe(this,_c),Xe(this,en),Xe(this,dt),Xe(this,As),Xe(this,Yi,new Set),Xe(this,tn),Xe(this,yc),Xe(this,rn),Xe(this,Ji,!1),Le(this,hr,e),Le(this,_c,r),Le(this,en,s??{})}get isClosed(){return E(this,Ji)}get batchSizeInBytes(){var e;return((e=E(this,dt))==null?void 0:e.sizeInBytes)??0}write(e,r,s){var n,i;if(E(this,Ji))throw new Error("[direct.dev/shared] BatchStreamOrchestrator is closed");const a=E(this,hr).framing,c=a?a.separator.byteLength+a.suffix.byteLength:0;if(E(this,dt)&&E(this,dt).sizeInBytes+e.byteLength+c>E(this,hr).maxSizeInBytes&&Zs(this,Es,bc).call(this,r),!E(this,dt)||!E(this,As))try{const[p,f]=Zs(this,Es,pv).call(this,r);Le(this,dt,p),Le(this,As,f)}catch(p){(i=(n=E(this,en)).onBatchError)==null||i.call(n,void 0,p);return}const h=E(this,dt),u=E(this,As),d=E(this,tn);return a&&(h.sizeInBytes===0?h.append(a.prefix.slice(0)):h.append(a.separator.slice(0))),h.write(e,s),E(this,hr).windowMs===0&&Zs(this,Es,bc).call(this,r),[d,u]}async flush(e){var r;const s=(r=E(this,rn))==null?void 0:r.signal,n=Zs(this,Es,bc).call(this,e);try{await n}catch(i){if(!Ir(i)&&!Ir(s))throw i}}async close(e){if(!E(this,Ji)&&(Le(this,Ji,!0),await this.flush(e),E(this,Yi).size>0)){const r=await Promise.allSettled(E(this,Yi));for(const s of r)if(s.status==="rejected"&&!Ir(s.reason))throw s.reason}}},o(no,"V"),no);hr=new WeakMap,_c=new WeakMap,en=new WeakMap,dt=new WeakMap,As=new WeakMap,Yi=new WeakMap,tn=new WeakMap,yc=new WeakMap,rn=new WeakMap,Ji=new WeakMap,Es=new WeakSet,pv=lr(function(t){const e=E(this,hr).disableDuplex||!gv.current?new Cv:E(this,hr).isolateSafe?new OC:new DC,r=E(this,_c).prepareContext(t),s=Ye();return s.catch(()=>{}),Fw({timeoutMs:E(this,hr).timeoutMs},async n=>{var i,a;Le(this,rn,n),Le(this,As,r),Le(this,dt,e),Le(this,tn,s);const c=e.maybeConsume();return c&&Zs(this,Es,Yf).call(this,e,r,t,c,s,n.signal).catch(h=>{var u,d;if(Ir(n.signal)){s.__isFulfilled()||s.__reject(Mh).catch(()=>{});return}s.__isFulfilled()||s.__reject(h).catch(()=>{}),!(h instanceof Error&&h.name==="AbortError")&&((d=(u=E(this,en)).onBatchError)==null||d.call(u,r,h))}),(a=(i=E(this,en)).onBatchOpen)==null||a.call(i,r),E(this,hr).windowMs>0&&Le(this,yc,setTimeout(()=>{E(this,dt)===e&&Zs(this,Es,bc).call(this,t)},E(this,hr).windowMs)),s.catch(()=>{})}).catch(()=>{}),[e,r]},"#openBatch"),bc=lr(function(t){var e;if(E(this,dt)===void 0||E(this,As)===void 0||E(this,tn)===void 0||E(this,rn)===void 0)return;clearTimeout(E(this,yc)),Le(this,yc,void 0);const r=(e=E(this,hr).framing)==null?void 0:e.suffix;r&&E(this,dt).append(r.slice(0));const s=E(this,dt).flush(E(this,rn),E(this,dt)instanceof Cv),n=E(this,dt).maybeConsume();if(n){const a=E(this,dt),c=E(this,As),h=E(this,tn),u=E(this,rn).signal;s?h.__isFulfilled()||h.__reject(Mh).catch(()=>{}):Zs(this,Es,Yf).call(this,a,c,t,n,h,u).catch(d=>{var p,f;if(Ir(u)){h.__isFulfilled()||h.__reject(Mh).catch(()=>{});return}h.__isFulfilled()||h.__reject(d).catch(()=>{}),!(d instanceof Error&&d.name==="AbortError")&&((f=(p=E(this,en)).onBatchError)==null||f.call(p,c,d))})}const i=E(this,tn);return Le(this,dt,void 0),Le(this,As,void 0),Le(this,tn,void 0),Le(this,rn,void 0),i},"#closeBatch"),Yf=lr(async function(t,e,r,s,n,i){var a,c;const h=E(this,_c).openRequest(s,e,r,i).finally(()=>{E(this,Yi).delete(h)});E(this,Yi).add(h);const u=await h;n.__resolve(u),(c=(a=E(this,en)).onBatchClose)==null||c.call(a,e,u,t.sizeInBytes,y()-t.startedAt)},"#emitRequest"),lr(vv,"BatchStreamOrchestrator");let _v=vv;const yv=(io=class{constructor(){Xe(this,Jf),kh(this,"startedAt",y()),Xe(this,Nn,0),Xe(this,$c,new Set),Xe(this,Ch,!1),Xe(this,Sh,!1)}get sizeInBytes(){return E(this,Nn)}maybeConsume(){if(!E(this,Sh)&&this.requestInit!==void 0)return Le(this,Sh,!0),this.requestInit}write(e,r){r?E(this,$c).add(r):Le(this,Ch,!0),Le(this,Nn,E(this,Nn)+e.byteLength),this.enqueue(e)}append(e){Le(this,Nn,E(this,Nn)+e.byteLength),this.enqueue(e)}flush(e,r=!1){return this.close(),Zs(this,Jf,mv).call(this,e,r)}},o(io,"X"),io);Nn=new WeakMap,$c=new WeakMap,Ch=new WeakMap,Sh=new WeakMap,Jf=new WeakSet,mv=lr(function(t,e){if(E(this,$c).size===0||E(this,Ch))return!1;try{const r=new Set(Array.from(E(this,$c)).filter(n=>!n.aborted));if(e&&r.size===0)return!0;const s=lr(()=>{r.size===0&&(wv.add(t.signal),t.abort())},"checkAllAborted");for(const n of r)n.addEventListener("abort",()=>{r.delete(n),s()},{once:!0});s()}catch{}return!1},"#applyEarlyAbort"),lr(yv,"BatchBody");let Xf=yv;const bv=(ao=class extends Xf{constructor(){super(),kh(this,"requestInit"),Xe(this,kc);let e;const r=new ReadableStream({start(s){e=s}});Le(this,kc,e),this.requestInit={body:r,duplex:"half"}}enqueue(e){E(this,kc).enqueue(e)}close(){E(this,kc).close()}},o(ao,"Z"),ao);kc=new WeakMap,lr(bv,"StreamBatch");let DC=bv;const $v=(oo=class extends Xf{constructor(){super(),kh(this,"requestInit"),Xe(this,rs,[]),Xe(this,Ah,!1);const e=new ReadableStream({pull:lr(async r=>{if(E(this,rs).length===1)r.enqueue(E(this,rs)[0]),E(this,rs).length=0;else if(E(this,rs).length>0){const s=E(this,rs).reduce((a,c)=>a+c.length,0),n=new Uint8Array(s);let i=0;for(const a of E(this,rs))n.set(a,i),i+=a.length;r.enqueue(n),E(this,rs).length=0}E(this,Ah)?r.close():await pc(10)},"pull")});this.requestInit={body:e,duplex:"half"}}enqueue(e){E(this,rs).push(e)}close(){Le(this,Ah,!0)}},o(oo,"$"),oo);rs=new WeakMap,Ah=new WeakMap,lr($v,"IsolateStreamBatch");let OC=$v;const kv=(co=class extends Xf{constructor(){super(...arguments),kh(this,"requestInit"),Xe(this,Eh,[])}enqueue(e){E(this,Eh).push(e)}close(){const e=new Uint8Array(this.sizeInBytes);let r=0;for(const s of E(this,Eh))e.set(s,r),r+=s.length;this.requestInit={body:e}}},o(co,"tt"),co);Eh=new WeakMap,lr(kv,"BufferBatch");let Cv=kv;var jC=Object.defineProperty,Sv=o(t=>{throw TypeError(t)},"L$i"),Qf=o((t,e)=>jC(t,"name",{value:e,configurable:!0}),"w$m"),Zf=o((t,e,r)=>e.has(t)||Sv("Cannot "+r),"C$k"),we=o((t,e,r)=>(Zf(t,e,"read from private field"),r?r.call(t):e.get(t)),"s$r"),qr=o((t,e,r)=>e.has(t)?Sv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"n$t"),ve=o((t,e,r,s)=>(Zf(t,e,"write to private field"),e.set(t,r),r),"i$n"),ur=o((t,e,r)=>(Zf(t,e,"access private method"),r),"c$z"),Av=o((t,e,r,s)=>({set _(n){ve(t,e,n)},get _(){return we(t,e,s)}}),"F$g"),Th,Rh,Xi,Cc,Bh,Sc,qt,it,Ms,Ln,Pt,Ts,Ac;const Ev=(lo=class{constructor(e,r){qr(this,Pt),qr(this,Th),qr(this,Rh),qr(this,Xi),qr(this,Cc),qr(this,Bh),qr(this,Sc),qr(this,qt,"half_closed"),qr(this,it,0),qr(this,Ms),qr(this,Ln,y()),ve(this,Th,e.halfOpenAttempts??3),ve(this,Rh,e.halfClosedAttempts??8),ve(this,Cc,e.backoff??(s=>250*2**s)),ve(this,Xi,e.cooldownMs??3e4),ve(this,Bh,(r==null?void 0:r.onFailure)??(()=>{})),ve(this,Sc,(r==null?void 0:r.onTransition)??(()=>{}))}recordSuccess(){switch(ve(this,Ln,y()),we(this,qt)){case"half_closed":ur(this,Pt,Ts).call(this,"closed"),ve(this,it,0);break;case"closed":ve(this,it,0);break;case"half_open":Av(this,it)._++,we(this,it)>=we(this,Th)&&(ur(this,Pt,Ts).call(this,"closed"),ve(this,it,0));break;case"open":ur(this,Pt,Ts).call(this,"closed"),ve(this,it,0);break}}recordFailure(){ve(this,Ln,y()),ur(this,Pt,Ac).call(this);let e=0,r=!0;switch(we(this,qt)){case"half_closed":{Av(this,it)._++,we(this,it)>=we(this,Rh)?(ve(this,Ms,y(+we(this,Xi))),ur(this,Pt,Ts).call(this,"open"),ve(this,it,0),r=!1):e=we(this,Cc).call(this,we(this,it)-1);break}case"closed":{ur(this,Pt,Ts).call(this,"half_closed"),ve(this,it,1),e=we(this,Cc).call(this,0);break}case"half_open":{ve(this,Ms,y(+we(this,Xi))),ur(this,Pt,Ts).call(this,"open"),ve(this,it,0),r=!1;break}case"open":{r=!1;break}}return we(this,Bh).call(this,we(this,qt),e),e===0?Promise.resolve(r):pc(e).then(()=>r)}check(){return ur(this,Pt,Ac).call(this),we(this,qt)!=="open"}reset(){const e=we(this,qt);ve(this,qt,"half_closed"),ve(this,it,0),ve(this,Ms,void 0),ve(this,Ln,y()),e!=="half_closed"&&we(this,Sc).call(this,e,"half_closed")}getState(){return ur(this,Pt,Ac).call(this),we(this,qt)}getAttemptCount(){return ur(this,Pt,Ac).call(this),we(this,it)}},o(lo,"S"),lo);Th=new WeakMap,Rh=new WeakMap,Xi=new WeakMap,Cc=new WeakMap,Bh=new WeakMap,Sc=new WeakMap,qt=new WeakMap,it=new WeakMap,Ms=new WeakMap,Ln=new WeakMap,Pt=new WeakSet,Ts=Qf(function(t){if(we(this,qt)===t)return;const e=we(this,qt);ve(this,qt,t),t==="closed"&&ve(this,Ms,void 0),we(this,Sc).call(this,e,t)},"#transition"),Ac=Qf(function(){const t=y();we(this,qt)==="open"?(!we(this,Ms)||t>we(this,Ms))&&(ur(this,Pt,Ts).call(this,"half_open"),ve(this,it,0),ve(this,Ln,t)):t-we(this,Ln)>=we(this,Xi)&&(we(this,qt)!=="half_closed"&&ur(this,Pt,Ts).call(this,"half_closed"),ve(this,it,0),ve(this,Ms,void 0))},"#checkCooldown"),Qf(Ev,"CircuitBreaker");let Ih=Ev;var Mv=Object.defineProperty,Tv=o(t=>{throw TypeError(t)},"Pe"),NC=o((t,e,r)=>e in t?Mv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"Le$1"),z=o((t,e)=>Mv(t,"name",{value:e,configurable:!0}),"a$t"),ep=o((t,e,r)=>NC(t,typeof e!="symbol"?e+"":e,r),"ie$7"),tp=o((t,e,r)=>e.has(t)||Tv("Cannot "+r),"fe$2"),_e=o((t,e,r)=>(tp(t,e,"read from private field"),e.get(t)),"h$s"),dr=o((t,e,r)=>e.has(t)?Tv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"b$r"),Pr=o((t,e,r,s)=>(tp(t,e,"write to private field"),e.set(t,r),r),"g$p"),xr=o((t,e,r)=>(tp(t,e,"access private method"),r),"C$j"),Ec,Mc,Tc,Qi,qh,Ph,fr,Rc,Fn,xh,Wh,Xt,zn,rp,sp,Rv;const Bv=2048,Hn={closed:0,half_closed:1,half_open:2,open:3},Wr=z(()=>{},"noop"),LC={getState:z(()=>"closed","getState"),check:z(()=>!0,"check"),recordSuccess:z(()=>{},"recordSuccess"),recordFailure:z(()=>Promise.resolve(!1),"recordFailure")},FC=z(()=>!0,"ALWAYS_RACE"),zC=z(()=>!0,"ALWAYS_ACCEPT_OUTPUT"),Uh=z(()=>{},"CATCH_NOOP"),HC=new Error("Pipeline timeout exceeded"),Bc=z((t,e)=>t!==void 0&&t>e?t:e,"getTimingBaseline");function np(t,e,r,s){return new Ss({maxBufferSize:s,onEarlyDisposal:Wr,onBackpressure:Wr},async(n,i)=>{const a=[];let c;const h=z(()=>{if(c&&(clearTimeout(c),c=void 0),a.length===0||i.aborted)return;const u=r(a);for(const d of u)n(d);a.length=0},"flush");for await(const u of t){if(i.aborted)break;a.push(u),e<0||a.length>=s?h():c||(c=setTimeout(()=>{c=void 0,h()},e))}h()})}o(np,"Re$3"),z(np,"createBatchedAsyncIterable");const Iv=(ho=class{constructor(e){ep(this,"name"),ep(this,"racing"),ep(this,"check"),dr(this,Ec),dr(this,Mc),dr(this,Tc),dr(this,Qi),this.name=e.name,this.racing=e.racing??{},this.check=e.check,Pr(this,Ec,e.claim),Pr(this,Mc,e.fulfill),Pr(this,Tc,e.batchWindowMs??0),Pr(this,Qi,e.circuitBreaker===!1?LC:new Ih(e.circuitBreaker??{}))}claimSync(e,r,s){return _e(this,Ec).call(this,e,r,s)}claimAsync(e,r,s,n){return np(e,_e(this,Tc),i=>_e(this,Ec).call(this,i,r,s),n??Bv)}fulfillSync(e,r,s){return _e(this,Mc).call(this,e,r,s)}fulfillAsync(e,r,s,n){return np(e,_e(this,Tc),i=>_e(this,Mc).call(this,i,r,s),n??Bv)}getHealth(){return _e(this,Qi).getState()}recordSuccess(){_e(this,Qi).recordSuccess()}recordFailure(){_e(this,Qi).recordFailure()}},o(ho,"Ae"),ho);Ec=new WeakMap,Mc=new WeakMap,Tc=new WeakMap,Qi=new WeakMap,z(Iv,"RequestHandler");let sn=Iv;const qv=(uo=class{constructor(e,r){dr(this,Xt),dr(this,qh),dr(this,Ph),dr(this,fr),dr(this,Rc),dr(this,Fn),dr(this,xh),dr(this,Wh);const s=(r==null?void 0:r.acceptOutput)??zC;Pr(this,xh,(r==null?void 0:r.canRace)??FC),Pr(this,Wh,r==null?void 0:r.onTelemetry),Pr(this,Ph,(r==null?void 0:r.timeoutMs)??1e4),Pr(this,fr,(r==null?void 0:r.maxBatchSize)??2048),Pr(this,Rc,r==null?void 0:r.transformInput),Pr(this,Fn,r==null?void 0:r.transformError),Pr(this,qh,e.map(n=>{var i;return{name:n.name,type:n.type,origin:n.origin,handlers:n.handlers,strategy:n.strategy,failover:{...n.failover,acceptOutput:((i=n.failover)==null?void 0:i.acceptOutput)??s}}}))}request(e,r){const s=Array.isArray(e),n=s?e:[e],i=n.length;if(i>_e(this,fr))throw new Error(`RequestPipeline.request(): batch size exceeds limits (${i} > ${_e(this,fr)})`);const a=new Array(i),c=y();for(let g=0;g<i;g++){const m=n[g],w=_e(this,Rc)?_e(this,Rc).call(this,m,r):m;a[g]={index:g,input:w,canRace:_e(this,xh).call(this,w),deferred:Ye(),lastError:void 0,lastHandler:void 0,executions:[],startedAt:c,latencyMs:0}}const h=new Set,u=new AbortController,d=setTimeout(()=>{for(const g of a)g.deferred.__isFulfilled()||(g.lastError??=HC);u.abort()},_e(this,Ph)),p=z(()=>{var g;clearTimeout(d),u.abort();const m=y();for(const w of a){for(const _ of w.executions)_.result==="pending"&&(_.result="timeout");if(!w.deferred.__isFulfilled()){const _=w.executions.at(-1),S=_?` (last: stage="${_.stageName}", handler="${_.handlerName}")`:"";w.lastError??=new Error(`No handler available for item at index ${w.index}${S}`),w.latencyMs=m-w.startedAt,_e(this,Fn)?w.deferred.__resolve(_e(this,Fn).call(this,w.input,w.lastError)):(w.deferred.catch(Uh),w.deferred.__reject(w.lastError))}}(g=_e(this,Wh))==null||g.call(this,a,r)},"finalize"),f=xr(this,Xt,zn).call(this,a,r,u.signal,h,0);if(f instanceof Promise){const g=xr(this,Xt,sp).call(this,a,s,u),m=g instanceof Ss?g.wait():Promise.resolve(g);return Promise.race([f,m]).catch(Uh).finally(p),g}else return p(),xr(this,Xt,sp).call(this,a,s,u)}},o(uo,"me"),uo);qh=new WeakMap,Ph=new WeakMap,fr=new WeakMap,Rc=new WeakMap,Fn=new WeakMap,xh=new WeakMap,Wh=new WeakMap,Xt=new WeakSet,zn=z(function(t,e,r,s,n){if(r.aborted)return;const i=_e(this,qh)[n];if(!i)return;const a=xr(this,Xt,rp).call(this,i,s);if(!a)return xr(this,Xt,zn).call(this,t,e,r,s,n+1);s.add(a);const c=a.getHealth(),h=i.failover??{};let u;const d=new Map;let p,f,g=!1,m,w,_,S=[],b=[],O=!1,j=!1,W=Array.isArray(t)?[]:new Ss({onEarlyDisposal:Wr,onBackpressure:Wr,maxBufferSize:_e(this,fr)});const K=Array.isArray(W)?W:[],q=[],Pe=[];let je,Ae,Ve;const Ft=z(()=>{w=xr(this,Xt,zn).call(this,S,e,r,s,n)},"triggerDeclinedContinuation"),zt=z(()=>{_=xr(this,Xt,zn).call(this,b,e,r,s,i.strategy==="exhaustive"?n:n+1)},"triggerClaimedContinuation"),or=z(k=>{r.aborted||g||k.deferred.__isFulfilled()||k.lastHandler!==a||(!Array.isArray(b)&&b.size===0&&zt(),b.push(k))},"continueClaimedToNextStage"),Qr=i.strategy==="first_eligible"&&xr(this,Xt,rp).call(this,i,s)!==void 0?k=>{r.aborted||g||k.deferred.__isFulfilled()||k.lastHandler!==a||(!Array.isArray(S)&&S.size===0&&Ft(),S.push(k))}:or,Zr=z(()=>{if(Array.isArray(S)){const k=S;if(S=new Ss({onEarlyDisposal:Wr,onBackpressure:Wr,maxBufferSize:_e(this,fr)}),k.length>0){Ft();for(const P of k)S.push(P)}}if(Array.isArray(b)){const k=b;if(b=new Ss({onEarlyDisposal:Wr,onBackpressure:Wr,maxBufferSize:_e(this,fr)}),k.length>0){zt();for(const P of k)b.push(P)}}},"transitionToAsyncContinuation"),eh=z(()=>{for(const k of u)k.lastHandler===a&&k.canRace&&!k.deferred.__isFulfilled()&&or(k)},"raceEligibleItems"),tw=z((k,P)=>{const M={stageIndex:n,stageName:i.name,stageType:i.type,stageOrigin:i.origin,handlerName:a.name,health:c,claimMs:0,checkMs:f,fulfillMs:0,result:"pending",meta:void 0};if(k.executions.push(M),P instanceof Promise){if(Array.isArray(W)){W=new Ss({onEarlyDisposal:Wr,onBackpressure:Wr,maxBufferSize:_e(this,fr)});for(const ee of K)W.push(ee)}q.push(P.then(ee=>rw(k,ee,M),ee=>Ui(k,ee,M,"claim")))}else rw(k,P,M)},"processClaim"),rw=z((k,P,M)=>{if(M.claimMs=y()-Bc(d.get(k),p),M.meta=P==null?void 0:P[1],r.aborted||k.deferred.__isFulfilled()){M.result==="pending"&&(M.result="superseded");return}if(P===void 0){M.result==="pending"&&(M.result="unclaimed"),Qr(k);return}const ee=[k,P[0],M];W.push(ee),Array.isArray(W)||K.push(ee)},"handleClaim"),sw=z((k,P,M)=>{P instanceof Promise?Pe.push(P.then(ee=>nw(k,ee,M)).catch(ee=>Ui(k,ee,M,"fulfill"))):nw(k,P,M)},"processOutput"),nw=z((k,P,M)=>{if(r.aborted||k.deferred.__isFulfilled()){M.result==="pending"&&(M.fulfillMs=y()-Bc(d.get(k),p)-M.claimMs,M.result="superseded");return}M.fulfillMs=y()-Bc(d.get(k),p)-M.claimMs,h.acceptOutput(P,M.meta)?(O=!0,M.result="fulfilled",k.latencyMs=y()-k.startedAt,k.deferred.__resolve(P)):(M.result="rejected",or(k))},"handleOutput"),Ui=z((k,P,M,ee)=>{if(r.aborted||k.deferred.__isFulfilled()){M&&M.result==="pending"&&(M.claimMs=y()-Bc(d.get(k),p),M.result="superseded");return}M||(M=k.executions.findLast(lc=>lc.stageIndex===n&&lc.handlerName===a.name&&lc.result==="pending"));const ys=y()-Bc(d.get(k),p);M?(ee==="claim"?(M.claimMs=ys,M.fulfillMs=0):M.fulfillMs=ys-M.claimMs,M.result="error"):(M={stageIndex:n,stageName:i.name,stageType:i.type,stageOrigin:i.origin,handlerName:a.name,health:c,claimMs:ys,checkMs:f,fulfillMs:0,result:"error",meta:void 0},k.executions.push(M)),k.lastError=P instanceof Error?P:new Error(String(P)),j=!0,!(g||k.lastHandler!==a)&&(h.continueOnError!==!1?or(k):_e(this,Fn)?(k.latencyMs=y()-k.startedAt,k.deferred.__resolve(_e(this,Fn).call(this,k.input,k.lastError))):k.deferred.__reject(k.lastError))},"handleError");if(Array.isArray(t)){u=t;const k=y();for(const P of u)P.lastHandler=a,d.set(P,k)}else u=[],t.tap(k=>{k.lastHandler=a,u.push(k),d.set(k,y())});const cf=y(),v0=z(()=>{var k;if(!a.check)return p=cf,f=0,!0;((k=a.racing)==null?void 0:k.checkMs)!==void 0&&(je=setTimeout(()=>{if(r.aborted)return;const ee=Array.isArray(S)||S.size===0,ys=Array.isArray(b)||b.size===0;ee&&ys&&(g=!0,m=xr(this,Xt,zn).call(this,Array.isArray(t)?t:t.tee(),e,r,s,n))},a.racing.checkMs),r.addEventListener("abort",()=>{clearTimeout(je)},{once:!0}));const P=z(ee=>(clearTimeout(je),p=y(),f=p-cf,ee),"handleCheckResult"),M=z(()=>(clearTimeout(je),p=y(),f=p-cf,!1),"handleCheckError");try{const ee=a.check(e,r);return ee instanceof Promise?ee.then(P,M):P(ee)}catch{return M()}},"runCheck"),_0=z(()=>{const k=z(()=>{!Array.isArray(W)&&!W.isClosed&&W.close(null),clearTimeout(Ae)},"cleanup");if(Array.isArray(t))try{const P=a.claimSync(t,e,r);for(let M=0;M<t.length;M++)tw(t[M],P[M]);if(q.length>0)return Promise.allSettled(q).then(k);k()}catch(P){for(const M of u)Ui(M,P,void 0,"claim");k()}else return(async()=>{try{const P=a.claimAsync(t,e,r,_e(this,fr))[Symbol.asyncIterator]();let M=0;for(;;){const ee=await P.next();if(ee.done||r.aborted)break;tw(u[M++],ee.value)}await Promise.allSettled(q)}catch(P){for(const M of u)Ui(M,P,void 0,"claim")}finally{k()}})()},"runClaimLoop"),y0=z(()=>{const k=z(()=>{clearTimeout(Ve)},"cleanup");if(Array.isArray(W))try{const P=a.fulfillSync(W,e,r);for(let M=0;M<W.length;M++){const[ee,,ys]=K[M];sw(ee,P[M],ys)}if(Pe.length>0)return Promise.allSettled(Pe).then(k);k()}catch(P){for(const[M,,ee]of K)Ui(M,P,ee,"fulfill");k()}else return(async()=>{try{const P=a.fulfillAsync(W,e,r,_e(this,fr))[Symbol.asyncIterator]();let M=0;for(;;){const ee=await P.next();if(ee.done||r.aborted)break;const ys=M++,[lc,,$0]=K[ys];sw(lc,ee.value,$0)}await Promise.allSettled(Pe)}catch(P){for(const[M,,ee]of K)Ui(M,P,ee,"fulfill")}finally{k()}})()},"runFulfillLoop"),iw=z(()=>{r.aborted||(a.racing.claimMs!==void 0&&(a.racing.claimMs>0?Ae=setTimeout(eh,a.racing.claimMs):eh()),a.racing.timeoutMs!==void 0&&(a.racing.timeoutMs>0?Ve=setTimeout(eh,a.racing.timeoutMs):eh()),r.addEventListener("abort",()=>{clearTimeout(Ae),clearTimeout(Ve)},{once:!0}))},"startRaceTimers");Array.isArray(t)?iw():t.wait().then(iw);const aw=z(()=>{if(clearTimeout(je),clearTimeout(Ae),clearTimeout(Ve),j?a.recordFailure():O&&a.recordSuccess(),Array.isArray(S)?S.length>0&&Ft():S.isClosed||S.close(null),Array.isArray(b)?b.length>0&&zt():b.isClosed||b.close(null),w instanceof Promise||_ instanceof Promise)return Promise.all([w,_]).then(()=>{})},"finalize"),b0=z(()=>{if(r.aborted)return;const k=_0(),P=y0();return k instanceof Promise||P instanceof Promise?(Zr(),Promise.allSettled([k,P]).then(aw)):aw()},"runLoops"),ow=z(k=>k?b0():(clearTimeout(je),clearTimeout(Ae),clearTimeout(Ve),g?m:xr(this,Xt,zn).call(this,t,e,r,s,n)),"dispatch"),lf=v0();return lf instanceof Promise?(Zr(),lf.then(ow)):ow(lf)},"#execute"),rp=z(function(t,e){const r=t.handlers.filter(s=>!e.has(s)&&s.getHealth()!=="open");if(r.length!==0)switch(t.strategy){case"first_eligible":return r[0];case"load_balanced":return r[Math.floor(Math.random()*r.length)];case"exhaustive":{const s=r.reduce((i,a)=>{const c=Hn[a.getHealth()];return i[c]??=[],i[c].push(a),i},{}),n=Math.random()<.8?s[Hn.closed]??s[Hn.half_closed]??s[Hn.half_open]:s[Hn.half_closed]??s[Hn.closed]??s[Hn.half_open];return n!=null&&n.length?n[Math.floor(Math.random()*n.length)]:void 0}default:return}},"#selectHandler"),sp=z(function(t,e,r){if(!e){const n=t[0].deferred;switch(n.__state()){case"resolved":return n.__resolvedWith();case"rejected":throw n.catch(Uh),n.__rejectedWith();default:return n}}const s=new Array(t.length);for(let n=0;n<t.length;n++){const i=t[n].deferred;switch(i.__state()){case"resolved":s[n]=i.__resolvedWith();break;case"rejected":throw t[n].deferred.catch(Uh),i.__rejectedWith();default:return xr(this,Xt,Rv).call(this,t,r)}}return s},"#resolveResult"),Rv=z(function(t,e){const r=new Ss({onEarlyDisposal:z(()=>e.abort(),"onEarlyDisposal"),onBackpressure:Wr,maxBufferSize:_e(this,fr)}),s=t.length;let n=0;for(const i of t)i.deferred.then(a=>{r.isClosed||r.push(a),++n===s&&!r.isClosed&&r.close(void 0)},a=>{r.isClosed||r.throw(a instanceof Error?a:new Error(String(a)))});return r},"#makeAsyncIterable"),z(qv,"RequestPipeline");let KC=qv;const ft=globalThis.__wireCheckpointParseRef??={lastCtx:"",lastError:""},pe=globalThis.__wireCheckpointDecodeRef??={arrayBudget:0,byteBudget:0,offset:0};var GC=Object.defineProperty,xe=o((t,e)=>GC(t,"name",{value:e,configurable:!0}),"r$n");function ne(t){const e=xe(f=>{if(!r(f,ft))throw new Error(`${ft.lastCtx} ${ft.lastError}`);return f},"parse"),r=t.safeParse,s=t.encode,n=t.decodeUntrusted,i=t.decodeTrusted;let a,c,h;function u(){return a??={_parse:xe(f=>{if(f===void 0)return f;if(!r(f,ft))throw new Error(ft.lastError);return f},"_parse"),_safeParse:xe(f=>f===void 0||r(f,ft),"_safeParse"),_encode:xe(f=>f===void 0?"\u07FE":s(f),"_encode"),_decodeTrusted:xe(f=>{if(f.charCodeAt(pe.offset)===2046){pe.offset++;return}return i(f,pe)},"_decodeTrusted"),_decodeUntrusted:xe(f=>{if(f.charCodeAt(pe.offset)===2046){pe.offset++;return}return n(f,pe)},"_decodeUntrusted"),get optional(){return a},get nullable(){return p()}},a}o(u,"C"),xe(u,"makeOptional");function d(){return c??={_parse:xe(f=>{if(f===null)return f;if(!r(f,ft))throw new Error(ft.lastError);return f},"_parse"),_safeParse:xe(f=>f===null||r(f,ft),"_safeParse"),_encode:xe(f=>f===null?"\u07FF":s(f),"_encode"),_decodeTrusted:xe(f=>f.charCodeAt(pe.offset)===2047?(pe.offset++,null):i(f,pe),"_decodeTrusted"),_decodeUntrusted:xe(f=>f.charCodeAt(pe.offset)===2047?(pe.offset++,null):n(f,pe),"_decodeUntrusted"),get optional(){return p()},get nullable(){return c}},c}o(d,"g"),xe(d,"makeNullable");function p(){return h??={_parse:xe(f=>{if(f==null)return f;if(!r(f,ft))throw new Error(ft.lastError);return f},"_parse"),_safeParse:xe(f=>f==null||r(f,ft),"_safeParse"),_encode:xe(f=>f==null?String.fromCharCode(f===void 0?2046:2047):s(f),"_encode"),_decodeTrusted:xe(f=>{const g=f.charCodeAt(pe.offset);if(g===2046){pe.offset++;return}return g===2047?(pe.offset++,null):i(f,pe)},"_decodeTrusted"),_decodeUntrusted:xe(f=>{const g=f.charCodeAt(pe.offset);if(g===2046){pe.offset++;return}return g===2047?(pe.offset++,null):n(f,pe)},"_decodeUntrusted"),get optional(){return h},get nullable(){return h}},h}return o(p,"h"),xe(p,"makeOptionalAndNullable"),{_parse:e,_safeParse:xe(f=>r(f,ft),"_safeParse"),_encode:s,_decodeTrusted:xe(f=>i(f,pe),"_decodeTrusted"),_decodeUntrusted:xe(f=>n(f,pe),"_decodeUntrusted"),get optional(){return u()},get nullable(){return d()}}}o(ne,"b$q"),xe(ne,"makeType");var Pv=Object.defineProperty,VC=o((t,e,r)=>e in t?Pv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"O$j"),ip=o((t,e)=>Pv(t,"name",{value:e,configurable:!0}),"d$r"),Ic=o((t,e,r)=>VC(t,typeof e!="symbol"?e+"":e,r),"a$s");const ap=(fo=class extends Error{constructor(e){super(`[direct.dev/wire/checkpoint.parse] ${e}`)}},o(fo,"u"),fo);ip(ap,"CheckpointParseError"),Ic(ap,"lastMessage","");let Dh=ap;const xv=(po=class extends Error{constructor(e){super(`[direct.dev/wire/checkpoint.encode] ${e}`)}},o(po,"w"),po);ip(xv,"CheckpointEncodeError");let Wv=xv;const ss=(mo=class extends Error{constructor(e){super(`[direct.dev/wire/checkpoint.decode] ${e}`)}},o(mo,"t"),mo);ip(ss,"CheckpointDecodeError"),Ic(ss,"PAYLOAD_TRUNCATED",Object.freeze(new ss("payload truncated"))),Ic(ss,"BYTE_BUDGET_EXHAUSTED",Object.freeze(new ss("byteBudget exhausted"))),Ic(ss,"ARRAY_BUDGET_EXHAUSTED",Object.freeze(new ss("arrayBudget exhausted"))),Ic(ss,"JSON_PARSE",Object.freeze(new ss("JSON.parse failed")));let $=ss;const qc=Symbol("[direct.dev/wire/checkpoint.safeParse] invalid input");var YC=Object.defineProperty,Kn=o((t,e)=>YC(t,"name",{value:e,configurable:!0}),"h$r");const at=Kn((t,e)=>{const r=e.offset,s=t.charCodeAt(r);if(s<64)return e.offset=r+1,s;const n=t.charCodeAt(r+1);if(n<64)return e.offset=r+2,s&63|n<<6;const i=t.charCodeAt(r+2);if(i<64)return e.offset=r+3,s&63|(n&63)<<6|i<<12;const a=t.charCodeAt(r+3);if(a<64)return e.offset=r+4,s&63|(n&63)<<6|(i&63)<<12|a<<18;const c=t.charCodeAt(r+4);if(c<64)return e.offset=r+5,s&63|(n&63)<<6|(i&63)<<12|(a&63)<<18|c<<24;const h=t.charCodeAt(r+5);return e.offset=r+6,(s&63|(n&63)<<6|(i&63)<<12|(a&63)<<18|(c&63)<<24|(h&3)<<30)>>>0},"uint32"),Rs=Kn((t,e,r)=>{const s=r.offset,n=(e&112)>>4,i=t.charCodeAt(s);if(n<2)return r.offset=s+1,i;const a=t.charCodeAt(s+1);if(n<3)return r.offset=s+2,i&127|a<<7;const c=t.charCodeAt(s+2);if(n<4)return r.offset=s+3,i&127|(a&127)<<7|c<<14;const h=t.charCodeAt(s+3);if(n<5)return r.offset=s+4,i&127|(a&127)<<7|(c&127)<<14|h<<21;const u=t.charCodeAt(s+4);return r.offset=s+5,(i&127|(a&127)<<7|(c&127)<<14|(h&127)<<21|(u&15)<<28)>>>0},"uint32_base128"),Uv=Kn((t,e)=>{const r=e.offset,s=t.charCodeAt(r),n=t.charCodeAt(r+1),i=t.charCodeAt(r+2),a=t.charCodeAt(r+3),c=t.charCodeAt(r+4),h=t.charCodeAt(r+5);e.offset=r+6;const u=s|n<<7|i<<14|a<<21,d=c|h<<7;return u+d*268435456},"timestamp");Kn((t,e)=>{const r=t.charCodeAt(e.offset++);return Bs(t,r,e)},"num");const Bs=Kn((t,e,r)=>{const s=r.offset,n=s+((e&124)>>2),i=+t.slice(s,n);return r.offset=n,i},"num_header"),nn=Kn((t,e)=>{const r=at(t,e);return t.slice(e.offset,e.offset+=r)},"str"),an=Kn((t,e,r)=>{const s=Rs(t,e,r);return t.slice(r.offset,r.offset+=s)},"str_base128");var JC=Object.defineProperty,Zi=o((t,e)=>JC(t,"name",{value:e,configurable:!0}),"t$c");const pr=Zi(t=>{let e="",r=t&63;return t>>>=6,t>0&&(e+=String.fromCharCode(r|64),r=t&63,t>>=6,t>0&&(e+=String.fromCharCode(r|64),r=t&63,t>>=6,t>0&&(e+=String.fromCharCode(r|64),r=t&63,t>>=6,t>0&&(e+=String.fromCharCode(r|64),r=t&63,t>>=6,t>0&&(e+=String.fromCharCode(r|64),r=t&63))))),e+String.fromCharCode(r)},"uint32"),Pc=Zi((t,e=0)=>{let r="",s=t&127;return t>>>=7,t>0&&(r+=String.fromCharCode(s),s=t&127,t>>=7,t>0&&(r+=String.fromCharCode(s),s=t&127,t>>=7,t>0&&(r+=String.fromCharCode(s),s=t&127,t>>=7,t>0&&(r+=String.fromCharCode(s),s=t&127)))),String.fromCharCode(e|r.length+1<<4)+r+String.fromCharCode(s)},"uint32_base128"),XC=Zi(t=>{const e=t&268435455,r=Math.floor(t/268435456),s=e&127,n=e>>7&127,i=e>>14&127,a=e>>21&127,c=r&127,h=r>>7&127;return String.fromCharCode(s)+String.fromCharCode(n)+String.fromCharCode(i)+String.fromCharCode(a)+String.fromCharCode(c)+String.fromCharCode(h)},"timestamp"),Oh=Zi((t,e=0)=>{const r=""+t;return String.fromCharCode(e|r.length<<2)+r},"num"),jh=Zi(t=>pr(t.length)+t,"str"),Nh=Zi((t,e=0)=>Pc(t.length,e)+t,"str_base128");var QC=Object.defineProperty,me=o((t,e)=>QC(t,"name",{value:e,configurable:!0}),"l$x");function xc(t,e){const r=Object.entries(t).sort(([p],[f])=>p===f?0:p>f?1:-1),s=[],n=[];for(const p of r)p[1]._safeParse(void 0)?s.push(p):n.push(p);const i=s.length>0&&s.length<12,a=new Set(e==null?void 0:e.ignoredProps),c=e==null?void 0:e.ignoreExtraProps,h=r.length,u=s.length,d=ne({safeParse(p,f){if(!Fi(p))return f.lastCtx="",f.lastError="must be a record",!1;for(let g=0;g<h;g++){const[m,w]=r[g];if(!w._safeParse(p[m]))return f.lastCtx=`.${m}${f.lastCtx}`,!1}if(!c){for(const g in p)if(!(g in t)&&!a.has(g))return f.lastCtx=`.${g}${f.lastCtx}`,f.lastError="not in schema",!1}return!0},encode:me(p=>{if(i){let g="",m=0;for(let w=0;w<u;w++){const[_,S]=s[w];p[_]!==void 0?g+=S._encode(p[_]):m|=1<<w}for(const[w,_]of n)g+=_._encode(p[w]);return m>0||g.charCodeAt(0)&2048?String.fromCharCode(m|2048)+g:g}let f="";for(const[g,m]of s)f+=m._encode(p[g]);for(const[g,m]of n)f+=m._encode(p[g]);return f},"encode"),decodeTrusted:me((p,f)=>{const g={};if(i){let m=0;const w=p.charCodeAt(f.offset);w&2048&&(f.offset++,m=w);for(let _=0;_<u;_++){const[S,b]=s[_];(m&1<<_)===0?g[S]=b._decodeTrusted(p):g[S]=void 0}}else for(const[m,w]of s)g[m]=w._decodeTrusted(p);for(const[m,w]of n)g[m]=w._decodeTrusted(p);return g},"decodeTrusted"),decodeUntrusted:me((p,f)=>{const g={};if(i){let m=0;const w=p.charCodeAt(f.offset);w&2048&&(f.offset++,m=w);for(let _=0;_<u;_++){const[S,b]=s[_];(m&1<<_)===0?g[S]=b._decodeUntrusted(p):g[S]=void 0}}else for(const[m,w]of s)g[m]=w._decodeUntrusted(p);for(const[m,w]of n)g[m]=w._decodeUntrusted(p);return g},"decodeUntrusted")});return Object.assign(d,{keys:Object.keys(t)})}o(xc,"P$g"),me(xc,"shape");function Dv(t,e){const r=(e==null?void 0:e.minLength)??0,s=(e==null?void 0:e.maxLength)??16384;return ne({safeParse:me((n,i)=>{if(!Array.isArray(n))return i.lastCtx="",i.lastError="must be an array",!1;const a=n.length;if(a<r)return i.lastCtx="",i.lastError=`must contain >= ${r} items`,!1;if(a>s)return i.lastCtx="",i.lastError=`must contain <= ${s} items`,!1;for(let c=0;c<a;c++)if(!t._safeParse(n[c]))return i.lastCtx=`[${c}]${i.lastCtx}`,!1;return!0},"safeParse"),encode:me(n=>{const i=n.length;let a=pr(i);for(let c=0;c<i;c++)a+=t._encode(n[c]);return a},"encode"),decodeTrusted:me((n,i)=>{const a=at(n,i),c=new Array(a);for(let h=0;h<a;h++)c[h]=t._decodeTrusted(n);return c},"decodeTrusted"),decodeUntrusted:me((n,i)=>{const a=at(n,i);if(a>i.arrayBudget)throw $.ARRAY_BUDGET_EXHAUSTED;i.arrayBudget-=a;const c=new Array(a);for(let h=0;h<a;h++)if(c[h]=t._decodeUntrusted(n),i.offset>i.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return c},"decodeUntrusted")})}o(Dv,"B$h"),me(Dv,"arr");function Ov(t){const e=t.length;return ne({safeParse:me((r,s)=>{if(!Array.isArray(r))return s.lastCtx="",s.lastError="must be an array",!1;if(r.length!==e)return s.lastCtx="",s.lastError=`must contain exactly ${e} elements`,!1;for(let n=0;n<e;n++)if(!t[n]._safeParse(r[n]))return s.lastCtx=`[${n}]${s.lastCtx}`,!1;return!0},"safeParse"),encode:me(r=>{let s="";for(let n=0;n<e;n++)s+=t[n]._encode(r[n]);return s},"encode"),decodeTrusted:me(r=>{const s=new Array(e);for(let n=0;n<e;n++)s[n]=t[n]._decodeTrusted(r);return s},"decodeTrusted"),decodeUntrusted:me((r,s)=>{const n=new Array(e);for(let i=0;i<e;i++)if(n[i]=t[i]._decodeUntrusted(r),s.offset>s.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return n},"decodeUntrusted")})}o(Ov,"b$n"),me(Ov,"tuple");function jv(t,e){return ne({safeParse:me((r,s)=>{if(!Fi(r))return s.lastCtx="",s.lastError="must be a record",!1;for(const n in r){if(!t._safeParse(n))return s.lastCtx=`[key=${n}]${s.lastCtx}`,!1;const i=r[n];if(!e._safeParse(i))return s.lastCtx=`.${n}${s.lastCtx}`,!1}return!0},"safeParse"),encode:me(r=>{let s=0,n="";for(const i in r)s++,n+=t._encode(i)+e._encode(r[i]);return pr(s)+n},"encode"),decodeTrusted:me((r,s)=>{const n=at(r,s),i={};for(let a=0;a<n;a++){const c=t._decodeTrusted(r),h=e._decodeTrusted(r);i[c]=h}return i},"decodeTrusted"),decodeUntrusted:me((r,s)=>{const n=at(r,s);if(n>s.arrayBudget)throw $.ARRAY_BUDGET_EXHAUSTED;s.arrayBudget-=n;const i={};for(let a=0;a<n;a++){const c=t._decodeUntrusted(r),h=e._decodeUntrusted(r);i[c]=h}return i},"decodeUntrusted")})}o(jv,"D$j"),me(jv,"record");function Nv(...t){const e=t.length;return ne({safeParse:me((r,s)=>{let n="";for(let i=0;i<e;i++){if(s.lastCtx="",t[i]._safeParse(r))return!0;n+=s.lastCtx?`
2
2
  - ${s.lastCtx} ${s.lastError}`:`
3
- - ${s.lastError}`}return s.lastError="did not match any union type:"+n,!1},"safeParse"),encode:me(r=>{for(let s=0;s<e;s++){const n=t[s];if(n._safeParse(r))return String.fromCharCode(s)+n._encode(r)}throw new Tv("did not match any union type")},"encode"),decodeTrusted:me((r,s)=>{const n=r.charCodeAt(s.offset++);return t[n]._decodeTrusted(r)},"decodeTrusted"),decodeUntrusted:me((r,s)=>{const n=r.charCodeAt(s.offset++);if(Number.isNaN(n))throw $.PAYLOAD_TRUNCATED;const i=t[n];if(!i)throw new $("union index out-of-range");return i._decodeUntrusted(r)},"decodeUntrusted")})}o(Pv,"x$e"),me(Pv,"union");function xv(t,e,r,s){const n=e.length,i={...s,ignoredProps:[...(s==null?void 0:s.ignoredProps)??[],t]},a=r?qc(r,i):void 0,c=new Array(n),h=new Map;for(let p=0;p<n;p++){const f=e[p],g=f[0],m=qc(f[1],i);c[p]={type:m,tag:g},h.set(f[0],{i:p,type:m})}let u;const d=ne({safeParse:me((p,f)=>{if(!ji(p))return f.lastError="must be a record",!1;if(!(t in p))return f.lastCtx=`.${t}`,f.lastError="discriminant missing",!1;const g=h.get(p[t]);return g?g.type._safeParse(p)?!0:a?a._safeParse(p):!1:a?a._safeParse(p):(u??=`did not match any discriminant tags: ${JSON.stringify(e.map(m=>m[0]))}`,f.lastCtx=`.${t}`,f.lastError=u,!1)},"safeParse"),encode:me(p=>{const f=h.get(p[t]);if(f&&f.type._safeParse(p))return String.fromCharCode(f.i)+f.type._encode(p);if(a)return"\x7F"+a._encode(p);throw u??=`did not match any discriminant tags: ${JSON.stringify(e.map(g=>g[0]))}`,new Tv(u)},"encode"),decodeTrusted:me((p,f)=>{const g=p.charCodeAt(f.offset++),m=c[g];if(m!=null){const w=m.type._decodeTrusted(p);return w[t]=m.tag,w}if(g===127){if(!a)throw new $("no taggedUnion fallback shape defined");return a._decodeTrusted(p)}throw new $("discriminant variant index out-of-range")},"decodeTrusted"),decodeUntrusted:me((p,f)=>{const g=p.charCodeAt(f.offset++);if(Number.isNaN(g))throw $.PAYLOAD_TRUNCATED;const m=c[g];if(m!=null){const w=m.type._decodeUntrusted(p);if(f.offset>f.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return w[t]=m.tag,w}if(g===127){if(!a)throw new $("no taggedUnion fallback shape defined");const w=a._decodeUntrusted(p);if(f.offset>f.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return w}throw new $("discriminant variant index out-of-range")},"decodeUntrusted")});return Object.assign(d,{__tags:Array.from(h.keys())})}o(xv,"S$i"),me(xv,"taggedUnion");var HC=Object.freeze({__proto__:null,arr:Bv,record:qv,shape:qc,taggedUnion:xv,tuple:Iv,union:Pv}),KC=Object.defineProperty,$e=o((t,e)=>KC(t,"name",{value:e,configurable:!0}),"e$h");const Kn=112,jh=0,Pc=dw,Nh=$e((...t)=>{const e=t.length,r=new Map;for(let n=0;n<e;n++){const i=t[n];r.set(i,String.fromCharCode(n))}let s;return ne({safeParse:$e((n,i)=>r.has(n)?!0:(s??=`must be ${JSON.stringify(t)}`,i.lastCtx="",i.lastError=s,!1),"safeParse"),encode:$e(n=>r.get(n),"encode"),decodeTrusted:$e((n,i)=>t[n.charCodeAt(i.offset++)],"decodeTrusted"),decodeUntrusted:$e((n,i)=>{const a=n.charCodeAt(i.offset++);if(Number.isNaN(a))throw $.PAYLOAD_TRUNCATED;if(i.offset>i.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;if(a>=t.length)throw new $(`literal index must be < ${t.length}`);return t[a]},"decodeUntrusted")})},"literal"),GC=$e((...t)=>{const e=t.length,r=new Map;for(let s=0;s<e;s++){const n=t[s];r.set(n,String.fromCharCode(512|s))}return ne({safeParse:$e((s,n)=>typeof s!="string"?(n.lastCtx="",n.lastError="must be a string",!1):!0,"safeParse"),encode:$e(s=>r.get(s)??Dh(s),"encode"),decodeTrusted:$e((s,n)=>{const i=s.charCodeAt(n.offset);return i>=512?(n.offset++,t[i&511]):nn(s,n)},"decodeTrusted"),decodeUntrusted:$e((s,n)=>{const i=s.charCodeAt(n.offset);if(Number.isNaN(i))throw $.PAYLOAD_TRUNCATED;if(i>=512){const c=i&511;if(n.offset++,c>=e)throw new $(`dictionary index must be < ${e}`);return t[c]}const a=nn(s,n);if(n.offset>n.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return a},"decodeUntrusted")})},"strWithDict"),Wv=ne({safeParse:$e((t,e)=>typeof t!="string"?(e.lastCtx="",e.lastError="must be a string",!1):t.length!==rt?(e.lastCtx="",e.lastError=`must be exactly ${rt} characters long`,!1):(t.charCodeAt(0)&Kn)!==jh?(e.lastCtx="",e.lastError="invalid FNV-1a magic bits",!1):!0,"safeParse"),encode:$e(t=>t,"encode"),decodeTrusted:$e((t,e)=>{const r=e.offset;return e.offset=r+rt,t.slice(r,e.offset)},"decodeTrusted"),decodeUntrusted:$e((t,e)=>{const r=e.offset;if(e.offset=r+rt,e.offset>t.length)throw $.PAYLOAD_TRUNCATED;if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;const s=t.slice(r,e.offset);if((s.charCodeAt(0)&Kn)!==jh)throw new $("invalid FNV-1a magic bits");return s},"decodeUntrusted")}),VC=ne({safeParse:$e((t,e)=>typeof t!="string"?(e.lastCtx="",e.lastError="must be a string",!1):t.length!==Mt?(e.lastCtx="",e.lastError=`must be exactly ${Mt} characters long`,!1):(t.charCodeAt(0)&Kn)!==Pc?(e.lastCtx="",e.lastError="invalid SHA-256 magic bits",!1):!0,"safeParse"),encode:$e(t=>t,"encode"),decodeTrusted:$e((t,e)=>{const r=e.offset;return e.offset=r+Mt,t.slice(r,e.offset)},"decodeTrusted"),decodeUntrusted:$e((t,e)=>{const r=e.offset;if(e.offset=r+Mt,e.offset>t.length)throw $.PAYLOAD_TRUNCATED;if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;const s=t.slice(r,e.offset);if((s.charCodeAt(0)&Kn)!==Pc)throw new $("invalid SHA-256 magic bits");return s},"decodeUntrusted")}),YC=ne({safeParse:$e((t,e)=>{if(typeof t!="string")return e.lastCtx="",e.lastError="must be a string",!1;if(t.length===0)return e.lastCtx="",e.lastError="must not be empty",!1;const r=t.charCodeAt(0)&Kn;switch(r){case jh:return t.length!==rt?(e.lastCtx="",e.lastError=`FNV-1a hash must be exactly ${rt} characters long`,!1):!0;case Pc:return t.length!==Mt?(e.lastCtx="",e.lastError=`SHA-256 hash must be exactly ${Mt} characters long`,!1):!0;default:return e.lastCtx="",e.lastError=`unknown hash algorithm ID: ${r}`,!1}},"safeParse"),encode:$e(t=>t,"encode"),decodeTrusted:$e((t,e)=>{const r=(t.charCodeAt(e.offset)&Kn)===Pc?Mt:rt,s=e.offset;return e.offset=s+r,t.slice(s,e.offset)},"decodeTrusted"),decodeUntrusted:$e((t,e)=>{if(e.offset>=t.length)throw $.PAYLOAD_TRUNCATED;const r=t.charCodeAt(e.offset)&Kn;let s;switch(r){case jh:s=rt;break;case Pc:s=Mt;break;default:throw new $(`unknown hash algorithm ID: ${r}`)}const n=e.offset;if(e.offset=n+s,e.offset>t.length)throw $.PAYLOAD_TRUNCATED;if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return t.slice(n,e.offset)},"decodeUntrusted")}),JC=$e(t=>ne({safeParse:$e((e,r)=>typeof e!="string"?(r.lastCtx="",r.lastError="must be a string",!1):(t.lastIndex=0,t.test(e)?!0:(r.lastCtx="",r.lastError=`must match ${t}`,!1)),"safeParse"),encode:$e(e=>Dh(e),"encode"),decodeTrusted:$e((e,r)=>nn(e,r),"decodeTrusted"),decodeUntrusted:$e((e,r)=>{const s=nn(e,r);if(r.offset>r.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;if(!t.test(s))throw new $(`must match ${t}`);return s},"decodeUntrusted")}),"strWithPattern");var XC=Object.freeze({__proto__:null,fnv1a:Wv,hash:YC,literal:Nh,sha256:VC,strWithDict:GC,strWithPattern:JC}),QC=Object.defineProperty,Re=o((t,e)=>QC(t,"name",{value:e,configurable:!0}),"s$q");const ZC=ne({safeParse:Re((t,e)=>typeof t!="string"?(e.lastCtx="",e.lastError="must be a string",!1):!0,"safeParse"),encode:Re(t=>Dh(t),"encode"),decodeTrusted:Re((t,e)=>nn(t,e),"decodeTrusted"),decodeUntrusted:Re((t,e)=>{const r=nn(t,e);if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r},"decodeUntrusted")}),eS=ne({safeParse:Re((t,e)=>typeof t!="number"?(e.lastCtx="",e.lastError="must be a number",!1):Number.isNaN(t)?(e.lastCtx="",e.lastError="must be not be NaN",!1):Number.isFinite(t)?!0:(e.lastCtx="",e.lastError="must be finite",!1),"safeParse"),encode:Re(t=>t>>>0===t?Ic(t,0):Uh(t,1),"encode"),decodeTrusted:Re((t,e)=>{const r=t.charCodeAt(e.offset++);switch(r&3){case 0:return Ts(t,r,e);case 1:return Rs(t,r,e)}throw new $(`malformed num header '${r}', type not recognized`)},"decodeTrusted"),decodeUntrusted:Re((t,e)=>{let r;const s=t.charCodeAt(e.offset++);if(Number.isNaN(s))throw $.PAYLOAD_TRUNCATED;switch(s&3){case 0:r=Ts(t,s,e);break;case 1:r=Rs(t,s,e);break;default:throw new $(`malformed num header '${s}', type not recognized`)}if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r},"decodeUntrusted")}),tS=ne({safeParse:Re((t,e)=>typeof t!="number"?(e.lastCtx="",e.lastError="must be a number",!1):Number.isNaN(t)?(e.lastCtx="",e.lastError="must be not be NaN",!1):t>>>0!==t?(e.lastCtx="",e.lastError="must be a uint32",!1):!0,"safeParse"),encode:Re(t=>dr(t),"encode"),decodeTrusted:Re((t,e)=>nt(t,e),"decodeTrusted"),decodeUntrusted:Re((t,e)=>{const r=nt(t,e);if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r},"decodeUntrusted")}),rS=ne({safeParse:Re((t,e)=>typeof t!="boolean"?(e.lastCtx="",e.lastError="must be a boolean",!1):!0,"safeParse"),encode:Re(t=>t?"1":"0","encode"),decodeTrusted:Re((t,e)=>t.charCodeAt(e.offset++)===49,"decodeTrusted"),decodeUntrusted:Re((t,e)=>{if(e.offset>=t.length)throw $.PAYLOAD_TRUNCATED;if(e.offset+1>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return t.charCodeAt(e.offset++)===49},"decodeUntrusted")}),sS=ne({safeParse:Re((t,e)=>typeof t!="number"?(e.lastCtx="",e.lastError="must be a number",!1):t<0?(e.lastCtx="",e.lastError="must be >= 0",!1):t>4398046511103?(e.lastCtx="",e.lastError="must be <= 4_398_046_511_103",!1):!0,"safeParse"),encode:Re(t=>FC(t),"encode"),decodeTrusted:Re((t,e)=>Rv(t,e),"decodeTrusted"),decodeUntrusted:Re((t,e)=>{const r=Rv(t,e);if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r},"decodeUntrusted")}),nS=ne({safeParse:Re(t=>!0,"safeParse"),encode:Re(t=>typeof t=="string"?Oh(t,2):typeof t=="number"?t>>>0===t?Ic(t,0):Uh(t,1):Oh(JSON.stringify(t),3),"encode"),decodeTrusted:Re((t,e)=>{const r=t.charCodeAt(e.offset++);switch(r&3){case 2:return an(t,r,e);case 0:return Ts(t,r,e);case 1:return Rs(t,r,e);case 3:return JSON.parse(an(t,r,e))}throw new $(`malformed unknown header '${r}', type not recognized`)},"decodeTrusted"),decodeUntrusted:Re((t,e)=>{let r;const s=t.charCodeAt(e.offset++);switch(s&3){case 2:r=an(t,s,e);break;case 0:r=Ts(t,s,e);break;case 1:r=Rs(t,s,e);break;case 3:{const n=an(t,s,e);if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;try{r=JSON.parse(n)}catch{throw $.JSON_PARSE}break}default:throw new $(`malformed unknown header '${s}', type not recognized`)}if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r},"decodeUntrusted")});var iS=Object.freeze({__proto__:null,bool:rS,num:eS,str:ZC,timestamp:sS,uint32:tS,unknown:nS}),aS=Object.defineProperty,on=o((t,e)=>aS(t,"name",{value:e,configurable:!0}),"A$i");const oS=ne({safeParse:on((t,e)=>t==null||!(t instanceof Uint8Array)?(e.lastCtx="",e.lastError="must be a Uint8Array",!1):t.length!==16?(e.lastCtx="",e.lastError="must contain exactly 16 bytes",!1):!0,"safeParse"),encode:on(t=>String.fromCharCode(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15]),"encode"),decodeTrusted:on((t,e)=>{const r=e.offset;return e.offset=r+16,new Uint8Array([t.charCodeAt(r),t.charCodeAt(r+1),t.charCodeAt(r+2),t.charCodeAt(r+3),t.charCodeAt(r+4),t.charCodeAt(r+5),t.charCodeAt(r+6),t.charCodeAt(r+7),t.charCodeAt(r+8),t.charCodeAt(r+9),t.charCodeAt(r+10),t.charCodeAt(r+11),t.charCodeAt(r+12),t.charCodeAt(r+13),t.charCodeAt(r+14),t.charCodeAt(r+15)])},"decodeTrusted"),decodeUntrusted:on((t,e)=>{if(e.offset+16>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;if(e.offset+16>t.length)throw $.PAYLOAD_TRUNCATED;const r=e.offset;return e.offset=r+16,new Uint8Array([t.charCodeAt(r),t.charCodeAt(r+1),t.charCodeAt(r+2),t.charCodeAt(r+3),t.charCodeAt(r+4),t.charCodeAt(r+5),t.charCodeAt(r+6),t.charCodeAt(r+7),t.charCodeAt(r+8),t.charCodeAt(r+9),t.charCodeAt(r+10),t.charCodeAt(r+11),t.charCodeAt(r+12),t.charCodeAt(r+13),t.charCodeAt(r+14),t.charCodeAt(r+15)])},"decodeUntrusted")}),cS=ne({safeParse:on((t,e)=>t==null||!(t instanceof Uint8Array)?(e.lastCtx="",e.lastError="must be a Uint8Array",!1):t.length!==8?(e.lastCtx="",e.lastError="must contain exactly 8 bytes",!1):!0,"safeParse"),encode:on(t=>String.fromCharCode(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]),"encode"),decodeTrusted:on((t,e)=>{const r=e.offset;return e.offset=r+8,new Uint8Array([t.charCodeAt(r),t.charCodeAt(r+1),t.charCodeAt(r+2),t.charCodeAt(r+3),t.charCodeAt(r+4),t.charCodeAt(r+5),t.charCodeAt(r+6),t.charCodeAt(r+7)])},"decodeTrusted"),decodeUntrusted:on((t,e)=>{if(e.offset+8>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;if(e.offset+8>t.length)throw $.PAYLOAD_TRUNCATED;const r=e.offset;return e.offset=r+8,new Uint8Array([t.charCodeAt(r),t.charCodeAt(r+1),t.charCodeAt(r+2),t.charCodeAt(r+3),t.charCodeAt(r+4),t.charCodeAt(r+5),t.charCodeAt(r+6),t.charCodeAt(r+7)])},"decodeUntrusted")});var lS=Object.freeze({__proto__:null,spanId:cS,traceId:oS}),hS=Object.defineProperty,ie=o((t,e)=>hS(t,"name",{value:e,configurable:!0}),"u$v");const uS=Nh("ethereum-holesky","ethereum-sepolia","ethereum","sonic-blaze-testnet","sonic-testnet","sonic"),Uv=ne({safeParse:ie((t,e)=>typeof t!="string"?(e.lastCtx="",e.lastError="must be a string",!1):lf(t)?!0:(e.lastCtx="",e.lastError="must be a valid block height (0x-prefixed hex without leading zeros)",!1),"safeParse"),encode:ie(t=>Dh(t),"encode"),decodeTrusted:ie((t,e)=>nn(t,e),"decodeTrusted"),decodeUntrusted:ie((t,e)=>{const r=nn(t,e);if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;if(!lf(r))throw new $("invalid block height format");return r},"decodeUntrusted")}),dS=Nh(...Tf),Dv=Wv,fS=qc({height:Uv,digest:Dv}),pS=Nh("ankr","drpc","envio","direct");function Ov(t){return ne({safeParse:ie((e,r)=>{if(typeof e!="string")return r.lastCtx="",r.lastError="must be a string",!1;const s=e.charCodeAt(0);if(s>127)return r.lastCtx="",r.lastError="invalid flags byte (bit 7 must be 0)",!1;const n=(s&Tt)!==0;if(t==="with-checksum"&&!n)return r.lastCtx="",r.lastError="request fingerprint must include checksum (FLAG_HAS_CHECKSUM not set)",!1;if(t==="without-checksum"&&n)return r.lastCtx="",r.lastError="request fingerprint must not include checksum (FLAG_HAS_CHECKSUM is set)",!1;const i=n?1+Mt+rt:1+rt;return e.length!==i?(r.lastCtx="",r.lastError=`request fingerprint must be exactly ${i} characters`,!1):!0},"safeParse"),encode:ie(e=>e,"encode"),decodeTrusted:ie((e,r)=>{const s=(e.charCodeAt(r.offset)&Tt)!==0?1+Mt+rt:1+rt,n=r.offset;return r.offset=n+s,e.slice(n,r.offset)},"decodeTrusted"),decodeUntrusted:ie((e,r)=>{if(r.offset>=e.length)throw $.PAYLOAD_TRUNCATED;const s=e.charCodeAt(r.offset);if(s>127)throw new $("invalid flags byte (bit 7 must be 0)");const n=(s&Tt)!==0;if(t==="with-checksum"&&!n)throw new $("request fingerprint must include checksum (FLAG_HAS_CHECKSUM not set)");if(t==="without-checksum"&&n)throw new $("request fingerprint must not include checksum (FLAG_HAS_CHECKSUM is set)");const i=n?1+Mt+rt:1+rt,a=r.offset;if(r.offset=a+i,r.offset>e.length)throw $.PAYLOAD_TRUNCATED;if(r.offset>r.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return e.slice(a,r.offset)},"decodeUntrusted")})}o(Ov,"x$d"),ie(Ov,"requestFingerprint");function jv(t){return ne({safeParse:ie((e,r)=>{if(typeof e!="string")return r.lastCtx="",r.lastError="must be a string",!1;const s=e.charCodeAt(0);if(s>127)return r.lastCtx="",r.lastError="invalid flags byte (bit 7 must be 0)",!1;const n=(s&Xs)!==0,i=(s&Tt)!==0;if(t==="with-checksum"&&!i)return r.lastCtx="",r.lastError="request identifier must include checksum (FLAG_HAS_CHECKSUM not set)",!1;if(t==="without-checksum"&&i)return r.lastCtx="",r.lastError="request identifier must not include checksum (FLAG_HAS_CHECKSUM is set)",!1;const a=i?$s:bs,c=i?Oi:Di;return e.length===a||n&&e.length===c?!0:(r.lastCtx="",r.lastError=n?`request identifier must be ${a} or ${c} bytes`:`request identifier must be exactly ${a} bytes`,!1)},"safeParse"),encode:ie(e=>{const r=(e.charCodeAt(0)&Tt)!==0?$s:bs;return e.length>r?""+e:"\0"+e},"encode"),decodeTrusted:ie((e,r)=>{const s=e.charCodeAt(r.offset++)===1,n=(e.charCodeAt(r.offset)&Tt)!==0,i=r.offset;return s?(r.offset=i+(n?Oi:Di),e.slice(i,r.offset)):(r.offset=i+(n?$s:bs),e.slice(i,r.offset))},"decodeTrusted"),decodeUntrusted:ie((e,r)=>{if(r.offset>=e.length)throw $.PAYLOAD_TRUNCATED;const s=e.charCodeAt(r.offset++)===1;if(r.offset>=e.length)throw $.PAYLOAD_TRUNCATED;const n=e.charCodeAt(r.offset);if(n>127)throw new $("invalid flags byte (bit 7 must be 0)");const i=(n&Tt)!==0;if(t==="with-checksum"&&!i)throw new $("request identifier must include checksum (FLAG_HAS_CHECKSUM not set)");if(t==="without-checksum"&&i)throw new $("request identifier must not include checksum (FLAG_HAS_CHECKSUM is set)");const a=s?i?Oi:Di:i?$s:bs,c=r.offset;if(c+a>e.length)throw $.PAYLOAD_TRUNCATED;if(c+a>r.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r.offset=c+a,e.slice(c,r.offset)},"decodeUntrusted")})}o(jv,"M$h"),ie(jv,"requestIdentifier");function Nv(t){return ne({safeParse:ie((e,r)=>{if(typeof e!="string")return r.lastCtx="",r.lastError="must be a string",!1;const s=e.charCodeAt(0);if(s>127)return r.lastCtx="",r.lastError="invalid flags byte (bit 7 must be 0)",!1;const n=(s&Xs)!==0,i=(s&Tt)!==0;if(t==="with-checksum"&&!i)return r.lastCtx="",r.lastError="request key must include checksum (FLAG_HAS_CHECKSUM not set)",!1;if(t==="without-checksum"&&i)return r.lastCtx="",r.lastError="request key must not include checksum (FLAG_HAS_CHECKSUM is set)",!1;let a;return n?i?a=Oi:a=Di:i?a=$s:a=bs,e.length!==a?(r.lastCtx="",r.lastError=n?`request key must be exactly ${a} bytes when FLAG_HAS_BLOCK_DIGEST is set`:`request key must be exactly ${a} bytes`,!1):!0},"safeParse"),encode:ie(e=>e,"encode"),decodeTrusted:ie((e,r)=>{const s=e.charCodeAt(r.offset),n=(s&Tt)!==0,i=(s&Xs)!==0,a=r.offset;return i?n?r.offset=a+Oi:r.offset=a+Di:n?r.offset=a+$s:r.offset=a+bs,e.slice(a,r.offset)},"decodeTrusted"),decodeUntrusted:ie((e,r)=>{if(r.offset>=e.length)throw $.PAYLOAD_TRUNCATED;const s=e.charCodeAt(r.offset);if(s>127)throw new $("invalid flags byte (bit 7 must be 0)");const n=(s&Tt)!==0,i=(s&Xs)!==0;if(t==="with-checksum"&&!n)throw new $("request key must include checksum (FLAG_HAS_CHECKSUM not set)");if(t==="without-checksum"&&n)throw new $("request key must not include checksum (FLAG_HAS_CHECKSUM is set)");let a;i?n?a=Oi:a=Di:n?a=$s:a=bs;const c=r.offset;if(c+a>e.length)throw $.PAYLOAD_TRUNCATED;if(c+a>r.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r.offset=c+a,e.slice(c,r.offset)},"decodeUntrusted")})}o(Nv,"z$d"),ie(Nv,"requestKey");const mS=ne({safeParse:ie((t,e)=>typeof t!="string"?(e.lastCtx="",e.lastError="must be a string",!1):t.length!==ch?(e.lastCtx="",e.lastError=`must be exactly ${ch} characters long`,!1):t.charCodeAt(0)>127?(e.lastCtx="",e.lastError="invalid flags byte (bit 7 must be 0)",!1):!0,"safeParse"),encode:ie(t=>t,"encode"),decodeTrusted:ie((t,e)=>{const r=e.offset;return e.offset=r+ch,t.slice(r,e.offset)},"decodeTrusted"),decodeUntrusted:ie((t,e)=>{const r=e.offset;if(e.offset=r+ch,e.offset>t.length)throw $.PAYLOAD_TRUNCATED;if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;if(t.charCodeAt(r)>127)throw new $("invalid flags byte (bit 7 must be 0)");return t.slice(r,e.offset)},"decodeUntrusted")}),gS=ne({safeParse:ie((t,e)=>t==null?!0:typeof t!="string"&&typeof t!="number"?(e.lastCtx="",e.lastError="must be a string, number, null, or undefined",!1):!0,"safeParse"),encode:ie(t=>t===void 0?"\u07FE":t===null?"\u07FF":typeof t=="string"?Oh(t,2):t>>>0===t?Ic(t,0):Uh(t,1),"encode"),decodeTrusted:ie((t,e)=>{const r=t.charCodeAt(e.offset);if(r===2046){e.offset++;return}if(r===2047)return e.offset++,null;switch(e.offset++,r&3){case 2:return an(t,r,e);case 0:return Ts(t,r,e);case 1:return Rs(t,r,e)}throw new $(`malformed rpcRequestId header '${r}', type not recognized`)},"decodeTrusted"),decodeUntrusted:ie((t,e)=>{if(e.offset>=t.length)throw $.PAYLOAD_TRUNCATED;const r=t.charCodeAt(e.offset);if(r===2046){if(e.offset++,e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return}if(r===2047){if(e.offset++,e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return null}e.offset++;let s;switch(r&3){case 2:s=an(t,r,e);break;case 0:s=Ts(t,r,e);break;case 1:s=Rs(t,r,e);break;default:throw new $(`malformed rpcRequestId header '${r}', type not recognized`)}if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return s},"decodeUntrusted")}),wS=ne({safeParse:ie((t,e)=>t===null?!0:typeof t!="string"&&typeof t!="number"?(e.lastCtx="",e.lastError="must be a string, number, or null",!1):!0,"safeParse"),encode:ie(t=>t===null?"\u07FF":typeof t=="string"?Oh(t,2):t>>>0===t?Ic(t,0):Uh(t,1),"encode"),decodeTrusted:ie((t,e)=>{const r=t.charCodeAt(e.offset);if(r===2047)return e.offset++,null;switch(e.offset++,r&3){case 2:return an(t,r,e);case 0:return Ts(t,r,e);case 1:return Rs(t,r,e)}throw new $(`malformed rpcResponseId header '${r}', type not recognized`)},"decodeTrusted"),decodeUntrusted:ie((t,e)=>{if(e.offset>=t.length)throw $.PAYLOAD_TRUNCATED;const r=t.charCodeAt(e.offset);if(r===2047){if(e.offset++,e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return null}e.offset++;let s;switch(r&3){case 2:s=an(t,r,e);break;case 0:s=Ts(t,r,e);break;case 1:s=Rs(t,r,e);break;default:throw new $(`malformed rpcResponseId header '${r}', type not recognized`)}if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return s},"decodeUntrusted")});var vS=Object.freeze({__proto__:null,blockContext:fS,blockDigest:Dv,blockHeight:Uv,networkId:uS,providerId:pS,requestFingerprint:Ov,requestIdentifier:jv,requestKey:Nv,requestMethod:dS,responseKey:mS,rpcRequestId:gS,rpcResponseId:wS}),_S=Object.defineProperty,Gn=o((t,e)=>_S(t,"name",{value:e,configurable:!0}),"t$b");const l={...HC,...XC,...iS,...lS,...vS};function ke(t,e){return Object.freeze({...e,parse:Gn(r=>{if(!e._safeParse(r))throw new Wh(`${t}${dt.lastCtx} ${dt.lastError}`);return r},"parse"),safeParse:Gn(r=>e._safeParse(r)?r:(Wh.lastMessage=`${t}${dt.lastCtx} ${dt.lastError}`,Bc),"safeParse"),encode:Gn(r=>e._encode(r),"encode"),decodeTrusted:Gn((r,s=0,n=524288,i=16384)=>(pe.offset=s,pe.byteBudget=n,pe.arrayBudget=i,e._decodeTrusted(r)),"decodeTrusted"),decodeUntrusted:Gn((r,s=0,n=524288,i=16384)=>(pe.offset=s,pe.byteBudget=n,pe.arrayBudget=i,e._decodeUntrusted(r)),"decodeUntrusted")})}o(ke,"k$f"),Gn(ke,"makeCheckpoint");function wt(){return pe.offset}o(wt,"l$v"),Gn(wt,"getDecodeOffset");var yS=Object.defineProperty,bS=o((t,e)=>yS(t,"name",{value:e,configurable:!0}),"n$q");const xc=ys("");function Lh(t,e){return ys(t+":"+e)}o(Lh,"m$t"),bS(Lh,"computeChecksum");var $S=Object.defineProperty,Lv=o((t,e)=>$S(t,"name",{value:e,configurable:!0}),"s$o");const Fv={onIngress:Lv(()=>{},"onIngress"),onEgress:Lv(()=>{},"onEgress")},vt=ke("trace_parent",l.shape({traceId:l.traceId,traceName:l.str,traceSampled:l.bool,spanId:l.spanId}).optional);var zv=Object.defineProperty,Hv=o(t=>{throw TypeError(t)},"J$a"),kS=o((t,e,r)=>e in t?zv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"$$b"),Xi=o((t,e)=>zv(t,"name",{value:e,configurable:!0}),"V$7"),Kv=o((t,e,r)=>kS(t,typeof e!="symbol"?e+"":e,r),"z$c"),sp=o((t,e,r)=>e.has(t)||Hv("Cannot "+r),"D$g"),qt=o((t,e,r)=>(sp(t,e,"read from private field"),r?r.call(t):e.get(t)),"o$m"),fr=o((t,e,r)=>e.has(t)?Hv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"d$n"),xr=o((t,e,r,s)=>(sp(t,e,"write to private field"),e.set(t,r),r),"u$t"),CS=o((t,e,r)=>(sp(t,e,"access private method"),r),"K$a"),Fh,zh,Qi,Wc,Hh,Kh,Gh,Vh,Yh,Jh,Xh,np,Gv;function ip(t,e,r){if((t&8)===0)return;const s=vt.decodeUntrusted(e,r.offset,512);return r.offset=wt(),s}o(ip,"Q$8"),Xi(ip,"decodeTraceParent");const Vv=(po=class{constructor(e,r){fr(this,np),Kv(this,"version"),Kv(this,"id"),fr(this,Fh,""),fr(this,zh,""),fr(this,Qi,""),fr(this,Wc,""),fr(this,Hh,0),fr(this,Kh,""),fr(this,Gh,""),fr(this,Vh,""),fr(this,Yh,""),fr(this,Jh,""),fr(this,Xh,""),this.version=e,this.id=r,CS(this,np,Gv).call(this)}encodeUnidirectionalRequest(e){const r=e.trace.exportTraceParent();return r?qt(this,Fh)+vt.encode(r):qt(this,zh)}encodeBidirectionalRequest(e,r){const s=e.trace.exportTraceParent();return s?qt(this,Qi)+Uc(r)+vt.encode(s):qt(this,Wc)+Uc(r)}retagBidirectionalRequest(e,r,s){const n=(s.charCodeAt(0)&8)!==0;let i=qt(this,Hh)+2;n&&(vt.decodeUntrusted(s,i,512),i=wt());const a=e.trace.exportTraceParent();return(a?qt(this,Qi):qt(this,Wc))+Uc(r)+(a?vt.encode(a):"")+s.slice(i)}encodeSuccessResponse(e){return qt(this,Kh)+e}encodeErrorResponse(e,r){return qt(this,Gh)+e+dr(r)}encodeStreamSegment(e){return qt(this,Vh)+e}encodeStreamClose(e){return qt(this,Yh)+e}encodeStreamError(e,r){return qt(this,Jh)+e+dr(r)}encodeUnsupportedVersion(){return qt(this,Xh)}},o(po,"k"),po);Fh=new WeakMap,zh=new WeakMap,Qi=new WeakMap,Wc=new WeakMap,Hh=new WeakMap,Kh=new WeakMap,Gh=new WeakMap,Vh=new WeakMap,Yh=new WeakMap,Jh=new WeakMap,Xh=new WeakMap,np=new WeakSet,Gv=Xi(function(){const t=dr(this.id),[e,r,s]=this.version<4?[4,this.version,""]:[0,this.version&3,dr(this.version>>2)],n=64|e|r;xr(this,Fh,String.fromCharCode(n|8)+s+t),xr(this,zh,String.fromCharCode(n)+s+t);const i=96|e|r;xr(this,Qi,String.fromCharCode(i|8)+s+t),xr(this,Wc,String.fromCharCode(i)+s+t),xr(this,Hh,qt(this,Qi).length);const[a,c,h]=this.version<8?[8,this.version,""]:[0,this.version&7,dr(this.version>>3)];xr(this,Kh,String.fromCharCode(32|a|c)+h+t),xr(this,Gh,String.fromCharCode(48|a|c)+h+t);const[u,d,p]=this.version<4?[4,this.version,""]:[0,this.version&3,dr(this.version>>2)];xr(this,Vh,String.fromCharCode(0|u|d)+p+t),xr(this,Yh,String.fromCharCode(16|u|d)+p+t),xr(this,Jh,String.fromCharCode(24|u|d)+p+t);const[f,g,m]=this.version<64?[64,this.version,""]:[0,this.version&63,dr(this.version>>6)];xr(this,Xh,String.fromCharCode(128|f|g)+m+t)},"#initPrecomputedHeaders"),Xi(Vv,"WireSignalEnvelope");let SS=Vv;function Qh(t,e=0){if(t.length<=e)throw new Error("[direct.dev/wire/signal] truncated envelope received");const r=t.charCodeAt(e);if((r&128)!==0){Vn.offset=e+1;const c=r&64,h=r&63;if(c!==0)Vn.desiredSignalVersion=h;else{const u=nt(t,Vn);Vn.desiredSignalVersion=u<<6|h}return Vn.signalId=nt(t,Vn),Vn}if((r&64)!==0&&(r&16)!==0){Bs.offset=e+1,Bs.signalId=nt(t,Bs),Bs.traceParent=ip(r,t,Bs);const c=t.charCodeAt(Bs.offset++)&127,h=t.charCodeAt(Bs.offset++)&127;return Bs.messageId=c|h<<7,Bs}if((r&64)!==0){Jt.offset=e+1;const c=r&4,h=r&3;if(c!==0)Jt.signalVersion=h;else{const u=nt(t,Jt);Jt.signalVersion=u<<2|h}return Jt.signalId=nt(t,Jt),(r&32)!==0?Jt.messageId=t.slice(Jt.offset,Jt.offset+=2):Jt.messageId=void 0,Jt.traceParent=ip(r,t,Jt),Jt}if((r&32)!==0){Xt.offset=e+1;const c=r&8,h=r&7;if(c!==0)Xt.signalVersion=h;else{const p=nt(t,Xt);Xt.signalVersion=p<<3|h}Xt.signalId=nt(t,Xt);const u=t.charCodeAt(Xt.offset++)&127,d=t.charCodeAt(Xt.offset++)&127;return Xt.messageId=u|d<<7,(r&16)===0?Xt.errorCode=void 0:Xt.errorCode=nt(t,Xt),Xt}Ze.offset=e+1;const s=r&4,n=r&3;if(s!==0)Ze.signalVersion=n;else{const c=nt(t,Ze);Ze.signalVersion=c<<2|n}Ze.signalId=nt(t,Ze);const i=t.charCodeAt(Ze.offset++)&127,a=t.charCodeAt(Ze.offset++)&127;switch(Ze.messageId=i|a<<7,r&24){case 0:return Ze.messageType="value",Ze.errorCode=void 0,Ze;case 16:return Ze.messageType="close",Ze.errorCode=void 0,Ze;case 24:return Ze.messageType="error",Ze.errorCode=nt(t,Ze),Ze}throw new Error("[direct.dev/wire/signal] malformed envelope header received, stream value type unrecognized: "+r)}o(Qh,"W$a"),Xi(Qh,"decodeEnvelope");const Vn={offset:0,type:"unsupported_version",signalId:0,desiredSignalVersion:0},Jt={offset:0,type:"request",signalId:0,signalVersion:0,messageId:void 0,traceParent:void 0},Xt={offset:0,type:"response",signalId:0,signalVersion:0,messageId:0,errorCode:void 0},Ze={offset:0,type:"stream",signalId:0,signalVersion:0,messageType:"value",messageId:0,errorCode:void 0},Bs={offset:0,type:"abort",signalId:0,messageId:0,traceParent:void 0};function Yv(t,e,r){const s=t.trace.exportTraceParent();return String.fromCharCode(80|(s?8:0))+dr(e)+(s?vt.encode(s):"")+Uc(r)}o(Yv,"y$i"),Xi(Yv,"encodeAbort");function Uc(t){const e=t&127,r=t>>7;return String.fromCharCode(e,r)}o(Uc,"b$m"),Xi(Uc,"encodeMessageId");var AS=Object.defineProperty,Zh=o((t,e)=>AS(t,"name",{value:e,configurable:!0}),"o$l");const it=Symbol("unsupported version"),Jv=(mo=class{tAttrs;version;id;name;req;_envelopes;_latestEnvelope;_migrations;constructor(e,r){this.tAttrs={"wire_signal.name":e.name},this.id=e.id,this.name=e.name,this.req=e.req,this.version=r.length;const s=new Array(this.version+1);for(let n=0;n<this.version+1;n++)s[n]=new SS(n,this.id);this._envelopes=s,this._latestEnvelope=s[this.version],this._migrations=r}decodeTrustedRequest(e,r,s,n){if(s===this.version)return this.req.decodeTrusted(e,r,n);const i=this._migrations[s];return i?i.upgradeReq(i.req.decodeTrusted(e,r,n)):it}decodeUntrustedRequest(e,r,s,n){if(s===this.version)return this.req.decodeUntrusted(e,r,n);const i=this._migrations[s];return i?i.upgradeReq(i.req.decodeUntrusted(e,r,n)):it}encodeUnsupportedVersion(e){return this._latestEnvelope.encodeUnsupportedVersion()+e}},o(mo,"a"),mo);Zh(Jv,"WireSignalBase");let ap=Jv;const Xv=(go=class extends ap{type="event";static migration(e,r){return Object.freeze({req:e.from,upgradeReq:r.upgradeReq,downgradeReq:r.downgradeReq})}encodeRequest(e,r,s){if(s!=null&&s!==this.version){const n=this._migrations[s],i=this._envelopes[s];return n?i.encodeUnidirectionalRequest(e)+n.req.encode(n.downgradeReq(r)):it}return this._latestEnvelope.encodeUnidirectionalRequest(e)+this.req.encode(r)}},o(go,"R"),go);Zh(Xv,"WireEventSignal");let Dc=Xv;const Qv=(wo=class extends ap{type="request";static migration(e,r,s){return Object.freeze({req:e.from,res:r.from,upgradeReq:s.upgradeReq,downgradeReq:s.downgradeReq,upgradeRes:s.upgradeRes,downgradeRes:s.downgradeRes})}res;timeoutMs;constructor(e,r){super(e,r),this.res=e.res,this.timeoutMs=e.timeoutMs}encodeRequest(e,r,s,n){if(n!=null&&n!==this.version){const i=this._migrations[n],a=this._envelopes[n];return i?a.encodeBidirectionalRequest(e,r)+i.req.encode(i.downgradeReq(s)):it}return this._latestEnvelope.encodeBidirectionalRequest(e,r)+this.req.encode(s)}retagRequest(e,r,s,n){if(n!=null&&n!==this.version){const i=this._envelopes[n];return i?i.retagBidirectionalRequest(e,r,s):it}return this._latestEnvelope.retagBidirectionalRequest(e,r,s)}encodeResponse(e,r,s){if(e!==this.version){const n=this._migrations[e],i=this._envelopes[e];return n?i.encodeSuccessResponse(r)+n.res.encode(n.downgradeRes(s)):it}return this._latestEnvelope.encodeSuccessResponse(r)+this.res.encode(s)}encodeError(e,r,s){return e!==this.version?this._envelopes[e].encodeErrorResponse(r,s):this._latestEnvelope.encodeErrorResponse(r,s)}decodeTrustedResponse(e,r,s,n){if(s===this.version)return this.res.decodeTrusted(e,r,n);const i=this._migrations[s];return i?i.upgradeRes(i.res.decodeTrusted(e,r,n)):it}decodeUntrustedResponse(e,r,s,n){if(s===this.version)return this.res.decodeUntrusted(e,r,n);const i=this._migrations[s];return i?i.upgradeRes(i.res.decodeUntrusted(e,r,n)):it}},o(wo,"p"),wo);Zh(Qv,"WireRequestSignal");let Zv=Qv;const e_=(vo=class extends ap{type="stream";static migration(e,r,s){return Object.freeze({req:e.from,res:r.from,upgradeReq:s.upgradeReq,downgradeReq:s.downgradeReq,upgradeRes:s.upgradeRes,downgradeRes:s.downgradeRes})}res;timeoutMs;initialTimeoutMs;itemTimeoutMs;constructor(e,r){super(e,r),this.res=e.res,this.timeoutMs=e.timeoutMs,this.initialTimeoutMs=e.initialTimeoutMs,this.itemTimeoutMs=e.itemTimeoutMs}encodeRequest(e,r,s,n){if(n!=null&&n!==this.version){const i=this._migrations[n],a=this._envelopes[n];return i?a.encodeBidirectionalRequest(e,r)+i.req.encode(i.downgradeReq(s)):it}return this._latestEnvelope.encodeBidirectionalRequest(e,r)+this.req.encode(s)}retagRequest(e,r,s,n){if(n!=null&&n!==this.version){const i=this._envelopes[n];return i?i.retagBidirectionalRequest(e,r,s):it}return this._latestEnvelope.retagBidirectionalRequest(e,r,s)}encodeResponse(e,r,s){if(e!==this.version){const n=this._migrations[e],i=this._envelopes[e];return n?i.encodeStreamSegment(r)+n.res.encode(n.downgradeRes(s)):it}return this._latestEnvelope.encodeStreamSegment(r)+this.res.encode(s)}encodeError(e,r,s){return e!==this.version?this._envelopes[e].encodeStreamError(r,s):this._latestEnvelope.encodeStreamError(r,s)}encodeClose(e,r){return e!==this.version?this._envelopes[e].encodeStreamClose(r):this._latestEnvelope.encodeStreamClose(r)}decodeTrustedResponse(e,r,s,n){if(s===this.version)return this.res.decodeTrusted(e,r,n);const i=this._migrations[s];return i?i.upgradeRes(i.res.decodeTrusted(e,r,n)):it}decodeUntrustedResponse(e,r,s,n){if(s===this.version)return this.res.decodeUntrusted(e,r,n);const i=this._migrations[s];return i?i.upgradeRes(i.res.decodeUntrusted(e,r,n)):it}},o(vo,"m"),vo);Zh(e_,"WireStreamSignal");let eu=e_;var ES=Object.defineProperty,MS=o((t,e)=>ES(t,"name",{value:e,configurable:!0}),"i$j");const TS=ys("");function t_(t,e,r){if(!(t==="client_continuum"&&typeof r=="object"&&r!=null&&"fromChecksum"in r&&r.fromChecksum!==TS))return e}o(t_,"u$s"),MS(t_,"getEffectiveInitialTimeoutMs");var RS=Object.defineProperty,BS=o((t,e)=>RS(t,"name",{value:e,configurable:!0}),"i$i");function op(t,e){if(!t.endsWith("continuum"))return e}o(op,"r$l"),BS(op,"getEffectiveStreamTimeoutMs");var r_=Object.defineProperty,s_=o(t=>{throw TypeError(t)},"ce$2"),IS=o((t,e,r)=>e in t?r_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"Ae$1"),ae=o((t,e)=>r_(t,"name",{value:e,configurable:!0}),"h$n"),Zi=o((t,e,r)=>IS(t,typeof e!="symbol"?e+"":e,r),"k$d"),cp=o((t,e,r)=>e.has(t)||s_("Cannot "+r),"W$9"),N=o((t,e,r)=>(cp(t,e,"read from private field"),r?r.call(t):e.get(t)),"u$r"),ss=o((t,e,r)=>e.has(t)?s_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"q$g"),n_=o((t,e,r,s)=>(cp(t,e,"write to private field"),e.set(t,r),r),"Q$7"),L=o((t,e,r)=>(cp(t,e,"access private method"),r),"c$u"),Oc,ns,jc,pr,Wr,tu,cn,ea,W,ru,lp,_t,hp,up,dp,su,i_,a_,o_,c_,l_,h_,fp,pp,u_,d_,mp,gp,wp,f_;const Yn=new Error("[direct.dev/wire/signal] request timed out"),Nc=new Error("[direct.dev/wire/signal] channel closed"),p_=1,vp=2,m_=(_o=class{constructor(e,r,s,n,i,a){ss(this,W),Zi(this,"t"),Zi(this,"bandwidthHooks"),Zi(this,"abortSignal"),Zi(this,"downstreamRelationship"),ss(this,Oc,xf()),ss(this,ns),ss(this,jc),ss(this,pr,new Map),ss(this,Wr,new Map),ss(this,tu,new Map),ss(this,cn,new Map),ss(this,ea,new Set),ss(this,su,ae(c=>{const h=c==="trusted"?"decodeTrustedRequest":"decodeUntrustedRequest",u=c==="trusted"?"decodeTrustedResponse":"decodeUntrustedResponse";return(d,p,f)=>{let g;try{g=Qh(d)}catch(w){throw this.t.log.info("wire_signal_relay.decode_envelope_failed",{err:w,payload_size:d.length,direction:"ingress",mode:c,header_char_code:d.length>0?d.charCodeAt(0):void 0}),w}const m=N(this,ns).get(g.signalId);if(this.bandwidthHooks.onIngress(p,m),!m){let w;for(const _ of N(this,ns).keys())w=w==null?_:Math.max(w,_);return this.t.record.wireSignalRequestHandleCount(1,"result:unrecognized_signal",{"wire_signal.name":void 0}),this.t.log.info("wire_signal_relay.unrecognized_signal_id",{signal_id:g.signalId,envelope_type:g.type,signal_version:"signalVersion"in g?g.signalVersion:void 0,envelope_offset:g.offset,message_id:"messageId"in g?g.messageId:void 0,payload_size:d.length,direction:"ingress",mode:c,header_char_code:d.length>0?d.charCodeAt(0):void 0,known_signal_count:N(this,ns).size,max_known_signal_id:w}),!1}switch(g.type){case"request":return Ni(()=>L(this,W,a_).call(this,g,m,d,h,f),()=>!0);case"response":return L(this,W,u_).call(this,m,g,d,u,f),!0;case"stream":return L(this,W,d_).call(this,m,g,d,u,f),!0;case"unsupported_version":return L(this,W,i_).call(this,m,g,d),!0;case"abort":return L(this,W,h_).call(this,m,g),!0}}},"#makeHandleMessage")),Zi(this,"handleTrustedMessage",N(this,su).call(this,"trusted")),Zi(this,"handleUntrustedMessage",N(this,su).call(this,"untrusted")),this.t=e.with({"component.id":"WireSignalRelay"}),n_(this,ns,r??new Map),n_(this,jc,s??new Map),this.bandwidthHooks=n??Fv,this.abortSignal=i??qS,this.downstreamRelationship=a??"parent",this.abortSignal.addEventListener("abort",()=>L(this,W,lp).call(this),{once:!0})}waitForSendQueue(){return N(this,Oc)}dispatch(e,r,s,n,i){switch(N(this,ns).set(r.id,r),r.type){case"event":return L(this,W,hp).call(this,e,r,r.encodeRequest(e,s),n,i);case"request":{const a=L(this,W,mp).call(this,e,r);return L(this,W,up).call(this,e,r,a,r.encodeRequest(e,a,s),n,i)}case"stream":{const a=L(this,W,gp).call(this,e,r),c=t_(r.name,r.initialTimeoutMs,s);return L(this,W,dp).call(this,e,r,a,r.encodeRequest(e,a,s),c,n,i)}}}dispatchRaw(e,r,s,n,i){switch(N(this,ns).set(r.id,r),r.type){case"event":return L(this,W,hp).call(this,e,r,s,n,i);case"request":{const a=L(this,W,mp).call(this,e,r);return L(this,W,up).call(this,e,r,a,r.retagRequest(e,a,s),n,i)}case"stream":{const a=L(this,W,gp).call(this,e,r);return L(this,W,dp).call(this,e,r,a,r.retagRequest(e,a,s),r.initialTimeoutMs,n,i)}}}dispatchAbort(e,r,s,n){const i=Yv(e,r.id,s);L(this,W,_t).call(this,r,s,i,void 0,n).catch(()=>{})}bind(e,r){N(this,ns).set(e.id,e),N(this,jc).set(e.id,r)}getSignalById(e){return N(this,ns).get(e)}async handleClose(e){e&&(await N(this,Oc).call(this,()=>{}),await Promise.allSettled([L(this,W,f_).call(this),...N(this,ea)])),L(this,W,lp).call(this);for(const r of N(this,pr).values()){for(const{promise:s,timeout:n}of r.values())s.__state()==="pending"&&s.__reject(Nc),clearTimeout(n);r.clear()}for(const r of N(this,Wr).values()){for(const{stream:s,timeout:n,itemTimeout:i}of r.values())s.throw(Nc),clearTimeout(n),clearTimeout(i);r.clear()}}terminateBatch(e,r,s=Nc){var n,i;for(const{signalId:a,messageId:c}of e){const h=(n=N(this,pr).get(a))==null?void 0:n.get(c);h&&(h.promise.__state()==="pending"&&h.promise.__reject(s),clearTimeout(h.timeout))}for(const{signalId:a,messageId:c}of r){const h=(i=N(this,Wr).get(a))==null?void 0:i.get(c);h&&(Rr(s)?h.stream.close(void 0):h.stream.throw(s),clearTimeout(h.itemTimeout),clearTimeout(h.timeout))}}get pendingCount(){let e=0;for(const r of N(this,pr).values())e+=r.size;return e}get streamCount(){let e=0;for(const r of N(this,Wr).values())e+=r.size;return e}},o(_o,"oe"),_o);Oc=new WeakMap,ns=new WeakMap,jc=new WeakMap,pr=new WeakMap,Wr=new WeakMap,tu=new WeakMap,cn=new WeakMap,ea=new WeakMap,W=new WeakSet,ru=ae(function(t){return N(this,ea).add(t),t.then(()=>N(this,ea).delete(t),()=>N(this,ea).delete(t)),t},"#trackHandler"),lp=ae(function(){for(const t of N(this,cn).values())for(const e of t.values())e.abort()},"#abortAllHandlers"),_t=ae(async function(t,e,r,s,n){const i=s??this.abortSignal;t.name;try{const a=this.prepareFrame(r),c=await N(this,Oc).call(this,()=>a);this.bandwidthHooks.onEgress(c.length,t),i.aborted||await this.writeFrame(t,e,c,i,n)}catch(a){throw Rr(a)||(this.t.log.warn("wire_signal_relay.send_failed",{err:a}),this.t.record.wireSignalSendErrorCount(1,t.tAttrs)),a}},"#sendInOrder"),hp=ae(function(t,e,r,s,n){return t.record.wireSignalDispatchCount(1,"type:event",e.tAttrs),t.record.wireSignalResultCount(1,"type:event result:ok",e.tAttrs),L(this,W,_t).call(this,e,void 0,r,s,n).catch(()=>{})},"#dispatchEvent"),up=ae(function(t,e,r,s,n,i){const a=y(),c=Ge(),h=setTimeout(()=>{c.__state()==="pending"&&(c.__reject(Yn),t.record.wireSignalResultCount(1,"type:request result:timeout",e.tAttrs),t.record.wireSignalLatencyMs(y()-a,"result:timeout",e.tAttrs))},e.timeoutMs);return N(this,pr).get(e.id).set(r,{promise:c,startedAt:a,timeout:h}),c.then(()=>{var u;(u=N(this,pr).get(e.id))==null||u.delete(r),clearTimeout(h)},()=>{var u;(u=N(this,pr).get(e.id))==null||u.delete(r),clearTimeout(h)}),n!=null&&n.addEventListener("abort",()=>{this.dispatchAbort(t,e,r,i)},{once:!0}),L(this,W,_t).call(this,e,r,s,n,i).catch(u=>{c.__state()==="pending"&&(c.__reject(u),t.record.wireSignalResultCount(1,"type:request result:send_error",e.tAttrs),t.record.wireSignalLatencyMs(y()-a,"result:send_error",e.tAttrs))}),t.record.wireSignalDispatchCount(1,"type:request",e.tAttrs),c},"#dispatchRequest"),dp=ae(function(t,e,r,s,n,i,a){const c=y(),h=new AbortController;let u=!1;const d=ae(()=>{u||(u=!0,h.signal.aborted||h.abort(),this.dispatchAbort(t,e,r,a))},"onAbort"),p=ae(()=>{h.signal.aborted||h.abort(i==null?void 0:i.reason),d()},"onExternalAbort"),f=new Cs({onClose:ae(()=>{var _;(_=N(this,Wr).get(e.id))==null||_.delete(r),clearTimeout(w.timeout),clearTimeout(w.itemTimeout),i==null||i.removeEventListener("abort",p)},"onClose"),onEarlyDisposal:d,onBackpressure:d}),g=op(e.name,e.timeoutMs),m=g==null?void 0:setTimeout(()=>{f.throw(Yn),t.record.wireSignalResultCount(1,"type:stream result:timeout",e.tAttrs),t.record.wireSignalLatencyMs(y()-c,"result:timeout",e.tAttrs)},g),w={stream:f,startedAt:c,timeout:m,itemTimeout:void 0,lastItemAt:void 0};return N(this,Wr).get(e.id).set(r,w),n!=null&&(w.itemTimeout=setTimeout(()=>{f.throw(Yn),t.record.wireSignalResultCount(1,"type:stream result:initial_timeout",e.tAttrs),t.record.wireSignalStreamLifetimeMs(y()-c,"result:initial_timeout",e.tAttrs)},n)),e.itemTimeoutMs!=null?f.tap(()=>{w.lastItemAt=y(),clearTimeout(w.itemTimeout),w.itemTimeout=setTimeout(()=>{f.throw(Yn),t.record.wireSignalResultCount(1,"type:stream result:item_timeout",e.tAttrs),t.record.wireSignalStreamLifetimeMs(y()-c,"result:item_timeout",e.tAttrs)},e.itemTimeoutMs)}):n!=null&&f.tap(()=>{clearTimeout(w.itemTimeout)}),i!=null&&(i.aborted?p():i.addEventListener("abort",p,{once:!0})),L(this,W,_t).call(this,e,r,s,h.signal,a).catch(_=>{Rr(_)?f.close(void 0):f.throw(_),t.record.wireSignalResultCount(1,"type:stream result:send_error",e.tAttrs)}),t.record.wireSignalDispatchCount(1,"type:stream",e.tAttrs),f},"#dispatchStream"),su=new WeakMap,i_=ae(function(t,e,r){const s=Qh(r,e.offset);if(s.type!=="request"){this.t.log.info("wire_signal_relay.unsupported_version.envelope_type_mismatch",{envelope_type:s.type,signal_id:t.id,signal_name:t.name,payload_size:r.length});return}const n=t.decodeUntrustedRequest(r,s.offset,s.signalVersion);if(n===it){this.t.record.wireSignalUnsupportedVersionCount(1,t.tAttrs),this.t.log.info("wire_signal_relay.unsupported_version.original_request_unsupported",{signal_id:t.id,signal_name:t.name,signal_version:s.signalVersion,desired_version:e.desiredSignalVersion,payload_size:r.length});return}const i=this.t.with({event:"wire_signal_relay.handle_unsupported_version"},s.traceParent?{traceId:s.traceParent.traceId,traceName:s.traceParent.traceName,traceSampled:s.traceParent.traceSampled,parentLink:void 0,parentSpanId:void 0,spanId:s.traceParent.spanId,spanKind:"INTERNAL"}:void 0);let a;switch(t.type){case"event":a=t.encodeRequest(i,n,e.desiredSignalVersion);break;case"request":case"stream":{if(s.messageId==null){this.t.log.info("wire_signal_relay.unsupported_version.missing_message_id",{signal_id:t.id,signal_name:t.name,signal_type:t.type,payload_size:r.length});return}const c=s.messageId.charCodeAt(0)&127,h=s.messageId.charCodeAt(1)&127,u=c|h<<7;a=t.encodeRequest(i,u,n,e.desiredSignalVersion);break}}a!==it?L(this,W,_t).call(this,t,void 0,a).catch(()=>{}):(this.t.record.wireSignalUnsupportedVersionCount(1,t.tAttrs),this.t.log.info("wire_signal_relay.unsupported_version.impossible",{signal_id:t.id,signal_name:t.name,signal_type:t.type,signal_version:t.version,desired_version:e.desiredSignalVersion,payload_size:r.length}))},"#handleUnsupportedVersionMessage"),a_=ae(function(t,e,r,s,n){const i=N(this,jc).get(e.id);if(!i){this.t.record.wireSignalRequestHandleCount(1,`type:${e.type} result:handler_not_bound`,e.tAttrs),this.t.log.warn("wire_signal_relay.unbound_handler",{signal_id:e.id,signal_name:e.name});return}switch(t.signalVersion!==e.version&&this.t.record.wireSignalMigrationCount(1,{"wire_signal.name":e.name,"wire_signal.from_version":t.signalVersion,"wire_signal.to_version":e.version}),e.type){case"event":return L(this,W,ru).call(this,L(this,W,o_).call(this,e,i,t,r,s,n));case"request":return L(this,W,ru).call(this,L(this,W,c_).call(this,e,i,t,r,s,n));case"stream":return L(this,W,ru).call(this,L(this,W,l_).call(this,e,i,t,r,s,n))}},"#handleRequestMessage"),o_=ae(async function(t,e,r,s,n,i){const a=r.signalVersion,c=t[n](s,r.offset,r.signalVersion,i);if(c===it){L(this,W,_t).call(this,t,void 0,t.encodeUnsupportedVersion(s)).catch(()=>{});return}await this.t.runSpan({parent:r.traceParent,parentRelationship:this.downstreamRelationship,kind:"CONSUMER"},{event:"wire_signal.handle","wire_signal.name":t.name,"wire_signal.id":t.id,"wire_signal.type":t.type},async h=>{try{await e(h,s,c,this.abortSignal),h.record.wireSignalRequestHandleCount(1,"type:event result:ok",t.tAttrs)}catch(u){h.record.wireSignalRequestHandleCount(1,"type:event result:error",t.tAttrs),h.log.info("wire_signal.handler_failed",{err:u,version:a,payload_size:s.length})}})},"#handleRequestMessageForEvent"),c_=ae(async function(t,e,r,s,n,i){const a=r.offset,c=r.signalVersion,h=r.messageId;if(h==null){this.t.log.info("wire_signal_relay.missing_message_id",{signal_id:t.id,signal_name:t.name});return}const u=h.charCodeAt(0)&127,d=h.charCodeAt(1)&127,p=u|d<<7,f=t[n](s,a,c,i);if(f===it){L(this,W,_t).call(this,t,void 0,t.encodeUnsupportedVersion(s)).catch(()=>{});return}const g=L(this,W,fp).call(this,t.id,p);await this.t.runSpan({parent:r.traceParent,parentRelationship:"parent",kind:"SERVER"},{event:"wire_signal.handle","wire_signal.name":t.name,"wire_signal.id":t.id,"wire_signal.type":t.type},async m=>{try{const w=await pc(t.timeoutMs,Promise.resolve(e(m,s,f,g.signal)));if(w===fc){g.signal.aborted||g.abort(Yn),m.record.wireSignalRequestHandleCount(1,"type:request result:timeout",t.tAttrs),L(this,W,_t).call(this,t,p,t.encodeError(c,h,vp)).catch(()=>{});return}m.record.wireSignalRequestHandleCount(1,"type:request result:ok",t.tAttrs),L(this,W,_t).call(this,t,p,t.encodeResponse(c,h,w)).catch(()=>{})}catch(w){m.record.wireSignalRequestHandleCount(1,"type:request result:error",t.tAttrs),m.log.info("wire_signal.handler_failed",{err:w,version:c,payload_size:s.length});const _=t.encodeError(c,h,p_);L(this,W,_t).call(this,t,p,_).catch(()=>{})}finally{L(this,W,pp).call(this,t.id,p)}})},"#handleRequestMessageForRequest"),l_=ae(async function(t,e,r,s,n,i){const a=r.offset,c=r.signalVersion,h=r.messageId;if(h==null){this.t.log.info("wire_signal_relay.missing_message_id",{signal_id:t.id,signal_name:t.name});return}const u=h.charCodeAt(0)&127,d=h.charCodeAt(1)&127,p=u|d<<7,f=t[n](s,a,c,i);if(f===it){L(this,W,_t).call(this,t,p,t.encodeUnsupportedVersion(s)).catch(()=>{});return}const g=L(this,W,fp).call(this,t.id,p);await this.t.runSpan({parent:r.traceParent,parentRelationship:"parent",kind:"SERVER"},{event:"wire_signal.handle","wire_signal.name":t.name,"wire_signal.id":t.id,"wire_signal.type":t.type},async m=>{var w;let _=ae(S=>{if(_=ae(async()=>{},"closeStream"),!g.signal.aborted)return S!=null?L(this,W,_t).call(this,t,p,t.encodeError(c,h,S)).catch(()=>{}):L(this,W,_t).call(this,t,p,t.encodeClose(c,h)).catch(()=>{})},"closeStream");try{const S=y(),b=await pc(t.initialTimeoutMs??t.timeoutMs,Promise.resolve(e(m,s,f,g.signal)));if(b===fc){g.signal.aborted||g.abort(Yn),m.record.wireSignalRequestHandleCount(1,"type:stream result:timeout",t.tAttrs),L(this,W,_t).call(this,t,p,t.encodeError(c,h,vp)).catch(()=>{});return}m.record.wireSignalRequestHandleCount(1,"type:stream result:started",t.tAttrs);const D=b[Symbol.asyncIterator]();for(;;){const O=op(t.name,t.timeoutMs),x=t.name==="client_continuum"?void 0:t.itemTimeoutMs,K=O==null?x:x!==void 0?Math.min(x,O-(y()-S)):O-(y()-S),I=K==null?await D.next():await pc(K,D.next());if(I===fc){g.signal.aborted||g.abort(Yn),m.record.wireSignalRequestHandleCount(1,"type:stream result:timeout",t.tAttrs),await _(vp),(w=D.return)==null||w.call(D,void 0).catch(()=>{});return}if(I.done)break;await L(this,W,_t).call(this,t,p,t.encodeResponse(c,h,I.value)),m.record.wireSignalStreamSegmentCount(1,t.tAttrs)}m.record.wireSignalRequestHandleCount(1,"type:stream result:ok",t.tAttrs),await _()}catch(S){await _(p_),m.record.wireSignalRequestHandleCount(1,"type:stream result:error",t.tAttrs),m.log.warn("wire_signal.stream_failed",{err:S,signal_name:t.name,signal_id:t.id,version:c,payload_size:s.length})}finally{L(this,W,pp).call(this,t.id,p)}})},"#handleRequestMessageForStream"),h_=ae(function(t,e){var r,s;const n=(r=N(this,cn).get(t.id))==null?void 0:r.get(e.messageId);if(!n){this.t.log.info("wire_signal_relay.abort_not_found",{signal_id:t.id,signal_name:t.name,message_id:e.messageId});return}n.abort(),(s=N(this,cn).get(t.id))==null||s.delete(e.messageId),this.t.record.wireSignalRequestHandleCount(1,`type:${t.type} result:aborted`,t.tAttrs)},"#handleAbortMessage"),fp=ae(function(t,e){const r=new AbortController;this.abortSignal.aborted&&r.abort();let s=N(this,cn).get(t);return s||(s=new Map,N(this,cn).set(t,s)),s.set(e,r),r},"#createRequestAbortController"),pp=ae(function(t,e){var r;(r=N(this,cn).get(t))==null||r.delete(e)},"#cleanupRequestAbortController"),u_=ae(function(t,e,r,s,n){var i;if(t.type!=="request"){this.t.record.wireSignalRequestHandleCount(1,"type:request result:mismatched_type",t.tAttrs),this.t.log.info("wire_request_signal.mismatched_signal",{signal_name:t.name,signal_type:t.type,payload_size:r.length});return}const a=(i=N(this,pr).get(t.id))==null?void 0:i.get(e.messageId);if(!a){this.t.record.wireSignalRequestHandleCount(1,"type:request result:unrecognized",t.tAttrs),this.t.log.info("wire_request_signal.non_recognized_response",{signal_name:t.name,payload_size:r.length,message_id:e.messageId});return}e.errorCode==null?(a.promise.__resolve(t[s](r,e.offset,e.signalVersion,n)),this.t.record.wireSignalResultCount(1,"type:request result:ok",t.tAttrs),this.t.record.wireSignalLatencyMs(y()-a.startedAt,"result:ok",t.tAttrs)):(a.promise.__reject(new Error("[direct.dev/wire/signal] remote error")),this.t.record.wireSignalResultCount(1,"type:request result:error",t.tAttrs),this.t.record.wireSignalLatencyMs(y()-a.startedAt,"result:error",t.tAttrs))},"#handleResponseMessage"),d_=ae(function(t,e,r,s,n){var i;if(t.type!=="stream"){this.t.record.wireSignalRequestHandleCount(1,"type:stream result:mismatched_type",t.tAttrs),this.t.log.info("wire_stream_signal.mismatched_signal",{signal_name:t.name,signal_type:t.type,payload_size:r.length});return}const a=(i=N(this,Wr).get(t.id))==null?void 0:i.get(e.messageId);if(!a){this.t.record.wireSignalRequestHandleCount(1,"type:stream result:unrecognized",t.tAttrs),this.t.log.info("wire_request_signal.non_recognized_stream",{signal_name:t.name,payload_size:r.length,message_id:e.messageId,message_type:e.messageType});return}switch(e.messageType){case"value":a.stream.push(t[s](r,e.offset,e.signalVersion,n));break;case"close":a.stream.close(void 0),this.t.record.wireSignalResultCount(1,"type:stream result:ok",t.tAttrs),this.t.record.wireSignalStreamLifetimeMs(y()-a.startedAt,"result:ok",t.tAttrs);break;case"error":a.stream.throw(new Error("[direct.dev/wire/signal] remote stream error")),this.t.record.wireSignalResultCount(1,"type:stream result:error",t.tAttrs),this.t.record.wireSignalStreamLifetimeMs(y()-a.startedAt,"result:error",t.tAttrs);break}},"#handleStream"),mp=ae(function(t,e){let r=N(this,pr).get(e.id);return r||(r=new Map,N(this,pr).set(e.id,r)),L(this,W,wp).call(this,t,e,r)},"#getReqId"),gp=ae(function(t,e){let r=N(this,Wr).get(e.id);return r||(r=new Map,N(this,Wr).set(e.id,r)),L(this,W,wp).call(this,t,e,r)},"#getStreamId"),wp=ae(function(t,e,r){let s=N(this,tu).get(e.id)??-1;if(r.size>=4096)throw t.record.wireSignalBackpressureCount(1,e.tAttrs),new Error("[direct.dev/wire/signal] backpressure - cannot have more than 4_096 concurrent requests");for(let n=0;n<4096;n++)if(s=s+1&4095,!r.has(s))return N(this,tu).set(e.id,s),s;throw t.record.wireSignalBackpressureCount(1,e.tAttrs),new Error("[direct.dev/wire/signal] backpressure - cannot have more than 4_096 concurrent requests")},"#getNextMsgId"),f_=ae(function(){const t=[];for(const e of N(this,pr).values())for(const{promise:r}of e.values())t.push(r);for(const e of N(this,Wr).values())for(const{stream:r}of e.values())t.push(r.wait());return Promise.allSettled(t)},"#drainPending"),ae(m_,"WireSignalRelay");let g_=m_;const qS={aborted:!1,reason:null,onabort:null,addEventListener:ae(()=>{},"addEventListener"),dispatchEvent:ae(()=>!1,"dispatchEvent"),removeEventListener:ae(()=>{},"removeEventListener"),throwIfAborted:ae(()=>{},"throwIfAborted")};var w_=Object.defineProperty,v_=o(t=>{throw TypeError(t)},"j$c"),PS=o((t,e,r)=>e in t?w_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"F$e"),nu=o((t,e)=>w_(t,"name",{value:e,configurable:!0}),"c$t"),__=o((t,e,r)=>PS(t,typeof e!="symbol"?e+"":e,r),"u$q"),_p=o((t,e,r)=>e.has(t)||v_("Cannot "+r),"v$k"),Jn=o((t,e,r)=>(_p(t,e,"read from private field"),r?r.call(t):e.get(t)),"a$p"),Lc=o((t,e,r)=>e.has(t)?v_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"h$m"),yp=o((t,e,r,s)=>(_p(t,e,"write to private field"),e.set(t,r),r),"p$n"),y_=o((t,e,r)=>(_p(t,e,"access private method"),r),"_$j"),iu,au,ou,ta,cu,bp;const b_=(yo=class{t;tAttrs={"wire_channel.name":"","wire_channel.role":"client","wire_channel.transport":""};mode="trusted";downstreamRelationship="parent";signals=new Map;handlers=new Map;constructor(e){this.t=e}_config(e,r,s){this.mode=e.mode,this.downstreamRelationship=e.downstreamRelationship,this.tAttrs={"wire_channel.name":e.channelName,"wire_channel.role":e.channelRole,"wire_channel.transport":this.type},this.t=this.t.with({"component.id":"WireChannelTransport",...this.tAttrs}),this.signals=r,this.handlers=s,this.afterConfig()}},o(yo,"f"),yo);nu(b_,"WireChannelTransport");let $p=b_;const $_=(bo=class{transport;mode;constructor(e,r){this.transport=e,this.mode=e.mode;for(const s in r){const n=r[s];switch(n.type){case"event":this.emit[s]=e.dispatch.bind(e,n),this.emitRaw[s]=e.dispatchRaw.bind(e,n);break;case"request":case"stream":this.request[s]=e.dispatch.bind(e,n)}}}request={};emit={};emitRaw={};dispatch(e,r,s,...n){return this.transport.dispatch(e,r,s,...n)}connect(e){var r,s;return(s=(r=this.transport).connect)==null?void 0:s.call(r,e)}disconnect(){var e,r;return(r=(e=this.transport).disconnect)==null?void 0:r.call(e)}},o(bo,"g"),bo);nu($_,"WireChannel");let xS=$_;const k_=($o=class{constructor(e,r,s){Lc(this,cu),Lc(this,iu),Lc(this,au),Lc(this,ou),Lc(this,ta,new Map),__(this,"client"),__(this,"server"),yp(this,iu,e.mode),yp(this,au,e.downstreamRelationship),yp(this,ou,e.name),this.client=r,this.server=s;for(const n of Object.values(s))Jn(this,ta).set(n.id,n);for(const n of Object.values(r))Jn(this,ta).set(n.id,n)}createClient(e,r){return y_(this,cu,bp).call(this,"client",e,this.server,this.client,r)}createServer(e,r){return y_(this,cu,bp).call(this,"server",e,this.client,this.server,r)}__signalMappingsForTests(){return Array.from(Jn(this,ta).entries())}},o($o,"A"),$o);iu=new WeakMap,au=new WeakMap,ou=new WeakMap,ta=new WeakMap,cu=new WeakSet,bp=nu(function(t,e,r,s,n){const i=new Map;for(const a in n){const c=r[a],h=n[a];i.set(c.id,h)}return e._config({channelName:Jn(this,ou),channelRole:t,mode:Jn(this,iu),downstreamRelationship:Jn(this,au)},Jn(this,ta),i),new xS(e,s)},"#createChannel"),nu(k_,"WireChannelPair");let C_=k_;var WS=Object.defineProperty,Fc=o((t,e)=>WS(t,"name",{value:e,configurable:!0}),"s$n");const US=4*1024,DS=4*1024*1024;function lu(t){const e=new CompressionStream("gzip"),r=e.writable.getWriter();return r.write(cc.encode(t)).catch(()=>{}),r.close().catch(()=>{}),e.readable.getReader()}o(lu,"y$h"),Fc(lu,"gzip");async function hu(t){const e=[];let r=0;for(;;){const i=await t.read();if(i.done)break;e.push(i.value),r+=i.value.length}if(e.length===1)return e[0];const s=new Uint8Array(r);let n=0;for(let i=0,a=e.length;i<a;i++){const c=e[i];s.set(c,n),n+=c.length}return s}o(hu,"E$l"),Fc(hu,"collectGzip");function S_(t){return Fc(async function(e){const r=new DecompressionStream("gzip"),s=r.writable.getWriter();s.write(e).then(()=>s.close(),()=>s.close()).catch(()=>{});const n=r.readable.getReader();let i=Math.min(US,t),a=new Uint8Array(i),c=0;for(;;){const h=await n.read();if(h.done)break;const u=c+h.value.length;if(u>t)throw await n.cancel(),new Error("gunzip(): Maximum decompression size exceeded");if(u>i){i*=2,i<u?i=u:i>t&&(i=t);const d=new Uint8Array(i);d.set(a),a=d}a.set(h.value,c),c=u}return gf.decode(a.subarray(0,c))},"gunzip2")}o(S_,"w$h"),Fc(S_,"makeGunzip");const kp=S_(DS);function Cp(){if(uu===void 0)try{uu=typeof CompressionStream=="function"&&new CompressionStream("gzip")instanceof CompressionStream}catch{uu=!1}return uu}o(Cp,"z$b"),Fc(Cp,"isCompressionSupported");let uu;const A_=3333;var OS=Object.defineProperty,E_=o(t=>{throw TypeError(t)},"te$4"),is=o((t,e)=>OS(t,"name",{value:e,configurable:!0}),"m$q"),Sp=o((t,e,r)=>e.has(t)||E_("Cannot "+r),"K$9"),C=o((t,e,r)=>(Sp(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$e"),Ae=o((t,e,r)=>e.has(t)?E_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"n$n"),de=o((t,e,r,s)=>(Sp(t,e,"write to private field"),e.set(t,r),r),"s$m"),et=o((t,e,r)=>(Sp(t,e,"access private method"),r),"o$j"),Be,mr,at,du,ra,Ap,ft,Is,zc,Hc,Ep,Mp,Tp,Rp,Bp,Ip,qp,fu,pu,mu,gu,Pp,wu,vu,sa,ze,_u,M_,T_,R_,B_,xp,Wp,na,yu;const I_=5e3,jS=I_*2,NS=2.5,q_=(ko=class extends g_{constructor(e,r,s,n,i,a,c,h,u){const d=e.with(r);super(d,n,i,h,void 0,u),Ae(this,ze),Ae(this,Be),Ae(this,mr),Ae(this,at),Ae(this,du),Ae(this,ra),Ae(this,Ap,Date.now()),Ae(this,ft,!1),Ae(this,Is,!1),Ae(this,zc),Ae(this,Hc),Ae(this,Ep,null),Ae(this,Mp,null),Ae(this,Tp,null),Ae(this,Rp,null),Ae(this,Bp,null),Ae(this,Ip,null),Ae(this,qp,null),Ae(this,fu,null),Ae(this,pu,null),Ae(this,mu,null),Ae(this,gu,null),Ae(this,Pp,null),Ae(this,wu,null),Ae(this,vu,null),Ae(this,sa,xf()),de(this,Be,d),de(this,mr,r),de(this,at,s),C(this,at).binaryType="arraybuffer",de(this,du,c),de(this,ra,a);const p=c.maxMessageSize??512*1024,f=Math.floor(p*NS);if(s.addEventListener("message",c.mode==="trusted"?g=>{et(this,ze,R_).call(this,g.data,p,f).catch(m=>{et(this,ze,_u).call(this,m)})}:g=>{et(this,ze,B_).call(this,g.data,p,f).catch(m=>{et(this,ze,_u).call(this,m)})}),s.addEventListener("close",g=>et(this,ze,M_).call(this,g)),s.addEventListener("error",g=>et(this,ze,_u).call(this,g)),c.acceptSocket!==!1&&typeof s.accept=="function")try{s.accept()}catch(g){C(this,Be).log.warn("wire_socket_relay.accept_failed",{err:g,ready_state:s.readyState})}c.startKeepalive!==!1&&(et(this,ze,na).call(this),et(this,ze,yu).call(this))}prepareFrame(e){return e.length>512&&C(this,ra).enableCompression?Ni(()=>C(this,ra).gzip(e),r=>r.length<e.length?r:e,r=>(C(this,Be).log.warn("wire_socket_relay.compression_failed",{err:r}),C(this,Be).record.wireSocketMessageCompressionFailureCount(1,C(this,mr)),e)):e}writeFrame(e,r,s){if(C(this,at).readyState!==WebSocket.OPEN){de(this,Tp,Date.now()),de(this,Rp,e.name),C(this,Be).log.error("wire_socket_relay.write_frame_dropped",{signal_name:e.name,ready_state:C(this,at).readyState,is_closed:C(this,ft),is_closing_gracefully:C(this,Is)}),C(this,Be).record.wireSocketMessageDropCount(1,C(this,mr));return}try{C(this,at).send(s),de(this,Ep,Date.now()),de(this,Mp,e.name)}catch(n){throw de(this,Bp,Date.now()),de(this,Ip,e.name),C(this,Be).log.error("wire_socket_relay.send_frame_failed",{err:n,signal_name:e.name,ready_state:C(this,at).readyState,is_closed:C(this,ft)}),n}et(this,ze,yu).call(this)}async disconnect(e,r,s){C(this,ft)||(de(this,ft,!0),de(this,Is,e===!0),de(this,fu,Date.now()),de(this,pu,r??null),de(this,mu,s??null),de(this,gu,e===!0?!0:null),C(this,du).onClose(r),clearTimeout(C(this,zc)),clearTimeout(C(this,Hc)),await this.handleClose(e),de(this,Is,!1),C(this,at).readyState!==WebSocket.CLOSING&&C(this,at).readyState!==WebSocket.CLOSED&&C(this,at).close(r,s))}get isClosed(){return C(this,ft)}},o(ko,"Z"),ko);Be=new WeakMap,mr=new WeakMap,at=new WeakMap,du=new WeakMap,ra=new WeakMap,Ap=new WeakMap,ft=new WeakMap,Is=new WeakMap,zc=new WeakMap,Hc=new WeakMap,Ep=new WeakMap,Mp=new WeakMap,Tp=new WeakMap,Rp=new WeakMap,Bp=new WeakMap,Ip=new WeakMap,qp=new WeakMap,fu=new WeakMap,pu=new WeakMap,mu=new WeakMap,gu=new WeakMap,Pp=new WeakMap,wu=new WeakMap,vu=new WeakMap,sa=new WeakMap,ze=new WeakSet,_u=is(function(t){C(this,ft)||(C(this,Be).log.warn("wire_channel.websocket_error",{err:t.error,err_message:t.message,ready_state:C(this,at).readyState,is_closed:C(this,ft),is_closing_gracefully:C(this,Is)}),C(this,Be).record.wireSocketErrorCount(1,C(this,mr)),C(this,at).close(),C(this,sa).call(this,()=>{if(!C(this,ft))return this.disconnect(!1)}).catch(e=>{C(this,Be).log.warn("wire_channel.websocket_disconnect_failed",{err:e})}))},"#handleSocketError"),M_=is(function(t){C(this,ft)||(de(this,fu,Date.now()),de(this,pu,t.code),de(this,mu,t.reason),de(this,gu,t.wasClean),C(this,Be).log.debug("wire_channel.websocket_closed",{code:t.code,reason:t.reason,was_clean:t.wasClean,ready_state:C(this,at).readyState,is_closing_gracefully:C(this,Is),lifetime_ms:Date.now()-C(this,Ap)}),C(this,Be).record.wireSocketCloseCount(1,t.wasClean?"was_clean:true":"was_clean:false",C(this,mr)),C(this,at).close(),C(this,sa).call(this,()=>{if(!C(this,ft))return this.disconnect(!1,t.code)}).catch(e=>{C(this,Be).log.warn("wire_channel.websocket_disconnect_failed",{err:e})}))},"#handleSocketClose"),T_=is(function(){C(this,ft)||(C(this,Be).record.wireSocketInactivityCount(1,C(this,mr)),this.disconnect().catch(t=>{C(this,Be).log.warn("wire_channel.websocket_disconnect_failed",{err:t})}))},"#handleSocketInactivity"),R_=is(async function(t,e,r){if(t===""){this.bandwidthHooks.onIngress(0,void 0),et(this,ze,na).call(this);return}const s=typeof t=="string"?t:new Uint8Array(t),n=s.length;if(C(this,Be).record.wireSocketMessageSizeInBytes(n,C(this,mr)),n>e){C(this,Be).record.wireSocketMessageTooLargeCount(1,"mode:trusted",C(this,mr)),C(this,Be).log.info("wire_socket_relay.message_too_large",{payload_size:n,max_size:e,mode:"trusted",payload_type:typeof t=="string"?"string":"binary"});return}return C(this,sa).call(this,()=>et(this,ze,Wp).call(this,s)).then(i=>{if(!(C(this,ft)&&!C(this,Is)))return et(this,ze,xp).call(this,i),Ni(()=>this.handleTrustedMessage(i,n,r),a=>{a&&et(this,ze,na).call(this)})})},"#handleTrustedIncomingMessage"),B_=is(async function(t,e,r){if(t===""){this.bandwidthHooks.onIngress(0,void 0),et(this,ze,na).call(this);return}const s=typeof t=="string"?t:new Uint8Array(t),n=s.length;if(C(this,Be).record.wireSocketMessageSizeInBytes(n,C(this,mr)),n>e){C(this,Be).record.wireSocketMessageTooLargeCount(1,"mode:untrusted",C(this,mr)),C(this,Be).log.info("wire_socket_relay.message_too_large",{payload_size:n,max_size:e,mode:"untrusted",payload_type:typeof t=="string"?"string":"binary"});return}return C(this,sa).call(this,()=>et(this,ze,Wp).call(this,s)).then(i=>{if(!(C(this,ft)&&!C(this,Is)))return et(this,ze,xp).call(this,i),Ni(()=>this.handleUntrustedMessage(i,n,r),a=>{a&&et(this,ze,na).call(this)})})},"#handleUntrustedIncomingMessage"),xp=is(function(t){var e;de(this,Pp,Date.now());try{const r=Qh(t);de(this,vu,r.type),de(this,wu,((e=this.getSignalById(r.signalId))==null?void 0:e.name)??null)}catch{de(this,vu,null),de(this,wu,null)}},"#recordIngressFrame"),Wp=is(function(t){return typeof t=="string"?t:C(this,ra).gunzip(t)},"#decodeFrame"),na=is(function(){clearTimeout(C(this,zc)),de(this,zc,setTimeout(()=>{et(this,ze,T_).call(this)},jS))},"#scheduleInactivity"),yu=is(function(){clearTimeout(C(this,Hc)),de(this,Hc,setTimeout(()=>{if(!(C(this,ft)||C(this,at).readyState!==WebSocket.OPEN)){try{C(this,at).send(""),de(this,qp,Date.now())}catch(t){throw C(this,Be).log.error("wire_socket_relay.send_ping_failed",{err:t,ready_state:C(this,at).readyState,is_closed:C(this,ft)}),t}this.bandwidthHooks.onEgress(0,void 0),et(this,ze,yu).call(this)}},I_))},"#schedulePing"),is(q_,"WireSocketRelay");let LS=q_;var FS=Object.defineProperty,P_=o(t=>{throw TypeError(t)},"ot$1"),gr=o((t,e)=>FS(t,"name",{value:e,configurable:!0}),"w$g"),Up=o((t,e,r)=>e.has(t)||P_("Cannot "+r),"et$1"),U=o((t,e,r)=>(Up(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$d"),Y=o((t,e,r)=>e.has(t)?P_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"i$f"),oe=o((t,e,r,s)=>(Up(t,e,"write to private field"),e.set(t,r),r),"r$j"),Kc=o((t,e,r)=>(Up(t,e,"access private method"),r),"y$g"),Qt=o((t,e,r,s)=>({set _(n){oe(t,e,n)},get _(){return U(t,e,s)}}),"u$p"),bu,Ct,Pt,Le,ia,Gc,$u,ku,Cu,Dp,Op,jp,Np,Lp,Fp,zp,Hp,Kp,Gp,Vp,Yp,Jp,Xp,Qp,Zp,em,tm,Su,Vc,rm,sm,nm,im,am,om,Xn,Au,x_,W_;const U_=(Co=class extends $p{type="websocket";_compression;constructor(e,r){super(e),this._compression={enableCompression:(r==null?void 0:r.enableCompression)??!1,gzip:(r==null?void 0:r.gzip)??(s=>hu(lu(s))),gunzip:(r==null?void 0:r.gunzip)??kp}}},o(Co,"rt"),Co);gr(U_,"WireSocketChannel");let zS=U_;const D_=(So=class extends zS{constructor(e,r,s,n){super(e,s==null?void 0:s.compression),Y(this,Xn),Y(this,bu),Y(this,Ct,!1),Y(this,Pt),Y(this,Le),Y(this,ia),Y(this,Gc),Y(this,$u),Y(this,ku),Y(this,Cu),Y(this,Dp,0),Y(this,Op,0),Y(this,jp,0),Y(this,Np,0),Y(this,Lp,0),Y(this,Fp,{public_connect:0,handle_close:0,roll_connection:0}),Y(this,zp,0),Y(this,Hp,0),Y(this,Kp,0),Y(this,Gp,0),Y(this,Vp,0),Y(this,Yp,0),Y(this,Jp,0),Y(this,Xp,0),Y(this,Qp,null),Y(this,Zp,null),Y(this,em,null),Y(this,tm,null),Y(this,Su,null),Y(this,Vc,null),Y(this,rm,null),Y(this,sm,null),Y(this,nm,null),Y(this,im,null),Y(this,am,null),Y(this,om,null),oe(this,bu,r),oe(this,Cu,n),oe(this,Gc,s),oe(this,$u,(s==null?void 0:s.onConnect)??(()=>{})),oe(this,ku,(s==null?void 0:s.onDisconnect)??(()=>{})),oe(this,ia,new Rh((s==null?void 0:s.circuitBreaker)??{},{onFailure:gr((i,a)=>{e.log.info("wire_socket_client.circuit_breaker_failure",{state:i,backoff_ms:a})},"onFailure"),onTransition:gr((i,a)=>{e.log.debug("wire_socket_client.circuit_breaker_transition",{prev_state:i,new_state:a}),e.record.wireSocketCircuitBreakerStateCount(1,`state:${a}`,{"wire_channel.name":this.tAttrs["wire_channel.name"]})},"onTransition")}))}afterConfig(){}dispatch(e,r,s){if(U(this,Pt))return U(this,Pt).then(()=>{if(!U(this,Le))throw new Error("[direct.dev/wire/channel] WireSocketClient.dispatch() called before connection established");return U(this,Le).dispatch(r,e,s)});if(!U(this,Le))throw new Error("[direct.dev/wire/channel] WireSocketClient.dispatch() called before connection established");return U(this,Le).dispatch(r,e,s)}dispatchRaw(e,r,s){if(U(this,Pt))return U(this,Pt).then(()=>{if(!U(this,Le))throw new Error("[direct.dev/wire/channel] WireSocketClient.dispatchRaw() called before connection established");return U(this,Le).dispatchRaw(r,e,s)});if(!U(this,Le))throw new Error("[direct.dev/wire/channel] WireSocketClient.dispatchRaw() called before connection established");return U(this,Le).dispatchRaw(r,e,s)}async connect(e){if(Qt(this,Dp)._++,oe(this,Qp,Date.now()),U(this,Ct)){Qt(this,Op)._++,oe(this,Zp,Date.now());return}try{oe(this,Ct,!0),await Kc(this,Xn,Au).call(this,e,"public_connect")}catch(r){throw oe(this,Ct,!1),r}}async disconnect(e,r=!1){var s;oe(this,Ct,!1),(s=U(this,Pt))==null||s.catch(()=>{});const n=U(this,Le);oe(this,Le,void 0),await(n==null?void 0:n.disconnect(r,A_,e))}async rollConnection(){if(!U(this,Ct))throw new Error("[direct.dev/wire/channel]: WireSocketClient.rollConnection() cannot be called on disconnected socket");try{await Kc(this,Xn,Au).call(this,this.t,"roll_connection"),this.t.record.wireSocketRollCount(1,"result:ok",this.tAttrs)}catch(e){throw this.t.record.wireSocketRollCount(1,"result:error",this.tAttrs),e}}get isConnected(){return U(this,Ct)&&U(this,Le)!==void 0&&!U(this,Le).isClosed}get isConnecting(){return U(this,Ct)&&U(this,Le)===void 0}get connectionPromise(){return U(this,Pt)}get __relayForTesting(){return U(this,Le)}},o(So,"st"),So);bu=new WeakMap,Ct=new WeakMap,Pt=new WeakMap,Le=new WeakMap,ia=new WeakMap,Gc=new WeakMap,$u=new WeakMap,ku=new WeakMap,Cu=new WeakMap,Dp=new WeakMap,Op=new WeakMap,jp=new WeakMap,Np=new WeakMap,Lp=new WeakMap,Fp=new WeakMap,zp=new WeakMap,Hp=new WeakMap,Kp=new WeakMap,Gp=new WeakMap,Vp=new WeakMap,Yp=new WeakMap,Jp=new WeakMap,Xp=new WeakMap,Qp=new WeakMap,Zp=new WeakMap,em=new WeakMap,tm=new WeakMap,Su=new WeakMap,Vc=new WeakMap,rm=new WeakMap,sm=new WeakMap,nm=new WeakMap,im=new WeakMap,am=new WeakMap,om=new WeakMap,Xn=new WeakSet,Au=gr(function(t,e){if(Qt(this,jp)._++,U(this,Fp)[e]++,oe(this,em,Date.now()),oe(this,tm,e),!U(this,Ct)){Qt(this,Np)._++,oe(this,Su,Date.now()),oe(this,Vc,"client_not_marked_connected");return}return U(this,Pt)?(Qt(this,Lp)._++,oe(this,Su,Date.now()),oe(this,Vc,"connection_in_flight"),U(this,Pt)):(oe(this,Vc,null),oe(this,Pt,(async()=>{var r;try{const s=await Kc(this,Xn,x_).call(this,t);if(!s||!U(this,Ct)){s||oe(this,Ct,!1),s==null||s.close();return}const n=U(this,Le),i=new LS(t,this.tAttrs,s,this.signals,this.handlers,this._compression,{mode:this.mode,maxMessageSize:(r=U(this,Gc))==null?void 0:r.maxMessageSize,onClose:gr(a=>{Qt(this,Vp)._++,oe(this,am,Date.now()),oe(this,om,a??null),U(this,Le)===i?(Qt(this,Yp)._++,U(this,Pt)&&Qt(this,Xp)._++):Qt(this,Jp)._++;try{U(this,ku).call(this)}catch(c){t.log.warn("wire_socket_client.on_disconnect_failed",{err:c})}U(this,Le)===i&&U(this,Ct)&&Kc(this,Xn,W_).call(this,t).catch(c=>{t.log.warn("wire_socket_client.handle_close_failed",{err:c})})},"onClose")},U(this,Cu),this.downstreamRelationship);oe(this,Le,i),n==null||n.disconnect(!0,A_,"wire_socket_roll").catch(a=>{t.log.warn("wire_socket_client.roll_disconnect_failed",{err:a})}),t.record.wireSocketConnectCount(1,this.tAttrs);try{U(this,$u).call(this)}catch(a){t.log.warn("wire_socket_client.on_connect_failed",{err:a})}}finally{oe(this,Pt,void 0)}})()),U(this,Pt))},"#connect"),x_=gr(async function(t){var e;if(!U(this,ia).check())return t.record.wireSocketCircuitBreakerRejectCount(1,this.tAttrs),null;for(;U(this,Ct);)try{Qt(this,Hp)._++,oe(this,sm,Date.now());const r=await U(this,bu).call(this);if(r.readyState===WebSocket.CONNECTING&&await new Promise((s,n)=>{const i=gr(()=>{h(),s()},"onOpen"),a=gr(()=>{h(),n(new Error("socket failed unexpectedly"))},"onError"),c=gr(()=>{h(),n(new Error("socket closed unexpectedly"))},"onClose");function h(){r.removeEventListener("open",i),r.removeEventListener("error",a),r.removeEventListener("close",c)}o(h,"v"),gr(h,"cleanup"),r.addEventListener("open",i),r.addEventListener("error",a),r.addEventListener("close",c)}),r.readyState!==WebSocket.OPEN)throw new Error("socket did not open correctly");return(e=U(this,Gc))!=null&&e.primeSocket&&r.send(""),t.record.wireSocketDialCount(1,"result:ok",this.tAttrs),Qt(this,Kp)._++,oe(this,nm,Date.now()),U(this,ia).recordSuccess(),r}catch(r){if(t.log.info("wire_socket_client.dial_failed",{err:r}),t.record.wireSocketDialCount(1,"result:error",this.tAttrs),Qt(this,Gp)._++,oe(this,im,Date.now()),!await U(this,ia).recordFailure())return null}return null},"#dialSocket"),W_=gr(async function(t){if(Qt(this,zp)._++,oe(this,rm,Date.now()),!U(this,Ct))return;const e=U(this,Le);oe(this,Le,void 0),await(e==null?void 0:e.disconnect()),await Kc(this,Xn,Au).call(this,t,"handle_close")},"#handleClose"),gr(D_,"WireSocketClient");let HS=D_;var O_=Object.defineProperty,j_=o(t=>{throw TypeError(t)},"G$7"),KS=o((t,e,r)=>e in t?O_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"Y$2"),yt=o((t,e)=>O_(t,"name",{value:e,configurable:!0}),"u$o"),GS=o((t,e,r)=>KS(t,e+"",r),"J$6"),cm=o((t,e,r)=>e.has(t)||j_("Cannot "+r),"F$b"),A=o((t,e,r)=>(cm(t,e,"read from private field"),r?r.call(t):e.get(t)),"t$8"),St=o((t,e,r)=>e.has(t)?j_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"f$m"),Je=o((t,e,r,s)=>(cm(t,e,"write to private field"),e.set(t,r),r),"d$i"),We=o((t,e,r)=>(cm(t,e,"access private method"),r),"a$m"),wr,Eu,Mu,Yc,ce,as,qs,aa,Qn,Zn,ei,oa,ti,Jc,Ee,lm,hm,N_,um,L_,F_,z_,Xc,dm,Tu,Qc;const H_=(Ao=class extends $p{constructor(e,r,s,n){super(e),St(this,Ee),GS(this,"type","websocket"),St(this,wr),St(this,Eu),St(this,Mu),St(this,Yc),St(this,ce,[]),St(this,as,0),St(this,qs),St(this,aa),St(this,Qn,new Map),St(this,Zn,new Map),St(this,ei,new Map),St(this,oa),St(this,ti),St(this,Jc),Je(this,Eu,r),Je(this,Mu,s),n?Je(this,Yc,{onIngress:yt((i,a)=>{We(this,Ee,Qc).call(this,i),n.onIngress(i,a)},"onIngress"),onEgress:yt((i,a)=>{We(this,Ee,Qc).call(this,i),n.onEgress(i,a)},"onEgress")}):Je(this,Yc,{onIngress:yt(i=>We(this,Ee,Qc).call(this,i),"onIngress"),onEgress:yt(i=>We(this,Ee,Qc).call(this,i),"onEgress")}),Je(this,wr,{scaleUpThreshold:(s==null?void 0:s.scaleUpThreshold)??100,scaleDownThreshold:(s==null?void 0:s.scaleDownThreshold)??80,scaleUpBytesPerSecond:(s==null?void 0:s.scaleUpBytesPerSecond)??1e6,scaleDownBytesPerSecond:(s==null?void 0:s.scaleDownBytesPerSecond)??5e5,scalingWindowMs:(s==null?void 0:s.scalingWindowMs)??5e3,idleDisconnectMs:s==null?void 0:s.idleDisconnectMs,minPoolSize:(s==null?void 0:s.minPoolSize)??1,maxPoolSize:(s==null?void 0:s.maxPoolSize)??10,connectionRollingIntervalMs:s==null?void 0:s.connectionRollingIntervalMs})}afterConfig(){Je(this,aa,{channelName:this.tAttrs["wire_channel.name"],channelRole:this.tAttrs["wire_channel.role"],mode:this.mode,downstreamRelationship:this.downstreamRelationship});for(const e of A(this,ce))e._config(A(this,aa),this.signals,this.handlers)}dispatch(e,r,s){const n=We(this,Ee,lm).call(this,r);return n instanceof Promise?n.then(i=>i.dispatch(e,r,s)):n.dispatch(e,r,s)}dispatchRaw(e,r,s){const n=We(this,Ee,lm).call(this,r);return n instanceof Promise?n.then(i=>i.dispatchRaw(e,r,s)):n.dispatchRaw(e,r,s)}async connect(e){if(A(this,ce).length>0){if(A(this,ce).some(s=>s.isConnected||s.connectionPromise)){await(A(this,qs)??Promise.allSettled(A(this,ce).map(s=>s.connectionPromise).filter(s=>s!==void 0)));return}await this.disconnect("reconnect_bootstrap")}Je(this,ti,y());const r=A(this,wr).minPoolSize;for(let s=0;s<r;s++)We(this,Ee,dm).call(this,e);Je(this,qs,Promise.allSettled(A(this,ce).map(s=>s.connectionPromise))),Je(this,oa,setInterval(()=>{We(this,Ee,N_).call(this)},1e3)),await A(this,qs),Je(this,qs,void 0)}async disconnect(e="client_disconnect"){A(this,oa)&&(clearInterval(A(this,oa)),Je(this,oa,void 0));for(const s of A(this,ei).values())clearInterval(s);A(this,ei).clear(),A(this,Qn).clear(),A(this,Zn).clear();const r=A(this,ce);Je(this,ce,[]),Je(this,as,0),Je(this,qs,void 0),Je(this,ti,void 0),Je(this,Jc,void 0),await Promise.all(r.map(s=>s.disconnect(e)))}get isConnected(){return A(this,ce).some(e=>e.isConnected)}get connectionPromise(){return A(this,qs)}},o(Ao,"j"),Ao);wr=new WeakMap,Eu=new WeakMap,Mu=new WeakMap,Yc=new WeakMap,ce=new WeakMap,as=new WeakMap,qs=new WeakMap,aa=new WeakMap,Qn=new WeakMap,Zn=new WeakMap,ei=new WeakMap,oa=new WeakMap,ti=new WeakMap,Jc=new WeakMap,Ee=new WeakSet,lm=yt(function(t){return We(this,Ee,hm).call(this)||(A(this,qs)??this.connect(t)).then(()=>{const r=We(this,Ee,hm).call(this);if(!r)throw new Error("[direct.dev/wire/channel] WireSocketClientPool.#getClientForDispatch() no client available after reconnect");return r})},"#getClientForDispatch"),hm=yt(function(){if(A(this,ce).length===0)return;const t=Math.floor(y()/1e3);A(this,Qn).set(t,(A(this,Qn).get(t)??0)+1),Je(this,Jc,Date.now());const e=A(this,ce).length;for(let s=0;s<e;s++){const n=(A(this,as)+s)%e,i=A(this,ce)[n];if(!(!i||i.connectionPromise))return Je(this,as,(n+1)%e),i}Je(this,as,(A(this,as)+1)%e);const r=A(this,ce)[A(this,as)];if(r)return r},"#selectClientForDispatch"),N_=yt(function(){if(A(this,ce).length===0)return;const[t,e,r]=We(this,Ee,um).call(this),s=We(this,Ee,Xc).call(this);if(!r&&!s)return;const{scaleUpThreshold:n,scaleDownThreshold:i,scaleUpBytesPerSecond:a,scaleDownBytesPerSecond:c}=A(this,wr);t>=n*A(this,ce).length||e>=a*A(this,ce).length?We(this,Ee,L_).call(this):t<=i*(A(this,ce).length-1)&&e<=c*(A(this,ce).length-1)&&We(this,Ee,F_).call(this)},"#evaluateScaling"),um=yt(function(){const t=y(),{scalingWindowMs:e}=A(this,wr),r=Math.floor((t-e)/1e3),s=A(this,ti)!==void 0&&t-A(this,ti)>=e;let n=0,i=0;for(const[h,u]of A(this,Qn))h<r?A(this,Qn).delete(h):n+=u;for(const[h,u]of A(this,Zn))h<r?A(this,Zn).delete(h):i+=u;const a=n/(e/1e3),c=i/(e/1e3);return[a,c,s]},"#computeThroughput"),L_=yt(function(){A(this,ce).length>=A(this,wr).maxPoolSize||this.t.runSpan({kind:"INTERNAL"},{event:"wire_socket_pool.scale_up",...this.tAttrs},t=>{We(this,Ee,dm).call(this,t)})},"#maybeScaleUp"),F_=yt(function(){const t=We(this,Ee,Xc).call(this);if(A(this,ce).length<=A(this,wr).minPoolSize){t&&this.t.runSpan({kind:"INTERNAL"},{event:"wire_socket_pool.idle_disconnect",...this.tAttrs},()=>{this.disconnect("idle_disconnect").catch(e=>{this.t.log.warn("wire_socket_pool.disconnect_failed",{...this.tAttrs,err:e})})});return}this.t.runSpan({kind:"INTERNAL"},{event:"wire_socket_pool.scale_down",...this.tAttrs},()=>{const e=A(this,ce)[A(this,ce).length-1];e&&We(this,Ee,Tu).call(this,e)})},"#maybeScaleDown"),z_=yt(function(){if(A(this,ce).length<=A(this,wr).minPoolSize)return We(this,Ee,Xc).call(this);const[t,e]=We(this,Ee,um).call(this),{scaleDownThreshold:r,scaleDownBytesPerSecond:s}=A(this,wr);return t<=r*(A(this,ce).length-1)&&e<=s*(A(this,ce).length-1)},"#shouldScaleDown"),Xc=yt(function(){const{idleDisconnectMs:t}=A(this,wr);if(!t)return!1;const e=A(this,Jc)??A(this,ti);return e?Date.now()-e>=t:!1},"#shouldDisconnectForIdle"),dm=yt(function(t){const e=new HS(this.t,A(this,Eu),A(this,Mu),A(this,Yc));A(this,aa)&&e._config(A(this,aa),this.signals,this.handlers),A(this,ce).push(e);const r=A(this,wr).connectionRollingIntervalMs;if(r){const s=setInterval(()=>{if(We(this,Ee,z_).call(this)){We(this,Ee,Xc).call(this)?this.disconnect("idle_disconnect").catch(n=>{this.t.log.warn("wire_socket_pool.disconnect_failed",{...this.tAttrs,err:n})}):We(this,Ee,Tu).call(this,e);return}e.rollConnection().catch(n=>{this.t.log.warn("wire_socket_pool.roll_failed",{...this.tAttrs,err:n})})},r);A(this,ei).set(e,s)}return e.connect(t).catch(()=>{We(this,Ee,Tu).call(this,e)}),e},"#addClient"),Tu=yt(function(t){const e=A(this,ce).indexOf(t);if(e<0||e>=A(this,ce).length)return;const r=A(this,ei).get(t);A(this,ce).splice(e,1),A(this,ei).delete(t),r&&clearInterval(r),A(this,as)>=A(this,ce).length&&Je(this,as,0),t==null||t.disconnect("scale_down").catch(s=>{this.t.log.warn("wire_socket_pool.client_disconnect_failed",{...this.tAttrs,err:s})})},"#removeClient"),Qc=yt(function(t){const e=Math.floor(y()/1e3);A(this,Zn).set(e,(A(this,Zn).get(e)??0)+t)},"#recordBandwidth"),yt(H_,"WireSocketClientPool");let VS=H_;var YS=Object.defineProperty,K_=o(t=>{throw TypeError(t)},"T$b"),Ru=o((t,e)=>YS(t,"name",{value:e,configurable:!0}),"I$c"),fm=o((t,e,r)=>e.has(t)||K_("Cannot "+r),"$$8"),ge=o((t,e,r)=>(fm(t,e,"read from private field"),r?r.call(t):e.get(t)),"n$m"),os=o((t,e,r)=>e.has(t)?K_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"d$h"),ln=o((t,e,r,s)=>(fm(t,e,"write to private field"),e.set(t,r),r),"m$n"),Bu=o((t,e,r)=>(fm(t,e,"access private method"),r),"E$h"),cs,ca,la,Iu,pm,G_,ri,ha,si,ni,Zc,qu;const V_=(Eo=class extends g_{constructor(e,r,s,n,i,a,c,h,u){super(e.with(r),s,n,c,h,u),os(this,pm),os(this,cs),os(this,ca),os(this,la),os(this,Iu),ln(this,cs,r),ln(this,ca,new J_(i,a.maxMessageSize,{t:e,tAttrs:r})),ln(this,la,a.maxStreamSize),ln(this,Iu,a.write)}prepareFrame(e){return ge(this,ca).encode(e)}writeFrame(e,r,s,n,i){return ge(this,Iu).call(this,e,r,s,n,i)}encodeFrame(e){return ge(this,ca).encode(e)}dispatchAbort(){}async processIngress(e,r,s){const n=Date.now(),i=[],a=s==="trusted"?this.handleTrustedMessage.bind(this):this.handleUntrustedMessage.bind(this);try{e.record.wireHttpIngressDelayMs(Date.now()-n,ge(this,cs));const c=r.getReader(),h={arr:void 0,length:0};let u=0;for(;;){const d=await c.read();if(d.value){if(u+=d.value.length,u>ge(this,la))throw e.log.warn("wire_stream_relay.stream_too_large",{total_size:u,max_size:ge(this,la)}),e.record.wireHttpIngressCount(1,"result:stream_too_large",ge(this,cs)),new Error(`[direct.dev/wire/channel] ingress stream exceeds maximum size (${u} > ${ge(this,la)})`);if(h.length===0)h.arr=d.value.slice(),h.length=h.arr.length;else{if(h.length+d.value.length>h.arr.length){const f=new Uint8Array(Math.max(h.arr.length*2,h.length+d.value.length));f.set(h.arr),h.arr=f}h.arr.set(d.value,h.length),h.length+=d.value.length}const p=await Bu(this,pm,G_).call(this,e,h,a);for(let f=0,g=p.length;f<g;f++){const m=p[f];m!==void 0&&i.push(m)}}if(d.done)break}return e.record.wireHttpIngressCount(1,"result:ok",ge(this,cs)),e.record.wireHttpIngressStreamSizeInBytes(u,ge(this,cs)),h.length>0&&(this.bandwidthHooks.onIngress(h.length,void 0),e.log.debug("wire_stream_relay.unprocessable_data",{...ge(this,cs),unprocessed_bytes:h.length,total_bytes:u})),i}catch(c){if(Rr(c)||c&&c instanceof TypeError&&c.message.includes("client disconnected")||c&&c instanceof Error&&c.name==="AbortError")return i;throw e.log.warn("wire_http_relay.ingress_failed",{err:c}),e.record.wireHttpIngressCount(1,"result:error",ge(this,cs)),c}}},o(Eo,"y"),Eo);cs=new WeakMap,ca=new WeakMap,la=new WeakMap,Iu=new WeakMap,pm=new WeakSet,G_=Ru(async function(t,e,r){const s=[];for(;e.length>0;){const n=e.length,i=await ge(this,ca).decode(e);if(i==null)break;const a=n-e.length,c=Math.max(a,i.length);s.push(r(i,a,c)),t.record.wireHttpMessageSizeInBytes(i.length,ge(this,cs))}return s},"#drainIngressBuffer"),Ru(V_,"WireStreamRelay");let JS=V_;const Y_=(Mo=class{constructor(e,r,s){os(this,Zc),os(this,ri),os(this,ha),os(this,si),os(this,ni);var n;ln(this,ha,(s==null?void 0:s.tAttrs)??{"wire_channel.role":"client","wire_channel.name":"","wire_channel.transport":""}),ln(this,ri,(n=s==null?void 0:s.t)==null?void 0:n.with(ge(this,ha))),ln(this,si,e),ln(this,ni,r)}encode(e){return e.length>512&&ge(this,si).enableCompression?Ni(()=>ge(this,si).gzip(e),r=>Bu(this,Zc,qu).call(this,r,!0),r=>{var s,n;return(s=ge(this,ri))==null||s.log.warn("wire_stream_framer.compression_failed",{err:r}),(n=ge(this,ri))==null||n.record.wireHttpMessageFramingFailureCount(1,"reason:compression_failed",ge(this,ha)),Bu(this,Zc,qu).call(this,cc.encode(e),!1)}):Bu(this,Zc,qu).call(this,cc.encode(e),!1)}decode(e){const r=e.arr[0];if(r==null)return;const s=(r&128)!==0,n=(r&64)!==0;let i=r&63;if(!n){if(i>ge(this,ni))throw new Error(`[direct.dev/wire/channel] message exceeds maximum size (${i} > ${ge(this,ni)})`);const a=i+1;if(e.length<a)return;const c=e.arr.subarray(1,a);return Rt(s?ge(this,si).gunzip(c):gf.decode(c),h=>(e.arr.set(e.arr.subarray(a)),e.length-=a,h))}for(let a=1;a<4;a++){const c=e.arr[a];if(c==null)return;const h=(c&128)!==0;if(i|=(c&127)<<a*7-1,!h){if(i>ge(this,ni))throw new Error(`[direct.dev/wire/channel] message exceeds maximum size (${i} > ${ge(this,ni)})`);const u=a+1,d=i+u;if(e.length<d)return;const p=e.arr.subarray(u,d);return Rt(s?ge(this,si).gunzip(p):gf.decode(p),f=>(e.arr.set(e.arr.subarray(d)),e.length-=d,f))}}throw new Error("[direct.dev/wire/channel] invalid WireRelayStream frame received, header must not exceed 4 bytes")}},o(Mo,"F"),Mo);ri=new WeakMap,ha=new WeakMap,si=new WeakMap,ni=new WeakMap,Zc=new WeakSet,qu=Ru(function(t,e){var r,s;if(t.length<64){const n=new Uint8Array(t.length+1);return n[0]=e?128|t.length:t.length,n.set(t,1),n}if(t.length<8192){const n=new Uint8Array(t.length+2);return n[0]=e?192|t.length&63:64|t.length&63,n[1]=t.length>>6,n.set(t,2),n}if(t.length<1048576){const n=new Uint8Array(t.length+3);return n[0]=e?192|t.length&63:64|t.length&63,n[1]=128|t.length>>6&127,n[2]=t.length>>13,n.set(t,3),n}if(t.length<134217728){const n=new Uint8Array(t.length+4);return n[0]=e?192|t.length&63:64|t.length&63,n[1]=128|t.length>>6&127,n[2]=128|t.length>>13&127,n[3]=t.length>>20,n.set(t,4),n}throw(r=ge(this,ri))==null||r.log.info("wire_stream_framer.payload_too_large",{payload_size:t.length,payload_max_size:134217727}),(s=ge(this,ri))==null||s.record.wireHttpMessageFramingFailureCount(1,"reason:payload_too_large",ge(this,ha)),new Error("[direct.dev/wire/channel]: messages above 128Mb not supported for HTTP transport")},"#frameBody"),Ru(Y_,"WireStreamFramer");let J_=Y_;var X_=Object.defineProperty,Q_=o(t=>{throw TypeError(t)},"W$6"),XS=o((t,e,r)=>e in t?X_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"$$7"),vr=o((t,e)=>X_(t,"name",{value:e,configurable:!0}),"u$n"),Z_=o((t,e,r)=>XS(t,typeof e!="symbol"?e+"":e,r),"M$c"),mm=o((t,e,r)=>e.has(t)||Q_("Cannot "+r),"P$b"),Ue=o((t,e,r)=>(mm(t,e,"read from private field"),r?r.call(t):e.get(t)),"h$k"),Ps=o((t,e,r)=>e.has(t)?Q_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"w$d"),hn=o((t,e,r,s)=>(mm(t,e,"write to private field"),e.set(t,r),r),"v$g"),ot=o((t,e,r)=>(mm(t,e,"access private method"),r),"l$r"),ls,ua,Pu,xu,Wu,el,xs,tl,Xe,gm,wm,vm,rl,ey,ty,ry,_m,Uu;const sy={"Content-Type":"text/plain"},QS=2*1024*1024,ZS=20*1024*1024,ny=(To=class extends $p{constructor(e,r,s,n){super(e),Ps(this,Xe),Z_(this,"type","http"),Z_(this,"isConnected",!1),Ps(this,ls),Ps(this,ua),Ps(this,Pu),Ps(this,xu),Ps(this,Wu),Ps(this,el),Ps(this,xs),Ps(this,tl);const i=r.url;hn(this,ua,typeof i=="string"?()=>i:i),hn(this,el,r.fetchFn??(()=>globalThis.fetch.bind(globalThis))),hn(this,ls,{batchWindowMs:r.batchWindowMs??15,batchMaxSizeInBytes:r.batchMaxSizeInBytes??524288,batchTimeoutMs:r.batchTimeoutMs??3e4,flushRequestsImmediately:r.flushRequestsImmediately??!1,maxMessageSize:r.maxMessageSize??QS,maxStreamSize:r.maxStreamSize??ZS,disableDuplex:r.disableDuplex??!1}),hn(this,Pu,r.onConnect??(()=>{})),hn(this,xu,{enableCompression:s.enableCompression??Cp(),gzip:s.gzip??(a=>hu(lu(a))),gunzip:s.gunzip??kp}),hn(this,Wu,n??Fv)}afterConfig(){const e=new JS(this.t,this.tAttrs,this.signals,this.handlers,Ue(this,xu),{write:ot(this,Xe,ry).bind(this),maxMessageSize:Ue(this,ls).maxMessageSize,maxStreamSize:Ue(this,ls).maxStreamSize},Ue(this,Wu),void 0,this.downstreamRelationship),r=new dv({maxSizeInBytes:Ue(this,ls).batchMaxSizeInBytes,windowMs:Ue(this,ls).batchWindowMs,timeoutMs:Ue(this,ls).batchTimeoutMs,disableDuplex:Ue(this,ls).disableDuplex},{prepareContext:vr(()=>{const s=Ge(),n=Ge();return s.catch(()=>{}),n.catch(()=>{}),{requests:[],streams:[],requestOpened:s,liveness:n}},"prepareContext"),openRequest:ot(this,Xe,ty).bind(this)},{onBatchError:vr((s,n)=>{this.t.log.warn("wire_http_client.request_failed",{err:n}),this.t.record.wireHttpRequestErrorCount(1,this.tAttrs)},"onBatchError")});hn(this,xs,e),hn(this,tl,r)}dispatch(e,r,s,...n){const[i,a,c]=ot(this,Xe,gm).call(this,n);if(i==="beacon"){if(e.type==="event")return ot(this,Xe,_m).call(this,r,e,e.encodeRequest(r,s),c);throw new Error("[direct.dev/wire/channel] Only WireEventSignals can be dispatched as beacons")}const h=ot(this,Xe,wm).call(this,c,i==="pipeline"?a:void 0);try{const u=Ue(this,xs).dispatch(r,e,s,void 0,h);return ot(this,Xe,vm).call(this,u,a),u}catch(u){throw a&&ot(this,Xe,rl).call(this,a,u),u}}dispatchRaw(e,r,s,...n){const[i,a,c]=ot(this,Xe,gm).call(this,n);if(i==="beacon"){if(e.type==="event")return ot(this,Xe,_m).call(this,r,e,s,c);throw new Error("[direct.dev/wire/channel] Only WireEventSignals can be dispatched as beacons")}const h=ot(this,Xe,wm).call(this,c,i==="pipeline"?a:void 0);try{const u=Ue(this,xs).dispatchRaw(r,e,s,void 0,h);return ot(this,Xe,vm).call(this,u,a),u}catch(u){throw a&&ot(this,Xe,rl).call(this,a,u),u}}},o(To,"I"),To);ls=new WeakMap,ua=new WeakMap,Pu=new WeakMap,xu=new WeakMap,Wu=new WeakMap,el=new WeakMap,xs=new WeakMap,tl=new WeakMap,Xe=new WeakSet,gm=vr(function(t){const e=t[0];return e==="pipeline"?["pipeline",t[1],t[2]]:e==="fetch"?["fetch",void 0,t[1]]:e==="beacon"?["beacon",void 0,t[1]]:[void 0,void 0,e]},"#parseDispatchArgs"),wm=vr(function(t,e){return e?{fetchCtx:t,pipelineProof:e}:{fetchCtx:t}},"#makeWriteContext"),vm=vr(function(t,e){!e||!t||typeof t.then!="function"||t.then(void 0,r=>{ot(this,Xe,rl).call(this,e,r)})},"#rejectPipelineProofOnAsyncFailure"),rl=vr(function(t,e){t.__state()==="pending"&&t.__reject(e).catch(()=>{})},"#rejectPipelineProof"),ey=vr(function(t,e){return e?(t.liveness.then(()=>{e.__state()==="pending"&&e.__resolve().catch(()=>{})},r=>ot(this,Xe,rl).call(this,e,r)),!0):!1},"#attachPipelineProof"),ty=vr(function(t,e,r,s){try{const n=Ue(this,el).call(this,r.fetchCtx);Ue(this,Pu).call(this);const i=n(Ue(this,ua).call(this),{method:"POST",headers:sy,signal:s,...t});i.then(c=>e.liveness.__resolve(c),c=>e.liveness.__reject(c).catch(()=>{}));const a=i.then(c=>{if(!c.ok)throw new Error(`[direct.dev/wire/channel] HTTP ${c.status}: ${c.statusText}`);if(!c.body)throw new Error("[direct.dev/wire/channel] received response without body");return Ue(this,xs).processIngress(this.t,c.body,this.mode).then(h=>Promise.allSettled(h).then(()=>{}))});return e.requestOpened.__isFulfilled()||e.requestOpened.__resolve(),a.then(()=>{Ue(this,xs).terminateBatch(e.requests,e.streams)}).catch(c=>{Ue(this,xs).terminateBatch(e.requests,e.streams,c)}),a}catch(n){throw e.requestOpened.__state()==="pending"&&e.requestOpened.__reject(n).catch(()=>{}),n}},"#openRequest"),ry=vr(function(t,e,r,s,n){const i=Ue(this,tl).write(r,n,s);if(!i)return Promise.reject(new Error("[direct.dev/wire/channel] WireHTTPClient.#writeToBatch() failed to open batch"));const[a,c]=i;return e!==void 0&&(t instanceof Zv?c.requests.push({signalId:t.id,messageId:e}):t instanceof eu&&c.streams.push({signalId:t.id,messageId:e}),(t instanceof Zv||t instanceof eu)&&ot(this,Xe,ey).call(this,c,n==null?void 0:n.pipelineProof)&&Ue(this,ls).flushRequestsImmediately&&Ue(this,tl).flush(n).catch(()=>{})),e===void 0?Promise.race([c.requestOpened,a]):a},"#writeToBatch"),_m=vr(async function(t,e,r,s){const n=await Ue(this,xs).encodeFrame(r);if(typeof navigator>"u"||typeof navigator.sendBeacon!="function")return ot(this,Xe,Uu).call(this,t,e,n,s);try{const i=new Blob([n],{type:"text/plain"});if(!navigator.sendBeacon(Ue(this,ua).call(this),i))return ot(this,Xe,Uu).call(this,t,e,n,s);this.t.record.wireHttpBeaconCount(1,"result:ok transport:beacon",this.tAttrs)}catch(i){return t.log.info("wire_http_client.send_beacon_failed",{err:i}),t.record.wireHttpBeaconCount(1,"result:error transport:beacon",this.tAttrs),ot(this,Xe,Uu).call(this,t,e,n,s)}},"#sendBeacon"),Uu=vr(async function(t,e,r,s){try{const n=await Ue(this,el).call(this,s)(Ue(this,ua).call(this),{method:"POST",headers:sy,body:r});if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);t.record.wireHttpBeaconCount(1,"result:ok transport:fetch",this.tAttrs)}catch(n){t.log.info("wire_http_client.send_beacon_fallback_failed",{err:n}),t.record.wireHttpBeaconCount(1,"result:error transport:fetch",this.tAttrs)}},"#sendBeaconFallback"),vr(ny,"WireHTTPClient");let iy=ny;var eA=Object.defineProperty,ay=o(t=>{throw TypeError(t)},"D$a"),sl=o((t,e)=>eA(t,"name",{value:e,configurable:!0}),"m$l"),ym=o((t,e,r)=>e.has(t)||ay("Cannot "+r),"b$f"),un=o((t,e,r)=>(ym(t,e,"read from private field"),r?r.call(t):e.get(t)),"l$q"),da=o((t,e,r)=>e.has(t)?ay("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"h$j"),nl=o((t,e,r,s)=>(ym(t,e,"write to private field"),e.set(t,r),r),"_$d"),oy=o((t,e,r)=>(ym(t,e,"access private method"),r),"C$a"),il,al,Du,Ou,ol,ju,cy,ly;const tA=2*1024*1024,rA="Direct-Preload-Checksum",sA="Direct-Preload-Ntp-T2",nA="Direct-Preload-Ntp-T3";function hy(t,e){const r=t.req.encode(e),s=`${t.id}:${t.version}:${t.name}:${r}`;return uw(s)}o(hy,"L$b"),sl(hy,"computePreloadChecksum");const uy=(Ro=class{constructor(e,r,s){da(this,ju),da(this,il),da(this,al),da(this,Du),da(this,Ou),da(this,ol),nl(this,il,e),nl(this,al,hy(e,r)),nl(this,Du,(s==null?void 0:s.fetchFn)??globalThis.fetch.bind(globalThis)),nl(this,ol,(s==null?void 0:s.maxMessageSize)??tA),nl(this,Ou,new J_({enableCompression:!0,gzip:sl(n=>hu(lu(n)),"gzip"),gunzip:kp},un(this,ol)))}dispatch(e,r,s,n){const i=new AbortController;s==null||s.addEventListener("abort",()=>i.abort(),{once:!0}),s!=null&&s.aborted&&i.abort();const a=new Cs({onEarlyDisposal(){i.abort()},onBackpressure(){i.abort()}});return oy(this,ju,cy).call(this,e,r,i.signal,a,n).finally(()=>{a.isClosed||a.close(null)}).catch(()=>{}),a}},o(Ro,"y"),Ro);il=new WeakMap,al=new WeakMap,Du=new WeakMap,Ou=new WeakMap,ol=new WeakMap,ju=new WeakSet,cy=sl(async function(t,e,r,s,n){var i,a;const c=un(this,il);if(!Cp()){t.trace.addEvent("preload_compression_unsupported"),t.trace.addEvent("preload_stream_skipped"),t.record.wireSignalResultCount(1,"type:stream result:skipped",c.tAttrs);return}if(!r.aborted){t.trace.addEvent("preload_fetch_start",{url:e});try{const h=y(),u=await un(this,Du).call(this,e,{method:"GET",signal:r,credentials:"same-origin",cache:"no-store"});if(!u.ok){t.trace.addEvent("preload_fetch_failed",{status:u.status}),t.trace.addEvent("preload_stream_skipped"),t.record.wireSignalResultCount(1,"type:stream result:skipped",c.tAttrs);return}const d=u.headers.get(rA);if(d!==un(this,al)){t.trace.addEvent("preload_checksum_mismatch",{expected:un(this,al),received:d??"(missing)"}),t.trace.addEvent("preload_stream_skipped"),t.record.wireSignalResultCount(1,"type:stream result:skipped",c.tAttrs);return}if(!u.body){t.trace.addEvent("preload_missing_body"),t.trace.addEvent("preload_stream_skipped"),t.record.wireSignalResultCount(1,"type:stream result:skipped",c.tAttrs);return}return(i=n==null?void 0:n.onValidatedResponse)==null||i.call(n,u,h),t.trace.addEvent("preload_stream_attached"),(a=n==null?void 0:n.onAttached)==null||a.call(n),oy(this,ju,ly).call(this,t,u.body,h,r,s)}catch(h){if(h instanceof Error&&h.name==="AbortError")return;t.trace.addEvent("preload_fetch_error",{err:String(h)}),t.trace.addEvent("preload_stream_skipped"),t.record.wireSignalResultCount(1,"type:stream result:skipped",c.tAttrs);return}}},"#fetchStream"),ly=sl(async function(t,e,r,s,n){const i=un(this,Ou),a=un(this,il);let c=0;const h=e.getReader();if(s.addEventListener("abort",()=>h.cancel().catch(()=>{}),{once:!0}),s.aborted){h.cancel().catch(()=>{});return}const u={arr:void 0,length:0};try{for(;;){const{value:d,done:p}=await h.read();if(p||s.aborted)break;if(u.length===0)u.arr=d.slice(),u.length=d.length;else{if(u.length+d.length>u.arr.length){const f=new Uint8Array(Math.max(u.arr.length*2,u.length+d.length));f.set(u.arr),u.arr=f}u.arr.set(d,u.length),u.length+=d.length}for(;u.length>0;){const f=await i.decode(u);if(f==null)break;n.push(a.res.decodeUntrusted(f,0,un(this,ol))),c++}}t.trace.addEvent("preload_stream_end",{segments:c}),t.record.wireSignalResultCount(1,"type:stream result:ok",a.tAttrs),t.record.wireSignalStreamLifetimeMs(y()-r,"result:ok",a.tAttrs)}catch(d){t.trace.addEvent("preload_stream_error",{err:String(d)}),t.record.wireSignalResultCount(1,"type:stream result:error",a.tAttrs),t.record.wireSignalStreamLifetimeMs(y()-r,"result:error",a.tAttrs),n.isClosed||n.throw(d instanceof Error?d:new Error(String(d)))}},"#decodeStream"),sl(uy,"WirePreloadClient");let iA=uy;const Ur=l.union(l.literal("latest","pending","safe","finalized","earliest"),l.blockHeight),bm=ke("rpc_request",l.taggedUnion("method",[["eth_accounts",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_blockNumber",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_call",{id:l.rpcRequestId,params:l.tuple([l.shape({to:l.str,from:l.str.optional.nullable,data:l.str.optional.nullable,input:l.str.optional.nullable,value:l.str.optional.nullable,gas:l.str.optional.nullable,gasPrice:l.str.optional.nullable}),Ur])}],["eth_chainId",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_coinbase",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_estimateGas",{id:l.rpcRequestId,params:l.tuple([l.shape({to:l.str,from:l.str.optional.nullable,data:l.str.optional.nullable,input:l.str.optional.nullable,value:l.str.optional.nullable,gas:l.str.optional.nullable,gasPrice:l.str.optional.nullable}),Ur])}],["eth_gasPrice",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_getBalance",{id:l.rpcRequestId,params:l.tuple([l.str,Ur])}],["eth_getBlockByHash",{id:l.rpcRequestId,params:l.tuple([l.str,l.bool])}],["eth_getBlockByNumber",{id:l.rpcRequestId,params:l.tuple([Ur,l.bool])}],["eth_getBlockTransactionCountByHash",{id:l.rpcRequestId,params:l.tuple([l.str])}],["eth_getBlockTransactionCountByNumber",{id:l.rpcRequestId,params:l.tuple([Ur])}],["eth_getCode",{id:l.rpcRequestId,params:l.tuple([l.str,Ur])}],["eth_getFilterChanges",{id:l.rpcRequestId,params:l.tuple([l.str])}],["eth_getFilterLogs",{id:l.rpcRequestId,params:l.tuple([l.str])}],["eth_getLogs",{id:l.rpcRequestId,params:l.tuple([l.shape({fromBlock:l.str.optional.nullable,toBlock:l.str.optional.nullable,address:l.unknown,topics:l.unknown,blockhash:l.str.optional.nullable})])}],["eth_getStorageAt",{id:l.rpcRequestId,params:l.tuple([l.str,Ur])}],["eth_getTransactionByBlockHashAndIndex",{id:l.rpcRequestId,params:l.tuple([l.str,l.str])}],["eth_getTransactionByBlockNumberAndIndex",{id:l.rpcRequestId,params:l.tuple([Ur,l.str])}],["eth_getTransactionByHash",{id:l.rpcRequestId,params:l.tuple([l.str])}],["eth_getTransactionCount",{id:l.rpcRequestId,params:l.tuple([l.str,Ur])}],["eth_getTransactionReceipt",{id:l.rpcRequestId,params:l.tuple([l.str])}],["direct_getTransactionReceipt",{id:l.rpcRequestId,params:l.union(l.tuple([l.str]),l.tuple([l.str,l.shape({retry:l.bool})]))}],["eth_getUncleByBlockHashAndIndex",{id:l.rpcRequestId,params:l.tuple([l.str,l.str])}],["eth_getUncleByBlockNumberAndIndex",{id:l.rpcRequestId,params:l.tuple([Ur,l.str])}],["eth_getUncleCountByBlockHash",{id:l.rpcRequestId,params:l.tuple([l.str])}],["eth_getUncleCountByBlockNumber",{id:l.rpcRequestId,params:l.tuple([Ur])}],["eth_hashrate",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_mining",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_newBlockFilter",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_newFilter",{id:l.rpcRequestId,params:l.tuple([l.shape({fromBlock:l.str.optional.nullable,toBlock:l.str.optional.nullable,address:l.unknown,topics:l.unknown})])}],["eth_newPendingTransactionFilter",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_protocolVersion",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_sendTransaction",{id:l.rpcRequestId,params:l.tuple([l.shape({from:l.str,to:l.str.optional.nullable,gas:l.str.optional.nullable,gasPrice:l.str.optional.nullable,value:l.str.optional.nullable,data:l.str,nonce:l.str.optional.nullable})])}],["eth_sendRawTransaction",{id:l.rpcRequestId,params:l.tuple([l.str])}],["eth_sign",{id:l.rpcRequestId,params:l.tuple([l.str,l.str])}],["eth_signTransaction",{id:l.rpcRequestId,params:l.tuple([l.shape({type:l.unknown,from:l.str,to:l.str.optional.nullable,gas:l.str.optional.nullable,gasPrice:l.str.optional.nullable,value:l.str.optional.nullable,data:l.str,nonce:l.str.optional.nullable})])}],["eth_syncing",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_uninstallFilter",{id:l.rpcRequestId,params:l.tuple([l.str])}],["net_listening",{id:l.rpcRequestId,params:l.tuple([]).optional}],["net_peerCount",{id:l.rpcRequestId,params:l.tuple([]).optional}],["net_version",{id:l.rpcRequestId,params:l.tuple([]).optional}],["web3_clientVersion",{id:l.rpcRequestId,params:l.tuple([]).optional}],["web3_sha3",{id:l.rpcRequestId,params:l.tuple([l.str])}]],{method:l.str,id:l.rpcRequestId,params:l.unknown},{ignoredProps:["jsonrpc"]})),cl=ke("rpc_response",l.union(l.shape({id:l.rpcResponseId,result:l.str,expiresAt:l.timestamp.optional},{ignoredProps:["jsonrpc"]}),l.shape({id:l.rpcResponseId,result:l.unknown,expiresAt:l.timestamp.optional},{ignoredProps:["jsonrpc"]}),l.shape({id:l.rpcResponseId,error:l.shape({code:l.num,message:l.str,data:l.unknown.optional})},{ignoredProps:["jsonrpc","expiresAt"]}))),aA=l.shape({requestMethod:l.requestMethod,requestId:l.requestIdentifier("without-checksum"),requestSizeInBytes:l.uint32,perBlockMetrics:l.record(l.union(l.blockDigest,l.literal("__unknown__")),l.shape({blockHeight:l.blockHeight.optional,responseSizeInBytes:l.uint32,responseKey:l.responseKey,timestamp:l.timestamp,latencyMs:l.arr(l.uint32)}))}),$m=l.strWithDict("inflight_cache","memory_cache","direct","configured_failover","public_failover"),oA=l.shape({headers:l.shape({upload:l.uint32,download:l.uint32}),payload:l.record(l.literal("direct","failover"),l.record($m,l.record(l.literal("upload","download"),l.uint32)))}),cA=ke("telemetry",l.shape({networkId:l.networkId,cacheHits:l.record($m,l.arr(aA)),upstreamResponseTimesMs:l.record($m,l.arr(l.uint32)),bandwidthEstimate:oA}));var lA=Object.defineProperty,Nu=o((t,e)=>lA(t,"name",{value:e,configurable:!0}),"c$q");const Lu=(()=>{if(typeof crypto<"u"){const t=new Uint8Array(16);return()=>(crypto.getRandomValues(t),t.slice())}try{const{randomBytes:t}=require("node:crypto");return()=>new Uint8Array(t(16))}catch{return()=>{throw new Error("Secure random generation unavailable in this environment")}}})();function hA(t){return ye===void 0&&(ye=Array.from({length:256},(e,r)=>r.toString(16).padStart(2,"0"))),ye[t[0]]+ye[t[1]]+ye[t[2]]+ye[t[3]]+ye[t[4]]+ye[t[5]]+ye[t[6]]+ye[t[7]]+ye[t[8]]+ye[t[9]]+ye[t[10]]+ye[t[11]]+ye[t[12]]+ye[t[13]]+ye[t[14]]+ye[t[15]]}o(hA,"u$m"),Nu(hA,"traceIdToHex");function dy(t){return be===void 0&&(be=Object.fromEntries(Array.from({length:256},(e,r)=>[r.toString(16).padStart(2,"0"),r]))),new Uint8Array([be[t.slice(0,2)],be[t.slice(2,4)],be[t.slice(4,6)],be[t.slice(6,8)],be[t.slice(8,10)],be[t.slice(10,12)],be[t.slice(12,14)],be[t.slice(14,16)],be[t.slice(16,18)],be[t.slice(18,20)],be[t.slice(20,22)],be[t.slice(22,24)],be[t.slice(24,26)],be[t.slice(26,28)],be[t.slice(28,30)],be[t.slice(30,32)]])}o(dy,"f$j"),Nu(dy,"traceIdFromHex");const km=(()=>{if(typeof crypto<"u"){const t=new Uint8Array(8);return()=>(crypto.getRandomValues(t),t.slice())}try{const{randomBytes:t}=require("node:crypto");return()=>new Uint8Array(t(8))}catch{return()=>{throw new Error("Secure random generation unavailable in this environment")}}})();function uA(t){return ye===void 0&&(ye=Array.from({length:256},(e,r)=>r.toString(16).padStart(2,"0"))),ye[t[0]]+ye[t[1]]+ye[t[2]]+ye[t[3]]+ye[t[4]]+ye[t[5]]+ye[t[6]]+ye[t[7]]}o(uA,"m$k"),Nu(uA,"spanIdToHex");function fy(t){return be===void 0&&(be=Object.fromEntries(Array.from({length:256},(e,r)=>[r.toString(16).padStart(2,"0"),r]))),new Uint8Array([be[t.slice(0,2)],be[t.slice(2,4)],be[t.slice(4,6)],be[t.slice(6,8)],be[t.slice(8,10)],be[t.slice(10,12)],be[t.slice(12,14)],be[t.slice(14,16)]])}o(fy,"g$e"),Nu(fy,"spanIdFromHex");let ye,be;var dA=Object.defineProperty,fA=o((t,e)=>dA(t,"name",{value:e,configurable:!0}),"b$e");const py=(Bo=class{},o(Bo,"c"),Bo);fA(py,"PulseExporter");let pA=py;const Fu={verbose:10,debug:20,info:30,warn:40,error:50,fatal:60,silent:70};var mA=Object.defineProperty,fa=o((t,e)=>mA(t,"name",{value:e,configurable:!0}),"r$g");const my=(Io=class{constructor(e,r=null,s=null){this.labels=r,this.attrs=s,this.type=e,this.record=wA}name="";unit="";type;record;flush(){return{collected:[],dropped:void 0}}},o(Io,"u"),Io);fa(my,"BaseInstrument");let zu=my;const gy=(qo=class extends zu{constructor(e,r){super("counter",e,r)}},o(qo,"n"),qo);fa(gy,"BaseCounter");let Q=gy;const wy=(Po=class extends zu{constructor(e,r){super("up_down_counter",e,r)}},o(Po,"p"),Po);fa(wy,"BaseUpDownCounter");let vy=wy;const gA=(xo=class extends zu{constructor(e,r){super("gauge",e,r)}},o(xo,"h"),xo);fa(gA,"BaseGauge");const _y=(Wo=class extends zu{constructor(e,r){super("histogram",e,r)}},o(Wo,"i"),Wo);fa(_y,"BaseHistogram");let Dr=_y;const wA=fa((()=>{}),"baseRecord");var vA=Object.defineProperty,_A=o((t,e)=>vA(t,"name",{value:e,configurable:!0}),"n$k");function yy(){return{flushDurationMs:new Dr,metricsDecisionCount:new Q(["decision:included","decision:dropped"]),logDecisionCount:new Q(["decision:included","decision:not_sampled","decision:below_log_level"]),traceDecisionCount:new Q(["decision:included","decision:not_sampled"])}}o(yy,"t$5"),_A(yy,"makePulseMetaInstruments");var yA=Object.defineProperty,bA=o((t,e)=>yA(t,"name",{value:e,configurable:!0}),"c$o");function by(t,e){var r;const s=t.trim().split(/\s+/).filter(Boolean),n={},i={wildcard:"silent",origin:void 0};for(const h of s){const u=h.split(":"),d=$A.parse(u.at(-1));switch(u[0]){case"*":{if(u.length!==2)throw new Error(`parseLogLevel: invalid token "${h}"`);i.wildcard=d;break}case"origin":{if(u.length!==3)throw new Error(`parseLogLevel: invalid token "${h}"`);u[1]&&e.startsWith(u[1])&&(!i.origin||u[1].length>=i.origin.specificity)&&(i.origin={specificity:u[1].length,level:d});break}case"trace":{if(u.length!==3)throw new Error(`parseLogLevel: invalid token "${h}"`);n[u[1]]=d;break}default:throw new Error(`parseLogLevel: invalid token "${h}"`)}}const a=((r=i.origin)==null?void 0:r.level)??i.wildcard,c=Fu[a];return{default:a,byTrace:Object.fromEntries(Object.entries(n).filter(([,h])=>Fu[h]>c))}}o(by,"h$h"),bA(by,"parseLogLevel");const $A=ke("logLevel",l.literal("verbose","debug","info","warn","error","fatal","silent"));var kA=Object.defineProperty,Cm=o((t,e)=>kA(t,"name",{value:e,configurable:!0}),"l$m");function $y(t,e){var r;const s=t.trim().split(/\s+/).filter(Boolean),n={},i={},a={wildcard:0,origin:void 0};for(const u of s){const d=u.split(":"),p=ky(d.at(-1)??"");switch(d[0]){case"*":{if(d.length!==2)throw new Error(`parseLogSampling: invalid token "${u}"`);a.wildcard=p;break}case"origin":{if(d.length!==3)throw new Error(`parseLogSampling: invalid token "${u}"`);d[1]&&e.startsWith(d[1])&&(!a.origin||d[1].length>=a.origin.specificity)&&(a.origin={specificity:d[1].length,factor:p});break}case"trace":{if(d.length!==3)throw new Error(`parseLogSampling: invalid token "${u}"`);n[d[1]]=p;break}case"level":{if(d.length!==3)throw new Error(`parseLogSampling: invalid token "${u}"`);i[CA.parse(d[1])]=p;break}default:throw new Error(`parseLogSampling: invalid token "${u}"`)}}const c=((r=a.origin)==null?void 0:r.factor)??a.wildcard,h=Cm(u=>{const d=i[u]!=null?Math.max(c,i[u]):c;return{default:d,byTrace:Object.fromEntries(Object.entries(n).filter(([,p])=>p>d))}},"parseByLevel");return{verbose:h("verbose"),debug:h("debug"),info:h("info"),warn:h("warn"),error:h("error"),fatal:h("fatal")}}o($y,"h$g"),Cm($y,"parseLogSampling");function ky(t){const e=parseFloat(t);if(Number.isNaN(e)||e<0||e>1)throw new Error(`parseFactor: invalid factor "${t}"`);return e*4294967295>>>0}o(ky,"m$j"),Cm(ky,"parseFactor");const CA=ke("logSampling",l.literal("verbose","debug","info","warn","error","fatal"));var SA=Object.defineProperty,Cy=o((t,e)=>SA(t,"name",{value:e,configurable:!0}),"o$e");function Sy(t,e){var r;const s=t.trim().split(/\s+/).filter(Boolean),n={},i={wildcard:0,origin:void 0};for(const a of s){const c=a.split(":"),h=Ay(c.at(-1)??"");switch(c[0]){case"*":{if(c.length!==2)throw new Error(`parseTraceSampling: invalid token "${a}"`);i.wildcard=h;break}case"origin":{if(c.length!==3)throw new Error(`parseTraceSampling: invalid token "${a}"`);c[1]&&e.startsWith(c[1])&&(!i.origin||c[1].length>=i.origin.specificity)&&(i.origin={specificity:c[1].length,factor:h});break}case"event":{if(c.length!==3)throw new Error(`parseTraceSampling: invalid token "${a}"`);n[c[1]]=h;break}default:throw new Error(`parseTraceSampling: invalid token "${a}"`)}}return{default:((r=i.origin)==null?void 0:r.factor)??i.wildcard,byEvent:n}}o(Sy,"p$h"),Cy(Sy,"parseTraceSampling");function Ay(t){const e=parseFloat(t);if(Number.isNaN(e)||e<0||e>1)throw new Error(`parseFactor: invalid factor "${t}"`);return e*4294967295>>>0}o(Ay,"g$c"),Cy(Ay,"parseFactor");var AA=Object.defineProperty,EA=o((t,e)=>AA(t,"name",{value:e,configurable:!0}),"r$f");function Sm(t){if(t instanceof Error)return t.stack?`${String(t)}
4
- ${t.stack}`:String(t);if(typeof t=="symbol")return String(t);if(t!=null&&typeof t=="object")try{const e=JSON.stringify(t);return e==="{}"?String(t):e}catch{return String(t)}return String(t)}o(Sm,"f$h"),EA(Sm,"stringifyAttribute");var Ey=Object.defineProperty,My=o(t=>{throw TypeError(t)},"ce$1"),MA=o((t,e,r)=>e in t?Ey(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"ye$1"),At=o((t,e)=>Ey(t,"name",{value:e,configurable:!0}),"b$d"),pa=o((t,e,r)=>MA(t,typeof e!="symbol"?e+"":e,r),"M$a"),Ty=o((t,e,r)=>e.has(t)||My("Cannot "+r),"le$1"),le=o((t,e,r)=>(Ty(t,e,"read from private field"),r?r.call(t):e.get(t)),"n$j"),dn=o((t,e,r)=>e.has(t)?My("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"N$7"),Or=o((t,e,r,s)=>(Ty(t,e,"write to private field"),e.set(t,r),r),"C$9"),ll,jr,ma,_r,hl,fn,ga,ul;const dl=Symbol("errorCode"),Hu=Symbol("message"),wa=Symbol("attributes"),ii=Symbol("events"),fl=Symbol("waitUntil"),G=Symbol("span"),pt=Symbol("ctx"),TA=Object.freeze({setError(t,e){this[dl]=t,this[Hu]=e},setAttributes(t){const e=this[wa];for(const r in t)e[r]=t[r]},addEvent(t,e){this[ii]??=[],this[ii].push({timeStamp:Date.now(),name:t,attributes:e})},waitUntil(t){this[fl]??=[],this[fl].push(t)},fromRequestHeaders(t){const e=BA.exec(String(t.get("traceparent")??"")),r=t.get("x-direct-tracename");if(!e||!r||typeof r!="string")return;const[,,s,n,i]=e;return{traceId:dy(s),traceName:r,traceSampled:(parseInt(i,16)&1)===1,spanId:fy(n)}},toRequestHeaders(){if(this[G])return{traceparent:`00-${this[G].traceId}-${this[G].spanId}-${this[G].traceSampled?"01":"00"}`,"x-direct-tracename":this[G].traceName}},exportTraceParent(){if(this[G])return this[G]}}),Ry={[G]:{value:void 0,writable:!0,enumerable:!1,configurable:!0},[pt]:{value:void 0,writable:!0,enumerable:!1,configurable:!0},[dl]:{value:void 0,writable:!0,configurable:!0},[Hu]:{value:void 0,writable:!0,configurable:!0},[wa]:{value:{},writable:!0,configurable:!0},[ii]:{value:void 0,writable:!0,configurable:!0},[fl]:{value:void 0,writable:!0,configurable:!0}},RA={[G]:{value:void 0,writable:!0,enumerable:!1,configurable:!0},[pt]:{value:void 0,writable:!0,enumerable:!1,configurable:!0}};function By(t,e,r,s,n){let i=Math.random()*4294967295|0;const a=At(()=>(i^=i<<13,i^=i>>>17,i^=i<<5,i>>>0),"rng"),c=At((b,D)=>b==null?D:b===4294967295?!0:b===0?!1:a()<b,"computeSampling"),h=Dy(e,t),u=TA,d=Am(e,h,s,n,a),p=Py(r),f=12,g=new Array(f);let m=0;const w=At(()=>{if(m>0){const b=g[--m];return b?(b[G]=void 0,b[pt]=void 0,b.trace[G]=void 0,b.trace[pt]=void 0,b.trace[dl]=void 0,b.trace[Hu]=void 0,b.trace[ii]=void 0,b.trace[fl]=void 0,b.trace[wa]={},b.log[G]=void 0,b.log[pt]=void 0,b.record[G]=void 0,b):void 0}},"acquirePulseFromPool"),_=At(b=>{m<f&&(g[m++]=b)},"releasePulseToPool"),S=Object.create(null,{trace:{writable:!0,value:Object.create(u,Ry)},log:{writable:!0,value:Object.create(d,xy)},record:{writable:!0,value:Object.create(p,qy)},with:{writable:!1,value:At(function(b,D){let O=w();const x=D??this[G];let K;if(!b)K=this[pt];else{K=Object.create(this[pt]??null);for(const Pe in b)K[Pe]=b[Pe]}O?(O[G]=x,O[pt]=K,O.trace[G]=x,O.trace[pt]=K,O.record[G]=x):(O=Object.create(S),O[G]=x,O[pt]=K,O.trace=Object.create(u,Ry),O.trace[G]=x,O.trace[pt]=K,O.record=Object.create(p,qy),O.record[G]=x);let I;return!(D&&!this[G])||!h.__logOverridesByTrace.has(D.traceName)?I=this.log:(I=h.__logCache.get(D.traceName),I||(I=Am(e,h,s,n,a,D),h.__logCache.set(D.traceName,I))),O.log=Object.create(I,xy),O.log[G]=x,O.log[pt]=K,O},"withFnc")},runInContext:{writable:!1,value:At(async function(b,D){const O=this.with(b);try{return await D(O)}catch(x){throw O.log.error("runInContext intercepted exception",{err:x}),x}},"runInContext")},runSpan:{writable:!1,value:At(async function(b,D,O){const x=y(),K=(b.parent&&b.parent instanceof Headers?this.trace.fromRequestHeaders(b.parent):b.parent)??this.trace.exportTraceParent(),I=(()=>{if((K==null?void 0:K.spanId)==null){const Ke=h.traceSampling.byEvent[D.event]??h.traceSampling.default;return{traceId:Lu(),traceName:D.event,traceSampled:c(Ke,!1),parentSpanId:void 0,parentLink:void 0,spanId:km(),spanKind:b.kind}}const Se=h.traceSampling.byEvent[D.event];return b.parentRelationship!=="link"?{traceId:K.traceId,traceName:K.traceName,traceSampled:c(Se,K.traceSampled),parentLink:void 0,parentSpanId:K.spanId,spanId:km(),spanKind:b.kind}:{traceId:Lu(),traceName:K.traceName,traceSampled:c(Se,K.traceSampled),parentSpanId:void 0,parentLink:K,spanId:km(),spanKind:b.kind}})();s.traceDecisionCount.record(I,1,I.traceSampled?"decision:included":"decision:not_sampled");let Pe=!1;const Oe=this.with(D,I);try{try{return await O(Oe)}finally{const Se=Oe.trace[fl];Se&&await Promise.allSettled(Se)}}catch(Se){Pe=!0;const Ke=y(),Nt=Oe.trace;if(Nt[dl]==null){const Lt=Nt[wa]??Iy,ir=Nt[ii];let Xr;I.traceSampled?Xr=I:(yr.traceId=Lu(),yr.traceName=I.traceName,yr.spanId=I.spanId,yr.spanKind=I.spanKind,I.parentSpanId&&(yr.parentLink=pn,pn.traceId=I.traceId,pn.traceName=I.traceName,pn.spanId=I.parentSpanId),Xr=yr),xt.startTimestamp=x,xt.endTimestamp=Ke,xt.success=!1,xt.message=Sm(Se),Lt.error_code="UNCAUGHT",n.trace(Xr,D,Lt,ir,{startTimestamp:x,endTimestamp:Ke,success:!1,message:Sm(Se)})}else Oe.log.error("An uncaught exception was thrown",{err:Se});throw Se}finally{_(Oe);const Se=y(),Ke=Oe.trace,Nt=Ke[dl];if(Nt!=null){const Lt=Ke[wa]??Iy,ir=Ke[ii],Xr=Ke[Hu];let Qr;I.traceSampled?Qr=I:(yr.traceId=Lu(),yr.traceName=I.traceName,yr.spanId=I.spanId,yr.spanKind=I.spanKind,I.parentSpanId&&(yr.parentLink=pn,pn.traceId=I.traceId,pn.traceName=I.traceName,pn.spanId=I.parentSpanId),Qr=yr),xt.startTimestamp=x,xt.endTimestamp=Se,xt.success=!1,xt.message=Xr,Lt.error_code=Nt,n.trace(Qr,D,Lt,ir,xt)}else if(!Pe&&I.traceSampled){const Lt=Ke[wa],ir=Ke[ii];xt.startTimestamp=x,xt.endTimestamp=Se,xt.success=!0,xt.message=void 0,n.trace(I,D,Lt,ir,xt)}}},"runSpan")}});return Object.create(S,RA)}o(By,"he"),At(By,"makePulseAPITemplate");const yr={traceSampled:!0,parentSpanId:void 0},pn={},xt={startTimestamp:0,endTimestamp:0,success:!0,message:void 0},Iy={},qy={[G]:{value:void 0,writable:!0,enumerable:!1,configurable:!0}};function Py(t){const e=Object.create(null);e[G]=void 0;for(const[r,s]of Object.entries(t))e[r]=function(...n){s.record(this[G],...n)};return Object.freeze(e)}o(Py,"xe$1"),At(Py,"makePulseMetricsProto");const xy={[G]:{value:void 0,writable:!0,enumerable:!1,configurable:!0},[pt]:{value:void 0,writable:!0,enumerable:!1,configurable:!0}};function Am(t,e,r,s,n,i){const{logRedactor:a}=t,c=At(h=>{const u=i?e.logLevel.byTrace[i.traceName]??e.logLevel.default:e.logLevel.default,d=i?e.logSampling[h].byTrace[i.traceName]??e.logSampling[h].default:e.logSampling[h].default,p=!!(i!=null&&i.traceSampled),f=d===1||p,g=d===0&&!p;return Fu[h]<Fu[u]?At(function(){r.logDecisionCount.record(this[G],1,"decision:below_log_level")},"noop"):g?At(function(){r.logDecisionCount.record(this[G],1,"decision:not_sampled")},"noop"):f?a?function(m,w){s.log(h,y(),m,this[G],this[pt],w?a(typeof w=="function"?w():w):void 0),r.logDecisionCount.record(this[G],1,"decision:included")}:function(m,w){s.log(h,y(),m,this[G],this[pt],w?typeof w=="function"?w():w:void 0),r.logDecisionCount.record(this[G],1,"decision:included")}:a?function(m,w){if(n()>=d){r.logDecisionCount.record(this[G],1,"decision:not_sampled");return}s.log(h,y(),m,this[G],this[pt],w?a(typeof w=="function"?w():w):void 0),r.logDecisionCount.record(this[G],1,"decision:included")}:function(m,w){n()>=d||(s.log(h,y(),m,this[G],this[pt],w?typeof w=="function"?w():w:void 0),r.logDecisionCount.record(this[G],1,"decision:included"))}},"makeLogWriter");return Object.freeze({verbose:c("verbose"),debug:c("debug"),info:c("info"),warn:c("warn"),error:c("error"),fatal:c("fatal")})}o(Am,"be$1"),At(Am,"makePulseLogProto");const Wy=new gc(50),Uy=50;function Dy(t,e){const r=t.logLevel+"|"+t.logSamples+"|"+t.traceSamples+"|"+e,s=Wy.get(r);if(s)return s;const n=by(t.logLevel,e),i=$y(t.logSamples,e),a=Sy(t.traceSamples,e),c=new Set([...Object.keys(n.byTrace),...Object.values(i).flatMap(d=>Object.keys(d.byTrace))]),h=c.size>Uy?new gc(Uy):new Map,u={logLevel:n,logSampling:i,traceSampling:a,__logCache:h,__logOverridesByTrace:c};return Wy.set(r,u),u}o(Dy,"je"),At(Dy,"parseOptions");const Oy=(Uo=class{constructor(e,r,s){dn(this,ll),dn(this,jr),dn(this,ma),dn(this,_r),dn(this,hl),dn(this,fn),dn(this,ga,!1),dn(this,ul,!1),pa(this,"log"),pa(this,"trace"),pa(this,"record"),pa(this,"with"),pa(this,"runSpan"),pa(this,"runInContext");const n=e.serviceNamespace?e.serviceNamespace+"."+e.serviceName:e.serviceName;Or(this,ll,Object.values(s)),Or(this,jr,this._createMetaInstruments()),Or(this,ma,r.exporter(e)),Or(this,_r,By(n,r,s,le(this,jr),le(this,ma))),Or(this,hl,r.metricExportIntervalMs??15e3),this.log=le(this,_r).log,this.trace=le(this,_r).trace,this.record=le(this,_r).record,this.with=le(this,_r).with.bind(le(this,_r)),this.runSpan=le(this,_r).runSpan.bind(le(this,_r)),this.runInContext=le(this,_r).runInContext.bind(le(this,_r))}_createMetaInstruments(){return yy()}async scheduleFlush(){if(le(this,fn)!=null)throw new Error("Pulse.scheduleFlush(): not allowed while activateAutoExport() is managing automatic flushing.");if(!le(this,ga))try{Or(this,ga,!0),await dc(le(this,hl)),await this.export()}finally{Or(this,ga,!1)}}activateAutoExport(){if(le(this,ga))throw new Error("Pulse.activateAutoFlush(): not allowed when manual call to scheduleFlush() is pending");le(this,fn)==null&&Or(this,fn,setInterval(()=>{this.export(!1)},le(this,hl)))}async deactivateAutoExport(){le(this,fn)!=null&&(clearInterval(le(this,fn)),Or(this,fn,void 0),await this.export())}async export(e=!0){if(!le(this,ul)){Or(this,ul,!0);try{const r=y(),s=[];for(let i=0,a=le(this,ll).length;i<a;i++){const c=le(this,ll)[i],{collected:h,dropped:u}=c.flush();h.length>0&&(le(this,jr).metricsDecisionCount.record(void 0,h.length,"decision:included"),s.push({timestamp:r,name:c.name,unit:c.unit,metrics:h})),u&&(le(this,jr).metricsDecisionCount.record(void 0,u[0].value,"decision:dropped"),s.push({timestamp:r,name:u[0].name,unit:u[0].unit,metrics:u}))}le(this,jr).flushDurationMs.record(void 0,y(-r));const n=[le(this,jr).flushDurationMs.flush().collected,le(this,jr).metricsDecisionCount.flush().collected,le(this,jr).logDecisionCount.flush().collected,le(this,jr).traceDecisionCount.flush().collected];for(let i=0,a=n.length;i<a;i++){const c=n[i];c!=null&&c[0]&&s.push({timestamp:r,name:c[0].name,unit:c[0].unit,metrics:c})}le(this,ma).metrics(s),e&&await le(this,ma).flush()}catch(r){this.log.warn("pulse_export_failed",{err:r,force_flush:e})}finally{Or(this,ul,!1)}}}},o(Uo,"ie"),Uo);ll=new WeakMap,jr=new WeakMap,ma=new WeakMap,_r=new WeakMap,hl=new WeakMap,fn=new WeakMap,ga=new WeakMap,ul=new WeakMap,At(Oy,"Pulse");let jy=Oy;const BA=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/i;var IA=Object.defineProperty,qA=o((t,e)=>IA(t,"name",{value:e,configurable:!0}),"n$i");function Em(){return{wireSocketConnectCount:new Q(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireSocketDialCount:new Q(["result:ok","result:error"],l.shape({"wire_channel.name":l.str})),wireSocketActiveCount:new vy(null,l.shape({"wire_channel.name":l.str})),wireSocketDispatchCount:new Q(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireSocketCloseCount:new Q(["was_clean:true","was_clean:false"],l.shape({"wire_channel.name":l.str})),wireSocketErrorCount:new Q(null,l.shape({"wire_channel.name":l.str})),wireSocketInactivityCount:new Q(null,l.shape({"wire_channel.name":l.str})),wireSocketMessageDropCount:new Q(null,l.shape({"wire_channel.name":l.str})),wireSocketRollCount:new Q(["result:ok","result:error"],l.shape({"wire_channel.name":l.str})),wireSocketMessageTooLargeCount:new Q(["mode:trusted","mode:untrusted"],l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireSocketMessageCompressionFailureCount:new Q(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireSocketMessageSizeInBytes:new Dr(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireSocketCircuitBreakerStateCount:new Q(["state:open","state:half_open","state:half_closed","state:closed"],l.shape({"wire_channel.name":l.str})),wireSocketCircuitBreakerRejectCount:new Q(null,l.shape({"wire_channel.name":l.str})),wireHttpIngressCount:new Q(["result:ok","result:error","result:stream_too_large"],l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireHttpIngressDelayMs:new Dr(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireHttpIngressStreamSizeInBytes:new Dr(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireHttpMessageSizeInBytes:new Dr(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireHttpMessageFramingFailureCount:new Q(["reason:payload_too_large","reason:compression_failed"],l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireHttpRequestErrorCount:new Q(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireHttpBeaconCount:new Q(["result:ok transport:beacon","result:error transport:beacon","result:ok transport:fetch","result:error transport:fetch"],l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireSignalDispatchCount:new Q(["type:event","type:request","type:stream"],l.shape({"wire_signal.name":l.str})),wireSignalResultCount:new Q(["type:event result:ok","type:request result:ok","type:request result:error","type:request result:timeout","type:request result:send_error","type:stream result:ok","type:stream result:skipped","type:stream result:error","type:stream result:timeout","type:stream result:initial_timeout","type:stream result:item_timeout","type:stream result:send_error"],l.shape({"wire_signal.name":l.str.optional})),wireSignalRequestHandleCount:new Q(["result:unrecognized_signal","result:malformed_header","type:event result:ok","type:event result:error","type:event result:handler_not_bound","type:event result:response_not_supported","type:event result:aborted","type:request result:unrecognized","type:request result:mismatched_type","type:request result:ok","type:request result:error","type:request result:handler_not_bound","type:request result:timeout","type:request result:aborted","type:stream result:unrecognized","type:stream result:mismatched_type","type:stream result:started","type:stream result:ok","type:stream result:error","type:stream result:timeout","type:stream result:handler_not_bound","type:stream result:aborted"],l.shape({"wire_signal.name":l.str.optional})),wireSignalStreamSegmentCount:new Q(null,l.shape({"wire_signal.name":l.str})),wireSignalMigrationCount:new Q(null,l.shape({"wire_signal.name":l.str,"wire_signal.from_version":l.uint32,"wire_signal.to_version":l.uint32})),wireSignalLatencyMs:new Dr(["result:ok","result:error","result:timeout","result:send_error"],l.shape({"wire_signal.name":l.str})),wireSignalStreamLifetimeMs:new Dr(["result:ok","result:error","result:timeout","result:initial_timeout","result:item_timeout"],l.shape({"wire_signal.name":l.str})),wireSignalBackpressureCount:new Q(null,l.shape({"wire_signal.name":l.str})),wireSignalSendErrorCount:new Q(null,l.shape({"wire_signal.name":l.str})),wireSignalUnsupportedVersionCount:new Q(null,l.shape({"wire_signal.name":l.str}))}}o(Em,"o$d"),qA(Em,"makeWireInstruments");var PA=Object.defineProperty,He=o((t,e)=>PA(t,"name",{value:e,configurable:!0}),"a$i");const Mm=96,xA=0,pl=32,Ku=64,Gu=96,Ws=16,ml=15,WA=xA|16,Zt=ke("continuum_checksum",l.fnv1a);function Ny(t,e){const r=[];for(const s in e)r.push([s,{payload:e[s]}]);return ke(t,l.taggedUnion("patch",r))}o(Ny,"j$6"),He(Ny,"makePatchSchema");function Ly(t,e,r,s,n){const i=n.encode(s),a=t.trace.exportTraceParent();if(a){const c=vt.encode(a);return[String.fromCharCode(pl|Ws|e)+c+Zt.encode(r)+i,c.length]}return[String.fromCharCode(pl|e)+Zt.encode(r)+i,0]}o(Ly,"z$5"),He(Ly,"encodePatch");function Vu(t,e,r){const s=r.encode(e.state),n=t.trace.exportTraceParent();if(n){const i=vt.encode(n);return[String.fromCharCode(Ku|Ws)+i+Zt.encode(e.headChecksum)+s,i.length]}return[String.fromCharCode(Ku)+Zt.encode(e.headChecksum)+s,0]}o(Vu,"B$9"),He(Vu,"encodeSnapshot");function UA(t,e){const r=t.trace.exportTraceParent();if(r){const s=vt.encode(r);return[String.fromCharCode(Gu|Ws)+s+e.join(""),s.length]}return[String.fromCharCode(Gu)+e.join(""),0]}o(UA,"K$6"),He(UA,"encodeBatch");function Fy(t,e,r){const s=He((d,p,f)=>t==="trusted"?Zt.decodeTrusted(d,p,f):Zt.decodeUntrusted(d,p,f),"decodeChecksum"),n=He((d,p,f)=>t==="trusted"?vt.decodeTrusted(d,p,f):vt.decodeUntrusted(d,p,f),"decodeTraceParent"),i=He((d,p,f)=>t==="trusted"?e.decodeTrusted(d,p,f):e.decodeUntrusted(d,p,f),"decodeState"),a=t==="trusted"?r.map(d=>(p,f,g)=>d.patchSchema.decodeTrusted(p,f,g)):r.map(d=>(p,f,g)=>d.patchSchema.decodeUntrusted(p,f,g));function c(d,p,f,g){const m=a[p];if(!m)return null;const w=s(d,f,g),_=m(d,wt(),g);return{type:"patch",continuumId:p,patch:_,expectedChecksum:w}}o(c,"R"),He(c,"decodePatch");function h(d,p,f){const g=s(d,p,f);return{type:"snapshot",snapshot:{state:i(d,wt(),f),headChecksum:g}}}o(h,"_"),He(h,"decodeSnapshot");function u(d,p,f){const g=[],m=[];let w=p;for(;w<d.length;){const _=w,S=d.charCodeAt(w)&ml,b=a[S];if(w+=1,!b)return null;const D=s(d,w,f),O=b(d,wt(),f);w=wt(),g.push({type:"patch",continuumId:S,patch:O,expectedChecksum:D}),m.push(d.slice(_,w))}return{type:"batch",patches:g,payloads:m}}return o(u,"x"),He(u,"decodeBatch"),He(function(d){const p=d.length,f=d.charCodeAt(0),g=(f&Ws)!==0;let m,w,_;g?(m=n(d,1,p),_=wt(),w=_-1):(m=void 0,_=1,w=0);const S=f&Mm,b=f&ml;if(S===Gu){if(b!==0)throw new Error(`[continuum/codec] Batch payload must have continuum ID = 0, got ${b}`);return{traceParent:m,event:u(d,_,p),traceDataLength:w}}if(S===Ku){if(b!==0)throw new Error(`[continuum/codec] Snapshot payload must have continuum ID = 0, got ${b}`);const D=h(d,_,p);return wt()!==d.length?{traceParent:m,event:null,traceDataLength:w}:{traceParent:m,event:D,traceDataLength:w}}if(S===pl){const D=c(d,b,_,p);return D&&wt()!==d.length?{traceParent:m,event:null,traceDataLength:w}:{traceParent:m,event:D,traceDataLength:w}}throw new Error(`[continuum/codec] Invalid payload header: 0b${f.toString(2).padStart(8,"0")} (type bits: ${(S>>5).toString(2).padStart(2,"0")})`)},"decodePayload")}o(Fy,"G$4"),He(Fy,"makePayloadDecoder");function Yu(t,e){let r;return e!==void 0?r=1+e:Rm(t)?(vt.decodeTrusted(t,1),r=wt()):r=1,Zt.decodeTrusted(t,r),t.slice(wt())}o(Yu,"L$a"),He(Yu,"extractPatchBody");function Tm(t,e,r,s){const n=t.trace.exportTraceParent();if(n){const i=vt.encode(n);return[String.fromCharCode(pl|Ws|e)+i+Zt.encode(r)+s,i.length]}return[String.fromCharCode(pl|e)+Zt.encode(r)+s,0]}o(Tm,"X$3"),He(Tm,"hydratePatchBody");function Rm(t){return(t.charCodeAt(0)&Ws)!==0}o(Rm,"k$8"),He(Rm,"hasTrace");function zy(t){return t.length>0&&t.charCodeAt(0)===WA}o(zy,"b$c"),He(zy,"hasContinuationFrame");function Bm(t){const e=t.charCodeAt(0);return(e&Mm)===Gu&&(e&ml)===0}o(Bm,"q$9"),He(Bm,"isBatchPayload");function Im(t){const e=t.charCodeAt(0);return(e&Mm)===Ku&&(e&ml)===0}o(Im,"J$5"),He(Im,"isSnapshotPayload");function DA(t,e){let r;return e!==void 0?r=1+e:(t.charCodeAt(0)&Ws)!==0?(vt.decodeTrusted(t,1),r=wt()):r=1,Zt.decodeUntrusted(t,r)}o(DA,"Q$4"),He(DA,"extractChecksumFromPayload");function OA(t,e){if(!Rm(t))return t;let r;e!==void 0?r=e:(vt.decodeTrusted(t,1),r=wt()-1);const s=t.charCodeAt(0)&~Ws;return String.fromCharCode(s)+t.slice(1+r)}o(OA,"V$3"),He(OA,"stripTrace");function jA(t,e){const r=t.trace.exportTraceParent();if(!r)return[e,0];const s=vt.encode(r),n=e.charCodeAt(0)|Ws;return[String.fromCharCode(n)+s+e.slice(1),s.length]}o(jA,"W$4"),He(jA,"addTrace");var Hy=Object.defineProperty,Ky=o(t=>{throw TypeError(t)},"k$7"),NA=o((t,e,r)=>e in t?Hy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"H$5"),qm=o((t,e)=>Hy(t,"name",{value:e,configurable:!0}),"p$g"),Pm=o((t,e,r)=>NA(t,typeof e!="symbol"?e+"":e,r),"m$i"),Gy=o((t,e,r)=>e.has(t)||Ky("Cannot "+r),"w$b"),va=o((t,e,r)=>(Gy(t,e,"read from private field"),r?r.call(t):e.get(t)),"c$n"),Ju=o((t,e,r)=>e.has(t)?Ky("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"i$c"),Vy=o((t,e,r)=>(Gy(t,e,"access private method"),r),"l$k"),gl,wl,Yy,Xu,Jy,Xy;const Qy=(Do=class{constructor(e){Ju(this,Xu),Pm(this,"name"),Pm(this,"stateSchema"),Pm(this,"patchSchema"),Ju(this,gl,new Set),Ju(this,wl,new Set),Ju(this,Yy,new WeakSet),this.name=e.name,this.stateSchema=ke(`${e.name}:state`,e.state),this.patchSchema=Ny(`${e.name}:patch`,e.patches)}applyPatch(e,r,s){const n=r.patch,i=this.reducers[r.patch],a=i(r.payload);if(a!==void 0)return e.log.debug("continuum_patch_rejected",{continuum:this.name,patch:n,reason:a,payload:r.payload}),e.record.continuumPatchRejectedCount(1,{patch:n,reason:a}),!1;e.record.continuumPatchAppliedCount(1,{patch:n});const[c,h]=s??Ly(e,0,xc,r,this.patchSchema);return Vy(this,Xu,Jy).call(this,e,r,c,h),!0}applySnapshot(e,r){this.setState(r),Vy(this,Xu,Xy).call(this,e,r)}onPatch(e){return va(this,gl).add(e),()=>{va(this,gl).delete(e)}}onSnapshot(e){return va(this,wl).add(e),()=>{va(this,wl).delete(e)}}},o(Do,"P"),Do);gl=new WeakMap,wl=new WeakMap,Yy=new WeakMap,Xu=new WeakSet,Jy=qm(function(t,e,r,s){for(const n of va(this,gl))n(t,e,r,s)},"#emitPatch"),Xy=qm(function(t,e){for(const r of va(this,wl))r(t,e)},"#emitSnapshot"),qm(Qy,"Continuum");let xm=Qy;var Zy=Object.defineProperty,eb=o(t=>{throw TypeError(t)},"P$7"),LA=o((t,e,r)=>e in t?Zy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"O$8"),hs=o((t,e)=>Zy(t,"name",{value:e,configurable:!0}),"u$j"),FA=o((t,e,r)=>LA(t,e+"",r),"B$8"),Wm=o((t,e,r)=>e.has(t)||eb("Cannot "+r),"T$7"),he=o((t,e,r)=>(Wm(t,e,"read from private field"),r?r.call(t):e.get(t)),"i$b"),mn=o((t,e,r)=>e.has(t)?eb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"m$h"),Ie=o((t,e,r,s)=>(Wm(t,e,"write to private field"),e.set(t,r),r),"r$e"),ai=o((t,e,r)=>(Wm(t,e,"access private method"),r),"p$f"),_a,er,mt,Nr,Us,gn,vl,Ds,Qu,_l;const ya=5,zA=3e3,HA=1500,oi=l.shape({height:l.blockHeight,digest:l.blockDigest}),ci=ke("serialized_block",ne({safeParse:hs(t=>typeof t=="number"?Number.isInteger(t)&&t>=0&&t<ya:oi._safeParse(t),"safeParse"),encode:hs(t=>typeof t=="number"?String.fromCharCode(t|64):oi._encode(t),"encode"),decodeTrusted:hs((t,e)=>{const r=t.charCodeAt(e.offset);return r&64?(e.offset+=1,r&63):oi._decodeTrusted(t)},"decodeTrusted"),decodeUntrusted:hs((t,e)=>{const r=t.charCodeAt(e.offset);if(r&64){e.offset+=1;const s=r&63;if(s<0||s>=ya)throw new Error(`Invalid blockRingBuffer index, must be 0-${ya-1}`);return s}return oi._decodeUntrusted(t)},"decodeUntrusted")})),tb=l.shape({context:oi,propagatesAt:l.timestamp}),KA=l.shape({digest:l.blockDigest,expiresAt:l.timestamp}),GA=l.shape({expiresAt:l.timestamp}),VA=l.shape({current:oi.optional,pending:tb.optional,expiresAt:l.timestamp,blockRingBuffer:l.arr(oi)}),rb=(Oo=class extends xm{constructor(e={}){super({name:"block_continuum",state:VA,patches:{transition:tb,promote:KA,affirm:GA}}),mn(this,Ds),mn(this,_a),mn(this,er),mn(this,mt),mn(this,Nr),mn(this,Us,new Array(ya)),mn(this,gn),mn(this,vl),FA(this,"reducers",{transition:hs(r=>{he(this,Us).unshift(r.context),he(this,Us).length=ya,he(this,mt)&&Ie(this,er,he(this,mt).context),he(this,_a).call(this,r.propagatesAt)?(Ie(this,er,r.context),Ie(this,mt,void 0)):Ie(this,mt,r),Ie(this,Nr,r.propagatesAt+zA),ai(this,Ds,_l).call(this)},"transition"),promote:hs(r=>{var s,n;if(((s=he(this,er))==null?void 0:s.digest)===r.digest){Ie(this,Nr,r.expiresAt),ai(this,Ds,_l).call(this);return}if(((n=he(this,mt))==null?void 0:n.context.digest)!==r.digest)return"digest_mismatch";Ie(this,er,he(this,mt).context),Ie(this,mt,void 0),Ie(this,Nr,r.expiresAt),ai(this,Ds,_l).call(this)},"promote"),affirm:hs(r=>{Ie(this,Nr,r.expiresAt)},"affirm")}),Ie(this,er,void 0),Ie(this,mt,void 0),Ie(this,Nr,0),Ie(this,vl,y()),Ie(this,_a,e.isExpired??(r=>y()>=r)),this.onPatch(()=>{Ie(this,vl,y())})}setState(e){Ie(this,er,e.current),Ie(this,mt,e.pending),Ie(this,Nr,e.expiresAt),Ie(this,Us,[...e.blockRingBuffer]),he(this,Us).length=ya,ai(this,Ds,_l).call(this)}getState(){return ai(this,Ds,Qu).call(this),{current:he(this,er),pending:he(this,mt),expiresAt:he(this,Nr),blockRingBuffer:he(this,Us).filter(e=>e!==void 0)}}getCurrent(){if(ai(this,Ds,Qu).call(this),!(!he(this,er)||he(this,_a).call(this,he(this,Nr))))return{height:he(this,er).height,digest:he(this,er).digest,expiresAt:he(this,Nr)}}getPendingTransition(){return ai(this,Ds,Qu).call(this),he(this,mt)}waitForCurrent(e){const r=this.getCurrent();if(r)return r;if(!(y()-he(this,vl)>HA))return he(this,gn)||Ie(this,gn,Ge()),pc(e,he(this,gn)).then(s=>s===fc?void 0:s)}getBlockRef(e){const r=he(this,Us).findIndex(s=>(s==null?void 0:s.digest)===e.digest);return r!==-1?r:e}parseBlockRef(e){if(e!==void 0){if(typeof e=="number"){const r=he(this,Us)[e];if(!r)throw new Error(`Block not found at ring buffer index ${e}`);return r}return e}}},o(Oo,"R"),Oo);_a=new WeakMap,er=new WeakMap,mt=new WeakMap,Nr=new WeakMap,Us=new WeakMap,gn=new WeakMap,vl=new WeakMap,Ds=new WeakSet,Qu=hs(function(){he(this,mt)&&he(this,_a).call(this,he(this,mt).propagatesAt)&&(Ie(this,er,he(this,mt).context),Ie(this,mt,void 0))},"#maybePromotePending"),_l=hs(function(){if(!he(this,gn))return;const t=this.getCurrent();t&&(he(this,gn).__resolve(t),Ie(this,gn,void 0))},"#maybeResolveWaiter"),hs(rb,"BlockContinuum");let sb=rb;var YA=Object.defineProperty,JA=o((t,e)=>YA(t,"name",{value:e,configurable:!0}),"r$d");const XA=l.shape({skip:l.uint32,deleteLen:l.uint32,insert:l.str}),nb=ke("diff",l.shape({prefixLen:l.uint32,ops:l.arr(XA)}));function Um(t,e){const{prefixLen:r,ops:s}=e;let n=t.slice(0,r),i=r;for(const a of s){const c=i+a.skip;i<c&&(n+=t.slice(i,c)),n+=a.insert,i=c+a.deleteLen}return n+=t.slice(i),n}o(Um,"h$d"),JA(Um,"applyDiff");var ib=Object.defineProperty,ab=o(t=>{throw TypeError(t)},"A$8"),QA=o((t,e,r)=>e in t?ib(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"R$7"),us=o((t,e)=>ib(t,"name",{value:e,configurable:!0}),"d$c"),ZA=o((t,e,r)=>QA(t,e+"",r),"C$7"),Dm=o((t,e,r)=>e.has(t)||ab("Cannot "+r),"w$9"),Ce=o((t,e,r)=>(Dm(t,e,"read from private field"),r?r.call(t):e.get(t)),"n$g"),ba=o((t,e,r)=>e.has(t)?ab("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"f$d"),ob=o((t,e,r,s)=>(Dm(t,e,"write to private field"),e.set(t,r),r),"S$a"),yl=o((t,e,r)=>(Dm(t,e,"access private method"),r),"a$f"),Wt,Os,bl,$l,$a,li,Zu,cb,lb;const ed=l.requestFingerprint("with-checksum"),wn=ke("fingerprint_ref",ne({safeParse:us(t=>typeof t=="number"?Number.isInteger(t)&&t>=0:ed._safeParse(t),"safeParse"),encode:us(t=>typeof t=="number"?l.uint32._encode(t+1):"\0"+ed._encode(t),"encode"),decodeTrusted:us((t,e)=>t.charCodeAt(e.offset)===0?(e.offset++,ed._decodeTrusted(t)):l.uint32._decodeTrusted(t)-1,"decodeTrusted"),decodeUntrusted:us((t,e)=>{if(Number.isNaN(t.charCodeAt(e.offset)))throw $.PAYLOAD_TRUNCATED;return t.charCodeAt(e.offset)===0?(e.offset++,ed._decodeUntrusted(t)):l.uint32._decodeUntrusted(t)-1},"decodeUntrusted")})),eE=l.shape({fingerprints:l.arr(l.requestFingerprint("with-checksum"))}),tE=l.shape({added:l.arr(l.requestFingerprint("with-checksum")),removed:l.arr(l.requestFingerprint("with-checksum"))}),rE=l.shape({added:l.arr(l.requestFingerprint("with-checksum")),kept:l.arr(l.requestFingerprint("with-checksum"))}),hb=(jo=class extends xm{constructor(){super({name:"fingerprint_continuum",state:eE,patches:{incremental:tE,replacement:rE}}),ba(this,li),ba(this,Wt,[]),ba(this,Os,new Map),ZA(this,"reducers",{incremental:us(e=>{yl(this,li,cb).call(this,e)},"incremental"),replacement:us(e=>{yl(this,li,lb).call(this,e)},"replacement")}),ba(this,bl,new Set),ba(this,$l,new Set),ba(this,$a,new Set)}setState(e){ob(this,Wt,[...e.fingerprints]),yl(this,li,Zu).call(this);for(const r of Ce(this,$a))r(e.fingerprints)}getState(){return{fingerprints:Ce(this,Wt).slice(0)}}onAdded(e){return Ce(this,bl).add(e),()=>{Ce(this,bl).delete(e)}}onRemoved(e){return Ce(this,$l).add(e),()=>{Ce(this,$l).delete(e)}}onReplacement(e){return Ce(this,$a).add(e),()=>{Ce(this,$a).delete(e)}}getFingerprintRef(e){const r=Ce(this,Os).get(e);return r!==void 0?r:e}parseFingerprintRef(e){if(typeof e=="number"){const r=Ce(this,Wt)[e];if(!r)throw new Error(`Fingerprint not found at index ${e}`);return r}return e}has(e){return Ce(this,Os).has(e)}get size(){return Ce(this,Wt).length}*iterate(){yield*Ce(this,Wt)}},o(jo,"b"),jo);Wt=new WeakMap,Os=new WeakMap,bl=new WeakMap,$l=new WeakMap,$a=new WeakMap,li=new WeakSet,Zu=us(function(){Ce(this,Os).clear();for(let t=0,e=Ce(this,Wt).length;t<e;t++){const r=Ce(this,Wt)[t];r!==void 0&&Ce(this,Os).set(r,t)}},"#rebuildIndexMap"),cb=us(function(t){if(t.removed.length>0){for(const e of t.removed){const r=Ce(this,Os).get(e);r!==void 0&&Ce(this,Wt).splice(r,1)}yl(this,li,Zu).call(this);for(const e of Ce(this,$l))e(t.removed)}if(t.added.length>0){for(const e of t.added)Ce(this,Os).has(e)||(Ce(this,Os).set(e,Ce(this,Wt).length),Ce(this,Wt).push(e));for(const e of Ce(this,bl))e(t.added)}},"#applyIncremental"),lb=us(function(t){ob(this,Wt,[...t.kept,...t.added]),yl(this,li,Zu).call(this);for(const e of Ce(this,$a))e(Ce(this,Wt))},"#applyReplacement"),us(hb,"FingerprintContinuum");let Om=hb;var ub=Object.defineProperty,db=o(t=>{throw TypeError(t)},"Q$3"),sE=o((t,e,r)=>e in t?ub(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"oe$1"),Me=o((t,e)=>ub(t,"name",{value:e,configurable:!0}),"u$h"),jm=o((t,e,r)=>sE(t,typeof e!="symbol"?e+"":e,r),"B$7"),Nm=o((t,e,r)=>e.has(t)||db("Cannot "+r),"U$5"),V=o((t,e,r)=>(Nm(t,e,"read from private field"),r?r.call(t):e.get(t)),"o$a"),ka=o((t,e,r)=>e.has(t)?db("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"x$5"),kl=o((t,e,r,s)=>(Nm(t,e,"write to private field"),e.set(t,r),r),"E$c"),se=o((t,e,r)=>(Nm(t,e,"access private method"),r),"p$d"),Ca,vn,Lr,Et,br,te,Lm,td,Fm,rd,zm,Hm,fb,_n,pb,mb,sd,gb,wb,nd;const nE=25*1024*1024,iE=1e3,aE=25e3,oE=2,cE=l.shape({requestKey:l.requestKey("with-checksum"),responseKey:l.responseKey,response:l.str,expiresAt:l.timestamp}),lE=l.shape({fingerprintRef:wn,blockRef:ci,responseKey:l.responseKey,expiresAt:l.timestamp}),hE=l.shape({fingerprintRef:wn,responseKey:l.responseKey,fromBlock:ci,toBlock:ci,expiresAt:l.timestamp}),uE=l.shape({fingerprintRef:wn,responseKey:l.responseKey,fromBlock:ci,toBlock:ci,diff:nb,expiresAt:l.timestamp}),dE=l.shape({fingerprintRef:wn,blockRef:ci,responseKey:l.responseKey,response:l.str,expiresAt:l.timestamp}),fE=l.shape({fingerprintRef:wn,responseKey:l.responseKey,expiresAt:l.timestamp}),pE=l.shape({fingerprintRef:wn,responseKey:l.responseKey,diff:nb,expiresAt:l.timestamp}),mE=l.shape({fingerprintRef:wn,responseKey:l.responseKey,response:l.str,expiresAt:l.timestamp}),gE=l.shape({fingerprintRef:wn,blockRef:ci}),wE=l.shape({requestKey:l.requestKey("with-checksum"),baseRequestKey:l.requestKey("with-checksum").optional,expiresAt:l.timestamp}),vE=l.shape({entries:l.arr(cE),inflightEntries:l.arr(wE)}),vb=(No=class extends xm{constructor(e,r,s,n){super({name:"cache_continuum",state:vE,patches:{mutable_zero_change:lE,immutable_zero_change:fE,mutable_block_only:hE,mutable_diff:uE,immutable_diff:pE,mutable_replacement:dE,immutable_replacement:mE,mutable_failed:gE}}),ka(this,te),ka(this,Ca),ka(this,vn),jm(this,"blockContinuum"),jm(this,"fingerprintContinuum"),ka(this,Lr),ka(this,Et),ka(this,br),jm(this,"reducers",{mutable_zero_change:Me(i=>{const{fingerprintRef:a,blockRef:c,responseKey:h,expiresAt:u}=i,d=this.fingerprintContinuum.parseFingerprintRef(a),p=this.blockContinuum.parseBlockRef(c),f=Ft(d,p.digest);return se(this,te,Lm).call(this,f,h,u)},"mutable_zero_change"),immutable_zero_change:Me(i=>{const{fingerprintRef:a,responseKey:c,expiresAt:h}=i,u=this.fingerprintContinuum.parseFingerprintRef(a);return Mr(u)?se(this,te,Lm).call(this,u,c,h):"missing_block_ref"},"immutable_zero_change"),mutable_block_only:Me(i=>{const{fingerprintRef:a,responseKey:c,fromBlock:h,toBlock:u,expiresAt:d}=i,p=this.fingerprintContinuum.parseFingerprintRef(a),f=this.blockContinuum.parseBlockRef(h),g=this.blockContinuum.parseBlockRef(u),m=Ft(p,f.digest),w=se(this,te,rd).call(this,m);if(!w)return"prev_entry_not_found";const _=se(this,te,Fm).call(this,w.response,f,g);if(!se(this,te,td).call(this,_,c))return"digest_mismatch";const S=Ft(p,g.digest);se(this,te,_n).call(this,{requestKey:S,responseKey:c,response:_,expiresAt:d})},"mutable_block_only"),mutable_diff:Me(i=>{const{fingerprintRef:a,responseKey:c,fromBlock:h,toBlock:u,diff:d,expiresAt:p}=i,f=this.fingerprintContinuum.parseFingerprintRef(a),g=this.blockContinuum.parseBlockRef(h),m=this.blockContinuum.parseBlockRef(u),w=Ft(f,g.digest),_=se(this,te,rd).call(this,w);if(!_)return"prev_entry_not_found";const S=se(this,te,Fm).call(this,_.response,g,m),b=Um(S,d);if(!se(this,te,td).call(this,b,c))return"digest_mismatch";const D=Ft(f,m.digest);se(this,te,_n).call(this,{requestKey:D,responseKey:c,response:b,expiresAt:p})},"mutable_diff"),immutable_diff:Me(i=>{const{fingerprintRef:a,responseKey:c,diff:h,expiresAt:u}=i,d=this.fingerprintContinuum.parseFingerprintRef(a);if(!Mr(d))return"missing_block_ref";const p=se(this,te,rd).call(this,d);if(!p)return"prev_entry_not_found";const f=Um(p.response,h);if(!se(this,te,td).call(this,f,c))return"digest_mismatch";se(this,te,_n).call(this,{requestKey:d,responseKey:c,response:f,expiresAt:u})},"immutable_diff"),mutable_replacement:Me(i=>{const{fingerprintRef:a,blockRef:c,responseKey:h,response:u,expiresAt:d}=i,p=this.fingerprintContinuum.parseFingerprintRef(a),f=this.blockContinuum.parseBlockRef(c),g=Ft(p,f.digest);se(this,te,_n).call(this,{requestKey:g,responseKey:h,response:u,expiresAt:d})},"mutable_replacement"),immutable_replacement:Me(i=>{const{fingerprintRef:a,responseKey:c,response:h,expiresAt:u}=i,d=this.fingerprintContinuum.parseFingerprintRef(a);if(!Mr(d))return"missing_block_ref";se(this,te,_n).call(this,{requestKey:d,responseKey:c,response:h,expiresAt:u})},"immutable_replacement"),mutable_failed:Me(i=>{const{fingerprintRef:a,blockRef:c}=i,h=this.fingerprintContinuum.parseFingerprintRef(a),u=Ft(h,this.blockContinuum.parseBlockRef(c).digest);se(this,te,sd).call(this,u,void 0)},"mutable_failed")}),this.blockContinuum=e,this.fingerprintContinuum=r,kl(this,Ca,s),kl(this,vn,(n==null?void 0:n.isExpired)??(i=>y()>=i)),kl(this,Et,new gc((n==null?void 0:n.maxRequestEntries)??aE)),kl(this,br,new gc((n==null?void 0:n.maxInflightEntries)??iE,{onEvict:Me((i,a)=>{clearTimeout(a.timeout),a.deferred&&!a.deferred.__isFulfilled()&&(a.deferred.__resolve(void 0),V(this,Ca).onInflightEviction())},"onEvict")})),kl(this,Lr,new Zw((n==null?void 0:n.maxSizeBytes)??nE,{onEvict:Me((i,a)=>{V(this,vn).call(this,a.expiresAt)||V(this,Ca).onPrematureEviction()},"onEvict")})),this.blockContinuum.onPatch((i,a)=>{a.patch==="transition"&&se(this,te,pb).call(this,a.payload.context)}),this.fingerprintContinuum.onRemoved(i=>{i.length>0&&se(this,te,gb).call(this,new Set(i))}),this.fingerprintContinuum.onReplacement(i=>{se(this,te,wb).call(this,new Set(i))})}setState(e){V(this,Lr).clear(),V(this,Et).clear();for(const r of e.entries)se(this,te,_n).call(this,r);for(const[,r]of V(this,br).entries())clearTimeout(r.timeout),r.deferred&&!r.deferred.__isFulfilled()&&r.deferred.__resolve(void 0);V(this,br).clear();for(const{requestKey:r,expiresAt:s,baseRequestKey:n}of e.inflightEntries)V(this,vn).call(this,s)||V(this,br).set(r,{expiresAt:s,baseRequestKey:n})}getState(){const e=[],{inflightEntries:r,retainedRequestKeys:s,retainedBlockDigests:n}=se(this,te,Hm).call(this);for(const[i,a]of V(this,Et).entries()){const c=V(this,Lr).get(a);!c||!se(this,te,zm).call(this,i,c,s,n)||e.push(c.requestKey===i?c:{...c,requestKey:i})}return{entries:e,inflightEntries:r}}readFromCache(e){const r=V(this,Et).get(e);if(r)return V(this,Lr).get(r);const s=V(this,br).get(e);if(!(!s||V(this,vn).call(this,s.expiresAt)))return s.deferred?s.deferred:se(this,te,mb).call(this,e,s)}has(e){return V(this,Et).has(e)}},o(No,"O"),No);Ca=new WeakMap,vn=new WeakMap,Lr=new WeakMap,Et=new WeakMap,br=new WeakMap,te=new WeakSet,Lm=Me(function(t,e,r){const s=V(this,Lr).get(e);if(!s)return"prev_entry_not_found";se(this,te,_n).call(this,{requestKey:t,responseKey:e,response:s.response,expiresAt:r})},"#applyZeroChange"),td=Me(function(t,e){const r=Bw(e);return Af(cl.decodeUntrusted(t))===r},"#validateDigest"),Fm=Me(function(t,e,r){return t.replaceAll(e.height.slice(2),r.height.slice(2))},"#applyBlockHeightTransform"),rd=Me(function(t){const e=V(this,Et).get(t);if(!e)return;const r=V(this,Lr).get(e);if(r)return r.requestKey===t?r:{...r,requestKey:t}},"#lookupEntry"),zm=Me(function(t,e,r,s){if(r.has(t))return!0;if(!lc(t))return!V(this,vn).call(this,e.expiresAt);const n=Sf(t);return n!==void 0&&s.has(n)},"#shouldRetainInSnapshot"),Hm=Me(function(){const t=[],e=new Set,r=new Set(this.blockContinuum.getState().blockRingBuffer.map(s=>s.digest));for(const[s,n]of V(this,br).entries())V(this,vn).call(this,n.expiresAt)||(t.push({requestKey:s,expiresAt:n.expiresAt,baseRequestKey:n.baseRequestKey}),e.add(s),n.baseRequestKey&&e.add(n.baseRequestKey));return{inflightEntries:t,retainedRequestKeys:e,retainedBlockDigests:r}},"#collectSnapshotRetention"),fb=Me(function(){const{retainedRequestKeys:t,retainedBlockDigests:e}=se(this,te,Hm).call(this),r=[];for(const[s,n]of V(this,Et).entries()){const i=V(this,Lr).get(n);(!i||!se(this,te,zm).call(this,s,i,t,e))&&r.push(s)}for(const s of r)se(this,te,nd).call(this,s)},"#pruneSnapshotIneligibleEntries"),_n=Me(function(t){const{requestKey:e,responseKey:r,response:s}=t;if(Mf(r)){const n=(e.length+r.length+s.length+8)*oE;V(this,Lr).set(r,t,n),V(this,Et).set(e,r)}se(this,te,sd).call(this,e,t)},"#insertEntry"),pb=Me(function(t){const e=y(3e3),r=this.blockContinuum.getCurrent();for(const s of this.fingerprintContinuum.iterate()){if(Mr(s))continue;const n=Ft(s,t.digest);let i;r&&r.digest!==t.digest&&(i=Ft(s,r.digest)),V(this,br).set(n,{expiresAt:e,baseRequestKey:i})}se(this,te,fb).call(this)},"#registerInflightFromPlan"),mb=Me(function(t,e){const r=Ge(),s=Math.max(0,e.expiresAt-y());return e.timeout=setTimeout(()=>{r.__isFulfilled()||(r.__resolve(void 0),V(this,Ca).onInflightTimeout())},s),r.finally(()=>{clearTimeout(e.timeout),V(this,br).delete(t)}),e.deferred=r,r},"#openInflightDeferred"),sd=Me(function(t,e){const r=V(this,br).get(t);r&&(r.deferred&&!r.deferred.__isFulfilled()&&r.deferred.__resolve(e),clearTimeout(r.timeout),V(this,br).delete(t))},"#resolveInflight"),gb=Me(function(t){if(t.size!==0)for(const[e]of V(this,Et).entries())t.has(oh(e))&&se(this,te,nd).call(this,e)},"#purgeByFingerprint"),wb=Me(function(t){for(const[e]of V(this,Et).entries())t.has(oh(e))||se(this,te,nd).call(this,e)},"#purgeUntrackedFingerprints"),nd=Me(function(t){const e=V(this,Et).get(t);if(V(this,Et).delete(t),se(this,te,sd).call(this,t,void 0),!!e){for(const[,r]of V(this,Et).entries())if(r===e)return;V(this,Lr).delete(e)}},"#deleteRequestKey"),Me(vb,"CacheContinuum");let _b=vb;var yb=Object.defineProperty,bb=o(t=>{throw TypeError(t)},"Q$2"),_E=o((t,e,r)=>e in t?yb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"ht$1"),tr=o((t,e)=>yb(t,"name",{value:e,configurable:!0}),"f$c"),$b=o((t,e,r)=>_E(t,typeof e!="symbol"?e+"":e,r),"N$3"),Km=o((t,e,r)=>e.has(t)||bb("Cannot "+r),"j$4"),R=o((t,e,r)=>(Km(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$8"),Ut=o((t,e,r)=>e.has(t)?bb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"d$a"),Dt=o((t,e,r,s)=>(Km(t,e,"write to private field"),e.set(t,r),r),"p$c"),Ot=o((t,e,r)=>(Km(t,e,"access private method"),r),"l$h"),Fr,Sa,ct,hi,id,rr,js,Cl,Sl,ad,Al,El,Ml,bt,Gm,kb,Cb,Vm,Ym,Tl,Jm;const yE=ne({safeParse:tr(t=>typeof t=="string","safeParse"),encode:tr(t=>t,"encode"),decodeTrusted:tr(t=>t.slice(wt()),"decodeTrusted"),decodeUntrusted:tr(t=>t.slice(wt()),"decodeUntrusted")});function Sb(t){return t?ke("continuum_req",l.shape({fromChecksum:Zt,timeoutMs:l.uint32.optional,params:t})):ke("continuum_req",l.shape({fromChecksum:Zt,timeoutMs:l.uint32.optional}))}o(Sb,"ct"),tr(Sb,"makeReqSchema");const bE=ke("continuum_res",yE),Ab=(Ii=class extends eu{constructor(e,r,s,n){const i=r.timeoutMs??3e4;super({id:r.id,name:r.name,req:Sb(s),res:bE,timeoutMs:i,initialTimeoutMs:r.initialTimeoutMs,itemTimeoutMs:r.itemTimeoutMs},[]),Ut(this,bt),Ut(this,Fr),Ut(this,Sa),Ut(this,ct),Ut(this,hi),Ut(this,id),$b(this,"paramsSchema"),Ut(this,rr),Ut(this,js),Ut(this,Cl),$b(this,"snapshotSchema"),Ut(this,Sl,new WeakSet),Ut(this,ad,new WeakSet),Ut(this,Al,new Set),Ut(this,El,new Set),Ut(this,Ml,new Set),Dt(this,id,r),this.paramsSchema=s,Dt(this,rr,{"continuum.signal":r.name}),Dt(this,Sa,Object.keys(e).sort());const a={};Dt(this,Fr,R(this,Sa).map(c=>{const h=e[c];return a[c]=h.stateSchema,h})),Dt(this,js,ke(`continuum:${this.name}`,l.shape(a))),this.snapshotSchema=l.shape({state:R(this,js),headChecksum:Zt}),n?(Dt(this,hi,!0),Dt(this,ct,n.headChecksum),Dt(this,Cl,Fy(n.mode,R(this,js),R(this,Fr))),Ot(this,bt,Cb).call(this)):(Dt(this,hi,!1),Dt(this,ct,xc))}get headChecksum(){return R(this,ct)}hydrate(e,r,s,n){if(R(this,hi))throw new Error(`ContinuumSignal "${this.name}" is already hydrated and cannot hydrate again`);return new Ii(r,R(this,id),this.paramsSchema,{headChecksum:n??xc,mode:s})}handlePayload(e,r){if(!R(this,hi)||!R(this,Cl))throw new Error(`ContinuumSignal "${this.name}" must be hydrated before use`);const{traceParent:s,event:n,traceDataLength:i}=R(this,Cl).call(this,r);return e.runSpan({parent:s,kind:"CONSUMER"},{event:"continuum.handle_payload",...R(this,rr)},a=>{if(Ot(this,bt,Jm).call(this,a,r,"remote"),!n)return Ot(this,bt,Tl).call(this,a,{reason:"decode_error",fromChecksum:R(this,ct),continuumId:!Bm(r)&&!Im(r)?r.charCodeAt(0)&ml:void 0}),!1;if(n.type==="snapshot")return a.record.continuumSnapshotCount(1,"source:remote",R(this,rr)),Ot(this,bt,kb).call(this,a,n.snapshot,[r,i]),!0;if(n.type==="batch"){a.record.continuumBatchSize(n.patches.length,R(this,rr)),a.record.continuumPatchCount(n.patches.length,"source:remote",R(this,rr));for(let c=0;c<n.payloads.length;c++){const h=n.payloads[c],u=n.patches[c],d=Yu(h),[p,f]=Tm(a,u.continuumId,u.expectedChecksum,d);if(!Ot(this,bt,Gm).call(this,a,u,p,f))return!1}return!0}return a.record.continuumPatchCount(1,"source:remote",R(this,rr)),Ot(this,bt,Gm).call(this,a,n,r,i)})}exportSnapshot(){if(!R(this,hi))throw new Error(`ContinuumSignal "${this.name}" must be hydrated before use`);const e={};for(let r=0,s=R(this,Fr).length;r<s;r++){const n=R(this,Sa)[r],i=R(this,Fr)[r];e[n]=i.getState()}return{state:e,headChecksum:R(this,ct)}}encodeSnapshot(e){return Vu(e,this.exportSnapshot(),R(this,js))}onPatch(e){return R(this,Al).add(e),()=>{R(this,Al).delete(e)}}onSnapshot(e){return R(this,El).add(e),()=>{R(this,El).delete(e)}}onDesync(e){return R(this,Ml).add(e),()=>{R(this,Ml).delete(e)}}},o(Ii,"U"),Ii);Fr=new WeakMap,Sa=new WeakMap,ct=new WeakMap,hi=new WeakMap,id=new WeakMap,rr=new WeakMap,js=new WeakMap,Cl=new WeakMap,Sl=new WeakMap,ad=new WeakMap,Al=new WeakMap,El=new WeakMap,Ml=new WeakMap,bt=new WeakSet,Gm=tr(function(t,e,r,s){const n=R(this,Fr)[e.continuumId];if(!n)return Ot(this,bt,Tl).call(this,t,{...e,reason:"invalid_continuum",fromChecksum:R(this,ct)}),!1;const i=Yu(r,s),a=Lh(i,R(this,ct));return a!==e.expectedChecksum?(Ot(this,bt,Tl).call(this,t,{...e,reason:"checksum_mismatch",fromChecksum:R(this,ct),computedChecksum:a}),!1):(R(this,Sl).add(e.patch),n.applyPatch(t,e.patch,[r,s])?(Dt(this,ct,a),Ot(this,bt,Vm).call(this,r,s),!0):(R(this,Sl).delete(e.patch),Ot(this,bt,Tl).call(this,t,{...e,reason:"reducer_rejected",fromChecksum:R(this,ct)}),!1))},"#applyPatch"),kb=tr(function(t,e,r){for(let i=0,a=R(this,Fr).length;i<a;i++){const c=R(this,Sa)[i],h=R(this,Fr)[i],u=e.state[c];R(this,ad).add(u),h.applySnapshot(t,u)}Dt(this,ct,e.headChecksum);const[s,n]=r??Vu(t,e,R(this,js));Ot(this,bt,Ym).call(this,t,e,s,n)},"#applySnapshot"),Cb=tr(function(){for(let t=0;t<R(this,Fr).length;t++){const e=R(this,Fr)[t];e.onPatch((r,s,n)=>{if(R(this,Sl).has(s))return;const i=Yu(n);Dt(this,ct,Lh(i,R(this,ct)));const[a,c]=Tm(r,t,R(this,ct),i);Ot(this,bt,Jm).call(this,r,a,"local"),r.record.continuumPatchCount(1,"source:local",R(this,rr)),Ot(this,bt,Vm).call(this,a,c)}),e.onSnapshot((r,s)=>{if(R(this,ad).has(s))return;const n=this.exportSnapshot(),i=R(this,js).encode(n.state);Dt(this,ct,Lh(i,xc)),n.headChecksum=R(this,ct);const[a,c]=Vu(r,n,R(this,js));r.record.continuumSnapshotCount(1,"source:local",R(this,rr)),Ot(this,bt,Ym).call(this,r,n,a,c)})}},"#subscribeToLocalUpdates"),Vm=tr(function(t,e){for(const r of R(this,Al))r(t,e)},"#emitPatch"),Ym=tr(function(t,e,r,s){for(const n of R(this,El))n(t,e,r,s)},"#emitSnapshot"),Tl=tr(function(t,e){t.record.continuumDesyncCount(1,`reason:${e.reason}`,R(this,rr));for(const r of R(this,Ml))r(e)},"#emitDesync"),Jm=tr(function(t,e,r){let s;Bm(e)?s=`type:batch source:${r}`:Im(e)?s=`type:snapshot source:${r}`:s=`type:patch source:${r}`,t.record.continuumPayloadCount(1,s,R(this,rr)),t.record.continuumPayloadBytes(e.length,s,R(this,rr))},"#recordPayload"),tr(Ab,"ContinuumSignal");let $E=Ab;var kE=Object.defineProperty,Eb=o(t=>{throw TypeError(t)},"B$6"),yn=o((t,e)=>kE(t,"name",{value:e,configurable:!0}),"m$e"),Xm=o((t,e,r)=>e.has(t)||Eb("Cannot "+r),"k$5"),H=o((t,e,r)=>(Xm(t,e,"read from private field"),r?r.call(t):e.get(t)),"n$e"),Ns=o((t,e,r)=>e.has(t)?Eb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"d$9"),zr=o((t,e,r,s)=>(Xm(t,e,"write to private field"),e.set(t,r),r),"l$g"),ui=o((t,e,r)=>(Xm(t,e,"access private method"),r),"_$7"),jt,od,Ls,$t,cd,ld,bn,$n,Fs,Qm,Mb,Tb,Zm,Rb;const eg=Symbol("ABORT_SENTINEL");function Bb(t){return t instanceof Error?t.message.includes("called before connection established")||t.message.includes("no client available after reconnect")||t.message.includes("socket failed unexpectedly")||t.message.includes("socket closed unexpectedly")||t.message.includes("socket did not open correctly"):!1}o(Bb,"J$3"),yn(Bb,"isRecoverableConnectionError");const Ib=(Lo=class{constructor(e,r,s,n,i){Ns(this,Fs),Ns(this,jt),Ns(this,od),Ns(this,Ls),Ns(this,$t),Ns(this,cd),Ns(this,ld),Ns(this,bn,null),Ns(this,$n,null),zr(this,jt,r.hydrate(e,n,"untrusted",i==null?void 0:i.headChecksum)),H(this,jt).onDesync(a=>{e.log.info("continuum_desync",{err:a,signal:H(this,jt).name})}),zr(this,od,s),zr(this,$t,{"continuum.signal":H(this,jt).name}),zr(this,Ls,new Rh((i==null?void 0:i.circuitBreaker)??{})),zr(this,cd,(i==null?void 0:i.shouldReconnect)??(()=>!0)),zr(this,ld,(i==null?void 0:i.distributedTracing)??!0)}get signal(){return H(this,jt)}get headChecksum(){return H(this,jt).headChecksum}get connected(){return H(this,$n)!=null||H(this,bn)!=null}connect(e,r,s){if(H(this,bn)||H(this,$n))throw new Error("[ContinuumSubscriber] Already connected");if(r===void 0&&H(this,jt).paramsSchema!==void 0)throw new Error("[ContinuumSubscriber] Missing params for signal");const n=new AbortController;zr(this,$n,n),e.record.continuumSubscriptionEventCount(1,"event:connect",H(this,$t)),zr(this,bn,(H(this,ld)?e.runSpan({kind:"INTERNAL"},{event:"continuum_subscription"},i=>ui(this,Fs,Qm).call(this,i,n.signal,r,s)):ui(this,Fs,Qm).call(this,e,n.signal,r,s)).finally(()=>{zr(this,$n,null),zr(this,bn,null)})),H(this,bn).catch(i=>{n.signal.aborted||Rr(i)||i===Nc||e.log.error("continuum_subscription_uncaught",{...H(this,$t),err:i})})}async applyInitialStream(e,r){const s=new AbortController;try{e.trace.addEvent("initial_stream_start"),await ui(this,Fs,Zm).call(this,e,s.signal,r),s.signal.aborted||(e.trace.addEvent("initial_stream_ended"),e.record.continuumSubscriptionEventCount(1,"event:initial_stream_end",H(this,$t)))}catch(n){if(s.signal.aborted)return;e.trace.addEvent("initial_stream_error",{err:String(n)}),e.record.continuumSubscriptionEventCount(1,"event:initial_stream_error",H(this,$t))}H(this,Ls).reset()}async disconnect(){const e=H(this,$n),r=H(this,bn);zr(this,$n,null),e==null||e.abort(),await(r==null?void 0:r.catch(()=>{}))}},o(Lo,"D"),Lo);jt=new WeakMap,od=new WeakMap,Ls=new WeakMap,$t=new WeakMap,cd=new WeakMap,ld=new WeakMap,bn=new WeakMap,$n=new WeakMap,Fs=new WeakSet,Qm=yn(async function(t,e,r,s){if(!e.aborted&&(s&&await this.applyInitialStream(t,s),!e.aborted))do{if(!H(this,Ls).check()){await ui(this,Fs,Mb).call(this,t);continue}try{await ui(this,Fs,Tb).call(this,t,e,r)}catch(n){if(e.aborted)break;await ui(this,Fs,Rb).call(this,t,n)}}while(!e.aborted&&H(this,cd).call(this))},"#subscriptionLoop"),Mb=yn(async function(t){t.trace.addEvent("circuit_open",{attempt_count:H(this,Ls).getAttemptCount()}),t.record.continuumSubscriptionEventCount(1,"event:circuit_open",H(this,$t));const e=y();await dc(1e3),t.record.continuumSubscriptionReconnectDelayMs(y()-e,H(this,$t))},"#handleCircuitOpen"),Tb=yn(async function(t,e,r){t.trace.addEvent("stream.connecting",{checksum:H(this,jt).headChecksum});const s=r?{fromChecksum:H(this,jt).headChecksum,params:r}:{fromChecksum:H(this,jt).headChecksum},n=await H(this,od).dispatch(H(this,jt),t,s),i=await ui(this,Fs,Zm).call(this,t,e,n);e.aborted||(t.trace.addEvent("stream.ended",{reason:i}),t.record.continuumSubscriptionEventCount(1,"event:stream_end",H(this,$t))),i==="desync"||i==="continuation_incomplete"?await H(this,Ls).recordFailure():H(this,Ls).recordSuccess()},"#fetchStream"),Zm=yn(async function(t,e,r){var s,n,i;const a=r[Symbol.asyncIterator]();let c="";if(e.aborted)return(s=a.return)==null||s.call(a,void 0),"aborted";const h=Ge(),u=yn(()=>h.__resolve(eg),"abortHandler");e.addEventListener("abort",u,{once:!0});try{for(;;){const d=await Promise.race([a.next(),h]);if(d===eg||d.done)return c.length>0?(t.trace.addEvent("payload_continuation_incomplete",{partial_length:c.length}),"continuation_incomplete"):d===eg?"aborted":"upstream_ended";if(zy(d.value)){t.record.continuumSubscriptionEventCount(1,"event:continuation_frame",H(this,$t)),c+=d.value.slice(1);continue}const p=c?c+d.value:d.value;if(c="",!await H(this,jt).handlePayload(t,p))return t.trace.addEvent("desync_detected"),t.record.continuumSubscriptionEventCount(1,"event:desync",H(this,$t)),"desync"}}finally{e.removeEventListener("abort",u),e.aborted?(n=a.return)==null||n.call(a,null).catch(()=>{}):await((i=a.return)==null?void 0:i.call(a,null))}},"#consumeStream"),Rb=yn(async function(t,e){if(e===Nc)return;Bb(e)?t.log.warn("subscriber_connection_recovering",{...H(this,$t),err:e}):t.log.error("subscriber_connection_error",{...H(this,$t),err:e}),t.record.continuumSubscriptionEventCount(1,"event:error",H(this,$t));const r=y();await H(this,Ls).recordFailure();const s=y()-r;s>0&&t.record.continuumSubscriptionReconnectDelayMs(s,H(this,$t))},"#handleConnectionError"),yn(Ib,"ContinuumSubscriber");let CE=Ib;var SE=Object.defineProperty,AE=o((t,e)=>SE(t,"name",{value:e,configurable:!0}),"c$k");const Hr=l.shape({"continuum.signal":l.str});function qb(){return{continuumPayloadCount:new Q(["type:patch source:local","type:patch source:remote","type:snapshot source:local","type:snapshot source:remote","type:batch source:local","type:batch source:remote"],Hr),continuumPayloadBytes:new Dr(["type:patch source:local","type:patch source:remote","type:snapshot source:local","type:snapshot source:remote","type:batch source:local","type:batch source:remote"],Hr),continuumBatchSize:new Dr(null,Hr),continuumPatchCount:new Q(["source:local","source:remote"],Hr),continuumSnapshotCount:new Q(["source:local","source:remote"],Hr),continuumDesyncCount:new Q(["reason:checksum_mismatch","reason:reducer_rejected","reason:invalid_continuum","reason:decode_error"],Hr),continuumPatchAppliedCount:new Q(null,l.shape({patch:l.str})),continuumPatchRejectedCount:new Q(null,l.shape({patch:l.str,reason:l.str})),continuumSubscriptionEventCount:new Q(["event:connect","event:transport_disconnected","event:stream_end","event:desync","event:error","event:circuit_open","event:continuation_frame","event:initial_stream_end","event:initial_stream_error"],Hr),continuumSubscriptionReconnectDelayMs:new Dr(null,Hr),continuumBroadcasterSubscriptionCount:new vy(null,Hr),continuumBroadcasterSubscribeResultCount:new Q(["result:hit","result:miss"],Hr),continuumBroadcasterSubscribePayloadBytes:new Dr(null,Hr)}}o(qb,"i$a"),AE(qb,"makeContinuumInstruments");var EE=Object.defineProperty,Pb=o(t=>{throw TypeError(t)},"p$b"),tg=o((t,e)=>EE(t,"name",{value:e,configurable:!0}),"c$j"),rg=o((t,e,r)=>e.has(t)||Pb("Cannot "+r),"l$f"),De=o((t,e,r)=>(rg(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$6"),Rl=o((t,e,r)=>e.has(t)?Pb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"o$9"),kn=o((t,e,r,s)=>(rg(t,e,"write to private field"),e.set(t,r),r),"n$d"),xb=o((t,e,r)=>(rg(t,e,"access private method"),r),"v$7"),di,fi,Aa,tt,hd,Wb,Ub;const Db=(Fo=class{constructor(e,r=()=>!1){Rl(this,hd),Rl(this,di),Rl(this,fi),Rl(this,Aa),Rl(this,tt),kn(this,di,e),kn(this,fi,r)}getCurrent(e){const r=xb(this,hd,Wb).call(this,e),s=this.getMinimum();if(!r&&s)return{height:s.height,digest:void 0,expiresAt:s.expiresAt};if(r)return s&&xn(s.height,r.height)?{height:s.height,digest:void 0,expiresAt:s.expiresAt}:r}getPendingTransition(){const e=De(this,di).getPendingTransition(),r=this.getMinimum();if(e&&!(r&&!xn(e.context.height,r.height)))return e}getMinimum(){if(De(this,Aa)&&!De(this,fi).call(this,De(this,Aa).expiresAt))return De(this,Aa)}getDebugState(){var e,r,s;return{has_last_current:!!De(this,tt),last_current_height:(e=De(this,tt))==null?void 0:e.height,last_current_digest:(r=De(this,tt))==null?void 0:r.digest,last_current_expires_at:(s=De(this,tt))==null?void 0:s.expiresAt,last_current_expired:De(this,tt)?De(this,fi).call(this,De(this,tt).expiresAt):void 0}}hasLiveCurrent(){const e=De(this,di).getCurrent();return e?(kn(this,tt,e),!0):!1}setMinimum(e,r){const s=this.getMinimum();s&&rw(e,s.height)||kn(this,Aa,{height:e,expiresAt:r})}waitForCurrent(e){return Rt(De(this,di).waitForCurrent(e),r=>xb(this,hd,Ub).call(this,r))}},o(Fo,"a"),Fo);di=new WeakMap,fi=new WeakMap,Aa=new WeakMap,tt=new WeakMap,hd=new WeakSet,Wb=tg(function(t){const e=De(this,di).getCurrent();if(e)return kn(this,tt,e),e;if(De(this,tt)){if(De(this,fi).call(this,De(this,tt).expiresAt)&&(t==null?void 0:t.allowExpiredRetained)!==!0){kn(this,tt,void 0);return}return De(this,tt)}},"#getCurrentOrRetained"),Ub=tg(function(t){t?kn(this,tt,t):(t=De(this,tt)&&!De(this,fi).call(this,De(this,tt).expiresAt)?De(this,tt):void 0,t||kn(this,tt,void 0));const e=this.getMinimum();return t?e&&xn(e.height,t.height)?{height:e.height,digest:void 0,expiresAt:e.expiresAt}:t:e?{height:e.height,digest:void 0,expiresAt:e.expiresAt}:void 0},"#applyMinimumToSnapshot"),tg(Db,"BlockManager");let ME=Db;var TE=Object.defineProperty,Ob=o(t=>{throw TypeError(t)},"O$6"),ud=o((t,e)=>TE(t,"name",{value:e,configurable:!0}),"S$8"),sg=o((t,e,r)=>e.has(t)||Ob("Cannot "+r),"U$3"),j=o((t,e,r)=>(sg(t,e,"read from private field"),e.get(t)),"i$9"),sr=o((t,e,r)=>e.has(t)?Ob("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"l$e"),zs=o((t,e,r,s)=>(sg(t,e,"write to private field"),e.set(t,r),r),"c$i"),Bl=o((t,e,r)=>(sg(t,e,"access private method"),r),"R$4"),Il,Cn,ql,Pl,xl,Ea,Ma,Wl,Ta,Kr,Gr,Ra,pi,ng,ig,jb;const RE=2e3,BE=1e4,IE=1e4,Nb=(zo=class{constructor(e,r={}){sr(this,pi),sr(this,Il),sr(this,Cn,!1),sr(this,ql),sr(this,Pl),sr(this,xl),sr(this,Ea),sr(this,Ma),sr(this,Wl),sr(this,Ta,new gc(25e3)),sr(this,Kr,new Map),sr(this,Gr,new Map),sr(this,Ra),zs(this,Il,e),zs(this,ql,r.inflightRequestSoftTimeoutMs??RE),zs(this,Pl,r.inflightRequestHardTimeoutMs??BE),zs(this,xl,r.inflightResponseTimeoutMs??IE),zs(this,Ra,new Zw(5*1024*1024)),zs(this,Wl,r.disableLocalMemoryCache??!1),zs(this,Ea,r.cacheContinuum),zs(this,Ma,r.fingerprintResolver)}getFromMemory(e,r,s,n){if(!kf(e)||!Mr(e))return;const i=this.getFromLocalMemory(e);if(i)return i;if(!(!j(this,Ea)||!j(this,Ma)||!r||!s))return Bl(this,pi,ng).call(this,e,r,s,n)}getFromLocalMemory(e){if(j(this,Wl)||!Mr(e))return;const r=j(this,Ta).get(e);if(!(r==null||j(this,Il).isPast(r.expiresAt)))return j(this,Ra).get(r.responseKey)}getFromContinuum(e,r,s,n){if(!(!j(this,Ea)||!j(this,Ma)))return Bl(this,pi,ng).call(this,e,r,s,n)}getInflight(e){if(!(j(this,Cn)||!Mr(e)||Bl(this,pi,ig).call(this,e)===void 0))return Bl(this,pi,jb).call(this,e)}mapRequestToResponse(e,r,s){j(this,Cn)||j(this,Ta).set(e,{responseKey:r,expiresAt:s})}registerInflightRequest(e,r){if(j(this,Cn)||!ah(e))return;let s=j(this,Kr).get(e);if(s){const{deferred:i}=s;s.softExpiresAt=y(+j(this,ql)),clearTimeout(s.hardTimer),s.hardTimer=setTimeout(()=>{i.__isFulfilled()||i.__resolve(void 0),j(this,Kr).delete(e)},j(this,Pl))}else{const i=Ge(),a=y(+j(this,ql)),c=setTimeout(()=>{i.__isFulfilled()||i.__resolve(void 0),j(this,Kr).delete(e)},j(this,Pl));s={deferred:i,softExpiresAt:a,hardTimer:c},j(this,Kr).set(e,s);const h=s;i.finally(()=>{clearTimeout(c),j(this,Kr).get(e)===h&&j(this,Kr).delete(e)}).catch(()=>{})}const{deferred:n}=s;r.then(i=>{n.__isFulfilled()||n.__resolve(i)},i=>{n.__isFulfilled()||n.__reject(i)})}registerInflightResponse(e,r){if(j(this,Cn))return;let s=j(this,Gr).get(e);if(s){const{deferred:i}=s;clearTimeout(s.cleanupTimer),s.cleanupTimer=setTimeout(()=>{i.__isFulfilled()||i.__resolve(void 0),j(this,Gr).delete(e)},j(this,xl))}else{const i=Ge(),a=setTimeout(()=>{i.__isFulfilled()||i.__resolve(void 0),j(this,Gr).delete(e)},j(this,xl));s={deferred:i,cleanupTimer:a},j(this,Gr).set(e,s);const c=s;i.finally(()=>{clearTimeout(a),j(this,Gr).get(e)===c&&j(this,Gr).delete(e)}).catch(()=>{})}const{deferred:n}=s;r.then(i=>{n.__isFulfilled()||n.__resolve(i)},i=>{n.__isFulfilled()||n.__reject(i)})}handleResponse(e,r,s){if(j(this,Cn))return;const n=Ef(r,s??"other");return!j(this,Wl)&&Mf(n)&&(j(this,Ra).set(n,r,Wi(r)),Mr(e)&&r.expiresAt&&this.mapRequestToResponse(e,n,r.expiresAt)),n}destroy(){zs(this,Cn,!0);for(const e of j(this,Kr).values())clearTimeout(e.hardTimer);for(const e of j(this,Gr).values())clearTimeout(e.cleanupTimer);j(this,Ta).clear(),j(this,Kr).clear(),j(this,Gr).clear(),j(this,Ra).clear()}},o(zo,"b"),zo);Il=new WeakMap,Cn=new WeakMap,ql=new WeakMap,Pl=new WeakMap,xl=new WeakMap,Ea=new WeakMap,Ma=new WeakMap,Wl=new WeakMap,Ta=new WeakMap,Kr=new WeakMap,Gr=new WeakMap,Ra=new WeakMap,pi=new WeakSet,ng=ud(function(t,e,r,s){const n=oh(t),i=j(this,Ma).resolve(n,e,r,s);return Rt(i,a=>{if(!a)return;const c=Sf(t),h=Ft(a,c);if(!Mr(h))return;const u=j(this,Ea).readFromCache(h);return Rt(u,d=>{if(d)return cl.decodeUntrusted(d.response)})})},"#getFromContinuum"),ig=ud(function(t){const e=y(),r=j(this,Kr).get(t);if(r&&r.softExpiresAt>e)return r.deferred;const s=j(this,Ta).get(t);if(s&&!j(this,Il).isPast(s.expiresAt)){const n=j(this,Gr).get(s.responseKey);if(n)return n.deferred}},"#getInflightEntry"),jb=ud(async function(t){for(;;){const e=Bl(this,pi,ig).call(this,t);if(e===void 0)return;const r=await e;if(r!==void 0)return r}},"#awaitInflight"),ud(Nb,"CacheLayer");let qE=Nb;var PE=Object.defineProperty,Lb=o(t=>{throw TypeError(t)},"m$b"),ag=o((t,e)=>PE(t,"name",{value:e,configurable:!0}),"p$a"),Fb=o((t,e,r)=>e.has(t)||Lb("Cannot "+r),"u$c"),mi=o((t,e,r)=>(Fb(t,e,"read from private field"),r?r.call(t):e.get(t)),"h$9"),zb=o((t,e,r)=>e.has(t)?Lb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"a$b"),dd=o((t,e,r)=>(Fb(t,e,"access private method"),r),"n$c"),Hs,Ba,fd,Hb;const Kb=(Ho=class{constructor(e){zb(this,Ba),zb(this,Hs,new Map);for(const r of e.iterate())dd(this,Ba,fd).call(this,r);e.onAdded(r=>{for(const s of r)dd(this,Ba,fd).call(this,s)}),e.onRemoved(r=>{for(const s of r)dd(this,Ba,Hb).call(this,s)}),e.onReplacement(r=>{mi(this,Hs).clear();for(const s of r)dd(this,Ba,fd).call(this,s)})}resolve(e,r,s,n){const i=mi(this,Hs).get(e);if(!(!i||i.length===0))return i.length===1?i[0]:Aw(r,s,n)}hasFingerprint(e){const r=mi(this,Hs).get(e);return!!r&&r.length>0}},o(Ho,"g"),Ho);Hs=new WeakMap,Ba=new WeakSet,fd=ag(function(t){const e=$f(t),r=mi(this,Hs).get(e);r?r.push(t):mi(this,Hs).set(e,[t])},"#addFingerprint"),Hb=ag(function(t){const e=$f(t),r=mi(this,Hs).get(e);if(r){const s=r.indexOf(t);s>=0&&r.splice(s,1),r.length===0&&mi(this,Hs).delete(e)}},"#removeFingerprint"),ag(Kb,"FingerprintResolver");let Gb=Kb;var xE=Object.defineProperty,Ia=o((t,e)=>xE(t,"name",{value:e,configurable:!0}),"r$a");function og(t){return(t==null?void 0:t.client)??"warn"}o(og,"a$a"),Ia(og,"getClientLogLevel");function cg(t){return(t==null?void 0:t.requests)??"off"}o(cg,"c$g"),Ia(cg,"getRequestLogging");function Vb(t){switch(t){case"fatal":return"error";case"verbose":return"debug";case"debug":case"info":case"warn":case"error":return t;default:return"info"}}o(Vb,"f$9"),Ia(Vb,"normalizeClientLogEventLevel");function Yb(t){return t.name==="request_resolution"||t.name==="request_pipeline_resolution"?t.level==="debug"?"[direct:REQUEST_DEBUG]":"[direct:REQUEST]":t.name==="request_handled"?"[direct:REQUEST_DEBUG]":`[direct:${t.level.toUpperCase()}]`}o(Yb,"d$6"),Ia(Yb,"getConsolePrefix");function Jb(t){console[t.level](Yb(t),t.name,t.value)}o(Jb,"t$4"),Ia(Jb,"defaultLogEventListener");function qa(t,e,r,s,n=y()){(t??Jb)({level:e,name:r,value:s,timestamp:n})}o(qa,"E$9"),Ia(qa,"emitLogEvent");var WE=Object.defineProperty,Xb=o(t=>{throw TypeError(t)},"c$f"),UE=o((t,e)=>WE(t,"name",{value:e,configurable:!0}),"m$a"),Qb=o((t,e,r)=>e.has(t)||Xb("Cannot "+r),"a$9"),DE=o((t,e,r)=>(Qb(t,e,"read from private field"),r?r.call(t):e.get(t)),"l$b"),OE=o((t,e,r)=>e.has(t)?Xb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"v$5"),jE=o((t,e,r,s)=>(Qb(t,e,"write to private field"),e.set(t,r),r),"u$b"),pd;const Zb=(Ko=class extends pA{constructor(e={}){super(),OE(this,pd),jE(this,pd,e.onEvent)}log(e,r,s,n,i,a){const c={...a,...i};qa(DE(this,pd),Vb(e),s,c,r)}trace(){}metrics(){}async flush(){}},o(Ko,"i"),Ko);pd=new WeakMap,UE(Zb,"ConsoleExporter");let e$=Zb;var NE=Object.defineProperty,t$=o(t=>{throw TypeError(t)},"L$5"),r$=o((t,e)=>NE(t,"name",{value:e,configurable:!0}),"k$3"),lg=o((t,e,r)=>e.has(t)||t$("Cannot "+r),"B$5"),re=o((t,e,r)=>(lg(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$5"),Ks=o((t,e,r)=>e.has(t)?t$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"n$b"),Sn=o((t,e,r,s)=>(lg(t,e,"write to private field"),e.set(t,r),r),"l$a"),s$=o((t,e,r)=>(lg(t,e,"access private method"),r),"E$7"),n$=o((t,e,r,s)=>({set _(n){Sn(t,e,n)},get _(){return re(t,e,s)}}),"y$5"),ds,gi,wi,vi,Gs,_i,yi,md,gd,hg;const i$=(Go=class{constructor(e){Ks(this,gd),Ks(this,ds),Ks(this,gi,new Map),Ks(this,wi,new Map),Ks(this,vi,{upload:0,download:0}),Ks(this,Gs,{}),Ks(this,_i,0),Ks(this,yi),Ks(this,md),Sn(this,ds,{networkId:e.networkId,softEntryLimit:e.softEntryLimit??100,softFlushIntervalMs:e.softFlushIntervalMs??2e3,hardFlushIntervalMs:e.hardFlushIntervalMs??6e4,onFlush:e.onFlush??(()=>{}),onBandwidthEstimate:e.onBandwidthEstimate??(()=>{})})}get entryCount(){return re(this,_i)}hasData(){return re(this,gi).size>0||re(this,wi).size>0||re(this,vi).upload>0||re(this,vi).download>0||Object.keys(re(this,Gs)).length>0}isSoftLimitReached(){return re(this,_i)>=re(this,ds).softEntryLimit||re(this,yi)!==void 0&&y()-re(this,yi)>=re(this,ds).softFlushIntervalMs}collectCacheHit(e,r){var s,n;s$(this,gd,hg).call(this);let i=re(this,gi).get(e);i||(i=new Map,re(this,gi).set(e,i));let a=i.get(r.requestId);a||(a={requestMethod:r.requestMethod,requestId:r.requestId,requestSizeInBytes:r.requestSizeInBytes,perBlockMetrics:{}},i.set(r.requestId,a));const c=((s=r.blockContext)==null?void 0:s.digest)||"__unknown__";let h=a.perBlockMetrics[c];h||(h={blockHeight:(n=r.blockContext)==null?void 0:n.height,responseSizeInBytes:r.responseSizeInBytes,responseKey:r.responseKey,timestamp:y(),latencyMs:[]},a.perBlockMetrics[c]=h),h.latencyMs.push(r.latencyMs),n$(this,_i)._++}collectUpstreamLatency(e,r){s$(this,gd,hg).call(this);let s=re(this,wi).get(e);s||(s=[],re(this,wi).set(e,s)),s.push(r),n$(this,_i)._++}collectBandwidthEstimateHeaders(e,r){r<=0||(re(this,vi)[e]+=r,re(this,ds).onBandwidthEstimate({type:"headers",direction:e,bytes:r}))}collectBandwidthEstimatePayload(e,r,s,n){n<=0||(re(this,Gs)[e]??={},re(this,Gs)[e][r]??={},re(this,Gs)[e][r][s]??=0,re(this,Gs)[e][r][s]+=n,re(this,ds).onBandwidthEstimate({type:"payload",target:e,stage:r,direction:s,bytes:n}))}maybeConsume(){if(this.isSoftLimitReached())return this.consume()}consume(){if(!this.hasData())return;clearTimeout(re(this,md));const e={};for(const[n,i]of re(this,gi))e[n]=Array.from(i.values());const r={};for(const[n,i]of re(this,wi))r[n]=i;const s={networkId:re(this,ds).networkId,cacheHits:e,upstreamResponseTimesMs:r,bandwidthEstimate:{headers:re(this,vi),payload:re(this,Gs)}};return re(this,gi).clear(),re(this,wi).clear(),Sn(this,vi,{upload:0,download:0}),Sn(this,Gs,{}),Sn(this,_i,0),Sn(this,yi,void 0),s}},o(Go,"z"),Go);ds=new WeakMap,gi=new WeakMap,wi=new WeakMap,vi=new WeakMap,Gs=new WeakMap,_i=new WeakMap,yi=new WeakMap,md=new WeakMap,gd=new WeakSet,hg=r$(function(){re(this,yi)===void 0&&(Sn(this,yi,y()),Sn(this,md,setTimeout(()=>{const t=this.consume();t&&re(this,ds).onFlush(t)},re(this,ds).hardFlushIntervalMs)))},"#openWindow"),r$(i$,"TelemetryCollector");let LE=i$;const FE="https://rpc.direkt.dev",zE={ethereum:["https://eth.drpc.org","https://ethereum-rpc.publicnode.com","https://mainnet.gateway.tenderly.co","https://eth.api.pocket.network","https://eth.llamarpc.com/"],"ethereum-holesky":["https://ethereum-holesky-rpc.publicnode.com"],"ethereum-sepolia":["https://sepolia.drpc.org"],sonic:["https://rpc.soniclabs.com","https://sonic.drpc.org","https://sonic.api.pocket.network","https://sonic-rpc.publicnode.com"],"sonic-testnet":["https://rpc.testnet.soniclabs.com"],"sonic-blaze-testnet":["https://rpc.blaze.soniclabs.com"]},HE=.07,KE=600,GE=300;var VE=Object.defineProperty,wd=o((t,e)=>VE(t,"name",{value:e,configurable:!0}),"s$a");function a$(t){const e={method:t.method,latency_ms:t.latency_ms};return t.resolution_source&&!(t.resolution_source==="pipeline"&&t.stage_name)&&(e.resolution_source=t.resolution_source),t.stage_name&&(e.stage_name=t.stage_name),t.stage_type&&(e.stage_type=t.stage_type),e}o(a$,"o$7"),wd(a$,"compactSummaryPayload");function o$(t,e,r){t==="debug"&&qa(r,"debug","request_pipeline_resolution",e)}o(o$,"r$7"),wd(o$,"logRequestPipelineResolution");function c$(t,e,r){t==="summary"?qa(r,"info","request_resolution",a$(e)):t==="debug"&&qa(r,"debug","request_resolution",e)}o(c$,"g$4"),wd(c$,"logRequestResolution");function l$(t,e,r){qa(r,"debug",t,e)}o(l$,"m$8"),wd(l$,"logRequestDebug");var h$=Object.defineProperty,u$=o(t=>{throw TypeError(t)},"k$2"),YE=o((t,e,r)=>e in t?h$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"y$4"),Ul=o((t,e)=>h$(t,"name",{value:e,configurable:!0}),"a$7"),Pa=o((t,e,r)=>YE(t,typeof e!="symbol"?e+"":e,r),"s$9"),JE=o((t,e,r)=>e.has(t)||u$("Cannot "+r),"m$7"),XE=o((t,e,r)=>e.has(t)?u$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"f$7"),d$=o((t,e,r)=>(JE(t,e,"access private method"),r),"d$5"),vd,f$,p$;const m$=(Vo=class{constructor(){XE(this,vd),Pa(this,"name","block_state_cache"),Pa(this,"type","cache"),Pa(this,"origin","client"),Pa(this,"strategy","first_eligible"),Pa(this,"failover"),Pa(this,"handlers");const e=this;this.handlers=[new sn({name:"block_state_cache",circuitBreaker:!1,claim:Ul((r,s)=>r.map(n=>{var i;return d$(i=e,vd,p$).call(i,n,s)}),"claim"),fulfill:Ul(r=>r.map(([,s])=>s),"fulfill")})]}},o(Vo,"n"),Vo);vd=new WeakSet,f$=Ul(function(t){return!t.block||!t.secondaryBlock?t.block??t.secondaryBlock:xn(t.secondaryBlock.height,t.block.height)?t.secondaryBlock:t.block},"#getBestBlock"),p$=Ul(function(t,e){const r=t.input.requestBody.id;if(r===void 0||t.input.requestMethod!=="eth_blockNumber")return;const s=t.input.requestBody.params;if(Array.isArray(s)&&s.length>0)return;const n=d$(this,vd,f$).call(this,e);if(n!=null&&n.height)return[{id:r,result:n.height},{}]},"#readFromBlockState"),Ul(m$,"ClientBlockStateCacheStage");let QE=m$;var g$=Object.defineProperty,w$=o(t=>{throw TypeError(t)},"g$3"),ZE=o((t,e,r)=>e in t?g$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"I$7"),_d=o((t,e)=>g$(t,"name",{value:e,configurable:!0}),"c$b"),xa=o((t,e,r)=>ZE(t,typeof e!="symbol"?e+"":e,r),"s$8"),ug=o((t,e,r)=>e.has(t)||w$("Cannot "+r),"l$9"),v$=o((t,e,r)=>(ug(t,e,"read from private field"),r?r.call(t):e.get(t)),"o$6"),_$=o((t,e,r)=>e.has(t)?w$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"a$6"),e1=o((t,e,r,s)=>(ug(t,e,"write to private field"),e.set(t,r),r),"v$4"),t1=o((t,e,r)=>(ug(t,e,"access private method"),r),"m$6"),Dl,dg,y$;const b$=(Yo=class{constructor(e){_$(this,dg),xa(this,"name","inflight_cache"),xa(this,"type","cache"),xa(this,"origin","client"),xa(this,"strategy","first_eligible"),xa(this,"failover",{}),xa(this,"handlers"),_$(this,Dl),e1(this,Dl,e);const r=this;this.handlers=[new sn({name:"inflight_cache",circuitBreaker:!1,racing:{timeoutMs:1500},claim:_d(s=>s.map(n=>{var i;return t1(i=r,dg,y$).call(i,n)}),"claim"),fulfill:_d(s=>s.map(([,n])=>n),"fulfill")})]}},o(Yo,"h"),Yo);Dl=new WeakMap,dg=new WeakSet,y$=_d(function(t){const e=t.input.requestBody.id;if(e===void 0)return;const r=v$(this,Dl).getInflight(t.input.requestId);if(r)return r.then(s=>s?[{...s,id:e},{}]:void 0);Mr(t.input.requestId)&&v$(this,Dl).registerInflightRequest(t.input.requestId,t.deferred)},"#deduplicateRequest"),_d(b$,"ClientInflightCacheStage");let r1=b$;var $$=Object.defineProperty,k$=o(t=>{throw TypeError(t)},"H$1"),s1=o((t,e,r)=>e in t?$$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"L$4"),bi=o((t,e)=>$$(t,"name",{value:e,configurable:!0}),"n$8"),Wa=o((t,e,r)=>s1(t,typeof e!="symbol"?e+"":e,r),"c$a"),fg=o((t,e,r)=>e.has(t)||k$("Cannot "+r),"f$5"),pg=o((t,e,r)=>(fg(t,e,"read from private field"),r?r.call(t):e.get(t)),"m$5"),C$=o((t,e,r)=>e.has(t)?k$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"q$4"),n1=o((t,e,r,s)=>(fg(t,e,"write to private field"),e.set(t,r),r),"I$6"),S$=o((t,e,r)=>(fg(t,e,"access private method"),r),"v$3"),Ua,yd,A$,E$;const M$=(Jo=class{constructor(e){C$(this,yd),Wa(this,"name","memory_cache"),Wa(this,"type","cache"),Wa(this,"origin","client"),Wa(this,"strategy","first_eligible"),Wa(this,"failover"),Wa(this,"handlers"),C$(this,Ua),n1(this,Ua,e);const r=this;this.handlers=[new sn({name:"local_memory_cache",circuitBreaker:!1,claim:bi(s=>s.map(n=>{var i;return S$(i=r,yd,A$).call(i,n)}),"claim"),fulfill:bi(s=>s.map(([,n])=>n),"fulfill")}),new sn({name:"continuum_cache",circuitBreaker:!1,claim:bi((s,n)=>s.map(i=>{var a;return S$(a=r,yd,E$).call(a,i,n)}),"claim"),fulfill:bi(s=>s.map(([,n])=>n),"fulfill")})]}},o(Jo,"B"),Jo);Ua=new WeakMap,yd=new WeakSet,A$=bi(function(t){const e=t.input.requestBody.id;if(e===void 0)return;const r=pg(this,Ua).getFromLocalMemory(t.input.requestId);if(r)return[{...r,id:e},{}]},"#readFromLocalMemory"),E$=bi(function(t,e){var r,s;const n=t.input.requestBody.id,i=t.input.requestMethod,a=(r=e.block)==null?void 0:r.height,c=(s=e.secondaryBlock)==null?void 0:s.height;let h=a??c;if(a&&c&&(h=xn(c,a)?c:a),n===void 0)return;const u=pg(this,Ua).getFromContinuum(t.input.requestId,t.input.requestBody,i,h);return Rt(u,d=>{if(d)return[{...d,id:n},{}];t.deferred.then(p=>{p&&"result"in p&&pg(this,Ua).handleResponse(t.input.requestId,p,t.input.requestMethod)})})},"#readFromContinuum"),bi(M$,"ClientMemoryCacheStage");let i1=M$;const mg=512e3,T$=7168,bd=15,Ol=750,fs=1e4,R$=3e4,gg=3e4;var a1=Object.defineProperty,B$=o(t=>{throw TypeError(t)},"F$3"),gt=o((t,e)=>a1(t,"name",{value:e,configurable:!0}),"n$7"),wg=o((t,e,r)=>e.has(t)||B$("Cannot "+r),"q$3"),J=o((t,e,r)=>(wg(t,e,"read from private field"),e.get(t)),"r$6"),Vr=o((t,e,r)=>e.has(t)?B$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"c$9"),An=o((t,e,r,s)=>(wg(t,e,"write to private field"),e.set(t,r),r),"g$2"),En=o((t,e,r)=>(wg(t,e,"access private method"),r),"b$4"),$r,kr,$d,kd,$i,vg,Cd,Da,Mn,Sd,ps,I$,q$,P$,x$,W$,U$,D$,O$;const _g=65535,o1=_g+1,j$=(Xo=class extends sn{constructor(e,r){const s=r.shouldTripBreaker!==void 0;super({name:r.nodeUrl,racing:r.racing,claim:gt((n,i,a)=>En(this,ps,I$).call(this,n,i,a),"claim"),fulfill:gt(n=>En(this,ps,P$).call(this,n),"fulfill"),circuitBreaker:s?!1:r.circuitBreaker}),Vr(this,ps),Vr(this,$r),Vr(this,kr),Vr(this,$d),Vr(this,kd),Vr(this,$i,new Map),Vr(this,vg,{"Content-Type":"application/json"}),Vr(this,Cd,0),Vr(this,Da),Vr(this,Mn),Vr(this,Sd),s&&(An(this,Mn,new Rh({halfOpenAttempts:3,halfClosedAttempts:8,cooldownMs:3e4})),An(this,Sd,r.shouldTripBreaker)),An(this,$r,e.with({"component.id":"JsonUpstreamHandler","component.node_url":r.nodeUrl})),An(this,kr,r.nodeUrl),An(this,$d,r.fetch??globalThis.fetch.bind(globalThis)),An(this,Da,{origin:"client",handler:"json_upstream",node_url:J(this,kr)}),An(this,kd,new dv({framing:TC,maxSizeInBytes:r.maxSizeInBytes??512e3,windowMs:r.windowMs??15,timeoutMs:r.timeoutMs??1e4},{prepareContext:gt(()=>En(this,ps,W$).call(this),"prepareContext"),openRequest:gt((n,i,a,c)=>En(this,ps,U$).call(this,n,i,c),"openRequest")},{onBatchError:gt((n,i)=>{J(this,$r).log.debug("batch_error",{error:i,nodeUrl:J(this,kr)})},"onBatchError")}))}getHealth(){var e;return((e=J(this,Mn))==null?void 0:e.getState())??super.getHealth()}},o(Xo,"D"),Xo);$r=new WeakMap,kr=new WeakMap,$d=new WeakMap,kd=new WeakMap,$i=new WeakMap,vg=new WeakMap,Cd=new WeakMap,Da=new WeakMap,Mn=new WeakMap,Sd=new WeakMap,ps=new WeakSet,I$=gt(function(t,e,r){return t.map(s=>En(this,ps,q$).call(this,s,r))},"#claim"),q$=gt(function(t,e){J(this,$r).log.debug("request_route_probe",{phase:"claimed",handler:"json_upstream",target:J(this,kr),method:t.input.requestMethod,request_id:t.input.requestBody.id,request:Ed(t.input.requestBody)});const{id:r,deferred:s}=En(this,ps,D$).call(this),n=J(this,kd).write(cc.encode(JSON.stringify(En(this,ps,O$).call(this,t.input.requestBody,r))),{},e);if(!n){J(this,$r).log.debug("request_route_probe",{phase:"failed",handler:"json_upstream",target:J(this,kr),reason:"write_rejected",method:t.input.requestMethod,request_id:t.input.requestBody.id,request:Ed(t.input.requestBody)}),s.__resolve(ks(null,"SERVER_ERROR",J(this,Da)));return}const[i,a]=n;return a.batch.push(r),a.methods.push(t.input.requestMethod),i.then(()=>[s,{}]).catch(c=>{throw J(this,$r).log.debug("request_route_probe",{phase:"failed",handler:"json_upstream",target:J(this,kr),reason:"claim_rejected",method:t.input.requestMethod,request_id:t.input.requestBody.id,request:Ed(t.input.requestBody),error:String(c)}),s.__isFulfilled()||(s.catch(()=>{}),s.__reject(c)),c})},"#claimItem"),P$=gt(function(t){return t.map(e=>En(this,ps,x$).call(this,e))},"#fulfill"),x$=gt(function([t,e]){const r=t.input.requestBody.id;return r===void 0?Promise.resolve(void 0):e.then(s=>s!==void 0?{...s,id:r}:void 0)},"#fulfillItem"),W$=gt(function(){return{nodeUrl:J(this,kr),batch:[],methods:[]}},"#prepareBatchContext"),U$=gt(function(t,e,r){if(r.aborted)throw new Error("JsonUpstreamHandler.#openBatch: Batch aborted before dispatch");return J(this,$d).call(this,J(this,kr),{method:"POST",headers:J(this,vg),signal:r,...t}).then(s=>({bodyPromise:s.text().then(n=>{var i;let a;try{a=JSON.parse(n)}catch{const u=n.slice(0,100);throw J(this,$r).log.debug("non_json_response",{preview:u}),new Error(`Response is not valid JSON: ${u}`)}const c=L$(a,e.batch.length);if(c===Bc)throw J(this,$r).log.debug("invalid_response_data",{error:Wh.lastMessage}),new Error(Wh.lastMessage);const h=new Map;for(const u of c)h.set(u.id,u);for(const u of e.batch){const d=J(this,$i).get(u);if(d){const p=h.get(u);p?d.__resolve(p):(d.__resolve(ks(u,"NO_RESPONSE",J(this,Da))),J(this,$r).log.debug("missing_response_data",{request_id:u,response_ids:Array.from(h.keys())}))}}return J(this,Mn)&&(((i=J(this,Sd))==null?void 0:i.call(this,s,c))??!1?J(this,Mn).recordFailure():J(this,Mn).recordSuccess()),{downloadSizeInBytes:n.length,itemCount:e.batch.length}}).catch(n=>{var i;(i=J(this,Mn))==null||i.recordFailure(),J(this,$r).log.debug("batch_failed",{err:n,nodeUrl:J(this,kr),request_methods:e.methods,request_ids:e.batch});for(let c=0;c<e.batch.length;c++)J(this,$r).log.debug("request_route_probe",{phase:"failed",handler:"json_upstream",target:J(this,kr),reason:"batch_failed",method:e.methods[c],request_id:e.batch[c],error:String(n)});const a=n instanceof Error?n:new Error(String(n));for(const c of e.batch){const h=J(this,$i).get(c);h&&!h.__isFulfilled()&&(h.catch(()=>{}),h.__reject(a))}return{downloadSizeInBytes:0,itemCount:e.batch.length}})}))},"#openBatch"),D$=gt(function(){let t=J(this,Cd),e=0;for(;J(this,$i).has(t);)if(t=t+1&_g,++e>=o1)throw new Error("JsonUpstreamHandler.#openPendingRequest: Deferred ID pool exhausted");An(this,Cd,t+1&_g);const r=Ge(),s=setTimeout(()=>{r.__resolve(ks(t,"UPSTREAM_TIMEOUT",J(this,Da)))},8e3),n=gt(()=>{clearTimeout(s),J(this,$i).delete(t)},"cleanup");return r.then(n,n),J(this,$i).set(t,r),{id:t,deferred:r}},"#openPendingRequest"),O$=gt(function(t,e){return t.method==="direct_getTransactionReceipt"?{id:e,method:"eth_getTransactionReceipt",params:Array.isArray(t.params)?t.params.slice(0,1):[""],jsonrpc:"2.0"}:{id:e,method:t.method,params:t.params,jsonrpc:"2.0"}},"#normalizeRequest"),gt(j$,"JsonUpstreamHandler");let Ad=j$;const N$=ke("response",l.arr(cl)),c1=ke("response",cl);function L$(t,e){if(Array.isArray(t))return N$.safeParse(t);if(e===1){const r=c1.safeParse(t);return r===Bc?Bc:[r]}return N$.safeParse(t)}o(L$,"ne$1"),gt(L$,"parseResponseData");function Ed(t){const e={method:t.method};if(t.method==="eth_getLogs"){const[r]=Array.isArray(t.params)?t.params:[];return r&&typeof r=="object"&&(e.from_block="fromBlock"in r?r.fromBlock:void 0,e.to_block="toBlock"in r?r.toBlock:void 0),e}return t.method==="eth_getBlockByNumber"||t.method==="eth_getBlockByHash"?(e.block_param=Array.isArray(t.params)?t.params[0]:void 0,e.full_transactions=Array.isArray(t.params)?t.params[1]===!0:!1,e):(e.params=t.params,e)}o(Ed,"O$4"),gt(Ed,"summarizeRequest");var l1=Object.defineProperty,F$=o(t=>{throw TypeError(t)},"j$2"),Tn=o((t,e)=>l1(t,"name",{value:e,configurable:!0}),"k"),yg=o((t,e,r)=>e.has(t)||F$("Cannot "+r),"N$1"),qe=o((t,e,r)=>(yg(t,e,"read from private field"),r?r.call(t):e.get(t)),"i$6"),jl=o((t,e,r)=>e.has(t)?F$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"I$4"),Md=o((t,e,r,s)=>(yg(t,e,"write to private field"),e.set(t,r),r),"q$2"),Oa=o((t,e,r)=>(yg(t,e,"access private method"),r),"S$4"),ms,ja,gs,ws,Rn,z$,H$,Td,K$;const G$=(Qo=class extends sn{constructor(e,r){super({name:"wire_http",racing:{claimMs:Ol,timeoutMs:fs},circuitBreaker:{halfClosedAttempts:1,halfOpenAttempts:1,cooldownMs:R$},claim:Tn((s,n)=>Oa(this,Rn,z$).call(this,s,n),"claim"),fulfill:Tn(s=>Oa(this,Rn,K$).call(this,s),"fulfill")}),jl(this,Rn),jl(this,ms),jl(this,ja),jl(this,gs),jl(this,ws),Md(this,ms,e.with({"component.id":"WireHTTPUpstreamHandler"})),Md(this,ja,r.channel),Md(this,gs,r.isPrimary),Md(this,ws,r.isShadow??!1)}},o(Qo,"L"),Qo);ms=new WeakMap,ja=new WeakMap,gs=new WeakMap,ws=new WeakMap,Rn=new WeakSet,z$=Tn(function(t,e){if(t.length===0)return[];const r=[],s=[],n=[];for(let a=0;a<t.length;a++){const c=t[a];if(c){if(Wn(c.input.requestBody)){qe(this,ms).log.debug("request_route_probe",{phase:"declined",handler:"wire_http",target:qe(this,gs)?"primary":qe(this,ws)?"secondary_shadow":"secondary",reason:"slow_request",method:c.input.requestMethod,request_id:c.input.requestBody.id,request:Nl(c.input.requestBody)});continue}qe(this,ms).log.debug("request_route_probe",{phase:"claimed",handler:"wire_http",target:qe(this,gs)?"primary":qe(this,ws)?"secondary_shadow":"secondary",method:c.input.requestMethod,request_id:c.input.requestBody.id,request:Nl(c.input.requestBody)}),s.push(c),n.push(a)}}if(s.length===0)return r;const i=Oa(this,Rn,H$).call(this,s,e);for(let a=0;a<n.length;a++){const c=n[a],h=i[a];c!==void 0&&h!==void 0&&(r[c]=h)}return r},"#claim"),H$=Tn(function(t,e){var r,s;if(t.length===0)return[];const n=t.map(u=>u.input.requestBody),i=Ge(),a=qe(this,gs)?e.block:e.secondaryBlock??e.block;let c;if(a&&(c=qe(this,gs)?{height:a.height,digest:a.digest}:{height:a.height,expiresAt:a.expiresAt}),!qe(this,gs)&&n.some(Wn)){const u=[],d=[],p=[];if(n.forEach((f,g)=>{var m;if(!Wn(f)){d.push(f),p.push(g);return}qe(this,ms).log.debug("request_route_probe",{phase:"claimed",handler:"wire_http",target:qe(this,ws)?"secondary_shadow":"secondary",reason:"isolated_slow_request",method:f.method,request_id:f.id,request:Nl(f)});const w=Ge(),_=qe(this,ja).request.rpc(qe(this,ms),{networkId:e.networkId,requests:[f],shadow:!!qe(this,ws),bypass:e.bypass,routingToken:(m=e.routing)==null?void 0:m.token,block:c},"pipeline",w),[S]=Oa(this,Rn,Td).call(this,[f],_);S!==void 0&&(u[g]=w.then(()=>[S,{}]))}),d.length>0){const f=Ge(),g=qe(this,ja).request.rpc(qe(this,ms),{networkId:e.networkId,requests:d,shadow:!!qe(this,ws),bypass:e.bypass,routingToken:(r=e.routing)==null?void 0:r.token,block:c},"pipeline",f),m=Oa(this,Rn,Td).call(this,d,g);for(let w=0;w<p.length;w++){const _=p[w],S=m[w];_!==void 0&&S!==void 0&&(u[_]=f.then(()=>[S,{}]))}}return u}const h=qe(this,ja).request.rpc(qe(this,ms),{networkId:e.networkId,requests:n,shadow:!!qe(this,ws),bypass:e.bypass,routingToken:qe(this,gs)||(s=e.routing)==null?void 0:s.token,block:c},"pipeline",i);return Oa(this,Rn,Td).call(this,n,h).map(u=>i.then(()=>[u,{}]))},"#claimEligible"),Td=Tn(function(t,e){var r,s;const n=t.map(()=>Ge()),i=new Map;for(let a=0;a<t.length;a++){const c=(r=t[a])==null?void 0:r.id;c===void 0?(s=n[a])==null||s.__resolve(void 0):i.set(c,a)}return(async()=>{var a,c,h,u,d,p,f,g;try{for await(const m of e){const w=i.get(m.id);w!==void 0&&((a=n[w])!=null&&a.__isFulfilled()||(c=n[w])==null||c.__resolve(m),i.delete(m.id))}for(const[m,w]of i)(h=n[w])!=null&&h.__isFulfilled()||(u=n[w])==null||u.__resolve(ks(m,"NO_RESPONSE",{origin:"client",handler:"wire_http"}))}catch(m){const w=m instanceof Error?m:new Error(String(m));for(const[_,S]of i)qe(this,ms).log.debug("request_route_probe",{phase:"failed",handler:"wire_http",target:qe(this,gs)?"primary":qe(this,ws)?"secondary_shadow":"secondary",reason:"response_stream_error",method:(d=t[S])==null?void 0:d.method,request_id:_,request:t[S]?Nl(t[S]):void 0,error:String(m)}),(p=n[S])!=null&&p.__isFulfilled()||((f=n[S])==null||f.catch(()=>{}),(g=n[S])==null||g.__reject(w))}})(),n},"#createResponsePromises"),K$=Tn(function(t){return t.map(([,e])=>e)},"#fulfill"),Tn(G$,"WireHTTPUpstreamHandler");let V$=G$;function Nl(t){const e={method:t.method};if(t.method==="eth_getLogs"){const[r]=Array.isArray(t.params)?t.params:[];return r&&typeof r=="object"&&(e.from_block="fromBlock"in r?r.fromBlock:void 0,e.to_block="toBlock"in r?r.toBlock:void 0,e.has_address="address"in r?!!r.address:!1,e.has_topics="topics"in r?!!r.topics:!1),e}return t.method==="eth_getBlockByNumber"||t.method==="eth_getBlockByHash"?(e.block_param=Array.isArray(t.params)?t.params[0]:void 0,e.full_transactions=Array.isArray(t.params)?t.params[1]===!0:!1,e):(e.params=t.params,e)}o(Nl,"O$3"),Tn(Nl,"summarizeRequest");var h1=Object.defineProperty,Y$=o(t=>{throw TypeError(t)},"O$2"),Vs=o((t,e)=>h1(t,"name",{value:e,configurable:!0}),"a$4"),bg=o((t,e,r)=>e.has(t)||Y$("Cannot "+r),"B$2"),Bn=o((t,e,r)=>(bg(t,e,"read from private field"),r?r.call(t):e.get(t)),"d$3"),$g=o((t,e,r)=>e.has(t)?Y$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"b$3"),J$=o((t,e,r,s)=>(bg(t,e,"write to private field"),e.set(t,r),r),"R$2"),ki=o((t,e,r)=>(bg(t,e,"access private method"),r),"c$8"),In,Na,Ys,X$,Q$,Z$,Ll;const ek=(Zo=class extends sn{constructor(e,r){super({name:"wire_socket",racing:{checkMs:100,timeoutMs:fs},circuitBreaker:{halfClosedAttempts:1,halfOpenAttempts:1,cooldownMs:R$},check:Vs(()=>ki(this,Ys,X$).call(this),"check"),claim:Vs((s,n)=>ki(this,Ys,Q$).call(this,s,n),"claim"),fulfill:Vs((s,n)=>ki(this,Ys,Z$).call(this,s,n),"fulfill")}),$g(this,Ys),$g(this,In),$g(this,Na),J$(this,In,e.with({"component.id":"WireSocketUpstreamHandler"})),J$(this,Na,r.channel)}},o(Zo,"E"),Zo);In=new WeakMap,Na=new WeakMap,Ys=new WeakSet,X$=Vs(function(){return ki(this,Ys,Ll).call(this)},"#check"),Q$=Vs(function(t,e){return!ki(this,Ys,Ll).call(this)||!e.wireSocketReady?t.map(r=>{Bn(this,In).log.debug("request_route_probe",{phase:"declined",handler:"wire_socket",target:"primary",reason:ki(this,Ys,Ll).call(this)?"socket_sync_not_ready":"socket_not_ready",method:r.input.requestMethod,request_id:r.input.requestBody.id,request:Fl(r.input.requestBody)})}):t.map(r=>{if(Wn(r.input.requestBody)){Bn(this,In).log.debug("request_route_probe",{phase:"declined",handler:"wire_socket",target:"primary",reason:"slow_request",method:r.input.requestMethod,request_id:r.input.requestBody.id,request:Fl(r.input.requestBody)});return}return Bn(this,In).log.debug("request_route_probe",{phase:"claimed",handler:"wire_socket",target:"primary",method:r.input.requestMethod,request_id:r.input.requestBody.id,request:Fl(r.input.requestBody)}),[void 0,{}]})},"#claim"),Z$=Vs(function(t,e){var r,s;if(t.length===0)return[];const n=t.map(([h])=>h.input.requestBody);if(!ki(this,Ys,Ll).call(this)){const h=new Error("[direct.dev/client] wire_socket unavailable before dispatch");return n.map(()=>Promise.reject(h))}const i=Bn(this,Na).request.rpc(Bn(this,In),{networkId:e.networkId,requests:n,shadow:!1,bypass:e.bypass,routingToken:void 0,block:e.block}),a=n.map(()=>Ge()),c=new Map;for(let h=0;h<n.length;h++){const u=(r=n[h])==null?void 0:r.id;u===void 0?(s=a[h])==null||s.__resolve(void 0):c.set(u,h)}return(async()=>{var h,u,d,p;try{const f=await i;for await(const g of f){const m=c.get(g.id);m!==void 0&&(a[m].__resolve(g),c.delete(g.id))}for(const[g,m]of c)a[m].__resolve(ks(g,"NO_RESPONSE",{origin:"client",handler:"wire_socket"}))}catch(f){const g=f instanceof Error?f:new Error(String(f));for(const[m,w]of c)Bn(this,In).log.debug("request_route_probe",{phase:"failed",handler:"wire_socket",target:"primary",reason:"response_stream_error",method:(h=n[w])==null?void 0:h.method,request_id:m,request:n[w]?Fl(n[w]):void 0,error:String(f)}),(u=a[w])!=null&&u.__isFulfilled()||((d=a[w])==null||d.catch(()=>{}),(p=a[w])==null||p.__reject(g))}})(),a},"#fulfill"),Ll=Vs(function(){return!Bn(this,Na).transport.connectionPromise&&Bn(this,Na).transport.isConnected},"#isReady"),Vs(ek,"WireSocketUpstreamHandler");let u1=ek;function Fl(t){const e={method:t.method};if(t.method==="eth_getLogs"){const[r]=Array.isArray(t.params)?t.params:[];return r&&typeof r=="object"&&(e.from_block="fromBlock"in r?r.fromBlock:void 0,e.to_block="toBlock"in r?r.toBlock:void 0),e}return t.method==="eth_getBlockByNumber"||t.method==="eth_getBlockByHash"?(e.block_param=Array.isArray(t.params)?t.params[0]:void 0,e.full_transactions=Array.isArray(t.params)?t.params[1]===!0:!1,e):(e.params=t.params,e)}o(Fl,"q$1"),Vs(Fl,"summarizeRequest");var d1=Object.defineProperty,f1=o((t,e)=>d1(t,"name",{value:e,configurable:!0}),"t$2");function Rd(t){if(t===void 0)return!0;const e=hf(200,t);return e===void 0?!0:!lw(e)}o(Rd,"u$6"),f1(Rd,"acceptOutput");var p1=Object.defineProperty,m1=o((t,e)=>p1(t,"name",{value:e,configurable:!0}),"l$6");const tk=(ec=class{name="direct";type="upstream";origin="client";strategy="first_eligible";failover={acceptOutput:Rd};handlers;constructor(e,r){const s=[];r.socketChannel&&s.push(new u1(e,{channel:r.socketChannel})),r.httpChannel&&s.push(new V$(e,{channel:r.httpChannel,isPrimary:!0})),s.push(new Ad(e,{nodeUrl:r.jsonUrl,maxSizeInBytes:mg,windowMs:bd,timeoutMs:fs,fetch:r.fetch,racing:{claimMs:Ol,timeoutMs:fs},circuitBreaker:{halfClosedAttempts:1,halfOpenAttempts:1,cooldownMs:gg}})),this.handlers=s}},o(ec,"s"),ec);m1(tk,"PrimaryDirectUpstreamStage");let g1=tk;var w1=Object.defineProperty,kg=o((t,e)=>w1(t,"name",{value:e,configurable:!0}),"i$5");const rk=(tc=class{name;type="upstream";origin="client";strategy="first_eligible";failover={acceptOutput:Rd};handlers;constructor(e,r){this.name=r.isShadow?"direct_secondary_shadow":"direct_secondary";const s=e.with({"component.id":"SecondaryDirectUpstreamStage"}),n=[];r.httpChannel&&n.push(new V$(e,{channel:r.httpChannel,isPrimary:!1,isShadow:r.isShadow})),n.push(new Ad(e,{nodeUrl:r.jsonUrl,maxSizeInBytes:T$,windowMs:bd,timeoutMs:fs,fetch:r.fetch,circuitBreaker:{halfClosedAttempts:1,halfOpenAttempts:1,cooldownMs:gg}}));const i=r.isShadow;this.handlers=n.map(a=>new sn({name:a.name,circuitBreaker:{halfClosedAttempts:1,halfOpenAttempts:1,cooldownMs:gg},racing:{claimMs:i?0:Ol,timeoutMs:fs},check:i?c=>c.shadowSecondaryLoad:void 0,claim:kg((c,h,u)=>{const d=[],p=c.filter((m,w)=>{if(i){if(!ah(m.input.requestId))return s.log.debug("request_route_probe",{phase:"declined",handler:a.name,target:this.name,reason:"shadow_non_deduplicatable",method:m.input.requestMethod,request_id:m.input.requestBody.id}),!1;if(Pw(m.input.requestBody))return s.log.debug("request_route_probe",{phase:"declined",handler:a.name,target:this.name,reason:"shadow_bypass_wire",method:m.input.requestMethod,request_id:m.input.requestBody.id}),!1;if(Wn(m.input.requestBody))return s.log.debug("request_route_probe",{phase:"declined",handler:a.name,target:this.name,reason:"shadow_slow_request",method:m.input.requestMethod,request_id:m.input.requestBody.id}),!1}else if(h.shadowSecondaryLoad&&ah(m.input.requestId))return s.log.debug("request_route_probe",{phase:"declined",handler:a.name,target:this.name,reason:"failover_shadow_deduplicatable",method:m.input.requestMethod,request_id:m.input.requestBody.id}),!1;return d.push(w),!0});if(p.length===0)return c.map(()=>{});const f=a.claimSync(p,h,u),g=c.map(()=>{});for(let m=0;m<f.length;m++)g[d[m]]=f[m];return g},"claim"),fulfill:kg((c,h,u)=>a.fulfillSync(c,h,u),"fulfill")}))}},o(tc,"p"),tc);kg(rk,"SecondaryDirectUpstreamStage");let sk=rk;var v1=Object.defineProperty,nk=o((t,e)=>v1(t,"name",{value:e,configurable:!0}),"s$4");function ik(t,e){for(const r of e){const s=hf(t.status,r);if(s!==void 0&&hw(s))return!0}return!1}o(ik,"h$3"),nk(ik,"batchShouldTripBreaker");const ak=(rc=class{name="configured_failover";type="upstream";origin="client";strategy="exhaustive";failover={acceptOutput:Rd};handlers;constructor(e,r){this.handlers=r.nodeUrls.map(s=>new Ad(e,{nodeUrl:s,maxSizeInBytes:mg,windowMs:bd,timeoutMs:fs,shouldTripBreaker:ik,fetch:r.fetch,racing:{claimMs:Ol,timeoutMs:fs}}))}},o(rc,"n"),rc);nk(ak,"ConfiguredFailoverUpstreamStage");let _1=ak;var y1=Object.defineProperty,b1=o((t,e)=>y1(t,"name",{value:e,configurable:!0}),"s$3");const ok=(sc=class{name="public_failover";type="upstream";origin="client";strategy="first_eligible";failover={};handlers;constructor(e,r){const s=zE[r.networkId]??[];this.handlers=s.map(n=>new Ad(e,{nodeUrl:n,maxSizeInBytes:mg,windowMs:bd,timeoutMs:fs,fetch:r.fetch,racing:{claimMs:Ol,timeoutMs:fs}}))}},o(sc,"e"),sc);b1(ok,"PublicFailoverUpstreamStage");let $1=ok;var k1=Object.defineProperty,Ci=o((t,e)=>k1(t,"name",{value:e,configurable:!0}),"u$5");function ck(t){var e,r,s;if((t==null?void 0:t.stageType)==="cache"&&(t.handlerName==="block_state_cache"||t.handlerName==="local_memory_cache"||t.handlerName==="continuum_cache"||t.handlerName==="inflight_cache"))return t.handlerName;if((t==null?void 0:t.stageType)==="upstream"&&(e=t.stageName)!=null&&e.startsWith("direct")){const n=t.stageName==="direct"?"primary":t.stageName==="direct_secondary"?"secondary":t.stageName==="direct_secondary_shadow"?"secondary_shadow":t.stageName;if(t.handlerName==="wire_socket"||t.handlerName==="wire_http")return`${n}_${t.handlerName}`;if((r=t.handlerName)!=null&&r.startsWith("http://")||(s=t.handlerName)!=null&&s.startsWith("https://"))return`${n}_json_rpc`}return(t==null?void 0:t.stageName)??"unknown"}o(ck,"Z$1"),Ci(ck,"getRequestResolutionStageName");function lk(t){if(t)return(t.checkMs??0)+(t.claimMs??0)+(t.fulfillMs??0)}o(lk,"$$1"),Ci(lk,"getRequestResolutionStageLatencyMs");const hk=(nc=class extends DC{constructor(e,r,s,n){const i={httpChannel:r.secondaryHttpChannel,jsonUrl:s.secondaryJsonUrl,fetch:s.fetch},a=[new QE,new i1(r.cache),new r1(r.cache),new sk(e,{...i,isShadow:!0}),new g1(e,{socketChannel:r.socketChannel,httpChannel:r.httpChannel,jsonUrl:s.jsonUrl,fetch:s.fetch}),new sk(e,{...i,isShadow:!1}),...s.failoverUrls&&s.failoverUrls.length>0?[new _1(e,{nodeUrls:s.failoverUrls,fetch:s.fetch})]:[],new $1(e,{networkId:s.networkId,fetch:s.fetch})];super(a,{timeoutMs:6e4,transformInput:Ci((c,h)=>{var u;const d=lh(c.method),p=nh(c,d),f=Ft(p,(u=h.block)==null?void 0:u.digest);return{requestBody:c,requestId:f,requestMethod:d}},"transformInput"),transformError:Ci((c,h)=>(e.log.warn("Request failed",{input:c,err:h}),ks(c.requestBody.id??null,"SERVER_ERROR",{...S1,error:String(h)})),"transformError"),onTelemetry:Ci((c,h)=>{var u,d;(u=s.onTelemetry)==null||u.call(s,c,h);const p=s.requestLogging??"off",f=p==="debug"||!!h.onResolution,g=[];for(const m of c){const w=m.executions.findLast(_=>_.result==="fulfilled");if(f){const _=ck(w),S=lk(w),b={method:m.input.requestMethod,request_id:m.input.requestBody.id,latency_ms:S??m.latencyMs,pipeline_latency_ms:m.latencyMs,stage_name:_,stage_type:(w==null?void 0:w.stageType)??"unknown"};if(g.push(b),p==="debug"){const D={client_instance_id:s.clientInstanceId,...b,handler_name:(w==null?void 0:w.handlerName)??"unknown"};o$(p,D,s.onLogEvent)}}if(p==="debug"){const _=m.deferred.__resolvedWith();l$("request_handled",{client_instance_id:s.clientInstanceId,req:m.input.requestBody,res:_===Bf?void 0:_,latency_ms:m.latencyMs},s.onLogEvent)}}if((d=h.onResolution)==null||d.call(h,g),!!n){n.collectBandwidthEstimateHeaders("upload",KE),n.collectBandwidthEstimateHeaders("download",GE);for(const m of c){const w=m.executions.findLast(O=>O.result==="fulfilled"),_=m.deferred.__resolvedWith(),S=uk(w==null?void 0:w.stageName),b=(w==null?void 0:w.stageName)??"unknown",D=Wi(m.input.requestBody);if(n.collectBandwidthEstimatePayload(S,b,"upload",D),_!==Bf&&_!==void 0){const O=Wi(_);switch(n.collectBandwidthEstimatePayload(S,b,"download",O*HE),w==null?void 0:w.stageType){case"upstream":n.collectUpstreamLatency(b,m.latencyMs);break;case"cache":{n.collectCacheHit(b,{requestMethod:m.input.requestMethod,requestId:m.input.requestId,requestSizeInBytes:D,blockContext:h.block,responseKey:Ef(_,m.input.requestMethod),responseSizeInBytes:O,latencyMs:m.latencyMs});break}}}}}},"onTelemetry")})}},o(nc,"S"),nc);Ci(hk,"ClientRequestPipeline");let C1=hk;function uk(t){return t!=null&&t.endsWith("_failover")?"failover":"direct"}o(uk,"J$1"),Ci(uk,"getTargetByStageName");const S1={origin:"client"},A1=ke("config",l.shape({projectId:l.str,projectToken:l.str.optional,networkId:l.networkId,failover:l.arr(l.str,{minLength:1}).optional,baseUrl:l.str.optional,secondaryBaseUrl:l.str.optional,logging:l.shape({client:l.literal("silent","info","debug","warn","error").optional,requests:l.literal("off","summary","debug").optional,onEvent:l.unknown.optional}).optional,disableWire:l.bool.optional,disableSync:l.bool.optional,disableLocalMemoryCache:l.bool.optional,fetch:l.unknown.optional,createWebSocket:l.unknown.optional})),E1=ke("eth_getTransactionReceipt",l.shape({result:l.shape({blockNumber:l.blockHeight})},{ignoreExtraProps:!0}));var M1=Object.defineProperty,dk=o(t=>{throw TypeError(t)},"v$1"),T1=o((t,e)=>M1(t,"name",{value:e,configurable:!0}),"m$2"),fk=o((t,e,r)=>e.has(t)||dk("Cannot "+r),"T$1"),Cr=o((t,e,r)=>(fk(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$2"),Cg=o((t,e,r)=>e.has(t)?dk("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"f$3"),Sg=o((t,e,r,s)=>(fk(t,e,"write to private field"),e.set(t,r),r),"d$2"),Si,vs,Bd;const pk=(ic=class{constructor(e){Cg(this,Si,1/0),Cg(this,vs,[]),Cg(this,Bd),Sg(this,Bd,(e==null?void 0:e.delayExpirationMs)??3e5)}sync(e,r,s){var n;const i=y(),a=(r-e+(s-i))/2,c=i-e-(s-r),h=i-Cr(this,Bd);for(;Cr(this,vs).length>0&&Cr(this,vs)[0][1]<h;)Cr(this,vs).shift();for(Cr(this,vs).push([c,i]);Cr(this,vs).length>16;)Cr(this,vs).shift();const u=Cr(this,vs).toSorted((p,f)=>p[0]-f[0]),d=((n=u.at(Math.floor(u.length/2)))==null?void 0:n[0])??1/0;c<=d&&Sg(this,Si,a)}delta(e,r=y()){const s=r+Cr(this,Si);return e-s}isFuture(e,r=y()){return this.delta(e,r)>0}isPast(e,r=y()){return this.delta(e,r)<0}getServerTime(e=y()){return Cr(this,Si)===1/0?e:e+Cr(this,Si)}__setOffsetForTest(e){Sg(this,Si,e),Cr(this,vs).length=0}},o(ic,"c"),ic);Si=new WeakMap,vs=new WeakMap,Bd=new WeakMap,T1(pk,"RemoteClock");let mk=pk;var R1=Object.defineProperty,gk=o(t=>{throw TypeError(t)},"I$1"),Ag=o((t,e)=>R1(t,"name",{value:e,configurable:!0}),"c$5"),Eg=o((t,e,r)=>e.has(t)||gk("Cannot "+r),"u$4"),La=o((t,e,r)=>(Eg(t,e,"read from private field"),e.get(t)),"i$3"),Mg=o((t,e,r)=>e.has(t)?gk("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"h$2"),wk=o((t,e,r,s)=>(Eg(t,e,"write to private field"),e.set(t,r),r),"E$3"),vk=o((t,e,r)=>(Eg(t,e,"access private method"),r),"_$2"),Id,qn,qd,_k,yk;const bk=(ac=class{constructor(e){Mg(this,qd),Mg(this,Id),Mg(this,qn),wk(this,Id,e)}update(e){wk(this,qn,e)}shouldShadow(){if(!La(this,qn))return!1;const e=vk(this,qd,_k).call(this);return e===0?!1:Math.random()*1e4<e}},o(ac,"l"),ac);Id=new WeakMap,qn=new WeakMap,qd=new WeakSet,_k=Ag(function(){if(!La(this,qn))return 0;const t=vk(this,qd,yk).call(this);return t%665===0?La(this,qn).weeklySpike:t%95===0?La(this,qn).dailySpike:La(this,qn).base},"#getCurrentRate"),yk=Ag(function(){const t=La(this,Id).getServerTime();return Math.floor(t/9e5)},"#getCurrentEpoch"),Ag(bk,"ShadowRateManager");let B1=bk;var I1=Object.defineProperty,Tg=o((t,e)=>I1(t,"name",{value:e,configurable:!0}),"i$2");const $k=new eu({id:0,name:"rpc",req:ke("rpc_request",l.shape({networkId:l.networkId,requests:l.arr(bm),shadow:l.bool,bypass:l.bool,routingToken:l.str.optional,block:l.shape({height:l.blockHeight,digest:l.blockDigest.optional,expiresAt:l.timestamp.optional}).optional})),res:cl,timeoutMs:1e4},[]),kk=new Dc({id:1,name:"ntp_sync",req:ke("ntp_sync",l.shape({t1:l.uint32,t2:l.timestamp,t3:l.timestamp}))},[]),q1=new Dc({id:2,name:"telemetry",req:cA},[]),P1=new Dc({id:3,name:"block_height",req:ke("block_height",l.shape({networkId:l.networkId,height:l.blockHeight,expiresAt:l.timestamp}))},[]),x1=new Dc({id:6,name:"routing_context",req:ke("routing_context",l.shape({networkId:l.networkId,token:l.str,expiresAt:l.timestamp}))},[]),W1=new Dc({id:4,name:"shadow_rate",req:ke("shadow_rate",l.shape({base:l.uint32,dailySpike:l.uint32,weeklySpike:l.uint32}))},[]),Ck=new sb,Rg=new Om,U1=new _b(Ck,Rg,{onInflightTimeout:Tg(()=>{},"onInflightTimeout"),onInflightEviction:Tg(()=>{},"onInflightEviction"),onPrematureEviction:Tg(()=>{},"onPrematureEviction")}),Bg=new $E({block:Ck,fingerprint:Rg,fingerprintRevalidated:Rg,cache:U1},{id:5,name:"client_continuum",timeoutMs:5*6e4},l.shape({networkId:l.networkId})),Sk=new C_({name:"client_to_primary",mode:"untrusted",downstreamRelationship:"parent"},{rpc:$k,telemetry:q1,continuum:Bg},{ntp:kk,shadowRate:W1}),D1=new C_({name:"client_to_secondary",mode:"untrusted",downstreamRelationship:"parent"},{rpc:$k},{ntp:kk,blockHeight:P1,routingContext:x1});var O1=Object.defineProperty,fe=o((t,e)=>O1(t,"name",{value:e,configurable:!0}),"o$2");const Ig=new Map,Ak=new WeakMap,Ek=new WeakMap;let j1=1,N1=1;const Mk=4*1024*1024,Tk=16*1024*1024;function Rk(t){if(!t)return 0;let e=Ak.get(t);return e===void 0&&(e=j1++,Ak.set(t,e)),e}o(Rk,"oe"),fe(Rk,"getFetchId");function Bk(t){if(!t)return 0;let e=Ek.get(t);return e===void 0&&(e=N1++,Ek.set(t,e)),e}o(Bk,"re"),fe(Bk,"getWebSocketFactoryId");const Pd=new Set;function Ik(t){const e=fe(r=>{t(r)},"cb");return Pd.add(e),()=>{Pd.delete(e)}}o(Ik,"se"),fe(Ik,"addWireBandwidthListener");function xd(t){return{onIngress:fe(e=>{for(const r of Pd)r({channel:t,direction:"ingress",bytes:e})},"onIngress"),onEgress:fe(e=>{for(const r of Pd)r({channel:t,direction:"egress",bytes:e})},"onEgress")}}o(xd,"I"),fe(xd,"makeBandwidthHooks");function Wd(t){const e=xg(t.baseUrl??"https://prod.rpc.direct.dev"),r=Pg(t);return`${e}/v1/${r}`}o(Wd,"$"),fe(Wd,"getUrl");function qg(t){const e=xg(t.secondaryBaseUrl??FE),r=Pg(t);return`${e}/v1/${r}`}o(qg,"j$1"),fe(qg,"getSecondaryUrl");function qk(t){var e;const r=Wd(t),s=qg(t),n=Rk(t.fetch),i=Bk(t.createWebSocket),a=og(t.logging),c=`${r}|${s}|${n}|${i}|${a}`,h=new Set,u=new Set,d=(e=t.logging)==null?void 0:e.onEvent;let p=Ig.get(c);if(p)p.refCount++,p.blockListeners.add(h),p.routingListeners.add(u),d&&p.logEventListeners.add(d);else{const m=new Set;d&&m.add(d);const w=new jy({serviceVersion:"0.7.2",serviceNamespace:"client",serviceName:"client",serviceInstanceId:void 0,projectId:t.projectId,networkId:void 0,coloId:void 0,continentId:void 0},{logLevel:`*:${a}`,logSamples:"*:1",traceSamples:"*:0",exporter:fe(()=>new e$({onEvent:fe(Pe=>{for(const Oe of m)Oe(Pe)},"onEvent")}),"exporter")},Em()),_=new mk,S=new B1(_),b=Pk(w,r,_,S,t.fetch),D=xk(w,r,_,S,t.createWebSocket),O=new Set([h]),x=new Set([u]),K=new mk,I=Wk(w,s,K,t.fetch,Pe=>{for(const Oe of O)for(const Se of Oe)Se(Pe)},Pe=>{for(const Oe of x)for(const Se of Oe)Se(Pe)});p={clock:_,secondaryClock:K,httpChannel:b,secondaryHttpChannel:I,socketChannel:D,shadowRateManager:S,refCount:1,blockListeners:O,routingListeners:x,logEventListeners:m},Ig.set(c,p)}let f=!1;const g=fe(()=>{var m;if(!f&&(f=!0,p.refCount--,p.blockListeners.delete(h),p.routingListeners.delete(u),d&&p.logEventListeners.delete(d),p.refCount===0))return Ig.delete(c),Promise.all([p.httpChannel.disconnect(),p.secondaryHttpChannel.disconnect(),(m=p.socketChannel)==null?void 0:m.disconnect()]).then(()=>{},()=>{})},"release");return[{clock:p.clock,httpChannel:p.httpChannel,socketChannel:p.socketChannel,secondaryClock:p.secondaryClock,secondaryHttpChannel:p.secondaryHttpChannel,shadowRateManager:p.shadowRateManager,onSecondaryBlockHeight:fe(m=>(h.add(m),()=>h.delete(m)),"onSecondaryBlockHeight"),onSecondaryRoutingContext:fe(m=>(u.add(m),()=>u.delete(m)),"onSecondaryRoutingContext")},g]}o(qk,"ce"),fe(qk,"getSharedResources");function Pk(t,e,r,s,n){const i=new zi,a=new iy(t,{url:fe(()=>{const c=y(),h=zi.encodeIndex(i.store(c));return Ud(e,h)},"url"),batchWindowMs:100,batchMaxSizeInBytes:512e3,batchTimeoutMs:3e4,flushRequestsImmediately:!0,disableDuplex:!0,maxMessageSize:Mk,maxStreamSize:Tk,fetchFn:n?()=>n:void 0},{enableCompression:!1},xd("primary_http"));return Sk.createClient(a,{ntp:fe((c,h,u)=>{const d=i.consume(u.t1);t.log.verbose("ntp_sync_received",{channel:"primary_http",token:u.t1,matched:d!==void 0,t2:u.t2,t3:u.t3}),d!==void 0&&r.sync(d,u.t2,u.t3)},"ntp"),shadowRate:fe((c,h,u)=>{s.update(u)},"shadowRate")})}o(Pk,"ie"),fe(Pk,"makeHTTPChannel");function xk(t,e,r,s,n){if(!n&&typeof WebSocket>"u")return;const i=new zi,a=e.replace("https://","wss://").replace("http://","ws://"),c=new VS(t,()=>{const h=y(),u=zi.encodeIndex(i.store(h)),d=Ud(a,u);return n?n(d):new WebSocket(d)},{compression:{enableCompression:!0},maxMessageSize:2*1024*1024,primeSocket:!0,circuitBreaker:{halfOpenAttempts:3,halfClosedAttempts:8,cooldownMs:3e4}},xd("primary_websocket"));return c.connect(t).catch(()=>{}),Sk.createClient(c,{ntp:fe((h,u,d)=>{const p=i.consume(d.t1);t.log.verbose("ntp_sync_received",{channel:"primary_websocket",token:d.t1,matched:p!==void 0,t2:d.t2,t3:d.t3}),p!==void 0&&r.sync(p,d.t2,d.t3)},"ntp"),shadowRate:fe((h,u,d)=>{s.update(d)},"shadowRate")})}o(xk,"ae"),fe(xk,"makeSocketChannel");function Wk(t,e,r,s,n,i){const a=new zi,c=new iy(t,{url:fe(()=>{const h=y(),u=zi.encodeIndex(a.store(h));return Ud(e,u)},"url"),batchWindowMs:100,batchMaxSizeInBytes:T$,batchTimeoutMs:3e4,flushRequestsImmediately:!0,disableDuplex:!0,maxMessageSize:Mk,maxStreamSize:Tk,fetchFn:s?()=>s:void 0},{enableCompression:!1},xd("secondary_http"));return D1.createClient(c,{ntp:fe((h,u,d)=>{const p=a.consume(d.t1);t.log.verbose("ntp_sync_received",{channel:"secondary_http",token:d.t1,matched:p!==void 0,t2:d.t2,t3:d.t3}),p!==void 0&&r.sync(p,d.t2,d.t3)},"ntp"),blockHeight:fe((h,u,d)=>{n(d)},"blockHeight"),routingContext:fe((h,u,d)=>{i(d)},"routingContext")})}o(Wk,"le"),fe(Wk,"makeSecondaryHTTPChannel");function Pg(t){return t.projectToken?t.projectId+"."+encodeURIComponent(t.projectToken):t.projectId}o(Pg,"z"),fe(Pg,"getProjectPath");function Ud(t,e){return e?t.includes("?")?t+"&t="+encodeURIComponent(e):t+"?t="+encodeURIComponent(e):t}o(Ud,"b$2"),fe(Ud,"appendTimeParam");function xg(t){let e=t.length;for(;e>0&&t.charAt(e-1)==="/";e--);return t.substring(0,e)}o(xg,"R"),fe(xg,"getBaseUrl");var Uk=Object.defineProperty,Dk=o(t=>{throw TypeError(t)},"Pt"),L1=o((t,e,r)=>e in t?Uk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"de"),F=o((t,e)=>Uk(t,"name",{value:e,configurable:!0}),"a$1"),Dd=o((t,e,r)=>L1(t,typeof e!="symbol"?e+"":e,r),"j"),Wg=o((t,e,r)=>e.has(t)||Dk("Cannot "+r),"gt"),v=o((t,e,r)=>(Wg(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$1"),X=o((t,e,r)=>e.has(t)?Dk("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"h"),Z=o((t,e,r,s)=>(Wg(t,e,"write to private field"),e.set(t,r),r),"u$2"),P=o((t,e,r)=>(Wg(t,e,"access private method"),r),"r$2"),F1=o((t,e,r,s)=>({set _(n){Z(t,e,n)},get _(){return v(t,e,s)}}),"Tt"),Ug,lt,Yr,Jr,Fa,Js,za,zl,Pn,Ha,Hl,Te,Ai,Od,jd,Kl,Nd,Ka,Gl,Ld,Fd,Ei,Ga,zd,Sr,Hd,Kd,Gd,Vl,Va,Ya,Ja,Vd,B,Yd,Jd,Xa,Xd,Dg,Qa,Ok,jk,Nk,Lk,Fk,zk,Hk,Kk,Gk,Vk,Yk,Jk,Og,jg,Qd,Zd,ef,Xk,tf,Yl;function Qk(t){if(t.length===0)return{};const e=t[0];if(t.length===1)return{stage_name:e==null?void 0:e.stage_name,stage_type:e==null?void 0:e.stage_type};const r=new Set(t.map(n=>n.stage_name)),s=new Set(t.map(n=>n.stage_type));return{stage_name:r.size===1?e==null?void 0:e.stage_name:"mixed",stage_type:s.size===1?e==null?void 0:e.stage_type:void 0}}o(Qk,"Fe"),F(Qk,"summarizePipelineResolutions");function Ng(t,e){return t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||e}o(Ng,"Wt"),F(Ng,"toClientIdSlug");const nr=(qi=class{constructor(e,r){X(this,B),X(this,lt),X(this,Yr),X(this,Jr),X(this,Fa),X(this,Js),X(this,za),X(this,zl),X(this,Pn),X(this,Ha),X(this,Hl),X(this,Te),X(this,Ai),X(this,Od),X(this,jd,!1),X(this,Kl),X(this,Nd),X(this,Ka),X(this,Gl),X(this,Ld),X(this,Fd),X(this,Ei),X(this,Ga),X(this,zd),X(this,Sr),X(this,Hd),X(this,Kd),X(this,Gd,y()),X(this,Vl),X(this,Va),X(this,Ya,new AbortController),X(this,Ja),X(this,Vd),X(this,Qd,F(()=>{if(typeof document>"u"||document.visibilityState!=="hidden")return;const d=v(this,Ei).consume();d&&P(this,B,Yl).call(this,d,!0)},"#handleVisibilityChange")),X(this,Zd,F(()=>{this.destroy().catch(()=>{})},"#handleBeforeUnload"));var s;const n=A1.parse(e);Z(this,Yr,n);const i=Ng(n.networkId,"network"),a=Ng(n.projectId.slice(0,8),"project");Z(this,Jr,`client_${i}_${a}_${F1(qi,Ug)._++}`);const[c,h]=qk(n);Z(this,Vd,h),Z(this,Pn,c.clock),Z(this,Hl,c.secondaryClock),Z(this,Nd,c.shadowRateManager),Z(this,Ga,c.httpChannel),Z(this,zd,c.secondaryHttpChannel),Z(this,Sr,c.socketChannel),Z(this,lt,new jy({serviceVersion:"0.7.2",serviceNamespace:"client",serviceName:"client",serviceInstanceId:void 0,projectId:n.projectId,networkId:n.networkId,coloId:void 0,continentId:void 0},{logLevel:`*:${og(n.logging)}`,logSamples:"*:1",traceSamples:"*:0",exporter:F(()=>{var d;return new e$({onEvent:(d=n.logging)==null?void 0:d.onEvent})},"exporter")},{...Em(),...qb()})),Z(this,Fa,new sb({isExpired:F(d=>v(this,Pn).isPast(d),"isExpired")})),Z(this,Js,new ME(v(this,Fa),d=>v(this,Pn).isPast(d))),c.onSecondaryBlockHeight(d=>{d.networkId===n.networkId&&Z(this,Hd,{height:d.height,expiresAt:d.expiresAt})}),c.onSecondaryRoutingContext(d=>{d.networkId===n.networkId&&Z(this,Kd,d)}),Z(this,Ka,new Om),Z(this,Gl,new Om),Z(this,zl,new _b(v(this,Fa),v(this,Ka),{onInflightTimeout:F(()=>{},"onInflightTimeout"),onInflightEviction:F(()=>{},"onInflightEviction"),onPrematureEviction:F(()=>{},"onPrematureEviction")}));const u=new Gb(v(this,Ka));Z(this,Ld,new Gb(v(this,Gl))),Z(this,za,new qE(v(this,Pn),{cacheContinuum:v(this,zl),fingerprintResolver:u,disableLocalMemoryCache:n.disableLocalMemoryCache})),Z(this,Ei,new LE({networkId:n.networkId,softEntryLimit:100,softFlushIntervalMs:2e3,hardFlushIntervalMs:6e4,onFlush:F(d=>P(this,B,Yl).call(this,d),"onFlush"),onBandwidthEstimate:r==null?void 0:r.bandwidthEstimate})),Z(this,Fd,new C1(v(this,lt),{cache:v(this,za),httpChannel:n.disableWire?void 0:v(this,Ga),secondaryHttpChannel:n.disableWire?void 0:v(this,zd),socketChannel:n.disableWire?void 0:v(this,Sr)},{networkId:n.networkId,jsonUrl:Wd(n)+`/${encodeURIComponent(n.networkId)}`,secondaryJsonUrl:qg(n)+`/${encodeURIComponent(n.networkId)}`,failoverUrls:n.failover,clientInstanceId:v(this,Jr),fetch:n.fetch,onLogEvent:(s=n.logging)==null?void 0:s.onEvent,requestLogging:cg(n.logging),onTelemetry:r==null?void 0:r.pipeline},v(this,Ei))),!n.disableSync&&v(this,Sr)&&(P(this,B,Yd).call(this),Z(this,Te,P(this,B,Dg).call(this,{usePreload:!0,connect:P(this,B,Jd).call(this)})),P(this,B,ef).call(this)),P(this,B,Lk).call(this)}static onWireBandwidth(e){return Ik(e)}getClientInstanceId(){return v(this,Jr)}fetch(e){var r,s,n;const i=y(),a=Array.isArray(e)?e.map(m=>bm.parse(m)):[bm.parse(e)];if(xw(a))return v(this,lt).log.error("Batch contains duplicate request IDs",{ids:a.map(m=>m.id)}),a.filter(m=>m.id!==void 0).map(m=>Mi(ks(m.id??null,"BAD_REQUEST",{reason:"duplicate_ids"})));Z(this,Vl,y()),P(this,B,ef).call(this),P(this,B,Yd).call(this);const c=v(this,Ha);v(this,Te)&&!v(this,Te).connected&&(c==null||c.applied)&&P(this,B,Jd).call(this)?P(this,B,Qa).call(this,v(this,Te)):v(this,Te)&&!v(this,Te).connected&&(c==null||c.applied)&&P(this,B,Xd).call(this,v(this,Te));const h=cg(v(this,Yr).logging),u=P(this,B,tf).call(this),d=v(this,Js).getCurrent({allowExpiredRetained:u}),p=v(this,Js).hasLiveCurrent();a.some(m=>m.method==="eth_blockNumber")&&h==="debug"&&v(this,lt).log.debug("block.state_probe",{client_instance_id:v(this,Jr),preload_attached:(c==null?void 0:c.attached)??!1,preload_applied:(c==null?void 0:c.applied)??!1,continuum_connected:((r=v(this,Te))==null?void 0:r.connected)??!1,has_current_block:!!d,has_live_current_block:p,current_block_height:d==null?void 0:d.height,current_block_digest:d==null?void 0:d.digest}),(s=v(this,Te))!=null&&s.connected&&p&&Z(this,jd,!0),(n=v(this,Te))!=null&&n.connected&&!p&&v(this,jd)&&!P(this,B,tf).call(this)&&P(this,B,Xk).call(this,"stale_sync_missing_block");const f=P(this,B,Fk).call(this,p),g=P(this,B,Gk).call(this,a,d,p,f,c);return Rt(g,m=>{const w=P(this,B,Og).call(this),_=P(this,B,Jk).call(this),S=[],b=h==="summary"||h==="debug",D=v(this,Fd).request(a,{block:d,secondaryBlock:w,routing:_,networkId:v(this,Yr).networkId,wireSocketReady:f,shadowSecondaryLoad:v(this,Nd).shouldShadow(),bypass:m,onResolution:b?I=>{S.push(...I)}:void 0}),O=P(this,B,Yk).call(this,D,a),x=P(this,B,zk).call(this,O,a),K=v(this,Ei).maybeConsume();return K&&P(this,B,Yl).call(this,K),Rt(x,({responses:I,winner:Pe})=>{var Oe,Se,Ke,Nt;const Lt=y()-i,ir=a.length===1?((Oe=a[0])==null?void 0:Oe.method)??"unknown":"batch",Xr=Pe==="pipeline"?Qk(S):{};if(c$(h,{client_instance_id:v(this,Jr),method:ir,methods:a.map(Qr=>Qr.method),request_id:a.length===1?(Se=a[0])==null?void 0:Se.id:void 0,request_ids:a.map(Qr=>Qr.id),request_count:a.length,latency_ms:Lt,resolution_source:Pe,stage_type:Pe==="preload_local"?"cache":Xr.stage_type,stage_name:Pe==="preload_local"?"preload_local":Xr.stage_name},(Ke=v(this,Yr).logging)==null?void 0:Ke.onEvent),Array.isArray(e))return I;if(((Nt=a[0])==null?void 0:Nt.id)!==void 0)return I[0]??Mi(ks(a[0].id,"NO_RESPONSE",{source:"client"}))})})}getBlockHeight(){var e;return(e=P(this,B,jg).call(this))==null?void 0:e.height}async destroy(){return v(this,Ja)?v(this,Ja):(Z(this,Ja,(async()=>{var e;typeof document<"u"&&document.removeEventListener("visibilitychange",v(this,Qd)),typeof window<"u"&&window.removeEventListener("beforeunload",v(this,Zd)),clearTimeout(v(this,Va)),Z(this,Va,void 0),v(this,za).destroy(),v(this,Ya).abort();const r=v(this,Ei).consume();r&&await P(this,B,Yl).call(this,r,!0),await((e=v(this,Te))==null?void 0:e.disconnect().catch(()=>{})),await v(this,Vd).call(this)})()),v(this,Ja))}},o(qi,"y"),qi);Ug=new WeakMap,lt=new WeakMap,Yr=new WeakMap,Jr=new WeakMap,Fa=new WeakMap,Js=new WeakMap,za=new WeakMap,zl=new WeakMap,Pn=new WeakMap,Ha=new WeakMap,Hl=new WeakMap,Te=new WeakMap,Ai=new WeakMap,Od=new WeakMap,jd=new WeakMap,Kl=new WeakMap,Nd=new WeakMap,Ka=new WeakMap,Gl=new WeakMap,Ld=new WeakMap,Fd=new WeakMap,Ei=new WeakMap,Ga=new WeakMap,zd=new WeakMap,Sr=new WeakMap,Hd=new WeakMap,Kd=new WeakMap,Gd=new WeakMap,Vl=new WeakMap,Va=new WeakMap,Ya=new WeakMap,Ja=new WeakMap,Vd=new WeakMap,B=new WeakSet,Yd=F(function(){var t;const e=(t=v(this,Sr))==null?void 0:t.transport;!e||e.isConnected||e.connectionPromise||Promise.resolve(e.connect(v(this,lt))).catch(()=>{})},"#ensureSocketTransportConnect"),Jd=F(function(){var t;const e=(t=v(this,Sr))==null?void 0:t.transport;return e?e.isConnected:!1},"#canConnectContinuumNow"),Xa=F(function(){const t=v(this,Vl);return t==null?y()-v(this,Gd)<nr.INITIAL_SYNC_INACTIVITY_MS:y()-t<nr.IDLE_DISCONNECT_MS},"#shouldKeepContinuumSyncActive"),Xd=F(function(t){var e;const r=(e=v(this,Sr))==null?void 0:e.transport;if(!r||t.connected)return;if(r.isConnected){P(this,B,Qa).call(this,t);return}const s=r.connectionPromise;s&&s.then(()=>{v(this,Ya).signal.aborted||v(this,Te)!==t||t.connected||!r.isConnected||!P(this,B,Xa).call(this)||P(this,B,Qa).call(this,t)}).catch(()=>{})},"#connectContinuumSubscriberWhenSocketReady"),Dg=F(function(t){const e=v(this,Sr);if(!e)throw new Error("[direct.dev/client] Continuum sync requires websocket transport");const r={block:v(this,Fa),fingerprint:v(this,Ka),fingerprintRevalidated:v(this,Gl),cache:v(this,zl)},s=new CE(v(this,lt),Bg,e,r,{distributedTracing:!1,shouldReconnect:F(()=>P(this,B,Xa).call(this),"shouldReconnect")});let n;if(t!=null&&t.usePreload&&typeof window<"u"){let i=F(()=>{},"resolveApplied");const a={attached:!1,applied:!1,appliedPromise:new Promise(h=>{i=h}),resolveApplied:i};Z(this,Ha,a);const c=new iA(Bg,{fromChecksum:xc,params:{networkId:v(this,Yr).networkId}}).dispatch(v(this,lt),Wd(v(this,Yr))+`/${encodeURIComponent(v(this,Yr).networkId)}`,v(this,Ya).signal,{onValidatedResponse:F((h,u)=>{P(this,B,Nk).call(this,h,u)},"onValidatedResponse"),onAttached:F(()=>{a.attached=!0,v(this,lt).log.debug("preload.phase",{phase:"attached",client_instance_id:v(this,Jr)})},"onAttached")});n=P(this,B,jk).call(this,c,a)}else Z(this,Ha,void 0);return(t==null?void 0:t.connect)!==!1?P(this,B,Qa).call(this,s,n):n?P(this,B,Ok).call(this,s,n):P(this,B,Xd).call(this,s),s},"#bootstrapContinuumSubscriber"),Qa=F(function(t,e){Z(this,Od,y(+nr.SYNC_BOOTSTRAP_GRACE_MS)),t.connect(v(this,lt),{networkId:v(this,Yr).networkId},e)},"#connectContinuumSubscriber"),Ok=F(function(t,e){(async()=>{try{await t.applyInitialStream(v(this,lt),e)}catch{return}t===v(this,Te)&&!t.connected&&P(this,B,Xa).call(this)&&P(this,B,Jd).call(this)?P(this,B,Qa).call(this,t):t===v(this,Te)&&!t.connected&&P(this,B,Xa).call(this)&&P(this,B,Xd).call(this,t)})()},"#applyInitialPreloadStream"),jk=F(function(t,e){const r=v(this,Jr),s=v(this,lt),n=v(this,Js);return{[Symbol.asyncIterator]:F(async function*(){try{for await(const i of t)yield i}finally{e.applied=!0,e.resolveApplied();const i=n.getCurrent();s.log.debug("preload.phase",{phase:"applied",client_instance_id:r,has_current_block:!!i,current_block_height:i==null?void 0:i.height,current_block_digest:i==null?void 0:i.digest})}},"trackedInitialPreloadApply")}},"#trackInitialPreloadApply"),Nk=F(function(t,e){const r=t.headers.get(sA),s=t.headers.get(nA),n=!!r&&!!s,i=n?Number(r):void 0,a=n?Number(s):void 0,c=n&&Number.isFinite(i)&&Number.isFinite(a);v(this,lt).log.debug("preload.clock_sync",{client_instance_id:v(this,Jr),valid:c,has_t2:!!r,has_t3:!!s,t2:r??void 0,t3:s??void 0,started_at:e,invalid_reason:n?c?void 0:"invalid_headers":"missing_headers"}),!(!n||!c)&&v(this,Pn).sync(e,i,a)},"#syncClockFromPreloadResponse"),Lk=F(async function(){P(this,B,Yd).call(this),typeof document<"u"&&document.addEventListener("visibilitychange",v(this,Qd)),typeof window<"u"&&window.addEventListener("beforeunload",v(this,Zd))},"#bootstrap"),Fk=F(function(t){var e;const r=(e=v(this,Sr))==null?void 0:e.transport;return!(r!=null&&r.isConnected)||r.connectionPromise?!1:v(this,Yr).disableSync||!v(this,Te)?!0:v(this,Te).connected&&t},"#isWireSocketReadyForRequests"),zk=F(function(t,e){const r=v(this,Ha);if(!r||r.applied)return Rt(t,n=>({responses:n,winner:"pipeline"}));const s=Promise.resolve(t);return Promise.race([s.then(n=>({responses:n,winner:"pipeline"})),(async()=>{await r.appliedPromise;const n=await P(this,B,Hk).call(this,e);return n?{responses:n,winner:"preload_local"}:s.then(i=>({responses:i,winner:"pipeline"}))})()])},"#raceInitialPreloadApply"),Hk=F(async function(t){const e=[];for(const r of t){if(r.id===void 0)continue;const s=await P(this,B,Kk).call(this,r);if(!s)return;e.push(s)}return e},"#tryResolveRequestsFromLocalState"),Kk=F(function(t){const e=lh(t.method),r=P(this,B,jg).call(this),s=v(this,Js).getCurrent();if(e==="eth_blockNumber"){const c=t.params;return Array.isArray(c)&&c.length>0||!(r!=null&&r.height)||t.id===void 0?void 0:Mi({id:t.id,result:r.height})}const n=nh(t,e,s==null?void 0:s.height);if(!kf(n))return;const i=Ft(n,s==null?void 0:s.digest),a=v(this,za).getFromMemory(i,t,e,r==null?void 0:r.height);return Rt(a,c=>{if(!(!c||t.id===void 0))return Mi({...c,id:t.id})})},"#resolveRequestFromLocalState"),Gk=F(function(t,e,r,s,n){var i;if(P(this,B,Vk).call(this,r,s,n))return!0;if(!((i=v(this,Te))!=null&&i.connected)||!r||!e)return!1;for(const a of t){const c=lh(a.method),h=nh(a,c,e==null?void 0:e.height);if(v(this,Ld).hasFingerprint(h))return!1}return!0},"#shouldBypassCache"),Vk=F(function(t,e,r){return e||t?!1:r!==void 0&&!r.applied||P(this,B,tf).call(this)},"#shouldBypassCacheDuringStartup"),Yk=F(function(t,e){const r=Array.isArray(t)?t.filter(s=>s!==void 0).map(Mi):(async()=>{const s=[];for await(const n of t)n!==void 0&&s.push(Mi(n));return s})();return Rt(r,s=>{const n=new Map(e.map(i=>[i.id,i]));for(const i of s){const a=n.get(i.id);switch(a==null?void 0:a.method){case"eth_getTransactionReceipt":case"direct_getTransactionReceipt":{const c=E1.safeParse(i);c!==Bc&&v(this,Js).setMinimum(c.result.blockNumber,y(45e3))}}}return s})},"#processResponses"),Jk=F(function(){const t=v(this,Kd);if(!(!t||v(this,Hl).isPast(t.expiresAt)))return{token:t.token,expiresAt:t.expiresAt}},"#getSecondaryRoutingContext"),Og=F(function(){const t=v(this,Hd);if(!(!t||v(this,Hl).isPast(t.expiresAt)))return t},"#getSecondaryBlockContext"),jg=F(function(){const t=v(this,Js).getCurrent(),e=P(this,B,Og).call(this);return t?e&&xn(e.height,t.height)?e:t:e},"#getBestKnownBlockContext"),Qd=new WeakMap,Zd=new WeakMap,ef=F(function(){if(clearTimeout(v(this,Va)),!v(this,Te))return;const t=v(this,Vl),e=t==null?v(this,Gd)+nr.INITIAL_SYNC_INACTIVITY_MS:t+nr.IDLE_DISCONNECT_MS,r=Math.max(0,e-y());Z(this,Va,setTimeout(()=>{var s;if((s=v(this,Te))!=null&&s.connected){if(P(this,B,Xa).call(this)){P(this,B,ef).call(this);return}v(this,Te).disconnect().catch(()=>{})}},r))},"#scheduleIdleDisconnect"),Xk=F(async function(t){const e=v(this,Te);if(!(e!=null&&e.connected))return;if(v(this,Ai))return v(this,Ai);const r=y();if(!(v(this,Kl)!=null&&r-v(this,Kl)<nr.SYNC_RECOVERY_COOLDOWN_MS))return Z(this,Kl,r),Z(this,Ai,(async()=>{v(this,lt).log.info("sync.rebuild",{client_instance_id:v(this,Jr),reason:t}),await e.disconnect().catch(()=>{}),!v(this,Ya).signal.aborted&&v(this,Te)===e&&Z(this,Te,P(this,B,Dg).call(this))})().finally(()=>{Z(this,Ai,void 0)})),v(this,Ai)},"#recoverContinuumSync"),tf=F(function(){const t=v(this,Od);return t!=null&&!v(this,Pn).isPast(t)},"#isWithinContinuumSyncGraceWindow"),Yl=F(function(t,e=!1){var r;if((r=v(this,Sr))!=null&&r.transport.isConnected&&!e)return v(this,Sr).emit.telemetry(v(this,lt),t);try{return e?v(this,Ga).emit.telemetry(v(this,lt),t,"beacon"):v(this,Ga).emit.telemetry(v(this,lt),t)}catch{}},"#dispatchTelemetry"),F(nr,"DirectRPCClient"),Dd(nr,"INITIAL_SYNC_INACTIVITY_MS",1e4),Dd(nr,"IDLE_DISCONNECT_MS",6e4),Dd(nr,"SYNC_RECOVERY_COOLDOWN_MS",3e3),Dd(nr,"SYNC_BOOTSTRAP_GRACE_MS",1e3),X(nr,Ug,1);let z1=nr;function Mi(t){return{jsonrpc:"2.0",...t}}o(Mi,"q"),F(Mi,"addJsonRpc");var H1=Object.defineProperty,Zk=o((t,e)=>H1(t,"name",{value:e,configurable:!0}),"i$1");const e0={silent:1/0,error:40,warn:30,info:20,debug:10};function t0(t,e){if(!(t!=null&&t.onEvent))return!1;const r=t.client??"warn";return e0[e]>=e0[r]}o(t0,"d$1"),Zk(t0,"shouldEmitClientLevel");function Ti(t,e,r,s="debug"){if(!t0(t,s))return;const n=t==null?void 0:t.onEvent;n&&n({level:s,name:e,value:r,timestamp:Date.now()})}o(Ti,"emitFetchLogEvent"),Zk(Ti,"emitFetchLogEvent");var K1=Object.defineProperty,Jl=o((t,e)=>K1(t,"name",{value:e,configurable:!0}),"t");const G1=Jl(t=>t instanceof URL?t:typeof t=="string"?r0(t):typeof Request<"u"&&t instanceof Request?r0(t.url):null,"resolveUrl"),r0=Jl(t=>{try{return new URL(t)}catch{return null}},"safeUrl"),V1=Jl(t=>{if(!s0(t.hostname))return null;const e=t.pathname.split("/").filter(Boolean),[r,s,n]=e;if(e.length!==3||r!=="v1"||!s||!n)return null;const i=s.indexOf(".");return i<=0||i===s.length-1?null:{projectId:s.slice(0,i),projectToken:s.slice(i+1),networkId:Y1(n),baseUrl:t.origin}},"parseDirectUrl"),s0=Jl(t=>v0.has(t),"isAllowedHost"),Y1=Jl(t=>{if(!t.includes("%"))return t;try{return decodeURIComponent(t)}catch{return t}},"safeDecode");var J1=Object.defineProperty,Lg=o((t,e)=>J1(t,"name",{value:e,configurable:!0}),"r$1");const X1=Lg(t=>{const e=new Map;return{getClientForUrl:Lg(r=>{const s=Q1(r),n=e.get(s);if(n)return Ti(t.logging,"client.phase",{phase:"reused",client_instance_id:n.client.getClientInstanceId(),cache_key:s,project_id:n.config.projectId,network_id:n.config.networkId}),n;const i=V1(r);if(!i)return null;Ti(t.logging,"client.phase",{phase:"creating",cache_key:s,project_id:i.projectId,network_id:i.networkId,base_url:i.baseUrl});const a=new z1({projectId:i.projectId,projectToken:i.projectToken,networkId:i.networkId,logging:t.logging,baseUrl:i.baseUrl,fetch:t.baseFetch,createWebSocket:t.createWebSocket}),c={client:a,config:i};return e.set(s,c),Ti(t.logging,"client.phase",{phase:"created",client_instance_id:a.getClientInstanceId(),cache_key:s,project_id:i.projectId,network_id:i.networkId}),c},"getClientForUrl")}},"createClientPool"),Q1=Lg(t=>{let e=t.pathname;for(;e.endsWith("/");)e=e.slice(0,-1);return`${t.origin}${e}`},"buildUrlCacheKey");var Z1=Object.defineProperty,Fg=o((t,e)=>Z1(t,"name",{value:e,configurable:!0}),"s$1");const eM=new Set(["direct_client_preload","direct_client_status"]),tM=Fg(t=>typeof t=="string"&&eM.has(t),"isDirectClientMethod"),n0=Fg((t,e)=>{var r,s;const{method:n,id:i}=t;if(!tM(n))return{kind:"not_handled"};if(i===void 0)return{kind:"notification"};const{directConfig:a}=e;switch(n==="direct_client_preload"&&Ti(e.logging,"preload.phase",{phase:"command_handled",client_instance_id:e.clientInstanceId,method:n,network_id:a.networkId,project_id:a.projectId,has_response:i!==void 0}),n){case"direct_client_preload":return{kind:"response",response:{jsonrpc:"2.0",result:"ok",id:i}};case"direct_client_status":return{kind:"response",response:{jsonrpc:"2.0",result:{initialized:!0,projectId:a.projectId,projectToken:a.projectToken,networkId:a.networkId,baseUrl:a.baseUrl,logging:{client:(r=e.logging)==null?void 0:r.client,requests:(s=e.logging)==null?void 0:s.requests}},id:i}};default:return{kind:"not_handled"}}},"handleSingleDirectMethod"),rM=Fg((t,e)=>{if(!Array.isArray(t)){const n=n0(t,e);switch(n.kind){case"response":return{handled:[n.response],forward:null};case"notification":return{handled:[],forward:null};case"not_handled":return{handled:[],forward:t}}}const r=[],s=[];for(const n of t){const i=n0(n,e);switch(i.kind){case"response":r.push(i.response);break;case"notification":break;case"not_handled":s.push(n);break}}return{handled:r,forward:s.length>0?s:null}},"handleDirectMethods"),sM=ke("createFetchOptions",l.shape({fetch:l.unknown.optional,createWebSocket:l.unknown.optional,logging:l.shape({client:l.literal("silent","info","debug","warn","error").optional,requests:l.literal("off","summary","debug").optional,onEvent:l.unknown.optional}).optional,preload:l.arr(l.str).optional}));var nM=Object.defineProperty,iM=o((t,e)=>nM(t,"name",{value:e,configurable:!0}),"c$1");const aM=iM((t,e,r)=>{if(!Array.isArray(t))return e[0]??r[0];if(e.length===0)return r;if(r.length===0)return e;const s=new Map;for(const i of r)i.id!==void 0&&s.set(i.id,i);const n=new Map;for(const i of e)i.id!==void 0&&n.set(i.id,i);return t.filter(i=>i.id!==void 0).map(i=>{const a=i.id;return n.get(a)??s.get(a)??{jsonrpc:"2.0",error:{code:-32603,message:"Internal error"},id:a}})},"mergeResults");var oM=Object.defineProperty,zg=o((t,e)=>oM(t,"name",{value:e,configurable:!0}),"o$1");const i0=typeof TextDecoder<"u"?new TextDecoder:null,Hg=zg(t=>{try{const e=JSON.parse(t);return e&&typeof e=="object"?e:null}catch{return null}},"parseJson"),cM=zg(t=>{if(!i0)return null;const e=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return Hg(i0.decode(e))},"parseBufferSource"),lM=zg(async(t,e)=>{if((e==null?void 0:e.body)!=null){const{body:r}=e;if(typeof r=="string")return Hg(r);if(typeof Blob<"u"&&r instanceof Blob){const s=await r.text().catch(()=>null);return s===null?null:Hg(s)}return r instanceof ArrayBuffer||ArrayBuffer.isView(r)?cM(r):null}if(typeof Request<"u"&&t instanceof Request){if(!t.body||t.bodyUsed)return null;try{const r=await t.clone().json();if(r&&typeof r=="object")return r}catch{}}return null},"readJsonPayloadInput");var hM=Object.defineProperty,Kg=o((t,e)=>hM(t,"name",{value:e,configurable:!0}),"n");const uM=Kg(()=>{if(typeof document>"u")return[];try{const t=document.querySelectorAll('link[rel="preload"][href*="direct.dev"]'),e=[];for(const r of t)r.href&&e.push(r.href);return e}catch{return[]}},"getPreloadLinksFromDOM"),dM=Kg(t=>t?[...new Set(t)]:[...new Set(uM())],"collectPreloadUrls"),fM=Kg((t,e,r)=>{var s;for(const n of e)(s=r==null?void 0:r.onDispatch)==null||s.call(r,n),t(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:"direct_client_preload",params:[],id:1})}).catch(()=>{})},"preloadUrls");var pM=Object.defineProperty,Ri=o((t,e)=>pM(t,"name",{value:e,configurable:!0}),"e");const mM=Ri((t,e)=>{let r=!1,s=null;const n=Ri(()=>{if(s===null){const f=JSON.stringify(t);s=f===void 0?"null":f}return s},"getBody"),i=new Response(gM(n),{status:200,headers:{...g0,[w0]:String(e)}}),a=Object.getOwnPropertyDescriptor(Response.prototype,"bodyUsed"),c=a!=null&&a.get?()=>{var f;return(f=a.get)==null?void 0:f.call(i)}:()=>!1,h=Ri(()=>r||c(),"isBodyUsed"),u=Ri(async()=>{if(h())throw new TypeError("Body has already been consumed.");if(r=!0,i.body)try{await i.body.cancel()}catch{}},"consumeOnce"),d=Ri(async()=>(await u(),t),"json"),p=Ri(async()=>(await u(),n()),"text");try{Object.defineProperty(i,"bodyUsed",{get:h})}catch{}return Object.defineProperties(i,{json:{value:d},text:{value:p}}),i},"createJsonResponse"),gM=Ri(t=>{if(typeof ReadableStream>"u"||!tw)return t();const e=tw;return new ReadableStream({pull(r){r.enqueue(e.encode(t())),r.close()}})},"createLazyBody");var wM=Object.defineProperty,a0=o((t,e)=>wM(t,"name",{value:e,configurable:!0}),"o");const o0=a0(()=>typeof performance<"u"?performance.now():Date.now(),"getTimingNow"),vM=a0(t=>Number(t.toFixed(2)),"formatDuration");var _M=Object.defineProperty,Xl=o((t,e)=>_M(t,"name",{value:e,configurable:!0}),"l");let rf=!1,c0=0,Gg;const l0=Xl((t={})=>{var e;const r=sM.parse(t),s=(e=globalThis.fetch)==null?void 0:e.bind(globalThis);if(rf&&!r.fetch)throw new Error("Cannot call createFetch() after install(). Use the globally installed fetch or call uninstall() first.");const n=r.fetch??s,i=r.logging;if(!n)throw new Error(_0);if(!globalThis.Response)throw new Error(y0);if(!globalThis.Request)throw new Error(b0);const a=X1({logging:i,baseFetch:n,createWebSocket:r.createWebSocket}),c=Xl(async(u,d)=>{var p;const f=G1(u);if(!f||!s0(f.hostname)||(((p=d==null?void 0:d.method)==null?void 0:p.toUpperCase())??(u instanceof Request?u.method.toUpperCase():"GET"))!=="POST")return n(u,d);const g=a.getClientForUrl(f);if(!g)return n(u,d);const m=await lM(u,d);if(!m)return n(u,d);const{handled:w,forward:_}=rM(m,{directConfig:g.config,logging:i,clientInstanceId:g.client.getClientInstanceId()}),S=o0();let b=[];if(_)try{const x=await g.client.fetch(_);b=(Array.isArray(x)?x:[x]).filter(K=>K!==void 0)}catch(x){const K=Array.isArray(_)?_.map(Pe=>Pe.method).join(", "):_.method,I=x instanceof Error?x.message:String(x);throw new Error(`direct.dev fetch failed [${g.config.networkId}] (${K}): ${I}`)}const D=vM(o0()-S);if(!Array.isArray(m)&&m.id===void 0)return new Response(null,{status:204});const O=aM(m,w,b);return Array.isArray(O)&&O.length===0?new Response(null,{status:204}):mM(O,D)},"wrappedFetch"),h=dM(r.preload);return Ti(i,"preload.phase",{phase:"urls_collected",source:r.preload?"config":"dom",url_count:h.length,urls:h}),h.length&&fM(c,h,{onDispatch:Xl(u=>{Ti(i,"preload.phase",{phase:"command_sent",url:u,method:"direct_client_preload"})},"onDispatch")}),c},"createFetch"),yM=Xl((t={})=>{if(rf)return Gg??(()=>{});const e=globalThis.fetch,r=e==null?void 0:e.bind(globalThis),s=l0({...t,fetch:t.fetch??r});globalThis.fetch=s,rf=!0;const n=++c0,i=Xl(()=>{c0===n&&(globalThis.fetch=e,rf=!1,Gg=void 0)},"uninstall");return Gg=i,i},"install");export{l0 as createFetch,yM as install};
3
+ - ${s.lastError}`}return s.lastError="did not match any union type:"+n,!1},"safeParse"),encode:me(r=>{for(let s=0;s<e;s++){const n=t[s];if(n._safeParse(r))return String.fromCharCode(s)+n._encode(r)}throw new Wv("did not match any union type")},"encode"),decodeTrusted:me((r,s)=>{const n=r.charCodeAt(s.offset++);return t[n]._decodeTrusted(r)},"decodeTrusted"),decodeUntrusted:me((r,s)=>{const n=r.charCodeAt(s.offset++);if(Number.isNaN(n))throw $.PAYLOAD_TRUNCATED;const i=t[n];if(!i)throw new $("union index out-of-range");return i._decodeUntrusted(r)},"decodeUntrusted")})}o(Nv,"x$e"),me(Nv,"union");function Lv(t,e,r,s){const n=e.length,i={...s,ignoredProps:[...(s==null?void 0:s.ignoredProps)??[],t]},a=r?xc(r,i):void 0,c=new Array(n),h=new Map;for(let p=0;p<n;p++){const f=e[p],g=f[0],m=xc(f[1],i);c[p]={type:m,tag:g},h.set(f[0],{i:p,type:m})}let u;const d=ne({safeParse:me((p,f)=>{if(!Fi(p))return f.lastError="must be a record",!1;if(!(t in p))return f.lastCtx=`.${t}`,f.lastError="discriminant missing",!1;const g=h.get(p[t]);return g?g.type._safeParse(p)?!0:a?a._safeParse(p):!1:a?a._safeParse(p):(u??=`did not match any discriminant tags: ${JSON.stringify(e.map(m=>m[0]))}`,f.lastCtx=`.${t}`,f.lastError=u,!1)},"safeParse"),encode:me(p=>{const f=h.get(p[t]);if(f&&f.type._safeParse(p))return String.fromCharCode(f.i)+f.type._encode(p);if(a)return"\x7F"+a._encode(p);throw u??=`did not match any discriminant tags: ${JSON.stringify(e.map(g=>g[0]))}`,new Wv(u)},"encode"),decodeTrusted:me((p,f)=>{const g=p.charCodeAt(f.offset++),m=c[g];if(m!=null){const w=m.type._decodeTrusted(p);return w[t]=m.tag,w}if(g===127){if(!a)throw new $("no taggedUnion fallback shape defined");return a._decodeTrusted(p)}throw new $("discriminant variant index out-of-range")},"decodeTrusted"),decodeUntrusted:me((p,f)=>{const g=p.charCodeAt(f.offset++);if(Number.isNaN(g))throw $.PAYLOAD_TRUNCATED;const m=c[g];if(m!=null){const w=m.type._decodeUntrusted(p);if(f.offset>f.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return w[t]=m.tag,w}if(g===127){if(!a)throw new $("no taggedUnion fallback shape defined");const w=a._decodeUntrusted(p);if(f.offset>f.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return w}throw new $("discriminant variant index out-of-range")},"decodeUntrusted")});return Object.assign(d,{__tags:Array.from(h.keys())})}o(Lv,"S$g"),me(Lv,"taggedUnion");var ZC=Object.freeze({__proto__:null,arr:Dv,record:jv,shape:xc,taggedUnion:Lv,tuple:Ov,union:Nv}),eS=Object.defineProperty,$e=o((t,e)=>eS(t,"name",{value:e,configurable:!0}),"e$h");const Gn=112,Lh=0,Wc=_w,Fh=$e((...t)=>{const e=t.length,r=new Map;for(let n=0;n<e;n++){const i=t[n];r.set(i,String.fromCharCode(n))}let s;return ne({safeParse:$e((n,i)=>r.has(n)?!0:(s??=`must be ${JSON.stringify(t)}`,i.lastCtx="",i.lastError=s,!1),"safeParse"),encode:$e(n=>r.get(n),"encode"),decodeTrusted:$e((n,i)=>t[n.charCodeAt(i.offset++)],"decodeTrusted"),decodeUntrusted:$e((n,i)=>{const a=n.charCodeAt(i.offset++);if(Number.isNaN(a))throw $.PAYLOAD_TRUNCATED;if(i.offset>i.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;if(a>=t.length)throw new $(`literal index must be < ${t.length}`);return t[a]},"decodeUntrusted")})},"literal"),tS=$e((...t)=>{const e=t.length,r=new Map;for(let s=0;s<e;s++){const n=t[s];r.set(n,String.fromCharCode(512|s))}return ne({safeParse:$e((s,n)=>typeof s!="string"?(n.lastCtx="",n.lastError="must be a string",!1):!0,"safeParse"),encode:$e(s=>r.get(s)??jh(s),"encode"),decodeTrusted:$e((s,n)=>{const i=s.charCodeAt(n.offset);return i>=512?(n.offset++,t[i&511]):nn(s,n)},"decodeTrusted"),decodeUntrusted:$e((s,n)=>{const i=s.charCodeAt(n.offset);if(Number.isNaN(i))throw $.PAYLOAD_TRUNCATED;if(i>=512){const c=i&511;if(n.offset++,c>=e)throw new $(`dictionary index must be < ${e}`);return t[c]}const a=nn(s,n);if(n.offset>n.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return a},"decodeUntrusted")})},"strWithDict"),Fv=ne({safeParse:$e((t,e)=>typeof t!="string"?(e.lastCtx="",e.lastError="must be a string",!1):t.length!==nt?(e.lastCtx="",e.lastError=`must be exactly ${nt} characters long`,!1):(t.charCodeAt(0)&Gn)!==Lh?(e.lastCtx="",e.lastError="invalid FNV-1a magic bits",!1):!0,"safeParse"),encode:$e(t=>t,"encode"),decodeTrusted:$e((t,e)=>{const r=e.offset;return e.offset=r+nt,t.slice(r,e.offset)},"decodeTrusted"),decodeUntrusted:$e((t,e)=>{const r=e.offset;if(e.offset=r+nt,e.offset>t.length)throw $.PAYLOAD_TRUNCATED;if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;const s=t.slice(r,e.offset);if((s.charCodeAt(0)&Gn)!==Lh)throw new $("invalid FNV-1a magic bits");return s},"decodeUntrusted")}),rS=ne({safeParse:$e((t,e)=>typeof t!="string"?(e.lastCtx="",e.lastError="must be a string",!1):t.length!==Rt?(e.lastCtx="",e.lastError=`must be exactly ${Rt} characters long`,!1):(t.charCodeAt(0)&Gn)!==Wc?(e.lastCtx="",e.lastError="invalid SHA-256 magic bits",!1):!0,"safeParse"),encode:$e(t=>t,"encode"),decodeTrusted:$e((t,e)=>{const r=e.offset;return e.offset=r+Rt,t.slice(r,e.offset)},"decodeTrusted"),decodeUntrusted:$e((t,e)=>{const r=e.offset;if(e.offset=r+Rt,e.offset>t.length)throw $.PAYLOAD_TRUNCATED;if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;const s=t.slice(r,e.offset);if((s.charCodeAt(0)&Gn)!==Wc)throw new $("invalid SHA-256 magic bits");return s},"decodeUntrusted")}),sS=ne({safeParse:$e((t,e)=>{if(typeof t!="string")return e.lastCtx="",e.lastError="must be a string",!1;if(t.length===0)return e.lastCtx="",e.lastError="must not be empty",!1;const r=t.charCodeAt(0)&Gn;switch(r){case Lh:return t.length!==nt?(e.lastCtx="",e.lastError=`FNV-1a hash must be exactly ${nt} characters long`,!1):!0;case Wc:return t.length!==Rt?(e.lastCtx="",e.lastError=`SHA-256 hash must be exactly ${Rt} characters long`,!1):!0;default:return e.lastCtx="",e.lastError=`unknown hash algorithm ID: ${r}`,!1}},"safeParse"),encode:$e(t=>t,"encode"),decodeTrusted:$e((t,e)=>{const r=(t.charCodeAt(e.offset)&Gn)===Wc?Rt:nt,s=e.offset;return e.offset=s+r,t.slice(s,e.offset)},"decodeTrusted"),decodeUntrusted:$e((t,e)=>{if(e.offset>=t.length)throw $.PAYLOAD_TRUNCATED;const r=t.charCodeAt(e.offset)&Gn;let s;switch(r){case Lh:s=nt;break;case Wc:s=Rt;break;default:throw new $(`unknown hash algorithm ID: ${r}`)}const n=e.offset;if(e.offset=n+s,e.offset>t.length)throw $.PAYLOAD_TRUNCATED;if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return t.slice(n,e.offset)},"decodeUntrusted")}),nS=$e(t=>ne({safeParse:$e((e,r)=>typeof e!="string"?(r.lastCtx="",r.lastError="must be a string",!1):(t.lastIndex=0,t.test(e)?!0:(r.lastCtx="",r.lastError=`must match ${t}`,!1)),"safeParse"),encode:$e(e=>jh(e),"encode"),decodeTrusted:$e((e,r)=>nn(e,r),"decodeTrusted"),decodeUntrusted:$e((e,r)=>{const s=nn(e,r);if(r.offset>r.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;if(!t.test(s))throw new $(`must match ${t}`);return s},"decodeUntrusted")}),"strWithPattern");var iS=Object.freeze({__proto__:null,fnv1a:Fv,hash:sS,literal:Fh,sha256:rS,strWithDict:tS,strWithPattern:nS}),aS=Object.defineProperty,Re=o((t,e)=>aS(t,"name",{value:e,configurable:!0}),"s$q");const oS=ne({safeParse:Re((t,e)=>typeof t!="string"?(e.lastCtx="",e.lastError="must be a string",!1):!0,"safeParse"),encode:Re(t=>jh(t),"encode"),decodeTrusted:Re((t,e)=>nn(t,e),"decodeTrusted"),decodeUntrusted:Re((t,e)=>{const r=nn(t,e);if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r},"decodeUntrusted")}),cS=ne({safeParse:Re((t,e)=>typeof t!="number"?(e.lastCtx="",e.lastError="must be a number",!1):Number.isNaN(t)?(e.lastCtx="",e.lastError="must be not be NaN",!1):Number.isFinite(t)?!0:(e.lastCtx="",e.lastError="must be finite",!1),"safeParse"),encode:Re(t=>t>>>0===t?Pc(t,0):Oh(t,1),"encode"),decodeTrusted:Re((t,e)=>{const r=t.charCodeAt(e.offset++);switch(r&3){case 0:return Rs(t,r,e);case 1:return Bs(t,r,e)}throw new $(`malformed num header '${r}', type not recognized`)},"decodeTrusted"),decodeUntrusted:Re((t,e)=>{let r;const s=t.charCodeAt(e.offset++);if(Number.isNaN(s))throw $.PAYLOAD_TRUNCATED;switch(s&3){case 0:r=Rs(t,s,e);break;case 1:r=Bs(t,s,e);break;default:throw new $(`malformed num header '${s}', type not recognized`)}if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r},"decodeUntrusted")}),lS=ne({safeParse:Re((t,e)=>typeof t!="number"?(e.lastCtx="",e.lastError="must be a number",!1):Number.isNaN(t)?(e.lastCtx="",e.lastError="must be not be NaN",!1):t>>>0!==t?(e.lastCtx="",e.lastError="must be a uint32",!1):!0,"safeParse"),encode:Re(t=>pr(t),"encode"),decodeTrusted:Re((t,e)=>at(t,e),"decodeTrusted"),decodeUntrusted:Re((t,e)=>{const r=at(t,e);if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r},"decodeUntrusted")}),hS=ne({safeParse:Re((t,e)=>typeof t!="boolean"?(e.lastCtx="",e.lastError="must be a boolean",!1):!0,"safeParse"),encode:Re(t=>t?"1":"0","encode"),decodeTrusted:Re((t,e)=>t.charCodeAt(e.offset++)===49,"decodeTrusted"),decodeUntrusted:Re((t,e)=>{if(e.offset>=t.length)throw $.PAYLOAD_TRUNCATED;if(e.offset+1>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return t.charCodeAt(e.offset++)===49},"decodeUntrusted")}),uS=ne({safeParse:Re((t,e)=>typeof t!="number"?(e.lastCtx="",e.lastError="must be a number",!1):t<0?(e.lastCtx="",e.lastError="must be >= 0",!1):t>4398046511103?(e.lastCtx="",e.lastError="must be <= 4_398_046_511_103",!1):!0,"safeParse"),encode:Re(t=>XC(t),"encode"),decodeTrusted:Re((t,e)=>Uv(t,e),"decodeTrusted"),decodeUntrusted:Re((t,e)=>{const r=Uv(t,e);if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r},"decodeUntrusted")}),dS=ne({safeParse:Re(t=>!0,"safeParse"),encode:Re(t=>typeof t=="string"?Nh(t,2):typeof t=="number"?t>>>0===t?Pc(t,0):Oh(t,1):Nh(JSON.stringify(t),3),"encode"),decodeTrusted:Re((t,e)=>{const r=t.charCodeAt(e.offset++);switch(r&3){case 2:return an(t,r,e);case 0:return Rs(t,r,e);case 1:return Bs(t,r,e);case 3:return JSON.parse(an(t,r,e))}throw new $(`malformed unknown header '${r}', type not recognized`)},"decodeTrusted"),decodeUntrusted:Re((t,e)=>{let r;const s=t.charCodeAt(e.offset++);switch(s&3){case 2:r=an(t,s,e);break;case 0:r=Rs(t,s,e);break;case 1:r=Bs(t,s,e);break;case 3:{const n=an(t,s,e);if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;try{r=JSON.parse(n)}catch{throw $.JSON_PARSE}break}default:throw new $(`malformed unknown header '${s}', type not recognized`)}if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r},"decodeUntrusted")});var fS=Object.freeze({__proto__:null,bool:hS,num:cS,str:oS,timestamp:uS,uint32:lS,unknown:dS}),pS=Object.defineProperty,on=o((t,e)=>pS(t,"name",{value:e,configurable:!0}),"A$i");const mS=ne({safeParse:on((t,e)=>t==null||!(t instanceof Uint8Array)?(e.lastCtx="",e.lastError="must be a Uint8Array",!1):t.length!==16?(e.lastCtx="",e.lastError="must contain exactly 16 bytes",!1):!0,"safeParse"),encode:on(t=>String.fromCharCode(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15]),"encode"),decodeTrusted:on((t,e)=>{const r=e.offset;return e.offset=r+16,new Uint8Array([t.charCodeAt(r),t.charCodeAt(r+1),t.charCodeAt(r+2),t.charCodeAt(r+3),t.charCodeAt(r+4),t.charCodeAt(r+5),t.charCodeAt(r+6),t.charCodeAt(r+7),t.charCodeAt(r+8),t.charCodeAt(r+9),t.charCodeAt(r+10),t.charCodeAt(r+11),t.charCodeAt(r+12),t.charCodeAt(r+13),t.charCodeAt(r+14),t.charCodeAt(r+15)])},"decodeTrusted"),decodeUntrusted:on((t,e)=>{if(e.offset+16>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;if(e.offset+16>t.length)throw $.PAYLOAD_TRUNCATED;const r=e.offset;return e.offset=r+16,new Uint8Array([t.charCodeAt(r),t.charCodeAt(r+1),t.charCodeAt(r+2),t.charCodeAt(r+3),t.charCodeAt(r+4),t.charCodeAt(r+5),t.charCodeAt(r+6),t.charCodeAt(r+7),t.charCodeAt(r+8),t.charCodeAt(r+9),t.charCodeAt(r+10),t.charCodeAt(r+11),t.charCodeAt(r+12),t.charCodeAt(r+13),t.charCodeAt(r+14),t.charCodeAt(r+15)])},"decodeUntrusted")}),gS=ne({safeParse:on((t,e)=>t==null||!(t instanceof Uint8Array)?(e.lastCtx="",e.lastError="must be a Uint8Array",!1):t.length!==8?(e.lastCtx="",e.lastError="must contain exactly 8 bytes",!1):!0,"safeParse"),encode:on(t=>String.fromCharCode(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]),"encode"),decodeTrusted:on((t,e)=>{const r=e.offset;return e.offset=r+8,new Uint8Array([t.charCodeAt(r),t.charCodeAt(r+1),t.charCodeAt(r+2),t.charCodeAt(r+3),t.charCodeAt(r+4),t.charCodeAt(r+5),t.charCodeAt(r+6),t.charCodeAt(r+7)])},"decodeTrusted"),decodeUntrusted:on((t,e)=>{if(e.offset+8>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;if(e.offset+8>t.length)throw $.PAYLOAD_TRUNCATED;const r=e.offset;return e.offset=r+8,new Uint8Array([t.charCodeAt(r),t.charCodeAt(r+1),t.charCodeAt(r+2),t.charCodeAt(r+3),t.charCodeAt(r+4),t.charCodeAt(r+5),t.charCodeAt(r+6),t.charCodeAt(r+7)])},"decodeUntrusted")});var wS=Object.freeze({__proto__:null,spanId:gS,traceId:mS}),vS=Object.defineProperty,ie=o((t,e)=>vS(t,"name",{value:e,configurable:!0}),"u$u");const _S=Fh("ethereum-holesky","ethereum-sepolia","ethereum","sonic-blaze-testnet","sonic-testnet","sonic"),zv=ne({safeParse:ie((t,e)=>typeof t!="string"?(e.lastCtx="",e.lastError="must be a string",!1):ff(t)?!0:(e.lastCtx="",e.lastError="must be a valid block height (0x-prefixed hex without leading zeros)",!1),"safeParse"),encode:ie(t=>jh(t),"encode"),decodeTrusted:ie((t,e)=>nn(t,e),"decodeTrusted"),decodeUntrusted:ie((t,e)=>{const r=nn(t,e);if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;if(!ff(r))throw new $("invalid block height format");return r},"decodeUntrusted")}),yS=Fh(...qf),Hv=Fv,bS=xc({height:zv,digest:Hv}),$S=Fh("ankr","drpc","envio","direct");function Kv(t){return ne({safeParse:ie((e,r)=>{if(typeof e!="string")return r.lastCtx="",r.lastError="must be a string",!1;const s=e.charCodeAt(0);if(s>127)return r.lastCtx="",r.lastError="invalid flags byte (bit 7 must be 0)",!1;const n=(s&Bt)!==0;if(t==="with-checksum"&&!n)return r.lastCtx="",r.lastError="request fingerprint must include checksum (FLAG_HAS_CHECKSUM not set)",!1;if(t==="without-checksum"&&n)return r.lastCtx="",r.lastError="request fingerprint must not include checksum (FLAG_HAS_CHECKSUM is set)",!1;const i=n?1+Rt+nt:1+nt;return e.length!==i?(r.lastCtx="",r.lastError=`request fingerprint must be exactly ${i} characters`,!1):!0},"safeParse"),encode:ie(e=>e,"encode"),decodeTrusted:ie((e,r)=>{const s=(e.charCodeAt(r.offset)&Bt)!==0?1+Rt+nt:1+nt,n=r.offset;return r.offset=n+s,e.slice(n,r.offset)},"decodeTrusted"),decodeUntrusted:ie((e,r)=>{if(r.offset>=e.length)throw $.PAYLOAD_TRUNCATED;const s=e.charCodeAt(r.offset);if(s>127)throw new $("invalid flags byte (bit 7 must be 0)");const n=(s&Bt)!==0;if(t==="with-checksum"&&!n)throw new $("request fingerprint must include checksum (FLAG_HAS_CHECKSUM not set)");if(t==="without-checksum"&&n)throw new $("request fingerprint must not include checksum (FLAG_HAS_CHECKSUM is set)");const i=n?1+Rt+nt:1+nt,a=r.offset;if(r.offset=a+i,r.offset>e.length)throw $.PAYLOAD_TRUNCATED;if(r.offset>r.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return e.slice(a,r.offset)},"decodeUntrusted")})}o(Kv,"x$d"),ie(Kv,"requestFingerprint");function Gv(t){return ne({safeParse:ie((e,r)=>{if(typeof e!="string")return r.lastCtx="",r.lastError="must be a string",!1;const s=e.charCodeAt(0);if(s>127)return r.lastCtx="",r.lastError="invalid flags byte (bit 7 must be 0)",!1;const n=(s&Xs)!==0,i=(s&Bt)!==0;if(t==="with-checksum"&&!i)return r.lastCtx="",r.lastError="request identifier must include checksum (FLAG_HAS_CHECKSUM not set)",!1;if(t==="without-checksum"&&i)return r.lastCtx="",r.lastError="request identifier must not include checksum (FLAG_HAS_CHECKSUM is set)",!1;const a=i?ks:$s,c=i?Li:Ni;return e.length===a||n&&e.length===c?!0:(r.lastCtx="",r.lastError=n?`request identifier must be ${a} or ${c} bytes`:`request identifier must be exactly ${a} bytes`,!1)},"safeParse"),encode:ie(e=>{const r=(e.charCodeAt(0)&Bt)!==0?ks:$s;return e.length>r?""+e:"\0"+e},"encode"),decodeTrusted:ie((e,r)=>{const s=e.charCodeAt(r.offset++)===1,n=(e.charCodeAt(r.offset)&Bt)!==0,i=r.offset;return s?(r.offset=i+(n?Li:Ni),e.slice(i,r.offset)):(r.offset=i+(n?ks:$s),e.slice(i,r.offset))},"decodeTrusted"),decodeUntrusted:ie((e,r)=>{if(r.offset>=e.length)throw $.PAYLOAD_TRUNCATED;const s=e.charCodeAt(r.offset++)===1;if(r.offset>=e.length)throw $.PAYLOAD_TRUNCATED;const n=e.charCodeAt(r.offset);if(n>127)throw new $("invalid flags byte (bit 7 must be 0)");const i=(n&Bt)!==0;if(t==="with-checksum"&&!i)throw new $("request identifier must include checksum (FLAG_HAS_CHECKSUM not set)");if(t==="without-checksum"&&i)throw new $("request identifier must not include checksum (FLAG_HAS_CHECKSUM is set)");const a=s?i?Li:Ni:i?ks:$s,c=r.offset;if(c+a>e.length)throw $.PAYLOAD_TRUNCATED;if(c+a>r.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r.offset=c+a,e.slice(c,r.offset)},"decodeUntrusted")})}o(Gv,"M$h"),ie(Gv,"requestIdentifier");function Vv(t){return ne({safeParse:ie((e,r)=>{if(typeof e!="string")return r.lastCtx="",r.lastError="must be a string",!1;const s=e.charCodeAt(0);if(s>127)return r.lastCtx="",r.lastError="invalid flags byte (bit 7 must be 0)",!1;const n=(s&Xs)!==0,i=(s&Bt)!==0;if(t==="with-checksum"&&!i)return r.lastCtx="",r.lastError="request key must include checksum (FLAG_HAS_CHECKSUM not set)",!1;if(t==="without-checksum"&&i)return r.lastCtx="",r.lastError="request key must not include checksum (FLAG_HAS_CHECKSUM is set)",!1;let a;return n?i?a=Li:a=Ni:i?a=ks:a=$s,e.length!==a?(r.lastCtx="",r.lastError=n?`request key must be exactly ${a} bytes when FLAG_HAS_BLOCK_DIGEST is set`:`request key must be exactly ${a} bytes`,!1):!0},"safeParse"),encode:ie(e=>e,"encode"),decodeTrusted:ie((e,r)=>{const s=e.charCodeAt(r.offset),n=(s&Bt)!==0,i=(s&Xs)!==0,a=r.offset;return i?n?r.offset=a+Li:r.offset=a+Ni:n?r.offset=a+ks:r.offset=a+$s,e.slice(a,r.offset)},"decodeTrusted"),decodeUntrusted:ie((e,r)=>{if(r.offset>=e.length)throw $.PAYLOAD_TRUNCATED;const s=e.charCodeAt(r.offset);if(s>127)throw new $("invalid flags byte (bit 7 must be 0)");const n=(s&Bt)!==0,i=(s&Xs)!==0;if(t==="with-checksum"&&!n)throw new $("request key must include checksum (FLAG_HAS_CHECKSUM not set)");if(t==="without-checksum"&&n)throw new $("request key must not include checksum (FLAG_HAS_CHECKSUM is set)");let a;i?n?a=Li:a=Ni:n?a=ks:a=$s;const c=r.offset;if(c+a>e.length)throw $.PAYLOAD_TRUNCATED;if(c+a>r.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return r.offset=c+a,e.slice(c,r.offset)},"decodeUntrusted")})}o(Vv,"z$d"),ie(Vv,"requestKey");const kS=ne({safeParse:ie((t,e)=>typeof t!="string"?(e.lastCtx="",e.lastError="must be a string",!1):t.length!==hh?(e.lastCtx="",e.lastError=`must be exactly ${hh} characters long`,!1):t.charCodeAt(0)>127?(e.lastCtx="",e.lastError="invalid flags byte (bit 7 must be 0)",!1):!0,"safeParse"),encode:ie(t=>t,"encode"),decodeTrusted:ie((t,e)=>{const r=e.offset;return e.offset=r+hh,t.slice(r,e.offset)},"decodeTrusted"),decodeUntrusted:ie((t,e)=>{const r=e.offset;if(e.offset=r+hh,e.offset>t.length)throw $.PAYLOAD_TRUNCATED;if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;if(t.charCodeAt(r)>127)throw new $("invalid flags byte (bit 7 must be 0)");return t.slice(r,e.offset)},"decodeUntrusted")}),CS=ne({safeParse:ie((t,e)=>t==null?!0:typeof t!="string"&&typeof t!="number"?(e.lastCtx="",e.lastError="must be a string, number, null, or undefined",!1):!0,"safeParse"),encode:ie(t=>t===void 0?"\u07FE":t===null?"\u07FF":typeof t=="string"?Nh(t,2):t>>>0===t?Pc(t,0):Oh(t,1),"encode"),decodeTrusted:ie((t,e)=>{const r=t.charCodeAt(e.offset);if(r===2046){e.offset++;return}if(r===2047)return e.offset++,null;switch(e.offset++,r&3){case 2:return an(t,r,e);case 0:return Rs(t,r,e);case 1:return Bs(t,r,e)}throw new $(`malformed rpcRequestId header '${r}', type not recognized`)},"decodeTrusted"),decodeUntrusted:ie((t,e)=>{if(e.offset>=t.length)throw $.PAYLOAD_TRUNCATED;const r=t.charCodeAt(e.offset);if(r===2046){if(e.offset++,e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return}if(r===2047){if(e.offset++,e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return null}e.offset++;let s;switch(r&3){case 2:s=an(t,r,e);break;case 0:s=Rs(t,r,e);break;case 1:s=Bs(t,r,e);break;default:throw new $(`malformed rpcRequestId header '${r}', type not recognized`)}if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return s},"decodeUntrusted")}),SS=ne({safeParse:ie((t,e)=>t===null?!0:typeof t!="string"&&typeof t!="number"?(e.lastCtx="",e.lastError="must be a string, number, or null",!1):!0,"safeParse"),encode:ie(t=>t===null?"\u07FF":typeof t=="string"?Nh(t,2):t>>>0===t?Pc(t,0):Oh(t,1),"encode"),decodeTrusted:ie((t,e)=>{const r=t.charCodeAt(e.offset);if(r===2047)return e.offset++,null;switch(e.offset++,r&3){case 2:return an(t,r,e);case 0:return Rs(t,r,e);case 1:return Bs(t,r,e)}throw new $(`malformed rpcResponseId header '${r}', type not recognized`)},"decodeTrusted"),decodeUntrusted:ie((t,e)=>{if(e.offset>=t.length)throw $.PAYLOAD_TRUNCATED;const r=t.charCodeAt(e.offset);if(r===2047){if(e.offset++,e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return null}e.offset++;let s;switch(r&3){case 2:s=an(t,r,e);break;case 0:s=Rs(t,r,e);break;case 1:s=Bs(t,r,e);break;default:throw new $(`malformed rpcResponseId header '${r}', type not recognized`)}if(e.offset>e.byteBudget)throw $.BYTE_BUDGET_EXHAUSTED;return s},"decodeUntrusted")});var AS=Object.freeze({__proto__:null,blockContext:bS,blockDigest:Hv,blockHeight:zv,networkId:_S,providerId:$S,requestFingerprint:Kv,requestIdentifier:Gv,requestKey:Vv,requestMethod:yS,responseKey:kS,rpcRequestId:CS,rpcResponseId:SS}),ES=Object.defineProperty,Vn=o((t,e)=>ES(t,"name",{value:e,configurable:!0}),"t$b");const l={...ZC,...iS,...fS,...wS,...AS};function ke(t,e){return Object.freeze({...e,parse:Vn(r=>{if(!e._safeParse(r))throw new Dh(`${t}${ft.lastCtx} ${ft.lastError}`);return r},"parse"),safeParse:Vn(r=>e._safeParse(r)?r:(Dh.lastMessage=`${t}${ft.lastCtx} ${ft.lastError}`,qc),"safeParse"),encode:Vn(r=>e._encode(r),"encode"),decodeTrusted:Vn((r,s=0,n=524288,i=16384)=>(pe.offset=s,pe.byteBudget=n,pe.arrayBudget=i,e._decodeTrusted(r)),"decodeTrusted"),decodeUntrusted:Vn((r,s=0,n=524288,i=16384)=>(pe.offset=s,pe.byteBudget=n,pe.arrayBudget=i,e._decodeUntrusted(r)),"decodeUntrusted")})}o(ke,"k$g"),Vn(ke,"makeCheckpoint");function vt(){return pe.offset}o(vt,"l$v"),Vn(vt,"getDecodeOffset");var MS=Object.defineProperty,TS=o((t,e)=>MS(t,"name",{value:e,configurable:!0}),"n$q");const Uc=bs("");function zh(t,e){return bs(t+":"+e)}o(zh,"m$s"),TS(zh,"computeChecksum");var RS=Object.defineProperty,Yv=o((t,e)=>RS(t,"name",{value:e,configurable:!0}),"s$o");const Jv={onIngress:Yv(()=>{},"onIngress"),onEgress:Yv(()=>{},"onEgress")},_t=ke("trace_parent",l.shape({traceId:l.traceId,traceName:l.str,traceSampled:l.bool,spanId:l.spanId}).optional);var Xv=Object.defineProperty,Qv=o(t=>{throw TypeError(t)},"J$a"),BS=o((t,e,r)=>e in t?Xv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"$$c"),ea=o((t,e)=>Xv(t,"name",{value:e,configurable:!0}),"V$7"),Zv=o((t,e,r)=>BS(t,typeof e!="symbol"?e+"":e,r),"z$c"),op=o((t,e,r)=>e.has(t)||Qv("Cannot "+r),"D$g"),xt=o((t,e,r)=>(op(t,e,"read from private field"),r?r.call(t):e.get(t)),"o$m"),mr=o((t,e,r)=>e.has(t)?Qv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"d$o"),Ur=o((t,e,r,s)=>(op(t,e,"write to private field"),e.set(t,r),r),"u$s"),IS=o((t,e,r)=>(op(t,e,"access private method"),r),"K$9"),Hh,Kh,ta,Dc,Gh,Vh,Yh,Jh,Xh,Qh,Zh,cp,e_;function lp(t,e,r){if((t&8)===0)return;const s=_t.decodeUntrusted(e,r.offset,512);return r.offset=vt(),s}o(lp,"Q$8"),ea(lp,"decodeTraceParent");const t_=(go=class{constructor(e,r){mr(this,cp),Zv(this,"version"),Zv(this,"id"),mr(this,Hh,""),mr(this,Kh,""),mr(this,ta,""),mr(this,Dc,""),mr(this,Gh,0),mr(this,Vh,""),mr(this,Yh,""),mr(this,Jh,""),mr(this,Xh,""),mr(this,Qh,""),mr(this,Zh,""),this.version=e,this.id=r,IS(this,cp,e_).call(this)}encodeUnidirectionalRequest(e){const r=e.trace.exportTraceParent();return r?xt(this,Hh)+_t.encode(r):xt(this,Kh)}encodeBidirectionalRequest(e,r){const s=e.trace.exportTraceParent();return s?xt(this,ta)+Oc(r)+_t.encode(s):xt(this,Dc)+Oc(r)}retagBidirectionalRequest(e,r,s){const n=(s.charCodeAt(0)&8)!==0;let i=xt(this,Gh)+2;n&&(_t.decodeUntrusted(s,i,512),i=vt());const a=e.trace.exportTraceParent();return(a?xt(this,ta):xt(this,Dc))+Oc(r)+(a?_t.encode(a):"")+s.slice(i)}encodeSuccessResponse(e){return xt(this,Vh)+e}encodeErrorResponse(e,r){return xt(this,Yh)+e+pr(r)}encodeStreamSegment(e){return xt(this,Jh)+e}encodeStreamClose(e){return xt(this,Xh)+e}encodeStreamError(e,r){return xt(this,Qh)+e+pr(r)}encodeUnsupportedVersion(){return xt(this,Zh)}},o(go,"k"),go);Hh=new WeakMap,Kh=new WeakMap,ta=new WeakMap,Dc=new WeakMap,Gh=new WeakMap,Vh=new WeakMap,Yh=new WeakMap,Jh=new WeakMap,Xh=new WeakMap,Qh=new WeakMap,Zh=new WeakMap,cp=new WeakSet,e_=ea(function(){const t=pr(this.id),[e,r,s]=this.version<4?[4,this.version,""]:[0,this.version&3,pr(this.version>>2)],n=64|e|r;Ur(this,Hh,String.fromCharCode(n|8)+s+t),Ur(this,Kh,String.fromCharCode(n)+s+t);const i=96|e|r;Ur(this,ta,String.fromCharCode(i|8)+s+t),Ur(this,Dc,String.fromCharCode(i)+s+t),Ur(this,Gh,xt(this,ta).length);const[a,c,h]=this.version<8?[8,this.version,""]:[0,this.version&7,pr(this.version>>3)];Ur(this,Vh,String.fromCharCode(32|a|c)+h+t),Ur(this,Yh,String.fromCharCode(48|a|c)+h+t);const[u,d,p]=this.version<4?[4,this.version,""]:[0,this.version&3,pr(this.version>>2)];Ur(this,Jh,String.fromCharCode(0|u|d)+p+t),Ur(this,Xh,String.fromCharCode(16|u|d)+p+t),Ur(this,Qh,String.fromCharCode(24|u|d)+p+t);const[f,g,m]=this.version<64?[64,this.version,""]:[0,this.version&63,pr(this.version>>6)];Ur(this,Zh,String.fromCharCode(128|f|g)+m+t)},"#initPrecomputedHeaders"),ea(t_,"WireSignalEnvelope");let qS=t_;function eu(t,e=0){if(t.length<=e)throw new Error("[direct.dev/wire/signal] truncated envelope received");const r=t.charCodeAt(e);if((r&128)!==0){Yn.offset=e+1;const c=r&64,h=r&63;if(c!==0)Yn.desiredSignalVersion=h;else{const u=at(t,Yn);Yn.desiredSignalVersion=u<<6|h}return Yn.signalId=at(t,Yn),Yn}if((r&64)!==0&&(r&16)!==0){Is.offset=e+1,Is.signalId=at(t,Is),Is.traceParent=lp(r,t,Is);const c=t.charCodeAt(Is.offset++)&127,h=t.charCodeAt(Is.offset++)&127;return Is.messageId=c|h<<7,Is}if((r&64)!==0){Qt.offset=e+1;const c=r&4,h=r&3;if(c!==0)Qt.signalVersion=h;else{const u=at(t,Qt);Qt.signalVersion=u<<2|h}return Qt.signalId=at(t,Qt),(r&32)!==0?Qt.messageId=t.slice(Qt.offset,Qt.offset+=2):Qt.messageId=void 0,Qt.traceParent=lp(r,t,Qt),Qt}if((r&32)!==0){Zt.offset=e+1;const c=r&8,h=r&7;if(c!==0)Zt.signalVersion=h;else{const p=at(t,Zt);Zt.signalVersion=p<<3|h}Zt.signalId=at(t,Zt);const u=t.charCodeAt(Zt.offset++)&127,d=t.charCodeAt(Zt.offset++)&127;return Zt.messageId=u|d<<7,(r&16)===0?Zt.errorCode=void 0:Zt.errorCode=at(t,Zt),Zt}tt.offset=e+1;const s=r&4,n=r&3;if(s!==0)tt.signalVersion=n;else{const c=at(t,tt);tt.signalVersion=c<<2|n}tt.signalId=at(t,tt);const i=t.charCodeAt(tt.offset++)&127,a=t.charCodeAt(tt.offset++)&127;switch(tt.messageId=i|a<<7,r&24){case 0:return tt.messageType="value",tt.errorCode=void 0,tt;case 16:return tt.messageType="close",tt.errorCode=void 0,tt;case 24:return tt.messageType="error",tt.errorCode=at(t,tt),tt}throw new Error("[direct.dev/wire/signal] malformed envelope header received, stream value type unrecognized: "+r)}o(eu,"W$a"),ea(eu,"decodeEnvelope");const Yn={offset:0,type:"unsupported_version",signalId:0,desiredSignalVersion:0},Qt={offset:0,type:"request",signalId:0,signalVersion:0,messageId:void 0,traceParent:void 0},Zt={offset:0,type:"response",signalId:0,signalVersion:0,messageId:0,errorCode:void 0},tt={offset:0,type:"stream",signalId:0,signalVersion:0,messageType:"value",messageId:0,errorCode:void 0},Is={offset:0,type:"abort",signalId:0,messageId:0,traceParent:void 0};function r_(t,e,r){const s=t.trace.exportTraceParent();return String.fromCharCode(80|(s?8:0))+pr(e)+(s?_t.encode(s):"")+Oc(r)}o(r_,"y$i"),ea(r_,"encodeAbort");function Oc(t){const e=t&127,r=t>>7;return String.fromCharCode(e,r)}o(Oc,"b$l"),ea(Oc,"encodeMessageId");var PS=Object.defineProperty,tu=o((t,e)=>PS(t,"name",{value:e,configurable:!0}),"o$l");const ot=Symbol("unsupported version"),s_=(wo=class{tAttrs;version;id;name;req;_envelopes;_latestEnvelope;_migrations;constructor(e,r){this.tAttrs={"wire_signal.name":e.name},this.id=e.id,this.name=e.name,this.req=e.req,this.version=r.length;const s=new Array(this.version+1);for(let n=0;n<this.version+1;n++)s[n]=new qS(n,this.id);this._envelopes=s,this._latestEnvelope=s[this.version],this._migrations=r}decodeTrustedRequest(e,r,s,n){if(s===this.version)return this.req.decodeTrusted(e,r,n);const i=this._migrations[s];return i?i.upgradeReq(i.req.decodeTrusted(e,r,n)):ot}decodeUntrustedRequest(e,r,s,n){if(s===this.version)return this.req.decodeUntrusted(e,r,n);const i=this._migrations[s];return i?i.upgradeReq(i.req.decodeUntrusted(e,r,n)):ot}encodeUnsupportedVersion(e){return this._latestEnvelope.encodeUnsupportedVersion()+e}},o(wo,"a"),wo);tu(s_,"WireSignalBase");let hp=s_;const n_=(vo=class extends hp{type="event";static migration(e,r){return Object.freeze({req:e.from,upgradeReq:r.upgradeReq,downgradeReq:r.downgradeReq})}encodeRequest(e,r,s){if(s!=null&&s!==this.version){const n=this._migrations[s],i=this._envelopes[s];return n?i.encodeUnidirectionalRequest(e)+n.req.encode(n.downgradeReq(r)):ot}return this._latestEnvelope.encodeUnidirectionalRequest(e)+this.req.encode(r)}},o(vo,"R"),vo);tu(n_,"WireEventSignal");let jc=n_;const i_=(_o=class extends hp{type="request";static migration(e,r,s){return Object.freeze({req:e.from,res:r.from,upgradeReq:s.upgradeReq,downgradeReq:s.downgradeReq,upgradeRes:s.upgradeRes,downgradeRes:s.downgradeRes})}res;timeoutMs;constructor(e,r){super(e,r),this.res=e.res,this.timeoutMs=e.timeoutMs}encodeRequest(e,r,s,n){if(n!=null&&n!==this.version){const i=this._migrations[n],a=this._envelopes[n];return i?a.encodeBidirectionalRequest(e,r)+i.req.encode(i.downgradeReq(s)):ot}return this._latestEnvelope.encodeBidirectionalRequest(e,r)+this.req.encode(s)}retagRequest(e,r,s,n){if(n!=null&&n!==this.version){const i=this._envelopes[n];return i?i.retagBidirectionalRequest(e,r,s):ot}return this._latestEnvelope.retagBidirectionalRequest(e,r,s)}encodeResponse(e,r,s){if(e!==this.version){const n=this._migrations[e],i=this._envelopes[e];return n?i.encodeSuccessResponse(r)+n.res.encode(n.downgradeRes(s)):ot}return this._latestEnvelope.encodeSuccessResponse(r)+this.res.encode(s)}encodeError(e,r,s){return e!==this.version?this._envelopes[e].encodeErrorResponse(r,s):this._latestEnvelope.encodeErrorResponse(r,s)}decodeTrustedResponse(e,r,s,n){if(s===this.version)return this.res.decodeTrusted(e,r,n);const i=this._migrations[s];return i?i.upgradeRes(i.res.decodeTrusted(e,r,n)):ot}decodeUntrustedResponse(e,r,s,n){if(s===this.version)return this.res.decodeUntrusted(e,r,n);const i=this._migrations[s];return i?i.upgradeRes(i.res.decodeUntrusted(e,r,n)):ot}},o(_o,"p"),_o);tu(i_,"WireRequestSignal");let a_=i_;const o_=(yo=class extends hp{type="stream";static migration(e,r,s){return Object.freeze({req:e.from,res:r.from,upgradeReq:s.upgradeReq,downgradeReq:s.downgradeReq,upgradeRes:s.upgradeRes,downgradeRes:s.downgradeRes})}res;timeoutMs;initialTimeoutMs;itemTimeoutMs;constructor(e,r){super(e,r),this.res=e.res,this.timeoutMs=e.timeoutMs,this.initialTimeoutMs=e.initialTimeoutMs,this.itemTimeoutMs=e.itemTimeoutMs}encodeRequest(e,r,s,n){if(n!=null&&n!==this.version){const i=this._migrations[n],a=this._envelopes[n];return i?a.encodeBidirectionalRequest(e,r)+i.req.encode(i.downgradeReq(s)):ot}return this._latestEnvelope.encodeBidirectionalRequest(e,r)+this.req.encode(s)}retagRequest(e,r,s,n){if(n!=null&&n!==this.version){const i=this._envelopes[n];return i?i.retagBidirectionalRequest(e,r,s):ot}return this._latestEnvelope.retagBidirectionalRequest(e,r,s)}encodeResponse(e,r,s){if(e!==this.version){const n=this._migrations[e],i=this._envelopes[e];return n?i.encodeStreamSegment(r)+n.res.encode(n.downgradeRes(s)):ot}return this._latestEnvelope.encodeStreamSegment(r)+this.res.encode(s)}encodeError(e,r,s){return e!==this.version?this._envelopes[e].encodeStreamError(r,s):this._latestEnvelope.encodeStreamError(r,s)}encodeClose(e,r){return e!==this.version?this._envelopes[e].encodeStreamClose(r):this._latestEnvelope.encodeStreamClose(r)}decodeTrustedResponse(e,r,s,n){if(s===this.version)return this.res.decodeTrusted(e,r,n);const i=this._migrations[s];return i?i.upgradeRes(i.res.decodeTrusted(e,r,n)):ot}decodeUntrustedResponse(e,r,s,n){if(s===this.version)return this.res.decodeUntrusted(e,r,n);const i=this._migrations[s];return i?i.upgradeRes(i.res.decodeUntrusted(e,r,n)):ot}},o(yo,"m"),yo);tu(o_,"WireStreamSignal");let ru=o_;var xS=Object.defineProperty,WS=o((t,e)=>xS(t,"name",{value:e,configurable:!0}),"i$j");const US=bs("");function c_(t,e,r){if(!(t==="client_continuum"&&typeof r=="object"&&r!=null&&"fromChecksum"in r&&r.fromChecksum!==US))return e}o(c_,"u$r"),WS(c_,"getEffectiveInitialTimeoutMs");var DS=Object.defineProperty,OS=o((t,e)=>DS(t,"name",{value:e,configurable:!0}),"i$i");function up(t,e){if(!t.endsWith("continuum"))return e}o(up,"r$l"),OS(up,"getEffectiveStreamTimeoutMs");var l_=Object.defineProperty,h_=o(t=>{throw TypeError(t)},"ce$2"),jS=o((t,e,r)=>e in t?l_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"Ae$1"),ae=o((t,e)=>l_(t,"name",{value:e,configurable:!0}),"h$n"),ra=o((t,e,r)=>jS(t,typeof e!="symbol"?e+"":e,r),"k$e"),dp=o((t,e,r)=>e.has(t)||h_("Cannot "+r),"W$9"),L=o((t,e,r)=>(dp(t,e,"read from private field"),r?r.call(t):e.get(t)),"u$q"),ns=o((t,e,r)=>e.has(t)?h_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"q$g"),u_=o((t,e,r,s)=>(dp(t,e,"write to private field"),e.set(t,r),r),"Q$7"),F=o((t,e,r)=>(dp(t,e,"access private method"),r),"c$u"),Nc,is,Lc,gr,Dr,su,cn,sa,U,nu,fp,yt,pp,mp,gp,iu,d_,f_,p_,m_,g_,w_,wp,vp,v_,__,_p,yp,bp,y_;const Jn=new Error("[direct.dev/wire/signal] request timed out"),Fc=new Error("[direct.dev/wire/signal] channel closed"),b_=1,$p=2,$_=(bo=class{constructor(e,r,s,n,i,a){ns(this,U),ra(this,"t"),ra(this,"bandwidthHooks"),ra(this,"abortSignal"),ra(this,"downstreamRelationship"),ns(this,Nc,Of()),ns(this,is),ns(this,Lc),ns(this,gr,new Map),ns(this,Dr,new Map),ns(this,su,new Map),ns(this,cn,new Map),ns(this,sa,new Set),ns(this,iu,ae(c=>{const h=c==="trusted"?"decodeTrustedRequest":"decodeUntrustedRequest",u=c==="trusted"?"decodeTrustedResponse":"decodeUntrustedResponse";return(d,p,f)=>{let g;try{g=eu(d)}catch(w){throw this.t.log.info("wire_signal_relay.decode_envelope_failed",{err:w,payload_size:d.length,direction:"ingress",mode:c,header_char_code:d.length>0?d.charCodeAt(0):void 0}),w}const m=L(this,is).get(g.signalId);if(this.bandwidthHooks.onIngress(p,m),!m){let w;for(const _ of L(this,is).keys())w=w==null?_:Math.max(w,_);return this.t.record.wireSignalRequestHandleCount(1,"result:unrecognized_signal",{"wire_signal.name":void 0}),this.t.log.info("wire_signal_relay.unrecognized_signal_id",{signal_id:g.signalId,envelope_type:g.type,signal_version:"signalVersion"in g?g.signalVersion:void 0,envelope_offset:g.offset,message_id:"messageId"in g?g.messageId:void 0,payload_size:d.length,direction:"ingress",mode:c,header_char_code:d.length>0?d.charCodeAt(0):void 0,known_signal_count:L(this,is).size,max_known_signal_id:w}),!1}switch(g.type){case"request":return zi(()=>F(this,U,f_).call(this,g,m,d,h,f),()=>!0);case"response":return F(this,U,v_).call(this,m,g,d,u,f),!0;case"stream":return F(this,U,__).call(this,m,g,d,u,f),!0;case"unsupported_version":return F(this,U,d_).call(this,m,g,d),!0;case"abort":return F(this,U,w_).call(this,m,g),!0}}},"#makeHandleMessage")),ra(this,"handleTrustedMessage",L(this,iu).call(this,"trusted")),ra(this,"handleUntrustedMessage",L(this,iu).call(this,"untrusted")),this.t=e.with({"component.id":"WireSignalRelay"}),u_(this,is,r??new Map),u_(this,Lc,s??new Map),this.bandwidthHooks=n??Jv,this.abortSignal=i??NS,this.downstreamRelationship=a??"parent",this.abortSignal.addEventListener("abort",()=>F(this,U,fp).call(this),{once:!0})}waitForSendQueue(){return L(this,Nc)}dispatch(e,r,s,n,i){switch(L(this,is).set(r.id,r),r.type){case"event":return F(this,U,pp).call(this,e,r,r.encodeRequest(e,s),n,i);case"request":{const a=F(this,U,_p).call(this,e,r);return F(this,U,mp).call(this,e,r,a,r.encodeRequest(e,a,s),n,i)}case"stream":{const a=F(this,U,yp).call(this,e,r),c=c_(r.name,r.initialTimeoutMs,s);return F(this,U,gp).call(this,e,r,a,r.encodeRequest(e,a,s),c,n,i)}}}dispatchRaw(e,r,s,n,i){switch(L(this,is).set(r.id,r),r.type){case"event":return F(this,U,pp).call(this,e,r,s,n,i);case"request":{const a=F(this,U,_p).call(this,e,r);return F(this,U,mp).call(this,e,r,a,r.retagRequest(e,a,s),n,i)}case"stream":{const a=F(this,U,yp).call(this,e,r);return F(this,U,gp).call(this,e,r,a,r.retagRequest(e,a,s),r.initialTimeoutMs,n,i)}}}dispatchAbort(e,r,s,n){const i=r_(e,r.id,s);F(this,U,yt).call(this,r,s,i,void 0,n).catch(()=>{})}bind(e,r){L(this,is).set(e.id,e),L(this,Lc).set(e.id,r)}getSignalById(e){return L(this,is).get(e)}async handleClose(e){e&&(await L(this,Nc).call(this,()=>{}),await Promise.allSettled([F(this,U,y_).call(this),...L(this,sa)])),F(this,U,fp).call(this);for(const r of L(this,gr).values()){for(const{promise:s,timeout:n}of r.values())s.__state()==="pending"&&s.__reject(Fc),clearTimeout(n);r.clear()}for(const r of L(this,Dr).values()){for(const{stream:s,timeout:n,itemTimeout:i}of r.values())s.throw(Fc),clearTimeout(n),clearTimeout(i);r.clear()}}terminateBatch(e,r,s=Fc){var n,i;for(const{signalId:a,messageId:c}of e){const h=(n=L(this,gr).get(a))==null?void 0:n.get(c);h&&(h.promise.__state()==="pending"&&h.promise.__reject(s),clearTimeout(h.timeout))}for(const{signalId:a,messageId:c}of r){const h=(i=L(this,Dr).get(a))==null?void 0:i.get(c);h&&(Ir(s)?h.stream.close(void 0):h.stream.throw(s),clearTimeout(h.itemTimeout),clearTimeout(h.timeout))}}get pendingCount(){let e=0;for(const r of L(this,gr).values())e+=r.size;return e}get streamCount(){let e=0;for(const r of L(this,Dr).values())e+=r.size;return e}},o(bo,"oe"),bo);Nc=new WeakMap,is=new WeakMap,Lc=new WeakMap,gr=new WeakMap,Dr=new WeakMap,su=new WeakMap,cn=new WeakMap,sa=new WeakMap,U=new WeakSet,nu=ae(function(t){return L(this,sa).add(t),t.then(()=>L(this,sa).delete(t),()=>L(this,sa).delete(t)),t},"#trackHandler"),fp=ae(function(){for(const t of L(this,cn).values())for(const e of t.values())e.abort()},"#abortAllHandlers"),yt=ae(async function(t,e,r,s,n){const i=s??this.abortSignal;t.name;try{const a=this.prepareFrame(r),c=await L(this,Nc).call(this,()=>a);this.bandwidthHooks.onEgress(c.length,t),i.aborted||await this.writeFrame(t,e,c,i,n)}catch(a){throw Ir(a)||(this.t.log.warn("wire_signal_relay.send_failed",{err:a}),this.t.record.wireSignalSendErrorCount(1,t.tAttrs)),a}},"#sendInOrder"),pp=ae(function(t,e,r,s,n){return t.record.wireSignalDispatchCount(1,"type:event",e.tAttrs),t.record.wireSignalResultCount(1,"type:event result:ok",e.tAttrs),F(this,U,yt).call(this,e,void 0,r,s,n).catch(()=>{})},"#dispatchEvent"),mp=ae(function(t,e,r,s,n,i){const a=y(),c=Ye(),h=setTimeout(()=>{c.__state()==="pending"&&(c.__reject(Jn),t.record.wireSignalResultCount(1,"type:request result:timeout",e.tAttrs),t.record.wireSignalLatencyMs(y()-a,"result:timeout",e.tAttrs))},e.timeoutMs);return L(this,gr).get(e.id).set(r,{promise:c,startedAt:a,timeout:h}),c.then(()=>{var u;(u=L(this,gr).get(e.id))==null||u.delete(r),clearTimeout(h)},()=>{var u;(u=L(this,gr).get(e.id))==null||u.delete(r),clearTimeout(h)}),n!=null&&n.addEventListener("abort",()=>{this.dispatchAbort(t,e,r,i)},{once:!0}),F(this,U,yt).call(this,e,r,s,n,i).catch(u=>{c.__state()==="pending"&&(c.__reject(u),t.record.wireSignalResultCount(1,"type:request result:send_error",e.tAttrs),t.record.wireSignalLatencyMs(y()-a,"result:send_error",e.tAttrs))}),t.record.wireSignalDispatchCount(1,"type:request",e.tAttrs),c},"#dispatchRequest"),gp=ae(function(t,e,r,s,n,i,a){const c=y(),h=new AbortController;let u=!1;const d=ae(()=>{u||(u=!0,h.signal.aborted||h.abort(),this.dispatchAbort(t,e,r,a))},"onAbort"),p=ae(()=>{h.signal.aborted||h.abort(i==null?void 0:i.reason),d()},"onExternalAbort"),f=new Ss({onClose:ae(()=>{var _;(_=L(this,Dr).get(e.id))==null||_.delete(r),clearTimeout(w.timeout),clearTimeout(w.itemTimeout),i==null||i.removeEventListener("abort",p)},"onClose"),onEarlyDisposal:d,onBackpressure:d}),g=up(e.name,e.timeoutMs),m=g==null?void 0:setTimeout(()=>{f.throw(Jn),t.record.wireSignalResultCount(1,"type:stream result:timeout",e.tAttrs),t.record.wireSignalLatencyMs(y()-c,"result:timeout",e.tAttrs)},g),w={stream:f,startedAt:c,timeout:m,itemTimeout:void 0,lastItemAt:void 0};return L(this,Dr).get(e.id).set(r,w),n!=null&&(w.itemTimeout=setTimeout(()=>{f.throw(Jn),t.record.wireSignalResultCount(1,"type:stream result:initial_timeout",e.tAttrs),t.record.wireSignalStreamLifetimeMs(y()-c,"result:initial_timeout",e.tAttrs)},n)),e.itemTimeoutMs!=null?f.tap(()=>{w.lastItemAt=y(),clearTimeout(w.itemTimeout),w.itemTimeout=setTimeout(()=>{f.throw(Jn),t.record.wireSignalResultCount(1,"type:stream result:item_timeout",e.tAttrs),t.record.wireSignalStreamLifetimeMs(y()-c,"result:item_timeout",e.tAttrs)},e.itemTimeoutMs)}):n!=null&&f.tap(()=>{clearTimeout(w.itemTimeout)}),i!=null&&(i.aborted?p():i.addEventListener("abort",p,{once:!0})),F(this,U,yt).call(this,e,r,s,h.signal,a).catch(_=>{Ir(_)?f.close(void 0):f.throw(_),t.record.wireSignalResultCount(1,"type:stream result:send_error",e.tAttrs)}),t.record.wireSignalDispatchCount(1,"type:stream",e.tAttrs),f},"#dispatchStream"),iu=new WeakMap,d_=ae(function(t,e,r){const s=eu(r,e.offset);if(s.type!=="request"){this.t.log.info("wire_signal_relay.unsupported_version.envelope_type_mismatch",{envelope_type:s.type,signal_id:t.id,signal_name:t.name,payload_size:r.length});return}const n=t.decodeUntrustedRequest(r,s.offset,s.signalVersion);if(n===ot){this.t.record.wireSignalUnsupportedVersionCount(1,t.tAttrs),this.t.log.info("wire_signal_relay.unsupported_version.original_request_unsupported",{signal_id:t.id,signal_name:t.name,signal_version:s.signalVersion,desired_version:e.desiredSignalVersion,payload_size:r.length});return}const i=this.t.with({event:"wire_signal_relay.handle_unsupported_version"},s.traceParent?{traceId:s.traceParent.traceId,traceName:s.traceParent.traceName,traceSampled:s.traceParent.traceSampled,parentLink:void 0,parentSpanId:void 0,spanId:s.traceParent.spanId,spanKind:"INTERNAL"}:void 0);let a;switch(t.type){case"event":a=t.encodeRequest(i,n,e.desiredSignalVersion);break;case"request":case"stream":{if(s.messageId==null){this.t.log.info("wire_signal_relay.unsupported_version.missing_message_id",{signal_id:t.id,signal_name:t.name,signal_type:t.type,payload_size:r.length});return}const c=s.messageId.charCodeAt(0)&127,h=s.messageId.charCodeAt(1)&127,u=c|h<<7;a=t.encodeRequest(i,u,n,e.desiredSignalVersion);break}}a!==ot?F(this,U,yt).call(this,t,void 0,a).catch(()=>{}):(this.t.record.wireSignalUnsupportedVersionCount(1,t.tAttrs),this.t.log.info("wire_signal_relay.unsupported_version.impossible",{signal_id:t.id,signal_name:t.name,signal_type:t.type,signal_version:t.version,desired_version:e.desiredSignalVersion,payload_size:r.length}))},"#handleUnsupportedVersionMessage"),f_=ae(function(t,e,r,s,n){const i=L(this,Lc).get(e.id);if(!i){this.t.record.wireSignalRequestHandleCount(1,`type:${e.type} result:handler_not_bound`,e.tAttrs),this.t.log.warn("wire_signal_relay.unbound_handler",{signal_id:e.id,signal_name:e.name});return}switch(t.signalVersion!==e.version&&this.t.record.wireSignalMigrationCount(1,{"wire_signal.name":e.name,"wire_signal.from_version":t.signalVersion,"wire_signal.to_version":e.version}),e.type){case"event":return F(this,U,nu).call(this,F(this,U,p_).call(this,e,i,t,r,s,n));case"request":return F(this,U,nu).call(this,F(this,U,m_).call(this,e,i,t,r,s,n));case"stream":return F(this,U,nu).call(this,F(this,U,g_).call(this,e,i,t,r,s,n))}},"#handleRequestMessage"),p_=ae(async function(t,e,r,s,n,i){const a=r.signalVersion,c=t[n](s,r.offset,r.signalVersion,i);if(c===ot){F(this,U,yt).call(this,t,void 0,t.encodeUnsupportedVersion(s)).catch(()=>{});return}await this.t.runSpan({parent:r.traceParent,parentRelationship:this.downstreamRelationship,kind:"CONSUMER"},{event:"wire_signal.handle","wire_signal.name":t.name,"wire_signal.id":t.id,"wire_signal.type":t.type},async h=>{try{await e(h,s,c,this.abortSignal),h.record.wireSignalRequestHandleCount(1,"type:event result:ok",t.tAttrs)}catch(u){h.record.wireSignalRequestHandleCount(1,"type:event result:error",t.tAttrs),h.log.info("wire_signal.handler_failed",{err:u,version:a,payload_size:s.length})}})},"#handleRequestMessageForEvent"),m_=ae(async function(t,e,r,s,n,i){const a=r.offset,c=r.signalVersion,h=r.messageId;if(h==null){this.t.log.info("wire_signal_relay.missing_message_id",{signal_id:t.id,signal_name:t.name});return}const u=h.charCodeAt(0)&127,d=h.charCodeAt(1)&127,p=u|d<<7,f=t[n](s,a,c,i);if(f===ot){F(this,U,yt).call(this,t,void 0,t.encodeUnsupportedVersion(s)).catch(()=>{});return}const g=F(this,U,wp).call(this,t.id,p);await this.t.runSpan({parent:r.traceParent,parentRelationship:"parent",kind:"SERVER"},{event:"wire_signal.handle","wire_signal.name":t.name,"wire_signal.id":t.id,"wire_signal.type":t.type},async m=>{try{const w=await gc(t.timeoutMs,Promise.resolve(e(m,s,f,g.signal)));if(w===mc){g.signal.aborted||g.abort(Jn),m.record.wireSignalRequestHandleCount(1,"type:request result:timeout",t.tAttrs),F(this,U,yt).call(this,t,p,t.encodeError(c,h,$p)).catch(()=>{});return}m.record.wireSignalRequestHandleCount(1,"type:request result:ok",t.tAttrs),F(this,U,yt).call(this,t,p,t.encodeResponse(c,h,w)).catch(()=>{})}catch(w){m.record.wireSignalRequestHandleCount(1,"type:request result:error",t.tAttrs),m.log.info("wire_signal.handler_failed",{err:w,version:c,payload_size:s.length});const _=t.encodeError(c,h,b_);F(this,U,yt).call(this,t,p,_).catch(()=>{})}finally{F(this,U,vp).call(this,t.id,p)}})},"#handleRequestMessageForRequest"),g_=ae(async function(t,e,r,s,n,i){const a=r.offset,c=r.signalVersion,h=r.messageId;if(h==null){this.t.log.info("wire_signal_relay.missing_message_id",{signal_id:t.id,signal_name:t.name});return}const u=h.charCodeAt(0)&127,d=h.charCodeAt(1)&127,p=u|d<<7,f=t[n](s,a,c,i);if(f===ot){F(this,U,yt).call(this,t,p,t.encodeUnsupportedVersion(s)).catch(()=>{});return}const g=F(this,U,wp).call(this,t.id,p);await this.t.runSpan({parent:r.traceParent,parentRelationship:"parent",kind:"SERVER"},{event:"wire_signal.handle","wire_signal.name":t.name,"wire_signal.id":t.id,"wire_signal.type":t.type},async m=>{var w;let _=ae(S=>{if(_=ae(async()=>{},"closeStream"),!g.signal.aborted)return S!=null?F(this,U,yt).call(this,t,p,t.encodeError(c,h,S)).catch(()=>{}):F(this,U,yt).call(this,t,p,t.encodeClose(c,h)).catch(()=>{})},"closeStream");try{const S=y(),b=await gc(t.initialTimeoutMs??t.timeoutMs,Promise.resolve(e(m,s,f,g.signal)));if(b===mc){g.signal.aborted||g.abort(Jn),m.record.wireSignalRequestHandleCount(1,"type:stream result:timeout",t.tAttrs),F(this,U,yt).call(this,t,p,t.encodeError(c,h,$p)).catch(()=>{});return}m.record.wireSignalRequestHandleCount(1,"type:stream result:started",t.tAttrs);const O=b[Symbol.asyncIterator]();for(;;){const j=up(t.name,t.timeoutMs),W=t.name==="client_continuum"?void 0:t.itemTimeoutMs,K=j==null?W:W!==void 0?Math.min(W,j-(y()-S)):j-(y()-S),q=K==null?await O.next():await gc(K,O.next());if(q===mc){g.signal.aborted||g.abort(Jn),m.record.wireSignalRequestHandleCount(1,"type:stream result:timeout",t.tAttrs),await _($p),(w=O.return)==null||w.call(O,void 0).catch(()=>{});return}if(q.done)break;await F(this,U,yt).call(this,t,p,t.encodeResponse(c,h,q.value)),m.record.wireSignalStreamSegmentCount(1,t.tAttrs)}m.record.wireSignalRequestHandleCount(1,"type:stream result:ok",t.tAttrs),await _()}catch(S){await _(b_),m.record.wireSignalRequestHandleCount(1,"type:stream result:error",t.tAttrs),m.log.warn("wire_signal.stream_failed",{err:S,signal_name:t.name,signal_id:t.id,version:c,payload_size:s.length})}finally{F(this,U,vp).call(this,t.id,p)}})},"#handleRequestMessageForStream"),w_=ae(function(t,e){var r,s;const n=(r=L(this,cn).get(t.id))==null?void 0:r.get(e.messageId);if(!n){this.t.log.info("wire_signal_relay.abort_not_found",{signal_id:t.id,signal_name:t.name,message_id:e.messageId});return}n.abort(),(s=L(this,cn).get(t.id))==null||s.delete(e.messageId),this.t.record.wireSignalRequestHandleCount(1,`type:${t.type} result:aborted`,t.tAttrs)},"#handleAbortMessage"),wp=ae(function(t,e){const r=new AbortController;this.abortSignal.aborted&&r.abort();let s=L(this,cn).get(t);return s||(s=new Map,L(this,cn).set(t,s)),s.set(e,r),r},"#createRequestAbortController"),vp=ae(function(t,e){var r;(r=L(this,cn).get(t))==null||r.delete(e)},"#cleanupRequestAbortController"),v_=ae(function(t,e,r,s,n){var i;if(t.type!=="request"){this.t.record.wireSignalRequestHandleCount(1,"type:request result:mismatched_type",t.tAttrs),this.t.log.info("wire_request_signal.mismatched_signal",{signal_name:t.name,signal_type:t.type,payload_size:r.length});return}const a=(i=L(this,gr).get(t.id))==null?void 0:i.get(e.messageId);if(!a){this.t.record.wireSignalRequestHandleCount(1,"type:request result:unrecognized",t.tAttrs),this.t.log.info("wire_request_signal.non_recognized_response",{signal_name:t.name,payload_size:r.length,message_id:e.messageId});return}e.errorCode==null?(a.promise.__resolve(t[s](r,e.offset,e.signalVersion,n)),this.t.record.wireSignalResultCount(1,"type:request result:ok",t.tAttrs),this.t.record.wireSignalLatencyMs(y()-a.startedAt,"result:ok",t.tAttrs)):(a.promise.__reject(new Error("[direct.dev/wire/signal] remote error")),this.t.record.wireSignalResultCount(1,"type:request result:error",t.tAttrs),this.t.record.wireSignalLatencyMs(y()-a.startedAt,"result:error",t.tAttrs))},"#handleResponseMessage"),__=ae(function(t,e,r,s,n){var i;if(t.type!=="stream"){this.t.record.wireSignalRequestHandleCount(1,"type:stream result:mismatched_type",t.tAttrs),this.t.log.info("wire_stream_signal.mismatched_signal",{signal_name:t.name,signal_type:t.type,payload_size:r.length});return}const a=(i=L(this,Dr).get(t.id))==null?void 0:i.get(e.messageId);if(!a){this.t.record.wireSignalRequestHandleCount(1,"type:stream result:unrecognized",t.tAttrs),this.t.log.info("wire_request_signal.non_recognized_stream",{signal_name:t.name,payload_size:r.length,message_id:e.messageId,message_type:e.messageType});return}switch(e.messageType){case"value":a.stream.push(t[s](r,e.offset,e.signalVersion,n));break;case"close":a.stream.close(void 0),this.t.record.wireSignalResultCount(1,"type:stream result:ok",t.tAttrs),this.t.record.wireSignalStreamLifetimeMs(y()-a.startedAt,"result:ok",t.tAttrs);break;case"error":a.stream.throw(new Error("[direct.dev/wire/signal] remote stream error")),this.t.record.wireSignalResultCount(1,"type:stream result:error",t.tAttrs),this.t.record.wireSignalStreamLifetimeMs(y()-a.startedAt,"result:error",t.tAttrs);break}},"#handleStream"),_p=ae(function(t,e){let r=L(this,gr).get(e.id);return r||(r=new Map,L(this,gr).set(e.id,r)),F(this,U,bp).call(this,t,e,r)},"#getReqId"),yp=ae(function(t,e){let r=L(this,Dr).get(e.id);return r||(r=new Map,L(this,Dr).set(e.id,r)),F(this,U,bp).call(this,t,e,r)},"#getStreamId"),bp=ae(function(t,e,r){let s=L(this,su).get(e.id)??-1;if(r.size>=4096)throw t.record.wireSignalBackpressureCount(1,e.tAttrs),new Error("[direct.dev/wire/signal] backpressure - cannot have more than 4_096 concurrent requests");for(let n=0;n<4096;n++)if(s=s+1&4095,!r.has(s))return L(this,su).set(e.id,s),s;throw t.record.wireSignalBackpressureCount(1,e.tAttrs),new Error("[direct.dev/wire/signal] backpressure - cannot have more than 4_096 concurrent requests")},"#getNextMsgId"),y_=ae(function(){const t=[];for(const e of L(this,gr).values())for(const{promise:r}of e.values())t.push(r);for(const e of L(this,Dr).values())for(const{stream:r}of e.values())t.push(r.wait());return Promise.allSettled(t)},"#drainPending"),ae($_,"WireSignalRelay");let k_=$_;const NS={aborted:!1,reason:null,onabort:null,addEventListener:ae(()=>{},"addEventListener"),dispatchEvent:ae(()=>!1,"dispatchEvent"),removeEventListener:ae(()=>{},"removeEventListener"),throwIfAborted:ae(()=>{},"throwIfAborted")};var C_=Object.defineProperty,S_=o(t=>{throw TypeError(t)},"j$c"),LS=o((t,e,r)=>e in t?C_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"F$e"),au=o((t,e)=>C_(t,"name",{value:e,configurable:!0}),"c$t"),A_=o((t,e,r)=>LS(t,typeof e!="symbol"?e+"":e,r),"u$p"),kp=o((t,e,r)=>e.has(t)||S_("Cannot "+r),"v$k"),Xn=o((t,e,r)=>(kp(t,e,"read from private field"),r?r.call(t):e.get(t)),"a$p"),zc=o((t,e,r)=>e.has(t)?S_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"h$m"),Cp=o((t,e,r,s)=>(kp(t,e,"write to private field"),e.set(t,r),r),"p$n"),E_=o((t,e,r)=>(kp(t,e,"access private method"),r),"_$k"),ou,cu,lu,na,hu,Sp;const M_=($o=class{t;tAttrs={"wire_channel.name":"","wire_channel.role":"client","wire_channel.transport":""};mode="trusted";downstreamRelationship="parent";signals=new Map;handlers=new Map;constructor(e){this.t=e}_config(e,r,s){this.mode=e.mode,this.downstreamRelationship=e.downstreamRelationship,this.tAttrs={"wire_channel.name":e.channelName,"wire_channel.role":e.channelRole,"wire_channel.transport":this.type},this.t=this.t.with({"component.id":"WireChannelTransport",...this.tAttrs}),this.signals=r,this.handlers=s,this.afterConfig()}},o($o,"f"),$o);au(M_,"WireChannelTransport");let Ap=M_;const T_=(ko=class{transport;mode;constructor(e,r){this.transport=e,this.mode=e.mode;for(const s in r){const n=r[s];switch(n.type){case"event":this.emit[s]=e.dispatch.bind(e,n),this.emitRaw[s]=e.dispatchRaw.bind(e,n);break;case"request":case"stream":this.request[s]=e.dispatch.bind(e,n)}}}request={};emit={};emitRaw={};dispatch(e,r,s,...n){return this.transport.dispatch(e,r,s,...n)}connect(e){var r,s;return(s=(r=this.transport).connect)==null?void 0:s.call(r,e)}disconnect(){var e,r;return(r=(e=this.transport).disconnect)==null?void 0:r.call(e)}},o(ko,"g"),ko);au(T_,"WireChannel");let FS=T_;const R_=(Co=class{constructor(e,r,s){zc(this,hu),zc(this,ou),zc(this,cu),zc(this,lu),zc(this,na,new Map),A_(this,"client"),A_(this,"server"),Cp(this,ou,e.mode),Cp(this,cu,e.downstreamRelationship),Cp(this,lu,e.name),this.client=r,this.server=s;for(const n of Object.values(s))Xn(this,na).set(n.id,n);for(const n of Object.values(r))Xn(this,na).set(n.id,n)}createClient(e,r){return E_(this,hu,Sp).call(this,"client",e,this.server,this.client,r)}createServer(e,r){return E_(this,hu,Sp).call(this,"server",e,this.client,this.server,r)}__signalMappingsForTests(){return Array.from(Xn(this,na).entries())}},o(Co,"A"),Co);ou=new WeakMap,cu=new WeakMap,lu=new WeakMap,na=new WeakMap,hu=new WeakSet,Sp=au(function(t,e,r,s,n){const i=new Map;for(const a in n){const c=r[a],h=n[a];i.set(c.id,h)}return e._config({channelName:Xn(this,lu),channelRole:t,mode:Xn(this,ou),downstreamRelationship:Xn(this,cu)},Xn(this,na),i),new FS(e,s)},"#createChannel"),au(R_,"WireChannelPair");let B_=R_;var zS=Object.defineProperty,Hc=o((t,e)=>zS(t,"name",{value:e,configurable:!0}),"s$n");const HS=4*1024,KS=4*1024*1024;function uu(t){const e=new CompressionStream("gzip"),r=e.writable.getWriter();return r.write(hc.encode(t)).catch(()=>{}),r.close().catch(()=>{}),e.readable.getReader()}o(uu,"y$h"),Hc(uu,"gzip");async function du(t){const e=[];let r=0;for(;;){const i=await t.read();if(i.done)break;e.push(i.value),r+=i.value.length}if(e.length===1)return e[0];const s=new Uint8Array(r);let n=0;for(let i=0,a=e.length;i<a;i++){const c=e[i];s.set(c,n),n+=c.length}return s}o(du,"E$l"),Hc(du,"collectGzip");function I_(t){return Hc(async function(e){const r=new DecompressionStream("gzip"),s=r.writable.getWriter();s.write(e).then(()=>s.close(),()=>s.close()).catch(()=>{});const n=r.readable.getReader();let i=Math.min(HS,t),a=new Uint8Array(i),c=0;for(;;){const h=await n.read();if(h.done)break;const u=c+h.value.length;if(u>t)throw await n.cancel(),new Error("gunzip(): Maximum decompression size exceeded");if(u>i){i*=2,i<u?i=u:i>t&&(i=t);const d=new Uint8Array(i);d.set(a),a=d}a.set(h.value,c),c=u}return yf.decode(a.subarray(0,c))},"gunzip2")}o(I_,"w$h"),Hc(I_,"makeGunzip");const Ep=I_(KS);function Mp(){if(fu===void 0)try{fu=typeof CompressionStream=="function"&&new CompressionStream("gzip")instanceof CompressionStream}catch{fu=!1}return fu}o(Mp,"z$b"),Hc(Mp,"isCompressionSupported");let fu;const q_=3333;var GS=Object.defineProperty,P_=o(t=>{throw TypeError(t)},"te$4"),as=o((t,e)=>GS(t,"name",{value:e,configurable:!0}),"m$p"),Tp=o((t,e,r)=>e.has(t)||P_("Cannot "+r),"K$8"),C=o((t,e,r)=>(Tp(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$e"),Ee=o((t,e,r)=>e.has(t)?P_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"n$n"),de=o((t,e,r,s)=>(Tp(t,e,"write to private field"),e.set(t,r),r),"s$m"),rt=o((t,e,r)=>(Tp(t,e,"access private method"),r),"o$j"),Be,wr,ct,pu,ia,Rp,pt,qs,Kc,Gc,Bp,Ip,qp,Pp,xp,Wp,Up,mu,gu,wu,vu,Dp,_u,yu,aa,He,bu,x_,W_,U_,D_,Op,jp,oa,$u;const O_=5e3,VS=O_*2,YS=2.5,j_=(So=class extends k_{constructor(e,r,s,n,i,a,c,h,u){const d=e.with(r);super(d,n,i,h,void 0,u),Ee(this,He),Ee(this,Be),Ee(this,wr),Ee(this,ct),Ee(this,pu),Ee(this,ia),Ee(this,Rp,Date.now()),Ee(this,pt,!1),Ee(this,qs,!1),Ee(this,Kc),Ee(this,Gc),Ee(this,Bp,null),Ee(this,Ip,null),Ee(this,qp,null),Ee(this,Pp,null),Ee(this,xp,null),Ee(this,Wp,null),Ee(this,Up,null),Ee(this,mu,null),Ee(this,gu,null),Ee(this,wu,null),Ee(this,vu,null),Ee(this,Dp,null),Ee(this,_u,null),Ee(this,yu,null),Ee(this,aa,Of()),de(this,Be,d),de(this,wr,r),de(this,ct,s),C(this,ct).binaryType="arraybuffer",de(this,pu,c),de(this,ia,a);const p=c.maxMessageSize??512*1024,f=Math.floor(p*YS);if(s.addEventListener("message",c.mode==="trusted"?g=>{rt(this,He,U_).call(this,g.data,p,f).catch(m=>{rt(this,He,bu).call(this,m)})}:g=>{rt(this,He,D_).call(this,g.data,p,f).catch(m=>{rt(this,He,bu).call(this,m)})}),s.addEventListener("close",g=>rt(this,He,x_).call(this,g)),s.addEventListener("error",g=>rt(this,He,bu).call(this,g)),c.acceptSocket!==!1&&typeof s.accept=="function")try{s.accept()}catch(g){C(this,Be).log.warn("wire_socket_relay.accept_failed",{err:g,ready_state:s.readyState})}c.startKeepalive!==!1&&(rt(this,He,oa).call(this),rt(this,He,$u).call(this))}prepareFrame(e){return e.length>512&&C(this,ia).enableCompression?zi(()=>C(this,ia).gzip(e),r=>r.length<e.length?r:e,r=>(C(this,Be).log.warn("wire_socket_relay.compression_failed",{err:r}),C(this,Be).record.wireSocketMessageCompressionFailureCount(1,C(this,wr)),e)):e}writeFrame(e,r,s){if(C(this,ct).readyState!==WebSocket.OPEN){de(this,qp,Date.now()),de(this,Pp,e.name),C(this,Be).log.error("wire_socket_relay.write_frame_dropped",{signal_name:e.name,ready_state:C(this,ct).readyState,is_closed:C(this,pt),is_closing_gracefully:C(this,qs)}),C(this,Be).record.wireSocketMessageDropCount(1,C(this,wr));return}try{C(this,ct).send(s),de(this,Bp,Date.now()),de(this,Ip,e.name)}catch(n){throw de(this,xp,Date.now()),de(this,Wp,e.name),C(this,Be).log.error("wire_socket_relay.send_frame_failed",{err:n,signal_name:e.name,ready_state:C(this,ct).readyState,is_closed:C(this,pt)}),n}rt(this,He,$u).call(this)}async disconnect(e,r,s){C(this,pt)||(de(this,pt,!0),de(this,qs,e===!0),de(this,mu,Date.now()),de(this,gu,r??null),de(this,wu,s??null),de(this,vu,e===!0?!0:null),C(this,pu).onClose(r),clearTimeout(C(this,Kc)),clearTimeout(C(this,Gc)),await this.handleClose(e),de(this,qs,!1),C(this,ct).readyState!==WebSocket.CLOSING&&C(this,ct).readyState!==WebSocket.CLOSED&&C(this,ct).close(r,s))}get isClosed(){return C(this,pt)}},o(So,"Z"),So);Be=new WeakMap,wr=new WeakMap,ct=new WeakMap,pu=new WeakMap,ia=new WeakMap,Rp=new WeakMap,pt=new WeakMap,qs=new WeakMap,Kc=new WeakMap,Gc=new WeakMap,Bp=new WeakMap,Ip=new WeakMap,qp=new WeakMap,Pp=new WeakMap,xp=new WeakMap,Wp=new WeakMap,Up=new WeakMap,mu=new WeakMap,gu=new WeakMap,wu=new WeakMap,vu=new WeakMap,Dp=new WeakMap,_u=new WeakMap,yu=new WeakMap,aa=new WeakMap,He=new WeakSet,bu=as(function(t){C(this,pt)||(C(this,Be).log.warn("wire_channel.websocket_error",{err:t.error,err_message:t.message,ready_state:C(this,ct).readyState,is_closed:C(this,pt),is_closing_gracefully:C(this,qs)}),C(this,Be).record.wireSocketErrorCount(1,C(this,wr)),C(this,ct).close(),C(this,aa).call(this,()=>{if(!C(this,pt))return this.disconnect(!1)}).catch(e=>{C(this,Be).log.warn("wire_channel.websocket_disconnect_failed",{err:e})}))},"#handleSocketError"),x_=as(function(t){C(this,pt)||(de(this,mu,Date.now()),de(this,gu,t.code),de(this,wu,t.reason),de(this,vu,t.wasClean),C(this,Be).log.debug("wire_channel.websocket_closed",{code:t.code,reason:t.reason,was_clean:t.wasClean,ready_state:C(this,ct).readyState,is_closing_gracefully:C(this,qs),lifetime_ms:Date.now()-C(this,Rp)}),C(this,Be).record.wireSocketCloseCount(1,t.wasClean?"was_clean:true":"was_clean:false",C(this,wr)),C(this,ct).close(),C(this,aa).call(this,()=>{if(!C(this,pt))return this.disconnect(!1,t.code)}).catch(e=>{C(this,Be).log.warn("wire_channel.websocket_disconnect_failed",{err:e})}))},"#handleSocketClose"),W_=as(function(){C(this,pt)||(C(this,Be).record.wireSocketInactivityCount(1,C(this,wr)),this.disconnect().catch(t=>{C(this,Be).log.warn("wire_channel.websocket_disconnect_failed",{err:t})}))},"#handleSocketInactivity"),U_=as(async function(t,e,r){if(t===""){this.bandwidthHooks.onIngress(0,void 0),rt(this,He,oa).call(this);return}const s=typeof t=="string"?t:new Uint8Array(t),n=s.length;if(C(this,Be).record.wireSocketMessageSizeInBytes(n,C(this,wr)),n>e){C(this,Be).record.wireSocketMessageTooLargeCount(1,"mode:trusted",C(this,wr)),C(this,Be).log.info("wire_socket_relay.message_too_large",{payload_size:n,max_size:e,mode:"trusted",payload_type:typeof t=="string"?"string":"binary"});return}return C(this,aa).call(this,()=>rt(this,He,jp).call(this,s)).then(i=>{if(!(C(this,pt)&&!C(this,qs)))return rt(this,He,Op).call(this,i),zi(()=>this.handleTrustedMessage(i,n,r),a=>{a&&rt(this,He,oa).call(this)})})},"#handleTrustedIncomingMessage"),D_=as(async function(t,e,r){if(t===""){this.bandwidthHooks.onIngress(0,void 0),rt(this,He,oa).call(this);return}const s=typeof t=="string"?t:new Uint8Array(t),n=s.length;if(C(this,Be).record.wireSocketMessageSizeInBytes(n,C(this,wr)),n>e){C(this,Be).record.wireSocketMessageTooLargeCount(1,"mode:untrusted",C(this,wr)),C(this,Be).log.info("wire_socket_relay.message_too_large",{payload_size:n,max_size:e,mode:"untrusted",payload_type:typeof t=="string"?"string":"binary"});return}return C(this,aa).call(this,()=>rt(this,He,jp).call(this,s)).then(i=>{if(!(C(this,pt)&&!C(this,qs)))return rt(this,He,Op).call(this,i),zi(()=>this.handleUntrustedMessage(i,n,r),a=>{a&&rt(this,He,oa).call(this)})})},"#handleUntrustedIncomingMessage"),Op=as(function(t){var e;de(this,Dp,Date.now());try{const r=eu(t);de(this,yu,r.type),de(this,_u,((e=this.getSignalById(r.signalId))==null?void 0:e.name)??null)}catch{de(this,yu,null),de(this,_u,null)}},"#recordIngressFrame"),jp=as(function(t){return typeof t=="string"?t:C(this,ia).gunzip(t)},"#decodeFrame"),oa=as(function(){clearTimeout(C(this,Kc)),de(this,Kc,setTimeout(()=>{rt(this,He,W_).call(this)},VS))},"#scheduleInactivity"),$u=as(function(){clearTimeout(C(this,Gc)),de(this,Gc,setTimeout(()=>{if(!(C(this,pt)||C(this,ct).readyState!==WebSocket.OPEN)){try{C(this,ct).send(""),de(this,Up,Date.now())}catch(t){throw C(this,Be).log.error("wire_socket_relay.send_ping_failed",{err:t,ready_state:C(this,ct).readyState,is_closed:C(this,pt)}),t}this.bandwidthHooks.onEgress(0,void 0),rt(this,He,$u).call(this)}},O_))},"#schedulePing"),as(j_,"WireSocketRelay");let JS=j_;var XS=Object.defineProperty,N_=o(t=>{throw TypeError(t)},"ot$1"),vr=o((t,e)=>XS(t,"name",{value:e,configurable:!0}),"w$g"),Np=o((t,e,r)=>e.has(t)||N_("Cannot "+r),"et$1"),D=o((t,e,r)=>(Np(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$d"),X=o((t,e,r)=>e.has(t)?N_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"i$f"),oe=o((t,e,r,s)=>(Np(t,e,"write to private field"),e.set(t,r),r),"r$j"),Vc=o((t,e,r)=>(Np(t,e,"access private method"),r),"y$g"),er=o((t,e,r,s)=>({set _(n){oe(t,e,n)},get _(){return D(t,e,s)}}),"u$o"),ku,At,Wt,Fe,ca,Yc,Cu,Su,Au,Lp,Fp,zp,Hp,Kp,Gp,Vp,Yp,Jp,Xp,Qp,Zp,em,tm,rm,sm,nm,im,Eu,Jc,am,om,cm,lm,hm,um,Qn,Mu,L_,F_;const z_=(Ao=class extends Ap{type="websocket";_compression;constructor(e,r){super(e),this._compression={enableCompression:(r==null?void 0:r.enableCompression)??!1,gzip:(r==null?void 0:r.gzip)??(s=>du(uu(s))),gunzip:(r==null?void 0:r.gunzip)??Ep}}},o(Ao,"rt"),Ao);vr(z_,"WireSocketChannel");let QS=z_;const H_=(Eo=class extends QS{constructor(e,r,s,n){super(e,s==null?void 0:s.compression),X(this,Qn),X(this,ku),X(this,At,!1),X(this,Wt),X(this,Fe),X(this,ca),X(this,Yc),X(this,Cu),X(this,Su),X(this,Au),X(this,Lp,0),X(this,Fp,0),X(this,zp,0),X(this,Hp,0),X(this,Kp,0),X(this,Gp,{public_connect:0,handle_close:0,roll_connection:0}),X(this,Vp,0),X(this,Yp,0),X(this,Jp,0),X(this,Xp,0),X(this,Qp,0),X(this,Zp,0),X(this,em,0),X(this,tm,0),X(this,rm,null),X(this,sm,null),X(this,nm,null),X(this,im,null),X(this,Eu,null),X(this,Jc,null),X(this,am,null),X(this,om,null),X(this,cm,null),X(this,lm,null),X(this,hm,null),X(this,um,null),oe(this,ku,r),oe(this,Au,n),oe(this,Yc,s),oe(this,Cu,(s==null?void 0:s.onConnect)??(()=>{})),oe(this,Su,(s==null?void 0:s.onDisconnect)??(()=>{})),oe(this,ca,new Ih((s==null?void 0:s.circuitBreaker)??{},{onFailure:vr((i,a)=>{e.log.info("wire_socket_client.circuit_breaker_failure",{state:i,backoff_ms:a})},"onFailure"),onTransition:vr((i,a)=>{e.log.debug("wire_socket_client.circuit_breaker_transition",{prev_state:i,new_state:a}),e.record.wireSocketCircuitBreakerStateCount(1,`state:${a}`,{"wire_channel.name":this.tAttrs["wire_channel.name"]})},"onTransition")}))}afterConfig(){}dispatch(e,r,s){if(D(this,Wt))return D(this,Wt).then(()=>{if(!D(this,Fe))throw new Error("[direct.dev/wire/channel] WireSocketClient.dispatch() called before connection established");return D(this,Fe).dispatch(r,e,s)});if(!D(this,Fe))throw new Error("[direct.dev/wire/channel] WireSocketClient.dispatch() called before connection established");return D(this,Fe).dispatch(r,e,s)}dispatchRaw(e,r,s){if(D(this,Wt))return D(this,Wt).then(()=>{if(!D(this,Fe))throw new Error("[direct.dev/wire/channel] WireSocketClient.dispatchRaw() called before connection established");return D(this,Fe).dispatchRaw(r,e,s)});if(!D(this,Fe))throw new Error("[direct.dev/wire/channel] WireSocketClient.dispatchRaw() called before connection established");return D(this,Fe).dispatchRaw(r,e,s)}async connect(e){if(er(this,Lp)._++,oe(this,rm,Date.now()),D(this,At)){er(this,Fp)._++,oe(this,sm,Date.now());return}try{oe(this,At,!0),await Vc(this,Qn,Mu).call(this,e,"public_connect")}catch(r){throw oe(this,At,!1),r}}async disconnect(e,r=!1){var s;oe(this,At,!1),(s=D(this,Wt))==null||s.catch(()=>{});const n=D(this,Fe);oe(this,Fe,void 0),await(n==null?void 0:n.disconnect(r,q_,e))}async rollConnection(){if(!D(this,At))throw new Error("[direct.dev/wire/channel]: WireSocketClient.rollConnection() cannot be called on disconnected socket");try{await Vc(this,Qn,Mu).call(this,this.t,"roll_connection"),this.t.record.wireSocketRollCount(1,"result:ok",this.tAttrs)}catch(e){throw this.t.record.wireSocketRollCount(1,"result:error",this.tAttrs),e}}get isConnected(){return D(this,At)&&D(this,Fe)!==void 0&&!D(this,Fe).isClosed}get isConnecting(){return D(this,At)&&D(this,Fe)===void 0}get connectionPromise(){return D(this,Wt)}get __relayForTesting(){return D(this,Fe)}},o(Eo,"st"),Eo);ku=new WeakMap,At=new WeakMap,Wt=new WeakMap,Fe=new WeakMap,ca=new WeakMap,Yc=new WeakMap,Cu=new WeakMap,Su=new WeakMap,Au=new WeakMap,Lp=new WeakMap,Fp=new WeakMap,zp=new WeakMap,Hp=new WeakMap,Kp=new WeakMap,Gp=new WeakMap,Vp=new WeakMap,Yp=new WeakMap,Jp=new WeakMap,Xp=new WeakMap,Qp=new WeakMap,Zp=new WeakMap,em=new WeakMap,tm=new WeakMap,rm=new WeakMap,sm=new WeakMap,nm=new WeakMap,im=new WeakMap,Eu=new WeakMap,Jc=new WeakMap,am=new WeakMap,om=new WeakMap,cm=new WeakMap,lm=new WeakMap,hm=new WeakMap,um=new WeakMap,Qn=new WeakSet,Mu=vr(function(t,e){if(er(this,zp)._++,D(this,Gp)[e]++,oe(this,nm,Date.now()),oe(this,im,e),!D(this,At)){er(this,Hp)._++,oe(this,Eu,Date.now()),oe(this,Jc,"client_not_marked_connected");return}return D(this,Wt)?(er(this,Kp)._++,oe(this,Eu,Date.now()),oe(this,Jc,"connection_in_flight"),D(this,Wt)):(oe(this,Jc,null),oe(this,Wt,(async()=>{var r;try{const s=await Vc(this,Qn,L_).call(this,t);if(!s||!D(this,At)){s||oe(this,At,!1),s==null||s.close();return}const n=D(this,Fe),i=new JS(t,this.tAttrs,s,this.signals,this.handlers,this._compression,{mode:this.mode,maxMessageSize:(r=D(this,Yc))==null?void 0:r.maxMessageSize,onClose:vr(a=>{er(this,Qp)._++,oe(this,hm,Date.now()),oe(this,um,a??null),D(this,Fe)===i?(er(this,Zp)._++,D(this,Wt)&&er(this,tm)._++):er(this,em)._++;try{D(this,Su).call(this)}catch(c){t.log.warn("wire_socket_client.on_disconnect_failed",{err:c})}D(this,Fe)===i&&D(this,At)&&Vc(this,Qn,F_).call(this,t).catch(c=>{t.log.warn("wire_socket_client.handle_close_failed",{err:c})})},"onClose")},D(this,Au),this.downstreamRelationship);oe(this,Fe,i),n==null||n.disconnect(!0,q_,"wire_socket_roll").catch(a=>{t.log.warn("wire_socket_client.roll_disconnect_failed",{err:a})}),t.record.wireSocketConnectCount(1,this.tAttrs);try{D(this,Cu).call(this)}catch(a){t.log.warn("wire_socket_client.on_connect_failed",{err:a})}}finally{oe(this,Wt,void 0)}})()),D(this,Wt))},"#connect"),L_=vr(async function(t){var e;if(!D(this,ca).check())return t.record.wireSocketCircuitBreakerRejectCount(1,this.tAttrs),null;for(;D(this,At);)try{er(this,Yp)._++,oe(this,om,Date.now());const r=await D(this,ku).call(this);if(r.readyState===WebSocket.CONNECTING&&await new Promise((s,n)=>{const i=vr(()=>{h(),s()},"onOpen"),a=vr(()=>{h(),n(new Error("socket failed unexpectedly"))},"onError"),c=vr(()=>{h(),n(new Error("socket closed unexpectedly"))},"onClose");function h(){r.removeEventListener("open",i),r.removeEventListener("error",a),r.removeEventListener("close",c)}o(h,"v"),vr(h,"cleanup"),r.addEventListener("open",i),r.addEventListener("error",a),r.addEventListener("close",c)}),r.readyState!==WebSocket.OPEN)throw new Error("socket did not open correctly");return(e=D(this,Yc))!=null&&e.primeSocket&&r.send(""),t.record.wireSocketDialCount(1,"result:ok",this.tAttrs),er(this,Jp)._++,oe(this,cm,Date.now()),D(this,ca).recordSuccess(),r}catch(r){if(t.log.info("wire_socket_client.dial_failed",{err:r}),t.record.wireSocketDialCount(1,"result:error",this.tAttrs),er(this,Xp)._++,oe(this,lm,Date.now()),!await D(this,ca).recordFailure())return null}return null},"#dialSocket"),F_=vr(async function(t){if(er(this,Vp)._++,oe(this,am,Date.now()),!D(this,At))return;const e=D(this,Fe);oe(this,Fe,void 0),await(e==null?void 0:e.disconnect()),await Vc(this,Qn,Mu).call(this,t,"handle_close")},"#handleClose"),vr(H_,"WireSocketClient");let ZS=H_;var K_=Object.defineProperty,G_=o(t=>{throw TypeError(t)},"G$7"),eA=o((t,e,r)=>e in t?K_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"Y$2"),bt=o((t,e)=>K_(t,"name",{value:e,configurable:!0}),"u$n"),tA=o((t,e,r)=>eA(t,e+"",r),"J$6"),dm=o((t,e,r)=>e.has(t)||G_("Cannot "+r),"F$b"),A=o((t,e,r)=>(dm(t,e,"read from private field"),r?r.call(t):e.get(t)),"t$8"),Et=o((t,e,r)=>e.has(t)?G_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"f$m"),Qe=o((t,e,r,s)=>(dm(t,e,"write to private field"),e.set(t,r),r),"d$j"),We=o((t,e,r)=>(dm(t,e,"access private method"),r),"a$m"),_r,Tu,Ru,Xc,ce,os,Ps,la,Zn,ei,ti,ha,ri,Qc,Me,fm,pm,V_,mm,Y_,J_,X_,Zc,gm,Bu,el;const Q_=(Mo=class extends Ap{constructor(e,r,s,n){super(e),Et(this,Me),tA(this,"type","websocket"),Et(this,_r),Et(this,Tu),Et(this,Ru),Et(this,Xc),Et(this,ce,[]),Et(this,os,0),Et(this,Ps),Et(this,la),Et(this,Zn,new Map),Et(this,ei,new Map),Et(this,ti,new Map),Et(this,ha),Et(this,ri),Et(this,Qc),Qe(this,Tu,r),Qe(this,Ru,s),n?Qe(this,Xc,{onIngress:bt((i,a)=>{We(this,Me,el).call(this,i),n.onIngress(i,a)},"onIngress"),onEgress:bt((i,a)=>{We(this,Me,el).call(this,i),n.onEgress(i,a)},"onEgress")}):Qe(this,Xc,{onIngress:bt(i=>We(this,Me,el).call(this,i),"onIngress"),onEgress:bt(i=>We(this,Me,el).call(this,i),"onEgress")}),Qe(this,_r,{scaleUpThreshold:(s==null?void 0:s.scaleUpThreshold)??100,scaleDownThreshold:(s==null?void 0:s.scaleDownThreshold)??80,scaleUpBytesPerSecond:(s==null?void 0:s.scaleUpBytesPerSecond)??1e6,scaleDownBytesPerSecond:(s==null?void 0:s.scaleDownBytesPerSecond)??5e5,scalingWindowMs:(s==null?void 0:s.scalingWindowMs)??5e3,idleDisconnectMs:s==null?void 0:s.idleDisconnectMs,minPoolSize:(s==null?void 0:s.minPoolSize)??1,maxPoolSize:(s==null?void 0:s.maxPoolSize)??10,connectionRollingIntervalMs:s==null?void 0:s.connectionRollingIntervalMs})}afterConfig(){Qe(this,la,{channelName:this.tAttrs["wire_channel.name"],channelRole:this.tAttrs["wire_channel.role"],mode:this.mode,downstreamRelationship:this.downstreamRelationship});for(const e of A(this,ce))e._config(A(this,la),this.signals,this.handlers)}dispatch(e,r,s){const n=We(this,Me,fm).call(this,r);return n instanceof Promise?n.then(i=>i.dispatch(e,r,s)):n.dispatch(e,r,s)}dispatchRaw(e,r,s){const n=We(this,Me,fm).call(this,r);return n instanceof Promise?n.then(i=>i.dispatchRaw(e,r,s)):n.dispatchRaw(e,r,s)}async connect(e){if(A(this,ce).length>0){if(A(this,ce).some(s=>s.isConnected||s.connectionPromise)){await(A(this,Ps)??Promise.allSettled(A(this,ce).map(s=>s.connectionPromise).filter(s=>s!==void 0)));return}await this.disconnect("reconnect_bootstrap")}Qe(this,ri,y());const r=A(this,_r).minPoolSize;for(let s=0;s<r;s++)We(this,Me,gm).call(this,e);Qe(this,Ps,Promise.allSettled(A(this,ce).map(s=>s.connectionPromise))),Qe(this,ha,setInterval(()=>{We(this,Me,V_).call(this)},1e3)),await A(this,Ps),Qe(this,Ps,void 0)}async disconnect(e="client_disconnect"){A(this,ha)&&(clearInterval(A(this,ha)),Qe(this,ha,void 0));for(const s of A(this,ti).values())clearInterval(s);A(this,ti).clear(),A(this,Zn).clear(),A(this,ei).clear();const r=A(this,ce);Qe(this,ce,[]),Qe(this,os,0),Qe(this,Ps,void 0),Qe(this,ri,void 0),Qe(this,Qc,void 0),await Promise.all(r.map(s=>s.disconnect(e)))}get isConnected(){return A(this,ce).some(e=>e.isConnected)}get connectionPromise(){return A(this,Ps)}},o(Mo,"j"),Mo);_r=new WeakMap,Tu=new WeakMap,Ru=new WeakMap,Xc=new WeakMap,ce=new WeakMap,os=new WeakMap,Ps=new WeakMap,la=new WeakMap,Zn=new WeakMap,ei=new WeakMap,ti=new WeakMap,ha=new WeakMap,ri=new WeakMap,Qc=new WeakMap,Me=new WeakSet,fm=bt(function(t){return We(this,Me,pm).call(this)||(A(this,Ps)??this.connect(t)).then(()=>{const r=We(this,Me,pm).call(this);if(!r)throw new Error("[direct.dev/wire/channel] WireSocketClientPool.#getClientForDispatch() no client available after reconnect");return r})},"#getClientForDispatch"),pm=bt(function(){if(A(this,ce).length===0)return;const t=Math.floor(y()/1e3);A(this,Zn).set(t,(A(this,Zn).get(t)??0)+1),Qe(this,Qc,Date.now());const e=A(this,ce).length;for(let s=0;s<e;s++){const n=(A(this,os)+s)%e,i=A(this,ce)[n];if(!(!i||i.connectionPromise))return Qe(this,os,(n+1)%e),i}Qe(this,os,(A(this,os)+1)%e);const r=A(this,ce)[A(this,os)];if(r)return r},"#selectClientForDispatch"),V_=bt(function(){if(A(this,ce).length===0)return;const[t,e,r]=We(this,Me,mm).call(this),s=We(this,Me,Zc).call(this);if(!r&&!s)return;const{scaleUpThreshold:n,scaleDownThreshold:i,scaleUpBytesPerSecond:a,scaleDownBytesPerSecond:c}=A(this,_r);t>=n*A(this,ce).length||e>=a*A(this,ce).length?We(this,Me,Y_).call(this):t<=i*(A(this,ce).length-1)&&e<=c*(A(this,ce).length-1)&&We(this,Me,J_).call(this)},"#evaluateScaling"),mm=bt(function(){const t=y(),{scalingWindowMs:e}=A(this,_r),r=Math.floor((t-e)/1e3),s=A(this,ri)!==void 0&&t-A(this,ri)>=e;let n=0,i=0;for(const[h,u]of A(this,Zn))h<r?A(this,Zn).delete(h):n+=u;for(const[h,u]of A(this,ei))h<r?A(this,ei).delete(h):i+=u;const a=n/(e/1e3),c=i/(e/1e3);return[a,c,s]},"#computeThroughput"),Y_=bt(function(){A(this,ce).length>=A(this,_r).maxPoolSize||this.t.runSpan({kind:"INTERNAL"},{event:"wire_socket_pool.scale_up",...this.tAttrs},t=>{We(this,Me,gm).call(this,t)})},"#maybeScaleUp"),J_=bt(function(){const t=We(this,Me,Zc).call(this);if(A(this,ce).length<=A(this,_r).minPoolSize){t&&this.t.runSpan({kind:"INTERNAL"},{event:"wire_socket_pool.idle_disconnect",...this.tAttrs},()=>{this.disconnect("idle_disconnect").catch(e=>{this.t.log.warn("wire_socket_pool.disconnect_failed",{...this.tAttrs,err:e})})});return}this.t.runSpan({kind:"INTERNAL"},{event:"wire_socket_pool.scale_down",...this.tAttrs},()=>{const e=A(this,ce)[A(this,ce).length-1];e&&We(this,Me,Bu).call(this,e)})},"#maybeScaleDown"),X_=bt(function(){if(A(this,ce).length<=A(this,_r).minPoolSize)return We(this,Me,Zc).call(this);const[t,e]=We(this,Me,mm).call(this),{scaleDownThreshold:r,scaleDownBytesPerSecond:s}=A(this,_r);return t<=r*(A(this,ce).length-1)&&e<=s*(A(this,ce).length-1)},"#shouldScaleDown"),Zc=bt(function(){const{idleDisconnectMs:t}=A(this,_r);if(!t)return!1;const e=A(this,Qc)??A(this,ri);return e?Date.now()-e>=t:!1},"#shouldDisconnectForIdle"),gm=bt(function(t){const e=new ZS(this.t,A(this,Tu),A(this,Ru),A(this,Xc));A(this,la)&&e._config(A(this,la),this.signals,this.handlers),A(this,ce).push(e);const r=A(this,_r).connectionRollingIntervalMs;if(r){const s=setInterval(()=>{if(We(this,Me,X_).call(this)){We(this,Me,Zc).call(this)?this.disconnect("idle_disconnect").catch(n=>{this.t.log.warn("wire_socket_pool.disconnect_failed",{...this.tAttrs,err:n})}):We(this,Me,Bu).call(this,e);return}e.rollConnection().catch(n=>{this.t.log.warn("wire_socket_pool.roll_failed",{...this.tAttrs,err:n})})},r);A(this,ti).set(e,s)}return e.connect(t).catch(()=>{We(this,Me,Bu).call(this,e)}),e},"#addClient"),Bu=bt(function(t){const e=A(this,ce).indexOf(t);if(e<0||e>=A(this,ce).length)return;const r=A(this,ti).get(t);A(this,ce).splice(e,1),A(this,ti).delete(t),r&&clearInterval(r),A(this,os)>=A(this,ce).length&&Qe(this,os,0),t==null||t.disconnect("scale_down").catch(s=>{this.t.log.warn("wire_socket_pool.client_disconnect_failed",{...this.tAttrs,err:s})})},"#removeClient"),el=bt(function(t){const e=Math.floor(y()/1e3);A(this,ei).set(e,(A(this,ei).get(e)??0)+t)},"#recordBandwidth"),bt(Q_,"WireSocketClientPool");let rA=Q_;var sA=Object.defineProperty,Z_=o(t=>{throw TypeError(t)},"T$b"),Iu=o((t,e)=>sA(t,"name",{value:e,configurable:!0}),"I$d"),wm=o((t,e,r)=>e.has(t)||Z_("Cannot "+r),"$$9"),ge=o((t,e,r)=>(wm(t,e,"read from private field"),r?r.call(t):e.get(t)),"n$m"),cs=o((t,e,r)=>e.has(t)?Z_("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"d$i"),ln=o((t,e,r,s)=>(wm(t,e,"write to private field"),e.set(t,r),r),"m$m"),qu=o((t,e,r)=>(wm(t,e,"access private method"),r),"E$h"),ls,ua,da,Pu,vm,ey,si,fa,ni,ii,tl,xu;const ty=(To=class extends k_{constructor(e,r,s,n,i,a,c,h,u){super(e.with(r),s,n,c,h,u),cs(this,vm),cs(this,ls),cs(this,ua),cs(this,da),cs(this,Pu),ln(this,ls,r),ln(this,ua,new sy(i,a.maxMessageSize,{t:e,tAttrs:r})),ln(this,da,a.maxStreamSize),ln(this,Pu,a.write)}prepareFrame(e){return ge(this,ua).encode(e)}writeFrame(e,r,s,n,i){return ge(this,Pu).call(this,e,r,s,n,i)}encodeFrame(e){return ge(this,ua).encode(e)}dispatchAbort(){}async processIngress(e,r,s){const n=Date.now(),i=[],a=s==="trusted"?this.handleTrustedMessage.bind(this):this.handleUntrustedMessage.bind(this);try{e.record.wireHttpIngressDelayMs(Date.now()-n,ge(this,ls));const c=r.getReader(),h={arr:void 0,length:0};let u=0;for(;;){const d=await c.read();if(d.value){if(u+=d.value.length,u>ge(this,da))throw e.log.warn("wire_stream_relay.stream_too_large",{total_size:u,max_size:ge(this,da)}),e.record.wireHttpIngressCount(1,"result:stream_too_large",ge(this,ls)),new Error(`[direct.dev/wire/channel] ingress stream exceeds maximum size (${u} > ${ge(this,da)})`);if(h.length===0)h.arr=d.value.slice(),h.length=h.arr.length;else{if(h.length+d.value.length>h.arr.length){const f=new Uint8Array(Math.max(h.arr.length*2,h.length+d.value.length));f.set(h.arr),h.arr=f}h.arr.set(d.value,h.length),h.length+=d.value.length}const p=await qu(this,vm,ey).call(this,e,h,a);for(let f=0,g=p.length;f<g;f++){const m=p[f];m!==void 0&&i.push(m)}}if(d.done)break}return e.record.wireHttpIngressCount(1,"result:ok",ge(this,ls)),e.record.wireHttpIngressStreamSizeInBytes(u,ge(this,ls)),h.length>0&&(this.bandwidthHooks.onIngress(h.length,void 0),e.log.debug("wire_stream_relay.unprocessable_data",{...ge(this,ls),unprocessed_bytes:h.length,total_bytes:u})),i}catch(c){if(Ir(c)||c&&c instanceof TypeError&&c.message.includes("client disconnected")||c&&c instanceof Error&&c.name==="AbortError")return i;throw e.log.warn("wire_http_relay.ingress_failed",{err:c}),e.record.wireHttpIngressCount(1,"result:error",ge(this,ls)),c}}},o(To,"y"),To);ls=new WeakMap,ua=new WeakMap,da=new WeakMap,Pu=new WeakMap,vm=new WeakSet,ey=Iu(async function(t,e,r){const s=[];for(;e.length>0;){const n=e.length,i=await ge(this,ua).decode(e);if(i==null)break;const a=n-e.length,c=Math.max(a,i.length);s.push(r(i,a,c)),t.record.wireHttpMessageSizeInBytes(i.length,ge(this,ls))}return s},"#drainIngressBuffer"),Iu(ty,"WireStreamRelay");let nA=ty;const ry=(Ro=class{constructor(e,r,s){cs(this,tl),cs(this,si),cs(this,fa),cs(this,ni),cs(this,ii);var n;ln(this,fa,(s==null?void 0:s.tAttrs)??{"wire_channel.role":"client","wire_channel.name":"","wire_channel.transport":""}),ln(this,si,(n=s==null?void 0:s.t)==null?void 0:n.with(ge(this,fa))),ln(this,ni,e),ln(this,ii,r)}encode(e){return e.length>512&&ge(this,ni).enableCompression?zi(()=>ge(this,ni).gzip(e),r=>qu(this,tl,xu).call(this,r,!0),r=>{var s,n;return(s=ge(this,si))==null||s.log.warn("wire_stream_framer.compression_failed",{err:r}),(n=ge(this,si))==null||n.record.wireHttpMessageFramingFailureCount(1,"reason:compression_failed",ge(this,fa)),qu(this,tl,xu).call(this,hc.encode(e),!1)}):qu(this,tl,xu).call(this,hc.encode(e),!1)}decode(e){const r=e.arr[0];if(r==null)return;const s=(r&128)!==0,n=(r&64)!==0;let i=r&63;if(!n){if(i>ge(this,ii))throw new Error(`[direct.dev/wire/channel] message exceeds maximum size (${i} > ${ge(this,ii)})`);const a=i+1;if(e.length<a)return;const c=e.arr.subarray(1,a);return It(s?ge(this,ni).gunzip(c):yf.decode(c),h=>(e.arr.set(e.arr.subarray(a)),e.length-=a,h))}for(let a=1;a<4;a++){const c=e.arr[a];if(c==null)return;const h=(c&128)!==0;if(i|=(c&127)<<a*7-1,!h){if(i>ge(this,ii))throw new Error(`[direct.dev/wire/channel] message exceeds maximum size (${i} > ${ge(this,ii)})`);const u=a+1,d=i+u;if(e.length<d)return;const p=e.arr.subarray(u,d);return It(s?ge(this,ni).gunzip(p):yf.decode(p),f=>(e.arr.set(e.arr.subarray(d)),e.length-=d,f))}}throw new Error("[direct.dev/wire/channel] invalid WireRelayStream frame received, header must not exceed 4 bytes")}},o(Ro,"F"),Ro);si=new WeakMap,fa=new WeakMap,ni=new WeakMap,ii=new WeakMap,tl=new WeakSet,xu=Iu(function(t,e){var r,s;if(t.length<64){const n=new Uint8Array(t.length+1);return n[0]=e?128|t.length:t.length,n.set(t,1),n}if(t.length<8192){const n=new Uint8Array(t.length+2);return n[0]=e?192|t.length&63:64|t.length&63,n[1]=t.length>>6,n.set(t,2),n}if(t.length<1048576){const n=new Uint8Array(t.length+3);return n[0]=e?192|t.length&63:64|t.length&63,n[1]=128|t.length>>6&127,n[2]=t.length>>13,n.set(t,3),n}if(t.length<134217728){const n=new Uint8Array(t.length+4);return n[0]=e?192|t.length&63:64|t.length&63,n[1]=128|t.length>>6&127,n[2]=128|t.length>>13&127,n[3]=t.length>>20,n.set(t,4),n}throw(r=ge(this,si))==null||r.log.info("wire_stream_framer.payload_too_large",{payload_size:t.length,payload_max_size:134217727}),(s=ge(this,si))==null||s.record.wireHttpMessageFramingFailureCount(1,"reason:payload_too_large",ge(this,fa)),new Error("[direct.dev/wire/channel]: messages above 128Mb not supported for HTTP transport")},"#frameBody"),Iu(ry,"WireStreamFramer");let sy=ry;var ny=Object.defineProperty,iy=o(t=>{throw TypeError(t)},"W$6"),iA=o((t,e,r)=>e in t?ny(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"$$8"),yr=o((t,e)=>ny(t,"name",{value:e,configurable:!0}),"u$m"),ay=o((t,e,r)=>iA(t,typeof e!="symbol"?e+"":e,r),"M$c"),_m=o((t,e,r)=>e.has(t)||iy("Cannot "+r),"P$b"),Ue=o((t,e,r)=>(_m(t,e,"read from private field"),r?r.call(t):e.get(t)),"h$k"),xs=o((t,e,r)=>e.has(t)?iy("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"w$d"),hn=o((t,e,r,s)=>(_m(t,e,"write to private field"),e.set(t,r),r),"v$g"),lt=o((t,e,r)=>(_m(t,e,"access private method"),r),"l$r"),hs,pa,Wu,Uu,Du,rl,Ws,sl,Ze,ym,bm,$m,nl,oy,cy,ly,km,Ou;const hy={"Content-Type":"text/plain"},aA=2*1024*1024,oA=20*1024*1024,uy=(Bo=class extends Ap{constructor(e,r,s,n){super(e),xs(this,Ze),ay(this,"type","http"),ay(this,"isConnected",!1),xs(this,hs),xs(this,pa),xs(this,Wu),xs(this,Uu),xs(this,Du),xs(this,rl),xs(this,Ws),xs(this,sl);const i=r.url;hn(this,pa,typeof i=="string"?()=>i:i),hn(this,rl,r.fetchFn??(()=>globalThis.fetch.bind(globalThis))),hn(this,hs,{batchWindowMs:r.batchWindowMs??15,batchMaxSizeInBytes:r.batchMaxSizeInBytes??524288,batchTimeoutMs:r.batchTimeoutMs??3e4,flushRequestsImmediately:r.flushRequestsImmediately??!1,maxMessageSize:r.maxMessageSize??aA,maxStreamSize:r.maxStreamSize??oA,disableDuplex:r.disableDuplex??!1}),hn(this,Wu,r.onConnect??(()=>{})),hn(this,Uu,{enableCompression:s.enableCompression??Mp(),gzip:s.gzip??(a=>du(uu(a))),gunzip:s.gunzip??Ep}),hn(this,Du,n??Jv)}afterConfig(){const e=new nA(this.t,this.tAttrs,this.signals,this.handlers,Ue(this,Uu),{write:lt(this,Ze,ly).bind(this),maxMessageSize:Ue(this,hs).maxMessageSize,maxStreamSize:Ue(this,hs).maxStreamSize},Ue(this,Du),void 0,this.downstreamRelationship),r=new _v({maxSizeInBytes:Ue(this,hs).batchMaxSizeInBytes,windowMs:Ue(this,hs).batchWindowMs,timeoutMs:Ue(this,hs).batchTimeoutMs,disableDuplex:Ue(this,hs).disableDuplex},{prepareContext:yr(()=>{const s=Ye(),n=Ye();return s.catch(()=>{}),n.catch(()=>{}),{requests:[],streams:[],requestOpened:s,liveness:n}},"prepareContext"),openRequest:lt(this,Ze,cy).bind(this)},{onBatchError:yr((s,n)=>{this.t.log.warn("wire_http_client.request_failed",{err:n}),this.t.record.wireHttpRequestErrorCount(1,this.tAttrs)},"onBatchError")});hn(this,Ws,e),hn(this,sl,r)}dispatch(e,r,s,...n){const[i,a,c]=lt(this,Ze,ym).call(this,n);if(i==="beacon"){if(e.type==="event")return lt(this,Ze,km).call(this,r,e,e.encodeRequest(r,s),c);throw new Error("[direct.dev/wire/channel] Only WireEventSignals can be dispatched as beacons")}const h=lt(this,Ze,bm).call(this,c,i==="pipeline"?a:void 0);try{const u=Ue(this,Ws).dispatch(r,e,s,void 0,h);return lt(this,Ze,$m).call(this,u,a),u}catch(u){throw a&&lt(this,Ze,nl).call(this,a,u),u}}dispatchRaw(e,r,s,...n){const[i,a,c]=lt(this,Ze,ym).call(this,n);if(i==="beacon"){if(e.type==="event")return lt(this,Ze,km).call(this,r,e,s,c);throw new Error("[direct.dev/wire/channel] Only WireEventSignals can be dispatched as beacons")}const h=lt(this,Ze,bm).call(this,c,i==="pipeline"?a:void 0);try{const u=Ue(this,Ws).dispatchRaw(r,e,s,void 0,h);return lt(this,Ze,$m).call(this,u,a),u}catch(u){throw a&&lt(this,Ze,nl).call(this,a,u),u}}},o(Bo,"I"),Bo);hs=new WeakMap,pa=new WeakMap,Wu=new WeakMap,Uu=new WeakMap,Du=new WeakMap,rl=new WeakMap,Ws=new WeakMap,sl=new WeakMap,Ze=new WeakSet,ym=yr(function(t){const e=t[0];return e==="pipeline"?["pipeline",t[1],t[2]]:e==="fetch"?["fetch",void 0,t[1]]:e==="beacon"?["beacon",void 0,t[1]]:[void 0,void 0,e]},"#parseDispatchArgs"),bm=yr(function(t,e){return e?{fetchCtx:t,pipelineProof:e}:{fetchCtx:t}},"#makeWriteContext"),$m=yr(function(t,e){!e||!t||typeof t.then!="function"||t.then(void 0,r=>{lt(this,Ze,nl).call(this,e,r)})},"#rejectPipelineProofOnAsyncFailure"),nl=yr(function(t,e){t.__state()==="pending"&&t.__reject(e).catch(()=>{})},"#rejectPipelineProof"),oy=yr(function(t,e){return e?(t.liveness.then(()=>{e.__state()==="pending"&&e.__resolve().catch(()=>{})},r=>lt(this,Ze,nl).call(this,e,r)),!0):!1},"#attachPipelineProof"),cy=yr(function(t,e,r,s){try{const n=Ue(this,rl).call(this,r.fetchCtx);Ue(this,Wu).call(this);const i=n(Ue(this,pa).call(this),{method:"POST",headers:hy,signal:s,...t});i.then(c=>e.liveness.__resolve(c),c=>e.liveness.__reject(c).catch(()=>{}));const a=i.then(c=>{if(!c.ok)throw new Error(`[direct.dev/wire/channel] HTTP ${c.status}: ${c.statusText}`);if(!c.body)throw new Error("[direct.dev/wire/channel] received response without body");return Ue(this,Ws).processIngress(this.t,c.body,this.mode).then(h=>Promise.allSettled(h).then(()=>{}))});return e.requestOpened.__isFulfilled()||e.requestOpened.__resolve(),a.then(()=>{Ue(this,Ws).terminateBatch(e.requests,e.streams)}).catch(c=>{Ue(this,Ws).terminateBatch(e.requests,e.streams,c)}),a}catch(n){throw e.requestOpened.__state()==="pending"&&e.requestOpened.__reject(n).catch(()=>{}),n}},"#openRequest"),ly=yr(function(t,e,r,s,n){const i=Ue(this,sl).write(r,n,s);if(!i)return Promise.reject(new Error("[direct.dev/wire/channel] WireHTTPClient.#writeToBatch() failed to open batch"));const[a,c]=i;return e!==void 0&&(t instanceof a_?c.requests.push({signalId:t.id,messageId:e}):t instanceof ru&&c.streams.push({signalId:t.id,messageId:e}),(t instanceof a_||t instanceof ru)&&lt(this,Ze,oy).call(this,c,n==null?void 0:n.pipelineProof)&&Ue(this,hs).flushRequestsImmediately&&Ue(this,sl).flush(n).catch(()=>{})),e===void 0?Promise.race([c.requestOpened,a]):a},"#writeToBatch"),km=yr(async function(t,e,r,s){const n=await Ue(this,Ws).encodeFrame(r);if(typeof navigator>"u"||typeof navigator.sendBeacon!="function")return lt(this,Ze,Ou).call(this,t,e,n,s);try{const i=new Blob([n],{type:"text/plain"});if(!navigator.sendBeacon(Ue(this,pa).call(this),i))return lt(this,Ze,Ou).call(this,t,e,n,s);this.t.record.wireHttpBeaconCount(1,"result:ok transport:beacon",this.tAttrs)}catch(i){return t.log.info("wire_http_client.send_beacon_failed",{err:i}),t.record.wireHttpBeaconCount(1,"result:error transport:beacon",this.tAttrs),lt(this,Ze,Ou).call(this,t,e,n,s)}},"#sendBeacon"),Ou=yr(async function(t,e,r,s){try{const n=await Ue(this,rl).call(this,s)(Ue(this,pa).call(this),{method:"POST",headers:hy,body:r});if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);t.record.wireHttpBeaconCount(1,"result:ok transport:fetch",this.tAttrs)}catch(n){t.log.info("wire_http_client.send_beacon_fallback_failed",{err:n}),t.record.wireHttpBeaconCount(1,"result:error transport:fetch",this.tAttrs)}},"#sendBeaconFallback"),yr(uy,"WireHTTPClient");let dy=uy;var cA=Object.defineProperty,fy=o(t=>{throw TypeError(t)},"D$a"),il=o((t,e)=>cA(t,"name",{value:e,configurable:!0}),"m$k"),Cm=o((t,e,r)=>e.has(t)||fy("Cannot "+r),"b$e"),un=o((t,e,r)=>(Cm(t,e,"read from private field"),r?r.call(t):e.get(t)),"l$q"),ma=o((t,e,r)=>e.has(t)?fy("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"h$j"),al=o((t,e,r,s)=>(Cm(t,e,"write to private field"),e.set(t,r),r),"_$e"),py=o((t,e,r)=>(Cm(t,e,"access private method"),r),"C$9"),ol,cl,ju,Nu,ll,Lu,my,gy;const lA=2*1024*1024,hA="Direct-Preload-Checksum",uA="Direct-Preload-Ntp-T2",dA="Direct-Preload-Ntp-T3";function wy(t,e){const r=t.req.encode(e),s=`${t.id}:${t.version}:${t.name}:${r}`;return vw(s)}o(wy,"L$b"),il(wy,"computePreloadChecksum");const vy=(Io=class{constructor(e,r,s){ma(this,Lu),ma(this,ol),ma(this,cl),ma(this,ju),ma(this,Nu),ma(this,ll),al(this,ol,e),al(this,cl,wy(e,r)),al(this,ju,(s==null?void 0:s.fetchFn)??globalThis.fetch.bind(globalThis)),al(this,ll,(s==null?void 0:s.maxMessageSize)??lA),al(this,Nu,new sy({enableCompression:!0,gzip:il(n=>du(uu(n)),"gzip"),gunzip:Ep},un(this,ll)))}dispatch(e,r,s,n){const i=new AbortController;s==null||s.addEventListener("abort",()=>i.abort(),{once:!0}),s!=null&&s.aborted&&i.abort();const a=new Ss({onEarlyDisposal(){i.abort()},onBackpressure(){i.abort()}});return py(this,Lu,my).call(this,e,r,i.signal,a,n).finally(()=>{a.isClosed||a.close(null)}).catch(()=>{}),a}},o(Io,"y"),Io);ol=new WeakMap,cl=new WeakMap,ju=new WeakMap,Nu=new WeakMap,ll=new WeakMap,Lu=new WeakSet,my=il(async function(t,e,r,s,n){var i,a;const c=un(this,ol);if(!Mp()){t.trace.addEvent("preload_compression_unsupported"),t.trace.addEvent("preload_stream_skipped"),t.record.wireSignalResultCount(1,"type:stream result:skipped",c.tAttrs);return}if(!r.aborted){t.trace.addEvent("preload_fetch_start",{url:e});try{const h=y(),u=await un(this,ju).call(this,e,{method:"GET",signal:r,credentials:"same-origin",cache:"no-store"});if(!u.ok){t.trace.addEvent("preload_fetch_failed",{status:u.status}),t.trace.addEvent("preload_stream_skipped"),t.record.wireSignalResultCount(1,"type:stream result:skipped",c.tAttrs);return}const d=u.headers.get(hA);if(d!==un(this,cl)){t.trace.addEvent("preload_checksum_mismatch",{expected:un(this,cl),received:d??"(missing)"}),t.trace.addEvent("preload_stream_skipped"),t.record.wireSignalResultCount(1,"type:stream result:skipped",c.tAttrs);return}if(!u.body){t.trace.addEvent("preload_missing_body"),t.trace.addEvent("preload_stream_skipped"),t.record.wireSignalResultCount(1,"type:stream result:skipped",c.tAttrs);return}return(i=n==null?void 0:n.onValidatedResponse)==null||i.call(n,u,h),t.trace.addEvent("preload_stream_attached"),(a=n==null?void 0:n.onAttached)==null||a.call(n),py(this,Lu,gy).call(this,t,u.body,h,r,s)}catch(h){if(h instanceof Error&&h.name==="AbortError")return;t.trace.addEvent("preload_fetch_error",{err:String(h)}),t.trace.addEvent("preload_stream_skipped"),t.record.wireSignalResultCount(1,"type:stream result:skipped",c.tAttrs);return}}},"#fetchStream"),gy=il(async function(t,e,r,s,n){const i=un(this,Nu),a=un(this,ol);let c=0;const h=e.getReader();if(s.addEventListener("abort",()=>h.cancel().catch(()=>{}),{once:!0}),s.aborted){h.cancel().catch(()=>{});return}const u={arr:void 0,length:0};try{for(;;){const{value:d,done:p}=await h.read();if(p||s.aborted)break;if(u.length===0)u.arr=d.slice(),u.length=d.length;else{if(u.length+d.length>u.arr.length){const f=new Uint8Array(Math.max(u.arr.length*2,u.length+d.length));f.set(u.arr),u.arr=f}u.arr.set(d,u.length),u.length+=d.length}for(;u.length>0;){const f=await i.decode(u);if(f==null)break;n.push(a.res.decodeUntrusted(f,0,un(this,ll))),c++}}t.trace.addEvent("preload_stream_end",{segments:c}),t.record.wireSignalResultCount(1,"type:stream result:ok",a.tAttrs),t.record.wireSignalStreamLifetimeMs(y()-r,"result:ok",a.tAttrs)}catch(d){t.trace.addEvent("preload_stream_error",{err:String(d)}),t.record.wireSignalResultCount(1,"type:stream result:error",a.tAttrs),t.record.wireSignalStreamLifetimeMs(y()-r,"result:error",a.tAttrs),n.isClosed||n.throw(d instanceof Error?d:new Error(String(d)))}},"#decodeStream"),il(vy,"WirePreloadClient");let fA=vy;const Or=l.union(l.literal("latest","pending","safe","finalized","earliest"),l.blockHeight),Sm=ke("rpc_request",l.taggedUnion("method",[["eth_accounts",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_blockNumber",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_call",{id:l.rpcRequestId,params:l.tuple([l.shape({to:l.str,from:l.str.optional.nullable,data:l.str.optional.nullable,input:l.str.optional.nullable,value:l.str.optional.nullable,gas:l.str.optional.nullable,gasPrice:l.str.optional.nullable}),Or])}],["eth_chainId",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_coinbase",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_estimateGas",{id:l.rpcRequestId,params:l.tuple([l.shape({to:l.str,from:l.str.optional.nullable,data:l.str.optional.nullable,input:l.str.optional.nullable,value:l.str.optional.nullable,gas:l.str.optional.nullable,gasPrice:l.str.optional.nullable}),Or])}],["eth_gasPrice",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_getBalance",{id:l.rpcRequestId,params:l.tuple([l.str,Or])}],["eth_getBlockByHash",{id:l.rpcRequestId,params:l.tuple([l.str,l.bool])}],["eth_getBlockByNumber",{id:l.rpcRequestId,params:l.tuple([Or,l.bool])}],["eth_getBlockTransactionCountByHash",{id:l.rpcRequestId,params:l.tuple([l.str])}],["eth_getBlockTransactionCountByNumber",{id:l.rpcRequestId,params:l.tuple([Or])}],["eth_getCode",{id:l.rpcRequestId,params:l.tuple([l.str,Or])}],["eth_getFilterChanges",{id:l.rpcRequestId,params:l.tuple([l.str])}],["eth_getFilterLogs",{id:l.rpcRequestId,params:l.tuple([l.str])}],["eth_getLogs",{id:l.rpcRequestId,params:l.tuple([l.shape({fromBlock:l.str.optional.nullable,toBlock:l.str.optional.nullable,address:l.unknown,topics:l.unknown,blockhash:l.str.optional.nullable})])}],["eth_getStorageAt",{id:l.rpcRequestId,params:l.tuple([l.str,Or])}],["eth_getTransactionByBlockHashAndIndex",{id:l.rpcRequestId,params:l.tuple([l.str,l.str])}],["eth_getTransactionByBlockNumberAndIndex",{id:l.rpcRequestId,params:l.tuple([Or,l.str])}],["eth_getTransactionByHash",{id:l.rpcRequestId,params:l.tuple([l.str])}],["eth_getTransactionCount",{id:l.rpcRequestId,params:l.tuple([l.str,Or])}],["eth_getTransactionReceipt",{id:l.rpcRequestId,params:l.tuple([l.str])}],["direct_getTransactionReceipt",{id:l.rpcRequestId,params:l.union(l.tuple([l.str]),l.tuple([l.str,l.shape({retry:l.bool})]))}],["eth_getUncleByBlockHashAndIndex",{id:l.rpcRequestId,params:l.tuple([l.str,l.str])}],["eth_getUncleByBlockNumberAndIndex",{id:l.rpcRequestId,params:l.tuple([Or,l.str])}],["eth_getUncleCountByBlockHash",{id:l.rpcRequestId,params:l.tuple([l.str])}],["eth_getUncleCountByBlockNumber",{id:l.rpcRequestId,params:l.tuple([Or])}],["eth_hashrate",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_mining",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_newBlockFilter",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_newFilter",{id:l.rpcRequestId,params:l.tuple([l.shape({fromBlock:l.str.optional.nullable,toBlock:l.str.optional.nullable,address:l.unknown,topics:l.unknown})])}],["eth_newPendingTransactionFilter",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_protocolVersion",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_sendTransaction",{id:l.rpcRequestId,params:l.tuple([l.shape({from:l.str,to:l.str.optional.nullable,gas:l.str.optional.nullable,gasPrice:l.str.optional.nullable,value:l.str.optional.nullable,data:l.str,nonce:l.str.optional.nullable})])}],["eth_sendRawTransaction",{id:l.rpcRequestId,params:l.tuple([l.str])}],["eth_sign",{id:l.rpcRequestId,params:l.tuple([l.str,l.str])}],["eth_signTransaction",{id:l.rpcRequestId,params:l.tuple([l.shape({type:l.unknown,from:l.str,to:l.str.optional.nullable,gas:l.str.optional.nullable,gasPrice:l.str.optional.nullable,value:l.str.optional.nullable,data:l.str,nonce:l.str.optional.nullable})])}],["eth_syncing",{id:l.rpcRequestId,params:l.tuple([]).optional}],["eth_uninstallFilter",{id:l.rpcRequestId,params:l.tuple([l.str])}],["net_listening",{id:l.rpcRequestId,params:l.tuple([]).optional}],["net_peerCount",{id:l.rpcRequestId,params:l.tuple([]).optional}],["net_version",{id:l.rpcRequestId,params:l.tuple([]).optional}],["web3_clientVersion",{id:l.rpcRequestId,params:l.tuple([]).optional}],["web3_sha3",{id:l.rpcRequestId,params:l.tuple([l.str])}]],{method:l.str,id:l.rpcRequestId,params:l.unknown},{ignoredProps:["jsonrpc"]})),hl=ke("rpc_response",l.union(l.shape({id:l.rpcResponseId,result:l.str,expiresAt:l.timestamp.optional},{ignoredProps:["jsonrpc"]}),l.shape({id:l.rpcResponseId,result:l.unknown,expiresAt:l.timestamp.optional},{ignoredProps:["jsonrpc"]}),l.shape({id:l.rpcResponseId,error:l.shape({code:l.num,message:l.str,data:l.unknown.optional})},{ignoredProps:["jsonrpc","expiresAt"]}))),pA=l.shape({requestMethod:l.requestMethod,requestId:l.requestIdentifier("without-checksum"),requestSizeInBytes:l.uint32,perBlockMetrics:l.record(l.union(l.blockDigest,l.literal("__unknown__")),l.shape({blockHeight:l.blockHeight.optional,responseSizeInBytes:l.uint32,responseKey:l.responseKey,timestamp:l.timestamp,latencyMs:l.arr(l.uint32)}))}),Am=l.strWithDict("inflight_cache","memory_cache","direct","configured_failover","public_failover"),mA=l.shape({headers:l.shape({upload:l.uint32,download:l.uint32}),payload:l.record(l.literal("direct","failover"),l.record(Am,l.record(l.literal("upload","download"),l.uint32)))}),gA=ke("telemetry",l.shape({networkId:l.networkId,cacheHits:l.record(Am,l.arr(pA)),upstreamResponseTimesMs:l.record(Am,l.arr(l.uint32)),bandwidthEstimate:mA}));var wA=Object.defineProperty,Fu=o((t,e)=>wA(t,"name",{value:e,configurable:!0}),"c$q");const zu=(()=>{if(typeof crypto<"u"){const t=new Uint8Array(16);return()=>(crypto.getRandomValues(t),t.slice())}try{const{randomBytes:t}=require("node:crypto");return()=>new Uint8Array(t(16))}catch{return()=>{throw new Error("Secure random generation unavailable in this environment")}}})();function vA(t){return ye===void 0&&(ye=Array.from({length:256},(e,r)=>r.toString(16).padStart(2,"0"))),ye[t[0]]+ye[t[1]]+ye[t[2]]+ye[t[3]]+ye[t[4]]+ye[t[5]]+ye[t[6]]+ye[t[7]]+ye[t[8]]+ye[t[9]]+ye[t[10]]+ye[t[11]]+ye[t[12]]+ye[t[13]]+ye[t[14]]+ye[t[15]]}o(vA,"u$l"),Fu(vA,"traceIdToHex");function _y(t){return be===void 0&&(be=Object.fromEntries(Array.from({length:256},(e,r)=>[r.toString(16).padStart(2,"0"),r]))),new Uint8Array([be[t.slice(0,2)],be[t.slice(2,4)],be[t.slice(4,6)],be[t.slice(6,8)],be[t.slice(8,10)],be[t.slice(10,12)],be[t.slice(12,14)],be[t.slice(14,16)],be[t.slice(16,18)],be[t.slice(18,20)],be[t.slice(20,22)],be[t.slice(22,24)],be[t.slice(24,26)],be[t.slice(26,28)],be[t.slice(28,30)],be[t.slice(30,32)]])}o(_y,"f$j"),Fu(_y,"traceIdFromHex");const Em=(()=>{if(typeof crypto<"u"){const t=new Uint8Array(8);return()=>(crypto.getRandomValues(t),t.slice())}try{const{randomBytes:t}=require("node:crypto");return()=>new Uint8Array(t(8))}catch{return()=>{throw new Error("Secure random generation unavailable in this environment")}}})();function _A(t){return ye===void 0&&(ye=Array.from({length:256},(e,r)=>r.toString(16).padStart(2,"0"))),ye[t[0]]+ye[t[1]]+ye[t[2]]+ye[t[3]]+ye[t[4]]+ye[t[5]]+ye[t[6]]+ye[t[7]]}o(_A,"m$j"),Fu(_A,"spanIdToHex");function yy(t){return be===void 0&&(be=Object.fromEntries(Array.from({length:256},(e,r)=>[r.toString(16).padStart(2,"0"),r]))),new Uint8Array([be[t.slice(0,2)],be[t.slice(2,4)],be[t.slice(4,6)],be[t.slice(6,8)],be[t.slice(8,10)],be[t.slice(10,12)],be[t.slice(12,14)],be[t.slice(14,16)]])}o(yy,"g$f"),Fu(yy,"spanIdFromHex");let ye,be;var yA=Object.defineProperty,bA=o((t,e)=>yA(t,"name",{value:e,configurable:!0}),"b$d");const by=(qo=class{},o(qo,"c"),qo);bA(by,"PulseExporter");let $A=by;const Hu={verbose:10,debug:20,info:30,warn:40,error:50,fatal:60,silent:70};var kA=Object.defineProperty,ga=o((t,e)=>kA(t,"name",{value:e,configurable:!0}),"r$g");const $y=(Po=class{constructor(e,r=null,s=null){this.labels=r,this.attrs=s,this.type=e,this.record=SA}name="";unit="";type;record;flush(){return{collected:[],dropped:void 0}}},o(Po,"u"),Po);ga($y,"BaseInstrument");let Ku=$y;const ky=(xo=class extends Ku{constructor(e,r){super("counter",e,r)}},o(xo,"n"),xo);ga(ky,"BaseCounter");let Z=ky;const Cy=(Wo=class extends Ku{constructor(e,r){super("up_down_counter",e,r)}},o(Wo,"p"),Wo);ga(Cy,"BaseUpDownCounter");let Sy=Cy;const CA=(Uo=class extends Ku{constructor(e,r){super("gauge",e,r)}},o(Uo,"h"),Uo);ga(CA,"BaseGauge");const Ay=(Do=class extends Ku{constructor(e,r){super("histogram",e,r)}},o(Do,"i"),Do);ga(Ay,"BaseHistogram");let jr=Ay;const SA=ga((()=>{}),"baseRecord");var AA=Object.defineProperty,EA=o((t,e)=>AA(t,"name",{value:e,configurable:!0}),"n$k");function Ey(){return{flushDurationMs:new jr,metricsDecisionCount:new Z(["decision:included","decision:dropped"]),logDecisionCount:new Z(["decision:included","decision:not_sampled","decision:below_log_level"]),traceDecisionCount:new Z(["decision:included","decision:not_sampled"])}}o(Ey,"t$5"),EA(Ey,"makePulseMetaInstruments");var MA=Object.defineProperty,TA=o((t,e)=>MA(t,"name",{value:e,configurable:!0}),"c$o");function My(t,e){var r;const s=t.trim().split(/\s+/).filter(Boolean),n={},i={wildcard:"silent",origin:void 0};for(const h of s){const u=h.split(":"),d=RA.parse(u.at(-1));switch(u[0]){case"*":{if(u.length!==2)throw new Error(`parseLogLevel: invalid token "${h}"`);i.wildcard=d;break}case"origin":{if(u.length!==3)throw new Error(`parseLogLevel: invalid token "${h}"`);u[1]&&e.startsWith(u[1])&&(!i.origin||u[1].length>=i.origin.specificity)&&(i.origin={specificity:u[1].length,level:d});break}case"trace":{if(u.length!==3)throw new Error(`parseLogLevel: invalid token "${h}"`);n[u[1]]=d;break}default:throw new Error(`parseLogLevel: invalid token "${h}"`)}}const a=((r=i.origin)==null?void 0:r.level)??i.wildcard,c=Hu[a];return{default:a,byTrace:Object.fromEntries(Object.entries(n).filter(([,h])=>Hu[h]>c))}}o(My,"h$h"),TA(My,"parseLogLevel");const RA=ke("logLevel",l.literal("verbose","debug","info","warn","error","fatal","silent"));var BA=Object.defineProperty,Mm=o((t,e)=>BA(t,"name",{value:e,configurable:!0}),"l$m");function Ty(t,e){var r;const s=t.trim().split(/\s+/).filter(Boolean),n={},i={},a={wildcard:0,origin:void 0};for(const u of s){const d=u.split(":"),p=Ry(d.at(-1)??"");switch(d[0]){case"*":{if(d.length!==2)throw new Error(`parseLogSampling: invalid token "${u}"`);a.wildcard=p;break}case"origin":{if(d.length!==3)throw new Error(`parseLogSampling: invalid token "${u}"`);d[1]&&e.startsWith(d[1])&&(!a.origin||d[1].length>=a.origin.specificity)&&(a.origin={specificity:d[1].length,factor:p});break}case"trace":{if(d.length!==3)throw new Error(`parseLogSampling: invalid token "${u}"`);n[d[1]]=p;break}case"level":{if(d.length!==3)throw new Error(`parseLogSampling: invalid token "${u}"`);i[IA.parse(d[1])]=p;break}default:throw new Error(`parseLogSampling: invalid token "${u}"`)}}const c=((r=a.origin)==null?void 0:r.factor)??a.wildcard,h=Mm(u=>{const d=i[u]!=null?Math.max(c,i[u]):c;return{default:d,byTrace:Object.fromEntries(Object.entries(n).filter(([,p])=>p>d))}},"parseByLevel");return{verbose:h("verbose"),debug:h("debug"),info:h("info"),warn:h("warn"),error:h("error"),fatal:h("fatal")}}o(Ty,"h$g"),Mm(Ty,"parseLogSampling");function Ry(t){const e=parseFloat(t);if(Number.isNaN(e)||e<0||e>1)throw new Error(`parseFactor: invalid factor "${t}"`);return e*4294967295>>>0}o(Ry,"m$i"),Mm(Ry,"parseFactor");const IA=ke("logSampling",l.literal("verbose","debug","info","warn","error","fatal"));var qA=Object.defineProperty,By=o((t,e)=>qA(t,"name",{value:e,configurable:!0}),"o$e");function Iy(t,e){var r;const s=t.trim().split(/\s+/).filter(Boolean),n={},i={wildcard:0,origin:void 0};for(const a of s){const c=a.split(":"),h=qy(c.at(-1)??"");switch(c[0]){case"*":{if(c.length!==2)throw new Error(`parseTraceSampling: invalid token "${a}"`);i.wildcard=h;break}case"origin":{if(c.length!==3)throw new Error(`parseTraceSampling: invalid token "${a}"`);c[1]&&e.startsWith(c[1])&&(!i.origin||c[1].length>=i.origin.specificity)&&(i.origin={specificity:c[1].length,factor:h});break}case"event":{if(c.length!==3)throw new Error(`parseTraceSampling: invalid token "${a}"`);n[c[1]]=h;break}default:throw new Error(`parseTraceSampling: invalid token "${a}"`)}}return{default:((r=i.origin)==null?void 0:r.factor)??i.wildcard,byEvent:n}}o(Iy,"p$h"),By(Iy,"parseTraceSampling");function qy(t){const e=parseFloat(t);if(Number.isNaN(e)||e<0||e>1)throw new Error(`parseFactor: invalid factor "${t}"`);return e*4294967295>>>0}o(qy,"g$d"),By(qy,"parseFactor");var PA=Object.defineProperty,xA=o((t,e)=>PA(t,"name",{value:e,configurable:!0}),"r$f");function Tm(t){if(t instanceof Error)return t.stack?`${String(t)}
4
+ ${t.stack}`:String(t);if(typeof t=="symbol")return String(t);if(t!=null&&typeof t=="object")try{const e=JSON.stringify(t);return e==="{}"?String(t):e}catch{return String(t)}return String(t)}o(Tm,"f$h"),xA(Tm,"stringifyAttribute");var Py=Object.defineProperty,xy=o(t=>{throw TypeError(t)},"ce$1"),WA=o((t,e,r)=>e in t?Py(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"ye$1"),Mt=o((t,e)=>Py(t,"name",{value:e,configurable:!0}),"b$c"),wa=o((t,e,r)=>WA(t,typeof e!="symbol"?e+"":e,r),"M$a"),Wy=o((t,e,r)=>e.has(t)||xy("Cannot "+r),"le$1"),le=o((t,e,r)=>(Wy(t,e,"read from private field"),r?r.call(t):e.get(t)),"n$j"),dn=o((t,e,r)=>e.has(t)?xy("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"N$7"),Nr=o((t,e,r,s)=>(Wy(t,e,"write to private field"),e.set(t,r),r),"C$8"),ul,Lr,va,br,dl,fn,_a,fl;const pl=Symbol("errorCode"),Gu=Symbol("message"),ya=Symbol("attributes"),ai=Symbol("events"),ml=Symbol("waitUntil"),Y=Symbol("span"),mt=Symbol("ctx"),UA=Object.freeze({setError(t,e){this[pl]=t,this[Gu]=e},setAttributes(t){const e=this[ya];for(const r in t)e[r]=t[r]},addEvent(t,e){this[ai]??=[],this[ai].push({timeStamp:Date.now(),name:t,attributes:e})},waitUntil(t){this[ml]??=[],this[ml].push(t)},fromRequestHeaders(t){const e=OA.exec(String(t.get("traceparent")??"")),r=t.get("x-direct-tracename");if(!e||!r||typeof r!="string")return;const[,,s,n,i]=e;return{traceId:_y(s),traceName:r,traceSampled:(parseInt(i,16)&1)===1,spanId:yy(n)}},toRequestHeaders(){if(this[Y])return{traceparent:`00-${this[Y].traceId}-${this[Y].spanId}-${this[Y].traceSampled?"01":"00"}`,"x-direct-tracename":this[Y].traceName}},exportTraceParent(){if(this[Y])return this[Y]}}),Uy={[Y]:{value:void 0,writable:!0,enumerable:!1,configurable:!0},[mt]:{value:void 0,writable:!0,enumerable:!1,configurable:!0},[pl]:{value:void 0,writable:!0,configurable:!0},[Gu]:{value:void 0,writable:!0,configurable:!0},[ya]:{value:{},writable:!0,configurable:!0},[ai]:{value:void 0,writable:!0,configurable:!0},[ml]:{value:void 0,writable:!0,configurable:!0}},DA={[Y]:{value:void 0,writable:!0,enumerable:!1,configurable:!0},[mt]:{value:void 0,writable:!0,enumerable:!1,configurable:!0}};function Dy(t,e,r,s,n){let i=Math.random()*4294967295|0;const a=Mt(()=>(i^=i<<13,i^=i>>>17,i^=i<<5,i>>>0),"rng"),c=Mt((b,O)=>b==null?O:b===4294967295?!0:b===0?!1:a()<b,"computeSampling"),h=Hy(e,t),u=UA,d=Rm(e,h,s,n,a),p=Ny(r),f=12,g=new Array(f);let m=0;const w=Mt(()=>{if(m>0){const b=g[--m];return b?(b[Y]=void 0,b[mt]=void 0,b.trace[Y]=void 0,b.trace[mt]=void 0,b.trace[pl]=void 0,b.trace[Gu]=void 0,b.trace[ai]=void 0,b.trace[ml]=void 0,b.trace[ya]={},b.log[Y]=void 0,b.log[mt]=void 0,b.record[Y]=void 0,b):void 0}},"acquirePulseFromPool"),_=Mt(b=>{m<f&&(g[m++]=b)},"releasePulseToPool"),S=Object.create(null,{trace:{writable:!0,value:Object.create(u,Uy)},log:{writable:!0,value:Object.create(d,Ly)},record:{writable:!0,value:Object.create(p,jy)},with:{writable:!1,value:Mt(function(b,O){let j=w();const W=O??this[Y];let K;if(!b)K=this[mt];else{K=Object.create(this[mt]??null);for(const Pe in b)K[Pe]=b[Pe]}j?(j[Y]=W,j[mt]=K,j.trace[Y]=W,j.trace[mt]=K,j.record[Y]=W):(j=Object.create(S),j[Y]=W,j[mt]=K,j.trace=Object.create(u,Uy),j.trace[Y]=W,j.trace[mt]=K,j.record=Object.create(p,jy),j.record[Y]=W);let q;return!(O&&!this[Y])||!h.__logOverridesByTrace.has(O.traceName)?q=this.log:(q=h.__logCache.get(O.traceName),q||(q=Rm(e,h,s,n,a,O),h.__logCache.set(O.traceName,q))),j.log=Object.create(q,Ly),j.log[Y]=W,j.log[mt]=K,j},"withFnc")},runInContext:{writable:!1,value:Mt(async function(b,O){const j=this.with(b);try{return await O(j)}catch(W){throw j.log.error("runInContext intercepted exception",{err:W}),W}},"runInContext")},runSpan:{writable:!1,value:Mt(async function(b,O,j){const W=y(),K=(b.parent&&b.parent instanceof Headers?this.trace.fromRequestHeaders(b.parent):b.parent)??this.trace.exportTraceParent(),q=(()=>{if((K==null?void 0:K.spanId)==null){const Ve=h.traceSampling.byEvent[O.event]??h.traceSampling.default;return{traceId:zu(),traceName:O.event,traceSampled:c(Ve,!1),parentSpanId:void 0,parentLink:void 0,spanId:Em(),spanKind:b.kind}}const Ae=h.traceSampling.byEvent[O.event];return b.parentRelationship!=="link"?{traceId:K.traceId,traceName:K.traceName,traceSampled:c(Ae,K.traceSampled),parentLink:void 0,parentSpanId:K.spanId,spanId:Em(),spanKind:b.kind}:{traceId:zu(),traceName:K.traceName,traceSampled:c(Ae,K.traceSampled),parentSpanId:void 0,parentLink:K,spanId:Em(),spanKind:b.kind}})();s.traceDecisionCount.record(q,1,q.traceSampled?"decision:included":"decision:not_sampled");let Pe=!1;const je=this.with(O,q);try{try{return await j(je)}finally{const Ae=je.trace[ml];Ae&&await Promise.allSettled(Ae)}}catch(Ae){Pe=!0;const Ve=y(),Ft=je.trace;if(Ft[pl]==null){const zt=Ft[ya]??Oy,or=Ft[ai];let Qr;q.traceSampled?Qr=q:($r.traceId=zu(),$r.traceName=q.traceName,$r.spanId=q.spanId,$r.spanKind=q.spanKind,q.parentSpanId&&($r.parentLink=pn,pn.traceId=q.traceId,pn.traceName=q.traceName,pn.spanId=q.parentSpanId),Qr=$r),Ut.startTimestamp=W,Ut.endTimestamp=Ve,Ut.success=!1,Ut.message=Tm(Ae),zt.error_code="UNCAUGHT",n.trace(Qr,O,zt,or,{startTimestamp:W,endTimestamp:Ve,success:!1,message:Tm(Ae)})}else je.log.error("An uncaught exception was thrown",{err:Ae});throw Ae}finally{_(je);const Ae=y(),Ve=je.trace,Ft=Ve[pl];if(Ft!=null){const zt=Ve[ya]??Oy,or=Ve[ai],Qr=Ve[Gu];let Zr;q.traceSampled?Zr=q:($r.traceId=zu(),$r.traceName=q.traceName,$r.spanId=q.spanId,$r.spanKind=q.spanKind,q.parentSpanId&&($r.parentLink=pn,pn.traceId=q.traceId,pn.traceName=q.traceName,pn.spanId=q.parentSpanId),Zr=$r),Ut.startTimestamp=W,Ut.endTimestamp=Ae,Ut.success=!1,Ut.message=Qr,zt.error_code=Ft,n.trace(Zr,O,zt,or,Ut)}else if(!Pe&&q.traceSampled){const zt=Ve[ya],or=Ve[ai];Ut.startTimestamp=W,Ut.endTimestamp=Ae,Ut.success=!0,Ut.message=void 0,n.trace(q,O,zt,or,Ut)}}},"runSpan")}});return Object.create(S,DA)}o(Dy,"he"),Mt(Dy,"makePulseAPITemplate");const $r={traceSampled:!0,parentSpanId:void 0},pn={},Ut={startTimestamp:0,endTimestamp:0,success:!0,message:void 0},Oy={},jy={[Y]:{value:void 0,writable:!0,enumerable:!1,configurable:!0}};function Ny(t){const e=Object.create(null);e[Y]=void 0;for(const[r,s]of Object.entries(t))e[r]=function(...n){s.record(this[Y],...n)};return Object.freeze(e)}o(Ny,"xe$1"),Mt(Ny,"makePulseMetricsProto");const Ly={[Y]:{value:void 0,writable:!0,enumerable:!1,configurable:!0},[mt]:{value:void 0,writable:!0,enumerable:!1,configurable:!0}};function Rm(t,e,r,s,n,i){const{logRedactor:a}=t,c=Mt(h=>{const u=i?e.logLevel.byTrace[i.traceName]??e.logLevel.default:e.logLevel.default,d=i?e.logSampling[h].byTrace[i.traceName]??e.logSampling[h].default:e.logSampling[h].default,p=!!(i!=null&&i.traceSampled),f=d===1||p,g=d===0&&!p;return Hu[h]<Hu[u]?Mt(function(){r.logDecisionCount.record(this[Y],1,"decision:below_log_level")},"noop"):g?Mt(function(){r.logDecisionCount.record(this[Y],1,"decision:not_sampled")},"noop"):f?a?function(m,w){s.log(h,y(),m,this[Y],this[mt],w?a(typeof w=="function"?w():w):void 0),r.logDecisionCount.record(this[Y],1,"decision:included")}:function(m,w){s.log(h,y(),m,this[Y],this[mt],w?typeof w=="function"?w():w:void 0),r.logDecisionCount.record(this[Y],1,"decision:included")}:a?function(m,w){if(n()>=d){r.logDecisionCount.record(this[Y],1,"decision:not_sampled");return}s.log(h,y(),m,this[Y],this[mt],w?a(typeof w=="function"?w():w):void 0),r.logDecisionCount.record(this[Y],1,"decision:included")}:function(m,w){n()>=d||(s.log(h,y(),m,this[Y],this[mt],w?typeof w=="function"?w():w:void 0),r.logDecisionCount.record(this[Y],1,"decision:included"))}},"makeLogWriter");return Object.freeze({verbose:c("verbose"),debug:c("debug"),info:c("info"),warn:c("warn"),error:c("error"),fatal:c("fatal")})}o(Rm,"be$1"),Mt(Rm,"makePulseLogProto");const Fy=new vc(50),zy=50;function Hy(t,e){const r=t.logLevel+"|"+t.logSamples+"|"+t.traceSamples+"|"+e,s=Fy.get(r);if(s)return s;const n=My(t.logLevel,e),i=Ty(t.logSamples,e),a=Iy(t.traceSamples,e),c=new Set([...Object.keys(n.byTrace),...Object.values(i).flatMap(d=>Object.keys(d.byTrace))]),h=c.size>zy?new vc(zy):new Map,u={logLevel:n,logSampling:i,traceSampling:a,__logCache:h,__logOverridesByTrace:c};return Fy.set(r,u),u}o(Hy,"je"),Mt(Hy,"parseOptions");const Ky=(Oo=class{constructor(e,r,s){dn(this,ul),dn(this,Lr),dn(this,va),dn(this,br),dn(this,dl),dn(this,fn),dn(this,_a,!1),dn(this,fl,!1),wa(this,"log"),wa(this,"trace"),wa(this,"record"),wa(this,"with"),wa(this,"runSpan"),wa(this,"runInContext");const n=e.serviceNamespace?e.serviceNamespace+"."+e.serviceName:e.serviceName;Nr(this,ul,Object.values(s)),Nr(this,Lr,this._createMetaInstruments()),Nr(this,va,r.exporter(e)),Nr(this,br,Dy(n,r,s,le(this,Lr),le(this,va))),Nr(this,dl,r.metricExportIntervalMs??15e3),this.log=le(this,br).log,this.trace=le(this,br).trace,this.record=le(this,br).record,this.with=le(this,br).with.bind(le(this,br)),this.runSpan=le(this,br).runSpan.bind(le(this,br)),this.runInContext=le(this,br).runInContext.bind(le(this,br))}_createMetaInstruments(){return Ey()}async scheduleFlush(){if(le(this,fn)!=null)throw new Error("Pulse.scheduleFlush(): not allowed while activateAutoExport() is managing automatic flushing.");if(!le(this,_a))try{Nr(this,_a,!0),await pc(le(this,dl)),await this.export()}finally{Nr(this,_a,!1)}}activateAutoExport(){if(le(this,_a))throw new Error("Pulse.activateAutoFlush(): not allowed when manual call to scheduleFlush() is pending");le(this,fn)==null&&Nr(this,fn,setInterval(()=>{this.export(!1)},le(this,dl)))}async deactivateAutoExport(){le(this,fn)!=null&&(clearInterval(le(this,fn)),Nr(this,fn,void 0),await this.export())}async export(e=!0){if(!le(this,fl)){Nr(this,fl,!0);try{const r=y(),s=[];for(let i=0,a=le(this,ul).length;i<a;i++){const c=le(this,ul)[i],{collected:h,dropped:u}=c.flush();h.length>0&&(le(this,Lr).metricsDecisionCount.record(void 0,h.length,"decision:included"),s.push({timestamp:r,name:c.name,unit:c.unit,metrics:h})),u&&(le(this,Lr).metricsDecisionCount.record(void 0,u[0].value,"decision:dropped"),s.push({timestamp:r,name:u[0].name,unit:u[0].unit,metrics:u}))}le(this,Lr).flushDurationMs.record(void 0,y(-r));const n=[le(this,Lr).flushDurationMs.flush().collected,le(this,Lr).metricsDecisionCount.flush().collected,le(this,Lr).logDecisionCount.flush().collected,le(this,Lr).traceDecisionCount.flush().collected];for(let i=0,a=n.length;i<a;i++){const c=n[i];c!=null&&c[0]&&s.push({timestamp:r,name:c[0].name,unit:c[0].unit,metrics:c})}le(this,va).metrics(s),e&&await le(this,va).flush()}catch(r){this.log.warn("pulse_export_failed",{err:r,force_flush:e})}finally{Nr(this,fl,!1)}}}},o(Oo,"ie"),Oo);ul=new WeakMap,Lr=new WeakMap,va=new WeakMap,br=new WeakMap,dl=new WeakMap,fn=new WeakMap,_a=new WeakMap,fl=new WeakMap,Mt(Ky,"Pulse");let Gy=Ky;const OA=/^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/i;var jA=Object.defineProperty,NA=o((t,e)=>jA(t,"name",{value:e,configurable:!0}),"n$i");function Bm(){return{wireSocketConnectCount:new Z(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireSocketDialCount:new Z(["result:ok","result:error"],l.shape({"wire_channel.name":l.str})),wireSocketActiveCount:new Sy(null,l.shape({"wire_channel.name":l.str})),wireSocketDispatchCount:new Z(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireSocketCloseCount:new Z(["was_clean:true","was_clean:false"],l.shape({"wire_channel.name":l.str})),wireSocketErrorCount:new Z(null,l.shape({"wire_channel.name":l.str})),wireSocketInactivityCount:new Z(null,l.shape({"wire_channel.name":l.str})),wireSocketMessageDropCount:new Z(null,l.shape({"wire_channel.name":l.str})),wireSocketRollCount:new Z(["result:ok","result:error"],l.shape({"wire_channel.name":l.str})),wireSocketMessageTooLargeCount:new Z(["mode:trusted","mode:untrusted"],l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireSocketMessageCompressionFailureCount:new Z(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireSocketMessageSizeInBytes:new jr(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireSocketCircuitBreakerStateCount:new Z(["state:open","state:half_open","state:half_closed","state:closed"],l.shape({"wire_channel.name":l.str})),wireSocketCircuitBreakerRejectCount:new Z(null,l.shape({"wire_channel.name":l.str})),wireHttpIngressCount:new Z(["result:ok","result:error","result:stream_too_large"],l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireHttpIngressDelayMs:new jr(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireHttpIngressStreamSizeInBytes:new jr(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireHttpMessageSizeInBytes:new jr(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireHttpMessageFramingFailureCount:new Z(["reason:payload_too_large","reason:compression_failed"],l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireHttpRequestErrorCount:new Z(null,l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireHttpBeaconCount:new Z(["result:ok transport:beacon","result:error transport:beacon","result:ok transport:fetch","result:error transport:fetch"],l.shape({"wire_channel.name":l.str,"wire_channel.role":l.literal("server","client")})),wireSignalDispatchCount:new Z(["type:event","type:request","type:stream"],l.shape({"wire_signal.name":l.str})),wireSignalResultCount:new Z(["type:event result:ok","type:request result:ok","type:request result:error","type:request result:timeout","type:request result:send_error","type:stream result:ok","type:stream result:skipped","type:stream result:error","type:stream result:timeout","type:stream result:initial_timeout","type:stream result:item_timeout","type:stream result:send_error"],l.shape({"wire_signal.name":l.str.optional})),wireSignalRequestHandleCount:new Z(["result:unrecognized_signal","result:malformed_header","type:event result:ok","type:event result:error","type:event result:handler_not_bound","type:event result:response_not_supported","type:event result:aborted","type:request result:unrecognized","type:request result:mismatched_type","type:request result:ok","type:request result:error","type:request result:handler_not_bound","type:request result:timeout","type:request result:aborted","type:stream result:unrecognized","type:stream result:mismatched_type","type:stream result:started","type:stream result:ok","type:stream result:error","type:stream result:timeout","type:stream result:handler_not_bound","type:stream result:aborted"],l.shape({"wire_signal.name":l.str.optional})),wireSignalStreamSegmentCount:new Z(null,l.shape({"wire_signal.name":l.str})),wireSignalMigrationCount:new Z(null,l.shape({"wire_signal.name":l.str,"wire_signal.from_version":l.uint32,"wire_signal.to_version":l.uint32})),wireSignalLatencyMs:new jr(["result:ok","result:error","result:timeout","result:send_error"],l.shape({"wire_signal.name":l.str})),wireSignalStreamLifetimeMs:new jr(["result:ok","result:error","result:timeout","result:initial_timeout","result:item_timeout"],l.shape({"wire_signal.name":l.str})),wireSignalBackpressureCount:new Z(null,l.shape({"wire_signal.name":l.str})),wireSignalSendErrorCount:new Z(null,l.shape({"wire_signal.name":l.str})),wireSignalUnsupportedVersionCount:new Z(null,l.shape({"wire_signal.name":l.str}))}}o(Bm,"o$d"),NA(Bm,"makeWireInstruments");var LA=Object.defineProperty,Ke=o((t,e)=>LA(t,"name",{value:e,configurable:!0}),"a$i");const Im=96,FA=0,gl=32,Vu=64,Yu=96,Us=16,wl=15,zA=FA|16,tr=ke("continuum_checksum",l.fnv1a);function Vy(t,e){const r=[];for(const s in e)r.push([s,{payload:e[s]}]);return ke(t,l.taggedUnion("patch",r))}o(Vy,"j$6"),Ke(Vy,"makePatchSchema");function Yy(t,e,r,s,n){const i=n.encode(s),a=t.trace.exportTraceParent();if(a){const c=_t.encode(a);return[String.fromCharCode(gl|Us|e)+c+tr.encode(r)+i,c.length]}return[String.fromCharCode(gl|e)+tr.encode(r)+i,0]}o(Yy,"z$5"),Ke(Yy,"encodePatch");function Ju(t,e,r){const s=r.encode(e.state),n=t.trace.exportTraceParent();if(n){const i=_t.encode(n);return[String.fromCharCode(Vu|Us)+i+tr.encode(e.headChecksum)+s,i.length]}return[String.fromCharCode(Vu)+tr.encode(e.headChecksum)+s,0]}o(Ju,"B$9"),Ke(Ju,"encodeSnapshot");function HA(t,e){const r=t.trace.exportTraceParent();if(r){const s=_t.encode(r);return[String.fromCharCode(Yu|Us)+s+e.join(""),s.length]}return[String.fromCharCode(Yu)+e.join(""),0]}o(HA,"K$5"),Ke(HA,"encodeBatch");function Jy(t,e,r){const s=Ke((d,p,f)=>t==="trusted"?tr.decodeTrusted(d,p,f):tr.decodeUntrusted(d,p,f),"decodeChecksum"),n=Ke((d,p,f)=>t==="trusted"?_t.decodeTrusted(d,p,f):_t.decodeUntrusted(d,p,f),"decodeTraceParent"),i=Ke((d,p,f)=>t==="trusted"?e.decodeTrusted(d,p,f):e.decodeUntrusted(d,p,f),"decodeState"),a=t==="trusted"?r.map(d=>(p,f,g)=>d.patchSchema.decodeTrusted(p,f,g)):r.map(d=>(p,f,g)=>d.patchSchema.decodeUntrusted(p,f,g));function c(d,p,f,g){const m=a[p];if(!m)return null;const w=s(d,f,g),_=m(d,vt(),g);return{type:"patch",continuumId:p,patch:_,expectedChecksum:w}}o(c,"R"),Ke(c,"decodePatch");function h(d,p,f){const g=s(d,p,f);return{type:"snapshot",snapshot:{state:i(d,vt(),f),headChecksum:g}}}o(h,"_"),Ke(h,"decodeSnapshot");function u(d,p,f){const g=[],m=[];let w=p;for(;w<d.length;){const _=w,S=d.charCodeAt(w)&wl,b=a[S];if(w+=1,!b)return null;const O=s(d,w,f),j=b(d,vt(),f);w=vt(),g.push({type:"patch",continuumId:S,patch:j,expectedChecksum:O}),m.push(d.slice(_,w))}return{type:"batch",patches:g,payloads:m}}return o(u,"x"),Ke(u,"decodeBatch"),Ke(function(d){const p=d.length,f=d.charCodeAt(0),g=(f&Us)!==0;let m,w,_;g?(m=n(d,1,p),_=vt(),w=_-1):(m=void 0,_=1,w=0);const S=f&Im,b=f&wl;if(S===Yu){if(b!==0)throw new Error(`[continuum/codec] Batch payload must have continuum ID = 0, got ${b}`);return{traceParent:m,event:u(d,_,p),traceDataLength:w}}if(S===Vu){if(b!==0)throw new Error(`[continuum/codec] Snapshot payload must have continuum ID = 0, got ${b}`);const O=h(d,_,p);return vt()!==d.length?{traceParent:m,event:null,traceDataLength:w}:{traceParent:m,event:O,traceDataLength:w}}if(S===gl){const O=c(d,b,_,p);return O&&vt()!==d.length?{traceParent:m,event:null,traceDataLength:w}:{traceParent:m,event:O,traceDataLength:w}}throw new Error(`[continuum/codec] Invalid payload header: 0b${f.toString(2).padStart(8,"0")} (type bits: ${(S>>5).toString(2).padStart(2,"0")})`)},"decodePayload")}o(Jy,"G$4"),Ke(Jy,"makePayloadDecoder");function Xu(t,e){let r;return e!==void 0?r=1+e:Pm(t)?(_t.decodeTrusted(t,1),r=vt()):r=1,tr.decodeTrusted(t,r),t.slice(vt())}o(Xu,"L$a"),Ke(Xu,"extractPatchBody");function qm(t,e,r,s){const n=t.trace.exportTraceParent();if(n){const i=_t.encode(n);return[String.fromCharCode(gl|Us|e)+i+tr.encode(r)+s,i.length]}return[String.fromCharCode(gl|e)+tr.encode(r)+s,0]}o(qm,"X$3"),Ke(qm,"hydratePatchBody");function Pm(t){return(t.charCodeAt(0)&Us)!==0}o(Pm,"k$9"),Ke(Pm,"hasTrace");function Xy(t){return t.length>0&&t.charCodeAt(0)===zA}o(Xy,"b$b"),Ke(Xy,"hasContinuationFrame");function xm(t){const e=t.charCodeAt(0);return(e&Im)===Yu&&(e&wl)===0}o(xm,"q$9"),Ke(xm,"isBatchPayload");function Wm(t){const e=t.charCodeAt(0);return(e&Im)===Vu&&(e&wl)===0}o(Wm,"J$5"),Ke(Wm,"isSnapshotPayload");function KA(t,e){let r;return e!==void 0?r=1+e:(t.charCodeAt(0)&Us)!==0?(_t.decodeTrusted(t,1),r=vt()):r=1,tr.decodeUntrusted(t,r)}o(KA,"Q$4"),Ke(KA,"extractChecksumFromPayload");function GA(t,e){if(!Pm(t))return t;let r;e!==void 0?r=e:(_t.decodeTrusted(t,1),r=vt()-1);const s=t.charCodeAt(0)&~Us;return String.fromCharCode(s)+t.slice(1+r)}o(GA,"V$3"),Ke(GA,"stripTrace");function VA(t,e){const r=t.trace.exportTraceParent();if(!r)return[e,0];const s=_t.encode(r),n=e.charCodeAt(0)|Us;return[String.fromCharCode(n)+s+e.slice(1),s.length]}o(VA,"W$4"),Ke(VA,"addTrace");var Qy=Object.defineProperty,Zy=o(t=>{throw TypeError(t)},"k$8"),YA=o((t,e,r)=>e in t?Qy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"H$5"),Um=o((t,e)=>Qy(t,"name",{value:e,configurable:!0}),"p$g"),Dm=o((t,e,r)=>YA(t,typeof e!="symbol"?e+"":e,r),"m$h"),eb=o((t,e,r)=>e.has(t)||Zy("Cannot "+r),"w$b"),ba=o((t,e,r)=>(eb(t,e,"read from private field"),r?r.call(t):e.get(t)),"c$n"),Qu=o((t,e,r)=>e.has(t)?Zy("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"i$c"),tb=o((t,e,r)=>(eb(t,e,"access private method"),r),"l$k"),vl,_l,rb,Zu,sb,nb;const ib=(jo=class{constructor(e){Qu(this,Zu),Dm(this,"name"),Dm(this,"stateSchema"),Dm(this,"patchSchema"),Qu(this,vl,new Set),Qu(this,_l,new Set),Qu(this,rb,new WeakSet),this.name=e.name,this.stateSchema=ke(`${e.name}:state`,e.state),this.patchSchema=Vy(`${e.name}:patch`,e.patches)}applyPatch(e,r,s){const n=r.patch,i=this.reducers[r.patch],a=i(r.payload);if(a!==void 0)return e.log.debug("continuum_patch_rejected",{continuum:this.name,patch:n,reason:a,payload:r.payload}),e.record.continuumPatchRejectedCount(1,{patch:n,reason:a}),!1;e.record.continuumPatchAppliedCount(1,{patch:n});const[c,h]=s??Yy(e,0,Uc,r,this.patchSchema);return tb(this,Zu,sb).call(this,e,r,c,h),!0}applySnapshot(e,r){this.setState(r),tb(this,Zu,nb).call(this,e,r)}onPatch(e){return ba(this,vl).add(e),()=>{ba(this,vl).delete(e)}}onSnapshot(e){return ba(this,_l).add(e),()=>{ba(this,_l).delete(e)}}},o(jo,"P"),jo);vl=new WeakMap,_l=new WeakMap,rb=new WeakMap,Zu=new WeakSet,sb=Um(function(t,e,r,s){for(const n of ba(this,vl))n(t,e,r,s)},"#emitPatch"),nb=Um(function(t,e){for(const r of ba(this,_l))r(t,e)},"#emitSnapshot"),Um(ib,"Continuum");let Om=ib;var ab=Object.defineProperty,ob=o(t=>{throw TypeError(t)},"P$7"),JA=o((t,e,r)=>e in t?ab(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"O$8"),us=o((t,e)=>ab(t,"name",{value:e,configurable:!0}),"u$i"),XA=o((t,e,r)=>JA(t,e+"",r),"B$8"),jm=o((t,e,r)=>e.has(t)||ob("Cannot "+r),"T$7"),he=o((t,e,r)=>(jm(t,e,"read from private field"),r?r.call(t):e.get(t)),"i$b"),mn=o((t,e,r)=>e.has(t)?ob("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"m$g"),Ie=o((t,e,r,s)=>(jm(t,e,"write to private field"),e.set(t,r),r),"r$e"),oi=o((t,e,r)=>(jm(t,e,"access private method"),r),"p$f"),$a,rr,gt,Fr,Ds,gn,yl,Os,ed,bl;const ka=5,QA=3e3,ZA=1500,ci=l.shape({height:l.blockHeight,digest:l.blockDigest}),li=ke("serialized_block",ne({safeParse:us(t=>typeof t=="number"?Number.isInteger(t)&&t>=0&&t<ka:ci._safeParse(t),"safeParse"),encode:us(t=>typeof t=="number"?String.fromCharCode(t|64):ci._encode(t),"encode"),decodeTrusted:us((t,e)=>{const r=t.charCodeAt(e.offset);return r&64?(e.offset+=1,r&63):ci._decodeTrusted(t)},"decodeTrusted"),decodeUntrusted:us((t,e)=>{const r=t.charCodeAt(e.offset);if(r&64){e.offset+=1;const s=r&63;if(s<0||s>=ka)throw new Error(`Invalid blockRingBuffer index, must be 0-${ka-1}`);return s}return ci._decodeUntrusted(t)},"decodeUntrusted")})),cb=l.shape({context:ci,propagatesAt:l.timestamp}),eE=l.shape({digest:l.blockDigest,expiresAt:l.timestamp}),tE=l.shape({expiresAt:l.timestamp}),rE=l.shape({current:ci.optional,pending:cb.optional,expiresAt:l.timestamp,blockRingBuffer:l.arr(ci)}),lb=(No=class extends Om{constructor(e={}){super({name:"block_continuum",state:rE,patches:{transition:cb,promote:eE,affirm:tE}}),mn(this,Os),mn(this,$a),mn(this,rr),mn(this,gt),mn(this,Fr),mn(this,Ds,new Array(ka)),mn(this,gn),mn(this,yl),XA(this,"reducers",{transition:us(r=>{he(this,Ds).unshift(r.context),he(this,Ds).length=ka,he(this,gt)&&Ie(this,rr,he(this,gt).context),he(this,$a).call(this,r.propagatesAt)?(Ie(this,rr,r.context),Ie(this,gt,void 0)):Ie(this,gt,r),Ie(this,Fr,r.propagatesAt+QA),oi(this,Os,bl).call(this)},"transition"),promote:us(r=>{var s,n;if(((s=he(this,rr))==null?void 0:s.digest)===r.digest){Ie(this,Fr,r.expiresAt),oi(this,Os,bl).call(this);return}if(((n=he(this,gt))==null?void 0:n.context.digest)!==r.digest)return"digest_mismatch";Ie(this,rr,he(this,gt).context),Ie(this,gt,void 0),Ie(this,Fr,r.expiresAt),oi(this,Os,bl).call(this)},"promote"),affirm:us(r=>{Ie(this,Fr,r.expiresAt)},"affirm")}),Ie(this,rr,void 0),Ie(this,gt,void 0),Ie(this,Fr,0),Ie(this,yl,y()),Ie(this,$a,e.isExpired??(r=>y()>=r)),this.onPatch(()=>{Ie(this,yl,y())})}setState(e){Ie(this,rr,e.current),Ie(this,gt,e.pending),Ie(this,Fr,e.expiresAt),Ie(this,Ds,[...e.blockRingBuffer]),he(this,Ds).length=ka,oi(this,Os,bl).call(this)}getState(){return oi(this,Os,ed).call(this),{current:he(this,rr),pending:he(this,gt),expiresAt:he(this,Fr),blockRingBuffer:he(this,Ds).filter(e=>e!==void 0)}}getCurrent(){if(oi(this,Os,ed).call(this),!(!he(this,rr)||he(this,$a).call(this,he(this,Fr))))return{height:he(this,rr).height,digest:he(this,rr).digest,expiresAt:he(this,Fr)}}getPendingTransition(){return oi(this,Os,ed).call(this),he(this,gt)}waitForCurrent(e){const r=this.getCurrent();if(r)return r;if(!(y()-he(this,yl)>ZA))return he(this,gn)||Ie(this,gn,Ye()),gc(e,he(this,gn)).then(s=>s===mc?void 0:s)}getBlockRef(e){const r=he(this,Ds).findIndex(s=>(s==null?void 0:s.digest)===e.digest);return r!==-1?r:e}parseBlockRef(e){if(e!==void 0){if(typeof e=="number"){const r=he(this,Ds)[e];if(!r)throw new Error(`Block not found at ring buffer index ${e}`);return r}return e}}},o(No,"R"),No);$a=new WeakMap,rr=new WeakMap,gt=new WeakMap,Fr=new WeakMap,Ds=new WeakMap,gn=new WeakMap,yl=new WeakMap,Os=new WeakSet,ed=us(function(){he(this,gt)&&he(this,$a).call(this,he(this,gt).propagatesAt)&&(Ie(this,rr,he(this,gt).context),Ie(this,gt,void 0))},"#maybePromotePending"),bl=us(function(){if(!he(this,gn))return;const t=this.getCurrent();t&&(he(this,gn).__resolve(t),Ie(this,gn,void 0))},"#maybeResolveWaiter"),us(lb,"BlockContinuum");let hb=lb;var sE=Object.defineProperty,nE=o((t,e)=>sE(t,"name",{value:e,configurable:!0}),"r$d");const iE=l.shape({skip:l.uint32,deleteLen:l.uint32,insert:l.str}),ub=ke("diff",l.shape({prefixLen:l.uint32,ops:l.arr(iE)}));function Nm(t,e){const{prefixLen:r,ops:s}=e;let n=t.slice(0,r),i=r;for(const a of s){const c=i+a.skip;i<c&&(n+=t.slice(i,c)),n+=a.insert,i=c+a.deleteLen}return n+=t.slice(i),n}o(Nm,"h$d"),nE(Nm,"applyDiff");var db=Object.defineProperty,fb=o(t=>{throw TypeError(t)},"A$8"),aE=o((t,e,r)=>e in t?db(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"R$8"),ds=o((t,e)=>db(t,"name",{value:e,configurable:!0}),"d$d"),oE=o((t,e,r)=>aE(t,e+"",r),"C$6"),Lm=o((t,e,r)=>e.has(t)||fb("Cannot "+r),"w$9"),Ce=o((t,e,r)=>(Lm(t,e,"read from private field"),r?r.call(t):e.get(t)),"n$g"),Ca=o((t,e,r)=>e.has(t)?fb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"f$d"),pb=o((t,e,r,s)=>(Lm(t,e,"write to private field"),e.set(t,r),r),"S$8"),$l=o((t,e,r)=>(Lm(t,e,"access private method"),r),"a$f"),Dt,js,kl,Cl,Sa,hi,td,mb,gb;const rd=l.requestFingerprint("with-checksum"),wn=ke("fingerprint_ref",ne({safeParse:ds(t=>typeof t=="number"?Number.isInteger(t)&&t>=0:rd._safeParse(t),"safeParse"),encode:ds(t=>typeof t=="number"?l.uint32._encode(t+1):"\0"+rd._encode(t),"encode"),decodeTrusted:ds((t,e)=>t.charCodeAt(e.offset)===0?(e.offset++,rd._decodeTrusted(t)):l.uint32._decodeTrusted(t)-1,"decodeTrusted"),decodeUntrusted:ds((t,e)=>{if(Number.isNaN(t.charCodeAt(e.offset)))throw $.PAYLOAD_TRUNCATED;return t.charCodeAt(e.offset)===0?(e.offset++,rd._decodeUntrusted(t)):l.uint32._decodeUntrusted(t)-1},"decodeUntrusted")})),cE=l.shape({fingerprints:l.arr(l.requestFingerprint("with-checksum"))}),lE=l.shape({added:l.arr(l.requestFingerprint("with-checksum")),removed:l.arr(l.requestFingerprint("with-checksum"))}),hE=l.shape({added:l.arr(l.requestFingerprint("with-checksum")),kept:l.arr(l.requestFingerprint("with-checksum"))}),wb=(Lo=class extends Om{constructor(){super({name:"fingerprint_continuum",state:cE,patches:{incremental:lE,replacement:hE}}),Ca(this,hi),Ca(this,Dt,[]),Ca(this,js,new Map),oE(this,"reducers",{incremental:ds(e=>{$l(this,hi,mb).call(this,e)},"incremental"),replacement:ds(e=>{$l(this,hi,gb).call(this,e)},"replacement")}),Ca(this,kl,new Set),Ca(this,Cl,new Set),Ca(this,Sa,new Set)}setState(e){pb(this,Dt,[...e.fingerprints]),$l(this,hi,td).call(this);for(const r of Ce(this,Sa))r(e.fingerprints)}getState(){return{fingerprints:Ce(this,Dt).slice(0)}}onAdded(e){return Ce(this,kl).add(e),()=>{Ce(this,kl).delete(e)}}onRemoved(e){return Ce(this,Cl).add(e),()=>{Ce(this,Cl).delete(e)}}onReplacement(e){return Ce(this,Sa).add(e),()=>{Ce(this,Sa).delete(e)}}getFingerprintRef(e){const r=Ce(this,js).get(e);return r!==void 0?r:e}parseFingerprintRef(e){if(typeof e=="number"){const r=Ce(this,Dt)[e];if(!r)throw new Error(`Fingerprint not found at index ${e}`);return r}return e}has(e){return Ce(this,js).has(e)}get size(){return Ce(this,Dt).length}*iterate(){yield*Ce(this,Dt)}},o(Lo,"b"),Lo);Dt=new WeakMap,js=new WeakMap,kl=new WeakMap,Cl=new WeakMap,Sa=new WeakMap,hi=new WeakSet,td=ds(function(){Ce(this,js).clear();for(let t=0,e=Ce(this,Dt).length;t<e;t++){const r=Ce(this,Dt)[t];r!==void 0&&Ce(this,js).set(r,t)}},"#rebuildIndexMap"),mb=ds(function(t){if(t.removed.length>0){for(const e of t.removed){const r=Ce(this,js).get(e);r!==void 0&&Ce(this,Dt).splice(r,1)}$l(this,hi,td).call(this);for(const e of Ce(this,Cl))e(t.removed)}if(t.added.length>0){for(const e of t.added)Ce(this,js).has(e)||(Ce(this,js).set(e,Ce(this,Dt).length),Ce(this,Dt).push(e));for(const e of Ce(this,kl))e(t.added)}},"#applyIncremental"),gb=ds(function(t){pb(this,Dt,[...t.kept,...t.added]),$l(this,hi,td).call(this);for(const e of Ce(this,Sa))e(Ce(this,Dt))},"#applyReplacement"),ds(wb,"FingerprintContinuum");let Fm=wb;var vb=Object.defineProperty,_b=o(t=>{throw TypeError(t)},"Q$3"),uE=o((t,e,r)=>e in t?vb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"oe$2"),Te=o((t,e)=>vb(t,"name",{value:e,configurable:!0}),"u$g"),zm=o((t,e,r)=>uE(t,typeof e!="symbol"?e+"":e,r),"B$7"),Hm=o((t,e,r)=>e.has(t)||_b("Cannot "+r),"U$5"),J=o((t,e,r)=>(Hm(t,e,"read from private field"),r?r.call(t):e.get(t)),"o$a"),Aa=o((t,e,r)=>e.has(t)?_b("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"x$5"),Sl=o((t,e,r,s)=>(Hm(t,e,"write to private field"),e.set(t,r),r),"E$c"),se=o((t,e,r)=>(Hm(t,e,"access private method"),r),"p$d"),Ea,vn,zr,Tt,kr,te,Km,sd,Gm,nd,Vm,Ym,yb,_n,bb,$b,id,kb,Cb,ad;const dE=25*1024*1024,fE=1e3,pE=25e3,mE=2,gE=l.shape({requestKey:l.requestKey("with-checksum"),responseKey:l.responseKey,response:l.str,expiresAt:l.timestamp}),wE=l.shape({fingerprintRef:wn,blockRef:li,responseKey:l.responseKey,expiresAt:l.timestamp}),vE=l.shape({fingerprintRef:wn,responseKey:l.responseKey,fromBlock:li,toBlock:li,expiresAt:l.timestamp}),_E=l.shape({fingerprintRef:wn,responseKey:l.responseKey,fromBlock:li,toBlock:li,diff:ub,expiresAt:l.timestamp}),yE=l.shape({fingerprintRef:wn,blockRef:li,responseKey:l.responseKey,response:l.str,expiresAt:l.timestamp}),bE=l.shape({fingerprintRef:wn,responseKey:l.responseKey,expiresAt:l.timestamp}),$E=l.shape({fingerprintRef:wn,responseKey:l.responseKey,diff:ub,expiresAt:l.timestamp}),kE=l.shape({fingerprintRef:wn,responseKey:l.responseKey,response:l.str,expiresAt:l.timestamp}),CE=l.shape({fingerprintRef:wn,blockRef:li}),SE=l.shape({requestKey:l.requestKey("with-checksum"),baseRequestKey:l.requestKey("with-checksum").optional,expiresAt:l.timestamp}),AE=l.shape({entries:l.arr(gE),inflightEntries:l.arr(SE)}),Sb=(Fo=class extends Om{constructor(e,r,s,n){super({name:"cache_continuum",state:AE,patches:{mutable_zero_change:wE,immutable_zero_change:bE,mutable_block_only:vE,mutable_diff:_E,immutable_diff:$E,mutable_replacement:yE,immutable_replacement:kE,mutable_failed:CE}}),Aa(this,te),Aa(this,Ea),Aa(this,vn),zm(this,"blockContinuum"),zm(this,"fingerprintContinuum"),Aa(this,zr),Aa(this,Tt),Aa(this,kr),zm(this,"reducers",{mutable_zero_change:Te(i=>{const{fingerprintRef:a,blockRef:c,responseKey:h,expiresAt:u}=i,d=this.fingerprintContinuum.parseFingerprintRef(a),p=this.blockContinuum.parseBlockRef(c),f=Ht(d,p.digest);return se(this,te,Km).call(this,f,h,u)},"mutable_zero_change"),immutable_zero_change:Te(i=>{const{fingerprintRef:a,responseKey:c,expiresAt:h}=i,u=this.fingerprintContinuum.parseFingerprintRef(a);return Rr(u)?se(this,te,Km).call(this,u,c,h):"missing_block_ref"},"immutable_zero_change"),mutable_block_only:Te(i=>{const{fingerprintRef:a,responseKey:c,fromBlock:h,toBlock:u,expiresAt:d}=i,p=this.fingerprintContinuum.parseFingerprintRef(a),f=this.blockContinuum.parseBlockRef(h),g=this.blockContinuum.parseBlockRef(u),m=Ht(p,f.digest),w=se(this,te,nd).call(this,m);if(!w)return"prev_entry_not_found";const _=se(this,te,Gm).call(this,w.response,f,g);if(!se(this,te,sd).call(this,_,c))return"digest_mismatch";const S=Ht(p,g.digest);se(this,te,_n).call(this,{requestKey:S,responseKey:c,response:_,expiresAt:d})},"mutable_block_only"),mutable_diff:Te(i=>{const{fingerprintRef:a,responseKey:c,fromBlock:h,toBlock:u,diff:d,expiresAt:p}=i,f=this.fingerprintContinuum.parseFingerprintRef(a),g=this.blockContinuum.parseBlockRef(h),m=this.blockContinuum.parseBlockRef(u),w=Ht(f,g.digest),_=se(this,te,nd).call(this,w);if(!_)return"prev_entry_not_found";const S=se(this,te,Gm).call(this,_.response,g,m),b=Nm(S,d);if(!se(this,te,sd).call(this,b,c))return"digest_mismatch";const O=Ht(f,m.digest);se(this,te,_n).call(this,{requestKey:O,responseKey:c,response:b,expiresAt:p})},"mutable_diff"),immutable_diff:Te(i=>{const{fingerprintRef:a,responseKey:c,diff:h,expiresAt:u}=i,d=this.fingerprintContinuum.parseFingerprintRef(a);if(!Rr(d))return"missing_block_ref";const p=se(this,te,nd).call(this,d);if(!p)return"prev_entry_not_found";const f=Nm(p.response,h);if(!se(this,te,sd).call(this,f,c))return"digest_mismatch";se(this,te,_n).call(this,{requestKey:d,responseKey:c,response:f,expiresAt:u})},"immutable_diff"),mutable_replacement:Te(i=>{const{fingerprintRef:a,blockRef:c,responseKey:h,response:u,expiresAt:d}=i,p=this.fingerprintContinuum.parseFingerprintRef(a),f=this.blockContinuum.parseBlockRef(c),g=Ht(p,f.digest);se(this,te,_n).call(this,{requestKey:g,responseKey:h,response:u,expiresAt:d})},"mutable_replacement"),immutable_replacement:Te(i=>{const{fingerprintRef:a,responseKey:c,response:h,expiresAt:u}=i,d=this.fingerprintContinuum.parseFingerprintRef(a);if(!Rr(d))return"missing_block_ref";se(this,te,_n).call(this,{requestKey:d,responseKey:c,response:h,expiresAt:u})},"immutable_replacement"),mutable_failed:Te(i=>{const{fingerprintRef:a,blockRef:c}=i,h=this.fingerprintContinuum.parseFingerprintRef(a),u=Ht(h,this.blockContinuum.parseBlockRef(c).digest);se(this,te,id).call(this,u,void 0)},"mutable_failed")}),this.blockContinuum=e,this.fingerprintContinuum=r,Sl(this,Ea,s),Sl(this,vn,(n==null?void 0:n.isExpired)??(i=>y()>=i)),Sl(this,Tt,new vc((n==null?void 0:n.maxRequestEntries)??pE)),Sl(this,kr,new vc((n==null?void 0:n.maxInflightEntries)??fE,{onEvict:Te((i,a)=>{clearTimeout(a.timeout),a.deferred&&!a.deferred.__isFulfilled()&&(a.deferred.__resolve(void 0),J(this,Ea).onInflightEviction())},"onEvict")})),Sl(this,zr,new av((n==null?void 0:n.maxSizeBytes)??dE,{onEvict:Te((i,a)=>{J(this,vn).call(this,a.expiresAt)||J(this,Ea).onPrematureEviction()},"onEvict")})),this.blockContinuum.onPatch((i,a)=>{a.patch==="transition"&&se(this,te,bb).call(this,a.payload.context)}),this.fingerprintContinuum.onRemoved(i=>{i.length>0&&se(this,te,kb).call(this,new Set(i))}),this.fingerprintContinuum.onReplacement(i=>{se(this,te,Cb).call(this,new Set(i))})}setState(e){J(this,zr).clear(),J(this,Tt).clear();for(const r of e.entries)se(this,te,_n).call(this,r);for(const[,r]of J(this,kr).entries())clearTimeout(r.timeout),r.deferred&&!r.deferred.__isFulfilled()&&r.deferred.__resolve(void 0);J(this,kr).clear();for(const{requestKey:r,expiresAt:s,baseRequestKey:n}of e.inflightEntries)J(this,vn).call(this,s)||J(this,kr).set(r,{expiresAt:s,baseRequestKey:n})}getState(){const e=[],{inflightEntries:r,retainedRequestKeys:s,retainedBlockDigests:n}=se(this,te,Ym).call(this);for(const[i,a]of J(this,Tt).entries()){const c=J(this,zr).get(a);!c||!se(this,te,Vm).call(this,i,c,s,n)||e.push(c.requestKey===i?c:{...c,requestKey:i})}return{entries:e,inflightEntries:r}}readFromCache(e){const r=J(this,Tt).get(e);if(r)return J(this,zr).get(r);const s=J(this,kr).get(e);if(!(!s||J(this,vn).call(this,s.expiresAt)))return s.deferred?s.deferred:se(this,te,$b).call(this,e,s)}has(e){return J(this,Tt).has(e)}},o(Fo,"O"),Fo);Ea=new WeakMap,vn=new WeakMap,zr=new WeakMap,Tt=new WeakMap,kr=new WeakMap,te=new WeakSet,Km=Te(function(t,e,r){const s=J(this,zr).get(e);if(!s)return"prev_entry_not_found";se(this,te,_n).call(this,{requestKey:t,responseKey:e,response:s.response,expiresAt:r})},"#applyZeroChange"),sd=Te(function(t,e){const r=Dw(e);return Rf(hl.decodeUntrusted(t))===r},"#validateDigest"),Gm=Te(function(t,e,r){return t.replaceAll(e.height.slice(2),r.height.slice(2))},"#applyBlockHeightTransform"),nd=Te(function(t){const e=J(this,Tt).get(t);if(!e)return;const r=J(this,zr).get(e);if(r)return r.requestKey===t?r:{...r,requestKey:t}},"#lookupEntry"),Vm=Te(function(t,e,r,s){if(r.has(t))return!0;if(!uc(t))return!J(this,vn).call(this,e.expiresAt);const n=Tf(t);return n!==void 0&&s.has(n)},"#shouldRetainInSnapshot"),Ym=Te(function(){const t=[],e=new Set,r=new Set(this.blockContinuum.getState().blockRingBuffer.map(s=>s.digest));for(const[s,n]of J(this,kr).entries())J(this,vn).call(this,n.expiresAt)||(t.push({requestKey:s,expiresAt:n.expiresAt,baseRequestKey:n.baseRequestKey}),e.add(s),n.baseRequestKey&&e.add(n.baseRequestKey));return{inflightEntries:t,retainedRequestKeys:e,retainedBlockDigests:r}},"#collectSnapshotRetention"),yb=Te(function(){const{retainedRequestKeys:t,retainedBlockDigests:e}=se(this,te,Ym).call(this),r=[];for(const[s,n]of J(this,Tt).entries()){const i=J(this,zr).get(n);(!i||!se(this,te,Vm).call(this,s,i,t,e))&&r.push(s)}for(const s of r)se(this,te,ad).call(this,s)},"#pruneSnapshotIneligibleEntries"),_n=Te(function(t){const{requestKey:e,responseKey:r,response:s}=t;if(If(r)){const n=(e.length+r.length+s.length+8)*mE;J(this,zr).set(r,t,n),J(this,Tt).set(e,r)}se(this,te,id).call(this,e,t)},"#insertEntry"),bb=Te(function(t){const e=y(3e3),r=this.blockContinuum.getCurrent();for(const s of this.fingerprintContinuum.iterate()){if(Rr(s))continue;const n=Ht(s,t.digest);let i;r&&r.digest!==t.digest&&(i=Ht(s,r.digest)),J(this,kr).set(n,{expiresAt:e,baseRequestKey:i})}se(this,te,yb).call(this)},"#registerInflightFromPlan"),$b=Te(function(t,e){const r=Ye(),s=Math.max(0,e.expiresAt-y());return e.timeout=setTimeout(()=>{r.__isFulfilled()||(r.__resolve(void 0),J(this,Ea).onInflightTimeout())},s),r.finally(()=>{clearTimeout(e.timeout),J(this,kr).delete(t)}),e.deferred=r,r},"#openInflightDeferred"),id=Te(function(t,e){const r=J(this,kr).get(t);r&&(r.deferred&&!r.deferred.__isFulfilled()&&r.deferred.__resolve(e),clearTimeout(r.timeout),J(this,kr).delete(t))},"#resolveInflight"),kb=Te(function(t){if(t.size!==0)for(const[e]of J(this,Tt).entries())t.has(lh(e))&&se(this,te,ad).call(this,e)},"#purgeByFingerprint"),Cb=Te(function(t){for(const[e]of J(this,Tt).entries())t.has(lh(e))||se(this,te,ad).call(this,e)},"#purgeUntrackedFingerprints"),ad=Te(function(t){const e=J(this,Tt).get(t);if(J(this,Tt).delete(t),se(this,te,id).call(this,t,void 0),!!e){for(const[,r]of J(this,Tt).entries())if(r===e)return;J(this,zr).delete(e)}},"#deleteRequestKey"),Te(Sb,"CacheContinuum");let Ab=Sb;var Eb=Object.defineProperty,Mb=o(t=>{throw TypeError(t)},"Q$2"),EE=o((t,e,r)=>e in t?Eb(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"ht"),sr=o((t,e)=>Eb(t,"name",{value:e,configurable:!0}),"f$c"),Tb=o((t,e,r)=>EE(t,typeof e!="symbol"?e+"":e,r),"N$3"),Jm=o((t,e,r)=>e.has(t)||Mb("Cannot "+r),"j$4"),I=o((t,e,r)=>(Jm(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$8"),Ot=o((t,e,r)=>e.has(t)?Mb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"d$b"),jt=o((t,e,r,s)=>(Jm(t,e,"write to private field"),e.set(t,r),r),"p$c"),Nt=o((t,e,r)=>(Jm(t,e,"access private method"),r),"l$h"),Hr,Ma,ht,ui,od,nr,Ns,Al,El,cd,Ml,Tl,Rl,$t,Xm,Rb,Bb,Qm,Zm,Bl,eg;const ME=ne({safeParse:sr(t=>typeof t=="string","safeParse"),encode:sr(t=>t,"encode"),decodeTrusted:sr(t=>t.slice(vt()),"decodeTrusted"),decodeUntrusted:sr(t=>t.slice(vt()),"decodeUntrusted")});function Ib(t){return t?ke("continuum_req",l.shape({fromChecksum:tr,timeoutMs:l.uint32.optional,params:t})):ke("continuum_req",l.shape({fromChecksum:tr,timeoutMs:l.uint32.optional}))}o(Ib,"ct$1"),sr(Ib,"makeReqSchema");const TE=ke("continuum_res",ME),qb=(xi=class extends ru{constructor(e,r,s,n){const i=r.timeoutMs??3e4;super({id:r.id,name:r.name,req:Ib(s),res:TE,timeoutMs:i,initialTimeoutMs:r.initialTimeoutMs,itemTimeoutMs:r.itemTimeoutMs},[]),Ot(this,$t),Ot(this,Hr),Ot(this,Ma),Ot(this,ht),Ot(this,ui),Ot(this,od),Tb(this,"paramsSchema"),Ot(this,nr),Ot(this,Ns),Ot(this,Al),Tb(this,"snapshotSchema"),Ot(this,El,new WeakSet),Ot(this,cd,new WeakSet),Ot(this,Ml,new Set),Ot(this,Tl,new Set),Ot(this,Rl,new Set),jt(this,od,r),this.paramsSchema=s,jt(this,nr,{"continuum.signal":r.name}),jt(this,Ma,Object.keys(e).sort());const a={};jt(this,Hr,I(this,Ma).map(c=>{const h=e[c];return a[c]=h.stateSchema,h})),jt(this,Ns,ke(`continuum:${this.name}`,l.shape(a))),this.snapshotSchema=l.shape({state:I(this,Ns),headChecksum:tr}),n?(jt(this,ui,!0),jt(this,ht,n.headChecksum),jt(this,Al,Jy(n.mode,I(this,Ns),I(this,Hr))),Nt(this,$t,Bb).call(this)):(jt(this,ui,!1),jt(this,ht,Uc))}get headChecksum(){return I(this,ht)}hydrate(e,r,s,n){if(I(this,ui))throw new Error(`ContinuumSignal "${this.name}" is already hydrated and cannot hydrate again`);return new xi(r,I(this,od),this.paramsSchema,{headChecksum:n??Uc,mode:s})}handlePayload(e,r){if(!I(this,ui)||!I(this,Al))throw new Error(`ContinuumSignal "${this.name}" must be hydrated before use`);const{traceParent:s,event:n,traceDataLength:i}=I(this,Al).call(this,r);return e.runSpan({parent:s,kind:"CONSUMER"},{event:"continuum.handle_payload",...I(this,nr)},a=>{if(Nt(this,$t,eg).call(this,a,r,"remote"),!n)return Nt(this,$t,Bl).call(this,a,{reason:"decode_error",fromChecksum:I(this,ht),continuumId:!xm(r)&&!Wm(r)?r.charCodeAt(0)&wl:void 0}),!1;if(n.type==="snapshot")return a.record.continuumSnapshotCount(1,"source:remote",I(this,nr)),Nt(this,$t,Rb).call(this,a,n.snapshot,[r,i]),!0;if(n.type==="batch"){a.record.continuumBatchSize(n.patches.length,I(this,nr)),a.record.continuumPatchCount(n.patches.length,"source:remote",I(this,nr));for(let c=0;c<n.payloads.length;c++){const h=n.payloads[c],u=n.patches[c],d=Xu(h),[p,f]=qm(a,u.continuumId,u.expectedChecksum,d);if(!Nt(this,$t,Xm).call(this,a,u,p,f))return!1}return!0}return a.record.continuumPatchCount(1,"source:remote",I(this,nr)),Nt(this,$t,Xm).call(this,a,n,r,i)})}exportSnapshot(){if(!I(this,ui))throw new Error(`ContinuumSignal "${this.name}" must be hydrated before use`);const e={};for(let r=0,s=I(this,Hr).length;r<s;r++){const n=I(this,Ma)[r],i=I(this,Hr)[r];e[n]=i.getState()}return{state:e,headChecksum:I(this,ht)}}encodeSnapshot(e){return Ju(e,this.exportSnapshot(),I(this,Ns))}onPatch(e){return I(this,Ml).add(e),()=>{I(this,Ml).delete(e)}}onSnapshot(e){return I(this,Tl).add(e),()=>{I(this,Tl).delete(e)}}onDesync(e){return I(this,Rl).add(e),()=>{I(this,Rl).delete(e)}}},o(xi,"U"),xi);Hr=new WeakMap,Ma=new WeakMap,ht=new WeakMap,ui=new WeakMap,od=new WeakMap,nr=new WeakMap,Ns=new WeakMap,Al=new WeakMap,El=new WeakMap,cd=new WeakMap,Ml=new WeakMap,Tl=new WeakMap,Rl=new WeakMap,$t=new WeakSet,Xm=sr(function(t,e,r,s){const n=I(this,Hr)[e.continuumId];if(!n)return Nt(this,$t,Bl).call(this,t,{...e,reason:"invalid_continuum",fromChecksum:I(this,ht)}),!1;const i=Xu(r,s),a=zh(i,I(this,ht));return a!==e.expectedChecksum?(Nt(this,$t,Bl).call(this,t,{...e,reason:"checksum_mismatch",fromChecksum:I(this,ht),computedChecksum:a}),!1):(I(this,El).add(e.patch),n.applyPatch(t,e.patch,[r,s])?(jt(this,ht,a),Nt(this,$t,Qm).call(this,r,s),!0):(I(this,El).delete(e.patch),Nt(this,$t,Bl).call(this,t,{...e,reason:"reducer_rejected",fromChecksum:I(this,ht)}),!1))},"#applyPatch"),Rb=sr(function(t,e,r){for(let i=0,a=I(this,Hr).length;i<a;i++){const c=I(this,Ma)[i],h=I(this,Hr)[i],u=e.state[c];I(this,cd).add(u),h.applySnapshot(t,u)}jt(this,ht,e.headChecksum);const[s,n]=r??Ju(t,e,I(this,Ns));Nt(this,$t,Zm).call(this,t,e,s,n)},"#applySnapshot"),Bb=sr(function(){for(let t=0;t<I(this,Hr).length;t++){const e=I(this,Hr)[t];e.onPatch((r,s,n)=>{if(I(this,El).has(s))return;const i=Xu(n);jt(this,ht,zh(i,I(this,ht)));const[a,c]=qm(r,t,I(this,ht),i);Nt(this,$t,eg).call(this,r,a,"local"),r.record.continuumPatchCount(1,"source:local",I(this,nr)),Nt(this,$t,Qm).call(this,a,c)}),e.onSnapshot((r,s)=>{if(I(this,cd).has(s))return;const n=this.exportSnapshot(),i=I(this,Ns).encode(n.state);jt(this,ht,zh(i,Uc)),n.headChecksum=I(this,ht);const[a,c]=Ju(r,n,I(this,Ns));r.record.continuumSnapshotCount(1,"source:local",I(this,nr)),Nt(this,$t,Zm).call(this,r,n,a,c)})}},"#subscribeToLocalUpdates"),Qm=sr(function(t,e){for(const r of I(this,Ml))r(t,e)},"#emitPatch"),Zm=sr(function(t,e,r,s){for(const n of I(this,Tl))n(t,e,r,s)},"#emitSnapshot"),Bl=sr(function(t,e){t.record.continuumDesyncCount(1,`reason:${e.reason}`,I(this,nr));for(const r of I(this,Rl))r(e)},"#emitDesync"),eg=sr(function(t,e,r){let s;xm(e)?s=`type:batch source:${r}`:Wm(e)?s=`type:snapshot source:${r}`:s=`type:patch source:${r}`,t.record.continuumPayloadCount(1,s,I(this,nr)),t.record.continuumPayloadBytes(e.length,s,I(this,nr))},"#recordPayload"),sr(qb,"ContinuumSignal");let RE=qb;var BE=Object.defineProperty,Pb=o(t=>{throw TypeError(t)},"B$6"),yn=o((t,e)=>BE(t,"name",{value:e,configurable:!0}),"m$d"),tg=o((t,e,r)=>e.has(t)||Pb("Cannot "+r),"k$6"),H=o((t,e,r)=>(tg(t,e,"read from private field"),r?r.call(t):e.get(t)),"n$e"),Ls=o((t,e,r)=>e.has(t)?Pb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"d$a"),Kr=o((t,e,r,s)=>(tg(t,e,"write to private field"),e.set(t,r),r),"l$g"),di=o((t,e,r)=>(tg(t,e,"access private method"),r),"_$8"),Lt,ld,Fs,kt,hd,ud,bn,$n,zs,rg,xb,Wb,sg,Ub;const ng=Symbol("ABORT_SENTINEL");function Db(t){return t instanceof Error?t.message.includes("called before connection established")||t.message.includes("no client available after reconnect")||t.message.includes("socket failed unexpectedly")||t.message.includes("socket closed unexpectedly")||t.message.includes("socket did not open correctly"):!1}o(Db,"J$3"),yn(Db,"isRecoverableConnectionError");const Ob=(zo=class{constructor(e,r,s,n,i){Ls(this,zs),Ls(this,Lt),Ls(this,ld),Ls(this,Fs),Ls(this,kt),Ls(this,hd),Ls(this,ud),Ls(this,bn,null),Ls(this,$n,null),Kr(this,Lt,r.hydrate(e,n,"untrusted",i==null?void 0:i.headChecksum)),H(this,Lt).onDesync(a=>{e.log.info("continuum_desync",{err:a,signal:H(this,Lt).name})}),Kr(this,ld,s),Kr(this,kt,{"continuum.signal":H(this,Lt).name}),Kr(this,Fs,new Ih((i==null?void 0:i.circuitBreaker)??{})),Kr(this,hd,(i==null?void 0:i.shouldReconnect)??(()=>!0)),Kr(this,ud,(i==null?void 0:i.distributedTracing)??!0)}get signal(){return H(this,Lt)}get headChecksum(){return H(this,Lt).headChecksum}get connected(){return H(this,$n)!=null||H(this,bn)!=null}connect(e,r,s){if(H(this,bn)||H(this,$n))throw new Error("[ContinuumSubscriber] Already connected");if(r===void 0&&H(this,Lt).paramsSchema!==void 0)throw new Error("[ContinuumSubscriber] Missing params for signal");const n=new AbortController;Kr(this,$n,n),e.record.continuumSubscriptionEventCount(1,"event:connect",H(this,kt)),Kr(this,bn,(H(this,ud)?e.runSpan({kind:"INTERNAL"},{event:"continuum_subscription"},i=>di(this,zs,rg).call(this,i,n.signal,r,s)):di(this,zs,rg).call(this,e,n.signal,r,s)).finally(()=>{Kr(this,$n,null),Kr(this,bn,null)})),H(this,bn).catch(i=>{n.signal.aborted||Ir(i)||i===Fc||e.log.error("continuum_subscription_uncaught",{...H(this,kt),err:i})})}async applyInitialStream(e,r){const s=new AbortController;try{e.trace.addEvent("initial_stream_start"),await di(this,zs,sg).call(this,e,s.signal,r),s.signal.aborted||(e.trace.addEvent("initial_stream_ended"),e.record.continuumSubscriptionEventCount(1,"event:initial_stream_end",H(this,kt)))}catch(n){if(s.signal.aborted)return;e.trace.addEvent("initial_stream_error",{err:String(n)}),e.record.continuumSubscriptionEventCount(1,"event:initial_stream_error",H(this,kt))}H(this,Fs).reset()}async disconnect(){const e=H(this,$n),r=H(this,bn);Kr(this,$n,null),e==null||e.abort(),await(r==null?void 0:r.catch(()=>{}))}},o(zo,"D"),zo);Lt=new WeakMap,ld=new WeakMap,Fs=new WeakMap,kt=new WeakMap,hd=new WeakMap,ud=new WeakMap,bn=new WeakMap,$n=new WeakMap,zs=new WeakSet,rg=yn(async function(t,e,r,s){if(!e.aborted&&(s&&await this.applyInitialStream(t,s),!e.aborted))do{if(!H(this,Fs).check()){await di(this,zs,xb).call(this,t);continue}try{await di(this,zs,Wb).call(this,t,e,r)}catch(n){if(e.aborted)break;await di(this,zs,Ub).call(this,t,n)}}while(!e.aborted&&H(this,hd).call(this))},"#subscriptionLoop"),xb=yn(async function(t){t.trace.addEvent("circuit_open",{attempt_count:H(this,Fs).getAttemptCount()}),t.record.continuumSubscriptionEventCount(1,"event:circuit_open",H(this,kt));const e=y();await pc(1e3),t.record.continuumSubscriptionReconnectDelayMs(y()-e,H(this,kt))},"#handleCircuitOpen"),Wb=yn(async function(t,e,r){t.trace.addEvent("stream.connecting",{checksum:H(this,Lt).headChecksum});const s=r?{fromChecksum:H(this,Lt).headChecksum,params:r}:{fromChecksum:H(this,Lt).headChecksum},n=await H(this,ld).dispatch(H(this,Lt),t,s),i=await di(this,zs,sg).call(this,t,e,n);e.aborted||(t.trace.addEvent("stream.ended",{reason:i}),t.record.continuumSubscriptionEventCount(1,"event:stream_end",H(this,kt))),i==="desync"||i==="continuation_incomplete"?await H(this,Fs).recordFailure():H(this,Fs).recordSuccess()},"#fetchStream"),sg=yn(async function(t,e,r){var s,n,i;const a=r[Symbol.asyncIterator]();let c="";if(e.aborted)return(s=a.return)==null||s.call(a,void 0),"aborted";const h=Ye(),u=yn(()=>h.__resolve(ng),"abortHandler");e.addEventListener("abort",u,{once:!0});try{for(;;){const d=await Promise.race([a.next(),h]);if(d===ng||d.done)return c.length>0?(t.trace.addEvent("payload_continuation_incomplete",{partial_length:c.length}),"continuation_incomplete"):d===ng?"aborted":"upstream_ended";if(Xy(d.value)){t.record.continuumSubscriptionEventCount(1,"event:continuation_frame",H(this,kt)),c+=d.value.slice(1);continue}const p=c?c+d.value:d.value;if(c="",!await H(this,Lt).handlePayload(t,p))return t.trace.addEvent("desync_detected"),t.record.continuumSubscriptionEventCount(1,"event:desync",H(this,kt)),"desync"}}finally{e.removeEventListener("abort",u),e.aborted?(n=a.return)==null||n.call(a,null).catch(()=>{}):await((i=a.return)==null?void 0:i.call(a,null))}},"#consumeStream"),Ub=yn(async function(t,e){if(e===Fc)return;Db(e)?t.log.warn("subscriber_connection_recovering",{...H(this,kt),err:e}):t.log.error("subscriber_connection_error",{...H(this,kt),err:e}),t.record.continuumSubscriptionEventCount(1,"event:error",H(this,kt));const r=y();await H(this,Fs).recordFailure();const s=y()-r;s>0&&t.record.continuumSubscriptionReconnectDelayMs(s,H(this,kt))},"#handleConnectionError"),yn(Ob,"ContinuumSubscriber");let IE=Ob;var qE=Object.defineProperty,PE=o((t,e)=>qE(t,"name",{value:e,configurable:!0}),"c$k");const Gr=l.shape({"continuum.signal":l.str});function jb(){return{continuumPayloadCount:new Z(["type:patch source:local","type:patch source:remote","type:snapshot source:local","type:snapshot source:remote","type:batch source:local","type:batch source:remote"],Gr),continuumPayloadBytes:new jr(["type:patch source:local","type:patch source:remote","type:snapshot source:local","type:snapshot source:remote","type:batch source:local","type:batch source:remote"],Gr),continuumBatchSize:new jr(null,Gr),continuumPatchCount:new Z(["source:local","source:remote"],Gr),continuumSnapshotCount:new Z(["source:local","source:remote"],Gr),continuumDesyncCount:new Z(["reason:checksum_mismatch","reason:reducer_rejected","reason:invalid_continuum","reason:decode_error"],Gr),continuumPatchAppliedCount:new Z(null,l.shape({patch:l.str})),continuumPatchRejectedCount:new Z(null,l.shape({patch:l.str,reason:l.str})),continuumSubscriptionEventCount:new Z(["event:connect","event:transport_disconnected","event:stream_end","event:desync","event:error","event:circuit_open","event:continuation_frame","event:initial_stream_end","event:initial_stream_error"],Gr),continuumSubscriptionReconnectDelayMs:new jr(null,Gr),continuumBroadcasterSubscriptionCount:new Sy(null,Gr),continuumBroadcasterSubscribeResultCount:new Z(["result:hit","result:miss"],Gr),continuumBroadcasterSubscribePayloadBytes:new jr(null,Gr)}}o(jb,"i$a"),PE(jb,"makeContinuumInstruments");var xE=Object.defineProperty,Nb=o(t=>{throw TypeError(t)},"p$b"),ig=o((t,e)=>xE(t,"name",{value:e,configurable:!0}),"c$j"),ag=o((t,e,r)=>e.has(t)||Nb("Cannot "+r),"l$f"),De=o((t,e,r)=>(ag(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$6"),Il=o((t,e,r)=>e.has(t)?Nb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"o$9"),kn=o((t,e,r,s)=>(ag(t,e,"write to private field"),e.set(t,r),r),"n$d"),Lb=o((t,e,r)=>(ag(t,e,"access private method"),r),"v$7"),fi,pi,Ta,st,dd,Fb,zb;const Hb=(Ho=class{constructor(e,r=()=>!1){Il(this,dd),Il(this,fi),Il(this,pi),Il(this,Ta),Il(this,st),kn(this,fi,e),kn(this,pi,r)}getCurrent(e){const r=Lb(this,dd,Fb).call(this,e),s=this.getMinimum();if(!r&&s)return{height:s.height,digest:void 0,expiresAt:s.expiresAt};if(r)return s&&Wn(s.height,r.height)?{height:s.height,digest:void 0,expiresAt:s.expiresAt}:r}getPendingTransition(){const e=De(this,fi).getPendingTransition(),r=this.getMinimum();if(e&&!(r&&!Wn(e.context.height,r.height)))return e}getMinimum(){if(De(this,Ta)&&!De(this,pi).call(this,De(this,Ta).expiresAt))return De(this,Ta)}getDebugState(){var e,r,s;return{has_last_current:!!De(this,st),last_current_height:(e=De(this,st))==null?void 0:e.height,last_current_digest:(r=De(this,st))==null?void 0:r.digest,last_current_expires_at:(s=De(this,st))==null?void 0:s.expiresAt,last_current_expired:De(this,st)?De(this,pi).call(this,De(this,st).expiresAt):void 0}}hasLiveCurrent(){const e=De(this,fi).getCurrent();return e?(kn(this,st,e),!0):!1}setMinimum(e,r){const s=this.getMinimum();s&&lw(e,s.height)||kn(this,Ta,{height:e,expiresAt:r})}waitForCurrent(e){return It(De(this,fi).waitForCurrent(e),r=>Lb(this,dd,zb).call(this,r))}},o(Ho,"a"),Ho);fi=new WeakMap,pi=new WeakMap,Ta=new WeakMap,st=new WeakMap,dd=new WeakSet,Fb=ig(function(t){const e=De(this,fi).getCurrent();if(e)return kn(this,st,e),e;if(De(this,st)){if(De(this,pi).call(this,De(this,st).expiresAt)&&(t==null?void 0:t.allowExpiredRetained)!==!0){kn(this,st,void 0);return}return De(this,st)}},"#getCurrentOrRetained"),zb=ig(function(t){t?kn(this,st,t):(t=De(this,st)&&!De(this,pi).call(this,De(this,st).expiresAt)?De(this,st):void 0,t||kn(this,st,void 0));const e=this.getMinimum();return t?e&&Wn(e.height,t.height)?{height:e.height,digest:void 0,expiresAt:e.expiresAt}:t:e?{height:e.height,digest:void 0,expiresAt:e.expiresAt}:void 0},"#applyMinimumToSnapshot"),ig(Hb,"BlockManager");let WE=Hb;var UE=Object.defineProperty,Kb=o(t=>{throw TypeError(t)},"O$6"),fd=o((t,e)=>UE(t,"name",{value:e,configurable:!0}),"S$6"),og=o((t,e,r)=>e.has(t)||Kb("Cannot "+r),"U$3"),N=o((t,e,r)=>(og(t,e,"read from private field"),e.get(t)),"i$9"),ir=o((t,e,r)=>e.has(t)?Kb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"l$e"),Hs=o((t,e,r,s)=>(og(t,e,"write to private field"),e.set(t,r),r),"c$i"),ql=o((t,e,r)=>(og(t,e,"access private method"),r),"R$5"),Pl,Cn,xl,Wl,Ul,Ra,Ba,Dl,Ia,Vr,Yr,qa,mi,cg,lg,Gb;const DE=2e3,OE=1e4,jE=1e4,Vb=(Ko=class{constructor(e,r={}){ir(this,mi),ir(this,Pl),ir(this,Cn,!1),ir(this,xl),ir(this,Wl),ir(this,Ul),ir(this,Ra),ir(this,Ba),ir(this,Dl),ir(this,Ia,new vc(25e3)),ir(this,Vr,new Map),ir(this,Yr,new Map),ir(this,qa),Hs(this,Pl,e),Hs(this,xl,r.inflightRequestSoftTimeoutMs??DE),Hs(this,Wl,r.inflightRequestHardTimeoutMs??OE),Hs(this,Ul,r.inflightResponseTimeoutMs??jE),Hs(this,qa,new av(5*1024*1024)),Hs(this,Dl,r.disableLocalMemoryCache??!1),Hs(this,Ra,r.cacheContinuum),Hs(this,Ba,r.fingerprintResolver)}getFromMemory(e,r,s,n){if(!Ef(e)||!Rr(e))return;const i=this.getFromLocalMemory(e);if(i)return i;if(!(!N(this,Ra)||!N(this,Ba)||!r||!s))return ql(this,mi,cg).call(this,e,r,s,n)}getFromLocalMemory(e){if(N(this,Dl)||!Rr(e))return;const r=N(this,Ia).get(e);if(!(r==null||N(this,Pl).isPast(r.expiresAt)))return N(this,qa).get(r.responseKey)}getFromContinuum(e,r,s,n){if(!(!N(this,Ra)||!N(this,Ba)))return ql(this,mi,cg).call(this,e,r,s,n)}getInflight(e){if(!(N(this,Cn)||!Rr(e)||ql(this,mi,lg).call(this,e)===void 0))return ql(this,mi,Gb).call(this,e)}mapRequestToResponse(e,r,s){N(this,Cn)||N(this,Ia).set(e,{responseKey:r,expiresAt:s})}registerInflightRequest(e,r){if(N(this,Cn)||!ch(e))return;let s=N(this,Vr).get(e);if(s){const{deferred:i}=s;s.softExpiresAt=y(+N(this,xl)),clearTimeout(s.hardTimer),s.hardTimer=setTimeout(()=>{i.__isFulfilled()||i.__resolve(void 0),N(this,Vr).delete(e)},N(this,Wl))}else{const i=Ye(),a=y(+N(this,xl)),c=setTimeout(()=>{i.__isFulfilled()||i.__resolve(void 0),N(this,Vr).delete(e)},N(this,Wl));s={deferred:i,softExpiresAt:a,hardTimer:c},N(this,Vr).set(e,s);const h=s;i.finally(()=>{clearTimeout(c),N(this,Vr).get(e)===h&&N(this,Vr).delete(e)}).catch(()=>{})}const{deferred:n}=s;r.then(i=>{n.__isFulfilled()||n.__resolve(i)},i=>{n.__isFulfilled()||n.__reject(i)})}registerInflightResponse(e,r){if(N(this,Cn))return;let s=N(this,Yr).get(e);if(s){const{deferred:i}=s;clearTimeout(s.cleanupTimer),s.cleanupTimer=setTimeout(()=>{i.__isFulfilled()||i.__resolve(void 0),N(this,Yr).delete(e)},N(this,Ul))}else{const i=Ye(),a=setTimeout(()=>{i.__isFulfilled()||i.__resolve(void 0),N(this,Yr).delete(e)},N(this,Ul));s={deferred:i,cleanupTimer:a},N(this,Yr).set(e,s);const c=s;i.finally(()=>{clearTimeout(a),N(this,Yr).get(e)===c&&N(this,Yr).delete(e)}).catch(()=>{})}const{deferred:n}=s;r.then(i=>{n.__isFulfilled()||n.__resolve(i)},i=>{n.__isFulfilled()||n.__reject(i)})}handleResponse(e,r,s){if(N(this,Cn))return;const n=Bf(r,s??"other");return!N(this,Dl)&&If(n)&&(N(this,qa).set(n,r,Oi(r)),Rr(e)&&r.expiresAt&&this.mapRequestToResponse(e,n,r.expiresAt)),n}destroy(){Hs(this,Cn,!0);for(const e of N(this,Vr).values())clearTimeout(e.hardTimer);for(const e of N(this,Yr).values())clearTimeout(e.cleanupTimer);N(this,Ia).clear(),N(this,Vr).clear(),N(this,Yr).clear(),N(this,qa).clear()}},o(Ko,"b"),Ko);Pl=new WeakMap,Cn=new WeakMap,xl=new WeakMap,Wl=new WeakMap,Ul=new WeakMap,Ra=new WeakMap,Ba=new WeakMap,Dl=new WeakMap,Ia=new WeakMap,Vr=new WeakMap,Yr=new WeakMap,qa=new WeakMap,mi=new WeakSet,cg=fd(function(t,e,r,s){const n=lh(t),i=N(this,Ba).resolve(n,e,r,s);return It(i,a=>{if(!a)return;const c=Tf(t),h=Ht(a,c);if(!Rr(h))return;const u=N(this,Ra).readFromCache(h);return It(u,d=>{if(d)return hl.decodeUntrusted(d.response)})})},"#getFromContinuum"),lg=fd(function(t){const e=y(),r=N(this,Vr).get(t);if(r&&r.softExpiresAt>e)return r.deferred;const s=N(this,Ia).get(t);if(s&&!N(this,Pl).isPast(s.expiresAt)){const n=N(this,Yr).get(s.responseKey);if(n)return n.deferred}},"#getInflightEntry"),Gb=fd(async function(t){for(;;){const e=ql(this,mi,lg).call(this,t);if(e===void 0)return;const r=await e;if(r!==void 0)return r}},"#awaitInflight"),fd(Vb,"CacheLayer");let NE=Vb;var LE=Object.defineProperty,Yb=o(t=>{throw TypeError(t)},"m$a"),hg=o((t,e)=>LE(t,"name",{value:e,configurable:!0}),"p$a"),Jb=o((t,e,r)=>e.has(t)||Yb("Cannot "+r),"u$b"),gi=o((t,e,r)=>(Jb(t,e,"read from private field"),r?r.call(t):e.get(t)),"h$9"),Xb=o((t,e,r)=>e.has(t)?Yb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"a$b"),pd=o((t,e,r)=>(Jb(t,e,"access private method"),r),"n$c"),Ks,Pa,md,Qb;const Zb=(Go=class{constructor(e){Xb(this,Pa),Xb(this,Ks,new Map);for(const r of e.iterate())pd(this,Pa,md).call(this,r);e.onAdded(r=>{for(const s of r)pd(this,Pa,md).call(this,s)}),e.onRemoved(r=>{for(const s of r)pd(this,Pa,Qb).call(this,s)}),e.onReplacement(r=>{gi(this,Ks).clear();for(const s of r)pd(this,Pa,md).call(this,s)})}resolve(e,r,s,n){const i=gi(this,Ks).get(e);if(!(!i||i.length===0))return i.length===1?i[0]:qw(r,s,n)}hasFingerprint(e){const r=gi(this,Ks).get(e);return!!r&&r.length>0}},o(Go,"g"),Go);Ks=new WeakMap,Pa=new WeakSet,md=hg(function(t){const e=Af(t),r=gi(this,Ks).get(e);r?r.push(t):gi(this,Ks).set(e,[t])},"#addFingerprint"),Qb=hg(function(t){const e=Af(t),r=gi(this,Ks).get(e);if(r){const s=r.indexOf(t);s>=0&&r.splice(s,1),r.length===0&&gi(this,Ks).delete(e)}},"#removeFingerprint"),hg(Zb,"FingerprintResolver");let e$=Zb;var FE=Object.defineProperty,xa=o((t,e)=>FE(t,"name",{value:e,configurable:!0}),"r$a");function ug(t){return(t==null?void 0:t.client)??"warn"}o(ug,"a$a"),xa(ug,"getClientLogLevel");function dg(t){return(t==null?void 0:t.requests)??"off"}o(dg,"c$g"),xa(dg,"getRequestLogging");function t$(t){switch(t){case"fatal":return"error";case"verbose":return"debug";case"debug":case"info":case"warn":case"error":return t;default:return"info"}}o(t$,"f$9"),xa(t$,"normalizeClientLogEventLevel");function r$(t){return t.name==="request_resolution"||t.name==="request_pipeline_resolution"?t.level==="debug"?"[direct:REQUEST_DEBUG]":"[direct:REQUEST]":t.name==="request_handled"?"[direct:REQUEST_DEBUG]":`[direct:${t.level.toUpperCase()}]`}o(r$,"d$7"),xa(r$,"getConsolePrefix");function s$(t){console[t.level](r$(t),t.name,t.value)}o(s$,"t$4"),xa(s$,"defaultLogEventListener");function Wa(t,e,r,s,n=y()){(t??s$)({level:e,name:r,value:s,timestamp:n})}o(Wa,"E$9"),xa(Wa,"emitLogEvent");var zE=Object.defineProperty,n$=o(t=>{throw TypeError(t)},"c$f"),HE=o((t,e)=>zE(t,"name",{value:e,configurable:!0}),"m$9"),i$=o((t,e,r)=>e.has(t)||n$("Cannot "+r),"a$9"),KE=o((t,e,r)=>(i$(t,e,"read from private field"),r?r.call(t):e.get(t)),"l$b"),GE=o((t,e,r)=>e.has(t)?n$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"v$5"),VE=o((t,e,r,s)=>(i$(t,e,"write to private field"),e.set(t,r),r),"u$a"),gd;const a$=(Vo=class extends $A{constructor(e={}){super(),GE(this,gd),VE(this,gd,e.onEvent)}log(e,r,s,n,i,a){const c={...a,...i};Wa(KE(this,gd),t$(e),s,c,r)}trace(){}metrics(){}async flush(){}},o(Vo,"i"),Vo);gd=new WeakMap,HE(a$,"ConsoleExporter");let o$=a$;var YE=Object.defineProperty,c$=o(t=>{throw TypeError(t)},"L$5"),l$=o((t,e)=>YE(t,"name",{value:e,configurable:!0}),"k$4"),fg=o((t,e,r)=>e.has(t)||c$("Cannot "+r),"B$5"),re=o((t,e,r)=>(fg(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$5"),Gs=o((t,e,r)=>e.has(t)?c$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"n$b"),Sn=o((t,e,r,s)=>(fg(t,e,"write to private field"),e.set(t,r),r),"l$a"),h$=o((t,e,r)=>(fg(t,e,"access private method"),r),"E$7"),u$=o((t,e,r,s)=>({set _(n){Sn(t,e,n)},get _(){return re(t,e,s)}}),"y$5"),fs,wi,vi,_i,Vs,yi,bi,wd,vd,pg;const d$=(Yo=class{constructor(e){Gs(this,vd),Gs(this,fs),Gs(this,wi,new Map),Gs(this,vi,new Map),Gs(this,_i,{upload:0,download:0}),Gs(this,Vs,{}),Gs(this,yi,0),Gs(this,bi),Gs(this,wd),Sn(this,fs,{networkId:e.networkId,softEntryLimit:e.softEntryLimit??100,softFlushIntervalMs:e.softFlushIntervalMs??2e3,hardFlushIntervalMs:e.hardFlushIntervalMs??6e4,onFlush:e.onFlush??(()=>{}),onBandwidthEstimate:e.onBandwidthEstimate??(()=>{})})}get entryCount(){return re(this,yi)}hasData(){return re(this,wi).size>0||re(this,vi).size>0||re(this,_i).upload>0||re(this,_i).download>0||Object.keys(re(this,Vs)).length>0}isSoftLimitReached(){return re(this,yi)>=re(this,fs).softEntryLimit||re(this,bi)!==void 0&&y()-re(this,bi)>=re(this,fs).softFlushIntervalMs}collectCacheHit(e,r){var s,n;h$(this,vd,pg).call(this);let i=re(this,wi).get(e);i||(i=new Map,re(this,wi).set(e,i));let a=i.get(r.requestId);a||(a={requestMethod:r.requestMethod,requestId:r.requestId,requestSizeInBytes:r.requestSizeInBytes,perBlockMetrics:{}},i.set(r.requestId,a));const c=((s=r.blockContext)==null?void 0:s.digest)||"__unknown__";let h=a.perBlockMetrics[c];h||(h={blockHeight:(n=r.blockContext)==null?void 0:n.height,responseSizeInBytes:r.responseSizeInBytes,responseKey:r.responseKey,timestamp:y(),latencyMs:[]},a.perBlockMetrics[c]=h),h.latencyMs.push(r.latencyMs),u$(this,yi)._++}collectUpstreamLatency(e,r){h$(this,vd,pg).call(this);let s=re(this,vi).get(e);s||(s=[],re(this,vi).set(e,s)),s.push(r),u$(this,yi)._++}collectBandwidthEstimateHeaders(e,r){r<=0||(re(this,_i)[e]+=r,re(this,fs).onBandwidthEstimate({type:"headers",direction:e,bytes:r}))}collectBandwidthEstimatePayload(e,r,s,n){n<=0||(re(this,Vs)[e]??={},re(this,Vs)[e][r]??={},re(this,Vs)[e][r][s]??=0,re(this,Vs)[e][r][s]+=n,re(this,fs).onBandwidthEstimate({type:"payload",target:e,stage:r,direction:s,bytes:n}))}maybeConsume(){if(this.isSoftLimitReached())return this.consume()}consume(){if(!this.hasData())return;clearTimeout(re(this,wd));const e={};for(const[n,i]of re(this,wi))e[n]=Array.from(i.values());const r={};for(const[n,i]of re(this,vi))r[n]=i;const s={networkId:re(this,fs).networkId,cacheHits:e,upstreamResponseTimesMs:r,bandwidthEstimate:{headers:re(this,_i),payload:re(this,Vs)}};return re(this,wi).clear(),re(this,vi).clear(),Sn(this,_i,{upload:0,download:0}),Sn(this,Vs,{}),Sn(this,yi,0),Sn(this,bi,void 0),s}},o(Yo,"z"),Yo);fs=new WeakMap,wi=new WeakMap,vi=new WeakMap,_i=new WeakMap,Vs=new WeakMap,yi=new WeakMap,bi=new WeakMap,wd=new WeakMap,vd=new WeakSet,pg=l$(function(){re(this,bi)===void 0&&(Sn(this,bi,y()),Sn(this,wd,setTimeout(()=>{const t=this.consume();t&&re(this,fs).onFlush(t)},re(this,fs).hardFlushIntervalMs)))},"#openWindow"),l$(d$,"TelemetryCollector");let JE=d$;const XE="https://rpc.direkt.dev",QE={ethereum:["https://eth.drpc.org","https://ethereum-rpc.publicnode.com","https://mainnet.gateway.tenderly.co","https://eth.api.pocket.network","https://eth.llamarpc.com/"],"ethereum-holesky":["https://ethereum-holesky-rpc.publicnode.com"],"ethereum-sepolia":["https://sepolia.drpc.org"],sonic:["https://rpc.soniclabs.com","https://sonic.drpc.org","https://sonic.api.pocket.network","https://sonic-rpc.publicnode.com"],"sonic-testnet":["https://rpc.testnet.soniclabs.com"],"sonic-blaze-testnet":["https://rpc.blaze.soniclabs.com"]},ZE=.07,e1=600,t1=300;var r1=Object.defineProperty,_d=o((t,e)=>r1(t,"name",{value:e,configurable:!0}),"s$a");function f$(t){const e={method:t.method,latency_ms:t.latency_ms};return t.resolution_source&&!(t.resolution_source==="pipeline"&&t.stage_name)&&(e.resolution_source=t.resolution_source),t.stage_name&&(e.stage_name=t.stage_name),t.stage_type&&(e.stage_type=t.stage_type),e}o(f$,"o$7"),_d(f$,"compactSummaryPayload");function p$(t,e,r){t==="debug"&&Wa(r,"debug","request_pipeline_resolution",e)}o(p$,"r$7"),_d(p$,"logRequestPipelineResolution");function m$(t,e,r){t==="summary"?Wa(r,"info","request_resolution",f$(e)):t==="debug"&&Wa(r,"debug","request_resolution",e)}o(m$,"g$5"),_d(m$,"logRequestResolution");function g$(t,e,r){Wa(r,"debug",t,e)}o(g$,"m$7"),_d(g$,"logRequestDebug");var w$=Object.defineProperty,v$=o(t=>{throw TypeError(t)},"k$3"),s1=o((t,e,r)=>e in t?w$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"y$4"),Ol=o((t,e)=>w$(t,"name",{value:e,configurable:!0}),"a$7"),Ua=o((t,e,r)=>s1(t,typeof e!="symbol"?e+"":e,r),"s$9"),n1=o((t,e,r)=>e.has(t)||v$("Cannot "+r),"m$6"),i1=o((t,e,r)=>e.has(t)?v$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"f$7"),_$=o((t,e,r)=>(n1(t,e,"access private method"),r),"d$6"),yd,y$,b$;const $$=(Jo=class{constructor(){i1(this,yd),Ua(this,"name","block_state_cache"),Ua(this,"type","cache"),Ua(this,"origin","client"),Ua(this,"strategy","first_eligible"),Ua(this,"failover"),Ua(this,"handlers");const e=this;this.handlers=[new sn({name:"block_state_cache",circuitBreaker:!1,claim:Ol((r,s)=>r.map(n=>{var i;return _$(i=e,yd,b$).call(i,n,s)}),"claim"),fulfill:Ol(r=>r.map(([,s])=>s),"fulfill")})]}},o(Jo,"n"),Jo);yd=new WeakSet,y$=Ol(function(t){return!t.block||!t.secondaryBlock?t.block??t.secondaryBlock:Wn(t.secondaryBlock.height,t.block.height)?t.secondaryBlock:t.block},"#getBestBlock"),b$=Ol(function(t,e){const r=t.input.requestBody.id;if(r===void 0||t.input.requestMethod!=="eth_blockNumber")return;const s=t.input.requestBody.params;if(Array.isArray(s)&&s.length>0)return;const n=_$(this,yd,y$).call(this,e);if(n!=null&&n.height)return[{id:r,result:n.height},{}]},"#readFromBlockState"),Ol($$,"ClientBlockStateCacheStage");let a1=$$;var k$=Object.defineProperty,C$=o(t=>{throw TypeError(t)},"g$4"),o1=o((t,e,r)=>e in t?k$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"I$8"),bd=o((t,e)=>k$(t,"name",{value:e,configurable:!0}),"c$b"),Da=o((t,e,r)=>o1(t,typeof e!="symbol"?e+"":e,r),"s$8"),mg=o((t,e,r)=>e.has(t)||C$("Cannot "+r),"l$9"),S$=o((t,e,r)=>(mg(t,e,"read from private field"),r?r.call(t):e.get(t)),"o$6"),A$=o((t,e,r)=>e.has(t)?C$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"a$6"),c1=o((t,e,r,s)=>(mg(t,e,"write to private field"),e.set(t,r),r),"v$4"),l1=o((t,e,r)=>(mg(t,e,"access private method"),r),"m$5"),jl,gg,E$;const M$=(Xo=class{constructor(e){A$(this,gg),Da(this,"name","inflight_cache"),Da(this,"type","cache"),Da(this,"origin","client"),Da(this,"strategy","first_eligible"),Da(this,"failover",{}),Da(this,"handlers"),A$(this,jl),c1(this,jl,e);const r=this;this.handlers=[new sn({name:"inflight_cache",circuitBreaker:!1,racing:{timeoutMs:1500},claim:bd(s=>s.map(n=>{var i;return l1(i=r,gg,E$).call(i,n)}),"claim"),fulfill:bd(s=>s.map(([,n])=>n),"fulfill")})]}},o(Xo,"h"),Xo);jl=new WeakMap,gg=new WeakSet,E$=bd(function(t){const e=t.input.requestBody.id;if(e===void 0)return;const r=S$(this,jl).getInflight(t.input.requestId);if(r)return r.then(s=>s?[{...s,id:e},{}]:void 0);Rr(t.input.requestId)&&S$(this,jl).registerInflightRequest(t.input.requestId,t.deferred)},"#deduplicateRequest"),bd(M$,"ClientInflightCacheStage");let h1=M$;var T$=Object.defineProperty,R$=o(t=>{throw TypeError(t)},"H$1"),u1=o((t,e,r)=>e in t?T$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"L$4"),$i=o((t,e)=>T$(t,"name",{value:e,configurable:!0}),"n$8"),Oa=o((t,e,r)=>u1(t,typeof e!="symbol"?e+"":e,r),"c$a"),wg=o((t,e,r)=>e.has(t)||R$("Cannot "+r),"f$5"),vg=o((t,e,r)=>(wg(t,e,"read from private field"),r?r.call(t):e.get(t)),"m$4"),B$=o((t,e,r)=>e.has(t)?R$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"q$4"),d1=o((t,e,r,s)=>(wg(t,e,"write to private field"),e.set(t,r),r),"I$7"),I$=o((t,e,r)=>(wg(t,e,"access private method"),r),"v$3"),ja,$d,q$,P$;const x$=(Qo=class{constructor(e){B$(this,$d),Oa(this,"name","memory_cache"),Oa(this,"type","cache"),Oa(this,"origin","client"),Oa(this,"strategy","first_eligible"),Oa(this,"failover"),Oa(this,"handlers"),B$(this,ja),d1(this,ja,e);const r=this;this.handlers=[new sn({name:"local_memory_cache",circuitBreaker:!1,claim:$i(s=>s.map(n=>{var i;return I$(i=r,$d,q$).call(i,n)}),"claim"),fulfill:$i(s=>s.map(([,n])=>n),"fulfill")}),new sn({name:"continuum_cache",circuitBreaker:!1,claim:$i((s,n)=>s.map(i=>{var a;return I$(a=r,$d,P$).call(a,i,n)}),"claim"),fulfill:$i(s=>s.map(([,n])=>n),"fulfill")})]}},o(Qo,"B"),Qo);ja=new WeakMap,$d=new WeakSet,q$=$i(function(t){const e=t.input.requestBody.id;if(e===void 0)return;const r=vg(this,ja).getFromLocalMemory(t.input.requestId);if(r)return[{...r,id:e},{}]},"#readFromLocalMemory"),P$=$i(function(t,e){var r,s;const n=t.input.requestBody.id,i=t.input.requestMethod,a=(r=e.block)==null?void 0:r.height,c=(s=e.secondaryBlock)==null?void 0:s.height;let h=a??c;if(a&&c&&(h=Wn(c,a)?c:a),n===void 0)return;const u=vg(this,ja).getFromContinuum(t.input.requestId,t.input.requestBody,i,h);return It(u,d=>{if(d)return[{...d,id:n},{}];t.deferred.then(p=>{p&&"result"in p&&vg(this,ja).handleResponse(t.input.requestId,p,t.input.requestMethod)})})},"#readFromContinuum"),$i(x$,"ClientMemoryCacheStage");let f1=x$;const _g=512e3,W$=7168,kd=15,Nl=750,ps=1e4,U$=3e4,yg=3e4;var p1=Object.defineProperty,D$=o(t=>{throw TypeError(t)},"F$3"),wt=o((t,e)=>p1(t,"name",{value:e,configurable:!0}),"n$7"),bg=o((t,e,r)=>e.has(t)||D$("Cannot "+r),"q$3"),Q=o((t,e,r)=>(bg(t,e,"read from private field"),e.get(t)),"r$6"),Jr=o((t,e,r)=>e.has(t)?D$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"c$9"),An=o((t,e,r,s)=>(bg(t,e,"write to private field"),e.set(t,r),r),"g$3"),En=o((t,e,r)=>(bg(t,e,"access private method"),r),"b$3"),Cr,Sr,Cd,Sd,ki,$g,Ad,Na,Mn,Ed,ms,O$,j$,N$,L$,F$,z$,H$,K$;const kg=65535,m1=kg+1,G$=(Zo=class extends sn{constructor(e,r){const s=r.shouldTripBreaker!==void 0;super({name:r.nodeUrl,racing:r.racing,claim:wt((n,i,a)=>En(this,ms,O$).call(this,n,i,a),"claim"),fulfill:wt(n=>En(this,ms,N$).call(this,n),"fulfill"),circuitBreaker:s?!1:r.circuitBreaker}),Jr(this,ms),Jr(this,Cr),Jr(this,Sr),Jr(this,Cd),Jr(this,Sd),Jr(this,ki,new Map),Jr(this,$g,{"Content-Type":"application/json"}),Jr(this,Ad,0),Jr(this,Na),Jr(this,Mn),Jr(this,Ed),s&&(An(this,Mn,new Ih({halfOpenAttempts:3,halfClosedAttempts:8,cooldownMs:3e4})),An(this,Ed,r.shouldTripBreaker)),An(this,Cr,e.with({"component.id":"JsonUpstreamHandler","component.node_url":r.nodeUrl})),An(this,Sr,r.nodeUrl),An(this,Cd,r.fetch??globalThis.fetch.bind(globalThis)),An(this,Na,{origin:"client",handler:"json_upstream",node_url:Q(this,Sr)}),An(this,Sd,new _v({framing:UC,maxSizeInBytes:r.maxSizeInBytes??512e3,windowMs:r.windowMs??15,timeoutMs:r.timeoutMs??1e4},{prepareContext:wt(()=>En(this,ms,F$).call(this),"prepareContext"),openRequest:wt((n,i,a,c)=>En(this,ms,z$).call(this,n,i,c),"openRequest")},{onBatchError:wt((n,i)=>{Q(this,Cr).log.debug("batch_error",{error:i,nodeUrl:Q(this,Sr)})},"onBatchError")}))}getHealth(){var e;return((e=Q(this,Mn))==null?void 0:e.getState())??super.getHealth()}},o(Zo,"D"),Zo);Cr=new WeakMap,Sr=new WeakMap,Cd=new WeakMap,Sd=new WeakMap,ki=new WeakMap,$g=new WeakMap,Ad=new WeakMap,Na=new WeakMap,Mn=new WeakMap,Ed=new WeakMap,ms=new WeakSet,O$=wt(function(t,e,r){return t.map(s=>En(this,ms,j$).call(this,s,r))},"#claim"),j$=wt(function(t,e){Q(this,Cr).log.debug("request_route_probe",{phase:"claimed",handler:"json_upstream",target:Q(this,Sr),method:t.input.requestMethod,request_id:t.input.requestBody.id,request:Td(t.input.requestBody)});const{id:r,deferred:s}=En(this,ms,H$).call(this),n=Q(this,Sd).write(hc.encode(JSON.stringify(En(this,ms,K$).call(this,t.input.requestBody,r))),{},e);if(!n){Q(this,Cr).log.debug("request_route_probe",{phase:"failed",handler:"json_upstream",target:Q(this,Sr),reason:"write_rejected",method:t.input.requestMethod,request_id:t.input.requestBody.id,request:Td(t.input.requestBody)}),s.__resolve(Cs(null,"SERVER_ERROR",Q(this,Na)));return}const[i,a]=n;return a.batch.push(r),a.methods.push(t.input.requestMethod),i.then(()=>[s,{}]).catch(c=>{throw Q(this,Cr).log.debug("request_route_probe",{phase:"failed",handler:"json_upstream",target:Q(this,Sr),reason:"claim_rejected",method:t.input.requestMethod,request_id:t.input.requestBody.id,request:Td(t.input.requestBody),error:String(c)}),s.__isFulfilled()||(s.catch(()=>{}),s.__reject(c)),c})},"#claimItem"),N$=wt(function(t){return t.map(e=>En(this,ms,L$).call(this,e))},"#fulfill"),L$=wt(function([t,e]){const r=t.input.requestBody.id;return r===void 0?Promise.resolve(void 0):e.then(s=>s!==void 0?{...s,id:r}:void 0)},"#fulfillItem"),F$=wt(function(){return{nodeUrl:Q(this,Sr),batch:[],methods:[]}},"#prepareBatchContext"),z$=wt(function(t,e,r){if(r.aborted)throw new Error("JsonUpstreamHandler.#openBatch: Batch aborted before dispatch");return Q(this,Cd).call(this,Q(this,Sr),{method:"POST",headers:Q(this,$g),signal:r,...t}).then(s=>({bodyPromise:s.text().then(n=>{var i;let a;try{a=JSON.parse(n)}catch{const u=n.slice(0,100);throw Q(this,Cr).log.debug("non_json_response",{preview:u}),new Error(`Response is not valid JSON: ${u}`)}const c=Y$(a,e.batch.length);if(c===qc)throw Q(this,Cr).log.debug("invalid_response_data",{error:Dh.lastMessage}),new Error(Dh.lastMessage);const h=new Map;for(const u of c)h.set(u.id,u);for(const u of e.batch){const d=Q(this,ki).get(u);if(d){const p=h.get(u);p?d.__resolve(p):(d.__resolve(Cs(u,"NO_RESPONSE",Q(this,Na))),Q(this,Cr).log.debug("missing_response_data",{request_id:u,response_ids:Array.from(h.keys())}))}}return Q(this,Mn)&&(((i=Q(this,Ed))==null?void 0:i.call(this,s,c))??!1?Q(this,Mn).recordFailure():Q(this,Mn).recordSuccess()),{downloadSizeInBytes:n.length,itemCount:e.batch.length}}).catch(n=>{var i;(i=Q(this,Mn))==null||i.recordFailure(),Q(this,Cr).log.debug("batch_failed",{err:n,nodeUrl:Q(this,Sr),request_methods:e.methods,request_ids:e.batch});for(let c=0;c<e.batch.length;c++)Q(this,Cr).log.debug("request_route_probe",{phase:"failed",handler:"json_upstream",target:Q(this,Sr),reason:"batch_failed",method:e.methods[c],request_id:e.batch[c],error:String(n)});const a=n instanceof Error?n:new Error(String(n));for(const c of e.batch){const h=Q(this,ki).get(c);h&&!h.__isFulfilled()&&(h.catch(()=>{}),h.__reject(a))}return{downloadSizeInBytes:0,itemCount:e.batch.length}})}))},"#openBatch"),H$=wt(function(){let t=Q(this,Ad),e=0;for(;Q(this,ki).has(t);)if(t=t+1&kg,++e>=m1)throw new Error("JsonUpstreamHandler.#openPendingRequest: Deferred ID pool exhausted");An(this,Ad,t+1&kg);const r=Ye(),s=setTimeout(()=>{r.__resolve(Cs(t,"UPSTREAM_TIMEOUT",Q(this,Na)))},8e3),n=wt(()=>{clearTimeout(s),Q(this,ki).delete(t)},"cleanup");return r.then(n,n),Q(this,ki).set(t,r),{id:t,deferred:r}},"#openPendingRequest"),K$=wt(function(t,e){return t.method==="direct_getTransactionReceipt"?{id:e,method:"eth_getTransactionReceipt",params:Array.isArray(t.params)?t.params.slice(0,1):[""],jsonrpc:"2.0"}:{id:e,method:t.method,params:t.params,jsonrpc:"2.0"}},"#normalizeRequest"),wt(G$,"JsonUpstreamHandler");let Md=G$;const V$=ke("response",l.arr(hl)),g1=ke("response",hl);function Y$(t,e){if(Array.isArray(t))return V$.safeParse(t);if(e===1){const r=g1.safeParse(t);return r===qc?qc:[r]}return V$.safeParse(t)}o(Y$,"ne$2"),wt(Y$,"parseResponseData");function Td(t){const e={method:t.method};if(t.method==="eth_getLogs"){const[r]=Array.isArray(t.params)?t.params:[];return r&&typeof r=="object"&&(e.from_block="fromBlock"in r?r.fromBlock:void 0,e.to_block="toBlock"in r?r.toBlock:void 0),e}return t.method==="eth_getBlockByNumber"||t.method==="eth_getBlockByHash"?(e.block_param=Array.isArray(t.params)?t.params[0]:void 0,e.full_transactions=Array.isArray(t.params)?t.params[1]===!0:!1,e):(e.params=t.params,e)}o(Td,"O$4"),wt(Td,"summarizeRequest");var w1=Object.defineProperty,J$=o(t=>{throw TypeError(t)},"j$2"),Tn=o((t,e)=>w1(t,"name",{value:e,configurable:!0}),"k$1"),Cg=o((t,e,r)=>e.has(t)||J$("Cannot "+r),"N$1"),qe=o((t,e,r)=>(Cg(t,e,"read from private field"),r?r.call(t):e.get(t)),"i$6"),Ll=o((t,e,r)=>e.has(t)?J$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"I$5"),Rd=o((t,e,r,s)=>(Cg(t,e,"write to private field"),e.set(t,r),r),"q$2"),La=o((t,e,r)=>(Cg(t,e,"access private method"),r),"S$2"),gs,Fa,ws,vs,Rn,X$,Q$,Bd,Z$;const ek=(ec=class extends sn{constructor(e,r){super({name:"wire_http",racing:{claimMs:Nl,timeoutMs:ps},circuitBreaker:{halfClosedAttempts:1,halfOpenAttempts:1,cooldownMs:U$},claim:Tn((s,n)=>La(this,Rn,X$).call(this,s,n),"claim"),fulfill:Tn(s=>La(this,Rn,Z$).call(this,s),"fulfill")}),Ll(this,Rn),Ll(this,gs),Ll(this,Fa),Ll(this,ws),Ll(this,vs),Rd(this,gs,e.with({"component.id":"WireHTTPUpstreamHandler"})),Rd(this,Fa,r.channel),Rd(this,ws,r.isPrimary),Rd(this,vs,r.isShadow??!1)}},o(ec,"L"),ec);gs=new WeakMap,Fa=new WeakMap,ws=new WeakMap,vs=new WeakMap,Rn=new WeakSet,X$=Tn(function(t,e){if(t.length===0)return[];const r=[],s=[],n=[];for(let a=0;a<t.length;a++){const c=t[a];if(c){if(Un(c.input.requestBody)){qe(this,gs).log.debug("request_route_probe",{phase:"declined",handler:"wire_http",target:qe(this,ws)?"primary":qe(this,vs)?"secondary_shadow":"secondary",reason:"slow_request",method:c.input.requestMethod,request_id:c.input.requestBody.id,request:Fl(c.input.requestBody)});continue}qe(this,gs).log.debug("request_route_probe",{phase:"claimed",handler:"wire_http",target:qe(this,ws)?"primary":qe(this,vs)?"secondary_shadow":"secondary",method:c.input.requestMethod,request_id:c.input.requestBody.id,request:Fl(c.input.requestBody)}),s.push(c),n.push(a)}}if(s.length===0)return r;const i=La(this,Rn,Q$).call(this,s,e);for(let a=0;a<n.length;a++){const c=n[a],h=i[a];c!==void 0&&h!==void 0&&(r[c]=h)}return r},"#claim"),Q$=Tn(function(t,e){var r,s;if(t.length===0)return[];const n=t.map(u=>u.input.requestBody),i=Ye(),a=qe(this,ws)?e.block:e.secondaryBlock??e.block;let c;if(a&&(c=qe(this,ws)?{height:a.height,digest:a.digest}:{height:a.height,expiresAt:a.expiresAt}),!qe(this,ws)&&n.some(Un)){const u=[],d=[],p=[];if(n.forEach((f,g)=>{var m;if(!Un(f)){d.push(f),p.push(g);return}qe(this,gs).log.debug("request_route_probe",{phase:"claimed",handler:"wire_http",target:qe(this,vs)?"secondary_shadow":"secondary",reason:"isolated_slow_request",method:f.method,request_id:f.id,request:Fl(f)});const w=Ye(),_=qe(this,Fa).request.rpc(qe(this,gs),{networkId:e.networkId,requests:[f],shadow:!!qe(this,vs),bypass:e.bypass,routingToken:(m=e.routing)==null?void 0:m.token,block:c},"pipeline",w),[S]=La(this,Rn,Bd).call(this,[f],_);S!==void 0&&(u[g]=w.then(()=>[S,{}]))}),d.length>0){const f=Ye(),g=qe(this,Fa).request.rpc(qe(this,gs),{networkId:e.networkId,requests:d,shadow:!!qe(this,vs),bypass:e.bypass,routingToken:(r=e.routing)==null?void 0:r.token,block:c},"pipeline",f),m=La(this,Rn,Bd).call(this,d,g);for(let w=0;w<p.length;w++){const _=p[w],S=m[w];_!==void 0&&S!==void 0&&(u[_]=f.then(()=>[S,{}]))}}return u}const h=qe(this,Fa).request.rpc(qe(this,gs),{networkId:e.networkId,requests:n,shadow:!!qe(this,vs),bypass:e.bypass,routingToken:qe(this,ws)||(s=e.routing)==null?void 0:s.token,block:c},"pipeline",i);return La(this,Rn,Bd).call(this,n,h).map(u=>i.then(()=>[u,{}]))},"#claimEligible"),Bd=Tn(function(t,e){var r,s;const n=t.map(()=>Ye()),i=new Map;for(let a=0;a<t.length;a++){const c=(r=t[a])==null?void 0:r.id;c===void 0?(s=n[a])==null||s.__resolve(void 0):i.set(c,a)}return(async()=>{var a,c,h,u,d,p,f,g;try{for await(const m of e){const w=i.get(m.id);w!==void 0&&((a=n[w])!=null&&a.__isFulfilled()||(c=n[w])==null||c.__resolve(m),i.delete(m.id))}for(const[m,w]of i)(h=n[w])!=null&&h.__isFulfilled()||(u=n[w])==null||u.__resolve(Cs(m,"NO_RESPONSE",{origin:"client",handler:"wire_http"}))}catch(m){const w=m instanceof Error?m:new Error(String(m));for(const[_,S]of i)qe(this,gs).log.debug("request_route_probe",{phase:"failed",handler:"wire_http",target:qe(this,ws)?"primary":qe(this,vs)?"secondary_shadow":"secondary",reason:"response_stream_error",method:(d=t[S])==null?void 0:d.method,request_id:_,request:t[S]?Fl(t[S]):void 0,error:String(m)}),(p=n[S])!=null&&p.__isFulfilled()||((f=n[S])==null||f.catch(()=>{}),(g=n[S])==null||g.__reject(w))}})(),n},"#createResponsePromises"),Z$=Tn(function(t){return t.map(([,e])=>e)},"#fulfill"),Tn(ek,"WireHTTPUpstreamHandler");let tk=ek;function Fl(t){const e={method:t.method};if(t.method==="eth_getLogs"){const[r]=Array.isArray(t.params)?t.params:[];return r&&typeof r=="object"&&(e.from_block="fromBlock"in r?r.fromBlock:void 0,e.to_block="toBlock"in r?r.toBlock:void 0,e.has_address="address"in r?!!r.address:!1,e.has_topics="topics"in r?!!r.topics:!1),e}return t.method==="eth_getBlockByNumber"||t.method==="eth_getBlockByHash"?(e.block_param=Array.isArray(t.params)?t.params[0]:void 0,e.full_transactions=Array.isArray(t.params)?t.params[1]===!0:!1,e):(e.params=t.params,e)}o(Fl,"O$3"),Tn(Fl,"summarizeRequest");var v1=Object.defineProperty,rk=o(t=>{throw TypeError(t)},"O$2"),Ys=o((t,e)=>v1(t,"name",{value:e,configurable:!0}),"a$4"),Sg=o((t,e,r)=>e.has(t)||rk("Cannot "+r),"B$2"),Bn=o((t,e,r)=>(Sg(t,e,"read from private field"),r?r.call(t):e.get(t)),"d$4"),Ag=o((t,e,r)=>e.has(t)?rk("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"b$2"),sk=o((t,e,r,s)=>(Sg(t,e,"write to private field"),e.set(t,r),r),"R$3"),Ci=o((t,e,r)=>(Sg(t,e,"access private method"),r),"c$8"),In,za,Js,nk,ik,ak,zl;const ok=(tc=class extends sn{constructor(e,r){super({name:"wire_socket",racing:{checkMs:100,timeoutMs:ps},circuitBreaker:{halfClosedAttempts:1,halfOpenAttempts:1,cooldownMs:U$},check:Ys(()=>Ci(this,Js,nk).call(this),"check"),claim:Ys((s,n)=>Ci(this,Js,ik).call(this,s,n),"claim"),fulfill:Ys((s,n)=>Ci(this,Js,ak).call(this,s,n),"fulfill")}),Ag(this,Js),Ag(this,In),Ag(this,za),sk(this,In,e.with({"component.id":"WireSocketUpstreamHandler"})),sk(this,za,r.channel)}},o(tc,"E"),tc);In=new WeakMap,za=new WeakMap,Js=new WeakSet,nk=Ys(function(){return Ci(this,Js,zl).call(this)},"#check"),ik=Ys(function(t,e){return!Ci(this,Js,zl).call(this)||!e.wireSocketReady?t.map(r=>{Bn(this,In).log.debug("request_route_probe",{phase:"declined",handler:"wire_socket",target:"primary",reason:Ci(this,Js,zl).call(this)?"socket_sync_not_ready":"socket_not_ready",method:r.input.requestMethod,request_id:r.input.requestBody.id,request:Hl(r.input.requestBody)})}):t.map(r=>{if(Un(r.input.requestBody)){Bn(this,In).log.debug("request_route_probe",{phase:"declined",handler:"wire_socket",target:"primary",reason:"slow_request",method:r.input.requestMethod,request_id:r.input.requestBody.id,request:Hl(r.input.requestBody)});return}return Bn(this,In).log.debug("request_route_probe",{phase:"claimed",handler:"wire_socket",target:"primary",method:r.input.requestMethod,request_id:r.input.requestBody.id,request:Hl(r.input.requestBody)}),[void 0,{}]})},"#claim"),ak=Ys(function(t,e){var r,s;if(t.length===0)return[];const n=t.map(([h])=>h.input.requestBody);if(!Ci(this,Js,zl).call(this)){const h=new Error("[direct.dev/client] wire_socket unavailable before dispatch");return n.map(()=>Promise.reject(h))}const i=Bn(this,za).request.rpc(Bn(this,In),{networkId:e.networkId,requests:n,shadow:!1,bypass:e.bypass,routingToken:void 0,block:e.block}),a=n.map(()=>Ye()),c=new Map;for(let h=0;h<n.length;h++){const u=(r=n[h])==null?void 0:r.id;u===void 0?(s=a[h])==null||s.__resolve(void 0):c.set(u,h)}return(async()=>{var h,u,d,p;try{const f=await i;for await(const g of f){const m=c.get(g.id);m!==void 0&&(a[m].__resolve(g),c.delete(g.id))}for(const[g,m]of c)a[m].__resolve(Cs(g,"NO_RESPONSE",{origin:"client",handler:"wire_socket"}))}catch(f){const g=f instanceof Error?f:new Error(String(f));for(const[m,w]of c)Bn(this,In).log.debug("request_route_probe",{phase:"failed",handler:"wire_socket",target:"primary",reason:"response_stream_error",method:(h=n[w])==null?void 0:h.method,request_id:m,request:n[w]?Hl(n[w]):void 0,error:String(f)}),(u=a[w])!=null&&u.__isFulfilled()||((d=a[w])==null||d.catch(()=>{}),(p=a[w])==null||p.__reject(g))}})(),a},"#fulfill"),zl=Ys(function(){return!Bn(this,za).transport.connectionPromise&&Bn(this,za).transport.isConnected},"#isReady"),Ys(ok,"WireSocketUpstreamHandler");let _1=ok;function Hl(t){const e={method:t.method};if(t.method==="eth_getLogs"){const[r]=Array.isArray(t.params)?t.params:[];return r&&typeof r=="object"&&(e.from_block="fromBlock"in r?r.fromBlock:void 0,e.to_block="toBlock"in r?r.toBlock:void 0),e}return t.method==="eth_getBlockByNumber"||t.method==="eth_getBlockByHash"?(e.block_param=Array.isArray(t.params)?t.params[0]:void 0,e.full_transactions=Array.isArray(t.params)?t.params[1]===!0:!1,e):(e.params=t.params,e)}o(Hl,"q$1"),Ys(Hl,"summarizeRequest");var y1=Object.defineProperty,b1=o((t,e)=>y1(t,"name",{value:e,configurable:!0}),"t$2");function Id(t){if(t===void 0)return!0;const e=pf(200,t);return e===void 0?!0:!gw(e)}o(Id,"u$5"),b1(Id,"acceptOutput");var $1=Object.defineProperty,k1=o((t,e)=>$1(t,"name",{value:e,configurable:!0}),"l$6");const ck=(rc=class{name="direct";type="upstream";origin="client";strategy="first_eligible";failover={acceptOutput:Id};handlers;constructor(e,r){const s=[];r.socketChannel&&s.push(new _1(e,{channel:r.socketChannel})),r.httpChannel&&s.push(new tk(e,{channel:r.httpChannel,isPrimary:!0})),s.push(new Md(e,{nodeUrl:r.jsonUrl,maxSizeInBytes:_g,windowMs:kd,timeoutMs:ps,fetch:r.fetch,racing:{claimMs:Nl,timeoutMs:ps},circuitBreaker:{halfClosedAttempts:1,halfOpenAttempts:1,cooldownMs:yg}})),this.handlers=s}},o(rc,"s"),rc);k1(ck,"PrimaryDirectUpstreamStage");let C1=ck;var S1=Object.defineProperty,Eg=o((t,e)=>S1(t,"name",{value:e,configurable:!0}),"i$5");const lk=(sc=class{name;type="upstream";origin="client";strategy="first_eligible";failover={acceptOutput:Id};handlers;constructor(e,r){this.name=r.isShadow?"direct_secondary_shadow":"direct_secondary";const s=e.with({"component.id":"SecondaryDirectUpstreamStage"}),n=[];r.httpChannel&&n.push(new tk(e,{channel:r.httpChannel,isPrimary:!1,isShadow:r.isShadow})),n.push(new Md(e,{nodeUrl:r.jsonUrl,maxSizeInBytes:W$,windowMs:kd,timeoutMs:ps,fetch:r.fetch,circuitBreaker:{halfClosedAttempts:1,halfOpenAttempts:1,cooldownMs:yg}}));const i=r.isShadow;this.handlers=n.map(a=>new sn({name:a.name,circuitBreaker:{halfClosedAttempts:1,halfOpenAttempts:1,cooldownMs:yg},racing:{claimMs:i?0:Nl,timeoutMs:ps},check:i?c=>c.shadowSecondaryLoad:void 0,claim:Eg((c,h,u)=>{const d=[],p=c.filter((m,w)=>{if(i){if(!ch(m.input.requestId))return s.log.debug("request_route_probe",{phase:"declined",handler:a.name,target:this.name,reason:"shadow_non_deduplicatable",method:m.input.requestMethod,request_id:m.input.requestBody.id}),!1;if(Nw(m.input.requestBody))return s.log.debug("request_route_probe",{phase:"declined",handler:a.name,target:this.name,reason:"shadow_bypass_wire",method:m.input.requestMethod,request_id:m.input.requestBody.id}),!1;if(Un(m.input.requestBody))return s.log.debug("request_route_probe",{phase:"declined",handler:a.name,target:this.name,reason:"shadow_slow_request",method:m.input.requestMethod,request_id:m.input.requestBody.id}),!1}else if(h.shadowSecondaryLoad&&ch(m.input.requestId))return s.log.debug("request_route_probe",{phase:"declined",handler:a.name,target:this.name,reason:"failover_shadow_deduplicatable",method:m.input.requestMethod,request_id:m.input.requestBody.id}),!1;return d.push(w),!0});if(p.length===0)return c.map(()=>{});const f=a.claimSync(p,h,u),g=c.map(()=>{});for(let m=0;m<f.length;m++)g[d[m]]=f[m];return g},"claim"),fulfill:Eg((c,h,u)=>a.fulfillSync(c,h,u),"fulfill")}))}},o(sc,"p"),sc);Eg(lk,"SecondaryDirectUpstreamStage");let hk=lk;var A1=Object.defineProperty,uk=o((t,e)=>A1(t,"name",{value:e,configurable:!0}),"s$4");function dk(t,e){for(const r of e){const s=pf(t.status,r);if(s!==void 0&&ww(s))return!0}return!1}o(dk,"h$3"),uk(dk,"batchShouldTripBreaker");const fk=(nc=class{name="configured_failover";type="upstream";origin="client";strategy="exhaustive";failover={acceptOutput:Id};handlers;constructor(e,r){this.handlers=r.nodeUrls.map(s=>new Md(e,{nodeUrl:s,maxSizeInBytes:_g,windowMs:kd,timeoutMs:ps,shouldTripBreaker:dk,fetch:r.fetch,racing:{claimMs:Nl,timeoutMs:ps}}))}},o(nc,"n"),nc);uk(fk,"ConfiguredFailoverUpstreamStage");let E1=fk;var M1=Object.defineProperty,T1=o((t,e)=>M1(t,"name",{value:e,configurable:!0}),"s$3");const pk=(ic=class{name="public_failover";type="upstream";origin="client";strategy="first_eligible";failover={};handlers;constructor(e,r){const s=QE[r.networkId]??[];this.handlers=s.map(n=>new Md(e,{nodeUrl:n,maxSizeInBytes:_g,windowMs:kd,timeoutMs:ps,fetch:r.fetch,racing:{claimMs:Nl,timeoutMs:ps}}))}},o(ic,"e"),ic);T1(pk,"PublicFailoverUpstreamStage");let R1=pk;var B1=Object.defineProperty,Si=o((t,e)=>B1(t,"name",{value:e,configurable:!0}),"u$4");function mk(t){var e,r,s;if((t==null?void 0:t.stageType)==="cache"&&(t.handlerName==="block_state_cache"||t.handlerName==="local_memory_cache"||t.handlerName==="continuum_cache"||t.handlerName==="inflight_cache"))return t.handlerName;if((t==null?void 0:t.stageType)==="upstream"&&(e=t.stageName)!=null&&e.startsWith("direct")){const n=t.stageName==="direct"?"primary":t.stageName==="direct_secondary"?"secondary":t.stageName==="direct_secondary_shadow"?"secondary_shadow":t.stageName;if(t.handlerName==="wire_socket"||t.handlerName==="wire_http")return`${n}_${t.handlerName}`;if((r=t.handlerName)!=null&&r.startsWith("http://")||(s=t.handlerName)!=null&&s.startsWith("https://"))return`${n}_json_rpc`}return(t==null?void 0:t.stageName)??"unknown"}o(mk,"Z$1"),Si(mk,"getRequestResolutionStageName");function gk(t){if(t)return(t.checkMs??0)+(t.claimMs??0)+(t.fulfillMs??0)}o(gk,"$$2"),Si(gk,"getRequestResolutionStageLatencyMs");const wk=(ac=class extends KC{constructor(e,r,s,n){const i={httpChannel:r.secondaryHttpChannel,jsonUrl:s.secondaryJsonUrl,fetch:s.fetch},a=[new a1,new f1(r.cache),new h1(r.cache),new hk(e,{...i,isShadow:!0}),new C1(e,{socketChannel:r.socketChannel,httpChannel:r.httpChannel,jsonUrl:s.jsonUrl,fetch:s.fetch}),new hk(e,{...i,isShadow:!1}),...s.failoverUrls&&s.failoverUrls.length>0?[new E1(e,{nodeUrls:s.failoverUrls,fetch:s.fetch})]:[],new R1(e,{networkId:s.networkId,fetch:s.fetch})];super(a,{timeoutMs:6e4,transformInput:Si((c,h)=>{var u;const d=uh(c.method),p=ah(c,d),f=Ht(p,(u=h.block)==null?void 0:u.digest);return{requestBody:c,requestId:f,requestMethod:d}},"transformInput"),transformError:Si((c,h)=>(e.log.warn("Request failed",{input:c,err:h}),Cs(c.requestBody.id??null,"SERVER_ERROR",{...q1,error:String(h)})),"transformError"),onTelemetry:Si((c,h)=>{var u,d;(u=s.onTelemetry)==null||u.call(s,c,h);const p=s.requestLogging??"off",f=p==="debug"||!!h.onResolution,g=[];for(const m of c){const w=m.executions.findLast(_=>_.result==="fulfilled");if(f){const _=mk(w),S=gk(w),b={method:m.input.requestMethod,request_id:m.input.requestBody.id,latency_ms:S??m.latencyMs,pipeline_latency_ms:m.latencyMs,stage_name:_,stage_type:(w==null?void 0:w.stageType)??"unknown"};if(g.push(b),p==="debug"){const O={client_instance_id:s.clientInstanceId,...b,handler_name:(w==null?void 0:w.handlerName)??"unknown"};p$(p,O,s.onLogEvent)}}if(p==="debug"){const _=m.deferred.__resolvedWith();g$("request_handled",{client_instance_id:s.clientInstanceId,req:m.input.requestBody,res:_===xf?void 0:_,latency_ms:m.latencyMs},s.onLogEvent)}}if((d=h.onResolution)==null||d.call(h,g),!!n){n.collectBandwidthEstimateHeaders("upload",e1),n.collectBandwidthEstimateHeaders("download",t1);for(const m of c){const w=m.executions.findLast(j=>j.result==="fulfilled"),_=m.deferred.__resolvedWith(),S=vk(w==null?void 0:w.stageName),b=(w==null?void 0:w.stageName)??"unknown",O=Oi(m.input.requestBody);if(n.collectBandwidthEstimatePayload(S,b,"upload",O),_!==xf&&_!==void 0){const j=Oi(_);switch(n.collectBandwidthEstimatePayload(S,b,"download",j*ZE),w==null?void 0:w.stageType){case"upstream":n.collectUpstreamLatency(b,m.latencyMs);break;case"cache":{n.collectCacheHit(b,{requestMethod:m.input.requestMethod,requestId:m.input.requestId,requestSizeInBytes:O,blockContext:h.block,responseKey:Bf(_,m.input.requestMethod),responseSizeInBytes:j,latencyMs:m.latencyMs});break}}}}}},"onTelemetry")})}},o(ac,"S"),ac);Si(wk,"ClientRequestPipeline");let I1=wk;function vk(t){return t!=null&&t.endsWith("_failover")?"failover":"direct"}o(vk,"J$1"),Si(vk,"getTargetByStageName");const q1={origin:"client"},P1=ke("config",l.shape({projectId:l.str,projectToken:l.str.optional,networkId:l.networkId,failover:l.arr(l.str,{minLength:1}).optional,baseUrl:l.str.optional,secondaryBaseUrl:l.str.optional,logging:l.shape({client:l.literal("silent","info","debug","warn","error").optional,requests:l.literal("off","summary","debug").optional,onEvent:l.unknown.optional}).optional,disableWire:l.bool.optional,disableSync:l.bool.optional,disableLocalMemoryCache:l.bool.optional,fetch:l.unknown.optional,createWebSocket:l.unknown.optional})),x1=ke("eth_getTransactionReceipt",l.shape({result:l.shape({blockNumber:l.blockHeight})},{ignoreExtraProps:!0}));var W1=Object.defineProperty,_k=o(t=>{throw TypeError(t)},"v$1"),U1=o((t,e)=>W1(t,"name",{value:e,configurable:!0}),"m$1"),yk=o((t,e,r)=>e.has(t)||_k("Cannot "+r),"T$1"),Ar=o((t,e,r)=>(yk(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$2"),Mg=o((t,e,r)=>e.has(t)?_k("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"f$3"),Tg=o((t,e,r,s)=>(yk(t,e,"write to private field"),e.set(t,r),r),"d$3"),Ai,_s,qd;const bk=(oc=class{constructor(e){Mg(this,Ai,1/0),Mg(this,_s,[]),Mg(this,qd),Tg(this,qd,(e==null?void 0:e.delayExpirationMs)??3e5)}sync(e,r,s){var n;const i=y(),a=(r-e+(s-i))/2,c=i-e-(s-r),h=i-Ar(this,qd);for(;Ar(this,_s).length>0&&Ar(this,_s)[0][1]<h;)Ar(this,_s).shift();for(Ar(this,_s).push([c,i]);Ar(this,_s).length>16;)Ar(this,_s).shift();const u=Ar(this,_s).toSorted((p,f)=>p[0]-f[0]),d=((n=u.at(Math.floor(u.length/2)))==null?void 0:n[0])??1/0;c<=d&&Tg(this,Ai,a)}delta(e,r=y()){const s=r+Ar(this,Ai);return e-s}isFuture(e,r=y()){return this.delta(e,r)>0}isPast(e,r=y()){return this.delta(e,r)<0}getServerTime(e=y()){return Ar(this,Ai)===1/0?e:e+Ar(this,Ai)}__setOffsetForTest(e){Tg(this,Ai,e),Ar(this,_s).length=0}},o(oc,"c"),oc);Ai=new WeakMap,_s=new WeakMap,qd=new WeakMap,U1(bk,"RemoteClock");let $k=bk;var D1=Object.defineProperty,kk=o(t=>{throw TypeError(t)},"I$2"),Rg=o((t,e)=>D1(t,"name",{value:e,configurable:!0}),"c$5"),Bg=o((t,e,r)=>e.has(t)||kk("Cannot "+r),"u$3"),Ha=o((t,e,r)=>(Bg(t,e,"read from private field"),e.get(t)),"i$3"),Ig=o((t,e,r)=>e.has(t)?kk("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"h$2"),Ck=o((t,e,r,s)=>(Bg(t,e,"write to private field"),e.set(t,r),r),"E$3"),Sk=o((t,e,r)=>(Bg(t,e,"access private method"),r),"_$3"),Pd,qn,xd,Ak,Ek;const Mk=(cc=class{constructor(e){Ig(this,xd),Ig(this,Pd),Ig(this,qn),Ck(this,Pd,e)}update(e){Ck(this,qn,e)}shouldShadow(){if(!Ha(this,qn))return!1;const e=Sk(this,xd,Ak).call(this);return e===0?!1:Math.random()*1e4<e}},o(cc,"l"),cc);Pd=new WeakMap,qn=new WeakMap,xd=new WeakSet,Ak=Rg(function(){if(!Ha(this,qn))return 0;const t=Sk(this,xd,Ek).call(this);return t%665===0?Ha(this,qn).weeklySpike:t%95===0?Ha(this,qn).dailySpike:Ha(this,qn).base},"#getCurrentRate"),Ek=Rg(function(){const t=Ha(this,Pd).getServerTime();return Math.floor(t/9e5)},"#getCurrentEpoch"),Rg(Mk,"ShadowRateManager");let O1=Mk;var j1=Object.defineProperty,qg=o((t,e)=>j1(t,"name",{value:e,configurable:!0}),"i$2");const Tk=new ru({id:0,name:"rpc",req:ke("rpc_request",l.shape({networkId:l.networkId,requests:l.arr(Sm),shadow:l.bool,bypass:l.bool,routingToken:l.str.optional,block:l.shape({height:l.blockHeight,digest:l.blockDigest.optional,expiresAt:l.timestamp.optional}).optional})),res:hl,timeoutMs:1e4},[]),Rk=new jc({id:1,name:"ntp_sync",req:ke("ntp_sync",l.shape({t1:l.uint32,t2:l.timestamp,t3:l.timestamp}))},[]),N1=new jc({id:2,name:"telemetry",req:gA},[]),L1=new jc({id:3,name:"block_height",req:ke("block_height",l.shape({networkId:l.networkId,height:l.blockHeight,expiresAt:l.timestamp}))},[]),F1=new jc({id:6,name:"routing_context",req:ke("routing_context",l.shape({networkId:l.networkId,token:l.str,expiresAt:l.timestamp}))},[]),z1=new jc({id:4,name:"shadow_rate",req:ke("shadow_rate",l.shape({base:l.uint32,dailySpike:l.uint32,weeklySpike:l.uint32}))},[]),Bk=new hb,Pg=new Fm,H1=new Ab(Bk,Pg,{onInflightTimeout:qg(()=>{},"onInflightTimeout"),onInflightEviction:qg(()=>{},"onInflightEviction"),onPrematureEviction:qg(()=>{},"onPrematureEviction")}),xg=new RE({block:Bk,fingerprint:Pg,fingerprintRevalidated:Pg,cache:H1},{id:5,name:"client_continuum",timeoutMs:5*6e4},l.shape({networkId:l.networkId})),Ik=new B_({name:"client_to_primary",mode:"untrusted",downstreamRelationship:"parent"},{rpc:Tk,telemetry:N1,continuum:xg},{ntp:Rk,shadowRate:z1}),K1=new B_({name:"client_to_secondary",mode:"untrusted",downstreamRelationship:"parent"},{rpc:Tk},{ntp:Rk,blockHeight:L1,routingContext:F1});var G1=Object.defineProperty,fe=o((t,e)=>G1(t,"name",{value:e,configurable:!0}),"o$2");const Wg=new Map,qk=new WeakMap,Pk=new WeakMap;let V1=1,Y1=1;const xk=4*1024*1024,Wk=16*1024*1024;function Uk(t){if(!t)return 0;let e=qk.get(t);return e===void 0&&(e=V1++,qk.set(t,e)),e}o(Uk,"oe$1"),fe(Uk,"getFetchId");function Dk(t){if(!t)return 0;let e=Pk.get(t);return e===void 0&&(e=Y1++,Pk.set(t,e)),e}o(Dk,"re$1"),fe(Dk,"getWebSocketFactoryId");const Wd=new Set;function Ok(t){const e=fe(r=>{t(r)},"cb");return Wd.add(e),()=>{Wd.delete(e)}}o(Ok,"se$1"),fe(Ok,"addWireBandwidthListener");function Ud(t){return{onIngress:fe(e=>{for(const r of Wd)r({channel:t,direction:"ingress",bytes:e})},"onIngress"),onEgress:fe(e=>{for(const r of Wd)r({channel:t,direction:"egress",bytes:e})},"onEgress")}}o(Ud,"I$1"),fe(Ud,"makeBandwidthHooks");function Dd(t){const e=Og(t.baseUrl??"https://prod.rpc.direct.dev"),r=Dg(t);return`${e}/v1/${r}`}o(Dd,"$$1"),fe(Dd,"getUrl");function Ug(t){const e=Og(t.secondaryBaseUrl??XE),r=Dg(t);return`${e}/v1/${r}`}o(Ug,"j$1"),fe(Ug,"getSecondaryUrl");function jk(t){var e;const r=Dd(t),s=Ug(t),n=Uk(t.fetch),i=Dk(t.createWebSocket),a=ug(t.logging),c=`${r}|${s}|${n}|${i}|${a}`,h=new Set,u=new Set,d=(e=t.logging)==null?void 0:e.onEvent;let p=Wg.get(c);if(p)p.refCount++,p.blockListeners.add(h),p.routingListeners.add(u),d&&p.logEventListeners.add(d);else{const m=new Set;d&&m.add(d);const w=new Gy({serviceVersion:"0.7.2",serviceNamespace:"client",serviceName:"client",serviceInstanceId:void 0,projectId:t.projectId,networkId:void 0,coloId:void 0,continentId:void 0},{logLevel:`*:${a}`,logSamples:"*:1",traceSamples:"*:0",exporter:fe(()=>new o$({onEvent:fe(Pe=>{for(const je of m)je(Pe)},"onEvent")}),"exporter")},Bm()),_=new $k,S=new O1(_),b=Nk(w,r,_,S,t.fetch),O=Lk(w,r,_,S,t.createWebSocket),j=new Set([h]),W=new Set([u]),K=new $k,q=Fk(w,s,K,t.fetch,Pe=>{for(const je of j)for(const Ae of je)Ae(Pe)},Pe=>{for(const je of W)for(const Ae of je)Ae(Pe)});p={clock:_,secondaryClock:K,httpChannel:b,secondaryHttpChannel:q,socketChannel:O,shadowRateManager:S,refCount:1,blockListeners:j,routingListeners:W,logEventListeners:m},Wg.set(c,p)}let f=!1;const g=fe(()=>{var m;if(!f&&(f=!0,p.refCount--,p.blockListeners.delete(h),p.routingListeners.delete(u),d&&p.logEventListeners.delete(d),p.refCount===0))return Wg.delete(c),Promise.all([p.httpChannel.disconnect(),p.secondaryHttpChannel.disconnect(),(m=p.socketChannel)==null?void 0:m.disconnect()]).then(()=>{},()=>{})},"release");return[{clock:p.clock,httpChannel:p.httpChannel,socketChannel:p.socketChannel,secondaryClock:p.secondaryClock,secondaryHttpChannel:p.secondaryHttpChannel,shadowRateManager:p.shadowRateManager,onSecondaryBlockHeight:fe(m=>(h.add(m),()=>h.delete(m)),"onSecondaryBlockHeight"),onSecondaryRoutingContext:fe(m=>(u.add(m),()=>u.delete(m)),"onSecondaryRoutingContext")},g]}o(jk,"ce"),fe(jk,"getSharedResources");function Nk(t,e,r,s,n){const i=new Gi,a=new dy(t,{url:fe(()=>{const c=y(),h=Gi.encodeIndex(i.store(c));return Od(e,h)},"url"),batchWindowMs:100,batchMaxSizeInBytes:512e3,batchTimeoutMs:3e4,flushRequestsImmediately:!0,disableDuplex:!0,maxMessageSize:xk,maxStreamSize:Wk,fetchFn:n?()=>n:void 0},{enableCompression:!1},Ud("primary_http"));return Ik.createClient(a,{ntp:fe((c,h,u)=>{const d=i.consume(u.t1);t.log.verbose("ntp_sync_received",{channel:"primary_http",token:u.t1,matched:d!==void 0,t2:u.t2,t3:u.t3}),d!==void 0&&r.sync(d,u.t2,u.t3)},"ntp"),shadowRate:fe((c,h,u)=>{s.update(u)},"shadowRate")})}o(Nk,"ie$1"),fe(Nk,"makeHTTPChannel");function Lk(t,e,r,s,n){if(!n&&typeof WebSocket>"u")return;const i=new Gi,a=e.replace("https://","wss://").replace("http://","ws://"),c=new rA(t,()=>{const h=y(),u=Gi.encodeIndex(i.store(h)),d=Od(a,u);return n?n(d):new WebSocket(d)},{compression:{enableCompression:!0},maxMessageSize:2*1024*1024,primeSocket:!0,circuitBreaker:{halfOpenAttempts:3,halfClosedAttempts:8,cooldownMs:3e4}},Ud("primary_websocket"));return c.connect(t).catch(()=>{}),Ik.createClient(c,{ntp:fe((h,u,d)=>{const p=i.consume(d.t1);t.log.verbose("ntp_sync_received",{channel:"primary_websocket",token:d.t1,matched:p!==void 0,t2:d.t2,t3:d.t3}),p!==void 0&&r.sync(p,d.t2,d.t3)},"ntp"),shadowRate:fe((h,u,d)=>{s.update(d)},"shadowRate")})}o(Lk,"ae$1"),fe(Lk,"makeSocketChannel");function Fk(t,e,r,s,n,i){const a=new Gi,c=new dy(t,{url:fe(()=>{const h=y(),u=Gi.encodeIndex(a.store(h));return Od(e,u)},"url"),batchWindowMs:100,batchMaxSizeInBytes:W$,batchTimeoutMs:3e4,flushRequestsImmediately:!0,disableDuplex:!0,maxMessageSize:xk,maxStreamSize:Wk,fetchFn:s?()=>s:void 0},{enableCompression:!1},Ud("secondary_http"));return K1.createClient(c,{ntp:fe((h,u,d)=>{const p=a.consume(d.t1);t.log.verbose("ntp_sync_received",{channel:"secondary_http",token:d.t1,matched:p!==void 0,t2:d.t2,t3:d.t3}),p!==void 0&&r.sync(p,d.t2,d.t3)},"ntp"),blockHeight:fe((h,u,d)=>{n(d)},"blockHeight"),routingContext:fe((h,u,d)=>{i(d)},"routingContext")})}o(Fk,"le"),fe(Fk,"makeSecondaryHTTPChannel");function Dg(t){return t.projectToken?t.projectId+"."+encodeURIComponent(t.projectToken):t.projectId}o(Dg,"z"),fe(Dg,"getProjectPath");function Od(t,e){return e?t.includes("?")?t+"&t="+encodeURIComponent(e):t+"?t="+encodeURIComponent(e):t}o(Od,"b$1"),fe(Od,"appendTimeParam");function Og(t){let e=t.length;for(;e>0&&t.charAt(e-1)==="/";e--);return t.substring(0,e)}o(Og,"R$1"),fe(Og,"getBaseUrl");var zk=Object.defineProperty,Hk=o(t=>{throw TypeError(t)},"qt"),J1=o((t,e,r)=>e in t?zk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,"_e"),x=o((t,e)=>zk(t,"name",{value:e,configurable:!0}),"a$1"),jd=o((t,e,r)=>J1(t,typeof e!="symbol"?e+"":e,r),"G"),jg=o((t,e,r)=>e.has(t)||Hk("Cannot "+r),"kt"),v=o((t,e,r)=>(jg(t,e,"read from private field"),r?r.call(t):e.get(t)),"e$1"),G=o((t,e,r)=>e.has(t)?Hk("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),"d$2"),V=o((t,e,r,s)=>(jg(t,e,"write to private field"),e.set(t,r),r),"h"),B=o((t,e,r)=>(jg(t,e,"access private method"),r),"r$2"),X1=o((t,e,r,s)=>({set _(n){V(t,e,n)},get _(){return v(t,e,s)}}),"Ft"),Ng,Oe,Ge,Ct,Pn,Xr,Ka,Kl,xn,Ga,Gl,Se,Ei,Nd,Ld,Vl,Mi,Fd,zd,Va,Yl,Hd,Kd,Ti,Ya,Gd,Er,Vd,Yd,Jd,Jl,Ja,Xa,Qa,Xd,R,Qd,Zd,Za,ef,Lg,eo,tf,Fg,Ri,zg,Hg,Kk,Gk,Vk,Yk,Jk,Xk,Qk,Zk,e0,t0,r0,s0,Kg,Gg,rf,sf,nf,n0,af,Xl;function i0(t){if(t.length===0)return{};const e=t[0];if(t.length===1)return{stage_name:e==null?void 0:e.stage_name,stage_type:e==null?void 0:e.stage_type};const r=new Set(t.map(n=>n.stage_name)),s=new Set(t.map(n=>n.stage_type));return{stage_name:r.size===1?e==null?void 0:e.stage_name:"mixed",stage_type:s.size===1?e==null?void 0:e.stage_type:void 0}}o(i0,"$e"),x(i0,"summarizePipelineResolutions");function Vg(t,e){return t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||e}o(Vg,"Gt"),x(Vg,"toClientIdSlug");const ar=(Wi=class{constructor(e,r){G(this,R),G(this,Oe),G(this,Ge),G(this,Ct),G(this,Pn),G(this,Xr),G(this,Ka),G(this,Kl),G(this,xn),G(this,Ga),G(this,Gl),G(this,Se),G(this,Ei),G(this,Nd),G(this,Ld,!1),G(this,Vl),G(this,Mi,!1),G(this,Fd),G(this,zd),G(this,Va),G(this,Yl),G(this,Hd),G(this,Kd),G(this,Ti),G(this,Ya),G(this,Gd),G(this,Er),G(this,Vd),G(this,Yd),G(this,Jd,y()),G(this,Jl),G(this,Ja),G(this,Xa,new AbortController),G(this,Qa),G(this,Xd),G(this,rf,x(()=>{if(typeof document>"u"||document.visibilityState!=="hidden")return;const d=v(this,Ti).consume();d&&B(this,R,Xl).call(this,d,!0)},"#handleVisibilityChange")),G(this,sf,x(()=>{this.destroy().catch(()=>{})},"#handleBeforeUnload"));var s;const n=P1.parse(e);V(this,Ge,n);const i=Vg(n.networkId,"network"),a=Vg(n.projectId.slice(0,8),"project");V(this,Ct,`client_${i}_${a}_${X1(Wi,Ng)._++}`);const[c,h]=jk(n);V(this,Xd,h),V(this,xn,c.clock),V(this,Gl,c.secondaryClock),V(this,zd,c.shadowRateManager),V(this,Ya,c.httpChannel),V(this,Gd,c.secondaryHttpChannel),V(this,Er,c.socketChannel),V(this,Oe,new Gy({serviceVersion:"0.7.2",serviceNamespace:"client",serviceName:"client",serviceInstanceId:void 0,projectId:n.projectId,networkId:n.networkId,coloId:void 0,continentId:void 0},{logLevel:`*:${ug(n.logging)}`,logSamples:"*:1",traceSamples:"*:0",exporter:x(()=>{var d;return new o$({onEvent:(d=n.logging)==null?void 0:d.onEvent})},"exporter")},{...Bm(),...jb()})),V(this,Pn,new hb({isExpired:x(d=>v(this,xn).isPast(d),"isExpired")})),V(this,Xr,new WE(v(this,Pn),d=>v(this,xn).isPast(d))),v(this,Pn).onPatch(()=>{B(this,R,Ri).call(this,"block_state_available")}),v(this,Pn).onSnapshot(()=>{B(this,R,Ri).call(this,"block_state_available")}),c.onSecondaryBlockHeight(d=>{d.networkId===n.networkId&&V(this,Vd,{height:d.height,expiresAt:d.expiresAt})}),c.onSecondaryRoutingContext(d=>{d.networkId===n.networkId&&V(this,Yd,d)}),V(this,Va,new Fm),V(this,Yl,new Fm),V(this,Kl,new Ab(v(this,Pn),v(this,Va),{onInflightTimeout:x(()=>{},"onInflightTimeout"),onInflightEviction:x(()=>{},"onInflightEviction"),onPrematureEviction:x(()=>{},"onPrematureEviction")}));const u=new e$(v(this,Va));V(this,Hd,new e$(v(this,Yl))),V(this,Ka,new NE(v(this,xn),{cacheContinuum:v(this,Kl),fingerprintResolver:u,disableLocalMemoryCache:n.disableLocalMemoryCache})),V(this,Ti,new JE({networkId:n.networkId,softEntryLimit:100,softFlushIntervalMs:2e3,hardFlushIntervalMs:6e4,onFlush:x(d=>B(this,R,Xl).call(this,d),"onFlush"),onBandwidthEstimate:r==null?void 0:r.bandwidthEstimate})),V(this,Kd,new I1(v(this,Oe),{cache:v(this,Ka),httpChannel:n.disableWire?void 0:v(this,Ya),secondaryHttpChannel:n.disableWire?void 0:v(this,Gd),socketChannel:n.disableWire?void 0:v(this,Er)},{networkId:n.networkId,jsonUrl:Dd(n)+`/${encodeURIComponent(n.networkId)}`,secondaryJsonUrl:Ug(n)+`/${encodeURIComponent(n.networkId)}`,failoverUrls:n.failover,clientInstanceId:v(this,Ct),fetch:n.fetch,onLogEvent:(s=n.logging)==null?void 0:s.onEvent,requestLogging:dg(n.logging),onTelemetry:r==null?void 0:r.pipeline},v(this,Ti))),!n.disableSync&&v(this,Er)&&(B(this,R,Qd).call(this),V(this,Se,B(this,R,Lg).call(this,{usePreload:!0,connect:B(this,R,Zd).call(this)})),B(this,R,nf).call(this)),B(this,R,Yk).call(this)}static onWireBandwidth(e){return Ok(e)}getClientInstanceId(){return v(this,Ct)}fetch(e){var r,s,n;const i=y(),a=Array.isArray(e)?e.map(m=>Sm.parse(m)):[Sm.parse(e)];if(Lw(a))return v(this,Oe).log.error("Batch contains duplicate request IDs",{ids:a.map(m=>m.id)}),a.filter(m=>m.id!==void 0).map(m=>Bi(Cs(m.id??null,"BAD_REQUEST",{reason:"duplicate_ids"})));V(this,Jl,y()),B(this,R,nf).call(this),B(this,R,Qd).call(this);const c=v(this,Ga);v(this,Se)&&!v(this,Se).connected&&(c==null||c.applied)&&B(this,R,Zd).call(this)?B(this,R,eo).call(this,v(this,Se)):v(this,Se)&&!v(this,Se).connected&&(c==null||c.applied)&&B(this,R,ef).call(this,v(this,Se));const h=dg(v(this,Ge).logging),u=B(this,R,af).call(this),d=v(this,Xr).getCurrent({allowExpiredRetained:u}),p=v(this,Xr).hasLiveCurrent();a.some(m=>m.method==="eth_blockNumber")&&h==="debug"&&v(this,Oe).log.debug("block.state_probe",{client_instance_id:v(this,Ct),network_id:v(this,Ge).networkId,preload_attached:(c==null?void 0:c.attached)??!1,preload_applied:(c==null?void 0:c.applied)??!1,continuum_connected:((r=v(this,Se))==null?void 0:r.connected)??!1,has_current_block:!!d,has_live_current_block:p,current_block_height:d==null?void 0:d.height,current_block_digest:d==null?void 0:d.digest}),(s=v(this,Se))!=null&&s.connected&&p&&(V(this,Ld,!0),B(this,R,Ri).call(this,"block_state_available")),(n=v(this,Se))!=null&&n.connected&&!p&&v(this,Ld)&&!B(this,R,af).call(this)&&B(this,R,n0).call(this,"stale_sync_missing_block");const f=B(this,R,Jk).call(this,p),g=B(this,R,e0).call(this,a,d,p,f,c);return It(g,m=>{const w=B(this,R,Kg).call(this),_=B(this,R,s0).call(this),S=[],b=h==="summary"||h==="debug",O=v(this,Kd).request(a,{block:d,secondaryBlock:w,routing:_,networkId:v(this,Ge).networkId,wireSocketReady:f,shadowSecondaryLoad:v(this,zd).shouldShadow(),bypass:m,onResolution:b?q=>{S.push(...q)}:void 0}),j=B(this,R,r0).call(this,O,a),W=B(this,R,Xk).call(this,j,a),K=v(this,Ti).maybeConsume();return K&&B(this,R,Xl).call(this,K),It(W,({responses:q,winner:Pe})=>{var je,Ae,Ve,Ft;const zt=y()-i,or=a.length===1?((je=a[0])==null?void 0:je.method)??"unknown":"batch",Qr=Pe==="pipeline"?i0(S):{};if(m$(h,{client_instance_id:v(this,Ct),method:or,methods:a.map(Zr=>Zr.method),request_id:a.length===1?(Ae=a[0])==null?void 0:Ae.id:void 0,request_ids:a.map(Zr=>Zr.id),request_count:a.length,latency_ms:zt,resolution_source:Pe,stage_type:Pe==="preload_local"?"cache":Qr.stage_type,stage_name:Pe==="preload_local"?"preload_local":Qr.stage_name},(Ve=v(this,Ge).logging)==null?void 0:Ve.onEvent),Array.isArray(e))return q;if(((Ft=a[0])==null?void 0:Ft.id)!==void 0)return q[0]??Bi(Cs(a[0].id,"NO_RESPONSE",{source:"client"}))})})}getBlockHeight(){var e;return(e=B(this,R,Gg).call(this))==null?void 0:e.height}async destroy(){return v(this,Qa)?v(this,Qa):(V(this,Qa,(async()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",v(this,rf)),typeof window<"u"&&window.removeEventListener("beforeunload",v(this,sf)),clearTimeout(v(this,Ja)),V(this,Ja,void 0),v(this,Ka).destroy(),v(this,Xa).abort();const e=v(this,Ti).consume();e&&await B(this,R,Xl).call(this,e,!0),v(this,Se)&&await B(this,R,tf).call(this,v(this,Se),"destroy").catch(()=>{}),await v(this,Xd).call(this)})()),v(this,Qa))}},o(Wi,"k"),Wi);Ng=new WeakMap,Oe=new WeakMap,Ge=new WeakMap,Ct=new WeakMap,Pn=new WeakMap,Xr=new WeakMap,Ka=new WeakMap,Kl=new WeakMap,xn=new WeakMap,Ga=new WeakMap,Gl=new WeakMap,Se=new WeakMap,Ei=new WeakMap,Nd=new WeakMap,Ld=new WeakMap,Vl=new WeakMap,Mi=new WeakMap,Fd=new WeakMap,zd=new WeakMap,Va=new WeakMap,Yl=new WeakMap,Hd=new WeakMap,Kd=new WeakMap,Ti=new WeakMap,Ya=new WeakMap,Gd=new WeakMap,Er=new WeakMap,Vd=new WeakMap,Yd=new WeakMap,Jd=new WeakMap,Jl=new WeakMap,Ja=new WeakMap,Xa=new WeakMap,Qa=new WeakMap,Xd=new WeakMap,R=new WeakSet,Qd=x(function(){var t;const e=(t=v(this,Er))==null?void 0:t.transport;!e||e.isConnected||e.connectionPromise||Promise.resolve(e.connect(v(this,Oe))).catch(()=>{})},"#ensureSocketTransportConnect"),Zd=x(function(){var t;const e=(t=v(this,Er))==null?void 0:t.transport;return e?e.isConnected:!1},"#canConnectContinuumNow"),Za=x(function(){const t=v(this,Jl);return t==null?y()-v(this,Jd)<ar.INITIAL_SYNC_INACTIVITY_MS:y()-t<ar.IDLE_DISCONNECT_MS},"#shouldKeepContinuumSyncActive"),ef=x(function(t){var e;const r=(e=v(this,Er))==null?void 0:e.transport;if(!r||t.connected)return;if(r.isConnected){B(this,R,eo).call(this,t);return}const s=r.connectionPromise;s&&s.then(()=>{v(this,Xa).signal.aborted||v(this,Se)!==t||t.connected||!r.isConnected||!B(this,R,Za).call(this)||B(this,R,eo).call(this,t)}).catch(()=>{})},"#connectContinuumSubscriberWhenSocketReady"),Lg=x(function(t){const e=v(this,Er);if(!e)throw new Error("[direct.dev/client] Continuum sync requires websocket transport");const r={block:v(this,Pn),fingerprint:v(this,Va),fingerprintRevalidated:v(this,Yl),cache:v(this,Kl)},s=new IE(v(this,Oe),xg,e,r,{distributedTracing:!1,shouldReconnect:x(()=>B(this,R,Za).call(this),"shouldReconnect")});let n;if(t!=null&&t.usePreload&&typeof window<"u"){let i=x(()=>{},"resolveApplied");const a={attached:!1,applied:!1,appliedPromise:new Promise(h=>{i=h}),resolveApplied:i};V(this,Ga,a);const c=new fA(xg,{fromChecksum:Uc,params:{networkId:v(this,Ge).networkId}}).dispatch(v(this,Oe),Dd(v(this,Ge))+`/${encodeURIComponent(v(this,Ge).networkId)}`,v(this,Xa).signal,{onValidatedResponse:x((h,u)=>{B(this,R,Vk).call(this,h,u)},"onValidatedResponse"),onAttached:x(()=>{a.attached=!0,v(this,Oe).log.debug("preload.phase",{phase:"attached",client_instance_id:v(this,Ct),network_id:v(this,Ge).networkId})},"onAttached")});n=B(this,R,Gk).call(this,c,a)}else V(this,Ga,void 0);return(t==null?void 0:t.connect)!==!1?B(this,R,eo).call(this,s,n):n?B(this,R,Kk).call(this,s,n):B(this,R,ef).call(this,s),s},"#bootstrapContinuumSubscriber"),eo=x(function(t,e){V(this,Nd,y(+ar.SYNC_BOOTSTRAP_GRACE_MS)),t.connect(v(this,Oe),{networkId:v(this,Ge).networkId},e),B(this,R,Fg).call(this,!0,"started"),B(this,R,Ri).call(this,"waiting_for_block")},"#connectContinuumSubscriber"),tf=x(async function(t,e){const r=t.connected;if(await t.disconnect(),r){if(B(this,R,Fg).call(this,!1,e),e==="destroy"){B(this,R,zg).call(this,"disconnected");return}B(this,R,Ri).call(this,"block_state_available")}},"#disconnectContinuumSubscriber"),Fg=x(function(t,e){v(this,Oe).log.info("sync.connection",{client_instance_id:v(this,Ct),network_id:v(this,Ge).networkId,connected:t,transport:"wire_socket",reason:e})},"#logSyncConnection"),Ri=x(function(t){var e;const r=((e=v(this,Se))==null?void 0:e.connected)??!1,s=v(this,Xr).hasLiveCurrent()?v(this,Xr).getCurrent():void 0;if(!(r&&s)){B(this,R,zg).call(this,t==="waiting_for_block"?"waiting_for_block":"disconnected");return}B(this,R,Hg).call(this,s,"wire_socket"),!v(this,Mi)&&(V(this,Mi,!0),v(this,Oe).log.info("sync.ready",{client_instance_id:v(this,Ct),network_id:v(this,Ge).networkId,ready:!0,transport:"wire_socket",reason:"block_state_available",current_block_height:s==null?void 0:s.height,current_block_digest:s==null?void 0:s.digest}))},"#maybeLogSyncReady"),zg=x(function(t){if(!(!v(this,Mi)&&t==="disconnected")){if(!v(this,Mi)&&t==="waiting_for_block"){v(this,Oe).log.info("sync.ready",{client_instance_id:v(this,Ct),network_id:v(this,Ge).networkId,ready:!1,transport:"wire_socket",reason:t});return}V(this,Mi,!1),v(this,Oe).log.info("sync.ready",{client_instance_id:v(this,Ct),network_id:v(this,Ge).networkId,ready:!1,transport:"wire_socket",reason:t})}},"#logSyncNotReady"),Hg=x(function(t,e){const r=v(this,Fd);r&&r.height===t.height&&r.digest===t.digest||(V(this,Fd,{height:t.height,digest:t.digest}),v(this,Oe).log.info("block.advanced",{client_instance_id:v(this,Ct),network_id:v(this,Ge).networkId,source:e,current_block_height:t.height,current_block_digest:t.digest}))},"#maybeLogBlockAdvanced"),Kk=x(function(t,e){(async()=>{try{await t.applyInitialStream(v(this,Oe),e)}catch{return}t===v(this,Se)&&!t.connected&&B(this,R,Za).call(this)&&B(this,R,Zd).call(this)?B(this,R,eo).call(this,t):t===v(this,Se)&&!t.connected&&B(this,R,Za).call(this)&&B(this,R,ef).call(this,t)})()},"#applyInitialPreloadStream"),Gk=x(function(t,e){const r=v(this,Ct),s=v(this,Ge).networkId,n=v(this,Oe),i=v(this,Xr),a=x(()=>{B(this,R,Ri).call(this,"block_state_available")},"logSyncReady"),c=x(h=>{B(this,R,Hg).call(this,h,"preload")},"logBlockAdvanced");return{[Symbol.asyncIterator]:x(async function*(){try{for await(const h of t)yield h}finally{e.applied=!0,e.resolveApplied();const h=i.getCurrent();n.log.debug("preload.phase",{phase:"applied",client_instance_id:r,network_id:s,has_current_block:!!h,current_block_height:h==null?void 0:h.height,current_block_digest:h==null?void 0:h.digest}),h&&c(h),a()}},"trackedInitialPreloadApply")}},"#trackInitialPreloadApply"),Vk=x(function(t,e){const r=t.headers.get(uA),s=t.headers.get(dA),n=!!r&&!!s,i=n?Number(r):void 0,a=n?Number(s):void 0,c=n&&Number.isFinite(i)&&Number.isFinite(a);v(this,Oe).log.debug("preload.clock_sync",{client_instance_id:v(this,Ct),network_id:v(this,Ge).networkId,valid:c,has_t2:!!r,has_t3:!!s,t2:r??void 0,t3:s??void 0,started_at:e,invalid_reason:n?c?void 0:"invalid_headers":"missing_headers"}),!(!n||!c)&&v(this,xn).sync(e,i,a)},"#syncClockFromPreloadResponse"),Yk=x(async function(){B(this,R,Qd).call(this),typeof document<"u"&&document.addEventListener("visibilitychange",v(this,rf)),typeof window<"u"&&window.addEventListener("beforeunload",v(this,sf))},"#bootstrap"),Jk=x(function(t){var e;const r=(e=v(this,Er))==null?void 0:e.transport;return!(r!=null&&r.isConnected)||r.connectionPromise?!1:v(this,Ge).disableSync||!v(this,Se)?!0:v(this,Se).connected&&t},"#isWireSocketReadyForRequests"),Xk=x(function(t,e){const r=v(this,Ga);if(!r||r.applied)return It(t,n=>({responses:n,winner:"pipeline"}));const s=Promise.resolve(t);return Promise.race([s.then(n=>({responses:n,winner:"pipeline"})),(async()=>{await r.appliedPromise;const n=await B(this,R,Qk).call(this,e);return n?{responses:n,winner:"preload_local"}:s.then(i=>({responses:i,winner:"pipeline"}))})()])},"#raceInitialPreloadApply"),Qk=x(async function(t){const e=[];for(const r of t){if(r.id===void 0)continue;const s=await B(this,R,Zk).call(this,r);if(!s)return;e.push(s)}return e},"#tryResolveRequestsFromLocalState"),Zk=x(function(t){const e=uh(t.method),r=B(this,R,Gg).call(this),s=v(this,Xr).getCurrent();if(e==="eth_blockNumber"){const c=t.params;return Array.isArray(c)&&c.length>0||!(r!=null&&r.height)||t.id===void 0?void 0:Bi({id:t.id,result:r.height})}const n=ah(t,e,s==null?void 0:s.height);if(!Ef(n))return;const i=Ht(n,s==null?void 0:s.digest),a=v(this,Ka).getFromMemory(i,t,e,r==null?void 0:r.height);return It(a,c=>{if(!(!c||t.id===void 0))return Bi({...c,id:t.id})})},"#resolveRequestFromLocalState"),e0=x(function(t,e,r,s,n){var i;if(B(this,R,t0).call(this,r,s,n))return!0;if(!((i=v(this,Se))!=null&&i.connected)||!r||!e)return!1;for(const a of t){const c=uh(a.method),h=ah(a,c,e==null?void 0:e.height);if(v(this,Hd).hasFingerprint(h))return!1}return!0},"#shouldBypassCache"),t0=x(function(t,e,r){return e||t?!1:r!==void 0&&!r.applied||B(this,R,af).call(this)},"#shouldBypassCacheDuringStartup"),r0=x(function(t,e){const r=Array.isArray(t)?t.filter(s=>s!==void 0).map(Bi):(async()=>{const s=[];for await(const n of t)n!==void 0&&s.push(Bi(n));return s})();return It(r,s=>{const n=new Map(e.map(i=>[i.id,i]));for(const i of s){const a=n.get(i.id);switch(a==null?void 0:a.method){case"eth_getTransactionReceipt":case"direct_getTransactionReceipt":{const c=x1.safeParse(i);c!==qc&&v(this,Xr).setMinimum(c.result.blockNumber,y(45e3))}}}return s})},"#processResponses"),s0=x(function(){const t=v(this,Yd);if(!(!t||v(this,Gl).isPast(t.expiresAt)))return{token:t.token,expiresAt:t.expiresAt}},"#getSecondaryRoutingContext"),Kg=x(function(){const t=v(this,Vd);if(!(!t||v(this,Gl).isPast(t.expiresAt)))return t},"#getSecondaryBlockContext"),Gg=x(function(){const t=v(this,Xr).getCurrent(),e=B(this,R,Kg).call(this);return t?e&&Wn(e.height,t.height)?e:t:e},"#getBestKnownBlockContext"),rf=new WeakMap,sf=new WeakMap,nf=x(function(){if(clearTimeout(v(this,Ja)),!v(this,Se))return;const t=v(this,Jl),e=t==null?v(this,Jd)+ar.INITIAL_SYNC_INACTIVITY_MS:t+ar.IDLE_DISCONNECT_MS,r=Math.max(0,e-y());V(this,Ja,setTimeout(()=>{var s;if((s=v(this,Se))!=null&&s.connected){if(B(this,R,Za).call(this)){B(this,R,nf).call(this);return}B(this,R,tf).call(this,v(this,Se),"idle_timeout").catch(()=>{})}},r))},"#scheduleIdleDisconnect"),n0=x(async function(t){const e=v(this,Se);if(!(e!=null&&e.connected))return;if(v(this,Ei))return v(this,Ei);const r=y();if(!(v(this,Vl)!=null&&r-v(this,Vl)<ar.SYNC_RECOVERY_COOLDOWN_MS))return V(this,Vl,r),V(this,Ei,(async()=>{v(this,Oe).log.info("sync.rebuild",{client_instance_id:v(this,Ct),network_id:v(this,Ge).networkId,reason:t}),await B(this,R,tf).call(this,e,"sync_rebuild").catch(()=>{}),!v(this,Xa).signal.aborted&&v(this,Se)===e&&V(this,Se,B(this,R,Lg).call(this))})().finally(()=>{V(this,Ei,void 0)})),v(this,Ei)},"#recoverContinuumSync"),af=x(function(){const t=v(this,Nd);return t!=null&&!v(this,xn).isPast(t)},"#isWithinContinuumSyncGraceWindow"),Xl=x(function(t,e=!1){var r;if((r=v(this,Er))!=null&&r.transport.isConnected&&!e)return v(this,Er).emit.telemetry(v(this,Oe),t);try{return e?v(this,Ya).emit.telemetry(v(this,Oe),t,"beacon"):v(this,Ya).emit.telemetry(v(this,Oe),t)}catch{}},"#dispatchTelemetry"),x(ar,"DirectRPCClient"),jd(ar,"INITIAL_SYNC_INACTIVITY_MS",1e4),jd(ar,"IDLE_DISCONNECT_MS",6e4),jd(ar,"SYNC_RECOVERY_COOLDOWN_MS",3e3),jd(ar,"SYNC_BOOTSTRAP_GRACE_MS",1e3),G(ar,Ng,1);let Q1=ar;function Bi(t){return{jsonrpc:"2.0",...t}}o(Bi,"H"),x(Bi,"addJsonRpc");var Z1=Object.defineProperty,a0=o((t,e)=>Z1(t,"name",{value:e,configurable:!0}),"i$1");const o0={silent:1/0,error:40,warn:30,info:20,debug:10};function c0(t,e){if(!(t!=null&&t.onEvent))return!1;const r=t.client??"warn";return o0[e]>=o0[r]}o(c0,"d$1"),a0(c0,"shouldEmitClientLevel");function Ii(t,e,r,s="debug"){if(!c0(t,s))return;const n=t==null?void 0:t.onEvent;n&&n({level:s,name:e,value:r,timestamp:Date.now()})}o(Ii,"emitFetchLogEvent"),a0(Ii,"emitFetchLogEvent");var eM=Object.defineProperty,Ql=o((t,e)=>eM(t,"name",{value:e,configurable:!0}),"t");const tM=Ql(t=>t instanceof URL?t:typeof t=="string"?l0(t):typeof Request<"u"&&t instanceof Request?l0(t.url):null,"resolveUrl"),l0=Ql(t=>{try{return new URL(t)}catch{return null}},"safeUrl"),h0=Ql(t=>{if(!u0(t.hostname))return null;const e=t.pathname.split("/").filter(Boolean),[r,s,n]=e;if(e.length!==3||r!=="v1"||!s||!n)return null;const i=s.indexOf(".");return i<=0||i===s.length-1?null:{projectId:s.slice(0,i),projectToken:s.slice(i+1),networkId:rM(n),baseUrl:t.origin}},"parseDirectUrl"),u0=Ql(t=>A0.has(t),"isAllowedHost"),rM=Ql(t=>{if(!t.includes("%"))return t;try{return decodeURIComponent(t)}catch{return t}},"safeDecode");var sM=Object.defineProperty,Yg=o((t,e)=>sM(t,"name",{value:e,configurable:!0}),"r$1");const nM=Yg(t=>{const e=new Map;return{getClientForUrl:Yg(r=>{const s=iM(r),n=e.get(s);if(n)return Ii(t.logging,"client.phase",{phase:"reused",client_instance_id:n.client.getClientInstanceId(),cache_key:s,project_id:n.config.projectId,network_id:n.config.networkId},"info"),n;const i=h0(r);if(!i)return null;Ii(t.logging,"client.phase",{phase:"creating",cache_key:s,project_id:i.projectId,network_id:i.networkId,base_url:i.baseUrl},"info");const a=new Q1({projectId:i.projectId,projectToken:i.projectToken,networkId:i.networkId,logging:t.logging,baseUrl:i.baseUrl,fetch:t.baseFetch,createWebSocket:t.createWebSocket}),c={client:a,config:i};return e.set(s,c),Ii(t.logging,"client.phase",{phase:"created",client_instance_id:a.getClientInstanceId(),cache_key:s,project_id:i.projectId,network_id:i.networkId},"info"),c},"getClientForUrl")}},"createClientPool"),iM=Yg(t=>{let e=t.pathname;for(;e.endsWith("/");)e=e.slice(0,-1);return`${t.origin}${e}`},"buildUrlCacheKey");var aM=Object.defineProperty,Jg=o((t,e)=>aM(t,"name",{value:e,configurable:!0}),"s$1");const oM=new Set(["direct_client_preload","direct_client_status"]),cM=Jg(t=>typeof t=="string"&&oM.has(t),"isDirectClientMethod"),d0=Jg((t,e)=>{var r,s;const{method:n,id:i}=t;if(!cM(n))return{kind:"not_handled"};if(i===void 0)return{kind:"notification"};const{directConfig:a}=e;switch(n==="direct_client_preload"&&Ii(e.logging,"preload.phase",{phase:"command_handled",client_instance_id:e.clientInstanceId,method:n,network_id:a.networkId,project_id:a.projectId,has_response:i!==void 0}),n){case"direct_client_preload":return{kind:"response",response:{jsonrpc:"2.0",result:"ok",id:i}};case"direct_client_status":return{kind:"response",response:{jsonrpc:"2.0",result:{initialized:!0,projectId:a.projectId,projectToken:a.projectToken,networkId:a.networkId,baseUrl:a.baseUrl,logging:{client:(r=e.logging)==null?void 0:r.client,requests:(s=e.logging)==null?void 0:s.requests}},id:i}};default:return{kind:"not_handled"}}},"handleSingleDirectMethod"),lM=Jg((t,e)=>{if(!Array.isArray(t)){const n=d0(t,e);switch(n.kind){case"response":return{handled:[n.response],forward:null};case"notification":return{handled:[],forward:null};case"not_handled":return{handled:[],forward:t}}}const r=[],s=[];for(const n of t){const i=d0(n,e);switch(i.kind){case"response":r.push(i.response);break;case"notification":break;case"not_handled":s.push(n);break}}return{handled:r,forward:s.length>0?s:null}},"handleDirectMethods"),hM=ke("createFetchOptions",l.shape({fetch:l.unknown.optional,createWebSocket:l.unknown.optional,logging:l.shape({client:l.literal("silent","info","debug","warn","error").optional,requests:l.literal("off","summary","debug").optional,onEvent:l.unknown.optional}).optional,preload:l.arr(l.str).optional}));var uM=Object.defineProperty,dM=o((t,e)=>uM(t,"name",{value:e,configurable:!0}),"c$1");const fM=dM((t,e,r)=>{if(!Array.isArray(t))return e[0]??r[0];if(e.length===0)return r;if(r.length===0)return e;const s=new Map;for(const i of r)i.id!==void 0&&s.set(i.id,i);const n=new Map;for(const i of e)i.id!==void 0&&n.set(i.id,i);return t.filter(i=>i.id!==void 0).map(i=>{const a=i.id;return n.get(a)??s.get(a)??{jsonrpc:"2.0",error:{code:-32603,message:"Internal error"},id:a}})},"mergeResults");var pM=Object.defineProperty,Xg=o((t,e)=>pM(t,"name",{value:e,configurable:!0}),"o$1");const f0=typeof TextDecoder<"u"?new TextDecoder:null,Qg=Xg(t=>{try{const e=JSON.parse(t);return e&&typeof e=="object"?e:null}catch{return null}},"parseJson"),mM=Xg(t=>{if(!f0)return null;const e=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return Qg(f0.decode(e))},"parseBufferSource"),gM=Xg(async(t,e)=>{if((e==null?void 0:e.body)!=null){const{body:r}=e;if(typeof r=="string")return Qg(r);if(typeof Blob<"u"&&r instanceof Blob){const s=await r.text().catch(()=>null);return s===null?null:Qg(s)}return r instanceof ArrayBuffer||ArrayBuffer.isView(r)?mM(r):null}if(typeof Request<"u"&&t instanceof Request){if(!t.body||t.bodyUsed)return null;try{const r=await t.clone().json();if(r&&typeof r=="object")return r}catch{}}return null},"readJsonPayloadInput");var wM=Object.defineProperty,Zg=o((t,e)=>wM(t,"name",{value:e,configurable:!0}),"n");const vM=Zg(()=>{if(typeof document>"u")return[];try{const t=document.querySelectorAll('link[rel="preload"][href*="direct.dev"]'),e=[];for(const r of t)r.href&&e.push(r.href);return e}catch{return[]}},"getPreloadLinksFromDOM"),_M=Zg(t=>t?[...new Set(t)]:[...new Set(vM())],"collectPreloadUrls"),yM=Zg((t,e,r)=>{var s;for(const n of e)(s=r==null?void 0:r.onDispatch)==null||s.call(r,n),t(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:"direct_client_preload",params:[],id:1})}).catch(()=>{})},"preloadUrls");var bM=Object.defineProperty,qi=o((t,e)=>bM(t,"name",{value:e,configurable:!0}),"e");const $M=qi((t,e)=>{let r=!1,s=null;const n=qi(()=>{if(s===null){const f=JSON.stringify(t);s=f===void 0?"null":f}return s},"getBody"),i=new Response(kM(n),{status:200,headers:{...C0,[S0]:String(e)}}),a=Object.getOwnPropertyDescriptor(Response.prototype,"bodyUsed"),c=a!=null&&a.get?()=>{var f;return(f=a.get)==null?void 0:f.call(i)}:()=>!1,h=qi(()=>r||c(),"isBodyUsed"),u=qi(async()=>{if(h())throw new TypeError("Body has already been consumed.");if(r=!0,i.body)try{await i.body.cancel()}catch{}},"consumeOnce"),d=qi(async()=>(await u(),t),"json"),p=qi(async()=>(await u(),n()),"text");try{Object.defineProperty(i,"bodyUsed",{get:h})}catch{}return Object.defineProperties(i,{json:{value:d},text:{value:p}}),i},"createJsonResponse"),kM=qi(t=>{if(typeof ReadableStream>"u"||!cw)return t();const e=cw;return new ReadableStream({pull(r){r.enqueue(e.encode(t())),r.close()}})},"createLazyBody");var CM=Object.defineProperty,p0=o((t,e)=>CM(t,"name",{value:e,configurable:!0}),"o");const m0=p0(()=>typeof performance<"u"?performance.now():Date.now(),"getTimingNow"),SM=p0(t=>Number(t.toFixed(2)),"formatDuration");var AM=Object.defineProperty,Zl=o((t,e)=>AM(t,"name",{value:e,configurable:!0}),"l");let of=!1,g0=0,ew;const w0=Zl((t={})=>{var e;const r=hM.parse(t),s=(e=globalThis.fetch)==null?void 0:e.bind(globalThis);if(of&&!r.fetch)throw new Error("Cannot call createFetch() after install(). Use the globally installed fetch or call uninstall() first.");const n=r.fetch??s,i=r.logging;if(!n)throw new Error(E0);if(!globalThis.Response)throw new Error(M0);if(!globalThis.Request)throw new Error(T0);const a=nM({logging:i,baseFetch:n,createWebSocket:r.createWebSocket}),c=Zl(async(u,d)=>{var p;const f=tM(u);if(!f||!u0(f.hostname)||(((p=d==null?void 0:d.method)==null?void 0:p.toUpperCase())??(u instanceof Request?u.method.toUpperCase():"GET"))!=="POST")return n(u,d);const g=a.getClientForUrl(f);if(!g)return n(u,d);const m=await gM(u,d);if(!m)return n(u,d);const{handled:w,forward:_}=lM(m,{directConfig:g.config,logging:i,clientInstanceId:g.client.getClientInstanceId()}),S=m0();let b=[];if(_)try{const W=await g.client.fetch(_);b=(Array.isArray(W)?W:[W]).filter(K=>K!==void 0)}catch(W){const K=Array.isArray(_)?_.map(Pe=>Pe.method).join(", "):_.method,q=W instanceof Error?W.message:String(W);throw new Error(`direct.dev fetch failed [${g.config.networkId}] (${K}): ${q}`)}const O=SM(m0()-S);if(!Array.isArray(m)&&m.id===void 0)return new Response(null,{status:204});const j=fM(m,w,b);return Array.isArray(j)&&j.length===0?new Response(null,{status:204}):$M(j,O)},"wrappedFetch"),h=_M(r.preload);return Ii(i,"preload.phase",{phase:"urls_collected",source:r.preload?"config":"dom",url_count:h.length,urls:h}),h.length&&yM(c,h,{onDispatch:Zl(u=>{const d=h0(new URL(u));Ii(i,"preload.phase",{phase:"command_sent",url:u,method:"direct_client_preload",network_id:d==null?void 0:d.networkId,project_id:d==null?void 0:d.projectId})},"onDispatch")}),c},"createFetch"),EM=Zl((t={})=>{if(of)return ew??(()=>{});const e=globalThis.fetch,r=e==null?void 0:e.bind(globalThis),s=w0({...t,fetch:t.fetch??r});globalThis.fetch=s,of=!0;const n=++g0,i=Zl(()=>{g0===n&&(globalThis.fetch=e,of=!1,ew=void 0)},"uninstall");return ew=i,i},"install");export{w0 as createFetch,EM as install};
5
5
  //# sourceMappingURL=index.mjs.map