@libp2p/devtools-metrics 1.0.0 → 1.0.1-4fd7eb2e1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +26 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/rpc/index.d.ts +35 -14
- package/dist/src/rpc/index.d.ts.map +1 -1
- package/dist/src/rpc/rpc.d.ts.map +1 -1
- package/dist/src/rpc/rpc.js +22 -2
- package/dist/src/rpc/rpc.js.map +1 -1
- package/dist/src/utils/find-capability.d.ts +2 -0
- package/dist/src/utils/find-capability.d.ts.map +1 -0
- package/dist/src/utils/find-capability.js +9 -0
- package/dist/src/utils/find-capability.js.map +1 -0
- package/dist/src/utils/gather-capabilities.d.ts +2 -0
- package/dist/src/utils/gather-capabilities.d.ts.map +1 -0
- package/dist/src/utils/gather-capabilities.js +12 -0
- package/dist/src/utils/gather-capabilities.js.map +1 -0
- package/dist/src/utils/get-pubsub.d.ts +3 -0
- package/dist/src/utils/get-pubsub.d.ts.map +1 -0
- package/dist/src/utils/get-pubsub.js +9 -0
- package/dist/src/utils/get-pubsub.js.map +1 -0
- package/package.json +9 -8
- package/src/index.ts +32 -2
- package/src/rpc/index.ts +42 -17
- package/src/rpc/rpc.ts +25 -7
- package/src/utils/find-capability.ts +9 -0
- package/src/utils/gather-capabilities.ts +14 -0
- package/src/utils/get-pubsub.ts +12 -0
- package/dist/typedoc-urls.json +0 -50
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 po=Object.defineProperty;var zu=Object.getOwnPropertyDescriptor;var Hu=Object.getOwnPropertyNames;var qu=Object.prototype.hasOwnProperty;var Ct=(r,t)=>{for(var e in t)po(r,e,{get:t[e],enumerable:!0})},Ku=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Hu(t))!qu.call(r,o)&&o!==e&&po(r,o,{get:()=>t[o],enumerable:!(n=zu(t,o))||n.enumerable});return r};var Gu=r=>Ku(po({},"__esModule",{value:!0}),r);var vp={};Ct(vp,{LIBP2P_DEVTOOLS_METRICS_KEY:()=>Nu,SOURCE_CONTENT_SCRIPT:()=>wp,SOURCE_DEVTOOLS:()=>Lu,SOURCE_METRICS:()=>_u,SOURCE_SERVICE_WORKER:()=>bp,devToolsMetrics:()=>Ep,valueCodecs:()=>Qi});var Xr=Symbol.for("@libp2p/peer-id");function as(r){return!!r?.[Xr]}var ze=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Qr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Jr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var yr=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};function us(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function fs(...r){let t=[];for(let e of r)us(e)&&t.push(e);await Promise.all(t.map(async e=>{e.beforeStart!=null&&await e.beforeStart()})),await Promise.all(t.map(async e=>{await e.start()})),await Promise.all(t.map(async e=>{e.afterStart!=null&&await e.afterStart()}))}async function ls(...r){let t=[];for(let e of r)us(e)&&t.push(e);await Promise.all(t.map(async e=>{e.beforeStop!=null&&await e.beforeStop()})),await Promise.all(t.map(async e=>{await e.stop()})),await Promise.all(t.map(async e=>{e.afterStop!=null&&await e.afterStop()}))}var tn=Symbol.for("@libp2p/service-capabilities"),Cp=Symbol.for("@libp2p/service-dependencies");var bo={};Ct(bo,{base32:()=>$t,base32hex:()=>ef,base32hexpad:()=>nf,base32hexpadupper:()=>of,base32hexupper:()=>rf,base32pad:()=>Ju,base32padupper:()=>tf,base32upper:()=>Qu,base32z:()=>sf});var Xp=new Uint8Array(0);function ds(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 te(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 hs(r){return new TextEncoder().encode(r)}function ps(r){return new TextDecoder().decode(r)}function ju(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),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function l(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var m=0,d=0,x=0,A=E.length;x!==A&&E[x]===0;)x++,m++;for(var y=(A-x)*u+1>>>0,B=new Uint8Array(y);x!==A;){for(var R=E[x],L=0,T=y-1;(R!==0||L<d)&&T!==-1;T--,L++)R+=256*B[T]>>>0,B[T]=R%c>>>0,R=R/c>>>0;if(R!==0)throw new Error("Non-zero carry");d=L,x++}for(var k=y-d;k!==y&&B[k]===0;)k++;for(var _=a.repeat(m);k<y;++k)_+=r.charAt(B[k]);return _}function h(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var m=0;if(E[m]!==" "){for(var d=0,x=0;E[m]===a;)d++,m++;for(var A=(E.length-m)*f+1>>>0,y=new Uint8Array(A);E[m];){var B=e[E.charCodeAt(m)];if(B===255)return;for(var R=0,L=A-1;(B!==0||R<x)&&L!==-1;L--,R++)B+=c*y[L]>>>0,y[L]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");x=R,m++}if(E[m]!==" "){for(var T=A-x;T!==A&&y[T]===0;)T++;for(var k=new Uint8Array(d+(A-T)),_=d;T!==A;)k[_++]=y[T++];return k}}}function w(E){var m=h(E);if(m)return m;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:h,decode:w}}var Zu=ju,Wu=Zu,gs=Wu;var mo=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")}},go=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),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 ys(this,t)}},yo=class{decoders;constructor(t){this.decoders=t}or(t){return ys(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 ys(r,t){return new yo({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var xo=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 mo(t,e,n),this.decoder=new go(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function He({name:r,prefix:t,encode:e,decode:n}){return new xo(r,t,e,n)}function de({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=gs(e,r);return He({prefix:t,name:r,encode:n,decode:i=>te(o(i))})}function Yu(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,f=0;for(let u=0;u<i;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|l,c+=e,c>=8&&(c-=8,s[f++]=255&a>>c)}if(c>=e||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return s}function Xu(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>e;)s-=e,i+=t[o&c>>s];if(s!==0&&(i+=t[o&c<<e-s]),n)for(;i.length*e&7;)i+="=";return i}function rt({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return He({prefix:t,name:r,encode(o){return Xu(o,n,e)},decode(o){return Yu(o,n,e,r)}})}var $t=rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qu=rt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ju=rt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),tf=rt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ef=rt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),rf=rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),nf=rt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),of=rt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),sf=rt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var wo={};Ct(wo,{base58btc:()=>J,base58flickr:()=>cf});var J=de({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),cf=de({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Eo={};Ct(Eo,{base64:()=>Yt,base64pad:()=>af,base64url:()=>uf,base64urlpad:()=>ff});var Yt=rt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),af=rt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),uf=rt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ff=rt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function lf(r,t){try{if(typeof r=="string"&&r.length>0)return df(r);if(typeof r=="number"&&isFinite(r))return t?.long?pf(r):hf(r);throw new Error("Value is not a string or number.")}catch(e){let n=mf(e)?`${e.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function df(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 rn=lf;function hf(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 pf(r){let t=Math.abs(r);return t>=864e5?en(r,t,864e5,"day"):t>=36e5?en(r,t,36e5,"hour"):t>=6e4?en(r,t,6e4,"minute"):t>=1e3?en(r,t,1e3,"second"):`${r} ms`}function en(r,t,e,n){let o=t>=e*1.5;return`${Math.round(r/e)} ${n}${o?"s":""}`}function mf(r){return typeof r=="object"&&r!==null&&"message"in r}function vo(r){e.debug=e,e.default=e,e.coerce=a,e.disable=i,e.enable=o,e.enabled=s,e.humanize=rn,e.destroy=f,Object.keys(r).forEach(u=>{e[u]=r[u]}),e.names=[],e.skips=[],e.formatters={};function t(u){let l=0;for(let h=0;h<u.length;h++)l=(l<<5)-l+u.charCodeAt(h),l|=0;return e.colors[Math.abs(l)%e.colors.length]}e.selectColor=t;function e(u){let l,h=null,w,E;function m(...d){if(!m.enabled)return;let x=m,A=Number(new Date),y=A-(l||A);x.diff=y,x.prev=l,x.curr=A,l=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,(L,T)=>{if(L==="%%")return"%";B++;let k=e.formatters[T];if(typeof k=="function"){let _=d[B];L=k.call(x,_),d.splice(B,1),B--}return L}),e.formatArgs.call(x,d),(x.log||e.log).apply(x,d)}return m.namespace=u,m.useColors=e.useColors(),m.color=e.selectColor(u),m.extend=n,m.destroy=e.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(w!==e.namespaces&&(w=e.namespaces,E=e.enabled(u)),E),set:d=>{h=d}}),typeof e.init=="function"&&e.init(m),m}function n(u,l){let h=e(this.namespace+(typeof l>"u"?":":l)+u);return h.log=this.log,h}function o(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let l,h=(typeof u=="string"?u:"").split(/[\s,]+/),w=h.length;for(l=0;l<w;l++)h[l]&&(u=h[l].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(l=>"-"+l)].join(",");return e.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,h;for(l=0,h=e.skips.length;l<h;l++)if(e.skips[l].test(u))return!1;for(l=0,h=e.names.length;l<h;l++)if(e.names[l].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 f(){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 nn=vf(),gf=["#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 yf(){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 xf(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+rn(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 bf=console.debug??console.log??(()=>{});function wf(r){try{r?nn?.setItem("debug",r):nn?.removeItem("debug")}catch{}}function Ef(){let r;try{r=nn?.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function vf(){try{return localStorage}catch{}}function Sf(r){r.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}var xs=vo({formatArgs:xf,save:wf,load:Ef,useColors:yf,setupFormatters:Sf,colors:gf,storage:nn,log:bf});var Et=xs;Et.formatters.b=r=>r==null?"undefined":J.baseEncode(r);Et.formatters.t=r=>r==null?"undefined":$t.baseEncode(r);Et.formatters.m=r=>r==null?"undefined":Yt.baseEncode(r);Et.formatters.p=r=>r==null?"undefined":r.toString();Et.formatters.c=r=>r==null?"undefined":r.toString();Et.formatters.k=r=>r==null?"undefined":r.toString();Et.formatters.a=r=>r==null?"undefined":r.toString();function Af(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function bs(r){let t=Af(`${r}:trace`);return Et.enabled(`${r}:trace`)&&Et.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=Et(`${r}:trace`)),Object.assign(Et(r),{error:Et(`${r}:error`),trace:t})}function ws(){Et.disable()}function Es(r){Et.enable(r)}function Bf(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 vs=Bf;function If(r){return r[Symbol.asyncIterator]!=null}function Ss(r){return r?.then!=null}function Cf(r,t){let e=0;if(If(r))return async function*(){for await(let a of r){let f=t(a,e++);Ss(f)&&await f,yield a}}();let n=vs(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 f=t(a,e++);Ss(f)&&await f,yield a}}();let c=t;return function*(){yield o;for(let a of n)c(a,e++),yield a}()}var So=Cf;var kf=bs("libp2p:simple-metrics"),xr=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}}},br=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}}},Ao=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";[tn]=["@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 xr?t[e]=n.value:n instanceof br?t[e]=n.values:t[e]=await n();this.onMetrics(structuredClone(t))}).catch(t=>{kf.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(So(c,a=>{n._incrementValue(`${e} sent`,a.byteLength)}))};let i=t.source;t.source=So(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 xr;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 br;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 xr;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 br;return this.metrics.set(t,n),n}};function As(r){return t=>new Ao(t,r)}function Vt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var on=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},qe=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new on(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 on(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 Bo=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function he(r={}){return Tf(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 Tf(r,t){t=t??{};let e=t.onEnd,n=new qe,o,i,s,c=Vt(),a=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((d,x)=>{i=A=>{i=null,n.push(A);try{d(r(n))}catch(y){x(y)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=Vt()})}},f=d=>i!=null?i(d):(n.push(d),o),u=d=>(n=new qe,i!=null?i({error:d}):(n.push({error:d}),o)),l=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 f({done:!1,value:d})},h=d=>s?o:(s=!0,d!=null?u(d):f({done:!0})),w=()=>(n=new qe,h(),{done:!0}),E=d=>(h(d),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:w,throw:E,push:l,end:h,get readableLength(){return n.size},onEmpty:async d=>{let x=d?.signal;if(x?.throwIfAborted(),n.isEmpty())return;let A,y;x!=null&&(A=new Promise((B,R)=>{y=()=>{R(new Bo)},x.addEventListener("abort",y)}));try{await Promise.race([c.promise,A])}finally{y!=null&&x!=null&&x?.removeEventListener("abort",y)}}},e==null)return o;let m=o;return o={[Symbol.asyncIterator](){return this},next(){return m.next()},throw(d){return m.throw(d),e!=null&&(e(d),e=void 0),{done:!0}},return(){return m.return(),e!=null&&(e(),e=void 0),{done:!0}},push:l,end(d){return m.end(d),e!=null&&(e(d),e=void 0),o},get readableLength(){return m.readableLength},onEmpty:d=>m.onEmpty(d)},o}function Uf(r){return r[Symbol.asyncIterator]!=null}function Lf(...r){let t=[];for(let e of r)Uf(e)||t.push(e);return t.length===r.length?function*(){for(let e of t)yield*e}():async function*(){let e=he({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)e.push(o)})),e.end()}catch(n){e.end(n)}}),yield*e}()}var Bs=Lf;function Is(r,...t){if(r==null)throw new Error("Empty pipeline");if(Io(r)){let n=r;r=()=>n.source}else if(ks(r)||Cs(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&Io(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++)Io(e[n])&&(e[n]=Nf(e[n]));return _f(...e)}var _f=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},Cs=r=>r?.[Symbol.asyncIterator]!=null,ks=r=>r?.[Symbol.iterator]!=null,Io=r=>r==null?!1:r.sink!=null&&r.source!=null,Nf=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=he({objectMode:!0});e.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(Cs(i))o=async function*(){yield*i,n.end()};else if(ks(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Bs(n,o())}return r.source};function sn(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 zt(r=0){return new Uint8Array(r)}function yt(r=0){return new Uint8Array(r)}var Rf=Math.pow(2,7),Pf=Math.pow(2,14),Df=Math.pow(2,21),Co=Math.pow(2,28),ko=Math.pow(2,35),To=Math.pow(2,42),Uo=Math.pow(2,49),G=128,xt=127;function ft(r){if(r<Rf)return 1;if(r<Pf)return 2;if(r<Df)return 3;if(r<Co)return 4;if(r<ko)return 5;if(r<To)return 6;if(r<Uo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Lo(r,t,e=0){switch(ft(r)){case 8:t[e++]=r&255|G,r/=128;case 7:t[e++]=r&255|G,r/=128;case 6:t[e++]=r&255|G,r/=128;case 5:t[e++]=r&255|G,r/=128;case 4:t[e++]=r&255|G,r>>>=7;case 3:t[e++]=r&255|G,r>>>=7;case 2:t[e++]=r&255|G,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Mf(r,t,e=0){switch(ft(r)){case 8:t.set(e++,r&255|G),r/=128;case 7:t.set(e++,r&255|G),r/=128;case 6:t.set(e++,r&255|G),r/=128;case 5:t.set(e++,r&255|G),r/=128;case 4:t.set(e++,r&255|G),r>>>=7;case 3:t.set(e++,r&255|G),r>>>=7;case 2:t.set(e++,r&255|G),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function _o(r,t){let e=r[t],n=0;if(n+=e&xt,e<G||(e=r[t+1],n+=(e&xt)<<7,e<G)||(e=r[t+2],n+=(e&xt)<<14,e<G)||(e=r[t+3],n+=(e&xt)<<21,e<G)||(e=r[t+4],n+=(e&xt)*Co,e<G)||(e=r[t+5],n+=(e&xt)*ko,e<G)||(e=r[t+6],n+=(e&xt)*To,e<G)||(e=r[t+7],n+=(e&xt)*Uo,e<G))return n;throw new RangeError("Could not decode varint")}function Of(r,t){let e=r.get(t),n=0;if(n+=e&xt,e<G||(e=r.get(t+1),n+=(e&xt)<<7,e<G)||(e=r.get(t+2),n+=(e&xt)<<14,e<G)||(e=r.get(t+3),n+=(e&xt)<<21,e<G)||(e=r.get(t+4),n+=(e&xt)*Co,e<G)||(e=r.get(t+5),n+=(e&xt)*ko,e<G)||(e=r.get(t+6),n+=(e&xt)*To,e<G)||(e=r.get(t+7),n+=(e&xt)*Uo,e<G))return n;throw new RangeError("Could not decode varint")}function pe(r,t,e=0){return t==null&&(t=yt(ft(r))),t instanceof Uint8Array?Lo(r,t,e):Mf(r,t,e)}function ee(r,t=0){return r instanceof Uint8Array?_o(r,t):Of(r,t)}function Lt(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=yt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function Ht(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 Us=Symbol.for("@achingbrain/uint8arraylist");function Ts(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 an(r){return!!r?.[Us]}var Ke=class r{bufs;length;[Us]=!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(an(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(an(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=Ts(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Ts(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(an(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Lt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Lt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),i=new r;return i.length=o,i.bufs=[...n],i}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,a=c+s.byteLength;if(o=a,t>=a)continue;let f=t>=c&&t<a,u=e>c&&e<=a;if(f&&u){if(t===c&&e===a){n.push(s);break}let l=t-c;n.push(s.subarray(l,l+(e-t)));break}if(f){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(!an(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 l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let c=s,a=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=e;l<=a;l+=u){u=0;for(let h=f;h>=0;h--){let w=this.get(l+h);if(n[h]!==w){u=Math.max(1,h-c[w]);break}}if(u===0)return l}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=yt(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=zt(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=zt(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=zt(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=yt(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=zt(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=zt(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=zt(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=zt(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=zt(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(!Ht(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,i)=>o+i.byteLength,0)),n.length=e,n}};function un(r){return r[Symbol.asyncIterator]!=null}var fn=r=>{let t=ft(r),e=yt(t);return pe(r,e),fn.bytes=t,e};fn.bytes=0;function ln(r,t){t=t??{};let e=t.lengthEncoder??fn;function*n(o){let i=e(o.byteLength);i instanceof Uint8Array?yield i:yield*i,o instanceof Uint8Array?yield o:yield*o}return un(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}ln.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??fn;return new Ke(e(r.byteLength),r)};var dn=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},hn=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},pn=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},wr=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var Ff=8,$f=1024*1024*4,ke;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(ke||(ke={}));var No=r=>{let t=ee(r);return No.bytes=ft(t),t};No.bytes=0;function Er(r,t){let e=new Ke,n=ke.LENGTH,o=-1,i=t?.lengthDecoder??No,s=t?.maxLengthLength??Ff,c=t?.maxDataLength??$f;function*a(){for(;e.byteLength>0;){if(n===ke.LENGTH)try{if(o=i(e),o<0)throw new dn("Invalid message length");if(o>c)throw new hn("Message length too long");let f=i.bytes;e.consume(f),t?.onLength!=null&&t.onLength(o),n=ke.DATA}catch(f){if(f instanceof RangeError){if(e.byteLength>s)throw new pn("Message length length too long");break}throw f}if(n===ke.DATA){if(e.byteLength<o)break;let f=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(f),yield f,n=ke.LENGTH}}}return un(r)?async function*(){for await(let f of r)e.append(f),yield*a();if(e.byteLength>0)throw new wr("Unexpected end of input")}():function*(){for(let f of r)e.append(f),yield*a();if(e.byteLength>0)throw new wr("Unexpected end of input")}()}Er.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 Er(n,{...t??{},onLength:i=>{e=i}})};var Ls="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Ge=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=Ls[e[r]&63];return t};var mn=class extends Error{constructor(t="Method not found"){super(t),this.name="MethodNotFoundError"}},gn=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"}},yn=class extends Error{constructor(t="Cannot reuse RPC target name"){super(t),this.name="DuplicateTargetNameError"}},Sr=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"}},Ar=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidInvocationTypeError"}},je=class extends Error{constructor(t="Parent invocation scope not found"){super(t),this.name="MissingParentScopeError"}},bn=class extends Error{constructor(t="Invocation not found"){super(t),this.name="MissingInvocationError"}},wn=class extends Error{constructor(t="Callback not found"){super(t),this.name="MissingCallbackError"}};var Ro=new Float32Array([-0]),me=new Uint8Array(Ro.buffer);function _s(r,t,e){Ro[0]=r,t[e]=me[0],t[e+1]=me[1],t[e+2]=me[2],t[e+3]=me[3]}function Ns(r,t){return me[0]=r[t],me[1]=r[t+1],me[2]=r[t+2],me[3]=r[t+3],Ro[0]}var Po=new Float64Array([-0]),bt=new Uint8Array(Po.buffer);function Rs(r,t,e){Po[0]=r,t[e]=bt[0],t[e+1]=bt[1],t[e+2]=bt[2],t[e+3]=bt[3],t[e+4]=bt[4],t[e+5]=bt[5],t[e+6]=bt[6],t[e+7]=bt[7]}function Ps(r,t){return bt[0]=r[t],bt[1]=r[t+1],bt[2]=r[t+2],bt[3]=r[t+3],bt[4]=r[t+4],bt[5]=r[t+5],bt[6]=r[t+6],bt[7]=r[t+7],Po[0]}var Vf=BigInt(Number.MAX_SAFE_INTEGER),zf=BigInt(Number.MIN_SAFE_INTEGER),_t=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 Te;if(t<Vf&&t>zf)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>Ds&&(o=0n,++n>Ds&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return Te;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):Te}},Te=new _t(0,0);Te.toBigInt=function(){return 0n};Te.zzEncode=Te.zzDecode=function(){return this};Te.length=function(){return 1};var Ds=4294967296n;function Ms(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 Os(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 Do(r,t,e){let n=e,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function qt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function En(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Mo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,qt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw qt(this,4);return En(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qt(this,4);return En(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qt(this,4);let t=Ns(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw qt(this,4);let t=Ps(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw qt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Os(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw qt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw qt(this);while(this.buf[this.pos++]&128);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 _t(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw qt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw qt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw qt(this,8);let t=En(this.buf,this.pos+=4),e=En(this.buf,this.pos+=4);return new _t(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=_o(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 Oo(r){return new Mo(r instanceof Uint8Array?r:r.subarray())}function vt(r,t,e){let n=Oo(r);return t.decode(n,void 0,e)}var Fo={};Ct(Fo,{base10:()=>Hf});var Hf=de({prefix:"9",name:"base10",alphabet:"0123456789"});var $o={};Ct($o,{base16:()=>qf,base16upper:()=>Kf});var qf=rt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Kf=rt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Vo={};Ct(Vo,{base2:()=>Gf});var Gf=rt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var zo={};Ct(zo,{base256emoji:()=>Xf});var $s=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}"),jf=$s.reduce((r,t,e)=>(r[e]=t,r),[]),Zf=$s.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Wf(r){return r.reduce((t,e)=>(t+=jf[e],t),"")}function Yf(r){let t=[];for(let e of r){let n=Zf[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Xf=He({prefix:"\u{1F680}",name:"base256emoji",encode:Wf,decode:Yf});var Ho={};Ct(Ho,{base36:()=>Qf,base36upper:()=>Jf});var Qf=de({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Jf=de({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var qo={};Ct(qo,{base8:()=>tl});var tl=rt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ko={};Ct(Ko,{identity:()=>el});var el=He({prefix:"\0",name:"identity",encode:r=>ps(r),decode:r=>hs(r)});var Cm=new TextEncoder,km=new TextDecoder;var jo={};Ct(jo,{identity:()=>ne});var ol=Hs,Vs=128,il=127,sl=~il,cl=Math.pow(2,31);function Hs(r,t,e){t=t||[],e=e||0;for(var n=e;r>=cl;)t[e++]=r&255|Vs,r/=128;for(;r&sl;)t[e++]=r&255|Vs,r>>>=7;return t[e]=r|0,Hs.bytes=e-n+1,t}var al=Go,ul=128,zs=127;function Go(r,n){var e=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw Go.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&zs)<<o:(s&zs)*Math.pow(2,o),o+=7}while(s>=ul);return Go.bytes=i-n,e}var fl=Math.pow(2,7),ll=Math.pow(2,14),dl=Math.pow(2,21),hl=Math.pow(2,28),pl=Math.pow(2,35),ml=Math.pow(2,42),gl=Math.pow(2,49),yl=Math.pow(2,56),xl=Math.pow(2,63),bl=function(r){return r<fl?1:r<ll?2:r<dl?3:r<hl?4:r<pl?5:r<ml?6:r<gl?7:r<yl?8:r<xl?9:10},wl={encode:ol,decode:al,encodingLength:bl},El=wl,Br=El;function Ir(r,t=0){return[Br.decode(r,t),Br.decode.bytes]}function Ze(r,t,e=0){return Br.encode(r,t,e),t}function We(r){return Br.encodingLength(r)}function Ue(r,t){let e=t.byteLength,n=We(r),o=n+We(e),i=new Uint8Array(o+e);return Ze(r,i,0),Ze(e,i,n),i.set(t,o),new Ye(r,e,t,i)}function re(r){let t=te(r),[e,n]=Ir(t),[o,i]=Ir(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Ye(e,o,s,t)}function qs(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ds(r.bytes,e.bytes)}}var Ye=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Ks=0,vl="identity",Gs=te;function Sl(r){return Ue(Ks,Gs(r))}var ne={code:Ks,name:vl,encode:Gs,digest:Sl};var Yo={};Ct(Yo,{sha256:()=>Cr,sha512:()=>Al});function Wo({name:r,code:t,encode:e}){return new Zo(r,t,e)}var Zo=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?Ue(this.code,e):e.then(n=>Ue(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Zs(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Cr=Wo({name:"sha2-256",code:18,encode:Zs("SHA-256")}),Al=Wo({name:"sha2-512",code:19,encode:Zs("SHA-512")});function Ws(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Il(e,Xo(r),t??J.encoder);default:return Cl(e,Xo(r),t??$t.encoder)}}var Ys=new WeakMap;function Xo(r){let t=Ys.get(r);if(t==null){let e=new Map;return Ys.set(r,e),e}return t}var mt=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!==kr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==kl)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=Ue(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&&qs(t.multihash,n.multihash)}toString(t){return Ws(this,t)}toJSON(){return{"/":Ws(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??Xs(n,o,i.bytes))}else if(e[Tl]===!0){let{version:n,multihash:o,code:i}=e,s=re(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!==kr)throw new Error(`Version 0 CID must use dag-pb (code: ${kr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Xs(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,kr,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=te(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 Ye(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[l,h]=Ir(t.subarray(e));return e+=h,l},o=n(),i=kr;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(),f=e+a,u=f-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(t,e){let[n,o]=Bl(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 Xo(i).set(n,t),i}};function Bl(r,t){switch(r[0]){case"Q":{let e=t??J;return[J.prefix,e.decode(`${J.prefix}${r}`)]}case J.prefix:{let e=t??J;return[J.prefix,e.decode(r)]}case $t.prefix:{let e=t??$t;return[$t.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Il(r,t,e){let{prefix:n}=e;if(n!==J.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function Cl(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 kr=112,kl=18;function Xs(r,t,e){let n=We(r),o=n+We(t),i=new Uint8Array(o+e.byteLength);return Ze(r,i,0),Ze(t,i,n),i.set(e,o),i}var Tl=Symbol.for("@ipld/js-cid/CID");var Tr={...Ko,...Vo,...qo,...Fo,...$o,...bo,...Ho,...wo,...Eo,...zo},Wm={...Yo,...jo};function Js(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Qs=Js("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Qo=Js("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=yt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Ul={utf8:Qs,"utf-8":Qs,hex:Tr.base16,latin1:Qo,ascii:Qo,binary:Qo,...Tr},Sn=Ul;function ye(r,t="utf8"){let e=Sn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Jo(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return yt(s);o+s>t&&(n=yt(t),o=0);let c=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),c}}var Le=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function ti(){}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}},Ll=Jo();function _l(r){return globalThis.Buffer!=null?yt(r):Ll(r)}var Lr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Le(ti,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Le(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new ni((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(An,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=_t.fromBigInt(t);return this._push(An,e.length(),e)}uint64Number(t){return this._push(Lo,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=_t.fromBigInt(t).zzEncode();return this._push(An,e.length(),e)}sint64Number(t){let e=_t.fromNumber(t).zzEncode();return this._push(An,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ei,1,t?1:0)}fixed32(t){return this._push(Ur,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=_t.fromBigInt(t);return this._push(Ur,4,e.lo)._push(Ur,4,e.hi)}fixed64Number(t){let e=_t.fromNumber(t);return this._push(Ur,4,e.lo)._push(Ur,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(_s,4,t)}double(t){return this._push(Rs,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(ei,1,0):this.uint32(e)._push(Rl,e,t)}string(t){let e=Ms(t);return e!==0?this.uint32(e)._push(Do,e,t):this._push(ei,1,0)}fork(){return this.states=new ri(this),this.head=this.tail=new Le(ti,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 Le(ti,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=_l(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function ei(r,t,e){t[e]=r&255}function Nl(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var ni=class extends Le{next;constructor(t,e){super(Nl,t,e),this.next=void 0}};function An(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 Ur(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 Rl(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Lr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Pl,t,r),this},Lr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Dl,t,r),this});function Pl(r,t,e){t.set(r,e)}function Dl(r,t,e){r.length<40?Do(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(ye(r),e)}function oi(){return new Lr}function St(r,t){let e=oi();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Xe;(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"})(Xe||(Xe={}));function Bn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function _r(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 Bn("enum",Xe.VARINT,e,n)}function At(r,t){return Bn("message",Xe.LENGTH_DELIMITED,r,t)}var oe=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 In;(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"})(In||(In={}));(function(r){r.codec=()=>_r(In)})(q||(q={}));var kt;(function(r){let t;r.codec=()=>(t==null&&(t=At((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=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(kt||(kt={}));var Bt;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.type!=null&&In[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:zt(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=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Bt||(Bt={}));var _e;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.path!=null&&e.path!==""&&(n.uint32(18),n.string(e.path)),e.args!=null)for(let i of e.args)n.uint32(26),kt.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",path:"",args:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.path=e.string();break}case 3:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new oe('Decode error - map field "args" had too many elements');i.args.push(kt.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(_e||(_e={}));var Nr;(function(r){let t;r.codec=()=>(t==null&&(t=At((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=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Nr||(Nr={}));var Qe;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.value!=null&&(n.uint32(18),kt.codec().encode(e.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.value=kt.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Qe||(Qe={}));var Rr;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.error!=null&&(n.uint32(18),kt.codec().encode(e.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.error=kt.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Rr||(Rr={}));var Je;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);if(e.callback!=null&&e.callback!==""&&(n.uint32(26),n.string(e.callback)),e.args!=null)for(let i of e.args)n.uint32(34),kt.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[],callback:"",args:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new oe('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 oe('Decode error - map field "args" had too many elements');i.args.push(kt.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Je||(Je={}));var tr;(function(r){let t;r.codec=()=>(t==null&&(t=At((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 oe('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=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(tr||(tr={}));var Pr;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);e.value!=null&&(n.uint32(26),kt.codec().encode(e.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new oe('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.value=kt.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Pr||(Pr={}));var Dr;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);e.error!=null&&(n.uint32(26),kt.codec().encode(e.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new oe('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.error=kt.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Dr||(Dr={}));function Ml(r){return r.parents!=null}function tc(r,t){if(Ml(r))return Ol(r.parents,t);let e=t.get(r.scope);if(e==null)throw new bn;return e}function Ol(r,t){let e;for(let n of r){if(e==null){if(e=t.get(n),e==null)throw new je;continue}if(e=e.children.get(n),e==null)throw new je}if(e==null)throw new je;return e}var Fl={type:1024,canEncode:r=>r===void 0,decode:()=>{}},ec=Fl;var $l={type:1025,canEncode:r=>r===null,decode:()=>null},rc=$l;var Vl=["string","number","bigint","symbol"],zl=["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 nc(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let t=typeof r;if(Vl.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(r))return"Array";if(Hl(r))return"Buffer";let e=ql(r);return e||"Object"}function Hl(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function ql(r){let t=Object.prototype.toString.call(r).slice(8,-1);if(zl.includes(t))return t}var p=class{constructor(t,e,n){this.major=t,this.majorEncoded=t<<5,this.name=e,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};p.uint=new p(0,"uint",!0);p.negint=new p(1,"negint",!0);p.bytes=new p(2,"bytes",!0);p.string=new p(3,"string",!0);p.array=new p(4,"array",!1);p.map=new p(5,"map",!1);p.tag=new p(6,"tag",!1);p.float=new p(7,"float",!0);p.false=new p(7,"false",!0);p.true=new p(7,"true",!0);p.null=new p(7,"null",!0);p.undefined=new p(7,"undefined",!0);p.break=new p(7,"break",!0);var C=class{constructor(t,e,n){this.type=t,this.value=e,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var er=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Kl=new TextDecoder,Gl=new TextEncoder;function Cn(r){return er&&globalThis.Buffer.isBuffer(r)}function ii(r){return r instanceof Uint8Array?Cn(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var cc=er?(r,t,e)=>e-t>64?globalThis.Buffer.from(r.subarray(t,e)).toString("utf8"):ic(r,t,e):(r,t,e)=>e-t>64?Kl.decode(r.subarray(t,e)):ic(r,t,e),ac=er?r=>r.length>64?globalThis.Buffer.from(r):oc(r):r=>r.length>64?Gl.encode(r):oc(r),Xt=r=>Uint8Array.from(r),rr=er?(r,t,e)=>Cn(r)?new Uint8Array(r.subarray(t,e)):r.slice(t,e):(r,t,e)=>r.slice(t,e),uc=er?(r,t)=>(r=r.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),ii(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},fc=er?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function lc(r,t){if(Cn(r)&&Cn(t))return r.compare(t);for(let e=0;e<r.length;e++)if(r[e]!==t[e])return r[e]<t[e]?-1:1;return 0}function oc(r){let t=[],e=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128)}return t}function ic(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,f,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],f=r[t+3],(c&192)===128&&(a&192)===128&&(f&192)===128&&(u=(o&15)<<18|(c&63)<<12|(a&63)<<6|f&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 jl(n)}var sc=4096;function jl(r){let t=r.length;if(t<=sc)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=sc));return e}var Zl=256,Mr=class{constructor(t=Zl){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=fc(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=rr(n,0,this.cursor)}else e=uc(this.chunks,this.cursor);return t&&this.reset(),e}};var M="CBOR decode error:",si="CBOR encode error:",Or=[];Or[23]=1;Or[24]=2;Or[25]=3;Or[26]=5;Or[27]=9;function ie(r,t,e){if(r.length-t<e)throw new Error(`${M} not enough data for type`)}var lt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Nt(r,t,e){ie(r,t,1);let n=r[t];if(e.strict===!0&&n<lt[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Rt(r,t,e){ie(r,t,2);let n=r[t]<<8|r[t+1];if(e.strict===!0&&n<lt[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Pt(r,t,e){ie(r,t,4);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];if(e.strict===!0&&n<lt[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Dt(r,t,e){ie(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<lt[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 dc(r,t,e,n){return new C(p.uint,Nt(r,t+1,n),2)}function hc(r,t,e,n){return new C(p.uint,Rt(r,t+1,n),3)}function pc(r,t,e,n){return new C(p.uint,Pt(r,t+1,n),5)}function mc(r,t,e,n){return new C(p.uint,Dt(r,t+1,n),9)}function Mt(r,t){return gt(r,0,t.value)}function gt(r,t,e){if(e<lt[0]){let n=Number(e);r.push([t|n])}else if(e<lt[1]){let n=Number(e);r.push([t|24,n])}else if(e<lt[2]){let n=Number(e);r.push([t|25,n>>>8,n&255])}else if(e<lt[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<lt[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`)}}Mt.encodedSize=function(t){return gt.encodedSize(t.value)};gt.encodedSize=function(t){return t<lt[0]?1:t<lt[1]?2:t<lt[2]?3:t<lt[3]?5:9};Mt.compareTokens=function(t,e){return t.value<e.value?-1:t.value>e.value?1:0};function gc(r,t,e,n){return new C(p.negint,-1-Nt(r,t+1,n),2)}function yc(r,t,e,n){return new C(p.negint,-1-Rt(r,t+1,n),3)}function xc(r,t,e,n){return new C(p.negint,-1-Pt(r,t+1,n),5)}var ci=BigInt(-1),bc=BigInt(1);function wc(r,t,e,n){let o=Dt(r,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new C(p.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new C(p.negint,ci-BigInt(o),9)}function kn(r,t){let e=t.value,n=typeof e=="bigint"?e*ci-bc:e*-1-1;gt(r,t.type.majorEncoded,n)}kn.encodedSize=function(t){let e=t.value,n=typeof e=="bigint"?e*ci-bc:e*-1-1;return n<lt[0]?1:n<lt[1]?2:n<lt[2]?3:n<lt[3]?5:9};kn.compareTokens=function(t,e){return t.value<e.value?1:t.value>e.value?-1:0};function Fr(r,t,e,n){ie(r,t,e+n);let o=rr(r,t+e,t+e+n);return new C(p.bytes,o,e+n)}function Ec(r,t,e,n){return Fr(r,t,1,e)}function vc(r,t,e,n){return Fr(r,t,2,Nt(r,t+1,n))}function Sc(r,t,e,n){return Fr(r,t,3,Rt(r,t+1,n))}function Ac(r,t,e,n){return Fr(r,t,5,Pt(r,t+1,n))}function Bc(r,t,e,n){let o=Dt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return Fr(r,t,9,o)}function Tn(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===p.string?ac(r.value):r.value),r.encodedBytes}function nr(r,t){let e=Tn(t);gt(r,t.type.majorEncoded,e.length),r.push(e)}nr.encodedSize=function(t){let e=Tn(t);return gt.encodedSize(e.length)+e.length};nr.compareTokens=function(t,e){return Yl(Tn(t),Tn(e))};function Yl(r,t){return r.length<t.length?-1:r.length>t.length?1:lc(r,t)}function $r(r,t,e,n,o){let i=e+n;ie(r,t,i);let s=new C(p.string,cc(r,t+e,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=rr(r,t+e,t+i)),s}function Ic(r,t,e,n){return $r(r,t,1,e,n)}function Cc(r,t,e,n){return $r(r,t,2,Nt(r,t+1,n),n)}function kc(r,t,e,n){return $r(r,t,3,Rt(r,t+1,n),n)}function Tc(r,t,e,n){return $r(r,t,5,Pt(r,t+1,n),n)}function Uc(r,t,e,n){let o=Dt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return $r(r,t,9,o,n)}var Lc=nr;function or(r,t,e,n){return new C(p.array,n,e)}function _c(r,t,e,n){return or(r,t,1,e)}function Nc(r,t,e,n){return or(r,t,2,Nt(r,t+1,n))}function Rc(r,t,e,n){return or(r,t,3,Rt(r,t+1,n))}function Pc(r,t,e,n){return or(r,t,5,Pt(r,t+1,n))}function Dc(r,t,e,n){let o=Dt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return or(r,t,9,o)}function Mc(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return or(r,t,1,1/0)}function Un(r,t){gt(r,p.array.majorEncoded,t.value)}Un.compareTokens=Mt.compareTokens;Un.encodedSize=function(t){return gt.encodedSize(t.value)};function ir(r,t,e,n){return new C(p.map,n,e)}function Oc(r,t,e,n){return ir(r,t,1,e)}function Fc(r,t,e,n){return ir(r,t,2,Nt(r,t+1,n))}function $c(r,t,e,n){return ir(r,t,3,Rt(r,t+1,n))}function Vc(r,t,e,n){return ir(r,t,5,Pt(r,t+1,n))}function zc(r,t,e,n){let o=Dt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return ir(r,t,9,o)}function Hc(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return ir(r,t,1,1/0)}function Ln(r,t){gt(r,p.map.majorEncoded,t.value)}Ln.compareTokens=Mt.compareTokens;Ln.encodedSize=function(t){return gt.encodedSize(t.value)};function qc(r,t,e,n){return new C(p.tag,e,1)}function Kc(r,t,e,n){return new C(p.tag,Nt(r,t+1,n),2)}function Gc(r,t,e,n){return new C(p.tag,Rt(r,t+1,n),3)}function jc(r,t,e,n){return new C(p.tag,Pt(r,t+1,n),5)}function Zc(r,t,e,n){return new C(p.tag,Dt(r,t+1,n),9)}function _n(r,t){gt(r,p.tag.majorEncoded,t.value)}_n.compareTokens=Mt.compareTokens;_n.encodedSize=function(t){return gt.encodedSize(t.value)};var rd=20,nd=21,od=22,id=23;function Wc(r,t,e,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new C(p.null,null,1):new C(p.undefined,void 0,1)}function Yc(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new C(p.break,void 0,1)}function ai(r,t,e){if(e){if(e.allowNaN===!1&&Number.isNaN(r))throw new Error(`${M} NaN values are not supported`);if(e.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new C(p.float,r,t)}function Xc(r,t,e,n){return ai(ui(r,t+1),3,n)}function Qc(r,t,e,n){return ai(fi(r,t+1),5,n)}function Jc(r,t,e,n){return ai(na(r,t+1),9,n)}function Nn(r,t,e){let n=t.value;if(n===!1)r.push([p.float.majorEncoded|rd]);else if(n===!0)r.push([p.float.majorEncoded|nd]);else if(n===null)r.push([p.float.majorEncoded|od]);else if(n===void 0)r.push([p.float.majorEncoded|id]);else{let o,i=!1;(!e||e.float64!==!0)&&(ea(n),o=ui(Kt,1),n===o||Number.isNaN(n)?(Kt[0]=249,r.push(Kt.slice(0,3)),i=!0):(ra(n),o=fi(Kt,1),n===o&&(Kt[0]=250,r.push(Kt.slice(0,5)),i=!0))),i||(sd(n),o=na(Kt,1),Kt[0]=251,r.push(Kt.slice(0,9)))}}Nn.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){ea(n);let o=ui(Kt,1);if(n===o||Number.isNaN(n))return 3;if(ra(n),o=fi(Kt,1),n===o)return 5}return 9};var ta=new ArrayBuffer(9),Ot=new DataView(ta,1),Kt=new Uint8Array(ta,0);function ea(r){if(r===1/0)Ot.setUint16(0,31744,!1);else if(r===-1/0)Ot.setUint16(0,64512,!1);else if(Number.isNaN(r))Ot.setUint16(0,32256,!1);else{Ot.setFloat32(0,r);let t=Ot.getUint32(0),e=(t&2139095040)>>23,n=t&8388607;if(e===255)Ot.setUint16(0,31744,!1);else if(e===0)Ot.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=e-127;o<-24?Ot.setUint16(0,0):o<-14?Ot.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ot.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ui(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 ra(r){Ot.setFloat32(0,r,!1)}function fi(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 sd(r){Ot.setFloat64(0,r,!1)}function na(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)}Nn.compareTokens=Mt.compareTokens;function K(r,t,e){throw new Error(`${M} encountered invalid minor (${e}) for major ${r[t]>>>5}`)}function Rn(r){return()=>{throw new Error(`${M} ${r}`)}}var S=[];for(let r=0;r<=23;r++)S[r]=K;S[24]=dc;S[25]=hc;S[26]=pc;S[27]=mc;S[28]=K;S[29]=K;S[30]=K;S[31]=K;for(let r=32;r<=55;r++)S[r]=K;S[56]=gc;S[57]=yc;S[58]=xc;S[59]=wc;S[60]=K;S[61]=K;S[62]=K;S[63]=K;for(let r=64;r<=87;r++)S[r]=Ec;S[88]=vc;S[89]=Sc;S[90]=Ac;S[91]=Bc;S[92]=K;S[93]=K;S[94]=K;S[95]=Rn("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)S[r]=Ic;S[120]=Cc;S[121]=kc;S[122]=Tc;S[123]=Uc;S[124]=K;S[125]=K;S[126]=K;S[127]=Rn("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)S[r]=_c;S[152]=Nc;S[153]=Rc;S[154]=Pc;S[155]=Dc;S[156]=K;S[157]=K;S[158]=K;S[159]=Mc;for(let r=160;r<=183;r++)S[r]=Oc;S[184]=Fc;S[185]=$c;S[186]=Vc;S[187]=zc;S[188]=K;S[189]=K;S[190]=K;S[191]=Hc;for(let r=192;r<=215;r++)S[r]=qc;S[216]=Kc;S[217]=Gc;S[218]=jc;S[219]=Zc;S[220]=K;S[221]=K;S[222]=K;S[223]=K;for(let r=224;r<=243;r++)S[r]=Rn("simple values are not supported");S[244]=K;S[245]=K;S[246]=K;S[247]=Wc;S[248]=Rn("simple values are not supported");S[249]=Xc;S[250]=Qc;S[251]=Jc;S[252]=K;S[253]=K;S[254]=K;S[255]=Yc;var Gt=[];for(let r=0;r<24;r++)Gt[r]=new C(p.uint,r,1);for(let r=-1;r>=-24;r--)Gt[31-r]=new C(p.negint,r,1);Gt[64]=new C(p.bytes,new Uint8Array(0),1);Gt[96]=new C(p.string,"",1);Gt[128]=new C(p.array,0,1);Gt[160]=new C(p.map,0,1);Gt[244]=new C(p.false,!1,1);Gt[245]=new C(p.true,!0,1);Gt[246]=new C(p.null,null,1);function oa(r){switch(r.type){case p.false:return Xt([244]);case p.true:return Xt([245]);case p.null:return Xt([246]);case p.bytes:return r.value.length?void 0:Xt([64]);case p.string:return r.value===""?Xt([96]):void 0;case p.array:return r.value===0?Xt([128]):void 0;case p.map:return r.value===0?Xt([160]):void 0;case p.uint:return r.value<24?Xt([Number(r.value)]):void 0;case p.negint:if(r.value>=-24)return Xt([31-Number(r.value)])}}var ad={float64:!1,mapSorter:ld,quickEncodeToken:oa};function ud(){let r=[];return r[p.uint.major]=Mt,r[p.negint.major]=kn,r[p.bytes.major]=nr,r[p.string.major]=Lc,r[p.array.major]=Un,r[p.map.major]=Ln,r[p.tag.major]=_n,r[p.float.major]=Nn,r}var ia=ud(),li=new Mr,Dn=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(`${si} object contains circular references`);return new r(e,t)}},xe={null:new C(p.null,null),undefined:new C(p.undefined,void 0),true:new C(p.true,!0),false:new C(p.false,!1),emptyArray:new C(p.array,0),emptyMap:new C(p.map,0)},be={number(r,t,e,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new C(p.float,r):r>=0?new C(p.uint,r):new C(p.negint,r)},bigint(r,t,e,n){return r>=BigInt(0)?new C(p.uint,r):new C(p.negint,r)},Uint8Array(r,t,e,n){return new C(p.bytes,r)},string(r,t,e,n){return new C(p.string,r)},boolean(r,t,e,n){return r?xe.true:xe.false},null(r,t,e,n){return xe.null},undefined(r,t,e,n){return xe.undefined},ArrayBuffer(r,t,e,n){return new C(p.bytes,new Uint8Array(r))},DataView(r,t,e,n){return new C(p.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,t,e,n){if(!r.length)return e.addBreakTokens===!0?[xe.emptyArray,new C(p.break)]:xe.emptyArray;n=Dn.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=Pn(s,e,n);return e.addBreakTokens?[new C(p.array,r.length),o,new C(p.break)]:[new C(p.array,r.length),o]},Object(r,t,e,n){let o=t!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return e.addBreakTokens===!0?[xe.emptyMap,new C(p.break)]:xe.emptyMap;n=Dn.createCheck(n,r);let c=[],a=0;for(let f of i)c[a++]=[Pn(f,e,n),Pn(o?r.get(f):r[f],e,n)];return fd(c,e),e.addBreakTokens?[new C(p.map,s),c,new C(p.break)]:[new C(p.map,s),c]}};be.Map=be.Object;be.Buffer=be.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))be[`${r}Array`]=be.DataView;function Pn(r,t={},e){let n=nc(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(`${si} unsupported type: ${n}`);return i(r,n,t,e)}function fd(r,t){t.mapSorter&&r.sort(t.mapSorter)}function ld(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=ia[o].compareTokens(e,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function sa(r,t,e,n){if(Array.isArray(t))for(let o of t)sa(r,o,e,n);else e[t.type.major](r,t,n)}function dd(r,t,e){let n=Pn(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 Mr(s);if(i(c,n,e),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return ii(c.chunks[0])}}return li.reset(),sa(li,n,t,e),li.toBytes(!0)}function W(r,t){return t=Object.assign({},ad,t),dd(r,ia,t)}var hd={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Mn=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=Gt[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}},Vr=Symbol.for("DONE"),On=Symbol.for("BREAK");function pd(r,t,e){let n=[];for(let o=0;o<r.value;o++){let i=sr(t,e);if(i===On){if(r.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===Vr)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function md(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=sr(t,e);if(c===On){if(r.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(c===Vr)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=sr(t,e);if(a===Vr)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 sr(r,t){if(r.done())return Vr;let e=r.next();if(e.type===p.break)return On;if(e.type.terminal)return e.value;if(e.type===p.array)return pd(e,r,t);if(e.type===p.map)return md(e,r,t);if(e.type===p.tag){if(t.tags&&typeof t.tags[e.value]=="function"){let n=sr(r,t);return t.tags[e.value](n)}throw new Error(`${M} tag not supported (${e.value})`)}throw new Error("unsupported")}function ca(r,t){if(!(r instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},hd,t);let e=t.tokenizer||new Mn(r,t),n=sr(e,t);if(n===Vr)throw new Error(`${M} did not find any content to decode`);if(n===On)throw new Error(`${M} got unexpected break`);return[n,r.subarray(e.pos())]}function Y(r,t){let[e,n]=ca(r,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return e}var gd={type:1026,canEncode:r=>r===!0||r===!1,encode:r=>W(r),decode:r=>Y(r)},aa=gd;var yd={type:1027,canEncode:r=>typeof r=="number"&&!isNaN(r),encode:r=>W(r),decode:r=>Y(r)},ua=yd;var xd={type:1028,canEncode:r=>typeof r=="string",encode:r=>W(r),decode:r=>Y(r)},fa=xd;var bd={type:1029,canEncode:r=>Array.isArray(r),encode:(r,t,e,n)=>W(r.map(o=>t.toValue(o,e,n))),decode:(r,t,e,n)=>Y(r).map(o=>t.fromValue(o,e,n))},la=bd;var wd={type:1030,canEncode:r=>typeof r=="function",encode:(r,t,e,n)=>{let o=Ge();return n?.callbacks.set(o,{context:e,fn:r}),W(o)},decode:(r,t,e,n)=>async(...o)=>new Promise((i,s)=>{let c=Y(r),a=Ge(),f={scope:a,result:Vt(),callbacks:new Map,children:new Map,parents:[...n.parents,n.scope],abortControllers:[],abortSignals:[]};n.children.set(a,f),o=o.map(l=>t.toValue(l,null,f));let u=sn(f.abortSignals);u.addEventListener("abort",()=>{e.push(Bt.encode({type:q.abortCallbackInvocation,message:tr.encode({scope:a,parents:f.parents})}))}),e.push(Bt.encode({type:q.invokeCallback,message:Je.encode({scope:a,parents:f.parents,callback:c,args:o})})),f.result.promise.then(l=>{i(l)},l=>{s(l)}).finally(()=>{n.children.delete(a),u.clear()})})},da=wd;var Ed={type:1031,canEncode:r=>r.toString()==="NaN"&&isNaN(r),decode:()=>NaN},ha=Ed;var vd={type:1032,canEncode:r=>r instanceof Error,encode:r=>W({message:r.message,name:r.name,code:r.code,type:r.type,stack:r.stack}),decode:r=>{let t=Y(r),e=new Error(t.message);return e.name=t.name,e.stack=t.stack,e.code=t.code,e.type=t.type,e}},pa=vd;var Sd={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")}},ma=Sd;var ga=["__defineGetter__","__defineSetter__","hasOwnProperty","__lookupGetter__","__lookupSetter__","isPrototypeOf","propertyIsEnumerable","toString","valueOf","__proto__","toLocaleString","constructor"],Ad={type:2147483647,canEncode:r=>typeof r=="object",encode:(r,t,e,n)=>{let o={};for(let i in r)ga.includes(i)||Object.hasOwn(r,i)&&(o[i]=r[i]);for(let i of Object.getOwnPropertyNames(Object.getPrototypeOf(r)))ga.includes(i)||(o[i]=r[i]);return W([...Object.entries(o)].map(([i,s])=>[t.toValue(i,r,n),t.toValue(s,r,n)]))},decode:(r,t,e,n)=>{let o={};return Y(r).forEach(([s,c])=>{o[t.fromValue(s,e,n)]=t.fromValue(c,e,n)}),o}},zr=Ad;var Bd={type:1034,canEncode:r=>typeof r.next=="function"&&typeof r.throw=="function"&&typeof r.return=="function",encode:(r,t,e,n)=>zr.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=zr.decode(r,t,e,n);return o[Symbol.asyncIterator]=()=>o,o}},ya=Bd;var Id={type:1035,canEncode:r=>typeof r=="bigint",encode:r=>W(r),decode:r=>BigInt(Y(r))},xa=Id;var Cd={type:1036,canEncode:r=>r instanceof Map,encode:(r,t,e,n)=>W([...r.entries()].map(([o,i])=>[t.toValue(o,e,n),t.toValue(i,e,n)])),decode:(r,t,e,n)=>{let o=new Map;return Y(r).forEach(([s,c])=>{let a=t.fromValue(s,e,n),f=t.fromValue(c,e,n);o.set(a,f)}),o}},ba=Cd;var kd={type:1037,canEncode:r=>r instanceof Set,encode:(r,t,e,n)=>W([...r.values()].map(o=>t.toValue(o,e,n))),decode:(r,t,e,n)=>{let o=new Set;return Y(r).forEach(s=>{o.add(t.fromValue(s,e,n))}),o}},wa=kd;var Td={type:1038,canEncode:r=>r instanceof Uint8Array,encode:r=>r,decode:r=>r},Ea=Td;var Ud={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}},va=Ud;var Ld={type:1040,canEncode:r=>r instanceof Date,encode:r=>W(r.toString()),decode:r=>new Date(Y(r))},Sa=Ld;var _d={type:1041,canEncode:r=>r instanceof RegExp,encode:r=>W({source:r.source,flags:r.flags}),decode:r=>{let{source:t,flags:e}=Y(r);return new RegExp(t,e)}},Aa=_d;var Ba=[ec,rc,aa,ua,fa,la,da,ha,pa,ma,ya,xa,ba,wa,Ea,va,Sa,Aa,zr];var Fn=class{transformersMap;transformersList;constructor(t){this.transformersList=[...Ba,...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 Nd(r){return r.isScope===!0}function Rd(r){return r.type===q.invokeMethod||r.type===q.invokeGeneratorMethod||r.type===q.invokeCallback}var di=class{source;output;targets;invocations;values;messageHandlers;constructor(t){this.output=he(),this.source=ln(this.output),this.targets=new Map,this.invocations=new Map,this.values=new Fn(t),this.sink=this.sink.bind(this),this.messageHandlers={[q.invokeMethod]:{decoder:_e,handler:this.handleInvokeMethod.bind(this)},[q.invokeGeneratorMethod]:{decoder:_e,handler:this.handleInvokeGeneratorMethod.bind(this)},[q.abortMethodInvocation]:{decoder:Nr,handler:this.handleAbortMethod.bind(this),isScope:!0},[q.methodResolved]:{decoder:Qe,handler:this.handleMethodResolved.bind(this),isScope:!0},[q.methodRejected]:{decoder:Rr,handler:this.handleMethodRejected.bind(this),isScope:!0,isError:!0},[q.invokeCallback]:{decoder:Je,handler:this.handleInvokeCallback.bind(this),isScope:!0},[q.abortCallbackInvocation]:{decoder:tr,handler:this.handleAbortCallback.bind(this),isScope:!0},[q.callbackResolved]:{decoder:Pr,handler:this.handleCallbackResolved.bind(this),isScope:!0},[q.callbackRejected]:{decoder:Dr,handler:this.handleCallbackRejected.bind(this),isScope:!0,isError:!0}}}async sink(t){for await(let e of Er(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(Nd(o))try{s=tc(i,this.invocations)}catch{continue}o.handler(i,s).catch(c=>{Rd(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(Bt.encode({type:q.callbackRejected,message:Dr.encode({scope:t.scope,parents:t.parents,error:this.values.toValue(e)})})):this.output.push(Bt.encode({type:q.methodRejected,message:Rr.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 yn(`Cannot reuse RPC target name "${t}"`);this.targets.set(t,e)}async handleInvokeMethod(t){if(this.invocations.has(t.scope))throw new Sr;let e=new Map,n=new Map,o={scope:t.scope,result:Vt(),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:q.methodResolved,message:Qe.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 Sr;let e=new Map,n=new Map,o={scope:t.scope,result:Vt(),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 f=await s.throw(a);return f.done===!0&&this.invocations.delete(t.scope),f}catch(f){throw this.invocations.delete(t.scope),f}},return:async a=>{let f=await s.return(a);return f.done===!0&&this.invocations.delete(t.scope),f},[Symbol.asyncIterator]:()=>c};this.output.push(Bt.encode({type:q.methodResolved,message:Qe.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 gn(`"${t.substring(0,t.length-5)}" was not a function`):new mn(`Could not find "${t}" on target`);if(typeof n!="function")throw new Ar("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 wn;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:q.callbackResolved,message:Pr.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 f(){return a==null&&(a=new Promise((l,h)=>{let w=Ge(),E={scope:w,result:Vt(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(w,E),n.output.push(Bt.encode({type:q.invokeMethod,message:_e.encode({scope:w,path:t,args:s.map(d=>n.values.toValue(d,null,E))})}));let m=sn(E.abortSignals);m.addEventListener("abort",()=>{n.output.push(Bt.encode({type:q.abortMethodInvocation,message:Nr.encode({scope:w})}))}),E.result.promise.then(d=>{l(d)},d=>{h(d)}).finally(()=>{n.invocations.delete(w),m.clear()})})),a}function u(){if(c==null){let l=Ge(),h={scope:l,result:Vt(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(l,h),n.output.push(Bt.encode({type:q.invokeGeneratorMethod,message:_e.encode({scope:l,path:t,args:s.map(E=>n.values.toValue(E,null,h))})}));let w;c={async next(){if(w!=null)throw w;let m=await(await h.result.promise).next();return m.done===!0&&n.invocations.delete(l),m},async throw(E){if(w!=null)throw w;try{let d=await(await h.result.promise).throw(E);return d.done===!0&&n.invocations.delete(l),d}catch(m){throw n.invocations.delete(l),w=E,m}},async return(E){if(w!=null)throw w;let d=await(await h.result.promise).return(E);return d.done===!0&&n.invocations.delete(l),d},[Symbol.asyncIterator]:()=>c}}return c}return new Proxy(e,{get(l,h,w){if(h==="then")return f().then.bind(a);if(h==="catch")return f().catch.bind(a);if(h==="finally")return f().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 Ar(`Property ${h.toString()} was not used as a promise or async generator`)}})}})}};function Ia(r){return new di(r)}var Ca={type:4096,canEncode:r=>r.code!=null&&r.version!=null&&r.multihash!=null&&r["/"]!=null,encode:r=>r.bytes,decode:r=>mt.decode(r)};var Hr=class extends Event{type;detail;constructor(t,e){super(t),this.type=t,this.detail=e}};var ka={type:4099,canEncode:r=>r instanceof Hr,encode:(r,t,e,n)=>W({type:r.type,detail:t.toValue(r.detail,e,n)}),decode:(r,t,e,n)=>{let{type:o,detail:i}=Y(r);return new Hr(o,t.fromValue(i,e,n))}};function dt(r,t="utf8"){let e=Sn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var $n=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",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let h=Number.parseInt(l,t);if(!Number.isNaN(h))return h});if(u===void 0)break;if(i*=t,i+=u,i>f||(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 Ta=45,Pd=15,cr=new $n;function hi(r){if(!(r.length>Pd))return cr.new(r).parseWith(()=>cr.readIPv4Addr())}function pi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ta))return cr.new(r).parseWith(()=>cr.readIPv6Addr())}function Vn(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ta))return cr.new(r).parseWith(()=>cr.readIPAddr())}var sb=parseInt("0xFFFF",16),cb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function _a(r){return!!hi(r)}function Na(r){return!!pi(r)}function zn(r){return!!Vn(r)}var Ra=_a,$d=Na,mi=function(r){let t=0;if(r=r.toString().trim(),Ra(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if($d(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=Ra(e[n]),s;i&&(s=mi(e[n]),e[n]=dt(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,dt(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")},Pa=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 ar={},gi={},zd=[[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"]];zd.forEach(r=>{let t=Hd(...r);gi[t.code]=t,ar[t.name]=t});function Hd(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function X(r){if(typeof r=="number"){if(gi[r]!=null)return gi[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(ar[r]!=null)return ar[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var qb=X("ip4"),Kb=X("ip6"),Gb=X("ipcidr");function wi(r,t){switch(X(r).code){case 4:case 41:return Kd(t);case 42:return bi(t);case 6:case 273:case 33:case 132:return Oa(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return bi(t);case 421:return Wd(t);case 444:return Ma(t);case 445:return Ma(t);case 466:return Zd(t);case 481:return globalThis.encodeURIComponent(bi(t));default:return dt(t,"base16")}}function Ei(r,t){switch(X(r).code){case 4:return Da(t);case 41:return Da(t);case 42:return xi(t);case 6:case 273:case 33:case 132:return vi(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return xi(t);case 421:return Gd(t);case 444:return Yd(t);case 445:return Xd(t);case 466:return jd(t);case 481:return xi(globalThis.decodeURIComponent(t));default:return ye(t,"base16")}}var yi=Object.values(Tr).map(r=>r.decoder),qd=function(){let r=yi[0].or(yi[1]);return yi.slice(2).forEach(t=>r=r.or(t)),r}();function Da(r){if(!zn(r))throw new Error("invalid ip address");return mi(r)}function Kd(r){let t=Pa(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!zn(t))throw new Error("invalid ip address");return t}function vi(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Oa(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function xi(r){let t=ye(r),e=Uint8Array.from(pe(t.length));return Lt([e,t],e.length+t.length)}function bi(r){let t=ee(r);if(r=r.slice(ft(t)),r.length!==t)throw new Error("inconsistent lengths");return dt(r)}function Gd(r){let t;r[0]==="Q"||r[0]==="1"?t=re(J.decode(`z${r}`)).bytes:t=mt.parse(r).multihash.bytes;let e=Uint8Array.from(pe(t.length));return Lt([e,t],e.length+t.length)}function jd(r){let t=qd.decode(r),e=Uint8Array.from(pe(t.length));return Lt([e,t],e.length+t.length)}function Zd(r){let t=ee(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+dt(e,"base64url")}function Wd(r){let t=ee(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return dt(e,"base58btc")}function Yd(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=$t.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=vi(n);return Lt([e,o],e.length+o.length)}function Xd(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=$t.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=vi(n);return Lt([e,o],e.length+o.length)}function Ma(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=dt(t,"base32"),o=Oa(e);return`${n}:${o}`}function Fa(r){r=Si(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=X(s);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(i++,i>=o.length)throw Va("invalid address: "+r);if(c.path===!0){n=Si(o.slice(i).join("/")),t.push([c.code,Ei(c.code,n)]),e.push([c.code,n]);break}let a=Ei(c.code,o[i]);t.push([c.code,a]),e.push([c.code,wi(c.code,a)])}return{string:$a(e),bytes:Bi(t),tuples:t,stringTuples:e,path:n}}function Ai(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=ee(r,o),s=ft(i),c=X(i),a=Qd(c,r.slice(o+s));if(a===0){t.push([i]),e.push([i]),o+=s;continue}let f=r.slice(o+s,o+s+a);if(o+=a+s,o>r.length)throw Va("Invalid address Uint8Array: "+dt(r,"base16"));t.push([i,f]);let u=wi(i,f);if(e.push([i,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:$a(e),tuples:t,stringTuples:e,path:n}}function $a(r){let t=[];return r.map(e=>{let n=X(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Si(t.join("/"))}function Bi(r){return Lt(r.map(t=>{let e=X(t[0]),n=Uint8Array.from(pe(e.code));return t.length>1&&t[1]!=null&&(n=Lt([n,t[1]])),n}))}function Qd(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=ee(t instanceof Uint8Array?t:Uint8Array.from(t));return e+ft(e)}}function Si(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Va(r){return new Error("Error parsing address: "+r)}var Jd=Symbol.for("nodejs.util.inspect.custom"),Ci=Symbol.for("@multiformats/js-multiaddr/multiaddr"),th=[X("dns").code,X("dns4").code,X("dns6").code,X("dnsaddr").code],Ii=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Hn=class r{bytes;#e;#t;#r;#n;[Ci]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Ai(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Fa(t)}else if(qn(t))e=Ai(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=X("tcp"),c=X("udp"),a=X("ip4"),f=X("ip6"),u=X("dns6"),l=X("ip6zone");for(let[w,E]of this.stringTuples())w===l.code&&(i=`%${E??""}`),th.includes(w)&&(e=s.name,o=443,n=`${E??""}${i}`,t=w===u.code?6:4),(w===s.code||w===c.code)&&(e=X(w).name,o=parseInt(E??"")),(w===a.code||w===f.code)&&(e=X(w).name,n=`${E??""}${i}`,t=w===f.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({},X(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>X(t).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Bi(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===ar.p2p.code&&t.push([n,o]),n===ar["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?dt(J.decode(`z${n}`),"base58btc"):dt(mt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Ht(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=za.get(e.name);if(n==null)throw new Ii(`no available resolver for ${e.name}`);return(await n(this,t)).map(i=>Re(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)}[Jd](){return`Multiaddr(${this.#e})`}};var za=new Map;function qn(r){return!!r?.[Ci]}function Re(r){return new Hn(r)}var Ha={type:4097,canEncode:r=>qn(r),encode:r=>r.bytes,decode:r=>Re(r)};function qa(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function eh(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function ur(r,...t){if(!eh(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function Ka(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");qa(r.outputLen),qa(r.blockLen)}function fr(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 Ga(r,t){ur(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Pe=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Kn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),jt=(r,t)=>r<<32-t|r>>>t;var vw=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ja(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function qr(r){return typeof r=="string"&&(r=ja(r)),ur(r),r}function ki(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];ur(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 lr=class{clone(){return this._cloneInto()}},Sw={}.toString;function Gn(r){let t=n=>r().update(qr(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function jn(r=32){if(Pe&&typeof Pe.getRandomValues=="function")return Pe.getRandomValues(new Uint8Array(r));if(Pe&&typeof Pe.randomBytes=="function")return Pe.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function rh(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,f=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+f,c,n)}var Za=(r,t,e)=>r&t^~r&e,Wa=(r,t,e)=>r&t^r&e^t&e,dr=class extends lr{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=Kn(this.buffer)}update(t){fr(this);let{view:e,buffer:n,blockLen:o}=this;t=qr(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=Kn(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){fr(this),Ga(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 l=s;l<o;l++)e[l]=0;rh(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=Kn(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)c.setUint32(4*l,u[l],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 Zn=BigInt(4294967295),Ti=BigInt(32);function Ya(r,t=!1){return t?{h:Number(r&Zn),l:Number(r>>Ti&Zn)}:{h:Number(r>>Ti&Zn)|0,l:Number(r&Zn)|0}}function nh(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}=Ya(r[o],t);[e[o],n[o]]=[i,s]}return[e,n]}var oh=(r,t)=>BigInt(r>>>0)<<Ti|BigInt(t>>>0),ih=(r,t,e)=>r>>>e,sh=(r,t,e)=>r<<32-e|t>>>e,ch=(r,t,e)=>r>>>e|t<<32-e,ah=(r,t,e)=>r<<32-e|t>>>e,uh=(r,t,e)=>r<<64-e|t>>>e-32,fh=(r,t,e)=>r>>>e-32|t<<64-e,lh=(r,t)=>t,dh=(r,t)=>r,hh=(r,t,e)=>r<<e|t>>>32-e,ph=(r,t,e)=>t<<e|r>>>32-e,mh=(r,t,e)=>t<<e-32|r>>>64-e,gh=(r,t,e)=>r<<e-32|t>>>64-e;function yh(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var xh=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),bh=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,wh=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Eh=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,vh=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Sh=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var Ah={fromBig:Ya,split:nh,toBig:oh,shrSH:ih,shrSL:sh,rotrSH:ch,rotrSL:ah,rotrBH:uh,rotrBL:fh,rotr32H:lh,rotr32L:dh,rotlSH:hh,rotlSL:ph,rotlBH:mh,rotlBL:gh,add:yh,add3L:xh,add3H:bh,add4L:wh,add4H:Eh,add5H:Sh,add5L:vh},O=Ah;var[Bh,Ih]=O.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),we=new Uint32Array(80),Ee=new Uint32Array(80),Ui=class extends dr{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:f,El:u,Fh:l,Fl:h,Gh:w,Gl:E,Hh:m,Hl:d}=this;return[t,e,n,o,i,s,c,a,f,u,l,h,w,E,m,d]}set(t,e,n,o,i,s,c,a,f,u,l,h,w,E,m,d){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=h|0,this.Gh=w|0,this.Gl=E|0,this.Hh=m|0,this.Hl=d|0}process(t,e){for(let y=0;y<16;y++,e+=4)we[y]=t.getUint32(e),Ee[y]=t.getUint32(e+=4);for(let y=16;y<80;y++){let B=we[y-15]|0,R=Ee[y-15]|0,L=O.rotrSH(B,R,1)^O.rotrSH(B,R,8)^O.shrSH(B,R,7),T=O.rotrSL(B,R,1)^O.rotrSL(B,R,8)^O.shrSL(B,R,7),k=we[y-2]|0,_=Ee[y-2]|0,ot=O.rotrSH(k,_,19)^O.rotrBH(k,_,61)^O.shrSH(k,_,6),H=O.rotrSL(k,_,19)^O.rotrBL(k,_,61)^O.shrSL(k,_,6),F=O.add4L(T,H,Ee[y-7],Ee[y-16]),it=O.add4H(F,L,ot,we[y-7],we[y-16]);we[y]=it|0,Ee[y]=F|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:h,Fh:w,Fl:E,Gh:m,Gl:d,Hh:x,Hl:A}=this;for(let y=0;y<80;y++){let B=O.rotrSH(l,h,14)^O.rotrSH(l,h,18)^O.rotrBH(l,h,41),R=O.rotrSL(l,h,14)^O.rotrSL(l,h,18)^O.rotrBL(l,h,41),L=l&w^~l&m,T=h&E^~h&d,k=O.add5L(A,R,T,Ih[y],Ee[y]),_=O.add5H(k,x,B,L,Bh[y],we[y]),ot=k|0,H=O.rotrSH(n,o,28)^O.rotrBH(n,o,34)^O.rotrBH(n,o,39),F=O.rotrSL(n,o,28)^O.rotrBL(n,o,34)^O.rotrBL(n,o,39),it=n&i^n&c^i&c,I=o&s^o&a^s&a;x=m|0,A=d|0,m=w|0,d=E|0,w=l|0,E=h|0,{h:l,l:h}=O.add(f|0,u|0,_|0,ot|0),f=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let U=O.add3L(ot,F,I);n=O.add3H(U,_,H,it),o=U|0}({h:n,l:o}=O.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=O.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=O.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=O.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:h}=O.add(this.Eh|0,this.El|0,l|0,h|0),{h:w,l:E}=O.add(this.Fh|0,this.Fl|0,w|0,E|0),{h:m,l:d}=O.add(this.Gh|0,this.Gl|0,m|0,d|0),{h:x,l:A}=O.add(this.Hh|0,this.Hl|0,x|0,A|0),this.set(n,o,i,s,c,a,f,u,l,h,w,E,m,d,x,A)}roundClean(){we.fill(0),Ee.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 Xa=Gn(()=>new Ui);var Yn={};Ct(Yn,{aInRange:()=>Tt,abool:()=>Zt,abytes:()=>hr,bitGet:()=>_h,bitLen:()=>Pi,bitMask:()=>Gr,bitSet:()=>Nh,bytesToHex:()=>ce,bytesToNumberBE:()=>ae,bytesToNumberLE:()=>Se,concatBytes:()=>ue,createHmacDrbg:()=>Di,ensureBytes:()=>nt,equalBytes:()=>Uh,hexToBytes:()=>Me,hexToNumber:()=>Ri,inRange:()=>Kr,isBytes:()=>ve,memoized:()=>Fe,notImplemented:()=>Ph,numberToBytesBE:()=>Ae,numberToBytesLE:()=>Oe,numberToHexUnpadded:()=>De,numberToVarBytesBE:()=>Th,utf8ToBytes:()=>Lh,validateObject:()=>Qt});var Ni=BigInt(0),Wn=BigInt(1),Ch=BigInt(2);function ve(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function hr(r){if(!ve(r))throw new Error("Uint8Array expected")}function Zt(r,t){if(typeof t!="boolean")throw new Error(`${r} must be valid boolean, got "${t}".`)}var kh=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function ce(r){hr(r);let t="";for(let e=0;e<r.length;e++)t+=kh[r[e]];return t}function De(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function Ri(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var se={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Qa(r){if(r>=se._0&&r<=se._9)return r-se._0;if(r>=se._A&&r<=se._F)return r-(se._A-10);if(r>=se._a&&r<=se._f)return r-(se._a-10)}function Me(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,i=0;o<e;o++,i+=2){let s=Qa(r.charCodeAt(i)),c=Qa(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 ae(r){return Ri(ce(r))}function Se(r){return hr(r),Ri(ce(Uint8Array.from(r).reverse()))}function Ae(r,t){return Me(r.toString(16).padStart(t*2,"0"))}function Oe(r,t){return Ae(r,t).reverse()}function Th(r){return Me(De(r))}function nt(r,t,e){let n;if(typeof t=="string")try{n=Me(t)}catch(i){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${i}`)}else if(ve(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(`${r} expected ${e} bytes, got ${o}`);return n}function ue(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];hr(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 Uh(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 Lh(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Li=r=>typeof r=="bigint"&&Ni<=r;function Kr(r,t,e){return Li(r)&&Li(t)&&Li(e)&&t<=r&&r<e}function Tt(r,t,e,n){if(!Kr(t,e,n))throw new Error(`expected valid ${r}: ${e} <= n < ${n}, got ${typeof t} ${t}`)}function Pi(r){let t;for(t=0;r>Ni;r>>=Wn,t+=1);return t}function _h(r,t){return r>>BigInt(t)&Wn}function Nh(r,t,e){return r|(e?Wn:Ni)<<BigInt(t)}var Gr=r=>(Ch<<BigInt(r-1))-Wn,_i=r=>new Uint8Array(r),Ja=r=>Uint8Array.from(r);function Di(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=_i(r),o=_i(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},c=(...l)=>e(o,n,...l),a=(l=_i())=>{o=c(Ja([0]),l),n=c(),l.length!==0&&(o=c(Ja([1]),l),n=c())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,h=[];for(;l<t;){n=c();let w=n.slice();h.push(w),l+=n.length}return ue(...h)};return(l,h)=>{s(),a(l);let w;for(;!(w=h(f()));)a();return s(),w}}var Rh={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"||ve(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 Qt(r,t,e={}){let n=(o,i,s)=>{let c=Rh[i];if(typeof c!="function")throw new Error(`Invalid validator "${i}", expected function`);let a=r[o];if(!(s&&a===void 0)&&!c(a,r))throw new Error(`Invalid param ${String(o)}=${a} (${typeof a}), expected ${i}`)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}var Ph=()=>{throw new Error("not implemented")};function Fe(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 ct=BigInt(0),tt=BigInt(1),$e=BigInt(2),Dh=BigInt(3),Mi=BigInt(4),tu=BigInt(5),eu=BigInt(8),Mh=BigInt(9),Oh=BigInt(16);function Z(r,t){let e=r%t;return e>=ct?e:t+e}function Fh(r,t,e){if(e<=ct||t<ct)throw new Error("Expected power/modulo > 0");if(e===tt)return ct;let n=tt;for(;t>ct;)t&tt&&(n=n*r%e),r=r*r%e,t>>=tt;return n}function et(r,t,e){let n=r;for(;t-- >ct;)n*=n,n%=e;return n}function Xn(r,t){if(r===ct||t<=ct)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=Z(r,t),n=t,o=ct,i=tt,s=tt,c=ct;for(;e!==ct;){let f=n/e,u=n%e,l=o-s*f,h=i-c*f;n=e,e=u,o=s,i=c,s=l,c=h}if(n!==tt)throw new Error("invert: does not exist");return Z(o,t)}function $h(r){let t=(r-tt)/$e,e,n,o;for(e=r-tt,n=0;e%$e===ct;e/=$e,n++);for(o=$e;o<r&&Fh(o,t,r)!==r-tt;o++);if(n===1){let s=(r+tt)/Mi;return function(a,f){let u=a.pow(f,s);if(!a.eql(a.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(e+tt)/$e;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=n,u=c.pow(c.mul(c.ONE,o),e),l=c.pow(a,i),h=c.pow(a,e);for(;!c.eql(h,c.ONE);){if(c.eql(h,c.ZERO))return c.ZERO;let w=1;for(let m=c.sqr(h);w<f&&!c.eql(m,c.ONE);w++)m=c.sqr(m);let E=c.pow(u,tt<<BigInt(f-w-1));u=c.sqr(E),l=c.mul(l,E),h=c.mul(h,u),f=w}return l}}function Vh(r){if(r%Mi===Dh){let t=(r+tt)/Mi;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%eu===tu){let t=(r-tu)/eu;return function(n,o){let i=n.mul(o,$e),s=n.pow(i,t),c=n.mul(o,s),a=n.mul(n.mul(c,$e),s),f=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%Oh,$h(r)}var ru=(r,t)=>(Z(r,t)&tt)===tt,zh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Oi(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=zh.reduce((n,o)=>(n[o]="function",n),t);return Qt(r,e)}function Hh(r,t,e){if(e<ct)throw new Error("Expected power > 0");if(e===ct)return r.ONE;if(e===tt)return t;let n=r.ONE,o=t;for(;e>ct;)e&tt&&(n=r.mul(n,o)),o=r.sqr(o),e>>=tt;return n}function qh(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 Fi(r,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<=ct)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Fi(r,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Vh(r),c=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:Gr(o),ZERO:ct,ONE:tt,create:a=>Z(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return ct<=a&&a<r},is0:a=>a===ct,isOdd:a=>(a&tt)===tt,neg:a=>Z(-a,r),eql:(a,f)=>a===f,sqr:a=>Z(a*a,r),add:(a,f)=>Z(a+f,r),sub:(a,f)=>Z(a-f,r),mul:(a,f)=>Z(a*f,r),pow:(a,f)=>Hh(c,a,f),div:(a,f)=>Z(a*Xn(f,r),r),sqrN:a=>a*a,addN:(a,f)=>a+f,subN:(a,f)=>a-f,mulN:(a,f)=>a*f,inv:a=>Xn(a,r),sqrt:n.sqrt||(a=>s(c,a)),invertBatch:a=>qh(c,a),cmov:(a,f,u)=>u?f:a,toBytes:a=>e?Oe(a,i):Ae(a,i),fromBytes:a=>{if(a.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${a.length}`);return e?Se(a):ae(a)}});return Object.freeze(c)}function nu(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 $i(r){let t=nu(r);return t+Math.ceil(t/2)}function ou(r,t,e=!1){let n=r.length,o=nu(t),i=$i(t);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=e?ae(r):Se(r),c=Z(s,t-tt)+tt;return e?Oe(c,o):Ae(c,o)}var Gh=BigInt(0),Vi=BigInt(1),zi=new WeakMap,iu=new WeakMap;function Qn(r,t){let e=(i,s)=>{let c=s.negate();return i?c:s},n=i=>{if(!Number.isSafeInteger(i)||i<=0||i>t)throw new Error(`Wrong window size=${i}, should be [1..${t}]`)},o=i=>{n(i);let s=Math.ceil(t/i)+1,c=2**(i-1);return{windows:s,windowSize:c}};return{constTimeNegate:e,unsafeLadder(i,s){let c=r.ZERO,a=i;for(;s>Gh;)s&Vi&&(c=c.add(a)),a=a.double(),s>>=Vi;return c},precomputeWindow(i,s){let{windows:c,windowSize:a}=o(s),f=[],u=i,l=u;for(let h=0;h<c;h++){l=u,f.push(l);for(let w=1;w<a;w++)l=l.add(u),f.push(l);u=l.double()}return f},wNAF(i,s,c){let{windows:a,windowSize:f}=o(i),u=r.ZERO,l=r.BASE,h=BigInt(2**i-1),w=2**i,E=BigInt(i);for(let m=0;m<a;m++){let d=m*f,x=Number(c&h);c>>=E,x>f&&(x-=w,c+=Vi);let A=d,y=d+Math.abs(x)-1,B=m%2!==0,R=x<0;x===0?l=l.add(e(B,s[A])):u=u.add(e(R,s[y]))}return{p:u,f:l}},wNAFCached(i,s,c){let a=iu.get(i)||1,f=zi.get(i);return f||(f=this.precomputeWindow(i,a),a!==1&&zi.set(i,c(f))),this.wNAF(a,f,s)},setWindowSize(i,s){n(s),iu.set(i,s),zi.delete(i)}}}function Jn(r,t,e,n){if(!Array.isArray(e)||!Array.isArray(n)||n.length!==e.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,l)=>{if(!t.isValid(u))throw new Error(`wrong scalar at index ${l}`)}),e.forEach((u,l)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${l}`)});let o=Pi(BigInt(e.length)),i=o>12?o-3:o>4?o-2:o?2:1,s=(1<<i)-1,c=new Array(s+1).fill(r.ZERO),a=Math.floor((t.BITS-1)/i)*i,f=r.ZERO;for(let u=a;u>=0;u-=i){c.fill(r.ZERO);for(let h=0;h<n.length;h++){let w=n[h],E=Number(w>>BigInt(u)&BigInt(s));c[E]=c[E].add(e[h])}let l=r.ZERO;for(let h=c.length-1,w=r.ZERO;h>0;h--)w=w.add(c[h]),l=l.add(w);if(f=f.add(l),u!==0)for(let h=0;h<i;h++)f=f.double()}return f}function jr(r){return Oi(r.Fp),Qt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Fi(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Wt=BigInt(0),Ut=BigInt(1),to=BigInt(2),jh=BigInt(8),Zh={zip215:!0};function Wh(r){let t=jr(r);return Qt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function su(r){let t=Wh(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,f=to<<BigInt(c*8)-Ut,u=e.create,l=Be(t.n,t.nBitLength),h=t.uvRatio||((b,g)=>{try{return{isValid:!0,value:e.sqrt(b*e.inv(g))}}catch{return{isValid:!1,value:Wt}}}),w=t.adjustScalarBytes||(b=>b),E=t.domain||((b,g,v)=>{if(Zt("phflag",v),g.length||v)throw new Error("Contexts/pre-hash are not supported");return b});function m(b,g){Tt("coordinate "+b,g,Wt,f)}function d(b){if(!(b instanceof y))throw new Error("ExtendedPoint expected")}let x=Fe((b,g)=>{let{ex:v,ey:N,ez:P}=b,D=b.is0();g==null&&(g=D?jh:e.inv(P));let $=u(v*g),z=u(N*g),V=u(P*g);if(D)return{x:Wt,y:Ut};if(V!==Ut)throw new Error("invZ was invalid");return{x:$,y:z}}),A=Fe(b=>{let{a:g,d:v}=t;if(b.is0())throw new Error("bad point: ZERO");let{ex:N,ey:P,ez:D,et:$}=b,z=u(N*N),V=u(P*P),j=u(D*D),Q=u(j*j),at=u(z*g),ut=u(j*u(at+V)),pt=u(Q+u(v*u(z*V)));if(ut!==pt)throw new Error("bad point: equation left != right (1)");let wt=u(N*P),st=u(D*$);if(wt!==st)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(g,v,N,P){this.ex=g,this.ey=v,this.ez=N,this.et=P,m("x",g),m("y",v),m("z",N),m("t",P),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(g){if(g instanceof y)throw new Error("extended point not allowed");let{x:v,y:N}=g||{};return m("x",v),m("y",N),new y(v,N,Ut,u(v*N))}static normalizeZ(g){let v=e.invertBatch(g.map(N=>N.ez));return g.map((N,P)=>N.toAffine(v[P])).map(y.fromAffine)}static msm(g,v){return Jn(y,l,g,v)}_setWindowSize(g){L.setWindowSize(this,g)}assertValidity(){A(this)}equals(g){d(g);let{ex:v,ey:N,ez:P}=this,{ex:D,ey:$,ez:z}=g,V=u(v*z),j=u(D*P),Q=u(N*z),at=u($*P);return V===j&&Q===at}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:g}=t,{ex:v,ey:N,ez:P}=this,D=u(v*v),$=u(N*N),z=u(to*u(P*P)),V=u(g*D),j=v+N,Q=u(u(j*j)-D-$),at=V+$,ut=at-z,pt=V-$,wt=u(Q*ut),st=u(at*pt),It=u(Q*pt),Jt=u(ut*at);return new y(wt,st,Jt,It)}add(g){d(g);let{a:v,d:N}=t,{ex:P,ey:D,ez:$,et:z}=this,{ex:V,ey:j,ez:Q,et:at}=g;if(v===BigInt(-1)){let es=u((D-P)*(j+V)),rs=u((D+P)*(j-V)),ho=u(rs-es);if(ho===Wt)return this.double();let ns=u($*to*at),os=u(z*to*Q),is=os+ns,ss=rs+es,cs=os-ns,Ou=u(is*ho),Fu=u(ss*cs),$u=u(is*cs),Vu=u(ho*ss);return new y(Ou,Fu,Vu,$u)}let ut=u(P*V),pt=u(D*j),wt=u(z*N*at),st=u($*Q),It=u((P+D)*(V+j)-ut-pt),Jt=st-wt,mr=st+wt,gr=u(pt-v*ut),Ru=u(It*Jt),Pu=u(mr*gr),Du=u(It*gr),Mu=u(Jt*mr);return new y(Ru,Pu,Mu,Du)}subtract(g){return this.add(g.negate())}wNAF(g){return L.wNAFCached(this,g,y.normalizeZ)}multiply(g){let v=g;Tt("scalar",v,Ut,n);let{p:N,f:P}=this.wNAF(v);return y.normalizeZ([N,P])[0]}multiplyUnsafe(g){let v=g;return Tt("scalar",v,Wt,n),v===Wt?R:this.equals(R)||v===Ut?this:this.equals(B)?this.wNAF(v).p:L.unsafeLadder(this,v)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return L.unsafeLadder(this,n).is0()}toAffine(g){return x(this,g)}clearCofactor(){let{h:g}=t;return g===Ut?this:this.multiplyUnsafe(g)}static fromHex(g,v=!1){let{d:N,a:P}=t,D=e.BYTES;g=nt("pointHex",g,D),Zt("zip215",v);let $=g.slice(),z=g[D-1];$[D-1]=z&-129;let V=Se($),j=v?f:e.ORDER;Tt("pointHex.y",V,Wt,j);let Q=u(V*V),at=u(Q-Ut),ut=u(N*Q-P),{isValid:pt,value:wt}=h(at,ut);if(!pt)throw new Error("Point.fromHex: invalid y coordinate");let st=(wt&Ut)===Ut,It=(z&128)!==0;if(!v&&wt===Wt&&It)throw new Error("Point.fromHex: x=0 and x_0=1");return It!==st&&(wt=u(-wt)),y.fromAffine({x:wt,y:V})}static fromPrivateKey(g){return _(g).point}toRawBytes(){let{x:g,y:v}=this.toAffine(),N=Oe(v,e.BYTES);return N[N.length-1]|=g&Ut?128:0,N}toHex(){return ce(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,Ut,u(t.Gx*t.Gy)),y.ZERO=new y(Wt,Ut,Ut,Wt);let{BASE:B,ZERO:R}=y,L=Qn(y,c*8);function T(b){return Z(b,n)}function k(b){return T(Se(b))}function _(b){let g=c;b=nt("private key",b,g);let v=nt("hashed private key",i(b),2*g),N=w(v.slice(0,g)),P=v.slice(g,2*g),D=k(N),$=B.multiply(D),z=$.toRawBytes();return{head:N,prefix:P,scalar:D,point:$,pointBytes:z}}function ot(b){return _(b).pointBytes}function H(b=new Uint8Array,...g){let v=ue(...g);return k(i(E(v,nt("context",b),!!o)))}function F(b,g,v={}){b=nt("message",b),o&&(b=o(b));let{prefix:N,scalar:P,pointBytes:D}=_(g),$=H(v.context,N,b),z=B.multiply($).toRawBytes(),V=H(v.context,z,D,b),j=T($+V*P);Tt("signature.s",j,Wt,n);let Q=ue(z,Oe(j,e.BYTES));return nt("result",Q,c*2)}let it=Zh;function I(b,g,v,N=it){let{context:P,zip215:D}=N,$=e.BYTES;b=nt("signature",b,2*$),g=nt("message",g),D!==void 0&&Zt("zip215",D),o&&(g=o(g));let z=Se(b.slice($,2*$)),V,j,Q;try{V=y.fromHex(v,D),j=y.fromHex(b.slice(0,$),D),Q=B.multiplyUnsafe(z)}catch{return!1}if(!D&&V.isSmallOrder())return!1;let at=H(P,j.toRawBytes(),V.toRawBytes(),g);return j.add(V.multiplyUnsafe(at)).subtract(Q).clearCofactor().equals(y.ZERO)}return B._setWindowSize(8),{CURVE:t,getPublicKey:ot,sign:F,verify:I,ExtendedPoint:y,utils:{getExtendedPublicKey:_,randomPrivateKey:()=>s(e.BYTES),precompute(b=8,g=y.BASE){return g._setWindowSize(b),g.multiply(BigInt(3)),g}}}}var Hi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),cu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Gw=BigInt(0),Yh=BigInt(1),au=BigInt(2),jw=BigInt(3),Xh=BigInt(5),Qh=BigInt(8);function Jh(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=Hi,c=r*r%i*r%i,a=et(c,au,i)*c%i,f=et(a,Yh,i)*r%i,u=et(f,Xh,i)*f%i,l=et(u,t,i)*u%i,h=et(l,e,i)*l%i,w=et(h,n,i)*h%i,E=et(w,o,i)*w%i,m=et(E,o,i)*w%i,d=et(m,t,i)*u%i;return{pow_p_5_8:et(d,au,i)*r%i,b2:c}}function tp(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function ep(r,t){let e=Hi,n=Z(t*t*t,e),o=Z(n*n*t,e),i=Jh(r*o).pow_p_5_8,s=Z(r*n*i,e),c=Z(t*s*s,e),a=s,f=Z(s*cu,e),u=c===r,l=c===Z(-r,e),h=c===Z(-r*cu,e);return u&&(s=a),(l||h)&&(s=f),ru(s,e)&&(s=Z(-s,e)),{isValid:u||l,value:s}}var rp=Be(Hi,void 0,!0),np={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:rp,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Qh,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Xa,randomBytes:jn,adjustScalarBytes:tp,uvRatio:ep},uu=su(np);var eo=32;function fu(r,t,e){return uu.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var ro=class{type="Ed25519";raw;constructor(t){this.raw=qi(t,eo)}toMultihash(){return ne.digest(no(this))}toCID(){return mt.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Ht(this.raw,t.raw)}verify(t,e){return fu(this.raw,e,t)}};function du(r){return r=qi(r,eo),new ro(r)}function qi(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new ze(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Ft;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(Ft||(Ft={}));var Ki;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Ki||(Ki={}));(function(r){r.codec=()=>_r(Ki)})(Ft||(Ft={}));var Zr;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Ft.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=Ft.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Zr||(Zr={}));var Gi;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Ft.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=Ft.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Gi||(Gi={}));var sp=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]),Ie=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ce=new Uint32Array(64),ji=class extends dr{constructor(){super(64,32,8,!1),this.A=Ie[0]|0,this.B=Ie[1]|0,this.C=Ie[2]|0,this.D=Ie[3]|0,this.E=Ie[4]|0,this.F=Ie[5]|0,this.G=Ie[6]|0,this.H=Ie[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 l=0;l<16;l++,e+=4)Ce[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let h=Ce[l-15],w=Ce[l-2],E=jt(h,7)^jt(h,18)^h>>>3,m=jt(w,17)^jt(w,19)^w>>>10;Ce[l]=m+Ce[l-7]+E+Ce[l-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:f,H:u}=this;for(let l=0;l<64;l++){let h=jt(c,6)^jt(c,11)^jt(c,25),w=u+h+Za(c,a,f)+sp[l]+Ce[l]|0,m=(jt(n,2)^jt(n,13)^jt(n,22))+Wa(n,o,i)|0;u=f,f=a,a=c,c=s+w|0,s=i,i=o,o=n,n=w+m|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,f,u)}roundClean(){Ce.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var hu=Gn(()=>new ji);var Wr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var oo=class extends lr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Ka(t);let n=qr(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 fr(this),this.iHash.update(t),this}digestInto(t){fr(this),ur(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()}},Zi=(r,t,e)=>new oo(r,t).update(e).digest();Zi.create=(r,t)=>new oo(r,t);function pu(r){r.lowS!==void 0&&Zt("lowS",r.lowS),r.prehash!==void 0&&Zt("prehash",r.prehash)}function cp(r){let t=jr(r);Qt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:ap,hexToBytes:up}=Yn,fe={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(r,t)=>{let{Err:e}=fe;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=De(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?De(o.length/2|128):"";return`${De(r)}${i}${o}${t}`},decode(r,t){let{Err:e}=fe,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 f=t.subarray(n,n+a);if(f.length!==a)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)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}=fe;if(r<le)throw new t("integer: negative integers are not allowed");let e=De(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected assertion");return e},decode(r){let{Err:t}=fe;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 ap(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=fe,o=typeof r=="string"?up(r):r;hr(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:f,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(f)}},hexFromSig(r){let{_tlv:t,_int:e}=fe,n=`${t.encode(2,e.encode(r.r))}${t.encode(2,e.encode(r.s))}`;return t.encode(48,n)}},le=BigInt(0),ht=BigInt(1),v1=BigInt(2),mu=BigInt(3),S1=BigInt(4);function fp(r){let t=cp(r),{Fp:e}=t,n=Be(t.n,t.nBitLength),o=t.toBytes||((m,d,x)=>{let A=d.toAffine();return ue(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),i=t.fromBytes||(m=>{let d=m.subarray(1),x=e.fromBytes(d.subarray(0,e.BYTES)),A=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x,y:A}});function s(m){let{a:d,b:x}=t,A=e.sqr(m),y=e.mul(A,m);return e.add(e.add(y,e.mul(m,d)),x)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function c(m){return Kr(m,ht,t.n)}function a(m){let{allowedPrivateKeyLengths:d,nByteLength:x,wrapPrivateKey:A,n:y}=t;if(d&&typeof m!="bigint"){if(ve(m)&&(m=ce(m)),typeof m!="string"||!d.includes(m.length))throw new Error("Invalid key");m=m.padStart(x*2,"0")}let B;try{B=typeof m=="bigint"?m:ae(nt("private key",m,x))}catch{throw new Error(`private key must be ${x} bytes, hex or bigint, not ${typeof m}`)}return A&&(B=Z(B,y)),Tt("private key",B,ht,y),B}function f(m){if(!(m instanceof h))throw new Error("ProjectivePoint expected")}let u=Fe((m,d)=>{let{px:x,py:A,pz:y}=m;if(e.eql(y,e.ONE))return{x,y:A};let B=m.is0();d==null&&(d=B?e.ONE:e.inv(y));let R=e.mul(x,d),L=e.mul(A,d),T=e.mul(y,d);if(B)return{x:e.ZERO,y:e.ZERO};if(!e.eql(T,e.ONE))throw new Error("invZ was invalid");return{x:R,y:L}}),l=Fe(m=>{if(m.is0()){if(t.allowInfinityPoint&&!e.is0(m.py))return;throw new Error("bad point: ZERO")}let{x:d,y:x}=m.toAffine();if(!e.isValid(d)||!e.isValid(x))throw new Error("bad point: x or y not FE");let A=e.sqr(x),y=s(d);if(!e.eql(A,y))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,x,A){if(this.px=d,this.py=x,this.pz=A,d==null||!e.isValid(d))throw new Error("x required");if(x==null||!e.isValid(x))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x,y:A}=d||{};if(!d||!e.isValid(x)||!e.isValid(A))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let y=B=>e.eql(B,e.ZERO);return y(x)&&y(A)?h.ZERO:new h(x,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let x=e.invertBatch(d.map(A=>A.pz));return d.map((A,y)=>A.toAffine(x[y])).map(h.fromAffine)}static fromHex(d){let x=h.fromAffine(i(nt("pointHex",d)));return x.assertValidity(),x}static fromPrivateKey(d){return h.BASE.multiply(a(d))}static msm(d,x){return Jn(h,n,d,x)}_setWindowSize(d){E.setWindowSize(this,d)}assertValidity(){l(this)}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:x,py:A,pz:y}=this,{px:B,py:R,pz:L}=d,T=e.eql(e.mul(x,L),e.mul(B,y)),k=e.eql(e.mul(A,L),e.mul(R,y));return T&&k}negate(){return new h(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:x}=t,A=e.mul(x,mu),{px:y,py:B,pz:R}=this,L=e.ZERO,T=e.ZERO,k=e.ZERO,_=e.mul(y,y),ot=e.mul(B,B),H=e.mul(R,R),F=e.mul(y,B);return F=e.add(F,F),k=e.mul(y,R),k=e.add(k,k),L=e.mul(d,k),T=e.mul(A,H),T=e.add(L,T),L=e.sub(ot,T),T=e.add(ot,T),T=e.mul(L,T),L=e.mul(F,L),k=e.mul(A,k),H=e.mul(d,H),F=e.sub(_,H),F=e.mul(d,F),F=e.add(F,k),k=e.add(_,_),_=e.add(k,_),_=e.add(_,H),_=e.mul(_,F),T=e.add(T,_),H=e.mul(B,R),H=e.add(H,H),_=e.mul(H,F),L=e.sub(L,_),k=e.mul(H,ot),k=e.add(k,k),k=e.add(k,k),new h(L,T,k)}add(d){f(d);let{px:x,py:A,pz:y}=this,{px:B,py:R,pz:L}=d,T=e.ZERO,k=e.ZERO,_=e.ZERO,ot=t.a,H=e.mul(t.b,mu),F=e.mul(x,B),it=e.mul(A,R),I=e.mul(y,L),U=e.add(x,A),b=e.add(B,R);U=e.mul(U,b),b=e.add(F,it),U=e.sub(U,b),b=e.add(x,y);let g=e.add(B,L);return b=e.mul(b,g),g=e.add(F,I),b=e.sub(b,g),g=e.add(A,y),T=e.add(R,L),g=e.mul(g,T),T=e.add(it,I),g=e.sub(g,T),_=e.mul(ot,b),T=e.mul(H,I),_=e.add(T,_),T=e.sub(it,_),_=e.add(it,_),k=e.mul(T,_),it=e.add(F,F),it=e.add(it,F),I=e.mul(ot,I),b=e.mul(H,b),it=e.add(it,I),I=e.sub(F,I),I=e.mul(ot,I),b=e.add(b,I),F=e.mul(it,b),k=e.add(k,F),F=e.mul(g,b),T=e.mul(U,T),T=e.sub(T,F),F=e.mul(U,it),_=e.mul(g,_),_=e.add(_,F),new h(T,k,_)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return E.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){Tt("scalar",d,le,t.n);let x=h.ZERO;if(d===le)return x;if(d===ht)return this;let{endo:A}=t;if(!A)return E.unsafeLadder(this,d);let{k1neg:y,k1:B,k2neg:R,k2:L}=A.splitScalar(d),T=x,k=x,_=this;for(;B>le||L>le;)B&ht&&(T=T.add(_)),L&ht&&(k=k.add(_)),_=_.double(),B>>=ht,L>>=ht;return y&&(T=T.negate()),R&&(k=k.negate()),k=new h(e.mul(k.px,A.beta),k.py,k.pz),T.add(k)}multiply(d){let{endo:x,n:A}=t;Tt("scalar",d,ht,A);let y,B;if(x){let{k1neg:R,k1:L,k2neg:T,k2:k}=x.splitScalar(d),{p:_,f:ot}=this.wNAF(L),{p:H,f:F}=this.wNAF(k);_=E.constTimeNegate(R,_),H=E.constTimeNegate(T,H),H=new h(e.mul(H.px,x.beta),H.py,H.pz),y=_.add(H),B=ot.add(F)}else{let{p:R,f:L}=this.wNAF(d);y=R,B=L}return h.normalizeZ([y,B])[0]}multiplyAndAddUnsafe(d,x,A){let y=h.BASE,B=(L,T)=>T===le||T===ht||!L.equals(y)?L.multiplyUnsafe(T):L.multiply(T),R=B(this,x).add(B(d,A));return R.is0()?void 0:R}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:x}=t;if(d===ht)return!0;if(x)return x(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:x}=t;return d===ht?this:x?x(h,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return Zt("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return Zt("isCompressed",d),ce(this.toRawBytes(d))}}h.BASE=new h(t.Gx,t.Gy,e.ONE),h.ZERO=new h(e.ZERO,e.ONE,e.ZERO);let w=t.nBitLength,E=Qn(h,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:c}}function lp(r){let t=jr(r);return Qt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function gu(r){let t=lp(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(I){return Z(I,n)}function c(I){return Xn(I,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=fp({...t,toBytes(I,U,b){let g=U.toAffine(),v=e.toBytes(g.x),N=ue;return Zt("isCompressed",b),b?N(Uint8Array.from([U.hasEvenY()?2:3]),v):N(Uint8Array.from([4]),v,e.toBytes(g.y))},fromBytes(I){let U=I.length,b=I[0],g=I.subarray(1);if(U===o&&(b===2||b===3)){let v=ae(g);if(!Kr(v,ht,e.ORDER))throw new Error("Point is not on curve");let N=u(v),P;try{P=e.sqrt(N)}catch(z){let V=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+V)}let D=(P&ht)===ht;return(b&1)===1!==D&&(P=e.neg(P)),{x:v,y:P}}else if(U===i&&b===4){let v=e.fromBytes(g.subarray(0,e.BYTES)),N=e.fromBytes(g.subarray(e.BYTES,2*e.BYTES));return{x:v,y:N}}else throw new Error(`Point of length ${U} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=I=>ce(Ae(I,t.nByteLength));function w(I){let U=n>>ht;return I>U}function E(I){return w(I)?s(-I):I}let m=(I,U,b)=>ae(I.slice(U,b));class d{constructor(U,b,g){this.r=U,this.s=b,this.recovery=g,this.assertValidity()}static fromCompact(U){let b=t.nByteLength;return U=nt("compactSignature",U,b*2),new d(m(U,0,b),m(U,b,2*b))}static fromDER(U){let{r:b,s:g}=fe.toSig(nt("DER",U));return new d(b,g)}assertValidity(){Tt("r",this.r,ht,n),Tt("s",this.s,ht,n)}addRecoveryBit(U){return new d(this.r,this.s,U)}recoverPublicKey(U){let{r:b,s:g,recovery:v}=this,N=L(nt("msgHash",U));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let P=v===2||v===3?b+t.n:b;if(P>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let D=v&1?"03":"02",$=a.fromHex(D+h(P)),z=c(P),V=s(-N*z),j=s(g*z),Q=a.BASE.multiplyAndAddUnsafe($,V,j);if(!Q)throw new Error("point at infinify");return Q.assertValidity(),Q}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Me(this.toDERHex())}toDERHex(){return fe.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Me(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let x={isValidPrivateKey(I){try{return f(I),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let I=$i(t.n);return ou(t.randomBytes(I),t.n)},precompute(I=8,U=a.BASE){return U._setWindowSize(I),U.multiply(BigInt(3)),U}};function A(I,U=!0){return a.fromPrivateKey(I).toRawBytes(U)}function y(I){let U=ve(I),b=typeof I=="string",g=(U||b)&&I.length;return U?g===o||g===i:b?g===2*o||g===2*i:I instanceof a}function B(I,U,b=!0){if(y(I))throw new Error("first arg must be private key");if(!y(U))throw new Error("second arg must be public key");return a.fromHex(U).multiply(f(I)).toRawBytes(b)}let R=t.bits2int||function(I){let U=ae(I),b=I.length*8-t.nBitLength;return b>0?U>>BigInt(b):U},L=t.bits2int_modN||function(I){return s(R(I))},T=Gr(t.nBitLength);function k(I){return Tt(`num < 2^${t.nBitLength}`,I,le,T),Ae(I,t.nByteLength)}function _(I,U,b=ot){if(["recovered","canonical"].some(ut=>ut in b))throw new Error("sign() legacy options not supported");let{hash:g,randomBytes:v}=t,{lowS:N,prehash:P,extraEntropy:D}=b;N==null&&(N=!0),I=nt("msgHash",I),pu(b),P&&(I=nt("prehashed msgHash",g(I)));let $=L(I),z=f(U),V=[k(z),k($)];if(D!=null&&D!==!1){let ut=D===!0?v(e.BYTES):D;V.push(nt("extraEntropy",ut))}let j=ue(...V),Q=$;function at(ut){let pt=R(ut);if(!l(pt))return;let wt=c(pt),st=a.BASE.multiply(pt).toAffine(),It=s(st.x);if(It===le)return;let Jt=s(wt*s(Q+It*z));if(Jt===le)return;let mr=(st.x===It?0:2)|Number(st.y&ht),gr=Jt;return N&&w(Jt)&&(gr=E(Jt),mr^=1),new d(It,gr,mr)}return{seed:j,k2sig:at}}let ot={lowS:t.lowS,prehash:!1},H={lowS:t.lowS,prehash:!1};function F(I,U,b=ot){let{seed:g,k2sig:v}=_(I,U,b),N=t;return Di(N.hash.outputLen,N.nByteLength,N.hmac)(g,v)}a.BASE._setWindowSize(8);function it(I,U,b,g=H){let v=I;if(U=nt("msgHash",U),b=nt("publicKey",b),"strict"in g)throw new Error("options.strict was renamed to lowS");pu(g);let{lowS:N,prehash:P}=g,D,$;try{if(typeof v=="string"||ve(v))try{D=d.fromDER(v)}catch(st){if(!(st instanceof fe.Err))throw st;D=d.fromCompact(v)}else if(typeof v=="object"&&typeof v.r=="bigint"&&typeof v.s=="bigint"){let{r:st,s:It}=v;D=new d(st,It)}else throw new Error("PARSE");$=a.fromHex(b)}catch(st){if(st.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(N&&D.hasHighS())return!1;P&&(U=t.hash(U));let{r:z,s:V}=D,j=L(U),Q=c(V),at=s(j*Q),ut=s(z*Q),pt=a.BASE.multiplyAndAddUnsafe($,at,ut)?.toAffine();return pt?s(pt.x)===z:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:B,sign:F,verify:it,ProjectivePoint:a,Signature:d,utils:x}}function dp(r){return{hash:r,hmac:(t,...e)=>Zi(r,t,ki(...e)),randomBytes:jn}}function yu(r,t){let e=n=>gu({...r,...dp(n)});return Object.freeze({...e(t),create:e})}var wu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),xu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),hp=BigInt(1),Wi=BigInt(2),bu=(r,t)=>(r+t/Wi)/t;function pp(r){let t=wu,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),f=r*r*r%t,u=f*f*r%t,l=et(u,e,t)*u%t,h=et(l,e,t)*u%t,w=et(h,Wi,t)*f%t,E=et(w,o,t)*w%t,m=et(E,i,t)*E%t,d=et(m,c,t)*m%t,x=et(d,a,t)*d%t,A=et(x,c,t)*m%t,y=et(A,e,t)*u%t,B=et(y,s,t)*E%t,R=et(B,n,t)*f%t,L=et(R,Wi,t);if(!Yi.eql(Yi.sqr(L),r))throw new Error("Cannot find square root");return L}var Yi=Be(wu,void 0,void 0,{sqrt:pp}),Ve=yu({a:BigInt(0),b:BigInt(7),Fp:Yi,n:xu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=xu,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-hp*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),c=bu(i*r,t),a=bu(-n*r,t),f=Z(r-c*e-a*o,t),u=Z(-c*n-a*i,t),l=f>s,h=u>s;if(l&&(f=t-f),h&&(u=t-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:h,k2:u}}}},hu),_1=BigInt(0);var N1=Ve.ProjectivePoint;function Eu(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function vu(r,t,e){let n=Cr.digest(e instanceof Uint8Array?e:e.subarray());if(Eu(n))return n.then(({digest:o})=>Ve.verify(t,o,r)).catch(o=>{throw new Wr(String(o))});try{return Ve.verify(t,n.digest,r)}catch(o){throw new Wr(String(o))}}var io=class{type="secp256k1";raw;_key;constructor(t){this._key=Au(t),this.raw=Su(this._key)}toMultihash(){return ne.digest(no(this))}toCID(){return mt.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Ht(this.raw,t.raw)}verify(t,e){return vu(this._key,e,t)}};function Bu(r){return new io(r)}function Su(r){return Ve.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Au(r){try{return Ve.ProjectivePoint.fromHex(r),r}catch(t){throw new Qr(String(t))}}function Iu(r){let{Type:t,Data:e}=Zr.decode(r.digest),n=e??new Uint8Array;switch(t){case Ft.Ed25519:return du(n);case Ft.secp256k1:return Bu(n);default:throw new yr}}function no(r){return Zr.encode({Type:Ft[r.type],Data:r.raw})}var Cu=Symbol.for("nodejs.util.inspect.custom"),mp=114,Yr=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()})`}[Xr]=!0;toString(){return this.string==null&&(this.string=J.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return mt.createV1(mp,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Ht(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Ht(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Cu](){return`PeerId(${this.toString()})`}},so=class extends Yr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},co=class extends Yr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},ao=class extends Yr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},gp=2336,uo=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=ne.digest(ye(this.url))}[Cu](){return`PeerId(${this.url})`}[Xr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return mt.createV1(gp,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=dt(t)),t.toString()===this.toString())}};function ku(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=re(J.decode(`z${r}`));else{if(t==null)throw new ze('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=re(t.decode(r))}return Xi(e)}function Xi(r){if(xp(r))return new so({multihash:r});if(yp(r))try{let t=Iu(r);if(t.type==="Ed25519")return new co({multihash:r,publicKey:t});if(t.type==="secp256k1")return new ao({multihash:r,publicKey:t})}catch{let e=dt(r.digest);return new uo(new URL(e))}throw new Jr("Supplied PeerID Multihash is invalid")}function yp(r){return r.code===ne.code}function xp(r){return r.code===Cr.code}var Tu={type:4098,canEncode:r=>as(r),encode:r=>r.toMultihash().bytes,decode:r=>Xi(re(r))};var Qi=[Ca,Ha,Tu,ka];function pr(r,t){let e={};for(let[n,o]of r.entries())e[n]=t(o);return e}async function fo(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:f})=>({multiaddr:f,isCertified:a,isConnected:o.includes(f.toString())})),protocols:[...c.protocols],tags:pr(c.tags,a=>a.value),metadata:pr(c.metadata,a=>Yt.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}async function lo(r){let t=await r.peerStore.get(r.peerId);return{id:t.id,addresses:t.addresses,protocols:[...t.protocols],tags:pr(t.tags,e=>e.value),metadata:pr(t.metadata,e=>Yt.encode(e))}}function Uu(r){let t=r.logger.forComponent("libp2p:devtools-metrics:metrics-rpc");return{init:async()=>({self:await lo(r),peers:await fo(r,t),debug:localStorage.getItem("debug")??""}),setDebug:async e=>{e?.length!=null&&e?.length>0?(Es(e),localStorage.setItem("debug",e)):(ws(),localStorage.removeItem("debug"))},openConnection:async(e,n)=>{let o;try{o=ku(e)}catch{o=Re(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}}function Ji(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)}}var Lu="@libp2p/devtools-metrics:devtools",bp="@libp2p/devtools-metrics:worker",wp="@libp2p/devtools-metrics:content",_u="@libp2p/devtools-metrics:metrics",Nu="________libp2p_devtools_metrics";Object.defineProperty(globalThis,Nu,{value:!0,enumerable:!1,writable:!1});var ts=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=he(),this.rpc=Ia({valueCodecs:Qi}),this.devTools=this.rpc.createClient("devTools"),this.onPeersUpdate=Ji(this.onPeersUpdate.bind(this),1e3),this.onSelfUpdate=Ji(this.onSelfUpdate.bind(this),1e3),this.onIncomingMessage=this.onIncomingMessage.bind(this),this.simpleMetrics=As({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";[tn]=["@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)}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",Uu(this.components)),await fs(this.simpleMetrics),Promise.resolve().then(async()=>{await Is(this.rpcQueue,this.rpc,async t=>{for await(let e of t)window.postMessage({source:_u,type:"libp2p-rpc",message:Yt.encode(e)})})}).catch(t=>{this.log.error("error while reading RPC messages",t)})}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 ls(this.simpleMetrics)}onIncomingMessage(t){if(t.source!==window)return;let e=t.data;e?.source===Lu&&e.type==="libp2p-rpc"&&this.rpcQueue.push(Yt.decode(e.message))}onSelfUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("self",{detail:await lo(this.components)})}).catch(t=>{this.log.error("error sending peers message",t)})}onPeersUpdate(){Promise.resolve().then(async()=>{await this.devTools.safeDispatchEvent("peers",{detail:await fo(this.components,this.log)})}).catch(t=>{this.log.error("error sending peers message",t)})}};function Ep(r){return t=>new ts(t,r)}return Gu(vp);})();
|
|
2
|
+
"use strict";var Libp2PDevtoolsMetrics=(()=>{var xo=Object.defineProperty;var Zu=Object.getOwnPropertyDescriptor;var Wu=Object.getOwnPropertyNames;var Yu=Object.prototype.hasOwnProperty;var Ct=(r,t)=>{for(var e in t)xo(r,e,{get:t[e],enumerable:!0})},Xu=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Wu(t))!Yu.call(r,o)&&o!==e&&xo(r,o,{get:()=>t[o],enumerable:!(n=Zu(t,o))||n.enumerable});return r};var Qu=r=>Xu(xo({},"__esModule",{value:!0}),r);var kp={};Ct(kp,{LIBP2P_DEVTOOLS_METRICS_KEY:()=>Fu,SOURCE_CONTENT_SCRIPT:()=>Ip,SOURCE_DEVTOOLS:()=>Mu,SOURCE_METRICS:()=>Ou,SOURCE_SERVICE_WORKER:()=>Bp,devToolsMetrics:()=>Cp,valueCodecs:()=>rs});var tn=Symbol.for("@libp2p/peer-id");function ds(r){return!!r?.[tn]}var hs;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(hs||(hs={}));var Ju=Symbol.for("@libp2p/pubsub");function en(r){return!!r?.[Ju]}var de=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},rn=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var nn=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var br=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};function ps(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}async function ms(...r){let t=[];for(let e of r)ps(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 gs(...r){let t=[];for(let e of r)ps(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 he=Symbol.for("@libp2p/service-capabilities"),Rp=Symbol.for("@libp2p/service-dependencies");var So={};Ct(So,{base32:()=>$t,base32hex:()=>uf,base32hexpad:()=>lf,base32hexpadupper:()=>df,base32hexupper:()=>ff,base32pad:()=>cf,base32padupper:()=>af,base32upper:()=>sf,base32z:()=>hf});var o0=new Uint8Array(0);function ys(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function te(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function xs(r){return new TextEncoder().encode(r)}function bs(r){return new TextDecoder().decode(r)}function tf(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),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function l(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var m=0,d=0,x=0,A=E.length;x!==A&&E[x]===0;)x++,m++;for(var y=(A-x)*u+1>>>0,B=new Uint8Array(y);x!==A;){for(var R=E[x],L=0,T=y-1;(R!==0||L<d)&&T!==-1;T--,L++)R+=256*B[T]>>>0,B[T]=R%c>>>0,R=R/c>>>0;if(R!==0)throw new Error("Non-zero carry");d=L,x++}for(var k=y-d;k!==y&&B[k]===0;)k++;for(var _=a.repeat(m);k<y;++k)_+=r.charAt(B[k]);return _}function h(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var m=0;if(E[m]!==" "){for(var d=0,x=0;E[m]===a;)d++,m++;for(var A=(E.length-m)*f+1>>>0,y=new Uint8Array(A);E[m];){var B=e[E.charCodeAt(m)];if(B===255)return;for(var R=0,L=A-1;(B!==0||R<x)&&L!==-1;L--,R++)B+=c*y[L]>>>0,y[L]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");x=R,m++}if(E[m]!==" "){for(var T=A-x;T!==A&&y[T]===0;)T++;for(var k=new Uint8Array(d+(A-T)),_=d;T!==A;)k[_++]=y[T++];return k}}}function w(E){var m=h(E);if(m)return m;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:h,decode:w}}var ef=tf,rf=ef,Es=rf;var bo=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")}},wo=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 vs(this,t)}},Eo=class{decoders;constructor(t){this.decoders=t}or(t){return vs(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 vs(r,t){return new Eo({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var vo=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 bo(t,e,n),this.decoder=new wo(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function qe({name:r,prefix:t,encode:e,decode:n}){return new vo(r,t,e,n)}function pe({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Es(e,r);return qe({prefix:t,name:r,encode:n,decode:i=>te(o(i))})}function nf(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,f=0;for(let u=0;u<i;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|l,c+=e,c>=8&&(c-=8,s[f++]=255&a>>c)}if(c>=e||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return s}function of(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>e;)s-=e,i+=t[o&c>>s];if(s!==0&&(i+=t[o&c<<e-s]),n)for(;i.length*e&7;)i+="=";return i}function rt({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return qe({prefix:t,name:r,encode(o){return of(o,n,e)},decode(o){return nf(o,n,e,r)}})}var $t=rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),sf=rt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),cf=rt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),af=rt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),uf=rt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ff=rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),lf=rt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),df=rt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),hf=rt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ao={};Ct(Ao,{base58btc:()=>J,base58flickr:()=>pf});var J=pe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pf=pe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bo={};Ct(Bo,{base64:()=>Yt,base64pad:()=>mf,base64url:()=>gf,base64urlpad:()=>yf});var Yt=rt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),mf=rt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gf=rt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yf=rt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function xf(r,t){try{if(typeof r=="string"&&r.length>0)return bf(r);if(typeof r=="number"&&isFinite(r))return t?.long?Ef(r):wf(r);throw new Error("Value is not a string or number.")}catch(e){let n=vf(e)?`${e.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function bf(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 sn=xf;function wf(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 Ef(r){let t=Math.abs(r);return t>=864e5?on(r,t,864e5,"day"):t>=36e5?on(r,t,36e5,"hour"):t>=6e4?on(r,t,6e4,"minute"):t>=1e3?on(r,t,1e3,"second"):`${r} ms`}function on(r,t,e,n){let o=t>=e*1.5;return`${Math.round(r/e)} ${n}${o?"s":""}`}function vf(r){return typeof r=="object"&&r!==null&&"message"in r}function Io(r){e.debug=e,e.default=e,e.coerce=a,e.disable=i,e.enable=o,e.enabled=s,e.humanize=sn,e.destroy=f,Object.keys(r).forEach(u=>{e[u]=r[u]}),e.names=[],e.skips=[],e.formatters={};function t(u){let l=0;for(let h=0;h<u.length;h++)l=(l<<5)-l+u.charCodeAt(h),l|=0;return e.colors[Math.abs(l)%e.colors.length]}e.selectColor=t;function e(u){let l,h=null,w,E;function m(...d){if(!m.enabled)return;let x=m,A=Number(new Date),y=A-(l||A);x.diff=y,x.prev=l,x.curr=A,l=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,(L,T)=>{if(L==="%%")return"%";B++;let k=e.formatters[T];if(typeof k=="function"){let _=d[B];L=k.call(x,_),d.splice(B,1),B--}return L}),e.formatArgs.call(x,d),(x.log||e.log).apply(x,d)}return m.namespace=u,m.useColors=e.useColors(),m.color=e.selectColor(u),m.extend=n,m.destroy=e.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(w!==e.namespaces&&(w=e.namespaces,E=e.enabled(u)),E),set:d=>{h=d}}),typeof e.init=="function"&&e.init(m),m}function n(u,l){let h=e(this.namespace+(typeof l>"u"?":":l)+u);return h.log=this.log,h}function o(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let l,h=(typeof u=="string"?u:"").split(/[\s,]+/),w=h.length;for(l=0;l<w;l++)h[l]&&(u=h[l].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(l=>"-"+l)].join(",");return e.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,h;for(l=0,h=e.skips.length;l<h;l++)if(e.skips[l].test(u))return!1;for(l=0,h=e.names.length;l<h;l++)if(e.names[l].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 f(){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 cn=Tf(),Sf=["#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 Af(){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 Bf(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+sn(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 If=console.debug??console.log??(()=>{});function Cf(r){try{r?cn?.setItem("debug",r):cn?.removeItem("debug")}catch{}}function kf(){let r;try{r=cn?.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Tf(){try{return localStorage}catch{}}function Uf(r){r.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}var Ss=Io({formatArgs:Bf,save:Cf,load:kf,useColors:Af,setupFormatters:Uf,colors:Sf,storage:cn,log:If});var Et=Ss;Et.formatters.b=r=>r==null?"undefined":J.baseEncode(r);Et.formatters.t=r=>r==null?"undefined":$t.baseEncode(r);Et.formatters.m=r=>r==null?"undefined":Yt.baseEncode(r);Et.formatters.p=r=>r==null?"undefined":r.toString();Et.formatters.c=r=>r==null?"undefined":r.toString();Et.formatters.k=r=>r==null?"undefined":r.toString();Et.formatters.a=r=>r==null?"undefined":r.toString();function Lf(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 As(r){let t=Lf(`${r}:trace`);return Et.enabled(`${r}:trace`)&&Et.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=Et(`${r}:trace`)),Object.assign(Et(r),{error:Et(`${r}:error`),trace:t})}function Bs(){Et.disable()}function Is(r){Et.enable(r)}function _f(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 Cs=_f;function Nf(r){return r[Symbol.asyncIterator]!=null}function ks(r){return r?.then!=null}function Rf(r,t){let e=0;if(Nf(r))return async function*(){for await(let a of r){let f=t(a,e++);ks(f)&&await f,yield a}}();let n=Cs(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 f=t(a,e++);ks(f)&&await f,yield a}}();let c=t;return function*(){yield o;for(let a of n)c(a,e++),yield a}()}var Co=Rf;var Pf=As("libp2p:simple-metrics"),wr=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}}},Er=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}}},ko=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";[he]=["@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 wr?t[e]=n.value:n instanceof Er?t[e]=n.values:t[e]=await n();this.onMetrics(structuredClone(t))}).catch(t=>{Pf.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(Co(c,a=>{n._incrementValue(`${e} sent`,a.byteLength)}))};let i=t.source;t.source=Co(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 wr;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 Er;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 wr;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 Er;return this.metrics.set(t,n),n}};function Ts(r){return t=>new ko(t,r)}function Vt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var an=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Ke=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new an(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new an(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var To=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function me(r={}){return Df(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 Df(r,t){t=t??{};let e=t.onEnd,n=new Ke,o,i,s,c=Vt(),a=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((d,x)=>{i=A=>{i=null,n.push(A);try{d(r(n))}catch(y){x(y)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=Vt()})}},f=d=>i!=null?i(d):(n.push(d),o),u=d=>(n=new Ke,i!=null?i({error:d}):(n.push({error:d}),o)),l=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 f({done:!1,value:d})},h=d=>s?o:(s=!0,d!=null?u(d):f({done:!0})),w=()=>(n=new Ke,h(),{done:!0}),E=d=>(h(d),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:w,throw:E,push:l,end:h,get readableLength(){return n.size},onEmpty:async d=>{let x=d?.signal;if(x?.throwIfAborted(),n.isEmpty())return;let A,y;x!=null&&(A=new Promise((B,R)=>{y=()=>{R(new To)},x.addEventListener("abort",y)}));try{await Promise.race([c.promise,A])}finally{y!=null&&x!=null&&x?.removeEventListener("abort",y)}}},e==null)return o;let m=o;return o={[Symbol.asyncIterator](){return this},next(){return m.next()},throw(d){return m.throw(d),e!=null&&(e(d),e=void 0),{done:!0}},return(){return m.return(),e!=null&&(e(),e=void 0),{done:!0}},push:l,end(d){return m.end(d),e!=null&&(e(d),e=void 0),o},get readableLength(){return m.readableLength},onEmpty:d=>m.onEmpty(d)},o}function Mf(r){return r[Symbol.asyncIterator]!=null}function Of(...r){let t=[];for(let e of r)Mf(e)||t.push(e);return t.length===r.length?function*(){for(let e of t)yield*e}():async function*(){let e=me({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)e.push(o)})),e.end()}catch(n){e.end(n)}}),yield*e}()}var Us=Of;function Ls(r,...t){if(r==null)throw new Error("Empty pipeline");if(Uo(r)){let n=r;r=()=>n.source}else if(Ns(r)||_s(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&Uo(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++)Uo(e[n])&&(e[n]=$f(e[n]));return Ff(...e)}var Ff=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},_s=r=>r?.[Symbol.asyncIterator]!=null,Ns=r=>r?.[Symbol.iterator]!=null,Uo=r=>r==null?!1:r.sink!=null&&r.source!=null,$f=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=me({objectMode:!0});e.then(()=>{n.end()},s=>{n.end(s)});let o,i=r.source;if(_s(i))o=async function*(){yield*i,n.end()};else if(Ns(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Us(n,o())}return r.source};function un(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 zt(r=0){return new Uint8Array(r)}function yt(r=0){return new Uint8Array(r)}var Vf=Math.pow(2,7),zf=Math.pow(2,14),Hf=Math.pow(2,21),Lo=Math.pow(2,28),_o=Math.pow(2,35),No=Math.pow(2,42),Ro=Math.pow(2,49),G=128,xt=127;function ft(r){if(r<Vf)return 1;if(r<zf)return 2;if(r<Hf)return 3;if(r<Lo)return 4;if(r<_o)return 5;if(r<No)return 6;if(r<Ro)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Po(r,t,e=0){switch(ft(r)){case 8:t[e++]=r&255|G,r/=128;case 7:t[e++]=r&255|G,r/=128;case 6:t[e++]=r&255|G,r/=128;case 5:t[e++]=r&255|G,r/=128;case 4:t[e++]=r&255|G,r>>>=7;case 3:t[e++]=r&255|G,r>>>=7;case 2:t[e++]=r&255|G,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function qf(r,t,e=0){switch(ft(r)){case 8:t.set(e++,r&255|G),r/=128;case 7:t.set(e++,r&255|G),r/=128;case 6:t.set(e++,r&255|G),r/=128;case 5:t.set(e++,r&255|G),r/=128;case 4:t.set(e++,r&255|G),r>>>=7;case 3:t.set(e++,r&255|G),r>>>=7;case 2:t.set(e++,r&255|G),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Do(r,t){let e=r[t],n=0;if(n+=e&xt,e<G||(e=r[t+1],n+=(e&xt)<<7,e<G)||(e=r[t+2],n+=(e&xt)<<14,e<G)||(e=r[t+3],n+=(e&xt)<<21,e<G)||(e=r[t+4],n+=(e&xt)*Lo,e<G)||(e=r[t+5],n+=(e&xt)*_o,e<G)||(e=r[t+6],n+=(e&xt)*No,e<G)||(e=r[t+7],n+=(e&xt)*Ro,e<G))return n;throw new RangeError("Could not decode varint")}function Kf(r,t){let e=r.get(t),n=0;if(n+=e&xt,e<G||(e=r.get(t+1),n+=(e&xt)<<7,e<G)||(e=r.get(t+2),n+=(e&xt)<<14,e<G)||(e=r.get(t+3),n+=(e&xt)<<21,e<G)||(e=r.get(t+4),n+=(e&xt)*Lo,e<G)||(e=r.get(t+5),n+=(e&xt)*_o,e<G)||(e=r.get(t+6),n+=(e&xt)*No,e<G)||(e=r.get(t+7),n+=(e&xt)*Ro,e<G))return n;throw new RangeError("Could not decode varint")}function ge(r,t,e=0){return t==null&&(t=yt(ft(r))),t instanceof Uint8Array?Po(r,t,e):qf(r,t,e)}function ee(r,t=0){return r instanceof Uint8Array?Do(r,t):Kf(r,t)}function Lt(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=yt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function Ht(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 Ps=Symbol.for("@achingbrain/uint8arraylist");function Rs(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 ln(r){return!!r?.[Ps]}var Ge=class r{bufs;length;[Ps]=!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(ln(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(ln(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=Rs(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Rs(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(ln(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Lt(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Lt(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),i=new r;return i.length=o,i.bufs=[...n],i}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,a=c+s.byteLength;if(o=a,t>=a)continue;let f=t>=c&&t<a,u=e>c&&e<=a;if(f&&u){if(t===c&&e===a){n.push(s);break}let l=t-c;n.push(s.subarray(l,l+(e-t)));break}if(f){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(!ln(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 l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let c=s,a=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=e;l<=a;l+=u){u=0;for(let h=f;h>=0;h--){let w=this.get(l+h);if(n[h]!==w){u=Math.max(1,h-c[w]);break}}if(u===0)return l}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=yt(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=zt(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=zt(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=zt(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=yt(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=zt(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=zt(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=zt(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=zt(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=zt(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(!Ht(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,i)=>o+i.byteLength,0)),n.length=e,n}};function dn(r){return r[Symbol.asyncIterator]!=null}var hn=r=>{let t=ft(r),e=yt(t);return ge(r,e),hn.bytes=t,e};hn.bytes=0;function pn(r,t){t=t??{};let e=t.lengthEncoder??hn;function*n(o){let i=e(o.byteLength);i instanceof Uint8Array?yield i:yield*i,o instanceof Uint8Array?yield o:yield*o}return dn(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}pn.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??hn;return new Ge(e(r.byteLength),r)};var mn=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},gn=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},yn=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},vr=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var Gf=8,jf=1024*1024*4,Ue;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Ue||(Ue={}));var Mo=r=>{let t=ee(r);return Mo.bytes=ft(t),t};Mo.bytes=0;function Sr(r,t){let e=new Ge,n=Ue.LENGTH,o=-1,i=t?.lengthDecoder??Mo,s=t?.maxLengthLength??Gf,c=t?.maxDataLength??jf;function*a(){for(;e.byteLength>0;){if(n===Ue.LENGTH)try{if(o=i(e),o<0)throw new mn("Invalid message length");if(o>c)throw new gn("Message length too long");let f=i.bytes;e.consume(f),t?.onLength!=null&&t.onLength(o),n=Ue.DATA}catch(f){if(f instanceof RangeError){if(e.byteLength>s)throw new yn("Message length length too long");break}throw f}if(n===Ue.DATA){if(e.byteLength<o)break;let f=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(f),yield f,n=Ue.LENGTH}}}return dn(r)?async function*(){for await(let f of r)e.append(f),yield*a();if(e.byteLength>0)throw new vr("Unexpected end of input")}():function*(){for(let f of r)e.append(f),yield*a();if(e.byteLength>0)throw new vr("Unexpected end of input")}()}Sr.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 Sr(n,{...t??{},onLength:i=>{e=i}})};var Ds="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var je=(r=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(r));for(;r--;)t+=Ds[e[r]&63];return t};var xn=class extends Error{constructor(t="Method not found"){super(t),this.name="MethodNotFoundError"}},bn=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidMethodError"}},Ar=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"}},Br=class extends Error{constructor(t="Duplicate scope"){super(t),this.name="DuplicateScopeError"}},En=class extends Error{constructor(t="Invalid return type"){super(t),this.name="InvalidReturnTypeError"}},Ir=class extends Error{constructor(t="Invocation target was not a function"){super(t),this.name="InvalidInvocationTypeError"}},Ze=class extends Error{constructor(t="Parent invocation scope not found"){super(t),this.name="MissingParentScopeError"}},vn=class extends Error{constructor(t="Invocation not found"){super(t),this.name="MissingInvocationError"}},Sn=class extends Error{constructor(t="Callback not found"){super(t),this.name="MissingCallbackError"}};var Oo=new Float32Array([-0]),ye=new Uint8Array(Oo.buffer);function Ms(r,t,e){Oo[0]=r,t[e]=ye[0],t[e+1]=ye[1],t[e+2]=ye[2],t[e+3]=ye[3]}function Os(r,t){return ye[0]=r[t],ye[1]=r[t+1],ye[2]=r[t+2],ye[3]=r[t+3],Oo[0]}var Fo=new Float64Array([-0]),bt=new Uint8Array(Fo.buffer);function Fs(r,t,e){Fo[0]=r,t[e]=bt[0],t[e+1]=bt[1],t[e+2]=bt[2],t[e+3]=bt[3],t[e+4]=bt[4],t[e+5]=bt[5],t[e+6]=bt[6],t[e+7]=bt[7]}function $s(r,t){return bt[0]=r[t],bt[1]=r[t+1],bt[2]=r[t+2],bt[3]=r[t+3],bt[4]=r[t+4],bt[5]=r[t+5],bt[6]=r[t+6],bt[7]=r[t+7],Fo[0]}var Zf=BigInt(Number.MAX_SAFE_INTEGER),Wf=BigInt(Number.MIN_SAFE_INTEGER),_t=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 Le;if(t<Zf&&t>Wf)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>Vs&&(o=0n,++n>Vs&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return Le;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):Le}},Le=new _t(0,0);Le.toBigInt=function(){return 0n};Le.zzEncode=Le.zzDecode=function(){return this};Le.length=function(){return 1};var Vs=4294967296n;function zs(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 Hs(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 $o(r,t,e){let n=e,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function qt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function An(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Vo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,qt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw qt(this,4);return An(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qt(this,4);return An(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qt(this,4);let t=Os(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw qt(this,4);let t=$s(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw qt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Hs(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw qt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw qt(this);while(this.buf[this.pos++]&128);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 _t(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw qt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw qt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw qt(this,8);let t=An(this.buf,this.pos+=4),e=An(this.buf,this.pos+=4);return new _t(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=Do(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 zo(r){return new Vo(r instanceof Uint8Array?r:r.subarray())}function vt(r,t,e){let n=zo(r);return t.decode(n,void 0,e)}var Ho={};Ct(Ho,{base10:()=>Yf});var Yf=pe({prefix:"9",name:"base10",alphabet:"0123456789"});var qo={};Ct(qo,{base16:()=>Xf,base16upper:()=>Qf});var Xf=rt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Qf=rt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ko={};Ct(Ko,{base2:()=>Jf});var Jf=rt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Go={};Ct(Go,{base256emoji:()=>ol});var Ks=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}"),tl=Ks.reduce((r,t,e)=>(r[e]=t,r),[]),el=Ks.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function rl(r){return r.reduce((t,e)=>(t+=tl[e],t),"")}function nl(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=el[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var ol=qe({prefix:"\u{1F680}",name:"base256emoji",encode:rl,decode:nl});var jo={};Ct(jo,{base36:()=>Cr,base36upper:()=>il});var Cr=pe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),il=pe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Zo={};Ct(Zo,{base8:()=>sl});var sl=rt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Wo={};Ct(Wo,{identity:()=>cl});var cl=qe({prefix:"\0",name:"identity",encode:r=>bs(r),decode:r=>xs(r)});var Rm=new TextEncoder,Pm=new TextDecoder;var Xo={};Ct(Xo,{identity:()=>ne});var fl=Zs,Gs=128,ll=127,dl=~ll,hl=Math.pow(2,31);function Zs(r,t,e){t=t||[],e=e||0;for(var n=e;r>=hl;)t[e++]=r&255|Gs,r/=128;for(;r&dl;)t[e++]=r&255|Gs,r>>>=7;return t[e]=r|0,Zs.bytes=e-n+1,t}var pl=Yo,ml=128,js=127;function Yo(r,n){var e=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw Yo.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&js)<<o:(s&js)*Math.pow(2,o),o+=7}while(s>=ml);return Yo.bytes=i-n,e}var gl=Math.pow(2,7),yl=Math.pow(2,14),xl=Math.pow(2,21),bl=Math.pow(2,28),wl=Math.pow(2,35),El=Math.pow(2,42),vl=Math.pow(2,49),Sl=Math.pow(2,56),Al=Math.pow(2,63),Bl=function(r){return r<gl?1:r<yl?2:r<xl?3:r<bl?4:r<wl?5:r<El?6:r<vl?7:r<Sl?8:r<Al?9:10},Il={encode:fl,decode:pl,encodingLength:Bl},Cl=Il,kr=Cl;function Tr(r,t=0){return[kr.decode(r,t),kr.decode.bytes]}function We(r,t,e=0){return kr.encode(r,t,e),t}function Ye(r){return kr.encodingLength(r)}function _e(r,t){let e=t.byteLength,n=Ye(r),o=n+Ye(e),i=new Uint8Array(o+e);return We(r,i,0),We(e,i,n),i.set(t,o),new Xe(r,e,t,i)}function re(r){let t=te(r),[e,n]=Tr(t),[o,i]=Tr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Xe(e,o,s,t)}function Ws(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ys(r.bytes,e.bytes)}}var Xe=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Ys=0,kl="identity",Xs=te;function Tl(r){return _e(Ys,Xs(r))}var ne={code:Ys,name:kl,encode:Xs,digest:Tl};var ti={};Ct(ti,{sha256:()=>Ur,sha512:()=>Ul});function Jo({name:r,code:t,encode:e}){return new Qo(r,t,e)}var Qo=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?_e(this.code,e):e.then(n=>_e(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Js(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Ur=Jo({name:"sha2-256",code:18,encode:Js("SHA-256")}),Ul=Jo({name:"sha2-512",code:19,encode:Js("SHA-512")});function tc(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return _l(e,ei(r),t??J.encoder);default:return Nl(e,ei(r),t??$t.encoder)}}var ec=new WeakMap;function ei(r){let t=ec.get(r);if(t==null){let e=new Map;return ec.set(r,e),e}return t}var mt=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!==Lr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Rl)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=_e(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&&Ws(t.multihash,n.multihash)}toString(t){return tc(this,t)}toJSON(){return{"/":tc(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let 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??rc(n,o,i.bytes))}else if(e[Pl]===!0){let{version:n,multihash:o,code:i}=e,s=re(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!==Lr)throw new Error(`Version 0 CID must use dag-pb (code: ${Lr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=rc(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Lr,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=te(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 Xe(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[l,h]=Tr(t.subarray(e));return e+=h,l},o=n(),i=Lr;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(),f=e+a,u=f-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:f}}static parse(t,e){let[n,o]=Ll(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 ei(i).set(n,t),i}};function Ll(r,t){switch(r[0]){case"Q":{let e=t??J;return[J.prefix,e.decode(`${J.prefix}${r}`)]}case J.prefix:{let e=t??J;return[J.prefix,e.decode(r)]}case $t.prefix:{let e=t??$t;return[$t.prefix,e.decode(r)]}case Cr.prefix:{let e=t??Cr;return[Cr.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 _l(r,t,e){let{prefix:n}=e;if(n!==J.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function Nl(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 Lr=112,Rl=18;function rc(r,t,e){let n=Ye(r),o=n+Ye(t),i=new Uint8Array(o+e.byteLength);return We(r,i,0),We(t,i,n),i.set(e,o),i}var Pl=Symbol.for("@ipld/js-cid/CID");var _r={...Wo,...Ko,...Zo,...Ho,...qo,...So,...jo,...Ao,...Bo,...Go},ng={...ti,...Xo};function oc(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var nc=oc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ri=oc("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=yt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Dl={utf8:nc,"utf-8":nc,hex:_r.base16,latin1:ri,ascii:ri,binary:ri,..._r},In=Dl;function be(r,t="utf8"){let e=In[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function ni(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return yt(s);o+s>t&&(n=yt(t),o=0);let c=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),c}}var Ne=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function oi(){}var si=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Ml=ni();function Ol(r){return globalThis.Buffer!=null?yt(r):Ml(r)}var Rr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ne(oi,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Ne(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new ci((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(Cn,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=_t.fromBigInt(t);return this._push(Cn,e.length(),e)}uint64Number(t){return this._push(Po,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=_t.fromBigInt(t).zzEncode();return this._push(Cn,e.length(),e)}sint64Number(t){let e=_t.fromNumber(t).zzEncode();return this._push(Cn,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ii,1,t?1:0)}fixed32(t){return this._push(Nr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=_t.fromBigInt(t);return this._push(Nr,4,e.lo)._push(Nr,4,e.hi)}fixed64Number(t){let e=_t.fromNumber(t);return this._push(Nr,4,e.lo)._push(Nr,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(Ms,4,t)}double(t){return this._push(Fs,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(ii,1,0):this.uint32(e)._push($l,e,t)}string(t){let e=zs(t);return e!==0?this.uint32(e)._push($o,e,t):this._push(ii,1,0)}fork(){return this.states=new si(this),this.head=this.tail=new Ne(oi,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Ne(oi,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=Ol(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function ii(r,t,e){t[e]=r&255}function Fl(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var ci=class extends Ne{next;constructor(t,e){super(Fl,t,e),this.next=void 0}};function Cn(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 Nr(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 $l(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Rr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Vl,t,r),this},Rr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(zl,t,r),this});function Vl(r,t,e){t.set(r,e)}function zl(r,t,e){r.length<40?$o(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(be(r),e)}function ai(){return new Rr}function St(r,t){let e=ai();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Qe;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Qe||(Qe={}));function kn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Pr(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 kn("enum",Qe.VARINT,e,n)}function At(r,t){return kn("message",Qe.LENGTH_DELIMITED,r,t)}var oe=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 Tn;(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"})(Tn||(Tn={}));(function(r){r.codec=()=>Pr(Tn)})(q||(q={}));var kt;(function(r){let t;r.codec=()=>(t==null&&(t=At((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=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(kt||(kt={}));var Bt;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.type!=null&&Tn[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:zt(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=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Bt||(Bt={}));var Re;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.path!=null&&e.path!==""&&(n.uint32(18),n.string(e.path)),e.args!=null)for(let i of e.args)n.uint32(26),kt.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",path:"",args:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.path=e.string();break}case 3:{if(o.limits?.args!=null&&i.args.length===o.limits.args)throw new oe('Decode error - map field "args" had too many elements');i.args.push(kt.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Re||(Re={}));var Dr;(function(r){let t;r.codec=()=>(t==null&&(t=At((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=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Dr||(Dr={}));var Je;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.value!=null&&(n.uint32(18),kt.codec().encode(e.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.value=kt.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Je||(Je={}));var Mr;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.error!=null&&(n.uint32(18),kt.codec().encode(e.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:""},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{i.error=kt.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Mr||(Mr={}));var tr;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);if(e.callback!=null&&e.callback!==""&&(n.uint32(26),n.string(e.callback)),e.args!=null)for(let i of e.args)n.uint32(34),kt.codec().encode(i,n);o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[],callback:"",args:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new oe('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 oe('Decode error - map field "args" had too many elements');i.args.push(kt.codec().decode(e,e.uint32(),{limits:o.limits?.args$}));break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(tr||(tr={}));var er;(function(r){let t;r.codec=()=>(t==null&&(t=At((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 oe('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=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(er||(er={}));var Or;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);e.value!=null&&(n.uint32(26),kt.codec().encode(e.value,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new oe('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.value=kt.codec().decode(e,e.uint32(),{limits:o.limits?.value});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Or||(Or={}));var Fr;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),e.scope!=null&&e.scope!==""&&(n.uint32(10),n.string(e.scope)),e.parents!=null)for(let i of e.parents)n.uint32(18),n.string(i);e.error!=null&&(n.uint32(26),kt.codec().encode(e.error,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={scope:"",parents:[]},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let c=e.uint32();switch(c>>>3){case 1:{i.scope=e.string();break}case 2:{if(o.limits?.parents!=null&&i.parents.length===o.limits.parents)throw new oe('Decode error - map field "parents" had too many elements');i.parents.push(e.string());break}case 3:{i.error=kt.codec().decode(e,e.uint32(),{limits:o.limits?.error});break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Fr||(Fr={}));function Hl(r){return r.parents!=null}function ic(r,t){if(Hl(r))return ql(r.parents,t);let e=t.get(r.scope);if(e==null)throw new vn;return e}function ql(r,t){let e;for(let n of r){if(e==null){if(e=t.get(n),e==null)throw new Ze;continue}if(e=e.children.get(n),e==null)throw new Ze}if(e==null)throw new Ze;return e}var Kl={type:1024,canEncode:r=>r===void 0,decode:()=>{}},sc=Kl;var Gl={type:1025,canEncode:r=>r===null,decode:()=>null},cc=Gl;var jl=["string","number","bigint","symbol"],Zl=["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 ac(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let t=typeof r;if(jl.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(r))return"Array";if(Wl(r))return"Buffer";let e=Yl(r);return e||"Object"}function Wl(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Yl(r){let t=Object.prototype.toString.call(r).slice(8,-1);if(Zl.includes(t))return t}var p=class{constructor(t,e,n){this.major=t,this.majorEncoded=t<<5,this.name=e,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};p.uint=new p(0,"uint",!0);p.negint=new p(1,"negint",!0);p.bytes=new p(2,"bytes",!0);p.string=new p(3,"string",!0);p.array=new p(4,"array",!1);p.map=new p(5,"map",!1);p.tag=new p(6,"tag",!1);p.float=new p(7,"float",!0);p.false=new p(7,"false",!0);p.true=new p(7,"true",!0);p.null=new p(7,"null",!0);p.undefined=new p(7,"undefined",!0);p.break=new p(7,"break",!0);var C=class{constructor(t,e,n){this.type=t,this.value=e,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var rr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Xl=new TextDecoder,Ql=new TextEncoder;function Un(r){return rr&&globalThis.Buffer.isBuffer(r)}function ui(r){return r instanceof Uint8Array?Un(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var dc=rr?(r,t,e)=>e-t>64?globalThis.Buffer.from(r.subarray(t,e)).toString("utf8"):fc(r,t,e):(r,t,e)=>e-t>64?Xl.decode(r.subarray(t,e)):fc(r,t,e),hc=rr?r=>r.length>64?globalThis.Buffer.from(r):uc(r):r=>r.length>64?Ql.encode(r):uc(r),Xt=r=>Uint8Array.from(r),nr=rr?(r,t,e)=>Un(r)?new Uint8Array(r.subarray(t,e)):r.slice(t,e):(r,t,e)=>r.slice(t,e),pc=rr?(r,t)=>(r=r.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),ui(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},mc=rr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function gc(r,t){if(Un(r)&&Un(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 uc(r){let t=[],e=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128)}return t}function fc(r,t,e){let n=[];for(;t<e;){let o=r[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=e){let c,a,f,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],f=r[t+3],(c&192)===128&&(a&192)===128&&(f&192)===128&&(u=(o&15)<<18|(c&63)<<12|(a&63)<<6|f&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 Jl(n)}var lc=4096;function Jl(r){let t=r.length;if(t<=lc)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=lc));return e}var td=256,$r=class{constructor(t=td){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=mc(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=nr(n,0,this.cursor)}else e=pc(this.chunks,this.cursor);return t&&this.reset(),e}};var M="CBOR decode error:",fi="CBOR encode error:",Vr=[];Vr[23]=1;Vr[24]=2;Vr[25]=3;Vr[26]=5;Vr[27]=9;function ie(r,t,e){if(r.length-t<e)throw new Error(`${M} not enough data for type`)}var lt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Nt(r,t,e){ie(r,t,1);let n=r[t];if(e.strict===!0&&n<lt[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Rt(r,t,e){ie(r,t,2);let n=r[t]<<8|r[t+1];if(e.strict===!0&&n<lt[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Pt(r,t,e){ie(r,t,4);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];if(e.strict===!0&&n<lt[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Dt(r,t,e){ie(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<lt[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 yc(r,t,e,n){return new C(p.uint,Nt(r,t+1,n),2)}function xc(r,t,e,n){return new C(p.uint,Rt(r,t+1,n),3)}function bc(r,t,e,n){return new C(p.uint,Pt(r,t+1,n),5)}function wc(r,t,e,n){return new C(p.uint,Dt(r,t+1,n),9)}function Mt(r,t){return gt(r,0,t.value)}function gt(r,t,e){if(e<lt[0]){let n=Number(e);r.push([t|n])}else if(e<lt[1]){let n=Number(e);r.push([t|24,n])}else if(e<lt[2]){let n=Number(e);r.push([t|25,n>>>8,n&255])}else if(e<lt[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<lt[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`)}}Mt.encodedSize=function(t){return gt.encodedSize(t.value)};gt.encodedSize=function(t){return t<lt[0]?1:t<lt[1]?2:t<lt[2]?3:t<lt[3]?5:9};Mt.compareTokens=function(t,e){return t.value<e.value?-1:t.value>e.value?1:0};function Ec(r,t,e,n){return new C(p.negint,-1-Nt(r,t+1,n),2)}function vc(r,t,e,n){return new C(p.negint,-1-Rt(r,t+1,n),3)}function Sc(r,t,e,n){return new C(p.negint,-1-Pt(r,t+1,n),5)}var li=BigInt(-1),Ac=BigInt(1);function Bc(r,t,e,n){let o=Dt(r,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new C(p.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new C(p.negint,li-BigInt(o),9)}function Ln(r,t){let e=t.value,n=typeof e=="bigint"?e*li-Ac:e*-1-1;gt(r,t.type.majorEncoded,n)}Ln.encodedSize=function(t){let e=t.value,n=typeof e=="bigint"?e*li-Ac:e*-1-1;return n<lt[0]?1:n<lt[1]?2:n<lt[2]?3:n<lt[3]?5:9};Ln.compareTokens=function(t,e){return t.value<e.value?1:t.value>e.value?-1:0};function zr(r,t,e,n){ie(r,t,e+n);let o=nr(r,t+e,t+e+n);return new C(p.bytes,o,e+n)}function Ic(r,t,e,n){return zr(r,t,1,e)}function Cc(r,t,e,n){return zr(r,t,2,Nt(r,t+1,n))}function kc(r,t,e,n){return zr(r,t,3,Rt(r,t+1,n))}function Tc(r,t,e,n){return zr(r,t,5,Pt(r,t+1,n))}function Uc(r,t,e,n){let o=Dt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return zr(r,t,9,o)}function _n(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===p.string?hc(r.value):r.value),r.encodedBytes}function or(r,t){let e=_n(t);gt(r,t.type.majorEncoded,e.length),r.push(e)}or.encodedSize=function(t){let e=_n(t);return gt.encodedSize(e.length)+e.length};or.compareTokens=function(t,e){return rd(_n(t),_n(e))};function rd(r,t){return r.length<t.length?-1:r.length>t.length?1:gc(r,t)}function Hr(r,t,e,n,o){let i=e+n;ie(r,t,i);let s=new C(p.string,dc(r,t+e,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=nr(r,t+e,t+i)),s}function Lc(r,t,e,n){return Hr(r,t,1,e,n)}function _c(r,t,e,n){return Hr(r,t,2,Nt(r,t+1,n),n)}function Nc(r,t,e,n){return Hr(r,t,3,Rt(r,t+1,n),n)}function Rc(r,t,e,n){return Hr(r,t,5,Pt(r,t+1,n),n)}function Pc(r,t,e,n){let o=Dt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return Hr(r,t,9,o,n)}var Dc=or;function ir(r,t,e,n){return new C(p.array,n,e)}function Mc(r,t,e,n){return ir(r,t,1,e)}function Oc(r,t,e,n){return ir(r,t,2,Nt(r,t+1,n))}function Fc(r,t,e,n){return ir(r,t,3,Rt(r,t+1,n))}function $c(r,t,e,n){return ir(r,t,5,Pt(r,t+1,n))}function Vc(r,t,e,n){let o=Dt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return ir(r,t,9,o)}function zc(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return ir(r,t,1,1/0)}function Nn(r,t){gt(r,p.array.majorEncoded,t.value)}Nn.compareTokens=Mt.compareTokens;Nn.encodedSize=function(t){return gt.encodedSize(t.value)};function sr(r,t,e,n){return new C(p.map,n,e)}function Hc(r,t,e,n){return sr(r,t,1,e)}function qc(r,t,e,n){return sr(r,t,2,Nt(r,t+1,n))}function Kc(r,t,e,n){return sr(r,t,3,Rt(r,t+1,n))}function Gc(r,t,e,n){return sr(r,t,5,Pt(r,t+1,n))}function jc(r,t,e,n){let o=Dt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return sr(r,t,9,o)}function Zc(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return sr(r,t,1,1/0)}function Rn(r,t){gt(r,p.map.majorEncoded,t.value)}Rn.compareTokens=Mt.compareTokens;Rn.encodedSize=function(t){return gt.encodedSize(t.value)};function Wc(r,t,e,n){return new C(p.tag,e,1)}function Yc(r,t,e,n){return new C(p.tag,Nt(r,t+1,n),2)}function Xc(r,t,e,n){return new C(p.tag,Rt(r,t+1,n),3)}function Qc(r,t,e,n){return new C(p.tag,Pt(r,t+1,n),5)}function Jc(r,t,e,n){return new C(p.tag,Dt(r,t+1,n),9)}function Pn(r,t){gt(r,p.tag.majorEncoded,t.value)}Pn.compareTokens=Mt.compareTokens;Pn.encodedSize=function(t){return gt.encodedSize(t.value)};var ad=20,ud=21,fd=22,ld=23;function ta(r,t,e,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new C(p.null,null,1):new C(p.undefined,void 0,1)}function ea(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new C(p.break,void 0,1)}function di(r,t,e){if(e){if(e.allowNaN===!1&&Number.isNaN(r))throw new Error(`${M} NaN values are not supported`);if(e.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new C(p.float,r,t)}function ra(r,t,e,n){return di(hi(r,t+1),3,n)}function na(r,t,e,n){return di(pi(r,t+1),5,n)}function oa(r,t,e,n){return di(aa(r,t+1),9,n)}function Dn(r,t,e){let n=t.value;if(n===!1)r.push([p.float.majorEncoded|ad]);else if(n===!0)r.push([p.float.majorEncoded|ud]);else if(n===null)r.push([p.float.majorEncoded|fd]);else if(n===void 0)r.push([p.float.majorEncoded|ld]);else{let o,i=!1;(!e||e.float64!==!0)&&(sa(n),o=hi(Kt,1),n===o||Number.isNaN(n)?(Kt[0]=249,r.push(Kt.slice(0,3)),i=!0):(ca(n),o=pi(Kt,1),n===o&&(Kt[0]=250,r.push(Kt.slice(0,5)),i=!0))),i||(dd(n),o=aa(Kt,1),Kt[0]=251,r.push(Kt.slice(0,9)))}}Dn.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){sa(n);let o=hi(Kt,1);if(n===o||Number.isNaN(n))return 3;if(ca(n),o=pi(Kt,1),n===o)return 5}return 9};var ia=new ArrayBuffer(9),Ot=new DataView(ia,1),Kt=new Uint8Array(ia,0);function sa(r){if(r===1/0)Ot.setUint16(0,31744,!1);else if(r===-1/0)Ot.setUint16(0,64512,!1);else if(Number.isNaN(r))Ot.setUint16(0,32256,!1);else{Ot.setFloat32(0,r);let t=Ot.getUint32(0),e=(t&2139095040)>>23,n=t&8388607;if(e===255)Ot.setUint16(0,31744,!1);else if(e===0)Ot.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=e-127;o<-24?Ot.setUint16(0,0):o<-14?Ot.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ot.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function hi(r,t){if(r.length-t<2)throw new Error(`${M} not enough data for float16`);let e=(r[t]<<8)+r[t+1];if(e===31744)return 1/0;if(e===64512)return-1/0;if(e===32256)return NaN;let n=e>>10&31,o=e&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,e&32768?-i:i}function ca(r){Ot.setFloat32(0,r,!1)}function pi(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 dd(r){Ot.setFloat64(0,r,!1)}function aa(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)}Dn.compareTokens=Mt.compareTokens;function K(r,t,e){throw new Error(`${M} encountered invalid minor (${e}) for major ${r[t]>>>5}`)}function Mn(r){return()=>{throw new Error(`${M} ${r}`)}}var S=[];for(let r=0;r<=23;r++)S[r]=K;S[24]=yc;S[25]=xc;S[26]=bc;S[27]=wc;S[28]=K;S[29]=K;S[30]=K;S[31]=K;for(let r=32;r<=55;r++)S[r]=K;S[56]=Ec;S[57]=vc;S[58]=Sc;S[59]=Bc;S[60]=K;S[61]=K;S[62]=K;S[63]=K;for(let r=64;r<=87;r++)S[r]=Ic;S[88]=Cc;S[89]=kc;S[90]=Tc;S[91]=Uc;S[92]=K;S[93]=K;S[94]=K;S[95]=Mn("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)S[r]=Lc;S[120]=_c;S[121]=Nc;S[122]=Rc;S[123]=Pc;S[124]=K;S[125]=K;S[126]=K;S[127]=Mn("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)S[r]=Mc;S[152]=Oc;S[153]=Fc;S[154]=$c;S[155]=Vc;S[156]=K;S[157]=K;S[158]=K;S[159]=zc;for(let r=160;r<=183;r++)S[r]=Hc;S[184]=qc;S[185]=Kc;S[186]=Gc;S[187]=jc;S[188]=K;S[189]=K;S[190]=K;S[191]=Zc;for(let r=192;r<=215;r++)S[r]=Wc;S[216]=Yc;S[217]=Xc;S[218]=Qc;S[219]=Jc;S[220]=K;S[221]=K;S[222]=K;S[223]=K;for(let r=224;r<=243;r++)S[r]=Mn("simple values are not supported");S[244]=K;S[245]=K;S[246]=K;S[247]=ta;S[248]=Mn("simple values are not supported");S[249]=ra;S[250]=na;S[251]=oa;S[252]=K;S[253]=K;S[254]=K;S[255]=ea;var Gt=[];for(let r=0;r<24;r++)Gt[r]=new C(p.uint,r,1);for(let r=-1;r>=-24;r--)Gt[31-r]=new C(p.negint,r,1);Gt[64]=new C(p.bytes,new Uint8Array(0),1);Gt[96]=new C(p.string,"",1);Gt[128]=new C(p.array,0,1);Gt[160]=new C(p.map,0,1);Gt[244]=new C(p.false,!1,1);Gt[245]=new C(p.true,!0,1);Gt[246]=new C(p.null,null,1);function ua(r){switch(r.type){case p.false:return Xt([244]);case p.true:return Xt([245]);case p.null:return Xt([246]);case p.bytes:return r.value.length?void 0:Xt([64]);case p.string:return r.value===""?Xt([96]):void 0;case p.array:return r.value===0?Xt([128]):void 0;case p.map:return r.value===0?Xt([160]):void 0;case p.uint:return r.value<24?Xt([Number(r.value)]):void 0;case p.negint:if(r.value>=-24)return Xt([31-Number(r.value)])}}var pd={float64:!1,mapSorter:yd,quickEncodeToken:ua};function md(){let r=[];return r[p.uint.major]=Mt,r[p.negint.major]=Ln,r[p.bytes.major]=or,r[p.string.major]=Dc,r[p.array.major]=Nn,r[p.map.major]=Rn,r[p.tag.major]=Pn,r[p.float.major]=Dn,r}var fa=md(),mi=new $r,Fn=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)}},we={null:new C(p.null,null),undefined:new C(p.undefined,void 0),true:new C(p.true,!0),false:new C(p.false,!1),emptyArray:new C(p.array,0),emptyMap:new C(p.map,0)},Ee={number(r,t,e,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new C(p.float,r):r>=0?new C(p.uint,r):new C(p.negint,r)},bigint(r,t,e,n){return r>=BigInt(0)?new C(p.uint,r):new C(p.negint,r)},Uint8Array(r,t,e,n){return new C(p.bytes,r)},string(r,t,e,n){return new C(p.string,r)},boolean(r,t,e,n){return r?we.true:we.false},null(r,t,e,n){return we.null},undefined(r,t,e,n){return we.undefined},ArrayBuffer(r,t,e,n){return new C(p.bytes,new Uint8Array(r))},DataView(r,t,e,n){return new C(p.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,t,e,n){if(!r.length)return e.addBreakTokens===!0?[we.emptyArray,new C(p.break)]:we.emptyArray;n=Fn.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=On(s,e,n);return e.addBreakTokens?[new C(p.array,r.length),o,new C(p.break)]:[new C(p.array,r.length),o]},Object(r,t,e,n){let o=t!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return e.addBreakTokens===!0?[we.emptyMap,new C(p.break)]:we.emptyMap;n=Fn.createCheck(n,r);let c=[],a=0;for(let f of i)c[a++]=[On(f,e,n),On(o?r.get(f):r[f],e,n)];return gd(c,e),e.addBreakTokens?[new C(p.map,s),c,new C(p.break)]:[new C(p.map,s),c]}};Ee.Map=Ee.Object;Ee.Buffer=Ee.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ee[`${r}Array`]=Ee.DataView;function On(r,t={},e){let n=ac(r),o=t&&t.typeEncoders&&t.typeEncoders[n]||Ee[n];if(typeof o=="function"){let s=o(r,n,t,e);if(s!=null)return s}let i=Ee[n];if(!i)throw new Error(`${fi} unsupported type: ${n}`);return i(r,n,t,e)}function gd(r,t){t.mapSorter&&r.sort(t.mapSorter)}function yd(r,t){let e=Array.isArray(r[0])?r[0][0]:r[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(e.type!==n.type)return e.type.compare(n.type);let o=e.type.major,i=fa[o].compareTokens(e,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function la(r,t,e,n){if(Array.isArray(t))for(let o of t)la(r,o,e,n);else e[t.type.major](r,t,n)}function xd(r,t,e){let n=On(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 $r(s);if(i(c,n,e),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return ui(c.chunks[0])}}return mi.reset(),la(mi,n,t,e),mi.toBytes(!0)}function W(r,t){return t=Object.assign({},pd,t),xd(r,fa,t)}var bd={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},$n=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=Gt[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}},qr=Symbol.for("DONE"),Vn=Symbol.for("BREAK");function wd(r,t,e){let n=[];for(let o=0;o<r.value;o++){let i=cr(t,e);if(i===Vn){if(r.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===qr)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Ed(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=cr(t,e);if(c===Vn){if(r.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(c===qr)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=cr(t,e);if(a===qr)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 cr(r,t){if(r.done())return qr;let e=r.next();if(e.type===p.break)return Vn;if(e.type.terminal)return e.value;if(e.type===p.array)return wd(e,r,t);if(e.type===p.map)return Ed(e,r,t);if(e.type===p.tag){if(t.tags&&typeof t.tags[e.value]=="function"){let n=cr(r,t);return t.tags[e.value](n)}throw new Error(`${M} tag not supported (${e.value})`)}throw new Error("unsupported")}function da(r,t){if(!(r instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},bd,t);let e=t.tokenizer||new $n(r,t),n=cr(e,t);if(n===qr)throw new Error(`${M} did not find any content to decode`);if(n===Vn)throw new Error(`${M} got unexpected break`);return[n,r.subarray(e.pos())]}function Y(r,t){let[e,n]=da(r,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return e}var vd={type:1026,canEncode:r=>r===!0||r===!1,encode:r=>W(r),decode:r=>Y(r)},ha=vd;var Sd={type:1027,canEncode:r=>typeof r=="number"&&!isNaN(r),encode:r=>W(r),decode:r=>Y(r)},pa=Sd;var Ad={type:1028,canEncode:r=>typeof r=="string",encode:r=>W(r),decode:r=>Y(r)},ma=Ad;var Bd={type:1029,canEncode:r=>Array.isArray(r),encode:(r,t,e,n)=>W(r.map(o=>t.toValue(o,e,n))),decode:(r,t,e,n)=>Y(r).map(o=>t.fromValue(o,e,n))},ga=Bd;var Id={type:1030,canEncode:r=>typeof r=="function",encode:(r,t,e,n)=>{let o=je();return n?.callbacks.set(o,{context:e,fn:r}),W(o)},decode:(r,t,e,n)=>async(...o)=>new Promise((i,s)=>{let c=Y(r),a=je(),f={scope:a,result:Vt(),callbacks:new Map,children:new Map,parents:[...n.parents,n.scope],abortControllers:[],abortSignals:[]};n.children.set(a,f),o=o.map(l=>t.toValue(l,null,f));let u=un(f.abortSignals);u.addEventListener("abort",()=>{e.push(Bt.encode({type:q.abortCallbackInvocation,message:er.encode({scope:a,parents:f.parents})}))}),e.push(Bt.encode({type:q.invokeCallback,message:tr.encode({scope:a,parents:f.parents,callback:c,args:o})})),f.result.promise.then(l=>{i(l)},l=>{s(l)}).finally(()=>{n.children.delete(a),u.clear()})})},ya=Id;var Cd={type:1031,canEncode:r=>r.toString()==="NaN"&&isNaN(r),decode:()=>NaN},xa=Cd;var kd={type:1032,canEncode:r=>r instanceof Error,encode:r=>W({message:r.message,name:r.name,code:r.code,type:r.type,stack:r.stack}),decode:r=>{let t=Y(r),e=new Error(t.message);return e.name=t.name,e.stack=t.stack,e.code=t.code,e.type=t.type,e}},ba=kd;var Td={type:1033,canEncode:r=>Array.isArray(r),encode:(r,t,e,n)=>{throw new Error("Promises are not supported")},decode:(r,t,e,n)=>{throw new Error("Promises are not supported")}},wa=Td;var Ea=["__defineGetter__","__defineSetter__","hasOwnProperty","__lookupGetter__","__lookupSetter__","isPrototypeOf","propertyIsEnumerable","toString","valueOf","__proto__","toLocaleString","constructor"],Ud={type:2147483647,canEncode:r=>typeof r=="object",encode:(r,t,e,n)=>{let o={};for(let i in r)Ea.includes(i)||Object.hasOwn(r,i)&&(o[i]=r[i]);for(let i of Object.getOwnPropertyNames(Object.getPrototypeOf(r)))Ea.includes(i)||(o[i]=r[i]);return W([...Object.entries(o)].map(([i,s])=>[t.toValue(i,r,n),t.toValue(s,r,n)]))},decode:(r,t,e,n)=>{let o={};return Y(r).forEach(([s,c])=>{o[t.fromValue(s,e,n)]=t.fromValue(c,e,n)}),o}},Kr=Ud;var Ld={type:1034,canEncode:r=>typeof r.next=="function"&&typeof r.throw=="function"&&typeof r.return=="function",encode:(r,t,e,n)=>Kr.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=Kr.decode(r,t,e,n);return o[Symbol.asyncIterator]=()=>o,o}},va=Ld;var _d={type:1035,canEncode:r=>typeof r=="bigint",encode:r=>W(r),decode:r=>BigInt(Y(r))},Sa=_d;var Nd={type:1036,canEncode:r=>r instanceof Map,encode:(r,t,e,n)=>W([...r.entries()].map(([o,i])=>[t.toValue(o,e,n),t.toValue(i,e,n)])),decode:(r,t,e,n)=>{let o=new Map;return Y(r).forEach(([s,c])=>{let a=t.fromValue(s,e,n),f=t.fromValue(c,e,n);o.set(a,f)}),o}},Aa=Nd;var Rd={type:1037,canEncode:r=>r instanceof Set,encode:(r,t,e,n)=>W([...r.values()].map(o=>t.toValue(o,e,n))),decode:(r,t,e,n)=>{let o=new Set;return Y(r).forEach(s=>{o.add(t.fromValue(s,e,n))}),o}},Ba=Rd;var Pd={type:1038,canEncode:r=>r instanceof Uint8Array,encode:r=>r,decode:r=>r},Ia=Pd;var Dd={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}},Ca=Dd;var Md={type:1040,canEncode:r=>r instanceof Date,encode:r=>W(r.toString()),decode:r=>new Date(Y(r))},ka=Md;var Od={type:1041,canEncode:r=>r instanceof RegExp,encode:r=>W({source:r.source,flags:r.flags}),decode:r=>{let{source:t,flags:e}=Y(r);return new RegExp(t,e)}},Ta=Od;var Ua=[sc,cc,ha,pa,ma,ga,ya,xa,ba,wa,va,Sa,Aa,Ba,Ia,Ca,ka,Ta,Kr];var zn=class{transformersMap;transformersList;constructor(t){this.transformersList=[...Ua,...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 Ar(`Unsupported value type "${t}"`)}fromValue(t,e,n){let o=this.transformersMap[t.type];if(o==null)throw new Ar(`Unsupported value type "${t.type}"`);return o.decode(t.value??new Uint8Array(0),this,e,n)}};function Fd(r){return r.isScope===!0}function $d(r){return r.type===q.invokeMethod||r.type===q.invokeGeneratorMethod||r.type===q.invokeCallback}var gi=class{source;output;targets;invocations;values;messageHandlers;constructor(t){this.output=me(),this.source=pn(this.output),this.targets=new Map,this.invocations=new Map,this.values=new zn(t),this.sink=this.sink.bind(this),this.messageHandlers={[q.invokeMethod]:{decoder:Re,handler:this.handleInvokeMethod.bind(this)},[q.invokeGeneratorMethod]:{decoder:Re,handler:this.handleInvokeGeneratorMethod.bind(this)},[q.abortMethodInvocation]:{decoder:Dr,handler:this.handleAbortMethod.bind(this),isScope:!0},[q.methodResolved]:{decoder:Je,handler:this.handleMethodResolved.bind(this),isScope:!0},[q.methodRejected]:{decoder:Mr,handler:this.handleMethodRejected.bind(this),isScope:!0,isError:!0},[q.invokeCallback]:{decoder:tr,handler:this.handleInvokeCallback.bind(this),isScope:!0},[q.abortCallbackInvocation]:{decoder:er,handler:this.handleAbortCallback.bind(this),isScope:!0},[q.callbackResolved]:{decoder:Or,handler:this.handleCallbackResolved.bind(this),isScope:!0},[q.callbackRejected]:{decoder:Fr,handler:this.handleCallbackRejected.bind(this),isScope:!0,isError:!0}}}async sink(t){for await(let e of Sr(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(Fd(o))try{s=ic(i,this.invocations)}catch{continue}o.handler(i,s).catch(c=>{$d(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(Bt.encode({type:q.callbackRejected,message:Fr.encode({scope:t.scope,parents:t.parents,error:this.values.toValue(e)})})):this.output.push(Bt.encode({type:q.methodRejected,message:Mr.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 Br;let e=new Map,n=new Map,o={scope:t.scope,result:Vt(),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:q.methodResolved,message:Je.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 Br;let e=new Map,n=new Map,o={scope:t.scope,result:Vt(),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 En(`${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 f=await s.throw(a);return f.done===!0&&this.invocations.delete(t.scope),f}catch(f){throw this.invocations.delete(t.scope),f}},return:async a=>{let f=await s.return(a);return f.done===!0&&this.invocations.delete(t.scope),f},[Symbol.asyncIterator]:()=>c};this.output.push(Bt.encode({type:q.methodResolved,message:Je.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 bn(`"${t.substring(0,t.length-5)}" was not a function`):new xn(`Could not find "${t}" on target`);if(typeof n!="function")throw new Ir("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 Sn;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:q.callbackResolved,message:Or.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 f(){return a==null&&(a=new Promise((l,h)=>{let w=je(),E={scope:w,result:Vt(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(w,E),n.output.push(Bt.encode({type:q.invokeMethod,message:Re.encode({scope:w,path:t,args:s.map(d=>n.values.toValue(d,null,E))})}));let m=un(E.abortSignals);m.addEventListener("abort",()=>{n.output.push(Bt.encode({type:q.abortMethodInvocation,message:Dr.encode({scope:w})}))}),E.result.promise.then(d=>{l(d)},d=>{h(d)}).finally(()=>{n.invocations.delete(w),m.clear()})})),a}function u(){if(c==null){let l=je(),h={scope:l,result:Vt(),callbacks:new Map,children:new Map,parents:[],abortControllers:[],abortSignals:[]};n.invocations.set(l,h),n.output.push(Bt.encode({type:q.invokeGeneratorMethod,message:Re.encode({scope:l,path:t,args:s.map(E=>n.values.toValue(E,null,h))})}));let w;c={async next(){if(w!=null)throw w;let m=await(await h.result.promise).next();return m.done===!0&&n.invocations.delete(l),m},async throw(E){if(w!=null)throw w;try{let d=await(await h.result.promise).throw(E);return d.done===!0&&n.invocations.delete(l),d}catch(m){throw n.invocations.delete(l),w=E,m}},async return(E){if(w!=null)throw w;let d=await(await h.result.promise).return(E);return d.done===!0&&n.invocations.delete(l),d},[Symbol.asyncIterator]:()=>c}}return c}return new Proxy(e,{get(l,h,w){if(h==="then")return f().then.bind(a);if(h==="catch")return f().catch.bind(a);if(h==="finally")return f().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 Ir(`Property ${h.toString()} was not used as a promise or async generator`)}})}})}};function La(r){return new gi(r)}var _a={type:4096,canEncode:r=>r.code!=null&&r.version!=null&&r.multihash!=null&&r["/"]!=null,encode:r=>r.bytes,decode:r=>mt.decode(r)};var Gr=class extends Event{type;detail;constructor(t,e){super(t),this.type=t,this.detail=e}};var Na={type:4099,canEncode:r=>r instanceof Gr,encode:(r,t,e,n)=>W({type:r.type,detail:t.toValue(r.detail,e,n)}),decode:(r,t,e,n)=>{let{type:o,detail:i}=Y(r);return new Gr(o,t.fromValue(i,e,n))}};function dt(r,t="utf8"){let e=In[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Hn=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",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let h=Number.parseInt(l,t);if(!Number.isNaN(h))return h});if(u===void 0)break;if(i*=t,i+=u,i>f||(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 Ra=45,Vd=15,ar=new Hn;function yi(r){if(!(r.length>Vd))return ar.new(r).parseWith(()=>ar.readIPv4Addr())}function xi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ra))return ar.new(r).parseWith(()=>ar.readIPv6Addr())}function qn(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ra))return ar.new(r).parseWith(()=>ar.readIPAddr())}var pb=parseInt("0xFFFF",16),mb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Ma(r){return!!yi(r)}function Oa(r){return!!xi(r)}function Kn(r){return!!qn(r)}var Fa=Ma,Gd=Oa,bi=function(r){let t=0;if(r=r.toString().trim(),Fa(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Gd(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=Fa(e[n]),s;i&&(s=bi(e[n]),e[n]=dt(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,dt(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")},$a=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 ur={},wi={},Zd=[[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"]];Zd.forEach(r=>{let t=Wd(...r);wi[t.code]=t,ur[t.name]=t});function Wd(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function X(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(ur[r]!=null)return ur[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Qb=X("ip4"),Jb=X("ip6"),tw=X("ipcidr");function Ai(r,t){switch(X(r).code){case 4:case 41:return Xd(t);case 42:return Si(t);case 6:case 273:case 33:case 132:return Ha(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Si(t);case 421:return eh(t);case 444:return za(t);case 445:return za(t);case 466:return th(t);case 481:return globalThis.encodeURIComponent(Si(t));default:return dt(t,"base16")}}function Bi(r,t){switch(X(r).code){case 4:return Va(t);case 41:return Va(t);case 42:return vi(t);case 6:case 273:case 33:case 132:return Ii(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return vi(t);case 421:return Qd(t);case 444:return rh(t);case 445:return nh(t);case 466:return Jd(t);case 481:return vi(globalThis.decodeURIComponent(t));default:return be(t,"base16")}}var Ei=Object.values(_r).map(r=>r.decoder),Yd=function(){let r=Ei[0].or(Ei[1]);return Ei.slice(2).forEach(t=>r=r.or(t)),r}();function Va(r){if(!Kn(r))throw new Error("invalid ip address");return bi(r)}function Xd(r){let t=$a(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Kn(t))throw new Error("invalid ip address");return t}function Ii(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Ha(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function vi(r){let t=be(r),e=Uint8Array.from(ge(t.length));return Lt([e,t],e.length+t.length)}function Si(r){let t=ee(r);if(r=r.slice(ft(t)),r.length!==t)throw new Error("inconsistent lengths");return dt(r)}function Qd(r){let t;r[0]==="Q"||r[0]==="1"?t=re(J.decode(`z${r}`)).bytes:t=mt.parse(r).multihash.bytes;let e=Uint8Array.from(ge(t.length));return Lt([e,t],e.length+t.length)}function Jd(r){let t=Yd.decode(r),e=Uint8Array.from(ge(t.length));return Lt([e,t],e.length+t.length)}function th(r){let t=ee(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+dt(e,"base64url")}function eh(r){let t=ee(r),e=r.slice(ft(t));if(e.length!==t)throw new Error("inconsistent lengths");return dt(e,"base58btc")}function rh(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=$t.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=Ii(n);return Lt([e,o],e.length+o.length)}function nh(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=$t.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=Ii(n);return Lt([e,o],e.length+o.length)}function za(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=dt(t,"base32"),o=Ha(e);return`${n}:${o}`}function qa(r){r=Ci(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=X(s);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(i++,i>=o.length)throw Ga("invalid address: "+r);if(c.path===!0){n=Ci(o.slice(i).join("/")),t.push([c.code,Bi(c.code,n)]),e.push([c.code,n]);break}let a=Bi(c.code,o[i]);t.push([c.code,a]),e.push([c.code,Ai(c.code,a)])}return{string:Ka(e),bytes:Ti(t),tuples:t,stringTuples:e,path:n}}function ki(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=ee(r,o),s=ft(i),c=X(i),a=oh(c,r.slice(o+s));if(a===0){t.push([i]),e.push([i]),o+=s;continue}let f=r.slice(o+s,o+s+a);if(o+=a+s,o>r.length)throw Ga("Invalid address Uint8Array: "+dt(r,"base16"));t.push([i,f]);let u=Ai(i,f);if(e.push([i,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Ka(e),tuples:t,stringTuples:e,path:n}}function Ka(r){let t=[];return r.map(e=>{let n=X(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Ci(t.join("/"))}function Ti(r){return Lt(r.map(t=>{let e=X(t[0]),n=Uint8Array.from(ge(e.code));return t.length>1&&t[1]!=null&&(n=Lt([n,t[1]])),n}))}function oh(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=ee(t instanceof Uint8Array?t:Uint8Array.from(t));return e+ft(e)}}function Ci(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Ga(r){return new Error("Error parsing address: "+r)}var ih=Symbol.for("nodejs.util.inspect.custom"),Li=Symbol.for("@multiformats/js-multiaddr/multiaddr"),sh=[X("dns").code,X("dns4").code,X("dns6").code,X("dnsaddr").code],Ui=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Gn=class r{bytes;#e;#t;#r;#n;[Li]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=ki(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=qa(t)}else if(jn(t))e=ki(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=X("tcp"),c=X("udp"),a=X("ip4"),f=X("ip6"),u=X("dns6"),l=X("ip6zone");for(let[w,E]of this.stringTuples())w===l.code&&(i=`%${E??""}`),sh.includes(w)&&(e=s.name,o=443,n=`${E??""}${i}`,t=w===u.code?6:4),(w===s.code||w===c.code)&&(e=X(w).name,o=parseInt(E??"")),(w===a.code||w===f.code)&&(e=X(w).name,n=`${E??""}${i}`,t=w===f.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({},X(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>X(t).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Ti(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===ur.p2p.code&&t.push([n,o]),n===ur["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?dt(J.decode(`z${n}`),"base58btc"):dt(mt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return Ht(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=ja.get(e.name);if(n==null)throw new Ui(`no available resolver for ${e.name}`);return(await n(this,t)).map(i=>De(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)}[ih](){return`Multiaddr(${this.#e})`}};var ja=new Map;function jn(r){return!!r?.[Li]}function De(r){return new Gn(r)}var Za={type:4097,canEncode:r=>jn(r),encode:r=>r.bytes,decode:r=>De(r)};function Wa(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function ch(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function fr(r,...t){if(!ch(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function Ya(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Wa(r.outputLen),Wa(r.blockLen)}function lr(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 Xa(r,t){fr(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Me=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Zn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),jt=(r,t)=>r<<32-t|r>>>t;var Uw=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Qa(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function jr(r){return typeof r=="string"&&(r=Qa(r)),fr(r),r}function _i(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];fr(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 dr=class{clone(){return this._cloneInto()}},Lw={}.toString;function Wn(r){let t=n=>r().update(jr(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Yn(r=32){if(Me&&typeof Me.getRandomValues=="function")return Me.getRandomValues(new Uint8Array(r));if(Me&&typeof Me.randomBytes=="function")return Me.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function ah(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,f=n?0:4;r.setUint32(t+a,s,n),r.setUint32(t+f,c,n)}var Ja=(r,t,e)=>r&t^~r&e,tu=(r,t,e)=>r&t^r&e^t&e,hr=class extends dr{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=Zn(this.buffer)}update(t){lr(this);let{view:e,buffer:n,blockLen:o}=this;t=jr(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=Zn(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){lr(this),Xa(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 l=s;l<o;l++)e[l]=0;ah(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=Zn(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=a/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)c.setUint32(4*l,u[l],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 Xn=BigInt(4294967295),Ni=BigInt(32);function eu(r,t=!1){return t?{h:Number(r&Xn),l:Number(r>>Ni&Xn)}:{h:Number(r>>Ni&Xn)|0,l:Number(r&Xn)|0}}function uh(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}=eu(r[o],t);[e[o],n[o]]=[i,s]}return[e,n]}var fh=(r,t)=>BigInt(r>>>0)<<Ni|BigInt(t>>>0),lh=(r,t,e)=>r>>>e,dh=(r,t,e)=>r<<32-e|t>>>e,hh=(r,t,e)=>r>>>e|t<<32-e,ph=(r,t,e)=>r<<32-e|t>>>e,mh=(r,t,e)=>r<<64-e|t>>>e-32,gh=(r,t,e)=>r>>>e-32|t<<64-e,yh=(r,t)=>t,xh=(r,t)=>r,bh=(r,t,e)=>r<<e|t>>>32-e,wh=(r,t,e)=>t<<e|r>>>32-e,Eh=(r,t,e)=>t<<e-32|r>>>64-e,vh=(r,t,e)=>r<<e-32|t>>>64-e;function Sh(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Ah=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Bh=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ih=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Ch=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,kh=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Th=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var Uh={fromBig:eu,split:uh,toBig:fh,shrSH:lh,shrSL:dh,rotrSH:hh,rotrSL:ph,rotrBH:mh,rotrBL:gh,rotr32H:yh,rotr32L:xh,rotlSH:bh,rotlSL:wh,rotlBH:Eh,rotlBL:vh,add:Sh,add3L:Ah,add3H:Bh,add4L:Ih,add4H:Ch,add5H:Th,add5L:kh},O=Uh;var[Lh,_h]=O.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),ve=new Uint32Array(80),Se=new Uint32Array(80),Ri=class extends hr{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:f,El:u,Fh:l,Fl:h,Gh:w,Gl:E,Hh:m,Hl:d}=this;return[t,e,n,o,i,s,c,a,f,u,l,h,w,E,m,d]}set(t,e,n,o,i,s,c,a,f,u,l,h,w,E,m,d){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=h|0,this.Gh=w|0,this.Gl=E|0,this.Hh=m|0,this.Hl=d|0}process(t,e){for(let y=0;y<16;y++,e+=4)ve[y]=t.getUint32(e),Se[y]=t.getUint32(e+=4);for(let y=16;y<80;y++){let B=ve[y-15]|0,R=Se[y-15]|0,L=O.rotrSH(B,R,1)^O.rotrSH(B,R,8)^O.shrSH(B,R,7),T=O.rotrSL(B,R,1)^O.rotrSL(B,R,8)^O.shrSL(B,R,7),k=ve[y-2]|0,_=Se[y-2]|0,ot=O.rotrSH(k,_,19)^O.rotrBH(k,_,61)^O.shrSH(k,_,6),H=O.rotrSL(k,_,19)^O.rotrBL(k,_,61)^O.shrSL(k,_,6),F=O.add4L(T,H,Se[y-7],Se[y-16]),it=O.add4H(F,L,ot,ve[y-7],ve[y-16]);ve[y]=it|0,Se[y]=F|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:f,Dl:u,Eh:l,El:h,Fh:w,Fl:E,Gh:m,Gl:d,Hh:x,Hl:A}=this;for(let y=0;y<80;y++){let B=O.rotrSH(l,h,14)^O.rotrSH(l,h,18)^O.rotrBH(l,h,41),R=O.rotrSL(l,h,14)^O.rotrSL(l,h,18)^O.rotrBL(l,h,41),L=l&w^~l&m,T=h&E^~h&d,k=O.add5L(A,R,T,_h[y],Se[y]),_=O.add5H(k,x,B,L,Lh[y],ve[y]),ot=k|0,H=O.rotrSH(n,o,28)^O.rotrBH(n,o,34)^O.rotrBH(n,o,39),F=O.rotrSL(n,o,28)^O.rotrBL(n,o,34)^O.rotrBL(n,o,39),it=n&i^n&c^i&c,I=o&s^o&a^s&a;x=m|0,A=d|0,m=w|0,d=E|0,w=l|0,E=h|0,{h:l,l:h}=O.add(f|0,u|0,_|0,ot|0),f=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let U=O.add3L(ot,F,I);n=O.add3H(U,_,H,it),o=U|0}({h:n,l:o}=O.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=O.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=O.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:f,l:u}=O.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:h}=O.add(this.Eh|0,this.El|0,l|0,h|0),{h:w,l:E}=O.add(this.Fh|0,this.Fl|0,w|0,E|0),{h:m,l:d}=O.add(this.Gh|0,this.Gl|0,m|0,d|0),{h:x,l:A}=O.add(this.Hh|0,this.Hl|0,x|0,A|0),this.set(n,o,i,s,c,a,f,u,l,h,w,E,m,d,x,A)}roundClean(){ve.fill(0),Se.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 ru=Wn(()=>new Ri);var Jn={};Ct(Jn,{aInRange:()=>Tt,abool:()=>Zt,abytes:()=>pr,bitGet:()=>Oh,bitLen:()=>Fi,bitMask:()=>Wr,bitSet:()=>Fh,bytesToHex:()=>ce,bytesToNumberBE:()=>ae,bytesToNumberLE:()=>Be,concatBytes:()=>ue,createHmacDrbg:()=>$i,ensureBytes:()=>nt,equalBytes:()=>Dh,hexToBytes:()=>Fe,hexToNumber:()=>Oi,inRange:()=>Zr,isBytes:()=>Ae,memoized:()=>Ve,notImplemented:()=>Vh,numberToBytesBE:()=>Ie,numberToBytesLE:()=>$e,numberToHexUnpadded:()=>Oe,numberToVarBytesBE:()=>Ph,utf8ToBytes:()=>Mh,validateObject:()=>Qt});var Mi=BigInt(0),Qn=BigInt(1),Nh=BigInt(2);function Ae(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function pr(r){if(!Ae(r))throw new Error("Uint8Array expected")}function Zt(r,t){if(typeof t!="boolean")throw new Error(`${r} must be valid boolean, got "${t}".`)}var Rh=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function ce(r){pr(r);let t="";for(let e=0;e<r.length;e++)t+=Rh[r[e]];return t}function Oe(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function Oi(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var se={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function nu(r){if(r>=se._0&&r<=se._9)return r-se._0;if(r>=se._A&&r<=se._F)return r-(se._A-10);if(r>=se._a&&r<=se._f)return r-(se._a-10)}function Fe(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,i=0;o<e;o++,i+=2){let s=nu(r.charCodeAt(i)),c=nu(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 ae(r){return Oi(ce(r))}function Be(r){return pr(r),Oi(ce(Uint8Array.from(r).reverse()))}function Ie(r,t){return Fe(r.toString(16).padStart(t*2,"0"))}function $e(r,t){return Ie(r,t).reverse()}function Ph(r){return Fe(Oe(r))}function nt(r,t,e){let n;if(typeof t=="string")try{n=Fe(t)}catch(i){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${i}`)}else if(Ae(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(`${r} expected ${e} bytes, got ${o}`);return n}function ue(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];pr(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 Dh(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 Mh(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Pi=r=>typeof r=="bigint"&&Mi<=r;function Zr(r,t,e){return Pi(r)&&Pi(t)&&Pi(e)&&t<=r&&r<e}function Tt(r,t,e,n){if(!Zr(t,e,n))throw new Error(`expected valid ${r}: ${e} <= n < ${n}, got ${typeof t} ${t}`)}function Fi(r){let t;for(t=0;r>Mi;r>>=Qn,t+=1);return t}function Oh(r,t){return r>>BigInt(t)&Qn}function Fh(r,t,e){return r|(e?Qn:Mi)<<BigInt(t)}var Wr=r=>(Nh<<BigInt(r-1))-Qn,Di=r=>new Uint8Array(r),ou=r=>Uint8Array.from(r);function $i(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=Di(r),o=Di(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},c=(...l)=>e(o,n,...l),a=(l=Di())=>{o=c(ou([0]),l),n=c(),l.length!==0&&(o=c(ou([1]),l),n=c())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,h=[];for(;l<t;){n=c();let w=n.slice();h.push(w),l+=n.length}return ue(...h)};return(l,h)=>{s(),a(l);let w;for(;!(w=h(f()));)a();return s(),w}}var $h={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"||Ae(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 Qt(r,t,e={}){let n=(o,i,s)=>{let c=$h[i];if(typeof c!="function")throw new Error(`Invalid validator "${i}", expected function`);let a=r[o];if(!(s&&a===void 0)&&!c(a,r))throw new Error(`Invalid param ${String(o)}=${a} (${typeof a}), expected ${i}`)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}var Vh=()=>{throw new Error("not implemented")};function Ve(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 ct=BigInt(0),tt=BigInt(1),ze=BigInt(2),zh=BigInt(3),Vi=BigInt(4),iu=BigInt(5),su=BigInt(8),Hh=BigInt(9),qh=BigInt(16);function Z(r,t){let e=r%t;return e>=ct?e:t+e}function Kh(r,t,e){if(e<=ct||t<ct)throw new Error("Expected power/modulo > 0");if(e===tt)return ct;let n=tt;for(;t>ct;)t&tt&&(n=n*r%e),r=r*r%e,t>>=tt;return n}function et(r,t,e){let n=r;for(;t-- >ct;)n*=n,n%=e;return n}function to(r,t){if(r===ct||t<=ct)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=Z(r,t),n=t,o=ct,i=tt,s=tt,c=ct;for(;e!==ct;){let f=n/e,u=n%e,l=o-s*f,h=i-c*f;n=e,e=u,o=s,i=c,s=l,c=h}if(n!==tt)throw new Error("invert: does not exist");return Z(o,t)}function Gh(r){let t=(r-tt)/ze,e,n,o;for(e=r-tt,n=0;e%ze===ct;e/=ze,n++);for(o=ze;o<r&&Kh(o,t,r)!==r-tt;o++);if(n===1){let s=(r+tt)/Vi;return function(a,f){let u=a.pow(f,s);if(!a.eql(a.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(e+tt)/ze;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let f=n,u=c.pow(c.mul(c.ONE,o),e),l=c.pow(a,i),h=c.pow(a,e);for(;!c.eql(h,c.ONE);){if(c.eql(h,c.ZERO))return c.ZERO;let w=1;for(let m=c.sqr(h);w<f&&!c.eql(m,c.ONE);w++)m=c.sqr(m);let E=c.pow(u,tt<<BigInt(f-w-1));u=c.sqr(E),l=c.mul(l,E),h=c.mul(h,u),f=w}return l}}function jh(r){if(r%Vi===zh){let t=(r+tt)/Vi;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%su===iu){let t=(r-iu)/su;return function(n,o){let i=n.mul(o,ze),s=n.pow(i,t),c=n.mul(o,s),a=n.mul(n.mul(c,ze),s),f=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%qh,Gh(r)}var cu=(r,t)=>(Z(r,t)&tt)===tt,Zh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function zi(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Zh.reduce((n,o)=>(n[o]="function",n),t);return Qt(r,e)}function Wh(r,t,e){if(e<ct)throw new Error("Expected power > 0");if(e===ct)return r.ONE;if(e===tt)return t;let n=r.ONE,o=t;for(;e>ct;)e&tt&&(n=r.mul(n,o)),o=r.sqr(o),e>>=tt;return n}function Yh(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 Hi(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Ce(r,t,e=!1,n={}){if(r<=ct)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Hi(r,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=jh(r),c=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:Wr(o),ZERO:ct,ONE:tt,create:a=>Z(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return ct<=a&&a<r},is0:a=>a===ct,isOdd:a=>(a&tt)===tt,neg:a=>Z(-a,r),eql:(a,f)=>a===f,sqr:a=>Z(a*a,r),add:(a,f)=>Z(a+f,r),sub:(a,f)=>Z(a-f,r),mul:(a,f)=>Z(a*f,r),pow:(a,f)=>Wh(c,a,f),div:(a,f)=>Z(a*to(f,r),r),sqrN:a=>a*a,addN:(a,f)=>a+f,subN:(a,f)=>a-f,mulN:(a,f)=>a*f,inv:a=>to(a,r),sqrt:n.sqrt||(a=>s(c,a)),invertBatch:a=>Yh(c,a),cmov:(a,f,u)=>u?f:a,toBytes:a=>e?$e(a,i):Ie(a,i),fromBytes:a=>{if(a.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${a.length}`);return e?Be(a):ae(a)}});return Object.freeze(c)}function au(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 qi(r){let t=au(r);return t+Math.ceil(t/2)}function uu(r,t,e=!1){let n=r.length,o=au(t),i=qi(t);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=e?ae(r):Be(r),c=Z(s,t-tt)+tt;return e?$e(c,o):Ie(c,o)}var Qh=BigInt(0),Ki=BigInt(1),Gi=new WeakMap,fu=new WeakMap;function eo(r,t){let e=(i,s)=>{let c=s.negate();return i?c:s},n=i=>{if(!Number.isSafeInteger(i)||i<=0||i>t)throw new Error(`Wrong window size=${i}, should be [1..${t}]`)},o=i=>{n(i);let s=Math.ceil(t/i)+1,c=2**(i-1);return{windows:s,windowSize:c}};return{constTimeNegate:e,unsafeLadder(i,s){let c=r.ZERO,a=i;for(;s>Qh;)s&Ki&&(c=c.add(a)),a=a.double(),s>>=Ki;return c},precomputeWindow(i,s){let{windows:c,windowSize:a}=o(s),f=[],u=i,l=u;for(let h=0;h<c;h++){l=u,f.push(l);for(let w=1;w<a;w++)l=l.add(u),f.push(l);u=l.double()}return f},wNAF(i,s,c){let{windows:a,windowSize:f}=o(i),u=r.ZERO,l=r.BASE,h=BigInt(2**i-1),w=2**i,E=BigInt(i);for(let m=0;m<a;m++){let d=m*f,x=Number(c&h);c>>=E,x>f&&(x-=w,c+=Ki);let A=d,y=d+Math.abs(x)-1,B=m%2!==0,R=x<0;x===0?l=l.add(e(B,s[A])):u=u.add(e(R,s[y]))}return{p:u,f:l}},wNAFCached(i,s,c){let a=fu.get(i)||1,f=Gi.get(i);return f||(f=this.precomputeWindow(i,a),a!==1&&Gi.set(i,c(f))),this.wNAF(a,f,s)},setWindowSize(i,s){n(s),fu.set(i,s),Gi.delete(i)}}}function ro(r,t,e,n){if(!Array.isArray(e)||!Array.isArray(n)||n.length!==e.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,l)=>{if(!t.isValid(u))throw new Error(`wrong scalar at index ${l}`)}),e.forEach((u,l)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${l}`)});let o=Fi(BigInt(e.length)),i=o>12?o-3:o>4?o-2:o?2:1,s=(1<<i)-1,c=new Array(s+1).fill(r.ZERO),a=Math.floor((t.BITS-1)/i)*i,f=r.ZERO;for(let u=a;u>=0;u-=i){c.fill(r.ZERO);for(let h=0;h<n.length;h++){let w=n[h],E=Number(w>>BigInt(u)&BigInt(s));c[E]=c[E].add(e[h])}let l=r.ZERO;for(let h=c.length-1,w=r.ZERO;h>0;h--)w=w.add(c[h]),l=l.add(w);if(f=f.add(l),u!==0)for(let h=0;h<i;h++)f=f.double()}return f}function Yr(r){return zi(r.Fp),Qt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Hi(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Wt=BigInt(0),Ut=BigInt(1),no=BigInt(2),Jh=BigInt(8),tp={zip215:!0};function ep(r){let t=Yr(r);return Qt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function lu(r){let t=ep(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,f=no<<BigInt(c*8)-Ut,u=e.create,l=Ce(t.n,t.nBitLength),h=t.uvRatio||((b,g)=>{try{return{isValid:!0,value:e.sqrt(b*e.inv(g))}}catch{return{isValid:!1,value:Wt}}}),w=t.adjustScalarBytes||(b=>b),E=t.domain||((b,g,v)=>{if(Zt("phflag",v),g.length||v)throw new Error("Contexts/pre-hash are not supported");return b});function m(b,g){Tt("coordinate "+b,g,Wt,f)}function d(b){if(!(b instanceof y))throw new Error("ExtendedPoint expected")}let x=Ve((b,g)=>{let{ex:v,ey:N,ez:P}=b,D=b.is0();g==null&&(g=D?Jh:e.inv(P));let $=u(v*g),z=u(N*g),V=u(P*g);if(D)return{x:Wt,y:Ut};if(V!==Ut)throw new Error("invZ was invalid");return{x:$,y:z}}),A=Ve(b=>{let{a:g,d:v}=t;if(b.is0())throw new Error("bad point: ZERO");let{ex:N,ey:P,ez:D,et:$}=b,z=u(N*N),V=u(P*P),j=u(D*D),Q=u(j*j),at=u(z*g),ut=u(j*u(at+V)),pt=u(Q+u(v*u(z*V)));if(ut!==pt)throw new Error("bad point: equation left != right (1)");let wt=u(N*P),st=u(D*$);if(wt!==st)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(g,v,N,P){this.ex=g,this.ey=v,this.ez=N,this.et=P,m("x",g),m("y",v),m("z",N),m("t",P),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(g){if(g instanceof y)throw new Error("extended point not allowed");let{x:v,y:N}=g||{};return m("x",v),m("y",N),new y(v,N,Ut,u(v*N))}static normalizeZ(g){let v=e.invertBatch(g.map(N=>N.ez));return g.map((N,P)=>N.toAffine(v[P])).map(y.fromAffine)}static msm(g,v){return ro(y,l,g,v)}_setWindowSize(g){L.setWindowSize(this,g)}assertValidity(){A(this)}equals(g){d(g);let{ex:v,ey:N,ez:P}=this,{ex:D,ey:$,ez:z}=g,V=u(v*z),j=u(D*P),Q=u(N*z),at=u($*P);return V===j&&Q===at}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:g}=t,{ex:v,ey:N,ez:P}=this,D=u(v*v),$=u(N*N),z=u(no*u(P*P)),V=u(g*D),j=v+N,Q=u(u(j*j)-D-$),at=V+$,ut=at-z,pt=V-$,wt=u(Q*ut),st=u(at*pt),It=u(Q*pt),Jt=u(ut*at);return new y(wt,st,Jt,It)}add(g){d(g);let{a:v,d:N}=t,{ex:P,ey:D,ez:$,et:z}=this,{ex:V,ey:j,ez:Q,et:at}=g;if(v===BigInt(-1)){let is=u((D-P)*(j+V)),ss=u((D+P)*(j-V)),yo=u(ss-is);if(yo===Wt)return this.double();let cs=u($*no*at),as=u(z*no*Q),us=as+cs,fs=ss+is,ls=as-cs,qu=u(us*yo),Ku=u(fs*ls),Gu=u(us*ls),ju=u(yo*fs);return new y(qu,Ku,ju,Gu)}let ut=u(P*V),pt=u(D*j),wt=u(z*N*at),st=u($*Q),It=u((P+D)*(V+j)-ut-pt),Jt=st-wt,yr=st+wt,xr=u(pt-v*ut),$u=u(It*Jt),Vu=u(yr*xr),zu=u(It*xr),Hu=u(Jt*yr);return new y($u,Vu,Hu,zu)}subtract(g){return this.add(g.negate())}wNAF(g){return L.wNAFCached(this,g,y.normalizeZ)}multiply(g){let v=g;Tt("scalar",v,Ut,n);let{p:N,f:P}=this.wNAF(v);return y.normalizeZ([N,P])[0]}multiplyUnsafe(g){let v=g;return Tt("scalar",v,Wt,n),v===Wt?R:this.equals(R)||v===Ut?this:this.equals(B)?this.wNAF(v).p:L.unsafeLadder(this,v)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return L.unsafeLadder(this,n).is0()}toAffine(g){return x(this,g)}clearCofactor(){let{h:g}=t;return g===Ut?this:this.multiplyUnsafe(g)}static fromHex(g,v=!1){let{d:N,a:P}=t,D=e.BYTES;g=nt("pointHex",g,D),Zt("zip215",v);let $=g.slice(),z=g[D-1];$[D-1]=z&-129;let V=Be($),j=v?f:e.ORDER;Tt("pointHex.y",V,Wt,j);let Q=u(V*V),at=u(Q-Ut),ut=u(N*Q-P),{isValid:pt,value:wt}=h(at,ut);if(!pt)throw new Error("Point.fromHex: invalid y coordinate");let st=(wt&Ut)===Ut,It=(z&128)!==0;if(!v&&wt===Wt&&It)throw new Error("Point.fromHex: x=0 and x_0=1");return It!==st&&(wt=u(-wt)),y.fromAffine({x:wt,y:V})}static fromPrivateKey(g){return _(g).point}toRawBytes(){let{x:g,y:v}=this.toAffine(),N=$e(v,e.BYTES);return N[N.length-1]|=g&Ut?128:0,N}toHex(){return ce(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,Ut,u(t.Gx*t.Gy)),y.ZERO=new y(Wt,Ut,Ut,Wt);let{BASE:B,ZERO:R}=y,L=eo(y,c*8);function T(b){return Z(b,n)}function k(b){return T(Be(b))}function _(b){let g=c;b=nt("private key",b,g);let v=nt("hashed private key",i(b),2*g),N=w(v.slice(0,g)),P=v.slice(g,2*g),D=k(N),$=B.multiply(D),z=$.toRawBytes();return{head:N,prefix:P,scalar:D,point:$,pointBytes:z}}function ot(b){return _(b).pointBytes}function H(b=new Uint8Array,...g){let v=ue(...g);return k(i(E(v,nt("context",b),!!o)))}function F(b,g,v={}){b=nt("message",b),o&&(b=o(b));let{prefix:N,scalar:P,pointBytes:D}=_(g),$=H(v.context,N,b),z=B.multiply($).toRawBytes(),V=H(v.context,z,D,b),j=T($+V*P);Tt("signature.s",j,Wt,n);let Q=ue(z,$e(j,e.BYTES));return nt("result",Q,c*2)}let it=tp;function I(b,g,v,N=it){let{context:P,zip215:D}=N,$=e.BYTES;b=nt("signature",b,2*$),g=nt("message",g),D!==void 0&&Zt("zip215",D),o&&(g=o(g));let z=Be(b.slice($,2*$)),V,j,Q;try{V=y.fromHex(v,D),j=y.fromHex(b.slice(0,$),D),Q=B.multiplyUnsafe(z)}catch{return!1}if(!D&&V.isSmallOrder())return!1;let at=H(P,j.toRawBytes(),V.toRawBytes(),g);return j.add(V.multiplyUnsafe(at)).subtract(Q).clearCofactor().equals(y.ZERO)}return B._setWindowSize(8),{CURVE:t,getPublicKey:ot,sign:F,verify:I,ExtendedPoint:y,utils:{getExtendedPublicKey:_,randomPrivateKey:()=>s(e.BYTES),precompute(b=8,g=y.BASE){return g._setWindowSize(b),g.multiply(BigInt(3)),g}}}}var ji=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),du=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),t2=BigInt(0),rp=BigInt(1),hu=BigInt(2),e2=BigInt(3),np=BigInt(5),op=BigInt(8);function ip(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=ji,c=r*r%i*r%i,a=et(c,hu,i)*c%i,f=et(a,rp,i)*r%i,u=et(f,np,i)*f%i,l=et(u,t,i)*u%i,h=et(l,e,i)*l%i,w=et(h,n,i)*h%i,E=et(w,o,i)*w%i,m=et(E,o,i)*w%i,d=et(m,t,i)*u%i;return{pow_p_5_8:et(d,hu,i)*r%i,b2:c}}function sp(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function cp(r,t){let e=ji,n=Z(t*t*t,e),o=Z(n*n*t,e),i=ip(r*o).pow_p_5_8,s=Z(r*n*i,e),c=Z(t*s*s,e),a=s,f=Z(s*du,e),u=c===r,l=c===Z(-r,e),h=c===Z(-r*du,e);return u&&(s=a),(l||h)&&(s=f),cu(s,e)&&(s=Z(-s,e)),{isValid:u||l,value:s}}var ap=Ce(ji,void 0,!0),up={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ap,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:op,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ru,randomBytes:Yn,adjustScalarBytes:sp,uvRatio:cp},pu=lu(up);var oo=32;function mu(r,t,e){return pu.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var io=class{type="Ed25519";raw;constructor(t){this.raw=Zi(t,oo)}toMultihash(){return ne.digest(so(this))}toCID(){return mt.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Ht(this.raw,t.raw)}verify(t,e){return mu(this.raw,e,t)}};function yu(r){return r=Zi(r,oo),new io(r)}function Zi(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new de(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Ft;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(Ft||(Ft={}));var Wi;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Wi||(Wi={}));(function(r){r.codec=()=>Pr(Wi)})(Ft||(Ft={}));var Xr;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Ft.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=Ft.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Xr||(Xr={}));var Yi;(function(r){let t;r.codec=()=>(t==null&&(t=At((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Ft.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=Ft.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return i})),t),r.encode=e=>St(e,r.codec()),r.decode=(e,n)=>vt(e,r.codec(),n)})(Yi||(Yi={}));var dp=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]),ke=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Te=new Uint32Array(64),Xi=class extends hr{constructor(){super(64,32,8,!1),this.A=ke[0]|0,this.B=ke[1]|0,this.C=ke[2]|0,this.D=ke[3]|0,this.E=ke[4]|0,this.F=ke[5]|0,this.G=ke[6]|0,this.H=ke[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 l=0;l<16;l++,e+=4)Te[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let h=Te[l-15],w=Te[l-2],E=jt(h,7)^jt(h,18)^h>>>3,m=jt(w,17)^jt(w,19)^w>>>10;Te[l]=m+Te[l-7]+E+Te[l-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:f,H:u}=this;for(let l=0;l<64;l++){let h=jt(c,6)^jt(c,11)^jt(c,25),w=u+h+Ja(c,a,f)+dp[l]+Te[l]|0,m=(jt(n,2)^jt(n,13)^jt(n,22))+tu(n,o,i)|0;u=f,f=a,a=c,c=s+w|0,s=i,i=o,o=n,n=w+m|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,f,u)}roundClean(){Te.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var xu=Wn(()=>new Xi);var Qr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var co=class extends dr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Ya(t);let n=jr(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 lr(this),this.iHash.update(t),this}digestInto(t){lr(this),fr(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()}},Qi=(r,t,e)=>new co(r,t).update(e).digest();Qi.create=(r,t)=>new co(r,t);function bu(r){r.lowS!==void 0&&Zt("lowS",r.lowS),r.prehash!==void 0&&Zt("prehash",r.prehash)}function hp(r){let t=Yr(r);Qt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:pp,hexToBytes:mp}=Jn,fe={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(r,t)=>{let{Err:e}=fe;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=Oe(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?Oe(o.length/2|128):"";return`${Oe(r)}${i}${o}${t}`},decode(r,t){let{Err:e}=fe,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 f=t.subarray(n,n+a);if(f.length!==a)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)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}=fe;if(r<le)throw new t("integer: negative integers are not allowed");let e=Oe(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected assertion");return e},decode(r){let{Err:t}=fe;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 pp(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=fe,o=typeof r=="string"?mp(r):r;pr(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:f,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(f)}},hexFromSig(r){let{_tlv:t,_int:e}=fe,n=`${t.encode(2,e.encode(r.r))}${t.encode(2,e.encode(r.s))}`;return t.encode(48,n)}},le=BigInt(0),ht=BigInt(1),U2=BigInt(2),wu=BigInt(3),L2=BigInt(4);function gp(r){let t=hp(r),{Fp:e}=t,n=Ce(t.n,t.nBitLength),o=t.toBytes||((m,d,x)=>{let A=d.toAffine();return ue(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),i=t.fromBytes||(m=>{let d=m.subarray(1),x=e.fromBytes(d.subarray(0,e.BYTES)),A=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x,y:A}});function s(m){let{a:d,b:x}=t,A=e.sqr(m),y=e.mul(A,m);return e.add(e.add(y,e.mul(m,d)),x)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function c(m){return Zr(m,ht,t.n)}function a(m){let{allowedPrivateKeyLengths:d,nByteLength:x,wrapPrivateKey:A,n:y}=t;if(d&&typeof m!="bigint"){if(Ae(m)&&(m=ce(m)),typeof m!="string"||!d.includes(m.length))throw new Error("Invalid key");m=m.padStart(x*2,"0")}let B;try{B=typeof m=="bigint"?m:ae(nt("private key",m,x))}catch{throw new Error(`private key must be ${x} bytes, hex or bigint, not ${typeof m}`)}return A&&(B=Z(B,y)),Tt("private key",B,ht,y),B}function f(m){if(!(m instanceof h))throw new Error("ProjectivePoint expected")}let u=Ve((m,d)=>{let{px:x,py:A,pz:y}=m;if(e.eql(y,e.ONE))return{x,y:A};let B=m.is0();d==null&&(d=B?e.ONE:e.inv(y));let R=e.mul(x,d),L=e.mul(A,d),T=e.mul(y,d);if(B)return{x:e.ZERO,y:e.ZERO};if(!e.eql(T,e.ONE))throw new Error("invZ was invalid");return{x:R,y:L}}),l=Ve(m=>{if(m.is0()){if(t.allowInfinityPoint&&!e.is0(m.py))return;throw new Error("bad point: ZERO")}let{x:d,y:x}=m.toAffine();if(!e.isValid(d)||!e.isValid(x))throw new Error("bad point: x or y not FE");let A=e.sqr(x),y=s(d);if(!e.eql(A,y))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,x,A){if(this.px=d,this.py=x,this.pz=A,d==null||!e.isValid(d))throw new Error("x required");if(x==null||!e.isValid(x))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x,y:A}=d||{};if(!d||!e.isValid(x)||!e.isValid(A))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let y=B=>e.eql(B,e.ZERO);return y(x)&&y(A)?h.ZERO:new h(x,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let x=e.invertBatch(d.map(A=>A.pz));return d.map((A,y)=>A.toAffine(x[y])).map(h.fromAffine)}static fromHex(d){let x=h.fromAffine(i(nt("pointHex",d)));return x.assertValidity(),x}static fromPrivateKey(d){return h.BASE.multiply(a(d))}static msm(d,x){return ro(h,n,d,x)}_setWindowSize(d){E.setWindowSize(this,d)}assertValidity(){l(this)}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:x,py:A,pz:y}=this,{px:B,py:R,pz:L}=d,T=e.eql(e.mul(x,L),e.mul(B,y)),k=e.eql(e.mul(A,L),e.mul(R,y));return T&&k}negate(){return new h(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:x}=t,A=e.mul(x,wu),{px:y,py:B,pz:R}=this,L=e.ZERO,T=e.ZERO,k=e.ZERO,_=e.mul(y,y),ot=e.mul(B,B),H=e.mul(R,R),F=e.mul(y,B);return F=e.add(F,F),k=e.mul(y,R),k=e.add(k,k),L=e.mul(d,k),T=e.mul(A,H),T=e.add(L,T),L=e.sub(ot,T),T=e.add(ot,T),T=e.mul(L,T),L=e.mul(F,L),k=e.mul(A,k),H=e.mul(d,H),F=e.sub(_,H),F=e.mul(d,F),F=e.add(F,k),k=e.add(_,_),_=e.add(k,_),_=e.add(_,H),_=e.mul(_,F),T=e.add(T,_),H=e.mul(B,R),H=e.add(H,H),_=e.mul(H,F),L=e.sub(L,_),k=e.mul(H,ot),k=e.add(k,k),k=e.add(k,k),new h(L,T,k)}add(d){f(d);let{px:x,py:A,pz:y}=this,{px:B,py:R,pz:L}=d,T=e.ZERO,k=e.ZERO,_=e.ZERO,ot=t.a,H=e.mul(t.b,wu),F=e.mul(x,B),it=e.mul(A,R),I=e.mul(y,L),U=e.add(x,A),b=e.add(B,R);U=e.mul(U,b),b=e.add(F,it),U=e.sub(U,b),b=e.add(x,y);let g=e.add(B,L);return b=e.mul(b,g),g=e.add(F,I),b=e.sub(b,g),g=e.add(A,y),T=e.add(R,L),g=e.mul(g,T),T=e.add(it,I),g=e.sub(g,T),_=e.mul(ot,b),T=e.mul(H,I),_=e.add(T,_),T=e.sub(it,_),_=e.add(it,_),k=e.mul(T,_),it=e.add(F,F),it=e.add(it,F),I=e.mul(ot,I),b=e.mul(H,b),it=e.add(it,I),I=e.sub(F,I),I=e.mul(ot,I),b=e.add(b,I),F=e.mul(it,b),k=e.add(k,F),F=e.mul(g,b),T=e.mul(U,T),T=e.sub(T,F),F=e.mul(U,it),_=e.mul(g,_),_=e.add(_,F),new h(T,k,_)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return E.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){Tt("scalar",d,le,t.n);let x=h.ZERO;if(d===le)return x;if(d===ht)return this;let{endo:A}=t;if(!A)return E.unsafeLadder(this,d);let{k1neg:y,k1:B,k2neg:R,k2:L}=A.splitScalar(d),T=x,k=x,_=this;for(;B>le||L>le;)B&ht&&(T=T.add(_)),L&ht&&(k=k.add(_)),_=_.double(),B>>=ht,L>>=ht;return y&&(T=T.negate()),R&&(k=k.negate()),k=new h(e.mul(k.px,A.beta),k.py,k.pz),T.add(k)}multiply(d){let{endo:x,n:A}=t;Tt("scalar",d,ht,A);let y,B;if(x){let{k1neg:R,k1:L,k2neg:T,k2:k}=x.splitScalar(d),{p:_,f:ot}=this.wNAF(L),{p:H,f:F}=this.wNAF(k);_=E.constTimeNegate(R,_),H=E.constTimeNegate(T,H),H=new h(e.mul(H.px,x.beta),H.py,H.pz),y=_.add(H),B=ot.add(F)}else{let{p:R,f:L}=this.wNAF(d);y=R,B=L}return h.normalizeZ([y,B])[0]}multiplyAndAddUnsafe(d,x,A){let y=h.BASE,B=(L,T)=>T===le||T===ht||!L.equals(y)?L.multiplyUnsafe(T):L.multiply(T),R=B(this,x).add(B(d,A));return R.is0()?void 0:R}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:x}=t;if(d===ht)return!0;if(x)return x(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:x}=t;return d===ht?this:x?x(h,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return Zt("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return Zt("isCompressed",d),ce(this.toRawBytes(d))}}h.BASE=new h(t.Gx,t.Gy,e.ONE),h.ZERO=new h(e.ZERO,e.ONE,e.ZERO);let w=t.nBitLength,E=eo(h,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:c}}function yp(r){let t=Yr(r);return Qt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Eu(r){let t=yp(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(I){return Z(I,n)}function c(I){return to(I,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=gp({...t,toBytes(I,U,b){let g=U.toAffine(),v=e.toBytes(g.x),N=ue;return Zt("isCompressed",b),b?N(Uint8Array.from([U.hasEvenY()?2:3]),v):N(Uint8Array.from([4]),v,e.toBytes(g.y))},fromBytes(I){let U=I.length,b=I[0],g=I.subarray(1);if(U===o&&(b===2||b===3)){let v=ae(g);if(!Zr(v,ht,e.ORDER))throw new Error("Point is not on curve");let N=u(v),P;try{P=e.sqrt(N)}catch(z){let V=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+V)}let D=(P&ht)===ht;return(b&1)===1!==D&&(P=e.neg(P)),{x:v,y:P}}else if(U===i&&b===4){let v=e.fromBytes(g.subarray(0,e.BYTES)),N=e.fromBytes(g.subarray(e.BYTES,2*e.BYTES));return{x:v,y:N}}else throw new Error(`Point of length ${U} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=I=>ce(Ie(I,t.nByteLength));function w(I){let U=n>>ht;return I>U}function E(I){return w(I)?s(-I):I}let m=(I,U,b)=>ae(I.slice(U,b));class d{constructor(U,b,g){this.r=U,this.s=b,this.recovery=g,this.assertValidity()}static fromCompact(U){let b=t.nByteLength;return U=nt("compactSignature",U,b*2),new d(m(U,0,b),m(U,b,2*b))}static fromDER(U){let{r:b,s:g}=fe.toSig(nt("DER",U));return new d(b,g)}assertValidity(){Tt("r",this.r,ht,n),Tt("s",this.s,ht,n)}addRecoveryBit(U){return new d(this.r,this.s,U)}recoverPublicKey(U){let{r:b,s:g,recovery:v}=this,N=L(nt("msgHash",U));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let P=v===2||v===3?b+t.n:b;if(P>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let D=v&1?"03":"02",$=a.fromHex(D+h(P)),z=c(P),V=s(-N*z),j=s(g*z),Q=a.BASE.multiplyAndAddUnsafe($,V,j);if(!Q)throw new Error("point at infinify");return Q.assertValidity(),Q}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Fe(this.toDERHex())}toDERHex(){return fe.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Fe(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let x={isValidPrivateKey(I){try{return f(I),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let I=qi(t.n);return uu(t.randomBytes(I),t.n)},precompute(I=8,U=a.BASE){return U._setWindowSize(I),U.multiply(BigInt(3)),U}};function A(I,U=!0){return a.fromPrivateKey(I).toRawBytes(U)}function y(I){let U=Ae(I),b=typeof I=="string",g=(U||b)&&I.length;return U?g===o||g===i:b?g===2*o||g===2*i:I instanceof a}function B(I,U,b=!0){if(y(I))throw new Error("first arg must be private key");if(!y(U))throw new Error("second arg must be public key");return a.fromHex(U).multiply(f(I)).toRawBytes(b)}let R=t.bits2int||function(I){let U=ae(I),b=I.length*8-t.nBitLength;return b>0?U>>BigInt(b):U},L=t.bits2int_modN||function(I){return s(R(I))},T=Wr(t.nBitLength);function k(I){return Tt(`num < 2^${t.nBitLength}`,I,le,T),Ie(I,t.nByteLength)}function _(I,U,b=ot){if(["recovered","canonical"].some(ut=>ut in b))throw new Error("sign() legacy options not supported");let{hash:g,randomBytes:v}=t,{lowS:N,prehash:P,extraEntropy:D}=b;N==null&&(N=!0),I=nt("msgHash",I),bu(b),P&&(I=nt("prehashed msgHash",g(I)));let $=L(I),z=f(U),V=[k(z),k($)];if(D!=null&&D!==!1){let ut=D===!0?v(e.BYTES):D;V.push(nt("extraEntropy",ut))}let j=ue(...V),Q=$;function at(ut){let pt=R(ut);if(!l(pt))return;let wt=c(pt),st=a.BASE.multiply(pt).toAffine(),It=s(st.x);if(It===le)return;let Jt=s(wt*s(Q+It*z));if(Jt===le)return;let yr=(st.x===It?0:2)|Number(st.y&ht),xr=Jt;return N&&w(Jt)&&(xr=E(Jt),yr^=1),new d(It,xr,yr)}return{seed:j,k2sig:at}}let ot={lowS:t.lowS,prehash:!1},H={lowS:t.lowS,prehash:!1};function F(I,U,b=ot){let{seed:g,k2sig:v}=_(I,U,b),N=t;return $i(N.hash.outputLen,N.nByteLength,N.hmac)(g,v)}a.BASE._setWindowSize(8);function it(I,U,b,g=H){let v=I;if(U=nt("msgHash",U),b=nt("publicKey",b),"strict"in g)throw new Error("options.strict was renamed to lowS");bu(g);let{lowS:N,prehash:P}=g,D,$;try{if(typeof v=="string"||Ae(v))try{D=d.fromDER(v)}catch(st){if(!(st instanceof fe.Err))throw st;D=d.fromCompact(v)}else if(typeof v=="object"&&typeof v.r=="bigint"&&typeof v.s=="bigint"){let{r:st,s:It}=v;D=new d(st,It)}else throw new Error("PARSE");$=a.fromHex(b)}catch(st){if(st.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(N&&D.hasHighS())return!1;P&&(U=t.hash(U));let{r:z,s:V}=D,j=L(U),Q=c(V),at=s(j*Q),ut=s(z*Q),pt=a.BASE.multiplyAndAddUnsafe($,at,ut)?.toAffine();return pt?s(pt.x)===z:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:B,sign:F,verify:it,ProjectivePoint:a,Signature:d,utils:x}}function xp(r){return{hash:r,hmac:(t,...e)=>Qi(r,t,_i(...e)),randomBytes:Yn}}function vu(r,t){let e=n=>Eu({...r,...xp(n)});return Object.freeze({...e(t),create:e})}var Bu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Su=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),bp=BigInt(1),Ji=BigInt(2),Au=(r,t)=>(r+t/Ji)/t;function wp(r){let t=Bu,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),f=r*r*r%t,u=f*f*r%t,l=et(u,e,t)*u%t,h=et(l,e,t)*u%t,w=et(h,Ji,t)*f%t,E=et(w,o,t)*w%t,m=et(E,i,t)*E%t,d=et(m,c,t)*m%t,x=et(d,a,t)*d%t,A=et(x,c,t)*m%t,y=et(A,e,t)*u%t,B=et(y,s,t)*E%t,R=et(B,n,t)*f%t,L=et(R,Ji,t);if(!ts.eql(ts.sqr(L),r))throw new Error("Cannot find square root");return L}var ts=Ce(Bu,void 0,void 0,{sqrt:wp}),He=vu({a:BigInt(0),b:BigInt(7),Fp:ts,n:Su,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Su,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-bp*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),c=Au(i*r,t),a=Au(-n*r,t),f=Z(r-c*e-a*o,t),u=Z(-c*n-a*i,t),l=f>s,h=u>s;if(l&&(f=t-f),h&&(u=t-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:h,k2:u}}}},xu),$2=BigInt(0);var V2=He.ProjectivePoint;function Iu(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Cu(r,t,e){let n=Ur.digest(e instanceof Uint8Array?e:e.subarray());if(Iu(n))return n.then(({digest:o})=>He.verify(t,o,r)).catch(o=>{throw new Qr(String(o))});try{return He.verify(t,n.digest,r)}catch(o){throw new Qr(String(o))}}var ao=class{type="secp256k1";raw;_key;constructor(t){this._key=Tu(t),this.raw=ku(this._key)}toMultihash(){return ne.digest(so(this))}toCID(){return mt.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Ht(this.raw,t.raw)}verify(t,e){return Cu(this._key,e,t)}};function Uu(r){return new ao(r)}function ku(r){return He.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Tu(r){try{return He.ProjectivePoint.fromHex(r),r}catch(t){throw new rn(String(t))}}function Lu(r){let{Type:t,Data:e}=Xr.decode(r.digest),n=e??new Uint8Array;switch(t){case Ft.Ed25519:return yu(n);case Ft.secp256k1:return Uu(n);default:throw new br}}function so(r){return Xr.encode({Type:Ft[r.type],Data:r.raw})}var _u=Symbol.for("nodejs.util.inspect.custom"),Ep=114,Jr=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()})`}[tn]=!0;toString(){return this.string==null&&(this.string=J.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return mt.createV1(Ep,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Ht(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Ht(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[_u](){return`PeerId(${this.toString()})`}},uo=class extends Jr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},fo=class extends Jr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},lo=class extends Jr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},vp=2336,ho=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=ne.digest(be(this.url))}[_u](){return`PeerId(${this.url})`}[tn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return mt.createV1(vp,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=dt(t)),t.toString()===this.toString())}};function Nu(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=re(J.decode(`z${r}`));else{if(t==null)throw new de('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=re(t.decode(r))}return es(e)}function es(r){if(Ap(r))return new uo({multihash:r});if(Sp(r))try{let t=Lu(r);if(t.type==="Ed25519")return new fo({multihash:r,publicKey:t});if(t.type==="secp256k1")return new lo({multihash:r,publicKey:t})}catch{let e=dt(r.digest);return new ho(new URL(e))}throw new nn("Supplied PeerID Multihash is invalid")}function Sp(r){return r.code===ne.code}function Ap(r){return r.code===Ur.code}var Ru={type:4098,canEncode:r=>ds(r),encode:r=>r.toMultihash().bytes,decode:r=>es(re(r))};var rs=[_a,Za,Ru,Na];function po(r){let t={},e=r.components??r;return Object.entries(e).forEach(([n,o])=>{o?.[he]!=null&&Array.isArray(o[he])&&(t[n]=o[he])}),t}function mr(r,t){let e={};for(let[n,o]of r.entries())e[n]=t(o);return e}async function mo(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:f})=>({multiaddr:f,isCertified:a,isConnected:o.includes(f.toString())})),protocols:[...c.protocols],tags:mr(c.tags,a=>a.value),metadata:mr(c.metadata,a=>Yt.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 gr(r,t){let e=t[r];if(!en(e))throw new de(`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:mr(t.tags,e=>e.value),metadata:mr(t.metadata,e=>Yt.encode(e))}}function Pu(r){let t=r.logger.forComponent("libp2p:devtools-metrics:metrics-rpc");return{init:async()=>({self:await go(r),peers:await mo(r,t),debug:localStorage.getItem("debug")??"",capabilities:po(r)}),setDebug:async e=>{e?.length!=null&&e?.length>0?(Is(e),localStorage.setItem("debug",e)):(Bs(),localStorage.removeItem("debug"))},openConnection:async(e,n)=>{let o;try{o=Nu(e)}catch{o=De(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 gr(e,r).getTopics()},async subscribe(e,n){gr(e,r).subscribe(n)},async unsubscribe(e,n){gr(e,r).unsubscribe(n)},async publish(e,n,o){await gr(e,r).publish(n,o)},async getSubscribers(e,n){return gr(e,r).getSubscribers(n)}}}}function ns(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 Du(r,t){for(let[e,n]of Object.entries(po(t)))if(n.includes(r))return t[e]}var Mu="@libp2p/devtools-metrics:devtools",Bp="@libp2p/devtools-metrics:worker",Ip="@libp2p/devtools-metrics:content",Ou="@libp2p/devtools-metrics:metrics",Fu="________libp2p_devtools_metrics";Object.defineProperty(globalThis,Fu,{value:!0,enumerable:!1,writable:!1});var os=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=me(),this.rpc=La({valueCodecs:rs}),this.devTools=this.rpc.createClient("devTools"),this.onPeersUpdate=ns(this.onPeersUpdate.bind(this),1e3),this.onSelfUpdate=ns(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=Ts({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";[he]=["@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)}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",Pu(this.components)),await ms(this.simpleMetrics),Promise.resolve().then(async()=>{await Ls(this.rpcQueue,this.rpc,async e=>{for await(let n of e)window.postMessage({source:Ou,type:"libp2p-rpc",message:Yt.encode(n)})})}).catch(e=>{this.log.error("error while reading RPC messages",e)});let t=Du("@libp2p/pubsub",this.components);en(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 gs(this.simpleMetrics)}onIncomingMessage(t){if(t.source!==window)return;let e=t.data;e?.source===Mu&&e.type==="libp2p-rpc"&&this.rpcQueue.push(Yt.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 mo(this.components,this.log)})}).catch(t=>{this.log.error("error sending peers message",t)})}};function Cp(r){return t=>new os(t,r)}return Qu(kp);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|