@libp2p/devtools-metrics 1.1.6 → 1.1.7
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/package.json +5 -5
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 tc(r,t){return r.mean>t.mean?1:r.mean<t.mean?-1:0}function mf(r,t){return r.mean_cumn-t.mean_cumn}tt.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)};tt.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)};tt.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}};tt.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};tt.prototype._new_centroid=function(r,t,e){var n={mean:r,n:t,cumn:e};return this.centroids.insert(n),this.n+=t,n};tt.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};tt.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()};tt.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]};tt.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]};tt.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}};tt.prototype.bound_mean_cumn=function(r){this.centroids._comparator=mf;var t=this.centroids.upperBound({mean_cumn:r});this.centroids._comparator=tc;var e=t.prev(),n=e&&e.mean_cumn===r?e:t.next();return[e,n]};tt.prototype.percentile=function(r){var t=Array.isArray(r)?r:[r],e=t.map(this._percentile,this);return Array.isArray(r)?e:e[0]};tt.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 gf(r){var t=Math.floor(Math.random()*r.length);return r.splice(t,1)[0]}tt.prototype.compress=function(){if(!this.compressing){var r=this.toArray();for(this.reset(),this.compressing=!0;r.length>0;)this.push_centroid(gf(r));this._cumulate(!0),this.compressing=!1}};function be(r){this.config=r||{},this.mode=this.config.mode||"auto",tt.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}be.prototype=Object.create(tt.prototype);be.prototype.constructor=be;be.prototype.push=function(r){tt.prototype.push.call(this,r),this.check_continuous()};be.prototype._new_centroid=function(r,t,e){this.n_unique+=1,tt.prototype._new_centroid.call(this,r,t,e)};be.prototype._addweight=function(r,t,e){r.n===1&&(this.n_unique-=1),tt.prototype._addweight.call(this,r,t,e)};be.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};ec.exports={TDigest:tt,Digest:be}});var l0={};Ct(l0,{LIBP2P_DEVTOOLS_METRICS_KEY:()=>pl,SOURCE_CONTENT_SCRIPT:()=>a0,SOURCE_DEVTOOLS:()=>dl,SOURCE_METRICS:()=>hl,SOURCE_SERVICE_WORKER:()=>c0,devToolsMetrics:()=>u0,valueCodecs:()=>bs});var hn=Symbol.for("@libp2p/peer-id");function ks(r){return!!r?.[hn]}var Ts;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Ts||(Ts={}));var Tl=Symbol.for("@libp2p/pubsub");function pn(r){return!!r?.[Tl]}var me=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},mn=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var gn=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var _r=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};function Us(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function Ls(...r){let t=[];for(let e of r)Us(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 Ns(...r){let t=[];for(let e of r)Us(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 ge=Symbol.for("@libp2p/service-capabilities"),g0=Symbol.for("@libp2p/service-dependencies");var Oo={};Ct(Oo,{base32:()=>zt,base32hex:()=>Fl,base32hexpad:()=>$l,base32hexpadupper:()=>zl,base32hexupper:()=>Vl,base32pad:()=>Ml,base32padupper:()=>Ol,base32upper:()=>Dl,base32z:()=>Hl});var V0=new Uint8Array(0);function Rs(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 ne(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 Ps(r){return new TextEncoder().encode(r)}function Ds(r){return new TextDecoder().decode(r)}function Ul(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,d=0,b=0,A=E.length;b!==A&&E[b]===0;)b++,m++;for(var y=(A-b)*u+1>>>0,B=new Uint8Array(y);b!==A;){for(var R=E[b],U=0,k=y-1;(R!==0||U<d)&&k!==-1;k--,U++)R+=256*B[k]>>>0,B[k]=R%c>>>0,R=R/c>>>0;if(R!==0)throw new Error("Non-zero carry");d=U,b++}for(var C=y-d;C!==y&&B[C]===0;)C++;for(var L=a.repeat(m);C<y;++C)L+=r.charAt(B[C]);return L}function h(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 d=0,b=0;E[m]===a;)d++,m++;for(var A=(E.length-m)*l+1>>>0,y=new Uint8Array(A);E[m];){var B=e[E.charCodeAt(m)];if(B===255)return;for(var R=0,U=A-1;(B!==0||R<b)&&U!==-1;U--,R++)B+=c*y[U]>>>0,y[U]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");b=R,m++}if(E[m]!==" "){for(var k=A-b;k!==A&&y[k]===0;)k++;for(var C=new Uint8Array(d+(A-k)),L=d;k!==A;)C[L++]=y[k++];return C}}}function w(E){var m=h(E);if(m)return m;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:h,decode:w}}var Ll=Ul,Nl=Ll,Os=Nl;var Ro=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")}},Po=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 Fs(this,t)}},Do=class{decoders;constructor(t){this.decoders=t}or(t){return Fs(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 Fs(r,t){return new Do({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Mo=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 Ro(t,e,n),this.decoder=new Po(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ze({name:r,prefix:t,encode:e,decode:n}){return new Mo(r,t,e,n)}function ye({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Os(e,r);return Ze({prefix:t,name:r,encode:n,decode:i=>ne(o(i))})}function Rl(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)throw new SyntaxError("Unexpected end of data");return s}function Pl(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;)i+="=";return i}function nt({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Ze({prefix:t,name:r,encode(o){return Pl(o,n,e)},decode(o){return Rl(o,n,e,r)}})}var zt=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Dl=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ml=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ol=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Fl=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Vl=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),$l=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),zl=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Hl=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Fo={};Ct(Fo,{base58btc:()=>J,base58flickr:()=>ql});var J=ye({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ql=ye({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Vo={};Ct(Vo,{base64:()=>Jt,base64pad:()=>Kl,base64url:()=>Gl,base64urlpad:()=>jl});var Jt=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Kl=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Gl=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),jl=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Zl(r,t){try{if(typeof r=="string"&&r.length>0)return Wl(r);if(typeof r=="number"&&isFinite(r))return t?.long?Yl(r):Xl(r);throw new Error("Value is not a string or number.")}catch(e){let n=Ql(e)?`${e.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function Wl(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 bn=Zl;function Xl(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 Yl(r){let t=Math.abs(r);return t>=864e5?yn(r,t,864e5,"day"):t>=36e5?yn(r,t,36e5,"hour"):t>=6e4?yn(r,t,6e4,"minute"):t>=1e3?yn(r,t,1e3,"second"):`${r} ms`}function yn(r,t,e,n){let o=t>=e*1.5;return`${Math.round(r/e)} ${n}${o?"s":""}`}function Ql(r){return typeof r=="object"&&r!==null&&"message"in r}function $o(r){e.debug=e,e.default=e,e.coerce=a,e.disable=i,e.enable=o,e.enabled=s,e.humanize=bn,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,w,E;function m(...d){if(!m.enabled)return;let b=m,A=Number(new Date),y=A-(f||A);b.diff=y,b.prev=f,b.curr=A,f=A,d[0]=e.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let B=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(U,k)=>{if(U==="%%")return"%";B++;let C=e.formatters[k];if(typeof C=="function"){let L=d[B];U=C.call(b,L),d.splice(B,1),B--}return U}),e.formatArgs.call(b,d),(b.log||e.log).apply(b,d)}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:()=>h!==null?h:(w!==e.namespaces&&(w=e.namespaces,E=e.enabled(u)),E),set:d=>{h=d}}),typeof e.init=="function"&&e.init(m),m}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,]+/),w=h.length;for(f=0;f<w;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 xn=sf(),Jl=["#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 tf(){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 ef(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+bn(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 rf=console.debug??console.log??(()=>{});function nf(r){try{r?xn?.setItem("debug",r):xn?.removeItem("debug")}catch{}}function of(){let r;try{r=xn?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function sf(){try{return localStorage}catch{}}function cf(r){r.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}var Vs=$o({formatArgs:ef,save:nf,load:of,useColors:tf,setupFormatters:cf,colors:Jl,storage:xn,log:rf});var bt=Vs;bt.formatters.b=r=>r==null?"undefined":J.baseEncode(r);bt.formatters.t=r=>r==null?"undefined":zt.baseEncode(r);bt.formatters.m=r=>r==null?"undefined":Jt.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":r.stack??r.message;function af(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 $s(r){let t=af(`${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 zs(){bt.disable()}function Hs(r){bt.enable(r)}function uf(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 qs=uf;function lf(r){return r[Symbol.asyncIterator]!=null}function Ks(r){return r?.then!=null}function ff(r,t){let e=0;if(lf(r))return async function*(){for await(let a of r){let l=t(a,e++);Ks(l)&&await l,yield a}}();let n=qs(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++);Ks(l)&&await l,yield a}}();let c=t;return function*(){yield o;for(let a of n)c(a,e++),yield a}()}var zo=ff;var nc=Cl(rc(),1),yf=$s("libp2p:simple-metrics"),kr=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}}},Tr=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}}},Ur=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)}}},vn=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 Ur({})),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})}}},Lr=class{sumValue=0;countValue=0;percentiles;tdigest=new nc.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)}}},Sn=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 Lr(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})}}},qo=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";[ge]=["@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 kr?t[e]=n.value:n instanceof Tr?t[e]=n.values:n instanceof Ur?t[e]={count:n.countValue,sum:n.sumValue,buckets:{...n.bucketValues}}:n instanceof vn?t[e]={...Object.fromEntries(Object.entries(n.histograms).map(([o,i])=>[o,{count:i.countValue,sum:i.sumValue,buckets:{...i.bucketValues}}]))}:n instanceof Lr?t[e]={count:n.countValue,sum:n.sumValue,percentiles:Object.fromEntries(n.percentiles.map(o=>[o,n.tdigest.percentile(o)]))}:n instanceof Sn?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=>{yf.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(zo(c,a=>{n._incrementValue(`${e} sent`,a.byteLength)}))};let i=t.source;t.source=zo(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 kr;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 Tr;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 kr;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 Tr;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 Ur(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 vn(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 Lr(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 Sn(e);return this.metrics.set(t,n),n}};function oc(r){return t=>new qo(t,r)}function qt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var An=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)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}},Ye=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new An(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 An(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 Ko=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function xe(r={}){return bf(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 bf(r,t){t=t??{};let e=t.onEnd,n=new Ye,o,i,s,c=qt(),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(y){b(y)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=qt()})}},l=d=>i!=null?i(d):(n.push(d),o),u=d=>(n=new Ye,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})),w=()=>(n=new Ye,h(),{done:!0}),E=d=>(h(d),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:w,throw:E,push:f,end:h,get readableLength(){return n.size},onEmpty:async d=>{let b=d?.signal;if(b?.throwIfAborted(),n.isEmpty())return;let A,y;b!=null&&(A=new Promise((B,R)=>{y=()=>{R(new Ko)},b.addEventListener("abort",y)}));try{await Promise.race([c.promise,A])}finally{y!=null&&b!=null&&b?.removeEventListener("abort",y)}}},e==null)return o;let m=o;return o={[Symbol.asyncIterator](){return this},next(){return m.next()},throw(d){return m.throw(d),e!=null&&(e(d),e=void 0),{done:!0}},return(){return m.return(),e!=null&&(e(),e=void 0),{done:!0}},push:f,end(d){return m.end(d),e!=null&&(e(d),e=void 0),o},get readableLength(){return m.readableLength},onEmpty:d=>m.onEmpty(d)},o}function xf(r){return r[Symbol.asyncIterator]!=null}function wf(...r){let t=[];for(let e of r)xf(e)||t.push(e);return t.length===r.length?function*(){for(let e of t)yield*e}():async function*(){let e=xe({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)e.push(o)})),e.end()}catch(n){e.end(n)}}),yield*e}()}var ic=wf;function sc(r,...t){if(r==null)throw new Error("Empty pipeline");if(Go(r)){let n=r;r=()=>n.source}else if(ac(r)||cc(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&Go(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++)Go(e[n])&&(e[n]=vf(e[n]));return Ef(...e)}var Ef=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},cc=r=>r?.[Symbol.asyncIterator]!=null,ac=r=>r?.[Symbol.iterator]!=null,Go=r=>r==null?!1:r.sink!=null&&r.source!=null,vf=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=xe({objectMode:!0});e.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(cc(i))o=async function*(){yield*i,n.end()};else if(ac(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return ic(n,o())}return r.source};function Bn(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 Kt(r=0){return new Uint8Array(r)}function xt(r=0){return new Uint8Array(r)}var Sf=Math.pow(2,7),Af=Math.pow(2,14),Bf=Math.pow(2,21),jo=Math.pow(2,28),Zo=Math.pow(2,35),Wo=Math.pow(2,42),Xo=Math.pow(2,49),G=128,wt=127;function ft(r){if(r<Sf)return 1;if(r<Af)return 2;if(r<Bf)return 3;if(r<jo)return 4;if(r<Zo)return 5;if(r<Wo)return 6;if(r<Xo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Yo(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 _f(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 Qo(r,t){let e=r[t],n=0;if(n+=e&wt,e<G||(e=r[t+1],n+=(e&wt)<<7,e<G)||(e=r[t+2],n+=(e&wt)<<14,e<G)||(e=r[t+3],n+=(e&wt)<<21,e<G)||(e=r[t+4],n+=(e&wt)*jo,e<G)||(e=r[t+5],n+=(e&wt)*Zo,e<G)||(e=r[t+6],n+=(e&wt)*Wo,e<G)||(e=r[t+7],n+=(e&wt)*Xo,e<G))return n;throw new RangeError("Could not decode varint")}function If(r,t){let e=r.get(t),n=0;if(n+=e&wt,e<G||(e=r.get(t+1),n+=(e&wt)<<7,e<G)||(e=r.get(t+2),n+=(e&wt)<<14,e<G)||(e=r.get(t+3),n+=(e&wt)<<21,e<G)||(e=r.get(t+4),n+=(e&wt)*jo,e<G)||(e=r.get(t+5),n+=(e&wt)*Zo,e<G)||(e=r.get(t+6),n+=(e&wt)*Wo,e<G)||(e=r.get(t+7),n+=(e&wt)*Xo,e<G))return n;throw new RangeError("Could not decode varint")}function we(r,t,e=0){return t==null&&(t=xt(ft(r))),t instanceof Uint8Array?Yo(r,t,e):_f(r,t,e)}function oe(r,t=0){return r instanceof Uint8Array?Qo(r,t):If(r,t)}function Lt(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=xt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function Gt(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 lc=Symbol.for("@achingbrain/uint8arraylist");function uc(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 In(r){return!!r?.[lc]}var Qe=class r{bufs;length;[lc]=!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(In(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(In(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=uc(this.bufs,t);return e.buf[e.index]}set(t,e){let n=uc(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(In(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 Lt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Lt(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(!In(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 w=this.get(f+h);if(n[h]!==w){u=Math.max(1,h-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=xt(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=Kt(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=Kt(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=Kt(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=xt(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=Kt(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=Kt(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=Kt(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=Kt(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=Kt(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(!Gt(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}};function Cn(r){return r[Symbol.asyncIterator]!=null}var kn=r=>{let t=ft(r),e=xt(t);return we(r,e),kn.bytes=t,e};kn.bytes=0;function Tn(r,t){t=t??{};let e=t.lengthEncoder??kn;function*n(o){let i=e(o.byteLength);i instanceof Uint8Array?yield i:yield*i,o instanceof Uint8Array?yield o:yield*o}return Cn(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}Tn.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??kn;return new Qe(e(r.byteLength),r)};var Un=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Ln=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Nn=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},Nr=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var Cf=8,kf=1024*1024*4,Re;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Re||(Re={}));var Jo=r=>{let t=oe(r);return Jo.bytes=ft(t),t};Jo.bytes=0;function Rr(r,t){let e=new Qe,n=Re.LENGTH,o=-1,i=t?.lengthDecoder??Jo,s=t?.maxLengthLength??Cf,c=t?.maxDataLength??kf;function*a(){for(;e.byteLength>0;){if(n===Re.LENGTH)try{if(o=i(e),o<0)throw new Un("Invalid message length");if(o>c)throw new Ln("Message length too long");let l=i.bytes;e.consume(l),t?.onLength!=null&&t.onLength(o),n=Re.DATA}catch(l){if(l instanceof RangeError){if(e.byteLength>s)throw new Nn("Message length length too long");break}throw l}if(n===Re.DATA){if(e.byteLength<o)break;let l=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(l),yield l,n=Re.LENGTH}}}return Cn(r)?async function*(){for await(let l of r)e.append(l),yield*a();if(e.byteLength>0)throw new Nr("Unexpected end of input")}():function*(){for(let l of r)e.append(l),yield*a();if(e.byteLength>0)throw new Nr("Unexpected end of input")}()}Rr.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 Rr(n,{...t??{},onLength:i=>{e=i}})};var fc="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Je=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=fc[e[r]&63];return t};var Rn=class extends Error{constructor(t="Method not found"){super(t),this.name="MethodNotFoundError"}},Pn=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidMethodError"}},Pr=class extends Error{constructor(t="Unsupported value type"){super(t),this.name="UnsupportedValueTypeError"}},Dn=class extends Error{constructor(t="Cannot reuse RPC target name"){super(t),this.name="DuplicateTargetNameError"}},Dr=class extends Error{constructor(t="Duplicate scope"){super(t),this.name="DuplicateScopeError"}},Mn=class extends Error{constructor(t="Invalid return type"){super(t),this.name="InvalidReturnTypeError"}},Mr=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidInvocationTypeError"}},tr=class extends Error{constructor(t="Parent invocation scope not found"){super(t),this.name="MissingParentScopeError"}},On=class extends Error{constructor(t="Invocation not found"){super(t),this.name="MissingInvocationError"}},Fn=class extends Error{constructor(t="Callback not found"){super(t),this.name="MissingCallbackError"}};var ti=new Float32Array([-0]),Ee=new Uint8Array(ti.buffer);function dc(r,t,e){ti[0]=r,t[e]=Ee[0],t[e+1]=Ee[1],t[e+2]=Ee[2],t[e+3]=Ee[3]}function hc(r,t){return Ee[0]=r[t],Ee[1]=r[t+1],Ee[2]=r[t+2],Ee[3]=r[t+3],ti[0]}var ei=new Float64Array([-0]),Et=new Uint8Array(ei.buffer);function pc(r,t,e){ei[0]=r,t[e]=Et[0],t[e+1]=Et[1],t[e+2]=Et[2],t[e+3]=Et[3],t[e+4]=Et[4],t[e+5]=Et[5],t[e+6]=Et[6],t[e+7]=Et[7]}function mc(r,t){return Et[0]=r[t],Et[1]=r[t+1],Et[2]=r[t+2],Et[3]=r[t+3],Et[4]=r[t+4],Et[5]=r[t+5],Et[6]=r[t+6],Et[7]=r[t+7],ei[0]}var Tf=BigInt(Number.MAX_SAFE_INTEGER),Uf=BigInt(Number.MIN_SAFE_INTEGER),Nt=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 Pe;if(t<Tf&&t>Uf)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>gc&&(o=0n,++n>gc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return Pe;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):Pe}},Pe=new Nt(0,0);Pe.toBigInt=function(){return 0n};Pe.zzEncode=Pe.zzDecode=function(){return this};Pe.length=function(){return 1};var gc=4294967296n;function yc(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 bc(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 ri(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 Vn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var ni=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 Vn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw jt(this,4);return Vn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw jt(this,4);let t=hc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw jt(this,4);let t=mc(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 bc(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);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 Nt(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=Vn(this.buf,this.pos+=4),e=Vn(this.buf,this.pos+=4);return new Nt(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=Qo(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 oi(r){return new ni(r instanceof Uint8Array?r:r.subarray())}function St(r,t,e){let n=oi(r);return t.decode(n,void 0,e)}var ii={};Ct(ii,{base10:()=>Lf});var Lf=ye({prefix:"9",name:"base10",alphabet:"0123456789"});var si={};Ct(si,{base16:()=>Nf,base16upper:()=>Rf});var Nf=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Rf=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ci={};Ct(ci,{base2:()=>Pf});var Pf=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ai={};Ct(ai,{base256emoji:()=>Vf});var wc=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}"),Df=wc.reduce((r,t,e)=>(r[e]=t,r),[]),Mf=wc.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Of(r){return r.reduce((t,e)=>(t+=Df[e],t),"")}function Ff(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Mf[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Vf=Ze({prefix:"\u{1F680}",name:"base256emoji",encode:Of,decode:Ff});var ui={};Ct(ui,{base36:()=>Or,base36upper:()=>$f});var Or=ye({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$f=ye({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var li={};Ct(li,{base8:()=>zf});var zf=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fi={};Ct(fi,{identity:()=>Hf});var Hf=Ze({prefix:"\0",name:"identity",encode:r=>Ds(r),decode:r=>Ps(r)});var Eg=new TextEncoder,vg=new TextDecoder;var hi={};Ct(hi,{identity:()=>se});var Gf=Sc,Ec=128,jf=127,Zf=~jf,Wf=Math.pow(2,31);function Sc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Wf;)t[e++]=r&255|Ec,r/=128;for(;r&Zf;)t[e++]=r&255|Ec,r>>>=7;return t[e]=r|0,Sc.bytes=e-n+1,t}var Xf=di,Yf=128,vc=127;function di(r,n){var e=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw di.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&vc)<<o:(s&vc)*Math.pow(2,o),o+=7}while(s>=Yf);return di.bytes=i-n,e}var Qf=Math.pow(2,7),Jf=Math.pow(2,14),td=Math.pow(2,21),ed=Math.pow(2,28),rd=Math.pow(2,35),nd=Math.pow(2,42),od=Math.pow(2,49),id=Math.pow(2,56),sd=Math.pow(2,63),cd=function(r){return r<Qf?1:r<Jf?2:r<td?3:r<ed?4:r<rd?5:r<nd?6:r<od?7:r<id?8:r<sd?9:10},ad={encode:Gf,decode:Xf,encodingLength:cd},ud=ad,Fr=ud;function Vr(r,t=0){return[Fr.decode(r,t),Fr.decode.bytes]}function er(r,t,e=0){return Fr.encode(r,t,e),t}function rr(r){return Fr.encodingLength(r)}function De(r,t){let e=t.byteLength,n=rr(r),o=n+rr(e),i=new Uint8Array(o+e);return er(r,i,0),er(e,i,n),i.set(t,o),new nr(r,e,t,i)}function ie(r){let t=ne(r),[e,n]=Vr(t),[o,i]=Vr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new nr(e,o,s,t)}function Ac(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Rs(r.bytes,e.bytes)}}var nr=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Bc=0,ld="identity",_c=ne;function fd(r){return De(Bc,_c(r))}var se={code:Bc,name:ld,encode:_c,digest:fd};var gi={};Ct(gi,{sha256:()=>$r,sha512:()=>dd});function mi({name:r,code:t,encode:e}){return new pi(r,t,e)}var pi=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?De(this.code,e):e.then(n=>De(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Cc(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var $r=mi({name:"sha2-256",code:18,encode:Cc("SHA-256")}),dd=mi({name:"sha2-512",code:19,encode:Cc("SHA-512")});function kc(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return pd(e,yi(r),t??J.encoder);default:return md(e,yi(r),t??zt.encoder)}}var Tc=new WeakMap;function yi(r){let t=Tc.get(r);if(t==null){let e=new Map;return Tc.set(r,e),e}return t}var gt=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!==zr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==gd)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=De(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&&Ac(t.multihash,n.multihash)}toString(t){return kc(this,t)}toJSON(){return{"/":kc(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??Uc(n,o,i.bytes))}else if(e[yd]===!0){let{version:n,multihash:o,code:i}=e,s=ie(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!==zr)throw new Error(`Version 0 CID must use dag-pb (code: ${zr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Uc(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,zr,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=ne(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 nr(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]=Vr(t.subarray(e));return e+=h,f},o=n(),i=zr;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]=hd(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 yi(i).set(n,t),i}};function hd(r,t){switch(r[0]){case"Q":{let e=t??J;return[J.prefix,e.decode(`${J.prefix}${r}`)]}case J.prefix:{let e=t??J;return[J.prefix,e.decode(r)]}case zt.prefix:{let e=t??zt;return[zt.prefix,e.decode(r)]}case Or.prefix:{let e=t??Or;return[Or.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 pd(r,t,e){let{prefix:n}=e;if(n!==J.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 md(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 zr=112,gd=18;function Uc(r,t,e){let n=rr(r),o=n+rr(t),i=new Uint8Array(o+e.byteLength);return er(r,i,0),er(t,i,n),i.set(e,o),i}var yd=Symbol.for("@ipld/js-cid/CID");var Hr={...fi,...ci,...li,...ii,...si,...Oo,...ui,...Fo,...Vo,...ai},qg={...gi,...hi};function Nc(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Lc=Nc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),bi=Nc("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=xt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),bd={utf8:Lc,"utf-8":Lc,hex:Hr.base16,latin1:bi,ascii:bi,binary:bi,...Hr},zn=bd;function Se(r,t="utf8"){let e=zn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function xi(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return xt(s);o+s>t&&(n=xt(t),o=0);let c=n.subarray(o,o+=s);return o&7&&(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 wi(){}var vi=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},xd=xi();function wd(r){return globalThis.Buffer!=null?xt(r):xd(r)}var Kr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Me(wi,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 Si((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(Hn,10,Nt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Nt.fromBigInt(t);return this._push(Hn,e.length(),e)}uint64Number(t){return this._push(Yo,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=Nt.fromBigInt(t).zzEncode();return this._push(Hn,e.length(),e)}sint64Number(t){let e=Nt.fromNumber(t).zzEncode();return this._push(Hn,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Ei,1,t?1:0)}fixed32(t){return this._push(qr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Nt.fromBigInt(t);return this._push(qr,4,e.lo)._push(qr,4,e.hi)}fixed64Number(t){let e=Nt.fromNumber(t);return this._push(qr,4,e.lo)._push(qr,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(dc,4,t)}double(t){return this._push(pc,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Ei,1,0):this.uint32(e)._push(vd,e,t)}string(t){let e=yc(t);return e!==0?this.uint32(e)._push(ri,e,t):this._push(Ei,1,0)}fork(){return this.states=new vi(this),this.head=this.tail=new Me(wi,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(wi,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=wd(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Ei(r,t,e){t[e]=r&255}function Ed(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Si=class extends Me{next;constructor(t,e){super(Ed,t,e),this.next=void 0}};function Hn(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 qr(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 vd(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Kr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Sd,t,r),this},Kr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Ad,t,r),this});function Sd(r,t,e){t.set(r,e)}function Ad(r,t,e){r.length<40?ri(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Se(r),e)}function Ai(){return new Kr}function At(r,t){let e=Ai();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var or;(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"})(or||(or={}));function qn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Gr(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 qn("enum",or.VARINT,e,n)}function Bt(r,t){return qn("message",or.LENGTH_DELIMITED,r,t)}var ce=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var q;(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"})(q||(q={}));var Kn;(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"})(Kn||(Kn={}));(function(r){r.codec=()=>Gr(Kn)})(q||(q={}));var kt;(function(r){let t;r.codec=()=>(t==null&&(t=Bt((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=>At(e,r.codec()),r.decode=(e,n)=>St(e,r.codec(),n)})(kt||(kt={}));var _t;(function(r){let t;r.codec=()=>(t==null&&(t=Bt((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.type!=null&&Kn[e.type]!==0&&(n.uint32(8),q.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:q.invokeMethod,message:Kt(0)},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.type=q.codec().decode(e);break}case 2:{i.message=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>At(e,r.codec()),r.decode=(e,n)=>St(e,r.codec(),n)})(_t||(_t={}));var Oe;(function(r){let t;r.codec=()=>(t==null&&(t=Bt((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),kt.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 ce('Decode error - map field "args" had too many elements');i.args.push(kt.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>At(e,r.codec()),r.decode=(e,n)=>St(e,r.codec(),n)})(Oe||(Oe={}));var jr;(function(r){let t;r.codec=()=>(t==null&&(t=Bt((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=>At(e,r.codec()),r.decode=(e,n)=>St(e,r.codec(),n)})(jr||(jr={}));var ir;(function(r){let t;r.codec=()=>(t==null&&(t=Bt((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),kt.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=kt.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>At(e,r.codec()),r.decode=(e,n)=>St(e,r.codec(),n)})(ir||(ir={}));var Zr;(function(r){let t;r.codec=()=>(t==null&&(t=Bt((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),kt.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=kt.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>At(e,r.codec()),r.decode=(e,n)=>St(e,r.codec(),n)})(Zr||(Zr={}));var sr;(function(r){let t;r.codec=()=>(t==null&&(t=Bt((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),kt.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 ce('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 ce('Decode error - map field "args" had too many elements');i.args.push(kt.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>At(e,r.codec()),r.decode=(e,n)=>St(e,r.codec(),n)})(sr||(sr={}));var cr;(function(r){let t;r.codec=()=>(t==null&&(t=Bt((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 ce('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=>At(e,r.codec()),r.decode=(e,n)=>St(e,r.codec(),n)})(cr||(cr={}));var Wr;(function(r){let t;r.codec=()=>(t==null&&(t=Bt((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),kt.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 ce('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.value=kt.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>At(e,r.codec()),r.decode=(e,n)=>St(e,r.codec(),n)})(Wr||(Wr={}));var Xr;(function(r){let t;r.codec=()=>(t==null&&(t=Bt((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),kt.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 ce('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.error=kt.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>At(e,r.codec()),r.decode=(e,n)=>St(e,r.codec(),n)})(Xr||(Xr={}));function Bd(r){return r.parents!=null}function Rc(r,t){if(Bd(r))return _d(r.parents,t);let e=t.get(r.scope);if(e==null)throw new On;return e}function _d(r,t){let e;for(let n of r){if(e==null){if(e=t.get(n),e==null)throw new tr;continue}if(e=e.children.get(n),e==null)throw new tr}if(e==null)throw new tr;return e}var Id={type:1024,canEncode:r=>r===void 0,decode:()=>{}},Pc=Id;var Cd={type:1025,canEncode:r=>r===null,decode:()=>null},Dc=Cd;var kd=["string","number","bigint","symbol"],Td=["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 Mc(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let t=typeof r;if(kd.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(r))return"Array";if(Ud(r))return"Buffer";let e=Ld(r);return e||"Object"}function Ud(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Ld(r){let t=Object.prototype.toString.call(r).slice(8,-1);if(Td.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 I=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 ar=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Nd=new TextDecoder,Rd=new TextEncoder;function Gn(r){return ar&&globalThis.Buffer.isBuffer(r)}function Bi(r){return r instanceof Uint8Array?Gn(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var $c=ar?(r,t,e)=>e-t>64?globalThis.Buffer.from(r.subarray(t,e)).toString("utf8"):Fc(r,t,e):(r,t,e)=>e-t>64?Nd.decode(r.subarray(t,e)):Fc(r,t,e),zc=ar?r=>r.length>64?globalThis.Buffer.from(r):Oc(r):r=>r.length>64?Rd.encode(r):Oc(r),te=r=>Uint8Array.from(r),ur=ar?(r,t,e)=>Gn(r)?new Uint8Array(r.subarray(t,e)):r.slice(t,e):(r,t,e)=>r.slice(t,e),Hc=ar?(r,t)=>(r=r.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),Bi(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},qc=ar?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Kc(r,t){if(Gn(r)&&Gn(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 Oc(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 Fc(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 Pd(n)}var Vc=4096;function Pd(r){let t=r.length;if(t<=Vc)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Vc));return e}var Dd=256,Yr=class{constructor(t=Dd){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=qc(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=ur(n,0,this.cursor)}else e=Hc(this.chunks,this.cursor);return t&&this.reset(),e}};var M="CBOR decode error:",_i="CBOR encode error:",Qr=[];Qr[23]=1;Qr[24]=2;Qr[25]=3;Qr[26]=5;Qr[27]=9;function ae(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 Rt(r,t,e){ae(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 Pt(r,t,e){ae(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 Dt(r,t,e){ae(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 Mt(r,t,e){ae(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 Gc(r,t,e,n){return new I(p.uint,Rt(r,t+1,n),2)}function jc(r,t,e,n){return new I(p.uint,Pt(r,t+1,n),3)}function Zc(r,t,e,n){return new I(p.uint,Dt(r,t+1,n),5)}function Wc(r,t,e,n){return new I(p.uint,Mt(r,t+1,n),9)}function Ft(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(`${M} encountered BigInt larger than allowable range`)}}Ft.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};Ft.compareTokens=function(t,e){return t.value<e.value?-1:t.value>e.value?1:0};function Xc(r,t,e,n){return new I(p.negint,-1-Rt(r,t+1,n),2)}function Yc(r,t,e,n){return new I(p.negint,-1-Pt(r,t+1,n),3)}function Qc(r,t,e,n){return new I(p.negint,-1-Dt(r,t+1,n),5)}var Ii=BigInt(-1),Jc=BigInt(1);function ta(r,t,e,n){let o=Mt(r,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new I(p.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new I(p.negint,Ii-BigInt(o),9)}function jn(r,t){let e=t.value,n=typeof e=="bigint"?e*Ii-Jc:e*-1-1;yt(r,t.type.majorEncoded,n)}jn.encodedSize=function(t){let e=t.value,n=typeof e=="bigint"?e*Ii-Jc:e*-1-1;return n<dt[0]?1:n<dt[1]?2:n<dt[2]?3:n<dt[3]?5:9};jn.compareTokens=function(t,e){return t.value<e.value?1:t.value>e.value?-1:0};function Jr(r,t,e,n){ae(r,t,e+n);let o=ur(r,t+e,t+e+n);return new I(p.bytes,o,e+n)}function ea(r,t,e,n){return Jr(r,t,1,e)}function ra(r,t,e,n){return Jr(r,t,2,Rt(r,t+1,n))}function na(r,t,e,n){return Jr(r,t,3,Pt(r,t+1,n))}function oa(r,t,e,n){return Jr(r,t,5,Dt(r,t+1,n))}function ia(r,t,e,n){let o=Mt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return Jr(r,t,9,o)}function Zn(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===p.string?zc(r.value):r.value),r.encodedBytes}function lr(r,t){let e=Zn(t);yt(r,t.type.majorEncoded,e.length),r.push(e)}lr.encodedSize=function(t){let e=Zn(t);return yt.encodedSize(e.length)+e.length};lr.compareTokens=function(t,e){return Od(Zn(t),Zn(e))};function Od(r,t){return r.length<t.length?-1:r.length>t.length?1:Kc(r,t)}function tn(r,t,e,n,o){let i=e+n;ae(r,t,i);let s=new I(p.string,$c(r,t+e,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=ur(r,t+e,t+i)),s}function sa(r,t,e,n){return tn(r,t,1,e,n)}function ca(r,t,e,n){return tn(r,t,2,Rt(r,t+1,n),n)}function aa(r,t,e,n){return tn(r,t,3,Pt(r,t+1,n),n)}function ua(r,t,e,n){return tn(r,t,5,Dt(r,t+1,n),n)}function la(r,t,e,n){let o=Mt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return tn(r,t,9,o,n)}var fa=lr;function fr(r,t,e,n){return new I(p.array,n,e)}function da(r,t,e,n){return fr(r,t,1,e)}function ha(r,t,e,n){return fr(r,t,2,Rt(r,t+1,n))}function pa(r,t,e,n){return fr(r,t,3,Pt(r,t+1,n))}function ma(r,t,e,n){return fr(r,t,5,Dt(r,t+1,n))}function ga(r,t,e,n){let o=Mt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return fr(r,t,9,o)}function ya(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return fr(r,t,1,1/0)}function Wn(r,t){yt(r,p.array.majorEncoded,t.value)}Wn.compareTokens=Ft.compareTokens;Wn.encodedSize=function(t){return yt.encodedSize(t.value)};function dr(r,t,e,n){return new I(p.map,n,e)}function ba(r,t,e,n){return dr(r,t,1,e)}function xa(r,t,e,n){return dr(r,t,2,Rt(r,t+1,n))}function wa(r,t,e,n){return dr(r,t,3,Pt(r,t+1,n))}function Ea(r,t,e,n){return dr(r,t,5,Dt(r,t+1,n))}function va(r,t,e,n){let o=Mt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return dr(r,t,9,o)}function Sa(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return dr(r,t,1,1/0)}function Xn(r,t){yt(r,p.map.majorEncoded,t.value)}Xn.compareTokens=Ft.compareTokens;Xn.encodedSize=function(t){return yt.encodedSize(t.value)};function Aa(r,t,e,n){return new I(p.tag,e,1)}function Ba(r,t,e,n){return new I(p.tag,Rt(r,t+1,n),2)}function _a(r,t,e,n){return new I(p.tag,Pt(r,t+1,n),3)}function Ia(r,t,e,n){return new I(p.tag,Dt(r,t+1,n),5)}function Ca(r,t,e,n){return new I(p.tag,Mt(r,t+1,n),9)}function Yn(r,t){yt(r,p.tag.majorEncoded,t.value)}Yn.compareTokens=Ft.compareTokens;Yn.encodedSize=function(t){return yt.encodedSize(t.value)};var qd=20,Kd=21,Gd=22,jd=23;function ka(r,t,e,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new I(p.null,null,1):new I(p.undefined,void 0,1)}function Ta(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new I(p.break,void 0,1)}function Ci(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 I(p.float,r,t)}function Ua(r,t,e,n){return Ci(ki(r,t+1),3,n)}function La(r,t,e,n){return Ci(Ti(r,t+1),5,n)}function Na(r,t,e,n){return Ci(Ma(r,t+1),9,n)}function Qn(r,t,e){let n=t.value;if(n===!1)r.push([p.float.majorEncoded|qd]);else if(n===!0)r.push([p.float.majorEncoded|Kd]);else if(n===null)r.push([p.float.majorEncoded|Gd]);else if(n===void 0)r.push([p.float.majorEncoded|jd]);else{let o,i=!1;(!e||e.float64!==!0)&&(Pa(n),o=ki(Zt,1),n===o||Number.isNaN(n)?(Zt[0]=249,r.push(Zt.slice(0,3)),i=!0):(Da(n),o=Ti(Zt,1),n===o&&(Zt[0]=250,r.push(Zt.slice(0,5)),i=!0))),i||(Zd(n),o=Ma(Zt,1),Zt[0]=251,r.push(Zt.slice(0,9)))}}Qn.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){Pa(n);let o=ki(Zt,1);if(n===o||Number.isNaN(n))return 3;if(Da(n),o=Ti(Zt,1),n===o)return 5}return 9};var Ra=new ArrayBuffer(9),Vt=new DataView(Ra,1),Zt=new Uint8Array(Ra,0);function Pa(r){if(r===1/0)Vt.setUint16(0,31744,!1);else if(r===-1/0)Vt.setUint16(0,64512,!1);else if(Number.isNaN(r))Vt.setUint16(0,32256,!1);else{Vt.setFloat32(0,r);let t=Vt.getUint32(0),e=(t&2139095040)>>23,n=t&8388607;if(e===255)Vt.setUint16(0,31744,!1);else if(e===0)Vt.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=e-127;o<-24?Vt.setUint16(0,0):o<-14?Vt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Vt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ki(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 Da(r){Vt.setFloat32(0,r,!1)}function Ti(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 Zd(r){Vt.setFloat64(0,r,!1)}function Ma(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)}Qn.compareTokens=Ft.compareTokens;function K(r,t,e){throw new Error(`${M} encountered invalid minor (${e}) for major ${r[t]>>>5}`)}function Jn(r){return()=>{throw new Error(`${M} ${r}`)}}var S=[];for(let r=0;r<=23;r++)S[r]=K;S[24]=Gc;S[25]=jc;S[26]=Zc;S[27]=Wc;S[28]=K;S[29]=K;S[30]=K;S[31]=K;for(let r=32;r<=55;r++)S[r]=K;S[56]=Xc;S[57]=Yc;S[58]=Qc;S[59]=ta;S[60]=K;S[61]=K;S[62]=K;S[63]=K;for(let r=64;r<=87;r++)S[r]=ea;S[88]=ra;S[89]=na;S[90]=oa;S[91]=ia;S[92]=K;S[93]=K;S[94]=K;S[95]=Jn("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)S[r]=sa;S[120]=ca;S[121]=aa;S[122]=ua;S[123]=la;S[124]=K;S[125]=K;S[126]=K;S[127]=Jn("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)S[r]=da;S[152]=ha;S[153]=pa;S[154]=ma;S[155]=ga;S[156]=K;S[157]=K;S[158]=K;S[159]=ya;for(let r=160;r<=183;r++)S[r]=ba;S[184]=xa;S[185]=wa;S[186]=Ea;S[187]=va;S[188]=K;S[189]=K;S[190]=K;S[191]=Sa;for(let r=192;r<=215;r++)S[r]=Aa;S[216]=Ba;S[217]=_a;S[218]=Ia;S[219]=Ca;S[220]=K;S[221]=K;S[222]=K;S[223]=K;for(let r=224;r<=243;r++)S[r]=Jn("simple values are not supported");S[244]=K;S[245]=K;S[246]=K;S[247]=ka;S[248]=Jn("simple values are not supported");S[249]=Ua;S[250]=La;S[251]=Na;S[252]=K;S[253]=K;S[254]=K;S[255]=Ta;var Wt=[];for(let r=0;r<24;r++)Wt[r]=new I(p.uint,r,1);for(let r=-1;r>=-24;r--)Wt[31-r]=new I(p.negint,r,1);Wt[64]=new I(p.bytes,new Uint8Array(0),1);Wt[96]=new I(p.string,"",1);Wt[128]=new I(p.array,0,1);Wt[160]=new I(p.map,0,1);Wt[244]=new I(p.false,!1,1);Wt[245]=new I(p.true,!0,1);Wt[246]=new I(p.null,null,1);function Oa(r){switch(r.type){case p.false:return te([244]);case p.true:return te([245]);case p.null:return te([246]);case p.bytes:return r.value.length?void 0:te([64]);case p.string:return r.value===""?te([96]):void 0;case p.array:return r.value===0?te([128]):void 0;case p.map:return r.value===0?te([160]):void 0;case p.uint:return r.value<24?te([Number(r.value)]):void 0;case p.negint:if(r.value>=-24)return te([31-Number(r.value)])}}var Xd={float64:!1,mapSorter:Jd,quickEncodeToken:Oa};function Yd(){let r=[];return r[p.uint.major]=Ft,r[p.negint.major]=jn,r[p.bytes.major]=lr,r[p.string.major]=fa,r[p.array.major]=Wn,r[p.map.major]=Xn,r[p.tag.major]=Yn,r[p.float.major]=Qn,r}var Fa=Yd(),Ui=new Yr,eo=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(`${_i} object contains circular references`);return new r(e,t)}},Ae={null:new I(p.null,null),undefined:new I(p.undefined,void 0),true:new I(p.true,!0),false:new I(p.false,!1),emptyArray:new I(p.array,0),emptyMap:new I(p.map,0)},Be={number(r,t,e,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new I(p.float,r):r>=0?new I(p.uint,r):new I(p.negint,r)},bigint(r,t,e,n){return r>=BigInt(0)?new I(p.uint,r):new I(p.negint,r)},Uint8Array(r,t,e,n){return new I(p.bytes,r)},string(r,t,e,n){return new I(p.string,r)},boolean(r,t,e,n){return r?Ae.true:Ae.false},null(r,t,e,n){return Ae.null},undefined(r,t,e,n){return Ae.undefined},ArrayBuffer(r,t,e,n){return new I(p.bytes,new Uint8Array(r))},DataView(r,t,e,n){return new I(p.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,t,e,n){if(!r.length)return e.addBreakTokens===!0?[Ae.emptyArray,new I(p.break)]:Ae.emptyArray;n=eo.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=to(s,e,n);return e.addBreakTokens?[new I(p.array,r.length),o,new I(p.break)]:[new I(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?[Ae.emptyMap,new I(p.break)]:Ae.emptyMap;n=eo.createCheck(n,r);let c=[],a=0;for(let l of i)c[a++]=[to(l,e,n),to(o?r.get(l):r[l],e,n)];return Qd(c,e),e.addBreakTokens?[new I(p.map,s),c,new I(p.break)]:[new I(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 to(r,t={},e){let n=Mc(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(`${_i} unsupported type: ${n}`);return i(r,n,t,e)}function Qd(r,t){t.mapSorter&&r.sort(t.mapSorter)}function Jd(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=Fa[o].compareTokens(e,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Va(r,t,e,n){if(Array.isArray(t))for(let o of t)Va(r,o,e,n);else e[t.type.major](r,t,n)}function th(r,t,e){let n=to(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 Yr(s);if(i(c,n,e),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Bi(c.chunks[0])}}return Ui.reset(),Va(Ui,n,t,e),Ui.toBytes(!0)}function W(r,t){return t=Object.assign({},Xd,t),th(r,Fa,t)}var eh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ro=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=Wt[t];if(e===void 0){let n=S[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}},en=Symbol.for("DONE"),no=Symbol.for("BREAK");function rh(r,t,e){let n=[];for(let o=0;o<r.value;o++){let i=hr(t,e);if(i===no){if(r.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===en)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function nh(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=hr(t,e);if(c===no){if(r.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(c===en)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=hr(t,e);if(a===en)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 hr(r,t){if(r.done())return en;let e=r.next();if(e.type===p.break)return no;if(e.type.terminal)return e.value;if(e.type===p.array)return rh(e,r,t);if(e.type===p.map)return nh(e,r,t);if(e.type===p.tag){if(t.tags&&typeof t.tags[e.value]=="function"){let n=hr(r,t);return t.tags[e.value](n)}throw new Error(`${M} tag not supported (${e.value})`)}throw new Error("unsupported")}function $a(r,t){if(!(r instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},eh,t);let e=t.tokenizer||new ro(r,t),n=hr(e,t);if(n===en)throw new Error(`${M} did not find any content to decode`);if(n===no)throw new Error(`${M} got unexpected break`);return[n,r.subarray(e.pos())]}function X(r,t){let[e,n]=$a(r,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return e}var oh={type:1026,canEncode:r=>r===!0||r===!1,encode:r=>W(r),decode:r=>X(r)},za=oh;var ih={type:1027,canEncode:r=>typeof r=="number"&&!isNaN(r),encode:r=>W(r),decode:r=>X(r)},Ha=ih;var sh={type:1028,canEncode:r=>typeof r=="string",encode:r=>W(r),decode:r=>X(r)},qa=sh;var ch={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)=>X(r).map(o=>t.fromValue(o,e,n))},Ka=ch;var ah={type:1030,canEncode:r=>typeof r=="function",encode:(r,t,e,n)=>{let o=Je();return n?.callbacks.set(o,{context:e,fn:r}),W(o)},decode:(r,t,e,n)=>async(...o)=>new Promise((i,s)=>{let c=X(r),a=Je(),l={scope:a,result:qt(),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=Bn(l.abortSignals);u.addEventListener("abort",()=>{e.push(_t.encode({type:q.abortCallbackInvocation,message:cr.encode({scope:a,parents:l.parents})}))}),e.push(_t.encode({type:q.invokeCallback,message:sr.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()})})},Ga=ah;var uh={type:1031,canEncode:r=>r.toString()==="NaN"&&isNaN(r),decode:()=>NaN},ja=uh;var lh={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=X(r),e=new Error(t.message);return e.name=t.name,e.stack=t.stack,e.code=t.code,e.type=t.type,e}},Za=lh;var fh={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")}},Wa=fh;var Xa=["__defineGetter__","__defineSetter__","hasOwnProperty","__lookupGetter__","__lookupSetter__","isPrototypeOf","propertyIsEnumerable","toString","valueOf","__proto__","toLocaleString","constructor"],dh={type:2147483647,canEncode:r=>typeof r=="object",encode:(r,t,e,n)=>{let o={};for(let i in r)Xa.includes(i)||Object.hasOwn(r,i)&&(o[i]=r[i]);for(let i of Object.getOwnPropertyNames(Object.getPrototypeOf(r)))Xa.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 X(r).forEach(([s,c])=>{o[t.fromValue(s,e,n)]=t.fromValue(c,e,n)}),o}},rn=dh;var hh={type:1034,canEncode:r=>typeof r.next=="function"&&typeof r.throw=="function"&&typeof r.return=="function",encode:(r,t,e,n)=>rn.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=rn.decode(r,t,e,n);return o[Symbol.asyncIterator]=()=>o,o}},Ya=hh;var ph={type:1035,canEncode:r=>typeof r=="bigint",encode:r=>W(r),decode:r=>BigInt(X(r))},Qa=ph;var mh={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 X(r).forEach(([s,c])=>{let a=t.fromValue(s,e,n),l=t.fromValue(c,e,n);o.set(a,l)}),o}},Ja=mh;var gh={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 X(r).forEach(s=>{o.add(t.fromValue(s,e,n))}),o}},tu=gh;var yh={type:1038,canEncode:r=>r instanceof Uint8Array,encode:r=>r,decode:r=>r},eu=yh;var bh={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}},ru=bh;var xh={type:1040,canEncode:r=>r instanceof Date,encode:r=>W(r.toString()),decode:r=>new Date(X(r))},nu=xh;var wh={type:1041,canEncode:r=>r instanceof RegExp,encode:r=>W({source:r.source,flags:r.flags}),decode:r=>{let{source:t,flags:e}=X(r);return new RegExp(t,e)}},ou=wh;var iu=[Pc,Dc,za,Ha,qa,Ka,Ga,ja,Za,Wa,Ya,Qa,Ja,tu,eu,ru,nu,ou,rn];var oo=class{transformersMap;transformersList;constructor(t){this.transformersList=[...iu,...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 Pr(`Unsupported value type "${t}"`)}fromValue(t,e,n){let o=this.transformersMap[t.type];if(o==null)throw new Pr(`Unsupported value type "${t.type}"`);return o.decode(t.value??new Uint8Array(0),this,e,n)}};function Eh(r){return r.isScope===!0}function vh(r){return r.type===q.invokeMethod||r.type===q.invokeGeneratorMethod||r.type===q.invokeCallback}var Li=class{source;output;targets;invocations;values;messageHandlers;constructor(t){this.output=xe(),this.source=Tn(this.output),this.targets=new Map,this.invocations=new Map,this.values=new oo(t),this.sink=this.sink.bind(this),this.messageHandlers={[q.invokeMethod]:{decoder:Oe,handler:this.handleInvokeMethod.bind(this)},[q.invokeGeneratorMethod]:{decoder:Oe,handler:this.handleInvokeGeneratorMethod.bind(this)},[q.abortMethodInvocation]:{decoder:jr,handler:this.handleAbortMethod.bind(this),isScope:!0},[q.methodResolved]:{decoder:ir,handler:this.handleMethodResolved.bind(this),isScope:!0},[q.methodRejected]:{decoder:Zr,handler:this.handleMethodRejected.bind(this),isScope:!0,isError:!0},[q.invokeCallback]:{decoder:sr,handler:this.handleInvokeCallback.bind(this),isScope:!0},[q.abortCallbackInvocation]:{decoder:cr,handler:this.handleAbortCallback.bind(this),isScope:!0},[q.callbackResolved]:{decoder:Wr,handler:this.handleCallbackResolved.bind(this),isScope:!0},[q.callbackRejected]:{decoder:Xr,handler:this.handleCallbackRejected.bind(this),isScope:!0,isError:!0}}}async sink(t){for await(let e of Rr(t))try{let n=_t.decode(e),o=this.messageHandlers[n.type];if(o==null)continue;let i=o.decoder.decode(n.message),s;if(Eh(o))try{s=Rc(i,this.invocations)}catch{continue}o.handler(i,s).catch(c=>{vh(n)&&this.sendError(i,c),this.invocations.delete(i.scope)}).finally(()=>{n.type===q.invokeMethod&&this.invocations.delete(i.scope)})}catch{continue}}sendError(t,e){t.parents!=null?this.output.push(_t.encode({type:q.callbackRejected,message:Xr.encode({scope:t.scope,parents:t.parents,error:this.values.toValue(e)})})):this.output.push(_t.encode({type:q.methodRejected,message:Zr.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 Dn(`Cannot reuse RPC target name "${t}"`);this.targets.set(t,e)}async handleInvokeMethod(t){if(this.invocations.has(t.scope))throw new Dr;let e=new Map,n=new Map,o={scope:t.scope,result:qt(),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(_t.encode({type:q.methodResolved,message:ir.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 Dr;let e=new Map,n=new Map,o={scope:t.scope,result:qt(),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 Mn(`${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(_t.encode({type:q.methodResolved,message:ir.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 Pn(`"${t.substring(0,t.length-5)}" was not a function`):new Rn(`Could not find "${t}" on target`);if(typeof n!="function")throw new Mr("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 Fn;let o=await n.fn.apply(n.context,t.args.map(i=>this.values.fromValue(i,this.output,e)));this.output.push(_t.encode({type:q.callbackResolved,message:Wr.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 w=Je(),E={scope:w,result:qt(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(w,E),n.output.push(_t.encode({type:q.invokeMethod,message:Oe.encode({scope:w,path:t,args:s.map(d=>n.values.toValue(d,null,E))})}));let m=Bn(E.abortSignals);m.addEventListener("abort",()=>{n.output.push(_t.encode({type:q.abortMethodInvocation,message:jr.encode({scope:w})}))}),E.result.promise.then(d=>{f(d)},d=>{h(d)}).finally(()=>{n.invocations.delete(w),m.clear()})})),a}function u(){if(c==null){let f=Je(),h={scope:f,result:qt(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(f,h),n.output.push(_t.encode({type:q.invokeGeneratorMethod,message:Oe.encode({scope:f,path:t,args:s.map(E=>n.values.toValue(E,null,h))})}));let w;c={async next(){if(w!=null)throw w;let m=await(await h.result.promise).next();return m.done===!0&&n.invocations.delete(f),m},async throw(E){if(w!=null)throw w;try{let d=await(await h.result.promise).throw(E);return d.done===!0&&n.invocations.delete(f),d}catch(m){throw n.invocations.delete(f),w=E,m}},async return(E){if(w!=null)throw w;let d=await(await h.result.promise).return(E);return d.done===!0&&n.invocations.delete(f),d},[Symbol.asyncIterator]:()=>c}}return c}return new Proxy(e,{get(f,h,w){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 Mr(`Property ${h.toString()} was not used as a promise or async generator`)}})}})}};function su(r){return new Li(r)}var cu={type:4096,canEncode:r=>r.code!=null&&r.version!=null&&r.multihash!=null&&r["/"]!=null,encode:r=>r.bytes,decode:r=>gt.decode(r)};var nn=class extends Event{type;detail;constructor(t,e){super(t),this.type=t,this.detail=e}};var au={type:4099,canEncode:r=>r instanceof nn,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}=X(r);return new nn(o,t.fromValue(i,e,n))}};function ht(r,t="utf8"){let e=zn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var io=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 uu=45,Sh=15,pr=new io;function Ni(r){if(!(r.length>Sh))return pr.new(r).parseWith(()=>pr.readIPv4Addr())}function Ri(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>uu))return pr.new(r).parseWith(()=>pr.readIPv6Addr())}function so(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>uu))return pr.new(r).parseWith(()=>pr.readIPAddr())}var ew=parseInt("0xFFFF",16),rw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function du(r){return!!Ni(r)}function hu(r){return!!Ri(r)}function co(r){return!!so(r)}var pu=du,Ch=hu,Pi=function(r){let t=0;if(r=r.toString().trim(),pu(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Ch(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=pu(e[n]),s;i&&(s=Pi(e[n]),e[n]=ht(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,ht(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")},mu=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 mr={},Di={},Th=[[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"]];Th.forEach(r=>{let t=Uh(...r);Di[t.code]=t,mr[t.name]=t});function Uh(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function Y(r){if(typeof r=="number"){if(Di[r]!=null)return Di[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(mr[r]!=null)return mr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Fw=Y("ip4"),Vw=Y("ip6"),$w=Y("ipcidr");function Vi(r,t){switch(Y(r).code){case 4:case 41:return Nh(t);case 42:return Fi(t);case 6:case 273:case 33:case 132:return bu(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Fi(t);case 421:return Mh(t);case 444:return yu(t);case 445:return yu(t);case 466:return Dh(t);case 481:return globalThis.encodeURIComponent(Fi(t));default:return ht(t,"base16")}}function $i(r,t){switch(Y(r).code){case 4:return gu(t);case 41:return gu(t);case 42:return Oi(t);case 6:case 273:case 33:case 132:return zi(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Oi(t);case 421:return Rh(t);case 444:return Oh(t);case 445:return Fh(t);case 466:return Ph(t);case 481:return Oi(globalThis.decodeURIComponent(t));default:return Se(t,"base16")}}var Mi=Object.values(Hr).map(r=>r.decoder),Lh=function(){let r=Mi[0].or(Mi[1]);return Mi.slice(2).forEach(t=>r=r.or(t)),r}();function gu(r){if(!co(r))throw new Error("invalid ip address");return Pi(r)}function Nh(r){let t=mu(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!co(t))throw new Error("invalid ip address");return t}function zi(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function bu(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Oi(r){let t=Se(r),e=Uint8Array.from(we(t.length));return Lt([e,t],e.length+t.length)}function Fi(r){let t=oe(r);if(r=r.slice(ft(t)),r.length!==t)throw new Error("inconsistent lengths");return ht(r)}function Rh(r){let t;r[0]==="Q"||r[0]==="1"?t=ie(J.decode(`z${r}`)).bytes:t=gt.parse(r).multihash.bytes;let e=Uint8Array.from(we(t.length));return Lt([e,t],e.length+t.length)}function Ph(r){let t=Lh.decode(r),e=Uint8Array.from(we(t.length));return Lt([e,t],e.length+t.length)}function Dh(r){let t=oe(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+ht(e,"base64url")}function Mh(r){let t=oe(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return ht(e,"base58btc")}function Oh(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=zt.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=zi(n);return Lt([e,o],e.length+o.length)}function Fh(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=zt.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=zi(n);return Lt([e,o],e.length+o.length)}function yu(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=ht(t,"base32"),o=bu(e);return`${n}:${o}`}function xu(r){r=Hi(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=Y(s);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(i++,i>=o.length)throw Eu("invalid address: "+r);if(c.path===!0){n=Hi(o.slice(i).join("/")),t.push([c.code,$i(c.code,n)]),e.push([c.code,n]);break}let a=$i(c.code,o[i]);t.push([c.code,a]),e.push([c.code,Vi(c.code,a)])}return{string:wu(e),bytes:Ki(t),tuples:t,stringTuples:e,path:n}}function qi(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=oe(r,o),s=ft(i),c=Y(i),a=Vh(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 Eu("Invalid address Uint8Array: "+ht(r,"base16"));t.push([i,l]);let u=Vi(i,l);if(e.push([i,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:wu(e),tuples:t,stringTuples:e,path:n}}function wu(r){let t=[];return r.map(e=>{let n=Y(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Hi(t.join("/"))}function Ki(r){return Lt(r.map(t=>{let e=Y(t[0]),n=Uint8Array.from(we(e.code));return t.length>1&&t[1]!=null&&(n=Lt([n,t[1]])),n}))}function Vh(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=oe(t instanceof Uint8Array?t:Uint8Array.from(t));return e+ft(e)}}function Hi(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Eu(r){return new Error("Error parsing address: "+r)}var $h=Symbol.for("nodejs.util.inspect.custom"),ji=Symbol.for("@multiformats/js-multiaddr/multiaddr"),zh=[Y("dns").code,Y("dns4").code,Y("dns6").code,Y("dnsaddr").code],Gi=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},ao=class r{bytes;#e;#t;#r;#n;[ji]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=qi(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=xu(t)}else if(uo(t))e=qi(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=Y("tcp"),c=Y("udp"),a=Y("ip4"),l=Y("ip6"),u=Y("dns6"),f=Y("ip6zone");for(let[w,E]of this.stringTuples())w===f.code&&(i=`%${E??""}`),zh.includes(w)&&(e=s.name,o=443,n=`${E??""}${i}`,t=w===u.code?6:4),(w===s.code||w===c.code)&&(e=Y(w).name,o=parseInt(E??"")),(w===a.code||w===l.code)&&(e=Y(w).name,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({},Y(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>Y(t).name)}tuples(){return this.#t}stringTuples(){return this.#r}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(Ki(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===mr.p2p.code&&t.push([n,o]),n===mr["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?ht(J.decode(`z${n}`),"base58btc"):ht(gt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Gt(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 Gi(`no available resolver for ${e.name}`);return(await n(this,t)).map(i=>Ve(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)}[$h](){return`Multiaddr(${this.#e})`}};var vu=new Map;function uo(r){return!!r?.[ji]}function Ve(r){return new ao(r)}var Su={type:4097,canEncode:r=>uo(r),encode:r=>r.bytes,decode:r=>Ve(r)};function Au(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function Hh(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function gr(r,...t){if(!Hh(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function Bu(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Au(r.outputLen),Au(r.blockLen)}function yr(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 _u(r,t){gr(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var $e=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var lo=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Xt=(r,t)=>r<<32-t|r>>>t;var y1=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Iu(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function on(r){return typeof r=="string"&&(r=Iu(r)),gr(r),r}function Zi(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];gr(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 br=class{clone(){return this._cloneInto()}},b1={}.toString;function fo(r){let t=n=>r().update(on(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ho(r=32){if($e&&typeof $e.getRandomValues=="function")return $e.getRandomValues(new Uint8Array(r));if($e&&typeof $e.randomBytes=="function")return $e.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function qh(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)}var Cu=(r,t,e)=>r&t^~r&e,ku=(r,t,e)=>r&t^r&e^t&e,xr=class extends br{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=lo(this.buffer)}update(t){yr(this);let{view:e,buffer:n,blockLen:o}=this;t=on(t);let i=t.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=lo(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){yr(this),_u(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)e[f]=0;qh(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=lo(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.length=o,t.pos=c,t.finished=i,t.destroyed=s,o%e&&t.buffer.set(n),t}};var po=BigInt(4294967295),Wi=BigInt(32);function Tu(r,t=!1){return t?{h:Number(r&po),l:Number(r>>Wi&po)}:{h:Number(r>>Wi&po)|0,l:Number(r&po)|0}}function Kh(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:i,l:s}=Tu(r[o],t);[e[o],n[o]]=[i,s]}return[e,n]}var Gh=(r,t)=>BigInt(r>>>0)<<Wi|BigInt(t>>>0),jh=(r,t,e)=>r>>>e,Zh=(r,t,e)=>r<<32-e|t>>>e,Wh=(r,t,e)=>r>>>e|t<<32-e,Xh=(r,t,e)=>r<<32-e|t>>>e,Yh=(r,t,e)=>r<<64-e|t>>>e-32,Qh=(r,t,e)=>r>>>e-32|t<<64-e,Jh=(r,t)=>t,tp=(r,t)=>r,ep=(r,t,e)=>r<<e|t>>>32-e,rp=(r,t,e)=>t<<e|r>>>32-e,np=(r,t,e)=>t<<e-32|r>>>64-e,op=(r,t,e)=>r<<e-32|t>>>64-e;function ip(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var sp=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),cp=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,ap=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),up=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,lp=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),fp=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var dp={fromBig:Tu,split:Kh,toBig:Gh,shrSH:jh,shrSL:Zh,rotrSH:Wh,rotrSL:Xh,rotrBH:Yh,rotrBL:Qh,rotr32H:Jh,rotr32L:tp,rotlSH:ep,rotlSL:rp,rotlBH:np,rotlBL:op,add:ip,add3L:sp,add3H:cp,add4L:ap,add4H:up,add5H:fp,add5L:lp},O=dp;var[hp,pp]=O.split(["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))),_e=new Uint32Array(80),Ie=new Uint32Array(80),Xi=class extends xr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}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:w,Gl:E,Hh:m,Hl:d}=this;return[t,e,n,o,i,s,c,a,l,u,f,h,w,E,m,d]}set(t,e,n,o,i,s,c,a,l,u,f,h,w,E,m,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=w|0,this.Gl=E|0,this.Hh=m|0,this.Hl=d|0}process(t,e){for(let y=0;y<16;y++,e+=4)_e[y]=t.getUint32(e),Ie[y]=t.getUint32(e+=4);for(let y=16;y<80;y++){let B=_e[y-15]|0,R=Ie[y-15]|0,U=O.rotrSH(B,R,1)^O.rotrSH(B,R,8)^O.shrSH(B,R,7),k=O.rotrSL(B,R,1)^O.rotrSL(B,R,8)^O.shrSL(B,R,7),C=_e[y-2]|0,L=Ie[y-2]|0,it=O.rotrSH(C,L,19)^O.rotrBH(C,L,61)^O.shrSH(C,L,6),H=O.rotrSL(C,L,19)^O.rotrBL(C,L,61)^O.shrSL(C,L,6),F=O.add4L(k,H,Ie[y-7],Ie[y-16]),st=O.add4H(F,U,it,_e[y-7],_e[y-16]);_e[y]=st|0,Ie[y]=F|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:h,Fh:w,Fl:E,Gh:m,Gl:d,Hh:b,Hl:A}=this;for(let y=0;y<80;y++){let B=O.rotrSH(f,h,14)^O.rotrSH(f,h,18)^O.rotrBH(f,h,41),R=O.rotrSL(f,h,14)^O.rotrSL(f,h,18)^O.rotrBL(f,h,41),U=f&w^~f&m,k=h&E^~h&d,C=O.add5L(A,R,k,pp[y],Ie[y]),L=O.add5H(C,b,B,U,hp[y],_e[y]),it=C|0,H=O.rotrSH(n,o,28)^O.rotrBH(n,o,34)^O.rotrBH(n,o,39),F=O.rotrSL(n,o,28)^O.rotrBL(n,o,34)^O.rotrBL(n,o,39),st=n&i^n&c^i&c,_=o&s^o&a^s&a;b=m|0,A=d|0,m=w|0,d=E|0,w=f|0,E=h|0,{h:f,l:h}=O.add(l|0,u|0,L|0,it|0),l=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let T=O.add3L(it,F,_);n=O.add3H(T,L,H,st),o=T|0}({h:n,l:o}=O.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=O.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=O.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=O.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=O.add(this.Eh|0,this.El|0,f|0,h|0),{h:w,l:E}=O.add(this.Fh|0,this.Fl|0,w|0,E|0),{h:m,l:d}=O.add(this.Gh|0,this.Gl|0,m|0,d|0),{h:b,l:A}=O.add(this.Hh|0,this.Hl|0,b|0,A|0),this.set(n,o,i,s,c,a,l,u,f,h,w,E,m,d,b,A)}roundClean(){_e.fill(0),Ie.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Uu=fo(()=>new Xi);var go={};Ct(go,{aInRange:()=>Tt,abool:()=>Yt,abytes:()=>wr,bitGet:()=>wp,bitLen:()=>es,bitMask:()=>cn,bitSet:()=>Ep,bytesToHex:()=>le,bytesToNumberBE:()=>fe,bytesToNumberLE:()=>ke,concatBytes:()=>de,createHmacDrbg:()=>rs,ensureBytes:()=>ot,equalBytes:()=>bp,hexToBytes:()=>He,hexToNumber:()=>ts,inRange:()=>sn,isBytes:()=>Ce,memoized:()=>Ke,notImplemented:()=>Sp,numberToBytesBE:()=>Te,numberToBytesLE:()=>qe,numberToHexUnpadded:()=>ze,numberToVarBytesBE:()=>yp,utf8ToBytes:()=>xp,validateObject:()=>ee});var Ji=BigInt(0),mo=BigInt(1),mp=BigInt(2);function Ce(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function wr(r){if(!Ce(r))throw new Error("Uint8Array expected")}function Yt(r,t){if(typeof t!="boolean")throw new Error(`${r} must be valid boolean, got "${t}".`)}var gp=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function le(r){wr(r);let t="";for(let e=0;e<r.length;e++)t+=gp[r[e]];return t}function ze(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function ts(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var ue={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Lu(r){if(r>=ue._0&&r<=ue._9)return r-ue._0;if(r>=ue._A&&r<=ue._F)return r-(ue._A-10);if(r>=ue._a&&r<=ue._f)return r-(ue._a-10)}function He(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded 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=Lu(r.charCodeAt(i)),c=Lu(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 fe(r){return ts(le(r))}function ke(r){return wr(r),ts(le(Uint8Array.from(r).reverse()))}function Te(r,t){return He(r.toString(16).padStart(t*2,"0"))}function qe(r,t){return Te(r,t).reverse()}function yp(r){return He(ze(r))}function ot(r,t,e){let n;if(typeof t=="string")try{n=He(t)}catch(i){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${i}`)}else if(Ce(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} expected ${e} bytes, got ${o}`);return n}function de(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];wr(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}function bp(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function xp(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Yi=r=>typeof r=="bigint"&&Ji<=r;function sn(r,t,e){return Yi(r)&&Yi(t)&&Yi(e)&&t<=r&&r<e}function Tt(r,t,e,n){if(!sn(t,e,n))throw new Error(`expected valid ${r}: ${e} <= n < ${n}, got ${typeof t} ${t}`)}function es(r){let t;for(t=0;r>Ji;r>>=mo,t+=1);return t}function wp(r,t){return r>>BigInt(t)&mo}function Ep(r,t,e){return r|(e?mo:Ji)<<BigInt(t)}var cn=r=>(mp<<BigInt(r-1))-mo,Qi=r=>new Uint8Array(r),Nu=r=>Uint8Array.from(r);function rs(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=Qi(r),o=Qi(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},c=(...f)=>e(o,n,...f),a=(f=Qi())=>{o=c(Nu([0]),f),n=c(),f.length!==0&&(o=c(Nu([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 w=n.slice();h.push(w),f+=n.length}return de(...h)};return(f,h)=>{s(),a(f);let w;for(;!(w=h(l()));)a();return s(),w}}var vp={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"||Ce(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 ee(r,t,e={}){let n=(o,i,s)=>{let c=vp[i];if(typeof c!="function")throw new Error(`Invalid validator "${i}", expected function`);let a=r[o];if(!(s&&a===void 0)&&!c(a,r))throw new Error(`Invalid param ${String(o)}=${a} (${typeof a}), expected ${i}`)};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}var Sp=()=>{throw new Error("not implemented")};function Ke(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 at=BigInt(0),et=BigInt(1),Ge=BigInt(2),Ap=BigInt(3),ns=BigInt(4),Ru=BigInt(5),Pu=BigInt(8),Bp=BigInt(9),_p=BigInt(16);function Z(r,t){let e=r%t;return e>=at?e:t+e}function Ip(r,t,e){if(e<=at||t<at)throw new Error("Expected power/modulo > 0");if(e===et)return at;let n=et;for(;t>at;)t&et&&(n=n*r%e),r=r*r%e,t>>=et;return n}function rt(r,t,e){let n=r;for(;t-- >at;)n*=n,n%=e;return n}function yo(r,t){if(r===at||t<=at)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=Z(r,t),n=t,o=at,i=et,s=et,c=at;for(;e!==at;){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!==et)throw new Error("invert: does not exist");return Z(o,t)}function Cp(r){let t=(r-et)/Ge,e,n,o;for(e=r-et,n=0;e%Ge===at;e/=Ge,n++);for(o=Ge;o<r&&Ip(o,t,r)!==r-et;o++);if(n===1){let s=(r+et)/ns;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=(e+et)/Ge;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=n,u=c.pow(c.mul(c.ONE,o),e),f=c.pow(a,i),h=c.pow(a,e);for(;!c.eql(h,c.ONE);){if(c.eql(h,c.ZERO))return c.ZERO;let w=1;for(let m=c.sqr(h);w<l&&!c.eql(m,c.ONE);w++)m=c.sqr(m);let E=c.pow(u,et<<BigInt(l-w-1));u=c.sqr(E),f=c.mul(f,E),h=c.mul(h,u),l=w}return f}}function kp(r){if(r%ns===Ap){let t=(r+et)/ns;return function(n,o){let i=n.pow(o,t);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(r%Pu===Ru){let t=(r-Ru)/Pu;return function(n,o){let i=n.mul(o,Ge),s=n.pow(i,t),c=n.mul(o,s),a=n.mul(n.mul(c,Ge),s),l=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(l),o))throw new Error("Cannot find square root");return l}}return r%_p,Cp(r)}var Du=(r,t)=>(Z(r,t)&et)===et,Tp=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function os(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Tp.reduce((n,o)=>(n[o]="function",n),t);return ee(r,e)}function Up(r,t,e){if(e<at)throw new Error("Expected power > 0");if(e===at)return r.ONE;if(e===et)return t;let n=r.ONE,o=t;for(;e>at;)e&et&&(n=r.mul(n,o)),o=r.sqr(o),e>>=et;return n}function Lp(r,t){let e=new Array(t.length),n=t.reduce((i,s,c)=>r.is0(s)?i:(e[c]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return t.reduceRight((i,s,c)=>r.is0(s)?i:(e[c]=r.mul(i,e[c]),r.mul(i,s)),o),e}function is(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Ue(r,t,e=!1,n={}){if(r<=at)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=is(r,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=kp(r),c=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:cn(o),ZERO:at,ONE:et,create:a=>Z(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return at<=a&&a<r},is0:a=>a===at,isOdd:a=>(a&et)===et,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)=>Up(c,a,l),div:(a,l)=>Z(a*yo(l,r),r),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>yo(a,r),sqrt:n.sqrt||(a=>s(c,a)),invertBatch:a=>Lp(c,a),cmov:(a,l,u)=>u?l:a,toBytes:a=>e?qe(a,i):Te(a,i),fromBytes:a=>{if(a.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${a.length}`);return e?ke(a):fe(a)}});return Object.freeze(c)}function Mu(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 ss(r){let t=Mu(r);return t+Math.ceil(t/2)}function Ou(r,t,e=!1){let n=r.length,o=Mu(t),i=ss(t);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=e?fe(r):ke(r),c=Z(s,t-et)+et;return e?qe(c,o):Te(c,o)}var Rp=BigInt(0),cs=BigInt(1),as=new WeakMap,Fu=new WeakMap;function bo(r,t){let e=(i,s)=>{let c=s.negate();return i?c:s},n=i=>{if(!Number.isSafeInteger(i)||i<=0||i>t)throw new Error(`Wrong window size=${i}, should be [1..${t}]`)},o=i=>{n(i);let s=Math.ceil(t/i)+1,c=2**(i-1);return{windows:s,windowSize:c}};return{constTimeNegate:e,unsafeLadder(i,s){let c=r.ZERO,a=i;for(;s>Rp;)s&cs&&(c=c.add(a)),a=a.double(),s>>=cs;return c},precomputeWindow(i,s){let{windows:c,windowSize:a}=o(s),l=[],u=i,f=u;for(let h=0;h<c;h++){f=u,l.push(f);for(let w=1;w<a;w++)f=f.add(u),l.push(f);u=f.double()}return l},wNAF(i,s,c){let{windows:a,windowSize:l}=o(i),u=r.ZERO,f=r.BASE,h=BigInt(2**i-1),w=2**i,E=BigInt(i);for(let m=0;m<a;m++){let d=m*l,b=Number(c&h);c>>=E,b>l&&(b-=w,c+=cs);let A=d,y=d+Math.abs(b)-1,B=m%2!==0,R=b<0;b===0?f=f.add(e(B,s[A])):u=u.add(e(R,s[y]))}return{p:u,f}},wNAFCached(i,s,c){let a=Fu.get(i)||1,l=as.get(i);return l||(l=this.precomputeWindow(i,a),a!==1&&as.set(i,c(l))),this.wNAF(a,l,s)},setWindowSize(i,s){n(s),Fu.set(i,s),as.delete(i)}}}function xo(r,t,e,n){if(!Array.isArray(e)||!Array.isArray(n)||n.length!==e.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,f)=>{if(!t.isValid(u))throw new Error(`wrong scalar at index ${f}`)}),e.forEach((u,f)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${f}`)});let o=es(BigInt(e.length)),i=o>12?o-3:o>4?o-2:o?2:1,s=(1<<i)-1,c=new Array(s+1).fill(r.ZERO),a=Math.floor((t.BITS-1)/i)*i,l=r.ZERO;for(let u=a;u>=0;u-=i){c.fill(r.ZERO);for(let h=0;h<n.length;h++){let w=n[h],E=Number(w>>BigInt(u)&BigInt(s));c[E]=c[E].add(e[h])}let f=r.ZERO;for(let h=c.length-1,w=r.ZERO;h>0;h--)w=w.add(c[h]),f=f.add(w);if(l=l.add(f),u!==0)for(let h=0;h<i;h++)l=l.double()}return l}function an(r){return os(r.Fp),ee(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...is(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Qt=BigInt(0),Ut=BigInt(1),wo=BigInt(2),Pp=BigInt(8),Dp={zip215:!0};function Mp(r){let t=an(r);return ee(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Vu(r){let t=Mp(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,l=wo<<BigInt(c*8)-Ut,u=e.create,f=Ue(t.n,t.nBitLength),h=t.uvRatio||((x,g)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(g))}}catch{return{isValid:!1,value:Qt}}}),w=t.adjustScalarBytes||(x=>x),E=t.domain||((x,g,v)=>{if(Yt("phflag",v),g.length||v)throw new Error("Contexts/pre-hash are not supported");return x});function m(x,g){Tt("coordinate "+x,g,Qt,l)}function d(x){if(!(x instanceof y))throw new Error("ExtendedPoint expected")}let b=Ke((x,g)=>{let{ex:v,ey:N,ez:P}=x,D=x.is0();g==null&&(g=D?Pp:e.inv(P));let V=u(v*g),z=u(N*g),$=u(P*g);if(D)return{x:Qt,y:Ut};if($!==Ut)throw new Error("invZ was invalid");return{x:V,y:z}}),A=Ke(x=>{let{a:g,d:v}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:N,ey:P,ez:D,et:V}=x,z=u(N*N),$=u(P*P),j=u(D*D),Q=u(j*j),ut=u(z*g),lt=u(j*u(ut+$)),mt=u(Q+u(v*u(z*$)));if(lt!==mt)throw new Error("bad point: equation left != right (1)");let vt=u(N*P),ct=u(D*V);if(vt!==ct)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(g,v,N,P){this.ex=g,this.ey=v,this.ez=N,this.et=P,m("x",g),m("y",v),m("z",N),m("t",P),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(g){if(g instanceof y)throw new Error("extended point not allowed");let{x:v,y:N}=g||{};return m("x",v),m("y",N),new y(v,N,Ut,u(v*N))}static normalizeZ(g){let v=e.invertBatch(g.map(N=>N.ez));return g.map((N,P)=>N.toAffine(v[P])).map(y.fromAffine)}static msm(g,v){return xo(y,f,g,v)}_setWindowSize(g){U.setWindowSize(this,g)}assertValidity(){A(this)}equals(g){d(g);let{ex:v,ey:N,ez:P}=this,{ex:D,ey:V,ez:z}=g,$=u(v*z),j=u(D*P),Q=u(N*z),ut=u(V*P);return $===j&&Q===ut}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:g}=t,{ex:v,ey:N,ez:P}=this,D=u(v*v),V=u(N*N),z=u(wo*u(P*P)),$=u(g*D),j=v+N,Q=u(u(j*j)-D-V),ut=$+V,lt=ut-z,mt=$-V,vt=u(Q*lt),ct=u(ut*mt),It=u(Q*mt),re=u(lt*ut);return new y(vt,ct,re,It)}add(g){d(g);let{a:v,d:N}=t,{ex:P,ey:D,ez:V,et:z}=this,{ex:$,ey:j,ez:Q,et:ut}=g;if(v===BigInt(-1)){let Es=u((D-P)*(j+$)),vs=u((D+P)*(j-$)),No=u(vs-Es);if(No===Qt)return this.double();let Ss=u(V*wo*ut),As=u(z*wo*Q),Bs=As+Ss,_s=vs+Es,Is=As-Ss,xl=u(Bs*No),wl=u(_s*Is),El=u(Bs*Is),vl=u(No*_s);return new y(xl,wl,vl,El)}let lt=u(P*$),mt=u(D*j),vt=u(z*N*ut),ct=u(V*Q),It=u((P+D)*($+j)-lt-mt),re=ct-vt,Sr=ct+vt,Ar=u(mt-v*lt),ml=u(It*re),gl=u(Sr*Ar),yl=u(It*Ar),bl=u(re*Sr);return new y(ml,gl,bl,yl)}subtract(g){return this.add(g.negate())}wNAF(g){return U.wNAFCached(this,g,y.normalizeZ)}multiply(g){let v=g;Tt("scalar",v,Ut,n);let{p:N,f:P}=this.wNAF(v);return y.normalizeZ([N,P])[0]}multiplyUnsafe(g){let v=g;return Tt("scalar",v,Qt,n),v===Qt?R:this.equals(R)||v===Ut?this:this.equals(B)?this.wNAF(v).p:U.unsafeLadder(this,v)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(g){return b(this,g)}clearCofactor(){let{h:g}=t;return g===Ut?this:this.multiplyUnsafe(g)}static fromHex(g,v=!1){let{d:N,a:P}=t,D=e.BYTES;g=ot("pointHex",g,D),Yt("zip215",v);let V=g.slice(),z=g[D-1];V[D-1]=z&-129;let $=ke(V),j=v?l:e.ORDER;Tt("pointHex.y",$,Qt,j);let Q=u($*$),ut=u(Q-Ut),lt=u(N*Q-P),{isValid:mt,value:vt}=h(ut,lt);if(!mt)throw new Error("Point.fromHex: invalid y coordinate");let ct=(vt&Ut)===Ut,It=(z&128)!==0;if(!v&&vt===Qt&&It)throw new Error("Point.fromHex: x=0 and x_0=1");return It!==ct&&(vt=u(-vt)),y.fromAffine({x:vt,y:$})}static fromPrivateKey(g){return L(g).point}toRawBytes(){let{x:g,y:v}=this.toAffine(),N=qe(v,e.BYTES);return N[N.length-1]|=g&Ut?128:0,N}toHex(){return le(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,Ut,u(t.Gx*t.Gy)),y.ZERO=new y(Qt,Ut,Ut,Qt);let{BASE:B,ZERO:R}=y,U=bo(y,c*8);function k(x){return Z(x,n)}function C(x){return k(ke(x))}function L(x){let g=c;x=ot("private key",x,g);let v=ot("hashed private key",i(x),2*g),N=w(v.slice(0,g)),P=v.slice(g,2*g),D=C(N),V=B.multiply(D),z=V.toRawBytes();return{head:N,prefix:P,scalar:D,point:V,pointBytes:z}}function it(x){return L(x).pointBytes}function H(x=new Uint8Array,...g){let v=de(...g);return C(i(E(v,ot("context",x),!!o)))}function F(x,g,v={}){x=ot("message",x),o&&(x=o(x));let{prefix:N,scalar:P,pointBytes:D}=L(g),V=H(v.context,N,x),z=B.multiply(V).toRawBytes(),$=H(v.context,z,D,x),j=k(V+$*P);Tt("signature.s",j,Qt,n);let Q=de(z,qe(j,e.BYTES));return ot("result",Q,c*2)}let st=Dp;function _(x,g,v,N=st){let{context:P,zip215:D}=N,V=e.BYTES;x=ot("signature",x,2*V),g=ot("message",g),D!==void 0&&Yt("zip215",D),o&&(g=o(g));let z=ke(x.slice(V,2*V)),$,j,Q;try{$=y.fromHex(v,D),j=y.fromHex(x.slice(0,V),D),Q=B.multiplyUnsafe(z)}catch{return!1}if(!D&&$.isSmallOrder())return!1;let ut=H(P,j.toRawBytes(),$.toRawBytes(),g);return j.add($.multiplyUnsafe(ut)).subtract(Q).clearCofactor().equals(y.ZERO)}return B._setWindowSize(8),{CURVE:t,getPublicKey:it,sign:F,verify:_,ExtendedPoint:y,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>s(e.BYTES),precompute(x=8,g=y.BASE){return g._setWindowSize(x),g.multiply(BigInt(3)),g}}}}var us=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),$u=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),$1=BigInt(0),Op=BigInt(1),zu=BigInt(2),z1=BigInt(3),Fp=BigInt(5),Vp=BigInt(8);function $p(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=us,c=r*r%i*r%i,a=rt(c,zu,i)*c%i,l=rt(a,Op,i)*r%i,u=rt(l,Fp,i)*l%i,f=rt(u,t,i)*u%i,h=rt(f,e,i)*f%i,w=rt(h,n,i)*h%i,E=rt(w,o,i)*w%i,m=rt(E,o,i)*w%i,d=rt(m,t,i)*u%i;return{pow_p_5_8:rt(d,zu,i)*r%i,b2:c}}function zp(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Hp(r,t){let e=us,n=Z(t*t*t,e),o=Z(n*n*t,e),i=$p(r*o).pow_p_5_8,s=Z(r*n*i,e),c=Z(t*s*s,e),a=s,l=Z(s*$u,e),u=c===r,f=c===Z(-r,e),h=c===Z(-r*$u,e);return u&&(s=a),(f||h)&&(s=l),Du(s,e)&&(s=Z(-s,e)),{isValid:u||f,value:s}}var qp=Ue(us,void 0,!0),Kp={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:qp,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Vp,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Uu,randomBytes:ho,adjustScalarBytes:zp,uvRatio:Hp},Hu=Vu(Kp);var Eo=32;function qu(r,t,e){return Hu.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var vo=class{type="Ed25519";raw;constructor(t){this.raw=ls(t,Eo)}toMultihash(){return se.digest(So(this))}toCID(){return gt.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Gt(this.raw,t.raw)}verify(t,e){return qu(this.raw,e,t)}};function Gu(r){return r=ls(r,Eo),new vo(r)}function ls(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new me(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var $t;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})($t||($t={}));var fs;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(fs||(fs={}));(function(r){r.codec=()=>Gr(fs)})($t||($t={}));var un;(function(r){let t;r.codec=()=>(t==null&&(t=Bt((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),$t.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=$t.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>At(e,r.codec()),r.decode=(e,n)=>St(e,r.codec(),n)})(un||(un={}));var ds;(function(r){let t;r.codec=()=>(t==null&&(t=Bt((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),$t.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=$t.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>At(e,r.codec()),r.decode=(e,n)=>St(e,r.codec(),n)})(ds||(ds={}));var Zp=new Uint32Array([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]),Le=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ne=new Uint32Array(64),hs=class extends xr{constructor(){super(64,32,8,!1),this.A=Le[0]|0,this.B=Le[1]|0,this.C=Le[2]|0,this.D=Le[3]|0,this.E=Le[4]|0,this.F=Le[5]|0,this.G=Le[6]|0,this.H=Le[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)Ne[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let h=Ne[f-15],w=Ne[f-2],E=Xt(h,7)^Xt(h,18)^h>>>3,m=Xt(w,17)^Xt(w,19)^w>>>10;Ne[f]=m+Ne[f-7]+E+Ne[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=Xt(c,6)^Xt(c,11)^Xt(c,25),w=u+h+Cu(c,a,l)+Zp[f]+Ne[f]|0,m=(Xt(n,2)^Xt(n,13)^Xt(n,22))+ku(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(){Ne.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ju=fo(()=>new hs);var ln=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var Ao=class extends br{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Bu(t);let n=on(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),i.fill(0)}update(t){return yr(this),this.iHash.update(t),this}digestInto(t){yr(this),gr(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}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ps=(r,t,e)=>new Ao(r,t).update(e).digest();ps.create=(r,t)=>new Ao(r,t);function Zu(r){r.lowS!==void 0&&Yt("lowS",r.lowS),r.prehash!==void 0&&Yt("prehash",r.prehash)}function Wp(r){let t=an(r);ee(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("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("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Xp,hexToBytes:Yp}=go,he={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(r,t)=>{let{Err:e}=he;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=ze(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?ze(o.length/2|128):"";return`${ze(r)}${i}${o}${t}`},decode(r,t){let{Err:e}=he,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}=he;if(r<pe)throw new t("integer: negative integers are not allowed");let e=ze(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected assertion");return e},decode(r){let{Err:t}=he;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 Xp(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=he,o=typeof r=="string"?Yp(r):r;wr(o);let{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}=he,n=`${t.encode(2,e.encode(r.r))}${t.encode(2,e.encode(r.s))}`;return t.encode(48,n)}},pe=BigInt(0),pt=BigInt(1),y2=BigInt(2),Wu=BigInt(3),b2=BigInt(4);function Qp(r){let t=Wp(r),{Fp:e}=t,n=Ue(t.n,t.nBitLength),o=t.toBytes||((m,d,b)=>{let A=d.toAffine();return de(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),i=t.fromBytes||(m=>{let d=m.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(m){let{a:d,b}=t,A=e.sqr(m),y=e.mul(A,m);return e.add(e.add(y,e.mul(m,d)),b)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function c(m){return sn(m,pt,t.n)}function a(m){let{allowedPrivateKeyLengths:d,nByteLength:b,wrapPrivateKey:A,n:y}=t;if(d&&typeof m!="bigint"){if(Ce(m)&&(m=le(m)),typeof m!="string"||!d.includes(m.length))throw new Error("Invalid key");m=m.padStart(b*2,"0")}let B;try{B=typeof m=="bigint"?m:fe(ot("private key",m,b))}catch{throw new Error(`private key must be ${b} bytes, hex or bigint, not ${typeof m}`)}return A&&(B=Z(B,y)),Tt("private key",B,pt,y),B}function l(m){if(!(m instanceof h))throw new Error("ProjectivePoint expected")}let u=Ke((m,d)=>{let{px:b,py:A,pz:y}=m;if(e.eql(y,e.ONE))return{x:b,y:A};let B=m.is0();d==null&&(d=B?e.ONE:e.inv(y));let R=e.mul(b,d),U=e.mul(A,d),k=e.mul(y,d);if(B)return{x:e.ZERO,y:e.ZERO};if(!e.eql(k,e.ONE))throw new Error("invZ was invalid");return{x:R,y:U}}),f=Ke(m=>{if(m.is0()){if(t.allowInfinityPoint&&!e.is0(m.py))return;throw new Error("bad point: ZERO")}let{x:d,y:b}=m.toAffine();if(!e.isValid(d)||!e.isValid(b))throw new Error("bad point: x or y not FE");let A=e.sqr(b),y=s(d);if(!e.eql(A,y))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,b,A){if(this.px=d,this.py=b,this.pz=A,d==null||!e.isValid(d))throw new Error("x required");if(b==null||!e.isValid(b))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");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 y=B=>e.eql(B,e.ZERO);return y(b)&&y(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=e.invertBatch(d.map(A=>A.pz));return d.map((A,y)=>A.toAffine(b[y])).map(h.fromAffine)}static fromHex(d){let b=h.fromAffine(i(ot("pointHex",d)));return b.assertValidity(),b}static fromPrivateKey(d){return h.BASE.multiply(a(d))}static msm(d,b){return xo(h,n,d,b)}_setWindowSize(d){E.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:y}=this,{px:B,py:R,pz:U}=d,k=e.eql(e.mul(b,U),e.mul(B,y)),C=e.eql(e.mul(A,U),e.mul(R,y));return k&&C}negate(){return new h(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b}=t,A=e.mul(b,Wu),{px:y,py:B,pz:R}=this,U=e.ZERO,k=e.ZERO,C=e.ZERO,L=e.mul(y,y),it=e.mul(B,B),H=e.mul(R,R),F=e.mul(y,B);return F=e.add(F,F),C=e.mul(y,R),C=e.add(C,C),U=e.mul(d,C),k=e.mul(A,H),k=e.add(U,k),U=e.sub(it,k),k=e.add(it,k),k=e.mul(U,k),U=e.mul(F,U),C=e.mul(A,C),H=e.mul(d,H),F=e.sub(L,H),F=e.mul(d,F),F=e.add(F,C),C=e.add(L,L),L=e.add(C,L),L=e.add(L,H),L=e.mul(L,F),k=e.add(k,L),H=e.mul(B,R),H=e.add(H,H),L=e.mul(H,F),U=e.sub(U,L),C=e.mul(H,it),C=e.add(C,C),C=e.add(C,C),new h(U,k,C)}add(d){l(d);let{px:b,py:A,pz:y}=this,{px:B,py:R,pz:U}=d,k=e.ZERO,C=e.ZERO,L=e.ZERO,it=t.a,H=e.mul(t.b,Wu),F=e.mul(b,B),st=e.mul(A,R),_=e.mul(y,U),T=e.add(b,A),x=e.add(B,R);T=e.mul(T,x),x=e.add(F,st),T=e.sub(T,x),x=e.add(b,y);let g=e.add(B,U);return x=e.mul(x,g),g=e.add(F,_),x=e.sub(x,g),g=e.add(A,y),k=e.add(R,U),g=e.mul(g,k),k=e.add(st,_),g=e.sub(g,k),L=e.mul(it,x),k=e.mul(H,_),L=e.add(k,L),k=e.sub(st,L),L=e.add(st,L),C=e.mul(k,L),st=e.add(F,F),st=e.add(st,F),_=e.mul(it,_),x=e.mul(H,x),st=e.add(st,_),_=e.sub(F,_),_=e.mul(it,_),x=e.add(x,_),F=e.mul(st,x),C=e.add(C,F),F=e.mul(g,x),k=e.mul(T,k),k=e.sub(k,F),F=e.mul(T,st),L=e.mul(g,L),L=e.add(L,F),new h(k,C,L)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return E.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){Tt("scalar",d,pe,t.n);let b=h.ZERO;if(d===pe)return b;if(d===pt)return this;let{endo:A}=t;if(!A)return E.unsafeLadder(this,d);let{k1neg:y,k1:B,k2neg:R,k2:U}=A.splitScalar(d),k=b,C=b,L=this;for(;B>pe||U>pe;)B&pt&&(k=k.add(L)),U&pt&&(C=C.add(L)),L=L.double(),B>>=pt,U>>=pt;return y&&(k=k.negate()),R&&(C=C.negate()),C=new h(e.mul(C.px,A.beta),C.py,C.pz),k.add(C)}multiply(d){let{endo:b,n:A}=t;Tt("scalar",d,pt,A);let y,B;if(b){let{k1neg:R,k1:U,k2neg:k,k2:C}=b.splitScalar(d),{p:L,f:it}=this.wNAF(U),{p:H,f:F}=this.wNAF(C);L=E.constTimeNegate(R,L),H=E.constTimeNegate(k,H),H=new h(e.mul(H.px,b.beta),H.py,H.pz),y=L.add(H),B=it.add(F)}else{let{p:R,f:U}=this.wNAF(d);y=R,B=U}return h.normalizeZ([y,B])[0]}multiplyAndAddUnsafe(d,b,A){let y=h.BASE,B=(U,k)=>k===pe||k===pt||!U.equals(y)?U.multiplyUnsafe(k):U.multiply(k),R=B(this,b).add(B(d,A));return R.is0()?void 0:R}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:b}=t;if(d===pt)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===pt?this:b?b(h,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return Yt("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return Yt("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 w=t.nBitLength,E=bo(h,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:c}}function Jp(r){let t=an(r);return ee(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Xu(r){let t=Jp(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(_){return Z(_,n)}function c(_){return yo(_,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=Qp({...t,toBytes(_,T,x){let g=T.toAffine(),v=e.toBytes(g.x),N=de;return Yt("isCompressed",x),x?N(Uint8Array.from([T.hasEvenY()?2:3]),v):N(Uint8Array.from([4]),v,e.toBytes(g.y))},fromBytes(_){let T=_.length,x=_[0],g=_.subarray(1);if(T===o&&(x===2||x===3)){let v=fe(g);if(!sn(v,pt,e.ORDER))throw new Error("Point is not on curve");let N=u(v),P;try{P=e.sqrt(N)}catch(z){let $=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+$)}let D=(P&pt)===pt;return(x&1)===1!==D&&(P=e.neg(P)),{x:v,y:P}}else if(T===i&&x===4){let v=e.fromBytes(g.subarray(0,e.BYTES)),N=e.fromBytes(g.subarray(e.BYTES,2*e.BYTES));return{x:v,y:N}}else throw new Error(`Point of length ${T} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=_=>le(Te(_,t.nByteLength));function w(_){let T=n>>pt;return _>T}function E(_){return w(_)?s(-_):_}let m=(_,T,x)=>fe(_.slice(T,x));class d{constructor(T,x,g){this.r=T,this.s=x,this.recovery=g,this.assertValidity()}static fromCompact(T){let x=t.nByteLength;return T=ot("compactSignature",T,x*2),new d(m(T,0,x),m(T,x,2*x))}static fromDER(T){let{r:x,s:g}=he.toSig(ot("DER",T));return new d(x,g)}assertValidity(){Tt("r",this.r,pt,n),Tt("s",this.s,pt,n)}addRecoveryBit(T){return new d(this.r,this.s,T)}recoverPublicKey(T){let{r:x,s:g,recovery:v}=this,N=U(ot("msgHash",T));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let P=v===2||v===3?x+t.n:x;if(P>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let D=v&1?"03":"02",V=a.fromHex(D+h(P)),z=c(P),$=s(-N*z),j=s(g*z),Q=a.BASE.multiplyAndAddUnsafe(V,$,j);if(!Q)throw new Error("point at infinify");return Q.assertValidity(),Q}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return He(this.toDERHex())}toDERHex(){return he.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return He(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let b={isValidPrivateKey(_){try{return l(_),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let _=ss(t.n);return Ou(t.randomBytes(_),t.n)},precompute(_=8,T=a.BASE){return T._setWindowSize(_),T.multiply(BigInt(3)),T}};function A(_,T=!0){return a.fromPrivateKey(_).toRawBytes(T)}function y(_){let T=Ce(_),x=typeof _=="string",g=(T||x)&&_.length;return T?g===o||g===i:x?g===2*o||g===2*i:_ instanceof a}function B(_,T,x=!0){if(y(_))throw new Error("first arg must be private key");if(!y(T))throw new Error("second arg must be public key");return a.fromHex(T).multiply(l(_)).toRawBytes(x)}let R=t.bits2int||function(_){let T=fe(_),x=_.length*8-t.nBitLength;return x>0?T>>BigInt(x):T},U=t.bits2int_modN||function(_){return s(R(_))},k=cn(t.nBitLength);function C(_){return Tt(`num < 2^${t.nBitLength}`,_,pe,k),Te(_,t.nByteLength)}function L(_,T,x=it){if(["recovered","canonical"].some(lt=>lt in x))throw new Error("sign() legacy options not supported");let{hash:g,randomBytes:v}=t,{lowS:N,prehash:P,extraEntropy:D}=x;N==null&&(N=!0),_=ot("msgHash",_),Zu(x),P&&(_=ot("prehashed msgHash",g(_)));let V=U(_),z=l(T),$=[C(z),C(V)];if(D!=null&&D!==!1){let lt=D===!0?v(e.BYTES):D;$.push(ot("extraEntropy",lt))}let j=de(...$),Q=V;function ut(lt){let mt=R(lt);if(!f(mt))return;let vt=c(mt),ct=a.BASE.multiply(mt).toAffine(),It=s(ct.x);if(It===pe)return;let re=s(vt*s(Q+It*z));if(re===pe)return;let Sr=(ct.x===It?0:2)|Number(ct.y&pt),Ar=re;return N&&w(re)&&(Ar=E(re),Sr^=1),new d(It,Ar,Sr)}return{seed:j,k2sig:ut}}let it={lowS:t.lowS,prehash:!1},H={lowS:t.lowS,prehash:!1};function F(_,T,x=it){let{seed:g,k2sig:v}=L(_,T,x),N=t;return rs(N.hash.outputLen,N.nByteLength,N.hmac)(g,v)}a.BASE._setWindowSize(8);function st(_,T,x,g=H){let v=_;if(T=ot("msgHash",T),x=ot("publicKey",x),"strict"in g)throw new Error("options.strict was renamed to lowS");Zu(g);let{lowS:N,prehash:P}=g,D,V;try{if(typeof v=="string"||Ce(v))try{D=d.fromDER(v)}catch(ct){if(!(ct instanceof he.Err))throw ct;D=d.fromCompact(v)}else if(typeof v=="object"&&typeof v.r=="bigint"&&typeof v.s=="bigint"){let{r:ct,s:It}=v;D=new d(ct,It)}else throw new Error("PARSE");V=a.fromHex(x)}catch(ct){if(ct.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(N&&D.hasHighS())return!1;P&&(T=t.hash(T));let{r:z,s:$}=D,j=U(T),Q=c($),ut=s(j*Q),lt=s(z*Q),mt=a.BASE.multiplyAndAddUnsafe(V,ut,lt)?.toAffine();return mt?s(mt.x)===z:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:B,sign:F,verify:st,ProjectivePoint:a,Signature:d,utils:b}}function t0(r){return{hash:r,hmac:(t,...e)=>ps(r,t,Zi(...e)),randomBytes:ho}}function Yu(r,t){let e=n=>Xu({...r,...t0(n)});return Object.freeze({...e(t),create:e})}var tl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Qu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),e0=BigInt(1),ms=BigInt(2),Ju=(r,t)=>(r+t/ms)/t;function r0(r){let t=tl,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,w=rt(h,ms,t)*l%t,E=rt(w,o,t)*w%t,m=rt(E,i,t)*E%t,d=rt(m,c,t)*m%t,b=rt(d,a,t)*d%t,A=rt(b,c,t)*m%t,y=rt(A,e,t)*u%t,B=rt(y,s,t)*E%t,R=rt(B,n,t)*l%t,U=rt(R,ms,t);if(!gs.eql(gs.sqr(U),r))throw new Error("Cannot find square root");return U}var gs=Ue(tl,void 0,void 0,{sqrt:r0}),je=Yu({a:BigInt(0),b:BigInt(7),Fp:gs,n:Qu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Qu,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-e0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),c=Ju(i*r,t),a=Ju(-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}}}},ju),I2=BigInt(0);var C2=je.ProjectivePoint;function el(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function rl(r,t,e){let n=$r.digest(e instanceof Uint8Array?e:e.subarray());if(el(n))return n.then(({digest:o})=>je.verify(t,o,r)).catch(o=>{throw new ln(String(o))});try{return je.verify(t,n.digest,r)}catch(o){throw new ln(String(o))}}var Bo=class{type="secp256k1";raw;_key;constructor(t){this._key=ol(t),this.raw=nl(this._key)}toMultihash(){return se.digest(So(this))}toCID(){return gt.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Gt(this.raw,t.raw)}verify(t,e){return rl(this._key,e,t)}};function il(r){return new Bo(r)}function nl(r){return je.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ol(r){try{return je.ProjectivePoint.fromHex(r),r}catch(t){throw new mn(String(t))}}function sl(r){let{Type:t,Data:e}=un.decode(r.digest),n=e??new Uint8Array;switch(t){case $t.Ed25519:return Gu(n);case $t.secp256k1:return il(n);default:throw new _r}}function So(r){return un.encode({Type:$t[r.type],Data:r.raw})}var cl=Symbol.for("nodejs.util.inspect.custom"),n0=114,fn=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()})`}[hn]=!0;toString(){return this.string==null&&(this.string=J.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return gt.createV1(n0,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Gt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Gt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[cl](){return`PeerId(${this.toString()})`}},_o=class extends fn{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Io=class extends fn{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Co=class extends fn{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},o0=2336,ko=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=se.digest(Se(this.url))}[cl](){return`PeerId(${this.url})`}[hn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return gt.createV1(o0,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=ht(t)),t.toString()===this.toString())}};function al(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=ie(J.decode(`z${r}`));else{if(t==null)throw new me('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=ie(t.decode(r))}return ys(e)}function ys(r){if(s0(r))return new _o({multihash:r});if(i0(r))try{let t=sl(r);if(t.type==="Ed25519")return new Io({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Co({multihash:r,publicKey:t})}catch{let e=ht(r.digest);return new ko(new URL(e))}throw new gn("Supplied PeerID Multihash is invalid")}function i0(r){return r.code===se.code}function s0(r){return r.code===$r.code}var ul={type:4098,canEncode:r=>ks(r),encode:r=>r.toMultihash().bytes,decode:r=>ys(ie(r))};var bs=[cu,Su,ul,au];function To(r){let t={},e=r.components??r;return Object.entries(e).forEach(([n,o])=>{o?.[ge]!=null&&Array.isArray(o[ge])&&(t[n]=o[ge])}),t}function Er(r,t){let e={};for(let[n,o]of r.entries())e[n]=t(o);return e}async function Uo(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:Er(c.tags,a=>a.value),metadata:Er(c.metadata,a=>Jt.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 vr(r,t){let e=t[r];if(!pn(e))throw new me(`Component ${r} did not implement the PubSub interface`);return e}async function Lo(r){let t=await r.peerStore.get(r.peerId);return{id:t.id,addresses:t.addresses,protocols:[...t.protocols],tags:Er(t.tags,e=>e.value),metadata:Er(t.metadata,e=>Jt.encode(e))}}function ll(r){let t=r.logger.forComponent("libp2p:devtools-metrics:metrics-rpc");return{init:async()=>({self:await Lo(r),peers:await Uo(r,t),debug:localStorage.getItem("debug")??"",capabilities:To(r)}),setDebug:async e=>{e?.length!=null&&e?.length>0?(Hs(e),localStorage.setItem("debug",e)):(zs(),localStorage.removeItem("debug"))},openConnection:async(e,n)=>{let o;try{o=al(e)}catch{o=Ve(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 vr(e,r).getTopics()},async subscribe(e,n){vr(e,r).subscribe(n)},async unsubscribe(e,n){vr(e,r).unsubscribe(n)},async publish(e,n,o){await vr(e,r).publish(n,o)},async getSubscribers(e,n){return vr(e,r).getSubscribers(n)}}}}function xs(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 fl(r,t){for(let[e,n]of Object.entries(To(t)))if(n.includes(r))return t[e]}var dl="@libp2p/devtools-metrics:devtools",c0="@libp2p/devtools-metrics:worker",a0="@libp2p/devtools-metrics:content",hl="@libp2p/devtools-metrics:metrics",pl="________libp2p_devtools_metrics";Object.defineProperty(globalThis,pl,{value:!0,enumerable:!1,writable:!1});var ws=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=xe(),this.rpc=su({valueCodecs:bs}),this.devTools=this.rpc.createClient("devTools"),this.onPeersUpdate=xs(this.onPeersUpdate.bind(this),1e3),this.onSelfUpdate=xs(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=oc({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";[ge]=["@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)}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",ll(this.components)),await Ls(this.simpleMetrics),Promise.resolve().then(async()=>{await sc(this.rpcQueue,this.rpc,async e=>{for await(let n of e)window.postMessage({source:hl,type:"libp2p-rpc",message:Jt.encode(n)})})}).catch(e=>{this.log.error("error while reading RPC messages",e)});let t=fl("@libp2p/pubsub",this.components);pn(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 Ns(this.simpleMetrics)}onIncomingMessage(t){if(t.source!==window)return;let e=t.data;e?.source===dl&&e.type==="libp2p-rpc"&&this.rpcQueue.push(Jt.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 Lo(this.components)})}).catch(t=>{this.log.error("error sending peers message",t)})}onPeersUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("peers",{detail:await Uo(this.components,this.log)})}).catch(t=>{this.log.error("error sending peers message",t)})}};function u0(r){return t=>new ws(t,r)}return kl(l0);})();
|
|
2
|
+
"use strict";var Libp2PDevtoolsMetrics=(()=>{var Al=Object.create;var dn=Object.defineProperty;var Bl=Object.getOwnPropertyDescriptor;var _l=Object.getOwnPropertyNames;var Il=Object.getPrototypeOf,Cl=Object.prototype.hasOwnProperty;var Br=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ct=(e,t)=>{for(var r in t)dn(e,r,{get:t[r],enumerable:!0})},Cs=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _l(t))!Cl.call(e,o)&&o!==r&&dn(e,o,{get:()=>t[o],enumerable:!(n=Bl(t,o))||n.enumerable});return e};var kl=(e,t,r)=>(r=e!=null?Al(Il(e)):{},Cs(t||!e||!e.__esModule?dn(r,"default",{value:e,enumerable:!0}):r,e)),Tl=e=>Cs(dn({},"__esModule",{value:!0}),e);var Ho=Br((fm,js)=>{function Ht(){}Ht.prototype.clear=function(){this._root=null,this.size=0};Ht.prototype.find=function(e){for(var t=this._root;t!==null;){var r=this._comparator(e,t.data);if(r===0)return t.data;t=t.get_child(r>0)}return null};Ht.prototype.findIter=function(e){for(var t=this._root,r=this.iterator();t!==null;){var n=this._comparator(e,t.data);if(n===0)return r._cursor=t,r;r._ancestors.push(t),t=t.get_child(n>0)}return null};Ht.prototype.lowerBound=function(e){for(var t=this._root,r=this.iterator(),n=this._comparator;t!==null;){var o=n(e,t.data);if(o===0)return r._cursor=t,r;r._ancestors.push(t),t=t.get_child(o>0)}for(var i=r._ancestors.length-1;i>=0;--i)if(t=r._ancestors[i],n(e,t.data)<0)return r._cursor=t,r._ancestors.length=i,r;return r._ancestors.length=0,r};Ht.prototype.upperBound=function(e){for(var t=this.lowerBound(e),r=this._comparator;t.data()!==null&&r(t.data(),e)===0;)t.next();return t};Ht.prototype.min=function(){var e=this._root;if(e===null)return null;for(;e.left!==null;)e=e.left;return e.data};Ht.prototype.max=function(){var e=this._root;if(e===null)return null;for(;e.right!==null;)e=e.right;return e.data};Ht.prototype.iterator=function(){return new We(this)};Ht.prototype.each=function(e){for(var t=this.iterator(),r;(r=t.next())!==null;)if(e(r)===!1)return};Ht.prototype.reach=function(e){for(var t=this.iterator(),r;(r=t.prev())!==null;)if(e(r)===!1)return};function We(e){this._tree=e,this._ancestors=[],this._cursor=null}We.prototype.data=function(){return this._cursor!==null?this._cursor.data:null};We.prototype.next=function(){if(this._cursor===null){var e=this._tree._root;e!==null&&this._minNode(e)}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};We.prototype.prev=function(){if(this._cursor===null){var e=this._tree._root;e!==null&&this._maxNode(e)}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};We.prototype._minNode=function(e){for(;e.left!==null;)this._ancestors.push(e),e=e.left;this._cursor=e};We.prototype._maxNode=function(e){for(;e.right!==null;)this._ancestors.push(e),e=e.right;this._cursor=e};js.exports=Ht});var Xs=Br((dm,Ws)=>{var hf=Ho();function Xe(e){this.data=e,this.left=null,this.right=null,this.red=!0}Xe.prototype.get_child=function(e){return e?this.right:this.left};Xe.prototype.set_child=function(e,t){e?this.right=t:this.left=t};function wn(e){this._root=null,this._comparator=e,this.size=0}wn.prototype=new hf;wn.prototype.insert=function(e){var t=!1;if(this._root===null)this._root=new Xe(e),t=!0,this.size++;else{var r=new Xe(void 0),n=0,o=0,i=null,s=r,c=null,a=this._root;for(s.right=this._root;;){if(a===null?(a=new Xe(e),c.set_child(n,a),t=!0,this.size++):Ot(a.left)&&Ot(a.right)&&(a.red=!0,a.left.red=!1,a.right.red=!1),Ot(a)&&Ot(c)){var l=s.right===i;a===c.get_child(o)?s.set_child(l,Ir(i,!o)):s.set_child(l,Zs(i,!o))}var u=this._comparator(a.data,e);if(u===0)break;o=n,n=u<0,i!==null&&(s=i),i=c,c=a,a=a.get_child(n)}this._root=r.right}return this._root.red=!1,t};wn.prototype.remove=function(e){if(this._root===null)return!1;var t=new Xe(void 0),r=t;r.right=this._root;for(var n=null,o=null,i=null,s=1;r.get_child(s)!==null;){var c=s;o=n,n=r,r=r.get_child(s);var a=this._comparator(e,r.data);if(s=a>0,a===0&&(i=r),!Ot(r)&&!Ot(r.get_child(s))){if(Ot(r.get_child(!s))){var l=Ir(r,s);n.set_child(c,l),n=l}else if(!Ot(r.get_child(!s))){var u=n.get_child(!c);if(u!==null)if(!Ot(u.get_child(!c))&&!Ot(u.get_child(c)))n.red=!1,u.red=!0,r.red=!0;else{var f=o.right===n;Ot(u.get_child(c))?o.set_child(f,Zs(n,c)):Ot(u.get_child(!c))&&o.set_child(f,Ir(n,c));var h=o.get_child(f);h.red=!0,r.red=!0,h.left.red=!1,h.right.red=!1}}}}return i!==null&&(i.data=r.data,n.set_child(n.right===r,r.get_child(r.left===null)),this.size--),this._root=t.right,this._root!==null&&(this._root.red=!1),i!==null};function Ot(e){return e!==null&&e.red}function Ir(e,t){var r=e.get_child(!t);return e.set_child(!t,r.get_child(t)),r.set_child(t,e),e.red=!0,r.red=!1,r}function Zs(e,t){return e.set_child(!t,Ir(e.get_child(!t),!t)),Ir(e,t)}Ws.exports=wn});var Qs=Br((hm,Ys)=>{var pf=Ho();function Cr(e){this.data=e,this.left=null,this.right=null}Cr.prototype.get_child=function(e){return e?this.right:this.left};Cr.prototype.set_child=function(e,t){e?this.right=t:this.left=t};function En(e){this._root=null,this._comparator=e,this.size=0}En.prototype=new pf;En.prototype.insert=function(e){if(this._root===null)return this._root=new Cr(e),this.size++,!0;for(var t=0,r=null,n=this._root;;){if(n===null)return n=new Cr(e),r.set_child(t,n),ret=!0,this.size++,!0;if(this._comparator(n.data,e)===0)return!1;t=this._comparator(n.data,e)<0,r=n,n=n.get_child(t)}};En.prototype.remove=function(e){if(this._root===null)return!1;var t=new Cr(void 0),r=t;r.right=this._root;for(var n=null,o=null,i=1;r.get_child(i)!==null;){n=r,r=r.get_child(i);var s=this._comparator(e,r.data);i=s>0,s===0&&(o=r)}return o!==null?(o.data=r.data,n.set_child(n.right===r,r.get_child(r.left===null)),this._root=t.right,this.size--,!0):!1};Ys.exports=En});var tc=Br((pm,Js)=>{Js.exports={RBTree:Xs(),BinTree:Qs()}});var nc=Br((mm,rc)=>{var mf=tc().RBTree;function tt(e,t,r){this.discrete=e===!1,this.delta=e||.01,this.K=t===void 0?25:t,this.CX=r===void 0?1.1:r,this.centroids=new mf(ec),this.nreset=0,this.reset()}tt.prototype.reset=function(){this.centroids.clear(),this.n=0,this.nreset+=1,this.last_cumulate=0};tt.prototype.size=function(){return this.centroids.size};tt.prototype.toArray=function(e){var t=[];return e?(this._cumulate(!0),this.centroids.each(function(r){t.push(r)})):this.centroids.each(function(r){t.push({mean:r.mean,n:r.n})}),t};tt.prototype.summary=function(){var e=this.discrete?"exact ":"approximating ",t=[e+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 ec(e,t){return e.mean>t.mean?1:e.mean<t.mean?-1:0}function gf(e,t){return e.mean_cumn-t.mean_cumn}tt.prototype.push=function(e,t){t=t||1,e=Array.isArray(e)?e:[e];for(var r=0;r<e.length;r++)this._digest(e[r],t)};tt.prototype.push_centroid=function(e){e=Array.isArray(e)?e:[e];for(var t=0;t<e.length;t++)this._digest(e[t].mean,e[t].n)};tt.prototype._cumulate=function(e){if(!(this.n===this.last_cumulate||!e&&this.CX&&this.CX>this.n/this.last_cumulate)){var t=0;this.centroids.each(function(r){r.mean_cumn=t+r.n/2,t=r.cumn=t+r.n}),this.n=this.last_cumulate=t}};tt.prototype.find_nearest=function(e){if(this.size()===0)return null;var t=this.centroids.lowerBound({mean:e}),r=t.data()===null?t.prev():t.data();if(r.mean===e||this.discrete)return r;var n=t.prev();return n&&Math.abs(n.mean-e)<Math.abs(r.mean-e)?n:r};tt.prototype._new_centroid=function(e,t,r){var n={mean:e,n:t,cumn:r};return this.centroids.insert(n),this.n+=t,n};tt.prototype._addweight=function(e,t,r){t!==e.mean&&(e.mean+=r*(t-e.mean)/(e.n+r)),e.cumn+=r,e.mean_cumn+=r/2,e.n+=r,this.n+=r};tt.prototype._digest=function(e,t){var r=this.centroids.min(),n=this.centroids.max(),o=this.find_nearest(e);if(o&&o.mean===e)this._addweight(o,e,t);else if(o===r)this._new_centroid(e,t,0);else if(o===n)this._new_centroid(e,t,this.n);else if(this.discrete)this._new_centroid(e,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,e,t):this._new_centroid(e,t,o.cumn)}this._cumulate(!1),!this.discrete&&this.K&&this.size()>this.K/this.delta&&this.compress()};tt.prototype.bound_mean=function(e){var t=this.centroids.upperBound({mean:e}),r=t.prev(),n=r.mean===e?r:t.next();return[r,n]};tt.prototype.p_rank=function(e){var t=Array.isArray(e)?e:[e],r=t.map(this._p_rank,this);return Array.isArray(e)?r:r[0]};tt.prototype._p_rank=function(e){if(this.size()!==0){{if(e<this.centroids.min().mean)return 0;if(e>this.centroids.max().mean)return 1}this._cumulate(!0);var t=this.bound_mean(e),r=t[0],n=t[1];if(this.discrete)return r.cumn/this.n;var o=r.mean_cumn;return r!==n&&(o+=(e-r.mean)*(n.mean_cumn-r.mean_cumn)/(n.mean-r.mean)),o/this.n}};tt.prototype.bound_mean_cumn=function(e){this.centroids._comparator=gf;var t=this.centroids.upperBound({mean_cumn:e});this.centroids._comparator=ec;var r=t.prev(),n=r&&r.mean_cumn===e?r:t.next();return[r,n]};tt.prototype.percentile=function(e){var t=Array.isArray(e)?e:[e],r=t.map(this._percentile,this);return Array.isArray(e)?r:r[0]};tt.prototype._percentile=function(e){if(this.size()!==0){this._cumulate(!0);var t=this.n*e,r=this.bound_mean_cumn(t),n=r[0],o=r[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 yf(e){var t=Math.floor(Math.random()*e.length);return e.splice(t,1)[0]}tt.prototype.compress=function(){if(!this.compressing){var e=this.toArray();for(this.reset(),this.compressing=!0;e.length>0;)this.push_centroid(yf(e));this._cumulate(!0),this.compressing=!1}};function be(e){this.config=e||{},this.mode=this.config.mode||"auto",tt.call(this,this.mode==="cont"?e.delta:!1),this.digest_ratio=this.config.ratio||.9,this.digest_thresh=this.config.thresh||1e3,this.n_unique=0}be.prototype=Object.create(tt.prototype);be.prototype.constructor=be;be.prototype.push=function(e){tt.prototype.push.call(this,e),this.check_continuous()};be.prototype._new_centroid=function(e,t,r){this.n_unique+=1,tt.prototype._new_centroid.call(this,e,t,r)};be.prototype._addweight=function(e,t,r){e.n===1&&(this.n_unique-=1),tt.prototype._addweight.call(this,e,t,r)};be.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};rc.exports={TDigest:tt,Digest:be}});var f0={};Ct(f0,{LIBP2P_DEVTOOLS_METRICS_KEY:()=>ml,SOURCE_CONTENT_SCRIPT:()=>u0,SOURCE_DEVTOOLS:()=>hl,SOURCE_METRICS:()=>pl,SOURCE_SERVICE_WORKER:()=>a0,devToolsMetrics:()=>l0,valueCodecs:()=>bs});var hn=Symbol.for("@libp2p/peer-id");function ks(e){return!!e?.[hn]}var Ts;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(Ts||(Ts={}));var Ul=Symbol.for("@libp2p/pubsub");function pn(e){return!!e?.[Ul]}var me=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},mn=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var gn=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var _r=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};function Us(e){return e!=null&&typeof e.start=="function"&&typeof e.stop=="function"}async function Ls(...e){let t=[];for(let r of e)Us(r)&&t.push(r);await Promise.all(t.map(async r=>{r.beforeStart!=null&&await r.beforeStart()})),await Promise.all(t.map(async r=>{await r.start()})),await Promise.all(t.map(async r=>{r.afterStart!=null&&await r.afterStart()}))}async function Ns(...e){let t=[];for(let r of e)Us(r)&&t.push(r);await Promise.all(t.map(async r=>{r.beforeStop!=null&&await r.beforeStop()})),await Promise.all(t.map(async r=>{await r.stop()})),await Promise.all(t.map(async r=>{r.afterStop!=null&&await r.afterStop()}))}var ge=Symbol.for("@libp2p/service-capabilities"),y0=Symbol.for("@libp2p/service-dependencies");var Oo={};Ct(Oo,{base32:()=>zt,base32hex:()=>Vl,base32hexpad:()=>zl,base32hexpadupper:()=>Hl,base32hexupper:()=>$l,base32pad:()=>Ol,base32padupper:()=>Fl,base32upper:()=>Ml,base32z:()=>ql});var $0=new Uint8Array(0);function Rs(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function ne(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function Ps(e){return new TextEncoder().encode(e)}function Ds(e){return new TextDecoder().decode(e)}function Ll(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=e.length,a=e.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,d=0,b=0,A=E.length;b!==A&&E[b]===0;)b++,m++;for(var y=(A-b)*u+1>>>0,B=new Uint8Array(y);b!==A;){for(var R=E[b],U=0,k=y-1;(R!==0||U<d)&&k!==-1;k--,U++)R+=256*B[k]>>>0,B[k]=R%c>>>0,R=R/c>>>0;if(R!==0)throw new Error("Non-zero carry");d=U,b++}for(var C=y-d;C!==y&&B[C]===0;)C++;for(var L=a.repeat(m);C<y;++C)L+=e.charAt(B[C]);return L}function h(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 d=0,b=0;E[m]===a;)d++,m++;for(var A=(E.length-m)*l+1>>>0,y=new Uint8Array(A);E[m];){var B=r[E.charCodeAt(m)];if(B===255)return;for(var R=0,U=A-1;(B!==0||R<b)&&U!==-1;U--,R++)B+=c*y[U]>>>0,y[U]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");b=R,m++}if(E[m]!==" "){for(var k=A-b;k!==A&&y[k]===0;)k++;for(var C=new Uint8Array(d+(A-k)),L=d;k!==A;)C[L++]=y[k++];return C}}}function w(E){var m=h(E);if(m)return m;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:h,decode:w}}var Nl=Ll,Rl=Nl,Os=Rl;var Ro=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Po=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.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 Fs(this,t)}},Do=class{decoders;constructor(t){this.decoders=t}or(t){return Fs(this,t)}decode(t){let r=t[0],n=this.decoders[r];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 Fs(e,t){return new Do({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Mo=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ro(t,r,n),this.decoder=new Po(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ze({name:e,prefix:t,encode:r,decode:n}){return new Mo(e,t,r,n)}function ye({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Os(r,e);return Ze({prefix:t,name:e,encode:n,decode:i=>ne(o(i))})}function Pl(e,t,r,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=e.length;for(;e[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),c=0,a=0,l=0;for(let u=0;u<i;++u){let f=o[e[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,c+=r,c>=8&&(c-=8,s[l++]=255&a>>c)}if(c>=r||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return s}function Dl(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let a=0;a<e.length;++a)for(c=c<<8|e[a],s+=8;s>r;)s-=r,i+=t[o&c>>s];if(s!==0&&(i+=t[o&c<<r-s]),n)for(;i.length*r&7;)i+="=";return i}function nt({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Ze({prefix:t,name:e,encode(o){return Dl(o,n,r)},decode(o){return Pl(o,n,r,e)}})}var zt=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ml=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ol=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Fl=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Vl=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$l=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),zl=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Hl=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ql=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Fo={};Ct(Fo,{base58btc:()=>J,base58flickr:()=>Kl});var J=ye({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Kl=ye({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Vo={};Ct(Vo,{base64:()=>Jt,base64pad:()=>Gl,base64url:()=>jl,base64urlpad:()=>Zl});var Jt=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Gl=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),jl=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Zl=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Wl(e,t){try{if(typeof e=="string"&&e.length>0)return Xl(e);if(typeof e=="number"&&isFinite(e))return t?.long?Ql(e):Yl(e);throw new Error("Value is not a string or number.")}catch(r){let n=Jl(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function Xl(e){if(e=String(e),e.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(e);if(!t)return NaN;let r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var bn=Wl;function Yl(e){let t=Math.abs(e);return t>=864e5?`${Math.round(e/864e5)}d`:t>=36e5?`${Math.round(e/36e5)}h`:t>=6e4?`${Math.round(e/6e4)}m`:t>=1e3?`${Math.round(e/1e3)}s`:`${e}ms`}function Ql(e){let t=Math.abs(e);return t>=864e5?yn(e,t,864e5,"day"):t>=36e5?yn(e,t,36e5,"hour"):t>=6e4?yn(e,t,6e4,"minute"):t>=1e3?yn(e,t,1e3,"second"):`${e} ms`}function yn(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function Jl(e){return typeof e=="object"&&e!==null&&"message"in e}function $o(e){r.debug=r,r.default=r,r.coerce=a,r.disable=i,r.enable=o,r.enabled=s,r.humanize=bn,r.destroy=l,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.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 r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u){let f,h=null,w,E;function m(...d){if(!m.enabled)return;let b=m,A=Number(new Date),y=A-(f||A);b.diff=y,b.prev=f,b.curr=A,f=A,d[0]=r.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let B=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(U,k)=>{if(U==="%%")return"%";B++;let C=r.formatters[k];if(typeof C=="function"){let L=d[B];U=C.call(b,L),d.splice(B,1),B--}return U}),r.formatArgs.call(b,d),(b.log||r.log).apply(b,d)}return m.namespace=u,m.useColors=r.useColors(),m.color=r.selectColor(u),m.extend=n,m.destroy=r.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(w!==r.namespaces&&(w=r.namespaces,E=r.enabled(u)),E),set:d=>{h=d}}),typeof r.init=="function"&&r.init(m),m}function n(u,f){let h=r(this.namespace+(typeof f>"u"?":":f)+u);return h.log=this.log,h}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,h=(typeof u=="string"?u:"").split(/[\s,]+/),w=h.length;for(f=0;f<w;f++)h[f]&&(u=h[f].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(c),...r.skips.map(c).map(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,h;for(f=0,h=r.skips.length;f<h;f++)if(r.skips[f].test(u))return!1;for(f=0,h=r.names.length;f<h;f++)if(r.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 r.setupFormatters(r.formatters),r.enable(r.load()),r}var xn=cf(),tf=["#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 ef(){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 rf(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+bn(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}var nf=console.debug??console.log??(()=>{});function of(e){try{e?xn?.setItem("debug",e):xn?.removeItem("debug")}catch{}}function sf(){let e;try{e=xn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function cf(){try{return localStorage}catch{}}function af(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Vs=$o({formatArgs:rf,save:of,load:sf,useColors:ef,setupFormatters:af,colors:tf,storage:xn,log:nf});var bt=Vs;bt.formatters.b=e=>e==null?"undefined":J.baseEncode(e);bt.formatters.t=e=>e==null?"undefined":zt.baseEncode(e);bt.formatters.m=e=>e==null?"undefined":Jt.baseEncode(e);bt.formatters.p=e=>e==null?"undefined":e.toString();bt.formatters.c=e=>e==null?"undefined":e.toString();bt.formatters.k=e=>e==null?"undefined":e.toString();bt.formatters.a=e=>e==null?"undefined":e.toString();bt.formatters.e=e=>e==null?"undefined":$s(e.stack)??$s(e.message)??e.toString();function uf(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function zs(e){let t=uf(`${e}:trace`);return bt.enabled(`${e}:trace`)&&bt.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=bt(`${e}:trace`)),Object.assign(bt(e),{error:bt(`${e}:error`),trace:t})}function Hs(){bt.disable()}function qs(e){bt.enable(e)}function $s(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}function lf(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[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(),[r](){return this}}}var Ks=lf;function ff(e){return e[Symbol.asyncIterator]!=null}function Gs(e){return e?.then!=null}function df(e,t){let r=0;if(ff(e))return async function*(){for await(let a of e){let l=t(a,r++);Gs(l)&&await l,yield a}}();let n=Ks(e),{value:o,done:i}=n.next();if(i===!0)return function*(){}();if(typeof t(o,r++)?.then=="function")return async function*(){yield o;for await(let a of n){let l=t(a,r++);Gs(l)&&await l,yield a}}();let c=t;return function*(){yield o;for(let a of n)c(a,r++),yield a}()}var zo=df;var oc=kl(nc(),1),bf=zs("libp2p:simple-metrics"),kr=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}}},Tr=class{values={};update(t){Object.entries(t).forEach(([r,n])=>{this.values[r]=n})}increment(t){Object.entries(t).forEach(([r,n])=>{this.values[r]=this.values[r]??0;let o=typeof n=="number"?n:1;this.values[r]+=Number(o)})}decrement(t){Object.entries(t).forEach(([r,n])=>{this.values[r]=this.values[r]??0;let o=typeof n=="number"?n:1;this.values[r]-=Number(o)})}reset(){this.values={}}timer(t){let r=Date.now();return()=>{this.values[t]=Date.now()-r}}},Ur=class{bucketValues=new Map;countValue=0;sumValue=0;constructor(t){let r=[...t.buckets??[.005,.01,.025,.05,.1,.25,.5,1,2.5,5,10],1/0];for(let n of r)this.bucketValues.set(n,0)}observe(t){this.countValue++,this.sumValue+=t;for(let[r,n]of this.bucketValues.entries())t<=r&&this.bucketValues.set(r,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)}}},vn=class{histograms={};constructor(t){this.histograms={}}observe(t){for(let[r,n]of Object.entries(t))this.histograms[r]===void 0&&(this.histograms[r]=new Ur({})),this.histograms[r].observe(n)}reset(){for(let t of Object.values(this.histograms))t.reset()}timer(t){let r=Date.now();return()=>{this.observe({[t]:Date.now()-r})}}},Lr=class{sumValue=0;countValue=0;percentiles;tdigest=new oc.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)}}},Sn=class{summaries={};opts;constructor(t){this.summaries={},this.opts=t}observe(t){for(let[r,n]of Object.entries(t))this.summaries[r]===void 0&&(this.summaries[r]=new Lr(this.opts)),this.summaries[r].observe(n)}reset(){for(let t of Object.values(this.summaries))t.reset()}timer(t){let r=Date.now();return()=>{this.observe({[t]:Date.now()-r})}}},qo=class{metrics=new Map;transferStats;started;interval;intervalMs;onMetrics;constructor(t,r){this.started=!1,this._emitMetrics=this._emitMetrics.bind(this),this.intervalMs=r.intervalMs??1e3,this.onMetrics=r.onMetrics,this.transferStats=new Map}[Symbol.toStringTag]="@libp2p/metrics-simple";[ge]=["@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[r,n]of this.metrics.entries())n instanceof kr?t[r]=n.value:n instanceof Tr?t[r]=n.values:n instanceof Ur?t[r]={count:n.countValue,sum:n.sumValue,buckets:{...n.bucketValues}}:n instanceof vn?t[r]={...Object.fromEntries(Object.entries(n.histograms).map(([o,i])=>[o,{count:i.countValue,sum:i.sumValue,buckets:{...i.bucketValues}}]))}:n instanceof Lr?t[r]={count:n.countValue,sum:n.sumValue,percentiles:Object.fromEntries(n.percentiles.map(o=>[o,n.tdigest.percentile(o)]))}:n instanceof Sn?t[r]={...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[r]=await n();this.onMetrics(structuredClone(t))}).catch(t=>{bf.error("could not invoke onMetrics callback",t)})}_incrementValue(t,r){let n=this.transferStats.get(t)??0;this.transferStats.set(t,n+r)}_track(t,r){let n=this,o=t.sink;t.sink=async function(c){await o(zo(c,a=>{n._incrementValue(`${r} sent`,a.byteLength)}))};let i=t.source;t.source=zo(i,s=>{n._incrementValue(`${r} received`,s.byteLength)})}trackMultiaddrConnection(t){this._track(t,"global")}trackProtocolStream(t,r){t.protocol!=null&&this._track(t,t.protocol)}registerMetric(t,r={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(r?.calculate!=null){this.metrics.set(t,r.calculate);return}let n=new kr;return this.metrics.set(t,n),n}registerMetricGroup(t,r={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(r?.calculate!=null){this.metrics.set(t,r.calculate);return}let n=new Tr;return this.metrics.set(t,n),n}registerCounter(t,r={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(r?.calculate!=null){this.metrics.set(t,r.calculate);return}let n=new kr;return this.metrics.set(t,n),n}registerCounterGroup(t,r={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(r?.calculate!=null){this.metrics.set(t,r.calculate);return}let n=new Tr;return this.metrics.set(t,n),n}registerHistogram(t,r={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(r?.calculate!=null){this.metrics.set(t,r.calculate);return}let n=new Ur(r);return this.metrics.set(t,n),n}registerHistogramGroup(t,r={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(r?.calculate!=null){this.metrics.set(t,r.calculate);return}let n=new vn(r);return this.metrics.set(t,n),n}registerSummary(t,r={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(r?.calculate!=null){this.metrics.set(t,r.calculate);return}let n=new Lr(r);return this.metrics.set(t,n),n}registerSummaryGroup(t,r={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(r?.calculate!=null){this.metrics.set(t,r.calculate);return}let n=new Sn(r);return this.metrics.set(t,n),n}};function ic(e){return t=>new qo(t,e)}function qt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var An=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)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}},Ye=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new An(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 r=this.head;this.head=r.next=new An(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var Ko=class extends Error{type;code;constructor(t,r){super(t??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function xe(e={}){return xf(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},e)}function xf(e,t){t=t??{};let r=t.onEnd,n=new Ye,o,i,s,c=qt(),a=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((d,b)=>{i=A=>{i=null,n.push(A);try{d(e(n))}catch(y){b(y)}return o}}):e(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=qt()})}},l=d=>i!=null?i(d):(n.push(d),o),u=d=>(n=new Ye,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})),w=()=>(n=new Ye,h(),{done:!0}),E=d=>(h(d),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:w,throw:E,push:f,end:h,get readableLength(){return n.size},onEmpty:async d=>{let b=d?.signal;if(b?.throwIfAborted(),n.isEmpty())return;let A,y;b!=null&&(A=new Promise((B,R)=>{y=()=>{R(new Ko)},b.addEventListener("abort",y)}));try{await Promise.race([c.promise,A])}finally{y!=null&&b!=null&&b?.removeEventListener("abort",y)}}},r==null)return o;let m=o;return o={[Symbol.asyncIterator](){return this},next(){return m.next()},throw(d){return m.throw(d),r!=null&&(r(d),r=void 0),{done:!0}},return(){return m.return(),r!=null&&(r(),r=void 0),{done:!0}},push:f,end(d){return m.end(d),r!=null&&(r(d),r=void 0),o},get readableLength(){return m.readableLength},onEmpty:d=>m.onEmpty(d)},o}function wf(e){return e[Symbol.asyncIterator]!=null}function Ef(...e){let t=[];for(let r of e)wf(r)||t.push(r);return t.length===e.length?function*(){for(let r of t)yield*r}():async function*(){let r=xe({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(e.map(async n=>{for await(let o of n)r.push(o)})),r.end()}catch(n){r.end(n)}}),yield*r}()}var sc=Ef;function cc(e,...t){if(e==null)throw new Error("Empty pipeline");if(Go(e)){let n=e;e=()=>n.source}else if(uc(e)||ac(e)){let n=e;e=()=>n}let r=[e,...t];if(r.length>1&&Go(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n<r.length-1;n++)Go(r[n])&&(r[n]=Sf(r[n]));return vf(...r)}var vf=(...e)=>{let t;for(;e.length>0;)t=e.shift()(t);return t},ac=e=>e?.[Symbol.asyncIterator]!=null,uc=e=>e?.[Symbol.iterator]!=null,Go=e=>e==null?!1:e.sink!=null&&e.source!=null,Sf=e=>t=>{let r=e.sink(t);if(r?.then!=null){let n=xe({objectMode:!0});r.then(()=>{n.end()},s=>{n.end(s)});let o,i=e.source;if(ac(i))o=async function*(){yield*i,n.end()};else if(uc(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return sc(n,o())}return e.source};function Bn(e){let t=new globalThis.AbortController;function r(){t.abort();for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}for(let i of e){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=t.signal;return o.clear=n,o}function Kt(e=0){return new Uint8Array(e)}function xt(e=0){return new Uint8Array(e)}var Af=Math.pow(2,7),Bf=Math.pow(2,14),_f=Math.pow(2,21),jo=Math.pow(2,28),Zo=Math.pow(2,35),Wo=Math.pow(2,42),Xo=Math.pow(2,49),G=128,wt=127;function ft(e){if(e<Af)return 1;if(e<Bf)return 2;if(e<_f)return 3;if(e<jo)return 4;if(e<Zo)return 5;if(e<Wo)return 6;if(e<Xo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Yo(e,t,r=0){switch(ft(e)){case 8:t[r++]=e&255|G,e/=128;case 7:t[r++]=e&255|G,e/=128;case 6:t[r++]=e&255|G,e/=128;case 5:t[r++]=e&255|G,e/=128;case 4:t[r++]=e&255|G,e>>>=7;case 3:t[r++]=e&255|G,e>>>=7;case 2:t[r++]=e&255|G,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function If(e,t,r=0){switch(ft(e)){case 8:t.set(r++,e&255|G),e/=128;case 7:t.set(r++,e&255|G),e/=128;case 6:t.set(r++,e&255|G),e/=128;case 5:t.set(r++,e&255|G),e/=128;case 4:t.set(r++,e&255|G),e>>>=7;case 3:t.set(r++,e&255|G),e>>>=7;case 2:t.set(r++,e&255|G),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function Qo(e,t){let r=e[t],n=0;if(n+=r&wt,r<G||(r=e[t+1],n+=(r&wt)<<7,r<G)||(r=e[t+2],n+=(r&wt)<<14,r<G)||(r=e[t+3],n+=(r&wt)<<21,r<G)||(r=e[t+4],n+=(r&wt)*jo,r<G)||(r=e[t+5],n+=(r&wt)*Zo,r<G)||(r=e[t+6],n+=(r&wt)*Wo,r<G)||(r=e[t+7],n+=(r&wt)*Xo,r<G))return n;throw new RangeError("Could not decode varint")}function Cf(e,t){let r=e.get(t),n=0;if(n+=r&wt,r<G||(r=e.get(t+1),n+=(r&wt)<<7,r<G)||(r=e.get(t+2),n+=(r&wt)<<14,r<G)||(r=e.get(t+3),n+=(r&wt)<<21,r<G)||(r=e.get(t+4),n+=(r&wt)*jo,r<G)||(r=e.get(t+5),n+=(r&wt)*Zo,r<G)||(r=e.get(t+6),n+=(r&wt)*Wo,r<G)||(r=e.get(t+7),n+=(r&wt)*Xo,r<G))return n;throw new RangeError("Could not decode varint")}function we(e,t,r=0){return t==null&&(t=xt(ft(e))),t instanceof Uint8Array?Yo(e,t,r):If(e,t,r)}function oe(e,t=0){return e instanceof Uint8Array?Qo(e,t):Cf(e,t)}function Lt(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=xt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function Gt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}var fc=Symbol.for("@achingbrain/uint8arraylist");function lc(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function In(e){return!!e?.[fc]}var Qe=class e{bufs;length;[fc]=!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 r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(In(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(In(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=lc(this.bufs,t);return r.buf[r.index]}set(t,r){let n=lc(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(In(t))for(let n=0;n<t.length;n++)this.set(r+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,r){let{bufs:n,length:o}=this._subList(t,r);return Lt(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Lt(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===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=r>c&&r<=a;if(l&&u){if(t===c&&r===a){n.push(s);break}let f=t-c;n.push(s.subarray(f,f+(r-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-c));continue}if(u){if(r===a){n.push(s);break}n.push(s.subarray(0,r-c));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!In(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(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;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=r;f<=a;f+=u){u=0;for(let h=l;h>=0;h--){let w=this.get(f+h);if(n[h]!==w){u=Math.max(1,h-c[w]);break}}if(u===0)return f}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=xt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Kt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=Kt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=Kt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=xt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Kt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=Kt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=Kt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=Kt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=Kt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!Gt(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};function Cn(e){return e[Symbol.asyncIterator]!=null}var kn=e=>{let t=ft(e),r=xt(t);return we(e,r),kn.bytes=t,r};kn.bytes=0;function Tn(e,t){t=t??{};let r=t.lengthEncoder??kn;function*n(o){let i=r(o.byteLength);i instanceof Uint8Array?yield i:yield*i,o instanceof Uint8Array?yield o:yield*o}return Cn(e)?async function*(){for await(let o of e)yield*n(o)}():function*(){for(let o of e)yield*n(o)}()}Tn.single=(e,t)=>{t=t??{};let r=t.lengthEncoder??kn;return new Qe(r(e.byteLength),e)};var Un=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Ln=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Nn=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},Nr=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var kf=8,Tf=1024*1024*4,Re;(function(e){e[e.LENGTH=0]="LENGTH",e[e.DATA=1]="DATA"})(Re||(Re={}));var Jo=e=>{let t=oe(e);return Jo.bytes=ft(t),t};Jo.bytes=0;function Rr(e,t){let r=new Qe,n=Re.LENGTH,o=-1,i=t?.lengthDecoder??Jo,s=t?.maxLengthLength??kf,c=t?.maxDataLength??Tf;function*a(){for(;r.byteLength>0;){if(n===Re.LENGTH)try{if(o=i(r),o<0)throw new Un("Invalid message length");if(o>c)throw new Ln("Message length too long");let l=i.bytes;r.consume(l),t?.onLength!=null&&t.onLength(o),n=Re.DATA}catch(l){if(l instanceof RangeError){if(r.byteLength>s)throw new Nn("Message length length too long");break}throw l}if(n===Re.DATA){if(r.byteLength<o)break;let l=r.sublist(0,o);r.consume(o),t?.onData!=null&&t.onData(l),yield l,n=Re.LENGTH}}}return Cn(e)?async function*(){for await(let l of e)r.append(l),yield*a();if(r.byteLength>0)throw new Nr("Unexpected end of input")}():function*(){for(let l of e)r.append(l),yield*a();if(r.byteLength>0)throw new Nr("Unexpected end of input")}()}Rr.fromReader=(e,t)=>{let r=1,n=async function*(){for(;;)try{let{done:i,value:s}=await e.next(r);if(i===!0)return;s!=null&&(yield s)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{r=1}}();return Rr(n,{...t??{},onLength:i=>{r=i}})};var dc="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Je=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e));for(;e--;)t+=dc[r[e]&63];return t};var Rn=class extends Error{constructor(t="Method not found"){super(t),this.name="MethodNotFoundError"}},Pn=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidMethodError"}},Pr=class extends Error{constructor(t="Unsupported value type"){super(t),this.name="UnsupportedValueTypeError"}},Dn=class extends Error{constructor(t="Cannot reuse RPC target name"){super(t),this.name="DuplicateTargetNameError"}},Dr=class extends Error{constructor(t="Duplicate scope"){super(t),this.name="DuplicateScopeError"}},Mn=class extends Error{constructor(t="Invalid return type"){super(t),this.name="InvalidReturnTypeError"}},Mr=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidInvocationTypeError"}},tr=class extends Error{constructor(t="Parent invocation scope not found"){super(t),this.name="MissingParentScopeError"}},On=class extends Error{constructor(t="Invocation not found"){super(t),this.name="MissingInvocationError"}},Fn=class extends Error{constructor(t="Callback not found"){super(t),this.name="MissingCallbackError"}};var ti=new Float32Array([-0]),Ee=new Uint8Array(ti.buffer);function hc(e,t,r){ti[0]=e,t[r]=Ee[0],t[r+1]=Ee[1],t[r+2]=Ee[2],t[r+3]=Ee[3]}function pc(e,t){return Ee[0]=e[t],Ee[1]=e[t+1],Ee[2]=e[t+2],Ee[3]=e[t+3],ti[0]}var ei=new Float64Array([-0]),Et=new Uint8Array(ei.buffer);function mc(e,t,r){ei[0]=e,t[r]=Et[0],t[r+1]=Et[1],t[r+2]=Et[2],t[r+3]=Et[3],t[r+4]=Et[4],t[r+5]=Et[5],t[r+6]=Et[6],t[r+7]=Et[7]}function gc(e,t){return Et[0]=e[t],Et[1]=e[t+1],Et[2]=e[t+2],Et[3]=e[t+3],Et[4]=e[t+4],Et[5]=e[t+5],Et[6]=e[t+6],Et[7]=e[t+7],ei[0]}var Uf=BigInt(Number.MAX_SAFE_INTEGER),Lf=BigInt(Number.MIN_SAFE_INTEGER),Nt=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+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 r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(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,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Pe;if(t<Uf&&t>Lf)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>yc&&(o=0n,++n>yc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Pe;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):Pe}},Pe=new Nt(0,0);Pe.toBigInt=function(){return 0n};Pe.zzEncode=Pe.zzDecode=function(){return this};Pe.length=function(){return 1};var yc=4294967296n;function bc(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function xc(e,t,r){if(r-t<1)return"";let o,i=[],s=0,c;for(;t<r;)c=e[t++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(e[t++]&63)<<6|e[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 ri(e,t,r){let n=r,o,i;for(let s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((i=e.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function jt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Vn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var ni=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 Vn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw jt(this,4);return Vn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw jt(this,4);let t=pc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw jt(this,4);let t=gc(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw jt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return xc(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);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 Nt(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*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;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw jt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw jt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*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=Vn(this.buf,this.pos+=4),r=Vn(this.buf,this.pos+=4);return new Nt(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Qo(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 oi(e){return new ni(e instanceof Uint8Array?e:e.subarray())}function St(e,t,r){let n=oi(e);return t.decode(n,void 0,r)}var ii={};Ct(ii,{base10:()=>Nf});var Nf=ye({prefix:"9",name:"base10",alphabet:"0123456789"});var si={};Ct(si,{base16:()=>Rf,base16upper:()=>Pf});var Rf=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Pf=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ci={};Ct(ci,{base2:()=>Df});var Df=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ai={};Ct(ai,{base256emoji:()=>$f});var Ec=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}"),Mf=Ec.reduce((e,t,r)=>(e[r]=t,e),[]),Of=Ec.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Ff(e){return e.reduce((t,r)=>(t+=Mf[r],t),"")}function Vf(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Of[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var $f=Ze({prefix:"\u{1F680}",name:"base256emoji",encode:Ff,decode:Vf});var ui={};Ct(ui,{base36:()=>Or,base36upper:()=>zf});var Or=ye({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),zf=ye({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var li={};Ct(li,{base8:()=>Hf});var Hf=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fi={};Ct(fi,{identity:()=>qf});var qf=Ze({prefix:"\0",name:"identity",encode:e=>Ds(e),decode:e=>Ps(e)});var vg=new TextEncoder,Sg=new TextDecoder;var hi={};Ct(hi,{identity:()=>se});var jf=Ac,vc=128,Zf=127,Wf=~Zf,Xf=Math.pow(2,31);function Ac(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Xf;)t[r++]=e&255|vc,e/=128;for(;e&Wf;)t[r++]=e&255|vc,e>>>=7;return t[r]=e|0,Ac.bytes=r-n+1,t}var Yf=di,Qf=128,Sc=127;function di(e,n){var r=0,n=n||0,o=0,i=n,s,c=e.length;do{if(i>=c)throw di.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Sc)<<o:(s&Sc)*Math.pow(2,o),o+=7}while(s>=Qf);return di.bytes=i-n,r}var Jf=Math.pow(2,7),td=Math.pow(2,14),ed=Math.pow(2,21),rd=Math.pow(2,28),nd=Math.pow(2,35),od=Math.pow(2,42),id=Math.pow(2,49),sd=Math.pow(2,56),cd=Math.pow(2,63),ad=function(e){return e<Jf?1:e<td?2:e<ed?3:e<rd?4:e<nd?5:e<od?6:e<id?7:e<sd?8:e<cd?9:10},ud={encode:jf,decode:Yf,encodingLength:ad},ld=ud,Fr=ld;function Vr(e,t=0){return[Fr.decode(e,t),Fr.decode.bytes]}function er(e,t,r=0){return Fr.encode(e,t,r),t}function rr(e){return Fr.encodingLength(e)}function De(e,t){let r=t.byteLength,n=rr(e),o=n+rr(r),i=new Uint8Array(o+r);return er(e,i,0),er(r,i,n),i.set(t,o),new nr(e,r,t,i)}function ie(e){let t=ne(e),[r,n]=Vr(t),[o,i]=Vr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new nr(r,o,s,t)}function Bc(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Rs(e.bytes,r.bytes)}}var nr=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var _c=0,fd="identity",Ic=ne;function dd(e){return De(_c,Ic(e))}var se={code:_c,name:fd,encode:Ic,digest:dd};var gi={};Ct(gi,{sha256:()=>$r,sha512:()=>hd});function mi({name:e,code:t,encode:r}){return new pi(e,t,r)}var pi=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?De(this.code,r):r.then(n=>De(this.code,n))}else throw Error("Unknown type, must be binary type")}};function kc(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var $r=mi({name:"sha2-256",code:18,encode:kc("SHA-256")}),hd=mi({name:"sha2-512",code:19,encode:kc("SHA-512")});function Tc(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return md(r,yi(e),t??J.encoder);default:return gd(r,yi(e),t??zt.encoder)}}var Uc=new WeakMap;function yi(e){let t=Uc.get(e);if(t==null){let r=new Map;return Uc.set(e,r),r}return t}var gt=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,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:r}=this;if(t!==zr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==yd)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}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:r}=this.multihash,n=De(t,r);return e.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 e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Bc(t.multihash,n.multihash)}toString(t){return Tc(this,t)}toJSON(){return{"/":Tc(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 r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new e(n,o,i,s??Lc(n,o,i.bytes))}else if(r[bd]===!0){let{version:n,multihash:o,code:i}=r,s=ie(o);return e.create(n,i,s)}else return null}static create(t,r,n){if(typeof r!="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(r!==zr)throw new Error(`Version 0 CID must use dag-pb (code: ${zr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Lc(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,zr,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=ne(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new nr(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[f,h]=Vr(t.subarray(r));return r+=h,f},o=n(),i=zr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),a=n(),l=r+a,u=l-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:l}}static parse(t,r){let[n,o]=pd(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return yi(i).set(n,t),i}};function pd(e,t){switch(e[0]){case"Q":{let r=t??J;return[J.prefix,r.decode(`${J.prefix}${e}`)]}case J.prefix:{let r=t??J;return[J.prefix,r.decode(e)]}case zt.prefix:{let r=t??zt;return[zt.prefix,r.decode(e)]}case Or.prefix:{let r=t??Or;return[Or.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function md(e,t,r){let{prefix:n}=r;if(n!==J.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function gd(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var zr=112,yd=18;function Lc(e,t,r){let n=rr(e),o=n+rr(t),i=new Uint8Array(o+r.byteLength);return er(e,i,0),er(t,i,n),i.set(r,o),i}var bd=Symbol.for("@ipld/js-cid/CID");var Hr={...fi,...ci,...li,...ii,...si,...Oo,...ui,...Fo,...Vo,...ai},Kg={...gi,...hi};function Rc(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Nc=Rc("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),bi=Rc("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=xt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),xd={utf8:Nc,"utf-8":Nc,hex:Hr.base16,latin1:bi,ascii:bi,binary:bi,...Hr},zn=xd;function Se(e,t="utf8"){let r=zn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function xi(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return xt(s);o+s>t&&(n=xt(t),o=0);let c=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),c}}var Me=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function wi(){}var vi=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},wd=xi();function Ed(e){return globalThis.Buffer!=null?xt(e):wd(e)}var Kr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Me(wi,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Me(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Si((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(Hn,10,Nt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Nt.fromBigInt(t);return this._push(Hn,r.length(),r)}uint64Number(t){return this._push(Yo,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 r=Nt.fromBigInt(t).zzEncode();return this._push(Hn,r.length(),r)}sint64Number(t){let r=Nt.fromNumber(t).zzEncode();return this._push(Hn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Ei,1,t?1:0)}fixed32(t){return this._push(qr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Nt.fromBigInt(t);return this._push(qr,4,r.lo)._push(qr,4,r.hi)}fixed64Number(t){let r=Nt.fromNumber(t);return this._push(qr,4,r.lo)._push(qr,4,r.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(hc,4,t)}double(t){return this._push(mc,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Ei,1,0):this.uint32(r)._push(Sd,r,t)}string(t){let r=bc(t);return r!==0?this.uint32(r)._push(ri,r,t):this._push(Ei,1,0)}fork(){return this.states=new vi(this),this.head=this.tail=new Me(wi,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(wi,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=Ed(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Ei(e,t,r){t[r]=e&255}function vd(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Si=class extends Me{next;constructor(t,r){super(vd,t,r),this.next=void 0}};function Hn(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function qr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Sd(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Kr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(Ad,t,e),this},Kr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Bd,t,e),this});function Ad(e,t,r){t.set(e,r)}function Bd(e,t,r){e.length<40?ri(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(Se(e),r)}function Ai(){return new Kr}function At(e,t){let r=Ai();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var or;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(or||(or={}));function qn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Gr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let c=t(i);s.int32(c)},n=function(i){let s=i.int32();return t(s)};return qn("enum",or.VARINT,r,n)}function Bt(e,t){return qn("message",or.LENGTH_DELIMITED,e,t)}var ce=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var q;(function(e){e.invokeMethod="invokeMethod",e.methodResolved="methodResolved",e.methodRejected="methodRejected",e.invokeGeneratorMethod="invokeGeneratorMethod",e.abortMethodInvocation="abortMethodInvocation",e.invokeCallback="invokeCallback",e.callbackResolved="callbackResolved",e.callbackRejected="callbackRejected",e.abortCallbackInvocation="abortCallbackInvocation"})(q||(q={}));var Kn;(function(e){e[e.invokeMethod=0]="invokeMethod",e[e.methodResolved=1]="methodResolved",e[e.methodRejected=2]="methodRejected",e[e.invokeGeneratorMethod=3]="invokeGeneratorMethod",e[e.abortMethodInvocation=4]="abortMethodInvocation",e[e.invokeCallback=5]="invokeCallback",e[e.callbackResolved=6]="callbackResolved",e[e.callbackRejected=7]="callbackRejected",e[e.abortCallbackInvocation=8]="abortCallbackInvocation"})(Kn||(Kn={}));(function(e){e.codec=()=>Gr(Kn)})(q||(q={}));var kt;(function(e){let t;e.codec=()=>(t==null&&(t=Bt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.type!=null&&r.type!==0&&(n.uint32(8),n.uint32(r.type)),r.value!=null&&(n.uint32(18),n.bytes(r.value)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={type:0},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.type=r.uint32();break}case 2:{i.value=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>At(r,e.codec()),e.decode=(r,n)=>St(r,e.codec(),n)})(kt||(kt={}));var _t;(function(e){let t;e.codec=()=>(t==null&&(t=Bt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.type!=null&&Kn[r.type]!==0&&(n.uint32(8),q.codec().encode(r.type,n)),r.message!=null&&r.message.byteLength>0&&(n.uint32(18),n.bytes(r.message)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={type:q.invokeMethod,message:Kt(0)},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.type=q.codec().decode(r);break}case 2:{i.message=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>At(r,e.codec()),e.decode=(r,n)=>St(r,e.codec(),n)})(_t||(_t={}));var Oe;(function(e){let t;e.codec=()=>(t==null&&(t=Bt((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.scope!=null&&r.scope!==""&&(n.uint32(10),n.string(r.scope)),r.path!=null&&r.path!==""&&(n.uint32(18),n.string(r.path)),r.args!=null)for(let i of r.args)n.uint32(26),kt.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={scope:"",path:"",args:[]},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.scope=r.string();break}case 2:{i.path=r.string();break}case 3:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new ce('Decode error - map field "args" had too many elements');i.args.push(kt.codec().decode(r,r.uint32(),{limits:o.limits?.args$}));break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>At(r,e.codec()),e.decode=(r,n)=>St(r,e.codec(),n)})(Oe||(Oe={}));var jr;(function(e){let t;e.codec=()=>(t==null&&(t=Bt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.scope!=null&&r.scope!==""&&(n.uint32(10),n.string(r.scope)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={scope:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.scope=r.string();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>At(r,e.codec()),e.decode=(r,n)=>St(r,e.codec(),n)})(jr||(jr={}));var ir;(function(e){let t;e.codec=()=>(t==null&&(t=Bt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.scope!=null&&r.scope!==""&&(n.uint32(10),n.string(r.scope)),r.value!=null&&(n.uint32(18),kt.codec().encode(r.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={scope:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.scope=r.string();break}case 2:{i.value=kt.codec().decode(r,r.uint32(),{limits:o.limits?.value});break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>At(r,e.codec()),e.decode=(r,n)=>St(r,e.codec(),n)})(ir||(ir={}));var Zr;(function(e){let t;e.codec=()=>(t==null&&(t=Bt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.scope!=null&&r.scope!==""&&(n.uint32(10),n.string(r.scope)),r.error!=null&&(n.uint32(18),kt.codec().encode(r.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={scope:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.scope=r.string();break}case 2:{i.error=kt.codec().decode(r,r.uint32(),{limits:o.limits?.error});break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>At(r,e.codec()),e.decode=(r,n)=>St(r,e.codec(),n)})(Zr||(Zr={}));var sr;(function(e){let t;e.codec=()=>(t==null&&(t=Bt((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.scope!=null&&r.scope!==""&&(n.uint32(10),n.string(r.scope)),r.parents!=null)for(let i of r.parents)n.uint32(18),n.string(i);if(r.callback!=null&&r.callback!==""&&(n.uint32(26),n.string(r.callback)),r.args!=null)for(let i of r.args)n.uint32(34),kt.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={scope:"",parents:[],callback:"",args:[]},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.scope=r.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new ce('Decode error - map field "parents" had too many elements');i.parents.push(r.string());break}case 3:{i.callback=r.string();break}case 4:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new ce('Decode error - map field "args" had too many elements');i.args.push(kt.codec().decode(r,r.uint32(),{limits:o.limits?.args$}));break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>At(r,e.codec()),e.decode=(r,n)=>St(r,e.codec(),n)})(sr||(sr={}));var cr;(function(e){let t;e.codec=()=>(t==null&&(t=Bt((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.scope!=null&&r.scope!==""&&(n.uint32(10),n.string(r.scope)),r.parents!=null)for(let i of r.parents)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={scope:"",parents:[]},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.scope=r.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new ce('Decode error - map field "parents" had too many elements');i.parents.push(r.string());break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>At(r,e.codec()),e.decode=(r,n)=>St(r,e.codec(),n)})(cr||(cr={}));var Wr;(function(e){let t;e.codec=()=>(t==null&&(t=Bt((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.scope!=null&&r.scope!==""&&(n.uint32(10),n.string(r.scope)),r.parents!=null)for(let i of r.parents)n.uint32(18),n.string(i);r.value!=null&&(n.uint32(26),kt.codec().encode(r.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={scope:"",parents:[]},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.scope=r.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new ce('Decode error - map field "parents" had too many elements');i.parents.push(r.string());break}case 3:{i.value=kt.codec().decode(r,r.uint32(),{limits:o.limits?.value});break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>At(r,e.codec()),e.decode=(r,n)=>St(r,e.codec(),n)})(Wr||(Wr={}));var Xr;(function(e){let t;e.codec=()=>(t==null&&(t=Bt((r,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),r.scope!=null&&r.scope!==""&&(n.uint32(10),n.string(r.scope)),r.parents!=null)for(let i of r.parents)n.uint32(18),n.string(i);r.error!=null&&(n.uint32(26),kt.codec().encode(r.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={scope:"",parents:[]},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.scope=r.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new ce('Decode error - map field "parents" had too many elements');i.parents.push(r.string());break}case 3:{i.error=kt.codec().decode(r,r.uint32(),{limits:o.limits?.error});break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>At(r,e.codec()),e.decode=(r,n)=>St(r,e.codec(),n)})(Xr||(Xr={}));function _d(e){return e.parents!=null}function Pc(e,t){if(_d(e))return Id(e.parents,t);let r=t.get(e.scope);if(r==null)throw new On;return r}function Id(e,t){let r;for(let n of e){if(r==null){if(r=t.get(n),r==null)throw new tr;continue}if(r=r.children.get(n),r==null)throw new tr}if(r==null)throw new tr;return r}var Cd={type:1024,canEncode:e=>e===void 0,decode:()=>{}},Dc=Cd;var kd={type:1025,canEncode:e=>e===null,decode:()=>null},Mc=kd;var Td=["string","number","bigint","symbol"],Ud=["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 Oc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Td.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Ld(e))return"Buffer";let r=Nd(e);return r||"Object"}function Ld(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Nd(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Ud.includes(t))return t}var p=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,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 I=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var ar=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Rd=new TextDecoder,Pd=new TextEncoder;function Gn(e){return ar&&globalThis.Buffer.isBuffer(e)}function Bi(e){return e instanceof Uint8Array?Gn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var zc=ar?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Vc(e,t,r):(e,t,r)=>r-t>64?Rd.decode(e.subarray(t,r)):Vc(e,t,r),Hc=ar?e=>e.length>64?globalThis.Buffer.from(e):Fc(e):e=>e.length>64?Pd.encode(e):Fc(e),te=e=>Uint8Array.from(e),ur=ar?(e,t,r)=>Gn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),qc=ar?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Bi(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Kc=ar?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Gc(e,t){if(Gn(e)&&Gn(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Fc(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Vc(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=r){let c,a,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:c=e[t+1],(c&192)===128&&(u=(o&31)<<6|c&63,u>127&&(i=u));break;case 3:c=e[t+1],a=e[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=e[t+1],a=e[t+2],l=e[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 Dd(n)}var $c=4096;function Dd(e){let t=e.length;if(t<=$c)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=$c));return r}var Md=256,Yr=class{constructor(t=Md){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 r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Kc(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=ur(n,0,this.cursor)}else r=qc(this.chunks,this.cursor);return t&&this.reset(),r}};var M="CBOR decode error:",_i="CBOR encode error:",Qr=[];Qr[23]=1;Qr[24]=2;Qr[25]=3;Qr[26]=5;Qr[27]=9;function ae(e,t,r){if(e.length-t<r)throw new Error(`${M} not enough data for type`)}var dt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Rt(e,t,r){ae(e,t,1);let n=e[t];if(r.strict===!0&&n<dt[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Pt(e,t,r){ae(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<dt[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Dt(e,t,r){ae(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<dt[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Mt(e,t,r){ae(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.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(r.allowBigInt===!0)return i;throw new Error(`${M} integers outside of the safe integer range are not supported`)}function jc(e,t,r,n){return new I(p.uint,Rt(e,t+1,n),2)}function Zc(e,t,r,n){return new I(p.uint,Pt(e,t+1,n),3)}function Wc(e,t,r,n){return new I(p.uint,Dt(e,t+1,n),5)}function Xc(e,t,r,n){return new I(p.uint,Mt(e,t+1,n),9)}function Ft(e,t){return yt(e,0,t.value)}function yt(e,t,r){if(r<dt[0]){let n=Number(r);e.push([t|n])}else if(r<dt[1]){let n=Number(r);e.push([t|24,n])}else if(r<dt[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<dt[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);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,e.push(o)}else throw new Error(`${M} encountered BigInt larger than allowable range`)}}Ft.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};Ft.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Yc(e,t,r,n){return new I(p.negint,-1-Rt(e,t+1,n),2)}function Qc(e,t,r,n){return new I(p.negint,-1-Pt(e,t+1,n),3)}function Jc(e,t,r,n){return new I(p.negint,-1-Dt(e,t+1,n),5)}var Ii=BigInt(-1),ta=BigInt(1);function ea(e,t,r,n){let o=Mt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new I(p.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new I(p.negint,Ii-BigInt(o),9)}function jn(e,t){let r=t.value,n=typeof r=="bigint"?r*Ii-ta:r*-1-1;yt(e,t.type.majorEncoded,n)}jn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ii-ta:r*-1-1;return n<dt[0]?1:n<dt[1]?2:n<dt[2]?3:n<dt[3]?5:9};jn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Jr(e,t,r,n){ae(e,t,r+n);let o=ur(e,t+r,t+r+n);return new I(p.bytes,o,r+n)}function ra(e,t,r,n){return Jr(e,t,1,r)}function na(e,t,r,n){return Jr(e,t,2,Rt(e,t+1,n))}function oa(e,t,r,n){return Jr(e,t,3,Pt(e,t+1,n))}function ia(e,t,r,n){return Jr(e,t,5,Dt(e,t+1,n))}function sa(e,t,r,n){let o=Mt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return Jr(e,t,9,o)}function Zn(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===p.string?Hc(e.value):e.value),e.encodedBytes}function lr(e,t){let r=Zn(t);yt(e,t.type.majorEncoded,r.length),e.push(r)}lr.encodedSize=function(t){let r=Zn(t);return yt.encodedSize(r.length)+r.length};lr.compareTokens=function(t,r){return Fd(Zn(t),Zn(r))};function Fd(e,t){return e.length<t.length?-1:e.length>t.length?1:Gc(e,t)}function tn(e,t,r,n,o){let i=r+n;ae(e,t,i);let s=new I(p.string,zc(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=ur(e,t+r,t+i)),s}function ca(e,t,r,n){return tn(e,t,1,r,n)}function aa(e,t,r,n){return tn(e,t,2,Rt(e,t+1,n),n)}function ua(e,t,r,n){return tn(e,t,3,Pt(e,t+1,n),n)}function la(e,t,r,n){return tn(e,t,5,Dt(e,t+1,n),n)}function fa(e,t,r,n){let o=Mt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return tn(e,t,9,o,n)}var da=lr;function fr(e,t,r,n){return new I(p.array,n,r)}function ha(e,t,r,n){return fr(e,t,1,r)}function pa(e,t,r,n){return fr(e,t,2,Rt(e,t+1,n))}function ma(e,t,r,n){return fr(e,t,3,Pt(e,t+1,n))}function ga(e,t,r,n){return fr(e,t,5,Dt(e,t+1,n))}function ya(e,t,r,n){let o=Mt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return fr(e,t,9,o)}function ba(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return fr(e,t,1,1/0)}function Wn(e,t){yt(e,p.array.majorEncoded,t.value)}Wn.compareTokens=Ft.compareTokens;Wn.encodedSize=function(t){return yt.encodedSize(t.value)};function dr(e,t,r,n){return new I(p.map,n,r)}function xa(e,t,r,n){return dr(e,t,1,r)}function wa(e,t,r,n){return dr(e,t,2,Rt(e,t+1,n))}function Ea(e,t,r,n){return dr(e,t,3,Pt(e,t+1,n))}function va(e,t,r,n){return dr(e,t,5,Dt(e,t+1,n))}function Sa(e,t,r,n){let o=Mt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return dr(e,t,9,o)}function Aa(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return dr(e,t,1,1/0)}function Xn(e,t){yt(e,p.map.majorEncoded,t.value)}Xn.compareTokens=Ft.compareTokens;Xn.encodedSize=function(t){return yt.encodedSize(t.value)};function Ba(e,t,r,n){return new I(p.tag,r,1)}function _a(e,t,r,n){return new I(p.tag,Rt(e,t+1,n),2)}function Ia(e,t,r,n){return new I(p.tag,Pt(e,t+1,n),3)}function Ca(e,t,r,n){return new I(p.tag,Dt(e,t+1,n),5)}function ka(e,t,r,n){return new I(p.tag,Mt(e,t+1,n),9)}function Yn(e,t){yt(e,p.tag.majorEncoded,t.value)}Yn.compareTokens=Ft.compareTokens;Yn.encodedSize=function(t){return yt.encodedSize(t.value)};var Kd=20,Gd=21,jd=22,Zd=23;function Ta(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new I(p.null,null,1):new I(p.undefined,void 0,1)}function Ua(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new I(p.break,void 0,1)}function Ci(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${M} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new I(p.float,e,t)}function La(e,t,r,n){return Ci(ki(e,t+1),3,n)}function Na(e,t,r,n){return Ci(Ti(e,t+1),5,n)}function Ra(e,t,r,n){return Ci(Oa(e,t+1),9,n)}function Qn(e,t,r){let n=t.value;if(n===!1)e.push([p.float.majorEncoded|Kd]);else if(n===!0)e.push([p.float.majorEncoded|Gd]);else if(n===null)e.push([p.float.majorEncoded|jd]);else if(n===void 0)e.push([p.float.majorEncoded|Zd]);else{let o,i=!1;(!r||r.float64!==!0)&&(Da(n),o=ki(Zt,1),n===o||Number.isNaN(n)?(Zt[0]=249,e.push(Zt.slice(0,3)),i=!0):(Ma(n),o=Ti(Zt,1),n===o&&(Zt[0]=250,e.push(Zt.slice(0,5)),i=!0))),i||(Wd(n),o=Oa(Zt,1),Zt[0]=251,e.push(Zt.slice(0,9)))}}Qn.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Da(n);let o=ki(Zt,1);if(n===o||Number.isNaN(n))return 3;if(Ma(n),o=Ti(Zt,1),n===o)return 5}return 9};var Pa=new ArrayBuffer(9),Vt=new DataView(Pa,1),Zt=new Uint8Array(Pa,0);function Da(e){if(e===1/0)Vt.setUint16(0,31744,!1);else if(e===-1/0)Vt.setUint16(0,64512,!1);else if(Number.isNaN(e))Vt.setUint16(0,32256,!1);else{Vt.setFloat32(0,e);let t=Vt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Vt.setUint16(0,31744,!1);else if(r===0)Vt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Vt.setUint16(0,0):o<-14?Vt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Vt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ki(e,t){if(e.length-t<2)throw new Error(`${M} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Ma(e){Vt.setFloat32(0,e,!1)}function Ti(e,t){if(e.length-t<4)throw new Error(`${M} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Wd(e){Vt.setFloat64(0,e,!1)}function Oa(e,t){if(e.length-t<8)throw new Error(`${M} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Qn.compareTokens=Ft.compareTokens;function K(e,t,r){throw new Error(`${M} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Jn(e){return()=>{throw new Error(`${M} ${e}`)}}var S=[];for(let e=0;e<=23;e++)S[e]=K;S[24]=jc;S[25]=Zc;S[26]=Wc;S[27]=Xc;S[28]=K;S[29]=K;S[30]=K;S[31]=K;for(let e=32;e<=55;e++)S[e]=K;S[56]=Yc;S[57]=Qc;S[58]=Jc;S[59]=ea;S[60]=K;S[61]=K;S[62]=K;S[63]=K;for(let e=64;e<=87;e++)S[e]=ra;S[88]=na;S[89]=oa;S[90]=ia;S[91]=sa;S[92]=K;S[93]=K;S[94]=K;S[95]=Jn("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)S[e]=ca;S[120]=aa;S[121]=ua;S[122]=la;S[123]=fa;S[124]=K;S[125]=K;S[126]=K;S[127]=Jn("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)S[e]=ha;S[152]=pa;S[153]=ma;S[154]=ga;S[155]=ya;S[156]=K;S[157]=K;S[158]=K;S[159]=ba;for(let e=160;e<=183;e++)S[e]=xa;S[184]=wa;S[185]=Ea;S[186]=va;S[187]=Sa;S[188]=K;S[189]=K;S[190]=K;S[191]=Aa;for(let e=192;e<=215;e++)S[e]=Ba;S[216]=_a;S[217]=Ia;S[218]=Ca;S[219]=ka;S[220]=K;S[221]=K;S[222]=K;S[223]=K;for(let e=224;e<=243;e++)S[e]=Jn("simple values are not supported");S[244]=K;S[245]=K;S[246]=K;S[247]=Ta;S[248]=Jn("simple values are not supported");S[249]=La;S[250]=Na;S[251]=Ra;S[252]=K;S[253]=K;S[254]=K;S[255]=Ua;var Wt=[];for(let e=0;e<24;e++)Wt[e]=new I(p.uint,e,1);for(let e=-1;e>=-24;e--)Wt[31-e]=new I(p.negint,e,1);Wt[64]=new I(p.bytes,new Uint8Array(0),1);Wt[96]=new I(p.string,"",1);Wt[128]=new I(p.array,0,1);Wt[160]=new I(p.map,0,1);Wt[244]=new I(p.false,!1,1);Wt[245]=new I(p.true,!0,1);Wt[246]=new I(p.null,null,1);function Fa(e){switch(e.type){case p.false:return te([244]);case p.true:return te([245]);case p.null:return te([246]);case p.bytes:return e.value.length?void 0:te([64]);case p.string:return e.value===""?te([96]):void 0;case p.array:return e.value===0?te([128]):void 0;case p.map:return e.value===0?te([160]):void 0;case p.uint:return e.value<24?te([Number(e.value)]):void 0;case p.negint:if(e.value>=-24)return te([31-Number(e.value)])}}var Yd={float64:!1,mapSorter:th,quickEncodeToken:Fa};function Qd(){let e=[];return e[p.uint.major]=Ft,e[p.negint.major]=jn,e[p.bytes.major]=lr,e[p.string.major]=da,e[p.array.major]=Wn,e[p.map.major]=Xn,e[p.tag.major]=Yn,e[p.float.major]=Qn,e}var Va=Qd(),Ui=new Yr,eo=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${_i} object contains circular references`);return new e(r,t)}},Ae={null:new I(p.null,null),undefined:new I(p.undefined,void 0),true:new I(p.true,!0),false:new I(p.false,!1),emptyArray:new I(p.array,0),emptyMap:new I(p.map,0)},Be={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new I(p.float,e):e>=0?new I(p.uint,e):new I(p.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new I(p.uint,e):new I(p.negint,e)},Uint8Array(e,t,r,n){return new I(p.bytes,e)},string(e,t,r,n){return new I(p.string,e)},boolean(e,t,r,n){return e?Ae.true:Ae.false},null(e,t,r,n){return Ae.null},undefined(e,t,r,n){return Ae.undefined},ArrayBuffer(e,t,r,n){return new I(p.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new I(p.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Ae.emptyArray,new I(p.break)]:Ae.emptyArray;n=eo.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=to(s,r,n);return r.addBreakTokens?[new I(p.array,e.length),o,new I(p.break)]:[new I(p.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length;if(!s)return r.addBreakTokens===!0?[Ae.emptyMap,new I(p.break)]:Ae.emptyMap;n=eo.createCheck(n,e);let c=[],a=0;for(let l of i)c[a++]=[to(l,r,n),to(o?e.get(l):e[l],r,n)];return Jd(c,r),r.addBreakTokens?[new I(p.map,s),c,new I(p.break)]:[new I(p.map,s),c]}};Be.Map=Be.Object;Be.Buffer=Be.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Be[`${e}Array`]=Be.DataView;function to(e,t={},r){let n=Oc(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Be[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Be[n];if(!i)throw new Error(`${_i} unsupported type: ${n}`);return i(e,n,t,r)}function Jd(e,t){t.mapSorter&&e.sort(t.mapSorter)}function th(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Va[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function $a(e,t,r,n){if(Array.isArray(t))for(let o of t)$a(e,o,r,n);else r[t.type.major](e,t,n)}function eh(e,t,r){let n=to(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),c=new Yr(s);if(i(c,n,r),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Bi(c.chunks[0])}}return Ui.reset(),$a(Ui,n,t,r),Ui.toBytes(!0)}function W(e,t){return t=Object.assign({},Yd,t),eh(e,Va,t)}var rh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ro=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=Wt[t];if(r===void 0){let n=S[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;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},en=Symbol.for("DONE"),no=Symbol.for("BREAK");function nh(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=hr(t,r);if(i===no){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===en)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function oh(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<e.value;s++){let c=hr(t,r);if(c===no){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(c===en)throw new Error(`${M} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${M} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${M} found repeat map key "${c}"`);let a=hr(t,r);if(a===en)throw new Error(`${M} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(c,a):o[c]=a}return n?i:o}function hr(e,t){if(e.done())return en;let r=e.next();if(r.type===p.break)return no;if(r.type.terminal)return r.value;if(r.type===p.array)return nh(r,e,t);if(r.type===p.map)return oh(r,e,t);if(r.type===p.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=hr(e,t);return t.tags[r.value](n)}throw new Error(`${M} tag not supported (${r.value})`)}throw new Error("unsupported")}function za(e,t){if(!(e instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},rh,t);let r=t.tokenizer||new ro(e,t),n=hr(r,t);if(n===en)throw new Error(`${M} did not find any content to decode`);if(n===no)throw new Error(`${M} got unexpected break`);return[n,e.subarray(r.pos())]}function X(e,t){let[r,n]=za(e,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return r}var ih={type:1026,canEncode:e=>e===!0||e===!1,encode:e=>W(e),decode:e=>X(e)},Ha=ih;var sh={type:1027,canEncode:e=>typeof e=="number"&&!isNaN(e),encode:e=>W(e),decode:e=>X(e)},qa=sh;var ch={type:1028,canEncode:e=>typeof e=="string",encode:e=>W(e),decode:e=>X(e)},Ka=ch;var ah={type:1029,canEncode:e=>Array.isArray(e),encode:(e,t,r,n)=>W(e.map(o=>t.toValue(o,r,n))),decode:(e,t,r,n)=>X(e).map(o=>t.fromValue(o,r,n))},Ga=ah;var uh={type:1030,canEncode:e=>typeof e=="function",encode:(e,t,r,n)=>{let o=Je();return n?.callbacks.set(o,{context:r,fn:e}),W(o)},decode:(e,t,r,n)=>async(...o)=>new Promise((i,s)=>{let c=X(e),a=Je(),l={scope:a,result:qt(),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=Bn(l.abortSignals);u.addEventListener("abort",()=>{r.push(_t.encode({type:q.abortCallbackInvocation,message:cr.encode({scope:a,parents:l.parents})}))}),r.push(_t.encode({type:q.invokeCallback,message:sr.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()})})},ja=uh;var lh={type:1031,canEncode:e=>e.toString()==="NaN"&&isNaN(e),decode:()=>NaN},Za=lh;var fh={type:1032,canEncode:e=>e instanceof Error,encode:e=>W({message:e.message,name:e.name,code:e.code,type:e.type,stack:e.stack}),decode:e=>{let t=X(e),r=new Error(t.message);return r.name=t.name,r.stack=t.stack,r.code=t.code,r.type=t.type,r}},Wa=fh;var dh={type:1033,canEncode:e=>Array.isArray(e),encode:(e,t,r,n)=>{throw new Error("Promises are not supported")},decode:(e,t,r,n)=>{throw new Error("Promises are not supported")}},Xa=dh;var Ya=["__defineGetter__","__defineSetter__","hasOwnProperty","__lookupGetter__","__lookupSetter__","isPrototypeOf","propertyIsEnumerable","toString","valueOf","__proto__","toLocaleString","constructor"],hh={type:2147483647,canEncode:e=>typeof e=="object",encode:(e,t,r,n)=>{let o={};for(let i in e)Ya.includes(i)||Object.hasOwn(e,i)&&(o[i]=e[i]);for(let i of Object.getOwnPropertyNames(Object.getPrototypeOf(e)))Ya.includes(i)||(o[i]=e[i]);return W([...Object.entries(o)].map(([i,s])=>[t.toValue(i,e,n),t.toValue(s,e,n)]))},decode:(e,t,r,n)=>{let o={};return X(e).forEach(([s,c])=>{o[t.fromValue(s,r,n)]=t.fromValue(c,r,n)}),o}},rn=hh;var ph={type:1034,canEncode:e=>typeof e.next=="function"&&typeof e.throw=="function"&&typeof e.return=="function",encode:(e,t,r,n)=>rn.encode({next:e.next.bind(e),throw:e.throw.bind(e),return:e.return.bind(e)},t,r,n),decode:(e,t,r,n)=>{let o=rn.decode(e,t,r,n);return o[Symbol.asyncIterator]=()=>o,o}},Qa=ph;var mh={type:1035,canEncode:e=>typeof e=="bigint",encode:e=>W(e),decode:e=>BigInt(X(e))},Ja=mh;var gh={type:1036,canEncode:e=>e instanceof Map,encode:(e,t,r,n)=>W([...e.entries()].map(([o,i])=>[t.toValue(o,r,n),t.toValue(i,r,n)])),decode:(e,t,r,n)=>{let o=new Map;return X(e).forEach(([s,c])=>{let a=t.fromValue(s,r,n),l=t.fromValue(c,r,n);o.set(a,l)}),o}},tu=gh;var yh={type:1037,canEncode:e=>e instanceof Set,encode:(e,t,r,n)=>W([...e.values()].map(o=>t.toValue(o,r,n))),decode:(e,t,r,n)=>{let o=new Set;return X(e).forEach(s=>{o.add(t.fromValue(s,r,n))}),o}},eu=yh;var bh={type:1038,canEncode:e=>e instanceof Uint8Array,encode:e=>e,decode:e=>e},ru=bh;var xh={type:1039,canEncode:e=>e instanceof AbortSignal,encode:(e,t,r,n)=>(n?.abortSignals.push(e),new Uint8Array(0)),decode:(e,t,r,n)=>{let o=new AbortController;return n.abortControllers.push(o),o.signal}},nu=xh;var wh={type:1040,canEncode:e=>e instanceof Date,encode:e=>W(e.toString()),decode:e=>new Date(X(e))},ou=wh;var Eh={type:1041,canEncode:e=>e instanceof RegExp,encode:e=>W({source:e.source,flags:e.flags}),decode:e=>{let{source:t,flags:r}=X(e);return new RegExp(t,r)}},iu=Eh;var su=[Dc,Mc,Ha,qa,Ka,Ga,ja,Za,Wa,Xa,Qa,Ja,tu,eu,ru,nu,ou,iu,rn];var oo=class{transformersMap;transformersList;constructor(t){this.transformersList=[...su,...t?.valueCodecs??[]].sort((r,n)=>r.type<n.type?-1:r.type>n.type?1:0),this.transformersMap={},this.transformersList.forEach(r=>{if(this.transformersMap[r.type]!=null)throw new Error(`Duplicate transformer type ${r.type}`);this.transformersMap[r.type]=r})}toValue(t,r,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,r,n)}}throw new Pr(`Unsupported value type "${t}"`)}fromValue(t,r,n){let o=this.transformersMap[t.type];if(o==null)throw new Pr(`Unsupported value type "${t.type}"`);return o.decode(t.value??new Uint8Array(0),this,r,n)}};function vh(e){return e.isScope===!0}function Sh(e){return e.type===q.invokeMethod||e.type===q.invokeGeneratorMethod||e.type===q.invokeCallback}var Li=class{source;output;targets;invocations;values;messageHandlers;constructor(t){this.output=xe(),this.source=Tn(this.output),this.targets=new Map,this.invocations=new Map,this.values=new oo(t),this.sink=this.sink.bind(this),this.messageHandlers={[q.invokeMethod]:{decoder:Oe,handler:this.handleInvokeMethod.bind(this)},[q.invokeGeneratorMethod]:{decoder:Oe,handler:this.handleInvokeGeneratorMethod.bind(this)},[q.abortMethodInvocation]:{decoder:jr,handler:this.handleAbortMethod.bind(this),isScope:!0},[q.methodResolved]:{decoder:ir,handler:this.handleMethodResolved.bind(this),isScope:!0},[q.methodRejected]:{decoder:Zr,handler:this.handleMethodRejected.bind(this),isScope:!0,isError:!0},[q.invokeCallback]:{decoder:sr,handler:this.handleInvokeCallback.bind(this),isScope:!0},[q.abortCallbackInvocation]:{decoder:cr,handler:this.handleAbortCallback.bind(this),isScope:!0},[q.callbackResolved]:{decoder:Wr,handler:this.handleCallbackResolved.bind(this),isScope:!0},[q.callbackRejected]:{decoder:Xr,handler:this.handleCallbackRejected.bind(this),isScope:!0,isError:!0}}}async sink(t){for await(let r of Rr(t))try{let n=_t.decode(r),o=this.messageHandlers[n.type];if(o==null)continue;let i=o.decoder.decode(n.message),s;if(vh(o))try{s=Pc(i,this.invocations)}catch{continue}o.handler(i,s).catch(c=>{Sh(n)&&this.sendError(i,c),this.invocations.delete(i.scope)}).finally(()=>{n.type===q.invokeMethod&&this.invocations.delete(i.scope)})}catch{continue}}sendError(t,r){t.parents!=null?this.output.push(_t.encode({type:q.callbackRejected,message:Xr.encode({scope:t.scope,parents:t.parents,error:this.values.toValue(r)})})):this.output.push(_t.encode({type:q.methodRejected,message:Zr.encode({scope:t.scope,error:this.values.toValue(r)})}))}createClient(t){return this.proxy(t)}createTarget(t,r){if(this.targets.has(t))throw new Dn(`Cannot reuse RPC target name "${t}"`);this.targets.set(t,r)}async handleInvokeMethod(t){if(this.invocations.has(t.scope))throw new Dr;let r=new Map,n=new Map,o={scope:t.scope,result:qt(),callbacks:r,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(_t.encode({type:q.methodResolved,message:ir.encode({scope:t.scope,value:this.values.toValue(s)})}))}async handleAbortMethod(t,r){r.abortControllers.forEach(n=>{n.abort()})}async handleInvokeGeneratorMethod(t){if(this.invocations.has(t.scope))throw new Dr;let r=new Map,n=new Map,o={scope:t.scope,result:qt(),callbacks:r,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 Mn(`${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(_t.encode({type:q.methodResolved,message:ir.encode({scope:t.scope,value:this.values.toValue(c,null,o)})}))}lookupInvocationTarget(t){let r=t.split("."),n=this.targets.get(r[0]),o=n;for(let i=1;i<r.length;i++)o=n,n=n?.[r[i]];if(n==null)throw o!=null&&t.endsWith(".then")?new Pn(`"${t.substring(0,t.length-5)}" was not a function`):new Rn(`Could not find "${t}" on target`);if(typeof n!="function")throw new Mr("Invocation target was not a function");return{context:o,fn:n}}async handleMethodResolved(t,r){let n;t.value!=null&&(n=this.values.fromValue(t.value,this.output,r)),r.result.resolve(n)}async handleMethodRejected(t,r){let n;t.error!=null&&(n=this.values.fromValue(t.error,this.output,r)),r.result.reject(n)}async handleInvokeCallback(t,r){let n=r.callbacks.get(t.callback);if(n==null)throw new Fn;let o=await n.fn.apply(n.context,t.args.map(i=>this.values.fromValue(i,this.output,r)));this.output.push(_t.encode({type:q.callbackResolved,message:Wr.encode({scope:t.scope,parents:t.parents,value:this.values.toValue(o)})}))}async handleAbortCallback(t,r){r.abortControllers.forEach(n=>{n.abort()})}async handleCallbackResolved(t,r){let n;t.value!=null&&(n=this.values.fromValue(t.value,this.output,r)),r.children.get(t.scope)?.result.resolve(n),r.children.delete(t.scope)}async handleCallbackRejected(t,r){let n;t.error!=null&&(n=this.values.fromValue(t.error,this.output,r)),r.children.get(t.scope)?.result.reject(n),r.children.delete(t.scope)}proxy(t){let r=()=>{},n=this;return new Proxy(r,{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 w=Je(),E={scope:w,result:qt(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(w,E),n.output.push(_t.encode({type:q.invokeMethod,message:Oe.encode({scope:w,path:t,args:s.map(d=>n.values.toValue(d,null,E))})}));let m=Bn(E.abortSignals);m.addEventListener("abort",()=>{n.output.push(_t.encode({type:q.abortMethodInvocation,message:jr.encode({scope:w})}))}),E.result.promise.then(d=>{f(d)},d=>{h(d)}).finally(()=>{n.invocations.delete(w),m.clear()})})),a}function u(){if(c==null){let f=Je(),h={scope:f,result:qt(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(f,h),n.output.push(_t.encode({type:q.invokeGeneratorMethod,message:Oe.encode({scope:f,path:t,args:s.map(E=>n.values.toValue(E,null,h))})}));let w;c={async next(){if(w!=null)throw w;let m=await(await h.result.promise).next();return m.done===!0&&n.invocations.delete(f),m},async throw(E){if(w!=null)throw w;try{let d=await(await h.result.promise).throw(E);return d.done===!0&&n.invocations.delete(f),d}catch(m){throw n.invocations.delete(f),w=E,m}},async return(E){if(w!=null)throw w;let d=await(await h.result.promise).return(E);return d.done===!0&&n.invocations.delete(f),d},[Symbol.asyncIterator]:()=>c}}return c}return new Proxy(r,{get(f,h,w){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 Mr(`Property ${h.toString()} was not used as a promise or async generator`)}})}})}};function cu(e){return new Li(e)}var au={type:4096,canEncode:e=>e.code!=null&&e.version!=null&&e.multihash!=null&&e["/"]!=null,encode:e=>e.bytes,decode:e=>gt.decode(e)};var nn=class extends Event{type;detail;constructor(t,r){super(t),this.type=t,this.detail=r}};var uu={type:4099,canEncode:e=>e instanceof nn,encode:(e,t,r,n)=>W({type:e.type,detail:t.toValue(e.detail,r,n)}),decode:(e,t,r,n)=>{let{type:o,detail:i}=X(e);return new nn(o,t.fromValue(i,r,n))}};function ht(e,t="utf8"){let r=zn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var io=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}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 r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,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,r!==void 0&&s>r))return}if(s!==0)return!n&&a&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[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];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;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 r.set(i.subarray(0,c),16-c),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var lu=45,Ah=15,pr=new io;function Ni(e){if(!(e.length>Ah))return pr.new(e).parseWith(()=>pr.readIPv4Addr())}function Ri(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>lu))return pr.new(e).parseWith(()=>pr.readIPv6Addr())}function so(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>lu))return pr.new(e).parseWith(()=>pr.readIPAddr())}var rw=parseInt("0xFFFF",16),nw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function hu(e){return!!Ni(e)}function pu(e){return!!Ri(e)}function co(e){return!!so(e)}var mu=hu,kh=pu,Pi=function(e){let t=0;if(e=e.toString().trim(),mu(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(kh(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=mu(r[n]),s;i&&(s=Pi(r[n]),r[n]=ht(s.slice(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,ht(s.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){let i=parseInt(r[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},gu=function(e,t=0,r){t=~~t,r=r??e.length-t;let n=new DataView(e.buffer);if(r===4){let o=[];for(let i=0;i<r;i++)o.push(e[t+i]);return o.join(".")}if(r===16){let o=[];for(let i=0;i<r;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var mr={},Di={},Uh=[[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"]];Uh.forEach(e=>{let t=Lh(...e);Di[t.code]=t,mr[t.name]=t});function Lh(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:!!n,path:!!o}}function Y(e){if(typeof e=="number"){if(Di[e]!=null)return Di[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(mr[e]!=null)return mr[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var Vw=Y("ip4"),$w=Y("ip6"),zw=Y("ipcidr");function Vi(e,t){switch(Y(e).code){case 4:case 41:return Rh(t);case 42:return Fi(t);case 6:case 273:case 33:case 132:return xu(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Fi(t);case 421:return Oh(t);case 444:return bu(t);case 445:return bu(t);case 466:return Mh(t);case 481:return globalThis.encodeURIComponent(Fi(t));default:return ht(t,"base16")}}function $i(e,t){switch(Y(e).code){case 4:return yu(t);case 41:return yu(t);case 42:return Oi(t);case 6:case 273:case 33:case 132:return zi(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Oi(t);case 421:return Ph(t);case 444:return Fh(t);case 445:return Vh(t);case 466:return Dh(t);case 481:return Oi(globalThis.decodeURIComponent(t));default:return Se(t,"base16")}}var Mi=Object.values(Hr).map(e=>e.decoder),Nh=function(){let e=Mi[0].or(Mi[1]);return Mi.slice(2).forEach(t=>e=e.or(t)),e}();function yu(e){if(!co(e))throw new Error("invalid ip address");return Pi(e)}function Rh(e){let t=gu(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!co(t))throw new Error("invalid ip address");return t}function zi(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function xu(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function Oi(e){let t=Se(e),r=Uint8Array.from(we(t.length));return Lt([r,t],r.length+t.length)}function Fi(e){let t=oe(e);if(e=e.slice(ft(t)),e.length!==t)throw new Error("inconsistent lengths");return ht(e)}function Ph(e){let t;e[0]==="Q"||e[0]==="1"?t=ie(J.decode(`z${e}`)).bytes:t=gt.parse(e).multihash.bytes;let r=Uint8Array.from(we(t.length));return Lt([r,t],r.length+t.length)}function Dh(e){let t=Nh.decode(e),r=Uint8Array.from(we(t.length));return Lt([r,t],r.length+t.length)}function Mh(e){let t=oe(e),r=e.slice(ft(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+ht(r,"base64url")}function Oh(e){let t=oe(e),r=e.slice(ft(t));if(r.length!==t)throw new Error("inconsistent lengths");return ht(r,"base58btc")}function Fh(e){let t=e.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 r=zt.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=zi(n);return Lt([r,o],r.length+o.length)}function Vh(e){let t=e.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 r=zt.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=zi(n);return Lt([r,o],r.length+o.length)}function bu(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=ht(t,"base32"),o=xu(r);return`${n}:${o}`}function wu(e){e=Hi(e);let t=[],r=[],n=null,o=e.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=Y(s);if(c.size===0){t.push([c.code]),r.push([c.code]);continue}if(i++,i>=o.length)throw vu("invalid address: "+e);if(c.path===!0){n=Hi(o.slice(i).join("/")),t.push([c.code,$i(c.code,n)]),r.push([c.code,n]);break}let a=$i(c.code,o[i]);t.push([c.code,a]),r.push([c.code,Vi(c.code,a)])}return{string:Eu(r),bytes:Ki(t),tuples:t,stringTuples:r,path:n}}function qi(e){let t=[],r=[],n=null,o=0;for(;o<e.length;){let i=oe(e,o),s=ft(i),c=Y(i),a=$h(c,e.slice(o+s));if(a===0){t.push([i]),r.push([i]),o+=s;continue}let l=e.slice(o+s,o+s+a);if(o+=a+s,o>e.length)throw vu("Invalid address Uint8Array: "+ht(e,"base16"));t.push([i,l]);let u=Vi(i,l);if(r.push([i,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(e),string:Eu(r),tuples:t,stringTuples:r,path:n}}function Eu(e){let t=[];return e.map(r=>{let n=Y(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),Hi(t.join("/"))}function Ki(e){return Lt(e.map(t=>{let r=Y(t[0]),n=Uint8Array.from(we(r.code));return t.length>1&&t[1]!=null&&(n=Lt([n,t[1]])),n}))}function $h(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{let r=oe(t instanceof Uint8Array?t:Uint8Array.from(t));return r+ft(r)}}function Hi(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}function vu(e){return new Error("Error parsing address: "+e)}var zh=Symbol.for("nodejs.util.inspect.custom"),ji=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Hh=[Y("dns").code,Y("dns4").code,Y("dns6").code,Y("dnsaddr").code],Gi=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},ao=class e{bytes;#e;#t;#r;#n;[ji]=!0;constructor(t){t==null&&(t="");let r;if(t instanceof Uint8Array)r=qi(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);r=wu(t)}else if(uo(t))r=qi(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#e=r.string,this.#t=r.tuples,this.#r=r.stringTuples,this.#n=r.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,r,n,o,i="",s=Y("tcp"),c=Y("udp"),a=Y("ip4"),l=Y("ip6"),u=Y("dns6"),f=Y("ip6zone");for(let[w,E]of this.stringTuples())w===f.code&&(i=`%${E??""}`),Hh.includes(w)&&(r=s.name,o=443,n=`${E??""}${i}`,t=w===u.code?6:4),(w===s.code||w===c.code)&&(r=Y(w).name,o=parseInt(E??"")),(w===a.code||w===l.code)&&(r=Y(w).name,n=`${E??""}${i}`,t=w===l.code?6:4);if(t==null||r==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:r,port:o}}protos(){return this.#t.map(([t])=>Object.assign({},Y(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>Y(t).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(t){return t=new e(t),new e(this.toString()+t.toString())}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new e(n.slice(0,o))}decapsulateCode(t){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===t)return new e(Ki(r.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===mr.p2p.code&&t.push([n,o]),n===mr["p2p-circuit"].code&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?ht(J.decode(`z${n}`),"base58btc"):ht(gt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Gt(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=Su.get(r.name);if(n==null)throw new Gi(`no available resolver for ${r.name}`);return(await n(this,t)).map(i=>Ve(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 r=(t??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[zh](){return`Multiaddr(${this.#e})`}};var Su=new Map;function uo(e){return!!e?.[ji]}function Ve(e){return new ao(e)}var Au={type:4097,canEncode:e=>uo(e),encode:e=>e.bytes,decode:e=>Ve(e)};function Bu(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function qh(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function gr(e,...t){if(!qh(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function _u(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Bu(e.outputLen),Bu(e.blockLen)}function yr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Iu(e,t){gr(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var $e=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var lo=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Xt=(e,t)=>e<<32-t|e>>>t;var b1=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Cu(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function on(e){return typeof e=="string"&&(e=Cu(e)),gr(e),e}function Zi(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];gr(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}var br=class{clone(){return this._cloneInto()}},x1={}.toString;function fo(e){let t=n=>e().update(on(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function ho(e=32){if($e&&typeof $e.getRandomValues=="function")return $e.getRandomValues(new Uint8Array(e));if($e&&typeof $e.randomBytes=="function")return $e.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function Kh(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),c=Number(r&i),a=n?4:0,l=n?0:4;e.setUint32(t+a,s,n),e.setUint32(t+l,c,n)}var ku=(e,t,r)=>e&t^~e&r,Tu=(e,t,r)=>e&t^e&r^t&r,xr=class extends br{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=lo(this.buffer)}update(t){yr(this);let{view:r,buffer:n,blockLen:o}=this;t=on(t);let i=t.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=lo(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(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){yr(this),Iu(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;Kh(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=lo(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:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return t.length=o,t.pos=c,t.finished=i,t.destroyed=s,o%r&&t.buffer.set(n),t}};var po=BigInt(4294967295),Wi=BigInt(32);function Uu(e,t=!1){return t?{h:Number(e&po),l:Number(e>>Wi&po)}:{h:Number(e>>Wi&po)|0,l:Number(e&po)|0}}function Gh(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let o=0;o<e.length;o++){let{h:i,l:s}=Uu(e[o],t);[r[o],n[o]]=[i,s]}return[r,n]}var jh=(e,t)=>BigInt(e>>>0)<<Wi|BigInt(t>>>0),Zh=(e,t,r)=>e>>>r,Wh=(e,t,r)=>e<<32-r|t>>>r,Xh=(e,t,r)=>e>>>r|t<<32-r,Yh=(e,t,r)=>e<<32-r|t>>>r,Qh=(e,t,r)=>e<<64-r|t>>>r-32,Jh=(e,t,r)=>e>>>r-32|t<<64-r,tp=(e,t)=>t,ep=(e,t)=>e,rp=(e,t,r)=>e<<r|t>>>32-r,np=(e,t,r)=>t<<r|e>>>32-r,op=(e,t,r)=>t<<r-32|e>>>64-r,ip=(e,t,r)=>e<<r-32|t>>>64-r;function sp(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var cp=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),ap=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,up=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),lp=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,fp=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),dp=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var hp={fromBig:Uu,split:Gh,toBig:jh,shrSH:Zh,shrSL:Wh,rotrSH:Xh,rotrSL:Yh,rotrBH:Qh,rotrBL:Jh,rotr32H:tp,rotr32L:ep,rotlSH:rp,rotlSL:np,rotlBH:op,rotlBL:ip,add:sp,add3L:cp,add3H:ap,add4L:up,add4H:lp,add5H:dp,add5L:fp},O=hp;var[pp,mp]=O.split(["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(e=>BigInt(e))),_e=new Uint32Array(80),Ie=new Uint32Array(80),Xi=class extends xr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:c,Dl:a,Eh:l,El:u,Fh:f,Fl:h,Gh:w,Gl:E,Hh:m,Hl:d}=this;return[t,r,n,o,i,s,c,a,l,u,f,h,w,E,m,d]}set(t,r,n,o,i,s,c,a,l,u,f,h,w,E,m,d){this.Ah=t|0,this.Al=r|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=w|0,this.Gl=E|0,this.Hh=m|0,this.Hl=d|0}process(t,r){for(let y=0;y<16;y++,r+=4)_e[y]=t.getUint32(r),Ie[y]=t.getUint32(r+=4);for(let y=16;y<80;y++){let B=_e[y-15]|0,R=Ie[y-15]|0,U=O.rotrSH(B,R,1)^O.rotrSH(B,R,8)^O.shrSH(B,R,7),k=O.rotrSL(B,R,1)^O.rotrSL(B,R,8)^O.shrSL(B,R,7),C=_e[y-2]|0,L=Ie[y-2]|0,it=O.rotrSH(C,L,19)^O.rotrBH(C,L,61)^O.shrSH(C,L,6),H=O.rotrSL(C,L,19)^O.rotrBL(C,L,61)^O.shrSL(C,L,6),F=O.add4L(k,H,Ie[y-7],Ie[y-16]),st=O.add4H(F,U,it,_e[y-7],_e[y-16]);_e[y]=st|0,Ie[y]=F|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:h,Fh:w,Fl:E,Gh:m,Gl:d,Hh:b,Hl:A}=this;for(let y=0;y<80;y++){let B=O.rotrSH(f,h,14)^O.rotrSH(f,h,18)^O.rotrBH(f,h,41),R=O.rotrSL(f,h,14)^O.rotrSL(f,h,18)^O.rotrBL(f,h,41),U=f&w^~f&m,k=h&E^~h&d,C=O.add5L(A,R,k,mp[y],Ie[y]),L=O.add5H(C,b,B,U,pp[y],_e[y]),it=C|0,H=O.rotrSH(n,o,28)^O.rotrBH(n,o,34)^O.rotrBH(n,o,39),F=O.rotrSL(n,o,28)^O.rotrBL(n,o,34)^O.rotrBL(n,o,39),st=n&i^n&c^i&c,_=o&s^o&a^s&a;b=m|0,A=d|0,m=w|0,d=E|0,w=f|0,E=h|0,{h:f,l:h}=O.add(l|0,u|0,L|0,it|0),l=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let T=O.add3L(it,F,_);n=O.add3H(T,L,H,st),o=T|0}({h:n,l:o}=O.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=O.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=O.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=O.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=O.add(this.Eh|0,this.El|0,f|0,h|0),{h:w,l:E}=O.add(this.Fh|0,this.Fl|0,w|0,E|0),{h:m,l:d}=O.add(this.Gh|0,this.Gl|0,m|0,d|0),{h:b,l:A}=O.add(this.Hh|0,this.Hl|0,b|0,A|0),this.set(n,o,i,s,c,a,l,u,f,h,w,E,m,d,b,A)}roundClean(){_e.fill(0),Ie.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Lu=fo(()=>new Xi);var go={};Ct(go,{aInRange:()=>Tt,abool:()=>Yt,abytes:()=>wr,bitGet:()=>Ep,bitLen:()=>es,bitMask:()=>cn,bitSet:()=>vp,bytesToHex:()=>le,bytesToNumberBE:()=>fe,bytesToNumberLE:()=>ke,concatBytes:()=>de,createHmacDrbg:()=>rs,ensureBytes:()=>ot,equalBytes:()=>xp,hexToBytes:()=>He,hexToNumber:()=>ts,inRange:()=>sn,isBytes:()=>Ce,memoized:()=>Ke,notImplemented:()=>Ap,numberToBytesBE:()=>Te,numberToBytesLE:()=>qe,numberToHexUnpadded:()=>ze,numberToVarBytesBE:()=>bp,utf8ToBytes:()=>wp,validateObject:()=>ee});var Ji=BigInt(0),mo=BigInt(1),gp=BigInt(2);function Ce(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function wr(e){if(!Ce(e))throw new Error("Uint8Array expected")}function Yt(e,t){if(typeof t!="boolean")throw new Error(`${e} must be valid boolean, got "${t}".`)}var yp=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function le(e){wr(e);let t="";for(let r=0;r<e.length;r++)t+=yp[e[r]];return t}function ze(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function ts(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}var ue={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Nu(e){if(e>=ue._0&&e<=ue._9)return e-ue._0;if(e>=ue._A&&e<=ue._F)return e-(ue._A-10);if(e>=ue._a&&e<=ue._f)return e-(ue._a-10)}function He(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Nu(e.charCodeAt(i)),c=Nu(e.charCodeAt(i+1));if(s===void 0||c===void 0){let a=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function fe(e){return ts(le(e))}function ke(e){return wr(e),ts(le(Uint8Array.from(e).reverse()))}function Te(e,t){return He(e.toString(16).padStart(t*2,"0"))}function qe(e,t){return Te(e,t).reverse()}function bp(e){return He(ze(e))}function ot(e,t,r){let n;if(typeof t=="string")try{n=He(t)}catch(i){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${i}`)}else if(Ce(t))n=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(`${e} expected ${r} bytes, got ${o}`);return n}function de(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];wr(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}function xp(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function wp(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}var Yi=e=>typeof e=="bigint"&&Ji<=e;function sn(e,t,r){return Yi(e)&&Yi(t)&&Yi(r)&&t<=e&&e<r}function Tt(e,t,r,n){if(!sn(t,r,n))throw new Error(`expected valid ${e}: ${r} <= n < ${n}, got ${typeof t} ${t}`)}function es(e){let t;for(t=0;e>Ji;e>>=mo,t+=1);return t}function Ep(e,t){return e>>BigInt(t)&mo}function vp(e,t,r){return e|(r?mo:Ji)<<BigInt(t)}var cn=e=>(gp<<BigInt(e-1))-mo,Qi=e=>new Uint8Array(e),Ru=e=>Uint8Array.from(e);function rs(e,t,r){if(typeof e!="number"||e<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 r!="function")throw new Error("hmacFn must be a function");let n=Qi(e),o=Qi(e),i=0,s=()=>{n.fill(1),o.fill(0),i=0},c=(...f)=>r(o,n,...f),a=(f=Qi())=>{o=c(Ru([0]),f),n=c(),f.length!==0&&(o=c(Ru([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 w=n.slice();h.push(w),f+=n.length}return de(...h)};return(f,h)=>{s(),a(f);let w;for(;!(w=h(l()));)a();return s(),w}}var Sp={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||Ce(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function ee(e,t,r={}){let n=(o,i,s)=>{let c=Sp[i];if(typeof c!="function")throw new Error(`Invalid validator "${i}", expected function`);let a=e[o];if(!(s&&a===void 0)&&!c(a,e))throw new Error(`Invalid param ${String(o)}=${a} (${typeof a}), expected ${i}`)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return e}var Ap=()=>{throw new Error("not implemented")};function Ke(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let i=e(r,...n);return t.set(r,i),i}}var at=BigInt(0),et=BigInt(1),Ge=BigInt(2),Bp=BigInt(3),ns=BigInt(4),Pu=BigInt(5),Du=BigInt(8),_p=BigInt(9),Ip=BigInt(16);function Z(e,t){let r=e%t;return r>=at?r:t+r}function Cp(e,t,r){if(r<=at||t<at)throw new Error("Expected power/modulo > 0");if(r===et)return at;let n=et;for(;t>at;)t&et&&(n=n*e%r),e=e*e%r,t>>=et;return n}function rt(e,t,r){let n=e;for(;t-- >at;)n*=n,n%=r;return n}function yo(e,t){if(e===at||t<=at)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=Z(e,t),n=t,o=at,i=et,s=et,c=at;for(;r!==at;){let l=n/r,u=n%r,f=o-s*l,h=i-c*l;n=r,r=u,o=s,i=c,s=f,c=h}if(n!==et)throw new Error("invert: does not exist");return Z(o,t)}function kp(e){let t=(e-et)/Ge,r,n,o;for(r=e-et,n=0;r%Ge===at;r/=Ge,n++);for(o=Ge;o<e&&Cp(o,t,e)!==e-et;o++);if(n===1){let s=(e+et)/ns;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=(r+et)/Ge;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=n,u=c.pow(c.mul(c.ONE,o),r),f=c.pow(a,i),h=c.pow(a,r);for(;!c.eql(h,c.ONE);){if(c.eql(h,c.ZERO))return c.ZERO;let w=1;for(let m=c.sqr(h);w<l&&!c.eql(m,c.ONE);w++)m=c.sqr(m);let E=c.pow(u,et<<BigInt(l-w-1));u=c.sqr(E),f=c.mul(f,E),h=c.mul(h,u),l=w}return f}}function Tp(e){if(e%ns===Bp){let t=(e+et)/ns;return function(n,o){let i=n.pow(o,t);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(e%Du===Pu){let t=(e-Pu)/Du;return function(n,o){let i=n.mul(o,Ge),s=n.pow(i,t),c=n.mul(o,s),a=n.mul(n.mul(c,Ge),s),l=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(l),o))throw new Error("Cannot find square root");return l}}return e%Ip,kp(e)}var Mu=(e,t)=>(Z(e,t)&et)===et,Up=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function os(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Up.reduce((n,o)=>(n[o]="function",n),t);return ee(e,r)}function Lp(e,t,r){if(r<at)throw new Error("Expected power > 0");if(r===at)return e.ONE;if(r===et)return t;let n=e.ONE,o=t;for(;r>at;)r&et&&(n=e.mul(n,o)),o=e.sqr(o),r>>=et;return n}function Np(e,t){let r=new Array(t.length),n=t.reduce((i,s,c)=>e.is0(s)?i:(r[c]=i,e.mul(i,s)),e.ONE),o=e.inv(n);return t.reduceRight((i,s,c)=>e.is0(s)?i:(r[c]=e.mul(i,r[c]),e.mul(i,s)),o),r}function is(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Ue(e,t,r=!1,n={}){if(e<=at)throw new Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:o,nByteLength:i}=is(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Tp(e),c=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:cn(o),ZERO:at,ONE:et,create:a=>Z(a,e),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return at<=a&&a<e},is0:a=>a===at,isOdd:a=>(a&et)===et,neg:a=>Z(-a,e),eql:(a,l)=>a===l,sqr:a=>Z(a*a,e),add:(a,l)=>Z(a+l,e),sub:(a,l)=>Z(a-l,e),mul:(a,l)=>Z(a*l,e),pow:(a,l)=>Lp(c,a,l),div:(a,l)=>Z(a*yo(l,e),e),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>yo(a,e),sqrt:n.sqrt||(a=>s(c,a)),invertBatch:a=>Np(c,a),cmov:(a,l,u)=>u?l:a,toBytes:a=>r?qe(a,i):Te(a,i),fromBytes:a=>{if(a.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${a.length}`);return r?ke(a):fe(a)}});return Object.freeze(c)}function Ou(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function ss(e){let t=Ou(e);return t+Math.ceil(t/2)}function Fu(e,t,r=!1){let n=e.length,o=Ou(t),i=ss(t);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=r?fe(e):ke(e),c=Z(s,t-et)+et;return r?qe(c,o):Te(c,o)}var Pp=BigInt(0),cs=BigInt(1),as=new WeakMap,Vu=new WeakMap;function bo(e,t){let r=(i,s)=>{let c=s.negate();return i?c:s},n=i=>{if(!Number.isSafeInteger(i)||i<=0||i>t)throw new Error(`Wrong window size=${i}, should be [1..${t}]`)},o=i=>{n(i);let s=Math.ceil(t/i)+1,c=2**(i-1);return{windows:s,windowSize:c}};return{constTimeNegate:r,unsafeLadder(i,s){let c=e.ZERO,a=i;for(;s>Pp;)s&cs&&(c=c.add(a)),a=a.double(),s>>=cs;return c},precomputeWindow(i,s){let{windows:c,windowSize:a}=o(s),l=[],u=i,f=u;for(let h=0;h<c;h++){f=u,l.push(f);for(let w=1;w<a;w++)f=f.add(u),l.push(f);u=f.double()}return l},wNAF(i,s,c){let{windows:a,windowSize:l}=o(i),u=e.ZERO,f=e.BASE,h=BigInt(2**i-1),w=2**i,E=BigInt(i);for(let m=0;m<a;m++){let d=m*l,b=Number(c&h);c>>=E,b>l&&(b-=w,c+=cs);let A=d,y=d+Math.abs(b)-1,B=m%2!==0,R=b<0;b===0?f=f.add(r(B,s[A])):u=u.add(r(R,s[y]))}return{p:u,f}},wNAFCached(i,s,c){let a=Vu.get(i)||1,l=as.get(i);return l||(l=this.precomputeWindow(i,a),a!==1&&as.set(i,c(l))),this.wNAF(a,l,s)},setWindowSize(i,s){n(s),Vu.set(i,s),as.delete(i)}}}function xo(e,t,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,f)=>{if(!t.isValid(u))throw new Error(`wrong scalar at index ${f}`)}),r.forEach((u,f)=>{if(!(u instanceof e))throw new Error(`wrong point at index ${f}`)});let o=es(BigInt(r.length)),i=o>12?o-3:o>4?o-2:o?2:1,s=(1<<i)-1,c=new Array(s+1).fill(e.ZERO),a=Math.floor((t.BITS-1)/i)*i,l=e.ZERO;for(let u=a;u>=0;u-=i){c.fill(e.ZERO);for(let h=0;h<n.length;h++){let w=n[h],E=Number(w>>BigInt(u)&BigInt(s));c[E]=c[E].add(r[h])}let f=e.ZERO;for(let h=c.length-1,w=e.ZERO;h>0;h--)w=w.add(c[h]),f=f.add(w);if(l=l.add(f),u!==0)for(let h=0;h<i;h++)l=l.double()}return l}function an(e){return os(e.Fp),ee(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...is(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var Qt=BigInt(0),Ut=BigInt(1),wo=BigInt(2),Dp=BigInt(8),Mp={zip215:!0};function Op(e){let t=an(e);return ee(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function $u(e){let t=Op(e),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,l=wo<<BigInt(c*8)-Ut,u=r.create,f=Ue(t.n,t.nBitLength),h=t.uvRatio||((x,g)=>{try{return{isValid:!0,value:r.sqrt(x*r.inv(g))}}catch{return{isValid:!1,value:Qt}}}),w=t.adjustScalarBytes||(x=>x),E=t.domain||((x,g,v)=>{if(Yt("phflag",v),g.length||v)throw new Error("Contexts/pre-hash are not supported");return x});function m(x,g){Tt("coordinate "+x,g,Qt,l)}function d(x){if(!(x instanceof y))throw new Error("ExtendedPoint expected")}let b=Ke((x,g)=>{let{ex:v,ey:N,ez:P}=x,D=x.is0();g==null&&(g=D?Dp:r.inv(P));let V=u(v*g),z=u(N*g),$=u(P*g);if(D)return{x:Qt,y:Ut};if($!==Ut)throw new Error("invZ was invalid");return{x:V,y:z}}),A=Ke(x=>{let{a:g,d:v}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:N,ey:P,ez:D,et:V}=x,z=u(N*N),$=u(P*P),j=u(D*D),Q=u(j*j),ut=u(z*g),lt=u(j*u(ut+$)),mt=u(Q+u(v*u(z*$)));if(lt!==mt)throw new Error("bad point: equation left != right (1)");let vt=u(N*P),ct=u(D*V);if(vt!==ct)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(g,v,N,P){this.ex=g,this.ey=v,this.ez=N,this.et=P,m("x",g),m("y",v),m("z",N),m("t",P),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(g){if(g instanceof y)throw new Error("extended point not allowed");let{x:v,y:N}=g||{};return m("x",v),m("y",N),new y(v,N,Ut,u(v*N))}static normalizeZ(g){let v=r.invertBatch(g.map(N=>N.ez));return g.map((N,P)=>N.toAffine(v[P])).map(y.fromAffine)}static msm(g,v){return xo(y,f,g,v)}_setWindowSize(g){U.setWindowSize(this,g)}assertValidity(){A(this)}equals(g){d(g);let{ex:v,ey:N,ez:P}=this,{ex:D,ey:V,ez:z}=g,$=u(v*z),j=u(D*P),Q=u(N*z),ut=u(V*P);return $===j&&Q===ut}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:g}=t,{ex:v,ey:N,ez:P}=this,D=u(v*v),V=u(N*N),z=u(wo*u(P*P)),$=u(g*D),j=v+N,Q=u(u(j*j)-D-V),ut=$+V,lt=ut-z,mt=$-V,vt=u(Q*lt),ct=u(ut*mt),It=u(Q*mt),re=u(lt*ut);return new y(vt,ct,re,It)}add(g){d(g);let{a:v,d:N}=t,{ex:P,ey:D,ez:V,et:z}=this,{ex:$,ey:j,ez:Q,et:ut}=g;if(v===BigInt(-1)){let Es=u((D-P)*(j+$)),vs=u((D+P)*(j-$)),No=u(vs-Es);if(No===Qt)return this.double();let Ss=u(V*wo*ut),As=u(z*wo*Q),Bs=As+Ss,_s=vs+Es,Is=As-Ss,wl=u(Bs*No),El=u(_s*Is),vl=u(Bs*Is),Sl=u(No*_s);return new y(wl,El,Sl,vl)}let lt=u(P*$),mt=u(D*j),vt=u(z*N*ut),ct=u(V*Q),It=u((P+D)*($+j)-lt-mt),re=ct-vt,Sr=ct+vt,Ar=u(mt-v*lt),gl=u(It*re),yl=u(Sr*Ar),bl=u(It*Ar),xl=u(re*Sr);return new y(gl,yl,xl,bl)}subtract(g){return this.add(g.negate())}wNAF(g){return U.wNAFCached(this,g,y.normalizeZ)}multiply(g){let v=g;Tt("scalar",v,Ut,n);let{p:N,f:P}=this.wNAF(v);return y.normalizeZ([N,P])[0]}multiplyUnsafe(g){let v=g;return Tt("scalar",v,Qt,n),v===Qt?R:this.equals(R)||v===Ut?this:this.equals(B)?this.wNAF(v).p:U.unsafeLadder(this,v)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(g){return b(this,g)}clearCofactor(){let{h:g}=t;return g===Ut?this:this.multiplyUnsafe(g)}static fromHex(g,v=!1){let{d:N,a:P}=t,D=r.BYTES;g=ot("pointHex",g,D),Yt("zip215",v);let V=g.slice(),z=g[D-1];V[D-1]=z&-129;let $=ke(V),j=v?l:r.ORDER;Tt("pointHex.y",$,Qt,j);let Q=u($*$),ut=u(Q-Ut),lt=u(N*Q-P),{isValid:mt,value:vt}=h(ut,lt);if(!mt)throw new Error("Point.fromHex: invalid y coordinate");let ct=(vt&Ut)===Ut,It=(z&128)!==0;if(!v&&vt===Qt&&It)throw new Error("Point.fromHex: x=0 and x_0=1");return It!==ct&&(vt=u(-vt)),y.fromAffine({x:vt,y:$})}static fromPrivateKey(g){return L(g).point}toRawBytes(){let{x:g,y:v}=this.toAffine(),N=qe(v,r.BYTES);return N[N.length-1]|=g&Ut?128:0,N}toHex(){return le(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,Ut,u(t.Gx*t.Gy)),y.ZERO=new y(Qt,Ut,Ut,Qt);let{BASE:B,ZERO:R}=y,U=bo(y,c*8);function k(x){return Z(x,n)}function C(x){return k(ke(x))}function L(x){let g=c;x=ot("private key",x,g);let v=ot("hashed private key",i(x),2*g),N=w(v.slice(0,g)),P=v.slice(g,2*g),D=C(N),V=B.multiply(D),z=V.toRawBytes();return{head:N,prefix:P,scalar:D,point:V,pointBytes:z}}function it(x){return L(x).pointBytes}function H(x=new Uint8Array,...g){let v=de(...g);return C(i(E(v,ot("context",x),!!o)))}function F(x,g,v={}){x=ot("message",x),o&&(x=o(x));let{prefix:N,scalar:P,pointBytes:D}=L(g),V=H(v.context,N,x),z=B.multiply(V).toRawBytes(),$=H(v.context,z,D,x),j=k(V+$*P);Tt("signature.s",j,Qt,n);let Q=de(z,qe(j,r.BYTES));return ot("result",Q,c*2)}let st=Mp;function _(x,g,v,N=st){let{context:P,zip215:D}=N,V=r.BYTES;x=ot("signature",x,2*V),g=ot("message",g),D!==void 0&&Yt("zip215",D),o&&(g=o(g));let z=ke(x.slice(V,2*V)),$,j,Q;try{$=y.fromHex(v,D),j=y.fromHex(x.slice(0,V),D),Q=B.multiplyUnsafe(z)}catch{return!1}if(!D&&$.isSmallOrder())return!1;let ut=H(P,j.toRawBytes(),$.toRawBytes(),g);return j.add($.multiplyUnsafe(ut)).subtract(Q).clearCofactor().equals(y.ZERO)}return B._setWindowSize(8),{CURVE:t,getPublicKey:it,sign:F,verify:_,ExtendedPoint:y,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>s(r.BYTES),precompute(x=8,g=y.BASE){return g._setWindowSize(x),g.multiply(BigInt(3)),g}}}}var us=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),zu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),z1=BigInt(0),Fp=BigInt(1),Hu=BigInt(2),H1=BigInt(3),Vp=BigInt(5),$p=BigInt(8);function zp(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=us,c=e*e%i*e%i,a=rt(c,Hu,i)*c%i,l=rt(a,Fp,i)*e%i,u=rt(l,Vp,i)*l%i,f=rt(u,t,i)*u%i,h=rt(f,r,i)*f%i,w=rt(h,n,i)*h%i,E=rt(w,o,i)*w%i,m=rt(E,o,i)*w%i,d=rt(m,t,i)*u%i;return{pow_p_5_8:rt(d,Hu,i)*e%i,b2:c}}function Hp(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function qp(e,t){let r=us,n=Z(t*t*t,r),o=Z(n*n*t,r),i=zp(e*o).pow_p_5_8,s=Z(e*n*i,r),c=Z(t*s*s,r),a=s,l=Z(s*zu,r),u=c===e,f=c===Z(-e,r),h=c===Z(-e*zu,r);return u&&(s=a),(f||h)&&(s=l),Mu(s,r)&&(s=Z(-s,r)),{isValid:u||f,value:s}}var Kp=Ue(us,void 0,!0),Gp={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Kp,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:$p,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Lu,randomBytes:ho,adjustScalarBytes:Hp,uvRatio:qp},qu=$u(Gp);var Eo=32;function Ku(e,t,r){return qu.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}var vo=class{type="Ed25519";raw;constructor(t){this.raw=ls(t,Eo)}toMultihash(){return se.digest(So(this))}toCID(){return gt.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Gt(this.raw,t.raw)}verify(t,r){return Ku(this.raw,r,t)}};function ju(e){return e=ls(e,Eo),new vo(e)}function ls(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new me(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var $t;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1"})($t||($t={}));var fs;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1"})(fs||(fs={}));(function(e){e.codec=()=>Gr(fs)})($t||($t={}));var un;(function(e){let t;e.codec=()=>(t==null&&(t=Bt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),$t.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.Type=$t.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>At(r,e.codec()),e.decode=(r,n)=>St(r,e.codec(),n)})(un||(un={}));var ds;(function(e){let t;e.codec=()=>(t==null&&(t=Bt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),$t.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.Type=$t.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>At(r,e.codec()),e.decode=(r,n)=>St(r,e.codec(),n)})(ds||(ds={}));var Wp=new Uint32Array([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]),Le=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ne=new Uint32Array(64),hs=class extends xr{constructor(){super(64,32,8,!1),this.A=Le[0]|0,this.B=Le[1]|0,this.C=Le[2]|0,this.D=Le[3]|0,this.E=Le[4]|0,this.F=Le[5]|0,this.G=Le[6]|0,this.H=Le[7]|0}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[t,r,n,o,i,s,c,a]}set(t,r,n,o,i,s,c,a){this.A=t|0,this.B=r|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,r){for(let f=0;f<16;f++,r+=4)Ne[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let h=Ne[f-15],w=Ne[f-2],E=Xt(h,7)^Xt(h,18)^h>>>3,m=Xt(w,17)^Xt(w,19)^w>>>10;Ne[f]=m+Ne[f-7]+E+Ne[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=Xt(c,6)^Xt(c,11)^Xt(c,25),w=u+h+ku(c,a,l)+Wp[f]+Ne[f]|0,m=(Xt(n,2)^Xt(n,13)^Xt(n,22))+Tu(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(){Ne.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Zu=fo(()=>new hs);var ln=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var Ao=class extends br{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,_u(t);let n=on(r);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),i.fill(0)}update(t){return yr(this),this.iHash.update(t),this}digestInto(t){yr(this),gr(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:r,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=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ps=(e,t,r)=>new Ao(e,t).update(r).digest();ps.create=(e,t)=>new Ao(e,t);function Wu(e){e.lowS!==void 0&&Yt("lowS",e.lowS),e.prehash!==void 0&&Yt("prehash",e.prehash)}function Xp(e){let t=an(e);ee(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Yp,hexToBytes:Qp}=go,he={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(e,t)=>{let{Err:r}=he;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=ze(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?ze(o.length/2|128):"";return`${ze(e)}${i}${o}${t}`},decode(e,t){let{Err:r}=he,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("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 r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+a);if(l.length!==a)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=a,s<128)throw new r("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+s);if(c.length!==s)throw new r("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=he;if(e<pe)throw new t("integer: negative integers are not allowed");let r=ze(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected assertion");return r},decode(e){let{Err:t}=he;if(e[0]&128)throw new t("Invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return Yp(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=he,o=typeof e=="string"?Qp(e):e;wr(o);let{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:r.decode(c),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=he,n=`${t.encode(2,r.encode(e.r))}${t.encode(2,r.encode(e.s))}`;return t.encode(48,n)}},pe=BigInt(0),pt=BigInt(1),b2=BigInt(2),Xu=BigInt(3),x2=BigInt(4);function Jp(e){let t=Xp(e),{Fp:r}=t,n=Ue(t.n,t.nBitLength),o=t.toBytes||((m,d,b)=>{let A=d.toAffine();return de(Uint8Array.from([4]),r.toBytes(A.x),r.toBytes(A.y))}),i=t.fromBytes||(m=>{let d=m.subarray(1),b=r.fromBytes(d.subarray(0,r.BYTES)),A=r.fromBytes(d.subarray(r.BYTES,2*r.BYTES));return{x:b,y:A}});function s(m){let{a:d,b}=t,A=r.sqr(m),y=r.mul(A,m);return r.add(r.add(y,r.mul(m,d)),b)}if(!r.eql(r.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function c(m){return sn(m,pt,t.n)}function a(m){let{allowedPrivateKeyLengths:d,nByteLength:b,wrapPrivateKey:A,n:y}=t;if(d&&typeof m!="bigint"){if(Ce(m)&&(m=le(m)),typeof m!="string"||!d.includes(m.length))throw new Error("Invalid key");m=m.padStart(b*2,"0")}let B;try{B=typeof m=="bigint"?m:fe(ot("private key",m,b))}catch{throw new Error(`private key must be ${b} bytes, hex or bigint, not ${typeof m}`)}return A&&(B=Z(B,y)),Tt("private key",B,pt,y),B}function l(m){if(!(m instanceof h))throw new Error("ProjectivePoint expected")}let u=Ke((m,d)=>{let{px:b,py:A,pz:y}=m;if(r.eql(y,r.ONE))return{x:b,y:A};let B=m.is0();d==null&&(d=B?r.ONE:r.inv(y));let R=r.mul(b,d),U=r.mul(A,d),k=r.mul(y,d);if(B)return{x:r.ZERO,y:r.ZERO};if(!r.eql(k,r.ONE))throw new Error("invZ was invalid");return{x:R,y:U}}),f=Ke(m=>{if(m.is0()){if(t.allowInfinityPoint&&!r.is0(m.py))return;throw new Error("bad point: ZERO")}let{x:d,y:b}=m.toAffine();if(!r.isValid(d)||!r.isValid(b))throw new Error("bad point: x or y not FE");let A=r.sqr(b),y=s(d);if(!r.eql(A,y))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,b,A){if(this.px=d,this.py=b,this.pz=A,d==null||!r.isValid(d))throw new Error("x required");if(b==null||!r.isValid(b))throw new Error("y required");if(A==null||!r.isValid(A))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:b,y:A}=d||{};if(!d||!r.isValid(b)||!r.isValid(A))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let y=B=>r.eql(B,r.ZERO);return y(b)&&y(A)?h.ZERO:new h(b,A,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let b=r.invertBatch(d.map(A=>A.pz));return d.map((A,y)=>A.toAffine(b[y])).map(h.fromAffine)}static fromHex(d){let b=h.fromAffine(i(ot("pointHex",d)));return b.assertValidity(),b}static fromPrivateKey(d){return h.BASE.multiply(a(d))}static msm(d,b){return xo(h,n,d,b)}_setWindowSize(d){E.setWindowSize(this,d)}assertValidity(){f(this)}hasEvenY(){let{y:d}=this.toAffine();if(r.isOdd)return!r.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){l(d);let{px:b,py:A,pz:y}=this,{px:B,py:R,pz:U}=d,k=r.eql(r.mul(b,U),r.mul(B,y)),C=r.eql(r.mul(A,U),r.mul(R,y));return k&&C}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){let{a:d,b}=t,A=r.mul(b,Xu),{px:y,py:B,pz:R}=this,U=r.ZERO,k=r.ZERO,C=r.ZERO,L=r.mul(y,y),it=r.mul(B,B),H=r.mul(R,R),F=r.mul(y,B);return F=r.add(F,F),C=r.mul(y,R),C=r.add(C,C),U=r.mul(d,C),k=r.mul(A,H),k=r.add(U,k),U=r.sub(it,k),k=r.add(it,k),k=r.mul(U,k),U=r.mul(F,U),C=r.mul(A,C),H=r.mul(d,H),F=r.sub(L,H),F=r.mul(d,F),F=r.add(F,C),C=r.add(L,L),L=r.add(C,L),L=r.add(L,H),L=r.mul(L,F),k=r.add(k,L),H=r.mul(B,R),H=r.add(H,H),L=r.mul(H,F),U=r.sub(U,L),C=r.mul(H,it),C=r.add(C,C),C=r.add(C,C),new h(U,k,C)}add(d){l(d);let{px:b,py:A,pz:y}=this,{px:B,py:R,pz:U}=d,k=r.ZERO,C=r.ZERO,L=r.ZERO,it=t.a,H=r.mul(t.b,Xu),F=r.mul(b,B),st=r.mul(A,R),_=r.mul(y,U),T=r.add(b,A),x=r.add(B,R);T=r.mul(T,x),x=r.add(F,st),T=r.sub(T,x),x=r.add(b,y);let g=r.add(B,U);return x=r.mul(x,g),g=r.add(F,_),x=r.sub(x,g),g=r.add(A,y),k=r.add(R,U),g=r.mul(g,k),k=r.add(st,_),g=r.sub(g,k),L=r.mul(it,x),k=r.mul(H,_),L=r.add(k,L),k=r.sub(st,L),L=r.add(st,L),C=r.mul(k,L),st=r.add(F,F),st=r.add(st,F),_=r.mul(it,_),x=r.mul(H,x),st=r.add(st,_),_=r.sub(F,_),_=r.mul(it,_),x=r.add(x,_),F=r.mul(st,x),C=r.add(C,F),F=r.mul(g,x),k=r.mul(T,k),k=r.sub(k,F),F=r.mul(T,st),L=r.mul(g,L),L=r.add(L,F),new h(k,C,L)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return E.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){Tt("scalar",d,pe,t.n);let b=h.ZERO;if(d===pe)return b;if(d===pt)return this;let{endo:A}=t;if(!A)return E.unsafeLadder(this,d);let{k1neg:y,k1:B,k2neg:R,k2:U}=A.splitScalar(d),k=b,C=b,L=this;for(;B>pe||U>pe;)B&pt&&(k=k.add(L)),U&pt&&(C=C.add(L)),L=L.double(),B>>=pt,U>>=pt;return y&&(k=k.negate()),R&&(C=C.negate()),C=new h(r.mul(C.px,A.beta),C.py,C.pz),k.add(C)}multiply(d){let{endo:b,n:A}=t;Tt("scalar",d,pt,A);let y,B;if(b){let{k1neg:R,k1:U,k2neg:k,k2:C}=b.splitScalar(d),{p:L,f:it}=this.wNAF(U),{p:H,f:F}=this.wNAF(C);L=E.constTimeNegate(R,L),H=E.constTimeNegate(k,H),H=new h(r.mul(H.px,b.beta),H.py,H.pz),y=L.add(H),B=it.add(F)}else{let{p:R,f:U}=this.wNAF(d);y=R,B=U}return h.normalizeZ([y,B])[0]}multiplyAndAddUnsafe(d,b,A){let y=h.BASE,B=(U,k)=>k===pe||k===pt||!U.equals(y)?U.multiplyUnsafe(k):U.multiply(k),R=B(this,b).add(B(d,A));return R.is0()?void 0:R}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:b}=t;if(d===pt)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===pt?this:b?b(h,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return Yt("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return Yt("isCompressed",d),le(this.toRawBytes(d))}}h.BASE=new h(t.Gx,t.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);let w=t.nBitLength,E=bo(h,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:c}}function t0(e){let t=an(e);return ee(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Yu(e){let t=t0(e),{Fp:r,n}=t,o=r.BYTES+1,i=2*r.BYTES+1;function s(_){return Z(_,n)}function c(_){return yo(_,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=Jp({...t,toBytes(_,T,x){let g=T.toAffine(),v=r.toBytes(g.x),N=de;return Yt("isCompressed",x),x?N(Uint8Array.from([T.hasEvenY()?2:3]),v):N(Uint8Array.from([4]),v,r.toBytes(g.y))},fromBytes(_){let T=_.length,x=_[0],g=_.subarray(1);if(T===o&&(x===2||x===3)){let v=fe(g);if(!sn(v,pt,r.ORDER))throw new Error("Point is not on curve");let N=u(v),P;try{P=r.sqrt(N)}catch(z){let $=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+$)}let D=(P&pt)===pt;return(x&1)===1!==D&&(P=r.neg(P)),{x:v,y:P}}else if(T===i&&x===4){let v=r.fromBytes(g.subarray(0,r.BYTES)),N=r.fromBytes(g.subarray(r.BYTES,2*r.BYTES));return{x:v,y:N}}else throw new Error(`Point of length ${T} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=_=>le(Te(_,t.nByteLength));function w(_){let T=n>>pt;return _>T}function E(_){return w(_)?s(-_):_}let m=(_,T,x)=>fe(_.slice(T,x));class d{constructor(T,x,g){this.r=T,this.s=x,this.recovery=g,this.assertValidity()}static fromCompact(T){let x=t.nByteLength;return T=ot("compactSignature",T,x*2),new d(m(T,0,x),m(T,x,2*x))}static fromDER(T){let{r:x,s:g}=he.toSig(ot("DER",T));return new d(x,g)}assertValidity(){Tt("r",this.r,pt,n),Tt("s",this.s,pt,n)}addRecoveryBit(T){return new d(this.r,this.s,T)}recoverPublicKey(T){let{r:x,s:g,recovery:v}=this,N=U(ot("msgHash",T));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let P=v===2||v===3?x+t.n:x;if(P>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let D=v&1?"03":"02",V=a.fromHex(D+h(P)),z=c(P),$=s(-N*z),j=s(g*z),Q=a.BASE.multiplyAndAddUnsafe(V,$,j);if(!Q)throw new Error("point at infinify");return Q.assertValidity(),Q}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return He(this.toDERHex())}toDERHex(){return he.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return He(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let b={isValidPrivateKey(_){try{return l(_),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let _=ss(t.n);return Fu(t.randomBytes(_),t.n)},precompute(_=8,T=a.BASE){return T._setWindowSize(_),T.multiply(BigInt(3)),T}};function A(_,T=!0){return a.fromPrivateKey(_).toRawBytes(T)}function y(_){let T=Ce(_),x=typeof _=="string",g=(T||x)&&_.length;return T?g===o||g===i:x?g===2*o||g===2*i:_ instanceof a}function B(_,T,x=!0){if(y(_))throw new Error("first arg must be private key");if(!y(T))throw new Error("second arg must be public key");return a.fromHex(T).multiply(l(_)).toRawBytes(x)}let R=t.bits2int||function(_){let T=fe(_),x=_.length*8-t.nBitLength;return x>0?T>>BigInt(x):T},U=t.bits2int_modN||function(_){return s(R(_))},k=cn(t.nBitLength);function C(_){return Tt(`num < 2^${t.nBitLength}`,_,pe,k),Te(_,t.nByteLength)}function L(_,T,x=it){if(["recovered","canonical"].some(lt=>lt in x))throw new Error("sign() legacy options not supported");let{hash:g,randomBytes:v}=t,{lowS:N,prehash:P,extraEntropy:D}=x;N==null&&(N=!0),_=ot("msgHash",_),Wu(x),P&&(_=ot("prehashed msgHash",g(_)));let V=U(_),z=l(T),$=[C(z),C(V)];if(D!=null&&D!==!1){let lt=D===!0?v(r.BYTES):D;$.push(ot("extraEntropy",lt))}let j=de(...$),Q=V;function ut(lt){let mt=R(lt);if(!f(mt))return;let vt=c(mt),ct=a.BASE.multiply(mt).toAffine(),It=s(ct.x);if(It===pe)return;let re=s(vt*s(Q+It*z));if(re===pe)return;let Sr=(ct.x===It?0:2)|Number(ct.y&pt),Ar=re;return N&&w(re)&&(Ar=E(re),Sr^=1),new d(It,Ar,Sr)}return{seed:j,k2sig:ut}}let it={lowS:t.lowS,prehash:!1},H={lowS:t.lowS,prehash:!1};function F(_,T,x=it){let{seed:g,k2sig:v}=L(_,T,x),N=t;return rs(N.hash.outputLen,N.nByteLength,N.hmac)(g,v)}a.BASE._setWindowSize(8);function st(_,T,x,g=H){let v=_;if(T=ot("msgHash",T),x=ot("publicKey",x),"strict"in g)throw new Error("options.strict was renamed to lowS");Wu(g);let{lowS:N,prehash:P}=g,D,V;try{if(typeof v=="string"||Ce(v))try{D=d.fromDER(v)}catch(ct){if(!(ct instanceof he.Err))throw ct;D=d.fromCompact(v)}else if(typeof v=="object"&&typeof v.r=="bigint"&&typeof v.s=="bigint"){let{r:ct,s:It}=v;D=new d(ct,It)}else throw new Error("PARSE");V=a.fromHex(x)}catch(ct){if(ct.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(N&&D.hasHighS())return!1;P&&(T=t.hash(T));let{r:z,s:$}=D,j=U(T),Q=c($),ut=s(j*Q),lt=s(z*Q),mt=a.BASE.multiplyAndAddUnsafe(V,ut,lt)?.toAffine();return mt?s(mt.x)===z:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:B,sign:F,verify:st,ProjectivePoint:a,Signature:d,utils:b}}function e0(e){return{hash:e,hmac:(t,...r)=>ps(e,t,Zi(...r)),randomBytes:ho}}function Qu(e,t){let r=n=>Yu({...e,...e0(n)});return Object.freeze({...r(t),create:r})}var el=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ju=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),r0=BigInt(1),ms=BigInt(2),tl=(e,t)=>(e+t/ms)/t;function n0(e){let t=el,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=rt(u,r,t)*u%t,h=rt(f,r,t)*u%t,w=rt(h,ms,t)*l%t,E=rt(w,o,t)*w%t,m=rt(E,i,t)*E%t,d=rt(m,c,t)*m%t,b=rt(d,a,t)*d%t,A=rt(b,c,t)*m%t,y=rt(A,r,t)*u%t,B=rt(y,s,t)*E%t,R=rt(B,n,t)*l%t,U=rt(R,ms,t);if(!gs.eql(gs.sqr(U),e))throw new Error("Cannot find square root");return U}var gs=Ue(el,void 0,void 0,{sqrt:n0}),je=Qu({a:BigInt(0),b:BigInt(7),Fp:gs,n:Ju,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=Ju,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-r0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),c=tl(i*e,t),a=tl(-n*e,t),l=Z(e-c*r-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="+e);return{k1neg:f,k1:l,k2neg:h,k2:u}}}},Zu),C2=BigInt(0);var k2=je.ProjectivePoint;function rl(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}function nl(e,t,r){let n=$r.digest(r instanceof Uint8Array?r:r.subarray());if(rl(n))return n.then(({digest:o})=>je.verify(t,o,e)).catch(o=>{throw new ln(String(o))});try{return je.verify(t,n.digest,e)}catch(o){throw new ln(String(o))}}var Bo=class{type="secp256k1";raw;_key;constructor(t){this._key=il(t),this.raw=ol(this._key)}toMultihash(){return se.digest(So(this))}toCID(){return gt.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Gt(this.raw,t.raw)}verify(t,r){return nl(this._key,r,t)}};function sl(e){return new Bo(e)}function ol(e){return je.ProjectivePoint.fromHex(e).toRawBytes(!0)}function il(e){try{return je.ProjectivePoint.fromHex(e),e}catch(t){throw new mn(String(t))}}function cl(e){let{Type:t,Data:r}=un.decode(e.digest),n=r??new Uint8Array;switch(t){case $t.Ed25519:return ju(n);case $t.secp256k1:return sl(n);default:throw new _r}}function So(e){return un.encode({Type:$t[e.type],Data:e.raw})}var al=Symbol.for("nodejs.util.inspect.custom"),o0=114,fn=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()})`}[hn]=!0;toString(){return this.string==null&&(this.string=J.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return gt.createV1(o0,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Gt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Gt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[al](){return`PeerId(${this.toString()})`}},_o=class extends fn{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Io=class extends fn{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Co=class extends fn{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},i0=2336,ko=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=se.digest(Se(this.url))}[al](){return`PeerId(${this.url})`}[hn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return gt.createV1(i0,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=ht(t)),t.toString()===this.toString())}};function ul(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=ie(J.decode(`z${e}`));else{if(t==null)throw new me('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=ie(t.decode(e))}return ys(r)}function ys(e){if(c0(e))return new _o({multihash:e});if(s0(e))try{let t=cl(e);if(t.type==="Ed25519")return new Io({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Co({multihash:e,publicKey:t})}catch{let r=ht(e.digest);return new ko(new URL(r))}throw new gn("Supplied PeerID Multihash is invalid")}function s0(e){return e.code===se.code}function c0(e){return e.code===$r.code}var ll={type:4098,canEncode:e=>ks(e),encode:e=>e.toMultihash().bytes,decode:e=>ys(ie(e))};var bs=[au,Au,ll,uu];function To(e){let t={},r=e.components??e;return Object.entries(r).forEach(([n,o])=>{o?.[ge]!=null&&Array.isArray(o[ge])&&(t[n]=o[ge])}),t}function Er(e,t){let r={};for(let[n,o]of e.entries())r[n]=t(o);return r}async function Uo(e,t){let r=[],n=e.connectionManager.getConnectionsMap(),o=[...n.values()].flatMap(i=>i).map(i=>i.remoteAddr.toString());for(let[i,s]of n.entries())try{let c=await e.peerStore.get(i);r.push({id:i,addresses:c.addresses.map(({isCertified:a,multiaddr:l})=>({multiaddr:l,isCertified:a,isConnected:o.includes(l.toString())})),protocols:[...c.protocols],tags:Er(c.tags,a=>a.value),metadata:Er(c.metadata,a=>Jt.encode(a))})}catch(c){t.error("could not load peer data from peer store",c),r.push({id:i,addresses:s.map(a=>({multiaddr:a.remoteAddr,isConnected:o.includes(a.remoteAddr.toString())})),protocols:[],tags:{},metadata:{}})}return r}function vr(e,t){let r=t[e];if(!pn(r))throw new me(`Component ${e} did not implement the PubSub interface`);return r}async function Lo(e){let t=await e.peerStore.get(e.peerId);return{id:t.id,addresses:t.addresses,protocols:[...t.protocols],tags:Er(t.tags,r=>r.value),metadata:Er(t.metadata,r=>Jt.encode(r))}}function fl(e){let t=e.logger.forComponent("libp2p:devtools-metrics:metrics-rpc");return{init:async()=>({self:await Lo(e),peers:await Uo(e,t),debug:localStorage.getItem("debug")??"",capabilities:To(e)}),setDebug:async r=>{r?.length!=null&&r?.length>0?(qs(r),localStorage.setItem("debug",r)):(Hs(),localStorage.removeItem("debug"))},openConnection:async(r,n)=>{let o;try{o=ul(r)}catch{o=Ve(r)}await e.connectionManager.openConnection(o,n)},closeConnection:async(r,n)=>{await Promise.all(e.connectionManager.getConnections(r).map(async o=>{try{await o.close(n)}catch(i){o.abort(i)}}))},contentRouting:e.contentRouting,peerRouting:e.peerRouting,pubsub:{async getTopics(r){return vr(r,e).getTopics()},async subscribe(r,n){vr(r,e).subscribe(n)},async unsubscribe(r,n){vr(r,e).unsubscribe(n)},async publish(r,n,o){await vr(r,e).publish(n,o)},async getSubscribers(r,n){return vr(r,e).getSubscribers(n)}}}}function xs(e,t=100){let r,n;return()=>{if(n==null&&(n=Date.now()),r!=null&&Date.now()-n>t){clearTimeout(r),n=void 0,e();return}clearTimeout(r),r=setTimeout(()=>{n=void 0,e()},t)}}function dl(e,t){for(let[r,n]of Object.entries(To(t)))if(n.includes(e))return t[r]}var hl="@libp2p/devtools-metrics:devtools",a0="@libp2p/devtools-metrics:worker",u0="@libp2p/devtools-metrics:content",pl="@libp2p/devtools-metrics:metrics",ml="________libp2p_devtools_metrics";Object.defineProperty(globalThis,ml,{value:!0,enumerable:!1,writable:!1});var ws=class{log;components;simpleMetrics;intervalMs;rpcQueue;rpc;devTools;constructor(t,r){this.log=t.logger.forComponent("libp2p:devtools-metrics"),this.intervalMs=r?.intervalMs,this.components=t,this.rpcQueue=xe(),this.rpc=cu({valueCodecs:bs}),this.devTools=this.rpc.createClient("devTools"),this.onPeersUpdate=xs(this.onPeersUpdate.bind(this),1e3),this.onSelfUpdate=xs(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=ic({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";[ge]=["@libp2p/metrics"];trackMultiaddrConnection(t){this.simpleMetrics.trackMultiaddrConnection(t)}trackProtocolStream(t,r){this.simpleMetrics.trackProtocolStream(t,r)}registerMetric(t,r){return this.simpleMetrics.registerMetric(t,r)}registerMetricGroup(t,r){return this.simpleMetrics.registerMetricGroup(t,r)}registerCounter(t,r){return this.simpleMetrics.registerCounter(t,r)}registerCounterGroup(t,r){return this.simpleMetrics.registerCounterGroup(t,r)}registerHistogram(t,r){return this.simpleMetrics.registerHistogram(t,r)}registerHistogramGroup(t,r){return this.simpleMetrics.registerHistogramGroup(t,r)}registerSummary(t,r){return this.simpleMetrics.registerSummary(t,r)}registerSummaryGroup(t,r){return this.simpleMetrics.registerSummaryGroup(t,r)}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",fl(this.components)),await Ls(this.simpleMetrics),Promise.resolve().then(async()=>{await cc(this.rpcQueue,this.rpc,async r=>{for await(let n of r)window.postMessage({source:pl,type:"libp2p-rpc",message:Jt.encode(n)})})}).catch(r=>{this.log.error("error while reading RPC messages",r)});let t=dl("@libp2p/pubsub",this.components);pn(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 Ns(this.simpleMetrics)}onIncomingMessage(t){if(t.source!==window)return;let r=t.data;r?.source===hl&&r.type==="libp2p-rpc"&&this.rpcQueue.push(Jt.decode(r.message))}onPubSubMessage(t){this.devTools.safeDispatchEvent("pubsub:message",{detail:t.detail}).catch(r=>{this.log.error("error relaying pubsub message",r)})}onPubSubSubscriptionChange(t){this.devTools.safeDispatchEvent("pubsub:subscription-change",{detail:t.detail}).catch(r=>{this.log.error("error relaying pubsub subscription change",r)})}onSelfUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("self",{detail:await Lo(this.components)})}).catch(t=>{this.log.error("error sending peers message",t)})}onPeersUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("peers",{detail:await Uo(this.components,this.log)})}).catch(t=>{this.log.error("error sending peers message",t)})}};function l0(e){return t=>new ws(t,e)}return Tl(f0);})();
|
|
4
4
|
/*! Bundled license information:
|
|
5
5
|
|
|
6
6
|
@noble/hashes/esm/utils.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/devtools-metrics",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "Collect libp2p metrics and send them to browser DevTools",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "Apache-2.0 OR MIT",
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@libp2p/interface": "^2.1.3",
|
|
72
|
-
"@libp2p/interface-internal": "^2.0.
|
|
73
|
-
"@libp2p/logger": "^5.1.
|
|
74
|
-
"@libp2p/peer-id": "^5.0.
|
|
75
|
-
"@libp2p/simple-metrics": "^1.2.
|
|
72
|
+
"@libp2p/interface-internal": "^2.0.9",
|
|
73
|
+
"@libp2p/logger": "^5.1.2",
|
|
74
|
+
"@libp2p/peer-id": "^5.0.6",
|
|
75
|
+
"@libp2p/simple-metrics": "^1.2.5",
|
|
76
76
|
"@multiformats/multiaddr": "^12.3.0",
|
|
77
77
|
"cborg": "^4.2.2",
|
|
78
78
|
"it-pipe": "^3.0.1",
|