kubo-rpc-client
Version:
A client library for the Kubo RPC API
2 lines • 276 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 rg=Object.create;var uo=Object.defineProperty;var ng=Object.getOwnPropertyDescriptor;var og=Object.getOwnPropertyNames;var sg=Object.getPrototypeOf,ig=Object.prototype.hasOwnProperty;var Mt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),de=(t,e)=>{for(var r in e)uo(t,r,{get:e[r],enumerable:!0})},Mu=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of og(e))!ig.call(t,o)&&o!==r&&uo(t,o,{get:()=>e[o],enumerable:!(n=ng(e,o))||n.enumerable});return t};var $t=(t,e,r)=>(r=t!=null?rg(sg(t)):{},Mu(e||!t||!t.__esModule?uo(r,"default",{value:t,enumerable:!0}):r,t)),ag=t=>Mu(uo({},"__esModule",{value:!0}),t);var md=Mt((LA,pd)=>{function zx(){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)}pd.exports=zx});var Vn=Mt((HA,vd)=>{"use strict";function bd(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function qx(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return bd(t,r)}catch{r.message=t.message,r.stack=t.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(t)),bd(new o,r)}}vd.exports=qx});var ah=Mt(on=>{"use strict";var w1="[object ArrayBuffer]",Rt=class t{static isArrayBuffer(e){return Object.prototype.toString.call(e)===w1}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,r){if(e.constructor===r)return e;if(this.isArrayBuffer(e))return new r(e);if(this.isArrayBufferView(e))return new r(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,r){let n=t.toUint8Array(e),o=t.toUint8Array(r);if(n.length!==o.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==o[s])return!1;return!0}static concat(...e){let r;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?r=e[0]:e[e.length-1]instanceof Function?r=e.slice(0,e.length-1):r=e;let n=0;for(let i of r)n+=i.byteLength;let o=new Uint8Array(n),s=0;for(let i of r){let a=this.toUint8Array(i);o.set(a,s),s+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},Hc="string",x1=/^[0-9a-f\s]+$/i,b1=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,v1=/^[a-zA-Z0-9-_]+$/,ds=class{static fromString(e){let r=unescape(encodeURIComponent(e)),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o);return n.buffer}static toString(e){let r=Rt.toUint8Array(e),n="";for(let s=0;s<r.length;s++)n+=String.fromCharCode(r[s]);return decodeURIComponent(escape(n))}},Xe=class{static toString(e,r=!1){let n=Rt.toArrayBuffer(e),o=new DataView(n),s="";for(let i=0;i<n.byteLength;i+=2){let a=o.getUint16(i,r);s+=String.fromCharCode(a)}return s}static fromString(e,r=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let s=0;s<e.length;s++)o.setUint16(s*2,e.charCodeAt(s),r);return n}},hs=class t{static isHex(e){return typeof e===Hc&&x1.test(e)}static isBase64(e){return typeof e===Hc&&b1.test(e)}static isBase64Url(e){return typeof e===Hc&&v1.test(e)}static ToString(e,r="utf8"){let n=Rt.toUint8Array(e);switch(r.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Xe.toString(n,!0);case"utf16":case"utf16be":return Xe.toString(n);default:throw new Error(`Unknown type of encoding '${r}'`)}}static FromString(e,r="utf8"){if(!e)return new ArrayBuffer(0);switch(r.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Xe.fromString(e,!0);case"utf16":case"utf16be":return Xe.fromString(e);default:throw new Error(`Unknown type of encoding '${r}'`)}}static ToBase64(e){let r=Rt.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(r,"binary");return btoa(n)}else return Buffer.from(r).toString("base64")}static FromBase64(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isBase64(r))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(r)):new Uint8Array(Buffer.from(r,"base64")).buffer}static FromBase64Url(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isBase64Url(r))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(r.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,r=t.DEFAULT_UTF8_ENCODING){switch(r){case"ascii":return this.FromBinary(e);case"utf8":return ds.fromString(e);case"utf16":case"utf16be":return Xe.fromString(e);case"utf16le":case"usc2":return Xe.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${r}'`)}}static ToUtf8String(e,r=t.DEFAULT_UTF8_ENCODING){switch(r){case"ascii":return this.ToBinary(e);case"utf8":return ds.toString(e);case"utf16":case"utf16be":return Xe.toString(e);case"utf16le":case"usc2":return Xe.toString(e,!0);default:throw new Error(`Unknown type of encoding '${r}'`)}}static FromBinary(e){let r=e.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let r=Rt.toUint8Array(e),n="";for(let o=0;o<r.length;o++)n+=String.fromCharCode(r[o]);return n}static ToHex(e){let r=Rt.toUint8Array(e),n="",o=r.length;for(let s=0;s<o;s++){let i=r[s];i<16&&(n+="0"),n+=i.toString(16)}return n}static FromHex(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isHex(r))throw new TypeError("Argument 'hexString' is not HEX encoded");r.length%2&&(r=`0${r}`);let n=new Uint8Array(r.length/2);for(let o=0;o<r.length;o=o+2){let s=r.slice(o,o+2);n[o/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,r=!1){return Xe.toString(e,r)}static FromUtf16String(e,r=!1){return Xe.fromString(e,r)}static Base64Padding(e){let r=4-e.length%4;if(r<4)for(let n=0;n<r;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};hs.DEFAULT_UTF8_ENCODING="utf8";function E1(t,...e){let r=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let s in o)r[s]=o[s]}return r}function B1(...t){let e=t.map(o=>o.byteLength).reduce((o,s)=>o+s),r=new Uint8Array(e),n=0;return t.map(o=>new Uint8Array(o)).forEach(o=>{for(let s of o)r[n++]=s}),r.buffer}function A1(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let o=0;o<t.byteLength;o++)if(r[o]!==n[o])return!1;return!0}on.BufferSourceConverter=Rt;on.Convert=hs;on.assign=E1;on.combine=B1;on.isEqual=A1});var fm=Mt((oU,lm)=>{"use strict";lm.exports=t=>{if(Object.prototype.toString.call(t)!=="[object Object]")return!1;let e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}});var ym=Mt((mm,gm)=>{"use strict";var gi=fm(),{hasOwnProperty:hm}=Object.prototype,{propertyIsEnumerable:m2}=Object,dn=(t,e,r)=>Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0}),g2=mm,dm={concatArrays:!1,ignoreUndefined:!1},yi=t=>{let e=[];for(let r in t)hm.call(t,r)&&e.push(r);if(Object.getOwnPropertySymbols){let r=Object.getOwnPropertySymbols(t);for(let n of r)m2.call(t,n)&&e.push(n)}return e};function hn(t){return Array.isArray(t)?y2(t):gi(t)?w2(t):t}function y2(t){let e=t.slice(0,0);return yi(t).forEach(r=>{dn(e,r,hn(t[r]))}),e}function w2(t){let e=Object.getPrototypeOf(t)===null?Object.create(null):{};return yi(t).forEach(r=>{dn(e,r,hn(t[r]))}),e}var pm=(t,e,r,n)=>(r.forEach(o=>{typeof e[o]>"u"&&n.ignoreUndefined||(o in t&&t[o]!==Object.getPrototypeOf(t)?dn(t,o,mu(t[o],e[o],n)):dn(t,o,hn(e[o])))}),t),x2=(t,e,r)=>{let n=t.slice(0,0),o=0;return[t,e].forEach(s=>{let i=[];for(let a=0;a<s.length;a++)hm.call(s,a)&&(i.push(String(a)),s===t?dn(n,o++,s[a]):dn(n,o++,hn(s[a])));n=pm(n,s,yi(s).filter(a=>!i.includes(a)),r)}),n};function mu(t,e,r){return r.concatArrays&&Array.isArray(t)&&Array.isArray(e)?x2(t,e,r):!gi(e)||!gi(t)?hn(e):pm(t,e,yi(e),r)}gm.exports=function(...t){let e=mu(hn(dm),this!==g2&&this||{},dm),r={_:{}};for(let n of t)if(n!==void 0){if(!gi(n))throw new TypeError("`"+n+"` is not an Option Object");r=mu(r,{_:n},e)}return r._}});var wu=Mt((lU,Sm)=>{"use strict";var v2=typeof navigator<"u"&&navigator.product==="ReactNative";function E2(){return v2?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var io=self.URL,Am=E2(),yu=class{constructor(e="",r=Am){this.super=new io(e,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(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set username(e){this.super.username=e}static createObjectURL(e){return io.createObjectURL(e)}static revokeObjectURL(e){io.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function B2(t){if(typeof t=="string")return new io(t).toString();if(!(t instanceof io)){let e=t.username&&t.password?`${t.username}:${t.password}@`:"",r=t.auth?t.auth+"@":"",n=t.port?":"+t.port:"",o=t.protocol?t.protocol+"//":"",s=t.host||"",i=t.hostname||"",a=t.search||(t.query?"?"+t.query:""),c=t.hash||"",f=t.pathname||"",u=t.path||f+a;return`${o}${e||r}${s||i+n}${u}${c}`}}Sm.exports={URLWithLegacySupport:yu,URLSearchParams:self.URLSearchParams,defaultBase:Am,format:B2}});var Im=Mt((fU,Cm)=>{"use strict";var{URLWithLegacySupport:km,format:A2}=wu();Cm.exports=(t,e={},r={},n)=>{let o=e.protocol?e.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let s;try{s=new km(t)}catch{s={}}let i=Object.assign({},e,{protocol:o||s.protocol,host:e.host||s.host});return new km(t,A2(i)).toString()}});var Tm=Mt((dU,Um)=>{"use strict";var{URLWithLegacySupport:S2,format:k2,URLSearchParams:C2,defaultBase:I2}=wu(),U2=Im();Um.exports={URL:S2,URLSearchParams:C2,format:k2,relative:U2,defaultBase:I2}});var iv={};de(iv,{CID:()=>A,RoutingEventTypes:()=>au,RoutingMessageType:()=>cu,create:()=>ov,createBitswap:()=>eu,createBlock:()=>tu,createBootstrap:()=>ru,createConfig:()=>nu,createDAG:()=>iu,createDHT:()=>uu,createDiag:()=>lu,createFiles:()=>du,createKey:()=>hu,createKuboRPCClient:()=>ov,createLog:()=>Bu,createName:()=>Au,createObject:()=>Su,createPin:()=>ku,createPubsub:()=>Cu,createRefs:()=>Iu,createRepo:()=>Uu,createRouting:()=>Tu,createStats:()=>Nu,createSwarm:()=>Pu,multiaddr:()=>re,readURLContent:()=>G0,urlSource:()=>sv});var Oi={};de(Oi,{base58btc:()=>se,base58flickr:()=>hg});var cv=new Uint8Array(0);function $u(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function et(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function ju(t){return new TextEncoder().encode(t)}function zu(t){return new TextDecoder().decode(t)}function cg(t,e){if(t.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<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var w=0,m=0,v=0,k=g.length;v!==k&&g[v]===0;)v++,w++;for(var y=(k-v)*u+1>>>0,C=new Uint8Array(y);v!==k;){for(var D=g[v],_=0,U=y-1;(D!==0||_<m)&&U!==-1;U--,_++)D+=256*C[U]>>>0,C[U]=D%a>>>0,D=D/a>>>0;if(D!==0)throw new Error("Non-zero carry");m=_,v++}for(var T=y-m;T!==y&&C[T]===0;)T++;for(var P=c.repeat(w);T<y;++T)P+=t.charAt(C[T]);return P}function p(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var w=0;if(g[w]!==" "){for(var m=0,v=0;g[w]===c;)m++,w++;for(var k=(g.length-w)*f+1>>>0,y=new Uint8Array(k);g[w];){var C=r[g.charCodeAt(w)];if(C===255)return;for(var D=0,_=k-1;(C!==0||D<v)&&_!==-1;_--,D++)C+=a*y[_]>>>0,y[_]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");v=D,w++}if(g[w]!==" "){for(var U=k-v;U!==k&&y[U]===0;)U++;for(var T=new Uint8Array(m+(k-U)),P=m;U!==k;)T[P++]=y[U++];return T}}}function b(g){var w=p(g);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:b}}var ug=cg,lg=ug,Ku=lg;var Ri=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},_i=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,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(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Gu(this,e)}},Li=class{decoders;constructor(e){this.decoders=e}or(e){return Gu(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Gu(t,e){return new Li({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Di=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ri(e,r,n),this.decoder=new _i(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Sr({name:t,prefix:e,encode:r,decode:n}){return new Di(t,e,r,n)}function jt({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Ku(r,t);return Sr({prefix:e,name:t,encode:n,decode:s=>et(o(s))})}function fg(t,e,r,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),a=0,c=0,f=0;for(let u=0;u<s;++u){let l=o[t[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,i[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function dg(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<r-i]),n)for(;s.length*r&7;)s+="=";return s}function fe({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return Sr({prefix:e,name:t,encode(o){return dg(o,n,r)},decode(o){return fg(o,n,r,t)}})}var se=jt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),hg=jt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Vi={};de(Vi,{base32:()=>tt,base32hex:()=>yg,base32hexpad:()=>xg,base32hexpadupper:()=>bg,base32hexupper:()=>wg,base32pad:()=>mg,base32padupper:()=>gg,base32upper:()=>pg,base32z:()=>vg});var tt=fe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pg=fe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mg=fe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gg=fe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yg=fe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wg=fe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xg=fe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),bg=fe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vg=fe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Fi={};de(Fi,{base36:()=>bn,base36upper:()=>Eg});var bn=jt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Eg=jt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Bg=Zu,Wu=128,Ag=127,Sg=~Ag,kg=Math.pow(2,31);function Zu(t,e,r){e=e||[],r=r||0;for(var n=r;t>=kg;)e[r++]=t&255|Wu,t/=128;for(;t&Sg;)e[r++]=t&255|Wu,t>>>=7;return e[r]=t|0,Zu.bytes=r-n+1,e}var Cg=Hi,Ig=128,Ju=127;function Hi(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw Hi.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Ju)<<o:(i&Ju)*Math.pow(2,o),o+=7}while(i>=Ig);return Hi.bytes=s-n,r}var Ug=Math.pow(2,7),Tg=Math.pow(2,14),Ng=Math.pow(2,21),Pg=Math.pow(2,28),Rg=Math.pow(2,35),_g=Math.pow(2,42),Lg=Math.pow(2,49),Dg=Math.pow(2,56),Og=Math.pow(2,63),Vg=function(t){return t<Ug?1:t<Tg?2:t<Ng?3:t<Pg?4:t<Rg?5:t<_g?6:t<Lg?7:t<Dg?8:t<Og?9:10},Fg={encode:Bg,decode:Cg,encodingLength:Vg},Hg=Fg,vn=Hg;function En(t,e=0){return[vn.decode(t,e),vn.decode.bytes]}function kr(t,e,r=0){return vn.encode(t,e,r),e}function Cr(t){return vn.encodingLength(t)}function rt(t,e){let r=e.byteLength,n=Cr(t),o=n+Cr(r),s=new Uint8Array(o+r);return kr(t,s,0),kr(r,s,n),s.set(e,o),new Ir(t,r,e,s)}function ar(t){let e=et(t),[r,n]=En(e),[o,s]=En(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Ir(r,o,i,e)}function Xu(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&$u(t.bytes,r.bytes)}}var Ir=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Yu(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return $g(r,Mi(t),e??se.encoder);default:return jg(r,Mi(t),e??tt.encoder)}}var Qu=new WeakMap;function Mi(t){let e=Qu.get(t);if(e==null){let r=new Map;return Qu.set(t,r),r}return e}var A=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,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:e,multihash:r}=this;if(e!==Bn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==zg)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.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:e,digest:r}=this.multihash,n=rt(e,r);return t.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(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&Xu(e.multihash,n.multihash)}toString(e){return Yu(this,e)}toJSON(){return{"/":Yu(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new t(n,o,s,i??el(n,o,s.bytes))}else if(r[qg]===!0){let{version:n,multihash:o,code:s}=r,i=ar(o);return t.create(n,s,i)}else return null}static create(e,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(e){case 0:{if(r!==Bn)throw new Error(`Version 0 CID must use dag-pb (code: ${Bn}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=el(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Bn,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=et(e.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 Ir(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,p]=En(e.subarray(r));return r+=p,l},o=n(),s=Bn;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(),f=r+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,r){let[n,o]=Mg(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Mi(s).set(n,e),s}};function Mg(t,e){switch(t[0]){case"Q":{let r=e??se;return[se.prefix,r.decode(`${se.prefix}${t}`)]}case se.prefix:{let r=e??se;return[se.prefix,r.decode(t)]}case tt.prefix:{let r=e??tt;return[tt.prefix,r.decode(t)]}case bn.prefix:{let r=e??bn;return[bn.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function $g(t,e,r){let{prefix:n}=r;if(n!==se.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o}function jg(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o}var Bn=112,zg=18;function el(t,e,r){let n=Cr(t),o=n+Cr(e),s=new Uint8Array(o+r.byteLength);return kr(t,s,0),kr(e,s,n),s.set(r,o),s}var qg=Symbol.for("@ipld/js-cid/CID");function Ke(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var $i={};de($i,{base10:()=>Kg});var Kg=jt({prefix:"9",name:"base10",alphabet:"0123456789"});var ji={};de(ji,{base16:()=>Gg,base16upper:()=>Wg});var Gg=fe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Wg=fe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var zi={};de(zi,{base2:()=>Jg});var Jg=fe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qi={};de(qi,{base256emoji:()=>ey});var tl=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}"),Zg=tl.reduce((t,e,r)=>(t[r]=e,t),[]),Xg=tl.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Yg(t){return t.reduce((e,r)=>(e+=Zg[r],e),"")}function Qg(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Xg[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var ey=Sr({prefix:"\u{1F680}",name:"base256emoji",encode:Yg,decode:Qg});var Ki={};de(Ki,{base64:()=>Ur,base64pad:()=>ty,base64url:()=>An,base64urlpad:()=>ry});var Ur=fe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ty=fe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),An=fe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ry=fe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Gi={};de(Gi,{base8:()=>ny});var ny=fe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Wi={};de(Wi,{identity:()=>oy});var oy=Sr({prefix:"\0",name:"identity",encode:t=>zu(t),decode:t=>ju(t)});var Ji={};de(Ji,{code:()=>cy,decode:()=>ly,encode:()=>uy,name:()=>ay});var sy=new TextEncoder,iy=new TextDecoder,ay="json",cy=512;function uy(t){return sy.encode(JSON.stringify(t))}function ly(t){return JSON.parse(iy.decode(t))}var Zi={};de(Zi,{code:()=>dy,decode:()=>py,encode:()=>hy,name:()=>fy});var fy="raw",dy=85;function hy(t){return et(t)}function py(t){return et(t)}var Xi={};de(Xi,{identity:()=>Ge});var rl=0,my="identity",nl=et;function gy(t){return rt(rl,nl(t))}var Ge={code:rl,name:my,encode:nl,digest:gy};var ea={};de(ea,{sha256:()=>Sn,sha512:()=>yy});function Qi({name:t,code:e,encode:r}){return new Yi(t,e,r)}var Yi=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?rt(this.code,r):r.then(n=>rt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function sl(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var Sn=Qi({name:"sha2-256",code:18,encode:sl("SHA-256")}),yy=Qi({name:"sha2-512",code:19,encode:sl("SHA-512")});var ur={...Wi,...zi,...Gi,...$i,...ji,...Vi,...Fi,...Oi,...Ki,...qi},il={...ea,...Xi},al={raw:Zi,json:Ji};function nt(t=0){return new Uint8Array(t)}function ul(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var cl=ul("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ta=ul("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=nt(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),wy={utf8:cl,"utf-8":cl,hex:ur.base16,latin1:ta,ascii:ta,binary:ta,...ur},fo=wy;function ee(t,e="utf8"){let r=fo[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var xy=Math.pow(2,7),by=Math.pow(2,14),vy=Math.pow(2,21),ra=Math.pow(2,28),na=Math.pow(2,35),oa=Math.pow(2,42),sa=Math.pow(2,49),Y=128,Ce=127;function De(t){if(t<xy)return 1;if(t<by)return 2;if(t<vy)return 3;if(t<ra)return 4;if(t<na)return 5;if(t<oa)return 6;if(t<sa)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ia(t,e,r=0){switch(De(t)){case 8:e[r++]=t&255|Y,t/=128;case 7:e[r++]=t&255|Y,t/=128;case 6:e[r++]=t&255|Y,t/=128;case 5:e[r++]=t&255|Y,t/=128;case 4:e[r++]=t&255|Y,t>>>=7;case 3:e[r++]=t&255|Y,t>>>=7;case 2:e[r++]=t&255|Y,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function Ey(t,e,r=0){switch(De(t)){case 8:e.set(r++,t&255|Y),t/=128;case 7:e.set(r++,t&255|Y),t/=128;case 6:e.set(r++,t&255|Y),t/=128;case 5:e.set(r++,t&255|Y),t/=128;case 4:e.set(r++,t&255|Y),t>>>=7;case 3:e.set(r++,t&255|Y),t>>>=7;case 2:e.set(r++,t&255|Y),t>>>=7;case 1:{e.set(r++,t&255),t>>>=7;break}default:throw new Error("unreachable")}return e}function aa(t,e){let r=t[e],n=0;if(n+=r&Ce,r<Y||(r=t[e+1],n+=(r&Ce)<<7,r<Y)||(r=t[e+2],n+=(r&Ce)<<14,r<Y)||(r=t[e+3],n+=(r&Ce)<<21,r<Y)||(r=t[e+4],n+=(r&Ce)*ra,r<Y)||(r=t[e+5],n+=(r&Ce)*na,r<Y)||(r=t[e+6],n+=(r&Ce)*oa,r<Y)||(r=t[e+7],n+=(r&Ce)*sa,r<Y))return n;throw new RangeError("Could not decode varint")}function By(t,e){let r=t.get(e),n=0;if(n+=r&Ce,r<Y||(r=t.get(e+1),n+=(r&Ce)<<7,r<Y)||(r=t.get(e+2),n+=(r&Ce)<<14,r<Y)||(r=t.get(e+3),n+=(r&Ce)<<21,r<Y)||(r=t.get(e+4),n+=(r&Ce)*ra,r<Y)||(r=t.get(e+5),n+=(r&Ce)*na,r<Y)||(r=t.get(e+6),n+=(r&Ce)*oa,r<Y)||(r=t.get(e+7),n+=(r&Ce)*sa,r<Y))return n;throw new RangeError("Could not decode varint")}function Tr(t,e,r=0){return e==null&&(e=nt(De(t))),e instanceof Uint8Array?ia(t,e,r):Ey(t,e,r)}function lr(t,e=0){return t instanceof Uint8Array?aa(t,e):By(t,e)}function gt(t,e){e==null&&(e=t.reduce((o,s)=>o+s.length,0));let r=nt(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}var ho=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();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(e){return this.readAtomically(()=>{let r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let p=Number.parseInt(l,e);if(!Number.isNaN(p))return p});if(u===void 0)break;if(s*=e,s+=u,s>f||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=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]=e(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]=e(s.subarray(0,i));return r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var fl=45,Ay=15,Nr=new ho;function ca(t){if(!(t.length>Ay))return Nr.new(t).parseWith(()=>Nr.readIPv4Addr())}function ua(t){if(t.includes("%")&&(t=t.split("%")[0]),!(t.length>fl))return Nr.new(t).parseWith(()=>Nr.readIPv6Addr())}function po(t,e=!1){if(t.includes("%")&&(t=t.split("%")[0]),t.length>fl)return;let r=Nr.new(t).parseWith(()=>Nr.readIPAddr());if(r)return e&&r.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,r[0],r[1],r[2],r[3]]):r}var pE=parseInt("0xFFFF",16),mE=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function te(t,e="utf8"){let r=fo[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function pl(t){return!!ca(t)}function ml(t){return!!ua(t)}function mo(t){return!!po(t)}var gl=pl,Uy=ml,la=function(t){let e=0;if(t=t.toString().trim(),gl(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(Uy(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let s=gl(r[n]),i;s&&(i=la(r[n]),r[n]=ee(i.slice(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,ee(i.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},yl=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let o=[];for(let s=0;s<r;s++)o.push(t[e+s]);return o.join(".")}if(r===16){let o=[];for(let s=0;s<r;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Pr={},fa={},Ny=[[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"]];Ny.forEach(t=>{let e=Py(...t);fa[e.code]=e,Pr[e.name]=e});function Py(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:!!n,path:!!o}}function j(t){if(typeof t=="number"){if(fa[t]!=null)return fa[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(Pr[t]!=null)return Pr[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var eB=j("ip4"),tB=j("ip6"),rB=j("ipcidr");function ma(t,e){switch(j(t).code){case 4:case 41:return _y(e);case 42:return pa(e);case 43:return ee(e,"base10");case 6:case 273:case 33:case 132:return bl(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return pa(e);case 421:return Vy(e);case 444:return xl(e);case 445:return xl(e);case 466:return Oy(e);case 481:return globalThis.encodeURIComponent(pa(e));default:return ee(e,"base16")}}function ga(t,e){switch(j(t).code){case 4:return wl(e);case 41:return wl(e);case 42:return ha(e);case 43:return te(e,"base10");case 6:case 273:case 33:case 132:return ya(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ha(e);case 421:return Ly(e);case 444:return Fy(e);case 445:return Hy(e);case 466:return Dy(e);case 481:return ha(globalThis.decodeURIComponent(e));default:return te(e,"base16")}}var da=Object.values(ur).map(t=>t.decoder),Ry=function(){let t=da[0].or(da[1]);return da.slice(2).forEach(e=>t=t.or(e)),t}();function wl(t){if(!mo(t))throw new Error("invalid ip address");return la(t)}function _y(t){let e=yl(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!mo(e))throw new Error("invalid ip address");return e}function ya(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function bl(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function ha(t){let e=te(t),r=Uint8Array.from(Tr(e.length));return gt([r,e],r.length+e.length)}function pa(t){let e=lr(t);if(t=t.slice(De(e)),t.length!==e)throw new Error("inconsistent lengths");return ee(t)}function Ly(t){let e;t[0]==="Q"||t[0]==="1"?e=ar(se.decode(`z${t}`)).bytes:e=A.parse(t).multihash.bytes;let r=Uint8Array.from(Tr(e.length));return gt([r,e],r.length+e.length)}function Dy(t){let e=Ry.decode(t),r=Uint8Array.from(Tr(e.length));return gt([r,e],r.length+e.length)}function Oy(t){let e=lr(t),r=t.slice(De(e));if(r.length!==e)throw new Error("inconsistent lengths");return"u"+ee(r,"base64url")}function Vy(t){let e=lr(t),r=t.slice(De(e));if(r.length!==e)throw new Error("inconsistent lengths");return ee(r,"base58btc")}function Fy(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let r=tt.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ya(n);return gt([r,o],r.length+o.length)}function Hy(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=tt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ya(n);return gt([r,o],r.length+o.length)}function xl(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=ee(e,"base32"),o=bl(r);return`${n}:${o}`}function vl(t){t=wa(t);let e=[],r=[],n=null,o=t.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<o.length;s++){let i=o[s],a=j(i);if(a.size===0){e.push([a.code]),r.push([a.code]);continue}if(s++,s>=o.length)throw new go("invalid address: "+t);if(a.path===!0){n=wa(o.slice(s).join("/")),e.push([a.code,ga(a.code,n)]),r.push([a.code,n]);break}let c=ga(a.code,o[s]);e.push([a.code,c]),r.push([a.code,ma(a.code,c)])}return{string:El(r),bytes:ba(e),tuples:e,stringTuples:r,path:n}}function xa(t){let e=[],r=[],n=null,o=0;for(;o<t.length;){let s=lr(t,o),i=De(s),a=j(s),c=My(a,t.slice(o+i));if(c===0){e.push([s]),r.push([s]),o+=i;continue}let f=t.slice(o+i,o+i+c);if(o+=c+i,o>t.length)throw new go("Invalid address Uint8Array: "+ee(t,"base16"));e.push([s,f]);let u=ma(s,f);if(r.push([s,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(t),string:El(r),tuples:e,stringTuples:r,path:n}}function El(t){let e=[];return t.map(r=>{let n=j(r[0]);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),wa(e.join("/"))}function ba(t){return gt(t.map(e=>{let r=j(e[0]),n=Uint8Array.from(Tr(r.code));return e.length>1&&e[1]!=null&&(n=gt([n,e[1]])),n}))}function My(t,e){if(t.size>0)return t.size/8;if(t.size===0)return 0;{let r=lr(e instanceof Uint8Array?e:Uint8Array.from(e));return r+De(r)}}function wa(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}var go=class extends Error{static name="ParseError";name="ParseError";constructor(e){super(`Error parsing address: ${e}`)}};var $y=Symbol.for("nodejs.util.inspect.custom"),Ea=Symbol.for("@multiformats/js-multiaddr/multiaddr"),jy=[j("dns").code,j("dns4").code,j("dns6").code,j("dnsaddr").code],va=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},yo=class t{bytes;#t;#e;#r;#n;[Ea]=!0;constructor(e){e==null&&(e="");let r;if(e instanceof Uint8Array)r=xa(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);r=vl(e)}else if(fr(e))r=xa(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#t=r.string,this.#e=r.tuples,this.#r=r.stringTuples,this.#n=r.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,r,n,o,s="",i=j("tcp"),a=j("udp"),c=j("ip4"),f=j("ip6"),u=j("dns6"),l=j("ip6zone");for(let[b,g]of this.stringTuples())b===l.code&&(s=`%${g??""}`),jy.includes(b)&&(r=i.name==="tcp"?"tcp":"udp",o=443,n=`${g??""}${s}`,e=b===u.code?6:4),(b===i.code||b===a.code)&&(r=j(b).name==="tcp"?"tcp":"udp",o=parseInt(g??"")),(b===c.code||b===f.code)&&(r=j(b).name==="tcp"?"tcp":"udp",n=`${g??""}${s}`,e=b===f.code?6:4);if(e==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:r,port:o}}protos(){return this.#e.map(([e])=>Object.assign({},j(e)))}protoCodes(){return this.#e.map(([e])=>e)}protoNames(){return this.#e.map(([e])=>j(e).name)}tuples(){return this.#e.map(([e,r])=>r==null?[e]:[e,r])}stringTuples(){return this.#r.map(([e,r])=>r==null?[e]:[e,r])}encapsulate(e){return e=new t(e),new t(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new t(n.slice(0,o))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new t(ba(r.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Pr.p2p.code&&e.push([n,o]),n===Pr["p2p-circuit"].code&&(e=[])});let r=e.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?ee(se.decode(`z${n}`),"base58btc"):ee(A.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Ke(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=Bl.get(r.name);if(n==null)throw new va(`no available resolver for ${r.name}`);return(await n(this,e)).map(s=>re(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[$y](){return`Multiaddr(${this.#t})`}};var Bl=new Map;function fr(t){return!!t?.[Ea]}function re(t){return new yo(t)}var Po={};de(Po,{code:()=>Sw,decode:()=>_a,decodeOptions:()=>Bw,encode:()=>Ra,encodeOptions:()=>vw,name:()=>Aw,toByteView:()=>Uf});var zy=["string","number","bigint","symbol"],qy=["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 Al(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(zy.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(Ky(t))return"Buffer";let r=Gy(t);return r||"Object"}function Ky(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function Gy(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(qy.includes(e))return e}var d=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};d.uint=new d(0,"uint",!0);d.negint=new d(1,"negint",!0);d.bytes=new d(2,"bytes",!0);d.string=new d(3,"string",!0);d.array=new d(4,"array",!1);d.map=new d(5,"map",!1);d.tag=new d(6,"tag",!1);d.float=new d(7,"float",!0);d.false=new d(7,"false",!0);d.true=new d(7,"true",!0);d.null=new d(7,"null",!0);d.undefined=new d(7,"undefined",!0);d.break=new d(7,"break",!0);var E=class{constructor(e,r,n){this.type=e,this.value=r,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",Wy=new TextDecoder,Jy=new TextEncoder;function wo(t){return Rr&&globalThis.Buffer.isBuffer(t)}function kn(t){return t instanceof Uint8Array?wo(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var Il=Rr?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):kl(t,e,r):(t,e,r)=>r-e>64?Wy.decode(t.subarray(e,r)):kl(t,e,r),xo=Rr?t=>t.length>64?globalThis.Buffer.from(t):Sl(t):t=>t.length>64?Jy.encode(t):Sl(t),yt=t=>Uint8Array.from(t),_r=Rr?(t,e,r)=>wo(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Ul=Rr?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),kn(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Tl=Rr?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function Nl(t,e){if(wo(t)&&wo(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function Sl(t){let e=[],r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128)}return e}function kl(t,e,r){let n=[];for(;e<r;){let o=t[e],s=null,i=o>239?4:o>223?3:o>191?2:1;if(e+i<=r){let a,c,f,u;switch(i){case 1:o<128&&(s=o);break;case 2:a=t[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(s=u));break;case 3:a=t[e+1],c=t[e+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(s=u));break;case 4:a=t[e+1],c=t[e+2],f=t[e+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(s=u))}}s===null?(s=65533,i=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),e+=i}return Ba(n)}var Cl=4096;function Ba(t){let e=t.length;if(e<=Cl)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Cl));return r}var Zy=256,Cn=class{constructor(e=Zy){this.chunkSize=e,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(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,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)}e.length<64&&e.length<this.chunkSize?(r=Tl(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=_r(n,0,this.cursor)}else r=Ul(this.chunks,this.cursor);return e&&this.reset(),r}};var O="CBOR decode error:",At="CBOR encode error:",In=[];In[23]=1;In[24]=2;In[25]=3;In[26]=5;In[27]=9;function St(t,e,r){if(t.length-e<r)throw new Error(`${O} not enough data for type`)}var xe=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Me(t,e,r){St(t,e,1);let n=t[e];if(r.strict