@libp2p/devtools-metrics 1.2.14-f1de46607 → 1.2.15
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 +2 -2
- package/dist/index.min.js.map +4 -4
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +18 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/rpc/index.d.ts +1 -1
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/typedoc-urls.json +46 -0
- package/package.json +8 -8
- package/src/index.ts +26 -2
- package/src/rpc/index.ts +1 -1
package/dist/index.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
|
|
3
|
-
`)};function yc(r,t){return r.mean>t.mean?1:r.mean<t.mean?-1:0}function ed(r,t){return r.mean_cumn-t.mean_cumn}et.prototype.push=function(r,t){t=t||1,r=Array.isArray(r)?r:[r];for(var e=0;e<r.length;e++)this._digest(r[e],t)};et.prototype.push_centroid=function(r){r=Array.isArray(r)?r:[r];for(var t=0;t<r.length;t++)this._digest(r[t].mean,r[t].n)};et.prototype._cumulate=function(r){if(!(this.n===this.last_cumulate||!r&&this.CX&&this.CX>this.n/this.last_cumulate)){var t=0;this.centroids.each(function(e){e.mean_cumn=t+e.n/2,t=e.cumn=t+e.n}),this.n=this.last_cumulate=t}};et.prototype.find_nearest=function(r){if(this.size()===0)return null;var t=this.centroids.lowerBound({mean:r}),e=t.data()===null?t.prev():t.data();if(e.mean===r||this.discrete)return e;var n=t.prev();return n&&Math.abs(n.mean-r)<Math.abs(e.mean-r)?n:e};et.prototype._new_centroid=function(r,t,e){var n={mean:r,n:t,cumn:e};return this.centroids.insert(n),this.n+=t,n};et.prototype._addweight=function(r,t,e){t!==r.mean&&(r.mean+=e*(t-r.mean)/(r.n+e)),r.cumn+=e,r.mean_cumn+=e/2,r.n+=e,this.n+=e};et.prototype._digest=function(r,t){var e=this.centroids.min(),n=this.centroids.max(),o=this.find_nearest(r);if(o&&o.mean===r)this._addweight(o,r,t);else if(o===e)this._new_centroid(r,t,0);else if(o===n)this._new_centroid(r,t,this.n);else if(this.discrete)this._new_centroid(r,t,o.cumn);else{var i=o.mean_cumn/this.n,s=Math.floor(4*this.n*this.delta*i*(1-i));s-o.n>=t?this._addweight(o,r,t):this._new_centroid(r,t,o.cumn)}this._cumulate(!1),!this.discrete&&this.K&&this.size()>this.K/this.delta&&this.compress()};et.prototype.bound_mean=function(r){var t=this.centroids.upperBound({mean:r}),e=t.prev(),n=e.mean===r?e:t.next();return[e,n]};et.prototype.p_rank=function(r){var t=Array.isArray(r)?r:[r],e=t.map(this._p_rank,this);return Array.isArray(r)?e:e[0]};et.prototype._p_rank=function(r){if(this.size()!==0){{if(r<this.centroids.min().mean)return 0;if(r>this.centroids.max().mean)return 1}this._cumulate(!0);var t=this.bound_mean(r),e=t[0],n=t[1];if(this.discrete)return e.cumn/this.n;var o=e.mean_cumn;return e!==n&&(o+=(r-e.mean)*(n.mean_cumn-e.mean_cumn)/(n.mean-e.mean)),o/this.n}};et.prototype.bound_mean_cumn=function(r){this.centroids._comparator=ed;var t=this.centroids.upperBound({mean_cumn:r});this.centroids._comparator=yc;var e=t.prev(),n=e&&e.mean_cumn===r?e:t.next();return[e,n]};et.prototype.percentile=function(r){var t=Array.isArray(r)?r:[r],e=t.map(this._percentile,this);return Array.isArray(r)?e:e[0]};et.prototype._percentile=function(r){if(this.size()!==0){this._cumulate(!0);var t=this.n*r,e=this.bound_mean_cumn(t),n=e[0],o=e[1];return o===n||n===null||o===null?(n||o).mean:this.discrete?t<=n.cumn?n.mean:o.mean:n.mean+(t-n.mean_cumn)*(o.mean-n.mean)/(o.mean_cumn-n.mean_cumn)}};function rd(r){var t=Math.floor(Math.random()*r.length);return r.splice(t,1)[0]}et.prototype.compress=function(){if(!this.compressing){var r=this.toArray();for(this.reset(),this.compressing=!0;r.length>0;)this.push_centroid(rd(r));this._cumulate(!0),this.compressing=!1}};function Se(r){this.config=r||{},this.mode=this.config.mode||"auto",et.call(this,this.mode==="cont"?r.delta:!1),this.digest_ratio=this.config.ratio||.9,this.digest_thresh=this.config.thresh||1e3,this.n_unique=0}Se.prototype=Object.create(et.prototype);Se.prototype.constructor=Se;Se.prototype.push=function(r){et.prototype.push.call(this,r),this.check_continuous()};Se.prototype._new_centroid=function(r,t,e){this.n_unique+=1,et.prototype._new_centroid.call(this,r,t,e)};Se.prototype._addweight=function(r,t,e){r.n===1&&(this.n_unique-=1),et.prototype._addweight.call(this,r,t,e)};Se.prototype.check_continuous=function(){return this.mode!=="auto"||this.size()<this.digest_thresh?!1:this.n_unique/this.size()>this.digest_ratio?(this.mode="cont",this.discrete=!1,this.delta=this.config.delta||.01,this.compress(),!0):!1};xc.exports={TDigest:et,Digest:Se}});var O0={};Pt(O0,{LIBP2P_DEVTOOLS_METRICS_KEY:()=>of,SOURCE_CONTENT_SCRIPT:()=>R0,SOURCE_DEVTOOLS:()=>rf,SOURCE_METRICS:()=>nf,SOURCE_SERVICE_WORKER:()=>N0,devToolsMetrics:()=>M0,valueCodecs:()=>Ks});var An=Symbol.for("@libp2p/peer-id");function $s(r){return!!r?.[An]}var Gs;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Gs||(Gs={}));var yf=Symbol.for("@libp2p/pubsub");function _n(r){return!!r?.[yf]}var zt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},In=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Cn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Bn=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Ur=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};function js(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function Zs(...r){let t=[];for(let e of r)js(e)&&t.push(e);await Promise.all(t.map(async e=>{e.beforeStart!=null&&await e.beforeStart()})),await Promise.all(t.map(async e=>{await e.start()})),await Promise.all(t.map(async e=>{e.afterStart!=null&&await e.afterStart()}))}async function Ws(...r){let t=[];for(let e of r)js(e)&&t.push(e);await Promise.all(t.map(async e=>{e.beforeStop!=null&&await e.beforeStop()})),await Promise.all(t.map(async e=>{await e.stop()})),await Promise.all(t.map(async e=>{e.afterStop!=null&&await e.afterStop()}))}var Ee=Symbol.for("@libp2p/service-capabilities"),q0=Symbol.for("@libp2p/service-dependencies");var Yo={};Pt(Yo,{base32:()=>Wt,base32hex:()=>If,base32hexpad:()=>Bf,base32hexpadupper:()=>kf,base32hexupper:()=>Cf,base32pad:()=>Af,base32padupper:()=>_f,base32upper:()=>Sf,base32z:()=>Tf});var hm=new Uint8Array(0);function Ys(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function ae(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 Xs(r){return new TextEncoder().encode(r)}function Qs(r){return new TextDecoder().decode(r)}function xf(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var c=r.length,a=r.charAt(0),l=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function f(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var g=0,d=0,b=0,A=w.length;b!==A&&w[b]===0;)b++,g++;for(var m=(A-b)*u+1>>>0,I=new Uint8Array(m);b!==A;){for(var N=w[b],P=0,k=m-1;(N!==0||P<d)&&k!==-1;k--,P++)N+=256*I[k]>>>0,I[k]=N%c>>>0,N=N/c>>>0;if(N!==0)throw new Error("Non-zero carry");d=P,b++}for(var T=m-d;T!==m&&I[T]===0;)T++;for(var L=a.repeat(g);T<m;++T)L+=r.charAt(I[T]);return L}function h(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var g=0;if(w[g]!==" "){for(var d=0,b=0;w[g]===a;)d++,g++;for(var A=(w.length-g)*l+1>>>0,m=new Uint8Array(A);w[g];){var I=e[w.charCodeAt(g)];if(I===255)return;for(var N=0,P=A-1;(I!==0||N<b)&&P!==-1;P--,N++)I+=c*m[P]>>>0,m[P]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");b=N,g++}if(w[g]!==" "){for(var k=A-b;k!==A&&m[k]===0;)k++;for(var T=new Uint8Array(d+(A-k)),L=d;k!==A;)T[L++]=m[k++];return T}}}function x(w){var g=h(w);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:h,decode:x}}var bf=xf,wf=bf,tc=wf;var Go=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},jo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return ec(this,t)}},Zo=class{decoders;constructor(t){this.decoders=t}or(t){return ec(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function ec(r,t){return new Zo({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Wo=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Go(t,e,n),this.decoder=new jo(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Xe({name:r,prefix:t,encode:e,decode:n}){return new Wo(r,t,e,n)}function ve({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=tc(e,r);return Xe({prefix:t,name:r,encode:n,decode:i=>ae(o(i))})}function Ef(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),c=0,a=0,l=0;for(let u=0;u<i;++u){let f=o[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,c+=e,c>=8&&(c-=8,s[l++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return s}function vf(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>e;)s-=e,i+=t[o&c>>s];if(s!==0&&(i+=t[o&c<<e-s]),n)for(;(i.length*e&7)!==0;)i+="=";return i}function ot({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Xe({prefix:t,name:r,encode(o){return vf(o,n,e)},decode(o){return Ef(o,n,e,r)}})}var Wt=ot({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Sf=ot({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Af=ot({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),_f=ot({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),If=ot({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Cf=ot({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Bf=ot({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),kf=ot({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Tf=ot({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Xo={};Pt(Xo,{base58btc:()=>tt,base58flickr:()=>Uf});var tt=ve({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Uf=ve({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Qo={};Pt(Qo,{base64:()=>ne,base64pad:()=>Lf,base64url:()=>Pf,base64urlpad:()=>Df});var ne=ot({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Lf=ot({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pf=ot({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Df=ot({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Nf(r,t){try{if(typeof r=="string"&&r.length>0)return Rf(r);if(typeof r=="number"&&isFinite(r))return t?.long?Of(r):Mf(r);throw new Error("Value is not a string or number.")}catch(e){let n=Ff(e)?`${e.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function Rf(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let t=/^(-?(?:\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(!t)return NaN;let e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*315576e5;case"weeks":case"week":case"w":return e*6048e5;case"days":case"day":case"d":return e*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return e*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return e*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return e*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Tn=Nf;function Mf(r){let t=Math.abs(r);return t>=864e5?`${Math.round(r/864e5)}d`:t>=36e5?`${Math.round(r/36e5)}h`:t>=6e4?`${Math.round(r/6e4)}m`:t>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function Of(r){let t=Math.abs(r);return t>=864e5?kn(r,t,864e5,"day"):t>=36e5?kn(r,t,36e5,"hour"):t>=6e4?kn(r,t,6e4,"minute"):t>=1e3?kn(r,t,1e3,"second"):`${r} ms`}function kn(r,t,e,n){let o=t>=e*1.5;return`${Math.round(r/e)} ${n}${o?"s":""}`}function Ff(r){return typeof r=="object"&&r!==null&&"message"in r}function Jo(r){e.debug=e,e.default=e,e.coerce=a,e.disable=i,e.enable=o,e.enabled=s,e.humanize=Tn,e.destroy=l,Object.keys(r).forEach(u=>{e[u]=r[u]}),e.names=[],e.skips=[],e.formatters={};function t(u){let f=0;for(let h=0;h<u.length;h++)f=(f<<5)-f+u.charCodeAt(h),f|=0;return e.colors[Math.abs(f)%e.colors.length]}e.selectColor=t;function e(u){let f,h=null,x,w;function g(...d){if(!g.enabled)return;let b=g,A=Number(new Date),m=A-(f||A);b.diff=m,b.prev=f,b.curr=A,f=A,d[0]=e.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let I=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(P,k)=>{if(P==="%%")return"%";I++;let T=e.formatters[k];if(typeof T=="function"){let L=d[I];P=T.call(b,L),d.splice(I,1),I--}return P}),e.formatArgs.call(b,d),(b.log||e.log).apply(b,d)}return g.namespace=u,g.useColors=e.useColors(),g.color=e.selectColor(u),g.extend=n,g.destroy=e.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(x!==e.namespaces&&(x=e.namespaces,w=e.enabled(u)),w),set:d=>{h=d}}),typeof e.init=="function"&&e.init(g),g}function n(u,f){let h=e(this.namespace+(typeof f>"u"?":":f)+u);return h.log=this.log,h}function o(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let f,h=(typeof u=="string"?u:"").split(/[\s,]+/),x=h.length;for(f=0;f<x;f++)h[f]&&(u=h[f].replace(/\*/g,".*?"),u[0]==="-"?e.skips.push(new RegExp("^"+u.substr(1)+"$")):e.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...e.names.map(c),...e.skips.map(c).map(f=>"-"+f)].join(",");return e.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,h;for(f=0,h=e.skips.length;f<h;f++)if(e.skips[f].test(u))return!1;for(f=0,h=e.names.length;f<h;f++)if(e.names[f].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function a(u){return u instanceof Error?u.stack??u.message:u}function l(){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 e.setupFormatters(e.formatters),e.enable(e.load()),e}var Un=Gf(),Kf=["#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 Vf(){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 Hf(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Tn(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}var zf=console.debug??console.log??(()=>{});function qf(r){try{r?Un?.setItem("debug",r):Un?.removeItem("debug")}catch{}}function $f(){let r;try{r=Un?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function Gf(){try{return localStorage}catch{}}function jf(r){r.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}var rc=Jo({formatArgs:Hf,save:qf,load:$f,useColors:Vf,setupFormatters:jf,colors:Kf,storage:Un,log:zf});var bt=rc;bt.formatters.b=r=>r==null?"undefined":tt.baseEncode(r);bt.formatters.t=r=>r==null?"undefined":Wt.baseEncode(r);bt.formatters.m=r=>r==null?"undefined":ne.baseEncode(r);bt.formatters.p=r=>r==null?"undefined":r.toString();bt.formatters.c=r=>r==null?"undefined":r.toString();bt.formatters.k=r=>r==null?"undefined":r.toString();bt.formatters.a=r=>r==null?"undefined":r.toString();bt.formatters.e=r=>r==null?"undefined":nc(r.stack)??nc(r.message)??r.toString();function Zf(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function oc(r){let t=Zf(`${r}:trace`);return bt.enabled(`${r}:trace`)&&bt.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=bt(`${r}:trace`)),Object.assign(bt(r),{error:bt(`${r}:error`),trace:t})}function ic(){bt.disable()}function sc(r){bt.enable(r)}function nc(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}function Wf(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var cc=Wf;function Yf(r){return r[Symbol.asyncIterator]!=null}function ac(r){return r?.then!=null}function Xf(r,t){let e=0;if(Yf(r))return async function*(){for await(let a of r){let l=t(a,e++);ac(l)&&await l,yield a}}();let n=cc(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();if(typeof t(o,e++)?.then=="function")return async function*(){yield o;for await(let a of n){let l=t(a,e++);ac(l)&&await l,yield a}}();let c=t;return function*(){yield o;for(let a of n)c(a,e++),yield a}()}var ti=Xf;var wc=mf(bc(),1),nd=oc("libp2p:simple-metrics"),Dr=class{value=0;update(t){this.value=t}increment(t=1){this.value+=t}decrement(t=1){this.value-=t}reset(){this.value=0}timer(){let t=Date.now();return()=>{this.value=Date.now()-t}}},Nr=class{values={};update(t){Object.entries(t).forEach(([e,n])=>{this.values[e]=n})}increment(t){Object.entries(t).forEach(([e,n])=>{this.values[e]=this.values[e]??0;let o=typeof n=="number"?n:1;this.values[e]+=Number(o)})}decrement(t){Object.entries(t).forEach(([e,n])=>{this.values[e]=this.values[e]??0;let o=typeof n=="number"?n:1;this.values[e]-=Number(o)})}reset(){this.values={}}timer(t){let e=Date.now();return()=>{this.values[t]=Date.now()-e}}},Rr=class{bucketValues=new Map;countValue=0;sumValue=0;constructor(t){let e=[...t.buckets??[.005,.01,.025,.05,.1,.25,.5,1,2.5,5,10],1/0];for(let n of e)this.bucketValues.set(n,0)}observe(t){this.countValue++,this.sumValue+=t;for(let[e,n]of this.bucketValues.entries())t<=e&&this.bucketValues.set(e,n+1)}reset(){this.countValue=0,this.sumValue=0;for(let t of this.bucketValues.keys())this.bucketValues.set(t,0)}timer(){let t=Date.now();return()=>{this.observe(Date.now()-t)}}},Dn=class{histograms={};constructor(t){this.histograms={}}observe(t){for(let[e,n]of Object.entries(t))this.histograms[e]===void 0&&(this.histograms[e]=new Rr({})),this.histograms[e].observe(n)}reset(){for(let t of Object.values(this.histograms))t.reset()}timer(t){let e=Date.now();return()=>{this.observe({[t]:Date.now()-e})}}},Mr=class{sumValue=0;countValue=0;percentiles;tdigest=new wc.TDigest(.01);compressCount;constructor(t){this.percentiles=t.percentiles??[.01,.05,.5,.9,.95,.99,.999],this.compressCount=t.compressCount??1e3}observe(t){this.sumValue+=t,this.countValue++,this.tdigest.push(t),this.tdigest.size()>this.compressCount&&this.tdigest.compress()}reset(){this.sumValue=0,this.countValue=0,this.tdigest.reset()}timer(){let t=Date.now();return()=>{this.observe(Date.now()-t)}}},Nn=class{summaries={};opts;constructor(t){this.summaries={},this.opts=t}observe(t){for(let[e,n]of Object.entries(t))this.summaries[e]===void 0&&(this.summaries[e]=new Mr(this.opts)),this.summaries[e].observe(n)}reset(){for(let t of Object.values(this.summaries))t.reset()}timer(t){let e=Date.now();return()=>{this.observe({[t]:Date.now()-e})}}},ri=class{metrics=new Map;transferStats;started;interval;intervalMs;onMetrics;constructor(t,e){this.started=!1,this._emitMetrics=this._emitMetrics.bind(this),this.intervalMs=e.intervalMs??1e3,this.onMetrics=e.onMetrics,this.transferStats=new Map}[Symbol.toStringTag]="@libp2p/metrics-simple";[Ee]=["@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 t={};for(let[e,n]of this.metrics.entries())n instanceof Dr?t[e]=n.value:n instanceof Nr?t[e]=n.values:n instanceof Rr?t[e]={count:n.countValue,sum:n.sumValue,buckets:{...n.bucketValues}}:n instanceof Dn?t[e]={...Object.fromEntries(Object.entries(n.histograms).map(([o,i])=>[o,{count:i.countValue,sum:i.sumValue,buckets:{...i.bucketValues}}]))}:n instanceof Mr?t[e]={count:n.countValue,sum:n.sumValue,percentiles:Object.fromEntries(n.percentiles.map(o=>[o,n.tdigest.percentile(o)]))}:n instanceof Nn?t[e]={...Object.fromEntries(Object.entries(n.summaries).map(([o,i])=>[o,{count:i.countValue,sum:i.sumValue,percentiles:Object.fromEntries(i.percentiles.map(s=>[s,i.tdigest.percentile(s)]))}]))}:t[e]=await n();this.onMetrics(structuredClone(t))}).catch(t=>{nd.error("could not invoke onMetrics callback",t)})}_incrementValue(t,e){let n=this.transferStats.get(t)??0;this.transferStats.set(t,n+e)}_track(t,e){let n=this,o=t.sink;t.sink=async function(c){await o(ti(c,a=>{n._incrementValue(`${e} sent`,a.byteLength)}))};let i=t.source;t.source=ti(i,s=>{n._incrementValue(`${e} received`,s.byteLength)})}trackMultiaddrConnection(t){this._track(t,"global")}trackProtocolStream(t,e){t.protocol!=null&&this._track(t,t.protocol)}registerMetric(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Dr;return this.metrics.set(t,n),n}registerMetricGroup(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Nr;return this.metrics.set(t,n),n}registerCounter(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Dr;return this.metrics.set(t,n),n}registerCounterGroup(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Nr;return this.metrics.set(t,n),n}registerHistogram(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Rr(e);return this.metrics.set(t,n),n}registerHistogramGroup(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Dn(e);return this.metrics.set(t,n),n}registerSummary(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Mr(e);return this.metrics.set(t,n),n}registerSummaryGroup(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Nn(e);return this.metrics.set(t,n),n}createTrace(){}traceFunction(t,e){return e}};function Ec(r){return t=>new ri(t,r)}function wt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Rn=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||(t-1&t)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},tr=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Rn(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Rn(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var ni=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function er(r={}){return od(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function od(r,t){t=t??{};let e=t.onEnd,n=new tr,o,i,s,c=wt(),a=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((d,b)=>{i=A=>{i=null,n.push(A);try{d(r(n))}catch(m){b(m)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=wt()})}},l=d=>i!=null?i(d):(n.push(d),o),u=d=>(n=new tr,i!=null?i({error:d}):(n.push({error:d}),o)),f=d=>{if(s)return o;if(t?.objectMode!==!0&&d?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:d})},h=d=>s?o:(s=!0,d!=null?u(d):l({done:!0})),x=()=>(n=new tr,h(),{done:!0}),w=d=>(h(d),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:x,throw:w,push:f,end:h,get readableLength(){return n.size},onEmpty:async d=>{let b=d?.signal;if(b?.throwIfAborted(),n.isEmpty())return;let A,m;b!=null&&(A=new Promise((I,N)=>{m=()=>{N(new ni)},b.addEventListener("abort",m)}));try{await Promise.race([c.promise,A])}finally{m!=null&&b!=null&&b?.removeEventListener("abort",m)}}},e==null)return o;let g=o;return o={[Symbol.asyncIterator](){return this},next(){return g.next()},throw(d){return g.throw(d),e!=null&&(e(d),e=void 0),{done:!0}},return(){return g.return(),e!=null&&(e(),e=void 0),{done:!0}},push:f,end(d){return g.end(d),e!=null&&(e(d),e=void 0),o},get readableLength(){return g.readableLength},onEmpty:d=>g.onEmpty(d)},o}var Mn=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function vc(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new Mn(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Mn(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((i,s)=>{n=()=>{s(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var oi=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=wt(),this.haveNext=wt()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=wt(),t}async throw(t){return this.ended=!0,this.error=t,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=wt(),await vc(this.readNext.promise,e?.signal,e)}};function Sc(){return new oi}function id(r){return r[Symbol.asyncIterator]!=null}async function sd(r,t){try{await Promise.all(r.map(async e=>{for await(let n of e)await t.push(n)})),await t.end()}catch(e){await t.end(e).catch(()=>{})}}async function*cd(r){let t=Sc();sd(r,t).catch(()=>{}),yield*t}function*ad(r){for(let t of r)yield*t}function ud(...r){let t=[];for(let e of r)id(e)||t.push(e);return t.length===r.length?ad(t):cd(r)}var Ac=ud;function _c(r,...t){if(r==null)throw new Error("Empty pipeline");if(ii(r)){let n=r;r=()=>n.source}else if(Cc(r)||Ic(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&ii(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let n=1;n<e.length-1;n++)ii(e[n])&&(e[n]=fd(e[n]));return ld(...e)}var ld=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},Ic=r=>r?.[Symbol.asyncIterator]!=null,Cc=r=>r?.[Symbol.iterator]!=null,ii=r=>r==null?!1:r.sink!=null&&r.source!=null,fd=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=er({objectMode:!0});e.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(Ic(i))o=async function*(){yield*i,n.end()};else if(Cc(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Ac(n,o())}return r.source};function On(r){let t=new globalThis.AbortController;function e(){t.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",e)}for(let i of r){if(i?.aborted===!0){e();break}i?.addEventListener!=null&&i.addEventListener("abort",e)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",e)}let o=t.signal;return o.clear=n,o}function Xt(r=0){return new Uint8Array(r)}function Et(r=0){return new Uint8Array(r)}var dd=Math.pow(2,7),hd=Math.pow(2,14),pd=Math.pow(2,21),si=Math.pow(2,28),ci=Math.pow(2,35),ai=Math.pow(2,42),ui=Math.pow(2,49),G=128,vt=127;function ft(r){if(r<dd)return 1;if(r<hd)return 2;if(r<pd)return 3;if(r<si)return 4;if(r<ci)return 5;if(r<ai)return 6;if(r<ui)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function li(r,t,e=0){switch(ft(r)){case 8:t[e++]=r&255|G,r/=128;case 7:t[e++]=r&255|G,r/=128;case 6:t[e++]=r&255|G,r/=128;case 5:t[e++]=r&255|G,r/=128;case 4:t[e++]=r&255|G,r>>>=7;case 3:t[e++]=r&255|G,r>>>=7;case 2:t[e++]=r&255|G,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function md(r,t,e=0){switch(ft(r)){case 8:t.set(e++,r&255|G),r/=128;case 7:t.set(e++,r&255|G),r/=128;case 6:t.set(e++,r&255|G),r/=128;case 5:t.set(e++,r&255|G),r/=128;case 4:t.set(e++,r&255|G),r>>>=7;case 3:t.set(e++,r&255|G),r>>>=7;case 2:t.set(e++,r&255|G),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function fi(r,t){let e=r[t],n=0;if(n+=e&vt,e<G||(e=r[t+1],n+=(e&vt)<<7,e<G)||(e=r[t+2],n+=(e&vt)<<14,e<G)||(e=r[t+3],n+=(e&vt)<<21,e<G)||(e=r[t+4],n+=(e&vt)*si,e<G)||(e=r[t+5],n+=(e&vt)*ci,e<G)||(e=r[t+6],n+=(e&vt)*ai,e<G)||(e=r[t+7],n+=(e&vt)*ui,e<G))return n;throw new RangeError("Could not decode varint")}function gd(r,t){let e=r.get(t),n=0;if(n+=e&vt,e<G||(e=r.get(t+1),n+=(e&vt)<<7,e<G)||(e=r.get(t+2),n+=(e&vt)<<14,e<G)||(e=r.get(t+3),n+=(e&vt)<<21,e<G)||(e=r.get(t+4),n+=(e&vt)*si,e<G)||(e=r.get(t+5),n+=(e&vt)*ci,e<G)||(e=r.get(t+6),n+=(e&vt)*ai,e<G)||(e=r.get(t+7),n+=(e&vt)*ui,e<G))return n;throw new RangeError("Could not decode varint")}function Ae(r,t,e=0){return t==null&&(t=Et(ft(r))),t instanceof Uint8Array?li(r,t,e):md(r,t,e)}function ue(r,t=0){return r instanceof Uint8Array?fi(r,t):gd(r,t)}function Dt(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=Et(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function Nt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var kc=Symbol.for("@achingbrain/uint8arraylist");function Bc(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function Kn(r){return!!r?.[kc]}var mt=class r{bufs;length;[kc]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Kn(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Kn(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Bc(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Bc(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Kn(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Dt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Dt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),i=new r;return i.length=o,i.bufs=[...n],i}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===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,a=c+s.byteLength;if(o=a,t>=a)continue;let l=t>=c&&t<a,u=e>c&&e<=a;if(l&&u){if(t===c&&e===a){n.push(s);break}let f=t-c;n.push(s.subarray(f,f+(e-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-c));continue}if(u){if(e===a){n.push(s);break}n.push(s.subarray(0,e-c));break}n.push(s)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Kn(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;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,a=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=e;f<=a;f+=u){u=0;for(let h=l;h>=0;h--){let x=this.get(f+h);if(n[h]!==x){u=Math.max(1,h-c[x]);break}}if(u===0)return f}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=Et(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=Xt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=Xt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=Xt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=Et(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=Xt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=Xt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=Xt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=Xt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=Xt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!Nt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,i)=>o+i.byteLength,0)),n.length=e,n}};var Vn=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},rr=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Hn=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},Or=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function zn(r){return r[Symbol.asyncIterator]!=null}function Tc(r,t){if(r.byteLength>t)throw new rr("Message length too long")}var $n=r=>{let t=ft(r),e=Et(t);return Ae(r,e),$n.bytes=t,e};$n.bytes=0;function Gn(r,t){t=t??{};let e=t.lengthEncoder??$n,n=t?.maxDataLength??4194304;function*o(i){Tc(i,n);let s=e(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}return zn(r)?async function*(){for await(let i of r)yield*o(i)}():function*(){for(let i of r)yield*o(i)}()}Gn.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??$n,n=t?.maxDataLength??4194304;return Tc(r,n),new mt(e(r.byteLength),r)};var De;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(De||(De={}));var di=r=>{let t=ue(r);return di.bytes=ft(t),t};di.bytes=0;function Fr(r,t){let e=new mt,n=De.LENGTH,o=-1,i=t?.lengthDecoder??di,s=t?.maxLengthLength??8,c=t?.maxDataLength??4194304;function*a(){for(;e.byteLength>0;){if(n===De.LENGTH)try{if(o=i(e),o<0)throw new Vn("Invalid message length");if(o>c)throw new rr("Message length too long");let l=i.bytes;e.consume(l),t?.onLength!=null&&t.onLength(o),n=De.DATA}catch(l){if(l instanceof RangeError){if(e.byteLength>s)throw new Hn("Message length length too long");break}throw l}if(n===De.DATA){if(e.byteLength<o)break;let l=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(l),yield l,n=De.LENGTH}}}return zn(r)?async function*(){for await(let l of r)e.append(l),yield*a();if(e.byteLength>0)throw new Or("Unexpected end of input")}():function*(){for(let l of r)e.append(l),yield*a();if(e.byteLength>0)throw new Or("Unexpected end of input")}()}Fr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:i,value:s}=await r.next(e);if(i===!0)return;s!=null&&(yield s)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{e=1}}();return Fr(n,{...t??{},onLength:i=>{e=i}})};var Uc="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var nr=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Uc[e[r]&63];return t};var jn=class extends Error{constructor(t="Method not found"){super(t),this.name="MethodNotFoundError"}},Zn=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidMethodError"}},Kr=class extends Error{constructor(t="Unsupported value type"){super(t),this.name="UnsupportedValueTypeError"}},Wn=class extends Error{constructor(t="Cannot reuse RPC target name"){super(t),this.name="DuplicateTargetNameError"}},Vr=class extends Error{constructor(t="Duplicate scope"){super(t),this.name="DuplicateScopeError"}},Yn=class extends Error{constructor(t="Invalid return type"){super(t),this.name="InvalidReturnTypeError"}},Hr=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidInvocationTypeError"}},or=class extends Error{constructor(t="Parent invocation scope not found"){super(t),this.name="MissingParentScopeError"}},Xn=class extends Error{constructor(t="Invocation not found"){super(t),this.name="MissingInvocationError"}},Qn=class extends Error{constructor(t="Callback not found"){super(t),this.name="MissingCallbackError"}};var hi=new Float32Array([-0]),_e=new Uint8Array(hi.buffer);function Lc(r,t,e){hi[0]=r,t[e]=_e[0],t[e+1]=_e[1],t[e+2]=_e[2],t[e+3]=_e[3]}function Pc(r,t){return _e[0]=r[t],_e[1]=r[t+1],_e[2]=r[t+2],_e[3]=r[t+3],hi[0]}var pi=new Float64Array([-0]),St=new Uint8Array(pi.buffer);function Dc(r,t,e){pi[0]=r,t[e]=St[0],t[e+1]=St[1],t[e+2]=St[2],t[e+3]=St[3],t[e+4]=St[4],t[e+5]=St[5],t[e+6]=St[6],t[e+7]=St[7]}function Nc(r,t){return St[0]=r[t],St[1]=r[t+1],St[2]=r[t+2],St[3]=r[t+3],St[4]=r[t+4],St[5]=r[t+5],St[6]=r[t+6],St[7]=r[t+7],pi[0]}var xd=BigInt(Number.MAX_SAFE_INTEGER),bd=BigInt(Number.MIN_SAFE_INTEGER),Rt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Ne;if(t<xd&&t>bd)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>Rc&&(o=0n,++n>Rc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return Ne;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):Ne}},Ne=new Rt(0,0);Ne.toBigInt=function(){return 0n};Ne.zzEncode=Ne.zzDecode=function(){return this};Ne.length=function(){return 1};var Rc=4294967296n;function Mc(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Oc(r,t,e){if(e-t<1)return"";let o,i=[],s=0,c;for(;t<e;)c=r[t++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&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 mi(r,t,e){let n=e,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function Qt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Jn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var gi=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Qt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Qt(this,4);return Jn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Qt(this,4);return Jn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Qt(this,4);let t=Pc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Qt(this,4);let t=Nc(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Qt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Oc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Qt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Qt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Rt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Qt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Qt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Qt(this,8);let t=Jn(this.buf,this.pos+=4),e=Jn(this.buf,this.pos+=4);return new Rt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=fi(this.buf,this.pos);return this.pos+=ft(t),t}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 yi(r){return new gi(r instanceof Uint8Array?r:r.subarray())}function At(r,t,e){let n=yi(r);return t.decode(n,void 0,e)}var xi={};Pt(xi,{base10:()=>wd});var wd=ve({prefix:"9",name:"base10",alphabet:"0123456789"});var bi={};Pt(bi,{base16:()=>Ed,base16upper:()=>vd});var Ed=ot({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),vd=ot({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var wi={};Pt(wi,{base2:()=>Sd});var Sd=ot({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ei={};Pt(Ei,{base256emoji:()=>Bd});var Kc=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}"),Ad=Kc.reduce((r,t,e)=>(r[e]=t,r),[]),_d=Kc.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Id(r){return r.reduce((t,e)=>(t+=Ad[e],t),"")}function Cd(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=_d[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Bd=Xe({prefix:"\u{1F680}",name:"base256emoji",encode:Id,decode:Cd});var vi={};Pt(vi,{base36:()=>zr,base36upper:()=>kd});var zr=ve({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),kd=ve({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Si={};Pt(Si,{base8:()=>Td});var Td=ot({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ai={};Pt(Ai,{identity:()=>Ud});var Ud=Xe({prefix:"\0",name:"identity",encode:r=>Qs(r),decode:r=>Xs(r)});var ry=new TextEncoder,ny=new TextDecoder;var Ii={};Pt(Ii,{identity:()=>Jt});var Dd=zc,Vc=128,Nd=127,Rd=~Nd,Md=Math.pow(2,31);function zc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Md;)t[e++]=r&255|Vc,r/=128;for(;r&Rd;)t[e++]=r&255|Vc,r>>>=7;return t[e]=r|0,zc.bytes=e-n+1,t}var Od=_i,Fd=128,Hc=127;function _i(r,n){var e=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw _i.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&Hc)<<o:(s&Hc)*Math.pow(2,o),o+=7}while(s>=Fd);return _i.bytes=i-n,e}var Kd=Math.pow(2,7),Vd=Math.pow(2,14),Hd=Math.pow(2,21),zd=Math.pow(2,28),qd=Math.pow(2,35),$d=Math.pow(2,42),Gd=Math.pow(2,49),jd=Math.pow(2,56),Zd=Math.pow(2,63),Wd=function(r){return r<Kd?1:r<Vd?2:r<Hd?3:r<zd?4:r<qd?5:r<$d?6:r<Gd?7:r<jd?8:r<Zd?9:10},Yd={encode:Dd,decode:Od,encodingLength:Wd},Xd=Yd,qr=Xd;function $r(r,t=0){return[qr.decode(r,t),qr.decode.bytes]}function ir(r,t,e=0){return qr.encode(r,t,e),t}function sr(r){return qr.encodingLength(r)}function Re(r,t){let e=t.byteLength,n=sr(r),o=n+sr(e),i=new Uint8Array(o+e);return ir(r,i,0),ir(e,i,n),i.set(t,o),new cr(r,e,t,i)}function le(r){let t=ae(r),[e,n]=$r(t),[o,i]=$r(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new cr(e,o,s,t)}function qc(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Ys(r.bytes,e.bytes)}}var cr=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var $c=0,Qd="identity",Gc=ae;function Jd(r){return Re($c,Gc(r))}var Jt={code:$c,name:Qd,encode:Gc,digest:Jd};var ki={};Pt(ki,{sha256:()=>Gr,sha512:()=>th});function Bi({name:r,code:t,encode:e}){return new Ci(r,t,e)}var Ci=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Re(this.code,e):e.then(n=>Re(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Zc(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Gr=Bi({name:"sha2-256",code:18,encode:Zc("SHA-256")}),th=Bi({name:"sha2-512",code:19,encode:Zc("SHA-512")});function Wc(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return rh(e,Ti(r),t??tt.encoder);default:return nh(e,Ti(r),t??Wt.encoder)}}var Yc=new WeakMap;function Ti(r){let t=Yc.get(r);if(t==null){let e=new Map;return Yc.set(r,e),e}return t}var st=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,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:t,multihash:e}=this;if(t!==jr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==oh)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:t,digest:e}=this.multihash,n=Re(t,e);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(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&qc(t.multihash,n.multihash)}toString(t){return Wc(this,t)}toJSON(){return{"/":Wc(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s??Xc(n,o,i.bytes))}else if(e[ih]===!0){let{version:n,multihash:o,code:i}=e,s=le(o);return r.create(n,i,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==jr)throw new Error(`Version 0 CID must use dag-pb (code: ${jr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Xc(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,jr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=ae(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new cr(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[f,h]=$r(t.subarray(e));return e+=h,f},o=n(),i=jr;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,c=n(),a=n(),l=e+a,u=l-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:l}}static parse(t,e){let[n,o]=eh(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ti(i).set(n,t),i}};function eh(r,t){switch(r[0]){case"Q":{let e=t??tt;return[tt.prefix,e.decode(`${tt.prefix}${r}`)]}case tt.prefix:{let e=t??tt;return[tt.prefix,e.decode(r)]}case Wt.prefix:{let e=t??Wt;return[Wt.prefix,e.decode(r)]}case zr.prefix:{let e=t??zr;return[zr.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function rh(r,t,e){let{prefix:n}=e;if(n!==tt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function nh(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o}var jr=112,oh=18;function Xc(r,t,e){let n=sr(r),o=n+sr(t),i=new Uint8Array(o+e.byteLength);return ir(r,i,0),ir(t,i,n),i.set(e,o),i}var ih=Symbol.for("@ipld/js-cid/CID");var Zr={...Ai,...wi,...Si,...xi,...bi,...Yo,...vi,...Xo,...Qo,...Ei},_y={...ki,...Ii};function Jc(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Qc=Jc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ui=Jc("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Et(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),sh={utf8:Qc,"utf-8":Qc,hex:Zr.base16,latin1:Ui,ascii:Ui,binary:Ui,...Zr},eo=sh;function $t(r,t="utf8"){let e=eo[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Li(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return Et(s);o+s>t&&(n=Et(t),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Me=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Pi(){}var Ni=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},ch=Li();function ah(r){return globalThis.Buffer!=null?Et(r):ch(r)}var Yr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Me(Pi,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Me(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Ri((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(ro,10,Rt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Rt.fromBigInt(t);return this._push(ro,e.length(),e)}uint64Number(t){return this._push(li,ft(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=Rt.fromBigInt(t).zzEncode();return this._push(ro,e.length(),e)}sint64Number(t){let e=Rt.fromNumber(t).zzEncode();return this._push(ro,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Di,1,t?1:0)}fixed32(t){return this._push(Wr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Rt.fromBigInt(t);return this._push(Wr,4,e.lo)._push(Wr,4,e.hi)}fixed64Number(t){let e=Rt.fromNumber(t);return this._push(Wr,4,e.lo)._push(Wr,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Lc,4,t)}double(t){return this._push(Dc,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Di,1,0):this.uint32(e)._push(lh,e,t)}string(t){let e=Mc(t);return e!==0?this.uint32(e)._push(mi,e,t):this._push(Di,1,0)}fork(){return this.states=new Ni(this),this.head=this.tail=new Me(Pi,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 Me(Pi,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=ah(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Di(r,t,e){t[e]=r&255}function uh(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Ri=class extends Me{next;constructor(t,e){super(uh,t,e),this.next=void 0}};function ro(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Wr(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function lh(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Yr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(fh,t,r),this},Yr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(dh,t,r),this});function fh(r,t,e){t.set(r,e)}function dh(r,t,e){r.length<40?mi(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set($t(r),e)}function Mi(){return new Yr}function _t(r,t){let e=Mi();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var ar;(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"})(ar||(ar={}));function no(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Xr(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,s){let c=t(i);s.int32(c)},n=function(i){let s=i.int32();return t(s)};return no("enum",ar.VARINT,e,n)}function It(r,t){return no("message",ar.LENGTH_DELIMITED,r,t)}var fe=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var H;(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"})(H||(H={}));var oo;(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"})(oo||(oo={}));(function(r){r.codec=()=>Xr(oo)})(H||(H={}));var Ut;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.type!=null&&e.type!==0&&(n.uint32(8),n.uint32(e.type)),e.value!=null&&(n.uint32(18),n.bytes(e.value)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={type:0},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.type=e.uint32();break}case 2:{i.value=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>_t(e,r.codec()),r.decode=(e,n)=>At(e,r.codec(),n)})(Ut||(Ut={}));var Ct;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.type!=null&&oo[e.type]!==0&&(n.uint32(8),H.codec().encode(e.type,n)),e.message!=null&&e.message.byteLength>0&&(n.uint32(18),n.bytes(e.message)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={type:H.invokeMethod,message:Xt(0)},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.type=H.codec().decode(e);break}case 2:{i.message=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>_t(e,r.codec()),r.decode=(e,n)=>At(e,r.codec(),n)})(Ct||(Ct={}));var Oe;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.path!=null&&e.path!==""&&(n.uint32(18),n.string(e.path)),e.args!=null)for(let i of e.args)n.uint32(26),Ut.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",path:"",args:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.path=e.string();break}case 3:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new fe('Decode error - map field "args" had too many elements');i.args.push(Ut.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>_t(e,r.codec()),r.decode=(e,n)=>At(e,r.codec(),n)})(Oe||(Oe={}));var Qr;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>_t(e,r.codec()),r.decode=(e,n)=>At(e,r.codec(),n)})(Qr||(Qr={}));var ur;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.value!=null&&(n.uint32(18),Ut.codec().encode(e.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.value=Ut.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>_t(e,r.codec()),r.decode=(e,n)=>At(e,r.codec(),n)})(ur||(ur={}));var Jr;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.error!=null&&(n.uint32(18),Ut.codec().encode(e.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.error=Ut.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>_t(e,r.codec()),r.decode=(e,n)=>At(e,r.codec(),n)})(Jr||(Jr={}));var lr;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);if(e.callback!=null&&e.callback!==""&&(n.uint32(26),n.string(e.callback)),e.args!=null)for(let i of e.args)n.uint32(34),Ut.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[],callback:"",args:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new fe('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.callback=e.string();break}case 4:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new fe('Decode error - map field "args" had too many elements');i.args.push(Ut.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>_t(e,r.codec()),r.decode=(e,n)=>At(e,r.codec(),n)})(lr||(lr={}));var fr;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new fe('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>_t(e,r.codec()),r.decode=(e,n)=>At(e,r.codec(),n)})(fr||(fr={}));var tn;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);e.value!=null&&(n.uint32(26),Ut.codec().encode(e.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new fe('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.value=Ut.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>_t(e,r.codec()),r.decode=(e,n)=>At(e,r.codec(),n)})(tn||(tn={}));var en;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);e.error!=null&&(n.uint32(26),Ut.codec().encode(e.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new fe('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.error=Ut.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>_t(e,r.codec()),r.decode=(e,n)=>At(e,r.codec(),n)})(en||(en={}));function hh(r){return r.parents!=null}function ta(r,t){if(hh(r))return ph(r.parents,t);let e=t.get(r.scope);if(e==null)throw new Xn;return e}function ph(r,t){let e;for(let n of r){if(e==null){if(e=t.get(n),e==null)throw new or;continue}if(e=e.children.get(n),e==null)throw new or}if(e==null)throw new or;return e}var mh={type:1024,canEncode:r=>r===void 0,decode:()=>{}},ea=mh;var gh={type:1025,canEncode:r=>r===null,decode:()=>null},ra=gh;var yh=["string","number","bigint","symbol"],xh=["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 na(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let t=typeof r;if(yh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(r))return"Array";if(bh(r))return"Buffer";let e=wh(r);return e||"Object"}function bh(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function wh(r){let t=Object.prototype.toString.call(r).slice(8,-1);if(xh.includes(t))return t}var p=class{constructor(t,e,n){this.major=t,this.majorEncoded=t<<5,this.name=e,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};p.uint=new p(0,"uint",!0);p.negint=new p(1,"negint",!0);p.bytes=new p(2,"bytes",!0);p.string=new p(3,"string",!0);p.array=new p(4,"array",!1);p.map=new p(5,"map",!1);p.tag=new p(6,"tag",!1);p.float=new p(7,"float",!0);p.false=new p(7,"false",!0);p.true=new p(7,"true",!0);p.null=new p(7,"null",!0);p.undefined=new p(7,"undefined",!0);p.break=new p(7,"break",!0);var C=class{constructor(t,e,n){this.type=t,this.value=e,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var dr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Eh=new TextDecoder,vh=new TextEncoder;function io(r){return dr&&globalThis.Buffer.isBuffer(r)}function Oi(r){return r instanceof Uint8Array?io(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var ca=dr?(r,t,e)=>e-t>64?globalThis.Buffer.from(r.subarray(t,e)).toString("utf8"):ia(r,t,e):(r,t,e)=>e-t>64?Eh.decode(r.subarray(t,e)):ia(r,t,e),aa=dr?r=>r.length>64?globalThis.Buffer.from(r):oa(r):r=>r.length>64?vh.encode(r):oa(r),oe=r=>Uint8Array.from(r),hr=dr?(r,t,e)=>io(r)?new Uint8Array(r.subarray(t,e)):r.slice(t,e):(r,t,e)=>r.slice(t,e),ua=dr?(r,t)=>(r=r.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),Oi(globalThis.Buffer.concat(r,t))):(r,t)=>{let e=new Uint8Array(t),n=0;for(let o of r)n+o.length>e.length&&(o=o.subarray(0,e.length-n)),e.set(o,n),n+=o.length;return e},la=dr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function fa(r,t){if(io(r)&&io(t))return r.compare(t);for(let e=0;e<r.length;e++)if(r[e]!==t[e])return r[e]<t[e]?-1:1;return 0}function oa(r){let t=[],e=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=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),t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128)}return t}function ia(r,t,e){let n=[];for(;t<e;){let o=r[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=e){let c,a,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:c=r[t+1],(c&192)===128&&(u=(o&31)<<6|c&63,u>127&&(i=u));break;case 3:c=r[t+1],a=r[t+2],(c&192)===128&&(a&192)===128&&(u=(o&15)<<12|(c&63)<<6|a&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:c=r[t+1],a=r[t+2],l=r[t+3],(c&192)===128&&(a&192)===128&&(l&192)===128&&(u=(o&15)<<18|(c&63)<<12|(a&63)<<6|l&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return Sh(n)}var sa=4096;function Sh(r){let t=r.length;if(t<=sa)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=sa));return e}var Ah=256,rn=class{constructor(t=Ah){this.chunkSize=t,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(t){let e=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=e.length-(this.maxCursor-this.cursor)-1;e.set(t,o)}else{if(e){let o=e.length-(this.maxCursor-this.cursor)-1;o<e.length&&(this.chunks[this.chunks.length-1]=e.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(e=la(this.chunkSize),this.chunks.push(e),this.maxCursor+=e.length,this._initReuseChunk===null&&(this._initReuseChunk=e),e.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let e;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(e=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):e=hr(n,0,this.cursor)}else e=ua(this.chunks,this.cursor);return t&&this.reset(),e}};var M="CBOR decode error:",Fi="CBOR encode error:",nn=[];nn[23]=1;nn[24]=2;nn[25]=3;nn[26]=5;nn[27]=9;function de(r,t,e){if(r.length-t<e)throw new Error(`${M} not enough data for type`)}var dt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Mt(r,t,e){de(r,t,1);let n=r[t];if(e.strict===!0&&n<dt[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Ot(r,t,e){de(r,t,2);let n=r[t]<<8|r[t+1];if(e.strict===!0&&n<dt[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Ft(r,t,e){de(r,t,4);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];if(e.strict===!0&&n<dt[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Kt(r,t,e){de(r,t,8);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3],o=r[t+4]*16777216+(r[t+5]<<16)+(r[t+6]<<8)+r[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(e.strict===!0&&i<dt[3])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(e.allowBigInt===!0)return i;throw new Error(`${M} integers outside of the safe integer range are not supported`)}function da(r,t,e,n){return new C(p.uint,Mt(r,t+1,n),2)}function ha(r,t,e,n){return new C(p.uint,Ot(r,t+1,n),3)}function pa(r,t,e,n){return new C(p.uint,Ft(r,t+1,n),5)}function ma(r,t,e,n){return new C(p.uint,Kt(r,t+1,n),9)}function Gt(r,t){return gt(r,0,t.value)}function gt(r,t,e){if(e<dt[0]){let n=Number(e);r.push([t|n])}else if(e<dt[1]){let n=Number(e);r.push([t|24,n])}else if(e<dt[2]){let n=Number(e);r.push([t|25,n>>>8,n&255])}else if(e<dt[3]){let n=Number(e);r.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(e);if(n<dt[4]){let o=[t|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(`${M} encountered BigInt larger than allowable range`)}}Gt.encodedSize=function(t){return gt.encodedSize(t.value)};gt.encodedSize=function(t){return t<dt[0]?1:t<dt[1]?2:t<dt[2]?3:t<dt[3]?5:9};Gt.compareTokens=function(t,e){return t.value<e.value?-1:t.value>e.value?1:0};function ga(r,t,e,n){return new C(p.negint,-1-Mt(r,t+1,n),2)}function ya(r,t,e,n){return new C(p.negint,-1-Ot(r,t+1,n),3)}function xa(r,t,e,n){return new C(p.negint,-1-Ft(r,t+1,n),5)}var Ki=BigInt(-1),ba=BigInt(1);function wa(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new C(p.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new C(p.negint,Ki-BigInt(o),9)}function so(r,t){let e=t.value,n=typeof e=="bigint"?e*Ki-ba:e*-1-1;gt(r,t.type.majorEncoded,n)}so.encodedSize=function(t){let e=t.value,n=typeof e=="bigint"?e*Ki-ba:e*-1-1;return n<dt[0]?1:n<dt[1]?2:n<dt[2]?3:n<dt[3]?5:9};so.compareTokens=function(t,e){return t.value<e.value?1:t.value>e.value?-1:0};function on(r,t,e,n){de(r,t,e+n);let o=hr(r,t+e,t+e+n);return new C(p.bytes,o,e+n)}function Ea(r,t,e,n){return on(r,t,1,e)}function va(r,t,e,n){return on(r,t,2,Mt(r,t+1,n))}function Sa(r,t,e,n){return on(r,t,3,Ot(r,t+1,n))}function Aa(r,t,e,n){return on(r,t,5,Ft(r,t+1,n))}function _a(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return on(r,t,9,o)}function co(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===p.string?aa(r.value):r.value),r.encodedBytes}function pr(r,t){let e=co(t);gt(r,t.type.majorEncoded,e.length),r.push(e)}pr.encodedSize=function(t){let e=co(t);return gt.encodedSize(e.length)+e.length};pr.compareTokens=function(t,e){return Ih(co(t),co(e))};function Ih(r,t){return r.length<t.length?-1:r.length>t.length?1:fa(r,t)}function sn(r,t,e,n,o){let i=e+n;de(r,t,i);let s=new C(p.string,ca(r,t+e,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=hr(r,t+e,t+i)),s}function Ia(r,t,e,n){return sn(r,t,1,e,n)}function Ca(r,t,e,n){return sn(r,t,2,Mt(r,t+1,n),n)}function Ba(r,t,e,n){return sn(r,t,3,Ot(r,t+1,n),n)}function ka(r,t,e,n){return sn(r,t,5,Ft(r,t+1,n),n)}function Ta(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return sn(r,t,9,o,n)}var Ua=pr;function mr(r,t,e,n){return new C(p.array,n,e)}function La(r,t,e,n){return mr(r,t,1,e)}function Pa(r,t,e,n){return mr(r,t,2,Mt(r,t+1,n))}function Da(r,t,e,n){return mr(r,t,3,Ot(r,t+1,n))}function Na(r,t,e,n){return mr(r,t,5,Ft(r,t+1,n))}function Ra(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return mr(r,t,9,o)}function Ma(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return mr(r,t,1,1/0)}function ao(r,t){gt(r,p.array.majorEncoded,t.value)}ao.compareTokens=Gt.compareTokens;ao.encodedSize=function(t){return gt.encodedSize(t.value)};function gr(r,t,e,n){return new C(p.map,n,e)}function Oa(r,t,e,n){return gr(r,t,1,e)}function Fa(r,t,e,n){return gr(r,t,2,Mt(r,t+1,n))}function Ka(r,t,e,n){return gr(r,t,3,Ot(r,t+1,n))}function Va(r,t,e,n){return gr(r,t,5,Ft(r,t+1,n))}function Ha(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return gr(r,t,9,o)}function za(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return gr(r,t,1,1/0)}function uo(r,t){gt(r,p.map.majorEncoded,t.value)}uo.compareTokens=Gt.compareTokens;uo.encodedSize=function(t){return gt.encodedSize(t.value)};function qa(r,t,e,n){return new C(p.tag,e,1)}function $a(r,t,e,n){return new C(p.tag,Mt(r,t+1,n),2)}function Ga(r,t,e,n){return new C(p.tag,Ot(r,t+1,n),3)}function ja(r,t,e,n){return new C(p.tag,Ft(r,t+1,n),5)}function Za(r,t,e,n){return new C(p.tag,Kt(r,t+1,n),9)}function lo(r,t){gt(r,p.tag.majorEncoded,t.value)}lo.compareTokens=Gt.compareTokens;lo.encodedSize=function(t){return gt.encodedSize(t.value)};var Lh=20,Ph=21,Dh=22,Nh=23;function Wa(r,t,e,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new C(p.null,null,1):new C(p.undefined,void 0,1)}function Ya(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new C(p.break,void 0,1)}function Vi(r,t,e){if(e){if(e.allowNaN===!1&&Number.isNaN(r))throw new Error(`${M} NaN values are not supported`);if(e.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new C(p.float,r,t)}function Xa(r,t,e,n){return Vi(Hi(r,t+1),3,n)}function Qa(r,t,e,n){return Vi(zi(r,t+1),5,n)}function Ja(r,t,e,n){return Vi(nu(r,t+1),9,n)}function fo(r,t,e){let n=t.value;if(n===!1)r.push([p.float.majorEncoded|Lh]);else if(n===!0)r.push([p.float.majorEncoded|Ph]);else if(n===null)r.push([p.float.majorEncoded|Dh]);else if(n===void 0)r.push([p.float.majorEncoded|Nh]);else{let o,i=!1;(!e||e.float64!==!0)&&(eu(n),o=Hi(te,1),n===o||Number.isNaN(n)?(te[0]=249,r.push(te.slice(0,3)),i=!0):(ru(n),o=zi(te,1),n===o&&(te[0]=250,r.push(te.slice(0,5)),i=!0))),i||(Rh(n),o=nu(te,1),te[0]=251,r.push(te.slice(0,9)))}}fo.encodedSize=function(t,e){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!e||e.float64!==!0){eu(n);let o=Hi(te,1);if(n===o||Number.isNaN(n))return 3;if(ru(n),o=zi(te,1),n===o)return 5}return 9};var tu=new ArrayBuffer(9),jt=new DataView(tu,1),te=new Uint8Array(tu,0);function eu(r){if(r===1/0)jt.setUint16(0,31744,!1);else if(r===-1/0)jt.setUint16(0,64512,!1);else if(Number.isNaN(r))jt.setUint16(0,32256,!1);else{jt.setFloat32(0,r);let t=jt.getUint32(0),e=(t&2139095040)>>23,n=t&8388607;if(e===255)jt.setUint16(0,31744,!1);else if(e===0)jt.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=e-127;o<-24?jt.setUint16(0,0):o<-14?jt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):jt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Hi(r,t){if(r.length-t<2)throw new Error(`${M} not enough data for float16`);let e=(r[t]<<8)+r[t+1];if(e===31744)return 1/0;if(e===64512)return-1/0;if(e===32256)return NaN;let n=e>>10&31,o=e&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,e&32768?-i:i}function ru(r){jt.setFloat32(0,r,!1)}function zi(r,t){if(r.length-t<4)throw new Error(`${M} not enough data for float32`);let e=(r.byteOffset||0)+t;return new DataView(r.buffer,e,4).getFloat32(0,!1)}function Rh(r){jt.setFloat64(0,r,!1)}function nu(r,t){if(r.length-t<8)throw new Error(`${M} not enough data for float64`);let e=(r.byteOffset||0)+t;return new DataView(r.buffer,e,8).getFloat64(0,!1)}fo.compareTokens=Gt.compareTokens;function z(r,t,e){throw new Error(`${M} encountered invalid minor (${e}) for major ${r[t]>>>5}`)}function ho(r){return()=>{throw new Error(`${M} ${r}`)}}var v=[];for(let r=0;r<=23;r++)v[r]=z;v[24]=da;v[25]=ha;v[26]=pa;v[27]=ma;v[28]=z;v[29]=z;v[30]=z;v[31]=z;for(let r=32;r<=55;r++)v[r]=z;v[56]=ga;v[57]=ya;v[58]=xa;v[59]=wa;v[60]=z;v[61]=z;v[62]=z;v[63]=z;for(let r=64;r<=87;r++)v[r]=Ea;v[88]=va;v[89]=Sa;v[90]=Aa;v[91]=_a;v[92]=z;v[93]=z;v[94]=z;v[95]=ho("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)v[r]=Ia;v[120]=Ca;v[121]=Ba;v[122]=ka;v[123]=Ta;v[124]=z;v[125]=z;v[126]=z;v[127]=ho("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)v[r]=La;v[152]=Pa;v[153]=Da;v[154]=Na;v[155]=Ra;v[156]=z;v[157]=z;v[158]=z;v[159]=Ma;for(let r=160;r<=183;r++)v[r]=Oa;v[184]=Fa;v[185]=Ka;v[186]=Va;v[187]=Ha;v[188]=z;v[189]=z;v[190]=z;v[191]=za;for(let r=192;r<=215;r++)v[r]=qa;v[216]=$a;v[217]=Ga;v[218]=ja;v[219]=Za;v[220]=z;v[221]=z;v[222]=z;v[223]=z;for(let r=224;r<=243;r++)v[r]=ho("simple values are not supported");v[244]=z;v[245]=z;v[246]=z;v[247]=Wa;v[248]=ho("simple values are not supported");v[249]=Xa;v[250]=Qa;v[251]=Ja;v[252]=z;v[253]=z;v[254]=z;v[255]=Ya;var ee=[];for(let r=0;r<24;r++)ee[r]=new C(p.uint,r,1);for(let r=-1;r>=-24;r--)ee[31-r]=new C(p.negint,r,1);ee[64]=new C(p.bytes,new Uint8Array(0),1);ee[96]=new C(p.string,"",1);ee[128]=new C(p.array,0,1);ee[160]=new C(p.map,0,1);ee[244]=new C(p.false,!1,1);ee[245]=new C(p.true,!0,1);ee[246]=new C(p.null,null,1);function ou(r){switch(r.type){case p.false:return oe([244]);case p.true:return oe([245]);case p.null:return oe([246]);case p.bytes:return r.value.length?void 0:oe([64]);case p.string:return r.value===""?oe([96]):void 0;case p.array:return r.value===0?oe([128]):void 0;case p.map:return r.value===0?oe([160]):void 0;case p.uint:return r.value<24?oe([Number(r.value)]):void 0;case p.negint:if(r.value>=-24)return oe([31-Number(r.value)])}}var Oh={float64:!1,mapSorter:Vh,quickEncodeToken:ou};function Fh(){let r=[];return r[p.uint.major]=Gt,r[p.negint.major]=so,r[p.bytes.major]=pr,r[p.string.major]=Ua,r[p.array.major]=ao,r[p.map.major]=uo,r[p.tag.major]=lo,r[p.float.major]=fo,r}var iu=Fh(),qi=new rn,mo=class r{constructor(t,e){this.obj=t,this.parent=e}includes(t){let e=this;do if(e.obj===t)return!0;while(e=e.parent);return!1}static createCheck(t,e){if(t&&t.includes(e))throw new Error(`${Fi} object contains circular references`);return new r(e,t)}},Ce={null:new C(p.null,null),undefined:new C(p.undefined,void 0),true:new C(p.true,!0),false:new C(p.false,!1),emptyArray:new C(p.array,0),emptyMap:new C(p.map,0)},Be={number(r,t,e,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new C(p.float,r):r>=0?new C(p.uint,r):new C(p.negint,r)},bigint(r,t,e,n){return r>=BigInt(0)?new C(p.uint,r):new C(p.negint,r)},Uint8Array(r,t,e,n){return new C(p.bytes,r)},string(r,t,e,n){return new C(p.string,r)},boolean(r,t,e,n){return r?Ce.true:Ce.false},null(r,t,e,n){return Ce.null},undefined(r,t,e,n){return Ce.undefined},ArrayBuffer(r,t,e,n){return new C(p.bytes,new Uint8Array(r))},DataView(r,t,e,n){return new C(p.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,t,e,n){if(!r.length)return e.addBreakTokens===!0?[Ce.emptyArray,new C(p.break)]:Ce.emptyArray;n=mo.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=po(s,e,n);return e.addBreakTokens?[new C(p.array,r.length),o,new C(p.break)]:[new C(p.array,r.length),o]},Object(r,t,e,n){let o=t!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return e.addBreakTokens===!0?[Ce.emptyMap,new C(p.break)]:Ce.emptyMap;n=mo.createCheck(n,r);let c=[],a=0;for(let l of i)c[a++]=[po(l,e,n),po(o?r.get(l):r[l],e,n)];return Kh(c,e),e.addBreakTokens?[new C(p.map,s),c,new C(p.break)]:[new C(p.map,s),c]}};Be.Map=Be.Object;Be.Buffer=Be.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Be[`${r}Array`]=Be.DataView;function po(r,t={},e){let n=na(r),o=t&&t.typeEncoders&&t.typeEncoders[n]||Be[n];if(typeof o=="function"){let s=o(r,n,t,e);if(s!=null)return s}let i=Be[n];if(!i)throw new Error(`${Fi} unsupported type: ${n}`);return i(r,n,t,e)}function Kh(r,t){t.mapSorter&&r.sort(t.mapSorter)}function Vh(r,t){let e=Array.isArray(r[0])?r[0][0]:r[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(e.type!==n.type)return e.type.compare(n.type);let o=e.type.major,i=iu[o].compareTokens(e,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function su(r,t,e,n){if(Array.isArray(t))for(let o of t)su(r,o,e,n);else e[t.type.major](r,t,n)}function Hh(r,t,e){let n=po(r,e);if(!Array.isArray(n)&&e.quickEncodeToken){let o=e.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,e),c=new rn(s);if(i(c,n,e),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Oi(c.chunks[0])}}return qi.reset(),su(qi,n,t,e),qi.toBytes(!0)}function W(r,t){return t=Object.assign({},Oh,t),Hh(r,iu,t)}var zh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},go=class{constructor(t,e={}){this._pos=0,this.data=t,this.options=e}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],e=ee[t];if(e===void 0){let n=v[t];if(!n)throw new Error(`${M} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;e=n(this.data,this._pos,o,this.options)}return this._pos+=e.encodedLength,e}},cn=Symbol.for("DONE"),yo=Symbol.for("BREAK");function qh(r,t,e){let n=[];for(let o=0;o<r.value;o++){let i=yr(t,e);if(i===yo){if(r.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===cn)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function $h(r,t,e){let n=e.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let c=yr(t,e);if(c===yo){if(r.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(c===cn)throw new Error(`${M} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${M} non-string keys not supported (got ${typeof c})`);if(e.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${M} found repeat map key "${c}"`);let a=yr(t,e);if(a===cn)throw new Error(`${M} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(c,a):o[c]=a}return n?i:o}function yr(r,t){if(r.done())return cn;let e=r.next();if(e.type===p.break)return yo;if(e.type.terminal)return e.value;if(e.type===p.array)return qh(e,r,t);if(e.type===p.map)return $h(e,r,t);if(e.type===p.tag){if(t.tags&&typeof t.tags[e.value]=="function"){let n=yr(r,t);return t.tags[e.value](n)}throw new Error(`${M} tag not supported (${e.value})`)}throw new Error("unsupported")}function cu(r,t){if(!(r instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},zh,t);let e=t.tokenizer||new go(r,t),n=yr(e,t);if(n===cn)throw new Error(`${M} did not find any content to decode`);if(n===yo)throw new Error(`${M} got unexpected break`);return[n,r.subarray(e.pos())]}function Y(r,t){let[e,n]=cu(r,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return e}var Gh={type:1026,canEncode:r=>r===!0||r===!1,encode:r=>W(r),decode:r=>Y(r)},au=Gh;var jh={type:1027,canEncode:r=>typeof r=="number"&&!isNaN(r),encode:r=>W(r),decode:r=>Y(r)},uu=jh;var Zh={type:1028,canEncode:r=>typeof r=="string",encode:r=>W(r),decode:r=>Y(r)},lu=Zh;var Wh={type:1029,canEncode:r=>Array.isArray(r),encode:(r,t,e,n)=>W(r.map(o=>t.toValue(o,e,n))),decode:(r,t,e,n)=>Y(r).map(o=>t.fromValue(o,e,n))},fu=Wh;var Yh={type:1030,canEncode:r=>typeof r=="function",encode:(r,t,e,n)=>{let o=nr();return n?.callbacks.set(o,{context:e,fn:r}),W(o)},decode:(r,t,e,n)=>async(...o)=>new Promise((i,s)=>{let c=Y(r),a=nr(),l={scope:a,result:wt(),callbacks:new Map,children:new Map,parents:[...n.parents,n.scope],abortControllers:[],abortSignals:[]};n.children.set(a,l),o=o.map(f=>t.toValue(f,null,l));let u=On(l.abortSignals);u.addEventListener("abort",()=>{e.push(Ct.encode({type:H.abortCallbackInvocation,message:fr.encode({scope:a,parents:l.parents})}))}),e.push(Ct.encode({type:H.invokeCallback,message:lr.encode({scope:a,parents:l.parents,callback:c,args:o})})),l.result.promise.then(f=>{i(f)},f=>{s(f)}).finally(()=>{n.children.delete(a),u.clear()})})},du=Yh;var Xh={type:1031,canEncode:r=>r.toString()==="NaN"&&isNaN(r),decode:()=>NaN},hu=Xh;var Qh={type:1032,canEncode:r=>r instanceof Error,encode:r=>W({message:r.message,name:r.name,code:r.code,type:r.type,stack:r.stack}),decode:r=>{let t=Y(r),e=new Error(t.message);return e.name=t.name,e.stack=t.stack,e.code=t.code,e.type=t.type,e}},pu=Qh;var Jh={type:1033,canEncode:r=>Array.isArray(r),encode:(r,t,e,n)=>{throw new Error("Promises are not supported")},decode:(r,t,e,n)=>{throw new Error("Promises are not supported")}},mu=Jh;var gu=["__defineGetter__","__defineSetter__","hasOwnProperty","__lookupGetter__","__lookupSetter__","isPrototypeOf","propertyIsEnumerable","toString","valueOf","__proto__","toLocaleString","constructor"],tp={type:2147483647,canEncode:r=>typeof r=="object",encode:(r,t,e,n)=>{let o={};for(let i in r)gu.includes(i)||Object.hasOwn(r,i)&&(o[i]=r[i]);for(let i of Object.getOwnPropertyNames(Object.getPrototypeOf(r)))gu.includes(i)||(o[i]=r[i]);return W([...Object.entries(o)].map(([i,s])=>[t.toValue(i,r,n),t.toValue(s,r,n)]))},decode:(r,t,e,n)=>{let o={};return Y(r).forEach(([s,c])=>{o[t.fromValue(s,e,n)]=t.fromValue(c,e,n)}),o}},an=tp;var ep={type:1034,canEncode:r=>typeof r.next=="function"&&typeof r.throw=="function"&&typeof r.return=="function",encode:(r,t,e,n)=>an.encode({next:r.next.bind(r),throw:r.throw.bind(r),return:r.return.bind(r)},t,e,n),decode:(r,t,e,n)=>{let o=an.decode(r,t,e,n);return o[Symbol.asyncIterator]=()=>o,o}},yu=ep;var rp={type:1035,canEncode:r=>typeof r=="bigint",encode:r=>W(r),decode:r=>BigInt(Y(r))},xu=rp;var np={type:1036,canEncode:r=>r instanceof Map,encode:(r,t,e,n)=>W([...r.entries()].map(([o,i])=>[t.toValue(o,e,n),t.toValue(i,e,n)])),decode:(r,t,e,n)=>{let o=new Map;return Y(r).forEach(([s,c])=>{let a=t.fromValue(s,e,n),l=t.fromValue(c,e,n);o.set(a,l)}),o}},bu=np;var op={type:1037,canEncode:r=>r instanceof Set,encode:(r,t,e,n)=>W([...r.values()].map(o=>t.toValue(o,e,n))),decode:(r,t,e,n)=>{let o=new Set;return Y(r).forEach(s=>{o.add(t.fromValue(s,e,n))}),o}},wu=op;var ip={type:1038,canEncode:r=>r instanceof Uint8Array,encode:r=>r,decode:r=>r},Eu=ip;var sp={type:1039,canEncode:r=>r instanceof AbortSignal,encode:(r,t,e,n)=>(n?.abortSignals.push(r),new Uint8Array(0)),decode:(r,t,e,n)=>{let o=new AbortController;return n.abortControllers.push(o),o.signal}},vu=sp;var cp={type:1040,canEncode:r=>r instanceof Date,encode:r=>W(r.toString()),decode:r=>new Date(Y(r))},Su=cp;var ap={type:1041,canEncode:r=>r instanceof RegExp,encode:r=>W({source:r.source,flags:r.flags}),decode:r=>{let{source:t,flags:e}=Y(r);return new RegExp(t,e)}},Au=ap;var _u=[ea,ra,au,uu,lu,fu,du,hu,pu,mu,yu,xu,bu,wu,Eu,vu,Su,Au,an];var xo=class{transformersMap;transformersList;constructor(t){this.transformersList=[..._u,...t?.valueCodecs??[]].sort((e,n)=>e.type<n.type?-1:e.type>n.type?1:0),this.transformersMap={},this.transformersList.forEach(e=>{if(this.transformersMap[e.type]!=null)throw new Error(`Duplicate transformer type ${e.type}`);this.transformersMap[e.type]=e})}toValue(t,e,n){for(let o=0;o<this.transformersList.length;o++){let i=this.transformersList[o];if(i.canEncode(t))return{type:i.type,value:i.encode?.(t,this,e,n)}}throw new Kr(`Unsupported value type "${t}"`)}fromValue(t,e,n){let o=this.transformersMap[t.type];if(o==null)throw new Kr(`Unsupported value type "${t.type}"`);return o.decode(t.value??new Uint8Array(0),this,e,n)}};function up(r){return r.isScope===!0}function lp(r){return r.type===H.invokeMethod||r.type===H.invokeGeneratorMethod||r.type===H.invokeCallback}var $i=class{source;output;targets;invocations;values;messageHandlers;constructor(t){this.output=er(),this.source=Gn(this.output),this.targets=new Map,this.invocations=new Map,this.values=new xo(t),this.sink=this.sink.bind(this),this.messageHandlers={[H.invokeMethod]:{decoder:Oe,handler:this.handleInvokeMethod.bind(this)},[H.invokeGeneratorMethod]:{decoder:Oe,handler:this.handleInvokeGeneratorMethod.bind(this)},[H.abortMethodInvocation]:{decoder:Qr,handler:this.handleAbortMethod.bind(this),isScope:!0},[H.methodResolved]:{decoder:ur,handler:this.handleMethodResolved.bind(this),isScope:!0},[H.methodRejected]:{decoder:Jr,handler:this.handleMethodRejected.bind(this),isScope:!0,isError:!0},[H.invokeCallback]:{decoder:lr,handler:this.handleInvokeCallback.bind(this),isScope:!0},[H.abortCallbackInvocation]:{decoder:fr,handler:this.handleAbortCallback.bind(this),isScope:!0},[H.callbackResolved]:{decoder:tn,handler:this.handleCallbackResolved.bind(this),isScope:!0},[H.callbackRejected]:{decoder:en,handler:this.handleCallbackRejected.bind(this),isScope:!0,isError:!0}}}async sink(t){for await(let e of Fr(t))try{let n=Ct.decode(e),o=this.messageHandlers[n.type];if(o==null)continue;let i=o.decoder.decode(n.message),s;if(up(o))try{s=ta(i,this.invocations)}catch{continue}o.handler(i,s).catch(c=>{lp(n)&&this.sendError(i,c),this.invocations.delete(i.scope)}).finally(()=>{n.type===H.invokeMethod&&this.invocations.delete(i.scope)})}catch{continue}}sendError(t,e){t.parents!=null?this.output.push(Ct.encode({type:H.callbackRejected,message:en.encode({scope:t.scope,parents:t.parents,error:this.values.toValue(e)})})):this.output.push(Ct.encode({type:H.methodRejected,message:Jr.encode({scope:t.scope,error:this.values.toValue(e)})}))}createClient(t){return this.proxy(t)}createTarget(t,e){if(this.targets.has(t))throw new Wn(`Cannot reuse RPC target name "${t}"`);this.targets.set(t,e)}async handleInvokeMethod(t){if(this.invocations.has(t.scope))throw new Vr;let e=new Map,n=new Map,o={scope:t.scope,result:wt(),callbacks:e,children:n,parents:[],abortControllers:[],abortSignals:[]};this.invocations.set(t.scope,o);let i=this.lookupInvocationTarget(t.path),s=await i.fn.apply(i.context,t.args.map(c=>this.values.fromValue(c,this.output,o)));this.output.push(Ct.encode({type:H.methodResolved,message:ur.encode({scope:t.scope,value:this.values.toValue(s)})}))}async handleAbortMethod(t,e){e.abortControllers.forEach(n=>{n.abort()})}async handleInvokeGeneratorMethod(t){if(this.invocations.has(t.scope))throw new Vr;let e=new Map,n=new Map,o={scope:t.scope,result:wt(),callbacks:e,children:n,parents:[],abortControllers:[],abortSignals:[]};this.invocations.set(t.scope,o);let i=this.lookupInvocationTarget(t.path),s=i.fn.apply(i.context,t.args.map(a=>this.values.fromValue(a,this.output,o)));if(typeof s.next!="function")throw new Yn(`${t.path} did not return an async generator`);let c={next:async()=>{let a=await s.next();return a.done===!0&&this.invocations.delete(t.scope),a},throw:async a=>{try{let l=await s.throw(a);return l.done===!0&&this.invocations.delete(t.scope),l}catch(l){throw this.invocations.delete(t.scope),l}},return:async a=>{let l=await s.return(a);return l.done===!0&&this.invocations.delete(t.scope),l},[Symbol.asyncIterator]:()=>c};this.output.push(Ct.encode({type:H.methodResolved,message:ur.encode({scope:t.scope,value:this.values.toValue(c,null,o)})}))}lookupInvocationTarget(t){let e=t.split("."),n=this.targets.get(e[0]),o=n;for(let i=1;i<e.length;i++)o=n,n=n?.[e[i]];if(n==null)throw o!=null&&t.endsWith(".then")?new Zn(`"${t.substring(0,t.length-5)}" was not a function`):new jn(`Could not find "${t}" on target`);if(typeof n!="function")throw new Hr("Invocation target was not a function");return{context:o,fn:n}}async handleMethodResolved(t,e){let n;t.value!=null&&(n=this.values.fromValue(t.value,this.output,e)),e.result.resolve(n)}async handleMethodRejected(t,e){let n;t.error!=null&&(n=this.values.fromValue(t.error,this.output,e)),e.result.reject(n)}async handleInvokeCallback(t,e){let n=e.callbacks.get(t.callback);if(n==null)throw new Qn;let o=await n.fn.apply(n.context,t.args.map(i=>this.values.fromValue(i,this.output,e)));this.output.push(Ct.encode({type:H.callbackResolved,message:tn.encode({scope:t.scope,parents:t.parents,value:this.values.toValue(o)})}))}async handleAbortCallback(t,e){e.abortControllers.forEach(n=>{n.abort()})}async handleCallbackResolved(t,e){let n;t.value!=null&&(n=this.values.fromValue(t.value,this.output,e)),e.children.get(t.scope)?.result.resolve(n),e.children.delete(t.scope)}async handleCallbackRejected(t,e){let n;t.error!=null&&(n=this.values.fromValue(t.error,this.output,e)),e.children.get(t.scope)?.result.reject(n),e.children.delete(t.scope)}proxy(t){let e=()=>{},n=this;return new Proxy(e,{get(o,i,s){return n.proxy(`${t==null?"":`${t}.`}${i.toString()}`)},apply(o,i,s){let c,a;function l(){return a==null&&(a=new Promise((f,h)=>{let x=nr(),w={scope:x,result:wt(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(x,w),n.output.push(Ct.encode({type:H.invokeMethod,message:Oe.encode({scope:x,path:t,args:s.map(d=>n.values.toValue(d,null,w))})}));let g=On(w.abortSignals);g.addEventListener("abort",()=>{n.output.push(Ct.encode({type:H.abortMethodInvocation,message:Qr.encode({scope:x})}))}),w.result.promise.then(d=>{f(d)},d=>{h(d)}).finally(()=>{n.invocations.delete(x),g.clear()})})),a}function u(){if(c==null){let f=nr(),h={scope:f,result:wt(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(f,h),n.output.push(Ct.encode({type:H.invokeGeneratorMethod,message:Oe.encode({scope:f,path:t,args:s.map(w=>n.values.toValue(w,null,h))})}));let x;c={async next(){if(x!=null)throw x;let g=await(await h.result.promise).next();return g.done===!0&&n.invocations.delete(f),g},async throw(w){if(x!=null)throw x;try{let d=await(await h.result.promise).throw(w);return d.done===!0&&n.invocations.delete(f),d}catch(g){throw n.invocations.delete(f),x=w,g}},async return(w){if(x!=null)throw x;let d=await(await h.result.promise).return(w);return d.done===!0&&n.invocations.delete(f),d},[Symbol.asyncIterator]:()=>c}}return c}return new Proxy(e,{get(f,h,x){if(h==="then")return l().then.bind(a);if(h==="catch")return l().catch.bind(a);if(h==="finally")return l().finally.bind(a);if(h===Symbol.asyncIterator)return()=>u();if(h==="next")return u().next.bind(c);if(h==="return")return u().return.bind(c);if(h==="throw")return u().throw.bind(c);if(h===Symbol.toStringTag)return"[object Object]";if(h==="constructor")return()=>{};throw new Hr(`Property ${h.toString()} was not used as a promise or async generator`)}})}})}};function Iu(r){return new $i(r)}var Cu={type:4096,canEncode:r=>r.code!=null&&r.version!=null&&r.multihash!=null&&r["/"]!=null,encode:r=>r.bytes,decode:r=>st.decode(r)};var un=class extends Event{type;detail;constructor(t,e){super(t),this.type=t,this.detail=e}};var Bu={type:4099,canEncode:r=>r instanceof un,encode:(r,t,e,n)=>W({type:r.type,detail:t.toValue(r.detail,e,n)}),decode:(r,t,e,n)=>{let{type:o,detail:i}=Y(r);return new un(o,t.fromValue(i,e,n))}};function X(r,t="utf8"){let e=eo[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var bo=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}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(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let i=0,s=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let h=Number.parseInt(f,t);if(!Number.isNaN(h))return h});if(u===void 0)break;if(i*=t,i+=u,i>l||(s+=1,e!==void 0&&s>e))return}if(s!==0)return!n&&a&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return e[o]=s[0],e[o+1]=s[1],e[o+2]=s[2],e[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];e[o]=i>>8,e[o+1]=i&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[c]=t(i.subarray(0,s));return e.set(i.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ku=45,fp=15,xr=new bo;function Gi(r){if(!(r.length>fp))return xr.new(r).parseWith(()=>xr.readIPv4Addr())}function ji(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ku))return xr.new(r).parseWith(()=>xr.readIPv6Addr())}function wo(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>ku)return;let e=xr.new(r).parseWith(()=>xr.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}var Rw=parseInt("0xFFFF",16),Mw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Lu(r){return!!Gi(r)}function Pu(r){return!!ji(r)}function Eo(r){return!!wo(r)}var Du=Lu,gp=Pu,Zi=function(r){let t=0;if(r=r.toString().trim(),Du(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(gp(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=Du(e[n]),s;i&&(s=Zi(e[n]),e[n]=X(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,X(s.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},Nu=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var br={},Wi={},xp=[[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"]];xp.forEach(r=>{let t=bp(...r);Wi[t.code]=t,br[t.name]=t});function bp(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function Q(r){if(typeof r=="number"){if(Wi[r]!=null)return Wi[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(br[r]!=null)return br[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var w1=Q("ip4"),E1=Q("ip6"),v1=Q("ipcidr");function Ji(r,t){switch(Q(r).code){case 4:case 41:return Ep(t);case 42:return Qi(t);case 43:return X(t,"base10");case 6:case 273:case 33:case 132:return Ou(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Qi(t);case 421:return _p(t);case 444:return Mu(t);case 445:return Mu(t);case 466:return Ap(t);case 481:return globalThis.encodeURIComponent(Qi(t));default:return X(t,"base16")}}function ts(r,t){switch(Q(r).code){case 4:return Ru(t);case 41:return Ru(t);case 42:return Xi(t);case 43:return $t(t,"base10");case 6:case 273:case 33:case 132:return es(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Xi(t);case 421:return vp(t);case 444:return Ip(t);case 445:return Cp(t);case 466:return Sp(t);case 481:return Xi(globalThis.decodeURIComponent(t));default:return $t(t,"base16")}}var Yi=Object.values(Zr).map(r=>r.decoder),wp=function(){let r=Yi[0].or(Yi[1]);return Yi.slice(2).forEach(t=>r=r.or(t)),r}();function Ru(r){if(!Eo(r))throw new Error("invalid ip address");return Zi(r)}function Ep(r){let t=Nu(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Eo(t))throw new Error("invalid ip address");return t}function es(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Ou(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Xi(r){let t=$t(r),e=Uint8Array.from(Ae(t.length));return Dt([e,t],e.length+t.length)}function Qi(r){let t=ue(r);if(r=r.slice(ft(t)),r.length!==t)throw new Error("inconsistent lengths");return X(r)}function vp(r){let t;r[0]==="Q"||r[0]==="1"?t=le(tt.decode(`z${r}`)).bytes:t=st.parse(r).multihash.bytes;let e=Uint8Array.from(Ae(t.length));return Dt([e,t],e.length+t.length)}function Sp(r){let t=wp.decode(r),e=Uint8Array.from(Ae(t.length));return Dt([e,t],e.length+t.length)}function Ap(r){let t=ue(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+X(e,"base64url")}function _p(r){let t=ue(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return X(e,"base58btc")}function Ip(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Wt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=es(n);return Dt([e,o],e.length+o.length)}function Cp(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Wt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=es(n);return Dt([e,o],e.length+o.length)}function Mu(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=X(t,"base32"),o=Ou(e);return`${n}:${o}`}function Fu(r){r=rs(r);let t=[],e=[],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=Q(s);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(i++,i>=o.length)throw new vo("invalid address: "+r);if(c.path===!0){n=rs(o.slice(i).join("/")),t.push([c.code,ts(c.code,n)]),e.push([c.code,n]);break}let a=ts(c.code,o[i]);t.push([c.code,a]),e.push([c.code,Ji(c.code,a)])}return{string:Ku(e),bytes:So(t),tuples:t,stringTuples:e,path:n}}function ns(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=ue(r,o),s=ft(i),c=Q(i),a=Bp(c,r.slice(o+s));if(a===0){t.push([i]),e.push([i]),o+=s;continue}let l=r.slice(o+s,o+s+a);if(o+=a+s,o>r.length)throw new vo("Invalid address Uint8Array: "+X(r,"base16"));t.push([i,l]);let u=Ji(i,l);if(e.push([i,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Ku(e),tuples:t,stringTuples:e,path:n}}function Ku(r){let t=[];return r.map(e=>{let n=Q(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),rs(t.join("/"))}function So(r){return Dt(r.map(t=>{let e=Q(t[0]),n=Uint8Array.from(Ae(e.code));return t.length>1&&t[1]!=null&&(n=Dt([n,t[1]])),n}))}function Bp(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=ue(t instanceof Uint8Array?t:Uint8Array.from(t));return e+ft(e)}}function rs(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var vo=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var kp=Symbol.for("nodejs.util.inspect.custom"),is=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Tp=[Q("dns").code,Q("dns4").code,Q("dns6").code,Q("dnsaddr").code],os=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Ao=class r{bytes;#e;#t;#r;#n;[is]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=ns(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Fu(t)}else if(_o(t))e=ns(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",s=Q("tcp"),c=Q("udp"),a=Q("ip4"),l=Q("ip6"),u=Q("dns6"),f=Q("ip6zone");for(let[x,w]of this.stringTuples())x===f.code&&(i=`%${w??""}`),Tp.includes(x)&&(e=s.name==="tcp"?"tcp":"udp",o=443,n=`${w??""}${i}`,t=x===u.code?6:4),(x===s.code||x===c.code)&&(e=Q(x).name==="tcp"?"tcp":"udp",o=parseInt(w??"")),(x===a.code||x===l.code)&&(e=Q(x).name==="tcp"?"tcp":"udp",n=`${w??""}${i}`,t=x===l.code?6:4);if(t==null||e==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:t,host:n,transport:e,port:o}}protos(){return this.#t.map(([t])=>Object.assign({},Q(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>Q(t).name)}tuples(){return this.#t.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(So(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===br.p2p.code&&t.push([n,o]),n===br["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?X(tt.decode(`z${n}`),"base58btc"):X(st.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Nt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=Vu.get(e.name);if(n==null)throw new os(`no available resolver for ${e.name}`);return(await n(this,t)).map(i=>Ke(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[kp](){return`Multiaddr(${this.#e})`}};var Vu=new Map;function _o(r){return!!r?.[is]}function Ke(r){return new Ao(r)}var Hu={type:4097,canEncode:r=>_o(r),encode:r=>r.bytes,decode:r=>Ke(r)};var Up=parseInt("11111",2),ss=parseInt("10000000",2),Lp=parseInt("01111111",2),zu={0:ln,1:ln,2:Pp,3:Rp,4:Mp,5:Np,6:Dp,16:ln,22:ln,48:ln};function cs(r,t={offset:0}){let e=r[t.offset]&Up;if(t.offset++,zu[e]!=null)return zu[e](r,t);throw new Error("No decoder for tag "+e)}function fn(r,t){let e=0;if((r[t.offset]&ss)===ss){let n=r[t.offset]&Lp,o="0x";t.offset++;for(let i=0;i<n;i++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function ln(r,t){fn(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=cs(r,t);if(n===null)break;e.push(n)}return e}function Pp(r,t){let e=fn(r,t),n=t.offset,o=t.offset+e,i=[];for(let s=n;s<o;s++)s===n&&r[s]===0||i.push(r[s]);return t.offset+=e,Uint8Array.from(i)}function Dp(r,t){let e=fn(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let c=`${i}.${s}`,a=[];for(;t.offset<n;){let l=r[t.offset];if(t.offset++,a.push(l&127),l<128){a.reverse();let u=0;for(let f=0;f<a.length;f++)u+=a[f]<<f*7;c+=`.${u}`,a=[]}}return c}function Np(r,t){return t.offset++,null}function Rp(r,t){let e=fn(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Mp(r,t){let e=fn(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Op(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new mt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function as(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Op(r.byteLength);return new mt(Uint8Array.from([t.byteLength|ss]),t)}function qu(r){let t=new mt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new mt(Uint8Array.from([2]),as(t),t)}function $u(r){let t=Uint8Array.from([0]),e=new mt(t,r);return new mt(Uint8Array.from([3]),as(e),e)}function Io(r,t=48){let e=new mt;for(let n of r)e.append(n);return new mt(Uint8Array.from([t]),as(e),e)}async function Gu(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var Fp=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Kp=Uint8Array.from([6,5,43,129,4,0,34]),Vp=Uint8Array.from([6,5,43,129,4,0,35]),Hp={ext:!0,kty:"EC",crv:"P-256"},zp={ext:!0,kty:"EC",crv:"P-384"},qp={ext:!0,kty:"EC",crv:"P-521"},us=32,ls=48,fs=66;function ju(r){let t=cs(r);return Zu(t)}function Zu(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===us*2+1)return n=X(t.subarray(e,e+us),"base64url"),o=X(t.subarray(e+us),"base64url"),new wr({...Hp,key_ops:["verify"],x:n,y:o});if(t.byteLength===ls*2+1)return n=X(t.subarray(e,e+ls),"base64url"),o=X(t.subarray(e+ls),"base64url"),new wr({...zp,key_ops:["verify"],x:n,y:o});if(t.byteLength===fs*2+1)return n=X(t.subarray(e,e+fs),"base64url"),o=X(t.subarray(e+fs),"base64url"),new wr({...qp,key_ops:["verify"],x:n,y:o});throw new zt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Wu(r){return Io([qu(Uint8Array.from([1])),Io([$p(r.crv)],160),Io([$u(new mt(Uint8Array.from([4]),$t(r.x??"","base64url"),$t(r.y??"","base64url")))],161)]).subarray()}function $p(r){if(r==="P-256")return Fp;if(r==="P-384")return Kp;if(r==="P-521")return Vp;throw new zt(`Invalid curve ${r}`)}var wr=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Wu(this.jwk)),this._raw}toMultihash(){return Jt.digest(Er(this))}toCID(){return st.createV1(114,this.toMultihash())}toString(){return tt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Nt(this.raw,t.raw)}async verify(t,e){return Gu(this.jwk,e,t)}};var Ve=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Gp(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Co(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function He(r,...t){if(!Gp(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Yu(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Co(r.outputLen),Co(r.blockLen)}function Sr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Xu(r,t){He(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function he(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function Bo(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function re(r,t){return r<<32-t|r>>>t}function Qu(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function dn(r){return typeof r=="string"&&(r=Qu(r)),He(r),r}function ds(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];He(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let i=r[n];e.set(i,o),o+=i.length}return e}var vr=class{};function hs(r){let t=n=>r().update(dn(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ko(r=32){if(Ve&&typeof Ve.getRandomValues=="function")return Ve.getRandomValues(new Uint8Array(r));if(Ve&&typeof Ve.randomBytes=="function")return Uint8Array.from(Ve.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function jp(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(e>>o&i),c=Number(e&i),a=n?4:0,l=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+l,c,n)}function Ju(r,t,e){return r&t^~r&e}function tl(r,t,e){return r&t^r&e^t&e}var hn=class extends vr{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Bo(this.buffer)}update(t){Sr(this),t=dn(t),He(t);let{view:e,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=Bo(t);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Sr(this),Xu(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;e[s++]=128,he(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)e[f]=0;jp(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=Bo(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)c.setUint32(4*f,u[f],i)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=c,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},pe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var yt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var To=BigInt(4294967295),el=BigInt(32);function Zp(r,t=!1){return t?{h:Number(r&To),l:Number(r>>el&To)}:{h:Number(r>>el&To)|0,l:Number(r&To)|0}}function rl(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let i=0;i<e;i++){let{h:s,l:c}=Zp(r[i],t);[n[i],o[i]]=[s,c]}return[n,o]}var ps=(r,t,e)=>r>>>e,ms=(r,t,e)=>r<<32-e|t>>>e,ze=(r,t,e)=>r>>>e|t<<32-e,qe=(r,t,e)=>r<<32-e|t>>>e,pn=(r,t,e)=>r<<64-e|t>>>e-32,mn=(r,t,e)=>r>>>e-32|t<<64-e;function ie(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var nl=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),ol=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,il=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),sl=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,cl=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),al=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var Yp=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ke=new Uint32Array(64),gs=class extends hn{constructor(t=32){super(64,t,8,!1),this.A=pe[0]|0,this.B=pe[1]|0,this.C=pe[2]|0,this.D=pe[3]|0,this.E=pe[4]|0,this.F=pe[5]|0,this.G=pe[6]|0,this.H=pe[7]|0}get(){let{A:t,B:e,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[t,e,n,o,i,s,c,a]}set(t,e,n,o,i,s,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,e){for(let f=0;f<16;f++,e+=4)ke[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let h=ke[f-15],x=ke[f-2],w=re(h,7)^re(h,18)^h>>>3,g=re(x,17)^re(x,19)^x>>>10;ke[f]=g+ke[f-7]+w+ke[f-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:l,H:u}=this;for(let f=0;f<64;f++){let h=re(c,6)^re(c,11)^re(c,25),x=u+h+Ju(c,a,l)+Yp[f]+ke[f]|0,g=(re(n,2)^re(n,13)^re(n,22))+tl(n,o,i)|0;u=l,l=a,a=c,c=s+x|0,s=i,i=o,o=n,n=x+g|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,l,u)}roundClean(){he(ke)}destroy(){this.set(0,0,0,0,0,0,0,0),he(this.buffer)}};var ul=rl(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Xp=ul[0],Qp=ul[1],Te=new Uint32Array(80),Ue=new Uint32Array(80),ys=class extends hn{constructor(t=64){super(128,t,16,!1),this.Ah=yt[0]|0,this.Al=yt[1]|0,this.Bh=yt[2]|0,this.Bl=yt[3]|0,this.Ch=yt[4]|0,this.Cl=yt[5]|0,this.Dh=yt[6]|0,this.Dl=yt[7]|0,this.Eh=yt[8]|0,this.El=yt[9]|0,this.Fh=yt[10]|0,this.Fl=yt[11]|0,this.Gh=yt[12]|0,this.Gl=yt[13]|0,this.Hh=yt[14]|0,this.Hl=yt[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:i,Cl:s,Dh:c,Dl:a,Eh:l,El:u,Fh:f,Fl:h,Gh:x,Gl:w,Hh:g,Hl:d}=this;return[t,e,n,o,i,s,c,a,l,u,f,h,x,w,g,d]}set(t,e,n,o,i,s,c,a,l,u,f,h,x,w,g,d){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=h|0,this.Gh=x|0,this.Gl=w|0,this.Hh=g|0,this.Hl=d|0}process(t,e){for(let m=0;m<16;m++,e+=4)Te[m]=t.getUint32(e),Ue[m]=t.getUint32(e+=4);for(let m=16;m<80;m++){let I=Te[m-15]|0,N=Ue[m-15]|0,P=ze(I,N,1)^ze(I,N,8)^ps(I,N,7),k=qe(I,N,1)^qe(I,N,8)^ms(I,N,7),T=Te[m-2]|0,L=Ue[m-2]|0,J=ze(T,L,19)^pn(T,L,61)^ps(T,L,6),$=qe(T,L,19)^mn(T,L,61)^ms(T,L,6),F=il(k,$,Ue[m-7],Ue[m-16]),at=sl(F,P,J,Te[m-7],Te[m-16]);Te[m]=at|0,Ue[m]=F|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:h,Fh:x,Fl:w,Gh:g,Gl:d,Hh:b,Hl:A}=this;for(let m=0;m<80;m++){let I=ze(f,h,14)^ze(f,h,18)^pn(f,h,41),N=qe(f,h,14)^qe(f,h,18)^mn(f,h,41),P=f&x^~f&g,k=h&w^~h&d,T=cl(A,N,k,Qp[m],Ue[m]),L=al(T,b,I,P,Xp[m],Te[m]),J=T|0,$=ze(n,o,28)^pn(n,o,34)^pn(n,o,39),F=qe(n,o,28)^mn(n,o,34)^mn(n,o,39),at=n&i^n&c^i&c,_=o&s^o&a^s&a;b=g|0,A=d|0,g=x|0,d=w|0,x=f|0,w=h|0,{h:f,l:h}=ie(l|0,u|0,L|0,J|0),l=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let U=nl(J,F,_);n=ol(U,L,$,at),o=U|0}({h:n,l:o}=ie(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=ie(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=ie(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=ie(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=ie(this.Eh|0,this.El|0,f|0,h|0),{h:x,l:w}=ie(this.Fh|0,this.Fl|0,x|0,w|0),{h:g,l:d}=ie(this.Gh|0,this.Gl|0,g|0,d|0),{h:b,l:A}=ie(this.Hh|0,this.Hl|0,b|0,A|0),this.set(n,o,i,s,c,a,l,u,f,h,x,w,g,d,b,A)}roundClean(){he(Te,Ue)}destroy(){he(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ll=hs(()=>new gs);var fl=hs(()=>new ys);var Es=BigInt(0),ws=BigInt(1);function $e(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function vs(r){if(!$e(r))throw new Error("Uint8Array expected")}function se(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function gn(r){let t=r.toString(16);return t.length&1?"0"+t:t}function pl(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Es:BigInt("0x"+r)}var ml=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Jp=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Le(r){if(vs(r),ml)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=Jp[r[e]];return t}var me={_0:48,_9:57,A:65,F:70,a:97,f:102};function dl(r){if(r>=me._0&&r<=me._9)return r-me._0;if(r>=me.A&&r<=me.F)return r-(me.A-10);if(r>=me.a&&r<=me.f)return r-(me.a-10)}function yn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(ml)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,i=0;o<e;o++,i+=2){let s=dl(r.charCodeAt(i)),c=dl(r.charCodeAt(i+1));if(s===void 0||c===void 0){let a=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function ge(r){return pl(Le(r))}function Ge(r){return vs(r),pl(Le(Uint8Array.from(r).reverse()))}function je(r,t){return yn(r.toString(16).padStart(t*2,"0"))}function Ar(r,t){return je(r,t).reverse()}function nt(r,t,e){let n;if(typeof t=="string")try{n=yn(t)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if($e(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function Pe(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];vs(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let i=r[n];e.set(i,o),o+=i.length}return e}var xs=r=>typeof r=="bigint"&&Es<=r;function Uo(r,t,e){return xs(r)&&xs(t)&&xs(e)&&t<=r&&r<e}function Vt(r,t,e,n){if(!Uo(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function gl(r){let t;for(t=0;r>Es;r>>=ws,t+=1);return t}var Ze=r=>(ws<<BigInt(r))-ws,bs=r=>new Uint8Array(r),hl=r=>Uint8Array.from(r);function yl(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=bs(r),o=bs(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},c=(...f)=>e(o,n,...f),a=(f=bs(0))=>{o=c(hl([0]),f),n=c(),f.length!==0&&(o=c(hl([1]),f),n=c())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,h=[];for(;f<t;){n=c();let x=n.slice();h.push(x),f+=n.length}return Pe(...h)};return(f,h)=>{s(),a(f);let x;for(;!(x=h(l()));)a();return s(),x}}var t0={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||$e(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ye(r,t,e={}){let n=(o,i,s)=>{let c=t0[i];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(s&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+a)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}function _r(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let i=r(e,...n);return t.set(e,i),i}}var Bt=BigInt(0),ut=BigInt(1),We=BigInt(2),e0=BigInt(3),Ss=BigInt(4),xl=BigInt(5),bl=BigInt(8),r0=BigInt(9),n0=BigInt(16);function Z(r,t){let e=r%t;return e>=Bt?e:t+e}function rt(r,t,e){let n=r;for(;t-- >Bt;)n*=n,n%=e;return n}function Lo(r,t){if(r===Bt)throw new Error("invert: expected non-zero number");if(t<=Bt)throw new Error("invert: expected positive modulus, got "+t);let e=Z(r,t),n=t,o=Bt,i=ut,s=ut,c=Bt;for(;e!==Bt;){let l=n/e,u=n%e,f=o-s*l,h=i-c*l;n=e,e=u,o=s,i=c,s=f,c=h}if(n!==ut)throw new Error("invert: does not exist");return Z(o,t)}function o0(r){let t=r-ut,e=0;for(;t%We===Bt;)t/=We,e++;let n=We,o=xe(r);for(;n<r&&wl(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1){let s=(r+ut)/Ss;return function(a,l){let u=a.pow(l,s);if(!a.eql(a.sqr(u),l))throw new Error("Cannot find square root");return u}}let i=(t+ut)/We;return function(c,a){if(!wl(c,a))throw new Error("Cannot find square root");let l=e,u=c.pow(c.mul(c.ONE,n),t),f=c.pow(a,i),h=c.pow(a,t);for(;!c.eql(h,c.ONE);){if(c.eql(h,c.ZERO))return c.ZERO;let x=1;for(let g=c.sqr(h);x<l&&!c.eql(g,c.ONE);x++)g=c.sqr(g);let w=c.pow(u,ut<<BigInt(l-x-1));u=c.sqr(w),f=c.mul(f,w),h=c.mul(h,u),l=x}return f}}function i0(r){return r%Ss===e0?function(e,n){let o=(r+ut)/Ss,i=e.pow(n,o);if(!e.eql(e.sqr(i),n))throw new Error("Cannot find square root");return i}:r%bl===xl?function(e,n){let o=e.mul(n,We),i=(r-xl)/bl,s=e.pow(o,i),c=e.mul(n,s),a=e.mul(e.mul(c,We),s),l=e.mul(c,e.sub(a,e.ONE));if(!e.eql(e.sqr(l),n))throw new Error("Cannot find square root");return l}:(r%n0,o0(r))}var El=(r,t)=>(Z(r,t)&ut)===ut,s0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function As(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=s0.reduce((n,o)=>(n[o]="function",n),t);return ye(r,e)}function c0(r,t,e){if(e<Bt)throw new Error("invalid exponent, negatives unsupported");if(e===Bt)return r.ONE;if(e===ut)return t;let n=r.ONE,o=t;for(;e>Bt;)e&ut&&(n=r.mul(n,o)),o=r.sqr(o),e>>=ut;return n}function Ir(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((s,c,a)=>r.is0(c)?s:(n[a]=s,r.mul(s,c)),r.ONE),i=r.inv(o);return t.reduceRight((s,c,a)=>r.is0(c)?s:(n[a]=r.mul(s,n[a]),r.mul(s,c)),i),n}function a0(r,t){let e=(r.ORDER-ut)/We,n=r.pow(t,e),o=r.eql(n,r.ONE),i=r.eql(n,r.ZERO),s=r.eql(n,r.neg(r.ONE));if(!o&&!i&&!s)throw new Error("Cannot find square root: probably non-prime P");return o?1:i?0:-1}function wl(r,t){let e=a0(r,t);return e===0||e===1}function _s(r,t){t!==void 0&&Co(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function xe(r,t,e=!1,n={}){if(r<=Bt)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:i}=_s(r,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:i,MASK:Ze(o),ZERO:Bt,ONE:ut,create:a=>Z(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return Bt<=a&&a<r},is0:a=>a===Bt,isOdd:a=>(a&ut)===ut,neg:a=>Z(-a,r),eql:(a,l)=>a===l,sqr:a=>Z(a*a,r),add:(a,l)=>Z(a+l,r),sub:(a,l)=>Z(a-l,r),mul:(a,l)=>Z(a*l,r),pow:(a,l)=>c0(c,a,l),div:(a,l)=>Z(a*Lo(l,r),r),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>Lo(a,r),sqrt:n.sqrt||(a=>(s||(s=i0(r)),s(c,a))),toBytes:a=>e?Ar(a,i):je(a,i),fromBytes:a=>{if(a.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+a.length);return e?Ge(a):ge(a)},invertBatch:a=>Ir(c,a),cmov:(a,l,u)=>u?l:a});return Object.freeze(c)}function vl(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Is(r){let t=vl(r);return t+Math.ceil(t/2)}function Sl(r,t,e=!1){let n=r.length,o=vl(t),i=Is(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=e?Ge(r):ge(r),c=Z(s,t-ut)+ut;return e?Ar(c,o):je(c,o)}var Al=BigInt(0),Us=BigInt(1);function Cs(r,t){let e=t.negate();return r?e:t}function Il(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Bs(r,t){Il(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,i=Ze(r),s=BigInt(r);return{windows:e,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function _l(r,t,e){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=e,c=Number(r&o),a=r>>s;c>n&&(c-=i,a+=Us);let l=t*n,u=l+Math.abs(c)-1,f=c===0,h=c<0,x=t%2!==0;return{nextN:a,offset:u,isZero:f,isNeg:h,isNegF:x,offsetF:l}}function u0(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function l0(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var ks=new WeakMap,Cl=new WeakMap;function Ts(r){return Cl.get(r)||1}function Po(r,t){return{constTimeNegate:Cs,hasPrecomputes(e){return Ts(e)!==1},unsafeLadder(e,n,o=r.ZERO){let i=e;for(;n>Al;)n&Us&&(o=o.add(i)),i=i.double(),n>>=Us;return o},precomputeWindow(e,n){let{windows:o,windowSize:i}=Bs(n,t),s=[],c=e,a=c;for(let l=0;l<o;l++){a=c,s.push(a);for(let u=1;u<i;u++)a=a.add(c),s.push(a);c=a.double()}return s},wNAF(e,n,o){let i=r.ZERO,s=r.BASE,c=Bs(e,t);for(let a=0;a<c.windows;a++){let{nextN:l,offset:u,isZero:f,isNeg:h,isNegF:x,offsetF:w}=_l(o,a,c);o=l,f?s=s.add(Cs(x,n[w])):i=i.add(Cs(h,n[u]))}return{p:i,f:s}},wNAFUnsafe(e,n,o,i=r.ZERO){let s=Bs(e,t);for(let c=0;c<s.windows&&o!==Al;c++){let{nextN:a,offset:l,isZero:u,isNeg:f}=_l(o,c,s);if(o=a,!u){let h=n[l];i=i.add(f?h.negate():h)}}return i},getPrecomputes(e,n,o){let i=ks.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&ks.set(n,o(i))),i},wNAFCached(e,n,o){let i=Ts(e);return this.wNAF(i,this.getPrecomputes(i,e,o),n)},wNAFCachedUnsafe(e,n,o,i){let s=Ts(e);return s===1?this.unsafeLadder(e,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,o),n,i)},setWindowSize(e,n){Il(n,t),Cl.set(e,n),ks.delete(e)}}}function Do(r,t,e,n){if(u0(e,r),l0(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,i=gl(BigInt(e.length)),s=i>12?i-3:i>4?i-2:i?2:1,c=Ze(s),a=new Array(Number(c)+1).fill(o),l=Math.floor((t.BITS-1)/s)*s,u=o;for(let f=l;f>=0;f-=s){a.fill(o);for(let x=0;x<n.length;x++){let w=n[x],g=Number(w>>BigInt(f)&c);a[g]=a[g].add(e[x])}let h=o;for(let x=a.length-1,w=o;x>0;x--)w=w.add(a[x]),h=h.add(w);if(u=u.add(h),f!==0)for(let x=0;x<s;x++)u=u.double()}return u}function xn(r){return As(r.Fp),ye(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({..._s(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var ce=BigInt(0),kt=BigInt(1),Bl=BigInt(2),f0=BigInt(8),d0={zip215:!0};function h0(r){let t=xn(r);return ye(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function kl(r){let t=h0(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,l=Bl<<BigInt(c*8)-kt,u=e.create,f=xe(t.n,t.nBitLength),h=t.uvRatio||((E,y)=>{try{return{isValid:!0,value:e.sqrt(E*e.inv(y))}}catch{return{isValid:!1,value:ce}}}),x=t.adjustScalarBytes||(E=>E),w=t.domain||((E,y,S)=>{if(se("phflag",S),y.length||S)throw new Error("Contexts/pre-hash are not supported");return E});function g(E,y,S=!1){let B=S?kt:ce;Vt("coordinate "+E,y,B,l)}function d(E){if(!(E instanceof m))throw new Error("ExtendedPoint expected")}let b=_r((E,y)=>{let{ex:S,ey:B,ez:R}=E,O=E.is0();y==null&&(y=O?f0:e.inv(R));let K=u(S*y),V=u(B*y),q=u(R*y);if(O)return{x:ce,y:kt};if(q!==kt)throw new Error("invZ was invalid");return{x:K,y:V}}),A=_r(E=>{let{a:y,d:S}=t;if(E.is0())throw new Error("bad point: ZERO");let{ex:B,ey:R,ez:O,et:K}=E,V=u(B*B),q=u(R*R),j=u(O*O),ct=u(j*j),it=u(V*y),pt=u(j*u(it+q)),Tt=u(ct+u(S*u(V*q)));if(pt!==Tt)throw new Error("bad point: equation left != right (1)");let lt=u(B*R),xt=u(O*K);if(lt!==xt)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(y,S,B,R){g("x",y),g("y",S),g("z",B,!0),g("t",R),this.ex=y,this.ey=S,this.ez=B,this.et=R,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(y){if(y instanceof m)throw new Error("extended point not allowed");let{x:S,y:B}=y||{};return g("x",S),g("y",B),new m(S,B,kt,u(S*B))}static normalizeZ(y){let S=Ir(e,y.map(B=>B.ez));return y.map((B,R)=>B.toAffine(S[R])).map(m.fromAffine)}static msm(y,S){return Do(m,f,y,S)}_setWindowSize(y){P.setWindowSize(this,y)}assertValidity(){A(this)}equals(y){d(y);let{ex:S,ey:B,ez:R}=this,{ex:O,ey:K,ez:V}=y,q=u(S*V),j=u(O*R),ct=u(B*V),it=u(K*R);return q===j&&ct===it}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:y}=t,{ex:S,ey:B,ez:R}=this,O=u(S*S),K=u(B*B),V=u(Bl*u(R*R)),q=u(y*O),j=S+B,ct=u(u(j*j)-O-K),it=q+K,pt=it-V,Tt=q-K,lt=u(ct*pt),xt=u(it*Tt),Lt=u(ct*Tt),Zt=u(pt*it);return new m(lt,xt,Zt,Lt)}add(y){d(y);let{a:S,d:B}=t,{ex:R,ey:O,ez:K,et:V}=this,{ex:q,ey:j,ez:ct,et:it}=y,pt=u(R*q),Tt=u(O*j),lt=u(V*B*it),xt=u(K*ct),Lt=u((R+O)*(q+j)-pt-Tt),Zt=xt-lt,kr=xt+lt,zs=u(Tt-S*pt),sf=u(Lt*Zt),cf=u(kr*zs),af=u(Lt*zs),uf=u(Zt*kr);return new m(sf,cf,uf,af)}subtract(y){return this.add(y.negate())}wNAF(y){return P.wNAFCached(this,y,m.normalizeZ)}multiply(y){let S=y;Vt("scalar",S,kt,n);let{p:B,f:R}=this.wNAF(S);return m.normalizeZ([B,R])[0]}multiplyUnsafe(y,S=m.ZERO){let B=y;return Vt("scalar",B,ce,n),B===ce?N:this.is0()||B===kt?this:P.wNAFCachedUnsafe(this,B,m.normalizeZ,S)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return P.unsafeLadder(this,n).is0()}toAffine(y){return b(this,y)}clearCofactor(){let{h:y}=t;return y===kt?this:this.multiplyUnsafe(y)}static fromHex(y,S=!1){let{d:B,a:R}=t,O=e.BYTES;y=nt("pointHex",y,O),se("zip215",S);let K=y.slice(),V=y[O-1];K[O-1]=V&-129;let q=Ge(K),j=S?l:e.ORDER;Vt("pointHex.y",q,ce,j);let ct=u(q*q),it=u(ct-kt),pt=u(B*ct-R),{isValid:Tt,value:lt}=h(it,pt);if(!Tt)throw new Error("Point.fromHex: invalid y coordinate");let xt=(lt&kt)===kt,Lt=(V&128)!==0;if(!S&<===ce&&Lt)throw new Error("Point.fromHex: x=0 and x_0=1");return Lt!==xt&&(lt=u(-lt)),m.fromAffine({x:lt,y:q})}static fromPrivateKey(y){let{scalar:S}=L(y);return I.multiply(S)}toRawBytes(){let{x:y,y:S}=this.toAffine(),B=Ar(S,e.BYTES);return B[B.length-1]|=y&kt?128:0,B}toHex(){return Le(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,kt,u(t.Gx*t.Gy)),m.ZERO=new m(ce,kt,kt,ce);let{BASE:I,ZERO:N}=m,P=Po(m,c*8);function k(E){return Z(E,n)}function T(E){return k(Ge(E))}function L(E){let y=e.BYTES;E=nt("private key",E,y);let S=nt("hashed private key",i(E),2*y),B=x(S.slice(0,y)),R=S.slice(y,2*y),O=T(B);return{head:B,prefix:R,scalar:O}}function J(E){let{head:y,prefix:S,scalar:B}=L(E),R=I.multiply(B),O=R.toRawBytes();return{head:y,prefix:S,scalar:B,point:R,pointBytes:O}}function $(E){return J(E).pointBytes}function F(E=Uint8Array.of(),...y){let S=Pe(...y);return T(i(w(S,nt("context",E),!!o)))}function at(E,y,S={}){E=nt("message",E),o&&(E=o(E));let{prefix:B,scalar:R,pointBytes:O}=J(y),K=F(S.context,B,E),V=I.multiply(K).toRawBytes(),q=F(S.context,V,O,E),j=k(K+q*R);Vt("signature.s",j,ce,n);let ct=Pe(V,Ar(j,e.BYTES));return nt("result",ct,e.BYTES*2)}let _=d0;function U(E,y,S,B=_){let{context:R,zip215:O}=B,K=e.BYTES;E=nt("signature",E,2*K),y=nt("message",y),S=nt("publicKey",S,K),O!==void 0&&se("zip215",O),o&&(y=o(y));let V=Ge(E.slice(K,2*K)),q,j,ct;try{q=m.fromHex(S,O),j=m.fromHex(E.slice(0,K),O),ct=I.multiplyUnsafe(V)}catch{return!1}if(!O&&q.isSmallOrder())return!1;let it=F(R,j.toRawBytes(),q.toRawBytes(),y);return j.add(q.multiplyUnsafe(it)).subtract(ct).clearCofactor().equals(m.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:$,sign:at,verify:U,ExtendedPoint:m,utils:{getExtendedPublicKey:J,randomPrivateKey:()=>s(e.BYTES),precompute(E=8,y=m.BASE){return y._setWindowSize(E),y.multiply(BigInt(3)),y}}}}var Ls=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Tl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),q2=BigInt(0),p0=BigInt(1),Ul=BigInt(2),$2=BigInt(3),m0=BigInt(5),g0=BigInt(8);function y0(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=Ls,c=r*r%i*r%i,a=rt(c,Ul,i)*c%i,l=rt(a,p0,i)*r%i,u=rt(l,m0,i)*l%i,f=rt(u,t,i)*u%i,h=rt(f,e,i)*f%i,x=rt(h,n,i)*h%i,w=rt(x,o,i)*x%i,g=rt(w,o,i)*x%i,d=rt(g,t,i)*u%i;return{pow_p_5_8:rt(d,Ul,i)*r%i,b2:c}}function x0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function b0(r,t){let e=Ls,n=Z(t*t*t,e),o=Z(n*n*t,e),i=y0(r*o).pow_p_5_8,s=Z(r*n*i,e),c=Z(t*s*s,e),a=s,l=Z(s*Tl,e),u=c===r,f=c===Z(-r,e),h=c===Z(-r*Tl,e);return u&&(s=a),(f||h)&&(s=l),El(s,e)&&(s=Z(-s,e)),{isValid:u||f,value:s}}var Ll=xe(Ls,void 0,!0),w0={a:Ll.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ll,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:g0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:fl,randomBytes:ko,adjustScalarBytes:x0,uvRatio:b0},Pl=kl(w0);var No=32;function Dl(r,t,e){return Pl.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var Ro=class{type="Ed25519";raw;constructor(t){this.raw=Ps(t,No)}toMultihash(){return Jt.digest(Er(this))}toCID(){return st.createV1(114,this.toMultihash())}toString(){return tt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Nt(this.raw,t.raw)}verify(t,e){return Dl(this.raw,e,t)}};function Rl(r){return r=Ps(r,No),new Ro(r)}function Ps(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new zt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Ht;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(Ht||(Ht={}));var Ds;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Ds||(Ds={}));(function(r){r.codec=()=>Xr(Ds)})(Ht||(Ht={}));var bn;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Ht.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.Type=Ht.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>_t(e,r.codec()),r.decode=(e,n)=>At(e,r.codec(),n)})(bn||(bn={}));var Ns;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Ht.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.Type=Ht.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>_t(e,r.codec()),r.decode=(e,n)=>At(e,r.codec(),n)})(Ns||(Ns={}));var wn=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var Mo=class extends vr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Yu(t);let n=dn(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),he(i)}update(t){return Sr(this),this.iHash.update(t),this}digestInto(t){Sr(this),He(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Rs=(r,t,e)=>new Mo(r,t).update(e).digest();Rs.create=(r,t)=>new Mo(r,t);function Ml(r){r.lowS!==void 0&&se("lowS",r.lowS),r.prehash!==void 0&&se("prehash",r.prehash)}function S0(r){let t=xn(r);ye(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var Ms=class extends Error{constructor(t=""){super(t)}},be={Err:Ms,_tlv:{encode:(r,t)=>{let{Err:e}=be;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=gn(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?gn(o.length/2|128):"";return gn(r)+i+o+t},decode(r,t){let{Err:e}=be,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+a);if(l.length!==a)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=a,s<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+s);if(c.length!==s)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+s)}}},_int:{encode(r){let{Err:t}=be;if(r<we)throw new t("integer: negative integers are not allowed");let e=gn(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=be;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return ge(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=be,o=nt("signature",r),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:l,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(l)}},hexFromSig(r){let{_tlv:t,_int:e}=be,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),i=n+o;return t.encode(48,i)}},we=BigInt(0),ht=BigInt(1),gE=BigInt(2),Ol=BigInt(3),yE=BigInt(4);function A0(r){let t=S0(r),{Fp:e}=t,n=xe(t.n,t.nBitLength),o=t.toBytes||((g,d,b)=>{let A=d.toAffine();return Pe(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),i=t.fromBytes||(g=>{let d=g.subarray(1),b=e.fromBytes(d.subarray(0,e.BYTES)),A=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:b,y:A}});function s(g){let{a:d,b}=t,A=e.sqr(g),m=e.mul(A,g);return e.add(e.add(m,e.mul(g,d)),b)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function c(g){return Uo(g,ht,t.n)}function a(g){let{allowedPrivateKeyLengths:d,nByteLength:b,wrapPrivateKey:A,n:m}=t;if(d&&typeof g!="bigint"){if($e(g)&&(g=Le(g)),typeof g!="string"||!d.includes(g.length))throw new Error("invalid private key");g=g.padStart(b*2,"0")}let I;try{I=typeof g=="bigint"?g:ge(nt("private key",g,b))}catch{throw new Error("invalid private key, expected hex or "+b+" bytes, got "+typeof g)}return A&&(I=Z(I,m)),Vt("private key",I,ht,m),I}function l(g){if(!(g instanceof h))throw new Error("ProjectivePoint expected")}let u=_r((g,d)=>{let{px:b,py:A,pz:m}=g;if(e.eql(m,e.ONE))return{x:b,y:A};let I=g.is0();d==null&&(d=I?e.ONE:e.inv(m));let N=e.mul(b,d),P=e.mul(A,d),k=e.mul(m,d);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(k,e.ONE))throw new Error("invZ was invalid");return{x:N,y:P}}),f=_r(g=>{if(g.is0()){if(t.allowInfinityPoint&&!e.is0(g.py))return;throw new Error("bad point: ZERO")}let{x:d,y:b}=g.toAffine();if(!e.isValid(d)||!e.isValid(b))throw new Error("bad point: x or y not FE");let A=e.sqr(b),m=s(d);if(!e.eql(A,m))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,b,A){if(d==null||!e.isValid(d))throw new Error("x required");if(b==null||!e.isValid(b)||e.is0(b))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");this.px=d,this.py=b,this.pz=A,Object.freeze(this)}static fromAffine(d){let{x:b,y:A}=d||{};if(!d||!e.isValid(b)||!e.isValid(A))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let m=I=>e.eql(I,e.ZERO);return m(b)&&m(A)?h.ZERO:new h(b,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let b=Ir(e,d.map(A=>A.pz));return d.map((A,m)=>A.toAffine(b[m])).map(h.fromAffine)}static fromHex(d){let b=h.fromAffine(i(nt("pointHex",d)));return b.assertValidity(),b}static fromPrivateKey(d){return h.BASE.multiply(a(d))}static msm(d,b){return Do(h,n,d,b)}_setWindowSize(d){w.setWindowSize(this,d)}assertValidity(){f(this)}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){l(d);let{px:b,py:A,pz:m}=this,{px:I,py:N,pz:P}=d,k=e.eql(e.mul(b,P),e.mul(I,m)),T=e.eql(e.mul(A,P),e.mul(N,m));return k&&T}negate(){return new h(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b}=t,A=e.mul(b,Ol),{px:m,py:I,pz:N}=this,P=e.ZERO,k=e.ZERO,T=e.ZERO,L=e.mul(m,m),J=e.mul(I,I),$=e.mul(N,N),F=e.mul(m,I);return F=e.add(F,F),T=e.mul(m,N),T=e.add(T,T),P=e.mul(d,T),k=e.mul(A,$),k=e.add(P,k),P=e.sub(J,k),k=e.add(J,k),k=e.mul(P,k),P=e.mul(F,P),T=e.mul(A,T),$=e.mul(d,$),F=e.sub(L,$),F=e.mul(d,F),F=e.add(F,T),T=e.add(L,L),L=e.add(T,L),L=e.add(L,$),L=e.mul(L,F),k=e.add(k,L),$=e.mul(I,N),$=e.add($,$),L=e.mul($,F),P=e.sub(P,L),T=e.mul($,J),T=e.add(T,T),T=e.add(T,T),new h(P,k,T)}add(d){l(d);let{px:b,py:A,pz:m}=this,{px:I,py:N,pz:P}=d,k=e.ZERO,T=e.ZERO,L=e.ZERO,J=t.a,$=e.mul(t.b,Ol),F=e.mul(b,I),at=e.mul(A,N),_=e.mul(m,P),U=e.add(b,A),D=e.add(I,N);U=e.mul(U,D),D=e.add(F,at),U=e.sub(U,D),D=e.add(b,m);let E=e.add(I,P);return D=e.mul(D,E),E=e.add(F,_),D=e.sub(D,E),E=e.add(A,m),k=e.add(N,P),E=e.mul(E,k),k=e.add(at,_),E=e.sub(E,k),L=e.mul(J,D),k=e.mul($,_),L=e.add(k,L),k=e.sub(at,L),L=e.add(at,L),T=e.mul(k,L),at=e.add(F,F),at=e.add(at,F),_=e.mul(J,_),D=e.mul($,D),at=e.add(at,_),_=e.sub(F,_),_=e.mul(J,_),D=e.add(D,_),F=e.mul(at,D),T=e.add(T,F),F=e.mul(E,D),k=e.mul(U,k),k=e.sub(k,F),F=e.mul(U,at),L=e.mul(E,L),L=e.add(L,F),new h(k,T,L)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return w.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){let{endo:b,n:A}=t;Vt("scalar",d,we,A);let m=h.ZERO;if(d===we)return m;if(this.is0()||d===ht)return this;if(!b||w.hasPrecomputes(this))return w.wNAFCachedUnsafe(this,d,h.normalizeZ);let{k1neg:I,k1:N,k2neg:P,k2:k}=b.splitScalar(d),T=m,L=m,J=this;for(;N>we||k>we;)N&ht&&(T=T.add(J)),k&ht&&(L=L.add(J)),J=J.double(),N>>=ht,k>>=ht;return I&&(T=T.negate()),P&&(L=L.negate()),L=new h(e.mul(L.px,b.beta),L.py,L.pz),T.add(L)}multiply(d){let{endo:b,n:A}=t;Vt("scalar",d,ht,A);let m,I;if(b){let{k1neg:N,k1:P,k2neg:k,k2:T}=b.splitScalar(d),{p:L,f:J}=this.wNAF(P),{p:$,f:F}=this.wNAF(T);L=w.constTimeNegate(N,L),$=w.constTimeNegate(k,$),$=new h(e.mul($.px,b.beta),$.py,$.pz),m=L.add($),I=J.add(F)}else{let{p:N,f:P}=this.wNAF(d);m=N,I=P}return h.normalizeZ([m,I])[0]}multiplyAndAddUnsafe(d,b,A){let m=h.BASE,I=(P,k)=>k===we||k===ht||!P.equals(m)?P.multiplyUnsafe(k):P.multiply(k),N=I(this,b).add(I(d,A));return N.is0()?void 0:N}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:b}=t;if(d===ht)return!0;if(b)return b(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:b}=t;return d===ht?this:b?b(h,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return se("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return se("isCompressed",d),Le(this.toRawBytes(d))}}h.BASE=new h(t.Gx,t.Gy,e.ONE),h.ZERO=new h(e.ZERO,e.ONE,e.ZERO);let x=t.nBitLength,w=Po(h,t.endo?Math.ceil(x/2):x);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:c}}function _0(r){let t=xn(r);return ye(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Fl(r){let t=_0(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(_){return Z(_,n)}function c(_){return Lo(_,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=A0({...t,toBytes(_,U,D){let E=U.toAffine(),y=e.toBytes(E.x),S=Pe;return se("isCompressed",D),D?S(Uint8Array.from([U.hasEvenY()?2:3]),y):S(Uint8Array.from([4]),y,e.toBytes(E.y))},fromBytes(_){let U=_.length,D=_[0],E=_.subarray(1);if(U===o&&(D===2||D===3)){let y=ge(E);if(!Uo(y,ht,e.ORDER))throw new Error("Point is not on curve");let S=u(y),B;try{B=e.sqrt(S)}catch(K){let V=K instanceof Error?": "+K.message:"";throw new Error("Point is not on curve"+V)}let R=(B&ht)===ht;return(D&1)===1!==R&&(B=e.neg(B)),{x:y,y:B}}else if(U===i&&D===4){let y=e.fromBytes(E.subarray(0,e.BYTES)),S=e.fromBytes(E.subarray(e.BYTES,2*e.BYTES));return{x:y,y:S}}else{let y=o,S=i;throw new Error("invalid Point, expected length of "+y+", or uncompressed "+S+", got "+U)}}}),h=_=>Le(je(_,t.nByteLength));function x(_){let U=n>>ht;return _>U}function w(_){return x(_)?s(-_):_}let g=(_,U,D)=>ge(_.slice(U,D));class d{constructor(U,D,E){Vt("r",U,ht,n),Vt("s",D,ht,n),this.r=U,this.s=D,E!=null&&(this.recovery=E),Object.freeze(this)}static fromCompact(U){let D=t.nByteLength;return U=nt("compactSignature",U,D*2),new d(g(U,0,D),g(U,D,2*D))}static fromDER(U){let{r:D,s:E}=be.toSig(nt("DER",U));return new d(D,E)}assertValidity(){}addRecoveryBit(U){return new d(this.r,this.s,U)}recoverPublicKey(U){let{r:D,s:E,recovery:y}=this,S=P(nt("msgHash",U));if(y==null||![0,1,2,3].includes(y))throw new Error("recovery id invalid");let B=y===2||y===3?D+t.n:D;if(B>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let R=(y&1)===0?"02":"03",O=a.fromHex(R+h(B)),K=c(B),V=s(-S*K),q=s(E*K),j=a.BASE.multiplyAndAddUnsafe(O,V,q);if(!j)throw new Error("point at infinify");return j.assertValidity(),j}hasHighS(){return x(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return yn(this.toDERHex())}toDERHex(){return be.hexFromSig(this)}toCompactRawBytes(){return yn(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let b={isValidPrivateKey(_){try{return l(_),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let _=Is(t.n);return Sl(t.randomBytes(_),t.n)},precompute(_=8,U=a.BASE){return U._setWindowSize(_),U.multiply(BigInt(3)),U}};function A(_,U=!0){return a.fromPrivateKey(_).toRawBytes(U)}function m(_){let U=$e(_),D=typeof _=="string",E=(U||D)&&_.length;return U?E===o||E===i:D?E===2*o||E===2*i:_ instanceof a}function I(_,U,D=!0){if(m(_))throw new Error("first arg must be private key");if(!m(U))throw new Error("second arg must be public key");return a.fromHex(U).multiply(l(_)).toRawBytes(D)}let N=t.bits2int||function(_){if(_.length>8192)throw new Error("input is too large");let U=ge(_),D=_.length*8-t.nBitLength;return D>0?U>>BigInt(D):U},P=t.bits2int_modN||function(_){return s(N(_))},k=Ze(t.nBitLength);function T(_){return Vt("num < 2^"+t.nBitLength,_,we,k),je(_,t.nByteLength)}function L(_,U,D=J){if(["recovered","canonical"].some(it=>it in D))throw new Error("sign() legacy options not supported");let{hash:E,randomBytes:y}=t,{lowS:S,prehash:B,extraEntropy:R}=D;S==null&&(S=!0),_=nt("msgHash",_),Ml(D),B&&(_=nt("prehashed msgHash",E(_)));let O=P(_),K=l(U),V=[T(K),T(O)];if(R!=null&&R!==!1){let it=R===!0?y(e.BYTES):R;V.push(nt("extraEntropy",it))}let q=Pe(...V),j=O;function ct(it){let pt=N(it);if(!f(pt))return;let Tt=c(pt),lt=a.BASE.multiply(pt).toAffine(),xt=s(lt.x);if(xt===we)return;let Lt=s(Tt*s(j+xt*K));if(Lt===we)return;let Zt=(lt.x===xt?0:2)|Number(lt.y&ht),kr=Lt;return S&&x(Lt)&&(kr=w(Lt),Zt^=1),new d(xt,kr,Zt)}return{seed:q,k2sig:ct}}let J={lowS:t.lowS,prehash:!1},$={lowS:t.lowS,prehash:!1};function F(_,U,D=J){let{seed:E,k2sig:y}=L(_,U,D),S=t;return yl(S.hash.outputLen,S.nByteLength,S.hmac)(E,y)}a.BASE._setWindowSize(8);function at(_,U,D,E=$){let y=_;U=nt("msgHash",U),D=nt("publicKey",D);let{lowS:S,prehash:B,format:R}=E;if(Ml(E),"strict"in E)throw new Error("options.strict was renamed to lowS");if(R!==void 0&&R!=="compact"&&R!=="der")throw new Error("format must be compact or der");let O=typeof y=="string"||$e(y),K=!O&&!R&&typeof y=="object"&&y!==null&&typeof y.r=="bigint"&&typeof y.s=="bigint";if(!O&&!K)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let V,q;try{if(K&&(V=new d(y.r,y.s)),O){try{R!=="compact"&&(V=d.fromDER(y))}catch(Zt){if(!(Zt instanceof be.Err))throw Zt}!V&&R!=="der"&&(V=d.fromCompact(y))}q=a.fromHex(D)}catch{return!1}if(!V||S&&V.hasHighS())return!1;B&&(U=t.hash(U));let{r:j,s:ct}=V,it=P(U),pt=c(ct),Tt=s(it*pt),lt=s(j*pt),xt=a.BASE.multiplyAndAddUnsafe(q,Tt,lt)?.toAffine();return xt?s(xt.x)===j:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:I,sign:F,verify:at,ProjectivePoint:a,Signature:d,utils:b}}function I0(r){return{hash:r,hmac:(t,...e)=>Rs(r,t,ds(...e)),randomBytes:ko}}function Kl(r,t){let e=n=>Fl({...r,...I0(n)});return{...e(t),create:e}}var zl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Vl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),C0=BigInt(1),Os=BigInt(2),Hl=(r,t)=>(r+t/Os)/t;function B0(r){let t=zl,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),l=r*r*r%t,u=l*l*r%t,f=rt(u,e,t)*u%t,h=rt(f,e,t)*u%t,x=rt(h,Os,t)*l%t,w=rt(x,o,t)*x%t,g=rt(w,i,t)*w%t,d=rt(g,c,t)*g%t,b=rt(d,a,t)*d%t,A=rt(b,c,t)*g%t,m=rt(A,e,t)*u%t,I=rt(m,s,t)*w%t,N=rt(I,n,t)*l%t,P=rt(N,Os,t);if(!Fs.eql(Fs.sqr(P),r))throw new Error("Cannot find square root");return P}var Fs=xe(zl,void 0,void 0,{sqrt:B0}),Ye=Kl({a:BigInt(0),b:BigInt(7),Fp:Fs,n:Vl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Vl,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-C0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),c=Hl(i*r,t),a=Hl(-n*r,t),l=Z(r-c*e-a*o,t),u=Z(-c*n-a*i,t),f=l>s,h=u>s;if(f&&(l=t-l),h&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:f,k1:l,k2neg:h,k2:u}}}},ll),IE=BigInt(0);var CE=Ye.ProjectivePoint;function ql(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function $l(r,t,e){let n=Gr.digest(e instanceof Uint8Array?e:e.subarray());if(ql(n))return n.then(({digest:o})=>Ye.verify(t,o,r)).catch(o=>{throw new wn(String(o))});try{return Ye.verify(t,n.digest,r)}catch(o){throw new wn(String(o))}}var Oo=class{type="secp256k1";raw;_key;constructor(t){this._key=jl(t),this.raw=Gl(this._key)}toMultihash(){return Jt.digest(Er(this))}toCID(){return st.createV1(114,this.toMultihash())}toString(){return tt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Nt(this.raw,t.raw)}verify(t,e){return $l(this._key,e,t)}};function Zl(r){return new Oo(r)}function Gl(r){return Ye.ProjectivePoint.fromHex(r).toRawBytes(!0)}function jl(r){try{return Ye.ProjectivePoint.fromHex(r),r}catch(t){throw new In(String(t))}}function Wl(r){let{Type:t,Data:e}=bn.decode(r.digest),n=e??new Uint8Array;switch(t){case Ht.Ed25519:return Rl(n);case Ht.secp256k1:return Zl(n);case Ht.ECDSA:return ju(n);default:throw new Ur}}function Er(r){return bn.encode({Type:Ht[r.type],Data:r.raw})}var Yl=Symbol.for("nodejs.util.inspect.custom"),k0=114,En=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[An]=!0;toString(){return this.string==null&&(this.string=tt.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return st.createV1(k0,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Nt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Nt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Yl](){return`PeerId(${this.toString()})`}},Fo=class extends En{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Ko=class extends En{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Vo=class extends En{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},T0=2336,vn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Jt.digest($t(this.url))}[Yl](){return`PeerId(${this.url})`}[An]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return st.createV1(T0,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=X(t)),t.toString()===this.toString())}};var U0=114,Xl=2336;function Ql(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=le(tt.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return L0(st.parse(r));if(t==null)throw new zt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=le(t.decode(r))}return Ho(e)}function Ho(r){if(D0(r))return new Fo({multihash:r});if(P0(r))try{let t=Wl(r);if(t.type==="Ed25519")return new Ko({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Vo({multihash:r,publicKey:t})}catch{let e=X(r.digest);return new vn(new URL(e))}throw new Bn("Supplied PeerID Multihash is invalid")}function L0(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==U0&&r.code!==Xl)throw new Cn("Supplied PeerID CID is invalid");if(r.code===Xl){let t=X(r.multihash.digest);return new vn(new URL(t))}return Ho(r.multihash)}function P0(r){return r.code===Jt.code}function D0(r){return r.code===Gr.code}var Jl={type:4098,canEncode:r=>$s(r),encode:r=>r.toMultihash().bytes,decode:r=>Ho(le(r))};var Ks=[Cu,Hu,Jl,Bu];function zo(r){let t={},e=r.components??r;return Object.entries(e).forEach(([n,o])=>{o?.[Ee]!=null&&Array.isArray(o[Ee])&&(t[n]=o[Ee])}),t}function Cr(r,t){let e={};for(let[n,o]of r.entries())e[n]=t(o);return e}async function qo(r,t){let e=[],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);e.push({id:i,addresses:c.addresses.map(({isCertified:a,multiaddr:l})=>({multiaddr:l,isCertified:a,isConnected:o.includes(l.toString())})),protocols:[...c.protocols],tags:Cr(c.tags,a=>a.value),metadata:Cr(c.metadata,a=>ne.encode(a))})}catch(c){t.error("could not load peer data from peer store",c),e.push({id:i,addresses:s.map(a=>({multiaddr:a.remoteAddr,isConnected:o.includes(a.remoteAddr.toString())})),protocols:[],tags:{},metadata:{}})}return e}function Br(r,t){let e=t[r];if(!_n(e))throw new zt(`Component ${r} did not implement the PubSub interface`);return e}async function $o(r){let t=await r.peerStore.get(r.peerId);return{id:t.id,addresses:t.addresses,protocols:[...t.protocols],tags:Cr(t.tags,e=>e.value),metadata:Cr(t.metadata,e=>ne.encode(e))}}function tf(r){let t=r.logger.forComponent("libp2p:devtools-metrics:metrics-rpc");return{init:async()=>({self:await $o(r),peers:await qo(r,t),debug:localStorage.getItem("debug")??"",capabilities:zo(r)}),setDebug:async e=>{e?.length!=null&&e?.length>0?(sc(e),localStorage.setItem("debug",e)):(ic(),localStorage.removeItem("debug"))},openConnection:async(e,n)=>{let o;try{o=Ql(e)}catch{o=Ke(e)}await r.connectionManager.openConnection(o,n)},closeConnection:async(e,n)=>{await Promise.all(r.connectionManager.getConnections(e).map(async o=>{try{await o.close(n)}catch(i){o.abort(i)}}))},contentRouting:r.contentRouting,peerRouting:r.peerRouting,pubsub:{async getTopics(e){return Br(e,r).getTopics()},async subscribe(e,n){Br(e,r).subscribe(n)},async unsubscribe(e,n){Br(e,r).unsubscribe(n)},async publish(e,n,o){await Br(e,r).publish(n,o)},async getSubscribers(e,n){return Br(e,r).getSubscribers(n)}}}}function Vs(r,t=100){let e,n;return()=>{if(n==null&&(n=Date.now()),e!=null&&Date.now()-n>t){clearTimeout(e),n=void 0,r();return}clearTimeout(e),e=setTimeout(()=>{n=void 0,r()},t)}}function ef(r,t){for(let[e,n]of Object.entries(zo(t)))if(n.includes(r))return t[e]}var rf="@libp2p/devtools-metrics:devtools",N0="@libp2p/devtools-metrics:worker",R0="@libp2p/devtools-metrics:content",nf="@libp2p/devtools-metrics:metrics",of="________libp2p_devtools_metrics";Object.defineProperty(globalThis,of,{value:!0,enumerable:!1,writable:!1});var Hs=class{log;components;simpleMetrics;intervalMs;rpcQueue;rpc;devTools;constructor(t,e){this.log=t.logger.forComponent("libp2p:devtools-metrics"),this.intervalMs=e?.intervalMs,this.components=t,this.rpcQueue=er(),this.rpc=Iu({valueCodecs:Ks}),this.devTools=this.rpc.createClient("devTools"),this.onPeersUpdate=Vs(this.onPeersUpdate.bind(this),1e3),this.onSelfUpdate=Vs(this.onSelfUpdate.bind(this),1e3),this.onIncomingMessage=this.onIncomingMessage.bind(this),this.onPubSubMessage=this.onPubSubMessage.bind(this),this.onPubSubSubscriptionChange=this.onPubSubSubscriptionChange.bind(this),this.simpleMetrics=Ec({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";[Ee]=["@libp2p/metrics"];trackMultiaddrConnection(t){this.simpleMetrics.trackMultiaddrConnection(t)}trackProtocolStream(t,e){this.simpleMetrics.trackProtocolStream(t,e)}registerMetric(t,e){return this.simpleMetrics.registerMetric(t,e)}registerMetricGroup(t,e){return this.simpleMetrics.registerMetricGroup(t,e)}registerCounter(t,e){return this.simpleMetrics.registerCounter(t,e)}registerCounterGroup(t,e){return this.simpleMetrics.registerCounterGroup(t,e)}registerHistogram(t,e){return this.simpleMetrics.registerHistogram(t,e)}registerHistogramGroup(t,e){return this.simpleMetrics.registerHistogramGroup(t,e)}registerSummary(t,e){return this.simpleMetrics.registerSummary(t,e)}registerSummaryGroup(t,e){return this.simpleMetrics.registerSummaryGroup(t,e)}createTrace(){return this.simpleMetrics.createTrace()}traceFunction(t,e,n){return this.simpleMetrics.traceFunction(t,e,n)}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",tf(this.components)),await Zs(this.simpleMetrics),Promise.resolve().then(async()=>{await _c(this.rpcQueue,this.rpc,async e=>{for await(let n of e)window.postMessage({source:nf,type:"libp2p-rpc",message:ne.encode(n)})})}).catch(e=>{this.log.error("error while reading RPC messages",e)});let t=ef("@libp2p/pubsub",this.components);_n(t)&&(t.addEventListener("message",this.onPubSubMessage),t.addEventListener("subscription-change",this.onPubSubSubscriptionChange))}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 Ws(this.simpleMetrics)}onIncomingMessage(t){if(t.source!==window)return;let e=t.data;e?.source===rf&&e.type==="libp2p-rpc"&&this.rpcQueue.push(ne.decode(e.message))}onPubSubMessage(t){this.devTools.safeDispatchEvent("pubsub:message",{detail:t.detail}).catch(e=>{this.log.error("error relaying pubsub message",e)})}onPubSubSubscriptionChange(t){this.devTools.safeDispatchEvent("pubsub:subscription-change",{detail:t.detail}).catch(e=>{this.log.error("error relaying pubsub subscription change",e)})}onSelfUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("self",{detail:await $o(this.components)})}).catch(t=>{this.log.error("error sending peers message",t)})}onPeersUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("peers",{detail:await qo(this.components,this.log)})}).catch(t=>{this.log.error("error sending peers message",t)})}};function M0(r){return t=>new Hs(t,r)}return gf(O0);})();
|
|
2
|
+
"use strict";var Libp2PDevtoolsMetrics=(()=>{var gf=Object.create;var Bn=Object.defineProperty;var yf=Object.getOwnPropertyDescriptor;var xf=Object.getOwnPropertyNames;var bf=Object.getPrototypeOf,wf=Object.prototype.hasOwnProperty;var Dr=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Dt=(r,t)=>{for(var e in t)Bn(r,e,{get:t[e],enumerable:!0})},Ws=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of xf(t))!wf.call(r,o)&&o!==e&&Bn(r,o,{get:()=>t[o],enumerable:!(n=yf(t,o))||n.enumerable});return r};var Ef=(r,t,e)=>(e=r!=null?gf(bf(r)):{},Ws(t||!r||!r.__esModule?Bn(e,"default",{value:r,enumerable:!0}):e,r)),vf=r=>Ws(Bn({},"__esModule",{value:!0}),r);var si=Dr((qm,mc)=>{function Xt(){}Xt.prototype.clear=function(){this._root=null,this.size=0};Xt.prototype.find=function(r){for(var t=this._root;t!==null;){var e=this._comparator(r,t.data);if(e===0)return t.data;t=t.get_child(e>0)}return null};Xt.prototype.findIter=function(r){for(var t=this._root,e=this.iterator();t!==null;){var n=this._comparator(r,t.data);if(n===0)return e._cursor=t,e;e._ancestors.push(t),t=t.get_child(n>0)}return null};Xt.prototype.lowerBound=function(r){for(var t=this._root,e=this.iterator(),n=this._comparator;t!==null;){var o=n(r,t.data);if(o===0)return e._cursor=t,e;e._ancestors.push(t),t=t.get_child(o>0)}for(var i=e._ancestors.length-1;i>=0;--i)if(t=e._ancestors[i],n(r,t.data)<0)return e._cursor=t,e._ancestors.length=i,e;return e._ancestors.length=0,e};Xt.prototype.upperBound=function(r){for(var t=this.lowerBound(r),e=this._comparator;t.data()!==null&&e(t.data(),r)===0;)t.next();return t};Xt.prototype.min=function(){var r=this._root;if(r===null)return null;for(;r.left!==null;)r=r.left;return r.data};Xt.prototype.max=function(){var r=this._root;if(r===null)return null;for(;r.right!==null;)r=r.right;return r.data};Xt.prototype.iterator=function(){return new tr(this)};Xt.prototype.each=function(r){for(var t=this.iterator(),e;(e=t.next())!==null;)if(r(e)===!1)return};Xt.prototype.reach=function(r){for(var t=this.iterator(),e;(e=t.prev())!==null;)if(r(e)===!1)return};function tr(r){this._tree=r,this._ancestors=[],this._cursor=null}tr.prototype.data=function(){return this._cursor!==null?this._cursor.data:null};tr.prototype.next=function(){if(this._cursor===null){var r=this._tree._root;r!==null&&this._minNode(r)}else if(this._cursor.right===null){var t;do if(t=this._cursor,this._ancestors.length)this._cursor=this._ancestors.pop();else{this._cursor=null;break}while(this._cursor.right===t)}else this._ancestors.push(this._cursor),this._minNode(this._cursor.right);return this._cursor!==null?this._cursor.data:null};tr.prototype.prev=function(){if(this._cursor===null){var r=this._tree._root;r!==null&&this._maxNode(r)}else if(this._cursor.left===null){var t;do if(t=this._cursor,this._ancestors.length)this._cursor=this._ancestors.pop();else{this._cursor=null;break}while(this._cursor.left===t)}else this._ancestors.push(this._cursor),this._maxNode(this._cursor.left);return this._cursor!==null?this._cursor.data:null};tr.prototype._minNode=function(r){for(;r.left!==null;)this._ancestors.push(r),r=r.left;this._cursor=r};tr.prototype._maxNode=function(r){for(;r.right!==null;)this._ancestors.push(r),r=r.right;this._cursor=r};mc.exports=Xt});var xc=Dr(($m,yc)=>{var od=si();function er(r){this.data=r,this.left=null,this.right=null,this.red=!0}er.prototype.get_child=function(r){return r?this.right:this.left};er.prototype.set_child=function(r,t){r?this.right=t:this.left=t};function Mn(r){this._root=null,this._comparator=r,this.size=0}Mn.prototype=new od;Mn.prototype.insert=function(r){var t=!1;if(this._root===null)this._root=new er(r),t=!0,this.size++;else{var e=new er(void 0),n=0,o=0,i=null,s=e,c=null,a=this._root;for(s.right=this._root;;){if(a===null?(a=new er(r),c.set_child(n,a),t=!0,this.size++):$t(a.left)&&$t(a.right)&&(a.red=!0,a.left.red=!1,a.right.red=!1),$t(a)&&$t(c)){var l=s.right===i;a===c.get_child(o)?s.set_child(l,Rr(i,!o)):s.set_child(l,gc(i,!o))}var u=this._comparator(a.data,r);if(u===0)break;o=n,n=u<0,i!==null&&(s=i),i=c,c=a,a=a.get_child(n)}this._root=e.right}return this._root.red=!1,t};Mn.prototype.remove=function(r){if(this._root===null)return!1;var t=new er(void 0),e=t;e.right=this._root;for(var n=null,o=null,i=null,s=1;e.get_child(s)!==null;){var c=s;o=n,n=e,e=e.get_child(s);var a=this._comparator(r,e.data);if(s=a>0,a===0&&(i=e),!$t(e)&&!$t(e.get_child(s))){if($t(e.get_child(!s))){var l=Rr(e,s);n.set_child(c,l),n=l}else if(!$t(e.get_child(!s))){var u=n.get_child(!c);if(u!==null)if(!$t(u.get_child(!c))&&!$t(u.get_child(c)))n.red=!1,u.red=!0,e.red=!0;else{var f=o.right===n;$t(u.get_child(c))?o.set_child(f,gc(n,c)):$t(u.get_child(!c))&&o.set_child(f,Rr(n,c));var p=o.get_child(f);p.red=!0,e.red=!0,p.left.red=!1,p.right.red=!1}}}}return i!==null&&(i.data=e.data,n.set_child(n.right===e,e.get_child(e.left===null)),this.size--),this._root=t.right,this._root!==null&&(this._root.red=!1),i!==null};function $t(r){return r!==null&&r.red}function Rr(r,t){var e=r.get_child(!t);return r.set_child(!t,e.get_child(t)),e.set_child(t,r),r.red=!0,e.red=!1,e}function gc(r,t){return r.set_child(!t,Rr(r.get_child(!t),!t)),Rr(r,t)}yc.exports=Mn});var wc=Dr((jm,bc)=>{var id=si();function Mr(r){this.data=r,this.left=null,this.right=null}Mr.prototype.get_child=function(r){return r?this.right:this.left};Mr.prototype.set_child=function(r,t){r?this.right=t:this.left=t};function On(r){this._root=null,this._comparator=r,this.size=0}On.prototype=new id;On.prototype.insert=function(r){if(this._root===null)return this._root=new Mr(r),this.size++,!0;for(var t=0,e=null,n=this._root;;){if(n===null)return n=new Mr(r),e.set_child(t,n),ret=!0,this.size++,!0;if(this._comparator(n.data,r)===0)return!1;t=this._comparator(n.data,r)<0,e=n,n=n.get_child(t)}};On.prototype.remove=function(r){if(this._root===null)return!1;var t=new Mr(void 0),e=t;e.right=this._root;for(var n=null,o=null,i=1;e.get_child(i)!==null;){n=e,e=e.get_child(i);var s=this._comparator(r,e.data);i=s>0,s===0&&(o=e)}return o!==null?(o.data=e.data,n.set_child(n.right===e,e.get_child(e.left===null)),this._root=t.right,this.size--,!0):!1};bc.exports=On});var vc=Dr((Gm,Ec)=>{Ec.exports={RBTree:xc(),BinTree:wc()}});var _c=Dr((Zm,Ac)=>{var sd=vc().RBTree;function rt(r,t,e){this.discrete=r===!1,this.delta=r||.01,this.K=t===void 0?25:t,this.CX=e===void 0?1.1:e,this.centroids=new sd(Sc),this.nreset=0,this.reset()}rt.prototype.reset=function(){this.centroids.clear(),this.n=0,this.nreset+=1,this.last_cumulate=0};rt.prototype.size=function(){return this.centroids.size};rt.prototype.toArray=function(r){var t=[];return r?(this._cumulate(!0),this.centroids.each(function(e){t.push(e)})):this.centroids.each(function(e){t.push({mean:e.mean,n:e.n})}),t};rt.prototype.summary=function(){var r=this.discrete?"exact ":"approximating ",t=[r+this.n+" samples using "+this.size()+" centroids","min = "+this.percentile(0),"Q1 = "+this.percentile(.25),"Q2 = "+this.percentile(.5),"Q3 = "+this.percentile(.75),"max = "+this.percentile(1)];return t.join(`
|
|
3
|
+
`)};function Sc(r,t){return r.mean>t.mean?1:r.mean<t.mean?-1:0}function cd(r,t){return r.mean_cumn-t.mean_cumn}rt.prototype.push=function(r,t){t=t||1,r=Array.isArray(r)?r:[r];for(var e=0;e<r.length;e++)this._digest(r[e],t)};rt.prototype.push_centroid=function(r){r=Array.isArray(r)?r:[r];for(var t=0;t<r.length;t++)this._digest(r[t].mean,r[t].n)};rt.prototype._cumulate=function(r){if(!(this.n===this.last_cumulate||!r&&this.CX&&this.CX>this.n/this.last_cumulate)){var t=0;this.centroids.each(function(e){e.mean_cumn=t+e.n/2,t=e.cumn=t+e.n}),this.n=this.last_cumulate=t}};rt.prototype.find_nearest=function(r){if(this.size()===0)return null;var t=this.centroids.lowerBound({mean:r}),e=t.data()===null?t.prev():t.data();if(e.mean===r||this.discrete)return e;var n=t.prev();return n&&Math.abs(n.mean-r)<Math.abs(e.mean-r)?n:e};rt.prototype._new_centroid=function(r,t,e){var n={mean:r,n:t,cumn:e};return this.centroids.insert(n),this.n+=t,n};rt.prototype._addweight=function(r,t,e){t!==r.mean&&(r.mean+=e*(t-r.mean)/(r.n+e)),r.cumn+=e,r.mean_cumn+=e/2,r.n+=e,this.n+=e};rt.prototype._digest=function(r,t){var e=this.centroids.min(),n=this.centroids.max(),o=this.find_nearest(r);if(o&&o.mean===r)this._addweight(o,r,t);else if(o===e)this._new_centroid(r,t,0);else if(o===n)this._new_centroid(r,t,this.n);else if(this.discrete)this._new_centroid(r,t,o.cumn);else{var i=o.mean_cumn/this.n,s=Math.floor(4*this.n*this.delta*i*(1-i));s-o.n>=t?this._addweight(o,r,t):this._new_centroid(r,t,o.cumn)}this._cumulate(!1),!this.discrete&&this.K&&this.size()>this.K/this.delta&&this.compress()};rt.prototype.bound_mean=function(r){var t=this.centroids.upperBound({mean:r}),e=t.prev(),n=e.mean===r?e:t.next();return[e,n]};rt.prototype.p_rank=function(r){var t=Array.isArray(r)?r:[r],e=t.map(this._p_rank,this);return Array.isArray(r)?e:e[0]};rt.prototype._p_rank=function(r){if(this.size()!==0){{if(r<this.centroids.min().mean)return 0;if(r>this.centroids.max().mean)return 1}this._cumulate(!0);var t=this.bound_mean(r),e=t[0],n=t[1];if(this.discrete)return e.cumn/this.n;var o=e.mean_cumn;return e!==n&&(o+=(r-e.mean)*(n.mean_cumn-e.mean_cumn)/(n.mean-e.mean)),o/this.n}};rt.prototype.bound_mean_cumn=function(r){this.centroids._comparator=cd;var t=this.centroids.upperBound({mean_cumn:r});this.centroids._comparator=Sc;var e=t.prev(),n=e&&e.mean_cumn===r?e:t.next();return[e,n]};rt.prototype.percentile=function(r){var t=Array.isArray(r)?r:[r],e=t.map(this._percentile,this);return Array.isArray(r)?e:e[0]};rt.prototype._percentile=function(r){if(this.size()!==0){this._cumulate(!0);var t=this.n*r,e=this.bound_mean_cumn(t),n=e[0],o=e[1];return o===n||n===null||o===null?(n||o).mean:this.discrete?t<=n.cumn?n.mean:o.mean:n.mean+(t-n.mean_cumn)*(o.mean-n.mean)/(o.mean_cumn-n.mean_cumn)}};function ad(r){var t=Math.floor(Math.random()*r.length);return r.splice(t,1)[0]}rt.prototype.compress=function(){if(!this.compressing){var r=this.toArray();for(this.reset(),this.compressing=!0;r.length>0;)this.push_centroid(ad(r));this._cumulate(!0),this.compressing=!1}};function _e(r){this.config=r||{},this.mode=this.config.mode||"auto",rt.call(this,this.mode==="cont"?r.delta:!1),this.digest_ratio=this.config.ratio||.9,this.digest_thresh=this.config.thresh||1e3,this.n_unique=0}_e.prototype=Object.create(rt.prototype);_e.prototype.constructor=_e;_e.prototype.push=function(r){rt.prototype.push.call(this,r),this.check_continuous()};_e.prototype._new_centroid=function(r,t,e){this.n_unique+=1,rt.prototype._new_centroid.call(this,r,t,e)};_e.prototype._addweight=function(r,t,e){r.n===1&&(this.n_unique-=1),rt.prototype._addweight.call(this,r,t,e)};_e.prototype.check_continuous=function(){return this.mode!=="auto"||this.size()<this.digest_thresh?!1:this.n_unique/this.size()>this.digest_ratio?(this.mode="cont",this.discrete=!1,this.delta=this.config.delta||.01,this.compress(),!0):!1};Ac.exports={TDigest:rt,Digest:_e}});var $0={};Dt($0,{LIBP2P_DEVTOOLS_METRICS_KEY:()=>ff,SOURCE_CONTENT_SCRIPT:()=>H0,SOURCE_DEVTOOLS:()=>uf,SOURCE_METRICS:()=>lf,SOURCE_SERVICE_WORKER:()=>V0,devToolsMetrics:()=>q0,valueCodecs:()=>js});var kn=Symbol.for("@libp2p/peer-id");function Xs(r){return!!r?.[kn]}var Qs;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Qs||(Qs={}));var Sf=Symbol.for("@libp2p/pubsub");function Tn(r){return!!r?.[Sf]}var qt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Un=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ln=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Pn=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Nr=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};function Js(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function tc(...r){let t=[];for(let e of r)Js(e)&&t.push(e);await Promise.all(t.map(async e=>{e.beforeStart!=null&&await e.beforeStart()})),await Promise.all(t.map(async e=>{await e.start()})),await Promise.all(t.map(async e=>{e.afterStart!=null&&await e.afterStart()}))}async function ec(...r){let t=[];for(let e of r)Js(e)&&t.push(e);await Promise.all(t.map(async e=>{e.beforeStop!=null&&await e.beforeStop()})),await Promise.all(t.map(async e=>{await e.stop()})),await Promise.all(t.map(async e=>{e.afterStop!=null&&await e.afterStop()}))}var Se=Symbol.for("@libp2p/service-capabilities"),X0=Symbol.for("@libp2p/service-dependencies");var ei={};Dt(ei,{base32:()=>Wt,base32hex:()=>Lf,base32hexpad:()=>Df,base32hexpadupper:()=>Nf,base32hexupper:()=>Pf,base32pad:()=>Tf,base32padupper:()=>Uf,base32upper:()=>kf,base32z:()=>Rf});var wm=new Uint8Array(0);function rc(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function ue(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 nc(r){return new TextEncoder().encode(r)}function oc(r){return new TextDecoder().decode(r)}function Af(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var c=r.length,a=r.charAt(0),l=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function f(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var m=0,x=0,B=0,P=E.length;B!==P&&E[B]===0;)B++,m++;for(var b=(P-B)*u+1>>>0,d=new Uint8Array(b);B!==P;){for(var v=E[B],T=0,U=b-1;(v!==0||T<x)&&U!==-1;U--,T++)v+=256*d[U]>>>0,d[U]=v%c>>>0,v=v/c>>>0;if(v!==0)throw new Error("Non-zero carry");x=T,B++}for(var L=b-x;L!==b&&d[L]===0;)L++;for(var O=a.repeat(m);L<b;++L)O+=r.charAt(d[L]);return O}function p(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var m=0;if(E[m]!==" "){for(var x=0,B=0;E[m]===a;)x++,m++;for(var P=(E.length-m)*l+1>>>0,b=new Uint8Array(P);E[m];){var d=e[E.charCodeAt(m)];if(d===255)return;for(var v=0,T=P-1;(d!==0||v<B)&&T!==-1;T--,v++)d+=c*b[T]>>>0,b[T]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");B=v,m++}if(E[m]!==" "){for(var U=P-B;U!==P&&b[U]===0;)U++;for(var L=new Uint8Array(x+(P-U)),O=x;U!==P;)L[O++]=b[U++];return L}}}function w(E){var m=p(E);if(m)return m;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:p,decode:w}}var _f=Af,If=_f,sc=If;var Xo=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Qo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return cc(this,t)}},Jo=class{decoders;constructor(t){this.decoders=t}or(t){return cc(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function cc(r,t){return new Jo({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var ti=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Xo(t,e,n),this.decoder=new Qo(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Je({name:r,prefix:t,encode:e,decode:n}){return new ti(r,t,e,n)}function Ae({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=sc(e,r);return Je({prefix:t,name:r,encode:n,decode:i=>ue(o(i))})}function Cf(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),c=0,a=0,l=0;for(let u=0;u<i;++u){let f=o[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,c+=e,c>=8&&(c-=8,s[l++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return s}function Bf(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>e;)s-=e,i+=t[o&c>>s];if(s!==0&&(i+=t[o&c<<e-s]),n)for(;(i.length*e&7)!==0;)i+="=";return i}function it({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Je({prefix:t,name:r,encode(o){return Bf(o,n,e)},decode(o){return Cf(o,n,e,r)}})}var Wt=it({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),kf=it({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Tf=it({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Uf=it({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Lf=it({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Pf=it({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Df=it({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nf=it({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Rf=it({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ri={};Dt(ri,{base58btc:()=>et,base58flickr:()=>Mf});var et=Ae({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Mf=Ae({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ni={};Dt(ni,{base64:()=>oe,base64pad:()=>Of,base64url:()=>Ff,base64urlpad:()=>Kf});var oe=it({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Of=it({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ff=it({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Kf=it({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Vf(r,t){try{if(typeof r=="string"&&r.length>0)return Hf(r);if(typeof r=="number"&&isFinite(r))return t?.long?qf(r):zf(r);throw new Error("Value is not a string or number.")}catch(e){let n=$f(e)?`${e.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function Hf(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let t=/^(-?(?:\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(!t)return NaN;let e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*315576e5;case"weeks":case"week":case"w":return e*6048e5;case"days":case"day":case"d":return e*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return e*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return e*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return e*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Nn=Vf;function zf(r){let t=Math.abs(r);return t>=864e5?`${Math.round(r/864e5)}d`:t>=36e5?`${Math.round(r/36e5)}h`:t>=6e4?`${Math.round(r/6e4)}m`:t>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function qf(r){let t=Math.abs(r);return t>=864e5?Dn(r,t,864e5,"day"):t>=36e5?Dn(r,t,36e5,"hour"):t>=6e4?Dn(r,t,6e4,"minute"):t>=1e3?Dn(r,t,1e3,"second"):`${r} ms`}function Dn(r,t,e,n){let o=t>=e*1.5;return`${Math.round(r/e)} ${n}${o?"s":""}`}function $f(r){return typeof r=="object"&&r!==null&&"message"in r}function oi(r){e.debug=e,e.default=e,e.coerce=a,e.disable=i,e.enable=o,e.enabled=s,e.humanize=Nn,e.destroy=l,Object.keys(r).forEach(u=>{e[u]=r[u]}),e.names=[],e.skips=[],e.formatters={};function t(u){let f=0;for(let p=0;p<u.length;p++)f=(f<<5)-f+u.charCodeAt(p),f|=0;return e.colors[Math.abs(f)%e.colors.length]}e.selectColor=t;function e(u){let f,p=null,w,E;function m(...x){if(!m.enabled)return;let B=m,P=Number(new Date),b=P-(f||P);B.diff=b,B.prev=f,B.curr=P,f=P,x[0]=e.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let d=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(T,U)=>{if(T==="%%")return"%";d++;let L=e.formatters[U];if(typeof L=="function"){let O=x[d];T=L.call(B,O),x.splice(d,1),d--}return T}),e.formatArgs.call(B,x),(B.log||e.log).apply(B,x)}return m.namespace=u,m.useColors=e.useColors(),m.color=e.selectColor(u),m.extend=n,m.destroy=e.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(w!==e.namespaces&&(w=e.namespaces,E=e.enabled(u)),E),set:x=>{p=x}}),typeof e.init=="function"&&e.init(m),m}function n(u,f){let p=e(this.namespace+(typeof f>"u"?":":f)+u);return p.log=this.log,p}function o(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let f,p=(typeof u=="string"?u:"").split(/[\s,]+/),w=p.length;for(f=0;f<w;f++)p[f]&&(u=p[f].replace(/\*/g,".*?"),u[0]==="-"?e.skips.push(new RegExp("^"+u.substr(1)+"$")):e.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...e.names.map(c),...e.skips.map(c).map(f=>"-"+f)].join(",");return e.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,p;for(f=0,p=e.skips.length;f<p;f++)if(e.skips[f].test(u))return!1;for(f=0,p=e.names.length;f<p;f++)if(e.names[f].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function a(u){return u instanceof Error?u.stack??u.message:u}function l(){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 e.setupFormatters(e.formatters),e.enable(e.load()),e}var Rn=Qf(),jf=["#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 Gf(){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 Zf(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Nn(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}var Yf=console.debug??console.log??(()=>{});function Wf(r){try{r?Rn?.setItem("debug",r):Rn?.removeItem("debug")}catch{}}function Xf(){let r;try{r=Rn?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function Qf(){try{return localStorage}catch{}}function Jf(r){r.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}var ac=oi({formatArgs:Zf,save:Wf,load:Xf,useColors:Gf,setupFormatters:Jf,colors:jf,storage:Rn,log:Yf});var wt=ac;wt.formatters.b=r=>r==null?"undefined":et.baseEncode(r);wt.formatters.t=r=>r==null?"undefined":Wt.baseEncode(r);wt.formatters.m=r=>r==null?"undefined":oe.baseEncode(r);wt.formatters.p=r=>r==null?"undefined":r.toString();wt.formatters.c=r=>r==null?"undefined":r.toString();wt.formatters.k=r=>r==null?"undefined":r.toString();wt.formatters.a=r=>r==null?"undefined":r.toString();wt.formatters.e=r=>r==null?"undefined":uc(r.stack)??uc(r.message)??r.toString();function td(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function lc(r){let t=td(`${r}:trace`);return wt.enabled(`${r}:trace`)&&wt.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=wt(`${r}:trace`)),Object.assign(wt(r),{error:wt(`${r}:error`),trace:t})}function fc(){wt.disable()}function dc(r){wt.enable(r)}function uc(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}function ed(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var hc=ed;function rd(r){return r[Symbol.asyncIterator]!=null}function pc(r){return r?.then!=null}function nd(r,t){let e=0;if(rd(r))return async function*(){for await(let a of r){let l=t(a,e++);pc(l)&&await l,yield a}}();let n=hc(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();if(typeof t(o,e++)?.then=="function")return async function*(){yield o;for await(let a of n){let l=t(a,e++);pc(l)&&await l,yield a}}();let c=t;return function*(){yield o;for(let a of n)c(a,e++),yield a}()}var ii=nd;var Ic=Ef(_c(),1),ud=lc("libp2p:simple-metrics"),Or=class{value=0;update(t){this.value=t}increment(t=1){this.value+=t}decrement(t=1){this.value-=t}reset(){this.value=0}timer(){let t=Date.now();return()=>{this.value=Date.now()-t}}},Fr=class{values={};update(t){Object.entries(t).forEach(([e,n])=>{this.values[e]=n})}increment(t){Object.entries(t).forEach(([e,n])=>{this.values[e]=this.values[e]??0;let o=typeof n=="number"?n:1;this.values[e]+=Number(o)})}decrement(t){Object.entries(t).forEach(([e,n])=>{this.values[e]=this.values[e]??0;let o=typeof n=="number"?n:1;this.values[e]-=Number(o)})}reset(){this.values={}}timer(t){let e=Date.now();return()=>{this.values[t]=Date.now()-e}}},Kr=class{bucketValues=new Map;countValue=0;sumValue=0;constructor(t){let e=[...t.buckets??[.005,.01,.025,.05,.1,.25,.5,1,2.5,5,10],1/0];for(let n of e)this.bucketValues.set(n,0)}observe(t){this.countValue++,this.sumValue+=t;for(let[e,n]of this.bucketValues.entries())t<=e&&this.bucketValues.set(e,n+1)}reset(){this.countValue=0,this.sumValue=0;for(let t of this.bucketValues.keys())this.bucketValues.set(t,0)}timer(){let t=Date.now();return()=>{this.observe(Date.now()-t)}}},Fn=class{histograms={};constructor(t){this.histograms={}}observe(t){for(let[e,n]of Object.entries(t))this.histograms[e]===void 0&&(this.histograms[e]=new Kr({})),this.histograms[e].observe(n)}reset(){for(let t of Object.values(this.histograms))t.reset()}timer(t){let e=Date.now();return()=>{this.observe({[t]:Date.now()-e})}}},Vr=class{sumValue=0;countValue=0;percentiles;tdigest=new Ic.TDigest(.01);compressCount;constructor(t){this.percentiles=t.percentiles??[.01,.05,.5,.9,.95,.99,.999],this.compressCount=t.compressCount??1e3}observe(t){this.sumValue+=t,this.countValue++,this.tdigest.push(t),this.tdigest.size()>this.compressCount&&this.tdigest.compress()}reset(){this.sumValue=0,this.countValue=0,this.tdigest.reset()}timer(){let t=Date.now();return()=>{this.observe(Date.now()-t)}}},Kn=class{summaries={};opts;constructor(t){this.summaries={},this.opts=t}observe(t){for(let[e,n]of Object.entries(t))this.summaries[e]===void 0&&(this.summaries[e]=new Vr(this.opts)),this.summaries[e].observe(n)}reset(){for(let t of Object.values(this.summaries))t.reset()}timer(t){let e=Date.now();return()=>{this.observe({[t]:Date.now()-e})}}},ci=class{metrics=new Map;transferStats;started;interval;intervalMs;onMetrics;constructor(t,e){this.started=!1,this._emitMetrics=this._emitMetrics.bind(this),this.intervalMs=e.intervalMs??1e3,this.onMetrics=e.onMetrics,this.transferStats=new Map}[Symbol.toStringTag]="@libp2p/metrics-simple";[Se]=["@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 t={};for(let[e,n]of this.metrics.entries())n instanceof Or?t[e]=n.value:n instanceof Fr?t[e]=n.values:n instanceof Kr?t[e]={count:n.countValue,sum:n.sumValue,buckets:{...n.bucketValues}}:n instanceof Fn?t[e]={...Object.fromEntries(Object.entries(n.histograms).map(([o,i])=>[o,{count:i.countValue,sum:i.sumValue,buckets:{...i.bucketValues}}]))}:n instanceof Vr?t[e]={count:n.countValue,sum:n.sumValue,percentiles:Object.fromEntries(n.percentiles.map(o=>[o,n.tdigest.percentile(o)]))}:n instanceof Kn?t[e]={...Object.fromEntries(Object.entries(n.summaries).map(([o,i])=>[o,{count:i.countValue,sum:i.sumValue,percentiles:Object.fromEntries(i.percentiles.map(s=>[s,i.tdigest.percentile(s)]))}]))}:t[e]=await n();this.onMetrics(structuredClone(t))}).catch(t=>{ud.error("could not invoke onMetrics callback",t)})}_incrementValue(t,e){let n=this.transferStats.get(t)??0;this.transferStats.set(t,n+e)}_track(t,e){let n=this,o=t.sink;t.sink=async function(c){await o(ii(c,a=>{n._incrementValue(`${e} sent`,a.byteLength)}))};let i=t.source;t.source=ii(i,s=>{n._incrementValue(`${e} received`,s.byteLength)})}trackMultiaddrConnection(t){this._track(t,"global")}trackProtocolStream(t,e){t.protocol!=null&&this._track(t,t.protocol)}registerMetric(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Or;return this.metrics.set(t,n),n}registerMetricGroup(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Fr;return this.metrics.set(t,n),n}registerCounter(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Or;return this.metrics.set(t,n),n}registerCounterGroup(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Fr;return this.metrics.set(t,n),n}registerHistogram(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Kr(e);return this.metrics.set(t,n),n}registerHistogramGroup(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Fn(e);return this.metrics.set(t,n),n}registerSummary(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Vr(e);return this.metrics.set(t,n),n}registerSummaryGroup(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Kn(e);return this.metrics.set(t,n),n}createTrace(){}traceFunction(t,e){return e}};function Cc(r){return t=>new ci(t,r)}function Et(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Vn=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||(t-1&t)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},rr=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Vn(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Vn(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var ai=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function nr(r={}){return ld(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function ld(r,t){t=t??{};let e=t.onEnd,n=new rr,o,i,s,c=Et(),a=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((x,B)=>{i=P=>{i=null,n.push(P);try{x(r(n))}catch(b){B(b)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=Et()})}},l=x=>i!=null?i(x):(n.push(x),o),u=x=>(n=new rr,i!=null?i({error:x}):(n.push({error:x}),o)),f=x=>{if(s)return o;if(t?.objectMode!==!0&&x?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:x})},p=x=>s?o:(s=!0,x!=null?u(x):l({done:!0})),w=()=>(n=new rr,p(),{done:!0}),E=x=>(p(x),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:w,throw:E,push:f,end:p,get readableLength(){return n.size},onEmpty:async x=>{let B=x?.signal;if(B?.throwIfAborted(),n.isEmpty())return;let P,b;B!=null&&(P=new Promise((d,v)=>{b=()=>{v(new ai)},B.addEventListener("abort",b)}));try{await Promise.race([c.promise,P])}finally{b!=null&&B!=null&&B?.removeEventListener("abort",b)}}},e==null)return o;let m=o;return o={[Symbol.asyncIterator](){return this},next(){return m.next()},throw(x){return m.throw(x),e!=null&&(e(x),e=void 0),{done:!0}},return(){return m.return(),e!=null&&(e(),e=void 0),{done:!0}},push:f,end(x){return m.end(x),e!=null&&(e(x),e=void 0),o},get readableLength(){return m.readableLength},onEmpty:x=>m.onEmpty(x)},o}var Hn=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function le(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new Hn(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Hn(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((i,s)=>{n=()=>{s(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var ui=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=Et(),this.haveNext=Et()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Et(),t}async throw(t){return this.ended=!0,this.error=t,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Et(),await le(this.readNext.promise,e?.signal,e)}};function Bc(){return new ui}function fd(r){return r[Symbol.asyncIterator]!=null}async function dd(r,t,e){try{await Promise.all(r.map(async n=>{for await(let o of n)await t.push(o,{signal:e}),e.throwIfAborted()})),await t.end(void 0,{signal:e})}catch(n){await t.end(n,{signal:e}).catch(()=>{})}}async function*hd(r){let t=new AbortController,e=Bc();dd(r,e,t.signal).catch(()=>{});try{yield*e}finally{t.abort()}}function*pd(r){for(let t of r)yield*t}function md(...r){let t=[];for(let e of r)fd(e)||t.push(e);return t.length===r.length?pd(t):hd(r)}var kc=md;function Tc(r,...t){if(r==null)throw new Error("Empty pipeline");if(li(r)){let n=r;r=()=>n.source}else if(Lc(r)||Uc(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&li(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let n=1;n<e.length-1;n++)li(e[n])&&(e[n]=yd(e[n]));return gd(...e)}var gd=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},Uc=r=>r?.[Symbol.asyncIterator]!=null,Lc=r=>r?.[Symbol.iterator]!=null,li=r=>r==null?!1:r.sink!=null&&r.source!=null,yd=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=nr({objectMode:!0});e.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(Uc(i))o=async function*(){yield*i,n.end()};else if(Lc(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return kc(n,o())}return r.source};var zn=class extends Error{static name="AbortError";name="AbortError";constructor(t="The operation was aborted",...e){super(t,...e)}};function Re(r){let t=new globalThis.AbortController;function e(){t.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",e)}for(let i of r){if(i?.aborted===!0){e();break}i?.addEventListener!=null&&i.addEventListener("abort",e)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",e)}let o=t.signal;return o.clear=n,o}function Qt(r=0){return new Uint8Array(r)}function vt(r=0){return new Uint8Array(r)}var xd=Math.pow(2,7),bd=Math.pow(2,14),wd=Math.pow(2,21),fi=Math.pow(2,28),di=Math.pow(2,35),hi=Math.pow(2,42),pi=Math.pow(2,49),Z=128,St=127;function ft(r){if(r<xd)return 1;if(r<bd)return 2;if(r<wd)return 3;if(r<fi)return 4;if(r<di)return 5;if(r<hi)return 6;if(r<pi)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function mi(r,t,e=0){switch(ft(r)){case 8:t[e++]=r&255|Z,r/=128;case 7:t[e++]=r&255|Z,r/=128;case 6:t[e++]=r&255|Z,r/=128;case 5:t[e++]=r&255|Z,r/=128;case 4:t[e++]=r&255|Z,r>>>=7;case 3:t[e++]=r&255|Z,r>>>=7;case 2:t[e++]=r&255|Z,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Ed(r,t,e=0){switch(ft(r)){case 8:t.set(e++,r&255|Z),r/=128;case 7:t.set(e++,r&255|Z),r/=128;case 6:t.set(e++,r&255|Z),r/=128;case 5:t.set(e++,r&255|Z),r/=128;case 4:t.set(e++,r&255|Z),r>>>=7;case 3:t.set(e++,r&255|Z),r>>>=7;case 2:t.set(e++,r&255|Z),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function gi(r,t){let e=r[t],n=0;if(n+=e&St,e<Z||(e=r[t+1],n+=(e&St)<<7,e<Z)||(e=r[t+2],n+=(e&St)<<14,e<Z)||(e=r[t+3],n+=(e&St)<<21,e<Z)||(e=r[t+4],n+=(e&St)*fi,e<Z)||(e=r[t+5],n+=(e&St)*di,e<Z)||(e=r[t+6],n+=(e&St)*hi,e<Z)||(e=r[t+7],n+=(e&St)*pi,e<Z))return n;throw new RangeError("Could not decode varint")}function vd(r,t){let e=r.get(t),n=0;if(n+=e&St,e<Z||(e=r.get(t+1),n+=(e&St)<<7,e<Z)||(e=r.get(t+2),n+=(e&St)<<14,e<Z)||(e=r.get(t+3),n+=(e&St)<<21,e<Z)||(e=r.get(t+4),n+=(e&St)*fi,e<Z)||(e=r.get(t+5),n+=(e&St)*di,e<Z)||(e=r.get(t+6),n+=(e&St)*hi,e<Z)||(e=r.get(t+7),n+=(e&St)*pi,e<Z))return n;throw new RangeError("Could not decode varint")}function Ie(r,t,e=0){return t==null&&(t=vt(ft(r))),t instanceof Uint8Array?mi(r,t,e):Ed(r,t,e)}function fe(r,t=0){return r instanceof Uint8Array?gi(r,t):vd(r,t)}function Nt(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=vt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function Rt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Dc=Symbol.for("@achingbrain/uint8arraylist");function Pc(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function $n(r){return!!r?.[Dc]}var gt=class r{bufs;length;[Dc]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if($n(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if($n(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Pc(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Pc(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if($n(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Nt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Nt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),i=new r;return i.length=o,i.bufs=[...n],i}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===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,a=c+s.byteLength;if(o=a,t>=a)continue;let l=t>=c&&t<a,u=e>c&&e<=a;if(l&&u){if(t===c&&e===a){n.push(s);break}let f=t-c;n.push(s.subarray(f,f+(e-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-c));continue}if(u){if(e===a){n.push(s);break}n.push(s.subarray(0,e-c));break}n.push(s)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!$n(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;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,a=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=e;f<=a;f+=u){u=0;for(let p=l;p>=0;p--){let w=this.get(f+p);if(n[p]!==w){u=Math.max(1,p-c[w]);break}}if(u===0)return f}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=Qt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=Qt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=Qt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=Qt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=Qt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=Qt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=Qt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=Qt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!Rt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,i)=>o+i.byteLength,0)),n.length=e,n}};var jn=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},or=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Gn=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},Hr=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function Zn(r){return r[Symbol.asyncIterator]!=null}function Nc(r,t){if(r.byteLength>t)throw new or("Message length too long")}var Wn=r=>{let t=ft(r),e=vt(t);return Ie(r,e),Wn.bytes=t,e};Wn.bytes=0;function Xn(r,t){t=t??{};let e=t.lengthEncoder??Wn,n=t?.maxDataLength??4194304;function*o(i){Nc(i,n);let s=e(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}return Zn(r)?async function*(){for await(let i of r)yield*o(i)}():function*(){for(let i of r)yield*o(i)}()}Xn.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??Wn,n=t?.maxDataLength??4194304;return Nc(r,n),new gt(e(r.byteLength),r)};var Me;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Me||(Me={}));var yi=r=>{let t=fe(r);return yi.bytes=ft(t),t};yi.bytes=0;function zr(r,t){let e=new gt,n=Me.LENGTH,o=-1,i=t?.lengthDecoder??yi,s=t?.maxLengthLength??8,c=t?.maxDataLength??4194304;function*a(){for(;e.byteLength>0;){if(n===Me.LENGTH)try{if(o=i(e),o<0)throw new jn("Invalid message length");if(o>c)throw new or("Message length too long");let l=i.bytes;e.consume(l),t?.onLength!=null&&t.onLength(o),n=Me.DATA}catch(l){if(l instanceof RangeError){if(e.byteLength>s)throw new Gn("Message length length too long");break}throw l}if(n===Me.DATA){if(e.byteLength<o)break;let l=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(l),yield l,n=Me.LENGTH}}}return Zn(r)?async function*(){for await(let l of r)e.append(l),yield*a();if(e.byteLength>0)throw new Hr("Unexpected end of input")}():function*(){for(let l of r)e.append(l),yield*a();if(e.byteLength>0)throw new Hr("Unexpected end of input")}()}zr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:i,value:s}=await r.next(e);if(i===!0)return;s!=null&&(yield s)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{e=1}}();return zr(n,{...t??{},onLength:i=>{e=i}})};var Rc="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var ir=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Rc[e[r]&63];return t};var Qn=class extends Error{constructor(t="Method not found"){super(t),this.name="MethodNotFoundError"}},Jn=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidMethodError"}},qr=class extends Error{constructor(t="Unsupported value type"){super(t),this.name="UnsupportedValueTypeError"}},to=class extends Error{constructor(t="Cannot reuse RPC target name"){super(t),this.name="DuplicateTargetNameError"}},$r=class extends Error{constructor(t="Duplicate scope"){super(t),this.name="DuplicateScopeError"}},eo=class extends Error{constructor(t="Invalid return type"){super(t),this.name="InvalidReturnTypeError"}},jr=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidInvocationTypeError"}},sr=class extends Error{constructor(t="Parent invocation scope not found"){super(t),this.name="MissingParentScopeError"}},ro=class extends Error{constructor(t="Invocation not found"){super(t),this.name="MissingInvocationError"}},no=class extends Error{constructor(t="Callback not found"){super(t),this.name="MissingCallbackError"}},Gr=class extends Error{constructor(t="Not connected"){super(t),this.name="NotConnectedError"}},Oe=class extends Error{constructor(t="Timeout"){super(t),this.name="TimeoutError"}};var xi=new Float32Array([-0]),Ce=new Uint8Array(xi.buffer);function Mc(r,t,e){xi[0]=r,t[e]=Ce[0],t[e+1]=Ce[1],t[e+2]=Ce[2],t[e+3]=Ce[3]}function Oc(r,t){return Ce[0]=r[t],Ce[1]=r[t+1],Ce[2]=r[t+2],Ce[3]=r[t+3],xi[0]}var bi=new Float64Array([-0]),At=new Uint8Array(bi.buffer);function Fc(r,t,e){bi[0]=r,t[e]=At[0],t[e+1]=At[1],t[e+2]=At[2],t[e+3]=At[3],t[e+4]=At[4],t[e+5]=At[5],t[e+6]=At[6],t[e+7]=At[7]}function Kc(r,t){return At[0]=r[t],At[1]=r[t+1],At[2]=r[t+2],At[3]=r[t+3],At[4]=r[t+4],At[5]=r[t+5],At[6]=r[t+6],At[7]=r[t+7],bi[0]}var Ad=BigInt(Number.MAX_SAFE_INTEGER),_d=BigInt(Number.MIN_SAFE_INTEGER),Mt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Fe;if(t<Ad&&t>_d)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>Vc&&(o=0n,++n>Vc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return Fe;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):Fe}},Fe=new Mt(0,0);Fe.toBigInt=function(){return 0n};Fe.zzEncode=Fe.zzDecode=function(){return this};Fe.length=function(){return 1};var Vc=4294967296n;function Hc(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function zc(r,t,e){if(e-t<1)return"";let o,i=[],s=0,c;for(;t<e;)c=r[t++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&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 wi(r,t,e){let n=e,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function Jt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function oo(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Ei=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Jt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Jt(this,4);return oo(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Jt(this,4);return oo(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Jt(this,4);let t=Oc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Jt(this,4);let t=Kc(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Jt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return zc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Jt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Jt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Mt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Jt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Jt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Jt(this,8);let t=oo(this.buf,this.pos+=4),e=oo(this.buf,this.pos+=4);return new Mt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=gi(this.buf,this.pos);return this.pos+=ft(t),t}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 vi(r){return new Ei(r instanceof Uint8Array?r:r.subarray())}function _t(r,t,e){let n=vi(r);return t.decode(n,void 0,e)}var Si={};Dt(Si,{base10:()=>Id});var Id=Ae({prefix:"9",name:"base10",alphabet:"0123456789"});var Ai={};Dt(Ai,{base16:()=>Cd,base16upper:()=>Bd});var Cd=it({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Bd=it({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var _i={};Dt(_i,{base2:()=>kd});var kd=it({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ii={};Dt(Ii,{base256emoji:()=>Dd});var $c=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}"),Td=$c.reduce((r,t,e)=>(r[e]=t,r),[]),Ud=$c.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Ld(r){return r.reduce((t,e)=>(t+=Td[e],t),"")}function Pd(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Ud[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Dd=Je({prefix:"\u{1F680}",name:"base256emoji",encode:Ld,decode:Pd});var Ci={};Dt(Ci,{base36:()=>Zr,base36upper:()=>Nd});var Zr=Ae({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Nd=Ae({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Bi={};Dt(Bi,{base8:()=>Rd});var Rd=it({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ki={};Dt(ki,{identity:()=>Md});var Md=Je({prefix:"\0",name:"identity",encode:r=>oc(r),decode:r=>nc(r)});var ly=new TextEncoder,fy=new TextDecoder;var Ui={};Dt(Ui,{identity:()=>te});var Kd=Zc,jc=128,Vd=127,Hd=~Vd,zd=Math.pow(2,31);function Zc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=zd;)t[e++]=r&255|jc,r/=128;for(;r&Hd;)t[e++]=r&255|jc,r>>>=7;return t[e]=r|0,Zc.bytes=e-n+1,t}var qd=Ti,$d=128,Gc=127;function Ti(r,n){var e=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw Ti.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&Gc)<<o:(s&Gc)*Math.pow(2,o),o+=7}while(s>=$d);return Ti.bytes=i-n,e}var jd=Math.pow(2,7),Gd=Math.pow(2,14),Zd=Math.pow(2,21),Yd=Math.pow(2,28),Wd=Math.pow(2,35),Xd=Math.pow(2,42),Qd=Math.pow(2,49),Jd=Math.pow(2,56),th=Math.pow(2,63),eh=function(r){return r<jd?1:r<Gd?2:r<Zd?3:r<Yd?4:r<Wd?5:r<Xd?6:r<Qd?7:r<Jd?8:r<th?9:10},rh={encode:Kd,decode:qd,encodingLength:eh},nh=rh,Yr=nh;function Wr(r,t=0){return[Yr.decode(r,t),Yr.decode.bytes]}function cr(r,t,e=0){return Yr.encode(r,t,e),t}function ar(r){return Yr.encodingLength(r)}function Ke(r,t){let e=t.byteLength,n=ar(r),o=n+ar(e),i=new Uint8Array(o+e);return cr(r,i,0),cr(e,i,n),i.set(t,o),new ur(r,e,t,i)}function de(r){let t=ue(r),[e,n]=Wr(t),[o,i]=Wr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new ur(e,o,s,t)}function Yc(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&rc(r.bytes,e.bytes)}}var ur=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Wc=0,oh="identity",Xc=ue;function ih(r){return Ke(Wc,Xc(r))}var te={code:Wc,name:oh,encode:Xc,digest:ih};var Di={};Dt(Di,{sha256:()=>Xr,sha512:()=>sh});function Pi({name:r,code:t,encode:e}){return new Li(r,t,e)}var Li=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Ke(this.code,e):e.then(n=>Ke(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Jc(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Xr=Pi({name:"sha2-256",code:18,encode:Jc("SHA-256")}),sh=Pi({name:"sha2-512",code:19,encode:Jc("SHA-512")});function ta(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return ah(e,Ni(r),t??et.encoder);default:return uh(e,Ni(r),t??Wt.encoder)}}var ea=new WeakMap;function Ni(r){let t=ea.get(r);if(t==null){let e=new Map;return ea.set(r,e),e}return t}var ct=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,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:t,multihash:e}=this;if(t!==Qr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==lh)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:t,digest:e}=this.multihash,n=Ke(t,e);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(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Yc(t.multihash,n.multihash)}toString(t){return ta(this,t)}toJSON(){return{"/":ta(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:i,bytes:s}=e;return new r(n,o,i,s??ra(n,o,i.bytes))}else if(e[fh]===!0){let{version:n,multihash:o,code:i}=e,s=de(o);return r.create(n,i,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Qr)throw new Error(`Version 0 CID must use dag-pb (code: ${Qr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=ra(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Qr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=ue(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new ur(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[f,p]=Wr(t.subarray(e));return e+=p,f},o=n(),i=Qr;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,c=n(),a=n(),l=e+a,u=l-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:l}}static parse(t,e){let[n,o]=ch(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ni(i).set(n,t),i}};function ch(r,t){switch(r[0]){case"Q":{let e=t??et;return[et.prefix,e.decode(`${et.prefix}${r}`)]}case et.prefix:{let e=t??et;return[et.prefix,e.decode(r)]}case Wt.prefix:{let e=t??Wt;return[Wt.prefix,e.decode(r)]}case Zr.prefix:{let e=t??Zr;return[Zr.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function ah(r,t,e){let{prefix:n}=e;if(n!==et.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function uh(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o}var Qr=112,lh=18;function ra(r,t,e){let n=ar(r),o=n+ar(t),i=new Uint8Array(o+e.byteLength);return cr(r,i,0),cr(t,i,n),i.set(e,o),i}var fh=Symbol.for("@ipld/js-cid/CID");var Jr={...ki,..._i,...Bi,...Si,...Ai,...ei,...Ci,...ri,...ni,...Ii},Py={...Di,...Ui};function oa(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var na=oa("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ri=oa("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=vt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),dh={utf8:na,"utf-8":na,hex:Jr.base16,latin1:Ri,ascii:Ri,binary:Ri,...Jr},so=dh;function jt(r,t="utf8"){let e=so[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Mi(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return vt(s);o+s>t&&(n=vt(t),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Ve=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Oi(){}var Ki=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},hh=Mi();function ph(r){return globalThis.Buffer!=null?vt(r):hh(r)}var en=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ve(Oi,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Ve(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Vi((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(co,10,Mt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Mt.fromBigInt(t);return this._push(co,e.length(),e)}uint64Number(t){return this._push(mi,ft(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=Mt.fromBigInt(t).zzEncode();return this._push(co,e.length(),e)}sint64Number(t){let e=Mt.fromNumber(t).zzEncode();return this._push(co,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Fi,1,t?1:0)}fixed32(t){return this._push(tn,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Mt.fromBigInt(t);return this._push(tn,4,e.lo)._push(tn,4,e.hi)}fixed64Number(t){let e=Mt.fromNumber(t);return this._push(tn,4,e.lo)._push(tn,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Mc,4,t)}double(t){return this._push(Fc,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Fi,1,0):this.uint32(e)._push(gh,e,t)}string(t){let e=Hc(t);return e!==0?this.uint32(e)._push(wi,e,t):this._push(Fi,1,0)}fork(){return this.states=new Ki(this),this.head=this.tail=new Ve(Oi,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 Ve(Oi,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=ph(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Fi(r,t,e){t[e]=r&255}function mh(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Vi=class extends Ve{next;constructor(t,e){super(mh,t,e),this.next=void 0}};function co(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function tn(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function gh(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(en.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(yh,t,r),this},en.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(xh,t,r),this});function yh(r,t,e){t.set(r,e)}function xh(r,t,e){r.length<40?wi(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(jt(r),e)}function Hi(){return new en}function It(r,t){let e=Hi();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var lr;(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"})(lr||(lr={}));function ao(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function rn(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,s){let c=t(i);s.int32(c)},n=function(i){let s=i.int32();return t(s)};return ao("enum",lr.VARINT,e,n)}function Ct(r,t){return ao("message",lr.LENGTH_DELIMITED,r,t)}var he=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var $;(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"})($||($={}));var uo;(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"})(uo||(uo={}));(function(r){r.codec=()=>rn(uo)})($||($={}));var Lt;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.type!=null&&e.type!==0&&(n.uint32(8),n.uint32(e.type)),e.value!=null&&(n.uint32(18),n.bytes(e.value)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={type:0},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.type=e.uint32();break}case 2:{i.value=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Lt||(Lt={}));var Bt;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.type!=null&&uo[e.type]!==0&&(n.uint32(8),$.codec().encode(e.type,n)),e.message!=null&&e.message.byteLength>0&&(n.uint32(18),n.bytes(e.message)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={type:$.invokeMethod,message:Qt(0)},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.type=$.codec().decode(e);break}case 2:{i.message=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Bt||(Bt={}));var He;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.path!=null&&e.path!==""&&(n.uint32(18),n.string(e.path)),e.args!=null)for(let i of e.args)n.uint32(26),Lt.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",path:"",args:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.path=e.string();break}case 3:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new he('Decode error - map field "args" had too many elements');i.args.push(Lt.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(He||(He={}));var nn;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(nn||(nn={}));var fr;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.value!=null&&(n.uint32(18),Lt.codec().encode(e.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.value=Lt.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(fr||(fr={}));var on;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.error!=null&&(n.uint32(18),Lt.codec().encode(e.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.error=Lt.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(on||(on={}));var dr;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);if(e.callback!=null&&e.callback!==""&&(n.uint32(26),n.string(e.callback)),e.args!=null)for(let i of e.args)n.uint32(34),Lt.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[],callback:"",args:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new he('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.callback=e.string();break}case 4:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new he('Decode error - map field "args" had too many elements');i.args.push(Lt.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(dr||(dr={}));var hr;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new he('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(hr||(hr={}));var sn;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);e.value!=null&&(n.uint32(26),Lt.codec().encode(e.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new he('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.value=Lt.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(sn||(sn={}));var cn;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);e.error!=null&&(n.uint32(26),Lt.codec().encode(e.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new he('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.error=Lt.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(cn||(cn={}));function bh(r){return r.parents!=null}function ia(r,t){if(bh(r))return wh(r.parents,t);let e=t.get(r.scope);if(e==null)throw new ro;return e}function wh(r,t){let e;for(let n of r){if(e==null){if(e=t.get(n),e==null)throw new sr;continue}if(e=e.children.get(n),e==null)throw new sr}if(e==null)throw new sr;return e}var Eh={type:1024,canEncode:r=>r===void 0,decode:()=>{}},sa=Eh;var vh={type:1025,canEncode:r=>r===null,decode:()=>null},ca=vh;var Sh=["string","number","bigint","symbol"],Ah=["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 aa(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let t=typeof r;if(Sh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(r))return"Array";if(_h(r))return"Buffer";let e=Ih(r);return e||"Object"}function _h(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Ih(r){let t=Object.prototype.toString.call(r).slice(8,-1);if(Ah.includes(t))return t}var h=class{constructor(t,e,n){this.major=t,this.majorEncoded=t<<5,this.name=e,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};h.uint=new h(0,"uint",!0);h.negint=new h(1,"negint",!0);h.bytes=new h(2,"bytes",!0);h.string=new h(3,"string",!0);h.array=new h(4,"array",!1);h.map=new h(5,"map",!1);h.tag=new h(6,"tag",!1);h.float=new h(7,"float",!0);h.false=new h(7,"false",!0);h.true=new h(7,"true",!0);h.null=new h(7,"null",!0);h.undefined=new h(7,"undefined",!0);h.break=new h(7,"break",!0);var k=class{constructor(t,e,n){this.type=t,this.value=e,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var pr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Ch=new TextDecoder,Bh=new TextEncoder;function lo(r){return pr&&globalThis.Buffer.isBuffer(r)}function zi(r){return r instanceof Uint8Array?lo(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var da=pr?(r,t,e)=>e-t>64?globalThis.Buffer.from(r.subarray(t,e)).toString("utf8"):la(r,t,e):(r,t,e)=>e-t>64?Ch.decode(r.subarray(t,e)):la(r,t,e),ha=pr?r=>r.length>64?globalThis.Buffer.from(r):ua(r):r=>r.length>64?Bh.encode(r):ua(r),ie=r=>Uint8Array.from(r),mr=pr?(r,t,e)=>lo(r)?new Uint8Array(r.subarray(t,e)):r.slice(t,e):(r,t,e)=>r.slice(t,e),pa=pr?(r,t)=>(r=r.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),zi(globalThis.Buffer.concat(r,t))):(r,t)=>{let e=new Uint8Array(t),n=0;for(let o of r)n+o.length>e.length&&(o=o.subarray(0,e.length-n)),e.set(o,n),n+=o.length;return e},ma=pr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function ga(r,t){if(lo(r)&&lo(t))return r.compare(t);for(let e=0;e<r.length;e++)if(r[e]!==t[e])return r[e]<t[e]?-1:1;return 0}function ua(r){let t=[],e=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=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),t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128)}return t}function la(r,t,e){let n=[];for(;t<e;){let o=r[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=e){let c,a,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:c=r[t+1],(c&192)===128&&(u=(o&31)<<6|c&63,u>127&&(i=u));break;case 3:c=r[t+1],a=r[t+2],(c&192)===128&&(a&192)===128&&(u=(o&15)<<12|(c&63)<<6|a&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:c=r[t+1],a=r[t+2],l=r[t+3],(c&192)===128&&(a&192)===128&&(l&192)===128&&(u=(o&15)<<18|(c&63)<<12|(a&63)<<6|l&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return kh(n)}var fa=4096;function kh(r){let t=r.length;if(t<=fa)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=fa));return e}var Th=256,an=class{constructor(t=Th){this.chunkSize=t,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(t){let e=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=e.length-(this.maxCursor-this.cursor)-1;e.set(t,o)}else{if(e){let o=e.length-(this.maxCursor-this.cursor)-1;o<e.length&&(this.chunks[this.chunks.length-1]=e.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(e=ma(this.chunkSize),this.chunks.push(e),this.maxCursor+=e.length,this._initReuseChunk===null&&(this._initReuseChunk=e),e.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let e;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(e=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):e=mr(n,0,this.cursor)}else e=pa(this.chunks,this.cursor);return t&&this.reset(),e}};var F="CBOR decode error:",qi="CBOR encode error:",un=[];un[23]=1;un[24]=2;un[25]=3;un[26]=5;un[27]=9;function pe(r,t,e){if(r.length-t<e)throw new Error(`${F} not enough data for type`)}var dt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ot(r,t,e){pe(r,t,1);let n=r[t];if(e.strict===!0&&n<dt[0])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Ft(r,t,e){pe(r,t,2);let n=r[t]<<8|r[t+1];if(e.strict===!0&&n<dt[1])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Kt(r,t,e){pe(r,t,4);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];if(e.strict===!0&&n<dt[2])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Vt(r,t,e){pe(r,t,8);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3],o=r[t+4]*16777216+(r[t+5]<<16)+(r[t+6]<<8)+r[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(e.strict===!0&&i<dt[3])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(e.allowBigInt===!0)return i;throw new Error(`${F} integers outside of the safe integer range are not supported`)}function ya(r,t,e,n){return new k(h.uint,Ot(r,t+1,n),2)}function xa(r,t,e,n){return new k(h.uint,Ft(r,t+1,n),3)}function ba(r,t,e,n){return new k(h.uint,Kt(r,t+1,n),5)}function wa(r,t,e,n){return new k(h.uint,Vt(r,t+1,n),9)}function Gt(r,t){return yt(r,0,t.value)}function yt(r,t,e){if(e<dt[0]){let n=Number(e);r.push([t|n])}else if(e<dt[1]){let n=Number(e);r.push([t|24,n])}else if(e<dt[2]){let n=Number(e);r.push([t|25,n>>>8,n&255])}else if(e<dt[3]){let n=Number(e);r.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(e);if(n<dt[4]){let o=[t|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(`${F} encountered BigInt larger than allowable range`)}}Gt.encodedSize=function(t){return yt.encodedSize(t.value)};yt.encodedSize=function(t){return t<dt[0]?1:t<dt[1]?2:t<dt[2]?3:t<dt[3]?5:9};Gt.compareTokens=function(t,e){return t.value<e.value?-1:t.value>e.value?1:0};function Ea(r,t,e,n){return new k(h.negint,-1-Ot(r,t+1,n),2)}function va(r,t,e,n){return new k(h.negint,-1-Ft(r,t+1,n),3)}function Sa(r,t,e,n){return new k(h.negint,-1-Kt(r,t+1,n),5)}var $i=BigInt(-1),Aa=BigInt(1);function _a(r,t,e,n){let o=Vt(r,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new k(h.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${F} integers outside of the safe integer range are not supported`);return new k(h.negint,$i-BigInt(o),9)}function fo(r,t){let e=t.value,n=typeof e=="bigint"?e*$i-Aa:e*-1-1;yt(r,t.type.majorEncoded,n)}fo.encodedSize=function(t){let e=t.value,n=typeof e=="bigint"?e*$i-Aa:e*-1-1;return n<dt[0]?1:n<dt[1]?2:n<dt[2]?3:n<dt[3]?5:9};fo.compareTokens=function(t,e){return t.value<e.value?1:t.value>e.value?-1:0};function ln(r,t,e,n){pe(r,t,e+n);let o=mr(r,t+e,t+e+n);return new k(h.bytes,o,e+n)}function Ia(r,t,e,n){return ln(r,t,1,e)}function Ca(r,t,e,n){return ln(r,t,2,Ot(r,t+1,n))}function Ba(r,t,e,n){return ln(r,t,3,Ft(r,t+1,n))}function ka(r,t,e,n){return ln(r,t,5,Kt(r,t+1,n))}function Ta(r,t,e,n){let o=Vt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer bytes lengths not supported`);return ln(r,t,9,o)}function ho(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===h.string?ha(r.value):r.value),r.encodedBytes}function gr(r,t){let e=ho(t);yt(r,t.type.majorEncoded,e.length),r.push(e)}gr.encodedSize=function(t){let e=ho(t);return yt.encodedSize(e.length)+e.length};gr.compareTokens=function(t,e){return Lh(ho(t),ho(e))};function Lh(r,t){return r.length<t.length?-1:r.length>t.length?1:ga(r,t)}function fn(r,t,e,n,o){let i=e+n;pe(r,t,i);let s=new k(h.string,da(r,t+e,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=mr(r,t+e,t+i)),s}function Ua(r,t,e,n){return fn(r,t,1,e,n)}function La(r,t,e,n){return fn(r,t,2,Ot(r,t+1,n),n)}function Pa(r,t,e,n){return fn(r,t,3,Ft(r,t+1,n),n)}function Da(r,t,e,n){return fn(r,t,5,Kt(r,t+1,n),n)}function Na(r,t,e,n){let o=Vt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer string lengths not supported`);return fn(r,t,9,o,n)}var Ra=gr;function yr(r,t,e,n){return new k(h.array,n,e)}function Ma(r,t,e,n){return yr(r,t,1,e)}function Oa(r,t,e,n){return yr(r,t,2,Ot(r,t+1,n))}function Fa(r,t,e,n){return yr(r,t,3,Ft(r,t+1,n))}function Ka(r,t,e,n){return yr(r,t,5,Kt(r,t+1,n))}function Va(r,t,e,n){let o=Vt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer array lengths not supported`);return yr(r,t,9,o)}function Ha(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return yr(r,t,1,1/0)}function po(r,t){yt(r,h.array.majorEncoded,t.value)}po.compareTokens=Gt.compareTokens;po.encodedSize=function(t){return yt.encodedSize(t.value)};function xr(r,t,e,n){return new k(h.map,n,e)}function za(r,t,e,n){return xr(r,t,1,e)}function qa(r,t,e,n){return xr(r,t,2,Ot(r,t+1,n))}function $a(r,t,e,n){return xr(r,t,3,Ft(r,t+1,n))}function ja(r,t,e,n){return xr(r,t,5,Kt(r,t+1,n))}function Ga(r,t,e,n){let o=Vt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer map lengths not supported`);return xr(r,t,9,o)}function Za(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return xr(r,t,1,1/0)}function mo(r,t){yt(r,h.map.majorEncoded,t.value)}mo.compareTokens=Gt.compareTokens;mo.encodedSize=function(t){return yt.encodedSize(t.value)};function Ya(r,t,e,n){return new k(h.tag,e,1)}function Wa(r,t,e,n){return new k(h.tag,Ot(r,t+1,n),2)}function Xa(r,t,e,n){return new k(h.tag,Ft(r,t+1,n),3)}function Qa(r,t,e,n){return new k(h.tag,Kt(r,t+1,n),5)}function Ja(r,t,e,n){return new k(h.tag,Vt(r,t+1,n),9)}function go(r,t){yt(r,h.tag.majorEncoded,t.value)}go.compareTokens=Gt.compareTokens;go.encodedSize=function(t){return yt.encodedSize(t.value)};var Oh=20,Fh=21,Kh=22,Vh=23;function tu(r,t,e,n){if(n.allowUndefined===!1)throw new Error(`${F} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new k(h.null,null,1):new k(h.undefined,void 0,1)}function eu(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return new k(h.break,void 0,1)}function ji(r,t,e){if(e){if(e.allowNaN===!1&&Number.isNaN(r))throw new Error(`${F} NaN values are not supported`);if(e.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${F} Infinity values are not supported`)}return new k(h.float,r,t)}function ru(r,t,e,n){return ji(Gi(r,t+1),3,n)}function nu(r,t,e,n){return ji(Zi(r,t+1),5,n)}function ou(r,t,e,n){return ji(au(r,t+1),9,n)}function yo(r,t,e){let n=t.value;if(n===!1)r.push([h.float.majorEncoded|Oh]);else if(n===!0)r.push([h.float.majorEncoded|Fh]);else if(n===null)r.push([h.float.majorEncoded|Kh]);else if(n===void 0)r.push([h.float.majorEncoded|Vh]);else{let o,i=!1;(!e||e.float64!==!0)&&(su(n),o=Gi(ee,1),n===o||Number.isNaN(n)?(ee[0]=249,r.push(ee.slice(0,3)),i=!0):(cu(n),o=Zi(ee,1),n===o&&(ee[0]=250,r.push(ee.slice(0,5)),i=!0))),i||(Hh(n),o=au(ee,1),ee[0]=251,r.push(ee.slice(0,9)))}}yo.encodedSize=function(t,e){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!e||e.float64!==!0){su(n);let o=Gi(ee,1);if(n===o||Number.isNaN(n))return 3;if(cu(n),o=Zi(ee,1),n===o)return 5}return 9};var iu=new ArrayBuffer(9),Zt=new DataView(iu,1),ee=new Uint8Array(iu,0);function su(r){if(r===1/0)Zt.setUint16(0,31744,!1);else if(r===-1/0)Zt.setUint16(0,64512,!1);else if(Number.isNaN(r))Zt.setUint16(0,32256,!1);else{Zt.setFloat32(0,r);let t=Zt.getUint32(0),e=(t&2139095040)>>23,n=t&8388607;if(e===255)Zt.setUint16(0,31744,!1);else if(e===0)Zt.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=e-127;o<-24?Zt.setUint16(0,0):o<-14?Zt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Zt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Gi(r,t){if(r.length-t<2)throw new Error(`${F} not enough data for float16`);let e=(r[t]<<8)+r[t+1];if(e===31744)return 1/0;if(e===64512)return-1/0;if(e===32256)return NaN;let n=e>>10&31,o=e&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,e&32768?-i:i}function cu(r){Zt.setFloat32(0,r,!1)}function Zi(r,t){if(r.length-t<4)throw new Error(`${F} not enough data for float32`);let e=(r.byteOffset||0)+t;return new DataView(r.buffer,e,4).getFloat32(0,!1)}function Hh(r){Zt.setFloat64(0,r,!1)}function au(r,t){if(r.length-t<8)throw new Error(`${F} not enough data for float64`);let e=(r.byteOffset||0)+t;return new DataView(r.buffer,e,8).getFloat64(0,!1)}yo.compareTokens=Gt.compareTokens;function j(r,t,e){throw new Error(`${F} encountered invalid minor (${e}) for major ${r[t]>>>5}`)}function xo(r){return()=>{throw new Error(`${F} ${r}`)}}var C=[];for(let r=0;r<=23;r++)C[r]=j;C[24]=ya;C[25]=xa;C[26]=ba;C[27]=wa;C[28]=j;C[29]=j;C[30]=j;C[31]=j;for(let r=32;r<=55;r++)C[r]=j;C[56]=Ea;C[57]=va;C[58]=Sa;C[59]=_a;C[60]=j;C[61]=j;C[62]=j;C[63]=j;for(let r=64;r<=87;r++)C[r]=Ia;C[88]=Ca;C[89]=Ba;C[90]=ka;C[91]=Ta;C[92]=j;C[93]=j;C[94]=j;C[95]=xo("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)C[r]=Ua;C[120]=La;C[121]=Pa;C[122]=Da;C[123]=Na;C[124]=j;C[125]=j;C[126]=j;C[127]=xo("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)C[r]=Ma;C[152]=Oa;C[153]=Fa;C[154]=Ka;C[155]=Va;C[156]=j;C[157]=j;C[158]=j;C[159]=Ha;for(let r=160;r<=183;r++)C[r]=za;C[184]=qa;C[185]=$a;C[186]=ja;C[187]=Ga;C[188]=j;C[189]=j;C[190]=j;C[191]=Za;for(let r=192;r<=215;r++)C[r]=Ya;C[216]=Wa;C[217]=Xa;C[218]=Qa;C[219]=Ja;C[220]=j;C[221]=j;C[222]=j;C[223]=j;for(let r=224;r<=243;r++)C[r]=xo("simple values are not supported");C[244]=j;C[245]=j;C[246]=j;C[247]=tu;C[248]=xo("simple values are not supported");C[249]=ru;C[250]=nu;C[251]=ou;C[252]=j;C[253]=j;C[254]=j;C[255]=eu;var re=[];for(let r=0;r<24;r++)re[r]=new k(h.uint,r,1);for(let r=-1;r>=-24;r--)re[31-r]=new k(h.negint,r,1);re[64]=new k(h.bytes,new Uint8Array(0),1);re[96]=new k(h.string,"",1);re[128]=new k(h.array,0,1);re[160]=new k(h.map,0,1);re[244]=new k(h.false,!1,1);re[245]=new k(h.true,!0,1);re[246]=new k(h.null,null,1);function uu(r){switch(r.type){case h.false:return ie([244]);case h.true:return ie([245]);case h.null:return ie([246]);case h.bytes:return r.value.length?void 0:ie([64]);case h.string:return r.value===""?ie([96]):void 0;case h.array:return r.value===0?ie([128]):void 0;case h.map:return r.value===0?ie([160]):void 0;case h.uint:return r.value<24?ie([Number(r.value)]):void 0;case h.negint:if(r.value>=-24)return ie([31-Number(r.value)])}}var qh={float64:!1,mapSorter:Gh,quickEncodeToken:uu};function $h(){let r=[];return r[h.uint.major]=Gt,r[h.negint.major]=fo,r[h.bytes.major]=gr,r[h.string.major]=Ra,r[h.array.major]=po,r[h.map.major]=mo,r[h.tag.major]=go,r[h.float.major]=yo,r}var lu=$h(),Yi=new an,wo=class r{constructor(t,e){this.obj=t,this.parent=e}includes(t){let e=this;do if(e.obj===t)return!0;while(e=e.parent);return!1}static createCheck(t,e){if(t&&t.includes(e))throw new Error(`${qi} object contains circular references`);return new r(e,t)}},ke={null:new k(h.null,null),undefined:new k(h.undefined,void 0),true:new k(h.true,!0),false:new k(h.false,!1),emptyArray:new k(h.array,0),emptyMap:new k(h.map,0)},Te={number(r,t,e,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new k(h.float,r):r>=0?new k(h.uint,r):new k(h.negint,r)},bigint(r,t,e,n){return r>=BigInt(0)?new k(h.uint,r):new k(h.negint,r)},Uint8Array(r,t,e,n){return new k(h.bytes,r)},string(r,t,e,n){return new k(h.string,r)},boolean(r,t,e,n){return r?ke.true:ke.false},null(r,t,e,n){return ke.null},undefined(r,t,e,n){return ke.undefined},ArrayBuffer(r,t,e,n){return new k(h.bytes,new Uint8Array(r))},DataView(r,t,e,n){return new k(h.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,t,e,n){if(!r.length)return e.addBreakTokens===!0?[ke.emptyArray,new k(h.break)]:ke.emptyArray;n=wo.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=bo(s,e,n);return e.addBreakTokens?[new k(h.array,r.length),o,new k(h.break)]:[new k(h.array,r.length),o]},Object(r,t,e,n){let o=t!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return e.addBreakTokens===!0?[ke.emptyMap,new k(h.break)]:ke.emptyMap;n=wo.createCheck(n,r);let c=[],a=0;for(let l of i)c[a++]=[bo(l,e,n),bo(o?r.get(l):r[l],e,n)];return jh(c,e),e.addBreakTokens?[new k(h.map,s),c,new k(h.break)]:[new k(h.map,s),c]}};Te.Map=Te.Object;Te.Buffer=Te.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Te[`${r}Array`]=Te.DataView;function bo(r,t={},e){let n=aa(r),o=t&&t.typeEncoders&&t.typeEncoders[n]||Te[n];if(typeof o=="function"){let s=o(r,n,t,e);if(s!=null)return s}let i=Te[n];if(!i)throw new Error(`${qi} unsupported type: ${n}`);return i(r,n,t,e)}function jh(r,t){t.mapSorter&&r.sort(t.mapSorter)}function Gh(r,t){let e=Array.isArray(r[0])?r[0][0]:r[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(e.type!==n.type)return e.type.compare(n.type);let o=e.type.major,i=lu[o].compareTokens(e,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function fu(r,t,e,n){if(Array.isArray(t))for(let o of t)fu(r,o,e,n);else e[t.type.major](r,t,n)}function Zh(r,t,e){let n=bo(r,e);if(!Array.isArray(n)&&e.quickEncodeToken){let o=e.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,e),c=new an(s);if(i(c,n,e),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return zi(c.chunks[0])}}return Yi.reset(),fu(Yi,n,t,e),Yi.toBytes(!0)}function X(r,t){return t=Object.assign({},qh,t),Zh(r,lu,t)}var Yh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Eo=class{constructor(t,e={}){this._pos=0,this.data=t,this.options=e}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],e=re[t];if(e===void 0){let n=C[t];if(!n)throw new Error(`${F} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;e=n(this.data,this._pos,o,this.options)}return this._pos+=e.encodedLength,e}},dn=Symbol.for("DONE"),vo=Symbol.for("BREAK");function Wh(r,t,e){let n=[];for(let o=0;o<r.value;o++){let i=br(t,e);if(i===vo){if(r.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed array`)}if(i===dn)throw new Error(`${F} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Xh(r,t,e){let n=e.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let c=br(t,e);if(c===vo){if(r.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed map`)}if(c===dn)throw new Error(`${F} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${F} non-string keys not supported (got ${typeof c})`);if(e.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${F} found repeat map key "${c}"`);let a=br(t,e);if(a===dn)throw new Error(`${F} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(c,a):o[c]=a}return n?i:o}function br(r,t){if(r.done())return dn;let e=r.next();if(e.type===h.break)return vo;if(e.type.terminal)return e.value;if(e.type===h.array)return Wh(e,r,t);if(e.type===h.map)return Xh(e,r,t);if(e.type===h.tag){if(t.tags&&typeof t.tags[e.value]=="function"){let n=br(r,t);return t.tags[e.value](n)}throw new Error(`${F} tag not supported (${e.value})`)}throw new Error("unsupported")}function du(r,t){if(!(r instanceof Uint8Array))throw new Error(`${F} data to decode must be a Uint8Array`);t=Object.assign({},Yh,t);let e=t.tokenizer||new Eo(r,t),n=br(e,t);if(n===dn)throw new Error(`${F} did not find any content to decode`);if(n===vo)throw new Error(`${F} got unexpected break`);return[n,r.subarray(e.pos())]}function Q(r,t){let[e,n]=du(r,t);if(n.length>0)throw new Error(`${F} too many terminals, data makes no sense`);return e}var Qh={type:1026,canEncode:r=>r===!0||r===!1,encode:r=>X(r),decode:r=>Q(r)},hu=Qh;var Jh={type:1027,canEncode:r=>typeof r=="number"&&!isNaN(r),encode:r=>X(r),decode:r=>Q(r)},pu=Jh;var tp={type:1028,canEncode:r=>typeof r=="string",encode:r=>X(r),decode:r=>Q(r)},mu=tp;var ep={type:1029,canEncode:r=>Array.isArray(r),encode:(r,t,e,n)=>X(r.map(o=>t.toValue(o,e,n))),decode:(r,t,e,n)=>Q(r).map(o=>t.fromValue(o,e,n))},gu=ep;var rp={type:1030,canEncode:r=>typeof r=="function",encode:(r,t,e,n)=>{let o=ir();return n?.callbacks.set(o,{context:e,fn:r}),X(o)},decode:(r,t,e,n)=>async(...o)=>new Promise((i,s)=>{let c=Q(r),a=ir(),l={scope:a,result:Et(),callbacks:new Map,children:new Map,parents:[...n.parents,n.scope],abortControllers:[],abortSignals:[]};n.children.set(a,l),o=o.map(f=>t.toValue(f,null,l));let u=Re(l.abortSignals);u.addEventListener("abort",()=>{e.push(Bt.encode({type:$.abortCallbackInvocation,message:hr.encode({scope:a,parents:l.parents})}))}),e.push(Bt.encode({type:$.invokeCallback,message:dr.encode({scope:a,parents:l.parents,callback:c,args:o})})),l.result.promise.then(f=>{i(f)},f=>{s(f)}).finally(()=>{n.children.delete(a),u.clear()})})},yu=rp;var np={type:1031,canEncode:r=>r.toString()==="NaN"&&isNaN(r),decode:()=>NaN},xu=np;var op={type:1032,canEncode:r=>r instanceof Error,encode:r=>X({message:r.message,name:r.name,code:r.code,type:r.type,stack:r.stack}),decode:r=>{let t=Q(r),e=new Error(t.message);return e.name=t.name,e.stack=t.stack,e.code=t.code,e.type=t.type,e}},bu=op;var ip={type:1033,canEncode:r=>Array.isArray(r),encode:(r,t,e,n)=>{throw new Error("Promises are not supported")},decode:(r,t,e,n)=>{throw new Error("Promises are not supported")}},wu=ip;var Eu=["__defineGetter__","__defineSetter__","hasOwnProperty","__lookupGetter__","__lookupSetter__","isPrototypeOf","propertyIsEnumerable","toString","valueOf","__proto__","toLocaleString","constructor"],sp={type:2147483647,canEncode:r=>typeof r=="object",encode:(r,t,e,n)=>{let o={};for(let i in r)Eu.includes(i)||Object.hasOwn(r,i)&&(o[i]=r[i]);for(let i of Object.getOwnPropertyNames(Object.getPrototypeOf(r)))Eu.includes(i)||(o[i]=r[i]);return X([...Object.entries(o)].map(([i,s])=>[t.toValue(i,r,n),t.toValue(s,r,n)]))},decode:(r,t,e,n)=>{let o={};return Q(r).forEach(([s,c])=>{o[t.fromValue(s,e,n)]=t.fromValue(c,e,n)}),o}},hn=sp;var cp={type:1034,canEncode:r=>typeof r.next=="function"&&typeof r.throw=="function"&&typeof r.return=="function",encode:(r,t,e,n)=>hn.encode({next:r.next.bind(r),throw:r.throw.bind(r),return:r.return.bind(r)},t,e,n),decode:(r,t,e,n)=>{let o=hn.decode(r,t,e,n);return o[Symbol.asyncIterator]=()=>o,o}},vu=cp;var ap={type:1035,canEncode:r=>typeof r=="bigint",encode:r=>X(r),decode:r=>BigInt(Q(r))},Su=ap;var up={type:1036,canEncode:r=>r instanceof Map,encode:(r,t,e,n)=>X([...r.entries()].map(([o,i])=>[t.toValue(o,e,n),t.toValue(i,e,n)])),decode:(r,t,e,n)=>{let o=new Map;return Q(r).forEach(([s,c])=>{let a=t.fromValue(s,e,n),l=t.fromValue(c,e,n);o.set(a,l)}),o}},Au=up;var lp={type:1037,canEncode:r=>r instanceof Set,encode:(r,t,e,n)=>X([...r.values()].map(o=>t.toValue(o,e,n))),decode:(r,t,e,n)=>{let o=new Set;return Q(r).forEach(s=>{o.add(t.fromValue(s,e,n))}),o}},_u=lp;var fp={type:1038,canEncode:r=>r instanceof Uint8Array,encode:r=>r,decode:r=>r},Iu=fp;var dp={type:1039,canEncode:r=>r instanceof AbortSignal,encode:(r,t,e,n)=>(n?.abortSignals.push(r),new Uint8Array(0)),decode:(r,t,e,n)=>{let o=new AbortController;return n.abortControllers.push(o),o.signal}},Cu=dp;var hp={type:1040,canEncode:r=>r instanceof Date,encode:r=>X(r.toString()),decode:r=>new Date(Q(r))},Bu=hp;var pp={type:1041,canEncode:r=>r instanceof RegExp,encode:r=>X({source:r.source,flags:r.flags}),decode:r=>{let{source:t,flags:e}=Q(r);return new RegExp(t,e)}},ku=pp;var Tu=[sa,ca,hu,pu,mu,gu,yu,xu,bu,wu,vu,Su,Au,_u,Iu,Cu,Bu,ku,hn];var So=class{transformersMap;transformersList;constructor(t){this.transformersList=[...Tu,...t?.valueCodecs??[]].sort((e,n)=>e.type<n.type?-1:e.type>n.type?1:0),this.transformersMap={},this.transformersList.forEach(e=>{if(this.transformersMap[e.type]!=null)throw new Error(`Duplicate transformer type ${e.type}`);this.transformersMap[e.type]=e})}toValue(t,e,n){for(let o=0;o<this.transformersList.length;o++){let i=this.transformersList[o];if(i.canEncode(t))return{type:i.type,value:i.encode?.(t,this,e,n)}}throw new qr(`Unsupported value type "${t}"`)}fromValue(t,e,n){let o=this.transformersMap[t.type];if(o==null)throw new qr(`Unsupported value type "${t.type}"`);return o.decode(t.value??new Uint8Array(0),this,e,n)}};function mp(r){return r.isScope===!0}function gp(r){return r.type===$.invokeMethod||r.type===$.invokeGeneratorMethod||r.type===$.invokeCallback}var Wi=class{source;output;targets;invocations;values;messageHandlers;connected;constructor(t){this.output=nr(),this.source=Xn(this.output),this.connected=!1;let e=this.source.next;this.source.next=async(...n)=>(this.connected=!0,e.apply(this.source,n)),this.targets=new Map,this.invocations=new Map,this.values=new So(t),this.sink=this.sink.bind(this),this.messageHandlers={[$.invokeMethod]:{decoder:He,handler:this.handleInvokeMethod.bind(this)},[$.invokeGeneratorMethod]:{decoder:He,handler:this.handleInvokeGeneratorMethod.bind(this)},[$.abortMethodInvocation]:{decoder:nn,handler:this.handleAbortMethod.bind(this),isScope:!0},[$.methodResolved]:{decoder:fr,handler:this.handleMethodResolved.bind(this),isScope:!0},[$.methodRejected]:{decoder:on,handler:this.handleMethodRejected.bind(this),isScope:!0,isError:!0},[$.invokeCallback]:{decoder:dr,handler:this.handleInvokeCallback.bind(this),isScope:!0},[$.abortCallbackInvocation]:{decoder:hr,handler:this.handleAbortCallback.bind(this),isScope:!0},[$.callbackResolved]:{decoder:sn,handler:this.handleCallbackResolved.bind(this),isScope:!0},[$.callbackRejected]:{decoder:cn,handler:this.handleCallbackRejected.bind(this),isScope:!0,isError:!0}}}async sink(t){for await(let e of zr(t))try{let n=Bt.decode(e),o=this.messageHandlers[n.type];if(o==null)continue;let i=o.decoder.decode(n.message),s;if(mp(o))try{s=ia(i,this.invocations)}catch{continue}o.handler(i,s).catch(c=>{gp(n)&&this.sendError(i,c),this.invocations.delete(i.scope)}).finally(()=>{n.type===$.invokeMethod&&this.invocations.delete(i.scope)})}catch{continue}}sendError(t,e){t.parents!=null?this.output.push(Bt.encode({type:$.callbackRejected,message:cn.encode({scope:t.scope,parents:t.parents,error:this.values.toValue(e)})})):this.output.push(Bt.encode({type:$.methodRejected,message:on.encode({scope:t.scope,error:this.values.toValue(e)})}))}createClient(t,e){return this.proxy(t,e)}createTarget(t,e){if(this.targets.has(t))throw new to(`Cannot reuse RPC target name "${t}"`);this.targets.set(t,e)}async handleInvokeMethod(t){if(this.invocations.has(t.scope))throw new $r;let e=new Map,n=new Map,o={scope:t.scope,result:Et(),callbacks:e,children:n,parents:[],abortControllers:[],abortSignals:[]};this.invocations.set(t.scope,o);let i=this.lookupInvocationTarget(t.path),s=await i.fn.apply(i.context,t.args.map(c=>this.values.fromValue(c,this.output,o)));this.output.push(Bt.encode({type:$.methodResolved,message:fr.encode({scope:t.scope,value:this.values.toValue(s)})}))}async handleAbortMethod(t,e){e.abortControllers.forEach(n=>{n.abort()})}async handleInvokeGeneratorMethod(t){if(this.invocations.has(t.scope))throw new $r;let e=new Map,n=new Map,o={scope:t.scope,result:Et(),callbacks:e,children:n,parents:[],abortControllers:[],abortSignals:[]};this.invocations.set(t.scope,o);let i=this.lookupInvocationTarget(t.path),s=i.fn.apply(i.context,t.args.map(a=>this.values.fromValue(a,this.output,o)));if(typeof s.next!="function")throw new eo(`${t.path} did not return an async generator`);let c={next:async()=>{let a=await s.next();return a.done===!0&&this.invocations.delete(t.scope),a},throw:async a=>{try{let l=await s.throw(a);return l.done===!0&&this.invocations.delete(t.scope),l}catch(l){throw this.invocations.delete(t.scope),l}},return:async a=>{let l=await s.return(a);return l.done===!0&&this.invocations.delete(t.scope),l},[Symbol.asyncIterator]:()=>c};this.output.push(Bt.encode({type:$.methodResolved,message:fr.encode({scope:t.scope,value:this.values.toValue(c,null,o)})}))}lookupInvocationTarget(t){let e=t.split("."),n=this.targets.get(e[0]),o=n;for(let i=1;i<e.length;i++)o=n,n=n?.[e[i]];if(n==null)throw o!=null&&t.endsWith(".then")?new Jn(`"${t.substring(0,t.length-5)}" was not a function`):new Qn(`Could not find "${t}" on target`);if(typeof n!="function")throw new jr("Invocation target was not a function");return{context:o,fn:n}}async handleMethodResolved(t,e){let n;t.value!=null&&(n=this.values.fromValue(t.value,this.output,e)),e.result.resolve(n)}async handleMethodRejected(t,e){let n;t.error!=null&&(n=this.values.fromValue(t.error,this.output,e)),e.result.reject(n)}async handleInvokeCallback(t,e){let n=e.callbacks.get(t.callback);if(n==null)throw new no;let o=await n.fn.apply(n.context,t.args.map(i=>this.values.fromValue(i,this.output,e)));this.output.push(Bt.encode({type:$.callbackResolved,message:sn.encode({scope:t.scope,parents:t.parents,value:this.values.toValue(o)})}))}async handleAbortCallback(t,e){e.abortControllers.forEach(n=>{n.abort()})}async handleCallbackResolved(t,e){let n;t.value!=null&&(n=this.values.fromValue(t.value,this.output,e)),e.children.get(t.scope)?.result.resolve(n),e.children.delete(t.scope)}async handleCallbackRejected(t,e){let n;t.error!=null&&(n=this.values.fromValue(t.error,this.output,e)),e.children.get(t.scope)?.result.reject(n),e.children.delete(t.scope)}proxy(t,e){let n=()=>{},o=this;return new Proxy(n,{get(i,s,c){return o.proxy(`${t==null?"":`${t}.`}${s.toString()}`,e)},apply(i,s,c){let a,l;function u(){return l==null&&(l=new Promise((p,w)=>{let E=ir(),m={scope:E,result:Et(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]},x;e?.timeout!=null&&(x=AbortSignal.timeout(e.timeout),m.abortSignals.push(x)),o.invocations.set(E,m),o.output.push(Bt.encode({type:$.invokeMethod,message:He.encode({scope:E,path:t,args:c.map(P=>o.values.toValue(P,null,m))})}));let B=Re(m.abortSignals);B.addEventListener("abort",()=>{o.output.push(Bt.encode({type:$.abortMethodInvocation,message:nn.encode({scope:E})})),x?.aborted===!0?m.result.reject(new Oe):m.result.reject(new zn)}),m.result.promise.then(P=>{p(P)},P=>{w(P)}).finally(()=>{o.invocations.delete(E),B.clear()}),o.connected||m.result.reject(new Gr)})),l}function f(){if(a==null){let p=ir(),w={scope:p,result:Et(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};o.invocations.set(p,w),o.output.push(Bt.encode({type:$.invokeGeneratorMethod,message:He.encode({scope:p,path:t,args:c.map(m=>o.values.toValue(m,null,w))})}));let E;a={async next(){if(E!=null)throw E;let m=[...w.abortSignals],x;e?.timeout!=null&&(x=AbortSignal.timeout(e.timeout),m.push(x));let B=Re(m);try{let P=await le(w.result.promise,B),b=await le(P.next(),B);return b.done===!0&&o.invocations.delete(p),b}catch(P){throw o.invocations.delete(p),x?.aborted===!0?new Oe:P}finally{B.clear()}},async throw(m){if(E!=null)throw E;let x=[...w.abortSignals],B;e?.timeout!=null&&(B=AbortSignal.timeout(e.timeout),x.push(B));let P=Re(x);try{let b=await le(w.result.promise,P),d=await le(b.throw(m),P);return d.done===!0&&o.invocations.delete(p),d}catch(b){throw o.invocations.delete(p),E=m,B?.aborted===!0?(E=new Oe,E):b}finally{P.clear()}},async return(m){if(E!=null)throw E;let x=[...w.abortSignals],B;e?.timeout!=null&&(B=AbortSignal.timeout(e.timeout),x.push(B));let P=Re(x);try{let b=await le(w.result.promise,P),d=await le(b.return(m),P);return d.done===!0&&o.invocations.delete(p),d}catch(b){throw o.invocations.delete(p),B?.aborted===!0?new Oe:b}finally{P.clear()}},[Symbol.asyncIterator]:()=>a},o.connected||w.result.reject(new Gr)}return a}return new Proxy(n,{get(p,w,E){if(w==="then")return u().then.bind(l);if(w==="catch")return u().catch.bind(l);if(w==="finally")return u().finally.bind(l);if(w===Symbol.asyncIterator)return()=>f();if(w==="next")return f().next.bind(a);if(w==="return")return f().return.bind(a);if(w==="throw")return f().throw.bind(a);if(w===Symbol.toStringTag)return"[object Object]";if(w==="constructor")return()=>{};throw new jr(`Property ${w.toString()} was not used as a promise or async generator`)}})}})}};function Uu(r){return new Wi(r)}var Lu={type:4096,canEncode:r=>r.code!=null&&r.version!=null&&r.multihash!=null&&r["/"]!=null,encode:r=>r.bytes,decode:r=>ct.decode(r)};var pn=class extends Event{type;detail;constructor(t,e){super(t),this.type=t,this.detail=e}};var Pu={type:4099,canEncode:r=>r instanceof pn,encode:(r,t,e,n)=>X({type:r.type,detail:t.toValue(r.detail,e,n)}),decode:(r,t,e,n)=>{let{type:o,detail:i}=Q(r);return new pn(o,t.fromValue(i,e,n))}};function J(r,t="utf8"){let e=so[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Ao=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}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(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let i=0,s=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let p=Number.parseInt(f,t);if(!Number.isNaN(p))return p});if(u===void 0)break;if(i*=t,i+=u,i>l||(s+=1,e!==void 0&&s>e))return}if(s!==0)return!n&&a&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return e[o]=s[0],e[o+1]=s[1],e[o+2]=s[2],e[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];e[o]=i>>8,e[o+1]=i&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[c]=t(i.subarray(0,s));return e.set(i.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Du=45,yp=15,wr=new Ao;function Xi(r){if(!(r.length>yp))return wr.new(r).parseWith(()=>wr.readIPv4Addr())}function Qi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Du))return wr.new(r).parseWith(()=>wr.readIPv6Addr())}function _o(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Du)return;let e=wr.new(r).parseWith(()=>wr.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}var jw=parseInt("0xFFFF",16),Gw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Mu(r){return!!Xi(r)}function Ou(r){return!!Qi(r)}function Io(r){return!!_o(r)}var Fu=Mu,vp=Ou,Ji=function(r){let t=0;if(r=r.toString().trim(),Fu(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(vp(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=Fu(e[n]),s;i&&(s=Ji(e[n]),e[n]=J(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,J(s.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},Ku=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Er={},ts={},Ap=[[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"]];Ap.forEach(r=>{let t=_p(...r);ts[t.code]=t,Er[t.name]=t});function _p(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function tt(r){if(typeof r=="number"){if(ts[r]!=null)return ts[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Er[r]!=null)return Er[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var T1=tt("ip4"),U1=tt("ip6"),L1=tt("ipcidr");function os(r,t){switch(tt(r).code){case 4:case 41:return Cp(t);case 42:return ns(t);case 43:return J(t,"base10");case 6:case 273:case 33:case 132:return zu(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ns(t);case 421:return Up(t);case 444:return Hu(t);case 445:return Hu(t);case 466:return Tp(t);case 481:return globalThis.encodeURIComponent(ns(t));default:return J(t,"base16")}}function is(r,t){switch(tt(r).code){case 4:return Vu(t);case 41:return Vu(t);case 42:return rs(t);case 43:return jt(t,"base10");case 6:case 273:case 33:case 132:return ss(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return rs(t);case 421:return Bp(t);case 444:return Lp(t);case 445:return Pp(t);case 466:return kp(t);case 481:return rs(globalThis.decodeURIComponent(t));default:return jt(t,"base16")}}var es=Object.values(Jr).map(r=>r.decoder),Ip=function(){let r=es[0].or(es[1]);return es.slice(2).forEach(t=>r=r.or(t)),r}();function Vu(r){if(!Io(r))throw new Error("invalid ip address");return Ji(r)}function Cp(r){let t=Ku(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Io(t))throw new Error("invalid ip address");return t}function ss(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function zu(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function rs(r){let t=jt(r),e=Uint8Array.from(Ie(t.length));return Nt([e,t],e.length+t.length)}function ns(r){let t=fe(r);if(r=r.slice(ft(t)),r.length!==t)throw new Error("inconsistent lengths");return J(r)}function Bp(r){let t;r[0]==="Q"||r[0]==="1"?t=de(et.decode(`z${r}`)).bytes:t=ct.parse(r).multihash.bytes;let e=Uint8Array.from(Ie(t.length));return Nt([e,t],e.length+t.length)}function kp(r){let t=Ip.decode(r),e=Uint8Array.from(Ie(t.length));return Nt([e,t],e.length+t.length)}function Tp(r){let t=fe(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+J(e,"base64url")}function Up(r){let t=fe(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return J(e,"base58btc")}function Lp(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Wt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ss(n);return Nt([e,o],e.length+o.length)}function Pp(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Wt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ss(n);return Nt([e,o],e.length+o.length)}function Hu(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=J(t,"base32"),o=zu(e);return`${n}:${o}`}function qu(r){r=cs(r);let t=[],e=[],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=tt(s);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(i++,i>=o.length)throw new Co("invalid address: "+r);if(c.path===!0){n=cs(o.slice(i).join("/")),t.push([c.code,is(c.code,n)]),e.push([c.code,n]);break}let a=is(c.code,o[i]);t.push([c.code,a]),e.push([c.code,os(c.code,a)])}return{string:$u(e),bytes:Bo(t),tuples:t,stringTuples:e,path:n}}function as(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=fe(r,o),s=ft(i),c=tt(i),a=Dp(c,r.slice(o+s));if(a===0){t.push([i]),e.push([i]),o+=s;continue}let l=r.slice(o+s,o+s+a);if(o+=a+s,o>r.length)throw new Co("Invalid address Uint8Array: "+J(r,"base16"));t.push([i,l]);let u=os(i,l);if(e.push([i,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:$u(e),tuples:t,stringTuples:e,path:n}}function $u(r){let t=[];return r.map(e=>{let n=tt(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),cs(t.join("/"))}function Bo(r){return Nt(r.map(t=>{let e=tt(t[0]),n=Uint8Array.from(Ie(e.code));return t.length>1&&t[1]!=null&&(n=Nt([n,t[1]])),n}))}function Dp(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=fe(t instanceof Uint8Array?t:Uint8Array.from(t));return e+ft(e)}}function cs(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var Co=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Np=Symbol.for("nodejs.util.inspect.custom"),ls=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Rp=[tt("dns").code,tt("dns4").code,tt("dns6").code,tt("dnsaddr").code],us=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},ko=class r{bytes;#e;#t;#r;#n;[ls]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=as(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=qu(t)}else if(To(t))e=as(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",s=tt("tcp"),c=tt("udp"),a=tt("ip4"),l=tt("ip6"),u=tt("dns6"),f=tt("ip6zone");for(let[w,E]of this.stringTuples())w===f.code&&(i=`%${E??""}`),Rp.includes(w)&&(e=s.name==="tcp"?"tcp":"udp",o=443,n=`${E??""}${i}`,t=w===u.code?6:4),(w===s.code||w===c.code)&&(e=tt(w).name==="tcp"?"tcp":"udp",o=parseInt(E??"")),(w===a.code||w===l.code)&&(e=tt(w).name==="tcp"?"tcp":"udp",n=`${E??""}${i}`,t=w===l.code?6:4);if(t==null||e==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:t,host:n,transport:e,port:o}}protos(){return this.#t.map(([t])=>Object.assign({},tt(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>tt(t).name)}tuples(){return this.#t.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Bo(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Er.p2p.code&&t.push([n,o]),n===Er["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?J(et.decode(`z${n}`),"base58btc"):J(ct.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Rt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=ju.get(e.name);if(n==null)throw new us(`no available resolver for ${e.name}`);return(await n(this,t)).map(i=>qe(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Np](){return`Multiaddr(${this.#e})`}};var ju=new Map;function To(r){return!!r?.[ls]}function qe(r){return new ko(r)}var Gu={type:4097,canEncode:r=>To(r),encode:r=>r.bytes,decode:r=>qe(r)};var Mp=parseInt("11111",2),fs=parseInt("10000000",2),Op=parseInt("01111111",2),Zu={0:mn,1:mn,2:Fp,3:Hp,4:zp,5:Vp,6:Kp,16:mn,22:mn,48:mn};function ds(r,t={offset:0}){let e=r[t.offset]&Mp;if(t.offset++,Zu[e]!=null)return Zu[e](r,t);throw new Error("No decoder for tag "+e)}function gn(r,t){let e=0;if((r[t.offset]&fs)===fs){let n=r[t.offset]&Op,o="0x";t.offset++;for(let i=0;i<n;i++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function mn(r,t){gn(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=ds(r,t);if(n===null)break;e.push(n)}return e}function Fp(r,t){let e=gn(r,t),n=t.offset,o=t.offset+e,i=[];for(let s=n;s<o;s++)s===n&&r[s]===0||i.push(r[s]);return t.offset+=e,Uint8Array.from(i)}function Kp(r,t){let e=gn(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let c=`${i}.${s}`,a=[];for(;t.offset<n;){let l=r[t.offset];if(t.offset++,a.push(l&127),l<128){a.reverse();let u=0;for(let f=0;f<a.length;f++)u+=a[f]<<f*7;c+=`.${u}`,a=[]}}return c}function Vp(r,t){return t.offset++,null}function Hp(r,t){let e=gn(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function zp(r,t){let e=gn(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function qp(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new gt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function hs(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=qp(r.byteLength);return new gt(Uint8Array.from([t.byteLength|fs]),t)}function Yu(r){let t=new gt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new gt(Uint8Array.from([2]),hs(t),t)}function Wu(r){let t=Uint8Array.from([0]),e=new gt(t,r);return new gt(Uint8Array.from([3]),hs(e),e)}function Uo(r,t=48){let e=new gt;for(let n of r)e.append(n);return new gt(Uint8Array.from([t]),hs(e),e)}async function Xu(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var $p=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),jp=Uint8Array.from([6,5,43,129,4,0,34]),Gp=Uint8Array.from([6,5,43,129,4,0,35]),Zp={ext:!0,kty:"EC",crv:"P-256"},Yp={ext:!0,kty:"EC",crv:"P-384"},Wp={ext:!0,kty:"EC",crv:"P-521"},ps=32,ms=48,gs=66;function Qu(r){let t=ds(r);return Ju(t)}function Ju(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===ps*2+1)return n=J(t.subarray(e,e+ps),"base64url"),o=J(t.subarray(e+ps),"base64url"),new vr({...Zp,key_ops:["verify"],x:n,y:o});if(t.byteLength===ms*2+1)return n=J(t.subarray(e,e+ms),"base64url"),o=J(t.subarray(e+ms),"base64url"),new vr({...Yp,key_ops:["verify"],x:n,y:o});if(t.byteLength===gs*2+1)return n=J(t.subarray(e,e+gs),"base64url"),o=J(t.subarray(e+gs),"base64url"),new vr({...Wp,key_ops:["verify"],x:n,y:o});throw new qt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function tl(r){return Uo([Yu(Uint8Array.from([1])),Uo([Xp(r.crv)],160),Uo([Wu(new gt(Uint8Array.from([4]),jt(r.x??"","base64url"),jt(r.y??"","base64url")))],161)]).subarray()}function Xp(r){if(r==="P-256")return $p;if(r==="P-384")return jp;if(r==="P-521")return Gp;throw new qt(`Invalid curve ${r}`)}var vr=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=tl(this.jwk)),this._raw}toMultihash(){return te.digest(Sr(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Rt(this.raw,t.raw)}async verify(t,e){return Xu(this.jwk,e,t)}};var $e=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Qp(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Lo(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function je(r,...t){if(!Qp(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function el(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Lo(r.outputLen),Lo(r.blockLen)}function _r(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function rl(r,t){je(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function me(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function Po(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function ne(r,t){return r<<32-t|r>>>t}function nl(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function yn(r){return typeof r=="string"&&(r=nl(r)),je(r),r}function ys(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];je(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let i=r[n];e.set(i,o),o+=i.length}return e}var Ar=class{};function xs(r){let t=n=>r().update(yn(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Do(r=32){if($e&&typeof $e.getRandomValues=="function")return $e.getRandomValues(new Uint8Array(r));if($e&&typeof $e.randomBytes=="function")return Uint8Array.from($e.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Jp(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(e>>o&i),c=Number(e&i),a=n?4:0,l=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+l,c,n)}function ol(r,t,e){return r&t^~r&e}function il(r,t,e){return r&t^r&e^t&e}var xn=class extends Ar{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Po(this.buffer)}update(t){_r(this),t=yn(t),je(t);let{view:e,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=Po(t);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){_r(this),rl(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;e[s++]=128,me(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)e[f]=0;Jp(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=Po(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)c.setUint32(4*f,u[f],i)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=c,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},ge=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var xt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var No=BigInt(4294967295),sl=BigInt(32);function t0(r,t=!1){return t?{h:Number(r&No),l:Number(r>>sl&No)}:{h:Number(r>>sl&No)|0,l:Number(r&No)|0}}function cl(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let i=0;i<e;i++){let{h:s,l:c}=t0(r[i],t);[n[i],o[i]]=[s,c]}return[n,o]}var bs=(r,t,e)=>r>>>e,ws=(r,t,e)=>r<<32-e|t>>>e,Ge=(r,t,e)=>r>>>e|t<<32-e,Ze=(r,t,e)=>r<<32-e|t>>>e,bn=(r,t,e)=>r<<64-e|t>>>e-32,wn=(r,t,e)=>r>>>e-32|t<<64-e;function se(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var al=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),ul=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,ll=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),fl=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,dl=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),hl=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var r0=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ue=new Uint32Array(64),Es=class extends xn{constructor(t=32){super(64,t,8,!1),this.A=ge[0]|0,this.B=ge[1]|0,this.C=ge[2]|0,this.D=ge[3]|0,this.E=ge[4]|0,this.F=ge[5]|0,this.G=ge[6]|0,this.H=ge[7]|0}get(){let{A:t,B:e,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[t,e,n,o,i,s,c,a]}set(t,e,n,o,i,s,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,e){for(let f=0;f<16;f++,e+=4)Ue[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let p=Ue[f-15],w=Ue[f-2],E=ne(p,7)^ne(p,18)^p>>>3,m=ne(w,17)^ne(w,19)^w>>>10;Ue[f]=m+Ue[f-7]+E+Ue[f-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:l,H:u}=this;for(let f=0;f<64;f++){let p=ne(c,6)^ne(c,11)^ne(c,25),w=u+p+ol(c,a,l)+r0[f]+Ue[f]|0,m=(ne(n,2)^ne(n,13)^ne(n,22))+il(n,o,i)|0;u=l,l=a,a=c,c=s+w|0,s=i,i=o,o=n,n=w+m|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,l,u)}roundClean(){me(Ue)}destroy(){this.set(0,0,0,0,0,0,0,0),me(this.buffer)}};var pl=cl(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),n0=pl[0],o0=pl[1],Le=new Uint32Array(80),Pe=new Uint32Array(80),vs=class extends xn{constructor(t=64){super(128,t,16,!1),this.Ah=xt[0]|0,this.Al=xt[1]|0,this.Bh=xt[2]|0,this.Bl=xt[3]|0,this.Ch=xt[4]|0,this.Cl=xt[5]|0,this.Dh=xt[6]|0,this.Dl=xt[7]|0,this.Eh=xt[8]|0,this.El=xt[9]|0,this.Fh=xt[10]|0,this.Fl=xt[11]|0,this.Gh=xt[12]|0,this.Gl=xt[13]|0,this.Hh=xt[14]|0,this.Hl=xt[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:i,Cl:s,Dh:c,Dl:a,Eh:l,El:u,Fh:f,Fl:p,Gh:w,Gl:E,Hh:m,Hl:x}=this;return[t,e,n,o,i,s,c,a,l,u,f,p,w,E,m,x]}set(t,e,n,o,i,s,c,a,l,u,f,p,w,E,m,x){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=p|0,this.Gh=w|0,this.Gl=E|0,this.Hh=m|0,this.Hl=x|0}process(t,e){for(let b=0;b<16;b++,e+=4)Le[b]=t.getUint32(e),Pe[b]=t.getUint32(e+=4);for(let b=16;b<80;b++){let d=Le[b-15]|0,v=Pe[b-15]|0,T=Ge(d,v,1)^Ge(d,v,8)^bs(d,v,7),U=Ze(d,v,1)^Ze(d,v,8)^ws(d,v,7),L=Le[b-2]|0,O=Pe[b-2]|0,H=Ge(L,O,19)^bn(L,O,61)^bs(L,O,6),N=Ze(L,O,19)^wn(L,O,61)^ws(L,O,6),K=ll(U,N,Pe[b-7],Pe[b-16]),M=fl(K,T,H,Le[b-7],Le[b-16]);Le[b]=M|0,Pe[b]=K|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:p,Fh:w,Fl:E,Gh:m,Gl:x,Hh:B,Hl:P}=this;for(let b=0;b<80;b++){let d=Ge(f,p,14)^Ge(f,p,18)^bn(f,p,41),v=Ze(f,p,14)^Ze(f,p,18)^wn(f,p,41),T=f&w^~f&m,U=p&E^~p&x,L=dl(P,v,U,o0[b],Pe[b]),O=hl(L,B,d,T,n0[b],Le[b]),H=L|0,N=Ge(n,o,28)^bn(n,o,34)^bn(n,o,39),K=Ze(n,o,28)^wn(n,o,34)^wn(n,o,39),M=n&i^n&c^i&c,at=o&s^o&a^s&a;B=m|0,P=x|0,m=w|0,x=E|0,w=f|0,E=p|0,{h:f,l:p}=se(l|0,u|0,O|0,H|0),l=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let _=al(H,K,at);n=ul(_,O,N,M),o=_|0}({h:n,l:o}=se(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=se(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=se(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=se(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:p}=se(this.Eh|0,this.El|0,f|0,p|0),{h:w,l:E}=se(this.Fh|0,this.Fl|0,w|0,E|0),{h:m,l:x}=se(this.Gh|0,this.Gl|0,m|0,x|0),{h:B,l:P}=se(this.Hh|0,this.Hl|0,B|0,P|0),this.set(n,o,i,s,c,a,l,u,f,p,w,E,m,x,B,P)}roundClean(){me(Le,Pe)}destroy(){me(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ml=xs(()=>new Es);var gl=xs(()=>new vs);var Is=BigInt(0),_s=BigInt(1);function Ir(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Cs(r){if(!Ir(r))throw new Error("Uint8Array expected")}function ce(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function En(r){let t=r.toString(16);return t.length&1?"0"+t:t}function bl(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Is:BigInt("0x"+r)}var wl=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",i0=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function De(r){if(Cs(r),wl)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=i0[r[e]];return t}var ye={_0:48,_9:57,A:65,F:70,a:97,f:102};function yl(r){if(r>=ye._0&&r<=ye._9)return r-ye._0;if(r>=ye.A&&r<=ye.F)return r-(ye.A-10);if(r>=ye.a&&r<=ye.f)return r-(ye.a-10)}function vn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(wl)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,i=0;o<e;o++,i+=2){let s=yl(r.charCodeAt(i)),c=yl(r.charCodeAt(i+1));if(s===void 0||c===void 0){let a=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function xe(r){return bl(De(r))}function Ye(r){return Cs(r),bl(De(Uint8Array.from(r).reverse()))}function We(r,t){return vn(r.toString(16).padStart(t*2,"0"))}function Cr(r,t){return We(r,t).reverse()}function nt(r,t,e){let n;if(typeof t=="string")try{n=vn(t)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(Ir(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function Ne(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Cs(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let i=r[n];e.set(i,o),o+=i.length}return e}var Ss=r=>typeof r=="bigint"&&Is<=r;function Ro(r,t,e){return Ss(r)&&Ss(t)&&Ss(e)&&t<=r&&r<e}function Ht(r,t,e,n){if(!Ro(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function El(r){let t;for(t=0;r>Is;r>>=_s,t+=1);return t}var Xe=r=>(_s<<BigInt(r))-_s,As=r=>new Uint8Array(r),xl=r=>Uint8Array.from(r);function vl(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=As(r),o=As(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},c=(...f)=>e(o,n,...f),a=(f=As(0))=>{o=c(xl([0]),f),n=c(),f.length!==0&&(o=c(xl([1]),f),n=c())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,p=[];for(;f<t;){n=c();let w=n.slice();p.push(w),f+=n.length}return Ne(...p)};return(f,p)=>{s(),a(f);let w;for(;!(w=p(l()));)a();return s(),w}}var s0={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Ir(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function be(r,t,e={}){let n=(o,i,s)=>{let c=s0[i];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(s&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+a)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}function Br(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let i=r(e,...n);return t.set(e,i),i}}var kt=BigInt(0),ht=BigInt(1),Qe=BigInt(2),c0=BigInt(3),Al=BigInt(4),_l=BigInt(5),Il=BigInt(8);function W(r,t){let e=r%t;return e>=kt?e:t+e}function ot(r,t,e){let n=r;for(;t-- >kt;)n*=n,n%=e;return n}function Mo(r,t){if(r===kt)throw new Error("invert: expected non-zero number");if(t<=kt)throw new Error("invert: expected positive modulus, got "+t);let e=W(r,t),n=t,o=kt,i=ht,s=ht,c=kt;for(;e!==kt;){let l=n/e,u=n%e,f=o-s*l,p=i-c*l;n=e,e=u,o=s,i=c,s=f,c=p}if(n!==ht)throw new Error("invert: does not exist");return W(o,t)}function Cl(r,t){let e=(r.ORDER+ht)/Al,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function a0(r,t){let e=(r.ORDER-_l)/Il,n=r.mul(t,Qe),o=r.pow(n,e),i=r.mul(t,o),s=r.mul(r.mul(i,Qe),o),c=r.mul(i,r.sub(s,r.ONE));if(!r.eql(r.sqr(c),t))throw new Error("Cannot find square root");return c}function u0(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-ht,e=0;for(;t%Qe===kt;)t/=Qe,e++;let n=Qe,o=we(r);for(;Sl(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Cl;let i=o.pow(n,t),s=(t+ht)/Qe;return function(a,l){if(a.is0(l))return l;if(Sl(a,l)!==1)throw new Error("Cannot find square root");let u=e,f=a.mul(a.ONE,i),p=a.pow(l,t),w=a.pow(l,s);for(;!a.eql(p,a.ONE);){if(a.is0(p))return a.ZERO;let E=1,m=a.sqr(p);for(;!a.eql(m,a.ONE);)if(E++,m=a.sqr(m),E===u)throw new Error("Cannot find square root");let x=ht<<BigInt(u-E-1),B=a.pow(f,x);u=E,f=a.sqr(B),p=a.mul(p,f),w=a.mul(w,B)}return w}}function l0(r){return r%Al===c0?Cl:r%Il===_l?a0:u0(r)}var Bl=(r,t)=>(W(r,t)&ht)===ht,f0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Bs(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=f0.reduce((n,o)=>(n[o]="function",n),t);return be(r,e)}function d0(r,t,e){if(e<kt)throw new Error("invalid exponent, negatives unsupported");if(e===kt)return r.ONE;if(e===ht)return t;let n=r.ONE,o=t;for(;e>kt;)e&ht&&(n=r.mul(n,o)),o=r.sqr(o),e>>=ht;return n}function kr(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((s,c,a)=>r.is0(c)?s:(n[a]=s,r.mul(s,c)),r.ONE),i=r.inv(o);return t.reduceRight((s,c,a)=>r.is0(c)?s:(n[a]=r.mul(s,n[a]),r.mul(s,c)),i),n}function Sl(r,t){let e=(r.ORDER-ht)/Qe,n=r.pow(t,e),o=r.eql(n,r.ONE),i=r.eql(n,r.ZERO),s=r.eql(n,r.neg(r.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function ks(r,t){t!==void 0&&Lo(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function we(r,t,e=!1,n={}){if(r<=kt)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:i}=ks(r,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:i,MASK:Xe(o),ZERO:kt,ONE:ht,create:a=>W(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return kt<=a&&a<r},is0:a=>a===kt,isOdd:a=>(a&ht)===ht,neg:a=>W(-a,r),eql:(a,l)=>a===l,sqr:a=>W(a*a,r),add:(a,l)=>W(a+l,r),sub:(a,l)=>W(a-l,r),mul:(a,l)=>W(a*l,r),pow:(a,l)=>d0(c,a,l),div:(a,l)=>W(a*Mo(l,r),r),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>Mo(a,r),sqrt:n.sqrt||(a=>(s||(s=l0(r)),s(c,a))),toBytes:a=>e?Cr(a,i):We(a,i),fromBytes:a=>{if(a.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+a.length);return e?Ye(a):xe(a)},invertBatch:a=>kr(c,a),cmov:(a,l,u)=>u?l:a});return Object.freeze(c)}function kl(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Ts(r){let t=kl(r);return t+Math.ceil(t/2)}function Tl(r,t,e=!1){let n=r.length,o=kl(t),i=Ts(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=e?Ye(r):xe(r),c=W(s,t-ht)+ht;return e?Cr(c,o):We(c,o)}var Ul=BigInt(0),Ns=BigInt(1);function Us(r,t){let e=t.negate();return r?e:t}function Pl(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Ls(r,t){Pl(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,i=Xe(r),s=BigInt(r);return{windows:e,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Ll(r,t,e){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=e,c=Number(r&o),a=r>>s;c>n&&(c-=i,a+=Ns);let l=t*n,u=l+Math.abs(c)-1,f=c===0,p=c<0,w=t%2!==0;return{nextN:a,offset:u,isZero:f,isNeg:p,isNegF:w,offsetF:l}}function h0(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function p0(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Ps=new WeakMap,Dl=new WeakMap;function Ds(r){return Dl.get(r)||1}function Oo(r,t){return{constTimeNegate:Us,hasPrecomputes(e){return Ds(e)!==1},unsafeLadder(e,n,o=r.ZERO){let i=e;for(;n>Ul;)n&Ns&&(o=o.add(i)),i=i.double(),n>>=Ns;return o},precomputeWindow(e,n){let{windows:o,windowSize:i}=Ls(n,t),s=[],c=e,a=c;for(let l=0;l<o;l++){a=c,s.push(a);for(let u=1;u<i;u++)a=a.add(c),s.push(a);c=a.double()}return s},wNAF(e,n,o){let i=r.ZERO,s=r.BASE,c=Ls(e,t);for(let a=0;a<c.windows;a++){let{nextN:l,offset:u,isZero:f,isNeg:p,isNegF:w,offsetF:E}=Ll(o,a,c);o=l,f?s=s.add(Us(w,n[E])):i=i.add(Us(p,n[u]))}return{p:i,f:s}},wNAFUnsafe(e,n,o,i=r.ZERO){let s=Ls(e,t);for(let c=0;c<s.windows&&o!==Ul;c++){let{nextN:a,offset:l,isZero:u,isNeg:f}=Ll(o,c,s);if(o=a,!u){let p=n[l];i=i.add(f?p.negate():p)}}return i},getPrecomputes(e,n,o){let i=Ps.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&Ps.set(n,o(i))),i},wNAFCached(e,n,o){let i=Ds(e);return this.wNAF(i,this.getPrecomputes(i,e,o),n)},wNAFCachedUnsafe(e,n,o,i){let s=Ds(e);return s===1?this.unsafeLadder(e,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,o),n,i)},setWindowSize(e,n){Pl(n,t),Dl.set(e,n),Ps.delete(e)}}}function Fo(r,t,e,n){h0(e,r),p0(n,t);let o=e.length,i=n.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");let s=r.ZERO,c=El(BigInt(o)),a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);let l=Xe(a),u=new Array(Number(l)+1).fill(s),f=Math.floor((t.BITS-1)/a)*a,p=s;for(let w=f;w>=0;w-=a){u.fill(s);for(let m=0;m<i;m++){let x=n[m],B=Number(x>>BigInt(w)&l);u[B]=u[B].add(e[m])}let E=s;for(let m=u.length-1,x=s;m>0;m--)x=x.add(u[m]),E=E.add(x);if(p=p.add(E),w!==0)for(let m=0;m<a;m++)p=p.double()}return p}function Sn(r){return Bs(r.Fp),be(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ks(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var ae=BigInt(0),Tt=BigInt(1),Nl=BigInt(2),m0=BigInt(8),g0={zip215:!0};function y0(r){let t=Sn(r);return be(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Rl(r){let t=y0(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,l=Nl<<BigInt(c*8)-Tt,u=e.create,f=we(t.n,t.nBitLength);function p(S,g){let y=e.sqr(S),I=e.sqr(g),R=e.add(e.mul(t.a,y),I),V=e.add(e.ONE,e.mul(t.d,e.mul(y,I)));return e.eql(R,V)}if(!p(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let w=t.uvRatio||((S,g)=>{try{return{isValid:!0,value:e.sqrt(S*e.inv(g))}}catch{return{isValid:!1,value:ae}}}),E=t.adjustScalarBytes||(S=>S),m=t.domain||((S,g,y)=>{if(ce("phflag",y),g.length||y)throw new Error("Contexts/pre-hash are not supported");return S});function x(S,g,y=!1){let I=y?Tt:ae;Ht("coordinate "+S,g,I,l)}function B(S){if(!(S instanceof d))throw new Error("ExtendedPoint expected")}let P=Br((S,g)=>{let{ex:y,ey:I,ez:R}=S,V=S.is0();g==null&&(g=V?m0:e.inv(R));let z=u(y*g),q=u(I*g),G=u(R*g);if(V)return{x:ae,y:Tt};if(G!==Tt)throw new Error("invZ was invalid");return{x:z,y:q}}),b=Br(S=>{let{a:g,d:y}=t;if(S.is0())throw new Error("bad point: ZERO");let{ex:I,ey:R,ez:V,et:z}=S,q=u(I*I),G=u(R*R),Y=u(V*V),ut=u(Y*Y),st=u(q*g),mt=u(Y*u(st+G)),Ut=u(ut+u(y*u(q*G)));if(mt!==Ut)throw new Error("bad point: equation left != right (1)");let lt=u(I*R),bt=u(V*z);if(lt!==bt)throw new Error("bad point: equation left != right (2)");return!0});class d{constructor(g,y,I,R){x("x",g),x("y",y),x("z",I,!0),x("t",R),this.ex=g,this.ey=y,this.ez=I,this.et=R,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(g){if(g instanceof d)throw new Error("extended point not allowed");let{x:y,y:I}=g||{};return x("x",y),x("y",I),new d(y,I,Tt,u(y*I))}static normalizeZ(g){let y=kr(e,g.map(I=>I.ez));return g.map((I,R)=>I.toAffine(y[R])).map(d.fromAffine)}static msm(g,y){return Fo(d,f,g,y)}_setWindowSize(g){U.setWindowSize(this,g)}assertValidity(){b(this)}equals(g){B(g);let{ex:y,ey:I,ez:R}=this,{ex:V,ey:z,ez:q}=g,G=u(y*q),Y=u(V*R),ut=u(I*q),st=u(z*R);return G===Y&&ut===st}is0(){return this.equals(d.ZERO)}negate(){return new d(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:g}=t,{ex:y,ey:I,ez:R}=this,V=u(y*y),z=u(I*I),q=u(Nl*u(R*R)),G=u(g*V),Y=y+I,ut=u(u(Y*Y)-V-z),st=G+z,mt=st-q,Ut=G-z,lt=u(ut*mt),bt=u(st*Ut),Pt=u(ut*Ut),Yt=u(mt*st);return new d(lt,bt,Yt,Pt)}add(g){B(g);let{a:y,d:I}=t,{ex:R,ey:V,ez:z,et:q}=this,{ex:G,ey:Y,ez:ut,et:st}=g,mt=u(R*G),Ut=u(V*Y),lt=u(q*I*st),bt=u(z*ut),Pt=u((R+V)*(G+Y)-mt-Ut),Yt=bt-lt,Pr=bt+lt,Ys=u(Ut-y*mt),df=u(Pt*Yt),hf=u(Pr*Ys),pf=u(Pt*Ys),mf=u(Yt*Pr);return new d(df,hf,mf,pf)}subtract(g){return this.add(g.negate())}wNAF(g){return U.wNAFCached(this,g,d.normalizeZ)}multiply(g){let y=g;Ht("scalar",y,Tt,n);let{p:I,f:R}=this.wNAF(y);return d.normalizeZ([I,R])[0]}multiplyUnsafe(g,y=d.ZERO){let I=g;return Ht("scalar",I,ae,n),I===ae?T:this.is0()||I===Tt?this:U.wNAFCachedUnsafe(this,I,d.normalizeZ,y)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(g){return P(this,g)}clearCofactor(){let{h:g}=t;return g===Tt?this:this.multiplyUnsafe(g)}static fromHex(g,y=!1){let{d:I,a:R}=t,V=e.BYTES;g=nt("pointHex",g,V),ce("zip215",y);let z=g.slice(),q=g[V-1];z[V-1]=q&-129;let G=Ye(z),Y=y?l:e.ORDER;Ht("pointHex.y",G,ae,Y);let ut=u(G*G),st=u(ut-Tt),mt=u(I*ut-R),{isValid:Ut,value:lt}=w(st,mt);if(!Ut)throw new Error("Point.fromHex: invalid y coordinate");let bt=(lt&Tt)===Tt,Pt=(q&128)!==0;if(!y&<===ae&&Pt)throw new Error("Point.fromHex: x=0 and x_0=1");return Pt!==bt&&(lt=u(-lt)),d.fromAffine({x:lt,y:G})}static fromPrivateKey(g){let{scalar:y}=H(g);return v.multiply(y)}toRawBytes(){let{x:g,y}=this.toAffine(),I=Cr(y,e.BYTES);return I[I.length-1]|=g&Tt?128:0,I}toHex(){return De(this.toRawBytes())}}d.BASE=new d(t.Gx,t.Gy,Tt,u(t.Gx*t.Gy)),d.ZERO=new d(ae,Tt,Tt,ae);let{BASE:v,ZERO:T}=d,U=Oo(d,c*8);function L(S){return W(S,n)}function O(S){return L(Ye(S))}function H(S){let g=e.BYTES;S=nt("private key",S,g);let y=nt("hashed private key",i(S),2*g),I=E(y.slice(0,g)),R=y.slice(g,2*g),V=O(I);return{head:I,prefix:R,scalar:V}}function N(S){let{head:g,prefix:y,scalar:I}=H(S),R=v.multiply(I),V=R.toRawBytes();return{head:g,prefix:y,scalar:I,point:R,pointBytes:V}}function K(S){return N(S).pointBytes}function M(S=Uint8Array.of(),...g){let y=Ne(...g);return O(i(m(y,nt("context",S),!!o)))}function at(S,g,y={}){S=nt("message",S),o&&(S=o(S));let{prefix:I,scalar:R,pointBytes:V}=N(g),z=M(y.context,I,S),q=v.multiply(z).toRawBytes(),G=M(y.context,q,V,S),Y=L(z+G*R);Ht("signature.s",Y,ae,n);let ut=Ne(q,Cr(Y,e.BYTES));return nt("result",ut,e.BYTES*2)}let _=g0;function A(S,g,y,I=_){let{context:R,zip215:V}=I,z=e.BYTES;S=nt("signature",S,2*z),g=nt("message",g),y=nt("publicKey",y,z),V!==void 0&&ce("zip215",V),o&&(g=o(g));let q=Ye(S.slice(z,2*z)),G,Y,ut;try{G=d.fromHex(y,V),Y=d.fromHex(S.slice(0,z),V),ut=v.multiplyUnsafe(q)}catch{return!1}if(!V&&G.isSmallOrder())return!1;let st=M(R,Y.toRawBytes(),G.toRawBytes(),g);return Y.add(G.multiplyUnsafe(st)).subtract(ut).clearCofactor().equals(d.ZERO)}return v._setWindowSize(8),{CURVE:t,getPublicKey:K,sign:at,verify:A,ExtendedPoint:d,utils:{getExtendedPublicKey:N,randomPrivateKey:()=>s(e.BYTES),precompute(S=8,g=d.BASE){return g._setWindowSize(S),g.multiply(BigInt(3)),g}}}}var Rs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ml=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),tE=BigInt(0),x0=BigInt(1),Ol=BigInt(2),eE=BigInt(3),b0=BigInt(5),w0=BigInt(8);function E0(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=Rs,c=r*r%i*r%i,a=ot(c,Ol,i)*c%i,l=ot(a,x0,i)*r%i,u=ot(l,b0,i)*l%i,f=ot(u,t,i)*u%i,p=ot(f,e,i)*f%i,w=ot(p,n,i)*p%i,E=ot(w,o,i)*w%i,m=ot(E,o,i)*w%i,x=ot(m,t,i)*u%i;return{pow_p_5_8:ot(x,Ol,i)*r%i,b2:c}}function v0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function S0(r,t){let e=Rs,n=W(t*t*t,e),o=W(n*n*t,e),i=E0(r*o).pow_p_5_8,s=W(r*n*i,e),c=W(t*s*s,e),a=s,l=W(s*Ml,e),u=c===r,f=c===W(-r,e),p=c===W(-r*Ml,e);return u&&(s=a),(f||p)&&(s=l),Bl(s,e)&&(s=W(-s,e)),{isValid:u||f,value:s}}var Fl=we(Rs,void 0,!0),A0={a:Fl.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Fl,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:w0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:gl,randomBytes:Do,adjustScalarBytes:v0,uvRatio:S0},Kl=Rl(A0);var Ko=32;function Vl(r,t,e){return Kl.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var Vo=class{type="Ed25519";raw;constructor(t){this.raw=Ms(t,Ko)}toMultihash(){return te.digest(Sr(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Rt(this.raw,t.raw)}verify(t,e){return Vl(this.raw,e,t)}};function zl(r){return r=Ms(r,Ko),new Vo(r)}function Ms(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new qt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var zt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(zt||(zt={}));var Os;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Os||(Os={}));(function(r){r.codec=()=>rn(Os)})(zt||(zt={}));var An;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),zt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.Type=zt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(An||(An={}));var Fs;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),zt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.Type=zt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Fs||(Fs={}));var _n=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var Ho=class extends Ar{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,el(t);let n=yn(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),me(i)}update(t){return _r(this),this.iHash.update(t),this}digestInto(t){_r(this),je(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ks=(r,t,e)=>new Ho(r,t).update(e).digest();Ks.create=(r,t)=>new Ho(r,t);function ql(r){r.lowS!==void 0&&ce("lowS",r.lowS),r.prehash!==void 0&&ce("prehash",r.prehash)}function C0(r){let t=Sn(r);be(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}var zs=class extends Error{constructor(t=""){super(t)}},Ee={Err:zs,_tlv:{encode:(r,t)=>{let{Err:e}=Ee;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=En(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?En(o.length/2|128):"";return En(r)+i+o+t},decode(r,t){let{Err:e}=Ee,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+a);if(l.length!==a)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=a,s<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+s);if(c.length!==s)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+s)}}},_int:{encode(r){let{Err:t}=Ee;if(r<ve)throw new t("integer: negative integers are not allowed");let e=En(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Ee;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return xe(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ee,o=nt("signature",r),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:l,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(l)}},hexFromSig(r){let{_tlv:t,_int:e}=Ee,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),i=n+o;return t.encode(48,i)}};function Vs(r,t){return De(We(r,t))}var ve=BigInt(0),pt=BigInt(1),IE=BigInt(2),Hs=BigInt(3),B0=BigInt(4);function k0(r){let t=C0(r),{Fp:e}=t,n=we(t.n,t.nBitLength),o=t.toBytes||((b,d,v)=>{let T=d.toAffine();return Ne(Uint8Array.from([4]),e.toBytes(T.x),e.toBytes(T.y))}),i=t.fromBytes||(b=>{let d=b.subarray(1),v=e.fromBytes(d.subarray(0,e.BYTES)),T=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:v,y:T}});function s(b){let{a:d,b:v}=t,T=e.sqr(b),U=e.mul(T,b);return e.add(e.add(U,e.mul(b,d)),v)}function c(b,d){let v=e.sqr(d),T=s(b);return e.eql(v,T)}if(!c(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let a=e.mul(e.pow(t.a,Hs),B0),l=e.mul(e.sqr(t.b),BigInt(27));if(e.is0(e.add(a,l)))throw new Error("bad curve params: a or b");function u(b){return Ro(b,pt,t.n)}function f(b){let{allowedPrivateKeyLengths:d,nByteLength:v,wrapPrivateKey:T,n:U}=t;if(d&&typeof b!="bigint"){if(Ir(b)&&(b=De(b)),typeof b!="string"||!d.includes(b.length))throw new Error("invalid private key");b=b.padStart(v*2,"0")}let L;try{L=typeof b=="bigint"?b:xe(nt("private key",b,v))}catch{throw new Error("invalid private key, expected hex or "+v+" bytes, got "+typeof b)}return T&&(L=W(L,U)),Ht("private key",L,pt,U),L}function p(b){if(!(b instanceof m))throw new Error("ProjectivePoint expected")}let w=Br((b,d)=>{let{px:v,py:T,pz:U}=b;if(e.eql(U,e.ONE))return{x:v,y:T};let L=b.is0();d==null&&(d=L?e.ONE:e.inv(U));let O=e.mul(v,d),H=e.mul(T,d),N=e.mul(U,d);if(L)return{x:e.ZERO,y:e.ZERO};if(!e.eql(N,e.ONE))throw new Error("invZ was invalid");return{x:O,y:H}}),E=Br(b=>{if(b.is0()){if(t.allowInfinityPoint&&!e.is0(b.py))return;throw new Error("bad point: ZERO")}let{x:d,y:v}=b.toAffine();if(!e.isValid(d)||!e.isValid(v))throw new Error("bad point: x or y not FE");if(!c(d,v))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(d,v,T){if(d==null||!e.isValid(d))throw new Error("x required");if(v==null||!e.isValid(v)||e.is0(v))throw new Error("y required");if(T==null||!e.isValid(T))throw new Error("z required");this.px=d,this.py=v,this.pz=T,Object.freeze(this)}static fromAffine(d){let{x:v,y:T}=d||{};if(!d||!e.isValid(v)||!e.isValid(T))throw new Error("invalid affine point");if(d instanceof m)throw new Error("projective point not allowed");let U=L=>e.eql(L,e.ZERO);return U(v)&&U(T)?m.ZERO:new m(v,T,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let v=kr(e,d.map(T=>T.pz));return d.map((T,U)=>T.toAffine(v[U])).map(m.fromAffine)}static fromHex(d){let v=m.fromAffine(i(nt("pointHex",d)));return v.assertValidity(),v}static fromPrivateKey(d){return m.BASE.multiply(f(d))}static msm(d,v){return Fo(m,n,d,v)}_setWindowSize(d){P.setWindowSize(this,d)}assertValidity(){E(this)}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){p(d);let{px:v,py:T,pz:U}=this,{px:L,py:O,pz:H}=d,N=e.eql(e.mul(v,H),e.mul(L,U)),K=e.eql(e.mul(T,H),e.mul(O,U));return N&&K}negate(){return new m(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:v}=t,T=e.mul(v,Hs),{px:U,py:L,pz:O}=this,H=e.ZERO,N=e.ZERO,K=e.ZERO,M=e.mul(U,U),at=e.mul(L,L),_=e.mul(O,O),A=e.mul(U,L);return A=e.add(A,A),K=e.mul(U,O),K=e.add(K,K),H=e.mul(d,K),N=e.mul(T,_),N=e.add(H,N),H=e.sub(at,N),N=e.add(at,N),N=e.mul(H,N),H=e.mul(A,H),K=e.mul(T,K),_=e.mul(d,_),A=e.sub(M,_),A=e.mul(d,A),A=e.add(A,K),K=e.add(M,M),M=e.add(K,M),M=e.add(M,_),M=e.mul(M,A),N=e.add(N,M),_=e.mul(L,O),_=e.add(_,_),M=e.mul(_,A),H=e.sub(H,M),K=e.mul(_,at),K=e.add(K,K),K=e.add(K,K),new m(H,N,K)}add(d){p(d);let{px:v,py:T,pz:U}=this,{px:L,py:O,pz:H}=d,N=e.ZERO,K=e.ZERO,M=e.ZERO,at=t.a,_=e.mul(t.b,Hs),A=e.mul(v,L),D=e.mul(T,O),S=e.mul(U,H),g=e.add(v,T),y=e.add(L,O);g=e.mul(g,y),y=e.add(A,D),g=e.sub(g,y),y=e.add(v,U);let I=e.add(L,H);return y=e.mul(y,I),I=e.add(A,S),y=e.sub(y,I),I=e.add(T,U),N=e.add(O,H),I=e.mul(I,N),N=e.add(D,S),I=e.sub(I,N),M=e.mul(at,y),N=e.mul(_,S),M=e.add(N,M),N=e.sub(D,M),M=e.add(D,M),K=e.mul(N,M),D=e.add(A,A),D=e.add(D,A),S=e.mul(at,S),y=e.mul(_,y),D=e.add(D,S),S=e.sub(A,S),S=e.mul(at,S),y=e.add(y,S),A=e.mul(D,y),K=e.add(K,A),A=e.mul(I,y),N=e.mul(g,N),N=e.sub(N,A),A=e.mul(g,D),M=e.mul(I,M),M=e.add(M,A),new m(N,K,M)}subtract(d){return this.add(d.negate())}is0(){return this.equals(m.ZERO)}wNAF(d){return P.wNAFCached(this,d,m.normalizeZ)}multiplyUnsafe(d){let{endo:v,n:T}=t;Ht("scalar",d,ve,T);let U=m.ZERO;if(d===ve)return U;if(this.is0()||d===pt)return this;if(!v||P.hasPrecomputes(this))return P.wNAFCachedUnsafe(this,d,m.normalizeZ);let{k1neg:L,k1:O,k2neg:H,k2:N}=v.splitScalar(d),K=U,M=U,at=this;for(;O>ve||N>ve;)O&pt&&(K=K.add(at)),N&pt&&(M=M.add(at)),at=at.double(),O>>=pt,N>>=pt;return L&&(K=K.negate()),H&&(M=M.negate()),M=new m(e.mul(M.px,v.beta),M.py,M.pz),K.add(M)}multiply(d){let{endo:v,n:T}=t;Ht("scalar",d,pt,T);let U,L;if(v){let{k1neg:O,k1:H,k2neg:N,k2:K}=v.splitScalar(d),{p:M,f:at}=this.wNAF(H),{p:_,f:A}=this.wNAF(K);M=P.constTimeNegate(O,M),_=P.constTimeNegate(N,_),_=new m(e.mul(_.px,v.beta),_.py,_.pz),U=M.add(_),L=at.add(A)}else{let{p:O,f:H}=this.wNAF(d);U=O,L=H}return m.normalizeZ([U,L])[0]}multiplyAndAddUnsafe(d,v,T){let U=m.BASE,L=(H,N)=>N===ve||N===pt||!H.equals(U)?H.multiplyUnsafe(N):H.multiply(N),O=L(this,v).add(L(d,T));return O.is0()?void 0:O}toAffine(d){return w(this,d)}isTorsionFree(){let{h:d,isTorsionFree:v}=t;if(d===pt)return!0;if(v)return v(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:v}=t;return d===pt?this:v?v(m,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return ce("isCompressed",d),this.assertValidity(),o(m,this,d)}toHex(d=!0){return ce("isCompressed",d),De(this.toRawBytes(d))}}m.BASE=new m(t.Gx,t.Gy,e.ONE),m.ZERO=new m(e.ZERO,e.ONE,e.ZERO);let{endo:x,nBitLength:B}=t,P=Oo(m,x?Math.ceil(B/2):B);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:f,weierstrassEquation:s,isWithinCurveOrder:u}}function T0(r){let t=Sn(r);return be(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function $l(r){let t=T0(r),{Fp:e,n,nByteLength:o,nBitLength:i}=t,s=e.BYTES+1,c=2*e.BYTES+1;function a(_){return W(_,n)}function l(_){return Mo(_,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:f,weierstrassEquation:p,isWithinCurveOrder:w}=k0({...t,toBytes(_,A,D){let S=A.toAffine(),g=e.toBytes(S.x),y=Ne;return ce("isCompressed",D),D?y(Uint8Array.from([A.hasEvenY()?2:3]),g):y(Uint8Array.from([4]),g,e.toBytes(S.y))},fromBytes(_){let A=_.length,D=_[0],S=_.subarray(1);if(A===s&&(D===2||D===3)){let g=xe(S);if(!Ro(g,pt,e.ORDER))throw new Error("Point is not on curve");let y=p(g),I;try{I=e.sqrt(y)}catch(z){let q=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+q)}let R=(I&pt)===pt;return(D&1)===1!==R&&(I=e.neg(I)),{x:g,y:I}}else if(A===c&&D===4){let g=e.fromBytes(S.subarray(0,e.BYTES)),y=e.fromBytes(S.subarray(e.BYTES,2*e.BYTES));return{x:g,y}}else{let g=s,y=c;throw new Error("invalid Point, expected length of "+g+", or uncompressed "+y+", got "+A)}}});function E(_){let A=n>>pt;return _>A}function m(_){return E(_)?a(-_):_}let x=(_,A,D)=>xe(_.slice(A,D));class B{constructor(A,D,S){Ht("r",A,pt,n),Ht("s",D,pt,n),this.r=A,this.s=D,S!=null&&(this.recovery=S),Object.freeze(this)}static fromCompact(A){let D=o;return A=nt("compactSignature",A,D*2),new B(x(A,0,D),x(A,D,2*D))}static fromDER(A){let{r:D,s:S}=Ee.toSig(nt("DER",A));return new B(D,S)}assertValidity(){}addRecoveryBit(A){return new B(this.r,this.s,A)}recoverPublicKey(A){let{r:D,s:S,recovery:g}=this,y=U(nt("msgHash",A));if(g==null||![0,1,2,3].includes(g))throw new Error("recovery id invalid");let I=g===2||g===3?D+t.n:D;if(I>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let R=(g&1)===0?"02":"03",V=u.fromHex(R+Vs(I,e.BYTES)),z=l(I),q=a(-y*z),G=a(S*z),Y=u.BASE.multiplyAndAddUnsafe(V,q,G);if(!Y)throw new Error("point at infinify");return Y.assertValidity(),Y}hasHighS(){return E(this.s)}normalizeS(){return this.hasHighS()?new B(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return vn(this.toDERHex())}toDERHex(){return Ee.hexFromSig(this)}toCompactRawBytes(){return vn(this.toCompactHex())}toCompactHex(){let A=o;return Vs(this.r,A)+Vs(this.s,A)}}let P={isValidPrivateKey(_){try{return f(_),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let _=Ts(t.n);return Tl(t.randomBytes(_),t.n)},precompute(_=8,A=u.BASE){return A._setWindowSize(_),A.multiply(BigInt(3)),A}};function b(_,A=!0){return u.fromPrivateKey(_).toRawBytes(A)}function d(_){if(typeof _=="bigint")return!1;if(_ instanceof u)return!0;let D=nt("key",_).length,S=e.BYTES,g=S+1,y=2*S+1;if(!(t.allowedPrivateKeyLengths||o===g))return D===g||D===y}function v(_,A,D=!0){if(d(_)===!0)throw new Error("first arg must be private key");if(d(A)===!1)throw new Error("second arg must be public key");return u.fromHex(A).multiply(f(_)).toRawBytes(D)}let T=t.bits2int||function(_){if(_.length>8192)throw new Error("input is too large");let A=xe(_),D=_.length*8-i;return D>0?A>>BigInt(D):A},U=t.bits2int_modN||function(_){return a(T(_))},L=Xe(i);function O(_){return Ht("num < 2^"+i,_,ve,L),We(_,o)}function H(_,A,D=N){if(["recovered","canonical"].some(st=>st in D))throw new Error("sign() legacy options not supported");let{hash:S,randomBytes:g}=t,{lowS:y,prehash:I,extraEntropy:R}=D;y==null&&(y=!0),_=nt("msgHash",_),ql(D),I&&(_=nt("prehashed msgHash",S(_)));let V=U(_),z=f(A),q=[O(z),O(V)];if(R!=null&&R!==!1){let st=R===!0?g(e.BYTES):R;q.push(nt("extraEntropy",st))}let G=Ne(...q),Y=V;function ut(st){let mt=T(st);if(!w(mt))return;let Ut=l(mt),lt=u.BASE.multiply(mt).toAffine(),bt=a(lt.x);if(bt===ve)return;let Pt=a(Ut*a(Y+bt*z));if(Pt===ve)return;let Yt=(lt.x===bt?0:2)|Number(lt.y&pt),Pr=Pt;return y&&E(Pt)&&(Pr=m(Pt),Yt^=1),new B(bt,Pr,Yt)}return{seed:G,k2sig:ut}}let N={lowS:t.lowS,prehash:!1},K={lowS:t.lowS,prehash:!1};function M(_,A,D=N){let{seed:S,k2sig:g}=H(_,A,D),y=t;return vl(y.hash.outputLen,y.nByteLength,y.hmac)(S,g)}u.BASE._setWindowSize(8);function at(_,A,D,S=K){let g=_;A=nt("msgHash",A),D=nt("publicKey",D);let{lowS:y,prehash:I,format:R}=S;if(ql(S),"strict"in S)throw new Error("options.strict was renamed to lowS");if(R!==void 0&&R!=="compact"&&R!=="der")throw new Error("format must be compact or der");let V=typeof g=="string"||Ir(g),z=!V&&!R&&typeof g=="object"&&g!==null&&typeof g.r=="bigint"&&typeof g.s=="bigint";if(!V&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let q,G;try{if(z&&(q=new B(g.r,g.s)),V){try{R!=="compact"&&(q=B.fromDER(g))}catch(Yt){if(!(Yt instanceof Ee.Err))throw Yt}!q&&R!=="der"&&(q=B.fromCompact(g))}G=u.fromHex(D)}catch{return!1}if(!q||y&&q.hasHighS())return!1;I&&(A=t.hash(A));let{r:Y,s:ut}=q,st=U(A),mt=l(ut),Ut=a(st*mt),lt=a(Y*mt),bt=u.BASE.multiplyAndAddUnsafe(G,Ut,lt)?.toAffine();return bt?a(bt.x)===Y:!1}return{CURVE:t,getPublicKey:b,getSharedSecret:v,sign:M,verify:at,ProjectivePoint:u,Signature:B,utils:P}}function U0(r){return{hash:r,hmac:(t,...e)=>Ks(r,t,ys(...e)),randomBytes:Do}}function jl(r,t){let e=n=>$l({...r,...U0(n)});return{...e(t),create:e}}var Yl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Gl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),L0=BigInt(0),P0=BigInt(1),qs=BigInt(2),Zl=(r,t)=>(r+t/qs)/t;function D0(r){let t=Yl,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),l=r*r*r%t,u=l*l*r%t,f=ot(u,e,t)*u%t,p=ot(f,e,t)*u%t,w=ot(p,qs,t)*l%t,E=ot(w,o,t)*w%t,m=ot(E,i,t)*E%t,x=ot(m,c,t)*m%t,B=ot(x,a,t)*x%t,P=ot(B,c,t)*m%t,b=ot(P,e,t)*u%t,d=ot(b,s,t)*E%t,v=ot(d,n,t)*l%t,T=ot(v,qs,t);if(!$s.eql($s.sqr(T),r))throw new Error("Cannot find square root");return T}var $s=we(Yl,void 0,void 0,{sqrt:D0}),Tr=jl({a:L0,b:BigInt(7),Fp:$s,n:Gl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Gl,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-P0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),c=Zl(i*r,t),a=Zl(-n*r,t),l=W(r-c*e-a*o,t),u=W(-c*n-a*i,t),f=l>s,p=u>s;if(f&&(l=t-l),p&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:f,k1:l,k2neg:p,k2:u}}}},ml);function Wl(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Xl(r,t,e){let n=Xr.digest(e instanceof Uint8Array?e:e.subarray());if(Wl(n))return n.then(({digest:o})=>Tr.verify(t,o,r)).catch(o=>{throw new _n(String(o))});try{return Tr.verify(t,n.digest,r)}catch(o){throw new _n(String(o))}}var zo=class{type="secp256k1";raw;_key;constructor(t){this._key=Jl(t),this.raw=Ql(this._key)}toMultihash(){return te.digest(Sr(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Rt(this.raw,t.raw)}verify(t,e){return Xl(this._key,e,t)}};function tf(r){return new zo(r)}function Ql(r){return Tr.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Jl(r){try{return Tr.ProjectivePoint.fromHex(r),r}catch(t){throw new Un(String(t))}}function ef(r){let{Type:t,Data:e}=An.decode(r.digest),n=e??new Uint8Array;switch(t){case zt.Ed25519:return zl(n);case zt.secp256k1:return tf(n);case zt.ECDSA:return Qu(n);default:throw new Nr}}function Sr(r){return An.encode({Type:zt[r.type],Data:r.raw})}var rf=Symbol.for("nodejs.util.inspect.custom"),N0=114,In=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[kn]=!0;toString(){return this.string==null&&(this.string=et.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ct.createV1(N0,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Rt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Rt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[rf](){return`PeerId(${this.toString()})`}},qo=class extends In{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},$o=class extends In{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},jo=class extends In{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},R0=2336,Cn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=te.digest(jt(this.url))}[rf](){return`PeerId(${this.url})`}[kn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ct.createV1(R0,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=J(t)),t.toString()===this.toString())}};var M0=114,nf=2336;function of(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=de(et.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return O0(ct.parse(r));if(t==null)throw new qt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=de(t.decode(r))}return Go(e)}function Go(r){if(K0(r))return new qo({multihash:r});if(F0(r))try{let t=ef(r);if(t.type==="Ed25519")return new $o({multihash:r,publicKey:t});if(t.type==="secp256k1")return new jo({multihash:r,publicKey:t})}catch{let e=J(r.digest);return new Cn(new URL(e))}throw new Pn("Supplied PeerID Multihash is invalid")}function O0(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==M0&&r.code!==nf)throw new Ln("Supplied PeerID CID is invalid");if(r.code===nf){let t=J(r.multihash.digest);return new Cn(new URL(t))}return Go(r.multihash)}function F0(r){return r.code===te.code}function K0(r){return r.code===Xr.code}var sf={type:4098,canEncode:r=>Xs(r),encode:r=>r.toMultihash().bytes,decode:r=>Go(de(r))};var js=[Lu,Gu,sf,Pu];function Zo(r){let t={},e=r.components??r;return Object.entries(e).forEach(([n,o])=>{o?.[Se]!=null&&Array.isArray(o[Se])&&(t[n]=o[Se])}),t}function Ur(r,t){let e={};for(let[n,o]of r.entries())e[n]=t(o);return e}async function Yo(r,t){let e=[],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);e.push({id:i,addresses:c.addresses.map(({isCertified:a,multiaddr:l})=>({multiaddr:l,isCertified:a,isConnected:o.includes(l.toString())})),protocols:[...c.protocols],tags:Ur(c.tags,a=>a.value),metadata:Ur(c.metadata,a=>oe.encode(a))})}catch(c){t.error("could not load peer data from peer store",c),e.push({id:i,addresses:s.map(a=>({multiaddr:a.remoteAddr,isConnected:o.includes(a.remoteAddr.toString())})),protocols:[],tags:{},metadata:{}})}return e}function Lr(r,t){let e=t[r];if(!Tn(e))throw new qt(`Component ${r} did not implement the PubSub interface`);return e}async function Wo(r){let t=await r.peerStore.get(r.peerId);return{id:t.id,addresses:t.addresses,protocols:[...t.protocols],tags:Ur(t.tags,e=>e.value),metadata:Ur(t.metadata,e=>oe.encode(e))}}function cf(r){let t=r.logger.forComponent("libp2p:devtools-metrics:metrics-rpc");return{init:async()=>({self:await Wo(r),peers:await Yo(r,t),debug:localStorage.getItem("debug")??"",capabilities:Zo(r)}),setDebug:async e=>{e?.length!=null&&e?.length>0?(dc(e),localStorage.setItem("debug",e)):(fc(),localStorage.removeItem("debug"))},openConnection:async(e,n)=>{let o;try{o=of(e)}catch{o=qe(e)}await r.connectionManager.openConnection(o,n)},closeConnection:async(e,n)=>{await Promise.all(r.connectionManager.getConnections(e).map(async o=>{try{await o.close(n)}catch(i){o.abort(i)}}))},contentRouting:r.contentRouting,peerRouting:r.peerRouting,pubsub:{async getTopics(e){return Lr(e,r).getTopics()},async subscribe(e,n){Lr(e,r).subscribe(n)},async unsubscribe(e,n){Lr(e,r).unsubscribe(n)},async publish(e,n,o){await Lr(e,r).publish(n,o)},async getSubscribers(e,n){return Lr(e,r).getSubscribers(n)}}}}function Gs(r,t=100){let e,n;return()=>{if(n==null&&(n=Date.now()),e!=null&&Date.now()-n>t){clearTimeout(e),n=void 0,r();return}clearTimeout(e),e=setTimeout(()=>{n=void 0,r()},t)}}function af(r,t){for(let[e,n]of Object.entries(Zo(t)))if(n.includes(r))return t[e]}var uf="@libp2p/devtools-metrics:devtools",V0="@libp2p/devtools-metrics:worker",H0="@libp2p/devtools-metrics:content",lf="@libp2p/devtools-metrics:metrics",ff="________libp2p_devtools_metrics",z0=1e3;Object.defineProperty(globalThis,ff,{value:!0,enumerable:!1,writable:!1});var Zs=class{log;components;simpleMetrics;intervalMs;rpcQueue;rpc;devTools;rpcSendTimeout;constructor(t,e={}){this.log=t.logger.forComponent("libp2p:devtools-metrics"),this.intervalMs=e?.intervalMs,this.components=t,this.rpcSendTimeout=e.rpcSendTimeout??z0,this.rpcQueue=nr(),this.rpc=Uu({valueCodecs:js}),this.devTools=this.rpc.createClient("devTools",{timeout:this.rpcSendTimeout}),this.onPeersUpdate=Gs(this.onPeersUpdate.bind(this),1e3),this.onSelfUpdate=Gs(this.onSelfUpdate.bind(this),1e3),this.onIncomingMessage=this.onIncomingMessage.bind(this),this.onPubSubMessage=this.onPubSubMessage.bind(this),this.onPubSubSubscriptionChange=this.onPubSubSubscriptionChange.bind(this),this.simpleMetrics=Cc({intervalMs:this.intervalMs,onMetrics:n=>{this.devTools.safeDispatchEvent("metrics",{detail:n},{signal:AbortSignal.timeout(this.rpcSendTimeout)}).catch(o=>{this.log.error("error sending metrics",o)})}})({})}[Symbol.toStringTag]="@libp2p/devtools-metrics";[Se]=["@libp2p/metrics"];trackMultiaddrConnection(t){this.simpleMetrics.trackMultiaddrConnection(t)}trackProtocolStream(t,e){this.simpleMetrics.trackProtocolStream(t,e)}registerMetric(t,e){return this.simpleMetrics.registerMetric(t,e)}registerMetricGroup(t,e){return this.simpleMetrics.registerMetricGroup(t,e)}registerCounter(t,e){return this.simpleMetrics.registerCounter(t,e)}registerCounterGroup(t,e){return this.simpleMetrics.registerCounterGroup(t,e)}registerHistogram(t,e){return this.simpleMetrics.registerHistogram(t,e)}registerHistogramGroup(t,e){return this.simpleMetrics.registerHistogramGroup(t,e)}registerSummary(t,e){return this.simpleMetrics.registerSummary(t,e)}registerSummaryGroup(t,e){return this.simpleMetrics.registerSummaryGroup(t,e)}createTrace(){return this.simpleMetrics.createTrace()}traceFunction(t,e,n){return this.simpleMetrics.traceFunction(t,e,n)}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",cf(this.components)),await tc(this.simpleMetrics),Promise.resolve().then(async()=>{await Tc(this.rpcQueue,this.rpc,async e=>{for await(let n of e)window.postMessage({source:lf,type:"libp2p-rpc",message:oe.encode(n)})})}).catch(e=>{this.log.error("error while reading RPC messages",e)});let t=af("@libp2p/pubsub",this.components);Tn(t)&&(t.addEventListener("message",this.onPubSubMessage),t.addEventListener("subscription-change",this.onPubSubSubscriptionChange))}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 ec(this.simpleMetrics)}onIncomingMessage(t){if(t.source!==window)return;let e=t.data;e?.source===uf&&e.type==="libp2p-rpc"&&this.rpcQueue.push(oe.decode(e.message))}onPubSubMessage(t){this.devTools.safeDispatchEvent("pubsub:message",{detail:t.detail},{signal:AbortSignal.timeout(this.rpcSendTimeout)}).catch(e=>{this.log.error("error relaying pubsub message",e)})}onPubSubSubscriptionChange(t){this.devTools.safeDispatchEvent("pubsub:subscription-change",{detail:t.detail},{signal:AbortSignal.timeout(this.rpcSendTimeout)}).catch(e=>{this.log.error("error relaying pubsub subscription change",e)})}onSelfUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("self",{detail:await Wo(this.components)},{signal:AbortSignal.timeout(this.rpcSendTimeout)})}).catch(t=>{this.log.error("error sending peers message",t)})}onPeersUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("peers",{detail:await Yo(this.components,this.log)},{signal:AbortSignal.timeout(this.rpcSendTimeout)})}).catch(t=>{this.log.error("error sending peers message",t)})}};function q0(r){return t=>new Zs(t,r)}return vf($0);})();
|
|
4
4
|
/*! Bundled license information:
|
|
5
5
|
|
|
6
6
|
@noble/hashes/esm/utils.js:
|