@zenfs/dom 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backends/FileSystemAccess.d.ts +7 -8
- package/dist/backends/FileSystemAccess.js +155 -210
- package/dist/backends/HTTPRequest.d.ts +7 -10
- package/dist/backends/HTTPRequest.js +83 -104
- package/dist/backends/IndexedDB.d.ts +2 -3
- package/dist/backends/IndexedDB.js +2 -3
- package/dist/backends/Storage.d.ts +2 -3
- package/dist/backends/Storage.js +2 -2
- package/dist/backends/Worker.d.ts +4 -5
- package/dist/backends/Worker.js +26 -32
- package/dist/browser.min.js +3 -8
- package/dist/browser.min.js.map +4 -4
- package/dist/fetch.d.ts +2 -3
- package/dist/fetch.js +20 -35
- package/package.json +3 -14
package/dist/browser.min.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
var ZenFS_DOM=(()=>{var Lt=Object.defineProperty,li=Object.defineProperties,hi=Object.getOwnPropertyDescriptor,di=Object.getOwnPropertyDescriptors,fi=Object.getOwnPropertyNames,Ae=Object.getOwnPropertySymbols;var Re=Object.prototype.hasOwnProperty,pi=Object.prototype.propertyIsEnumerable;var C=Math.pow,ve=(l,t,e)=>t in l?Lt(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,pt=(l,t)=>{for(var e in t||(t={}))Re.call(t,e)&&ve(l,e,t[e]);if(Ae)for(var e of Ae(t))pi.call(t,e)&&ve(l,e,t[e]);return l},At=(l,t)=>li(l,di(t)),h=(l,t)=>Lt(l,"name",{value:t,configurable:!0});var mi=(l,t)=>{for(var e in t)Lt(l,e,{get:t[e],enumerable:!0})},yi=(l,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of fi(t))!Re.call(l,o)&&o!==e&&Lt(l,o,{get:()=>t[o],enumerable:!(n=hi(t,o))||n.enumerable});return l};var wi=l=>yi(Lt({},"__esModule",{value:!0}),l);var v=(l,t,e)=>new Promise((n,o)=>{var a=w=>{try{f(e.next(w))}catch(S){o(S)}},s=w=>{try{f(e.throw(w))}catch(S){o(S)}},f=w=>w.done?n(w.value):Promise.resolve(w.value).then(a,s);f((e=e.apply(l,t)).next())}),Ce=(l,t,e)=>(t=l[Symbol.asyncIterator],e=(n,o)=>(o=l[n])&&(t[n]=a=>new Promise((s,f,w)=>(a=o.call(l,a),w=a.done,Promise.resolve(a.value).then(S=>s({value:S,done:w}),f)))),t?t.call(l):(l=l[Symbol.iterator](),t={},e("next"),e("return"),t));var Ti={};mi(Ti,{FileSystemAccessFile:()=>zt,FileSystemAccessFileSystem:()=>Nt,HTTPRequest:()=>bt,IndexedDBFileSystem:()=>dt,IndexedDBROTransaction:()=>Dt,IndexedDBRWTransaction:()=>Vt,IndexedDBStore:()=>Ot,StorageFileSystem:()=>ft,StorageStore:()=>Kt,WorkerFS:()=>Tt});var kt={},Pe=!1;function gi(){if(Pe)return kt;Pe=!0,kt.byteLength=f,kt.toByteArray=S,kt.fromByteArray=b;for(var l=[],t=[],e=typeof Uint8Array!="undefined"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,a=n.length;o<a;++o)l[o]=n[o],t[n.charCodeAt(o)]=o;t["-".charCodeAt(0)]=62,t["_".charCodeAt(0)]=63;function s(x){var N=x.length;if(N%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var B=x.indexOf("=");B===-1&&(B=N);var P=B===N?0:4-B%4;return[B,P]}h(s,"getLens");function f(x){var N=s(x),B=N[0],P=N[1];return(B+P)*3/4-P}h(f,"byteLength");function w(x,N,B){return(N+B)*3/4-B}h(w,"_byteLength");function S(x){var N,B=s(x),P=B[0],q=B[1],D=new e(w(x,P,q)),X=0,et=q>0?P-4:P,J;for(J=0;J<et;J+=4)N=t[x.charCodeAt(J)]<<18|t[x.charCodeAt(J+1)]<<12|t[x.charCodeAt(J+2)]<<6|t[x.charCodeAt(J+3)],D[X++]=N>>16&255,D[X++]=N>>8&255,D[X++]=N&255;return q===2&&(N=t[x.charCodeAt(J)]<<2|t[x.charCodeAt(J+1)]>>4,D[X++]=N&255),q===1&&(N=t[x.charCodeAt(J)]<<10|t[x.charCodeAt(J+1)]<<4|t[x.charCodeAt(J+2)]>>2,D[X++]=N>>8&255,D[X++]=N&255),D}h(S,"toByteArray");function y(x){return l[x>>18&63]+l[x>>12&63]+l[x>>6&63]+l[x&63]}h(y,"tripletToBase64");function I(x,N,B){for(var P,q=[],D=N;D<B;D+=3)P=(x[D]<<16&16711680)+(x[D+1]<<8&65280)+(x[D+2]&255),q.push(y(P));return q.join("")}h(I,"encodeChunk");function b(x){for(var N,B=x.length,P=B%3,q=[],D=16383,X=0,et=B-P;X<et;X+=D)q.push(I(x,X,X+D>et?et:X+D));return P===1?(N=x[B-1],q.push(l[N>>2]+l[N<<4&63]+"==")):P===2&&(N=(x[B-2]<<8)+x[B-1],q.push(l[N>>10]+l[N>>4&63]+l[N<<2&63]+"=")),q.join("")}return h(b,"fromByteArray"),kt}h(gi,"dew$2");var Qt={},De=!1;function Ei(){if(De)return Qt;De=!0;return Qt.read=function(l,t,e,n,o){var a,s,f=o*8-n-1,w=(1<<f)-1,S=w>>1,y=-7,I=e?o-1:0,b=e?-1:1,x=l[t+I];for(I+=b,a=x&(1<<-y)-1,x>>=-y,y+=f;y>0;a=a*256+l[t+I],I+=b,y-=8);for(s=a&(1<<-y)-1,a>>=-y,y+=n;y>0;s=s*256+l[t+I],I+=b,y-=8);if(a===0)a=1-S;else{if(a===w)return s?NaN:(x?-1:1)*(1/0);s=s+Math.pow(2,n),a=a-S}return(x?-1:1)*s*Math.pow(2,a-n)},Qt.write=function(l,t,e,n,o,a){var s,f,w,S=a*8-o-1,y=(1<<S)-1,I=y>>1,b=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:a-1,N=n?1:-1,B=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(f=isNaN(t)?1:0,s=y):(s=Math.floor(Math.log(t)/Math.LN2),t*(w=Math.pow(2,-s))<1&&(s--,w*=2),s+I>=1?t+=b/w:t+=b*Math.pow(2,1-I),t*w>=2&&(s++,w/=2),s+I>=y?(f=0,s=y):s+I>=1?(f=(t*w-1)*Math.pow(2,o),s=s+I):(f=t*Math.pow(2,I-1)*Math.pow(2,o),s=0));o>=8;l[e+x]=f&255,x+=N,f/=256,o-=8);for(s=s<<o|f,S+=o;S>0;l[e+x]=s&255,x+=N,s/=256,S-=8);l[e+x-N]|=B*128},Qt}h(Ei,"dew$1");var mt={},Ue=!1;function Si(){if(Ue)return mt;Ue=!0;let l=gi(),t=Ei(),e=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;mt.Buffer=s,mt.SlowBuffer=q,mt.INSPECT_MAX_BYTES=50;let n=2147483647;mt.kMaxLength=n,s.TYPED_ARRAY_SUPPORT=o(),!s.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 o(){try{let c=new Uint8Array(1),i={foo:function(){return 42}};return Object.setPrototypeOf(i,Uint8Array.prototype),Object.setPrototypeOf(c,i),c.foo()===42}catch(c){return!1}}h(o,"typedArraySupport"),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function a(c){if(c>n)throw new RangeError('The value "'+c+'" is invalid for option "size"');let i=new Uint8Array(c);return Object.setPrototypeOf(i,s.prototype),i}h(a,"createBuffer");function s(c,i,r){if(typeof c=="number"){if(typeof i=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return y(c)}return f(c,i,r)}h(s,"Buffer"),s.poolSize=8192;function f(c,i,r){if(typeof c=="string")return I(c,i);if(ArrayBuffer.isView(c))return x(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(st(c,ArrayBuffer)||c&&st(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(st(c,SharedArrayBuffer)||c&&st(c.buffer,SharedArrayBuffer)))return N(c,i,r);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let u=c.valueOf&&c.valueOf();if(u!=null&&u!==c)return s.from(u,i,r);let d=B(c);if(d)return d;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return s.from(c[Symbol.toPrimitive]("string"),i,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}h(f,"from"),s.from=function(c,i,r){return f(c,i,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function w(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}h(w,"assertSize");function S(c,i,r){return w(c),c<=0?a(c):i!==void 0?typeof r=="string"?a(c).fill(i,r):a(c).fill(i):a(c)}h(S,"alloc"),s.alloc=function(c,i,r){return S(c,i,r)};function y(c){return w(c),a(c<0?0:P(c)|0)}h(y,"allocUnsafe"),s.allocUnsafe=function(c){return y(c)},s.allocUnsafeSlow=function(c){return y(c)};function I(c,i){if((typeof i!="string"||i==="")&&(i="utf8"),!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);let r=D(c,i)|0,u=a(r),d=u.write(c,i);return d!==r&&(u=u.slice(0,d)),u}h(I,"fromString");function b(c){let i=c.length<0?0:P(c.length)|0,r=a(i);for(let u=0;u<i;u+=1)r[u]=c[u]&255;return r}h(b,"fromArrayLike");function x(c){if(st(c,Uint8Array)){let i=new Uint8Array(c);return N(i.buffer,i.byteOffset,i.byteLength)}return b(c)}h(x,"fromArrayView");function N(c,i,r){if(i<0||c.byteLength<i)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<i+(r||0))throw new RangeError('"length" is outside of buffer bounds');let u;return i===void 0&&r===void 0?u=new Uint8Array(c):r===void 0?u=new Uint8Array(c,i):u=new Uint8Array(c,i,r),Object.setPrototypeOf(u,s.prototype),u}h(N,"fromArrayBuffer");function B(c){if(s.isBuffer(c)){let i=P(c.length)|0,r=a(i);return r.length===0||c.copy(r,0,0,i),r}if(c.length!==void 0)return typeof c.length!="number"||fe(c.length)?a(0):b(c);if(c.type==="Buffer"&&Array.isArray(c.data))return b(c.data)}h(B,"fromObject");function P(c){if(c>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return c|0}h(P,"checked");function q(c){return+c!=c&&(c=0),s.alloc(+c)}h(q,"SlowBuffer"),s.isBuffer=h(function(i){return i!=null&&i._isBuffer===!0&&i!==s.prototype},"isBuffer"),s.compare=h(function(i,r){if(st(i,Uint8Array)&&(i=s.from(i,i.offset,i.byteLength)),st(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(i)||!s.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===r)return 0;let u=i.length,d=r.length;for(let m=0,g=Math.min(u,d);m<g;++m)if(i[m]!==r[m]){u=i[m],d=r[m];break}return u<d?-1:d<u?1:0},"compare"),s.isEncoding=h(function(i){switch(String(i).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"),s.concat=h(function(i,r){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return s.alloc(0);let u;if(r===void 0)for(r=0,u=0;u<i.length;++u)r+=i[u].length;let d=s.allocUnsafe(r),m=0;for(u=0;u<i.length;++u){let g=i[u];if(st(g,Uint8Array))m+g.length>d.length?(s.isBuffer(g)||(g=s.from(g)),g.copy(d,m)):Uint8Array.prototype.set.call(d,g,m);else if(s.isBuffer(g))g.copy(d,m);else throw new TypeError('"list" argument must be an Array of Buffers');m+=g.length}return d},"concat");function D(c,i){if(s.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||st(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);let r=c.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&r===0)return 0;let d=!1;for(;;)switch(i){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return de(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Fe(c).length;default:if(d)return u?-1:de(c).length;i=(""+i).toLowerCase(),d=!0}}h(D,"byteLength"),s.byteLength=D;function X(c,i,r){let u=!1;if((i===void 0||i<0)&&(i=0),i>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,i>>>=0,r<=i))return"";for(c||(c="utf8");;)switch(c){case"hex":return ei(this,i,r);case"utf8":case"utf-8":return Se(this,i,r);case"ascii":return Ze(this,i,r);case"latin1":case"binary":return ti(this,i,r);case"base64":return Ge(this,i,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ii(this,i,r);default:if(u)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),u=!0}}h(X,"slowToString"),s.prototype._isBuffer=!0;function et(c,i,r){let u=c[i];c[i]=c[r],c[r]=u}h(et,"swap"),s.prototype.swap16=h(function(){let i=this.length;if(i%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<i;r+=2)et(this,r,r+1);return this},"swap16"),s.prototype.swap32=h(function(){let i=this.length;if(i%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<i;r+=4)et(this,r,r+3),et(this,r+1,r+2);return this},"swap32"),s.prototype.swap64=h(function(){let i=this.length;if(i%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<i;r+=8)et(this,r,r+7),et(this,r+1,r+6),et(this,r+2,r+5),et(this,r+3,r+4);return this},"swap64"),s.prototype.toString=h(function(){let i=this.length;return i===0?"":arguments.length===0?Se(this,0,i):X.apply(this,arguments)},"toString"),s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=h(function(i){if(!s.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i?!0:s.compare(this,i)===0},"equals"),s.prototype.inspect=h(function(){let i="",r=mt.INSPECT_MAX_BYTES;return i=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(i+=" ... "),"<Buffer "+i+">"},"inspect"),e&&(s.prototype[e]=s.prototype.inspect),s.prototype.compare=h(function(i,r,u,d,m){if(st(i,Uint8Array)&&(i=s.from(i,i.offset,i.byteLength)),!s.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(r===void 0&&(r=0),u===void 0&&(u=i?i.length:0),d===void 0&&(d=0),m===void 0&&(m=this.length),r<0||u>i.length||d<0||m>this.length)throw new RangeError("out of range index");if(d>=m&&r>=u)return 0;if(d>=m)return-1;if(r>=u)return 1;if(r>>>=0,u>>>=0,d>>>=0,m>>>=0,this===i)return 0;let g=m-d,O=u-r,M=Math.min(g,O),L=this.slice(d,m),$=i.slice(r,u);for(let A=0;A<M;++A)if(L[A]!==$[A]){g=L[A],O=$[A];break}return g<O?-1:O<g?1:0},"compare");function J(c,i,r,u,d){if(c.length===0)return-1;if(typeof r=="string"?(u=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,fe(r)&&(r=d?0:c.length-1),r<0&&(r=c.length+r),r>=c.length){if(d)return-1;r=c.length-1}else if(r<0)if(d)r=0;else return-1;if(typeof i=="string"&&(i=s.from(i,u)),s.isBuffer(i))return i.length===0?-1:Ee(c,i,r,u,d);if(typeof i=="number")return i=i&255,typeof Uint8Array.prototype.indexOf=="function"?d?Uint8Array.prototype.indexOf.call(c,i,r):Uint8Array.prototype.lastIndexOf.call(c,i,r):Ee(c,[i],r,u,d);throw new TypeError("val must be string, number or Buffer")}h(J,"bidirectionalIndexOf");function Ee(c,i,r,u,d){let m=1,g=c.length,O=i.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(c.length<2||i.length<2)return-1;m=2,g/=2,O/=2,r/=2}function M($,A){return m===1?$[A]:$.readUInt16BE(A*m)}h(M,"read");let L;if(d){let $=-1;for(L=r;L<g;L++)if(M(c,L)===M(i,$===-1?0:L-$)){if($===-1&&($=L),L-$+1===O)return $*m}else $!==-1&&(L-=L-$),$=-1}else for(r+O>g&&(r=g-O),L=r;L>=0;L--){let $=!0;for(let A=0;A<O;A++)if(M(c,L+A)!==M(i,A)){$=!1;break}if($)return L}return-1}h(Ee,"arrayIndexOf"),s.prototype.includes=h(function(i,r,u){return this.indexOf(i,r,u)!==-1},"includes"),s.prototype.indexOf=h(function(i,r,u){return J(this,i,r,u,!0)},"indexOf"),s.prototype.lastIndexOf=h(function(i,r,u){return J(this,i,r,u,!1)},"lastIndexOf");function qe(c,i,r,u){r=Number(r)||0;let d=c.length-r;u?(u=Number(u),u>d&&(u=d)):u=d;let m=i.length;u>m/2&&(u=m/2);let g;for(g=0;g<u;++g){let O=parseInt(i.substr(g*2,2),16);if(fe(O))return g;c[r+g]=O}return g}h(qe,"hexWrite");function Ve(c,i,r,u){return Gt(de(i,c.length-r),c,r,u)}h(Ve,"utf8Write");function Xe(c,i,r,u){return Gt(si(i),c,r,u)}h(Xe,"asciiWrite");function Ke(c,i,r,u){return Gt(Fe(i),c,r,u)}h(Ke,"base64Write");function Je(c,i,r,u){return Gt(ci(i,c.length-r),c,r,u)}h(Je,"ucs2Write"),s.prototype.write=h(function(i,r,u,d){if(r===void 0)d="utf8",u=this.length,r=0;else if(u===void 0&&typeof r=="string")d=r,u=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(u)?(u=u>>>0,d===void 0&&(d="utf8")):(d=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let m=this.length-r;if((u===void 0||u>m)&&(u=m),i.length>0&&(u<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let g=!1;for(;;)switch(d){case"hex":return qe(this,i,r,u);case"utf8":case"utf-8":return Ve(this,i,r,u);case"ascii":case"latin1":case"binary":return Xe(this,i,r,u);case"base64":return Ke(this,i,r,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Je(this,i,r,u);default:if(g)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),g=!0}},"write"),s.prototype.toJSON=h(function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},"toJSON");function Ge(c,i,r){return i===0&&r===c.length?l.fromByteArray(c):l.fromByteArray(c.slice(i,r))}h(Ge,"base64Slice");function Se(c,i,r){r=Math.min(c.length,r);let u=[],d=i;for(;d<r;){let m=c[d],g=null,O=m>239?4:m>223?3:m>191?2:1;if(d+O<=r){let M,L,$,A;switch(O){case 1:m<128&&(g=m);break;case 2:M=c[d+1],(M&192)===128&&(A=(m&31)<<6|M&63,A>127&&(g=A));break;case 3:M=c[d+1],L=c[d+2],(M&192)===128&&(L&192)===128&&(A=(m&15)<<12|(M&63)<<6|L&63,A>2047&&(A<55296||A>57343)&&(g=A));break;case 4:M=c[d+1],L=c[d+2],$=c[d+3],(M&192)===128&&(L&192)===128&&($&192)===128&&(A=(m&15)<<18|(M&63)<<12|(L&63)<<6|$&63,A>65535&&A<1114112&&(g=A))}}g===null?(g=65533,O=1):g>65535&&(g-=65536,u.push(g>>>10&1023|55296),g=56320|g&1023),u.push(g),d+=O}return Qe(u)}h(Se,"utf8Slice");let Ie=4096;function Qe(c){let i=c.length;if(i<=Ie)return String.fromCharCode.apply(String,c);let r="",u=0;for(;u<i;)r+=String.fromCharCode.apply(String,c.slice(u,u+=Ie));return r}h(Qe,"decodeCodePointsArray");function Ze(c,i,r){let u="";r=Math.min(c.length,r);for(let d=i;d<r;++d)u+=String.fromCharCode(c[d]&127);return u}h(Ze,"asciiSlice");function ti(c,i,r){let u="";r=Math.min(c.length,r);for(let d=i;d<r;++d)u+=String.fromCharCode(c[d]);return u}h(ti,"latin1Slice");function ei(c,i,r){let u=c.length;(!i||i<0)&&(i=0),(!r||r<0||r>u)&&(r=u);let d="";for(let m=i;m<r;++m)d+=ai[c[m]];return d}h(ei,"hexSlice");function ii(c,i,r){let u=c.slice(i,r),d="";for(let m=0;m<u.length-1;m+=2)d+=String.fromCharCode(u[m]+u[m+1]*256);return d}h(ii,"utf16leSlice"),s.prototype.slice=h(function(i,r){let u=this.length;i=~~i,r=r===void 0?u:~~r,i<0?(i+=u,i<0&&(i=0)):i>u&&(i=u),r<0?(r+=u,r<0&&(r=0)):r>u&&(r=u),r<i&&(r=i);let d=this.subarray(i,r);return Object.setPrototypeOf(d,s.prototype),d},"slice");function V(c,i,r){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+i>r)throw new RangeError("Trying to access beyond buffer length")}h(V,"checkOffset"),s.prototype.readUintLE=s.prototype.readUIntLE=h(function(i,r,u){i=i>>>0,r=r>>>0,u||V(i,r,this.length);let d=this[i],m=1,g=0;for(;++g<r&&(m*=256);)d+=this[i+g]*m;return d},"readUIntLE"),s.prototype.readUintBE=s.prototype.readUIntBE=h(function(i,r,u){i=i>>>0,r=r>>>0,u||V(i,r,this.length);let d=this[i+--r],m=1;for(;r>0&&(m*=256);)d+=this[i+--r]*m;return d},"readUIntBE"),s.prototype.readUint8=s.prototype.readUInt8=h(function(i,r){return i=i>>>0,r||V(i,1,this.length),this[i]},"readUInt8"),s.prototype.readUint16LE=s.prototype.readUInt16LE=h(function(i,r){return i=i>>>0,r||V(i,2,this.length),this[i]|this[i+1]<<8},"readUInt16LE"),s.prototype.readUint16BE=s.prototype.readUInt16BE=h(function(i,r){return i=i>>>0,r||V(i,2,this.length),this[i]<<8|this[i+1]},"readUInt16BE"),s.prototype.readUint32LE=s.prototype.readUInt32LE=h(function(i,r){return i=i>>>0,r||V(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+this[i+3]*16777216},"readUInt32LE"),s.prototype.readUint32BE=s.prototype.readUInt32BE=h(function(i,r){return i=i>>>0,r||V(i,4,this.length),this[i]*16777216+(this[i+1]<<16|this[i+2]<<8|this[i+3])},"readUInt32BE"),s.prototype.readBigUInt64LE=lt(h(function(i){i=i>>>0,Ft(i,"offset");let r=this[i],u=this[i+7];(r===void 0||u===void 0)&&Ut(i,this.length-8);let d=r+this[++i]*C(2,8)+this[++i]*C(2,16)+this[++i]*C(2,24),m=this[++i]+this[++i]*C(2,8)+this[++i]*C(2,16)+u*C(2,24);return BigInt(d)+(BigInt(m)<<BigInt(32))},"readBigUInt64LE")),s.prototype.readBigUInt64BE=lt(h(function(i){i=i>>>0,Ft(i,"offset");let r=this[i],u=this[i+7];(r===void 0||u===void 0)&&Ut(i,this.length-8);let d=r*C(2,24)+this[++i]*C(2,16)+this[++i]*C(2,8)+this[++i],m=this[++i]*C(2,24)+this[++i]*C(2,16)+this[++i]*C(2,8)+u;return(BigInt(d)<<BigInt(32))+BigInt(m)},"readBigUInt64BE")),s.prototype.readIntLE=h(function(i,r,u){i=i>>>0,r=r>>>0,u||V(i,r,this.length);let d=this[i],m=1,g=0;for(;++g<r&&(m*=256);)d+=this[i+g]*m;return m*=128,d>=m&&(d-=Math.pow(2,8*r)),d},"readIntLE"),s.prototype.readIntBE=h(function(i,r,u){i=i>>>0,r=r>>>0,u||V(i,r,this.length);let d=r,m=1,g=this[i+--d];for(;d>0&&(m*=256);)g+=this[i+--d]*m;return m*=128,g>=m&&(g-=Math.pow(2,8*r)),g},"readIntBE"),s.prototype.readInt8=h(function(i,r){return i=i>>>0,r||V(i,1,this.length),this[i]&128?(255-this[i]+1)*-1:this[i]},"readInt8"),s.prototype.readInt16LE=h(function(i,r){i=i>>>0,r||V(i,2,this.length);let u=this[i]|this[i+1]<<8;return u&32768?u|4294901760:u},"readInt16LE"),s.prototype.readInt16BE=h(function(i,r){i=i>>>0,r||V(i,2,this.length);let u=this[i+1]|this[i]<<8;return u&32768?u|4294901760:u},"readInt16BE"),s.prototype.readInt32LE=h(function(i,r){return i=i>>>0,r||V(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},"readInt32LE"),s.prototype.readInt32BE=h(function(i,r){return i=i>>>0,r||V(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},"readInt32BE"),s.prototype.readBigInt64LE=lt(h(function(i){i=i>>>0,Ft(i,"offset");let r=this[i],u=this[i+7];(r===void 0||u===void 0)&&Ut(i,this.length-8);let d=this[i+4]+this[i+5]*C(2,8)+this[i+6]*C(2,16)+(u<<24);return(BigInt(d)<<BigInt(32))+BigInt(r+this[++i]*C(2,8)+this[++i]*C(2,16)+this[++i]*C(2,24))},"readBigInt64LE")),s.prototype.readBigInt64BE=lt(h(function(i){i=i>>>0,Ft(i,"offset");let r=this[i],u=this[i+7];(r===void 0||u===void 0)&&Ut(i,this.length-8);let d=(r<<24)+this[++i]*C(2,16)+this[++i]*C(2,8)+this[++i];return(BigInt(d)<<BigInt(32))+BigInt(this[++i]*C(2,24)+this[++i]*C(2,16)+this[++i]*C(2,8)+u)},"readBigInt64BE")),s.prototype.readFloatLE=h(function(i,r){return i=i>>>0,r||V(i,4,this.length),t.read(this,i,!0,23,4)},"readFloatLE"),s.prototype.readFloatBE=h(function(i,r){return i=i>>>0,r||V(i,4,this.length),t.read(this,i,!1,23,4)},"readFloatBE"),s.prototype.readDoubleLE=h(function(i,r){return i=i>>>0,r||V(i,8,this.length),t.read(this,i,!0,52,8)},"readDoubleLE"),s.prototype.readDoubleBE=h(function(i,r){return i=i>>>0,r||V(i,8,this.length),t.read(this,i,!1,52,8)},"readDoubleBE");function G(c,i,r,u,d,m){if(!s.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(i>d||i<m)throw new RangeError('"value" argument is out of bounds');if(r+u>c.length)throw new RangeError("Index out of range")}h(G,"checkInt"),s.prototype.writeUintLE=s.prototype.writeUIntLE=h(function(i,r,u,d){if(i=+i,r=r>>>0,u=u>>>0,!d){let O=Math.pow(2,8*u)-1;G(this,i,r,u,O,0)}let m=1,g=0;for(this[r]=i&255;++g<u&&(m*=256);)this[r+g]=i/m&255;return r+u},"writeUIntLE"),s.prototype.writeUintBE=s.prototype.writeUIntBE=h(function(i,r,u,d){if(i=+i,r=r>>>0,u=u>>>0,!d){let O=Math.pow(2,8*u)-1;G(this,i,r,u,O,0)}let m=u-1,g=1;for(this[r+m]=i&255;--m>=0&&(g*=256);)this[r+m]=i/g&255;return r+u},"writeUIntBE"),s.prototype.writeUint8=s.prototype.writeUInt8=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,1,255,0),this[r]=i&255,r+1},"writeUInt8"),s.prototype.writeUint16LE=s.prototype.writeUInt16LE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,2,65535,0),this[r]=i&255,this[r+1]=i>>>8,r+2},"writeUInt16LE"),s.prototype.writeUint16BE=s.prototype.writeUInt16BE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,2,65535,0),this[r]=i>>>8,this[r+1]=i&255,r+2},"writeUInt16BE"),s.prototype.writeUint32LE=s.prototype.writeUInt32LE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,4,4294967295,0),this[r+3]=i>>>24,this[r+2]=i>>>16,this[r+1]=i>>>8,this[r]=i&255,r+4},"writeUInt32LE"),s.prototype.writeUint32BE=s.prototype.writeUInt32BE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,4,4294967295,0),this[r]=i>>>24,this[r+1]=i>>>16,this[r+2]=i>>>8,this[r+3]=i&255,r+4},"writeUInt32BE");function xe(c,i,r,u,d){Be(i,u,d,c,r,7);let m=Number(i&BigInt(4294967295));c[r++]=m,m=m>>8,c[r++]=m,m=m>>8,c[r++]=m,m=m>>8,c[r++]=m;let g=Number(i>>BigInt(32)&BigInt(4294967295));return c[r++]=g,g=g>>8,c[r++]=g,g=g>>8,c[r++]=g,g=g>>8,c[r++]=g,r}h(xe,"wrtBigUInt64LE");function Ne(c,i,r,u,d){Be(i,u,d,c,r,7);let m=Number(i&BigInt(4294967295));c[r+7]=m,m=m>>8,c[r+6]=m,m=m>>8,c[r+5]=m,m=m>>8,c[r+4]=m;let g=Number(i>>BigInt(32)&BigInt(4294967295));return c[r+3]=g,g=g>>8,c[r+2]=g,g=g>>8,c[r+1]=g,g=g>>8,c[r]=g,r+8}h(Ne,"wrtBigUInt64BE"),s.prototype.writeBigUInt64LE=lt(h(function(i,r=0){return xe(this,i,r,BigInt(0),BigInt("0xffffffffffffffff"))},"writeBigUInt64LE")),s.prototype.writeBigUInt64BE=lt(h(function(i,r=0){return Ne(this,i,r,BigInt(0),BigInt("0xffffffffffffffff"))},"writeBigUInt64BE")),s.prototype.writeIntLE=h(function(i,r,u,d){if(i=+i,r=r>>>0,!d){let M=Math.pow(2,8*u-1);G(this,i,r,u,M-1,-M)}let m=0,g=1,O=0;for(this[r]=i&255;++m<u&&(g*=256);)i<0&&O===0&&this[r+m-1]!==0&&(O=1),this[r+m]=(i/g>>0)-O&255;return r+u},"writeIntLE"),s.prototype.writeIntBE=h(function(i,r,u,d){if(i=+i,r=r>>>0,!d){let M=Math.pow(2,8*u-1);G(this,i,r,u,M-1,-M)}let m=u-1,g=1,O=0;for(this[r+m]=i&255;--m>=0&&(g*=256);)i<0&&O===0&&this[r+m+1]!==0&&(O=1),this[r+m]=(i/g>>0)-O&255;return r+u},"writeIntBE"),s.prototype.writeInt8=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,1,127,-128),i<0&&(i=255+i+1),this[r]=i&255,r+1},"writeInt8"),s.prototype.writeInt16LE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,2,32767,-32768),this[r]=i&255,this[r+1]=i>>>8,r+2},"writeInt16LE"),s.prototype.writeInt16BE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,2,32767,-32768),this[r]=i>>>8,this[r+1]=i&255,r+2},"writeInt16BE"),s.prototype.writeInt32LE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,4,2147483647,-2147483648),this[r]=i&255,this[r+1]=i>>>8,this[r+2]=i>>>16,this[r+3]=i>>>24,r+4},"writeInt32LE"),s.prototype.writeInt32BE=h(function(i,r,u){return i=+i,r=r>>>0,u||G(this,i,r,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[r]=i>>>24,this[r+1]=i>>>16,this[r+2]=i>>>8,this[r+3]=i&255,r+4},"writeInt32BE"),s.prototype.writeBigInt64LE=lt(h(function(i,r=0){return xe(this,i,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64LE")),s.prototype.writeBigInt64BE=lt(h(function(i,r=0){return Ne(this,i,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))},"writeBigInt64BE"));function _e(c,i,r,u,d,m){if(r+u>c.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}h(_e,"checkIEEE754");function be(c,i,r,u,d){return i=+i,r=r>>>0,d||_e(c,i,r,4),t.write(c,i,r,u,23,4),r+4}h(be,"writeFloat"),s.prototype.writeFloatLE=h(function(i,r,u){return be(this,i,r,!0,u)},"writeFloatLE"),s.prototype.writeFloatBE=h(function(i,r,u){return be(this,i,r,!1,u)},"writeFloatBE");function Oe(c,i,r,u,d){return i=+i,r=r>>>0,d||_e(c,i,r,8),t.write(c,i,r,u,52,8),r+8}h(Oe,"writeDouble"),s.prototype.writeDoubleLE=h(function(i,r,u){return Oe(this,i,r,!0,u)},"writeDoubleLE"),s.prototype.writeDoubleBE=h(function(i,r,u){return Oe(this,i,r,!1,u)},"writeDoubleBE"),s.prototype.copy=h(function(i,r,u,d){if(!s.isBuffer(i))throw new TypeError("argument should be a Buffer");if(u||(u=0),!d&&d!==0&&(d=this.length),r>=i.length&&(r=i.length),r||(r=0),d>0&&d<u&&(d=u),d===u||i.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(u<0||u>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),i.length-r<d-u&&(d=i.length-r+u);let m=d-u;return this===i&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,u,d):Uint8Array.prototype.set.call(i,this.subarray(u,d),r),m},"copy"),s.prototype.fill=h(function(i,r,u,d){if(typeof i=="string"){if(typeof r=="string"?(d=r,r=0,u=this.length):typeof u=="string"&&(d=u,u=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!s.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(i.length===1){let g=i.charCodeAt(0);(d==="utf8"&&g<128||d==="latin1")&&(i=g)}}else typeof i=="number"?i=i&255:typeof i=="boolean"&&(i=Number(i));if(r<0||this.length<r||this.length<u)throw new RangeError("Out of range index");if(u<=r)return this;r=r>>>0,u=u===void 0?this.length:u>>>0,i||(i=0);let m;if(typeof i=="number")for(m=r;m<u;++m)this[m]=i;else{let g=s.isBuffer(i)?i:s.from(i,d),O=g.length;if(O===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(m=0;m<u-r;++m)this[m+r]=g[m%O]}return this},"fill");let Bt={};function he(c,i,r){Bt[c]=h(class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:i.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}},"NodeError")}h(he,"E"),he("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),he("ERR_INVALID_ARG_TYPE",function(c,i){return`The "${c}" argument must be of type number. Received type ${typeof i}`},TypeError),he("ERR_OUT_OF_RANGE",function(c,i,r){let u=`The value of "${c}" is out of range.`,d=r;return Number.isInteger(r)&&Math.abs(r)>C(2,32)?d=Te(String(r)):typeof r=="bigint"&&(d=String(r),(r>C(BigInt(2),BigInt(32))||r<-C(BigInt(2),BigInt(32)))&&(d=Te(d)),d+="n"),u+=` It must be ${i}. Received ${d}`,u},RangeError);function Te(c){let i="",r=c.length,u=c[0]==="-"?1:0;for(;r>=u+4;r-=3)i=`_${c.slice(r-3,r)}${i}`;return`${c.slice(0,r)}${i}`}h(Te,"addNumericalSeparator");function ri(c,i,r){Ft(i,"offset"),(c[i]===void 0||c[i+r]===void 0)&&Ut(i,c.length-(r+1))}h(ri,"checkBounds");function Be(c,i,r,u,d,m){if(c>r||c<i){let g=typeof i=="bigint"?"n":"",O;throw m>3?i===0||i===BigInt(0)?O=`>= 0${g} and < 2${g} ** ${(m+1)*8}${g}`:O=`>= -(2${g} ** ${(m+1)*8-1}${g}) and < 2 ** ${(m+1)*8-1}${g}`:O=`>= ${i}${g} and <= ${r}${g}`,new Bt.ERR_OUT_OF_RANGE("value",O,c)}ri(u,d,m)}h(Be,"checkIntBI");function Ft(c,i){if(typeof c!="number")throw new Bt.ERR_INVALID_ARG_TYPE(i,"number",c)}h(Ft,"validateNumber");function Ut(c,i,r){throw Math.floor(c)!==c?(Ft(c,r),new Bt.ERR_OUT_OF_RANGE(r||"offset","an integer",c)):i<0?new Bt.ERR_BUFFER_OUT_OF_BOUNDS:new Bt.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${i}`,c)}h(Ut,"boundsError");let ni=/[^+/0-9A-Za-z-_]/g;function oi(c){if(c=c.split("=")[0],c=c.trim().replace(ni,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}h(oi,"base64clean");function de(c,i){i=i||1/0;let r,u=c.length,d=null,m=[];for(let g=0;g<u;++g){if(r=c.charCodeAt(g),r>55295&&r<57344){if(!d){if(r>56319){(i-=3)>-1&&m.push(239,191,189);continue}else if(g+1===u){(i-=3)>-1&&m.push(239,191,189);continue}d=r;continue}if(r<56320){(i-=3)>-1&&m.push(239,191,189),d=r;continue}r=(d-55296<<10|r-56320)+65536}else d&&(i-=3)>-1&&m.push(239,191,189);if(d=null,r<128){if((i-=1)<0)break;m.push(r)}else if(r<2048){if((i-=2)<0)break;m.push(r>>6|192,r&63|128)}else if(r<65536){if((i-=3)<0)break;m.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((i-=4)<0)break;m.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return m}h(de,"utf8ToBytes");function si(c){let i=[];for(let r=0;r<c.length;++r)i.push(c.charCodeAt(r)&255);return i}h(si,"asciiToBytes");function ci(c,i){let r,u,d,m=[];for(let g=0;g<c.length&&!((i-=2)<0);++g)r=c.charCodeAt(g),u=r>>8,d=r%256,m.push(d),m.push(u);return m}h(ci,"utf16leToBytes");function Fe(c){return l.toByteArray(oi(c))}h(Fe,"base64ToBytes");function Gt(c,i,r,u){let d;for(d=0;d<u&&!(d+r>=i.length||d>=c.length);++d)i[d+r]=c[d];return d}h(Gt,"blitBuffer");function st(c,i){return c instanceof i||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===i.name}h(st,"isInstance");function fe(c){return c!==c}h(fe,"numberIsNaN");let ai=function(){let c="0123456789abcdef",i=new Array(256);for(let r=0;r<16;++r){let u=r*16;for(let d=0;d<16;++d)i[u+d]=c[r]+c[d]}return i}();function lt(c){return typeof BigInt=="undefined"?ui:c}h(lt,"defineBigIntMethod");function ui(){throw new Error("BigInt not supported")}return h(ui,"BufferBigIntNotDefined"),mt}h(Si,"dew");var yt=Si();yt.Buffer;yt.SlowBuffer;yt.INSPECT_MAX_BYTES;yt.kMaxLength;var _=yt.Buffer,Ai=yt.INSPECT_MAX_BYTES,vi=yt.kMaxLength;var Ii="/",wt="/";function vt(l,t){if(typeof l!="string")throw new TypeError(`"${t}" is not a string`)}h(vt,"validateString");function Le(l,t){let e="",n=0,o=-1,a=0,s="\0";for(let f=0;f<=l.length;++f){if(f<l.length)s=l[f];else{if(s=="/")break;s="/"}if(s=="/"){if(!(o===f-1||a===1))if(a===2){if(e.length<2||n!==2||e.at(-1)!=="."||e.at(-2)!=="."){if(e.length>2){let w=e.lastIndexOf("/");w===-1?(e="",n=0):(e=e.slice(0,w),n=e.length-1-e.lastIndexOf("/")),o=f,a=0;continue}else if(e.length!==0){e="",n=0,o=f,a=0;continue}}t&&(e+=e.length>0?"/..":"..",n=2)}else e.length>0?e+="/"+l.slice(o+1,f):e=l.slice(o+1,f),n=f-o-1;o=f,a=0}else s==="."&&a!==-1?++a:a=-1}return e}h(Le,"normalizeString");function gt(...l){let t="",e=!1;for(let n=l.length-1;n>=-1&&!e;n--){let o=n>=0?l[n]:Ii;vt(o,`paths[${n}]`),o.length!==0&&(t=`${o}/${t}`,e=o[0]==="/")}return t=Le(t,!e),e?`/${t}`:t.length>0?t:"."}h(gt,"resolve");function xi(l){if(vt(l,"path"),l.length===0)return".";let t=l[0]==="/",e=l.at(-1)==="/";return l=Le(l,!t),l.length===0?t?"/":e?"./":".":(e&&(l+="/"),t?`/${l}`:l)}h(xi,"normalize");function it(...l){if(l.length===0)return".";let t;for(let e=0;e<l.length;++e){let n=l[e];vt(n,"path"),n.length>0&&(t===void 0?t=n:t+=`/${n}`)}return t===void 0?".":xi(t)}h(it,"join");function F(l){if(vt(l,"path"),l.length===0)return".";let t=l[0]==="/",e=-1,n=!0;for(let o=l.length-1;o>=1;--o)if(l[o]==="/"){if(!n){e=o;break}}else n=!1;return e===-1?t?"/":".":t&&e===1?"//":l.slice(0,e)}h(F,"dirname");function W(l,t){t!==void 0&&vt(t,"ext"),vt(l,"path");let e=0,n=-1,o=!0;if(t!==void 0&&t.length>0&&t.length<=l.length){if(t===l)return"";let a=t.length-1,s=-1;for(let f=l.length-1;f>=0;--f)if(l[f]==="/"){if(!o){e=f+1;break}}else s===-1&&(o=!1,s=f+1),a>=0&&(l[f]===t[a]?--a===-1&&(n=f):(a=-1,n=s));return e===n?n=s:n===-1&&(n=l.length),l.slice(e,n)}for(let a=l.length-1;a>=0;--a)if(l[a]==="/"){if(!o){e=a+1;break}}else n===-1&&(o=!1,n=a+1);return n===-1?"":l.slice(e,n)}h(W,"basename");var E;(function(l){l[l.EPERM=1]="EPERM",l[l.ENOENT=2]="ENOENT",l[l.EIO=5]="EIO",l[l.EBADF=9]="EBADF",l[l.EACCES=13]="EACCES",l[l.EBUSY=16]="EBUSY",l[l.EEXIST=17]="EEXIST",l[l.ENOTDIR=20]="ENOTDIR",l[l.EISDIR=21]="EISDIR",l[l.EINVAL=22]="EINVAL",l[l.EFBIG=27]="EFBIG",l[l.ENOSPC=28]="ENOSPC",l[l.EROFS=30]="EROFS",l[l.ENOTEMPTY=39]="ENOTEMPTY",l[l.ENOTSUP=95]="ENOTSUP"})(E=E||(E={}));var K={};K[E.EPERM]="Operation not permitted.";K[E.ENOENT]="No such file or directory.";K[E.EIO]="Input/output error.";K[E.EBADF]="Bad file descriptor.";K[E.EACCES]="Permission denied.";K[E.EBUSY]="Resource busy or locked.";K[E.EEXIST]="File exists.";K[E.ENOTDIR]="File is not a directory.";K[E.EISDIR]="File is a directory.";K[E.EINVAL]="Invalid argument.";K[E.EFBIG]="File is too big.";K[E.ENOSPC]="No space left on disk.";K[E.EROFS]="Cannot modify a read-only file system.";K[E.ENOTEMPTY]="Directory is not empty.";K[E.ENOTSUP]="Operation is not supported.";var p=class extends Error{static fromJSON(t){let e=new p(t.errno,t.message,t.path);return e.code=t.code,e.stack=t.stack,e}static fromBuffer(t,e=0){return p.fromJSON(JSON.parse(t.toString("utf8",e+4,e+4+t.readUInt32LE(e))))}static FileError(t,e){return new p(t,K[t],e)}static EACCES(t){return this.FileError(E.EACCES,t)}static ENOENT(t){return this.FileError(E.ENOENT,t)}static EEXIST(t){return this.FileError(E.EEXIST,t)}static EISDIR(t){return this.FileError(E.EISDIR,t)}static ENOTDIR(t){return this.FileError(E.ENOTDIR,t)}static EPERM(t){return this.FileError(E.EPERM,t)}static ENOTEMPTY(t){return this.FileError(E.ENOTEMPTY,t)}constructor(t,e=K[t],n){super(e),this.syscall="",this.errno=t,this.code=E[t],this.path=n,this.message=`Error: ${this.code}: ${e}${this.path?`, '${this.path}'`:""}`}toString(){return this.message}toJSON(){return{errno:this.errno,code:this.code,path:this.path,stack:this.stack,message:this.message}}writeToBuffer(t=_.alloc(this.bufferSize()),e=0){let n=t.write(JSON.stringify(this.toJSON()),e+4);return t.writeUInt32LE(n,e),t}bufferSize(){return 4+_.byteLength(JSON.stringify(this.toJSON()))}};h(p,"ApiError");var nt=class{constructor(t,e,n,o,a,s){this.uid=t,this.gid=e,this.suid=n,this.sgid=o,this.euid=a,this.egid=s}};h(nt,"Cred");nt.Root=new nt(0,0,0,0,0,0);var R;(function(l){l[l.FILE=32768]="FILE",l[l.DIRECTORY=16384]="DIRECTORY",l[l.SYMLINK=40960]="SYMLINK"})(R=R||(R={}));var j=class{static fromBuffer(t){let e=t.readUInt32LE(0),n=t.readUInt32LE(4),o=t.readDoubleLE(8),a=t.readDoubleLE(16),s=t.readDoubleLE(24),f=t.readUInt32LE(32),w=t.readUInt32LE(36);return new j(n&61440,e,n&-61441,o,a,s,f,w)}static clone(t){return new j(t.mode&61440,t.size,t.mode&-61441,t.atimeMs,t.mtimeMs,t.ctimeMs,t.uid,t.gid,t.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)}constructor(t,e,n,o,a,s,f,w,S){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=e;let y=0;if(typeof o!="number"&&(y=Date.now(),o=y),typeof a!="number"&&(y||(y=Date.now()),a=y),typeof s!="number"&&(y||(y=Date.now()),s=y),typeof S!="number"&&(y||(y=Date.now()),S=y),typeof f!="number"&&(f=0),typeof w!="number"&&(w=0),this.atimeMs=o,this.ctimeMs=s,this.mtimeMs=a,this.birthtimeMs=S,n)this.mode=n;else switch(t){case R.FILE:this.mode=420;break;case R.DIRECTORY:default:this.mode=511}this.blocks=Math.ceil(e/512),this.mode&61440||(this.mode|=t)}toBuffer(){let t=_.alloc(32);return t.writeUInt32LE(this.size,0),t.writeUInt32LE(this.mode,4),t.writeDoubleLE(this.atime.getTime(),8),t.writeDoubleLE(this.mtime.getTime(),16),t.writeDoubleLE(this.ctime.getTime(),24),t.writeUInt32LE(this.uid,32),t.writeUInt32LE(this.gid,36),t}isFile(){return(this.mode&61440)===32768}isDirectory(){return(this.mode&61440)===16384}isSymbolicLink(){return(this.mode&61440)===40960}hasAccess(t,e){if(e.euid===0||e.egid===0)return!0;let n=this.mode&-61441,o=15,a=15,s=15;if(e.euid==this.uid){let S=(3840&n)>>8;o=(t^S)&t}if(e.egid==this.gid){let S=(240&n)>>4;a=(t^S)&t}let f=15&n;return s=(t^f)&t,!(o&a&s)}getCred(t=this.uid,e=this.gid){return new nt(t,e,this.uid,this.gid,t,e)}chmod(t){this.mode=this.mode&61440|t}chown(t,e){!isNaN(+t)&&0<=+t&&+t<Math.pow(2,32)&&(this.uid=t),!isNaN(+e)&&0<=+e&&+e<Math.pow(2,32)&&(this.gid=e)}isSocket(){return!1}isBlockDevice(){return!1}isCharacterDevice(){return!1}isFIFO(){return!1}};h(j,"Stats");var T=function(l,t,e,n){function o(a){return a instanceof e?a:new e(function(s){s(a)})}return h(o,"adopt"),new(e||(e=Promise))(function(a,s){function f(y){try{S(n.next(y))}catch(I){s(I)}}h(f,"fulfilled");function w(y){try{S(n.throw(y))}catch(I){s(I)}}h(w,"rejected");function S(y){y.done?a(y.value):o(y.value).then(f,w)}h(S,"step"),S((n=n.apply(l,t||[])).next())})},ze,Zt=class{constructor(t){}};h(Zt,"FileSystem");var Q=class extends Zt{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,e,n){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}createFile(t,e,n,o){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}open(t,e,n,o){return T(this,void 0,void 0,function*(){try{let a=yield this.stat(t,o);switch(e.pathExistsAction()){case k.THROW_EXCEPTION:throw p.EEXIST(t);case k.TRUNCATE_FILE:let s=yield this.openFile(t,e,o);if(!s)throw new Error("BFS has reached an impossible code path; please file a bug.");return yield s.truncate(0),yield s.sync(),s;case k.NOP:return this.openFile(t,e,o);default:throw new p(E.EINVAL,"Invalid FileFlag object.")}}catch(a){switch(e.pathNotExistsAction()){case k.CREATE_FILE:let s=yield this.stat(F(t),o);if(s&&!s.isDirectory())throw p.ENOTDIR(F(t));return this.createFile(t,e,n,o);case k.THROW_EXCEPTION:throw p.ENOENT(t);default:throw new p(E.EINVAL,"Invalid FileFlag object.")}}})}access(t,e,n){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}accessSync(t,e,n){throw new p(E.ENOTSUP)}rename(t,e,n){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}renameSync(t,e,n){throw new p(E.ENOTSUP)}stat(t,e){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}statSync(t,e){throw new p(E.ENOTSUP)}openFileSync(t,e,n){throw new p(E.ENOTSUP)}createFileSync(t,e,n,o){throw new p(E.ENOTSUP)}openSync(t,e,n,o){let a;try{a=this.statSync(t,o)}catch(s){switch(e.pathNotExistsAction()){case k.CREATE_FILE:if(!this.statSync(F(t),o).isDirectory())throw p.ENOTDIR(F(t));return this.createFileSync(t,e,n,o);case k.THROW_EXCEPTION:throw p.ENOENT(t);default:throw new p(E.EINVAL,"Invalid FileFlag object.")}}if(!a.hasAccess(n,o))throw p.EACCES(t);switch(e.pathExistsAction()){case k.THROW_EXCEPTION:throw p.EEXIST(t);case k.TRUNCATE_FILE:return this.unlinkSync(t,o),this.createFileSync(t,e,a.mode,o);case k.NOP:return this.openFileSync(t,e,o);default:throw new p(E.EINVAL,"Invalid FileFlag object.")}}unlink(t,e){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}unlinkSync(t,e){throw new p(E.ENOTSUP)}rmdir(t,e){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}rmdirSync(t,e){throw new p(E.ENOTSUP)}mkdir(t,e,n){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}mkdirSync(t,e,n){throw new p(E.ENOTSUP)}readdir(t,e){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}readdirSync(t,e){throw new p(E.ENOTSUP)}exists(t,e){return T(this,void 0,void 0,function*(){try{return yield this.stat(t,e),!0}catch(n){return!1}})}existsSync(t,e){try{return this.statSync(t,e),!0}catch(n){return!1}}realpath(t,e){return T(this,void 0,void 0,function*(){if(this.metadata.supportsLinks){let n=t.split(wt);for(let o=0;o<n.length;o++){let a=n.slice(0,o+1);n[o]=it(...a)}return n.join(wt)}else{if(!(yield this.exists(t,e)))throw p.ENOENT(t);return t}})}realpathSync(t,e){if(this.metadata.supportsLinks){let n=t.split(wt);for(let o=0;o<n.length;o++){let a=n.slice(0,o+1);n[o]=it(...a)}return n.join(wt)}else{if(this.existsSync(t,e))return t;throw p.ENOENT(t)}}truncate(t,e,n){return T(this,void 0,void 0,function*(){let o=yield this.open(t,Y.getFileFlag("r+"),420,n);try{yield o.truncate(e)}finally{yield o.close()}})}truncateSync(t,e,n){let o=this.openSync(t,Y.getFileFlag("r+"),420,n);try{o.truncateSync(e)}finally{o.closeSync()}}readFile(t,e,n,o){return T(this,void 0,void 0,function*(){let a=yield this.open(t,n,420,o);try{let s=yield a.stat(),f=_.alloc(s.size);return yield a.read(f,0,s.size,0),yield a.close(),e===null?f:f.toString(e)}finally{yield a.close()}})}readFileSync(t,e,n,o){let a=this.openSync(t,n,420,o);try{let s=a.statSync(),f=_.alloc(s.size);return a.readSync(f,0,s.size,0),a.closeSync(),e===null?f:f.toString(e)}finally{a.closeSync()}}writeFile(t,e,n,o,a,s){return T(this,void 0,void 0,function*(){let f=yield this.open(t,o,a,s);try{typeof e=="string"&&(e=_.from(e,n)),yield f.write(e,0,e.length,0)}finally{yield f.close()}})}writeFileSync(t,e,n,o,a,s){let f=this.openSync(t,o,a,s);try{typeof e=="string"&&(e=_.from(e,n)),f.writeSync(e,0,e.length,0)}finally{f.closeSync()}}appendFile(t,e,n,o,a,s){return T(this,void 0,void 0,function*(){let f=yield this.open(t,o,a,s);try{typeof e=="string"&&(e=_.from(e,n)),yield f.write(e,0,e.length,null)}finally{yield f.close()}})}appendFileSync(t,e,n,o,a,s){let f=this.openSync(t,o,a,s);try{typeof e=="string"&&(e=_.from(e,n)),f.writeSync(e,0,e.length,null)}finally{f.closeSync()}}chmod(t,e,n){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}chmodSync(t,e,n){throw new p(E.ENOTSUP)}chown(t,e,n,o){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}chownSync(t,e,n,o){throw new p(E.ENOTSUP)}utimes(t,e,n,o){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}utimesSync(t,e,n,o){throw new p(E.ENOTSUP)}link(t,e,n){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}linkSync(t,e,n){throw new p(E.ENOTSUP)}symlink(t,e,n,o){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}symlinkSync(t,e,n,o){throw new p(E.ENOTSUP)}readlink(t,e){return T(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}readlinkSync(t,e){throw new p(E.ENOTSUP)}};h(Q,"BaseFileSystem");ze=Q;Q.Name=ze.name;var Mt=class extends Q{get metadata(){return Object.assign(Object.assign({},super.metadata),{synchronous:!0})}access(t,e,n){return T(this,void 0,void 0,function*(){return this.accessSync(t,e,n)})}rename(t,e,n){return T(this,void 0,void 0,function*(){return this.renameSync(t,e,n)})}stat(t,e){return T(this,void 0,void 0,function*(){return this.statSync(t,e)})}open(t,e,n,o){return T(this,void 0,void 0,function*(){return this.openSync(t,e,n,o)})}unlink(t,e){return T(this,void 0,void 0,function*(){return this.unlinkSync(t,e)})}rmdir(t,e){return T(this,void 0,void 0,function*(){return this.rmdirSync(t,e)})}mkdir(t,e,n){return T(this,void 0,void 0,function*(){return this.mkdirSync(t,e,n)})}readdir(t,e){return T(this,void 0,void 0,function*(){return this.readdirSync(t,e)})}chmod(t,e,n){return T(this,void 0,void 0,function*(){return this.chmodSync(t,e,n)})}chown(t,e,n,o){return T(this,void 0,void 0,function*(){return this.chownSync(t,e,n,o)})}utimes(t,e,n,o){return T(this,void 0,void 0,function*(){return this.utimesSync(t,e,n,o)})}link(t,e,n){return T(this,void 0,void 0,function*(){return this.linkSync(t,e,n)})}symlink(t,e,n,o){return T(this,void 0,void 0,function*(){return this.symlinkSync(t,e,n,o)})}readlink(t,e){return T(this,void 0,void 0,function*(){return this.readlinkSync(t,e)})}};h(Mt,"SynchronousFileSystem");var Z=class{static fromBuffer(t){if(t===void 0)throw new Error("NO");return new Z(t.toString("ascii",38),t.readUInt32LE(0),t.readUInt16LE(4),t.readDoubleLE(6),t.readDoubleLE(14),t.readDoubleLE(22),t.readUInt32LE(30),t.readUInt32LE(34))}constructor(t,e,n,o,a,s,f,w){this.id=t,this.size=e,this.mode=n,this.atime=o,this.mtime=a,this.ctime=s,this.uid=f,this.gid=w}toStats(){return new j((this.mode&61440)===R.DIRECTORY?R.DIRECTORY:R.FILE,this.size,this.mode,this.atime,this.mtime,this.ctime,this.uid,this.gid)}getSize(){return 38+this.id.length}toBuffer(t=_.alloc(this.getSize())){return t.writeUInt32LE(this.size,0),t.writeUInt16LE(this.mode,4),t.writeDoubleLE(this.atime,6),t.writeDoubleLE(this.mtime,14),t.writeDoubleLE(this.ctime,22),t.writeUInt32LE(this.uid,30),t.writeUInt32LE(this.gid,34),t.write(this.id,38,this.id.length,"ascii"),t}update(t){let e=!1;this.size!==t.size&&(this.size=t.size,e=!0),this.mode!==t.mode&&(this.mode=t.mode,e=!0);let n=t.atime.getTime();this.atime!==n&&(this.atime=n,e=!0);let o=t.mtime.getTime();this.mtime!==o&&(this.mtime=o,e=!0);let a=t.ctime.getTime();return this.ctime!==a&&(this.ctime=a,e=!0),this.uid!==t.uid&&(this.uid=t.uid,e=!0),this.uid!==t.uid&&(this.uid=t.uid,e=!0),e}isFile(){return(this.mode&61440)===R.FILE}isDirectory(){return(this.mode&61440)===R.DIRECTORY}};h(Z,"Inode");var Ni=function(l,t,e,n){function o(a){return a instanceof e?a:new e(function(s){s(a)})}return h(o,"adopt"),new(e||(e=Promise))(function(a,s){function f(y){try{S(n.next(y))}catch(I){s(I)}}h(f,"fulfilled");function w(y){try{S(n.throw(y))}catch(I){s(I)}}h(w,"rejected");function S(y){y.done?a(y.value):o(y.value).then(f,w)}h(S,"step"),S((n=n.apply(l,t||[])).next())})};function te(l,t,e,n,o){return Math.min(l+1,t+1,e+1,n===o?t:t+1)}h(te,"_min");function _i(l,t){if(l===t)return 0;l.length>t.length&&([l,t]=[t,l]);let e=l.length,n=t.length;for(;e>0&&l.charCodeAt(e-1)===t.charCodeAt(n-1);)e--,n--;let o=0;for(;o<e&&l.charCodeAt(o)===t.charCodeAt(o);)o++;if(e-=o,n-=o,e===0||n===1)return n;let a=new Array(e<<1);for(let b=0;b<e;)a[e+b]=l.charCodeAt(o+b),a[b]=++b;let s,f,w,S,y;for(s=0;s+3<n;){let b=t.charCodeAt(o+(f=s)),x=t.charCodeAt(o+(w=s+1)),N=t.charCodeAt(o+(S=s+2)),B=t.charCodeAt(o+(y=s+3)),P=s+=4;for(let q=0;q<e;){let D=a[e+q],X=a[q];f=te(X,f,w,b,D),w=te(f,w,S,x,D),S=te(w,S,y,N,D),P=te(S,y,P,B,D),a[q++]=P,y=S,S=w,w=f,f=X}}let I=0;for(;s<n;){let b=t.charCodeAt(o+(f=s));I=++s;for(let x=0;x<e;x++){let N=a[x];a[x]=I=N<f||I<f?N>I?I+1:N+1:b===a[e+x]?f:f+1,f=N}}return I}h(_i,"levenshtein");function He(l,t){return Ni(this,void 0,void 0,function*(){let e=l.Options,n=l.Name,o=0,a=!1,s=!1;for(let f in e)if(Object.prototype.hasOwnProperty.call(e,f)){let w=e[f],S=t&&t[f];if(S==null){if(!w.optional){let y=Object.keys(t).filter(I=>!(I in e)).map(I=>({str:I,distance:_i(f,I)})).filter(I=>I.distance<5).sort((I,b)=>I.distance-b.distance);if(a)return;throw a=!0,new p(E.EINVAL,`[${n}] Required option '${f}' not provided.${y.length>0?` You provided unrecognized option '${y[0].str}'; perhaps you meant to type '${f}'.`:""}
|
|
2
|
-
Option description: ${
|
|
3
|
-
Option description: ${w.description}`)}}}s=!0})}h(He,"checkOptions");var Fr=typeof globalThis.setImmediate=="function"?globalThis.setImmediate:l=>setTimeout(l,0),ot="/";function ee(){return _.from("{}")}h(ee,"getEmptyDirNode");function Rt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(l){let t=Math.random()*16|0;return(l==="x"?t:t&3|8).toString(16)})}h(Rt,"randomUUID");var Et=class{constructor(t){this.store=t,this.originalData={},this.modifiedKeys=[]}get(t){let e=this.store.get(t);return this.stashOldValue(t,e),e}put(t,e,n){return this.markModified(t),this.store.put(t,e,n)}del(t){this.markModified(t),this.store.del(t)}commit(){}abort(){for(let t of this.modifiedKeys){let e=this.originalData[t];e?this.store.put(t,e,!0):this.store.del(t)}}_has(t){return Object.prototype.hasOwnProperty.call(this.originalData,t)}stashOldValue(t,e){this._has(t)||(this.originalData[t]=e)}markModified(t){this.modifiedKeys.indexOf(t)===-1&&(this.modifiedKeys.push(t),this._has(t)||(this.originalData[t]=this.store.get(t)))}};h(Et,"SimpleSyncRWTransaction");var $t=class extends at{constructor(t,e,n,o,a){super(t,e,n,o,a)}syncSync(){this.isDirty()&&(this._fs._syncSync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())}closeSync(){this.syncSync()}};h($t,"SyncKeyValueFile");var St=class extends Mt{static isAvailable(){return!0}constructor(t){super(),this.store=t.store,this.makeRootDirectory()}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,e,n){let o=this.store.beginTransaction("readonly");if(!this.findINode(o,t).toStats().hasAccess(e,n))throw p.EACCES(t)}renameSync(t,e,n){let o=this.store.beginTransaction("readwrite"),a=F(t),s=W(t),f=F(e),w=W(e),S=this.findINode(o,a),y=this.getDirListing(o,a,S);if(!S.toStats().hasAccess(2,n))throw p.EACCES(t);if(!y[s])throw p.ENOENT(t);let I=y[s];if(delete y[s],(f+"/").indexOf(t+"/")===0)throw new p(E.EBUSY,a);let b,x;if(f===a?(b=S,x=y):(b=this.findINode(o,f),x=this.getDirListing(o,f,b)),x[w]){let N=this.getINode(o,e,x[w]);if(N.isFile())try{o.del(N.id),o.del(x[w])}catch(B){throw o.abort(),B}else throw p.EPERM(e)}x[w]=I;try{o.put(S.id,_.from(JSON.stringify(y)),!0),o.put(b.id,_.from(JSON.stringify(x)),!0)}catch(N){throw o.abort(),N}o.commit()}statSync(t,e){let n=this.findINode(this.store.beginTransaction("readonly"),t).toStats();if(!n.hasAccess(4,e))throw p.EACCES(t);return n}createFileSync(t,e,n,o){let a=this.store.beginTransaction("readwrite"),s=_.alloc(0),f=this.commitNewFile(a,t,R.FILE,n,o,s);return new $t(this,t,e,f.toStats(),s)}openFileSync(t,e,n){let o=this.store.beginTransaction("readonly"),a=this.findINode(o,t),s=o.get(a.id);if(!a.toStats().hasAccess(e.getMode(),n))throw p.EACCES(t);if(s===void 0)throw p.ENOENT(t);return new $t(this,t,e,a.toStats(),s)}unlinkSync(t,e){this.removeEntry(t,!1,e)}rmdirSync(t,e){if(this.readdirSync(t,e).length>0)throw p.ENOTEMPTY(t);this.removeEntry(t,!0,e)}mkdirSync(t,e,n){let o=this.store.beginTransaction("readwrite"),a=_.from("{}");this.commitNewFile(o,t,R.DIRECTORY,e,n,a)}readdirSync(t,e){let n=this.store.beginTransaction("readonly"),o=this.findINode(n,t);if(!o.toStats().hasAccess(4,e))throw p.EACCES(t);return Object.keys(this.getDirListing(n,t,o))}chmodSync(t,e,n){this.openFileSync(t,Y.getFileFlag("r+"),n).chmodSync(e)}chownSync(t,e,n,o){this.openFileSync(t,Y.getFileFlag("r+"),o).chownSync(e,n)}_syncSync(t,e,n){let o=this.store.beginTransaction("readwrite"),a=this._findINode(o,F(t),W(t)),s=this.getINode(o,t,a),f=s.update(n);try{o.put(s.id,e,!0),f&&o.put(a,s.toBuffer(),!0)}catch(w){throw o.abort(),w}o.commit()}makeRootDirectory(){let t=this.store.beginTransaction("readwrite");if(t.get(ot)===void 0){let e=new Date().getTime(),n=new Z(Rt(),4096,511|R.DIRECTORY,e,e,e,0,0);t.put(n.id,ee(),!1),t.put(ot,n.toBuffer(),!1),t.commit()}}_findINode(t,e,n,o=new Set){let a=it(e,n);if(o.has(a))throw new p(E.EIO,"Infinite loop detected while finding inode",a);o.add(a);let s=h(f=>{let w=this.getDirListing(t,e,f);if(w[n])return w[n];throw p.ENOENT(gt(e,n))},"readDirectory");return e==="/"?n===""?ot:s(this.getINode(t,e,ot)):s(this.getINode(t,e+wt+n,this._findINode(t,F(e),W(e),o)))}findINode(t,e){return this.getINode(t,e,this._findINode(t,F(e),W(e)))}getINode(t,e,n){let o=t.get(n);if(o===void 0)throw p.ENOENT(e);return Z.fromBuffer(o)}getDirListing(t,e,n){if(!n.isDirectory())throw p.ENOTDIR(e);let o=t.get(n.id);if(o===void 0)throw p.ENOENT(e);return JSON.parse(o.toString())}addNewNode(t,e){let o;for(;0<5;)try{return o=Rt(),t.put(o,e,!1),o}catch(a){}throw new p(E.EIO,"Unable to commit data to key-value store.")}commitNewFile(t,e,n,o,a,s){let f=F(e),w=W(e),S=this.findINode(t,f),y=this.getDirListing(t,f,S),I=new Date().getTime();if(!S.toStats().hasAccess(4,a))throw p.EACCES(e);if(e==="/")throw p.EEXIST(e);if(y[w])throw p.EEXIST(e);let b;try{let x=this.addNewNode(t,s);b=new Z(x,s.length,o|n,I,I,I,a.uid,a.gid);let N=this.addNewNode(t,b.toBuffer());y[w]=N,t.put(S.id,_.from(JSON.stringify(y)),!0)}catch(x){throw t.abort(),x}return t.commit(),b}removeEntry(t,e,n){let o=this.store.beginTransaction("readwrite"),a=F(t),s=this.findINode(o,a),f=this.getDirListing(o,a,s),w=W(t);if(!f[w])throw p.ENOENT(t);let S=f[w],y=this.getINode(o,t,S);if(!y.toStats().hasAccess(2,n))throw p.EACCES(t);if(delete f[w],!e&&y.isDirectory())throw p.EISDIR(t);if(e&&!y.isDirectory())throw p.ENOTDIR(t);try{o.del(y.id),o.del(S),o.put(s.id,_.from(JSON.stringify(f)),!0)}catch(I){throw o.abort(),I}o.commit()}};h(St,"SyncKeyValueFileSystem");function rt(l,t){t=typeof l=="function"?l:t,He(this,l);let e=new this(typeof l=="function"?{}:l);if(typeof t!="function")return e.whenReady();e.whenReady().then(n=>t(null,n)).catch(n=>t(n))}h(rt,"CreateBackend");var je,ie=class{constructor(){this.store=new Map}name(){return ut.Name}clear(){this.store.clear()}beginTransaction(t){return new Et(this)}get(t){return this.store.get(t)}put(t,e,n){return!n&&this.store.has(t)?!1:(this.store.set(t,e),!0)}del(t){this.store.delete(t)}};h(ie,"InMemoryStore");var ut=class extends St{constructor(){super({store:new ie})}};h(ut,"InMemoryFileSystem");je=ut;ut.Name="InMemory";ut.Create=rt.bind(je);ut.Options={};var dn=nt.Root;var me=new Map;ut.Create().then(l=>bi("/",l));function re(l){return me.get(l)}h(re,"getMount");function bi(l,t){if(l[0]!=="/"&&(l="/"+l),l=gt(l),me.has(l))throw new p(E.EINVAL,"Mount point "+l+" is already in use.");me.set(l,t)}h(bi,"mount");var tt=function(l,t,e,n){function o(a){return a instanceof e?a:new e(function(s){s(a)})}return h(o,"adopt"),new(e||(e=Promise))(function(a,s){function f(y){try{S(n.next(y))}catch(I){s(I)}}h(f,"fulfilled");function w(y){try{S(n.throw(y))}catch(I){s(I)}}h(w,"rejected");function S(y){y.done?a(y.value):o(y.value).then(f,w)}h(S,"step"),S((n=n.apply(l,t||[])).next())})},k;(function(l){l[l.NOP=0]="NOP",l[l.THROW_EXCEPTION=1]="THROW_EXCEPTION",l[l.TRUNCATE_FILE=2]="TRUNCATE_FILE",l[l.CREATE_FILE=3]="CREATE_FILE"})(k=k||(k={}));var Y=class{static getFileFlag(t){return Y.flagCache.has(t)||Y.flagCache.set(t,new Y(t)),Y.flagCache.get(t)}constructor(t){if(this.flagStr=t,Y.validFlagStrs.indexOf(t)<0)throw new p(E.EINVAL,"Invalid flag: "+t)}getFlagString(){return this.flagStr}getMode(){let t=0;return t<<=1,t+=+this.isReadable(),t<<=1,t+=+this.isWriteable(),t<<=1,t}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()?k.THROW_EXCEPTION:this.isTruncating()?k.TRUNCATE_FILE:k.NOP}pathNotExistsAction(){return(this.isWriteable()||this.isAppendable())&&this.flagStr!=="r+"?k.CREATE_FILE:k.THROW_EXCEPTION}};h(Y,"FileFlag");Y.flagCache=new Map;Y.validFlagStrs=["r","r+","rs","rs+","w","wx","w+","wx+","a","ax","a+","ax+"];var ne=class{sync(){return tt(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}syncSync(){throw new p(E.ENOTSUP)}datasync(){return tt(this,void 0,void 0,function*(){return this.sync()})}datasyncSync(){return this.syncSync()}chown(t,e){return tt(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}chownSync(t,e){throw new p(E.ENOTSUP)}chmod(t){return tt(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}chmodSync(t){throw new p(E.ENOTSUP)}utimes(t,e){return tt(this,void 0,void 0,function*(){throw new p(E.ENOTSUP)})}utimesSync(t,e){throw new p(E.ENOTSUP)}};h(ne,"BaseFile");var at=class extends ne{constructor(t,e,n,o,a){if(super(),this._pos=0,this._dirty=!1,this._fs=t,this._path=e,this._flag=n,this._stat=o,this._buffer=a||_.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 tt(this,void 0,void 0,function*(){this.syncSync()})}syncSync(){throw new p(E.ENOTSUP)}close(){return tt(this,void 0,void 0,function*(){this.closeSync()})}closeSync(){throw new p(E.ENOTSUP)}stat(){return tt(this,void 0,void 0,function*(){return j.clone(this._stat)})}statSync(){return j.clone(this._stat)}truncate(t){if(this.truncateSync(t),this._flag.isSynchronous()&&!re("/").metadata.synchronous)return this.sync()}truncateSync(t){if(this._dirty=!0,!this._flag.isWriteable())throw new p(E.EPERM,"File not opened with a writeable mode.");if(this._stat.mtimeMs=Date.now(),t>this._buffer.length){let n=_.alloc(t-this._buffer.length,0);this.writeSync(n,0,n.length,this._buffer.length),this._flag.isSynchronous()&&re("/").metadata.synchronous&&this.syncSync();return}this._stat.size=t;let e=_.alloc(t);this._buffer.copy(e,0,0,t),this._buffer=e,this._flag.isSynchronous()&&re("/").metadata.synchronous&&this.syncSync()}write(t,e,n,o){return tt(this,void 0,void 0,function*(){return this.writeSync(t,e,n,o)})}writeSync(t,e,n,o){if(this._dirty=!0,o==null&&(o=this.getPos()),!this._flag.isWriteable())throw new p(E.EPERM,"File not opened with a writeable mode.");let a=o+n;if(a>this._stat.size&&(this._stat.size=a,a>this._buffer.length)){let f=_.alloc(a);this._buffer.copy(f),this._buffer=f}let s=t.copy(this._buffer,o,e,e+n);return this._stat.mtimeMs=Date.now(),this._flag.isSynchronous()?(this.syncSync(),s):(this.setPos(o+s),s)}read(t,e,n,o){return tt(this,void 0,void 0,function*(){return{bytesRead:this.readSync(t,e,n,o),buffer:t}})}readSync(t,e,n,o){if(!this._flag.isReadable())throw new p(E.EPERM,"File not opened with a readable mode.");o==null&&(o=this.getPos()),o+n>this._stat.size&&(n=this._stat.size-o);let s=this._buffer.copy(t,e,o,o+n);return this._stat.atimeMs=Date.now(),this._pos=o+n,s}chmod(t){return tt(this,void 0,void 0,function*(){this.chmodSync(t)})}chmodSync(t){if(!this._fs.metadata.supportsProperties)throw new p(E.ENOTSUP);this._dirty=!0,this._stat.chmod(t),this.syncSync()}chown(t,e){return tt(this,void 0,void 0,function*(){this.chownSync(t,e)})}chownSync(t,e){if(!this._fs.metadata.supportsProperties)throw new p(E.ENOTSUP);this._dirty=!0,this._stat.chown(t,e),this.syncSync()}isDirty(){return this._dirty}resetDirty(){this._dirty=!1}};h(at,"PreloadFile");var xt=class extends at{constructor(t,e,n,o,a){super(t,e,n,o,a)}sync(){return tt(this,void 0,void 0,function*(){})}syncSync(){}close(){return tt(this,void 0,void 0,function*(){})}closeSync(){}};h(xt,"NoSyncFile");var oe=h((l="",t)=>{throw t.name==="NotFoundError"?p.ENOENT(l):t},"handleError"),zt=class extends at{constructor(t,e,n,o,a){super(t,e,n,o,a)}sync(){return v(this,null,function*(){this.isDirty()&&(yield this._fs._sync(this.getPath(),this.getBuffer(),this.getStats(),nt.Root),this.resetDirty())})}close(){return v(this,null,function*(){yield this.sync()})}};h(zt,"FileSystemAccessFile");var se=class extends Q{constructor({handle:e}){super();this._handles=new Map;this._handles.set("/",e)}static isAvailable(){return typeof FileSystemHandle=="function"}get metadata(){return At(pt({},super.metadata),{name:se.Name})}_sync(e,n,o,a){return v(this,null,function*(){let s=yield this.stat(e,a);o.mtime!==s.mtime&&(yield this.writeFile(e,n,null,Y.getFileFlag("w"),s.mode,a))})}rename(e,n,o){return v(this,null,function*(){try{let a=yield this.getHandle(e);if(a instanceof FileSystemDirectoryHandle){let s=yield this.readdir(e,o);if(yield this.mkdir(n,"wx",o),s.length===0)yield this.unlink(e,o);else for(let f of s)yield this.rename(it(e,f),it(n,f),o),yield this.unlink(e,o)}if(a instanceof FileSystemFileHandle){let s=yield a.getFile(),f=yield this.getHandle(F(n));if(f instanceof FileSystemDirectoryHandle){let S=yield(yield f.getFileHandle(W(n),{create:!0})).createWritable(),y=yield s.arrayBuffer();yield S.write(y),S.close(),yield this.unlink(e,o)}}}catch(a){oe(e,a)}})}writeFile(e,n,o,a,s,f,w){return v(this,null,function*(){let S=yield this.getHandle(F(e));if(S instanceof FileSystemDirectoryHandle){let I=yield(yield S.getFileHandle(W(e),{create:!0})).createWritable();yield I.write(n),yield I.close()}})}createFile(e,n,o,a){return v(this,null,function*(){return yield this.writeFile(e,_.alloc(0),null,n,o,a,!0),this.openFile(e,n,a)})}stat(e,n){return v(this,null,function*(){let o=yield this.getHandle(e);if(!o)throw p.FileError(E.EINVAL,e);if(o instanceof FileSystemDirectoryHandle)return new j(R.DIRECTORY,4096);if(o instanceof FileSystemFileHandle){let{lastModified:a,size:s}=yield o.getFile();return new j(R.FILE,s,void 0,void 0,a)}})}exists(e,n){return v(this,null,function*(){try{return yield this.getHandle(e),!0}catch(o){return!1}})}openFile(e,n,o){return v(this,null,function*(){let a=yield this.getHandle(e);if(a instanceof FileSystemFileHandle){let s=yield a.getFile(),f=yield s.arrayBuffer();return this.newFile(e,n,f,s.size,s.lastModified)}})}unlink(e,n){return v(this,null,function*(){let o=yield this.getHandle(F(e));if(o instanceof FileSystemDirectoryHandle)try{yield o.removeEntry(W(e),{recursive:!0})}catch(a){oe(e,a)}})}rmdir(e,n){return v(this,null,function*(){return this.unlink(e,n)})}mkdir(e,n,o){return v(this,null,function*(){let a=n&&n.flag&&n.flag.includes("w")&&!n.flag.includes("x");if((yield this.getHandle(e))&&!a)throw p.EEXIST(e);let f=yield this.getHandle(F(e));f instanceof FileSystemDirectoryHandle&&(yield f.getDirectoryHandle(W(e),{create:!0}))})}readdir(e,n){return v(this,null,function*(){let o=yield this.getHandle(e);if(!(o instanceof FileSystemDirectoryHandle))throw p.ENOTDIR(e);let a=[];try{for(var s=Ce(o.keys()),f,w,S;f=!(w=yield s.next()).done;f=!1){let y=w.value;a.push(it(e,y))}}catch(w){S=[w]}finally{try{f&&(w=s.return)&&(yield w.call(s))}finally{if(S)throw S[0]}}return a})}newFile(e,n,o,a,s){return new zt(this,e,n,new j(R.FILE,a||0,void 0,void 0,s||new Date().getTime()),_.from(o))}getHandle(e){return v(this,null,function*(){if(this._handles.has(e))return this._handles.get(e);let n="/",[,...o]=e.split("/"),a=h(w=>v(this,[w],function*([s,...f]){let S=it(n,s),y=h(b=>{if(n=S,this._handles.set(n,b),f.length===0)return this._handles.get(e);a(f)},"continueWalk"),I=this._handles.get(n);try{return yield y(yield I.getDirectoryHandle(s))}catch(b){if(b.name==="TypeMismatchError")try{return yield y(yield I.getFileHandle(s))}catch(x){oe(S,x)}else{if(b.message==="Name is not allowed.")throw new p(E.ENOENT,b.message,S);oe(S,b)}}}),"getHandleParts");yield a(o)})}},Nt=se;h(Nt,"FileSystemAccessFileSystem"),Nt.Name="FileSystemAccess",Nt.Create=rt.bind(se),Nt.Options={};var Ye=typeof fetch!="undefined"&&fetch!==null;function ce(l){throw new p(E.EIO,l.message)}h(ce,"convertError");function ye(l,t){return v(this,null,function*(){let e=yield fetch(l).catch(ce);if(!e.ok)throw new p(E.EIO,`fetch error: response returned code ${e.status}`);switch(t){case"buffer":let n=yield e.arrayBuffer().catch(ce);return _.from(n);case"json":return yield e.json().catch(ce);default:throw new p(E.EINVAL,"Invalid download type: "+t)}})}h(ye,"fetchFile");function We(l){return v(this,null,function*(){let t=yield fetch(l,{method:"HEAD"}).catch(ce);if(!t.ok)throw new p(E.EIO,`fetch HEAD error: response returned code ${t.status}`);return parseInt(t.headers.get("Content-Length")||"-1",10)})}h(We,"fetchFileSize");var _t=class{static fromListing(t){let e=new _t,n=new ht;e._index["/"]=n;let o=[["",t,n]];for(;o.length>0;){let a,s=o.pop(),f=s[0],w=s[1],S=s[2];for(let y in w)if(Object.prototype.hasOwnProperty.call(w,y)){let I=w[y],b=`${f}/${y}`;I?(e._index[b]=a=new ht,o.push([b,I,a])):a=new ae(new j(R.FILE,-1,365)),S&&(S._ls[y]=a)}}return e}constructor(){this._index={},this.addPath("/",new ht)}fileIterator(t){for(let e in this._index)if(Object.prototype.hasOwnProperty.call(this._index,e)){let n=this._index[e],o=n.getListing();for(let a of o){let s=n.getItem(a);Ht(s)&&t(s.getData())}}}addPath(t,e){if(!e)throw new Error("Inode must be specified");if(t[0]!=="/")throw new Error("Path must be absolute, got: "+t);if(Object.prototype.hasOwnProperty.call(this._index,t))return this._index[t]===e;let n=this._split_path(t),o=n[0],a=n[1],s=this._index[o];return s===void 0&&t!=="/"&&(s=new ht,!this.addPath(o,s))||t!=="/"&&!s.addItem(a,e)?!1:(Pt(e)&&(this._index[t]=e),!0)}addPathFast(t,e){let n=t.lastIndexOf("/"),o=n===0?"/":t.substring(0,n),a=t.substring(n+1),s=this._index[o];return s===void 0&&(s=new ht,this.addPathFast(o,s)),s.addItem(a,e)?(e.isDir()&&(this._index[t]=e),!0):!1}removePath(t){let e=this._split_path(t),n=e[0],o=e[1],a=this._index[n];if(a===void 0)return null;let s=a.remItem(o);if(s===null)return null;if(Pt(s)){let f=s.getListing();for(let w of f)this.removePath(t+"/"+w);t!=="/"&&delete this._index[t]}return s}ls(t){let e=this._index[t];return e===void 0?null:e.getListing()}getInode(t){let e=this._split_path(t),n=e[0],o=e[1],a=this._index[n];return a===void 0?null:n===t?a:a.getItem(o)}_split_path(t){let e=F(t),n=t.slice(e.length+(e==="/"?0:1));return[e,n]}};h(_t,"FileIndex");var ae=class{constructor(t){this.data=t}isFile(){return!0}isDir(){return!1}getData(){return this.data}setData(t){this.data=t}toStats(){return new j(R.FILE,4096,438)}};h(ae,"IndexFileInode");var ht=class{constructor(t=null){this.data=t,this._ls={}}isFile(){return!1}isDir(){return!0}getData(){return this.data}getStats(){return new j(R.DIRECTORY,4096,365)}toStats(){return this.getStats()}getListing(){return Object.keys(this._ls)}getItem(t){let e=this._ls[t];return e||null}addItem(t,e){return t in this._ls?!1:(this._ls[t]=e,!0)}remItem(t){let e=this._ls[t];return e===void 0?null:(delete this._ls[t],e)}};h(ht,"IndexDirInode");function Ht(l){return!!l&&l.isFile()}h(Ht,"isIndexFileInode");function Pt(l){return!!l&&l.isDir()}h(Pt,"isIndexDirInode");var ue=class extends Q{constructor({index:e,baseUrl:n=""}){super();e||(e="index.json");let o=typeof e=="string"?ye(e,"json"):Promise.resolve(e);this._ready=o.then(a=>(this._index=_t.fromListing(a),this)),n.length>0&&n.charAt(n.length-1)!=="/"&&(n=n+"/"),this.prefixUrl=n,this._requestFileInternal=ye,this._requestFileSizeInternal=We}static isAvailable(){return Ye}get metadata(){return At(pt({},super.metadata),{name:ue.Name,readonly:!0})}empty(){this._index.fileIterator(function(e){e.fileData=null})}preloadFile(e,n){let o=this._index.getInode(e);if(Ht(o)){if(o===null)throw p.ENOENT(e);let a=o.getData();a.size=n.length,a.fileData=n}else throw p.EISDIR(e)}stat(e,n){return v(this,null,function*(){let o=this._index.getInode(e);if(o===null)throw p.ENOENT(e);if(!o.toStats().hasAccess(4,n))throw p.EACCES(e);let a;if(Ht(o))a=o.getData(),a.size<0&&(a.size=yield this._requestFileSize(e));else if(Pt(o))a=o.getStats();else throw p.FileError(E.EINVAL,e);return a})}open(e,n,o,a){return v(this,null,function*(){if(n.isWriteable())throw new p(E.EPERM,e);let s=this._index.getInode(e);if(s===null)throw p.ENOENT(e);if(!s.toStats().hasAccess(n.getMode(),a))throw p.EACCES(e);if(Ht(s)||Pt(s))switch(n.pathExistsAction()){case k.THROW_EXCEPTION:case k.TRUNCATE_FILE:throw p.EEXIST(e);case k.NOP:if(Pt(s)){let S=s.getStats();return new xt(this,e,n,S,S.fileData||void 0)}let f=s.getData();if(f.fileData)return new xt(this,e,n,j.clone(f),f.fileData);let w=yield this._requestFile(e,"buffer");return f.size=w.length,f.fileData=w,new xt(this,e,n,j.clone(f),w);default:throw new p(E.EINVAL,"Invalid FileMode object.")}else throw p.EPERM(e)})}readdir(e,n){return v(this,null,function*(){return this.readdirSync(e,n)})}readFile(e,n,o,a){return v(this,null,function*(){let s=yield this.open(e,o,420,a);try{let w=s.getBuffer();return n===null?_.from(w):w.toString(n)}finally{yield s.close()}})}_getHTTPPath(e){return e.charAt(0)==="/"&&(e=e.slice(1)),this.prefixUrl+e}_requestFile(e,n){return this._requestFileInternal(this._getHTTPPath(e),n)}_requestFileSize(e){return this._requestFileSizeInternal(this._getHTTPPath(e))}},bt=ue;h(bt,"HTTPRequest"),bt.Name="HTTPRequest",bt.Create=rt.bind(ue),bt.Options={index:{type:["string","object"],optional:!0,description:"URL to a file index as a JSON file or the file index object itself, generated with the make_http_index script. Defaults to `index.json`."},baseUrl:{type:"string",optional:!0,description:"Used as the URL prefix for fetched files. Default: Fetch files relative to the index."}};var U=function(l,t,e,n){function o(a){return a instanceof e?a:new e(function(s){s(a)})}return h(o,"adopt"),new(e||(e=Promise))(function(a,s){function f(y){try{S(n.next(y))}catch(I){s(I)}}h(f,"fulfilled");function w(y){try{S(n.throw(y))}catch(I){s(I)}}h(w,"rejected");function S(y){y.done?a(y.value):o(y.value).then(f,w)}h(S,"step"),S((n=n.apply(l,t||[])).next())})},jt=class{constructor(t,e){this.key=t,this.value=e,this.prev=null,this.next=null}};h(jt,"LRUNode");var le=class{constructor(t){this.limit=t,this.size=0,this.map={},this.head=null,this.tail=null}set(t,e){let n=new jt(t,e);this.map[t]?(this.map[t].value=n.value,this.remove(n.key)):this.size>=this.limit&&(delete this.map[this.tail.key],this.size--,this.tail=this.tail.prev,this.tail.next=null),this.setHead(n)}get(t){if(this.map[t]){let e=this.map[t].value,n=new jt(t,e);return this.remove(t),this.setHead(n),e}else return null}remove(t){let e=this.map[t];e&&(e.prev!==null?e.prev.next=e.next:this.head=e.next,e.next!==null?e.next.prev=e.prev:this.tail=e.prev,delete this.map[t],this.size--)}removeAll(){this.size=0,this.map={},this.head=null,this.tail=null}setHead(t){t.next=this.head,t.prev=null,this.head!==null&&(this.head.prev=t),this.head=t,this.tail===null&&(this.tail=t),this.size++,this.map[t.key]=t}};h(le,"LRUCache");var Yt=class extends at{constructor(t,e,n,o,a){super(t,e,n,o,a)}sync(){return U(this,void 0,void 0,function*(){this.isDirty()&&(yield this._fs._sync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())})}close(){return U(this,void 0,void 0,function*(){this.sync()})}};h(Yt,"AsyncKeyValueFile");var Wt=class extends Q{static isAvailable(){return!0}constructor(t){super(),this._cache=null,t>0&&(this._cache=new le(t))}init(t){return U(this,void 0,void 0,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,void 0,void 0,function*(){this._cache&&this._cache.removeAll(),yield this.store.clear(),yield this.makeRootDirectory()})}access(t,e,n){return U(this,void 0,void 0,function*(){let o=this.store.beginTransaction("readonly"),a=yield this.findINode(o,t);if(!a)throw p.ENOENT(t);if(!a.toStats().hasAccess(e,n))throw p.EACCES(t)})}rename(t,e,n){return U(this,void 0,void 0,function*(){let o=this._cache;this._cache&&(this._cache=null,o.removeAll());try{let a=this.store.beginTransaction("readwrite"),s=F(t),f=W(t),w=F(e),S=W(e),y=yield this.findINode(a,s),I=yield this.getDirListing(a,s,y);if(!y.toStats().hasAccess(2,n))throw p.EACCES(t);if(!I[f])throw p.ENOENT(t);let b=I[f];if(delete I[f],(w+"/").indexOf(t+"/")===0)throw new p(E.EBUSY,s);let x,N;if(w===s?(x=y,N=I):(x=yield this.findINode(a,w),N=yield this.getDirListing(a,w,x)),N[S]){let B=yield this.getINode(a,e,N[S]);if(B.isFile())try{yield a.del(B.id),yield a.del(N[S])}catch(P){throw yield a.abort(),P}else throw p.EPERM(e)}N[S]=b;try{yield a.put(y.id,_.from(JSON.stringify(I)),!0),yield a.put(x.id,_.from(JSON.stringify(N)),!0)}catch(B){throw yield a.abort(),B}yield a.commit()}finally{o&&(this._cache=o)}})}stat(t,e){return U(this,void 0,void 0,function*(){let n=this.store.beginTransaction("readonly"),a=(yield this.findINode(n,t)).toStats();if(!a.hasAccess(4,e))throw p.EACCES(t);return a})}createFile(t,e,n,o){return U(this,void 0,void 0,function*(){let a=this.store.beginTransaction("readwrite"),s=_.alloc(0),f=yield this.commitNewFile(a,t,R.FILE,n,o,s);return new Yt(this,t,e,f.toStats(),s)})}openFile(t,e,n){return U(this,void 0,void 0,function*(){let o=this.store.beginTransaction("readonly"),a=yield this.findINode(o,t),s=yield o.get(a.id);if(!a.toStats().hasAccess(e.getMode(),n))throw p.EACCES(t);if(s===void 0)throw p.ENOENT(t);return new Yt(this,t,e,a.toStats(),s)})}unlink(t,e){return U(this,void 0,void 0,function*(){return this.removeEntry(t,!1,e)})}rmdir(t,e){return U(this,void 0,void 0,function*(){if((yield this.readdir(t,e)).length>0)throw p.ENOTEMPTY(t);yield this.removeEntry(t,!0,e)})}mkdir(t,e,n){return U(this,void 0,void 0,function*(){let o=this.store.beginTransaction("readwrite"),a=_.from("{}");yield this.commitNewFile(o,t,R.DIRECTORY,e,n,a)})}readdir(t,e){return U(this,void 0,void 0,function*(){let n=this.store.beginTransaction("readonly"),o=yield this.findINode(n,t);if(!o.toStats().hasAccess(4,e))throw p.EACCES(t);return Object.keys(yield this.getDirListing(n,t,o))})}chmod(t,e,n){return U(this,void 0,void 0,function*(){yield(yield this.openFile(t,Y.getFileFlag("r+"),n)).chmod(e)})}chown(t,e,n,o){return U(this,void 0,void 0,function*(){yield(yield this.openFile(t,Y.getFileFlag("r+"),o)).chown(e,n)})}_sync(t,e,n){return U(this,void 0,void 0,function*(){let o=this.store.beginTransaction("readwrite"),a=yield this._findINode(o,F(t),W(t)),s=yield this.getINode(o,t,a),f=s.update(n);try{yield o.put(s.id,e,!0),f&&(yield o.put(a,s.toBuffer(),!0))}catch(w){throw yield o.abort(),w}yield o.commit()})}makeRootDirectory(){return U(this,void 0,void 0,function*(){let t=this.store.beginTransaction("readwrite");if((yield t.get(ot))===void 0){let e=new Date().getTime(),n=new Z(Rt(),4096,511|R.DIRECTORY,e,e,e,0,0);yield t.put(n.id,ee(),!1),yield t.put(ot,n.toBuffer(),!1),yield t.commit()}})}_findINode(t,e,n,o=new Set){return U(this,void 0,void 0,function*(){let a=it(e,n);if(o.has(a))throw new p(E.EIO,"Infinite loop detected while finding inode",a);if(o.add(a),this._cache){let s=this._cache.get(a);if(s)return s}if(e==="/"){if(n==="")return this._cache&&this._cache.set(a,ot),ot;{let s=yield this.getINode(t,e,ot),f=yield this.getDirListing(t,e,s);if(f[n]){let w=f[n];return this._cache&&this._cache.set(a,w),w}else throw p.ENOENT(gt(e,n))}}else{let s=yield this.findINode(t,e,o),f=yield this.getDirListing(t,e,s);if(f[n]){let w=f[n];return this._cache&&this._cache.set(a,w),w}else throw p.ENOENT(gt(e,n))}})}findINode(t,e,n=new Set){return U(this,void 0,void 0,function*(){let o=yield this._findINode(t,F(e),W(e),n);return this.getINode(t,e,o)})}getINode(t,e,n){return U(this,void 0,void 0,function*(){let o=yield t.get(n);if(!o)throw p.ENOENT(e);return Z.fromBuffer(o)})}getDirListing(t,e,n){return U(this,void 0,void 0,function*(){if(!n.isDirectory())throw p.ENOTDIR(e);let o=yield t.get(n.id);try{return JSON.parse(o.toString())}catch(a){throw p.ENOENT(e)}})}addNewNode(t,e){return U(this,void 0,void 0,function*(){let n=0,o=h(()=>U(this,void 0,void 0,function*(){if(++n===5)throw new p(E.EIO,"Unable to commit data to key-value store.");{let a=Rt();return(yield t.put(a,e,!1))?a:o()}}),"reroll");return o()})}commitNewFile(t,e,n,o,a,s){return U(this,void 0,void 0,function*(){let f=F(e),w=W(e),S=yield this.findINode(t,f),y=yield this.getDirListing(t,f,S),I=new Date().getTime();if(!S.toStats().hasAccess(2,a))throw p.EACCES(e);if(e==="/")throw p.EEXIST(e);if(y[w])throw yield t.abort(),p.EEXIST(e);try{let b=yield this.addNewNode(t,s),x=new Z(b,s.length,o|n,I,I,I,a.uid,a.gid),N=yield this.addNewNode(t,x.toBuffer());return y[w]=N,yield t.put(S.id,_.from(JSON.stringify(y)),!0),yield t.commit(),x}catch(b){throw t.abort(),b}})}removeEntry(t,e,n){return U(this,void 0,void 0,function*(){this._cache&&this._cache.remove(t);let o=this.store.beginTransaction("readwrite"),a=F(t),s=yield this.findINode(o,a),f=yield this.getDirListing(o,a,s),w=W(t);if(!f[w])throw p.ENOENT(t);let S=f[w],y=yield this.getINode(o,t,S);if(!y.toStats().hasAccess(2,n))throw p.EACCES(t);if(delete f[w],!e&&y.isDirectory())throw p.EISDIR(t);if(e&&!y.isDirectory())throw p.ENOTDIR(t);try{yield o.del(y.id),yield o.del(S),yield o.put(s.id,_.from(JSON.stringify(f)),!0)}catch(I){throw yield o.abort(),I}yield o.commit()})}};h(Wt,"AsyncKeyValueFileSystem");function qt(l,t=l.toString()){switch(l.name){case"NotFoundError":return new p(E.ENOENT,t);case"QuotaExceededError":return new p(E.ENOSPC,t);default:return new p(E.EIO,t)}}h(qt,"convertError");function Xt(l,t=E.EIO,e=null){return function(n){n.preventDefault(),l(new p(t,e!==null?e:void 0))}}h(Xt,"onErrorHandler");var Dt=class{constructor(t,e){this.tx=t;this.store=e}get(t){return new Promise((e,n)=>{try{let o=this.store.get(t);o.onerror=Xt(n),o.onsuccess=a=>{let s=a.target.result;e(s===void 0?s:_.from(s))}}catch(o){n(qt(o))}})}};h(Dt,"IndexedDBROTransaction");var Vt=class extends Dt{constructor(t,e){super(t,e)}put(t,e,n){return new Promise((o,a)=>{try{let s=n?this.store.put(e,t):this.store.add(e,t);s.onerror=Xt(a),s.onsuccess=()=>{o(!0)}}catch(s){a(qt(s))}})}del(t){return new Promise((e,n)=>{try{let o=this.store.delete(t);o.onerror=Xt(n),o.onsuccess=()=>{e()}}catch(o){n(qt(o))}})}commit(){return new Promise(t=>{setTimeout(t,0)})}abort(){return new Promise((t,e)=>{try{this.tx.abort(),t()}catch(n){e(qt(n))}})}};h(Vt,"IndexedDBRWTransaction");var Ot=class{constructor(t,e){this.db=t;this.storeName=e}static Create(t,e){return new Promise((n,o)=>{let a=e.open(t,1);a.onupgradeneeded=s=>{let f=s.target.result;f.objectStoreNames.contains(t)&&f.deleteObjectStore(t),f.createObjectStore(t)},a.onsuccess=s=>{n(new Ot(s.target.result,t))},a.onerror=Xt(o,E.EACCES)})}name(){return dt.Name+" - "+this.storeName}clear(){return new Promise((t,e)=>{try{let n=this.db.transaction(this.storeName,"readwrite"),o=n.objectStore(this.storeName),a=o.clear();a.onsuccess=()=>{setTimeout(t,0)},a.onerror=Xt(e)}catch(n){e(qt(n))}})}beginTransaction(t="readonly"){let e=this.db.transaction(this.storeName,t),n=e.objectStore(this.storeName);if(t==="readwrite")return new Vt(e,n);if(t==="readonly")return new Dt(e,n);throw new p(E.EINVAL,"Invalid transaction type.")}};h(Ot,"IndexedDBStore");var we=class extends Wt{static isAvailable(t=globalThis.indexedDB){try{if(!(t instanceof IDBFactory)||!t.open("__zenfs_test__"))return!1}catch(e){return!1}}constructor({cacheSize:t=100,storeName:e="zenfs",idbFactory:n=globalThis.indexedDB}){super(t),this._ready=Ot.Create(e,n).then(o=>(this.init(o),this))}},dt=we;h(dt,"IndexedDBFileSystem"),dt.Name="IndexedDB",dt.Create=rt.bind(we),dt.Options={storeName:{type:"string",optional:!0,description:"The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name."},cacheSize:{type:"number",optional:!0,description:"The size of the inode cache. Defaults to 100. A size of 0 or below disables caching."},idbFactory:{type:"object",optional:!0,description:"The IDBFactory to use. Defaults to globalThis.indexedDB."}};var Kt=class{constructor(t){this._storage=t}name(){return ft.Name}clear(){this._storage.clear()}beginTransaction(t){return new Et(this)}get(t){let e=this._storage.getItem(t);if(typeof e=="string")return _.from(e)}put(t,e,n){try{return!n&&this._storage.getItem(t)!==null?!1:(this._storage.setItem(t,e.toString()),!0)}catch(o){throw new p(E.ENOSPC,"Storage is full.")}}del(t){try{this._storage.removeItem(t)}catch(e){throw new p(E.EIO,"Unable to delete key "+t+": "+e)}}};h(Kt,"StorageStore");var ge=class extends St{static isAvailable(t=globalThis.localStorage){return t instanceof Storage}constructor({storage:t=globalThis.localStorage}){super({store:new Kt(t)})}},ft=ge;h(ft,"StorageFileSystem"),ft.Name="Storage",ft.Create=rt.bind(ge),ft.Options={storage:{type:"object",optional:!0,description:"The Storage to use. Defaults to globalThis.localStorage."}};function Oi(l){return typeof l=="object"&&"isBFS"in l&&!!l.isBFS}h(Oi,"isRPCMessage");var Jt=class extends Q{constructor({worker:e}){super();this._currentID=0;this._requests=new Map;this._isInitialized=!1;this._worker=e,this._worker.onmessage=n=>{if(!Oi(n.data))return;let{id:o,method:a,value:s}=n.data;if(a==="metadata"){this._metadata=s,this._isInitialized=!0;return}let{resolve:f,reject:w}=this._requests.get(o);if(this._requests.delete(o),s instanceof Error||s instanceof p){w(s);return}f(s)}}static isAvailable(){return typeof importScripts!="undefined"||typeof Worker!="undefined"}get metadata(){return At(pt(pt({},super.metadata),this._metadata),{name:Jt.Name,synchronous:!1})}_rpc(e,...n){return v(this,null,function*(){return new Promise((o,a)=>{let s=this._currentID++;this._requests.set(s,{resolve:o,reject:a}),this._worker.postMessage({isBFS:!0,id:s,method:e,args:n})})})}rename(e,n,o){return this._rpc("rename",e,n,o)}stat(e,n){return this._rpc("stat",e,n)}open(e,n,o,a){return this._rpc("open",e,n,o,a)}unlink(e,n){return this._rpc("unlink",e,n)}rmdir(e,n){return this._rpc("rmdir",e,n)}mkdir(e,n,o){return this._rpc("mkdir",e,n,o)}readdir(e,n){return this._rpc("readdir",e,n)}exists(e,n){return this._rpc("exists",e,n)}realpath(e,n){return this._rpc("realpath",e,n)}truncate(e,n,o){return this._rpc("truncate",e,n,o)}readFile(e,n,o,a){return this._rpc("readFile",e,n,o,a)}writeFile(e,n,o,a,s,f){return this._rpc("writeFile",e,n,o,a,s,f)}appendFile(e,n,o,a,s,f){return this._rpc("appendFile",e,n,o,a,s,f)}chmod(e,n,o){return this._rpc("chmod",e,n,o)}chown(e,n,o,a){return this._rpc("chown",e,n,o,a)}utimes(e,n,o,a){return this._rpc("utimes",e,n,o,a)}link(e,n,o){return this._rpc("link",e,n,o)}symlink(e,n,o,a){return this._rpc("symlink",e,n,o,a)}readlink(e,n){return this._rpc("readlink",e,n)}syncClose(e,n){return this._rpc("syncClose",e,n)}},Tt=Jt;h(Tt,"WorkerFS"),Tt.Name="WorkerFS",Tt.Create=rt.bind(Jt),Tt.Options={worker:{type:"object",description:"The target worker that you want to connect to, or the current worker if in a worker context.",validator:e=>v(Jt,null,function*(){if(typeof(e==null?void 0:e.postMessage)!="function")throw new p(E.EINVAL,"option must be a Web Worker instance.")})}};return wi(Ti);})();
|
|
4
|
-
/*! Bundled license information:
|
|
5
|
-
|
|
6
|
-
@jspm/core/nodelibs/browser/buffer.js:
|
|
7
|
-
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
8
|
-
*/
|
|
1
|
+
var ZenFS_DOM=(()=>{var yt=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var u=(o,t)=>yt(o,"name",{value:t,configurable:!0});var re=(o,t)=>{for(var e in t)yt(o,e,{get:t[e],enumerable:!0})},se=(o,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ee(t))!ie.call(o,r)&&r!==e&&yt(o,r,{get:()=>t[r],enumerable:!(i=te(t,r))||i.enumerable});return o};var ne=o=>se(yt({},"__esModule",{value:!0}),o);var de={};re(de,{FileSystemAccessFile:()=>ot,FileSystemAccessFileSystem:()=>Y,HTTPRequest:()=>X,IndexedDBFileSystem:()=>L,IndexedDBROTransaction:()=>it,IndexedDBRWTransaction:()=>dt,IndexedDBStore:()=>K,StorageFileSystem:()=>B,StorageStore:()=>mt,WorkerFS:()=>J});var oe="/",z="/";function G(o,t){if(typeof o!="string")throw new TypeError(`"${t}" is not a string`)}u(G,"validateString");function jt(o,t){let e="",i=0,r=-1,s=0,n="\0";for(let c=0;c<=o.length;++c){if(c<o.length)n=o[c];else{if(n=="/")break;n="/"}if(n=="/"){if(!(r===c-1||s===1))if(s===2){if(e.length<2||i!==2||e.at(-1)!=="."||e.at(-2)!=="."){if(e.length>2){let h=e.lastIndexOf("/");h===-1?(e="",i=0):(e=e.slice(0,h),i=e.length-1-e.lastIndexOf("/")),r=c,s=0;continue}else if(e.length!==0){e="",i=0,r=c,s=0;continue}}t&&(e+=e.length>0?"/..":"..",i=2)}else e.length>0?e+="/"+o.slice(r+1,c):e=o.slice(r+1,c),i=c-r-1;r=c,s=0}else n==="."&&s!==-1?++s:s=-1}return e}u(jt,"normalizeString");function H(...o){let t="",e=!1;for(let i=o.length-1;i>=-1&&!e;i--){let r=i>=0?o[i]:oe;G(r,`paths[${i}]`),r.length!==0&&(t=`${r}/${t}`,e=r[0]==="/")}return t=jt(t,!e),e?`/${t}`:t.length>0?t:"."}u(H,"resolve");function ae(o){if(G(o,"path"),o.length===0)return".";let t=o[0]==="/",e=o.at(-1)==="/";return o=jt(o,!t),o.length===0?t?"/":e?"./":".":(e&&(o+="/"),t?`/${o}`:o)}u(ae,"normalize");function F(...o){if(o.length===0)return".";let t;for(let e=0;e<o.length;++e){let i=o[e];G(i,"path"),i.length>0&&(t===void 0?t=i:t+=`/${i}`)}return t===void 0?".":ae(t)}u(F,"join");function y(o){if(G(o,"path"),o.length===0)return".";let t=o[0]==="/",e=-1,i=!0;for(let r=o.length-1;r>=1;--r)if(o[r]==="/"){if(!i){e=r;break}}else i=!1;return e===-1?t?"/":".":t&&e===1?"//":o.slice(0,e)}u(y,"dirname");function _(o,t){t!==void 0&&G(t,"ext"),G(o,"path");let e=0,i=-1,r=!0;if(t!==void 0&&t.length>0&&t.length<=o.length){if(t===o)return"";let s=t.length-1,n=-1;for(let c=o.length-1;c>=0;--c)if(o[c]==="/"){if(!r){e=c+1;break}}else n===-1&&(r=!1,n=c+1),s>=0&&(o[c]===t[s]?--s===-1&&(i=c):(s=-1,i=n));return e===i?i=n:i===-1&&(i=o.length),o.slice(e,i)}for(let s=o.length-1;s>=0;--s)if(o[s]==="/"){if(!r){e=s+1;break}}else i===-1&&(r=!1,i=s+1);return i===-1?"":o.slice(e,i)}u(_,"basename");function gt(o,t,e,i,r){return Math.min(o+1,t+1,e+1,i===r?t:t+1)}u(gt,"_min");function ce(o,t){if(o===t)return 0;o.length>t.length&&([o,t]=[t,o]);let e=o.length,i=t.length;for(;e>0&&o.charCodeAt(e-1)===t.charCodeAt(i-1);)e--,i--;let r=0;for(;r<e&&o.charCodeAt(r)===t.charCodeAt(r);)r++;if(e-=r,i-=r,e===0||i===1)return i;let s=new Array(e<<1);for(let p=0;p<e;)s[e+p]=o.charCodeAt(r+p),s[p]=++p;let n,c,h,d,f;for(n=0;n+3<i;){let p=t.charCodeAt(r+(c=n)),w=t.charCodeAt(r+(h=n+1)),S=t.charCodeAt(r+(d=n+2)),v=t.charCodeAt(r+(f=n+3)),rt=n+=4;for(let pt=0;pt<e;){let wt=s[e+pt],Ht=s[pt];c=gt(Ht,c,h,p,wt),h=gt(c,h,d,w,wt),d=gt(h,d,f,S,wt),rt=gt(d,f,rt,v,wt),s[pt++]=rt,f=d,d=h,h=c,c=Ht}}let m=0;for(;n<i;){let p=t.charCodeAt(r+(c=n));m=++n;for(let w=0;w<e;w++){let S=s[w];s[w]=m=S<c||m<c?S>m?m+1:S+1:p===s[e+w]?c:c+1,c=S}}return m}u(ce,"levenshtein");async function Vt(o,t){let e=o.Options,i=o.Name,r=0,s=!1,n=!1;for(let c in e)if(Object.prototype.hasOwnProperty.call(e,c)){let h=e[c],d=t&&t[c];if(d==null){if(!h.optional){let f=Object.keys(t).filter(m=>!(m in e)).map(m=>({str:m,distance:ce(c,m)})).filter(m=>m.distance<5).sort((m,p)=>m.distance-p.distance);if(s)return;throw s=!0,new a(l.EINVAL,`[${i}] Required option '${c}' not provided.${f.length>0?` You provided unrecognized option '${f[0].str}'; perhaps you meant to type '${c}'.`:""}
|
|
2
|
+
Option description: ${h.description}`)}}else{let f=!1;if(Array.isArray(h.type)?f=h.type.indexOf(typeof d)!==-1:f=typeof d===h.type,f){if(h.validator){r++;try{await h.validator(d)}catch(m){if(!s){if(m)throw s=!0,m;if(r--,r===0&&n)return}}}}else{if(s)return;throw s=!0,new a(l.EINVAL,`[${i}] Value provided for option ${c} is not the proper type. Expected ${Array.isArray(h.type)?`one of {${h.type.join(", ")}}`:h.type}, but received ${typeof d}
|
|
3
|
+
Option description: ${h.description}`)}}}n=!0}u(Vt,"checkOptions");var we=typeof globalThis.setImmediate=="function"?globalThis.setImmediate:o=>setTimeout(o,0),P="/",kt=new Map,le=new globalThis.TextEncoder;function E(o,t="utf8"){return le.encode(o)}u(E,"encode");function U(o,t="utf8"){if(!kt.has(t)){let e=new globalThis.TextDecoder(t);kt.set(t,e.decode.bind(e))}return kt.get(t)(o)}u(U,"decode");function Q(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(o){let t=Math.random()*16|0;return(o==="x"?t:t&3|8).toString(16)})}u(Q,"randomUUID");var l;(function(o){o[o.EPERM=1]="EPERM",o[o.ENOENT=2]="ENOENT",o[o.EIO=5]="EIO",o[o.EBADF=9]="EBADF",o[o.EACCES=13]="EACCES",o[o.EBUSY=16]="EBUSY",o[o.EEXIST=17]="EEXIST",o[o.ENOTDIR=20]="ENOTDIR",o[o.EISDIR=21]="EISDIR",o[o.EINVAL=22]="EINVAL",o[o.EFBIG=27]="EFBIG",o[o.ENOSPC=28]="ENOSPC",o[o.EROFS=30]="EROFS",o[o.ENOTEMPTY=39]="ENOTEMPTY",o[o.ENOTSUP=95]="ENOTSUP"})(l=l||(l={}));var $t={[l.EPERM]:"Operation not permitted.",[l.ENOENT]:"No such file or directory.",[l.EIO]:"Input/output error.",[l.EBADF]:"Bad file descriptor.",[l.EACCES]:"Permission denied.",[l.EBUSY]:"Resource busy or locked.",[l.EEXIST]:"File exists.",[l.ENOTDIR]:"File is not a directory.",[l.EISDIR]:"File is a directory.",[l.EINVAL]:"Invalid argument.",[l.EFBIG]:"File is too big.",[l.ENOSPC]:"No space left on disk.",[l.EROFS]:"Cannot modify a read-only file system.",[l.ENOTEMPTY]:"Directory is not empty.",[l.ENOTSUP]:"Operation is not supported."},a=class extends Error{static fromJSON(t){let e=new a(t.errno,t.message,t.path);return e.code=t.code,e.stack=t.stack,e}static Derserialize(t,e=0){let i=new DataView("buffer"in t?t.buffer:t),r=U(i.buffer.slice(e+4,e+4+i.getUint32(e,!0)));return a.fromJSON(JSON.parse(r))}static FileError(t,e){return new a(t,$t[t],e)}static EACCES(t){return this.FileError(l.EACCES,t)}static ENOENT(t){return this.FileError(l.ENOENT,t)}static EEXIST(t){return this.FileError(l.EEXIST,t)}static EISDIR(t){return this.FileError(l.EISDIR,t)}static ENOTDIR(t){return this.FileError(l.ENOTDIR,t)}static EPERM(t){return this.FileError(l.EPERM,t)}static ENOTEMPTY(t){return this.FileError(l.ENOTEMPTY,t)}constructor(t,e=$t[t],i){super(e),this.syscall="",this.errno=t,this.code=l[t],this.path=i,this.message=`Error: ${this.code}: ${e}${this.path?`, '${this.path}'`:""}`}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()),e=0){let i=new DataView("buffer"in t?t.buffer:t),r=new Uint8Array(i.buffer),s=E(JSON.stringify(this.toJSON()));return r.set(s),i.setUint32(e,s.byteLength,!0),r}bufferSize(){return 4+JSON.stringify(this.toJSON()).length}};u(a,"ApiError");var D=class{constructor(t,e,i,r,s,n){this.uid=t,this.gid=e,this.suid=i,this.sgid=r,this.euid=s,this.egid=n}};u(D,"Cred");D.Root=new D(0,0,0,0,0,0);var g;(function(o){o[o.FILE=32768]="FILE",o[o.DIRECTORY=16384]="DIRECTORY",o[o.SYMLINK=40960]="SYMLINK"})(g=g||(g={}));var Et=class{static Deserialize(t){throw new ReferenceError("Called static abstract method: StatsCommon.Deserialize()")}get _typename(){return this._isBigint?"bigint":"number"}get _typename_inverse(){return this._isBigint?"number":"bigint"}_convert(t){return this._isBigint?BigInt(t):Number(t)}get atime(){return new Date(Number(this.atimeMs))}get mtime(){return new Date(Number(this.mtimeMs))}get ctime(){return new Date(Number(this.ctimeMs))}get birthtime(){return new Date(Number(this.birthtimeMs))}constructor(t=g.FILE,e=-1,i,r,s,n,c,h,d){this.dev=this._convert(0),this.ino=this._convert(0),this.rdev=this._convert(0),this.nlink=this._convert(1),this.blksize=this._convert(4096),this.uid=this._convert(0),this.gid=this._convert(0),this.fileData=null;let f=Date.now(),m=u((p,w)=>typeof p==this._typename?p:this._convert(typeof p==this._typename_inverse?p:w),"resolveT");if(this.atimeMs=m(r,f),this.mtimeMs=m(s,f),this.ctimeMs=m(n,f),this.birthtimeMs=m(d,f),this.uid=m(c,0),this.gid=m(h,0),this.size=this._convert(e),i)this.mode=this._convert(i);else switch(t){case g.FILE:this.mode=this._convert(420);break;case g.DIRECTORY:default:this.mode=this._convert(511)}this.blocks=this._convert(Math.ceil(Number(e)/512)),this.mode&61440||(this.mode=this.mode|this._convert(t))}isFile(){return(this.mode&61440)===32768}isDirectory(){return(this.mode&61440)===16384}isSymbolicLink(){return(this.mode&61440)===40960}hasAccess(t,e){if(e.euid===0||e.egid===0)return!0;let i=this.mode&-61441,r=15,s=15,n=15;if(e.euid==this.uid){let d=(3840&i)>>8;r=(t^d)&t}if(e.egid==this.gid){let d=(240&i)>>4;s=(t^d)&t}let c=15&i;return n=(t^c)&t,!(r&s&n)}getCred(t=Number(this.uid),e=Number(this.gid)){return new D(t,e,Number(this.uid),Number(this.gid),t,e)}chmod(t){this.mode=this._convert(this.mode&61440|t)}chown(t,e){t=Number(t),e=Number(e),!isNaN(t)&&0<=t&&t<2**32&&(this.uid=this._convert(t)),!isNaN(e)&&0<=e&&e<2**32&&(this.gid=this._convert(e))}isSocket(){return!1}isBlockDevice(){return!1}isCharacterDevice(){return!1}isFIFO(){return!1}};u(Et,"StatsCommon");var x=class extends Et{constructor(){super(...arguments),this._isBigint=!1}static clone(t){return new x(t.mode&61440,t.size,t.mode&-61441,t.atimeMs,t.mtimeMs,t.ctimeMs,t.uid,t.gid,t.birthtimeMs)}static Deserialize(t){let e=new DataView("buffer"in t?t.buffer:t),i=e.getUint32(0,!0),r=e.getUint32(4,!0),s=e.getFloat64(8,!0),n=e.getFloat64(16,!0),c=e.getFloat64(24,!0),h=e.getUint32(32,!0),d=e.getUint32(36,!0);return new x(r&61440,i,r&-61441,s,n,c,h,d)}serialize(){let t=new Uint8Array(32),e=new DataView(t.buffer);return e.setUint32(0,this.size,!0),e.setUint32(4,this.mode,!0),e.setFloat64(8,this.atime.getTime(),!0),e.setFloat64(16,this.mtime.getTime(),!0),e.setFloat64(24,this.ctime.getTime(),!0),e.setUint32(32,this.uid,!0),e.setUint32(36,this.gid,!0),t}};u(x,"Stats");var Xt,St=class{constructor(t){}};u(St,"FileSystem");var O=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}async openFile(t,e,i){throw new a(l.ENOTSUP)}async createFile(t,e,i,r){throw new a(l.ENOTSUP)}async open(t,e,i,r){try{let s=await this.stat(t,r);switch(e.pathExistsAction()){case b.THROW_EXCEPTION:throw a.EEXIST(t);case b.TRUNCATE_FILE:let n=await this.openFile(t,e,r);if(!n)throw new Error("BFS has reached an impossible code path; please file a bug.");return await n.truncate(0),await n.sync(),n;case b.NOP:return this.openFile(t,e,r);default:throw new a(l.EINVAL,"Invalid FileFlag object.")}}catch{switch(e.pathNotExistsAction()){case b.CREATE_FILE:let n=await this.stat(y(t),r);if(n&&!n.isDirectory())throw a.ENOTDIR(y(t));return this.createFile(t,e,i,r);case b.THROW_EXCEPTION:throw a.ENOENT(t);default:throw new a(l.EINVAL,"Invalid FileFlag object.")}}}async access(t,e,i){throw new a(l.ENOTSUP)}accessSync(t,e,i){throw new a(l.ENOTSUP)}async rename(t,e,i){throw new a(l.ENOTSUP)}renameSync(t,e,i){throw new a(l.ENOTSUP)}async stat(t,e){throw new a(l.ENOTSUP)}statSync(t,e){throw new a(l.ENOTSUP)}openFileSync(t,e,i){throw new a(l.ENOTSUP)}createFileSync(t,e,i,r){throw new a(l.ENOTSUP)}openSync(t,e,i,r){let s;try{s=this.statSync(t,r)}catch{switch(e.pathNotExistsAction()){case b.CREATE_FILE:if(!this.statSync(y(t),r).isDirectory())throw a.ENOTDIR(y(t));return this.createFileSync(t,e,i,r);case b.THROW_EXCEPTION:throw a.ENOENT(t);default:throw new a(l.EINVAL,"Invalid FileFlag object.")}}if(!s.hasAccess(i,r))throw a.EACCES(t);switch(e.pathExistsAction()){case b.THROW_EXCEPTION:throw a.EEXIST(t);case b.TRUNCATE_FILE:return this.unlinkSync(t,r),this.createFileSync(t,e,s.mode,r);case b.NOP:return this.openFileSync(t,e,r);default:throw new a(l.EINVAL,"Invalid FileFlag object.")}}async unlink(t,e){throw new a(l.ENOTSUP)}unlinkSync(t,e){throw new a(l.ENOTSUP)}async rmdir(t,e){throw new a(l.ENOTSUP)}rmdirSync(t,e){throw new a(l.ENOTSUP)}async mkdir(t,e,i){throw new a(l.ENOTSUP)}mkdirSync(t,e,i){throw new a(l.ENOTSUP)}async readdir(t,e){throw new a(l.ENOTSUP)}readdirSync(t,e){throw new a(l.ENOTSUP)}async exists(t,e){try{return await this.stat(t,e),!0}catch{return!1}}existsSync(t,e){try{return this.statSync(t,e),!0}catch{return!1}}async realpath(t,e){if(this.metadata.supportsLinks){let i=t.split(z);for(let r=0;r<i.length;r++){let s=i.slice(0,r+1);i[r]=F(...s)}return i.join(z)}else{if(!await this.exists(t,e))throw a.ENOENT(t);return t}}realpathSync(t,e){if(this.metadata.supportsLinks){let i=t.split(z);for(let r=0;r<i.length;r++){let s=i.slice(0,r+1);i[r]=F(...s)}return i.join(z)}else{if(this.existsSync(t,e))return t;throw a.ENOENT(t)}}async truncate(t,e,i){let r=await this.open(t,N.getFileFlag("r+"),420,i);try{await r.truncate(e)}finally{await r.close()}}truncateSync(t,e,i){let r=this.openSync(t,N.getFileFlag("r+"),420,i);try{r.truncateSync(e)}finally{r.closeSync()}}async readFile(t,e,i){let r=await this.open(t,e,420,i);try{let s=await r.stat(),n=new Uint8Array(s.size);return await r.read(n,0,s.size,0),await r.close(),n}finally{await r.close()}}readFileSync(t,e,i){let r=this.openSync(t,e,420,i);try{let s=r.statSync(),n=new Uint8Array(s.size);return r.readSync(n,0,s.size,0),r.closeSync(),n}finally{r.closeSync()}}async writeFile(t,e,i,r,s){let n=await this.open(t,i,r,s);try{typeof e=="string"&&(e=E(e)),await n.write(e,0,e.length,0)}finally{await n.close()}}writeFileSync(t,e,i,r,s){let n=this.openSync(t,i,r,s);try{typeof e=="string"&&(e=E(e)),n.writeSync(e,0,e.length,0)}finally{n.closeSync()}}async appendFile(t,e,i,r,s){let n=await this.open(t,i,r,s);try{typeof e=="string"&&(e=E(e)),await n.write(e,0,e.length,null)}finally{await n.close()}}appendFileSync(t,e,i,r,s){let n=this.openSync(t,i,r,s);try{typeof e=="string"&&(e=E(e)),n.writeSync(e,0,e.length,null)}finally{n.closeSync()}}async chmod(t,e,i){throw new a(l.ENOTSUP)}chmodSync(t,e,i){throw new a(l.ENOTSUP)}async chown(t,e,i,r){throw new a(l.ENOTSUP)}chownSync(t,e,i,r){throw new a(l.ENOTSUP)}async utimes(t,e,i,r){throw new a(l.ENOTSUP)}utimesSync(t,e,i,r){throw new a(l.ENOTSUP)}async link(t,e,i){throw new a(l.ENOTSUP)}linkSync(t,e,i){throw new a(l.ENOTSUP)}async symlink(t,e,i,r){throw new a(l.ENOTSUP)}symlinkSync(t,e,i,r){throw new a(l.ENOTSUP)}async readlink(t,e){throw new a(l.ENOTSUP)}readlinkSync(t,e){throw new a(l.ENOTSUP)}};u(O,"BaseFileSystem");Xt=O;O.Name=Xt.name;var st=class extends O{get metadata(){return{...super.metadata,synchronous:!0}}async access(t,e,i){return this.accessSync(t,e,i)}async rename(t,e,i){return this.renameSync(t,e,i)}async stat(t,e){return this.statSync(t,e)}async open(t,e,i,r){return this.openSync(t,e,i,r)}async unlink(t,e){return this.unlinkSync(t,e)}async rmdir(t,e){return this.rmdirSync(t,e)}async mkdir(t,e,i){return this.mkdirSync(t,e,i)}async readdir(t,e){return this.readdirSync(t,e)}async chmod(t,e,i){return this.chmodSync(t,e,i)}async chown(t,e,i,r){return this.chownSync(t,e,i,r)}async utimes(t,e,i,r){return this.utimesSync(t,e,i,r)}async link(t,e,i){return this.linkSync(t,e,i)}async symlink(t,e,i,r){return this.symlinkSync(t,e,i,r)}async readlink(t,e){return this.readlinkSync(t,e)}};u(st,"SynchronousFileSystem");var I=class{static Deserialize(t){let e=new DataView("buffer"in t?t.buffer:t);return new I(U(e.buffer.slice(38)),e.getUint32(0,!0),e.getUint16(4,!0),e.getFloat64(6,!0),e.getFloat64(14,!0),e.getFloat64(22,!0),e.getUint32(30,!0),e.getUint32(34,!0))}constructor(t,e,i,r,s,n,c,h){this.id=t,this.size=e,this.mode=i,this.atime=r,this.mtime=s,this.ctime=n,this.uid=c,this.gid=h}toStats(){return new x((this.mode&61440)===g.DIRECTORY?g.DIRECTORY:g.FILE,this.size,this.mode,this.atime,this.mtime,this.ctime,this.uid,this.gid)}getSize(){return 38+this.id.length}serialize(t=new Uint8Array(this.getSize())){let e=new DataView("buffer"in t?t.buffer:t);e.setUint32(0,this.size,!0),e.setUint16(4,this.mode,!0),e.setFloat64(6,this.atime,!0),e.setFloat64(14,this.mtime,!0),e.setFloat64(22,this.ctime,!0),e.setUint32(30,this.uid,!0),e.setUint32(34,this.gid,!0);let i=new Uint8Array(e.buffer);return i.set(E(this.id),38),i}update(t){let e=!1;this.size!==t.size&&(this.size=t.size,e=!0),this.mode!==t.mode&&(this.mode=t.mode,e=!0);let i=t.atime.getTime();this.atime!==i&&(this.atime=i,e=!0);let r=t.mtime.getTime();this.mtime!==r&&(this.mtime=r,e=!0);let s=t.ctime.getTime();return this.ctime!==s&&(this.ctime=s,e=!0),this.uid!==t.uid&&(this.uid=t.uid,e=!0),this.uid!==t.uid&&(this.uid=t.uid,e=!0),e}isFile(){return(this.mode&61440)===g.FILE}isDirectory(){return(this.mode&61440)===g.DIRECTORY}};u(I,"Inode");var j=class{constructor(t){this.store=t,this.originalData={},this.modifiedKeys=[]}get(t){let e=this.store.get(t);return this.stashOldValue(t,e),e}put(t,e,i){return this.markModified(t),this.store.put(t,e,i)}del(t){this.markModified(t),this.store.del(t)}commit(){}abort(){for(let t of this.modifiedKeys){let e=this.originalData[t];e?this.store.put(t,e,!0):this.store.del(t)}}_has(t){return Object.prototype.hasOwnProperty.call(this.originalData,t)}stashOldValue(t,e){this._has(t)||(this.originalData[t]=e)}markModified(t){this.modifiedKeys.indexOf(t)===-1&&(this.modifiedKeys.push(t),this._has(t)||(this.originalData[t]=this.store.get(t)))}};u(j,"SimpleSyncRWTransaction");var nt=class extends R{constructor(t,e,i,r,s){super(t,e,i,r,s)}syncSync(){this.isDirty()&&(this._fs._syncSync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())}closeSync(){this.syncSync()}};u(nt,"SyncKeyValueFile");var V=class extends st{static isAvailable(){return!0}constructor(t){super(),this.store=t.store,this.makeRootDirectory()}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,e,i){let r=this.store.beginTransaction("readonly");if(!this.findINode(r,t).toStats().hasAccess(e,i))throw a.EACCES(t)}renameSync(t,e,i){let r=this.store.beginTransaction("readwrite"),s=y(t),n=_(t),c=y(e),h=_(e),d=this.findINode(r,s),f=this.getDirListing(r,s,d);if(!d.toStats().hasAccess(2,i))throw a.EACCES(t);if(!f[n])throw a.ENOENT(t);let m=f[n];if(delete f[n],(c+"/").indexOf(t+"/")===0)throw new a(l.EBUSY,s);let p,w;if(c===s?(p=d,w=f):(p=this.findINode(r,c),w=this.getDirListing(r,c,p)),w[h]){let S=this.getINode(r,e,w[h]);if(S.isFile())try{r.del(S.id),r.del(w[h])}catch(v){throw r.abort(),v}else throw a.EPERM(e)}w[h]=m;try{r.put(d.id,E(JSON.stringify(f)),!0),r.put(p.id,E(JSON.stringify(w)),!0)}catch(S){throw r.abort(),S}r.commit()}statSync(t,e){let i=this.findINode(this.store.beginTransaction("readonly"),t).toStats();if(!i.hasAccess(4,e))throw a.EACCES(t);return i}createFileSync(t,e,i,r){let s=this.store.beginTransaction("readwrite"),n=new Uint8Array(0),c=this.commitNewFile(s,t,g.FILE,i,r,n);return new nt(this,t,e,c.toStats(),n)}openFileSync(t,e,i){let r=this.store.beginTransaction("readonly"),s=this.findINode(r,t),n=r.get(s.id);if(!s.toStats().hasAccess(e.getMode(),i))throw a.EACCES(t);if(n===void 0)throw a.ENOENT(t);return new nt(this,t,e,s.toStats(),n)}unlinkSync(t,e){this.removeEntry(t,!1,e)}rmdirSync(t,e){if(this.readdirSync(t,e).length>0)throw a.ENOTEMPTY(t);this.removeEntry(t,!0,e)}mkdirSync(t,e,i){let r=this.store.beginTransaction("readwrite"),s=E("{}");this.commitNewFile(r,t,g.DIRECTORY,e,i,s)}readdirSync(t,e){let i=this.store.beginTransaction("readonly"),r=this.findINode(i,t);if(!r.toStats().hasAccess(4,e))throw a.EACCES(t);return Object.keys(this.getDirListing(i,t,r))}chmodSync(t,e,i){this.openFileSync(t,N.getFileFlag("r+"),i).chmodSync(e)}chownSync(t,e,i,r){this.openFileSync(t,N.getFileFlag("r+"),r).chownSync(e,i)}_syncSync(t,e,i){let r=this.store.beginTransaction("readwrite"),s=this._findINode(r,y(t),_(t)),n=this.getINode(r,t,s),c=n.update(i);try{r.put(n.id,e,!0),c&&r.put(s,n.serialize(),!0)}catch(h){throw r.abort(),h}r.commit()}makeRootDirectory(){let t=this.store.beginTransaction("readwrite");if(t.get(P)===void 0){let e=new Date().getTime(),i=new I(Q(),4096,511|g.DIRECTORY,e,e,e,0,0);t.put(i.id,E("{}"),!1),t.put(P,i.serialize(),!1),t.commit()}}_findINode(t,e,i,r=new Set){let s=F(e,i);if(r.has(s))throw new a(l.EIO,"Infinite loop detected while finding inode",s);r.add(s);let n=u(c=>{let h=this.getDirListing(t,e,c);if(h[i])return h[i];throw a.ENOENT(H(e,i))},"readDirectory");return e==="/"?i===""?P:n(this.getINode(t,e,P)):n(this.getINode(t,e+z+i,this._findINode(t,y(e),_(e),r)))}findINode(t,e){return this.getINode(t,e,this._findINode(t,y(e),_(e)))}getINode(t,e,i){let r=t.get(i);if(r===void 0)throw a.ENOENT(e);return I.Deserialize(r)}getDirListing(t,e,i){if(!i.isDirectory())throw a.ENOTDIR(e);let r=t.get(i.id);if(r===void 0)throw a.ENOENT(e);return JSON.parse(U(r))}addNewNode(t,e){let r;for(;0<5;)try{return r=Q(),t.put(r,e,!1),r}catch{}throw new a(l.EIO,"Unable to commit data to key-value store.")}commitNewFile(t,e,i,r,s,n){let c=y(e),h=_(e),d=this.findINode(t,c),f=this.getDirListing(t,c,d),m=new Date().getTime();if(!d.toStats().hasAccess(4,s))throw a.EACCES(e);if(e==="/")throw a.EEXIST(e);if(f[h])throw a.EEXIST(e);let p;try{let w=this.addNewNode(t,n);p=new I(w,n.length,r|i,m,m,m,s.uid,s.gid);let S=this.addNewNode(t,p.serialize());f[h]=S,t.put(d.id,E(JSON.stringify(f)),!0)}catch(w){throw t.abort(),w}return t.commit(),p}removeEntry(t,e,i){let r=this.store.beginTransaction("readwrite"),s=y(t),n=this.findINode(r,s),c=this.getDirListing(r,s,n),h=_(t);if(!c[h])throw a.ENOENT(t);let d=c[h],f=this.getINode(r,t,d);if(!f.toStats().hasAccess(2,i))throw a.EACCES(t);if(delete c[h],!e&&f.isDirectory())throw a.EISDIR(t);if(e&&!f.isDirectory())throw a.ENOTDIR(t);try{r.del(f.id),r.del(d),r.put(n.id,E(JSON.stringify(c)),!0)}catch(m){throw r.abort(),m}r.commit()}};u(V,"SyncKeyValueFileSystem");function T(o,t){t=typeof o=="function"?o:t,Vt(this,o);let e=new this(typeof o=="function"?{}:o);if(typeof t!="function")return e.whenReady();e.whenReady().then(i=>t(null,i)).catch(i=>t(i))}u(T,"CreateBackend");var Kt,bt=class{constructor(){this.store=new Map}name(){return A.Name}clear(){this.store.clear()}beginTransaction(t){return new j(this)}get(t){return this.store.get(t)}put(t,e,i){return!i&&this.store.has(t)?!1:(this.store.set(t,e),!0)}del(t){this.store.delete(t)}};u(bt,"InMemoryStore");var A=class extends V{constructor(){super({store:new bt})}};u(A,"InMemoryFileSystem");Kt=A;A.Name="InMemory";A.Create=T.bind(Kt);A.Options={};var ni=D.Root;var Mt=new Map;A.Create().then(o=>he("/",o));function Nt(o){return Mt.get(o)}u(Nt,"getMount");function he(o,t){if(o[0]!=="/"&&(o="/"+o),o=H(o),Mt.has(o))throw new a(l.EINVAL,"Mount point "+o+" is already in use.");Mt.set(o,t)}u(he,"mount");var b;(function(o){o[o.NOP=0]="NOP",o[o.THROW_EXCEPTION=1]="THROW_EXCEPTION",o[o.TRUNCATE_FILE=2]="TRUNCATE_FILE",o[o.CREATE_FILE=3]="CREATE_FILE"})(b=b||(b={}));var N=class{static getFileFlag(t){return N.flagCache.has(t)||N.flagCache.set(t,new N(t)),N.flagCache.get(t)}constructor(t){if(typeof t=="number"&&(t=N.StringFromNumber(t)),N.validFlagStrs.indexOf(t)<0)throw new a(l.EINVAL,"Invalid flag string: "+t);this.flagStr=t}static StringFromNumber(t){switch(t){case 0:return"r";case 1052672:return"rs";case 2:return"r+";case 1052674:return"rs+";case 577:return"w";case 705:return"wx";case 578:return"w+";case 706:return"wx+";case 1089:return"a";case 1217:return"ax";case 1090:return"a+";case 1218:return"ax+";default:throw new a(l.EINVAL,"Invalid flag number: "+t)}}getFlagString(){return this.flagStr}getMode(){let t=0;return t<<=1,t+=+this.isReadable(),t<<=1,t+=+this.isWriteable(),t<<=1,t}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()?b.THROW_EXCEPTION:this.isTruncating()?b.TRUNCATE_FILE:b.NOP}pathNotExistsAction(){return(this.isWriteable()||this.isAppendable())&&this.flagStr!=="r+"?b.CREATE_FILE:b.THROW_EXCEPTION}};u(N,"FileFlag");N.flagCache=new Map;N.validFlagStrs=["r","r+","rs","rs+","w","wx","w+","wx+","a","ax","a+","ax+"];var Ft=class{async sync(){throw new a(l.ENOTSUP)}syncSync(){throw new a(l.ENOTSUP)}async datasync(){return this.sync()}datasyncSync(){return this.syncSync()}async chown(t,e){throw new a(l.ENOTSUP)}chownSync(t,e){throw new a(l.ENOTSUP)}async chmod(t){throw new a(l.ENOTSUP)}chmodSync(t){throw new a(l.ENOTSUP)}async utimes(t,e){throw new a(l.ENOTSUP)}utimesSync(t,e){throw new a(l.ENOTSUP)}};u(Ft,"BaseFile");var R=class extends Ft{constructor(t,e,i,r,s){if(super(),this._pos=0,this._dirty=!1,this._fs=t,this._path=e,this._flag=i,this._stat=r,this._buffer=s||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}async sync(){this.syncSync()}syncSync(){throw new a(l.ENOTSUP)}async close(){this.closeSync()}closeSync(){throw new a(l.ENOTSUP)}async stat(){return x.clone(this._stat)}statSync(){return x.clone(this._stat)}truncate(t){if(this.truncateSync(t),this._flag.isSynchronous()&&!Nt("/").metadata.synchronous)return this.sync()}truncateSync(t){if(this._dirty=!0,!this._flag.isWriteable())throw new a(l.EPERM,"File not opened with a writeable mode.");if(this._stat.mtimeMs=Date.now(),t>this._buffer.length){let e=new Uint8Array(t-this._buffer.length);this.writeSync(e,0,e.length,this._buffer.length),this._flag.isSynchronous()&&Nt("/").metadata.synchronous&&this.syncSync();return}this._stat.size=t,this._buffer=this._buffer.subarray(0,t),this._flag.isSynchronous()&&Nt("/").metadata.synchronous&&this.syncSync()}async write(t,e,i,r){return this.writeSync(t,e,i,r)}writeSync(t,e,i,r){if(this._dirty=!0,r==null&&(r=this.getPos()),!this._flag.isWriteable())throw new a(l.EPERM,"File not opened with a writeable mode.");let s=r+i;if(s>this._stat.size&&(this._stat.size=s,s>this._buffer.length)){let c=new Uint8Array(s);c.set(this._buffer),this._buffer=c}this._buffer.set(t.slice(e,e+i),r);let n=this._buffer.length;return this._stat.mtimeMs=Date.now(),this._flag.isSynchronous()?(this.syncSync(),n):(this.setPos(r+n),n)}async read(t,e,i,r){return{bytesRead:this.readSync(t,e,i,r),buffer:t}}readSync(t,e,i,r){if(!this._flag.isReadable())throw new a(l.EPERM,"File not opened with a readable mode.");return r==null&&(r=this.getPos()),r+i>this._stat.size&&(i=this._stat.size-r),this._buffer.set(t.slice(e,e+i),r),this._stat.atimeMs=Date.now(),this._pos=r+i,this._buffer.length}async chmod(t){this.chmodSync(t)}chmodSync(t){if(!this._fs.metadata.supportsProperties)throw new a(l.ENOTSUP);this._dirty=!0,this._stat.chmod(t),this.syncSync()}async chown(t,e){this.chownSync(t,e)}chownSync(t,e){if(!this._fs.metadata.supportsProperties)throw new a(l.ENOTSUP);this._dirty=!0,this._stat.chown(t,e),this.syncSync()}isDirty(){return this._dirty}resetDirty(){this._dirty=!1}};u(R,"PreloadFile");var W=class extends R{constructor(t,e,i,r,s){super(t,e,i,r,s)}async sync(){}syncSync(){}async close(){}closeSync(){}};u(W,"NoSyncFile");var Tt=u((o="",t)=>{throw t.name==="NotFoundError"?a.ENOENT(o):t},"handleError"),ot=class extends R{constructor(t,e,i,r,s){super(t,e,i,r,s)}async sync(){this.isDirty()&&(await this._fs._sync(this.getPath(),this.getBuffer(),this.getStats(),D.Root),this.resetDirty())}async close(){await this.sync()}};u(ot,"FileSystemAccessFile");var Pt=class extends O{constructor({handle:e}){super();this._handles=new Map;this._handles.set("/",e)}static isAvailable(){return typeof FileSystemHandle=="function"}get metadata(){return{...super.metadata,name:Pt.Name}}async _sync(e,i,r,s){let n=await this.stat(e,s);r.mtime!==n.mtime&&await this.writeFile(e,i,N.getFileFlag("w"),n.mode,s)}async rename(e,i,r){try{let s=await this.getHandle(e);if(s instanceof FileSystemDirectoryHandle){let n=await this.readdir(e,r);if(await this.mkdir(i,"wx",r),n.length===0)await this.unlink(e,r);else for(let c of n)await this.rename(F(e,c),F(i,c),r),await this.unlink(e,r)}if(s instanceof FileSystemFileHandle){let n=await s.getFile(),c=await this.getHandle(y(i));if(c instanceof FileSystemDirectoryHandle){let d=await(await c.getFileHandle(_(i),{create:!0})).createWritable(),f=await n.arrayBuffer();await d.write(f),d.close(),await this.unlink(e,r)}}}catch(s){Tt(e,s)}}async writeFile(e,i,r,s,n,c){let h=await this.getHandle(y(e));if(h instanceof FileSystemDirectoryHandle){let f=await(await h.getFileHandle(_(e),{create:!0})).createWritable();await f.write(i),await f.close()}}async createFile(e,i,r,s){return await this.writeFile(e,new Uint8Array,i,r,s,!0),this.openFile(e,i,s)}async stat(e,i){let r=await this.getHandle(e);if(!r)throw a.FileError(l.EINVAL,e);if(r instanceof FileSystemDirectoryHandle)return new x(g.DIRECTORY,4096);if(r instanceof FileSystemFileHandle){let{lastModified:s,size:n}=await r.getFile();return new x(g.FILE,n,void 0,void 0,s)}}async exists(e,i){try{return await this.getHandle(e),!0}catch{return!1}}async openFile(e,i,r){let s=await this.getHandle(e);if(s instanceof FileSystemFileHandle){let n=await s.getFile(),c=await n.arrayBuffer();return this.newFile(e,i,c,n.size,n.lastModified)}}async unlink(e,i){let r=await this.getHandle(y(e));if(r instanceof FileSystemDirectoryHandle)try{await r.removeEntry(_(e),{recursive:!0})}catch(s){Tt(e,s)}}async rmdir(e,i){return this.unlink(e,i)}async mkdir(e,i,r){let s=i&&i.flag&&i.flag.includes("w")&&!i.flag.includes("x");if(await this.getHandle(e)&&!s)throw a.EEXIST(e);let c=await this.getHandle(y(e));c instanceof FileSystemDirectoryHandle&&await c.getDirectoryHandle(_(e),{create:!0})}async readdir(e,i){let r=await this.getHandle(e);if(!(r instanceof FileSystemDirectoryHandle))throw a.ENOTDIR(e);let s=[];for await(let n of r.keys())s.push(F(e,n));return s}newFile(e,i,r,s,n){return new ot(this,e,i,new x(g.FILE,s||0,void 0,void 0,n||new Date().getTime()),new Uint8Array(r))}async getHandle(e){if(this._handles.has(e))return this._handles.get(e);let i="/",[,...r]=e.split("/"),s=u(async([n,...c])=>{let h=F(i,n),d=u(m=>{if(i=h,this._handles.set(i,m),c.length===0)return this._handles.get(e);s(c)},"continueWalk"),f=this._handles.get(i);try{return await d(await f.getDirectoryHandle(n))}catch(m){if(m.name==="TypeMismatchError")try{return await d(await f.getFileHandle(n))}catch(p){Tt(h,p)}else{if(m.message==="Name is not allowed.")throw new a(l.ENOENT,m.message,h);Tt(h,m)}}},"getHandleParts");await s(r)}},Y=Pt;u(Y,"FileSystemAccessFileSystem"),Y.Name="FileSystemAccess",Y.Create=T.bind(Pt),Y.Options={};var Qt=typeof fetch<"u"&&fetch!==null;function Dt(o){throw new a(l.EIO,o.message)}u(Dt,"convertError");async function Lt(o,t){let e=await fetch(o).catch(Dt);if(!e.ok)throw new a(l.EIO,`fetch error: response returned code ${e.status}`);switch(t){case"buffer":let i=await e.arrayBuffer().catch(Dt);return new Uint8Array(i);case"json":return e.json().catch(Dt);default:throw new a(l.EINVAL,"Invalid download type: "+t)}}u(Lt,"fetchFile");async function Zt(o){let t=await fetch(o,{method:"HEAD"}).catch(Dt);if(!t.ok)throw new a(l.EIO,`fetch HEAD error: response returned code ${t.status}`);return parseInt(t.headers.get("Content-Length")||"-1",10)}u(Zt,"fetchFileSize");var q=class{static fromListing(t){let e=new q,i=new M;e._index["/"]=i;let r=[["",t,i]];for(;r.length>0;){let s,n=r.pop(),c=n[0],h=n[1],d=n[2];for(let f in h)if(Object.prototype.hasOwnProperty.call(h,f)){let m=h[f],p=`${c}/${f}`;m?(e._index[p]=s=new M,r.push([p,m,s])):s=new Ct(new x(g.FILE,-1,365)),d&&(d._ls[f]=s)}}return e}constructor(){this._index={},this.addPath("/",new M)}fileIterator(t){for(let e in this._index)if(Object.prototype.hasOwnProperty.call(this._index,e)){let i=this._index[e],r=i.getListing();for(let s of r){let n=i.getItem(s);at(n)&&t(n.getData())}}}addPath(t,e){if(!e)throw new Error("Inode must be specified");if(t[0]!=="/")throw new Error("Path must be absolute, got: "+t);if(Object.prototype.hasOwnProperty.call(this._index,t))return this._index[t]===e;let i=this._split_path(t),r=i[0],s=i[1],n=this._index[r];return n===void 0&&t!=="/"&&(n=new M,!this.addPath(r,n))||t!=="/"&&!n.addItem(s,e)?!1:(et(e)&&(this._index[t]=e),!0)}addPathFast(t,e){let i=t.lastIndexOf("/"),r=i===0?"/":t.substring(0,i),s=t.substring(i+1),n=this._index[r];return n===void 0&&(n=new M,this.addPathFast(r,n)),n.addItem(s,e)?(e.isDir()&&(this._index[t]=e),!0):!1}removePath(t){let e=this._split_path(t),i=e[0],r=e[1],s=this._index[i];if(s===void 0)return null;let n=s.remItem(r);if(n===null)return null;if(et(n)){let c=n.getListing();for(let h of c)this.removePath(t+"/"+h);t!=="/"&&delete this._index[t]}return n}ls(t){let e=this._index[t];return e===void 0?null:e.getListing()}getInode(t){let e=this._split_path(t),i=e[0],r=e[1],s=this._index[i];return s===void 0?null:i===t?s:s.getItem(r)}_split_path(t){let e=y(t),i=t.slice(e.length+(e==="/"?0:1));return[e,i]}};u(q,"FileIndex");var Ct=class{constructor(t){this.data=t}isFile(){return!0}isDir(){return!1}getData(){return this.data}setData(t){this.data=t}toStats(){return new x(g.FILE,4096,438)}};u(Ct,"IndexFileInode");var M=class{constructor(t=null){this.data=t,this._ls={}}isFile(){return!1}isDir(){return!0}getData(){return this.data}getStats(){return new x(g.DIRECTORY,4096,365)}toStats(){return this.getStats()}getListing(){return Object.keys(this._ls)}getItem(t){let e=this._ls[t];return e||null}addItem(t,e){return t in this._ls?!1:(this._ls[t]=e,!0)}remItem(t){let e=this._ls[t];return e===void 0?null:(delete this._ls[t],e)}};u(M,"IndexDirInode");function at(o){return!!o&&o.isFile()}u(at,"isIndexFileInode");function et(o){return!!o&&o.isDir()}u(et,"isIndexDirInode");var Rt=class extends O{constructor({index:e,baseUrl:i=""}){super();e||(e="index.json");let r=typeof e=="string"?Lt(e,"json"):Promise.resolve(e);this._ready=r.then(s=>(this._index=q.fromListing(s),this)),i.length>0&&i.charAt(i.length-1)!=="/"&&(i=i+"/"),this.prefixUrl=i}static isAvailable(){return Qt}get metadata(){return{...super.metadata,name:Rt.Name,readonly:!0}}empty(){this._index.fileIterator(function(e){e.fileData=null})}preloadFile(e,i){let r=this._index.getInode(e);if(at(r)){if(r===null)throw a.ENOENT(e);let s=r.getData();s.size=i.length,s.fileData=i}else throw a.EISDIR(e)}async stat(e,i){let r=this._index.getInode(e);if(r===null)throw a.ENOENT(e);if(!r.toStats().hasAccess(4,i))throw a.EACCES(e);let s;if(at(r))s=r.getData(),s.size<0&&(s.size=await this._requestFileSize(e));else if(et(r))s=r.getStats();else throw a.FileError(l.EINVAL,e);return s}async open(e,i,r,s){if(i.isWriteable())throw new a(l.EPERM,e);let n=this._index.getInode(e);if(n===null)throw a.ENOENT(e);if(!n.toStats().hasAccess(i.getMode(),s))throw a.EACCES(e);if(at(n)||et(n))switch(i.pathExistsAction()){case b.THROW_EXCEPTION:case b.TRUNCATE_FILE:throw a.EEXIST(e);case b.NOP:if(et(n)){let d=n.getStats();return new W(this,e,i,d,d.fileData||void 0)}let c=n.getData();if(c.fileData)return new W(this,e,i,x.clone(c),c.fileData);let h=await this._requestFile(e,"buffer");return c.size=h.length,c.fileData=h,new W(this,e,i,x.clone(c),h);default:throw new a(l.EINVAL,"Invalid FileMode object.")}else throw a.EPERM(e)}async readdir(e,i){return this.readdirSync(e,i)}async readFile(e,i,r){let s=await this.open(e,i,420,r);try{return s.getBuffer()}finally{await s.close()}}_getHTTPPath(e){return e.charAt(0)==="/"&&(e=e.slice(1)),this.prefixUrl+e}_requestFile(e,i){return Lt(this._getHTTPPath(e),i)}_requestFileSize(e){return Zt(this._getHTTPPath(e))}},X=Rt;u(X,"HTTPRequest"),X.Name="HTTPRequest",X.Create=T.bind(Rt),X.Options={index:{type:["string","object"],optional:!0,description:"URL to a file index as a JSON file or the file index object itself, generated with the make_http_index script. Defaults to `index.json`."},baseUrl:{type:"string",optional:!0,description:"Used as the URL prefix for fetched files. Default: Fetch files relative to the index."}};var ct=class{constructor(t,e){this.key=t,this.value=e,this.prev=null,this.next=null}};u(ct,"LRUNode");var At=class{constructor(t){this.limit=t,this.size=0,this.map={},this.head=null,this.tail=null}set(t,e){let i=new ct(t,e);this.map[t]?(this.map[t].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(t){if(this.map[t]){let e=this.map[t].value,i=new ct(t,e);return this.remove(t),this.setHead(i),e}else return null}remove(t){let e=this.map[t];e&&(e.prev!==null?e.prev.next=e.next:this.head=e.next,e.next!==null?e.next.prev=e.prev:this.tail=e.prev,delete this.map[t],this.size--)}removeAll(){this.size=0,this.map={},this.head=null,this.tail=null}setHead(t){t.next=this.head,t.prev=null,this.head!==null&&(this.head.prev=t),this.head=t,this.tail===null&&(this.tail=t),this.size++,this.map[t.key]=t}};u(At,"LRUCache");var lt=class extends R{constructor(t,e,i,r,s){super(t,e,i,r,s)}async sync(){this.isDirty()&&(await this._fs._sync(this.getPath(),this.getBuffer(),this.getStats()),this.resetDirty())}async close(){this.sync()}};u(lt,"AsyncKeyValueFile");var ht=class extends O{static isAvailable(){return!0}constructor(t){super(),this._cache=null,t>0&&(this._cache=new At(t))}async init(t){this.store=t,await this.makeRootDirectory()}getName(){return this.store.name()}isReadOnly(){return!1}supportsSymlinks(){return!1}supportsProps(){return!0}supportsSynch(){return!1}async empty(){this._cache&&this._cache.removeAll(),await this.store.clear(),await this.makeRootDirectory()}async access(t,e,i){let r=this.store.beginTransaction("readonly"),s=await this.findINode(r,t);if(!s)throw a.ENOENT(t);if(!s.toStats().hasAccess(e,i))throw a.EACCES(t)}async rename(t,e,i){let r=this._cache;this._cache&&(this._cache=null,r.removeAll());try{let s=this.store.beginTransaction("readwrite"),n=y(t),c=_(t),h=y(e),d=_(e),f=await this.findINode(s,n),m=await this.getDirListing(s,n,f);if(!f.toStats().hasAccess(2,i))throw a.EACCES(t);if(!m[c])throw a.ENOENT(t);let p=m[c];if(delete m[c],(h+"/").indexOf(t+"/")===0)throw new a(l.EBUSY,n);let w,S;if(h===n?(w=f,S=m):(w=await this.findINode(s,h),S=await this.getDirListing(s,h,w)),S[d]){let v=await this.getINode(s,e,S[d]);if(v.isFile())try{await s.del(v.id),await s.del(S[d])}catch(rt){throw await s.abort(),rt}else throw a.EPERM(e)}S[d]=p;try{await s.put(f.id,E(JSON.stringify(m)),!0),await s.put(w.id,E(JSON.stringify(S)),!0)}catch(v){throw await s.abort(),v}await s.commit()}finally{r&&(this._cache=r)}}async stat(t,e){let i=this.store.beginTransaction("readonly"),s=(await this.findINode(i,t)).toStats();if(!s.hasAccess(4,e))throw a.EACCES(t);return s}async createFile(t,e,i,r){let s=this.store.beginTransaction("readwrite"),n=new Uint8Array(0),c=await this.commitNewFile(s,t,g.FILE,i,r,n);return new lt(this,t,e,c.toStats(),n)}async openFile(t,e,i){let r=this.store.beginTransaction("readonly"),s=await this.findINode(r,t),n=await r.get(s.id);if(!s.toStats().hasAccess(e.getMode(),i))throw a.EACCES(t);if(n===void 0)throw a.ENOENT(t);return new lt(this,t,e,s.toStats(),n)}async unlink(t,e){return this.removeEntry(t,!1,e)}async rmdir(t,e){if((await this.readdir(t,e)).length>0)throw a.ENOTEMPTY(t);await this.removeEntry(t,!0,e)}async mkdir(t,e,i){let r=this.store.beginTransaction("readwrite"),s=E("{}");await this.commitNewFile(r,t,g.DIRECTORY,e,i,s)}async readdir(t,e){let i=this.store.beginTransaction("readonly"),r=await this.findINode(i,t);if(!r.toStats().hasAccess(4,e))throw a.EACCES(t);return Object.keys(await this.getDirListing(i,t,r))}async chmod(t,e,i){await(await this.openFile(t,N.getFileFlag("r+"),i)).chmod(e)}async chown(t,e,i,r){await(await this.openFile(t,N.getFileFlag("r+"),r)).chown(e,i)}async _sync(t,e,i){let r=this.store.beginTransaction("readwrite"),s=await this._findINode(r,y(t),_(t)),n=await this.getINode(r,t,s),c=n.update(i);try{await r.put(n.id,e,!0),c&&await r.put(s,n.serialize(),!0)}catch(h){throw await r.abort(),h}await r.commit()}async makeRootDirectory(){let t=this.store.beginTransaction("readwrite");if(await t.get(P)===void 0){let e=new Date().getTime(),i=new I(Q(),4096,511|g.DIRECTORY,e,e,e,0,0);await t.put(i.id,E("{}"),!1),await t.put(P,i.serialize(),!1),await t.commit()}}async _findINode(t,e,i,r=new Set){let s=F(e,i);if(r.has(s))throw new a(l.EIO,"Infinite loop detected while finding inode",s);if(r.add(s),this._cache){let n=this._cache.get(s);if(n)return n}if(e==="/"){if(i==="")return this._cache&&this._cache.set(s,P),P;{let n=await this.getINode(t,e,P),c=await this.getDirListing(t,e,n);if(c[i]){let h=c[i];return this._cache&&this._cache.set(s,h),h}else throw a.ENOENT(H(e,i))}}else{let n=await this.findINode(t,e,r),c=await this.getDirListing(t,e,n);if(c[i]){let h=c[i];return this._cache&&this._cache.set(s,h),h}else throw a.ENOENT(H(e,i))}}async findINode(t,e,i=new Set){let r=await this._findINode(t,y(e),_(e),i);return this.getINode(t,e,r)}async getINode(t,e,i){let r=await t.get(i);if(!r)throw a.ENOENT(e);return I.Deserialize(r)}async getDirListing(t,e,i){if(!i.isDirectory())throw a.ENOTDIR(e);let r=await t.get(i.id);try{return JSON.parse(U(r))}catch{throw a.ENOENT(e)}}async addNewNode(t,e){let i=0,r=u(async()=>{if(++i===5)throw new a(l.EIO,"Unable to commit data to key-value store.");{let s=Q();return await t.put(s,e,!1)?s:r()}},"reroll");return r()}async commitNewFile(t,e,i,r,s,n){let c=y(e),h=_(e),d=await this.findINode(t,c),f=await this.getDirListing(t,c,d),m=new Date().getTime();if(!d.toStats().hasAccess(2,s))throw a.EACCES(e);if(e==="/")throw a.EEXIST(e);if(f[h])throw await t.abort(),a.EEXIST(e);try{let p=await this.addNewNode(t,n),w=new I(p,n.length,r|i,m,m,m,s.uid,s.gid),S=await this.addNewNode(t,w.serialize());return f[h]=S,await t.put(d.id,E(JSON.stringify(f)),!0),await t.commit(),w}catch(p){throw t.abort(),p}}async removeEntry(t,e,i){this._cache&&this._cache.remove(t);let r=this.store.beginTransaction("readwrite"),s=y(t),n=await this.findINode(r,s),c=await this.getDirListing(r,s,n),h=_(t);if(!c[h])throw a.ENOENT(t);let d=c[h],f=await this.getINode(r,t,d);if(!f.toStats().hasAccess(2,i))throw a.EACCES(t);if(delete c[h],!e&&f.isDirectory())throw a.EISDIR(t);if(e&&!f.isDirectory())throw a.ENOTDIR(t);try{await r.del(f.id),await r.del(d),await r.put(n.id,E(JSON.stringify(c)),!0)}catch(m){throw await r.abort(),m}await r.commit()}};u(ht,"AsyncKeyValueFileSystem");function ut(o,t=o.toString()){switch(o.name){case"NotFoundError":return new a(l.ENOENT,t);case"QuotaExceededError":return new a(l.ENOSPC,t);default:return new a(l.EIO,t)}}u(ut,"convertError");function ft(o,t=l.EIO,e=null){return function(i){i.preventDefault(),o(new a(t,e!==null?e:void 0))}}u(ft,"onErrorHandler");var it=class{constructor(t,e){this.tx=t;this.store=e}get(t){return new Promise((e,i)=>{try{let r=this.store.get(t);r.onerror=ft(i),r.onsuccess=s=>{let n=s.target.result;e(n===void 0?n:Uint8Array.from(n))}}catch(r){i(ut(r))}})}};u(it,"IndexedDBROTransaction");var dt=class extends it{constructor(t,e){super(t,e)}put(t,e,i){return new Promise((r,s)=>{try{let n=i?this.store.put(e,t):this.store.add(e,t);n.onerror=ft(s),n.onsuccess=()=>{r(!0)}}catch(n){s(ut(n))}})}del(t){return new Promise((e,i)=>{try{let r=this.store.delete(t);r.onerror=ft(i),r.onsuccess=()=>{e()}}catch(r){i(ut(r))}})}commit(){return new Promise(t=>{setTimeout(t,0)})}abort(){return new Promise((t,e)=>{try{this.tx.abort(),t()}catch(i){e(ut(i))}})}};u(dt,"IndexedDBRWTransaction");var K=class{constructor(t,e){this.db=t;this.storeName=e}static Create(t,e){return new Promise((i,r)=>{let s=e.open(t,1);s.onupgradeneeded=n=>{let c=n.target.result;c.objectStoreNames.contains(t)&&c.deleteObjectStore(t),c.createObjectStore(t)},s.onsuccess=n=>{i(new K(n.target.result,t))},s.onerror=ft(r,l.EACCES)})}name(){return L.Name+" - "+this.storeName}clear(){return new Promise((t,e)=>{try{let i=this.db.transaction(this.storeName,"readwrite"),r=i.objectStore(this.storeName),s=r.clear();s.onsuccess=()=>{setTimeout(t,0)},s.onerror=ft(e)}catch(i){e(ut(i))}})}beginTransaction(t="readonly"){let e=this.db.transaction(this.storeName,t),i=e.objectStore(this.storeName);if(t==="readwrite")return new dt(e,i);if(t==="readonly")return new it(e,i);throw new a(l.EINVAL,"Invalid transaction type.")}};u(K,"IndexedDBStore");var Bt=class extends ht{static isAvailable(t=globalThis.indexedDB){try{if(!(t instanceof IDBFactory)||!t.open("__zenfs_test__"))return!1}catch{return!1}}constructor({cacheSize:t=100,storeName:e="zenfs",idbFactory:i=globalThis.indexedDB}){super(t),this._ready=K.Create(e,i).then(r=>(this.init(r),this))}},L=Bt;u(L,"IndexedDBFileSystem"),L.Name="IndexedDB",L.Create=T.bind(Bt),L.Options={storeName:{type:"string",optional:!0,description:"The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name."},cacheSize:{type:"number",optional:!0,description:"The size of the inode cache. Defaults to 100. A size of 0 or below disables caching."},idbFactory:{type:"object",optional:!0,description:"The IDBFactory to use. Defaults to globalThis.indexedDB."}};var mt=class{constructor(t){this._storage=t}name(){return B.Name}clear(){this._storage.clear()}beginTransaction(t){return new j(this)}get(t){let e=this._storage.getItem(t);if(typeof e=="string")return E(e)}put(t,e,i){try{return!i&&this._storage.getItem(t)!==null?!1:(this._storage.setItem(t,e.toString()),!0)}catch{throw new a(l.ENOSPC,"Storage is full.")}}del(t){try{this._storage.removeItem(t)}catch(e){throw new a(l.EIO,"Unable to delete key "+t+": "+e)}}};u(mt,"StorageStore");var zt=class extends V{static isAvailable(t=globalThis.localStorage){return t instanceof Storage}constructor({storage:t=globalThis.localStorage}){super({store:new mt(t)})}},B=zt;u(B,"StorageFileSystem"),B.Name="Storage",B.Create=T.bind(zt),B.Options={storage:{type:"object",optional:!0,description:"The Storage to use. Defaults to globalThis.localStorage."}};function ue(o){return typeof o=="object"&&"isBFS"in o&&!!o.isBFS}u(ue,"isRPCMessage");var vt=class extends O{constructor({worker:e}){super();this._currentID=0;this._requests=new Map;this._isInitialized=!1;this._worker=e,this._worker.onmessage=i=>{if(!ue(i.data))return;let{id:r,method:s,value:n}=i.data;if(s==="metadata"){this._metadata=n,this._isInitialized=!0;return}let{resolve:c,reject:h}=this._requests.get(r);if(this._requests.delete(r),n instanceof Error||n instanceof a){h(n);return}c(n)}}static isAvailable(){return typeof importScripts<"u"||typeof Worker<"u"}get metadata(){return{...super.metadata,...this._metadata,name:vt.Name,synchronous:!1}}async _rpc(e,...i){return new Promise((r,s)=>{let n=this._currentID++;this._requests.set(n,{resolve:r,reject:s}),this._worker.postMessage({isBFS:!0,id:n,method:e,args:i})})}rename(e,i,r){return this._rpc("rename",e,i,r)}stat(e,i){return this._rpc("stat",e,i)}open(e,i,r,s){return this._rpc("open",e,i,r,s)}unlink(e,i){return this._rpc("unlink",e,i)}rmdir(e,i){return this._rpc("rmdir",e,i)}mkdir(e,i,r){return this._rpc("mkdir",e,i,r)}readdir(e,i){return this._rpc("readdir",e,i)}exists(e,i){return this._rpc("exists",e,i)}realpath(e,i){return this._rpc("realpath",e,i)}truncate(e,i,r){return this._rpc("truncate",e,i,r)}readFile(e,i,r){return this._rpc("readFile",e,i,r)}writeFile(e,i,r,s,n){return this._rpc("writeFile",e,i,r,s,n)}appendFile(e,i,r,s,n){return this._rpc("appendFile",e,i,r,s,n)}chmod(e,i,r){return this._rpc("chmod",e,i,r)}chown(e,i,r,s){return this._rpc("chown",e,i,r,s)}utimes(e,i,r,s){return this._rpc("utimes",e,i,r,s)}link(e,i,r){return this._rpc("link",e,i,r)}symlink(e,i,r,s){return this._rpc("symlink",e,i,r,s)}readlink(e,i){return this._rpc("readlink",e,i)}syncClose(e,i){return this._rpc("syncClose",e,i)}},J=vt;u(J,"WorkerFS"),J.Name="WorkerFS",J.Create=T.bind(vt),J.Options={worker:{type:"object",description:"The target worker that you want to connect to, or the current worker if in a worker context.",validator(e){if(typeof e?.postMessage!="function")throw new a(l.EINVAL,"option must be a Web Worker instance.")}}};return ne(de);})();
|
|
9
4
|
//# sourceMappingURL=browser.min.js.map
|