@wovin/connect-ucan-store-proxy 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4JTLYRW4.min.js → chunk-4WKM2MPH.min.js} +3 -3
- package/dist/chunk-4WKM2MPH.min.js.map +1 -0
- package/dist/{chunk-DVH3GIBT.min.js → chunk-R5T56SIO.min.js} +2 -2
- package/dist/{chunk-DVH3GIBT.min.js.map → chunk-R5T56SIO.min.js.map} +1 -1
- package/dist/chunk-U6LK5UQW.min.js +2 -0
- package/dist/chunk-U6LK5UQW.min.js.map +1 -0
- package/dist/{chunk-ZGM6NJHV.min.js → chunk-ULU4ARX5.min.js} +2 -2
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/retrieve.min.js +1 -1
- package/dist/store.min.js +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.min.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-4JTLYRW4.min.js.map +0 -1
- package/dist/chunk-DFTNS77W.min.js +0 -2
- package/dist/chunk-DFTNS77W.min.js.map +0 -1
- /package/dist/{chunk-ZGM6NJHV.min.js.map → chunk-ULU4ARX5.min.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as eo,d as tr,e as Xs}from"./chunk-DVH3GIBT.min.js";import{a as Zi,b as Js,c as Ys}from"./chunk-DFTNS77W.min.js";var Ff=Zi((iR,jf)=>{"use strict";jf.exports=pa;var kf=128,Ng=127,Rg=~Ng,$g=Math.pow(2,31);function pa(e,t,r){if(Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw pa.bytes=0,new RangeError("Could not encode varint");t=t||[],r=r||0;for(var n=r;e>=$g;)t[r++]=e&255|kf,e/=128;for(;e&Rg;)t[r++]=e&255|kf,e>>>=7;return t[r]=e|0,pa.bytes=r-n+1,t}});var Kf=Zi((oR,zf)=>{"use strict";zf.exports=ha;var Pg=128,Vf=127;function ha(e,n){var r=0,n=n||0,i=0,o=n,s,a=e.length;do{if(o>=a||i>49)throw ha.bytes=0,new RangeError("Could not decode varint");s=e[o++],r+=i<28?(s&Vf)<<i:(s&Vf)*Math.pow(2,i),i+=7}while(s>=Pg);return ha.bytes=o-n,r}});var Gf=Zi((sR,qf)=>{"use strict";var Ug=Math.pow(2,7),Bg=Math.pow(2,14),Dg=Math.pow(2,21),Mg=Math.pow(2,28),Lg=Math.pow(2,35),kg=Math.pow(2,42),jg=Math.pow(2,49),Fg=Math.pow(2,56),Vg=Math.pow(2,63);qf.exports=function(e){return e<Ug?1:e<Bg?2:e<Dg?3:e<Mg?4:e<Lg?5:e<kg?6:e<jg?7:e<Fg?8:e<Vg?9:10}});var go=Zi((aR,Wf)=>{"use strict";Wf.exports={encode:Ff(),decode:Kf(),encodingLength:Gf()}});var Ty=["string","number","bigint","symbol"],Ay=["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 vc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Ty.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Oy(e))return"Buffer";let r=Ey(e);return r||"Object"}function Oy(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Ey(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Ay.includes(t))return t}var K=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}};K.uint=new K(0,"uint",!0);K.negint=new K(1,"negint",!0);K.bytes=new K(2,"bytes",!0);K.string=new K(3,"string",!0);K.array=new K(4,"array",!1);K.map=new K(5,"map",!1);K.tag=new K(6,"tag",!1);K.float=new K(7,"float",!0);K.false=new K(7,"false",!0);K.true=new K(7,"true",!0);K.null=new K(7,"null",!0);K.undefined=new K(7,"undefined",!0);K.break=new K(7,"break",!0);var fe=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 pn=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Iy=new TextDecoder,xy=new TextEncoder;function to(e){return pn&&globalThis.Buffer.isBuffer(e)}function Ac(e){return e instanceof Uint8Array?to(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Oc=pn?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):wc(e,t,r):(e,t,r)=>r-t>64?Iy.decode(e.subarray(t,r)):wc(e,t,r),Ec=pn?e=>e.length>64?globalThis.Buffer.from(e):_c(e):e=>e.length>64?xy.encode(e):_c(e);var hn=pn?(e,t,r)=>to(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Ic=pn?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ac(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let i of e)n+i.length>r.length&&(i=i.subarray(0,r.length-n)),r.set(i,n),n+=i.length;return r},xc=pn?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Sc(e,t){if(to(e)&&to(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 _c(e){let t=[],r=0;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=i&63|128):(i&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=i&63|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=i&63|128)}return t}function wc(e,t,r){let n=[];for(;t<r;){let i=e[t],o=null,s=i>239?4:i>223?3:i>191?2:1;if(t+s<=r){let a,u,c,l;switch(s){case 1:i<128&&(o=i);break;case 2:a=e[t+1],(a&192)===128&&(l=(i&31)<<6|a&63,l>127&&(o=l));break;case 3:a=e[t+1],u=e[t+2],(a&192)===128&&(u&192)===128&&(l=(i&15)<<12|(a&63)<<6|u&63,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:a=e[t+1],u=e[t+2],c=e[t+3],(a&192)===128&&(u&192)===128&&(c&192)===128&&(l=(i&15)<<18|(a&63)<<12|(u&63)<<6|c&63,l>65535&&l<1114112&&(o=l))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),t+=s}return Sy(n)}var Tc=4096;function Sy(e){let t=e.length;if(t<=Tc)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Tc));return r}var Cy=256,ro=class{constructor(t=Cy){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 i=r.length-(this.maxCursor-this.cursor)-1;r.set(t,i)}else{if(r){let i=r.length-(this.maxCursor-this.cursor)-1;i<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,i),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=xc(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=hn(n,0,this.cursor)}else r=Ic(this.chunks,this.cursor);return t&&this.reset(),r}};var ve="CBOR decode error:",Qs="CBOR encode error:",ei=[];ei[23]=1;ei[24]=2;ei[25]=3;ei[26]=5;ei[27]=9;function rr(e,t,r){if(e.length-t<r)throw new Error(`${ve} not enough data for type`)}var qe=[24,256,65536,4294967296,BigInt("18446744073709551616")];function ut(e,t,r){rr(e,t,1);let n=e[t];if(r.strict===!0&&n<qe[0])throw new Error(`${ve} integer encoded in more bytes than necessary (strict decode)`);return n}function ct(e,t,r){rr(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<qe[1])throw new Error(`${ve} integer encoded in more bytes than necessary (strict decode)`);return n}function ft(e,t,r){rr(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<qe[2])throw new Error(`${ve} integer encoded in more bytes than necessary (strict decode)`);return n}function lt(e,t,r){rr(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],i=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],o=(BigInt(n)<<BigInt(32))+BigInt(i);if(r.strict===!0&&o<qe[3])throw new Error(`${ve} integer encoded in more bytes than necessary (strict decode)`);if(o<=Number.MAX_SAFE_INTEGER)return Number(o);if(r.allowBigInt===!0)return o;throw new Error(`${ve} integers outside of the safe integer range are not supported`)}function Cc(e,t,r,n){return new fe(K.uint,ut(e,t+1,n),2)}function Nc(e,t,r,n){return new fe(K.uint,ct(e,t+1,n),3)}function Rc(e,t,r,n){return new fe(K.uint,ft(e,t+1,n),5)}function $c(e,t,r,n){return new fe(K.uint,lt(e,t+1,n),9)}function vt(e,t){return Je(e,0,t.value)}function Je(e,t,r){if(r<qe[0]){let n=Number(r);e.push([t|n])}else if(r<qe[1]){let n=Number(r);e.push([t|24,n])}else if(r<qe[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<qe[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<qe[4]){let i=[t|27,0,0,0,0,0,0,0],o=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,e.push(i)}else throw new Error(`${ve} encountered BigInt larger than allowable range`)}}vt.encodedSize=function(t){return Je.encodedSize(t.value)};Je.encodedSize=function(t){return t<qe[0]?1:t<qe[1]?2:t<qe[2]?3:t<qe[3]?5:9};vt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Pc(e,t,r,n){return new fe(K.negint,-1-ut(e,t+1,n),2)}function Uc(e,t,r,n){return new fe(K.negint,-1-ct(e,t+1,n),3)}function Bc(e,t,r,n){return new fe(K.negint,-1-ft(e,t+1,n),5)}var Zs=BigInt(-1),Dc=BigInt(1);function Mc(e,t,r,n){let i=lt(e,t+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new fe(K.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${ve} integers outside of the safe integer range are not supported`);return new fe(K.negint,Zs-BigInt(i),9)}function no(e,t){let r=t.value,n=typeof r=="bigint"?r*Zs-Dc:r*-1-1;Je(e,t.type.majorEncoded,n)}no.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Zs-Dc:r*-1-1;return n<qe[0]?1:n<qe[1]?2:n<qe[2]?3:n<qe[3]?5:9};no.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function ti(e,t,r,n){rr(e,t,r+n);let i=hn(e,t+r,t+r+n);return new fe(K.bytes,i,r+n)}function Lc(e,t,r,n){return ti(e,t,1,r)}function kc(e,t,r,n){return ti(e,t,2,ut(e,t+1,n))}function jc(e,t,r,n){return ti(e,t,3,ct(e,t+1,n))}function Fc(e,t,r,n){return ti(e,t,5,ft(e,t+1,n))}function Vc(e,t,r,n){let i=lt(e,t+1,n);if(typeof i=="bigint")throw new Error(`${ve} 64-bit integer bytes lengths not supported`);return ti(e,t,9,i)}function io(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===K.string?Ec(e.value):e.value),e.encodedBytes}function yn(e,t){let r=io(t);Je(e,t.type.majorEncoded,r.length),e.push(r)}yn.encodedSize=function(t){let r=io(t);return Je.encodedSize(r.length)+r.length};yn.compareTokens=function(t,r){return Ry(io(t),io(r))};function Ry(e,t){return e.length<t.length?-1:e.length>t.length?1:Sc(e,t)}function ri(e,t,r,n,i){let o=r+n;rr(e,t,o);let s=new fe(K.string,Oc(e,t+r,t+o),o);return i.retainStringBytes===!0&&(s.byteValue=hn(e,t+r,t+o)),s}function zc(e,t,r,n){return ri(e,t,1,r,n)}function Kc(e,t,r,n){return ri(e,t,2,ut(e,t+1,n),n)}function qc(e,t,r,n){return ri(e,t,3,ct(e,t+1,n),n)}function Gc(e,t,r,n){return ri(e,t,5,ft(e,t+1,n),n)}function Wc(e,t,r,n){let i=lt(e,t+1,n);if(typeof i=="bigint")throw new Error(`${ve} 64-bit integer string lengths not supported`);return ri(e,t,9,i,n)}var Hc=yn;function gn(e,t,r,n){return new fe(K.array,n,r)}function Jc(e,t,r,n){return gn(e,t,1,r)}function Xc(e,t,r,n){return gn(e,t,2,ut(e,t+1,n))}function Yc(e,t,r,n){return gn(e,t,3,ct(e,t+1,n))}function Qc(e,t,r,n){return gn(e,t,5,ft(e,t+1,n))}function Zc(e,t,r,n){let i=lt(e,t+1,n);if(typeof i=="bigint")throw new Error(`${ve} 64-bit integer array lengths not supported`);return gn(e,t,9,i)}function ef(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${ve} indefinite length items not allowed`);return gn(e,t,1,1/0)}function oo(e,t){Je(e,K.array.majorEncoded,t.value)}oo.compareTokens=vt.compareTokens;oo.encodedSize=function(t){return Je.encodedSize(t.value)};function mn(e,t,r,n){return new fe(K.map,n,r)}function tf(e,t,r,n){return mn(e,t,1,r)}function rf(e,t,r,n){return mn(e,t,2,ut(e,t+1,n))}function nf(e,t,r,n){return mn(e,t,3,ct(e,t+1,n))}function of(e,t,r,n){return mn(e,t,5,ft(e,t+1,n))}function sf(e,t,r,n){let i=lt(e,t+1,n);if(typeof i=="bigint")throw new Error(`${ve} 64-bit integer map lengths not supported`);return mn(e,t,9,i)}function af(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${ve} indefinite length items not allowed`);return mn(e,t,1,1/0)}function so(e,t){Je(e,K.map.majorEncoded,t.value)}so.compareTokens=vt.compareTokens;so.encodedSize=function(t){return Je.encodedSize(t.value)};function uf(e,t,r,n){return new fe(K.tag,r,1)}function cf(e,t,r,n){return new fe(K.tag,ut(e,t+1,n),2)}function ff(e,t,r,n){return new fe(K.tag,ct(e,t+1,n),3)}function lf(e,t,r,n){return new fe(K.tag,ft(e,t+1,n),5)}function df(e,t,r,n){return new fe(K.tag,lt(e,t+1,n),9)}function ao(e,t){Je(e,K.tag.majorEncoded,t.value)}ao.compareTokens=vt.compareTokens;ao.encodedSize=function(t){return Je.encodedSize(t.value)};var My=20,Ly=21,ky=22,jy=23;function pf(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${ve} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new fe(K.null,null,1):new fe(K.undefined,void 0,1)}function hf(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${ve} indefinite length items not allowed`);return new fe(K.break,void 0,1)}function ea(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${ve} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${ve} Infinity values are not supported`)}return new fe(K.float,e,t)}function yf(e,t,r,n){return ea(ta(e,t+1),3,n)}function gf(e,t,r,n){return ea(ra(e,t+1),5,n)}function mf(e,t,r,n){return ea(wf(e,t+1),9,n)}function uo(e,t,r){let n=t.value;if(n===!1)e.push([K.float.majorEncoded|My]);else if(n===!0)e.push([K.float.majorEncoded|Ly]);else if(n===null)e.push([K.float.majorEncoded|ky]);else if(n===void 0)e.push([K.float.majorEncoded|jy]);else{let i,o=!1;(!r||r.float64!==!0)&&(vf(n),i=ta(Bt,1),n===i||Number.isNaN(n)?(Bt[0]=249,e.push(Bt.slice(0,3)),o=!0):(_f(n),i=ra(Bt,1),n===i&&(Bt[0]=250,e.push(Bt.slice(0,5)),o=!0))),o||(Fy(n),i=wf(Bt,1),Bt[0]=251,e.push(Bt.slice(0,9)))}}uo.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){vf(n);let i=ta(Bt,1);if(n===i||Number.isNaN(n))return 3;if(_f(n),i=ra(Bt,1),n===i)return 5}return 9};var bf=new ArrayBuffer(9),_t=new DataView(bf,1),Bt=new Uint8Array(bf,0);function vf(e){if(e===1/0)_t.setUint16(0,31744,!1);else if(e===-1/0)_t.setUint16(0,64512,!1);else if(Number.isNaN(e))_t.setUint16(0,32256,!1);else{_t.setFloat32(0,e);let t=_t.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)_t.setUint16(0,31744,!1);else if(r===0)_t.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?_t.setUint16(0,0):i<-14?_t.setUint16(0,(t&2147483648)>>16|1<<24+i,!1):_t.setUint16(0,(t&2147483648)>>16|i+15<<10|n>>13,!1)}}}function ta(e,t){if(e.length-t<2)throw new Error(`${ve} 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,i=r&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,r&32768?-o:o}function _f(e){_t.setFloat32(0,e,!1)}function ra(e,t){if(e.length-t<4)throw new Error(`${ve} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Fy(e){_t.setFloat64(0,e,!1)}function wf(e,t){if(e.length-t<8)throw new Error(`${ve} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}uo.compareTokens=vt.compareTokens;function Ee(e,t,r){throw new Error(`${ve} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function co(e){return()=>{throw new Error(`${ve} ${e}`)}}var ue=[];for(let e=0;e<=23;e++)ue[e]=Ee;ue[24]=Cc;ue[25]=Nc;ue[26]=Rc;ue[27]=$c;ue[28]=Ee;ue[29]=Ee;ue[30]=Ee;ue[31]=Ee;for(let e=32;e<=55;e++)ue[e]=Ee;ue[56]=Pc;ue[57]=Uc;ue[58]=Bc;ue[59]=Mc;ue[60]=Ee;ue[61]=Ee;ue[62]=Ee;ue[63]=Ee;for(let e=64;e<=87;e++)ue[e]=Lc;ue[88]=kc;ue[89]=jc;ue[90]=Fc;ue[91]=Vc;ue[92]=Ee;ue[93]=Ee;ue[94]=Ee;ue[95]=co("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)ue[e]=zc;ue[120]=Kc;ue[121]=qc;ue[122]=Gc;ue[123]=Wc;ue[124]=Ee;ue[125]=Ee;ue[126]=Ee;ue[127]=co("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)ue[e]=Jc;ue[152]=Xc;ue[153]=Yc;ue[154]=Qc;ue[155]=Zc;ue[156]=Ee;ue[157]=Ee;ue[158]=Ee;ue[159]=ef;for(let e=160;e<=183;e++)ue[e]=tf;ue[184]=rf;ue[185]=nf;ue[186]=of;ue[187]=sf;ue[188]=Ee;ue[189]=Ee;ue[190]=Ee;ue[191]=af;for(let e=192;e<=215;e++)ue[e]=uf;ue[216]=cf;ue[217]=ff;ue[218]=lf;ue[219]=df;ue[220]=Ee;ue[221]=Ee;ue[222]=Ee;ue[223]=Ee;for(let e=224;e<=243;e++)ue[e]=co("simple values are not supported");ue[244]=Ee;ue[245]=Ee;ue[246]=Ee;ue[247]=pf;ue[248]=co("simple values are not supported");ue[249]=yf;ue[250]=gf;ue[251]=mf;ue[252]=Ee;ue[253]=Ee;ue[254]=Ee;ue[255]=hf;var Dt=[];for(let e=0;e<24;e++)Dt[e]=new fe(K.uint,e,1);for(let e=-1;e>=-24;e--)Dt[31-e]=new fe(K.negint,e,1);Dt[64]=new fe(K.bytes,new Uint8Array(0),1);Dt[96]=new fe(K.string,"",1);Dt[128]=new fe(K.array,0,1);Dt[160]=new fe(K.map,0,1);Dt[244]=new fe(K.false,!1,1);Dt[245]=new fe(K.true,!0,1);Dt[246]=new fe(K.null,null,1);function na(){let e=[];return e[K.uint.major]=vt,e[K.negint.major]=no,e[K.bytes.major]=yn,e[K.string.major]=Hc,e[K.array.major]=oo,e[K.map.major]=so,e[K.tag.major]=ao,e[K.float.major]=uo,e}var hN=na(),yN=new ro,lo=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(`${Qs} object contains circular references`);return new e(r,t)}},yr={null:new fe(K.null,null),undefined:new fe(K.undefined,void 0),true:new fe(K.true,!0),false:new fe(K.false,!1),emptyArray:new fe(K.array,0),emptyMap:new fe(K.map,0)},gr={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new fe(K.float,e):e>=0?new fe(K.uint,e):new fe(K.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new fe(K.uint,e):new fe(K.negint,e)},Uint8Array(e,t,r,n){return new fe(K.bytes,e)},string(e,t,r,n){return new fe(K.string,e)},boolean(e,t,r,n){return e?yr.true:yr.false},null(e,t,r,n){return yr.null},undefined(e,t,r,n){return yr.undefined},ArrayBuffer(e,t,r,n){return new fe(K.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new fe(K.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[yr.emptyArray,new fe(K.break)]:yr.emptyArray;n=lo.createCheck(n,e);let i=[],o=0;for(let s of e)i[o++]=fo(s,r,n);return r.addBreakTokens?[new fe(K.array,e.length),i,new fe(K.break)]:[new fe(K.array,e.length),i]},Object(e,t,r,n){let i=t!=="Object",o=i?e.keys():Object.keys(e),s=i?e.size:o.length;if(!s)return r.addBreakTokens===!0?[yr.emptyMap,new fe(K.break)]:yr.emptyMap;n=lo.createCheck(n,e);let a=[],u=0;for(let c of o)a[u++]=[fo(c,r,n),fo(i?e.get(c):e[c],r,n)];return Ky(a,r),r.addBreakTokens?[new fe(K.map,s),a,new fe(K.break)]:[new fe(K.map,s),a]}};gr.Map=gr.Object;gr.Buffer=gr.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))gr[`${e}Array`]=gr.DataView;function fo(e,t={},r){let n=vc(e),i=t&&t.typeEncoders&&t.typeEncoders[n]||gr[n];if(typeof i=="function"){let s=i(e,n,t,r);if(s!=null)return s}let o=gr[n];if(!o)throw new Error(`${Qs} unsupported type: ${n}`);return o(e,n,t,r)}function Ky(e,t){t.mapSorter&&e.sort(t.mapSorter)}var qy={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ia=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=Dt[t];if(r===void 0){let n=ue[t];if(!n)throw new Error(`${ve} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let i=t&31;r=n(this.data,this._pos,i,this.options)}return this._pos+=r.encodedLength,r}},ni=Symbol.for("DONE"),po=Symbol.for("BREAK");function Gy(e,t,r){let n=[];for(let i=0;i<e.value;i++){let o=ii(t,r);if(o===po){if(e.value===1/0)break;throw new Error(`${ve} got unexpected break to lengthed array`)}if(o===ni)throw new Error(`${ve} found array but not enough entries (got ${i}, expected ${e.value})`);n[i]=o}return n}function Wy(e,t,r){let n=r.useMaps===!0,i=n?void 0:{},o=n?new Map:void 0;for(let s=0;s<e.value;s++){let a=ii(t,r);if(a===po){if(e.value===1/0)break;throw new Error(`${ve} got unexpected break to lengthed map`)}if(a===ni)throw new Error(`${ve} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${ve} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&o.has(a)||!n&&a in i))throw new Error(`${ve} found repeat map key "${a}"`);let u=ii(t,r);if(u===ni)throw new Error(`${ve} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?o.set(a,u):i[a]=u}return n?o:i}function ii(e,t){if(e.done())return ni;let r=e.next();if(r.type===K.break)return po;if(r.type.terminal)return r.value;if(r.type===K.array)return Gy(r,e,t);if(r.type===K.map)return Wy(r,e,t);if(r.type===K.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=ii(e,t);return t.tags[r.value](n)}throw new Error(`${ve} tag not supported (${r.value})`)}throw new Error("unsupported")}function Tf(e,t){if(!(e instanceof Uint8Array))throw new Error(`${ve} data to decode must be a Uint8Array`);t=Object.assign({},qy,t);let r=t.tokenizer||new ia(e,t),n=ii(r,t);if(n===ni)throw new Error(`${ve} did not find any content to decode`);if(n===po)throw new Error(`${ve} got unexpected break`);return[n,e.subarray(r.pos())]}function oa(e,t){let[r,n]=Tf(e,t);if(n.length>0)throw new Error(`${ve} too many terminals, data makes no sense`);return r}var ON=new Uint8Array(0);function Af(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 bn(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 Xy(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 i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,u=e.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function p(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var z=0,W=0,T=0,k=E.length;T!==k&&E[T]===0;)T++,z++;for(var G=(k-T)*l+1>>>0,H=new Uint8Array(G);T!==k;){for(var F=E[T],Y=0,V=G-1;(F!==0||Y<W)&&V!==-1;V--,Y++)F+=256*H[V]>>>0,H[V]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");W=Y,T++}for(var ae=G-W;ae!==G&&H[ae]===0;)ae++;for(var L=u.repeat(z);ae<G;++ae)L+=e.charAt(H[ae]);return L}function S(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var z=0;if(E[z]!==" "){for(var W=0,T=0;E[z]===u;)W++,z++;for(var k=(E.length-z)*c+1>>>0,G=new Uint8Array(k);E[z];){var H=r[E.charCodeAt(z)];if(H===255)return;for(var F=0,Y=k-1;(H!==0||F<T)&&Y!==-1;Y--,F++)H+=a*G[Y]>>>0,G[Y]=H%256>>>0,H=H/256>>>0;if(H!==0)throw new Error("Non-zero carry");T=F,z++}if(E[z]!==" "){for(var V=k-T;V!==k&&G[V]===0;)V++;for(var ae=new Uint8Array(W+(k-V)),L=W;V!==k;)ae[L++]=G[V++];return ae}}}function x(E){var z=S(E);if(z)return z;throw new Error(`Non-${t} character`)}return{encode:p,decodeUnsafe:S,decode:x}}var Yy=Xy,Qy=Yy,Of=Qy;var sa=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")}},aa=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let i=r.codePointAt(0);if(i===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i,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 Ef(this,t)}},ua=class{decoders;constructor(t){this.decoders=t}or(t){return Ef(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 Ef(e,t){return new ua({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ca=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,i){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new sa(t,r,n),this.decoder=new aa(t,r,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function If({name:e,prefix:t,encode:r,decode:n}){return new ca(e,t,r,n)}function vn({name:e,prefix:t,alphabet:r}){let{encode:n,decode:i}=Of(r,e);return If({prefix:t,name:e,encode:n,decode:o=>bn(i(o))})}function Zy(e,t,r,n){let i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,u=0,c=0;for(let l=0;l<o;++l){let p=i[e[l]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<r|p,a+=r,a>=8&&(a-=8,s[c++]=255&u>>a)}if(a>=r||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return s}function eg(e,t,r){let n=t[t.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let u=0;u<e.length;++u)for(a=a<<8|e[u],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(s!==0&&(o+=t[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o}function qt({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return If({prefix:t,name:e,encode(i){return eg(i,n,r)},decode(i){return Zy(i,n,r,e)}})}var oi=qt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),RN=qt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$N=qt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),PN=qt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),UN=qt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),BN=qt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),DN=qt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),MN=qt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),LN=qt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ho=vn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),FN=vn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var nr=vn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),KN=vn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var tg=Cf,xf=128,rg=127,ng=~rg,ig=Math.pow(2,31);function Cf(e,t,r){t=t||[],r=r||0;for(var n=r;e>=ig;)t[r++]=e&255|xf,e/=128;for(;e&ng;)t[r++]=e&255|xf,e>>>=7;return t[r]=e|0,Cf.bytes=r-n+1,t}var og=fa,sg=128,Sf=127;function fa(e,n){var r=0,n=n||0,i=0,o=n,s,a=e.length;do{if(o>=a)throw fa.bytes=0,new RangeError("Could not decode varint");s=e[o++],r+=i<28?(s&Sf)<<i:(s&Sf)*Math.pow(2,i),i+=7}while(s>=sg);return fa.bytes=o-n,r}var ag=Math.pow(2,7),ug=Math.pow(2,14),cg=Math.pow(2,21),fg=Math.pow(2,28),lg=Math.pow(2,35),dg=Math.pow(2,42),pg=Math.pow(2,49),hg=Math.pow(2,56),yg=Math.pow(2,63),gg=function(e){return e<ag?1:e<ug?2:e<cg?3:e<fg?4:e<lg?5:e<dg?6:e<pg?7:e<hg?8:e<yg?9:10},mg={encode:tg,decode:og,encodingLength:gg},bg=mg,si=bg;function ai(e,t=0){return[si.decode(e,t),si.decode.bytes]}function _n(e,t,r=0){return si.encode(e,t,r),t}function wn(e){return si.encodingLength(e)}function Rf(e,t){let r=t.byteLength,n=wn(e),i=n+wn(r),o=new Uint8Array(i+r);return _n(e,o,0),_n(r,o,n),o.set(t,i),new Tn(e,r,t,o)}function $f(e){let t=bn(e),[r,n]=ai(t),[i,o]=ai(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Tn(r,i,s,t)}function Pf(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Af(e.bytes,r.bytes)}}var Tn=class{code;size;digest;bytes;constructor(t,r,n,i){this.code=t,this.size=r,this.digest=n,this.bytes=i}};function Uf(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return wg(r,la(e),t??nr.encoder);default:return Tg(r,la(e),t??oi.encoder)}}var Bf=new WeakMap;function la(e){let t=Bf.get(e);if(t==null){let r=new Map;return Bf.set(e,r),r}return t}var ci=class e{code;version;multihash;bytes;"/";constructor(t,r,n,i){this.code=r,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}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!==ui)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ag)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=Rf(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&&Pf(t.multihash,n.multihash)}toString(t){return Uf(this,t)}toJSON(){return{"/":Uf(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:i,multihash:o,bytes:s}=r;return new e(n,i,o,s??Df(n,i,o.bytes))}else if(r[Og]===!0){let{version:n,multihash:i,code:o}=r,s=$f(i);return e.create(n,o,s)}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!==ui)throw new Error(`Version 0 CID must use dag-pb (code: ${ui}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let i=Df(t,r,n.bytes);return new e(t,r,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ui,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,i=bn(t.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let o=i.subarray(r.multihashSize-r.digestSize),s=new Tn(r.multihashCode,r.digestSize,o,i);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[p,S]=ai(t.subarray(r));return r+=S,p},i=n(),o=ui;if(i===18?(i=0,r=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,a=n(),u=n(),c=r+u,l=c-s;return{version:i,codec:o,multihashCode:a,digestSize:u,multihashSize:l,size:c}}static parse(t,r){let[n,i]=_g(t,r),o=e.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return la(o).set(n,t),o}};function _g(e,t){switch(e[0]){case"Q":{let r=t??nr;return[nr.prefix,r.decode(`${nr.prefix}${e}`)]}case nr.prefix:{let r=t??nr;return[nr.prefix,r.decode(e)]}case oi.prefix:{let r=t??oi;return[oi.prefix,r.decode(e)]}case ho.prefix:{let r=t??ho;return[ho.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function wg(e,t,r){let{prefix:n}=r;if(n!==nr.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=t.get(n);if(i==null){let o=r.encode(e).slice(1);return t.set(n,o),o}else return i}function Tg(e,t,r){let{prefix:n}=r,i=t.get(n);if(i==null){let o=r.encode(e);return t.set(n,o),o}else return i}var ui=112,Ag=18;function Df(e,t,r){let n=wn(e),i=n+wn(t),o=new Uint8Array(i+r.byteLength);return _n(e,o,0),_n(t,o,n),o.set(r,i),o}var Og=Symbol.for("@ipld/js-cid/CID");var Lf=42;function Eg(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=ci.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new fe(K.tag,Lf),new fe(K.bytes,r)]}function Ig(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function xg(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 Mf={float64:!0,typeEncoders:{Object:Eg,undefined:Ig,number:xg}},rR={...Mf,typeEncoders:{...Mf.typeEncoders}};function Sg(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return ci.decode(e.subarray(1))}var yo={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};yo.tags[Lf]=Sg;var nR={...yo,tags:yo.tags.slice()};var da=e=>oa(e,yo);var mr=Js(go(),1),fi={SHA2_256:18,LENGTH:32,DAG_PB:112},ya=40;function An(e,t){if(!e.length)throw new Error("Unexpected end of data");let r=mr.default.decode(e);return t.seek(mr.default.decode.bytes),r}function ga(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))}}function ma(e){mr.default.decode(e);let t=mr.default.decode.bytes,r=mr.default.decode(e.subarray(mr.default.decode.bytes)),n=mr.default.decode.bytes;return t+n+r}var br={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},li={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":br.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(br.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=li["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let i=t;i<e.length;i++){let o=e[i];if(o=li["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](o),o===void 0)return;n.push(o)}return n}}return e}},Int:br.Int,CarV1HeaderOrV2Pragma:e=>{if(br.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let i=0;i<t.length;i++){let[o,s]=t[i];switch(o){case"roots":{let a=li["CarV1HeaderOrV2Pragma > roots (anon)"](e[o]);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.roots=a}}break;case"version":{n--;let a=li.Int(e[o]);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},di={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":br.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(br.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=di["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let i=t;i<e.length;i++){let o=e[i];if(o=di["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](o),o===void 0)return;n.push(o)}return n}}return e}},Int:br.Int,CarV1HeaderOrV2Pragma:e=>{if(br.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let i=0;i<t.length;i++){let[o,s]=t[i];switch(o){case"roots":{let a=di["CarV1HeaderOrV2Pragma > roots (anon)"](s);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.roots=a}}break;case"version":{n--;let a=di.Int(s);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},ba={toTyped:li.CarV1HeaderOrV2Pragma,toRepresentation:di.CarV1HeaderOrV2Pragma};var bR=na();var Gg=Js(go(),1);var AR=[new fe(K.map,2),new fe(K.string,"version"),new fe(K.uint,1),new fe(K.string,"roots")],OR=new fe(K.tag,42);async function va(e,t){let r=An(await e.upTo(8),e);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await e.exactly(r,!0),i=da(n);if(ba.toTyped(i)===void 0)throw new Error("Invalid CAR header format");if(i.version!==1&&i.version!==2||t!==void 0&&i.version!==t)throw new Error(`Invalid CAR version: ${i.version}${t!==void 0?` (expected ${t})`:""}`);if(i.version===1){if(!Array.isArray(i.roots))throw new Error("Invalid CAR header format");return i}if(i.roots!==void 0)throw new Error("Invalid CAR header format");let o=ga(await e.exactly(ya,!0));e.seek(o.dataOffset-e.pos);let s=await va(e,1);return Object.assign(s,o)}async function Hg(e){let t=await e.exactly(2,!1);if(t[0]===fi.SHA2_256&&t[1]===fi.LENGTH){let s=await e.exactly(34,!0),a=eo(s);return tr.create(0,fi.DAG_PB,a)}let r=An(await e.upTo(8),e);if(r!==1)throw new Error(`Unexpected CID version (${r})`);let n=An(await e.upTo(8),e),i=await e.exactly(ma(await e.upTo(8)),!0),o=eo(i);return tr.create(r,n,o)}async function Hf(e){let t=e.pos,r=An(await e.upTo(8),e);if(r===0)throw new Error("Invalid CAR section (zero length)");r+=e.pos-t;let n=await Hg(e),i=r-Number(e.pos-t);return{cid:n,length:r,blockLength:i}}async function Jg(e){let{cid:t,blockLength:r}=await Hf(e);return{bytes:await e.exactly(r,!0),cid:t}}async function Xg(e){let t=e.pos,{cid:r,length:n,blockLength:i}=await Hf(e),o={cid:r,length:n,blockLength:i,offset:t,blockOffset:e.pos};return e.seek(o.blockLength),o}function mo(e){let t=(async()=>{let r=await va(e);if(r.version===2){let n=e.pos-r.dataOffset;e=Qg(e,r.dataSize-n)}return r})();return{header:()=>t,async*blocks(){for(await t;(await e.upTo(8)).length>0;)yield await Jg(e)},async*blocksIndex(){for(await t;(await e.upTo(8)).length>0;)yield await Xg(e)}}}function pi(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 i=e.subarray(t,t+r);return n&&(t+=r),i},seek(r){t+=r},get pos(){return t}}}function Yg(e){let t=0,r=0,n=0,i=new Uint8Array(0),o=async s=>{r=i.length-n;let a=[i.subarray(n)];for(;r<s;){let c=await e();if(c==null)break;r<0?c.length>r&&a.push(c.subarray(-r)):a.push(c),r+=c.length}i=new Uint8Array(a.reduce((c,l)=>c+l.length,0));let u=0;for(let c of a)i.set(c,u),u+=c.length;n=0};return{async upTo(s){return i.length-n<s&&await o(s),i.subarray(n,n+Math.min(i.length-n,s))},async exactly(s,a=!1){if(i.length-n<s&&await o(s),i.length-n<s)throw new Error("Unexpected end of data");let u=i.subarray(n,n+s);return a&&(t+=s,n+=s),u},seek(s){t+=s,n+=s},get pos(){return t}}}function bo(e){let t=e[Symbol.asyncIterator]();async function r(){let n=await t.next();return n.done?null:n.value}return Yg(r)}function Qg(e,t){let r=0;return{async upTo(n){let i=await e.upTo(n);return i.length+r>t&&(i=i.subarray(0,t-r)),i},async exactly(n,i=!1){let o=await e.exactly(n,i);if(o.length+r>t)throw new Error("Unexpected end of data");return i&&(r+=n),o},seek(n){r+=n,e.seek(n)},get pos(){return e.pos}}}var Dr=class{constructor(t,r){this._header=t,this._blocks=r,this._keys=r.map(n=>n.cid.toString())}get version(){return this._header.version}async getRoots(){return this._header.roots}async has(t){return this._keys.indexOf(t.toString())>-1}async get(t){let r=this._keys.indexOf(t.toString());return r>-1?this._blocks[r]:void 0}async*blocks(){for(let t of this._blocks)yield t}async*cids(){for(let t of this._blocks)yield t.cid}static async fromBytes(t){if(!(t instanceof Uint8Array))throw new TypeError("fromBytes() requires a Uint8Array");return Jf(pi(t))}static async fromIterable(t){if(!t||typeof t[Symbol.asyncIterator]!="function")throw new TypeError("fromIterable() requires an async iterable");return Jf(bo(t))}};async function Jf(e){let t=mo(e),r=await t.header(),n=[];for await(let i of t.blocks())n.push(i);return new Dr(r,n)}var em=Js(go(),1);var tm={0:"Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'",1:function(t,r){return"Cannot apply '"+t+"' to '"+r.toString()+"': Field not found."},5:"'keys()' can only be used on observable objects, arrays, sets and maps",6:"'values()' can only be used on observable objects, arrays, sets and maps",7:"'entries()' can only be used on observable objects, arrays and maps",8:"'set()' can only be used on observable objects, arrays and maps",9:"'remove()' can only be used on observable objects, arrays and maps",10:"'has()' can only be used on observable objects, arrays and maps",11:"'get()' can only be used on observable objects, arrays and maps",12:"Invalid annotation",13:"Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",14:"Intercept handlers should return nothing or a change object",15:"Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",16:"Modification exception: the internal structure of an observable array was changed.",17:function(t,r){return"[mobx.array] Index out of bounds, "+t+" is larger than "+r},18:"mobx.map requires Map polyfill for the current browser. Check babel-polyfill or core-js/es6/map.js",19:function(t){return"Cannot initialize from classes that inherit from Map: "+t.constructor.name},20:function(t){return"Cannot initialize map from "+t},21:function(t){return"Cannot convert to map from '"+t+"'"},22:"mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js",23:"It is not possible to get index atoms from arrays",24:function(t){return"Cannot obtain administration from "+t},25:function(t,r){return"the entry '"+t+"' does not exist in the observable map '"+r+"'"},26:"please specify a property",27:function(t,r){return"no observable property '"+t.toString()+"' found on the observable object '"+r+"'"},28:function(t){return"Cannot obtain atom from "+t},29:"Expecting some object",30:"invalid action stack. did you forget to finish an action?",31:"missing option for computed: get",32:function(t,r){return"Cycle detected in computation "+t+": "+r},33:function(t){return"The setter of computed value '"+t+"' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?"},34:function(t){return"[ComputedValue '"+t+"'] It is not possible to assign a new value to a computed value."},35:"There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`",36:"isolateGlobalState should be called before MobX is running any reactions",37:function(t){return"[mobx] `observableArray."+t+"()` mutates the array in-place, which is not allowed inside a derivation. Use `array.slice()."+t+"()` instead"},38:"'ownKeys()' can only be used on observable objects",39:"'defineProperty()' can only be used on observable objects"},rm=tm;function le(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=typeof e=="string"?e:rm[e];throw typeof i=="function"&&(i=i.apply(null,r)),new Error("[MobX] "+i)}var nm={};function Pa(){return typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:nm}var ll=Object.assign,xo=Object.getOwnPropertyDescriptor,Wt=Object.defineProperty,vi=Object.prototype,So=[];Object.freeze(So);var Ua={};Object.freeze(Ua);var im=typeof Proxy<"u",om=Object.toString();function dl(){im||le("`Proxy` objects are not available in the current environment. Please configure MobX to enable a fallback implementation.`")}function hi(e){Q.verifyProxies&&le("MobX is currently configured to be able to run in ES5 mode, but in ES5 MobX won't be able to "+e)}function St(){return++Q.mobxGuid}function Ba(e){var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}var En=function(){};function je(e){return typeof e=="function"}function Lr(e){var t=typeof e;switch(t){case"string":case"symbol":case"number":return!0}return!1}function Do(e){return e!==null&&typeof e=="object"}function jt(e){if(!Do(e))return!1;var t=Object.getPrototypeOf(e);if(t==null)return!0;var r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r.toString()===om}function pl(e){var t=e?.constructor;return t?t.name==="GeneratorFunction"||t.displayName==="GeneratorFunction":!1}function Mo(e,t,r){Wt(e,t,{enumerable:!1,writable:!0,configurable:!0,value:r})}function hl(e,t,r){Wt(e,t,{enumerable:!1,writable:!1,configurable:!0,value:r})}function wr(e,t){var r="isMobX"+e;return t.prototype[r]=!0,function(n){return Do(n)&&n[r]===!0}}function Nn(e){return e instanceof Map}function _i(e){return e instanceof Set}var yl=typeof Object.getOwnPropertySymbols<"u";function sm(e){var t=Object.keys(e);if(!yl)return t;var r=Object.getOwnPropertySymbols(e);return r.length?[].concat(t,r.filter(function(n){return vi.propertyIsEnumerable.call(e,n)})):t}var Lo=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:yl?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function Ta(e){return typeof e=="string"?e:typeof e=="symbol"?e.toString():new String(e).toString()}function gl(e){return e===null?null:typeof e=="object"?""+e:e}function Et(e,t){return vi.hasOwnProperty.call(e,t)}var am=Object.getOwnPropertyDescriptors||function(t){var r={};return Lo(t).forEach(function(n){r[n]=xo(t,n)}),r};function Xf(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,fm(n.key),n)}}function Da(e,t,r){return t&&Xf(e.prototype,t),r&&Xf(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function sr(){return sr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},sr.apply(this,arguments)}function ml(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Aa(e,t)}function Aa(e,t){return Aa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Aa(e,t)}function Ao(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function um(e,t){if(e){if(typeof e=="string")return Yf(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Yf(e,t)}}function Yf(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function In(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=um(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
1
|
+
import{b as eo,d as tr,e as Xs}from"./chunk-R5T56SIO.min.js";import{a as Zi,b as Js,c as Ys}from"./chunk-U6LK5UQW.min.js";var Ff=Zi((iR,jf)=>{"use strict";jf.exports=pa;var kf=128,Ng=127,Rg=~Ng,$g=Math.pow(2,31);function pa(e,t,r){if(Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw pa.bytes=0,new RangeError("Could not encode varint");t=t||[],r=r||0;for(var n=r;e>=$g;)t[r++]=e&255|kf,e/=128;for(;e&Rg;)t[r++]=e&255|kf,e>>>=7;return t[r]=e|0,pa.bytes=r-n+1,t}});var Kf=Zi((oR,zf)=>{"use strict";zf.exports=ha;var Pg=128,Vf=127;function ha(e,n){var r=0,n=n||0,i=0,o=n,s,a=e.length;do{if(o>=a||i>49)throw ha.bytes=0,new RangeError("Could not decode varint");s=e[o++],r+=i<28?(s&Vf)<<i:(s&Vf)*Math.pow(2,i),i+=7}while(s>=Pg);return ha.bytes=o-n,r}});var Gf=Zi((sR,qf)=>{"use strict";var Ug=Math.pow(2,7),Bg=Math.pow(2,14),Dg=Math.pow(2,21),Mg=Math.pow(2,28),Lg=Math.pow(2,35),kg=Math.pow(2,42),jg=Math.pow(2,49),Fg=Math.pow(2,56),Vg=Math.pow(2,63);qf.exports=function(e){return e<Ug?1:e<Bg?2:e<Dg?3:e<Mg?4:e<Lg?5:e<kg?6:e<jg?7:e<Fg?8:e<Vg?9:10}});var go=Zi((aR,Wf)=>{"use strict";Wf.exports={encode:Ff(),decode:Kf(),encodingLength:Gf()}});var Ty=["string","number","bigint","symbol"],Ay=["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 vc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Ty.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Oy(e))return"Buffer";let r=Ey(e);return r||"Object"}function Oy(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Ey(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Ay.includes(t))return t}var K=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}};K.uint=new K(0,"uint",!0);K.negint=new K(1,"negint",!0);K.bytes=new K(2,"bytes",!0);K.string=new K(3,"string",!0);K.array=new K(4,"array",!1);K.map=new K(5,"map",!1);K.tag=new K(6,"tag",!1);K.float=new K(7,"float",!0);K.false=new K(7,"false",!0);K.true=new K(7,"true",!0);K.null=new K(7,"null",!0);K.undefined=new K(7,"undefined",!0);K.break=new K(7,"break",!0);var fe=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 pn=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Iy=new TextDecoder,xy=new TextEncoder;function to(e){return pn&&globalThis.Buffer.isBuffer(e)}function Ac(e){return e instanceof Uint8Array?to(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Oc=pn?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):wc(e,t,r):(e,t,r)=>r-t>64?Iy.decode(e.subarray(t,r)):wc(e,t,r),Ec=pn?e=>e.length>64?globalThis.Buffer.from(e):_c(e):e=>e.length>64?xy.encode(e):_c(e);var hn=pn?(e,t,r)=>to(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Ic=pn?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ac(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let i of e)n+i.length>r.length&&(i=i.subarray(0,r.length-n)),r.set(i,n),n+=i.length;return r},xc=pn?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Sc(e,t){if(to(e)&&to(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 _c(e){let t=[],r=0;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=i&63|128):(i&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=i&63|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=i&63|128)}return t}function wc(e,t,r){let n=[];for(;t<r;){let i=e[t],o=null,s=i>239?4:i>223?3:i>191?2:1;if(t+s<=r){let a,u,c,l;switch(s){case 1:i<128&&(o=i);break;case 2:a=e[t+1],(a&192)===128&&(l=(i&31)<<6|a&63,l>127&&(o=l));break;case 3:a=e[t+1],u=e[t+2],(a&192)===128&&(u&192)===128&&(l=(i&15)<<12|(a&63)<<6|u&63,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:a=e[t+1],u=e[t+2],c=e[t+3],(a&192)===128&&(u&192)===128&&(c&192)===128&&(l=(i&15)<<18|(a&63)<<12|(u&63)<<6|c&63,l>65535&&l<1114112&&(o=l))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),t+=s}return Sy(n)}var Tc=4096;function Sy(e){let t=e.length;if(t<=Tc)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Tc));return r}var Cy=256,ro=class{constructor(t=Cy){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 i=r.length-(this.maxCursor-this.cursor)-1;r.set(t,i)}else{if(r){let i=r.length-(this.maxCursor-this.cursor)-1;i<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,i),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=xc(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=hn(n,0,this.cursor)}else r=Ic(this.chunks,this.cursor);return t&&this.reset(),r}};var ve="CBOR decode error:",Qs="CBOR encode error:",ei=[];ei[23]=1;ei[24]=2;ei[25]=3;ei[26]=5;ei[27]=9;function rr(e,t,r){if(e.length-t<r)throw new Error(`${ve} not enough data for type`)}var qe=[24,256,65536,4294967296,BigInt("18446744073709551616")];function ut(e,t,r){rr(e,t,1);let n=e[t];if(r.strict===!0&&n<qe[0])throw new Error(`${ve} integer encoded in more bytes than necessary (strict decode)`);return n}function ct(e,t,r){rr(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<qe[1])throw new Error(`${ve} integer encoded in more bytes than necessary (strict decode)`);return n}function ft(e,t,r){rr(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<qe[2])throw new Error(`${ve} integer encoded in more bytes than necessary (strict decode)`);return n}function lt(e,t,r){rr(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],i=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],o=(BigInt(n)<<BigInt(32))+BigInt(i);if(r.strict===!0&&o<qe[3])throw new Error(`${ve} integer encoded in more bytes than necessary (strict decode)`);if(o<=Number.MAX_SAFE_INTEGER)return Number(o);if(r.allowBigInt===!0)return o;throw new Error(`${ve} integers outside of the safe integer range are not supported`)}function Cc(e,t,r,n){return new fe(K.uint,ut(e,t+1,n),2)}function Nc(e,t,r,n){return new fe(K.uint,ct(e,t+1,n),3)}function Rc(e,t,r,n){return new fe(K.uint,ft(e,t+1,n),5)}function $c(e,t,r,n){return new fe(K.uint,lt(e,t+1,n),9)}function vt(e,t){return Je(e,0,t.value)}function Je(e,t,r){if(r<qe[0]){let n=Number(r);e.push([t|n])}else if(r<qe[1]){let n=Number(r);e.push([t|24,n])}else if(r<qe[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<qe[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<qe[4]){let i=[t|27,0,0,0,0,0,0,0],o=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,e.push(i)}else throw new Error(`${ve} encountered BigInt larger than allowable range`)}}vt.encodedSize=function(t){return Je.encodedSize(t.value)};Je.encodedSize=function(t){return t<qe[0]?1:t<qe[1]?2:t<qe[2]?3:t<qe[3]?5:9};vt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Pc(e,t,r,n){return new fe(K.negint,-1-ut(e,t+1,n),2)}function Uc(e,t,r,n){return new fe(K.negint,-1-ct(e,t+1,n),3)}function Bc(e,t,r,n){return new fe(K.negint,-1-ft(e,t+1,n),5)}var Zs=BigInt(-1),Dc=BigInt(1);function Mc(e,t,r,n){let i=lt(e,t+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new fe(K.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${ve} integers outside of the safe integer range are not supported`);return new fe(K.negint,Zs-BigInt(i),9)}function no(e,t){let r=t.value,n=typeof r=="bigint"?r*Zs-Dc:r*-1-1;Je(e,t.type.majorEncoded,n)}no.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Zs-Dc:r*-1-1;return n<qe[0]?1:n<qe[1]?2:n<qe[2]?3:n<qe[3]?5:9};no.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function ti(e,t,r,n){rr(e,t,r+n);let i=hn(e,t+r,t+r+n);return new fe(K.bytes,i,r+n)}function Lc(e,t,r,n){return ti(e,t,1,r)}function kc(e,t,r,n){return ti(e,t,2,ut(e,t+1,n))}function jc(e,t,r,n){return ti(e,t,3,ct(e,t+1,n))}function Fc(e,t,r,n){return ti(e,t,5,ft(e,t+1,n))}function Vc(e,t,r,n){let i=lt(e,t+1,n);if(typeof i=="bigint")throw new Error(`${ve} 64-bit integer bytes lengths not supported`);return ti(e,t,9,i)}function io(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===K.string?Ec(e.value):e.value),e.encodedBytes}function yn(e,t){let r=io(t);Je(e,t.type.majorEncoded,r.length),e.push(r)}yn.encodedSize=function(t){let r=io(t);return Je.encodedSize(r.length)+r.length};yn.compareTokens=function(t,r){return Ry(io(t),io(r))};function Ry(e,t){return e.length<t.length?-1:e.length>t.length?1:Sc(e,t)}function ri(e,t,r,n,i){let o=r+n;rr(e,t,o);let s=new fe(K.string,Oc(e,t+r,t+o),o);return i.retainStringBytes===!0&&(s.byteValue=hn(e,t+r,t+o)),s}function zc(e,t,r,n){return ri(e,t,1,r,n)}function Kc(e,t,r,n){return ri(e,t,2,ut(e,t+1,n),n)}function qc(e,t,r,n){return ri(e,t,3,ct(e,t+1,n),n)}function Gc(e,t,r,n){return ri(e,t,5,ft(e,t+1,n),n)}function Wc(e,t,r,n){let i=lt(e,t+1,n);if(typeof i=="bigint")throw new Error(`${ve} 64-bit integer string lengths not supported`);return ri(e,t,9,i,n)}var Hc=yn;function gn(e,t,r,n){return new fe(K.array,n,r)}function Jc(e,t,r,n){return gn(e,t,1,r)}function Xc(e,t,r,n){return gn(e,t,2,ut(e,t+1,n))}function Yc(e,t,r,n){return gn(e,t,3,ct(e,t+1,n))}function Qc(e,t,r,n){return gn(e,t,5,ft(e,t+1,n))}function Zc(e,t,r,n){let i=lt(e,t+1,n);if(typeof i=="bigint")throw new Error(`${ve} 64-bit integer array lengths not supported`);return gn(e,t,9,i)}function ef(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${ve} indefinite length items not allowed`);return gn(e,t,1,1/0)}function oo(e,t){Je(e,K.array.majorEncoded,t.value)}oo.compareTokens=vt.compareTokens;oo.encodedSize=function(t){return Je.encodedSize(t.value)};function mn(e,t,r,n){return new fe(K.map,n,r)}function tf(e,t,r,n){return mn(e,t,1,r)}function rf(e,t,r,n){return mn(e,t,2,ut(e,t+1,n))}function nf(e,t,r,n){return mn(e,t,3,ct(e,t+1,n))}function of(e,t,r,n){return mn(e,t,5,ft(e,t+1,n))}function sf(e,t,r,n){let i=lt(e,t+1,n);if(typeof i=="bigint")throw new Error(`${ve} 64-bit integer map lengths not supported`);return mn(e,t,9,i)}function af(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${ve} indefinite length items not allowed`);return mn(e,t,1,1/0)}function so(e,t){Je(e,K.map.majorEncoded,t.value)}so.compareTokens=vt.compareTokens;so.encodedSize=function(t){return Je.encodedSize(t.value)};function uf(e,t,r,n){return new fe(K.tag,r,1)}function cf(e,t,r,n){return new fe(K.tag,ut(e,t+1,n),2)}function ff(e,t,r,n){return new fe(K.tag,ct(e,t+1,n),3)}function lf(e,t,r,n){return new fe(K.tag,ft(e,t+1,n),5)}function df(e,t,r,n){return new fe(K.tag,lt(e,t+1,n),9)}function ao(e,t){Je(e,K.tag.majorEncoded,t.value)}ao.compareTokens=vt.compareTokens;ao.encodedSize=function(t){return Je.encodedSize(t.value)};var My=20,Ly=21,ky=22,jy=23;function pf(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${ve} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new fe(K.null,null,1):new fe(K.undefined,void 0,1)}function hf(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${ve} indefinite length items not allowed`);return new fe(K.break,void 0,1)}function ea(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${ve} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${ve} Infinity values are not supported`)}return new fe(K.float,e,t)}function yf(e,t,r,n){return ea(ta(e,t+1),3,n)}function gf(e,t,r,n){return ea(ra(e,t+1),5,n)}function mf(e,t,r,n){return ea(wf(e,t+1),9,n)}function uo(e,t,r){let n=t.value;if(n===!1)e.push([K.float.majorEncoded|My]);else if(n===!0)e.push([K.float.majorEncoded|Ly]);else if(n===null)e.push([K.float.majorEncoded|ky]);else if(n===void 0)e.push([K.float.majorEncoded|jy]);else{let i,o=!1;(!r||r.float64!==!0)&&(vf(n),i=ta(Bt,1),n===i||Number.isNaN(n)?(Bt[0]=249,e.push(Bt.slice(0,3)),o=!0):(_f(n),i=ra(Bt,1),n===i&&(Bt[0]=250,e.push(Bt.slice(0,5)),o=!0))),o||(Fy(n),i=wf(Bt,1),Bt[0]=251,e.push(Bt.slice(0,9)))}}uo.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){vf(n);let i=ta(Bt,1);if(n===i||Number.isNaN(n))return 3;if(_f(n),i=ra(Bt,1),n===i)return 5}return 9};var bf=new ArrayBuffer(9),_t=new DataView(bf,1),Bt=new Uint8Array(bf,0);function vf(e){if(e===1/0)_t.setUint16(0,31744,!1);else if(e===-1/0)_t.setUint16(0,64512,!1);else if(Number.isNaN(e))_t.setUint16(0,32256,!1);else{_t.setFloat32(0,e);let t=_t.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)_t.setUint16(0,31744,!1);else if(r===0)_t.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?_t.setUint16(0,0):i<-14?_t.setUint16(0,(t&2147483648)>>16|1<<24+i,!1):_t.setUint16(0,(t&2147483648)>>16|i+15<<10|n>>13,!1)}}}function ta(e,t){if(e.length-t<2)throw new Error(`${ve} 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,i=r&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,r&32768?-o:o}function _f(e){_t.setFloat32(0,e,!1)}function ra(e,t){if(e.length-t<4)throw new Error(`${ve} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Fy(e){_t.setFloat64(0,e,!1)}function wf(e,t){if(e.length-t<8)throw new Error(`${ve} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}uo.compareTokens=vt.compareTokens;function Ee(e,t,r){throw new Error(`${ve} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function co(e){return()=>{throw new Error(`${ve} ${e}`)}}var ue=[];for(let e=0;e<=23;e++)ue[e]=Ee;ue[24]=Cc;ue[25]=Nc;ue[26]=Rc;ue[27]=$c;ue[28]=Ee;ue[29]=Ee;ue[30]=Ee;ue[31]=Ee;for(let e=32;e<=55;e++)ue[e]=Ee;ue[56]=Pc;ue[57]=Uc;ue[58]=Bc;ue[59]=Mc;ue[60]=Ee;ue[61]=Ee;ue[62]=Ee;ue[63]=Ee;for(let e=64;e<=87;e++)ue[e]=Lc;ue[88]=kc;ue[89]=jc;ue[90]=Fc;ue[91]=Vc;ue[92]=Ee;ue[93]=Ee;ue[94]=Ee;ue[95]=co("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)ue[e]=zc;ue[120]=Kc;ue[121]=qc;ue[122]=Gc;ue[123]=Wc;ue[124]=Ee;ue[125]=Ee;ue[126]=Ee;ue[127]=co("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)ue[e]=Jc;ue[152]=Xc;ue[153]=Yc;ue[154]=Qc;ue[155]=Zc;ue[156]=Ee;ue[157]=Ee;ue[158]=Ee;ue[159]=ef;for(let e=160;e<=183;e++)ue[e]=tf;ue[184]=rf;ue[185]=nf;ue[186]=of;ue[187]=sf;ue[188]=Ee;ue[189]=Ee;ue[190]=Ee;ue[191]=af;for(let e=192;e<=215;e++)ue[e]=uf;ue[216]=cf;ue[217]=ff;ue[218]=lf;ue[219]=df;ue[220]=Ee;ue[221]=Ee;ue[222]=Ee;ue[223]=Ee;for(let e=224;e<=243;e++)ue[e]=co("simple values are not supported");ue[244]=Ee;ue[245]=Ee;ue[246]=Ee;ue[247]=pf;ue[248]=co("simple values are not supported");ue[249]=yf;ue[250]=gf;ue[251]=mf;ue[252]=Ee;ue[253]=Ee;ue[254]=Ee;ue[255]=hf;var Dt=[];for(let e=0;e<24;e++)Dt[e]=new fe(K.uint,e,1);for(let e=-1;e>=-24;e--)Dt[31-e]=new fe(K.negint,e,1);Dt[64]=new fe(K.bytes,new Uint8Array(0),1);Dt[96]=new fe(K.string,"",1);Dt[128]=new fe(K.array,0,1);Dt[160]=new fe(K.map,0,1);Dt[244]=new fe(K.false,!1,1);Dt[245]=new fe(K.true,!0,1);Dt[246]=new fe(K.null,null,1);function na(){let e=[];return e[K.uint.major]=vt,e[K.negint.major]=no,e[K.bytes.major]=yn,e[K.string.major]=Hc,e[K.array.major]=oo,e[K.map.major]=so,e[K.tag.major]=ao,e[K.float.major]=uo,e}var hN=na(),yN=new ro,lo=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(`${Qs} object contains circular references`);return new e(r,t)}},yr={null:new fe(K.null,null),undefined:new fe(K.undefined,void 0),true:new fe(K.true,!0),false:new fe(K.false,!1),emptyArray:new fe(K.array,0),emptyMap:new fe(K.map,0)},gr={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new fe(K.float,e):e>=0?new fe(K.uint,e):new fe(K.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new fe(K.uint,e):new fe(K.negint,e)},Uint8Array(e,t,r,n){return new fe(K.bytes,e)},string(e,t,r,n){return new fe(K.string,e)},boolean(e,t,r,n){return e?yr.true:yr.false},null(e,t,r,n){return yr.null},undefined(e,t,r,n){return yr.undefined},ArrayBuffer(e,t,r,n){return new fe(K.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new fe(K.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[yr.emptyArray,new fe(K.break)]:yr.emptyArray;n=lo.createCheck(n,e);let i=[],o=0;for(let s of e)i[o++]=fo(s,r,n);return r.addBreakTokens?[new fe(K.array,e.length),i,new fe(K.break)]:[new fe(K.array,e.length),i]},Object(e,t,r,n){let i=t!=="Object",o=i?e.keys():Object.keys(e),s=i?e.size:o.length;if(!s)return r.addBreakTokens===!0?[yr.emptyMap,new fe(K.break)]:yr.emptyMap;n=lo.createCheck(n,e);let a=[],u=0;for(let c of o)a[u++]=[fo(c,r,n),fo(i?e.get(c):e[c],r,n)];return Ky(a,r),r.addBreakTokens?[new fe(K.map,s),a,new fe(K.break)]:[new fe(K.map,s),a]}};gr.Map=gr.Object;gr.Buffer=gr.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))gr[`${e}Array`]=gr.DataView;function fo(e,t={},r){let n=vc(e),i=t&&t.typeEncoders&&t.typeEncoders[n]||gr[n];if(typeof i=="function"){let s=i(e,n,t,r);if(s!=null)return s}let o=gr[n];if(!o)throw new Error(`${Qs} unsupported type: ${n}`);return o(e,n,t,r)}function Ky(e,t){t.mapSorter&&e.sort(t.mapSorter)}var qy={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},ia=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=Dt[t];if(r===void 0){let n=ue[t];if(!n)throw new Error(`${ve} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let i=t&31;r=n(this.data,this._pos,i,this.options)}return this._pos+=r.encodedLength,r}},ni=Symbol.for("DONE"),po=Symbol.for("BREAK");function Gy(e,t,r){let n=[];for(let i=0;i<e.value;i++){let o=ii(t,r);if(o===po){if(e.value===1/0)break;throw new Error(`${ve} got unexpected break to lengthed array`)}if(o===ni)throw new Error(`${ve} found array but not enough entries (got ${i}, expected ${e.value})`);n[i]=o}return n}function Wy(e,t,r){let n=r.useMaps===!0,i=n?void 0:{},o=n?new Map:void 0;for(let s=0;s<e.value;s++){let a=ii(t,r);if(a===po){if(e.value===1/0)break;throw new Error(`${ve} got unexpected break to lengthed map`)}if(a===ni)throw new Error(`${ve} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${ve} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&o.has(a)||!n&&a in i))throw new Error(`${ve} found repeat map key "${a}"`);let u=ii(t,r);if(u===ni)throw new Error(`${ve} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?o.set(a,u):i[a]=u}return n?o:i}function ii(e,t){if(e.done())return ni;let r=e.next();if(r.type===K.break)return po;if(r.type.terminal)return r.value;if(r.type===K.array)return Gy(r,e,t);if(r.type===K.map)return Wy(r,e,t);if(r.type===K.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=ii(e,t);return t.tags[r.value](n)}throw new Error(`${ve} tag not supported (${r.value})`)}throw new Error("unsupported")}function Tf(e,t){if(!(e instanceof Uint8Array))throw new Error(`${ve} data to decode must be a Uint8Array`);t=Object.assign({},qy,t);let r=t.tokenizer||new ia(e,t),n=ii(r,t);if(n===ni)throw new Error(`${ve} did not find any content to decode`);if(n===po)throw new Error(`${ve} got unexpected break`);return[n,e.subarray(r.pos())]}function oa(e,t){let[r,n]=Tf(e,t);if(n.length>0)throw new Error(`${ve} too many terminals, data makes no sense`);return r}var ON=new Uint8Array(0);function Af(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 bn(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 Xy(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 i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,u=e.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function p(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var z=0,W=0,T=0,k=E.length;T!==k&&E[T]===0;)T++,z++;for(var G=(k-T)*l+1>>>0,H=new Uint8Array(G);T!==k;){for(var F=E[T],Y=0,V=G-1;(F!==0||Y<W)&&V!==-1;V--,Y++)F+=256*H[V]>>>0,H[V]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");W=Y,T++}for(var ae=G-W;ae!==G&&H[ae]===0;)ae++;for(var L=u.repeat(z);ae<G;++ae)L+=e.charAt(H[ae]);return L}function S(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var z=0;if(E[z]!==" "){for(var W=0,T=0;E[z]===u;)W++,z++;for(var k=(E.length-z)*c+1>>>0,G=new Uint8Array(k);E[z];){var H=r[E.charCodeAt(z)];if(H===255)return;for(var F=0,Y=k-1;(H!==0||F<T)&&Y!==-1;Y--,F++)H+=a*G[Y]>>>0,G[Y]=H%256>>>0,H=H/256>>>0;if(H!==0)throw new Error("Non-zero carry");T=F,z++}if(E[z]!==" "){for(var V=k-T;V!==k&&G[V]===0;)V++;for(var ae=new Uint8Array(W+(k-V)),L=W;V!==k;)ae[L++]=G[V++];return ae}}}function x(E){var z=S(E);if(z)return z;throw new Error(`Non-${t} character`)}return{encode:p,decodeUnsafe:S,decode:x}}var Yy=Xy,Qy=Yy,Of=Qy;var sa=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")}},aa=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let i=r.codePointAt(0);if(i===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i,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 Ef(this,t)}},ua=class{decoders;constructor(t){this.decoders=t}or(t){return Ef(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 Ef(e,t){return new ua({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ca=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,i){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new sa(t,r,n),this.decoder=new aa(t,r,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function If({name:e,prefix:t,encode:r,decode:n}){return new ca(e,t,r,n)}function vn({name:e,prefix:t,alphabet:r}){let{encode:n,decode:i}=Of(r,e);return If({prefix:t,name:e,encode:n,decode:o=>bn(i(o))})}function Zy(e,t,r,n){let i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,u=0,c=0;for(let l=0;l<o;++l){let p=i[e[l]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<r|p,a+=r,a>=8&&(a-=8,s[c++]=255&u>>a)}if(a>=r||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return s}function eg(e,t,r){let n=t[t.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let u=0;u<e.length;++u)for(a=a<<8|e[u],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(s!==0&&(o+=t[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o}function qt({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return If({prefix:t,name:e,encode(i){return eg(i,n,r)},decode(i){return Zy(i,n,r,e)}})}var oi=qt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),RN=qt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$N=qt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),PN=qt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),UN=qt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),BN=qt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),DN=qt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),MN=qt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),LN=qt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ho=vn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),FN=vn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var nr=vn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),KN=vn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var tg=Cf,xf=128,rg=127,ng=~rg,ig=Math.pow(2,31);function Cf(e,t,r){t=t||[],r=r||0;for(var n=r;e>=ig;)t[r++]=e&255|xf,e/=128;for(;e&ng;)t[r++]=e&255|xf,e>>>=7;return t[r]=e|0,Cf.bytes=r-n+1,t}var og=fa,sg=128,Sf=127;function fa(e,n){var r=0,n=n||0,i=0,o=n,s,a=e.length;do{if(o>=a)throw fa.bytes=0,new RangeError("Could not decode varint");s=e[o++],r+=i<28?(s&Sf)<<i:(s&Sf)*Math.pow(2,i),i+=7}while(s>=sg);return fa.bytes=o-n,r}var ag=Math.pow(2,7),ug=Math.pow(2,14),cg=Math.pow(2,21),fg=Math.pow(2,28),lg=Math.pow(2,35),dg=Math.pow(2,42),pg=Math.pow(2,49),hg=Math.pow(2,56),yg=Math.pow(2,63),gg=function(e){return e<ag?1:e<ug?2:e<cg?3:e<fg?4:e<lg?5:e<dg?6:e<pg?7:e<hg?8:e<yg?9:10},mg={encode:tg,decode:og,encodingLength:gg},bg=mg,si=bg;function ai(e,t=0){return[si.decode(e,t),si.decode.bytes]}function _n(e,t,r=0){return si.encode(e,t,r),t}function wn(e){return si.encodingLength(e)}function Rf(e,t){let r=t.byteLength,n=wn(e),i=n+wn(r),o=new Uint8Array(i+r);return _n(e,o,0),_n(r,o,n),o.set(t,i),new Tn(e,r,t,o)}function $f(e){let t=bn(e),[r,n]=ai(t),[i,o]=ai(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Tn(r,i,s,t)}function Pf(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Af(e.bytes,r.bytes)}}var Tn=class{code;size;digest;bytes;constructor(t,r,n,i){this.code=t,this.size=r,this.digest=n,this.bytes=i}};function Uf(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return wg(r,la(e),t??nr.encoder);default:return Tg(r,la(e),t??oi.encoder)}}var Bf=new WeakMap;function la(e){let t=Bf.get(e);if(t==null){let r=new Map;return Bf.set(e,r),r}return t}var ci=class e{code;version;multihash;bytes;"/";constructor(t,r,n,i){this.code=r,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}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!==ui)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ag)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=Rf(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&&Pf(t.multihash,n.multihash)}toString(t){return Uf(this,t)}toJSON(){return{"/":Uf(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:i,multihash:o,bytes:s}=r;return new e(n,i,o,s??Df(n,i,o.bytes))}else if(r[Og]===!0){let{version:n,multihash:i,code:o}=r,s=$f(i);return e.create(n,o,s)}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!==ui)throw new Error(`Version 0 CID must use dag-pb (code: ${ui}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let i=Df(t,r,n.bytes);return new e(t,r,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ui,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,i=bn(t.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let o=i.subarray(r.multihashSize-r.digestSize),s=new Tn(r.multihashCode,r.digestSize,o,i);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[p,S]=ai(t.subarray(r));return r+=S,p},i=n(),o=ui;if(i===18?(i=0,r=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,a=n(),u=n(),c=r+u,l=c-s;return{version:i,codec:o,multihashCode:a,digestSize:u,multihashSize:l,size:c}}static parse(t,r){let[n,i]=_g(t,r),o=e.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return la(o).set(n,t),o}};function _g(e,t){switch(e[0]){case"Q":{let r=t??nr;return[nr.prefix,r.decode(`${nr.prefix}${e}`)]}case nr.prefix:{let r=t??nr;return[nr.prefix,r.decode(e)]}case oi.prefix:{let r=t??oi;return[oi.prefix,r.decode(e)]}case ho.prefix:{let r=t??ho;return[ho.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function wg(e,t,r){let{prefix:n}=r;if(n!==nr.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=t.get(n);if(i==null){let o=r.encode(e).slice(1);return t.set(n,o),o}else return i}function Tg(e,t,r){let{prefix:n}=r,i=t.get(n);if(i==null){let o=r.encode(e);return t.set(n,o),o}else return i}var ui=112,Ag=18;function Df(e,t,r){let n=wn(e),i=n+wn(t),o=new Uint8Array(i+r.byteLength);return _n(e,o,0),_n(t,o,n),o.set(r,i),o}var Og=Symbol.for("@ipld/js-cid/CID");var Lf=42;function Eg(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=ci.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new fe(K.tag,Lf),new fe(K.bytes,r)]}function Ig(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function xg(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 Mf={float64:!0,typeEncoders:{Object:Eg,undefined:Ig,number:xg}},rR={...Mf,typeEncoders:{...Mf.typeEncoders}};function Sg(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return ci.decode(e.subarray(1))}var yo={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};yo.tags[Lf]=Sg;var nR={...yo,tags:yo.tags.slice()};var da=e=>oa(e,yo);var mr=Js(go(),1),fi={SHA2_256:18,LENGTH:32,DAG_PB:112},ya=40;function An(e,t){if(!e.length)throw new Error("Unexpected end of data");let r=mr.default.decode(e);return t.seek(mr.default.decode.bytes),r}function ga(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))}}function ma(e){mr.default.decode(e);let t=mr.default.decode.bytes,r=mr.default.decode(e.subarray(mr.default.decode.bytes)),n=mr.default.decode.bytes;return t+n+r}var br={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},li={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":br.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(br.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=li["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let i=t;i<e.length;i++){let o=e[i];if(o=li["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](o),o===void 0)return;n.push(o)}return n}}return e}},Int:br.Int,CarV1HeaderOrV2Pragma:e=>{if(br.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let i=0;i<t.length;i++){let[o,s]=t[i];switch(o){case"roots":{let a=li["CarV1HeaderOrV2Pragma > roots (anon)"](e[o]);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.roots=a}}break;case"version":{n--;let a=li.Int(e[o]);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},di={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":br.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(br.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=di["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let i=t;i<e.length;i++){let o=e[i];if(o=di["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](o),o===void 0)return;n.push(o)}return n}}return e}},Int:br.Int,CarV1HeaderOrV2Pragma:e=>{if(br.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let i=0;i<t.length;i++){let[o,s]=t[i];switch(o){case"roots":{let a=di["CarV1HeaderOrV2Pragma > roots (anon)"](s);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.roots=a}}break;case"version":{n--;let a=di.Int(s);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},ba={toTyped:li.CarV1HeaderOrV2Pragma,toRepresentation:di.CarV1HeaderOrV2Pragma};var bR=na();var Gg=Js(go(),1);var AR=[new fe(K.map,2),new fe(K.string,"version"),new fe(K.uint,1),new fe(K.string,"roots")],OR=new fe(K.tag,42);async function va(e,t){let r=An(await e.upTo(8),e);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await e.exactly(r,!0),i=da(n);if(ba.toTyped(i)===void 0)throw new Error("Invalid CAR header format");if(i.version!==1&&i.version!==2||t!==void 0&&i.version!==t)throw new Error(`Invalid CAR version: ${i.version}${t!==void 0?` (expected ${t})`:""}`);if(i.version===1){if(!Array.isArray(i.roots))throw new Error("Invalid CAR header format");return i}if(i.roots!==void 0)throw new Error("Invalid CAR header format");let o=ga(await e.exactly(ya,!0));e.seek(o.dataOffset-e.pos);let s=await va(e,1);return Object.assign(s,o)}async function Hg(e){let t=await e.exactly(2,!1);if(t[0]===fi.SHA2_256&&t[1]===fi.LENGTH){let s=await e.exactly(34,!0),a=eo(s);return tr.create(0,fi.DAG_PB,a)}let r=An(await e.upTo(8),e);if(r!==1)throw new Error(`Unexpected CID version (${r})`);let n=An(await e.upTo(8),e),i=await e.exactly(ma(await e.upTo(8)),!0),o=eo(i);return tr.create(r,n,o)}async function Hf(e){let t=e.pos,r=An(await e.upTo(8),e);if(r===0)throw new Error("Invalid CAR section (zero length)");r+=e.pos-t;let n=await Hg(e),i=r-Number(e.pos-t);return{cid:n,length:r,blockLength:i}}async function Jg(e){let{cid:t,blockLength:r}=await Hf(e);return{bytes:await e.exactly(r,!0),cid:t}}async function Xg(e){let t=e.pos,{cid:r,length:n,blockLength:i}=await Hf(e),o={cid:r,length:n,blockLength:i,offset:t,blockOffset:e.pos};return e.seek(o.blockLength),o}function mo(e){let t=(async()=>{let r=await va(e);if(r.version===2){let n=e.pos-r.dataOffset;e=Qg(e,r.dataSize-n)}return r})();return{header:()=>t,async*blocks(){for(await t;(await e.upTo(8)).length>0;)yield await Jg(e)},async*blocksIndex(){for(await t;(await e.upTo(8)).length>0;)yield await Xg(e)}}}function pi(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 i=e.subarray(t,t+r);return n&&(t+=r),i},seek(r){t+=r},get pos(){return t}}}function Yg(e){let t=0,r=0,n=0,i=new Uint8Array(0),o=async s=>{r=i.length-n;let a=[i.subarray(n)];for(;r<s;){let c=await e();if(c==null)break;r<0?c.length>r&&a.push(c.subarray(-r)):a.push(c),r+=c.length}i=new Uint8Array(a.reduce((c,l)=>c+l.length,0));let u=0;for(let c of a)i.set(c,u),u+=c.length;n=0};return{async upTo(s){return i.length-n<s&&await o(s),i.subarray(n,n+Math.min(i.length-n,s))},async exactly(s,a=!1){if(i.length-n<s&&await o(s),i.length-n<s)throw new Error("Unexpected end of data");let u=i.subarray(n,n+s);return a&&(t+=s,n+=s),u},seek(s){t+=s,n+=s},get pos(){return t}}}function bo(e){let t=e[Symbol.asyncIterator]();async function r(){let n=await t.next();return n.done?null:n.value}return Yg(r)}function Qg(e,t){let r=0;return{async upTo(n){let i=await e.upTo(n);return i.length+r>t&&(i=i.subarray(0,t-r)),i},async exactly(n,i=!1){let o=await e.exactly(n,i);if(o.length+r>t)throw new Error("Unexpected end of data");return i&&(r+=n),o},seek(n){r+=n,e.seek(n)},get pos(){return e.pos}}}var Dr=class{constructor(t,r){this._header=t,this._blocks=r,this._keys=r.map(n=>n.cid.toString())}get version(){return this._header.version}async getRoots(){return this._header.roots}async has(t){return this._keys.indexOf(t.toString())>-1}async get(t){let r=this._keys.indexOf(t.toString());return r>-1?this._blocks[r]:void 0}async*blocks(){for(let t of this._blocks)yield t}async*cids(){for(let t of this._blocks)yield t.cid}static async fromBytes(t){if(!(t instanceof Uint8Array))throw new TypeError("fromBytes() requires a Uint8Array");return Jf(pi(t))}static async fromIterable(t){if(!t||typeof t[Symbol.asyncIterator]!="function")throw new TypeError("fromIterable() requires an async iterable");return Jf(bo(t))}};async function Jf(e){let t=mo(e),r=await t.header(),n=[];for await(let i of t.blocks())n.push(i);return new Dr(r,n)}var em=Js(go(),1);var tm={0:"Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'",1:function(t,r){return"Cannot apply '"+t+"' to '"+r.toString()+"': Field not found."},5:"'keys()' can only be used on observable objects, arrays, sets and maps",6:"'values()' can only be used on observable objects, arrays, sets and maps",7:"'entries()' can only be used on observable objects, arrays and maps",8:"'set()' can only be used on observable objects, arrays and maps",9:"'remove()' can only be used on observable objects, arrays and maps",10:"'has()' can only be used on observable objects, arrays and maps",11:"'get()' can only be used on observable objects, arrays and maps",12:"Invalid annotation",13:"Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",14:"Intercept handlers should return nothing or a change object",15:"Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",16:"Modification exception: the internal structure of an observable array was changed.",17:function(t,r){return"[mobx.array] Index out of bounds, "+t+" is larger than "+r},18:"mobx.map requires Map polyfill for the current browser. Check babel-polyfill or core-js/es6/map.js",19:function(t){return"Cannot initialize from classes that inherit from Map: "+t.constructor.name},20:function(t){return"Cannot initialize map from "+t},21:function(t){return"Cannot convert to map from '"+t+"'"},22:"mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js",23:"It is not possible to get index atoms from arrays",24:function(t){return"Cannot obtain administration from "+t},25:function(t,r){return"the entry '"+t+"' does not exist in the observable map '"+r+"'"},26:"please specify a property",27:function(t,r){return"no observable property '"+t.toString()+"' found on the observable object '"+r+"'"},28:function(t){return"Cannot obtain atom from "+t},29:"Expecting some object",30:"invalid action stack. did you forget to finish an action?",31:"missing option for computed: get",32:function(t,r){return"Cycle detected in computation "+t+": "+r},33:function(t){return"The setter of computed value '"+t+"' is trying to update itself. Did you intend to update an _observable_ value, instead of the computed property?"},34:function(t){return"[ComputedValue '"+t+"'] It is not possible to assign a new value to a computed value."},35:"There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`",36:"isolateGlobalState should be called before MobX is running any reactions",37:function(t){return"[mobx] `observableArray."+t+"()` mutates the array in-place, which is not allowed inside a derivation. Use `array.slice()."+t+"()` instead"},38:"'ownKeys()' can only be used on observable objects",39:"'defineProperty()' can only be used on observable objects"},rm=tm;function le(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=typeof e=="string"?e:rm[e];throw typeof i=="function"&&(i=i.apply(null,r)),new Error("[MobX] "+i)}var nm={};function Pa(){return typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:nm}var ll=Object.assign,xo=Object.getOwnPropertyDescriptor,Wt=Object.defineProperty,vi=Object.prototype,So=[];Object.freeze(So);var Ua={};Object.freeze(Ua);var im=typeof Proxy<"u",om=Object.toString();function dl(){im||le("`Proxy` objects are not available in the current environment. Please configure MobX to enable a fallback implementation.`")}function hi(e){Q.verifyProxies&&le("MobX is currently configured to be able to run in ES5 mode, but in ES5 MobX won't be able to "+e)}function St(){return++Q.mobxGuid}function Ba(e){var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}var En=function(){};function je(e){return typeof e=="function"}function Lr(e){var t=typeof e;switch(t){case"string":case"symbol":case"number":return!0}return!1}function Do(e){return e!==null&&typeof e=="object"}function jt(e){if(!Do(e))return!1;var t=Object.getPrototypeOf(e);if(t==null)return!0;var r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r.toString()===om}function pl(e){var t=e?.constructor;return t?t.name==="GeneratorFunction"||t.displayName==="GeneratorFunction":!1}function Mo(e,t,r){Wt(e,t,{enumerable:!1,writable:!0,configurable:!0,value:r})}function hl(e,t,r){Wt(e,t,{enumerable:!1,writable:!1,configurable:!0,value:r})}function wr(e,t){var r="isMobX"+e;return t.prototype[r]=!0,function(n){return Do(n)&&n[r]===!0}}function Nn(e){return e instanceof Map}function _i(e){return e instanceof Set}var yl=typeof Object.getOwnPropertySymbols<"u";function sm(e){var t=Object.keys(e);if(!yl)return t;var r=Object.getOwnPropertySymbols(e);return r.length?[].concat(t,r.filter(function(n){return vi.propertyIsEnumerable.call(e,n)})):t}var Lo=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:yl?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function Ta(e){return typeof e=="string"?e:typeof e=="symbol"?e.toString():new String(e).toString()}function gl(e){return e===null?null:typeof e=="object"?""+e:e}function Et(e,t){return vi.hasOwnProperty.call(e,t)}var am=Object.getOwnPropertyDescriptors||function(t){var r={};return Lo(t).forEach(function(n){r[n]=xo(t,n)}),r};function Xf(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,fm(n.key),n)}}function Da(e,t,r){return t&&Xf(e.prototype,t),r&&Xf(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function sr(){return sr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},sr.apply(this,arguments)}function ml(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Aa(e,t)}function Aa(e,t){return Aa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Aa(e,t)}function Ao(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function um(e,t){if(e){if(typeof e=="string")return Yf(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Yf(e,t)}}function Yf(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function In(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=um(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cm(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function fm(e){var t=cm(e,"string");return typeof t=="symbol"?t:String(t)}var ot=Symbol("mobx-stored-annotations");function Ht(e){function t(r,n){if(wi(n))return e.decorate_20223_(r,n);Rn(r,n,e)}return Object.assign(t,e)}function Rn(e,t,r){if(Et(e,ot)||Mo(e,ot,sr({},e[ot])),Co(r)&&!Et(e[ot],t)){var n=e.constructor.name+".prototype."+t.toString();le("'"+n+"' is decorated with 'override', but no such decorated member was found on prototype.")}lm(e,r,t),Co(r)||(e[ot][t]=r)}function lm(e,t,r){if(!Co(t)&&Et(e[ot],r)){var n=e.constructor.name+".prototype."+r.toString(),i=e[ot][r].annotationType_,o=t.annotationType_;le("Cannot apply '@"+o+"' to '"+n+"':"+(`
|
|
3
3
|
The field is already decorated with '@`+i+"'.")+`
|
|
4
4
|
Re-decorating fields is not allowed.
|
|
@@ -58,7 +58,7 @@ ${Z}`),J.pop(),`{${C}}`}case"number":return isFinite(O)?String(O):k?k(O):"null";
|
|
|
58
58
|
`+" ".repeat(t+1)):o==="}"&&n===1?(n--,r+=`
|
|
59
59
|
`+" ".repeat(t)+o):o==="{"&&n>0?(n++,r+=o):(o==="}"&&n>1&&n--,r+=o)}return r}var{WARN:ld,LOG:L$,DEBUG:Ev,VERBOSE:k$,ERROR:Jr}=$e.setup($e.INFO,{prefix:"[thread]"});function Yt(e){return e.init!==void 0}var gs=class{constructor(e,t,r,n=[],i={}){this.name=e,this._applogs=n,this.parents=t===null?null:fd(t),this.filters=r,Re(()=>this.parents?.length===0)&&ld("[Thread] empty parents array",e),i.skipObservable||Tr(this,{applogsCids:Me,applogsByCid:Me,insert:st,size:Me,isEmpty:Me,firstLog:Me,latestLog:Me},{name:`Thread{${e}}`})}filters;parents;_subscribers=[];get readOnly(){return this.parents.length!==1?!0:this.parents[0].readOnly}insert(e){if(this.readOnly)throw Jr("[Thread] insert() called on read-only thread:",this.nameAndSizeUntracked);if(!this.parents)throw Jr("[Thread] insert() called on non-writable thread without parents:",this.nameAndSizeUntracked);if(this.parents?.length!==1)throw Jr("[Thread] insert() called on thread with multiple parents:",this.nameAndSizeUntracked);return this.parents[0].insert(e)}insertRaw(e){if(this.readOnly)throw Jr("[Thread] insertRaw() called on read-only thread:",this.nameAndSizeUntracked);if(!this.parents)throw Jr("[Thread] insertRaw() called on non-writable thread without parents:",this.nameAndSizeUntracked);if(this.parents?.length!==1)throw Jr("[Thread] insertRaw() called on thread with multiple parents:",this.nameAndSizeUntracked);return this.parents[0].insertRaw(e)}subscribe(e){return this._subscribers.push(e),this.unsubscribe.bind(this,e)}unsubscribe(e){let t=this._subscribers.indexOf(e);t!==-1?this._subscribers.splice(t,1):ld("unsubscribe called for non-existent",e)}notifySubscribers(e){Ev(`[thread: ${this.name}] notifying`,this._subscribers.length,"subscribers of",{...e,subs:this._subscribers});for(let t of this._subscribers)t(e)}get applogs(){return this._applogs}get applogsCids(){return this._applogs.map(e=>e.cid)}map(e){return this.applogs.map(e)}get findLast(){return this.applogs.findLast.bind(this.applogs)}get findFirst(){return this.applogs.find.bind(this.applogs)}get firstLog(){return this.applogs[0]}get latestLog(){return this.applogs[this.applogs.length-1]}hasApplog(e,t){if(t)return this.applogs.includes(e);if(!e.cid)throw Jr("[hasApplogs] applog without CID:",e);return this.hasApplogCid(e.cid)}hasApplogCid(e){return this.applogsCids.includes(e.toString())}get applogsByCid(){return new Map(this.applogs.map(e=>[e.cid,e]))}getApplog(e){return this.applogsByCid.get(e.toString())}hasApplogWithDiffTs(e){return this.applogs.find(t=>t.en===e.en&&t.at===e.at&&t.vl===e.vl&&t.ag===e.ag)}get isEmpty(){return this.size===0}get size(){return this.applogs.length}get length(){return this.applogs.length}get untrackedSize(){return Re(()=>this.size)}get nameAndSizeUntracked(){return Re(()=>`${this.name} (${this.size})`)}get prettyName(){return Ov(this.name)}get hasParents(){return!!this.parents?.length}};var _u=class Ep extends gs{static fromArray(t,r){return new Ep(r||"static",null,[],t)}constructor(t,r,n,i){super(t,r,n,i,{skipObservable:!0})}get readOnly(){return!0}},Ip={};Wa(Ip,{code:()=>Gp,decode:()=>Ts,encode:()=>Bu,format:()=>wd,name:()=>Nw,parse:()=>$w,stringify:()=>wd});var Iv=["string","number","bigint","symbol"],xv=["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 Sv(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Iv.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Cv(e))return"Buffer";let r=Nv(e);return r||"Object"}function Cv(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Nv(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(xv.includes(t))return t}var B=class{constructor(e,t,r){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=r}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};B.uint=new B(0,"uint",!0);B.negint=new B(1,"negint",!0);B.bytes=new B(2,"bytes",!0);B.string=new B(3,"string",!0);B.array=new B(4,"array",!1);B.map=new B(5,"map",!1);B.tag=new B(6,"tag",!1);B.float=new B(7,"float",!0);B.false=new B(7,"false",!0);B.true=new B(7,"true",!0);B.null=new B(7,"null",!0);B.undefined=new B(7,"undefined",!0);B.break=new B(7,"break",!0);var ee=class{constructor(e,t,r){this.type=e,this.value=t,this.encodedLength=r,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}},Fn=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Rv=new TextDecoder,$v=new TextEncoder;function Yo(e){return Fn&&globalThis.Buffer.isBuffer(e)}function wu(e){return e instanceof Uint8Array?Yo(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Pv=Fn?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):pd(e,t,r):(e,t,r)=>r-t>64?Rv.decode(e.subarray(t,r)):pd(e,t,r),xp=Fn?e=>e.length>64?globalThis.Buffer.from(e):dd(e):e=>e.length>64?$v.encode(e):dd(e);var Tu=Fn?(e,t,r)=>Yo(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Uv=Fn?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),wu(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let i of e)n+i.length>r.length&&(i=i.subarray(0,r.length-n)),r.set(i,n),n+=i.length;return r},Bv=Fn?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Dv(e,t){if(Yo(e)&&Yo(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 dd(e){let t=[],r=0;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=i&63|128):(i&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=i&63|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=i&63|128)}return t}function pd(e,t,r){let n=[];for(;t<r;){let i=e[t],o=null,s=i>239?4:i>223?3:i>191?2:1;if(t+s<=r){let a,u,c,l;switch(s){case 1:i<128&&(o=i);break;case 2:a=e[t+1],(a&192)===128&&(l=(i&31)<<6|a&63,l>127&&(o=l));break;case 3:a=e[t+1],u=e[t+2],(a&192)===128&&(u&192)===128&&(l=(i&15)<<12|(a&63)<<6|u&63,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:a=e[t+1],u=e[t+2],c=e[t+3],(a&192)===128&&(u&192)===128&&(c&192)===128&&(l=(i&15)<<18|(a&63)<<12|(u&63)<<6|c&63,l>65535&&l<1114112&&(o=l))}}o===null?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),t+=s}return Sp(n)}var hd=4096;function Sp(e){let t=e.length;if(t<=hd)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=hd));return r}var Mv=256,Cp=class{constructor(e=Mv){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let n=t.length-(this.maxCursor-this.cursor)-1;t.set(e,n)}else{if(t){let n=t.length-(this.maxCursor-this.cursor)-1;n<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,n),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=Bv(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let r=this.chunks[0];e&&this.cursor>r.length/2?(t=this.cursor===r.length?r:r.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Tu(r,0,this.cursor)}else t=Uv(this.chunks,this.cursor);return e&&this.reset(),t}},ye="CBOR decode error:",Qr="CBOR encode error:",Fi=[];Fi[23]=1;Fi[24]=2;Fi[25]=3;Fi[26]=5;Fi[27]=9;function Vn(e,t,r){if(e.length-t<r)throw new Error(`${ye} not enough data for type`)}var Ye=[24,256,65536,4294967296,BigInt("18446744073709551616")];function tn(e,t,r){Vn(e,t,1);let n=e[t];if(r.strict===!0&&n<Ye[0])throw new Error(`${ye} integer encoded in more bytes than necessary (strict decode)`);return n}function rn(e,t,r){Vn(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<Ye[1])throw new Error(`${ye} integer encoded in more bytes than necessary (strict decode)`);return n}function nn(e,t,r){Vn(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<Ye[2])throw new Error(`${ye} integer encoded in more bytes than necessary (strict decode)`);return n}function on(e,t,r){Vn(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],i=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],o=(BigInt(n)<<BigInt(32))+BigInt(i);if(r.strict===!0&&o<Ye[3])throw new Error(`${ye} integer encoded in more bytes than necessary (strict decode)`);if(o<=Number.MAX_SAFE_INTEGER)return Number(o);if(r.allowBigInt===!0)return o;throw new Error(`${ye} integers outside of the safe integer range are not supported`)}function Lv(e,t,r,n){return new ee(B.uint,tn(e,t+1,n),2)}function kv(e,t,r,n){return new ee(B.uint,rn(e,t+1,n),3)}function jv(e,t,r,n){return new ee(B.uint,nn(e,t+1,n),5)}function Fv(e,t,r,n){return new ee(B.uint,on(e,t+1,n),9)}function sn(e,t){return Pt(e,0,t.value)}function Pt(e,t,r){if(r<Ye[0]){let n=Number(r);e.push([t|n])}else if(r<Ye[1]){let n=Number(r);e.push([t|24,n])}else if(r<Ye[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<Ye[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<Ye[4]){let i=[t|27,0,0,0,0,0,0,0],o=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,e.push(i)}else throw new Error(`${ye} encountered BigInt larger than allowable range`)}}sn.encodedSize=function(t){return Pt.encodedSize(t.value)};Pt.encodedSize=function(t){return t<Ye[0]?1:t<Ye[1]?2:t<Ye[2]?3:t<Ye[3]?5:9};sn.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Vv(e,t,r,n){return new ee(B.negint,-1-tn(e,t+1,n),2)}function zv(e,t,r,n){return new ee(B.negint,-1-rn(e,t+1,n),3)}function Kv(e,t,r,n){return new ee(B.negint,-1-nn(e,t+1,n),5)}var Au=BigInt(-1),Np=BigInt(1);function qv(e,t,r,n){let i=on(e,t+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new ee(B.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${ye} integers outside of the safe integer range are not supported`);return new ee(B.negint,Au-BigInt(i),9)}function Ou(e,t){let r=t.value,n=typeof r=="bigint"?r*Au-Np:r*-1-1;Pt(e,t.type.majorEncoded,n)}Ou.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Au-Np:r*-1-1;return n<Ye[0]?1:n<Ye[1]?2:n<Ye[2]?3:n<Ye[3]?5:9};Ou.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Vi(e,t,r,n){Vn(e,t,r+n);let i=Tu(e,t+r,t+r+n);return new ee(B.bytes,i,r+n)}function Gv(e,t,r,n){return Vi(e,t,1,r)}function Wv(e,t,r,n){return Vi(e,t,2,tn(e,t+1,n))}function Hv(e,t,r,n){return Vi(e,t,3,rn(e,t+1,n))}function Jv(e,t,r,n){return Vi(e,t,5,nn(e,t+1,n))}function Xv(e,t,r,n){let i=on(e,t+1,n);if(typeof i=="bigint")throw new Error(`${ye} 64-bit integer bytes lengths not supported`);return Vi(e,t,9,i)}function Qo(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===B.string?xp(e.value):e.value),e.encodedBytes}function ms(e,t){let r=Qo(t);Pt(e,t.type.majorEncoded,r.length),e.push(r)}ms.encodedSize=function(t){let r=Qo(t);return Pt.encodedSize(r.length)+r.length};ms.compareTokens=function(t,r){return Yv(Qo(t),Qo(r))};function Yv(e,t){return e.length<t.length?-1:e.length>t.length?1:Dv(e,t)}function zi(e,t,r,n,i){let o=r+n;Vn(e,t,o);let s=new ee(B.string,Pv(e,t+r,t+o),o);return i.retainStringBytes===!0&&(s.byteValue=Tu(e,t+r,t+o)),s}function Qv(e,t,r,n){return zi(e,t,1,r,n)}function Zv(e,t,r,n){return zi(e,t,2,tn(e,t+1,n),n)}function e_(e,t,r,n){return zi(e,t,3,rn(e,t+1,n),n)}function t_(e,t,r,n){return zi(e,t,5,nn(e,t+1,n),n)}function r_(e,t,r,n){let i=on(e,t+1,n);if(typeof i=="bigint")throw new Error(`${ye} 64-bit integer string lengths not supported`);return zi(e,t,9,i,n)}var n_=ms;function zn(e,t,r,n){return new ee(B.array,n,r)}function i_(e,t,r,n){return zn(e,t,1,r)}function o_(e,t,r,n){return zn(e,t,2,tn(e,t+1,n))}function s_(e,t,r,n){return zn(e,t,3,rn(e,t+1,n))}function a_(e,t,r,n){return zn(e,t,5,nn(e,t+1,n))}function u_(e,t,r,n){let i=on(e,t+1,n);if(typeof i=="bigint")throw new Error(`${ye} 64-bit integer array lengths not supported`);return zn(e,t,9,i)}function c_(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${ye} indefinite length items not allowed`);return zn(e,t,1,1/0)}function Eu(e,t){Pt(e,B.array.majorEncoded,t.value)}Eu.compareTokens=sn.compareTokens;Eu.encodedSize=function(t){return Pt.encodedSize(t.value)};function Kn(e,t,r,n){return new ee(B.map,n,r)}function f_(e,t,r,n){return Kn(e,t,1,r)}function l_(e,t,r,n){return Kn(e,t,2,tn(e,t+1,n))}function d_(e,t,r,n){return Kn(e,t,3,rn(e,t+1,n))}function p_(e,t,r,n){return Kn(e,t,5,nn(e,t+1,n))}function h_(e,t,r,n){let i=on(e,t+1,n);if(typeof i=="bigint")throw new Error(`${ye} 64-bit integer map lengths not supported`);return Kn(e,t,9,i)}function y_(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${ye} indefinite length items not allowed`);return Kn(e,t,1,1/0)}function Iu(e,t){Pt(e,B.map.majorEncoded,t.value)}Iu.compareTokens=sn.compareTokens;Iu.encodedSize=function(t){return Pt.encodedSize(t.value)};function g_(e,t,r,n){return new ee(B.tag,r,1)}function m_(e,t,r,n){return new ee(B.tag,tn(e,t+1,n),2)}function b_(e,t,r,n){return new ee(B.tag,rn(e,t+1,n),3)}function v_(e,t,r,n){return new ee(B.tag,nn(e,t+1,n),5)}function __(e,t,r,n){return new ee(B.tag,on(e,t+1,n),9)}function xu(e,t){Pt(e,B.tag.majorEncoded,t.value)}xu.compareTokens=sn.compareTokens;xu.encodedSize=function(t){return Pt.encodedSize(t.value)};var w_=20,T_=21,A_=22,O_=23;function E_(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${ye} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new ee(B.null,null,1):new ee(B.undefined,void 0,1)}function I_(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${ye} indefinite length items not allowed`);return new ee(B.break,void 0,1)}function Su(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${ye} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${ye} Infinity values are not supported`)}return new ee(B.float,e,t)}function x_(e,t,r,n){return Su(Nu(e,t+1),3,n)}function S_(e,t,r,n){return Su(Ru(e,t+1),5,n)}function C_(e,t,r,n){return Su(Up(e,t+1),9,n)}function Cu(e,t,r){let n=t.value;if(n===!1)e.push([B.float.majorEncoded|w_]);else if(n===!0)e.push([B.float.majorEncoded|T_]);else if(n===null)e.push([B.float.majorEncoded|A_]);else if(n===void 0)e.push([B.float.majorEncoded|O_]);else{let i,o=!1;(!r||r.float64!==!0)&&($p(n),i=Nu(zt,1),n===i||Number.isNaN(n)?(zt[0]=249,e.push(zt.slice(0,3)),o=!0):(Pp(n),i=Ru(zt,1),n===i&&(zt[0]=250,e.push(zt.slice(0,5)),o=!0))),o||(N_(n),i=Up(zt,1),zt[0]=251,e.push(zt.slice(0,9)))}}Cu.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){$p(n);let i=Nu(zt,1);if(n===i||Number.isNaN(n))return 3;if(Pp(n),i=Ru(zt,1),n===i)return 5}return 9};var Rp=new ArrayBuffer(9),Rt=new DataView(Rp,1),zt=new Uint8Array(Rp,0);function $p(e){if(e===1/0)Rt.setUint16(0,31744,!1);else if(e===-1/0)Rt.setUint16(0,64512,!1);else if(Number.isNaN(e))Rt.setUint16(0,32256,!1);else{Rt.setFloat32(0,e);let t=Rt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Rt.setUint16(0,31744,!1);else if(r===0)Rt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let i=r-127;i<-24?Rt.setUint16(0,0):i<-14?Rt.setUint16(0,(t&2147483648)>>16|1<<24+i,!1):Rt.setUint16(0,(t&2147483648)>>16|i+15<<10|n>>13,!1)}}}function Nu(e,t){if(e.length-t<2)throw new Error(`${ye} 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,i=r&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,r&32768?-o:o}function Pp(e){Rt.setFloat32(0,e,!1)}function Ru(e,t){if(e.length-t<4)throw new Error(`${ye} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function N_(e){Rt.setFloat64(0,e,!1)}function Up(e,t){if(e.length-t<8)throw new Error(`${ye} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Cu.compareTokens=sn.compareTokens;function xe(e,t,r){throw new Error(`${ye} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function bs(e){return()=>{throw new Error(`${ye} ${e}`)}}var ce=[];for(let e=0;e<=23;e++)ce[e]=xe;ce[24]=Lv;ce[25]=kv;ce[26]=jv;ce[27]=Fv;ce[28]=xe;ce[29]=xe;ce[30]=xe;ce[31]=xe;for(let e=32;e<=55;e++)ce[e]=xe;ce[56]=Vv;ce[57]=zv;ce[58]=Kv;ce[59]=qv;ce[60]=xe;ce[61]=xe;ce[62]=xe;ce[63]=xe;for(let e=64;e<=87;e++)ce[e]=Gv;ce[88]=Wv;ce[89]=Hv;ce[90]=Jv;ce[91]=Xv;ce[92]=xe;ce[93]=xe;ce[94]=xe;ce[95]=bs("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)ce[e]=Qv;ce[120]=Zv;ce[121]=e_;ce[122]=t_;ce[123]=r_;ce[124]=xe;ce[125]=xe;ce[126]=xe;ce[127]=bs("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)ce[e]=i_;ce[152]=o_;ce[153]=s_;ce[154]=a_;ce[155]=u_;ce[156]=xe;ce[157]=xe;ce[158]=xe;ce[159]=c_;for(let e=160;e<=183;e++)ce[e]=f_;ce[184]=l_;ce[185]=d_;ce[186]=p_;ce[187]=h_;ce[188]=xe;ce[189]=xe;ce[190]=xe;ce[191]=y_;for(let e=192;e<=215;e++)ce[e]=g_;ce[216]=m_;ce[217]=b_;ce[218]=v_;ce[219]=__;ce[220]=xe;ce[221]=xe;ce[222]=xe;ce[223]=xe;for(let e=224;e<=243;e++)ce[e]=bs("simple values are not supported");ce[244]=xe;ce[245]=xe;ce[246]=xe;ce[247]=E_;ce[248]=bs("simple values are not supported");ce[249]=x_;ce[250]=S_;ce[251]=C_;ce[252]=xe;ce[253]=xe;ce[254]=xe;ce[255]=I_;var Zt=[];for(let e=0;e<24;e++)Zt[e]=new ee(B.uint,e,1);for(let e=-1;e>=-24;e--)Zt[31-e]=new ee(B.negint,e,1);Zt[64]=new ee(B.bytes,new Uint8Array(0),1);Zt[96]=new ee(B.string,"",1);Zt[128]=new ee(B.array,0,1);Zt[160]=new ee(B.map,0,1);Zt[244]=new ee(B.false,!1,1);Zt[245]=new ee(B.true,!0,1);Zt[246]=new ee(B.null,null,1);function $u(){let e=[];return e[B.uint.major]=sn,e[B.negint.major]=Ou,e[B.bytes.major]=ms,e[B.string.major]=n_,e[B.array.major]=Eu,e[B.map.major]=Iu,e[B.tag.major]=xu,e[B.float.major]=Cu,e}var j$=$u(),Xa=new Cp,yd=class Bp{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(`${Qr} object contains circular references`);return new Bp(r,t)}},Ar={null:new ee(B.null,null),undefined:new ee(B.undefined,void 0),true:new ee(B.true,!0),false:new ee(B.false,!1),emptyArray:new ee(B.array,0),emptyMap:new ee(B.map,0)},xr={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new ee(B.float,e):e>=0?new ee(B.uint,e):new ee(B.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new ee(B.uint,e):new ee(B.negint,e)},Uint8Array(e,t,r,n){return new ee(B.bytes,e)},string(e,t,r,n){return new ee(B.string,e)},boolean(e,t,r,n){return e?Ar.true:Ar.false},null(e,t,r,n){return Ar.null},undefined(e,t,r,n){return Ar.undefined},ArrayBuffer(e,t,r,n){return new ee(B.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new ee(B.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Ar.emptyArray,new ee(B.break)]:Ar.emptyArray;n=yd.createCheck(n,e);let i=[],o=0;for(let s of e)i[o++]=qo(s,r,n);return r.addBreakTokens?[new ee(B.array,e.length),i,new ee(B.break)]:[new ee(B.array,e.length),i]},Object(e,t,r,n){let i=t!=="Object",o=i?e.keys():Object.keys(e),s=i?e.size:o.length;if(!s)return r.addBreakTokens===!0?[Ar.emptyMap,new ee(B.break)]:Ar.emptyMap;n=yd.createCheck(n,e);let a=[],u=0;for(let c of o)a[u++]=[qo(c,r,n),qo(i?e.get(c):e[c],r,n)];return R_(a,r),r.addBreakTokens?[new ee(B.map,s),a,new ee(B.break)]:[new ee(B.map,s),a]}};xr.Map=xr.Object;xr.Buffer=xr.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))xr[`${e}Array`]=xr.DataView;function qo(e,t={},r){let n=Sv(e),i=t&&t.typeEncoders&&t.typeEncoders[n]||xr[n];if(typeof i=="function"){let s=i(e,n,t,r);if(s!=null)return s}let o=xr[n];if(!o)throw new Error(`${Qr} unsupported type: ${n}`);return o(e,n,t,r)}function R_(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Dp(e,t,r,n){if(Array.isArray(t))for(let i of t)Dp(e,i,r,n);else r[t.type.major](e,t,n)}function $_(e,t,r){let n=qo(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let i=r.quickEncodeToken(n);if(i)return i;let o=t[n.type.major];if(o.encodedSize){let s=o.encodedSize(n,r),a=new Cp(s);if(o(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return wu(a.chunks[0])}}return Xa.reset(),Dp(Xa,n,t,r),Xa.toBytes(!0)}var P_={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},U_=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=Zt[e];if(t===void 0){let r=ce[e];if(!r)throw new Error(`${ye} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let n=e&31;t=r(this.data,this._pos,n,this.options)}return this._pos+=t.encodedLength,t}},Ui=Symbol.for("DONE"),vs=Symbol.for("BREAK");function B_(e,t,r){let n=[];for(let i=0;i<e.value;i++){let o=Bi(t,r);if(o===vs){if(e.value===1/0)break;throw new Error(`${ye} got unexpected break to lengthed array`)}if(o===Ui)throw new Error(`${ye} found array but not enough entries (got ${i}, expected ${e.value})`);n[i]=o}return n}function D_(e,t,r){let n=r.useMaps===!0,i=n?void 0:{},o=n?new Map:void 0;for(let s=0;s<e.value;s++){let a=Bi(t,r);if(a===vs){if(e.value===1/0)break;throw new Error(`${ye} got unexpected break to lengthed map`)}if(a===Ui)throw new Error(`${ye} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${ye} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&o.has(a)||!n&&a in i))throw new Error(`${ye} found repeat map key "${a}"`);let u=Bi(t,r);if(u===Ui)throw new Error(`${ye} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?o.set(a,u):i[a]=u}return n?o:i}function Bi(e,t){if(e.done())return Ui;let r=e.next();if(r.type===B.break)return vs;if(r.type.terminal)return r.value;if(r.type===B.array)return B_(r,e,t);if(r.type===B.map)return D_(r,e,t);if(r.type===B.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Bi(e,t);return t.tags[r.value](n)}throw new Error(`${ye} tag not supported (${r.value})`)}throw new Error("unsupported")}function M_(e,t){if(!(e instanceof Uint8Array))throw new Error(`${ye} data to decode must be a Uint8Array`);t=Object.assign({},P_,t);let r=t.tokenizer||new U_(e,t),n=Bi(r,t);if(n===Ui)throw new Error(`${ye} did not find any content to decode`);if(n===vs)throw new Error(`${ye} got unexpected break`);return[n,e.subarray(r.pos())]}function Mp(e,t){let[r,n]=M_(e,t);if(n.length>0)throw new Error(`${ye} too many terminals, data makes no sense`);return r}var L_=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let t=this.inRecursive[this.inRecursive.length-1];t&&(t.type===B.array&&(t.elements++,t.elements!==1&&e.push([44])),t.type===B.map&&(t.elements++,t.elements!==1&&(t.elements%2===1?e.push([44]):e.push([58]))))}[B.uint.major](e,t){this.prefix(e);let r=String(t.value),n=[];for(let i=0;i<r.length;i++)n[i]=r.charCodeAt(i);e.push(n)}[B.negint.major](e,t){this[B.uint.major](e,t)}[B.bytes.major](e,t){throw new Error(`${Qr} unsupported type: Uint8Array`)}[B.string.major](e,t){this.prefix(e);let r=xp(JSON.stringify(t.value));e.push(r.length>32?wu(r):r)}[B.array.major](e,t){this.prefix(e),this.inRecursive.push({type:B.array,elements:0}),e.push([91])}[B.map.major](e,t){this.prefix(e),this.inRecursive.push({type:B.map,elements:0}),e.push([123])}[B.tag.major](e,t){}[B.float.major](e,t){if(t.type.name==="break"){let o=this.inRecursive.pop();if(o){if(o.type===B.array)e.push([93]);else if(o.type===B.map)e.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(t.value===void 0)throw new Error(`${Qr} unsupported type: undefined`);if(this.prefix(e),t.type.name==="true"){e.push([116,114,117,101]);return}else if(t.type.name==="false"){e.push([102,97,108,115,101]);return}else if(t.type.name==="null"){e.push([110,117,108,108]);return}let r=String(t.value),n=[],i=!1;for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o),!i&&(n[o]===46||n[o]===101||n[o]===69)&&(i=!0);i||(n.push(46),n.push(48)),e.push(n)}};function k_(e,t){if(Array.isArray(e[0])||Array.isArray(t[0]))throw new Error(`${Qr} complex map keys are not supported`);let r=e[0],n=t[0];if(r.type!==B.string||n.type!==B.string)throw new Error(`${Qr} non-string map keys are not supported`);if(r<n)return-1;if(r>n)return 1;throw new Error(`${Qr} unexpected duplicate map keys, this is not supported`)}var j_={addBreakTokens:!0,mapSorter:k_};function F_(e,t){return t=Object.assign({},j_,t),$_(e,new L_,t)}var Lp=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t,this.modeStack=["value"],this.lastToken=""}pos(){return this._pos}done(){return this._pos>=this.data.length}ch(){return this.data[this._pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;e===32||e===9||e===13||e===10;)e=this.data[++this._pos]}expect(e){if(this.data.length-this._pos<e.length)throw new Error(`${ye} unexpected end of input at position ${this._pos}`);for(let t=0;t<e.length;t++)if(this.data[this._pos++]!==e[t])throw new Error(`${ye} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this._pos,t=!1,r=!1,n=s=>{for(;!this.done();){let a=this.ch();if(s.includes(a))this._pos++;else break}};if(this.ch()===45&&(t=!0,this._pos++),this.ch()===48)if(this._pos++,this.ch()===46)this._pos++,r=!0;else return new ee(B.uint,0,this._pos-e);if(n([48,49,50,51,52,53,54,55,56,57]),t&&this._pos===e+1)throw new Error(`${ye} unexpected token at position ${this._pos}`);if(!this.done()&&this.ch()===46){if(r)throw new Error(`${ye} unexpected token at position ${this._pos}`);r=!0,this._pos++,n([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(r=!0,this._pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this._pos++,n([48,49,50,51,52,53,54,55,56,57]));let i=String.fromCharCode.apply(null,this.data.subarray(e,this._pos)),o=parseFloat(i);return r?new ee(B.float,o,this._pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(o)?new ee(o>=0?B.uint:B.negint,o,this._pos-e):new ee(o>=0?B.uint:B.negint,BigInt(i),this._pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${ye} unexpected character at position ${this._pos}; this shouldn't happen`);this._pos++;for(let i=this._pos,o=0;i<this.data.length&&o<65536;i++,o++){let s=this.data[i];if(s===92||s<32||s>=128)break;if(s===34){let a=String.fromCharCode.apply(null,this.data.subarray(this._pos,i));return this._pos=i+1,new ee(B.string,a,o)}}let e=this._pos,t=[],r=()=>{if(this._pos+4>=this.data.length)throw new Error(`${ye} unexpected end of unicode escape sequence at position ${this._pos}`);let i=0;for(let o=0;o<4;o++){let s=this.ch();if(s>=48&&s<=57)s-=48;else if(s>=97&&s<=102)s=s-97+10;else if(s>=65&&s<=70)s=s-65+10;else throw new Error(`${ye} unexpected unicode escape character at position ${this._pos}`);i=i*16+s,this._pos++}return i},n=()=>{let i=this.ch(),o=null,s=i>239?4:i>223?3:i>191?2:1;if(this._pos+s>this.data.length)throw new Error(`${ye} unexpected unicode sequence at position ${this._pos}`);let a,u,c,l;switch(s){case 1:i<128&&(o=i);break;case 2:a=this.data[this._pos+1],(a&192)===128&&(l=(i&31)<<6|a&63,l>127&&(o=l));break;case 3:a=this.data[this._pos+1],u=this.data[this._pos+2],(a&192)===128&&(u&192)===128&&(l=(i&15)<<12|(a&63)<<6|u&63,l>2047&&(l<55296||l>57343)&&(o=l));break;case 4:a=this.data[this._pos+1],u=this.data[this._pos+2],c=this.data[this._pos+3],(a&192)===128&&(u&192)===128&&(c&192)===128&&(l=(i&15)<<18|(a&63)<<12|(u&63)<<6|c&63,l>65535&&l<1114112&&(o=l))}o===null?(o=65533,s=1):o>65535&&(o-=65536,t.push(o>>>10&1023|55296),o=56320|o&1023),t.push(o),this._pos+=s};for(;!this.done();){let i=this.ch(),o;switch(i){case 92:if(this._pos++,this.done())throw new Error(`${ye} unexpected string termination at position ${this._pos}`);switch(o=this.ch(),this._pos++,o){case 34:case 39:case 92:case 47:t.push(o);break;case 98:t.push(8);break;case 116:t.push(9);break;case 110:t.push(10);break;case 102:t.push(12);break;case 114:t.push(13);break;case 117:t.push(r());break;default:throw new Error(`${ye} unexpected string escape character at position ${this._pos}`)}break;case 34:return this._pos++,new ee(B.string,Sp(t),this._pos-e);default:if(i<32)throw new Error(`${ye} invalid control character at position ${this._pos}`);i<128?(t.push(i),this._pos++):n()}}throw new Error(`${ye} unexpected end of string at position ${this._pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this._pos++,new ee(B.map,1/0,1);case 91:return this.modeStack.push("array-start"),this._pos++,new ee(B.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new ee(B.null,null,4);case 102:return this.expect([102,97,108,115,101]),new ee(B.false,!1,5);case 116:return this.expect([116,114,117,101]),new ee(B.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${ye} unexpected character at position ${this._pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this._pos++,this.skipWhitespace(),new ee(B.break,void 0,1);if(this.ch()!==44)throw new Error(`${ye} unexpected character at position ${this._pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this._pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this._pos++,this.skipWhitespace(),new ee(B.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this._pos++,this.skipWhitespace(),new ee(B.break,void 0,1);if(this.ch()!==44)throw new Error(`${ye} unexpected character at position ${this._pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this._pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this._pos++,this.skipWhitespace(),new ee(B.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${ye} unexpected character at position ${this._pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this._pos++,this.modeStack.push("obj-value"),e}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${ye} unexpected parse state at position ${this._pos}; this shouldn't happen`)}}};function V_(e,t){return t=Object.assign({tokenizer:new Lp(e,t)},t),Mp(e,t)}var F$=new Uint8Array(0);function z_(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 Pu(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 K_(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 i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,u=e.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function p(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var z=0,W=0,T=0,k=E.length;T!==k&&E[T]===0;)T++,z++;for(var G=(k-T)*l+1>>>0,H=new Uint8Array(G);T!==k;){for(var F=E[T],Y=0,V=G-1;(F!==0||Y<W)&&V!==-1;V--,Y++)F+=256*H[V]>>>0,H[V]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");W=Y,T++}for(var ae=G-W;ae!==G&&H[ae]===0;)ae++;for(var L=u.repeat(z);ae<G;++ae)L+=e.charAt(H[ae]);return L}function S(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var z=0;if(E[z]!==" "){for(var W=0,T=0;E[z]===u;)W++,z++;for(var k=(E.length-z)*c+1>>>0,G=new Uint8Array(k);E[z];){var H=r[E.charCodeAt(z)];if(H===255)return;for(var F=0,Y=k-1;(H!==0||F<T)&&Y!==-1;Y--,F++)H+=a*G[Y]>>>0,G[Y]=H%256>>>0,H=H/256>>>0;if(H!==0)throw new Error("Non-zero carry");T=F,z++}if(E[z]!==" "){for(var V=k-T;V!==k&&G[V]===0;)V++;for(var ae=new Uint8Array(W+(k-V)),L=W;V!==k;)ae[L++]=G[V++];return ae}}}function x(E){var z=S(E);if(z)return z;throw new Error(`Non-${t} character`)}return{encode:p,decodeUnsafe:S,decode:x}}var q_=K_,G_=q_,W_=G_,H_=class{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},J_=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return kp(this,e)}},X_=class{decoders;constructor(e){this.decoders=e}or(e){return kp(this,e)}decode(e){let t=e[0],r=this.decoders[t];if(r!=null)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function kp(e,t){return new X_({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Y_=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new H_(e,t,r),this.decoder=new J_(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function jp({name:e,prefix:t,encode:r,decode:n}){return new Y_(e,t,r,n)}function _s({name:e,prefix:t,alphabet:r}){let{encode:n,decode:i}=W_(r,e);return jp({prefix:t,name:e,encode:n,decode:o=>Pu(i(o))})}function Q_(e,t,r,n){let i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,u=0,c=0;for(let l=0;l<o;++l){let p=i[e[l]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<r|p,a+=r,a>=8&&(a-=8,s[c++]=255&u>>a)}if(a>=r||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Z_(e,t,r){let n=t[t.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let u=0;u<e.length;++u)for(a=a<<8|e[u],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(s!==0&&(o+=t[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o}function gt({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return jp({prefix:t,name:e,encode(i){return Z_(i,n,r)},decode(i){return Q_(i,n,r,e)}})}var Go=gt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),V$=gt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),z$=gt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),K$=gt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),q$=gt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),G$=gt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),W$=gt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),H$=gt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),J$=gt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Ir=_s({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),X$=_s({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Fp={};Wa(Fp,{Digest:()=>ws,create:()=>rs,decode:()=>Uu,equals:()=>zp});var ew=Vp,gd=128,tw=127,rw=~tw,nw=Math.pow(2,31);function Vp(e,t,r){t=t||[],r=r||0;for(var n=r;e>=nw;)t[r++]=e&255|gd,e/=128;for(;e&rw;)t[r++]=e&255|gd,e>>>=7;return t[r]=e|0,Vp.bytes=r-n+1,t}var iw=su,ow=128,md=127;function su(e,n){var r=0,n=n||0,i=0,o=n,s,a=e.length;do{if(o>=a)throw su.bytes=0,new RangeError("Could not decode varint");s=e[o++],r+=i<28?(s&md)<<i:(s&md)*Math.pow(2,i),i+=7}while(s>=ow);return su.bytes=o-n,r}var sw=Math.pow(2,7),aw=Math.pow(2,14),uw=Math.pow(2,21),cw=Math.pow(2,28),fw=Math.pow(2,35),lw=Math.pow(2,42),dw=Math.pow(2,49),pw=Math.pow(2,56),hw=Math.pow(2,63),yw=function(e){return e<sw?1:e<aw?2:e<uw?3:e<cw?4:e<fw?5:e<lw?6:e<dw?7:e<pw?8:e<hw?9:10},gw={encode:ew,decode:iw,encodingLength:yw},mw=gw,Zo=mw;function au(e,t=0){return[Zo.decode(e,t),Zo.decode.bytes]}function es(e,t,r=0){return Zo.encode(e,t,r),t}function ts(e){return Zo.encodingLength(e)}function rs(e,t){let r=t.byteLength,n=ts(e),i=n+ts(r),o=new Uint8Array(i+r);return es(e,o,0),es(r,o,n),o.set(t,i),new ws(e,r,t,o)}function Uu(e){let t=Pu(e),[r,n]=au(t),[i,o]=au(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new ws(r,i,s,t)}function zp(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&z_(e.bytes,r.bytes)}}var ws=class{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}};function bd(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return vw(r,uu(e),t??Ir.encoder);default:return _w(r,uu(e),t??Go.encoder)}}var vd=new WeakMap;function uu(e){let t=vd.get(e);if(t==null){let r=new Map;return vd.set(e,r),r}return t}var $t=class et{code;version;multihash;bytes;"/";constructor(t,r,n,i){this.code=r,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}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!==Ci)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==ww)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return et.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=rs(t,r);return et.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 et.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&zp(t.multihash,n.multihash)}toString(t){return bd(this,t)}toJSON(){return{"/":bd(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 et)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:o,bytes:s}=r;return new et(n,i,o,s??_d(n,i,o.bytes))}else if(r[Tw]===!0){let{version:n,multihash:i,code:o}=r,s=Uu(i);return et.create(n,o,s)}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!==Ci)throw new Error(`Version 0 CID must use dag-pb (code: ${Ci}) block encoding`);return new et(t,r,n,n.bytes)}case 1:{let i=_d(t,r,n.bytes);return new et(t,r,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return et.create(0,Ci,t)}static createV1(t,r){return et.create(1,t,r)}static decode(t){let[r,n]=et.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=et.inspectBytes(t),n=r.size-r.multihashSize,i=Pu(t.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let o=i.subarray(r.multihashSize-r.digestSize),s=new ws(r.multihashCode,r.digestSize,o,i);return[r.version===0?et.createV0(s):et.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[p,S]=au(t.subarray(r));return r+=S,p},i=n(),o=Ci;if(i===18?(i=0,r=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,a=n(),u=n(),c=r+u,l=c-s;return{version:i,codec:o,multihashCode:a,digestSize:u,multihashSize:l,size:c}}static parse(t,r){let[n,i]=bw(t,r),o=et.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return uu(o).set(n,t),o}};function bw(e,t){switch(e[0]){case"Q":{let r=t??Ir;return[Ir.prefix,r.decode(`${Ir.prefix}${e}`)]}case Ir.prefix:{let r=t??Ir;return[Ir.prefix,r.decode(e)]}case Go.prefix:{let r=t??Go;return[Go.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 vw(e,t,r){let{prefix:n}=r;if(n!==Ir.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=t.get(n);if(i==null){let o=r.encode(e).slice(1);return t.set(n,o),o}else return i}function _w(e,t,r){let{prefix:n}=r,i=t.get(n);if(i==null){let o=r.encode(e);return t.set(n,o),o}else return i}var Ci=112,ww=18;function _d(e,t,r){let n=ts(e),i=n+ts(t),o=new Uint8Array(i+r.byteLength);return es(e,o,0),es(t,o,n),o.set(r,i),o}var Tw=Symbol.for("@ipld/js-cid/CID");function Kp({name:e,code:t,encode:r}){return new Aw(e,t,r)}var Aw=class{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?rs(this.code,t):t.then(r=>rs(this.code,r))}else throw Error("Unknown type, must be binary type")}},qp=gt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Y$=gt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Q$=gt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Z$=gt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Ow(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=$t.asCID(e);if(!t)return null;let r=t.toString();return[new ee(B.map,1/0,1),new ee(B.string,"/",1),new ee(B.string,r,r.length),new ee(B.break,void 0,1)]}function ns(e){let t=qp.encode(e).slice(1);return[new ee(B.map,1/0,1),new ee(B.string,"/",1),new ee(B.map,1/0,1),new ee(B.string,"bytes",5),new ee(B.string,t,t.length),new ee(B.break,void 0,1),new ee(B.break,void 0,1)]}function Vt(e){return ns(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Ew(e){return ns(new Uint8Array(e))}function Iw(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function xw(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 Sw={typeEncoders:{Object:Ow,Buffer:ns,Uint8Array:ns,Int8Array:Vt,Uint16Array:Vt,Int16Array:Vt,Uint32Array:Vt,Int32Array:Vt,Float32Array:Vt,Float64Array:Vt,Uint8ClampedArray:Vt,BigInt64Array:Vt,BigUint64Array:Vt,DataView:Vt,ArrayBuffer:Ew,undefined:Iw,number:xw}},Cw=class extends Lp{constructor(e,t){super(e,t),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let e=this._next();if(e.type===B.map){let t=this._next();if(t.type===B.string&&t.value==="/"){let r=this._next();if(r.type===B.string){if(this._next().type!==B.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(r),new ee(B.tag,42,0)}if(r.type===B.map){let n=this._next();if(n.type===B.string&&n.value==="bytes"){let i=this._next();if(i.type===B.string){for(let s=0;s<2;s++)if(this._next().type!==B.break)throw new Error("Invalid encoded Bytes form");let o=qp.decode(`m${i.value}`);return new ee(B.bytes,o,i.value.length)}this.tokenBuffer.push(i)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}this.tokenBuffer.push(t)}return e}},cu={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};cu.tags[42]=$t.parse;var Nw="dag-json",Gp=297,Bu=e=>F_(e,Sw),Ts=e=>{let t=Object.assign(cu,{tokenizer:new Cw(e,cu)});return V_(e,t)},wd=e=>Rw.decode(Bu(e)),Rw=new TextDecoder,$w=e=>Ts(Pw.encode(e)),Pw=new TextEncoder;function Uw(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function Bw(e,...t){if(!Uw(e))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Td(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Dw(e,t){Bw(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}function Mw(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}var Ya=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Xt=(e,t)=>e<<32-t|e>>>t,Lw=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Lw)throw new Error("Non little-endian hardware is not supported");function kw(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function Wp(e){if(typeof e=="string"&&(e=kw(e)),!Mw(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}var jw=class{clone(){return this._cloneInto()}},eP={}.toString;function Fw(e){let t=n=>e().update(Wp(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Vw(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+c,a,n)}var zw=class extends jw{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ya(this.buffer)}update(e){Td(this);let{view:t,buffer:r,blockLen:n}=this;e=Wp(e);let i=e.length;for(let o=0;o<i;){let s=Math.min(n-this.pos,i-o);if(s===n){let a=Ya(e);for(;n<=i-o;o+=n)this.process(a,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Td(this),Dw(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:n,isLE:i}=this,{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let l=o;l<n;l++)t[l]=0;Vw(r,n-8,BigInt(this.length*8),i),this.process(r,0);let s=Ya(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)s.setUint32(4*l,c[l],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return e.length=n,e.pos=s,e.finished=i,e.destroyed=o,n%t&&e.buffer.set(r),e}},Kw=(e,t,r)=>e&t^~e&r,qw=(e,t,r)=>e&t^e&r^t&r,Gw=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Or=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Er=new Uint32Array(64),Ww=class extends zw{constructor(){super(64,32,8,!1),this.A=Or[0]|0,this.B=Or[1]|0,this.C=Or[2]|0,this.D=Or[3]|0,this.E=Or[4]|0,this.F=Or[5]|0,this.G=Or[6]|0,this.H=Or[7]|0}get(){let{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=e|0,this.B=t|0,this.C=r|0,this.D=n|0,this.E=i|0,this.F=o|0,this.G=s|0,this.H=a|0}process(e,t){for(let l=0;l<16;l++,t+=4)Er[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let p=Er[l-15],S=Er[l-2],x=Xt(p,7)^Xt(p,18)^p>>>3,E=Xt(S,17)^Xt(S,19)^S>>>10;Er[l]=E+Er[l-7]+x+Er[l-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let l=0;l<64;l++){let p=Xt(s,6)^Xt(s,11)^Xt(s,25),S=c+p+Kw(s,a,u)+Gw[l]+Er[l]|0,E=(Xt(r,2)^Xt(r,13)^Xt(r,22))+qw(r,n,i)|0;c=u,u=a,a=s,s=o+S|0,o=i,i=n,n=r,r=S+E|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,s,a,u,c)}roundClean(){Er.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}},Hw=Fw(()=>new Ww);var We=Nt(ur(),1),Hp=Nt(bv(),1),fu=e=>We.Type.Union([e,We.Type.Null()]);var Jp=/^(k51qz|baguq)[0-9a-z]{56,57}$/,Jw=/^[0-9A-Fa-f]{7,8}$/g;We.FormatRegistry.Set("EntityID",e=>!!e.match(Jw)||!!e.match(Jp));var Xp=We.Type.String(),As=e=>e?.enc instanceof Uint8Array;We.FormatRegistry.Set("CID",e=>!!e.match(Jp));var Du=We.Type.String({format:"CID"}),Xw=/^http([s]?):\/\/.*\..*/;We.FormatRegistry.Set("URL",e=>!!e.match(Xw));var Yw=We.Type.String({format:"URL"}),Mu=We.Type.Object({en:Xp,at:We.Type.String(),vl:fu(We.Type.Union([We.Type.String(),We.Type.Boolean(),We.Type.Number()])),ts:We.Type.String(),ag:We.Type.String(),pv:fu(Du)}),lu=Hp.TypeCompiler.Compile(Mu);var Qw=lu.Check.bind(lu),Yp=We.Type.Composite([We.Type.Object({cid:Du}),Mu]),is=Hp.TypeCompiler.Compile(Yp),Qp=e=>Array.from(is.Errors(e)),Lu=is.Check.bind(is),Zw=_s({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),tP=_s({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});function Zp(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var e0=Kp({name:"sha2-256",code:18,encode:Zp("SHA-256")}),rP=Kp({name:"sha2-512",code:19,encode:Zp("SHA-512")}),{WARN:Ad,LOG:nP,DEBUG:t0,VERBOSE:os,ERROR:r0}=$e.setup($e.INFO),eh=114;function ku(e,t=["cid"]){if(!e)throw r0("falsy log",e);let r=e.cid;if(As(e))return r||(r=Os(ju(e).bytes).toString()),Ad("preparing an encrypted applog - really?"),{log:e,cid:r};let n={};for(let[i,o]of Object.entries(e))o===void 0&&(Ad(`log.${i} is undefined, which is not allowed - encoding as null`,e),o=null),t.includes(i)?os("excluding app log",{key:i,val:o}):n[i]=o;return{log:n,cid:r}}function th(e){return Os(rh(e).bytes)}function rh(e){return ju(ku(e)?.log)}function Os(e){let t=Hw(e),r=Fp.create(e0.code,t),n=$t.create(1,Gp,r);return os("[getCidSync]",{bytes:e,hash:t,digest:r,cid:n}),n}function ju(e){t0("[encodeBlock]",e);let t=Bu(e);return{bytes:t,cid:Os(t)}}function Fu(e){let t=null,r=[];try{t=$t.parse(e)}catch(n){os("[retrieveThread] couldn't parse pubID with default base"),r.push(n)}if(!t)try{t=$t.parse(e,Zw)}catch(n){os("[retrieveThread] couldn't parse pubID with base36"),r.push(n)}return{cid:t,errors:t?null:r,isIpns:t&&nh(t)}}function nh(e){return e.code===eh}function du(e){return typeof e=="string"?$t.parse(e):typeof e.toV1!="function"?$t.decode(e.bytes):e}function Es(e,t){if(!e||!t)throw new Error(`[areCidsEqual] invalid params: ${e}, ${t}`);if(e===t)return!0;let r=du(e),n=du(t);return r.toV1().toString()===n.toV1().toString()}function Vu(e,t){return e instanceof Set?e.has(typeof t=="string"?t:t.toV1().toString()):e.some(r=>Es(r,t))}function Od(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function n0(e,t){let r=Od(e),n=Od(t);return+r<+n}var i0=typeof global=="object"&&global&&global.Object===Object&&global,ih=i0,o0=typeof self=="object"&&self&&self.Object===Object&&self,s0=ih||o0||Function("return this")(),mt=s0,a0=mt.Symbol,Qt=a0,oh=Object.prototype,u0=oh.hasOwnProperty,c0=oh.toString,Ni=Qt?Qt.toStringTag:void 0;function f0(e){var t=u0.call(e,Ni),r=e[Ni];try{e[Ni]=void 0;var n=!0}catch{}var i=c0.call(e);return n&&(t?e[Ni]=r:delete e[Ni]),i}var l0=f0,d0=Object.prototype,p0=d0.toString;function h0(e){return p0.call(e)}var y0=h0,g0="[object Null]",m0="[object Undefined]",Ed=Qt?Qt.toStringTag:void 0;function b0(e){return e==null?e===void 0?m0:g0:Ed&&Ed in Object(e)?l0(e):y0(e)}var qn=b0;function v0(e){return e!=null&&typeof e=="object"}var en=v0,_0="[object Symbol]";function w0(e){return typeof e=="symbol"||en(e)&&qn(e)==_0}var Ln=w0;function T0(e,t){for(var r=-1,n=e==null?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}var A0=T0,O0=Array.isArray,Kt=O0,E0=1/0,Id=Qt?Qt.prototype:void 0,xd=Id?Id.toString:void 0;function sh(e){if(typeof e=="string")return e;if(Kt(e))return A0(e,sh)+"";if(Ln(e))return xd?xd.call(e):"";var t=e+"";return t=="0"&&1/e==-E0?"-0":t}var I0=sh,x0=/\s/;function S0(e){for(var t=e.length;t--&&x0.test(e.charAt(t)););return t}var C0=S0,N0=/^\s+/;function R0(e){return e&&e.slice(0,C0(e)+1).replace(N0,"")}var $0=R0;function P0(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var cr=P0,Sd=NaN,U0=/^[-+]0x[0-9a-f]+$/i,B0=/^0b[01]+$/i,D0=/^0o[0-7]+$/i,M0=parseInt;function L0(e){if(typeof e=="number")return e;if(Ln(e))return Sd;if(cr(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=cr(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=$0(e);var r=B0.test(e);return r||D0.test(e)?M0(e.slice(2),r?2:8):U0.test(e)?Sd:+e}var k0=L0,Cd=1/0,j0=17976931348623157e292;function F0(e){if(!e)return e===0?e:0;if(e=k0(e),e===Cd||e===-Cd){var t=e<0?-1:1;return t*j0}return e===e?e:0}var V0=F0;function z0(e){var t=V0(e),r=t%1;return t===t?r?t-r:t:0}var Nd=z0;function K0(e){return e}var Is=K0,q0="[object AsyncFunction]",G0="[object Function]",W0="[object GeneratorFunction]",H0="[object Proxy]";function J0(e){if(!cr(e))return!1;var t=qn(e);return t==G0||t==W0||t==q0||t==H0}var ah=J0,X0=mt["__core-js_shared__"],Qa=X0,Rd=function(){var e=/[^.]+$/.exec(Qa&&Qa.keys&&Qa.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Y0(e){return!!Rd&&Rd in e}var Q0=Y0,Z0=Function.prototype,eT=Z0.toString;function tT(e){if(e!=null){try{return eT.call(e)}catch{}try{return e+""}catch{}}return""}var an=tT,rT=/[\\^$.*+?()[\]{}|]/g,nT=/^\[object .+?Constructor\]$/,iT=Function.prototype,oT=Object.prototype,sT=iT.toString,aT=oT.hasOwnProperty,uT=RegExp("^"+sT.call(aT).replace(rT,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function cT(e){if(!cr(e)||Q0(e))return!1;var t=ah(e)?uT:nT;return t.test(an(e))}var fT=cT;function lT(e,t){return e?.[t]}var dT=lT;function pT(e,t){var r=dT(e,t);return fT(r)?r:void 0}var un=pT,hT=un(mt,"WeakMap"),Di=hT,yT=Di&&new Di,ss=yT,gT=ss?function(e,t){return ss.set(e,t),e}:Is,uh=gT,$d=Object.create,mT=function(){function e(){}return function(t){if(!cr(t))return{};if($d)return $d(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}(),zu=mT;function bT(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=zu(e.prototype),n=e.apply(r,t);return cr(n)?n:r}}var Mi=bT,vT=1;function _T(e,t,r){var n=t&vT,i=Mi(e);function o(){var s=this&&this!==mt&&this instanceof o?i:e;return s.apply(n?r:this,arguments)}return o}var wT=_T;function TT(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var Ku=TT,AT=Math.max;function OT(e,t,r,n){for(var i=-1,o=e.length,s=r.length,a=-1,u=t.length,c=AT(o-s,0),l=Array(u+c),p=!n;++a<u;)l[a]=t[a];for(;++i<s;)(p||i<o)&&(l[r[i]]=e[i]);for(;c--;)l[a++]=e[i++];return l}var ch=OT,ET=Math.max;function IT(e,t,r,n){for(var i=-1,o=e.length,s=-1,a=r.length,u=-1,c=t.length,l=ET(o-a,0),p=Array(l+c),S=!n;++i<l;)p[i]=e[i];for(var x=i;++u<c;)p[x+u]=t[u];for(;++s<a;)(S||i<o)&&(p[x+r[s]]=e[i++]);return p}var fh=IT;function xT(e,t){for(var r=e.length,n=0;r--;)e[r]===t&&++n;return n}var ST=xT;function CT(){}var qu=CT,NT=4294967295;function as(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=NT,this.__views__=[]}as.prototype=zu(qu.prototype);as.prototype.constructor=as;var Gu=as;function RT(){}var lh=RT,$T=ss?function(e){return ss.get(e)}:lh,dh=$T,PT={},Pd=PT,UT=Object.prototype,BT=UT.hasOwnProperty;function DT(e){for(var t=e.name+"",r=Pd[t],n=BT.call(Pd,t)?r.length:0;n--;){var i=r[n],o=i.func;if(o==null||o==e)return i.name}return t}var MT=DT;function us(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}us.prototype=zu(qu.prototype);us.prototype.constructor=us;var pu=us;function LT(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var ph=LT;function kT(e){if(e instanceof Gu)return e.clone();var t=new pu(e.__wrapped__,e.__chain__);return t.__actions__=ph(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var jT=kT,FT=Object.prototype,VT=FT.hasOwnProperty;function cs(e){if(en(e)&&!Kt(e)&&!(e instanceof Gu)){if(e instanceof pu)return e;if(VT.call(e,"__wrapped__"))return jT(e)}return new pu(e)}cs.prototype=qu.prototype;cs.prototype.constructor=cs;var zT=cs;function KT(e){var t=MT(e),r=zT[t];if(typeof r!="function"||!(t in Gu.prototype))return!1;if(e===r)return!0;var n=dh(r);return!!n&&e===n[0]}var qT=KT,GT=800,WT=16,HT=Date.now;function JT(e){var t=0,r=0;return function(){var n=HT(),i=WT-(n-r);if(r=n,i>0){if(++t>=GT)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var hh=JT,XT=hh(uh),yh=XT,YT=/\{\n\/\* \[wrapped with (.+)\] \*/,QT=/,? & /;function ZT(e){var t=e.match(YT);return t?t[1].split(QT):[]}var eA=ZT,tA=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;function rA(e,t){var r=t.length;if(!r)return e;var n=r-1;return t[n]=(r>1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(tA,`{
|
|
60
60
|
/* [wrapped with `+t+`] */
|
|
61
|
-
`)}var nA=rA;function iA(e){return function(){return e}}var oA=iA,sA=function(){try{var e=un(Object,"defineProperty");return e({},"",{}),e}catch{}}(),fs=sA,aA=fs?function(e,t){return fs(e,"toString",{configurable:!0,enumerable:!1,value:oA(t),writable:!0})}:Is,uA=aA,cA=hh(uA),Wu=cA;function fA(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var lA=fA;function dA(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o<i;)if(t(e[o],o,e))return o;return-1}var pA=dA;function hA(e){return e!==e}var yA=hA;function gA(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1}var mA=gA;function bA(e,t,r){return t===t?mA(e,t,r):pA(e,yA,r)}var vA=bA;function _A(e,t){var r=e==null?0:e.length;return!!r&&vA(e,t,0)>-1}var wA=_A,TA=1,AA=2,OA=8,EA=16,IA=32,xA=64,SA=128,CA=256,NA=512,RA=[["ary",SA],["bind",TA],["bindKey",AA],["curry",OA],["curryRight",EA],["flip",NA],["partial",IA],["partialRight",xA],["rearg",CA]];function $A(e,t){return lA(RA,function(r){var n="_."+r[0];t&r[1]&&!wA(e,n)&&e.push(n)}),e.sort()}var PA=$A;function UA(e,t,r){var n=t+"";return Wu(e,nA(n,PA(eA(n),r)))}var gh=UA,BA=1,DA=2,MA=4,LA=8,Ud=32,Bd=64;function kA(e,t,r,n,i,o,s,a,u,c){var l=t&LA,p=l?s:void 0,S=l?void 0:s,x=l?o:void 0,E=l?void 0:o;t|=l?Ud:Bd,t&=~(l?Bd:Ud),t&MA||(t&=~(BA|DA));var z=[e,t,i,x,p,E,S,a,u,c],W=r.apply(void 0,z);return qT(e)&&yh(W,z),W.placeholder=n,gh(W,e,t)}var mh=kA;function jA(e){var t=e;return t.placeholder}var Hu=jA,FA=9007199254740991,VA=/^(?:0|[1-9]\d*)$/;function zA(e,t){var r=typeof e;return t=t??FA,!!t&&(r=="number"||r!="symbol"&&VA.test(e))&&e>-1&&e%1==0&&e<t}var xs=zA,KA=Math.min;function qA(e,t){for(var r=e.length,n=KA(t.length,r),i=ph(e);n--;){var o=t[n];e[n]=xs(o,r)?i[o]:void 0}return e}var GA=qA,Dd="__lodash_placeholder__";function WA(e,t){for(var r=-1,n=e.length,i=0,o=[];++r<n;){var s=e[r];(s===t||s===Dd)&&(e[r]=Dd,o[i++]=r)}return o}var Li=WA,HA=1,JA=2,XA=8,YA=16,QA=128,ZA=512;function bh(e,t,r,n,i,o,s,a,u,c){var l=t&QA,p=t&HA,S=t&JA,x=t&(XA|YA),E=t&ZA,z=S?void 0:Mi(e);function W(){for(var T=arguments.length,k=Array(T),G=T;G--;)k[G]=arguments[G];if(x)var H=Hu(W),F=ST(k,H);if(n&&(k=ch(k,n,i,x)),o&&(k=fh(k,o,s,x)),T-=F,x&&T<c){var Y=Li(k,H);return mh(e,t,bh,W.placeholder,r,k,Y,a,u,c-T)}var V=p?r:this,ae=S?V[e]:e;return T=k.length,a?k=GA(k,a):E&&T>1&&k.reverse(),l&&u<T&&(k.length=u),this&&this!==mt&&this instanceof W&&(ae=z||Mi(ae)),ae.apply(V,k)}return W}var vh=bh;function e1(e,t,r){var n=Mi(e);function i(){for(var o=arguments.length,s=Array(o),a=o,u=Hu(i);a--;)s[a]=arguments[a];var c=o<3&&s[0]!==u&&s[o-1]!==u?[]:Li(s,u);if(o-=c.length,o<r)return mh(e,t,vh,i.placeholder,void 0,s,c,void 0,void 0,r-o);var l=this&&this!==mt&&this instanceof i?n:e;return Ku(l,this,s)}return i}var t1=e1,r1=1;function n1(e,t,r,n){var i=t&r1,o=Mi(e);function s(){for(var a=-1,u=arguments.length,c=-1,l=n.length,p=Array(l+u),S=this&&this!==mt&&this instanceof s?o:e;++c<l;)p[c]=n[c];for(;u--;)p[c++]=arguments[++a];return Ku(S,i?r:this,p)}return s}var i1=n1,Md="__lodash_placeholder__",Za=1,o1=2,s1=4,Ld=8,Ri=128,kd=256,a1=Math.min;function u1(e,t){var r=e[1],n=t[1],i=r|n,o=i<(Za|o1|Ri),s=n==Ri&&r==Ld||n==Ri&&r==kd&&e[7].length<=t[8]||n==(Ri|kd)&&t[7].length<=t[8]&&r==Ld;if(!(o||s))return e;n&Za&&(e[2]=t[2],i|=r&Za?0:s1);var a=t[3];if(a){var u=e[3];e[3]=u?ch(u,a,t[4]):a,e[4]=u?Li(e[3],Md):t[4]}return a=t[5],a&&(u=e[5],e[5]=u?fh(u,a,t[6]):a,e[6]=u?Li(e[5],Md):t[6]),a=t[7],a&&(e[7]=a),n&Ri&&(e[8]=e[8]==null?t[8]:a1(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=i,e}var c1=u1,f1="Expected a function",jd=1,l1=2,eu=8,tu=16,ru=32,Fd=64,Vd=Math.max;function d1(e,t,r,n,i,o,s,a){var u=t&l1;if(!u&&typeof e!="function")throw new TypeError(f1);var c=n?n.length:0;if(c||(t&=~(ru|Fd),n=i=void 0),s=s===void 0?s:Vd(Nd(s),0),a=a===void 0?a:Nd(a),c-=i?i.length:0,t&Fd){var l=n,p=i;n=i=void 0}var S=u?void 0:dh(e),x=[e,t,r,n,i,l,p,o,s,a];if(S&&c1(x,S),e=x[0],t=x[1],r=x[2],n=x[3],i=x[4],a=x[9]=x[9]===void 0?u?0:e.length:Vd(x[9]-c,0),!a&&t&(eu|tu)&&(t&=~(eu|tu)),!t||t==jd)var E=wT(e,t,r);else t==eu||t==tu?E=t1(e,t,a):(t==ru||t==(jd|ru))&&!i.length?E=i1(e,t,r,n):E=vh.apply(void 0,x);var z=S?uh:yh;return gh(z(E,x),e,t)}var p1=d1;function h1(e,t,r){t=="__proto__"&&fs?fs(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var y1=h1;function g1(e,t){return e===t||e!==e&&t!==t}var Ju=g1,m1=Object.prototype,b1=m1.hasOwnProperty;function v1(e,t,r){var n=e[t];(!(b1.call(e,t)&&Ju(n,r))||r===void 0&&!(t in e))&&y1(e,t,r)}var _1=v1,zd=Math.max;function w1(e,t,r){return t=zd(t===void 0?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=zd(n.length-t,0),s=Array(o);++i<o;)s[i]=n[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=n[i];return a[t]=r(s),Ku(e,this,a)}}var _h=w1;function T1(e,t){return Wu(_h(e,t,Is),e+"")}var A1=T1,O1=9007199254740991;function E1(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=O1}var Xu=E1;function I1(e){return e!=null&&Xu(e.length)&&!ah(e)}var x1=I1,S1=Object.prototype;function C1(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||S1;return e===r}var N1=C1;function R1(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var $1=R1,P1="[object Arguments]";function U1(e){return en(e)&&qn(e)==P1}var Kd=U1,wh=Object.prototype,B1=wh.hasOwnProperty,D1=wh.propertyIsEnumerable,M1=Kd(function(){return arguments}())?Kd:function(e){return en(e)&&B1.call(e,"callee")&&!D1.call(e,"callee")},Yu=M1;function L1(){return!1}var k1=L1,Th=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qd=Th&&typeof module=="object"&&module&&!module.nodeType&&module,j1=qd&&qd.exports===Th,Gd=j1?mt.Buffer:void 0,F1=Gd?Gd.isBuffer:void 0,V1=F1||k1,hu=V1,z1="[object Arguments]",K1="[object Array]",q1="[object Boolean]",G1="[object Date]",W1="[object Error]",H1="[object Function]",J1="[object Map]",X1="[object Number]",Y1="[object Object]",Q1="[object RegExp]",Z1="[object Set]",eO="[object String]",tO="[object WeakMap]",rO="[object ArrayBuffer]",nO="[object DataView]",iO="[object Float32Array]",oO="[object Float64Array]",sO="[object Int8Array]",aO="[object Int16Array]",uO="[object Int32Array]",cO="[object Uint8Array]",fO="[object Uint8ClampedArray]",lO="[object Uint16Array]",dO="[object Uint32Array]",De={};De[iO]=De[oO]=De[sO]=De[aO]=De[uO]=De[cO]=De[fO]=De[lO]=De[dO]=!0;De[z1]=De[K1]=De[rO]=De[q1]=De[nO]=De[G1]=De[W1]=De[H1]=De[J1]=De[X1]=De[Y1]=De[Q1]=De[Z1]=De[eO]=De[tO]=!1;function pO(e){return en(e)&&Xu(e.length)&&!!De[qn(e)]}var hO=pO;function yO(e){return function(t){return e(t)}}var gO=yO,Ah=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Pi=Ah&&typeof module=="object"&&module&&!module.nodeType&&module,mO=Pi&&Pi.exports===Ah,nu=mO&&ih.process,bO=function(){try{var e=Pi&&Pi.require&&Pi.require("util").types;return e||nu&&nu.binding&&nu.binding("util")}catch{}}(),Wd=bO,Hd=Wd&&Wd.isTypedArray,vO=Hd?gO(Hd):hO,Oh=vO,_O=Object.prototype,wO=_O.hasOwnProperty;function TO(e,t){var r=Kt(e),n=!r&&Yu(e),i=!r&&!n&&hu(e),o=!r&&!n&&!i&&Oh(e),s=r||n||i||o,a=s?$1(e.length,String):[],u=a.length;for(var c in e)(t||wO.call(e,c))&&!(s&&(c=="length"||i&&(c=="offset"||c=="parent")||o&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||xs(c,u)))&&a.push(c);return a}var AO=TO;function OO(e,t){return function(r){return e(t(r))}}var EO=OO,IO=EO(Object.keys,Object),xO=IO,SO=Object.prototype,CO=SO.hasOwnProperty;function NO(e){if(!N1(e))return xO(e);var t=[];for(var r in Object(e))CO.call(e,r)&&r!="constructor"&&t.push(r);return t}var RO=NO;function $O(e){return x1(e)?AO(e):RO(e)}var Eh=$O,PO=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,UO=/^\w*$/;function BO(e,t){if(Kt(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Ln(e)?!0:UO.test(e)||!PO.test(e)||t!=null&&e in Object(t)}var Qu=BO,DO=un(Object,"create"),ki=DO;function MO(){this.__data__=ki?ki(null):{},this.size=0}var LO=MO;function kO(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var jO=kO,FO="__lodash_hash_undefined__",VO=Object.prototype,zO=VO.hasOwnProperty;function KO(e){var t=this.__data__;if(ki){var r=t[e];return r===FO?void 0:r}return zO.call(t,e)?t[e]:void 0}var qO=KO,GO=Object.prototype,WO=GO.hasOwnProperty;function HO(e){var t=this.__data__;return ki?t[e]!==void 0:WO.call(t,e)}var JO=HO,XO="__lodash_hash_undefined__";function YO(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=ki&&t===void 0?XO:t,this}var QO=YO;function Gn(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Gn.prototype.clear=LO;Gn.prototype.delete=jO;Gn.prototype.get=qO;Gn.prototype.has=JO;Gn.prototype.set=QO;var Jd=Gn;function ZO(){this.__data__=[],this.size=0}var eE=ZO;function tE(e,t){for(var r=e.length;r--;)if(Ju(e[r][0],t))return r;return-1}var Ss=tE,rE=Array.prototype,nE=rE.splice;function iE(e){var t=this.__data__,r=Ss(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():nE.call(t,r,1),--this.size,!0}var oE=iE;function sE(e){var t=this.__data__,r=Ss(t,e);return r<0?void 0:t[r][1]}var aE=sE;function uE(e){return Ss(this.__data__,e)>-1}var cE=uE;function fE(e,t){var r=this.__data__,n=Ss(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var lE=fE;function Wn(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Wn.prototype.clear=eE;Wn.prototype.delete=oE;Wn.prototype.get=aE;Wn.prototype.has=cE;Wn.prototype.set=lE;var Cs=Wn,dE=un(mt,"Map"),ji=dE;function pE(){this.size=0,this.__data__={hash:new Jd,map:new(ji||Cs),string:new Jd}}var hE=pE;function yE(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var gE=yE;function mE(e,t){var r=e.__data__;return gE(t)?r[typeof t=="string"?"string":"hash"]:r.map}var Ns=mE;function bE(e){var t=Ns(this,e).delete(e);return this.size-=t?1:0,t}var vE=bE;function _E(e){return Ns(this,e).get(e)}var wE=_E;function TE(e){return Ns(this,e).has(e)}var AE=TE;function OE(e,t){var r=Ns(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var EE=OE;function Hn(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Hn.prototype.clear=hE;Hn.prototype.delete=vE;Hn.prototype.get=wE;Hn.prototype.has=AE;Hn.prototype.set=EE;var Rs=Hn,IE="Expected a function";function Zu(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(IE);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(Zu.Cache||Rs),r}Zu.Cache=Rs;var xE=Zu,SE=500;function CE(e){var t=xE(e,function(n){return r.size===SE&&r.clear(),n}),r=t.cache;return t}var NE=CE,RE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$E=/\\(\\)?/g,PE=NE(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(RE,function(r,n,i,o){t.push(i?o.replace($E,"$1"):n||r)}),t}),UE=PE;function BE(e){return e==null?"":I0(e)}var DE=BE;function ME(e,t){return Kt(e)?e:Qu(e,t)?[e]:UE(DE(e))}var $s=ME,LE=1/0;function kE(e){if(typeof e=="string"||Ln(e))return e;var t=e+"";return t=="0"&&1/e==-LE?"-0":t}var Ki=kE;function jE(e,t){t=$s(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[Ki(t[r++])];return r&&r==n?e:void 0}var ec=jE;function FE(e,t,r){var n=e==null?void 0:ec(e,t);return n===void 0?r:n}var VE=FE;function zE(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var Ih=zE,Xd=Qt?Qt.isConcatSpreadable:void 0;function KE(e){return Kt(e)||Yu(e)||!!(Xd&&e&&e[Xd])}var qE=KE;function xh(e,t,r,n,i){var o=-1,s=e.length;for(r||(r=qE),i||(i=[]);++o<s;){var a=e[o];t>0&&r(a)?t>1?xh(a,t-1,r,n,i):Ih(i,a):n||(i[i.length]=a)}return i}var GE=xh;function WE(e){var t=e==null?0:e.length;return t?GE(e,1):[]}var HE=WE;function JE(e){return Wu(_h(e,void 0,HE),e+"")}var XE=JE;function YE(){this.__data__=new Cs,this.size=0}var QE=YE;function ZE(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var eI=ZE;function tI(e){return this.__data__.get(e)}var rI=tI;function nI(e){return this.__data__.has(e)}var iI=nI,oI=200;function sI(e,t){var r=this.__data__;if(r instanceof Cs){var n=r.__data__;if(!ji||n.length<oI-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Rs(n)}return r.set(e,t),this.size=r.size,this}var aI=sI;function Jn(e){var t=this.__data__=new Cs(e);this.size=t.size}Jn.prototype.clear=QE;Jn.prototype.delete=eI;Jn.prototype.get=rI;Jn.prototype.has=iI;Jn.prototype.set=aI;var Wo=Jn;function uI(e,t){for(var r=-1,n=e==null?0:e.length,i=0,o=[];++r<n;){var s=e[r];t(s,r,e)&&(o[i++]=s)}return o}var cI=uI;function fI(){return[]}var lI=fI,dI=Object.prototype,pI=dI.propertyIsEnumerable,Yd=Object.getOwnPropertySymbols,hI=Yd?function(e){return e==null?[]:(e=Object(e),cI(Yd(e),function(t){return pI.call(e,t)}))}:lI,yI=hI;function gI(e,t,r){var n=t(e);return Kt(e)?n:Ih(n,r(e))}var mI=gI;function bI(e){return mI(e,Eh,yI)}var Qd=bI,vI=un(mt,"DataView"),yu=vI,_I=un(mt,"Promise"),gu=_I,wI=un(mt,"Set"),Mn=wI,Zd="[object Map]",TI="[object Object]",ep="[object Promise]",tp="[object Set]",rp="[object WeakMap]",np="[object DataView]",AI=an(yu),OI=an(ji),EI=an(gu),II=an(Mn),xI=an(Di),Yr=qn;(yu&&Yr(new yu(new ArrayBuffer(1)))!=np||ji&&Yr(new ji)!=Zd||gu&&Yr(gu.resolve())!=ep||Mn&&Yr(new Mn)!=tp||Di&&Yr(new Di)!=rp)&&(Yr=function(e){var t=qn(e),r=t==TI?e.constructor:void 0,n=r?an(r):"";if(n)switch(n){case AI:return np;case OI:return Zd;case EI:return ep;case II:return tp;case xI:return rp}return t});var ip=Yr,SI=mt.Uint8Array,op=SI,CI="__lodash_hash_undefined__";function NI(e){return this.__data__.set(e,CI),this}var RI=NI;function $I(e){return this.__data__.has(e)}var PI=$I;function ls(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new Rs;++t<r;)this.add(e[t])}ls.prototype.add=ls.prototype.push=RI;ls.prototype.has=PI;var UI=ls;function BI(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var DI=BI;function MI(e,t){return e.has(t)}var LI=MI,kI=1,jI=2;function FI(e,t,r,n,i,o){var s=r&kI,a=e.length,u=t.length;if(a!=u&&!(s&&u>a))return!1;var c=o.get(e),l=o.get(t);if(c&&l)return c==t&&l==e;var p=-1,S=!0,x=r&jI?new UI:void 0;for(o.set(e,t),o.set(t,e);++p<a;){var E=e[p],z=t[p];if(n)var W=s?n(z,E,p,t,e,o):n(E,z,p,e,t,o);if(W!==void 0){if(W)continue;S=!1;break}if(x){if(!DI(t,function(T,k){if(!LI(x,k)&&(E===T||i(E,T,r,n,o)))return x.push(k)})){S=!1;break}}else if(!(E===z||i(E,z,r,n,o))){S=!1;break}}return o.delete(e),o.delete(t),S}var Sh=FI;function VI(e){var t=-1,r=Array(e.size);return e.forEach(function(n,i){r[++t]=[i,n]}),r}var zI=VI;function KI(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var Ch=KI,qI=1,GI=2,WI="[object Boolean]",HI="[object Date]",JI="[object Error]",XI="[object Map]",YI="[object Number]",QI="[object RegExp]",ZI="[object Set]",ex="[object String]",tx="[object Symbol]",rx="[object ArrayBuffer]",nx="[object DataView]",sp=Qt?Qt.prototype:void 0,iu=sp?sp.valueOf:void 0;function ix(e,t,r,n,i,o,s){switch(r){case nx:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case rx:return!(e.byteLength!=t.byteLength||!o(new op(e),new op(t)));case WI:case HI:case YI:return Ju(+e,+t);case JI:return e.name==t.name&&e.message==t.message;case QI:case ex:return e==t+"";case XI:var a=zI;case ZI:var u=n&qI;if(a||(a=Ch),e.size!=t.size&&!u)return!1;var c=s.get(e);if(c)return c==t;n|=GI,s.set(e,t);var l=Sh(a(e),a(t),n,i,o,s);return s.delete(e),l;case tx:if(iu)return iu.call(e)==iu.call(t)}return!1}var ox=ix,sx=1,ax=Object.prototype,ux=ax.hasOwnProperty;function cx(e,t,r,n,i,o){var s=r&sx,a=Qd(e),u=a.length,c=Qd(t),l=c.length;if(u!=l&&!s)return!1;for(var p=u;p--;){var S=a[p];if(!(s?S in t:ux.call(t,S)))return!1}var x=o.get(e),E=o.get(t);if(x&&E)return x==t&&E==e;var z=!0;o.set(e,t),o.set(t,e);for(var W=s;++p<u;){S=a[p];var T=e[S],k=t[S];if(n)var G=s?n(k,T,S,t,e,o):n(T,k,S,e,t,o);if(!(G===void 0?T===k||i(T,k,r,n,o):G)){z=!1;break}W||(W=S=="constructor")}if(z&&!W){var H=e.constructor,F=t.constructor;H!=F&&"constructor"in e&&"constructor"in t&&!(typeof H=="function"&&H instanceof H&&typeof F=="function"&&F instanceof F)&&(z=!1)}return o.delete(e),o.delete(t),z}var fx=cx,lx=1,ap="[object Arguments]",up="[object Array]",Ko="[object Object]",dx=Object.prototype,cp=dx.hasOwnProperty;function px(e,t,r,n,i,o){var s=Kt(e),a=Kt(t),u=s?up:ip(e),c=a?up:ip(t);u=u==ap?Ko:u,c=c==ap?Ko:c;var l=u==Ko,p=c==Ko,S=u==c;if(S&&hu(e)){if(!hu(t))return!1;s=!0,l=!1}if(S&&!l)return o||(o=new Wo),s||Oh(e)?Sh(e,t,r,n,i,o):ox(e,t,u,r,n,i,o);if(!(r&lx)){var x=l&&cp.call(e,"__wrapped__"),E=p&&cp.call(t,"__wrapped__");if(x||E){var z=x?e.value():e,W=E?t.value():t;return o||(o=new Wo),i(z,W,r,n,o)}}return S?(o||(o=new Wo),fx(e,t,r,n,i,o)):!1}var hx=px;function Nh(e,t,r,n,i){return e===t?!0:e==null||t==null||!en(e)&&!en(t)?e!==e&&t!==t:hx(e,t,r,n,Nh,i)}var Rh=Nh,yx=1,gx=2;function mx(e,t,r,n){var i=r.length,o=i,s=!n;if(e==null)return!o;for(e=Object(e);i--;){var a=r[i];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++i<o;){a=r[i];var u=a[0],c=e[u],l=a[1];if(s&&a[2]){if(c===void 0&&!(u in e))return!1}else{var p=new Wo;if(n)var S=n(c,l,u,e,t,p);if(!(S===void 0?Rh(l,c,yx|gx,n,p):S))return!1}}return!0}var bx=mx;function vx(e){return e===e&&!cr(e)}var $h=vx;function _x(e){for(var t=Eh(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,$h(i)]}return t}var wx=_x;function Tx(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}var Ph=Tx;function Ax(e){var t=wx(e);return t.length==1&&t[0][2]?Ph(t[0][0],t[0][1]):function(r){return r===e||bx(r,e,t)}}var Ox=Ax;function Ex(e,t){return e!=null&&t in Object(e)}var Ix=Ex;function xx(e,t,r){t=$s(t,e);for(var n=-1,i=t.length,o=!1;++n<i;){var s=Ki(t[n]);if(!(o=e!=null&&r(e,s)))break;e=e[s]}return o||++n!=i?o:(i=e==null?0:e.length,!!i&&Xu(i)&&xs(s,i)&&(Kt(e)||Yu(e)))}var Sx=xx;function Cx(e,t){return e!=null&&Sx(e,t,Ix)}var Uh=Cx,Nx=1,Rx=2;function $x(e,t){return Qu(e)&&$h(t)?Ph(Ki(e),t):function(r){var n=VE(r,e);return n===void 0&&n===t?Uh(r,e):Rh(t,n,Nx|Rx)}}var Px=$x;function Ux(e){return function(t){return t?.[e]}}var Bx=Ux;function Dx(e){return function(t){return ec(t,e)}}var Mx=Dx;function Lx(e){return Qu(e)?Bx(Ki(e)):Mx(e)}var kx=Lx;function jx(e){return typeof e=="function"?e:e==null?Is:typeof e=="object"?Kt(e)?Px(e[0],e[1]):Ox(e):kx(e)}var Fx=jx;function Vx(e,t,r,n){if(!cr(e))return e;t=$s(t,e);for(var i=-1,o=t.length,s=o-1,a=e;a!=null&&++i<o;){var u=Ki(t[i]),c=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return e;if(i!=s){var l=a[u];c=n?n(l,u,a):void 0,c===void 0&&(c=cr(l)?l:xs(t[i+1])?[]:{})}_1(a,u,c),a=a[u]}return e}var zx=Vx;function Kx(e,t,r){for(var n=-1,i=t.length,o={};++n<i;){var s=t[n],a=ec(e,s);r(a,s)&&zx(o,$s(s,e),a)}return o}var qx=Kx,Gx=32,tc=A1(function(e,t){var r=Li(t,Hu(tc));return p1(e,Gx,void 0,t,r)});tc.placeholder={};var Wx=tc;function Hx(e,t){return qx(e,t,function(r,n){return Uh(e,n)})}var Jx=Hx,Xx=XE(function(e,t){return e==null?{}:Jx(e,t)}),fp=Xx,Yx=4294967295,Qx=Yx-1,Zx=Math.floor,eS=Math.min;function tS(e,t,r,n){var i=0,o=e==null?0:e.length;if(o===0)return 0;t=r(t);for(var s=t!==t,a=t===null,u=Ln(t),c=t===void 0;i<o;){var l=Zx((i+o)/2),p=r(e[l]),S=p!==void 0,x=p===null,E=p===p,z=Ln(p);if(s)var W=n||E;else c?W=E&&(n||S):a?W=E&&S&&(n||!x):u?W=E&&S&&!x&&(n||!z):x||z?W=!1:W=n?p<=t:p<t;W?i=l+1:o=l}return eS(o,Qx)}var rS=tS;function nS(e,t,r){return rS(e,t,Fx(r,2))}var iS=nS,oS=1/0,iP=Mn&&1/Ch(new Mn([,-0]))[1]==oS?function(e){return new Mn(e)}:lh;var{WARN:oP,LOG:sP,DEBUG:aP,VERBOSE:sS,ERROR:aS}=$e.setup($e.INFO),Bh=(e,t,r="asc")=>r==="asc"?e.localeCompare(t,"en-US"):t.localeCompare(e,"en-US"),rc=(e,t,r)=>Ge.structural(fp(t,e),fp(r,e)),Dh=(e,t,r="asc")=>Bh(e.ts,t.ts,r),uS=Wx(rc,["en","at"]);function Sr(e,t="asc"){return e.sort((r,n)=>Dh(r,n,t))}var Mh=(e,t)=>n0(new Date(e.ts),new Date(t.ts));var nc=e=>{let t=new Map;for(let r of e){if(!r)throw aS("falsy entry in applogs",e),new Error("falsy entry in applogs");let n=r.cid;t.has(n)?sS("Skipping duplicate applog:",[t.get(n),r]):t.set(n,r)}return Array.from(t.values())};function Lh(e){return typeof e=="string"&&e.startsWith("?")}function kh(e){return e.slice(1)}function Ps(e,t){let r={},n={};for(let[i,o]of Object.entries(e))if(Lh(o)){let s=kh(o),a=t[s];a?n[i]=a:r[i]=s}else n[i]=o;return[n,r]}function jh(e,t,r){let n;if(t){let i=typeof t;i==="string"?n=t===r:i==="function"?n=t(r):typeof t.has=="function"?n=t.has(r):Array.isArray(t)&&!Array.isArray(r)?n=t.includes(r):n=t===r}else n=t===r;return e.charAt(0)==="!"?!n:n}var Fh=function(t){for(var r=0,n=0,i=t.length;n<i;n++)r+=t[n];return r},lp=function(t){return Fh(t)/t.length},yt={max:function(e){return Math.max.apply(null,e)},min:function(e){return Math.min.apply(null,e)},range:function(e){return yt.max(e)-yt.min(e)},midrange:function(e){return yt.range(e)/2},sum:Fh,mean:lp,average:lp,median:function(e){e.sort(function(r,n){return r-n});var t=e.length/2;return t%1?e[t-.5]:(e[t-1]+e[t])/2},modes:function(e){if(!e.length)return[];var t={},r=0,n=[];return e.forEach(function(i){t[i]?t[i]++:t[i]=1,t[i]>r?(n=[i],r=t[i]):t[i]===r&&(n.push(i),r=t[i])}),n},variance:function(e){var t=yt.mean(e);return yt.mean(e.map(function(r){return Math.pow(r-t,2)}))},standardDeviation:function(e){return Math.sqrt(yt.variance(e))},meanAbsoluteDeviation:function(e){var t=yt.mean(e);return yt.mean(e.map(function(r){return Math.abs(r-t)}))},zScores:function(e){var t=yt.mean(e),r=yt.standardDeviation(e);return e.map(function(n){return(n-t)/r})}};yt.average=yt.mean;function ic(){return new Date().toISOString()}var{WARN:cS,LOG:uP,DEBUG:fS,VERBOSE:cP,ERROR:ds}=$e.setup($e.INFO);function Vh(e,t){let r=ic(),n=t;return e.map(o=>zh(o,{ts:r,threadForPv:n}))}function zh(e,{ts:t,threadForPv:r}={}){let n=Gh(e,t??ic()),i=Wh(n,r),o=th(i).toString();e.cid&&e.cid!==o&&cS("[finalizeApplogForInsert] overwriting wrong CID",{log:e,cid:o,logWithPv:i});let s={...i,cid:o};if(!Lu(s))throw ds(`Bogus Applog ${JSON.stringify(s)}`,Qp(s));return Object.freeze(s)}function Kh(e){return!!e.ts}function qh(e){return!!e.pv}function Gh(e,t){return Kh(e)?e:{...e,ts:t}}function Wh(e,t){if(e.pv!==void 0)return e;if(t){let{en:r,at:n}=e,i=t.findLast(s=>s.en==r&&s.at==n);if(rc(["en","at","vl","ts","ag"],e,i))throw ds("[withPvFrom] Same as previous:",{log:e,pv:i,thread:t});let o=(e.pv!==void 0?e.pv:i?.cid)??null;return{...e,pv:o}}else{if(!qh(e))throw ds("[withPvFrom] no thread and no pv:",e);return e}}function qi(e){let t=()=>(Re(()=>e.length<2&&fS(`joinThreads with count=${e.length}`)),Sr(nc(e.flatMap(i=>{let o=i.applogs;if(!o)throw ds("falsy applogs of thread",i),new Error("falsy applogs of thread");return o})))),r=Re(()=>t()),n=st(function(i,o){return Yt(i)?{init:Re(()=>t())}:{added:i.added.filter(s=>!this.hasApplog(s,!0)),removed:i.removed?.filter(s=>!!this.parents.some(u=>u===o?!1:u.hasApplog(s,!0)))}});return new Us(Re(()=>`join(~ ${e.map(i=>i.name).join(", ")})`),e,["?"],r,n)}var{WARN:dp,LOG:fP,DEBUG:pp,VERBOSE:Xr,ERROR:hp}=$e.setup($e.INFO),Us=class Hh extends gs{constructor(t,r,n,i,o,s=null){super(t,r,n,o?Pe.array([...i],{deep:!1,name:`${t}.array`}):i),this.name=t,this._initialLogs=i,this._eventMapper=o,this._writeMapper=s,Tr(this,{onParentUpdate:st}),o&&this.subscribeToParents()}static mapWrites(t,r,n){return new Hh(`${r}<${t.nameAndSizeUntracked}>`,t,t.filters,t._applogs,null,n)}_parentSubscriptions=null;insert(t){let r=this._writeMapper?this._writeMapper(t):t;if(!(this._writeMapper&&!r))return this.parents.forEach(n=>n.insert(r))}insertRaw(t){let r=this._writeMapper?this._writeMapper(t):t;if(!(this._writeMapper&&!r))return this.parents.forEach(n=>n.insertRaw(r))}subscribeToParents(){this._parentSubscriptions=new Map;let t=Ct(()=>{this.parents.length||dp("MappedThread has no parents",this),Xr(`[MappedThread: ${this.name}] subscribing to parents:`,this.parents.map(n=>n.name));let r=new Set([...this._parentSubscriptions.keys()]);for(let n of this.parents){r.delete(n)&&Xr(`[MappedThread: ${this.name}] Skipping re-sub to parent`,n.nameAndSizeUntracked),Xr(`[MappedThread: ${this.name}] sub to new parent`,n.nameAndSizeUntracked);let o=this.onParentUpdate.bind(this,n),s=n.subscribe(o);this._parentSubscriptions.set(n,s)}for(let n of r)Xr(`[MappedThread: ${this.name}] un-subscribing from old parent`,n.nameAndSizeUntracked),this._parentSubscriptions.get(n)(),this._parentSubscriptions.delete(n)})}subscribe(t){return this._parentSubscriptions||this.subscribeToParents(),super.subscribe(t)}triggerRemap(){if(!this._eventMapper)throw hp("triggerRemap on a thread that is not actually mapping?!",this.nameAndSizeUntracked);pp(`MappedThread{${this.nameAndSizeUntracked}} triggerRemap`),this.parents.length!==1&&dp(`MappedThread{${this.nameAndSizeUntracked}} triggerRemap with parentCount=${this.parents.length} - not meant for this`),this.parents.forEach(t=>{this.onParentUpdate(t,{init:Re(()=>ar(t.applogs))})})}onParentUpdate(t,r){Xr(`MappedThread{${this.nameAndSizeUntracked}} parentUpdate`,r);let n=this._eventMapper?this._eventMapper(r,t):r;if(this._eventMapper)if(Xr(`MappedThread{${this.nameAndSizeUntracked}} parentUpdate => mapped`,n),Yt(n))this._applogs.replace([...n.init]);else{for(let i of n.added)this._applogs.splice(iS(this._applogs,i,"ts"),0,i);if(n.removed){for(let i of n.removed)if(!this._applogs.remove(i))if(!Yt(r)&&r.removed?.includes(i))pp("Ignoring remove event for non-existent because it was part of parent event's removed",i,r);else throw hp(`MappedThread{${this.name}} toRemove contained log that doesn't exist`,i,{thread:this,event:r,mapResult:n})}}Xr(`MappedThread{${this.nameAndSizeUntracked}} parentUpdate => deps?`,Ei(this._applogs)),this.notifySubscribers(n)}get readOnly(){return!1}},{WARN:lP,LOG:dP,DEBUG:pP,VERBOSE:ou,ERROR:lS}=$e.setup($e.INFO),lr=Qe("rollingFilter",function(t,r,n={}){let i=Jh(r),o=mu(i),s=Pe.array(Re(function(){return o(t.applogs)}),{deep:!1,name:`${t.name} | ${n.name||`rollingFilter.array{${Zr(i)}}`}`}),a=p=>{let S;return Yt(p)?S={init:o(p.init)}:S={added:o(p.added),removed:p.removed},ou(`rollingFilter{${t.nameAndSizeUntracked} | ${n.name?` '${n.name}'}`:""} parentUpdate`,i,p,"=>",S),S},u=new Us(`${t.name} | ${n.name||`rollingFilter{${Zr(i)}}`}`,t,[...t.filters,...n.extraFilterName?[n.extraFilterName]:[]],s,a),c=Gl(()=>ar(r),p=>{ou(`rollingFilter<${t.nameAndSizeUntracked}>${n.name?` '${n.name}'`:""} patternUpdate`,i,"=>",p),i=p,o=mu(i),u.triggerRemap()}),l=Gr(s,()=>{ou(`rollingFilter<${Re(()=>t.name)}>${n.name?` '${n.name}'`:""} unobserve`,i),c(),l()});return u},{equals:jn,argsDebugName:(e,t,r)=>He({caller:"rollingFilter",thread:e,pattern:t,args:r})}),oc=Qe("rollingMapper",function(t,r,n={}){let i=Re(()=>r.call(null,{init:t.applogs},t));if(!Yt(i))throw lS("Initial run must return init event");let o=i.init;return new Us(`${t.name} | ${n.name||"rollingMapper"}`,t,[...t.filters,...n.extraFilterName?[n.extraFilterName]:[]],o,r)},{equals:jn,argsDebugName:(e,t,r)=>He({caller:"rollingMapper",thread:e,args:r})}),dS=Qe("rollingAcc",function(t,r,n,i={}){let o=st(n);return o({init:t.applogs},r),t.subscribe(s=>{o(s,r)}),r},{argsDebugName:(e,t,r,n)=>`rollingAcc{${e.nameAndSizeUntracked}${n?.name?` | ${n?.name}`:""}}`}),Jh=function(t){let r=Re(function(){return Object.fromEntries(Object.entries(ar(t)).map(([i,o])=>[ar(i),ar(o)]))});if(!Object.entries(r).length)throw new Error("Pattern is empty");return r};function mu(e){return function(r){return r.filter(function(i){for(let o of Object.keys(e)){let s=e[o];if(s===void 0)continue;let a=i[o.startsWith("!")?o.slice(1):o];if(!jh(o,s,a))return!1}return!0})}}var{WARN:pS,LOG:hS,DEBUG:yS,VERBOSE:gS,ERROR:Ho}=$e.setup($e.INFO),Xh=class extends gs{constructor(e,t=[],r){super(e,null,r,t),Tr(this,{})}purge(e){let t=this.applogs.length;return this._applogs=this.applogs.filter(r=>!e.includes(r.cid)),t-this.applogs.length}insert(e){let t=Vh(e,this);return this.insertRaw(t)}insertRaw(e){let t=nc(e);if(t.length!==e.length)throw Ho(`[insertRaw] duplicate applogs passed: ${e.length-t.length}`,{appLogsToInsert:e,deduplicated:t});let r=e.filter(o=>!Lu(o));if(r.length)throw Ho(`[insertRaw] bogus applogs passed: ${r.length}`,{bogus:r});let n=e.filter(o=>this.hasApplog(o,!1));if(n.length)throw Ho(`[insertRaw] already existing applogs passed: ${n.length}`,{existing:n});if(!e.length){pS("[insertRaw] skipping empty insert empty logs array");return}(!this.hasParents&&!(this instanceof Xn)?hS:yS)("Inserting:",e.length===1?e[0]:e,{ds:this}),Sr(e);let i=this._applogs.length&&Mh(e[0],this._applogs[this._applogs.length-1]);return this._applogs.push(...e),i&&Sr(this._applogs),this.notifySubscribers({added:e,removed:null}),this.persist(e),e}get readOnly(){return!1}},Xn=class bu extends Xh{constructor(t,r,n,i){super(t,r,n),this._readOnly=i,Tr(this,{_applogs:Pe.shallow})}static empty(t){return bu.fromArray([],t??"empty in-memory",!1)}static fromArray(t,r,n=!1){return new bu(r??"in-memory",t,[],n)}get readOnly(){return this._readOnly}async persist(t){if(gS("[InMem.persist] no persist for",t),this.readOnly)throw Ho("[persist] called for readOnly thread")}},{WARN:hP,LOG:yP,DEBUG:gP,VERBOSE:mP,ERROR:bP}=$e.setup($e.INFO);var bS=class{constructor(e,t,r=null){this.logsOfThisNode=e,this.variables=t,this.prevNode=r,Tr(this,{threadOfTrail:Me})}get record(){return this.variables}get threadOfTrail(){return this.prevNode?qi([this.logsOfThisNode,this.prevNode.threadOfTrail]):this.logsOfThisNode}get trailLogs(){return this.threadOfTrail.applogs}},Yh=class{constructor(e){this.nodes=e,Tr(this,{threadOfAllTrails:Me,size:Me,isEmpty:Me})}get size(){return this.records.length}get isEmpty(){return this.records.length===0}get untrackedSize(){return Re(()=>this.records.length)}get records(){return fr(()=>this.nodes.map(({variables:e})=>e),{name:"QueryResult.records"})}get leafNodeThread(){return qi(fr(()=>this.nodes.map(({logsOfThisNode:e})=>e),{name:"QueryResult.leafNodeThread"}))}get leafNodeLogs(){return fr(()=>this.nodes.map(({logsOfThisNode:e})=>e.applogs),{name:"QueryResult.leafNodeLogs"})}get threadOfAllTrails(){return qi(fr(()=>this.nodes.map(e=>e.threadOfTrail),{name:"QueryResult.threadOfAllTrails"}))}get thread(){return this.threadOfAllTrails}get allApplogs(){return this.threadOfAllTrails.applogs}},{WARN:TU,LOG:Bs,DEBUG:dr,VERBOSE:Ae,ERROR:cn}=$e.setup($e.INFO,{prefix:"[q]"}),vS=Qe("lastWriteWins",function(t,{inverseToOnlyReturnFirstLogs:r,tolerateAlreadyFiltered:n}={}){if(Ae(`lastWriteWins${r?".inversed":""} < ${t.nameAndSizeUntracked} > initializing`),t.filters.includes("lastWriteWins")){if(n)return dr("[lastWriteWins] already filtered, but tolerateAlreadyFiltered=true, so returning"),t;throw cn("thread already filtered lastWriteWins:",t.filters,{name:t.name})}let i,o=oc(t,function(a,u){let c=Yt(a),l,p=[],S=c?null:[];c?(i=new Map,l=a.init):l=a.added;let x;for(let E=r?0:l.length-1;r?E<l.length:E>=0;r?E++:E--){let z=l[E],W=z.en+"|"+z.at;if(x&&(r?x>z.ts:x<z.ts))throw cn("lastWriteWins.mapper logs not sorted:",x,r?">":"<",z.ts,{log:z,i:E,newLogs:l,inverseToOnlyReturnFirstLogs:r});x=z.ts;let T=i.get(W);(!T||(r?T.ts>z.ts:T.ts<z.ts))&&(T&&!c&&S.push(T),p.push(z),i.set(W,z))}return Sr(p),Ae.isDisabled||Ae(`lastWriteWins${r?".inversed":""}<${t.nameAndSizeUntracked}> mapped event`,c?{...Object.fromEntries(Object.entries(a).map(([E,z])=>[E,z?.length])),toAdd:p.length,toRemove:S}:{...a,toAdd:p,toRemove:S}),c?{init:p}:{added:p,removed:S}},{name:`lastWriteWins${r?".inversed":""}`,extraFilterName:"lastWriteWins"});return Ae.isDisabled||Ct(()=>{Ae(`lastWriteWins<${t.nameAndSizeUntracked}> filtered down to`,o.applogs.length)}),o},{equals:jn,argsDebugName:e=>He({caller:"lastWriteWins",thread:e})}),AU=Qe("withoutDeleted",function(t){if(Ae.isEnabled&&Ae(`withoutDeleted<${t.nameAndSizeUntracked}>`),t.filters.includes("withoutDeleted"))throw cn("thread already filtered withoutDeleted:",t.filters,{name:t.name});let r=lr(t,{at:["isDeleted","relation/isDeleted","block/isDeleted"],vl:!0},{name:"isDeleted"});Ae.isEnabled&&Ae(`withoutDeleted<${t.nameAndSizeUntracked}> deletionLogs:`,Re(function(){return[...r.applogs]}));let n=He({caller:"allDeletedEntities",thread:t}),i=Ap(function(){return r.map(s=>s.en)},{name:n});return Ae.isEnabled&&Ct(()=>{Ae(`withoutDeleted<${t.nameAndSizeUntracked}> deleted:`,[...i])}),lr(t,{"!en":i},{name:"withoutDeleted",extraFilterName:"withoutDeleted"})},{equals:jn}),Qh=Qe("query",function e(t,r,n={},i={}){let o=Zh(t);dr(`query<${o.nameAndSizeUntracked}>:`,r);let s=Array.isArray(r)?r:[r],a;if(s.length===1)a=null;else{let l=s.slice(0,-1);a=e(o,l,n,i)}let u=s[s.length-1],c=_S(o,a,u,i);return Ae.isDisabled||Ct(()=>Ae("query result:",ar(c))),c},{equals:ys,argsDebugName:(e,t,r)=>He({caller:"query",thread:e,args:r?{pattern:t,startVars:r}:t})}),_S=Qe("queryStep",function(t,r,n,i={}){if(dr(`queryStep<${t.nameAndSizeUntracked}> with`,r?.untrackedSize??"all","nodes, pattern:",n),!Object.entries(n).length)throw new Error("Pattern is empty");function o(a){let[u,c]=Ps(n,a?.variables??{});Ae("[queryStep.doQuery] patternWithoutVars: ",u);let l=lr(t,u),p=Ds(c),S=fr(function(){let E=l.map(z=>({log:z,vars:p(z)}));return Ae.isEnabled&&Ae("[queryStep.doQuery] step node:",a?.variables," =>",E,"from:",Re(()=>l.applogs)),E.map(({log:z,vars:W})=>{let T=Object.assign({},a?.variables,W);return new bS(_u.fromArray([z],He({caller:"QueryNode",thread:l,pattern:`${Zr(T)}@${Zr(u)}`})),T,a)})},{name:He({caller:"doQuery.mapNodes",thread:l,pattern:n})});return Ae.isEnabled&&Ct(()=>Ae("[queryStep.doQuery] resultNodes:",[...S])),i.debug&&Bs("[queryStep] step result:",Re(()=>S.map(({variables:x,logsOfThisNode:E})=>({variables:x,thread:E})))),S}let s=fr(function(){return dr(`[queryStep] Running with ${r?.nodes?.length} input nodes:`),r?[...r.nodes.flatMap(o)]:[...o(null)]},{name:He({caller:"queryStep",thread:t,pattern:n})});return Ae.isEnabled&&Ct(()=>Ae("[queryStep] observableResultNodes:",[...s])),new Yh(s)},{equals:ys,argsDebugName:(e,t,r)=>He({caller:"queryStep",thread:e,pattern:r})}),OU=Qe("queryNot",function(t,r,n,i={}){let o=r.nodes;dr(`queryNot<${t.nameAndSizeUntracked}> from: ${o.length} nodes`);let s=Array.isArray(n)?n:[n];for(let a of s){if(!Object.entries(n).length)throw new Error("Pattern is empty");o=o.filter(function({variables:c}){let[l,p]=Ps(a,c??{});Ae("[queryNot] patternWithoutVars: ",l);let S=lr(t,l);return Ae("[queryNot] step node:",c," =>",S.size,"applogs"),Ae.isDisabled||Ae("[queryNot] step node:",c," => empty?",Re(()=>S.applogs)),i.debug&&Bs("[queryNot] node result:",c,"=>",S.applogs),S.isEmpty})}return new Yh(o)},{equals:ys,argsDebugName:(e,t,r)=>He({caller:"queryNot",thread:e,pattern:r})}),EU=Qe("filterAndMap",function(t,r,n){dr(`filterAndMap<${t.nameAndSizeUntracked}>`,r);let i=lr(t,r);Ae("[filterAndMap] filtered:",i.untrackedSize),Ae.isDisabled||Ct(()=>Ae("[filterAndMap] filtered:",i.applogs));let o=He({thread:t,pattern:r,caller:"filterAndMap"}),s=fr(()=>AS(i,n),{name:o});return Ae.isDisabled||Ct(()=>Ae("[filterAndMap] mapped:",s)),s},{equals:Ge.structural,argsDebugName:(e,t)=>He({caller:"filterAndMap",thread:e,pattern:t})}),IU=Qe("queryAndMap",function(t,r,n,i={}){let o=Zh(t);dr(`queryAndMap<${o.nameAndSizeUntracked}>`,{patternOrPatterns:r,variables:i,map:n});let s=He({thread:o,caller:"queryAndMap"}),a=Qh(o,r);Ae("[queryAndMap] filtered count:",a.untrackedSize);let u=fr(()=>OS(a,n),{name:s});return Ae.isDisabled||Ct(()=>Ae("[queryAndMap] result:",ar(u))),u},{equals:Ge.structural,argsDebugName:(e,t)=>He({caller:"queryAndMap",thread:e,pattern:t})}),xU=Qe("queryEntity",function(t,r,n,i){dr(`queryEntity<${t.nameAndSizeUntracked}>`,n,r);let o=lr(t,{en:n,at:ES(r,i)});return Ae("queryEntity applogs:",o.applogs),Me(()=>o.isEmpty?null:Object.fromEntries(o.map(({at:s,vl:a})=>[s.slice(r.length+1),a])))},{equals:Tp,argsDebugName:(e,t,r)=>He({caller:"queryEntity",thread:e,args:{name:t,entityID:r}})}),SU=Qe("agentsOfThread",function(t){dr(`agentsOfThread<${t.nameAndSizeUntracked}>`);let r=Pe.map(),n=st(o=>{for(let s of Yt(o)?o.init:o.added){let a=r.get(s.ag)??0;r.set(s.ag,a+1)}for(let s of!Yt(o)&&o.removed||[]){let a=r.get(s.ag);if(!a||a<1)throw cn("[agentsOfThread] number is now negative",{log:s,event:o,mapped:r,prev:a});r.set(s.ag,a-1)}Bs(`agentsOfThread<${t.nameAndSizeUntracked}> processed event`,{event:o,mapped:r})});n({init:t.applogs});let i=t.subscribe(n);return Pn(r,i),r}),wS=Qe("entityOverlap",function(t,r){return Bs(`entityOverlap<${t.nameAndSizeUntracked}, ${r.nameAndSizeUntracked}>`),Me(()=>{let n=new Set(t.map(o=>o.en)),i=new Set(r.map(o=>o.en));return[...n].filter(o=>i.has(o))})});var CU=Qe("entityOverlapCount",function(t,r){return Me(()=>wS(t,r).get().length)}),TS=Qe("querySingle",function(t,r,n={}){let i=Qh(t,r,n);return Me(()=>{if(i.isEmpty)return null;if(i.size>1)throw cn("[querySingle] got",i.size,"results:",i);let o=i.nodes[0].logsOfThisNode;if(o.size!=1)throw cn("[querySingle] single result, but got",o.size,"logs:",o.applogs);return o.applogs[0]})},{equals:Ge.structural,argsDebugName:(e,t)=>He({caller:"querySingle",thread:e,pattern:t})}),NU=Qe("querySingleAndMap",function(t,r,n,i={}){let o=TS(t,r,i);return Me(()=>{let s=o.get();if(s)return typeof n=="string"?s[n]:Ds(n)(s)})},{equals:Ge.structural,argsDebugName:(e,t)=>He({caller:"querySingleAndMap",thread:e,pattern:t})}),AS=function(t,r){return typeof r=="function"?t.map(r):typeof r=="string"?t.map(n=>n[r]):t.map(Ds(r))},OS=function(t,r){return typeof r=="function"?t.records.map(r):typeof r=="string"?t.nodes.map(n=>{if(!Object.hasOwn(n.record,r)){if(n.logsOfThisNode.size!==1)throw cn(`not sure what to map (it's not a var and a result node log count of ${n.logsOfThisNode.size})`);return n.logsOfThisNode.firstLog[r]}return n.record[r]}):t.nodes.map(n=>Ds(r)(t))};function Ds(e){return t=>Object.entries(e).reduce((r,[n,i])=>(r[i]=t[n],r),{})}function ES(e,t){return t.map(r=>IS(e,r))}function IS(e,t){return`${e}/${t}`}function Zh(e){return Array.isArray(e)?Xn.fromArray(e,`threadFromArray[${e.length}]`,!0):e}var CS=Le({"../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/encode.js"(e,t){"use strict";t.exports=s;var r=128,n=127,i=~n,o=Math.pow(2,31);function s(a,u,c){if(Number.MAX_SAFE_INTEGER&&a>Number.MAX_SAFE_INTEGER)throw s.bytes=0,new RangeError("Could not encode varint");u=u||[],c=c||0;for(var l=c;a>=o;)u[c++]=a&255|r,a/=128;for(;a&i;)u[c++]=a&255|r,a>>>=7;return u[c]=a|0,s.bytes=c-l+1,u}}}),NS=Le({"../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/decode.js"(e,t){"use strict";t.exports=i;var r=128,n=127;function i(o,u){var a=0,u=u||0,c=0,l=u,p,S=o.length;do{if(l>=S||c>49)throw i.bytes=0,new RangeError("Could not decode varint");p=o[l++],a+=c<28?(p&n)<<c:(p&n)*Math.pow(2,c),c+=7}while(p>=r);return i.bytes=l-u,a}}}),RS=Le({"../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/length.js"(e,t){"use strict";var r=Math.pow(2,7),n=Math.pow(2,14),i=Math.pow(2,21),o=Math.pow(2,28),s=Math.pow(2,35),a=Math.pow(2,42),u=Math.pow(2,49),c=Math.pow(2,56),l=Math.pow(2,63);t.exports=function(p){return p<r?1:p<n?2:p<i?3:p<o?4:p<s?5:p<a?6:p<u?7:p<c?8:p<l?9:10}}}),lc=Le({"../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/index.js"(e,t){"use strict";t.exports={encode:CS(),decode:NS(),encodingLength:RS()}}}),jU=new Uint8Array(0);function $S(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 dc(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 PS(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 i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,u=e.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function p(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var z=0,W=0,T=0,k=E.length;T!==k&&E[T]===0;)T++,z++;for(var G=(k-T)*l+1>>>0,H=new Uint8Array(G);T!==k;){for(var F=E[T],Y=0,V=G-1;(F!==0||Y<W)&&V!==-1;V--,Y++)F+=256*H[V]>>>0,H[V]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");W=Y,T++}for(var ae=G-W;ae!==G&&H[ae]===0;)ae++;for(var L=u.repeat(z);ae<G;++ae)L+=e.charAt(H[ae]);return L}function S(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var z=0;if(E[z]!==" "){for(var W=0,T=0;E[z]===u;)W++,z++;for(var k=(E.length-z)*c+1>>>0,G=new Uint8Array(k);E[z];){var H=r[E.charCodeAt(z)];if(H===255)return;for(var F=0,Y=k-1;(H!==0||F<T)&&Y!==-1;Y--,F++)H+=a*G[Y]>>>0,G[Y]=H%256>>>0,H=H/256>>>0;if(H!==0)throw new Error("Non-zero carry");T=F,z++}if(E[z]!==" "){for(var V=k-T;V!==k&&G[V]===0;)V++;for(var ae=new Uint8Array(W+(k-V)),L=W;V!==k;)ae[L++]=G[V++];return ae}}}function x(E){var z=S(E);if(z)return z;throw new Error(`Non-${t} character`)}return{encode:p,decodeUnsafe:S,decode:x}}var US=PS,BS=US,DS=BS,MS=class{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},LS=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){this.name=e,this.prefix=t;let n=t.codePointAt(0);if(n===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n,this.baseDecode=r}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ay(this,e)}},kS=class{decoders;constructor(e){this.decoders=e}or(e){return ay(this,e)}decode(e){let t=e[0],r=this.decoders[t];if(r!=null)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function ay(e,t){return new kS({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var jS=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new MS(e,t,r),this.decoder=new LS(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function uy({name:e,prefix:t,encode:r,decode:n}){return new jS(e,t,r,n)}function Vs({name:e,prefix:t,alphabet:r}){let{encode:n,decode:i}=DS(r,e);return uy({prefix:t,name:e,encode:n,decode:o=>dc(i(o))})}function FS(e,t,r,n){let i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,u=0,c=0;for(let l=0;l<o;++l){let p=i[e[l]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<r|p,a+=r,a>=8&&(a-=8,s[c++]=255&u>>a)}if(a>=r||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return s}function VS(e,t,r){let n=t[t.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let u=0;u<e.length;++u)for(a=a<<8|e[u],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(s!==0&&(o+=t[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o}function pr({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return uy({prefix:t,name:e,encode(i){return VS(i,n,r)},decode(i){return FS(i,n,r,e)}})}var Ls=pr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),FU=pr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),VU=pr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),zU=pr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),KU=pr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),qU=pr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),GU=pr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),WU=pr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),HU=pr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),sc=Vs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),JU=Vs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Cr=Vs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),XU=Vs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),zS=cy,ey=128,KS=127,qS=~KS,GS=Math.pow(2,31);function cy(e,t,r){t=t||[],r=r||0;for(var n=r;e>=GS;)t[r++]=e&255|ey,e/=128;for(;e&qS;)t[r++]=e&255|ey,e>>>=7;return t[r]=e|0,cy.bytes=r-n+1,t}var WS=ac,HS=128,ty=127;function ac(e,n){var r=0,n=n||0,i=0,o=n,s,a=e.length;do{if(o>=a)throw ac.bytes=0,new RangeError("Could not decode varint");s=e[o++],r+=i<28?(s&ty)<<i:(s&ty)*Math.pow(2,i),i+=7}while(s>=HS);return ac.bytes=o-n,r}var JS=Math.pow(2,7),XS=Math.pow(2,14),YS=Math.pow(2,21),QS=Math.pow(2,28),ZS=Math.pow(2,35),eC=Math.pow(2,42),tC=Math.pow(2,49),rC=Math.pow(2,56),nC=Math.pow(2,63),iC=function(e){return e<JS?1:e<XS?2:e<YS?3:e<QS?4:e<ZS?5:e<eC?6:e<tC?7:e<rC?8:e<nC?9:10},oC={encode:zS,decode:WS,encodingLength:iC},sC=oC,ks=sC;function uc(e,t=0){return[ks.decode(e,t),ks.decode.bytes]}function js(e,t,r=0){return ks.encode(e,t,r),t}function Fs(e){return ks.encodingLength(e)}function aC(e,t){let r=t.byteLength,n=Fs(e),i=n+Fs(r),o=new Uint8Array(i+r);return js(e,o,0),js(r,o,n),o.set(t,i),new pc(e,r,t,o)}function uC(e){let t=dc(e),[r,n]=uc(t),[i,o]=uc(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new pc(r,i,s,t)}function cC(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&$S(e.bytes,r.bytes)}}var pc=class{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}};function ry(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return lC(r,cc(e),t??Cr.encoder);default:return dC(r,cc(e),t??Ls.encoder)}}var ny=new WeakMap;function cc(e){let t=ny.get(e);if(t==null){let r=new Map;return ny.set(e,r),r}return t}var fy=class tt{code;version;multihash;bytes;"/";constructor(t,r,n,i){this.code=r,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}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!==Gi)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==pC)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return tt.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=aC(t,r);return tt.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 tt.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&cC(t.multihash,n.multihash)}toString(t){return ry(this,t)}toJSON(){return{"/":ry(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 tt)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:o,bytes:s}=r;return new tt(n,i,o,s??iy(n,i,o.bytes))}else if(r[hC]===!0){let{version:n,multihash:i,code:o}=r,s=uC(i);return tt.create(n,o,s)}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!==Gi)throw new Error(`Version 0 CID must use dag-pb (code: ${Gi}) block encoding`);return new tt(t,r,n,n.bytes)}case 1:{let i=iy(t,r,n.bytes);return new tt(t,r,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return tt.create(0,Gi,t)}static createV1(t,r){return tt.create(1,t,r)}static decode(t){let[r,n]=tt.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=tt.inspectBytes(t),n=r.size-r.multihashSize,i=dc(t.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let o=i.subarray(r.multihashSize-r.digestSize),s=new pc(r.multihashCode,r.digestSize,o,i);return[r.version===0?tt.createV0(s):tt.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[p,S]=uc(t.subarray(r));return r+=S,p},i=n(),o=Gi;if(i===18?(i=0,r=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,a=n(),u=n(),c=r+u,l=c-s;return{version:i,codec:o,multihashCode:a,digestSize:u,multihashSize:l,size:c}}static parse(t,r){let[n,i]=fC(t,r),o=tt.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return cc(o).set(n,t),o}};function fC(e,t){switch(e[0]){case"Q":{let r=t??Cr;return[Cr.prefix,r.decode(`${Cr.prefix}${e}`)]}case Cr.prefix:{let r=t??Cr;return[Cr.prefix,r.decode(e)]}case Ls.prefix:{let r=t??Ls;return[Ls.prefix,r.decode(e)]}case sc.prefix:{let r=t??sc;return[sc.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function lC(e,t,r){let{prefix:n}=r;if(n!==Cr.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=t.get(n);if(i==null){let o=r.encode(e).slice(1);return t.set(n,o),o}else return i}function dC(e,t,r){let{prefix:n}=r,i=t.get(n);if(i==null){let o=r.encode(e);return t.set(n,o),o}else return i}var Gi=112,pC=18;function iy(e,t,r){let n=Fs(e),i=n+Fs(t),o=new Uint8Array(i+r.byteLength);return js(e,o,0),js(t,o,n),o.set(r,i),o}var hC=Symbol.for("@ipld/js-cid/CID"),ly=42;function yC(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=fy.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new ee(B.tag,ly),new ee(B.bytes,r)]}function gC(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function mC(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 oy={float64:!0,typeEncoders:{Object:yC,undefined:gC,number:mC}},YU={...oy,typeEncoders:{...oy.typeEncoders}};function bC(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return fy.decode(e.subarray(1))}var fc={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};fc.tags[ly]=bC;var QU={...fc,tags:fc.tags.slice()};var ZU=Nt(lc(),1);var Nr={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},Wi={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":Nr.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(Nr.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=Wi["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let i=t;i<e.length;i++){let o=e[i];if(o=Wi["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](o),o===void 0)return;n.push(o)}return n}}return e}},Int:Nr.Int,CarV1HeaderOrV2Pragma:e=>{if(Nr.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let i=0;i<t.length;i++){let[o,s]=t[i];switch(o){case"roots":{let a=Wi["CarV1HeaderOrV2Pragma > roots (anon)"](e[o]);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.roots=a}}break;case"version":{n--;let a=Wi.Int(e[o]);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},Hi={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":Nr.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(Nr.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=Hi["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let i=t;i<e.length;i++){let o=e[i];if(o=Hi["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](o),o===void 0)return;n.push(o)}return n}}return e}},Int:Nr.Int,CarV1HeaderOrV2Pragma:e=>{if(Nr.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let i=0;i<t.length;i++){let[o,s]=t[i];switch(o){case"roots":{let a=Hi["CarV1HeaderOrV2Pragma > roots (anon)"](s);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.roots=a}}break;case"version":{n--;let a=Hi.Int(s);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},eB={toTyped:Wi.CarV1HeaderOrV2Pragma,toRepresentation:Hi.CarV1HeaderOrV2Pragma},tB=$u(),rB=Nt(lc(),1),nB=[new ee(B.map,2),new ee(B.string,"version"),new ee(B.uint,1),new ee(B.string,"roots")],iB=new ee(B.tag,42);var oB=Nt(lc(),1);var{WARN:dy,LOG:sB,DEBUG:sy,VERBOSE:hc,ERROR:Ms}=$e.setup($e.INFO);async function yc(e){let t=await py(e);return await gc(t)}async function gc({rootCID:e,blockStore:t},r=[]){if(!e||!t)throw Ms("Empty roots/blocks",{rootCID:e,blockStore:t});let n=await Yn(t,e),i,o=null,s=null;if(hc("[decodePubFromBlocks] root:",e.toString(),n,{blockStore:t}),!n)throw Ms("root not found in blockStore",{blockStore:t,rootCID:e});if(n?.info){o=n.applogs;let l=await Yn(t,o);i=await _C(l,t),s=await Yn(t,n.info),sy("new format - infoLogs",s.logs.map(p=>({[p.toString()]:p})))}else i=n.applogs;let a=async l=>{let p=l,S=await Yn(t,p);if(!S)throw Ms("Could not find applog CID in pub blocks:",p.toString(),{cid:p,root:n,blockStore:t}),new Error(`Could not find applog CID in pub blocks: ${p.toString()}`);return S.pv instanceof $t&&(S.pv=S.pv.toV1().toString()),{...S,cid:p.toV1().toString()}},u;if(u=await Promise.all(i.map(a)),n.prev){if(Es(n.prev,e)||Vu(r,n.prev))throw Ms("[pubFromBlocks] pub chain has a loop",{rootCID:e,prev:n.prev,recursionTrace:r});u.push(...(await gc({rootCID:n.prev,blockStore:t},[...r,e])).applogs)}let c={cid:e,info:{...s,logs:await Promise.all(s.logs.map(a))},applogsCID:o,applogs:u};return sy("[decodePubFromBlocks] result:",c,{rootCID:e.toString(),root:n,blockStore:t,applogs:u,info:s}),c}async function py(e){let r=(await e.getRoots()).map(i=>(typeof i.toV1=="function"?i:$t.decode(i.bytes)).toV1().toString()),n=new Map;for await(let{cid:i,bytes:o}of e.blocks()){let s=typeof i.toV1=="function"?i:$t.decode(i.bytes);hc({cidFromCarblocks:i,cid:s}),n.set(s.toV1().toString(),o)}return r.length!==1&&dy("Unexpected roots count:",r),{rootCID:$t.parse(r[0]),blockStore:{get:i=>n.get(i.toV1().toString())}}}async function Yn(e,t){try{var r=await e.get(t);if(!r)return dy("returning null"),null}catch(n){if(n.message==="Not Found")return null;throw n}return Ts(r)}function mc(e){return async function*(){for(;;){let{done:t,value:r}=await e.read();if(hc("[car] chunk",{done:t,value:r}),t)break;yield r}}()}var{WARN:aB,LOG:uB,DEBUG:cB,VERBOSE:fB,ERROR:vC}=$e.setup($e.INFO);async function _C(e,t){return wC(e)?(await Promise.all(e.chunks.map(async r=>{let n=await Yn(t,r);if(!n.logs)throw vC("Weird chunk",n);return n.logs}))).flat():e.logs}function wC(e){return e.chunks}var{WARN:Ks,LOG:t2,DEBUG:Ji,VERBOSE:r2,ERROR:zs}=Xs.setup(Xs.INFO);async function n2(e,t,{readOnly:r=!0,pinnedCID:n}={}){let{cid:i,errors:o,isIpns:s}=Fu(t);if(!i)throw zs("Failed to parse pubID",t,o);Ji("[retrieveThread] parsedPubID",i);let a;if(n)Ji("[retrieveThread] using pinnedCID"),s||Ks("pubID isn't IPNS, but pinnedCID different:",{pubID:t,pinnedCID:n}),a=tr.parse(n);else if(!s)Ji("[retrieveThread] pubID is not IPNS - using as CID"),a=i;else{if(!t)throw zs("[retrieveThread] neither pubID nor pinnedCID provided");try{a=await TC(e.baseUrl,t),Ji("Resolved pub to CID",a.toString())}catch(x){throw zs(`Failed to resolve IPNS ${t}:`,x)}}let u=await AC(e.gatewayBaseUrl,a),{applogs:c}=await yc(u),l=c.filter(x=>As(x));l.length&&Ks(`Found ${l.length} encrypted logs - skipping`);let p=c.filter(x=>!(x instanceof Uint8Array));Sr(p);let S=Xn.fromArray(p,`preview${t&&t!==a.toString()?"-"+t:""}@${a.toString()}`,r);return{cid:a,thread:S,encryptedCount:l.length}}async function TC(e,t){e=Ys(e);let n=await(await fetch(`${e}/name/${t}`)).json();return n.value.startsWith("/ipfs/")||Ks("IPNS value is not '/ipfs/..':",n),tr.parse(n.value.replace("/ipfs/",""))}async function AC(e,t){e=Ys(e),Ji("Retrieving:",t.toString(),"from",e);let r=`${e}/ipfs/${t}?format=car&dag-scope=all`,n=await fetch(r),i;if((!n?.ok||!n?.body)&&(i=zs(`[retrieveCar] unexpected response ${n?.statusText}`,{url:r}),Ks("Gateway failed:",r,i)),i=mc(n.body.getReader()),i instanceof Error)throw i;return await Dr.fromIterable(i)}export{n2 as a,TC as b,AC as c};
|
|
61
|
+
`)}var nA=rA;function iA(e){return function(){return e}}var oA=iA,sA=function(){try{var e=un(Object,"defineProperty");return e({},"",{}),e}catch{}}(),fs=sA,aA=fs?function(e,t){return fs(e,"toString",{configurable:!0,enumerable:!1,value:oA(t),writable:!0})}:Is,uA=aA,cA=hh(uA),Wu=cA;function fA(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var lA=fA;function dA(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o<i;)if(t(e[o],o,e))return o;return-1}var pA=dA;function hA(e){return e!==e}var yA=hA;function gA(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1}var mA=gA;function bA(e,t,r){return t===t?mA(e,t,r):pA(e,yA,r)}var vA=bA;function _A(e,t){var r=e==null?0:e.length;return!!r&&vA(e,t,0)>-1}var wA=_A,TA=1,AA=2,OA=8,EA=16,IA=32,xA=64,SA=128,CA=256,NA=512,RA=[["ary",SA],["bind",TA],["bindKey",AA],["curry",OA],["curryRight",EA],["flip",NA],["partial",IA],["partialRight",xA],["rearg",CA]];function $A(e,t){return lA(RA,function(r){var n="_."+r[0];t&r[1]&&!wA(e,n)&&e.push(n)}),e.sort()}var PA=$A;function UA(e,t,r){var n=t+"";return Wu(e,nA(n,PA(eA(n),r)))}var gh=UA,BA=1,DA=2,MA=4,LA=8,Ud=32,Bd=64;function kA(e,t,r,n,i,o,s,a,u,c){var l=t&LA,p=l?s:void 0,S=l?void 0:s,x=l?o:void 0,E=l?void 0:o;t|=l?Ud:Bd,t&=~(l?Bd:Ud),t&MA||(t&=~(BA|DA));var z=[e,t,i,x,p,E,S,a,u,c],W=r.apply(void 0,z);return qT(e)&&yh(W,z),W.placeholder=n,gh(W,e,t)}var mh=kA;function jA(e){var t=e;return t.placeholder}var Hu=jA,FA=9007199254740991,VA=/^(?:0|[1-9]\d*)$/;function zA(e,t){var r=typeof e;return t=t??FA,!!t&&(r=="number"||r!="symbol"&&VA.test(e))&&e>-1&&e%1==0&&e<t}var xs=zA,KA=Math.min;function qA(e,t){for(var r=e.length,n=KA(t.length,r),i=ph(e);n--;){var o=t[n];e[n]=xs(o,r)?i[o]:void 0}return e}var GA=qA,Dd="__lodash_placeholder__";function WA(e,t){for(var r=-1,n=e.length,i=0,o=[];++r<n;){var s=e[r];(s===t||s===Dd)&&(e[r]=Dd,o[i++]=r)}return o}var Li=WA,HA=1,JA=2,XA=8,YA=16,QA=128,ZA=512;function bh(e,t,r,n,i,o,s,a,u,c){var l=t&QA,p=t&HA,S=t&JA,x=t&(XA|YA),E=t&ZA,z=S?void 0:Mi(e);function W(){for(var T=arguments.length,k=Array(T),G=T;G--;)k[G]=arguments[G];if(x)var H=Hu(W),F=ST(k,H);if(n&&(k=ch(k,n,i,x)),o&&(k=fh(k,o,s,x)),T-=F,x&&T<c){var Y=Li(k,H);return mh(e,t,bh,W.placeholder,r,k,Y,a,u,c-T)}var V=p?r:this,ae=S?V[e]:e;return T=k.length,a?k=GA(k,a):E&&T>1&&k.reverse(),l&&u<T&&(k.length=u),this&&this!==mt&&this instanceof W&&(ae=z||Mi(ae)),ae.apply(V,k)}return W}var vh=bh;function e1(e,t,r){var n=Mi(e);function i(){for(var o=arguments.length,s=Array(o),a=o,u=Hu(i);a--;)s[a]=arguments[a];var c=o<3&&s[0]!==u&&s[o-1]!==u?[]:Li(s,u);if(o-=c.length,o<r)return mh(e,t,vh,i.placeholder,void 0,s,c,void 0,void 0,r-o);var l=this&&this!==mt&&this instanceof i?n:e;return Ku(l,this,s)}return i}var t1=e1,r1=1;function n1(e,t,r,n){var i=t&r1,o=Mi(e);function s(){for(var a=-1,u=arguments.length,c=-1,l=n.length,p=Array(l+u),S=this&&this!==mt&&this instanceof s?o:e;++c<l;)p[c]=n[c];for(;u--;)p[c++]=arguments[++a];return Ku(S,i?r:this,p)}return s}var i1=n1,Md="__lodash_placeholder__",Za=1,o1=2,s1=4,Ld=8,Ri=128,kd=256,a1=Math.min;function u1(e,t){var r=e[1],n=t[1],i=r|n,o=i<(Za|o1|Ri),s=n==Ri&&r==Ld||n==Ri&&r==kd&&e[7].length<=t[8]||n==(Ri|kd)&&t[7].length<=t[8]&&r==Ld;if(!(o||s))return e;n&Za&&(e[2]=t[2],i|=r&Za?0:s1);var a=t[3];if(a){var u=e[3];e[3]=u?ch(u,a,t[4]):a,e[4]=u?Li(e[3],Md):t[4]}return a=t[5],a&&(u=e[5],e[5]=u?fh(u,a,t[6]):a,e[6]=u?Li(e[5],Md):t[6]),a=t[7],a&&(e[7]=a),n&Ri&&(e[8]=e[8]==null?t[8]:a1(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=i,e}var c1=u1,f1="Expected a function",jd=1,l1=2,eu=8,tu=16,ru=32,Fd=64,Vd=Math.max;function d1(e,t,r,n,i,o,s,a){var u=t&l1;if(!u&&typeof e!="function")throw new TypeError(f1);var c=n?n.length:0;if(c||(t&=~(ru|Fd),n=i=void 0),s=s===void 0?s:Vd(Nd(s),0),a=a===void 0?a:Nd(a),c-=i?i.length:0,t&Fd){var l=n,p=i;n=i=void 0}var S=u?void 0:dh(e),x=[e,t,r,n,i,l,p,o,s,a];if(S&&c1(x,S),e=x[0],t=x[1],r=x[2],n=x[3],i=x[4],a=x[9]=x[9]===void 0?u?0:e.length:Vd(x[9]-c,0),!a&&t&(eu|tu)&&(t&=~(eu|tu)),!t||t==jd)var E=wT(e,t,r);else t==eu||t==tu?E=t1(e,t,a):(t==ru||t==(jd|ru))&&!i.length?E=i1(e,t,r,n):E=vh.apply(void 0,x);var z=S?uh:yh;return gh(z(E,x),e,t)}var p1=d1;function h1(e,t,r){t=="__proto__"&&fs?fs(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var y1=h1;function g1(e,t){return e===t||e!==e&&t!==t}var Ju=g1,m1=Object.prototype,b1=m1.hasOwnProperty;function v1(e,t,r){var n=e[t];(!(b1.call(e,t)&&Ju(n,r))||r===void 0&&!(t in e))&&y1(e,t,r)}var _1=v1,zd=Math.max;function w1(e,t,r){return t=zd(t===void 0?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=zd(n.length-t,0),s=Array(o);++i<o;)s[i]=n[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=n[i];return a[t]=r(s),Ku(e,this,a)}}var _h=w1;function T1(e,t){return Wu(_h(e,t,Is),e+"")}var A1=T1,O1=9007199254740991;function E1(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=O1}var Xu=E1;function I1(e){return e!=null&&Xu(e.length)&&!ah(e)}var x1=I1,S1=Object.prototype;function C1(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||S1;return e===r}var N1=C1;function R1(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var $1=R1,P1="[object Arguments]";function U1(e){return en(e)&&qn(e)==P1}var Kd=U1,wh=Object.prototype,B1=wh.hasOwnProperty,D1=wh.propertyIsEnumerable,M1=Kd(function(){return arguments}())?Kd:function(e){return en(e)&&B1.call(e,"callee")&&!D1.call(e,"callee")},Yu=M1;function L1(){return!1}var k1=L1,Th=typeof exports=="object"&&exports&&!exports.nodeType&&exports,qd=Th&&typeof module=="object"&&module&&!module.nodeType&&module,j1=qd&&qd.exports===Th,Gd=j1?mt.Buffer:void 0,F1=Gd?Gd.isBuffer:void 0,V1=F1||k1,hu=V1,z1="[object Arguments]",K1="[object Array]",q1="[object Boolean]",G1="[object Date]",W1="[object Error]",H1="[object Function]",J1="[object Map]",X1="[object Number]",Y1="[object Object]",Q1="[object RegExp]",Z1="[object Set]",eO="[object String]",tO="[object WeakMap]",rO="[object ArrayBuffer]",nO="[object DataView]",iO="[object Float32Array]",oO="[object Float64Array]",sO="[object Int8Array]",aO="[object Int16Array]",uO="[object Int32Array]",cO="[object Uint8Array]",fO="[object Uint8ClampedArray]",lO="[object Uint16Array]",dO="[object Uint32Array]",De={};De[iO]=De[oO]=De[sO]=De[aO]=De[uO]=De[cO]=De[fO]=De[lO]=De[dO]=!0;De[z1]=De[K1]=De[rO]=De[q1]=De[nO]=De[G1]=De[W1]=De[H1]=De[J1]=De[X1]=De[Y1]=De[Q1]=De[Z1]=De[eO]=De[tO]=!1;function pO(e){return en(e)&&Xu(e.length)&&!!De[qn(e)]}var hO=pO;function yO(e){return function(t){return e(t)}}var gO=yO,Ah=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Pi=Ah&&typeof module=="object"&&module&&!module.nodeType&&module,mO=Pi&&Pi.exports===Ah,nu=mO&&ih.process,bO=function(){try{var e=Pi&&Pi.require&&Pi.require("util").types;return e||nu&&nu.binding&&nu.binding("util")}catch{}}(),Wd=bO,Hd=Wd&&Wd.isTypedArray,vO=Hd?gO(Hd):hO,Oh=vO,_O=Object.prototype,wO=_O.hasOwnProperty;function TO(e,t){var r=Kt(e),n=!r&&Yu(e),i=!r&&!n&&hu(e),o=!r&&!n&&!i&&Oh(e),s=r||n||i||o,a=s?$1(e.length,String):[],u=a.length;for(var c in e)(t||wO.call(e,c))&&!(s&&(c=="length"||i&&(c=="offset"||c=="parent")||o&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||xs(c,u)))&&a.push(c);return a}var AO=TO;function OO(e,t){return function(r){return e(t(r))}}var EO=OO,IO=EO(Object.keys,Object),xO=IO,SO=Object.prototype,CO=SO.hasOwnProperty;function NO(e){if(!N1(e))return xO(e);var t=[];for(var r in Object(e))CO.call(e,r)&&r!="constructor"&&t.push(r);return t}var RO=NO;function $O(e){return x1(e)?AO(e):RO(e)}var Eh=$O,PO=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,UO=/^\w*$/;function BO(e,t){if(Kt(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Ln(e)?!0:UO.test(e)||!PO.test(e)||t!=null&&e in Object(t)}var Qu=BO,DO=un(Object,"create"),ki=DO;function MO(){this.__data__=ki?ki(null):{},this.size=0}var LO=MO;function kO(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var jO=kO,FO="__lodash_hash_undefined__",VO=Object.prototype,zO=VO.hasOwnProperty;function KO(e){var t=this.__data__;if(ki){var r=t[e];return r===FO?void 0:r}return zO.call(t,e)?t[e]:void 0}var qO=KO,GO=Object.prototype,WO=GO.hasOwnProperty;function HO(e){var t=this.__data__;return ki?t[e]!==void 0:WO.call(t,e)}var JO=HO,XO="__lodash_hash_undefined__";function YO(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=ki&&t===void 0?XO:t,this}var QO=YO;function Gn(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Gn.prototype.clear=LO;Gn.prototype.delete=jO;Gn.prototype.get=qO;Gn.prototype.has=JO;Gn.prototype.set=QO;var Jd=Gn;function ZO(){this.__data__=[],this.size=0}var eE=ZO;function tE(e,t){for(var r=e.length;r--;)if(Ju(e[r][0],t))return r;return-1}var Ss=tE,rE=Array.prototype,nE=rE.splice;function iE(e){var t=this.__data__,r=Ss(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():nE.call(t,r,1),--this.size,!0}var oE=iE;function sE(e){var t=this.__data__,r=Ss(t,e);return r<0?void 0:t[r][1]}var aE=sE;function uE(e){return Ss(this.__data__,e)>-1}var cE=uE;function fE(e,t){var r=this.__data__,n=Ss(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}var lE=fE;function Wn(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Wn.prototype.clear=eE;Wn.prototype.delete=oE;Wn.prototype.get=aE;Wn.prototype.has=cE;Wn.prototype.set=lE;var Cs=Wn,dE=un(mt,"Map"),ji=dE;function pE(){this.size=0,this.__data__={hash:new Jd,map:new(ji||Cs),string:new Jd}}var hE=pE;function yE(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var gE=yE;function mE(e,t){var r=e.__data__;return gE(t)?r[typeof t=="string"?"string":"hash"]:r.map}var Ns=mE;function bE(e){var t=Ns(this,e).delete(e);return this.size-=t?1:0,t}var vE=bE;function _E(e){return Ns(this,e).get(e)}var wE=_E;function TE(e){return Ns(this,e).has(e)}var AE=TE;function OE(e,t){var r=Ns(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}var EE=OE;function Hn(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Hn.prototype.clear=hE;Hn.prototype.delete=vE;Hn.prototype.get=wE;Hn.prototype.has=AE;Hn.prototype.set=EE;var Rs=Hn,IE="Expected a function";function Zu(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(IE);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(Zu.Cache||Rs),r}Zu.Cache=Rs;var xE=Zu,SE=500;function CE(e){var t=xE(e,function(n){return r.size===SE&&r.clear(),n}),r=t.cache;return t}var NE=CE,RE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$E=/\\(\\)?/g,PE=NE(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(RE,function(r,n,i,o){t.push(i?o.replace($E,"$1"):n||r)}),t}),UE=PE;function BE(e){return e==null?"":I0(e)}var DE=BE;function ME(e,t){return Kt(e)?e:Qu(e,t)?[e]:UE(DE(e))}var $s=ME,LE=1/0;function kE(e){if(typeof e=="string"||Ln(e))return e;var t=e+"";return t=="0"&&1/e==-LE?"-0":t}var Ki=kE;function jE(e,t){t=$s(t,e);for(var r=0,n=t.length;e!=null&&r<n;)e=e[Ki(t[r++])];return r&&r==n?e:void 0}var ec=jE;function FE(e,t,r){var n=e==null?void 0:ec(e,t);return n===void 0?r:n}var VE=FE;function zE(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var Ih=zE,Xd=Qt?Qt.isConcatSpreadable:void 0;function KE(e){return Kt(e)||Yu(e)||!!(Xd&&e&&e[Xd])}var qE=KE;function xh(e,t,r,n,i){var o=-1,s=e.length;for(r||(r=qE),i||(i=[]);++o<s;){var a=e[o];t>0&&r(a)?t>1?xh(a,t-1,r,n,i):Ih(i,a):n||(i[i.length]=a)}return i}var GE=xh;function WE(e){var t=e==null?0:e.length;return t?GE(e,1):[]}var HE=WE;function JE(e){return Wu(_h(e,void 0,HE),e+"")}var XE=JE;function YE(){this.__data__=new Cs,this.size=0}var QE=YE;function ZE(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var eI=ZE;function tI(e){return this.__data__.get(e)}var rI=tI;function nI(e){return this.__data__.has(e)}var iI=nI,oI=200;function sI(e,t){var r=this.__data__;if(r instanceof Cs){var n=r.__data__;if(!ji||n.length<oI-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Rs(n)}return r.set(e,t),this.size=r.size,this}var aI=sI;function Jn(e){var t=this.__data__=new Cs(e);this.size=t.size}Jn.prototype.clear=QE;Jn.prototype.delete=eI;Jn.prototype.get=rI;Jn.prototype.has=iI;Jn.prototype.set=aI;var Wo=Jn;function uI(e,t){for(var r=-1,n=e==null?0:e.length,i=0,o=[];++r<n;){var s=e[r];t(s,r,e)&&(o[i++]=s)}return o}var cI=uI;function fI(){return[]}var lI=fI,dI=Object.prototype,pI=dI.propertyIsEnumerable,Yd=Object.getOwnPropertySymbols,hI=Yd?function(e){return e==null?[]:(e=Object(e),cI(Yd(e),function(t){return pI.call(e,t)}))}:lI,yI=hI;function gI(e,t,r){var n=t(e);return Kt(e)?n:Ih(n,r(e))}var mI=gI;function bI(e){return mI(e,Eh,yI)}var Qd=bI,vI=un(mt,"DataView"),yu=vI,_I=un(mt,"Promise"),gu=_I,wI=un(mt,"Set"),Mn=wI,Zd="[object Map]",TI="[object Object]",ep="[object Promise]",tp="[object Set]",rp="[object WeakMap]",np="[object DataView]",AI=an(yu),OI=an(ji),EI=an(gu),II=an(Mn),xI=an(Di),Yr=qn;(yu&&Yr(new yu(new ArrayBuffer(1)))!=np||ji&&Yr(new ji)!=Zd||gu&&Yr(gu.resolve())!=ep||Mn&&Yr(new Mn)!=tp||Di&&Yr(new Di)!=rp)&&(Yr=function(e){var t=qn(e),r=t==TI?e.constructor:void 0,n=r?an(r):"";if(n)switch(n){case AI:return np;case OI:return Zd;case EI:return ep;case II:return tp;case xI:return rp}return t});var ip=Yr,SI=mt.Uint8Array,op=SI,CI="__lodash_hash_undefined__";function NI(e){return this.__data__.set(e,CI),this}var RI=NI;function $I(e){return this.__data__.has(e)}var PI=$I;function ls(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new Rs;++t<r;)this.add(e[t])}ls.prototype.add=ls.prototype.push=RI;ls.prototype.has=PI;var UI=ls;function BI(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var DI=BI;function MI(e,t){return e.has(t)}var LI=MI,kI=1,jI=2;function FI(e,t,r,n,i,o){var s=r&kI,a=e.length,u=t.length;if(a!=u&&!(s&&u>a))return!1;var c=o.get(e),l=o.get(t);if(c&&l)return c==t&&l==e;var p=-1,S=!0,x=r&jI?new UI:void 0;for(o.set(e,t),o.set(t,e);++p<a;){var E=e[p],z=t[p];if(n)var W=s?n(z,E,p,t,e,o):n(E,z,p,e,t,o);if(W!==void 0){if(W)continue;S=!1;break}if(x){if(!DI(t,function(T,k){if(!LI(x,k)&&(E===T||i(E,T,r,n,o)))return x.push(k)})){S=!1;break}}else if(!(E===z||i(E,z,r,n,o))){S=!1;break}}return o.delete(e),o.delete(t),S}var Sh=FI;function VI(e){var t=-1,r=Array(e.size);return e.forEach(function(n,i){r[++t]=[i,n]}),r}var zI=VI;function KI(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var Ch=KI,qI=1,GI=2,WI="[object Boolean]",HI="[object Date]",JI="[object Error]",XI="[object Map]",YI="[object Number]",QI="[object RegExp]",ZI="[object Set]",ex="[object String]",tx="[object Symbol]",rx="[object ArrayBuffer]",nx="[object DataView]",sp=Qt?Qt.prototype:void 0,iu=sp?sp.valueOf:void 0;function ix(e,t,r,n,i,o,s){switch(r){case nx:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case rx:return!(e.byteLength!=t.byteLength||!o(new op(e),new op(t)));case WI:case HI:case YI:return Ju(+e,+t);case JI:return e.name==t.name&&e.message==t.message;case QI:case ex:return e==t+"";case XI:var a=zI;case ZI:var u=n&qI;if(a||(a=Ch),e.size!=t.size&&!u)return!1;var c=s.get(e);if(c)return c==t;n|=GI,s.set(e,t);var l=Sh(a(e),a(t),n,i,o,s);return s.delete(e),l;case tx:if(iu)return iu.call(e)==iu.call(t)}return!1}var ox=ix,sx=1,ax=Object.prototype,ux=ax.hasOwnProperty;function cx(e,t,r,n,i,o){var s=r&sx,a=Qd(e),u=a.length,c=Qd(t),l=c.length;if(u!=l&&!s)return!1;for(var p=u;p--;){var S=a[p];if(!(s?S in t:ux.call(t,S)))return!1}var x=o.get(e),E=o.get(t);if(x&&E)return x==t&&E==e;var z=!0;o.set(e,t),o.set(t,e);for(var W=s;++p<u;){S=a[p];var T=e[S],k=t[S];if(n)var G=s?n(k,T,S,t,e,o):n(T,k,S,e,t,o);if(!(G===void 0?T===k||i(T,k,r,n,o):G)){z=!1;break}W||(W=S=="constructor")}if(z&&!W){var H=e.constructor,F=t.constructor;H!=F&&"constructor"in e&&"constructor"in t&&!(typeof H=="function"&&H instanceof H&&typeof F=="function"&&F instanceof F)&&(z=!1)}return o.delete(e),o.delete(t),z}var fx=cx,lx=1,ap="[object Arguments]",up="[object Array]",Ko="[object Object]",dx=Object.prototype,cp=dx.hasOwnProperty;function px(e,t,r,n,i,o){var s=Kt(e),a=Kt(t),u=s?up:ip(e),c=a?up:ip(t);u=u==ap?Ko:u,c=c==ap?Ko:c;var l=u==Ko,p=c==Ko,S=u==c;if(S&&hu(e)){if(!hu(t))return!1;s=!0,l=!1}if(S&&!l)return o||(o=new Wo),s||Oh(e)?Sh(e,t,r,n,i,o):ox(e,t,u,r,n,i,o);if(!(r&lx)){var x=l&&cp.call(e,"__wrapped__"),E=p&&cp.call(t,"__wrapped__");if(x||E){var z=x?e.value():e,W=E?t.value():t;return o||(o=new Wo),i(z,W,r,n,o)}}return S?(o||(o=new Wo),fx(e,t,r,n,i,o)):!1}var hx=px;function Nh(e,t,r,n,i){return e===t?!0:e==null||t==null||!en(e)&&!en(t)?e!==e&&t!==t:hx(e,t,r,n,Nh,i)}var Rh=Nh,yx=1,gx=2;function mx(e,t,r,n){var i=r.length,o=i,s=!n;if(e==null)return!o;for(e=Object(e);i--;){var a=r[i];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++i<o;){a=r[i];var u=a[0],c=e[u],l=a[1];if(s&&a[2]){if(c===void 0&&!(u in e))return!1}else{var p=new Wo;if(n)var S=n(c,l,u,e,t,p);if(!(S===void 0?Rh(l,c,yx|gx,n,p):S))return!1}}return!0}var bx=mx;function vx(e){return e===e&&!cr(e)}var $h=vx;function _x(e){for(var t=Eh(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,$h(i)]}return t}var wx=_x;function Tx(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}var Ph=Tx;function Ax(e){var t=wx(e);return t.length==1&&t[0][2]?Ph(t[0][0],t[0][1]):function(r){return r===e||bx(r,e,t)}}var Ox=Ax;function Ex(e,t){return e!=null&&t in Object(e)}var Ix=Ex;function xx(e,t,r){t=$s(t,e);for(var n=-1,i=t.length,o=!1;++n<i;){var s=Ki(t[n]);if(!(o=e!=null&&r(e,s)))break;e=e[s]}return o||++n!=i?o:(i=e==null?0:e.length,!!i&&Xu(i)&&xs(s,i)&&(Kt(e)||Yu(e)))}var Sx=xx;function Cx(e,t){return e!=null&&Sx(e,t,Ix)}var Uh=Cx,Nx=1,Rx=2;function $x(e,t){return Qu(e)&&$h(t)?Ph(Ki(e),t):function(r){var n=VE(r,e);return n===void 0&&n===t?Uh(r,e):Rh(t,n,Nx|Rx)}}var Px=$x;function Ux(e){return function(t){return t?.[e]}}var Bx=Ux;function Dx(e){return function(t){return ec(t,e)}}var Mx=Dx;function Lx(e){return Qu(e)?Bx(Ki(e)):Mx(e)}var kx=Lx;function jx(e){return typeof e=="function"?e:e==null?Is:typeof e=="object"?Kt(e)?Px(e[0],e[1]):Ox(e):kx(e)}var Fx=jx;function Vx(e,t,r,n){if(!cr(e))return e;t=$s(t,e);for(var i=-1,o=t.length,s=o-1,a=e;a!=null&&++i<o;){var u=Ki(t[i]),c=r;if(u==="__proto__"||u==="constructor"||u==="prototype")return e;if(i!=s){var l=a[u];c=n?n(l,u,a):void 0,c===void 0&&(c=cr(l)?l:xs(t[i+1])?[]:{})}_1(a,u,c),a=a[u]}return e}var zx=Vx;function Kx(e,t,r){for(var n=-1,i=t.length,o={};++n<i;){var s=t[n],a=ec(e,s);r(a,s)&&zx(o,$s(s,e),a)}return o}var qx=Kx,Gx=32,tc=A1(function(e,t){var r=Li(t,Hu(tc));return p1(e,Gx,void 0,t,r)});tc.placeholder={};var Wx=tc;function Hx(e,t){return qx(e,t,function(r,n){return Uh(e,n)})}var Jx=Hx,Xx=XE(function(e,t){return e==null?{}:Jx(e,t)}),fp=Xx,Yx=4294967295,Qx=Yx-1,Zx=Math.floor,eS=Math.min;function tS(e,t,r,n){var i=0,o=e==null?0:e.length;if(o===0)return 0;t=r(t);for(var s=t!==t,a=t===null,u=Ln(t),c=t===void 0;i<o;){var l=Zx((i+o)/2),p=r(e[l]),S=p!==void 0,x=p===null,E=p===p,z=Ln(p);if(s)var W=n||E;else c?W=E&&(n||S):a?W=E&&S&&(n||!x):u?W=E&&S&&!x&&(n||!z):x||z?W=!1:W=n?p<=t:p<t;W?i=l+1:o=l}return eS(o,Qx)}var rS=tS;function nS(e,t,r){return rS(e,t,Fx(r,2))}var iS=nS,oS=1/0,iP=Mn&&1/Ch(new Mn([,-0]))[1]==oS?function(e){return new Mn(e)}:lh;var{WARN:oP,LOG:sP,DEBUG:aP,VERBOSE:sS,ERROR:aS}=$e.setup($e.INFO),Bh=(e,t,r="asc")=>r==="asc"?e.localeCompare(t,"en-US"):t.localeCompare(e,"en-US"),rc=(e,t,r)=>Ge.structural(fp(t,e),fp(r,e)),Dh=(e,t,r="asc")=>Bh(e.ts,t.ts,r),uS=Wx(rc,["en","at"]);function Sr(e,t="asc"){return e.sort((r,n)=>Dh(r,n,t))}var Mh=(e,t)=>n0(new Date(e.ts),new Date(t.ts));var nc=e=>{let t=new Map;for(let r of e){if(!r)throw aS("falsy entry in applogs",e),new Error("falsy entry in applogs");let n=r.cid;t.has(n)?sS("Skipping duplicate applog:",[t.get(n),r]):t.set(n,r)}return Array.from(t.values())};function Lh(e){return typeof e=="string"&&e.startsWith("?")}function kh(e){return e.slice(1)}function Ps(e,t){let r={},n={};for(let[i,o]of Object.entries(e))if(Lh(o)){let s=kh(o),a=t[s];a?n[i]=a:r[i]=s}else n[i]=o;return[n,r]}function jh(e,t,r){let n;if(t){let i=typeof t;i==="string"?n=t===r:i==="function"?n=t(r):typeof t.has=="function"?n=t.has(r):Array.isArray(t)&&!Array.isArray(r)?n=t.includes(r):n=t===r}else n=t===r;return e.charAt(0)==="!"?!n:n}var Fh=function(t){for(var r=0,n=0,i=t.length;n<i;n++)r+=t[n];return r},lp=function(t){return Fh(t)/t.length},yt={max:function(e){return Math.max.apply(null,e)},min:function(e){return Math.min.apply(null,e)},range:function(e){return yt.max(e)-yt.min(e)},midrange:function(e){return yt.range(e)/2},sum:Fh,mean:lp,average:lp,median:function(e){e.sort(function(r,n){return r-n});var t=e.length/2;return t%1?e[t-.5]:(e[t-1]+e[t])/2},modes:function(e){if(!e.length)return[];var t={},r=0,n=[];return e.forEach(function(i){t[i]?t[i]++:t[i]=1,t[i]>r?(n=[i],r=t[i]):t[i]===r&&(n.push(i),r=t[i])}),n},variance:function(e){var t=yt.mean(e);return yt.mean(e.map(function(r){return Math.pow(r-t,2)}))},standardDeviation:function(e){return Math.sqrt(yt.variance(e))},meanAbsoluteDeviation:function(e){var t=yt.mean(e);return yt.mean(e.map(function(r){return Math.abs(r-t)}))},zScores:function(e){var t=yt.mean(e),r=yt.standardDeviation(e);return e.map(function(n){return(n-t)/r})}};yt.average=yt.mean;function ic(){return new Date().toISOString()}var{WARN:cS,LOG:uP,DEBUG:fS,VERBOSE:cP,ERROR:ds}=$e.setup($e.INFO);function Vh(e,t){let r=ic(),n=t;return e.map(o=>zh(o,{ts:r,threadForPv:n}))}function zh(e,{ts:t,threadForPv:r}={}){let n=Gh(e,t??ic()),i=Wh(n,r),o=th(i).toString();e.cid&&e.cid!==o&&cS("[finalizeApplogForInsert] overwriting wrong CID",{log:e,cid:o,logWithPv:i});let s={...i,cid:o};if(!Lu(s))throw ds(`Bogus Applog ${JSON.stringify(s)}`,Qp(s));return Object.freeze(s)}function Kh(e){return!!e.ts}function qh(e){return!!e.pv}function Gh(e,t){return Kh(e)?e:{...e,ts:t}}function Wh(e,t){if(e.pv!==void 0)return e;if(t){let{en:r,at:n}=e,i=t.findLast(s=>s.en==r&&s.at==n);if(rc(["en","at","vl","ts","ag"],e,i))throw ds("[withPvFrom] Same as previous:",{log:e,pv:i,thread:t});let o=(e.pv!==void 0?e.pv:i?.cid)??null;return{...e,pv:o}}else{if(!qh(e))throw ds("[withPvFrom] no thread and no pv:",e);return e}}function qi(e){let t=()=>(Re(()=>e.length<2&&fS(`joinThreads with count=${e.length}`)),Sr(nc(e.flatMap(i=>{let o=i.applogs;if(!o)throw ds("falsy applogs of thread",i),new Error("falsy applogs of thread");return o})))),r=Re(()=>t()),n=st(function(i,o){return Yt(i)?{init:Re(()=>t())}:{added:i.added.filter(s=>!this.hasApplog(s,!0)),removed:i.removed?.filter(s=>!!this.parents.some(u=>u===o?!1:u.hasApplog(s,!0)))}});return new Us(Re(()=>`join(~ ${e.map(i=>i.name).join(", ")})`),e,["?"],r,n)}var{WARN:dp,LOG:fP,DEBUG:pp,VERBOSE:Xr,ERROR:hp}=$e.setup($e.INFO),Us=class Hh extends gs{constructor(t,r,n,i,o,s=null){super(t,r,n,o?Pe.array([...i],{deep:!1,name:`${t}.array`}):i),this.name=t,this._initialLogs=i,this._eventMapper=o,this._writeMapper=s,Tr(this,{onParentUpdate:st}),o&&this.subscribeToParents()}static mapWrites(t,r,n){return new Hh(`${r}<${t.nameAndSizeUntracked}>`,t,t.filters,t._applogs,null,n)}_parentSubscriptions=null;insert(t){let r=this._writeMapper?this._writeMapper(t):t;if(!(this._writeMapper&&!r))return this.parents.forEach(n=>n.insert(r))}insertRaw(t){let r=this._writeMapper?this._writeMapper(t):t;if(!(this._writeMapper&&!r))return this.parents.forEach(n=>n.insertRaw(r))}subscribeToParents(){this._parentSubscriptions=new Map;let t=Ct(()=>{this.parents.length||dp("MappedThread has no parents",this),Xr(`[MappedThread: ${this.name}] subscribing to parents:`,this.parents.map(n=>n.name));let r=new Set([...this._parentSubscriptions.keys()]);for(let n of this.parents){r.delete(n)&&Xr(`[MappedThread: ${this.name}] Skipping re-sub to parent`,n.nameAndSizeUntracked),Xr(`[MappedThread: ${this.name}] sub to new parent`,n.nameAndSizeUntracked);let o=this.onParentUpdate.bind(this,n),s=n.subscribe(o);this._parentSubscriptions.set(n,s)}for(let n of r)Xr(`[MappedThread: ${this.name}] un-subscribing from old parent`,n.nameAndSizeUntracked),this._parentSubscriptions.get(n)(),this._parentSubscriptions.delete(n)})}subscribe(t){return this._parentSubscriptions||this.subscribeToParents(),super.subscribe(t)}triggerRemap(){if(!this._eventMapper)throw hp("triggerRemap on a thread that is not actually mapping?!",this.nameAndSizeUntracked);pp(`MappedThread{${this.nameAndSizeUntracked}} triggerRemap`),this.parents.length!==1&&dp(`MappedThread{${this.nameAndSizeUntracked}} triggerRemap with parentCount=${this.parents.length} - not meant for this`),this.parents.forEach(t=>{this.onParentUpdate(t,{init:Re(()=>ar(t.applogs))})})}onParentUpdate(t,r){Xr(`MappedThread{${this.nameAndSizeUntracked}} parentUpdate`,r);let n=this._eventMapper?this._eventMapper(r,t):r;if(this._eventMapper)if(Xr(`MappedThread{${this.nameAndSizeUntracked}} parentUpdate => mapped`,n),Yt(n))this._applogs.replace([...n.init]);else{for(let i of n.added)this._applogs.splice(iS(this._applogs,i,"ts"),0,i);if(n.removed){for(let i of n.removed)if(!this._applogs.remove(i))if(!Yt(r)&&r.removed?.includes(i))pp("Ignoring remove event for non-existent because it was part of parent event's removed",i,r);else throw hp(`MappedThread{${this.name}} toRemove contained log that doesn't exist`,i,{thread:this,event:r,mapResult:n})}}Xr(`MappedThread{${this.nameAndSizeUntracked}} parentUpdate => deps?`,Ei(this._applogs)),this.notifySubscribers(n)}get readOnly(){return!1}},{WARN:lP,LOG:dP,DEBUG:pP,VERBOSE:ou,ERROR:lS}=$e.setup($e.INFO),lr=Qe("rollingFilter",function(t,r,n={}){let i=Jh(r),o=mu(i),s=Pe.array(Re(function(){return o(t.applogs)}),{deep:!1,name:`${t.name} | ${n.name||`rollingFilter.array{${Zr(i)}}`}`}),a=p=>{let S;return Yt(p)?S={init:o(p.init)}:S={added:o(p.added),removed:p.removed},ou(`rollingFilter{${t.nameAndSizeUntracked} | ${n.name?` '${n.name}'}`:""} parentUpdate`,i,p,"=>",S),S},u=new Us(`${t.name} | ${n.name||`rollingFilter{${Zr(i)}}`}`,t,[...t.filters,...n.extraFilterName?[n.extraFilterName]:[]],s,a),c=Gl(()=>ar(r),p=>{ou(`rollingFilter<${t.nameAndSizeUntracked}>${n.name?` '${n.name}'`:""} patternUpdate`,i,"=>",p),i=p,o=mu(i),u.triggerRemap()}),l=Gr(s,()=>{ou(`rollingFilter<${Re(()=>t.name)}>${n.name?` '${n.name}'`:""} unobserve`,i),c(),l()});return u},{equals:jn,argsDebugName:(e,t,r)=>He({caller:"rollingFilter",thread:e,pattern:t,args:r})}),oc=Qe("rollingMapper",function(t,r,n={}){let i=Re(()=>r.call(null,{init:t.applogs},t));if(!Yt(i))throw lS("Initial run must return init event");let o=i.init;return new Us(`${t.name} | ${n.name||"rollingMapper"}`,t,[...t.filters,...n.extraFilterName?[n.extraFilterName]:[]],o,r)},{equals:jn,argsDebugName:(e,t,r)=>He({caller:"rollingMapper",thread:e,args:r})}),dS=Qe("rollingAcc",function(t,r,n,i={}){let o=st(n);return o({init:t.applogs},r),t.subscribe(s=>{o(s,r)}),r},{argsDebugName:(e,t,r,n)=>`rollingAcc{${e.nameAndSizeUntracked}${n?.name?` | ${n?.name}`:""}}`}),Jh=function(t){let r=Re(function(){return Object.fromEntries(Object.entries(ar(t)).map(([i,o])=>[ar(i),ar(o)]))});if(!Object.entries(r).length)throw new Error("Pattern is empty");return r};function mu(e){return function(r){return r.filter(function(i){for(let o of Object.keys(e)){let s=e[o];if(s===void 0)continue;let a=i[o.startsWith("!")?o.slice(1):o];if(!jh(o,s,a))return!1}return!0})}}var{WARN:pS,LOG:hS,DEBUG:yS,VERBOSE:gS,ERROR:Ho}=$e.setup($e.INFO),Xh=class extends gs{constructor(e,t=[],r){super(e,null,r,t),Tr(this,{})}purge(e){let t=this.applogs.length;return this._applogs=this.applogs.filter(r=>!e.includes(r.cid)),t-this.applogs.length}insert(e){let t=Vh(e,this);return this.insertRaw(t)}insertRaw(e){let t=nc(e);if(t.length!==e.length)throw Ho(`[insertRaw] duplicate applogs passed: ${e.length-t.length}`,{appLogsToInsert:e,deduplicated:t});let r=e.filter(o=>!Lu(o));if(r.length)throw Ho(`[insertRaw] bogus applogs passed: ${r.length}`,{bogus:r});let n=e.filter(o=>this.hasApplog(o,!1));if(n.length)throw Ho(`[insertRaw] already existing applogs passed: ${n.length}`,{existing:n});if(!e.length){pS("[insertRaw] skipping empty insert empty logs array");return}(!this.hasParents&&!(this instanceof Xn)?hS:yS)("Inserting:",e.length===1?e[0]:e,{ds:this}),Sr(e);let i=this._applogs.length&&Mh(e[0],this._applogs[this._applogs.length-1]);return this._applogs.push(...e),i&&Sr(this._applogs),this.notifySubscribers({added:e,removed:null}),this.persist(e),e}get readOnly(){return!1}},Xn=class bu extends Xh{constructor(t,r,n,i){super(t,r,n),this._readOnly=i,Tr(this,{_applogs:Pe.shallow})}static empty(t){return bu.fromArray([],t??"empty in-memory",!1)}static fromArray(t,r,n=!1){return new bu(r??"in-memory",t,[],n)}get readOnly(){return this._readOnly}async persist(t){if(gS("[InMem.persist] no persist for",t),this.readOnly)throw Ho("[persist] called for readOnly thread")}},{WARN:hP,LOG:yP,DEBUG:gP,VERBOSE:mP,ERROR:bP}=$e.setup($e.INFO);var bS=class{constructor(e,t,r=null){this.logsOfThisNode=e,this.variables=t,this.prevNode=r,Tr(this,{threadOfTrail:Me})}get record(){return this.variables}get threadOfTrail(){return this.prevNode?qi([this.logsOfThisNode,this.prevNode.threadOfTrail]):this.logsOfThisNode}get trailLogs(){return this.threadOfTrail.applogs}},Yh=class{constructor(e){this.nodes=e,Tr(this,{threadOfAllTrails:Me,size:Me,isEmpty:Me})}get size(){return this.records.length}get isEmpty(){return this.records.length===0}get untrackedSize(){return Re(()=>this.records.length)}get records(){return fr(()=>this.nodes.map(({variables:e})=>e),{name:"QueryResult.records"})}get leafNodeThread(){return qi(fr(()=>this.nodes.map(({logsOfThisNode:e})=>e),{name:"QueryResult.leafNodeThread"}))}get leafNodeLogs(){return fr(()=>this.nodes.map(({logsOfThisNode:e})=>e.applogs),{name:"QueryResult.leafNodeLogs"})}get threadOfAllTrails(){return qi(fr(()=>this.nodes.map(e=>e.threadOfTrail),{name:"QueryResult.threadOfAllTrails"}))}get thread(){return this.threadOfAllTrails}get allApplogs(){return this.threadOfAllTrails.applogs}},{WARN:TU,LOG:Bs,DEBUG:dr,VERBOSE:Ae,ERROR:cn}=$e.setup($e.INFO,{prefix:"[q]"}),vS=Qe("lastWriteWins",function(t,{inverseToOnlyReturnFirstLogs:r,tolerateAlreadyFiltered:n}={}){if(Ae(`lastWriteWins${r?".inversed":""} < ${t.nameAndSizeUntracked} > initializing`),t.filters.includes("lastWriteWins")){if(n)return dr("[lastWriteWins] already filtered, but tolerateAlreadyFiltered=true, so returning"),t;throw cn("thread already filtered lastWriteWins:",t.filters,{name:t.name})}let i,o=oc(t,function(a,u){let c=Yt(a),l,p=[],S=c?null:[];c?(i=new Map,l=a.init):l=a.added;let x;for(let E=r?0:l.length-1;r?E<l.length:E>=0;r?E++:E--){let z=l[E],W=z.en+"|"+z.at;if(x&&(r?x>z.ts:x<z.ts))throw cn("lastWriteWins.mapper logs not sorted:",x,r?">":"<",z.ts,{log:z,i:E,newLogs:l,inverseToOnlyReturnFirstLogs:r});x=z.ts;let T=i.get(W);(!T||(r?T.ts>z.ts:T.ts<z.ts))&&(T&&!c&&S.push(T),p.push(z),i.set(W,z))}return Sr(p),Ae.isDisabled||Ae(`lastWriteWins${r?".inversed":""}<${t.nameAndSizeUntracked}> mapped event`,c?{...Object.fromEntries(Object.entries(a).map(([E,z])=>[E,z?.length])),toAdd:p.length,toRemove:S}:{...a,toAdd:p,toRemove:S}),c?{init:p}:{added:p,removed:S}},{name:`lastWriteWins${r?".inversed":""}`,extraFilterName:"lastWriteWins"});return Ae.isDisabled||Ct(()=>{Ae(`lastWriteWins<${t.nameAndSizeUntracked}> filtered down to`,o.applogs.length)}),o},{equals:jn,argsDebugName:e=>He({caller:"lastWriteWins",thread:e})}),AU=Qe("withoutDeleted",function(t){if(Ae.isEnabled&&Ae(`withoutDeleted<${t.nameAndSizeUntracked}>`),t.filters.includes("withoutDeleted"))throw cn("thread already filtered withoutDeleted:",t.filters,{name:t.name});let r=lr(t,{at:["isDeleted","relation/isDeleted","block/isDeleted"],vl:!0},{name:"isDeleted"});Ae.isEnabled&&Ae(`withoutDeleted<${t.nameAndSizeUntracked}> deletionLogs:`,Re(function(){return[...r.applogs]}));let n=He({caller:"allDeletedEntities",thread:t}),i=Ap(function(){return r.map(s=>s.en)},{name:n});return Ae.isEnabled&&Ct(()=>{Ae(`withoutDeleted<${t.nameAndSizeUntracked}> deleted:`,[...i])}),lr(t,{"!en":i},{name:"withoutDeleted",extraFilterName:"withoutDeleted"})},{equals:jn}),Qh=Qe("query",function e(t,r,n={},i={}){let o=Zh(t);dr(`query<${o.nameAndSizeUntracked}>:`,r);let s=Array.isArray(r)?r:[r],a;if(s.length===1)a=null;else{let l=s.slice(0,-1);a=e(o,l,n,i)}let u=s[s.length-1],c=_S(o,a,u,i);return Ae.isDisabled||Ct(()=>Ae("query result:",ar(c))),c},{equals:ys,argsDebugName:(e,t,r)=>He({caller:"query",thread:e,args:r?{pattern:t,startVars:r}:t})}),_S=Qe("queryStep",function(t,r,n,i={}){if(dr(`queryStep<${t.nameAndSizeUntracked}> with`,r?.untrackedSize??"all","nodes, pattern:",n),!Object.entries(n).length)throw new Error("Pattern is empty");function o(a){let[u,c]=Ps(n,a?.variables??{});Ae("[queryStep.doQuery] patternWithoutVars: ",u);let l=lr(t,u),p=Ds(c),S=fr(function(){let E=l.map(z=>({log:z,vars:p(z)}));return Ae.isEnabled&&Ae("[queryStep.doQuery] step node:",a?.variables," =>",E,"from:",Re(()=>l.applogs)),E.map(({log:z,vars:W})=>{let T=Object.assign({},a?.variables,W);return new bS(_u.fromArray([z],He({caller:"QueryNode",thread:l,pattern:`${Zr(T)}@${Zr(u)}`})),T,a)})},{name:He({caller:"doQuery.mapNodes",thread:l,pattern:n})});return Ae.isEnabled&&Ct(()=>Ae("[queryStep.doQuery] resultNodes:",[...S])),i.debug&&Bs("[queryStep] step result:",Re(()=>S.map(({variables:x,logsOfThisNode:E})=>({variables:x,thread:E})))),S}let s=fr(function(){return dr(`[queryStep] Running with ${r?.nodes?.length} input nodes:`),r?[...r.nodes.flatMap(o)]:[...o(null)]},{name:He({caller:"queryStep",thread:t,pattern:n})});return Ae.isEnabled&&Ct(()=>Ae("[queryStep] observableResultNodes:",[...s])),new Yh(s)},{equals:ys,argsDebugName:(e,t,r)=>He({caller:"queryStep",thread:e,pattern:r})}),OU=Qe("queryNot",function(t,r,n,i={}){let o=r.nodes;dr(`queryNot<${t.nameAndSizeUntracked}> from: ${o.length} nodes`);let s=Array.isArray(n)?n:[n];for(let a of s){if(!Object.entries(n).length)throw new Error("Pattern is empty");o=o.filter(function({variables:c}){let[l,p]=Ps(a,c??{});Ae("[queryNot] patternWithoutVars: ",l);let S=lr(t,l);return Ae("[queryNot] step node:",c," =>",S.size,"applogs"),Ae.isDisabled||Ae("[queryNot] step node:",c," => empty?",Re(()=>S.applogs)),i.debug&&Bs("[queryNot] node result:",c,"=>",S.applogs),S.isEmpty})}return new Yh(o)},{equals:ys,argsDebugName:(e,t,r)=>He({caller:"queryNot",thread:e,pattern:r})}),EU=Qe("filterAndMap",function(t,r,n){dr(`filterAndMap<${t.nameAndSizeUntracked}>`,r);let i=lr(t,r);Ae("[filterAndMap] filtered:",i.untrackedSize),Ae.isDisabled||Ct(()=>Ae("[filterAndMap] filtered:",i.applogs));let o=He({thread:t,pattern:r,caller:"filterAndMap"}),s=fr(()=>AS(i,n),{name:o});return Ae.isDisabled||Ct(()=>Ae("[filterAndMap] mapped:",s)),s},{equals:Ge.structural,argsDebugName:(e,t)=>He({caller:"filterAndMap",thread:e,pattern:t})}),IU=Qe("queryAndMap",function(t,r,n,i={}){let o=Zh(t);dr(`queryAndMap<${o.nameAndSizeUntracked}>`,{patternOrPatterns:r,variables:i,map:n});let s=He({thread:o,caller:"queryAndMap"}),a=Qh(o,r);Ae("[queryAndMap] filtered count:",a.untrackedSize);let u=fr(()=>OS(a,n),{name:s});return Ae.isDisabled||Ct(()=>Ae("[queryAndMap] result:",ar(u))),u},{equals:Ge.structural,argsDebugName:(e,t)=>He({caller:"queryAndMap",thread:e,pattern:t})}),xU=Qe("queryEntity",function(t,r,n,i){dr(`queryEntity<${t.nameAndSizeUntracked}>`,n,r);let o=lr(t,{en:n,at:ES(r,i)});return Ae("queryEntity applogs:",o.applogs),Me(()=>o.isEmpty?null:Object.fromEntries(o.map(({at:s,vl:a})=>[s.slice(r.length+1),a])))},{equals:Tp,argsDebugName:(e,t,r)=>He({caller:"queryEntity",thread:e,args:{name:t,entityID:r}})}),SU=Qe("agentsOfThread",function(t){dr(`agentsOfThread<${t.nameAndSizeUntracked}>`);let r=Pe.map(),n=st(o=>{for(let s of Yt(o)?o.init:o.added){let a=r.get(s.ag)??0;r.set(s.ag,a+1)}for(let s of!Yt(o)&&o.removed||[]){let a=r.get(s.ag);if(!a||a<1)throw cn("[agentsOfThread] number is now negative",{log:s,event:o,mapped:r,prev:a});r.set(s.ag,a-1)}Bs(`agentsOfThread<${t.nameAndSizeUntracked}> processed event`,{event:o,mapped:r})});n({init:t.applogs});let i=t.subscribe(n);return Pn(r,i),r}),wS=Qe("entityOverlap",function(t,r){return Bs(`entityOverlap<${t.nameAndSizeUntracked}, ${r.nameAndSizeUntracked}>`),Me(()=>{let n=new Set(t.map(o=>o.en)),i=new Set(r.map(o=>o.en));return[...n].filter(o=>i.has(o))})});var CU=Qe("entityOverlapCount",function(t,r){return Me(()=>wS(t,r).get().length)}),TS=Qe("querySingle",function(t,r,n={}){let i=Qh(t,r,n);return Me(()=>{if(i.isEmpty)return null;if(i.size>1)throw cn("[querySingle] got",i.size,"results:",i);let o=i.nodes[0].logsOfThisNode;if(o.size!=1)throw cn("[querySingle] single result, but got",o.size,"logs:",o.applogs);return o.applogs[0]})},{equals:Ge.structural,argsDebugName:(e,t)=>He({caller:"querySingle",thread:e,pattern:t})}),NU=Qe("querySingleAndMap",function(t,r,n,i={}){let o=TS(t,r,i);return Me(()=>{let s=o.get();if(s)return typeof n=="string"?s[n]:Ds(n)(s)})},{equals:Ge.structural,argsDebugName:(e,t)=>He({caller:"querySingleAndMap",thread:e,pattern:t})}),AS=function(t,r){return typeof r=="function"?t.map(r):typeof r=="string"?t.map(n=>n[r]):t.map(Ds(r))},OS=function(t,r){return typeof r=="function"?t.records.map(r):typeof r=="string"?t.nodes.map(n=>{if(!Object.hasOwn(n.record,r)){if(n.logsOfThisNode.size!==1)throw cn(`not sure what to map (it's not a var and a result node log count of ${n.logsOfThisNode.size})`);return n.logsOfThisNode.firstLog[r]}return n.record[r]}):t.nodes.map(n=>Ds(r)(t))};function Ds(e){return t=>Object.entries(e).reduce((r,[n,i])=>(r[i]=t[n],r),{})}function ES(e,t){return t.map(r=>IS(e,r))}function IS(e,t){return`${e}/${t}`}function Zh(e){return Array.isArray(e)?Xn.fromArray(e,`threadFromArray[${e.length}]`,!0):e}var CS=Le({"../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/encode.js"(e,t){"use strict";t.exports=s;var r=128,n=127,i=~n,o=Math.pow(2,31);function s(a,u,c){if(Number.MAX_SAFE_INTEGER&&a>Number.MAX_SAFE_INTEGER)throw s.bytes=0,new RangeError("Could not encode varint");u=u||[],c=c||0;for(var l=c;a>=o;)u[c++]=a&255|r,a/=128;for(;a&i;)u[c++]=a&255|r,a>>>=7;return u[c]=a|0,s.bytes=c-l+1,u}}}),NS=Le({"../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/decode.js"(e,t){"use strict";t.exports=i;var r=128,n=127;function i(o,u){var a=0,u=u||0,c=0,l=u,p,S=o.length;do{if(l>=S||c>49)throw i.bytes=0,new RangeError("Could not decode varint");p=o[l++],a+=c<28?(p&n)<<c:(p&n)*Math.pow(2,c),c+=7}while(p>=r);return i.bytes=l-u,a}}}),RS=Le({"../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/length.js"(e,t){"use strict";var r=Math.pow(2,7),n=Math.pow(2,14),i=Math.pow(2,21),o=Math.pow(2,28),s=Math.pow(2,35),a=Math.pow(2,42),u=Math.pow(2,49),c=Math.pow(2,56),l=Math.pow(2,63);t.exports=function(p){return p<r?1:p<n?2:p<i?3:p<o?4:p<s?5:p<a?6:p<u?7:p<c?8:p<l?9:10}}}),lc=Le({"../../../node_modules/.pnpm/varint@6.0.0/node_modules/varint/index.js"(e,t){"use strict";t.exports={encode:CS(),decode:NS(),encodingLength:RS()}}}),jU=new Uint8Array(0);function $S(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 dc(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 PS(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 i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=e.length,u=e.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function p(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var z=0,W=0,T=0,k=E.length;T!==k&&E[T]===0;)T++,z++;for(var G=(k-T)*l+1>>>0,H=new Uint8Array(G);T!==k;){for(var F=E[T],Y=0,V=G-1;(F!==0||Y<W)&&V!==-1;V--,Y++)F+=256*H[V]>>>0,H[V]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");W=Y,T++}for(var ae=G-W;ae!==G&&H[ae]===0;)ae++;for(var L=u.repeat(z);ae<G;++ae)L+=e.charAt(H[ae]);return L}function S(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var z=0;if(E[z]!==" "){for(var W=0,T=0;E[z]===u;)W++,z++;for(var k=(E.length-z)*c+1>>>0,G=new Uint8Array(k);E[z];){var H=r[E.charCodeAt(z)];if(H===255)return;for(var F=0,Y=k-1;(H!==0||F<T)&&Y!==-1;Y--,F++)H+=a*G[Y]>>>0,G[Y]=H%256>>>0,H=H/256>>>0;if(H!==0)throw new Error("Non-zero carry");T=F,z++}if(E[z]!==" "){for(var V=k-T;V!==k&&G[V]===0;)V++;for(var ae=new Uint8Array(W+(k-V)),L=W;V!==k;)ae[L++]=G[V++];return ae}}}function x(E){var z=S(E);if(z)return z;throw new Error(`Non-${t} character`)}return{encode:p,decodeUnsafe:S,decode:x}}var US=PS,BS=US,DS=BS,MS=class{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},LS=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){this.name=e,this.prefix=t;let n=t.codePointAt(0);if(n===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n,this.baseDecode=r}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ay(this,e)}},kS=class{decoders;constructor(e){this.decoders=e}or(e){return ay(this,e)}decode(e){let t=e[0],r=this.decoders[t];if(r!=null)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function ay(e,t){return new kS({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var jS=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new MS(e,t,r),this.decoder=new LS(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function uy({name:e,prefix:t,encode:r,decode:n}){return new jS(e,t,r,n)}function Vs({name:e,prefix:t,alphabet:r}){let{encode:n,decode:i}=DS(r,e);return uy({prefix:t,name:e,encode:n,decode:o=>dc(i(o))})}function FS(e,t,r,n){let i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,u=0,c=0;for(let l=0;l<o;++l){let p=i[e[l]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<r|p,a+=r,a>=8&&(a-=8,s[c++]=255&u>>a)}if(a>=r||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return s}function VS(e,t,r){let n=t[t.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let u=0;u<e.length;++u)for(a=a<<8|e[u],s+=8;s>r;)s-=r,o+=t[i&a>>s];if(s!==0&&(o+=t[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o}function pr({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return uy({prefix:t,name:e,encode(i){return VS(i,n,r)},decode(i){return FS(i,n,r,e)}})}var Ls=pr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),FU=pr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),VU=pr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),zU=pr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),KU=pr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),qU=pr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),GU=pr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),WU=pr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),HU=pr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),sc=Vs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),JU=Vs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Cr=Vs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),XU=Vs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),zS=cy,ey=128,KS=127,qS=~KS,GS=Math.pow(2,31);function cy(e,t,r){t=t||[],r=r||0;for(var n=r;e>=GS;)t[r++]=e&255|ey,e/=128;for(;e&qS;)t[r++]=e&255|ey,e>>>=7;return t[r]=e|0,cy.bytes=r-n+1,t}var WS=ac,HS=128,ty=127;function ac(e,n){var r=0,n=n||0,i=0,o=n,s,a=e.length;do{if(o>=a)throw ac.bytes=0,new RangeError("Could not decode varint");s=e[o++],r+=i<28?(s&ty)<<i:(s&ty)*Math.pow(2,i),i+=7}while(s>=HS);return ac.bytes=o-n,r}var JS=Math.pow(2,7),XS=Math.pow(2,14),YS=Math.pow(2,21),QS=Math.pow(2,28),ZS=Math.pow(2,35),eC=Math.pow(2,42),tC=Math.pow(2,49),rC=Math.pow(2,56),nC=Math.pow(2,63),iC=function(e){return e<JS?1:e<XS?2:e<YS?3:e<QS?4:e<ZS?5:e<eC?6:e<tC?7:e<rC?8:e<nC?9:10},oC={encode:zS,decode:WS,encodingLength:iC},sC=oC,ks=sC;function uc(e,t=0){return[ks.decode(e,t),ks.decode.bytes]}function js(e,t,r=0){return ks.encode(e,t,r),t}function Fs(e){return ks.encodingLength(e)}function aC(e,t){let r=t.byteLength,n=Fs(e),i=n+Fs(r),o=new Uint8Array(i+r);return js(e,o,0),js(r,o,n),o.set(t,i),new pc(e,r,t,o)}function uC(e){let t=dc(e),[r,n]=uc(t),[i,o]=uc(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new pc(r,i,s,t)}function cC(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&$S(e.bytes,r.bytes)}}var pc=class{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}};function ry(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return lC(r,cc(e),t??Cr.encoder);default:return dC(r,cc(e),t??Ls.encoder)}}var ny=new WeakMap;function cc(e){let t=ny.get(e);if(t==null){let r=new Map;return ny.set(e,r),r}return t}var fy=class tt{code;version;multihash;bytes;"/";constructor(t,r,n,i){this.code=r,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}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!==Gi)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==pC)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return tt.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=aC(t,r);return tt.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 tt.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&cC(t.multihash,n.multihash)}toString(t){return ry(this,t)}toJSON(){return{"/":ry(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 tt)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:o,bytes:s}=r;return new tt(n,i,o,s??iy(n,i,o.bytes))}else if(r[hC]===!0){let{version:n,multihash:i,code:o}=r,s=uC(i);return tt.create(n,o,s)}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!==Gi)throw new Error(`Version 0 CID must use dag-pb (code: ${Gi}) block encoding`);return new tt(t,r,n,n.bytes)}case 1:{let i=iy(t,r,n.bytes);return new tt(t,r,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return tt.create(0,Gi,t)}static createV1(t,r){return tt.create(1,t,r)}static decode(t){let[r,n]=tt.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=tt.inspectBytes(t),n=r.size-r.multihashSize,i=dc(t.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let o=i.subarray(r.multihashSize-r.digestSize),s=new pc(r.multihashCode,r.digestSize,o,i);return[r.version===0?tt.createV0(s):tt.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[p,S]=uc(t.subarray(r));return r+=S,p},i=n(),o=Gi;if(i===18?(i=0,r=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,a=n(),u=n(),c=r+u,l=c-s;return{version:i,codec:o,multihashCode:a,digestSize:u,multihashSize:l,size:c}}static parse(t,r){let[n,i]=fC(t,r),o=tt.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return cc(o).set(n,t),o}};function fC(e,t){switch(e[0]){case"Q":{let r=t??Cr;return[Cr.prefix,r.decode(`${Cr.prefix}${e}`)]}case Cr.prefix:{let r=t??Cr;return[Cr.prefix,r.decode(e)]}case Ls.prefix:{let r=t??Ls;return[Ls.prefix,r.decode(e)]}case sc.prefix:{let r=t??sc;return[sc.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function lC(e,t,r){let{prefix:n}=r;if(n!==Cr.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=t.get(n);if(i==null){let o=r.encode(e).slice(1);return t.set(n,o),o}else return i}function dC(e,t,r){let{prefix:n}=r,i=t.get(n);if(i==null){let o=r.encode(e);return t.set(n,o),o}else return i}var Gi=112,pC=18;function iy(e,t,r){let n=Fs(e),i=n+Fs(t),o=new Uint8Array(i+r.byteLength);return js(e,o,0),js(t,o,n),o.set(r,i),o}var hC=Symbol.for("@ipld/js-cid/CID"),ly=42;function yC(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=fy.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new ee(B.tag,ly),new ee(B.bytes,r)]}function gC(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function mC(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 oy={float64:!0,typeEncoders:{Object:yC,undefined:gC,number:mC}},YU={...oy,typeEncoders:{...oy.typeEncoders}};function bC(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return fy.decode(e.subarray(1))}var fc={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};fc.tags[ly]=bC;var QU={...fc,tags:fc.tags.slice()};var ZU=Nt(lc(),1);var Nr={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},Wi={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":Nr.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(Nr.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=Wi["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let i=t;i<e.length;i++){let o=e[i];if(o=Wi["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](o),o===void 0)return;n.push(o)}return n}}return e}},Int:Nr.Int,CarV1HeaderOrV2Pragma:e=>{if(Nr.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let i=0;i<t.length;i++){let[o,s]=t[i];switch(o){case"roots":{let a=Wi["CarV1HeaderOrV2Pragma > roots (anon)"](e[o]);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.roots=a}}break;case"version":{n--;let a=Wi.Int(e[o]);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},Hi={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":Nr.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(Nr.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=Hi["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let i=t;i<e.length;i++){let o=e[i];if(o=Hi["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](o),o===void 0)return;n.push(o)}return n}}return e}},Int:Nr.Int,CarV1HeaderOrV2Pragma:e=>{if(Nr.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let i=0;i<t.length;i++){let[o,s]=t[i];switch(o){case"roots":{let a=Hi["CarV1HeaderOrV2Pragma > roots (anon)"](s);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.roots=a}}break;case"version":{n--;let a=Hi.Int(s);if(a===void 0)return;if(a!==s||r!==e){if(r===e){r={};for(let u=0;u<i;u++)r[t[u][0]]=t[u][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},eB={toTyped:Wi.CarV1HeaderOrV2Pragma,toRepresentation:Hi.CarV1HeaderOrV2Pragma},tB=$u(),rB=Nt(lc(),1),nB=[new ee(B.map,2),new ee(B.string,"version"),new ee(B.uint,1),new ee(B.string,"roots")],iB=new ee(B.tag,42);var oB=Nt(lc(),1);var{WARN:dy,LOG:sB,DEBUG:sy,VERBOSE:hc,ERROR:Ms}=$e.setup($e.INFO);async function yc(e){let t=await py(e);return await gc(t)}async function gc({rootCID:e,blockStore:t},r=[]){if(!e||!t)throw Ms("Empty roots/blocks",{rootCID:e,blockStore:t});let n=await Yn(t,e),i,o=null,s=null;if(hc("[decodePubFromBlocks] root:",e.toString(),n,{blockStore:t}),!n)throw Ms("root not found in blockStore",{blockStore:t,rootCID:e});if(n?.info){o=n.applogs;let l=await Yn(t,o);i=await _C(l,t),s=await Yn(t,n.info),sy("new format - infoLogs",s.logs.map(p=>({[p.toString()]:p})))}else i=n.applogs;let a=async l=>{let p=l,S=await Yn(t,p);if(!S)throw Ms("Could not find applog CID in pub blocks:",p.toString(),{cid:p,root:n,blockStore:t}),new Error(`Could not find applog CID in pub blocks: ${p.toString()}`);return S.pv instanceof $t&&(S.pv=S.pv.toV1().toString()),{...S,cid:p.toV1().toString()}},u;if(u=await Promise.all(i.map(a)),n.prev){if(Es(n.prev,e)||Vu(r,n.prev))throw Ms("[pubFromBlocks] pub chain has a loop",{rootCID:e,prev:n.prev,recursionTrace:r});u=u.concat((await gc({rootCID:n.prev,blockStore:t},[...r,e])).applogs)}let c={cid:e,info:{...s,logs:await Promise.all(s.logs.map(a))},applogsCID:o,applogs:u};return sy("[decodePubFromBlocks] result:",c,{rootCID:e.toString(),root:n,blockStore:t,applogs:u,info:s}),c}async function py(e){let r=(await e.getRoots()).map(i=>(typeof i.toV1=="function"?i:$t.decode(i.bytes)).toV1().toString()),n=new Map;for await(let{cid:i,bytes:o}of e.blocks()){let s=typeof i.toV1=="function"?i:$t.decode(i.bytes);hc({cidFromCarblocks:i,cid:s}),n.set(s.toV1().toString(),o)}return r.length!==1&&dy("Unexpected roots count:",r),{rootCID:$t.parse(r[0]),blockStore:{get:i=>n.get(i.toV1().toString())}}}async function Yn(e,t){try{var r=await e.get(t);if(!r)return dy("returning null"),null}catch(n){if(n.message==="Not Found")return null;throw n}return Ts(r)}function mc(e){return async function*(){for(;;){let{done:t,value:r}=await e.read();if(hc("[car] chunk",{done:t,value:r}),t)break;yield r}}()}var{WARN:aB,LOG:uB,DEBUG:cB,VERBOSE:fB,ERROR:vC}=$e.setup($e.INFO);async function _C(e,t){return wC(e)?(await Promise.all(e.chunks.map(async r=>{let n=await Yn(t,r);if(!n.logs)throw vC("Weird chunk",n);return n.logs}))).flat():e.logs}function wC(e){return e.chunks}var{WARN:Ks,LOG:t2,DEBUG:Ji,VERBOSE:r2,ERROR:zs}=Xs.setup(Xs.INFO);async function n2(e,t,{readOnly:r=!0,pinnedCID:n}={}){let{cid:i,errors:o,isIpns:s}=Fu(t);if(!i)throw zs("Failed to parse pubID",t,o);Ji("[retrieveThread] parsedPubID",i);let a;if(n)Ji("[retrieveThread] using pinnedCID"),s||Ks("pubID isn't IPNS, but pinnedCID different:",{pubID:t,pinnedCID:n}),a=tr.parse(n);else if(!s)Ji("[retrieveThread] pubID is not IPNS - using as CID"),a=i;else{if(!t)throw zs("[retrieveThread] neither pubID nor pinnedCID provided");try{a=await TC(e.baseUrl,t),Ji("Resolved pub to CID",a.toString())}catch(x){throw zs(`Failed to resolve IPNS ${t}:`,x)}}let u=await AC(e.gatewayBaseUrl,a),{applogs:c}=await yc(u),l=c.filter(x=>As(x));l.length&&Ks(`Found ${l.length} encrypted logs - skipping`);let p=c.filter(x=>!(x instanceof Uint8Array));Sr(p);let S=Xn.fromArray(p,`preview${t&&t!==a.toString()?"-"+t:""}@${a.toString()}`,r);return{cid:a,thread:S,encryptedCount:l.length}}async function TC(e,t){e=Ys(e);let n=await(await fetch(`${e}/name/${t}`)).json();return n.value.startsWith("/ipfs/")||Ks("IPNS value is not '/ipfs/..':",n),tr.parse(n.value.replace("/ipfs/",""))}async function AC(e,t){e=Ys(e),Ji("Retrieving:",t.toString(),"from",e);let r=`${e}/ipfs/${t}?format=car&dag-scope=all`,n=await fetch(r),i;if((!n?.ok||!n?.body)&&(i=zs(`[retrieveCar] unexpected response ${n?.statusText}`,{url:r}),Ks("Gateway failed:",r,i)),i=mc(n.body.getReader()),i instanceof Error)throw i;return await Dr.fromIterable(i)}export{n2 as a,TC as b,AC as c};
|
|
62
62
|
/*! Bundled license information:
|
|
63
63
|
|
|
64
64
|
@noble/hashes/esm/utils.js:
|
|
@@ -75,4 +75,4 @@ lodash-es/lodash.js:
|
|
|
75
75
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
76
76
|
*)
|
|
77
77
|
*/
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
78
|
+
//# sourceMappingURL=chunk-4WKM2MPH.min.js.map
|