@libp2p/devtools-metrics 1.2.13 → 1.2.14-185b23eac

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 CHANGED
@@ -1,33 +1,20 @@
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 ef=Object.create;var bn=Object.defineProperty;var rf=Object.getOwnPropertyDescriptor;var nf=Object.getOwnPropertyNames;var of=Object.getPrototypeOf,sf=Object.prototype.hasOwnProperty;var Cr=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Tt=(r,t)=>{for(var e in t)bn(r,e,{get:t[e],enumerable:!0})},js=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of nf(t))!sf.call(r,o)&&o!==e&&bn(r,o,{get:()=>t[o],enumerable:!(n=rf(t,o))||n.enumerable});return r};var cf=(r,t,e)=>(e=r!=null?ef(of(r)):{},js(t||!r||!r.__esModule?bn(e,"default",{value:r,enumerable:!0}):e,r)),af=r=>js(bn({},"__esModule",{value:!0}),r);var ei=Cr((sg,dc)=>{function Zt(){}Zt.prototype.clear=function(){this._root=null,this.size=0};Zt.prototype.find=function(r){for(var t=this._root;t!==null;){var e=this._comparator(r,t.data);if(e===0)return t.data;t=t.get_child(e>0)}return null};Zt.prototype.findIter=function(r){for(var t=this._root,e=this.iterator();t!==null;){var n=this._comparator(r,t.data);if(n===0)return e._cursor=t,e;e._ancestors.push(t),t=t.get_child(n>0)}return null};Zt.prototype.lowerBound=function(r){for(var t=this._root,e=this.iterator(),n=this._comparator;t!==null;){var o=n(r,t.data);if(o===0)return e._cursor=t,e;e._ancestors.push(t),t=t.get_child(o>0)}for(var i=e._ancestors.length-1;i>=0;--i)if(t=e._ancestors[i],n(r,t.data)<0)return e._cursor=t,e._ancestors.length=i,e;return e._ancestors.length=0,e};Zt.prototype.upperBound=function(r){for(var t=this.lowerBound(r),e=this._comparator;t.data()!==null&&e(t.data(),r)===0;)t.next();return t};Zt.prototype.min=function(){var r=this._root;if(r===null)return null;for(;r.left!==null;)r=r.left;return r.data};Zt.prototype.max=function(){var r=this._root;if(r===null)return null;for(;r.right!==null;)r=r.right;return r.data};Zt.prototype.iterator=function(){return new We(this)};Zt.prototype.each=function(r){for(var t=this.iterator(),e;(e=t.next())!==null;)if(r(e)===!1)return};Zt.prototype.reach=function(r){for(var t=this.iterator(),e;(e=t.prev())!==null;)if(r(e)===!1)return};function We(r){this._tree=r,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 r=this._tree._root;r!==null&&this._minNode(r)}else if(this._cursor.right===null){var t;do if(t=this._cursor,this._ancestors.length)this._cursor=this._ancestors.pop();else{this._cursor=null;break}while(this._cursor.right===t)}else this._ancestors.push(this._cursor),this._minNode(this._cursor.right);return this._cursor!==null?this._cursor.data:null};We.prototype.prev=function(){if(this._cursor===null){var r=this._tree._root;r!==null&&this._maxNode(r)}else if(this._cursor.left===null){var t;do if(t=this._cursor,this._ancestors.length)this._cursor=this._ancestors.pop();else{this._cursor=null;break}while(this._cursor.left===t)}else this._ancestors.push(this._cursor),this._maxNode(this._cursor.left);return this._cursor!==null?this._cursor.data:null};We.prototype._minNode=function(r){for(;r.left!==null;)this._ancestors.push(r),r=r.left;this._cursor=r};We.prototype._maxNode=function(r){for(;r.right!==null;)this._ancestors.push(r),r=r.right;this._cursor=r};dc.exports=Zt});var mc=Cr((cg,pc)=>{var qf=ei();function Xe(r){this.data=r,this.left=null,this.right=null,this.red=!0}Xe.prototype.get_child=function(r){return r?this.right:this.left};Xe.prototype.set_child=function(r,t){r?this.right=t:this.left=t};function In(r){this._root=null,this._comparator=r,this.size=0}In.prototype=new qf;In.prototype.insert=function(r){var t=!1;if(this._root===null)this._root=new Xe(r),t=!0,this.size++;else{var e=new Xe(void 0),n=0,o=0,i=null,s=e,c=null,a=this._root;for(s.right=this._root;;){if(a===null?(a=new Xe(r),c.set_child(n,a),t=!0,this.size++):Ht(a.left)&&Ht(a.right)&&(a.red=!0,a.left.red=!1,a.right.red=!1),Ht(a)&&Ht(c)){var l=s.right===i;a===c.get_child(o)?s.set_child(l,Tr(i,!o)):s.set_child(l,hc(i,!o))}var u=this._comparator(a.data,r);if(u===0)break;o=n,n=u<0,i!==null&&(s=i),i=c,c=a,a=a.get_child(n)}this._root=e.right}return this._root.red=!1,t};In.prototype.remove=function(r){if(this._root===null)return!1;var t=new Xe(void 0),e=t;e.right=this._root;for(var n=null,o=null,i=null,s=1;e.get_child(s)!==null;){var c=s;o=n,n=e,e=e.get_child(s);var a=this._comparator(r,e.data);if(s=a>0,a===0&&(i=e),!Ht(e)&&!Ht(e.get_child(s))){if(Ht(e.get_child(!s))){var l=Tr(e,s);n.set_child(c,l),n=l}else if(!Ht(e.get_child(!s))){var u=n.get_child(!c);if(u!==null)if(!Ht(u.get_child(!c))&&!Ht(u.get_child(c)))n.red=!1,u.red=!0,e.red=!0;else{var f=o.right===n;Ht(u.get_child(c))?o.set_child(f,hc(n,c)):Ht(u.get_child(!c))&&o.set_child(f,Tr(n,c));var h=o.get_child(f);h.red=!0,e.red=!0,h.left.red=!1,h.right.red=!1}}}}return i!==null&&(i.data=e.data,n.set_child(n.right===e,e.get_child(e.left===null)),this.size--),this._root=t.right,this._root!==null&&(this._root.red=!1),i!==null};function Ht(r){return r!==null&&r.red}function Tr(r,t){var e=r.get_child(!t);return r.set_child(!t,e.get_child(t)),e.set_child(t,r),r.red=!0,e.red=!1,e}function hc(r,t){return r.set_child(!t,Tr(r.get_child(!t),!t)),Tr(r,t)}pc.exports=In});var yc=Cr((ag,gc)=>{var $f=ei();function Ur(r){this.data=r,this.left=null,this.right=null}Ur.prototype.get_child=function(r){return r?this.right:this.left};Ur.prototype.set_child=function(r,t){r?this.right=t:this.left=t};function Cn(r){this._root=null,this._comparator=r,this.size=0}Cn.prototype=new $f;Cn.prototype.insert=function(r){if(this._root===null)return this._root=new Ur(r),this.size++,!0;for(var t=0,e=null,n=this._root;;){if(n===null)return n=new Ur(r),e.set_child(t,n),ret=!0,this.size++,!0;if(this._comparator(n.data,r)===0)return!1;t=this._comparator(n.data,r)<0,e=n,n=n.get_child(t)}};Cn.prototype.remove=function(r){if(this._root===null)return!1;var t=new Ur(void 0),e=t;e.right=this._root;for(var n=null,o=null,i=1;e.get_child(i)!==null;){n=e,e=e.get_child(i);var s=this._comparator(r,e.data);i=s>0,s===0&&(o=e)}return o!==null?(o.data=e.data,n.set_child(n.right===e,e.get_child(e.left===null)),this._root=t.right,this.size--,!0):!1};gc.exports=Cn});var xc=Cr((ug,bc)=>{bc.exports={RBTree:mc(),BinTree:yc()}});var vc=Cr((lg,Ec)=>{var Gf=xc().RBTree;function rt(r,t,e){this.discrete=r===!1,this.delta=r||.01,this.K=t===void 0?25:t,this.CX=e===void 0?1.1:e,this.centroids=new Gf(wc),this.nreset=0,this.reset()}rt.prototype.reset=function(){this.centroids.clear(),this.n=0,this.nreset+=1,this.last_cumulate=0};rt.prototype.size=function(){return this.centroids.size};rt.prototype.toArray=function(r){var t=[];return r?(this._cumulate(!0),this.centroids.each(function(e){t.push(e)})):this.centroids.each(function(e){t.push({mean:e.mean,n:e.n})}),t};rt.prototype.summary=function(){var r=this.discrete?"exact ":"approximating ",t=[r+this.n+" samples using "+this.size()+" centroids","min = "+this.percentile(0),"Q1 = "+this.percentile(.25),"Q2 = "+this.percentile(.5),"Q3 = "+this.percentile(.75),"max = "+this.percentile(1)];return t.join(`
3
- `)};function wc(r,t){return r.mean>t.mean?1:r.mean<t.mean?-1:0}function jf(r,t){return r.mean_cumn-t.mean_cumn}rt.prototype.push=function(r,t){t=t||1,r=Array.isArray(r)?r:[r];for(var e=0;e<r.length;e++)this._digest(r[e],t)};rt.prototype.push_centroid=function(r){r=Array.isArray(r)?r:[r];for(var t=0;t<r.length;t++)this._digest(r[t].mean,r[t].n)};rt.prototype._cumulate=function(r){if(!(this.n===this.last_cumulate||!r&&this.CX&&this.CX>this.n/this.last_cumulate)){var t=0;this.centroids.each(function(e){e.mean_cumn=t+e.n/2,t=e.cumn=t+e.n}),this.n=this.last_cumulate=t}};rt.prototype.find_nearest=function(r){if(this.size()===0)return null;var t=this.centroids.lowerBound({mean:r}),e=t.data()===null?t.prev():t.data();if(e.mean===r||this.discrete)return e;var n=t.prev();return n&&Math.abs(n.mean-r)<Math.abs(e.mean-r)?n:e};rt.prototype._new_centroid=function(r,t,e){var n={mean:r,n:t,cumn:e};return this.centroids.insert(n),this.n+=t,n};rt.prototype._addweight=function(r,t,e){t!==r.mean&&(r.mean+=e*(t-r.mean)/(r.n+e)),r.cumn+=e,r.mean_cumn+=e/2,r.n+=e,this.n+=e};rt.prototype._digest=function(r,t){var e=this.centroids.min(),n=this.centroids.max(),o=this.find_nearest(r);if(o&&o.mean===r)this._addweight(o,r,t);else if(o===e)this._new_centroid(r,t,0);else if(o===n)this._new_centroid(r,t,this.n);else if(this.discrete)this._new_centroid(r,t,o.cumn);else{var i=o.mean_cumn/this.n,s=Math.floor(4*this.n*this.delta*i*(1-i));s-o.n>=t?this._addweight(o,r,t):this._new_centroid(r,t,o.cumn)}this._cumulate(!1),!this.discrete&&this.K&&this.size()>this.K/this.delta&&this.compress()};rt.prototype.bound_mean=function(r){var t=this.centroids.upperBound({mean:r}),e=t.prev(),n=e.mean===r?e:t.next();return[e,n]};rt.prototype.p_rank=function(r){var t=Array.isArray(r)?r:[r],e=t.map(this._p_rank,this);return Array.isArray(r)?e:e[0]};rt.prototype._p_rank=function(r){if(this.size()!==0){{if(r<this.centroids.min().mean)return 0;if(r>this.centroids.max().mean)return 1}this._cumulate(!0);var t=this.bound_mean(r),e=t[0],n=t[1];if(this.discrete)return e.cumn/this.n;var o=e.mean_cumn;return e!==n&&(o+=(r-e.mean)*(n.mean_cumn-e.mean_cumn)/(n.mean-e.mean)),o/this.n}};rt.prototype.bound_mean_cumn=function(r){this.centroids._comparator=jf;var t=this.centroids.upperBound({mean_cumn:r});this.centroids._comparator=wc;var e=t.prev(),n=e&&e.mean_cumn===r?e:t.next();return[e,n]};rt.prototype.percentile=function(r){var t=Array.isArray(r)?r:[r],e=t.map(this._percentile,this);return Array.isArray(r)?e:e[0]};rt.prototype._percentile=function(r){if(this.size()!==0){this._cumulate(!0);var t=this.n*r,e=this.bound_mean_cumn(t),n=e[0],o=e[1];return o===n||n===null||o===null?(n||o).mean:this.discrete?t<=n.cumn?n.mean:o.mean:n.mean+(t-n.mean_cumn)*(o.mean-n.mean)/(o.mean_cumn-n.mean_cumn)}};function Zf(r){var t=Math.floor(Math.random()*r.length);return r.splice(t,1)[0]}rt.prototype.compress=function(){if(!this.compressing){var r=this.toArray();for(this.reset(),this.compressing=!0;r.length>0;)this.push_centroid(Zf(r));this._cumulate(!0),this.compressing=!1}};function Ee(r){this.config=r||{},this.mode=this.config.mode||"auto",rt.call(this,this.mode==="cont"?r.delta:!1),this.digest_ratio=this.config.ratio||.9,this.digest_thresh=this.config.thresh||1e3,this.n_unique=0}Ee.prototype=Object.create(rt.prototype);Ee.prototype.constructor=Ee;Ee.prototype.push=function(r){rt.prototype.push.call(this,r),this.check_continuous()};Ee.prototype._new_centroid=function(r,t,e){this.n_unique+=1,rt.prototype._new_centroid.call(this,r,t,e)};Ee.prototype._addweight=function(r,t,e){r.n===1&&(this.n_unique-=1),rt.prototype._addweight.call(this,r,t,e)};Ee.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:rt,Digest:Ee}});var cm={};Tt(cm,{LIBP2P_DEVTOOLS_METRICS_KEY:()=>Gl,SOURCE_CONTENT_SCRIPT:()=>im,SOURCE_DEVTOOLS:()=>ql,SOURCE_METRICS:()=>$l,SOURCE_SERVICE_WORKER:()=>om,devToolsMetrics:()=>sm,valueCodecs:()=>Ms});var xn=Symbol.for("@libp2p/peer-id");function Zs(r){return!!r?.[xn]}var Ys;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Ys||(Ys={}));var uf=Symbol.for("@libp2p/pubsub");function wn(r){return!!r?.[uf]}var zt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},En=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var vn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Sn=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var kr=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};function Ws(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function Xs(...r){let t=[];for(let e of r)Ws(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 Qs(...r){let t=[];for(let e of r)Ws(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 xe=Symbol.for("@libp2p/service-capabilities"),hm=Symbol.for("@libp2p/service-dependencies");var Wo={};Tt(Wo,{base32:()=>jt,base32hex:()=>bf,base32hexpad:()=>wf,base32hexpadupper:()=>Ef,base32hexupper:()=>xf,base32pad:()=>gf,base32padupper:()=>yf,base32upper:()=>mf,base32z:()=>vf});var Rm=new Uint8Array(0);function Js(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function ae(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function tc(r){return new TextEncoder().encode(r)}function ec(r){return new TextDecoder().decode(r)}function lf(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(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var g=0,d=0,E=0,A=x.length;E!==A&&x[E]===0;)E++,g++;for(var m=(A-E)*u+1>>>0,B=new Uint8Array(m);E!==A;){for(var D=x[E],P=0,k=m-1;(D!==0||P<d)&&k!==-1;k--,P++)D+=256*B[k]>>>0,B[k]=D%c>>>0,D=D/c>>>0;if(D!==0)throw new Error("Non-zero carry");d=P,E++}for(var U=m-d;U!==m&&B[U]===0;)U++;for(var T=a.repeat(g);U<m;++U)T+=r.charAt(B[U]);return T}function h(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var g=0;if(x[g]!==" "){for(var d=0,E=0;x[g]===a;)d++,g++;for(var A=(x.length-g)*l+1>>>0,m=new Uint8Array(A);x[g];){var B=e[x.charCodeAt(g)];if(B===255)return;for(var D=0,P=A-1;(B!==0||D<E)&&P!==-1;P--,D++)B+=c*m[P]>>>0,m[P]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");E=D,g++}if(x[g]!==" "){for(var k=A-E;k!==A&&m[k]===0;)k++;for(var U=new Uint8Array(d+(A-k)),T=d;k!==A;)U[T++]=m[k++];return U}}}function b(x){var g=h(x);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:h,decode:b}}var ff=lf,df=ff,nc=df;var Go=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},jo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return oc(this,t)}},Zo=class{decoders;constructor(t){this.decoders=t}or(t){return oc(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 oc(r,t){return new Zo({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Yo=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Go(t,e,n),this.decoder=new jo(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ye({name:r,prefix:t,encode:e,decode:n}){return new Yo(r,t,e,n)}function we({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=nc(e,r);return Ye({prefix:t,name:r,encode:n,decode:i=>ae(o(i))})}function hf(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),c=0,a=0,l=0;for(let u=0;u<i;++u){let f=o[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,c+=e,c>=8&&(c-=8,s[l++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return s}function pf(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>e;)s-=e,i+=t[o&c>>s];if(s!==0&&(i+=t[o&c<<e-s]),n)for(;(i.length*e&7)!==0;)i+="=";return i}function st({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Ye({prefix:t,name:r,encode(o){return pf(o,n,e)},decode(o){return hf(o,n,e,r)}})}var jt=st({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mf=st({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gf=st({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yf=st({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bf=st({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xf=st({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),wf=st({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ef=st({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vf=st({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Xo={};Tt(Xo,{base58btc:()=>tt,base58flickr:()=>Sf});var tt=we({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sf=we({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Qo={};Tt(Qo,{base64:()=>oe,base64pad:()=>Af,base64url:()=>_f,base64urlpad:()=>Bf});var oe=st({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Af=st({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_f=st({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Bf=st({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function If(r,t){try{if(typeof r=="string"&&r.length>0)return Cf(r);if(typeof r=="number"&&isFinite(r))return t?.long?Tf(r):kf(r);throw new Error("Value is not a string or number.")}catch(e){let n=Uf(e)?`${e.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function Cf(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 _n=If;function kf(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 Tf(r){let t=Math.abs(r);return t>=864e5?An(r,t,864e5,"day"):t>=36e5?An(r,t,36e5,"hour"):t>=6e4?An(r,t,6e4,"minute"):t>=1e3?An(r,t,1e3,"second"):`${r} ms`}function An(r,t,e,n){let o=t>=e*1.5;return`${Math.round(r/e)} ${n}${o?"s":""}`}function Uf(r){return typeof r=="object"&&r!==null&&"message"in r}function Jo(r){e.debug=e,e.default=e,e.coerce=a,e.disable=i,e.enable=o,e.enabled=s,e.humanize=_n,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,b,x;function g(...d){if(!g.enabled)return;let E=g,A=Number(new Date),m=A-(f||A);E.diff=m,E.prev=f,E.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,(P,k)=>{if(P==="%%")return"%";B++;let U=e.formatters[k];if(typeof U=="function"){let T=d[B];P=U.call(E,T),d.splice(B,1),B--}return P}),e.formatArgs.call(E,d),(E.log||e.log).apply(E,d)}return g.namespace=u,g.useColors=e.useColors(),g.color=e.selectColor(u),g.extend=n,g.destroy=e.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(b!==e.namespaces&&(b=e.namespaces,x=e.enabled(u)),x),set:d=>{h=d}}),typeof e.init=="function"&&e.init(g),g}function n(u,f){let h=e(this.namespace+(typeof f>"u"?":":f)+u);return h.log=this.log,h}function o(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let f,h=(typeof u=="string"?u:"").split(/[\s,]+/),b=h.length;for(f=0;f<b;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 Bn=Of(),Lf=["#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 Pf(){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 Df(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+_n(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 Nf=console.debug??console.log??(()=>{});function Rf(r){try{r?Bn?.setItem("debug",r):Bn?.removeItem("debug")}catch{}}function Mf(){let r;try{r=Bn?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function Of(){try{return localStorage}catch{}}function Ff(r){r.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}var ic=Jo({formatArgs:Df,save:Rf,load:Mf,useColors:Pf,setupFormatters:Ff,colors:Lf,storage:Bn,log:Nf});var xt=ic;xt.formatters.b=r=>r==null?"undefined":tt.baseEncode(r);xt.formatters.t=r=>r==null?"undefined":jt.baseEncode(r);xt.formatters.m=r=>r==null?"undefined":oe.baseEncode(r);xt.formatters.p=r=>r==null?"undefined":r.toString();xt.formatters.c=r=>r==null?"undefined":r.toString();xt.formatters.k=r=>r==null?"undefined":r.toString();xt.formatters.a=r=>r==null?"undefined":r.toString();xt.formatters.e=r=>r==null?"undefined":sc(r.stack)??sc(r.message)??r.toString();function Kf(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 cc(r){let t=Kf(`${r}:trace`);return xt.enabled(`${r}:trace`)&&xt.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=xt(`${r}:trace`)),Object.assign(xt(r),{error:xt(`${r}:error`),trace:t})}function ac(){xt.disable()}function uc(r){xt.enable(r)}function sc(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}function Vf(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 lc=Vf;function zf(r){return r[Symbol.asyncIterator]!=null}function fc(r){return r?.then!=null}function Hf(r,t){let e=0;if(zf(r))return async function*(){for await(let a of r){let l=t(a,e++);fc(l)&&await l,yield a}}();let n=lc(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++);fc(l)&&await l,yield a}}();let c=t;return function*(){yield o;for(let a of n)c(a,e++),yield a}()}var ti=Hf;var Sc=cf(vc(),1),Yf=cc("libp2p:simple-metrics"),Lr=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}}},Pr=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}}},Dr=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)}}},kn=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 Dr({})),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})}}},Nr=class{sumValue=0;countValue=0;percentiles;tdigest=new Sc.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)}}},Tn=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 Nr(this.opts)),this.summaries[e].observe(n)}reset(){for(let t of Object.values(this.summaries))t.reset()}timer(t){let e=Date.now();return()=>{this.observe({[t]:Date.now()-e})}}},ri=class{metrics=new Map;transferStats;started;interval;intervalMs;onMetrics;constructor(t,e){this.started=!1,this._emitMetrics=this._emitMetrics.bind(this),this.intervalMs=e.intervalMs??1e3,this.onMetrics=e.onMetrics,this.transferStats=new Map}[Symbol.toStringTag]="@libp2p/metrics-simple";[xe]=["@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 Lr?t[e]=n.value:n instanceof Pr?t[e]=n.values:n instanceof Dr?t[e]={count:n.countValue,sum:n.sumValue,buckets:{...n.bucketValues}}:n instanceof kn?t[e]={...Object.fromEntries(Object.entries(n.histograms).map(([o,i])=>[o,{count:i.countValue,sum:i.sumValue,buckets:{...i.bucketValues}}]))}:n instanceof Nr?t[e]={count:n.countValue,sum:n.sumValue,percentiles:Object.fromEntries(n.percentiles.map(o=>[o,n.tdigest.percentile(o)]))}:n instanceof Tn?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(ti(c,a=>{n._incrementValue(`${e} sent`,a.byteLength)}))};let i=t.source;t.source=ti(i,s=>{n._incrementValue(`${e} received`,s.byteLength)})}trackMultiaddrConnection(t){this._track(t,"global")}trackProtocolStream(t,e){t.protocol!=null&&this._track(t,t.protocol)}registerMetric(t,e={}){if(t==null||t.trim()==="")throw new Error("Metric name is required");if(e?.calculate!=null){this.metrics.set(t,e.calculate);return}let n=new Lr;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 Pr;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 Lr;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 Pr;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 Dr(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 kn(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 Nr(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 Tn(e);return this.metrics.set(t,n),n}createTrace(){}traceFunction(t,e){return e}};function Ac(r){return t=>new ri(t,r)}function wt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Un=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||(t-1&t)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Qe=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Un(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 Un(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var ni=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function Je(r={}){return Wf(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 Wf(r,t){t=t??{};let e=t.onEnd,n=new Qe,o,i,s,c=wt(),a=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((d,E)=>{i=A=>{i=null,n.push(A);try{d(r(n))}catch(m){E(m)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=wt()})}},l=d=>i!=null?i(d):(n.push(d),o),u=d=>(n=new Qe,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})),b=()=>(n=new Qe,h(),{done:!0}),x=d=>(h(d),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:b,throw:x,push:f,end:h,get readableLength(){return n.size},onEmpty:async d=>{let E=d?.signal;if(E?.throwIfAborted(),n.isEmpty())return;let A,m;E!=null&&(A=new Promise((B,D)=>{m=()=>{D(new ni)},E.addEventListener("abort",m)}));try{await Promise.race([c.promise,A])}finally{m!=null&&E!=null&&E?.removeEventListener("abort",m)}}},e==null)return o;let g=o;return o={[Symbol.asyncIterator](){return this},next(){return g.next()},throw(d){return g.throw(d),e!=null&&(e(d),e=void 0),{done:!0}},return(){return g.return(),e!=null&&(e(),e=void 0),{done:!0}},push:f,end(d){return g.end(d),e!=null&&(e(d),e=void 0),o},get readableLength(){return g.readableLength},onEmpty:d=>g.onEmpty(d)},o}var Ln=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function _c(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new Ln(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Ln(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((i,s)=>{n=()=>{s(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var oi=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=wt(),this.haveNext=wt()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=wt(),t}async throw(t){return this.ended=!0,this.error=t,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=wt(),await _c(this.readNext.promise,e?.signal,e)}};function Bc(){return new oi}function Xf(r){return r[Symbol.asyncIterator]!=null}async function Qf(r,t){try{await Promise.all(r.map(async e=>{for await(let n of e)await t.push(n)})),await t.end()}catch(e){await t.end(e).catch(()=>{})}}async function*Jf(r){let t=Bc();Qf(r,t).catch(()=>{}),yield*t}function*td(r){for(let t of r)yield*t}function ed(...r){let t=[];for(let e of r)Xf(e)||t.push(e);return t.length===r.length?td(t):Jf(r)}var Ic=ed;function Cc(r,...t){if(r==null)throw new Error("Empty pipeline");if(ii(r)){let n=r;r=()=>n.source}else if(Tc(r)||kc(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&ii(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let n=1;n<e.length-1;n++)ii(e[n])&&(e[n]=nd(e[n]));return rd(...e)}var rd=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},kc=r=>r?.[Symbol.asyncIterator]!=null,Tc=r=>r?.[Symbol.iterator]!=null,ii=r=>r==null?!1:r.sink!=null&&r.source!=null,nd=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=Je({objectMode:!0});e.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(kc(i))o=async function*(){yield*i,n.end()};else if(Tc(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 Pn(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 Yt(r=0){return new Uint8Array(r)}function Et(r=0){return new Uint8Array(r)}var od=Math.pow(2,7),id=Math.pow(2,14),sd=Math.pow(2,21),si=Math.pow(2,28),ci=Math.pow(2,35),ai=Math.pow(2,42),ui=Math.pow(2,49),G=128,vt=127;function dt(r){if(r<od)return 1;if(r<id)return 2;if(r<sd)return 3;if(r<si)return 4;if(r<ci)return 5;if(r<ai)return 6;if(r<ui)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function li(r,t,e=0){switch(dt(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 cd(r,t,e=0){switch(dt(r)){case 8:t.set(e++,r&255|G),r/=128;case 7:t.set(e++,r&255|G),r/=128;case 6:t.set(e++,r&255|G),r/=128;case 5:t.set(e++,r&255|G),r/=128;case 4:t.set(e++,r&255|G),r>>>=7;case 3:t.set(e++,r&255|G),r>>>=7;case 2:t.set(e++,r&255|G),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function fi(r,t){let e=r[t],n=0;if(n+=e&vt,e<G||(e=r[t+1],n+=(e&vt)<<7,e<G)||(e=r[t+2],n+=(e&vt)<<14,e<G)||(e=r[t+3],n+=(e&vt)<<21,e<G)||(e=r[t+4],n+=(e&vt)*si,e<G)||(e=r[t+5],n+=(e&vt)*ci,e<G)||(e=r[t+6],n+=(e&vt)*ai,e<G)||(e=r[t+7],n+=(e&vt)*ui,e<G))return n;throw new RangeError("Could not decode varint")}function ad(r,t){let e=r.get(t),n=0;if(n+=e&vt,e<G||(e=r.get(t+1),n+=(e&vt)<<7,e<G)||(e=r.get(t+2),n+=(e&vt)<<14,e<G)||(e=r.get(t+3),n+=(e&vt)<<21,e<G)||(e=r.get(t+4),n+=(e&vt)*si,e<G)||(e=r.get(t+5),n+=(e&vt)*ci,e<G)||(e=r.get(t+6),n+=(e&vt)*ai,e<G)||(e=r.get(t+7),n+=(e&vt)*ui,e<G))return n;throw new RangeError("Could not decode varint")}function ve(r,t,e=0){return t==null&&(t=Et(dt(r))),t instanceof Uint8Array?li(r,t,e):cd(r,t,e)}function ue(r,t=0){return r instanceof Uint8Array?fi(r,t):ad(r,t)}function Dt(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=Et(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function Nt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var 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 Nn(r){return!!r?.[Lc]}var gt=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(Nn(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(Nn(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(Nn(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Dt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Dt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),i=new r;return i.length=o,i.bufs=[...n],i}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,a=c+s.byteLength;if(o=a,t>=a)continue;let l=t>=c&&t<a,u=e>c&&e<=a;if(l&&u){if(t===c&&e===a){n.push(s);break}let f=t-c;n.push(s.subarray(f,f+(e-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-c));continue}if(u){if(e===a){n.push(s);break}n.push(s.subarray(0,e-c));break}n.push(s)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Nn(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 b=this.get(f+h);if(n[h]!==b){u=Math.max(1,h-c[b]);break}}if(u===0)return f}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=Et(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=Yt(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=Yt(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=Yt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=Et(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=Yt(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=Yt(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=Yt(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=Yt(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=Yt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!Nt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,i)=>o+i.byteLength,0)),n.length=e,n}};var Rn=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},tr=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Mn=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},Rr=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function On(r){return r[Symbol.asyncIterator]!=null}function Pc(r,t){if(r.byteLength>t)throw new tr("Message length too long")}var Kn=r=>{let t=dt(r),e=Et(t);return ve(r,e),Kn.bytes=t,e};Kn.bytes=0;function Vn(r,t){t=t??{};let e=t.lengthEncoder??Kn,n=t?.maxDataLength??4194304;function*o(i){Pc(i,n);let s=e(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}return On(r)?async function*(){for await(let i of r)yield*o(i)}():function*(){for(let i of r)yield*o(i)}()}Vn.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??Kn,n=t?.maxDataLength??4194304;return Pc(r,n),new gt(e(r.byteLength),r)};var Ne;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Ne||(Ne={}));var di=r=>{let t=ue(r);return di.bytes=dt(t),t};di.bytes=0;function Mr(r,t){let e=new gt,n=Ne.LENGTH,o=-1,i=t?.lengthDecoder??di,s=t?.maxLengthLength??8,c=t?.maxDataLength??4194304;function*a(){for(;e.byteLength>0;){if(n===Ne.LENGTH)try{if(o=i(e),o<0)throw new Rn("Invalid message length");if(o>c)throw new tr("Message length too long");let l=i.bytes;e.consume(l),t?.onLength!=null&&t.onLength(o),n=Ne.DATA}catch(l){if(l instanceof RangeError){if(e.byteLength>s)throw new Mn("Message length length too long");break}throw l}if(n===Ne.DATA){if(e.byteLength<o)break;let l=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(l),yield l,n=Ne.LENGTH}}}return On(r)?async function*(){for await(let l of r)e.append(l),yield*a();if(e.byteLength>0)throw new Rr("Unexpected end of input")}():function*(){for(let l of r)e.append(l),yield*a();if(e.byteLength>0)throw new Rr("Unexpected end of input")}()}Mr.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 Mr(n,{...t??{},onLength:i=>{e=i}})};var Dc="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var er=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Dc[e[r]&63];return t};var zn=class extends Error{constructor(t="Method not found"){super(t),this.name="MethodNotFoundError"}},Hn=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidMethodError"}},Or=class extends Error{constructor(t="Unsupported value type"){super(t),this.name="UnsupportedValueTypeError"}},qn=class extends Error{constructor(t="Cannot reuse RPC target name"){super(t),this.name="DuplicateTargetNameError"}},Fr=class extends Error{constructor(t="Duplicate scope"){super(t),this.name="DuplicateScopeError"}},$n=class extends Error{constructor(t="Invalid return type"){super(t),this.name="InvalidReturnTypeError"}},Kr=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidInvocationTypeError"}},rr=class extends Error{constructor(t="Parent invocation scope not found"){super(t),this.name="MissingParentScopeError"}},Gn=class extends Error{constructor(t="Invocation not found"){super(t),this.name="MissingInvocationError"}},jn=class extends Error{constructor(t="Callback not found"){super(t),this.name="MissingCallbackError"}};var hi=new Float32Array([-0]),Se=new Uint8Array(hi.buffer);function Nc(r,t,e){hi[0]=r,t[e]=Se[0],t[e+1]=Se[1],t[e+2]=Se[2],t[e+3]=Se[3]}function Rc(r,t){return Se[0]=r[t],Se[1]=r[t+1],Se[2]=r[t+2],Se[3]=r[t+3],hi[0]}var pi=new Float64Array([-0]),St=new Uint8Array(pi.buffer);function Mc(r,t,e){pi[0]=r,t[e]=St[0],t[e+1]=St[1],t[e+2]=St[2],t[e+3]=St[3],t[e+4]=St[4],t[e+5]=St[5],t[e+6]=St[6],t[e+7]=St[7]}function Oc(r,t){return St[0]=r[t],St[1]=r[t+1],St[2]=r[t+2],St[3]=r[t+3],St[4]=r[t+4],St[5]=r[t+5],St[6]=r[t+6],St[7]=r[t+7],pi[0]}var ld=BigInt(Number.MAX_SAFE_INTEGER),fd=BigInt(Number.MIN_SAFE_INTEGER),Rt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Re;if(t<ld&&t>fd)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>Fc&&(o=0n,++n>Fc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return Re;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):Re}},Re=new Rt(0,0);Re.toBigInt=function(){return 0n};Re.zzEncode=Re.zzDecode=function(){return this};Re.length=function(){return 1};var Fc=4294967296n;function Kc(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 Vc(r,t,e){if(e-t<1)return"";let o,i=[],s=0,c;for(;t<e;)c=r[t++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function mi(r,t,e){let n=e,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function Wt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Zn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var gi=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Wt(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 Wt(this,4);return Zn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Wt(this,4);return Zn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Wt(this,4);let t=Rc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Wt(this,4);let t=Oc(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 Wt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Vc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Wt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Wt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Rt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Wt(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 Wt(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 Wt(this,8);let t=Zn(this.buf,this.pos+=4),e=Zn(this.buf,this.pos+=4);return new Rt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=fi(this.buf,this.pos);return this.pos+=dt(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function yi(r){return new gi(r instanceof Uint8Array?r:r.subarray())}function _t(r,t,e){let n=yi(r);return t.decode(n,void 0,e)}var bi={};Tt(bi,{base10:()=>dd});var dd=we({prefix:"9",name:"base10",alphabet:"0123456789"});var xi={};Tt(xi,{base16:()=>hd,base16upper:()=>pd});var hd=st({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),pd=st({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var wi={};Tt(wi,{base2:()=>md});var md=st({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ei={};Tt(Ei,{base256emoji:()=>wd});var Hc=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}"),gd=Hc.reduce((r,t,e)=>(r[e]=t,r),[]),yd=Hc.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function bd(r){return r.reduce((t,e)=>(t+=gd[e],t),"")}function xd(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=yd[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var wd=Ye({prefix:"\u{1F680}",name:"base256emoji",encode:bd,decode:xd});var vi={};Tt(vi,{base36:()=>Vr,base36upper:()=>Ed});var Vr=we({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ed=we({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Si={};Tt(Si,{base8:()=>vd});var vd=st({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ai={};Tt(Ai,{identity:()=>Sd});var Sd=Ye({prefix:"\0",name:"identity",encode:r=>ec(r),decode:r=>tc(r)});var _y=new TextEncoder,By=new TextDecoder;var Bi={};Tt(Bi,{identity:()=>Xt});var Bd=Gc,qc=128,Id=127,Cd=~Id,kd=Math.pow(2,31);function Gc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=kd;)t[e++]=r&255|qc,r/=128;for(;r&Cd;)t[e++]=r&255|qc,r>>>=7;return t[e]=r|0,Gc.bytes=e-n+1,t}var Td=_i,Ud=128,$c=127;function _i(r,n){var e=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw _i.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&$c)<<o:(s&$c)*Math.pow(2,o),o+=7}while(s>=Ud);return _i.bytes=i-n,e}var Ld=Math.pow(2,7),Pd=Math.pow(2,14),Dd=Math.pow(2,21),Nd=Math.pow(2,28),Rd=Math.pow(2,35),Md=Math.pow(2,42),Od=Math.pow(2,49),Fd=Math.pow(2,56),Kd=Math.pow(2,63),Vd=function(r){return r<Ld?1:r<Pd?2:r<Dd?3:r<Nd?4:r<Rd?5:r<Md?6:r<Od?7:r<Fd?8:r<Kd?9:10},zd={encode:Bd,decode:Td,encodingLength:Vd},Hd=zd,zr=Hd;function Hr(r,t=0){return[zr.decode(r,t),zr.decode.bytes]}function nr(r,t,e=0){return zr.encode(r,t,e),t}function or(r){return zr.encodingLength(r)}function Me(r,t){let e=t.byteLength,n=or(r),o=n+or(e),i=new Uint8Array(o+e);return nr(r,i,0),nr(e,i,n),i.set(t,o),new ir(r,e,t,i)}function le(r){let t=ae(r),[e,n]=Hr(t),[o,i]=Hr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new ir(e,o,s,t)}function jc(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Js(r.bytes,e.bytes)}}var ir=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Zc=0,qd="identity",Yc=ae;function $d(r){return Me(Zc,Yc(r))}var Xt={code:Zc,name:qd,encode:Yc,digest:$d};var ki={};Tt(ki,{sha256:()=>qr,sha512:()=>Gd});function Ci({name:r,code:t,encode:e}){return new Ii(r,t,e)}var Ii=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?Me(this.code,e):e.then(n=>Me(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Xc(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var qr=Ci({name:"sha2-256",code:18,encode:Xc("SHA-256")}),Gd=Ci({name:"sha2-512",code:19,encode:Xc("SHA-512")});function Qc(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Zd(e,Ti(r),t??tt.encoder);default:return Yd(e,Ti(r),t??jt.encoder)}}var Jc=new WeakMap;function Ti(r){let t=Jc.get(r);if(t==null){let e=new Map;return Jc.set(r,e),e}return t}var ct=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==$r)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Wd)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=Me(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&&jc(t.multihash,n.multihash)}toString(t){return Qc(this,t)}toJSON(){return{"/":Qc(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??ta(n,o,i.bytes))}else if(e[Xd]===!0){let{version:n,multihash:o,code:i}=e,s=le(o);return r.create(n,i,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==$r)throw new Error(`Version 0 CID must use dag-pb (code: ${$r}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=ta(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,$r,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=ae(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new ir(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]=Hr(t.subarray(e));return e+=h,f},o=n(),i=$r;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]=jd(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ti(i).set(n,t),i}};function jd(r,t){switch(r[0]){case"Q":{let e=t??tt;return[tt.prefix,e.decode(`${tt.prefix}${r}`)]}case tt.prefix:{let e=t??tt;return[tt.prefix,e.decode(r)]}case jt.prefix:{let e=t??jt;return[jt.prefix,e.decode(r)]}case Vr.prefix:{let e=t??Vr;return[Vr.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 Zd(r,t,e){let{prefix:n}=e;if(n!==tt.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function Yd(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 $r=112,Wd=18;function ta(r,t,e){let n=or(r),o=n+or(t),i=new Uint8Array(o+e.byteLength);return nr(r,i,0),nr(t,i,n),i.set(e,o),i}var Xd=Symbol.for("@ipld/js-cid/CID");var Gr={...Ai,...wi,...Si,...bi,...xi,...Wo,...vi,...Xo,...Qo,...Ei},Zy={...ki,...Bi};function ra(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var ea=ra("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ui=ra("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Et(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Qd={utf8:ea,"utf-8":ea,hex:Gr.base16,latin1:Ui,ascii:Ui,binary:Ui,...Gr},Wn=Qd;function qt(r,t="utf8"){let e=Wn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Li(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return Et(s);o+s>t&&(n=Et(t),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Oe=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Pi(){}var Ni=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Jd=Li();function th(r){return globalThis.Buffer!=null?Et(r):Jd(r)}var Zr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Oe(Pi,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Oe(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Ri((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Xn,10,Rt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Rt.fromBigInt(t);return this._push(Xn,e.length(),e)}uint64Number(t){return this._push(li,dt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=Rt.fromBigInt(t).zzEncode();return this._push(Xn,e.length(),e)}sint64Number(t){let e=Rt.fromNumber(t).zzEncode();return this._push(Xn,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Di,1,t?1:0)}fixed32(t){return this._push(jr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Rt.fromBigInt(t);return this._push(jr,4,e.lo)._push(jr,4,e.hi)}fixed64Number(t){let e=Rt.fromNumber(t);return this._push(jr,4,e.lo)._push(jr,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(Nc,4,t)}double(t){return this._push(Mc,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Di,1,0):this.uint32(e)._push(rh,e,t)}string(t){let e=Kc(t);return e!==0?this.uint32(e)._push(mi,e,t):this._push(Di,1,0)}fork(){return this.states=new Ni(this),this.head=this.tail=new Oe(Pi,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Oe(Pi,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=th(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Di(r,t,e){t[e]=r&255}function eh(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Ri=class extends Oe{next;constructor(t,e){super(eh,t,e),this.next=void 0}};function Xn(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 jr(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 rh(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Zr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(nh,t,r),this},Zr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(oh,t,r),this});function nh(r,t,e){t.set(r,e)}function oh(r,t,e){r.length<40?mi(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(qt(r),e)}function Mi(){return new Zr}function Bt(r,t){let e=Mi();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var sr;(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"})(sr||(sr={}));function Qn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Yr(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",sr.VARINT,e,n)}function It(r,t){return Qn("message",sr.LENGTH_DELIMITED,r,t)}var fe=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 Jn;(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"})(Jn||(Jn={}));(function(r){r.codec=()=>Yr(Jn)})(q||(q={}));var Ut;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.type!=null&&e.type!==0&&(n.uint32(8),n.uint32(e.type)),e.value!=null&&(n.uint32(18),n.bytes(e.value)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={type:0},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.type=e.uint32();break}case 2:{i.value=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>Bt(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Ut||(Ut={}));var Ct;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.type!=null&&Jn[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:Yt(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=>Bt(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Ct||(Ct={}));var Fe;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.path!=null&&e.path!==""&&(n.uint32(18),n.string(e.path)),e.args!=null)for(let i of e.args)n.uint32(26),Ut.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",path:"",args:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.path=e.string();break}case 3:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new fe('Decode error - map field "args" had too many elements');i.args.push(Ut.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>Bt(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Fe||(Fe={}));var Wr;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>Bt(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Wr||(Wr={}));var cr;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.value!=null&&(n.uint32(18),Ut.codec().encode(e.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.value=Ut.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>Bt(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(cr||(cr={}));var Xr;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.error!=null&&(n.uint32(18),Ut.codec().encode(e.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.error=Ut.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>Bt(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Xr||(Xr={}));var ar;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);if(e.callback!=null&&e.callback!==""&&(n.uint32(26),n.string(e.callback)),e.args!=null)for(let i of e.args)n.uint32(34),Ut.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[],callback:"",args:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new fe('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.callback=e.string();break}case 4:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new fe('Decode error - map field "args" had too many elements');i.args.push(Ut.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>Bt(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(ar||(ar={}));var ur;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new fe('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>Bt(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(ur||(ur={}));var Qr;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);e.value!=null&&(n.uint32(26),Ut.codec().encode(e.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new fe('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.value=Ut.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>Bt(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Qr||(Qr={}));var Jr;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);e.error!=null&&(n.uint32(26),Ut.codec().encode(e.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new fe('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.error=Ut.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>Bt(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Jr||(Jr={}));function ih(r){return r.parents!=null}function na(r,t){if(ih(r))return sh(r.parents,t);let e=t.get(r.scope);if(e==null)throw new Gn;return e}function sh(r,t){let e;for(let n of r){if(e==null){if(e=t.get(n),e==null)throw new rr;continue}if(e=e.children.get(n),e==null)throw new rr}if(e==null)throw new rr;return e}var ch={type:1024,canEncode:r=>r===void 0,decode:()=>{}},oa=ch;var ah={type:1025,canEncode:r=>r===null,decode:()=>null},ia=ah;var uh=["string","number","bigint","symbol"],lh=["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 sa(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let t=typeof r;if(uh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(r))return"Array";if(fh(r))return"Buffer";let e=dh(r);return e||"Object"}function fh(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function dh(r){let t=Object.prototype.toString.call(r).slice(8,-1);if(lh.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 lr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",hh=new TextDecoder,ph=new TextEncoder;function to(r){return lr&&globalThis.Buffer.isBuffer(r)}function Oi(r){return r instanceof Uint8Array?to(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var la=lr?(r,t,e)=>e-t>64?globalThis.Buffer.from(r.subarray(t,e)).toString("utf8"):aa(r,t,e):(r,t,e)=>e-t>64?hh.decode(r.subarray(t,e)):aa(r,t,e),fa=lr?r=>r.length>64?globalThis.Buffer.from(r):ca(r):r=>r.length>64?ph.encode(r):ca(r),ie=r=>Uint8Array.from(r),fr=lr?(r,t,e)=>to(r)?new Uint8Array(r.subarray(t,e)):r.slice(t,e):(r,t,e)=>r.slice(t,e),da=lr?(r,t)=>(r=r.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),Oi(globalThis.Buffer.concat(r,t))):(r,t)=>{let e=new Uint8Array(t),n=0;for(let o of r)n+o.length>e.length&&(o=o.subarray(0,e.length-n)),e.set(o,n),n+=o.length;return e},ha=lr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function pa(r,t){if(to(r)&&to(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 ca(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 aa(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 mh(n)}var ua=4096;function mh(r){let t=r.length;if(t<=ua)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=ua));return e}var gh=256,tn=class{constructor(t=gh){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=ha(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=fr(n,0,this.cursor)}else e=da(this.chunks,this.cursor);return t&&this.reset(),e}};var M="CBOR decode error:",Fi="CBOR encode error:",en=[];en[23]=1;en[24]=2;en[25]=3;en[26]=5;en[27]=9;function de(r,t,e){if(r.length-t<e)throw new Error(`${M} not enough data for type`)}var ht=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Mt(r,t,e){de(r,t,1);let n=r[t];if(e.strict===!0&&n<ht[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Ot(r,t,e){de(r,t,2);let n=r[t]<<8|r[t+1];if(e.strict===!0&&n<ht[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Ft(r,t,e){de(r,t,4);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];if(e.strict===!0&&n<ht[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Kt(r,t,e){de(r,t,8);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3],o=r[t+4]*16777216+(r[t+5]<<16)+(r[t+6]<<8)+r[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(e.strict===!0&&i<ht[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 ma(r,t,e,n){return new I(p.uint,Mt(r,t+1,n),2)}function ga(r,t,e,n){return new I(p.uint,Ot(r,t+1,n),3)}function ya(r,t,e,n){return new I(p.uint,Ft(r,t+1,n),5)}function ba(r,t,e,n){return new I(p.uint,Kt(r,t+1,n),9)}function $t(r,t){return yt(r,0,t.value)}function yt(r,t,e){if(e<ht[0]){let n=Number(e);r.push([t|n])}else if(e<ht[1]){let n=Number(e);r.push([t|24,n])}else if(e<ht[2]){let n=Number(e);r.push([t|25,n>>>8,n&255])}else if(e<ht[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<ht[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`)}}$t.encodedSize=function(t){return yt.encodedSize(t.value)};yt.encodedSize=function(t){return t<ht[0]?1:t<ht[1]?2:t<ht[2]?3:t<ht[3]?5:9};$t.compareTokens=function(t,e){return t.value<e.value?-1:t.value>e.value?1:0};function xa(r,t,e,n){return new I(p.negint,-1-Mt(r,t+1,n),2)}function wa(r,t,e,n){return new I(p.negint,-1-Ot(r,t+1,n),3)}function Ea(r,t,e,n){return new I(p.negint,-1-Ft(r,t+1,n),5)}var Ki=BigInt(-1),va=BigInt(1);function Sa(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new 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,Ki-BigInt(o),9)}function eo(r,t){let e=t.value,n=typeof e=="bigint"?e*Ki-va:e*-1-1;yt(r,t.type.majorEncoded,n)}eo.encodedSize=function(t){let e=t.value,n=typeof e=="bigint"?e*Ki-va:e*-1-1;return n<ht[0]?1:n<ht[1]?2:n<ht[2]?3:n<ht[3]?5:9};eo.compareTokens=function(t,e){return t.value<e.value?1:t.value>e.value?-1:0};function rn(r,t,e,n){de(r,t,e+n);let o=fr(r,t+e,t+e+n);return new I(p.bytes,o,e+n)}function Aa(r,t,e,n){return rn(r,t,1,e)}function _a(r,t,e,n){return rn(r,t,2,Mt(r,t+1,n))}function Ba(r,t,e,n){return rn(r,t,3,Ot(r,t+1,n))}function Ia(r,t,e,n){return rn(r,t,5,Ft(r,t+1,n))}function Ca(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return rn(r,t,9,o)}function ro(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===p.string?fa(r.value):r.value),r.encodedBytes}function dr(r,t){let e=ro(t);yt(r,t.type.majorEncoded,e.length),r.push(e)}dr.encodedSize=function(t){let e=ro(t);return yt.encodedSize(e.length)+e.length};dr.compareTokens=function(t,e){return bh(ro(t),ro(e))};function bh(r,t){return r.length<t.length?-1:r.length>t.length?1:pa(r,t)}function nn(r,t,e,n,o){let i=e+n;de(r,t,i);let s=new I(p.string,la(r,t+e,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=fr(r,t+e,t+i)),s}function ka(r,t,e,n){return nn(r,t,1,e,n)}function Ta(r,t,e,n){return nn(r,t,2,Mt(r,t+1,n),n)}function Ua(r,t,e,n){return nn(r,t,3,Ot(r,t+1,n),n)}function La(r,t,e,n){return nn(r,t,5,Ft(r,t+1,n),n)}function Pa(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return nn(r,t,9,o,n)}var Da=dr;function hr(r,t,e,n){return new I(p.array,n,e)}function Na(r,t,e,n){return hr(r,t,1,e)}function Ra(r,t,e,n){return hr(r,t,2,Mt(r,t+1,n))}function Ma(r,t,e,n){return hr(r,t,3,Ot(r,t+1,n))}function Oa(r,t,e,n){return hr(r,t,5,Ft(r,t+1,n))}function Fa(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return hr(r,t,9,o)}function Ka(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return hr(r,t,1,1/0)}function no(r,t){yt(r,p.array.majorEncoded,t.value)}no.compareTokens=$t.compareTokens;no.encodedSize=function(t){return yt.encodedSize(t.value)};function pr(r,t,e,n){return new I(p.map,n,e)}function Va(r,t,e,n){return pr(r,t,1,e)}function za(r,t,e,n){return pr(r,t,2,Mt(r,t+1,n))}function Ha(r,t,e,n){return pr(r,t,3,Ot(r,t+1,n))}function qa(r,t,e,n){return pr(r,t,5,Ft(r,t+1,n))}function $a(r,t,e,n){let o=Kt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return pr(r,t,9,o)}function Ga(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return pr(r,t,1,1/0)}function oo(r,t){yt(r,p.map.majorEncoded,t.value)}oo.compareTokens=$t.compareTokens;oo.encodedSize=function(t){return yt.encodedSize(t.value)};function ja(r,t,e,n){return new I(p.tag,e,1)}function Za(r,t,e,n){return new I(p.tag,Mt(r,t+1,n),2)}function Ya(r,t,e,n){return new I(p.tag,Ot(r,t+1,n),3)}function Wa(r,t,e,n){return new I(p.tag,Ft(r,t+1,n),5)}function Xa(r,t,e,n){return new I(p.tag,Kt(r,t+1,n),9)}function io(r,t){yt(r,p.tag.majorEncoded,t.value)}io.compareTokens=$t.compareTokens;io.encodedSize=function(t){return yt.encodedSize(t.value)};var Ah=20,_h=21,Bh=22,Ih=23;function Qa(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 Ja(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 Vi(r,t,e){if(e){if(e.allowNaN===!1&&Number.isNaN(r))throw new Error(`${M} NaN values are not supported`);if(e.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new I(p.float,r,t)}function tu(r,t,e,n){return Vi(zi(r,t+1),3,n)}function eu(r,t,e,n){return Vi(Hi(r,t+1),5,n)}function ru(r,t,e,n){return Vi(su(r,t+1),9,n)}function so(r,t,e){let n=t.value;if(n===!1)r.push([p.float.majorEncoded|Ah]);else if(n===!0)r.push([p.float.majorEncoded|_h]);else if(n===null)r.push([p.float.majorEncoded|Bh]);else if(n===void 0)r.push([p.float.majorEncoded|Ih]);else{let o,i=!1;(!e||e.float64!==!0)&&(ou(n),o=zi(Qt,1),n===o||Number.isNaN(n)?(Qt[0]=249,r.push(Qt.slice(0,3)),i=!0):(iu(n),o=Hi(Qt,1),n===o&&(Qt[0]=250,r.push(Qt.slice(0,5)),i=!0))),i||(Ch(n),o=su(Qt,1),Qt[0]=251,r.push(Qt.slice(0,9)))}}so.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){ou(n);let o=zi(Qt,1);if(n===o||Number.isNaN(n))return 3;if(iu(n),o=Hi(Qt,1),n===o)return 5}return 9};var nu=new ArrayBuffer(9),Gt=new DataView(nu,1),Qt=new Uint8Array(nu,0);function ou(r){if(r===1/0)Gt.setUint16(0,31744,!1);else if(r===-1/0)Gt.setUint16(0,64512,!1);else if(Number.isNaN(r))Gt.setUint16(0,32256,!1);else{Gt.setFloat32(0,r);let t=Gt.getUint32(0),e=(t&2139095040)>>23,n=t&8388607;if(e===255)Gt.setUint16(0,31744,!1);else if(e===0)Gt.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=e-127;o<-24?Gt.setUint16(0,0):o<-14?Gt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Gt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function zi(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 iu(r){Gt.setFloat32(0,r,!1)}function Hi(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 Ch(r){Gt.setFloat64(0,r,!1)}function su(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)}so.compareTokens=$t.compareTokens;function $(r,t,e){throw new Error(`${M} encountered invalid minor (${e}) for major ${r[t]>>>5}`)}function co(r){return()=>{throw new Error(`${M} ${r}`)}}var S=[];for(let r=0;r<=23;r++)S[r]=$;S[24]=ma;S[25]=ga;S[26]=ya;S[27]=ba;S[28]=$;S[29]=$;S[30]=$;S[31]=$;for(let r=32;r<=55;r++)S[r]=$;S[56]=xa;S[57]=wa;S[58]=Ea;S[59]=Sa;S[60]=$;S[61]=$;S[62]=$;S[63]=$;for(let r=64;r<=87;r++)S[r]=Aa;S[88]=_a;S[89]=Ba;S[90]=Ia;S[91]=Ca;S[92]=$;S[93]=$;S[94]=$;S[95]=co("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)S[r]=ka;S[120]=Ta;S[121]=Ua;S[122]=La;S[123]=Pa;S[124]=$;S[125]=$;S[126]=$;S[127]=co("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)S[r]=Na;S[152]=Ra;S[153]=Ma;S[154]=Oa;S[155]=Fa;S[156]=$;S[157]=$;S[158]=$;S[159]=Ka;for(let r=160;r<=183;r++)S[r]=Va;S[184]=za;S[185]=Ha;S[186]=qa;S[187]=$a;S[188]=$;S[189]=$;S[190]=$;S[191]=Ga;for(let r=192;r<=215;r++)S[r]=ja;S[216]=Za;S[217]=Ya;S[218]=Wa;S[219]=Xa;S[220]=$;S[221]=$;S[222]=$;S[223]=$;for(let r=224;r<=243;r++)S[r]=co("simple values are not supported");S[244]=$;S[245]=$;S[246]=$;S[247]=Qa;S[248]=co("simple values are not supported");S[249]=tu;S[250]=eu;S[251]=ru;S[252]=$;S[253]=$;S[254]=$;S[255]=Ja;var Jt=[];for(let r=0;r<24;r++)Jt[r]=new I(p.uint,r,1);for(let r=-1;r>=-24;r--)Jt[31-r]=new I(p.negint,r,1);Jt[64]=new I(p.bytes,new Uint8Array(0),1);Jt[96]=new I(p.string,"",1);Jt[128]=new I(p.array,0,1);Jt[160]=new I(p.map,0,1);Jt[244]=new I(p.false,!1,1);Jt[245]=new I(p.true,!0,1);Jt[246]=new I(p.null,null,1);function cu(r){switch(r.type){case p.false:return ie([244]);case p.true:return ie([245]);case p.null:return ie([246]);case p.bytes:return r.value.length?void 0:ie([64]);case p.string:return r.value===""?ie([96]):void 0;case p.array:return r.value===0?ie([128]):void 0;case p.map:return r.value===0?ie([160]):void 0;case p.uint:return r.value<24?ie([Number(r.value)]):void 0;case p.negint:if(r.value>=-24)return ie([31-Number(r.value)])}}var Th={float64:!1,mapSorter:Ph,quickEncodeToken:cu};function Uh(){let r=[];return r[p.uint.major]=$t,r[p.negint.major]=eo,r[p.bytes.major]=dr,r[p.string.major]=Da,r[p.array.major]=no,r[p.map.major]=oo,r[p.tag.major]=io,r[p.float.major]=so,r}var au=Uh(),qi=new tn,uo=class r{constructor(t,e){this.obj=t,this.parent=e}includes(t){let e=this;do if(e.obj===t)return!0;while(e=e.parent);return!1}static createCheck(t,e){if(t&&t.includes(e))throw new Error(`${Fi} object contains circular references`);return new r(e,t)}},_e={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?_e.true:_e.false},null(r,t,e,n){return _e.null},undefined(r,t,e,n){return _e.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?[_e.emptyArray,new I(p.break)]:_e.emptyArray;n=uo.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=ao(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?[_e.emptyMap,new I(p.break)]:_e.emptyMap;n=uo.createCheck(n,r);let c=[],a=0;for(let l of i)c[a++]=[ao(l,e,n),ao(o?r.get(l):r[l],e,n)];return Lh(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 ao(r,t={},e){let n=sa(r),o=t&&t.typeEncoders&&t.typeEncoders[n]||Be[n];if(typeof o=="function"){let s=o(r,n,t,e);if(s!=null)return s}let i=Be[n];if(!i)throw new Error(`${Fi} unsupported type: ${n}`);return i(r,n,t,e)}function Lh(r,t){t.mapSorter&&r.sort(t.mapSorter)}function Ph(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=au[o].compareTokens(e,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function uu(r,t,e,n){if(Array.isArray(t))for(let o of t)uu(r,o,e,n);else e[t.type.major](r,t,n)}function Dh(r,t,e){let n=ao(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 tn(s);if(i(c,n,e),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Oi(c.chunks[0])}}return qi.reset(),uu(qi,n,t,e),qi.toBytes(!0)}function Y(r,t){return t=Object.assign({},Th,t),Dh(r,au,t)}var Nh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},lo=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=Jt[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}},on=Symbol.for("DONE"),fo=Symbol.for("BREAK");function Rh(r,t,e){let n=[];for(let o=0;o<r.value;o++){let i=mr(t,e);if(i===fo){if(r.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===on)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Mh(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=mr(t,e);if(c===fo){if(r.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(c===on)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=mr(t,e);if(a===on)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 mr(r,t){if(r.done())return on;let e=r.next();if(e.type===p.break)return fo;if(e.type.terminal)return e.value;if(e.type===p.array)return Rh(e,r,t);if(e.type===p.map)return Mh(e,r,t);if(e.type===p.tag){if(t.tags&&typeof t.tags[e.value]=="function"){let n=mr(r,t);return t.tags[e.value](n)}throw new Error(`${M} tag not supported (${e.value})`)}throw new Error("unsupported")}function lu(r,t){if(!(r instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},Nh,t);let e=t.tokenizer||new lo(r,t),n=mr(e,t);if(n===on)throw new Error(`${M} did not find any content to decode`);if(n===fo)throw new Error(`${M} got unexpected break`);return[n,r.subarray(e.pos())]}function W(r,t){let[e,n]=lu(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=>Y(r),decode:r=>W(r)},fu=Oh;var Fh={type:1027,canEncode:r=>typeof r=="number"&&!isNaN(r),encode:r=>Y(r),decode:r=>W(r)},du=Fh;var Kh={type:1028,canEncode:r=>typeof r=="string",encode:r=>Y(r),decode:r=>W(r)},hu=Kh;var Vh={type:1029,canEncode:r=>Array.isArray(r),encode:(r,t,e,n)=>Y(r.map(o=>t.toValue(o,e,n))),decode:(r,t,e,n)=>W(r).map(o=>t.fromValue(o,e,n))},pu=Vh;var zh={type:1030,canEncode:r=>typeof r=="function",encode:(r,t,e,n)=>{let o=er();return n?.callbacks.set(o,{context:e,fn:r}),Y(o)},decode:(r,t,e,n)=>async(...o)=>new Promise((i,s)=>{let c=W(r),a=er(),l={scope:a,result:wt(),callbacks:new Map,children:new Map,parents:[...n.parents,n.scope],abortControllers:[],abortSignals:[]};n.children.set(a,l),o=o.map(f=>t.toValue(f,null,l));let u=Pn(l.abortSignals);u.addEventListener("abort",()=>{e.push(Ct.encode({type:q.abortCallbackInvocation,message:ur.encode({scope:a,parents:l.parents})}))}),e.push(Ct.encode({type:q.invokeCallback,message:ar.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()})})},mu=zh;var Hh={type:1031,canEncode:r=>r.toString()==="NaN"&&isNaN(r),decode:()=>NaN},gu=Hh;var qh={type:1032,canEncode:r=>r instanceof Error,encode:r=>Y({message:r.message,name:r.name,code:r.code,type:r.type,stack:r.stack}),decode:r=>{let t=W(r),e=new Error(t.message);return e.name=t.name,e.stack=t.stack,e.code=t.code,e.type=t.type,e}},yu=qh;var $h={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")}},bu=$h;var xu=["__defineGetter__","__defineSetter__","hasOwnProperty","__lookupGetter__","__lookupSetter__","isPrototypeOf","propertyIsEnumerable","toString","valueOf","__proto__","toLocaleString","constructor"],Gh={type:2147483647,canEncode:r=>typeof r=="object",encode:(r,t,e,n)=>{let o={};for(let i in r)xu.includes(i)||Object.hasOwn(r,i)&&(o[i]=r[i]);for(let i of Object.getOwnPropertyNames(Object.getPrototypeOf(r)))xu.includes(i)||(o[i]=r[i]);return Y([...Object.entries(o)].map(([i,s])=>[t.toValue(i,r,n),t.toValue(s,r,n)]))},decode:(r,t,e,n)=>{let o={};return W(r).forEach(([s,c])=>{o[t.fromValue(s,e,n)]=t.fromValue(c,e,n)}),o}},sn=Gh;var jh={type:1034,canEncode:r=>typeof r.next=="function"&&typeof r.throw=="function"&&typeof r.return=="function",encode:(r,t,e,n)=>sn.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=sn.decode(r,t,e,n);return o[Symbol.asyncIterator]=()=>o,o}},wu=jh;var Zh={type:1035,canEncode:r=>typeof r=="bigint",encode:r=>Y(r),decode:r=>BigInt(W(r))},Eu=Zh;var Yh={type:1036,canEncode:r=>r instanceof Map,encode:(r,t,e,n)=>Y([...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 W(r).forEach(([s,c])=>{let a=t.fromValue(s,e,n),l=t.fromValue(c,e,n);o.set(a,l)}),o}},vu=Yh;var Wh={type:1037,canEncode:r=>r instanceof Set,encode:(r,t,e,n)=>Y([...r.values()].map(o=>t.toValue(o,e,n))),decode:(r,t,e,n)=>{let o=new Set;return W(r).forEach(s=>{o.add(t.fromValue(s,e,n))}),o}},Su=Wh;var Xh={type:1038,canEncode:r=>r instanceof Uint8Array,encode:r=>r,decode:r=>r},Au=Xh;var Qh={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}},_u=Qh;var Jh={type:1040,canEncode:r=>r instanceof Date,encode:r=>Y(r.toString()),decode:r=>new Date(W(r))},Bu=Jh;var tp={type:1041,canEncode:r=>r instanceof RegExp,encode:r=>Y({source:r.source,flags:r.flags}),decode:r=>{let{source:t,flags:e}=W(r);return new RegExp(t,e)}},Iu=tp;var Cu=[oa,ia,fu,du,hu,pu,mu,gu,yu,bu,wu,Eu,vu,Su,Au,_u,Bu,Iu,sn];var ho=class{transformersMap;transformersList;constructor(t){this.transformersList=[...Cu,...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 Or(`Unsupported value type "${t}"`)}fromValue(t,e,n){let o=this.transformersMap[t.type];if(o==null)throw new Or(`Unsupported value type "${t.type}"`);return o.decode(t.value??new Uint8Array(0),this,e,n)}};function ep(r){return r.isScope===!0}function rp(r){return r.type===q.invokeMethod||r.type===q.invokeGeneratorMethod||r.type===q.invokeCallback}var $i=class{source;output;targets;invocations;values;messageHandlers;constructor(t){this.output=Je(),this.source=Vn(this.output),this.targets=new Map,this.invocations=new Map,this.values=new ho(t),this.sink=this.sink.bind(this),this.messageHandlers={[q.invokeMethod]:{decoder:Fe,handler:this.handleInvokeMethod.bind(this)},[q.invokeGeneratorMethod]:{decoder:Fe,handler:this.handleInvokeGeneratorMethod.bind(this)},[q.abortMethodInvocation]:{decoder:Wr,handler:this.handleAbortMethod.bind(this),isScope:!0},[q.methodResolved]:{decoder:cr,handler:this.handleMethodResolved.bind(this),isScope:!0},[q.methodRejected]:{decoder:Xr,handler:this.handleMethodRejected.bind(this),isScope:!0,isError:!0},[q.invokeCallback]:{decoder:ar,handler:this.handleInvokeCallback.bind(this),isScope:!0},[q.abortCallbackInvocation]:{decoder:ur,handler:this.handleAbortCallback.bind(this),isScope:!0},[q.callbackResolved]:{decoder:Qr,handler:this.handleCallbackResolved.bind(this),isScope:!0},[q.callbackRejected]:{decoder:Jr,handler:this.handleCallbackRejected.bind(this),isScope:!0,isError:!0}}}async sink(t){for await(let e of Mr(t))try{let n=Ct.decode(e),o=this.messageHandlers[n.type];if(o==null)continue;let i=o.decoder.decode(n.message),s;if(ep(o))try{s=na(i,this.invocations)}catch{continue}o.handler(i,s).catch(c=>{rp(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(Ct.encode({type:q.callbackRejected,message:Jr.encode({scope:t.scope,parents:t.parents,error:this.values.toValue(e)})})):this.output.push(Ct.encode({type:q.methodRejected,message:Xr.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 qn(`Cannot reuse RPC target name "${t}"`);this.targets.set(t,e)}async handleInvokeMethod(t){if(this.invocations.has(t.scope))throw new Fr;let e=new Map,n=new Map,o={scope:t.scope,result:wt(),callbacks:e,children:n,parents:[],abortControllers:[],abortSignals:[]};this.invocations.set(t.scope,o);let i=this.lookupInvocationTarget(t.path),s=await i.fn.apply(i.context,t.args.map(c=>this.values.fromValue(c,this.output,o)));this.output.push(Ct.encode({type:q.methodResolved,message:cr.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 Fr;let e=new Map,n=new Map,o={scope:t.scope,result:wt(),callbacks:e,children:n,parents:[],abortControllers:[],abortSignals:[]};this.invocations.set(t.scope,o);let i=this.lookupInvocationTarget(t.path),s=i.fn.apply(i.context,t.args.map(a=>this.values.fromValue(a,this.output,o)));if(typeof s.next!="function")throw new $n(`${t.path} did not return an async generator`);let c={next:async()=>{let a=await s.next();return a.done===!0&&this.invocations.delete(t.scope),a},throw:async a=>{try{let l=await s.throw(a);return l.done===!0&&this.invocations.delete(t.scope),l}catch(l){throw this.invocations.delete(t.scope),l}},return:async a=>{let l=await s.return(a);return l.done===!0&&this.invocations.delete(t.scope),l},[Symbol.asyncIterator]:()=>c};this.output.push(Ct.encode({type:q.methodResolved,message:cr.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 Hn(`"${t.substring(0,t.length-5)}" was not a function`):new zn(`Could not find "${t}" on target`);if(typeof n!="function")throw new Kr("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 jn;let o=await n.fn.apply(n.context,t.args.map(i=>this.values.fromValue(i,this.output,e)));this.output.push(Ct.encode({type:q.callbackResolved,message:Qr.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 b=er(),x={scope:b,result:wt(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(b,x),n.output.push(Ct.encode({type:q.invokeMethod,message:Fe.encode({scope:b,path:t,args:s.map(d=>n.values.toValue(d,null,x))})}));let g=Pn(x.abortSignals);g.addEventListener("abort",()=>{n.output.push(Ct.encode({type:q.abortMethodInvocation,message:Wr.encode({scope:b})}))}),x.result.promise.then(d=>{f(d)},d=>{h(d)}).finally(()=>{n.invocations.delete(b),g.clear()})})),a}function u(){if(c==null){let f=er(),h={scope:f,result:wt(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(f,h),n.output.push(Ct.encode({type:q.invokeGeneratorMethod,message:Fe.encode({scope:f,path:t,args:s.map(x=>n.values.toValue(x,null,h))})}));let b;c={async next(){if(b!=null)throw b;let g=await(await h.result.promise).next();return g.done===!0&&n.invocations.delete(f),g},async throw(x){if(b!=null)throw b;try{let d=await(await h.result.promise).throw(x);return d.done===!0&&n.invocations.delete(f),d}catch(g){throw n.invocations.delete(f),b=x,g}},async return(x){if(b!=null)throw b;let d=await(await h.result.promise).return(x);return d.done===!0&&n.invocations.delete(f),d},[Symbol.asyncIterator]:()=>c}}return c}return new Proxy(e,{get(f,h,b){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 Kr(`Property ${h.toString()} was not used as a promise or async generator`)}})}})}};function ku(r){return new $i(r)}var Tu={type:4096,canEncode:r=>r.code!=null&&r.version!=null&&r.multihash!=null&&r["/"]!=null,encode:r=>r.bytes,decode:r=>ct.decode(r)};var cn=class extends Event{type;detail;constructor(t,e){super(t),this.type=t,this.detail=e}};var Uu={type:4099,canEncode:r=>r instanceof cn,encode:(r,t,e,n)=>Y({type:r.type,detail:t.toValue(r.detail,e,n)}),decode:(r,t,e,n)=>{let{type:o,detail:i}=W(r);return new cn(o,t.fromValue(i,e,n))}};function X(r,t="utf8"){let e=Wn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var po=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 Lu=45,np=15,gr=new po;function Gi(r){if(!(r.length>np))return gr.new(r).parseWith(()=>gr.readIPv4Addr())}function ji(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Lu))return gr.new(r).parseWith(()=>gr.readIPv6Addr())}function mo(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Lu)return;let e=gr.new(r).parseWith(()=>gr.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}var i1=parseInt("0xFFFF",16),s1=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Nu(r){return!!Gi(r)}function Ru(r){return!!ji(r)}function go(r){return!!mo(r)}var Mu=Nu,ap=Ru,Zi=function(r){let t=0;if(r=r.toString().trim(),Mu(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(ap(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=Mu(e[n]),s;i&&(s=Zi(e[n]),e[n]=X(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,X(s.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},Ou=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 yr={},Yi={},lp=[[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"]];lp.forEach(r=>{let t=fp(...r);Yi[t.code]=t,yr[t.name]=t});function fp(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function Q(r){if(typeof r=="number"){if(Yi[r]!=null)return Yi[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(yr[r]!=null)return yr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var H1=Q("ip4"),q1=Q("ip6"),$1=Q("ipcidr");function Ji(r,t){switch(Q(r).code){case 4:case 41:return hp(t);case 42:return Qi(t);case 43:return X(t,"base10");case 6:case 273:case 33:case 132:return Vu(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Qi(t);case 421:return yp(t);case 444:return Ku(t);case 445:return Ku(t);case 466:return gp(t);case 481:return globalThis.encodeURIComponent(Qi(t));default:return X(t,"base16")}}function ts(r,t){switch(Q(r).code){case 4:return Fu(t);case 41:return Fu(t);case 42:return Xi(t);case 43:return qt(t,"base10");case 6:case 273:case 33:case 132:return es(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Xi(t);case 421:return pp(t);case 444:return bp(t);case 445:return xp(t);case 466:return mp(t);case 481:return Xi(globalThis.decodeURIComponent(t));default:return qt(t,"base16")}}var Wi=Object.values(Gr).map(r=>r.decoder),dp=function(){let r=Wi[0].or(Wi[1]);return Wi.slice(2).forEach(t=>r=r.or(t)),r}();function Fu(r){if(!go(r))throw new Error("invalid ip address");return Zi(r)}function hp(r){let t=Ou(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!go(t))throw new Error("invalid ip address");return t}function es(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Vu(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Xi(r){let t=qt(r),e=Uint8Array.from(ve(t.length));return Dt([e,t],e.length+t.length)}function Qi(r){let t=ue(r);if(r=r.slice(dt(t)),r.length!==t)throw new Error("inconsistent lengths");return X(r)}function pp(r){let t;r[0]==="Q"||r[0]==="1"?t=le(tt.decode(`z${r}`)).bytes:t=ct.parse(r).multihash.bytes;let e=Uint8Array.from(ve(t.length));return Dt([e,t],e.length+t.length)}function mp(r){let t=dp.decode(r),e=Uint8Array.from(ve(t.length));return Dt([e,t],e.length+t.length)}function gp(r){let t=ue(r),e=r.slice(dt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+X(e,"base64url")}function yp(r){let t=ue(r),e=r.slice(dt(t));if(e.length!==t)throw new Error("inconsistent lengths");return X(e,"base58btc")}function bp(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=jt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=es(n);return Dt([e,o],e.length+o.length)}function xp(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=jt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=es(n);return Dt([e,o],e.length+o.length)}function Ku(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=X(t,"base32"),o=Vu(e);return`${n}:${o}`}function zu(r){r=rs(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],c=Q(s);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(i++,i>=o.length)throw new yo("invalid address: "+r);if(c.path===!0){n=rs(o.slice(i).join("/")),t.push([c.code,ts(c.code,n)]),e.push([c.code,n]);break}let a=ts(c.code,o[i]);t.push([c.code,a]),e.push([c.code,Ji(c.code,a)])}return{string:Hu(e),bytes:bo(t),tuples:t,stringTuples:e,path:n}}function ns(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=ue(r,o),s=dt(i),c=Q(i),a=wp(c,r.slice(o+s));if(a===0){t.push([i]),e.push([i]),o+=s;continue}let l=r.slice(o+s,o+s+a);if(o+=a+s,o>r.length)throw new yo("Invalid address Uint8Array: "+X(r,"base16"));t.push([i,l]);let u=Ji(i,l);if(e.push([i,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Hu(e),tuples:t,stringTuples:e,path:n}}function Hu(r){let t=[];return r.map(e=>{let n=Q(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),rs(t.join("/"))}function bo(r){return Dt(r.map(t=>{let e=Q(t[0]),n=Uint8Array.from(ve(e.code));return t.length>1&&t[1]!=null&&(n=Dt([n,t[1]])),n}))}function wp(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=ue(t instanceof Uint8Array?t:Uint8Array.from(t));return e+dt(e)}}function rs(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var yo=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Ep=Symbol.for("nodejs.util.inspect.custom"),is=Symbol.for("@multiformats/js-multiaddr/multiaddr"),vp=[Q("dns").code,Q("dns4").code,Q("dns6").code,Q("dnsaddr").code],os=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},xo=class r{bytes;#e;#t;#r;#n;[is]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=ns(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=zu(t)}else if(wo(t))e=ns(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",s=Q("tcp"),c=Q("udp"),a=Q("ip4"),l=Q("ip6"),u=Q("dns6"),f=Q("ip6zone");for(let[b,x]of this.stringTuples())b===f.code&&(i=`%${x??""}`),vp.includes(b)&&(e=s.name==="tcp"?"tcp":"udp",o=443,n=`${x??""}${i}`,t=b===u.code?6:4),(b===s.code||b===c.code)&&(e=Q(b).name==="tcp"?"tcp":"udp",o=parseInt(x??"")),(b===a.code||b===l.code)&&(e=Q(b).name==="tcp"?"tcp":"udp",n=`${x??""}${i}`,t=b===l.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#t.map(([t])=>Object.assign({},Q(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>Q(t).name)}tuples(){return this.#t.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(bo(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===yr.p2p.code&&t.push([n,o]),n===yr["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?X(tt.decode(`z${n}`),"base58btc"):X(ct.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Nt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=qu.get(e.name);if(n==null)throw new os(`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)}[Ep](){return`Multiaddr(${this.#e})`}};var qu=new Map;function wo(r){return!!r?.[is]}function Ve(r){return new xo(r)}var $u={type:4097,canEncode:r=>wo(r),encode:r=>r.bytes,decode:r=>Ve(r)};var Sp=parseInt("11111",2),ss=parseInt("10000000",2),Ap=parseInt("01111111",2),Gu={0:an,1:an,2:_p,3:Cp,4:kp,5:Ip,6:Bp,16:an,22:an,48:an};function cs(r,t={offset:0}){let e=r[t.offset]&Sp;if(t.offset++,Gu[e]!=null)return Gu[e](r,t);throw new Error("No decoder for tag "+e)}function un(r,t){let e=0;if((r[t.offset]&ss)===ss){let n=r[t.offset]&Ap,o="0x";t.offset++;for(let i=0;i<n;i++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function an(r,t){un(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=cs(r,t);if(n===null)break;e.push(n)}return e}function _p(r,t){let e=un(r,t),n=t.offset,o=t.offset+e,i=[];for(let s=n;s<o;s++)s===n&&r[s]===0||i.push(r[s]);return t.offset+=e,Uint8Array.from(i)}function Bp(r,t){let e=un(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let c=`${i}.${s}`,a=[];for(;t.offset<n;){let l=r[t.offset];if(t.offset++,a.push(l&127),l<128){a.reverse();let u=0;for(let f=0;f<a.length;f++)u+=a[f]<<f*7;c+=`.${u}`,a=[]}}return c}function Ip(r,t){return t.offset++,null}function Cp(r,t){let e=un(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function kp(r,t){let e=un(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Tp(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new gt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function as(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Tp(r.byteLength);return new gt(Uint8Array.from([t.byteLength|ss]),t)}function ju(r){let t=new gt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new gt(Uint8Array.from([2]),as(t),t)}function Zu(r){let t=Uint8Array.from([0]),e=new gt(t,r);return new gt(Uint8Array.from([3]),as(e),e)}function Eo(r,t=48){let e=new gt;for(let n of r)e.append(n);return new gt(Uint8Array.from([t]),as(e),e)}async function Yu(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var Up=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Lp=Uint8Array.from([6,5,43,129,4,0,34]),Pp=Uint8Array.from([6,5,43,129,4,0,35]),Dp={ext:!0,kty:"EC",crv:"P-256"},Np={ext:!0,kty:"EC",crv:"P-384"},Rp={ext:!0,kty:"EC",crv:"P-521"},us=32,ls=48,fs=66;function Wu(r){let t=cs(r);return Xu(t)}function Xu(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===us*2+1)return n=X(t.subarray(e,e+us),"base64url"),o=X(t.subarray(e+us),"base64url"),new br({...Dp,key_ops:["verify"],x:n,y:o});if(t.byteLength===ls*2+1)return n=X(t.subarray(e,e+ls),"base64url"),o=X(t.subarray(e+ls),"base64url"),new br({...Np,key_ops:["verify"],x:n,y:o});if(t.byteLength===fs*2+1)return n=X(t.subarray(e,e+fs),"base64url"),o=X(t.subarray(e+fs),"base64url"),new br({...Rp,key_ops:["verify"],x:n,y:o});throw new zt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Qu(r){return Eo([ju(Uint8Array.from([1])),Eo([Mp(r.crv)],160),Eo([Zu(new gt(Uint8Array.from([4]),qt(r.x??"","base64url"),qt(r.y??"","base64url")))],161)]).subarray()}function Mp(r){if(r==="P-256")return Up;if(r==="P-384")return Lp;if(r==="P-521")return Pp;throw new zt(`Invalid curve ${r}`)}var br=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Qu(this.jwk)),this._raw}toMultihash(){return Xt.digest(xr(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return tt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Nt(this.raw,t.raw)}async verify(t,e){return Yu(this.jwk,e,t)}};function Ju(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Op(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function wr(r,...t){if(!Op(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function tl(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ju(r.outputLen),Ju(r.blockLen)}function Er(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 el(r,t){wr(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var ze=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function vo(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function te(r,t){return r<<32-t|r>>>t}function rl(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function ln(r){return typeof r=="string"&&(r=rl(r)),wr(r),r}function ds(...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}var vr=class{clone(){return this._cloneInto()}};function So(r){let t=n=>r().update(ln(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Ao(r=32){if(ze&&typeof ze.getRandomValues=="function")return ze.getRandomValues(new Uint8Array(r));if(ze&&typeof ze.randomBytes=="function")return ze.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Fp(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(e>>o&i),c=Number(e&i),a=n?4:0,l=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+l,c,n)}function nl(r,t,e){return r&t^~r&e}function ol(r,t,e){return r&t^r&e^t&e}var Sr=class extends vr{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=vo(this.buffer)}update(t){Er(this);let{view:e,buffer:n,blockLen:o}=this;t=ln(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=vo(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){Er(this),el(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;Fp(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=vo(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 _o=BigInt(4294967295),hs=BigInt(32);function il(r,t=!1){return t?{h:Number(r&_o),l:Number(r>>hs&_o)}:{h:Number(r>>hs&_o)|0,l:Number(r&_o)|0}}function Kp(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}=il(r[o],t);[e[o],n[o]]=[i,s]}return[e,n]}var Vp=(r,t)=>BigInt(r>>>0)<<hs|BigInt(t>>>0),zp=(r,t,e)=>r>>>e,Hp=(r,t,e)=>r<<32-e|t>>>e,qp=(r,t,e)=>r>>>e|t<<32-e,$p=(r,t,e)=>r<<32-e|t>>>e,Gp=(r,t,e)=>r<<64-e|t>>>e-32,jp=(r,t,e)=>r>>>e-32|t<<64-e,Zp=(r,t)=>t,Yp=(r,t)=>r,Wp=(r,t,e)=>r<<e|t>>>32-e,Xp=(r,t,e)=>t<<e|r>>>32-e,Qp=(r,t,e)=>t<<e-32|r>>>64-e,Jp=(r,t,e)=>r<<e-32|t>>>64-e;function t0(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var e0=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),r0=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,n0=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),o0=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,i0=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),s0=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var c0={fromBig:il,split:Kp,toBig:Vp,shrSH:zp,shrSL:Hp,rotrSH:qp,rotrSL:$p,rotrBH:Gp,rotrBL:jp,rotr32H:Zp,rotr32L:Yp,rotlSH:Wp,rotlSL:Xp,rotlBH:Qp,rotlBL:Jp,add:t0,add3L:e0,add3H:r0,add4L:n0,add4H:o0,add5H:s0,add5L:i0},F=c0;var[a0,u0]=F.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))),Ie=new Uint32Array(80),Ce=new Uint32Array(80),ps=class extends Sr{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:b,Gl:x,Hh:g,Hl:d}=this;return[t,e,n,o,i,s,c,a,l,u,f,h,b,x,g,d]}set(t,e,n,o,i,s,c,a,l,u,f,h,b,x,g,d){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=h|0,this.Gh=b|0,this.Gl=x|0,this.Hh=g|0,this.Hl=d|0}process(t,e){for(let m=0;m<16;m++,e+=4)Ie[m]=t.getUint32(e),Ce[m]=t.getUint32(e+=4);for(let m=16;m<80;m++){let B=Ie[m-15]|0,D=Ce[m-15]|0,P=F.rotrSH(B,D,1)^F.rotrSH(B,D,8)^F.shrSH(B,D,7),k=F.rotrSL(B,D,1)^F.rotrSL(B,D,8)^F.shrSL(B,D,7),U=Ie[m-2]|0,T=Ce[m-2]|0,et=F.rotrSH(U,T,19)^F.rotrBH(U,T,61)^F.shrSH(U,T,6),H=F.rotrSL(U,T,19)^F.rotrBL(U,T,61)^F.shrSL(U,T,6),V=F.add4L(k,H,Ce[m-7],Ce[m-16]),at=F.add4H(V,P,et,Ie[m-7],Ie[m-16]);Ie[m]=at|0,Ce[m]=V|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:h,Fh:b,Fl:x,Gh:g,Gl:d,Hh:E,Hl:A}=this;for(let m=0;m<80;m++){let B=F.rotrSH(f,h,14)^F.rotrSH(f,h,18)^F.rotrBH(f,h,41),D=F.rotrSL(f,h,14)^F.rotrSL(f,h,18)^F.rotrBL(f,h,41),P=f&b^~f&g,k=h&x^~h&d,U=F.add5L(A,D,k,u0[m],Ce[m]),T=F.add5H(U,E,B,P,a0[m],Ie[m]),et=U|0,H=F.rotrSH(n,o,28)^F.rotrBH(n,o,34)^F.rotrBH(n,o,39),V=F.rotrSL(n,o,28)^F.rotrBL(n,o,34)^F.rotrBL(n,o,39),at=n&i^n&c^i&c,_=o&s^o&a^s&a;E=g|0,A=d|0,g=b|0,d=x|0,b=f|0,x=h|0,{h:f,l:h}=F.add(l|0,u|0,T|0,et|0),l=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let L=F.add3L(et,V,_);n=F.add3H(L,T,H,at),o=L|0}({h:n,l:o}=F.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=F.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=F.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=F.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=F.add(this.Eh|0,this.El|0,f|0,h|0),{h:b,l:x}=F.add(this.Fh|0,this.Fl|0,b|0,x|0),{h:g,l:d}=F.add(this.Gh|0,this.Gl|0,g|0,d|0),{h:E,l:A}=F.add(this.Hh|0,this.Hl|0,E|0,A|0),this.set(n,o,i,s,c,a,l,u,f,h,b,x,g,d,E,A)}roundClean(){Ie.fill(0),Ce.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 sl=So(()=>new ps);var Co={};Tt(Co,{aInRange:()=>Lt,abool:()=>ee,abytes:()=>Ar,bitGet:()=>m0,bitLen:()=>bs,bitMask:()=>dn,bitSet:()=>g0,bytesToHex:()=>pe,bytesToNumberBE:()=>me,bytesToNumberLE:()=>Te,concatBytes:()=>ge,createHmacDrbg:()=>xs,ensureBytes:()=>it,equalBytes:()=>h0,hexToBytes:()=>qe,hexToNumber:()=>ys,inRange:()=>fn,isBytes:()=>ke,memoized:()=>Ge,notImplemented:()=>b0,numberToBytesBE:()=>Ue,numberToBytesLE:()=>$e,numberToHexUnpadded:()=>He,numberToVarBytesBE:()=>d0,utf8ToBytes:()=>p0,validateObject:()=>se});var Bo=BigInt(0),Io=BigInt(1),l0=BigInt(2);function ke(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ar(r){if(!ke(r))throw new Error("Uint8Array expected")}function ee(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var f0=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function pe(r){Ar(r);let t="";for(let e=0;e<r.length;e++)t+=f0[r[e]];return t}function He(r){let t=r.toString(16);return t.length&1?"0"+t:t}function ys(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Bo:BigInt("0x"+r)}var he={_0:48,_9:57,A:65,F:70,a:97,f:102};function cl(r){if(r>=he._0&&r<=he._9)return r-he._0;if(r>=he.A&&r<=he.F)return r-(he.A-10);if(r>=he.a&&r<=he.f)return r-(he.a-10)}function qe(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("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=cl(r.charCodeAt(i)),c=cl(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 me(r){return ys(pe(r))}function Te(r){return Ar(r),ys(pe(Uint8Array.from(r).reverse()))}function Ue(r,t){return qe(r.toString(16).padStart(t*2,"0"))}function $e(r,t){return Ue(r,t).reverse()}function d0(r){return qe(He(r))}function it(r,t,e){let n;if(typeof t=="string")try{n=qe(t)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(ke(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function ge(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Ar(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 h0(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 p0(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var ms=r=>typeof r=="bigint"&&Bo<=r;function fn(r,t,e){return ms(r)&&ms(t)&&ms(e)&&t<=r&&r<e}function Lt(r,t,e,n){if(!fn(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function bs(r){let t;for(t=0;r>Bo;r>>=Io,t+=1);return t}function m0(r,t){return r>>BigInt(t)&Io}function g0(r,t,e){return r|(e?Io:Bo)<<BigInt(t)}var dn=r=>(l0<<BigInt(r-1))-Io,gs=r=>new Uint8Array(r),al=r=>Uint8Array.from(r);function xs(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=gs(r),o=gs(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},c=(...f)=>e(o,n,...f),a=(f=gs())=>{o=c(al([0]),f),n=c(),f.length!==0&&(o=c(al([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 b=n.slice();h.push(b),f+=n.length}return ge(...h)};return(f,h)=>{s(),a(f);let b;for(;!(b=h(l()));)a();return s(),b}}var y0={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"||ke(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 se(r,t,e={}){let n=(o,i,s)=>{let c=y0[i];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(s&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+a)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}var b0=()=>{throw new Error("not implemented")};function Ge(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 ut=BigInt(0),nt=BigInt(1),je=BigInt(2),x0=BigInt(3),ws=BigInt(4),ul=BigInt(5),ll=BigInt(8),w0=BigInt(9),E0=BigInt(16);function Z(r,t){let e=r%t;return e>=ut?e:t+e}function v0(r,t,e){if(t<ut)throw new Error("invalid exponent, negatives unsupported");if(e<=ut)throw new Error("invalid modulus");if(e===nt)return ut;let n=nt;for(;t>ut;)t&nt&&(n=n*r%e),r=r*r%e,t>>=nt;return n}function ot(r,t,e){let n=r;for(;t-- >ut;)n*=n,n%=e;return n}function ko(r,t){if(r===ut)throw new Error("invert: expected non-zero number");if(t<=ut)throw new Error("invert: expected positive modulus, got "+t);let e=Z(r,t),n=t,o=ut,i=nt,s=nt,c=ut;for(;e!==ut;){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!==nt)throw new Error("invert: does not exist");return Z(o,t)}function S0(r){let t=(r-nt)/je,e,n,o;for(e=r-nt,n=0;e%je===ut;e/=je,n++);for(o=je;o<r&&v0(o,t,r)!==r-nt;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(r+nt)/ws;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+nt)/je;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 b=1;for(let g=c.sqr(h);b<l&&!c.eql(g,c.ONE);b++)g=c.sqr(g);let x=c.pow(u,nt<<BigInt(l-b-1));u=c.sqr(x),f=c.mul(f,x),h=c.mul(h,u),l=b}return f}}function A0(r){if(r%ws===x0){let t=(r+nt)/ws;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%ll===ul){let t=(r-ul)/ll;return function(n,o){let i=n.mul(o,je),s=n.pow(i,t),c=n.mul(o,s),a=n.mul(n.mul(c,je),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%E0,S0(r)}var fl=(r,t)=>(Z(r,t)&nt)===nt,_0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Es(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=_0.reduce((n,o)=>(n[o]="function",n),t);return se(r,e)}function B0(r,t,e){if(e<ut)throw new Error("invalid exponent, negatives unsupported");if(e===ut)return r.ONE;if(e===nt)return t;let n=r.ONE,o=t;for(;e>ut;)e&nt&&(n=r.mul(n,o)),o=r.sqr(o),e>>=nt;return n}function I0(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 vs(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Le(r,t,e=!1,n={}){if(r<=ut)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:i}=vs(r,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:i,MASK:dn(o),ZERO:ut,ONE:nt,create:a=>Z(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return ut<=a&&a<r},is0:a=>a===ut,isOdd:a=>(a&nt)===nt,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)=>B0(c,a,l),div:(a,l)=>Z(a*ko(l,r),r),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>ko(a,r),sqrt:n.sqrt||(a=>(s||(s=A0(r)),s(c,a))),invertBatch:a=>I0(c,a),cmov:(a,l,u)=>u?l:a,toBytes:a=>e?$e(a,i):Ue(a,i),fromBytes:a=>{if(a.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+a.length);return e?Te(a):me(a)}});return Object.freeze(c)}function dl(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=dl(r);return t+Math.ceil(t/2)}function hl(r,t,e=!1){let n=r.length,o=dl(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?Te(r):me(r),c=Z(s,t-nt)+nt;return e?$e(c,o):Ue(c,o)}var pl=BigInt(0),To=BigInt(1);function As(r,t){let e=t.negate();return r?e:t}function ml(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function _s(r,t){ml(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function C0(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function k0(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Bs=new WeakMap,gl=new WeakMap;function Is(r){return gl.get(r)||1}function Uo(r,t){return{constTimeNegate:As,hasPrecomputes(e){return Is(e)!==1},unsafeLadder(e,n,o=r.ZERO){let i=e;for(;n>pl;)n&To&&(o=o.add(i)),i=i.double(),n>>=To;return o},precomputeWindow(e,n){let{windows:o,windowSize:i}=_s(n,t),s=[],c=e,a=c;for(let l=0;l<o;l++){a=c,s.push(a);for(let u=1;u<i;u++)a=a.add(c),s.push(a);c=a.double()}return s},wNAF(e,n,o){let{windows:i,windowSize:s}=_s(e,t),c=r.ZERO,a=r.BASE,l=BigInt(2**e-1),u=2**e,f=BigInt(e);for(let h=0;h<i;h++){let b=h*s,x=Number(o&l);o>>=f,x>s&&(x-=u,o+=To);let g=b,d=b+Math.abs(x)-1,E=h%2!==0,A=x<0;x===0?a=a.add(As(E,n[g])):c=c.add(As(A,n[d]))}return{p:c,f:a}},wNAFUnsafe(e,n,o,i=r.ZERO){let{windows:s,windowSize:c}=_s(e,t),a=BigInt(2**e-1),l=2**e,u=BigInt(e);for(let f=0;f<s;f++){let h=f*c;if(o===pl)break;let b=Number(o&a);if(o>>=u,b>c&&(b-=l,o+=To),b===0)continue;let x=n[h+Math.abs(b)-1];b<0&&(x=x.negate()),i=i.add(x)}return i},getPrecomputes(e,n,o){let i=Bs.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&Bs.set(n,o(i))),i},wNAFCached(e,n,o){let i=Is(e);return this.wNAF(i,this.getPrecomputes(i,e,o),n)},wNAFCachedUnsafe(e,n,o,i){let s=Is(e);return s===1?this.unsafeLadder(e,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,o),n,i)},setWindowSize(e,n){ml(n,t),gl.set(e,n),Bs.delete(e)}}}function Lo(r,t,e,n){if(C0(e,r),k0(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,i=bs(BigInt(e.length)),s=i>12?i-3:i>4?i-2:i?2:1,c=(1<<s)-1,a=new Array(c+1).fill(o),l=Math.floor((t.BITS-1)/s)*s,u=o;for(let f=l;f>=0;f-=s){a.fill(o);for(let b=0;b<n.length;b++){let x=n[b],g=Number(x>>BigInt(f)&BigInt(c));a[g]=a[g].add(e[b])}let h=o;for(let b=a.length-1,x=o;b>0;b--)x=x.add(a[b]),h=h.add(x);if(u=u.add(h),f!==0)for(let b=0;b<s;b++)u=u.double()}return u}function hn(r){return Es(r.Fp),se(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...vs(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var re=BigInt(0),Pt=BigInt(1),Po=BigInt(2),T0=BigInt(8),U0={zip215:!0};function L0(r){let t=hn(r);return se(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function yl(r){let t=L0(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,l=Po<<BigInt(c*8)-Pt,u=e.create,f=Le(t.n,t.nBitLength),h=t.uvRatio||((w,y)=>{try{return{isValid:!0,value:e.sqrt(w*e.inv(y))}}catch{return{isValid:!1,value:re}}}),b=t.adjustScalarBytes||(w=>w),x=t.domain||((w,y,v)=>{if(ee("phflag",v),y.length||v)throw new Error("Contexts/pre-hash are not supported");return w});function g(w,y){Lt("coordinate "+w,y,re,l)}function d(w){if(!(w instanceof m))throw new Error("ExtendedPoint expected")}let E=Ge((w,y)=>{let{ex:v,ey:C,ez:N}=w,R=w.is0();y==null&&(y=R?T0:e.inv(N));let K=u(v*y),z=u(C*y),O=u(N*y);if(R)return{x:re,y:Pt};if(O!==Pt)throw new Error("invZ was invalid");return{x:K,y:z}}),A=Ge(w=>{let{a:y,d:v}=t;if(w.is0())throw new Error("bad point: ZERO");let{ex:C,ey:N,ez:R,et:K}=w,z=u(C*C),O=u(N*N),j=u(R*R),J=u(j*j),lt=u(z*y),ft=u(j*u(lt+O)),mt=u(J+u(v*u(z*O)));if(ft!==mt)throw new Error("bad point: equation left != right (1)");let bt=u(C*N),kt=u(R*K);if(bt!==kt)throw new Error("bad point: equation left != right (2)");return!0});class m{constructor(y,v,C,N){this.ex=y,this.ey=v,this.ez=C,this.et=N,g("x",y),g("y",v),g("z",C),g("t",N),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(y){if(y instanceof m)throw new Error("extended point not allowed");let{x:v,y:C}=y||{};return g("x",v),g("y",C),new m(v,C,Pt,u(v*C))}static normalizeZ(y){let v=e.invertBatch(y.map(C=>C.ez));return y.map((C,N)=>C.toAffine(v[N])).map(m.fromAffine)}static msm(y,v){return Lo(m,f,y,v)}_setWindowSize(y){P.setWindowSize(this,y)}assertValidity(){A(this)}equals(y){d(y);let{ex:v,ey:C,ez:N}=this,{ex:R,ey:K,ez:z}=y,O=u(v*z),j=u(R*N),J=u(C*z),lt=u(K*N);return O===j&&J===lt}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:y}=t,{ex:v,ey:C,ez:N}=this,R=u(v*v),K=u(C*C),z=u(Po*u(N*N)),O=u(y*R),j=v+C,J=u(u(j*j)-R-K),lt=O+K,ft=lt-z,mt=O-K,bt=u(J*ft),kt=u(lt*mt),At=u(J*mt),ne=u(ft*lt);return new m(bt,kt,ne,At)}add(y){d(y);let{a:v,d:C}=t,{ex:N,ey:R,ez:K,et:z}=this,{ex:O,ey:j,ez:J,et:lt}=y;if(v===BigInt(-1)){let Ks=u((R-N)*(j+O)),Vs=u((R+N)*(j-O)),$o=u(Vs-Ks);if($o===re)return this.double();let zs=u(K*Po*lt),Hs=u(z*Po*J),qs=Hs+zs,$s=Vs+Ks,Gs=Hs-zs,Xl=u(qs*$o),Ql=u($s*Gs),Jl=u(qs*Gs),tf=u($o*$s);return new m(Xl,Ql,tf,Jl)}let ft=u(N*O),mt=u(R*j),bt=u(z*C*lt),kt=u(K*J),At=u((N+R)*(O+j)-ft-mt),ne=kt-bt,ce=kt+bt,Ir=u(mt-v*ft),jl=u(At*ne),Zl=u(ce*Ir),Yl=u(At*Ir),Wl=u(ne*ce);return new m(jl,Zl,Wl,Yl)}subtract(y){return this.add(y.negate())}wNAF(y){return P.wNAFCached(this,y,m.normalizeZ)}multiply(y){let v=y;Lt("scalar",v,Pt,n);let{p:C,f:N}=this.wNAF(v);return m.normalizeZ([C,N])[0]}multiplyUnsafe(y,v=m.ZERO){let C=y;return Lt("scalar",C,re,n),C===re?D:this.is0()||C===Pt?this:P.wNAFCachedUnsafe(this,C,m.normalizeZ,v)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return P.unsafeLadder(this,n).is0()}toAffine(y){return E(this,y)}clearCofactor(){let{h:y}=t;return y===Pt?this:this.multiplyUnsafe(y)}static fromHex(y,v=!1){let{d:C,a:N}=t,R=e.BYTES;y=it("pointHex",y,R),ee("zip215",v);let K=y.slice(),z=y[R-1];K[R-1]=z&-129;let O=Te(K),j=v?l:e.ORDER;Lt("pointHex.y",O,re,j);let J=u(O*O),lt=u(J-Pt),ft=u(C*J-N),{isValid:mt,value:bt}=h(lt,ft);if(!mt)throw new Error("Point.fromHex: invalid y coordinate");let kt=(bt&Pt)===Pt,At=(z&128)!==0;if(!v&&bt===re&&At)throw new Error("Point.fromHex: x=0 and x_0=1");return At!==kt&&(bt=u(-bt)),m.fromAffine({x:bt,y:O})}static fromPrivateKey(y){return T(y).point}toRawBytes(){let{x:y,y:v}=this.toAffine(),C=$e(v,e.BYTES);return C[C.length-1]|=y&Pt?128:0,C}toHex(){return pe(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,Pt,u(t.Gx*t.Gy)),m.ZERO=new m(re,Pt,Pt,re);let{BASE:B,ZERO:D}=m,P=Uo(m,c*8);function k(w){return Z(w,n)}function U(w){return k(Te(w))}function T(w){let y=e.BYTES;w=it("private key",w,y);let v=it("hashed private key",i(w),2*y),C=b(v.slice(0,y)),N=v.slice(y,2*y),R=U(C),K=B.multiply(R),z=K.toRawBytes();return{head:C,prefix:N,scalar:R,point:K,pointBytes:z}}function et(w){return T(w).pointBytes}function H(w=new Uint8Array,...y){let v=ge(...y);return U(i(x(v,it("context",w),!!o)))}function V(w,y,v={}){w=it("message",w),o&&(w=o(w));let{prefix:C,scalar:N,pointBytes:R}=T(y),K=H(v.context,C,w),z=B.multiply(K).toRawBytes(),O=H(v.context,z,R,w),j=k(K+O*N);Lt("signature.s",j,re,n);let J=ge(z,$e(j,e.BYTES));return it("result",J,e.BYTES*2)}let at=U0;function _(w,y,v,C=at){let{context:N,zip215:R}=C,K=e.BYTES;w=it("signature",w,2*K),y=it("message",y),v=it("publicKey",v,K),R!==void 0&&ee("zip215",R),o&&(y=o(y));let z=Te(w.slice(K,2*K)),O,j,J;try{O=m.fromHex(v,R),j=m.fromHex(w.slice(0,K),R),J=B.multiplyUnsafe(z)}catch{return!1}if(!R&&O.isSmallOrder())return!1;let lt=H(N,j.toRawBytes(),O.toRawBytes(),y);return j.add(O.multiplyUnsafe(lt)).subtract(J).clearCofactor().equals(m.ZERO)}return B._setWindowSize(8),{CURVE:t,getPublicKey:et,sign:V,verify:_,ExtendedPoint:m,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>s(e.BYTES),precompute(w=8,y=m.BASE){return y._setWindowSize(w),y.multiply(BigInt(3)),y}}}}var Cs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),bl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),pE=BigInt(0),P0=BigInt(1),xl=BigInt(2),mE=BigInt(3),D0=BigInt(5),N0=BigInt(8);function R0(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=Cs,c=r*r%i*r%i,a=ot(c,xl,i)*c%i,l=ot(a,P0,i)*r%i,u=ot(l,D0,i)*l%i,f=ot(u,t,i)*u%i,h=ot(f,e,i)*f%i,b=ot(h,n,i)*h%i,x=ot(b,o,i)*b%i,g=ot(x,o,i)*b%i,d=ot(g,t,i)*u%i;return{pow_p_5_8:ot(d,xl,i)*r%i,b2:c}}function M0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function O0(r,t){let e=Cs,n=Z(t*t*t,e),o=Z(n*n*t,e),i=R0(r*o).pow_p_5_8,s=Z(r*n*i,e),c=Z(t*s*s,e),a=s,l=Z(s*bl,e),u=c===r,f=c===Z(-r,e),h=c===Z(-r*bl,e);return u&&(s=a),(f||h)&&(s=l),fl(s,e)&&(s=Z(-s,e)),{isValid:u||f,value:s}}var F0=Le(Cs,void 0,!0),K0={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:F0,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:N0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sl,randomBytes:Ao,adjustScalarBytes:M0,uvRatio:O0},wl=yl(K0);var Do=32;function El(r,t,e){return wl.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var No=class{type="Ed25519";raw;constructor(t){this.raw=ks(t,Do)}toMultihash(){return Xt.digest(xr(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return tt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Nt(this.raw,t.raw)}verify(t,e){return El(this.raw,e,t)}};function Sl(r){return r=ks(r,Do),new No(r)}function ks(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new zt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Vt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(Vt||(Vt={}));var Ts;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Ts||(Ts={}));(function(r){r.codec=()=>Yr(Ts)})(Vt||(Vt={}));var pn;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Vt.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=Vt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>Bt(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(pn||(pn={}));var Us;(function(r){let t;r.codec=()=>(t==null&&(t=It((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Vt.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=Vt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>Bt(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Us||(Us={}));var mn=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var H0=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]),Pe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),De=new Uint32Array(64),Ls=class extends Sr{constructor(){super(64,32,8,!1),this.A=Pe[0]|0,this.B=Pe[1]|0,this.C=Pe[2]|0,this.D=Pe[3]|0,this.E=Pe[4]|0,this.F=Pe[5]|0,this.G=Pe[6]|0,this.H=Pe[7]|0}get(){let{A:t,B:e,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[t,e,n,o,i,s,c,a]}set(t,e,n,o,i,s,c,a){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,e){for(let f=0;f<16;f++,e+=4)De[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let h=De[f-15],b=De[f-2],x=te(h,7)^te(h,18)^h>>>3,g=te(b,17)^te(b,19)^b>>>10;De[f]=g+De[f-7]+x+De[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=te(c,6)^te(c,11)^te(c,25),b=u+h+nl(c,a,l)+H0[f]+De[f]|0,g=(te(n,2)^te(n,13)^te(n,22))+ol(n,o,i)|0;u=l,l=a,a=c,c=s+b|0,s=i,i=o,o=n,n=b+g|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,l,u)}roundClean(){De.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Al=So(()=>new Ls);var Ro=class extends vr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,tl(t);let n=ln(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 Er(this),this.iHash.update(t),this}digestInto(t){Er(this),wr(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 Ro(r,t).update(e).digest();Ps.create=(r,t)=>new Ro(r,t);function _l(r){r.lowS!==void 0&&ee("lowS",r.lowS),r.prehash!==void 0&&ee("prehash",r.prehash)}function q0(r){let t=hn(r);se(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:$0,hexToBytes:G0}=Co,Ds=class extends Error{constructor(t=""){super(t)}},ye={Err:Ds,_tlv:{encode:(r,t)=>{let{Err:e}=ye;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=He(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?He(o.length/2|128):"";return He(r)+i+o+t},decode(r,t){let{Err:e}=ye,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}=ye;if(r<be)throw new t("integer: negative integers are not allowed");let e=He(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=ye;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 $0(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=ye,o=typeof r=="string"?G0(r):r;Ar(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}=ye,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),i=n+o;return t.encode(48,i)}},be=BigInt(0),pt=BigInt(1),qE=BigInt(2),Bl=BigInt(3),$E=BigInt(4);function j0(r){let t=q0(r),{Fp:e}=t,n=Le(t.n,t.nBitLength),o=t.toBytes||((g,d,E)=>{let A=d.toAffine();return ge(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),i=t.fromBytes||(g=>{let d=g.subarray(1),E=e.fromBytes(d.subarray(0,e.BYTES)),A=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:E,y:A}});function s(g){let{a:d,b:E}=t,A=e.sqr(g),m=e.mul(A,g);return e.add(e.add(m,e.mul(g,d)),E)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function c(g){return fn(g,pt,t.n)}function a(g){let{allowedPrivateKeyLengths:d,nByteLength:E,wrapPrivateKey:A,n:m}=t;if(d&&typeof g!="bigint"){if(ke(g)&&(g=pe(g)),typeof g!="string"||!d.includes(g.length))throw new Error("invalid private key");g=g.padStart(E*2,"0")}let B;try{B=typeof g=="bigint"?g:me(it("private key",g,E))}catch{throw new Error("invalid private key, expected hex or "+E+" bytes, got "+typeof g)}return A&&(B=Z(B,m)),Lt("private key",B,pt,m),B}function l(g){if(!(g instanceof h))throw new Error("ProjectivePoint expected")}let u=Ge((g,d)=>{let{px:E,py:A,pz:m}=g;if(e.eql(m,e.ONE))return{x:E,y:A};let B=g.is0();d==null&&(d=B?e.ONE:e.inv(m));let D=e.mul(E,d),P=e.mul(A,d),k=e.mul(m,d);if(B)return{x:e.ZERO,y:e.ZERO};if(!e.eql(k,e.ONE))throw new Error("invZ was invalid");return{x:D,y:P}}),f=Ge(g=>{if(g.is0()){if(t.allowInfinityPoint&&!e.is0(g.py))return;throw new Error("bad point: ZERO")}let{x:d,y:E}=g.toAffine();if(!e.isValid(d)||!e.isValid(E))throw new Error("bad point: x or y not FE");let A=e.sqr(E),m=s(d);if(!e.eql(A,m))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,E,A){if(this.px=d,this.py=E,this.pz=A,d==null||!e.isValid(d))throw new Error("x required");if(E==null||!e.isValid(E))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:E,y:A}=d||{};if(!d||!e.isValid(E)||!e.isValid(A))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let m=B=>e.eql(B,e.ZERO);return m(E)&&m(A)?h.ZERO:new h(E,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let E=e.invertBatch(d.map(A=>A.pz));return d.map((A,m)=>A.toAffine(E[m])).map(h.fromAffine)}static fromHex(d){let E=h.fromAffine(i(it("pointHex",d)));return E.assertValidity(),E}static fromPrivateKey(d){return h.BASE.multiply(a(d))}static msm(d,E){return Lo(h,n,d,E)}_setWindowSize(d){x.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:E,py:A,pz:m}=this,{px:B,py:D,pz:P}=d,k=e.eql(e.mul(E,P),e.mul(B,m)),U=e.eql(e.mul(A,P),e.mul(D,m));return k&&U}negate(){return new h(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:E}=t,A=e.mul(E,Bl),{px:m,py:B,pz:D}=this,P=e.ZERO,k=e.ZERO,U=e.ZERO,T=e.mul(m,m),et=e.mul(B,B),H=e.mul(D,D),V=e.mul(m,B);return V=e.add(V,V),U=e.mul(m,D),U=e.add(U,U),P=e.mul(d,U),k=e.mul(A,H),k=e.add(P,k),P=e.sub(et,k),k=e.add(et,k),k=e.mul(P,k),P=e.mul(V,P),U=e.mul(A,U),H=e.mul(d,H),V=e.sub(T,H),V=e.mul(d,V),V=e.add(V,U),U=e.add(T,T),T=e.add(U,T),T=e.add(T,H),T=e.mul(T,V),k=e.add(k,T),H=e.mul(B,D),H=e.add(H,H),T=e.mul(H,V),P=e.sub(P,T),U=e.mul(H,et),U=e.add(U,U),U=e.add(U,U),new h(P,k,U)}add(d){l(d);let{px:E,py:A,pz:m}=this,{px:B,py:D,pz:P}=d,k=e.ZERO,U=e.ZERO,T=e.ZERO,et=t.a,H=e.mul(t.b,Bl),V=e.mul(E,B),at=e.mul(A,D),_=e.mul(m,P),L=e.add(E,A),w=e.add(B,D);L=e.mul(L,w),w=e.add(V,at),L=e.sub(L,w),w=e.add(E,m);let y=e.add(B,P);return w=e.mul(w,y),y=e.add(V,_),w=e.sub(w,y),y=e.add(A,m),k=e.add(D,P),y=e.mul(y,k),k=e.add(at,_),y=e.sub(y,k),T=e.mul(et,w),k=e.mul(H,_),T=e.add(k,T),k=e.sub(at,T),T=e.add(at,T),U=e.mul(k,T),at=e.add(V,V),at=e.add(at,V),_=e.mul(et,_),w=e.mul(H,w),at=e.add(at,_),_=e.sub(V,_),_=e.mul(et,_),w=e.add(w,_),V=e.mul(at,w),U=e.add(U,V),V=e.mul(y,w),k=e.mul(L,k),k=e.sub(k,V),V=e.mul(L,at),T=e.mul(y,T),T=e.add(T,V),new h(k,U,T)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return x.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){let{endo:E,n:A}=t;Lt("scalar",d,be,A);let m=h.ZERO;if(d===be)return m;if(this.is0()||d===pt)return this;if(!E||x.hasPrecomputes(this))return x.wNAFCachedUnsafe(this,d,h.normalizeZ);let{k1neg:B,k1:D,k2neg:P,k2:k}=E.splitScalar(d),U=m,T=m,et=this;for(;D>be||k>be;)D&pt&&(U=U.add(et)),k&pt&&(T=T.add(et)),et=et.double(),D>>=pt,k>>=pt;return B&&(U=U.negate()),P&&(T=T.negate()),T=new h(e.mul(T.px,E.beta),T.py,T.pz),U.add(T)}multiply(d){let{endo:E,n:A}=t;Lt("scalar",d,pt,A);let m,B;if(E){let{k1neg:D,k1:P,k2neg:k,k2:U}=E.splitScalar(d),{p:T,f:et}=this.wNAF(P),{p:H,f:V}=this.wNAF(U);T=x.constTimeNegate(D,T),H=x.constTimeNegate(k,H),H=new h(e.mul(H.px,E.beta),H.py,H.pz),m=T.add(H),B=et.add(V)}else{let{p:D,f:P}=this.wNAF(d);m=D,B=P}return h.normalizeZ([m,B])[0]}multiplyAndAddUnsafe(d,E,A){let m=h.BASE,B=(P,k)=>k===be||k===pt||!P.equals(m)?P.multiplyUnsafe(k):P.multiply(k),D=B(this,E).add(B(d,A));return D.is0()?void 0:D}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:E}=t;if(d===pt)return!0;if(E)return E(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:E}=t;return d===pt?this:E?E(h,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return ee("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return ee("isCompressed",d),pe(this.toRawBytes(d))}}h.BASE=new h(t.Gx,t.Gy,e.ONE),h.ZERO=new h(e.ZERO,e.ONE,e.ZERO);let b=t.nBitLength,x=Uo(h,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:c}}function Z0(r){let t=hn(r);return se(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Il(r){let t=Z0(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(_){return Z(_,n)}function c(_){return ko(_,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=j0({...t,toBytes(_,L,w){let y=L.toAffine(),v=e.toBytes(y.x),C=ge;return ee("isCompressed",w),w?C(Uint8Array.from([L.hasEvenY()?2:3]),v):C(Uint8Array.from([4]),v,e.toBytes(y.y))},fromBytes(_){let L=_.length,w=_[0],y=_.subarray(1);if(L===o&&(w===2||w===3)){let v=me(y);if(!fn(v,pt,e.ORDER))throw new Error("Point is not on curve");let C=u(v),N;try{N=e.sqrt(C)}catch(z){let O=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+O)}let R=(N&pt)===pt;return(w&1)===1!==R&&(N=e.neg(N)),{x:v,y:N}}else if(L===i&&w===4){let v=e.fromBytes(y.subarray(0,e.BYTES)),C=e.fromBytes(y.subarray(e.BYTES,2*e.BYTES));return{x:v,y:C}}else{let v=o,C=i;throw new Error("invalid Point, expected length of "+v+", or uncompressed "+C+", got "+L)}}}),h=_=>pe(Ue(_,t.nByteLength));function b(_){let L=n>>pt;return _>L}function x(_){return b(_)?s(-_):_}let g=(_,L,w)=>me(_.slice(L,w));class d{constructor(L,w,y){this.r=L,this.s=w,this.recovery=y,this.assertValidity()}static fromCompact(L){let w=t.nByteLength;return L=it("compactSignature",L,w*2),new d(g(L,0,w),g(L,w,2*w))}static fromDER(L){let{r:w,s:y}=ye.toSig(it("DER",L));return new d(w,y)}assertValidity(){Lt("r",this.r,pt,n),Lt("s",this.s,pt,n)}addRecoveryBit(L){return new d(this.r,this.s,L)}recoverPublicKey(L){let{r:w,s:y,recovery:v}=this,C=P(it("msgHash",L));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let N=v===2||v===3?w+t.n:w;if(N>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let R=(v&1)===0?"02":"03",K=a.fromHex(R+h(N)),z=c(N),O=s(-C*z),j=s(y*z),J=a.BASE.multiplyAndAddUnsafe(K,O,j);if(!J)throw new Error("point at infinify");return J.assertValidity(),J}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return qe(this.toDERHex())}toDERHex(){return ye.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return qe(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let E={isValidPrivateKey(_){try{return l(_),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let _=Ss(t.n);return hl(t.randomBytes(_),t.n)},precompute(_=8,L=a.BASE){return L._setWindowSize(_),L.multiply(BigInt(3)),L}};function A(_,L=!0){return a.fromPrivateKey(_).toRawBytes(L)}function m(_){let L=ke(_),w=typeof _=="string",y=(L||w)&&_.length;return L?y===o||y===i:w?y===2*o||y===2*i:_ instanceof a}function B(_,L,w=!0){if(m(_))throw new Error("first arg must be private key");if(!m(L))throw new Error("second arg must be public key");return a.fromHex(L).multiply(l(_)).toRawBytes(w)}let D=t.bits2int||function(_){if(_.length>8192)throw new Error("input is too large");let L=me(_),w=_.length*8-t.nBitLength;return w>0?L>>BigInt(w):L},P=t.bits2int_modN||function(_){return s(D(_))},k=dn(t.nBitLength);function U(_){return Lt("num < 2^"+t.nBitLength,_,be,k),Ue(_,t.nByteLength)}function T(_,L,w=et){if(["recovered","canonical"].some(ft=>ft in w))throw new Error("sign() legacy options not supported");let{hash:y,randomBytes:v}=t,{lowS:C,prehash:N,extraEntropy:R}=w;C==null&&(C=!0),_=it("msgHash",_),_l(w),N&&(_=it("prehashed msgHash",y(_)));let K=P(_),z=l(L),O=[U(z),U(K)];if(R!=null&&R!==!1){let ft=R===!0?v(e.BYTES):R;O.push(it("extraEntropy",ft))}let j=ge(...O),J=K;function lt(ft){let mt=D(ft);if(!f(mt))return;let bt=c(mt),kt=a.BASE.multiply(mt).toAffine(),At=s(kt.x);if(At===be)return;let ne=s(bt*s(J+At*z));if(ne===be)return;let ce=(kt.x===At?0:2)|Number(kt.y&pt),Ir=ne;return C&&b(ne)&&(Ir=x(ne),ce^=1),new d(At,Ir,ce)}return{seed:j,k2sig:lt}}let et={lowS:t.lowS,prehash:!1},H={lowS:t.lowS,prehash:!1};function V(_,L,w=et){let{seed:y,k2sig:v}=T(_,L,w),C=t;return xs(C.hash.outputLen,C.nByteLength,C.hmac)(y,v)}a.BASE._setWindowSize(8);function at(_,L,w,y=H){let v=_;L=it("msgHash",L),w=it("publicKey",w);let{lowS:C,prehash:N,format:R}=y;if(_l(y),"strict"in y)throw new Error("options.strict was renamed to lowS");if(R!==void 0&&R!=="compact"&&R!=="der")throw new Error("format must be compact or der");let K=typeof v=="string"||ke(v),z=!K&&!R&&typeof v=="object"&&v!==null&&typeof v.r=="bigint"&&typeof v.s=="bigint";if(!K&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let O,j;try{if(z&&(O=new d(v.r,v.s)),K){try{R!=="compact"&&(O=d.fromDER(v))}catch(ce){if(!(ce instanceof ye.Err))throw ce}!O&&R!=="der"&&(O=d.fromCompact(v))}j=a.fromHex(w)}catch{return!1}if(!O||C&&O.hasHighS())return!1;N&&(L=t.hash(L));let{r:J,s:lt}=O,ft=P(L),mt=c(lt),bt=s(ft*mt),kt=s(J*mt),At=a.BASE.multiplyAndAddUnsafe(j,bt,kt)?.toAffine();return At?s(At.x)===J:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:B,sign:V,verify:at,ProjectivePoint:a,Signature:d,utils:E}}function Y0(r){return{hash:r,hmac:(t,...e)=>Ps(r,t,ds(...e)),randomBytes:Ao}}function Cl(r,t){let e=n=>Il({...r,...Y0(n)});return{...e(t),create:e}}var Ul=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),kl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),W0=BigInt(1),Ns=BigInt(2),Tl=(r,t)=>(r+t/Ns)/t;function X0(r){let t=Ul,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),l=r*r*r%t,u=l*l*r%t,f=ot(u,e,t)*u%t,h=ot(f,e,t)*u%t,b=ot(h,Ns,t)*l%t,x=ot(b,o,t)*b%t,g=ot(x,i,t)*x%t,d=ot(g,c,t)*g%t,E=ot(d,a,t)*d%t,A=ot(E,c,t)*g%t,m=ot(A,e,t)*u%t,B=ot(m,s,t)*x%t,D=ot(B,n,t)*l%t,P=ot(D,Ns,t);if(!Rs.eql(Rs.sqr(P),r))throw new Error("Cannot find square root");return P}var Rs=Le(Ul,void 0,void 0,{sqrt:X0}),Ze=Cl({a:BigInt(0),b:BigInt(7),Fp:Rs,n:kl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=kl,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-W0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),c=Tl(i*r,t),a=Tl(-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}}}},Al),t3=BigInt(0);var e3=Ze.ProjectivePoint;function Ll(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Pl(r,t,e){let n=qr.digest(e instanceof Uint8Array?e:e.subarray());if(Ll(n))return n.then(({digest:o})=>Ze.verify(t,o,r)).catch(o=>{throw new mn(String(o))});try{return Ze.verify(t,n.digest,r)}catch(o){throw new mn(String(o))}}var Mo=class{type="secp256k1";raw;_key;constructor(t){this._key=Nl(t),this.raw=Dl(this._key)}toMultihash(){return Xt.digest(xr(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return tt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Nt(this.raw,t.raw)}verify(t,e){return Pl(this._key,e,t)}};function Rl(r){return new Mo(r)}function Dl(r){return Ze.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Nl(r){try{return Ze.ProjectivePoint.fromHex(r),r}catch(t){throw new En(String(t))}}function Ml(r){let{Type:t,Data:e}=pn.decode(r.digest),n=e??new Uint8Array;switch(t){case Vt.Ed25519:return Sl(n);case Vt.secp256k1:return Rl(n);case Vt.ECDSA:return Wu(n);default:throw new kr}}function xr(r){return pn.encode({Type:Vt[r.type],Data:r.raw})}var Ol=Symbol.for("nodejs.util.inspect.custom"),Q0=114,gn=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()})`}[xn]=!0;toString(){return this.string==null&&(this.string=tt.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ct.createV1(Q0,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Nt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Nt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ol](){return`PeerId(${this.toString()})`}},Oo=class extends gn{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Fo=class extends gn{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Ko=class extends gn{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},J0=2336,yn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Xt.digest(qt(this.url))}[Ol](){return`PeerId(${this.url})`}[xn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ct.createV1(J0,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=X(t)),t.toString()===this.toString())}};var tm=114,Fl=2336;function Kl(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=le(tt.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return em(ct.parse(r));if(t==null)throw new zt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=le(t.decode(r))}return Vo(e)}function Vo(r){if(nm(r))return new Oo({multihash:r});if(rm(r))try{let t=Ml(r);if(t.type==="Ed25519")return new Fo({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Ko({multihash:r,publicKey:t})}catch{let e=X(r.digest);return new yn(new URL(e))}throw new Sn("Supplied PeerID Multihash is invalid")}function em(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==tm&&r.code!==Fl)throw new vn("Supplied PeerID CID is invalid");if(r.code===Fl){let t=X(r.multihash.digest);return new yn(new URL(t))}return Vo(r.multihash)}function rm(r){return r.code===Xt.code}function nm(r){return r.code===qr.code}var Vl={type:4098,canEncode:r=>Zs(r),encode:r=>r.toMultihash().bytes,decode:r=>Vo(le(r))};var Ms=[Tu,$u,Vl,Uu];function zo(r){let t={},e=r.components??r;return Object.entries(e).forEach(([n,o])=>{o?.[xe]!=null&&Array.isArray(o[xe])&&(t[n]=o[xe])}),t}function _r(r,t){let e={};for(let[n,o]of r.entries())e[n]=t(o);return e}async function Ho(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:_r(c.tags,a=>a.value),metadata:_r(c.metadata,a=>oe.encode(a))})}catch(c){t.error("could not load peer data from peer store",c),e.push({id:i,addresses:s.map(a=>({multiaddr:a.remoteAddr,isConnected:o.includes(a.remoteAddr.toString())})),protocols:[],tags:{},metadata:{}})}return e}function Br(r,t){let e=t[r];if(!wn(e))throw new zt(`Component ${r} did not implement the PubSub interface`);return e}async function qo(r){let t=await r.peerStore.get(r.peerId);return{id:t.id,addresses:t.addresses,protocols:[...t.protocols],tags:_r(t.tags,e=>e.value),metadata:_r(t.metadata,e=>oe.encode(e))}}function zl(r){let t=r.logger.forComponent("libp2p:devtools-metrics:metrics-rpc");return{init:async()=>({self:await qo(r),peers:await Ho(r,t),debug:localStorage.getItem("debug")??"",capabilities:zo(r)}),setDebug:async e=>{e?.length!=null&&e?.length>0?(uc(e),localStorage.setItem("debug",e)):(ac(),localStorage.removeItem("debug"))},openConnection:async(e,n)=>{let o;try{o=Kl(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 Br(e,r).getTopics()},async subscribe(e,n){Br(e,r).subscribe(n)},async unsubscribe(e,n){Br(e,r).unsubscribe(n)},async publish(e,n,o){await Br(e,r).publish(n,o)},async getSubscribers(e,n){return Br(e,r).getSubscribers(n)}}}}function Os(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 Hl(r,t){for(let[e,n]of Object.entries(zo(t)))if(n.includes(r))return t[e]}var ql="@libp2p/devtools-metrics:devtools",om="@libp2p/devtools-metrics:worker",im="@libp2p/devtools-metrics:content",$l="@libp2p/devtools-metrics:metrics",Gl="________libp2p_devtools_metrics";Object.defineProperty(globalThis,Gl,{value:!0,enumerable:!1,writable:!1});var Fs=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=Je(),this.rpc=ku({valueCodecs:Ms}),this.devTools=this.rpc.createClient("devTools"),this.onPeersUpdate=Os(this.onPeersUpdate.bind(this),1e3),this.onSelfUpdate=Os(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=Ac({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";[xe]=["@libp2p/metrics"];trackMultiaddrConnection(t){this.simpleMetrics.trackMultiaddrConnection(t)}trackProtocolStream(t,e){this.simpleMetrics.trackProtocolStream(t,e)}registerMetric(t,e){return this.simpleMetrics.registerMetric(t,e)}registerMetricGroup(t,e){return this.simpleMetrics.registerMetricGroup(t,e)}registerCounter(t,e){return this.simpleMetrics.registerCounter(t,e)}registerCounterGroup(t,e){return this.simpleMetrics.registerCounterGroup(t,e)}registerHistogram(t,e){return this.simpleMetrics.registerHistogram(t,e)}registerHistogramGroup(t,e){return this.simpleMetrics.registerHistogramGroup(t,e)}registerSummary(t,e){return this.simpleMetrics.registerSummary(t,e)}registerSummaryGroup(t,e){return this.simpleMetrics.registerSummaryGroup(t,e)}createTrace(){return this.simpleMetrics.createTrace()}traceFunction(t,e,n){return this.simpleMetrics.traceFunction(t,e,n)}async start(){this.components.events.addEventListener("peer:connect",this.onPeersUpdate),this.components.events.addEventListener("peer:disconnect",this.onPeersUpdate),this.components.events.addEventListener("peer:identify",this.onPeersUpdate),this.components.events.addEventListener("peer:update",this.onPeersUpdate),this.components.events.addEventListener("self:peer:update",this.onSelfUpdate),window.addEventListener("message",this.onIncomingMessage),this.rpc.createTarget("metrics",zl(this.components)),await Xs(this.simpleMetrics),Promise.resolve().then(async()=>{await Cc(this.rpcQueue,this.rpc,async e=>{for await(let n of e)window.postMessage({source:$l,type:"libp2p-rpc",message:oe.encode(n)})})}).catch(e=>{this.log.error("error while reading RPC messages",e)});let t=Hl("@libp2p/pubsub",this.components);wn(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 Qs(this.simpleMetrics)}onIncomingMessage(t){if(t.source!==window)return;let e=t.data;e?.source===ql&&e.type==="libp2p-rpc"&&this.rpcQueue.push(oe.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 qo(this.components)})}).catch(t=>{this.log.error("error sending peers message",t)})}onPeersUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("peers",{detail:await Ho(this.components,this.log)})}).catch(t=>{this.log.error("error sending peers message",t)})}};function sm(r){return t=>new Fs(t,r)}return af(cm);})();
2
+ "use strict";var Libp2PDevtoolsMetrics=(()=>{var hf=Object.create;var An=Object.defineProperty;var pf=Object.getOwnPropertyDescriptor;var mf=Object.getOwnPropertyNames;var gf=Object.getPrototypeOf,yf=Object.prototype.hasOwnProperty;var Ur=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Dt=(r,t)=>{for(var e in t)An(r,e,{get:t[e],enumerable:!0})},Gs=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of mf(t))!yf.call(r,o)&&o!==e&&An(r,o,{get:()=>t[o],enumerable:!(n=pf(t,o))||n.enumerable});return r};var xf=(r,t,e)=>(e=r!=null?hf(gf(r)):{},Gs(t||!r||!r.__esModule?An(e,"default",{value:r,enumerable:!0}):e,r)),bf=r=>Gs(An({},"__esModule",{value:!0}),r);var ri=Ur((Km,fc)=>{function Xt(){}Xt.prototype.clear=function(){this._root=null,this.size=0};Xt.prototype.find=function(r){for(var t=this._root;t!==null;){var e=this._comparator(r,t.data);if(e===0)return t.data;t=t.get_child(e>0)}return null};Xt.prototype.findIter=function(r){for(var t=this._root,e=this.iterator();t!==null;){var n=this._comparator(r,t.data);if(n===0)return e._cursor=t,e;e._ancestors.push(t),t=t.get_child(n>0)}return null};Xt.prototype.lowerBound=function(r){for(var t=this._root,e=this.iterator(),n=this._comparator;t!==null;){var o=n(r,t.data);if(o===0)return e._cursor=t,e;e._ancestors.push(t),t=t.get_child(o>0)}for(var i=e._ancestors.length-1;i>=0;--i)if(t=e._ancestors[i],n(r,t.data)<0)return e._cursor=t,e._ancestors.length=i,e;return e._ancestors.length=0,e};Xt.prototype.upperBound=function(r){for(var t=this.lowerBound(r),e=this._comparator;t.data()!==null&&e(t.data(),r)===0;)t.next();return t};Xt.prototype.min=function(){var r=this._root;if(r===null)return null;for(;r.left!==null;)r=r.left;return r.data};Xt.prototype.max=function(){var r=this._root;if(r===null)return null;for(;r.right!==null;)r=r.right;return r.data};Xt.prototype.iterator=function(){return new Xe(this)};Xt.prototype.each=function(r){for(var t=this.iterator(),e;(e=t.next())!==null;)if(r(e)===!1)return};Xt.prototype.reach=function(r){for(var t=this.iterator(),e;(e=t.prev())!==null;)if(r(e)===!1)return};function Xe(r){this._tree=r,this._ancestors=[],this._cursor=null}Xe.prototype.data=function(){return this._cursor!==null?this._cursor.data:null};Xe.prototype.next=function(){if(this._cursor===null){var r=this._tree._root;r!==null&&this._minNode(r)}else if(this._cursor.right===null){var t;do if(t=this._cursor,this._ancestors.length)this._cursor=this._ancestors.pop();else{this._cursor=null;break}while(this._cursor.right===t)}else this._ancestors.push(this._cursor),this._minNode(this._cursor.right);return this._cursor!==null?this._cursor.data:null};Xe.prototype.prev=function(){if(this._cursor===null){var r=this._tree._root;r!==null&&this._maxNode(r)}else if(this._cursor.left===null){var t;do if(t=this._cursor,this._ancestors.length)this._cursor=this._ancestors.pop();else{this._cursor=null;break}while(this._cursor.left===t)}else this._ancestors.push(this._cursor),this._maxNode(this._cursor.left);return this._cursor!==null?this._cursor.data:null};Xe.prototype._minNode=function(r){for(;r.left!==null;)this._ancestors.push(r),r=r.left;this._cursor=r};Xe.prototype._maxNode=function(r){for(;r.right!==null;)this._ancestors.push(r),r=r.right;this._cursor=r};fc.exports=Xt});var pc=Ur((Vm,hc)=>{var ed=ri();function Qe(r){this.data=r,this.left=null,this.right=null,this.red=!0}Qe.prototype.get_child=function(r){return r?this.right:this.left};Qe.prototype.set_child=function(r,t){r?this.right=t:this.left=t};function Pn(r){this._root=null,this._comparator=r,this.size=0}Pn.prototype=new ed;Pn.prototype.insert=function(r){var t=!1;if(this._root===null)this._root=new Qe(r),t=!0,this.size++;else{var e=new Qe(void 0),n=0,o=0,i=null,s=e,c=null,a=this._root;for(s.right=this._root;;){if(a===null?(a=new Qe(r),c.set_child(n,a),t=!0,this.size++):$t(a.left)&&$t(a.right)&&(a.red=!0,a.left.red=!1,a.right.red=!1),$t(a)&&$t(c)){var l=s.right===i;a===c.get_child(o)?s.set_child(l,Pr(i,!o)):s.set_child(l,dc(i,!o))}var u=this._comparator(a.data,r);if(u===0)break;o=n,n=u<0,i!==null&&(s=i),i=c,c=a,a=a.get_child(n)}this._root=e.right}return this._root.red=!1,t};Pn.prototype.remove=function(r){if(this._root===null)return!1;var t=new Qe(void 0),e=t;e.right=this._root;for(var n=null,o=null,i=null,s=1;e.get_child(s)!==null;){var c=s;o=n,n=e,e=e.get_child(s);var a=this._comparator(r,e.data);if(s=a>0,a===0&&(i=e),!$t(e)&&!$t(e.get_child(s))){if($t(e.get_child(!s))){var l=Pr(e,s);n.set_child(c,l),n=l}else if(!$t(e.get_child(!s))){var u=n.get_child(!c);if(u!==null)if(!$t(u.get_child(!c))&&!$t(u.get_child(c)))n.red=!1,u.red=!0,e.red=!0;else{var f=o.right===n;$t(u.get_child(c))?o.set_child(f,dc(n,c)):$t(u.get_child(!c))&&o.set_child(f,Pr(n,c));var h=o.get_child(f);h.red=!0,e.red=!0,h.left.red=!1,h.right.red=!1}}}}return i!==null&&(i.data=e.data,n.set_child(n.right===e,e.get_child(e.left===null)),this.size--),this._root=t.right,this._root!==null&&(this._root.red=!1),i!==null};function $t(r){return r!==null&&r.red}function Pr(r,t){var e=r.get_child(!t);return r.set_child(!t,e.get_child(t)),e.set_child(t,r),r.red=!0,e.red=!1,e}function dc(r,t){return r.set_child(!t,Pr(r.get_child(!t),!t)),Pr(r,t)}hc.exports=Pn});var gc=Ur((Hm,mc)=>{var rd=ri();function Dr(r){this.data=r,this.left=null,this.right=null}Dr.prototype.get_child=function(r){return r?this.right:this.left};Dr.prototype.set_child=function(r,t){r?this.right=t:this.left=t};function Dn(r){this._root=null,this._comparator=r,this.size=0}Dn.prototype=new rd;Dn.prototype.insert=function(r){if(this._root===null)return this._root=new Dr(r),this.size++,!0;for(var t=0,e=null,n=this._root;;){if(n===null)return n=new Dr(r),e.set_child(t,n),ret=!0,this.size++,!0;if(this._comparator(n.data,r)===0)return!1;t=this._comparator(n.data,r)<0,e=n,n=n.get_child(t)}};Dn.prototype.remove=function(r){if(this._root===null)return!1;var t=new Dr(void 0),e=t;e.right=this._root;for(var n=null,o=null,i=1;e.get_child(i)!==null;){n=e,e=e.get_child(i);var s=this._comparator(r,e.data);i=s>0,s===0&&(o=e)}return o!==null?(o.data=e.data,n.set_child(n.right===e,e.get_child(e.left===null)),this._root=t.right,this.size--,!0):!1};mc.exports=Dn});var xc=Ur((zm,yc)=>{yc.exports={RBTree:pc(),BinTree:gc()}});var Ec=Ur((qm,wc)=>{var nd=xc().RBTree;function rt(r,t,e){this.discrete=r===!1,this.delta=r||.01,this.K=t===void 0?25:t,this.CX=e===void 0?1.1:e,this.centroids=new nd(bc),this.nreset=0,this.reset()}rt.prototype.reset=function(){this.centroids.clear(),this.n=0,this.nreset+=1,this.last_cumulate=0};rt.prototype.size=function(){return this.centroids.size};rt.prototype.toArray=function(r){var t=[];return r?(this._cumulate(!0),this.centroids.each(function(e){t.push(e)})):this.centroids.each(function(e){t.push({mean:e.mean,n:e.n})}),t};rt.prototype.summary=function(){var r=this.discrete?"exact ":"approximating ",t=[r+this.n+" samples using "+this.size()+" centroids","min = "+this.percentile(0),"Q1 = "+this.percentile(.25),"Q2 = "+this.percentile(.5),"Q3 = "+this.percentile(.75),"max = "+this.percentile(1)];return t.join(`
3
+ `)};function bc(r,t){return r.mean>t.mean?1:r.mean<t.mean?-1:0}function od(r,t){return r.mean_cumn-t.mean_cumn}rt.prototype.push=function(r,t){t=t||1,r=Array.isArray(r)?r:[r];for(var e=0;e<r.length;e++)this._digest(r[e],t)};rt.prototype.push_centroid=function(r){r=Array.isArray(r)?r:[r];for(var t=0;t<r.length;t++)this._digest(r[t].mean,r[t].n)};rt.prototype._cumulate=function(r){if(!(this.n===this.last_cumulate||!r&&this.CX&&this.CX>this.n/this.last_cumulate)){var t=0;this.centroids.each(function(e){e.mean_cumn=t+e.n/2,t=e.cumn=t+e.n}),this.n=this.last_cumulate=t}};rt.prototype.find_nearest=function(r){if(this.size()===0)return null;var t=this.centroids.lowerBound({mean:r}),e=t.data()===null?t.prev():t.data();if(e.mean===r||this.discrete)return e;var n=t.prev();return n&&Math.abs(n.mean-r)<Math.abs(e.mean-r)?n:e};rt.prototype._new_centroid=function(r,t,e){var n={mean:r,n:t,cumn:e};return this.centroids.insert(n),this.n+=t,n};rt.prototype._addweight=function(r,t,e){t!==r.mean&&(r.mean+=e*(t-r.mean)/(r.n+e)),r.cumn+=e,r.mean_cumn+=e/2,r.n+=e,this.n+=e};rt.prototype._digest=function(r,t){var e=this.centroids.min(),n=this.centroids.max(),o=this.find_nearest(r);if(o&&o.mean===r)this._addweight(o,r,t);else if(o===e)this._new_centroid(r,t,0);else if(o===n)this._new_centroid(r,t,this.n);else if(this.discrete)this._new_centroid(r,t,o.cumn);else{var i=o.mean_cumn/this.n,s=Math.floor(4*this.n*this.delta*i*(1-i));s-o.n>=t?this._addweight(o,r,t):this._new_centroid(r,t,o.cumn)}this._cumulate(!1),!this.discrete&&this.K&&this.size()>this.K/this.delta&&this.compress()};rt.prototype.bound_mean=function(r){var t=this.centroids.upperBound({mean:r}),e=t.prev(),n=e.mean===r?e:t.next();return[e,n]};rt.prototype.p_rank=function(r){var t=Array.isArray(r)?r:[r],e=t.map(this._p_rank,this);return Array.isArray(r)?e:e[0]};rt.prototype._p_rank=function(r){if(this.size()!==0){{if(r<this.centroids.min().mean)return 0;if(r>this.centroids.max().mean)return 1}this._cumulate(!0);var t=this.bound_mean(r),e=t[0],n=t[1];if(this.discrete)return e.cumn/this.n;var o=e.mean_cumn;return e!==n&&(o+=(r-e.mean)*(n.mean_cumn-e.mean_cumn)/(n.mean-e.mean)),o/this.n}};rt.prototype.bound_mean_cumn=function(r){this.centroids._comparator=od;var t=this.centroids.upperBound({mean_cumn:r});this.centroids._comparator=bc;var e=t.prev(),n=e&&e.mean_cumn===r?e:t.next();return[e,n]};rt.prototype.percentile=function(r){var t=Array.isArray(r)?r:[r],e=t.map(this._percentile,this);return Array.isArray(r)?e:e[0]};rt.prototype._percentile=function(r){if(this.size()!==0){this._cumulate(!0);var t=this.n*r,e=this.bound_mean_cumn(t),n=e[0],o=e[1];return o===n||n===null||o===null?(n||o).mean:this.discrete?t<=n.cumn?n.mean:o.mean:n.mean+(t-n.mean_cumn)*(o.mean-n.mean)/(o.mean_cumn-n.mean_cumn)}};function id(r){var t=Math.floor(Math.random()*r.length);return r.splice(t,1)[0]}rt.prototype.compress=function(){if(!this.compressing){var r=this.toArray();for(this.reset(),this.compressing=!0;r.length>0;)this.push_centroid(id(r));this._cumulate(!0),this.compressing=!1}};function Ae(r){this.config=r||{},this.mode=this.config.mode||"auto",rt.call(this,this.mode==="cont"?r.delta:!1),this.digest_ratio=this.config.ratio||.9,this.digest_thresh=this.config.thresh||1e3,this.n_unique=0}Ae.prototype=Object.create(rt.prototype);Ae.prototype.constructor=Ae;Ae.prototype.push=function(r){rt.prototype.push.call(this,r),this.check_continuous()};Ae.prototype._new_centroid=function(r,t,e){this.n_unique+=1,rt.prototype._new_centroid.call(this,r,t,e)};Ae.prototype._addweight=function(r,t,e){r.n===1&&(this.n_unique-=1),rt.prototype._addweight.call(this,r,t,e)};Ae.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};wc.exports={TDigest:rt,Digest:Ae}});var V0={};Dt(V0,{LIBP2P_DEVTOOLS_METRICS_KEY:()=>af,SOURCE_CONTENT_SCRIPT:()=>F0,SOURCE_DEVTOOLS:()=>sf,SOURCE_METRICS:()=>cf,SOURCE_SERVICE_WORKER:()=>O0,devToolsMetrics:()=>K0,valueCodecs:()=>Hs});var _n=Symbol.for("@libp2p/peer-id");function js(r){return!!r?.[_n]}var Zs;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Zs||(Zs={}));var wf=Symbol.for("@libp2p/pubsub");function In(r){return!!r?.[wf]}var qt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Cn=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Bn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},kn=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Lr=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};function Ys(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function Ws(...r){let t=[];for(let e of r)Ys(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 Xs(...r){let t=[];for(let e of r)Ys(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 ve=Symbol.for("@libp2p/service-capabilities"),j0=Symbol.for("@libp2p/service-dependencies");var Xo={};Dt(Xo,{base32:()=>Wt,base32hex:()=>kf,base32hexpad:()=>Uf,base32hexpadupper:()=>Lf,base32hexupper:()=>Tf,base32pad:()=>Cf,base32padupper:()=>Bf,base32upper:()=>If,base32z:()=>Pf});var gm=new Uint8Array(0);function Qs(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function ue(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Js(r){return new TextEncoder().encode(r)}function tc(r){return new TextDecoder().decode(r)}function Ef(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var c=r.length,a=r.charAt(0),l=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function f(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var g=0,x=0,U=0,V=w.length;U!==V&&w[U]===0;)U++,g++;for(var v=(V-U)*u+1>>>0,d=new Uint8Array(v);U!==V;){for(var b=w[U],k=0,T=v-1;(b!==0||k<x)&&T!==-1;T--,k++)b+=256*d[T]>>>0,d[T]=b%c>>>0,b=b/c>>>0;if(b!==0)throw new Error("Non-zero carry");x=k,U++}for(var L=v-x;L!==v&&d[L]===0;)L++;for(var M=a.repeat(g);L<v;++L)M+=r.charAt(d[L]);return M}function h(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var g=0;if(w[g]!==" "){for(var x=0,U=0;w[g]===a;)x++,g++;for(var V=(w.length-g)*l+1>>>0,v=new Uint8Array(V);w[g];){var d=e[w.charCodeAt(g)];if(d===255)return;for(var b=0,k=V-1;(d!==0||b<U)&&k!==-1;k--,b++)d+=c*v[k]>>>0,v[k]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");U=b,g++}if(w[g]!==" "){for(var T=V-U;T!==V&&v[T]===0;)T++;for(var L=new Uint8Array(x+(V-T)),M=x;T!==V;)L[M++]=v[T++];return L}}}function E(w){var g=h(w);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:h,decode:E}}var vf=Ef,Sf=vf,rc=Sf;var jo=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")}},Zo=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 nc(this,t)}},Yo=class{decoders;constructor(t){this.decoders=t}or(t){return nc(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 nc(r,t){return new Yo({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Wo=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new jo(t,e,n),this.decoder=new Zo(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function We({name:r,prefix:t,encode:e,decode:n}){return new Wo(r,t,e,n)}function Se({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=rc(e,r);return We({prefix:t,name:r,encode:n,decode:i=>ue(o(i))})}function Af(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),c=0,a=0,l=0;for(let u=0;u<i;++u){let f=o[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,c+=e,c>=8&&(c-=8,s[l++]=255&a>>c)}if(c>=e||(255&a<<8-c)!==0)throw new SyntaxError("Unexpected end of data");return s}function _f(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>e;)s-=e,i+=t[o&c>>s];if(s!==0&&(i+=t[o&c<<e-s]),n)for(;(i.length*e&7)!==0;)i+="=";return i}function it({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return We({prefix:t,name:r,encode(o){return _f(o,n,e)},decode(o){return Af(o,n,e,r)}})}var Wt=it({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),If=it({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Cf=it({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Bf=it({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),kf=it({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Tf=it({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Uf=it({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Lf=it({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Pf=it({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Qo={};Dt(Qo,{base58btc:()=>et,base58flickr:()=>Df});var et=Se({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Df=Se({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Jo={};Dt(Jo,{base64:()=>oe,base64pad:()=>Nf,base64url:()=>Rf,base64urlpad:()=>Mf});var oe=it({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Nf=it({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Rf=it({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Mf=it({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Of(r,t){try{if(typeof r=="string"&&r.length>0)return Ff(r);if(typeof r=="number"&&isFinite(r))return t?.long?Vf(r):Kf(r);throw new Error("Value is not a string or number.")}catch(e){let n=Hf(e)?`${e.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function Ff(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 Un=Of;function Kf(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 Vf(r){let t=Math.abs(r);return t>=864e5?Tn(r,t,864e5,"day"):t>=36e5?Tn(r,t,36e5,"hour"):t>=6e4?Tn(r,t,6e4,"minute"):t>=1e3?Tn(r,t,1e3,"second"):`${r} ms`}function Tn(r,t,e,n){let o=t>=e*1.5;return`${Math.round(r/e)} ${n}${o?"s":""}`}function Hf(r){return typeof r=="object"&&r!==null&&"message"in r}function ti(r){e.debug=e,e.default=e,e.coerce=a,e.disable=i,e.enable=o,e.enabled=s,e.humanize=Un,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,E,w;function g(...x){if(!g.enabled)return;let U=g,V=Number(new Date),v=V-(f||V);U.diff=v,U.prev=f,U.curr=V,f=V,x[0]=e.coerce(x[0]),typeof x[0]!="string"&&x.unshift("%O");let d=0;x[0]=x[0].replace(/%([a-zA-Z%])/g,(k,T)=>{if(k==="%%")return"%";d++;let L=e.formatters[T];if(typeof L=="function"){let M=x[d];k=L.call(U,M),x.splice(d,1),d--}return k}),e.formatArgs.call(U,x),(U.log||e.log).apply(U,x)}return g.namespace=u,g.useColors=e.useColors(),g.color=e.selectColor(u),g.extend=n,g.destroy=e.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(E!==e.namespaces&&(E=e.namespaces,w=e.enabled(u)),w),set:x=>{h=x}}),typeof e.init=="function"&&e.init(g),g}function n(u,f){let h=e(this.namespace+(typeof f>"u"?":":f)+u);return h.log=this.log,h}function o(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let f,h=(typeof u=="string"?u:"").split(/[\s,]+/),E=h.length;for(f=0;f<E;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 Ln=Yf(),zf=["#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 qf(){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 $f(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Un(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 Gf=console.debug??console.log??(()=>{});function jf(r){try{r?Ln?.setItem("debug",r):Ln?.removeItem("debug")}catch{}}function Zf(){let r;try{r=Ln?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function Yf(){try{return localStorage}catch{}}function Wf(r){r.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}var oc=ti({formatArgs:$f,save:jf,load:Zf,useColors:qf,setupFormatters:Wf,colors:zf,storage:Ln,log:Gf});var wt=oc;wt.formatters.b=r=>r==null?"undefined":et.baseEncode(r);wt.formatters.t=r=>r==null?"undefined":Wt.baseEncode(r);wt.formatters.m=r=>r==null?"undefined":oe.baseEncode(r);wt.formatters.p=r=>r==null?"undefined":r.toString();wt.formatters.c=r=>r==null?"undefined":r.toString();wt.formatters.k=r=>r==null?"undefined":r.toString();wt.formatters.a=r=>r==null?"undefined":r.toString();wt.formatters.e=r=>r==null?"undefined":ic(r.stack)??ic(r.message)??r.toString();function Xf(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 sc(r){let t=Xf(`${r}:trace`);return wt.enabled(`${r}:trace`)&&wt.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=wt(`${r}:trace`)),Object.assign(wt(r),{error:wt(`${r}:error`),trace:t})}function cc(){wt.disable()}function ac(r){wt.enable(r)}function ic(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}function Qf(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 uc=Qf;function Jf(r){return r[Symbol.asyncIterator]!=null}function lc(r){return r?.then!=null}function td(r,t){let e=0;if(Jf(r))return async function*(){for await(let a of r){let l=t(a,e++);lc(l)&&await l,yield a}}();let n=uc(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++);lc(l)&&await l,yield a}}();let c=t;return function*(){yield o;for(let a of n)c(a,e++),yield a}()}var ei=td;var vc=xf(Ec(),1),sd=sc("libp2p:simple-metrics"),Nr=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}}},Rr=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}}},Mr=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)}}},Nn=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 Mr({})),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})}}},Or=class{sumValue=0;countValue=0;percentiles;tdigest=new vc.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)}}},Rn=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 Or(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})}}},ni=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";[ve]=["@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 Nr?t[e]=n.value:n instanceof Rr?t[e]=n.values:n instanceof Mr?t[e]={count:n.countValue,sum:n.sumValue,buckets:{...n.bucketValues}}:n instanceof Nn?t[e]={...Object.fromEntries(Object.entries(n.histograms).map(([o,i])=>[o,{count:i.countValue,sum:i.sumValue,buckets:{...i.bucketValues}}]))}:n instanceof Or?t[e]={count:n.countValue,sum:n.sumValue,percentiles:Object.fromEntries(n.percentiles.map(o=>[o,n.tdigest.percentile(o)]))}:n instanceof Rn?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=>{sd.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(ei(c,a=>{n._incrementValue(`${e} sent`,a.byteLength)}))};let i=t.source;t.source=ei(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 Nr;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 Rr;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 Nr;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 Rr;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 Mr(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 Nn(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 Or(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 Rn(e);return this.metrics.set(t,n),n}createTrace(){}traceFunction(t,e){return e}};function Sc(r){return t=>new ni(t,r)}function Et(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Mn=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||(t-1&t)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Je=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Mn(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 Mn(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 oi=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function tr(r={}){return cd(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 cd(r,t){t=t??{};let e=t.onEnd,n=new Je,o,i,s,c=Et(),a=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((x,U)=>{i=V=>{i=null,n.push(V);try{x(r(n))}catch(v){U(v)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=Et()})}},l=x=>i!=null?i(x):(n.push(x),o),u=x=>(n=new Je,i!=null?i({error:x}):(n.push({error:x}),o)),f=x=>{if(s)return o;if(t?.objectMode!==!0&&x?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:x})},h=x=>s?o:(s=!0,x!=null?u(x):l({done:!0})),E=()=>(n=new Je,h(),{done:!0}),w=x=>(h(x),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:E,throw:w,push:f,end:h,get readableLength(){return n.size},onEmpty:async x=>{let U=x?.signal;if(U?.throwIfAborted(),n.isEmpty())return;let V,v;U!=null&&(V=new Promise((d,b)=>{v=()=>{b(new oi)},U.addEventListener("abort",v)}));try{await Promise.race([c.promise,V])}finally{v!=null&&U!=null&&U?.removeEventListener("abort",v)}}},e==null)return o;let g=o;return o={[Symbol.asyncIterator](){return this},next(){return g.next()},throw(x){return g.throw(x),e!=null&&(e(x),e=void 0),{done:!0}},return(){return g.return(),e!=null&&(e(),e=void 0),{done:!0}},push:f,end(x){return g.end(x),e!=null&&(e(x),e=void 0),o},get readableLength(){return g.readableLength},onEmpty:x=>g.onEmpty(x)},o}var On=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function Ac(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new On(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new On(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((i,s)=>{n=()=>{s(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var ii=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=Et(),this.haveNext=Et()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Et(),t}async throw(t){return this.ended=!0,this.error=t,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Et(),await Ac(this.readNext.promise,e?.signal,e)}};function _c(){return new ii}function ad(r){return r[Symbol.asyncIterator]!=null}async function ud(r,t,e){try{await Promise.all(r.map(async n=>{for await(let o of n)await t.push(o,{signal:e}),e.throwIfAborted()})),await t.end(void 0,{signal:e})}catch(n){await t.end(n,{signal:e}).catch(()=>{})}}async function*ld(r){let t=new AbortController,e=_c();ud(r,e,t.signal).catch(()=>{});try{yield*e}finally{t.abort()}}function*fd(r){for(let t of r)yield*t}function dd(...r){let t=[];for(let e of r)ad(e)||t.push(e);return t.length===r.length?fd(t):ld(r)}var Ic=dd;function Cc(r,...t){if(r==null)throw new Error("Empty pipeline");if(si(r)){let n=r;r=()=>n.source}else if(kc(r)||Bc(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&si(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++)si(e[n])&&(e[n]=pd(e[n]));return hd(...e)}var hd=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},Bc=r=>r?.[Symbol.asyncIterator]!=null,kc=r=>r?.[Symbol.iterator]!=null,si=r=>r==null?!1:r.sink!=null&&r.source!=null,pd=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=tr({objectMode:!0});e.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(Bc(i))o=async function*(){yield*i,n.end()};else if(kc(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 Fn(r){let t=new globalThis.AbortController;function e(){t.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",e)}for(let i of r){if(i?.aborted===!0){e();break}i?.addEventListener!=null&&i.addEventListener("abort",e)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",e)}let o=t.signal;return o.clear=n,o}function Qt(r=0){return new Uint8Array(r)}function vt(r=0){return new Uint8Array(r)}var md=Math.pow(2,7),gd=Math.pow(2,14),yd=Math.pow(2,21),ci=Math.pow(2,28),ai=Math.pow(2,35),ui=Math.pow(2,42),li=Math.pow(2,49),Z=128,St=127;function ft(r){if(r<md)return 1;if(r<gd)return 2;if(r<yd)return 3;if(r<ci)return 4;if(r<ai)return 5;if(r<ui)return 6;if(r<li)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function fi(r,t,e=0){switch(ft(r)){case 8:t[e++]=r&255|Z,r/=128;case 7:t[e++]=r&255|Z,r/=128;case 6:t[e++]=r&255|Z,r/=128;case 5:t[e++]=r&255|Z,r/=128;case 4:t[e++]=r&255|Z,r>>>=7;case 3:t[e++]=r&255|Z,r>>>=7;case 2:t[e++]=r&255|Z,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function xd(r,t,e=0){switch(ft(r)){case 8:t.set(e++,r&255|Z),r/=128;case 7:t.set(e++,r&255|Z),r/=128;case 6:t.set(e++,r&255|Z),r/=128;case 5:t.set(e++,r&255|Z),r/=128;case 4:t.set(e++,r&255|Z),r>>>=7;case 3:t.set(e++,r&255|Z),r>>>=7;case 2:t.set(e++,r&255|Z),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function di(r,t){let e=r[t],n=0;if(n+=e&St,e<Z||(e=r[t+1],n+=(e&St)<<7,e<Z)||(e=r[t+2],n+=(e&St)<<14,e<Z)||(e=r[t+3],n+=(e&St)<<21,e<Z)||(e=r[t+4],n+=(e&St)*ci,e<Z)||(e=r[t+5],n+=(e&St)*ai,e<Z)||(e=r[t+6],n+=(e&St)*ui,e<Z)||(e=r[t+7],n+=(e&St)*li,e<Z))return n;throw new RangeError("Could not decode varint")}function bd(r,t){let e=r.get(t),n=0;if(n+=e&St,e<Z||(e=r.get(t+1),n+=(e&St)<<7,e<Z)||(e=r.get(t+2),n+=(e&St)<<14,e<Z)||(e=r.get(t+3),n+=(e&St)<<21,e<Z)||(e=r.get(t+4),n+=(e&St)*ci,e<Z)||(e=r.get(t+5),n+=(e&St)*ai,e<Z)||(e=r.get(t+6),n+=(e&St)*ui,e<Z)||(e=r.get(t+7),n+=(e&St)*li,e<Z))return n;throw new RangeError("Could not decode varint")}function _e(r,t,e=0){return t==null&&(t=vt(ft(r))),t instanceof Uint8Array?fi(r,t,e):xd(r,t,e)}function le(r,t=0){return r instanceof Uint8Array?di(r,t):bd(r,t)}function Nt(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=vt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function Rt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Uc=Symbol.for("@achingbrain/uint8arraylist");function Tc(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 Vn(r){return!!r?.[Uc]}var gt=class r{bufs;length;[Uc]=!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(Vn(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(Vn(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=Tc(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Tc(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(Vn(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Nt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Nt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),i=new r;return i.length=o,i.bufs=[...n],i}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,a=c+s.byteLength;if(o=a,t>=a)continue;let l=t>=c&&t<a,u=e>c&&e<=a;if(l&&u){if(t===c&&e===a){n.push(s);break}let f=t-c;n.push(s.subarray(f,f+(e-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-c));continue}if(u){if(e===a){n.push(s);break}n.push(s.subarray(0,e-c));break}n.push(s)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Vn(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 E=this.get(f+h);if(n[h]!==E){u=Math.max(1,h-c[E]);break}}if(u===0)return f}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=Qt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=Qt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=Qt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=Qt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=Qt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=Qt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=Qt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=Qt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!Rt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,i)=>o+i.byteLength,0)),n.length=e,n}};var Hn=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},er=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},zn=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},Fr=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function qn(r){return r[Symbol.asyncIterator]!=null}function Lc(r,t){if(r.byteLength>t)throw new er("Message length too long")}var Gn=r=>{let t=ft(r),e=vt(t);return _e(r,e),Gn.bytes=t,e};Gn.bytes=0;function jn(r,t){t=t??{};let e=t.lengthEncoder??Gn,n=t?.maxDataLength??4194304;function*o(i){Lc(i,n);let s=e(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}return qn(r)?async function*(){for await(let i of r)yield*o(i)}():function*(){for(let i of r)yield*o(i)}()}jn.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??Gn,n=t?.maxDataLength??4194304;return Lc(r,n),new gt(e(r.byteLength),r)};var Ne;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Ne||(Ne={}));var hi=r=>{let t=le(r);return hi.bytes=ft(t),t};hi.bytes=0;function Kr(r,t){let e=new gt,n=Ne.LENGTH,o=-1,i=t?.lengthDecoder??hi,s=t?.maxLengthLength??8,c=t?.maxDataLength??4194304;function*a(){for(;e.byteLength>0;){if(n===Ne.LENGTH)try{if(o=i(e),o<0)throw new Hn("Invalid message length");if(o>c)throw new er("Message length too long");let l=i.bytes;e.consume(l),t?.onLength!=null&&t.onLength(o),n=Ne.DATA}catch(l){if(l instanceof RangeError){if(e.byteLength>s)throw new zn("Message length length too long");break}throw l}if(n===Ne.DATA){if(e.byteLength<o)break;let l=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(l),yield l,n=Ne.LENGTH}}}return qn(r)?async function*(){for await(let l of r)e.append(l),yield*a();if(e.byteLength>0)throw new Fr("Unexpected end of input")}():function*(){for(let l of r)e.append(l),yield*a();if(e.byteLength>0)throw new Fr("Unexpected end of input")}()}Kr.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 Kr(n,{...t??{},onLength:i=>{e=i}})};var Pc="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var rr=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)t+=Pc[e[r]&63];return t};var Zn=class extends Error{constructor(t="Method not found"){super(t),this.name="MethodNotFoundError"}},Yn=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidMethodError"}},Vr=class extends Error{constructor(t="Unsupported value type"){super(t),this.name="UnsupportedValueTypeError"}},Wn=class extends Error{constructor(t="Cannot reuse RPC target name"){super(t),this.name="DuplicateTargetNameError"}},Hr=class extends Error{constructor(t="Duplicate scope"){super(t),this.name="DuplicateScopeError"}},Xn=class extends Error{constructor(t="Invalid return type"){super(t),this.name="InvalidReturnTypeError"}},zr=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidInvocationTypeError"}},nr=class extends Error{constructor(t="Parent invocation scope not found"){super(t),this.name="MissingParentScopeError"}},Qn=class extends Error{constructor(t="Invocation not found"){super(t),this.name="MissingInvocationError"}},Jn=class extends Error{constructor(t="Callback not found"){super(t),this.name="MissingCallbackError"}};var pi=new Float32Array([-0]),Ie=new Uint8Array(pi.buffer);function Dc(r,t,e){pi[0]=r,t[e]=Ie[0],t[e+1]=Ie[1],t[e+2]=Ie[2],t[e+3]=Ie[3]}function Nc(r,t){return Ie[0]=r[t],Ie[1]=r[t+1],Ie[2]=r[t+2],Ie[3]=r[t+3],pi[0]}var mi=new Float64Array([-0]),At=new Uint8Array(mi.buffer);function Rc(r,t,e){mi[0]=r,t[e]=At[0],t[e+1]=At[1],t[e+2]=At[2],t[e+3]=At[3],t[e+4]=At[4],t[e+5]=At[5],t[e+6]=At[6],t[e+7]=At[7]}function Mc(r,t){return At[0]=r[t],At[1]=r[t+1],At[2]=r[t+2],At[3]=r[t+3],At[4]=r[t+4],At[5]=r[t+5],At[6]=r[t+6],At[7]=r[t+7],mi[0]}var Ed=BigInt(Number.MAX_SAFE_INTEGER),vd=BigInt(Number.MIN_SAFE_INTEGER),Mt=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Re;if(t<Ed&&t>vd)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>Oc&&(o=0n,++n>Oc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return Re;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):Re}},Re=new Mt(0,0);Re.toBigInt=function(){return 0n};Re.zzEncode=Re.zzDecode=function(){return this};Re.length=function(){return 1};var Oc=4294967296n;function Fc(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 Kc(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 gi(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 to(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var yi=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 to(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Jt(this,4);return to(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Jt(this,4);let t=Nc(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 Kc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Jt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Jt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Mt(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Jt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Jt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Jt(this,8);let t=to(this.buf,this.pos+=4),e=to(this.buf,this.pos+=4);return new Mt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=di(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 xi(r){return new yi(r instanceof Uint8Array?r:r.subarray())}function _t(r,t,e){let n=xi(r);return t.decode(n,void 0,e)}var bi={};Dt(bi,{base10:()=>Sd});var Sd=Se({prefix:"9",name:"base10",alphabet:"0123456789"});var wi={};Dt(wi,{base16:()=>Ad,base16upper:()=>_d});var Ad=it({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_d=it({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ei={};Dt(Ei,{base2:()=>Id});var Id=it({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var vi={};Dt(vi,{base256emoji:()=>Ud});var Hc=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}"),Cd=Hc.reduce((r,t,e)=>(r[e]=t,r),[]),Bd=Hc.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function kd(r){return r.reduce((t,e)=>(t+=Cd[e],t),"")}function Td(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Bd[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Ud=We({prefix:"\u{1F680}",name:"base256emoji",encode:kd,decode:Td});var Si={};Dt(Si,{base36:()=>qr,base36upper:()=>Ld});var qr=Se({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ld=Se({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ai={};Dt(Ai,{base8:()=>Pd});var Pd=it({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var _i={};Dt(_i,{identity:()=>Dd});var Dd=We({prefix:"\0",name:"identity",encode:r=>tc(r),decode:r=>Js(r)});var iy=new TextEncoder,sy=new TextDecoder;var Ci={};Dt(Ci,{identity:()=>te});var Md=$c,zc=128,Od=127,Fd=~Od,Kd=Math.pow(2,31);function $c(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Kd;)t[e++]=r&255|zc,r/=128;for(;r&Fd;)t[e++]=r&255|zc,r>>>=7;return t[e]=r|0,$c.bytes=e-n+1,t}var Vd=Ii,Hd=128,qc=127;function Ii(r,n){var e=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw Ii.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&qc)<<o:(s&qc)*Math.pow(2,o),o+=7}while(s>=Hd);return Ii.bytes=i-n,e}var zd=Math.pow(2,7),qd=Math.pow(2,14),$d=Math.pow(2,21),Gd=Math.pow(2,28),jd=Math.pow(2,35),Zd=Math.pow(2,42),Yd=Math.pow(2,49),Wd=Math.pow(2,56),Xd=Math.pow(2,63),Qd=function(r){return r<zd?1:r<qd?2:r<$d?3:r<Gd?4:r<jd?5:r<Zd?6:r<Yd?7:r<Wd?8:r<Xd?9:10},Jd={encode:Md,decode:Vd,encodingLength:Qd},th=Jd,$r=th;function Gr(r,t=0){return[$r.decode(r,t),$r.decode.bytes]}function or(r,t,e=0){return $r.encode(r,t,e),t}function ir(r){return $r.encodingLength(r)}function Me(r,t){let e=t.byteLength,n=ir(r),o=n+ir(e),i=new Uint8Array(o+e);return or(r,i,0),or(e,i,n),i.set(t,o),new sr(r,e,t,i)}function fe(r){let t=ue(r),[e,n]=Gr(t),[o,i]=Gr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new sr(e,o,s,t)}function Gc(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Qs(r.bytes,e.bytes)}}var sr=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var jc=0,eh="identity",Zc=ue;function rh(r){return Me(jc,Zc(r))}var te={code:jc,name:eh,encode:Zc,digest:rh};var Ti={};Dt(Ti,{sha256:()=>jr,sha512:()=>nh});function ki({name:r,code:t,encode:e}){return new Bi(r,t,e)}var Bi=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?Me(this.code,e):e.then(n=>Me(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Wc(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var jr=ki({name:"sha2-256",code:18,encode:Wc("SHA-256")}),nh=ki({name:"sha2-512",code:19,encode:Wc("SHA-512")});function Xc(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return ih(e,Ui(r),t??et.encoder);default:return sh(e,Ui(r),t??Wt.encoder)}}var Qc=new WeakMap;function Ui(r){let t=Qc.get(r);if(t==null){let e=new Map;return Qc.set(r,e),e}return t}var ct=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Zr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==ch)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=Me(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&&Gc(t.multihash,n.multihash)}toString(t){return Xc(this,t)}toJSON(){return{"/":Xc(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??Jc(n,o,i.bytes))}else if(e[ah]===!0){let{version:n,multihash:o,code:i}=e,s=fe(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=Jc(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=ue(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new sr(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]=Gr(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]=oh(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 Ui(i).set(n,t),i}};function oh(r,t){switch(r[0]){case"Q":{let e=t??et;return[et.prefix,e.decode(`${et.prefix}${r}`)]}case et.prefix:{let e=t??et;return[et.prefix,e.decode(r)]}case Wt.prefix:{let e=t??Wt;return[Wt.prefix,e.decode(r)]}case qr.prefix:{let e=t??qr;return[qr.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 ih(r,t,e){let{prefix:n}=e;if(n!==et.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function sh(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,ch=18;function Jc(r,t,e){let n=ir(r),o=n+ir(t),i=new Uint8Array(o+e.byteLength);return or(r,i,0),or(t,i,n),i.set(e,o),i}var ah=Symbol.for("@ipld/js-cid/CID");var Yr={..._i,...Ei,...Ai,...bi,...wi,...Xo,...Si,...Qo,...Jo,...vi},By={...Ti,...Ci};function ea(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var ta=ea("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Li=ea("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=vt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),uh={utf8:ta,"utf-8":ta,hex:Yr.base16,latin1:Li,ascii:Li,binary:Li,...Yr},ro=uh;function Gt(r,t="utf8"){let e=ro[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Pi(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return vt(s);o+s>t&&(n=vt(t),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Oe=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Di(){}var Ri=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},lh=Pi();function fh(r){return globalThis.Buffer!=null?vt(r):lh(r)}var Xr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Oe(Di,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Oe(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Mi((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(no,10,Mt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Mt.fromBigInt(t);return this._push(no,e.length(),e)}uint64Number(t){return this._push(fi,ft(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=Mt.fromBigInt(t).zzEncode();return this._push(no,e.length(),e)}sint64Number(t){let e=Mt.fromNumber(t).zzEncode();return this._push(no,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Ni,1,t?1:0)}fixed32(t){return this._push(Wr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Mt.fromBigInt(t);return this._push(Wr,4,e.lo)._push(Wr,4,e.hi)}fixed64Number(t){let e=Mt.fromNumber(t);return this._push(Wr,4,e.lo)._push(Wr,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Dc,4,t)}double(t){return this._push(Rc,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Ni,1,0):this.uint32(e)._push(hh,e,t)}string(t){let e=Fc(t);return e!==0?this.uint32(e)._push(gi,e,t):this._push(Ni,1,0)}fork(){return this.states=new Ri(this),this.head=this.tail=new Oe(Di,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 Oe(Di,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=fh(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Ni(r,t,e){t[e]=r&255}function dh(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Mi=class extends Oe{next;constructor(t,e){super(dh,t,e),this.next=void 0}};function no(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Wr(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function hh(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Xr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(ph,t,r),this},Xr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(mh,t,r),this});function ph(r,t,e){t.set(r,e)}function mh(r,t,e){r.length<40?gi(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Gt(r),e)}function Oi(){return new Xr}function It(r,t){let e=Oi();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var cr;(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"})(cr||(cr={}));function oo(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Qr(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 oo("enum",cr.VARINT,e,n)}function Ct(r,t){return oo("message",cr.LENGTH_DELIMITED,r,t)}var de=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var $;(function(r){r.invokeMethod="invokeMethod",r.methodResolved="methodResolved",r.methodRejected="methodRejected",r.invokeGeneratorMethod="invokeGeneratorMethod",r.abortMethodInvocation="abortMethodInvocation",r.invokeCallback="invokeCallback",r.callbackResolved="callbackResolved",r.callbackRejected="callbackRejected",r.abortCallbackInvocation="abortCallbackInvocation"})($||($={}));var io;(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"})(io||(io={}));(function(r){r.codec=()=>Qr(io)})($||($={}));var Lt;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.type!=null&&e.type!==0&&(n.uint32(8),n.uint32(e.type)),e.value!=null&&(n.uint32(18),n.bytes(e.value)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={type:0},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.type=e.uint32();break}case 2:{i.value=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Lt||(Lt={}));var Bt;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.type!=null&&io[e.type]!==0&&(n.uint32(8),$.codec().encode(e.type,n)),e.message!=null&&e.message.byteLength>0&&(n.uint32(18),n.bytes(e.message)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={type:$.invokeMethod,message:Qt(0)},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.type=$.codec().decode(e);break}case 2:{i.message=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Bt||(Bt={}));var Fe;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.path!=null&&e.path!==""&&(n.uint32(18),n.string(e.path)),e.args!=null)for(let i of e.args)n.uint32(26),Lt.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",path:"",args:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.path=e.string();break}case 3:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new de('Decode error - map field "args" had too many elements');i.args.push(Lt.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Fe||(Fe={}));var Jr;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Jr||(Jr={}));var ar;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.value!=null&&(n.uint32(18),Lt.codec().encode(e.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.value=Lt.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(ar||(ar={}));var tn;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.error!=null&&(n.uint32(18),Lt.codec().encode(e.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.error=Lt.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(tn||(tn={}));var ur;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);if(e.callback!=null&&e.callback!==""&&(n.uint32(26),n.string(e.callback)),e.args!=null)for(let i of e.args)n.uint32(34),Lt.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[],callback:"",args:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new de('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 de('Decode error - map field "args" had too many elements');i.args.push(Lt.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(ur||(ur={}));var lr;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new de('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(lr||(lr={}));var en;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);e.value!=null&&(n.uint32(26),Lt.codec().encode(e.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new de('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.value=Lt.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(en||(en={}));var rn;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);e.error!=null&&(n.uint32(26),Lt.codec().encode(e.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new de('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.error=Lt.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(rn||(rn={}));function gh(r){return r.parents!=null}function ra(r,t){if(gh(r))return yh(r.parents,t);let e=t.get(r.scope);if(e==null)throw new Qn;return e}function yh(r,t){let e;for(let n of r){if(e==null){if(e=t.get(n),e==null)throw new nr;continue}if(e=e.children.get(n),e==null)throw new nr}if(e==null)throw new nr;return e}var xh={type:1024,canEncode:r=>r===void 0,decode:()=>{}},na=xh;var bh={type:1025,canEncode:r=>r===null,decode:()=>null},oa=bh;var wh=["string","number","bigint","symbol"],Eh=["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 ia(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let t=typeof r;if(wh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(r))return"Array";if(vh(r))return"Buffer";let e=Sh(r);return e||"Object"}function vh(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Sh(r){let t=Object.prototype.toString.call(r).slice(8,-1);if(Eh.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 B=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 fr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Ah=new TextDecoder,_h=new TextEncoder;function so(r){return fr&&globalThis.Buffer.isBuffer(r)}function Fi(r){return r instanceof Uint8Array?so(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var ua=fr?(r,t,e)=>e-t>64?globalThis.Buffer.from(r.subarray(t,e)).toString("utf8"):ca(r,t,e):(r,t,e)=>e-t>64?Ah.decode(r.subarray(t,e)):ca(r,t,e),la=fr?r=>r.length>64?globalThis.Buffer.from(r):sa(r):r=>r.length>64?_h.encode(r):sa(r),ie=r=>Uint8Array.from(r),dr=fr?(r,t,e)=>so(r)?new Uint8Array(r.subarray(t,e)):r.slice(t,e):(r,t,e)=>r.slice(t,e),fa=fr?(r,t)=>(r=r.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),Fi(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},da=fr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function ha(r,t){if(so(r)&&so(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 sa(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 ca(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 Ih(n)}var aa=4096;function Ih(r){let t=r.length;if(t<=aa)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=aa));return e}var Ch=256,nn=class{constructor(t=Ch){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=da(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=dr(n,0,this.cursor)}else e=fa(this.chunks,this.cursor);return t&&this.reset(),e}};var O="CBOR decode error:",Ki="CBOR encode error:",on=[];on[23]=1;on[24]=2;on[25]=3;on[26]=5;on[27]=9;function he(r,t,e){if(r.length-t<e)throw new Error(`${O} not enough data for type`)}var dt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ot(r,t,e){he(r,t,1);let n=r[t];if(e.strict===!0&&n<dt[0])throw new Error(`${O} integer encoded in more bytes than necessary (strict decode)`);return n}function Ft(r,t,e){he(r,t,2);let n=r[t]<<8|r[t+1];if(e.strict===!0&&n<dt[1])throw new Error(`${O} integer encoded in more bytes than necessary (strict decode)`);return n}function Kt(r,t,e){he(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(`${O} integer encoded in more bytes than necessary (strict decode)`);return n}function Vt(r,t,e){he(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(`${O} 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(`${O} integers outside of the safe integer range are not supported`)}function pa(r,t,e,n){return new B(p.uint,Ot(r,t+1,n),2)}function ma(r,t,e,n){return new B(p.uint,Ft(r,t+1,n),3)}function ga(r,t,e,n){return new B(p.uint,Kt(r,t+1,n),5)}function ya(r,t,e,n){return new B(p.uint,Vt(r,t+1,n),9)}function jt(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(`${O} encountered BigInt larger than allowable range`)}}jt.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};jt.compareTokens=function(t,e){return t.value<e.value?-1:t.value>e.value?1:0};function xa(r,t,e,n){return new B(p.negint,-1-Ot(r,t+1,n),2)}function ba(r,t,e,n){return new B(p.negint,-1-Ft(r,t+1,n),3)}function wa(r,t,e,n){return new B(p.negint,-1-Kt(r,t+1,n),5)}var Vi=BigInt(-1),Ea=BigInt(1);function va(r,t,e,n){let o=Vt(r,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new B(p.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${O} integers outside of the safe integer range are not supported`);return new B(p.negint,Vi-BigInt(o),9)}function co(r,t){let e=t.value,n=typeof e=="bigint"?e*Vi-Ea:e*-1-1;yt(r,t.type.majorEncoded,n)}co.encodedSize=function(t){let e=t.value,n=typeof e=="bigint"?e*Vi-Ea:e*-1-1;return n<dt[0]?1:n<dt[1]?2:n<dt[2]?3:n<dt[3]?5:9};co.compareTokens=function(t,e){return t.value<e.value?1:t.value>e.value?-1:0};function sn(r,t,e,n){he(r,t,e+n);let o=dr(r,t+e,t+e+n);return new B(p.bytes,o,e+n)}function Sa(r,t,e,n){return sn(r,t,1,e)}function Aa(r,t,e,n){return sn(r,t,2,Ot(r,t+1,n))}function _a(r,t,e,n){return sn(r,t,3,Ft(r,t+1,n))}function Ia(r,t,e,n){return sn(r,t,5,Kt(r,t+1,n))}function Ca(r,t,e,n){let o=Vt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${O} 64-bit integer bytes lengths not supported`);return sn(r,t,9,o)}function ao(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===p.string?la(r.value):r.value),r.encodedBytes}function hr(r,t){let e=ao(t);yt(r,t.type.majorEncoded,e.length),r.push(e)}hr.encodedSize=function(t){let e=ao(t);return yt.encodedSize(e.length)+e.length};hr.compareTokens=function(t,e){return kh(ao(t),ao(e))};function kh(r,t){return r.length<t.length?-1:r.length>t.length?1:ha(r,t)}function cn(r,t,e,n,o){let i=e+n;he(r,t,i);let s=new B(p.string,ua(r,t+e,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=dr(r,t+e,t+i)),s}function Ba(r,t,e,n){return cn(r,t,1,e,n)}function ka(r,t,e,n){return cn(r,t,2,Ot(r,t+1,n),n)}function Ta(r,t,e,n){return cn(r,t,3,Ft(r,t+1,n),n)}function Ua(r,t,e,n){return cn(r,t,5,Kt(r,t+1,n),n)}function La(r,t,e,n){let o=Vt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${O} 64-bit integer string lengths not supported`);return cn(r,t,9,o,n)}var Pa=hr;function pr(r,t,e,n){return new B(p.array,n,e)}function Da(r,t,e,n){return pr(r,t,1,e)}function Na(r,t,e,n){return pr(r,t,2,Ot(r,t+1,n))}function Ra(r,t,e,n){return pr(r,t,3,Ft(r,t+1,n))}function Ma(r,t,e,n){return pr(r,t,5,Kt(r,t+1,n))}function Oa(r,t,e,n){let o=Vt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${O} 64-bit integer array lengths not supported`);return pr(r,t,9,o)}function Fa(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${O} indefinite length items not allowed`);return pr(r,t,1,1/0)}function uo(r,t){yt(r,p.array.majorEncoded,t.value)}uo.compareTokens=jt.compareTokens;uo.encodedSize=function(t){return yt.encodedSize(t.value)};function mr(r,t,e,n){return new B(p.map,n,e)}function Ka(r,t,e,n){return mr(r,t,1,e)}function Va(r,t,e,n){return mr(r,t,2,Ot(r,t+1,n))}function Ha(r,t,e,n){return mr(r,t,3,Ft(r,t+1,n))}function za(r,t,e,n){return mr(r,t,5,Kt(r,t+1,n))}function qa(r,t,e,n){let o=Vt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${O} 64-bit integer map lengths not supported`);return mr(r,t,9,o)}function $a(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${O} indefinite length items not allowed`);return mr(r,t,1,1/0)}function lo(r,t){yt(r,p.map.majorEncoded,t.value)}lo.compareTokens=jt.compareTokens;lo.encodedSize=function(t){return yt.encodedSize(t.value)};function Ga(r,t,e,n){return new B(p.tag,e,1)}function ja(r,t,e,n){return new B(p.tag,Ot(r,t+1,n),2)}function Za(r,t,e,n){return new B(p.tag,Ft(r,t+1,n),3)}function Ya(r,t,e,n){return new B(p.tag,Kt(r,t+1,n),5)}function Wa(r,t,e,n){return new B(p.tag,Vt(r,t+1,n),9)}function fo(r,t){yt(r,p.tag.majorEncoded,t.value)}fo.compareTokens=jt.compareTokens;fo.encodedSize=function(t){return yt.encodedSize(t.value)};var Nh=20,Rh=21,Mh=22,Oh=23;function Xa(r,t,e,n){if(n.allowUndefined===!1)throw new Error(`${O} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new B(p.null,null,1):new B(p.undefined,void 0,1)}function Qa(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${O} indefinite length items not allowed`);return new B(p.break,void 0,1)}function Hi(r,t,e){if(e){if(e.allowNaN===!1&&Number.isNaN(r))throw new Error(`${O} NaN values are not supported`);if(e.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${O} Infinity values are not supported`)}return new B(p.float,r,t)}function Ja(r,t,e,n){return Hi(zi(r,t+1),3,n)}function tu(r,t,e,n){return Hi(qi(r,t+1),5,n)}function eu(r,t,e,n){return Hi(iu(r,t+1),9,n)}function ho(r,t,e){let n=t.value;if(n===!1)r.push([p.float.majorEncoded|Nh]);else if(n===!0)r.push([p.float.majorEncoded|Rh]);else if(n===null)r.push([p.float.majorEncoded|Mh]);else if(n===void 0)r.push([p.float.majorEncoded|Oh]);else{let o,i=!1;(!e||e.float64!==!0)&&(nu(n),o=zi(ee,1),n===o||Number.isNaN(n)?(ee[0]=249,r.push(ee.slice(0,3)),i=!0):(ou(n),o=qi(ee,1),n===o&&(ee[0]=250,r.push(ee.slice(0,5)),i=!0))),i||(Fh(n),o=iu(ee,1),ee[0]=251,r.push(ee.slice(0,9)))}}ho.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){nu(n);let o=zi(ee,1);if(n===o||Number.isNaN(n))return 3;if(ou(n),o=qi(ee,1),n===o)return 5}return 9};var ru=new ArrayBuffer(9),Zt=new DataView(ru,1),ee=new Uint8Array(ru,0);function nu(r){if(r===1/0)Zt.setUint16(0,31744,!1);else if(r===-1/0)Zt.setUint16(0,64512,!1);else if(Number.isNaN(r))Zt.setUint16(0,32256,!1);else{Zt.setFloat32(0,r);let t=Zt.getUint32(0),e=(t&2139095040)>>23,n=t&8388607;if(e===255)Zt.setUint16(0,31744,!1);else if(e===0)Zt.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=e-127;o<-24?Zt.setUint16(0,0):o<-14?Zt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Zt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function zi(r,t){if(r.length-t<2)throw new Error(`${O} 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 ou(r){Zt.setFloat32(0,r,!1)}function qi(r,t){if(r.length-t<4)throw new Error(`${O} not enough data for float32`);let e=(r.byteOffset||0)+t;return new DataView(r.buffer,e,4).getFloat32(0,!1)}function Fh(r){Zt.setFloat64(0,r,!1)}function iu(r,t){if(r.length-t<8)throw new Error(`${O} not enough data for float64`);let e=(r.byteOffset||0)+t;return new DataView(r.buffer,e,8).getFloat64(0,!1)}ho.compareTokens=jt.compareTokens;function G(r,t,e){throw new Error(`${O} encountered invalid minor (${e}) for major ${r[t]>>>5}`)}function po(r){return()=>{throw new Error(`${O} ${r}`)}}var C=[];for(let r=0;r<=23;r++)C[r]=G;C[24]=pa;C[25]=ma;C[26]=ga;C[27]=ya;C[28]=G;C[29]=G;C[30]=G;C[31]=G;for(let r=32;r<=55;r++)C[r]=G;C[56]=xa;C[57]=ba;C[58]=wa;C[59]=va;C[60]=G;C[61]=G;C[62]=G;C[63]=G;for(let r=64;r<=87;r++)C[r]=Sa;C[88]=Aa;C[89]=_a;C[90]=Ia;C[91]=Ca;C[92]=G;C[93]=G;C[94]=G;C[95]=po("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)C[r]=Ba;C[120]=ka;C[121]=Ta;C[122]=Ua;C[123]=La;C[124]=G;C[125]=G;C[126]=G;C[127]=po("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)C[r]=Da;C[152]=Na;C[153]=Ra;C[154]=Ma;C[155]=Oa;C[156]=G;C[157]=G;C[158]=G;C[159]=Fa;for(let r=160;r<=183;r++)C[r]=Ka;C[184]=Va;C[185]=Ha;C[186]=za;C[187]=qa;C[188]=G;C[189]=G;C[190]=G;C[191]=$a;for(let r=192;r<=215;r++)C[r]=Ga;C[216]=ja;C[217]=Za;C[218]=Ya;C[219]=Wa;C[220]=G;C[221]=G;C[222]=G;C[223]=G;for(let r=224;r<=243;r++)C[r]=po("simple values are not supported");C[244]=G;C[245]=G;C[246]=G;C[247]=Xa;C[248]=po("simple values are not supported");C[249]=Ja;C[250]=tu;C[251]=eu;C[252]=G;C[253]=G;C[254]=G;C[255]=Qa;var re=[];for(let r=0;r<24;r++)re[r]=new B(p.uint,r,1);for(let r=-1;r>=-24;r--)re[31-r]=new B(p.negint,r,1);re[64]=new B(p.bytes,new Uint8Array(0),1);re[96]=new B(p.string,"",1);re[128]=new B(p.array,0,1);re[160]=new B(p.map,0,1);re[244]=new B(p.false,!1,1);re[245]=new B(p.true,!0,1);re[246]=new B(p.null,null,1);function su(r){switch(r.type){case p.false:return ie([244]);case p.true:return ie([245]);case p.null:return ie([246]);case p.bytes:return r.value.length?void 0:ie([64]);case p.string:return r.value===""?ie([96]):void 0;case p.array:return r.value===0?ie([128]):void 0;case p.map:return r.value===0?ie([160]):void 0;case p.uint:return r.value<24?ie([Number(r.value)]):void 0;case p.negint:if(r.value>=-24)return ie([31-Number(r.value)])}}var Vh={float64:!1,mapSorter:qh,quickEncodeToken:su};function Hh(){let r=[];return r[p.uint.major]=jt,r[p.negint.major]=co,r[p.bytes.major]=hr,r[p.string.major]=Pa,r[p.array.major]=uo,r[p.map.major]=lo,r[p.tag.major]=fo,r[p.float.major]=ho,r}var cu=Hh(),$i=new nn,go=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(`${Ki} object contains circular references`);return new r(e,t)}},Be={null:new B(p.null,null),undefined:new B(p.undefined,void 0),true:new B(p.true,!0),false:new B(p.false,!1),emptyArray:new B(p.array,0),emptyMap:new B(p.map,0)},ke={number(r,t,e,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new B(p.float,r):r>=0?new B(p.uint,r):new B(p.negint,r)},bigint(r,t,e,n){return r>=BigInt(0)?new B(p.uint,r):new B(p.negint,r)},Uint8Array(r,t,e,n){return new B(p.bytes,r)},string(r,t,e,n){return new B(p.string,r)},boolean(r,t,e,n){return r?Be.true:Be.false},null(r,t,e,n){return Be.null},undefined(r,t,e,n){return Be.undefined},ArrayBuffer(r,t,e,n){return new B(p.bytes,new Uint8Array(r))},DataView(r,t,e,n){return new B(p.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,t,e,n){if(!r.length)return e.addBreakTokens===!0?[Be.emptyArray,new B(p.break)]:Be.emptyArray;n=go.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=mo(s,e,n);return e.addBreakTokens?[new B(p.array,r.length),o,new B(p.break)]:[new B(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?[Be.emptyMap,new B(p.break)]:Be.emptyMap;n=go.createCheck(n,r);let c=[],a=0;for(let l of i)c[a++]=[mo(l,e,n),mo(o?r.get(l):r[l],e,n)];return zh(c,e),e.addBreakTokens?[new B(p.map,s),c,new B(p.break)]:[new B(p.map,s),c]}};ke.Map=ke.Object;ke.Buffer=ke.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))ke[`${r}Array`]=ke.DataView;function mo(r,t={},e){let n=ia(r),o=t&&t.typeEncoders&&t.typeEncoders[n]||ke[n];if(typeof o=="function"){let s=o(r,n,t,e);if(s!=null)return s}let i=ke[n];if(!i)throw new Error(`${Ki} unsupported type: ${n}`);return i(r,n,t,e)}function zh(r,t){t.mapSorter&&r.sort(t.mapSorter)}function qh(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=cu[o].compareTokens(e,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function au(r,t,e,n){if(Array.isArray(t))for(let o of t)au(r,o,e,n);else e[t.type.major](r,t,n)}function $h(r,t,e){let n=mo(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 nn(s);if(i(c,n,e),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Fi(c.chunks[0])}}return $i.reset(),au($i,n,t,e),$i.toBytes(!0)}function X(r,t){return t=Object.assign({},Vh,t),$h(r,cu,t)}var Gh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},yo=class{constructor(t,e={}){this._pos=0,this.data=t,this.options=e}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],e=re[t];if(e===void 0){let n=C[t];if(!n)throw new Error(`${O} 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}},an=Symbol.for("DONE"),xo=Symbol.for("BREAK");function jh(r,t,e){let n=[];for(let o=0;o<r.value;o++){let i=gr(t,e);if(i===xo){if(r.value===1/0)break;throw new Error(`${O} got unexpected break to lengthed array`)}if(i===an)throw new Error(`${O} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Zh(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=gr(t,e);if(c===xo){if(r.value===1/0)break;throw new Error(`${O} got unexpected break to lengthed map`)}if(c===an)throw new Error(`${O} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${O} non-string keys not supported (got ${typeof c})`);if(e.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${O} found repeat map key "${c}"`);let a=gr(t,e);if(a===an)throw new Error(`${O} 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 gr(r,t){if(r.done())return an;let e=r.next();if(e.type===p.break)return xo;if(e.type.terminal)return e.value;if(e.type===p.array)return jh(e,r,t);if(e.type===p.map)return Zh(e,r,t);if(e.type===p.tag){if(t.tags&&typeof t.tags[e.value]=="function"){let n=gr(r,t);return t.tags[e.value](n)}throw new Error(`${O} tag not supported (${e.value})`)}throw new Error("unsupported")}function uu(r,t){if(!(r instanceof Uint8Array))throw new Error(`${O} data to decode must be a Uint8Array`);t=Object.assign({},Gh,t);let e=t.tokenizer||new yo(r,t),n=gr(e,t);if(n===an)throw new Error(`${O} did not find any content to decode`);if(n===xo)throw new Error(`${O} got unexpected break`);return[n,r.subarray(e.pos())]}function Q(r,t){let[e,n]=uu(r,t);if(n.length>0)throw new Error(`${O} too many terminals, data makes no sense`);return e}var Yh={type:1026,canEncode:r=>r===!0||r===!1,encode:r=>X(r),decode:r=>Q(r)},lu=Yh;var Wh={type:1027,canEncode:r=>typeof r=="number"&&!isNaN(r),encode:r=>X(r),decode:r=>Q(r)},fu=Wh;var Xh={type:1028,canEncode:r=>typeof r=="string",encode:r=>X(r),decode:r=>Q(r)},du=Xh;var Qh={type:1029,canEncode:r=>Array.isArray(r),encode:(r,t,e,n)=>X(r.map(o=>t.toValue(o,e,n))),decode:(r,t,e,n)=>Q(r).map(o=>t.fromValue(o,e,n))},hu=Qh;var Jh={type:1030,canEncode:r=>typeof r=="function",encode:(r,t,e,n)=>{let o=rr();return n?.callbacks.set(o,{context:e,fn:r}),X(o)},decode:(r,t,e,n)=>async(...o)=>new Promise((i,s)=>{let c=Q(r),a=rr(),l={scope:a,result:Et(),callbacks:new Map,children:new Map,parents:[...n.parents,n.scope],abortControllers:[],abortSignals:[]};n.children.set(a,l),o=o.map(f=>t.toValue(f,null,l));let u=Fn(l.abortSignals);u.addEventListener("abort",()=>{e.push(Bt.encode({type:$.abortCallbackInvocation,message:lr.encode({scope:a,parents:l.parents})}))}),e.push(Bt.encode({type:$.invokeCallback,message:ur.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()})})},pu=Jh;var tp={type:1031,canEncode:r=>r.toString()==="NaN"&&isNaN(r),decode:()=>NaN},mu=tp;var ep={type:1032,canEncode:r=>r instanceof Error,encode:r=>X({message:r.message,name:r.name,code:r.code,type:r.type,stack:r.stack}),decode:r=>{let t=Q(r),e=new Error(t.message);return e.name=t.name,e.stack=t.stack,e.code=t.code,e.type=t.type,e}},gu=ep;var rp={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")}},yu=rp;var xu=["__defineGetter__","__defineSetter__","hasOwnProperty","__lookupGetter__","__lookupSetter__","isPrototypeOf","propertyIsEnumerable","toString","valueOf","__proto__","toLocaleString","constructor"],np={type:2147483647,canEncode:r=>typeof r=="object",encode:(r,t,e,n)=>{let o={};for(let i in r)xu.includes(i)||Object.hasOwn(r,i)&&(o[i]=r[i]);for(let i of Object.getOwnPropertyNames(Object.getPrototypeOf(r)))xu.includes(i)||(o[i]=r[i]);return X([...Object.entries(o)].map(([i,s])=>[t.toValue(i,r,n),t.toValue(s,r,n)]))},decode:(r,t,e,n)=>{let o={};return Q(r).forEach(([s,c])=>{o[t.fromValue(s,e,n)]=t.fromValue(c,e,n)}),o}},un=np;var op={type:1034,canEncode:r=>typeof r.next=="function"&&typeof r.throw=="function"&&typeof r.return=="function",encode:(r,t,e,n)=>un.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=un.decode(r,t,e,n);return o[Symbol.asyncIterator]=()=>o,o}},bu=op;var ip={type:1035,canEncode:r=>typeof r=="bigint",encode:r=>X(r),decode:r=>BigInt(Q(r))},wu=ip;var sp={type:1036,canEncode:r=>r instanceof Map,encode:(r,t,e,n)=>X([...r.entries()].map(([o,i])=>[t.toValue(o,e,n),t.toValue(i,e,n)])),decode:(r,t,e,n)=>{let o=new Map;return Q(r).forEach(([s,c])=>{let a=t.fromValue(s,e,n),l=t.fromValue(c,e,n);o.set(a,l)}),o}},Eu=sp;var cp={type:1037,canEncode:r=>r instanceof Set,encode:(r,t,e,n)=>X([...r.values()].map(o=>t.toValue(o,e,n))),decode:(r,t,e,n)=>{let o=new Set;return Q(r).forEach(s=>{o.add(t.fromValue(s,e,n))}),o}},vu=cp;var ap={type:1038,canEncode:r=>r instanceof Uint8Array,encode:r=>r,decode:r=>r},Su=ap;var up={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}},Au=up;var lp={type:1040,canEncode:r=>r instanceof Date,encode:r=>X(r.toString()),decode:r=>new Date(Q(r))},_u=lp;var fp={type:1041,canEncode:r=>r instanceof RegExp,encode:r=>X({source:r.source,flags:r.flags}),decode:r=>{let{source:t,flags:e}=Q(r);return new RegExp(t,e)}},Iu=fp;var Cu=[na,oa,lu,fu,du,hu,pu,mu,gu,yu,bu,wu,Eu,vu,Su,Au,_u,Iu,un];var bo=class{transformersMap;transformersList;constructor(t){this.transformersList=[...Cu,...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 Vr(`Unsupported value type "${t}"`)}fromValue(t,e,n){let o=this.transformersMap[t.type];if(o==null)throw new Vr(`Unsupported value type "${t.type}"`);return o.decode(t.value??new Uint8Array(0),this,e,n)}};function dp(r){return r.isScope===!0}function hp(r){return r.type===$.invokeMethod||r.type===$.invokeGeneratorMethod||r.type===$.invokeCallback}var Gi=class{source;output;targets;invocations;values;messageHandlers;constructor(t){this.output=tr(),this.source=jn(this.output),this.targets=new Map,this.invocations=new Map,this.values=new bo(t),this.sink=this.sink.bind(this),this.messageHandlers={[$.invokeMethod]:{decoder:Fe,handler:this.handleInvokeMethod.bind(this)},[$.invokeGeneratorMethod]:{decoder:Fe,handler:this.handleInvokeGeneratorMethod.bind(this)},[$.abortMethodInvocation]:{decoder:Jr,handler:this.handleAbortMethod.bind(this),isScope:!0},[$.methodResolved]:{decoder:ar,handler:this.handleMethodResolved.bind(this),isScope:!0},[$.methodRejected]:{decoder:tn,handler:this.handleMethodRejected.bind(this),isScope:!0,isError:!0},[$.invokeCallback]:{decoder:ur,handler:this.handleInvokeCallback.bind(this),isScope:!0},[$.abortCallbackInvocation]:{decoder:lr,handler:this.handleAbortCallback.bind(this),isScope:!0},[$.callbackResolved]:{decoder:en,handler:this.handleCallbackResolved.bind(this),isScope:!0},[$.callbackRejected]:{decoder:rn,handler:this.handleCallbackRejected.bind(this),isScope:!0,isError:!0}}}async sink(t){for await(let e of Kr(t))try{let n=Bt.decode(e),o=this.messageHandlers[n.type];if(o==null)continue;let i=o.decoder.decode(n.message),s;if(dp(o))try{s=ra(i,this.invocations)}catch{continue}o.handler(i,s).catch(c=>{hp(n)&&this.sendError(i,c),this.invocations.delete(i.scope)}).finally(()=>{n.type===$.invokeMethod&&this.invocations.delete(i.scope)})}catch{continue}}sendError(t,e){t.parents!=null?this.output.push(Bt.encode({type:$.callbackRejected,message:rn.encode({scope:t.scope,parents:t.parents,error:this.values.toValue(e)})})):this.output.push(Bt.encode({type:$.methodRejected,message:tn.encode({scope:t.scope,error:this.values.toValue(e)})}))}createClient(t){return this.proxy(t)}createTarget(t,e){if(this.targets.has(t))throw new Wn(`Cannot reuse RPC target name "${t}"`);this.targets.set(t,e)}async handleInvokeMethod(t){if(this.invocations.has(t.scope))throw new Hr;let e=new Map,n=new Map,o={scope:t.scope,result:Et(),callbacks:e,children:n,parents:[],abortControllers:[],abortSignals:[]};this.invocations.set(t.scope,o);let i=this.lookupInvocationTarget(t.path),s=await i.fn.apply(i.context,t.args.map(c=>this.values.fromValue(c,this.output,o)));this.output.push(Bt.encode({type:$.methodResolved,message:ar.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 Hr;let e=new Map,n=new Map,o={scope:t.scope,result:Et(),callbacks:e,children:n,parents:[],abortControllers:[],abortSignals:[]};this.invocations.set(t.scope,o);let i=this.lookupInvocationTarget(t.path),s=i.fn.apply(i.context,t.args.map(a=>this.values.fromValue(a,this.output,o)));if(typeof s.next!="function")throw new Xn(`${t.path} did not return an async generator`);let c={next:async()=>{let a=await s.next();return a.done===!0&&this.invocations.delete(t.scope),a},throw:async a=>{try{let l=await s.throw(a);return l.done===!0&&this.invocations.delete(t.scope),l}catch(l){throw this.invocations.delete(t.scope),l}},return:async a=>{let l=await s.return(a);return l.done===!0&&this.invocations.delete(t.scope),l},[Symbol.asyncIterator]:()=>c};this.output.push(Bt.encode({type:$.methodResolved,message:ar.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 Yn(`"${t.substring(0,t.length-5)}" was not a function`):new Zn(`Could not find "${t}" on target`);if(typeof n!="function")throw new zr("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 Jn;let o=await n.fn.apply(n.context,t.args.map(i=>this.values.fromValue(i,this.output,e)));this.output.push(Bt.encode({type:$.callbackResolved,message:en.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 E=rr(),w={scope:E,result:Et(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(E,w),n.output.push(Bt.encode({type:$.invokeMethod,message:Fe.encode({scope:E,path:t,args:s.map(x=>n.values.toValue(x,null,w))})}));let g=Fn(w.abortSignals);g.addEventListener("abort",()=>{n.output.push(Bt.encode({type:$.abortMethodInvocation,message:Jr.encode({scope:E})}))}),w.result.promise.then(x=>{f(x)},x=>{h(x)}).finally(()=>{n.invocations.delete(E),g.clear()})})),a}function u(){if(c==null){let f=rr(),h={scope:f,result:Et(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(f,h),n.output.push(Bt.encode({type:$.invokeGeneratorMethod,message:Fe.encode({scope:f,path:t,args:s.map(w=>n.values.toValue(w,null,h))})}));let E;c={async next(){if(E!=null)throw E;let g=await(await h.result.promise).next();return g.done===!0&&n.invocations.delete(f),g},async throw(w){if(E!=null)throw E;try{let x=await(await h.result.promise).throw(w);return x.done===!0&&n.invocations.delete(f),x}catch(g){throw n.invocations.delete(f),E=w,g}},async return(w){if(E!=null)throw E;let x=await(await h.result.promise).return(w);return x.done===!0&&n.invocations.delete(f),x},[Symbol.asyncIterator]:()=>c}}return c}return new Proxy(e,{get(f,h,E){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 zr(`Property ${h.toString()} was not used as a promise or async generator`)}})}})}};function Bu(r){return new Gi(r)}var ku={type:4096,canEncode:r=>r.code!=null&&r.version!=null&&r.multihash!=null&&r["/"]!=null,encode:r=>r.bytes,decode:r=>ct.decode(r)};var ln=class extends Event{type;detail;constructor(t,e){super(t),this.type=t,this.detail=e}};var Tu={type:4099,canEncode:r=>r instanceof ln,encode:(r,t,e,n)=>X({type:r.type,detail:t.toValue(r.detail,e,n)}),decode:(r,t,e,n)=>{let{type:o,detail:i}=Q(r);return new ln(o,t.fromValue(i,e,n))}};function J(r,t="utf8"){let e=ro[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var wo=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,pp=15,yr=new wo;function ji(r){if(!(r.length>pp))return yr.new(r).parseWith(()=>yr.readIPv4Addr())}function Zi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Uu))return yr.new(r).parseWith(()=>yr.readIPv6Addr())}function Eo(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Uu)return;let e=yr.new(r).parseWith(()=>yr.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}var Fw=parseInt("0xFFFF",16),Kw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Du(r){return!!ji(r)}function Nu(r){return!!Zi(r)}function vo(r){return!!Eo(r)}var Ru=Du,bp=Nu,Yi=function(r){let t=0;if(r=r.toString().trim(),Ru(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(bp(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=Ru(e[n]),s;i&&(s=Yi(e[n]),e[n]=J(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,J(s.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},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 xr={},Wi={},Ep=[[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"]];Ep.forEach(r=>{let t=vp(...r);Wi[t.code]=t,xr[t.name]=t});function vp(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function tt(r){if(typeof r=="number"){if(Wi[r]!=null)return Wi[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(xr[r]!=null)return xr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var S1=tt("ip4"),A1=tt("ip6"),_1=tt("ipcidr");function ts(r,t){switch(tt(r).code){case 4:case 41:return Ap(t);case 42:return Ji(t);case 43:return J(t,"base10");case 6:case 273:case 33:case 132:return Ku(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ji(t);case 421:return Bp(t);case 444:return Fu(t);case 445:return Fu(t);case 466:return Cp(t);case 481:return globalThis.encodeURIComponent(Ji(t));default:return J(t,"base16")}}function es(r,t){switch(tt(r).code){case 4:return Ou(t);case 41:return Ou(t);case 42:return Qi(t);case 43:return Gt(t,"base10");case 6:case 273:case 33:case 132:return rs(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Qi(t);case 421:return _p(t);case 444:return kp(t);case 445:return Tp(t);case 466:return Ip(t);case 481:return Qi(globalThis.decodeURIComponent(t));default:return Gt(t,"base16")}}var Xi=Object.values(Yr).map(r=>r.decoder),Sp=function(){let r=Xi[0].or(Xi[1]);return Xi.slice(2).forEach(t=>r=r.or(t)),r}();function Ou(r){if(!vo(r))throw new Error("invalid ip address");return Yi(r)}function Ap(r){let t=Mu(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!vo(t))throw new Error("invalid ip address");return t}function rs(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Ku(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Qi(r){let t=Gt(r),e=Uint8Array.from(_e(t.length));return Nt([e,t],e.length+t.length)}function Ji(r){let t=le(r);if(r=r.slice(ft(t)),r.length!==t)throw new Error("inconsistent lengths");return J(r)}function _p(r){let t;r[0]==="Q"||r[0]==="1"?t=fe(et.decode(`z${r}`)).bytes:t=ct.parse(r).multihash.bytes;let e=Uint8Array.from(_e(t.length));return Nt([e,t],e.length+t.length)}function Ip(r){let t=Sp.decode(r),e=Uint8Array.from(_e(t.length));return Nt([e,t],e.length+t.length)}function Cp(r){let t=le(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+J(e,"base64url")}function Bp(r){let t=le(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return J(e,"base58btc")}function kp(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Wt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=rs(n);return Nt([e,o],e.length+o.length)}function Tp(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Wt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=rs(n);return Nt([e,o],e.length+o.length)}function Fu(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=J(t,"base32"),o=Ku(e);return`${n}:${o}`}function Vu(r){r=ns(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],c=tt(s);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(i++,i>=o.length)throw new So("invalid address: "+r);if(c.path===!0){n=ns(o.slice(i).join("/")),t.push([c.code,es(c.code,n)]),e.push([c.code,n]);break}let a=es(c.code,o[i]);t.push([c.code,a]),e.push([c.code,ts(c.code,a)])}return{string:Hu(e),bytes:Ao(t),tuples:t,stringTuples:e,path:n}}function os(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=le(r,o),s=ft(i),c=tt(i),a=Up(c,r.slice(o+s));if(a===0){t.push([i]),e.push([i]),o+=s;continue}let l=r.slice(o+s,o+s+a);if(o+=a+s,o>r.length)throw new So("Invalid address Uint8Array: "+J(r,"base16"));t.push([i,l]);let u=ts(i,l);if(e.push([i,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Hu(e),tuples:t,stringTuples:e,path:n}}function Hu(r){let t=[];return r.map(e=>{let n=tt(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),ns(t.join("/"))}function Ao(r){return Nt(r.map(t=>{let e=tt(t[0]),n=Uint8Array.from(_e(e.code));return t.length>1&&t[1]!=null&&(n=Nt([n,t[1]])),n}))}function Up(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=le(t instanceof Uint8Array?t:Uint8Array.from(t));return e+ft(e)}}function ns(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var So=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Lp=Symbol.for("nodejs.util.inspect.custom"),ss=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Pp=[tt("dns").code,tt("dns4").code,tt("dns6").code,tt("dnsaddr").code],is=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},_o=class r{bytes;#e;#t;#r;#n;[ss]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=os(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Vu(t)}else if(Io(t))e=os(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",s=tt("tcp"),c=tt("udp"),a=tt("ip4"),l=tt("ip6"),u=tt("dns6"),f=tt("ip6zone");for(let[E,w]of this.stringTuples())E===f.code&&(i=`%${w??""}`),Pp.includes(E)&&(e=s.name==="tcp"?"tcp":"udp",o=443,n=`${w??""}${i}`,t=E===u.code?6:4),(E===s.code||E===c.code)&&(e=tt(E).name==="tcp"?"tcp":"udp",o=parseInt(w??"")),(E===a.code||E===l.code)&&(e=tt(E).name==="tcp"?"tcp":"udp",n=`${w??""}${i}`,t=E===l.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#t.map(([t])=>Object.assign({},tt(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>tt(t).name)}tuples(){return this.#t.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Ao(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===xr.p2p.code&&t.push([n,o]),n===xr["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?J(et.decode(`z${n}`),"base58btc"):J(ct.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Rt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=zu.get(e.name);if(n==null)throw new is(`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)}[Lp](){return`Multiaddr(${this.#e})`}};var zu=new Map;function Io(r){return!!r?.[ss]}function Ve(r){return new _o(r)}var qu={type:4097,canEncode:r=>Io(r),encode:r=>r.bytes,decode:r=>Ve(r)};var Dp=parseInt("11111",2),cs=parseInt("10000000",2),Np=parseInt("01111111",2),$u={0:fn,1:fn,2:Rp,3:Fp,4:Kp,5:Op,6:Mp,16:fn,22:fn,48:fn};function as(r,t={offset:0}){let e=r[t.offset]&Dp;if(t.offset++,$u[e]!=null)return $u[e](r,t);throw new Error("No decoder for tag "+e)}function dn(r,t){let e=0;if((r[t.offset]&cs)===cs){let n=r[t.offset]&Np,o="0x";t.offset++;for(let i=0;i<n;i++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function fn(r,t){dn(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=as(r,t);if(n===null)break;e.push(n)}return e}function Rp(r,t){let e=dn(r,t),n=t.offset,o=t.offset+e,i=[];for(let s=n;s<o;s++)s===n&&r[s]===0||i.push(r[s]);return t.offset+=e,Uint8Array.from(i)}function Mp(r,t){let e=dn(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let c=`${i}.${s}`,a=[];for(;t.offset<n;){let l=r[t.offset];if(t.offset++,a.push(l&127),l<128){a.reverse();let u=0;for(let f=0;f<a.length;f++)u+=a[f]<<f*7;c+=`.${u}`,a=[]}}return c}function Op(r,t){return t.offset++,null}function Fp(r,t){let e=dn(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Kp(r,t){let e=dn(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Vp(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new gt;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function us(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Vp(r.byteLength);return new gt(Uint8Array.from([t.byteLength|cs]),t)}function Gu(r){let t=new gt,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new gt(Uint8Array.from([2]),us(t),t)}function ju(r){let t=Uint8Array.from([0]),e=new gt(t,r);return new gt(Uint8Array.from([3]),us(e),e)}function Co(r,t=48){let e=new gt;for(let n of r)e.append(n);return new gt(Uint8Array.from([t]),us(e),e)}async function Zu(r,t,e){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,e.subarray())}var Hp=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),zp=Uint8Array.from([6,5,43,129,4,0,34]),qp=Uint8Array.from([6,5,43,129,4,0,35]),$p={ext:!0,kty:"EC",crv:"P-256"},Gp={ext:!0,kty:"EC",crv:"P-384"},jp={ext:!0,kty:"EC",crv:"P-521"},ls=32,fs=48,ds=66;function Yu(r){let t=as(r);return Wu(t)}function Wu(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===ls*2+1)return n=J(t.subarray(e,e+ls),"base64url"),o=J(t.subarray(e+ls),"base64url"),new br({...$p,key_ops:["verify"],x:n,y:o});if(t.byteLength===fs*2+1)return n=J(t.subarray(e,e+fs),"base64url"),o=J(t.subarray(e+fs),"base64url"),new br({...Gp,key_ops:["verify"],x:n,y:o});if(t.byteLength===ds*2+1)return n=J(t.subarray(e,e+ds),"base64url"),o=J(t.subarray(e+ds),"base64url"),new br({...jp,key_ops:["verify"],x:n,y:o});throw new qt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Xu(r){return Co([Gu(Uint8Array.from([1])),Co([Zp(r.crv)],160),Co([ju(new gt(Uint8Array.from([4]),Gt(r.x??"","base64url"),Gt(r.y??"","base64url")))],161)]).subarray()}function Zp(r){if(r==="P-256")return Hp;if(r==="P-384")return zp;if(r==="P-521")return qp;throw new qt(`Invalid curve ${r}`)}var br=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Xu(this.jwk)),this._raw}toMultihash(){return te.digest(wr(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Rt(this.raw,t.raw)}async verify(t,e){return Zu(this.jwk,e,t)}};var He=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Yp(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Bo(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function ze(r,...t){if(!Yp(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Qu(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Bo(r.outputLen),Bo(r.blockLen)}function vr(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 Ju(r,t){ze(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function pe(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function ko(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function ne(r,t){return r<<32-t|r>>>t}function tl(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function hn(r){return typeof r=="string"&&(r=tl(r)),ze(r),r}function hs(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ze(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 Er=class{};function ps(r){let t=n=>r().update(hn(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function To(r=32){if(He&&typeof He.getRandomValues=="function")return He.getRandomValues(new Uint8Array(r));if(He&&typeof He.randomBytes=="function")return Uint8Array.from(He.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Wp(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(e>>o&i),c=Number(e&i),a=n?4:0,l=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+l,c,n)}function el(r,t,e){return r&t^~r&e}function rl(r,t,e){return r&t^r&e^t&e}var pn=class extends Er{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=ko(this.buffer)}update(t){vr(this),t=hn(t),ze(t);let{view:e,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=ko(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){vr(this),Ju(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;e[s++]=128,pe(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)e[f]=0;Wp(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=ko(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)c.setUint32(4*f,u[f],i)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=c,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},me=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var xt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Uo=BigInt(4294967295),nl=BigInt(32);function Xp(r,t=!1){return t?{h:Number(r&Uo),l:Number(r>>nl&Uo)}:{h:Number(r>>nl&Uo)|0,l:Number(r&Uo)|0}}function ol(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let i=0;i<e;i++){let{h:s,l:c}=Xp(r[i],t);[n[i],o[i]]=[s,c]}return[n,o]}var ms=(r,t,e)=>r>>>e,gs=(r,t,e)=>r<<32-e|t>>>e,qe=(r,t,e)=>r>>>e|t<<32-e,$e=(r,t,e)=>r<<32-e|t>>>e,mn=(r,t,e)=>r<<64-e|t>>>e-32,gn=(r,t,e)=>r>>>e-32|t<<64-e;function se(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var il=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),sl=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,cl=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),al=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,ul=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),ll=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var Jp=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Te=new Uint32Array(64),ys=class extends pn{constructor(t=32){super(64,t,8,!1),this.A=me[0]|0,this.B=me[1]|0,this.C=me[2]|0,this.D=me[3]|0,this.E=me[4]|0,this.F=me[5]|0,this.G=me[6]|0,this.H=me[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)Te[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let h=Te[f-15],E=Te[f-2],w=ne(h,7)^ne(h,18)^h>>>3,g=ne(E,17)^ne(E,19)^E>>>10;Te[f]=g+Te[f-7]+w+Te[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=ne(c,6)^ne(c,11)^ne(c,25),E=u+h+el(c,a,l)+Jp[f]+Te[f]|0,g=(ne(n,2)^ne(n,13)^ne(n,22))+rl(n,o,i)|0;u=l,l=a,a=c,c=s+E|0,s=i,i=o,o=n,n=E+g|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,l,u)}roundClean(){pe(Te)}destroy(){this.set(0,0,0,0,0,0,0,0),pe(this.buffer)}};var fl=ol(["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))),t0=fl[0],e0=fl[1],Ue=new Uint32Array(80),Le=new Uint32Array(80),xs=class extends pn{constructor(t=64){super(128,t,16,!1),this.Ah=xt[0]|0,this.Al=xt[1]|0,this.Bh=xt[2]|0,this.Bl=xt[3]|0,this.Ch=xt[4]|0,this.Cl=xt[5]|0,this.Dh=xt[6]|0,this.Dl=xt[7]|0,this.Eh=xt[8]|0,this.El=xt[9]|0,this.Fh=xt[10]|0,this.Fl=xt[11]|0,this.Gh=xt[12]|0,this.Gl=xt[13]|0,this.Hh=xt[14]|0,this.Hl=xt[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:i,Cl:s,Dh:c,Dl:a,Eh:l,El:u,Fh:f,Fl:h,Gh:E,Gl:w,Hh:g,Hl:x}=this;return[t,e,n,o,i,s,c,a,l,u,f,h,E,w,g,x]}set(t,e,n,o,i,s,c,a,l,u,f,h,E,w,g,x){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=h|0,this.Gh=E|0,this.Gl=w|0,this.Hh=g|0,this.Hl=x|0}process(t,e){for(let v=0;v<16;v++,e+=4)Ue[v]=t.getUint32(e),Le[v]=t.getUint32(e+=4);for(let v=16;v<80;v++){let d=Ue[v-15]|0,b=Le[v-15]|0,k=qe(d,b,1)^qe(d,b,8)^ms(d,b,7),T=$e(d,b,1)^$e(d,b,8)^gs(d,b,7),L=Ue[v-2]|0,M=Le[v-2]|0,H=qe(L,M,19)^mn(L,M,61)^ms(L,M,6),D=$e(L,M,19)^gn(L,M,61)^gs(L,M,6),F=cl(T,D,Le[v-7],Le[v-16]),R=al(F,k,H,Ue[v-7],Ue[v-16]);Ue[v]=R|0,Le[v]=F|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:h,Fh:E,Fl:w,Gh:g,Gl:x,Hh:U,Hl:V}=this;for(let v=0;v<80;v++){let d=qe(f,h,14)^qe(f,h,18)^mn(f,h,41),b=$e(f,h,14)^$e(f,h,18)^gn(f,h,41),k=f&E^~f&g,T=h&w^~h&x,L=ul(V,b,T,e0[v],Le[v]),M=ll(L,U,d,k,t0[v],Ue[v]),H=L|0,D=qe(n,o,28)^mn(n,o,34)^mn(n,o,39),F=$e(n,o,28)^gn(n,o,34)^gn(n,o,39),R=n&i^n&c^i&c,at=o&s^o&a^s&a;U=g|0,V=x|0,g=E|0,x=w|0,E=f|0,w=h|0,{h:f,l:h}=se(l|0,u|0,M|0,H|0),l=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let _=il(H,F,at);n=sl(_,M,D,R),o=_|0}({h:n,l:o}=se(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=se(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=se(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=se(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=se(this.Eh|0,this.El|0,f|0,h|0),{h:E,l:w}=se(this.Fh|0,this.Fl|0,E|0,w|0),{h:g,l:x}=se(this.Gh|0,this.Gl|0,g|0,x|0),{h:U,l:V}=se(this.Hh|0,this.Hl|0,U|0,V|0),this.set(n,o,i,s,c,a,l,u,f,h,E,w,g,x,U,V)}roundClean(){pe(Ue,Le)}destroy(){pe(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var dl=ps(()=>new ys);var hl=ps(()=>new xs);var vs=BigInt(0),Es=BigInt(1);function Sr(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ss(r){if(!Sr(r))throw new Error("Uint8Array expected")}function ce(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function yn(r){let t=r.toString(16);return t.length&1?"0"+t:t}function gl(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?vs:BigInt("0x"+r)}var yl=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",r0=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Pe(r){if(Ss(r),yl)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=r0[r[e]];return t}var ge={_0:48,_9:57,A:65,F:70,a:97,f:102};function pl(r){if(r>=ge._0&&r<=ge._9)return r-ge._0;if(r>=ge.A&&r<=ge.F)return r-(ge.A-10);if(r>=ge.a&&r<=ge.f)return r-(ge.a-10)}function xn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(yl)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,i=0;o<e;o++,i+=2){let s=pl(r.charCodeAt(i)),c=pl(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 ye(r){return gl(Pe(r))}function Ge(r){return Ss(r),gl(Pe(Uint8Array.from(r).reverse()))}function je(r,t){return xn(r.toString(16).padStart(t*2,"0"))}function Ar(r,t){return je(r,t).reverse()}function nt(r,t,e){let n;if(typeof t=="string")try{n=xn(t)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(Sr(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function De(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Ss(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 bs=r=>typeof r=="bigint"&&vs<=r;function Lo(r,t,e){return bs(r)&&bs(t)&&bs(e)&&t<=r&&r<e}function Ht(r,t,e,n){if(!Lo(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function xl(r){let t;for(t=0;r>vs;r>>=Es,t+=1);return t}var Ze=r=>(Es<<BigInt(r))-Es,ws=r=>new Uint8Array(r),ml=r=>Uint8Array.from(r);function bl(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=ws(r),o=ws(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},c=(...f)=>e(o,n,...f),a=(f=ws(0))=>{o=c(ml([0]),f),n=c(),f.length!==0&&(o=c(ml([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 E=n.slice();h.push(E),f+=n.length}return De(...h)};return(f,h)=>{s(),a(f);let E;for(;!(E=h(l()));)a();return s(),E}}var n0={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"||Sr(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 xe(r,t,e={}){let n=(o,i,s)=>{let c=n0[i];if(typeof c!="function")throw new Error("invalid validator function");let a=r[o];if(!(s&&a===void 0)&&!c(a,r))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+a)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}function _r(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let i=r(e,...n);return t.set(e,i),i}}var kt=BigInt(0),ht=BigInt(1),Ye=BigInt(2),o0=BigInt(3),El=BigInt(4),vl=BigInt(5),Sl=BigInt(8);function W(r,t){let e=r%t;return e>=kt?e:t+e}function ot(r,t,e){let n=r;for(;t-- >kt;)n*=n,n%=e;return n}function Po(r,t){if(r===kt)throw new Error("invert: expected non-zero number");if(t<=kt)throw new Error("invert: expected positive modulus, got "+t);let e=W(r,t),n=t,o=kt,i=ht,s=ht,c=kt;for(;e!==kt;){let l=n/e,u=n%e,f=o-s*l,h=i-c*l;n=e,e=u,o=s,i=c,s=f,c=h}if(n!==ht)throw new Error("invert: does not exist");return W(o,t)}function Al(r,t){let e=(r.ORDER+ht)/El,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function i0(r,t){let e=(r.ORDER-vl)/Sl,n=r.mul(t,Ye),o=r.pow(n,e),i=r.mul(t,o),s=r.mul(r.mul(i,Ye),o),c=r.mul(i,r.sub(s,r.ONE));if(!r.eql(r.sqr(c),t))throw new Error("Cannot find square root");return c}function s0(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-ht,e=0;for(;t%Ye===kt;)t/=Ye,e++;let n=Ye,o=be(r);for(;wl(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Al;let i=o.pow(n,t),s=(t+ht)/Ye;return function(a,l){if(a.is0(l))return l;if(wl(a,l)!==1)throw new Error("Cannot find square root");let u=e,f=a.mul(a.ONE,i),h=a.pow(l,t),E=a.pow(l,s);for(;!a.eql(h,a.ONE);){if(a.is0(h))return a.ZERO;let w=1,g=a.sqr(h);for(;!a.eql(g,a.ONE);)if(w++,g=a.sqr(g),w===u)throw new Error("Cannot find square root");let x=ht<<BigInt(u-w-1),U=a.pow(f,x);u=w,f=a.sqr(U),h=a.mul(h,f),E=a.mul(E,U)}return E}}function c0(r){return r%El===o0?Al:r%Sl===vl?i0:s0(r)}var _l=(r,t)=>(W(r,t)&ht)===ht,a0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function As(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=a0.reduce((n,o)=>(n[o]="function",n),t);return xe(r,e)}function u0(r,t,e){if(e<kt)throw new Error("invalid exponent, negatives unsupported");if(e===kt)return r.ONE;if(e===ht)return t;let n=r.ONE,o=t;for(;e>kt;)e&ht&&(n=r.mul(n,o)),o=r.sqr(o),e>>=ht;return n}function Ir(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((s,c,a)=>r.is0(c)?s:(n[a]=s,r.mul(s,c)),r.ONE),i=r.inv(o);return t.reduceRight((s,c,a)=>r.is0(c)?s:(n[a]=r.mul(s,n[a]),r.mul(s,c)),i),n}function wl(r,t){let e=(r.ORDER-ht)/Ye,n=r.pow(t,e),o=r.eql(n,r.ONE),i=r.eql(n,r.ZERO),s=r.eql(n,r.neg(r.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function _s(r,t){t!==void 0&&Bo(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function be(r,t,e=!1,n={}){if(r<=kt)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:i}=_s(r,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,c=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:i,MASK:Ze(o),ZERO:kt,ONE:ht,create:a=>W(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return kt<=a&&a<r},is0:a=>a===kt,isOdd:a=>(a&ht)===ht,neg:a=>W(-a,r),eql:(a,l)=>a===l,sqr:a=>W(a*a,r),add:(a,l)=>W(a+l,r),sub:(a,l)=>W(a-l,r),mul:(a,l)=>W(a*l,r),pow:(a,l)=>u0(c,a,l),div:(a,l)=>W(a*Po(l,r),r),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>Po(a,r),sqrt:n.sqrt||(a=>(s||(s=c0(r)),s(c,a))),toBytes:a=>e?Ar(a,i):je(a,i),fromBytes:a=>{if(a.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+a.length);return e?Ge(a):ye(a)},invertBatch:a=>Ir(c,a),cmov:(a,l,u)=>u?l:a});return Object.freeze(c)}function Il(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Is(r){let t=Il(r);return t+Math.ceil(t/2)}function Cl(r,t,e=!1){let n=r.length,o=Il(t),i=Is(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=e?Ge(r):ye(r),c=W(s,t-ht)+ht;return e?Ar(c,o):je(c,o)}var Bl=BigInt(0),Us=BigInt(1);function Cs(r,t){let e=t.negate();return r?e:t}function Tl(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Bs(r,t){Tl(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,i=Ze(r),s=BigInt(r);return{windows:e,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function kl(r,t,e){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=e,c=Number(r&o),a=r>>s;c>n&&(c-=i,a+=Us);let l=t*n,u=l+Math.abs(c)-1,f=c===0,h=c<0,E=t%2!==0;return{nextN:a,offset:u,isZero:f,isNeg:h,isNegF:E,offsetF:l}}function l0(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function f0(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var ks=new WeakMap,Ul=new WeakMap;function Ts(r){return Ul.get(r)||1}function Do(r,t){return{constTimeNegate:Cs,hasPrecomputes(e){return Ts(e)!==1},unsafeLadder(e,n,o=r.ZERO){let i=e;for(;n>Bl;)n&Us&&(o=o.add(i)),i=i.double(),n>>=Us;return o},precomputeWindow(e,n){let{windows:o,windowSize:i}=Bs(n,t),s=[],c=e,a=c;for(let l=0;l<o;l++){a=c,s.push(a);for(let u=1;u<i;u++)a=a.add(c),s.push(a);c=a.double()}return s},wNAF(e,n,o){let i=r.ZERO,s=r.BASE,c=Bs(e,t);for(let a=0;a<c.windows;a++){let{nextN:l,offset:u,isZero:f,isNeg:h,isNegF:E,offsetF:w}=kl(o,a,c);o=l,f?s=s.add(Cs(E,n[w])):i=i.add(Cs(h,n[u]))}return{p:i,f:s}},wNAFUnsafe(e,n,o,i=r.ZERO){let s=Bs(e,t);for(let c=0;c<s.windows&&o!==Bl;c++){let{nextN:a,offset:l,isZero:u,isNeg:f}=kl(o,c,s);if(o=a,!u){let h=n[l];i=i.add(f?h.negate():h)}}return i},getPrecomputes(e,n,o){let i=ks.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&ks.set(n,o(i))),i},wNAFCached(e,n,o){let i=Ts(e);return this.wNAF(i,this.getPrecomputes(i,e,o),n)},wNAFCachedUnsafe(e,n,o,i){let s=Ts(e);return s===1?this.unsafeLadder(e,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,o),n,i)},setWindowSize(e,n){Tl(n,t),Ul.set(e,n),ks.delete(e)}}}function No(r,t,e,n){l0(e,r),f0(n,t);let o=e.length,i=n.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");let s=r.ZERO,c=xl(BigInt(o)),a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);let l=Ze(a),u=new Array(Number(l)+1).fill(s),f=Math.floor((t.BITS-1)/a)*a,h=s;for(let E=f;E>=0;E-=a){u.fill(s);for(let g=0;g<i;g++){let x=n[g],U=Number(x>>BigInt(E)&l);u[U]=u[U].add(e[g])}let w=s;for(let g=u.length-1,x=s;g>0;g--)x=x.add(u[g]),w=w.add(x);if(h=h.add(w),E!==0)for(let g=0;g<a;g++)h=h.double()}return h}function bn(r){return As(r.Fp),xe(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({..._s(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var ae=BigInt(0),Tt=BigInt(1),Ll=BigInt(2),d0=BigInt(8),h0={zip215:!0};function p0(r){let t=bn(r);return xe(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Pl(r){let t=p0(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,l=Ll<<BigInt(c*8)-Tt,u=e.create,f=be(t.n,t.nBitLength);function h(S,m){let y=e.sqr(S),I=e.sqr(m),N=e.add(e.mul(t.a,y),I),K=e.add(e.ONE,e.mul(t.d,e.mul(y,I)));return e.eql(N,K)}if(!h(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let E=t.uvRatio||((S,m)=>{try{return{isValid:!0,value:e.sqrt(S*e.inv(m))}}catch{return{isValid:!1,value:ae}}}),w=t.adjustScalarBytes||(S=>S),g=t.domain||((S,m,y)=>{if(ce("phflag",y),m.length||y)throw new Error("Contexts/pre-hash are not supported");return S});function x(S,m,y=!1){let I=y?Tt:ae;Ht("coordinate "+S,m,I,l)}function U(S){if(!(S instanceof d))throw new Error("ExtendedPoint expected")}let V=_r((S,m)=>{let{ex:y,ey:I,ez:N}=S,K=S.is0();m==null&&(m=K?d0:e.inv(N));let z=u(y*m),q=u(I*m),j=u(N*m);if(K)return{x:ae,y:Tt};if(j!==Tt)throw new Error("invZ was invalid");return{x:z,y:q}}),v=_r(S=>{let{a:m,d:y}=t;if(S.is0())throw new Error("bad point: ZERO");let{ex:I,ey:N,ez:K,et:z}=S,q=u(I*I),j=u(N*N),Y=u(K*K),ut=u(Y*Y),st=u(q*m),mt=u(Y*u(st+j)),Ut=u(ut+u(y*u(q*j)));if(mt!==Ut)throw new Error("bad point: equation left != right (1)");let lt=u(I*N),bt=u(K*z);if(lt!==bt)throw new Error("bad point: equation left != right (2)");return!0});class d{constructor(m,y,I,N){x("x",m),x("y",y),x("z",I,!0),x("t",N),this.ex=m,this.ey=y,this.ez=I,this.et=N,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof d)throw new Error("extended point not allowed");let{x:y,y:I}=m||{};return x("x",y),x("y",I),new d(y,I,Tt,u(y*I))}static normalizeZ(m){let y=Ir(e,m.map(I=>I.ez));return m.map((I,N)=>I.toAffine(y[N])).map(d.fromAffine)}static msm(m,y){return No(d,f,m,y)}_setWindowSize(m){T.setWindowSize(this,m)}assertValidity(){v(this)}equals(m){U(m);let{ex:y,ey:I,ez:N}=this,{ex:K,ey:z,ez:q}=m,j=u(y*q),Y=u(K*N),ut=u(I*q),st=u(z*N);return j===Y&&ut===st}is0(){return this.equals(d.ZERO)}negate(){return new d(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:m}=t,{ex:y,ey:I,ez:N}=this,K=u(y*y),z=u(I*I),q=u(Ll*u(N*N)),j=u(m*K),Y=y+I,ut=u(u(Y*Y)-K-z),st=j+z,mt=st-q,Ut=j-z,lt=u(ut*mt),bt=u(st*Ut),Pt=u(ut*Ut),Yt=u(mt*st);return new d(lt,bt,Yt,Pt)}add(m){U(m);let{a:y,d:I}=t,{ex:N,ey:K,ez:z,et:q}=this,{ex:j,ey:Y,ez:ut,et:st}=m,mt=u(N*j),Ut=u(K*Y),lt=u(q*I*st),bt=u(z*ut),Pt=u((N+K)*(j+Y)-mt-Ut),Yt=bt-lt,Tr=bt+lt,$s=u(Ut-y*mt),uf=u(Pt*Yt),lf=u(Tr*$s),ff=u(Pt*$s),df=u(Yt*Tr);return new d(uf,lf,df,ff)}subtract(m){return this.add(m.negate())}wNAF(m){return T.wNAFCached(this,m,d.normalizeZ)}multiply(m){let y=m;Ht("scalar",y,Tt,n);let{p:I,f:N}=this.wNAF(y);return d.normalizeZ([I,N])[0]}multiplyUnsafe(m,y=d.ZERO){let I=m;return Ht("scalar",I,ae,n),I===ae?k:this.is0()||I===Tt?this:T.wNAFCachedUnsafe(this,I,d.normalizeZ,y)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(m){return V(this,m)}clearCofactor(){let{h:m}=t;return m===Tt?this:this.multiplyUnsafe(m)}static fromHex(m,y=!1){let{d:I,a:N}=t,K=e.BYTES;m=nt("pointHex",m,K),ce("zip215",y);let z=m.slice(),q=m[K-1];z[K-1]=q&-129;let j=Ge(z),Y=y?l:e.ORDER;Ht("pointHex.y",j,ae,Y);let ut=u(j*j),st=u(ut-Tt),mt=u(I*ut-N),{isValid:Ut,value:lt}=E(st,mt);if(!Ut)throw new Error("Point.fromHex: invalid y coordinate");let bt=(lt&Tt)===Tt,Pt=(q&128)!==0;if(!y&&lt===ae&&Pt)throw new Error("Point.fromHex: x=0 and x_0=1");return Pt!==bt&&(lt=u(-lt)),d.fromAffine({x:lt,y:j})}static fromPrivateKey(m){let{scalar:y}=H(m);return b.multiply(y)}toRawBytes(){let{x:m,y}=this.toAffine(),I=Ar(y,e.BYTES);return I[I.length-1]|=m&Tt?128:0,I}toHex(){return Pe(this.toRawBytes())}}d.BASE=new d(t.Gx,t.Gy,Tt,u(t.Gx*t.Gy)),d.ZERO=new d(ae,Tt,Tt,ae);let{BASE:b,ZERO:k}=d,T=Do(d,c*8);function L(S){return W(S,n)}function M(S){return L(Ge(S))}function H(S){let m=e.BYTES;S=nt("private key",S,m);let y=nt("hashed private key",i(S),2*m),I=w(y.slice(0,m)),N=y.slice(m,2*m),K=M(I);return{head:I,prefix:N,scalar:K}}function D(S){let{head:m,prefix:y,scalar:I}=H(S),N=b.multiply(I),K=N.toRawBytes();return{head:m,prefix:y,scalar:I,point:N,pointBytes:K}}function F(S){return D(S).pointBytes}function R(S=Uint8Array.of(),...m){let y=De(...m);return M(i(g(y,nt("context",S),!!o)))}function at(S,m,y={}){S=nt("message",S),o&&(S=o(S));let{prefix:I,scalar:N,pointBytes:K}=D(m),z=R(y.context,I,S),q=b.multiply(z).toRawBytes(),j=R(y.context,q,K,S),Y=L(z+j*N);Ht("signature.s",Y,ae,n);let ut=De(q,Ar(Y,e.BYTES));return nt("result",ut,e.BYTES*2)}let _=h0;function A(S,m,y,I=_){let{context:N,zip215:K}=I,z=e.BYTES;S=nt("signature",S,2*z),m=nt("message",m),y=nt("publicKey",y,z),K!==void 0&&ce("zip215",K),o&&(m=o(m));let q=Ge(S.slice(z,2*z)),j,Y,ut;try{j=d.fromHex(y,K),Y=d.fromHex(S.slice(0,z),K),ut=b.multiplyUnsafe(q)}catch{return!1}if(!K&&j.isSmallOrder())return!1;let st=R(N,Y.toRawBytes(),j.toRawBytes(),m);return Y.add(j.multiplyUnsafe(st)).subtract(ut).clearCofactor().equals(d.ZERO)}return b._setWindowSize(8),{CURVE:t,getPublicKey:F,sign:at,verify:A,ExtendedPoint:d,utils:{getExtendedPublicKey:D,randomPrivateKey:()=>s(e.BYTES),precompute(S=8,m=d.BASE){return m._setWindowSize(S),m.multiply(BigInt(3)),m}}}}var Ls=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Dl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),j2=BigInt(0),m0=BigInt(1),Nl=BigInt(2),Z2=BigInt(3),g0=BigInt(5),y0=BigInt(8);function x0(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=Ls,c=r*r%i*r%i,a=ot(c,Nl,i)*c%i,l=ot(a,m0,i)*r%i,u=ot(l,g0,i)*l%i,f=ot(u,t,i)*u%i,h=ot(f,e,i)*f%i,E=ot(h,n,i)*h%i,w=ot(E,o,i)*E%i,g=ot(w,o,i)*E%i,x=ot(g,t,i)*u%i;return{pow_p_5_8:ot(x,Nl,i)*r%i,b2:c}}function b0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function w0(r,t){let e=Ls,n=W(t*t*t,e),o=W(n*n*t,e),i=x0(r*o).pow_p_5_8,s=W(r*n*i,e),c=W(t*s*s,e),a=s,l=W(s*Dl,e),u=c===r,f=c===W(-r,e),h=c===W(-r*Dl,e);return u&&(s=a),(f||h)&&(s=l),_l(s,e)&&(s=W(-s,e)),{isValid:u||f,value:s}}var Rl=be(Ls,void 0,!0),E0={a:Rl.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Rl,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:y0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:hl,randomBytes:To,adjustScalarBytes:b0,uvRatio:w0},Ml=Pl(E0);var Ro=32;function Ol(r,t,e){return Ml.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var Mo=class{type="Ed25519";raw;constructor(t){this.raw=Ps(t,Ro)}toMultihash(){return te.digest(wr(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Rt(this.raw,t.raw)}verify(t,e){return Ol(this.raw,e,t)}};function Kl(r){return r=Ps(r,Ro),new Mo(r)}function Ps(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new qt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var zt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(zt||(zt={}));var Ds;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Ds||(Ds={}));(function(r){r.codec=()=>Qr(Ds)})(zt||(zt={}));var wn;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),zt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.Type=zt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(wn||(wn={}));var Ns;(function(r){let t;r.codec=()=>(t==null&&(t=Ct((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),zt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.Type=zt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>It(e,r.codec()),r.decode=(e,n)=>_t(e,r.codec(),n)})(Ns||(Ns={}));var En=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var Oo=class extends Er{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Qu(t);let n=hn(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),pe(i)}update(t){return vr(this),this.iHash.update(t),this}digestInto(t){vr(this),ze(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Rs=(r,t,e)=>new Oo(r,t).update(e).digest();Rs.create=(r,t)=>new Oo(r,t);function Vl(r){r.lowS!==void 0&&ce("lowS",r.lowS),r.prehash!==void 0&&ce("prehash",r.prehash)}function A0(r){let t=bn(r);xe(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}var Fs=class extends Error{constructor(t=""){super(t)}},we={Err:Fs,_tlv:{encode:(r,t)=>{let{Err:e}=we;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=yn(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?yn(o.length/2|128):"";return yn(r)+i+o+t},decode(r,t){let{Err:e}=we,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}=we;if(r<Ee)throw new t("integer: negative integers are not allowed");let e=yn(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=we;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 ye(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=we,o=nt("signature",r),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:l,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(l)}},hexFromSig(r){let{_tlv:t,_int:e}=we,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),i=n+o;return t.encode(48,i)}};function Ms(r,t){return Pe(je(r,t))}var Ee=BigInt(0),pt=BigInt(1),bE=BigInt(2),Os=BigInt(3),_0=BigInt(4);function I0(r){let t=A0(r),{Fp:e}=t,n=be(t.n,t.nBitLength),o=t.toBytes||((v,d,b)=>{let k=d.toAffine();return De(Uint8Array.from([4]),e.toBytes(k.x),e.toBytes(k.y))}),i=t.fromBytes||(v=>{let d=v.subarray(1),b=e.fromBytes(d.subarray(0,e.BYTES)),k=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:b,y:k}});function s(v){let{a:d,b}=t,k=e.sqr(v),T=e.mul(k,v);return e.add(e.add(T,e.mul(v,d)),b)}function c(v,d){let b=e.sqr(d),k=s(v);return e.eql(b,k)}if(!c(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let a=e.mul(e.pow(t.a,Os),_0),l=e.mul(e.sqr(t.b),BigInt(27));if(e.is0(e.add(a,l)))throw new Error("bad curve params: a or b");function u(v){return Lo(v,pt,t.n)}function f(v){let{allowedPrivateKeyLengths:d,nByteLength:b,wrapPrivateKey:k,n:T}=t;if(d&&typeof v!="bigint"){if(Sr(v)&&(v=Pe(v)),typeof v!="string"||!d.includes(v.length))throw new Error("invalid private key");v=v.padStart(b*2,"0")}let L;try{L=typeof v=="bigint"?v:ye(nt("private key",v,b))}catch{throw new Error("invalid private key, expected hex or "+b+" bytes, got "+typeof v)}return k&&(L=W(L,T)),Ht("private key",L,pt,T),L}function h(v){if(!(v instanceof g))throw new Error("ProjectivePoint expected")}let E=_r((v,d)=>{let{px:b,py:k,pz:T}=v;if(e.eql(T,e.ONE))return{x:b,y:k};let L=v.is0();d==null&&(d=L?e.ONE:e.inv(T));let M=e.mul(b,d),H=e.mul(k,d),D=e.mul(T,d);if(L)return{x:e.ZERO,y:e.ZERO};if(!e.eql(D,e.ONE))throw new Error("invZ was invalid");return{x:M,y:H}}),w=_r(v=>{if(v.is0()){if(t.allowInfinityPoint&&!e.is0(v.py))return;throw new Error("bad point: ZERO")}let{x:d,y:b}=v.toAffine();if(!e.isValid(d)||!e.isValid(b))throw new Error("bad point: x or y not FE");if(!c(d,b))throw new Error("bad point: equation left != right");if(!v.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(d,b,k){if(d==null||!e.isValid(d))throw new Error("x required");if(b==null||!e.isValid(b)||e.is0(b))throw new Error("y required");if(k==null||!e.isValid(k))throw new Error("z required");this.px=d,this.py=b,this.pz=k,Object.freeze(this)}static fromAffine(d){let{x:b,y:k}=d||{};if(!d||!e.isValid(b)||!e.isValid(k))throw new Error("invalid affine point");if(d instanceof g)throw new Error("projective point not allowed");let T=L=>e.eql(L,e.ZERO);return T(b)&&T(k)?g.ZERO:new g(b,k,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let b=Ir(e,d.map(k=>k.pz));return d.map((k,T)=>k.toAffine(b[T])).map(g.fromAffine)}static fromHex(d){let b=g.fromAffine(i(nt("pointHex",d)));return b.assertValidity(),b}static fromPrivateKey(d){return g.BASE.multiply(f(d))}static msm(d,b){return No(g,n,d,b)}_setWindowSize(d){V.setWindowSize(this,d)}assertValidity(){w(this)}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){h(d);let{px:b,py:k,pz:T}=this,{px:L,py:M,pz:H}=d,D=e.eql(e.mul(b,H),e.mul(L,T)),F=e.eql(e.mul(k,H),e.mul(M,T));return D&&F}negate(){return new g(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b}=t,k=e.mul(b,Os),{px:T,py:L,pz:M}=this,H=e.ZERO,D=e.ZERO,F=e.ZERO,R=e.mul(T,T),at=e.mul(L,L),_=e.mul(M,M),A=e.mul(T,L);return A=e.add(A,A),F=e.mul(T,M),F=e.add(F,F),H=e.mul(d,F),D=e.mul(k,_),D=e.add(H,D),H=e.sub(at,D),D=e.add(at,D),D=e.mul(H,D),H=e.mul(A,H),F=e.mul(k,F),_=e.mul(d,_),A=e.sub(R,_),A=e.mul(d,A),A=e.add(A,F),F=e.add(R,R),R=e.add(F,R),R=e.add(R,_),R=e.mul(R,A),D=e.add(D,R),_=e.mul(L,M),_=e.add(_,_),R=e.mul(_,A),H=e.sub(H,R),F=e.mul(_,at),F=e.add(F,F),F=e.add(F,F),new g(H,D,F)}add(d){h(d);let{px:b,py:k,pz:T}=this,{px:L,py:M,pz:H}=d,D=e.ZERO,F=e.ZERO,R=e.ZERO,at=t.a,_=e.mul(t.b,Os),A=e.mul(b,L),P=e.mul(k,M),S=e.mul(T,H),m=e.add(b,k),y=e.add(L,M);m=e.mul(m,y),y=e.add(A,P),m=e.sub(m,y),y=e.add(b,T);let I=e.add(L,H);return y=e.mul(y,I),I=e.add(A,S),y=e.sub(y,I),I=e.add(k,T),D=e.add(M,H),I=e.mul(I,D),D=e.add(P,S),I=e.sub(I,D),R=e.mul(at,y),D=e.mul(_,S),R=e.add(D,R),D=e.sub(P,R),R=e.add(P,R),F=e.mul(D,R),P=e.add(A,A),P=e.add(P,A),S=e.mul(at,S),y=e.mul(_,y),P=e.add(P,S),S=e.sub(A,S),S=e.mul(at,S),y=e.add(y,S),A=e.mul(P,y),F=e.add(F,A),A=e.mul(I,y),D=e.mul(m,D),D=e.sub(D,A),A=e.mul(m,P),R=e.mul(I,R),R=e.add(R,A),new g(D,F,R)}subtract(d){return this.add(d.negate())}is0(){return this.equals(g.ZERO)}wNAF(d){return V.wNAFCached(this,d,g.normalizeZ)}multiplyUnsafe(d){let{endo:b,n:k}=t;Ht("scalar",d,Ee,k);let T=g.ZERO;if(d===Ee)return T;if(this.is0()||d===pt)return this;if(!b||V.hasPrecomputes(this))return V.wNAFCachedUnsafe(this,d,g.normalizeZ);let{k1neg:L,k1:M,k2neg:H,k2:D}=b.splitScalar(d),F=T,R=T,at=this;for(;M>Ee||D>Ee;)M&pt&&(F=F.add(at)),D&pt&&(R=R.add(at)),at=at.double(),M>>=pt,D>>=pt;return L&&(F=F.negate()),H&&(R=R.negate()),R=new g(e.mul(R.px,b.beta),R.py,R.pz),F.add(R)}multiply(d){let{endo:b,n:k}=t;Ht("scalar",d,pt,k);let T,L;if(b){let{k1neg:M,k1:H,k2neg:D,k2:F}=b.splitScalar(d),{p:R,f:at}=this.wNAF(H),{p:_,f:A}=this.wNAF(F);R=V.constTimeNegate(M,R),_=V.constTimeNegate(D,_),_=new g(e.mul(_.px,b.beta),_.py,_.pz),T=R.add(_),L=at.add(A)}else{let{p:M,f:H}=this.wNAF(d);T=M,L=H}return g.normalizeZ([T,L])[0]}multiplyAndAddUnsafe(d,b,k){let T=g.BASE,L=(H,D)=>D===Ee||D===pt||!H.equals(T)?H.multiplyUnsafe(D):H.multiply(D),M=L(this,b).add(L(d,k));return M.is0()?void 0:M}toAffine(d){return E(this,d)}isTorsionFree(){let{h:d,isTorsionFree:b}=t;if(d===pt)return!0;if(b)return b(g,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(g,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return ce("isCompressed",d),this.assertValidity(),o(g,this,d)}toHex(d=!0){return ce("isCompressed",d),Pe(this.toRawBytes(d))}}g.BASE=new g(t.Gx,t.Gy,e.ONE),g.ZERO=new g(e.ZERO,e.ONE,e.ZERO);let{endo:x,nBitLength:U}=t,V=Do(g,x?Math.ceil(U/2):U);return{CURVE:t,ProjectivePoint:g,normPrivateKeyToScalar:f,weierstrassEquation:s,isWithinCurveOrder:u}}function C0(r){let t=bn(r);return xe(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Hl(r){let t=C0(r),{Fp:e,n,nByteLength:o,nBitLength:i}=t,s=e.BYTES+1,c=2*e.BYTES+1;function a(_){return W(_,n)}function l(_){return Po(_,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:f,weierstrassEquation:h,isWithinCurveOrder:E}=I0({...t,toBytes(_,A,P){let S=A.toAffine(),m=e.toBytes(S.x),y=De;return ce("isCompressed",P),P?y(Uint8Array.from([A.hasEvenY()?2:3]),m):y(Uint8Array.from([4]),m,e.toBytes(S.y))},fromBytes(_){let A=_.length,P=_[0],S=_.subarray(1);if(A===s&&(P===2||P===3)){let m=ye(S);if(!Lo(m,pt,e.ORDER))throw new Error("Point is not on curve");let y=h(m),I;try{I=e.sqrt(y)}catch(z){let q=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+q)}let N=(I&pt)===pt;return(P&1)===1!==N&&(I=e.neg(I)),{x:m,y:I}}else if(A===c&&P===4){let m=e.fromBytes(S.subarray(0,e.BYTES)),y=e.fromBytes(S.subarray(e.BYTES,2*e.BYTES));return{x:m,y}}else{let m=s,y=c;throw new Error("invalid Point, expected length of "+m+", or uncompressed "+y+", got "+A)}}});function w(_){let A=n>>pt;return _>A}function g(_){return w(_)?a(-_):_}let x=(_,A,P)=>ye(_.slice(A,P));class U{constructor(A,P,S){Ht("r",A,pt,n),Ht("s",P,pt,n),this.r=A,this.s=P,S!=null&&(this.recovery=S),Object.freeze(this)}static fromCompact(A){let P=o;return A=nt("compactSignature",A,P*2),new U(x(A,0,P),x(A,P,2*P))}static fromDER(A){let{r:P,s:S}=we.toSig(nt("DER",A));return new U(P,S)}assertValidity(){}addRecoveryBit(A){return new U(this.r,this.s,A)}recoverPublicKey(A){let{r:P,s:S,recovery:m}=this,y=T(nt("msgHash",A));if(m==null||![0,1,2,3].includes(m))throw new Error("recovery id invalid");let I=m===2||m===3?P+t.n:P;if(I>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let N=(m&1)===0?"02":"03",K=u.fromHex(N+Ms(I,e.BYTES)),z=l(I),q=a(-y*z),j=a(S*z),Y=u.BASE.multiplyAndAddUnsafe(K,q,j);if(!Y)throw new Error("point at infinify");return Y.assertValidity(),Y}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new U(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return xn(this.toDERHex())}toDERHex(){return we.hexFromSig(this)}toCompactRawBytes(){return xn(this.toCompactHex())}toCompactHex(){let A=o;return Ms(this.r,A)+Ms(this.s,A)}}let V={isValidPrivateKey(_){try{return f(_),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let _=Is(t.n);return Cl(t.randomBytes(_),t.n)},precompute(_=8,A=u.BASE){return A._setWindowSize(_),A.multiply(BigInt(3)),A}};function v(_,A=!0){return u.fromPrivateKey(_).toRawBytes(A)}function d(_){if(typeof _=="bigint")return!1;if(_ instanceof u)return!0;let P=nt("key",_).length,S=e.BYTES,m=S+1,y=2*S+1;if(!(t.allowedPrivateKeyLengths||o===m))return P===m||P===y}function b(_,A,P=!0){if(d(_)===!0)throw new Error("first arg must be private key");if(d(A)===!1)throw new Error("second arg must be public key");return u.fromHex(A).multiply(f(_)).toRawBytes(P)}let k=t.bits2int||function(_){if(_.length>8192)throw new Error("input is too large");let A=ye(_),P=_.length*8-i;return P>0?A>>BigInt(P):A},T=t.bits2int_modN||function(_){return a(k(_))},L=Ze(i);function M(_){return Ht("num < 2^"+i,_,Ee,L),je(_,o)}function H(_,A,P=D){if(["recovered","canonical"].some(st=>st in P))throw new Error("sign() legacy options not supported");let{hash:S,randomBytes:m}=t,{lowS:y,prehash:I,extraEntropy:N}=P;y==null&&(y=!0),_=nt("msgHash",_),Vl(P),I&&(_=nt("prehashed msgHash",S(_)));let K=T(_),z=f(A),q=[M(z),M(K)];if(N!=null&&N!==!1){let st=N===!0?m(e.BYTES):N;q.push(nt("extraEntropy",st))}let j=De(...q),Y=K;function ut(st){let mt=k(st);if(!E(mt))return;let Ut=l(mt),lt=u.BASE.multiply(mt).toAffine(),bt=a(lt.x);if(bt===Ee)return;let Pt=a(Ut*a(Y+bt*z));if(Pt===Ee)return;let Yt=(lt.x===bt?0:2)|Number(lt.y&pt),Tr=Pt;return y&&w(Pt)&&(Tr=g(Pt),Yt^=1),new U(bt,Tr,Yt)}return{seed:j,k2sig:ut}}let D={lowS:t.lowS,prehash:!1},F={lowS:t.lowS,prehash:!1};function R(_,A,P=D){let{seed:S,k2sig:m}=H(_,A,P),y=t;return bl(y.hash.outputLen,y.nByteLength,y.hmac)(S,m)}u.BASE._setWindowSize(8);function at(_,A,P,S=F){let m=_;A=nt("msgHash",A),P=nt("publicKey",P);let{lowS:y,prehash:I,format:N}=S;if(Vl(S),"strict"in S)throw new Error("options.strict was renamed to lowS");if(N!==void 0&&N!=="compact"&&N!=="der")throw new Error("format must be compact or der");let K=typeof m=="string"||Sr(m),z=!K&&!N&&typeof m=="object"&&m!==null&&typeof m.r=="bigint"&&typeof m.s=="bigint";if(!K&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let q,j;try{if(z&&(q=new U(m.r,m.s)),K){try{N!=="compact"&&(q=U.fromDER(m))}catch(Yt){if(!(Yt instanceof we.Err))throw Yt}!q&&N!=="der"&&(q=U.fromCompact(m))}j=u.fromHex(P)}catch{return!1}if(!q||y&&q.hasHighS())return!1;I&&(A=t.hash(A));let{r:Y,s:ut}=q,st=T(A),mt=l(ut),Ut=a(st*mt),lt=a(Y*mt),bt=u.BASE.multiplyAndAddUnsafe(j,Ut,lt)?.toAffine();return bt?a(bt.x)===Y:!1}return{CURVE:t,getPublicKey:v,getSharedSecret:b,sign:R,verify:at,ProjectivePoint:u,Signature:U,utils:V}}function B0(r){return{hash:r,hmac:(t,...e)=>Rs(r,t,hs(...e)),randomBytes:To}}function zl(r,t){let e=n=>Hl({...r,...B0(n)});return{...e(t),create:e}}var Gl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ql=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),k0=BigInt(0),T0=BigInt(1),Ks=BigInt(2),$l=(r,t)=>(r+t/Ks)/t;function U0(r){let t=Gl,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),l=r*r*r%t,u=l*l*r%t,f=ot(u,e,t)*u%t,h=ot(f,e,t)*u%t,E=ot(h,Ks,t)*l%t,w=ot(E,o,t)*E%t,g=ot(w,i,t)*w%t,x=ot(g,c,t)*g%t,U=ot(x,a,t)*x%t,V=ot(U,c,t)*g%t,v=ot(V,e,t)*u%t,d=ot(v,s,t)*w%t,b=ot(d,n,t)*l%t,k=ot(b,Ks,t);if(!Vs.eql(Vs.sqr(k),r))throw new Error("Cannot find square root");return k}var Vs=be(Gl,void 0,void 0,{sqrt:U0}),Cr=zl({a:k0,b:BigInt(7),Fp:Vs,n:ql,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=ql,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-T0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),c=$l(i*r,t),a=$l(-n*r,t),l=W(r-c*e-a*o,t),u=W(-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}}}},dl);function jl(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Zl(r,t,e){let n=jr.digest(e instanceof Uint8Array?e:e.subarray());if(jl(n))return n.then(({digest:o})=>Cr.verify(t,o,r)).catch(o=>{throw new En(String(o))});try{return Cr.verify(t,n.digest,r)}catch(o){throw new En(String(o))}}var Fo=class{type="secp256k1";raw;_key;constructor(t){this._key=Wl(t),this.raw=Yl(this._key)}toMultihash(){return te.digest(wr(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Rt(this.raw,t.raw)}verify(t,e){return Zl(this._key,e,t)}};function Xl(r){return new Fo(r)}function Yl(r){return Cr.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Wl(r){try{return Cr.ProjectivePoint.fromHex(r),r}catch(t){throw new Cn(String(t))}}function Ql(r){let{Type:t,Data:e}=wn.decode(r.digest),n=e??new Uint8Array;switch(t){case zt.Ed25519:return Kl(n);case zt.secp256k1:return Xl(n);case zt.ECDSA:return Yu(n);default:throw new Lr}}function wr(r){return wn.encode({Type:zt[r.type],Data:r.raw})}var Jl=Symbol.for("nodejs.util.inspect.custom"),L0=114,vn=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()})`}[_n]=!0;toString(){return this.string==null&&(this.string=et.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ct.createV1(L0,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Rt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Rt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Jl](){return`PeerId(${this.toString()})`}},Ko=class extends vn{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Vo=class extends vn{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Ho=class extends vn{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},P0=2336,Sn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=te.digest(Gt(this.url))}[Jl](){return`PeerId(${this.url})`}[_n]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ct.createV1(P0,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=J(t)),t.toString()===this.toString())}};var D0=114,tf=2336;function ef(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=fe(et.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return N0(ct.parse(r));if(t==null)throw new qt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=fe(t.decode(r))}return zo(e)}function zo(r){if(M0(r))return new Ko({multihash:r});if(R0(r))try{let t=Ql(r);if(t.type==="Ed25519")return new Vo({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Ho({multihash:r,publicKey:t})}catch{let e=J(r.digest);return new Sn(new URL(e))}throw new kn("Supplied PeerID Multihash is invalid")}function N0(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==D0&&r.code!==tf)throw new Bn("Supplied PeerID CID is invalid");if(r.code===tf){let t=J(r.multihash.digest);return new Sn(new URL(t))}return zo(r.multihash)}function R0(r){return r.code===te.code}function M0(r){return r.code===jr.code}var rf={type:4098,canEncode:r=>js(r),encode:r=>r.toMultihash().bytes,decode:r=>zo(fe(r))};var Hs=[ku,qu,rf,Tu];function qo(r){let t={},e=r.components??r;return Object.entries(e).forEach(([n,o])=>{o?.[ve]!=null&&Array.isArray(o[ve])&&(t[n]=o[ve])}),t}function Br(r,t){let e={};for(let[n,o]of r.entries())e[n]=t(o);return e}async function $o(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:Br(c.tags,a=>a.value),metadata:Br(c.metadata,a=>oe.encode(a))})}catch(c){t.error("could not load peer data from peer store",c),e.push({id:i,addresses:s.map(a=>({multiaddr:a.remoteAddr,isConnected:o.includes(a.remoteAddr.toString())})),protocols:[],tags:{},metadata:{}})}return e}function kr(r,t){let e=t[r];if(!In(e))throw new qt(`Component ${r} did not implement the PubSub interface`);return e}async function Go(r){let t=await r.peerStore.get(r.peerId);return{id:t.id,addresses:t.addresses,protocols:[...t.protocols],tags:Br(t.tags,e=>e.value),metadata:Br(t.metadata,e=>oe.encode(e))}}function nf(r){let t=r.logger.forComponent("libp2p:devtools-metrics:metrics-rpc");return{init:async()=>({self:await Go(r),peers:await $o(r,t),debug:localStorage.getItem("debug")??"",capabilities:qo(r)}),setDebug:async e=>{e?.length!=null&&e?.length>0?(ac(e),localStorage.setItem("debug",e)):(cc(),localStorage.removeItem("debug"))},openConnection:async(e,n)=>{let o;try{o=ef(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 kr(e,r).getTopics()},async subscribe(e,n){kr(e,r).subscribe(n)},async unsubscribe(e,n){kr(e,r).unsubscribe(n)},async publish(e,n,o){await kr(e,r).publish(n,o)},async getSubscribers(e,n){return kr(e,r).getSubscribers(n)}}}}function zs(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 of(r,t){for(let[e,n]of Object.entries(qo(t)))if(n.includes(r))return t[e]}var sf="@libp2p/devtools-metrics:devtools",O0="@libp2p/devtools-metrics:worker",F0="@libp2p/devtools-metrics:content",cf="@libp2p/devtools-metrics:metrics",af="________libp2p_devtools_metrics";Object.defineProperty(globalThis,af,{value:!0,enumerable:!1,writable:!1});var qs=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=tr(),this.rpc=Bu({valueCodecs:Hs}),this.devTools=this.rpc.createClient("devTools"),this.onPeersUpdate=zs(this.onPeersUpdate.bind(this),1e3),this.onSelfUpdate=zs(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=Sc({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";[ve]=["@libp2p/metrics"];trackMultiaddrConnection(t){this.simpleMetrics.trackMultiaddrConnection(t)}trackProtocolStream(t,e){this.simpleMetrics.trackProtocolStream(t,e)}registerMetric(t,e){return this.simpleMetrics.registerMetric(t,e)}registerMetricGroup(t,e){return this.simpleMetrics.registerMetricGroup(t,e)}registerCounter(t,e){return this.simpleMetrics.registerCounter(t,e)}registerCounterGroup(t,e){return this.simpleMetrics.registerCounterGroup(t,e)}registerHistogram(t,e){return this.simpleMetrics.registerHistogram(t,e)}registerHistogramGroup(t,e){return this.simpleMetrics.registerHistogramGroup(t,e)}registerSummary(t,e){return this.simpleMetrics.registerSummary(t,e)}registerSummaryGroup(t,e){return this.simpleMetrics.registerSummaryGroup(t,e)}createTrace(){return this.simpleMetrics.createTrace()}traceFunction(t,e,n){return this.simpleMetrics.traceFunction(t,e,n)}async start(){this.components.events.addEventListener("peer:connect",this.onPeersUpdate),this.components.events.addEventListener("peer:disconnect",this.onPeersUpdate),this.components.events.addEventListener("peer:identify",this.onPeersUpdate),this.components.events.addEventListener("peer:update",this.onPeersUpdate),this.components.events.addEventListener("self:peer:update",this.onSelfUpdate),window.addEventListener("message",this.onIncomingMessage),this.rpc.createTarget("metrics",nf(this.components)),await Ws(this.simpleMetrics),Promise.resolve().then(async()=>{await Cc(this.rpcQueue,this.rpc,async e=>{for await(let n of e)window.postMessage({source:cf,type:"libp2p-rpc",message:oe.encode(n)})})}).catch(e=>{this.log.error("error while reading RPC messages",e)});let t=of("@libp2p/pubsub",this.components);In(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 Xs(this.simpleMetrics)}onIncomingMessage(t){if(t.source!==window)return;let e=t.data;e?.source===sf&&e.type==="libp2p-rpc"&&this.rpcQueue.push(oe.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 Go(this.components)})}).catch(t=>{this.log.error("error sending peers message",t)})}onPeersUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("peers",{detail:await $o(this.components,this.log)})}).catch(t=>{this.log.error("error sending peers message",t)})}};function K0(r){return t=>new qs(t,r)}return bf(V0);})();
4
4
  /*! Bundled license information:
5
5
 
6
6
  @noble/hashes/esm/utils.js:
7
7
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
8
8
 
9
9
  @noble/curves/esm/abstract/utils.js:
10
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
11
-
12
10
  @noble/curves/esm/abstract/modular.js:
13
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
14
-
15
11
  @noble/curves/esm/abstract/curve.js:
16
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
17
-
18
12
  @noble/curves/esm/abstract/edwards.js:
19
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
20
-
21
13
  @noble/curves/esm/ed25519.js:
22
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
23
-
24
14
  @noble/curves/esm/abstract/weierstrass.js:
25
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
26
-
27
15
  @noble/curves/esm/_shortw_utils.js:
28
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
29
-
30
16
  @noble/curves/esm/secp256k1.js:
31
17
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
32
18
  */
33
19
  return Libp2PDevtoolsMetrics}));
20
+ //# sourceMappingURL=index.min.js.map