@zenfs/core 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,7 @@
1
- var ZenFS=(()=>{var or=Object.create;var Et=Object.defineProperty,ar=Object.defineProperties,cr=Object.getOwnPropertyDescriptor,lr=Object.getOwnPropertyDescriptors,ur=Object.getOwnPropertyNames,mi=Object.getOwnPropertySymbols,gi=Object.getPrototypeOf,yi=Object.prototype.hasOwnProperty,dr=Object.prototype.propertyIsEnumerable,fr=Reflect.get;var ye=Math.pow,pi=(r,e,t)=>e in r?Et(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,q=(r,e)=>{for(var t in e||(e={}))yi.call(e,t)&&pi(r,t,e[t]);if(mi)for(var t of mi(e))dr.call(e,t)&&pi(r,t,e[t]);return r},Q=(r,e)=>ar(r,lr(e)),a=(r,e)=>Et(r,"name",{value:e,configurable:!0});var be=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Xt=(r,e)=>{for(var t in e)Et(r,t,{get:e[t],enumerable:!0})},bi=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ur(e))!yi.call(r,n)&&n!==t&&Et(r,n,{get:()=>e[n],enumerable:!(i=cr(e,n))||i.enumerable});return r};var vt=(r,e,t)=>(t=r!=null?or(gi(r)):{},bi(e||!r||!r.__esModule?Et(t,"default",{value:r,enumerable:!0}):t,r)),hr=r=>bi(Et({},"__esModule",{value:!0}),r);var wi=(r,e,t)=>fr(gi(r),t,e);var d=(r,e,t)=>new Promise((i,n)=>{var s=u=>{try{c(t.next(u))}catch(f){n(f)}},o=u=>{try{c(t.throw(u))}catch(f){n(f)}},c=u=>u.done?i(u.value):Promise.resolve(u.value).then(s,o);c((t=t.apply(r,e)).next())});var xi=be(Jt=>{"use strict";Jt.byteLength=pr;Jt.toByteArray=yr;Jt.fromByteArray=Sr;var tt=[],K=[],mr=typeof Uint8Array!="undefined"?Uint8Array:Array,we="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(mt=0,Si=we.length;mt<Si;++mt)tt[mt]=we[mt],K[we.charCodeAt(mt)]=mt;var mt,Si;K["-".charCodeAt(0)]=62;K["_".charCodeAt(0)]=63;function Fi(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var i=t===e?0:4-t%4;return[t,i]}a(Fi,"getLens");function pr(r){var e=Fi(r),t=e[0],i=e[1];return(t+i)*3/4-i}a(pr,"byteLength");function gr(r,e,t){return(e+t)*3/4-t}a(gr,"_byteLength");function yr(r){var e,t=Fi(r),i=t[0],n=t[1],s=new mr(gr(r,i,n)),o=0,c=n>0?i-4:i,u;for(u=0;u<c;u+=4)e=K[r.charCodeAt(u)]<<18|K[r.charCodeAt(u+1)]<<12|K[r.charCodeAt(u+2)]<<6|K[r.charCodeAt(u+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return n===2&&(e=K[r.charCodeAt(u)]<<2|K[r.charCodeAt(u+1)]>>4,s[o++]=e&255),n===1&&(e=K[r.charCodeAt(u)]<<10|K[r.charCodeAt(u+1)]<<4|K[r.charCodeAt(u+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}a(yr,"toByteArray");function br(r){return tt[r>>18&63]+tt[r>>12&63]+tt[r>>6&63]+tt[r&63]}a(br,"tripletToBase64");function wr(r,e,t){for(var i,n=[],s=e;s<t;s+=3)i=(r[s]<<16&16711680)+(r[s+1]<<8&65280)+(r[s+2]&255),n.push(br(i));return n.join("")}a(wr,"encodeChunk");function Sr(r){for(var e,t=r.length,i=t%3,n=[],s=16383,o=0,c=t-i;o<c;o+=s)n.push(wr(r,o,o+s>c?c:o+s));return i===1?(e=r[t-1],n.push(tt[e>>2]+tt[e<<4&63]+"==")):i===2&&(e=(r[t-2]<<8)+r[t-1],n.push(tt[e>>10]+tt[e>>4&63]+tt[e<<2&63]+"=")),n.join("")}a(Sr,"fromByteArray")});var Ei=be(Se=>{Se.read=function(r,e,t,i,n){var s,o,c=n*8-i-1,u=(1<<c)-1,f=u>>1,h=-7,m=t?n-1:0,g=t?-1:1,S=r[e+m];for(m+=g,s=S&(1<<-h)-1,S>>=-h,h+=c;h>0;s=s*256+r[e+m],m+=g,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=i;h>0;o=o*256+r[e+m],m+=g,h-=8);if(s===0)s=1-f;else{if(s===u)return o?NaN:(S?-1:1)*(1/0);o=o+Math.pow(2,i),s=s-f}return(S?-1:1)*o*Math.pow(2,s-i)};Se.write=function(r,e,t,i,n,s){var o,c,u,f=s*8-n-1,h=(1<<f)-1,m=h>>1,g=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=i?0:s-1,F=i?1:-1,b=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+m>=1?e+=g/u:e+=g*Math.pow(2,1-m),e*u>=2&&(o++,u/=2),o+m>=h?(c=0,o=h):o+m>=1?(c=(e*u-1)*Math.pow(2,n),o=o+m):(c=e*Math.pow(2,m-1)*Math.pow(2,n),o=0));n>=8;r[t+S]=c&255,S+=F,c/=256,n-=8);for(o=o<<n|c,f+=n;f>0;r[t+S]=o&255,S+=F,o/=256,f-=8);r[t+S-F]|=b*128}});var gt=be(_t=>{"use strict";var Fe=xi(),Ct=Ei();_t.Buffer=p;_t.SlowBuffer=_r;_t.INSPECT_MAX_BYTES=50;var qt=2147483647;_t.kMaxLength=qt;p.TYPED_ARRAY_SUPPORT=Fr();!p.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Fr(){try{var r=new Uint8Array(1);return r.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},r.foo()===42}catch(e){return!1}}a(Fr,"typedArraySupport");Object.defineProperty(p.prototype,"parent",{get:function(){if(this instanceof p)return this.buffer}});Object.defineProperty(p.prototype,"offset",{get:function(){if(this instanceof p)return this.byteOffset}});function it(r){if(r>qt)throw new RangeError("Invalid typed array length");var e=new Uint8Array(r);return e.__proto__=p.prototype,e}a(it,"createBuffer");function p(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return ve(r)}return ki(r,e,t)}a(p,"Buffer");typeof Symbol!="undefined"&&Symbol.species&&p[Symbol.species]===p&&Object.defineProperty(p,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1});p.poolSize=8192;function ki(r,e,t){if(typeof r=="number")throw new TypeError('"value" argument must not be a number');return Ee(r)||r&&Ee(r.buffer)?vr(r,e,t):typeof r=="string"?Er(r,e):Cr(r)}a(ki,"from");p.from=function(r,e,t){return ki(r,e,t)};p.prototype.__proto__=Uint8Array.prototype;p.__proto__=Uint8Array;function Ii(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('"size" argument must not be negative')}a(Ii,"assertSize");function xr(r,e,t){return Ii(r),r<=0?it(r):e!==void 0?typeof t=="string"?it(r).fill(e,t):it(r).fill(e):it(r)}a(xr,"alloc");p.alloc=function(r,e,t){return xr(r,e,t)};function ve(r){return Ii(r),it(r<0?0:Ce(r)|0)}a(ve,"allocUnsafe");p.allocUnsafe=function(r){return ve(r)};p.allocUnsafeSlow=function(r){return ve(r)};function Er(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!p.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var t=Ti(r,e)|0,i=it(t),n=i.write(r,e);return n!==t&&(i=i.slice(0,n)),i}a(Er,"fromString");function vi(r){for(var e=r.length<0?0:Ce(r.length)|0,t=it(e),i=0;i<e;i+=1)t[i]=r[i]&255;return t}a(vi,"fromArrayLike");function vr(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');var i;return e===void 0&&t===void 0?i=new Uint8Array(r):t===void 0?i=new Uint8Array(r,e):i=new Uint8Array(r,e,t),i.__proto__=p.prototype,i}a(vr,"fromArrayBuffer");function Cr(r){if(p.isBuffer(r)){var e=Ce(r.length)|0,t=it(e);return t.length===0||r.copy(t,0,0,e),t}if(r){if(ArrayBuffer.isView(r)||"length"in r)return typeof r.length!="number"||_e(r.length)?it(0):vi(r);if(r.type==="Buffer"&&Array.isArray(r.data))return vi(r.data)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.")}a(Cr,"fromObject");function Ce(r){if(r>=qt)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+qt.toString(16)+" bytes");return r|0}a(Ce,"checked");function _r(r){return+r!=r&&(r=0),p.alloc(+r)}a(_r,"SlowBuffer");p.isBuffer=a(function(e){return e!=null&&e._isBuffer===!0},"isBuffer");p.compare=a(function(e,t){if(!p.isBuffer(e)||!p.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var i=e.length,n=t.length,s=0,o=Math.min(i,n);s<o;++s)if(e[s]!==t[s]){i=e[s],n=t[s];break}return i<n?-1:n<i?1:0},"compare");p.isEncoding=a(function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},"isEncoding");p.concat=a(function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return p.alloc(0);var i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var n=p.allocUnsafe(t),s=0;for(i=0;i<e.length;++i){var o=e[i];if(ArrayBuffer.isView(o)&&(o=p.from(o)),!p.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,s),s+=o.length}return n},"concat");function Ti(r,e){if(p.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||Ee(r))return r.byteLength;typeof r!="string"&&(r=""+r);var t=r.length;if(t===0)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return xe(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Ri(r).length;default:if(i)return xe(r).length;e=(""+e).toLowerCase(),i=!0}}a(Ti,"byteLength");p.byteLength=Ti;function kr(r,e,t){var i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Lr(this,e,t);case"utf8":case"utf-8":return Bi(this,e,t);case"ascii":return Dr(this,e,t);case"latin1":case"binary":return Rr(this,e,t);case"base64":return Pr(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ur(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}a(kr,"slowToString");p.prototype._isBuffer=!0;function pt(r,e,t){var i=r[e];r[e]=r[t],r[t]=i}a(pt,"swap");p.prototype.swap16=a(function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)pt(this,t,t+1);return this},"swap16");p.prototype.swap32=a(function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)pt(this,t,t+3),pt(this,t+1,t+2);return this},"swap32");p.prototype.swap64=a(function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)pt(this,t,t+7),pt(this,t+1,t+6),pt(this,t+2,t+5),pt(this,t+3,t+4);return this},"swap64");p.prototype.toString=a(function(){var e=this.length;return e===0?"":arguments.length===0?Bi(this,0,e):kr.apply(this,arguments)},"toString");p.prototype.toLocaleString=p.prototype.toString;p.prototype.equals=a(function(e){if(!p.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:p.compare(this,e)===0},"equals");p.prototype.inspect=a(function(){var e="",t=_t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},"inspect");p.prototype.compare=a(function(e,t,i,n,s){if(!p.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),n===void 0&&(n=0),s===void 0&&(s=this.length),t<0||i>e.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&t>=i)return 0;if(n>=s)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,n>>>=0,s>>>=0,this===e)return 0;for(var o=s-n,c=i-t,u=Math.min(o,c),f=this.slice(n,s),h=e.slice(t,i),m=0;m<u;++m)if(f[m]!==h[m]){o=f[m],c=h[m];break}return o<c?-1:c<o?1:0},"compare");function Ni(r,e,t,i,n){if(r.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,_e(t)&&(t=n?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(n)return-1;t=r.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=p.from(e,i)),p.isBuffer(e))return e.length===0?-1:Ci(r,e,t,i,n);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):Ci(r,[e],t,i,n);throw new TypeError("val must be string, number or Buffer")}a(Ni,"bidirectionalIndexOf");function Ci(r,e,t,i,n){var s=1,o=r.length,c=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,o/=2,c/=2,t/=2}function u(S,F){return s===1?S[F]:S.readUInt16BE(F*s)}a(u,"read");var f;if(n){var h=-1;for(f=t;f<o;f++)if(u(r,f)===u(e,h===-1?0:f-h)){if(h===-1&&(h=f),f-h+1===c)return h*s}else h!==-1&&(f-=f-h),h=-1}else for(t+c>o&&(t=o-c),f=t;f>=0;f--){for(var m=!0,g=0;g<c;g++)if(u(r,f+g)!==u(e,g)){m=!1;break}if(m)return f}return-1}a(Ci,"arrayIndexOf");p.prototype.includes=a(function(e,t,i){return this.indexOf(e,t,i)!==-1},"includes");p.prototype.indexOf=a(function(e,t,i){return Ni(this,e,t,i,!0)},"indexOf");p.prototype.lastIndexOf=a(function(e,t,i){return Ni(this,e,t,i,!1)},"lastIndexOf");function Ir(r,e,t,i){t=Number(t)||0;var n=r.length-t;i?(i=Number(i),i>n&&(i=n)):i=n;var s=e.length;i>s/2&&(i=s/2);for(var o=0;o<i;++o){var c=parseInt(e.substr(o*2,2),16);if(_e(c))return o;r[t+o]=c}return o}a(Ir,"hexWrite");function Tr(r,e,t,i){return Ht(xe(e,r.length-t),r,t,i)}a(Tr,"utf8Write");function Oi(r,e,t,i){return Ht(Wr(e),r,t,i)}a(Oi,"asciiWrite");function Nr(r,e,t,i){return Oi(r,e,t,i)}a(Nr,"latin1Write");function Or(r,e,t,i){return Ht(Ri(e),r,t,i)}a(Or,"base64Write");function Br(r,e,t,i){return Ht(Kr(e,r.length-t),r,t,i)}a(Br,"ucs2Write");p.prototype.write=a(function(e,t,i,n){if(t===void 0)n="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")n=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-t;if((i===void 0||i>s)&&(i=s),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return Ir(this,e,t,i);case"utf8":case"utf-8":return Tr(this,e,t,i);case"ascii":return Oi(this,e,t,i);case"latin1":case"binary":return Nr(this,e,t,i);case"base64":return Or(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Br(this,e,t,i);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},"write");p.prototype.toJSON=a(function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},"toJSON");function Pr(r,e,t){return e===0&&t===r.length?Fe.fromByteArray(r):Fe.fromByteArray(r.slice(e,t))}a(Pr,"base64Slice");function Bi(r,e,t){t=Math.min(r.length,t);for(var i=[],n=e;n<t;){var s=r[n],o=null,c=s>239?4:s>223?3:s>191?2:1;if(n+c<=t){var u,f,h,m;switch(c){case 1:s<128&&(o=s);break;case 2:u=r[n+1],(u&192)===128&&(m=(s&31)<<6|u&63,m>127&&(o=m));break;case 3:u=r[n+1],f=r[n+2],(u&192)===128&&(f&192)===128&&(m=(s&15)<<12|(u&63)<<6|f&63,m>2047&&(m<55296||m>57343)&&(o=m));break;case 4:u=r[n+1],f=r[n+2],h=r[n+3],(u&192)===128&&(f&192)===128&&(h&192)===128&&(m=(s&15)<<18|(u&63)<<12|(f&63)<<6|h&63,m>65535&&m<1114112&&(o=m))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|o&1023),i.push(o),n+=c}return Ar(i)}a(Bi,"utf8Slice");var _i=4096;function Ar(r){var e=r.length;if(e<=_i)return String.fromCharCode.apply(String,r);for(var t="",i=0;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=_i));return t}a(Ar,"decodeCodePointsArray");function Dr(r,e,t){var i="";t=Math.min(r.length,t);for(var n=e;n<t;++n)i+=String.fromCharCode(r[n]&127);return i}a(Dr,"asciiSlice");function Rr(r,e,t){var i="";t=Math.min(r.length,t);for(var n=e;n<t;++n)i+=String.fromCharCode(r[n]);return i}a(Rr,"latin1Slice");function Lr(r,e,t){var i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);for(var n="",s=e;s<t;++s)n+=Vr(r[s]);return n}a(Lr,"hexSlice");function Ur(r,e,t){for(var i=r.slice(e,t),n="",s=0;s<i.length;s+=2)n+=String.fromCharCode(i[s]+i[s+1]*256);return n}a(Ur,"utf16leSlice");p.prototype.slice=a(function(e,t){var i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);var n=this.subarray(e,t);return n.__proto__=p.prototype,n},"slice");function O(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}a(O,"checkOffset");p.prototype.readUIntLE=a(function(e,t,i){e=e>>>0,t=t>>>0,i||O(e,t,this.length);for(var n=this[e],s=1,o=0;++o<t&&(s*=256);)n+=this[e+o]*s;return n},"readUIntLE");p.prototype.readUIntBE=a(function(e,t,i){e=e>>>0,t=t>>>0,i||O(e,t,this.length);for(var n=this[e+--t],s=1;t>0&&(s*=256);)n+=this[e+--t]*s;return n},"readUIntBE");p.prototype.readUInt8=a(function(e,t){return e=e>>>0,t||O(e,1,this.length),this[e]},"readUInt8");p.prototype.readUInt16LE=a(function(e,t){return e=e>>>0,t||O(e,2,this.length),this[e]|this[e+1]<<8},"readUInt16LE");p.prototype.readUInt16BE=a(function(e,t){return e=e>>>0,t||O(e,2,this.length),this[e]<<8|this[e+1]},"readUInt16BE");p.prototype.readUInt32LE=a(function(e,t){return e=e>>>0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},"readUInt32LE");p.prototype.readUInt32BE=a(function(e,t){return e=e>>>0,t||O(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},"readUInt32BE");p.prototype.readIntLE=a(function(e,t,i){e=e>>>0,t=t>>>0,i||O(e,t,this.length);for(var n=this[e],s=1,o=0;++o<t&&(s*=256);)n+=this[e+o]*s;return s*=128,n>=s&&(n-=Math.pow(2,8*t)),n},"readIntLE");p.prototype.readIntBE=a(function(e,t,i){e=e>>>0,t=t>>>0,i||O(e,t,this.length);for(var n=t,s=1,o=this[e+--n];n>0&&(s*=256);)o+=this[e+--n]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*t)),o},"readIntBE");p.prototype.readInt8=a(function(e,t){return e=e>>>0,t||O(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},"readInt8");p.prototype.readInt16LE=a(function(e,t){e=e>>>0,t||O(e,2,this.length);var i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i},"readInt16LE");p.prototype.readInt16BE=a(function(e,t){e=e>>>0,t||O(e,2,this.length);var i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i},"readInt16BE");p.prototype.readInt32LE=a(function(e,t){return e=e>>>0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},"readInt32LE");p.prototype.readInt32BE=a(function(e,t){return e=e>>>0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},"readInt32BE");p.prototype.readFloatLE=a(function(e,t){return e=e>>>0,t||O(e,4,this.length),Ct.read(this,e,!0,23,4)},"readFloatLE");p.prototype.readFloatBE=a(function(e,t){return e=e>>>0,t||O(e,4,this.length),Ct.read(this,e,!1,23,4)},"readFloatBE");p.prototype.readDoubleLE=a(function(e,t){return e=e>>>0,t||O(e,8,this.length),Ct.read(this,e,!0,52,8)},"readDoubleLE");p.prototype.readDoubleBE=a(function(e,t){return e=e>>>0,t||O(e,8,this.length),Ct.read(this,e,!1,52,8)},"readDoubleBE");function R(r,e,t,i,n,s){if(!p.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<s)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}a(R,"checkInt");p.prototype.writeUIntLE=a(function(e,t,i,n){if(e=+e,t=t>>>0,i=i>>>0,!n){var s=Math.pow(2,8*i)-1;R(this,e,t,i,s,0)}var o=1,c=0;for(this[t]=e&255;++c<i&&(o*=256);)this[t+c]=e/o&255;return t+i},"writeUIntLE");p.prototype.writeUIntBE=a(function(e,t,i,n){if(e=+e,t=t>>>0,i=i>>>0,!n){var s=Math.pow(2,8*i)-1;R(this,e,t,i,s,0)}var o=i-1,c=1;for(this[t+o]=e&255;--o>=0&&(c*=256);)this[t+o]=e/c&255;return t+i},"writeUIntBE");p.prototype.writeUInt8=a(function(e,t,i){return e=+e,t=t>>>0,i||R(this,e,t,1,255,0),this[t]=e&255,t+1},"writeUInt8");p.prototype.writeUInt16LE=a(function(e,t,i){return e=+e,t=t>>>0,i||R(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},"writeUInt16LE");p.prototype.writeUInt16BE=a(function(e,t,i){return e=+e,t=t>>>0,i||R(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},"writeUInt16BE");p.prototype.writeUInt32LE=a(function(e,t,i){return e=+e,t=t>>>0,i||R(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},"writeUInt32LE");p.prototype.writeUInt32BE=a(function(e,t,i){return e=+e,t=t>>>0,i||R(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},"writeUInt32BE");p.prototype.writeIntLE=a(function(e,t,i,n){if(e=+e,t=t>>>0,!n){var s=Math.pow(2,8*i-1);R(this,e,t,i,s-1,-s)}var o=0,c=1,u=0;for(this[t]=e&255;++o<i&&(c*=256);)e<0&&u===0&&this[t+o-1]!==0&&(u=1),this[t+o]=(e/c>>0)-u&255;return t+i},"writeIntLE");p.prototype.writeIntBE=a(function(e,t,i,n){if(e=+e,t=t>>>0,!n){var s=Math.pow(2,8*i-1);R(this,e,t,i,s-1,-s)}var o=i-1,c=1,u=0;for(this[t+o]=e&255;--o>=0&&(c*=256);)e<0&&u===0&&this[t+o+1]!==0&&(u=1),this[t+o]=(e/c>>0)-u&255;return t+i},"writeIntBE");p.prototype.writeInt8=a(function(e,t,i){return e=+e,t=t>>>0,i||R(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},"writeInt8");p.prototype.writeInt16LE=a(function(e,t,i){return e=+e,t=t>>>0,i||R(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},"writeInt16LE");p.prototype.writeInt16BE=a(function(e,t,i){return e=+e,t=t>>>0,i||R(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},"writeInt16BE");p.prototype.writeInt32LE=a(function(e,t,i){return e=+e,t=t>>>0,i||R(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},"writeInt32LE");p.prototype.writeInt32BE=a(function(e,t,i){return e=+e,t=t>>>0,i||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},"writeInt32BE");function Pi(r,e,t,i,n,s){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}a(Pi,"checkIEEE754");function Ai(r,e,t,i,n){return e=+e,t=t>>>0,n||Pi(r,e,t,4,34028234663852886e22,-34028234663852886e22),Ct.write(r,e,t,i,23,4),t+4}a(Ai,"writeFloat");p.prototype.writeFloatLE=a(function(e,t,i){return Ai(this,e,t,!0,i)},"writeFloatLE");p.prototype.writeFloatBE=a(function(e,t,i){return Ai(this,e,t,!1,i)},"writeFloatBE");function Di(r,e,t,i,n){return e=+e,t=t>>>0,n||Pi(r,e,t,8,17976931348623157e292,-17976931348623157e292),Ct.write(r,e,t,i,52,8),t+8}a(Di,"writeDouble");p.prototype.writeDoubleLE=a(function(e,t,i){return Di(this,e,t,!0,i)},"writeDoubleLE");p.prototype.writeDoubleBE=a(function(e,t,i){return Di(this,e,t,!1,i)},"writeDoubleBE");p.prototype.copy=a(function(e,t,i,n){if(!p.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-i&&(n=e.length-t+i);var s=n-i;if(this===e&&typeof Uint8Array.prototype.copyWithin=="function")this.copyWithin(t,i,n);else if(this===e&&i<t&&t<n)for(var o=s-1;o>=0;--o)e[o+t]=this[o+i];else Uint8Array.prototype.set.call(e,this.subarray(i,n),t);return s},"copy");p.prototype.fill=a(function(e,t,i,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!p.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(e.length===1){var s=e.charCodeAt(0);(n==="utf8"&&s<128||n==="latin1")&&(e=s)}}else typeof e=="number"&&(e=e&255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);var o;if(typeof e=="number")for(o=t;o<i;++o)this[o]=e;else{var c=p.isBuffer(e)?e:new p(e,n),u=c.length;if(u===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<i-t;++o)this[o+t]=c[o%u]}return this},"fill");var Mr=/[^+/0-9A-Za-z-_]/g;function zr(r){if(r=r.split("=")[0],r=r.trim().replace(Mr,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}a(zr,"base64clean");function Vr(r){return r<16?"0"+r.toString(16):r.toString(16)}a(Vr,"toHex");function xe(r,e){e=e||1/0;for(var t,i=r.length,n=null,s=[],o=0;o<i;++o){if(t=r.charCodeAt(o),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}a(xe,"utf8ToBytes");function Wr(r){for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}a(Wr,"asciiToBytes");function Kr(r,e){for(var t,i,n,s=[],o=0;o<r.length&&!((e-=2)<0);++o)t=r.charCodeAt(o),i=t>>8,n=t%256,s.push(n),s.push(i);return s}a(Kr,"utf16leToBytes");function Ri(r){return Fe.toByteArray(zr(r))}a(Ri,"base64ToBytes");function Ht(r,e,t,i){for(var n=0;n<i&&!(n+t>=e.length||n>=r.length);++n)e[n+t]=r[n];return n}a(Ht,"blitBuffer");function Ee(r){return r instanceof ArrayBuffer||r!=null&&r.constructor!=null&&r.constructor.name==="ArrayBuffer"&&typeof r.byteLength=="number"}a(Ee,"isArrayBuffer");function _e(r){return r!==r}a(_e,"numberIsNaN")});var no={};Xt(no,{ActionType:()=>ee,ApiError:()=>l,AsyncKeyValueFile:()=>At,AsyncKeyValueFileSystem:()=>ge,AsyncMirror:()=>nt,BaseFile:()=>Lt,BaseFileSystem:()=>Y,Cred:()=>v,ErrorCode:()=>A,ErrorStrings:()=>B,FileFlag:()=>x,FileIndex:()=>Dt,FileSystem:()=>lt,FileType:()=>C,FolderAdapter:()=>G,InMemory:()=>X,IndexDirInode:()=>ot,IndexFileInode:()=>Yt,NoSyncFile:()=>te,OverlayFS:()=>et,PreloadFile:()=>z,ROOT_NODE_ID:()=>j,SimpleSyncRWTransaction:()=>Tt,Stats:()=>k,SyncKeyValueFile:()=>Nt,SyncKeyValueFileSystem:()=>Ot,SynchronousFileSystem:()=>ut,backends:()=>me,checkOptions:()=>Oe,configure:()=>io,default:()=>ro,fs:()=>de,getEmptyDirNode:()=>Ut,getFileSystem:()=>sr,initialize:()=>nr,isIndexDirInode:()=>di,isIndexFileInode:()=>ir,mkdirpSync:()=>Wi,randomUUID:()=>St,registerBackend:()=>er,setImmediate:()=>Pn,toPromise:()=>Bn,wait:()=>On});var li={};Xt(li,{_toUnixTimestamp:()=>$i,access:()=>ws,accessSync:()=>Qs,appendFile:()=>qn,appendFileSync:()=>Ns,chmod:()=>ms,chmodSync:()=>qs,chown:()=>fs,chownSync:()=>Xs,close:()=>Gn,closeSync:()=>Bs,constants:()=>kt,createReadStream:()=>Es,createWriteStream:()=>vs,exists:()=>Vn,existsSync:()=>Ji,fchmod:()=>ns,fchmodSync:()=>Ms,fchown:()=>rs,fchownSync:()=>Us,fdatasync:()=>ts,fdatasyncSync:()=>Ds,fstat:()=>Hn,fstatSync:()=>Os,fsync:()=>Qn,fsyncSync:()=>As,ftruncate:()=>Zn,ftruncateSync:()=>Ps,futimes:()=>ss,futimesSync:()=>zs,getMount:()=>It,getMounts:()=>ji,initialize:()=>Xi,lchmod:()=>ps,lchmodSync:()=>Hs,lchown:()=>hs,lchownSync:()=>Js,link:()=>ls,linkSync:()=>$s,lstat:()=>Kn,lstatSync:()=>ks,lutimes:()=>ys,lutimesSync:()=>Zs,mkdir:()=>as,mkdirSync:()=>Ws,mount:()=>se,open:()=>jn,openSync:()=>Ts,promises:()=>zt,read:()=>is,readFile:()=>Xn,readFileSync:()=>Hi,readSync:()=>Ls,readdir:()=>cs,readdirSync:()=>Ks,readlink:()=>ds,readlinkSync:()=>js,realpath:()=>bs,realpathSync:()=>ci,rename:()=>zn,renameSync:()=>Cs,rmdir:()=>os,rmdirSync:()=>Vs,stat:()=>Wn,statSync:()=>_s,symlink:()=>us,symlinkSync:()=>Ys,truncate:()=>$n,truncateSync:()=>Is,umount:()=>Pe,unlink:()=>Yn,unlinkSync:()=>qi,unwatchFile:()=>Fs,utimes:()=>gs,utimesSync:()=>Gs,watch:()=>xs,watchFile:()=>Ss,write:()=>es,writeFile:()=>Jn,writeFileSync:()=>Gi,writeSync:()=>Rs});var ke=vt(gt(),1);var A=(b=>(b[b.EPERM=1]="EPERM",b[b.ENOENT=2]="ENOENT",b[b.EIO=5]="EIO",b[b.EBADF=9]="EBADF",b[b.EACCES=13]="EACCES",b[b.EBUSY=16]="EBUSY",b[b.EEXIST=17]="EEXIST",b[b.ENOTDIR=20]="ENOTDIR",b[b.EISDIR=21]="EISDIR",b[b.EINVAL=22]="EINVAL",b[b.EFBIG=27]="EFBIG",b[b.ENOSPC=28]="ENOSPC",b[b.EROFS=30]="EROFS",b[b.ENOTEMPTY=39]="ENOTEMPTY",b[b.ENOTSUP=95]="ENOTSUP",b))(A||{}),B={};B[1]="Operation not permitted.";B[2]="No such file or directory.";B[5]="Input/output error.";B[9]="Bad file descriptor.";B[13]="Permission denied.";B[16]="Resource busy or locked.";B[17]="File exists.";B[20]="File is not a directory.";B[21]="File is a directory.";B[22]="Invalid argument.";B[27]="File is too big.";B[28]="No space left on disk.";B[30]="Cannot modify a read-only file system.";B[39]="Directory is not empty.";B[95]="Operation is not supported.";var l=class extends Error{constructor(t,i=B[t],n){super(i);this.syscall="";this.errno=t,this.code=A[t],this.path=n,this.message=`Error: ${this.code}: ${i}${this.path?`, '${this.path}'`:""}`}static fromJSON(t){let i=new l(t.errno,t.message,t.path);return i.code=t.code,i.stack=t.stack,i}static fromBuffer(t,i=0){return l.fromJSON(JSON.parse(t.toString("utf8",i+4,i+4+t.readUInt32LE(i))))}static FileError(t,i){return new l(t,B[t],i)}static EACCES(t){return this.FileError(13,t)}static ENOENT(t){return this.FileError(2,t)}static EEXIST(t){return this.FileError(17,t)}static EISDIR(t){return this.FileError(21,t)}static ENOTDIR(t){return this.FileError(20,t)}static EPERM(t){return this.FileError(1,t)}static ENOTEMPTY(t){return this.FileError(39,t)}toString(){return this.message}toJSON(){return{errno:this.errno,code:this.code,path:this.path,stack:this.stack,message:this.message}}writeToBuffer(t=ke.Buffer.alloc(this.bufferSize()),i=0){let n=t.write(JSON.stringify(this.toJSON()),i+4);return t.writeUInt32LE(n,i),t}bufferSize(){return 4+ke.Buffer.byteLength(JSON.stringify(this.toJSON()))}};a(l,"ApiError");var $r="/",yt="/";function at(r,e){if(typeof r!="string")throw new TypeError(`"${e}" is not a string`)}a(at,"validateString");function Li(r,e){let t="",i=0,n=-1,s=0,o="\0";for(let c=0;c<=r.length;++c){if(c<r.length)o=r[c];else{if(o=="/")break;o="/"}if(o=="/"){if(!(n===c-1||s===1))if(s===2){if(t.length<2||i!==2||t.at(-1)!=="."||t.at(-2)!=="."){if(t.length>2){let u=t.lastIndexOf("/");u===-1?(t="",i=0):(t=t.slice(0,u),i=t.length-1-t.lastIndexOf("/")),n=c,s=0;continue}else if(t.length!==0){t="",i=0,n=c,s=0;continue}}e&&(t+=t.length>0?"/..":"..",i=2)}else t.length>0?t+="/"+r.slice(n+1,c):t=r.slice(n+1,c),i=c-n-1;n=c,s=0}else o==="."&&s!==-1?++s:s=-1}return t}a(Li,"normalizeString");function P(...r){let e="",t=!1;for(let i=r.length-1;i>=-1&&!t;i--){let n=i>=0?r[i]:$r;at(n,`paths[${i}]`),n.length!==0&&(e=`${n}/${e}`,t=n[0]==="/")}return e=Li(e,!t),t?`/${e}`:e.length>0?e:"."}a(P,"resolve");function Yr(r){if(at(r,"path"),r.length===0)return".";let e=r[0]==="/",t=r.at(-1)==="/";return r=Li(r,!e),r.length===0?e?"/":t?"./":".":(t&&(r+="/"),e?`/${r}`:r)}a(Yr,"normalize");function L(...r){if(r.length===0)return".";let e;for(let t=0;t<r.length;++t){let i=r[t];at(i,"path"),i.length>0&&(e===void 0?e=i:e+=`/${i}`)}return e===void 0?".":Yr(e)}a(L,"join");function Ui(r,e){if(at(r,"from"),at(e,"to"),r===e||(r=P(r),e=P(e),r===e))return"";let t=1,i=r.length,n=i-t,s=1,o=e.length-s,c=n<o?n:o,u=-1,f=0;for(;f<c;f++){let m=r[t+f];if(m!==e[s+f])break;m==="/"&&(u=f)}if(f===c)if(o>c){if(e[s+f]==="/")return e.slice(s+f+1);if(f===0)return e.slice(s+f)}else n>c&&(r[t+f]==="/"?u=f:f===0&&(u=0));let h="";for(f=t+u+1;f<=i;++f)(f===i||r[f]==="/")&&(h+=h.length===0?"..":"/..");return`${h}${e.slice(s+u)}`}a(Ui,"relative");function E(r){if(at(r,"path"),r.length===0)return".";let e=r[0]==="/",t=-1,i=!0;for(let n=r.length-1;n>=1;--n)if(r[n]==="/"){if(!i){t=n;break}}else i=!1;return t===-1?e?"/":".":e&&t===1?"//":r.slice(0,t)}a(E,"dirname");function D(r,e){e!==void 0&&at(e,"ext"),at(r,"path");let t=0,i=-1,n=!0;if(e!==void 0&&e.length>0&&e.length<=r.length){if(e===r)return"";let s=e.length-1,o=-1;for(let c=r.length-1;c>=0;--c)if(r[c]==="/"){if(!n){t=c+1;break}}else o===-1&&(n=!1,o=c+1),s>=0&&(r[c]===e[s]?--s===-1&&(i=c):(s=-1,i=o));return t===i?i=o:i===-1&&(i=r.length),r.slice(t,i)}for(let s=r.length-1;s>=0;--s)if(r[s]==="/"){if(!n){t=s+1;break}}else i===-1&&(n=!1,i=s+1);return i===-1?"":r.slice(t,i)}a(D,"basename");var Te=class{constructor(e,t,i,n,s,o){this.uid=e;this.gid=t;this.suid=i;this.sgid=n;this.euid=s;this.egid=o}},v=Te;a(v,"Cred"),v.Root=new Te(0,0,0,0,0,0);var kt={};Xt(kt,{COPYFILE_EXCL:()=>Jr,COPYFILE_FICLONE:()=>qr,COPYFILE_FICLONE_FORCE:()=>Hr,F_OK:()=>jr,O_APPEND:()=>sn,O_CREAT:()=>tn,O_DIRECT:()=>fn,O_DIRECTORY:()=>on,O_DSYNC:()=>un,O_EXCL:()=>en,O_NOATIME:()=>an,O_NOCTTY:()=>rn,O_NOFOLLOW:()=>cn,O_NONBLOCK:()=>hn,O_RDONLY:()=>Gr,O_RDWR:()=>Qr,O_SYMLINK:()=>dn,O_SYNC:()=>ln,O_TRUNC:()=>nn,O_WRONLY:()=>Zr,R_OK:()=>rt,S_IFBLK:()=>pn,S_IFCHR:()=>mn,S_IFDIR:()=>Zt,S_IFIFO:()=>gn,S_IFLNK:()=>Qt,S_IFMT:()=>$,S_IFREG:()=>Gt,S_IFSOCK:()=>yn,S_IRGRP:()=>En,S_IROTH:()=>kn,S_IRUSR:()=>wn,S_IRWXG:()=>xn,S_IRWXO:()=>_n,S_IRWXU:()=>bn,S_IWGRP:()=>vn,S_IWOTH:()=>In,S_IWUSR:()=>Sn,S_IXGRP:()=>Cn,S_IXOTH:()=>Tn,S_IXUSR:()=>Fn,W_OK:()=>ct,X_OK:()=>Xr});var jr=0,rt=4,ct=2,Xr=1,Jr=1,qr=2,Hr=4,Gr=0,Zr=1,Qr=2,tn=64,en=128,rn=256,nn=512,sn=1024,on=65536,an=262144,cn=131072,ln=1052672,un=4096,dn=32768,fn=16384,hn=2048,$=61440,Gt=32768,Zt=16384,mn=8192,pn=24576,gn=4096,Qt=40960,yn=49152,bn=448,wn=256,Sn=128,Fn=64,xn=56,En=32,vn=16,Cn=8,_n=7,kn=4,In=2,Tn=1;var Mi=vt(gt(),1);var C=(i=>(i[i.FILE=32768]="FILE",i[i.DIRECTORY=16384]="DIRECTORY",i[i.SYMLINK=40960]="SYMLINK",i))(C||{}),k=class{constructor(e,t,i,n,s,o,c,u,f){this.dev=0;this.ino=0;this.rdev=0;this.nlink=1;this.blksize=4096;this.uid=0;this.gid=0;this.fileData=null;this.size=t;let h=0;if(typeof n!="number"&&(h=Date.now(),n=h),typeof s!="number"&&(h||(h=Date.now()),s=h),typeof o!="number"&&(h||(h=Date.now()),o=h),typeof f!="number"&&(h||(h=Date.now()),f=h),typeof c!="number"&&(c=0),typeof u!="number"&&(u=0),this.atimeMs=n,this.ctimeMs=o,this.mtimeMs=s,this.birthtimeMs=f,i)this.mode=i;else switch(e){case C.FILE:this.mode=420;break;case C.DIRECTORY:default:this.mode=511}this.blocks=Math.ceil(t/512),this.mode&61440||(this.mode|=e)}static fromBuffer(e){let t=e.readUInt32LE(0),i=e.readUInt32LE(4),n=e.readDoubleLE(8),s=e.readDoubleLE(16),o=e.readDoubleLE(24),c=e.readUInt32LE(32),u=e.readUInt32LE(36);return new k(i&61440,t,i&-61441,n,s,o,c,u)}static clone(e){return new k(e.mode&61440,e.size,e.mode&-61441,e.atimeMs,e.mtimeMs,e.ctimeMs,e.uid,e.gid,e.birthtimeMs)}get atime(){return new Date(this.atimeMs)}get mtime(){return new Date(this.mtimeMs)}get ctime(){return new Date(this.ctimeMs)}get birthtime(){return new Date(this.birthtimeMs)}toBuffer(){let e=Mi.Buffer.alloc(32);return e.writeUInt32LE(this.size,0),e.writeUInt32LE(this.mode,4),e.writeDoubleLE(this.atime.getTime(),8),e.writeDoubleLE(this.mtime.getTime(),16),e.writeDoubleLE(this.ctime.getTime(),24),e.writeUInt32LE(this.uid,32),e.writeUInt32LE(this.gid,36),e}isFile(){return(this.mode&61440)===32768}isDirectory(){return(this.mode&61440)===16384}isSymbolicLink(){return(this.mode&61440)===40960}hasAccess(e,t){if(t.euid===0||t.egid===0)return!0;let i=this.mode&-61441,n=15,s=15,o=15;if(t.euid==this.uid){let f=(3840&i)>>8;n=(e^f)&e}if(t.egid==this.gid){let f=(240&i)>>4;s=(e^f)&e}let c=15&i;return o=(e^c)&e,!(n&s&o)}getCred(e=this.uid,t=this.gid){return new v(e,t,this.uid,this.gid,e,t)}chmod(e){this.mode=this.mode&61440|e}chown(e,t){!isNaN(+e)&&0<=+e&&+e<ye(2,32)&&(this.uid=e),!isNaN(+t)&&0<=+t&&+t<ye(2,32)&&(this.gid=t)}isSocket(){return!1}isBlockDevice(){return!1}isCharacterDevice(){return!1}isFIFO(){return!1}};a(k,"Stats");var Rt=vt(gt(),1);var ee=(n=>(n[n.NOP=0]="NOP",n[n.THROW_EXCEPTION=1]="THROW_EXCEPTION",n[n.TRUNCATE_FILE=2]="TRUNCATE_FILE",n[n.CREATE_FILE=3]="CREATE_FILE",n))(ee||{}),bt=class{static getFileFlag(e){return bt.flagCache.has(e)||bt.flagCache.set(e,new bt(e)),bt.flagCache.get(e)}constructor(e){if(this.flagStr=e,bt.validFlagStrs.indexOf(e)<0)throw new l(22,"Invalid flag: "+e)}getFlagString(){return this.flagStr}getMode(){let e=0;return e<<=1,e+=+this.isReadable(),e<<=1,e+=+this.isWriteable(),e<<=1,e}isReadable(){return this.flagStr.indexOf("r")!==-1||this.flagStr.indexOf("+")!==-1}isWriteable(){return this.flagStr.indexOf("w")!==-1||this.flagStr.indexOf("a")!==-1||this.flagStr.indexOf("+")!==-1}isTruncating(){return this.flagStr.indexOf("w")!==-1}isAppendable(){return this.flagStr.indexOf("a")!==-1}isSynchronous(){return this.flagStr.indexOf("s")!==-1}isExclusive(){return this.flagStr.indexOf("x")!==-1}pathExistsAction(){return this.isExclusive()?1:this.isTruncating()?2:0}pathNotExistsAction(){return(this.isWriteable()||this.isAppendable())&&this.flagStr!=="r+"?3:1}},x=bt;a(x,"FileFlag"),x.flagCache=new Map,x.validFlagStrs=["r","r+","rs","rs+","w","wx","w+","wx+","a","ax","a+","ax+"];var Lt=class{sync(){return d(this,null,function*(){throw new l(95)})}syncSync(){throw new l(95)}datasync(){return d(this,null,function*(){return this.sync()})}datasyncSync(){return this.syncSync()}chown(e,t){return d(this,null,function*(){throw new l(95)})}chownSync(e,t){throw new l(95)}chmod(e){return d(this,null,function*(){throw new l(95)})}chmodSync(e){throw new l(95)}utimes(e,t){return d(this,null,function*(){throw new l(95)})}utimesSync(e,t){throw new l(95)}};a(Lt,"BaseFile");var z=class extends Lt{constructor(t,i,n,s,o){super();this._pos=0;this._dirty=!1;if(this._fs=t,this._path=i,this._flag=n,this._stat=s,this._buffer=o||Rt.Buffer.alloc(0),this._stat.size!==this._buffer.length&&this._flag.isReadable())throw new Error(`Invalid buffer: Buffer is ${this._buffer.length} long, yet Stats object specifies that file is ${this._stat.size} long.`)}getBuffer(){return this._buffer}getStats(){return this._stat}getFlag(){return this._flag}getPath(){return this._path}getPos(){return this._flag.isAppendable()?this._stat.size:this._pos}advancePos(t){return this._pos+=t}setPos(t){return this._pos=t}sync(){return d(this,null,function*(){this.syncSync()})}syncSync(){throw new l(95)}close(){return d(this,null,function*(){this.closeSync()})}closeSync(){throw new l(95)}stat(){return d(this,null,function*(){return k.clone(this._stat)})}statSync(){return k.clone(this._stat)}truncate(t){if(this.truncateSync(t),this._flag.isSynchronous()&&!It("/").metadata.synchronous)return this.sync()}truncateSync(t){if(this._dirty=!0,!this._flag.isWriteable())throw new l(1,"File not opened with a writeable mode.");if(this._stat.mtimeMs=Date.now(),t>this._buffer.length){let n=Rt.Buffer.alloc(t-this._buffer.length,0);this.writeSync(n,0,n.length,this._buffer.length),this._flag.isSynchronous()&&It("/").metadata.synchronous&&this.syncSync();return}this._stat.size=t;let i=Rt.Buffer.alloc(t);this._buffer.copy(i,0,0,t),this._buffer=i,this._flag.isSynchronous()&&It("/").metadata.synchronous&&this.syncSync()}write(t,i,n,s){return d(this,null,function*(){return this.writeSync(t,i,n,s)})}writeSync(t,i,n,s){if(this._dirty=!0,s==null&&(s=this.getPos()),!this._flag.isWriteable())throw new l(1,"File not opened with a writeable mode.");let o=s+n;if(o>this._stat.size&&(this._stat.size=o,o>this._buffer.length)){let u=Rt.Buffer.alloc(o);this._buffer.copy(u),this._buffer=u}let c=t.copy(this._buffer,s,i,i+n);return this._stat.mtimeMs=Date.now(),this._flag.isSynchronous()?(this.syncSync(),c):(this.setPos(s+c),c)}read(t,i,n,s){return d(this,null,function*(){return{bytesRead:this.readSync(t,i,n,s),buffer:t}})}readSync(t,i,n,s){if(!this._flag.isReadable())throw new l(1,"File not opened with a readable mode.");s==null&&(s=this.getPos()),s+n>this._stat.size&&(n=this._stat.size-s);let c=this._buffer.copy(t,i,s,s+n);return this._stat.atimeMs=Date.now(),this._pos=s+n,c}chmod(t){return d(this,null,function*(){this.chmodSync(t)})}chmodSync(t){if(!this._fs.metadata.supportsProperties)throw new l(95);this._dirty=!0,this._stat.chmod(t),this.syncSync()}chown(t,i){return d(this,null,function*(){this.chownSync(t,i)})}chownSync(t,i){if(!this._fs.metadata.supportsProperties)throw new l(95);this._dirty=!0,this._stat.chown(t,i),this.syncSync()}isDirty(){return this._dirty}resetDirty(){this._dirty=!1}};a(z,"PreloadFile");var te=class extends z{constructor(e,t,i,n,s){super(e,t,i,n,s)}sync(){return d(this,null,function*(){})}syncSync(){}close(){return d(this,null,function*(){})}closeSync(){}};a(te,"NoSyncFile");var wt=vt(gt(),1);var lt=class{constructor(e){}};a(lt,"FileSystem");var Ne=class extends lt{constructor(t){super();this._ready=Promise.resolve(this)}get metadata(){return{name:this.constructor.name,readonly:!1,synchronous:!1,supportsProperties:!1,supportsLinks:!1,totalSpace:0,freeSpace:0}}whenReady(){return this._ready}openFile(t,i,n){return d(this,null,function*(){throw new l(95)})}createFile(t,i,n,s){return d(this,null,function*(){throw new l(95)})}open(t,i,n,s){return d(this,null,function*(){try{let o=yield this.stat(t,s);switch(i.pathExistsAction()){case 1:throw l.EEXIST(t);case 2:let c=yield this.openFile(t,i,s);if(!c)throw new Error("BFS has reached an impossible code path; please file a bug.");return yield c.truncate(0),yield c.sync(),c;case 0:return this.openFile(t,i,s);default:throw new l(22,"Invalid FileFlag object.")}}catch(o){switch(i.pathNotExistsAction()){case 3:let c=yield this.stat(E(t),s);if(c&&!c.isDirectory())throw l.ENOTDIR(E(t));return this.createFile(t,i,n,s);case 1:throw l.ENOENT(t);default:throw new l(22,"Invalid FileFlag object.")}}})}access(t,i,n){return d(this,null,function*(){throw new l(95)})}accessSync(t,i,n){throw new l(95)}rename(t,i,n){return d(this,null,function*(){throw new l(95)})}renameSync(t,i,n){throw new l(95)}stat(t,i){return d(this,null,function*(){throw new l(95)})}statSync(t,i){throw new l(95)}openFileSync(t,i,n){throw new l(95)}createFileSync(t,i,n,s){throw new l(95)}openSync(t,i,n,s){let o;try{o=this.statSync(t,s)}catch(c){switch(i.pathNotExistsAction()){case 3:if(!this.statSync(E(t),s).isDirectory())throw l.ENOTDIR(E(t));return this.createFileSync(t,i,n,s);case 1:throw l.ENOENT(t);default:throw new l(22,"Invalid FileFlag object.")}}if(!o.hasAccess(n,s))throw l.EACCES(t);switch(i.pathExistsAction()){case 1:throw l.EEXIST(t);case 2:return this.unlinkSync(t,s),this.createFileSync(t,i,o.mode,s);case 0:return this.openFileSync(t,i,s);default:throw new l(22,"Invalid FileFlag object.")}}unlink(t,i){return d(this,null,function*(){throw new l(95)})}unlinkSync(t,i){throw new l(95)}rmdir(t,i){return d(this,null,function*(){throw new l(95)})}rmdirSync(t,i){throw new l(95)}mkdir(t,i,n){return d(this,null,function*(){throw new l(95)})}mkdirSync(t,i,n){throw new l(95)}readdir(t,i){return d(this,null,function*(){throw new l(95)})}readdirSync(t,i){throw new l(95)}exists(t,i){return d(this,null,function*(){try{return yield this.stat(t,i),!0}catch(n){return!1}})}existsSync(t,i){try{return this.statSync(t,i),!0}catch(n){return!1}}realpath(t,i){return d(this,null,function*(){if(this.metadata.supportsLinks){let n=t.split(yt);for(let s=0;s<n.length;s++){let o=n.slice(0,s+1);n[s]=L(...o)}return n.join(yt)}else{if(!(yield this.exists(t,i)))throw l.ENOENT(t);return t}})}realpathSync(t,i){if(this.metadata.supportsLinks){let n=t.split(yt);for(let s=0;s<n.length;s++){let o=n.slice(0,s+1);n[s]=L(...o)}return n.join(yt)}else{if(this.existsSync(t,i))return t;throw l.ENOENT(t)}}truncate(t,i,n){return d(this,null,function*(){let s=yield this.open(t,x.getFileFlag("r+"),420,n);try{yield s.truncate(i)}finally{yield s.close()}})}truncateSync(t,i,n){let s=this.openSync(t,x.getFileFlag("r+"),420,n);try{s.truncateSync(i)}finally{s.closeSync()}}readFile(t,i,n,s){return d(this,null,function*(){let o=yield this.open(t,n,420,s);try{let c=yield o.stat(),u=wt.Buffer.alloc(c.size);return yield o.read(u,0,c.size,0),yield o.close(),i===null?u:u.toString(i)}finally{yield o.close()}})}readFileSync(t,i,n,s){let o=this.openSync(t,n,420,s);try{let c=o.statSync(),u=wt.Buffer.alloc(c.size);return o.readSync(u,0,c.size,0),o.closeSync(),i===null?u:u.toString(i)}finally{o.closeSync()}}writeFile(t,i,n,s,o,c){return d(this,null,function*(){let u=yield this.open(t,s,o,c);try{typeof i=="string"&&(i=wt.Buffer.from(i,n)),yield u.write(i,0,i.length,0)}finally{yield u.close()}})}writeFileSync(t,i,n,s,o,c){let u=this.openSync(t,s,o,c);try{typeof i=="string"&&(i=wt.Buffer.from(i,n)),u.writeSync(i,0,i.length,0)}finally{u.closeSync()}}appendFile(t,i,n,s,o,c){return d(this,null,function*(){let u=yield this.open(t,s,o,c);try{typeof i=="string"&&(i=wt.Buffer.from(i,n)),yield u.write(i,0,i.length,null)}finally{yield u.close()}})}appendFileSync(t,i,n,s,o,c){let u=this.openSync(t,s,o,c);try{typeof i=="string"&&(i=wt.Buffer.from(i,n)),u.writeSync(i,0,i.length,null)}finally{u.closeSync()}}chmod(t,i,n){return d(this,null,function*(){throw new l(95)})}chmodSync(t,i,n){throw new l(95)}chown(t,i,n,s){return d(this,null,function*(){throw new l(95)})}chownSync(t,i,n,s){throw new l(95)}utimes(t,i,n,s){return d(this,null,function*(){throw new l(95)})}utimesSync(t,i,n,s){throw new l(95)}link(t,i,n){return d(this,null,function*(){throw new l(95)})}linkSync(t,i,n){throw new l(95)}symlink(t,i,n,s){return d(this,null,function*(){throw new l(95)})}symlinkSync(t,i,n,s){throw new l(95)}readlink(t,i){return d(this,null,function*(){throw new l(95)})}readlinkSync(t,i){throw new l(95)}},Y=Ne;a(Y,"BaseFileSystem"),Y.Name=Ne.name;var ut=class extends Y{get metadata(){return Q(q({},super.metadata),{synchronous:!0})}access(e,t,i){return d(this,null,function*(){return this.accessSync(e,t,i)})}rename(e,t,i){return d(this,null,function*(){return this.renameSync(e,t,i)})}stat(e,t){return d(this,null,function*(){return this.statSync(e,t)})}open(e,t,i,n){return d(this,null,function*(){return this.openSync(e,t,i,n)})}unlink(e,t){return d(this,null,function*(){return this.unlinkSync(e,t)})}rmdir(e,t){return d(this,null,function*(){return this.rmdirSync(e,t)})}mkdir(e,t,i){return d(this,null,function*(){return this.mkdirSync(e,t,i)})}readdir(e,t){return d(this,null,function*(){return this.readdirSync(e,t)})}chmod(e,t,i){return d(this,null,function*(){return this.chmodSync(e,t,i)})}chown(e,t,i,n){return d(this,null,function*(){return this.chownSync(e,t,i,n)})}utimes(e,t,i,n){return d(this,null,function*(){return this.utimesSync(e,t,i,n)})}link(e,t,i){return d(this,null,function*(){return this.linkSync(e,t,i)})}symlink(e,t,i,n){return d(this,null,function*(){return this.symlinkSync(e,t,i,n)})}readlink(e,t){return d(this,null,function*(){return this.readlinkSync(e,t)})}};a(ut,"SynchronousFileSystem");var zi=vt(gt(),1);var U=class{constructor(e,t,i,n,s,o,c,u){this.id=e;this.size=t;this.mode=i;this.atime=n;this.mtime=s;this.ctime=o;this.uid=c;this.gid=u}static fromBuffer(e){if(e===void 0)throw new Error("NO");return new U(e.toString("ascii",38),e.readUInt32LE(0),e.readUInt16LE(4),e.readDoubleLE(6),e.readDoubleLE(14),e.readDoubleLE(22),e.readUInt32LE(30),e.readUInt32LE(34))}toStats(){return new k((this.mode&61440)===C.DIRECTORY?C.DIRECTORY:C.FILE,this.size,this.mode,this.atime,this.mtime,this.ctime,this.uid,this.gid)}getSize(){return 38+this.id.length}toBuffer(e=zi.Buffer.alloc(this.getSize())){return e.writeUInt32LE(this.size,0),e.writeUInt16LE(this.mode,4),e.writeDoubleLE(this.atime,6),e.writeDoubleLE(this.mtime,14),e.writeDoubleLE(this.ctime,22),e.writeUInt32LE(this.uid,30),e.writeUInt32LE(this.gid,34),e.write(this.id,38,this.id.length,"ascii"),e}update(e){let t=!1;this.size!==e.size&&(this.size=e.size,t=!0),this.mode!==e.mode&&(this.mode=e.mode,t=!0);let i=e.atime.getTime();this.atime!==i&&(this.atime=i,t=!0);let n=e.mtime.getTime();this.mtime!==n&&(this.mtime=n,t=!0);let s=e.ctime.getTime();return this.ctime!==s&&(this.ctime=s,t=!0),this.uid!==e.uid&&(this.uid=e.uid,t=!0),this.uid!==e.uid&&(this.uid=e.uid,t=!0),t}isFile(){return(this.mode&61440)===C.FILE}isDirectory(){return(this.mode&61440)===C.DIRECTORY}};a(U,"Inode");var Vi=vt(gt(),1);function Wi(r,e,t,i){i.existsSync(r,t)||(Wi(E(r),e,t,i),i.mkdirSync(r,e,t))}a(Wi,"mkdirpSync");function ie(r,e,t,i,n){return Math.min(r+1,e+1,t+1,i===n?e:e+1)}a(ie,"_min");function Nn(r,e){if(r===e)return 0;r.length>e.length&&([r,e]=[e,r]);let t=r.length,i=e.length;for(;t>0&&r.charCodeAt(t-1)===e.charCodeAt(i-1);)t--,i--;let n=0;for(;n<t&&r.charCodeAt(n)===e.charCodeAt(n);)n++;if(t-=n,i-=n,t===0||i===1)return i;let s=new Array(t<<1);for(let g=0;g<t;)s[t+g]=r.charCodeAt(n+g),s[g]=++g;let o,c,u,f,h;for(o=0;o+3<i;){let g=e.charCodeAt(n+(c=o)),S=e.charCodeAt(n+(u=o+1)),F=e.charCodeAt(n+(f=o+2)),b=e.charCodeAt(n+(h=o+3)),Z=o+=4;for(let xt=0;xt<t;){let jt=s[t+xt],hi=s[xt];c=ie(hi,c,u,g,jt),u=ie(c,u,f,S,jt),f=ie(u,f,h,F,jt),Z=ie(f,h,Z,b,jt),s[xt++]=Z,h=f,f=u,u=c,c=hi}}let m=0;for(;o<i;){let g=e.charCodeAt(n+(c=o));m=++o;for(let S=0;S<t;S++){let F=s[S];s[S]=m=F<c||m<c?F>m?m+1:F+1:g===s[t+S]?c:c+1,c=F}}return m}a(Nn,"levenshtein");function Oe(r,e){return d(this,null,function*(){let t=r.Options,i=r.Name,n=0,s=!1,o=!1;for(let c in t)if(Object.prototype.hasOwnProperty.call(t,c)){let u=t[c],f=e&&e[c];if(f==null){if(!u.optional){let h=Object.keys(e).filter(m=>!(m in t)).map(m=>({str:m,distance:Nn(c,m)})).filter(m=>m.distance<5).sort((m,g)=>m.distance-g.distance);if(s)return;throw s=!0,new l(22,`[${i}] Required option '${c}' not provided.${h.length>0?` You provided unrecognized option '${h[0].str}'; perhaps you meant to type '${c}'.`:""}
2
- Option description: ${u.description}`)}}else{let h=!1;if(Array.isArray(u.type)?h=u.type.indexOf(typeof f)!==-1:h=typeof f===u.type,h){if(u.validator){n++;try{yield u.validator(f)}catch(m){if(!s){if(m)throw s=!0,m;if(n--,n===0&&o)return}}}}else{if(s)return;throw s=!0,new l(22,`[${i}] Value provided for option ${c} is not the proper type. Expected ${Array.isArray(u.type)?`one of {${u.type.join(", ")}}`:u.type}, but received ${typeof f}
3
- Option description: ${u.description}`)}}}o=!0})}a(Oe,"checkOptions");function On(r){return new Promise(e=>{setTimeout(e,r)})}a(On,"wait");function Bn(r){return function(...e){return new Promise((t,i)=>{e.push((n,...s)=>{n?i(n):t(s[0])}),r(...e)})}}a(Bn,"toPromise");var Pn=typeof globalThis.setImmediate=="function"?globalThis.setImmediate:r=>setTimeout(r,0),j="/";function Ut(){return Vi.Buffer.from("{}")}a(Ut,"getEmptyDirNode");function St(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}a(St,"randomUUID");var Tt=class{constructor(e){this.store=e;this.originalData={};this.modifiedKeys=[]}get(e){let t=this.store.get(e);return this.stashOldValue(e,t),t}put(e,t,i){return this.markModified(e),this.store.put(e,t,i)}del(e){this.markModified(e),this.store.del(e)}commit(){}abort(){for(let e of this.modifiedKeys){let t=this.originalData[e];t?this.store.put(e,t,!0):this.store.del(e)}}_has(e){return Object.prototype.hasOwnProperty.call(this.originalData,e)}stashOldValue(e,t){this._has(e)||(this.originalData[e]=t)}markModified(e){this.modifiedKeys.indexOf(e)===-1&&(this.modifiedKeys.push(e),this._has(e)||(this.originalData[e]=this.store.get(e)))}};a(Tt,"SimpleSyncRWTransaction");var Nt=class extends z{constructor(e,t,i,n,s){super(e,t,i,n,s)}syncSync(){this.isDirty()&&(this._fs._syncSync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())}closeSync(){this.syncSync()}};a(Nt,"SyncKeyValueFile");var Ot=class extends ut{constructor(t){super();this.store=t.store,this.makeRootDirectory()}static isAvailable(){return!0}getName(){return this.store.name()}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!0}supportsSynch(){return!0}empty(){this.store.clear(),this.makeRootDirectory()}accessSync(t,i,n){let s=this.store.beginTransaction("readonly");if(!this.findINode(s,t).toStats().hasAccess(i,n))throw l.EACCES(t)}renameSync(t,i,n){let s=this.store.beginTransaction("readwrite"),o=E(t),c=D(t),u=E(i),f=D(i),h=this.findINode(s,o),m=this.getDirListing(s,o,h);if(!h.toStats().hasAccess(2,n))throw l.EACCES(t);if(!m[c])throw l.ENOENT(t);let g=m[c];if(delete m[c],(u+"/").indexOf(t+"/")===0)throw new l(16,o);let S,F;if(u===o?(S=h,F=m):(S=this.findINode(s,u),F=this.getDirListing(s,u,S)),F[f]){let b=this.getINode(s,i,F[f]);if(b.isFile())try{s.del(b.id),s.del(F[f])}catch(Z){throw s.abort(),Z}else throw l.EPERM(i)}F[f]=g;try{s.put(h.id,Buffer.from(JSON.stringify(m)),!0),s.put(S.id,Buffer.from(JSON.stringify(F)),!0)}catch(b){throw s.abort(),b}s.commit()}statSync(t,i){let n=this.findINode(this.store.beginTransaction("readonly"),t).toStats();if(!n.hasAccess(4,i))throw l.EACCES(t);return n}createFileSync(t,i,n,s){let o=this.store.beginTransaction("readwrite"),c=Buffer.alloc(0),u=this.commitNewFile(o,t,C.FILE,n,s,c);return new Nt(this,t,i,u.toStats(),c)}openFileSync(t,i,n){let s=this.store.beginTransaction("readonly"),o=this.findINode(s,t),c=s.get(o.id);if(!o.toStats().hasAccess(i.getMode(),n))throw l.EACCES(t);if(c===void 0)throw l.ENOENT(t);return new Nt(this,t,i,o.toStats(),c)}unlinkSync(t,i){this.removeEntry(t,!1,i)}rmdirSync(t,i){if(this.readdirSync(t,i).length>0)throw l.ENOTEMPTY(t);this.removeEntry(t,!0,i)}mkdirSync(t,i,n){let s=this.store.beginTransaction("readwrite"),o=Buffer.from("{}");this.commitNewFile(s,t,C.DIRECTORY,i,n,o)}readdirSync(t,i){let n=this.store.beginTransaction("readonly"),s=this.findINode(n,t);if(!s.toStats().hasAccess(4,i))throw l.EACCES(t);return Object.keys(this.getDirListing(n,t,s))}chmodSync(t,i,n){this.openFileSync(t,x.getFileFlag("r+"),n).chmodSync(i)}chownSync(t,i,n,s){this.openFileSync(t,x.getFileFlag("r+"),s).chownSync(i,n)}_syncSync(t,i,n){let s=this.store.beginTransaction("readwrite"),o=this._findINode(s,E(t),D(t)),c=this.getINode(s,t,o),u=c.update(n);try{s.put(c.id,i,!0),u&&s.put(o,c.toBuffer(),!0)}catch(f){throw s.abort(),f}s.commit()}makeRootDirectory(){let t=this.store.beginTransaction("readwrite");if(t.get(j)===void 0){let i=new Date().getTime(),n=new U(St(),4096,511|C.DIRECTORY,i,i,i,0,0);t.put(n.id,Ut(),!1),t.put(j,n.toBuffer(),!1),t.commit()}}_findINode(t,i,n,s=new Set){let o=L(i,n);if(s.has(o))throw new l(5,"Infinite loop detected while finding inode",o);s.add(o);let c=a(u=>{let f=this.getDirListing(t,i,u);if(f[n])return f[n];throw l.ENOENT(P(i,n))},"readDirectory");return i==="/"?n===""?j:c(this.getINode(t,i,j)):c(this.getINode(t,i+yt+n,this._findINode(t,E(i),D(i),s)))}findINode(t,i){return this.getINode(t,i,this._findINode(t,E(i),D(i)))}getINode(t,i,n){let s=t.get(n);if(s===void 0)throw l.ENOENT(i);return U.fromBuffer(s)}getDirListing(t,i,n){if(!n.isDirectory())throw l.ENOTDIR(i);let s=t.get(n.id);if(s===void 0)throw l.ENOENT(i);return JSON.parse(s.toString())}addNewNode(t,i){let s;for(;0<5;)try{return s=St(),t.put(s,i,!1),s}catch(o){}throw new l(5,"Unable to commit data to key-value store.")}commitNewFile(t,i,n,s,o,c){let u=E(i),f=D(i),h=this.findINode(t,u),m=this.getDirListing(t,u,h),g=new Date().getTime();if(!h.toStats().hasAccess(4,o))throw l.EACCES(i);if(i==="/")throw l.EEXIST(i);if(m[f])throw l.EEXIST(i);let S;try{let F=this.addNewNode(t,c);S=new U(F,c.length,s|n,g,g,g,o.uid,o.gid);let b=this.addNewNode(t,S.toBuffer());m[f]=b,t.put(h.id,Buffer.from(JSON.stringify(m)),!0)}catch(F){throw t.abort(),F}return t.commit(),S}removeEntry(t,i,n){let s=this.store.beginTransaction("readwrite"),o=E(t),c=this.findINode(s,o),u=this.getDirListing(s,o,c),f=D(t);if(!u[f])throw l.ENOENT(t);let h=u[f],m=this.getINode(s,t,h);if(!m.toStats().hasAccess(2,n))throw l.EACCES(t);if(delete u[f],!i&&m.isDirectory())throw l.EISDIR(t);if(i&&!m.isDirectory())throw l.ENOTDIR(t);try{s.del(m.id),s.del(h),s.put(c.id,Buffer.from(JSON.stringify(u)),!0)}catch(g){throw s.abort(),g}s.commit()}};a(Ot,"SyncKeyValueFileSystem");function dt(r,e){e=typeof r=="function"?r:e,Oe(this,r);let t=new this(typeof r=="function"?{}:r);if(typeof e!="function")return t.whenReady();t.whenReady().then(i=>e(null,i)).catch(i=>e(i))}a(dt,"CreateBackend");var re=class{constructor(){this.store=new Map}name(){return X.Name}clear(){this.store.clear()}beginTransaction(e){return new Tt(this)}get(e){return this.store.get(e)}put(e,t,i){return!i&&this.store.has(e)?!1:(this.store.set(e,t),!0)}del(e){this.store.delete(e)}};a(re,"InMemoryStore");var Be=class extends Ot{constructor(){super({store:new re})}},X=Be;a(X,"InMemoryFileSystem"),X.Name="InMemory",X.Create=dt.bind(Be),X.Options={};function $i(r){if(typeof r=="number")return r;if(r instanceof Date)return r.getTime()/1e3;throw new Error("Cannot parse time: "+r)}a($i,"_toUnixTimestamp");function V(r,e){switch(typeof r){case"number":return r;case"string":let t=parseInt(r,8);return isNaN(t)?e:t;default:return e}}a(V,"normalizeMode");function M(r){if(r instanceof Date)return r;if(typeof r=="number")return new Date(r*1e3);throw new l(22,"Invalid time.")}a(M,"normalizeTime");function I(r){if(r.indexOf("\0")>=0)throw new l(22,"Path must be a string without null bytes.");if(r==="")throw new l(22,"Path must not be empty.");return r=r.replaceAll(/\/+/g,"/"),P(r)}a(I,"normalizePath");function ft(r,e,t,i){switch(r===null?"null":typeof r){case"object":return{encoding:typeof r.encoding!="undefined"?r.encoding:e,flag:typeof r.flag!="undefined"?r.flag:t,mode:V(r.mode,i)};case"string":return{encoding:r,flag:t,mode:i};case"null":case"undefined":case"function":return{encoding:e,flag:t,mode:i};default:throw new TypeError(`"options" must be a string or an object, got ${typeof r} instead.`)}}a(ft,"normalizeOptions");function w(){}a(w,"nop");var y=v.Root;function Yi(r){y=r}a(Yi,"setCred");var Ft=new Map,An=100;function ne(r){let e=An++;return Ft.set(e,r),e}a(ne,"getFdForFile");function _(r){if(!Ft.has(r))throw new l(9,"Invalid file descriptor.");return Ft.get(r)}a(_,"fd2file");var H=new Map;X.Create().then(r=>se("/",r));function It(r){return H.get(r)}a(It,"getMount");function ji(){return Object.fromEntries(H.entries())}a(ji,"getMounts");function se(r,e){if(r[0]!=="/"&&(r="/"+r),r=P(r),H.has(r))throw new l(22,"Mount point "+r+" is already in use.");H.set(r,e)}a(se,"mount");function Pe(r){if(r[0]!=="/"&&(r=`/${r}`),r=P(r),!H.has(r))throw new l(22,"Mount point "+r+" is already unmounted.");H.delete(r)}a(Pe,"umount");function J(r){let e=[...H].sort((t,i)=>t[0].length>i[0].length?-1:1);for(let[t,i]of e)if(t.length<=r.length&&r.startsWith(t))return r=r.slice(t.length>1?t.length:0),r===""&&(r="/"),{fs:i,path:r,mountPoint:t};throw new l(5,"ZenFS not initialized with a file system")}a(J,"resolveFS");function Ki(r,e){for(let[t,i]of Object.entries(e))r=r.replaceAll(t,i);return r}a(Ki,"fixPaths");function ht(r,e){return r.stack=Ki(r.stack,e),r.message=Ki(r.message,e),r}a(ht,"fixError");function Xi(r){r["/"]&&Pe("/");for(let[e,t]of Object.entries(r)){if(!t.constructor.isAvailable())throw new l(22,`Can not mount "${e}" since the filesystem is unavailable.`);se(e,t)}}a(Xi,"initialize");var zt={};Xt(zt,{access:()=>ai,appendFile:()=>Me,chmod:()=>ri,chown:()=>ei,close:()=>Ve,constants:()=>kt,createReadStream:()=>Un,createWriteStream:()=>Mn,exists:()=>oe,fchmod:()=>Xe,fchown:()=>je,fdatasync:()=>$e,fstat:()=>ze,fsync:()=>Ke,ftruncate:()=>We,futimes:()=>Je,lchmod:()=>ni,lchown:()=>ii,link:()=>Ze,lstat:()=>Re,lutimes:()=>oi,mkdir:()=>He,open:()=>Ue,read:()=>Ye,readFile:()=>ce,readdir:()=>Ge,readlink:()=>ti,realpath:()=>Mt,rename:()=>Ae,rmdir:()=>qe,stat:()=>De,symlink:()=>Qe,truncate:()=>Le,unlink:()=>ae,unwatchFile:()=>Rn,utimes:()=>si,watch:()=>Ln,watchFile:()=>Dn,write:()=>ue,writeFile:()=>le});function T(){return d(this,arguments,function*(...[r,e,t,...i]){t=I(t);let{fs:n,path:s}=J(e&&(yield oe(t))?yield Mt(t):t);try{return n[r](s,...i)}catch(o){throw ht(o,{[s]:t})}})}a(T,"doOp");function Ae(r,e){return d(this,null,function*(){r=I(r),e=I(e);let t=J(r),i=J(e),n={[t.path]:r,[i.path]:e};try{if(t===i)return t.fs.rename(t.path,i.path,y);let s=yield ce(r);yield le(e,s),yield ae(r)}catch(s){throw ht(s,n)}})}a(Ae,"rename");function oe(r){return d(this,null,function*(){r=I(r);try{let{fs:e,path:t}=J(r);return e.exists(t,y)}catch(e){if(e.errno==2)return!1;throw e}})}a(oe,"exists");function De(r){return d(this,null,function*(){return T("stat",!0,r,y)})}a(De,"stat");function Re(r){return d(this,null,function*(){return T("stat",!1,r,y)})}a(Re,"lstat");function Le(r,e=0){return d(this,null,function*(){if(e<0)throw new l(22);return T("truncate",!0,r,e,y)})}a(Le,"truncate");function ae(r){return d(this,null,function*(){return T("unlink",!1,r,y)})}a(ae,"unlink");function Ue(r,e,t=420){return d(this,null,function*(){let i=yield T("open",!0,r,x.getFileFlag(e),V(t,420),y);return ne(i)})}a(Ue,"open");function ce(t){return d(this,arguments,function*(r,e={}){let i=ft(e,null,"r",null),n=x.getFileFlag(i.flag);if(!n.isReadable())throw new l(22,"Flag passed to readFile must allow for reading.");return T("readFile",!0,r,i.encoding,n,y)})}a(ce,"readFile");function le(r,e,t){return d(this,null,function*(){let i=ft(t,"utf8","w",420),n=x.getFileFlag(i.flag);if(!n.isWriteable())throw new l(22,"Flag passed to writeFile must allow for writing.");return T("writeFile",!0,r,e,i.encoding,n,i.mode,y)})}a(le,"writeFile");function Me(r,e,t){return d(this,null,function*(){let i=ft(t,"utf8","a",420),n=x.getFileFlag(i.flag);if(!n.isAppendable())throw new l(22,"Flag passed to appendFile must allow for appending.");return T("appendFile",!0,r,e,i.encoding,n,i.mode,y)})}a(Me,"appendFile");function ze(r){return d(this,null,function*(){return _(r).stat()})}a(ze,"fstat");function Ve(r){return d(this,null,function*(){yield _(r).close(),Ft.delete(r)})}a(Ve,"close");function We(r,e=0){return d(this,null,function*(){let t=_(r);if(e<0)throw new l(22);return t.truncate(e)})}a(We,"ftruncate");function Ke(r){return d(this,null,function*(){return _(r).sync()})}a(Ke,"fsync");function $e(r){return d(this,null,function*(){return _(r).datasync()})}a($e,"fdatasync");function ue(r,e,t,i,n){return d(this,null,function*(){let s,o=0,c,u;if(typeof e=="string"){u=typeof t=="number"?t:null;let h=typeof i=="string"?i:"utf8";o=0,s=Buffer.from(e,h),c=s.length}else s=e,o=t,c=i,u=typeof n=="number"?n:null;let f=_(r);return u==null&&(u=f.getPos()),f.write(s,o,c,u)})}a(ue,"write");function Ye(r,e,t,i,n){return d(this,null,function*(){let s=_(r);return isNaN(+n)&&(n=s.getPos()),s.read(e,t,i,n)})}a(Ye,"read");function je(r,e,t){return d(this,null,function*(){return _(r).chown(e,t)})}a(je,"fchown");function Xe(r,e){return d(this,null,function*(){let t=typeof e=="string"?parseInt(e,8):e;return _(r).chmod(t)})}a(Xe,"fchmod");function Je(r,e,t){return d(this,null,function*(){return _(r).utimes(M(e),M(t))})}a(Je,"futimes");function qe(r){return d(this,null,function*(){return T("rmdir",!0,r,y)})}a(qe,"rmdir");function He(r,e){return d(this,null,function*(){return T("mkdir",!0,r,V(e,511),y)})}a(He,"mkdir");function Ge(r){return d(this,null,function*(){r=I(r);let e=yield T("readdir",!0,r,y),t=[...H.keys()];for(let i of t)if(i.startsWith(r)){let n=i.slice(r.length);if(n.includes("/")||n.length==0)continue;e.push(n)}return e})}a(Ge,"readdir");function Ze(r,e){return d(this,null,function*(){return e=I(e),T("link",!1,r,e,y)})}a(Ze,"link");function Qe(r,e,t="file"){return d(this,null,function*(){if(!["file","dir","junction"].includes(t))throw new l(22,"Invalid type: "+t);return e=I(e),T("symlink",!1,r,e,t,y)})}a(Qe,"symlink");function ti(r){return d(this,null,function*(){return T("readlink",!1,r,y)})}a(ti,"readlink");function ei(r,e,t){return d(this,null,function*(){return T("chown",!0,r,e,t,y)})}a(ei,"chown");function ii(r,e,t){return d(this,null,function*(){return T("chown",!1,r,e,t,y)})}a(ii,"lchown");function ri(r,e){return d(this,null,function*(){let t=V(e,-1);if(t<0)throw new l(22,"Invalid mode.");return T("chmod",!0,r,t,y)})}a(ri,"chmod");function ni(r,e){return d(this,null,function*(){let t=V(e,-1);if(t<1)throw new l(22,"Invalid mode.");return T("chmod",!1,I(r),t,y)})}a(ni,"lchmod");function si(r,e,t){return d(this,null,function*(){return T("utimes",!0,r,M(e),M(t),y)})}a(si,"utimes");function oi(r,e,t){return d(this,null,function*(){return T("utimes",!1,r,M(e),M(t),y)})}a(oi,"lutimes");function Mt(t){return d(this,arguments,function*(r,e={}){r=I(r);let{fs:i,path:n,mountPoint:s}=J(r);try{if(!(yield i.stat(n,y)).isSymbolicLink())return r;let c=s+I(yield i.readlink(n,y));return Mt(c)}catch(o){throw ht(o,{[n]:r})}})}a(Mt,"realpath");function Dn(i,n){return d(this,arguments,function*(r,e,t=w){throw new l(95)})}a(Dn,"watchFile");function Rn(t){return d(this,arguments,function*(r,e=w){throw new l(95)})}a(Rn,"unwatchFile");function Ln(i,n){return d(this,arguments,function*(r,e,t=w){throw new l(95)})}a(Ln,"watch");function ai(r,e=384){return d(this,null,function*(){return T("access",!0,r,e,y)})}a(ai,"access");function Un(r,e){return d(this,null,function*(){throw new l(95)})}a(Un,"createReadStream");function Mn(r,e){return d(this,null,function*(){throw new l(95)})}a(Mn,"createWriteStream");function zn(r,e,t=w){Ae(r,e).then(()=>t()).catch(t)}a(zn,"rename");function Vn(r,e=w){oe(r).then(e).catch(()=>e(!1))}a(Vn,"exists");function Wn(r,e=w){De(r).then(t=>e(null,t)).catch(e)}a(Wn,"stat");function Kn(r,e=w){Re(r).then(t=>e(null,t)).catch(e)}a(Kn,"lstat");function $n(r,e=0,t=w){t=typeof e=="function"?e:t,Le(r,typeof e=="number"?e:0).then(()=>t()).catch(t)}a($n,"truncate");function Yn(r,e=w){ae(r).then(()=>e()).catch(e)}a(Yn,"unlink");function jn(r,e,t,i=w){let n=V(t,420);i=typeof t=="function"?t:i,Ue(r,e,n).then(s=>i(null,s)).catch(i)}a(jn,"open");function Xn(r,e={},t=w){t=typeof e=="function"?e:t,ce(r,typeof e=="function"?null:e)}a(Xn,"readFile");function Jn(r,e,t={},i=w){i=typeof t=="function"?t:i,le(r,e,typeof t=="function"?void 0:t)}a(Jn,"writeFile");function qn(r,e,t,i=w){i=typeof t=="function"?t:i,Me(r,e,typeof t=="function"?null:t)}a(qn,"appendFile");function Hn(r,e=w){ze(r).then(t=>e(null,t)).catch(e)}a(Hn,"fstat");function Gn(r,e=w){Ve(r).then(()=>e()).catch(e)}a(Gn,"close");function Zn(r,e,t=w){let i=typeof e=="number"?e:0;t=typeof e=="function"?e:t,We(r,i)}a(Zn,"ftruncate");function Qn(r,e=w){Ke(r).then(()=>e()).catch(e)}a(Qn,"fsync");function ts(r,e=w){$e(r).then(()=>e()).catch(e)}a(ts,"fdatasync");function es(r,e,t,i,n,s=w){let o,c,u,f=null,h;if(typeof e=="string"){switch(h="utf8",typeof t){case"function":s=t;break;case"number":f=t,h=typeof i=="string"?i:"utf8",s=typeof n=="function"?n:s;break;default:s=typeof i=="function"?i:typeof n=="function"?n:s,s(new l(22,"Invalid arguments."));return}o=Buffer.from(e,h),c=0,u=o.length;let m=s;ue(r,o,c,u,f).then(g=>m(null,g,o.toString(h))).catch(m)}else{o=e,c=t,u=i,f=typeof n=="number"?n:null;let m=typeof n=="function"?n:s;ue(r,o,c,u,f).then(g=>m(null,g,o)).catch(m)}}a(es,"write");function is(r,e,t,i,n,s=w){Ye(r,e,t,i,n).then(({bytesRead:o,buffer:c})=>s(null,o,c)).catch(s)}a(is,"read");function rs(r,e,t,i=w){je(r,e,t).then(()=>i()).catch(i)}a(rs,"fchown");function ns(r,e,t){Xe(r,e).then(()=>t()).catch(t)}a(ns,"fchmod");function ss(r,e,t,i=w){Je(r,e,t).then(()=>i()).catch(i)}a(ss,"futimes");function os(r,e=w){qe(r).then(()=>e()).catch(e)}a(os,"rmdir");function as(r,e,t=w){He(r,e).then(()=>t()).catch(t)}a(as,"mkdir");function cs(r,e=w){Ge(r).then(t=>e(null,t)).catch(e)}a(cs,"readdir");function ls(r,e,t=w){Ze(r,e).then(()=>t()).catch(t)}a(ls,"link");function us(r,e,t,i=w){let n=typeof t=="string"?t:"file";i=typeof t=="function"?t:i,Qe(r,e,typeof t=="function"?null:t).then(()=>i()).catch(i)}a(us,"symlink");function ds(r,e=w){ti(r).then(t=>e(null,t)).catch(e)}a(ds,"readlink");function fs(r,e,t,i=w){ei(r,e,t).then(()=>i()).catch(i)}a(fs,"chown");function hs(r,e,t,i=w){ii(r,e,t).then(()=>i()).catch(i)}a(hs,"lchown");function ms(r,e,t=w){ri(r,e).then(()=>t()).catch(t)}a(ms,"chmod");function ps(r,e,t=w){ni(r,e).then(()=>t()).catch(t)}a(ps,"lchmod");function gs(r,e,t,i=w){si(r,e,t).then(()=>i()).catch(i)}a(gs,"utimes");function ys(r,e,t,i=w){oi(r,e,t).then(()=>i()).catch(i)}a(ys,"lutimes");function bs(r,e,t=w){let i=typeof e=="object"?e:{};t=typeof e=="function"?e:t,Mt(r,typeof e=="function"?null:e).then(n=>t(null,n)).catch(t)}a(bs,"realpath");function ws(r,e,t=w){let i=typeof e=="number"?e:4;t=typeof e=="function"?e:t,ai(r,typeof e=="function"?null:e).then(()=>t()).catch(t)}a(ws,"access");function Ss(r,e,t=w){throw new l(95)}a(Ss,"watchFile");function Fs(r,e=w){throw new l(95)}a(Fs,"unwatchFile");function xs(r,e,t=w){throw new l(95)}a(xs,"watch");function Es(r,e){throw new l(95)}a(Es,"createReadStream");function vs(r,e){throw new l(95)}a(vs,"createWriteStream");function N(...[r,e,t,...i]){t=I(t);let{fs:n,path:s}=J(e&&Ji(t)?ci(t):t);try{return n[r](s,...i)}catch(o){throw ht(o,{[s]:t})}}a(N,"doOp");function Cs(r,e){r=I(r),e=I(e);let t=J(r),i=J(e),n={[t.path]:r,[i.path]:e};try{if(t===i)return t.fs.renameSync(t.path,i.path,y);let s=Hi(r);Gi(e,s),qi(r)}catch(s){throw ht(s,n)}}a(Cs,"renameSync");function Ji(r){r=I(r);try{let{fs:e,path:t}=J(r);return e.existsSync(t,y)}catch(e){if(e.errno==2)return!1;throw e}}a(Ji,"existsSync");function _s(r){return N("statSync",!0,r,y)}a(_s,"statSync");function ks(r){return N("statSync",!1,r,y)}a(ks,"lstatSync");function Is(r,e=0){if(e<0)throw new l(22);return N("truncateSync",!0,r,e,y)}a(Is,"truncateSync");function qi(r){return N("unlinkSync",!1,r,y)}a(qi,"unlinkSync");function Ts(r,e,t=420){let i=N("openSync",!0,r,x.getFileFlag(e),V(t,420),y);return ne(i)}a(Ts,"openSync");function Hi(r,e={}){let t=ft(e,null,"r",null),i=x.getFileFlag(t.flag);if(!i.isReadable())throw new l(22,"Flag passed to readFile must allow for reading.");return N("readFileSync",!0,r,t.encoding,i,y)}a(Hi,"readFileSync");function Gi(r,e,t){let i=ft(t,"utf8","w",420),n=x.getFileFlag(i.flag);if(!n.isWriteable())throw new l(22,"Flag passed to writeFile must allow for writing.");return N("writeFileSync",!0,r,e,i.encoding,n,i.mode,y)}a(Gi,"writeFileSync");function Ns(r,e,t){let i=ft(t,"utf8","a",420),n=x.getFileFlag(i.flag);if(!n.isAppendable())throw new l(22,"Flag passed to appendFile must allow for appending.");return N("appendFileSync",!0,r,e,i.encoding,n,i.mode,y)}a(Ns,"appendFileSync");function Os(r){return _(r).statSync()}a(Os,"fstatSync");function Bs(r){_(r).closeSync(),Ft.delete(r)}a(Bs,"closeSync");function Ps(r,e=0){let t=_(r);if(e<0)throw new l(22);t.truncateSync(e)}a(Ps,"ftruncateSync");function As(r){_(r).syncSync()}a(As,"fsyncSync");function Ds(r){_(r).datasyncSync()}a(Ds,"fdatasyncSync");function Rs(r,e,t,i,n){let s,o=0,c,u;if(typeof e=="string"){u=typeof t=="number"?t:null;let h=typeof i=="string"?i:"utf8";o=0,s=Buffer.from(e,h),c=s.length}else s=e,o=t,c=i,u=typeof n=="number"?n:null;let f=_(r);return u==null&&(u=f.getPos()),f.writeSync(s,o,c,u)}a(Rs,"writeSync");function Ls(r,e,t,i,n){let s=_(r),o=t;return typeof t=="object"&&({offset:o,length:i,position:n}=t),isNaN(+n)&&(n=s.getPos()),s.readSync(e,o,i,n)}a(Ls,"readSync");function Us(r,e,t){_(r).chownSync(e,t)}a(Us,"fchownSync");function Ms(r,e){let t=typeof e=="string"?parseInt(e,8):e;_(r).chmodSync(t)}a(Ms,"fchmodSync");function zs(r,e,t){_(r).utimesSync(M(e),M(t))}a(zs,"futimesSync");function Vs(r){return N("rmdirSync",!0,r,y)}a(Vs,"rmdirSync");function Ws(r,e){N("mkdirSync",!0,r,V(e,511),y)}a(Ws,"mkdirSync");function Ks(r){r=I(r);let e=N("readdirSync",!0,r,y),t=[...H.keys()];for(let i of t)if(i.startsWith(r)){let n=i.slice(r.length);if(n.includes("/")||n.length==0)continue;e.push(n)}return e}a(Ks,"readdirSync");function $s(r,e){return e=I(e),N("linkSync",!1,r,e,y)}a($s,"linkSync");function Ys(r,e,t){if(!["file","dir","junction"].includes(t))throw new l(22,"Invalid type: "+t);return e=I(e),N("symlinkSync",!1,r,e,t,y)}a(Ys,"symlinkSync");function js(r){return N("readlinkSync",!1,r,y)}a(js,"readlinkSync");function Xs(r,e,t){N("chownSync",!0,r,e,t,y)}a(Xs,"chownSync");function Js(r,e,t){N("chownSync",!1,r,e,t,y)}a(Js,"lchownSync");function qs(r,e){let t=V(e,-1);if(t<0)throw new l(22,"Invalid mode.");N("chmodSync",!0,r,t,y)}a(qs,"chmodSync");function Hs(r,e){let t=V(e,-1);if(t<1)throw new l(22,"Invalid mode.");N("chmodSync",!1,r,t,y)}a(Hs,"lchmodSync");function Gs(r,e,t){N("utimesSync",!0,r,M(e),M(t),y)}a(Gs,"utimesSync");function Zs(r,e,t){N("utimesSync",!1,r,M(e),M(t),y)}a(Zs,"lutimesSync");function ci(r,e={}){r=I(r);let{fs:t,path:i,mountPoint:n}=J(r);try{if(!t.statSync(i,y).isSymbolicLink())return r;let o=I(n+t.readlinkSync(i,y));return ci(o)}catch(s){throw ht(s,{[i]:r})}}a(ci,"realpathSync");function Qs(r,e=384){return N("accessSync",!0,r,e,y)}a(Qs,"accessSync");var to=li,de=to;var fe=class extends z{constructor(e,t,i,n,s){super(e,t,i,n,s)}syncSync(){this.isDirty()&&(this._fs._syncSync(this),this.resetDirty())}closeSync(){this.syncSync()}};a(fe,"MirrorFile");var Vt=class extends ut{constructor({sync:t,async:i}){super();this._queue=[];this._queueRunning=!1;this._isInitialized=!1;this._initializeCallbacks=[];this._sync=t,this._async=i,this._ready=this._initialize()}static isAvailable(){return!0}get metadata(){return Q(q({},super.metadata),{name:Vt.Name,synchronous:!0,supportsProperties:this._sync.metadata.supportsProperties&&this._async.metadata.supportsProperties})}_syncSync(t){let i=t.getStats();this._sync.writeFileSync(t.getPath(),t.getBuffer(),null,x.getFileFlag("w"),i.mode,i.getCred(0,0)),this.enqueueOp({apiMethod:"writeFile",arguments:[t.getPath(),t.getBuffer(),null,t.getFlag(),i.mode,i.getCred(0,0)]})}renameSync(t,i,n){this._sync.renameSync(t,i,n),this.enqueueOp({apiMethod:"rename",arguments:[t,i,n]})}statSync(t,i){return this._sync.statSync(t,i)}openSync(t,i,n,s){return this._sync.openSync(t,i,n,s).closeSync(),new fe(this,t,i,this._sync.statSync(t,s),this._sync.readFileSync(t,null,x.getFileFlag("r"),s))}unlinkSync(t,i){this._sync.unlinkSync(t,i),this.enqueueOp({apiMethod:"unlink",arguments:[t,i]})}rmdirSync(t,i){this._sync.rmdirSync(t,i),this.enqueueOp({apiMethod:"rmdir",arguments:[t,i]})}mkdirSync(t,i,n){this._sync.mkdirSync(t,i,n),this.enqueueOp({apiMethod:"mkdir",arguments:[t,i,n]})}readdirSync(t,i){return this._sync.readdirSync(t,i)}existsSync(t,i){return this._sync.existsSync(t,i)}chmodSync(t,i,n){this._sync.chmodSync(t,i,n),this.enqueueOp({apiMethod:"chmod",arguments:[t,i,n]})}chownSync(t,i,n,s){this._sync.chownSync(t,i,n,s),this.enqueueOp({apiMethod:"chown",arguments:[t,i,n,s]})}utimesSync(t,i,n,s){this._sync.utimesSync(t,i,n,s),this.enqueueOp({apiMethod:"utimes",arguments:[t,i,n,s]})}_initialize(){return d(this,null,function*(){if(!this._isInitialized){let t=a((s,o)=>d(this,null,function*(){if(s!=="/"){let u=yield this._async.stat(s,v.Root);this._sync.mkdirSync(s,o,u.getCred())}let c=yield this._async.readdir(s,v.Root);for(let u of c)yield n(L(s,u))}),"copyDirectory"),i=a((s,o)=>d(this,null,function*(){let c=yield this._async.readFile(s,null,x.getFileFlag("r"),v.Root);this._sync.writeFileSync(s,c,null,x.getFileFlag("w"),o,v.Root)}),"copyFile"),n=a(s=>d(this,null,function*(){let o=yield this._async.stat(s,v.Root);o.isDirectory()?yield t(s,o.mode):yield i(s,o.mode)}),"copyItem");try{yield t("/",0),this._isInitialized=!0}catch(s){throw this._isInitialized=!1,s}}return this})}enqueueOp(t){if(this._queue.push(t),!this._queueRunning){this._queueRunning=!0;let i=a(n=>{if(n)throw new Error(`WARNING: File system has desynchronized. Received following error: ${n}
4
- $`);if(this._queue.length>0){let s=this._queue.shift();s.arguments.push(i),this._async[s.apiMethod].apply(this._async,s.arguments)}else this._queueRunning=!1},"doNextOp");i()}}},nt=Vt;a(nt,"AsyncMirror"),nt.Name="AsyncMirror",nt.Create=dt.bind(Vt),nt.Options={sync:{type:"object",description:"The synchronous file system to mirror the asynchronous file system to.",validator:t=>d(Vt,null,function*(){if(!(t!=null&&t.metadata.synchronous))throw new l(22,"'sync' option must be a file system that supports synchronous operations")})},async:{type:"object",description:"The asynchronous file system to mirror."}};var ui=class extends Y{constructor({folder:t,wrapped:i}){super();this._folder=t,this._wrapped=i,this._ready=this._initialize()}static isAvailable(){return!0}get metadata(){return Q(q(q({},super.metadata),this._wrapped.metadata),{supportsLinks:!1})}_initialize(){return d(this,null,function*(){if(!(yield this._wrapped.exists(this._folder,v.Root))&&this._wrapped.metadata.readonly)throw l.ENOENT(this._folder);return yield this._wrapped.mkdir(this._folder,511,v.Root),this})}},G=ui;a(G,"FolderAdapter"),G.Name="FolderAdapter",G.Create=dt.bind(ui),G.Options={folder:{type:"string",description:"The folder to use as the root directory"},wrapped:{type:"object",description:"The file system to wrap"}};function Zi(r,e){if(e!==null&&typeof e=="object"){let t=e,i=t.path;i&&(i="/"+Ui(r,i),t.message=t.message.replace(t.path,i),t.path=i)}return e}a(Zi,"translateError");function eo(r,e){return typeof e=="function"?function(t){arguments.length>0&&(arguments[0]=Zi(r,t)),e.apply(null,arguments)}:e}a(eo,"wrapCallback");function Qi(r,e,t){return r.slice(r.length-4)!=="Sync"?function(){return arguments.length>0&&(e&&(arguments[0]=L(this._folder,arguments[0])),t&&(arguments[1]=L(this._folder,arguments[1])),arguments[arguments.length-1]=eo(this._folder,arguments[arguments.length-1])),this._wrapped[r].apply(this._wrapped,arguments)}:function(){try{return e&&(arguments[0]=L(this._folder,arguments[0])),t&&(arguments[1]=L(this._folder,arguments[1])),this._wrapped[r].apply(this._wrapped,arguments)}catch(i){throw Zi(this._folder,i)}}}a(Qi,"wrapFunction");["diskSpace","stat","statSync","open","openSync","unlink","unlinkSync","rmdir","rmdirSync","mkdir","mkdirSync","readdir","readdirSync","exists","existsSync","realpath","realpathSync","truncate","truncateSync","readFile","readFileSync","writeFile","writeFileSync","appendFile","appendFileSync","chmod","chmodSync","chown","chownSync","utimes","utimesSync","readlink","readlinkSync"].forEach(r=>{G.prototype[r]=Qi(r,!0,!1)});["rename","renameSync","link","linkSync","symlink","symlinkSync"].forEach(r=>{G.prototype[r]=Qi(r,!0,!0)});var Bt=class{constructor(){this._locks=new Map}lock(e){return new Promise(t=>{this._locks.has(e)?this._locks.get(e).push(t):this._locks.set(e,[])})}unlock(e){if(!this._locks.has(e))throw new Error("unlock of a non-locked mutex");let t=this._locks.get(e).shift();if(t){setTimeout(t,0);return}this._locks.delete(e)}tryLock(e){return this._locks.has(e)?!1:(this._locks.set(e,[]),!0)}isLocked(e){return this._locks.has(e)}};a(Bt,"Mutex");var Pt=class{constructor(e){this._ready=Promise.resolve(this);this._fs=e,this._mu=new Bt}whenReady(){return this._ready}get metadata(){return Q(q({},this._fs.metadata),{name:"LockedFS<"+this._fs.metadata.name+">"})}get fs(){return this._fs}rename(e,t,i){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.rename(e,t,i),this._mu.unlock(e)})}renameSync(e,t,i){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.renameSync(e,t,i)}stat(e,t){return d(this,null,function*(){yield this._mu.lock(e);let i=yield this._fs.stat(e,t);return this._mu.unlock(e),i})}statSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.statSync(e,t)}access(e,t,i){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.access(e,t,i),this._mu.unlock(e)})}accessSync(e,t,i){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.accessSync(e,t,i)}open(e,t,i,n){return d(this,null,function*(){yield this._mu.lock(e);let s=yield this._fs.open(e,t,i,n);return this._mu.unlock(e),s})}openSync(e,t,i,n){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.openSync(e,t,i,n)}unlink(e,t){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.unlink(e,t),this._mu.unlock(e)})}unlinkSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.unlinkSync(e,t)}rmdir(e,t){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.rmdir(e,t),this._mu.unlock(e)})}rmdirSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.rmdirSync(e,t)}mkdir(e,t,i){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.mkdir(e,t,i),this._mu.unlock(e)})}mkdirSync(e,t,i){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.mkdirSync(e,t,i)}readdir(e,t){return d(this,null,function*(){yield this._mu.lock(e);let i=yield this._fs.readdir(e,t);return this._mu.unlock(e),i})}readdirSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.readdirSync(e,t)}exists(e,t){return d(this,null,function*(){yield this._mu.lock(e);let i=yield this._fs.exists(e,t);return this._mu.unlock(e),i})}existsSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.existsSync(e,t)}realpath(e,t){return d(this,null,function*(){yield this._mu.lock(e);let i=yield this._fs.realpath(e,t);return this._mu.unlock(e),i})}realpathSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.realpathSync(e,t)}truncate(e,t,i){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.truncate(e,t,i),this._mu.unlock(e)})}truncateSync(e,t,i){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.truncateSync(e,t,i)}readFile(e,t,i,n){return d(this,null,function*(){yield this._mu.lock(e);let s=yield this._fs.readFile(e,t,i,n);return this._mu.unlock(e),s})}readFileSync(e,t,i,n){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.readFileSync(e,t,i,n)}writeFile(e,t,i,n,s,o){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.writeFile(e,t,i,n,s,o),this._mu.unlock(e)})}writeFileSync(e,t,i,n,s,o){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.writeFileSync(e,t,i,n,s,o)}appendFile(e,t,i,n,s,o){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.appendFile(e,t,i,n,s,o),this._mu.unlock(e)})}appendFileSync(e,t,i,n,s,o){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.appendFileSync(e,t,i,n,s,o)}chmod(e,t,i){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.chmod(e,t,i),this._mu.unlock(e)})}chmodSync(e,t,i){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.chmodSync(e,t,i)}chown(e,t,i,n){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.chown(e,t,i,n),this._mu.unlock(e)})}chownSync(e,t,i,n){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.chownSync(e,t,i,n)}utimes(e,t,i,n){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.utimes(e,t,i,n),this._mu.unlock(e)})}utimesSync(e,t,i,n){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.utimesSync(e,t,i,n)}link(e,t,i){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.link(e,t,i),this._mu.unlock(e)})}linkSync(e,t,i){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.linkSync(e,t,i)}symlink(e,t,i,n){return d(this,null,function*(){yield this._mu.lock(e),yield this._fs.symlink(e,t,i,n),this._mu.unlock(e)})}symlinkSync(e,t,i,n){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.symlinkSync(e,t,i,n)}readlink(e,t){return d(this,null,function*(){yield this._mu.lock(e);let i=yield this._fs.readlink(e,t);return this._mu.unlock(e),i})}readlinkSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.readlinkSync(e,t)}};a(Pt,"LockedFS");var st="/.deletedFiles.log";function tr(r){return 146|r}a(tr,"makeModeWritable");function W(r){return x.getFileFlag(r)}a(W,"getFlag");var Wt=class extends z{constructor(e,t,i,n,s){super(e,t,i,n,s)}sync(){return d(this,null,function*(){this.isDirty()&&(yield this._fs._syncAsync(this),this.resetDirty())})}syncSync(){this.isDirty()&&(this._fs._syncSync(this),this.resetDirty())}close(){return d(this,null,function*(){yield this.sync()})}closeSync(){this.syncSync()}};a(Wt,"OverlayFile");var Kt=class extends Y{constructor({writable:t,readable:i}){super();this._isInitialized=!1;this._deletedFiles={};this._deleteLog="";this._deleteLogUpdatePending=!1;this._deleteLogUpdateNeeded=!1;this._deleteLogError=null;if(this._writable=t,this._readable=i,this._writable.metadata.readonly)throw new l(22,"Writable file system must be writable.")}static isAvailable(){return!0}get metadata(){return Q(q({},super.metadata),{name:et.Name,synchronous:this._readable.metadata.synchronous&&this._writable.metadata.synchronous,supportsProperties:this._readable.metadata.supportsProperties&&this._writable.metadata.supportsProperties})}getOverlayedFileSystems(){return{readable:this._readable,writable:this._writable}}_syncAsync(t){return d(this,null,function*(){let i=t.getStats();return yield this.createParentDirectoriesAsync(t.getPath(),i.getCred(0,0)),this._writable.writeFile(t.getPath(),t.getBuffer(),null,W("w"),i.mode,i.getCred(0,0))})}_syncSync(t){let i=t.getStats();this.createParentDirectories(t.getPath(),i.getCred(0,0)),this._writable.writeFileSync(t.getPath(),t.getBuffer(),null,W("w"),i.mode,i.getCred(0,0))}_initialize(){return d(this,null,function*(){if(!this._isInitialized){try{let t=yield this._writable.readFile(st,"utf8",W("r"),v.Root);this._deleteLog=t}catch(t){if(t.errno!==2)throw t}this._isInitialized=!0,this._reparseDeletionLog()}})}getDeletionLog(){return this._deleteLog}restoreDeletionLog(t,i){this._deleteLog=t,this._reparseDeletionLog(),this.updateLog("",i)}rename(t,i,n){return d(this,null,function*(){if(this.checkInitialized(),this.checkPath(t),this.checkPath(i),t===st||i===st)throw l.EPERM("Cannot rename deletion log.");let s=yield this.stat(t,n);if(s.isDirectory()){if(t===i)return;let o=511;if(yield this.exists(i,n)){let c=yield this.stat(i,n);if(o=c.mode,c.isDirectory()){if((yield this.readdir(i,n)).length>0)throw l.ENOTEMPTY(i)}else throw l.ENOTDIR(i)}if((yield this._writable.exists(t,n))?yield this._writable.rename(t,i,n):(yield this._writable.exists(i,n))||(yield this._writable.mkdir(i,o,n)),yield this._readable.exists(t,n))for(let c of yield this._readable.readdir(t,n))yield this.rename(P(t,c),P(i,c),n)}else{if((yield this.exists(i,n))&&(yield this.stat(i,n)).isDirectory())throw l.EISDIR(i);yield this.writeFile(i,yield this.readFile(t,null,W("r"),n),null,W("w"),s.mode,n)}t!==i&&(yield this.exists(t,n))&&(yield this.unlink(t,n))})}renameSync(t,i,n){if(this.checkInitialized(),this.checkPath(t),this.checkPath(i),t===st||i===st)throw l.EPERM("Cannot rename deletion log.");let s=this.statSync(t,n);if(s.isDirectory()){if(t===i)return;let o=511;if(this.existsSync(i,n)){let c=this.statSync(i,n);if(o=c.mode,c.isDirectory()){if(this.readdirSync(i,n).length>0)throw l.ENOTEMPTY(i)}else throw l.ENOTDIR(i)}this._writable.existsSync(t,n)?this._writable.renameSync(t,i,n):this._writable.existsSync(i,n)||this._writable.mkdirSync(i,o,n),this._readable.existsSync(t,n)&&this._readable.readdirSync(t,n).forEach(c=>{this.renameSync(P(t,c),P(i,c),n)})}else{if(this.existsSync(i,n)&&this.statSync(i,n).isDirectory())throw l.EISDIR(i);this.writeFileSync(i,this.readFileSync(t,null,W("r"),n),null,W("w"),s.mode,n)}t!==i&&this.existsSync(t,n)&&this.unlinkSync(t,n)}stat(t,i){return d(this,null,function*(){this.checkInitialized();try{return this._writable.stat(t,i)}catch(n){if(this._deletedFiles[t])throw l.ENOENT(t);let s=k.clone(yield this._readable.stat(t,i));return s.mode=tr(s.mode),s}})}statSync(t,i){this.checkInitialized();try{return this._writable.statSync(t,i)}catch(n){if(this._deletedFiles[t])throw l.ENOENT(t);let s=k.clone(this._readable.statSync(t,i));return s.mode=tr(s.mode),s}}open(t,i,n,s){return d(this,null,function*(){if(this.checkInitialized(),this.checkPath(t),t===st)throw l.EPERM("Cannot open deletion log.");if(yield this.exists(t,s))switch(i.pathExistsAction()){case 2:return yield this.createParentDirectoriesAsync(t,s),this._writable.open(t,i,n,s);case 0:if(yield this._writable.exists(t,s))return this._writable.open(t,i,n,s);{let o=yield this._readable.readFile(t,null,W("r"),s),c=k.clone(yield this._readable.stat(t,s));return c.mode=n,new Wt(this,t,i,c,o)}default:throw l.EEXIST(t)}else switch(i.pathNotExistsAction()){case 3:return yield this.createParentDirectoriesAsync(t,s),this._writable.open(t,i,n,s);default:throw l.ENOENT(t)}})}openSync(t,i,n,s){if(this.checkInitialized(),this.checkPath(t),t===st)throw l.EPERM("Cannot open deletion log.");if(this.existsSync(t,s))switch(i.pathExistsAction()){case 2:return this.createParentDirectories(t,s),this._writable.openSync(t,i,n,s);case 0:if(this._writable.existsSync(t,s))return this._writable.openSync(t,i,n,s);{let o=this._readable.readFileSync(t,null,W("r"),s),c=k.clone(this._readable.statSync(t,s));return c.mode=n,new Wt(this,t,i,c,o)}default:throw l.EEXIST(t)}else switch(i.pathNotExistsAction()){case 3:return this.createParentDirectories(t,s),this._writable.openSync(t,i,n,s);default:throw l.ENOENT(t)}}unlink(t,i){return d(this,null,function*(){if(this.checkInitialized(),this.checkPath(t),yield this.exists(t,i))(yield this._writable.exists(t,i))&&(yield this._writable.unlink(t,i)),(yield this.exists(t,i))&&this.deletePath(t,i);else throw l.ENOENT(t)})}unlinkSync(t,i){if(this.checkInitialized(),this.checkPath(t),this.existsSync(t,i))this._writable.existsSync(t,i)&&this._writable.unlinkSync(t,i),this.existsSync(t,i)&&this.deletePath(t,i);else throw l.ENOENT(t)}rmdir(t,i){return d(this,null,function*(){if(this.checkInitialized(),yield this.exists(t,i)){if((yield this._writable.exists(t,i))&&(yield this._writable.rmdir(t,i)),yield this.exists(t,i)){if((yield this.readdir(t,i)).length>0)throw l.ENOTEMPTY(t);this.deletePath(t,i)}}else throw l.ENOENT(t)})}rmdirSync(t,i){if(this.checkInitialized(),this.existsSync(t,i)){if(this._writable.existsSync(t,i)&&this._writable.rmdirSync(t,i),this.existsSync(t,i)){if(this.readdirSync(t,i).length>0)throw l.ENOTEMPTY(t);this.deletePath(t,i)}}else throw l.ENOENT(t)}mkdir(t,i,n){return d(this,null,function*(){if(this.checkInitialized(),yield this.exists(t,n))throw l.EEXIST(t);yield this.createParentDirectoriesAsync(t,n),yield this._writable.mkdir(t,i,n)})}mkdirSync(t,i,n){if(this.checkInitialized(),this.existsSync(t,n))throw l.EEXIST(t);this.createParentDirectories(t,n),this._writable.mkdirSync(t,i,n)}readdir(t,i){return d(this,null,function*(){if(this.checkInitialized(),!(yield this.stat(t,i)).isDirectory())throw l.ENOTDIR(t);let s=[];try{s=s.concat(yield this._writable.readdir(t,i))}catch(c){}try{s=s.concat((yield this._readable.readdir(t,i)).filter(c=>!this._deletedFiles[`${t}/${c}`]))}catch(c){}let o={};return s.filter(c=>{let u=!o[c];return o[c]=!0,u})})}readdirSync(t,i){if(this.checkInitialized(),!this.statSync(t,i).isDirectory())throw l.ENOTDIR(t);let s=[];try{s=s.concat(this._writable.readdirSync(t,i))}catch(c){}try{s=s.concat(this._readable.readdirSync(t,i).filter(c=>!this._deletedFiles[`${t}/${c}`]))}catch(c){}let o={};return s.filter(c=>{let u=!o[c];return o[c]=!0,u})}exists(t,i){return d(this,null,function*(){return this.checkInitialized(),(yield this._writable.exists(t,i))||(yield this._readable.exists(t,i))&&this._deletedFiles[t]!==!0})}existsSync(t,i){return this.checkInitialized(),this._writable.existsSync(t,i)||this._readable.existsSync(t,i)&&this._deletedFiles[t]!==!0}chmod(t,i,n){return d(this,null,function*(){this.checkInitialized(),yield this.operateOnWritableAsync(t,n),yield this._writable.chmod(t,i,n)})}chmodSync(t,i,n){this.checkInitialized(),this.operateOnWritable(t,n),this._writable.chmodSync(t,i,n)}chown(t,i,n,s){return d(this,null,function*(){this.checkInitialized(),yield this.operateOnWritableAsync(t,s),yield this._writable.chown(t,i,n,s)})}chownSync(t,i,n,s){this.checkInitialized(),this.operateOnWritable(t,s),this._writable.chownSync(t,i,n,s)}utimes(t,i,n,s){return d(this,null,function*(){this.checkInitialized(),yield this.operateOnWritableAsync(t,s),yield this._writable.utimes(t,i,n,s)})}utimesSync(t,i,n,s){this.checkInitialized(),this.operateOnWritable(t,s),this._writable.utimesSync(t,i,n,s)}deletePath(t,i){this._deletedFiles[t]=!0,this.updateLog(`d${t}
5
- `,i)}updateLog(t,i){this._deleteLog+=t,this._deleteLogUpdatePending?this._deleteLogUpdateNeeded=!0:(this._deleteLogUpdatePending=!0,this._writable.writeFile(st,this._deleteLog,"utf8",x.getFileFlag("w"),420,i).then(()=>{this._deleteLogUpdateNeeded&&(this._deleteLogUpdateNeeded=!1,this.updateLog("",i))}).catch(n=>{this._deleteLogError=n}).finally(()=>{this._deleteLogUpdatePending=!1}))}_reparseDeletionLog(){this._deletedFiles={},this._deleteLog.split(`
6
- `).forEach(t=>{this._deletedFiles[t.slice(1)]=t.slice(0,1)==="d"})}checkInitialized(){if(this._isInitialized){if(this._deleteLogError!==null){let t=this._deleteLogError;throw this._deleteLogError=null,t}}else throw new l(1,"OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.")}checkPath(t){if(t===st)throw l.EPERM(t)}createParentDirectories(t,i){let n=E(t),s=[];for(;!this._writable.existsSync(n,i);)s.push(n),n=E(n);s=s.reverse();for(let o of s)this._writable.mkdirSync(o,this.statSync(o,i).mode,i)}createParentDirectoriesAsync(t,i){return d(this,null,function*(){let n=E(t),s=[];for(;!(yield this._writable.exists(n,i));)s.push(n),n=E(n);s=s.reverse();for(let o of s){let c=yield this.stat(o,i);yield this._writable.mkdir(o,c.mode,i)}})}operateOnWritable(t,i){if(!this.existsSync(t,i))throw l.ENOENT(t);this._writable.existsSync(t,i)||this.copyToWritable(t,i)}operateOnWritableAsync(t,i){return d(this,null,function*(){if(!(yield this.exists(t,i)))throw l.ENOENT(t);if(!(yield this._writable.exists(t,i)))return this.copyToWritableAsync(t,i)})}copyToWritable(t,i){let n=this.statSync(t,i);n.isDirectory()?this._writable.mkdirSync(t,n.mode,i):this.writeFileSync(t,this._readable.readFileSync(t,null,W("r"),i),null,W("w"),n.mode,i)}copyToWritableAsync(t,i){return d(this,null,function*(){let n=yield this.stat(t,i);n.isDirectory()?yield this._writable.mkdir(t,n.mode,i):yield this.writeFile(t,yield this._readable.readFile(t,null,W("r"),i),null,W("w"),n.mode,i)})}};a(Kt,"UnlockedOverlayFS");var he=class extends Pt{static isAvailable(){return Kt.isAvailable()}constructor(e){super(new Kt(e)),this._ready=this._initialize()}getOverlayedFileSystems(){return super.fs.getOverlayedFileSystems()}getDeletionLog(){return super.fs.getDeletionLog()}resDeletionLog(){return super.fs.getDeletionLog()}unwrap(){return super.fs}_initialize(){return d(this,null,function*(){return yield wi(he.prototype,this,"fs")._initialize(),this})}},et=he;a(et,"OverlayFS"),et.Name="OverlayFS",et.Create=dt.bind(he),et.Options={writable:{type:"object",description:"The file system to write modified files to."},readable:{type:"object",description:"The file system that initially populates this file system."}};var me={};function er(...r){for(let e of r)me[e.Name]=e}a(er,"registerBackend");er(nt,G,X,et);var $t=class{constructor(e,t){this.key=e;this.value=t;this.prev=null;this.next=null}};a($t,"LRUNode");var pe=class{constructor(e){this.limit=e;this.size=0;this.map={};this.head=null;this.tail=null}set(e,t){let i=new $t(e,t);this.map[e]?(this.map[e].value=i.value,this.remove(i.key)):this.size>=this.limit&&(delete this.map[this.tail.key],this.size--,this.tail=this.tail.prev,this.tail.next=null),this.setHead(i)}get(e){if(this.map[e]){let t=this.map[e].value,i=new $t(e,t);return this.remove(e),this.setHead(i),t}else return null}remove(e){let t=this.map[e];t&&(t.prev!==null?t.prev.next=t.next:this.head=t.next,t.next!==null?t.next.prev=t.prev:this.tail=t.prev,delete this.map[e],this.size--)}removeAll(){this.size=0,this.map={},this.head=null,this.tail=null}setHead(e){e.next=this.head,e.prev=null,this.head!==null&&(this.head.prev=e),this.head=e,this.tail===null&&(this.tail=e),this.size++,this.map[e.key]=e}};a(pe,"LRUCache");var At=class extends z{constructor(e,t,i,n,s){super(e,t,i,n,s)}sync(){return d(this,null,function*(){this.isDirty()&&(yield this._fs._sync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())})}close(){return d(this,null,function*(){this.sync()})}};a(At,"AsyncKeyValueFile");var ge=class extends Y{constructor(t){super();this._cache=null;t>0&&(this._cache=new pe(t))}static isAvailable(){return!0}init(t){return d(this,null,function*(){this.store=t,yield this.makeRootDirectory()})}getName(){return this.store.name()}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!0}supportsSynch(){return!1}empty(){return d(this,null,function*(){this._cache&&this._cache.removeAll(),yield this.store.clear(),yield this.makeRootDirectory()})}access(t,i,n){return d(this,null,function*(){let s=this.store.beginTransaction("readonly"),o=yield this.findINode(s,t);if(!o)throw l.ENOENT(t);if(!o.toStats().hasAccess(i,n))throw l.EACCES(t)})}rename(t,i,n){return d(this,null,function*(){let s=this._cache;this._cache&&(this._cache=null,s.removeAll());try{let o=this.store.beginTransaction("readwrite"),c=E(t),u=D(t),f=E(i),h=D(i),m=yield this.findINode(o,c),g=yield this.getDirListing(o,c,m);if(!m.toStats().hasAccess(2,n))throw l.EACCES(t);if(!g[u])throw l.ENOENT(t);let S=g[u];if(delete g[u],(f+"/").indexOf(t+"/")===0)throw new l(16,c);let F,b;if(f===c?(F=m,b=g):(F=yield this.findINode(o,f),b=yield this.getDirListing(o,f,F)),b[h]){let Z=yield this.getINode(o,i,b[h]);if(Z.isFile())try{yield o.del(Z.id),yield o.del(b[h])}catch(xt){throw yield o.abort(),xt}else throw l.EPERM(i)}b[h]=S;try{yield o.put(m.id,Buffer.from(JSON.stringify(g)),!0),yield o.put(F.id,Buffer.from(JSON.stringify(b)),!0)}catch(Z){throw yield o.abort(),Z}yield o.commit()}finally{s&&(this._cache=s)}})}stat(t,i){return d(this,null,function*(){let n=this.store.beginTransaction("readonly"),o=(yield this.findINode(n,t)).toStats();if(!o.hasAccess(4,i))throw l.EACCES(t);return o})}createFile(t,i,n,s){return d(this,null,function*(){let o=this.store.beginTransaction("readwrite"),c=Buffer.alloc(0),u=yield this.commitNewFile(o,t,C.FILE,n,s,c);return new At(this,t,i,u.toStats(),c)})}openFile(t,i,n){return d(this,null,function*(){let s=this.store.beginTransaction("readonly"),o=yield this.findINode(s,t),c=yield s.get(o.id);if(!o.toStats().hasAccess(i.getMode(),n))throw l.EACCES(t);if(c===void 0)throw l.ENOENT(t);return new At(this,t,i,o.toStats(),c)})}unlink(t,i){return d(this,null,function*(){return this.removeEntry(t,!1,i)})}rmdir(t,i){return d(this,null,function*(){if((yield this.readdir(t,i)).length>0)throw l.ENOTEMPTY(t);yield this.removeEntry(t,!0,i)})}mkdir(t,i,n){return d(this,null,function*(){let s=this.store.beginTransaction("readwrite"),o=Buffer.from("{}");yield this.commitNewFile(s,t,C.DIRECTORY,i,n,o)})}readdir(t,i){return d(this,null,function*(){let n=this.store.beginTransaction("readonly"),s=yield this.findINode(n,t);if(!s.toStats().hasAccess(4,i))throw l.EACCES(t);return Object.keys(yield this.getDirListing(n,t,s))})}chmod(t,i,n){return d(this,null,function*(){yield(yield this.openFile(t,x.getFileFlag("r+"),n)).chmod(i)})}chown(t,i,n,s){return d(this,null,function*(){yield(yield this.openFile(t,x.getFileFlag("r+"),s)).chown(i,n)})}_sync(t,i,n){return d(this,null,function*(){let s=this.store.beginTransaction("readwrite"),o=yield this._findINode(s,E(t),D(t)),c=yield this.getINode(s,t,o),u=c.update(n);try{yield s.put(c.id,i,!0),u&&(yield s.put(o,c.toBuffer(),!0))}catch(f){throw yield s.abort(),f}yield s.commit()})}makeRootDirectory(){return d(this,null,function*(){let t=this.store.beginTransaction("readwrite");if((yield t.get(j))===void 0){let i=new Date().getTime(),n=new U(St(),4096,511|C.DIRECTORY,i,i,i,0,0);yield t.put(n.id,Ut(),!1),yield t.put(j,n.toBuffer(),!1),yield t.commit()}})}_findINode(o,c,u){return d(this,arguments,function*(t,i,n,s=new Set){let f=L(i,n);if(s.has(f))throw new l(5,"Infinite loop detected while finding inode",f);if(s.add(f),this._cache){let h=this._cache.get(f);if(h)return h}if(i==="/"){if(n==="")return this._cache&&this._cache.set(f,j),j;{let h=yield this.getINode(t,i,j),m=yield this.getDirListing(t,i,h);if(m[n]){let g=m[n];return this._cache&&this._cache.set(f,g),g}else throw l.ENOENT(P(i,n))}}else{let h=yield this.findINode(t,i,s),m=yield this.getDirListing(t,i,h);if(m[n]){let g=m[n];return this._cache&&this._cache.set(f,g),g}else throw l.ENOENT(P(i,n))}})}findINode(s,o){return d(this,arguments,function*(t,i,n=new Set){let c=yield this._findINode(t,E(i),D(i),n);return this.getINode(t,i,c)})}getINode(t,i,n){return d(this,null,function*(){let s=yield t.get(n);if(!s)throw l.ENOENT(i);return U.fromBuffer(s)})}getDirListing(t,i,n){return d(this,null,function*(){if(!n.isDirectory())throw l.ENOTDIR(i);let s=yield t.get(n.id);try{return JSON.parse(s.toString())}catch(o){throw l.ENOENT(i)}})}addNewNode(t,i){return d(this,null,function*(){let n=0,s=a(()=>d(this,null,function*(){if(++n===5)throw new l(5,"Unable to commit data to key-value store.");{let o=St();return(yield t.put(o,i,!1))?o:s()}}),"reroll");return s()})}commitNewFile(t,i,n,s,o,c){return d(this,null,function*(){let u=E(i),f=D(i),h=yield this.findINode(t,u),m=yield this.getDirListing(t,u,h),g=new Date().getTime();if(!h.toStats().hasAccess(2,o))throw l.EACCES(i);if(i==="/")throw l.EEXIST(i);if(m[f])throw yield t.abort(),l.EEXIST(i);try{let S=yield this.addNewNode(t,c),F=new U(S,c.length,s|n,g,g,g,o.uid,o.gid),b=yield this.addNewNode(t,F.toBuffer());return m[f]=b,yield t.put(h.id,Buffer.from(JSON.stringify(m)),!0),yield t.commit(),F}catch(S){throw t.abort(),S}})}removeEntry(t,i,n){return d(this,null,function*(){this._cache&&this._cache.remove(t);let s=this.store.beginTransaction("readwrite"),o=E(t),c=yield this.findINode(s,o),u=yield this.getDirListing(s,o,c),f=D(t);if(!u[f])throw l.ENOENT(t);let h=u[f],m=yield this.getINode(s,t,h);if(!m.toStats().hasAccess(2,n))throw l.EACCES(t);if(delete u[f],!i&&m.isDirectory())throw l.EISDIR(t);if(i&&!m.isDirectory())throw l.ENOTDIR(t);try{yield s.del(m.id),yield s.del(h),yield s.put(c.id,Buffer.from(JSON.stringify(u)),!0)}catch(g){throw yield s.abort(),g}yield s.commit()})}};a(ge,"AsyncKeyValueFileSystem");var Dt=class{static fromListing(e){let t=new Dt,i=new ot;t._index["/"]=i;let n=[["",e,i]];for(;n.length>0;){let s,o=n.pop(),c=o[0],u=o[1],f=o[2];for(let h in u)if(Object.prototype.hasOwnProperty.call(u,h)){let m=u[h],g=`${c}/${h}`;m?(t._index[g]=s=new ot,n.push([g,m,s])):s=new Yt(new k(C.FILE,-1,365)),f&&(f._ls[h]=s)}}return t}constructor(){this._index={},this.addPath("/",new ot)}fileIterator(e){for(let t in this._index)if(Object.prototype.hasOwnProperty.call(this._index,t)){let i=this._index[t],n=i.getListing();for(let s of n){let o=i.getItem(s);ir(o)&&e(o.getData())}}}addPath(e,t){if(!t)throw new Error("Inode must be specified");if(e[0]!=="/")throw new Error("Path must be absolute, got: "+e);if(Object.prototype.hasOwnProperty.call(this._index,e))return this._index[e]===t;let i=this._split_path(e),n=i[0],s=i[1],o=this._index[n];return o===void 0&&e!=="/"&&(o=new ot,!this.addPath(n,o))||e!=="/"&&!o.addItem(s,t)?!1:(di(t)&&(this._index[e]=t),!0)}addPathFast(e,t){let i=e.lastIndexOf("/"),n=i===0?"/":e.substring(0,i),s=e.substring(i+1),o=this._index[n];return o===void 0&&(o=new ot,this.addPathFast(n,o)),o.addItem(s,t)?(t.isDir()&&(this._index[e]=t),!0):!1}removePath(e){let t=this._split_path(e),i=t[0],n=t[1],s=this._index[i];if(s===void 0)return null;let o=s.remItem(n);if(o===null)return null;if(di(o)){let c=o.getListing();for(let u of c)this.removePath(e+"/"+u);e!=="/"&&delete this._index[e]}return o}ls(e){let t=this._index[e];return t===void 0?null:t.getListing()}getInode(e){let t=this._split_path(e),i=t[0],n=t[1],s=this._index[i];return s===void 0?null:i===e?s:s.getItem(n)}_split_path(e){let t=E(e),i=e.slice(t.length+(t==="/"?0:1));return[t,i]}};a(Dt,"FileIndex");var Yt=class{constructor(e){this.data=e}isFile(){return!0}isDir(){return!1}getData(){return this.data}setData(e){this.data=e}toStats(){return new k(C.FILE,4096,438)}};a(Yt,"IndexFileInode");var ot=class{constructor(e=null){this.data=e;this._ls={}}isFile(){return!1}isDir(){return!0}getData(){return this.data}getStats(){return new k(C.DIRECTORY,4096,365)}toStats(){return this.getStats()}getListing(){return Object.keys(this._ls)}getItem(e){let t=this._ls[e];return t||null}addItem(e,t){return e in this._ls?!1:(this._ls[e]=t,!0)}remItem(e){let t=this._ls[e];return t===void 0?null:(delete this._ls[e],t)}};a(ot,"IndexDirInode");function ir(r){return!!r&&r.isFile()}a(ir,"isIndexFileInode");function di(r){return!!r&&r.isDir()}a(di,"isIndexDirInode");function nr(r,e=0,t=0){return Yi(new v(e,t,e,t,e,t)),de.initialize(r)}a(nr,"initialize");function rr(r){return d(this,null,function*(){("fs"in r||r instanceof lt)&&(r={"/":r});for(let[e,t]of Object.entries(r))typeof t!="number"&&(e=e.toString(),!(t instanceof lt)&&(typeof t=="string"&&(t={fs:t}),r[e]=yield sr(t)));return nr(r)})}a(rr,"_configure");function io(r,e){if(typeof e!="function")return rr(r);rr(r).then(()=>e()).catch(t=>e(t))}a(io,"configure");function fi(t){return d(this,arguments,function*({fs:r,options:e={}}){if(!r)throw new l(1,'Missing "fs" property on configuration object.');if(typeof e!="object"||e===null)throw new l(22,'Invalid "options" property on configuration object.');let i=Object.keys(e).filter(s=>s!="fs");for(let s of i){let o=e[s];if(o===null||typeof o!="object"||!("fs"in o))continue;let c=yield fi(o);e[s]=c}let n=me[r];if(n)return n.Create(e);throw new l(1,`File system ${r} is not available in ZenFS.`)})}a(fi,"_getFileSystem");function sr(r,e){if(typeof e!="function")return fi(r);fi(r).then(t=>e(null,t)).catch(t=>e(t))}a(sr,"getFileSystem");var ro=de;return hr(no);})();
7
- /*! Bundled license information:
8
-
9
- ieee754/index.js:
10
- (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
11
-
12
- buffer/index.js:
13
- (*!
14
- * The buffer module from node.js, for the browser.
15
- *
16
- * @author Feross Aboukhadijeh <https://feross.org>
17
- * @license MIT
18
- *)
19
- */
1
+ var ZenFS=(()=>{var Et=Object.defineProperty,mi=Object.defineProperties,fi=Object.getOwnPropertyDescriptor,hi=Object.getOwnPropertyDescriptors,pi=Object.getOwnPropertyNames,We=Object.getOwnPropertySymbols,gi=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty,yi=Object.prototype.propertyIsEnumerable,bi=Reflect.get;var ee=Math.pow,Ke=(n,e,t)=>e in n?Et(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Y=(n,e)=>{for(var t in e||(e={}))je.call(e,t)&&Ke(n,t,e[t]);if(We)for(var t of We(e))yi.call(e,t)&&Ke(n,t,e[t]);return n},H=(n,e)=>mi(n,hi(e)),a=(n,e)=>Et(n,"name",{value:e,configurable:!0});var Dt=(n,e)=>{for(var t in e)Et(n,t,{get:e[t],enumerable:!0})},Si=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of pi(e))!je.call(n,r)&&r!==t&&Et(n,r,{get:()=>e[r],enumerable:!(i=fi(e,r))||i.enumerable});return n};var wi=n=>Si(Et({},"__esModule",{value:!0}),n);var $e=(n,e,t)=>bi(gi(n),t,e);var u=(n,e,t)=>new Promise((i,r)=>{var s=d=>{try{l(t.next(d))}catch(m){r(m)}},o=d=>{try{l(t.throw(d))}catch(m){r(m)}},l=d=>d.done?i(d.value):Promise.resolve(d.value).then(s,o);l((t=t.apply(n,e)).next())});var Rr={};Dt(Rr,{ActionType:()=>zt,ApiError:()=>c,AsyncKeyValueFile:()=>xt,AsyncKeyValueFileSystem:()=>te,AsyncMirror:()=>tt,BaseFile:()=>Ct,BaseFileSystem:()=>K,Cred:()=>E,ErrorCode:()=>D,ErrorStrings:()=>P,FileFlag:()=>S,FileIndex:()=>vt,FileSystem:()=>st,FileType:()=>C,FolderAdapter:()=>J,InMemory:()=>j,IndexDirInode:()=>it,IndexFileInode:()=>It,NoSyncFile:()=>Mt,OverlayFS:()=>Z,PreloadFile:()=>L,ROOT_NODE_ID:()=>V,SimpleSyncRWTransaction:()=>yt,Stats:()=>k,SyncKeyValueFile:()=>bt,SyncKeyValueFileSystem:()=>St,SynchronousFileSystem:()=>ot,backends:()=>Zt,checkOptions:()=>ne,configure:()=>Ar,decode:()=>G,default:()=>Dr,encode:()=>w,fs:()=>qt,getFileSystem:()=>di,initialize:()=>ui,isIndexDirInode:()=>Me,isIndexFileInode:()=>ci,mkdirpSync:()=>Je,randomUUID:()=>dt,registerBackend:()=>ai,setImmediate:()=>_i,toPromise:()=>Ci,wait:()=>Ei});var Ue={};Dt(Ue,{_toUnixTimestamp:()=>He,access:()=>Hn,accessSync:()=>Nr,appendFile:()=>_n,appendFileSync:()=>ar,chmod:()=>$n,chmodSync:()=>_r,chown:()=>Kn,chownSync:()=>Er,close:()=>On,closeSync:()=>lr,constants:()=>pt,createReadStream:()=>tr,createWriteStream:()=>er,exists:()=>bn,existsSync:()=>ti,fchmod:()=>Rn,fchmodSync:()=>gr,fchown:()=>Dn,fchownSync:()=>pr,fdatasync:()=>Pn,fdatasyncSync:()=>mr,fstat:()=>kn,fstatSync:()=>cr,fsync:()=>Nn,fsyncSync:()=>dr,ftruncate:()=>Tn,ftruncateSync:()=>ur,futimes:()=>Bn,futimesSync:()=>yr,getMount:()=>gt,getMounts:()=>Ze,initialize:()=>Qe,lchmod:()=>Yn,lchmodSync:()=>kr,lchown:()=>jn,lchownSync:()=>Cr,link:()=>zn,linkSync:()=>Fr,lstat:()=>wn,lstatSync:()=>rr,lutimes:()=>Jn,lutimesSync:()=>Tr,mkdir:()=>Ln,mkdirSync:()=>Sr,mount:()=>Kt,open:()=>vn,openSync:()=>or,promises:()=>kt,read:()=>An,readFile:()=>En,readFileSync:()=>ii,readSync:()=>hr,readdir:()=>Mn,readdirSync:()=>wr,readlink:()=>Wn,readlinkSync:()=>vr,realpath:()=>qn,realpathSync:()=>Be,rename:()=>yn,renameSync:()=>ir,rmdir:()=>Un,rmdirSync:()=>br,stat:()=>Sn,statSync:()=>nr,symlink:()=>Vn,symlinkSync:()=>xr,truncate:()=>Fn,truncateSync:()=>sr,umount:()=>ae,unlink:()=>xn,unlinkSync:()=>ei,unwatchFile:()=>Zn,utimes:()=>Xn,utimesSync:()=>Or,watch:()=>Qn,watchFile:()=>Gn,write:()=>In,writeFile:()=>Cn,writeFileSync:()=>ni,writeSync:()=>fr});var Fi="/",ut="/";function nt(n,e){if(typeof n!="string")throw new TypeError(`"${e}" is not a string`)}a(nt,"validateString");function Ye(n,e){let t="",i=0,r=-1,s=0,o="\0";for(let l=0;l<=n.length;++l){if(l<n.length)o=n[l];else{if(o=="/")break;o="/"}if(o=="/"){if(!(r===l-1||s===1))if(s===2){if(t.length<2||i!==2||t.at(-1)!=="."||t.at(-2)!=="."){if(t.length>2){let d=t.lastIndexOf("/");d===-1?(t="",i=0):(t=t.slice(0,d),i=t.length-1-t.lastIndexOf("/")),r=l,s=0;continue}else if(t.length!==0){t="",i=0,r=l,s=0;continue}}e&&(t+=t.length>0?"/..":"..",i=2)}else t.length>0?t+="/"+n.slice(r+1,l):t=n.slice(r+1,l),i=l-r-1;r=l,s=0}else o==="."&&s!==-1?++s:s=-1}return t}a(Ye,"normalizeString");function I(...n){let e="",t=!1;for(let i=n.length-1;i>=-1&&!t;i--){let r=i>=0?n[i]:Fi;nt(r,`paths[${i}]`),r.length!==0&&(e=`${r}/${e}`,t=r[0]==="/")}return e=Ye(e,!t),t?`/${e}`:e.length>0?e:"."}a(I,"resolve");function xi(n){if(nt(n,"path"),n.length===0)return".";let e=n[0]==="/",t=n.at(-1)==="/";return n=Ye(n,!e),n.length===0?e?"/":t?"./":".":(t&&(n+="/"),e?`/${n}`:n)}a(xi,"normalize");function R(...n){if(n.length===0)return".";let e;for(let t=0;t<n.length;++t){let i=n[t];nt(i,"path"),i.length>0&&(e===void 0?e=i:e+=`/${i}`)}return e===void 0?".":xi(e)}a(R,"join");function Xe(n,e){if(nt(n,"from"),nt(e,"to"),n===e||(n=I(n),e=I(e),n===e))return"";let t=1,i=n.length,r=i-t,s=1,o=e.length-s,l=r<o?r:o,d=-1,m=0;for(;m<l;m++){let h=n[t+m];if(h!==e[s+m])break;h==="/"&&(d=m)}if(m===l)if(o>l){if(e[s+m]==="/")return e.slice(s+m+1);if(m===0)return e.slice(s+m)}else r>l&&(n[t+m]==="/"?d=m:m===0&&(d=0));let f="";for(m=t+d+1;m<=i;++m)(m===i||n[m]==="/")&&(f+=f.length===0?"..":"/..");return`${f}${e.slice(s+d)}`}a(Xe,"relative");function F(n){if(nt(n,"path"),n.length===0)return".";let e=n[0]==="/",t=-1,i=!0;for(let r=n.length-1;r>=1;--r)if(n[r]==="/"){if(!i){t=r;break}}else i=!1;return t===-1?e?"/":".":e&&t===1?"//":n.slice(0,t)}a(F,"dirname");function A(n,e){e!==void 0&&nt(e,"ext"),nt(n,"path");let t=0,i=-1,r=!0;if(e!==void 0&&e.length>0&&e.length<=n.length){if(e===n)return"";let s=e.length-1,o=-1;for(let l=n.length-1;l>=0;--l)if(n[l]==="/"){if(!r){t=l+1;break}}else o===-1&&(r=!1,o=l+1),s>=0&&(n[l]===e[s]?--s===-1&&(i=l):(s=-1,i=o));return t===i?i=o:i===-1&&(i=n.length),n.slice(t,i)}for(let s=n.length-1;s>=0;--s)if(n[s]==="/"){if(!r){t=s+1;break}}else i===-1&&(r=!1,i=s+1);return i===-1?"":n.slice(t,i)}a(A,"basename");function Je(n,e,t,i){i.existsSync(n,t)||(Je(F(n),e,t,i),i.mkdirSync(n,e,t))}a(Je,"mkdirpSync");function Rt(n,e,t,i,r){return Math.min(n+1,e+1,t+1,i===r?e:e+1)}a(Rt,"_min");function vi(n,e){if(n===e)return 0;n.length>e.length&&([n,e]=[e,n]);let t=n.length,i=e.length;for(;t>0&&n.charCodeAt(t-1)===e.charCodeAt(i-1);)t--,i--;let r=0;for(;r<t&&n.charCodeAt(r)===e.charCodeAt(r);)r++;if(t-=r,i-=r,t===0||i===1)return i;let s=new Array(t<<1);for(let y=0;y<t;)s[t+y]=n.charCodeAt(r+y),s[y]=++y;let o,l,d,m,f;for(o=0;o+3<i;){let y=e.charCodeAt(r+(l=o)),v=e.charCodeAt(r+(d=o+1)),x=e.charCodeAt(r+(m=o+2)),g=e.charCodeAt(r+(f=o+3)),q=o+=4;for(let ht=0;ht<t;){let At=s[t+ht],Ve=s[ht];l=Rt(Ve,l,d,y,At),d=Rt(l,d,m,v,At),m=Rt(d,m,f,x,At),q=Rt(m,f,q,g,At),s[ht++]=q,f=m,m=d,d=l,l=Ve}}let h=0;for(;o<i;){let y=e.charCodeAt(r+(l=o));h=++o;for(let v=0;v<t;v++){let x=s[v];s[v]=h=x<l||h<l?x>h?h+1:x+1:y===s[t+v]?l:l+1,l=x}}return h}a(vi,"levenshtein");function ne(n,e){return u(this,null,function*(){let t=n.Options,i=n.Name,r=0,s=!1,o=!1;for(let l in t)if(Object.prototype.hasOwnProperty.call(t,l)){let d=t[l],m=e&&e[l];if(m==null){if(!d.optional){let f=Object.keys(e).filter(h=>!(h in t)).map(h=>({str:h,distance:vi(l,h)})).filter(h=>h.distance<5).sort((h,y)=>h.distance-y.distance);if(s)return;throw s=!0,new c(22,`[${i}] Required option '${l}' not provided.${f.length>0?` You provided unrecognized option '${f[0].str}'; perhaps you meant to type '${l}'.`:""}
2
+ Option description: ${d.description}`)}}else{let f=!1;if(Array.isArray(d.type)?f=d.type.indexOf(typeof m)!==-1:f=typeof m===d.type,f){if(d.validator){r++;try{yield d.validator(m)}catch(h){if(!s){if(h)throw s=!0,h;if(r--,r===0&&o)return}}}}else{if(s)return;throw s=!0,new c(22,`[${i}] Value provided for option ${l} is not the proper type. Expected ${Array.isArray(d.type)?`one of {${d.type.join(", ")}}`:d.type}, but received ${typeof m}
3
+ Option description: ${d.description}`)}}}o=!0})}a(ne,"checkOptions");function Ei(n){return new Promise(e=>{setTimeout(e,n)})}a(Ei,"wait");function Ci(n){return function(...e){return new Promise((t,i)=>{e.push((r,...s)=>{r?i(r):t(s[0])}),n(...e)})}}a(Ci,"toPromise");var _i=typeof globalThis.setImmediate=="function"?globalThis.setImmediate:n=>setTimeout(n,0),V="/",w=new TextEncoder().encode,G=new TextDecoder().decode;function dt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){let e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}a(dt,"randomUUID");var D=(g=>(g[g.EPERM=1]="EPERM",g[g.ENOENT=2]="ENOENT",g[g.EIO=5]="EIO",g[g.EBADF=9]="EBADF",g[g.EACCES=13]="EACCES",g[g.EBUSY=16]="EBUSY",g[g.EEXIST=17]="EEXIST",g[g.ENOTDIR=20]="ENOTDIR",g[g.EISDIR=21]="EISDIR",g[g.EINVAL=22]="EINVAL",g[g.EFBIG=27]="EFBIG",g[g.ENOSPC=28]="ENOSPC",g[g.EROFS=30]="EROFS",g[g.ENOTEMPTY=39]="ENOTEMPTY",g[g.ENOTSUP=95]="ENOTSUP",g))(D||{}),P={};P[1]="Operation not permitted.";P[2]="No such file or directory.";P[5]="Input/output error.";P[9]="Bad file descriptor.";P[13]="Permission denied.";P[16]="Resource busy or locked.";P[17]="File exists.";P[20]="File is not a directory.";P[21]="File is a directory.";P[22]="Invalid argument.";P[27]="File is too big.";P[28]="No space left on disk.";P[30]="Cannot modify a read-only file system.";P[39]="Directory is not empty.";P[95]="Operation is not supported.";var c=class extends Error{constructor(t,i=P[t],r){super(i);this.syscall="";this.errno=t,this.code=D[t],this.path=r,this.message=`Error: ${this.code}: ${i}${this.path?`, '${this.path}'`:""}`}static fromJSON(t){let i=new c(t.errno,t.message,t.path);return i.code=t.code,i.stack=t.stack,i}static Derserialize(t,i=0){let r=new DataView("buffer"in t?t.buffer:t),s=G(r.buffer.slice(i+4,i+4+r.getUint32(i,!0)));return c.fromJSON(JSON.parse(s))}static FileError(t,i){return new c(t,P[t],i)}static EACCES(t){return this.FileError(13,t)}static ENOENT(t){return this.FileError(2,t)}static EEXIST(t){return this.FileError(17,t)}static EISDIR(t){return this.FileError(21,t)}static ENOTDIR(t){return this.FileError(20,t)}static EPERM(t){return this.FileError(1,t)}static ENOTEMPTY(t){return this.FileError(39,t)}toString(){return this.message}toJSON(){return{errno:this.errno,code:this.code,path:this.path,stack:this.stack,message:this.message}}serialize(t=new Uint8Array(this.bufferSize()),i=0){let r=new DataView("buffer"in t?t.buffer:t),s=new Uint8Array(r.buffer),o=w(JSON.stringify(this.toJSON()));return s.set(o),r.setUint32(i,o.byteLength,!0),s}bufferSize(){return 4+JSON.stringify(this.toJSON()).length}};a(c,"ApiError");var re=class{constructor(e,t,i,r,s,o){this.uid=e;this.gid=t;this.suid=i;this.sgid=r;this.euid=s;this.egid=o}},E=re;a(E,"Cred"),E.Root=new re(0,0,0,0,0,0);var pt={};Dt(pt,{COPYFILE_EXCL:()=>Ti,COPYFILE_FICLONE:()=>Ni,COPYFILE_FICLONE_FORCE:()=>Pi,F_OK:()=>ki,O_APPEND:()=>Mi,O_CREAT:()=>Ri,O_DIRECT:()=>Yi,O_DIRECTORY:()=>zi,O_DSYNC:()=>ji,O_EXCL:()=>Bi,O_NOATIME:()=>Vi,O_NOCTTY:()=>Ui,O_NOFOLLOW:()=>Wi,O_NONBLOCK:()=>Xi,O_RDONLY:()=>Ii,O_RDWR:()=>Di,O_SYMLINK:()=>$i,O_SYNC:()=>Ki,O_TRUNC:()=>Li,O_WRONLY:()=>Ai,R_OK:()=>Q,S_IFBLK:()=>qi,S_IFCHR:()=>Ji,S_IFDIR:()=>Ut,S_IFIFO:()=>Hi,S_IFLNK:()=>Lt,S_IFMT:()=>W,S_IFREG:()=>Bt,S_IFSOCK:()=>Gi,S_IRGRP:()=>rn,S_IROTH:()=>cn,S_IRUSR:()=>Qi,S_IRWXG:()=>nn,S_IRWXO:()=>an,S_IRWXU:()=>Zi,S_IWGRP:()=>sn,S_IWOTH:()=>ln,S_IWUSR:()=>tn,S_IXGRP:()=>on,S_IXOTH:()=>un,S_IXUSR:()=>en,W_OK:()=>rt,X_OK:()=>Oi});var ki=0,Q=4,rt=2,Oi=1,Ti=1,Ni=2,Pi=4,Ii=0,Ai=1,Di=2,Ri=64,Bi=128,Ui=256,Li=512,Mi=1024,zi=65536,Vi=262144,Wi=131072,Ki=1052672,ji=4096,$i=32768,Yi=16384,Xi=2048,W=61440,Bt=32768,Ut=16384,Ji=8192,qi=24576,Hi=4096,Lt=40960,Gi=49152,Zi=448,Qi=256,tn=128,en=64,nn=56,rn=32,sn=16,on=8,an=7,cn=4,ln=2,un=1;var C=(i=>(i[i.FILE=32768]="FILE",i[i.DIRECTORY=16384]="DIRECTORY",i[i.SYMLINK=40960]="SYMLINK",i))(C||{}),k=class{constructor(e,t,i,r,s,o,l,d,m){this.dev=0;this.ino=0;this.rdev=0;this.nlink=1;this.blksize=4096;this.uid=0;this.gid=0;this.fileData=null;this.size=t;let f=0;if(typeof r!="number"&&(f=Date.now(),r=f),typeof s!="number"&&(f||(f=Date.now()),s=f),typeof o!="number"&&(f||(f=Date.now()),o=f),typeof m!="number"&&(f||(f=Date.now()),m=f),typeof l!="number"&&(l=0),typeof d!="number"&&(d=0),this.atimeMs=r,this.ctimeMs=o,this.mtimeMs=s,this.birthtimeMs=m,i)this.mode=i;else switch(e){case C.FILE:this.mode=420;break;case C.DIRECTORY:default:this.mode=511}this.blocks=Math.ceil(t/512),this.mode&61440||(this.mode|=e)}static Deserialize(e){let t=new DataView("buffer"in e?e.buffer:e),i=t.getUint32(0,!0),r=t.getUint32(4,!0),s=t.getFloat64(8,!0),o=t.getFloat64(16,!0),l=t.getFloat64(24,!0),d=t.getUint32(32,!0),m=t.getUint32(36,!0);return new k(r&61440,i,r&-61441,s,o,l,d,m)}static clone(e){return new k(e.mode&61440,e.size,e.mode&-61441,e.atimeMs,e.mtimeMs,e.ctimeMs,e.uid,e.gid,e.birthtimeMs)}get atime(){return new Date(this.atimeMs)}get mtime(){return new Date(this.mtimeMs)}get ctime(){return new Date(this.ctimeMs)}get birthtime(){return new Date(this.birthtimeMs)}serialize(){let e=new Uint8Array(32),t=new DataView(e.buffer);return t.setUint32(0,this.size,!0),t.setUint32(4,this.mode,!0),t.setFloat64(8,this.atime.getTime(),!0),t.setFloat64(16,this.mtime.getTime(),!0),t.setFloat64(24,this.ctime.getTime(),!0),t.setUint32(32,this.uid,!0),t.setUint32(36,this.gid,!0),e}isFile(){return(this.mode&61440)===32768}isDirectory(){return(this.mode&61440)===16384}isSymbolicLink(){return(this.mode&61440)===40960}hasAccess(e,t){if(t.euid===0||t.egid===0)return!0;let i=this.mode&-61441,r=15,s=15,o=15;if(t.euid==this.uid){let m=(3840&i)>>8;r=(e^m)&e}if(t.egid==this.gid){let m=(240&i)>>4;s=(e^m)&e}let l=15&i;return o=(e^l)&e,!(r&s&o)}getCred(e=this.uid,t=this.gid){return new E(e,t,this.uid,this.gid,e,t)}chmod(e){this.mode=this.mode&61440|e}chown(e,t){!isNaN(+e)&&0<=+e&&+e<ee(2,32)&&(this.uid=e),!isNaN(+t)&&0<=+t&&+t<ee(2,32)&&(this.gid=t)}isSocket(){return!1}isBlockDevice(){return!1}isCharacterDevice(){return!1}isFIFO(){return!1}};a(k,"Stats");var zt=(r=>(r[r.NOP=0]="NOP",r[r.THROW_EXCEPTION=1]="THROW_EXCEPTION",r[r.TRUNCATE_FILE=2]="TRUNCATE_FILE",r[r.CREATE_FILE=3]="CREATE_FILE",r))(zt||{}),mt=class{static getFileFlag(e){return mt.flagCache.has(e)||mt.flagCache.set(e,new mt(e)),mt.flagCache.get(e)}constructor(e){if(this.flagStr=e,mt.validFlagStrs.indexOf(e)<0)throw new c(22,"Invalid flag: "+e)}getFlagString(){return this.flagStr}getMode(){let e=0;return e<<=1,e+=+this.isReadable(),e<<=1,e+=+this.isWriteable(),e<<=1,e}isReadable(){return this.flagStr.indexOf("r")!==-1||this.flagStr.indexOf("+")!==-1}isWriteable(){return this.flagStr.indexOf("w")!==-1||this.flagStr.indexOf("a")!==-1||this.flagStr.indexOf("+")!==-1}isTruncating(){return this.flagStr.indexOf("w")!==-1}isAppendable(){return this.flagStr.indexOf("a")!==-1}isSynchronous(){return this.flagStr.indexOf("s")!==-1}isExclusive(){return this.flagStr.indexOf("x")!==-1}pathExistsAction(){return this.isExclusive()?1:this.isTruncating()?2:0}pathNotExistsAction(){return(this.isWriteable()||this.isAppendable())&&this.flagStr!=="r+"?3:1}},S=mt;a(S,"FileFlag"),S.flagCache=new Map,S.validFlagStrs=["r","r+","rs","rs+","w","wx","w+","wx+","a","ax","a+","ax+"];var Ct=class{sync(){return u(this,null,function*(){throw new c(95)})}syncSync(){throw new c(95)}datasync(){return u(this,null,function*(){return this.sync()})}datasyncSync(){return this.syncSync()}chown(e,t){return u(this,null,function*(){throw new c(95)})}chownSync(e,t){throw new c(95)}chmod(e){return u(this,null,function*(){throw new c(95)})}chmodSync(e){throw new c(95)}utimes(e,t){return u(this,null,function*(){throw new c(95)})}utimesSync(e,t){throw new c(95)}};a(Ct,"BaseFile");var L=class extends Ct{constructor(t,i,r,s,o){super();this._pos=0;this._dirty=!1;if(this._fs=t,this._path=i,this._flag=r,this._stat=s,this._buffer=o||new Uint8Array(0),this._stat.size!==this._buffer.length&&this._flag.isReadable())throw new Error(`Invalid buffer: Uint8Array is ${this._buffer.length} long, yet Stats object specifies that file is ${this._stat.size} long.`)}getBuffer(){return this._buffer}getStats(){return this._stat}getFlag(){return this._flag}getPath(){return this._path}getPos(){return this._flag.isAppendable()?this._stat.size:this._pos}advancePos(t){return this._pos+=t}setPos(t){return this._pos=t}sync(){return u(this,null,function*(){this.syncSync()})}syncSync(){throw new c(95)}close(){return u(this,null,function*(){this.closeSync()})}closeSync(){throw new c(95)}stat(){return u(this,null,function*(){return k.clone(this._stat)})}statSync(){return k.clone(this._stat)}truncate(t){if(this.truncateSync(t),this._flag.isSynchronous()&&!gt("/").metadata.synchronous)return this.sync()}truncateSync(t){if(this._dirty=!0,!this._flag.isWriteable())throw new c(1,"File not opened with a writeable mode.");if(this._stat.mtimeMs=Date.now(),t>this._buffer.length){let i=new Uint8Array(t-this._buffer.length);this.writeSync(i,0,i.length,this._buffer.length),this._flag.isSynchronous()&&gt("/").metadata.synchronous&&this.syncSync();return}this._stat.size=t,this._buffer=this._buffer.subarray(0,t),this._flag.isSynchronous()&&gt("/").metadata.synchronous&&this.syncSync()}write(t,i,r,s){return u(this,null,function*(){return this.writeSync(t,i,r,s)})}writeSync(t,i,r,s){if(this._dirty=!0,s==null&&(s=this.getPos()),!this._flag.isWriteable())throw new c(1,"File not opened with a writeable mode.");let o=s+r;if(o>this._stat.size&&(this._stat.size=o,o>this._buffer.length)){let d=new Uint8Array(o);d.set(this._buffer),this._buffer=d}this._buffer.set(t.slice(i,i+r),s);let l=this._buffer.length;return this._stat.mtimeMs=Date.now(),this._flag.isSynchronous()?(this.syncSync(),l):(this.setPos(s+l),l)}read(t,i,r,s){return u(this,null,function*(){return{bytesRead:this.readSync(t,i,r,s),buffer:t}})}readSync(t,i,r,s){if(!this._flag.isReadable())throw new c(1,"File not opened with a readable mode.");return s==null&&(s=this.getPos()),s+r>this._stat.size&&(r=this._stat.size-s),this._buffer.set(t.slice(i,i+r),s),this._stat.atimeMs=Date.now(),this._pos=s+r,this._buffer.length}chmod(t){return u(this,null,function*(){this.chmodSync(t)})}chmodSync(t){if(!this._fs.metadata.supportsProperties)throw new c(95);this._dirty=!0,this._stat.chmod(t),this.syncSync()}chown(t,i){return u(this,null,function*(){this.chownSync(t,i)})}chownSync(t,i){if(!this._fs.metadata.supportsProperties)throw new c(95);this._dirty=!0,this._stat.chown(t,i),this.syncSync()}isDirty(){return this._dirty}resetDirty(){this._dirty=!1}};a(L,"PreloadFile");var Mt=class extends L{constructor(e,t,i,r,s){super(e,t,i,r,s)}sync(){return u(this,null,function*(){})}syncSync(){}close(){return u(this,null,function*(){})}closeSync(){}};a(Mt,"NoSyncFile");var st=class{constructor(e){}};a(st,"FileSystem");var se=class extends st{constructor(t){super();this._ready=Promise.resolve(this)}get metadata(){return{name:this.constructor.name,readonly:!1,synchronous:!1,supportsProperties:!1,supportsLinks:!1,totalSpace:0,freeSpace:0}}whenReady(){return this._ready}openFile(t,i,r){return u(this,null,function*(){throw new c(95)})}createFile(t,i,r,s){return u(this,null,function*(){throw new c(95)})}open(t,i,r,s){return u(this,null,function*(){try{let o=yield this.stat(t,s);switch(i.pathExistsAction()){case 1:throw c.EEXIST(t);case 2:let l=yield this.openFile(t,i,s);if(!l)throw new Error("BFS has reached an impossible code path; please file a bug.");return yield l.truncate(0),yield l.sync(),l;case 0:return this.openFile(t,i,s);default:throw new c(22,"Invalid FileFlag object.")}}catch(o){switch(i.pathNotExistsAction()){case 3:let l=yield this.stat(F(t),s);if(l&&!l.isDirectory())throw c.ENOTDIR(F(t));return this.createFile(t,i,r,s);case 1:throw c.ENOENT(t);default:throw new c(22,"Invalid FileFlag object.")}}})}access(t,i,r){return u(this,null,function*(){throw new c(95)})}accessSync(t,i,r){throw new c(95)}rename(t,i,r){return u(this,null,function*(){throw new c(95)})}renameSync(t,i,r){throw new c(95)}stat(t,i){return u(this,null,function*(){throw new c(95)})}statSync(t,i){throw new c(95)}openFileSync(t,i,r){throw new c(95)}createFileSync(t,i,r,s){throw new c(95)}openSync(t,i,r,s){let o;try{o=this.statSync(t,s)}catch(l){switch(i.pathNotExistsAction()){case 3:if(!this.statSync(F(t),s).isDirectory())throw c.ENOTDIR(F(t));return this.createFileSync(t,i,r,s);case 1:throw c.ENOENT(t);default:throw new c(22,"Invalid FileFlag object.")}}if(!o.hasAccess(r,s))throw c.EACCES(t);switch(i.pathExistsAction()){case 1:throw c.EEXIST(t);case 2:return this.unlinkSync(t,s),this.createFileSync(t,i,o.mode,s);case 0:return this.openFileSync(t,i,s);default:throw new c(22,"Invalid FileFlag object.")}}unlink(t,i){return u(this,null,function*(){throw new c(95)})}unlinkSync(t,i){throw new c(95)}rmdir(t,i){return u(this,null,function*(){throw new c(95)})}rmdirSync(t,i){throw new c(95)}mkdir(t,i,r){return u(this,null,function*(){throw new c(95)})}mkdirSync(t,i,r){throw new c(95)}readdir(t,i){return u(this,null,function*(){throw new c(95)})}readdirSync(t,i){throw new c(95)}exists(t,i){return u(this,null,function*(){try{return yield this.stat(t,i),!0}catch(r){return!1}})}existsSync(t,i){try{return this.statSync(t,i),!0}catch(r){return!1}}realpath(t,i){return u(this,null,function*(){if(this.metadata.supportsLinks){let r=t.split(ut);for(let s=0;s<r.length;s++){let o=r.slice(0,s+1);r[s]=R(...o)}return r.join(ut)}else{if(!(yield this.exists(t,i)))throw c.ENOENT(t);return t}})}realpathSync(t,i){if(this.metadata.supportsLinks){let r=t.split(ut);for(let s=0;s<r.length;s++){let o=r.slice(0,s+1);r[s]=R(...o)}return r.join(ut)}else{if(this.existsSync(t,i))return t;throw c.ENOENT(t)}}truncate(t,i,r){return u(this,null,function*(){let s=yield this.open(t,S.getFileFlag("r+"),420,r);try{yield s.truncate(i)}finally{yield s.close()}})}truncateSync(t,i,r){let s=this.openSync(t,S.getFileFlag("r+"),420,r);try{s.truncateSync(i)}finally{s.closeSync()}}readFile(t,i,r,s){return u(this,null,function*(){let o=yield this.open(t,r,420,s);try{let l=yield o.stat(),d=new Uint8Array(l.size);return yield o.read(d,0,l.size,0),yield o.close(),i===null?d:G(d)}finally{yield o.close()}})}readFileSync(t,i,r,s){let o=this.openSync(t,r,420,s);try{let l=o.statSync(),d=new Uint8Array(l.size);return o.readSync(d,0,l.size,0),o.closeSync(),i===null?d:G(d)}finally{o.closeSync()}}writeFile(t,i,r,s,o,l){return u(this,null,function*(){let d=yield this.open(t,s,o,l);try{typeof i=="string"&&(i=w(i)),yield d.write(i,0,i.length,0)}finally{yield d.close()}})}writeFileSync(t,i,r,s,o,l){let d=this.openSync(t,s,o,l);try{typeof i=="string"&&(i=w(i)),d.writeSync(i,0,i.length,0)}finally{d.closeSync()}}appendFile(t,i,r,s,o,l){return u(this,null,function*(){let d=yield this.open(t,s,o,l);try{typeof i=="string"&&(i=w(i)),yield d.write(i,0,i.length,null)}finally{yield d.close()}})}appendFileSync(t,i,r,s,o,l){let d=this.openSync(t,s,o,l);try{typeof i=="string"&&(i=w(i)),d.writeSync(i,0,i.length,null)}finally{d.closeSync()}}chmod(t,i,r){return u(this,null,function*(){throw new c(95)})}chmodSync(t,i,r){throw new c(95)}chown(t,i,r,s){return u(this,null,function*(){throw new c(95)})}chownSync(t,i,r,s){throw new c(95)}utimes(t,i,r,s){return u(this,null,function*(){throw new c(95)})}utimesSync(t,i,r,s){throw new c(95)}link(t,i,r){return u(this,null,function*(){throw new c(95)})}linkSync(t,i,r){throw new c(95)}symlink(t,i,r,s){return u(this,null,function*(){throw new c(95)})}symlinkSync(t,i,r,s){throw new c(95)}readlink(t,i){return u(this,null,function*(){throw new c(95)})}readlinkSync(t,i){throw new c(95)}},K=se;a(K,"BaseFileSystem"),K.Name=se.name;var ot=class extends K{get metadata(){return H(Y({},super.metadata),{synchronous:!0})}access(e,t,i){return u(this,null,function*(){return this.accessSync(e,t,i)})}rename(e,t,i){return u(this,null,function*(){return this.renameSync(e,t,i)})}stat(e,t){return u(this,null,function*(){return this.statSync(e,t)})}open(e,t,i,r){return u(this,null,function*(){return this.openSync(e,t,i,r)})}unlink(e,t){return u(this,null,function*(){return this.unlinkSync(e,t)})}rmdir(e,t){return u(this,null,function*(){return this.rmdirSync(e,t)})}mkdir(e,t,i){return u(this,null,function*(){return this.mkdirSync(e,t,i)})}readdir(e,t){return u(this,null,function*(){return this.readdirSync(e,t)})}chmod(e,t,i){return u(this,null,function*(){return this.chmodSync(e,t,i)})}chown(e,t,i,r){return u(this,null,function*(){return this.chownSync(e,t,i,r)})}utimes(e,t,i,r){return u(this,null,function*(){return this.utimesSync(e,t,i,r)})}link(e,t,i){return u(this,null,function*(){return this.linkSync(e,t,i)})}symlink(e,t,i,r){return u(this,null,function*(){return this.symlinkSync(e,t,i,r)})}readlink(e,t){return u(this,null,function*(){return this.readlinkSync(e,t)})}};a(ot,"SynchronousFileSystem");var B=class{constructor(e,t,i,r,s,o,l,d){this.id=e;this.size=t;this.mode=i;this.atime=r;this.mtime=s;this.ctime=o;this.uid=l;this.gid=d}static Deserialize(e){let t=new DataView("buffer"in e?e.buffer:e);return new B(G(t.buffer.slice(38)),t.getUint32(0,!0),t.getUint16(4,!0),t.getFloat64(6,!0),t.getFloat64(14,!0),t.getFloat64(22,!0),t.getUint32(30,!0),t.getUint32(34,!0))}toStats(){return new k((this.mode&61440)===C.DIRECTORY?C.DIRECTORY:C.FILE,this.size,this.mode,this.atime,this.mtime,this.ctime,this.uid,this.gid)}getSize(){return 38+this.id.length}serialize(e=new Uint8Array(this.getSize())){let t=new DataView("buffer"in e?e.buffer:e);t.setUint32(0,this.size,!0),t.setUint16(4,this.mode,!0),t.setFloat64(6,this.atime,!0),t.setFloat64(14,this.mtime,!0),t.setFloat64(22,this.ctime,!0),t.setUint32(30,this.uid,!0),t.setUint32(34,this.gid,!0);let i=new Uint8Array(t.buffer);return i.set(w(this.id),38),i}update(e){let t=!1;this.size!==e.size&&(this.size=e.size,t=!0),this.mode!==e.mode&&(this.mode=e.mode,t=!0);let i=e.atime.getTime();this.atime!==i&&(this.atime=i,t=!0);let r=e.mtime.getTime();this.mtime!==r&&(this.mtime=r,t=!0);let s=e.ctime.getTime();return this.ctime!==s&&(this.ctime=s,t=!0),this.uid!==e.uid&&(this.uid=e.uid,t=!0),this.uid!==e.uid&&(this.uid=e.uid,t=!0),t}isFile(){return(this.mode&61440)===C.FILE}isDirectory(){return(this.mode&61440)===C.DIRECTORY}};a(B,"Inode");var yt=class{constructor(e){this.store=e;this.originalData={};this.modifiedKeys=[]}get(e){let t=this.store.get(e);return this.stashOldValue(e,t),t}put(e,t,i){return this.markModified(e),this.store.put(e,t,i)}del(e){this.markModified(e),this.store.del(e)}commit(){}abort(){for(let e of this.modifiedKeys){let t=this.originalData[e];t?this.store.put(e,t,!0):this.store.del(e)}}_has(e){return Object.prototype.hasOwnProperty.call(this.originalData,e)}stashOldValue(e,t){this._has(e)||(this.originalData[e]=t)}markModified(e){this.modifiedKeys.indexOf(e)===-1&&(this.modifiedKeys.push(e),this._has(e)||(this.originalData[e]=this.store.get(e)))}};a(yt,"SimpleSyncRWTransaction");var bt=class extends L{constructor(e,t,i,r,s){super(e,t,i,r,s)}syncSync(){this.isDirty()&&(this._fs._syncSync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())}closeSync(){this.syncSync()}};a(bt,"SyncKeyValueFile");var St=class extends ot{constructor(t){super();this.store=t.store,this.makeRootDirectory()}static isAvailable(){return!0}getName(){return this.store.name()}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!0}supportsSynch(){return!0}empty(){this.store.clear(),this.makeRootDirectory()}accessSync(t,i,r){let s=this.store.beginTransaction("readonly");if(!this.findINode(s,t).toStats().hasAccess(i,r))throw c.EACCES(t)}renameSync(t,i,r){let s=this.store.beginTransaction("readwrite"),o=F(t),l=A(t),d=F(i),m=A(i),f=this.findINode(s,o),h=this.getDirListing(s,o,f);if(!f.toStats().hasAccess(2,r))throw c.EACCES(t);if(!h[l])throw c.ENOENT(t);let y=h[l];if(delete h[l],(d+"/").indexOf(t+"/")===0)throw new c(16,o);let v,x;if(d===o?(v=f,x=h):(v=this.findINode(s,d),x=this.getDirListing(s,d,v)),x[m]){let g=this.getINode(s,i,x[m]);if(g.isFile())try{s.del(g.id),s.del(x[m])}catch(q){throw s.abort(),q}else throw c.EPERM(i)}x[m]=y;try{s.put(f.id,w(JSON.stringify(h)),!0),s.put(v.id,w(JSON.stringify(x)),!0)}catch(g){throw s.abort(),g}s.commit()}statSync(t,i){let r=this.findINode(this.store.beginTransaction("readonly"),t).toStats();if(!r.hasAccess(4,i))throw c.EACCES(t);return r}createFileSync(t,i,r,s){let o=this.store.beginTransaction("readwrite"),l=new Uint8Array(0),d=this.commitNewFile(o,t,C.FILE,r,s,l);return new bt(this,t,i,d.toStats(),l)}openFileSync(t,i,r){let s=this.store.beginTransaction("readonly"),o=this.findINode(s,t),l=s.get(o.id);if(!o.toStats().hasAccess(i.getMode(),r))throw c.EACCES(t);if(l===void 0)throw c.ENOENT(t);return new bt(this,t,i,o.toStats(),l)}unlinkSync(t,i){this.removeEntry(t,!1,i)}rmdirSync(t,i){if(this.readdirSync(t,i).length>0)throw c.ENOTEMPTY(t);this.removeEntry(t,!0,i)}mkdirSync(t,i,r){let s=this.store.beginTransaction("readwrite"),o=w("{}");this.commitNewFile(s,t,C.DIRECTORY,i,r,o)}readdirSync(t,i){let r=this.store.beginTransaction("readonly"),s=this.findINode(r,t);if(!s.toStats().hasAccess(4,i))throw c.EACCES(t);return Object.keys(this.getDirListing(r,t,s))}chmodSync(t,i,r){this.openFileSync(t,S.getFileFlag("r+"),r).chmodSync(i)}chownSync(t,i,r,s){this.openFileSync(t,S.getFileFlag("r+"),s).chownSync(i,r)}_syncSync(t,i,r){let s=this.store.beginTransaction("readwrite"),o=this._findINode(s,F(t),A(t)),l=this.getINode(s,t,o),d=l.update(r);try{s.put(l.id,i,!0),d&&s.put(o,l.serialize(),!0)}catch(m){throw s.abort(),m}s.commit()}makeRootDirectory(){let t=this.store.beginTransaction("readwrite");if(t.get(V)===void 0){let i=new Date().getTime(),r=new B(dt(),4096,511|C.DIRECTORY,i,i,i,0,0);t.put(r.id,w("{}"),!1),t.put(V,r.serialize(),!1),t.commit()}}_findINode(t,i,r,s=new Set){let o=R(i,r);if(s.has(o))throw new c(5,"Infinite loop detected while finding inode",o);s.add(o);let l=a(d=>{let m=this.getDirListing(t,i,d);if(m[r])return m[r];throw c.ENOENT(I(i,r))},"readDirectory");return i==="/"?r===""?V:l(this.getINode(t,i,V)):l(this.getINode(t,i+ut+r,this._findINode(t,F(i),A(i),s)))}findINode(t,i){return this.getINode(t,i,this._findINode(t,F(i),A(i)))}getINode(t,i,r){let s=t.get(r);if(s===void 0)throw c.ENOENT(i);return B.Deserialize(s)}getDirListing(t,i,r){if(!r.isDirectory())throw c.ENOTDIR(i);let s=t.get(r.id);if(s===void 0)throw c.ENOENT(i);return JSON.parse(s.toString())}addNewNode(t,i){let s;for(;0<5;)try{return s=dt(),t.put(s,i,!1),s}catch(o){}throw new c(5,"Unable to commit data to key-value store.")}commitNewFile(t,i,r,s,o,l){let d=F(i),m=A(i),f=this.findINode(t,d),h=this.getDirListing(t,d,f),y=new Date().getTime();if(!f.toStats().hasAccess(4,o))throw c.EACCES(i);if(i==="/")throw c.EEXIST(i);if(h[m])throw c.EEXIST(i);let v;try{let x=this.addNewNode(t,l);v=new B(x,l.length,s|r,y,y,y,o.uid,o.gid);let g=this.addNewNode(t,v.serialize());h[m]=g,t.put(f.id,w(JSON.stringify(h)),!0)}catch(x){throw t.abort(),x}return t.commit(),v}removeEntry(t,i,r){let s=this.store.beginTransaction("readwrite"),o=F(t),l=this.findINode(s,o),d=this.getDirListing(s,o,l),m=A(t);if(!d[m])throw c.ENOENT(t);let f=d[m],h=this.getINode(s,t,f);if(!h.toStats().hasAccess(2,r))throw c.EACCES(t);if(delete d[m],!i&&h.isDirectory())throw c.EISDIR(t);if(i&&!h.isDirectory())throw c.ENOTDIR(t);try{s.del(h.id),s.del(f),s.put(l.id,w(JSON.stringify(d)),!0)}catch(y){throw s.abort(),y}s.commit()}};a(St,"SyncKeyValueFileSystem");function at(n,e){e=typeof n=="function"?n:e,ne(this,n);let t=new this(typeof n=="function"?{}:n);if(typeof e!="function")return t.whenReady();t.whenReady().then(i=>e(null,i)).catch(i=>e(i))}a(at,"CreateBackend");var Vt=class{constructor(){this.store=new Map}name(){return j.Name}clear(){this.store.clear()}beginTransaction(e){return new yt(this)}get(e){return this.store.get(e)}put(e,t,i){return!i&&this.store.has(e)?!1:(this.store.set(e,t),!0)}del(e){this.store.delete(e)}};a(Vt,"InMemoryStore");var oe=class extends St{constructor(){super({store:new Vt})}},j=oe;a(j,"InMemoryFileSystem"),j.Name="InMemory",j.Create=at.bind(oe),j.Options={};function He(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime()/1e3;throw new Error("Cannot parse time: "+n)}a(He,"_toUnixTimestamp");function M(n,e){switch(typeof n){case"number":return n;case"string":let t=parseInt(n,8);return isNaN(t)?e:t;default:return e}}a(M,"normalizeMode");function U(n){if(n instanceof Date)return n;if(typeof n=="number")return new Date(n*1e3);throw new c(22,"Invalid time.")}a(U,"normalizeTime");function O(n){if(n.indexOf("\0")>=0)throw new c(22,"Path must be a string without null bytes.");if(n==="")throw new c(22,"Path must not be empty.");return n=n.replaceAll(/\/+/g,"/"),I(n)}a(O,"normalizePath");function ct(n,e,t,i){switch(n===null?"null":typeof n){case"object":return{encoding:typeof n.encoding!="undefined"?n.encoding:e,flag:typeof n.flag!="undefined"?n.flag:t,mode:M(n.mode,i)};case"string":return{encoding:n,flag:t,mode:i};case"null":case"undefined":case"function":return{encoding:e,flag:t,mode:i};default:throw new TypeError(`"options" must be a string or an object, got ${typeof n} instead.`)}}a(ct,"normalizeOptions");function b(){}a(b,"nop");var p=E.Root;function Ge(n){p=n}a(Ge,"setCred");var ft=new Map,dn=100;function Wt(n){let e=dn++;return ft.set(e,n),e}a(Wt,"getFdForFile");function _(n){if(!ft.has(n))throw new c(9,"Invalid file descriptor.");return ft.get(n)}a(_,"fd2file");var X=new Map;j.Create().then(n=>Kt("/",n));function gt(n){return X.get(n)}a(gt,"getMount");function Ze(){return Object.fromEntries(X.entries())}a(Ze,"getMounts");function Kt(n,e){if(n[0]!=="/"&&(n="/"+n),n=I(n),X.has(n))throw new c(22,"Mount point "+n+" is already in use.");X.set(n,e)}a(Kt,"mount");function ae(n){if(n[0]!=="/"&&(n=`/${n}`),n=I(n),!X.has(n))throw new c(22,"Mount point "+n+" is already unmounted.");X.delete(n)}a(ae,"umount");function $(n){let e=[...X].sort((t,i)=>t[0].length>i[0].length?-1:1);for(let[t,i]of e)if(t.length<=n.length&&n.startsWith(t))return n=n.slice(t.length>1?t.length:0),n===""&&(n="/"),{fs:i,path:n,mountPoint:t};throw new c(5,"ZenFS not initialized with a file system")}a($,"resolveFS");function qe(n,e){for(let[t,i]of Object.entries(e))n=n.replaceAll(t,i);return n}a(qe,"fixPaths");function lt(n,e){return n.stack=qe(n.stack,e),n.message=qe(n.message,e),n}a(lt,"fixError");function Qe(n){n["/"]&&ae("/");for(let[e,t]of Object.entries(n)){if(!t.constructor.isAvailable())throw new c(22,`Can not mount "${e}" since the filesystem is unavailable.`);Kt(e,t)}}a(Qe,"initialize");var kt={};Dt(kt,{access:()=>Re,appendFile:()=>fe,chmod:()=>Pe,chown:()=>Te,close:()=>pe,constants:()=>pt,createReadStream:()=>pn,createWriteStream:()=>gn,exists:()=>jt,fchmod:()=>Fe,fchown:()=>we,fdatasync:()=>be,fstat:()=>he,fsync:()=>ye,ftruncate:()=>ge,futimes:()=>xe,lchmod:()=>Ie,lchown:()=>Ne,link:()=>_e,lstat:()=>ue,lutimes:()=>De,mkdir:()=>Ee,open:()=>me,read:()=>Se,readFile:()=>Yt,readdir:()=>Ce,readlink:()=>Oe,realpath:()=>_t,rename:()=>ce,rmdir:()=>ve,stat:()=>le,symlink:()=>ke,truncate:()=>de,unlink:()=>$t,unwatchFile:()=>fn,utimes:()=>Ae,watch:()=>hn,watchFile:()=>mn,write:()=>Jt,writeFile:()=>Xt});function T(){return u(this,arguments,function*(...[n,e,t,...i]){t=O(t);let{fs:r,path:s}=$(e&&(yield jt(t))?yield _t(t):t);try{return r[n](s,...i)}catch(o){throw lt(o,{[s]:t})}})}a(T,"doOp");function ce(n,e){return u(this,null,function*(){n=O(n),e=O(e);let t=$(n),i=$(e),r={[t.path]:n,[i.path]:e};try{if(t===i)return t.fs.rename(t.path,i.path,p);let s=yield Yt(n);yield Xt(e,s),yield $t(n)}catch(s){throw lt(s,r)}})}a(ce,"rename");function jt(n){return u(this,null,function*(){n=O(n);try{let{fs:e,path:t}=$(n);return e.exists(t,p)}catch(e){if(e.errno==2)return!1;throw e}})}a(jt,"exists");function le(n){return u(this,null,function*(){return T("stat",!0,n,p)})}a(le,"stat");function ue(n){return u(this,null,function*(){return T("stat",!1,n,p)})}a(ue,"lstat");function de(n,e=0){return u(this,null,function*(){if(e<0)throw new c(22);return T("truncate",!0,n,e,p)})}a(de,"truncate");function $t(n){return u(this,null,function*(){return T("unlink",!1,n,p)})}a($t,"unlink");function me(n,e,t=420){return u(this,null,function*(){let i=yield T("open",!0,n,S.getFileFlag(e),M(t,420),p);return Wt(i)})}a(me,"open");function Yt(t){return u(this,arguments,function*(n,e={}){let i=ct(e,null,"r",null),r=S.getFileFlag(i.flag);if(!r.isReadable())throw new c(22,"Flag passed to readFile must allow for reading.");return T("readFile",!0,n,i.encoding,r,p)})}a(Yt,"readFile");function Xt(n,e,t){return u(this,null,function*(){let i=ct(t,"utf8","w",420),r=S.getFileFlag(i.flag);if(!r.isWriteable())throw new c(22,"Flag passed to writeFile must allow for writing.");return T("writeFile",!0,n,e,i.encoding,r,i.mode,p)})}a(Xt,"writeFile");function fe(n,e,t){return u(this,null,function*(){let i=ct(t,"utf8","a",420),r=S.getFileFlag(i.flag);if(!r.isAppendable())throw new c(22,"Flag passed to appendFile must allow for appending.");return T("appendFile",!0,n,e,i.encoding,r,i.mode,p)})}a(fe,"appendFile");function he(n){return u(this,null,function*(){return _(n).stat()})}a(he,"fstat");function pe(n){return u(this,null,function*(){yield _(n).close(),ft.delete(n)})}a(pe,"close");function ge(n,e=0){return u(this,null,function*(){let t=_(n);if(e<0)throw new c(22);return t.truncate(e)})}a(ge,"ftruncate");function ye(n){return u(this,null,function*(){return _(n).sync()})}a(ye,"fsync");function be(n){return u(this,null,function*(){return _(n).datasync()})}a(be,"fdatasync");function Jt(n,e,t,i,r){return u(this,null,function*(){let s,o=0,l,d;if(typeof e=="string"){d=typeof t=="number"?t:null;let f=typeof i=="string"?i:"utf8";o=0,s=w(e),l=s.length}else s=e,o=t,l=i,d=typeof r=="number"?r:null;let m=_(n);return d==null&&(d=m.getPos()),m.write(s,o,l,d)})}a(Jt,"write");function Se(n,e,t,i,r){return u(this,null,function*(){let s=_(n);return isNaN(+r)&&(r=s.getPos()),s.read(e,t,i,r)})}a(Se,"read");function we(n,e,t){return u(this,null,function*(){return _(n).chown(e,t)})}a(we,"fchown");function Fe(n,e){return u(this,null,function*(){let t=typeof e=="string"?parseInt(e,8):e;return _(n).chmod(t)})}a(Fe,"fchmod");function xe(n,e,t){return u(this,null,function*(){return _(n).utimes(U(e),U(t))})}a(xe,"futimes");function ve(n){return u(this,null,function*(){return T("rmdir",!0,n,p)})}a(ve,"rmdir");function Ee(n,e){return u(this,null,function*(){return T("mkdir",!0,n,M(e,511),p)})}a(Ee,"mkdir");function Ce(n){return u(this,null,function*(){n=O(n);let e=yield T("readdir",!0,n,p),t=[...X.keys()];for(let i of t)if(i.startsWith(n)){let r=i.slice(n.length);if(r.includes("/")||r.length==0)continue;e.push(r)}return e})}a(Ce,"readdir");function _e(n,e){return u(this,null,function*(){return e=O(e),T("link",!1,n,e,p)})}a(_e,"link");function ke(n,e,t="file"){return u(this,null,function*(){if(!["file","dir","junction"].includes(t))throw new c(22,"Invalid type: "+t);return e=O(e),T("symlink",!1,n,e,t,p)})}a(ke,"symlink");function Oe(n){return u(this,null,function*(){return T("readlink",!1,n,p)})}a(Oe,"readlink");function Te(n,e,t){return u(this,null,function*(){return T("chown",!0,n,e,t,p)})}a(Te,"chown");function Ne(n,e,t){return u(this,null,function*(){return T("chown",!1,n,e,t,p)})}a(Ne,"lchown");function Pe(n,e){return u(this,null,function*(){let t=M(e,-1);if(t<0)throw new c(22,"Invalid mode.");return T("chmod",!0,n,t,p)})}a(Pe,"chmod");function Ie(n,e){return u(this,null,function*(){let t=M(e,-1);if(t<1)throw new c(22,"Invalid mode.");return T("chmod",!1,O(n),t,p)})}a(Ie,"lchmod");function Ae(n,e,t){return u(this,null,function*(){return T("utimes",!0,n,U(e),U(t),p)})}a(Ae,"utimes");function De(n,e,t){return u(this,null,function*(){return T("utimes",!1,n,U(e),U(t),p)})}a(De,"lutimes");function _t(t){return u(this,arguments,function*(n,e={}){n=O(n);let{fs:i,path:r,mountPoint:s}=$(n);try{if(!(yield i.stat(r,p)).isSymbolicLink())return n;let l=s+O(yield i.readlink(r,p));return _t(l)}catch(o){throw lt(o,{[r]:n})}})}a(_t,"realpath");function mn(i,r){return u(this,arguments,function*(n,e,t=b){throw new c(95)})}a(mn,"watchFile");function fn(t){return u(this,arguments,function*(n,e=b){throw new c(95)})}a(fn,"unwatchFile");function hn(i,r){return u(this,arguments,function*(n,e,t=b){throw new c(95)})}a(hn,"watch");function Re(n,e=384){return u(this,null,function*(){return T("access",!0,n,e,p)})}a(Re,"access");function pn(n,e){return u(this,null,function*(){throw new c(95)})}a(pn,"createReadStream");function gn(n,e){return u(this,null,function*(){throw new c(95)})}a(gn,"createWriteStream");function yn(n,e,t=b){ce(n,e).then(()=>t()).catch(t)}a(yn,"rename");function bn(n,e=b){jt(n).then(e).catch(()=>e(!1))}a(bn,"exists");function Sn(n,e=b){le(n).then(t=>e(null,t)).catch(e)}a(Sn,"stat");function wn(n,e=b){ue(n).then(t=>e(null,t)).catch(e)}a(wn,"lstat");function Fn(n,e=0,t=b){t=typeof e=="function"?e:t,de(n,typeof e=="number"?e:0).then(()=>t()).catch(t)}a(Fn,"truncate");function xn(n,e=b){$t(n).then(()=>e()).catch(e)}a(xn,"unlink");function vn(n,e,t,i=b){let r=M(t,420);i=typeof t=="function"?t:i,me(n,e,r).then(s=>i(null,s)).catch(i)}a(vn,"open");function En(n,e={},t=b){t=typeof e=="function"?e:t,Yt(n,typeof e=="function"?null:e)}a(En,"readFile");function Cn(n,e,t={},i=b){i=typeof t=="function"?t:i,Xt(n,e,typeof t=="function"?void 0:t)}a(Cn,"writeFile");function _n(n,e,t,i=b){i=typeof t=="function"?t:i,fe(n,e,typeof t=="function"?null:t)}a(_n,"appendFile");function kn(n,e=b){he(n).then(t=>e(null,t)).catch(e)}a(kn,"fstat");function On(n,e=b){pe(n).then(()=>e()).catch(e)}a(On,"close");function Tn(n,e,t=b){let i=typeof e=="number"?e:0;t=typeof e=="function"?e:t,ge(n,i)}a(Tn,"ftruncate");function Nn(n,e=b){ye(n).then(()=>e()).catch(e)}a(Nn,"fsync");function Pn(n,e=b){be(n).then(()=>e()).catch(e)}a(Pn,"fdatasync");function In(n,e,t,i,r,s=b){let o,l,d,m=null,f;if(typeof e=="string"){switch(f="utf8",typeof t){case"function":s=t;break;case"number":m=t,f=typeof i=="string"?i:"utf8",s=typeof r=="function"?r:s;break;default:s=typeof i=="function"?i:typeof r=="function"?r:s,s(new c(22,"Invalid arguments."));return}o=w(e),l=0,d=o.length;let h=s;Jt(n,o,l,d,m).then(y=>h(null,y,G(o))).catch(h)}else{o=e,l=t,d=i,m=typeof r=="number"?r:null;let h=typeof r=="function"?r:s;Jt(n,o,l,d,m).then(y=>h(null,y,o)).catch(h)}}a(In,"write");function An(n,e,t,i,r,s=b){Se(n,e,t,i,r).then(({bytesRead:o,buffer:l})=>s(null,o,l)).catch(s)}a(An,"read");function Dn(n,e,t,i=b){we(n,e,t).then(()=>i()).catch(i)}a(Dn,"fchown");function Rn(n,e,t){Fe(n,e).then(()=>t()).catch(t)}a(Rn,"fchmod");function Bn(n,e,t,i=b){xe(n,e,t).then(()=>i()).catch(i)}a(Bn,"futimes");function Un(n,e=b){ve(n).then(()=>e()).catch(e)}a(Un,"rmdir");function Ln(n,e,t=b){Ee(n,e).then(()=>t()).catch(t)}a(Ln,"mkdir");function Mn(n,e=b){Ce(n).then(t=>e(null,t)).catch(e)}a(Mn,"readdir");function zn(n,e,t=b){_e(n,e).then(()=>t()).catch(t)}a(zn,"link");function Vn(n,e,t,i=b){let r=typeof t=="string"?t:"file";i=typeof t=="function"?t:i,ke(n,e,typeof t=="function"?null:t).then(()=>i()).catch(i)}a(Vn,"symlink");function Wn(n,e=b){Oe(n).then(t=>e(null,t)).catch(e)}a(Wn,"readlink");function Kn(n,e,t,i=b){Te(n,e,t).then(()=>i()).catch(i)}a(Kn,"chown");function jn(n,e,t,i=b){Ne(n,e,t).then(()=>i()).catch(i)}a(jn,"lchown");function $n(n,e,t=b){Pe(n,e).then(()=>t()).catch(t)}a($n,"chmod");function Yn(n,e,t=b){Ie(n,e).then(()=>t()).catch(t)}a(Yn,"lchmod");function Xn(n,e,t,i=b){Ae(n,e,t).then(()=>i()).catch(i)}a(Xn,"utimes");function Jn(n,e,t,i=b){De(n,e,t).then(()=>i()).catch(i)}a(Jn,"lutimes");function qn(n,e,t=b){let i=typeof e=="object"?e:{};t=typeof e=="function"?e:t,_t(n,typeof e=="function"?null:e).then(r=>t(null,r)).catch(t)}a(qn,"realpath");function Hn(n,e,t=b){let i=typeof e=="number"?e:4;t=typeof e=="function"?e:t,Re(n,typeof e=="function"?null:e).then(()=>t()).catch(t)}a(Hn,"access");function Gn(n,e,t=b){throw new c(95)}a(Gn,"watchFile");function Zn(n,e=b){throw new c(95)}a(Zn,"unwatchFile");function Qn(n,e,t=b){throw new c(95)}a(Qn,"watch");function tr(n,e){throw new c(95)}a(tr,"createReadStream");function er(n,e){throw new c(95)}a(er,"createWriteStream");function N(...[n,e,t,...i]){t=O(t);let{fs:r,path:s}=$(e&&ti(t)?Be(t):t);try{return r[n](s,...i)}catch(o){throw lt(o,{[s]:t})}}a(N,"doOp");function ir(n,e){n=O(n),e=O(e);let t=$(n),i=$(e),r={[t.path]:n,[i.path]:e};try{if(t===i)return t.fs.renameSync(t.path,i.path,p);let s=ii(n);ni(e,s),ei(n)}catch(s){throw lt(s,r)}}a(ir,"renameSync");function ti(n){n=O(n);try{let{fs:e,path:t}=$(n);return e.existsSync(t,p)}catch(e){if(e.errno==2)return!1;throw e}}a(ti,"existsSync");function nr(n){return N("statSync",!0,n,p)}a(nr,"statSync");function rr(n){return N("statSync",!1,n,p)}a(rr,"lstatSync");function sr(n,e=0){if(e<0)throw new c(22);return N("truncateSync",!0,n,e,p)}a(sr,"truncateSync");function ei(n){return N("unlinkSync",!1,n,p)}a(ei,"unlinkSync");function or(n,e,t=420){let i=N("openSync",!0,n,S.getFileFlag(e),M(t,420),p);return Wt(i)}a(or,"openSync");function ii(n,e={}){let t=ct(e,null,"r",null),i=S.getFileFlag(t.flag);if(!i.isReadable())throw new c(22,"Flag passed to readFile must allow for reading.");return N("readFileSync",!0,n,t.encoding,i,p)}a(ii,"readFileSync");function ni(n,e,t){let i=ct(t,"utf8","w",420),r=S.getFileFlag(i.flag);if(!r.isWriteable())throw new c(22,"Flag passed to writeFile must allow for writing.");return N("writeFileSync",!0,n,e,i.encoding,r,i.mode,p)}a(ni,"writeFileSync");function ar(n,e,t){let i=ct(t,"utf8","a",420),r=S.getFileFlag(i.flag);if(!r.isAppendable())throw new c(22,"Flag passed to appendFile must allow for appending.");return N("appendFileSync",!0,n,e,i.encoding,r,i.mode,p)}a(ar,"appendFileSync");function cr(n){return _(n).statSync()}a(cr,"fstatSync");function lr(n){_(n).closeSync(),ft.delete(n)}a(lr,"closeSync");function ur(n,e=0){let t=_(n);if(e<0)throw new c(22);t.truncateSync(e)}a(ur,"ftruncateSync");function dr(n){_(n).syncSync()}a(dr,"fsyncSync");function mr(n){_(n).datasyncSync()}a(mr,"fdatasyncSync");function fr(n,e,t,i,r){let s,o=0,l,d;if(typeof e=="string"){d=typeof t=="number"?t:null;let f=typeof i=="string"?i:"utf8";o=0,s=w(e),l=s.length}else s=e,o=t,l=i,d=typeof r=="number"?r:null;let m=_(n);return d==null&&(d=m.getPos()),m.writeSync(s,o,l,d)}a(fr,"writeSync");function hr(n,e,t,i,r){let s=_(n),o=t;return typeof t=="object"&&({offset:o,length:i,position:r}=t),isNaN(+r)&&(r=s.getPos()),s.readSync(e,o,i,r)}a(hr,"readSync");function pr(n,e,t){_(n).chownSync(e,t)}a(pr,"fchownSync");function gr(n,e){let t=typeof e=="string"?parseInt(e,8):e;_(n).chmodSync(t)}a(gr,"fchmodSync");function yr(n,e,t){_(n).utimesSync(U(e),U(t))}a(yr,"futimesSync");function br(n){return N("rmdirSync",!0,n,p)}a(br,"rmdirSync");function Sr(n,e){N("mkdirSync",!0,n,M(e,511),p)}a(Sr,"mkdirSync");function wr(n){n=O(n);let e=N("readdirSync",!0,n,p),t=[...X.keys()];for(let i of t)if(i.startsWith(n)){let r=i.slice(n.length);if(r.includes("/")||r.length==0)continue;e.push(r)}return e}a(wr,"readdirSync");function Fr(n,e){return e=O(e),N("linkSync",!1,n,e,p)}a(Fr,"linkSync");function xr(n,e,t){if(!["file","dir","junction"].includes(t))throw new c(22,"Invalid type: "+t);return e=O(e),N("symlinkSync",!1,n,e,t,p)}a(xr,"symlinkSync");function vr(n){return N("readlinkSync",!1,n,p)}a(vr,"readlinkSync");function Er(n,e,t){N("chownSync",!0,n,e,t,p)}a(Er,"chownSync");function Cr(n,e,t){N("chownSync",!1,n,e,t,p)}a(Cr,"lchownSync");function _r(n,e){let t=M(e,-1);if(t<0)throw new c(22,"Invalid mode.");N("chmodSync",!0,n,t,p)}a(_r,"chmodSync");function kr(n,e){let t=M(e,-1);if(t<1)throw new c(22,"Invalid mode.");N("chmodSync",!1,n,t,p)}a(kr,"lchmodSync");function Or(n,e,t){N("utimesSync",!0,n,U(e),U(t),p)}a(Or,"utimesSync");function Tr(n,e,t){N("utimesSync",!1,n,U(e),U(t),p)}a(Tr,"lutimesSync");function Be(n,e={}){n=O(n);let{fs:t,path:i,mountPoint:r}=$(n);try{if(!t.statSync(i,p).isSymbolicLink())return n;let o=O(r+t.readlinkSync(i,p));return Be(o)}catch(s){throw lt(s,{[i]:n})}}a(Be,"realpathSync");function Nr(n,e=384){return N("accessSync",!0,n,e,p)}a(Nr,"accessSync");var Pr=Ue,qt=Pr;var Ht=class extends L{constructor(e,t,i,r,s){super(e,t,i,r,s)}syncSync(){this.isDirty()&&(this._fs._syncSync(this),this.resetDirty())}closeSync(){this.syncSync()}};a(Ht,"MirrorFile");var Ot=class extends ot{constructor({sync:t,async:i}){super();this._queue=[];this._queueRunning=!1;this._isInitialized=!1;this._initializeCallbacks=[];this._sync=t,this._async=i,this._ready=this._initialize()}static isAvailable(){return!0}get metadata(){return H(Y({},super.metadata),{name:Ot.Name,synchronous:!0,supportsProperties:this._sync.metadata.supportsProperties&&this._async.metadata.supportsProperties})}_syncSync(t){let i=t.getStats();this._sync.writeFileSync(t.getPath(),t.getBuffer(),null,S.getFileFlag("w"),i.mode,i.getCred(0,0)),this.enqueueOp({apiMethod:"writeFile",arguments:[t.getPath(),t.getBuffer(),null,t.getFlag(),i.mode,i.getCred(0,0)]})}renameSync(t,i,r){this._sync.renameSync(t,i,r),this.enqueueOp({apiMethod:"rename",arguments:[t,i,r]})}statSync(t,i){return this._sync.statSync(t,i)}openSync(t,i,r,s){return this._sync.openSync(t,i,r,s).closeSync(),new Ht(this,t,i,this._sync.statSync(t,s),this._sync.readFileSync(t,null,S.getFileFlag("r"),s))}unlinkSync(t,i){this._sync.unlinkSync(t,i),this.enqueueOp({apiMethod:"unlink",arguments:[t,i]})}rmdirSync(t,i){this._sync.rmdirSync(t,i),this.enqueueOp({apiMethod:"rmdir",arguments:[t,i]})}mkdirSync(t,i,r){this._sync.mkdirSync(t,i,r),this.enqueueOp({apiMethod:"mkdir",arguments:[t,i,r]})}readdirSync(t,i){return this._sync.readdirSync(t,i)}existsSync(t,i){return this._sync.existsSync(t,i)}chmodSync(t,i,r){this._sync.chmodSync(t,i,r),this.enqueueOp({apiMethod:"chmod",arguments:[t,i,r]})}chownSync(t,i,r,s){this._sync.chownSync(t,i,r,s),this.enqueueOp({apiMethod:"chown",arguments:[t,i,r,s]})}utimesSync(t,i,r,s){this._sync.utimesSync(t,i,r,s),this.enqueueOp({apiMethod:"utimes",arguments:[t,i,r,s]})}_initialize(){return u(this,null,function*(){if(!this._isInitialized){let t=a((s,o)=>u(this,null,function*(){if(s!=="/"){let d=yield this._async.stat(s,E.Root);this._sync.mkdirSync(s,o,d.getCred())}let l=yield this._async.readdir(s,E.Root);for(let d of l)yield r(R(s,d))}),"copyDirectory"),i=a((s,o)=>u(this,null,function*(){let l=yield this._async.readFile(s,null,S.getFileFlag("r"),E.Root);this._sync.writeFileSync(s,l,null,S.getFileFlag("w"),o,E.Root)}),"copyFile"),r=a(s=>u(this,null,function*(){let o=yield this._async.stat(s,E.Root);o.isDirectory()?yield t(s,o.mode):yield i(s,o.mode)}),"copyItem");try{yield t("/",0),this._isInitialized=!0}catch(s){throw this._isInitialized=!1,s}}return this})}enqueueOp(t){if(this._queue.push(t),!this._queueRunning){this._queueRunning=!0;let i=a(r=>{if(r)throw new Error(`WARNING: File system has desynchronized. Received following error: ${r}
4
+ $`);if(this._queue.length>0){let s=this._queue.shift();s.arguments.push(i),this._async[s.apiMethod].apply(this._async,s.arguments)}else this._queueRunning=!1},"doNextOp");i()}}},tt=Ot;a(tt,"AsyncMirror"),tt.Name="AsyncMirror",tt.Create=at.bind(Ot),tt.Options={sync:{type:"object",description:"The synchronous file system to mirror the asynchronous file system to.",validator:t=>u(Ot,null,function*(){if(!(t!=null&&t.metadata.synchronous))throw new c(22,"'sync' option must be a file system that supports synchronous operations")})},async:{type:"object",description:"The asynchronous file system to mirror."}};var Le=class extends K{constructor({folder:t,wrapped:i}){super();this._folder=t,this._wrapped=i,this._ready=this._initialize()}static isAvailable(){return!0}get metadata(){return H(Y(Y({},super.metadata),this._wrapped.metadata),{supportsLinks:!1})}_initialize(){return u(this,null,function*(){if(!(yield this._wrapped.exists(this._folder,E.Root))&&this._wrapped.metadata.readonly)throw c.ENOENT(this._folder);return yield this._wrapped.mkdir(this._folder,511,E.Root),this})}},J=Le;a(J,"FolderAdapter"),J.Name="FolderAdapter",J.Create=at.bind(Le),J.Options={folder:{type:"string",description:"The folder to use as the root directory"},wrapped:{type:"object",description:"The file system to wrap"}};function ri(n,e){if(e!==null&&typeof e=="object"){let t=e,i=t.path;i&&(i="/"+Xe(n,i),t.message=t.message.replace(t.path,i),t.path=i)}return e}a(ri,"translateError");function Ir(n,e){return typeof e=="function"?function(t){arguments.length>0&&(arguments[0]=ri(n,t)),e.apply(null,arguments)}:e}a(Ir,"wrapCallback");function si(n,e,t){return n.slice(n.length-4)!=="Sync"?function(){return arguments.length>0&&(e&&(arguments[0]=R(this._folder,arguments[0])),t&&(arguments[1]=R(this._folder,arguments[1])),arguments[arguments.length-1]=Ir(this._folder,arguments[arguments.length-1])),this._wrapped[n].apply(this._wrapped,arguments)}:function(){try{return e&&(arguments[0]=R(this._folder,arguments[0])),t&&(arguments[1]=R(this._folder,arguments[1])),this._wrapped[n].apply(this._wrapped,arguments)}catch(i){throw ri(this._folder,i)}}}a(si,"wrapFunction");["diskSpace","stat","statSync","open","openSync","unlink","unlinkSync","rmdir","rmdirSync","mkdir","mkdirSync","readdir","readdirSync","exists","existsSync","realpath","realpathSync","truncate","truncateSync","readFile","readFileSync","writeFile","writeFileSync","appendFile","appendFileSync","chmod","chmodSync","chown","chownSync","utimes","utimesSync","readlink","readlinkSync"].forEach(n=>{J.prototype[n]=si(n,!0,!1)});["rename","renameSync","link","linkSync","symlink","symlinkSync"].forEach(n=>{J.prototype[n]=si(n,!0,!0)});var wt=class{constructor(){this._locks=new Map}lock(e){return new Promise(t=>{this._locks.has(e)?this._locks.get(e).push(t):this._locks.set(e,[])})}unlock(e){if(!this._locks.has(e))throw new Error("unlock of a non-locked mutex");let t=this._locks.get(e).shift();if(t){setTimeout(t,0);return}this._locks.delete(e)}tryLock(e){return this._locks.has(e)?!1:(this._locks.set(e,[]),!0)}isLocked(e){return this._locks.has(e)}};a(wt,"Mutex");var Ft=class{constructor(e){this._ready=Promise.resolve(this);this._fs=e,this._mu=new wt}whenReady(){return this._ready}get metadata(){return H(Y({},this._fs.metadata),{name:"LockedFS<"+this._fs.metadata.name+">"})}get fs(){return this._fs}rename(e,t,i){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.rename(e,t,i),this._mu.unlock(e)})}renameSync(e,t,i){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.renameSync(e,t,i)}stat(e,t){return u(this,null,function*(){yield this._mu.lock(e);let i=yield this._fs.stat(e,t);return this._mu.unlock(e),i})}statSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.statSync(e,t)}access(e,t,i){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.access(e,t,i),this._mu.unlock(e)})}accessSync(e,t,i){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.accessSync(e,t,i)}open(e,t,i,r){return u(this,null,function*(){yield this._mu.lock(e);let s=yield this._fs.open(e,t,i,r);return this._mu.unlock(e),s})}openSync(e,t,i,r){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.openSync(e,t,i,r)}unlink(e,t){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.unlink(e,t),this._mu.unlock(e)})}unlinkSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.unlinkSync(e,t)}rmdir(e,t){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.rmdir(e,t),this._mu.unlock(e)})}rmdirSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.rmdirSync(e,t)}mkdir(e,t,i){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.mkdir(e,t,i),this._mu.unlock(e)})}mkdirSync(e,t,i){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.mkdirSync(e,t,i)}readdir(e,t){return u(this,null,function*(){yield this._mu.lock(e);let i=yield this._fs.readdir(e,t);return this._mu.unlock(e),i})}readdirSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.readdirSync(e,t)}exists(e,t){return u(this,null,function*(){yield this._mu.lock(e);let i=yield this._fs.exists(e,t);return this._mu.unlock(e),i})}existsSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.existsSync(e,t)}realpath(e,t){return u(this,null,function*(){yield this._mu.lock(e);let i=yield this._fs.realpath(e,t);return this._mu.unlock(e),i})}realpathSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.realpathSync(e,t)}truncate(e,t,i){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.truncate(e,t,i),this._mu.unlock(e)})}truncateSync(e,t,i){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.truncateSync(e,t,i)}readFile(e,t,i,r){return u(this,null,function*(){yield this._mu.lock(e);let s=yield this._fs.readFile(e,t,i,r);return this._mu.unlock(e),s})}readFileSync(e,t,i,r){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.readFileSync(e,t,i,r)}writeFile(e,t,i,r,s,o){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.writeFile(e,t,i,r,s,o),this._mu.unlock(e)})}writeFileSync(e,t,i,r,s,o){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.writeFileSync(e,t,i,r,s,o)}appendFile(e,t,i,r,s,o){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.appendFile(e,t,i,r,s,o),this._mu.unlock(e)})}appendFileSync(e,t,i,r,s,o){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.appendFileSync(e,t,i,r,s,o)}chmod(e,t,i){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.chmod(e,t,i),this._mu.unlock(e)})}chmodSync(e,t,i){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.chmodSync(e,t,i)}chown(e,t,i,r){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.chown(e,t,i,r),this._mu.unlock(e)})}chownSync(e,t,i,r){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.chownSync(e,t,i,r)}utimes(e,t,i,r){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.utimes(e,t,i,r),this._mu.unlock(e)})}utimesSync(e,t,i,r){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.utimesSync(e,t,i,r)}link(e,t,i){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.link(e,t,i),this._mu.unlock(e)})}linkSync(e,t,i){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.linkSync(e,t,i)}symlink(e,t,i,r){return u(this,null,function*(){yield this._mu.lock(e),yield this._fs.symlink(e,t,i,r),this._mu.unlock(e)})}symlinkSync(e,t,i,r){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.symlinkSync(e,t,i,r)}readlink(e,t){return u(this,null,function*(){yield this._mu.lock(e);let i=yield this._fs.readlink(e,t);return this._mu.unlock(e),i})}readlinkSync(e,t){if(this._mu.isLocked(e))throw new Error("invalid sync call");return this._fs.readlinkSync(e,t)}};a(Ft,"LockedFS");var et="/.deletedFiles.log";function oi(n){return 146|n}a(oi,"makeModeWritable");function z(n){return S.getFileFlag(n)}a(z,"getFlag");var Tt=class extends L{constructor(e,t,i,r,s){super(e,t,i,r,s)}sync(){return u(this,null,function*(){this.isDirty()&&(yield this._fs._syncAsync(this),this.resetDirty())})}syncSync(){this.isDirty()&&(this._fs._syncSync(this),this.resetDirty())}close(){return u(this,null,function*(){yield this.sync()})}closeSync(){this.syncSync()}};a(Tt,"OverlayFile");var Nt=class extends K{constructor({writable:t,readable:i}){super();this._isInitialized=!1;this._deletedFiles={};this._deleteLog="";this._deleteLogUpdatePending=!1;this._deleteLogUpdateNeeded=!1;this._deleteLogError=null;if(this._writable=t,this._readable=i,this._writable.metadata.readonly)throw new c(22,"Writable file system must be writable.")}static isAvailable(){return!0}get metadata(){return H(Y({},super.metadata),{name:Z.Name,synchronous:this._readable.metadata.synchronous&&this._writable.metadata.synchronous,supportsProperties:this._readable.metadata.supportsProperties&&this._writable.metadata.supportsProperties})}getOverlayedFileSystems(){return{readable:this._readable,writable:this._writable}}_syncAsync(t){return u(this,null,function*(){let i=t.getStats();return yield this.createParentDirectoriesAsync(t.getPath(),i.getCred(0,0)),this._writable.writeFile(t.getPath(),t.getBuffer(),null,z("w"),i.mode,i.getCred(0,0))})}_syncSync(t){let i=t.getStats();this.createParentDirectories(t.getPath(),i.getCred(0,0)),this._writable.writeFileSync(t.getPath(),t.getBuffer(),null,z("w"),i.mode,i.getCred(0,0))}_initialize(){return u(this,null,function*(){if(!this._isInitialized){try{let t=yield this._writable.readFile(et,"utf8",z("r"),E.Root);this._deleteLog=t}catch(t){if(t.errno!==2)throw t}this._isInitialized=!0,this._reparseDeletionLog()}})}getDeletionLog(){return this._deleteLog}restoreDeletionLog(t,i){this._deleteLog=t,this._reparseDeletionLog(),this.updateLog("",i)}rename(t,i,r){return u(this,null,function*(){if(this.checkInitialized(),this.checkPath(t),this.checkPath(i),t===et||i===et)throw c.EPERM("Cannot rename deletion log.");let s=yield this.stat(t,r);if(s.isDirectory()){if(t===i)return;let o=511;if(yield this.exists(i,r)){let l=yield this.stat(i,r);if(o=l.mode,l.isDirectory()){if((yield this.readdir(i,r)).length>0)throw c.ENOTEMPTY(i)}else throw c.ENOTDIR(i)}if((yield this._writable.exists(t,r))?yield this._writable.rename(t,i,r):(yield this._writable.exists(i,r))||(yield this._writable.mkdir(i,o,r)),yield this._readable.exists(t,r))for(let l of yield this._readable.readdir(t,r))yield this.rename(I(t,l),I(i,l),r)}else{if((yield this.exists(i,r))&&(yield this.stat(i,r)).isDirectory())throw c.EISDIR(i);yield this.writeFile(i,yield this.readFile(t,null,z("r"),r),null,z("w"),s.mode,r)}t!==i&&(yield this.exists(t,r))&&(yield this.unlink(t,r))})}renameSync(t,i,r){if(this.checkInitialized(),this.checkPath(t),this.checkPath(i),t===et||i===et)throw c.EPERM("Cannot rename deletion log.");let s=this.statSync(t,r);if(s.isDirectory()){if(t===i)return;let o=511;if(this.existsSync(i,r)){let l=this.statSync(i,r);if(o=l.mode,l.isDirectory()){if(this.readdirSync(i,r).length>0)throw c.ENOTEMPTY(i)}else throw c.ENOTDIR(i)}this._writable.existsSync(t,r)?this._writable.renameSync(t,i,r):this._writable.existsSync(i,r)||this._writable.mkdirSync(i,o,r),this._readable.existsSync(t,r)&&this._readable.readdirSync(t,r).forEach(l=>{this.renameSync(I(t,l),I(i,l),r)})}else{if(this.existsSync(i,r)&&this.statSync(i,r).isDirectory())throw c.EISDIR(i);this.writeFileSync(i,this.readFileSync(t,null,z("r"),r),null,z("w"),s.mode,r)}t!==i&&this.existsSync(t,r)&&this.unlinkSync(t,r)}stat(t,i){return u(this,null,function*(){this.checkInitialized();try{return this._writable.stat(t,i)}catch(r){if(this._deletedFiles[t])throw c.ENOENT(t);let s=k.clone(yield this._readable.stat(t,i));return s.mode=oi(s.mode),s}})}statSync(t,i){this.checkInitialized();try{return this._writable.statSync(t,i)}catch(r){if(this._deletedFiles[t])throw c.ENOENT(t);let s=k.clone(this._readable.statSync(t,i));return s.mode=oi(s.mode),s}}open(t,i,r,s){return u(this,null,function*(){if(this.checkInitialized(),this.checkPath(t),t===et)throw c.EPERM("Cannot open deletion log.");if(yield this.exists(t,s))switch(i.pathExistsAction()){case 2:return yield this.createParentDirectoriesAsync(t,s),this._writable.open(t,i,r,s);case 0:if(yield this._writable.exists(t,s))return this._writable.open(t,i,r,s);{let o=yield this._readable.readFile(t,null,z("r"),s),l=k.clone(yield this._readable.stat(t,s));return l.mode=r,new Tt(this,t,i,l,o)}default:throw c.EEXIST(t)}else switch(i.pathNotExistsAction()){case 3:return yield this.createParentDirectoriesAsync(t,s),this._writable.open(t,i,r,s);default:throw c.ENOENT(t)}})}openSync(t,i,r,s){if(this.checkInitialized(),this.checkPath(t),t===et)throw c.EPERM("Cannot open deletion log.");if(this.existsSync(t,s))switch(i.pathExistsAction()){case 2:return this.createParentDirectories(t,s),this._writable.openSync(t,i,r,s);case 0:if(this._writable.existsSync(t,s))return this._writable.openSync(t,i,r,s);{let o=this._readable.readFileSync(t,null,z("r"),s),l=k.clone(this._readable.statSync(t,s));return l.mode=r,new Tt(this,t,i,l,o)}default:throw c.EEXIST(t)}else switch(i.pathNotExistsAction()){case 3:return this.createParentDirectories(t,s),this._writable.openSync(t,i,r,s);default:throw c.ENOENT(t)}}unlink(t,i){return u(this,null,function*(){if(this.checkInitialized(),this.checkPath(t),yield this.exists(t,i))(yield this._writable.exists(t,i))&&(yield this._writable.unlink(t,i)),(yield this.exists(t,i))&&this.deletePath(t,i);else throw c.ENOENT(t)})}unlinkSync(t,i){if(this.checkInitialized(),this.checkPath(t),this.existsSync(t,i))this._writable.existsSync(t,i)&&this._writable.unlinkSync(t,i),this.existsSync(t,i)&&this.deletePath(t,i);else throw c.ENOENT(t)}rmdir(t,i){return u(this,null,function*(){if(this.checkInitialized(),yield this.exists(t,i)){if((yield this._writable.exists(t,i))&&(yield this._writable.rmdir(t,i)),yield this.exists(t,i)){if((yield this.readdir(t,i)).length>0)throw c.ENOTEMPTY(t);this.deletePath(t,i)}}else throw c.ENOENT(t)})}rmdirSync(t,i){if(this.checkInitialized(),this.existsSync(t,i)){if(this._writable.existsSync(t,i)&&this._writable.rmdirSync(t,i),this.existsSync(t,i)){if(this.readdirSync(t,i).length>0)throw c.ENOTEMPTY(t);this.deletePath(t,i)}}else throw c.ENOENT(t)}mkdir(t,i,r){return u(this,null,function*(){if(this.checkInitialized(),yield this.exists(t,r))throw c.EEXIST(t);yield this.createParentDirectoriesAsync(t,r),yield this._writable.mkdir(t,i,r)})}mkdirSync(t,i,r){if(this.checkInitialized(),this.existsSync(t,r))throw c.EEXIST(t);this.createParentDirectories(t,r),this._writable.mkdirSync(t,i,r)}readdir(t,i){return u(this,null,function*(){if(this.checkInitialized(),!(yield this.stat(t,i)).isDirectory())throw c.ENOTDIR(t);let s=[];try{s=s.concat(yield this._writable.readdir(t,i))}catch(l){}try{s=s.concat((yield this._readable.readdir(t,i)).filter(l=>!this._deletedFiles[`${t}/${l}`]))}catch(l){}let o={};return s.filter(l=>{let d=!o[l];return o[l]=!0,d})})}readdirSync(t,i){if(this.checkInitialized(),!this.statSync(t,i).isDirectory())throw c.ENOTDIR(t);let s=[];try{s=s.concat(this._writable.readdirSync(t,i))}catch(l){}try{s=s.concat(this._readable.readdirSync(t,i).filter(l=>!this._deletedFiles[`${t}/${l}`]))}catch(l){}let o={};return s.filter(l=>{let d=!o[l];return o[l]=!0,d})}exists(t,i){return u(this,null,function*(){return this.checkInitialized(),(yield this._writable.exists(t,i))||(yield this._readable.exists(t,i))&&this._deletedFiles[t]!==!0})}existsSync(t,i){return this.checkInitialized(),this._writable.existsSync(t,i)||this._readable.existsSync(t,i)&&this._deletedFiles[t]!==!0}chmod(t,i,r){return u(this,null,function*(){this.checkInitialized(),yield this.operateOnWritableAsync(t,r),yield this._writable.chmod(t,i,r)})}chmodSync(t,i,r){this.checkInitialized(),this.operateOnWritable(t,r),this._writable.chmodSync(t,i,r)}chown(t,i,r,s){return u(this,null,function*(){this.checkInitialized(),yield this.operateOnWritableAsync(t,s),yield this._writable.chown(t,i,r,s)})}chownSync(t,i,r,s){this.checkInitialized(),this.operateOnWritable(t,s),this._writable.chownSync(t,i,r,s)}utimes(t,i,r,s){return u(this,null,function*(){this.checkInitialized(),yield this.operateOnWritableAsync(t,s),yield this._writable.utimes(t,i,r,s)})}utimesSync(t,i,r,s){this.checkInitialized(),this.operateOnWritable(t,s),this._writable.utimesSync(t,i,r,s)}deletePath(t,i){this._deletedFiles[t]=!0,this.updateLog(`d${t}
5
+ `,i)}updateLog(t,i){this._deleteLog+=t,this._deleteLogUpdatePending?this._deleteLogUpdateNeeded=!0:(this._deleteLogUpdatePending=!0,this._writable.writeFile(et,this._deleteLog,"utf8",S.getFileFlag("w"),420,i).then(()=>{this._deleteLogUpdateNeeded&&(this._deleteLogUpdateNeeded=!1,this.updateLog("",i))}).catch(r=>{this._deleteLogError=r}).finally(()=>{this._deleteLogUpdatePending=!1}))}_reparseDeletionLog(){this._deletedFiles={},this._deleteLog.split(`
6
+ `).forEach(t=>{this._deletedFiles[t.slice(1)]=t.slice(0,1)==="d"})}checkInitialized(){if(this._isInitialized){if(this._deleteLogError!==null){let t=this._deleteLogError;throw this._deleteLogError=null,t}}else throw new c(1,"OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.")}checkPath(t){if(t===et)throw c.EPERM(t)}createParentDirectories(t,i){let r=F(t),s=[];for(;!this._writable.existsSync(r,i);)s.push(r),r=F(r);s=s.reverse();for(let o of s)this._writable.mkdirSync(o,this.statSync(o,i).mode,i)}createParentDirectoriesAsync(t,i){return u(this,null,function*(){let r=F(t),s=[];for(;!(yield this._writable.exists(r,i));)s.push(r),r=F(r);s=s.reverse();for(let o of s){let l=yield this.stat(o,i);yield this._writable.mkdir(o,l.mode,i)}})}operateOnWritable(t,i){if(!this.existsSync(t,i))throw c.ENOENT(t);this._writable.existsSync(t,i)||this.copyToWritable(t,i)}operateOnWritableAsync(t,i){return u(this,null,function*(){if(!(yield this.exists(t,i)))throw c.ENOENT(t);if(!(yield this._writable.exists(t,i)))return this.copyToWritableAsync(t,i)})}copyToWritable(t,i){let r=this.statSync(t,i);r.isDirectory()?this._writable.mkdirSync(t,r.mode,i):this.writeFileSync(t,this._readable.readFileSync(t,null,z("r"),i),null,z("w"),r.mode,i)}copyToWritableAsync(t,i){return u(this,null,function*(){let r=yield this.stat(t,i);r.isDirectory()?yield this._writable.mkdir(t,r.mode,i):yield this.writeFile(t,yield this._readable.readFile(t,null,z("r"),i),null,z("w"),r.mode,i)})}};a(Nt,"UnlockedOverlayFS");var Gt=class extends Ft{static isAvailable(){return Nt.isAvailable()}constructor(e){super(new Nt(e)),this._ready=this._initialize()}getOverlayedFileSystems(){return super.fs.getOverlayedFileSystems()}getDeletionLog(){return super.fs.getDeletionLog()}resDeletionLog(){return super.fs.getDeletionLog()}unwrap(){return super.fs}_initialize(){return u(this,null,function*(){return yield $e(Gt.prototype,this,"fs")._initialize(),this})}},Z=Gt;a(Z,"OverlayFS"),Z.Name="OverlayFS",Z.Create=at.bind(Gt),Z.Options={writable:{type:"object",description:"The file system to write modified files to."},readable:{type:"object",description:"The file system that initially populates this file system."}};var Zt={};function ai(...n){for(let e of n)Zt[e.Name]=e}a(ai,"registerBackend");ai(tt,J,j,Z);var Pt=class{constructor(e,t){this.key=e;this.value=t;this.prev=null;this.next=null}};a(Pt,"LRUNode");var Qt=class{constructor(e){this.limit=e;this.size=0;this.map={};this.head=null;this.tail=null}set(e,t){let i=new Pt(e,t);this.map[e]?(this.map[e].value=i.value,this.remove(i.key)):this.size>=this.limit&&(delete this.map[this.tail.key],this.size--,this.tail=this.tail.prev,this.tail.next=null),this.setHead(i)}get(e){if(this.map[e]){let t=this.map[e].value,i=new Pt(e,t);return this.remove(e),this.setHead(i),t}else return null}remove(e){let t=this.map[e];t&&(t.prev!==null?t.prev.next=t.next:this.head=t.next,t.next!==null?t.next.prev=t.prev:this.tail=t.prev,delete this.map[e],this.size--)}removeAll(){this.size=0,this.map={},this.head=null,this.tail=null}setHead(e){e.next=this.head,e.prev=null,this.head!==null&&(this.head.prev=e),this.head=e,this.tail===null&&(this.tail=e),this.size++,this.map[e.key]=e}};a(Qt,"LRUCache");var xt=class extends L{constructor(e,t,i,r,s){super(e,t,i,r,s)}sync(){return u(this,null,function*(){this.isDirty()&&(yield this._fs._sync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())})}close(){return u(this,null,function*(){this.sync()})}};a(xt,"AsyncKeyValueFile");var te=class extends K{constructor(t){super();this._cache=null;t>0&&(this._cache=new Qt(t))}static isAvailable(){return!0}init(t){return u(this,null,function*(){this.store=t,yield this.makeRootDirectory()})}getName(){return this.store.name()}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!0}supportsSynch(){return!1}empty(){return u(this,null,function*(){this._cache&&this._cache.removeAll(),yield this.store.clear(),yield this.makeRootDirectory()})}access(t,i,r){return u(this,null,function*(){let s=this.store.beginTransaction("readonly"),o=yield this.findINode(s,t);if(!o)throw c.ENOENT(t);if(!o.toStats().hasAccess(i,r))throw c.EACCES(t)})}rename(t,i,r){return u(this,null,function*(){let s=this._cache;this._cache&&(this._cache=null,s.removeAll());try{let o=this.store.beginTransaction("readwrite"),l=F(t),d=A(t),m=F(i),f=A(i),h=yield this.findINode(o,l),y=yield this.getDirListing(o,l,h);if(!h.toStats().hasAccess(2,r))throw c.EACCES(t);if(!y[d])throw c.ENOENT(t);let v=y[d];if(delete y[d],(m+"/").indexOf(t+"/")===0)throw new c(16,l);let x,g;if(m===l?(x=h,g=y):(x=yield this.findINode(o,m),g=yield this.getDirListing(o,m,x)),g[f]){let q=yield this.getINode(o,i,g[f]);if(q.isFile())try{yield o.del(q.id),yield o.del(g[f])}catch(ht){throw yield o.abort(),ht}else throw c.EPERM(i)}g[f]=v;try{yield o.put(h.id,w(JSON.stringify(y)),!0),yield o.put(x.id,w(JSON.stringify(g)),!0)}catch(q){throw yield o.abort(),q}yield o.commit()}finally{s&&(this._cache=s)}})}stat(t,i){return u(this,null,function*(){let r=this.store.beginTransaction("readonly"),o=(yield this.findINode(r,t)).toStats();if(!o.hasAccess(4,i))throw c.EACCES(t);return o})}createFile(t,i,r,s){return u(this,null,function*(){let o=this.store.beginTransaction("readwrite"),l=new Uint8Array(0),d=yield this.commitNewFile(o,t,C.FILE,r,s,l);return new xt(this,t,i,d.toStats(),l)})}openFile(t,i,r){return u(this,null,function*(){let s=this.store.beginTransaction("readonly"),o=yield this.findINode(s,t),l=yield s.get(o.id);if(!o.toStats().hasAccess(i.getMode(),r))throw c.EACCES(t);if(l===void 0)throw c.ENOENT(t);return new xt(this,t,i,o.toStats(),l)})}unlink(t,i){return u(this,null,function*(){return this.removeEntry(t,!1,i)})}rmdir(t,i){return u(this,null,function*(){if((yield this.readdir(t,i)).length>0)throw c.ENOTEMPTY(t);yield this.removeEntry(t,!0,i)})}mkdir(t,i,r){return u(this,null,function*(){let s=this.store.beginTransaction("readwrite"),o=w("{}");yield this.commitNewFile(s,t,C.DIRECTORY,i,r,o)})}readdir(t,i){return u(this,null,function*(){let r=this.store.beginTransaction("readonly"),s=yield this.findINode(r,t);if(!s.toStats().hasAccess(4,i))throw c.EACCES(t);return Object.keys(yield this.getDirListing(r,t,s))})}chmod(t,i,r){return u(this,null,function*(){yield(yield this.openFile(t,S.getFileFlag("r+"),r)).chmod(i)})}chown(t,i,r,s){return u(this,null,function*(){yield(yield this.openFile(t,S.getFileFlag("r+"),s)).chown(i,r)})}_sync(t,i,r){return u(this,null,function*(){let s=this.store.beginTransaction("readwrite"),o=yield this._findINode(s,F(t),A(t)),l=yield this.getINode(s,t,o),d=l.update(r);try{yield s.put(l.id,i,!0),d&&(yield s.put(o,l.serialize(),!0))}catch(m){throw yield s.abort(),m}yield s.commit()})}makeRootDirectory(){return u(this,null,function*(){let t=this.store.beginTransaction("readwrite");if((yield t.get(V))===void 0){let i=new Date().getTime(),r=new B(dt(),4096,511|C.DIRECTORY,i,i,i,0,0);yield t.put(r.id,w("{}"),!1),yield t.put(V,r.serialize(),!1),yield t.commit()}})}_findINode(o,l,d){return u(this,arguments,function*(t,i,r,s=new Set){let m=R(i,r);if(s.has(m))throw new c(5,"Infinite loop detected while finding inode",m);if(s.add(m),this._cache){let f=this._cache.get(m);if(f)return f}if(i==="/"){if(r==="")return this._cache&&this._cache.set(m,V),V;{let f=yield this.getINode(t,i,V),h=yield this.getDirListing(t,i,f);if(h[r]){let y=h[r];return this._cache&&this._cache.set(m,y),y}else throw c.ENOENT(I(i,r))}}else{let f=yield this.findINode(t,i,s),h=yield this.getDirListing(t,i,f);if(h[r]){let y=h[r];return this._cache&&this._cache.set(m,y),y}else throw c.ENOENT(I(i,r))}})}findINode(s,o){return u(this,arguments,function*(t,i,r=new Set){let l=yield this._findINode(t,F(i),A(i),r);return this.getINode(t,i,l)})}getINode(t,i,r){return u(this,null,function*(){let s=yield t.get(r);if(!s)throw c.ENOENT(i);return B.Deserialize(s)})}getDirListing(t,i,r){return u(this,null,function*(){if(!r.isDirectory())throw c.ENOTDIR(i);let s=yield t.get(r.id);try{return JSON.parse(s.toString())}catch(o){throw c.ENOENT(i)}})}addNewNode(t,i){return u(this,null,function*(){let r=0,s=a(()=>u(this,null,function*(){if(++r===5)throw new c(5,"Unable to commit data to key-value store.");{let o=dt();return(yield t.put(o,i,!1))?o:s()}}),"reroll");return s()})}commitNewFile(t,i,r,s,o,l){return u(this,null,function*(){let d=F(i),m=A(i),f=yield this.findINode(t,d),h=yield this.getDirListing(t,d,f),y=new Date().getTime();if(!f.toStats().hasAccess(2,o))throw c.EACCES(i);if(i==="/")throw c.EEXIST(i);if(h[m])throw yield t.abort(),c.EEXIST(i);try{let v=yield this.addNewNode(t,l),x=new B(v,l.length,s|r,y,y,y,o.uid,o.gid),g=yield this.addNewNode(t,x.serialize());return h[m]=g,yield t.put(f.id,w(JSON.stringify(h)),!0),yield t.commit(),x}catch(v){throw t.abort(),v}})}removeEntry(t,i,r){return u(this,null,function*(){this._cache&&this._cache.remove(t);let s=this.store.beginTransaction("readwrite"),o=F(t),l=yield this.findINode(s,o),d=yield this.getDirListing(s,o,l),m=A(t);if(!d[m])throw c.ENOENT(t);let f=d[m],h=yield this.getINode(s,t,f);if(!h.toStats().hasAccess(2,r))throw c.EACCES(t);if(delete d[m],!i&&h.isDirectory())throw c.EISDIR(t);if(i&&!h.isDirectory())throw c.ENOTDIR(t);try{yield s.del(h.id),yield s.del(f),yield s.put(l.id,w(JSON.stringify(d)),!0)}catch(y){throw yield s.abort(),y}yield s.commit()})}};a(te,"AsyncKeyValueFileSystem");var vt=class{static fromListing(e){let t=new vt,i=new it;t._index["/"]=i;let r=[["",e,i]];for(;r.length>0;){let s,o=r.pop(),l=o[0],d=o[1],m=o[2];for(let f in d)if(Object.prototype.hasOwnProperty.call(d,f)){let h=d[f],y=`${l}/${f}`;h?(t._index[y]=s=new it,r.push([y,h,s])):s=new It(new k(C.FILE,-1,365)),m&&(m._ls[f]=s)}}return t}constructor(){this._index={},this.addPath("/",new it)}fileIterator(e){for(let t in this._index)if(Object.prototype.hasOwnProperty.call(this._index,t)){let i=this._index[t],r=i.getListing();for(let s of r){let o=i.getItem(s);ci(o)&&e(o.getData())}}}addPath(e,t){if(!t)throw new Error("Inode must be specified");if(e[0]!=="/")throw new Error("Path must be absolute, got: "+e);if(Object.prototype.hasOwnProperty.call(this._index,e))return this._index[e]===t;let i=this._split_path(e),r=i[0],s=i[1],o=this._index[r];return o===void 0&&e!=="/"&&(o=new it,!this.addPath(r,o))||e!=="/"&&!o.addItem(s,t)?!1:(Me(t)&&(this._index[e]=t),!0)}addPathFast(e,t){let i=e.lastIndexOf("/"),r=i===0?"/":e.substring(0,i),s=e.substring(i+1),o=this._index[r];return o===void 0&&(o=new it,this.addPathFast(r,o)),o.addItem(s,t)?(t.isDir()&&(this._index[e]=t),!0):!1}removePath(e){let t=this._split_path(e),i=t[0],r=t[1],s=this._index[i];if(s===void 0)return null;let o=s.remItem(r);if(o===null)return null;if(Me(o)){let l=o.getListing();for(let d of l)this.removePath(e+"/"+d);e!=="/"&&delete this._index[e]}return o}ls(e){let t=this._index[e];return t===void 0?null:t.getListing()}getInode(e){let t=this._split_path(e),i=t[0],r=t[1],s=this._index[i];return s===void 0?null:i===e?s:s.getItem(r)}_split_path(e){let t=F(e),i=e.slice(t.length+(t==="/"?0:1));return[t,i]}};a(vt,"FileIndex");var It=class{constructor(e){this.data=e}isFile(){return!0}isDir(){return!1}getData(){return this.data}setData(e){this.data=e}toStats(){return new k(C.FILE,4096,438)}};a(It,"IndexFileInode");var it=class{constructor(e=null){this.data=e;this._ls={}}isFile(){return!1}isDir(){return!0}getData(){return this.data}getStats(){return new k(C.DIRECTORY,4096,365)}toStats(){return this.getStats()}getListing(){return Object.keys(this._ls)}getItem(e){let t=this._ls[e];return t||null}addItem(e,t){return e in this._ls?!1:(this._ls[e]=t,!0)}remItem(e){let t=this._ls[e];return t===void 0?null:(delete this._ls[e],t)}};a(it,"IndexDirInode");function ci(n){return!!n&&n.isFile()}a(ci,"isIndexFileInode");function Me(n){return!!n&&n.isDir()}a(Me,"isIndexDirInode");function ui(n,e=0,t=0){return Ge(new E(e,t,e,t,e,t)),qt.initialize(n)}a(ui,"initialize");function li(n){return u(this,null,function*(){("fs"in n||n instanceof st)&&(n={"/":n});for(let[e,t]of Object.entries(n))typeof t!="number"&&(e=e.toString(),!(t instanceof st)&&(typeof t=="string"&&(t={fs:t}),n[e]=yield di(t)));return ui(n)})}a(li,"_configure");function Ar(n,e){if(typeof e!="function")return li(n);li(n).then(()=>e()).catch(t=>e(t))}a(Ar,"configure");function ze(t){return u(this,arguments,function*({fs:n,options:e={}}){if(!n)throw new c(1,'Missing "fs" property on configuration object.');if(typeof e!="object"||e===null)throw new c(22,'Invalid "options" property on configuration object.');let i=Object.keys(e).filter(s=>s!="fs");for(let s of i){let o=e[s];if(o===null||typeof o!="object"||!("fs"in o))continue;let l=yield ze(o);e[s]=l}let r=Zt[n];if(r)return r.Create(e);throw new c(1,`File system ${n} is not available in ZenFS.`)})}a(ze,"_getFileSystem");function di(n,e){if(typeof e!="function")return ze(n);ze(n).then(t=>e(null,t)).catch(t=>e(t))}a(di,"getFileSystem");var Dr=qt;return wi(Rr);})();
20
7
  //# sourceMappingURL=browser.min.js.map