@helia/car 3.2.1-3bf5ab0 → 3.2.1-8805202
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 +1 -1
- package/package.json +8 -8
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 bn=Object.create;var Ce=Object.defineProperty;var vn=Object.getOwnPropertyDescriptor;var En=Object.getOwnPropertyNames;var _n=Object.getPrototypeOf,kn=Object.prototype.hasOwnProperty;var ce=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Tn=(e,t)=>{for(var r in t)Ce(e,r,{get:t[r],enumerable:!0})},Nt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of En(t))!kn.call(e,o)&&o!==r&&Ce(e,o,{get:()=>t[o],enumerable:!(n=vn(t,o))||n.enumerable});return e};var Se=(e,t,r)=>(r=e!=null?bn(_n(e)):{},Nt(t||!e||!e.__esModule?Ce(r,"default",{value:e,enumerable:!0}):r,e)),An=e=>Nt(Ce({},"__esModule",{value:!0}),e);var jr=ce((Ws,Zr)=>{Zr.exports=yt;var Qr=128,Mo=127,$o=~Mo,Lo=Math.pow(2,31);function yt(e,t,r){if(Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw yt.bytes=0,new RangeError("Could not encode varint");t=t||[],r=r||0;for(var n=r;e>=Lo;)t[r++]=e&255|Qr,e/=128;for(;e&$o;)t[r++]=e&255|Qr,e>>>=7;return t[r]=e|0,yt.bytes=r-n+1,t}});var rn=ce((Ks,tn)=>{tn.exports=mt;var Vo=128,en=127;function mt(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u||o>49)throw mt.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&en)<<o:(a&en)*Math.pow(2,o),o+=7}while(a>=Vo);return mt.bytes=i-n,r}});var on=ce((Ys,nn)=>{var Po=Math.pow(2,7),Fo=Math.pow(2,14),Ho=Math.pow(2,21),qo=Math.pow(2,28),Go=Math.pow(2,35),Wo=Math.pow(2,42),Ko=Math.pow(2,49),Yo=Math.pow(2,56),Xo=Math.pow(2,63);nn.exports=function(e){return e<Po?1:e<Fo?2:e<Ho?3:e<qo?4:e<Go?5:e<Wo?6:e<Ko?7:e<Yo?8:e<Xo?9:10}});var qe=ce((Xs,sn)=>{sn.exports={encode:jr(),decode:rn(),encodingLength:on()}});var wn=ce((Za,At)=>{"use strict";var ui=Object.prototype.hasOwnProperty,E="~";function _e(){}Object.create&&(_e.prototype=Object.create(null),new _e().__proto__||(E=!1));function fi(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function mn(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new fi(r,n||e,o),a=E?E+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],i]:e._events[a].push(i):(e._events[a]=i,e._eventsCount++),e}function Ke(e,t){--e._eventsCount===0?e._events=new _e:delete e._events[t]}function b(){this._events=new _e,this._eventsCount=0}b.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)ui.call(r,n)&&t.push(E?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};b.prototype.listeners=function(t){var r=E?E+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,a=new Array(i);o<i;o++)a[o]=n[o].fn;return a};b.prototype.listenerCount=function(t){var r=E?E+t:t,n=this._events[r];return n?n.fn?1:n.length:0};b.prototype.emit=function(t,r,n,o,i,a){var u=E?E+t:t;if(!this._events[u])return!1;var c=this._events[u],p=arguments.length,l,m;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),p){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,a),!0}for(m=1,l=new Array(p-1);m<p;m++)l[m-1]=arguments[m];c.fn.apply(c.context,l)}else{var v=c.length,Y;for(m=0;m<v;m++)switch(c[m].once&&this.removeListener(t,c[m].fn,void 0,!0),p){case 1:c[m].fn.call(c[m].context);break;case 2:c[m].fn.call(c[m].context,r);break;case 3:c[m].fn.call(c[m].context,r,n);break;case 4:c[m].fn.call(c[m].context,r,n,o);break;default:if(!l)for(Y=1,l=new Array(p-1);Y<p;Y++)l[Y-1]=arguments[Y];c[m].fn.apply(c[m].context,l)}}return!0};b.prototype.on=function(t,r,n){return mn(this,t,r,n,!1)};b.prototype.once=function(t,r,n){return mn(this,t,r,n,!0)};b.prototype.removeListener=function(t,r,n,o){var i=E?E+t:t;if(!this._events[i])return this;if(!r)return Ke(this,i),this;var a=this._events[i];if(a.fn)a.fn===r&&(!o||a.once)&&(!n||a.context===n)&&Ke(this,i);else{for(var u=0,c=[],p=a.length;u<p;u++)(a[u].fn!==r||o&&!a[u].once||n&&a[u].context!==n)&&c.push(a[u]);c.length?this._events[i]=c.length===1?c[0]:c:Ke(this,i)}return this};b.prototype.removeAllListeners=function(t){var r;return t?(r=E?E+t:t,this._events[r]&&Ke(this,r)):(this._events=new _e,this._eventsCount=0),this};b.prototype.off=b.prototype.removeListener;b.prototype.addListener=b.prototype.on;b.prefixed=E;b.EventEmitter=b;typeof At<"u"&&(At.exports=b)});var hi={};Tn(hi,{car:()=>li});var In=["string","number","bigint","symbol"],Cn=["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 Ot(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(In.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Sn(e))return"Buffer";let r=Un(e);return r||"Object"}function Sn(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Un(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Cn.includes(t))return t}var s=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};s.uint=new s(0,"uint",!0);s.negint=new s(1,"negint",!0);s.bytes=new s(2,"bytes",!0);s.string=new s(3,"string",!0);s.array=new s(4,"array",!1);s.map=new s(5,"map",!1);s.tag=new s(6,"tag",!1);s.float=new s(7,"float",!0);s.false=new s(7,"false",!0);s.true=new s(7,"true",!0);s.null=new s(7,"null",!0);s.undefined=new s(7,"undefined",!0);s.break=new s(7,"break",!0);var d=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Q=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Bn=new TextDecoder,Nn=new TextEncoder;function Ue(e){return Q&&globalThis.Buffer.isBuffer(e)}function Ye(e){return e instanceof Uint8Array?Ue(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Mt=Q?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Rt(e,t,r):(e,t,r)=>r-t>64?Bn.decode(e.subarray(t,r)):Rt(e,t,r),$t=Q?e=>e.length>64?globalThis.Buffer.from(e):Dt(e):e=>e.length>64?Nn.encode(e):Dt(e),L=e=>Uint8Array.from(e),Z=Q?(e,t,r)=>Ue(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Lt=Q?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ye(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Vt=Q?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Pt(e,t){if(Ue(e)&&Ue(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Dt(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Rt(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=r){let u,c,p,l;switch(a){case 1:o<128&&(i=o);break;case 2:u=e[t+1],(u&192)===128&&(l=(o&31)<<6|u&63,l>127&&(i=l));break;case 3:u=e[t+1],c=e[t+2],(u&192)===128&&(c&192)===128&&(l=(o&15)<<12|(u&63)<<6|c&63,l>2047&&(l<55296||l>57343)&&(i=l));break;case 4:u=e[t+1],c=e[t+2],p=e[t+3],(u&192)===128&&(c&192)===128&&(p&192)===128&&(l=(o&15)<<18|(u&63)<<12|(c&63)<<6|p&63,l>65535&&l<1114112&&(i=l))}}i===null?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=a}return On(n)}var zt=4096;function On(e){let t=e.length;if(t<=zt)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=zt));return r}var Dn=256,ue=class{constructor(t=Dn){this.chunkSize=t,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(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,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)}t.length<64&&t.length<this.chunkSize?(r=Vt(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Z(n,0,this.cursor)}else r=Lt(this.chunks,this.cursor);return t&&this.reset(),r}};var h="CBOR decode error:",Xe="CBOR encode error:",fe=[];fe[23]=1;fe[24]=2;fe[25]=3;fe[26]=5;fe[27]=9;function F(e,t,r){if(e.length-t<r)throw new Error(`${h} not enough data for type`)}var g=[24,256,65536,4294967296,BigInt("18446744073709551616")];function k(e,t,r){F(e,t,1);let n=e[t];if(r.strict===!0&&n<g[0])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function T(e,t,r){F(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<g[1])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function A(e,t,r){F(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<g[2])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function I(e,t,r){F(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<g[3])throw new Error(`${h} 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(`${h} integers outside of the safe integer range are not supported`)}function Ft(e,t,r,n){return new d(s.uint,k(e,t+1,n),2)}function Ht(e,t,r,n){return new d(s.uint,T(e,t+1,n),3)}function qt(e,t,r,n){return new d(s.uint,A(e,t+1,n),5)}function Gt(e,t,r,n){return new d(s.uint,I(e,t+1,n),9)}function S(e,t){return x(e,0,t.value)}function x(e,t,r){if(r<g[0]){let n=Number(r);e.push([t|n])}else if(r<g[1]){let n=Number(r);e.push([t|24,n])}else if(r<g[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<g[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<g[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),a=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]=a&255,a=a>>8,o[3]=a&255,a=a>>8,o[2]=a&255,a=a>>8,o[1]=a&255,e.push(o)}else throw new Error(`${h} encountered BigInt larger than allowable range`)}}S.encodedSize=function(t){return x.encodedSize(t.value)};x.encodedSize=function(t){return t<g[0]?1:t<g[1]?2:t<g[2]?3:t<g[3]?5:9};S.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Wt(e,t,r,n){return new d(s.negint,-1-k(e,t+1,n),2)}function Kt(e,t,r,n){return new d(s.negint,-1-T(e,t+1,n),3)}function Yt(e,t,r,n){return new d(s.negint,-1-A(e,t+1,n),5)}var Je=BigInt(-1),Xt=BigInt(1);function Jt(e,t,r,n){let o=I(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new d(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${h} integers outside of the safe integer range are not supported`);return new d(s.negint,Je-BigInt(o),9)}function Be(e,t){let r=t.value,n=typeof r=="bigint"?r*Je-Xt:r*-1-1;x(e,t.type.majorEncoded,n)}Be.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Je-Xt:r*-1-1;return n<g[0]?1:n<g[1]?2:n<g[2]?3:n<g[3]?5:9};Be.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function de(e,t,r,n){F(e,t,r+n);let o=Z(e,t+r,t+r+n);return new d(s.bytes,o,r+n)}function Qt(e,t,r,n){return de(e,t,1,r)}function Zt(e,t,r,n){return de(e,t,2,k(e,t+1,n))}function jt(e,t,r,n){return de(e,t,3,T(e,t+1,n))}function er(e,t,r,n){return de(e,t,5,A(e,t+1,n))}function tr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer bytes lengths not supported`);return de(e,t,9,o)}function Ne(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===s.string?$t(e.value):e.value),e.encodedBytes}function j(e,t){let r=Ne(t);x(e,t.type.majorEncoded,r.length),e.push(r)}j.encodedSize=function(t){let r=Ne(t);return x.encodedSize(r.length)+r.length};j.compareTokens=function(t,r){return zn(Ne(t),Ne(r))};function zn(e,t){return e.length<t.length?-1:e.length>t.length?1:Pt(e,t)}function le(e,t,r,n,o){let i=r+n;F(e,t,i);let a=new d(s.string,Mt(e,t+r,t+i),i);return o.retainStringBytes===!0&&(a.byteValue=Z(e,t+r,t+i)),a}function rr(e,t,r,n){return le(e,t,1,r,n)}function nr(e,t,r,n){return le(e,t,2,k(e,t+1,n),n)}function or(e,t,r,n){return le(e,t,3,T(e,t+1,n),n)}function ir(e,t,r,n){return le(e,t,5,A(e,t+1,n),n)}function sr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer string lengths not supported`);return le(e,t,9,o,n)}var ar=j;function ee(e,t,r,n){return new d(s.array,n,r)}function cr(e,t,r,n){return ee(e,t,1,r)}function ur(e,t,r,n){return ee(e,t,2,k(e,t+1,n))}function fr(e,t,r,n){return ee(e,t,3,T(e,t+1,n))}function dr(e,t,r,n){return ee(e,t,5,A(e,t+1,n))}function lr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer array lengths not supported`);return ee(e,t,9,o)}function hr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return ee(e,t,1,1/0)}function Oe(e,t){x(e,s.array.majorEncoded,t.value)}Oe.compareTokens=S.compareTokens;Oe.encodedSize=function(t){return x.encodedSize(t.value)};function te(e,t,r,n){return new d(s.map,n,r)}function pr(e,t,r,n){return te(e,t,1,r)}function yr(e,t,r,n){return te(e,t,2,k(e,t+1,n))}function mr(e,t,r,n){return te(e,t,3,T(e,t+1,n))}function wr(e,t,r,n){return te(e,t,5,A(e,t+1,n))}function gr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer map lengths not supported`);return te(e,t,9,o)}function xr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return te(e,t,1,1/0)}function De(e,t){x(e,s.map.majorEncoded,t.value)}De.compareTokens=S.compareTokens;De.encodedSize=function(t){return x.encodedSize(t.value)};function br(e,t,r,n){return new d(s.tag,r,1)}function vr(e,t,r,n){return new d(s.tag,k(e,t+1,n),2)}function Er(e,t,r,n){return new d(s.tag,T(e,t+1,n),3)}function _r(e,t,r,n){return new d(s.tag,A(e,t+1,n),5)}function kr(e,t,r,n){return new d(s.tag,I(e,t+1,n),9)}function Re(e,t){x(e,s.tag.majorEncoded,t.value)}Re.compareTokens=S.compareTokens;Re.encodedSize=function(t){return x.encodedSize(t.value)};var Fn=20,Hn=21,qn=22,Gn=23;function Tr(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${h} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new d(s.null,null,1):new d(s.undefined,void 0,1)}function Ar(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return new d(s.break,void 0,1)}function Qe(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${h} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${h} Infinity values are not supported`)}return new d(s.float,e,t)}function Ir(e,t,r,n){return Qe(Ze(e,t+1),3,n)}function Cr(e,t,r,n){return Qe(je(e,t+1),5,n)}function Sr(e,t,r,n){return Qe(Or(e,t+1),9,n)}function ze(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|Fn]);else if(n===!0)e.push([s.float.majorEncoded|Hn]);else if(n===null)e.push([s.float.majorEncoded|qn]);else if(n===void 0)e.push([s.float.majorEncoded|Gn]);else{let o,i=!1;(!r||r.float64!==!0)&&(Br(n),o=Ze(D,1),n===o||Number.isNaN(n)?(D[0]=249,e.push(D.slice(0,3)),i=!0):(Nr(n),o=je(D,1),n===o&&(D[0]=250,e.push(D.slice(0,5)),i=!0))),i||(Wn(n),o=Or(D,1),D[0]=251,e.push(D.slice(0,9)))}}ze.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Br(n);let o=Ze(D,1);if(n===o||Number.isNaN(n))return 3;if(Nr(n),o=je(D,1),n===o)return 5}return 9};var Ur=new ArrayBuffer(9),U=new DataView(Ur,1),D=new Uint8Array(Ur,0);function Br(e){if(e===1/0)U.setUint16(0,31744,!1);else if(e===-1/0)U.setUint16(0,64512,!1);else if(Number.isNaN(e))U.setUint16(0,32256,!1);else{U.setFloat32(0,e);let t=U.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)U.setUint16(0,31744,!1);else if(r===0)U.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?U.setUint16(0,0):o<-14?U.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):U.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ze(e,t){if(e.length-t<2)throw new Error(`${h} not enough data for float16`);let r=(e[t]<<8)+e[t+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 Nr(e){U.setFloat32(0,e,!1)}function je(e,t){if(e.length-t<4)throw new Error(`${h} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Wn(e){U.setFloat64(0,e,!1)}function Or(e,t){if(e.length-t<8)throw new Error(`${h} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}ze.compareTokens=S.compareTokens;function y(e,t,r){throw new Error(`${h} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Me(e){return()=>{throw new Error(`${h} ${e}`)}}var f=[];for(let e=0;e<=23;e++)f[e]=y;f[24]=Ft;f[25]=Ht;f[26]=qt;f[27]=Gt;f[28]=y;f[29]=y;f[30]=y;f[31]=y;for(let e=32;e<=55;e++)f[e]=y;f[56]=Wt;f[57]=Kt;f[58]=Yt;f[59]=Jt;f[60]=y;f[61]=y;f[62]=y;f[63]=y;for(let e=64;e<=87;e++)f[e]=Qt;f[88]=Zt;f[89]=jt;f[90]=er;f[91]=tr;f[92]=y;f[93]=y;f[94]=y;f[95]=Me("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)f[e]=rr;f[120]=nr;f[121]=or;f[122]=ir;f[123]=sr;f[124]=y;f[125]=y;f[126]=y;f[127]=Me("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)f[e]=cr;f[152]=ur;f[153]=fr;f[154]=dr;f[155]=lr;f[156]=y;f[157]=y;f[158]=y;f[159]=hr;for(let e=160;e<=183;e++)f[e]=pr;f[184]=yr;f[185]=mr;f[186]=wr;f[187]=gr;f[188]=y;f[189]=y;f[190]=y;f[191]=xr;for(let e=192;e<=215;e++)f[e]=br;f[216]=vr;f[217]=Er;f[218]=_r;f[219]=kr;f[220]=y;f[221]=y;f[222]=y;f[223]=y;for(let e=224;e<=243;e++)f[e]=Me("simple values are not supported");f[244]=y;f[245]=y;f[246]=y;f[247]=Tr;f[248]=Me("simple values are not supported");f[249]=Ir;f[250]=Cr;f[251]=Sr;f[252]=y;f[253]=y;f[254]=y;f[255]=Ar;var R=[];for(let e=0;e<24;e++)R[e]=new d(s.uint,e,1);for(let e=-1;e>=-24;e--)R[31-e]=new d(s.negint,e,1);R[64]=new d(s.bytes,new Uint8Array(0),1);R[96]=new d(s.string,"",1);R[128]=new d(s.array,0,1);R[160]=new d(s.map,0,1);R[244]=new d(s.false,!1,1);R[245]=new d(s.true,!0,1);R[246]=new d(s.null,null,1);function et(e){switch(e.type){case s.false:return L([244]);case s.true:return L([245]);case s.null:return L([246]);case s.bytes:return e.value.length?void 0:L([64]);case s.string:return e.value===""?L([96]):void 0;case s.array:return e.value===0?L([128]):void 0;case s.map:return e.value===0?L([160]):void 0;case s.uint:return e.value<24?L([Number(e.value)]):void 0;case s.negint:if(e.value>=-24)return L([31-Number(e.value)])}}var Yn={float64:!1,mapSorter:Jn,quickEncodeToken:et};function rt(){let e=[];return e[s.uint.major]=S,e[s.negint.major]=Be,e[s.bytes.major]=j,e[s.string.major]=ar,e[s.array.major]=Oe,e[s.map.major]=De,e[s.tag.major]=Re,e[s.float.major]=ze,e}var Dr=rt(),tt=new ue,$e=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${Xe} object contains circular references`);return new e(r,t)}},G={null:new d(s.null,null),undefined:new d(s.undefined,void 0),true:new d(s.true,!0),false:new d(s.false,!1),emptyArray:new d(s.array,0),emptyMap:new d(s.map,0)},W={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new d(s.float,e):e>=0?new d(s.uint,e):new d(s.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new d(s.uint,e):new d(s.negint,e)},Uint8Array(e,t,r,n){return new d(s.bytes,e)},string(e,t,r,n){return new d(s.string,e)},boolean(e,t,r,n){return e?G.true:G.false},null(e,t,r,n){return G.null},undefined(e,t,r,n){return G.undefined},ArrayBuffer(e,t,r,n){return new d(s.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new d(s.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[G.emptyArray,new d(s.break)]:G.emptyArray;n=$e.createCheck(n,e);let o=[],i=0;for(let a of e)o[i++]=he(a,r,n);return r.addBreakTokens?[new d(s.array,e.length),o,new d(s.break)]:[new d(s.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),a=o?e.size:i.length;if(!a)return r.addBreakTokens===!0?[G.emptyMap,new d(s.break)]:G.emptyMap;n=$e.createCheck(n,e);let u=[],c=0;for(let p of i)u[c++]=[he(p,r,n),he(o?e.get(p):e[p],r,n)];return Xn(u,r),r.addBreakTokens?[new d(s.map,a),u,new d(s.break)]:[new d(s.map,a),u]}};W.Map=W.Object;W.Buffer=W.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))W[`${e}Array`]=W.DataView;function he(e,t={},r){let n=Ot(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||W[n];if(typeof o=="function"){let a=o(e,n,t,r);if(a!=null)return a}let i=W[n];if(!i)throw new Error(`${Xe} unsupported type: ${n}`);return i(e,n,t,r)}function Xn(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Jn(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Dr[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Rr(e,t,r,n){if(Array.isArray(t))for(let o of t)Rr(e,o,r,n);else r[t.type.major](e,t,n)}function Qn(e,t,r){let n=he(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let a=i.encodedSize(n,r),u=new ue(a);if(i(u,n,r),u.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ye(u.chunks[0])}}return tt.reset(),Rr(tt,n,t,r),tt.toBytes(!0)}function nt(e,t){return t=Object.assign({},Yn,t),Qn(e,Dr,t)}var Zn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Le=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=R[t];if(r===void 0){let n=f[t];if(!n)throw new Error(`${h} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},pe=Symbol.for("DONE"),Ve=Symbol.for("BREAK");function jn(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=re(t,r);if(i===Ve){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed array`)}if(i===pe)throw new Error(`${h} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function eo(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let a=0;a<e.value;a++){let u=re(t,r);if(u===Ve){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed map`)}if(u===pe)throw new Error(`${h} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(n!==!0&&typeof u!="string")throw new Error(`${h} non-string keys not supported (got ${typeof u})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(u)||!n&&u in o))throw new Error(`${h} found repeat map key "${u}"`);let c=re(t,r);if(c===pe)throw new Error(`${h} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?i.set(u,c):o[u]=c}return n?i:o}function re(e,t){if(e.done())return pe;let r=e.next();if(r.type===s.break)return Ve;if(r.type.terminal)return r.value;if(r.type===s.array)return jn(r,e,t);if(r.type===s.map)return eo(r,e,t);if(r.type===s.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=re(e,t);return t.tags[r.value](n)}throw new Error(`${h} tag not supported (${r.value})`)}throw new Error("unsupported")}function zr(e,t){if(!(e instanceof Uint8Array))throw new Error(`${h} data to decode must be a Uint8Array`);t=Object.assign({},Zn,t);let r=t.tokenizer||new Le(e,t),n=re(r,t);if(n===pe)throw new Error(`${h} did not find any content to decode`);if(n===Ve)throw new Error(`${h} got unexpected break`);return[n,e.subarray(r.pos())]}function ot(e,t){let[r,n]=zr(e,t);if(n.length>0)throw new Error(`${h} too many terminals, data makes no sense`);return r}var ls=new Uint8Array(0);function Mr(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function ne(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function ro(e,t){if(e.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<e.length;o++){var i=e.charAt(o),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var u=e.length,c=e.charAt(0),p=Math.log(u)/Math.log(256),l=Math.log(256)/Math.log(u);function m(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var _=0,X=0,N=0,z=w.length;N!==z&&w[N]===0;)N++,_++;for(var M=(z-N)*l+1>>>0,C=new Uint8Array(M);N!==z;){for(var $=w[N],q=0,O=M-1;($!==0||q<X)&&O!==-1;O--,q++)$+=256*C[O]>>>0,C[O]=$%u>>>0,$=$/u>>>0;if($!==0)throw new Error("Non-zero carry");X=q,N++}for(var P=M-X;P!==M&&C[P]===0;)P++;for(var Ie=c.repeat(_);P<M;++P)Ie+=e.charAt(C[P]);return Ie}function v(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var _=0;if(w[_]!==" "){for(var X=0,N=0;w[_]===c;)X++,_++;for(var z=(w.length-_)*p+1>>>0,M=new Uint8Array(z);w[_];){var C=r[w.charCodeAt(_)];if(C===255)return;for(var $=0,q=z-1;(C!==0||$<N)&&q!==-1;q--,$++)C+=u*M[q]>>>0,M[q]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");N=$,_++}if(w[_]!==" "){for(var O=z-N;O!==z&&M[O]===0;)O++;for(var P=new Uint8Array(X+(z-O)),Ie=X;O!==z;)P[Ie++]=M[O++];return P}}}function Y(w){var _=v(w);if(_)return _;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:v,decode:Y}}var no=ro,oo=no,$r=oo;var it=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},st=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Lr(this,t)}},at=class{decoders;constructor(t){this.decoders=t}or(t){return Lr(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Lr(e,t){return new at({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ct=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new it(t,r,n),this.decoder=new st(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Vr({name:e,prefix:t,encode:r,decode:n}){return new ct(e,t,r,n)}function oe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=$r(r,e);return Vr({prefix:t,name:e,encode:n,decode:i=>ne(o(i))})}function io(e,t,r,n){let o={};for(let l=0;l<t.length;++l)o[t[l]]=l;let i=e.length;for(;e[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),u=0,c=0,p=0;for(let l=0;l<i;++l){let m=o[e[l]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|m,u+=r,u>=8&&(u-=8,a[p++]=255&c>>u)}if(u>=r||255&c<<8-u)throw new SyntaxError("Unexpected end of data");return a}function so(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",a=0,u=0;for(let c=0;c<e.length;++c)for(u=u<<8|e[c],a+=8;a>r;)a-=r,i+=t[o&u>>a];if(a!==0&&(i+=t[o&u<<r-a]),n)for(;i.length*r&7;)i+="=";return i}function V({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Vr({prefix:t,name:e,encode(o){return so(o,n,r)},decode(o){return io(o,n,r,e)}})}var ye=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xs=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bs=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vs=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Es=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_s=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ks=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ts=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),As=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pe=oe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ss=oe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var H=oe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ns=oe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ao=Hr,Pr=128,co=127,uo=~co,fo=Math.pow(2,31);function Hr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=fo;)t[r++]=e&255|Pr,e/=128;for(;e&uo;)t[r++]=e&255|Pr,e>>>=7;return t[r]=e|0,Hr.bytes=r-n+1,t}var lo=ut,ho=128,Fr=127;function ut(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u)throw ut.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&Fr)<<o:(a&Fr)*Math.pow(2,o),o+=7}while(a>=ho);return ut.bytes=i-n,r}var po=Math.pow(2,7),yo=Math.pow(2,14),mo=Math.pow(2,21),wo=Math.pow(2,28),go=Math.pow(2,35),xo=Math.pow(2,42),bo=Math.pow(2,49),vo=Math.pow(2,56),Eo=Math.pow(2,63),_o=function(e){return e<po?1:e<yo?2:e<mo?3:e<wo?4:e<go?5:e<xo?6:e<bo?7:e<vo?8:e<Eo?9:10},ko={encode:ao,decode:lo,encodingLength:_o},To=ko,me=To;function we(e,t=0){return[me.decode(e,t),me.decode.bytes]}function ie(e,t,r=0){return me.encode(e,t,r),t}function se(e){return me.encodingLength(e)}function Gr(e,t){let r=t.byteLength,n=se(e),o=n+se(r),i=new Uint8Array(o+r);return ie(e,i,0),ie(r,i,n),i.set(t,o),new ae(e,r,t,i)}function Fe(e){let t=ne(e),[r,n]=we(t),[o,i]=we(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new ae(r,o,a,t)}function Wr(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Mr(e.bytes,r.bytes)}}var ae=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Kr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Io(r,dt(e),t??H.encoder);default:return Co(r,dt(e),t??ye.encoder)}}var Yr=new WeakMap;function dt(e){let t=Yr.get(e);if(t==null){let r=new Map;return Yr.set(e,r),r}return t}var B=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==ge)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==So)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.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:t,digest:r}=this.multihash,n=Gr(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Wr(t.multihash,n.multihash)}toString(t){return Kr(this,t)}toJSON(){return{"/":Kr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:a}=r;return new e(n,o,i,a??Xr(n,o,i.bytes))}else if(r[Uo]===!0){let{version:n,multihash:o,code:i}=r,a=Fe(o);return e.create(n,i,a)}else return null}static create(t,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(t){case 0:{if(r!==ge)throw new Error(`Version 0 CID must use dag-pb (code: ${ge}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Xr(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ge,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=ne(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new ae(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(a):e.createV1(r.codec,a),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[m,v]=we(t.subarray(r));return r+=v,m},o=n(),i=ge;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),c=n(),p=r+c,l=p-a;return{version:o,codec:i,multihashCode:u,digestSize:c,multihashSize:l,size:p}}static parse(t,r){let[n,o]=Ao(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return dt(i).set(n,t),i}};function Ao(e,t){switch(e[0]){case"Q":{let r=t??H;return[H.prefix,r.decode(`${H.prefix}${e}`)]}case H.prefix:{let r=t??H;return[H.prefix,r.decode(e)]}case ye.prefix:{let r=t??ye;return[ye.prefix,r.decode(e)]}case Pe.prefix:{let r=t??Pe;return[Pe.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Io(e,t,r){let{prefix:n}=r;if(n!==H.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Co(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var ge=112,So=18;function Xr(e,t,r){let n=se(e),o=n+se(t),i=new Uint8Array(o+r.byteLength);return ie(e,i,0),ie(t,i,n),i.set(r,o),i}var Uo=Symbol.for("@ipld/js-cid/CID");var Jr=42;function Bo(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function No(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=B.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new d(s.tag,Jr),new d(s.bytes,r)]}function Oo(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Do(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var lt={float64:!0,typeEncoders:{Object:No,undefined:Oo,number:Do}},qs={...lt,typeEncoders:{...lt.typeEncoders}};function Ro(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return B.decode(e.subarray(1))}var He={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};He.tags[Jr]=Ro;var Gs={...He,tags:He.tags.slice()};var ht=e=>nt(e,lt),pt=e=>ot(Bo(e),He);var wt=Se(qe(),1);var gt=40;function xt(e,t){if(!e.length)throw new Error("Unexpected end of data");let r=wt.default.decode(e);return t.seek(wt.default.decode.bytes),r}function bt(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),r=0;return{version:2,characteristics:[t.getBigUint64(r,!0),t.getBigUint64(r+=8,!0)],dataOffset:Number(t.getBigUint64(r+=8,!0)),dataSize:Number(t.getBigUint64(r+=8,!0)),indexOffset:Number(t.getBigUint64(r+=8,!0))}}var K={Null:e=>e===null?e:void 0,Int:e=>Number.isInteger(e)?e:void 0,Float:e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,String:e=>typeof e=="string"?e:void 0,Bool:e=>typeof e=="boolean"?e:void 0,Bytes:e=>e instanceof Uint8Array?e:void 0,Link:e=>e!==null&&typeof e=="object"&&e.asCID===e?e:void 0,List:e=>Array.isArray(e)?e:void 0,Map:e=>e!==null&&typeof e=="object"&&e.asCID!==e&&!Array.isArray(e)&&!(e instanceof Uint8Array)?e:void 0},xe={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":K.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(K.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=xe["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let o=t;o<e.length;o++){let i=e[o];if(i=xe["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:K.Int,CarV1HeaderOrV2Pragma:e=>{if(K.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let o=0;o<t.length;o++){let[i,a]=t[o];switch(i){case"roots":{let u=xe["CarV1HeaderOrV2Pragma > roots (anon)"](e[i]);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.roots=u}}break;case"version":{n--;let u=xe.Int(e[i]);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.version=u}}break;default:return}}if(!(n>0))return r}},be={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":K.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(K.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=be["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let o=t;o<e.length;o++){let i=e[o];if(i=be["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:K.Int,CarV1HeaderOrV2Pragma:e=>{if(K.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let o=0;o<t.length;o++){let[i,a]=t[o];switch(i){case"roots":{let u=be["CarV1HeaderOrV2Pragma > roots (anon)"](a);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.roots=u}}break;case"version":{n--;let u=be.Int(a);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.version=u}}break;default:return}}if(!(n>0))return r}},vt={toTyped:xe.CarV1HeaderOrV2Pragma,toRepresentation:be.CarV1HeaderOrV2Pragma};var sa=rt();var jo=Se(qe(),1);var da=[new d(s.map,2),new d(s.string,"version"),new d(s.uint,1),new d(s.string,"roots")],la=new d(s.tag,42);async function Et(e,t){let r=xt(await e.upTo(8),e);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await e.exactly(r,!0),o=pt(n);if(vt.toTyped(o)===void 0)throw new Error("Invalid CAR header format");if(o.version!==1&&o.version!==2||t!==void 0&&o.version!==t)throw new Error(`Invalid CAR version: ${o.version}${t!==void 0?` (expected ${t})`:""}`);if(o.version===1){if(!Array.isArray(o.roots))throw new Error("Invalid CAR header format");return o}if(o.roots!==void 0)throw new Error("Invalid CAR header format");let i=bt(await e.exactly(gt,!0));e.seek(i.dataOffset-e.pos);let a=await Et(e,1);return Object.assign(a,i)}function ve(e){let t=0;return{async upTo(r){return e.subarray(t,t+Math.min(r,e.length-t))},async exactly(r,n=!1){if(r>e.length-t)throw new Error("Unexpected end of data");let o=e.subarray(t,t+r);return n&&(t+=r),o},seek(r){t+=r},get pos(){return t}}}var _t=Se(qe(),1),un=1;function kt(e){let t=ht({version:un,roots:e}),r=_t.default.encode(t.length),n=new Uint8Array(r.length+t.length);return n.set(r,0),n.set(t,r.length),n}function fn(e){return{async setRoots(t){let r=kt(t);await e.write(r)},async writeBlock(t){let{cid:r,bytes:n}=t;await e.write(new Uint8Array(_t.default.encode(r.bytes.length+n.length))),await e.write(r.bytes),n.length&&await e.write(n)},async close(){await e.end()},version(){return un}}}function Ge(){}function dn(){let e=[],t=null,r=Ge,n=!1,o=null,i=Ge,a=()=>(t||(t=new Promise(p=>{r=()=>{t=null,r=Ge,p()}})),t),u={write(p){e.push(p);let l=a();return i(),l},async end(){n=!0;let p=a();i(),await p}},c={async next(){let p=e.shift();return p?(e.length===0&&r(),{done:!1,value:p}):n?(r(),{done:!0,value:void 0}):(o||(o=new Promise(l=>{i=()=>(o=null,i=Ge,l(c.next()))})),o)}};return{writer:u,iterator:c}}var Ee=class e{constructor(t,r){this._encoder=r,this._mutex=r.setRoots(t),this._ended=!1}async put(t){if(!(t.bytes instanceof Uint8Array)||!t.cid)throw new TypeError("Can only write {cid, bytes} objects");if(this._ended)throw new Error("Already closed");let r=B.asCID(t.cid);if(!r)throw new TypeError("Can only write {cid, bytes} objects");return this._mutex=this._mutex.then(()=>this._encoder.writeBlock({cid:r,bytes:t.bytes})),this._mutex}async close(){if(this._ended)throw new Error("Already closed");return await this._mutex,this._ended=!0,this._encoder.close()}version(){return this._encoder.version()}static create(t){t=ni(t);let{encoder:r,iterator:n}=ln(),o=new e(t,r),i=new We(n);return{writer:o,out:i}}static createAppender(){let{encoder:t,iterator:r}=ln();t.setRoots=()=>Promise.resolve();let n=new e([],t),o=new We(r);return{writer:n,out:o}}static async updateRootsInBytes(t,r){let n=ve(t);await Et(n);let o=kt(r);if(Number(n.pos)!==o.length)throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${n.pos} bytes, new header is ${o.length} bytes)`);return t.set(o,0),t}},We=class{constructor(t){this._iterator=t}[Symbol.asyncIterator](){if(this._iterating)throw new Error("Multiple iterator not supported");return this._iterating=!0,this._iterator}};function ln(){let e=dn(),{writer:t,iterator:r}=e;return{encoder:fn(t),iterator:r}}function ni(e){if(e===void 0)return[];if(!Array.isArray(e)){let r=B.asCID(e);if(!r)throw new TypeError("roots must be a single CID or an array of CIDs");return[r]}let t=[];for(let r of e){let n=B.asCID(r);if(!n)throw new TypeError("roots must be a single CID or an array of CIDs");t.push(n)}return t}function oi(e){return e[Symbol.asyncIterator]!=null}function ii(e){if(oi(e))return(async()=>{for await(let t of e);})();for(let t of e);}var hn=ii;function si(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}var pn=si;function ai(e){return e[Symbol.asyncIterator]!=null}function ci(e,t){let r=0;if(ai(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=pn(e),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let a=t(o,r++);if(typeof a.then=="function")return async function*(){yield await a;for await(let c of n)yield t(c,r++)}();let u=t;return function*(){yield a;for(let c of n)yield u(c,r++)}()}var yn=ci;function Tt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var It=Se(wn(),1);var ke=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Ct=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},gn=e=>globalThis.DOMException===void 0?new Ct(e):new DOMException(e),xn=e=>{let t=e.reason===void 0?gn("This operation was aborted."):e.reason;return t instanceof Error?t:gn(t)};function St(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,a,c=new Promise((p,l)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:v}=t;v.aborted&&l(xn(v)),v.addEventListener("abort",()=>{l(xn(v))})}if(r===Number.POSITIVE_INFINITY){e.then(p,l);return}let m=new ke;a=i.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(v){l(v)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?p():o instanceof Error?l(o):(m.message=o??`Promise timed out after ${r} milliseconds`,l(m))},r),(async()=>{try{p(await e)}catch(v){l(v)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},c}function Ut(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),a=n+i;r(e[a],t)<=0?(n=++a,o-=i+1):o=i}return n}var Te=class{#e=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,run:t};if(this.size&&this.#e[this.size-1].priority>=r.priority){this.#e.push(n);return}let o=Ut(this.#e,n,(i,a)=>a.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(t){return this.#e.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#e.length}};var Ae=class extends It.default{#e;#s;#i=0;#h;#a;#p=0;#r;#c;#t;#y;#n=0;#u;#o;#m;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Te,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#e=t.carryoverConcurrencyCount,this.#s=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#h=t.intervalCap,this.#a=t.interval,this.#t=new t.queueClass,this.#y=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#m=t.throwOnTimeout===!0,this.#o=t.autoStart===!1}get#x(){return this.#s||this.#i<this.#h}get#b(){return this.#n<this.#u}#v(){this.#n--,this.#f(),this.emit("next")}#E(){this.#g(),this.#w(),this.#c=void 0}get#_(){let t=Date.now();if(this.#r===void 0){let r=this.#p-t;if(r<0)this.#i=this.#e?this.#n:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#E()},r)),!0}return!1}#f(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#o){let t=!this.#_;if(this.#x&&this.#b){let r=this.#t.dequeue();return r?(this.emit("active"),r(),t&&this.#w(),!0):!1}}return!1}#w(){this.#s||this.#r!==void 0||(this.#r=setInterval(()=>{this.#g()},this.#a),this.#p=Date.now()+this.#a)}#g(){this.#i===0&&this.#n===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#i=this.#e?this.#n:0,this.#d()}#d(){for(;this.#f(););}get concurrency(){return this.#u}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#u=t,this.#d()}async#k(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}async add(t,r={}){return r={timeout:this.timeout,throwOnTimeout:this.#m,...r},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#n++,this.#i++;try{r.signal?.throwIfAborted();let i=t({signal:r.signal});r.timeout&&(i=St(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#k(r.signal)]));let a=await i;n(a),this.emit("completed",a)}catch(i){if(i instanceof ke&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#v()}},r),this.emit("add"),this.#f()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#o?(this.#o=!1,this.#d(),this):this}pause(){this.#o=!0}clear(){this.#t=new this.#y}async onEmpty(){this.#t.size!==0&&await this.#l("empty")}async onSizeLessThan(t){this.#t.size<t||await this.#l("next",()=>this.#t.size<t)}async onIdle(){this.#n===0&&this.#t.size===0||await this.#l("idle")}async#l(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#t.size}sizeBy(t){return this.#t.filter(t).length}get pending(){return this.#n}get isPaused(){return this.#o}};var di=1,Bt=class{components;constructor(t,r){this.components=t}async import(t,r){await hn(this.components.blockstore.putMany(yn(t.blocks(),({cid:n,bytes:o})=>({cid:n,block:o})),r))}async export(t,r,n){let o=Tt(),i=Array.isArray(t)?t:[t],a=new Ae({concurrency:di});a.on("idle",()=>{o.resolve()}),a.on("error",u=>{a.clear(),o.reject(u)});for(let u of i)a.add(async()=>{await this.#e(u,a,async(c,p)=>{n?.blockFilter?.has(c.multihash.bytes)!==!0&&(n?.blockFilter?.add(c.multihash.bytes),await r.put({cid:c,bytes:p}))},n)}).catch(()=>{});try{await o.promise}finally{await r.close()}}async*stream(t,r){let{writer:n,out:o}=Ee.create(t);this.export(t,n,r).catch(()=>{});for await(let i of o)yield i}async#e(t,r,n,o){let i=this.components.dagWalkers[t.code];if(i==null)throw new Error(`No dag walker found for cid codec ${t.code}`);let a=await this.components.blockstore.get(t,o);await n(t,a);for await(let u of i.walk(a))r.add(async()=>{await this.#e(u,r,n,o)})}};function li(e,t={}){return new Bt(e,t)}return An(hi);})();
|
|
2
|
+
"use strict";var HeliaCar=(()=>{var bn=Object.create;var Ce=Object.defineProperty;var vn=Object.getOwnPropertyDescriptor;var En=Object.getOwnPropertyNames;var _n=Object.getPrototypeOf,kn=Object.prototype.hasOwnProperty;var ce=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Tn=(e,t)=>{for(var r in t)Ce(e,r,{get:t[r],enumerable:!0})},Nt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of En(t))!kn.call(e,o)&&o!==r&&Ce(e,o,{get:()=>t[o],enumerable:!(n=vn(t,o))||n.enumerable});return e};var Se=(e,t,r)=>(r=e!=null?bn(_n(e)):{},Nt(t||!e||!e.__esModule?Ce(r,"default",{value:e,enumerable:!0}):r,e)),An=e=>Nt(Ce({},"__esModule",{value:!0}),e);var jr=ce((Ws,Zr)=>{Zr.exports=yt;var Qr=128,Mo=127,$o=~Mo,Lo=Math.pow(2,31);function yt(e,t,r){if(Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw yt.bytes=0,new RangeError("Could not encode varint");t=t||[],r=r||0;for(var n=r;e>=Lo;)t[r++]=e&255|Qr,e/=128;for(;e&$o;)t[r++]=e&255|Qr,e>>>=7;return t[r]=e|0,yt.bytes=r-n+1,t}});var rn=ce((Ks,tn)=>{tn.exports=mt;var Vo=128,en=127;function mt(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u||o>49)throw mt.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&en)<<o:(a&en)*Math.pow(2,o),o+=7}while(a>=Vo);return mt.bytes=i-n,r}});var on=ce((Ys,nn)=>{var Po=Math.pow(2,7),Fo=Math.pow(2,14),Ho=Math.pow(2,21),qo=Math.pow(2,28),Go=Math.pow(2,35),Wo=Math.pow(2,42),Ko=Math.pow(2,49),Yo=Math.pow(2,56),Xo=Math.pow(2,63);nn.exports=function(e){return e<Po?1:e<Fo?2:e<Ho?3:e<qo?4:e<Go?5:e<Wo?6:e<Ko?7:e<Yo?8:e<Xo?9:10}});var qe=ce((Xs,sn)=>{sn.exports={encode:jr(),decode:rn(),encodingLength:on()}});var wn=ce((Za,At)=>{"use strict";var ui=Object.prototype.hasOwnProperty,E="~";function _e(){}Object.create&&(_e.prototype=Object.create(null),new _e().__proto__||(E=!1));function fi(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function mn(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new fi(r,n||e,o),a=E?E+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],i]:e._events[a].push(i):(e._events[a]=i,e._eventsCount++),e}function Ke(e,t){--e._eventsCount===0?e._events=new _e:delete e._events[t]}function b(){this._events=new _e,this._eventsCount=0}b.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)ui.call(r,n)&&t.push(E?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};b.prototype.listeners=function(t){var r=E?E+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,a=new Array(i);o<i;o++)a[o]=n[o].fn;return a};b.prototype.listenerCount=function(t){var r=E?E+t:t,n=this._events[r];return n?n.fn?1:n.length:0};b.prototype.emit=function(t,r,n,o,i,a){var u=E?E+t:t;if(!this._events[u])return!1;var c=this._events[u],p=arguments.length,l,m;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),p){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,a),!0}for(m=1,l=new Array(p-1);m<p;m++)l[m-1]=arguments[m];c.fn.apply(c.context,l)}else{var v=c.length,Y;for(m=0;m<v;m++)switch(c[m].once&&this.removeListener(t,c[m].fn,void 0,!0),p){case 1:c[m].fn.call(c[m].context);break;case 2:c[m].fn.call(c[m].context,r);break;case 3:c[m].fn.call(c[m].context,r,n);break;case 4:c[m].fn.call(c[m].context,r,n,o);break;default:if(!l)for(Y=1,l=new Array(p-1);Y<p;Y++)l[Y-1]=arguments[Y];c[m].fn.apply(c[m].context,l)}}return!0};b.prototype.on=function(t,r,n){return mn(this,t,r,n,!1)};b.prototype.once=function(t,r,n){return mn(this,t,r,n,!0)};b.prototype.removeListener=function(t,r,n,o){var i=E?E+t:t;if(!this._events[i])return this;if(!r)return Ke(this,i),this;var a=this._events[i];if(a.fn)a.fn===r&&(!o||a.once)&&(!n||a.context===n)&&Ke(this,i);else{for(var u=0,c=[],p=a.length;u<p;u++)(a[u].fn!==r||o&&!a[u].once||n&&a[u].context!==n)&&c.push(a[u]);c.length?this._events[i]=c.length===1?c[0]:c:Ke(this,i)}return this};b.prototype.removeAllListeners=function(t){var r;return t?(r=E?E+t:t,this._events[r]&&Ke(this,r)):(this._events=new _e,this._eventsCount=0),this};b.prototype.off=b.prototype.removeListener;b.prototype.addListener=b.prototype.on;b.prefixed=E;b.EventEmitter=b;typeof At<"u"&&(At.exports=b)});var hi={};Tn(hi,{car:()=>li});var In=["string","number","bigint","symbol"],Cn=["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 Ot(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(In.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Sn(e))return"Buffer";let r=Un(e);return r||"Object"}function Sn(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Un(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Cn.includes(t))return t}var s=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};s.uint=new s(0,"uint",!0);s.negint=new s(1,"negint",!0);s.bytes=new s(2,"bytes",!0);s.string=new s(3,"string",!0);s.array=new s(4,"array",!1);s.map=new s(5,"map",!1);s.tag=new s(6,"tag",!1);s.float=new s(7,"float",!0);s.false=new s(7,"false",!0);s.true=new s(7,"true",!0);s.null=new s(7,"null",!0);s.undefined=new s(7,"undefined",!0);s.break=new s(7,"break",!0);var d=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Q=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Bn=new TextDecoder,Nn=new TextEncoder;function Ue(e){return Q&&globalThis.Buffer.isBuffer(e)}function Ye(e){return e instanceof Uint8Array?Ue(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Mt=Q?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Rt(e,t,r):(e,t,r)=>r-t>64?Bn.decode(e.subarray(t,r)):Rt(e,t,r),$t=Q?e=>e.length>64?globalThis.Buffer.from(e):Dt(e):e=>e.length>64?Nn.encode(e):Dt(e),L=e=>Uint8Array.from(e),Z=Q?(e,t,r)=>Ue(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Lt=Q?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ye(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Vt=Q?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Pt(e,t){if(Ue(e)&&Ue(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Dt(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Rt(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=r){let u,c,p,l;switch(a){case 1:o<128&&(i=o);break;case 2:u=e[t+1],(u&192)===128&&(l=(o&31)<<6|u&63,l>127&&(i=l));break;case 3:u=e[t+1],c=e[t+2],(u&192)===128&&(c&192)===128&&(l=(o&15)<<12|(u&63)<<6|c&63,l>2047&&(l<55296||l>57343)&&(i=l));break;case 4:u=e[t+1],c=e[t+2],p=e[t+3],(u&192)===128&&(c&192)===128&&(p&192)===128&&(l=(o&15)<<18|(u&63)<<12|(c&63)<<6|p&63,l>65535&&l<1114112&&(i=l))}}i===null?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=a}return On(n)}var zt=4096;function On(e){let t=e.length;if(t<=zt)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=zt));return r}var Dn=256,ue=class{constructor(t=Dn){this.chunkSize=t,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(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,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)}t.length<64&&t.length<this.chunkSize?(r=Vt(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Z(n,0,this.cursor)}else r=Lt(this.chunks,this.cursor);return t&&this.reset(),r}};var h="CBOR decode error:",Xe="CBOR encode error:",fe=[];fe[23]=1;fe[24]=2;fe[25]=3;fe[26]=5;fe[27]=9;function F(e,t,r){if(e.length-t<r)throw new Error(`${h} not enough data for type`)}var g=[24,256,65536,4294967296,BigInt("18446744073709551616")];function k(e,t,r){F(e,t,1);let n=e[t];if(r.strict===!0&&n<g[0])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function T(e,t,r){F(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<g[1])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function A(e,t,r){F(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<g[2])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function I(e,t,r){F(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<g[3])throw new Error(`${h} 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(`${h} integers outside of the safe integer range are not supported`)}function Ft(e,t,r,n){return new d(s.uint,k(e,t+1,n),2)}function Ht(e,t,r,n){return new d(s.uint,T(e,t+1,n),3)}function qt(e,t,r,n){return new d(s.uint,A(e,t+1,n),5)}function Gt(e,t,r,n){return new d(s.uint,I(e,t+1,n),9)}function S(e,t){return x(e,0,t.value)}function x(e,t,r){if(r<g[0]){let n=Number(r);e.push([t|n])}else if(r<g[1]){let n=Number(r);e.push([t|24,n])}else if(r<g[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<g[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<g[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),a=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]=a&255,a=a>>8,o[3]=a&255,a=a>>8,o[2]=a&255,a=a>>8,o[1]=a&255,e.push(o)}else throw new Error(`${h} encountered BigInt larger than allowable range`)}}S.encodedSize=function(t){return x.encodedSize(t.value)};x.encodedSize=function(t){return t<g[0]?1:t<g[1]?2:t<g[2]?3:t<g[3]?5:9};S.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Wt(e,t,r,n){return new d(s.negint,-1-k(e,t+1,n),2)}function Kt(e,t,r,n){return new d(s.negint,-1-T(e,t+1,n),3)}function Yt(e,t,r,n){return new d(s.negint,-1-A(e,t+1,n),5)}var Je=BigInt(-1),Xt=BigInt(1);function Jt(e,t,r,n){let o=I(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new d(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${h} integers outside of the safe integer range are not supported`);return new d(s.negint,Je-BigInt(o),9)}function Be(e,t){let r=t.value,n=typeof r=="bigint"?r*Je-Xt:r*-1-1;x(e,t.type.majorEncoded,n)}Be.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Je-Xt:r*-1-1;return n<g[0]?1:n<g[1]?2:n<g[2]?3:n<g[3]?5:9};Be.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function de(e,t,r,n){F(e,t,r+n);let o=Z(e,t+r,t+r+n);return new d(s.bytes,o,r+n)}function Qt(e,t,r,n){return de(e,t,1,r)}function Zt(e,t,r,n){return de(e,t,2,k(e,t+1,n))}function jt(e,t,r,n){return de(e,t,3,T(e,t+1,n))}function er(e,t,r,n){return de(e,t,5,A(e,t+1,n))}function tr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer bytes lengths not supported`);return de(e,t,9,o)}function Ne(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===s.string?$t(e.value):e.value),e.encodedBytes}function j(e,t){let r=Ne(t);x(e,t.type.majorEncoded,r.length),e.push(r)}j.encodedSize=function(t){let r=Ne(t);return x.encodedSize(r.length)+r.length};j.compareTokens=function(t,r){return zn(Ne(t),Ne(r))};function zn(e,t){return e.length<t.length?-1:e.length>t.length?1:Pt(e,t)}function le(e,t,r,n,o){let i=r+n;F(e,t,i);let a=new d(s.string,Mt(e,t+r,t+i),i);return o.retainStringBytes===!0&&(a.byteValue=Z(e,t+r,t+i)),a}function rr(e,t,r,n){return le(e,t,1,r,n)}function nr(e,t,r,n){return le(e,t,2,k(e,t+1,n),n)}function or(e,t,r,n){return le(e,t,3,T(e,t+1,n),n)}function ir(e,t,r,n){return le(e,t,5,A(e,t+1,n),n)}function sr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer string lengths not supported`);return le(e,t,9,o,n)}var ar=j;function ee(e,t,r,n){return new d(s.array,n,r)}function cr(e,t,r,n){return ee(e,t,1,r)}function ur(e,t,r,n){return ee(e,t,2,k(e,t+1,n))}function fr(e,t,r,n){return ee(e,t,3,T(e,t+1,n))}function dr(e,t,r,n){return ee(e,t,5,A(e,t+1,n))}function lr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer array lengths not supported`);return ee(e,t,9,o)}function hr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return ee(e,t,1,1/0)}function Oe(e,t){x(e,s.array.majorEncoded,t.value)}Oe.compareTokens=S.compareTokens;Oe.encodedSize=function(t){return x.encodedSize(t.value)};function te(e,t,r,n){return new d(s.map,n,r)}function pr(e,t,r,n){return te(e,t,1,r)}function yr(e,t,r,n){return te(e,t,2,k(e,t+1,n))}function mr(e,t,r,n){return te(e,t,3,T(e,t+1,n))}function wr(e,t,r,n){return te(e,t,5,A(e,t+1,n))}function gr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer map lengths not supported`);return te(e,t,9,o)}function xr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return te(e,t,1,1/0)}function De(e,t){x(e,s.map.majorEncoded,t.value)}De.compareTokens=S.compareTokens;De.encodedSize=function(t){return x.encodedSize(t.value)};function br(e,t,r,n){return new d(s.tag,r,1)}function vr(e,t,r,n){return new d(s.tag,k(e,t+1,n),2)}function Er(e,t,r,n){return new d(s.tag,T(e,t+1,n),3)}function _r(e,t,r,n){return new d(s.tag,A(e,t+1,n),5)}function kr(e,t,r,n){return new d(s.tag,I(e,t+1,n),9)}function Re(e,t){x(e,s.tag.majorEncoded,t.value)}Re.compareTokens=S.compareTokens;Re.encodedSize=function(t){return x.encodedSize(t.value)};var Fn=20,Hn=21,qn=22,Gn=23;function Tr(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${h} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new d(s.null,null,1):new d(s.undefined,void 0,1)}function Ar(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return new d(s.break,void 0,1)}function Qe(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${h} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${h} Infinity values are not supported`)}return new d(s.float,e,t)}function Ir(e,t,r,n){return Qe(Ze(e,t+1),3,n)}function Cr(e,t,r,n){return Qe(je(e,t+1),5,n)}function Sr(e,t,r,n){return Qe(Or(e,t+1),9,n)}function ze(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|Fn]);else if(n===!0)e.push([s.float.majorEncoded|Hn]);else if(n===null)e.push([s.float.majorEncoded|qn]);else if(n===void 0)e.push([s.float.majorEncoded|Gn]);else{let o,i=!1;(!r||r.float64!==!0)&&(Br(n),o=Ze(D,1),n===o||Number.isNaN(n)?(D[0]=249,e.push(D.slice(0,3)),i=!0):(Nr(n),o=je(D,1),n===o&&(D[0]=250,e.push(D.slice(0,5)),i=!0))),i||(Wn(n),o=Or(D,1),D[0]=251,e.push(D.slice(0,9)))}}ze.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Br(n);let o=Ze(D,1);if(n===o||Number.isNaN(n))return 3;if(Nr(n),o=je(D,1),n===o)return 5}return 9};var Ur=new ArrayBuffer(9),U=new DataView(Ur,1),D=new Uint8Array(Ur,0);function Br(e){if(e===1/0)U.setUint16(0,31744,!1);else if(e===-1/0)U.setUint16(0,64512,!1);else if(Number.isNaN(e))U.setUint16(0,32256,!1);else{U.setFloat32(0,e);let t=U.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)U.setUint16(0,31744,!1);else if(r===0)U.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?U.setUint16(0,0):o<-14?U.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):U.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ze(e,t){if(e.length-t<2)throw new Error(`${h} not enough data for float16`);let r=(e[t]<<8)+e[t+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 Nr(e){U.setFloat32(0,e,!1)}function je(e,t){if(e.length-t<4)throw new Error(`${h} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Wn(e){U.setFloat64(0,e,!1)}function Or(e,t){if(e.length-t<8)throw new Error(`${h} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}ze.compareTokens=S.compareTokens;function y(e,t,r){throw new Error(`${h} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Me(e){return()=>{throw new Error(`${h} ${e}`)}}var f=[];for(let e=0;e<=23;e++)f[e]=y;f[24]=Ft;f[25]=Ht;f[26]=qt;f[27]=Gt;f[28]=y;f[29]=y;f[30]=y;f[31]=y;for(let e=32;e<=55;e++)f[e]=y;f[56]=Wt;f[57]=Kt;f[58]=Yt;f[59]=Jt;f[60]=y;f[61]=y;f[62]=y;f[63]=y;for(let e=64;e<=87;e++)f[e]=Qt;f[88]=Zt;f[89]=jt;f[90]=er;f[91]=tr;f[92]=y;f[93]=y;f[94]=y;f[95]=Me("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)f[e]=rr;f[120]=nr;f[121]=or;f[122]=ir;f[123]=sr;f[124]=y;f[125]=y;f[126]=y;f[127]=Me("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)f[e]=cr;f[152]=ur;f[153]=fr;f[154]=dr;f[155]=lr;f[156]=y;f[157]=y;f[158]=y;f[159]=hr;for(let e=160;e<=183;e++)f[e]=pr;f[184]=yr;f[185]=mr;f[186]=wr;f[187]=gr;f[188]=y;f[189]=y;f[190]=y;f[191]=xr;for(let e=192;e<=215;e++)f[e]=br;f[216]=vr;f[217]=Er;f[218]=_r;f[219]=kr;f[220]=y;f[221]=y;f[222]=y;f[223]=y;for(let e=224;e<=243;e++)f[e]=Me("simple values are not supported");f[244]=y;f[245]=y;f[246]=y;f[247]=Tr;f[248]=Me("simple values are not supported");f[249]=Ir;f[250]=Cr;f[251]=Sr;f[252]=y;f[253]=y;f[254]=y;f[255]=Ar;var R=[];for(let e=0;e<24;e++)R[e]=new d(s.uint,e,1);for(let e=-1;e>=-24;e--)R[31-e]=new d(s.negint,e,1);R[64]=new d(s.bytes,new Uint8Array(0),1);R[96]=new d(s.string,"",1);R[128]=new d(s.array,0,1);R[160]=new d(s.map,0,1);R[244]=new d(s.false,!1,1);R[245]=new d(s.true,!0,1);R[246]=new d(s.null,null,1);function et(e){switch(e.type){case s.false:return L([244]);case s.true:return L([245]);case s.null:return L([246]);case s.bytes:return e.value.length?void 0:L([64]);case s.string:return e.value===""?L([96]):void 0;case s.array:return e.value===0?L([128]):void 0;case s.map:return e.value===0?L([160]):void 0;case s.uint:return e.value<24?L([Number(e.value)]):void 0;case s.negint:if(e.value>=-24)return L([31-Number(e.value)])}}var Yn={float64:!1,mapSorter:Jn,quickEncodeToken:et};function rt(){let e=[];return e[s.uint.major]=S,e[s.negint.major]=Be,e[s.bytes.major]=j,e[s.string.major]=ar,e[s.array.major]=Oe,e[s.map.major]=De,e[s.tag.major]=Re,e[s.float.major]=ze,e}var Dr=rt(),tt=new ue,$e=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${Xe} object contains circular references`);return new e(r,t)}},G={null:new d(s.null,null),undefined:new d(s.undefined,void 0),true:new d(s.true,!0),false:new d(s.false,!1),emptyArray:new d(s.array,0),emptyMap:new d(s.map,0)},W={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new d(s.float,e):e>=0?new d(s.uint,e):new d(s.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new d(s.uint,e):new d(s.negint,e)},Uint8Array(e,t,r,n){return new d(s.bytes,e)},string(e,t,r,n){return new d(s.string,e)},boolean(e,t,r,n){return e?G.true:G.false},null(e,t,r,n){return G.null},undefined(e,t,r,n){return G.undefined},ArrayBuffer(e,t,r,n){return new d(s.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new d(s.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[G.emptyArray,new d(s.break)]:G.emptyArray;n=$e.createCheck(n,e);let o=[],i=0;for(let a of e)o[i++]=he(a,r,n);return r.addBreakTokens?[new d(s.array,e.length),o,new d(s.break)]:[new d(s.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),a=o?e.size:i.length;if(!a)return r.addBreakTokens===!0?[G.emptyMap,new d(s.break)]:G.emptyMap;n=$e.createCheck(n,e);let u=[],c=0;for(let p of i)u[c++]=[he(p,r,n),he(o?e.get(p):e[p],r,n)];return Xn(u,r),r.addBreakTokens?[new d(s.map,a),u,new d(s.break)]:[new d(s.map,a),u]}};W.Map=W.Object;W.Buffer=W.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))W[`${e}Array`]=W.DataView;function he(e,t={},r){let n=Ot(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||W[n];if(typeof o=="function"){let a=o(e,n,t,r);if(a!=null)return a}let i=W[n];if(!i)throw new Error(`${Xe} unsupported type: ${n}`);return i(e,n,t,r)}function Xn(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Jn(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Dr[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Rr(e,t,r,n){if(Array.isArray(t))for(let o of t)Rr(e,o,r,n);else r[t.type.major](e,t,n)}function Qn(e,t,r){let n=he(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let a=i.encodedSize(n,r),u=new ue(a);if(i(u,n,r),u.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ye(u.chunks[0])}}return tt.reset(),Rr(tt,n,t,r),tt.toBytes(!0)}function nt(e,t){return t=Object.assign({},Yn,t),Qn(e,Dr,t)}var Zn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Le=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=R[t];if(r===void 0){let n=f[t];if(!n)throw new Error(`${h} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},pe=Symbol.for("DONE"),Ve=Symbol.for("BREAK");function jn(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=re(t,r);if(i===Ve){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed array`)}if(i===pe)throw new Error(`${h} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function eo(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let a=0;a<e.value;a++){let u=re(t,r);if(u===Ve){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed map`)}if(u===pe)throw new Error(`${h} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(n!==!0&&typeof u!="string")throw new Error(`${h} non-string keys not supported (got ${typeof u})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(u)||!n&&u in o))throw new Error(`${h} found repeat map key "${u}"`);let c=re(t,r);if(c===pe)throw new Error(`${h} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?i.set(u,c):o[u]=c}return n?i:o}function re(e,t){if(e.done())return pe;let r=e.next();if(r.type===s.break)return Ve;if(r.type.terminal)return r.value;if(r.type===s.array)return jn(r,e,t);if(r.type===s.map)return eo(r,e,t);if(r.type===s.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=re(e,t);return t.tags[r.value](n)}throw new Error(`${h} tag not supported (${r.value})`)}throw new Error("unsupported")}function zr(e,t){if(!(e instanceof Uint8Array))throw new Error(`${h} data to decode must be a Uint8Array`);t=Object.assign({},Zn,t);let r=t.tokenizer||new Le(e,t),n=re(r,t);if(n===pe)throw new Error(`${h} did not find any content to decode`);if(n===Ve)throw new Error(`${h} got unexpected break`);return[n,e.subarray(r.pos())]}function ot(e,t){let[r,n]=zr(e,t);if(n.length>0)throw new Error(`${h} too many terminals, data makes no sense`);return r}var ls=new Uint8Array(0);function Mr(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function ne(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function ro(e,t){if(e.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<e.length;o++){var i=e.charAt(o),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var u=e.length,c=e.charAt(0),p=Math.log(u)/Math.log(256),l=Math.log(256)/Math.log(u);function m(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var _=0,X=0,N=0,z=w.length;N!==z&&w[N]===0;)N++,_++;for(var M=(z-N)*l+1>>>0,C=new Uint8Array(M);N!==z;){for(var $=w[N],q=0,O=M-1;($!==0||q<X)&&O!==-1;O--,q++)$+=256*C[O]>>>0,C[O]=$%u>>>0,$=$/u>>>0;if($!==0)throw new Error("Non-zero carry");X=q,N++}for(var P=M-X;P!==M&&C[P]===0;)P++;for(var Ie=c.repeat(_);P<M;++P)Ie+=e.charAt(C[P]);return Ie}function v(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var _=0;if(w[_]!==" "){for(var X=0,N=0;w[_]===c;)X++,_++;for(var z=(w.length-_)*p+1>>>0,M=new Uint8Array(z);w[_];){var C=r[w.charCodeAt(_)];if(C===255)return;for(var $=0,q=z-1;(C!==0||$<N)&&q!==-1;q--,$++)C+=u*M[q]>>>0,M[q]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");N=$,_++}if(w[_]!==" "){for(var O=z-N;O!==z&&M[O]===0;)O++;for(var P=new Uint8Array(X+(z-O)),Ie=X;O!==z;)P[Ie++]=M[O++];return P}}}function Y(w){var _=v(w);if(_)return _;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:v,decode:Y}}var no=ro,oo=no,$r=oo;var it=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},st=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Lr(this,t)}},at=class{decoders;constructor(t){this.decoders=t}or(t){return Lr(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Lr(e,t){return new at({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ct=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new it(t,r,n),this.decoder=new st(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Vr({name:e,prefix:t,encode:r,decode:n}){return new ct(e,t,r,n)}function oe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=$r(r,e);return Vr({prefix:t,name:e,encode:n,decode:i=>ne(o(i))})}function io(e,t,r,n){let o={};for(let l=0;l<t.length;++l)o[t[l]]=l;let i=e.length;for(;e[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),u=0,c=0,p=0;for(let l=0;l<i;++l){let m=o[e[l]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|m,u+=r,u>=8&&(u-=8,a[p++]=255&c>>u)}if(u>=r||255&c<<8-u)throw new SyntaxError("Unexpected end of data");return a}function so(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",a=0,u=0;for(let c=0;c<e.length;++c)for(u=u<<8|e[c],a+=8;a>r;)a-=r,i+=t[o&u>>a];if(a!==0&&(i+=t[o&u<<r-a]),n)for(;i.length*r&7;)i+="=";return i}function V({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Vr({prefix:t,name:e,encode(o){return so(o,n,r)},decode(o){return io(o,n,r,e)}})}var ye=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xs=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bs=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vs=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Es=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_s=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ks=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ts=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),As=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pe=oe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ss=oe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var H=oe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ns=oe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ao=Hr,Pr=128,co=127,uo=~co,fo=Math.pow(2,31);function Hr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=fo;)t[r++]=e&255|Pr,e/=128;for(;e&uo;)t[r++]=e&255|Pr,e>>>=7;return t[r]=e|0,Hr.bytes=r-n+1,t}var lo=ut,ho=128,Fr=127;function ut(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u)throw ut.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&Fr)<<o:(a&Fr)*Math.pow(2,o),o+=7}while(a>=ho);return ut.bytes=i-n,r}var po=Math.pow(2,7),yo=Math.pow(2,14),mo=Math.pow(2,21),wo=Math.pow(2,28),go=Math.pow(2,35),xo=Math.pow(2,42),bo=Math.pow(2,49),vo=Math.pow(2,56),Eo=Math.pow(2,63),_o=function(e){return e<po?1:e<yo?2:e<mo?3:e<wo?4:e<go?5:e<xo?6:e<bo?7:e<vo?8:e<Eo?9:10},ko={encode:ao,decode:lo,encodingLength:_o},To=ko,me=To;function we(e,t=0){return[me.decode(e,t),me.decode.bytes]}function ie(e,t,r=0){return me.encode(e,t,r),t}function se(e){return me.encodingLength(e)}function Gr(e,t){let r=t.byteLength,n=se(e),o=n+se(r),i=new Uint8Array(o+r);return ie(e,i,0),ie(r,i,n),i.set(t,o),new ae(e,r,t,i)}function Fe(e){let t=ne(e),[r,n]=we(t),[o,i]=we(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new ae(r,o,a,t)}function Wr(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Mr(e.bytes,r.bytes)}}var ae=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Kr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Io(r,dt(e),t??H.encoder);default:return Co(r,dt(e),t??ye.encoder)}}var Yr=new WeakMap;function dt(e){let t=Yr.get(e);if(t==null){let r=new Map;return Yr.set(e,r),r}return t}var B=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==ge)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==So)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.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:t,digest:r}=this.multihash,n=Gr(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Wr(t.multihash,n.multihash)}toString(t){return Kr(this,t)}toJSON(){return{"/":Kr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:a}=r;return new e(n,o,i,a??Xr(n,o,i.bytes))}else if(r[Uo]===!0){let{version:n,multihash:o,code:i}=r,a=Fe(o);return e.create(n,i,a)}else return null}static create(t,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(t){case 0:{if(r!==ge)throw new Error(`Version 0 CID must use dag-pb (code: ${ge}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Xr(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ge,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=ne(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new ae(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(a):e.createV1(r.codec,a),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[m,v]=we(t.subarray(r));return r+=v,m},o=n(),i=ge;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),c=n(),p=r+c,l=p-a;return{version:o,codec:i,multihashCode:u,digestSize:c,multihashSize:l,size:p}}static parse(t,r){let[n,o]=Ao(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return dt(i).set(n,t),i}};function Ao(e,t){switch(e[0]){case"Q":{let r=t??H;return[H.prefix,r.decode(`${H.prefix}${e}`)]}case H.prefix:{let r=t??H;return[H.prefix,r.decode(e)]}case ye.prefix:{let r=t??ye;return[ye.prefix,r.decode(e)]}case Pe.prefix:{let r=t??Pe;return[Pe.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Io(e,t,r){let{prefix:n}=r;if(n!==H.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Co(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var ge=112,So=18;function Xr(e,t,r){let n=se(e),o=n+se(t),i=new Uint8Array(o+r.byteLength);return ie(e,i,0),ie(t,i,n),i.set(r,o),i}var Uo=Symbol.for("@ipld/js-cid/CID");var Jr=42;function Bo(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function No(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=B.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new d(s.tag,Jr),new d(s.bytes,r)]}function Oo(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Do(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var lt={float64:!0,typeEncoders:{Object:No,undefined:Oo,number:Do}},qs={...lt,typeEncoders:{...lt.typeEncoders}};function Ro(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return B.decode(e.subarray(1))}var He={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};He.tags[Jr]=Ro;var Gs={...He,tags:He.tags.slice()};var ht=e=>nt(e,lt),pt=e=>ot(Bo(e),He);var wt=Se(qe(),1);var gt=40;function xt(e,t){if(!e.length)throw new Error("Unexpected end of data");let r=wt.default.decode(e);return t.seek(wt.default.decode.bytes),r}function bt(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),r=0;return{version:2,characteristics:[t.getBigUint64(r,!0),t.getBigUint64(r+=8,!0)],dataOffset:Number(t.getBigUint64(r+=8,!0)),dataSize:Number(t.getBigUint64(r+=8,!0)),indexOffset:Number(t.getBigUint64(r+=8,!0))}}var K={Null:e=>e===null?e:void 0,Int:e=>Number.isInteger(e)?e:void 0,Float:e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,String:e=>typeof e=="string"?e:void 0,Bool:e=>typeof e=="boolean"?e:void 0,Bytes:e=>e instanceof Uint8Array?e:void 0,Link:e=>e!==null&&typeof e=="object"&&e.asCID===e?e:void 0,List:e=>Array.isArray(e)?e:void 0,Map:e=>e!==null&&typeof e=="object"&&e.asCID!==e&&!Array.isArray(e)&&!(e instanceof Uint8Array)?e:void 0},xe={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":K.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(K.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=xe["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let o=t;o<e.length;o++){let i=e[o];if(i=xe["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:K.Int,CarV1HeaderOrV2Pragma:e=>{if(K.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let o=0;o<t.length;o++){let[i,a]=t[o];switch(i){case"roots":{let u=xe["CarV1HeaderOrV2Pragma > roots (anon)"](e[i]);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.roots=u}}break;case"version":{n--;let u=xe.Int(e[i]);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.version=u}}break;default:return}}if(!(n>0))return r}},be={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":K.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(K.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=be["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let o=t;o<e.length;o++){let i=e[o];if(i=be["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:K.Int,CarV1HeaderOrV2Pragma:e=>{if(K.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let o=0;o<t.length;o++){let[i,a]=t[o];switch(i){case"roots":{let u=be["CarV1HeaderOrV2Pragma > roots (anon)"](a);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.roots=u}}break;case"version":{n--;let u=be.Int(a);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.version=u}}break;default:return}}if(!(n>0))return r}},vt={toTyped:xe.CarV1HeaderOrV2Pragma,toRepresentation:be.CarV1HeaderOrV2Pragma};var sa=rt();var jo=Se(qe(),1);var da=[new d(s.map,2),new d(s.string,"version"),new d(s.uint,1),new d(s.string,"roots")],la=new d(s.tag,42);async function Et(e,t){let r=xt(await e.upTo(8),e);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await e.exactly(r,!0),o=pt(n);if(vt.toTyped(o)===void 0)throw new Error("Invalid CAR header format");if(o.version!==1&&o.version!==2||t!==void 0&&o.version!==t)throw new Error(`Invalid CAR version: ${o.version}${t!==void 0?` (expected ${t})`:""}`);if(o.version===1){if(!Array.isArray(o.roots))throw new Error("Invalid CAR header format");return o}if(o.roots!==void 0)throw new Error("Invalid CAR header format");let i=bt(await e.exactly(gt,!0));e.seek(i.dataOffset-e.pos);let a=await Et(e,1);return Object.assign(a,i)}function ve(e){let t=0;return{async upTo(r){return e.subarray(t,t+Math.min(r,e.length-t))},async exactly(r,n=!1){if(r>e.length-t)throw new Error("Unexpected end of data");let o=e.subarray(t,t+r);return n&&(t+=r),o},seek(r){t+=r},get pos(){return t}}}var _t=Se(qe(),1),un=1;function kt(e){let t=ht({version:un,roots:e}),r=_t.default.encode(t.length),n=new Uint8Array(r.length+t.length);return n.set(r,0),n.set(t,r.length),n}function fn(e){return{async setRoots(t){let r=kt(t);await e.write(r)},async writeBlock(t){let{cid:r,bytes:n}=t;await e.write(new Uint8Array(_t.default.encode(r.bytes.length+n.length))),await e.write(r.bytes),n.length&&await e.write(n)},async close(){await e.end()},version(){return un}}}function Ge(){}function dn(){let e=[],t=null,r=Ge,n=!1,o=null,i=Ge,a=()=>(t||(t=new Promise(p=>{r=()=>{t=null,r=Ge,p()}})),t),u={write(p){e.push(p);let l=a();return i(),l},async end(){n=!0;let p=a();i(),await p}},c={async next(){let p=e.shift();return p?(e.length===0&&r(),{done:!1,value:p}):n?(r(),{done:!0,value:void 0}):(o||(o=new Promise(l=>{i=()=>(o=null,i=Ge,l(c.next()))})),o)}};return{writer:u,iterator:c}}var Ee=class e{constructor(t,r){this._encoder=r,this._mutex=r.setRoots(t),this._ended=!1}async put(t){if(!(t.bytes instanceof Uint8Array)||!t.cid)throw new TypeError("Can only write {cid, bytes} objects");if(this._ended)throw new Error("Already closed");let r=B.asCID(t.cid);if(!r)throw new TypeError("Can only write {cid, bytes} objects");return this._mutex=this._mutex.then(()=>this._encoder.writeBlock({cid:r,bytes:t.bytes})),this._mutex}async close(){if(this._ended)throw new Error("Already closed");return await this._mutex,this._ended=!0,this._encoder.close()}version(){return this._encoder.version()}static create(t){t=ni(t);let{encoder:r,iterator:n}=ln(),o=new e(t,r),i=new We(n);return{writer:o,out:i}}static createAppender(){let{encoder:t,iterator:r}=ln();t.setRoots=()=>Promise.resolve();let n=new e([],t),o=new We(r);return{writer:n,out:o}}static async updateRootsInBytes(t,r){let n=ve(t);await Et(n);let o=kt(r);if(Number(n.pos)!==o.length)throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${n.pos} bytes, new header is ${o.length} bytes)`);return t.set(o,0),t}},We=class{constructor(t){this._iterator=t}[Symbol.asyncIterator](){if(this._iterating)throw new Error("Multiple iterator not supported");return this._iterating=!0,this._iterator}};function ln(){let e=dn(),{writer:t,iterator:r}=e;return{encoder:fn(t),iterator:r}}function ni(e){if(e===void 0)return[];if(!Array.isArray(e)){let r=B.asCID(e);if(!r)throw new TypeError("roots must be a single CID or an array of CIDs");return[r]}let t=[];for(let r of e){let n=B.asCID(r);if(!n)throw new TypeError("roots must be a single CID or an array of CIDs");t.push(n)}return t}function oi(e){return e[Symbol.asyncIterator]!=null}function ii(e){if(oi(e))return(async()=>{for await(let t of e);})();for(let t of e);}var hn=ii;function si(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}var pn=si;function ai(e){return e[Symbol.asyncIterator]!=null}function ci(e,t){let r=0;if(ai(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=pn(e),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let a=t(o,r++);if(typeof a.then=="function")return async function*(){yield await a;for await(let c of n)yield t(c,r++)}();let u=t;return function*(){yield a;for(let c of n)yield u(c,r++)}()}var yn=ci;function Tt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var It=Se(wn(),1);var ke=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Ct=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},gn=e=>globalThis.DOMException===void 0?new Ct(e):new DOMException(e),xn=e=>{let t=e.reason===void 0?gn("This operation was aborted."):e.reason;return t instanceof Error?t:gn(t)};function St(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,a,c=new Promise((p,l)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:v}=t;v.aborted&&l(xn(v)),v.addEventListener("abort",()=>{l(xn(v))})}if(r===Number.POSITIVE_INFINITY){e.then(p,l);return}let m=new ke;a=i.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(v){l(v)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?p():o instanceof Error?l(o):(m.message=o??`Promise timed out after ${r} milliseconds`,l(m))},r),(async()=>{try{p(await e)}catch(v){l(v)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},c}function Ut(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),a=n+i;r(e[a],t)<=0?(n=++a,o-=i+1):o=i}return n}var Te=class{#e=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,run:t};if(this.size&&this.#e[this.size-1].priority>=r.priority){this.#e.push(n);return}let o=Ut(this.#e,n,(i,a)=>a.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(t){return this.#e.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#e.length}};var Ae=class extends It.default{#e;#s;#i=0;#h;#a;#p=0;#r;#c;#t;#y;#n=0;#u;#o;#m;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Te,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#e=t.carryoverConcurrencyCount,this.#s=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#h=t.intervalCap,this.#a=t.interval,this.#t=new t.queueClass,this.#y=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#m=t.throwOnTimeout===!0,this.#o=t.autoStart===!1}get#x(){return this.#s||this.#i<this.#h}get#b(){return this.#n<this.#u}#v(){this.#n--,this.#f(),this.emit("next")}#E(){this.#g(),this.#w(),this.#c=void 0}get#_(){let t=Date.now();if(this.#r===void 0){let r=this.#p-t;if(r<0)this.#i=this.#e?this.#n:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#E()},r)),!0}return!1}#f(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#o){let t=!this.#_;if(this.#x&&this.#b){let r=this.#t.dequeue();return r?(this.emit("active"),r(),t&&this.#w(),!0):!1}}return!1}#w(){this.#s||this.#r!==void 0||(this.#r=setInterval(()=>{this.#g()},this.#a),this.#p=Date.now()+this.#a)}#g(){this.#i===0&&this.#n===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#i=this.#e?this.#n:0,this.#d()}#d(){for(;this.#f(););}get concurrency(){return this.#u}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#u=t,this.#d()}async#k(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}async add(t,r={}){return r={timeout:this.timeout,throwOnTimeout:this.#m,...r},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#n++,this.#i++;try{r.signal?.throwIfAborted();let i=t({signal:r.signal});r.timeout&&(i=St(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#k(r.signal)]));let a=await i;n(a),this.emit("completed",a)}catch(i){if(i instanceof ke&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#v()}},r),this.emit("add"),this.#f()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#o?(this.#o=!1,this.#d(),this):this}pause(){this.#o=!0}clear(){this.#t=new this.#y}async onEmpty(){this.#t.size!==0&&await this.#l("empty")}async onSizeLessThan(t){this.#t.size<t||await this.#l("next",()=>this.#t.size<t)}async onIdle(){this.#n===0&&this.#t.size===0||await this.#l("idle")}async#l(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#t.size}sizeBy(t){return this.#t.filter(t).length}get pending(){return this.#n}get isPaused(){return this.#o}};var di=1,Bt=class{components;constructor(t,r){this.components=t}async import(t,r){await hn(this.components.blockstore.putMany(yn(t.blocks(),({cid:n,bytes:o})=>({cid:n,block:o})),r))}async export(t,r,n){let o=Tt(),i=Array.isArray(t)?t:[t],a=new Ae({concurrency:di});a.on("idle",()=>{o.resolve()}),a.on("error",u=>{a.clear(),o.reject(u)});for(let u of i)a.add(async()=>{await this.#e(u,a,async(c,p)=>{n?.blockFilter?.has(c.multihash.bytes)!==!0&&(n?.blockFilter?.add(c.multihash.bytes),await r.put({cid:c,bytes:p}))},n)}).catch(()=>{});try{await o.promise}finally{await r.close()}}async*stream(t,r){let{writer:n,out:o}=Ee.create(t);this.export(t,n,r).catch(()=>{});for await(let i of o)yield i}async#e(t,r,n,o){let i=this.components.dagWalkers[t.code];if(i==null)throw new Error(`No dag walker found for cid codec ${t.code}`);let a=await this.components.blockstore.get(t,o);await n(t,a);for await(let u of i.walk(a))r.add(async()=>{await this.#e(u,r,n,o)})}};function li(e,t={}){return new Bt(e,t)}return An(hi);})();
|
|
3
3
|
return HeliaCar}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/car",
|
|
3
|
-
"version": "3.2.1-
|
|
3
|
+
"version": "3.2.1-8805202",
|
|
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/tree/main/packages/car#readme",
|
|
@@ -139,10 +139,10 @@
|
|
|
139
139
|
"release": "aegir release"
|
|
140
140
|
},
|
|
141
141
|
"dependencies": {
|
|
142
|
-
"@helia/interface": "4.3.1-
|
|
142
|
+
"@helia/interface": "4.3.1-8805202",
|
|
143
143
|
"@ipld/car": "^5.3.0",
|
|
144
|
-
"@libp2p/interface": "^
|
|
145
|
-
"@libp2p/utils": "^
|
|
144
|
+
"@libp2p/interface": "^2.0.0",
|
|
145
|
+
"@libp2p/utils": "^6.0.0",
|
|
146
146
|
"interface-blockstore": "^5.2.10",
|
|
147
147
|
"it-drain": "^3.0.5",
|
|
148
148
|
"it-map": "^3.0.5",
|
|
@@ -152,12 +152,12 @@
|
|
|
152
152
|
"progress-events": "^1.0.0"
|
|
153
153
|
},
|
|
154
154
|
"devDependencies": {
|
|
155
|
-
"@helia/mfs": "3.0.8-
|
|
156
|
-
"@helia/unixfs": "3.0.7-
|
|
155
|
+
"@helia/mfs": "3.0.8-8805202",
|
|
156
|
+
"@helia/unixfs": "3.0.7-8805202",
|
|
157
157
|
"@ipld/dag-pb": "^4.1.0",
|
|
158
158
|
"aegir": "^44.0.1",
|
|
159
|
-
"blockstore-core": "^
|
|
160
|
-
"datastore-core": "^
|
|
159
|
+
"blockstore-core": "^5.0.0",
|
|
160
|
+
"datastore-core": "^10.0.0",
|
|
161
161
|
"ipfs-unixfs-importer": "^15.2.4",
|
|
162
162
|
"it-to-buffer": "^4.0.5"
|
|
163
163
|
},
|