kubo-rpc-client
Version:
A client library for the Kubo RPC API
2 lines • 236 kB
JavaScript
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.KuboRpcClient = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var KuboRpcClient=(()=>{var Km=Object.create;var Gn=Object.defineProperty;var Mm=Object.getOwnPropertyDescriptor;var Fm=Object.getOwnPropertyNames;var jm=Object.getPrototypeOf,Vm=Object.prototype.hasOwnProperty;var Kt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),le=(e,t)=>{for(var r in t)Gn(e,r,{get:t[r],enumerable:!0})},Hc=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Fm(t))!Vm.call(e,o)&&o!==r&&Gn(e,o,{get:()=>t[o],enumerable:!(n=Mm(t,o))||n.enumerable});return e};var Mt=(e,t,r)=>(r=e!=null?Km(jm(e)):{},Hc(t||!e||!e.__esModule?Gn(r,"default",{value:e,enumerable:!0}):r,e)),Hm=e=>Hc(Gn({},"__esModule",{value:!0}),e);var Sl=Kt((n8,El)=>{function cb(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}El.exports=cb});var An=Kt((c8,Pl)=>{"use strict";function Bl(e,t){for(let r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}function fb(e,t,r){if(!e||typeof e=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof t=="object"&&(r=t,t=""),t&&(r.code=t);try{return Bl(e,r)}catch{r.message=e.message,r.stack=e.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(e)),Bl(new o,r)}}Pl.exports=fb});var rp=Kt((FB,tp)=>{"use strict";tp.exports=e=>{if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}});var cp=Kt((ip,ap)=>{"use strict";var us=rp(),{hasOwnProperty:op}=Object.prototype,{propertyIsEnumerable:u1}=Object,zr=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),l1=ip,np={concatArrays:!1,ignoreUndefined:!1},ls=e=>{let t=[];for(let r in e)op.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){let r=Object.getOwnPropertySymbols(e);for(let n of r)u1.call(e,n)&&t.push(n)}return t};function Gr(e){return Array.isArray(e)?d1(e):us(e)?h1(e):e}function d1(e){let t=e.slice(0,0);return ls(e).forEach(r=>{zr(t,r,Gr(e[r]))}),t}function h1(e){let t=Object.getPrototypeOf(e)===null?Object.create(null):{};return ls(e).forEach(r=>{zr(t,r,Gr(e[r]))}),t}var sp=(e,t,r,n)=>(r.forEach(o=>{typeof t[o]>"u"&&n.ignoreUndefined||(o in e&&e[o]!==Object.getPrototypeOf(e)?zr(e,o,vc(e[o],t[o],n)):zr(e,o,Gr(t[o])))}),e),p1=(e,t,r)=>{let n=e.slice(0,0),o=0;return[e,t].forEach(s=>{let i=[];for(let a=0;a<s.length;a++)op.call(s,a)&&(i.push(String(a)),s===e?zr(n,o++,s[a]):zr(n,o++,Gr(s[a])));n=sp(n,s,ls(s).filter(a=>!i.includes(a)),r)}),n};function vc(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?p1(e,t,r):!us(t)||!us(e)?Gr(t):sp(e,t,ls(t),r)}ap.exports=function(...e){let t=vc(Gr(np),this!==l1&&this||{},np),r={_:{}};for(let n of e)if(n!==void 0){if(!us(n))throw new TypeError("`"+n+"` is not an Option Object");r=vc(r,{_:n},t)}return r._}});var Bc=Kt((GB,yp)=>{"use strict";var y1=typeof navigator<"u"&&navigator.product==="ReactNative";function g1(){return y1?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var Hn=self.URL,mp=g1(),Ic=class{constructor(t="",r=mp){this.super=new Hn(t,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set username(t){this.super.username=t}static createObjectURL(t){return Hn.createObjectURL(t)}static revokeObjectURL(t){Hn.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function w1(e){if(typeof e=="string")return new Hn(e).toString();if(!(e instanceof Hn)){let t=e.username&&e.password?`${e.username}:${e.password}@`:"",r=e.auth?e.auth+"@":"",n=e.port?":"+e.port:"",o=e.protocol?e.protocol+"//":"",s=e.host||"",i=e.hostname||"",a=e.search||(e.query?"?"+e.query:""),c=e.hash||"",l=e.pathname||"",u=e.path||l+a;return`${o}${t||r}${s||i+n}${u}${c}`}}yp.exports={URLWithLegacySupport:Ic,URLSearchParams:self.URLSearchParams,defaultBase:mp,format:w1}});var bp=Kt((WB,wp)=>{"use strict";var{URLWithLegacySupport:gp,format:b1}=Bc();wp.exports=(e,t={},r={},n)=>{let o=t.protocol?t.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let s;try{s=new gp(e)}catch{s={}}let i=Object.assign({},t,{protocol:o||s.protocol,host:t.host||s.host});return new gp(e,b1(i)).toString()}});var Ep=Kt((ZB,xp)=>{"use strict";var{URLWithLegacySupport:x1,format:E1,URLSearchParams:S1,defaultBase:A1}=Bc(),v1=bp();xp.exports={URL:x1,URLSearchParams:S1,format:E1,relative:v1,defaultBase:A1}});var o2={};le(o2,{CID:()=>C,RoutingEventTypes:()=>yc,RoutingMessageType:()=>gc,StrictNoSign:()=>t2,StrictSign:()=>e2,create:()=>r2,createBitswap:()=>fc,createBlock:()=>uc,createBootstrap:()=>lc,createConfig:()=>dc,createDAG:()=>mc,createDHT:()=>wc,createDiag:()=>bc,createFiles:()=>Ec,createKey:()=>Sc,createKuboRPCClient:()=>r2,createLog:()=>Tc,createName:()=>Uc,createObject:()=>Dc,createPin:()=>Rc,createProvide:()=>Nc,createPubsub:()=>Oc,createRefs:()=>Lc,createRepo:()=>kc,createRouting:()=>$c,createStats:()=>Kc,createSwarm:()=>Mc,multiaddr:()=>Q,readURLContent:()=>$m,urlSource:()=>n2});function Se(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function ut(e=0){return new Uint8Array(e)}function De(e=0){return new Uint8Array(e)}var qm=Math.pow(2,7),zm=Math.pow(2,14),Gm=Math.pow(2,21),Bs=Math.pow(2,28),Ps=Math.pow(2,35),_s=Math.pow(2,42),Ts=Math.pow(2,49),oe=128,Ae=127;function tt(e){if(e<qm)return 1;if(e<zm)return 2;if(e<Gm)return 3;if(e<Bs)return 4;if(e<Ps)return 5;if(e<_s)return 6;if(e<Ts)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Qr(e,t,r=0){switch(tt(e)){case 8:t[r++]=e&255|oe,e/=128;case 7:t[r++]=e&255|oe,e/=128;case 6:t[r++]=e&255|oe,e/=128;case 5:t[r++]=e&255|oe,e/=128;case 4:t[r++]=e&255|oe,e>>>=7;case 3:t[r++]=e&255|oe,e>>>=7;case 2:t[r++]=e&255|oe,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Us(e,t){let r=e[t],n=0;if(n+=r&Ae,r<oe||(r=e[t+1],n+=(r&Ae)<<7,r<oe)||(r=e[t+2],n+=(r&Ae)<<14,r<oe)||(r=e[t+3],n+=(r&Ae)<<21,r<oe)||(r=e[t+4],n+=(r&Ae)*Bs,r<oe)||(r=e[t+5],n+=(r&Ae)*Ps,r<oe)||(r=e[t+6],n+=(r&Ae)*_s,r<oe)||(r=e[t+7],n+=(r&Ae)*Ts,r<oe))return n;throw new RangeError("Could not decode varint")}function Wm(e,t){let r=e.get(t),n=0;if(n+=r&Ae,r<oe||(r=e.get(t+1),n+=(r&Ae)<<7,r<oe)||(r=e.get(t+2),n+=(r&Ae)<<14,r<oe)||(r=e.get(t+3),n+=(r&Ae)<<21,r<oe)||(r=e.get(t+4),n+=(r&Ae)*Bs,r<oe)||(r=e.get(t+5),n+=(r&Ae)*Ps,r<oe)||(r=e.get(t+6),n+=(r&Ae)*_s,r<oe)||(r=e.get(t+7),n+=(r&Ae)*Ts,r<oe))return n;throw new RangeError("Could not decode varint")}function Ds(e,t=0){return e instanceof Uint8Array?Us(e,t):Wm(e,t)}function lt(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=De(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var ks={};le(ks,{base10:()=>r0});var p2=new Uint8Array(0);function qc(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function qe(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function zc(e){return new TextEncoder().encode(e)}function Gc(e){return new TextDecoder().decode(e)}function Ym(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var P=0,A=0,m=0,B=p.length;m!==B&&p[m]===0;)m++,P++;for(var w=(B-m)*u+1>>>0,T=new Uint8Array(w);m!==B;){for(var R=p[m],F=0,K=w-1;(R!==0||F<A)&&K!==-1;K--,F++)R+=256*T[K]>>>0,T[K]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");A=F,m++}for(var v=w-A;v!==w&&T[v]===0;)v++;for(var S=c.repeat(P);v<w;++v)S+=e.charAt(T[v]);return S}function y(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var P=0;if(p[P]!==" "){for(var A=0,m=0;p[P]===c;)A++,P++;for(var B=(p.length-P)*l+1>>>0,w=new Uint8Array(B);p[P];){var T=r[p.charCodeAt(P)];if(T===255)return;for(var R=0,F=B-1;(T!==0||R<m)&&F!==-1;F--,R++)T+=a*w[F]>>>0,w[F]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");m=R,P++}if(p[P]!==" "){for(var K=B-m;K!==B&&w[K]===0;)K++;for(var v=new Uint8Array(A+(B-K)),S=A;K!==B;)v[S++]=w[K++];return v}}}function I(p){var P=y(p);if(P)return P;throw new Error(`Non-${t} character`)}return{encode:d,decodeUnsafe:y,decode:I}}var Xm=Ym,Jm=Xm,Zc=Jm;var Rs=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Ns=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Yc(this,t)}},Os=class{decoders;constructor(t){this.decoders=t}or(t){return Yc(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Yc(e,t){return new Os({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Ls=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Rs(t,r,n),this.decoder=new Ns(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ar({name:e,prefix:t,encode:r,decode:n}){return new Ls(e,t,r,n)}function It({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Zc(r,e);return ar({prefix:t,name:e,encode:n,decode:s=>qe(o(s))})}function Qm(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,a=0,c=0;for(let l=0;l<o;++l){let u=t[e[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,i+=r,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=r||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function e0(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],i+=8;i>r;)i-=r,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function t0(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function ce({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=t0(n);return ar({prefix:t,name:e,encode(s){return e0(s,n,r)},decode(s){return Qm(s,o,r,e)}})}var r0=It({prefix:"9",name:"base10",alphabet:"0123456789"});var $s={};le($s,{base16:()=>n0,base16upper:()=>o0});var n0=ce({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),o0=ce({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ks={};le(Ks,{base2:()=>s0});var s0=ce({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ms={};le(Ms,{base256emoji:()=>u0});var Xc=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}"),i0=Xc.reduce((e,t,r)=>(e[r]=t,e),[]),a0=Xc.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function c0(e){return e.reduce((t,r)=>(t+=i0[r],t),"")}function f0(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=a0[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var u0=ar({prefix:"\u{1F680}",name:"base256emoji",encode:c0,decode:f0});var Fs={};le(Fs,{base32:()=>rt,base32hex:()=>p0,base32hexpad:()=>y0,base32hexpadupper:()=>g0,base32hexupper:()=>m0,base32pad:()=>d0,base32padupper:()=>h0,base32upper:()=>l0,base32z:()=>w0});var rt=ce({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),l0=ce({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),d0=ce({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),h0=ce({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),p0=ce({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),m0=ce({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),y0=ce({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),g0=ce({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),w0=ce({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var js={};le(js,{base36:()=>en,base36upper:()=>b0});var en=It({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),b0=It({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Vs={};le(Vs,{base58btc:()=>re,base58flickr:()=>x0});var re=It({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),x0=It({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Hs={};le(Hs,{base64:()=>cr,base64pad:()=>E0,base64url:()=>Ft,base64urlpad:()=>S0});var cr=ce({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),E0=ce({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ft=ce({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),S0=ce({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var qs={};le(qs,{base8:()=>A0});var A0=ce({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var zs={};le(zs,{identity:()=>v0});var v0=ar({prefix:"\0",name:"identity",encode:e=>Gc(e),decode:e=>zc(e)});var Gs={};le(Gs,{code:()=>P0,decode:()=>T0,encode:()=>_0,name:()=>B0});var C0=new TextEncoder,I0=new TextDecoder,B0="json",P0=512;function _0(e){return C0.encode(JSON.stringify(e))}function T0(e){return JSON.parse(I0.decode(e))}var Ws={};le(Ws,{code:()=>D0,decode:()=>N0,encode:()=>R0,name:()=>U0});var U0="raw",D0=85;function R0(e){return qe(e)}function N0(e){return qe(e)}var Ys={};le(Ys,{identity:()=>Pe});var O0=ef,Jc=128,L0=127,k0=~L0,$0=Math.pow(2,31);function ef(e,t,r){t=t||[],r=r||0;for(var n=r;e>=$0;)t[r++]=e&255|Jc,e/=128;for(;e&k0;)t[r++]=e&255|Jc,e>>>=7;return t[r]=e|0,ef.bytes=r-n+1,t}var K0=Zs,M0=128,Qc=127;function Zs(e,n){var r=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw Zs.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&Qc)<<o:(i&Qc)*Math.pow(2,o),o+=7}while(i>=M0);return Zs.bytes=s-n,r}var F0=Math.pow(2,7),j0=Math.pow(2,14),V0=Math.pow(2,21),H0=Math.pow(2,28),q0=Math.pow(2,35),z0=Math.pow(2,42),G0=Math.pow(2,49),W0=Math.pow(2,56),Z0=Math.pow(2,63),Y0=function(e){return e<F0?1:e<j0?2:e<V0?3:e<H0?4:e<q0?5:e<z0?6:e<G0?7:e<W0?8:e<Z0?9:10},X0={encode:O0,decode:K0,encodingLength:Y0},J0=X0,tn=J0;function rn(e,t=0){return[tn.decode(e,t),tn.decode.bytes]}function fr(e,t,r=0){return tn.encode(e,t,r),t}function ur(e){return tn.encodingLength(e)}function nt(e,t){let r=t.byteLength,n=ur(e),o=n+ur(r),s=new Uint8Array(o+r);return fr(e,s,0),fr(r,s,n),s.set(t,o),new lr(e,r,t,s)}function nn(e){let t=qe(e),[r,n]=rn(t),[o,s]=rn(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new lr(r,o,i,t)}function tf(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&qc(e.bytes,r.bytes)}}var lr=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var rf=0,Q0="identity",nf=qe;function ey(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return nt(rf,nf(e))}var Pe={code:rf,name:Q0,encode:nf,digest:ey};var Qs={};le(Qs,{sha256:()=>on,sha512:()=>ry});var ty=20;function Js({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Xs(e,t,r,n,o)}var Xs=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??ty,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?of(n,this.code,r?.truncate):n.then(o=>of(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function of(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return nt(t,e)}function af(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var on=Js({name:"sha2-256",code:18,encode:af("SHA-256")}),ry=Js({name:"sha2-512",code:19,encode:af("SHA-512")});function cf(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return oy(r,ei(e),t??re.encoder);default:return sy(r,ei(e),t??rt.encoder)}}var ff=new WeakMap;function ei(e){let t=ff.get(e);if(t==null){let r=new Map;return ff.set(e,r),r}return t}var C=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==sn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==iy)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=nt(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&tf(t.multihash,n.multihash)}toString(t){return cf(this,t)}toJSON(){return{"/":cf(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??uf(n,o,s.bytes))}else if(r[ay]===!0){let{version:n,multihash:o,code:s}=r,i=nn(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==sn)throw new Error(`Version 0 CID must use dag-pb (code: ${sn}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=uf(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,sn,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=qe(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new lr(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[d,y]=rn(t.subarray(r));return r+=y,d},o=n(),s=sn;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),c=n(),l=r+c,u=l-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,r){let[n,o]=ny(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ei(s).set(n,t),s}};function ny(e,t){switch(e[0]){case"Q":{let r=t??re;return[re.prefix,r.decode(`${re.prefix}${e}`)]}case re.prefix:{let r=t??re;return[re.prefix,r.decode(e)]}case rt.prefix:{let r=t??rt;return[rt.prefix,r.decode(e)]}case en.prefix:{let r=t??en;return[en.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function oy(e,t,r){let{prefix:n}=r;if(n!==re.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function sy(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var sn=112,iy=18;function uf(e,t,r){let n=ur(e),o=n+ur(t),s=new Uint8Array(o+r.byteLength);return fr(e,s,0),fr(t,s,n),s.set(r,o),s}var ay=Symbol.for("@ipld/js-cid/CID");var jt={...zs,...Ks,...qs,...ks,...$s,...Fs,...js,...Vs,...Hs,...Ms},lf={...Qs,...Ys},df={raw:Ws,json:Gs};function pf(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var hf=pf("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),ti=pf("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=De(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),cy={utf8:hf,"utf-8":hf,hex:jt.base16,latin1:ti,ascii:ti,binary:ti,...jt},Zn=cy;function Y(e,t="utf8"){let r=Zn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function q(e,t="utf8"){let r=Zn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var be=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},dt=class extends Error{static name="ValidationError";name="ValidationError"},Yn=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Xn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var Jn=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let d=this.readChar();if(d===void 0)return;let y=Number.parseInt(d,t);if(!Number.isNaN(y))return y});if(u===void 0)break;if(s*=t,s+=u,s>l||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return r[o]=i[0],r[o+1]=i[1],r[o+2]=i[2],r[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=t(s.subarray(0,i));return r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var fy=45,uy=15,Qn=new Jn;function mf(e){if(!(e.length>uy))return Qn.new(e).parseWith(()=>Qn.readIPv4Addr())}function yf(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>fy))return Qn.new(e).parseWith(()=>Qn.readIPv6Addr())}function eo(e){return!!mf(e)}function gf(e){return!!yf(e)}function ni(e){return t=>q(t,e)}function oi(e){return t=>Y(t,e)}function hr(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function Vt(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function wf(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=Y(t[0],"base32"),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Vt(n);return lt([r,o],r.length+o.length)}function bf(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let r=rt.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=Vt(n);return lt([r,o],r.length+o.length)}function si(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=q(t,"base32"),o=hr(r);return`${n}:${o}`}var ii=function(e){e=e.toString().trim();let t=new Uint8Array(4);return e.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new be("Invalid byte value in IP address");t[n]=o}),t},xf=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let s=eo(r[n]),i;s&&(i=ii(r[n]),r[n]=q(i.subarray(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,q(i.subarray(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){r[n]===""&&(r[n]="0");let s=parseInt(r[n],16);if(isNaN(s)||s<0||s>65535)throw new be("Invalid byte value in IP address");o[t++]=s>>8&255,o[t++]=s&255}return o},Ef=function(e){if(e.byteLength!==4)throw new be("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},Sf=function(e){if(e.byteLength!==16)throw new be("IPv6 address was incorrect length");let t=[];for(let n=0;n<e.byteLength;n+=2){let o=e[n],s=e[n+1],i=`${o.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`;t.push(i)}let r=t.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new be(`Invalid IPv6 address "${r}"`)}};function Af(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new be(`Invalid IPv6 address "${e}"`)}}var ri=Object.values(jt).map(e=>e.decoder),ly=(function(){let e=ri[0].or(ri[1]);return ri.slice(2).forEach(t=>e=e.or(t)),e})();function vf(e){return ly.decode(e)}function Cf(e){return t=>e.encoder.encode(t)}function dy(e){if(parseInt(e).toString()!==e)throw new dt("Value must be an integer")}function hy(e){if(e<0)throw new dt("Value must be a positive integer, or zero")}function py(e){return t=>{if(t>e)throw new dt(`Value must be smaller than or equal to ${e}`)}}function my(...e){return t=>{for(let r of e)r(t)}}var an=my(dy,hy,py(65535));var he=-1,ai=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(t){let r;if(typeof t=="string"?r=this.protocolsByName.get(t):r=this.protocolsByCode.get(t),r==null)throw new Xn(`Protocol ${t} was unknown`);return r}addProtocol(t){this.protocolsByCode.set(t.code,t),this.protocolsByName.set(t.name,t),t.aliases?.forEach(r=>{this.protocolsByName.set(r,t)})}removeProtocol(t){let r=this.protocolsByCode.get(t);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},ht=new ai,Zy=[{code:4,name:"ip4",size:32,valueToBytes:ii,bytesToValue:Ef,validate:e=>{if(!eo(e))throw new dt(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Vt,bytesToValue:hr,validate:an},{code:273,name:"udp",size:16,valueToBytes:Vt,bytesToValue:hr,validate:an},{code:33,name:"dccp",size:16,valueToBytes:Vt,bytesToValue:hr,validate:an},{code:41,name:"ip6",size:128,valueToBytes:xf,bytesToValue:Sf,stringToValue:Af,validate:e=>{if(!gf(e))throw new dt(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:he},{code:43,name:"ipcidr",size:8,bytesToValue:ni("base10"),valueToBytes:oi("base10")},{code:53,name:"dns",size:he},{code:54,name:"dns4",size:he},{code:55,name:"dns6",size:he},{code:56,name:"dnsaddr",size:he},{code:132,name:"sctp",size:16,valueToBytes:Vt,bytesToValue:hr,validate:an},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:he,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:he,bytesToValue:ni("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?oi("base58btc")(e):C.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:si,valueToBytes:wf},{code:445,name:"onion3",size:296,bytesToValue:si,valueToBytes:bf},{code:446,name:"garlic64",size:he},{code:447,name:"garlic32",size:he},{code:448,name:"tls"},{code:449,name:"sni",size:he},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:he,bytesToValue:Cf(Ft),valueToBytes:vf},{code:480,name:"http"},{code:481,name:"http-path",size:he,stringToValue:e=>`/${decodeURIComponent(e)}`,valueToString:e=>encodeURIComponent(e.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:he}];Zy.forEach(e=>{ht.addProtocol(e)});function If(e){let t=[],r=0;for(;r<e.length;){let n=Ds(e,r),o=ht.getProtocol(n),s=tt(n),i=Yy(o,e,r+s),a=0;i>0&&o.size===he&&(a=tt(i));let c=s+a+i,l={code:n,name:o.name,bytes:e.subarray(r,r+c)};if(i>0){let u=r+s+a,d=e.subarray(u,u+i);l.value=o.bytesToValue?.(d)??q(d)}t.push(l),r+=c}return t}function Bf(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=ht.getProtocol(n.code),s=tt(n.code),i,a=0,c=0;n.value!=null&&(i=o.valueToBytes?.(n.value)??Y(n.value),a=i.byteLength,o.size===he&&(c=tt(a)));let l=new Uint8Array(s+c+a),u=0;Qr(n.code,l,u),u+=s,i!=null&&(o.size===he&&(Qr(a,l,u),u+=c),l.set(i,u)),n.bytes=l}r.push(n.bytes),t+=n.bytes.byteLength}return lt(r,t)}function Pf(e){if(e.charAt(0)!=="/")throw new be('String multiaddr must start with "/"');let t=[],r="protocol",n="",o="";for(let s=1;s<e.length;s++){let i=e.charAt(s);i!=="/"&&(r==="protocol"?o+=e.charAt(s):n+=e.charAt(s));let a=s===e.length-1;if(i==="/"||a){let c=ht.getProtocol(o);if(r==="protocol"){if(c.size==null||c.size===0){t.push({code:c.code,name:c.name}),n="",o="",r="protocol";continue}else if(a)throw new be(`Component ${o} was missing value`);r="value"}else if(r==="value"){let l={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new be(`Component ${o} was missing value`);l.value=c.stringToValue?.(n)??n}t.push(l),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new be("Incomplete multiaddr");return t}function _f(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=ht.getProtocol(t.code);if(r==null)throw new be(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function Yy(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:Ds(t,r)}var Xy=Symbol.for("nodejs.util.inspect.custom"),mi=Symbol.for("@multiformats/multiaddr");function Jy(e){if(e==null&&(e="/"),Ht(e))return e.getComponents();if(e instanceof Uint8Array)return If(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),Pf(e);if(Array.isArray(e))return e;throw new be("Must be a string, Uint8Array, Component[], or another Multiaddr")}var to=class e{[mi]=!0;#e;#t;#r;constructor(t="/",r={}){this.#e=Jy(t),r.validate!==!1&&Qy(this)}get bytes(){return this.#r==null&&(this.#r=Bf(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=_f(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(t=>({...t}))]}encapsulate(t){let r=new e(t);return new e([...this.#e,...r.getComponents()],{validate:!1})}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Yn(`Address ${this.toString()} does not contain subaddress: ${r}`);return new e(n.slice(0,o),{validate:!1})}decapsulateCode(t){let r;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===t){r=n;break}return new e(this.#e.slice(0,r),{validate:!1})}equals(t){return Se(this.bytes,t.bytes)}[Xy](){return`Multiaddr(${this.toString()})`}};function Qy(e){e.getComponents().forEach(t=>{let r=ht.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function Ht(e){return!!e?.[mi]}function Q(e){return new to(e)}var wo={};le(wo,{code:()=>Vg,decode:()=>Ti,decodeOptions:()=>Fg,encode:()=>_i,encodeOptions:()=>Kg,name:()=>jg,toByteView:()=>Lu});var eg=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function yi(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let r=tg(e);return r||"Object"}function tg(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(eg.includes(t))return t}var f=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,r){return t===r||t.major===r.major&&t.name===r.name}};f.uint=new f(0,"uint",!0);f.negint=new f(1,"negint",!0);f.bytes=new f(2,"bytes",!0);f.string=new f(3,"string",!0);f.array=new f(4,"array",!1);f.map=new f(5,"map",!1);f.tag=new f(6,"tag",!1);f.float=new f(7,"float",!0);f.false=new f(7,"false",!0);f.true=new f(7,"true",!0);f.null=new f(7,"null",!0);f.undefined=new f(7,"undefined",!0);f.break=new f(7,"break",!0);var x=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var cn=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",rg=new TextEncoder;function ro(e){return cn&&globalThis.Buffer.isBuffer(e)}function qt(e){return e instanceof Uint8Array?ro(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var ng=24,og=200,pr=cn?e=>e.length>=ng?globalThis.Buffer.from(e):Tf(e):e=>e.length>=og?rg.encode(e):Tf(e),ot=e=>Uint8Array.from(e),Df=cn?(e,t,r)=>ro(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Rf=cn?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),qt(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Nf=cn?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function no(e,t){if(ro(e)&&ro(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Tf(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}var Uf=4096;function Of(e){let t=e.length;if(t<=Uf)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Uf));return r}var sg=256,fn=class{constructor(t=sg){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Nf(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Df(n,0,this.cursor)}else r=Rf(this.chunks,this.cursor);return t&&this.reset(),r}},oo=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let r=this.dest.subarray(0,this.cursor);return t&&this.reset(),r}};var D="CBOR decode error:",st="CBOR encode error:",un=[];un[23]=1;un[24]=2;un[25]=3;un[26]=5;un[27]=9;function pt(e,t,r){if(e.length-t<r)throw new Error(`${D} not enough data for type`)}var pe=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Re(e,t,r){pt(e,t,1);let n=e[t];if(r.strict===!0&&n<pe[0])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);return n}function Ne(e,t,r){pt(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<pe[1])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);return n}function Oe(e,t,r){pt(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<pe[2])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);return n}function Le(e,t,r){pt(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<pe[3])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(r.allowBigInt===!0)return s;throw new Error(`${D} integers outside of the safe integer range are not supported`)}function Lf(e,t,r,n){return new x(f.uint,Re(e,t+1,n),2)}function kf(e,t,r,n){return new x(f.uint,Ne(e,t+1,n),3)}function $f(e,t,r,n){return new x(f.uint,Oe(e,t+1,n),5)}function Kf(e,t,r,n){return new x(f.uint,Le(e,t+1,n),9)}function Ke(e,t){return ee(e,0,t.value)}function ee(e,t,r){if(r<pe[0]){let n=Number(r);e.push([t|n])}else if(r<pe[1]){let n=Number(r);e.push([t|24,n])}else if(r<pe[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<pe[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<pe[4]){let o=[t|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),i=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=i&255,i=i>>8,o[3]=i&255,i=i>>8,o[2]=i&255,i=i>>8,o[1]=i&255,e.push(o)}else throw new Error(`${D} encountered BigInt larger than allowable range`)}}Ke.encodedSize=function(t){return ee.encodedSize(t.value)};ee.encodedSize=function(t){return t<pe[0]?1:t<pe[1]?2:t<pe[2]?3:t<pe[3]?5:9};Ke.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Mf(e,t,r,n){return new x(f.negint,-1-Re(e,t+1,n),2)}function Ff(e,t,r,n){return new x(f.negint,-1-Ne(e,t+1,n),3)}function jf(e,t,r,n){return new x(f.negint,-1-Oe(e,t+1,n),5)}var gi=BigInt(-1),Vf=BigInt(1);function Hf(e,t,r,n){let o=Le(e,t+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new x(f.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${D} integers outside of the safe integer range are not supported`);return new x(f.negint,gi-BigInt(o),9)}function so(e,t){let r=t.value,n=typeof r=="bigint"?r*gi-Vf:r*-1-1;ee(e,t.type.majorEncoded,n)}so.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*gi-Vf:r*-1-1;return n<pe[0]?1:n<pe[1]?2:n<pe[2]?3:n<pe[3]?5:9};so.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function ln(e,t,r,n){pt(e,t,r+n);let o=e.slice(t+r,t+r+n);return new x(f.bytes,o,r+n)}function qf(e,t,r,n){return ln(e,t,1,r)}function zf(e,t,r,n){return ln(e,t,2,Re(e,t+1,n))}function Gf(e,t,r,n){return ln(e,t,3,Ne(e,t+1,n))}function Wf(e,t,r,n){return ln(e,t,5,Oe(e,t+1,n))}function Zf(e,t,r,n){let o=Le(e,t+1,n);if(typeof o=="bigint")throw new Error(`${D} 64-bit integer bytes lengths not supported`);return ln(e,t,9,o)}function io(e){return e.encodedBytes===void 0&&(e.encodedBytes=f.equals(e.type,f.string)?pr(e.value):e.value),e.encodedBytes}function mr(e,t){let r=io(t);ee(e,t.type.majorEncoded,r.length),e.push(r)}mr.encodedSize=function(t){let r=io(t);return ee.encodedSize(r.length)+r.length};mr.compareTokens=function(t,r){return ag(io(t),io(r))};function ag(e,t){return e.length<t.length?-1:e.length>t.length?1:no(e,t)}var Yf=new TextDecoder,fg=32;function ug(e,t,r){if(r-t<fg){let o="";for(let s=t;s<r;s++){let i=e[s];if(i&128)return Yf.decode(e.subarray(t,r));o+=String.fromCharCode(i)}return o}return Yf.decode(e.subarray(t,r))}function dn(e,t,r,n,o){let s=r+n;pt(e,t,s);let i=new x(f.string,ug(e,t+r,t+s),s);return o.retainStringBytes===!0&&(i.byteValue=e.slice(t+r,t+s)),i}function Xf(e,t,r,n){return dn(e,t,1,r,n)}function Jf(e,t,r,n){return dn(e,t,2,Re(e,t+1,n),n)}function Qf(e,t,r,n){return dn(e,t,3,Ne(e,t+1,n),n)}function eu(e,t,r,n){return dn(e,t,5,Oe(e,t+1,n),n)}function tu(e,t,r,n){let o=Le(e,t+1,n);if(typeof o=="bigint")throw new Error(`${D} 64-bit integer string lengths not supported`);return dn(e,t,9,o,n)}var ru=mr;function yr(e,t,r,n){return new x(f.array,n,r)}function nu(e,t,r,n){return yr(e,t,1,r)}function ou(e,t,r,n){return yr(e,t,2,Re(e,t+1,n))}function su(e,t,r,n){return yr(e,t,3,Ne(e,t+1,n))}function iu(e,t,r,n){return yr(e,t,5,Oe(e,t+1,n))}function au(e,t,r,n){let o=Le(e,t+1,n);if(typeof o=="bigint")throw new Error(`${D} 64-bit integer array lengths not supported`);return yr(e,t,9,o)}function cu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${D} indefinite length items not allowed`);return yr(e,t,1,1/0)}function ao(e,t){ee(e,f.array.majorEncoded,t.value)}ao.compareTokens=Ke.compareTokens;ao.encodedSize=function(t){return ee.encodedSize(t.value)};function gr(e,t,r,n){return new x(f.map,n,r)}function fu(e,t,r,n){return gr(e,t,1,r)}function uu(e,t,r,n){return gr(e,t,2,Re(e,t+1,n))}function lu(e,t,r,n){return gr(e,t,3,Ne(e,t+1,n))}function du(e,t,r,n){return gr(e,t,5,Oe(e,t+1,n))}function hu(e,t,r,n){let o=Le(e,t+1,n);if(typeof o=="bigint")throw new Error(`${D} 64-bit integer map lengths not supported`);return gr(e,t,9,o)}function pu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${D} indefinite length items not allowed`);return gr(e,t,1,1/0)}function co(e,t){ee(e,f.map.majorEncoded,t.value)}co.compareTokens=Ke.compareTokens;co.encodedSize=function(t){return ee.encodedSize(t.value)};function mu(e,t,r,n){return new x(f.tag,r,1)}function yu(e,t,r,n){return new x(f.tag,Re(e,t+1,n),2)}function gu(e,t,r,n){return new x(f.tag,Ne(e,t+1,n),3)}function wu(e,t,r,n){return new x(f.tag,Oe(e,t+1,n),5)}function bu(e,t,r,n){return new x(f.tag,Le(e,t+1,n),9)}function fo(e,t){ee(e,f.tag.majorEncoded,t.value)}fo.compareTokens=Ke.compareTokens;fo.encodedSize=function(t){return ee.encodedSize(t.value)};var wi=20,bi=21,xi=22,Ei=23;function xu(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${D} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new x(f.null,null,1):new x(f.undefined,void 0,1)}function Eu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${D} indefinite length items not allowed`);return new x(f.break,void 0,1)}function Si(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${D} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${D} Infinity values are not supported`)}return new x(f.float,e,t)}function Su(e,t,r,n){return Si(Ai(e,t+1),3,n)}function Au(e,t,r,n){return Si(vi(e,t+1),5,n)}function vu(e,t,r,n){return Si(Pu(e,t+1),9,n)}function h