@helia/car 3.1.5 → 3.2.0
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/README.md +1 -1
- package/dist/index.min.js +1 -1
- package/dist/src/index.d.ts +9 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -1
- package/package.json +7 -4
- package/src/index.ts +17 -3
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ $ npm i @helia/car
|
|
|
94
94
|
|
|
95
95
|
## Browser `<script>` tag
|
|
96
96
|
|
|
97
|
-
Loading this module through a script tag will make
|
|
97
|
+
Loading this module through a script tag will make its exports available as `HeliaCar` in the global namespace.
|
|
98
98
|
|
|
99
99
|
```html
|
|
100
100
|
<script src="https://unpkg.com/@helia/car/dist/index.min.js"></script>
|
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaCar = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var HeliaCar=(()=>{var xn=Object.create;var Ie=Object.defineProperty;var bn=Object.getOwnPropertyDescriptor;var vn=Object.getOwnPropertyNames;var En=Object.getPrototypeOf,_n=Object.prototype.hasOwnProperty;var ae=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Tn=(e,t)=>{for(var r in t)Ie(e,r,{get:t[r],enumerable:!0})},Bt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of vn(t))!_n.call(e,o)&&o!==r&&Ie(e,o,{get:()=>t[o],enumerable:!(n=bn(t,o))||n.enumerable});return e};var Ce=(e,t,r)=>(r=e!=null?xn(En(e)):{},Bt(t||!e||!e.__esModule?Ie(r,"default",{value:e,enumerable:!0}):r,e)),kn=e=>Bt(Ie({},"__esModule",{value:!0}),e);var Zr=ae((Ps,Xr)=>{Xr.exports=pt;var Qr=128,zo=127,$o=~zo,Mo=Math.pow(2,31);function pt(e,t,r){if(Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw pt.bytes=0,new RangeError("Could not encode varint");t=t||[],r=r||0;for(var n=r;e>=Mo;)t[r++]=e&255|Qr,e/=128;for(;e&$o;)t[r++]=e&255|Qr,e>>>=7;return t[r]=e|0,pt.bytes=r-n+1,t}});var tn=ae((Fs,en)=>{en.exports=yt;var Lo=128,jr=127;function yt(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u||o>49)throw yt.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&jr)<<o:(a&jr)*Math.pow(2,o),o+=7}while(a>=Lo);return yt.bytes=i-n,r}});var nn=ae((Hs,rn)=>{var Vo=Math.pow(2,7),Po=Math.pow(2,14),Fo=Math.pow(2,21),Ho=Math.pow(2,28),qo=Math.pow(2,35),Go=Math.pow(2,42),Wo=Math.pow(2,49),Yo=Math.pow(2,56),Ko=Math.pow(2,63);rn.exports=function(e){return e<Vo?1:e<Po?2:e<Fo?3:e<Ho?4:e<qo?5:e<Go?6:e<Wo?7:e<Yo?8:e<Ko?9:10}});var Fe=ae((qs,on)=>{on.exports={encode:Zr(),decode:tn(),encodingLength:nn()}});var mn=ae((Ya,kt)=>{"use strict";var ci=Object.prototype.hasOwnProperty,E="~";function Ee(){}Object.create&&(Ee.prototype=Object.create(null),new Ee().__proto__||(E=!1));function ui(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function yn(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new ui(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 Ge(e,t){--e._eventsCount===0?e._events=new Ee:delete e._events[t]}function b(){this._events=new Ee,this._eventsCount=0}b.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)ci.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,K;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(K=1,l=new Array(p-1);K<p;K++)l[K-1]=arguments[K];c[m].fn.apply(c[m].context,l)}}return!0};b.prototype.on=function(t,r,n){return yn(this,t,r,n,!1)};b.prototype.once=function(t,r,n){return yn(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 Ge(this,i),this;var a=this._events[i];if(a.fn)a.fn===r&&(!o||a.once)&&(!n||a.context===n)&&Ge(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:Ge(this,i)}return this};b.prototype.removeAllListeners=function(t){var r;return t?(r=E?E+t:t,this._events[r]&&Ge(this,r)):(this._events=new Ee,this._eventsCount=0),this};b.prototype.off=b.prototype.removeListener;b.prototype.addListener=b.prototype.on;b.prefixed=E;b.EventEmitter=b;typeof kt<"u"&&(kt.exports=b)});var li={};Tn(li,{car:()=>di});var An=["string","number","bigint","symbol"],In=["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 Nt(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(An.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Cn(e))return"Buffer";let r=Sn(e);return r||"Object"}function Cn(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Sn(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(In.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 X=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Un=new TextDecoder,Bn=new TextEncoder;function Se(e){return X&&globalThis.Buffer.isBuffer(e)}function We(e){return e instanceof Uint8Array?Se(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var zt=X?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Dt(e,t,r):(e,t,r)=>r-t>64?Un.decode(e.subarray(t,r)):Dt(e,t,r),$t=X?e=>e.length>64?globalThis.Buffer.from(e):Ot(e):e=>e.length>64?Bn.encode(e):Ot(e),L=e=>Uint8Array.from(e),Z=X?(e,t,r)=>Se(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Mt=X?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),We(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},Lt=X?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Vt(e,t){if(Se(e)&&Se(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 Ot(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 Dt(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 Nn(n)}var Rt=4096;function Nn(e){let t=e.length;if(t<=Rt)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Rt));return r}var On=256,ce=class{constructor(t=On){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=Lt(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=Mt(this.chunks,this.cursor);return t&&this.reset(),r}};var h="CBOR decode error:",Ye="CBOR encode error:",ue=[];ue[23]=1;ue[24]=2;ue[25]=3;ue[26]=5;ue[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 T(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 k(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 Pt(e,t,r,n){return new d(s.uint,T(e,t+1,n),2)}function Ft(e,t,r,n){return new d(s.uint,k(e,t+1,n),3)}function Ht(e,t,r,n){return new d(s.uint,A(e,t+1,n),5)}function qt(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 Gt(e,t,r,n){return new d(s.negint,-1-T(e,t+1,n),2)}function Wt(e,t,r,n){return new d(s.negint,-1-k(e,t+1,n),3)}function Yt(e,t,r,n){return new d(s.negint,-1-A(e,t+1,n),5)}var Ke=BigInt(-1),Kt=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,Ke-BigInt(o),9)}function Ue(e,t){let r=t.value,n=typeof r=="bigint"?r*Ke-Kt:r*-1-1;x(e,t.type.majorEncoded,n)}Ue.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ke-Kt:r*-1-1;return n<g[0]?1:n<g[1]?2:n<g[2]?3:n<g[3]?5:9};Ue.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function fe(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 fe(e,t,1,r)}function Xt(e,t,r,n){return fe(e,t,2,T(e,t+1,n))}function Zt(e,t,r,n){return fe(e,t,3,k(e,t+1,n))}function jt(e,t,r,n){return fe(e,t,5,A(e,t+1,n))}function er(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 fe(e,t,9,o)}function Be(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=Be(t);x(e,t.type.majorEncoded,r.length),e.push(r)}j.encodedSize=function(t){let r=Be(t);return x.encodedSize(r.length)+r.length};j.compareTokens=function(t,r){return Rn(Be(t),Be(r))};function Rn(e,t){return e.length<t.length?-1:e.length>t.length?1:Vt(e,t)}function de(e,t,r,n,o){let i=r+n;F(e,t,i);let a=new d(s.string,zt(e,t+r,t+i),i);return o.retainStringBytes===!0&&(a.byteValue=Z(e,t+r,t+i)),a}function tr(e,t,r,n){return de(e,t,1,r,n)}function rr(e,t,r,n){return de(e,t,2,T(e,t+1,n),n)}function nr(e,t,r,n){return de(e,t,3,k(e,t+1,n),n)}function or(e,t,r,n){return de(e,t,5,A(e,t+1,n),n)}function ir(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 de(e,t,9,o,n)}var sr=j;function ee(e,t,r,n){return new d(s.array,n,r)}function ar(e,t,r,n){return ee(e,t,1,r)}function cr(e,t,r,n){return ee(e,t,2,T(e,t+1,n))}function ur(e,t,r,n){return ee(e,t,3,k(e,t+1,n))}function fr(e,t,r,n){return ee(e,t,5,A(e,t+1,n))}function dr(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 lr(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 Ne(e,t){x(e,s.array.majorEncoded,t.value)}Ne.compareTokens=S.compareTokens;Ne.encodedSize=function(t){return x.encodedSize(t.value)};function te(e,t,r,n){return new d(s.map,n,r)}function hr(e,t,r,n){return te(e,t,1,r)}function pr(e,t,r,n){return te(e,t,2,T(e,t+1,n))}function yr(e,t,r,n){return te(e,t,3,k(e,t+1,n))}function mr(e,t,r,n){return te(e,t,5,A(e,t+1,n))}function wr(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 gr(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 Oe(e,t){x(e,s.map.majorEncoded,t.value)}Oe.compareTokens=S.compareTokens;Oe.encodedSize=function(t){return x.encodedSize(t.value)};function xr(e,t,r,n){return new d(s.tag,r,1)}function br(e,t,r,n){return new d(s.tag,T(e,t+1,n),2)}function vr(e,t,r,n){return new d(s.tag,k(e,t+1,n),3)}function Er(e,t,r,n){return new d(s.tag,A(e,t+1,n),5)}function _r(e,t,r,n){return new d(s.tag,I(e,t+1,n),9)}function De(e,t){x(e,s.tag.majorEncoded,t.value)}De.compareTokens=S.compareTokens;De.encodedSize=function(t){return x.encodedSize(t.value)};var Pn=20,Fn=21,Hn=22,qn=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 kr(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 Je(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 Ar(e,t,r,n){return Je(Qe(e,t+1),3,n)}function Ir(e,t,r,n){return Je(Xe(e,t+1),5,n)}function Cr(e,t,r,n){return Je(Nr(e,t+1),9,n)}function Re(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|Pn]);else if(n===!0)e.push([s.float.majorEncoded|Fn]);else if(n===null)e.push([s.float.majorEncoded|Hn]);else if(n===void 0)e.push([s.float.majorEncoded|qn]);else{let o,i=!1;(!r||r.float64!==!0)&&(Ur(n),o=Qe(D,1),n===o||Number.isNaN(n)?(D[0]=249,e.push(D.slice(0,3)),i=!0):(Br(n),o=Xe(D,1),n===o&&(D[0]=250,e.push(D.slice(0,5)),i=!0))),i||(Gn(n),o=Nr(D,1),D[0]=251,e.push(D.slice(0,9)))}}Re.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){Ur(n);let o=Qe(D,1);if(n===o||Number.isNaN(n))return 3;if(Br(n),o=Xe(D,1),n===o)return 5}return 9};var Sr=new ArrayBuffer(9),U=new DataView(Sr,1),D=new Uint8Array(Sr,0);function Ur(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 Qe(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 Br(e){U.setFloat32(0,e,!1)}function Xe(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 Gn(e){U.setFloat64(0,e,!1)}function Nr(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)}Re.compareTokens=S.compareTokens;function y(e,t,r){throw new Error(`${h} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function ze(e){return()=>{throw new Error(`${h} ${e}`)}}var f=[];for(let e=0;e<=23;e++)f[e]=y;f[24]=Pt;f[25]=Ft;f[26]=Ht;f[27]=qt;f[28]=y;f[29]=y;f[30]=y;f[31]=y;for(let e=32;e<=55;e++)f[e]=y;f[56]=Gt;f[57]=Wt;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]=Xt;f[89]=Zt;f[90]=jt;f[91]=er;f[92]=y;f[93]=y;f[94]=y;f[95]=ze("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)f[e]=tr;f[120]=rr;f[121]=nr;f[122]=or;f[123]=ir;f[124]=y;f[125]=y;f[126]=y;f[127]=ze("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)f[e]=ar;f[152]=cr;f[153]=ur;f[154]=fr;f[155]=dr;f[156]=y;f[157]=y;f[158]=y;f[159]=lr;for(let e=160;e<=183;e++)f[e]=hr;f[184]=pr;f[185]=yr;f[186]=mr;f[187]=wr;f[188]=y;f[189]=y;f[190]=y;f[191]=gr;for(let e=192;e<=215;e++)f[e]=xr;f[216]=br;f[217]=vr;f[218]=Er;f[219]=_r;f[220]=y;f[221]=y;f[222]=y;f[223]=y;for(let e=224;e<=243;e++)f[e]=ze("simple values are not supported");f[244]=y;f[245]=y;f[246]=y;f[247]=Tr;f[248]=ze("simple values are not supported");f[249]=Ar;f[250]=Ir;f[251]=Cr;f[252]=y;f[253]=y;f[254]=y;f[255]=kr;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 Ze(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:Ze};function et(){let e=[];return e[s.uint.major]=S,e[s.negint.major]=Ue,e[s.bytes.major]=j,e[s.string.major]=sr,e[s.array.major]=Ne,e[s.map.major]=Oe,e[s.tag.major]=De,e[s.float.major]=Re,e}var Or=et(),je=new ce,$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(`${Ye} 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++]=le(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++]=[le(p,r,n),le(o?e.get(p):e[p],r,n)];return Kn(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 le(e,t={},r){let n=Nt(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(`${Ye} unsupported type: ${n}`);return i(e,n,t,r)}function Kn(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=Or[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Dr(e,t,r,n){if(Array.isArray(t))for(let o of t)Dr(e,o,r,n);else r[t.type.major](e,t,n)}function Qn(e,t,r){let n=le(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 ce(a);if(i(u,n,r),u.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return We(u.chunks[0])}}return je.reset(),Dr(je,n,t,r),je.toBytes(!0)}function tt(e,t){return t=Object.assign({},Yn,t),Qn(e,Or,t)}var Xn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Me=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}},he=Symbol.for("DONE"),Le=Symbol.for("BREAK");function Zn(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=re(t,r);if(i===Le){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed array`)}if(i===he)throw new Error(`${h} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function jn(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===Le){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed map`)}if(u===he)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===he)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 he;let r=e.next();if(r.type===s.break)return Le;if(r.type.terminal)return r.value;if(r.type===s.array)return Zn(r,e,t);if(r.type===s.map)return jn(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 Rr(e,t){if(!(e instanceof Uint8Array))throw new Error(`${h} data to decode must be a Uint8Array`);t=Object.assign({},Xn,t);let r=t.tokenizer||new Me(e,t),n=re(r,t);if(n===he)throw new Error(`${h} did not find any content to decode`);if(n===Le)throw new Error(`${h} got unexpected break`);return[n,e.subarray(r.pos())]}function rt(e,t){let[r,n]=Rr(e,t);if(n.length>0)throw new Error(`${h} too many terminals, data makes no sense`);return r}var ds=new Uint8Array(0);function zr(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 to(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,J=0,N=0,z=w.length;N!==z&&w[N]===0;)N++,_++;for(var $=(z-N)*l+1>>>0,C=new Uint8Array($);N!==z;){for(var M=w[N],q=0,O=$-1;(M!==0||q<J)&&O!==-1;O--,q++)M+=256*C[O]>>>0,C[O]=M%u>>>0,M=M/u>>>0;if(M!==0)throw new Error("Non-zero carry");J=q,N++}for(var P=$-J;P!==$&&C[P]===0;)P++;for(var Ae=c.repeat(_);P<$;++P)Ae+=e.charAt(C[P]);return Ae}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 J=0,N=0;w[_]===c;)J++,_++;for(var z=(w.length-_)*p+1>>>0,$=new Uint8Array(z);w[_];){var C=r[w.charCodeAt(_)];if(C===255)return;for(var M=0,q=z-1;(C!==0||M<N)&&q!==-1;q--,M++)C+=u*$[q]>>>0,$[q]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");N=M,_++}if(w[_]!==" "){for(var O=z-N;O!==z&&$[O]===0;)O++;for(var P=new Uint8Array(J+(z-O)),Ae=J;O!==z;)P[Ae++]=$[O++];return P}}}function K(w){var _=v(w);if(_)return _;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:v,decode:K}}var ro=to,no=ro,$r=no;var nt=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")}},ot=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 Mr(this,t)}},it=class{decoders;constructor(t){this.decoders=t}or(t){return Mr(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 Mr(e,t){return new it({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var st=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 nt(t,r,n),this.decoder=new ot(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Lr({name:e,prefix:t,encode:r,decode:n}){return new st(e,t,r,n)}function at({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=$r(r,e);return Lr({prefix:t,name:e,encode:n,decode:i=>ne(o(i))})}function oo(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 io(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 Lr({prefix:t,name:e,encode(o){return io(o,n,r)},decode(o){return oo(o,n,r,e)}})}var pe=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gs=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xs=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bs=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vs=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Es=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),_s=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ts=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ks=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var H=at({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Cs=at({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var so=Fr,Vr=128,ao=127,co=~ao,uo=Math.pow(2,31);function Fr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=uo;)t[r++]=e&255|Vr,e/=128;for(;e&co;)t[r++]=e&255|Vr,e>>>=7;return t[r]=e|0,Fr.bytes=r-n+1,t}var fo=ct,lo=128,Pr=127;function ct(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u)throw ct.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&Pr)<<o:(a&Pr)*Math.pow(2,o),o+=7}while(a>=lo);return ct.bytes=i-n,r}var ho=Math.pow(2,7),po=Math.pow(2,14),yo=Math.pow(2,21),mo=Math.pow(2,28),wo=Math.pow(2,35),go=Math.pow(2,42),xo=Math.pow(2,49),bo=Math.pow(2,56),vo=Math.pow(2,63),Eo=function(e){return e<ho?1:e<po?2:e<yo?3:e<mo?4:e<wo?5:e<go?6:e<xo?7:e<bo?8:e<vo?9:10},_o={encode:so,decode:fo,encodingLength:Eo},To=_o,ye=To;function me(e,t=0){return[ye.decode(e,t),ye.decode.bytes]}function oe(e,t,r=0){return ye.encode(e,t,r),t}function ie(e){return ye.encodingLength(e)}function qr(e,t){let r=t.byteLength,n=ie(e),o=n+ie(r),i=new Uint8Array(o+r);return oe(e,i,0),oe(r,i,n),i.set(t,o),new se(e,r,t,i)}function Ve(e){let t=ne(e),[r,n]=me(t),[o,i]=me(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new se(r,o,a,t)}function Gr(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&zr(e.bytes,r.bytes)}}var se=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Wr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Ao(r,ft(e),t??H.encoder);default:return Io(r,ft(e),t??pe.encoder)}}var Yr=new WeakMap;function ft(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!==we)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Co)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=qr(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&&Gr(t.multihash,n.multihash)}toString(t){return Wr(this,t)}toJSON(){return{"/":Wr(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??Kr(n,o,i.bytes))}else if(r[So]===!0){let{version:n,multihash:o,code:i}=r,a=Ve(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!==we)throw new Error(`Version 0 CID must use dag-pb (code: ${we}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Kr(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,we,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 se(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]=me(t.subarray(r));return r+=v,m},o=n(),i=we;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let 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]=ko(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 ft(i).set(n,t),i}};function ko(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 pe.prefix:{let r=t??pe;return[pe.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Ao(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 Io(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 we=112,Co=18;function Kr(e,t,r){let n=ie(e),o=n+ie(t),i=new Uint8Array(o+r.byteLength);return oe(e,i,0),oe(t,i,n),i.set(r,o),i}var So=Symbol.for("@ipld/js-cid/CID");var Jr=42;function Uo(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function Bo(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 No(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Oo(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 dt={float64:!0,typeEncoders:{Object:Bo,undefined:No,number:Oo}},Ls={...dt,typeEncoders:{...dt.typeEncoders}};function Do(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return B.decode(e.subarray(1))}var Pe={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Pe.tags[Jr]=Do;var Vs={...Pe,tags:Pe.tags.slice()};var lt=e=>tt(e,dt),ht=e=>rt(Uo(e),Pe);var mt=Ce(Fe(),1);var wt=40;function gt(e,t){if(!e.length)throw new Error("Unexpected end of data");let r=mt.default.decode(e);return t.seek(mt.default.decode.bytes),r}function xt(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 Y={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},ge={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":Y.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(Y.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=ge["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=ge["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:Y.Int,CarV1HeaderOrV2Pragma:e=>{if(Y.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=ge["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=ge.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}},xe={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":Y.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(Y.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:Y.Int,CarV1HeaderOrV2Pragma:e=>{if(Y.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)"](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=xe.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}},bt={toTyped:ge.CarV1HeaderOrV2Pragma,toRepresentation:xe.CarV1HeaderOrV2Pragma};var ta=et();var Zo=Ce(Fe(),1);var sa=[new d(s.map,2),new d(s.string,"version"),new d(s.uint,1),new d(s.string,"roots")],aa=new d(s.tag,42);async function vt(e,t){let r=gt(await e.upTo(8),e);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await e.exactly(r,!0),o=ht(n);if(bt.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=xt(await e.exactly(wt,!0));e.seek(i.dataOffset-e.pos);let a=await vt(e,1);return Object.assign(a,i)}function be(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 Et=Ce(Fe(),1),cn=1;function _t(e){let t=lt({version:cn,roots:e}),r=Et.default.encode(t.length),n=new Uint8Array(r.length+t.length);return n.set(r,0),n.set(t,r.length),n}function un(e){return{async setRoots(t){let r=_t(t);await e.write(r)},async writeBlock(t){let{cid:r,bytes:n}=t;await e.write(new Uint8Array(Et.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 cn}}}function He(){}function fn(){let e=[],t=null,r=He,n=!1,o=null,i=He,a=()=>(t||(t=new Promise(p=>{r=()=>{t=null,r=He,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=He,l(c.next()))})),o)}};return{writer:u,iterator:c}}var ve=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=ri(t);let{encoder:r,iterator:n}=dn(),o=new e(t,r),i=new qe(n);return{writer:o,out:i}}static createAppender(){let{encoder:t,iterator:r}=dn();t.setRoots=()=>Promise.resolve();let n=new e([],t),o=new qe(r);return{writer:n,out:o}}static async updateRootsInBytes(t,r){let n=be(t);await vt(n);let o=_t(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}},qe=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 dn(){let e=fn(),{writer:t,iterator:r}=e;return{encoder:un(t),iterator:r}}function ri(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 ni(e){return e[Symbol.asyncIterator]!=null}function oi(e){if(ni(e))return(async()=>{for await(let t of e);})();for(let t of e);}var ln=oi;function ii(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 hn=ii;function si(e){return e[Symbol.asyncIterator]!=null}function ai(e,t){let r=0;if(si(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=hn(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 pn=ai;function Tt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var At=Ce(mn(),1);var _e=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},It=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},wn=e=>globalThis.DOMException===void 0?new It(e):new DOMException(e),gn=e=>{let t=e.reason===void 0?wn("This operation was aborted."):e.reason;return t instanceof Error?t:wn(t)};function Ct(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(gn(v)),v.addEventListener("abort",()=>{l(gn(v))})}if(r===Number.POSITIVE_INFINITY){e.then(p,l);return}let m=new _e;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 St(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=St(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 ke=class extends At.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#T(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=Ct(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#T(r.signal)]));let a=await i;n(a),this.emit("completed",a)}catch(i){if(i instanceof _e&&!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 fi=1,Ut=class{components;constructor(t,r){this.components=t}async import(t,r){await ln(this.components.blockstore.putMany(pn(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 ke({concurrency:fi});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)=>{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}=ve.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 di(e,t={}){return new Ut(e,t)}return kn(li);})();
|
|
2
|
+
"use strict";var HeliaCar=(()=>{var xn=Object.create;var Ie=Object.defineProperty;var bn=Object.getOwnPropertyDescriptor;var vn=Object.getOwnPropertyNames;var En=Object.getPrototypeOf,_n=Object.prototype.hasOwnProperty;var ae=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Tn=(e,t)=>{for(var r in t)Ie(e,r,{get:t[r],enumerable:!0})},Bt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of vn(t))!_n.call(e,o)&&o!==r&&Ie(e,o,{get:()=>t[o],enumerable:!(n=bn(t,o))||n.enumerable});return e};var Ce=(e,t,r)=>(r=e!=null?xn(En(e)):{},Bt(t||!e||!e.__esModule?Ie(r,"default",{value:e,enumerable:!0}):r,e)),kn=e=>Bt(Ie({},"__esModule",{value:!0}),e);var Zr=ae((Ps,Xr)=>{Xr.exports=pt;var Qr=128,zo=127,$o=~zo,Mo=Math.pow(2,31);function pt(e,t,r){if(Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw pt.bytes=0,new RangeError("Could not encode varint");t=t||[],r=r||0;for(var n=r;e>=Mo;)t[r++]=e&255|Qr,e/=128;for(;e&$o;)t[r++]=e&255|Qr,e>>>=7;return t[r]=e|0,pt.bytes=r-n+1,t}});var tn=ae((Fs,en)=>{en.exports=yt;var Lo=128,jr=127;function yt(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u||o>49)throw yt.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&jr)<<o:(a&jr)*Math.pow(2,o),o+=7}while(a>=Lo);return yt.bytes=i-n,r}});var nn=ae((Hs,rn)=>{var Vo=Math.pow(2,7),Po=Math.pow(2,14),Fo=Math.pow(2,21),Ho=Math.pow(2,28),qo=Math.pow(2,35),Go=Math.pow(2,42),Wo=Math.pow(2,49),Yo=Math.pow(2,56),Ko=Math.pow(2,63);rn.exports=function(e){return e<Vo?1:e<Po?2:e<Fo?3:e<Ho?4:e<qo?5:e<Go?6:e<Wo?7:e<Yo?8:e<Ko?9:10}});var Fe=ae((qs,on)=>{on.exports={encode:Zr(),decode:tn(),encodingLength:nn()}});var mn=ae((Ya,kt)=>{"use strict";var ci=Object.prototype.hasOwnProperty,E="~";function Ee(){}Object.create&&(Ee.prototype=Object.create(null),new Ee().__proto__||(E=!1));function ui(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function yn(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new ui(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 Ge(e,t){--e._eventsCount===0?e._events=new Ee:delete e._events[t]}function b(){this._events=new Ee,this._eventsCount=0}b.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)ci.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,K;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(K=1,l=new Array(p-1);K<p;K++)l[K-1]=arguments[K];c[m].fn.apply(c[m].context,l)}}return!0};b.prototype.on=function(t,r,n){return yn(this,t,r,n,!1)};b.prototype.once=function(t,r,n){return yn(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 Ge(this,i),this;var a=this._events[i];if(a.fn)a.fn===r&&(!o||a.once)&&(!n||a.context===n)&&Ge(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:Ge(this,i)}return this};b.prototype.removeAllListeners=function(t){var r;return t?(r=E?E+t:t,this._events[r]&&Ge(this,r)):(this._events=new Ee,this._eventsCount=0),this};b.prototype.off=b.prototype.removeListener;b.prototype.addListener=b.prototype.on;b.prefixed=E;b.EventEmitter=b;typeof kt<"u"&&(kt.exports=b)});var li={};Tn(li,{car:()=>di});var An=["string","number","bigint","symbol"],In=["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 Nt(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(An.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Cn(e))return"Buffer";let r=Sn(e);return r||"Object"}function Cn(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Sn(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(In.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 X=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Un=new TextDecoder,Bn=new TextEncoder;function Se(e){return X&&globalThis.Buffer.isBuffer(e)}function We(e){return e instanceof Uint8Array?Se(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var zt=X?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Dt(e,t,r):(e,t,r)=>r-t>64?Un.decode(e.subarray(t,r)):Dt(e,t,r),$t=X?e=>e.length>64?globalThis.Buffer.from(e):Ot(e):e=>e.length>64?Bn.encode(e):Ot(e),L=e=>Uint8Array.from(e),Z=X?(e,t,r)=>Se(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Mt=X?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),We(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},Lt=X?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Vt(e,t){if(Se(e)&&Se(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 Ot(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 Dt(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 Nn(n)}var Rt=4096;function Nn(e){let t=e.length;if(t<=Rt)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Rt));return r}var On=256,ce=class{constructor(t=On){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=Lt(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=Mt(this.chunks,this.cursor);return t&&this.reset(),r}};var h="CBOR decode error:",Ye="CBOR encode error:",ue=[];ue[23]=1;ue[24]=2;ue[25]=3;ue[26]=5;ue[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 T(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 k(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 Pt(e,t,r,n){return new d(s.uint,T(e,t+1,n),2)}function Ft(e,t,r,n){return new d(s.uint,k(e,t+1,n),3)}function Ht(e,t,r,n){return new d(s.uint,A(e,t+1,n),5)}function qt(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 Gt(e,t,r,n){return new d(s.negint,-1-T(e,t+1,n),2)}function Wt(e,t,r,n){return new d(s.negint,-1-k(e,t+1,n),3)}function Yt(e,t,r,n){return new d(s.negint,-1-A(e,t+1,n),5)}var Ke=BigInt(-1),Kt=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,Ke-BigInt(o),9)}function Ue(e,t){let r=t.value,n=typeof r=="bigint"?r*Ke-Kt:r*-1-1;x(e,t.type.majorEncoded,n)}Ue.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ke-Kt:r*-1-1;return n<g[0]?1:n<g[1]?2:n<g[2]?3:n<g[3]?5:9};Ue.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function fe(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 fe(e,t,1,r)}function Xt(e,t,r,n){return fe(e,t,2,T(e,t+1,n))}function Zt(e,t,r,n){return fe(e,t,3,k(e,t+1,n))}function jt(e,t,r,n){return fe(e,t,5,A(e,t+1,n))}function er(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 fe(e,t,9,o)}function Be(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=Be(t);x(e,t.type.majorEncoded,r.length),e.push(r)}j.encodedSize=function(t){let r=Be(t);return x.encodedSize(r.length)+r.length};j.compareTokens=function(t,r){return Rn(Be(t),Be(r))};function Rn(e,t){return e.length<t.length?-1:e.length>t.length?1:Vt(e,t)}function de(e,t,r,n,o){let i=r+n;F(e,t,i);let a=new d(s.string,zt(e,t+r,t+i),i);return o.retainStringBytes===!0&&(a.byteValue=Z(e,t+r,t+i)),a}function tr(e,t,r,n){return de(e,t,1,r,n)}function rr(e,t,r,n){return de(e,t,2,T(e,t+1,n),n)}function nr(e,t,r,n){return de(e,t,3,k(e,t+1,n),n)}function or(e,t,r,n){return de(e,t,5,A(e,t+1,n),n)}function ir(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 de(e,t,9,o,n)}var sr=j;function ee(e,t,r,n){return new d(s.array,n,r)}function ar(e,t,r,n){return ee(e,t,1,r)}function cr(e,t,r,n){return ee(e,t,2,T(e,t+1,n))}function ur(e,t,r,n){return ee(e,t,3,k(e,t+1,n))}function fr(e,t,r,n){return ee(e,t,5,A(e,t+1,n))}function dr(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 lr(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 Ne(e,t){x(e,s.array.majorEncoded,t.value)}Ne.compareTokens=S.compareTokens;Ne.encodedSize=function(t){return x.encodedSize(t.value)};function te(e,t,r,n){return new d(s.map,n,r)}function hr(e,t,r,n){return te(e,t,1,r)}function pr(e,t,r,n){return te(e,t,2,T(e,t+1,n))}function yr(e,t,r,n){return te(e,t,3,k(e,t+1,n))}function mr(e,t,r,n){return te(e,t,5,A(e,t+1,n))}function wr(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 gr(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 Oe(e,t){x(e,s.map.majorEncoded,t.value)}Oe.compareTokens=S.compareTokens;Oe.encodedSize=function(t){return x.encodedSize(t.value)};function xr(e,t,r,n){return new d(s.tag,r,1)}function br(e,t,r,n){return new d(s.tag,T(e,t+1,n),2)}function vr(e,t,r,n){return new d(s.tag,k(e,t+1,n),3)}function Er(e,t,r,n){return new d(s.tag,A(e,t+1,n),5)}function _r(e,t,r,n){return new d(s.tag,I(e,t+1,n),9)}function De(e,t){x(e,s.tag.majorEncoded,t.value)}De.compareTokens=S.compareTokens;De.encodedSize=function(t){return x.encodedSize(t.value)};var Pn=20,Fn=21,Hn=22,qn=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 kr(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 Je(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 Ar(e,t,r,n){return Je(Qe(e,t+1),3,n)}function Ir(e,t,r,n){return Je(Xe(e,t+1),5,n)}function Cr(e,t,r,n){return Je(Nr(e,t+1),9,n)}function Re(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|Pn]);else if(n===!0)e.push([s.float.majorEncoded|Fn]);else if(n===null)e.push([s.float.majorEncoded|Hn]);else if(n===void 0)e.push([s.float.majorEncoded|qn]);else{let o,i=!1;(!r||r.float64!==!0)&&(Ur(n),o=Qe(D,1),n===o||Number.isNaN(n)?(D[0]=249,e.push(D.slice(0,3)),i=!0):(Br(n),o=Xe(D,1),n===o&&(D[0]=250,e.push(D.slice(0,5)),i=!0))),i||(Gn(n),o=Nr(D,1),D[0]=251,e.push(D.slice(0,9)))}}Re.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){Ur(n);let o=Qe(D,1);if(n===o||Number.isNaN(n))return 3;if(Br(n),o=Xe(D,1),n===o)return 5}return 9};var Sr=new ArrayBuffer(9),U=new DataView(Sr,1),D=new Uint8Array(Sr,0);function Ur(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 Qe(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 Br(e){U.setFloat32(0,e,!1)}function Xe(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 Gn(e){U.setFloat64(0,e,!1)}function Nr(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)}Re.compareTokens=S.compareTokens;function y(e,t,r){throw new Error(`${h} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function ze(e){return()=>{throw new Error(`${h} ${e}`)}}var f=[];for(let e=0;e<=23;e++)f[e]=y;f[24]=Pt;f[25]=Ft;f[26]=Ht;f[27]=qt;f[28]=y;f[29]=y;f[30]=y;f[31]=y;for(let e=32;e<=55;e++)f[e]=y;f[56]=Gt;f[57]=Wt;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]=Xt;f[89]=Zt;f[90]=jt;f[91]=er;f[92]=y;f[93]=y;f[94]=y;f[95]=ze("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)f[e]=tr;f[120]=rr;f[121]=nr;f[122]=or;f[123]=ir;f[124]=y;f[125]=y;f[126]=y;f[127]=ze("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)f[e]=ar;f[152]=cr;f[153]=ur;f[154]=fr;f[155]=dr;f[156]=y;f[157]=y;f[158]=y;f[159]=lr;for(let e=160;e<=183;e++)f[e]=hr;f[184]=pr;f[185]=yr;f[186]=mr;f[187]=wr;f[188]=y;f[189]=y;f[190]=y;f[191]=gr;for(let e=192;e<=215;e++)f[e]=xr;f[216]=br;f[217]=vr;f[218]=Er;f[219]=_r;f[220]=y;f[221]=y;f[222]=y;f[223]=y;for(let e=224;e<=243;e++)f[e]=ze("simple values are not supported");f[244]=y;f[245]=y;f[246]=y;f[247]=Tr;f[248]=ze("simple values are not supported");f[249]=Ar;f[250]=Ir;f[251]=Cr;f[252]=y;f[253]=y;f[254]=y;f[255]=kr;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 Ze(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:Ze};function et(){let e=[];return e[s.uint.major]=S,e[s.negint.major]=Ue,e[s.bytes.major]=j,e[s.string.major]=sr,e[s.array.major]=Ne,e[s.map.major]=Oe,e[s.tag.major]=De,e[s.float.major]=Re,e}var Or=et(),je=new ce,$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(`${Ye} 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++]=le(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++]=[le(p,r,n),le(o?e.get(p):e[p],r,n)];return Kn(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 le(e,t={},r){let n=Nt(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(`${Ye} unsupported type: ${n}`);return i(e,n,t,r)}function Kn(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=Or[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Dr(e,t,r,n){if(Array.isArray(t))for(let o of t)Dr(e,o,r,n);else r[t.type.major](e,t,n)}function Qn(e,t,r){let n=le(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 ce(a);if(i(u,n,r),u.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return We(u.chunks[0])}}return je.reset(),Dr(je,n,t,r),je.toBytes(!0)}function tt(e,t){return t=Object.assign({},Yn,t),Qn(e,Or,t)}var Xn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Me=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}},he=Symbol.for("DONE"),Le=Symbol.for("BREAK");function Zn(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=re(t,r);if(i===Le){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed array`)}if(i===he)throw new Error(`${h} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function jn(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===Le){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed map`)}if(u===he)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===he)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 he;let r=e.next();if(r.type===s.break)return Le;if(r.type.terminal)return r.value;if(r.type===s.array)return Zn(r,e,t);if(r.type===s.map)return jn(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 Rr(e,t){if(!(e instanceof Uint8Array))throw new Error(`${h} data to decode must be a Uint8Array`);t=Object.assign({},Xn,t);let r=t.tokenizer||new Me(e,t),n=re(r,t);if(n===he)throw new Error(`${h} did not find any content to decode`);if(n===Le)throw new Error(`${h} got unexpected break`);return[n,e.subarray(r.pos())]}function rt(e,t){let[r,n]=Rr(e,t);if(n.length>0)throw new Error(`${h} too many terminals, data makes no sense`);return r}var ds=new Uint8Array(0);function zr(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 to(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,J=0,N=0,z=w.length;N!==z&&w[N]===0;)N++,_++;for(var $=(z-N)*l+1>>>0,C=new Uint8Array($);N!==z;){for(var M=w[N],q=0,O=$-1;(M!==0||q<J)&&O!==-1;O--,q++)M+=256*C[O]>>>0,C[O]=M%u>>>0,M=M/u>>>0;if(M!==0)throw new Error("Non-zero carry");J=q,N++}for(var P=$-J;P!==$&&C[P]===0;)P++;for(var Ae=c.repeat(_);P<$;++P)Ae+=e.charAt(C[P]);return Ae}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 J=0,N=0;w[_]===c;)J++,_++;for(var z=(w.length-_)*p+1>>>0,$=new Uint8Array(z);w[_];){var C=r[w.charCodeAt(_)];if(C===255)return;for(var M=0,q=z-1;(C!==0||M<N)&&q!==-1;q--,M++)C+=u*$[q]>>>0,$[q]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");N=M,_++}if(w[_]!==" "){for(var O=z-N;O!==z&&$[O]===0;)O++;for(var P=new Uint8Array(J+(z-O)),Ae=J;O!==z;)P[Ae++]=$[O++];return P}}}function K(w){var _=v(w);if(_)return _;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:v,decode:K}}var ro=to,no=ro,$r=no;var nt=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")}},ot=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 Mr(this,t)}},it=class{decoders;constructor(t){this.decoders=t}or(t){return Mr(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 Mr(e,t){return new it({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var st=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 nt(t,r,n),this.decoder=new ot(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Lr({name:e,prefix:t,encode:r,decode:n}){return new st(e,t,r,n)}function at({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=$r(r,e);return Lr({prefix:t,name:e,encode:n,decode:i=>ne(o(i))})}function oo(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 io(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 Lr({prefix:t,name:e,encode(o){return io(o,n,r)},decode(o){return oo(o,n,r,e)}})}var pe=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gs=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xs=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bs=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vs=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Es=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),_s=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ts=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ks=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var H=at({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Cs=at({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var so=Fr,Vr=128,ao=127,co=~ao,uo=Math.pow(2,31);function Fr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=uo;)t[r++]=e&255|Vr,e/=128;for(;e&co;)t[r++]=e&255|Vr,e>>>=7;return t[r]=e|0,Fr.bytes=r-n+1,t}var fo=ct,lo=128,Pr=127;function ct(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u)throw ct.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&Pr)<<o:(a&Pr)*Math.pow(2,o),o+=7}while(a>=lo);return ct.bytes=i-n,r}var ho=Math.pow(2,7),po=Math.pow(2,14),yo=Math.pow(2,21),mo=Math.pow(2,28),wo=Math.pow(2,35),go=Math.pow(2,42),xo=Math.pow(2,49),bo=Math.pow(2,56),vo=Math.pow(2,63),Eo=function(e){return e<ho?1:e<po?2:e<yo?3:e<mo?4:e<wo?5:e<go?6:e<xo?7:e<bo?8:e<vo?9:10},_o={encode:so,decode:fo,encodingLength:Eo},To=_o,ye=To;function me(e,t=0){return[ye.decode(e,t),ye.decode.bytes]}function oe(e,t,r=0){return ye.encode(e,t,r),t}function ie(e){return ye.encodingLength(e)}function qr(e,t){let r=t.byteLength,n=ie(e),o=n+ie(r),i=new Uint8Array(o+r);return oe(e,i,0),oe(r,i,n),i.set(t,o),new se(e,r,t,i)}function Ve(e){let t=ne(e),[r,n]=me(t),[o,i]=me(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new se(r,o,a,t)}function Gr(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&zr(e.bytes,r.bytes)}}var se=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Wr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Ao(r,ft(e),t??H.encoder);default:return Io(r,ft(e),t??pe.encoder)}}var Yr=new WeakMap;function ft(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!==we)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Co)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=qr(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&&Gr(t.multihash,n.multihash)}toString(t){return Wr(this,t)}toJSON(){return{"/":Wr(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??Kr(n,o,i.bytes))}else if(r[So]===!0){let{version:n,multihash:o,code:i}=r,a=Ve(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!==we)throw new Error(`Version 0 CID must use dag-pb (code: ${we}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Kr(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,we,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 se(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]=me(t.subarray(r));return r+=v,m},o=n(),i=we;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let 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]=ko(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 ft(i).set(n,t),i}};function ko(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 pe.prefix:{let r=t??pe;return[pe.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Ao(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 Io(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 we=112,Co=18;function Kr(e,t,r){let n=ie(e),o=n+ie(t),i=new Uint8Array(o+r.byteLength);return oe(e,i,0),oe(t,i,n),i.set(r,o),i}var So=Symbol.for("@ipld/js-cid/CID");var Jr=42;function Uo(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function Bo(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 No(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Oo(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 dt={float64:!0,typeEncoders:{Object:Bo,undefined:No,number:Oo}},Ls={...dt,typeEncoders:{...dt.typeEncoders}};function Do(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return B.decode(e.subarray(1))}var Pe={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Pe.tags[Jr]=Do;var Vs={...Pe,tags:Pe.tags.slice()};var lt=e=>tt(e,dt),ht=e=>rt(Uo(e),Pe);var mt=Ce(Fe(),1);var wt=40;function gt(e,t){if(!e.length)throw new Error("Unexpected end of data");let r=mt.default.decode(e);return t.seek(mt.default.decode.bytes),r}function xt(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 Y={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},ge={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":Y.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(Y.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=ge["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=ge["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:Y.Int,CarV1HeaderOrV2Pragma:e=>{if(Y.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=ge["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=ge.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}},xe={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":Y.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(Y.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:Y.Int,CarV1HeaderOrV2Pragma:e=>{if(Y.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)"](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=xe.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}},bt={toTyped:ge.CarV1HeaderOrV2Pragma,toRepresentation:xe.CarV1HeaderOrV2Pragma};var ta=et();var Zo=Ce(Fe(),1);var sa=[new d(s.map,2),new d(s.string,"version"),new d(s.uint,1),new d(s.string,"roots")],aa=new d(s.tag,42);async function vt(e,t){let r=gt(await e.upTo(8),e);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await e.exactly(r,!0),o=ht(n);if(bt.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=xt(await e.exactly(wt,!0));e.seek(i.dataOffset-e.pos);let a=await vt(e,1);return Object.assign(a,i)}function be(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 Et=Ce(Fe(),1),cn=1;function _t(e){let t=lt({version:cn,roots:e}),r=Et.default.encode(t.length),n=new Uint8Array(r.length+t.length);return n.set(r,0),n.set(t,r.length),n}function un(e){return{async setRoots(t){let r=_t(t);await e.write(r)},async writeBlock(t){let{cid:r,bytes:n}=t;await e.write(new Uint8Array(Et.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 cn}}}function He(){}function fn(){let e=[],t=null,r=He,n=!1,o=null,i=He,a=()=>(t||(t=new Promise(p=>{r=()=>{t=null,r=He,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=He,l(c.next()))})),o)}};return{writer:u,iterator:c}}var ve=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=ri(t);let{encoder:r,iterator:n}=dn(),o=new e(t,r),i=new qe(n);return{writer:o,out:i}}static createAppender(){let{encoder:t,iterator:r}=dn();t.setRoots=()=>Promise.resolve();let n=new e([],t),o=new qe(r);return{writer:n,out:o}}static async updateRootsInBytes(t,r){let n=be(t);await vt(n);let o=_t(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}},qe=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 dn(){let e=fn(),{writer:t,iterator:r}=e;return{encoder:un(t),iterator:r}}function ri(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 ni(e){return e[Symbol.asyncIterator]!=null}function oi(e){if(ni(e))return(async()=>{for await(let t of e);})();for(let t of e);}var ln=oi;function ii(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 hn=ii;function si(e){return e[Symbol.asyncIterator]!=null}function ai(e,t){let r=0;if(si(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=hn(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 pn=ai;function Tt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var At=Ce(mn(),1);var _e=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},It=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},wn=e=>globalThis.DOMException===void 0?new It(e):new DOMException(e),gn=e=>{let t=e.reason===void 0?wn("This operation was aborted."):e.reason;return t instanceof Error?t:wn(t)};function Ct(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(gn(v)),v.addEventListener("abort",()=>{l(gn(v))})}if(r===Number.POSITIVE_INFINITY){e.then(p,l);return}let m=new _e;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 St(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=St(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 ke=class extends At.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#T(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=Ct(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#T(r.signal)]));let a=await i;n(a),this.emit("completed",a)}catch(i){if(i instanceof _e&&!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 fi=1,Ut=class{components;constructor(t,r){this.components=t}async import(t,r){await ln(this.components.blockstore.putMany(pn(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 ke({concurrency:fi});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}=ve.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 di(e,t={}){return new Ut(e,t)}return kn(li);})();
|
|
3
3
|
return HeliaCar}));
|
package/dist/src/index.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ import type { DAGWalker } from '@helia/interface';
|
|
|
62
62
|
import type { GetBlockProgressEvents, PutManyBlocksProgressEvents } from '@helia/interface/blocks';
|
|
63
63
|
import type { CarReader } from '@ipld/car';
|
|
64
64
|
import type { AbortOptions } from '@libp2p/interfaces';
|
|
65
|
+
import type { Filter } from '@libp2p/utils/filters';
|
|
65
66
|
import type { Blockstore } from 'interface-blockstore';
|
|
66
67
|
import type { CID } from 'multiformats/cid';
|
|
67
68
|
import type { ProgressOptions } from 'progress-events';
|
|
@@ -69,6 +70,12 @@ export interface CarComponents {
|
|
|
69
70
|
blockstore: Blockstore;
|
|
70
71
|
dagWalkers: Record<number, DAGWalker>;
|
|
71
72
|
}
|
|
73
|
+
interface ExportCarOptions extends AbortOptions, ProgressOptions<GetBlockProgressEvents> {
|
|
74
|
+
/**
|
|
75
|
+
* If a filter is passed it will be used to deduplicate blocks exported in the car file
|
|
76
|
+
*/
|
|
77
|
+
blockFilter?: Filter;
|
|
78
|
+
}
|
|
72
79
|
/**
|
|
73
80
|
* The Car interface provides operations for importing and exporting Car files
|
|
74
81
|
* from Helia's underlying blockstore.
|
|
@@ -121,7 +128,7 @@ export interface Car {
|
|
|
121
128
|
* await eventPromise
|
|
122
129
|
* ```
|
|
123
130
|
*/
|
|
124
|
-
export(root: CID | CID[], writer: Pick<CarWriter, 'put' | 'close'>, options?:
|
|
131
|
+
export(root: CID | CID[], writer: Pick<CarWriter, 'put' | 'close'>, options?: ExportCarOptions): Promise<void>;
|
|
125
132
|
/**
|
|
126
133
|
* Returns an AsyncGenerator that yields CAR file bytes.
|
|
127
134
|
*
|
|
@@ -151,4 +158,5 @@ export declare function car(helia: {
|
|
|
151
158
|
blockstore: Blockstore;
|
|
152
159
|
dagWalkers: Record<number, DAGWalker>;
|
|
153
160
|
}, init?: any): Car;
|
|
161
|
+
export {};
|
|
154
162
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAKrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAClG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,GAAG;IAClB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,2BAA2B,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE/H;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAKrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAClG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CACtC;AAED,UAAU,gBAAiB,SAAQ,YAAY,EAAE,eAAe,CAAC,sBAAsB,CAAC;IACtF;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,GAAG;IAClB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,2BAA2B,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE/H;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE9G;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,sBAAsB,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,CAAA;CACxH;AA8FD;;GAEG;AACH,wBAAgB,GAAG,CAAE,KAAK,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CAAE,EAAE,IAAI,GAAE,GAAQ,GAAG,GAAG,CAElH"}
|
package/dist/src/index.js
CHANGED
|
@@ -88,6 +88,11 @@ class DefaultCar {
|
|
|
88
88
|
for (const root of roots) {
|
|
89
89
|
void queue.add(async () => {
|
|
90
90
|
await this.#walkDag(root, queue, async (cid, bytes) => {
|
|
91
|
+
// if a filter has been passed, skip blocks that have already been written
|
|
92
|
+
if (options?.blockFilter?.has(cid.multihash.bytes) === true) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
options?.blockFilter?.add(cid.multihash.bytes);
|
|
91
96
|
await writer.put({ cid, bytes });
|
|
92
97
|
}, options);
|
|
93
98
|
})
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,MAAM,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,MAAM,MAAM,SAAS,CAAA;AAoG5B,MAAM,0BAA0B,GAAG,CAAC,CAAA;AAEpC,MAAM,UAAU;IACG,UAAU,CAAe;IAE1C,YAAa,UAAyB,EAAE,IAAS;QAC/C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,MAAiC,EAAE,OAAqE;QACpH,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAC5C,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,EACjE,OAAO,CACR,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,IAAiB,EAAE,MAAwC,EAAE,OAA0B;QACnG,MAAM,QAAQ,GAAG,KAAK,EAAqB,CAAA;QAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAEjD,sFAAsF;QACtF,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC;YACvB,WAAW,EAAE,0BAA0B;SACxC,CAAC,CAAA;QACF,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YACpB,QAAQ,CAAC,OAAO,EAAE,CAAA;QACpB,CAAC,CAAC,CAAA;QACF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,KAAK,CAAC,KAAK,EAAE,CAAA;YACb,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACtB,CAAC,CAAC,CAAA;QAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;gBACxB,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;oBACpD,0EAA0E;oBAC1E,IAAI,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;wBAC5D,OAAM;oBACR,CAAC;oBAED,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;oBAC9C,MAAM,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;gBAClC,CAAC,EAAE,OAAO,CAAC,CAAA;YACb,CAAC,CAAC;iBACC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACpB,CAAC;QAED,6BAA6B;QAC7B,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,OAAO,CAAA;QACxB,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;QACtB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAE,MAAM,CAAE,IAAiB,EAAE,OAA0B;QAC3D,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAE9C,0EAA0E;QAC1E,YAAY;QACZ,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;aAC/B,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAElB,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;YAC5B,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ,CAAE,GAAQ,EAAE,KAAa,EAAE,SAAyD,EAAE,OAAgE;QAClK,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAEtD,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;QAClE,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAEhE,MAAM,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAE3B,0CAA0C;QAC1C,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;gBACxB,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;YACrD,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAE,KAAwE,EAAE,OAAY,EAAE;IAC3G,OAAO,IAAI,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACpC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/car",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
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,9 +139,10 @@
|
|
|
139
139
|
"release": "aegir release"
|
|
140
140
|
},
|
|
141
141
|
"dependencies": {
|
|
142
|
-
"@helia/interface": "^4.3.
|
|
142
|
+
"@helia/interface": "^4.3.1",
|
|
143
143
|
"@ipld/car": "^5.3.0",
|
|
144
144
|
"@libp2p/interfaces": "^3.3.2",
|
|
145
|
+
"@libp2p/utils": "^5.4.6",
|
|
145
146
|
"interface-blockstore": "^5.2.10",
|
|
146
147
|
"it-drain": "^3.0.5",
|
|
147
148
|
"it-map": "^3.0.5",
|
|
@@ -151,10 +152,12 @@
|
|
|
151
152
|
"progress-events": "^1.0.0"
|
|
152
153
|
},
|
|
153
154
|
"devDependencies": {
|
|
154
|
-
"@helia/
|
|
155
|
+
"@helia/mfs": "^3.0.7",
|
|
156
|
+
"@helia/unixfs": "^3.0.7",
|
|
155
157
|
"@ipld/dag-pb": "^4.1.0",
|
|
156
|
-
"aegir": "^
|
|
158
|
+
"aegir": "^44.0.1",
|
|
157
159
|
"blockstore-core": "^4.4.0",
|
|
160
|
+
"datastore-core": "^9.2.9",
|
|
158
161
|
"ipfs-unixfs-importer": "^15.2.4",
|
|
159
162
|
"it-to-buffer": "^4.0.5"
|
|
160
163
|
},
|
package/src/index.ts
CHANGED
|
@@ -67,6 +67,7 @@ import type { DAGWalker } from '@helia/interface'
|
|
|
67
67
|
import type { GetBlockProgressEvents, PutManyBlocksProgressEvents } from '@helia/interface/blocks'
|
|
68
68
|
import type { CarReader } from '@ipld/car'
|
|
69
69
|
import type { AbortOptions } from '@libp2p/interfaces'
|
|
70
|
+
import type { Filter } from '@libp2p/utils/filters'
|
|
70
71
|
import type { Blockstore } from 'interface-blockstore'
|
|
71
72
|
import type { CID } from 'multiformats/cid'
|
|
72
73
|
import type { ProgressOptions } from 'progress-events'
|
|
@@ -76,6 +77,13 @@ export interface CarComponents {
|
|
|
76
77
|
dagWalkers: Record<number, DAGWalker>
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
interface ExportCarOptions extends AbortOptions, ProgressOptions<GetBlockProgressEvents> {
|
|
81
|
+
/**
|
|
82
|
+
* If a filter is passed it will be used to deduplicate blocks exported in the car file
|
|
83
|
+
*/
|
|
84
|
+
blockFilter?: Filter
|
|
85
|
+
}
|
|
86
|
+
|
|
79
87
|
/**
|
|
80
88
|
* The Car interface provides operations for importing and exporting Car files
|
|
81
89
|
* from Helia's underlying blockstore.
|
|
@@ -129,7 +137,7 @@ export interface Car {
|
|
|
129
137
|
* await eventPromise
|
|
130
138
|
* ```
|
|
131
139
|
*/
|
|
132
|
-
export(root: CID | CID[], writer: Pick<CarWriter, 'put' | 'close'>, options?:
|
|
140
|
+
export(root: CID | CID[], writer: Pick<CarWriter, 'put' | 'close'>, options?: ExportCarOptions): Promise<void>
|
|
133
141
|
|
|
134
142
|
/**
|
|
135
143
|
* Returns an AsyncGenerator that yields CAR file bytes.
|
|
@@ -170,7 +178,7 @@ class DefaultCar implements Car {
|
|
|
170
178
|
))
|
|
171
179
|
}
|
|
172
180
|
|
|
173
|
-
async export (root: CID | CID[], writer: Pick<CarWriter, 'put' | 'close'>, options?:
|
|
181
|
+
async export (root: CID | CID[], writer: Pick<CarWriter, 'put' | 'close'>, options?: ExportCarOptions): Promise<void> {
|
|
174
182
|
const deferred = defer<Error | undefined>()
|
|
175
183
|
const roots = Array.isArray(root) ? root : [root]
|
|
176
184
|
|
|
@@ -189,6 +197,12 @@ class DefaultCar implements Car {
|
|
|
189
197
|
for (const root of roots) {
|
|
190
198
|
void queue.add(async () => {
|
|
191
199
|
await this.#walkDag(root, queue, async (cid, bytes) => {
|
|
200
|
+
// if a filter has been passed, skip blocks that have already been written
|
|
201
|
+
if (options?.blockFilter?.has(cid.multihash.bytes) === true) {
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
options?.blockFilter?.add(cid.multihash.bytes)
|
|
192
206
|
await writer.put({ cid, bytes })
|
|
193
207
|
}, options)
|
|
194
208
|
})
|
|
@@ -203,7 +217,7 @@ class DefaultCar implements Car {
|
|
|
203
217
|
}
|
|
204
218
|
}
|
|
205
219
|
|
|
206
|
-
async * stream (root: CID | CID[], options?:
|
|
220
|
+
async * stream (root: CID | CID[], options?: ExportCarOptions): AsyncGenerator<Uint8Array, void, undefined> {
|
|
207
221
|
const { writer, out } = CarWriter.create(root)
|
|
208
222
|
|
|
209
223
|
// has to be done async so we write to `writer` and read from `out` at the
|