ipfs-unixfs-importer
Version:
JavaScript implementation of the UnixFs importer used by IPFS
2 lines • 83.2 kB
JavaScript
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.IpfsUnixfsImporter = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var IpfsUnixfsImporter=(()=>{var oi=Object.create;var Rt=Object.defineProperty;var si=Object.getOwnPropertyDescriptor;var ai=Object.getOwnPropertyNames;var ci=Object.getPrototypeOf,fi=Object.prototype.hasOwnProperty;var z=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),C=(r,t)=>{for(var e in t)Rt(r,e,{get:t[e],enumerable:!0})},ir=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ai(t))!fi.call(r,i)&&i!==e&&Rt(r,i,{get:()=>t[i],enumerable:!(n=si(t,i))||n.enumerable});return r};var O=(r,t,e)=>(e=r!=null?oi(ci(r)):{},ir(t||!r||!r.__esModule?Rt(e,"default",{value:r,enumerable:!0}):e,r)),ui=r=>ir(Rt({},"__esModule",{value:!0}),r);var _t=z((Ds,sr)=>{"use strict";function or(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function hi(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return or(r,e)}catch{e.message=r.message,e.stack=r.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(r)),or(new i,e)}}sr.exports=hi});var cr=z((Ls,ar)=>{"use strict";ar.exports=li;function li(r,t){for(var e=new Array(arguments.length-1),n=0,i=2,o=!0;i<arguments.length;)e[n++]=arguments[i++];return new Promise(function(f,a){e[n]=function(u){if(o)if(o=!1,u)a(u);else{for(var p=new Array(arguments.length-1),D=0;D<p.length;)p[D++]=arguments[D];f.apply(null,p)}};try{r.apply(t||null,e)}catch(h){o&&(o=!1,a(h))}})}});var lr=z(hr=>{"use strict";var Vt=hr;Vt.length=function(t){var e=t.length;if(!e)return 0;for(var n=0;--e%4>1&&t.charAt(e)==="=";)++n;return Math.ceil(t.length*3)/4-n};var ht=new Array(64),ur=new Array(123);for(R=0;R<64;)ur[ht[R]=R<26?R+65:R<52?R+71:R<62?R-4:R-59|43]=R++;var R;Vt.encode=function(t,e,n){for(var i=null,o=[],s=0,f=0,a;e<n;){var h=t[e++];switch(f){case 0:o[s++]=ht[h>>2],a=(h&3)<<4,f=1;break;case 1:o[s++]=ht[a|h>>4],a=(h&15)<<2,f=2;break;case 2:o[s++]=ht[a|h>>6],o[s++]=ht[h&63],f=0;break}s>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),s=0)}return f&&(o[s++]=ht[a],o[s++]=61,f===1&&(o[s++]=61)),i?(s&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))};var fr="invalid encoding";Vt.decode=function(t,e,n){for(var i=n,o=0,s,f=0;f<t.length;){var a=t.charCodeAt(f++);if(a===61&&o>1)break;if((a=ur[a])===void 0)throw Error(fr);switch(o){case 0:s=a,o=1;break;case 1:e[n++]=s<<2|(a&48)>>4,s=a,o=2;break;case 2:e[n++]=(s&15)<<4|(a&60)>>2,s=a,o=3;break;case 3:e[n++]=(s&3)<<6|a,o=0;break}}if(o===1)throw Error(fr);return n-i};Vt.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var pr=z((Ts,dr)=>{"use strict";dr.exports=qt;function qt(){this._listeners={}}qt.prototype.on=function(t,e,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:n||this}),this};qt.prototype.off=function(t,e){if(t===void 0)this._listeners={};else if(e===void 0)this._listeners[t]=[];else for(var n=this._listeners[t],i=0;i<n.length;)n[i].fn===e?n.splice(i,1):++i;return this};qt.prototype.emit=function(t){var e=this._listeners[t];if(e){for(var n=[],i=1;i<arguments.length;)n.push(arguments[i++]);for(i=0;i<e.length;)e[i].fn.apply(e[i++].ctx,n)}return this}});var _r=z((Ns,xr)=>{"use strict";xr.exports=mr(mr);function mr(r){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),e=new Uint8Array(t.buffer),n=e[3]===128;function i(a,h,u){t[0]=a,h[u]=e[0],h[u+1]=e[1],h[u+2]=e[2],h[u+3]=e[3]}function o(a,h,u){t[0]=a,h[u]=e[3],h[u+1]=e[2],h[u+2]=e[1],h[u+3]=e[0]}r.writeFloatLE=n?i:o,r.writeFloatBE=n?o:i;function s(a,h){return e[0]=a[h],e[1]=a[h+1],e[2]=a[h+2],e[3]=a[h+3],t[0]}function f(a,h){return e[3]=a[h],e[2]=a[h+1],e[1]=a[h+2],e[0]=a[h+3],t[0]}r.readFloatLE=n?s:f,r.readFloatBE=n?f:s}():function(){function t(n,i,o,s){var f=i<0?1:0;if(f&&(i=-i),i===0)n(1/i>0?0:2147483648,o,s);else if(isNaN(i))n(2143289344,o,s);else if(i>34028234663852886e22)n((f<<31|2139095040)>>>0,o,s);else if(i<11754943508222875e-54)n((f<<31|Math.round(i/1401298464324817e-60))>>>0,o,s);else{var a=Math.floor(Math.log(i)/Math.LN2),h=Math.round(i*Math.pow(2,-a)*8388608)&8388607;n((f<<31|a+127<<23|h)>>>0,o,s)}}r.writeFloatLE=t.bind(null,yr),r.writeFloatBE=t.bind(null,gr);function e(n,i,o){var s=n(i,o),f=(s>>31)*2+1,a=s>>>23&255,h=s&8388607;return a===255?h?NaN:f*(1/0):a===0?f*1401298464324817e-60*h:f*Math.pow(2,a-150)*(h+8388608)}r.readFloatLE=e.bind(null,wr),r.readFloatBE=e.bind(null,br)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),e=new Uint8Array(t.buffer),n=e[7]===128;function i(a,h,u){t[0]=a,h[u]=e[0],h[u+1]=e[1],h[u+2]=e[2],h[u+3]=e[3],h[u+4]=e[4],h[u+5]=e[5],h[u+6]=e[6],h[u+7]=e[7]}function o(a,h,u){t[0]=a,h[u]=e[7],h[u+1]=e[6],h[u+2]=e[5],h[u+3]=e[4],h[u+4]=e[3],h[u+5]=e[2],h[u+6]=e[1],h[u+7]=e[0]}r.writeDoubleLE=n?i:o,r.writeDoubleBE=n?o:i;function s(a,h){return e[0]=a[h],e[1]=a[h+1],e[2]=a[h+2],e[3]=a[h+3],e[4]=a[h+4],e[5]=a[h+5],e[6]=a[h+6],e[7]=a[h+7],t[0]}function f(a,h){return e[7]=a[h],e[6]=a[h+1],e[5]=a[h+2],e[4]=a[h+3],e[3]=a[h+4],e[2]=a[h+5],e[1]=a[h+6],e[0]=a[h+7],t[0]}r.readDoubleLE=n?s:f,r.readDoubleBE=n?f:s}():function(){function t(n,i,o,s,f,a){var h=s<0?1:0;if(h&&(s=-s),s===0)n(0,f,a+i),n(1/s>0?0:2147483648,f,a+o);else if(isNaN(s))n(0,f,a+i),n(2146959360,f,a+o);else if(s>17976931348623157e292)n(0,f,a+i),n((h<<31|2146435072)>>>0,f,a+o);else{var u;if(s<22250738585072014e-324)u=s/5e-324,n(u>>>0,f,a+i),n((h<<31|u/4294967296)>>>0,f,a+o);else{var p=Math.floor(Math.log(s)/Math.LN2);p===1024&&(p=1023),u=s*Math.pow(2,-p),n(u*4503599627370496>>>0,f,a+i),n((h<<31|p+1023<<20|u*1048576&1048575)>>>0,f,a+o)}}}r.writeDoubleLE=t.bind(null,yr,0,4),r.writeDoubleBE=t.bind(null,gr,4,0);function e(n,i,o,s,f){var a=n(s,f+i),h=n(s,f+o),u=(h>>31)*2+1,p=h>>>20&2047,D=4294967296*(h&1048575)+a;return p===2047?D?NaN:u*(1/0):p===0?u*5e-324*D:u*Math.pow(2,p-1075)*(D+4503599627370496)}r.readDoubleLE=e.bind(null,wr,0,4),r.readDoubleBE=e.bind(null,br,4,0)}(),r}function yr(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function gr(r,t,e){t[e]=r>>>24,t[e+1]=r>>>16&255,t[e+2]=r>>>8&255,t[e+3]=r&255}function wr(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24)>>>0}function br(r,t){return(r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3])>>>0}});var vr=z((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(r){}return null}});var Ar=z(Br=>{"use strict";var ie=Br;ie.length=function(t){for(var e=0,n=0,i=0;i<t.length;++i)n=t.charCodeAt(i),n<128?e+=1:n<2048?e+=2:(n&64512)===55296&&(t.charCodeAt(i+1)&64512)===56320?(++i,e+=4):e+=3;return e};ie.read=function(t,e,n){var i=n-e;if(i<1)return"";for(var o=null,s=[],f=0,a;e<n;)a=t[e++],a<128?s[f++]=a:a>191&&a<224?s[f++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,s[f++]=55296+(a>>10),s[f++]=56320+(a&1023)):s[f++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,f>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),f=0);return o?(f&&o.push(String.fromCharCode.apply(String,s.slice(0,f))),o.join("")):String.fromCharCode.apply(String,s.slice(0,f))};ie.write=function(t,e,n){for(var i=n,o,s,f=0;f<t.length;++f)o=t.charCodeAt(f),o<128?e[n++]=o:o<2048?(e[n++]=o>>6|192,e[n++]=o&63|128):(o&64512)===55296&&((s=t.charCodeAt(f+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++f,e[n++]=o>>18|240,e[n++]=o>>12&63|128,e[n++]=o>>6&63|128,e[n++]=o&63|128):(e[n++]=o>>12|224,e[n++]=o>>6&63|128,e[n++]=o&63|128);return n-i}});var Sr=z((Cs,kr)=>{"use strict";kr.exports=di;function di(r,t,e){var n=e||8192,i=n>>>1,o=null,s=n;return function(a){if(a<1||a>i)return r(a);s+a>n&&(o=r(n),s=0);var h=t.call(o,s,s+=a);return s&7&&(s=(s|7)+1),h}}});var Lr=z((Ps,Dr)=>{"use strict";Dr.exports=N;var vt=nt();function N(r,t){this.lo=r>>>0,this.hi=t>>>0}var rt=N.zero=new N(0,0);rt.toNumber=function(){return 0};rt.zzEncode=rt.zzDecode=function(){return this};rt.length=function(){return 1};var pi=N.zeroHash="\0\0\0\0\0\0\0\0";N.fromNumber=function(t){if(t===0)return rt;var e=t<0;e&&(t=-t);var n=t>>>0,i=(t-n)/4294967296>>>0;return e&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new N(n,i)};N.from=function(t){if(typeof t=="number")return N.fromNumber(t);if(vt.isString(t))if(vt.Long)t=vt.Long.fromString(t);else return N.fromNumber(parseInt(t,10));return t.low||t.high?new N(t.low>>>0,t.high>>>0):rt};N.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var e=~this.lo+1>>>0,n=~this.hi>>>0;return e||(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296};N.prototype.toLong=function(t){return vt.Long?new vt.Long(this.lo|0,this.hi|0,!!t):{low:this.lo|0,high:this.hi|0,unsigned:!!t}};var Y=String.prototype.charCodeAt;N.fromHash=function(t){return t===pi?rt:new N((Y.call(t,0)|Y.call(t,1)<<8|Y.call(t,2)<<16|Y.call(t,3)<<24)>>>0,(Y.call(t,4)|Y.call(t,5)<<8|Y.call(t,6)<<16|Y.call(t,7)<<24)>>>0)};N.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};N.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this};N.prototype.zzDecode=function(){var t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this};N.prototype.length=function(){var t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}});var nt=z(oe=>{"use strict";var x=oe;x.asPromise=cr();x.base64=lr();x.EventEmitter=pr();x.float=_r();x.inquire=vr();x.utf8=Ar();x.pool=Sr();x.LongBits=Lr();x.isNode=!!(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);x.global=x.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||oe;x.emptyArray=Object.freeze?Object.freeze([]):[];x.emptyObject=Object.freeze?Object.freeze({}):{};x.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};x.isString=function(t){return typeof t=="string"||t instanceof String};x.isObject=function(t){return t&&typeof t=="object"};x.isset=x.isSet=function(t,e){var n=t[e];return n!=null&&t.hasOwnProperty(e)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};x.Buffer=function(){try{var r=x.inquire("buffer").Buffer;return r.prototype.utf8Write?r:null}catch{return null}}();x._Buffer_from=null;x._Buffer_allocUnsafe=null;x.newBuffer=function(t){return typeof t=="number"?x.Buffer?x._Buffer_allocUnsafe(t):new x.Array(t):x.Buffer?x._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)};x.Array=typeof Uint8Array<"u"?Uint8Array:Array;x.Long=x.global.dcodeIO&&x.global.dcodeIO.Long||x.global.Long||x.inquire("long");x.key2Re=/^true|false|0|1$/;x.key32Re=/^-?(?:0|[1-9][0-9]*)$/;x.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;x.longToHash=function(t){return t?x.LongBits.from(t).toHash():x.LongBits.zeroHash};x.longFromHash=function(t,e){var n=x.LongBits.fromHash(t);return x.Long?x.Long.fromBits(n.lo,n.hi,e):n.toNumber(!!e)};function Er(r,t,e){for(var n=Object.keys(t),i=0;i<n.length;++i)(r[n[i]]===void 0||!e)&&(r[n[i]]=t[n[i]]);return r}x.merge=Er;x.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function Tr(r){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&Er(this,n)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return r},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}x.newError=Tr;x.ProtocolError=Tr("ProtocolError");x.oneOfGetter=function(t){for(var e={},n=0;n<t.length;++n)e[t[n]]=1;return function(){for(var i=Object.keys(this),o=i.length-1;o>-1;--o)if(e[i[o]]===1&&this[i[o]]!==void 0&&this[i[o]]!==null)return i[o]}};x.oneOfSetter=function(t){return function(e){for(var n=0;n<t.length;++n)t[n]!==e&&delete this[t[n]]}};x.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};x._configure=function(){var r=x.Buffer;if(!r){x._Buffer_from=x._Buffer_allocUnsafe=null;return}x._Buffer_from=r.from!==Uint8Array.from&&r.from||function(e,n){return new r(e,n)},x._Buffer_allocUnsafe=r.allocUnsafe||function(e){return new r(e)}}});var ce=z((Fs,Ir)=>{"use strict";Ir.exports=T;var j=nt(),ae,Cr=j.LongBits,mi=j.utf8;function V(r,t){return RangeError("index out of range: "+r.pos+" + "+(t||1)+" > "+r.len)}function T(r){this.buf=r,this.pos=0,this.len=r.length}var Nr=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new T(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new T(t);throw Error("illegal buffer")},Pr=function(){return j.Buffer?function(e){return(T.create=function(i){return j.Buffer.isBuffer(i)?new ae(i):Nr(i)})(e)}:Nr};T.create=Pr();T.prototype._slice=j.Array.prototype.subarray||j.Array.prototype.slice;T.prototype.uint32=function(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,V(this,10);return t}}();T.prototype.int32=function(){return this.uint32()|0};T.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function se(){var r=new Cr(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r;if(r.lo=(r.lo|(this.buf[this.pos]&127)<<28)>>>0,r.hi=(r.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return r;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw V(this);if(r.lo=(r.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return r}return r.lo=(r.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,r}if(this.len-this.pos>4){for(;t<5;++t)if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}else for(;t<5;++t){if(this.pos>=this.len)throw V(this);if(r.hi=(r.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return r}throw Error("invalid varint encoding")}T.prototype.bool=function(){return this.uint32()!==0};function Gt(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}T.prototype.fixed32=function(){if(this.pos+4>this.len)throw V(this,4);return Gt(this.buf,this.pos+=4)};T.prototype.sfixed32=function(){if(this.pos+4>this.len)throw V(this,4);return Gt(this.buf,this.pos+=4)|0};function zr(){if(this.pos+8>this.len)throw V(this,8);return new Cr(Gt(this.buf,this.pos+=4),Gt(this.buf,this.pos+=4))}T.prototype.float=function(){if(this.pos+4>this.len)throw V(this,4);var t=j.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};T.prototype.double=function(){if(this.pos+8>this.len)throw V(this,4);var t=j.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};T.prototype.bytes=function(){var t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw V(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,n):e===n?new this.buf.constructor(0):this._slice.call(this.buf,e,n)};T.prototype.string=function(){var t=this.bytes();return mi.read(t,0,t.length)};T.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw V(this,t);this.pos+=t}else do if(this.pos>=this.len)throw V(this);while(this.buf[this.pos++]&128);return this};T.prototype.skipType=function(r){switch(r){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(r=this.uint32()&7)!==4;)this.skipType(r);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+r+" at offset "+this.pos)}return this};T._configure=function(r){ae=r,T.create=Pr(),ae._configure();var t=j.Long?"toLong":"toNumber";j.merge(T.prototype,{int64:function(){return se.call(this)[t](!1)},uint64:function(){return se.call(this)[t](!0)},sint64:function(){return se.call(this).zzDecode()[t](!1)},fixed64:function(){return zr.call(this)[t](!0)},sfixed64:function(){return zr.call(this)[t](!1)}})}});var Hr=z((Us,Mr)=>{"use strict";Mr.exports=it;var Ur=ce();(it.prototype=Object.create(Ur.prototype)).constructor=it;var Fr=nt();function it(r){Ur.call(this,r)}it._configure=function(){Fr.Buffer&&(it.prototype._slice=Fr.Buffer.prototype.slice)};it.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};it._configure()});var me=z((Ms,qr)=>{"use strict";qr.exports=A;var M=nt(),fe,jt=M.LongBits,Or=M.base64,Rr=M.utf8;function Bt(r,t,e){this.fn=r,this.len=t,this.next=void 0,this.val=e}function he(){}function yi(r){this.head=r.head,this.tail=r.tail,this.len=r.len,this.next=r.states}function A(){this.len=0,this.head=new Bt(he,0,0),this.tail=this.head,this.states=null}var Vr=function(){return M.Buffer?function(){return(A.create=function(){return new fe})()}:function(){return new A}};A.create=Vr();A.alloc=function(t){return new M.Array(t)};M.Array!==Array&&(A.alloc=M.pool(A.alloc,M.Array.prototype.subarray));A.prototype._push=function(t,e,n){return this.tail=this.tail.next=new Bt(t,e,n),this.len+=e,this};function le(r,t,e){t[e]=r&255}function gi(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}function de(r,t){this.len=r,this.next=void 0,this.val=t}de.prototype=Object.create(Bt.prototype);de.prototype.fn=gi;A.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new de((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};A.prototype.int32=function(t){return t<0?this._push(pe,10,jt.fromNumber(t)):this.uint32(t)};A.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function pe(r,t,e){for(;r.hi;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}A.prototype.uint64=function(t){var e=jt.from(t);return this._push(pe,e.length(),e)};A.prototype.int64=A.prototype.uint64;A.prototype.sint64=function(t){var e=jt.from(t).zzEncode();return this._push(pe,e.length(),e)};A.prototype.bool=function(t){return this._push(le,1,t?1:0)};function ue(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}A.prototype.fixed32=function(t){return this._push(ue,4,t>>>0)};A.prototype.sfixed32=A.prototype.fixed32;A.prototype.fixed64=function(t){var e=jt.from(t);return this._push(ue,4,e.lo)._push(ue,4,e.hi)};A.prototype.sfixed64=A.prototype.fixed64;A.prototype.float=function(t){return this._push(M.float.writeFloatLE,4,t)};A.prototype.double=function(t){return this._push(M.float.writeDoubleLE,8,t)};var wi=M.Array.prototype.set?function(t,e,n){e.set(t,n)}:function(t,e,n){for(var i=0;i<t.length;++i)e[n+i]=t[i]};A.prototype.bytes=function(t){var e=t.length>>>0;if(!e)return this._push(le,1,0);if(M.isString(t)){var n=A.alloc(e=Or.length(t));Or.decode(t,n,0),t=n}return this.uint32(e)._push(wi,e,t)};A.prototype.string=function(t){var e=Rr.length(t);return e?this.uint32(e)._push(Rr.write,e,t):this._push(le,1,0)};A.prototype.fork=function(){return this.states=new yi(this),this.head=this.tail=new Bt(he,0,0),this.len=0,this};A.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 Bt(he,0,0),this.len=0),this};A.prototype.ldelim=function(){var t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=e,this.len+=n),this};A.prototype.finish=function(){for(var t=this.head.next,e=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e};A._configure=function(r){fe=r,A.create=Vr(),fe._configure()}});var $r=z((Hs,jr)=>{"use strict";jr.exports=$;var Gr=me();($.prototype=Object.create(Gr.prototype)).constructor=$;var tt=nt();function $(){Gr.call(this)}$._configure=function(){$.alloc=tt._Buffer_allocUnsafe,$.writeBytesBuffer=tt.Buffer&&tt.Buffer.prototype instanceof Uint8Array&&tt.Buffer.prototype.set.name==="set"?function(t,e,n){e.set(t,n)}:function(t,e,n){if(t.copy)t.copy(e,n,0,t.length);else for(var i=0;i<t.length;)e[n++]=t[i++]}};$.prototype.bytes=function(t){tt.isString(t)&&(t=tt._Buffer_from(t,"base64"));var e=t.length>>>0;return this.uint32(e),e&&this._push($.writeBytesBuffer,e,t),this};function bi(r,t,e){r.length<40?tt.utf8.write(r,t,e):t.utf8Write?t.utf8Write(r,e):t.write(r,e)}$.prototype.string=function(t){var e=tt.Buffer.byteLength(t);return this.uint32(e),e&&this._push(bi,e,t),this};$._configure()});var Nn=z((rc,Tn)=>{"use strict";Tn.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(t,e){let n=this._internalPositionFor(t,!1);if(e===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(t),this._changedLength=!0,this._changedData=!0);else{let i=!1;n===-1?(n=this._data.length,this._setBit(t),this._changedData=!0):i=!0,this._setInternalPos(n,t,e,i),this._changedLength=!0}}unset(t){this.set(t,void 0)}get(t){this._sortData();let e=this._internalPositionFor(t,!0);if(e!==-1)return this._data[e][1]}push(t){return this.set(this.length,t),this.length}get length(){if(this._sortData(),this._changedLength){let t=this._data[this._data.length-1];this._length=t?t[0]+1:0,this._changedLength=!1}return this._length}forEach(t){let e=0;for(;e<this.length;)t(this.get(e),e,this),e++}map(t){let e=0,n=new Array(this.length);for(;e<this.length;)n[e]=t(this.get(e),e,this),e++;return n}reduce(t,e){let n=0,i=e;for(;n<this.length;){let o=this.get(n);i=t(i,o,n),n++}return i}find(t){let e=0,n,i;for(;e<this.length&&!n;)i=this.get(e),n=t(i),e++;return n?i:void 0}_internalPositionFor(t,e){let n=this._bytePosFor(t,e);if(n>=this._bitArrays.length)return-1;let i=this._bitArrays[n],o=t-n*7;if(!((i&1<<o)>0))return-1;let f=this._bitArrays.slice(0,n).reduce(Po,0),a=~(4294967295<<o+1),h=En(i&a);return f+h-1}_bytePosFor(t,e){let n=Math.floor(t/7),i=n+1;for(;!e&&this._bitArrays.length<i;)this._bitArrays.push(0);return n}_setBit(t){let e=this._bytePosFor(t,!1);this._bitArrays[e]|=1<<t-e*7}_unsetBit(t){let e=this._bytePosFor(t,!1);this._bitArrays[e]&=~(1<<t-e*7)}_setInternalPos(t,e,n,i){let o=this._data,s=[e,n];if(i)this._sortData(),o[t]=s;else{if(o.length)if(o[o.length-1][0]>=e)o.push(s);else if(o[0][0]<=e)o.unshift(s);else{let f=Math.round(o.length/2);this._data=o.slice(0,f).concat(s).concat(o.slice(f))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(t){this._data.splice(t,1)}_sortData(){this._changedData&&this._data.sort(Io),this._changedData=!1}bitField(){let t=[],e=8,n=0,i=0,o,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(o=s.shift(),n=7);let a=Math.min(n,e),h=~(255<<a),u=o&h;i|=u<<8-e,o=o>>>a,n-=a,e-=a,(!e||!n&&!s.length)&&(t.push(i),i=0,e=8)}for(var f=t.length-1;f>0&&t[f]===0;f--)t.pop();return t}compactArray(){return this._sortData(),this._data.map(Fo)}};function Po(r,t){return r+En(t)}function En(r){let t=r;return t=t-(t>>1&1431655765),t=(t&858993459)+(t>>2&858993459),(t+(t>>4)&252645135)*16843009>>24}function Io(r,t){return r[0]-t[0]}function Fo(r){return r[1]}});var Vn=z((Ut,te)=>{(function(r,t){"use strict";var e={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(c){if(!Array.isArray(c)&&!ArrayBuffer.isView(c))return!1;for(var l=0;l<c.length;l++)if(!Number.isInteger(c[l])||c[l]<0||c[l]>255)return!1;return!0}function i(c,l){return(c&65535)*l+(((c>>>16)*l&65535)<<16)}function o(c,l){return c<<l|c>>>32-l}function s(c){return c^=c>>>16,c=i(c,2246822507),c^=c>>>13,c=i(c,3266489909),c^=c>>>16,c}function f(c,l){c=[c[0]>>>16,c[0]&65535,c[1]>>>16,c[1]&65535],l=[l[0]>>>16,l[0]&65535,l[1]>>>16,l[1]&65535];var m=[0,0,0,0];return m[3]+=c[3]+l[3],m[2]+=m[3]>>>16,m[3]&=65535,m[2]+=c[2]+l[2],m[1]+=m[2]>>>16,m[2]&=65535,m[1]+=c[1]+l[1],m[0]+=m[1]>>>16,m[1]&=65535,m[0]+=c[0]+l[0],m[0]&=65535,[m[0]<<16|m[1],m[2]<<16|m[3]]}function a(c,l){c=[c[0]>>>16,c[0]&65535,c[1]>>>16,c[1]&65535],l=[l[0]>>>16,l[0]&65535,l[1]>>>16,l[1]&65535];var m=[0,0,0,0];return m[3]+=c[3]*l[3],m[2]+=m[3]>>>16,m[3]&=65535,m[2]+=c[2]*l[3],m[1]+=m[2]>>>16,m[2]&=65535,m[2]+=c[3]*l[2],m[1]+=m[2]>>>16,m[2]&=65535,m[1]+=c[1]*l[3],m[0]+=m[1]>>>16,m[1]&=65535,m[1]+=c[2]*l[2],m[0]+=m[1]>>>16,m[1]&=65535,m[1]+=c[3]*l[1],m[0]+=m[1]>>>16,m[1]&=65535,m[0]+=c[0]*l[3]+c[1]*l[2]+c[2]*l[1]+c[3]*l[0],m[0]&=65535,[m[0]<<16|m[1],m[2]<<16|m[3]]}function h(c,l){return l%=64,l===32?[c[1],c[0]]:l<32?[c[0]<<l|c[1]>>>32-l,c[1]<<l|c[0]>>>32-l]:(l-=32,[c[1]<<l|c[0]>>>32-l,c[0]<<l|c[1]>>>32-l])}function u(c,l){return l%=64,l===0?c:l<32?[c[0]<<l|c[1]>>>32-l,c[1]<<l]:[c[1]<<l-32,0]}function p(c,l){return[c[0]^l[0],c[1]^l[1]]}function D(c){return c=p(c,[0,c[0]>>>1]),c=a(c,[4283543511,3981806797]),c=p(c,[0,c[0]>>>1]),c=a(c,[3301882366,444984403]),c=p(c,[0,c[0]>>>1]),c}e.x86.hash32=function(c,l){if(e.inputValidation&&!n(c))return t;l=l||0;for(var m=c.length%4,S=c.length-m,d=l,y=0,w=3432918353,b=461845907,_=0;_<S;_=_+4)y=c[_]|c[_+1]<<8|c[_+2]<<16|c[_+3]<<24,y=i(y,w),y=o(y,15),y=i(y,b),d^=y,d=o(d,13),d=i(d,5)+3864292196;switch(y=0,m){case 3:y^=c[_+2]<<16;case 2:y^=c[_+1]<<8;case 1:y^=c[_],y=i(y,w),y=o(y,15),y=i(y,b),d^=y}return d^=c.length,d=s(d),d>>>0},e.x86.hash128=function(c,l){if(e.inputValidation&&!n(c))return t;l=l||0;for(var m=c.length%16,S=c.length-m,d=l,y=l,w=l,b=l,_=0,v=0,g=0,L=0,X=597399067,Mt=2869860233,Ht=951274213,Ot=2716044179,B=0;B<S;B=B+16)_=c[B]|c[B+1]<<8|c[B+2]<<16|c[B+3]<<24,v=c[B+4]|c[B+5]<<8|c[B+6]<<16|c[B+7]<<24,g=c[B+8]|c[B+9]<<8|c[B+10]<<16|c[B+11]<<24,L=c[B+12]|c[B+13]<<8|c[B+14]<<16|c[B+15]<<24,_=i(_,X),_=o(_,15),_=i(_,Mt),d^=_,d=o(d,19),d+=y,d=i(d,5)+1444728091,v=i(v,Mt),v=o(v,16),v=i(v,Ht),y^=v,y=o(y,17),y+=w,y=i(y,5)+197830471,g=i(g,Ht),g=o(g,17),g=i(g,Ot),w^=g,w=o(w,15),w+=b,w=i(w,5)+2530024501,L=i(L,Ot),L=o(L,18),L=i(L,X),b^=L,b=o(b,13),b+=d,b=i(b,5)+850148119;switch(_=0,v=0,g=0,L=0,m){case 15:L^=c[B+14]<<16;case 14:L^=c[B+13]<<8;case 13:L^=c[B+12],L=i(L,Ot),L=o(L,18),L=i(L,X),b^=L;case 12:g^=c[B+11]<<24;case 11:g^=c[B+10]<<16;case 10:g^=c[B+9]<<8;case 9:g^=c[B+8],g=i(g,Ht),g=o(g,17),g=i(g,Ot),w^=g;case 8:v^=c[B+7]<<24;case 7:v^=c[B+6]<<16;case 6:v^=c[B+5]<<8;case 5:v^=c[B+4],v=i(v,Mt),v=o(v,16),v=i(v,Ht),y^=v;case 4:_^=c[B+3]<<24;case 3:_^=c[B+2]<<16;case 2:_^=c[B+1]<<8;case 1:_^=c[B],_=i(_,X),_=o(_,15),_=i(_,Mt),d^=_}return d^=c.length,y^=c.length,w^=c.length,b^=c.length,d+=y,d+=w,d+=b,y+=d,w+=d,b+=d,d=s(d),y=s(y),w=s(w),b=s(b),d+=y,d+=w,d+=b,y+=d,w+=d,b+=d,("00000000"+(d>>>0).toString(16)).slice(-8)+("00000000"+(y>>>0).toString(16)).slice(-8)+("00000000"+(w>>>0).toString(16)).slice(-8)+("00000000"+(b>>>0).toString(16)).slice(-8)},e.x64.hash128=function(c,l){if(e.inputValidation&&!n(c))return t;l=l||0;for(var m=c.length%16,S=c.length-m,d=[0,l],y=[0,l],w=[0,0],b=[0,0],_=[2277735313,289559509],v=[1291169091,658871167],g=0;g<S;g=g+16)w=[c[g+4]|c[g+5]<<8|c[g+6]<<16|c[g+7]<<24,c[g]|c[g+1]<<8|c[g+2]<<16|c[g+3]<<24],b=[c[g+12]|c[g+13]<<8|c[g+14]<<16|c[g+15]<<24,c[g+8]|c[g+9]<<8|c[g+10]<<16|c[g+11]<<24],w=a(w,_),w=h(w,31),w=a(w,v),d=p(d,w),d=h(d,27),d=f(d,y),d=f(a(d,[0,5]),[0,1390208809]),b=a(b,v),b=h(b,33),b=a(b,_),y=p(y,b),y=h(y,31),y=f(y,d),y=f(a(y,[0,5]),[0,944331445]);switch(w=[0,0],b=[0,0],m){case 15:b=p(b,u([0,c[g+14]],48));case 14:b=p(b,u([0,c[g+13]],40));case 13:b=p(b,u([0,c[g+12]],32));case 12:b=p(b,u([0,c[g+11]],24));case 11:b=p(b,u([0,c[g+10]],16));case 10:b=p(b,u([0,c[g+9]],8));case 9:b=p(b,[0,c[g+8]]),b=a(b,v),b=h(b,33),b=a(b,_),y=p(y,b);case 8:w=p(w,u([0,c[g+7]],56));case 7:w=p(w,u([0,c[g+6]],48));case 6:w=p(w,u([0,c[g+5]],40));case 5:w=p(w,u([0,c[g+4]],32));case 4:w=p(w,u([0,c[g+3]],24));case 3:w=p(w,u([0,c[g+2]],16));case 2:w=p(w,u([0,c[g+1]],8));case 1:w=p(w,[0,c[g]]),w=a(w,_),w=h(w,31),w=a(w,v),d=p(d,w)}return d=p(d,[0,c.length]),y=p(y,[0,c.length]),d=f(d,y),y=f(y,d),d=D(d),y=D(y),d=f(d,y),y=f(y,d),("00000000"+(d[0]>>>0).toString(16)).slice(-8)+("00000000"+(d[1]>>>0).toString(16)).slice(-8)+("00000000"+(y[0]>>>0).toString(16)).slice(-8)+("00000000"+(y[1]>>>0).toString(16)).slice(-8)},typeof Ut<"u"?(typeof te<"u"&&te.exports&&(Ut=te.exports=e),Ut.murmurHash3=e):typeof define=="function"&&define.amd?define([],function(){return e}):(e._murmurHash3=r.murmurHash3,e.noConflict=function(){return r.murmurHash3=e._murmurHash3,e._murmurHash3=t,e.noConflict=t,e},r.murmurHash3=e)})(Ut)});var Gn=z((Vc,qn)=>{qn.exports=Vn()});var vs={};C(vs,{importByteStream:()=>_s,importBytes:()=>xs,importDirectory:()=>bs,importFile:()=>nr,importer:()=>rr});async function*ut(r,t=1){let e=[];t<1&&(t=1);for await(let n of r)for(e.push(n);e.length>=t;)yield e.slice(0,t),e=e.slice(t);for(;e.length>0;)yield e.slice(0,t),e=e.slice(t)}async function*xt(r,t=1){for await(let e of ut(r,t)){let n=e.map(async i=>await i().then(o=>({ok:!0,value:o}),o=>({ok:!1,err:o})));for(let i=0;i<n.length;i++){let o=await n[i];if(o.ok)yield o.value;else throw o.err}}}var _e=O(_t(),1);var ye=O(ce(),1),Wr=O(Hr(),1),Jr=O(nt(),1),ge=O(me(),1),Kr=O($r(),1);function xi(){Jr.default._configure(),ye.default._configure(Wr.default),ge.default._configure(Kr.default)}xi();var Xr=["uint64","int64","sint64","fixed64","sfixed64"];function _i(r){for(let t of Xr){if(r[t]==null)continue;let e=r[t];r[t]=function(){return BigInt(e.call(this).toString())}}return r}function we(r){return _i(new ye.default(r))}function vi(r){for(let t of Xr){if(r[t]==null)continue;let e=r[t];r[t]=function(n){return e.call(this,n.toString())}}return r}function be(){return vi(ge.default.create())}function At(r,t){let e=we(r instanceof Uint8Array?r:r.subarray());return t.decode(e)}function kt(r,t){let e=be();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var lt;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(lt||(lt={}));function $t(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function xe(r){function t(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let e=function(o,s){let f=t(o);s.int32(f)},n=function(o){let s=o.int32();return t(s)};return $t("enum",lt.VARINT,e,n)}function St(r,t){return $t("message",lt.LENGTH_DELIMITED,r,t)}var q;(function(r){let t;(function(i){i.Raw="Raw",i.Directory="Directory",i.File="File",i.Metadata="Metadata",i.Symlink="Symlink",i.HAMTShard="HAMTShard"})(t=r.DataType||(r.DataType={}));let e;(function(i){i[i.Raw=0]="Raw",i[i.Directory=1]="Directory",i[i.File=2]="File",i[i.Metadata=3]="Metadata",i[i.Symlink=4]="Symlink",i[i.HAMTShard=5]="HAMTShard"})(e||(e={})),function(i){i.codec=()=>xe(e)}(t=r.DataType||(r.DataType={}));let n;r.codec=()=>(n==null&&(n=St((i,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),i.Type!=null&&(o.uint32(8),r.DataType.codec().encode(i.Type,o)),i.Data!=null&&(o.uint32(18),o.bytes(i.Data)),i.filesize!=null&&(o.uint32(24),o.uint64(i.filesize)),i.blocksizes!=null)for(let f of i.blocksizes)o.uint32(32),o.uint64(f);i.hashType!=null&&(o.uint32(40),o.uint64(i.hashType)),i.fanout!=null&&(o.uint32(48),o.uint64(i.fanout)),i.mode!=null&&(o.uint32(56),o.uint32(i.mode)),i.mtime!=null&&(o.uint32(66),Wt.codec().encode(i.mtime,o)),s.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let s={blocksizes:[]},f=o==null?i.len:i.pos+o;for(;i.pos<f;){let a=i.uint32();switch(a>>>3){case 1:s.Type=r.DataType.codec().decode(i);break;case 2:s.Data=i.bytes();break;case 3:s.filesize=i.uint64();break;case 4:s.blocksizes.push(i.uint64());break;case 5:s.hashType=i.uint64();break;case 6:s.fanout=i.uint64();break;case 7:s.mode=i.uint32();break;case 8:s.mtime=Wt.codec().decode(i,i.uint32());break;default:i.skipType(a&7);break}}return s})),n),r.encode=i=>kt(i,r.codec()),r.decode=i=>At(i,r.codec())})(q||(q={}));var Wt;(function(r){let t;r.codec=()=>(t==null&&(t=St((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.Seconds!=null&&(n.uint32(8),n.int64(e.Seconds)),e.FractionalNanoseconds!=null&&(n.uint32(21),n.fixed32(e.FractionalNanoseconds)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:i.Seconds=e.int64();break;case 2:i.FractionalNanoseconds=e.fixed32();break;default:e.skipType(s&7);break}}return i})),t),r.encode=e=>kt(e,r.codec()),r.decode=e=>At(e,r.codec())})(Wt||(Wt={}));var Qr;(function(r){let t;r.codec=()=>(t==null&&(t=St((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.MimeType!=null&&(n.uint32(10),n.string(e.MimeType)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:i.MimeType=e.string();break;default:e.skipType(s&7);break}}return i})),t),r.encode=e=>kt(e,r.codec()),r.decode=e=>At(e,r.codec())})(Qr||(Qr={}));var Zr={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},Bi=["directory","hamt-sharded-directory"],Yr=parseInt("0644",8),tn=parseInt("0755",8),P=class{static unmarshal(t){let e=q.decode(t),n=new P({type:Zr[e.Type!=null?e.Type.toString():"File"],data:e.Data,blockSizes:e.blocksizes,mode:e.mode,mtime:e.mtime!=null?{secs:e.mtime.Seconds??0n,nsecs:e.mtime.FractionalNanoseconds}:void 0});return n._originalMode=e.mode??0,n}constructor(t={type:"file"}){let{type:e,data:n,blockSizes:i,hashType:o,fanout:s,mtime:f,mode:a}=t;if(e!=null&&!Object.values(Zr).includes(e))throw(0,_e.default)(new Error("Type: "+e+" is not valid"),"ERR_INVALID_TYPE");this.type=e??"file",this.data=n,this.hashType=o,this.fanout=s,this.blockSizes=i??[],this._originalMode=0,this.mode=a,this.mtime=f}set mode(t){t==null?this._mode=this.isDirectory()?tn:Yr:this._mode=t&4095}get mode(){return this._mode}isDirectory(){return Bi.includes(this.type)}addBlockSize(t){this.blockSizes.push(t)}removeBlockSize(t){this.blockSizes.splice(t,1)}fileSize(){if(this.isDirectory())return 0n;let t=0n;return this.blockSizes.forEach(e=>{t+=e}),this.data!=null&&(t+=BigInt(this.data.length)),t}marshal(){let t;switch(this.type){case"raw":t=q.DataType.Raw;break;case"directory":t=q.DataType.Directory;break;case"file":t=q.DataType.File;break;case"metadata":t=q.DataType.Metadata;break;case"symlink":t=q.DataType.Symlink;break;case"hamt-sharded-directory":t=q.DataType.HAMTShard;break;default:throw(0,_e.default)(new Error(`Type: ${t} is not valid`),"ERR_INVALID_TYPE")}let e=this.data;(this.data==null||this.data.length===0)&&(e=void 0);let n;this.mode!=null&&(n=this._originalMode&4294963200|(this.mode??0),n===Yr&&!this.isDirectory()&&(n=void 0),n===tn&&this.isDirectory()&&(n=void 0));let i;return this.mtime!=null&&(i={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),q.encode({Type:t,Data:e,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:n,mtime:i})}};var Ai=nn,en=128,ki=127,Si=~ki,Di=Math.pow(2,31);function nn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Di;)t[e++]=r&255|en,r/=128;for(;r&Si;)t[e++]=r&255|en,r>>>=7;return t[e]=r|0,nn.bytes=e-n+1,t}var Li=ve,Ei=128,rn=127;function ve(r,n){var e=0,n=n||0,i=0,o=n,s,f=r.length;do{if(o>=f)throw ve.bytes=0,new RangeError("Could not decode varint");s=r[o++],e+=i<28?(s&rn)<<i:(s&rn)*Math.pow(2,i),i+=7}while(s>=Ei);return ve.bytes=o-n,e}var Ti=Math.pow(2,7),Ni=Math.pow(2,14),zi=Math.pow(2,21),Ci=Math.pow(2,28),Pi=Math.pow(2,35),Ii=Math.pow(2,42),Fi=Math.pow(2,49),Ui=Math.pow(2,56),Mi=Math.pow(2,63),Hi=function(r){return r<Ti?1:r<Ni?2:r<zi?3:r<Ci?4:r<Pi?5:r<Ii?6:r<Fi?7:r<Ui?8:r<Mi?9:10},Oi={encode:Ai,decode:Li,encodingLength:Hi},Ri=Oi,Dt=Ri;var Lt=(r,t=0)=>[Dt.decode(r,t),Dt.decode.bytes],dt=(r,t,e=0)=>(Dt.encode(r,t,e),t),pt=r=>Dt.encodingLength(r);var mt={};C(mt,{coerce:()=>H,empty:()=>on,equals:()=>Be,fromHex:()=>qi,fromString:()=>Ae,isBinary:()=>Gi,toHex:()=>Vi,toString:()=>ke});var on=new Uint8Array(0),Vi=r=>r.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),""),qi=r=>{let t=r.match(/../g);return t?new Uint8Array(t.map(e=>parseInt(e,16))):on},Be=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},H=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},Gi=r=>r instanceof ArrayBuffer||ArrayBuffer.isView(r),Ae=r=>new TextEncoder().encode(r),ke=r=>new TextDecoder().decode(r);var ot=(r,t)=>{let e=t.byteLength,n=pt(r),i=n+pt(e),o=new Uint8Array(i+e);return dt(r,o,0),dt(e,o,n),o.set(t,i),new yt(r,e,t,o)},sn=r=>{let t=H(r),[e,n]=Lt(t),[i,o]=Lt(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new yt(e,i,s,t)},an=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Be(r.bytes,e.bytes)}},yt=class{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};var Te={};C(Te,{base58btc:()=>W,base58flickr:()=>Xi});function ji(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(e[s]!==255)throw new TypeError(o+" is ambiguous");e[s]=i}var f=r.length,a=r.charAt(0),h=Math.log(f)/Math.log(256),u=Math.log(256)/Math.log(f);function p(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var m=0,S=0,d=0,y=l.length;d!==y&&l[d]===0;)d++,m++;for(var w=(y-d)*u+1>>>0,b=new Uint8Array(w);d!==y;){for(var _=l[d],v=0,g=w-1;(_!==0||v<S)&&g!==-1;g--,v++)_+=256*b[g]>>>0,b[g]=_%f>>>0,_=_/f>>>0;if(_!==0)throw new Error("Non-zero carry");S=v,d++}for(var L=w-S;L!==w&&b[L]===0;)L++;for(var X=a.repeat(m);L<w;++L)X+=r.charAt(b[L]);return X}function D(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var m=0;if(l[m]!==" "){for(var S=0,d=0;l[m]===a;)S++,m++;for(var y=(l.length-m)*h+1>>>0,w=new Uint8Array(y);l[m];){var b=e[l.charCodeAt(m)];if(b===255)return;for(var _=0,v=y-1;(b!==0||_<d)&&v!==-1;v--,_++)b+=f*w[v]>>>0,w[v]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");d=_,m++}if(l[m]!==" "){for(var g=y-d;g!==y&&w[g]===0;)g++;for(var L=new Uint8Array(S+(y-g)),X=S;g!==y;)L[X++]=w[g++];return L}}}function c(l){var m=D(l);if(m)return m;throw new Error(`Non-${t} character`)}return{encode:p,decodeUnsafe:D,decode:c}}var $i=ji,Wi=$i,cn=Wi;var Se=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},De=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return fn(this,t)}},Le=class{constructor(t){this.decoders=t}or(t){return fn(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},fn=(r,t)=>new Le({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Ee=class{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new Se(t,e,n),this.decoder=new De(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},gt=({name:r,prefix:t,encode:e,decode:n})=>new Ee(r,t,e,n),et=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:i}=cn(e,t);return gt({prefix:r,name:t,encode:n,decode:o=>H(i(o))})},Ji=(r,t,e,n)=>{let i={};for(let u=0;u<t.length;++u)i[t[u]]=u;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),f=0,a=0,h=0;for(let u=0;u<o;++u){let p=i[r[u]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|p,f+=e,f>=8&&(f-=8,s[h++]=255&a>>f)}if(f>=e||255&a<<8-f)throw new SyntaxError("Unexpected end of data");return s},Ki=(r,t,e)=>{let n=t[t.length-1]==="=",i=(1<<e)-1,o="",s=0,f=0;for(let a=0;a<r.length;++a)for(f=f<<8|r[a],s+=8;s>e;)s-=e,o+=t[i&f>>s];if(s&&(o+=t[i&f<<e-s]),n)for(;o.length*e&7;)o+="=";return o},E=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>gt({prefix:t,name:r,encode(i){return Ki(i,n,e)},decode(i){return Ji(i,n,e,r)}});var W=et({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Xi=et({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ne={};C(Ne,{base32:()=>wt,base32hex:()=>to,base32hexpad:()=>ro,base32hexpadupper:()=>no,base32hexupper:()=>eo,base32pad:()=>Zi,base32padupper:()=>Yi,base32upper:()=>Qi,base32z:()=>io});var wt=E({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qi=E({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zi=E({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Yi=E({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),to=E({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),eo=E({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ro=E({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),no=E({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),io=E({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var un=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return so(e,ze(r),t||W.encoder);default:return ao(e,ze(r),t||wt.encoder)}};var hn=new WeakMap,ze=r=>{let t=hn.get(r);if(t==null){let e=new Map;return hn.set(r,e),e}return t},k=class{constructor(t,e,n,i){this.code=e,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Tt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==co)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return k.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=ot(t,e);return k.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return k.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&an(t.multihash,n.multihash)}toString(t){return un(this,t)}toJSON(){return{"/":un(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof k)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:o,bytes:s}=e;return new k(n,i,o,s||ln(n,i,o.bytes))}else if(e[fo]===!0){let{version:n,multihash:i,code:o}=e,s=sn(i);return k.create(n,o,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Tt)throw new Error(`Version 0 CID must use dag-pb (code: ${Tt}) block encoding`);return new k(t,e,n,n.bytes)}case 1:{let i=ln(t,e,n.bytes);return new k(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return k.create(0,Tt,t)}static createV1(t,e){return k.create(1,t,e)}static decode(t){let[e,n]=k.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=k.inspectBytes(t),n=e.size-e.multihashSize,i=H(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=i.subarray(e.multihashSize-e.digestSize),s=new yt(e.multihashCode,e.digestSize,o,i);return[e.version===0?k.createV0(s):k.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[p,D]=Lt(t.subarray(e));return e+=D,p},i=n(),o=Tt;if(i===18?(i=0,e=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=e,f=n(),a=n(),h=e+a,u=h-s;return{version:i,codec:o,multihashCode:f,digestSize:a,multihashSize:u,size:h}}static parse(t,e){let[n,i]=oo(t,e),o=k.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ze(o).set(n,t),o}},oo=(r,t)=>{switch(r[0]){case"Q":{let e=t||W;return[W.prefix,e.decode(`${W.prefix}${r}`)]}case W.prefix:{let e=t||W;return[W.prefix,e.decode(r)]}case wt.prefix:{let e=t||wt;return[wt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},so=(r,t,e)=>{let{prefix:n}=e;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return i},ao=(r,t,e)=>{let{prefix:n}=e,i=t.get(n);if(i==null){let o=e.encode(r);return t.set(n,o),o}else return i},Tt=112,co=18,ln=(r,t,e)=>{let n=pt(r),i=n+pt(t),o=new Uint8Array(i+e.byteLength);return dt(r,o,0),dt(t,o,n),o.set(e,i),o},fo=Symbol.for("@ipld/js-cid/CID");var zt={};C(zt,{code:()=>vo,createLink:()=>vn,createNode:()=>_n,decode:()=>Bo,encode:()=>U,name:()=>_o,prepare:()=>F,validate:()=>Ie});var uo=new TextDecoder;function Ce(r,t){let e=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(t>=r.length)throw new Error("protobuf: unexpected end of data");let i=r[t++];if(e+=n<28?(i&127)<<n:(i&127)*2**n,i<128)break}return[e,t]}function Kt(r,t){let e;[e,t]=Ce(r,t);let n=t+e;if(e<0||n<0)throw new Error("protobuf: invalid length");if(n>r.length)throw new Error("protobuf: unexpected end of data");return[r.subarray(t,n),n]}function dn(r,t){let e;return[e,t]=Ce(r,t),[e&7,e>>3,t]}function ho(r){let t={},e=r.length,n=0;for(;n<e;){let i,o;if([i,o,n]=dn(r,n),o===1){if(t.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Hash`);if(t.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(t.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[t.Hash,n]=Kt(r,n)}else if(o===2){if(t.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Name`);if(t.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let s;[s,n]=Kt(r,n),t.Name=uo.decode(s)}else if(o===3){if(t.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(i!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Tsize`);[t.Tsize,n]=Ce(r,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${o}`)}if(n>e)throw new Error("protobuf: (PBLink) unexpected end of data");return t}function pn(r){let t=r.length,e=0,n,i=!1,o;for(;e<t;){let f,a;if([f,a,e]=dn(r,e),f!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${f}`);if(a===1){if(o)throw new Error("protobuf: (PBNode) duplicate Data section");[o,e]=Kt(r,e),n&&(i=!0)}else if(a===2){if(i)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let h;[h,e]=Kt(r,e),n.push(ho(h))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${a}`)}if(e>t)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return o&&(s.Data=o),s.Links=n||[],s}var yn=new TextEncoder,mn=2**32,lo=2**31;function po(r,t){let e=t.length;if(typeof r.Tsize=="number"){if(r.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(r.Tsize))throw new Error("Tsize too large for encoding");e=Nt(t,e,r.Tsize)-1,t[e]=24}if(typeof r.Name=="string"){let n=yn.encode(r.Name);e-=n.length,t.set(n,e),e=Nt(t,e,n.length)-1,t[e]=18}return r.Hash&&(e-=r.Hash.length,t.set(r.Hash,e),e=Nt(t,e,r.Hash.length)-1,t[e]=10),t.length-e}function gn(r){let t=yo(r),e=new Uint8Array(t),n=t;if(r.Data&&(n-=r.Data.length,e.set(r.Data,n),n=Nt(e,n,r.Data.length)-1,e[n]=10),r.Links)for(let i=r.Links.length-1;i>=0;i--){let o=po(r.Links[i],e.subarray(0,n));n-=o,n=Nt(e,n,o)-1,e[n]=18}return e}function mo(r){let t=0;if(r.Hash){let e=r.Hash.length;t+=1+e+bt(e)}if(typeof r.Name=="string"){let e=yn.encode(r.Name).length;t+=1+e+bt(e)}return ty