@helia/car 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,3 +1,3 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaCar = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaCar=(()=>{var Xn=Object.create;var Ge=Object.defineProperty;var Yn=Object.getOwnPropertyDescriptor;var Zn=Object.getOwnPropertyNames;var eo=Object.getPrototypeOf,to=Object.prototype.hasOwnProperty;var ro=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),no=(r,e)=>{for(var t in e)Ge(r,t,{get:e[t],enumerable:!0})},Jt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Zn(e))!to.call(r,o)&&o!==t&&Ge(r,o,{get:()=>e[o],enumerable:!(n=Yn(e,o))||n.enumerable});return r};var oo=(r,e,t)=>(t=r!=null?Xn(eo(r)):{},Jt(e||!r||!r.__esModule?Ge(t,"default",{value:r,enumerable:!0}):t,r)),io=r=>Jt(Ge({},"__esModule",{value:!0}),r);var er=ro((is,gt)=>{"use strict";var ho=Object.prototype.hasOwnProperty,D="~";function Ae(){}Object.create&&(Ae.prototype=Object.create(null),new Ae().__proto__||(D=!1));function lo(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Zt(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new lo(t,n||r,o),s=D?D+e:e;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function Je(r,e){--r._eventsCount===0?r._events=new Ae:delete r._events[e]}function $(){this._events=new Ae,this._eventsCount=0}$.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)ho.call(t,n)&&e.push(D?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};$.prototype.listeners=function(e){var t=D?D+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};$.prototype.listenerCount=function(e){var t=D?D+e:e,n=this._events[t];return n?n.fn?1:n.length:0};$.prototype.emit=function(e,t,n,o,i,s){var c=D?D+e:e;if(!this._events[c])return!1;var u=this._events[c],w=arguments.length,p,y;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),w){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,o),!0;case 5:return u.fn.call(u.context,t,n,o,i),!0;case 6:return u.fn.call(u.context,t,n,o,i,s),!0}for(y=1,p=new Array(w-1);y<w;y++)p[y-1]=arguments[y];u.fn.apply(u.context,p)}else{var q=u.length,X;for(y=0;y<q;y++)switch(u[y].once&&this.removeListener(e,u[y].fn,void 0,!0),w){case 1:u[y].fn.call(u[y].context);break;case 2:u[y].fn.call(u[y].context,t);break;case 3:u[y].fn.call(u[y].context,t,n);break;case 4:u[y].fn.call(u[y].context,t,n,o);break;default:if(!p)for(X=1,p=new Array(w-1);X<w;X++)p[X-1]=arguments[X];u[y].fn.apply(u[y].context,p)}}return!0};$.prototype.on=function(e,t,n){return Zt(this,e,t,n,!1)};$.prototype.once=function(e,t,n){return Zt(this,e,t,n,!0)};$.prototype.removeListener=function(e,t,n,o){var i=D?D+e:e;if(!this._events[i])return this;if(!t)return Je(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&Je(this,i);else{for(var c=0,u=[],w=s.length;c<w;c++)(s[c].fn!==t||o&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[i]=u.length===1?u[0]:u:Je(this,i)}return this};$.prototype.removeAllListeners=function(e){var t;return e?(t=D?D+e:e,this._events[t]&&Je(this,t)):(this._events=new Ae,this._eventsCount=0),this};$.prototype.off=$.prototype.removeListener;$.prototype.addListener=$.prototype.on;$.prefixed=D;$.EventEmitter=$;typeof gt<"u"&&(gt.exports=$)});var Yi={};no(Yi,{car:()=>Xi});function so(r){return r[Symbol.asyncIterator]!=null}function ao(r){if(so(r))return(async()=>{for await(let e of r);})();for(let e of r);}var Kt=ao;function co(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var Xt=co;function uo(r){return r[Symbol.asyncIterator]!=null}function fo(r,e){if(uo(r))return async function*(){for await(let c of r)yield e(c)}();let t=Xt(r),{value:n,done:o}=t.next();if(o===!0)return function*(){}();let i=e(n);if(typeof i.then=="function")return async function*(){yield await i;for await(let c of t)yield e(c)}();let s=e;return function*(){yield i;for(let c of t)yield s(c)}()}var Yt=fo;function yt(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var ur=oo(er(),1);var _e=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},bt=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},tr=r=>globalThis.DOMException===void 0?new bt(r):new DOMException(r),rr=r=>{let e=r.reason===void 0?tr("This operation was aborted."):r.reason;return e instanceof Error?e:tr(e)};function xt(r,e,t,n){let o,i=new Promise((s,c)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){s(r);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:u}=n;u.aborted&&c(rr(u)),u.addEventListener("abort",()=>{c(rr(u))})}o=n.customTimers.setTimeout.call(void 0,()=>{if(typeof t=="function"){try{s(t())}catch(p){c(p)}return}let u=typeof t=="string"?t:`Promise timed out after ${e} milliseconds`,w=t instanceof Error?t:new _e(u);typeof r.cancel=="function"&&r.cancel(),c(w)},e),(async()=>{try{s(await r)}catch(u){c(u)}finally{n.customTimers.clearTimeout.call(void 0,o)}})()});return i.clear=()=>{clearTimeout(o),o=void 0},i}function vt(r,e,t){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;t(r[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var ae=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},Z,Se=class{constructor(){Z.set(this,[])}enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&ae(this,Z,"f")[this.size-1].priority>=t.priority){ae(this,Z,"f").push(n);return}let o=vt(ae(this,Z,"f"),n,(i,s)=>s.priority-i.priority);ae(this,Z,"f").splice(o,0,n)}dequeue(){let e=ae(this,Z,"f").shift();return e?.run}filter(e){return ae(this,Z,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return ae(this,Z,"f").length}};Z=new WeakMap;var k=function(r,e,t,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t},l=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},S,Be,Ie,oe,tt,Ne,Ke,H,Ue,L,Xe,O,Ce,ne,Ye,nr,or,ar,ir,sr,Ze,Et,kt,rt,cr,et,nt=class extends Error{},Pe=class extends ur.default{constructor(e){var t,n,o,i;if(super(),S.add(this),Be.set(this,void 0),Ie.set(this,void 0),oe.set(this,0),tt.set(this,void 0),Ne.set(this,void 0),Ke.set(this,0),H.set(this,void 0),Ue.set(this,void 0),L.set(this,void 0),Xe.set(this,void 0),O.set(this,0),Ce.set(this,void 0),ne.set(this,void 0),Ye.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Se,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(t=e.intervalCap)===null||t===void 0?void 0:t.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(i=(o=e.interval)===null||o===void 0?void 0:o.toString())!==null&&i!==void 0?i:""}\` (${typeof e.interval})`);k(this,Be,e.carryoverConcurrencyCount,"f"),k(this,Ie,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),k(this,tt,e.intervalCap,"f"),k(this,Ne,e.interval,"f"),k(this,L,new e.queueClass,"f"),k(this,Xe,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,k(this,Ye,e.throwOnTimeout===!0,"f"),k(this,ne,e.autoStart===!1,"f")}get concurrency(){return l(this,Ce,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);k(this,Ce,e,"f"),l(this,S,"m",rt).call(this)}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:l(this,Ye,"f"),...t},new Promise((n,o)=>{l(this,L,"f").enqueue(async()=>{var i,s,c;k(this,O,(s=l(this,O,"f"),s++,s),"f"),k(this,oe,(c=l(this,oe,"f"),c++,c),"f");try{if(!((i=t.signal)===null||i===void 0)&&i.aborted)throw new nt("The task was aborted.");let u=e({signal:t.signal});t.timeout&&(u=xt(Promise.resolve(u),t.timeout)),t.signal&&(u=Promise.race([u,l(this,S,"m",cr).call(this,t.signal)]));let w=await u;n(w),this.emit("completed",w)}catch(u){if(u instanceof _e&&!t.throwOnTimeout){n();return}o(u),this.emit("error",u)}finally{l(this,S,"m",ar).call(this)}},t),this.emit("add"),l(this,S,"m",Ze).call(this)})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return l(this,ne,"f")?(k(this,ne,!1,"f"),l(this,S,"m",rt).call(this),this):this}pause(){k(this,ne,!0,"f")}clear(){k(this,L,new(l(this,Xe,"f")),"f")}async onEmpty(){l(this,L,"f").size!==0&&await l(this,S,"m",et).call(this,"empty")}async onSizeLessThan(e){l(this,L,"f").size<e||await l(this,S,"m",et).call(this,"next",()=>l(this,L,"f").size<e)}async onIdle(){l(this,O,"f")===0&&l(this,L,"f").size===0||await l(this,S,"m",et).call(this,"idle")}get size(){return l(this,L,"f").size}sizeBy(e){return l(this,L,"f").filter(e).length}get pending(){return l(this,O,"f")}get isPaused(){return l(this,ne,"f")}};Be=new WeakMap,Ie=new WeakMap,oe=new WeakMap,tt=new WeakMap,Ne=new WeakMap,Ke=new WeakMap,H=new WeakMap,Ue=new WeakMap,L=new WeakMap,Xe=new WeakMap,O=new WeakMap,Ce=new WeakMap,ne=new WeakMap,Ye=new WeakMap,S=new WeakSet,nr=function(){return l(this,Ie,"f")||l(this,oe,"f")<l(this,tt,"f")},or=function(){return l(this,O,"f")<l(this,Ce,"f")},ar=function(){var e;k(this,O,(e=l(this,O,"f"),e--,e),"f"),l(this,S,"m",Ze).call(this),this.emit("next")},ir=function(){l(this,S,"m",kt).call(this),l(this,S,"m",Et).call(this),k(this,Ue,void 0,"f")},sr=function(){let e=Date.now();if(l(this,H,"f")===void 0){let t=l(this,Ke,"f")-e;if(t<0)k(this,oe,l(this,Be,"f")?l(this,O,"f"):0,"f");else return l(this,Ue,"f")===void 0&&k(this,Ue,setTimeout(()=>{l(this,S,"m",ir).call(this)},t),"f"),!0}return!1},Ze=function(){if(l(this,L,"f").size===0)return l(this,H,"f")&&clearInterval(l(this,H,"f")),k(this,H,void 0,"f"),this.emit("empty"),l(this,O,"f")===0&&this.emit("idle"),!1;if(!l(this,ne,"f")){let e=!l(this,S,"a",sr);if(l(this,S,"a",nr)&&l(this,S,"a",or)){let t=l(this,L,"f").dequeue();return t?(this.emit("active"),t(),e&&l(this,S,"m",Et).call(this),!0):!1}}return!1},Et=function(){l(this,Ie,"f")||l(this,H,"f")!==void 0||(k(this,H,setInterval(()=>{l(this,S,"m",kt).call(this)},l(this,Ne,"f")),"f"),k(this,Ke,Date.now()+l(this,Ne,"f"),"f"))},kt=function(){l(this,oe,"f")===0&&l(this,O,"f")===0&&l(this,H,"f")&&(clearInterval(l(this,H,"f")),k(this,H,void 0,"f")),k(this,oe,l(this,Be,"f")?l(this,O,"f"):0,"f"),l(this,S,"m",rt).call(this)},rt=function(){for(;l(this,S,"m",Ze).call(this););},cr=async function(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(new nt("The task was aborted."))},{once:!0})})},et=async function(e,t){return new Promise(n=>{let o=()=>{t&&!t()||(this.off(e,o),n())};this.on(e,o)})};var po=dr,fr=128,mo=127,wo=~mo,yo=Math.pow(2,31);function dr(r,e,t){e=e||[],t=t||0;for(var n=t;r>=yo;)e[t++]=r&255|fr,r/=128;for(;r&wo;)e[t++]=r&255|fr,r>>>=7;return e[t]=r|0,dr.bytes=t-n+1,e}var go=Tt,bo=128,hr=127;function Tt(r,n){var t=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw Tt.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&hr)<<o:(s&hr)*Math.pow(2,o),o+=7}while(s>=bo);return Tt.bytes=i-n,t}var xo=Math.pow(2,7),vo=Math.pow(2,14),Eo=Math.pow(2,21),ko=Math.pow(2,28),To=Math.pow(2,35),Ao=Math.pow(2,42),_o=Math.pow(2,49),So=Math.pow(2,56),Uo=Math.pow(2,63),Bo=function(r){return r<xo?1:r<vo?2:r<Eo?3:r<ko?4:r<To?5:r<Ao?6:r<_o?7:r<So?8:r<Uo?9:10},Io={encode:po,decode:go,encodingLength:Bo},No=Io,$e=No;var ze=(r,e=0)=>[$e.decode(r,e),$e.decode.bytes],fe=(r,e,t=0)=>($e.encode(r,e,t),e),he=r=>$e.encodingLength(r);var ms=new Uint8Array(0);var pr=(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},de=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 mr=(r,e)=>{let t=e.byteLength,n=he(r),o=n+he(t),i=new Uint8Array(o+t);return fe(r,i,0),fe(t,i,n),i.set(e,o),new le(r,t,e,i)},wr=r=>{let e=de(r),[t,n]=ze(e),[o,i]=ze(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new le(t,o,s,e)},yr=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&pr(r.bytes,t.bytes)}},le=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function Po(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var c=r.length,u=r.charAt(0),w=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function y(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var b=0,z=0,v=0,T=m.length;v!==T&&m[v]===0;)v++,b++;for(var A=(T-v)*p+1>>>0,x=new Uint8Array(A);v!==T;){for(var _=m[v],C=0,E=A-1;(_!==0||C<z)&&E!==-1;E--,C++)_+=256*x[E]>>>0,x[E]=_%c>>>0,_=_/c>>>0;if(_!==0)throw new Error("Non-zero carry");z=C,v++}for(var I=A-z;I!==A&&x[I]===0;)I++;for(var Y=u.repeat(b);I<A;++I)Y+=r.charAt(x[I]);return Y}function q(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var b=0;if(m[b]!==" "){for(var z=0,v=0;m[b]===u;)z++,b++;for(var T=(m.length-b)*w+1>>>0,A=new Uint8Array(T);m[b];){var x=t[m.charCodeAt(b)];if(x===255)return;for(var _=0,C=T-1;(x!==0||_<v)&&C!==-1;C--,_++)x+=c*A[C]>>>0,A[C]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");v=_,b++}if(m[b]!==" "){for(var E=T-v;E!==T&&A[E]===0;)E++;for(var I=new Uint8Array(z+(T-E)),Y=z;E!==T;)I[Y++]=A[E++];return I}}}function X(m){var b=q(m);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:q,decode:X}}var $o=Po,zo=$o,gr=zo;var At=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")}},_t=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 br(this,e)}},St=class{constructor(e){this.decoders=e}or(e){return br(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`)}},br=(r,e)=>new St({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Ut=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new At(e,t,n),this.decoder=new _t(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},xr=({name:r,prefix:e,encode:t,decode:n})=>new Ut(r,e,t,n),Bt=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=gr(t,e);return xr({prefix:r,name:e,encode:n,decode:i=>de(o(i))})},Do=(r,e,t,n)=>{let o={};for(let p=0;p<e.length;++p)o[e[p]]=p;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*t/8|0),c=0,u=0,w=0;for(let p=0;p<i;++p){let y=o[r[p]];if(y===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<t|y,c+=t,c>=8&&(c-=8,s[w++]=255&u>>c)}if(c>=t||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s},Mo=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],s+=8;s>t;)s-=t,i+=e[o&c>>s];if(s&&(i+=e[o&c<<t-s]),n)for(;i.length*t&7;)i+="=";return i},K=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>xr({prefix:e,name:r,encode(o){return Mo(o,n,t)},decode(o){return Do(o,n,t,r)}});var ee=Bt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ks=Bt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var De=K({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_s=K({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ss=K({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Us=K({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bs=K({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Is=K({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ns=K({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Cs=K({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ps=K({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vr=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Oo(t,It(r),e||ee.encoder);default:return Vo(t,It(r),e||De.encoder)}};var Er=new WeakMap,It=r=>{let e=Er.get(r);if(e==null){let t=new Map;return Er.set(r,t),t}return e},U=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!==Me)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Fo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return U.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=mr(e,t);return U.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 U.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&yr(e.multihash,n.multihash)}toString(e){return vr(this,e)}toJSON(){return{"/":vr(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 U)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new U(n,o,i,s||kr(n,o,i.bytes))}else if(t[jo]===!0){let{version:n,multihash:o,code:i}=t,s=wr(o);return U.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Me)throw new Error(`Version 0 CID must use dag-pb (code: ${Me}) block encoding`);return new U(e,t,n,n.bytes)}case 1:{let o=kr(e,t,n.bytes);return new U(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return U.create(0,Me,e)}static createV1(e,t){return U.create(1,e,t)}static decode(e){let[t,n]=U.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=U.inspectBytes(e),n=t.size-t.multihashSize,o=de(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new le(t.multihashCode,t.digestSize,i,o);return[t.version===0?U.createV0(s):U.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[y,q]=ze(e.subarray(t));return t+=q,y},o=n(),i=Me;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,c=n(),u=n(),w=t+u,p=w-s;return{version:o,codec:i,multihashCode:c,digestSize:u,multihashSize:p,size:w}}static parse(e,t){let[n,o]=Lo(e,t),i=U.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return It(i).set(n,e),i}},Lo=(r,e)=>{switch(r[0]){case"Q":{let t=e||ee;return[ee.prefix,t.decode(`${ee.prefix}${r}`)]}case ee.prefix:{let t=e||ee;return[ee.prefix,t.decode(r)]}case De.prefix:{let t=e||De;return[De.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)]}}},Oo=(r,e,t)=>{let{prefix:n}=t;if(n!==ee.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o},Vo=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o},Me=112,Fo=18,kr=(r,e,t)=>{let n=he(r),o=n+he(e),i=new Uint8Array(o+t.byteLength);return fe(r,i,0),fe(e,i,n),i.set(t,o),i},jo=Symbol.for("@ipld/js-cid/CID");var Ro=new TextDecoder;function Nt(r,e){let t=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(e>=r.length)throw new Error("protobuf: unexpected end of data");let o=r[e++];if(t+=n<28?(o&127)<<n:(o&127)*2**n,o<128)break}return[t,e]}function ot(r,e){let t;[t,e]=Nt(r,e);let n=e+t;if(t<0||n<0)throw new Error("protobuf: invalid length");if(n>r.length)throw new Error("protobuf: unexpected end of data");return[r.subarray(e,n),n]}function Tr(r,e){let t;return[t,e]=Nt(r,e),[t&7,t>>3,e]}function Qo(r){let e={},t=r.length,n=0;for(;n<t;){let o,i;if([o,i,n]=Tr(r,n),i===1){if(e.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Hash`);if(e.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[e.Hash,n]=ot(r,n)}else if(i===2){if(e.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Name`);if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let s;[s,n]=ot(r,n),e.Name=Ro.decode(s)}else if(i===3){if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(o!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Tsize`);[e.Tsize,n]=Nt(r,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${i}`)}if(n>t)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function Ar(r){let e=r.length,t=0,n,o=!1,i;for(;t<e;){let c,u;if([c,u,t]=Tr(r,t),c!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${c}`);if(u===1){if(i)throw new Error("protobuf: (PBNode) duplicate Data section");[i,t]=ot(r,t),n&&(o=!0)}else if(u===2){if(o)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let w;[w,t]=ot(r,t),n.push(Qo(w))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${u}`)}if(t>e)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return i&&(s.Data=i),s.Links=n||[],s}var Fs=new TextEncoder,js=2**32,Rs=2**31;var qs=new TextEncoder;var _r=112;function Sr(r){let e=Ar(r),t={};return e.Data&&(t.Data=e.Data),e.Links&&(t.Links=e.Links.map(n=>{let o={};try{o.Hash=U.decode(n.Hash)}catch{}if(!o.Hash)throw new Error("Invalid Hash field found in link, expected CID");return n.Name!==void 0&&(o.Name=n.Name),n.Tsize!==void 0&&(o.Tsize=n.Tsize),o})),t}var qo=["string","number","bigint","symbol"],Ho=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Ur(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(qo.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(Go(r))return"Buffer";let t=Jo(r);return t||"Object"}function Go(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Jo(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Ho.includes(e))return e}var a=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};a.uint=new a(0,"uint",!0);a.negint=new a(1,"negint",!0);a.bytes=new a(2,"bytes",!0);a.string=new a(3,"string",!0);a.array=new a(4,"array",!1);a.map=new a(5,"map",!1);a.tag=new a(6,"tag",!1);a.float=new a(7,"float",!0);a.false=new a(7,"false",!0);a.true=new a(7,"true",!0);a.null=new a(7,"null",!0);a.undefined=new a(7,"undefined",!0);a.break=new a(7,"break",!0);var f=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var pe=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Ko=new TextDecoder,Xo=new TextEncoder;function it(r){return pe&&globalThis.Buffer.isBuffer(r)}function st(r){return r instanceof Uint8Array?it(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Cr=pe?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Ir(r,e,t):(r,e,t)=>t-e>64?Ko.decode(r.subarray(e,t)):Ir(r,e,t),at=pe?r=>r.length>64?globalThis.Buffer.from(r):Br(r):r=>r.length>64?Xo.encode(r):Br(r);var me=pe?(r,e,t)=>it(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Pr=pe?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),st(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},$r=pe?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function zr(r,e){if(it(r)&&it(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function Br(r,e=1/0){let t,n=r.length,o=null,i=[];for(let s=0;s<n;++s){if(t=r.charCodeAt(s),t>55295&&t<57344){if(!o){if(t>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=t;continue}if(t<56320){(e-=3)>-1&&i.push(239,191,189),o=t;continue}t=(o-55296<<10|t-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,t<128){if((e-=1)<0)break;i.push(t)}else if(t<2048){if((e-=2)<0)break;i.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;i.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;i.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return i}function Ir(r,e,t){let n=[];for(;e<t;){let o=r[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=t){let c,u,w,p;switch(s){case 1:o<128&&(i=o);break;case 2:c=r[e+1],(c&192)===128&&(p=(o&31)<<6|c&63,p>127&&(i=p));break;case 3:c=r[e+1],u=r[e+2],(c&192)===128&&(u&192)===128&&(p=(o&15)<<12|(c&63)<<6|u&63,p>2047&&(p<55296||p>57343)&&(i=p));break;case 4:c=r[e+1],u=r[e+2],w=r[e+3],(c&192)===128&&(u&192)===128&&(w&192)===128&&(p=(o&15)<<18|(c&63)<<12|(u&63)<<6|w&63,p>65535&&p<1114112&&(i=p))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return Ct(n)}var Nr=4096;function Ct(r){let e=r.length;if(e<=Nr)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Nr));return t}var Yo=256,ct=class{constructor(e=Yo){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=t.length-(this.maxCursor-this.cursor)-1;t.set(e,o)}else{if(t){let o=t.length-(this.maxCursor-this.cursor)-1;o<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=$r(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=me(n,0,this.cursor)}else t=Pr(this.chunks,this.cursor);return e&&this.reset(),t}};var d="CBOR decode error:",we="CBOR encode error:",Le=[];Le[23]=1;Le[24]=2;Le[25]=3;Le[26]=5;Le[27]=9;function te(r,e,t){if(r.length-e<t)throw new Error(`${d} not enough data for type`)}var N=[24,256,65536,4294967296,BigInt("18446744073709551616")];function V(r,e,t){te(r,e,1);let n=r[e];if(t.strict===!0&&n<N[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function F(r,e,t){te(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<N[1])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function j(r,e,t){te(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<N[2])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function R(r,e,t){te(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],o=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&i<N[3])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(t.allowBigInt===!0)return i;throw new Error(`${d} integers outside of the safe integer range are not supported`)}function Dr(r,e,t,n){return new f(a.uint,V(r,e+1,n),2)}function Mr(r,e,t,n){return new f(a.uint,F(r,e+1,n),3)}function Lr(r,e,t,n){return new f(a.uint,j(r,e+1,n),5)}function Or(r,e,t,n){return new f(a.uint,R(r,e+1,n),9)}function Q(r,e){return P(r,0,e.value)}function P(r,e,t){if(t<N[0]){let n=Number(t);r.push([e|n])}else if(t<N[1]){let n=Number(t);r.push([e|24,n])}else if(t<N[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<N[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<N[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${d} encountered BigInt larger than allowable range`)}}Q.encodedSize=function(e){return P.encodedSize(e.value)};P.encodedSize=function(e){return e<N[0]?1:e<N[1]?2:e<N[2]?3:e<N[3]?5:9};Q.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function Vr(r,e,t,n){return new f(a.negint,-1-V(r,e+1,n),2)}function Fr(r,e,t,n){return new f(a.negint,-1-F(r,e+1,n),3)}function jr(r,e,t,n){return new f(a.negint,-1-j(r,e+1,n),5)}var Pt=BigInt(-1),Rr=BigInt(1);function Qr(r,e,t,n){let o=R(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new f(a.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${d} integers outside of the safe integer range are not supported`);return new f(a.negint,Pt-BigInt(o),9)}function ut(r,e){let t=e.value,n=typeof t=="bigint"?t*Pt-Rr:t*-1-1;P(r,e.type.majorEncoded,n)}ut.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*Pt-Rr:t*-1-1;return n<N[0]?1:n<N[1]?2:n<N[2]?3:n<N[3]?5:9};ut.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Oe(r,e,t,n){te(r,e,t+n);let o=me(r,e+t,e+t+n);return new f(a.bytes,o,t+n)}function Wr(r,e,t,n){return Oe(r,e,1,t)}function qr(r,e,t,n){return Oe(r,e,2,V(r,e+1,n))}function Hr(r,e,t,n){return Oe(r,e,3,F(r,e+1,n))}function Gr(r,e,t,n){return Oe(r,e,5,j(r,e+1,n))}function Jr(r,e,t,n){let o=R(r,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return Oe(r,e,9,o)}function ft(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===a.string?at(r.value):r.value),r.encodedBytes}function ye(r,e){let t=ft(e);P(r,e.type.majorEncoded,t.length),r.push(t)}ye.encodedSize=function(e){let t=ft(e);return P.encodedSize(t.length)+t.length};ye.compareTokens=function(e,t){return ei(ft(e),ft(t))};function ei(r,e){return r.length<e.length?-1:r.length>e.length?1:zr(r,e)}function Ve(r,e,t,n,o){let i=t+n;te(r,e,i);let s=new f(a.string,Cr(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=me(r,e+t,e+i)),s}function Kr(r,e,t,n){return Ve(r,e,1,t,n)}function Xr(r,e,t,n){return Ve(r,e,2,V(r,e+1,n),n)}function Yr(r,e,t,n){return Ve(r,e,3,F(r,e+1,n),n)}function Zr(r,e,t,n){return Ve(r,e,5,j(r,e+1,n),n)}function en(r,e,t,n){let o=R(r,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return Ve(r,e,9,o,n)}var tn=ye;function ge(r,e,t,n){return new f(a.array,n,t)}function rn(r,e,t,n){return ge(r,e,1,t)}function nn(r,e,t,n){return ge(r,e,2,V(r,e+1,n))}function on(r,e,t,n){return ge(r,e,3,F(r,e+1,n))}function sn(r,e,t,n){return ge(r,e,5,j(r,e+1,n))}function an(r,e,t,n){let o=R(r,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer array lengths not supported`);return ge(r,e,9,o)}function cn(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return ge(r,e,1,1/0)}function ht(r,e){P(r,a.array.majorEncoded,e.value)}ht.compareTokens=Q.compareTokens;ht.encodedSize=function(e){return P.encodedSize(e.value)};function be(r,e,t,n){return new f(a.map,n,t)}function un(r,e,t,n){return be(r,e,1,t)}function fn(r,e,t,n){return be(r,e,2,V(r,e+1,n))}function hn(r,e,t,n){return be(r,e,3,F(r,e+1,n))}function dn(r,e,t,n){return be(r,e,5,j(r,e+1,n))}function ln(r,e,t,n){let o=R(r,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer map lengths not supported`);return be(r,e,9,o)}function pn(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return be(r,e,1,1/0)}function dt(r,e){P(r,a.map.majorEncoded,e.value)}dt.compareTokens=Q.compareTokens;dt.encodedSize=function(e){return P.encodedSize(e.value)};function mn(r,e,t,n){return new f(a.tag,t,1)}function wn(r,e,t,n){return new f(a.tag,V(r,e+1,n),2)}function yn(r,e,t,n){return new f(a.tag,F(r,e+1,n),3)}function gn(r,e,t,n){return new f(a.tag,j(r,e+1,n),5)}function bn(r,e,t,n){return new f(a.tag,R(r,e+1,n),9)}function lt(r,e){P(r,a.tag.majorEncoded,e.value)}lt.compareTokens=Q.compareTokens;lt.encodedSize=function(e){return P.encodedSize(e.value)};var si=20,ai=21,ci=22,ui=23;function xn(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new f(a.null,null,1):new f(a.undefined,void 0,1)}function vn(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new f(a.break,void 0,1)}function $t(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${d} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${d} Infinity values are not supported`)}return new f(a.float,r,e)}function En(r,e,t,n){return $t(zt(r,e+1),3,n)}function kn(r,e,t,n){return $t(Dt(r,e+1),5,n)}function Tn(r,e,t,n){return $t(Un(r,e+1),9,n)}function pt(r,e,t){let n=e.value;if(n===!1)r.push([a.float.majorEncoded|si]);else if(n===!0)r.push([a.float.majorEncoded|ai]);else if(n===null)r.push([a.float.majorEncoded|ci]);else if(n===void 0)r.push([a.float.majorEncoded|ui]);else{let o,i=!1;(!t||t.float64!==!0)&&(_n(n),o=zt(G,1),n===o||Number.isNaN(n)?(G[0]=249,r.push(G.slice(0,3)),i=!0):(Sn(n),o=Dt(G,1),n===o&&(G[0]=250,r.push(G.slice(0,5)),i=!0))),i||(fi(n),o=Un(G,1),G[0]=251,r.push(G.slice(0,9)))}}pt.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){_n(n);let o=zt(G,1);if(n===o||Number.isNaN(n))return 3;if(Sn(n),o=Dt(G,1),n===o)return 5}return 9};var An=new ArrayBuffer(9),W=new DataView(An,1),G=new Uint8Array(An,0);function _n(r){if(r===1/0)W.setUint16(0,31744,!1);else if(r===-1/0)W.setUint16(0,64512,!1);else if(Number.isNaN(r))W.setUint16(0,32256,!1);else{W.setFloat32(0,r);let e=W.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)W.setUint16(0,31744,!1);else if(t===0)W.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?W.setUint16(0,0):o<-14?W.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):W.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function zt(r,e){if(r.length-e<2)throw new Error(`${d} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function Sn(r){W.setFloat32(0,r,!1)}function Dt(r,e){if(r.length-e<4)throw new Error(`${d} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function fi(r){W.setFloat64(0,r,!1)}function Un(r,e){if(r.length-e<8)throw new Error(`${d} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}pt.compareTokens=Q.compareTokens;function g(r,e,t){throw new Error(`${d} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function mt(r){return()=>{throw new Error(`${d} ${r}`)}}var h=[];for(let r=0;r<=23;r++)h[r]=g;h[24]=Dr;h[25]=Mr;h[26]=Lr;h[27]=Or;h[28]=g;h[29]=g;h[30]=g;h[31]=g;for(let r=32;r<=55;r++)h[r]=g;h[56]=Vr;h[57]=Fr;h[58]=jr;h[59]=Qr;h[60]=g;h[61]=g;h[62]=g;h[63]=g;for(let r=64;r<=87;r++)h[r]=Wr;h[88]=qr;h[89]=Hr;h[90]=Gr;h[91]=Jr;h[92]=g;h[93]=g;h[94]=g;h[95]=mt("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)h[r]=Kr;h[120]=Xr;h[121]=Yr;h[122]=Zr;h[123]=en;h[124]=g;h[125]=g;h[126]=g;h[127]=mt("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)h[r]=rn;h[152]=nn;h[153]=on;h[154]=sn;h[155]=an;h[156]=g;h[157]=g;h[158]=g;h[159]=cn;for(let r=160;r<=183;r++)h[r]=un;h[184]=fn;h[185]=hn;h[186]=dn;h[187]=ln;h[188]=g;h[189]=g;h[190]=g;h[191]=pn;for(let r=192;r<=215;r++)h[r]=mn;h[216]=wn;h[217]=yn;h[218]=gn;h[219]=bn;h[220]=g;h[221]=g;h[222]=g;h[223]=g;for(let r=224;r<=243;r++)h[r]=mt("simple values are not supported");h[244]=g;h[245]=g;h[246]=g;h[247]=xn;h[248]=mt("simple values are not supported");h[249]=En;h[250]=kn;h[251]=Tn;h[252]=g;h[253]=g;h[254]=g;h[255]=vn;var J=[];for(let r=0;r<24;r++)J[r]=new f(a.uint,r,1);for(let r=-1;r>=-24;r--)J[31-r]=new f(a.negint,r,1);J[64]=new f(a.bytes,new Uint8Array(0),1);J[96]=new f(a.string,"",1);J[128]=new f(a.array,0,1);J[160]=new f(a.map,0,1);J[244]=new f(a.false,!1,1);J[245]=new f(a.true,!0,1);J[246]=new f(a.null,null,1);function di(){let r=[];return r[a.uint.major]=Q,r[a.negint.major]=ut,r[a.bytes.major]=ye,r[a.string.major]=tn,r[a.array.major]=ht,r[a.map.major]=dt,r[a.tag.major]=lt,r[a.float.major]=pt,r}var Ga=di(),Ja=new ct,xe=class{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${we} object contains circular references`);return new xe(t,e)}},ie={null:new f(a.null,null),undefined:new f(a.undefined,void 0),true:new f(a.true,!0),false:new f(a.false,!1),emptyArray:new f(a.array,0),emptyMap:new f(a.map,0)},se={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new f(a.float,r):r>=0?new f(a.uint,r):new f(a.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new f(a.uint,r):new f(a.negint,r)},Uint8Array(r,e,t,n){return new f(a.bytes,r)},string(r,e,t,n){return new f(a.string,r)},boolean(r,e,t,n){return r?ie.true:ie.false},null(r,e,t,n){return ie.null},undefined(r,e,t,n){return ie.undefined},ArrayBuffer(r,e,t,n){return new f(a.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new f(a.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[ie.emptyArray,new f(a.break)]:ie.emptyArray;n=xe.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=Mt(s,t,n);return t.addBreakTokens?[new f(a.array,r.length),o,new f(a.break)]:[new f(a.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[ie.emptyMap,new f(a.break)]:ie.emptyMap;n=xe.createCheck(n,r);let c=[],u=0;for(let w of i)c[u++]=[Mt(w,t,n),Mt(o?r.get(w):r[w],t,n)];return li(c,t),t.addBreakTokens?[new f(a.map,s),c,new f(a.break)]:[new f(a.map,s),c]}};se.Map=se.Object;se.Buffer=se.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))se[`${r}Array`]=se.DataView;function Mt(r,e={},t){let n=Ur(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||se[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=se[n];if(!i)throw new Error(`${we} unsupported type: ${n}`);return i(r,n,e,t)}function li(r,e){e.mapSorter&&r.sort(e.mapSorter)}var pi={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Lt=class{constructor(e,t={}){this.pos=0,this.data=e,this.options=t}done(){return this.pos>=this.data.length}next(){let e=this.data[this.pos],t=J[e];if(t===void 0){let n=h[e];if(!n)throw new Error(`${d} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this.pos,o,this.options)}return this.pos+=t.encodedLength,t}},Fe=Symbol.for("DONE"),wt=Symbol.for("BREAK");function mi(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=je(e,t);if(i===wt){if(r.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(i===Fe)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function wi(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let c=je(e,t);if(c===wt){if(r.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(c===Fe)throw new Error(`${d} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${d} non-string keys not supported (got ${typeof c})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${d} found repeat map key "${c}"`);let u=je(e,t);if(u===Fe)throw new Error(`${d} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(c,u):o[c]=u}return n?i:o}function je(r,e){if(r.done())return Fe;let t=r.next();if(t.type===a.break)return wt;if(t.type.terminal)return t.value;if(t.type===a.array)return mi(t,r,e);if(t.type===a.map)return wi(t,r,e);if(t.type===a.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=je(r,e);return e.tags[t.value](n)}throw new Error(`${d} tag not supported (${t.value})`)}throw new Error("unsupported")}function Re(r,e){if(!(r instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);e=Object.assign({},pi,e);let t=e.tokenizer||new Lt(r,e),n=je(t,e);if(n===Fe)throw new Error(`${d} did not find any content to decode`);if(n===wt)throw new Error(`${d} got unexpected break`);if(!t.done())throw new Error(`${d} too many terminals, data makes no sense`);return n}var Bn=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let t=this.inRecursive[this.inRecursive.length-1];t&&(t.type===a.array&&(t.elements++,t.elements!==1&&e.push([44])),t.type===a.map&&(t.elements++,t.elements!==1&&(t.elements%2===1?e.push([44]):e.push([58]))))}[a.uint.major](e,t){this.prefix(e);let n=String(t.value),o=[];for(let i=0;i<n.length;i++)o[i]=n.charCodeAt(i);e.push(o)}[a.negint.major](e,t){this[a.uint.major](e,t)}[a.bytes.major](e,t){throw new Error(`${we} unsupported type: Uint8Array`)}[a.string.major](e,t){this.prefix(e);let n=at(JSON.stringify(t.value));e.push(n.length>32?st(n):n)}[a.array.major](e,t){this.prefix(e),this.inRecursive.push({type:a.array,elements:0}),e.push([91])}[a.map.major](e,t){this.prefix(e),this.inRecursive.push({type:a.map,elements:0}),e.push([123])}[a.tag.major](e,t){}[a.float.major](e,t){if(t.type.name==="break"){let s=this.inRecursive.pop();if(s){if(s.type===a.array)e.push([93]);else if(s.type===a.map)e.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(t.value===void 0)throw new Error(`${we} unsupported type: undefined`);if(this.prefix(e),t.type.name==="true"){e.push([116,114,117,101]);return}else if(t.type.name==="false"){e.push([102,97,108,115,101]);return}else if(t.type.name==="null"){e.push([110,117,108,108]);return}let n=String(t.value),o=[],i=!1;for(let s=0;s<n.length;s++)o[s]=n.charCodeAt(s),!i&&(o[s]===46||o[s]===101||o[s]===69)&&(i=!0);i||(o.push(46),o.push(48)),e.push(o)}};var ve=class{constructor(e,t={}){this.pos=0,this.data=e,this.options=t,this.modeStack=["value"],this.lastToken=""}done(){return this.pos>=this.data.length}ch(){return this.data[this.pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;e===32||e===9||e===13||e===10;)e=this.data[++this.pos]}expect(e){if(this.data.length-this.pos<e.length)throw new Error(`${d} unexpected end of input at position ${this.pos}`);for(let t=0;t<e.length;t++)if(this.data[this.pos++]!==e[t])throw new Error(`${d} unexpected token at position ${this.pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this.pos,t=!1,n=!1,o=c=>{for(;!this.done();){let u=this.ch();if(c.includes(u))this.pos++;else break}};if(this.ch()===45&&(t=!0,this.pos++),this.ch()===48)if(this.pos++,this.ch()===46)this.pos++,n=!0;else return new f(a.uint,0,this.pos-e);if(o([48,49,50,51,52,53,54,55,56,57]),t&&this.pos===e+1)throw new Error(`${d} unexpected token at position ${this.pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${d} unexpected token at position ${this.pos}`);n=!0,this.pos++,o([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(n=!0,this.pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this.pos++,o([48,49,50,51,52,53,54,55,56,57]));let i=String.fromCharCode.apply(null,this.data.subarray(e,this.pos)),s=parseFloat(i);return n?new f(a.float,s,this.pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(s)?new f(s>=0?a.uint:a.negint,s,this.pos-e):new f(s>=0?a.uint:a.negint,BigInt(i),this.pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${d} unexpected character at position ${this.pos}; this shouldn't happen`);this.pos++;for(let i=this.pos,s=0;i<this.data.length&&s<65536;i++,s++){let c=this.data[i];if(c===92||c<32||c>=128)break;if(c===34){let u=String.fromCharCode.apply(null,this.data.subarray(this.pos,i));return this.pos=i+1,new f(a.string,u,s)}}let e=this.pos,t=[],n=()=>{if(this.pos+4>=this.data.length)throw new Error(`${d} unexpected end of unicode escape sequence at position ${this.pos}`);let i=0;for(let s=0;s<4;s++){let c=this.ch();if(c>=48&&c<=57)c-=48;else if(c>=97&&c<=102)c=c-97+10;else if(c>=65&&c<=70)c=c-65+10;else throw new Error(`${d} unexpected unicode escape character at position ${this.pos}`);i=i*16+c,this.pos++}return i},o=()=>{let i=this.ch(),s=null,c=i>239?4:i>223?3:i>191?2:1;if(this.pos+c>this.data.length)throw new Error(`${d} unexpected unicode sequence at position ${this.pos}`);let u,w,p,y;switch(c){case 1:i<128&&(s=i);break;case 2:u=this.data[this.pos+1],(u&192)===128&&(y=(i&31)<<6|u&63,y>127&&(s=y));break;case 3:u=this.data[this.pos+1],w=this.data[this.pos+2],(u&192)===128&&(w&192)===128&&(y=(i&15)<<12|(u&63)<<6|w&63,y>2047&&(y<55296||y>57343)&&(s=y));break;case 4:u=this.data[this.pos+1],w=this.data[this.pos+2],p=this.data[this.pos+3],(u&192)===128&&(w&192)===128&&(p&192)===128&&(y=(i&15)<<18|(u&63)<<12|(w&63)<<6|p&63,y>65535&&y<1114112&&(s=y))}s===null?(s=65533,c=1):s>65535&&(s-=65536,t.push(s>>>10&1023|55296),s=56320|s&1023),t.push(s),this.pos+=c};for(;!this.done();){let i=this.ch(),s;switch(i){case 92:if(this.pos++,this.done())throw new Error(`${d} unexpected string termination at position ${this.pos}`);switch(s=this.ch(),this.pos++,s){case 34:case 39:case 92:case 47:t.push(s);break;case 98:t.push(8);break;case 116:t.push(9);break;case 110:t.push(10);break;case 102:t.push(12);break;case 114:t.push(13);break;case 117:t.push(n());break;default:throw new Error(`${d} unexpected string escape character at position ${this.pos}`)}break;case 34:return this.pos++,new f(a.string,Ct(t),this.pos-e);default:if(i<32)throw new Error(`${d} invalid control character at position ${this.pos}`);i<128?(t.push(i),this.pos++):o()}}throw new Error(`${d} unexpected end of string at position ${this.pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this.pos++,new f(a.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new f(a.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new f(a.null,null,4);case 102:return this.expect([102,97,108,115,101]),new f(a.false,!1,5);case 116:return this.expect([116,114,117,101]),new f(a.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${d} unexpected character at position ${this.pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this.pos++,this.skipWhitespace(),new f(a.break,void 0,1);if(this.ch()!==44)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this.pos++,this.skipWhitespace(),new f(a.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this.pos++,this.skipWhitespace(),new f(a.break,void 0,1);if(this.ch()!==44)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this.pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this.pos++,this.skipWhitespace(),new f(a.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("obj-value"),e}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${d} unexpected parse state at position ${this.pos}; this shouldn't happen`)}}};function Ot(r,e){return e=Object.assign({tokenizer:new ve(r,e)},e),Re(r,e)}function bi(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var c=r.length,u=r.charAt(0),w=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function y(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var b=0,z=0,v=0,T=m.length;v!==T&&m[v]===0;)v++,b++;for(var A=(T-v)*p+1>>>0,x=new Uint8Array(A);v!==T;){for(var _=m[v],C=0,E=A-1;(_!==0||C<z)&&E!==-1;E--,C++)_+=256*x[E]>>>0,x[E]=_%c>>>0,_=_/c>>>0;if(_!==0)throw new Error("Non-zero carry");z=C,v++}for(var I=A-z;I!==A&&x[I]===0;)I++;for(var Y=u.repeat(b);I<A;++I)Y+=r.charAt(x[I]);return Y}function q(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var b=0;if(m[b]!==" "){for(var z=0,v=0;m[b]===u;)z++,b++;for(var T=(m.length-b)*w+1>>>0,A=new Uint8Array(T);m[b];){var x=t[m.charCodeAt(b)];if(x===255)return;for(var _=0,C=T-1;(x!==0||_<v)&&C!==-1;C--,_++)x+=c*A[C]>>>0,A[C]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");v=_,b++}if(m[b]!==" "){for(var E=T-v;E!==T&&A[E]===0;)E++;for(var I=new Uint8Array(z+(T-E)),Y=z;E!==T;)I[Y++]=A[E++];return I}}}function X(m){var b=q(m);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:q,decode:X}}var xi=bi,vi=xi,In=vi;var xc=new Uint8Array(0);var Nn=(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},ue=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 Vt=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")}},Ft=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 Cn(this,e)}},jt=class{constructor(e){this.decoders=e}or(e){return Cn(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`)}},Cn=(r,e)=>new jt({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Rt=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Vt(e,t,n),this.decoder=new Ft(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Pn=({name:r,prefix:e,encode:t,decode:n})=>new Rt(r,e,t,n),Qt=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=In(t,e);return Pn({prefix:r,name:e,encode:n,decode:i=>ue(o(i))})},Ei=(r,e,t,n)=>{let o={};for(let p=0;p<e.length;++p)o[e[p]]=p;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*t/8|0),c=0,u=0,w=0;for(let p=0;p<i;++p){let y=o[r[p]];if(y===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<t|y,c+=t,c>=8&&(c-=8,s[w++]=255&u>>c)}if(c>=t||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s},ki=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],s+=8;s>t;)s-=t,i+=e[o&c>>s];if(s&&(i+=e[o&c<<t-s]),n)for(;i.length*t&7;)i+="=";return i},M=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Pn({prefix:e,name:r,encode(o){return ki(o,n,t)},decode(o){return Ei(o,n,t,r)}});var $n=M({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),_c=M({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Sc=M({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Uc=M({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ti=Mn,zn=128,Ai=127,_i=~Ai,Si=Math.pow(2,31);function Mn(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Si;)e[t++]=r&255|zn,r/=128;for(;r&_i;)e[t++]=r&255|zn,r>>>=7;return e[t]=r|0,Mn.bytes=t-n+1,e}var Ui=Wt,Bi=128,Dn=127;function Wt(r,n){var t=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw Wt.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&Dn)<<o:(s&Dn)*Math.pow(2,o),o+=7}while(s>=Bi);return Wt.bytes=i-n,t}var Ii=Math.pow(2,7),Ni=Math.pow(2,14),Ci=Math.pow(2,21),Pi=Math.pow(2,28),$i=Math.pow(2,35),zi=Math.pow(2,42),Di=Math.pow(2,49),Mi=Math.pow(2,56),Li=Math.pow(2,63),Oi=function(r){return r<Ii?1:r<Ni?2:r<Ci?3:r<Pi?4:r<$i?5:r<zi?6:r<Di?7:r<Mi?8:r<Li?9:10},Vi={encode:Ti,decode:Ui,encodingLength:Oi},Fi=Vi,Qe=Fi;var We=(r,e=0)=>[Qe.decode(r,e),Qe.decode.bytes],Ee=(r,e,t=0)=>(Qe.encode(r,e,t),e),ke=r=>Qe.encodingLength(r);var On=(r,e)=>{let t=e.byteLength,n=ke(r),o=n+ke(t),i=new Uint8Array(o+t);return Ee(r,i,0),Ee(t,i,n),i.set(e,o),new Te(r,t,e,i)},Vn=r=>{let e=ue(r),[t,n]=We(e),[o,i]=We(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Te(t,o,s,e)},Fn=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Nn(r.bytes,t.bytes)}},Te=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var re=Qt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$c=Qt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var qe=M({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Mc=M({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Lc=M({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Oc=M({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Vc=M({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Fc=M({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),jc=M({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Rc=M({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Qc=M({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var jn=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Qi(t,qt(r),e||re.encoder);default:return Wi(t,qt(r),e||qe.encoder)}};var Rn=new WeakMap,qt=r=>{let e=Rn.get(r);if(e==null){let t=new Map;return Rn.set(r,t),t}return e},B=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!==He)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==qi)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return B.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=On(e,t);return B.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 B.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Fn(e.multihash,n.multihash)}toString(e){return jn(this,e)}toJSON(){return{"/":jn(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 B)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new B(n,o,i,s||Qn(n,o,i.bytes))}else if(t[Hi]===!0){let{version:n,multihash:o,code:i}=t,s=Vn(o);return B.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==He)throw new Error(`Version 0 CID must use dag-pb (code: ${He}) block encoding`);return new B(e,t,n,n.bytes)}case 1:{let o=Qn(e,t,n.bytes);return new B(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return B.create(0,He,e)}static createV1(e,t){return B.create(1,e,t)}static decode(e){let[t,n]=B.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=B.inspectBytes(e),n=t.size-t.multihashSize,o=ue(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new Te(t.multihashCode,t.digestSize,i,o);return[t.version===0?B.createV0(s):B.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[y,q]=We(e.subarray(t));return t+=q,y},o=n(),i=He;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,c=n(),u=n(),w=t+u,p=w-s;return{version:o,codec:i,multihashCode:c,digestSize:u,multihashSize:p,size:w}}static parse(e,t){let[n,o]=Ri(e,t),i=B.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return qt(i).set(n,e),i}},Ri=(r,e)=>{switch(r[0]){case"Q":{let t=e||re;return[re.prefix,t.decode(`${re.prefix}${r}`)]}case re.prefix:{let t=e||re;return[re.prefix,t.decode(r)]}case qe.prefix:{let t=e||qe;return[qe.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)]}}},Qi=(r,e,t)=>{let{prefix:n}=t;if(n!==re.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o},Wi=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o},He=112,qi=18,Qn=(r,e,t)=>{let n=ke(r),o=n+ke(e),i=new Uint8Array(o+t.byteLength);return Ee(r,i,0),Ee(e,i,n),i.set(t,o),i},Hi=Symbol.for("@ipld/js-cid/CID");var Wn=85;var qn={codec:_r,async*walk(r){yield*Sr(r).Links.map(t=>t.Hash)}},Hn={codec:Wn,async*walk(){}},Gn=42,Jn={codec:113,async*walk(r){let e=[],t=[];t[Gn]=n=>{if(n[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");let o=B.decode(n.subarray(1));return e.push(o),o},Re(r,{tags:t}),yield*e}},Ht=class extends ve{tokenBuffer;constructor(e,t){super(e,t),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let e=this._next();if(e.type===a.map){let t=this._next();if(t.type===a.string&&t.value==="/"){let n=this._next();if(n.type===a.string){if(this._next().type!==a.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new f(a.tag,42,0)}if(n.type===a.map){let o=this._next();if(o.type===a.string&&o.value==="bytes"){let i=this._next();if(i.type===a.string){for(let c=0;c<2;c++)if(this._next().type!==a.break)throw new Error("Invalid encoded Bytes form");let s=$n.decode(`m${i.value}`);return new f(a.bytes,s,i.value.length)}this.tokenBuffer.push(i)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(t)}return e}},Kn={codec:297,async*walk(r){let e=[],t=[];t[Gn]=n=>{let o=B.parse(n);return e.push(o),o},Ot(r,{tags:t,tokenizer:new Ht(r,{tags:t,allowIndefinite:!0,allowUndefined:!0,allowNaN:!0,allowInfinity:!0,allowBigInt:!0,strict:!1,rejectDuplicateMapKeys:!1})}),yield*e}};var Ji=[Hn,qn,Jn,Kn],Ki=1,Gt=class{components;dagWalkers;constructor(e,t){this.components=e,this.dagWalkers={},[...Ji,...t.dagWalkers??[]].forEach(n=>{this.dagWalkers[n.codec]=n})}async import(e,t){await Kt(this.components.blockstore.putMany(Yt(e.blocks(),({cid:n,bytes:o})=>({cid:n,block:o})),t))}async export(e,t,n){let o=yt(),i=Array.isArray(e)?e:[e],s=new Pe({concurrency:Ki});s.on("idle",()=>{o.resolve()}),s.on("error",c=>{o.resolve(c)});for(let c of i)s.add(async()=>{await this.#e(c,s,async(u,w)=>{await t.put({cid:u,bytes:w})},n)});try{await o.promise}finally{await t.close()}}async#e(e,t,n,o){let i=this.dagWalkers[e.code];if(i==null)throw new Error(`No dag walker found for cid codec ${e.code}`);let s=await this.components.blockstore.get(e,o);await n(e,s);for await(let c of i.walk(s))t.add(async()=>{await this.#e(c,t,n,o)})}};function Xi(r,e={}){return new Gt(r,e)}return io(Yi);})();
2
+ "use strict";var HeliaCar=(()=>{var Xn=Object.create;var He=Object.defineProperty;var Yn=Object.getOwnPropertyDescriptor;var Zn=Object.getOwnPropertyNames;var eo=Object.getPrototypeOf,to=Object.prototype.hasOwnProperty;var ro=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),no=(t,e)=>{for(var r in e)He(t,r,{get:e[r],enumerable:!0})},Jt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Zn(e))!to.call(t,o)&&o!==r&&He(t,o,{get:()=>e[o],enumerable:!(n=Yn(e,o))||n.enumerable});return t};var oo=(t,e,r)=>(r=t!=null?Xn(eo(t)):{},Jt(e||!t||!t.__esModule?He(r,"default",{value:t,enumerable:!0}):r,t)),io=t=>Jt(He({},"__esModule",{value:!0}),t);var er=ro((is,gt)=>{"use strict";var ho=Object.prototype.hasOwnProperty,$="~";function Ee(){}Object.create&&(Ee.prototype=Object.create(null),new Ee().__proto__||($=!1));function lo(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function Zt(t,e,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new lo(r,n||t,o),s=$?$+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],i]:t._events[s].push(i):(t._events[s]=i,t._eventsCount++),t}function Ge(t,e){--t._eventsCount===0?t._events=new Ee:delete t._events[e]}function N(){this._events=new Ee,this._eventsCount=0}N.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)ho.call(r,n)&&e.push($?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};N.prototype.listeners=function(e){var r=$?$+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};N.prototype.listenerCount=function(e){var r=$?$+e:e,n=this._events[r];return n?n.fn?1:n.length:0};N.prototype.emit=function(e,r,n,o,i,s){var c=$?$+e:e;if(!this._events[c])return!1;var u=this._events[c],w=arguments.length,p,y;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),w){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,r),!0;case 3:return u.fn.call(u.context,r,n),!0;case 4:return u.fn.call(u.context,r,n,o),!0;case 5:return u.fn.call(u.context,r,n,o,i),!0;case 6:return u.fn.call(u.context,r,n,o,i,s),!0}for(y=1,p=new Array(w-1);y<w;y++)p[y-1]=arguments[y];u.fn.apply(u.context,p)}else{var Q=u.length,J;for(y=0;y<Q;y++)switch(u[y].once&&this.removeListener(e,u[y].fn,void 0,!0),w){case 1:u[y].fn.call(u[y].context);break;case 2:u[y].fn.call(u[y].context,r);break;case 3:u[y].fn.call(u[y].context,r,n);break;case 4:u[y].fn.call(u[y].context,r,n,o);break;default:if(!p)for(J=1,p=new Array(w-1);J<w;J++)p[J-1]=arguments[J];u[y].fn.apply(u[y].context,p)}}return!0};N.prototype.on=function(e,r,n){return Zt(this,e,r,n,!1)};N.prototype.once=function(e,r,n){return Zt(this,e,r,n,!0)};N.prototype.removeListener=function(e,r,n,o){var i=$?$+e:e;if(!this._events[i])return this;if(!r)return Ge(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&Ge(this,i);else{for(var c=0,u=[],w=s.length;c<w;c++)(s[c].fn!==r||o&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[i]=u.length===1?u[0]:u:Ge(this,i)}return this};N.prototype.removeAllListeners=function(e){var r;return e?(r=$?$+e:e,this._events[r]&&Ge(this,r)):(this._events=new Ee,this._eventsCount=0),this};N.prototype.off=N.prototype.removeListener;N.prototype.addListener=N.prototype.on;N.prefixed=$;N.EventEmitter=N;typeof gt<"u"&&(gt.exports=N)});var Yi={};no(Yi,{car:()=>Xi});function so(t){return t[Symbol.asyncIterator]!=null}function ao(t){if(so(t))return(async()=>{for await(let e of t);})();for(let e of t);}var Kt=ao;function co(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[r](){return this}}}var Xt=co;function uo(t){return t[Symbol.asyncIterator]!=null}function fo(t,e){if(uo(t))return async function*(){for await(let c of t)yield e(c)}();let r=Xt(t),{value:n,done:o}=r.next();if(o===!0)return function*(){}();let i=e(n);if(typeof i.then=="function")return async function*(){yield await i;for await(let c of r)yield e(c)}();let s=e;return function*(){yield i;for(let c of r)yield s(c)}()}var Yt=fo;function yt(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var ur=oo(er(),1);var ke=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},bt=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},tr=t=>globalThis.DOMException===void 0?new bt(t):new DOMException(t),rr=t=>{let e=t.reason===void 0?tr("This operation was aborted."):t.reason;return e instanceof Error?e:tr(e)};function xt(t,e,r,n){let o,i=new Promise((s,c)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e===Number.POSITIVE_INFINITY){s(t);return}if(n={customTimers:{setTimeout,clearTimeout},...n},n.signal){let{signal:u}=n;u.aborted&&c(rr(u)),u.addEventListener("abort",()=>{c(rr(u))})}o=n.customTimers.setTimeout.call(void 0,()=>{if(typeof r=="function"){try{s(r())}catch(p){c(p)}return}let u=typeof r=="string"?r:`Promise timed out after ${e} milliseconds`,w=r instanceof Error?r:new ke(u);typeof t.cancel=="function"&&t.cancel(),c(w)},e),(async()=>{try{s(await t)}catch(u){c(u)}finally{n.customTimers.clearTimeout.call(void 0,o)}})()});return i.clear=()=>{clearTimeout(o),o=void 0},i}function vt(t,e,r){let n=0,o=t.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(t[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var ie=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},X,Te=class{constructor(){X.set(this,[])}enqueue(e,r){r={priority:0,...r};let n={priority:r.priority,run:e};if(this.size&&ie(this,X,"f")[this.size-1].priority>=r.priority){ie(this,X,"f").push(n);return}let o=vt(ie(this,X,"f"),n,(i,s)=>s.priority-i.priority);ie(this,X,"f").splice(o,0,n)}dequeue(){let e=ie(this,X,"f").shift();return e?.run}filter(e){return ie(this,X,"f").filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return ie(this,X,"f").length}};X=new WeakMap;var k=function(t,e,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r},l=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},S,_e,Se,re,et,Ie,Je,W,Ae,D,Ke,M,Ue,te,Xe,nr,or,ar,ir,sr,Ye,Et,kt,tt,cr,Ze,rt=class extends Error{},Ce=class extends ur.default{constructor(e){var r,n,o,i;if(super(),S.add(this),_e.set(this,void 0),Se.set(this,void 0),re.set(this,0),et.set(this,void 0),Ie.set(this,void 0),Je.set(this,0),W.set(this,void 0),Ae.set(this,void 0),D.set(this,void 0),Ke.set(this,void 0),M.set(this,0),Ue.set(this,void 0),te.set(this,void 0),Xe.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Te,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=e.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(i=(o=e.interval)===null||o===void 0?void 0:o.toString())!==null&&i!==void 0?i:""}\` (${typeof e.interval})`);k(this,_e,e.carryoverConcurrencyCount,"f"),k(this,Se,e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,"f"),k(this,et,e.intervalCap,"f"),k(this,Ie,e.interval,"f"),k(this,D,new e.queueClass,"f"),k(this,Ke,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,k(this,Xe,e.throwOnTimeout===!0,"f"),k(this,te,e.autoStart===!1,"f")}get concurrency(){return l(this,Ue,"f")}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);k(this,Ue,e,"f"),l(this,S,"m",tt).call(this)}async add(e,r={}){return r={timeout:this.timeout,throwOnTimeout:l(this,Xe,"f"),...r},new Promise((n,o)=>{l(this,D,"f").enqueue(async()=>{var i,s,c;k(this,M,(s=l(this,M,"f"),s++,s),"f"),k(this,re,(c=l(this,re,"f"),c++,c),"f");try{if(!((i=r.signal)===null||i===void 0)&&i.aborted)throw new rt("The task was aborted.");let u=e({signal:r.signal});r.timeout&&(u=xt(Promise.resolve(u),r.timeout)),r.signal&&(u=Promise.race([u,l(this,S,"m",cr).call(this,r.signal)]));let w=await u;n(w),this.emit("completed",w)}catch(u){if(u instanceof ke&&!r.throwOnTimeout){n();return}o(u),this.emit("error",u)}finally{l(this,S,"m",ar).call(this)}},r),this.emit("add"),l(this,S,"m",Ye).call(this)})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return l(this,te,"f")?(k(this,te,!1,"f"),l(this,S,"m",tt).call(this),this):this}pause(){k(this,te,!0,"f")}clear(){k(this,D,new(l(this,Ke,"f")),"f")}async onEmpty(){l(this,D,"f").size!==0&&await l(this,S,"m",Ze).call(this,"empty")}async onSizeLessThan(e){l(this,D,"f").size<e||await l(this,S,"m",Ze).call(this,"next",()=>l(this,D,"f").size<e)}async onIdle(){l(this,M,"f")===0&&l(this,D,"f").size===0||await l(this,S,"m",Ze).call(this,"idle")}get size(){return l(this,D,"f").size}sizeBy(e){return l(this,D,"f").filter(e).length}get pending(){return l(this,M,"f")}get isPaused(){return l(this,te,"f")}};_e=new WeakMap,Se=new WeakMap,re=new WeakMap,et=new WeakMap,Ie=new WeakMap,Je=new WeakMap,W=new WeakMap,Ae=new WeakMap,D=new WeakMap,Ke=new WeakMap,M=new WeakMap,Ue=new WeakMap,te=new WeakMap,Xe=new WeakMap,S=new WeakSet,nr=function(){return l(this,Se,"f")||l(this,re,"f")<l(this,et,"f")},or=function(){return l(this,M,"f")<l(this,Ue,"f")},ar=function(){var e;k(this,M,(e=l(this,M,"f"),e--,e),"f"),l(this,S,"m",Ye).call(this),this.emit("next")},ir=function(){l(this,S,"m",kt).call(this),l(this,S,"m",Et).call(this),k(this,Ae,void 0,"f")},sr=function(){let e=Date.now();if(l(this,W,"f")===void 0){let r=l(this,Je,"f")-e;if(r<0)k(this,re,l(this,_e,"f")?l(this,M,"f"):0,"f");else return l(this,Ae,"f")===void 0&&k(this,Ae,setTimeout(()=>{l(this,S,"m",ir).call(this)},r),"f"),!0}return!1},Ye=function(){if(l(this,D,"f").size===0)return l(this,W,"f")&&clearInterval(l(this,W,"f")),k(this,W,void 0,"f"),this.emit("empty"),l(this,M,"f")===0&&this.emit("idle"),!1;if(!l(this,te,"f")){let e=!l(this,S,"a",sr);if(l(this,S,"a",nr)&&l(this,S,"a",or)){let r=l(this,D,"f").dequeue();return r?(this.emit("active"),r(),e&&l(this,S,"m",Et).call(this),!0):!1}}return!1},Et=function(){l(this,Se,"f")||l(this,W,"f")!==void 0||(k(this,W,setInterval(()=>{l(this,S,"m",kt).call(this)},l(this,Ie,"f")),"f"),k(this,Je,Date.now()+l(this,Ie,"f"),"f"))},kt=function(){l(this,re,"f")===0&&l(this,M,"f")===0&&l(this,W,"f")&&(clearInterval(l(this,W,"f")),k(this,W,void 0,"f")),k(this,re,l(this,_e,"f")?l(this,M,"f"):0,"f"),l(this,S,"m",tt).call(this)},tt=function(){for(;l(this,S,"m",Ye).call(this););},cr=async function(e){return new Promise((r,n)=>{e.addEventListener("abort",()=>{n(new rt("The task was aborted."))},{once:!0})})},Ze=async function(e,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(e,o),n())};this.on(e,o)})};var po=dr,fr=128,mo=127,wo=~mo,yo=Math.pow(2,31);function dr(t,e,r){e=e||[],r=r||0;for(var n=r;t>=yo;)e[r++]=t&255|fr,t/=128;for(;t&wo;)e[r++]=t&255|fr,t>>>=7;return e[r]=t|0,dr.bytes=r-n+1,e}var go=Tt,bo=128,hr=127;function Tt(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw Tt.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&hr)<<o:(s&hr)*Math.pow(2,o),o+=7}while(s>=bo);return Tt.bytes=i-n,r}var xo=Math.pow(2,7),vo=Math.pow(2,14),Eo=Math.pow(2,21),ko=Math.pow(2,28),To=Math.pow(2,35),Ao=Math.pow(2,42),_o=Math.pow(2,49),So=Math.pow(2,56),Io=Math.pow(2,63),Uo=function(t){return t<xo?1:t<vo?2:t<Eo?3:t<ko?4:t<To?5:t<Ao?6:t<_o?7:t<So?8:t<Io?9:10},Co={encode:po,decode:go,encodingLength:Uo},Bo=Co,Be=Bo;var Ne=(t,e=0)=>[Be.decode(t,e),Be.decode.bytes],ce=(t,e,r=0)=>(Be.encode(t,e,r),e),ue=t=>Be.encodingLength(t);var ms=new Uint8Array(0);var pr=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},fe=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var mr=(t,e)=>{let r=e.byteLength,n=ue(t),o=n+ue(r),i=new Uint8Array(o+r);return ce(t,i,0),ce(r,i,n),i.set(e,o),new he(t,r,e,i)},wr=t=>{let e=fe(t),[r,n]=Ne(e),[o,i]=Ne(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new he(r,o,s,e)},yr=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&pr(t.bytes,r.bytes)}},he=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Po(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=t.length,u=t.charAt(0),w=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function y(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var b=0,P=0,v=0,T=m.length;v!==T&&m[v]===0;)v++,b++;for(var A=(T-v)*p+1>>>0,x=new Uint8Array(A);v!==T;){for(var _=m[v],C=0,E=A-1;(_!==0||C<P)&&E!==-1;E--,C++)_+=256*x[E]>>>0,x[E]=_%c>>>0,_=_/c>>>0;if(_!==0)throw new Error("Non-zero carry");P=C,v++}for(var I=A-P;I!==A&&x[I]===0;)I++;for(var K=u.repeat(b);I<A;++I)K+=t.charAt(x[I]);return K}function Q(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var b=0;if(m[b]!==" "){for(var P=0,v=0;m[b]===u;)P++,b++;for(var T=(m.length-b)*w+1>>>0,A=new Uint8Array(T);m[b];){var x=r[m.charCodeAt(b)];if(x===255)return;for(var _=0,C=T-1;(x!==0||_<v)&&C!==-1;C--,_++)x+=c*A[C]>>>0,A[C]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");v=_,b++}if(m[b]!==" "){for(var E=T-v;E!==T&&A[E]===0;)E++;for(var I=new Uint8Array(P+(T-E)),K=P;E!==T;)I[K++]=A[E++];return I}}}function J(m){var b=Q(m);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:Q,decode:J}}var $o=Po,zo=$o,gr=zo;var At=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},_t=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 br(this,e)}},St=class{constructor(e){this.decoders=e}or(e){return br(this,e)}decode(e){let r=e[0],n=this.decoders[r];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`)}},br=(t,e)=>new St({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),It=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new At(e,r,n),this.decoder=new _t(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},xr=({name:t,prefix:e,encode:r,decode:n})=>new It(t,e,r,n),Ut=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=gr(r,e);return xr({prefix:t,name:e,encode:n,decode:i=>fe(o(i))})},Do=(t,e,r,n)=>{let o={};for(let p=0;p<e.length;++p)o[e[p]]=p;let i=t.length;for(;t[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),c=0,u=0,w=0;for(let p=0;p<i;++p){let y=o[t[p]];if(y===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<r|y,c+=r,c>=8&&(c-=8,s[w++]=255&u>>c)}if(c>=r||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s},Mo=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let u=0;u<t.length;++u)for(c=c<<8|t[u],s+=8;s>r;)s-=r,i+=e[o&c>>s];if(s&&(i+=e[o&c<<r-s]),n)for(;i.length*r&7;)i+="=";return i},G=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>xr({prefix:e,name:t,encode(o){return Mo(o,n,r)},decode(o){return Do(o,n,r,t)}});var Y=Ut({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ks=Ut({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Pe=G({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_s=G({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ss=G({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Is=G({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Us=G({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Cs=G({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Bs=G({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ns=G({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ps=G({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vr=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Oo(r,Ct(t),e||Y.encoder);default:return Vo(r,Ct(t),e||Pe.encoder)}};var Er=new WeakMap,Ct=t=>{let e=Er.get(t);if(e==null){let r=new Map;return Er.set(t,r),r}return e},ze=class t{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==$e)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Fo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=mr(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&yr(e.multihash,n.multihash)}toString(e){return vr(this,e)}toJSON(){return{"/":vr(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 r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s||kr(n,o,i.bytes))}else if(r[jo]===!0){let{version:n,multihash:o,code:i}=r,s=wr(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==$e)throw new Error(`Version 0 CID must use dag-pb (code: ${$e}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=kr(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,$e,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=fe(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new he(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[y,Q]=Ne(e.subarray(r));return r+=Q,y},o=n(),i=$e;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),u=n(),w=r+u,p=w-s;return{version:o,codec:i,multihashCode:c,digestSize:u,multihashSize:p,size:w}}static parse(e,r){let[n,o]=Lo(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ct(i).set(n,e),i}},Lo=(t,e)=>{switch(t[0]){case"Q":{let r=e||Y;return[Y.prefix,r.decode(`${Y.prefix}${t}`)]}case Y.prefix:{let r=e||Y;return[Y.prefix,r.decode(t)]}case Pe.prefix:{let r=e||Pe;return[Pe.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Oo=(t,e,r)=>{let{prefix:n}=r;if(n!==Y.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o},Vo=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o},$e=112,Fo=18,kr=(t,e,r)=>{let n=ue(t),o=n+ue(e),i=new Uint8Array(o+r.byteLength);return ce(t,i,0),ce(e,i,n),i.set(r,o),i},jo=Symbol.for("@ipld/js-cid/CID");var Ro=new TextDecoder;function Bt(t,e){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(e>=t.length)throw new Error("protobuf: unexpected end of data");let o=t[e++];if(r+=n<28?(o&127)<<n:(o&127)*2**n,o<128)break}return[r,e]}function nt(t,e){let r;[r,e]=Bt(t,e);let n=e+r;if(r<0||n<0)throw new Error("protobuf: invalid length");if(n>t.length)throw new Error("protobuf: unexpected end of data");return[t.subarray(e,n),n]}function Tr(t,e){let r;return[r,e]=Bt(t,e),[r&7,r>>3,e]}function Qo(t){let e={},r=t.length,n=0;for(;n<r;){let o,i;if([o,i,n]=Tr(t,n),i===1){if(e.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Hash`);if(e.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[e.Hash,n]=nt(t,n)}else if(i===2){if(e.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Name`);if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let s;[s,n]=nt(t,n),e.Name=Ro.decode(s)}else if(i===3){if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(o!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Tsize`);[e.Tsize,n]=Bt(t,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${i}`)}if(n>r)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function Ar(t){let e=t.length,r=0,n,o=!1,i;for(;r<e;){let c,u;if([c,u,r]=Tr(t,r),c!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${c}`);if(u===1){if(i)throw new Error("protobuf: (PBNode) duplicate Data section");[i,r]=nt(t,r),n&&(o=!0)}else if(u===2){if(o)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let w;[w,r]=nt(t,r),n.push(Qo(w))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${u}`)}if(r>e)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return i&&(s.Data=i),s.Links=n||[],s}var Fs=new TextEncoder,js=2**32,Rs=2**31;var qs=new TextEncoder;var _r=112;function Sr(t){let e=Ar(t),r={};return e.Data&&(r.Data=e.Data),e.Links&&(r.Links=e.Links.map(n=>{let o={};try{o.Hash=ze.decode(n.Hash)}catch{}if(!o.Hash)throw new Error("Invalid Hash field found in link, expected CID");return n.Name!==void 0&&(o.Name=n.Name),n.Tsize!==void 0&&(o.Tsize=n.Tsize),o})),r}var qo=["string","number","bigint","symbol"],Ho=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Ir(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(qo.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(Go(t))return"Buffer";let r=Jo(t);return r||"Object"}function Go(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function Jo(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(Ho.includes(e))return e}var a=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};a.uint=new a(0,"uint",!0);a.negint=new a(1,"negint",!0);a.bytes=new a(2,"bytes",!0);a.string=new a(3,"string",!0);a.array=new a(4,"array",!1);a.map=new a(5,"map",!1);a.tag=new a(6,"tag",!1);a.float=new a(7,"float",!0);a.false=new a(7,"false",!0);a.true=new a(7,"true",!0);a.null=new a(7,"null",!0);a.undefined=new a(7,"undefined",!0);a.break=new a(7,"break",!0);var f=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var de=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Ko=new TextDecoder,Xo=new TextEncoder;function ot(t){return de&&globalThis.Buffer.isBuffer(t)}function it(t){return t instanceof Uint8Array?ot(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var Nr=de?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):Cr(t,e,r):(t,e,r)=>r-e>64?Ko.decode(t.subarray(e,r)):Cr(t,e,r),st=de?t=>t.length>64?globalThis.Buffer.from(t):Ur(t):t=>t.length>64?Xo.encode(t):Ur(t);var le=de?(t,e,r)=>ot(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Pr=de?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),it(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},$r=de?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function zr(t,e){if(ot(t)&&ot(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function Ur(t,e=1/0){let r,n=t.length,o=null,i=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return i}function Cr(t,e,r){let n=[];for(;e<r;){let o=t[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=r){let c,u,w,p;switch(s){case 1:o<128&&(i=o);break;case 2:c=t[e+1],(c&192)===128&&(p=(o&31)<<6|c&63,p>127&&(i=p));break;case 3:c=t[e+1],u=t[e+2],(c&192)===128&&(u&192)===128&&(p=(o&15)<<12|(c&63)<<6|u&63,p>2047&&(p<55296||p>57343)&&(i=p));break;case 4:c=t[e+1],u=t[e+2],w=t[e+3],(c&192)===128&&(u&192)===128&&(w&192)===128&&(p=(o&15)<<18|(c&63)<<12|(u&63)<<6|w&63,p>65535&&p<1114112&&(i=p))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return Nt(n)}var Br=4096;function Nt(t){let e=t.length;if(e<=Br)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Br));return r}var Yo=256,at=class{constructor(e=Yo){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=$r(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=le(n,0,this.cursor)}else r=Pr(this.chunks,this.cursor);return e&&this.reset(),r}};var d="CBOR decode error:",pe="CBOR encode error:",De=[];De[23]=1;De[24]=2;De[25]=3;De[26]=5;De[27]=9;function Z(t,e,r){if(t.length-e<r)throw new Error(`${d} not enough data for type`)}var U=[24,256,65536,4294967296,BigInt("18446744073709551616")];function L(t,e,r){Z(t,e,1);let n=t[e];if(r.strict===!0&&n<U[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function O(t,e,r){Z(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<U[1])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function V(t,e,r){Z(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<U[2])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function F(t,e,r){Z(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<U[3])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${d} integers outside of the safe integer range are not supported`)}function Dr(t,e,r,n){return new f(a.uint,L(t,e+1,n),2)}function Mr(t,e,r,n){return new f(a.uint,O(t,e+1,n),3)}function Lr(t,e,r,n){return new f(a.uint,V(t,e+1,n),5)}function Or(t,e,r,n){return new f(a.uint,F(t,e+1,n),9)}function j(t,e){return B(t,0,e.value)}function B(t,e,r){if(r<U[0]){let n=Number(r);t.push([e|n])}else if(r<U[1]){let n=Number(r);t.push([e|24,n])}else if(r<U[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<U[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<U[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,t.push(o)}else throw new Error(`${d} encountered BigInt larger than allowable range`)}}j.encodedSize=function(e){return B.encodedSize(e.value)};B.encodedSize=function(e){return e<U[0]?1:e<U[1]?2:e<U[2]?3:e<U[3]?5:9};j.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function Vr(t,e,r,n){return new f(a.negint,-1-L(t,e+1,n),2)}function Fr(t,e,r,n){return new f(a.negint,-1-O(t,e+1,n),3)}function jr(t,e,r,n){return new f(a.negint,-1-V(t,e+1,n),5)}var Pt=BigInt(-1),Rr=BigInt(1);function Qr(t,e,r,n){let o=F(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new f(a.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${d} integers outside of the safe integer range are not supported`);return new f(a.negint,Pt-BigInt(o),9)}function ct(t,e){let r=e.value,n=typeof r=="bigint"?r*Pt-Rr:r*-1-1;B(t,e.type.majorEncoded,n)}ct.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*Pt-Rr:r*-1-1;return n<U[0]?1:n<U[1]?2:n<U[2]?3:n<U[3]?5:9};ct.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function Me(t,e,r,n){Z(t,e,r+n);let o=le(t,e+r,e+r+n);return new f(a.bytes,o,r+n)}function Wr(t,e,r,n){return Me(t,e,1,r)}function qr(t,e,r,n){return Me(t,e,2,L(t,e+1,n))}function Hr(t,e,r,n){return Me(t,e,3,O(t,e+1,n))}function Gr(t,e,r,n){return Me(t,e,5,V(t,e+1,n))}function Jr(t,e,r,n){let o=F(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return Me(t,e,9,o)}function ut(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===a.string?st(t.value):t.value),t.encodedBytes}function me(t,e){let r=ut(e);B(t,e.type.majorEncoded,r.length),t.push(r)}me.encodedSize=function(e){let r=ut(e);return B.encodedSize(r.length)+r.length};me.compareTokens=function(e,r){return ei(ut(e),ut(r))};function ei(t,e){return t.length<e.length?-1:t.length>e.length?1:zr(t,e)}function Le(t,e,r,n,o){let i=r+n;Z(t,e,i);let s=new f(a.string,Nr(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=le(t,e+r,e+i)),s}function Kr(t,e,r,n){return Le(t,e,1,r,n)}function Xr(t,e,r,n){return Le(t,e,2,L(t,e+1,n),n)}function Yr(t,e,r,n){return Le(t,e,3,O(t,e+1,n),n)}function Zr(t,e,r,n){return Le(t,e,5,V(t,e+1,n),n)}function en(t,e,r,n){let o=F(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return Le(t,e,9,o,n)}var tn=me;function we(t,e,r,n){return new f(a.array,n,r)}function rn(t,e,r,n){return we(t,e,1,r)}function nn(t,e,r,n){return we(t,e,2,L(t,e+1,n))}function on(t,e,r,n){return we(t,e,3,O(t,e+1,n))}function sn(t,e,r,n){return we(t,e,5,V(t,e+1,n))}function an(t,e,r,n){let o=F(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer array lengths not supported`);return we(t,e,9,o)}function cn(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return we(t,e,1,1/0)}function ft(t,e){B(t,a.array.majorEncoded,e.value)}ft.compareTokens=j.compareTokens;ft.encodedSize=function(e){return B.encodedSize(e.value)};function ye(t,e,r,n){return new f(a.map,n,r)}function un(t,e,r,n){return ye(t,e,1,r)}function fn(t,e,r,n){return ye(t,e,2,L(t,e+1,n))}function hn(t,e,r,n){return ye(t,e,3,O(t,e+1,n))}function dn(t,e,r,n){return ye(t,e,5,V(t,e+1,n))}function ln(t,e,r,n){let o=F(t,e+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer map lengths not supported`);return ye(t,e,9,o)}function pn(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return ye(t,e,1,1/0)}function ht(t,e){B(t,a.map.majorEncoded,e.value)}ht.compareTokens=j.compareTokens;ht.encodedSize=function(e){return B.encodedSize(e.value)};function mn(t,e,r,n){return new f(a.tag,r,1)}function wn(t,e,r,n){return new f(a.tag,L(t,e+1,n),2)}function yn(t,e,r,n){return new f(a.tag,O(t,e+1,n),3)}function gn(t,e,r,n){return new f(a.tag,V(t,e+1,n),5)}function bn(t,e,r,n){return new f(a.tag,F(t,e+1,n),9)}function dt(t,e){B(t,a.tag.majorEncoded,e.value)}dt.compareTokens=j.compareTokens;dt.encodedSize=function(e){return B.encodedSize(e.value)};var si=20,ai=21,ci=22,ui=23;function xn(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new f(a.null,null,1):new f(a.undefined,void 0,1)}function vn(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new f(a.break,void 0,1)}function $t(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${d} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${d} Infinity values are not supported`)}return new f(a.float,t,e)}function En(t,e,r,n){return $t(zt(t,e+1),3,n)}function kn(t,e,r,n){return $t(Dt(t,e+1),5,n)}function Tn(t,e,r,n){return $t(In(t,e+1),9,n)}function lt(t,e,r){let n=e.value;if(n===!1)t.push([a.float.majorEncoded|si]);else if(n===!0)t.push([a.float.majorEncoded|ai]);else if(n===null)t.push([a.float.majorEncoded|ci]);else if(n===void 0)t.push([a.float.majorEncoded|ui]);else{let o,i=!1;(!r||r.float64!==!0)&&(_n(n),o=zt(q,1),n===o||Number.isNaN(n)?(q[0]=249,t.push(q.slice(0,3)),i=!0):(Sn(n),o=Dt(q,1),n===o&&(q[0]=250,t.push(q.slice(0,5)),i=!0))),i||(fi(n),o=In(q,1),q[0]=251,t.push(q.slice(0,9)))}}lt.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){_n(n);let o=zt(q,1);if(n===o||Number.isNaN(n))return 3;if(Sn(n),o=Dt(q,1),n===o)return 5}return 9};var An=new ArrayBuffer(9),R=new DataView(An,1),q=new Uint8Array(An,0);function _n(t){if(t===1/0)R.setUint16(0,31744,!1);else if(t===-1/0)R.setUint16(0,64512,!1);else if(Number.isNaN(t))R.setUint16(0,32256,!1);else{R.setFloat32(0,t);let e=R.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)R.setUint16(0,31744,!1);else if(r===0)R.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?R.setUint16(0,0):o<-14?R.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):R.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function zt(t,e){if(t.length-e<2)throw new Error(`${d} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Sn(t){R.setFloat32(0,t,!1)}function Dt(t,e){if(t.length-e<4)throw new Error(`${d} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function fi(t){R.setFloat64(0,t,!1)}function In(t,e){if(t.length-e<8)throw new Error(`${d} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}lt.compareTokens=j.compareTokens;function g(t,e,r){throw new Error(`${d} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function pt(t){return()=>{throw new Error(`${d} ${t}`)}}var h=[];for(let t=0;t<=23;t++)h[t]=g;h[24]=Dr;h[25]=Mr;h[26]=Lr;h[27]=Or;h[28]=g;h[29]=g;h[30]=g;h[31]=g;for(let t=32;t<=55;t++)h[t]=g;h[56]=Vr;h[57]=Fr;h[58]=jr;h[59]=Qr;h[60]=g;h[61]=g;h[62]=g;h[63]=g;for(let t=64;t<=87;t++)h[t]=Wr;h[88]=qr;h[89]=Hr;h[90]=Gr;h[91]=Jr;h[92]=g;h[93]=g;h[94]=g;h[95]=pt("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)h[t]=Kr;h[120]=Xr;h[121]=Yr;h[122]=Zr;h[123]=en;h[124]=g;h[125]=g;h[126]=g;h[127]=pt("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)h[t]=rn;h[152]=nn;h[153]=on;h[154]=sn;h[155]=an;h[156]=g;h[157]=g;h[158]=g;h[159]=cn;for(let t=160;t<=183;t++)h[t]=un;h[184]=fn;h[185]=hn;h[186]=dn;h[187]=ln;h[188]=g;h[189]=g;h[190]=g;h[191]=pn;for(let t=192;t<=215;t++)h[t]=mn;h[216]=wn;h[217]=yn;h[218]=gn;h[219]=bn;h[220]=g;h[221]=g;h[222]=g;h[223]=g;for(let t=224;t<=243;t++)h[t]=pt("simple values are not supported");h[244]=g;h[245]=g;h[246]=g;h[247]=xn;h[248]=pt("simple values are not supported");h[249]=En;h[250]=kn;h[251]=Tn;h[252]=g;h[253]=g;h[254]=g;h[255]=vn;var H=[];for(let t=0;t<24;t++)H[t]=new f(a.uint,t,1);for(let t=-1;t>=-24;t--)H[31-t]=new f(a.negint,t,1);H[64]=new f(a.bytes,new Uint8Array(0),1);H[96]=new f(a.string,"",1);H[128]=new f(a.array,0,1);H[160]=new f(a.map,0,1);H[244]=new f(a.false,!1,1);H[245]=new f(a.true,!0,1);H[246]=new f(a.null,null,1);function di(){let t=[];return t[a.uint.major]=j,t[a.negint.major]=ct,t[a.bytes.major]=me,t[a.string.major]=tn,t[a.array.major]=ft,t[a.map.major]=ht,t[a.tag.major]=dt,t[a.float.major]=lt,t}var Ga=di(),Ja=new at,mt=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${pe} object contains circular references`);return new t(r,e)}},ne={null:new f(a.null,null),undefined:new f(a.undefined,void 0),true:new f(a.true,!0),false:new f(a.false,!1),emptyArray:new f(a.array,0),emptyMap:new f(a.map,0)},oe={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new f(a.float,t):t>=0?new f(a.uint,t):new f(a.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new f(a.uint,t):new f(a.negint,t)},Uint8Array(t,e,r,n){return new f(a.bytes,t)},string(t,e,r,n){return new f(a.string,t)},boolean(t,e,r,n){return t?ne.true:ne.false},null(t,e,r,n){return ne.null},undefined(t,e,r,n){return ne.undefined},ArrayBuffer(t,e,r,n){return new f(a.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new f(a.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[ne.emptyArray,new f(a.break)]:ne.emptyArray;n=mt.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=Mt(s,r,n);return r.addBreakTokens?[new f(a.array,t.length),o,new f(a.break)]:[new f(a.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),s=o?t.size:i.length;if(!s)return r.addBreakTokens===!0?[ne.emptyMap,new f(a.break)]:ne.emptyMap;n=mt.createCheck(n,t);let c=[],u=0;for(let w of i)c[u++]=[Mt(w,r,n),Mt(o?t.get(w):t[w],r,n)];return li(c,r),r.addBreakTokens?[new f(a.map,s),c,new f(a.break)]:[new f(a.map,s),c]}};oe.Map=oe.Object;oe.Buffer=oe.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))oe[`${t}Array`]=oe.DataView;function Mt(t,e={},r){let n=Ir(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||oe[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=oe[n];if(!i)throw new Error(`${pe} unsupported type: ${n}`);return i(t,n,e,r)}function li(t,e){e.mapSorter&&t.sort(e.mapSorter)}var pi={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Lt=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r}done(){return this.pos>=this.data.length}next(){let e=this.data[this.pos],r=H[e];if(r===void 0){let n=h[e];if(!n)throw new Error(`${d} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this.pos,o,this.options)}return this.pos+=r.encodedLength,r}},Oe=Symbol.for("DONE"),wt=Symbol.for("BREAK");function mi(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=Ve(e,r);if(i===wt){if(t.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(i===Oe)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function wi(t,e,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<t.value;s++){let c=Ve(e,r);if(c===wt){if(t.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(c===Oe)throw new Error(`${d} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${d} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${d} found repeat map key "${c}"`);let u=Ve(e,r);if(u===Oe)throw new Error(`${d} found map but not enough entries (got ${s} [no value], expected ${t.value})`);n?i.set(c,u):o[c]=u}return n?i:o}function Ve(t,e){if(t.done())return Oe;let r=t.next();if(r.type===a.break)return wt;if(r.type.terminal)return r.value;if(r.type===a.array)return mi(r,t,e);if(r.type===a.map)return wi(r,t,e);if(r.type===a.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=Ve(t,e);return e.tags[r.value](n)}throw new Error(`${d} tag not supported (${r.value})`)}throw new Error("unsupported")}function Fe(t,e){if(!(t instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);e=Object.assign({},pi,e);let r=e.tokenizer||new Lt(t,e),n=Ve(r,e);if(n===Oe)throw new Error(`${d} did not find any content to decode`);if(n===wt)throw new Error(`${d} got unexpected break`);if(!r.done())throw new Error(`${d} too many terminals, data makes no sense`);return n}var Un=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let r=this.inRecursive[this.inRecursive.length-1];r&&(r.type===a.array&&(r.elements++,r.elements!==1&&e.push([44])),r.type===a.map&&(r.elements++,r.elements!==1&&(r.elements%2===1?e.push([44]):e.push([58]))))}[a.uint.major](e,r){this.prefix(e);let n=String(r.value),o=[];for(let i=0;i<n.length;i++)o[i]=n.charCodeAt(i);e.push(o)}[a.negint.major](e,r){this[a.uint.major](e,r)}[a.bytes.major](e,r){throw new Error(`${pe} unsupported type: Uint8Array`)}[a.string.major](e,r){this.prefix(e);let n=st(JSON.stringify(r.value));e.push(n.length>32?it(n):n)}[a.array.major](e,r){this.prefix(e),this.inRecursive.push({type:a.array,elements:0}),e.push([91])}[a.map.major](e,r){this.prefix(e),this.inRecursive.push({type:a.map,elements:0}),e.push([123])}[a.tag.major](e,r){}[a.float.major](e,r){if(r.type.name==="break"){let s=this.inRecursive.pop();if(s){if(s.type===a.array)e.push([93]);else if(s.type===a.map)e.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(r.value===void 0)throw new Error(`${pe} unsupported type: undefined`);if(this.prefix(e),r.type.name==="true"){e.push([116,114,117,101]);return}else if(r.type.name==="false"){e.push([102,97,108,115,101]);return}else if(r.type.name==="null"){e.push([110,117,108,108]);return}let n=String(r.value),o=[],i=!1;for(let s=0;s<n.length;s++)o[s]=n.charCodeAt(s),!i&&(o[s]===46||o[s]===101||o[s]===69)&&(i=!0);i||(o.push(46),o.push(48)),e.push(o)}};var ge=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r,this.modeStack=["value"],this.lastToken=""}done(){return this.pos>=this.data.length}ch(){return this.data[this.pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;e===32||e===9||e===13||e===10;)e=this.data[++this.pos]}expect(e){if(this.data.length-this.pos<e.length)throw new Error(`${d} unexpected end of input at position ${this.pos}`);for(let r=0;r<e.length;r++)if(this.data[this.pos++]!==e[r])throw new Error(`${d} unexpected token at position ${this.pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this.pos,r=!1,n=!1,o=c=>{for(;!this.done();){let u=this.ch();if(c.includes(u))this.pos++;else break}};if(this.ch()===45&&(r=!0,this.pos++),this.ch()===48)if(this.pos++,this.ch()===46)this.pos++,n=!0;else return new f(a.uint,0,this.pos-e);if(o([48,49,50,51,52,53,54,55,56,57]),r&&this.pos===e+1)throw new Error(`${d} unexpected token at position ${this.pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${d} unexpected token at position ${this.pos}`);n=!0,this.pos++,o([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(n=!0,this.pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this.pos++,o([48,49,50,51,52,53,54,55,56,57]));let i=String.fromCharCode.apply(null,this.data.subarray(e,this.pos)),s=parseFloat(i);return n?new f(a.float,s,this.pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(s)?new f(s>=0?a.uint:a.negint,s,this.pos-e):new f(s>=0?a.uint:a.negint,BigInt(i),this.pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${d} unexpected character at position ${this.pos}; this shouldn't happen`);this.pos++;for(let i=this.pos,s=0;i<this.data.length&&s<65536;i++,s++){let c=this.data[i];if(c===92||c<32||c>=128)break;if(c===34){let u=String.fromCharCode.apply(null,this.data.subarray(this.pos,i));return this.pos=i+1,new f(a.string,u,s)}}let e=this.pos,r=[],n=()=>{if(this.pos+4>=this.data.length)throw new Error(`${d} unexpected end of unicode escape sequence at position ${this.pos}`);let i=0;for(let s=0;s<4;s++){let c=this.ch();if(c>=48&&c<=57)c-=48;else if(c>=97&&c<=102)c=c-97+10;else if(c>=65&&c<=70)c=c-65+10;else throw new Error(`${d} unexpected unicode escape character at position ${this.pos}`);i=i*16+c,this.pos++}return i},o=()=>{let i=this.ch(),s=null,c=i>239?4:i>223?3:i>191?2:1;if(this.pos+c>this.data.length)throw new Error(`${d} unexpected unicode sequence at position ${this.pos}`);let u,w,p,y;switch(c){case 1:i<128&&(s=i);break;case 2:u=this.data[this.pos+1],(u&192)===128&&(y=(i&31)<<6|u&63,y>127&&(s=y));break;case 3:u=this.data[this.pos+1],w=this.data[this.pos+2],(u&192)===128&&(w&192)===128&&(y=(i&15)<<12|(u&63)<<6|w&63,y>2047&&(y<55296||y>57343)&&(s=y));break;case 4:u=this.data[this.pos+1],w=this.data[this.pos+2],p=this.data[this.pos+3],(u&192)===128&&(w&192)===128&&(p&192)===128&&(y=(i&15)<<18|(u&63)<<12|(w&63)<<6|p&63,y>65535&&y<1114112&&(s=y))}s===null?(s=65533,c=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),this.pos+=c};for(;!this.done();){let i=this.ch(),s;switch(i){case 92:if(this.pos++,this.done())throw new Error(`${d} unexpected string termination at position ${this.pos}`);switch(s=this.ch(),this.pos++,s){case 34:case 39:case 92:case 47:r.push(s);break;case 98:r.push(8);break;case 116:r.push(9);break;case 110:r.push(10);break;case 102:r.push(12);break;case 114:r.push(13);break;case 117:r.push(n());break;default:throw new Error(`${d} unexpected string escape character at position ${this.pos}`)}break;case 34:return this.pos++,new f(a.string,Nt(r),this.pos-e);default:if(i<32)throw new Error(`${d} invalid control character at position ${this.pos}`);i<128?(r.push(i),this.pos++):o()}}throw new Error(`${d} unexpected end of string at position ${this.pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this.pos++,new f(a.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new f(a.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new f(a.null,null,4);case 102:return this.expect([102,97,108,115,101]),new f(a.false,!1,5);case 116:return this.expect([116,114,117,101]),new f(a.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${d} unexpected character at position ${this.pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this.pos++,this.skipWhitespace(),new f(a.break,void 0,1);if(this.ch()!==44)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this.pos++,this.skipWhitespace(),new f(a.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this.pos++,this.skipWhitespace(),new f(a.break,void 0,1);if(this.ch()!==44)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this.pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this.pos++,this.skipWhitespace(),new f(a.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${d} unexpected character at position ${this.pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("obj-value"),e}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${d} unexpected parse state at position ${this.pos}; this shouldn't happen`)}}};function Ot(t,e){return e=Object.assign({tokenizer:new ge(t,e)},e),Fe(t,e)}function bi(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=t.length,u=t.charAt(0),w=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function y(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var b=0,P=0,v=0,T=m.length;v!==T&&m[v]===0;)v++,b++;for(var A=(T-v)*p+1>>>0,x=new Uint8Array(A);v!==T;){for(var _=m[v],C=0,E=A-1;(_!==0||C<P)&&E!==-1;E--,C++)_+=256*x[E]>>>0,x[E]=_%c>>>0,_=_/c>>>0;if(_!==0)throw new Error("Non-zero carry");P=C,v++}for(var I=A-P;I!==A&&x[I]===0;)I++;for(var K=u.repeat(b);I<A;++I)K+=t.charAt(x[I]);return K}function Q(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var b=0;if(m[b]!==" "){for(var P=0,v=0;m[b]===u;)P++,b++;for(var T=(m.length-b)*w+1>>>0,A=new Uint8Array(T);m[b];){var x=r[m.charCodeAt(b)];if(x===255)return;for(var _=0,C=T-1;(x!==0||_<v)&&C!==-1;C--,_++)x+=c*A[C]>>>0,A[C]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");v=_,b++}if(m[b]!==" "){for(var E=T-v;E!==T&&A[E]===0;)E++;for(var I=new Uint8Array(P+(T-E)),K=P;E!==T;)I[K++]=A[E++];return I}}}function J(m){var b=Q(m);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:Q,decode:J}}var xi=bi,vi=xi,Cn=vi;var xc=new Uint8Array(0);var Bn=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},ae=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var Vt=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ft=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 Nn(this,e)}},jt=class{constructor(e){this.decoders=e}or(e){return Nn(this,e)}decode(e){let r=e[0],n=this.decoders[r];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`)}},Nn=(t,e)=>new jt({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Rt=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Vt(e,r,n),this.decoder=new Ft(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Pn=({name:t,prefix:e,encode:r,decode:n})=>new Rt(t,e,r,n),Qt=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=Cn(r,e);return Pn({prefix:t,name:e,encode:n,decode:i=>ae(o(i))})},Ei=(t,e,r,n)=>{let o={};for(let p=0;p<e.length;++p)o[e[p]]=p;let i=t.length;for(;t[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),c=0,u=0,w=0;for(let p=0;p<i;++p){let y=o[t[p]];if(y===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<r|y,c+=r,c>=8&&(c-=8,s[w++]=255&u>>c)}if(c>=r||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s},ki=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let u=0;u<t.length;++u)for(c=c<<8|t[u],s+=8;s>r;)s-=r,i+=e[o&c>>s];if(s&&(i+=e[o&c<<r-s]),n)for(;i.length*r&7;)i+="=";return i},z=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Pn({prefix:e,name:t,encode(o){return ki(o,n,r)},decode(o){return Ei(o,n,r,t)}});var $n=z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),_c=z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Sc=z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ic=z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ti=Mn,zn=128,Ai=127,_i=~Ai,Si=Math.pow(2,31);function Mn(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Si;)e[r++]=t&255|zn,t/=128;for(;t&_i;)e[r++]=t&255|zn,t>>>=7;return e[r]=t|0,Mn.bytes=r-n+1,e}var Ii=Wt,Ui=128,Dn=127;function Wt(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw Wt.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Dn)<<o:(s&Dn)*Math.pow(2,o),o+=7}while(s>=Ui);return Wt.bytes=i-n,r}var Ci=Math.pow(2,7),Bi=Math.pow(2,14),Ni=Math.pow(2,21),Pi=Math.pow(2,28),$i=Math.pow(2,35),zi=Math.pow(2,42),Di=Math.pow(2,49),Mi=Math.pow(2,56),Li=Math.pow(2,63),Oi=function(t){return t<Ci?1:t<Bi?2:t<Ni?3:t<Pi?4:t<$i?5:t<zi?6:t<Di?7:t<Mi?8:t<Li?9:10},Vi={encode:Ti,decode:Ii,encodingLength:Oi},Fi=Vi,je=Fi;var Re=(t,e=0)=>[je.decode(t,e),je.decode.bytes],be=(t,e,r=0)=>(je.encode(t,e,r),e),xe=t=>je.encodingLength(t);var On=(t,e)=>{let r=e.byteLength,n=xe(t),o=n+xe(r),i=new Uint8Array(o+r);return be(t,i,0),be(r,i,n),i.set(e,o),new ve(t,r,e,i)},Vn=t=>{let e=ae(t),[r,n]=Re(e),[o,i]=Re(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new ve(r,o,s,e)},Fn=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Bn(t.bytes,r.bytes)}},ve=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var ee=Qt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$c=Qt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Qe=z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Mc=z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Lc=z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Oc=z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Vc=z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Fc=z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),jc=z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Rc=z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Qc=z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var jn=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Qi(r,qt(t),e||ee.encoder);default:return Wi(r,qt(t),e||Qe.encoder)}};var Rn=new WeakMap,qt=t=>{let e=Rn.get(t);if(e==null){let r=new Map;return Rn.set(t,r),r}return e},qe=class t{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==We)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==qi)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=On(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&Fn(e.multihash,n.multihash)}toString(e){return jn(this,e)}toJSON(){return{"/":jn(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 r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s||Qn(n,o,i.bytes))}else if(r[Hi]===!0){let{version:n,multihash:o,code:i}=r,s=Vn(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==We)throw new Error(`Version 0 CID must use dag-pb (code: ${We}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Qn(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,We,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=ae(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new ve(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[y,Q]=Re(e.subarray(r));return r+=Q,y},o=n(),i=We;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),u=n(),w=r+u,p=w-s;return{version:o,codec:i,multihashCode:c,digestSize:u,multihashSize:p,size:w}}static parse(e,r){let[n,o]=Ri(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return qt(i).set(n,e),i}},Ri=(t,e)=>{switch(t[0]){case"Q":{let r=e||ee;return[ee.prefix,r.decode(`${ee.prefix}${t}`)]}case ee.prefix:{let r=e||ee;return[ee.prefix,r.decode(t)]}case Qe.prefix:{let r=e||Qe;return[Qe.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Qi=(t,e,r)=>{let{prefix:n}=r;if(n!==ee.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o},Wi=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o},We=112,qi=18,Qn=(t,e,r)=>{let n=xe(t),o=n+xe(e),i=new Uint8Array(o+r.byteLength);return be(t,i,0),be(e,i,n),i.set(r,o),i},Hi=Symbol.for("@ipld/js-cid/CID");var Wn=85;var qn={codec:_r,async*walk(t){yield*Sr(t).Links.map(r=>r.Hash)}},Hn={codec:Wn,async*walk(){}},Gn=42,Jn={codec:113,async*walk(t){let e=[],r=[];r[Gn]=n=>{if(n[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");let o=qe.decode(n.subarray(1));return e.push(o),o},Fe(t,{tags:r}),yield*e}},Ht=class extends ge{tokenBuffer;constructor(e,r){super(e,r),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let e=this._next();if(e.type===a.map){let r=this._next();if(r.type===a.string&&r.value==="/"){let n=this._next();if(n.type===a.string){if(this._next().type!==a.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new f(a.tag,42,0)}if(n.type===a.map){let o=this._next();if(o.type===a.string&&o.value==="bytes"){let i=this._next();if(i.type===a.string){for(let c=0;c<2;c++)if(this._next().type!==a.break)throw new Error("Invalid encoded Bytes form");let s=$n.decode(`m${i.value}`);return new f(a.bytes,s,i.value.length)}this.tokenBuffer.push(i)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return e}},Kn={codec:297,async*walk(t){let e=[],r=[];r[Gn]=n=>{let o=qe.parse(n);return e.push(o),o},Ot(t,{tags:r,tokenizer:new Ht(t,{tags:r,allowIndefinite:!0,allowUndefined:!0,allowNaN:!0,allowInfinity:!0,allowBigInt:!0,strict:!1,rejectDuplicateMapKeys:!1})}),yield*e}};var Ji=[Hn,qn,Jn,Kn],Ki=1,Gt=class{components;dagWalkers;constructor(e,r){this.components=e,this.dagWalkers={},[...Ji,...r.dagWalkers??[]].forEach(n=>{this.dagWalkers[n.codec]=n})}async import(e,r){await Kt(this.components.blockstore.putMany(Yt(e.blocks(),({cid:n,bytes:o})=>({cid:n,block:o})),r))}async export(e,r,n){let o=yt(),i=Array.isArray(e)?e:[e],s=new Ce({concurrency:Ki});s.on("idle",()=>{o.resolve()}),s.on("error",c=>{o.resolve(c)});for(let c of i)s.add(async()=>{await this.#e(c,s,async(u,w)=>{await r.put({cid:u,bytes:w})},n)});try{await o.promise}finally{await r.close()}}async#e(e,r,n,o){let i=this.dagWalkers[e.code];if(i==null)throw new Error(`No dag walker found for cid codec ${e.code}`);let s=await this.components.blockstore.get(e,o);await n(e,s);for await(let c of i.walk(s))r.add(async()=>{await this.#e(c,r,n,o)})}};function Xi(t,e={}){return new Gt(t,e)}return io(Yi);})();
3
3
  return HeliaCar}));
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * `@helia/car` provides `import` and `export` methods to read/write Car files to {@link https://github.com/ipfs/helia Helia}'s blockstore.
5
5
  *
6
- * See the {@link Car Car interface} for all available operations.
6
+ * See the {@link Car} interface for all available operations.
7
7
  *
8
8
  * By default it supports `dag-pb`, `dag-cbor`, `dag-json` and `raw` CIDs, more esoteric DAG walkers can be passed as an init option.
9
9
  *
package/dist/src/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * `@helia/car` provides `import` and `export` methods to read/write Car files to {@link https://github.com/ipfs/helia Helia}'s blockstore.
5
5
  *
6
- * See the {@link Car Car interface} for all available operations.
6
+ * See the {@link Car} interface for all available operations.
7
7
  *
8
8
  * By default it supports `dag-pb`, `dag-cbor`, `dag-json` and `raw` CIDs, more esoteric DAG walkers can be passed as an init option.
9
9
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/car",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Import/export car files from Helia",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/ipfs/helia-car/tree/master/packages/car#readme",
@@ -144,7 +144,6 @@
144
144
  "lint": "aegir lint",
145
145
  "dep-check": "aegir dep-check",
146
146
  "build": "aegir build",
147
- "docs": "aegir docs",
148
147
  "test": "aegir test",
149
148
  "test:chrome": "aegir test -t browser --cov",
150
149
  "test:chrome-webworker": "aegir test -t webworker",
@@ -169,13 +168,10 @@
169
168
  },
170
169
  "devDependencies": {
171
170
  "@helia/unixfs": "^1.2.2",
172
- "aegir": "^39.0.8",
171
+ "aegir": "^40.0.11",
173
172
  "blockstore-core": "^4.0.1",
174
173
  "ipfs-unixfs-importer": "^15.1.0",
175
174
  "it-drain": "^3.0.1",
176
175
  "it-to-buffer": "^4.0.2"
177
- },
178
- "typedoc": {
179
- "entryPoint": "./src/index.ts"
180
176
  }
181
177
  }
package/src/index.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * `@helia/car` provides `import` and `export` methods to read/write Car files to {@link https://github.com/ipfs/helia Helia}'s blockstore.
5
5
  *
6
- * See the {@link Car Car interface} for all available operations.
6
+ * See the {@link Car} interface for all available operations.
7
7
  *
8
8
  * By default it supports `dag-pb`, `dag-cbor`, `dag-json` and `raw` CIDs, more esoteric DAG walkers can be passed as an init option.
9
9
  *