@zenfs/dom 0.0.2 → 0.0.4

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