@libp2p/multistream-select 6.0.28-cfe2be4c9 → 6.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +9 -9
- package/dist/index.min.js.map +3 -3
- package/dist/typedoc-urls.json +10 -0
- package/package.json +3 -3
package/dist/index.min.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PMultistreamSelect = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PMultistreamSelect=(()=>{var Ae=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var Pt=Object.prototype.hasOwnProperty;var U=(r,t)=>{for(var e in t)Ae(r,e,{get:t[e],enumerable:!0})},_t=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ft(t))!Pt.call(r,o)&&o!==e&&Ae(r,o,{get:()=>t[o],enumerable:!(n=Mt(t,o))||n.enumerable});return r};var Vt=r=>_t(Ae({},"__esModule",{value:!0}),r);var on={};U(on,{PROTOCOL_ID:()=>x,handle:()=>Rt,select:()=>Tt});var x="/multistream/1.0.0";var Q=class extends Error{static name="UnsupportedProtocolError";constructor(t="Unsupported protocol error"){super(t),this.name="UnsupportedProtocolError"}},ie=class extends Error{static name="InvalidMessageError";constructor(t="Invalid message"){super(t),this.name="InvalidMessageError"}};function C(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var ae=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function k(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new ae(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new ae(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var De=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=C(),this.haveNext=C()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=C(),t}async throw(t){return this.ended=!0,this.error=t,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=C(),await k(this.readNext.promise,e?.signal,e)}};function rt(){return new De}function M(r=0){return new Uint8Array(r)}function I(r=0){return new Uint8Array(r)}function Se(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=I(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function nt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var st=Symbol.for("@achingbrain/uint8arraylist");function ot(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function ce(r){return!!r?.[st]}var y=class r{bufs;length;[st]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(ce(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(ce(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=ot(this.bufs,t);return e.buf[e.index]}set(t,e){let n=ot(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(ce(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Se(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Se(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,f=a+i.byteLength;if(o=f,t>=f)continue;let c=t>=a&&t<f,g=e>a&&e<=f;if(c&&g){if(t===a&&e===f){n.push(i);break}let p=t-a;n.push(i.subarray(p,p+(e-t)));break}if(c){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(g){if(e===f){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!ce(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let p=0;p<s;p++)i[p]=-1;for(let p=0;p<o;p++)i[n[p]]=p;let a=i,f=this.byteLength-n.byteLength,c=n.byteLength-1,g;for(let p=e;p<=f;p+=g){g=0;for(let v=c;v>=0;v--){let _=this.get(p+v);if(n[v]!==_){g=Math.max(1,v-a[_]);break}}if(g===0)return p}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=I(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=M(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=M(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=M(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=I(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=M(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=M(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=M(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=M(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=M(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!nt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var fe=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function it(r,t){let e=rt();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let a of i)await e.push(a);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new y;return{read:async i=>{if(i?.signal?.throwIfAborted(),i?.bytes==null){let{done:f,value:c}=await k(n.next(),i?.signal);return f===!0?null:c}for(;o.byteLength<i.bytes;){let{value:f,done:c}=await k(n.next(),i?.signal);if(c===!0)throw new fe("unexpected end of input");o.append(f)}let a=o.sublist(0,i.bytes);return o.consume(i.bytes),a},write:async(i,a)=>{a?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,a):await e.push(i.subarray(),a)},unwrap:()=>{if(o.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*i}()}return r}}}var Bt=Math.pow(2,7),kt=Math.pow(2,14),Gt=Math.pow(2,21),Ue=Math.pow(2,28),Ne=Math.pow(2,35),Ie=Math.pow(2,42),Ce=Math.pow(2,49),u=128,E=127;function F(r){if(r<Bt)return 1;if(r<kt)return 2;if(r<Gt)return 3;if(r<Ue)return 4;if(r<Ne)return 5;if(r<Ie)return 6;if(r<Ce)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function zt(r,t,e=0){switch(F(r)){case 8:t[e++]=r&255|u,r/=128;case 7:t[e++]=r&255|u,r/=128;case 6:t[e++]=r&255|u,r/=128;case 5:t[e++]=r&255|u,r/=128;case 4:t[e++]=r&255|u,r>>>=7;case 3:t[e++]=r&255|u,r>>>=7;case 2:t[e++]=r&255|u,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function $t(r,t,e=0){switch(F(r)){case 8:t.set(e++,r&255|u),r/=128;case 7:t.set(e++,r&255|u),r/=128;case 6:t.set(e++,r&255|u),r/=128;case 5:t.set(e++,r&255|u),r/=128;case 4:t.set(e++,r&255|u),r>>>=7;case 3:t.set(e++,r&255|u),r>>>=7;case 2:t.set(e++,r&255|u),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Ht(r,t){let e=r[t],n=0;if(n+=e&E,e<u||(e=r[t+1],n+=(e&E)<<7,e<u)||(e=r[t+2],n+=(e&E)<<14,e<u)||(e=r[t+3],n+=(e&E)<<21,e<u)||(e=r[t+4],n+=(e&E)*Ue,e<u)||(e=r[t+5],n+=(e&E)*Ne,e<u)||(e=r[t+6],n+=(e&E)*Ie,e<u)||(e=r[t+7],n+=(e&E)*Ce,e<u))return n;throw new RangeError("Could not decode varint")}function Xt(r,t){let e=r.get(t),n=0;if(n+=e&E,e<u||(e=r.get(t+1),n+=(e&E)<<7,e<u)||(e=r.get(t+2),n+=(e&E)<<14,e<u)||(e=r.get(t+3),n+=(e&E)<<21,e<u)||(e=r.get(t+4),n+=(e&E)*Ue,e<u)||(e=r.get(t+5),n+=(e&E)*Ne,e<u)||(e=r.get(t+6),n+=(e&E)*Ie,e<u)||(e=r.get(t+7),n+=(e&E)*Ce,e<u))return n;throw new RangeError("Could not decode varint")}function H(r,t,e=0){return t==null&&(t=I(F(r))),t instanceof Uint8Array?zt(r,t,e):$t(r,t,e)}function he(r,t=0){return r instanceof Uint8Array?Ht(r,t):Xt(r,t)}var le=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},de=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},pe=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Y(r,t={}){let e=it(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=F(t.maxDataLength));let n=t?.lengthDecoder??he,o=t?.lengthEncoder??H;return{read:async i=>{let a=-1,f=new y;for(;;){f.append(await e.read({...i,bytes:1}));try{a=n(f)}catch(c){if(c instanceof RangeError)continue;throw c}if(a<0)throw new le("Invalid message length");if(t?.maxLengthLength!=null&&f.byteLength>t.maxLengthLength)throw new pe("message length length too long");if(a>-1)break}if(t?.maxDataLength!=null&&a>t.maxDataLength)throw new de("message length too long");return e.read({...i,bytes:a})},write:async(i,a)=>{await e.write(new y(o(i.byteLength),i),a)},writeV:async(i,a)=>{let f=new y(...i.flatMap(c=>[o(c.byteLength),c]));await e.write(f,a)},unwrap:()=>e.unwrap()}}var Fe={};U(Fe,{base10:()=>Yt});var _n=new Uint8Array(0);function at(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function P(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 ct(r){return new TextEncoder().encode(r)}function ft(r){return new TextDecoder().decode(r)}function jt(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,f=r.charAt(0),c=Math.log(a)/Math.log(256),g=Math.log(256)/Math.log(a);function p(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var w=0,O=0,D=0,l=h.length;D!==l&&h[D]===0;)D++,w++;for(var b=(l-D)*g+1>>>0,d=new Uint8Array(b);D!==l;){for(var A=h[D],N=0,S=b-1;(A!==0||N<O)&&S!==-1;S--,N++)A+=256*d[S]>>>0,d[S]=A%a>>>0,A=A/a>>>0;if(A!==0)throw new Error("Non-zero carry");O=N,D++}for(var R=b-O;R!==b&&d[R]===0;)R++;for(var se=f.repeat(w);R<b;++R)se+=r.charAt(d[R]);return se}function v(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var w=0;if(h[w]!==" "){for(var O=0,D=0;h[w]===f;)O++,w++;for(var l=(h.length-w)*c+1>>>0,b=new Uint8Array(l);h[w];){var d=e[h.charCodeAt(w)];if(d===255)return;for(var A=0,N=l-1;(d!==0||A<D)&&N!==-1;N--,A++)d+=a*b[N]>>>0,b[N]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");D=A,w++}if(h[w]!==" "){for(var S=l-D;S!==l&&b[S]===0;)S++;for(var R=new Uint8Array(O+(l-S)),se=O;S!==l;)R[se++]=b[S++];return R}}}function _(h){var w=v(h);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:p,decodeUnsafe:v,decode:_}}var qt=jt,Jt=qt,ut=Jt;var Te=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Oe=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return lt(this,t)}},Re=class{decoders;constructor(t){this.decoders=t}or(t){return lt(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function lt(r,t){return new Re({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Me=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Te(t,e,n),this.decoder=new Oe(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function X({name:r,prefix:t,encode:e,decode:n}){return new Me(r,t,e,n)}function V({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=ut(e,r);return X({prefix:t,name:r,encode:n,decode:s=>P(o(s))})}function Wt(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,f=0;for(let c=0;c<o;++c){let g=t[r[c]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|g,i+=e,i>=8&&(i-=8,s[f++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Kt(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let f=0;f<r.length;++f)for(a=a<<8|r[f],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function Qt(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function m({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=Qt(n);return X({prefix:t,name:r,encode(s){return Kt(s,n,e)},decode(s){return Wt(s,o,e,r)}})}var Yt=V({prefix:"9",name:"base10",alphabet:"0123456789"});var Pe={};U(Pe,{base16:()=>Zt,base16upper:()=>er});var Zt=m({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),er=m({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var _e={};U(_e,{base2:()=>tr});var tr=m({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ve={};U(Ve,{base256emoji:()=>ir});var dt=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}"),rr=dt.reduce((r,t,e)=>(r[e]=t,r),[]),nr=dt.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function or(r){return r.reduce((t,e)=>(t+=rr[e],t),"")}function sr(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=nr[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var ir=X({prefix:"\u{1F680}",name:"base256emoji",encode:or,decode:sr});var Be={};U(Be,{base32:()=>j,base32hex:()=>hr,base32hexpad:()=>lr,base32hexpadupper:()=>dr,base32hexupper:()=>ur,base32pad:()=>cr,base32padupper:()=>fr,base32upper:()=>ar,base32z:()=>pr});var j=m({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ar=m({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),cr=m({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fr=m({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),hr=m({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ur=m({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),lr=m({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),dr=m({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),pr=m({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ke={};U(ke,{base36:()=>Z,base36upper:()=>mr});var Z=V({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),mr=V({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ge={};U(Ge,{base58btc:()=>T,base58flickr:()=>gr});var T=V({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),gr=V({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ze={};U(ze,{base64:()=>wr,base64pad:()=>br,base64url:()=>xr,base64urlpad:()=>yr});var wr=m({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),br=m({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),xr=m({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yr=m({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $e={};U($e,{base8:()=>Er});var Er=m({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var He={};U(He,{identity:()=>Lr});var Lr=X({prefix:"\0",name:"identity",encode:r=>ft(r),decode:r=>ct(r)});var Zn=new TextEncoder,eo=new TextDecoder;var je={};U(je,{identity:()=>Xr});var Dr=gt,pt=128,Sr=127,Ur=~Sr,Nr=Math.pow(2,31);function gt(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Nr;)t[e++]=r&255|pt,r/=128;for(;r&Ur;)t[e++]=r&255|pt,r>>>=7;return t[e]=r|0,gt.bytes=e-n+1,t}var Ir=Xe,Cr=128,mt=127;function Xe(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Xe.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&mt)<<o:(i&mt)*Math.pow(2,o),o+=7}while(i>=Cr);return Xe.bytes=s-n,e}var Tr=Math.pow(2,7),Or=Math.pow(2,14),Rr=Math.pow(2,21),Mr=Math.pow(2,28),Fr=Math.pow(2,35),Pr=Math.pow(2,42),_r=Math.pow(2,49),Vr=Math.pow(2,56),Br=Math.pow(2,63),kr=function(r){return r<Tr?1:r<Or?2:r<Rr?3:r<Mr?4:r<Fr?5:r<Pr?6:r<_r?7:r<Vr?8:r<Br?9:10},Gr={encode:Dr,decode:Ir,encodingLength:kr},zr=Gr,ee=zr;function te(r,t=0){return[ee.decode(r,t),ee.decode.bytes]}function q(r,t,e=0){return ee.encode(r,t,e),t}function J(r){return ee.encodingLength(r)}function G(r,t){let e=t.byteLength,n=J(r),o=n+J(e),s=new Uint8Array(o+e);return q(r,s,0),q(e,s,n),s.set(t,o),new W(r,e,t,s)}function wt(r){let t=P(r),[e,n]=te(t),[o,s]=te(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new W(e,o,i,t)}function bt(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&at(r.bytes,e.bytes)}}var W=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var xt=0,$r="identity",yt=P;function Hr(r){return G(xt,yt(r))}var Xr={code:xt,name:$r,encode:yt,digest:Hr};var We={};U(We,{sha256:()=>jr,sha512:()=>qr});function Je({name:r,code:t,encode:e}){return new qe(r,t,e)}var qe=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?G(this.code,e):e.then(n=>G(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Lt(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var jr=Je({name:"sha2-256",code:18,encode:Lt("SHA-256")}),qr=Je({name:"sha2-512",code:19,encode:Lt("SHA-512")});function vt(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Wr(e,Ke(r),t??T.encoder);default:return Kr(e,Ke(r),t??j.encoder)}}var At=new WeakMap;function Ke(r){let t=At.get(r);if(t==null){let e=new Map;return At.set(r,e),e}return t}var ge=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==ne)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Qr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=G(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&bt(t.multihash,n.multihash)}toString(t){return vt(this,t)}toJSON(){return{"/":vt(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??Dt(n,o,s.bytes))}else if(e[Yr]===!0){let{version:n,multihash:o,code:s}=e,i=wt(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==ne)throw new Error(`Version 0 CID must use dag-pb (code: ${ne}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Dt(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,ne,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=P(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new W(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[p,v]=te(t.subarray(e));return e+=v,p},o=n(),s=ne;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),f=n(),c=e+f,g=c-i;return{version:o,codec:s,multihashCode:a,digestSize:f,multihashSize:g,size:c}}static parse(t,e){let[n,o]=Jr(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ke(s).set(n,t),s}};function Jr(r,t){switch(r[0]){case"Q":{let e=t??T;return[T.prefix,e.decode(`${T.prefix}${r}`)]}case T.prefix:{let e=t??T;return[T.prefix,e.decode(r)]}case j.prefix:{let e=t??j;return[j.prefix,e.decode(r)]}case Z.prefix:{let e=t??Z;return[Z.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Wr(r,t,e){let{prefix:n}=e;if(n!==T.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Kr(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var ne=112,Qr=18;function Dt(r,t,e){let n=J(r),o=n+J(t),s=new Uint8Array(o+e.byteLength);return q(r,s,0),q(t,s,n),s.set(e,o),s}var Yr=Symbol.for("@ipld/js-cid/CID");var Qe={...He,..._e,...$e,...Fe,...Pe,...Be,...ke,...Ge,...ze,...Ve},vo={...We,...je};function Ut(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var St=Ut("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ye=Ut("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=I(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Zr={utf8:St,"utf-8":St,hex:Qe.base16,latin1:Ye,ascii:Ye,binary:Ye,...Qe},we=Zr;function L(r,t="utf8"){let e=we[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Nt(r,t="utf8"){let e=we[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var en=L(`
|
|
3
|
-
`);async function
|
|
2
|
+
"use strict";var Libp2PMultistreamSelect=(()=>{var Ae=Object.defineProperty;var Ft=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var _t=Object.prototype.hasOwnProperty;var U=(r,t)=>{for(var e in t)Ae(r,e,{get:t[e],enumerable:!0})},Vt=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Pt(t))!_t.call(r,o)&&o!==e&&Ae(r,o,{get:()=>t[o],enumerable:!(n=Ft(t,o))||n.enumerable});return r};var Bt=r=>Vt(Ae({},"__esModule",{value:!0}),r);var an={};U(an,{PROTOCOL_ID:()=>x,handle:()=>Rt,select:()=>Ot});var x="/multistream/1.0.0";var Q=class extends Error{static name="UnsupportedProtocolError";constructor(t="Unsupported protocol error"){super(t),this.name="UnsupportedProtocolError"}},ie=class extends Error{static name="InvalidMessageError";constructor(t="Invalid message"){super(t),this.name="InvalidMessageError"}};function C(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var ae=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function G(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new ae(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new ae(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var De=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=C(),this.haveNext=C()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=C(),t}async throw(t){return this.ended=!0,this.error=t,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=C(),await G(this.readNext.promise,e?.signal,e)}};function rt(){return new De}function R(r=0){return new Uint8Array(r)}function N(r=0){return new Uint8Array(r)}function Se(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=N(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function nt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var st=Symbol.for("@achingbrain/uint8arraylist");function ot(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function ce(r){return!!r?.[st]}var y=class r{bufs;length;[st]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(ce(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(ce(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=ot(this.bufs,t);return e.buf[e.index]}set(t,e){let n=ot(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(ce(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return Se(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:Se(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,h=a+i.byteLength;if(o=h,t>=h)continue;let c=t>=a&&t<h,g=e>a&&e<=h;if(c&&g){if(t===a&&e===h){n.push(i);break}let m=t-a;n.push(i.subarray(m,m+(e-t)));break}if(c){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(g){if(e===h){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!ce(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let m=0;m<s;m++)i[m]=-1;for(let m=0;m<o;m++)i[n[m]]=m;let a=i,h=this.byteLength-n.byteLength,c=n.byteLength-1,g;for(let m=e;m<=h;m+=g){g=0;for(let v=c;v>=0;v--){let _=this.get(m+v);if(n[v]!==_){g=Math.max(1,v-a[_]);break}}if(g===0)return m}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=N(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=R(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=R(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=R(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=N(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=R(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=R(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=R(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=R(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=R(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!nt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var he=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function it(r,t){let e=rt();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let a of i)await e.push(a);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new y;return{read:async i=>{if(i?.signal?.throwIfAborted(),i?.bytes==null){let{done:h,value:c}=await G(n.next(),i?.signal);return h===!0?null:c}for(;o.byteLength<i.bytes;){let{value:h,done:c}=await G(n.next(),i?.signal);if(c===!0)throw new he("unexpected end of input");o.append(h)}let a=o.sublist(0,i.bytes);return o.consume(i.bytes),a},write:async(i,a)=>{a?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,a):await e.push(i.subarray(),a)},unwrap:()=>{if(o.byteLength>0){let i=r.source;r.source=(async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*i})()}return r}}}var Gt=Math.pow(2,7),kt=Math.pow(2,14),zt=Math.pow(2,21),Ue=Math.pow(2,28),Ie=Math.pow(2,35),Ne=Math.pow(2,42),Ce=Math.pow(2,49),f=128,E=127;function F(r){if(r<Gt)return 1;if(r<kt)return 2;if(r<zt)return 3;if(r<Ue)return 4;if(r<Ie)return 5;if(r<Ne)return 6;if(r<Ce)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function $t(r,t,e=0){switch(F(r)){case 8:t[e++]=r&255|f,r/=128;case 7:t[e++]=r&255|f,r/=128;case 6:t[e++]=r&255|f,r/=128;case 5:t[e++]=r&255|f,r/=128;case 4:t[e++]=r&255|f,r>>>=7;case 3:t[e++]=r&255|f,r>>>=7;case 2:t[e++]=r&255|f,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Ht(r,t,e=0){switch(F(r)){case 8:t.set(e++,r&255|f),r/=128;case 7:t.set(e++,r&255|f),r/=128;case 6:t.set(e++,r&255|f),r/=128;case 5:t.set(e++,r&255|f),r/=128;case 4:t.set(e++,r&255|f),r>>>=7;case 3:t.set(e++,r&255|f),r>>>=7;case 2:t.set(e++,r&255|f),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function qt(r,t){let e=r[t],n=0;if(n+=e&E,e<f||(e=r[t+1],n+=(e&E)<<7,e<f)||(e=r[t+2],n+=(e&E)<<14,e<f)||(e=r[t+3],n+=(e&E)<<21,e<f)||(e=r[t+4],n+=(e&E)*Ue,e<f)||(e=r[t+5],n+=(e&E)*Ie,e<f)||(e=r[t+6],n+=(e&E)*Ne,e<f)||(e=r[t+7],n+=(e&E)*Ce,e<f))return n;throw new RangeError("Could not decode varint")}function Xt(r,t){let e=r.get(t),n=0;if(n+=e&E,e<f||(e=r.get(t+1),n+=(e&E)<<7,e<f)||(e=r.get(t+2),n+=(e&E)<<14,e<f)||(e=r.get(t+3),n+=(e&E)<<21,e<f)||(e=r.get(t+4),n+=(e&E)*Ue,e<f)||(e=r.get(t+5),n+=(e&E)*Ie,e<f)||(e=r.get(t+6),n+=(e&E)*Ne,e<f)||(e=r.get(t+7),n+=(e&E)*Ce,e<f))return n;throw new RangeError("Could not decode varint")}function $(r,t,e=0){return t==null&&(t=N(F(r))),t instanceof Uint8Array?$t(r,t,e):Ht(r,t,e)}function ue(r,t=0){return r instanceof Uint8Array?qt(r,t):Xt(r,t)}var le=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},de=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},me=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Y(r,t={}){let e=it(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=F(t.maxDataLength));let n=t?.lengthDecoder??ue,o=t?.lengthEncoder??$;return{read:async i=>{let a=-1,h=new y;for(;;){h.append(await e.read({...i,bytes:1}));try{a=n(h)}catch(c){if(c instanceof RangeError)continue;throw c}if(a<0)throw new le("Invalid message length");if(t?.maxLengthLength!=null&&h.byteLength>t.maxLengthLength)throw new me("message length length too long");if(a>-1)break}if(t?.maxDataLength!=null&&a>t.maxDataLength)throw new de("message length too long");return e.read({...i,bytes:a})},write:async(i,a)=>{await e.write(new y(o(i.byteLength),i),a)},writeV:async(i,a)=>{let h=new y(...i.flatMap(c=>[o(c.byteLength),c]));await e.write(h,a)},unwrap:()=>e.unwrap()}}var Fe={};U(Fe,{base10:()=>Zt});var Bn=new Uint8Array(0);function at(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function P(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 ct(r){return new TextEncoder().encode(r)}function ht(r){return new TextDecoder().decode(r)}function jt(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,h=r.charAt(0),c=Math.log(a)/Math.log(256),g=Math.log(256)/Math.log(a);function m(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";for(var w=0,O=0,D=0,l=u.length;D!==l&&u[D]===0;)D++,w++;for(var b=(l-D)*g+1>>>0,d=new Uint8Array(b);D!==l;){for(var A=u[D],I=0,S=b-1;(A!==0||I<O)&&S!==-1;S--,I++)A+=256*d[S]>>>0,d[S]=A%a>>>0,A=A/a>>>0;if(A!==0)throw new Error("Non-zero carry");O=I,D++}for(var M=b-O;M!==b&&d[M]===0;)M++;for(var se=h.repeat(w);M<b;++M)se+=r.charAt(d[M]);return se}function v(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var w=0;if(u[w]!==" "){for(var O=0,D=0;u[w]===h;)O++,w++;for(var l=(u.length-w)*c+1>>>0,b=new Uint8Array(l);u[w];){var d=e[u.charCodeAt(w)];if(d===255)return;for(var A=0,I=l-1;(d!==0||A<D)&&I!==-1;I--,A++)d+=a*b[I]>>>0,b[I]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");D=A,w++}if(u[w]!==" "){for(var S=l-D;S!==l&&b[S]===0;)S++;for(var M=new Uint8Array(O+(l-S)),se=O;S!==l;)M[se++]=b[S++];return M}}}function _(u){var w=v(u);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:v,decode:_}}var Jt=jt,Wt=Jt,ft=Wt;var Te=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Oe=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return lt(this,t)}},Me=class{decoders;constructor(t){this.decoders=t}or(t){return lt(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function lt(r,t){return new Me({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Re=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Te(t,e,n),this.decoder=new Oe(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function H({name:r,prefix:t,encode:e,decode:n}){return new Re(r,t,e,n)}function V({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=ft(e,r);return H({prefix:t,name:r,encode:n,decode:s=>P(o(s))})}function Kt(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,h=0;for(let c=0;c<o;++c){let g=t[r[c]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|g,i+=e,i>=8&&(i-=8,s[h++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Qt(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let h=0;h<r.length;++h)for(a=a<<8|r[h],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function Yt(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function p({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=Yt(n);return H({prefix:t,name:r,encode(s){return Qt(s,n,e)},decode(s){return Kt(s,o,e,r)}})}var Zt=V({prefix:"9",name:"base10",alphabet:"0123456789"});var Pe={};U(Pe,{base16:()=>er,base16upper:()=>tr});var er=p({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),tr=p({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var _e={};U(_e,{base2:()=>rr});var rr=p({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ve={};U(Ve,{base256emoji:()=>ar});var dt=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}"),nr=dt.reduce((r,t,e)=>(r[e]=t,r),[]),or=dt.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function sr(r){return r.reduce((t,e)=>(t+=nr[e],t),"")}function ir(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=or[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var ar=H({prefix:"\u{1F680}",name:"base256emoji",encode:sr,decode:ir});var Be={};U(Be,{base32:()=>q,base32hex:()=>fr,base32hexpad:()=>dr,base32hexpadupper:()=>mr,base32hexupper:()=>lr,base32pad:()=>hr,base32padupper:()=>ur,base32upper:()=>cr,base32z:()=>pr});var q=p({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),cr=p({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),hr=p({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ur=p({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),fr=p({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),lr=p({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),dr=p({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),mr=p({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),pr=p({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ge={};U(Ge,{base36:()=>Z,base36upper:()=>gr});var Z=V({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),gr=V({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ke={};U(ke,{base58btc:()=>T,base58flickr:()=>wr});var T=V({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),wr=V({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ze={};U(ze,{base64:()=>br,base64pad:()=>xr,base64url:()=>yr,base64urlpad:()=>Er});var br=p({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xr=p({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),yr=p({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Er=p({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $e={};U($e,{base8:()=>Lr});var Lr=p({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var He={};U(He,{identity:()=>vr});var vr=H({prefix:"\0",name:"identity",encode:r=>ht(r),decode:r=>ct(r)});var to=new TextEncoder,ro=new TextDecoder;var Xe={};U(Xe,{identity:()=>Xr});var Sr=gt,mt=128,Ur=127,Ir=~Ur,Nr=Math.pow(2,31);function gt(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Nr;)t[e++]=r&255|mt,r/=128;for(;r&Ir;)t[e++]=r&255|mt,r>>>=7;return t[e]=r|0,gt.bytes=e-n+1,t}var Cr=qe,Tr=128,pt=127;function qe(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw qe.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&pt)<<o:(i&pt)*Math.pow(2,o),o+=7}while(i>=Tr);return qe.bytes=s-n,e}var Or=Math.pow(2,7),Mr=Math.pow(2,14),Rr=Math.pow(2,21),Fr=Math.pow(2,28),Pr=Math.pow(2,35),_r=Math.pow(2,42),Vr=Math.pow(2,49),Br=Math.pow(2,56),Gr=Math.pow(2,63),kr=function(r){return r<Or?1:r<Mr?2:r<Rr?3:r<Fr?4:r<Pr?5:r<_r?6:r<Vr?7:r<Br?8:r<Gr?9:10},zr={encode:Sr,decode:Cr,encodingLength:kr},$r=zr,ee=$r;function te(r,t=0){return[ee.decode(r,t),ee.decode.bytes]}function X(r,t,e=0){return ee.encode(r,t,e),t}function j(r){return ee.encodingLength(r)}function W(r,t){let e=t.byteLength,n=j(r),o=n+j(e),s=new Uint8Array(o+e);return X(r,s,0),X(e,s,n),s.set(t,o),new J(r,e,t,s)}function wt(r){let t=P(r),[e,n]=te(t),[o,s]=te(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new J(e,o,i,t)}function bt(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&at(r.bytes,e.bytes)}}var J=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var xt=0,Hr="identity",yt=P;function qr(r,t){if(t?.truncate!=null&&t.truncate!==r.byteLength){if(t.truncate<0||t.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t.truncate)}return W(xt,yt(r))}var Xr={code:xt,name:Hr,encode:yt,digest:qr};var We={};U(We,{sha256:()=>Jr,sha512:()=>Wr});var jr=20;function Je({name:r,code:t,encode:e,minDigestLength:n,maxDigestLength:o}){return new je(r,t,e,n,o)}var je=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,e,n,o,s){this.name=t,this.code=e,this.encode=n,this.minDigestLength=o??jr,this.maxDigestLength=s}digest(t,e){if(e?.truncate!=null){if(e.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&e.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?Et(n,this.code,e?.truncate):n.then(o=>Et(o,this.code,e?.truncate))}else throw Error("Unknown type, must be binary type")}};function Et(r,t,e){if(e!=null&&e!==r.byteLength){if(e>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e)}return W(t,r)}function vt(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Jr=Je({name:"sha2-256",code:18,encode:vt("SHA-256")}),Wr=Je({name:"sha2-512",code:19,encode:vt("SHA-512")});function At(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Qr(e,Ke(r),t??T.encoder);default:return Yr(e,Ke(r),t??q.encoder)}}var Dt=new WeakMap;function Ke(r){let t=Dt.get(r);if(t==null){let e=new Map;return Dt.set(r,e),e}return t}var ge=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==ne)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Zr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=W(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&bt(t.multihash,n.multihash)}toString(t){return At(this,t)}toJSON(){return{"/":At(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??St(n,o,s.bytes))}else if(e[en]===!0){let{version:n,multihash:o,code:s}=e,i=wt(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==ne)throw new Error(`Version 0 CID must use dag-pb (code: ${ne}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=St(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,ne,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=P(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new J(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[m,v]=te(t.subarray(e));return e+=v,m},o=n(),s=ne;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),h=n(),c=e+h,g=c-i;return{version:o,codec:s,multihashCode:a,digestSize:h,multihashSize:g,size:c}}static parse(t,e){let[n,o]=Kr(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ke(s).set(n,t),s}};function Kr(r,t){switch(r[0]){case"Q":{let e=t??T;return[T.prefix,e.decode(`${T.prefix}${r}`)]}case T.prefix:{let e=t??T;return[T.prefix,e.decode(r)]}case q.prefix:{let e=t??q;return[q.prefix,e.decode(r)]}case Z.prefix:{let e=t??Z;return[Z.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Qr(r,t,e){let{prefix:n}=e;if(n!==T.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function Yr(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var ne=112,Zr=18;function St(r,t,e){let n=j(r),o=n+j(t),s=new Uint8Array(o+e.byteLength);return X(r,s,0),X(t,s,n),s.set(e,o),s}var en=Symbol.for("@ipld/js-cid/CID");var Qe={...He,..._e,...$e,...Fe,...Pe,...Be,...Ge,...ke,...ze,...Ve},Do={...We,...Xe};function It(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Ut=It("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ye=It("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=N(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),tn={utf8:Ut,"utf-8":Ut,hex:Qe.base16,latin1:Ye,ascii:Ye,binary:Ye,...Qe},we=tn;function L(r,t="utf8"){let e=we[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Nt(r,t="utf8"){let e=we[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var rn=L(`
|
|
3
|
+
`);async function k(r,t,e){await r.write(t,e)}async function Ct(r,t,e){await r.writeV(t,e)}async function nn(r,t){let e=await r.read(t);if(e.byteLength===0||e.get(e.byteLength-1)!==rn[0])throw t.log.error("Invalid mss message - missing newline",e),new ie("Missing newline");return e.sublist(0,-1)}async function B(r,t){let e=await nn(r,t);return Nt(e.subarray())}async function Ot(r,t,e){if(t=Array.isArray(t)?[...t]:[t],t.length===1&&e.negotiateFully===!1)return on(r,t[0],e);let n=Y(r,{...e,maxDataLength:1024}),o=t.shift();if(o==null)throw new Error("At least one protocol must be specified");e.log.trace('select: write ["%s", "%s"]',x,o);let s=L(`${x}
|
|
4
4
|
`),i=L(`${o}
|
|
5
|
-
`);await
|
|
6
|
-
`),e),e.log.trace("select: reading protocol response");let c=await B(n,e);if(e.log.trace('select: read "%s" for "%s"',c,
|
|
5
|
+
`);await Ct(n,[s,i],e),e.log.trace("select: reading multistream-select header");let a=await B(n,e);if(e.log.trace('select: read "%s"',a),a===x&&(e.log.trace("select: reading protocol response"),a=await B(n,e),e.log.trace('select: read "%s"',a)),a===o)return{stream:n.unwrap(),protocol:o};for(let h of t){e.log.trace('select: write "%s"',h),await k(n,L(`${h}
|
|
6
|
+
`),e),e.log.trace("select: reading protocol response");let c=await B(n,e);if(e.log.trace('select: read "%s" for "%s"',c,h),c===h)return{stream:n.unwrap(),protocol:h}}throw new Q("protocol selection failed")}function on(r,t,e){let n=r.sink.bind(r),o=r.source,s=!1,i=!1,a=C(),h=!1,c=!1,g=C(),m=!1,v=!1,_=C(),u=Y({sink:n,source:o},{...e,maxDataLength:1024});r.sink=async l=>{let{sink:b}=u.unwrap();await b((async function*(){let d=!1;for await(let A of l){if(c&&await g.promise,h)yield A;else{c=!0,e.log.trace('optimistic: write ["%s", "%s", data(%d)] in sink',x,t,A.byteLength);let I=`${t}
|
|
7
7
|
`;yield new y(Uint8Array.from([19]),L(`${x}
|
|
8
|
-
`)
|
|
8
|
+
`),$(I.length),L(I),A).subarray(),e.log.trace('optimistic: wrote ["%s", "%s", data(%d)] in sink',x,t,A.byteLength),h=!0,c=!1,g.resolve(),w().catch(S=>{e.log.error("could not finish optimistic protocol negotiation of %s",t,S)})}d=!0}d||await w()})())};async function w(){if(i){e.log.trace("optimistic: already negotiating %s stream",t),await a.promise;return}i=!0;try{h||(e.log.trace("optimistic: doing send protocol for %s stream",t),await O()),m||(e.log.trace("optimistic: doing read protocol for %s stream",t),await D())}finally{i=!1,s=!0,a.resolve()}}async function O(){if(c){await g.promise;return}c=!0;try{e.log.trace('optimistic: write ["%s", "%s", data] in source',x,t),await u.writeV([L(`${x}
|
|
9
9
|
`),L(`${t}
|
|
10
|
-
`)]),e.log.trace('optimistic: wrote ["%s", "%s", data] in source',x,t)}finally{
|
|
11
|
-
`),e),e.log.trace('handle: responded with "%s" for "%s"',x,o);continue}if(t.includes(o))return e.log.trace('handle: respond with "%s" for "%s"',o,o),await
|
|
10
|
+
`)]),e.log.trace('optimistic: wrote ["%s", "%s", data] in source',x,t)}finally{h=!0,c=!1,g.resolve()}}async function D(){if(v){await _.promise;return}v=!0;try{e.log.trace("optimistic: reading multistream select header");let l=await B(u,e);if(e.log.trace('optimistic: read multistream select header "%s"',l),l===x&&(l=await B(u,e)),e.log.trace('optimistic: read protocol "%s", expecting "%s"',l,t),l!==t)throw new Q("protocol selection failed")}finally{m=!0,v=!1,_.resolve()}}if(r.source=(async function*(){await w(),e.log.trace('optimistic: reading data from "%s" stream',t),yield*u.unwrap().source})(),r.closeRead!=null){let l=r.closeRead.bind(r);r.closeRead=async b=>{s||await w().catch(d=>{e.log.error("could not negotiate protocol before close read",d)}),await l(b)}}if(r.closeWrite!=null){let l=r.closeWrite.bind(r);r.closeWrite=async b=>{s||await w().catch(d=>{e.log.error("could not negotiate protocol before close write",d)}),await l(b)}}if(r.close!=null){let l=r.close.bind(r);r.close=async b=>{let d=[];c&&d.push(g.promise),v&&d.push(_.promise),d.length>0?await G(Promise.all(d),b?.signal):(s=!0,i=!1,a.resolve()),await l(b)}}return{stream:r,protocol:t}}var be=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},K=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},xe=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},oe=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function ye(r){return r[Symbol.asyncIterator]!=null}function Mt(r,t){if(r.byteLength>t)throw new K("Message length too long")}var Le=r=>{let t=F(r),e=N(t);return $(r,e),Le.bytes=t,e};Le.bytes=0;function ve(r,t){t=t??{};let e=t.lengthEncoder??Le,n=t?.maxDataLength??4194304;function*o(s){Mt(s,n);let i=e(s.byteLength);i instanceof Uint8Array?yield i:yield*i,s instanceof Uint8Array?yield s:yield*s}return ye(r)?(async function*(){for await(let s of r)yield*o(s)})():(function*(){for(let s of r)yield*o(s)})()}ve.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??Le,n=t?.maxDataLength??4194304;return Mt(r,n),new y(e(r.byteLength),r)};var z;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(z||(z={}));var tt=r=>{let t=ue(r);return tt.bytes=F(t),t};tt.bytes=0;function et(r,t){let e=new y,n=z.LENGTH,o=-1,s=t?.lengthDecoder??tt,i=t?.maxLengthLength??8,a=t?.maxDataLength??4194304;function*h(){for(;e.byteLength>0;){if(n===z.LENGTH)try{if(o=s(e),o<0)throw new be("Invalid message length");if(o>a)throw new K("Message length too long");let c=s.bytes;e.consume(c),t?.onLength!=null&&t.onLength(o),n=z.DATA}catch(c){if(c instanceof RangeError){if(e.byteLength>i)throw new xe("Message length length too long");break}throw c}if(n===z.DATA){if(e.byteLength<o)break;let c=e.sublist(0,o);e.consume(o),t?.onData!=null&&t.onData(c),yield c,n=z.LENGTH}}}return ye(r)?(async function*(){for await(let c of r)e.append(c),yield*h();if(e.byteLength>0)throw new oe("Unexpected end of input")})():(function*(){for(let c of r)e.append(c),yield*h();if(e.byteLength>0)throw new oe("Unexpected end of input")})()}et.fromReader=(r,t)=>{let e=1,n=(async function*(){for(;;)try{let{done:s,value:i}=await r.next(e);if(s===!0)return;i!=null&&(yield i)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{e=1}})();return et(n,{...t??{},onLength:s=>{e=s}})};async function Rt(r,t,e){t=Array.isArray(t)?t:[t],e.log.trace("handle: available protocols %s",t);let n=Y(r,{...e,maxDataLength:1024,maxLengthLength:2});for(;;){e.log.trace("handle: reading incoming string");let o=await B(n,e);if(e.log.trace('handle: read "%s"',o),o===x){e.log.trace('handle: respond with "%s" for "%s"',x,o),await k(n,L(`${x}
|
|
11
|
+
`),e),e.log.trace('handle: responded with "%s" for "%s"',x,o);continue}if(t.includes(o))return e.log.trace('handle: respond with "%s" for "%s"',o,o),await k(n,L(`${o}
|
|
12
12
|
`),e),e.log.trace('handle: responded with "%s" for "%s"',o,o),{stream:n.unwrap(),protocol:o};if(o==="ls"){let s=new y(...t.map(i=>ve.single(L(`${i}
|
|
13
13
|
`))),L(`
|
|
14
|
-
`));e.log.trace('handle: respond with "%s" for %s',t,o),await
|
|
15
|
-
`),e),e.log('handle: responded with "na" for "%s"',o)}}return
|
|
14
|
+
`));e.log.trace('handle: respond with "%s" for %s',t,o),await k(n,s,e),e.log.trace('handle: responded with "%s" for %s',t,o);continue}e.log.trace('handle: respond with "na" for "%s"',o),await k(n,L(`na
|
|
15
|
+
`),e),e.log('handle: responded with "na" for "%s"',o)}}return Bt(an);})();
|
|
16
16
|
return Libp2PMultistreamSelect}));
|
|
17
17
|
//# sourceMappingURL=index.min.js.map
|