var SaturnModule;(()=>{var __webpack_modules__={537:e=>{"use strict";e.exports=function(e,t){for(var r=new Array(arguments.length-1),n=0,o=2,i=!0;o{"use strict";var r=t;r.length=function(e){var t=e.length;if(!t)return 0;for(var r=0;--t%4>1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var n=new Array(64),o=new Array(123),i=0;i<64;)o[n[i]=i<26?i+65:i<52?i+71:i<62?i-4:i-59|43]=i++;r.encode=function(e,t,r){for(var o,i=null,s=[],a=0,c=0;t>2],o=(3&u)<<4,c=1;break;case 1:s[a++]=n[o|u>>4],o=(15&u)<<2,c=2;break;case 2:s[a++]=n[o|u>>6],s[a++]=n[63&u],c=0}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),a=0)}return c&&(s[a++]=n[o],s[a++]=61,1===c&&(s[a++]=61)),i?(a&&i.push(String.fromCharCode.apply(String,s.slice(0,a))),i.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var s="invalid encoding";r.decode=function(e,t,r){for(var n,i=r,a=0,c=0;c1)break;if(void 0===(u=o[u]))throw Error(s);switch(a){case 0:n=u,a=1;break;case 1:t[r++]=n<<2|(48&u)>>4,n=u,a=2;break;case 2:t[r++]=(15&n)<<4|(60&u)>>2,n=u,a=3;break;case 3:t[r++]=(3&n)<<6|u,a=0}}if(1===a)throw Error(s);return r-i},r.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},211:e=>{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var r=this._listeners[e],n=0;n{"use strict";function t(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),n=128===r[3];function o(e,n,o){t[0]=e,n[o]=r[0],n[o+1]=r[1],n[o+2]=r[2],n[o+3]=r[3]}function i(e,n,o){t[0]=e,n[o]=r[3],n[o+1]=r[2],n[o+2]=r[1],n[o+3]=r[0]}function s(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],t[0]}function a(e,n){return r[3]=e[n],r[2]=e[n+1],r[1]=e[n+2],r[0]=e[n+3],t[0]}e.writeFloatLE=n?o:i,e.writeFloatBE=n?i:o,e.readFloatLE=n?s:a,e.readFloatBE=n?a:s}():function(){function t(e,t,r,n){var o=t<0?1:0;if(o&&(t=-t),0===t)e(1/t>0?0:2147483648,r,n);else if(isNaN(t))e(2143289344,r,n);else if(t>34028234663852886e22)e((o<<31|2139095040)>>>0,r,n);else if(t<11754943508222875e-54)e((o<<31|Math.round(t/1401298464324817e-60))>>>0,r,n);else{var i=Math.floor(Math.log(t)/Math.LN2);e((o<<31|i+127<<23|8388607&Math.round(t*Math.pow(2,-i)*8388608))>>>0,r,n)}}function s(e,t,r){var n=e(t,r),o=2*(n>>31)+1,i=n>>>23&255,s=8388607&n;return 255===i?s?NaN:o*(1/0):0===i?1401298464324817e-60*o*s:o*Math.pow(2,i-150)*(s+8388608)}e.writeFloatLE=t.bind(null,r),e.writeFloatBE=t.bind(null,n),e.readFloatLE=s.bind(null,o),e.readFloatBE=s.bind(null,i)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=128===r[7];function o(e,n,o){t[0]=e,n[o]=r[0],n[o+1]=r[1],n[o+2]=r[2],n[o+3]=r[3],n[o+4]=r[4],n[o+5]=r[5],n[o+6]=r[6],n[o+7]=r[7]}function i(e,n,o){t[0]=e,n[o]=r[7],n[o+1]=r[6],n[o+2]=r[5],n[o+3]=r[4],n[o+4]=r[3],n[o+5]=r[2],n[o+6]=r[1],n[o+7]=r[0]}function s(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],r[4]=e[n+4],r[5]=e[n+5],r[6]=e[n+6],r[7]=e[n+7],t[0]}function a(e,n){return r[7]=e[n],r[6]=e[n+1],r[5]=e[n+2],r[4]=e[n+3],r[3]=e[n+4],r[2]=e[n+5],r[1]=e[n+6],r[0]=e[n+7],t[0]}e.writeDoubleLE=n?o:i,e.writeDoubleBE=n?i:o,e.readDoubleLE=n?s:a,e.readDoubleBE=n?a:s}():function(){function t(e,t,r,n,o,i){var s=n<0?1:0;if(s&&(n=-n),0===n)e(0,o,i+t),e(1/n>0?0:2147483648,o,i+r);else if(isNaN(n))e(0,o,i+t),e(2146959360,o,i+r);else if(n>17976931348623157e292)e(0,o,i+t),e((s<<31|2146435072)>>>0,o,i+r);else{var a;if(n<22250738585072014e-324)e((a=n/5e-324)>>>0,o,i+t),e((s<<31|a/4294967296)>>>0,o,i+r);else{var c=Math.floor(Math.log(n)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(a=n*Math.pow(2,-c))>>>0,o,i+t),e((s<<31|c+1023<<20|1048576*a&1048575)>>>0,o,i+r)}}}function s(e,t,r,n,o){var i=e(n,o+t),s=e(n,o+r),a=2*(s>>31)+1,c=s>>>20&2047,u=4294967296*(1048575&s)+i;return 2047===c?u?NaN:a*(1/0):0===c?5e-324*a*u:a*Math.pow(2,c-1075)*(u+4503599627370496)}e.writeDoubleLE=t.bind(null,r,0,4),e.writeDoubleBE=t.bind(null,n,4,0),e.readDoubleLE=s.bind(null,o,0,4),e.readDoubleBE=s.bind(null,i,4,0)}(),e}function r(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function n(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function o(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function i(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},199:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},662:e=>{"use strict";e.exports=function(e,t,r){var n=r||8192,o=n>>>1,i=null,s=n;return function(r){if(r<1||r>o)return e(r);s+r>n&&(i=e(n),s=0);var a=t.call(i,s,s+=r);return 7&s&&(s=1+(7|s)),a}}},997:(e,t)=>{"use strict";var r=t;r.length=function(e){for(var t=0,r=0,n=0;n191&&n<224?i[s++]=(31&n)<<6|63&e[t++]:n>239&&n<365?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(n>>10),i[s++]=56320+(1023&n)):i[s++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o?(s&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))},r.write=function(e,t,r){for(var n,o,i=r,s=0;s>6|192,t[r++]=63&n|128):55296==(64512&n)&&56320==(64512&(o=e.charCodeAt(s+1)))?(n=65536+((1023&n)<<10)+(1023&o),++s,t[r++]=n>>18|240,t[r++]=n>>12&63|128,t[r++]=n>>6&63|128,t[r++]=63&n|128):(t[r++]=n>>12|224,t[r++]=n>>6&63|128,t[r++]=63&n|128);return r-i}},442:(e,t,r)=>{const n=r(488);function o(e,t,r){const n=e[t]+e[r];let o=e[t+1]+e[r+1];n>=4294967296&&o++,e[t]=n,e[t+1]=o}function i(e,t,r,n){let o=e[t]+r;r<0&&(o+=4294967296);let i=e[t+1]+n;o>=4294967296&&i++,e[t]=o,e[t+1]=i}function s(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function a(e,t,r,n,s,a){const c=f[s],u=f[s+1],l=f[a],d=f[a+1];o(h,e,t),i(h,e,c,u);let p=h[n]^h[e],w=h[n+1]^h[e+1];h[n]=w,h[n+1]=p,o(h,r,n),p=h[t]^h[r],w=h[t+1]^h[r+1],h[t]=p>>>24^w<<8,h[t+1]=w>>>24^p<<8,o(h,e,t),i(h,e,l,d),p=h[n]^h[e],w=h[n+1]^h[e+1],h[n]=p>>>16^w<<16,h[n+1]=w>>>16^p<<16,o(h,r,n),p=h[t]^h[r],w=h[t+1]^h[r+1],h[t]=w>>>31^p<<1,h[t+1]=p>>>31^w<<1}const c=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((function(e){return 2*e}))),h=new Uint32Array(32),f=new Uint32Array(32);function l(e,t){let r=0;for(r=0;r<16;r++)h[r]=e.h[r],h[r+16]=c[r];for(h[24]=h[24]^e.t,h[25]=h[25]^e.t/4294967296,t&&(h[28]=~h[28],h[29]=~h[29]),r=0;r<32;r++)f[r]=s(e.b,4*r);for(r=0;r<12;r++)a(0,8,16,24,u[16*r+0],u[16*r+1]),a(2,10,18,26,u[16*r+2],u[16*r+3]),a(4,12,20,28,u[16*r+4],u[16*r+5]),a(6,14,22,30,u[16*r+6],u[16*r+7]),a(0,10,20,30,u[16*r+8],u[16*r+9]),a(2,12,22,24,u[16*r+10],u[16*r+11]),a(4,14,16,26,u[16*r+12],u[16*r+13]),a(6,8,18,28,u[16*r+14],u[16*r+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^h[r]^h[r+16]}const d=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function p(e,t,r,n){if(0===e||e>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(t&&t.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(r&&16!==r.length)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(n&&16!==n.length)throw new Error("Illegal personal, expected Uint8Array with length is 16");const o={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:e};d.fill(0),d[0]=e,t&&(d[1]=t.length),d[2]=1,d[3]=1,r&&d.set(r,32),n&&d.set(n,48);for(let e=0;e<16;e++)o.h[e]=c[e]^s(d,4*e);return t&&(w(o,t),o.c=128),o}function w(e,t){for(let r=0;r>2]>>8*(3&r);return t}function y(e,t,r,o,i){r=r||64,e=n.normalizeInput(e),o&&(o=n.normalizeInput(o)),i&&(i=n.normalizeInput(i));const s=p(r,t,o,i);return w(s,e),b(s)}e.exports={blake2b:y,blake2bHex:function(e,t,r,o,i){const s=y(e,t,r,o,i);return n.toHex(s)},blake2bInit:p,blake2bUpdate:w,blake2bFinal:b}},297:(e,t,r)=>{const n=r(488);function o(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function i(e,t,r,n,o,i){u[e]=u[e]+u[t]+o,u[n]=s(u[n]^u[e],16),u[r]=u[r]+u[n],u[t]=s(u[t]^u[r],12),u[e]=u[e]+u[t]+i,u[n]=s(u[n]^u[e],8),u[r]=u[r]+u[n],u[t]=s(u[t]^u[r],7)}function s(e,t){return e>>>t^e<<32-t}const a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),c=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),u=new Uint32Array(16),h=new Uint32Array(16);function f(e,t){let r=0;for(r=0;r<8;r++)u[r]=e.h[r],u[r+8]=a[r];for(u[12]^=e.t,u[13]^=e.t/4294967296,t&&(u[14]=~u[14]),r=0;r<16;r++)h[r]=o(e.b,4*r);for(r=0;r<10;r++)i(0,4,8,12,h[c[16*r+0]],h[c[16*r+1]]),i(1,5,9,13,h[c[16*r+2]],h[c[16*r+3]]),i(2,6,10,14,h[c[16*r+4]],h[c[16*r+5]]),i(3,7,11,15,h[c[16*r+6]],h[c[16*r+7]]),i(0,5,10,15,h[c[16*r+8]],h[c[16*r+9]]),i(1,6,11,12,h[c[16*r+10]],h[c[16*r+11]]),i(2,7,8,13,h[c[16*r+12]],h[c[16*r+13]]),i(3,4,9,14,h[c[16*r+14]],h[c[16*r+15]]);for(r=0;r<8;r++)e.h[r]^=u[r]^u[r+8]}function l(e,t){if(!(e>0&&e<=32))throw new Error("Incorrect output length, should be in [1, 32]");const r=t?t.length:0;if(t&&!(r>0&&r<=32))throw new Error("Incorrect key length, should be in [1, 32]");const n={h:new Uint32Array(a),b:new Uint8Array(64),c:0,t:0,outlen:e};return n.h[0]^=16842752^r<<8^e,r>0&&(d(n,t),n.c=64),n}function d(e,t){for(let r=0;r>2]>>8*(3&r)&255;return t}function w(e,t,r){r=r||32,e=n.normalizeInput(e);const o=l(r,t);return d(o,e),p(o)}e.exports={blake2s:w,blake2sHex:function(e,t,r){const o=w(e,t,r);return n.toHex(o)},blake2sInit:l,blake2sUpdate:d,blake2sFinal:p}},191:(e,t,r)=>{const n=r(442),o=r(297);e.exports={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:o.blake2s,blake2sHex:o.blake2sHex,blake2sInit:o.blake2sInit,blake2sUpdate:o.blake2sUpdate,blake2sFinal:o.blake2sFinal}},488:e=>{function t(e){return(4294967296+e).toString(16).substring(1)}e.exports={normalizeInput:function(e){let t;if(e instanceof Uint8Array)t=e;else{if("string"!=typeof e)throw new Error("Input must be an string, Buffer or Uint8Array");t=(new TextEncoder).encode(e)}return t},toHex:function(e){return Array.prototype.map.call(e,(function(e){return(e<16?"0":"")+e.toString(16)})).join("")},debugPrint:function(e,r,n){let o="\n"+e+" = ";for(let i=0;i{"use strict";function t(e,t){for(const r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}e.exports=function(e,r,n){if(!e||"string"==typeof e)throw new TypeError("Please pass an Error to err-code");n||(n={}),"object"==typeof r&&(n=r,r=""),r&&(n.code=r);try{return t(e,n)}catch(r){n.message=e.message,n.stack=e.stack;const o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(e)),t(new o,n)}}},729:e=>{"use strict";var t=Object.prototype.hasOwnProperty,r="~";function n(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function i(e,t,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,i||e,s),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,o=[];if(0===this._eventsCount)return o;for(n in e=this._events)t.call(e,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o{e.exports=r(27)},27:function(e,t){!function(r,n){"use strict";var o={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function i(e){if(!Array.isArray(e)&&!ArrayBuffer.isView(e))return!1;for(var t=0;t255)return!1;return!0}function s(e,t){return(65535&e)*t+(((e>>>16)*t&65535)<<16)}function a(e,t){return e<>>32-t}function c(e){return e=s(e^=e>>>16,2246822507),(e=s(e^=e>>>13,3266489909))^e>>>16}function u(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]+t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]+t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]+t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]+t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]}function h(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]*t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]*t[3],r[1]+=r[2]>>>16,r[2]&=65535,r[2]+=e[3]*t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]*t[3],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[2]*t[2],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[3]*t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]}function f(e,t){return 32==(t%=64)?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])}function l(e,t){return 0==(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=d(e=h(e,[4283543511,3981806797]),[0,e[0]>>>1]),d(e=h(e,[3301882366,444984403]),[0,e[0]>>>1])}o.x86.hash32=function(e,t){if(o.inputValidation&&!i(e))return n;t=t||0;for(var r=e.length%4,u=e.length-r,h=t,f=0,l=3432918353,d=461845907,p=0;p>>0},o.x86.hash128=function(e,t){if(o.inputValidation&&!i(e))return n;t=t||0;for(var r=e.length%16,u=e.length-r,h=t,f=t,l=t,d=t,p=0,w=0,b=0,y=0,g=597399067,m=2869860233,v=951274213,_=2716044179,k=0;k>>0).toString(16)).slice(-8)+("00000000"+(f>>>0).toString(16)).slice(-8)+("00000000"+(l>>>0).toString(16)).slice(-8)+("00000000"+(d>>>0).toString(16)).slice(-8)},o.x64.hash128=function(e,t){if(o.inputValidation&&!i(e))return n;t=t||0;for(var r=e.length%16,s=e.length-r,a=[0,t],c=[0,t],w=[0,0],b=[0,0],y=[2277735313,289559509],g=[1291169091,658871167],m=0;m>>0).toString(16)).slice(-8)+("00000000"+(a[1]>>>0).toString(16)).slice(-8)+("00000000"+(c[0]>>>0).toString(16)).slice(-8)+("00000000"+(c[1]>>>0).toString(16)).slice(-8)},e.exports&&(t=e.exports=o),t.murmurHash3=o}()},408:(e,t,r)=>{"use strict";e.exports=c;var n,o=r(693),i=o.LongBits,s=o.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function c(e){this.buf=e,this.pos=0,this.len=e.length}var u,h="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new c(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new c(e);throw Error("illegal buffer")},f=function(){return o.Buffer?function(e){return(c.create=function(e){return o.Buffer.isBuffer(e)?new n(e):h(e)})(e)}:h};function l(){var e=new i(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function d(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function p(){if(this.pos+8>this.len)throw a(this,8);return new i(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}c.create=f(),c.prototype._slice=o.Array.prototype.subarray||o.Array.prototype.slice,c.prototype.uint32=(u=4294967295,function(){if(u=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return u;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return u}),c.prototype.int32=function(){return 0|this.uint32()},c.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},c.prototype.bool=function(){return 0!==this.uint32()},c.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return d(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|d(this.buf,this.pos+=4)},c.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=o.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},c.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=o.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},c.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw a(this,e);if(this.pos+=e,Array.isArray(this.buf))return this.buf.slice(t,r);if(t===r){var n=o.Buffer;return n?n.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,t,r)},c.prototype.string=function(){var e=this.bytes();return s.read(e,0,e.length)},c.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},c.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},c._configure=function(e){n=e,c.create=f(),n._configure();var t=o.Long?"toLong":"toNumber";o.merge(c.prototype,{int64:function(){return l.call(this)[t](!1)},uint64:function(){return l.call(this)[t](!0)},sint64:function(){return l.call(this).zzDecode()[t](!1)},fixed64:function(){return p.call(this)[t](!0)},sfixed64:function(){return p.call(this)[t](!1)}})}},593:(e,t,r)=>{"use strict";e.exports=i;var n=r(408);(i.prototype=Object.create(n.prototype)).constructor=i;var o=r(693);function i(e){n.call(this,e)}i._configure=function(){o.Buffer&&(i.prototype._slice=o.Buffer.prototype.slice)},i.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},i._configure()},630:(e,t,r)=>{"use strict";e.exports=o;var n=r(693);function o(e,t){this.lo=e>>>0,this.hi=t>>>0}var i=o.zero=new o(0,0);i.toNumber=function(){return 0},i.zzEncode=i.zzDecode=function(){return this},i.length=function(){return 1};var s=o.zeroHash="\0\0\0\0\0\0\0\0";o.fromNumber=function(e){if(0===e)return i;var t=e<0;t&&(e=-e);var r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new o(r,n)},o.from=function(e){if("number"==typeof e)return o.fromNumber(e);if(n.isString(e)){if(!n.Long)return o.fromNumber(parseInt(e,10));e=n.Long.fromString(e)}return e.low||e.high?new o(e.low>>>0,e.high>>>0):i},o.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},o.prototype.toLong=function(e){return n.Long?new n.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var a=String.prototype.charCodeAt;o.fromHash=function(e){return e===s?i:new o((a.call(e,0)|a.call(e,1)<<8|a.call(e,2)<<16|a.call(e,3)<<24)>>>0,(a.call(e,4)|a.call(e,5)<<8|a.call(e,6)<<16|a.call(e,7)<<24)>>>0)},o.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},o.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},o.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},o.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}},693:function(e,t,r){"use strict";var n=t;function o(e,t,r){for(var n=Object.keys(t),o=0;o0)},n.Buffer=function(){try{var e=n.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(e){return"number"==typeof e?n.Buffer?n._Buffer_allocUnsafe(e):new n.Array(e):n.Buffer?n._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},n.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(e){return e?n.LongBits.from(e).toHash():n.LongBits.zeroHash},n.longFromHash=function(e,t){var r=n.LongBits.fromHash(e);return n.Long?n.Long.fromBits(r.lo,r.hi,t):r.toNumber(Boolean(t))},n.merge=o,n.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},n.newError=i,n.ProtocolError=i("ProtocolError"),n.oneOfGetter=function(e){for(var t={},r=0;r-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},n.oneOfSetter=function(e){return function(t){for(var r=0;r{"use strict";e.exports=f;var n,o=r(693),i=o.LongBits,s=o.base64,a=o.utf8;function c(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function u(){}function h(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function f(){this.len=0,this.head=new c(u,0,0),this.tail=this.head,this.states=null}var l=function(){return o.Buffer?function(){return(f.create=function(){return new n})()}:function(){return new f}};function d(e,t,r){t[r]=255&e}function p(e,t){this.len=e,this.next=void 0,this.val=t}function w(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function b(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}f.create=l(),f.alloc=function(e){return new o.Array(e)},o.Array!==Array&&(f.alloc=o.pool(f.alloc,o.Array.prototype.subarray)),f.prototype._push=function(e,t,r){return this.tail=this.tail.next=new c(e,t,r),this.len+=t,this},p.prototype=Object.create(c.prototype),p.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},f.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new p((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},f.prototype.int32=function(e){return e<0?this._push(w,10,i.fromNumber(e)):this.uint32(e)},f.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},f.prototype.uint64=function(e){var t=i.from(e);return this._push(w,t.length(),t)},f.prototype.int64=f.prototype.uint64,f.prototype.sint64=function(e){var t=i.from(e).zzEncode();return this._push(w,t.length(),t)},f.prototype.bool=function(e){return this._push(d,1,e?1:0)},f.prototype.fixed32=function(e){return this._push(b,4,e>>>0)},f.prototype.sfixed32=f.prototype.fixed32,f.prototype.fixed64=function(e){var t=i.from(e);return this._push(b,4,t.lo)._push(b,4,t.hi)},f.prototype.sfixed64=f.prototype.fixed64,f.prototype.float=function(e){return this._push(o.float.writeFloatLE,4,e)},f.prototype.double=function(e){return this._push(o.float.writeDoubleLE,8,e)};var y=o.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var n=0;n>>0;if(!t)return this._push(d,1,0);if(o.isString(e)){var r=f.alloc(t=s.length(e));s.decode(e,r,0),e=r}return this.uint32(t)._push(y,t,e)},f.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(d,1,0)},f.prototype.fork=function(){return this.states=new h(this),this.head=this.tail=new c(u,0,0),this.len=0,this},f.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new c(u,0,0),this.len=0),this},f.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},f.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},f._configure=function(e){n=e,f.create=l(),n._configure()}},155:(e,t,r)=>{"use strict";e.exports=i;var n=r(173);(i.prototype=Object.create(n.prototype)).constructor=i;var o=r(693);function i(){n.call(this)}function s(e,t,r){e.length<40?o.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}i._configure=function(){i.alloc=o._Buffer_allocUnsafe,i.writeBytesBuffer=o.Buffer&&o.Buffer.prototype instanceof Uint8Array&&"set"===o.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var n=0;n>>0;return this.uint32(t),t&&this._push(i.writeBytesBuffer,t,e),this},i.prototype.string=function(e){var t=o.Buffer.byteLength(e);return this.uint32(t),t&&this._push(s,t,e),this},i._configure()},544:e=>{"use strict";function t(e,t){return e+r(t)}function r(e){let t=e;return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),16843009*(t+(t>>4)&252645135)>>24}function n(e,t){return e[0]-t[0]}function o(e){return e[1]}e.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,t){let r=this._internalPositionFor(e,!1);if(void 0===t)-1!==r&&(this._unsetInternalPos(r),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let n=!1;-1===r?(r=this._data.length,this._setBit(e),this._changedData=!0):n=!0,this._setInternalPos(r,e,t,n),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();const t=this._internalPositionFor(e,!0);if(-1!==t)return this._data[t][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){const e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let t=0;for(;t=this._bitArrays.length)return-1;const i=this._bitArrays[o],s=e-7*o;return(i&1<0?this._bitArrays.slice(0,o).reduce(t,0)+r(i&~(4294967295<=t)o.push(i);else if(o[0][0]<=t)o.unshift(i);else{const e=Math.round(o.length/2);this._data=o.slice(0,e).concat(i).concat(o.slice(e))}else this._data.push(i);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(n),this._changedData=!1}bitField(){const e=[];let t,r=8,n=0,o=0;const i=this._bitArrays.slice();for(;i.length||n;){0===n&&(t=i.shift(),n=7);const s=Math.min(n,r);o|=(t&~(255<>>=s,n-=s,r-=s,r&&(n||i.length)||(e.push(o),o=0,r=8)}for(var s=e.length-1;s>0&&0===e[s];s--)e.pop();return e}compactArray(){return this._sortData(),this._data.map(o)}}},988:e=>{e.exports=function e(t,r){var n,o=0,i=0,s=r=r||0,a=t.length;do{if(s>=a||i>49)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],o+=i<28?(127&n)<=128);return e.bytes=s-r,o}},312:e=>{e.exports=function e(r,n,o){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw e.bytes=0,new RangeError("Could not encode varint");n=n||[];for(var i=o=o||0;r>=t;)n[o++]=255&r|128,r/=128;for(;-128&r;)n[o++]=255&r|128,r>>>=7;return n[o]=0|r,e.bytes=o-i+1,n};var t=Math.pow(2,31)},676:(e,t,r)=>{e.exports={encode:r(312),decode:r(988),encodingLength:r(82)}},82:e=>{var t=Math.pow(2,7),r=Math.pow(2,14),n=Math.pow(2,21),o=Math.pow(2,28),i=Math.pow(2,35),s=Math.pow(2,42),a=Math.pow(2,49),c=Math.pow(2,56),u=Math.pow(2,63);e.exports=function(e){return e{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Saturn:()=>wf,extractVerifiedContent:()=>Mh,indexedDbStorage:()=>nf,memoryStorage:()=>of,validateBody:()=>zh,verifyBlock:()=>Rh});var e={};__webpack_require__.r(e),__webpack_require__.d(e,{coerce:()=>k,empty:()=>g,equals:()=>_,fromHex:()=>v,fromString:()=>x,isBinary:()=>E,toHex:()=>m,toString:()=>C});var t={};__webpack_require__.r(t),__webpack_require__.d(t,{base32:()=>P,base32hex:()=>M,base32hexpad:()=>$,base32hexpadupper:()=>F,base32hexupper:()=>j,base32pad:()=>z,base32padupper:()=>R,base32upper:()=>O,base32z:()=>V});var r={};__webpack_require__.r(r),__webpack_require__.d(r,{base58btc:()=>q,base58flickr:()=>H});var n={};__webpack_require__.r(n),__webpack_require__.d(n,{code:()=>En,decode:()=>Cn,encode:()=>xn,name:()=>kn});var o={};__webpack_require__.r(o),__webpack_require__.d(o,{code:()=>Yo,createLink:()=>Xo,createNode:()=>Qo,decode:()=>ti,encode:()=>ei,name:()=>Zo,prepare:()=>Jo,validate:()=>Ko});var i={};__webpack_require__.r(i),__webpack_require__.d(i,{code:()=>Qi,decode:()=>Zi,encode:()=>Xi,name:()=>Ki});var s={};__webpack_require__.r(s),__webpack_require__.d(s,{code:()=>_a,decode:()=>Ea,encode:()=>ka,name:()=>va});var a={};__webpack_require__.r(a),__webpack_require__.d(a,{identity:()=>Ca});var c={};__webpack_require__.r(c),__webpack_require__.d(c,{base10:()=>Za});var u={};__webpack_require__.r(u),__webpack_require__.d(u,{base16:()=>Ya,base16upper:()=>ec});var h={};__webpack_require__.r(h),__webpack_require__.d(h,{base2:()=>tc});var f={};__webpack_require__.r(f),__webpack_require__.d(f,{base256emoji:()=>ic});var l={};__webpack_require__.r(l),__webpack_require__.d(l,{base36:()=>sc,base36upper:()=>ac});var d={};__webpack_require__.r(d),__webpack_require__.d(d,{base64:()=>cc,base64pad:()=>uc,base64url:()=>hc,base64urlpad:()=>fc});var p={};__webpack_require__.r(p),__webpack_require__.d(p,{base8:()=>lc});var w={};__webpack_require__.r(w),__webpack_require__.d(w,{identity:()=>dc});var b={};__webpack_require__.r(b),__webpack_require__.d(b,{code:()=>yc,decode:()=>mc,encode:()=>gc,name:()=>bc});var y={};__webpack_require__.r(y),__webpack_require__.d(y,{sha256:()=>_c,sha512:()=>kc});const g=new Uint8Array(0),m=e=>e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),""),v=e=>{const t=e.match(/../g);return t?new Uint8Array(t.map((e=>parseInt(e,16)))):g},_=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)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")},E=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),x=e=>(new TextEncoder).encode(e),C=e=>(new TextDecoder).decode(e);const A=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,s=new Uint8Array(i);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var f=0,l=i-1;(0!==h||f>>0,s[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=f,t++}if(" "!==e[t]){for(var d=i-o;d!==i&&0===s[d];)d++;for(var p=new Uint8Array(n+(i-d)),w=n;d!==i;)p[w++]=s[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var s=(i-o)*h+1>>>0,u=new Uint8Array(s);o!==i;){for(var f=t[o],l=0,d=s-1;(0!==f||l>>0,u[d]=f%a>>>0,f=f/a>>>0;if(0!==f)throw new Error("Non-zero carry");n=l,o++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var w=c.repeat(r);pnew S({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class T{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new B(e,t,r),this.decoder=new I(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const U=({name:e,prefix:t,encode:r,decode:n})=>new T(e,t,r,n),N=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:o}=A(r,t);return U({prefix:e,name:t,encode:n,decode:e=>k(o(e))})},L=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>U({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],o=(1<r;)s-=r,i+=t[o&a>>s];if(s&&(i+=t[o&a<((e,t,r,n)=>{const o={};for(let e=0;e=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(t,n,r,e)}),P=L({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),O=L({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),z=L({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),R=L({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),M=L({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),j=L({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),$=L({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),F=L({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),V=L({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),q=N({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),H=N({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var G=Math.pow(2,31),W=Math.pow(2,7),J=Math.pow(2,14),K=Math.pow(2,21),Q=Math.pow(2,28),X=Math.pow(2,35),Z=Math.pow(2,42),Y=Math.pow(2,49),ee=Math.pow(2,56),te=Math.pow(2,63);const re={encode:function e(t,r,n){r=r||[];for(var o=n=n||0;t>=G;)r[n++]=255&t|128,t/=128;for(;-128&t;)r[n++]=255&t|128,t>>>=7;return r[n]=0|t,e.bytes=n-o+1,r},decode:function e(t,r){var n,o=0,i=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],o+=i<28?(127&n)<=128);return e.bytes=s-r,o},encodingLength:function(e){return e[re.decode(e,t),re.decode.bytes],oe=(e,t,r=0)=>(re.encode(e,t,r),t),ie=e=>re.encodingLength(e),se=(e,t)=>{const r=t.byteLength,n=ie(e),o=n+ie(r),i=new Uint8Array(o+r);return oe(e,i,0),oe(r,i,n),i.set(t,o),new ce(e,r,t,i)},ae=e=>{const t=k(e),[r,n]=ne(t),[o,i]=ne(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new ce(r,o,s,t)};class ce{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const ue=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?pe(r,fe(e),t||q.encoder):we(r,fe(e),t||P.encoder)},he=new WeakMap,fe=e=>{const t=he.get(e);if(null==t){const t=new Map;return he.set(e,t),t}return t};class le{constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==be)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==ye)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return le.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=se(e,t);return le.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return le.equals(this,e)}static equals(e,t){const r=t;return r&&e.code===r.code&&e.version===r.version&&((e,t)=>{if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&_(e.bytes,r.bytes)}})(e.multihash,r.multihash)}toString(e){return ue(this,e)}toJSON(){return{"/":ue(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof le)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:o}=t;return new le(e,r,n,o||ge(e,r,n.bytes))}if(!0===t[me]){const{version:e,multihash:r,code:n}=t,o=ae(r);return le.create(e,n,o)}return null}static create(e,t,r){if("number"!=typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==be)throw new Error(`Version 0 CID must use dag-pb (code: ${be}) block encoding`);return new le(e,t,r,r.bytes);case 1:{const n=ge(e,t,r.bytes);return new le(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return le.create(0,be,e)}static createV1(e,t){return le.create(1,e,t)}static decode(e){const[t,r]=le.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=le.inspectBytes(e),r=t.size-t.multihashSize,n=k(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const o=n.subarray(t.multihashSize-t.digestSize),i=new ce(t.multihashCode,t.digestSize,o,n);return[0===t.version?le.createV0(i):le.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=ne(e.subarray(t));return t+=n,r};let n=r(),o=be;if(18===n?(n=0,t=0):o=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const i=t,s=r(),a=r(),c=t+a;return{version:n,codec:o,multihashCode:s,digestSize:a,multihashSize:c-i,size:c}}static parse(e,t){const[r,n]=de(e,t),o=le.decode(n);if(0===o.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return fe(o).set(r,e),o}}const de=(e,t)=>{switch(e[0]){case"Q":{const r=t||q;return[q.prefix,r.decode(`${q.prefix}${e}`)]}case q.prefix:{const r=t||q;return[q.prefix,r.decode(e)]}case P.prefix:{const r=t||P;return[P.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}},pe=(e,t,r)=>{const{prefix:n}=r;if(n!==q.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const o=t.get(n);if(null==o){const o=r.encode(e).slice(1);return t.set(n,o),o}return o},we=(e,t,r)=>{const{prefix:n}=r,o=t.get(n);if(null==o){const o=r.encode(e);return t.set(n,o),o}return o},be=112,ye=18,ge=(e,t,r)=>{const n=ie(e),o=n+ie(t),i=new Uint8Array(o+r.byteLength);return oe(e,i,0),oe(t,i,n),i.set(r,o),i},me=Symbol.for("@ipld/js-cid/CID"),ve=({name:e,code:t,encode:r})=>new _e(e,t,r);class _e{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?se(this.code,t):t.then((e=>se(this.code,e)))}throw Error("Unknown type, must be binary type")}}class ke{value;next;constructor(e){this.value=e}}class Ee{#e;#t;#r;constructor(){this.clear()}enqueue(e){const t=new ke(e);this.#e?(this.#t.next=t,this.#t=t):(this.#e=t,this.#t=t),this.#r++}dequeue(){const e=this.#e;if(e)return this.#e=this.#e.next,this.#r--,e.value}clear(){this.#e=void 0,this.#t=void 0,this.#r=0}get size(){return this.#r}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}}const xe=(e,t,r)=>e.bind(r);function Ce(e){if(!Number.isInteger(e)&&e!==Number.POSITIVE_INFINITY||!(e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const t=new Ee;let r=0;const n=async(e,n,o)=>{r++;const i=(async()=>e(...o))();n(i);try{await i}catch{}r--,t.size>0&&t.dequeue()()},o=(o,...i)=>new Promise((s=>{((o,i,s)=>{t.enqueue(xe(n.bind(void 0,o,i,s))),(async()=>{await Promise.resolve(),r0&&t.dequeue()()})()})(o,s,i)}));return Object.defineProperties(o,{activeCount:{get:()=>r},pendingCount:{get:()=>t.size},clearQueue:{value(){t.clear()}}}),o}var Ae=__webpack_require__(676),Be=Math.pow(2,31),Ie=Math.pow(2,7),Se=Math.pow(2,14),De=Math.pow(2,21),Te=Math.pow(2,28),Ue=Math.pow(2,35),Ne=Math.pow(2,42),Le=Math.pow(2,49),Pe=Math.pow(2,56),Oe=Math.pow(2,63);const ze={encode:function e(t,r,n){r=r||[];for(var o=n=n||0;t>=Be;)r[n++]=255&t|128,t/=128;for(;-128&t;)r[n++]=255&t|128,t>>>=7;return r[n]=0|t,e.bytes=n-o+1,r},decode:function e(t,r){var n,o=0,i=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],o+=i<28?(127&n)<=128);return e.bytes=s-r,o},encodingLength:function(e){return e[ze.decode(e,t),ze.decode.bytes],Me=(e,t,r=0)=>(ze.encode(e,t,r),t),je=e=>ze.encodingLength(e),$e=(new Uint8Array(0),e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)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")}),Fe=e=>{const t=$e(e),[r,n]=Re(t),[o,i]=Re(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Ve(r,o,s,t)};class Ve{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const qe=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,s=new Uint8Array(i);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var f=0,l=i-1;(0!==h||f>>0,s[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=f,t++}if(" "!==e[t]){for(var d=i-o;d!==i&&0===s[d];)d++;for(var p=new Uint8Array(n+(i-d)),w=n;d!==i;)p[w++]=s[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var s=(i-o)*h+1>>>0,u=new Uint8Array(s);o!==i;){for(var f=t[o],l=0,d=s-1;(0!==f||l>>0,u[d]=f%a>>>0,f=f/a>>>0;if(0!==f)throw new Error("Non-zero carry");n=l,o++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var w=c.repeat(r);pnew We({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Ke{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new He(e,t,r),this.decoder=new Ge(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Qe=({name:e,prefix:t,encode:r,decode:n})=>new Ke(e,t,r,n),Xe=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:o}=qe(r,t);return Qe({prefix:e,name:t,encode:n,decode:e=>$e(o(e))})},Ze=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>Qe({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],o=(1<r;)s-=r,i+=t[o&a>>s];if(s&&(i+=t[o&a<((e,t,r,n)=>{const o={};for(let e=0;e=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(t,n,r,e)}),Ye=Xe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),et=(Xe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Ze({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}));Ze({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ze({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ze({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ze({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ze({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ze({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ze({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ze({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});class tt{constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:ht,byteLength:ht,code:ut,version:ut,multihash:ut,bytes:ut,_baseCache:ht,asCID:ht})}toV0(){if(0===this.version)return this;{const{code:e,multihash:t}=this;if(e!==it)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==st)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return tt.createV0(t)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=((e,t)=>{const r=t.byteLength,n=je(e),o=n+je(r),i=new Uint8Array(o+r);return Me(e,i,0),Me(r,i,n),i.set(t,o),new Ve(e,r,t,i)})(e,t);return tt.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&((t=this.multihash)===(r=e.multihash)||t.code===r.code&&t.size===r.size&&((e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{const[r,n]=Re(e.subarray(t));return t+=n,r};let n=r(),o=it;if(18===n?(n=0,t=0):1===n&&(o=r()),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const i=t,s=r(),a=r(),c=t+a;return{version:n,codec:o,multihashCode:s,digestSize:a,multihashSize:c-i,size:c}}static parse(e,t){const[r,n]=rt(e,t),o=tt.decode(n);return o._baseCache.set(r,e),o}}const rt=(e,t)=>{switch(e[0]){case"Q":{const r=t||Ye;return[Ye.prefix,r.decode(`${Ye.prefix}${e}`)]}case Ye.prefix:{const r=t||Ye;return[Ye.prefix,r.decode(e)]}case et.prefix:{const r=t||et;return[et.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}},nt=(e,t,r)=>{const{prefix:n}=r;if(n!==Ye.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const o=t.get(n);if(null==o){const o=r.encode(e).slice(1);return t.set(n,o),o}return o},ot=(e,t,r)=>{const{prefix:n}=r,o=t.get(n);if(null==o){const o=r.encode(e);return t.set(n,o),o}return o},it=112,st=18,at=(e,t,r)=>{const n=je(e),o=n+je(t),i=new Uint8Array(o+r.byteLength);return Me(e,i,0),Me(t,i,n),i.set(r,o),i},ct=Symbol.for("@ipld/js-cid/CID"),ut={writable:!1,configurable:!1,enumerable:!0},ht={writable:!1,enumerable:!1,configurable:!1},ft=(e,t)=>{if(!e.test("0.0.0-dev"))throw new Error(t);console.warn(t)},lt="CID.isCID(v) is deprecated and will be removed in the next major release.\nFollowing code pattern:\n\nif (CID.isCID(value)) {\n doSomethingWithCID(value)\n}\n\nIs replaced with:\n\nconst cid = CID.asCID(value)\nif (cid) {\n // Make sure to use cid instead of value\n doSomethingWithCID(cid)\n}\n",dt=["string","number","bigint","symbol"],pt=["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"];class wt{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.majore.major?1:0}}wt.uint=new wt(0,"uint",!0),wt.negint=new wt(1,"negint",!0),wt.bytes=new wt(2,"bytes",!0),wt.string=new wt(3,"string",!0),wt.array=new wt(4,"array",!1),wt.map=new wt(5,"map",!1),wt.tag=new wt(6,"tag",!1),wt.float=new wt(7,"float",!0),wt.false=new wt(7,"false",!0),wt.true=new wt(7,"true",!0),wt.null=new wt(7,"null",!0),wt.undefined=new wt(7,"undefined",!0),wt.break=new wt(7,"break",!0);class bt{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}`}}const yt=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer,gt=new TextDecoder,mt=new TextEncoder;function vt(e){return yt&&globalThis.Buffer.isBuffer(e)}function _t(e){return e instanceof Uint8Array?vt(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}const kt=yt?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):St(e,t,r):(e,t,r)=>r-t>64?gt.decode(e.subarray(t,r)):St(e,t,r),Et=yt?e=>e.length>64?globalThis.Buffer.from(e):It(e):e=>e.length>64?mt.encode(e):It(e),xt=e=>Uint8Array.from(e),Ct=yt?(e,t,r)=>vt(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),At=yt?(e,t)=>(e=e.map((e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e))),_t(globalThis.Buffer.concat(e,t))):(e,t)=>{const r=new Uint8Array(t);let n=0;for(let t of e)n+t.length>r.length&&(t=t.subarray(0,r.length-n)),r.set(t,n),n+=t.length;return r},Bt=yt?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function It(e,t=1/0){let r;const n=e.length;let o=null;const i=[];for(let s=0;s55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function St(e,t,r){const n=[];for(;t239?4:o>223?3:o>191?2:1;if(t+s<=r){let r,n,a,c;switch(s){case 1:o<128&&(i=o);break;case 2:r=e[t+1],128==(192&r)&&(c=(31&o)<<6|63&r,c>127&&(i=c));break;case 3:r=e[t+1],n=e[t+2],128==(192&r)&&128==(192&n)&&(c=(15&o)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(i=c));break;case 4:r=e[t+1],n=e[t+2],a=e[t+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&o)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(i=c))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),t+=s}return Dt(n)}function Dt(e){const t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nr.length/2?(t=this.cursor===r.length?r:r.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Ct(r,0,this.cursor)}else t=At(this.chunks,this.cursor);return e&&this.reset(),t}}const Ut=[];function Nt(e,t,r){if(e.length-t>>8,255&n])}else if(r>>24&255,n>>>16&255,n>>>8&255,255&n])}else{const n=BigInt(r);if(!(n>BigInt(32)&BigInt(4294967295));r[8]=255&o,o>>=8,r[7]=255&o,o>>=8,r[6]=255&o,o>>=8,r[5]=255&o,r[4]=255&i,i>>=8,r[3]=255&i,i>>=8,r[2]=255&i,i>>=8,r[1]=255&i,e.push(r)}}}Mt.encodedSize=function(e){return jt.encodedSize(e.value)},jt.encodedSize=function(e){return et.value?1:0};const $t=BigInt(-1),Ft=BigInt(1);function Vt(e,t){const r=t.value,n="bigint"==typeof r?r*$t-Ft:-1*r-1;jt(e,t.type.majorEncoded,n)}function qt(e,t,r,n){Nt(e,t,r+n);const o=Ct(e,t+r,t+r+n);return new bt(wt.bytes,o,r+n)}function Ht(e,t,r,n){return qt(e,t,1,r)}function Gt(e){return void 0===e.encodedBytes&&(e.encodedBytes=e.type===wt.string?Et(e.value):e.value),e.encodedBytes}function Wt(e,t){const r=Gt(t);jt(e,t.type.majorEncoded,r.length),e.push(r)}function Jt(e,t,r,n,o){const i=r+n;Nt(e,t,i);const s=new bt(wt.string,kt(e,t+r,t+i),i);return!0===o.retainStringBytes&&(s.byteValue=Ct(e,t+r,t+i)),s}function Kt(e,t,r,n){return Jt(e,t,1,r,n)}Vt.encodedSize=function(e){const t=e.value,r="bigint"==typeof t?t*$t-Ft:-1*t-1;return rt.value?-1:0},Wt.encodedSize=function(e){const t=Gt(e);return jt.encodedSize(t.length)+t.length},Wt.compareTokens=function(e,t){return r=Gt(e),n=Gt(t),r.lengthn.length?1:function(e,t){if(vt(e)&&vt(t))return e.compare(t);for(let r=0;r>23,n=8388607&t;if(255===r)cr.setUint16(0,31744,!1);else if(0===r)cr.setUint16(0,(2147483648&e)>>16|n>>13,!1);else{const e=r-127;e<-24?cr.setUint16(0,0):e<-14?cr.setUint16(0,(2147483648&t)>>16|1<<24+e,!1):cr.setUint16(0,(2147483648&t)>>16|e+15<<10|n>>13,!1)}}}function fr(e,t){if(e.length-t<2)throw new Error("CBOR decode error: not enough data for float16");const r=(e[t]<<8)+e[t+1];if(31744===r)return 1/0;if(64512===r)return-1/0;if(32256===r)return NaN;const n=r>>10&31,o=1023&r;let i;return i=0===n?o*2**-24:31!==n?(o+1024)*2**(n-25):0===o?1/0:NaN,32768&r?-i:i}function lr(e){cr.setFloat32(0,e,!1)}function dr(e,t){if(e.length-t<4)throw new Error("CBOR decode error: not enough data for float32");const r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function pr(e,t){if(e.length-t<8)throw new Error("CBOR decode error: not enough data for float64");const r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}function wr(e,t,r){throw new Error(`CBOR decode error: encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function br(e){return()=>{throw new Error(`CBOR decode error: ${e}`)}}sr.compareTokens=Mt.compareTokens;const yr=[];for(let e=0;e<=23;e++)yr[e]=wr;yr[24]=function(e,t,r,n){return new bt(wt.uint,Pt(e,t+1,n),2)},yr[25]=function(e,t,r,n){return new bt(wt.uint,Ot(e,t+1,n),3)},yr[26]=function(e,t,r,n){return new bt(wt.uint,zt(e,t+1,n),5)},yr[27]=function(e,t,r,n){return new bt(wt.uint,Rt(e,t+1,n),9)},yr[28]=wr,yr[29]=wr,yr[30]=wr,yr[31]=wr;for(let e=32;e<=55;e++)yr[e]=wr;yr[56]=function(e,t,r,n){return new bt(wt.negint,-1-Pt(e,t+1,n),2)},yr[57]=function(e,t,r,n){return new bt(wt.negint,-1-Ot(e,t+1,n),3)},yr[58]=function(e,t,r,n){return new bt(wt.negint,-1-zt(e,t+1,n),5)},yr[59]=function(e,t,r,n){const o=Rt(e,t+1,n);if("bigint"!=typeof o){const e=-1-o;if(e>=Number.MIN_SAFE_INTEGER)return new bt(wt.negint,e,9)}if(!0!==n.allowBigInt)throw new Error("CBOR decode error: integers outside of the safe integer range are not supported");return new bt(wt.negint,$t-BigInt(o),9)},yr[60]=wr,yr[61]=wr,yr[62]=wr,yr[63]=wr;for(let e=64;e<=87;e++)yr[e]=Ht;yr[88]=function(e,t,r,n){return qt(e,t,2,Pt(e,t+1,n))},yr[89]=function(e,t,r,n){return qt(e,t,3,Ot(e,t+1,n))},yr[90]=function(e,t,r,n){return qt(e,t,5,zt(e,t+1,n))},yr[91]=function(e,t,r,n){const o=Rt(e,t+1,n);if("bigint"==typeof o)throw new Error("CBOR decode error: 64-bit integer bytes lengths not supported");return qt(e,t,9,o)},yr[92]=wr,yr[93]=wr,yr[94]=wr,yr[95]=br("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)yr[e]=Kt;yr[120]=function(e,t,r,n){return Jt(e,t,2,Pt(e,t+1,n),n)},yr[121]=function(e,t,r,n){return Jt(e,t,3,Ot(e,t+1,n),n)},yr[122]=function(e,t,r,n){return Jt(e,t,5,zt(e,t+1,n),n)},yr[123]=function(e,t,r,n){const o=Rt(e,t+1,n);if("bigint"==typeof o)throw new Error("CBOR decode error: 64-bit integer string lengths not supported");return Jt(e,t,9,o,n)},yr[124]=wr,yr[125]=wr,yr[126]=wr,yr[127]=br("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)yr[e]=Zt;yr[152]=function(e,t,r,n){return Xt(0,0,2,Pt(e,t+1,n))},yr[153]=function(e,t,r,n){return Xt(0,0,3,Ot(e,t+1,n))},yr[154]=function(e,t,r,n){return Xt(0,0,5,zt(e,t+1,n))},yr[155]=function(e,t,r,n){const o=Rt(e,t+1,n);if("bigint"==typeof o)throw new Error("CBOR decode error: 64-bit integer array lengths not supported");return Xt(0,0,9,o)},yr[156]=wr,yr[157]=wr,yr[158]=wr,yr[159]=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error("CBOR decode error: indefinite length items not allowed");return Xt(0,0,1,1/0)};for(let e=160;e<=183;e++)yr[e]=tr;yr[184]=function(e,t,r,n){return er(0,0,2,Pt(e,t+1,n))},yr[185]=function(e,t,r,n){return er(0,0,3,Ot(e,t+1,n))},yr[186]=function(e,t,r,n){return er(0,0,5,zt(e,t+1,n))},yr[187]=function(e,t,r,n){const o=Rt(e,t+1,n);if("bigint"==typeof o)throw new Error("CBOR decode error: 64-bit integer map lengths not supported");return er(0,0,9,o)},yr[188]=wr,yr[189]=wr,yr[190]=wr,yr[191]=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error("CBOR decode error: indefinite length items not allowed");return er(0,0,1,1/0)};for(let e=192;e<=215;e++)yr[e]=nr;yr[216]=function(e,t,r,n){return new bt(wt.tag,Pt(e,t+1,n),2)},yr[217]=function(e,t,r,n){return new bt(wt.tag,Ot(e,t+1,n),3)},yr[218]=function(e,t,r,n){return new bt(wt.tag,zt(e,t+1,n),5)},yr[219]=function(e,t,r,n){return new bt(wt.tag,Rt(e,t+1,n),9)},yr[220]=wr,yr[221]=wr,yr[222]=wr,yr[223]=wr;for(let e=224;e<=243;e++)yr[e]=br("simple values are not supported");yr[244]=wr,yr[245]=wr,yr[246]=wr,yr[247]=function(e,t,r,n){if(!1===n.allowUndefined)throw new Error("CBOR decode error: undefined values are not supported");return!0===n.coerceUndefinedToNull?new bt(wt.null,null,1):new bt(wt.undefined,void 0,1)},yr[248]=br("simple values are not supported"),yr[249]=function(e,t,r,n){return ir(fr(e,t+1),3,n)},yr[250]=function(e,t,r,n){return ir(dr(e,t+1),5,n)},yr[251]=function(e,t,r,n){return ir(pr(e,t+1),9,n)},yr[252]=wr,yr[253]=wr,yr[254]=wr,yr[255]=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error("CBOR decode error: indefinite length items not allowed");return new bt(wt.break,void 0,1)};const gr=[];for(let e=0;e<24;e++)gr[e]=new bt(wt.uint,e,1);for(let e=-1;e>=-24;e--)gr[31-e]=new bt(wt.negint,e,1);gr[64]=new bt(wt.bytes,new Uint8Array(0),1),gr[96]=new bt(wt.string,"",1),gr[128]=new bt(wt.array,0,1),gr[160]=new bt(wt.map,0,1),gr[244]=new bt(wt.false,!1,1),gr[245]=new bt(wt.true,!0,1),gr[246]=new bt(wt.null,null,1);const mr={float64:!1,mapSorter:function(e,t){const r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);const o=r.type.major,i=vr[o].compareTokens(r,n);return 0===i&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i},quickEncodeToken:function(e){switch(e.type){case wt.false:return xt([244]);case wt.true:return xt([245]);case wt.null:return xt([246]);case wt.bytes:return e.value.length?void 0:xt([64]);case wt.string:return""===e.value?xt([96]):void 0;case wt.array:return 0===e.value?xt([128]):void 0;case wt.map:return 0===e.value?xt([160]):void 0;case wt.uint:return e.value<24?xt([Number(e.value)]):void 0;case wt.negint:if(e.value>=-24)return xt([31-Number(e.value)])}}},vr=function(){const e=[];return e[wt.uint.major]=Mt,e[wt.negint.major]=Vt,e[wt.bytes.major]=Wt,e[wt.string.major]=Qt,e[wt.array.major]=Yt,e[wt.map.major]=rr,e[wt.tag.major]=or,e[wt.float.major]=sr,e}(),_r=new Tt;class kr{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do{if(t.obj===e)return!0}while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error("CBOR encode error: object contains circular references");return new kr(t,e)}}const Er={null:new bt(wt.null,null),undefined:new bt(wt.undefined,void 0),true:new bt(wt.true,!0),false:new bt(wt.false,!1),emptyArray:new bt(wt.array,0),emptyMap:new bt(wt.map,0)},xr={number:(e,t,r,n)=>Number.isInteger(e)&&Number.isSafeInteger(e)?new bt(e>=0?wt.uint:wt.negint,e):new bt(wt.float,e),bigint:(e,t,r,n)=>e>=BigInt(0)?new bt(wt.uint,e):new bt(wt.negint,e),Uint8Array:(e,t,r,n)=>new bt(wt.bytes,e),string:(e,t,r,n)=>new bt(wt.string,e),boolean:(e,t,r,n)=>e?Er.true:Er.false,null:(e,t,r,n)=>Er.null,undefined:(e,t,r,n)=>Er.undefined,ArrayBuffer:(e,t,r,n)=>new bt(wt.bytes,new Uint8Array(e)),DataView:(e,t,r,n)=>new bt(wt.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Array(e,t,r,n){if(!e.length)return!0===r.addBreakTokens?[Er.emptyArray,new bt(wt.break)]:Er.emptyArray;n=kr.createCheck(n,e);const o=[];let i=0;for(const t of e)o[i++]=Cr(t,r,n);return r.addBreakTokens?[new bt(wt.array,e.length),o,new bt(wt.break)]:[new bt(wt.array,e.length),o]},Object(e,t,r,n){const o="Object"!==t,i=o?e.keys():Object.keys(e),s=o?e.size:i.length;if(!s)return!0===r.addBreakTokens?[Er.emptyMap,new bt(wt.break)]:Er.emptyMap;n=kr.createCheck(n,e);const a=[];let c=0;for(const t of i)a[c++]=[Cr(t,r,n),Cr(o?e.get(t):e[t],r,n)];return function(e,t){t.mapSorter&&e.sort(t.mapSorter)}(a,r),r.addBreakTokens?[new bt(wt.map,s),a,new bt(wt.break)]:[new bt(wt.map,s),a]}};xr.Map=xr.Object,xr.Buffer=xr.Uint8Array;for(const e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))xr[`${e}Array`]=xr.DataView;function Cr(e,t={},r){const n=function(e){if(null===e)return"null";if(void 0===e)return"undefined";if(!0===e||!1===e)return"boolean";const t=typeof e;if(dt.includes(t))return t;if("function"===t)return"Function";if(Array.isArray(e))return"Array";if(function(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}(e))return"Buffer";const r=function(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(pt.includes(t))return t}(e);return r||"Object"}(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||xr[n];if("function"==typeof o){const i=o(e,n,t,r);if(null!=i)return i}const i=xr[n];if(!i)throw new Error(`CBOR encode error: unsupported type: ${n}`);return i(e,n,t,r)}function Ar(e,t,r,n){if(Array.isArray(t))for(const o of t)Ar(e,o,r,n);else r[t.type.major](e,t,n)}function Br(e,t,r){const n=Cr(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){const e=r.quickEncodeToken(n);if(e)return e;const o=t[n.type.major];if(o.encodedSize){const e=o.encodedSize(n,r),t=new Tt(e);if(o(t,n,r),1!==t.chunks.length)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return _t(t.chunks[0])}}return _r.reset(),Ar(_r,n,t,r),_r.toBytes(!0)}const Ir={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};class Sr{constructor(e,t={}){this.pos=0,this.data=e,this.options=t}done(){return this.pos>=this.data.length}next(){const e=this.data[this.pos];let t=gr[e];if(void 0===t){const r=yr[e];if(!r)throw new Error(`CBOR decode error: no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);const n=31&e;t=r(this.data,this.pos,n,this.options)}return this.pos+=t.encodedLength,t}}const Dr=Symbol.for("DONE"),Tr=Symbol.for("BREAK");function Ur(e,t){if(e.done())return Dr;const r=e.next();if(r.type===wt.break)return Tr;if(r.type.terminal)return r.value;if(r.type===wt.array)return function(e,t,r){const n=[];for(let o=0;o=Lr;)r[n++]=255&t|128,t/=128;for(;-128&t;)r[n++]=255&t|128,t>>>=7;return r[n]=0|t,e.bytes=n-o+1,r},decode:function e(t,r){var n,o=0,i=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],o+=i<28?(127&n)<=128);return e.bytes=s-r,o},encodingLength:function(e){return e[qr.decode(e,t),qr.decode.bytes],Gr=(e,t,r=0)=>(qr.encode(e,t,r),t),Wr=e=>qr.encodingLength(e),Jr=(new Uint8Array(0),e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)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")});class Kr{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Qr=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,s=new Uint8Array(i);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var f=0,l=i-1;(0!==h||f>>0,s[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=f,t++}if(" "!==e[t]){for(var d=i-o;d!==i&&0===s[d];)d++;for(var p=new Uint8Array(n+(i-d)),w=n;d!==i;)p[w++]=s[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var s=(i-o)*h+1>>>0,u=new Uint8Array(s);o!==i;){for(var f=t[o],l=0,d=s-1;(0!==f||l>>0,u[d]=f%a>>>0,f=f/a>>>0;if(0!==f)throw new Error("Non-zero carry");n=l,o++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var w=c.repeat(r);pnew Yr({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class tn{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Xr(e,t,r),this.decoder=new Zr(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const rn=({name:e,prefix:t,encode:r,decode:n})=>new tn(e,t,r,n),nn=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:o}=Qr(r,t);return rn({prefix:e,name:t,encode:n,decode:e=>Jr(o(e))})},on=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>rn({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],o=(1<r;)s-=r,i+=t[o&a>>s];if(s&&(i+=t[o&a<((e,t,r,n)=>{const o={};for(let e=0;e=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(t,n,r,e)}),sn=nn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),an=(nn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),on({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}));on({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),on({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),on({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),on({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),on({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),on({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),on({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),on({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});class cn{constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:yn,byteLength:yn,code:bn,version:bn,multihash:bn,bytes:bn,_baseCache:yn,asCID:yn})}toV0(){if(0===this.version)return this;{const{code:e,multihash:t}=this;if(e!==ln)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==dn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return cn.createV0(t)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=((e,t)=>{const r=t.byteLength,n=Wr(e),o=n+Wr(r),i=new Uint8Array(o+r);return Gr(e,i,0),Gr(r,i,n),i.set(t,o),new Kr(e,r,t,i)})(e,t);return cn.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&((t=this.multihash)===(r=e.multihash)||t.code===r.code&&t.size===r.size&&((e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{const t=Jr(e),[r,n]=Hr(t),[o,i]=Hr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Kr(r,o,s,t)})(r);return cn.create(t,n,o)}return null}static create(e,t,r){if("number"!=typeof t)throw new Error("String codecs are no longer supported");switch(e){case 0:if(t!==ln)throw new Error(`Version 0 CID must use dag-pb (code: ${ln}) block encoding`);return new cn(e,t,r,r.bytes);case 1:{const n=pn(e,t,r.bytes);return new cn(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return cn.create(0,ln,e)}static createV1(e,t){return cn.create(1,e,t)}static decode(e){const[t,r]=cn.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=cn.inspectBytes(e),r=t.size-t.multihashSize,n=Jr(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const o=n.subarray(t.multihashSize-t.digestSize),i=new Kr(t.multihashCode,t.digestSize,o,n);return[0===t.version?cn.createV0(i):cn.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=Hr(e.subarray(t));return t+=n,r};let n=r(),o=ln;if(18===n?(n=0,t=0):1===n&&(o=r()),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const i=t,s=r(),a=r(),c=t+a;return{version:n,codec:o,multihashCode:s,digestSize:a,multihashSize:c-i,size:c}}static parse(e,t){const[r,n]=un(e,t),o=cn.decode(n);return o._baseCache.set(r,e),o}}const un=(e,t)=>{switch(e[0]){case"Q":{const r=t||sn;return[sn.prefix,r.decode(`${sn.prefix}${e}`)]}case sn.prefix:{const r=t||sn;return[sn.prefix,r.decode(e)]}case an.prefix:{const r=t||an;return[an.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}},hn=(e,t,r)=>{const{prefix:n}=r;if(n!==sn.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const o=t.get(n);if(null==o){const o=r.encode(e).slice(1);return t.set(n,o),o}return o},fn=(e,t,r)=>{const{prefix:n}=r,o=t.get(n);if(null==o){const o=r.encode(e);return t.set(n,o),o}return o},ln=112,dn=18,pn=(e,t,r)=>{const n=Wr(e),o=n+Wr(t),i=new Uint8Array(o+r.byteLength);return Gr(e,i,0),Gr(t,i,n),i.set(r,o),i},wn=Symbol.for("@ipld/js-cid/CID"),bn={writable:!1,configurable:!1,enumerable:!0},yn={writable:!1,enumerable:!1,configurable:!1},gn=(e,t)=>{if(!e.test("0.0.0-dev"))throw new Error(t);console.warn(t)},mn="CID.isCID(v) is deprecated and will be removed in the next major release.\nFollowing code pattern:\n\nif (CID.isCID(value)) {\n doSomethingWithCID(value)\n}\n\nIs replaced with:\n\nconst cid = CID.asCID(value)\nif (cid) {\n // Make sure to use cid instead of value\n doSomethingWithCID(cid)\n}\n",vn={float64:!0,typeEncoders:{Object:function(e){if(e.asCID!==e)return null;const t=cn.asCID(e);if(!t)return null;const r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new bt(wt.tag,42),new bt(wt.bytes,r)]},undefined:function(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")},number:function(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}}},_n={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};_n.tags[42]=function(e){if(0!==e[0])throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return cn.decode(e.subarray(1))};const kn="dag-cbor",En=113,xn=e=>{return t=e,r=vn,r=Object.assign({},mr,r),Br(t,vr,r);var t,r},Cn=e=>Nr(e,_n),An={Null:e=>null===e,Int:e=>Number.isInteger(e),Float:e=>"number"==typeof e&&Number.isFinite(e),String:e=>"string"==typeof e,Bool:e=>"boolean"==typeof e,Bytes:e=>e instanceof Uint8Array,Link:e=>!An.Null(e)&&"object"==typeof e&&e.asCID===e,List:e=>Array.isArray(e),Map:e=>!An.Null(e)&&"object"==typeof e&&e.asCID!==e&&!An.List(e)&&!An.Bytes(e)},Bn={Int:An.Int,"CarHeader > version":e=>Bn.Int(e),"CarHeader > roots (anon) > valueType (anon)":An.Link,"CarHeader > roots (anon)":e=>An.List(e)&&Array.prototype.every.call(e,Bn["CarHeader > roots (anon) > valueType (anon)"]),"CarHeader > roots":e=>Bn["CarHeader > roots (anon)"](e),CarHeader:e=>{const t=e&&Object.keys(e);return An.Map(e)&&["version"].every((e=>t.includes(e)))&&Object.entries(e).every((([e,t])=>Bn["CarHeader > "+e]&&Bn["CarHeader > "+e](t)))}},In=Bn.CarHeader;async function Sn(e){const t=await e.upTo(8);if(!t.length)throw new Error("Unexpected end of data");const r=Ae.decode(t);return e.seek(Ae.decode.bytes),r}async function Dn(e,t){const r=await Sn(e);if(0===r)throw new Error("Invalid CAR header (zero length)");const n=await e.exactly(r);e.seek(r);const o=Cn(n);if(!In(o))throw new Error("Invalid CAR header format");if(1!==o.version&&2!==o.version||void 0!==t&&o.version!==t)throw new Error(`Invalid CAR version: ${o.version}${void 0!==t?` (expected ${t})`:""}`);const i=Array.isArray(o.roots);if(1===o.version&&!i||2===o.version&&i)throw new Error("Invalid CAR header format");if(1===o.version)return o;const s=await async function(e){const t=await e.exactly(40),r=new DataView(t.buffer,t.byteOffset,t.byteLength);let n=0;const o={version:2,characteristics:[r.getBigUint64(n,!0),r.getBigUint64(n+=8,!0)],dataOffset:Number(r.getBigUint64(n+=8,!0)),dataSize:Number(r.getBigUint64(n+=8,!0)),indexOffset:Number(r.getBigUint64(n+=8,!0))};return e.seek(40),o}(e);e.seek(s.dataOffset-e.pos);const a=await Dn(e,1);return Object.assign(a,s)}async function Tn(e){const t=await e.exactly(2);if(18===t[0]&&32===t[1]){const t=await e.exactly(34);e.seek(34);const r=Fe(t);return tt.create(0,112,r)}const r=await Sn(e);if(1!==r)throw new Error(`Unexpected CID version (${r})`);const n=await Sn(e),o=await async function(e){const t=await e.upTo(8);Ae.decode(t);const r=Ae.decode.bytes,n=Ae.decode(t.subarray(Ae.decode.bytes)),o=r+Ae.decode.bytes+n,i=await e.exactly(o);return e.seek(o),i}(e),i=Fe(o);return tt.create(r,n,i)}async function Un(e){const t=e.pos;let r=await Sn(e);if(0===r)throw new Error("Invalid CAR section (zero length)");return r+=e.pos-t,{cid:await Tn(e),length:r,blockLength:r-Number(e.pos-t)}}async function Nn(e){const{cid:t,blockLength:r}=await Un(e),n=await e.exactly(r);return e.seek(r),{bytes:n,cid:t}}async function Ln(e){const t=e.pos,{cid:r,length:n,blockLength:o}=await Un(e),i={cid:r,length:n,blockLength:o,offset:t,blockOffset:e.pos};return e.seek(i.blockLength),i}function Pn(e){const t=(async()=>{const t=await Dn(e);if(2===t.version){const r=e.pos-t.dataOffset;e=function(e,t){let r=0;return{async upTo(n){let o=await e.upTo(n);return o.length+r>t&&(o=o.subarray(0,t-r)),o},async exactly(n){const o=await e.exactly(n);if(o.length+r>t)throw new Error("Unexpected end of data");return o},seek(t){r+=t,e.seek(t)},get pos(){return e.pos}}}(e,t.dataSize-r)}return t})();return{header:()=>t,async*blocks(){for(await t;(await e.upTo(8)).length>0;)yield await Nn(e)},async*blocksIndex(){for(await t;(await e.upTo(8)).length>0;)yield await Ln(e)}}}class On{constructor(e,t,r){this._version=e,this._roots=t,this._iterator=r}get version(){return this._version}async getRoots(){return this._roots}[Symbol.asyncIterator](){return this._iterator}static async fromBytes(e){if(!(e instanceof Uint8Array))throw new TypeError("fromBytes() requires a Uint8Array");return decodeIndexerComplete(bytesReader(e))}static async fromIterable(e){if(!e||"function"!=typeof e[Symbol.asyncIterator])throw new TypeError("fromIterable() requires an async iterable");return decodeIndexerComplete(asyncIterableReader(e))}}class zn{constructor(e,t,r){this._version=e,this._roots=t,this._iterable=r,this._decoded=!1}get version(){return this._version}async getRoots(){return this._roots}}class Rn extends zn{[Symbol.asyncIterator](){if(this._decoded)throw new Error("Cannot decode more than once");if(!this._iterable)throw new Error("Block iterable not found");return this._decoded=!0,this._iterable[Symbol.asyncIterator]()}static async fromBytes(e){const{version:t,roots:r,iterator:n}=await jn(e);return new Rn(t,r,n)}static async fromIterable(e){const{version:t,roots:r,iterator:n}=await $n(e);return new Rn(t,r,n)}}class Mn extends(null){[Symbol.asyncIterator](){if(this._decoded)throw new Error("Cannot decode more than once");if(!this._iterable)throw new Error("Block iterable not found");this._decoded=!0;const e=this._iterable[Symbol.asyncIterator]();return{async next(){const t=await e.next();return t.done?t:{done:!1,value:t.value.cid}}}}static async fromBytes(e){const{version:t,roots:r,iterator:n}=await jn(e);return new Mn(t,r,n)}static async fromIterable(e){const{version:t,roots:r,iterator:n}=await $n(e);return new Mn(t,r,n)}}async function jn(e){if(!(e instanceof Uint8Array))throw new TypeError("fromBytes() requires a Uint8Array");return Fn(function(e){let t=0;return{upTo:async r=>e.subarray(t,t+Math.min(r,e.length-t)),async exactly(r){if(r>e.length-t)throw new Error("Unexpected end of data");return e.subarray(t,t+r)},seek(e){t+=e},get pos(){return t}}}(e))}async function $n(e){if(!e||"function"!=typeof e[Symbol.asyncIterator])throw new TypeError("fromIterable() requires an async iterable");return Fn(function(e){const t=e[Symbol.asyncIterator]();return function(e){let t=0,r=0,n=0,o=new Uint8Array(0);const i=async t=>{r=o.length-n;const i=[o.subarray(n)];for(;rr&&i.push(t.subarray(-r)):i.push(t),r+=t.length}o=new Uint8Array(i.reduce(((e,t)=>e+t.length),0));let s=0;for(const e of i)o.set(e,s),s+=e.length;n=0};return{upTo:async e=>(o.length-n=qn;)r[n++]=255&t|128,t/=128;for(;-128&t;)r[n++]=255&t|128,t>>>=7;return r[n]=0|t,e.bytes=n-o+1,r},decode:function e(t,r){var n,o=0,i=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],o+=i<28?(127&n)<=128);return e.bytes=s-r,o},encodingLength:function(e){return e[eo.decode(e,t),eo.decode.bytes],ro=(e,t,r=0)=>(eo.encode(e,t,r),t),no=e=>eo.encodingLength(e),oo=(new Uint8Array(0),e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)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")});class io{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const so=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,s=new Uint8Array(i);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var f=0,l=i-1;(0!==h||f>>0,s[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=f,t++}if(" "!==e[t]){for(var d=i-o;d!==i&&0===s[d];)d++;for(var p=new Uint8Array(n+(i-d)),w=n;d!==i;)p[w++]=s[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var s=(i-o)*h+1>>>0,u=new Uint8Array(s);o!==i;){for(var f=t[o],l=0,d=s-1;(0!==f||l>>0,u[d]=f%a>>>0,f=f/a>>>0;if(0!==f)throw new Error("Non-zero carry");n=l,o++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var w=c.repeat(r);pnew uo({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class fo{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new ao(e,t,r),this.decoder=new co(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const lo=({name:e,prefix:t,encode:r,decode:n})=>new fo(e,t,r,n),po=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:o}=so(r,t);return lo({prefix:e,name:t,encode:n,decode:e=>oo(o(e))})},wo=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>lo({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],o=(1<r;)s-=r,i+=t[o&a>>s];if(s&&(i+=t[o&a<((e,t,r,n)=>{const o={};for(let e=0;e=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(t,n,r,e)}),bo=po({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),yo=(po({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),wo({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}));wo({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wo({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wo({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wo({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wo({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),wo({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),wo({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),wo({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});class go{constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Bo,byteLength:Bo,code:Ao,version:Ao,multihash:Ao,bytes:Ao,_baseCache:Bo,asCID:Bo})}toV0(){if(0===this.version)return this;{const{code:e,multihash:t}=this;if(e!==ko)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Eo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return go.createV0(t)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=((e,t)=>{const r=t.byteLength,n=no(e),o=n+no(r),i=new Uint8Array(o+r);return ro(e,i,0),ro(r,i,n),i.set(t,o),new io(e,r,t,i)})(e,t);return go.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&((t=this.multihash)===(r=e.multihash)||t.code===r.code&&t.size===r.size&&((e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{const t=oo(e),[r,n]=to(t),[o,i]=to(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new io(r,o,s,t)})(r);return go.create(t,n,o)}return null}static create(e,t,r){if("number"!=typeof t)throw new Error("String codecs are no longer supported");switch(e){case 0:if(t!==ko)throw new Error(`Version 0 CID must use dag-pb (code: ${ko}) block encoding`);return new go(e,t,r,r.bytes);case 1:{const n=xo(e,t,r.bytes);return new go(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return go.create(0,ko,e)}static createV1(e,t){return go.create(1,e,t)}static decode(e){const[t,r]=go.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=go.inspectBytes(e),r=t.size-t.multihashSize,n=oo(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const o=n.subarray(t.multihashSize-t.digestSize),i=new io(t.multihashCode,t.digestSize,o,n);return[0===t.version?go.createV0(i):go.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=to(e.subarray(t));return t+=n,r};let n=r(),o=ko;if(18===n?(n=0,t=0):1===n&&(o=r()),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const i=t,s=r(),a=r(),c=t+a;return{version:n,codec:o,multihashCode:s,digestSize:a,multihashSize:c-i,size:c}}static parse(e,t){const[r,n]=mo(e,t),o=go.decode(n);return o._baseCache.set(r,e),o}}const mo=(e,t)=>{switch(e[0]){case"Q":{const r=t||bo;return[bo.prefix,r.decode(`${bo.prefix}${e}`)]}case bo.prefix:{const r=t||bo;return[bo.prefix,r.decode(e)]}case yo.prefix:{const r=t||yo;return[yo.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}},vo=(e,t,r)=>{const{prefix:n}=r;if(n!==bo.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const o=t.get(n);if(null==o){const o=r.encode(e).slice(1);return t.set(n,o),o}return o},_o=(e,t,r)=>{const{prefix:n}=r,o=t.get(n);if(null==o){const o=r.encode(e);return t.set(n,o),o}return o},ko=112,Eo=18,xo=(e,t,r)=>{const n=no(e),o=n+no(t),i=new Uint8Array(o+r.byteLength);return ro(e,i,0),ro(t,i,n),i.set(r,o),i},Co=Symbol.for("@ipld/js-cid/CID"),Ao={writable:!1,configurable:!1,enumerable:!0},Bo={writable:!1,enumerable:!1,configurable:!1},Io=(e,t)=>{if(!e.test("0.0.0-dev"))throw new Error(t);console.warn(t)},So="CID.isCID(v) is deprecated and will be removed in the next major release.\nFollowing code pattern:\n\nif (CID.isCID(value)) {\n doSomethingWithCID(value)\n}\n\nIs replaced with:\n\nconst cid = CID.asCID(value)\nif (cid) {\n // Make sure to use cid instead of value\n doSomethingWithCID(cid)\n}\n",Do=new TextDecoder;function To(e,t){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(t>=e.length)throw new Error("protobuf: unexpected end of data");const o=e[t++];if(r+=n<28?(127&o)<e.length)throw new Error("protobuf: unexpected end of data");return[e.subarray(t,n),n]}function No(e,t){let r;return[r,t]=To(e,t),[7&r,r>>3,t]}function Lo(e){const t={},r=e.length;let n=0;for(;nr)throw new Error("protobuf: (PBLink) unexpected end of data");return t}const Po=new TextEncoder,Oo=2**32;function zo(e,t){let r=t.length;if("number"==typeof e.Tsize){if(e.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(e.Tsize))throw new Error("Tsize too large for encoding");r=Mo(t,r,e.Tsize)-1,t[r]=24}if("string"==typeof e.Name){const n=Po.encode(e.Name);r-=n.length,t.set(n,r),r=Mo(t,r,n.length)-1,t[r]=18}return e.Hash&&(r-=e.Hash.length,t.set(e.Hash,r),r=Mo(t,r,e.Hash.length)-1,t[r]=10),t.length-r}function Ro(e){let t=0;if(e.Hash){const r=e.Hash.length;t+=1+r+jo(r)}if("string"==typeof e.Name){const r=Po.encode(e.Name).length;t+=1+r+jo(r)}return"number"==typeof e.Tsize&&(t+=1+jo(e.Tsize)),t}function Mo(e,t,r){const n=t-=jo(r);for(;r>=2147483648;)e[t++]=127&r|128,r/=128;for(;r>=128;)e[t++]=127&r|128,r>>>=7;return e[t]=r,n}function jo(e){return e%2==0&&e++,Math.floor((function(e){let t=0;return e>=Oo&&(e=Math.floor(e/Oo),t=32),e>=65536&&(e>>>=16,t+=16),e>=256&&(e>>>=8,t+=8),t+$o[e]}(e)+6)/7)}const $o=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8],Fo=["Data","Links"],Vo=["Hash","Name","Tsize"],qo=new TextEncoder;function Ho(e,t){if(e===t)return 0;const r=e.Name?qo.encode(e.Name):[],n=t.Name?qo.encode(t.Name):[];let o=r.length,i=n.length;for(let e=0,t=Math.min(o,i);e!t.includes(e)))}function Wo(e){if("object"==typeof e.asCID){const t=go.asCID(e);if(!t)throw new TypeError("Invalid DAG-PB form");return{Hash:t}}if("object"!=typeof e||Array.isArray(e))throw new TypeError("Invalid DAG-PB form");const t={};if(e.Hash){let r=go.asCID(e.Hash);try{r||("string"==typeof e.Hash?r=go.parse(e.Hash):e.Hash instanceof Uint8Array&&(r=go.decode(e.Hash)))}catch(e){throw new TypeError(`Invalid DAG-PB form: ${e.message}`)}r&&(t.Hash=r)}if(!t.Hash)throw new TypeError("Invalid DAG-PB form");return"string"==typeof e.Name&&(t.Name=e.Name),"number"==typeof e.Tsize&&(t.Tsize=e.Tsize),t}function Jo(e){if((e instanceof Uint8Array||"string"==typeof e)&&(e={Data:e}),"object"!=typeof e||Array.isArray(e))throw new TypeError("Invalid DAG-PB form");const t={};if(void 0!==e.Data)if("string"==typeof e.Data)t.Data=qo.encode(e.Data);else{if(!(e.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form");t.Data=e.Data}if(void 0!==e.Links){if(!Array.isArray(e.Links))throw new TypeError("Invalid DAG-PB form");t.Links=e.Links.map(Wo),t.Links.sort(Ho)}else t.Links=[];return t}function Ko(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("Invalid DAG-PB form");if(!Go(e,Fo))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(void 0!==e.Data&&!(e.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be a Uint8Array)");if(!Array.isArray(e.Links))throw new TypeError("Invalid DAG-PB form (Links must be an array)");for(let t=0;t0&&-1===Ho(r,e.Links[t-1]))throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function Qo(e,t=[]){return Jo({Data:e,Links:t})}function Xo(e,t,r){return Wo({Hash:r,Name:e,Tsize:t})}const Zo="dag-pb",Yo=112;function ei(e){Ko(e);const t={};return e.Links&&(t.Links=e.Links.map((e=>{const t={};return e.Hash&&(t.Hash=e.Hash.bytes),void 0!==e.Name&&(t.Name=e.Name),void 0!==e.Tsize&&(t.Tsize=e.Tsize),t}))),e.Data&&(t.Data=e.Data),function(e){const t=function(e){let t=0;if(e.Data){const r=e.Data.length;t+=1+r+jo(r)}if(e.Links)for(const r of e.Links){const e=Ro(r);t+=1+e+jo(e)}return t}(e),r=new Uint8Array(t);let n=t;if(e.Data&&(n-=e.Data.length,r.set(e.Data,n),n=Mo(r,n,e.Data.length)-1,r[n]=10),e.Links)for(let t=e.Links.length-1;t>=0;t--){const o=zo(e.Links[t],r.subarray(0,n));n-=o,n=Mo(r,n,o)-1,r[n]=18}return r}(t)}function ti(e){const t=function(e){const t=e.length;let r,n,o=0,i=!1;for(;ot)throw new Error("protobuf: (PBNode) unexpected end of data");const s={};return n&&(s.Data=n),s.Links=r||[],s}(e),r={};return t.Data&&(r.Data=t.Data),t.Links&&(r.Links=t.Links.map((e=>{const t={};try{t.Hash=go.decode(e.Hash)}catch(e){}if(!t.Hash)throw new Error("Invalid Hash field found in link, expected CID");return void 0!==e.Name&&(t.Name=e.Name),void 0!==e.Tsize&&(t.Tsize=e.Tsize),t}))),r}var ri=Math.pow(2,31),ni=Math.pow(2,7),oi=Math.pow(2,14),ii=Math.pow(2,21),si=Math.pow(2,28),ai=Math.pow(2,35),ci=Math.pow(2,42),ui=Math.pow(2,49),hi=Math.pow(2,56),fi=Math.pow(2,63);const li={encode:function e(t,r,n){r=r||[];for(var o=n=n||0;t>=ri;)r[n++]=255&t|128,t/=128;for(;-128&t;)r[n++]=255&t|128,t>>>=7;return r[n]=0|t,e.bytes=n-o+1,r},decode:function e(t,r){var n,o=0,i=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],o+=i<28?(127&n)<=128);return e.bytes=s-r,o},encodingLength:function(e){return e[li.decode(e,t),li.decode.bytes],pi=(e,t,r=0)=>(li.encode(e,t,r),t),wi=e=>li.encodingLength(e),bi=(new Uint8Array(0),e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)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")});class yi{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const gi=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,s=new Uint8Array(i);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var f=0,l=i-1;(0!==h||f>>0,s[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=f,t++}if(" "!==e[t]){for(var d=i-o;d!==i&&0===s[d];)d++;for(var p=new Uint8Array(n+(i-d)),w=n;d!==i;)p[w++]=s[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var s=(i-o)*h+1>>>0,u=new Uint8Array(s);o!==i;){for(var f=t[o],l=0,d=s-1;(0!==f||l>>0,u[d]=f%a>>>0,f=f/a>>>0;if(0!==f)throw new Error("Non-zero carry");n=l,o++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var w=c.repeat(r);pnew _i({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Ei{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new mi(e,t,r),this.decoder=new vi(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const xi=({name:e,prefix:t,encode:r,decode:n})=>new Ei(e,t,r,n),Ci=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:o}=gi(r,t);return xi({prefix:e,name:t,encode:n,decode:e=>bi(o(e))})},Ai=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>xi({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],o=(1<r;)s-=r,i+=t[o&a>>s];if(s&&(i+=t[o&a<((e,t,r,n)=>{const o={};for(let e=0;e=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(t,n,r,e)}),Bi=Ci({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ii=(Ci({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Ai({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}));Ai({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ai({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ai({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ai({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ai({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ai({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ai({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ai({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});class Si{constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Ri,byteLength:Ri,code:zi,version:zi,multihash:zi,bytes:zi,_baseCache:Ri,asCID:Ri})}toV0(){if(0===this.version)return this;{const{code:e,multihash:t}=this;if(e!==Ni)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Li)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return Si.createV0(t)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=((e,t)=>{const r=t.byteLength,n=wi(e),o=n+wi(r),i=new Uint8Array(o+r);return pi(e,i,0),pi(r,i,n),i.set(t,o),new yi(e,r,t,i)})(e,t);return Si.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&((t=this.multihash)===(r=e.multihash)||t.code===r.code&&t.size===r.size&&((e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{const t=bi(e),[r,n]=di(t),[o,i]=di(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new yi(r,o,s,t)})(r);return Si.create(t,n,o)}return null}static create(e,t,r){if("number"!=typeof t)throw new Error("String codecs are no longer supported");switch(e){case 0:if(t!==Ni)throw new Error(`Version 0 CID must use dag-pb (code: ${Ni}) block encoding`);return new Si(e,t,r,r.bytes);case 1:{const n=Pi(e,t,r.bytes);return new Si(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return Si.create(0,Ni,e)}static createV1(e,t){return Si.create(1,e,t)}static decode(e){const[t,r]=Si.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=Si.inspectBytes(e),r=t.size-t.multihashSize,n=bi(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const o=n.subarray(t.multihashSize-t.digestSize),i=new yi(t.multihashCode,t.digestSize,o,n);return[0===t.version?Si.createV0(i):Si.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=di(e.subarray(t));return t+=n,r};let n=r(),o=Ni;if(18===n?(n=0,t=0):1===n&&(o=r()),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const i=t,s=r(),a=r(),c=t+a;return{version:n,codec:o,multihashCode:s,digestSize:a,multihashSize:c-i,size:c}}static parse(e,t){const[r,n]=Di(e,t),o=Si.decode(n);return o._baseCache.set(r,e),o}}const Di=(e,t)=>{switch(e[0]){case"Q":{const r=t||Bi;return[Bi.prefix,r.decode(`${Bi.prefix}${e}`)]}case Bi.prefix:{const r=t||Bi;return[Bi.prefix,r.decode(e)]}case Ii.prefix:{const r=t||Ii;return[Ii.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}},Ti=(e,t,r)=>{const{prefix:n}=r;if(n!==Bi.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const o=t.get(n);if(null==o){const o=r.encode(e).slice(1);return t.set(n,o),o}return o},Ui=(e,t,r)=>{const{prefix:n}=r,o=t.get(n);if(null==o){const o=r.encode(e);return t.set(n,o),o}return o},Ni=112,Li=18,Pi=(e,t,r)=>{const n=wi(e),o=n+wi(t),i=new Uint8Array(o+r.byteLength);return pi(e,i,0),pi(t,i,n),i.set(r,o),i},Oi=Symbol.for("@ipld/js-cid/CID"),zi={writable:!1,configurable:!1,enumerable:!0},Ri={writable:!1,enumerable:!1,configurable:!1},Mi=(e,t)=>{if(!e.test("0.0.0-dev"))throw new Error(t);console.warn(t)},ji="CID.isCID(v) is deprecated and will be removed in the next major release.\nFollowing code pattern:\n\nif (CID.isCID(value)) {\n doSomethingWithCID(value)\n}\n\nIs replaced with:\n\nconst cid = CID.asCID(value)\nif (cid) {\n // Make sure to use cid instead of value\n doSomethingWithCID(cid)\n}\n",$i=Ai({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6});Ai({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ai({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ai({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});class Fi extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){const t=this.inRecursive[this.inRecursive.length-1];t&&(t.type===wt.array&&(t.elements++,1!==t.elements&&e.push([44])),t.type===wt.map&&(t.elements++,1!==t.elements&&(t.elements%2==1?e.push([44]):e.push([58]))))}[wt.uint.major](e,t){this.prefix(e);const r=String(t.value),n=[];for(let e=0;e32?_t(r):r)}[wt.array.major](e,t){this.prefix(e),this.inRecursive.push({type:wt.array,elements:0}),e.push([91])}[wt.map.major](e,t){this.prefix(e),this.inRecursive.push({type:wt.map,elements:0}),e.push([123])}[wt.tag.major](e,t){}[wt.float.major](e,t){if("break"===t.type.name){const t=this.inRecursive.pop();if(t){if(t.type===wt.array)e.push([93]);else{if(t.type!==wt.map)throw new Error("Unexpected recursive type; this should not happen!");e.push([125])}return}throw new Error("Unexpected break; this should not happen!")}if(void 0===t.value)throw new Error("CBOR encode error: unsupported type: undefined");if(this.prefix(e),"true"===t.type.name)return void e.push([116,114,117,101]);if("false"===t.type.name)return void e.push([102,97,108,115,101]);if("null"===t.type.name)return void e.push([110,117,108,108]);const r=String(t.value),n=[];let o=!1;for(let e=0;en)return 1;throw new Error("CBOR encode error: unexpected duplicate map keys, this is not supported")}};class qi{constructor(e,t={}){this.pos=0,this.data=e,this.options=t,this.modeStack=["value"],this.lastToken=""}done(){return this.pos>=this.data.length}ch(){return this.data[this.pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;32===e||9===e||13===e||10===e;)e=this.data[++this.pos]}expect(e){if(this.data.length-this.pos{for(;!this.done();){const t=this.ch();if(!e.includes(t))break;this.pos++}};if(45===this.ch()&&(t=!0,this.pos++),48===this.ch()){if(this.pos++,46!==this.ch())return new bt(wt.uint,0,this.pos-e);this.pos++,r=!0}if(n([48,49,50,51,52,53,54,55,56,57]),t&&this.pos===e+1)throw new Error(`CBOR decode error: unexpected token at position ${this.pos}`);if(!this.done()&&46===this.ch()){if(r)throw new Error(`CBOR decode error: unexpected token at position ${this.pos}`);r=!0,this.pos++,n([48,49,50,51,52,53,54,55,56,57])}this.done()||101!==this.ch()&&69!==this.ch()||(r=!0,this.pos++,this.done()||43!==this.ch()&&45!==this.ch()||this.pos++,n([48,49,50,51,52,53,54,55,56,57]));const o=String.fromCharCode.apply(null,this.data.subarray(e,this.pos)),i=parseFloat(o);return r?new bt(wt.float,i,this.pos-e):!0!==this.options.allowBigInt||Number.isSafeInteger(i)?new bt(i>=0?wt.uint:wt.negint,i,this.pos-e):new bt(i>=0?wt.uint:wt.negint,BigInt(o),this.pos-e)}parseString(){if(34!==this.ch())throw new Error(`CBOR decode error: unexpected character at position ${this.pos}; this shouldn't happen`);this.pos++;for(let e=this.pos,t=0;e=128)break;if(34===r){const r=String.fromCharCode.apply(null,this.data.subarray(this.pos,e));return this.pos=e+1,new bt(wt.string,r,t)}}const e=this.pos,t=[],r=()=>{if(this.pos+4>=this.data.length)throw new Error(`CBOR decode error: unexpected end of unicode escape sequence at position ${this.pos}`);let e=0;for(let t=0;t<4;t++){let t=this.ch();if(t>=48&&t<=57)t-=48;else if(t>=97&&t<=102)t=t-97+10;else{if(!(t>=65&&t<=70))throw new Error(`CBOR decode error: unexpected unicode escape character at position ${this.pos}`);t=t-65+10}e=16*e+t,this.pos++}return e},n=()=>{const e=this.ch();let r,n,o,i,s=null,a=e>239?4:e>223?3:e>191?2:1;if(this.pos+a>this.data.length)throw new Error(`CBOR decode error: unexpected unicode sequence at position ${this.pos}`);switch(a){case 1:e<128&&(s=e);break;case 2:r=this.data[this.pos+1],128==(192&r)&&(i=(31&e)<<6|63&r,i>127&&(s=i));break;case 3:r=this.data[this.pos+1],n=this.data[this.pos+2],128==(192&r)&&128==(192&n)&&(i=(15&e)<<12|(63&r)<<6|63&n,i>2047&&(i<55296||i>57343)&&(s=i));break;case 4:r=this.data[this.pos+1],n=this.data[this.pos+2],o=this.data[this.pos+3],128==(192&r)&&128==(192&n)&&128==(192&o)&&(i=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&o,i>65535&&i<1114112&&(s=i))}null===s?(s=65533,a=1):s>65535&&(s-=65536,t.push(s>>>10&1023|55296),s=56320|1023&s),t.push(s),this.pos+=a};for(;!this.done();){const o=this.ch();let i;switch(o){case 92:if(this.pos++,this.done())throw new Error(`CBOR decode error: unexpected string termination at position ${this.pos}`);switch(i=this.ch(),this.pos++,i){case 34:case 39:case 92:case 47:t.push(i);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(`CBOR decode error: unexpected string escape character at position ${this.pos}`)}break;case 34:return this.pos++,new bt(wt.string,Dt(t),this.pos-e);default:if(o<32)throw new Error(`CBOR decode error: invalid control character at position ${this.pos}`);o<128?(t.push(o),this.pos++):n()}}throw new Error(`CBOR decode error: unexpected end of string at position ${this.pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this.pos++,new bt(wt.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new bt(wt.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new bt(wt.null,null,4);case 102:return this.expect([102,97,108,115,101]),new bt(wt.false,!1,5);case 116:return this.expect([116,114,117,101]),new bt(wt.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(`CBOR decode error: 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(),93===this.ch())return this.pos++,this.skipWhitespace(),new bt(wt.break,void 0,1);if(44!==this.ch())throw new Error(`CBOR decode error: 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(),93===this.ch()?(this.pos++,this.skipWhitespace(),new bt(wt.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(125===this.ch())return this.modeStack.pop(),this.pos++,this.skipWhitespace(),new bt(wt.break,void 0,1);if(44!==this.ch())throw new Error(`CBOR decode error: 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(),125===this.ch())return this.pos++,this.skipWhitespace(),new bt(wt.break,void 0,1);const e=this.parseString();if(this.skipWhitespace(),58!==this.ch())throw new Error(`CBOR decode error: 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(`CBOR decode error: unexpected parse state at position ${this.pos}; this shouldn't happen`)}}}function Hi(e){const t=$i.encode(e).slice(1);return[new bt(wt.map,1/0,1),new bt(wt.string,"/",1),new bt(wt.map,1/0,1),new bt(wt.string,"bytes",5),new bt(wt.string,t,t.length),new bt(wt.break,void 0,1),new bt(wt.break,void 0,1)]}const Gi={typeEncoders:{Object:function(e){if(e.asCID!==e)return null;const t=Si.asCID(e);if(!t)return null;const r=t.toString();return[new bt(wt.map,1/0,1),new bt(wt.string,"/",1),new bt(wt.string,r,r.length),new bt(wt.break,void 0,1)]},Uint8Array:Hi,Buffer:Hi,undefined:function(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")},number:function(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}}};class Wi extends qi{constructor(e,t){super(e,t),this.tokenBuffer=[]}done(){return 0===this.tokenBuffer.length&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){const e=this._next();if(e.type===wt.map){const e=this._next();if(e.type===wt.string&&"/"===e.value){const e=this._next();if(e.type===wt.string){if(this._next().type!==wt.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(e),new bt(wt.tag,42,0)}if(e.type===wt.map){const e=this._next();if(e.type===wt.string&&"bytes"===e.value){const e=this._next();if(e.type===wt.string){for(let e=0;e<2;e++)if(this._next().type!==wt.break)throw new Error("Invalid encoded Bytes form");const t=$i.decode(`m${e.value}`);return new bt(wt.bytes,t,e.value.length)}this.tokenBuffer.push(e)}this.tokenBuffer.push(e)}this.tokenBuffer.push(e)}this.tokenBuffer.push(e)}return e}}const Ji={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};Ji.tags[42]=Si.parse;const Ki="dag-json",Qi=297,Xi=e=>{return t=e,r=Gi,r=Object.assign({},Vi,r),Br(t,new Fi,r);var t,r},Zi=e=>function(e,t){return Nr(e,t=Object.assign({tokenizer:new qi(e,t)},t))}(e,Object.assign(Ji,{tokenizer:new Wi(e,Ji)}));var Yi=__webpack_require__(114);const es=["string","number","bigint","symbol"],ts=["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"];class rs{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.majore.major?1:0}}rs.uint=new rs(0,"uint",!0),rs.negint=new rs(1,"negint",!0),rs.bytes=new rs(2,"bytes",!0),rs.string=new rs(3,"string",!0),rs.array=new rs(4,"array",!1),rs.map=new rs(5,"map",!1),rs.tag=new rs(6,"tag",!1),rs.float=new rs(7,"float",!0),rs.false=new rs(7,"false",!0),rs.true=new rs(7,"true",!0),rs.null=new rs(7,"null",!0),rs.undefined=new rs(7,"undefined",!0),rs.break=new rs(7,"break",!0);class ns{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}`}}const os=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer,is=new TextDecoder,ss=new TextEncoder;function as(e){return os&&globalThis.Buffer.isBuffer(e)}const cs=os?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):ps(e,t,r):(e,t,r)=>r-t>64?is.decode(e.subarray(t,r)):ps(e,t,r),us=os?e=>e.length>64?globalThis.Buffer.from(e):ds(e):e=>e.length>64?ss.encode(e):ds(e),hs=os?(e,t,r)=>as(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),fs=os?(e,t)=>(e=e.map((e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e))),function(e){return e instanceof Uint8Array?as(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}(globalThis.Buffer.concat(e,t))):(e,t)=>{const r=new Uint8Array(t);let n=0;for(let t of e)n+t.length>r.length&&(t=t.subarray(0,r.length-n)),r.set(t,n),n+=t.length;return r},ls=os?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function ds(e,t=1/0){let r;const n=e.length;let o=null;const i=[];for(let s=0;s55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function ps(e,t,r){const n=[];for(;t239?4:o>223?3:o>191?2:1;if(t+s<=r){let r,n,a,c;switch(s){case 1:o<128&&(i=o);break;case 2:r=e[t+1],128==(192&r)&&(c=(31&o)<<6|63&r,c>127&&(i=c));break;case 3:r=e[t+1],n=e[t+2],128==(192&r)&&128==(192&n)&&(c=(15&o)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(i=c));break;case 4:r=e[t+1],n=e[t+2],a=e[t+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&o)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(i=c))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),t+=s}return function(e){const t=e.length;if(t<=ws)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n>>8,255&n])}else if(r>>24&255,n>>>16&255,n>>>8&255,255&n])}else{const n=BigInt(r);if(!(n>BigInt(32)&BigInt(4294967295));r[8]=255&o,o>>=8,r[7]=255&o,o>>=8,r[6]=255&o,o>>=8,r[5]=255&o,r[4]=255&i,i>>=8,r[3]=255&i,i>>=8,r[2]=255&i,i>>=8,r[1]=255&i,e.push(r)}}}Es.encodedSize=function(e){return xs.encodedSize(e.value)},xs.encodedSize=function(e){return et.value?1:0};const Cs=BigInt(-1),As=BigInt(1);function Bs(e,t){const r=t.value,n="bigint"==typeof r?r*Cs-As:-1*r-1;xs(e,t.type.majorEncoded,n)}function Is(e,t,r,n){ys(e,t,r+n);const o=hs(e,t+r,t+r+n);return new ns(rs.bytes,o,r+n)}function Ss(e,t,r,n){return Is(e,t,1,r)}function Ds(e){return void 0===e.encodedBytes&&(e.encodedBytes=e.type===rs.string?us(e.value):e.value),e.encodedBytes}function Ts(e,t){const r=Ds(t);xs(e,t.type.majorEncoded,r.length),e.push(r)}function Us(e,t,r,n,o){const i=r+n;ys(e,t,i);const s=new ns(rs.string,cs(e,t+r,t+i),i);return!0===o.retainStringBytes&&(s.byteValue=hs(e,t+r,t+i)),s}function Ns(e,t,r,n){return Us(e,t,1,r,n)}Bs.encodedSize=function(e){const t=e.value,r="bigint"==typeof t?t*Cs-As:-1*t-1;return rt.value?-1:0},Ts.encodedSize=function(e){const t=Ds(e);return xs.encodedSize(t.length)+t.length},Ts.compareTokens=function(e,t){return r=Ds(e),n=Ds(t),r.lengthn.length?1:function(e,t){if(as(e)&&as(t))return e.compare(t);for(let r=0;r>23,n=8388607&t;if(255===r)Gs.setUint16(0,31744,!1);else if(0===r)Gs.setUint16(0,(2147483648&e)>>16|n>>13,!1);else{const e=r-127;e<-24?Gs.setUint16(0,0):e<-14?Gs.setUint16(0,(2147483648&t)>>16|1<<24+e,!1):Gs.setUint16(0,(2147483648&t)>>16|e+15<<10|n>>13,!1)}}}function Ks(e,t){if(e.length-t<2)throw new Error("CBOR decode error: not enough data for float16");const r=(e[t]<<8)+e[t+1];if(31744===r)return 1/0;if(64512===r)return-1/0;if(32256===r)return NaN;const n=r>>10&31,o=1023&r;let i;return i=0===n?o*2**-24:31!==n?(o+1024)*2**(n-25):0===o?1/0:NaN,32768&r?-i:i}function Qs(e){Gs.setFloat32(0,e,!1)}function Xs(e,t){if(e.length-t<4)throw new Error("CBOR decode error: not enough data for float32");const r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Zs(e,t){if(e.length-t<8)throw new Error("CBOR decode error: not enough data for float64");const r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}function Ys(e,t,r){throw new Error(`CBOR decode error: encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function ea(e){return()=>{throw new Error(`CBOR decode error: ${e}`)}}qs.compareTokens=Es.compareTokens;const ta=[];for(let e=0;e<=23;e++)ta[e]=Ys;ta[24]=function(e,t,r,n){return new ns(rs.uint,ms(e,t+1,n),2)},ta[25]=function(e,t,r,n){return new ns(rs.uint,vs(e,t+1,n),3)},ta[26]=function(e,t,r,n){return new ns(rs.uint,_s(e,t+1,n),5)},ta[27]=function(e,t,r,n){return new ns(rs.uint,ks(e,t+1,n),9)},ta[28]=Ys,ta[29]=Ys,ta[30]=Ys,ta[31]=Ys;for(let e=32;e<=55;e++)ta[e]=Ys;ta[56]=function(e,t,r,n){return new ns(rs.negint,-1-ms(e,t+1,n),2)},ta[57]=function(e,t,r,n){return new ns(rs.negint,-1-vs(e,t+1,n),3)},ta[58]=function(e,t,r,n){return new ns(rs.negint,-1-_s(e,t+1,n),5)},ta[59]=function(e,t,r,n){const o=ks(e,t+1,n);if("bigint"!=typeof o){const e=-1-o;if(e>=Number.MIN_SAFE_INTEGER)return new ns(rs.negint,e,9)}if(!0!==n.allowBigInt)throw new Error("CBOR decode error: integers outside of the safe integer range are not supported");return new ns(rs.negint,Cs-BigInt(o),9)},ta[60]=Ys,ta[61]=Ys,ta[62]=Ys,ta[63]=Ys;for(let e=64;e<=87;e++)ta[e]=Ss;ta[88]=function(e,t,r,n){return Is(e,t,2,ms(e,t+1,n))},ta[89]=function(e,t,r,n){return Is(e,t,3,vs(e,t+1,n))},ta[90]=function(e,t,r,n){return Is(e,t,5,_s(e,t+1,n))},ta[91]=function(e,t,r,n){const o=ks(e,t+1,n);if("bigint"==typeof o)throw new Error("CBOR decode error: 64-bit integer bytes lengths not supported");return Is(e,t,9,o)},ta[92]=Ys,ta[93]=Ys,ta[94]=Ys,ta[95]=ea("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)ta[e]=Ns;ta[120]=function(e,t,r,n){return Us(e,t,2,ms(e,t+1,n),n)},ta[121]=function(e,t,r,n){return Us(e,t,3,vs(e,t+1,n),n)},ta[122]=function(e,t,r,n){return Us(e,t,5,_s(e,t+1,n),n)},ta[123]=function(e,t,r,n){const o=ks(e,t+1,n);if("bigint"==typeof o)throw new Error("CBOR decode error: 64-bit integer string lengths not supported");return Us(e,t,9,o,n)},ta[124]=Ys,ta[125]=Ys,ta[126]=Ys,ta[127]=ea("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)ta[e]=Os;ta[152]=function(e,t,r,n){return Ps(0,0,2,ms(e,t+1,n))},ta[153]=function(e,t,r,n){return Ps(0,0,3,vs(e,t+1,n))},ta[154]=function(e,t,r,n){return Ps(0,0,5,_s(e,t+1,n))},ta[155]=function(e,t,r,n){const o=ks(e,t+1,n);if("bigint"==typeof o)throw new Error("CBOR decode error: 64-bit integer array lengths not supported");return Ps(0,0,9,o)},ta[156]=Ys,ta[157]=Ys,ta[158]=Ys,ta[159]=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error("CBOR decode error: indefinite length items not allowed");return Ps(0,0,1,1/0)};for(let e=160;e<=183;e++)ta[e]=Ms;ta[184]=function(e,t,r,n){return Rs(0,0,2,ms(e,t+1,n))},ta[185]=function(e,t,r,n){return Rs(0,0,3,vs(e,t+1,n))},ta[186]=function(e,t,r,n){return Rs(0,0,5,_s(e,t+1,n))},ta[187]=function(e,t,r,n){const o=ks(e,t+1,n);if("bigint"==typeof o)throw new Error("CBOR decode error: 64-bit integer map lengths not supported");return Rs(0,0,9,o)},ta[188]=Ys,ta[189]=Ys,ta[190]=Ys,ta[191]=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error("CBOR decode error: indefinite length items not allowed");return Rs(0,0,1,1/0)};for(let e=192;e<=215;e++)ta[e]=$s;ta[216]=function(e,t,r,n){return new ns(rs.tag,ms(e,t+1,n),2)},ta[217]=function(e,t,r,n){return new ns(rs.tag,vs(e,t+1,n),3)},ta[218]=function(e,t,r,n){return new ns(rs.tag,_s(e,t+1,n),5)},ta[219]=function(e,t,r,n){return new ns(rs.tag,ks(e,t+1,n),9)},ta[220]=Ys,ta[221]=Ys,ta[222]=Ys,ta[223]=Ys;for(let e=224;e<=243;e++)ta[e]=ea("simple values are not supported");ta[244]=Ys,ta[245]=Ys,ta[246]=Ys,ta[247]=function(e,t,r,n){if(!1===n.allowUndefined)throw new Error("CBOR decode error: undefined values are not supported");return!0===n.coerceUndefinedToNull?new ns(rs.null,null,1):new ns(rs.undefined,void 0,1)},ta[248]=ea("simple values are not supported"),ta[249]=function(e,t,r,n){return Vs(Ks(e,t+1),3,n)},ta[250]=function(e,t,r,n){return Vs(Xs(e,t+1),5,n)},ta[251]=function(e,t,r,n){return Vs(Zs(e,t+1),9,n)},ta[252]=Ys,ta[253]=Ys,ta[254]=Ys,ta[255]=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error("CBOR decode error: indefinite length items not allowed");return new ns(rs.break,void 0,1)};const ra=[];for(let e=0;e<24;e++)ra[e]=new ns(rs.uint,e,1);for(let e=-1;e>=-24;e--)ra[31-e]=new ns(rs.negint,e,1);ra[64]=new ns(rs.bytes,new Uint8Array(0),1),ra[96]=new ns(rs.string,"",1),ra[128]=new ns(rs.array,0,1),ra[160]=new ns(rs.map,0,1),ra[244]=new ns(rs.false,!1,1),ra[245]=new ns(rs.true,!0,1),ra[246]=new ns(rs.null,null,1),function(){const e=[];e[rs.uint.major]=Es,e[rs.negint.major]=Bs,e[rs.bytes.major]=Ts,e[rs.string.major]=Ls,e[rs.array.major]=zs,e[rs.map.major]=js,e[rs.tag.major]=Fs,e[rs.float.major]=qs}(),new class{constructor(e=256){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=[]),null!==this._initReuseChunk&&(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){const r=t.length-(this.maxCursor-this.cursor)-1;t.set(e,r)}else{if(t){const e=t.length-(this.maxCursor-this.cursor)-1;er.length/2?(t=this.cursor===r.length?r:r.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=hs(r,0,this.cursor)}else t=fs(this.chunks,this.cursor);return e&&this.reset(),t}};class na{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do{if(t.obj===e)return!0}while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error("CBOR encode error: object contains circular references");return new na(t,e)}}const oa={null:new ns(rs.null,null),undefined:new ns(rs.undefined,void 0),true:new ns(rs.true,!0),false:new ns(rs.false,!1),emptyArray:new ns(rs.array,0),emptyMap:new ns(rs.map,0)},ia={number:(e,t,r,n)=>Number.isInteger(e)&&Number.isSafeInteger(e)?new ns(e>=0?rs.uint:rs.negint,e):new ns(rs.float,e),bigint:(e,t,r,n)=>e>=BigInt(0)?new ns(rs.uint,e):new ns(rs.negint,e),Uint8Array:(e,t,r,n)=>new ns(rs.bytes,e),string:(e,t,r,n)=>new ns(rs.string,e),boolean:(e,t,r,n)=>e?oa.true:oa.false,null:(e,t,r,n)=>oa.null,undefined:(e,t,r,n)=>oa.undefined,ArrayBuffer:(e,t,r,n)=>new ns(rs.bytes,new Uint8Array(e)),DataView:(e,t,r,n)=>new ns(rs.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Array(e,t,r,n){if(!e.length)return!0===r.addBreakTokens?[oa.emptyArray,new ns(rs.break)]:oa.emptyArray;n=na.createCheck(n,e);const o=[];let i=0;for(const t of e)o[i++]=sa(t,r,n);return r.addBreakTokens?[new ns(rs.array,e.length),o,new ns(rs.break)]:[new ns(rs.array,e.length),o]},Object(e,t,r,n){const o="Object"!==t,i=o?e.keys():Object.keys(e),s=o?e.size:i.length;if(!s)return!0===r.addBreakTokens?[oa.emptyMap,new ns(rs.break)]:oa.emptyMap;n=na.createCheck(n,e);const a=[];let c=0;for(const t of i)a[c++]=[sa(t,r,n),sa(o?e.get(t):e[t],r,n)];return function(e,t){t.mapSorter&&e.sort(t.mapSorter)}(a,r),r.addBreakTokens?[new ns(rs.map,s),a,new ns(rs.break)]:[new ns(rs.map,s),a]}};ia.Map=ia.Object,ia.Buffer=ia.Uint8Array;for(const e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))ia[`${e}Array`]=ia.DataView;function sa(e,t={},r){const n=function(e){if(null===e)return"null";if(void 0===e)return"undefined";if(!0===e||!1===e)return"boolean";const t=typeof e;if(es.includes(t))return t;if("function"===t)return"Function";if(Array.isArray(e))return"Array";if(function(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}(e))return"Buffer";const r=function(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(ts.includes(t))return t}(e);return r||"Object"}(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||ia[n];if("function"==typeof o){const i=o(e,n,t,r);if(null!=i)return i}const i=ia[n];if(!i)throw new Error(`CBOR encode error: unsupported type: ${n}`);return i(e,n,t,r)}const aa={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};class ca{constructor(e,t={}){this.pos=0,this.data=e,this.options=t}done(){return this.pos>=this.data.length}next(){const e=this.data[this.pos];let t=ra[e];if(void 0===t){const r=ta[e];if(!r)throw new Error(`CBOR decode error: no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);const n=31&e;t=r(this.data,this.pos,n,this.options)}return this.pos+=t.encodedLength,t}}const ua=Symbol.for("DONE"),ha=Symbol.for("BREAK");function fa(e,t){if(e.done())return ua;const r=e.next();if(r.type===rs.break)return ha;if(r.type.terminal)return r.value;if(r.type===rs.array)return function(e,t,r){const n=[];for(let o=0;ofunction(e,t){if(!(e instanceof Uint8Array))throw new Error("CBOR decode error: data to decode must be a Uint8Array");const r=(t=Object.assign({},aa,t)).tokenizer||new ca(e,t),n=fa(r,t);if(n===ua)throw new Error("CBOR decode error: did not find any content to decode");if(n===ha)throw new Error("CBOR decode error: got unexpected break");if(!r.done())throw new Error("CBOR decode error: too many terminals, data makes no sense");return n}(e,la),pa=new TextDecoder;function wa(e,t){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(t>=e.length)throw new Error("protobuf: unexpected end of data");const o=e[t++];if(r+=n<28?(127&o)<e.length)throw new Error("protobuf: unexpected end of data");return[e.subarray(t,n),n]}function ya(e,t){let r;return[r,t]=wa(e,t),[7&r,r>>3,t]}function ga(e){const t={},r=e.length;let n=0;for(;nr)throw new Error("protobuf: (PBLink) unexpected end of data");return t}function ma(e){const t=function(e){const t=e.length;let r,n,o=0,i=!1;for(;ot)throw new Error("protobuf: (PBNode) unexpected end of data");const s={};return n&&(s.Data=n),s.Links=r||[],s}(e),r={};return t.Data&&(r.Data=t.Data),t.Links&&(r.Links=t.Links.map((e=>{const t={};try{t.Hash=le.decode(e.Hash)}catch(e){}if(!t.Hash)throw new Error("Invalid Hash field found in link, expected CID");return void 0!==e.Name&&(t.Name=e.Name),void 0!==e.Tsize&&(t.Tsize=e.Tsize),t}))),r}new TextEncoder,new TextEncoder;const va="raw",_a=85,ka=e=>k(e),Ea=e=>k(e),xa=k,Ca={code:0,name:"identity",encode:xa,digest:e=>se(0,xa(e))};class Aa extends Event{constructor(e,t){super(e),this.detail=t}}const Ba=function(e,t,r,n){const o=BigInt(e.length),i=BigInt(t+o);return r>=i||n=t&&n=t&&r{const n=BigInt(e),o=BigInt(t??0);let i=BigInt(r);if(i!==n&&(i=o+i),i>n&&(i=n),o<0n)throw Yi(new Error("Offset must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(o>n)throw Yi(new Error("Offset must be less than the file size"),"ERR_INVALID_PARAMS");if(i<0n)throw Yi(new Error("Length must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(i>n)throw Yi(new Error("Length must be less than the file size"),"ERR_INVALID_PARAMS");return{start:o,end:i}};var Sa=__webpack_require__(408),Da=__webpack_require__(593),Ta=__webpack_require__(693),Ua=__webpack_require__(173),Na=__webpack_require__(155);Ta._configure(),Sa._configure(Da),Ua._configure(Na);const La=["uint64","int64","sint64","fixed64","sfixed64"];function Pa(e,t){const r=function(e){return function(e){for(const t of La){if(null==e[t])continue;const r=e[t];e[t]=function(){return BigInt(r.call(this).toString())}}return e}(new Sa(e))}(e instanceof Uint8Array?e:e.subarray());return t.decode(r)}function Oa(e,t){const r=function(e){for(const t of La){if(null==e[t])continue;const r=e[t];e[t]=function(e){return r.call(this,e.toString())}}return e}(Ua.create());return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var za,Ra,Ma,ja;function $a(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Fa(e,t){return $a("message",za.LENGTH_DELIMITED,e,t)}!function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(za||(za={})),function(e){let t,r,n;!function(e){e.Raw="Raw",e.Directory="Directory",e.File="File",e.Metadata="Metadata",e.Symlink="Symlink",e.HAMTShard="HAMTShard"}(t=e.DataType||(e.DataType={})),function(e){e[e.Raw=0]="Raw",e[e.Directory=1]="Directory",e[e.File=2]="File",e[e.Metadata=3]="Metadata",e[e.Symlink=4]="Symlink",e[e.HAMTShard=5]="HAMTShard"}(r||(r={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return $a("enum",za.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(r)}(t=e.DataType||(e.DataType={})),e.codec=()=>(null==n&&(n=Fa(((t,r,n={})=>{if(!1!==n.lengthDelimited&&r.fork(),null!=t.Type&&(r.uint32(8),e.DataType.codec().encode(t.Type,r)),null!=t.Data&&(r.uint32(18),r.bytes(t.Data)),null!=t.filesize&&(r.uint32(24),r.uint64(t.filesize)),null!=t.blocksizes)for(const e of t.blocksizes)r.uint32(32),r.uint64(e);null!=t.hashType&&(r.uint32(40),r.uint64(t.hashType)),null!=t.fanout&&(r.uint32(48),r.uint64(t.fanout)),null!=t.mode&&(r.uint32(56),r.uint32(t.mode)),null!=t.mtime&&(r.uint32(66),Ma.codec().encode(t.mtime,r)),!1!==n.lengthDelimited&&r.ldelim()}),((t,r)=>{const n={blocksizes:[]},o=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:n.Type=e.DataType.codec().decode(t);break;case 2:n.Data=t.bytes();break;case 3:n.filesize=t.uint64();break;case 4:n.blocksizes.push(t.uint64());break;case 5:n.hashType=t.uint64();break;case 6:n.fanout=t.uint64();break;case 7:n.mode=t.uint32();break;case 8:n.mtime=Ma.codec().decode(t,t.uint32());break;default:t.skipType(7&r)}}return n}))),n),e.encode=t=>Oa(t,e.codec()),e.decode=t=>Pa(t,e.codec())}(Ra||(Ra={})),function(e){let t;e.codec=()=>(null==t&&(t=Fa(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.Seconds&&(t.uint32(8),t.int64(e.Seconds)),null!=e.FractionalNanoseconds&&(t.uint32(21),t.fixed32(e.FractionalNanoseconds)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:r.Seconds=e.int64();break;case 2:r.FractionalNanoseconds=e.fixed32();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Oa(t,e.codec()),e.decode=t=>Pa(t,e.codec())}(Ma||(Ma={})),function(e){let t;e.codec=()=>(null==t&&(t=Fa(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.MimeType&&(t.uint32(10),t.string(e.MimeType)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos>>3==1?r.MimeType=e.string():e.skipType(7&t)}return r}))),t),e.encode=t=>Oa(t,e.codec()),e.decode=t=>Pa(t,e.codec())}(ja||(ja={}));const Va={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},qa=["directory","hamt-sharded-directory"],Ha=parseInt("0644",8),Ga=parseInt("0755",8);class Wa{static unmarshal(e){const t=Ra.decode(e),r=new Wa({type:Va[null!=t.Type?t.Type.toString():"File"],data:t.Data,blockSizes:t.blocksizes,mode:t.mode,mtime:null!=t.mtime?{secs:t.mtime.Seconds??0n,nsecs:t.mtime.FractionalNanoseconds}:void 0,fanout:t.fanout});return r._originalMode=t.mode??0,r}type;data;blockSizes;hashType;fanout;mtime;_mode;_originalMode;constructor(e={type:"file"}){const{type:t,data:r,blockSizes:n,hashType:o,fanout:i,mtime:s,mode:a}=e;if(null!=t&&!Object.values(Va).includes(t))throw Yi(new Error("Type: "+t+" is not valid"),"ERR_INVALID_TYPE");this.type=t??"file",this.data=r,this.hashType=o,this.fanout=i,this.blockSizes=n??[],this._originalMode=0,this.mode=a,this.mtime=s}set mode(e){this._mode=null==e?this.isDirectory()?Ga:Ha:4095&e}get mode(){return this._mode}isDirectory(){return qa.includes(this.type)}addBlockSize(e){this.blockSizes.push(e)}removeBlockSize(e){this.blockSizes.splice(e,1)}fileSize(){if(this.isDirectory())return 0n;let e=0n;return this.blockSizes.forEach((t=>{e+=t})),null!=this.data&&(e+=BigInt(this.data.length)),e}marshal(){let e;switch(this.type){case"raw":e=Ra.DataType.Raw;break;case"directory":e=Ra.DataType.Directory;break;case"file":e=Ra.DataType.File;break;case"metadata":e=Ra.DataType.Metadata;break;case"symlink":e=Ra.DataType.Symlink;break;case"hamt-sharded-directory":e=Ra.DataType.HAMTShard;break;default:throw Yi(new Error(`Type: ${e} is not valid`),"ERR_INVALID_TYPE")}let t,r,n=this.data;return null!=this.data&&0!==this.data.length||(n=void 0),null!=this.mode&&(t=4294963200&this._originalMode|(this.mode??0),t!==Ha||this.isDirectory()||(t=void 0),t===Ga&&this.isDirectory()&&(t=void 0)),null!=this.mtime&&(r={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),Ra.encode({Type:e,Data:n,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:t,mtime:r})}}var Ja=__webpack_require__(469);ve({name:"murmur3-32",code:35,encode:e=>function(e){const t=new Array(4);for(let r=0;r<4;r++)t[r]=255&e,e>>=8;return new Uint8Array(t)}(Ja.x86.hash32(e))});const Ka=ve({name:"murmur3-128",code:34,encode:e=>v(Ja.x64.hash128(e))});ve({name:"murmur3-x64-64",code:34,encode:e=>v(Ja.x64.hash128(e)).subarray(0,8)});var Qa=__webpack_require__(544);function Xa(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}const Za=N({prefix:"9",name:"base10",alphabet:"0123456789"}),Ya=L({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ec=L({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),tc=L({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),rc=Array.from("๐Ÿš€๐Ÿชโ˜„๐Ÿ›ฐ๐ŸŒŒ๐ŸŒ‘๐ŸŒ’๐ŸŒ“๐ŸŒ”๐ŸŒ•๐ŸŒ–๐ŸŒ—๐ŸŒ˜๐ŸŒ๐ŸŒ๐ŸŒŽ๐Ÿ‰โ˜€๐Ÿ’ป๐Ÿ–ฅ๐Ÿ’พ๐Ÿ’ฟ๐Ÿ˜‚โค๐Ÿ˜๐Ÿคฃ๐Ÿ˜Š๐Ÿ™๐Ÿ’•๐Ÿ˜ญ๐Ÿ˜˜๐Ÿ‘๐Ÿ˜…๐Ÿ‘๐Ÿ˜๐Ÿ”ฅ๐Ÿฅฐ๐Ÿ’”๐Ÿ’–๐Ÿ’™๐Ÿ˜ข๐Ÿค”๐Ÿ˜†๐Ÿ™„๐Ÿ’ช๐Ÿ˜‰โ˜บ๐Ÿ‘Œ๐Ÿค—๐Ÿ’œ๐Ÿ˜”๐Ÿ˜Ž๐Ÿ˜‡๐ŸŒน๐Ÿคฆ๐ŸŽ‰๐Ÿ’žโœŒโœจ๐Ÿคท๐Ÿ˜ฑ๐Ÿ˜Œ๐ŸŒธ๐Ÿ™Œ๐Ÿ˜‹๐Ÿ’—๐Ÿ’š๐Ÿ˜๐Ÿ’›๐Ÿ™‚๐Ÿ’“๐Ÿคฉ๐Ÿ˜„๐Ÿ˜€๐Ÿ–ค๐Ÿ˜ƒ๐Ÿ’ฏ๐Ÿ™ˆ๐Ÿ‘‡๐ŸŽถ๐Ÿ˜’๐Ÿคญโฃ๐Ÿ˜œ๐Ÿ’‹๐Ÿ‘€๐Ÿ˜ช๐Ÿ˜‘๐Ÿ’ฅ๐Ÿ™‹๐Ÿ˜ž๐Ÿ˜ฉ๐Ÿ˜ก๐Ÿคช๐Ÿ‘Š๐Ÿฅณ๐Ÿ˜ฅ๐Ÿคค๐Ÿ‘‰๐Ÿ’ƒ๐Ÿ˜ณโœ‹๐Ÿ˜š๐Ÿ˜๐Ÿ˜ด๐ŸŒŸ๐Ÿ˜ฌ๐Ÿ™ƒ๐Ÿ€๐ŸŒท๐Ÿ˜ป๐Ÿ˜“โญโœ…๐Ÿฅบ๐ŸŒˆ๐Ÿ˜ˆ๐Ÿค˜๐Ÿ’ฆโœ”๐Ÿ˜ฃ๐Ÿƒ๐Ÿ’โ˜น๐ŸŽŠ๐Ÿ’˜๐Ÿ˜ โ˜๐Ÿ˜•๐ŸŒบ๐ŸŽ‚๐ŸŒป๐Ÿ˜๐Ÿ–•๐Ÿ’๐Ÿ™Š๐Ÿ˜น๐Ÿ—ฃ๐Ÿ’ซ๐Ÿ’€๐Ÿ‘‘๐ŸŽต๐Ÿคž๐Ÿ˜›๐Ÿ”ด๐Ÿ˜ค๐ŸŒผ๐Ÿ˜ซโšฝ๐Ÿค™โ˜•๐Ÿ†๐Ÿคซ๐Ÿ‘ˆ๐Ÿ˜ฎ๐Ÿ™†๐Ÿป๐Ÿƒ๐Ÿถ๐Ÿ’๐Ÿ˜ฒ๐ŸŒฟ๐Ÿงก๐ŸŽโšก๐ŸŒž๐ŸŽˆโŒโœŠ๐Ÿ‘‹๐Ÿ˜ฐ๐Ÿคจ๐Ÿ˜ถ๐Ÿค๐Ÿšถ๐Ÿ’ฐ๐Ÿ“๐Ÿ’ข๐ŸคŸ๐Ÿ™๐Ÿšจ๐Ÿ’จ๐Ÿคฌโœˆ๐ŸŽ€๐Ÿบ๐Ÿค“๐Ÿ˜™๐Ÿ’Ÿ๐ŸŒฑ๐Ÿ˜–๐Ÿ‘ถ๐Ÿฅดโ–ถโžกโ“๐Ÿ’Ž๐Ÿ’ธโฌ‡๐Ÿ˜จ๐ŸŒš๐Ÿฆ‹๐Ÿ˜ท๐Ÿ•บโš ๐Ÿ™…๐Ÿ˜Ÿ๐Ÿ˜ต๐Ÿ‘Ž๐Ÿคฒ๐Ÿค ๐Ÿคง๐Ÿ“Œ๐Ÿ”ต๐Ÿ’…๐Ÿง๐Ÿพ๐Ÿ’๐Ÿ˜—๐Ÿค‘๐ŸŒŠ๐Ÿคฏ๐Ÿทโ˜Ž๐Ÿ’ง๐Ÿ˜ฏ๐Ÿ’†๐Ÿ‘†๐ŸŽค๐Ÿ™‡๐Ÿ‘โ„๐ŸŒด๐Ÿ’ฃ๐Ÿธ๐Ÿ’Œ๐Ÿ“๐Ÿฅ€๐Ÿคข๐Ÿ‘…๐Ÿ’ก๐Ÿ’ฉ๐Ÿ‘๐Ÿ“ธ๐Ÿ‘ป๐Ÿค๐Ÿคฎ๐ŸŽผ๐Ÿฅต๐Ÿšฉ๐ŸŽ๐ŸŠ๐Ÿ‘ผ๐Ÿ’๐Ÿ“ฃ๐Ÿฅ‚"),nc=rc.reduce(((e,t,r)=>(e[r]=t,e)),[]),oc=rc.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]),ic=U({prefix:"๐Ÿš€",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+nc[t]),"")},decode:function(e){const t=[];for(const r of e){const e=oc[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),sc=N({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ac=N({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),cc=L({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),uc=L({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),hc=L({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),fc=L({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),lc=L({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),dc=U({prefix:"\0",name:"identity",encode:e=>C(e),decode:e=>x(e)}),pc=new TextEncoder,wc=new TextDecoder,bc="json",yc=512,gc=e=>pc.encode(JSON.stringify(e)),mc=e=>JSON.parse(wc.decode(e)),vc=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),_c=ve({name:"sha2-256",code:18,encode:vc("SHA-256")}),kc=ve({name:"sha2-512",code:19,encode:vc("SHA-512")}),Ec={...w,...h,...p,...c,...u,...t,...l,...r,...d,...f};function xc(e=0){return null!=globalThis.Buffer?.allocUnsafe?Xa(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function Cc(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Ac=Cc("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Bc=Cc("ascii","a",(e=>{let t="a";for(let r=0;r{const t=xc((e=e.substring(1)).length);for(let r=0;rt instanceof Sc?e+t.leafCount():e+1),0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){const e=this._children.compactArray();for(const t of e)t instanceof Sc?yield*t.eachLeafSeries():yield t}serialize(e,t){return t(this._children.reduce(((r,n,o)=>(null!=n&&(n instanceof Sc?r.push(n.serialize(e,t)):r.push(e(n,o))),r)),[]))}async asyncTransform(e,t){return await Nc(this,e,t)}toJSON(){return this.serialize(Tc,Uc)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(e){const t=await this._findPlace(e),r=t.bucket._at(t.pos);if(!(r instanceof Sc))return null!=r&&r.key===e?r:void 0}async _findPlace(e){const t=this._options.hash("string"==typeof e?function(e,t="utf8"){const r=Ic[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${e}`):Xa(globalThis.Buffer.from(e,"utf-8"))}(e):e),r=await t.take(this._options.bits),n=this._children.get(r);return n instanceof Sc?await n._findPlace(t):{bucket:this,pos:r,hash:t,existingChild:n}}async _findNewBucketAndPos(e){const t=await this._findPlace(e);if(null!=t.existingChild&&t.existingChild.key!==e){const e=new Sc(this._options,t.bucket,t.pos);t.bucket._putObjectAt(t.pos,e);const r=await e._findPlace(t.existingChild.hash);return r.bucket._putAt(r,t.existingChild.key,t.existingChild.value),await e._findNewBucketAndPos(t.hash)}return t}_putAt(e,t,r){this._putObjectAt(e.pos,{key:t,value:r,hash:e.hash})}_putObjectAt(e,t){null==this._children.get(e)&&this._popCount++,this._children.set(e,t)}_delAt(e){if(-1===e)throw new Error("Invalid position");null!=this._children.get(e)&&this._popCount--,this._children.unset(e),this._level()}_level(){if(null!=this._parent&&this._popCount<=1)if(1===this._popCount){const e=this._children.find(Dc);if(null!=e&&!(e instanceof Sc)){const t=e.hash;t.untake(this._options.bits);const r={pos:this._posAtParent,hash:t,bucket:this._parent};this._parent._putAt(r,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}}function Dc(e){return Boolean(e)}function Tc(e,t){return e.key}function Uc(e){return e}async function Nc(e,t,r){const n=[];for(const o of e._children.compactArray())if(o instanceof Sc)await Nc(o,t,r);else{const r=await t(o);n.push({bitField:e._children.bitField(),children:r})}return await r(n)}const Lc=[255,254,252,248,240,224,192,128],Pc=[1,3,7,15,31,63,127,255];class Oc{constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+8*this._currentBytePos}totalBits(){return 8*this._value.length}take(e){let t=e,r=0;for(;t>0&&this._haveBits();){const e=this._value[this._currentBytePos],n=this._currentBitPos+1,o=Math.min(n,t);r=(r<7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}}function zc(e,t,r){const n=function(e,t){return Lc[e]&Pc[Math.min(t+e-1,7)]}(t,r);return(e&n)>>>t}function Rc(e){return function(t){return t instanceof Mc?t:new Mc(t,e)}}class Mc{constructor(e,t){if(!(e instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=e,this._hashFn=t,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let t=e;for(;this._availableBits0;){const e=this._buffers[this._currentBufferIndex],n=Math.min(e.availableBits(),t);r=(r<0;){const e=this._buffers[this._currentBufferIndex],r=Math.min(e.totalBits()-e.availableBits(),t);e.untake(r),t-=r,this._availableBits+=r,this._currentBufferIndex>0&&e.totalBits()===e.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;const e=this._depth>0?function(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=xc(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return Xa(r)}([this._value,Uint8Array.from([this._depth])]):this._value,t=await this._hashFn(e),r=new Oc(t);this._buffers.push(r),this._availableBits+=r.availableBits()}}const jc=async function(e){return(await Ka.encode(e)).slice(0,8).reverse()},$c=(e,t)=>e.toString(16).toUpperCase().padStart(t,"0").substring(0,t),Fc=async(e,t,r,n,o)=>{if(null==n){if(null==e.Data)throw Yi(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");let t;try{t=Wa.unmarshal(e.Data)}catch(e){throw Yi(e,"ERR_NOT_UNIXFS")}if("hamt-sharded-directory"!==t.type)throw Yi(new Error("not a HAMT"),"ERR_NOT_UNIXFS");if(null==t.fanout)throw Yi(new Error("missing fanout"),"ERR_NOT_UNIXFS");const r=function(e){if(null==e||null==e.hashFn)throw new Error("please define an options.hashFn");const t={bits:e.bits??8,hash:Rc(e.hashFn)};return new Sc(t)}({hashFn:jc,bits:Math.log2(Number(t.fanout))});n={rootBucket:r,hamtDepth:1,lastBucket:r}}const i=(n.lastBucket.tableSize()-1).toString(16).length;await(async(e,t,r)=>{const n=(t.tableSize()-1).toString(16).length;await Promise.all(e.map((async e=>{if(null==e.Name)throw new Error("Unexpected Link without a Name");if(e.Name.length!==n)await r.put(e.Name.substring(2),!0);else{const n=parseInt(e.Name,16);t._putObjectAt(n,new Sc({hash:r._options.hash,bits:r._options.bits},t,n))}})))})(e.Links,n.lastBucket,n.rootBucket);const s=await n.rootBucket._findNewBucketAndPos(t);let a=$c(s.pos,i);const c=(e=>{let t=e.bucket;const r=[];for(;null!=t._parent;)r.push(t),t=t._parent;return r.push(t),r.reverse()})(s);c.length>n.hamtDepth&&(n.lastBucket=c[n.hamtDepth],a=$c(n.lastBucket._posAtParent,i));const u=e.Links.find((e=>{if(null==e.Name)return!1;const r=e.Name.substring(0,i),n=e.Name.substring(i);return r===a&&(""===n||n===t)}));if(null!=u)return null!=u.Name&&u.Name.substring(i)===t?u.Hash:(n.hamtDepth++,e=ma(await r.get(u.Hash,o)),Fc(e,t,r,n,o))},Vc=Fc,qc=function(e){const[t,r]=null!=e[Symbol.asyncIterator]?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:e=>{n.push(e)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}},Hc=function(e,t){if(null!=e[Symbol.asyncIterator])return async function*(){for await(const r of e)yield t(r)}();const r=qc(e),{value:n,done:o}=r.next();if(!0===o)return function*(){}();const i=t(n);if("function"==typeof i.then)return async function*(){yield await i;for await(const e of r)yield t(e)}();const s=t;return function*(){yield i;for(const e of r)yield s(e)}()};function Gc(){const e={};return e.promise=new Promise(((t,r)=>{e.resolve=t,e.reject=r})),e}const Wc=globalThis.CustomEvent??Event;async function*Jc(e,t={}){let r=t.concurrency??1/0;r<1&&(r=1/0);const n=null!=t.ordered&&t.ordered,o=new EventTarget,i=[];let s,a=Gc(),c=Gc(),u=!1,h=!1;function f(){return n?i[0]?.done:Boolean(i.find((e=>e.done)))}function*l(){for(;i.length>0&&i[0].done;){const e=i[0];if(i.shift(),!e.ok)throw h=!0,a.resolve(),e.err;yield e.value,a.resolve()}}function*d(){for(;f();)for(let e=0;e{c.resolve()})),Promise.resolve().then((async()=>{try{for await(const t of e){if(i.length===r&&(a=Gc(),await a.promise),h)break;const e={done:!1};i.push(e),t().then((t=>{e.done=!0,e.ok=!0,e.value=t,o.dispatchEvent(new Wc("task-complete"))}),(t=>{e.done=!0,e.err=t,o.dispatchEvent(new Wc("task-complete"))}))}u=!0,o.dispatchEvent(new Wc("task-complete"))}catch(e){s=e,o.dispatchEvent(new Wc("task-complete"))}}));;){if(f()||(c=Gc(),await c.promise),null!=s)throw s;if(n?yield*l():yield*d(),u&&0===i.length)break}}class Kc{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||0!=(e-1&e))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return void 0===this.buffer[this.btm]}}class Qc{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Kc(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return null!=e?.byteLength?e.byteLength:1}push(e){if(null!=e?.value&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){const t=this.head;this.head=t.next=new Kc(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(void 0===e&&null!=this.tail.next){const t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return null!=e?.value&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}}class Xc extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}}function Zc(e={}){return function(e,t){let r,n,o,i=(t=t??{}).onEnd,s=new Qc,a=Gc();const c=e=>null!=n?n(e):(s.push(e),r),u=e=>{if(o)return r;if(!0!==t?.objectMode&&null==e?.byteLength)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return c({done:!1,value:e})},h=e=>o?r:(o=!0,null!=e?(e=>(s=new Qc,null!=n?n({error:e}):(s.push({error:e}),r)))(e):c({done:!0}));if(r={[Symbol.asyncIterator](){return this},next:async()=>{try{return s.isEmpty()?o?{done:!0}:await new Promise(((t,o)=>{n=i=>{n=null,s.push(i);try{t(e(s))}catch(e){o(e)}return r}})):e(s)}finally{s.isEmpty()&&queueMicrotask((()=>{a.resolve(),a=Gc()}))}},return:()=>(s=new Qc,h(),{done:!0}),throw:e=>(h(e),{done:!0}),push:u,end:h,get readableLength(){return s.size},onEmpty:async e=>{const t=e?.signal;if(t?.throwIfAborted(),s.isEmpty())return;let r,n;null!=t&&(r=new Promise(((e,r)=>{n=()=>{r(new Xc)},t.addEventListener("abort",n)})));try{await Promise.race([a.promise,r])}finally{null!=n&&null!=t&&t?.removeEventListener("abort",n)}}},null==i)return r;const f=r;return r={[Symbol.asyncIterator](){return this},next:()=>f.next(),throw:e=>(f.throw(e),null!=i&&(i(e),i=void 0),{done:!0}),return:()=>(f.return(),null!=i&&(i(),i=void 0),{done:!0}),push:u,end:e=>(f.end(e),null!=i&&(i(e),i=void 0),r),get readableLength(){return f.readableLength}},r}((e=>{const t=e.shift();if(null==t)return{done:!0};if(null!=t.error)throw t.error;return{done:!0===t.done,value:t.value}}),e)}function Yc(e,...t){if(null==e)throw new Error("Empty pipeline");if(nu(e)){const t=e;e=()=>t.source}else if(ru(e)||tu(e)){const t=e;e=()=>t}const r=[e,...t];if(r.length>1&&nu(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let e=1;e{let t;for(;e.length>0;)t=e.shift()(t);return t},tu=e=>null!=e?.[Symbol.asyncIterator],ru=e=>null!=e?.[Symbol.iterator],nu=e=>null!=e&&null!=e.sink&&null!=e.source,ou=e=>t=>{const r=e.sink(t);if(null!=r?.then){const t=Zc({objectMode:!0});let n;r.then((()=>{t.end()}),(e=>{t.end(e)}));const o=e.source;if(tu(o))n=async function*(){yield*o,t.end()};else{if(!ru(o))throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");n=function*(){yield*o,t.end()}}return function(...e){const t=[];for(const r of e)null==r[Symbol.asyncIterator]&&t.push(r);return t.length===e.length?function*(){for(const e of t)yield*e}():async function*(){const t=Zc({objectMode:!0});Promise.resolve().then((async()=>{try{await Promise.all(e.map((async e=>{for await(const r of e)t.push(r)}))),t.end()}catch(e){t.end(e)}})),yield*t}()}(t,n())}return e.source};var iu=__webpack_require__(729);class su extends Error{constructor(e){super(e),this.name="TimeoutError"}}class au extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const cu=e=>void 0===globalThis.DOMException?new au(e):new DOMException(e),uu=e=>{const t=void 0===e.reason?cu("This operation was aborted."):e.reason;return t instanceof Error?t:cu(t)};var hu,fu=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};class lu{constructor(){hu.set(this,[])}enqueue(e,t){const r={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&fu(this,hu,"f")[this.size-1].priority>=t.priority)return void fu(this,hu,"f").push(r);const n=function(e,t,r){let n=0,o=e.length;for(;o>0;){const r=Math.trunc(o/2);let s=n+r;i=e[s],t.priority-i.priority<=0?(n=++s,o-=r+1):o=r}var i;return n}(fu(this,hu,"f"),r);fu(this,hu,"f").splice(n,0,r)}dequeue(){const e=fu(this,hu,"f").shift();return null==e?void 0:e.run}filter(e){return fu(this,hu,"f").filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return fu(this,hu,"f").length}}hu=new WeakMap;var du,pu,wu,bu,yu,gu,mu,vu,_u,ku,Eu,xu,Cu,Au,Bu,Iu,Su,Du,Tu,Uu,Nu,Lu,Pu,Ou,zu,Ru,Mu=function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},ju=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};class $u extends Error{}class Fu extends iu{constructor(e){var t,r,n,o;if(super(),du.add(this),pu.set(this,void 0),wu.set(this,void 0),bu.set(this,0),yu.set(this,void 0),gu.set(this,void 0),mu.set(this,0),vu.set(this,void 0),_u.set(this,void 0),ku.set(this,void 0),Eu.set(this,void 0),xu.set(this,0),Cu.set(this,void 0),Au.set(this,void 0),Bu.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:lu,...e}).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(r=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==r?r:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(o=null===(n=e.interval)||void 0===n?void 0:n.toString())&&void 0!==o?o:""}\` (${typeof e.interval})`);Mu(this,pu,e.carryoverConcurrencyCount,"f"),Mu(this,wu,e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,"f"),Mu(this,yu,e.intervalCap,"f"),Mu(this,gu,e.interval,"f"),Mu(this,ku,new e.queueClass,"f"),Mu(this,Eu,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Mu(this,Bu,!0===e.throwOnTimeout,"f"),Mu(this,Au,!1===e.autoStart,"f")}get concurrency(){return ju(this,Cu,"f")}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);Mu(this,Cu,e,"f"),ju(this,du,"m",Ou).call(this)}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:ju(this,Bu,"f"),...t},new Promise(((r,n)=>{ju(this,ku,"f").enqueue((async()=>{var o,i,s;Mu(this,xu,(i=ju(this,xu,"f"),++i),"f"),Mu(this,bu,(s=ju(this,bu,"f"),++s),"f");try{if(null===(o=t.signal)||void 0===o?void 0:o.aborted)throw new $u("The task was aborted.");let n=e({signal:t.signal});t.timeout&&(n=function(e,t,r,n){let o;const i=new Promise(((i,s)=>{if("number"!=typeof t||1!==Math.sign(t))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t!==Number.POSITIVE_INFINITY){if((n={customTimers:{setTimeout,clearTimeout},...n}).signal){const{signal:e}=n;e.aborted&&s(uu(e)),e.addEventListener("abort",(()=>{s(uu(e))}))}o=n.customTimers.setTimeout.call(void 0,(()=>{const n=r instanceof Error?r:new su(`Promise timed out after ${t} milliseconds`);"function"==typeof e.cancel&&e.cancel(),s(n)}),t),(async()=>{try{i(await e)}catch(e){s(e)}finally{n.customTimers.clearTimeout.call(void 0,o)}})()}else i(e)}));return i.clear=()=>{clearTimeout(o),o=void 0},i}(Promise.resolve(n),t.timeout)),t.signal&&(n=Promise.race([n,ju(this,du,"m",zu).call(this,t.signal)]));const i=await n;r(i),this.emit("completed",i)}catch(e){if(e instanceof su&&!t.throwOnTimeout)return void r();n(e),this.emit("error",e)}finally{ju(this,du,"m",Du).call(this)}}),t),this.emit("add"),ju(this,du,"m",Nu).call(this)}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return ju(this,Au,"f")?(Mu(this,Au,!1,"f"),ju(this,du,"m",Ou).call(this),this):this}pause(){Mu(this,Au,!0,"f")}clear(){Mu(this,ku,new(ju(this,Eu,"f")),"f")}async onEmpty(){0!==ju(this,ku,"f").size&&await ju(this,du,"m",Ru).call(this,"empty")}async onSizeLessThan(e){ju(this,ku,"f").sizeju(this,ku,"f").size=s&&o=s&&i<=h||oh)&&c.push({link:r,blockStart:n}),r.Hash.code!==_a&&(await u(c),c=[]),(n=h)>i)break}async function u(t){await Yc(t,(t=>Hc(t,(t=>async()=>{const r=await e.get(t.link.Hash,s);return{...t,block:r}}))),(e=>Jc(e,{ordered:!0})),(async t=>{for await(const{link:n,block:a,blockStart:c}of t){let t;switch(n.Hash.code){case 112:t=ma(a);break;case _a:t=a;break;default:return void r.end(Yi(new Error(`Unsupported codec: ${n.Hash.code}`),"ERR_NOT_UNIXFS"))}const u=new Fu({concurrency:1});u.on("error",(e=>{r.end(e)})),u.add((async()=>{s.onProgress?.(new Aa("unixfs:exporter:walk:file",{cid:n.Hash})),await Vu(e,t,r,c,o,i,s)})),await u.onIdle()}}))}c.length&&await u(c),n>=i&&r.end()}pu=new WeakMap,wu=new WeakMap,bu=new WeakMap,yu=new WeakMap,gu=new WeakMap,mu=new WeakMap,vu=new WeakMap,_u=new WeakMap,ku=new WeakMap,Eu=new WeakMap,xu=new WeakMap,Cu=new WeakMap,Au=new WeakMap,Bu=new WeakMap,du=new WeakSet,Iu=function(){return ju(this,wu,"f")||ju(this,bu,"f"){ju(this,du,"m",Tu).call(this)}),t),"f"),!0;Mu(this,bu,ju(this,pu,"f")?ju(this,xu,"f"):0,"f")}return!1},Nu=function(){if(0===ju(this,ku,"f").size)return ju(this,vu,"f")&&clearInterval(ju(this,vu,"f")),Mu(this,vu,void 0,"f"),this.emit("empty"),0===ju(this,xu,"f")&&this.emit("idle"),!1;if(!ju(this,Au,"f")){const e=!ju(this,du,"a",Uu);if(ju(this,du,"a",Iu)&&ju(this,du,"a",Su)){const t=ju(this,ku,"f").dequeue();return!!t&&(this.emit("active"),t(),e&&ju(this,du,"m",Lu).call(this),!0)}}return!1},Lu=function(){ju(this,wu,"f")||void 0!==ju(this,vu,"f")||(Mu(this,vu,setInterval((()=>{ju(this,du,"m",Pu).call(this)}),ju(this,gu,"f")),"f"),Mu(this,mu,Date.now()+ju(this,gu,"f"),"f"))},Pu=function(){0===ju(this,bu,"f")&&0===ju(this,xu,"f")&&ju(this,vu,"f")&&(clearInterval(ju(this,vu,"f")),Mu(this,vu,void 0,"f")),Mu(this,bu,ju(this,pu,"f")?ju(this,xu,"f"):0,"f"),ju(this,du,"m",Ou).call(this)},Ou=function(){for(;ju(this,du,"m",Nu).call(this););},zu=async function(e){return new Promise(((t,r)=>{e.addEventListener("abort",(()=>{r(new $u("The task was aborted."))}),{once:!0})}))},Ru=async function(e,t){return new Promise((r=>{const n=()=>{t&&!t()||(this.off(e,n),r())};this.on(e,n)}))};const qu=(e,t,r,n,o,i,s)=>async function*(n={}){const o=r.fileSize();if(void 0===o)throw new Error("File was a directory");const{start:i,end:a}=Ia(o,n.offset,n.length);if(0n===a)return;let c=0n;const u=a-i,h=Zc();n.onProgress?.(new Aa("unixfs:exporter:walk:file",{cid:e})),Vu(s,t,h,0n,i,a,n).catch((e=>{h.end(e)}));for await(const e of h)if(null!=e){if(c+=BigInt(e.byteLength),c>u)throw h.end(),Yi(new Error("Read too many bytes - the file size reported by the UnixFS data in the root node may be incorrect"),"ERR_OVER_READ");c===u&&h.end(),n.onProgress?.(new Aa("unixfs:exporter:progress:unixfs:file",{bytesRead:c,totalBytes:u,fileSize:o})),yield e}if(cHc(s,(s=>async()=>{const a=null!=s.Name?s.Name.substring(c):null;if(null!=a&&""!==a){const e=await r(s.Hash,a,`${t}/${a}`,[],n+1,o,i);return{entries:null==e.entry?[]:[e.entry]}}{const a=await o.get(s.Hash,i);return e=ma(a),i.onProgress?.(new Aa("unixfs:exporter:walk:hamt-sharded-directory",{cid:s.Hash})),{entries:Hu(e,t,r,n,o,i)}}}))),(e=>Jc(e,{ordered:!0,concurrency:1})));for await(const{entries:e}of u)yield*e}const Gu={raw:qu,file:qu,directory:(e,t,r,n,o,i,s)=>async function*(r={}){const a=r.offset??0,c=r.length??t.Links.length,u=t.Links.slice(a,c);r.onProgress?.(new Aa("unixfs:exporter:walk:directory",{cid:e})),yield*Yc(u,(e=>Hc(e,(e=>async()=>{const t=e.Name??"",a=`${n}/${t}`;return(await o(e.Hash,t,a,[],i+1,s,r)).entry}))),(e=>Jc(e,{ordered:!0,concurrency:1})),(e=>function(e,t){if(null!=e[Symbol.asyncIterator])return async function*(){for await(const r of e)await t(r)&&(yield r)}();const r=qc(e),{value:n,done:o}=r.next();if(!0===o)return function*(){}();const i=t(n);if("function"==typeof i.then)return async function*(){await i&&(yield n);for await(const e of r)await t(e)&&(yield e)}();const s=t;return function*(){!0===i&&(yield n);for(const e of r)s(e)&&(yield e)}()}(e,(e=>null!=e))))},"hamt-sharded-directory":(e,t,r,n,o,i,s)=>function(r={}){return r.onProgress?.(new Aa("unixfs:exporter:walk:hamt-sharded-directory",{cid:e})),Hu(t,n,o,i,s,r)},metadata:(e,t,r,n,o,i,s)=>()=>[],symlink:(e,t,r,n,o,i,s)=>()=>[]},Wu={112:async(e,t,r,n,o,i,s,a)=>{const c=ma(await s.get(e,a));let u,h;if(null==t&&(t=e.toString()),null==c.Data)throw Yi(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");try{u=Wa.unmarshal(c.Data)}catch(e){throw Yi(e,"ERR_NOT_UNIXFS")}if(null==r&&(r=t),n.length>0){let e;if(e="hamt-sharded-directory"===u?.type?await Vc(c,n[0],s):((e,t)=>e.Links.find((e=>e.Name===t))?.Hash)(c,n[0]),null==e)throw Yi(new Error("file does not exist"),"ERR_NOT_FOUND");const t=n.shift();h={cid:e,toResolve:n,name:t??"",path:`${r}/${t}`}}const f=Gu[u.type](e,c,u,r,o,i,s);if(null==f)throw Yi(new Error("could not find content exporter"),"ERR_NOT_FOUND");return u.isDirectory()?{entry:{type:"directory",name:t,path:r,cid:e,content:f,unixfs:u,depth:i,node:c,size:u.fileSize()},next:h}:{entry:{type:"file",name:t,path:r,cid:e,content:f,unixfs:u,depth:i,node:c,size:u.fileSize()},next:h}},[_a]:async(e,t,r,n,o,i,s,a)=>{if(n.length>0)throw Yi(new Error(`No link named ${r} found in raw node ${e}`),"ERR_NOT_FOUND");const c=await s.get(e,a);return{entry:{type:"raw",name:t,path:r,cid:e,content:(u=c,async function*(e={}){const{start:t,end:r}=Ia(u.length,e.offset,e.length),n=Ba(u,0n,t,r);e.onProgress?.(new Aa("unixfs:exporter:progress:raw",{bytesRead:BigInt(n.byteLength),totalBytes:r-t,fileSize:BigInt(u.byteLength)})),yield n}),depth:i,size:BigInt(c.length),node:c}};var u},113:async(e,t,r,n,o,i,s,a)=>{const c=await s.get(e,a),u=da(c);let h=u,f=r;for(;n.length>0;){const o=n[0];if(!(o in h))throw Yi(new Error(`No property named ${o} found in cbor node ${e}`),"ERR_NO_PROP");{n.shift(),f=`${f}/${o}`;const s=le.asCID(h[o]);if(null!=s)return{entry:{type:"object",name:t,path:r,cid:e,node:c,depth:i,size:BigInt(c.length),content:async function*(){yield u}},next:{cid:s,name:o,path:f,toResolve:n}};h=h[o]}}return{entry:{type:"object",name:t,path:r,cid:e,node:c,depth:i,size:BigInt(c.length),content:async function*(){yield u}}}},[Ca.code]:async(e,t,r,n,o,i,s,a)=>{if(n.length>0)throw Yi(new Error(`No link named ${r} found in raw node ${e}`),"ERR_NOT_FOUND");const c=ae(e.multihash.bytes);return{entry:{type:"identity",name:t,path:r,cid:e,content:(u=c.digest,async function*(e={}){const{start:t,end:r}=Ia(u.length,e.offset,e.length),n=Ba(u,0n,t,r);e.onProgress?.(new Aa("unixfs:exporter:progress:identity",{bytesRead:BigInt(n.byteLength),totalBytes:r-t,fileSize:BigInt(u.byteLength)})),yield n}),depth:i,size:BigInt(c.digest.length),node:c.digest}};var u}},Ju=async(e,t,r,n,o,i,s)=>{const a=Wu[e.code];if(null==a)throw Yi(new Error(`No resolver for code ${e.code}`),"ERR_NO_RESOLVER");return a(e,t,r,n,Ju,o,i,s)},Ku=Ju;async function Qu(e,t,r={}){const n=await function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{let t;for await(const r of e)t=r;return t})();let t;for(const r of e)t=r;return t}(async function*(e,t,r={}){let{cid:n,toResolve:o}=(e=>{if(e instanceof Uint8Array)return{cid:le.decode(e),toResolve:[]};const t=le.asCID(e);if(null!=t)return{cid:t,toResolve:[]};if("string"==typeof e){0===e.indexOf("/ipfs/")&&(e=e.substring(6));const t=((e="")=>(e.trim().match(/([^\\^/]|\\\/)+/g)??[]).filter(Boolean))(e);return{cid:le.parse(t[0]),toResolve:t.slice(1)}}throw Yi(new Error(`Unknown path type ${e}`),"ERR_BAD_PATH")})(e),i=n.toString(),s=i;const a=o.length;for(;;){const c=await Ku(n,i,s,o,a,t,r);if(null==c.entry&&null==c.next)throw Yi(new Error(`Could not resolve ${e}`),"ERR_NOT_FOUND");if(null!=c.entry&&(yield c.entry),null==c.next)return;o=c.next.toResolve,n=c.next.cid,i=c.next.name,s=c.next.path}}(e,t,r));if(null==n)throw Yi(new Error(`Could not resolve ${e}`),"ERR_NOT_FOUND");return n}var Xu=__webpack_require__(191);new Uint8Array(0);const Zu=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)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")};var Yu=Math.pow(2,31),eh=Math.pow(2,7),th=Math.pow(2,14),rh=Math.pow(2,21),nh=Math.pow(2,28),oh=Math.pow(2,35),ih=Math.pow(2,42),sh=Math.pow(2,49),ah=Math.pow(2,56),ch=Math.pow(2,63);const uh=function e(t,r,n){r=r||[];for(var o=n=n||0;t>=Yu;)r[n++]=255&t|128,t/=128;for(;-128&t;)r[n++]=255&t|128,t>>>=7;return r[n]=0|t,e.bytes=n-o+1,r},hh=function(e){return e(uh(e,t,r),t),lh=e=>hh(e),dh=(e,t)=>{const r=t.byteLength,n=lh(e),o=n+lh(r),i=new Uint8Array(o+r);return fh(e,i,0),fh(r,i,n),i.set(t,o),new ph(e,r,t,i)};class ph{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const wh=({name:e,code:t,encode:r})=>new bh(e,t,r);class bh{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?dh(this.code,t):t.then((e=>dh(this.code,e)))}throw Error("Unknown type, must be binary type")}}const yh=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,s=new Uint8Array(i);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var f=0,l=i-1;(0!==h||f>>0,s[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=f,t++}if(" "!==e[t]){for(var d=i-o;d!==i&&0===s[d];)d++;for(var p=new Uint8Array(n+(i-d)),w=n;d!==i;)p[w++]=s[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var s=(i-o)*h+1>>>0,u=new Uint8Array(s);o!==i;){for(var f=t[o],l=0,d=s-1;(0!==f||l>>0,u[d]=f%a>>>0,f=f/a>>>0;if(0!==f)throw new Error("Non-zero carry");n=l,o++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var w=c.repeat(r);pnew vh({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class kh{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new gh(e,t,r),this.decoder=new mh(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Eh=({name:e,prefix:t,encode:r,decode:n})=>new kh(e,t,r,n),xh=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:o}=yh(r,t);return Eh({prefix:e,name:t,encode:n,decode:e=>Zu(o(e))})},Ch=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>Eh({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],o=(1<r;)s-=r,i+=t[o&a>>s];if(s&&(i+=t[o&a<((e,t,r,n)=>{const o={};for(let e=0;e=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(t,n,r,e)});xh({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),xh({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Ch({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ch({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ch({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ch({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ch({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ch({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ch({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ch({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ch({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});class Ah{constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:node_modules_multiformats_esm_src_cid_hidden,byteLength:node_modules_multiformats_esm_src_cid_hidden,code:multiformats_esm_src_cid_readonly,version:multiformats_esm_src_cid_readonly,multihash:multiformats_esm_src_cid_readonly,bytes:multiformats_esm_src_cid_readonly,_baseCache:node_modules_multiformats_esm_src_cid_hidden,asCID:node_modules_multiformats_esm_src_cid_hidden})}toV0(){if(0===this.version)return this;{const{code:e,multihash:t}=this;if(e!==node_modules_multiformats_esm_src_cid_DAG_PB_CODE)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==node_modules_multiformats_esm_src_cid_SHA_256_CODE)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return Ah.createV0(t)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=Digest.create(e,t);return Ah.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&Digest.equals(this.multihash,e.multihash)}toString(e){const{bytes:t,version:r,_baseCache:n}=this;return 0===r?node_modules_multiformats_esm_src_cid_toStringV0(t,n,e||base58btc.encoder):node_modules_multiformats_esm_src_cid_toStringV1(t,n,e||base32.encoder)}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return multiformats_esm_src_cid_deprecate(/^0\.0/,multiformats_esm_src_cid_IS_CID_DEPRECATION),!(!e||!e[node_modules_multiformats_esm_src_cid_cidSymbol]&&e.asCID!==e)}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof Ah)return e;if(null!=e&&e.asCID===e){const{version:t,code:r,multihash:n,bytes:o}=e;return new Ah(t,r,n,o||node_modules_multiformats_esm_src_cid_encodeCID(t,r,n.bytes))}if(null!=e&&!0===e[node_modules_multiformats_esm_src_cid_cidSymbol]){const{version:t,multihash:r,code:n}=e,o=Digest.decode(r);return Ah.create(t,n,o)}return null}static create(e,t,r){if("number"!=typeof t)throw new Error("String codecs are no longer supported");switch(e){case 0:if(t!==node_modules_multiformats_esm_src_cid_DAG_PB_CODE)throw new Error(`Version 0 CID must use dag-pb (code: ${node_modules_multiformats_esm_src_cid_DAG_PB_CODE}) block encoding`);return new Ah(e,t,r,r.bytes);case 1:{const n=node_modules_multiformats_esm_src_cid_encodeCID(e,t,r.bytes);return new Ah(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return Ah.create(0,node_modules_multiformats_esm_src_cid_DAG_PB_CODE,e)}static createV1(e,t){return Ah.create(1,e,t)}static decode(e){const[t,r]=Ah.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=Ah.inspectBytes(e),r=t.size-t.multihashSize,n=coerce(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const o=n.subarray(t.multihashSize-t.digestSize),i=new Digest.Digest(t.multihashCode,t.digestSize,o,n);return[0===t.version?Ah.createV0(i):Ah.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){const t=()=>{const[t,r]=varint.decode(e.subarray(0));return t};let r=t(),n=node_modules_multiformats_esm_src_cid_DAG_PB_CODE;if(18===r||1===r&&t(),0!==r&&1!==r)throw new RangeError(`Invalid CID version ${r}`);const o=t(),i=t(),s=0+i;return{version:r,codec:n,multihashCode:o,digestSize:i,multihashSize:s-0,size:s}}static parse(e,t){const[r,n]=node_modules_multiformats_esm_src_cid_parseCIDtoBytes(e,t),o=Ah.decode(n);return o._baseCache.set(r,e),o}}Symbol.for("@ipld/js-cid/CID");const{blake2b:Bh}=Xu,Ih=(wh({name:"blake2b-8",code:45569,encode:e=>Zu(Bh(e,void 0,1))}),wh({name:"blake2b-16",code:45570,encode:e=>Zu(Bh(e,void 0,2))}),wh({name:"blake2b-24",code:45571,encode:e=>Zu(Bh(e,void 0,3))}),wh({name:"blake2b-32",code:45572,encode:e=>Zu(Bh(e,void 0,4))}),wh({name:"blake2b-40",code:45573,encode:e=>Zu(Bh(e,void 0,5))}),wh({name:"blake2b-48",code:45574,encode:e=>Zu(Bh(e,void 0,6))}),wh({name:"blake2b-56",code:45575,encode:e=>Zu(Bh(e,void 0,7))}),wh({name:"blake2b-64",code:45576,encode:e=>Zu(Bh(e,void 0,8))}),wh({name:"blake2b-72",code:45577,encode:e=>Zu(Bh(e,void 0,9))}),wh({name:"blake2b-80",code:45578,encode:e=>Zu(Bh(e,void 0,10))}),wh({name:"blake2b-88",code:45579,encode:e=>Zu(Bh(e,void 0,11))}),wh({name:"blake2b-96",code:45580,encode:e=>Zu(Bh(e,void 0,12))}),wh({name:"blake2b-104",code:45581,encode:e=>Zu(Bh(e,void 0,13))}),wh({name:"blake2b-112",code:45582,encode:e=>Zu(Bh(e,void 0,14))}),wh({name:"blake2b-120",code:45583,encode:e=>Zu(Bh(e,void 0,15))}),wh({name:"blake2b-128",code:45584,encode:e=>Zu(Bh(e,void 0,16))}),wh({name:"blake2b-136",code:45585,encode:e=>Zu(Bh(e,void 0,17))}),wh({name:"blake2b-144",code:45586,encode:e=>Zu(Bh(e,void 0,18))}),wh({name:"blake2b-152",code:45587,encode:e=>Zu(Bh(e,void 0,19))}),wh({name:"blake2b-160",code:45588,encode:e=>Zu(Bh(e,void 0,20))}),wh({name:"blake2b-168",code:45589,encode:e=>Zu(Bh(e,void 0,21))}),wh({name:"blake2b-176",code:45590,encode:e=>Zu(Bh(e,void 0,22))}),wh({name:"blake2b-184",code:45591,encode:e=>Zu(Bh(e,void 0,23))}),wh({name:"blake2b-192",code:45592,encode:e=>Zu(Bh(e,void 0,24))}),wh({name:"blake2b-200",code:45593,encode:e=>Zu(Bh(e,void 0,25))}),wh({name:"blake2b-208",code:45594,encode:e=>Zu(Bh(e,void 0,26))}),wh({name:"blake2b-216",code:45595,encode:e=>Zu(Bh(e,void 0,27))}),wh({name:"blake2b-224",code:45596,encode:e=>Zu(Bh(e,void 0,28))}),wh({name:"blake2b-232",code:45597,encode:e=>Zu(Bh(e,void 0,29))}),wh({name:"blake2b-240",code:45598,encode:e=>Zu(Bh(e,void 0,30))}),wh({name:"blake2b-248",code:45599,encode:e=>Zu(Bh(e,void 0,31))}),wh({name:"blake2b-256",code:45600,encode:e=>Zu(Bh(e,void 0,32))}));function Sh(e){return Symbol.asyncIterator in e?e:async function*(e,t={}){const r=e.getReader();try{for(;;){const e=await r.read();if(e.done)return;yield e.value}}finally{!0!==t.preventCancel&&await r.cancel(),r.releaseLock()}}(e)}wh({name:"blake2b-264",code:45601,encode:e=>Zu(Bh(e,void 0,33))}),wh({name:"blake2b-272",code:45602,encode:e=>Zu(Bh(e,void 0,34))}),wh({name:"blake2b-280",code:45603,encode:e=>Zu(Bh(e,void 0,35))}),wh({name:"blake2b-288",code:45604,encode:e=>Zu(Bh(e,void 0,36))}),wh({name:"blake2b-296",code:45605,encode:e=>Zu(Bh(e,void 0,37))}),wh({name:"blake2b-304",code:45606,encode:e=>Zu(Bh(e,void 0,38))}),wh({name:"blake2b-312",code:45607,encode:e=>Zu(Bh(e,void 0,39))}),wh({name:"blake2b-320",code:45608,encode:e=>Zu(Bh(e,void 0,40))}),wh({name:"blake2b-328",code:45609,encode:e=>Zu(Bh(e,void 0,41))}),wh({name:"blake2b-336",code:45610,encode:e=>Zu(Bh(e,void 0,42))}),wh({name:"blake2b-344",code:45611,encode:e=>Zu(Bh(e,void 0,43))}),wh({name:"blake2b-352",code:45612,encode:e=>Zu(Bh(e,void 0,44))}),wh({name:"blake2b-360",code:45613,encode:e=>Zu(Bh(e,void 0,45))}),wh({name:"blake2b-368",code:45614,encode:e=>Zu(Bh(e,void 0,46))}),wh({name:"blake2b-376",code:45615,encode:e=>Zu(Bh(e,void 0,47))}),wh({name:"blake2b-384",code:45616,encode:e=>Zu(Bh(e,void 0,48))}),wh({name:"blake2b-392",code:45617,encode:e=>Zu(Bh(e,void 0,49))}),wh({name:"blake2b-400",code:45618,encode:e=>Zu(Bh(e,void 0,50))}),wh({name:"blake2b-408",code:45619,encode:e=>Zu(Bh(e,void 0,51))}),wh({name:"blake2b-416",code:45620,encode:e=>Zu(Bh(e,void 0,52))}),wh({name:"blake2b-424",code:45621,encode:e=>Zu(Bh(e,void 0,53))}),wh({name:"blake2b-432",code:45622,encode:e=>Zu(Bh(e,void 0,54))}),wh({name:"blake2b-440",code:45623,encode:e=>Zu(Bh(e,void 0,55))}),wh({name:"blake2b-448",code:45624,encode:e=>Zu(Bh(e,void 0,56))}),wh({name:"blake2b-456",code:45625,encode:e=>Zu(Bh(e,void 0,57))}),wh({name:"blake2b-464",code:45626,encode:e=>Zu(Bh(e,void 0,58))}),wh({name:"blake2b-472",code:45627,encode:e=>Zu(Bh(e,void 0,59))}),wh({name:"blake2b-480",code:45628,encode:e=>Zu(Bh(e,void 0,60))}),wh({name:"blake2b-488",code:45629,encode:e=>Zu(Bh(e,void 0,61))}),wh({name:"blake2b-496",code:45630,encode:e=>Zu(Bh(e,void 0,62))}),wh({name:"blake2b-504",code:45631,encode:e=>Zu(Bh(e,void 0,63))}),wh({name:"blake2b-512",code:45632,encode:e=>Zu(Bh(e,void 0,64))});class Dh extends Error{constructor(e){super(e),this.name="VerificationError"}}class Th extends Error{constructor(e){super(e),this.name="TimeoutError"}}function Uh(e){if(!e||"string"!=typeof e.message)return!1;const t=[/file does not exist/,/Cannot read properties of undefined \(reading '([^']+)'\)/,/([a-zA-Z_.]+) is undefined/,/undefined is not an object \(evaluating '([^']+)'\)/,/all retrievals failed/];for(const r of t)if(r.test(e.message))return!0;return!1}class Nh{constructor(e,t={}){this.carItr=e,this.getBlockTimeout=t.getBlockTimeout??1e4}static async fromStream(e){const t=(await Rn.fromIterable(Sh(e)))[Symbol.asyncIterator]();return new Nh(t)}async get(e,t){if((e="string"==typeof e?le.parse(e):e).multihash.code===Ca.code)return e.multihash.digest;const{value:r,done:n}=await function(e,t,r){let n;const o=new Promise(((e,o)=>{n=setTimeout((()=>{const e=new Error("Promise timed out");o(r||e)}),t)}));return Promise.race([e,o]).finally((()=>clearTimeout(n)))}(this.carItr.next(),this.getBlockTimeout,new Th(`get ${e}: timed out`));if(!r&&n)throw new Dh(`get ${e}: CAR file has no more blocks`);const{cid:o,bytes:i}=r;if(await Rh(o,i),!e.equals(o))throw new Dh(`get ${e}: received ${o} instead`);return i}}const{toHex:Lh}=e,Ph={[En]:n,[Yo]:o,[Qi]:i,[_a]:s,[yc]:b},Oh={[Ca.code]:Ca,[_c.code]:_c,[Ih.code]:ve(Ih)};async function zh(e){const t=await Rn.fromIterable(e);for await(const{cid:e,bytes:r}of t)await Rh(e,r);return!0}async function Rh(e,t){const{code:r,digest:n}=e.multihash;if(!Ph[e.code])throw new Dh(`Unexpected codec: 0x${e.code.toString(16)}`);if(!Oh[r])throw new Dh(`Unexpected multihash code: 0x${r.toString(16)}`);if(r!==Ca.code&&n.length<20)throw new Dh("Hashes must be at least 20 bytes long");if(r!==Ca.code&&n.length>128)throw new Dh("Hashes must be at most 128 bytes long");const o=await Oh[r].digest(t);if(Lh(o.digest)!==Lh(n))throw new Dh(`Mismatch: digest of bytes (${Lh(o)}) does not match digest in CID (${Lh(n)})`)}async function*Mh(e,t){const r=await Nh.fromStream(t),n=await Qu(e,r);for await(const e of n.content())yield e}let jh,$h;const Fh=new WeakMap,Vh=new WeakMap,qh=new WeakMap,Hh=new WeakMap,Gh=new WeakMap;let Wh={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return Vh.get(e);if("objectStoreNames"===t)return e.objectStoreNames||qh.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Kh(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function Jh(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?($h||($h=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(Qh(this),e),Kh(Fh.get(this))}:function(...e){return Kh(t.apply(Qh(this),e))}:function(e,...r){const n=t.call(Qh(this),e,...r);return qh.set(n,e.sort?e.sort():[e]),Kh(n)}:(e instanceof IDBTransaction&&function(e){if(Vh.has(e))return;const t=new Promise(((t,r)=>{const n=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",i),e.removeEventListener("abort",i)},o=()=>{t(),n()},i=()=>{r(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",o),e.addEventListener("error",i),e.addEventListener("abort",i)}));Vh.set(e,t)}(e),r=e,(jh||(jh=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some((e=>r instanceof e))?new Proxy(e,Wh):e);var t,r}function Kh(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,r)=>{const n=()=>{e.removeEventListener("success",o),e.removeEventListener("error",i)},o=()=>{t(Kh(e.result)),n()},i=()=>{r(e.error),n()};e.addEventListener("success",o),e.addEventListener("error",i)}));return t.then((t=>{t instanceof IDBCursor&&Fh.set(t,e)})).catch((()=>{})),Gh.set(t,e),t}(e);if(Hh.has(e))return Hh.get(e);const t=Jh(e);return t!==e&&(Hh.set(e,t),Gh.set(t,e)),t}const Qh=e=>Gh.get(e),Xh=["get","getKey","getAll","getAllKeys","count"],Zh=["put","add","delete","clear"],Yh=new Map;function ef(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(Yh.get(t))return Yh.get(t);const r=t.replace(/FromIndex$/,""),n=t!==r,o=Zh.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!o&&!Xh.includes(r))return;const i=async function(e,...t){const i=this.transaction(e,o?"readwrite":"readonly");let s=i.store;return n&&(s=s.index(t.shift())),(await Promise.all([s[r](...t),o&&i.done]))[0]};return Yh.set(t,i),i}var tf;tf=Wh,Wh={...tf,get:(e,t,r)=>ef(e,t)||tf.get(e,t,r),has:(e,t)=>!!ef(e,t)||tf.has(e,t)};const rf="saturn-client";function nf(){const e="undefined"!=typeof self&&self?.indexedDB;let t;return e&&(t=function(e,t,{blocked:r,upgrade:n,blocking:o,terminated:i}={}){const s=indexedDB.open(e,t),a=Kh(s);return n&&s.addEventListener("upgradeneeded",(e=>{n(Kh(s.result),e.oldVersion,e.newVersion,Kh(s.transaction),e)})),r&&s.addEventListener("blocked",(e=>r(e.oldVersion,e.newVersion,e))),a.then((e=>{i&&e.addEventListener("close",(()=>i())),o&&e.addEventListener("versionchange",(e=>o(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a}("saturn-db",1,{upgrade(e){e.createObjectStore(rf)}})),{get:async r=>e&&(await t).get(rf,r),set:async(r,n)=>e&&(await t).put(rf,n,r),delete:async r=>e&&(await t).delete(rf,r)}}function of(){const e={};return{get:async t=>e[t],set:async(t,r)=>{e[t]=r},delete:async t=>{delete e[t]}}}const sf="strn/jwt";async function af(e,t){try{const e=await t.get(sf);if(function(e){if(!e)return!1;const{exp:t}=JSON.parse(C(cc.decode("m"+e.split(".")[1])));return Date.now()<1e3*t}(e))return e}catch(e){}const{clientKey:r,authURL:n}=e,o=`${n}?clientKey=${r}`,i=await fetch(o),{token:s,message:a}=await i.json();if(!s)throw new Error(a||"Failed to refresh jwt");try{await t.set(sf,s)}catch(e){}return s}function cf(e){try{if(process?.env?.TESTING)return e.toJSON()}catch(e){}return e}function uf(e){return e.startsWith("http")||(e=`https://${e}`),e}const hf="undefined"!=typeof window&&void 0!==window.document,ff="undefined"!=typeof ServiceWorkerGlobalScope,lf="undefined"!=typeof DedicatedWorkerGlobalScope,df="undefined"!=typeof SharedWorkerGlobalScope,pf=hf||ff||lf||df;"undefined"!=typeof process&&null!=process.versions&&process.versions.node;class wf{static nodesListKey="saturn-nodes";static defaultRaceCount=3;constructor(e={}){this.config=Object.assign({},{clientId:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),cdnURL:"l1s.saturn.ms",logURL:"https://twb3qukm2i654i3tnvx36char40aymqq.lambda-url.us-west-2.on.aws/",orchURL:"https://orchestrator.strn.pl/nodes?maxNodes=100",authURL:"https://su4hesnyinnwvtk3h2rkauh5ja0qrisq.lambda-url.us-west-2.on.aws/",format:"car",fallbackLimit:5,connectTimeout:5e3,downloadTimeout:0},e),this.logs=[],this.nodes=[],this.reportingLogs=!0,this.hasPerformanceAPI=pf&&self?.performance,this.reportingLogs&&this.hasPerformanceAPI&&this._monitorPerformanceBuffer(),this.storage=this.config.storage||of(),this.loadNodesPromise=this.config.experimental?this._loadNodes(this.config):null,this.authLimiter=Ce(1)}async fetchCIDWithRace(e,t={}){const r=Object.assign({},this.config,t);if(!t.originFallback){const[t]=(e??"").split("/");le.parse(t),r.clientKey&&(r.jwt=await this.authLimiter((()=>af(r,this.storage))))}r.headers={...r.headers||{}},!pf&&r.jwt&&(r.headers.Authorization="Bearer "+r.jwt);let n=r.nodes;n&&0!==n.length||(n=[{url:r.cdnURL}]);const o=[],i=async t=>{const n={...r,url:t.url},i=this.createRequestURL(e,n),s=new AbortController;o.push(s);const c=setTimeout((()=>{s.abort()}),r.connectTimeout);try{return a=await fetch(cf(i),{signal:s.signal,...r}),clearTimeout(c),{res:a,url:i,node:t,controller:s}}catch(e){throw e.node=t,e}},s=Promise.any(n.map((e=>i(e))));let a,c,u,h,f={startTime:new Date};try{if(({res:a,url:c,controller:u,node:h}=await s),(async(e,t)=>{t.forEach((t=>{e!==t&&t.abort("Request race unsuccessful")}))})(u,o),f.nodeId=h.id,f=Object.assign(f,this._generateLog(a,f),{url:c}),!a.ok){const e=new Error(`Non OK response received: ${a.status} ${a.statusText}`);throw e.res=a,e}}catch(e){throw a||(f.error=e.message),e.node&&(f.nodeId=e.node.id),this._finalizeLog(f),e}return{res:a,controller:u,log:f}}async fetchCID(e,t={}){const r=Object.assign({},this.config,t);if(!t.originFallback){const[t]=(e??"").split("/");le.parse(t),r.clientKey&&(r.jwt=await this.authLimiter((()=>af(r,this.storage))))}const n=r.nodes&&r.nodes[0],o=n?.url??this.config.cdnURL,i=this.createRequestURL(e,{...r,url:o});let s={url:i,startTime:new Date};n?.id&&(s.nodeId=n.id);const a=r.controller??new AbortController,c=setTimeout((()=>{a.abort()}),r.connectTimeout);let u;r.headers={...r.headers||{}},!pf&&r.jwt&&(r.headers.Authorization="Bearer "+r.jwt);try{if(u=await fetch(cf(i),{signal:a.signal,...r}),clearTimeout(c),s=Object.assign(s,this._generateLog(u,s)),!u.ok){const e=new Error(`Non OK response received: ${u.status} ${u.statusText}`);throw e.res=u,e}}catch(e){throw u||(s.error=e.message),this._finalizeLog(s),e}return{res:u,controller:a,log:s}}_generateLog(e,t){const{headers:r}=e;return t.httpStatusCode=e.status,t.cacheHit="HIT"===r.get("saturn-cache-status"),t.nodeId=t.nodeId??r.get("saturn-node-id"),t.requestId=r.get("saturn-transfer-id"),t.httpProtocol=r.get("quic-status"),e.ok&&(t.ttfbMs=new Date-t.startTime),t}async*fetchContentWithFallback(e,t={}){const r=t.controller;delete t.controller;let n=null,o=!1,i=0;const s=async function*(n){const o=new AbortController;t.controller=o,r&&r.signal.addEventListener("abort",(()=>{o.abort()}));let s=0;const a=Object.assign(t,n),c=await this.fetchContent(e,a);for await(const e of c){if(sthis.config.fallbackLimit||o||r?.signal.aborted);e++){t.raceNodes?t.nodes=c.slice(e,e+wf.defaultRaceCount):t.nodes=Array(c[e]);try{return void(yield*s())}catch(e){if(n=e,410===e.res?.status||Uh(e))break}a+=1}if(n){const e=t.customerFallbackURL??this.config.customerFallbackURL;if(e){t.nodes=Array({url:e});try{return void(yield*s({format:null,originFallback:!0}))}catch(e){n=e}}(()=>{throw new Error(`All attempts to fetch content have failed. Last error: ${n.message}`)})()}}async*fetchContent(e,t={}){let r,n,o;(t=Object.assign({},this.config,t)).raceNodes?({res:r,controller:n,log:o}=await this.fetchCIDWithRace(e,t)):({res:r,controller:n,log:o}=await this.fetchCID(e,t));try{const n=async function*(e){o.numBytesSent=0;for await(const t of e)o.numBytesSent+=t.length,yield t}(Sh(r.body));t.format?yield*Mh(e,n):yield*n}catch(e){throw o.error=e.message,n.abort(),e}finally{this._finalizeLog(o)}}async fetchContentBuffer(e,t={}){return await async function(e){const t=[];let r=0;for await(const n of e){const e=new Uint8Array(n);t.push(e),r+=e.byteLength}const n=new Uint8Array(r);let o=0;for(const e of t)n.set(e,o),o+=e.byteLength;return n}(this.fetchContent(e,t))}createRequestURL(e,t={}){let r=t.url??this.config.cdnURL;if(r=uf(r),t.originFallback)return new URL(r);const n=new URL(`${r}/ipfs/${e}`);return t.format&&n.searchParams.set("format",t.format),"car"===t.format&&n.searchParams.set("dag-scope","entity"),pf&&t.jwt&&n.searchParams.set("jwt",t.jwt),n}_finalizeLog(e){e.requestDurationSec=(new Date-e.startTime)/1e3,this.reportLogs(e)}reportLogs(e){this.logs.push(e),this.reportingLogs&&(this.reportLogsTimeout&&clearTimeout(this.reportLogsTimeout),this.reportLogsTimeout=setTimeout(this._reportLogs.bind(this),3e3))}async _reportLogs(){if(!this.logs.length)return;const e=this.hasPerformanceAPI?this._matchLogsWithPerformanceMetrics(this.logs):this.logs;await fetch(this.config.logURL,{method:"POST",body:JSON.stringify({bandwidthLogs:e,logSender:this.config.logSender})}),this.logs=[],this._clearPerformanceBuffer()}_matchLogsWithPerformanceMetrics(e){return e.map((e=>({...e,...this._getPerformanceMetricsForLog(e)}))).filter((e=>!e.isFromBrowserCache)).map((e=>{const{isFromBrowserCache:t,...r}=e;return r}))}_getPerformanceMetricsForLog(e){const t={},r=performance.getEntriesByType("resource").find((t=>t.name===e.url.href));if(r){const n=r.domainLookupStart,o=r.domainLookupEnd;o>0&&n>0&&(t.dnsTimeMs=Math.round(o-n),t.ttfbAfterDnsMs=Math.round(r.responseStart-r.requestStart)),r.nextHopProtocol&&(t.httpProtocol=r.nextHopProtocol),t.isFromBrowserCache="cache"===r.deliveryType||e.httpStatusCode&&0===r.transferSize}return t}_monitorPerformanceBuffer(){performance.addEventListener("resourcetimingbufferfull",wf._setResourceBufferSize)}static _setResourceBufferSize(){const e=performance.getEntriesByType("resource").length,t=Math.min(e+250,1e3);performance.setResourceTimingBufferSize(t)}_clearPerformanceBuffer(){this.hasPerformanceAPI&&performance.clearResourceTimings()}_sortNodes(e){const t=Math.max(...e.map((e=>e.distance))),r=1-.8;return e.slice().sort(((e,n)=>{const o=e.distance/t,i=n.distance/t,s=e.weight/100,a=n.weight/100;return.8*o-r*s-(.8*i-r*a)}))}async _loadNodes(e){let t,r=e.orchURL;this.storage&&(t=this.storage.get(wf.nodesListKey)),r=uf(r);const n=new URL(r),o=new AbortController,i=Object.assign({},{method:"GET"},this.config),s=setTimeout((()=>{o.abort()}),i.connectTimeout),a=(await fetch(cf(n),{signal:o.signal,...i})).json();let c;clearTimeout(s),c=t?await Promise.any([a,t]):await a,c===await t&&(this.nodes=c),c=await a,c=this._sortNodes(c),this.nodes=c,this.storage.set(wf.nodesListKey,c)}}})(),SaturnModule=__webpack_exports__})();