UNPKG

@multiformats/multiaddr-to-uri

Version:
5 lines (4 loc) 36 kB
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.MultiformatsMultiaddrToUri = factory()}(typeof self !== 'undefined' ? self : this, function () { "use strict";var MultiformatsMultiaddrToUri=(()=>{var Ee=Object.defineProperty;var rr=Object.getOwnPropertyDescriptor;var nr=Object.getOwnPropertyNames;var or=Object.prototype.hasOwnProperty;var g=(r,e)=>{for(var t in e)Ee(r,t,{get:e[t],enumerable:!0})},ir=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of nr(e))!or.call(r,o)&&o!==t&&Ee(r,o,{get:()=>e[o],enumerable:!(n=rr(e,o))||n.enumerable});return r};var sr=r=>ir(Ee({},"__esModule",{value:!0}),r);var mo={};g(mo,{multiaddrToUri:()=>ho});var Ie={};g(Ie,{base10:()=>fr});var wo=new Uint8Array(0);function lt(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function _(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function pt(r){return new TextEncoder().encode(r)}function ut(r){return new TextDecoder().decode(r)}function ar(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var a=r.length,c=r.charAt(0),d=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function O(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var w=0,L=0,v=0,I=l.length;v!==I&&l[v]===0;)v++,w++;for(var T=(I-v)*f+1>>>0,y=new Uint8Array(T);v!==I;){for(var P=l[v],N=0,D=T-1;(P!==0||N<L)&&D!==-1;D--,N++)P+=256*y[D]>>>0,y[D]=P%a>>>0,P=P/a>>>0;if(P!==0)throw new Error("Non-zero carry");L=N,v++}for(var A=T-L;A!==T&&y[A]===0;)A++;for(var pe=c.repeat(w);A<T;++A)pe+=r.charAt(y[A]);return pe}function R(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var w=0;if(l[w]!==" "){for(var L=0,v=0;l[w]===c;)L++,w++;for(var I=(l.length-w)*d+1>>>0,T=new Uint8Array(I);l[w];){var y=t[l.charCodeAt(w)];if(y===255)return;for(var P=0,N=I-1;(y!==0||P<v)&&N!==-1;N--,P++)y+=a*T[N]>>>0,T[N]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");v=P,w++}if(l[w]!==" "){for(var D=I-v;D!==I&&T[D]===0;)D++;for(var A=new Uint8Array(L+(I-D)),pe=L;D!==I;)A[pe++]=T[D++];return A}}}function tr(l){var w=R(l);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:O,decodeUnsafe:R,decode:tr}}var cr=ar,dr=cr,ht=dr;var Ce=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ve=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.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 mt(this,e)}},De=class{decoders;constructor(e){this.decoders=e}or(e){return mt(this,e)}decode(e){let t=e[0],n=this.decoders[t];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 mt(r,e){return new De({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Se=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ce(e,t,n),this.decoder=new ve(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function W({name:r,prefix:e,encode:t,decode:n}){return new Se(r,e,t,n)}function B({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=ht(t,r);return W({prefix:e,name:r,encode:n,decode:i=>_(o(i))})}function lr(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),s=0,a=0,c=0;for(let d=0;d<o;++d){let f=e[r[d]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|f,s+=t,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=t||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function pr(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;(i.length*t&7)!==0;)i+="=";return i}function ur(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function u({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=ur(n);return W({prefix:e,name:r,encode(i){return pr(i,n,t)},decode(i){return lr(i,o,t,r)}})}var fr=B({prefix:"9",name:"base10",alphabet:"0123456789"});var Te={};g(Te,{base16:()=>hr,base16upper:()=>mr});var hr=u({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),mr=u({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Pe={};g(Pe,{base2:()=>xr});var xr=u({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Oe={};g(Oe,{base256emoji:()=>Er});var xt=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}"),wr=xt.reduce((r,e,t)=>(r[t]=e,r),[]),gr=xt.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function br(r){return r.reduce((e,t)=>(e+=wr[t],e),"")}function yr(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=gr[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var Er=W({prefix:"\u{1F680}",name:"base256emoji",encode:br,decode:yr});var Ae={};g(Ae,{base32:()=>z,base32hex:()=>Sr,base32hexpad:()=>Tr,base32hexpadupper:()=>Pr,base32hexupper:()=>Ir,base32pad:()=>vr,base32padupper:()=>Dr,base32upper:()=>Cr,base32z:()=>Or});var z=u({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Cr=u({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),vr=u({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Dr=u({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Sr=u({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ir=u({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Tr=u({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Pr=u({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Or=u({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _e={};g(_e,{base36:()=>K,base36upper:()=>Ar});var K=B({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ar=B({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ue={};g(Ue,{base58btc:()=>E,base58flickr:()=>_r});var E=B({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_r=B({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Be={};g(Be,{base64:()=>Ur,base64pad:()=>Nr,base64url:()=>Ne,base64urlpad:()=>Br});var Ur=u({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Nr=u({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ne=u({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Br=u({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ze={};g(ze,{base8:()=>zr});var zr=u({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var $e={};g($e,{identity:()=>$r});var $r=W({prefix:"\0",name:"identity",encode:r=>ut(r),decode:r=>pt(r)});var No=new TextEncoder,Bo=new TextDecoder;var Re={};g(Re,{identity:()=>sn});var Lr=bt,wt=128,Vr=127,Mr=~Vr,kr=Math.pow(2,31);function bt(r,e,t){e=e||[],t=t||0;for(var n=t;r>=kr;)e[t++]=r&255|wt,r/=128;for(;r&Mr;)e[t++]=r&255|wt,r>>>=7;return e[t]=r|0,bt.bytes=t-n+1,e}var Wr=Fe,jr=128,gt=127;function Fe(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Fe.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&gt)<<o:(s&gt)*Math.pow(2,o),o+=7}while(s>=jr);return Fe.bytes=i-n,t}var qr=Math.pow(2,7),Hr=Math.pow(2,14),Gr=Math.pow(2,21),Xr=Math.pow(2,28),Jr=Math.pow(2,35),Qr=Math.pow(2,42),Kr=Math.pow(2,49),Zr=Math.pow(2,56),Yr=Math.pow(2,63),en=function(r){return r<qr?1:r<Hr?2:r<Gr?3:r<Xr?4:r<Jr?5:r<Qr?6:r<Kr?7:r<Zr?8:r<Yr?9:10},tn={encode:Lr,decode:Wr,encodingLength:en},rn=tn,Z=rn;function Y(r,e=0){return[Z.decode(r,e),Z.decode.bytes]}function j(r,e,t=0){return Z.encode(r,e,t),e}function q(r){return Z.encodingLength(r)}function V(r,e){let t=e.byteLength,n=q(r),o=n+q(t),i=new Uint8Array(o+t);return j(r,i,0),j(t,i,n),i.set(e,o),new H(r,t,e,i)}function yt(r){let e=_(r),[t,n]=Y(e),[o,i]=Y(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new H(t,o,s,e)}function Et(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&lt(r.bytes,t.bytes)}}var H=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Ct=0,nn="identity",vt=_;function on(r){return V(Ct,vt(r))}var sn={code:Ct,name:nn,encode:vt,digest:on};var Me={};g(Me,{sha256:()=>an,sha512:()=>cn});function Ve({name:r,code:e,encode:t}){return new Le(r,e,t)}var Le=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?V(this.code,t):t.then(n=>V(this.code,n))}else throw Error("Unknown type, must be binary type")}};function St(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var an=Ve({name:"sha2-256",code:18,encode:St("SHA-256")}),cn=Ve({name:"sha2-512",code:19,encode:St("SHA-512")});function It(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return ln(t,ke(r),e??E.encoder);default:return pn(t,ke(r),e??z.encoder)}}var Tt=new WeakMap;function ke(r){let e=Tt.get(r);if(e==null){let t=new Map;return Tt.set(r,t),t}return e}var $=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,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:t}=this;if(e!==te)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==un)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}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:t}=this.multihash,n=V(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&Et(e.multihash,n.multihash)}toString(e){return It(this,e)}toJSON(){return{"/":It(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 t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??Pt(n,o,i.bytes))}else if(t[fn]===!0){let{version:n,multihash:o,code:i}=t,s=yt(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="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(t!==te)throw new Error(`Version 0 CID must use dag-pb (code: ${te}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Pt(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,te,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=_(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new H(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[O,R]=Y(e.subarray(t));return t+=R,O},o=n(),i=te;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),d=t+c,f=d-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:d}}static parse(e,t){let[n,o]=dn(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ke(i).set(n,e),i}};function dn(r,e){switch(r[0]){case"Q":{let t=e??E;return[E.prefix,t.decode(`${E.prefix}${r}`)]}case E.prefix:{let t=e??E;return[E.prefix,t.decode(r)]}case z.prefix:{let t=e??z;return[z.prefix,t.decode(r)]}case K.prefix:{let t=e??K;return[K.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function ln(r,e,t){let{prefix:n}=t;if(n!==E.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function pn(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var te=112,un=18;function Pt(r,e,t){let n=q(r),o=n+q(e),i=new Uint8Array(o+t.byteLength);return j(r,i,0),j(e,i,n),i.set(t,o),i}var fn=Symbol.for("@ipld/js-cid/CID");var re={...$e,...Pe,...ze,...Ie,...Te,...Ae,..._e,...Ue,...Be,...Oe},ri={...Me,...Re};function ne(r=0){return new Uint8Array(r)}function At(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Ot=At("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),We=At("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=ne(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),hn={utf8:Ot,"utf-8":Ot,hex:re.base16,latin1:We,ascii:We,binary:We,...re},fe=hn;function C(r,e="utf8"){let t=fe[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var m=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},U=class extends Error{static name="ValidationError";name="ValidationError"},oe=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},he=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function _t(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function F(r,e="utf8"){let t=fe[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}var mn=Math.pow(2,7),xn=Math.pow(2,14),wn=Math.pow(2,21),je=Math.pow(2,28),qe=Math.pow(2,35),He=Math.pow(2,42),Ge=Math.pow(2,49),p=128,x=127;function G(r){if(r<mn)return 1;if(r<xn)return 2;if(r<wn)return 3;if(r<je)return 4;if(r<qe)return 5;if(r<He)return 6;if(r<Ge)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Xe(r,e,t=0){switch(G(r)){case 8:e[t++]=r&255|p,r/=128;case 7:e[t++]=r&255|p,r/=128;case 6:e[t++]=r&255|p,r/=128;case 5:e[t++]=r&255|p,r/=128;case 4:e[t++]=r&255|p,r>>>=7;case 3:e[t++]=r&255|p,r>>>=7;case 2:e[t++]=r&255|p,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function gn(r,e){let t=r[e],n=0;if(n+=t&x,t<p||(t=r[e+1],n+=(t&x)<<7,t<p)||(t=r[e+2],n+=(t&x)<<14,t<p)||(t=r[e+3],n+=(t&x)<<21,t<p)||(t=r[e+4],n+=(t&x)*je,t<p)||(t=r[e+5],n+=(t&x)*qe,t<p)||(t=r[e+6],n+=(t&x)*He,t<p)||(t=r[e+7],n+=(t&x)*Ge,t<p))return n;throw new RangeError("Could not decode varint")}function bn(r,e){let t=r.get(e),n=0;if(n+=t&x,t<p||(t=r.get(e+1),n+=(t&x)<<7,t<p)||(t=r.get(e+2),n+=(t&x)<<14,t<p)||(t=r.get(e+3),n+=(t&x)<<21,t<p)||(t=r.get(e+4),n+=(t&x)*je,t<p)||(t=r.get(e+5),n+=(t&x)*qe,t<p)||(t=r.get(e+6),n+=(t&x)*He,t<p)||(t=r.get(e+7),n+=(t&x)*Ge,t<p))return n;throw new RangeError("Could not decode varint")}function Je(r,e=0){return r instanceof Uint8Array?gn(r,e):bn(r,e)}function ie(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=ne(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var me=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}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 t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",d=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let O=this.readChar();if(O===void 0)return;let R=Number.parseInt(O,e);if(!Number.isNaN(R))return R});if(f===void 0)break;if(i*=e,i+=f,i>d||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var En=45,Cn=15,xe=new me;function Qe(r){if(!(r.length>Cn))return xe.new(r).parseWith(()=>xe.readIPv4Addr())}function Ke(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>En))return xe.new(r).parseWith(()=>xe.readIPv6Addr())}function we(r){return!!Qe(r)}function Nt(r){return!!Ke(r)}function Ye(r){return e=>C(e,r)}function et(r){return e=>F(e,r)}function X(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function M(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(e)}function Bt(r){let e=r.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 t=F(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=M(n);return ie([t,o],t.length+o.length)}function zt(r){let e=r.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 t=z.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=M(n);return ie([t,o],t.length+o.length)}function tt(r){let e=r.subarray(0,r.length-2),t=r.subarray(r.length-2),n=C(e,"base32"),o=X(t);return`${n}:${o}`}var rt=function(r){r=r.toString().trim();let e=new Uint8Array(4);return r.split(/\./g).forEach((t,n)=>{let o=parseInt(t,10);if(isNaN(o)||o<0||o>255)throw new m("Invalid byte value in IP address");e[n]=o}),e},$t=function(r){let e=0;r=r.toString().trim();let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=we(t[n]),s;i&&(s=rt(t[n]),t[n]=C(s.subarray(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,C(s.subarray(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){t[n]===""&&(t[n]="0");let i=parseInt(t[n],16);if(isNaN(i)||i<0||i>65535)throw new m("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},Ft=function(r){if(r.byteLength!==4)throw new m("IPv4 address was incorrect length");let e=[];for(let t=0;t<r.byteLength;t++)e.push(r[t]);return e.join(".")},Rt=function(r){if(r.byteLength!==16)throw new m("IPv6 address was incorrect length");let e=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],i=r[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;e.push(s)}let t=e.join(":");try{let n=new URL(`http://[${t}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new m(`Invalid IPv6 address "${t}"`)}};function Lt(r){try{let e=new URL(`http://[${r}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new m(`Invalid IPv6 address "${r}"`)}}var Ze=Object.values(re).map(r=>r.decoder),vn=function(){let r=Ze[0].or(Ze[1]);return Ze.slice(2).forEach(e=>r=r.or(e)),r}();function Vt(r){return vn.decode(r)}function Mt(r){return e=>r.encoder.encode(e)}function Dn(r){if(parseInt(r).toString()!==r)throw new U("Value must be an integer")}function Sn(r){if(r<0)throw new U("Value must be a positive integer, or zero")}function In(r){return e=>{if(e>r)throw new U(`Value must be smaller than or equal to ${r}`)}}function Tn(...r){return e=>{for(let t of r)t(e)}}var se=Tn(Dn,Sn,In(65535));var h=-1,nt=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let t;if(typeof e=="string"?t=this.protocolsByName.get(e):t=this.protocolsByCode.get(e),t==null)throw new he(`Protocol ${e} was unknown`);return t}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(t=>{this.protocolsByName.set(t,e)})}removeProtocol(e){let t=this.protocolsByCode.get(e);t!=null&&(this.protocolsByCode.delete(t.code),this.protocolsByName.delete(t.name),t.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},b=new nt,ro=[{code:4,name:"ip4",size:32,valueToBytes:rt,bytesToValue:Ft,validate:r=>{if(!we(r))throw new U(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:M,bytesToValue:X,validate:se},{code:273,name:"udp",size:16,valueToBytes:M,bytesToValue:X,validate:se},{code:33,name:"dccp",size:16,valueToBytes:M,bytesToValue:X,validate:se},{code:41,name:"ip6",size:128,valueToBytes:$t,bytesToValue:Rt,stringToValue:Lt,validate:r=>{if(!Nt(r))throw new U(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:h},{code:43,name:"ipcidr",size:8,bytesToValue:Ye("base10"),valueToBytes:et("base10")},{code:53,name:"dns",size:h,resolvable:!0},{code:54,name:"dns4",size:h,resolvable:!0},{code:55,name:"dns6",size:h,resolvable:!0},{code:56,name:"dnsaddr",size:h,resolvable:!0},{code:132,name:"sctp",size:16,valueToBytes:M,bytesToValue:X,validate:se},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:h,path:!0,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:h,bytesToValue:Ye("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?et("base58btc")(r):$.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:tt,valueToBytes:Bt},{code:445,name:"onion3",size:296,bytesToValue:tt,valueToBytes:zt},{code:446,name:"garlic64",size:h},{code:447,name:"garlic32",size:h},{code:448,name:"tls"},{code:449,name:"sni",size:h},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:h,bytesToValue:Mt(Ne),valueToBytes:Vt},{code:480,name:"http"},{code:481,name:"http-path",size:h,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.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:h}];ro.forEach(r=>{b.addProtocol(r)});function kt(r){let e=[],t=0;for(;t<r.length;){let n=Je(r,t),o=b.getProtocol(n),i=G(n),s=no(o,r,t+i),a=0;s>0&&o.size===h&&(a=G(s));let c=i+a+s,d={code:n,name:o.name,bytes:r.subarray(t,t+c)};if(s>0){let f=t+i+a,O=r.subarray(f,f+s);d.value=o.bytesToValue?.(O)??C(O)}e.push(d),t+=c}return e}function Wt(r){let e=0,t=[];for(let n of r){if(n.bytes==null){let o=b.getProtocol(n.code),i=G(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??F(n.value),a=s.byteLength,o.size===h&&(c=G(a)));let d=new Uint8Array(i+c+a),f=0;Xe(n.code,d,f),f+=i,s!=null&&(o.size===h&&(Xe(a,d,f),f+=c),d.set(s,f)),n.bytes=d}t.push(n.bytes),e+=n.bytes.byteLength}return ie(t,e)}function jt(r){if(r.charAt(0)!=="/")throw new m('String multiaddr must start with "/"');let e=[],t="protocol",n="",o="";for(let i=1;i<r.length;i++){let s=r.charAt(i);s!=="/"&&(t==="protocol"?o+=r.charAt(i):n+=r.charAt(i));let a=i===r.length-1;if(s==="/"||a){let c=b.getProtocol(o);if(t==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",t="protocol";continue}else if(a)throw new m(`Component ${o} was missing value`);t="value"}else if(t==="value"){let d={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new m(`Component ${o} was missing value`);d.value=c.stringToValue?.(n)??n}e.push(d),n="",o="",t="protocol"}}}if(o!==""&&n!=="")throw new m("Incomplete multiaddr");return e}function qt(r){return`/${r.flatMap(e=>{if(e.value==null)return e.name;let t=b.getProtocol(e.code);if(t==null)throw new m(`Unknown protocol code ${e.code}`);return[e.name,t.valueToString?.(e.value)??e.value]}).join("/")}`}function no(r,e,t){return r.size==null||r.size===0?0:r.size>0?r.size/8:Je(e,t)}var oo=Symbol.for("nodejs.util.inspect.custom"),dt=Symbol.for("@multiformats/multiaddr"),io=[53,54,55,56],ct=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}};function so(r){if(r==null&&(r="/"),Gt(r))return r.getComponents();if(r instanceof Uint8Array)return kt(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),jt(r);if(Array.isArray(r))return r;throw new m("Must be a string, Uint8Array, Component[], or another Multiaddr")}var ye=class r{[dt]=!0;#e;#t;#r;constructor(e="/",t={}){this.#e=so(e),t.validate!==!1&&ao(this)}get bytes(){return this.#r==null&&(this.#r=Wt(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=qt(this.#e)),this.#t}toJSON(){return this.toString()}toOptions(){let e,t,n,o,i="";for(let{code:a,name:c,value:d}of this.#e)a===42&&(i=`%${d??""}`),io.includes(a)&&(t="tcp",o=443,n=`${d??""}${i}`,e=a===55?6:4),(a===6||a===273)&&(t=c==="tcp"?"tcp":"udp",o=parseInt(d??"")),(a===4||a===41)&&(t="tcp",n=`${d??""}${i}`,e=a===41?6:4);if(e==null||t==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:t,port:o}}getComponents(){return[...this.#e]}protos(){return this.#e.map(({code:e,value:t})=>{let n=b.getProtocol(e);return{code:e,size:n.size??0,name:n.name,resolvable:!!n.resolvable,path:!!n.path}})}protoCodes(){return this.#e.map(({code:e})=>e)}protoNames(){return this.#e.map(({name:e})=>e)}tuples(){return this.#e.map(({code:e,value:t})=>{if(t==null)return[e];let n=b.getProtocol(e),o=[e];return t!=null&&o.push(n.valueToBytes?.(t)??F(t)),o})}stringTuples(){return this.#e.map(({code:e,value:t})=>t==null?[e]:[e,t])}encapsulate(e){let t=new r(e);return new r([...this.#e,...t.getComponents()],{validate:!1})}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new oe(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(e){let t;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){t=n;break}return new r(this.#e.slice(0,t),{validate:!1})}getPeerId(){try{let e=[];this.#e.forEach(({code:n,value:o})=>{n===421&&e.push([n,o]),n===290&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?C(E.decode(`z${n}`),"base58btc"):C($.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){for(let e of this.#e)if(b.getProtocol(e.code).path)return e.value??null;return null}equals(e){return _t(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=Ht.get(t.name);if(n==null)throw new ct(`no available resolver for ${t.name}`);return(await n(this,e)).map(i=>le(i))}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(){return!(this.#e.length!==2||this.#e[0].code!==4&&this.#e[0].code!==41||this.#e[1].code!==6&&this.#e[1].code!==273)}[oo](){return`Multiaddr(${this.toString()})`}};function ao(r){r.getComponents().forEach(e=>{let t=b.getProtocol(e.code);e.value!=null&&t.validate?.(e.value)})}var fs=parseInt("0xFFFF",16),hs=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Ht=new Map;function Gt(r){return!!r?.[dt]}function le(r){return new ye(r)}var fo=[6,53,56,54,55];function Qt(r){return Yt("sni",r)?.value}function Kt(r){let e=Yt("tcp",r)?.value;return e==null?"":`:${e}`}function Yt(r,e){return e.find(t=>t.name===r)}function Zt(r){return r.some(({code:e})=>e===448)}function S(r,e){let t=er[r.name];if(t==null)throw new Error(`Can't interpret protocol ${r.name}`);let n=t(r,e);return r.code===41?`[${n}]`:n}var er={ip4:(r,e)=>r.value,ip6:(r,e)=>e.length===0?r.value:`[${r.value}]`,tcp:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");return`tcp://${S(t,e)}:${r.value}`},udp:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");return`udp://${S(t,e)}:${r.value}`},dnsaddr:(r,e)=>r.value,dns4:(r,e)=>r.value,dns6:(r,e)=>r.value,dns:(r,e)=>r.value,ipfs:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");return`${S(t,e)}`},p2p:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");return`${S(t,e)}`},http:(r,e)=>{let t=Zt(e),n=Qt(e),o=Kt(e);if(t&&n!=null)return`https://${n}${o}`;let i=t?"https://":"http://",s=e.pop();if(s==null)throw new Error("Unexpected end of multiaddr");let a=S(s,e);return a=a?.replace("tcp://",""),`${i}${a}`},"http-path":(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");let n=S(t,e),o=decodeURIComponent(r.value??"");return`${n}${o}`},tls:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");return S(t,e)},sni:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");return S(t,e)},https:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");let n=S(t,e);return n=n?.replace("tcp://",""),`https://${n}`},ws:(r,e)=>{let t=Zt(e),n=Qt(e),o=Kt(e);if(t&&n!=null)return`wss://${n}${o}`;let i=t?"wss://":"ws://",s=e.pop();if(s==null)throw new Error("Unexpected end of multiaddr");let a=S(s,e);return a=a?.replace("tcp://",""),`${i}${a}`},wss:(r,e)=>{let t=e.pop();if(t==null)throw new Error("Unexpected end of multiaddr");let n=S(t,e);return n=n?.replace("tcp://",""),`wss://${n}`}};function ho(r,e){let n=le(r).getComponents(),o=n.pop();if(o==null)throw new Error("Unexpected end of multiaddr");let i=er[o.name];if(i==null)throw new Error(`No interpreter found for ${o.name}`);let s=i(o,n)??"";return e?.assumeHttp!==!1&&fo.includes(o.code)&&(s=s.replace(/^.*:\/\//,""),o.value==="443"?s=`https://${s}`:s=`http://${s}`),(s.startsWith("http://")||s.startsWith("https://")||s.startsWith("ws://")||s.startsWith("wss://"))&&(s=new URL(s).toString(),s.endsWith("/")&&(s=s.substring(0,s.length-1))),s}return sr(mo);})(); return MultiformatsMultiaddrToUri})); //# sourceMappingURL=index.min.js.map