New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@libp2p/multistream-select

Package Overview
Dependencies
Maintainers
6
Versions
591
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libp2p/multistream-select - npm Package Compare versions

Comparing version 3.1.8 to 3.1.9-05abd49f

4

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PMultistreamSelect = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var Libp2PMultistreamSelect=(()=>{var Wt=Object.create;var me=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var er=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty;var be=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),L=(r,e)=>{for(var t in e)me(r,t,{get:e[t],enumerable:!0})},nt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Yt(e))!tr.call(r,o)&&o!==t&&me(r,o,{get:()=>e[o],enumerable:!(n=Zt(e,o))||n.enumerable});return r};var ot=(r,e,t)=>(t=r!=null?Wt(er(r)):{},nt(e||!r||!r.__esModule?me(t,"default",{value:r,enumerable:!0}):t,r)),rr=r=>nt(me({},"__esModule",{value:!0}),r);var it=be((Qn,st)=>{var W=1e3,Z=W*60,Y=Z*60,G=Y*24,nr=G*7,or=G*365.25;st.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return sr(r);if(t==="number"&&isFinite(r))return e.long?ar(r):ir(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function sr(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*or;case"weeks":case"week":case"w":return t*nr;case"days":case"day":case"d":return t*G;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Y;case"minutes":case"minute":case"mins":case"min":case"m":return t*Z;case"seconds":case"second":case"secs":case"sec":case"s":return t*W;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function ir(r){var e=Math.abs(r);return e>=G?Math.round(r/G)+"d":e>=Y?Math.round(r/Y)+"h":e>=Z?Math.round(r/Z)+"m":e>=W?Math.round(r/W)+"s":r+"ms"}function ar(r){var e=Math.abs(r);return e>=G?ge(r,e,G,"day"):e>=Y?ge(r,e,Y,"hour"):e>=Z?ge(r,e,Z,"minute"):e>=W?ge(r,e,W,"second"):r+" ms"}function ge(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var ct=be((Wn,at)=>{function cr(r){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=o,t.enabled=i,t.humanize=it(),t.destroy=d,Object.keys(r).forEach(u=>{t[u]=r[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let c=0;for(let h=0;h<u.length;h++)c=(c<<5)-c+u.charCodeAt(h),c|=0;return t.colors[Math.abs(c)%t.colors.length]}t.selectColor=e;function t(u){let c,h=null,E,p;function f(...m){if(!f.enabled)return;let g=f,x=Number(new Date),U=x-(c||x);g.diff=U,g.prev=c,g.curr=x,c=x,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let C=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(O,A)=>{if(O==="%%")return"%";C++;let T=t.formatters[A];if(typeof T=="function"){let Q=m[C];O=T.call(g,Q),m.splice(C,1),C--}return O}),t.formatArgs.call(g,m),(g.log||t.log).apply(g,m)}return f.namespace=u,f.useColors=t.useColors(),f.color=t.selectColor(u),f.extend=n,f.destroy=t.destroy,Object.defineProperty(f,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(E!==t.namespaces&&(E=t.namespaces,p=t.enabled(u)),p),set:m=>{h=m}}),typeof t.init=="function"&&t.init(f),f}function n(u,c){let h=t(this.namespace+(typeof c>"u"?":":c)+u);return h.log=this.log,h}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let c,h=(typeof u=="string"?u:"").split(/[\s,]+/),E=h.length;for(c=0;c<E;c++)h[c]&&(u=h[c].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...t.names.map(a),...t.skips.map(a).map(c=>"-"+c)].join(",");return t.enable(""),u}function i(u){if(u[u.length-1]==="*")return!0;let c,h;for(c=0,h=t.skips.length;c<h;c++)if(t.skips[c].test(u))return!1;for(c=0,h=t.names.length;c<h;c++)if(t.names[c].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function l(u){return u instanceof Error?u.stack||u.message:u}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}at.exports=cr});var ut=be((v,we)=>{v.formatArgs=fr;v.save=lr;v.load=hr;v.useColors=ur;v.storage=dr();v.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();v.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function ur(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function fr(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+we.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}v.log=console.debug||console.log||(()=>{});function lr(r){try{r?v.storage.setItem("debug",r):v.storage.removeItem("debug")}catch{}}function hr(){let r;try{r=v.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function dr(){try{return localStorage}catch{}}we.exports=ct()(v);var{formatters:pr}=we.exports;pr.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Et=be((ko,Ct)=>{"use strict";function xt(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function $r(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return xt(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),xt(new o,t)}}Ct.exports=$r});var Xn={};L(Xn,{PROTOCOL_ID:()=>N,handle:()=>Qt,lazySelect:()=>Kt,select:()=>Jt});var N="/multistream/1.0.0";var I=ot(ut(),1);var Re={};L(Re,{base58btc:()=>D,base58flickr:()=>xr});function mr(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=r.length,l=r.charAt(0),d=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function c(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var f=0,m=0,g=0,x=p.length;g!==x&&p[g]===0;)g++,f++;for(var U=(x-g)*u+1>>>0,C=new Uint8Array(U);g!==x;){for(var R=p[g],O=0,A=U-1;(R!==0||O<m)&&A!==-1;A--,O++)R+=256*C[A]>>>0,C[A]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");m=O,g++}for(var T=U-m;T!==U&&C[T]===0;)T++;for(var Q=l.repeat(f);T<U;++T)Q+=r.charAt(C[T]);return Q}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var f=0;if(p[f]!==" "){for(var m=0,g=0;p[f]===l;)m++,f++;for(var x=(p.length-f)*d+1>>>0,U=new Uint8Array(x);p[f];){var C=t[p.charCodeAt(f)];if(C===255)return;for(var R=0,O=x-1;(C!==0||R<g)&&O!==-1;O--,R++)C+=a*U[O]>>>0,U[O]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");g=R,f++}if(p[f]!==" "){for(var A=x-g;A!==x&&U[A]===0;)A++;for(var T=new Uint8Array(m+(x-A)),Q=m;A!==x;)T[Q++]=U[A++];return T}}}function E(p){var f=h(p);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:c,decodeUnsafe:h,decode:E}}var br=mr,gr=br,ft=gr;var Yn=new Uint8Array(0);var 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},M=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")};var ht=r=>new TextEncoder().encode(r),dt=r=>new TextDecoder().decode(r);var Te=class{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")}},Ne=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),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{constructor(e){this.decoders=e}or(e){return mt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},mt=(r,e)=>new De({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Ie=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Te(e,t,n),this.decoder=new Ne(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ee=({name:r,prefix:e,encode:t,decode:n})=>new Ie(r,e,t,n),P=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=ft(t,e);return ee({prefix:r,name:e,encode:n,decode:s=>M(o(s))})},wr=(r,e,t,n)=>{let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,l=0,d=0;for(let u=0;u<s;++u){let c=o[r[u]];if(c===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<t|c,a+=t,a>=8&&(a-=8,i[d++]=255&l>>a)}if(a>=t||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return i},yr=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let l=0;l<r.length;++l)for(a=a<<8|r[l],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},b=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>ee({prefix:e,name:r,encode(o){return yr(o,n,t)},decode(o){return wr(o,n,t,r)}});var D=P({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),xr=P({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ke={};L(ke,{base32:()=>z,base32hex:()=>Lr,base32hexpad:()=>Sr,base32hexpadupper:()=>Fr,base32hexupper:()=>vr,base32pad:()=>Er,base32padupper:()=>Ar,base32upper:()=>Cr,base32z:()=>Ur});var z=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Cr=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Er=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ar=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Lr=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),vr=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sr=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Fr=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ur=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Be={};L(Be,{base64:()=>Me,base64pad:()=>Or,base64url:()=>Tr,base64urlpad:()=>Nr});var Me=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Or=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Tr=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Nr=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});I.default.formatters.b=r=>r==null?"undefined":D.baseEncode(r);I.default.formatters.t=r=>r==null?"undefined":z.baseEncode(r);I.default.formatters.m=r=>r==null?"undefined":Me.baseEncode(r);I.default.formatters.p=r=>r==null?"undefined":r.toString();I.default.formatters.c=r=>r==null?"undefined":r.toString();I.default.formatters.k=r=>r==null?"undefined":r.toString();function Dr(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function te(r){let e=Dr(`${r}:trace`);return I.default.enabled(`${r}:trace`)&&I.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,I.default)(`${r}:trace`)),Object.assign((0,I.default)(r),{error:(0,I.default)(`${r}:error`),trace:e})}var V=class extends Error{constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};function j(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function B(r=0){return globalThis.Buffer?.alloc!=null?j(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function k(r=0){return globalThis.Buffer?.allocUnsafe!=null?j(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Pe(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=k(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return j(t)}function bt(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}var wt=Symbol.for("@achingbrain/uint8arraylist");function gt(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function ye(r){return!!r?.[wt]}var w=class{constructor(...e){Object.defineProperty(this,wt,{value:!0}),this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(ye(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(ye(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=gt(this.bufs,e);return t.buf[t.index]}set(e,t){let n=gt(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(ye(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return Pe(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:Pe(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),s=new w;return s.length=o,s.bufs=n,s}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===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,l=a+i.byteLength;if(o=l,e>=l)continue;let d=e>=a&&e<l,u=t>a&&t<=l;if(d&&u){if(e===a&&t===l){n.push(i);break}let c=e-a;n.push(i.subarray(c,c+(t-e)));break}if(d){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(u){if(t===l){n.push(i);break}n.push(i.subarray(0,t-a));break}n.push(i)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!ye(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;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 c=0;c<s;c++)i[c]=-1;for(let c=0;c<o;c++)i[n[c]]=c;let a=i,l=this.byteLength-n.byteLength,d=n.byteLength-1,u;for(let c=t;c<=l;c+=u){u=0;for(let h=d;h>=0;h--){let E=this.get(c+h);if(n[h]!==E){u=Math.max(1,h-a[E]);break}}if(u===0)return c}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=k(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=B(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=B(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=B(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=k(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=B(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=B(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=B(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=B(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=B(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof w)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!bt(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new w;return n.bufs=e,t==null&&(t=e.reduce((o,s)=>o+s.byteLength,0)),n.length=t,n}};function xe(r){return r instanceof Uint8Array?{get(e){return r[e]},set(e,t){r[e]=t}}:{get(e){return r.get(e)},set(e,t){r.set(e,t)}}}var yt=4294967296,S=class{constructor(e=0,t=0){this.hi=e,this.lo=t}toBigInt(e){if(e===!0)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(e){return Number(this.toBigInt(e))}zzDecode(){let e=-(this.lo&1),t=((this.lo>>>1|this.hi<<31)^e)>>>0,n=(this.hi>>>1^e)>>>0;return new S(n,t)}zzEncode(){let e=this.hi>>31,t=((this.hi<<1|this.lo>>>31)^e)>>>0,n=(this.lo<<1^e)>>>0;return new S(t,n)}toBytes(e,t=0){let n=xe(e);for(;this.hi>0;)n.set(t++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(t++,this.lo&127|128),this.lo=this.lo>>>7;n.set(t++,this.lo)}static fromBigInt(e){if(e===0n)return new S;let t=e<0;t&&(e=-e);let n=Number(e>>32n)|0,o=Number(e-(BigInt(n)<<32n))|0;return t&&(n=~n>>>0,o=~o>>>0,++o>yt&&(o=0,++n>yt&&(n=0))),new S(n,o)}static fromNumber(e){if(e===0)return new S;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new S(o,n)}static fromBytes(e,t=0){let n=xe(e),o=new S,s=0;if(e.length-t>4){for(;s<4;++s)if(o.lo=(o.lo|(n.get(t)&127)<<s*7)>>>0,n.get(t++)<128)return o;if(o.lo=(o.lo|(n.get(t)&127)<<28)>>>0,o.hi=(o.hi|(n.get(t)&127)>>4)>>>0,n.get(t++)<128)return o;s=0}else for(;s<4;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(o.lo=(o.lo|(n.get(t)&127)<<s*7)>>>0,n.get(t++)<128)return o}if(e.length-t>4){for(;s<5;++s)if(o.hi=(o.hi|(n.get(t)&127)<<s*7+3)>>>0,n.get(t++)<128)return o}else if(t<e.byteLength)for(;s<5;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(o.hi=(o.hi|(n.get(t)&127)<<s*7+3)>>>0,n.get(t++)<128)return o}throw RangeError("invalid varint encoding")}};var Ir=Math.pow(2,7),Rr=Math.pow(2,14),kr=Math.pow(2,21),Mr=Math.pow(2,28),Br=Math.pow(2,35),Pr=Math.pow(2,42),zr=Math.pow(2,49),Vr=Math.pow(2,56),_r=Math.pow(2,63),q={encodingLength(r){return r<Ir?1:r<Rr?2:r<kr?3:r<Mr?4:r<Br?5:r<Pr?6:r<zr?7:r<Vr?8:r<_r?9:10},encode(r,e,t=0){if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return e==null&&(e=k(q.encodingLength(r))),S.fromNumber(r).toBytes(e,t),e},decode(r,e=0){return S.fromBytes(r,e).toNumber(!0)}};function Ce(r){return r[Symbol.asyncIterator]!=null}var Ee=r=>{let e=q.encodingLength(r),t=k(e);return q.encode(r,t),Ee.bytes=e,t};Ee.bytes=0;function Ae(r,e){e=e??{};let t=e.lengthEncoder??Ee;function*n(o){let s=t(o.byteLength);s instanceof Uint8Array?yield s:yield*s,o instanceof Uint8Array?yield o:yield*o}return Ce(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}Ae.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??Ee;return new w(t(r.byteLength),r)};var re=ot(Et(),1);var Gr=8,jr=1024*1024*4,H;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(H||(H={}));var ze=r=>{let e=q.decode(r);return ze.bytes=q.encodingLength(e),e};ze.bytes=0;function ae(r,e){let t=new w,n=H.LENGTH,o=-1,s=e?.lengthDecoder??ze,i=e?.maxLengthLength??Gr,a=e?.maxDataLength??jr;function*l(){for(;t.byteLength>0;){if(n===H.LENGTH)try{if(o=s(t),o<0)throw(0,re.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>a)throw(0,re.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let d=s.bytes;t.consume(d),e?.onLength!=null&&e.onLength(o),n=H.DATA}catch(d){if(d instanceof RangeError){if(t.byteLength>i)throw(0,re.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw d}if(n===H.DATA){if(t.byteLength<o)break;let d=t.sublist(0,o);t.consume(o),e?.onData!=null&&e.onData(d),yield d,n=H.LENGTH}}}return Ce(r)?async function*(){for await(let d of r)t.append(d),yield*l();if(t.byteLength>0)throw(0,re.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let d of r)t.append(d),yield*l();if(t.byteLength>0)throw(0,re.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}ae.fromReader=(r,e)=>{let t=1,n=async function*(){for(;;)try{let{done:s,value:i}=await r.next(t);if(s===!0)return;i!=null&&(yield i)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{t=1}}();return ae(n,{...e??{},onLength:s=>{t=s}})};var Le=class{constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},ne=class{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Le(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new Le(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};function _(r={}){return Hr(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Hr(r,e){e=e??{};let t=e.onEnd,n=new ne,o,s,i,a=async()=>n.isEmpty()?i?{done:!0}:await new Promise((f,m)=>{s=g=>{s=null,n.push(g);try{f(r(n))}catch(x){m(x)}return o}}):r(n),l=f=>s!=null?s(f):(n.push(f),o),d=f=>(n=new ne,s!=null?s({error:f}):(n.push({error:f}),o)),u=f=>{if(i)return o;if(e?.objectMode!==!0&&f?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:f})},c=f=>i?o:(i=!0,f!=null?d(f):l({done:!0})),h=()=>(n=new ne,c(),{done:!0}),E=f=>(c(f),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:h,throw:E,push:u,end:c,get readableLength(){return n.size}},t==null)return o;let p=o;return o={[Symbol.asyncIterator](){return this},next(){return p.next()},throw(f){return p.throw(f),t!=null&&(t(f),t=void 0),{done:!0}},return(){return p.return(),t!=null&&(t(),t=void 0),{done:!0}},push:u,end(f){return p.end(f),t!=null&&(t(f),t=void 0),o},get readableLength(){return p.readableLength}},o}function Xr(r){return r[Symbol.asyncIterator]!=null}function Jr(...r){let e=[];for(let t of r)Xr(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=_({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)t.push(o)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var ve=Jr;function At(r,...e){if(r==null)throw new Error("Empty pipeline");if(Ve(r)){let n=r;r=()=>n.source}else if(vt(r)||Lt(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&Ve(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)Ve(t[n])&&(t[n]=Qr(t[n]));return Kr(...t)}var Kr=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},Lt=r=>r?.[Symbol.asyncIterator]!=null,vt=r=>r?.[Symbol.iterator]!=null,Ve=r=>r==null?!1:r.sink!=null&&r.source!=null,Qr=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=_({objectMode:!0});t.then(()=>{n.end()},i=>{n.end(i)});let o,s=r.source;if(Lt(s))o=async function*(){yield*s,n.end()};else if(vt(s))o=function*(){yield*s,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return ve(n,o())}return r.source};var _e={};L(_e,{identity:()=>Wr});var Wr=ee({prefix:"\0",name:"identity",encode:r=>dt(r),decode:r=>ht(r)});var $e={};L($e,{base2:()=>Zr});var Zr=b({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ge={};L(Ge,{base8:()=>Yr});var Yr=b({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var je={};L(je,{base10:()=>en});var en=P({prefix:"9",name:"base10",alphabet:"0123456789"});var qe={};L(qe,{base16:()=>tn,base16upper:()=>rn});var tn=b({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),rn=b({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var He={};L(He,{base36:()=>nn,base36upper:()=>on});var nn=P({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),on=P({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Xe={};L(Xe,{base256emoji:()=>fn});var St=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}"),sn=St.reduce((r,e,t)=>(r[t]=e,r),[]),an=St.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function cn(r){return r.reduce((e,t)=>(e+=sn[t],e),"")}function un(r){let e=[];for(let t of r){let n=an[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var fn=ee({prefix:"\u{1F680}",name:"base256emoji",encode:cn,decode:un});var We={};L(We,{sha256:()=>On,sha512:()=>Tn});var ln=Ot,Ft=128,hn=127,dn=~hn,pn=Math.pow(2,31);function Ot(r,e,t){e=e||[],t=t||0;for(var n=t;r>=pn;)e[t++]=r&255|Ft,r/=128;for(;r&dn;)e[t++]=r&255|Ft,r>>>=7;return e[t]=r|0,Ot.bytes=t-n+1,e}var mn=Je,bn=128,Ut=127;function Je(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Je.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Ut)<<o:(i&Ut)*Math.pow(2,o),o+=7}while(i>=bn);return Je.bytes=s-n,t}var gn=Math.pow(2,7),wn=Math.pow(2,14),yn=Math.pow(2,21),xn=Math.pow(2,28),Cn=Math.pow(2,35),En=Math.pow(2,42),An=Math.pow(2,49),Ln=Math.pow(2,56),vn=Math.pow(2,63),Sn=function(r){return r<gn?1:r<wn?2:r<yn?3:r<xn?4:r<Cn?5:r<En?6:r<An?7:r<Ln?8:r<vn?9:10},Fn={encode:ln,decode:mn,encodingLength:Sn},Un=Fn,ce=Un;var ue=(r,e=0)=>[ce.decode(r,e),ce.decode.bytes],oe=(r,e,t=0)=>(ce.encode(r,e,t),e),se=r=>ce.encodingLength(r);var X=(r,e)=>{let t=e.byteLength,n=se(r),o=n+se(t),s=new Uint8Array(o+t);return oe(r,s,0),oe(t,s,n),s.set(e,o),new ie(r,t,e,s)},Tt=r=>{let e=M(r),[t,n]=ue(e),[o,s]=ue(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ie(t,o,i,e)},Nt=(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)}},ie=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Qe=({name:r,code:e,encode:t})=>new Ke(r,e,t),Ke=class{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?X(this.code,t):t.then(n=>X(this.code,n))}else throw Error("Unknown type, must be binary type")}};var It=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),On=Qe({name:"sha2-256",code:18,encode:It("SHA-256")}),Tn=Qe({name:"sha2-512",code:19,encode:It("SHA-512")});var Ze={};L(Ze,{identity:()=>In});var Rt=0,Nn="identity",kt=M,Dn=r=>X(Rt,kt(r)),In={code:Rt,name:Nn,encode:kt,digest:Dn};var fs=new TextEncoder,ls=new TextDecoder;var Mt=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Bn(t,Ye(r),e||D.encoder);default:return Pn(t,Ye(r),e||z.encoder)}};var Bt=new WeakMap,Ye=r=>{let e=Bt.get(r);if(e==null){let t=new Map;return Bt.set(r,t),t}return e},y=class{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!==le)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==zn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return y.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=X(e,t);return y.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 y.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Nt(e.multihash,n.multihash)}toString(e){return Mt(this,e)}toJSON(){return{"/":Mt(this)}}link(){return this}get[Symbol.toStringTag](){return"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 y)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new y(n,o,s,i||Pt(n,o,s.bytes))}else if(t[Vn]===!0){let{version:n,multihash:o,code:s}=t,i=Tt(o);return y.create(n,s,i)}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!==le)throw new Error(`Version 0 CID must use dag-pb (code: ${le}) block encoding`);return new y(e,t,n,n.bytes)}case 1:{let o=Pt(e,t,n.bytes);return new y(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return y.create(0,le,e)}static createV1(e,t){return y.create(1,e,t)}static decode(e){let[t,n]=y.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=y.inspectBytes(e),n=t.size-t.multihashSize,o=M(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new ie(t.multihashCode,t.digestSize,s,o);return[t.version===0?y.createV0(i):y.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[c,h]=ue(e.subarray(t));return t+=h,c},o=n(),s=le;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),l=n(),d=t+l,u=d-i;return{version:o,codec:s,multihashCode:a,digestSize:l,multihashSize:u,size:d}}static parse(e,t){let[n,o]=Mn(e,t),s=y.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ye(s).set(n,e),s}},Mn=(r,e)=>{switch(r[0]){case"Q":{let t=e||D;return[D.prefix,t.decode(`${D.prefix}${r}`)]}case D.prefix:{let t=e||D;return[D.prefix,t.decode(r)]}case z.prefix:{let t=e||z;return[z.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},Bn=(r,e,t)=>{let{prefix:n}=t;if(n!==D.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},Pn=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},le=112,zn=18,Pt=(r,e,t)=>{let n=se(r),o=n+se(e),s=new Uint8Array(o+t.byteLength);return oe(r,s,0),oe(e,s,n),s.set(t,o),s},Vn=Symbol.for("@ipld/js-cid/CID");var et={..._e,...$e,...Ge,...je,...qe,...ke,...He,...Re,...Be,...Xe},Cs={...We,...Ze};function Vt(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var zt=Vt("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),tt=Vt("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=k(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),_n={utf8:zt,"utf-8":zt,hex:et.base16,latin1:tt,ascii:tt,binary:tt,...et},Fe=_n;function F(r,e="utf8"){let t=Fe[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?j(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function $n(r){return r[Symbol.asyncIterator]!=null}function Gn(r){if($n(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var _t=Gn;var he=class extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function $t(r){if(r!=null){if(typeof r[Symbol.iterator]=="function")return r[Symbol.iterator]();if(typeof r[Symbol.asyncIterator]=="function")return r[Symbol.asyncIterator]();if(typeof r.next=="function")return r}throw new Error("argument is not an iterator or iterable")}function Gt(r,e,t){let n=t??{},o=$t(r);async function*s(){let i,a=()=>{i?.()};for(e.addEventListener("abort",a);;){let l;try{if(e.aborted){let{abortMessage:u,abortCode:c}=n;throw new he(u,c)}let d=new Promise((u,c)=>{i=()=>{let{abortMessage:h,abortCode:E}=n;c(new he(h,E))}});l=await Promise.race([d,o.next()]),i=null}catch(d){e.removeEventListener("abort",a);let u=d.type==="aborted"&&e.aborted;if(u&&n.onAbort!=null&&n.onAbort(r),typeof o.return=="function")try{let c=o.return();c instanceof Promise&&c.catch(h=>{n.onReturnError!=null&&n.onReturnError(h)})}catch(c){n.onReturnError!=null&&n.onReturnError(c)}if(u&&n.returnOnAbort===!0)return;throw d}if(l.done===!0)break;yield l.value}e.removeEventListener("abort",a)}return s()}function jt(r,e="utf8"){let t=Fe[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var qn=te("libp2p:mss"),qt=F(`
`);function J(r){let e=new w(r,qt);return Ae.single(e)}function K(r,e,t={}){let n=J(e);t.writeBytes===!0?r.push(n.subarray()):r.push(n)}function Ht(r,e,t={}){let n=new w;for(let o of e)n.append(J(o));t.writeBytes===!0?r.push(n.subarray()):r.push(n)}async function Hn(r,e){let t=1,n={[Symbol.asyncIterator]:()=>n,next:async()=>await r.next(t)},o=n;e?.signal!=null&&(o=Gt(n,e.signal));let s=a=>{t=a},i=await At(o,a=>ae(a,{onLength:s,maxDataLength:1024}),async a=>await _t(a));if(i==null||i.length===0)throw new V("no buffer returned","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(i.get(i.byteLength-1)!==qt[0])throw qn.error("Invalid mss message - missing newline - %s",i.subarray()),new V("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return i.sublist(0,-1)}async function $(r,e){let t=await Hn(r,e);return jt(t.subarray())}function Ue(r){let e=async function*(){let t=yield,n=new w;for await(let o of r){if(t==null){n.append(o),t=yield n,n=new w;continue}for(n.append(o);n.length>=t;){let s=n.sublist(0,t);if(n.consume(t),t=yield s,t==null){n.length>0&&(t=yield n,n=new w);break}}}if(t!=null)throw Object.assign(new Error(`stream ended before ${t} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return e.next(),e}function rt(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}function Oe(r){let e=_(),t=Ue(r.source),n=rt(),o,s=r.sink(async function*(){yield*e,yield*await n.promise}());return s.catch(a=>{o=a}),{reader:t,writer:e,stream:{sink:async a=>{if(o!=null){await Promise.reject(o);return}n.resolve(a),await s},source:t},rest:()=>e.end(),write:e.push,read:async()=>{let a=await t.next();if(a.value!=null)return a.value}}}var de=te("libp2p:mss:select");async function Jt(r,e,t={}){e=Array.isArray(e)?[...e]:[e];let{reader:n,writer:o,rest:s,stream:i}=Oe(r),a=e.shift();if(a==null)throw new Error("At least one protocol must be specified");de.trace('select: write ["%s", "%s"]',N,a);let l=F(N),d=F(a);Ht(o,[l,d],t);let u=await $(n,t);if(de.trace('select: read "%s"',u),u===N&&(u=await $(n,t),de.trace('select: read "%s"',u)),u===a)return s(),{stream:i,protocol:a};for(let c of e){de.trace('select: write "%s"',c),K(o,F(c),t);let h=await $(n,t);if(de.trace('select: read "%s" for "%s"',h,c),h===c)return s(),{stream:i,protocol:c}}throw s(),new V("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}function Kt(r,e){let t=_(),n=!1;return{stream:{sink:async o=>{await r.sink(async function*(){let s=!0;for await(let i of ve(o,t))if(s){s=!1,n=!0,t.end();let a=F(N),l=F(e),d=new w(J(a),J(l));i.length>0&&d.append(i),yield*d}else yield i}())},source:async function*(){n||t.push(new Uint8Array);let o=Ue(r.source),s=await $(o);if(s===N&&(s=await $(o)),s!==e)throw new V("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL");for await(let i of o)yield*i}()},protocol:e}}var pe=te("libp2p:mss:handle");async function Qt(r,e,t){e=Array.isArray(e)?e:[e];let{writer:n,reader:o,rest:s,stream:i}=Oe(r);for(;;){let a=await $(o,t);if(pe.trace('read "%s"',a),a===N){pe.trace('respond with "%s" for "%s"',N,a),K(n,F(N),t);continue}if(e.includes(a))return K(n,F(a),t),pe.trace('respond with "%s" for "%s"',a,a),s(),{stream:i,protocol:a};if(a==="ls"){K(n,new w(...e.map(l=>J(F(l)))),t),pe.trace('respond with "%s" for %s',e,a);continue}K(n,F("na"),t),pe('respond with "na" for "%s"',a)}}return rr(Xn);})();
"use strict";var Libp2PMultistreamSelect=(()=>{var fr=Object.create;var me=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var hr=Object.getPrototypeOf,dr=Object.prototype.hasOwnProperty;var ge=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),N=(r,e)=>{for(var t in e)me(r,t,{get:e[t],enumerable:!0})},ct=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of lr(e))!dr.call(r,o)&&o!==t&&me(r,o,{get:()=>e[o],enumerable:!(n=ur(e,o))||n.enumerable});return r};var ft=(r,e,t)=>(t=r!=null?fr(hr(r)):{},ct(e||!r||!r.__esModule?me(t,"default",{value:r,enumerable:!0}):t,r)),pr=r=>ct(me({},"__esModule",{value:!0}),r);var lt=ge((wo,ut)=>{var W=1e3,Y=W*60,Z=Y*60,j=Z*24,br=j*7,mr=j*365.25;ut.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return gr(r);if(t==="number"&&isFinite(r))return e.long?yr(r):wr(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function gr(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*mr;case"weeks":case"week":case"w":return t*br;case"days":case"day":case"d":return t*j;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Z;case"minutes":case"minute":case"mins":case"min":case"m":return t*Y;case"seconds":case"second":case"secs":case"sec":case"s":return t*W;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function wr(r){var e=Math.abs(r);return e>=j?Math.round(r/j)+"d":e>=Z?Math.round(r/Z)+"h":e>=Y?Math.round(r/Y)+"m":e>=W?Math.round(r/W)+"s":r+"ms"}function yr(r){var e=Math.abs(r);return e>=j?we(r,e,j,"day"):e>=Z?we(r,e,Z,"hour"):e>=Y?we(r,e,Y,"minute"):e>=W?we(r,e,W,"second"):r+" ms"}function we(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var dt=ge((yo,ht)=>{function xr(r){t.debug=t,t.default=t,t.coerce=h,t.disable=s,t.enable=o,t.enabled=a,t.humanize=lt(),t.destroy=p,Object.keys(r).forEach(c=>{t[c]=r[c]}),t.names=[],t.skips=[],t.formatters={};function e(c){let f=0;for(let d=0;d<c.length;d++)f=(f<<5)-f+c.charCodeAt(d),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(c){let f,d=null,U,l;function u(...m){if(!u.enabled)return;let b=u,w=Number(new Date),x=w-(f||w);b.diff=x,b.prev=f,b.curr=w,f=w,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let g=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(v,y)=>{if(v==="%%")return"%";g++;let A=t.formatters[y];if(typeof A=="function"){let k=m[g];v=A.call(b,k),m.splice(g,1),g--}return v}),t.formatArgs.call(b,m),(b.log||t.log).apply(b,m)}return u.namespace=c,u.useColors=t.useColors(),u.color=t.selectColor(c),u.extend=n,u.destroy=t.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(U!==t.namespaces&&(U=t.namespaces,l=t.enabled(c)),l),set:m=>{d=m}}),typeof t.init=="function"&&t.init(u),u}function n(c,f){let d=t(this.namespace+(typeof f>"u"?":":f)+c);return d.log=this.log,d}function o(c){t.save(c),t.namespaces=c,t.names=[],t.skips=[];let f,d=(typeof c=="string"?c:"").split(/[\s,]+/),U=d.length;for(f=0;f<U;f++)d[f]&&(c=d[f].replace(/\*/g,".*?"),c[0]==="-"?t.skips.push(new RegExp("^"+c.slice(1)+"$")):t.names.push(new RegExp("^"+c+"$")))}function s(){let c=[...t.names.map(i),...t.skips.map(i).map(f=>"-"+f)].join(",");return t.enable(""),c}function a(c){if(c[c.length-1]==="*")return!0;let f,d;for(f=0,d=t.skips.length;f<d;f++)if(t.skips[f].test(c))return!1;for(f=0,d=t.names.length;f<d;f++)if(t.names[f].test(c))return!0;return!1}function i(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function h(c){return c instanceof Error?c.stack||c.message:c}function p(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}ht.exports=xr});var pt=ge((O,ye)=>{O.formatArgs=Ar;O.save=Er;O.load=vr;O.useColors=Cr;O.storage=Lr();O.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();O.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Cr(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Ar(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+ye.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}O.log=console.debug||console.log||(()=>{});function Er(r){try{r?O.storage.setItem("debug",r):O.storage.removeItem("debug")}catch{}}function vr(){let r;try{r=O.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Lr(){try{return localStorage}catch{}}ye.exports=dt()(O);var{formatters:Sr}=ye.exports;Sr.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Yt=ge((Ai,Wt)=>{"use strict";function Qt(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function ro(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return Qt(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Qt(new o,t)}}Wt.exports=ro});var lo={};N(lo,{PROTOCOL_ID:()=>I,handle:()=>cr,lazySelect:()=>ar,select:()=>ir});var I="/multistream/1.0.0";var V=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var T=ft(pt(),1);function Ur(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 s=r.charAt(o),a=s.charCodeAt(0);if(t[a]!==255)throw new TypeError(s+" is ambiguous");t[a]=o}var i=r.length,h=r.charAt(0),p=Math.log(i)/Math.log(256),c=Math.log(256)/Math.log(i);function f(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 u=0,m=0,b=0,w=l.length;b!==w&&l[b]===0;)b++,u++;for(var x=(w-b)*c+1>>>0,g=new Uint8Array(x);b!==w;){for(var C=l[b],v=0,y=x-1;(C!==0||v<m)&&y!==-1;y--,v++)C+=256*g[y]>>>0,g[y]=C%i>>>0,C=C/i>>>0;if(C!==0)throw new Error("Non-zero carry");m=v,b++}for(var A=x-m;A!==x&&g[A]===0;)A++;for(var k=h.repeat(u);A<x;++A)k+=r.charAt(g[A]);return k}function d(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var u=0;if(l[u]!==" "){for(var m=0,b=0;l[u]===h;)m++,u++;for(var w=(l.length-u)*p+1>>>0,x=new Uint8Array(w);l[u];){var g=t[l.charCodeAt(u)];if(g===255)return;for(var C=0,v=w-1;(g!==0||C<b)&&v!==-1;v--,C++)g+=i*x[v]>>>0,x[v]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");b=C,u++}if(l[u]!==" "){for(var y=w-b;y!==w&&x[y]===0;)y++;for(var A=new Uint8Array(m+(w-y)),k=m;y!==w;)A[k++]=x[y++];return A}}}function U(l){var u=d(l);if(u)return u;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:d,decode:U}}var Fr=Ur,Nr=Fr,bt=Nr;var Co=new Uint8Array(0);var mt=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")};var Te=class{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")}},De=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),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 gt(this,e)}},Re=class{constructor(e){this.decoders=e}or(e){return gt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},gt=(r,e)=>new Re({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Ie=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Te(e,t,n),this.decoder=new De(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},wt=({name:r,prefix:e,encode:t,decode:n})=>new Ie(r,e,t,n),ke=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=bt(t,e);return wt({prefix:r,name:e,encode:n,decode:s=>mt(o(s))})},Or=(r,e,t,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*t/8|0),i=0,h=0,p=0;for(let c=0;c<s;++c){let f=o[r[c]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<t|f,i+=t,i>=8&&(i-=8,a[p++]=255&h>>i)}if(i>=t||255&h<<8-i)throw new SyntaxError("Unexpected end of data");return a},Tr=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",a=0,i=0;for(let h=0;h<r.length;++h)for(i=i<<8|r[h],a+=8;a>t;)a-=t,s+=e[o&i>>a];if(a&&(s+=e[o&i<<t-a]),n)for(;s.length*t&7;)s+="=";return s},F=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>wt({prefix:e,name:r,encode(o){return Tr(o,n,t)},decode(o){return Or(o,n,t,r)}});var yt=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Uo=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Fo=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),No=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Oo=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),To=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Do=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ro=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Io=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var xt=ke({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bo=ke({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ct=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Vo=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_o=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$o=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});T.default.formatters.b=r=>r==null?"undefined":xt.baseEncode(r);T.default.formatters.t=r=>r==null?"undefined":yt.baseEncode(r);T.default.formatters.m=r=>r==null?"undefined":Ct.baseEncode(r);T.default.formatters.p=r=>r==null?"undefined":r.toString();T.default.formatters.c=r=>r==null?"undefined":r.toString();T.default.formatters.k=r=>r==null?"undefined":r.toString();T.default.formatters.a=r=>r==null?"undefined":r.toString();function Dr(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function ee(r){let e=Dr(`${r}:trace`);return T.default.enabled(`${r}:trace`)&&T.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,T.default)(`${r}:trace`)),Object.assign((0,T.default)(r),{error:(0,T.default)(`${r}:error`),trace:e})}function q(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function P(r=0){return globalThis.Buffer?.alloc!=null?q(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function M(r=0){return globalThis.Buffer?.allocUnsafe!=null?q(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Me(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=M(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return q(t)}function At(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}var vt=Symbol.for("@achingbrain/uint8arraylist");function Et(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function xe(r){return!!r?.[vt]}var L=class{constructor(...e){Object.defineProperty(this,vt,{value:!0}),this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(xe(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(xe(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=Et(this.bufs,e);return t.buf[t.index]}set(e,t){let n=Et(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(xe(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return Me(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:Me(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),s=new L;return s.length=o,s.bufs=n,s}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let a=this.bufs[s],i=o,h=i+a.byteLength;if(o=h,e>=h)continue;let p=e>=i&&e<h,c=t>i&&t<=h;if(p&&c){if(e===i&&t===h){n.push(a);break}let f=e-i;n.push(a.subarray(f,f+(t-e)));break}if(p){if(e===0){n.push(a);continue}n.push(a.subarray(e-i));continue}if(c){if(t===h){n.push(a);break}n.push(a.subarray(0,t-i));break}n.push(a)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!xe(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,a=new Int32Array(s);for(let f=0;f<s;f++)a[f]=-1;for(let f=0;f<o;f++)a[n[f]]=f;let i=a,h=this.byteLength-n.byteLength,p=n.byteLength-1,c;for(let f=t;f<=h;f+=c){c=0;for(let d=p;d>=0;d--){let U=this.get(f+d);if(n[d]!==U){c=Math.max(1,d-i[U]);break}}if(c===0)return f}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=M(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=P(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=P(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=P(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=M(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=P(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=P(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=P(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=P(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=P(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof L)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!At(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new L;return n.bufs=e,t==null&&(t=e.reduce((o,s)=>o+s.byteLength,0)),n.length=t,n}};function Ce(r){let e=async function*(){let t=yield,n=new L;for await(let o of r){if(t==null){n.append(o),t=yield n,n=new L;continue}for(n.append(o);n.length>=t;){let s=n.sublist(0,t);if(n.consume(t),t=yield s,t==null){n.length>0&&(t=yield n,n=new L);break}}}if(t!=null)throw Object.assign(new Error(`stream ended before ${t} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return e.next(),e}var Ae=class{constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},te=class{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Ae(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new Ae(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};function _(r={}){return Rr(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Rr(r,e){e=e??{};let t=e.onEnd,n=new te,o,s,a,i=async()=>n.isEmpty()?a?{done:!0}:await new Promise((u,m)=>{s=b=>{s=null,n.push(b);try{u(r(n))}catch(w){m(w)}return o}}):r(n),h=u=>s!=null?s(u):(n.push(u),o),p=u=>(n=new te,s!=null?s({error:u}):(n.push({error:u}),o)),c=u=>{if(a)return o;if(e?.objectMode!==!0&&u?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return h({done:!1,value:u})},f=u=>a?o:(a=!0,u!=null?p(u):h({done:!0})),d=()=>(n=new te,f(),{done:!0}),U=u=>(f(u),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:i,return:d,throw:U,push:c,end:f,get readableLength(){return n.size}},t==null)return o;let l=o;return o={[Symbol.asyncIterator](){return this},next(){return l.next()},throw(u){return l.throw(u),t!=null&&(t(u),t=void 0),{done:!0}},return(){return l.return(),t!=null&&(t(),t=void 0),{done:!0}},push:c,end(u){return l.end(u),t!=null&&(t(u),t=void 0),o},get readableLength(){return l.readableLength}},o}function Be(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}function Ee(r){let e=_(),t=Ce(r.source),n=Be(),o,s=r.sink(async function*(){yield*e,yield*await n.promise}());return s.catch(i=>{o=i}),{reader:t,writer:e,stream:{sink:async i=>{if(o!=null){await Promise.reject(o);return}n.resolve(i),await s},source:t},rest:()=>e.end(),write:e.push,read:async()=>{let i=await t.next();if(i.value!=null)return i.value}}}function Ir(r){return r[Symbol.asyncIterator]!=null}function kr(...r){let e=[];for(let t of r)Ir(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=_({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)t.push(o)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var ve=kr;var $e={};N($e,{identity:()=>_r});function Mr(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 s=r.charAt(o),a=s.charCodeAt(0);if(t[a]!==255)throw new TypeError(s+" is ambiguous");t[a]=o}var i=r.length,h=r.charAt(0),p=Math.log(i)/Math.log(256),c=Math.log(256)/Math.log(i);function f(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 u=0,m=0,b=0,w=l.length;b!==w&&l[b]===0;)b++,u++;for(var x=(w-b)*c+1>>>0,g=new Uint8Array(x);b!==w;){for(var C=l[b],v=0,y=x-1;(C!==0||v<m)&&y!==-1;y--,v++)C+=256*g[y]>>>0,g[y]=C%i>>>0,C=C/i>>>0;if(C!==0)throw new Error("Non-zero carry");m=v,b++}for(var A=x-m;A!==x&&g[A]===0;)A++;for(var k=h.repeat(u);A<x;++A)k+=r.charAt(g[A]);return k}function d(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var u=0;if(l[u]!==" "){for(var m=0,b=0;l[u]===h;)m++,u++;for(var w=(l.length-u)*p+1>>>0,x=new Uint8Array(w);l[u];){var g=t[l.charCodeAt(u)];if(g===255)return;for(var C=0,v=w-1;(g!==0||C<b)&&v!==-1;v--,C++)g+=i*x[v]>>>0,x[v]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");b=C,u++}if(l[u]!==" "){for(var y=w-b;y!==w&&x[y]===0;)y++;for(var A=new Uint8Array(m+(w-y)),k=m;y!==w;)A[k++]=x[y++];return A}}}function U(l){var u=d(l);if(u)return u;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:d,decode:U}}var Br=Mr,Pr=Br,Lt=Pr;var ws=new Uint8Array(0);var St=(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},z=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")};var Ut=r=>new TextEncoder().encode(r),Ft=r=>new TextDecoder().decode(r);var Pe=class{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")}},ze=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),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 Ot(this,e)}},Ve=class{constructor(e){this.decoders=e}or(e){return Ot(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Ot=(r,e)=>new Ve({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),_e=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Pe(e,t,n),this.decoder=new ze(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},re=({name:r,prefix:e,encode:t,decode:n})=>new _e(r,e,t,n),$=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Lt(t,e);return re({prefix:r,name:e,encode:n,decode:s=>z(o(s))})},zr=(r,e,t,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*t/8|0),i=0,h=0,p=0;for(let c=0;c<s;++c){let f=o[r[c]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<t|f,i+=t,i>=8&&(i-=8,a[p++]=255&h>>i)}if(i>=t||255&h<<8-i)throw new SyntaxError("Unexpected end of data");return a},Vr=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",a=0,i=0;for(let h=0;h<r.length;++h)for(i=i<<8|r[h],a+=8;a>t;)a-=t,s+=e[o&i>>a];if(a&&(s+=e[o&i<<t-a]),n)for(;s.length*t&7;)s+="=";return s},E=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>re({prefix:e,name:r,encode(o){return Vr(o,n,t)},decode(o){return zr(o,n,t,r)}});var _r=re({prefix:"\0",name:"identity",encode:r=>Ft(r),decode:r=>Ut(r)});var Ge={};N(Ge,{base2:()=>$r});var $r=E({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var je={};N(je,{base8:()=>Gr});var Gr=E({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qe={};N(qe,{base10:()=>jr});var jr=$({prefix:"9",name:"base10",alphabet:"0123456789"});var Xe={};N(Xe,{base16:()=>qr,base16upper:()=>Xr});var qr=E({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Xr=E({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Je={};N(Je,{base32:()=>ne,base32hex:()=>Qr,base32hexpad:()=>Yr,base32hexpadupper:()=>Zr,base32hexupper:()=>Wr,base32pad:()=>Hr,base32padupper:()=>Kr,base32upper:()=>Jr,base32z:()=>en});var ne=E({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Jr=E({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Hr=E({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Kr=E({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Qr=E({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Wr=E({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Yr=E({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zr=E({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),en=E({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var He={};N(He,{base36:()=>tn,base36upper:()=>rn});var tn=$({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),rn=$({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ke={};N(Ke,{base58btc:()=>B,base58flickr:()=>nn});var B=$({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),nn=$({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Qe={};N(Qe,{base64:()=>on,base64pad:()=>sn,base64url:()=>an,base64urlpad:()=>cn});var on=E({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sn=E({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),an=E({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cn=E({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var We={};N(We,{base256emoji:()=>dn});var Tt=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}"),fn=Tt.reduce((r,e,t)=>(r[t]=e,r),[]),un=Tt.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ln(r){return r.reduce((e,t)=>(e+=fn[t],e),"")}function hn(r){let e=[];for(let t of r){let n=un[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var dn=re({prefix:"\u{1F680}",name:"base256emoji",encode:ln,decode:hn});var tt={};N(tt,{sha256:()=>Dn,sha512:()=>Rn});var pn=It,Dt=128,bn=127,mn=~bn,gn=Math.pow(2,31);function It(r,e,t){e=e||[],t=t||0;for(var n=t;r>=gn;)e[t++]=r&255|Dt,r/=128;for(;r&mn;)e[t++]=r&255|Dt,r>>>=7;return e[t]=r|0,It.bytes=t-n+1,e}var wn=Ye,yn=128,Rt=127;function Ye(r,n){var t=0,n=n||0,o=0,s=n,a,i=r.length;do{if(s>=i)throw Ye.bytes=0,new RangeError("Could not decode varint");a=r[s++],t+=o<28?(a&Rt)<<o:(a&Rt)*Math.pow(2,o),o+=7}while(a>=yn);return Ye.bytes=s-n,t}var xn=Math.pow(2,7),Cn=Math.pow(2,14),An=Math.pow(2,21),En=Math.pow(2,28),vn=Math.pow(2,35),Ln=Math.pow(2,42),Sn=Math.pow(2,49),Un=Math.pow(2,56),Fn=Math.pow(2,63),Nn=function(r){return r<xn?1:r<Cn?2:r<An?3:r<En?4:r<vn?5:r<Ln?6:r<Sn?7:r<Un?8:r<Fn?9:10},On={encode:pn,decode:wn,encodingLength:Nn},Tn=On,ce=Tn;var fe=(r,e=0)=>[ce.decode(r,e),ce.decode.bytes],oe=(r,e,t=0)=>(ce.encode(r,e,t),e),se=r=>ce.encodingLength(r);var X=(r,e)=>{let t=e.byteLength,n=se(r),o=n+se(t),s=new Uint8Array(o+t);return oe(r,s,0),oe(t,s,n),s.set(e,o),new ie(r,t,e,s)},kt=r=>{let e=z(r),[t,n]=fe(e),[o,s]=fe(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new ie(t,o,a,e)},Mt=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&St(r.bytes,t.bytes)}},ie=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var et=({name:r,code:e,encode:t})=>new Ze(r,e,t),Ze=class{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?X(this.code,t):t.then(n=>X(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Pt=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Dn=et({name:"sha2-256",code:18,encode:Pt("SHA-256")}),Rn=et({name:"sha2-512",code:19,encode:Pt("SHA-512")});var rt={};N(rt,{identity:()=>Mn});var zt=0,In="identity",Vt=z,kn=r=>X(zt,Vt(r)),Mn={code:zt,name:In,encode:Vt,digest:kn};var zs=new TextEncoder,Vs=new TextDecoder;var _t=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Vn(t,nt(r),e||B.encoder);default:return _n(t,nt(r),e||ne.encoder)}};var $t=new WeakMap,nt=r=>{let e=$t.get(r);if(e==null){let t=new Map;return $t.set(r,t),t}return e},S=class{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!==le)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$n)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return S.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=X(e,t);return S.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 S.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Mt(e.multihash,n.multihash)}toString(e){return _t(this,e)}toJSON(){return{"/":_t(this)}}link(){return this}get[Symbol.toStringTag](){return"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 S)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:a}=t;return new S(n,o,s,a||Gt(n,o,s.bytes))}else if(t[Gn]===!0){let{version:n,multihash:o,code:s}=t,a=kt(o);return S.create(n,s,a)}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!==le)throw new Error(`Version 0 CID must use dag-pb (code: ${le}) block encoding`);return new S(e,t,n,n.bytes)}case 1:{let o=Gt(e,t,n.bytes);return new S(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return S.create(0,le,e)}static createV1(e,t){return S.create(1,e,t)}static decode(e){let[t,n]=S.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=S.inspectBytes(e),n=t.size-t.multihashSize,o=z(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),a=new ie(t.multihashCode,t.digestSize,s,o);return[t.version===0?S.createV0(a):S.createV1(t.codec,a),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,d]=fe(e.subarray(t));return t+=d,f},o=n(),s=le;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=t,i=n(),h=n(),p=t+h,c=p-a;return{version:o,codec:s,multihashCode:i,digestSize:h,multihashSize:c,size:p}}static parse(e,t){let[n,o]=zn(e,t),s=S.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return nt(s).set(n,e),s}},zn=(r,e)=>{switch(r[0]){case"Q":{let t=e||B;return[B.prefix,t.decode(`${B.prefix}${r}`)]}case B.prefix:{let t=e||B;return[B.prefix,t.decode(r)]}case ne.prefix:{let t=e||ne;return[ne.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},Vn=(r,e,t)=>{let{prefix:n}=t;if(n!==B.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},_n=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},le=112,$n=18,Gt=(r,e,t)=>{let n=se(r),o=n+se(e),s=new Uint8Array(o+t.byteLength);return oe(r,s,0),oe(e,s,n),s.set(t,o),s},Gn=Symbol.for("@ipld/js-cid/CID");var ot={...$e,...Ge,...je,...qe,...Xe,...Je,...He,...Ke,...Qe,...We},Qs={...tt,...rt};function qt(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var jt=qt("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),st=qt("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=M(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),jn={utf8:jt,"utf-8":jt,hex:ot.base16,latin1:st,ascii:st,binary:st,...ot},Se=jn;function D(r,e="utf8"){let t=Se[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?q(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var he=class extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function Xt(r){if(r!=null){if(typeof r[Symbol.iterator]=="function")return r[Symbol.iterator]();if(typeof r[Symbol.asyncIterator]=="function")return r[Symbol.asyncIterator]();if(typeof r.next=="function")return r}throw new Error("argument is not an iterator or iterable")}function Jt(r,e,t){let n=t??{},o=Xt(r);async function*s(){let a,i=()=>{a?.()};for(e.addEventListener("abort",i);;){let h;try{if(e.aborted){let{abortMessage:c,abortCode:f}=n;throw new he(c,f)}let p=new Promise((c,f)=>{a=()=>{let{abortMessage:d,abortCode:U}=n;f(new he(d,U))}});h=await Promise.race([p,o.next()]),a=null}catch(p){e.removeEventListener("abort",i);let c=p.type==="aborted"&&e.aborted;if(c&&n.onAbort!=null&&n.onAbort(r),typeof o.return=="function")try{let f=o.return();f instanceof Promise&&f.catch(d=>{n.onReturnError!=null&&n.onReturnError(d)})}catch(f){n.onReturnError!=null&&n.onReturnError(f)}if(c&&n.returnOnAbort===!0)return;throw p}if(h.done===!0)break;yield h.value}e.removeEventListener("abort",i)}return s()}function qn(r){return r[Symbol.asyncIterator]!=null}function Xn(r){if(qn(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var Ht=Xn;function Ue(r){return r instanceof Uint8Array?{get(e){return r[e]},set(e,t){r[e]=t}}:{get(e){return r.get(e)},set(e,t){r.set(e,t)}}}var Kt=4294967296,R=class{constructor(e=0,t=0){this.hi=e,this.lo=t}toBigInt(e){if(e===!0)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(e){return Number(this.toBigInt(e))}zzDecode(){let e=-(this.lo&1),t=((this.lo>>>1|this.hi<<31)^e)>>>0,n=(this.hi>>>1^e)>>>0;return new R(n,t)}zzEncode(){let e=this.hi>>31,t=((this.hi<<1|this.lo>>>31)^e)>>>0,n=(this.lo<<1^e)>>>0;return new R(t,n)}toBytes(e,t=0){let n=Ue(e);for(;this.hi>0;)n.set(t++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(t++,this.lo&127|128),this.lo=this.lo>>>7;n.set(t++,this.lo)}static fromBigInt(e){if(e===0n)return new R;let t=e<0;t&&(e=-e);let n=Number(e>>32n)|0,o=Number(e-(BigInt(n)<<32n))|0;return t&&(n=~n>>>0,o=~o>>>0,++o>Kt&&(o=0,++n>Kt&&(n=0))),new R(n,o)}static fromNumber(e){if(e===0)return new R;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new R(o,n)}static fromBytes(e,t=0){let n=Ue(e),o=new R,s=0;if(e.length-t>4){for(;s<4;++s)if(o.lo=(o.lo|(n.get(t)&127)<<s*7)>>>0,n.get(t++)<128)return o;if(o.lo=(o.lo|(n.get(t)&127)<<28)>>>0,o.hi=(o.hi|(n.get(t)&127)>>4)>>>0,n.get(t++)<128)return o;s=0}else for(;s<4;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(o.lo=(o.lo|(n.get(t)&127)<<s*7)>>>0,n.get(t++)<128)return o}if(e.length-t>4){for(;s<5;++s)if(o.hi=(o.hi|(n.get(t)&127)<<s*7+3)>>>0,n.get(t++)<128)return o}else if(t<e.byteLength)for(;s<5;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(o.hi=(o.hi|(n.get(t)&127)<<s*7+3)>>>0,n.get(t++)<128)return o}throw RangeError("invalid varint encoding")}};var Jn=Math.pow(2,7),Hn=Math.pow(2,14),Kn=Math.pow(2,21),Qn=Math.pow(2,28),Wn=Math.pow(2,35),Yn=Math.pow(2,42),Zn=Math.pow(2,49),eo=Math.pow(2,56),to=Math.pow(2,63),J={encodingLength(r){return r<Jn?1:r<Hn?2:r<Kn?3:r<Qn?4:r<Wn?5:r<Yn?6:r<Zn?7:r<eo?8:r<to?9:10},encode(r,e,t=0){if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return e==null&&(e=M(J.encodingLength(r))),R.fromNumber(r).toBytes(e,t),e},decode(r,e=0){return R.fromBytes(r,e).toNumber(!0)}};function Fe(r){return r[Symbol.asyncIterator]!=null}var Ne=r=>{let e=J.encodingLength(r),t=M(e);return J.encode(r,t),Ne.bytes=e,t};Ne.bytes=0;function Oe(r,e){e=e??{};let t=e.lengthEncoder??Ne;function*n(o){let s=t(o.byteLength);s instanceof Uint8Array?yield s:yield*s,o instanceof Uint8Array?yield o:yield*o}return Fe(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}Oe.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??Ne;return new L(t(r.byteLength),r)};var ae=ft(Yt(),1);var no=8,oo=1024*1024*4,H;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(H||(H={}));var it=r=>{let e=J.decode(r);return it.bytes=J.encodingLength(e),e};it.bytes=0;function de(r,e){let t=new L,n=H.LENGTH,o=-1,s=e?.lengthDecoder??it,a=e?.maxLengthLength??no,i=e?.maxDataLength??oo;function*h(){for(;t.byteLength>0;){if(n===H.LENGTH)try{if(o=s(t),o<0)throw(0,ae.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>i)throw(0,ae.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let p=s.bytes;t.consume(p),e?.onLength!=null&&e.onLength(o),n=H.DATA}catch(p){if(p instanceof RangeError){if(t.byteLength>a)throw(0,ae.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw p}if(n===H.DATA){if(t.byteLength<o)break;let p=t.sublist(0,o);t.consume(o),e?.onData!=null&&e.onData(p),yield p,n=H.LENGTH}}}return Fe(r)?async function*(){for await(let p of r)t.append(p),yield*h();if(t.byteLength>0)throw(0,ae.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let p of r)t.append(p),yield*h();if(t.byteLength>0)throw(0,ae.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}de.fromReader=(r,e)=>{let t=1,n=async function*(){for(;;)try{let{done:s,value:a}=await r.next(t);if(s===!0)return;a!=null&&(yield a)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{t=1}}();return de(n,{...e??{},onLength:s=>{t=s}})};function Zt(r,...e){if(r==null)throw new Error("Empty pipeline");if(at(r)){let n=r;r=()=>n.source}else if(tr(r)||er(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&at(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)at(t[n])&&(t[n]=ao(t[n]));return io(...t)}var io=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},er=r=>r?.[Symbol.asyncIterator]!=null,tr=r=>r?.[Symbol.iterator]!=null,at=r=>r==null?!1:r.sink!=null&&r.source!=null,ao=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=_({objectMode:!0});t.then(()=>{n.end()},a=>{n.end(a)});let o,s=r.source;if(er(s))o=async function*(){yield*s,n.end()};else if(tr(s))o=function*(){yield*s,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return ve(n,o())}return r.source};function rr(r,e="utf8"){let t=Se[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var fo=ee("libp2p:mss"),nr=D(`
`);function K(r){let e=new L(r,nr);return Oe.single(e)}function Q(r,e,t={}){let n=K(e);t.writeBytes===!0?r.push(n.subarray()):r.push(n)}function or(r,e,t={}){let n=new L;for(let o of e)n.append(K(o));t.writeBytes===!0?r.push(n.subarray()):r.push(n)}async function uo(r,e){let t=1,n={[Symbol.asyncIterator]:()=>n,next:async()=>r.next(t)},o=n;e?.signal!=null&&(o=Jt(n,e.signal));let s=i=>{t=i},a=await Zt(o,i=>de(i,{onLength:s,maxDataLength:1024}),async i=>Ht(i));if(a==null||a.length===0)throw new V("no buffer returned","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(a.get(a.byteLength-1)!==nr[0])throw fo.error("Invalid mss message - missing newline - %s",a.subarray()),new V("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return a.sublist(0,-1)}async function G(r,e){let t=await uo(r,e);return rr(t.subarray())}var pe=ee("libp2p:mss:select");async function ir(r,e,t={}){e=Array.isArray(e)?[...e]:[e];let{reader:n,writer:o,rest:s,stream:a}=Ee(r),i=e.shift();if(i==null)throw new Error("At least one protocol must be specified");pe.trace('select: write ["%s", "%s"]',I,i);let h=D(I),p=D(i);or(o,[h,p],t);let c=await G(n,t);if(pe.trace('select: read "%s"',c),c===I&&(c=await G(n,t),pe.trace('select: read "%s"',c)),c===i)return s(),{stream:a,protocol:i};for(let f of e){pe.trace('select: write "%s"',f),Q(o,D(f),t);let d=await G(n,t);if(pe.trace('select: read "%s" for "%s"',d,f),d===f)return s(),{stream:a,protocol:f}}throw s(),new V("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}function ar(r,e){let t=_(),n=!1;return{stream:{sink:async o=>{await r.sink(async function*(){let s=!0;for await(let a of ve(o,t))if(s){s=!1,n=!0,t.end();let i=D(I),h=D(e),p=new L(K(i),K(h));a.length>0&&p.append(a),yield*p}else yield a}())},source:async function*(){n||t.push(new Uint8Array);let o=Ce(r.source),s=await G(o);if(s===I&&(s=await G(o)),s!==e)throw new V("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL");for await(let a of o)yield*a}()},protocol:e}}var be=ee("libp2p:mss:handle");async function cr(r,e,t){e=Array.isArray(e)?e:[e];let{writer:n,reader:o,rest:s,stream:a}=Ee(r);for(;;){let i=await G(o,t);if(be.trace('read "%s"',i),i===I){be.trace('respond with "%s" for "%s"',I,i),Q(n,D(I),t);continue}if(e.includes(i))return Q(n,D(i),t),be.trace('respond with "%s" for "%s"',i,i),s(),{stream:a,protocol:i};if(i==="ls"){Q(n,new L(...e.map(h=>K(D(h)))),t),be.trace('respond with "%s" for %s',e,i);continue}Q(n,D("na"),t),be('respond with "na" for "%s"',i)}}return pr(lo);})();
return Libp2PMultistreamSelect}));
import { Uint8ArrayList } from 'uint8arraylist';
import type { ByteArrayInit, ByteListInit, ProtocolStream } from './index.js';
import type { Duplex, Source } from 'it-stream-types';
import type { ByteArrayInit, ByteListInit, ProtocolStream } from './index.js';
/**

@@ -5,0 +5,0 @@ * Handle multistream protocol selections for the given list of protocols.

import { logger } from '@libp2p/logger';
import * as multistream from './multistream.js';
import { handshake } from 'it-handshake';
import { Uint8ArrayList } from 'uint8arraylist';
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
import { PROTOCOL_ID } from './constants.js';
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
import { Uint8ArrayList } from 'uint8arraylist';
import * as multistream from './multistream.js';
const log = logger('libp2p:mss:handle');

@@ -8,0 +8,0 @@ export async function handle(stream, protocols, options) {

import { PROTOCOL_ID } from './constants.js';
import type { AbortOptions } from '@libp2p/interface';
import type { Duplex, Source } from 'it-stream-types';
import type { AbortOptions } from '@libp2p/interfaces';
export { PROTOCOL_ID };

@@ -5,0 +5,0 @@ export interface ProtocolStream<TSource, TSink = TSource, RSink = Promise<void>> {

import { Uint8ArrayList } from 'uint8arraylist';
import type { MultistreamSelectInit } from '.';
import type { AbortOptions } from '@libp2p/interface';
import type { Pushable } from 'it-pushable';
import type { AbortOptions } from '@libp2p/interfaces';
import type { Reader } from 'it-reader';
import type { MultistreamSelectInit } from '.';
export declare function encode(buffer: Uint8Array | Uint8ArrayList): Uint8ArrayList;

@@ -7,0 +7,0 @@ /**

@@ -1,11 +0,11 @@

import { Uint8ArrayList } from 'uint8arraylist';
import { CodeError } from '@libp2p/interface/errors';
import { logger } from '@libp2p/logger';
import { abortableSource } from 'abortable-iterator';
import first from 'it-first';
import * as lp from 'it-length-prefixed';
import { pipe } from 'it-pipe';
import { CodeError } from '@libp2p/interfaces/errors';
import { Uint8ArrayList } from 'uint8arraylist';
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
import first from 'it-first';
import { abortableSource } from 'abortable-iterator';
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
import { MAX_PROTOCOL_LENGTH } from './constants.js';
import { logger } from '@libp2p/logger';
const log = logger('libp2p:mss');

@@ -48,3 +48,3 @@ const NewLine = uint8ArrayFromString('\n');

[Symbol.asyncIterator]: () => varByteSource,
next: async () => await reader.next(byteLength)
next: async () => reader.next(byteLength)
};

@@ -61,3 +61,3 @@ let input = varByteSource;

};
const buf = await pipe(input, (source) => lp.decode(source, { onLength, maxDataLength: MAX_PROTOCOL_LENGTH }), async (source) => await first(source));
const buf = await pipe(input, (source) => lp.decode(source, { onLength, maxDataLength: MAX_PROTOCOL_LENGTH }), async (source) => first(source));
if (buf == null || buf.length === 0) {

@@ -64,0 +64,0 @@ throw new CodeError('no buffer returned', 'ERR_INVALID_MULTISTREAM_SELECT_MESSAGE');

@@ -1,4 +0,4 @@

import type { Duplex, Source } from 'it-stream-types';
import { Uint8ArrayList } from 'uint8arraylist';
import type { ByteArrayInit, ByteListInit, ProtocolStream } from './index.js';
import type { Duplex, Source } from 'it-stream-types';
/**

@@ -5,0 +5,0 @@ * Negotiate a protocol to use from a list of protocols.

@@ -0,11 +1,11 @@

import { CodeError } from '@libp2p/interface/errors';
import { logger } from '@libp2p/logger';
import { CodeError } from '@libp2p/interfaces/errors';
import * as multistream from './multistream.js';
import { handshake } from 'it-handshake';
import merge from 'it-merge';
import { pushable } from 'it-pushable';
import { reader } from 'it-reader';
import { Uint8ArrayList } from 'uint8arraylist';
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
import * as multistream from './multistream.js';
import { PROTOCOL_ID } from './index.js';
import { Uint8ArrayList } from 'uint8arraylist';
import { pushable } from 'it-pushable';
import merge from 'it-merge';
import { reader } from 'it-reader';
const log = logger('libp2p:mss:select');

@@ -12,0 +12,0 @@ export async function select(stream, protocols, options = {}) {

{
"name": "@libp2p/multistream-select",
"version": "3.1.8",
"version": "3.1.9-05abd49f",
"description": "JavaScript implementation of multistream-select",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/libp2p/js-libp2p-multistream-select#readme",
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/multistream-select#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/libp2p/js-libp2p-multistream-select.git"
"url": "git+https://github.com/libp2p/js-libp2p.git"
},
"bugs": {
"url": "https://github.com/libp2p/js-libp2p-multistream-select/issues"
"url": "https://github.com/libp2p/js-libp2p/issues"
},

@@ -21,6 +21,2 @@ "keywords": [

],
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"type": "module",

@@ -46,87 +42,2 @@ "types": "./dist/src/index.d.ts",

},
"release": {
"branches": [
"master"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"breaking": true,
"release": "major"
},
{
"revert": true,
"release": "patch"
},
{
"type": "feat",
"release": "minor"
},
{
"type": "fix",
"release": "patch"
},
{
"type": "docs",
"release": "patch"
},
{
"type": "test",
"release": "patch"
},
{
"type": "deps",
"release": "patch"
},
{
"scope": "no-release",
"release": false
}
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"section": "Trivial Changes"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "deps",
"section": "Dependencies"
},
{
"type": "test",
"section": "Tests"
}
]
}
}
],
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/github",
"@semantic-release/git"
]
},
"scripts": {

@@ -143,31 +54,32 @@ "clean": "aegir clean",

"test:node": "aegir test -t node --cov",
"test:electron-main": "aegir test -t electron-main",
"release": "aegir release",
"docs": "aegir docs"
"test:electron-main": "aegir test -t electron-main"
},
"dependencies": {
"@libp2p/interfaces": "^3.2.0",
"@libp2p/logger": "^2.0.0",
"abortable-iterator": "^5.0.0",
"@libp2p/interface": "0.0.1-05abd49f",
"@libp2p/logger": "2.1.1-05abd49f",
"abortable-iterator": "^5.0.1",
"it-first": "^3.0.1",
"it-handshake": "^4.1.3",
"it-length-prefixed": "^9.0.0",
"it-length-prefixed": "^9.0.1",
"it-merge": "^3.0.0",
"it-pipe": "^3.0.0",
"it-pushable": "^3.1.0",
"it-pipe": "^3.0.1",
"it-pushable": "^3.1.3",
"it-reader": "^6.0.1",
"it-stream-types": "^2.0.1",
"uint8arraylist": "^2.3.1",
"uint8arrays": "^4.0.2"
"uint8arraylist": "^2.4.3",
"uint8arrays": "^4.0.4"
},
"devDependencies": {
"@types/varint": "^6.0.0",
"aegir": "^38.1.8",
"aegir": "^39.0.10",
"iso-random-stream": "^2.0.2",
"it-all": "^3.0.1",
"it-map": "^3.0.2",
"it-map": "^3.0.3",
"it-pair": "^2.0.6",
"p-timeout": "^6.0.0",
"varint": "^6.0.0"
},
"typedoc": {
"entryPoint": "./src/index.ts"
}
}

@@ -5,4 +5,4 @@ # @libp2p/multistream-select <!-- omit in toc -->

[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-multistream-select.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-multistream-select)
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-multistream-select/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p-multistream-select/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amaster)

@@ -58,3 +58,3 @@ > JavaScript implementation of multistream-select

- <https://libp2p.github.io/js-libp2p-multistream-select>
- <https://libp2p.github.io/js-libp2p/modules/_libp2p_multistream_select.html>

@@ -61,0 +61,0 @@ ## License

import { logger } from '@libp2p/logger'
import * as multistream from './multistream.js'
import { handshake } from 'it-handshake'
import { Uint8ArrayList } from 'uint8arraylist'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { PROTOCOL_ID } from './constants.js'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { Uint8ArrayList } from 'uint8arraylist'
import * as multistream from './multistream.js'
import type { ByteArrayInit, ByteListInit, MultistreamSelectInit, ProtocolStream } from './index.js'
import type { Duplex, Source } from 'it-stream-types'
import type { ByteArrayInit, ByteListInit, MultistreamSelectInit, ProtocolStream } from './index.js'

@@ -10,0 +10,0 @@ const log = logger('libp2p:mss:handle')

import { PROTOCOL_ID } from './constants.js'
import type { AbortOptions } from '@libp2p/interface'
import type { Duplex, Source } from 'it-stream-types'
import type { AbortOptions } from '@libp2p/interfaces'

@@ -5,0 +5,0 @@ export { PROTOCOL_ID }

import { Uint8ArrayList } from 'uint8arraylist'
import { CodeError } from '@libp2p/interface/errors'
import { logger } from '@libp2p/logger'
import { abortableSource } from 'abortable-iterator'
import first from 'it-first'
import * as lp from 'it-length-prefixed'
import { pipe } from 'it-pipe'
import { CodeError } from '@libp2p/interfaces/errors'
import { Uint8ArrayList } from 'uint8arraylist'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import first from 'it-first'
import { abortableSource } from 'abortable-iterator'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
import { MAX_PROTOCOL_LENGTH } from './constants.js'
import type { MultistreamSelectInit } from '.'
import type { AbortOptions } from '@libp2p/interface'
import type { Pushable } from 'it-pushable'
import type { AbortOptions } from '@libp2p/interfaces'
import type { Reader } from 'it-reader'
import type { Source } from 'it-stream-types'
import type { Reader } from 'it-reader'
import type { MultistreamSelectInit } from '.'
import { MAX_PROTOCOL_LENGTH } from './constants.js'
import { logger } from '@libp2p/logger'

@@ -62,3 +62,3 @@ const log = logger('libp2p:mss')

[Symbol.asyncIterator]: () => varByteSource,
next: async () => await reader.next(byteLength)
next: async () => reader.next(byteLength)
}

@@ -82,3 +82,3 @@

(source) => lp.decode(source, { onLength, maxDataLength: MAX_PROTOCOL_LENGTH }),
async (source) => await first(source)
async (source) => first(source)
)

@@ -85,0 +85,0 @@

@@ -0,13 +1,13 @@

import { CodeError } from '@libp2p/interface/errors'
import { logger } from '@libp2p/logger'
import { CodeError } from '@libp2p/interfaces/errors'
import * as multistream from './multistream.js'
import { handshake } from 'it-handshake'
import merge from 'it-merge'
import { pushable } from 'it-pushable'
import { reader } from 'it-reader'
import { Uint8ArrayList } from 'uint8arraylist'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import * as multistream from './multistream.js'
import { PROTOCOL_ID } from './index.js'
import type { ByteArrayInit, ByteListInit, MultistreamSelectInit, ProtocolStream } from './index.js'
import type { Duplex, Source } from 'it-stream-types'
import { Uint8ArrayList } from 'uint8arraylist'
import { pushable } from 'it-pushable'
import merge from 'it-merge'
import { reader } from 'it-reader'
import type { ByteArrayInit, ByteListInit, MultistreamSelectInit, ProtocolStream } from './index.js'

@@ -14,0 +14,0 @@ const log = logger('libp2p:mss:select')

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc