@libp2p/devtools-metrics 0.2.4 → 0.2.5
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/dist/index.min.js +1 -1
- package/package.json +7 -7
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PDevtoolsMetrics = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PDevtoolsMetrics=(()=>{var Gs=Object.create;var Ft=Object.defineProperty;var js=Object.getOwnPropertyDescriptor;var qs=Object.getOwnPropertyNames;var Hs=Object.getPrototypeOf,Xs=Object.prototype.hasOwnProperty;var Ws=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),H=(r,e)=>{for(var t in e)Ft(r,t,{get:e[t],enumerable:!0})},Hn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of qs(e))!Xs.call(r,o)&&o!==t&&Ft(r,o,{get:()=>e[o],enumerable:!(n=js(e,o))||n.enumerable});return r};var Ks=(r,e,t)=>(t=r!=null?Gs(Hs(r)):{},Hn(e||!r||!r.__esModule?Ft(t,"default",{value:r,enumerable:!0}):t,r)),Js=r=>Hn(Ft({},"__esModule",{value:!0}),r);var xo=Ws((Vf,wo)=>{"use strict";function yo(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function zc(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return yo(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),yo(new o,t)}}wo.exports=zc});var ul={};H(ul,{LIBP2P_DEVTOOLS_METRICS_KEY:()=>zs,SOURCE_CONTENT_SCRIPT:()=>cl,SOURCE_DEVTOOLS:()=>Os,SOURCE_METRICS:()=>Vs,SOURCE_SERVICE_WORKER:()=>sl,devToolsMetrics:()=>al,valueCodecs:()=>Gn});var _t=Symbol.for("@libp2p/peer-id");function Xn(r){return r!=null&&!!r[_t]}var Mt=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};function Wn(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function Kn(...r){let e=[];for(let t of r)Wn(t)&&e.push(t);await Promise.all(e.map(async t=>{t.beforeStart!=null&&await t.beforeStart()})),await Promise.all(e.map(async t=>{await t.start()})),await Promise.all(e.map(async t=>{t.afterStart!=null&&await t.afterStart()}))}async function Jn(...r){let e=[];for(let t of r)Wn(t)&&e.push(t);await Promise.all(e.map(async t=>{t.beforeStop!=null&&await t.beforeStop()})),await Promise.all(e.map(async t=>{await t.stop()})),await Promise.all(e.map(async t=>{t.afterStop!=null&&await t.afterStop()}))}var Dt=Symbol.for("@libp2p/service-capabilities"),pl=Symbol.for("@libp2p/service-dependencies");var Ur={};H(Ur,{base32:()=>se,base32hex:()=>ic,base32hexpad:()=>cc,base32hexpadupper:()=>ac,base32hexupper:()=>sc,base32pad:()=>nc,base32padupper:()=>oc,base32upper:()=>rc,base32z:()=>uc});var Pl=new Uint8Array(0);function Qn(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function pe(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Zn(r){return new TextEncoder().encode(r)}function Yn(r){return new TextDecoder().decode(r)}function Qs(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var c=r.length,u=r.charAt(0),h=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function f(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var x=0,m=0,C=0,U=y.length;C!==U&&y[C]===0;)C++,x++;for(var N=(U-C)*l+1>>>0,F=new Uint8Array(N);C!==U;){for(var j=y[C],Z=0,q=N-1;(j!==0||Z<m)&&q!==-1;q--,Z++)j+=256*F[q]>>>0,F[q]=j%c>>>0,j=j/c>>>0;if(j!==0)throw new Error("Non-zero carry");m=Z,C++}for(var Y=N-m;Y!==N&&F[Y]===0;)Y++;for(var Be=u.repeat(x);Y<N;++Y)Be+=r.charAt(F[Y]);return Be}function g(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var x=0;if(y[x]!==" "){for(var m=0,C=0;y[x]===u;)m++,x++;for(var U=(y.length-x)*h+1>>>0,N=new Uint8Array(U);y[x];){var F=t[y.charCodeAt(x)];if(F===255)return;for(var j=0,Z=U-1;(F!==0||j<C)&&Z!==-1;Z--,j++)F+=c*N[Z]>>>0,N[Z]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");C=j,x++}if(y[x]!==" "){for(var q=U-C;q!==U&&N[q]===0;)q++;for(var Y=new Uint8Array(m+(U-q)),Be=m;q!==U;)Y[Be++]=N[q++];return Y}}}function b(y){var x=g(y);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:g,decode:b}}var Zs=Qs,Ys=Zs,to=Ys;var Ar=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},kr=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ro(this,e)}},Ir=class{decoders;constructor(e){this.decoders=e}or(e){return ro(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function ro(r,e){return new Ir({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Tr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ar(e,t,n),this.decoder=new kr(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Re({name:r,prefix:e,encode:t,decode:n}){return new Tr(r,e,t,n)}function we({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=to(t,r);return Re({prefix:e,name:r,encode:n,decode:i=>pe(o(i))})}function ec(r,e,t,n){let o={};for(let l=0;l<e.length;++l)o[e[l]]=l;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*t/8|0),c=0,u=0,h=0;for(let l=0;l<i;++l){let f=o[r[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<t|f,c+=t,c>=8&&(c-=8,s[h++]=255&u>>c)}if(c>=t||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s}function tc(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],s+=8;s>t;)s-=t,i+=e[o&c>>s];if(s!==0&&(i+=e[o&c<<t-s]),n)for(;i.length*t&7;)i+="=";return i}function T({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Re({prefix:e,name:r,encode(o){return tc(o,n,t)},decode(o){return ec(o,n,t,r)}})}var se=T({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),rc=T({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),nc=T({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),oc=T({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ic=T({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),sc=T({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),cc=T({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ac=T({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),uc=T({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Nr={};H(Nr,{base58btc:()=>L,base58flickr:()=>lc});var L=we({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),lc=we({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Lr={};H(Lr,{base64:()=>de,base64pad:()=>fc,base64url:()=>dc,base64urlpad:()=>hc});var de=T({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),fc=T({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),dc=T({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),hc=T({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function pc(r,e){try{if(typeof r=="string"&&r.length>0)return mc(r);if(typeof r=="number"&&isFinite(r))return e?.long?yc(r):gc(r);throw new Error("Value is not a string or number.")}catch(t){let n=wc(t)?`${t.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function mc(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!e)return NaN;let t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*315576e5;case"weeks":case"week":case"w":return t*6048e5;case"days":case"day":case"d":return t*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return t*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return t*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return t*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Rt=pc;function gc(r){let e=Math.abs(r);return e>=864e5?`${Math.round(r/864e5)}d`:e>=36e5?`${Math.round(r/36e5)}h`:e>=6e4?`${Math.round(r/6e4)}m`:e>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function yc(r){let e=Math.abs(r);return e>=864e5?Bt(r,e,864e5,"day"):e>=36e5?Bt(r,e,36e5,"hour"):e>=6e4?Bt(r,e,6e4,"minute"):e>=1e3?Bt(r,e,1e3,"second"):`${r} ms`}function Bt(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function wc(r){return typeof r=="object"&&r!==null&&"message"in r}function Fr(r){t.debug=t,t.default=t,t.coerce=u,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Rt,t.destroy=h,Object.keys(r).forEach(l=>{t[l]=r[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let g=0;g<l.length;g++)f=(f<<5)-f+l.charCodeAt(g),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,g=null,b,y;function x(...m){if(!x.enabled)return;let C=x,U=Number(new Date),N=U-(f||U);C.diff=N,C.prev=f,C.curr=U,f=U,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let F=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(Z,q)=>{if(Z==="%%")return"%";F++;let Y=t.formatters[q];if(typeof Y=="function"){let Be=m[F];Z=Y.call(C,Be),m.splice(F,1),F--}return Z}),t.formatArgs.call(C,m),(C.log||t.log).apply(C,m)}return x.namespace=l,x.useColors=t.useColors(),x.color=t.selectColor(l),x.extend=n,x.destroy=t.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>g!==null?g:(b!==t.namespaces&&(b=t.namespaces,y=t.enabled(l)),y),set:m=>{g=m}}),typeof t.init=="function"&&t.init(x),x}function n(l,f){let g=t(this.namespace+(typeof f>"u"?":":f)+l);return g.log=this.log,g}function o(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,g=(typeof l=="string"?l:"").split(/[\s,]+/),b=g.length;for(f=0;f<b;f++)g[f]&&(l=g[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.substr(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function i(){let l=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),l}function s(l){if(l[l.length-1]==="*")return!0;let f,g;for(f=0,g=t.skips.length;f<g;f++)if(t.skips[f].test(l))return!1;for(f=0,g=t.names.length;f<g;f++)if(t.names[f].test(l))return!0;return!1}function c(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function u(l){return l instanceof Error?l.stack??l.message:l}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.setupFormatters(t.formatters),t.enable(t.load()),t}var Pt=Ac(),xc=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function bc(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function Ec(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Rt(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}var vc=console.debug??console.log??(()=>{});function Sc(r){try{r?Pt?.setItem("debug",r):Pt?.removeItem("debug")}catch{}}function Cc(){let r;try{r=Pt?.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Ac(){try{return localStorage}catch{}}function kc(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var no=Fr({formatArgs:Ec,save:Sc,load:Cc,useColors:bc,setupFormatters:kc,colors:xc,storage:Pt,log:vc});var O=no;O.formatters.b=r=>r==null?"undefined":L.baseEncode(r);O.formatters.t=r=>r==null?"undefined":se.baseEncode(r);O.formatters.m=r=>r==null?"undefined":de.baseEncode(r);O.formatters.p=r=>r==null?"undefined":r.toString();O.formatters.c=r=>r==null?"undefined":r.toString();O.formatters.k=r=>r==null?"undefined":r.toString();O.formatters.a=r=>r==null?"undefined":r.toString();function Ic(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function oo(r){let e=Ic(`${r}:trace`);return O.enabled(`${r}:trace`)&&O.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=O(`${r}:trace`)),Object.assign(O(r),{error:O(`${r}:error`),trace:e})}function io(){O.disable()}function so(r){O.enable(r)}function Tc(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var co=Tc;function Uc(r){return r[Symbol.asyncIterator]!=null}function ao(r){return r?.then!=null}function Nc(r,e){let t=0;if(Uc(r))return async function*(){for await(let u of r){let h=e(u,t++);ao(h)&&await h,yield u}}();let n=co(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();if(typeof e(o,t++)?.then=="function")return async function*(){yield o;for await(let u of n){let h=e(u,t++);ao(h)&&await h,yield u}}();let c=e;return function*(){yield o;for(let u of n)c(u,t++),yield u}()}var _r=Nc;var Lc=oo("libp2p:simple-metrics"),it=class{value=0;update(e){this.value=e}increment(e=1){this.value+=e}decrement(e=1){this.value-=e}reset(){this.value=0}timer(){let e=Date.now();return()=>{this.value=Date.now()-e}}},st=class{values={};update(e){Object.entries(e).forEach(([t,n])=>{this.values[t]=n})}increment(e){Object.entries(e).forEach(([t,n])=>{this.values[t]=this.values[t]??0;let o=typeof n=="number"?n:1;this.values[t]+=Number(o)})}decrement(e){Object.entries(e).forEach(([t,n])=>{this.values[t]=this.values[t]??0;let o=typeof n=="number"?n:1;this.values[t]-=Number(o)})}reset(){this.values={}}timer(e){let t=Date.now();return()=>{this.values[e]=Date.now()-t}}},Mr=class{metrics=new Map;transferStats;started;interval;intervalMs;onMetrics;constructor(e,t){this.started=!1,this._emitMetrics=this._emitMetrics.bind(this),this.intervalMs=t.intervalMs??1e3,this.onMetrics=t.onMetrics,this.transferStats=new Map}[Symbol.toStringTag]="@libp2p/metrics-simple";[Dt]=["@libp2p/metrics"];isStarted(){return this.started}start(){this.started=!0,this.interval=setInterval(this._emitMetrics,this.intervalMs)}stop(){this.started=!1,clearInterval(this.interval)}_emitMetrics(){Promise.resolve().then(async()=>{let e={};for(let[t,n]of this.metrics.entries())n instanceof it?e[t]=n.value:n instanceof st?e[t]=n.values:e[t]=await n();this.onMetrics(structuredClone(e))}).catch(e=>{Lc.error("could not invoke onMetrics callback",e)})}_incrementValue(e,t){let n=this.transferStats.get(e)??0;this.transferStats.set(e,n+t)}_track(e,t){let n=this,o=e.sink;e.sink=async function(c){await o(_r(c,u=>{n._incrementValue(`${t} sent`,u.byteLength)}))};let i=e.source;e.source=_r(i,s=>{n._incrementValue(`${t} received`,s.byteLength)})}trackMultiaddrConnection(e){this._track(e,"global")}trackProtocolStream(e,t){e.protocol!=null&&this._track(e,e.protocol)}registerMetric(e,t={}){if(e==null||e.trim()==="")throw new Error("Metric name is required");if(t?.calculate!=null){this.metrics.set(e,t.calculate);return}let n=new it;return this.metrics.set(e,n),n}registerMetricGroup(e,t={}){if(e==null||e.trim()==="")throw new Error("Metric name is required");if(t?.calculate!=null){this.metrics.set(e,t.calculate);return}let n=new st;return this.metrics.set(e,n),n}registerCounter(e,t={}){if(e==null||e.trim()==="")throw new Error("Metric name is required");if(t?.calculate!=null){this.metrics.set(e,t.calculate);return}let n=new it;return this.metrics.set(e,n),n}registerCounterGroup(e,t={}){if(e==null||e.trim()==="")throw new Error("Metric name is required");if(t?.calculate!=null){this.metrics.set(e,t.calculate);return}let n=new st;return this.metrics.set(e,n),n}};function uo(r){return e=>new Mr(e,r)}function ce(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var $t=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},Pe=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new $t(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new $t(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var Dr=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function xe(r={}){return Fc(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Fc(r,e){e=e??{};let t=e.onEnd,n=new Pe,o,i,s,c=ce(),u=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((m,C)=>{i=U=>{i=null,n.push(U);try{m(r(n))}catch(N){C(N)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=ce()})}},h=m=>i!=null?i(m):(n.push(m),o),l=m=>(n=new Pe,i!=null?i({error:m}):(n.push({error:m}),o)),f=m=>{if(s)return o;if(e?.objectMode!==!0&&m?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return h({done:!1,value:m})},g=m=>s?o:(s=!0,m!=null?l(m):h({done:!0})),b=()=>(n=new Pe,g(),{done:!0}),y=m=>(g(m),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:u,return:b,throw:y,push:f,end:g,get readableLength(){return n.size},onEmpty:async m=>{let C=m?.signal;if(C?.throwIfAborted(),n.isEmpty())return;let U,N;C!=null&&(U=new Promise((F,j)=>{N=()=>{j(new Dr)},C.addEventListener("abort",N)}));try{await Promise.race([c.promise,U])}finally{N!=null&&C!=null&&C?.removeEventListener("abort",N)}}},t==null)return o;let x=o;return o={[Symbol.asyncIterator](){return this},next(){return x.next()},throw(m){return x.throw(m),t!=null&&(t(m),t=void 0),{done:!0}},return(){return x.return(),t!=null&&(t(),t=void 0),{done:!0}},push:f,end(m){return x.end(m),t!=null&&(t(m),t=void 0),o},get readableLength(){return x.readableLength},onEmpty:m=>x.onEmpty(m)},o}function _c(r){return r[Symbol.asyncIterator]!=null}function Mc(...r){let e=[];for(let t of r)_c(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=xe({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)t.push(o)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var lo=Mc;function fo(r,...e){if(r==null)throw new Error("Empty pipeline");if(Br(r)){let n=r;r=()=>n.source}else if(po(r)||ho(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&Br(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)Br(t[n])&&(t[n]=Bc(t[n]));return Dc(...t)}var Dc=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},ho=r=>r?.[Symbol.asyncIterator]!=null,po=r=>r?.[Symbol.iterator]!=null,Br=r=>r==null?!1:r.sink!=null&&r.source!=null,Bc=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=xe({objectMode:!0});t.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(ho(i))o=async function*(){yield*i,n.end()};else if(po(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return lo(n,o())}return r.source};function Ot(r){let e=new globalThis.AbortController;function t(){e.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}for(let i of r){if(i?.aborted===!0){t();break}i?.addEventListener!=null&&i.addEventListener("abort",t)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}let o=e.signal;return o.clear=n,o}function ae(r=0){return new Uint8Array(r)}function R(r=0){return new Uint8Array(r)}var Rc=Math.pow(2,7),Pc=Math.pow(2,14),$c=Math.pow(2,21),Rr=Math.pow(2,28),Pr=Math.pow(2,35),$r=Math.pow(2,42),Or=Math.pow(2,49),S=128,P=127;function _(r){if(r<Rc)return 1;if(r<Pc)return 2;if(r<$c)return 3;if(r<Rr)return 4;if(r<Pr)return 5;if(r<$r)return 6;if(r<Or)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Vr(r,e,t=0){switch(_(r)){case 8:e[t++]=r&255|S,r/=128;case 7:e[t++]=r&255|S,r/=128;case 6:e[t++]=r&255|S,r/=128;case 5:e[t++]=r&255|S,r/=128;case 4:e[t++]=r&255|S,r>>>=7;case 3:e[t++]=r&255|S,r>>>=7;case 2:e[t++]=r&255|S,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Oc(r,e,t=0){switch(_(r)){case 8:e.set(t++,r&255|S),r/=128;case 7:e.set(t++,r&255|S),r/=128;case 6:e.set(t++,r&255|S),r/=128;case 5:e.set(t++,r&255|S),r/=128;case 4:e.set(t++,r&255|S),r>>>=7;case 3:e.set(t++,r&255|S),r>>>=7;case 2:e.set(t++,r&255|S),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function zr(r,e){let t=r[e],n=0;if(n+=t&P,t<S||(t=r[e+1],n+=(t&P)<<7,t<S)||(t=r[e+2],n+=(t&P)<<14,t<S)||(t=r[e+3],n+=(t&P)<<21,t<S)||(t=r[e+4],n+=(t&P)*Rr,t<S)||(t=r[e+5],n+=(t&P)*Pr,t<S)||(t=r[e+6],n+=(t&P)*$r,t<S)||(t=r[e+7],n+=(t&P)*Or,t<S))return n;throw new RangeError("Could not decode varint")}function Vc(r,e){let t=r.get(e),n=0;if(n+=t&P,t<S||(t=r.get(e+1),n+=(t&P)<<7,t<S)||(t=r.get(e+2),n+=(t&P)<<14,t<S)||(t=r.get(e+3),n+=(t&P)<<21,t<S)||(t=r.get(e+4),n+=(t&P)*Rr,t<S)||(t=r.get(e+5),n+=(t&P)*Pr,t<S)||(t=r.get(e+6),n+=(t&P)*$r,t<S)||(t=r.get(e+7),n+=(t&P)*Or,t<S))return n;throw new RangeError("Could not decode varint")}function be(r,e,t=0){return e==null&&(e=R(_(r))),e instanceof Uint8Array?Vr(r,e,t):Oc(r,e,t)}function me(r,e=0){return r instanceof Uint8Array?zr(r,e):Vc(r,e)}function ee(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=R(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function ke(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var go=Symbol.for("@achingbrain/uint8arraylist");function mo(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function zt(r){return!!r?.[go]}var $e=class r{bufs;length;[go]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(zt(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(zt(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=mo(this.bufs,e);return t.buf[t.index]}set(e,t){let n=mo(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(zt(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return ee(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:ee(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),i=new r;return i.length=o,i.bufs=[...n],i}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,u=c+s.byteLength;if(o=u,e>=u)continue;let h=e>=c&&e<u,l=t>c&&t<=u;if(h&&l){if(e===c&&t===u){n.push(s);break}let f=e-c;n.push(s.subarray(f,f+(t-e)));break}if(h){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(l){if(t===u){n.push(s);break}n.push(s.subarray(0,t-c));break}n.push(s)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!zt(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let c=s,u=this.byteLength-n.byteLength,h=n.byteLength-1,l;for(let f=t;f<=u;f+=l){l=0;for(let g=h;g>=0;g--){let b=this.get(f+g);if(n[g]!==b){l=Math.max(1,g-c[b]);break}}if(l===0)return f}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=R(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=ae(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=ae(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=ae(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=R(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=ae(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=ae(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=ae(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=ae(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=ae(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!ke(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((o,i)=>o+i.byteLength,0)),n.length=t,n}};function Gt(r){return r[Symbol.asyncIterator]!=null}var jt=r=>{let e=_(r),t=R(e);return be(r,t),jt.bytes=e,t};jt.bytes=0;function qt(r,e){e=e??{};let t=e.lengthEncoder??jt;function*n(o){let i=t(o.byteLength);i instanceof Uint8Array?yield i:yield*i,o instanceof Uint8Array?yield o:yield*o}return Gt(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}qt.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??jt;return new $e(t(r.byteLength),r)};var Oe=Ks(xo(),1);var Gc=8,jc=1024*1024*4,Ie;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Ie||(Ie={}));var Gr=r=>{let e=me(r);return Gr.bytes=_(e),e};Gr.bytes=0;function ct(r,e){let t=new $e,n=Ie.LENGTH,o=-1,i=e?.lengthDecoder??Gr,s=e?.maxLengthLength??Gc,c=e?.maxDataLength??jc;function*u(){for(;t.byteLength>0;){if(n===Ie.LENGTH)try{if(o=i(t),o<0)throw(0,Oe.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>c)throw(0,Oe.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let h=i.bytes;t.consume(h),e?.onLength!=null&&e.onLength(o),n=Ie.DATA}catch(h){if(h instanceof RangeError){if(t.byteLength>s)throw(0,Oe.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw h}if(n===Ie.DATA){if(t.byteLength<o)break;let h=t.sublist(0,o);t.consume(o),e?.onData!=null&&e.onData(h),yield h,n=Ie.LENGTH}}}return Gt(r)?async function*(){for await(let h of r)t.append(h),yield*u();if(t.byteLength>0)throw(0,Oe.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let h of r)t.append(h),yield*u();if(t.byteLength>0)throw(0,Oe.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}ct.fromReader=(r,e)=>{let t=1,n=async function*(){for(;;)try{let{done:i,value:s}=await r.next(t);if(i===!0)return;s!=null&&(yield s)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{t=1}}();return ct(n,{...e??{},onLength:i=>{t=i}})};var bo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Ve=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=bo[t[r]&63];return e};var Ht=class extends Error{constructor(e="Method not found"){super(e),this.name="MethodNotFoundError"}},Xt=class extends Error{constructor(e="Invocation target was not a function"){super(e),this.name="InvalidMethodError"}},at=class extends Error{constructor(e="Unsupported value type"){super(e),this.name="UnsupportedValueTypeError"}},Wt=class extends Error{constructor(e="Cannot reuse RPC target name"){super(e),this.name="DuplicateTargetNameError"}},ut=class extends Error{constructor(e="Duplicate scope"){super(e),this.name="DuplicateScopeError"}},Kt=class extends Error{constructor(e="Invalid return type"){super(e),this.name="InvalidReturnTypeError"}},lt=class extends Error{constructor(e="Invocation target was not a function"){super(e),this.name="InvalidInvocationTypeError"}},ze=class extends Error{constructor(e="Parent invocation scope not found"){super(e),this.name="MissingParentScopeError"}},Jt=class extends Error{constructor(e="Invocation not found"){super(e),this.name="MissingInvocationError"}},Qt=class extends Error{constructor(e="Callback not found"){super(e),this.name="MissingCallbackError"}};var jr=new Float32Array([-0]),Ee=new Uint8Array(jr.buffer);function Eo(r,e,t){jr[0]=r,e[t]=Ee[0],e[t+1]=Ee[1],e[t+2]=Ee[2],e[t+3]=Ee[3]}function vo(r,e){return Ee[0]=r[e],Ee[1]=r[e+1],Ee[2]=r[e+2],Ee[3]=r[e+3],jr[0]}var qr=new Float64Array([-0]),$=new Uint8Array(qr.buffer);function So(r,e,t){qr[0]=r,e[t]=$[0],e[t+1]=$[1],e[t+2]=$[2],e[t+3]=$[3],e[t+4]=$[4],e[t+5]=$[5],e[t+6]=$[6],e[t+7]=$[7]}function Co(r,e){return $[0]=r[e],$[1]=r[e+1],$[2]=r[e+2],$[3]=r[e+3],$[4]=r[e+4],$[5]=r[e+5],$[6]=r[e+6],$[7]=r[e+7],qr[0]}var qc=BigInt(Number.MAX_SAFE_INTEGER),Hc=BigInt(Number.MIN_SAFE_INTEGER),X=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Te;if(e<qc&&e>Hc)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>Ao&&(o=0n,++n>Ao&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return Te;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):Te}},Te=new X(0,0);Te.toBigInt=function(){return 0n};Te.zzEncode=Te.zzDecode=function(){return this};Te.length=function(){return 1};var Ao=4294967296n;function ko(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Io(r,e,t){if(t-e<1)return"";let o,i=[],s=0,c;for(;e<t;)c=r[e++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|r[e++]&63:c>239&&c<365?(c=((c&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Hr(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function ue(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Zt(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Xr=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,ue(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw ue(this,4);return Zt(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ue(this,4);return Zt(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw ue(this,4);let e=vo(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw ue(this,4);let e=Co(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw ue(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Io(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw ue(this,e);this.pos+=e}else do if(this.pos>=this.len)throw ue(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new X(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw ue(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw ue(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw ue(this,8);let e=Zt(this.buf,this.pos+=4),t=Zt(this.buf,this.pos+=4);return new X(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=zr(this.buf,this.pos);return this.pos+=_(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Wr(r){return new Xr(r instanceof Uint8Array?r:r.subarray())}function te(r,e,t){let n=Wr(r);return e.decode(n,void 0,t)}var Kr={};H(Kr,{base10:()=>Xc});var Xc=we({prefix:"9",name:"base10",alphabet:"0123456789"});var Jr={};H(Jr,{base16:()=>Wc,base16upper:()=>Kc});var Wc=T({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Kc=T({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Qr={};H(Qr,{base2:()=>Jc});var Jc=T({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Zr={};H(Zr,{base256emoji:()=>ta});var Uo=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Qc=Uo.reduce((r,e,t)=>(r[t]=e,r),[]),Zc=Uo.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Yc(r){return r.reduce((e,t)=>(e+=Qc[t],e),"")}function ea(r){let e=[];for(let t of r){let n=Zc[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var ta=Re({prefix:"\u{1F680}",name:"base256emoji",encode:Yc,decode:ea});var Yr={};H(Yr,{base36:()=>ra,base36upper:()=>na});var ra=we({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),na=we({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var en={};H(en,{base8:()=>oa});var oa=T({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var tn={};H(tn,{identity:()=>ia});var ia=Re({prefix:"\0",name:"identity",encode:r=>Yn(r),decode:r=>Zn(r)});var pd=new TextEncoder,md=new TextDecoder;var nn={};H(nn,{identity:()=>ht});var aa=Fo,No=128,ua=127,la=~ua,fa=Math.pow(2,31);function Fo(r,e,t){e=e||[],t=t||0;for(var n=t;r>=fa;)e[t++]=r&255|No,r/=128;for(;r&la;)e[t++]=r&255|No,r>>>=7;return e[t]=r|0,Fo.bytes=t-n+1,e}var da=rn,ha=128,Lo=127;function rn(r,n){var t=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw rn.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&Lo)<<o:(s&Lo)*Math.pow(2,o),o+=7}while(s>=ha);return rn.bytes=i-n,t}var pa=Math.pow(2,7),ma=Math.pow(2,14),ga=Math.pow(2,21),ya=Math.pow(2,28),wa=Math.pow(2,35),xa=Math.pow(2,42),ba=Math.pow(2,49),Ea=Math.pow(2,56),va=Math.pow(2,63),Sa=function(r){return r<pa?1:r<ma?2:r<ga?3:r<ya?4:r<wa?5:r<xa?6:r<ba?7:r<Ea?8:r<va?9:10},Ca={encode:aa,decode:da,encodingLength:Sa},Aa=Ca,ft=Aa;function dt(r,e=0){return[ft.decode(r,e),ft.decode.bytes]}function Ge(r,e,t=0){return ft.encode(r,e,t),e}function je(r){return ft.encodingLength(r)}function ve(r,e){let t=e.byteLength,n=je(r),o=n+je(t),i=new Uint8Array(o+t);return Ge(r,i,0),Ge(t,i,n),i.set(e,o),new qe(r,t,e,i)}function Ue(r){let e=pe(r),[t,n]=dt(e),[o,i]=dt(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new qe(t,o,s,e)}function _o(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Qn(r.bytes,t.bytes)}}var qe=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Mo=0,ka="identity",Do=pe;function Ia(r){return ve(Mo,Do(r))}var ht={code:Mo,name:ka,encode:Do,digest:Ia};var cn={};H(cn,{sha256:()=>er,sha512:()=>Ta});function sn({name:r,code:e,encode:t}){return new on(r,e,t)}var on=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?ve(this.code,t):t.then(n=>ve(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Ro(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var er=sn({name:"sha2-256",code:18,encode:Ro("SHA-256")}),Ta=sn({name:"sha2-512",code:19,encode:Ro("SHA-512")});function Po(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Na(t,an(r),e??L.encoder);default:return La(t,an(r),e??se.encoder)}}var $o=new WeakMap;function an(r){let e=$o.get(r);if(e==null){let t=new Map;return $o.set(r,t),t}return e}var z=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==pt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Fa)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=ve(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&_o(e.multihash,n.multihash)}toString(e){return Po(this,e)}toJSON(){return{"/":Po(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??Oo(n,o,i.bytes))}else if(t[_a]===!0){let{version:n,multihash:o,code:i}=t,s=Ue(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==pt)throw new Error(`Version 0 CID must use dag-pb (code: ${pt}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Oo(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,pt,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=pe(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new qe(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,g]=dt(e.subarray(t));return t+=g,f},o=n(),i=pt;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,c=n(),u=n(),h=t+u,l=h-s;return{version:o,codec:i,multihashCode:c,digestSize:u,multihashSize:l,size:h}}static parse(e,t){let[n,o]=Ua(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return an(i).set(n,e),i}};function Ua(r,e){switch(r[0]){case"Q":{let t=e??L;return[L.prefix,t.decode(`${L.prefix}${r}`)]}case L.prefix:{let t=e??L;return[L.prefix,t.decode(r)]}case se.prefix:{let t=e??se;return[se.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Na(r,e,t){let{prefix:n}=t;if(n!==L.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function La(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var pt=112,Fa=18;function Oo(r,e,t){let n=je(r),o=n+je(e),i=new Uint8Array(o+t.byteLength);return Ge(r,i,0),Ge(e,i,n),i.set(t,o),i}var _a=Symbol.for("@ipld/js-cid/CID");var Se={...tn,...Qr,...en,...Kr,...Jr,...Ur,...Yr,...Nr,...Lr,...Zr},Bd={...cn,...nn};function zo(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Vo=zo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),un=zo("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=R(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Ma={utf8:Vo,"utf-8":Vo,hex:Se.base16,latin1:un,ascii:un,binary:un,...Se},tr=Ma;function Le(r,e="utf8"){let t=tr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function ln(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return R(s);o+s>e&&(n=R(e),o=0);let c=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),c}}var Fe=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function fn(){}var hn=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Da=ln();function Ba(r){return globalThis.Buffer!=null?R(r):Da(r)}var gt=class{len;head;tail;states;constructor(){this.len=0,this.head=new Fe(fn,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Fe(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new pn((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(rr,10,X.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=X.fromBigInt(e);return this._push(rr,t.length(),t)}uint64Number(e){return this._push(Vr,_(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=X.fromBigInt(e).zzEncode();return this._push(rr,t.length(),t)}sint64Number(e){let t=X.fromNumber(e).zzEncode();return this._push(rr,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(dn,1,e?1:0)}fixed32(e){return this._push(mt,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=X.fromBigInt(e);return this._push(mt,4,t.lo)._push(mt,4,t.hi)}fixed64Number(e){let t=X.fromNumber(e);return this._push(mt,4,t.lo)._push(mt,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Eo,4,e)}double(e){return this._push(So,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(dn,1,0):this.uint32(t)._push(Pa,t,e)}string(e){let t=ko(e);return t!==0?this.uint32(t)._push(Hr,t,e):this._push(dn,1,0)}fork(){return this.states=new hn(this),this.head=this.tail=new Fe(fn,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Fe(fn,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=Ba(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function dn(r,e,t){e[t]=r&255}function Ra(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var pn=class extends Fe{next;constructor(e,t){super(Ra,e,t),this.next=void 0}};function rr(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function mt(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function Pa(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(gt.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push($a,e,r),this},gt.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Oa,e,r),this});function $a(r,e,t){e.set(r,t)}function Oa(r,e,t){r.length<40?Hr(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Le(r),t)}function mn(){return new gt}function re(r,e){let t=mn();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var He;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(He||(He={}));function nr(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function gn(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let c=e(i);s.int32(c)},n=function(i){let s=i.int32();return e(s)};return nr("enum",He.VARINT,t,n)}function ne(r,e){return nr("message",He.LENGTH_DELIMITED,r,e)}var ge=class extends Error{code;constructor(e,t,n){super(e,n),this.code=t}};var E;(function(r){r.invokeMethod="invokeMethod",r.methodResolved="methodResolved",r.methodRejected="methodRejected",r.invokeGeneratorMethod="invokeGeneratorMethod",r.abortMethodInvocation="abortMethodInvocation",r.invokeCallback="invokeCallback",r.callbackResolved="callbackResolved",r.callbackRejected="callbackRejected",r.abortCallbackInvocation="abortCallbackInvocation"})(E||(E={}));var or;(function(r){r[r.invokeMethod=0]="invokeMethod",r[r.methodResolved=1]="methodResolved",r[r.methodRejected=2]="methodRejected",r[r.invokeGeneratorMethod=3]="invokeGeneratorMethod",r[r.abortMethodInvocation=4]="abortMethodInvocation",r[r.invokeCallback=5]="invokeCallback",r[r.callbackResolved=6]="callbackResolved",r[r.callbackRejected=7]="callbackRejected",r[r.abortCallbackInvocation=8]="abortCallbackInvocation"})(or||(or={}));(function(r){r.codec=()=>gn(or)})(E||(E={}));var G;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.type!=null&&t.type!==0&&(n.uint32(8),n.uint32(t.type)),t.value!=null&&(n.uint32(18),n.bytes(t.value)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={type:0},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.type=t.uint32();break}case 2:{i.value=t.bytes();break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(G||(G={}));var V;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.type!=null&&or[t.type]!==0&&(n.uint32(8),E.codec().encode(t.type,n)),t.message!=null&&t.message.byteLength>0&&(n.uint32(18),n.bytes(t.message)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={type:E.invokeMethod,message:ae(0)},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.type=E.codec().decode(t);break}case 2:{i.message=t.bytes();break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(V||(V={}));var _e;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.path!=null&&t.path!==""&&(n.uint32(18),n.string(t.path)),t.args!=null)for(let i of t.args)n.uint32(26),G.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:"",path:"",args:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{i.path=t.string();break}case 3:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new ge('decode error - map field "args" had too many elements',"ERR_MAX_LENGTH");i.args.push(G.codec().decode(t,t.uint32(),{limits:o.limits?.args$}));break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(_e||(_e={}));var yt;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(yt||(yt={}));var Xe;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.value!=null&&(n.uint32(18),G.codec().encode(t.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{i.value=G.codec().decode(t,t.uint32(),{limits:o.limits?.value});break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(Xe||(Xe={}));var wt;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.error!=null&&(n.uint32(18),G.codec().encode(t.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{i.error=G.codec().decode(t,t.uint32(),{limits:o.limits?.error});break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(wt||(wt={}));var We;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.parents!=null)for(let i of t.parents)n.uint32(18),n.string(i);if(t.callback!=null&&t.callback!==""&&(n.uint32(26),n.string(t.callback)),t.args!=null)for(let i of t.args)n.uint32(34),G.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:"",parents:[],callback:"",args:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new ge('decode error - map field "parents" had too many elements',"ERR_MAX_LENGTH");i.parents.push(t.string());break}case 3:{i.callback=t.string();break}case 4:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new ge('decode error - map field "args" had too many elements',"ERR_MAX_LENGTH");i.args.push(G.codec().decode(t,t.uint32(),{limits:o.limits?.args$}));break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(We||(We={}));var Ke;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.parents!=null)for(let i of t.parents)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:"",parents:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new ge('decode error - map field "parents" had too many elements',"ERR_MAX_LENGTH");i.parents.push(t.string());break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(Ke||(Ke={}));var xt;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.parents!=null)for(let i of t.parents)n.uint32(18),n.string(i);t.value!=null&&(n.uint32(26),G.codec().encode(t.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:"",parents:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new ge('decode error - map field "parents" had too many elements',"ERR_MAX_LENGTH");i.parents.push(t.string());break}case 3:{i.value=G.codec().decode(t,t.uint32(),{limits:o.limits?.value});break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(xt||(xt={}));var bt;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.parents!=null)for(let i of t.parents)n.uint32(18),n.string(i);t.error!=null&&(n.uint32(26),G.codec().encode(t.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:"",parents:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new ge('decode error - map field "parents" had too many elements',"ERR_MAX_LENGTH");i.parents.push(t.string());break}case 3:{i.error=G.codec().decode(t,t.uint32(),{limits:o.limits?.error});break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(bt||(bt={}));function Va(r){return r.parents!=null}function Go(r,e){if(Va(r))return za(r.parents,e);let t=e.get(r.scope);if(t==null)throw new Jt;return t}function za(r,e){let t;for(let n of r){if(t==null){if(t=e.get(n),t==null)throw new ze;continue}if(t=t.children.get(n),t==null)throw new ze}if(t==null)throw new ze;return t}var Ga={type:1024,canEncode:r=>r===void 0,decode:()=>{}},jo=Ga;var ja={type:1025,canEncode:r=>r===null,decode:()=>null},qo=ja;var qa=["string","number","bigint","symbol"],Ha=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Ho(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(qa.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(Xa(r))return"Buffer";let t=Wa(r);return t||"Object"}function Xa(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Wa(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Ha.includes(e))return e}var a=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};a.uint=new a(0,"uint",!0);a.negint=new a(1,"negint",!0);a.bytes=new a(2,"bytes",!0);a.string=new a(3,"string",!0);a.array=new a(4,"array",!1);a.map=new a(5,"map",!1);a.tag=new a(6,"tag",!1);a.float=new a(7,"float",!0);a.false=new a(7,"false",!0);a.true=new a(7,"true",!0);a.null=new a(7,"null",!0);a.undefined=new a(7,"undefined",!0);a.break=new a(7,"break",!0);var p=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Je=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Ka=new TextDecoder,Ja=new TextEncoder;function ir(r){return Je&&globalThis.Buffer.isBuffer(r)}function yn(r){return r instanceof Uint8Array?ir(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Jo=Je?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Wo(r,e,t):(r,e,t)=>t-e>64?Ka.decode(r.subarray(e,t)):Wo(r,e,t),Qo=Je?r=>r.length>64?globalThis.Buffer.from(r):Xo(r):r=>r.length>64?Ja.encode(r):Xo(r),he=r=>Uint8Array.from(r),Qe=Je?(r,e,t)=>ir(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Zo=Je?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),yn(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},Yo=Je?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function ei(r,e){if(ir(r)&&ir(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function Xo(r){let e=[],t=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128)}return e}function Wo(r,e,t){let n=[];for(;e<t;){let o=r[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=t){let c,u,h,l;switch(s){case 1:o<128&&(i=o);break;case 2:c=r[e+1],(c&192)===128&&(l=(o&31)<<6|c&63,l>127&&(i=l));break;case 3:c=r[e+1],u=r[e+2],(c&192)===128&&(u&192)===128&&(l=(o&15)<<12|(c&63)<<6|u&63,l>2047&&(l<55296||l>57343)&&(i=l));break;case 4:c=r[e+1],u=r[e+2],h=r[e+3],(c&192)===128&&(u&192)===128&&(h&192)===128&&(l=(o&15)<<18|(c&63)<<12|(u&63)<<6|h&63,l>65535&&l<1114112&&(i=l))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return Qa(n)}var Ko=4096;function Qa(r){let e=r.length;if(e<=Ko)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Ko));return t}var Za=256,Et=class{constructor(e=Za){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=t.length-(this.maxCursor-this.cursor)-1;t.set(e,o)}else{if(t){let o=t.length-(this.maxCursor-this.cursor)-1;o<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=Yo(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Qe(n,0,this.cursor)}else t=Zo(this.chunks,this.cursor);return e&&this.reset(),t}};var w="CBOR decode error:",wn="CBOR encode error:",vt=[];vt[23]=1;vt[24]=2;vt[25]=3;vt[26]=5;vt[27]=9;function ye(r,e,t){if(r.length-e<t)throw new Error(`${w} not enough data for type`)}var M=[24,256,65536,4294967296,BigInt("18446744073709551616")];function W(r,e,t){ye(r,e,1);let n=r[e];if(t.strict===!0&&n<M[0])throw new Error(`${w} integer encoded in more bytes than necessary (strict decode)`);return n}function K(r,e,t){ye(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<M[1])throw new Error(`${w} integer encoded in more bytes than necessary (strict decode)`);return n}function J(r,e,t){ye(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<M[2])throw new Error(`${w} integer encoded in more bytes than necessary (strict decode)`);return n}function Q(r,e,t){ye(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],o=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&i<M[3])throw new Error(`${w} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(t.allowBigInt===!0)return i;throw new Error(`${w} integers outside of the safe integer range are not supported`)}function ti(r,e,t,n){return new p(a.uint,W(r,e+1,n),2)}function ri(r,e,t,n){return new p(a.uint,K(r,e+1,n),3)}function ni(r,e,t,n){return new p(a.uint,J(r,e+1,n),5)}function oi(r,e,t,n){return new p(a.uint,Q(r,e+1,n),9)}function oe(r,e){return D(r,0,e.value)}function D(r,e,t){if(t<M[0]){let n=Number(t);r.push([e|n])}else if(t<M[1]){let n=Number(t);r.push([e|24,n])}else if(t<M[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<M[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<M[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${w} encountered BigInt larger than allowable range`)}}oe.encodedSize=function(e){return D.encodedSize(e.value)};D.encodedSize=function(e){return e<M[0]?1:e<M[1]?2:e<M[2]?3:e<M[3]?5:9};oe.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function ii(r,e,t,n){return new p(a.negint,-1-W(r,e+1,n),2)}function si(r,e,t,n){return new p(a.negint,-1-K(r,e+1,n),3)}function ci(r,e,t,n){return new p(a.negint,-1-J(r,e+1,n),5)}var xn=BigInt(-1),ai=BigInt(1);function ui(r,e,t,n){let o=Q(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new p(a.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${w} integers outside of the safe integer range are not supported`);return new p(a.negint,xn-BigInt(o),9)}function sr(r,e){let t=e.value,n=typeof t=="bigint"?t*xn-ai:t*-1-1;D(r,e.type.majorEncoded,n)}sr.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*xn-ai:t*-1-1;return n<M[0]?1:n<M[1]?2:n<M[2]?3:n<M[3]?5:9};sr.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function St(r,e,t,n){ye(r,e,t+n);let o=Qe(r,e+t,e+t+n);return new p(a.bytes,o,t+n)}function li(r,e,t,n){return St(r,e,1,t)}function fi(r,e,t,n){return St(r,e,2,W(r,e+1,n))}function di(r,e,t,n){return St(r,e,3,K(r,e+1,n))}function hi(r,e,t,n){return St(r,e,5,J(r,e+1,n))}function pi(r,e,t,n){let o=Q(r,e+1,n);if(typeof o=="bigint")throw new Error(`${w} 64-bit integer bytes lengths not supported`);return St(r,e,9,o)}function cr(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===a.string?Qo(r.value):r.value),r.encodedBytes}function Ze(r,e){let t=cr(e);D(r,e.type.majorEncoded,t.length),r.push(t)}Ze.encodedSize=function(e){let t=cr(e);return D.encodedSize(t.length)+t.length};Ze.compareTokens=function(e,t){return eu(cr(e),cr(t))};function eu(r,e){return r.length<e.length?-1:r.length>e.length?1:ei(r,e)}function Ct(r,e,t,n,o){let i=t+n;ye(r,e,i);let s=new p(a.string,Jo(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Qe(r,e+t,e+i)),s}function mi(r,e,t,n){return Ct(r,e,1,t,n)}function gi(r,e,t,n){return Ct(r,e,2,W(r,e+1,n),n)}function yi(r,e,t,n){return Ct(r,e,3,K(r,e+1,n),n)}function wi(r,e,t,n){return Ct(r,e,5,J(r,e+1,n),n)}function xi(r,e,t,n){let o=Q(r,e+1,n);if(typeof o=="bigint")throw new Error(`${w} 64-bit integer string lengths not supported`);return Ct(r,e,9,o,n)}var bi=Ze;function Ye(r,e,t,n){return new p(a.array,n,t)}function Ei(r,e,t,n){return Ye(r,e,1,t)}function vi(r,e,t,n){return Ye(r,e,2,W(r,e+1,n))}function Si(r,e,t,n){return Ye(r,e,3,K(r,e+1,n))}function Ci(r,e,t,n){return Ye(r,e,5,J(r,e+1,n))}function Ai(r,e,t,n){let o=Q(r,e+1,n);if(typeof o=="bigint")throw new Error(`${w} 64-bit integer array lengths not supported`);return Ye(r,e,9,o)}function ki(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${w} indefinite length items not allowed`);return Ye(r,e,1,1/0)}function ar(r,e){D(r,a.array.majorEncoded,e.value)}ar.compareTokens=oe.compareTokens;ar.encodedSize=function(e){return D.encodedSize(e.value)};function et(r,e,t,n){return new p(a.map,n,t)}function Ii(r,e,t,n){return et(r,e,1,t)}function Ti(r,e,t,n){return et(r,e,2,W(r,e+1,n))}function Ui(r,e,t,n){return et(r,e,3,K(r,e+1,n))}function Ni(r,e,t,n){return et(r,e,5,J(r,e+1,n))}function Li(r,e,t,n){let o=Q(r,e+1,n);if(typeof o=="bigint")throw new Error(`${w} 64-bit integer map lengths not supported`);return et(r,e,9,o)}function Fi(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${w} indefinite length items not allowed`);return et(r,e,1,1/0)}function ur(r,e){D(r,a.map.majorEncoded,e.value)}ur.compareTokens=oe.compareTokens;ur.encodedSize=function(e){return D.encodedSize(e.value)};function _i(r,e,t,n){return new p(a.tag,t,1)}function Mi(r,e,t,n){return new p(a.tag,W(r,e+1,n),2)}function Di(r,e,t,n){return new p(a.tag,K(r,e+1,n),3)}function Bi(r,e,t,n){return new p(a.tag,J(r,e+1,n),5)}function Ri(r,e,t,n){return new p(a.tag,Q(r,e+1,n),9)}function lr(r,e){D(r,a.tag.majorEncoded,e.value)}lr.compareTokens=oe.compareTokens;lr.encodedSize=function(e){return D.encodedSize(e.value)};var su=20,cu=21,au=22,uu=23;function Pi(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${w} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new p(a.null,null,1):new p(a.undefined,void 0,1)}function $i(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${w} indefinite length items not allowed`);return new p(a.break,void 0,1)}function bn(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${w} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${w} Infinity values are not supported`)}return new p(a.float,r,e)}function Oi(r,e,t,n){return bn(En(r,e+1),3,n)}function Vi(r,e,t,n){return bn(vn(r,e+1),5,n)}function zi(r,e,t,n){return bn(Hi(r,e+1),9,n)}function fr(r,e,t){let n=e.value;if(n===!1)r.push([a.float.majorEncoded|su]);else if(n===!0)r.push([a.float.majorEncoded|cu]);else if(n===null)r.push([a.float.majorEncoded|au]);else if(n===void 0)r.push([a.float.majorEncoded|uu]);else{let o,i=!1;(!t||t.float64!==!0)&&(ji(n),o=En(le,1),n===o||Number.isNaN(n)?(le[0]=249,r.push(le.slice(0,3)),i=!0):(qi(n),o=vn(le,1),n===o&&(le[0]=250,r.push(le.slice(0,5)),i=!0))),i||(lu(n),o=Hi(le,1),le[0]=251,r.push(le.slice(0,9)))}}fr.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){ji(n);let o=En(le,1);if(n===o||Number.isNaN(n))return 3;if(qi(n),o=vn(le,1),n===o)return 5}return 9};var Gi=new ArrayBuffer(9),ie=new DataView(Gi,1),le=new Uint8Array(Gi,0);function ji(r){if(r===1/0)ie.setUint16(0,31744,!1);else if(r===-1/0)ie.setUint16(0,64512,!1);else if(Number.isNaN(r))ie.setUint16(0,32256,!1);else{ie.setFloat32(0,r);let e=ie.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)ie.setUint16(0,31744,!1);else if(t===0)ie.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?ie.setUint16(0,0):o<-14?ie.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):ie.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function En(r,e){if(r.length-e<2)throw new Error(`${w} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function qi(r){ie.setFloat32(0,r,!1)}function vn(r,e){if(r.length-e<4)throw new Error(`${w} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function lu(r){ie.setFloat64(0,r,!1)}function Hi(r,e){if(r.length-e<8)throw new Error(`${w} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}fr.compareTokens=oe.compareTokens;function v(r,e,t){throw new Error(`${w} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function dr(r){return()=>{throw new Error(`${w} ${r}`)}}var d=[];for(let r=0;r<=23;r++)d[r]=v;d[24]=ti;d[25]=ri;d[26]=ni;d[27]=oi;d[28]=v;d[29]=v;d[30]=v;d[31]=v;for(let r=32;r<=55;r++)d[r]=v;d[56]=ii;d[57]=si;d[58]=ci;d[59]=ui;d[60]=v;d[61]=v;d[62]=v;d[63]=v;for(let r=64;r<=87;r++)d[r]=li;d[88]=fi;d[89]=di;d[90]=hi;d[91]=pi;d[92]=v;d[93]=v;d[94]=v;d[95]=dr("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)d[r]=mi;d[120]=gi;d[121]=yi;d[122]=wi;d[123]=xi;d[124]=v;d[125]=v;d[126]=v;d[127]=dr("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)d[r]=Ei;d[152]=vi;d[153]=Si;d[154]=Ci;d[155]=Ai;d[156]=v;d[157]=v;d[158]=v;d[159]=ki;for(let r=160;r<=183;r++)d[r]=Ii;d[184]=Ti;d[185]=Ui;d[186]=Ni;d[187]=Li;d[188]=v;d[189]=v;d[190]=v;d[191]=Fi;for(let r=192;r<=215;r++)d[r]=_i;d[216]=Mi;d[217]=Di;d[218]=Bi;d[219]=Ri;d[220]=v;d[221]=v;d[222]=v;d[223]=v;for(let r=224;r<=243;r++)d[r]=dr("simple values are not supported");d[244]=v;d[245]=v;d[246]=v;d[247]=Pi;d[248]=dr("simple values are not supported");d[249]=Oi;d[250]=Vi;d[251]=zi;d[252]=v;d[253]=v;d[254]=v;d[255]=$i;var fe=[];for(let r=0;r<24;r++)fe[r]=new p(a.uint,r,1);for(let r=-1;r>=-24;r--)fe[31-r]=new p(a.negint,r,1);fe[64]=new p(a.bytes,new Uint8Array(0),1);fe[96]=new p(a.string,"",1);fe[128]=new p(a.array,0,1);fe[160]=new p(a.map,0,1);fe[244]=new p(a.false,!1,1);fe[245]=new p(a.true,!0,1);fe[246]=new p(a.null,null,1);function Xi(r){switch(r.type){case a.false:return he([244]);case a.true:return he([245]);case a.null:return he([246]);case a.bytes:return r.value.length?void 0:he([64]);case a.string:return r.value===""?he([96]):void 0;case a.array:return r.value===0?he([128]):void 0;case a.map:return r.value===0?he([160]):void 0;case a.uint:return r.value<24?he([Number(r.value)]):void 0;case a.negint:if(r.value>=-24)return he([31-Number(r.value)])}}var du={float64:!1,mapSorter:mu,quickEncodeToken:Xi};function hu(){let r=[];return r[a.uint.major]=oe,r[a.negint.major]=sr,r[a.bytes.major]=Ze,r[a.string.major]=bi,r[a.array.major]=ar,r[a.map.major]=ur,r[a.tag.major]=lr,r[a.float.major]=fr,r}var Wi=hu(),Sn=new Et,pr=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${wn} object contains circular references`);return new r(t,e)}},Ce={null:new p(a.null,null),undefined:new p(a.undefined,void 0),true:new p(a.true,!0),false:new p(a.false,!1),emptyArray:new p(a.array,0),emptyMap:new p(a.map,0)},Ae={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new p(a.float,r):r>=0?new p(a.uint,r):new p(a.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new p(a.uint,r):new p(a.negint,r)},Uint8Array(r,e,t,n){return new p(a.bytes,r)},string(r,e,t,n){return new p(a.string,r)},boolean(r,e,t,n){return r?Ce.true:Ce.false},null(r,e,t,n){return Ce.null},undefined(r,e,t,n){return Ce.undefined},ArrayBuffer(r,e,t,n){return new p(a.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new p(a.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Ce.emptyArray,new p(a.break)]:Ce.emptyArray;n=pr.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=hr(s,t,n);return t.addBreakTokens?[new p(a.array,r.length),o,new p(a.break)]:[new p(a.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[Ce.emptyMap,new p(a.break)]:Ce.emptyMap;n=pr.createCheck(n,r);let c=[],u=0;for(let h of i)c[u++]=[hr(h,t,n),hr(o?r.get(h):r[h],t,n)];return pu(c,t),t.addBreakTokens?[new p(a.map,s),c,new p(a.break)]:[new p(a.map,s),c]}};Ae.Map=Ae.Object;Ae.Buffer=Ae.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ae[`${r}Array`]=Ae.DataView;function hr(r,e={},t){let n=Ho(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Ae[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=Ae[n];if(!i)throw new Error(`${wn} unsupported type: ${n}`);return i(r,n,e,t)}function pu(r,e){e.mapSorter&&r.sort(e.mapSorter)}function mu(r,e){let t=Array.isArray(r[0])?r[0][0]:r[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(t.type!==n.type)return t.type.compare(n.type);let o=t.type.major,i=Wi[o].compareTokens(t,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Ki(r,e,t,n){if(Array.isArray(e))for(let o of e)Ki(r,o,t,n);else t[e.type.major](r,e,n)}function gu(r,e,t){let n=hr(r,t);if(!Array.isArray(n)&&t.quickEncodeToken){let o=t.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,t),c=new Et(s);if(i(c,n,t),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return yn(c.chunks[0])}}return Sn.reset(),Ki(Sn,n,e,t),Sn.toBytes(!0)}function A(r,e){return e=Object.assign({},du,e),gu(r,Wi,e)}var yu={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},mr=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=fe[e];if(t===void 0){let n=d[e];if(!n)throw new Error(`${w} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this._pos,o,this.options)}return this._pos+=t.encodedLength,t}},At=Symbol.for("DONE"),gr=Symbol.for("BREAK");function wu(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=tt(e,t);if(i===gr){if(r.value===1/0)break;throw new Error(`${w} got unexpected break to lengthed array`)}if(i===At)throw new Error(`${w} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function xu(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let c=tt(e,t);if(c===gr){if(r.value===1/0)break;throw new Error(`${w} got unexpected break to lengthed map`)}if(c===At)throw new Error(`${w} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${w} non-string keys not supported (got ${typeof c})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${w} found repeat map key "${c}"`);let u=tt(e,t);if(u===At)throw new Error(`${w} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(c,u):o[c]=u}return n?i:o}function tt(r,e){if(r.done())return At;let t=r.next();if(t.type===a.break)return gr;if(t.type.terminal)return t.value;if(t.type===a.array)return wu(t,r,e);if(t.type===a.map)return xu(t,r,e);if(t.type===a.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=tt(r,e);return e.tags[t.value](n)}throw new Error(`${w} tag not supported (${t.value})`)}throw new Error("unsupported")}function Ji(r,e){if(!(r instanceof Uint8Array))throw new Error(`${w} data to decode must be a Uint8Array`);e=Object.assign({},yu,e);let t=e.tokenizer||new mr(r,e),n=tt(t,e);if(n===At)throw new Error(`${w} did not find any content to decode`);if(n===gr)throw new Error(`${w} got unexpected break`);return[n,r.subarray(t.pos())]}function k(r,e){let[t,n]=Ji(r,e);if(n.length>0)throw new Error(`${w} too many terminals, data makes no sense`);return t}var bu={type:1026,canEncode:r=>r===!0||r===!1,encode:r=>A(r),decode:r=>k(r)},Qi=bu;var Eu={type:1027,canEncode:r=>typeof r=="number"&&!isNaN(r),encode:r=>A(r),decode:r=>k(r)},Zi=Eu;var vu={type:1028,canEncode:r=>typeof r=="string",encode:r=>A(r),decode:r=>k(r)},Yi=vu;var Su={type:1029,canEncode:r=>Array.isArray(r),encode:(r,e,t,n)=>A(r.map(o=>e.toValue(o,t,n))),decode:(r,e,t,n)=>k(r).map(o=>e.fromValue(o,t,n))},es=Su;var Cu={type:1030,canEncode:r=>typeof r=="function",encode:(r,e,t,n)=>{let o=Ve();return n?.callbacks.set(o,{context:t,fn:r}),A(o)},decode:(r,e,t,n)=>async(...o)=>new Promise((i,s)=>{let c=k(r),u=Ve(),h={scope:u,result:ce(),callbacks:new Map,children:new Map,parents:[...n.parents,n.scope],abortControllers:[],abortSignals:[]};n.children.set(u,h),o=o.map(f=>e.toValue(f,null,h));let l=Ot(h.abortSignals);l.addEventListener("abort",()=>{t.push(V.encode({type:E.abortCallbackInvocation,message:Ke.encode({scope:u,parents:h.parents})}))}),t.push(V.encode({type:E.invokeCallback,message:We.encode({scope:u,parents:h.parents,callback:c,args:o})})),h.result.promise.then(f=>{i(f)},f=>{s(f)}).finally(()=>{n.children.delete(u),l.clear()})})},ts=Cu;var Au={type:1031,canEncode:r=>r.toString()==="NaN"&&isNaN(r),decode:()=>NaN},rs=Au;var ku={type:1032,canEncode:r=>r instanceof Error,encode:r=>A({message:r.message,name:r.name,code:r.code,type:r.type,stack:r.stack}),decode:r=>{let e=k(r),t=new Error(e.message);return t.name=e.name,t.stack=e.stack,t.code=e.code,t.type=e.type,t}},ns=ku;var Iu={type:1033,canEncode:r=>Array.isArray(r),encode:(r,e,t,n)=>{throw new Error("Promises are not supported")},decode:(r,e,t,n)=>{throw new Error("Promises are not supported")}},os=Iu;var is=["__defineGetter__","__defineSetter__","hasOwnProperty","__lookupGetter__","__lookupSetter__","isPrototypeOf","propertyIsEnumerable","toString","valueOf","__proto__","toLocaleString","constructor"],Tu={type:2147483647,canEncode:r=>typeof r=="object",encode:(r,e,t,n)=>{let o={};for(let i in r)is.includes(i)||Object.hasOwn(r,i)&&(o[i]=r[i]);for(let i of Object.getOwnPropertyNames(Object.getPrototypeOf(r)))is.includes(i)||(o[i]=r[i]);return A([...Object.entries(o)].map(([i,s])=>[e.toValue(i,r,n),e.toValue(s,r,n)]))},decode:(r,e,t,n)=>{let o={};return k(r).forEach(([s,c])=>{o[e.fromValue(s,t,n)]=e.fromValue(c,t,n)}),o}},kt=Tu;var Uu={type:1034,canEncode:r=>typeof r.next=="function"&&typeof r.throw=="function"&&typeof r.return=="function",encode:(r,e,t,n)=>kt.encode({next:r.next.bind(r),throw:r.throw.bind(r),return:r.return.bind(r)},e,t,n),decode:(r,e,t,n)=>{let o=kt.decode(r,e,t,n);return o[Symbol.asyncIterator]=()=>o,o}},ss=Uu;var Nu={type:1035,canEncode:r=>typeof r=="bigint",encode:r=>A(r),decode:r=>BigInt(k(r))},cs=Nu;var Lu={type:1036,canEncode:r=>r instanceof Map,encode:(r,e,t,n)=>A([...r.entries()].map(([o,i])=>[e.toValue(o,t,n),e.toValue(i,t,n)])),decode:(r,e,t,n)=>{let o=new Map;return k(r).forEach(([s,c])=>{let u=e.fromValue(s,t,n),h=e.fromValue(c,t,n);o.set(u,h)}),o}},as=Lu;var Fu={type:1037,canEncode:r=>r instanceof Set,encode:(r,e,t,n)=>A([...r.values()].map(o=>e.toValue(o,t,n))),decode:(r,e,t,n)=>{let o=new Set;return k(r).forEach(s=>{o.add(e.fromValue(s,t,n))}),o}},us=Fu;var _u={type:1038,canEncode:r=>r instanceof Uint8Array,encode:r=>r,decode:r=>r},ls=_u;var Mu={type:1039,canEncode:r=>r instanceof AbortSignal,encode:(r,e,t,n)=>(n?.abortSignals.push(r),new Uint8Array(0)),decode:(r,e,t,n)=>{let o=new AbortController;return n.abortControllers.push(o),o.signal}},fs=Mu;var Du={type:1040,canEncode:r=>r instanceof Date,encode:r=>A(r.toString()),decode:r=>new Date(k(r))},ds=Du;var Bu={type:1041,canEncode:r=>r instanceof RegExp,encode:r=>A({source:r.source,flags:r.flags}),decode:r=>{let{source:e,flags:t}=k(r);return new RegExp(e,t)}},hs=Bu;var ps=[jo,qo,Qi,Zi,Yi,es,ts,rs,ns,os,ss,cs,as,us,ls,fs,ds,hs,kt];var yr=class{transformersMap;transformersList;constructor(e){this.transformersList=[...ps,...e?.valueCodecs??[]].sort((t,n)=>t.type<n.type?-1:t.type>n.type?1:0),this.transformersMap={},this.transformersList.forEach(t=>{if(this.transformersMap[t.type]!=null)throw new Error(`Duplicate transformer type ${t.type}`);this.transformersMap[t.type]=t})}toValue(e,t,n){for(let o=0;o<this.transformersList.length;o++){let i=this.transformersList[o];if(i.canEncode(e))return{type:i.type,value:i.encode?.(e,this,t,n)}}throw new at(`Unsupported value type "${e}"`)}fromValue(e,t,n){let o=this.transformersMap[e.type];if(o==null)throw new at(`Unsupported value type "${e.type}"`);return o.decode(e.value??new Uint8Array(0),this,t,n)}};function Ru(r){return r.isScope===!0}function Pu(r){return r.type===E.invokeMethod||r.type===E.invokeGeneratorMethod||r.type===E.invokeCallback}var Cn=class{source;output;targets;invocations;values;messageHandlers;constructor(e){this.output=xe(),this.source=qt(this.output),this.targets=new Map,this.invocations=new Map,this.values=new yr(e),this.sink=this.sink.bind(this),this.messageHandlers={[E.invokeMethod]:{decoder:_e,handler:this.handleInvokeMethod.bind(this)},[E.invokeGeneratorMethod]:{decoder:_e,handler:this.handleInvokeGeneratorMethod.bind(this)},[E.abortMethodInvocation]:{decoder:yt,handler:this.handleAbortMethod.bind(this),isScope:!0},[E.methodResolved]:{decoder:Xe,handler:this.handleMethodResolved.bind(this),isScope:!0},[E.methodRejected]:{decoder:wt,handler:this.handleMethodRejected.bind(this),isScope:!0,isError:!0},[E.invokeCallback]:{decoder:We,handler:this.handleInvokeCallback.bind(this),isScope:!0},[E.abortCallbackInvocation]:{decoder:Ke,handler:this.handleAbortCallback.bind(this),isScope:!0},[E.callbackResolved]:{decoder:xt,handler:this.handleCallbackResolved.bind(this),isScope:!0},[E.callbackRejected]:{decoder:bt,handler:this.handleCallbackRejected.bind(this),isScope:!0,isError:!0}}}async sink(e){for await(let t of ct(e))try{let n=V.decode(t),o=this.messageHandlers[n.type];if(o==null)continue;let i=o.decoder.decode(n.message),s;if(Ru(o))try{s=Go(i,this.invocations)}catch{continue}o.handler(i,s).catch(c=>{Pu(n)&&this.sendError(i,c),this.invocations.delete(i.scope)}).finally(()=>{n.type===E.invokeMethod&&this.invocations.delete(i.scope)})}catch{continue}}sendError(e,t){e.parents!=null?this.output.push(V.encode({type:E.callbackRejected,message:bt.encode({scope:e.scope,parents:e.parents,error:this.values.toValue(t)})})):this.output.push(V.encode({type:E.methodRejected,message:wt.encode({scope:e.scope,error:this.values.toValue(t)})}))}createClient(e){return this.proxy(e)}createTarget(e,t){if(this.targets.has(e))throw new Wt(`Cannot reuse RPC target name "${e}"`);this.targets.set(e,t)}async handleInvokeMethod(e){if(this.invocations.has(e.scope))throw new ut;let t=new Map,n=new Map,o={scope:e.scope,result:ce(),callbacks:t,children:n,parents:[],abortControllers:[],abortSignals:[]};this.invocations.set(e.scope,o);let i=this.lookupInvocationTarget(e.path),s=await i.fn.apply(i.context,e.args.map(c=>this.values.fromValue(c,this.output,o)));this.output.push(V.encode({type:E.methodResolved,message:Xe.encode({scope:e.scope,value:this.values.toValue(s)})}))}async handleAbortMethod(e,t){t.abortControllers.forEach(n=>{n.abort()})}async handleInvokeGeneratorMethod(e){if(this.invocations.has(e.scope))throw new ut;let t=new Map,n=new Map,o={scope:e.scope,result:ce(),callbacks:t,children:n,parents:[],abortControllers:[],abortSignals:[]};this.invocations.set(e.scope,o);let i=this.lookupInvocationTarget(e.path),s=i.fn.apply(i.context,e.args.map(u=>this.values.fromValue(u,this.output,o)));if(typeof s.next!="function")throw new Kt(`${e.path} did not return an async generator`);let c={next:async()=>{let u=await s.next();return u.done===!0&&this.invocations.delete(e.scope),u},throw:async u=>{try{let h=await s.throw(u);return h.done===!0&&this.invocations.delete(e.scope),h}catch(h){throw this.invocations.delete(e.scope),h}},return:async u=>{let h=await s.return(u);return h.done===!0&&this.invocations.delete(e.scope),h},[Symbol.asyncIterator]:()=>c};this.output.push(V.encode({type:E.methodResolved,message:Xe.encode({scope:e.scope,value:this.values.toValue(c,null,o)})}))}lookupInvocationTarget(e){let t=e.split("."),n=this.targets.get(t[0]),o=n;for(let i=1;i<t.length;i++)o=n,n=n?.[t[i]];if(n==null)throw o!=null&&e.endsWith(".then")?new Xt(`"${e.substring(0,e.length-5)}" was not a function`):new Ht(`Could not find "${e}" on target`);if(typeof n!="function")throw new lt("Invocation target was not a function");return{context:o,fn:n}}async handleMethodResolved(e,t){let n;e.value!=null&&(n=this.values.fromValue(e.value,this.output,t)),t.result.resolve(n)}async handleMethodRejected(e,t){let n;e.error!=null&&(n=this.values.fromValue(e.error,this.output,t)),t.result.reject(n)}async handleInvokeCallback(e,t){let n=t.callbacks.get(e.callback);if(n==null)throw new Qt;let o=await n.fn.apply(n.context,e.args.map(i=>this.values.fromValue(i,this.output,t)));this.output.push(V.encode({type:E.callbackResolved,message:xt.encode({scope:e.scope,parents:e.parents,value:this.values.toValue(o)})}))}async handleAbortCallback(e,t){t.abortControllers.forEach(n=>{n.abort()})}async handleCallbackResolved(e,t){let n;e.value!=null&&(n=this.values.fromValue(e.value,this.output,t)),t.children.get(e.scope)?.result.resolve(n),t.children.delete(e.scope)}async handleCallbackRejected(e,t){let n;e.error!=null&&(n=this.values.fromValue(e.error,this.output,t)),t.children.get(e.scope)?.result.reject(n),t.children.delete(e.scope)}proxy(e){let t=()=>{},n=this;return new Proxy(t,{get(o,i,s){return n.proxy(`${e==null?"":`${e}.`}${i.toString()}`)},apply(o,i,s){let c,u;function h(){return u==null&&(u=new Promise((f,g)=>{let b=Ve(),y={scope:b,result:ce(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(b,y),n.output.push(V.encode({type:E.invokeMethod,message:_e.encode({scope:b,path:e,args:s.map(m=>n.values.toValue(m,null,y))})}));let x=Ot(y.abortSignals);x.addEventListener("abort",()=>{n.output.push(V.encode({type:E.abortMethodInvocation,message:yt.encode({scope:b})}))}),y.result.promise.then(m=>{f(m)},m=>{g(m)}).finally(()=>{n.invocations.delete(b),x.clear()})})),u}function l(){if(c==null){let f=Ve(),g={scope:f,result:ce(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(f,g),n.output.push(V.encode({type:E.invokeGeneratorMethod,message:_e.encode({scope:f,path:e,args:s.map(y=>n.values.toValue(y,null,g))})}));let b;c={async next(){if(b!=null)throw b;let x=await(await g.result.promise).next();return x.done===!0&&n.invocations.delete(f),x},async throw(y){if(b!=null)throw b;try{let m=await(await g.result.promise).throw(y);return m.done===!0&&n.invocations.delete(f),m}catch(x){throw n.invocations.delete(f),b=y,x}},async return(y){if(b!=null)throw b;let m=await(await g.result.promise).return(y);return m.done===!0&&n.invocations.delete(f),m},[Symbol.asyncIterator]:()=>c}}return c}return new Proxy(t,{get(f,g,b){if(g==="then")return h().then.bind(u);if(g==="catch")return h().catch.bind(u);if(g==="finally")return h().finally.bind(u);if(g===Symbol.asyncIterator)return()=>l();if(g==="next")return l().next.bind(c);if(g==="return")return l().return.bind(c);if(g==="throw")return l().throw.bind(c);if(g===Symbol.toStringTag)return"[object Object]";if(g==="constructor")return()=>{};throw new lt(`Property ${g.toString()} was not used as a promise or async generator`)}})}})}};function ms(r){return new Cn(r)}var gs={type:4096,canEncode:r=>r.code!=null&&r.version!=null&&r.multihash!=null&&r["/"]!=null,encode:r=>r.bytes,decode:r=>z.decode(r)};var It=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var ys={type:4099,canEncode:r=>r instanceof It,encode:(r,e,t,n)=>A({type:r.type,detail:e.toValue(r.detail,t,n)}),decode:(r,e,t,n)=>{let{type:o,detail:i}=k(r);return new It(o,e.fromValue(i,t,n))}};function B(r,e="utf8"){let t=tr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var wr=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,c=this.peekChar();if(c===void 0)return;let u=c==="0",h=2**(8*o)-1;for(;;){let l=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let g=Number.parseInt(f,e);if(!Number.isNaN(g))return g});if(l===void 0)break;if(i*=e,i+=l,i>h||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&u&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[c]=e(i.subarray(0,s));return t.set(i.subarray(0,c),16-c),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ws=45,$u=15,rt=new wr;function An(r){if(!(r.length>$u))return rt.new(r).parseWith(()=>rt.readIPv4Addr())}function kn(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ws))return rt.new(r).parseWith(()=>rt.readIPv6Addr())}function xr(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ws))return rt.new(r).parseWith(()=>rt.readIPAddr())}var Xm=parseInt("0xFFFF",16),Wm=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Es(r){return!!An(r)}function vs(r){return!!kn(r)}function br(r){return!!xr(r)}var Ss=Es,ju=vs,In=function(r){let e=0;if(r=r.toString().trim(),Ss(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(ju(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=Ss(t[n]),s;i&&(s=In(t[n]),t[n]=B(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,B(s.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let i=parseInt(t[n],16);o[e++]=i>>8&255,o[e++]=i&255}return o}throw new Error("invalid ip address")},Cs=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let i=0;i<t;i++)o.push(r[e+i]);return o.join(".")}if(t===16){let o=[];for(let i=0;i<t;i+=2)o.push(n.getUint16(e+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var nt={},Tn={},Hu=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Hu.forEach(r=>{let e=Xu(...r);Tn[e.code]=e,nt[e.name]=e});function Xu(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function I(r){if(typeof r=="number"){if(Tn[r]!=null)return Tn[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(nt[r]!=null)return nt[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Lg=I("ip4"),Fg=I("ip6"),_g=I("ipcidr");function Fn(r,e){switch(I(r).code){case 4:case 41:return Ku(e);case 42:return Ln(e);case 6:case 273:case 33:case 132:return Is(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ln(e);case 421:return Yu(e);case 444:return ks(e);case 445:return ks(e);case 466:return Zu(e);case 481:return globalThis.encodeURIComponent(Ln(e));default:return B(e,"base16")}}function _n(r,e){switch(I(r).code){case 4:return As(e);case 41:return As(e);case 42:return Nn(e);case 6:case 273:case 33:case 132:return Mn(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Nn(e);case 421:return Ju(e);case 444:return el(e);case 445:return tl(e);case 466:return Qu(e);case 481:return Nn(globalThis.decodeURIComponent(e));default:return Le(e,"base16")}}var Un=Object.values(Se).map(r=>r.decoder),Wu=function(){let r=Un[0].or(Un[1]);return Un.slice(2).forEach(e=>r=r.or(e)),r}();function As(r){if(!br(r))throw new Error("invalid ip address");return In(r)}function Ku(r){let e=Cs(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!br(e))throw new Error("invalid ip address");return e}function Mn(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Is(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Nn(r){let e=Le(r),t=Uint8Array.from(be(e.length));return ee([t,e],t.length+e.length)}function Ln(r){let e=me(r);if(r=r.slice(_(e)),r.length!==e)throw new Error("inconsistent lengths");return B(r)}function Ju(r){let e;r[0]==="Q"||r[0]==="1"?e=Ue(L.decode(`z${r}`)).bytes:e=z.parse(r).multihash.bytes;let t=Uint8Array.from(be(e.length));return ee([t,e],t.length+e.length)}function Qu(r){let e=Wu.decode(r),t=Uint8Array.from(be(e.length));return ee([t,e],t.length+e.length)}function Zu(r){let e=me(r),t=r.slice(_(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+B(t,"base64url")}function Yu(r){let e=me(r),t=r.slice(_(e));if(t.length!==e)throw new Error("inconsistent lengths");return B(t,"base58btc")}function el(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=se.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Mn(n);return ee([t,o],t.length+o.length)}function tl(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=se.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Mn(n);return ee([t,o],t.length+o.length)}function ks(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=B(e,"base32"),o=Is(t);return`${n}:${o}`}function Ts(r){r=Dn(r);let e=[],t=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],c=I(s);if(c.size===0){e.push([c.code]),t.push([c.code]);continue}if(i++,i>=o.length)throw Ns("invalid address: "+r);if(c.path===!0){n=Dn(o.slice(i).join("/")),e.push([c.code,_n(c.code,n)]),t.push([c.code,n]);break}let u=_n(c.code,o[i]);e.push([c.code,u]),t.push([c.code,Fn(c.code,u)])}return{string:Us(t),bytes:Rn(e),tuples:e,stringTuples:t,path:n}}function Bn(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let i=me(r,o),s=_(i),c=I(i),u=rl(c,r.slice(o+s));if(u===0){e.push([i]),t.push([i]),o+=s;continue}let h=r.slice(o+s,o+s+u);if(o+=u+s,o>r.length)throw Ns("Invalid address Uint8Array: "+B(r,"base16"));e.push([i,h]);let l=Fn(i,h);if(t.push([i,l]),c.path===!0){n=l;break}}return{bytes:Uint8Array.from(r),string:Us(t),tuples:e,stringTuples:t,path:n}}function Us(r){let e=[];return r.map(t=>{let n=I(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Dn(e.join("/"))}function Rn(r){return ee(r.map(e=>{let t=I(e[0]),n=Uint8Array.from(be(t.code));return e.length>1&&e[1]!=null&&(n=ee([n,e[1]])),n}))}function rl(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=me(e instanceof Uint8Array?e:Uint8Array.from(e));return t+_(t)}}function Dn(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Ns(r){return new Error("Error parsing address: "+r)}var nl=Symbol.for("nodejs.util.inspect.custom"),Pn=Symbol.for("@multiformats/js-multiaddr/multiaddr"),ol=[I("dns").code,I("dns4").code,I("dns6").code,I("dnsaddr").code],Er=class r{bytes;#t;#e;#r;#n;[Pn]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Bn(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Ts(e)}else if(vr(e))t=Bn(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#t=t.string,this.#e=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,n,o,i="",s=I("tcp"),c=I("udp"),u=I("ip4"),h=I("ip6"),l=I("dns6"),f=I("ip6zone");for(let[b,y]of this.stringTuples())b===f.code&&(i=`%${y??""}`),ol.includes(b)&&(t=s.name,o=443,n=`${y??""}${i}`,e=b===l.code?6:4),(b===s.code||b===c.code)&&(t=I(b).name,o=parseInt(y??"")),(b===u.code||b===h.code)&&(t=I(b).name,n=`${y??""}${i}`,e=b===h.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.#e.map(([e])=>Object.assign({},I(e)))}protoCodes(){return this.#e.map(([e])=>e)}protoNames(){return this.#e.map(([e])=>I(e).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Rn(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===nt.p2p.code&&e.push([n,o]),n===nt["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?B(L.decode(`z${n}`),"base58btc"):B(z.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return ke(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=Ls.get(t.name);if(n==null)throw new Mt(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(i=>De(i))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[nl](){return`Multiaddr(${this.#t})`}};var Ls=new Map;function vr(r){return!!r?.[Pn]}function De(r){return new Er(r)}var Fs={type:4097,canEncode:r=>vr(r),encode:r=>r.bytes,decode:r=>De(r)};var Ms=Symbol.for("nodejs.util.inspect.custom"),_s=Object.values(Se).map(r=>r.decoder).reduce((r,e)=>r.or(e),Se.identity.decoder),Ds=114,Bs=36,Rs=37,Tt=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[_t]=!0;toString(){return this.string==null&&(this.string=L.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return z.createV1(Ds,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ke(this.multihash.bytes,e);if(typeof e=="string")return Vn(e).equals(this);if(e?.multihash?.bytes!=null)return ke(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Ms](){return`PeerId(${this.toString()})`}},Ut=class extends Tt{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Nt=class extends Tt{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Lt=class extends Tt{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}},$n=2336,On=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=ht.digest(Le(this.url))}[Ms](){return`PeerId(${this.url})`}[_t]=!0;toString(){return this.toCID().toString()}toCID(){return z.createV1($n,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=B(e)),e.toString()===this.toString())}};function Vn(r,e){if(e=e??_s,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Ue(L.decode(`z${r}`));return r.startsWith("12D")?new Nt({multihash:t}):r.startsWith("16U")?new Lt({multihash:t}):new Ut({multihash:t})}return zn(_s.decode(r))}function zn(r){try{let e=Ue(r);if(e.code===ht.code){if(e.digest.length===Bs)return new Nt({multihash:e});if(e.digest.length===Rs)return new Lt({multihash:e})}if(e.code===er.code)return new Ut({multihash:e})}catch{return il(z.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function il(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Ds&&r.code!==$n)throw new Error("Supplied PeerID CID is invalid");if(r.code===$n){let t=B(r.multihash.digest);return new On(new URL(t))}let e=r.multihash;if(e.code===er.code)return new Ut({multihash:r.multihash});if(e.code===ht.code){if(e.digest.length===Bs)return new Nt({multihash:r.multihash});if(e.digest.length===Rs)return new Lt({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var Ps={type:4098,canEncode:r=>Xn(r),encode:r=>r.toBytes(),decode:r=>zn(r)};var Gn=[gs,Fs,Ps,ys];function ot(r,e){let t={};for(let[n,o]of r.entries())t[n]=e(o);return t}async function Sr(r,e){let t=[],n=r.connectionManager.getConnectionsMap(),o=[...n.values()].flatMap(i=>i).map(i=>i.remoteAddr.toString());for(let[i,s]of n.entries())try{let c=await r.peerStore.get(i);t.push({id:i,addresses:c.addresses.map(({isCertified:u,multiaddr:h})=>({multiaddr:h,isCertified:u,isConnected:o.includes(h.toString())})),protocols:[...c.protocols],tags:ot(c.tags,u=>u.value),metadata:ot(c.metadata,u=>de.encode(u))})}catch(c){e.error("could not load peer data from peer store",c),t.push({id:i,addresses:s.map(u=>({multiaddr:u.remoteAddr,isConnected:o.includes(u.remoteAddr.toString())})),protocols:[],tags:{},metadata:{}})}return t}async function Cr(r){let e=await r.peerStore.get(r.peerId);return{id:e.id,addresses:e.addresses,protocols:[...e.protocols],tags:ot(e.tags,t=>t.value),metadata:ot(e.metadata,t=>de.encode(t))}}function $s(r){let e=r.logger.forComponent("libp2p:devtools-metrics:metrics-rpc");return{init:async()=>({self:await Cr(r),peers:await Sr(r,e),debug:localStorage.getItem("debug")??""}),setDebug:async t=>{t?.length!=null&&t?.length>0?(so(t),localStorage.setItem("debug",t)):(io(),localStorage.removeItem("debug"))},openConnection:async(t,n)=>{let o;try{o=Vn(t)}catch{o=De(t)}await r.connectionManager.openConnection(o,n)},closeConnection:async(t,n)=>{await Promise.all(r.connectionManager.getConnections(t).map(async o=>{try{await o.close(n)}catch(i){o.abort(i)}}))},contentRouting:r.contentRouting,peerRouting:r.peerRouting}}function jn(r,e=100){let t,n;return()=>{if(n==null&&(n=Date.now()),t!=null&&Date.now()-n>e){clearTimeout(t),n=void 0,r();return}clearTimeout(t),t=setTimeout(()=>{n=void 0,r()},e)}}var Os="@libp2p/devtools-metrics:devtools",sl="@libp2p/devtools-metrics:worker",cl="@libp2p/devtools-metrics:content",Vs="@libp2p/devtools-metrics:metrics",zs="________libp2p_devtools_metrics";Object.defineProperty(globalThis,zs,{value:!0,enumerable:!1,writable:!1});var qn=class{log;components;simpleMetrics;intervalMs;rpcQueue;rpc;devTools;constructor(e,t){this.log=e.logger.forComponent("libp2p:devtools-metrics"),this.intervalMs=t?.intervalMs,this.components=e,this.rpcQueue=xe(),this.rpc=ms({valueCodecs:Gn}),this.devTools=this.rpc.createClient("devTools"),this.onPeersUpdate=jn(this.onPeersUpdate.bind(this),1e3),this.onSelfUpdate=jn(this.onSelfUpdate.bind(this),1e3),this.onIncomingMessage=this.onIncomingMessage.bind(this),this.simpleMetrics=uo({intervalMs:this.intervalMs,onMetrics:n=>{this.devTools.safeDispatchEvent("metrics",{detail:n}).catch(o=>{this.log.error("error sending metrics",o)})}})({})}[Symbol.toStringTag]="@libp2p/devtools-metrics";[Dt]=["@libp2p/metrics"];trackMultiaddrConnection(e){this.simpleMetrics.trackMultiaddrConnection(e)}trackProtocolStream(e,t){this.simpleMetrics.trackProtocolStream(e,t)}registerMetric(e,t){return this.simpleMetrics.registerMetric(e,t)}registerMetricGroup(e,t){return this.simpleMetrics.registerMetricGroup(e,t)}registerCounter(e,t){return this.simpleMetrics.registerCounter(e,t)}registerCounterGroup(e,t){return this.simpleMetrics.registerCounterGroup(e,t)}async start(){this.components.events.addEventListener("peer:connect",this.onPeersUpdate),this.components.events.addEventListener("peer:disconnect",this.onPeersUpdate),this.components.events.addEventListener("peer:identify",this.onPeersUpdate),this.components.events.addEventListener("peer:update",this.onPeersUpdate),this.components.events.addEventListener("self:peer:update",this.onSelfUpdate),window.addEventListener("message",this.onIncomingMessage),this.rpc.createTarget("metrics",$s(this.components)),await Kn(this.simpleMetrics),Promise.resolve().then(async()=>{await fo(this.rpcQueue,this.rpc,async e=>{for await(let t of e)window.postMessage({source:Vs,type:"libp2p-rpc",message:de.encode(t)})})}).catch(e=>{this.log.error("error while reading RPC messages",e)})}async stop(){window.removeEventListener("message",this.onIncomingMessage),this.components.events.removeEventListener("self:peer:update",this.onSelfUpdate),this.components.events.removeEventListener("peer:connect",this.onPeersUpdate),this.components.events.removeEventListener("peer:disconnect",this.onPeersUpdate),this.components.events.removeEventListener("peer:identify",this.onPeersUpdate),this.components.events.removeEventListener("peer:update",this.onPeersUpdate),await Jn(this.simpleMetrics)}onIncomingMessage(e){if(e.source!==window)return;let t=e.data;t?.source===Os&&t.type==="libp2p-rpc"&&this.rpcQueue.push(de.decode(t.message))}onSelfUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("self",{detail:await Cr(this.components)})}).catch(e=>{this.log.error("error sending peers message",e)})}onPeersUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("peers",{detail:await Sr(this.components,this.log)})}).catch(e=>{this.log.error("error sending peers message",e)})}};function al(r){return e=>new qn(e,r)}return Js(ul);})();
|
|
2
|
+
"use strict";var Libp2PDevtoolsMetrics=(()=>{var Ir=Object.defineProperty;var zs=Object.getOwnPropertyDescriptor;var Gs=Object.getOwnPropertyNames;var js=Object.prototype.hasOwnProperty;var H=(r,e)=>{for(var t in e)Ir(r,t,{get:e[t],enumerable:!0})},qs=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Gs(e))!js.call(r,o)&&o!==t&&Ir(r,o,{get:()=>e[o],enumerable:!(n=zs(e,o))||n.enumerable});return r};var Hs=r=>qs(Ir({},"__esModule",{value:!0}),r);var ol={};H(ol,{LIBP2P_DEVTOOLS_METRICS_KEY:()=>Vs,SOURCE_CONTENT_SCRIPT:()=>rl,SOURCE_DEVTOOLS:()=>$s,SOURCE_METRICS:()=>Os,SOURCE_SERVICE_WORKER:()=>tl,devToolsMetrics:()=>nl,valueCodecs:()=>Hn});var Ft=Symbol.for("@libp2p/peer-id");function Kn(r){return r!=null&&!!r[Ft]}var _t=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};function Jn(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function Qn(...r){let e=[];for(let t of r)Jn(t)&&e.push(t);await Promise.all(e.map(async t=>{t.beforeStart!=null&&await t.beforeStart()})),await Promise.all(e.map(async t=>{await t.start()})),await Promise.all(e.map(async t=>{t.afterStart!=null&&await t.afterStart()}))}async function Zn(...r){let e=[];for(let t of r)Jn(t)&&e.push(t);await Promise.all(e.map(async t=>{t.beforeStop!=null&&await t.beforeStop()})),await Promise.all(e.map(async t=>{await t.stop()})),await Promise.all(e.map(async t=>{t.afterStop!=null&&await t.afterStop()}))}var Dt=Symbol.for("@libp2p/service-capabilities"),ul=Symbol.for("@libp2p/service-dependencies");var Fr={};H(Fr,{base32:()=>se,base32hex:()=>tc,base32hexpad:()=>nc,base32hexpadupper:()=>oc,base32hexupper:()=>rc,base32pad:()=>Ys,base32padupper:()=>ec,base32upper:()=>Zs,base32z:()=>ic});var _l=new Uint8Array(0);function Yn(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function pe(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function eo(r){return new TextEncoder().encode(r)}function to(r){return new TextDecoder().decode(r)}function Ws(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var c=r.length,u=r.charAt(0),h=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function f(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var x=0,m=0,A=0,T=y.length;A!==T&&y[A]===0;)A++,x++;for(var L=(T-A)*l+1>>>0,F=new Uint8Array(L);A!==T;){for(var j=y[A],Z=0,q=L-1;(j!==0||Z<m)&&q!==-1;q--,Z++)j+=256*F[q]>>>0,F[q]=j%c>>>0,j=j/c>>>0;if(j!==0)throw new Error("Non-zero carry");m=Z,A++}for(var Y=L-m;Y!==L&&F[Y]===0;)Y++;for(var Be=u.repeat(x);Y<L;++Y)Be+=r.charAt(F[Y]);return Be}function g(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var x=0;if(y[x]!==" "){for(var m=0,A=0;y[x]===u;)m++,x++;for(var T=(y.length-x)*h+1>>>0,L=new Uint8Array(T);y[x];){var F=t[y.charCodeAt(x)];if(F===255)return;for(var j=0,Z=T-1;(F!==0||j<A)&&Z!==-1;Z--,j++)F+=c*L[Z]>>>0,L[Z]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");A=j,x++}if(y[x]!==" "){for(var q=T-A;q!==T&&L[q]===0;)q++;for(var Y=new Uint8Array(m+(T-q)),Be=m;q!==T;)Y[Be++]=L[q++];return Y}}}function b(y){var x=g(y);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:g,decode:b}}var Xs=Ws,Ks=Xs,no=Ks;var Ur=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Tr=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return oo(this,e)}},Lr=class{decoders;constructor(e){this.decoders=e}or(e){return oo(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function oo(r,e){return new Lr({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Nr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ur(e,t,n),this.decoder=new Tr(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Re({name:r,prefix:e,encode:t,decode:n}){return new Nr(r,e,t,n)}function we({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=no(t,r);return Re({prefix:e,name:r,encode:n,decode:i=>pe(o(i))})}function Js(r,e,t,n){let o={};for(let l=0;l<e.length;++l)o[e[l]]=l;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*t/8|0),c=0,u=0,h=0;for(let l=0;l<i;++l){let f=o[r[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<t|f,c+=t,c>=8&&(c-=8,s[h++]=255&u>>c)}if(c>=t||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s}function Qs(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],s+=8;s>t;)s-=t,i+=e[o&c>>s];if(s!==0&&(i+=e[o&c<<t-s]),n)for(;i.length*t&7;)i+="=";return i}function U({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Re({prefix:e,name:r,encode(o){return Qs(o,n,t)},decode(o){return Js(o,n,t,r)}})}var se=U({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Zs=U({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ys=U({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ec=U({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),tc=U({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),rc=U({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),nc=U({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oc=U({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ic=U({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _r={};H(_r,{base58btc:()=>N,base58flickr:()=>sc});var N=we({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),sc=we({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Dr={};H(Dr,{base64:()=>de,base64pad:()=>cc,base64url:()=>ac,base64urlpad:()=>uc});var de=U({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),cc=U({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ac=U({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),uc=U({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function lc(r,e){try{if(typeof r=="string"&&r.length>0)return fc(r);if(typeof r=="number"&&isFinite(r))return e?.long?hc(r):dc(r);throw new Error("Value is not a string or number.")}catch(t){let n=pc(t)?`${t.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function fc(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!e)return NaN;let t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*315576e5;case"weeks":case"week":case"w":return t*6048e5;case"days":case"day":case"d":return t*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return t*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return t*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return t*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Bt=lc;function dc(r){let e=Math.abs(r);return e>=864e5?`${Math.round(r/864e5)}d`:e>=36e5?`${Math.round(r/36e5)}h`:e>=6e4?`${Math.round(r/6e4)}m`:e>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function hc(r){let e=Math.abs(r);return e>=864e5?Mt(r,e,864e5,"day"):e>=36e5?Mt(r,e,36e5,"hour"):e>=6e4?Mt(r,e,6e4,"minute"):e>=1e3?Mt(r,e,1e3,"second"):`${r} ms`}function Mt(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function pc(r){return typeof r=="object"&&r!==null&&"message"in r}function Mr(r){t.debug=t,t.default=t,t.coerce=u,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Bt,t.destroy=h,Object.keys(r).forEach(l=>{t[l]=r[l]}),t.names=[],t.skips=[],t.formatters={};function e(l){let f=0;for(let g=0;g<l.length;g++)f=(f<<5)-f+l.charCodeAt(g),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(l){let f,g=null,b,y;function x(...m){if(!x.enabled)return;let A=x,T=Number(new Date),L=T-(f||T);A.diff=L,A.prev=f,A.curr=T,f=T,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let F=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(Z,q)=>{if(Z==="%%")return"%";F++;let Y=t.formatters[q];if(typeof Y=="function"){let Be=m[F];Z=Y.call(A,Be),m.splice(F,1),F--}return Z}),t.formatArgs.call(A,m),(A.log||t.log).apply(A,m)}return x.namespace=l,x.useColors=t.useColors(),x.color=t.selectColor(l),x.extend=n,x.destroy=t.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>g!==null?g:(b!==t.namespaces&&(b=t.namespaces,y=t.enabled(l)),y),set:m=>{g=m}}),typeof t.init=="function"&&t.init(x),x}function n(l,f){let g=t(this.namespace+(typeof f>"u"?":":f)+l);return g.log=this.log,g}function o(l){t.save(l),t.namespaces=l,t.names=[],t.skips=[];let f,g=(typeof l=="string"?l:"").split(/[\s,]+/),b=g.length;for(f=0;f<b;f++)g[f]&&(l=g[f].replace(/\*/g,".*?"),l[0]==="-"?t.skips.push(new RegExp("^"+l.substr(1)+"$")):t.names.push(new RegExp("^"+l+"$")))}function i(){let l=[...t.names.map(c),...t.skips.map(c).map(f=>"-"+f)].join(",");return t.enable(""),l}function s(l){if(l[l.length-1]==="*")return!0;let f,g;for(f=0,g=t.skips.length;f<g;f++)if(t.skips[f].test(l))return!1;for(f=0,g=t.names.length;f<g;f++)if(t.names[f].test(l))return!0;return!1}function c(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function u(l){return l instanceof Error?l.stack??l.message:l}function h(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.setupFormatters(t.formatters),t.enable(t.load()),t}var Rt=Ec(),mc=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function gc(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function yc(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Bt(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}var wc=console.debug??console.log??(()=>{});function xc(r){try{r?Rt?.setItem("debug",r):Rt?.removeItem("debug")}catch{}}function bc(){let r;try{r=Rt?.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Ec(){try{return localStorage}catch{}}function vc(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var io=Mr({formatArgs:yc,save:xc,load:bc,useColors:gc,setupFormatters:vc,colors:mc,storage:Rt,log:wc});var O=io;O.formatters.b=r=>r==null?"undefined":N.baseEncode(r);O.formatters.t=r=>r==null?"undefined":se.baseEncode(r);O.formatters.m=r=>r==null?"undefined":de.baseEncode(r);O.formatters.p=r=>r==null?"undefined":r.toString();O.formatters.c=r=>r==null?"undefined":r.toString();O.formatters.k=r=>r==null?"undefined":r.toString();O.formatters.a=r=>r==null?"undefined":r.toString();function Sc(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function so(r){let e=Sc(`${r}:trace`);return O.enabled(`${r}:trace`)&&O.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=O(`${r}:trace`)),Object.assign(O(r),{error:O(`${r}:error`),trace:e})}function co(){O.disable()}function ao(r){O.enable(r)}function Ac(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var uo=Ac;function Cc(r){return r[Symbol.asyncIterator]!=null}function lo(r){return r?.then!=null}function kc(r,e){let t=0;if(Cc(r))return async function*(){for await(let u of r){let h=e(u,t++);lo(h)&&await h,yield u}}();let n=uo(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();if(typeof e(o,t++)?.then=="function")return async function*(){yield o;for await(let u of n){let h=e(u,t++);lo(h)&&await h,yield u}}();let c=e;return function*(){yield o;for(let u of n)c(u,t++),yield u}()}var Br=kc;var Ic=so("libp2p:simple-metrics"),ot=class{value=0;update(e){this.value=e}increment(e=1){this.value+=e}decrement(e=1){this.value-=e}reset(){this.value=0}timer(){let e=Date.now();return()=>{this.value=Date.now()-e}}},it=class{values={};update(e){Object.entries(e).forEach(([t,n])=>{this.values[t]=n})}increment(e){Object.entries(e).forEach(([t,n])=>{this.values[t]=this.values[t]??0;let o=typeof n=="number"?n:1;this.values[t]+=Number(o)})}decrement(e){Object.entries(e).forEach(([t,n])=>{this.values[t]=this.values[t]??0;let o=typeof n=="number"?n:1;this.values[t]-=Number(o)})}reset(){this.values={}}timer(e){let t=Date.now();return()=>{this.values[e]=Date.now()-t}}},Rr=class{metrics=new Map;transferStats;started;interval;intervalMs;onMetrics;constructor(e,t){this.started=!1,this._emitMetrics=this._emitMetrics.bind(this),this.intervalMs=t.intervalMs??1e3,this.onMetrics=t.onMetrics,this.transferStats=new Map}[Symbol.toStringTag]="@libp2p/metrics-simple";[Dt]=["@libp2p/metrics"];isStarted(){return this.started}start(){this.started=!0,this.interval=setInterval(this._emitMetrics,this.intervalMs)}stop(){this.started=!1,clearInterval(this.interval)}_emitMetrics(){Promise.resolve().then(async()=>{let e={};for(let[t,n]of this.metrics.entries())n instanceof ot?e[t]=n.value:n instanceof it?e[t]=n.values:e[t]=await n();this.onMetrics(structuredClone(e))}).catch(e=>{Ic.error("could not invoke onMetrics callback",e)})}_incrementValue(e,t){let n=this.transferStats.get(e)??0;this.transferStats.set(e,n+t)}_track(e,t){let n=this,o=e.sink;e.sink=async function(c){await o(Br(c,u=>{n._incrementValue(`${t} sent`,u.byteLength)}))};let i=e.source;e.source=Br(i,s=>{n._incrementValue(`${t} received`,s.byteLength)})}trackMultiaddrConnection(e){this._track(e,"global")}trackProtocolStream(e,t){e.protocol!=null&&this._track(e,e.protocol)}registerMetric(e,t={}){if(e==null||e.trim()==="")throw new Error("Metric name is required");if(t?.calculate!=null){this.metrics.set(e,t.calculate);return}let n=new ot;return this.metrics.set(e,n),n}registerMetricGroup(e,t={}){if(e==null||e.trim()==="")throw new Error("Metric name is required");if(t?.calculate!=null){this.metrics.set(e,t.calculate);return}let n=new it;return this.metrics.set(e,n),n}registerCounter(e,t={}){if(e==null||e.trim()==="")throw new Error("Metric name is required");if(t?.calculate!=null){this.metrics.set(e,t.calculate);return}let n=new ot;return this.metrics.set(e,n),n}registerCounterGroup(e,t={}){if(e==null||e.trim()==="")throw new Error("Metric name is required");if(t?.calculate!=null){this.metrics.set(e,t.calculate);return}let n=new it;return this.metrics.set(e,n),n}};function fo(r){return e=>new Rr(e,r)}function ce(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Pt=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},Pe=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Pt(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new Pt(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var Pr=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function xe(r={}){return Uc(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Uc(r,e){e=e??{};let t=e.onEnd,n=new Pe,o,i,s,c=ce(),u=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((m,A)=>{i=T=>{i=null,n.push(T);try{m(r(n))}catch(L){A(L)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=ce()})}},h=m=>i!=null?i(m):(n.push(m),o),l=m=>(n=new Pe,i!=null?i({error:m}):(n.push({error:m}),o)),f=m=>{if(s)return o;if(e?.objectMode!==!0&&m?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return h({done:!1,value:m})},g=m=>s?o:(s=!0,m!=null?l(m):h({done:!0})),b=()=>(n=new Pe,g(),{done:!0}),y=m=>(g(m),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:u,return:b,throw:y,push:f,end:g,get readableLength(){return n.size},onEmpty:async m=>{let A=m?.signal;if(A?.throwIfAborted(),n.isEmpty())return;let T,L;A!=null&&(T=new Promise((F,j)=>{L=()=>{j(new Pr)},A.addEventListener("abort",L)}));try{await Promise.race([c.promise,T])}finally{L!=null&&A!=null&&A?.removeEventListener("abort",L)}}},t==null)return o;let x=o;return o={[Symbol.asyncIterator](){return this},next(){return x.next()},throw(m){return x.throw(m),t!=null&&(t(m),t=void 0),{done:!0}},return(){return x.return(),t!=null&&(t(),t=void 0),{done:!0}},push:f,end(m){return x.end(m),t!=null&&(t(m),t=void 0),o},get readableLength(){return x.readableLength},onEmpty:m=>x.onEmpty(m)},o}function Tc(r){return r[Symbol.asyncIterator]!=null}function Lc(...r){let e=[];for(let t of r)Tc(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=xe({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)t.push(o)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var ho=Lc;function po(r,...e){if(r==null)throw new Error("Empty pipeline");if($r(r)){let n=r;r=()=>n.source}else if(go(r)||mo(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&$r(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)$r(t[n])&&(t[n]=Fc(t[n]));return Nc(...t)}var Nc=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},mo=r=>r?.[Symbol.asyncIterator]!=null,go=r=>r?.[Symbol.iterator]!=null,$r=r=>r==null?!1:r.sink!=null&&r.source!=null,Fc=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=xe({objectMode:!0});t.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(mo(i))o=async function*(){yield*i,n.end()};else if(go(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return ho(n,o())}return r.source};function $t(r){let e=new globalThis.AbortController;function t(){e.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}for(let i of r){if(i?.aborted===!0){t();break}i?.addEventListener!=null&&i.addEventListener("abort",t)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}let o=e.signal;return o.clear=n,o}function ae(r=0){return new Uint8Array(r)}function R(r=0){return new Uint8Array(r)}var _c=Math.pow(2,7),Dc=Math.pow(2,14),Mc=Math.pow(2,21),Or=Math.pow(2,28),Vr=Math.pow(2,35),zr=Math.pow(2,42),Gr=Math.pow(2,49),S=128,P=127;function _(r){if(r<_c)return 1;if(r<Dc)return 2;if(r<Mc)return 3;if(r<Or)return 4;if(r<Vr)return 5;if(r<zr)return 6;if(r<Gr)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function jr(r,e,t=0){switch(_(r)){case 8:e[t++]=r&255|S,r/=128;case 7:e[t++]=r&255|S,r/=128;case 6:e[t++]=r&255|S,r/=128;case 5:e[t++]=r&255|S,r/=128;case 4:e[t++]=r&255|S,r>>>=7;case 3:e[t++]=r&255|S,r>>>=7;case 2:e[t++]=r&255|S,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Bc(r,e,t=0){switch(_(r)){case 8:e.set(t++,r&255|S),r/=128;case 7:e.set(t++,r&255|S),r/=128;case 6:e.set(t++,r&255|S),r/=128;case 5:e.set(t++,r&255|S),r/=128;case 4:e.set(t++,r&255|S),r>>>=7;case 3:e.set(t++,r&255|S),r>>>=7;case 2:e.set(t++,r&255|S),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function qr(r,e){let t=r[e],n=0;if(n+=t&P,t<S||(t=r[e+1],n+=(t&P)<<7,t<S)||(t=r[e+2],n+=(t&P)<<14,t<S)||(t=r[e+3],n+=(t&P)<<21,t<S)||(t=r[e+4],n+=(t&P)*Or,t<S)||(t=r[e+5],n+=(t&P)*Vr,t<S)||(t=r[e+6],n+=(t&P)*zr,t<S)||(t=r[e+7],n+=(t&P)*Gr,t<S))return n;throw new RangeError("Could not decode varint")}function Rc(r,e){let t=r.get(e),n=0;if(n+=t&P,t<S||(t=r.get(e+1),n+=(t&P)<<7,t<S)||(t=r.get(e+2),n+=(t&P)<<14,t<S)||(t=r.get(e+3),n+=(t&P)<<21,t<S)||(t=r.get(e+4),n+=(t&P)*Or,t<S)||(t=r.get(e+5),n+=(t&P)*Vr,t<S)||(t=r.get(e+6),n+=(t&P)*zr,t<S)||(t=r.get(e+7),n+=(t&P)*Gr,t<S))return n;throw new RangeError("Could not decode varint")}function be(r,e,t=0){return e==null&&(e=R(_(r))),e instanceof Uint8Array?jr(r,e,t):Bc(r,e,t)}function me(r,e=0){return r instanceof Uint8Array?qr(r,e):Rc(r,e)}function ee(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=R(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function ke(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var wo=Symbol.for("@achingbrain/uint8arraylist");function yo(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function Vt(r){return!!r?.[wo]}var $e=class r{bufs;length;[wo]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(Vt(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(Vt(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=yo(this.bufs,e);return t.buf[t.index]}set(e,t){let n=yo(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(Vt(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return ee(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:ee(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),i=new r;return i.length=o,i.bufs=[...n],i}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,u=c+s.byteLength;if(o=u,e>=u)continue;let h=e>=c&&e<u,l=t>c&&t<=u;if(h&&l){if(e===c&&t===u){n.push(s);break}let f=e-c;n.push(s.subarray(f,f+(t-e)));break}if(h){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(l){if(t===u){n.push(s);break}n.push(s.subarray(0,t-c));break}n.push(s)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!Vt(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let c=s,u=this.byteLength-n.byteLength,h=n.byteLength-1,l;for(let f=t;f<=u;f+=l){l=0;for(let g=h;g>=0;g--){let b=this.get(f+g);if(n[g]!==b){l=Math.max(1,g-c[b]);break}}if(l===0)return f}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=R(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=ae(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=ae(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=ae(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=R(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=ae(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=ae(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=ae(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=ae(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=ae(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!ke(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((o,i)=>o+i.byteLength,0)),n.length=t,n}};function zt(r){return r[Symbol.asyncIterator]!=null}var Gt=r=>{let e=_(r),t=R(e);return be(r,t),Gt.bytes=e,t};Gt.bytes=0;function jt(r,e){e=e??{};let t=e.lengthEncoder??Gt;function*n(o){let i=t(o.byteLength);i instanceof Uint8Array?yield i:yield*i,o instanceof Uint8Array?yield o:yield*o}return zt(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}jt.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??Gt;return new $e(t(r.byteLength),r)};var qt=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Ht=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Wt=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},st=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var Pc=8,$c=1024*1024*4,Ie;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Ie||(Ie={}));var Hr=r=>{let e=me(r);return Hr.bytes=_(e),e};Hr.bytes=0;function ct(r,e){let t=new $e,n=Ie.LENGTH,o=-1,i=e?.lengthDecoder??Hr,s=e?.maxLengthLength??Pc,c=e?.maxDataLength??$c;function*u(){for(;t.byteLength>0;){if(n===Ie.LENGTH)try{if(o=i(t),o<0)throw new qt("Invalid message length");if(o>c)throw new Ht("Message length too long");let h=i.bytes;t.consume(h),e?.onLength!=null&&e.onLength(o),n=Ie.DATA}catch(h){if(h instanceof RangeError){if(t.byteLength>s)throw new Wt("Message length length too long");break}throw h}if(n===Ie.DATA){if(t.byteLength<o)break;let h=t.sublist(0,o);t.consume(o),e?.onData!=null&&e.onData(h),yield h,n=Ie.LENGTH}}}return zt(r)?async function*(){for await(let h of r)t.append(h),yield*u();if(t.byteLength>0)throw new st("Unexpected end of input")}():function*(){for(let h of r)t.append(h),yield*u();if(t.byteLength>0)throw new st("Unexpected end of input")}()}ct.fromReader=(r,e)=>{let t=1,n=async function*(){for(;;)try{let{done:i,value:s}=await r.next(t);if(i===!0)return;s!=null&&(yield s)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{t=1}}();return ct(n,{...e??{},onLength:i=>{t=i}})};var xo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Oe=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r));for(;r--;)e+=xo[t[r]&63];return e};var Xt=class extends Error{constructor(e="Method not found"){super(e),this.name="MethodNotFoundError"}},Kt=class extends Error{constructor(e="Invocation target was not a function"){super(e),this.name="InvalidMethodError"}},at=class extends Error{constructor(e="Unsupported value type"){super(e),this.name="UnsupportedValueTypeError"}},Jt=class extends Error{constructor(e="Cannot reuse RPC target name"){super(e),this.name="DuplicateTargetNameError"}},ut=class extends Error{constructor(e="Duplicate scope"){super(e),this.name="DuplicateScopeError"}},Qt=class extends Error{constructor(e="Invalid return type"){super(e),this.name="InvalidReturnTypeError"}},lt=class extends Error{constructor(e="Invocation target was not a function"){super(e),this.name="InvalidInvocationTypeError"}},Ve=class extends Error{constructor(e="Parent invocation scope not found"){super(e),this.name="MissingParentScopeError"}},Zt=class extends Error{constructor(e="Invocation not found"){super(e),this.name="MissingInvocationError"}},Yt=class extends Error{constructor(e="Callback not found"){super(e),this.name="MissingCallbackError"}};var Wr=new Float32Array([-0]),Ee=new Uint8Array(Wr.buffer);function bo(r,e,t){Wr[0]=r,e[t]=Ee[0],e[t+1]=Ee[1],e[t+2]=Ee[2],e[t+3]=Ee[3]}function Eo(r,e){return Ee[0]=r[e],Ee[1]=r[e+1],Ee[2]=r[e+2],Ee[3]=r[e+3],Wr[0]}var Xr=new Float64Array([-0]),$=new Uint8Array(Xr.buffer);function vo(r,e,t){Xr[0]=r,e[t]=$[0],e[t+1]=$[1],e[t+2]=$[2],e[t+3]=$[3],e[t+4]=$[4],e[t+5]=$[5],e[t+6]=$[6],e[t+7]=$[7]}function So(r,e){return $[0]=r[e],$[1]=r[e+1],$[2]=r[e+2],$[3]=r[e+3],$[4]=r[e+4],$[5]=r[e+5],$[6]=r[e+6],$[7]=r[e+7],Xr[0]}var Oc=BigInt(Number.MAX_SAFE_INTEGER),Vc=BigInt(Number.MIN_SAFE_INTEGER),W=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Ue;if(e<Oc&&e>Vc)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>Ao&&(o=0n,++n>Ao&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return Ue;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):Ue}},Ue=new W(0,0);Ue.toBigInt=function(){return 0n};Ue.zzEncode=Ue.zzDecode=function(){return this};Ue.length=function(){return 1};var Ao=4294967296n;function Co(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function ko(r,e,t){if(t-e<1)return"";let o,i=[],s=0,c;for(;e<t;)c=r[e++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|r[e++]&63:c>239&&c<365?(c=((c&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Kr(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function ue(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function er(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Jr=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,ue(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw ue(this,4);return er(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ue(this,4);return er(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw ue(this,4);let e=Eo(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw ue(this,4);let e=So(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw ue(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return ko(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw ue(this,e);this.pos+=e}else do if(this.pos>=this.len)throw ue(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new W(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw ue(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw ue(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw ue(this,8);let e=er(this.buf,this.pos+=4),t=er(this.buf,this.pos+=4);return new W(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=qr(this.buf,this.pos);return this.pos+=_(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Qr(r){return new Jr(r instanceof Uint8Array?r:r.subarray())}function te(r,e,t){let n=Qr(r);return e.decode(n,void 0,t)}var Zr={};H(Zr,{base10:()=>zc});var zc=we({prefix:"9",name:"base10",alphabet:"0123456789"});var Yr={};H(Yr,{base16:()=>Gc,base16upper:()=>jc});var Gc=U({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),jc=U({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var en={};H(en,{base2:()=>qc});var qc=U({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var tn={};H(tn,{base256emoji:()=>Jc});var Uo=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Hc=Uo.reduce((r,e,t)=>(r[t]=e,r),[]),Wc=Uo.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Xc(r){return r.reduce((e,t)=>(e+=Hc[t],e),"")}function Kc(r){let e=[];for(let t of r){let n=Wc[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Jc=Re({prefix:"\u{1F680}",name:"base256emoji",encode:Xc,decode:Kc});var rn={};H(rn,{base36:()=>Qc,base36upper:()=>Zc});var Qc=we({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Zc=we({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var nn={};H(nn,{base8:()=>Yc});var Yc=U({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var on={};H(on,{identity:()=>ea});var ea=Re({prefix:"\0",name:"identity",encode:r=>to(r),decode:r=>eo(r)});var ld=new TextEncoder,fd=new TextDecoder;var cn={};H(cn,{identity:()=>ht});var na=No,To=128,oa=127,ia=~oa,sa=Math.pow(2,31);function No(r,e,t){e=e||[],t=t||0;for(var n=t;r>=sa;)e[t++]=r&255|To,r/=128;for(;r&ia;)e[t++]=r&255|To,r>>>=7;return e[t]=r|0,No.bytes=t-n+1,e}var ca=sn,aa=128,Lo=127;function sn(r,n){var t=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw sn.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&Lo)<<o:(s&Lo)*Math.pow(2,o),o+=7}while(s>=aa);return sn.bytes=i-n,t}var ua=Math.pow(2,7),la=Math.pow(2,14),fa=Math.pow(2,21),da=Math.pow(2,28),ha=Math.pow(2,35),pa=Math.pow(2,42),ma=Math.pow(2,49),ga=Math.pow(2,56),ya=Math.pow(2,63),wa=function(r){return r<ua?1:r<la?2:r<fa?3:r<da?4:r<ha?5:r<pa?6:r<ma?7:r<ga?8:r<ya?9:10},xa={encode:na,decode:ca,encodingLength:wa},ba=xa,ft=ba;function dt(r,e=0){return[ft.decode(r,e),ft.decode.bytes]}function ze(r,e,t=0){return ft.encode(r,e,t),e}function Ge(r){return ft.encodingLength(r)}function ve(r,e){let t=e.byteLength,n=Ge(r),o=n+Ge(t),i=new Uint8Array(o+t);return ze(r,i,0),ze(t,i,n),i.set(e,o),new je(r,t,e,i)}function Te(r){let e=pe(r),[t,n]=dt(e),[o,i]=dt(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new je(t,o,s,e)}function Fo(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Yn(r.bytes,t.bytes)}}var je=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var _o=0,Ea="identity",Do=pe;function va(r){return ve(_o,Do(r))}var ht={code:_o,name:Ea,encode:Do,digest:va};var ln={};H(ln,{sha256:()=>rr,sha512:()=>Sa});function un({name:r,code:e,encode:t}){return new an(r,e,t)}var an=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?ve(this.code,t):t.then(n=>ve(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Bo(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var rr=un({name:"sha2-256",code:18,encode:Bo("SHA-256")}),Sa=un({name:"sha2-512",code:19,encode:Bo("SHA-512")});function Ro(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Ca(t,fn(r),e??N.encoder);default:return ka(t,fn(r),e??se.encoder)}}var Po=new WeakMap;function fn(r){let e=Po.get(r);if(e==null){let t=new Map;return Po.set(r,t),t}return e}var z=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==pt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ia)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=ve(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&Fo(e.multihash,n.multihash)}toString(e){return Ro(this,e)}toJSON(){return{"/":Ro(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??$o(n,o,i.bytes))}else if(t[Ua]===!0){let{version:n,multihash:o,code:i}=t,s=Te(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==pt)throw new Error(`Version 0 CID must use dag-pb (code: ${pt}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=$o(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,pt,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=pe(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new je(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,g]=dt(e.subarray(t));return t+=g,f},o=n(),i=pt;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,c=n(),u=n(),h=t+u,l=h-s;return{version:o,codec:i,multihashCode:c,digestSize:u,multihashSize:l,size:h}}static parse(e,t){let[n,o]=Aa(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return fn(i).set(n,e),i}};function Aa(r,e){switch(r[0]){case"Q":{let t=e??N;return[N.prefix,t.decode(`${N.prefix}${r}`)]}case N.prefix:{let t=e??N;return[N.prefix,t.decode(r)]}case se.prefix:{let t=e??se;return[se.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Ca(r,e,t){let{prefix:n}=t;if(n!==N.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function ka(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var pt=112,Ia=18;function $o(r,e,t){let n=Ge(r),o=n+Ge(e),i=new Uint8Array(o+t.byteLength);return ze(r,i,0),ze(e,i,n),i.set(t,o),i}var Ua=Symbol.for("@ipld/js-cid/CID");var Se={...on,...en,...nn,...Zr,...Yr,...Fr,...rn,..._r,...Dr,...tn},Fd={...ln,...cn};function Vo(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Oo=Vo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),dn=Vo("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=R(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Ta={utf8:Oo,"utf-8":Oo,hex:Se.base16,latin1:dn,ascii:dn,binary:dn,...Se},nr=Ta;function Ne(r,e="utf8"){let t=nr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function hn(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return R(s);o+s>e&&(n=R(e),o=0);let c=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),c}}var Fe=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function pn(){}var gn=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},La=hn();function Na(r){return globalThis.Buffer!=null?R(r):La(r)}var gt=class{len;head;tail;states;constructor(){this.len=0,this.head=new Fe(pn,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Fe(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new yn((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(or,10,W.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=W.fromBigInt(e);return this._push(or,t.length(),t)}uint64Number(e){return this._push(jr,_(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=W.fromBigInt(e).zzEncode();return this._push(or,t.length(),t)}sint64Number(e){let t=W.fromNumber(e).zzEncode();return this._push(or,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(mn,1,e?1:0)}fixed32(e){return this._push(mt,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=W.fromBigInt(e);return this._push(mt,4,t.lo)._push(mt,4,t.hi)}fixed64Number(e){let t=W.fromNumber(e);return this._push(mt,4,t.lo)._push(mt,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(bo,4,e)}double(e){return this._push(vo,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(mn,1,0):this.uint32(t)._push(_a,t,e)}string(e){let t=Co(e);return t!==0?this.uint32(t)._push(Kr,t,e):this._push(mn,1,0)}fork(){return this.states=new gn(this),this.head=this.tail=new Fe(pn,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Fe(pn,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=Na(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function mn(r,e,t){e[t]=r&255}function Fa(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var yn=class extends Fe{next;constructor(e,t){super(Fa,e,t),this.next=void 0}};function or(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function mt(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function _a(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(gt.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Da,e,r),this},gt.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Ma,e,r),this});function Da(r,e,t){e.set(r,t)}function Ma(r,e,t){r.length<40?Kr(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Ne(r),t)}function wn(){return new gt}function re(r,e){let t=wn();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var qe;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(qe||(qe={}));function ir(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function xn(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let c=e(i);s.int32(c)},n=function(i){let s=i.int32();return e(s)};return ir("enum",qe.VARINT,t,n)}function ne(r,e){return ir("message",qe.LENGTH_DELIMITED,r,e)}var ge=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var E;(function(r){r.invokeMethod="invokeMethod",r.methodResolved="methodResolved",r.methodRejected="methodRejected",r.invokeGeneratorMethod="invokeGeneratorMethod",r.abortMethodInvocation="abortMethodInvocation",r.invokeCallback="invokeCallback",r.callbackResolved="callbackResolved",r.callbackRejected="callbackRejected",r.abortCallbackInvocation="abortCallbackInvocation"})(E||(E={}));var sr;(function(r){r[r.invokeMethod=0]="invokeMethod",r[r.methodResolved=1]="methodResolved",r[r.methodRejected=2]="methodRejected",r[r.invokeGeneratorMethod=3]="invokeGeneratorMethod",r[r.abortMethodInvocation=4]="abortMethodInvocation",r[r.invokeCallback=5]="invokeCallback",r[r.callbackResolved=6]="callbackResolved",r[r.callbackRejected=7]="callbackRejected",r[r.abortCallbackInvocation=8]="abortCallbackInvocation"})(sr||(sr={}));(function(r){r.codec=()=>xn(sr)})(E||(E={}));var G;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.type!=null&&t.type!==0&&(n.uint32(8),n.uint32(t.type)),t.value!=null&&(n.uint32(18),n.bytes(t.value)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={type:0},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.type=t.uint32();break}case 2:{i.value=t.bytes();break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(G||(G={}));var V;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.type!=null&&sr[t.type]!==0&&(n.uint32(8),E.codec().encode(t.type,n)),t.message!=null&&t.message.byteLength>0&&(n.uint32(18),n.bytes(t.message)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={type:E.invokeMethod,message:ae(0)},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.type=E.codec().decode(t);break}case 2:{i.message=t.bytes();break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(V||(V={}));var _e;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.path!=null&&t.path!==""&&(n.uint32(18),n.string(t.path)),t.args!=null)for(let i of t.args)n.uint32(26),G.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:"",path:"",args:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{i.path=t.string();break}case 3:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new ge('Decode error - map field "args" had too many elements');i.args.push(G.codec().decode(t,t.uint32(),{limits:o.limits?.args$}));break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(_e||(_e={}));var yt;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(yt||(yt={}));var He;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.value!=null&&(n.uint32(18),G.codec().encode(t.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{i.value=G.codec().decode(t,t.uint32(),{limits:o.limits?.value});break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(He||(He={}));var wt;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.error!=null&&(n.uint32(18),G.codec().encode(t.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{i.error=G.codec().decode(t,t.uint32(),{limits:o.limits?.error});break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(wt||(wt={}));var We;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.parents!=null)for(let i of t.parents)n.uint32(18),n.string(i);if(t.callback!=null&&t.callback!==""&&(n.uint32(26),n.string(t.callback)),t.args!=null)for(let i of t.args)n.uint32(34),G.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:"",parents:[],callback:"",args:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new ge('Decode error - map field "parents" had too many elements');i.parents.push(t.string());break}case 3:{i.callback=t.string();break}case 4:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new ge('Decode error - map field "args" had too many elements');i.args.push(G.codec().decode(t,t.uint32(),{limits:o.limits?.args$}));break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(We||(We={}));var Xe;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.parents!=null)for(let i of t.parents)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:"",parents:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new ge('Decode error - map field "parents" had too many elements');i.parents.push(t.string());break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(Xe||(Xe={}));var xt;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.parents!=null)for(let i of t.parents)n.uint32(18),n.string(i);t.value!=null&&(n.uint32(26),G.codec().encode(t.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:"",parents:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new ge('Decode error - map field "parents" had too many elements');i.parents.push(t.string());break}case 3:{i.value=G.codec().decode(t,t.uint32(),{limits:o.limits?.value});break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(xt||(xt={}));var bt;(function(r){let e;r.codec=()=>(e==null&&(e=ne((t,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),t.scope!=null&&t.scope!==""&&(n.uint32(10),n.string(t.scope)),t.parents!=null)for(let i of t.parents)n.uint32(18),n.string(i);t.error!=null&&(n.uint32(26),G.codec().encode(t.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={scope:"",parents:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{i.scope=t.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new ge('Decode error - map field "parents" had too many elements');i.parents.push(t.string());break}case 3:{i.error=G.codec().decode(t,t.uint32(),{limits:o.limits?.error});break}default:{t.skipType(c&7);break}}}return i})),e),r.encode=t=>re(t,r.codec()),r.decode=(t,n)=>te(t,r.codec(),n)})(bt||(bt={}));function Ba(r){return r.parents!=null}function zo(r,e){if(Ba(r))return Ra(r.parents,e);let t=e.get(r.scope);if(t==null)throw new Zt;return t}function Ra(r,e){let t;for(let n of r){if(t==null){if(t=e.get(n),t==null)throw new Ve;continue}if(t=t.children.get(n),t==null)throw new Ve}if(t==null)throw new Ve;return t}var Pa={type:1024,canEncode:r=>r===void 0,decode:()=>{}},Go=Pa;var $a={type:1025,canEncode:r=>r===null,decode:()=>null},jo=$a;var Oa=["string","number","bigint","symbol"],Va=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function qo(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(Oa.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(za(r))return"Buffer";let t=Ga(r);return t||"Object"}function za(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Ga(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Va.includes(e))return e}var a=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};a.uint=new a(0,"uint",!0);a.negint=new a(1,"negint",!0);a.bytes=new a(2,"bytes",!0);a.string=new a(3,"string",!0);a.array=new a(4,"array",!1);a.map=new a(5,"map",!1);a.tag=new a(6,"tag",!1);a.float=new a(7,"float",!0);a.false=new a(7,"false",!0);a.true=new a(7,"true",!0);a.null=new a(7,"null",!0);a.undefined=new a(7,"undefined",!0);a.break=new a(7,"break",!0);var p=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Ke=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",ja=new TextDecoder,qa=new TextEncoder;function cr(r){return Ke&&globalThis.Buffer.isBuffer(r)}function bn(r){return r instanceof Uint8Array?cr(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Ko=Ke?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Wo(r,e,t):(r,e,t)=>t-e>64?ja.decode(r.subarray(e,t)):Wo(r,e,t),Jo=Ke?r=>r.length>64?globalThis.Buffer.from(r):Ho(r):r=>r.length>64?qa.encode(r):Ho(r),he=r=>Uint8Array.from(r),Je=Ke?(r,e,t)=>cr(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Qo=Ke?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),bn(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},Zo=Ke?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Yo(r,e){if(cr(r)&&cr(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function Ho(r){let e=[],t=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128)}return e}function Wo(r,e,t){let n=[];for(;e<t;){let o=r[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=t){let c,u,h,l;switch(s){case 1:o<128&&(i=o);break;case 2:c=r[e+1],(c&192)===128&&(l=(o&31)<<6|c&63,l>127&&(i=l));break;case 3:c=r[e+1],u=r[e+2],(c&192)===128&&(u&192)===128&&(l=(o&15)<<12|(c&63)<<6|u&63,l>2047&&(l<55296||l>57343)&&(i=l));break;case 4:c=r[e+1],u=r[e+2],h=r[e+3],(c&192)===128&&(u&192)===128&&(h&192)===128&&(l=(o&15)<<18|(c&63)<<12|(u&63)<<6|h&63,l>65535&&l<1114112&&(i=l))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return Ha(n)}var Xo=4096;function Ha(r){let e=r.length;if(e<=Xo)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Xo));return t}var Wa=256,Et=class{constructor(e=Wa){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=t.length-(this.maxCursor-this.cursor)-1;t.set(e,o)}else{if(t){let o=t.length-(this.maxCursor-this.cursor)-1;o<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=Zo(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Je(n,0,this.cursor)}else t=Qo(this.chunks,this.cursor);return e&&this.reset(),t}};var w="CBOR decode error:",En="CBOR encode error:",vt=[];vt[23]=1;vt[24]=2;vt[25]=3;vt[26]=5;vt[27]=9;function ye(r,e,t){if(r.length-e<t)throw new Error(`${w} not enough data for type`)}var D=[24,256,65536,4294967296,BigInt("18446744073709551616")];function X(r,e,t){ye(r,e,1);let n=r[e];if(t.strict===!0&&n<D[0])throw new Error(`${w} integer encoded in more bytes than necessary (strict decode)`);return n}function K(r,e,t){ye(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<D[1])throw new Error(`${w} integer encoded in more bytes than necessary (strict decode)`);return n}function J(r,e,t){ye(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<D[2])throw new Error(`${w} integer encoded in more bytes than necessary (strict decode)`);return n}function Q(r,e,t){ye(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],o=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&i<D[3])throw new Error(`${w} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(t.allowBigInt===!0)return i;throw new Error(`${w} integers outside of the safe integer range are not supported`)}function ei(r,e,t,n){return new p(a.uint,X(r,e+1,n),2)}function ti(r,e,t,n){return new p(a.uint,K(r,e+1,n),3)}function ri(r,e,t,n){return new p(a.uint,J(r,e+1,n),5)}function ni(r,e,t,n){return new p(a.uint,Q(r,e+1,n),9)}function oe(r,e){return M(r,0,e.value)}function M(r,e,t){if(t<D[0]){let n=Number(t);r.push([e|n])}else if(t<D[1]){let n=Number(t);r.push([e|24,n])}else if(t<D[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<D[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<D[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${w} encountered BigInt larger than allowable range`)}}oe.encodedSize=function(e){return M.encodedSize(e.value)};M.encodedSize=function(e){return e<D[0]?1:e<D[1]?2:e<D[2]?3:e<D[3]?5:9};oe.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function oi(r,e,t,n){return new p(a.negint,-1-X(r,e+1,n),2)}function ii(r,e,t,n){return new p(a.negint,-1-K(r,e+1,n),3)}function si(r,e,t,n){return new p(a.negint,-1-J(r,e+1,n),5)}var vn=BigInt(-1),ci=BigInt(1);function ai(r,e,t,n){let o=Q(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new p(a.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${w} integers outside of the safe integer range are not supported`);return new p(a.negint,vn-BigInt(o),9)}function ar(r,e){let t=e.value,n=typeof t=="bigint"?t*vn-ci:t*-1-1;M(r,e.type.majorEncoded,n)}ar.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*vn-ci:t*-1-1;return n<D[0]?1:n<D[1]?2:n<D[2]?3:n<D[3]?5:9};ar.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function St(r,e,t,n){ye(r,e,t+n);let o=Je(r,e+t,e+t+n);return new p(a.bytes,o,t+n)}function ui(r,e,t,n){return St(r,e,1,t)}function li(r,e,t,n){return St(r,e,2,X(r,e+1,n))}function fi(r,e,t,n){return St(r,e,3,K(r,e+1,n))}function di(r,e,t,n){return St(r,e,5,J(r,e+1,n))}function hi(r,e,t,n){let o=Q(r,e+1,n);if(typeof o=="bigint")throw new Error(`${w} 64-bit integer bytes lengths not supported`);return St(r,e,9,o)}function ur(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===a.string?Jo(r.value):r.value),r.encodedBytes}function Qe(r,e){let t=ur(e);M(r,e.type.majorEncoded,t.length),r.push(t)}Qe.encodedSize=function(e){let t=ur(e);return M.encodedSize(t.length)+t.length};Qe.compareTokens=function(e,t){return Ka(ur(e),ur(t))};function Ka(r,e){return r.length<e.length?-1:r.length>e.length?1:Yo(r,e)}function At(r,e,t,n,o){let i=t+n;ye(r,e,i);let s=new p(a.string,Ko(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Je(r,e+t,e+i)),s}function pi(r,e,t,n){return At(r,e,1,t,n)}function mi(r,e,t,n){return At(r,e,2,X(r,e+1,n),n)}function gi(r,e,t,n){return At(r,e,3,K(r,e+1,n),n)}function yi(r,e,t,n){return At(r,e,5,J(r,e+1,n),n)}function wi(r,e,t,n){let o=Q(r,e+1,n);if(typeof o=="bigint")throw new Error(`${w} 64-bit integer string lengths not supported`);return At(r,e,9,o,n)}var xi=Qe;function Ze(r,e,t,n){return new p(a.array,n,t)}function bi(r,e,t,n){return Ze(r,e,1,t)}function Ei(r,e,t,n){return Ze(r,e,2,X(r,e+1,n))}function vi(r,e,t,n){return Ze(r,e,3,K(r,e+1,n))}function Si(r,e,t,n){return Ze(r,e,5,J(r,e+1,n))}function Ai(r,e,t,n){let o=Q(r,e+1,n);if(typeof o=="bigint")throw new Error(`${w} 64-bit integer array lengths not supported`);return Ze(r,e,9,o)}function Ci(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${w} indefinite length items not allowed`);return Ze(r,e,1,1/0)}function lr(r,e){M(r,a.array.majorEncoded,e.value)}lr.compareTokens=oe.compareTokens;lr.encodedSize=function(e){return M.encodedSize(e.value)};function Ye(r,e,t,n){return new p(a.map,n,t)}function ki(r,e,t,n){return Ye(r,e,1,t)}function Ii(r,e,t,n){return Ye(r,e,2,X(r,e+1,n))}function Ui(r,e,t,n){return Ye(r,e,3,K(r,e+1,n))}function Ti(r,e,t,n){return Ye(r,e,5,J(r,e+1,n))}function Li(r,e,t,n){let o=Q(r,e+1,n);if(typeof o=="bigint")throw new Error(`${w} 64-bit integer map lengths not supported`);return Ye(r,e,9,o)}function Ni(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${w} indefinite length items not allowed`);return Ye(r,e,1,1/0)}function fr(r,e){M(r,a.map.majorEncoded,e.value)}fr.compareTokens=oe.compareTokens;fr.encodedSize=function(e){return M.encodedSize(e.value)};function Fi(r,e,t,n){return new p(a.tag,t,1)}function _i(r,e,t,n){return new p(a.tag,X(r,e+1,n),2)}function Di(r,e,t,n){return new p(a.tag,K(r,e+1,n),3)}function Mi(r,e,t,n){return new p(a.tag,J(r,e+1,n),5)}function Bi(r,e,t,n){return new p(a.tag,Q(r,e+1,n),9)}function dr(r,e){M(r,a.tag.majorEncoded,e.value)}dr.compareTokens=oe.compareTokens;dr.encodedSize=function(e){return M.encodedSize(e.value)};var tu=20,ru=21,nu=22,ou=23;function Ri(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${w} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new p(a.null,null,1):new p(a.undefined,void 0,1)}function Pi(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${w} indefinite length items not allowed`);return new p(a.break,void 0,1)}function Sn(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${w} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${w} Infinity values are not supported`)}return new p(a.float,r,e)}function $i(r,e,t,n){return Sn(An(r,e+1),3,n)}function Oi(r,e,t,n){return Sn(Cn(r,e+1),5,n)}function Vi(r,e,t,n){return Sn(qi(r,e+1),9,n)}function hr(r,e,t){let n=e.value;if(n===!1)r.push([a.float.majorEncoded|tu]);else if(n===!0)r.push([a.float.majorEncoded|ru]);else if(n===null)r.push([a.float.majorEncoded|nu]);else if(n===void 0)r.push([a.float.majorEncoded|ou]);else{let o,i=!1;(!t||t.float64!==!0)&&(Gi(n),o=An(le,1),n===o||Number.isNaN(n)?(le[0]=249,r.push(le.slice(0,3)),i=!0):(ji(n),o=Cn(le,1),n===o&&(le[0]=250,r.push(le.slice(0,5)),i=!0))),i||(iu(n),o=qi(le,1),le[0]=251,r.push(le.slice(0,9)))}}hr.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){Gi(n);let o=An(le,1);if(n===o||Number.isNaN(n))return 3;if(ji(n),o=Cn(le,1),n===o)return 5}return 9};var zi=new ArrayBuffer(9),ie=new DataView(zi,1),le=new Uint8Array(zi,0);function Gi(r){if(r===1/0)ie.setUint16(0,31744,!1);else if(r===-1/0)ie.setUint16(0,64512,!1);else if(Number.isNaN(r))ie.setUint16(0,32256,!1);else{ie.setFloat32(0,r);let e=ie.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)ie.setUint16(0,31744,!1);else if(t===0)ie.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?ie.setUint16(0,0):o<-14?ie.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):ie.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function An(r,e){if(r.length-e<2)throw new Error(`${w} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function ji(r){ie.setFloat32(0,r,!1)}function Cn(r,e){if(r.length-e<4)throw new Error(`${w} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function iu(r){ie.setFloat64(0,r,!1)}function qi(r,e){if(r.length-e<8)throw new Error(`${w} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}hr.compareTokens=oe.compareTokens;function v(r,e,t){throw new Error(`${w} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function pr(r){return()=>{throw new Error(`${w} ${r}`)}}var d=[];for(let r=0;r<=23;r++)d[r]=v;d[24]=ei;d[25]=ti;d[26]=ri;d[27]=ni;d[28]=v;d[29]=v;d[30]=v;d[31]=v;for(let r=32;r<=55;r++)d[r]=v;d[56]=oi;d[57]=ii;d[58]=si;d[59]=ai;d[60]=v;d[61]=v;d[62]=v;d[63]=v;for(let r=64;r<=87;r++)d[r]=ui;d[88]=li;d[89]=fi;d[90]=di;d[91]=hi;d[92]=v;d[93]=v;d[94]=v;d[95]=pr("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)d[r]=pi;d[120]=mi;d[121]=gi;d[122]=yi;d[123]=wi;d[124]=v;d[125]=v;d[126]=v;d[127]=pr("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)d[r]=bi;d[152]=Ei;d[153]=vi;d[154]=Si;d[155]=Ai;d[156]=v;d[157]=v;d[158]=v;d[159]=Ci;for(let r=160;r<=183;r++)d[r]=ki;d[184]=Ii;d[185]=Ui;d[186]=Ti;d[187]=Li;d[188]=v;d[189]=v;d[190]=v;d[191]=Ni;for(let r=192;r<=215;r++)d[r]=Fi;d[216]=_i;d[217]=Di;d[218]=Mi;d[219]=Bi;d[220]=v;d[221]=v;d[222]=v;d[223]=v;for(let r=224;r<=243;r++)d[r]=pr("simple values are not supported");d[244]=v;d[245]=v;d[246]=v;d[247]=Ri;d[248]=pr("simple values are not supported");d[249]=$i;d[250]=Oi;d[251]=Vi;d[252]=v;d[253]=v;d[254]=v;d[255]=Pi;var fe=[];for(let r=0;r<24;r++)fe[r]=new p(a.uint,r,1);for(let r=-1;r>=-24;r--)fe[31-r]=new p(a.negint,r,1);fe[64]=new p(a.bytes,new Uint8Array(0),1);fe[96]=new p(a.string,"",1);fe[128]=new p(a.array,0,1);fe[160]=new p(a.map,0,1);fe[244]=new p(a.false,!1,1);fe[245]=new p(a.true,!0,1);fe[246]=new p(a.null,null,1);function Hi(r){switch(r.type){case a.false:return he([244]);case a.true:return he([245]);case a.null:return he([246]);case a.bytes:return r.value.length?void 0:he([64]);case a.string:return r.value===""?he([96]):void 0;case a.array:return r.value===0?he([128]):void 0;case a.map:return r.value===0?he([160]):void 0;case a.uint:return r.value<24?he([Number(r.value)]):void 0;case a.negint:if(r.value>=-24)return he([31-Number(r.value)])}}var cu={float64:!1,mapSorter:lu,quickEncodeToken:Hi};function au(){let r=[];return r[a.uint.major]=oe,r[a.negint.major]=ar,r[a.bytes.major]=Qe,r[a.string.major]=xi,r[a.array.major]=lr,r[a.map.major]=fr,r[a.tag.major]=dr,r[a.float.major]=hr,r}var Wi=au(),kn=new Et,gr=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${En} object contains circular references`);return new r(t,e)}},Ae={null:new p(a.null,null),undefined:new p(a.undefined,void 0),true:new p(a.true,!0),false:new p(a.false,!1),emptyArray:new p(a.array,0),emptyMap:new p(a.map,0)},Ce={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new p(a.float,r):r>=0?new p(a.uint,r):new p(a.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new p(a.uint,r):new p(a.negint,r)},Uint8Array(r,e,t,n){return new p(a.bytes,r)},string(r,e,t,n){return new p(a.string,r)},boolean(r,e,t,n){return r?Ae.true:Ae.false},null(r,e,t,n){return Ae.null},undefined(r,e,t,n){return Ae.undefined},ArrayBuffer(r,e,t,n){return new p(a.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new p(a.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Ae.emptyArray,new p(a.break)]:Ae.emptyArray;n=gr.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=mr(s,t,n);return t.addBreakTokens?[new p(a.array,r.length),o,new p(a.break)]:[new p(a.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[Ae.emptyMap,new p(a.break)]:Ae.emptyMap;n=gr.createCheck(n,r);let c=[],u=0;for(let h of i)c[u++]=[mr(h,t,n),mr(o?r.get(h):r[h],t,n)];return uu(c,t),t.addBreakTokens?[new p(a.map,s),c,new p(a.break)]:[new p(a.map,s),c]}};Ce.Map=Ce.Object;Ce.Buffer=Ce.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ce[`${r}Array`]=Ce.DataView;function mr(r,e={},t){let n=qo(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Ce[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=Ce[n];if(!i)throw new Error(`${En} unsupported type: ${n}`);return i(r,n,e,t)}function uu(r,e){e.mapSorter&&r.sort(e.mapSorter)}function lu(r,e){let t=Array.isArray(r[0])?r[0][0]:r[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(t.type!==n.type)return t.type.compare(n.type);let o=t.type.major,i=Wi[o].compareTokens(t,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Xi(r,e,t,n){if(Array.isArray(e))for(let o of e)Xi(r,o,t,n);else t[e.type.major](r,e,n)}function fu(r,e,t){let n=mr(r,t);if(!Array.isArray(n)&&t.quickEncodeToken){let o=t.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,t),c=new Et(s);if(i(c,n,t),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return bn(c.chunks[0])}}return kn.reset(),Xi(kn,n,e,t),kn.toBytes(!0)}function C(r,e){return e=Object.assign({},cu,e),fu(r,Wi,e)}var du={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},yr=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=fe[e];if(t===void 0){let n=d[e];if(!n)throw new Error(`${w} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this._pos,o,this.options)}return this._pos+=t.encodedLength,t}},Ct=Symbol.for("DONE"),wr=Symbol.for("BREAK");function hu(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=et(e,t);if(i===wr){if(r.value===1/0)break;throw new Error(`${w} got unexpected break to lengthed array`)}if(i===Ct)throw new Error(`${w} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function pu(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let c=et(e,t);if(c===wr){if(r.value===1/0)break;throw new Error(`${w} got unexpected break to lengthed map`)}if(c===Ct)throw new Error(`${w} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${w} non-string keys not supported (got ${typeof c})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${w} found repeat map key "${c}"`);let u=et(e,t);if(u===Ct)throw new Error(`${w} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(c,u):o[c]=u}return n?i:o}function et(r,e){if(r.done())return Ct;let t=r.next();if(t.type===a.break)return wr;if(t.type.terminal)return t.value;if(t.type===a.array)return hu(t,r,e);if(t.type===a.map)return pu(t,r,e);if(t.type===a.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=et(r,e);return e.tags[t.value](n)}throw new Error(`${w} tag not supported (${t.value})`)}throw new Error("unsupported")}function Ki(r,e){if(!(r instanceof Uint8Array))throw new Error(`${w} data to decode must be a Uint8Array`);e=Object.assign({},du,e);let t=e.tokenizer||new yr(r,e),n=et(t,e);if(n===Ct)throw new Error(`${w} did not find any content to decode`);if(n===wr)throw new Error(`${w} got unexpected break`);return[n,r.subarray(t.pos())]}function k(r,e){let[t,n]=Ki(r,e);if(n.length>0)throw new Error(`${w} too many terminals, data makes no sense`);return t}var mu={type:1026,canEncode:r=>r===!0||r===!1,encode:r=>C(r),decode:r=>k(r)},Ji=mu;var gu={type:1027,canEncode:r=>typeof r=="number"&&!isNaN(r),encode:r=>C(r),decode:r=>k(r)},Qi=gu;var yu={type:1028,canEncode:r=>typeof r=="string",encode:r=>C(r),decode:r=>k(r)},Zi=yu;var wu={type:1029,canEncode:r=>Array.isArray(r),encode:(r,e,t,n)=>C(r.map(o=>e.toValue(o,t,n))),decode:(r,e,t,n)=>k(r).map(o=>e.fromValue(o,t,n))},Yi=wu;var xu={type:1030,canEncode:r=>typeof r=="function",encode:(r,e,t,n)=>{let o=Oe();return n?.callbacks.set(o,{context:t,fn:r}),C(o)},decode:(r,e,t,n)=>async(...o)=>new Promise((i,s)=>{let c=k(r),u=Oe(),h={scope:u,result:ce(),callbacks:new Map,children:new Map,parents:[...n.parents,n.scope],abortControllers:[],abortSignals:[]};n.children.set(u,h),o=o.map(f=>e.toValue(f,null,h));let l=$t(h.abortSignals);l.addEventListener("abort",()=>{t.push(V.encode({type:E.abortCallbackInvocation,message:Xe.encode({scope:u,parents:h.parents})}))}),t.push(V.encode({type:E.invokeCallback,message:We.encode({scope:u,parents:h.parents,callback:c,args:o})})),h.result.promise.then(f=>{i(f)},f=>{s(f)}).finally(()=>{n.children.delete(u),l.clear()})})},es=xu;var bu={type:1031,canEncode:r=>r.toString()==="NaN"&&isNaN(r),decode:()=>NaN},ts=bu;var Eu={type:1032,canEncode:r=>r instanceof Error,encode:r=>C({message:r.message,name:r.name,code:r.code,type:r.type,stack:r.stack}),decode:r=>{let e=k(r),t=new Error(e.message);return t.name=e.name,t.stack=e.stack,t.code=e.code,t.type=e.type,t}},rs=Eu;var vu={type:1033,canEncode:r=>Array.isArray(r),encode:(r,e,t,n)=>{throw new Error("Promises are not supported")},decode:(r,e,t,n)=>{throw new Error("Promises are not supported")}},ns=vu;var os=["__defineGetter__","__defineSetter__","hasOwnProperty","__lookupGetter__","__lookupSetter__","isPrototypeOf","propertyIsEnumerable","toString","valueOf","__proto__","toLocaleString","constructor"],Su={type:2147483647,canEncode:r=>typeof r=="object",encode:(r,e,t,n)=>{let o={};for(let i in r)os.includes(i)||Object.hasOwn(r,i)&&(o[i]=r[i]);for(let i of Object.getOwnPropertyNames(Object.getPrototypeOf(r)))os.includes(i)||(o[i]=r[i]);return C([...Object.entries(o)].map(([i,s])=>[e.toValue(i,r,n),e.toValue(s,r,n)]))},decode:(r,e,t,n)=>{let o={};return k(r).forEach(([s,c])=>{o[e.fromValue(s,t,n)]=e.fromValue(c,t,n)}),o}},kt=Su;var Au={type:1034,canEncode:r=>typeof r.next=="function"&&typeof r.throw=="function"&&typeof r.return=="function",encode:(r,e,t,n)=>kt.encode({next:r.next.bind(r),throw:r.throw.bind(r),return:r.return.bind(r)},e,t,n),decode:(r,e,t,n)=>{let o=kt.decode(r,e,t,n);return o[Symbol.asyncIterator]=()=>o,o}},is=Au;var Cu={type:1035,canEncode:r=>typeof r=="bigint",encode:r=>C(r),decode:r=>BigInt(k(r))},ss=Cu;var ku={type:1036,canEncode:r=>r instanceof Map,encode:(r,e,t,n)=>C([...r.entries()].map(([o,i])=>[e.toValue(o,t,n),e.toValue(i,t,n)])),decode:(r,e,t,n)=>{let o=new Map;return k(r).forEach(([s,c])=>{let u=e.fromValue(s,t,n),h=e.fromValue(c,t,n);o.set(u,h)}),o}},cs=ku;var Iu={type:1037,canEncode:r=>r instanceof Set,encode:(r,e,t,n)=>C([...r.values()].map(o=>e.toValue(o,t,n))),decode:(r,e,t,n)=>{let o=new Set;return k(r).forEach(s=>{o.add(e.fromValue(s,t,n))}),o}},as=Iu;var Uu={type:1038,canEncode:r=>r instanceof Uint8Array,encode:r=>r,decode:r=>r},us=Uu;var Tu={type:1039,canEncode:r=>r instanceof AbortSignal,encode:(r,e,t,n)=>(n?.abortSignals.push(r),new Uint8Array(0)),decode:(r,e,t,n)=>{let o=new AbortController;return n.abortControllers.push(o),o.signal}},ls=Tu;var Lu={type:1040,canEncode:r=>r instanceof Date,encode:r=>C(r.toString()),decode:r=>new Date(k(r))},fs=Lu;var Nu={type:1041,canEncode:r=>r instanceof RegExp,encode:r=>C({source:r.source,flags:r.flags}),decode:r=>{let{source:e,flags:t}=k(r);return new RegExp(e,t)}},ds=Nu;var hs=[Go,jo,Ji,Qi,Zi,Yi,es,ts,rs,ns,is,ss,cs,as,us,ls,fs,ds,kt];var xr=class{transformersMap;transformersList;constructor(e){this.transformersList=[...hs,...e?.valueCodecs??[]].sort((t,n)=>t.type<n.type?-1:t.type>n.type?1:0),this.transformersMap={},this.transformersList.forEach(t=>{if(this.transformersMap[t.type]!=null)throw new Error(`Duplicate transformer type ${t.type}`);this.transformersMap[t.type]=t})}toValue(e,t,n){for(let o=0;o<this.transformersList.length;o++){let i=this.transformersList[o];if(i.canEncode(e))return{type:i.type,value:i.encode?.(e,this,t,n)}}throw new at(`Unsupported value type "${e}"`)}fromValue(e,t,n){let o=this.transformersMap[e.type];if(o==null)throw new at(`Unsupported value type "${e.type}"`);return o.decode(e.value??new Uint8Array(0),this,t,n)}};function Fu(r){return r.isScope===!0}function _u(r){return r.type===E.invokeMethod||r.type===E.invokeGeneratorMethod||r.type===E.invokeCallback}var In=class{source;output;targets;invocations;values;messageHandlers;constructor(e){this.output=xe(),this.source=jt(this.output),this.targets=new Map,this.invocations=new Map,this.values=new xr(e),this.sink=this.sink.bind(this),this.messageHandlers={[E.invokeMethod]:{decoder:_e,handler:this.handleInvokeMethod.bind(this)},[E.invokeGeneratorMethod]:{decoder:_e,handler:this.handleInvokeGeneratorMethod.bind(this)},[E.abortMethodInvocation]:{decoder:yt,handler:this.handleAbortMethod.bind(this),isScope:!0},[E.methodResolved]:{decoder:He,handler:this.handleMethodResolved.bind(this),isScope:!0},[E.methodRejected]:{decoder:wt,handler:this.handleMethodRejected.bind(this),isScope:!0,isError:!0},[E.invokeCallback]:{decoder:We,handler:this.handleInvokeCallback.bind(this),isScope:!0},[E.abortCallbackInvocation]:{decoder:Xe,handler:this.handleAbortCallback.bind(this),isScope:!0},[E.callbackResolved]:{decoder:xt,handler:this.handleCallbackResolved.bind(this),isScope:!0},[E.callbackRejected]:{decoder:bt,handler:this.handleCallbackRejected.bind(this),isScope:!0,isError:!0}}}async sink(e){for await(let t of ct(e))try{let n=V.decode(t),o=this.messageHandlers[n.type];if(o==null)continue;let i=o.decoder.decode(n.message),s;if(Fu(o))try{s=zo(i,this.invocations)}catch{continue}o.handler(i,s).catch(c=>{_u(n)&&this.sendError(i,c),this.invocations.delete(i.scope)}).finally(()=>{n.type===E.invokeMethod&&this.invocations.delete(i.scope)})}catch{continue}}sendError(e,t){e.parents!=null?this.output.push(V.encode({type:E.callbackRejected,message:bt.encode({scope:e.scope,parents:e.parents,error:this.values.toValue(t)})})):this.output.push(V.encode({type:E.methodRejected,message:wt.encode({scope:e.scope,error:this.values.toValue(t)})}))}createClient(e){return this.proxy(e)}createTarget(e,t){if(this.targets.has(e))throw new Jt(`Cannot reuse RPC target name "${e}"`);this.targets.set(e,t)}async handleInvokeMethod(e){if(this.invocations.has(e.scope))throw new ut;let t=new Map,n=new Map,o={scope:e.scope,result:ce(),callbacks:t,children:n,parents:[],abortControllers:[],abortSignals:[]};this.invocations.set(e.scope,o);let i=this.lookupInvocationTarget(e.path),s=await i.fn.apply(i.context,e.args.map(c=>this.values.fromValue(c,this.output,o)));this.output.push(V.encode({type:E.methodResolved,message:He.encode({scope:e.scope,value:this.values.toValue(s)})}))}async handleAbortMethod(e,t){t.abortControllers.forEach(n=>{n.abort()})}async handleInvokeGeneratorMethod(e){if(this.invocations.has(e.scope))throw new ut;let t=new Map,n=new Map,o={scope:e.scope,result:ce(),callbacks:t,children:n,parents:[],abortControllers:[],abortSignals:[]};this.invocations.set(e.scope,o);let i=this.lookupInvocationTarget(e.path),s=i.fn.apply(i.context,e.args.map(u=>this.values.fromValue(u,this.output,o)));if(typeof s.next!="function")throw new Qt(`${e.path} did not return an async generator`);let c={next:async()=>{let u=await s.next();return u.done===!0&&this.invocations.delete(e.scope),u},throw:async u=>{try{let h=await s.throw(u);return h.done===!0&&this.invocations.delete(e.scope),h}catch(h){throw this.invocations.delete(e.scope),h}},return:async u=>{let h=await s.return(u);return h.done===!0&&this.invocations.delete(e.scope),h},[Symbol.asyncIterator]:()=>c};this.output.push(V.encode({type:E.methodResolved,message:He.encode({scope:e.scope,value:this.values.toValue(c,null,o)})}))}lookupInvocationTarget(e){let t=e.split("."),n=this.targets.get(t[0]),o=n;for(let i=1;i<t.length;i++)o=n,n=n?.[t[i]];if(n==null)throw o!=null&&e.endsWith(".then")?new Kt(`"${e.substring(0,e.length-5)}" was not a function`):new Xt(`Could not find "${e}" on target`);if(typeof n!="function")throw new lt("Invocation target was not a function");return{context:o,fn:n}}async handleMethodResolved(e,t){let n;e.value!=null&&(n=this.values.fromValue(e.value,this.output,t)),t.result.resolve(n)}async handleMethodRejected(e,t){let n;e.error!=null&&(n=this.values.fromValue(e.error,this.output,t)),t.result.reject(n)}async handleInvokeCallback(e,t){let n=t.callbacks.get(e.callback);if(n==null)throw new Yt;let o=await n.fn.apply(n.context,e.args.map(i=>this.values.fromValue(i,this.output,t)));this.output.push(V.encode({type:E.callbackResolved,message:xt.encode({scope:e.scope,parents:e.parents,value:this.values.toValue(o)})}))}async handleAbortCallback(e,t){t.abortControllers.forEach(n=>{n.abort()})}async handleCallbackResolved(e,t){let n;e.value!=null&&(n=this.values.fromValue(e.value,this.output,t)),t.children.get(e.scope)?.result.resolve(n),t.children.delete(e.scope)}async handleCallbackRejected(e,t){let n;e.error!=null&&(n=this.values.fromValue(e.error,this.output,t)),t.children.get(e.scope)?.result.reject(n),t.children.delete(e.scope)}proxy(e){let t=()=>{},n=this;return new Proxy(t,{get(o,i,s){return n.proxy(`${e==null?"":`${e}.`}${i.toString()}`)},apply(o,i,s){let c,u;function h(){return u==null&&(u=new Promise((f,g)=>{let b=Oe(),y={scope:b,result:ce(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(b,y),n.output.push(V.encode({type:E.invokeMethod,message:_e.encode({scope:b,path:e,args:s.map(m=>n.values.toValue(m,null,y))})}));let x=$t(y.abortSignals);x.addEventListener("abort",()=>{n.output.push(V.encode({type:E.abortMethodInvocation,message:yt.encode({scope:b})}))}),y.result.promise.then(m=>{f(m)},m=>{g(m)}).finally(()=>{n.invocations.delete(b),x.clear()})})),u}function l(){if(c==null){let f=Oe(),g={scope:f,result:ce(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(f,g),n.output.push(V.encode({type:E.invokeGeneratorMethod,message:_e.encode({scope:f,path:e,args:s.map(y=>n.values.toValue(y,null,g))})}));let b;c={async next(){if(b!=null)throw b;let x=await(await g.result.promise).next();return x.done===!0&&n.invocations.delete(f),x},async throw(y){if(b!=null)throw b;try{let m=await(await g.result.promise).throw(y);return m.done===!0&&n.invocations.delete(f),m}catch(x){throw n.invocations.delete(f),b=y,x}},async return(y){if(b!=null)throw b;let m=await(await g.result.promise).return(y);return m.done===!0&&n.invocations.delete(f),m},[Symbol.asyncIterator]:()=>c}}return c}return new Proxy(t,{get(f,g,b){if(g==="then")return h().then.bind(u);if(g==="catch")return h().catch.bind(u);if(g==="finally")return h().finally.bind(u);if(g===Symbol.asyncIterator)return()=>l();if(g==="next")return l().next.bind(c);if(g==="return")return l().return.bind(c);if(g==="throw")return l().throw.bind(c);if(g===Symbol.toStringTag)return"[object Object]";if(g==="constructor")return()=>{};throw new lt(`Property ${g.toString()} was not used as a promise or async generator`)}})}})}};function ps(r){return new In(r)}var ms={type:4096,canEncode:r=>r.code!=null&&r.version!=null&&r.multihash!=null&&r["/"]!=null,encode:r=>r.bytes,decode:r=>z.decode(r)};var It=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var gs={type:4099,canEncode:r=>r instanceof It,encode:(r,e,t,n)=>C({type:r.type,detail:e.toValue(r.detail,t,n)}),decode:(r,e,t,n)=>{let{type:o,detail:i}=k(r);return new It(o,e.fromValue(i,t,n))}};function B(r,e="utf8"){let t=nr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var br=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,c=this.peekChar();if(c===void 0)return;let u=c==="0",h=2**(8*o)-1;for(;;){let l=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let g=Number.parseInt(f,e);if(!Number.isNaN(g))return g});if(l===void 0)break;if(i*=e,i+=l,i>h||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&u&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[c]=e(i.subarray(0,s));return t.set(i.subarray(0,c),16-c),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ys=45,Du=15,tt=new br;function Un(r){if(!(r.length>Du))return tt.new(r).parseWith(()=>tt.readIPv4Addr())}function Tn(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ys))return tt.new(r).parseWith(()=>tt.readIPv6Addr())}function Er(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ys))return tt.new(r).parseWith(()=>tt.readIPAddr())}var Gm=parseInt("0xFFFF",16),jm=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function bs(r){return!!Un(r)}function Es(r){return!!Tn(r)}function vr(r){return!!Er(r)}var vs=bs,$u=Es,Ln=function(r){let e=0;if(r=r.toString().trim(),vs(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if($u(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=vs(t[n]),s;i&&(s=Ln(t[n]),t[n]=B(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,B(s.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let i=parseInt(t[n],16);o[e++]=i>>8&255,o[e++]=i&255}return o}throw new Error("invalid ip address")},Ss=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let i=0;i<t;i++)o.push(r[e+i]);return o.join(".")}if(t===16){let o=[];for(let i=0;i<t;i+=2)o.push(n.getUint16(e+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var rt={},Nn={},Vu=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Vu.forEach(r=>{let e=zu(...r);Nn[e.code]=e,rt[e.name]=e});function zu(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function I(r){if(typeof r=="number"){if(Nn[r]!=null)return Nn[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(rt[r]!=null)return rt[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ig=I("ip4"),Ug=I("ip6"),Tg=I("ipcidr");function Mn(r,e){switch(I(r).code){case 4:case 41:return ju(e);case 42:return Dn(e);case 6:case 273:case 33:case 132:return ks(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Dn(e);case 421:return Xu(e);case 444:return Cs(e);case 445:return Cs(e);case 466:return Wu(e);case 481:return globalThis.encodeURIComponent(Dn(e));default:return B(e,"base16")}}function Bn(r,e){switch(I(r).code){case 4:return As(e);case 41:return As(e);case 42:return _n(e);case 6:case 273:case 33:case 132:return Rn(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return _n(e);case 421:return qu(e);case 444:return Ku(e);case 445:return Ju(e);case 466:return Hu(e);case 481:return _n(globalThis.decodeURIComponent(e));default:return Ne(e,"base16")}}var Fn=Object.values(Se).map(r=>r.decoder),Gu=function(){let r=Fn[0].or(Fn[1]);return Fn.slice(2).forEach(e=>r=r.or(e)),r}();function As(r){if(!vr(r))throw new Error("invalid ip address");return Ln(r)}function ju(r){let e=Ss(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!vr(e))throw new Error("invalid ip address");return e}function Rn(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function ks(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function _n(r){let e=Ne(r),t=Uint8Array.from(be(e.length));return ee([t,e],t.length+e.length)}function Dn(r){let e=me(r);if(r=r.slice(_(e)),r.length!==e)throw new Error("inconsistent lengths");return B(r)}function qu(r){let e;r[0]==="Q"||r[0]==="1"?e=Te(N.decode(`z${r}`)).bytes:e=z.parse(r).multihash.bytes;let t=Uint8Array.from(be(e.length));return ee([t,e],t.length+e.length)}function Hu(r){let e=Gu.decode(r),t=Uint8Array.from(be(e.length));return ee([t,e],t.length+e.length)}function Wu(r){let e=me(r),t=r.slice(_(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+B(t,"base64url")}function Xu(r){let e=me(r),t=r.slice(_(e));if(t.length!==e)throw new Error("inconsistent lengths");return B(t,"base58btc")}function Ku(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=se.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Rn(n);return ee([t,o],t.length+o.length)}function Ju(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=se.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Rn(n);return ee([t,o],t.length+o.length)}function Cs(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=B(e,"base32"),o=ks(t);return`${n}:${o}`}function Is(r){r=Pn(r);let e=[],t=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],c=I(s);if(c.size===0){e.push([c.code]),t.push([c.code]);continue}if(i++,i>=o.length)throw Ts("invalid address: "+r);if(c.path===!0){n=Pn(o.slice(i).join("/")),e.push([c.code,Bn(c.code,n)]),t.push([c.code,n]);break}let u=Bn(c.code,o[i]);e.push([c.code,u]),t.push([c.code,Mn(c.code,u)])}return{string:Us(t),bytes:On(e),tuples:e,stringTuples:t,path:n}}function $n(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let i=me(r,o),s=_(i),c=I(i),u=Qu(c,r.slice(o+s));if(u===0){e.push([i]),t.push([i]),o+=s;continue}let h=r.slice(o+s,o+s+u);if(o+=u+s,o>r.length)throw Ts("Invalid address Uint8Array: "+B(r,"base16"));e.push([i,h]);let l=Mn(i,h);if(t.push([i,l]),c.path===!0){n=l;break}}return{bytes:Uint8Array.from(r),string:Us(t),tuples:e,stringTuples:t,path:n}}function Us(r){let e=[];return r.map(t=>{let n=I(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Pn(e.join("/"))}function On(r){return ee(r.map(e=>{let t=I(e[0]),n=Uint8Array.from(be(t.code));return e.length>1&&e[1]!=null&&(n=ee([n,e[1]])),n}))}function Qu(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=me(e instanceof Uint8Array?e:Uint8Array.from(e));return t+_(t)}}function Pn(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Ts(r){return new Error("Error parsing address: "+r)}var Zu=Symbol.for("nodejs.util.inspect.custom"),Vn=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Yu=[I("dns").code,I("dns4").code,I("dns6").code,I("dnsaddr").code],Sr=class r{bytes;#t;#e;#r;#n;[Vn]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=$n(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Is(e)}else if(Ar(e))t=$n(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#t=t.string,this.#e=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,n,o,i="",s=I("tcp"),c=I("udp"),u=I("ip4"),h=I("ip6"),l=I("dns6"),f=I("ip6zone");for(let[b,y]of this.stringTuples())b===f.code&&(i=`%${y??""}`),Yu.includes(b)&&(t=s.name,o=443,n=`${y??""}${i}`,e=b===l.code?6:4),(b===s.code||b===c.code)&&(t=I(b).name,o=parseInt(y??"")),(b===u.code||b===h.code)&&(t=I(b).name,n=`${y??""}${i}`,e=b===h.code?6:4);if(e==null||t==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:o}}protos(){return this.#e.map(([e])=>Object.assign({},I(e)))}protoCodes(){return this.#e.map(([e])=>e)}protoNames(){return this.#e.map(([e])=>I(e).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(On(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===rt.p2p.code&&e.push([n,o]),n===rt["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?B(N.decode(`z${n}`),"base58btc"):B(z.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return ke(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=Ls.get(t.name);if(n==null)throw new _t(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(i=>Me(i))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[Zu](){return`Multiaddr(${this.#t})`}};var Ls=new Map;function Ar(r){return!!r?.[Vn]}function Me(r){return new Sr(r)}var Ns={type:4097,canEncode:r=>Ar(r),encode:r=>r.bytes,decode:r=>Me(r)};var _s=Symbol.for("nodejs.util.inspect.custom"),Fs=Object.values(Se).map(r=>r.decoder).reduce((r,e)=>r.or(e),Se.identity.decoder),Ds=114,Ms=36,Bs=37,Ut=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Ft]=!0;toString(){return this.string==null&&(this.string=N.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return z.createV1(Ds,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ke(this.multihash.bytes,e);if(typeof e=="string")return jn(e).equals(this);if(e?.multihash?.bytes!=null)return ke(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[_s](){return`PeerId(${this.toString()})`}},Tt=class extends Ut{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Lt=class extends Ut{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Nt=class extends Ut{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}},zn=2336,Gn=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=ht.digest(Ne(this.url))}[_s](){return`PeerId(${this.url})`}[Ft]=!0;toString(){return this.toCID().toString()}toCID(){return z.createV1(zn,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=B(e)),e.toString()===this.toString())}};function jn(r,e){if(e=e??Fs,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Te(N.decode(`z${r}`));return r.startsWith("12D")?new Lt({multihash:t}):r.startsWith("16U")?new Nt({multihash:t}):new Tt({multihash:t})}return qn(Fs.decode(r))}function qn(r){try{let e=Te(r);if(e.code===ht.code){if(e.digest.length===Ms)return new Lt({multihash:e});if(e.digest.length===Bs)return new Nt({multihash:e})}if(e.code===rr.code)return new Tt({multihash:e})}catch{return el(z.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function el(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Ds&&r.code!==zn)throw new Error("Supplied PeerID CID is invalid");if(r.code===zn){let t=B(r.multihash.digest);return new Gn(new URL(t))}let e=r.multihash;if(e.code===rr.code)return new Tt({multihash:r.multihash});if(e.code===ht.code){if(e.digest.length===Ms)return new Lt({multihash:r.multihash});if(e.digest.length===Bs)return new Nt({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}var Rs={type:4098,canEncode:r=>Kn(r),encode:r=>r.toBytes(),decode:r=>qn(r)};var Hn=[ms,Ns,Rs,gs];function nt(r,e){let t={};for(let[n,o]of r.entries())t[n]=e(o);return t}async function Cr(r,e){let t=[],n=r.connectionManager.getConnectionsMap(),o=[...n.values()].flatMap(i=>i).map(i=>i.remoteAddr.toString());for(let[i,s]of n.entries())try{let c=await r.peerStore.get(i);t.push({id:i,addresses:c.addresses.map(({isCertified:u,multiaddr:h})=>({multiaddr:h,isCertified:u,isConnected:o.includes(h.toString())})),protocols:[...c.protocols],tags:nt(c.tags,u=>u.value),metadata:nt(c.metadata,u=>de.encode(u))})}catch(c){e.error("could not load peer data from peer store",c),t.push({id:i,addresses:s.map(u=>({multiaddr:u.remoteAddr,isConnected:o.includes(u.remoteAddr.toString())})),protocols:[],tags:{},metadata:{}})}return t}async function kr(r){let e=await r.peerStore.get(r.peerId);return{id:e.id,addresses:e.addresses,protocols:[...e.protocols],tags:nt(e.tags,t=>t.value),metadata:nt(e.metadata,t=>de.encode(t))}}function Ps(r){let e=r.logger.forComponent("libp2p:devtools-metrics:metrics-rpc");return{init:async()=>({self:await kr(r),peers:await Cr(r,e),debug:localStorage.getItem("debug")??""}),setDebug:async t=>{t?.length!=null&&t?.length>0?(ao(t),localStorage.setItem("debug",t)):(co(),localStorage.removeItem("debug"))},openConnection:async(t,n)=>{let o;try{o=jn(t)}catch{o=Me(t)}await r.connectionManager.openConnection(o,n)},closeConnection:async(t,n)=>{await Promise.all(r.connectionManager.getConnections(t).map(async o=>{try{await o.close(n)}catch(i){o.abort(i)}}))},contentRouting:r.contentRouting,peerRouting:r.peerRouting}}function Wn(r,e=100){let t,n;return()=>{if(n==null&&(n=Date.now()),t!=null&&Date.now()-n>e){clearTimeout(t),n=void 0,r();return}clearTimeout(t),t=setTimeout(()=>{n=void 0,r()},e)}}var $s="@libp2p/devtools-metrics:devtools",tl="@libp2p/devtools-metrics:worker",rl="@libp2p/devtools-metrics:content",Os="@libp2p/devtools-metrics:metrics",Vs="________libp2p_devtools_metrics";Object.defineProperty(globalThis,Vs,{value:!0,enumerable:!1,writable:!1});var Xn=class{log;components;simpleMetrics;intervalMs;rpcQueue;rpc;devTools;constructor(e,t){this.log=e.logger.forComponent("libp2p:devtools-metrics"),this.intervalMs=t?.intervalMs,this.components=e,this.rpcQueue=xe(),this.rpc=ps({valueCodecs:Hn}),this.devTools=this.rpc.createClient("devTools"),this.onPeersUpdate=Wn(this.onPeersUpdate.bind(this),1e3),this.onSelfUpdate=Wn(this.onSelfUpdate.bind(this),1e3),this.onIncomingMessage=this.onIncomingMessage.bind(this),this.simpleMetrics=fo({intervalMs:this.intervalMs,onMetrics:n=>{this.devTools.safeDispatchEvent("metrics",{detail:n}).catch(o=>{this.log.error("error sending metrics",o)})}})({})}[Symbol.toStringTag]="@libp2p/devtools-metrics";[Dt]=["@libp2p/metrics"];trackMultiaddrConnection(e){this.simpleMetrics.trackMultiaddrConnection(e)}trackProtocolStream(e,t){this.simpleMetrics.trackProtocolStream(e,t)}registerMetric(e,t){return this.simpleMetrics.registerMetric(e,t)}registerMetricGroup(e,t){return this.simpleMetrics.registerMetricGroup(e,t)}registerCounter(e,t){return this.simpleMetrics.registerCounter(e,t)}registerCounterGroup(e,t){return this.simpleMetrics.registerCounterGroup(e,t)}async start(){this.components.events.addEventListener("peer:connect",this.onPeersUpdate),this.components.events.addEventListener("peer:disconnect",this.onPeersUpdate),this.components.events.addEventListener("peer:identify",this.onPeersUpdate),this.components.events.addEventListener("peer:update",this.onPeersUpdate),this.components.events.addEventListener("self:peer:update",this.onSelfUpdate),window.addEventListener("message",this.onIncomingMessage),this.rpc.createTarget("metrics",Ps(this.components)),await Qn(this.simpleMetrics),Promise.resolve().then(async()=>{await po(this.rpcQueue,this.rpc,async e=>{for await(let t of e)window.postMessage({source:Os,type:"libp2p-rpc",message:de.encode(t)})})}).catch(e=>{this.log.error("error while reading RPC messages",e)})}async stop(){window.removeEventListener("message",this.onIncomingMessage),this.components.events.removeEventListener("self:peer:update",this.onSelfUpdate),this.components.events.removeEventListener("peer:connect",this.onPeersUpdate),this.components.events.removeEventListener("peer:disconnect",this.onPeersUpdate),this.components.events.removeEventListener("peer:identify",this.onPeersUpdate),this.components.events.removeEventListener("peer:update",this.onPeersUpdate),await Zn(this.simpleMetrics)}onIncomingMessage(e){if(e.source!==window)return;let t=e.data;t?.source===$s&&t.type==="libp2p-rpc"&&this.rpcQueue.push(de.decode(t.message))}onSelfUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("self",{detail:await kr(this.components)})}).catch(e=>{this.log.error("error sending peers message",e)})}onPeersUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("peers",{detail:await Cr(this.components,this.log)})}).catch(e=>{this.log.error("error sending peers message",e)})}};function nl(r){return e=>new Xn(e,r)}return Hs(ol);})();
|
|
3
3
|
return Libp2PDevtoolsMetrics}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/devtools-metrics",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Collect libp2p metrics and send them to browser DevTools",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "Apache-2.0 OR MIT",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"test:chrome": "aegir test -t browser --cov"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@libp2p/interface": "^1.
|
|
71
|
-
"@libp2p/interface-internal": "^1.3.
|
|
72
|
-
"@libp2p/logger": "^4.0.
|
|
73
|
-
"@libp2p/peer-id": "^4.2.
|
|
74
|
-
"@libp2p/simple-metrics": "^1.1.
|
|
70
|
+
"@libp2p/interface": "^1.7.0",
|
|
71
|
+
"@libp2p/interface-internal": "^1.3.4",
|
|
72
|
+
"@libp2p/logger": "^4.0.20",
|
|
73
|
+
"@libp2p/peer-id": "^4.2.4",
|
|
74
|
+
"@libp2p/simple-metrics": "^1.1.5",
|
|
75
75
|
"@multiformats/multiaddr": "^12.3.0",
|
|
76
76
|
"cborg": "^4.2.2",
|
|
77
77
|
"it-pipe": "^3.0.1",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"progress-events": "^1.0.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@libp2p/peer-id-factory": "^4.2.
|
|
84
|
+
"@libp2p/peer-id-factory": "^4.2.4",
|
|
85
85
|
"aegir": "^44.0.1",
|
|
86
86
|
"sinon-ts": "^2.0.0"
|
|
87
87
|
},
|