!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.BrowserFS=e():t.BrowserFS=e()}(this,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e,n){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},function(t,e,n){"use strict"; /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */const r=n(5),i=n(6),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;e.kMaxLength=s;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return u(t,e,n)}function u(t,e,n){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|y(t,e);let r=a(n);const i=r.write(t,e);i!==n&&(r=r.slice(0,i));return r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(q(t,Uint8Array)){const e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return p(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer))return l(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return l(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return c.from(r,e,n);const i=function(t){if(c.isBuffer(t)){const e=0|d(t.length),n=a(e);return 0===n.length?n:(t.copy(n,0,0,e),n)}if(void 0!==t.length)return"number"!=typeof t.length||$(t.length)?a(0):p(t);if("Buffer"===t.type&&Array.isArray(t.data))return p(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return c.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return f(t),a(t<0?0:0|d(t))}function p(t){const e=t.length<0?0:0|d(t.length),n=a(e);for(let r=0;r=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function y(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return W(t).length;default:if(i)return r?-1:Y(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function m(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),$(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=c.from(e,r)),c.isBuffer(e))return 0===e.length?-1:w(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):w(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,n,r,i){let o,s=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let r=-1;for(o=n;oa&&(n=a-c),o=n;o>=0;o--){let n=!0;for(let r=0;ri&&(r=i):r=i;const o=e.length;let s;for(r>o/2&&(r=o/2),s=0;s>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function I(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function k(t,e,n){n=Math.min(t.length,n);const r=[];let i=e;for(;i239?4:e>223?3:e>191?2:1;if(i+s<=n){let n,r,a,c;switch(s){case 1:e<128&&(o=e);break;case 2:128==(192&(n=t[i+1]))&&(c=(31&e)<<6|63&n)>127&&(o=c);break;case 3:n=t[i+1],r=t[i+2],128==(192&n)&&128==(192&r)&&(c=(15&e)<<12|(63&n)<<6|63&r)>2047&&(c<55296||c>57343)&&(o=c);break;case 4:n=t[i+1],r=t[i+2],a=t[i+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(c=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&a)>65535&&c<1114112&&(o=c)}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return function(t){const e=t.length;if(e<=O)return String.fromCharCode.apply(String,t);let n="",r=0;for(;rr.length?(c.isBuffer(e)||(e=c.from(e.buffer,e.byteOffset,e.byteLength)),e.copy(r,i)):Uint8Array.prototype.set.call(r,e,i);else{if(!c.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,i)}i+=e.length}return r},c.byteLength=y,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;ethis.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return T(this,e,n);case"utf8":case"utf-8":return k(this,e,n);case"ascii":return N(this,e,n);case"latin1":case"binary":return F(this,e,n);case"base64":return I(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){let t="";const n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),""},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(t,e,n,r,i){if(q(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,i>>>=0,this===t)return 0;let o=i-r,s=n-e;const a=Math.min(o,s),u=this.slice(r,i),f=t.slice(e,n);for(let t=0;t>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let o=!1;for(;;)switch(r){case"hex":return _(this,t,e,n);case"utf8":case"utf-8":return E(this,t,e,n);case"ascii":case"latin1":case"binary":return v(this,t,e,n);case"base64":return S(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const O=4096;function N(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;ir)&&(n=r);let i="";for(let r=e;rn)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,n,r,i,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function R(t,e,n,r,i){j(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function A(t,e,n,r,i){j(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function U(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function P(t,e,n,r,o){return e=+e,n>>>=0,o||U(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function B(t,e,n,r,o){return e=+e,n>>>=0,o||U(t,0,n,8),i.write(t,e,n,r,52,8),n+8}c.prototype.slice=function(t,e){const n=this.length;t=~~t,e=void 0===e?n:~~e,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),e<0?(e+=n)<0&&(e=0):e>n&&(e=n),e>>=0,e>>>=0,n||x(t,e,this.length);let r=this[t],i=1,o=0;for(;++o>>=0,e>>>=0,n||x(t,e,this.length);let r=this[t+--e],i=1;for(;e>0&&(i*=256);)r+=this[t+--e]*i;return r},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=G(function(t){H(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||Z(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(i)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||Z(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<>>=0,e>>>=0,n||x(t,e,this.length);let r=this[t],i=1,o=0;for(;++o=(i*=128)&&(r-=Math.pow(2,8*e)),r},c.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||x(t,e,this.length);let r=e,i=1,o=this[t+--r];for(;r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||x(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(t,e){t>>>=0,e||x(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=G(function(t){H(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||Z(t,this.length-8);const r=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(r)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||Z(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<>>=0,e||x(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||x(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||x(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||x(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,e,n,r){if(t=+t,e>>>=0,n>>>=0,!r){D(this,t,e,n,Math.pow(2,8*n)-1,0)}let i=1,o=0;for(this[e]=255&t;++o>>=0,n>>>=0,!r){D(this,t,e,n,Math.pow(2,8*n)-1,0)}let i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigUInt64LE=G(function(t,e=0){return R(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=G(function(t,e=0){return A(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);D(this,t,e,n,r-1,-r)}let i=0,o=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+n},c.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);D(this,t,e,n,r-1,-r)}let i=n-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},c.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigInt64LE=G(function(t,e=0){return R(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=G(function(t,e=0){return A(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeFloatLE=function(t,e,n){return P(this,t,e,!0,n)},c.prototype.writeFloatBE=function(t,e,n){return P(this,t,e,!1,n)},c.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},c.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},c.prototype.copy=function(t,e,n,r){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function j(t,e,n,r,i,o){if(t>n||t3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** `+`${8*(o+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new C.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){H(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||Z(e,t.length-(n+1))}(r,i,o)}function H(t,e){if("number"!=typeof t)throw new C.ERR_INVALID_ARG_TYPE(e,"number",t)}function Z(t,e,n){if(Math.floor(t)!==t)throw H(t,n),new C.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new C.ERR_BUFFER_OUT_OF_BOUNDS;throw new C.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}M("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),M("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),M("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=z(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=z(i)),i+="n"),r+=` It must be ${e}. Received ${i}`},RangeError);const V=/[^+/0-9A-Za-z-_]/g;function Y(t,e){let n;e=e||1/0;const r=t.length;let i=null;const o=[];for(let s=0;s55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function W(t){return r.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(t,e,n,r){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function $(t){return t!=t}const J=function(){const t=new Array(256);for(let e=0;e<16;++e){const n=16*e;for(let r=0;r<16;++r)t[n+r]="0123456789abcdef"[e]+"0123456789abcdef"[r]}return t}(),K={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};function G(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(t){r=s}}();var c,u=[],f=!1,h=-1;function p(){f&&c&&(f=!1,c.length?u=c.concat(u):h=-1,u.length&&l())}function l(){if(!f){var t=a(p);f=!0;for(var e=u.length;e;){for(c=u,u=[];++h1)for(var n=1;n0))return S.shift()()};v.addEventListener?v.addEventListener("message",b,!0):v.attachEvent("onmessage",b)}else if(v.MessageChannel){var I=new v.MessageChannel;I.port1.onmessage=function(t){if(S.length>0)return S.shift()()},_=function(t){S.push(t),I.port2.postMessage("")}}else _=function(t){return setTimeout(t,0)}}var k=_,O=function(t,e){return t};function N(t,e){if("function"!=typeof t)throw new Error("Callback must be a function.");var n=O(t,e);switch(e){case 1:return function(t){k(function(){return n(t)})};case 2:return function(t,e){k(function(){return n(t,e)})};case 3:return function(t,e,r){k(function(){return n(t,e,r)})};default:throw new Error("Invalid invocation of wrapCb.")}}function F(t){if(t)return t;throw new l(c.EIO,"Initialize BrowserFS with a file system using BrowserFS.initialize(filesystem)")}function T(t,e){switch(typeof t){case"number":return t;case"string":var n=parseInt(t,8);return isNaN(n)?e:n;default:return e}}function L(t){if(t instanceof Date)return t;if("number"==typeof t)return new Date(1e3*t);throw new l(c.EINVAL,"Invalid time.")}function x(t){if(t.indexOf("\0")>=0)throw new l(c.EINVAL,"Path must be a string without null bytes.");if(""===t)throw new l(c.EINVAL,"Path must not be empty.");return f.resolve(t)}function D(t,e,n,r){switch(null===t?"null":typeof t){case"object":return{encoding:void 0!==t.encoding?t.encoding:e,flag:void 0!==t.flag?t.flag:n,mode:T(t.mode,r)};case"string":return{encoding:t,flag:n,mode:r};case"null":case"undefined":case"function":return{encoding:e,flag:n,mode:r};default:throw new TypeError('"options" must be a string or an object, got '+typeof t+" instead.")}}function R(){}var A=function(){this.F_OK=0,this.R_OK=4,this.W_OK=2,this.X_OK=1,this.root=null,this.fdMap={},this.nextFd=100};A.prototype.initialize=function(t){if(!t.constructor.isAvailable())throw new l(c.EINVAL,"Tried to instantiate BrowserFS with an unavailable file system.");return this.root=t},A.prototype._toUnixTimestamp=function(t){if("number"==typeof t)return t;if(t instanceof Date)return t.getTime()/1e3;throw new Error("Cannot parse time: "+t)},A.prototype.getRootFS=function(){return this.root?this.root:null},A.prototype.rename=function(t,e,n){void 0===n&&(n=R);var r=N(n,1);try{F(this.root).rename(x(t),x(e),r)}catch(t){r(t)}},A.prototype.renameSync=function(t,e){F(this.root).renameSync(x(t),x(e))},A.prototype.exists=function(t,e){void 0===e&&(e=R);var n=N(e,1);try{return F(this.root).exists(x(t),n)}catch(t){return n(!1)}},A.prototype.existsSync=function(t){try{return F(this.root).existsSync(x(t))}catch(t){return!1}},A.prototype.stat=function(t,e){void 0===e&&(e=R);var n=N(e,2);try{return F(this.root).stat(x(t),!1,n)}catch(t){return n(t)}},A.prototype.statSync=function(t){return F(this.root).statSync(x(t),!1)},A.prototype.lstat=function(t,e){void 0===e&&(e=R);var n=N(e,2);try{return F(this.root).stat(x(t),!0,n)}catch(t){return n(t)}},A.prototype.lstatSync=function(t){return F(this.root).statSync(x(t),!0)},A.prototype.truncate=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=R);var r=0;"function"==typeof e?n=e:"number"==typeof e&&(r=e);var i=N(n,1);try{if(r<0)throw new l(c.EINVAL);return F(this.root).truncate(x(t),r,i)}catch(t){return i(t)}},A.prototype.truncateSync=function(t,e){if(void 0===e&&(e=0),e<0)throw new l(c.EINVAL);return F(this.root).truncateSync(x(t),e)},A.prototype.unlink=function(t,e){void 0===e&&(e=R);var n=N(e,1);try{return F(this.root).unlink(x(t),n)}catch(t){return n(t)}},A.prototype.unlinkSync=function(t){return F(this.root).unlinkSync(x(t))},A.prototype.open=function(t,e,n,r){var i=this;void 0===r&&(r=R);var o=T(n,420),s=N(r="function"==typeof n?n:r,2);try{F(this.root).open(x(t),g.getFileFlag(e),o,function(t,e){e?s(t,i.getFdForFile(e)):s(t)})}catch(t){s(t)}},A.prototype.openSync=function(t,e,n){return void 0===n&&(n=420),this.getFdForFile(F(this.root).openSync(x(t),g.getFileFlag(e),T(n,420)))},A.prototype.readFile=function(t,e,n){void 0===e&&(e={}),void 0===n&&(n=R);var r=D(e,null,"r",null),i=N(n="function"==typeof e?e:n,2);try{var o=g.getFileFlag(r.flag);return o.isReadable()?F(this.root).readFile(x(t),r.encoding,o,i):i(new l(c.EINVAL,"Flag passed to readFile must allow for reading."))}catch(t){return i(t)}},A.prototype.readFileSync=function(t,e){void 0===e&&(e={});var n=D(e,null,"r",null),r=g.getFileFlag(n.flag);if(!r.isReadable())throw new l(c.EINVAL,"Flag passed to readFile must allow for reading.");return F(this.root).readFileSync(x(t),n.encoding,r)},A.prototype.writeFile=function(t,e,n,r){void 0===n&&(n={}),void 0===r&&(r=R);var i=D(n,"utf8","w",420),o=N(r="function"==typeof n?n:r,1);try{var s=g.getFileFlag(i.flag);return s.isWriteable()?F(this.root).writeFile(x(t),e,i.encoding,s,i.mode,o):o(new l(c.EINVAL,"Flag passed to writeFile must allow for writing."))}catch(t){return o(t)}},A.prototype.writeFileSync=function(t,e,n){var r=D(n,"utf8","w",420),i=g.getFileFlag(r.flag);if(!i.isWriteable())throw new l(c.EINVAL,"Flag passed to writeFile must allow for writing.");return F(this.root).writeFileSync(x(t),e,r.encoding,i,r.mode)},A.prototype.appendFile=function(t,e,n,r){void 0===r&&(r=R);var i=D(n,"utf8","a",420),o=N(r="function"==typeof n?n:r,1);try{var s=g.getFileFlag(i.flag);if(!s.isAppendable())return o(new l(c.EINVAL,"Flag passed to appendFile must allow for appending."));F(this.root).appendFile(x(t),e,i.encoding,s,i.mode,o)}catch(t){o(t)}},A.prototype.appendFileSync=function(t,e,n){var r=D(n,"utf8","a",420),i=g.getFileFlag(r.flag);if(!i.isAppendable())throw new l(c.EINVAL,"Flag passed to appendFile must allow for appending.");return F(this.root).appendFileSync(x(t),e,r.encoding,i,r.mode)},A.prototype.fstat=function(t,e){void 0===e&&(e=R);var n=N(e,2);try{this.fd2file(t).stat(n)}catch(t){n(t)}},A.prototype.fstatSync=function(t){return this.fd2file(t).statSync()},A.prototype.close=function(t,e){var n=this;void 0===e&&(e=R);var r=N(e,1);try{this.fd2file(t).close(function(e){e||n.closeFd(t),r(e)})}catch(t){r(t)}},A.prototype.closeSync=function(t){this.fd2file(t).closeSync(),this.closeFd(t)},A.prototype.ftruncate=function(t,e,n){void 0===n&&(n=R);var r="number"==typeof e?e:0,i=N(n="function"==typeof e?e:n,1);try{var o=this.fd2file(t);if(r<0)throw new l(c.EINVAL);o.truncate(r,i)}catch(t){i(t)}},A.prototype.ftruncateSync=function(t,e){void 0===e&&(e=0);var n=this.fd2file(t);if(e<0)throw new l(c.EINVAL);n.truncateSync(e)},A.prototype.fsync=function(t,e){void 0===e&&(e=R);var n=N(e,1);try{this.fd2file(t).sync(n)}catch(t){n(t)}},A.prototype.fsyncSync=function(t){this.fd2file(t).syncSync()},A.prototype.fdatasync=function(t,e){void 0===e&&(e=R);var n=N(e,1);try{this.fd2file(t).datasync(n)}catch(t){n(t)}},A.prototype.fdatasyncSync=function(t){this.fd2file(t).datasyncSync()},A.prototype.write=function(e,n,r,i,o,s){void 0===s&&(s=R);var a,u,f,h=null;if("string"==typeof n){var p="utf8";switch(typeof r){case"function":s=r;break;case"number":h=r,p="string"==typeof i?i:"utf8",s="function"==typeof o?o:s;break;default:return(s="function"==typeof i?i:"function"==typeof o?o:s)(new l(c.EINVAL,"Invalid arguments."))}u=0,f=(a=t.from(n,p)).length}else a=n,u=r,f=i,h="number"==typeof o?o:null,s="function"==typeof o?o:s;var d=N(s,3);try{var y=this.fd2file(e);void 0!==h&&null!==h||(h=y.getPos()),y.write(a,u,f,h,d)}catch(t){d(t)}},A.prototype.writeSync=function(e,n,r,i,o){var s,a,c,u=0;if("string"==typeof n){c="number"==typeof r?r:null;var f="string"==typeof i?i:"utf8";u=0,a=(s=t.from(n,f)).length}else s=n,u=r,a=i,c="number"==typeof o?o:null;var h=this.fd2file(e);return void 0!==c&&null!==c||(c=h.getPos()),h.writeSync(s,u,a,c)},A.prototype.read=function(e,n,r,i,o,s){var a,c,u,f,h;if(void 0===s&&(s=R),"number"==typeof n){u=n,a=r;var p=i;s="function"==typeof o?o:s,c=0,f=t.alloc(u),h=N(function(t,e,n){if(t)return s(t);s(t,n.toString(p),e)},3)}else f=n,c=r,u=i,a=o,h=N(s,3);try{var l=this.fd2file(e);void 0!==a&&null!==a||(a=l.getPos()),l.read(f,c,u,a,h)}catch(t){h(t)}},A.prototype.readSync=function(e,n,r,i,o){var s,a,c,u,f=!1,h="utf8";"number"==typeof n?(c=n,u=r,h=i,a=0,s=t.alloc(c),f=!0):(s=n,a=r,c=i,u=o);var p=this.fd2file(e);void 0!==u&&null!==u||(u=p.getPos());var l=p.readSync(s,a,c,u);return f?[s.toString(h),l]:l},A.prototype.fchown=function(t,e,n,r){void 0===r&&(r=R);var i=N(r,1);try{this.fd2file(t).chown(e,n,i)}catch(t){i(t)}},A.prototype.fchownSync=function(t,e,n){this.fd2file(t).chownSync(e,n)},A.prototype.fchmod=function(t,e,n){var r=N(n,1);try{var i="string"==typeof e?parseInt(e,8):e;this.fd2file(t).chmod(i,r)}catch(t){r(t)}},A.prototype.fchmodSync=function(t,e){var n="string"==typeof e?parseInt(e,8):e;this.fd2file(t).chmodSync(n)},A.prototype.futimes=function(t,e,n,r){void 0===r&&(r=R);var i=N(r,1);try{var o=this.fd2file(t);"number"==typeof e&&(e=new Date(1e3*e)),"number"==typeof n&&(n=new Date(1e3*n)),o.utimes(e,n,i)}catch(t){i(t)}},A.prototype.futimesSync=function(t,e,n){this.fd2file(t).utimesSync(L(e),L(n))},A.prototype.rmdir=function(t,e){void 0===e&&(e=R);var n=N(e,1);try{t=x(t),F(this.root).rmdir(t,n)}catch(t){n(t)}},A.prototype.rmdirSync=function(t){return t=x(t),F(this.root).rmdirSync(t)},A.prototype.mkdir=function(t,e,n){void 0===n&&(n=R),"function"==typeof e&&(n=e,e=511);var r=N(n,1);try{t=x(t),F(this.root).mkdir(t,e,r)}catch(t){r(t)}},A.prototype.mkdirSync=function(t,e){F(this.root).mkdirSync(x(t),T(e,511))},A.prototype.readdir=function(t,e){void 0===e&&(e=R);var n=N(e,2);try{t=x(t),F(this.root).readdir(t,n)}catch(t){n(t)}},A.prototype.readdirSync=function(t){return t=x(t),F(this.root).readdirSync(t)},A.prototype.link=function(t,e,n){void 0===n&&(n=R);var r=N(n,1);try{t=x(t),e=x(e),F(this.root).link(t,e,r)}catch(t){r(t)}},A.prototype.linkSync=function(t,e){return t=x(t),e=x(e),F(this.root).linkSync(t,e)},A.prototype.symlink=function(t,e,n,r){void 0===r&&(r=R);var i="string"==typeof n?n:"file",o=N(r="function"==typeof n?n:r,1);try{if("file"!==i&&"dir"!==i)return o(new l(c.EINVAL,"Invalid type: "+i));t=x(t),e=x(e),F(this.root).symlink(t,e,i,o)}catch(t){o(t)}},A.prototype.symlinkSync=function(t,e,n){if(n){if("file"!==n&&"dir"!==n)throw new l(c.EINVAL,"Invalid type: "+n)}else n="file";return t=x(t),e=x(e),F(this.root).symlinkSync(t,e,n)},A.prototype.readlink=function(t,e){void 0===e&&(e=R);var n=N(e,2);try{t=x(t),F(this.root).readlink(t,n)}catch(t){n(t)}},A.prototype.readlinkSync=function(t){return t=x(t),F(this.root).readlinkSync(t)},A.prototype.chown=function(t,e,n,r){void 0===r&&(r=R);var i=N(r,1);try{t=x(t),F(this.root).chown(t,!1,e,n,i)}catch(t){i(t)}},A.prototype.chownSync=function(t,e,n){t=x(t),F(this.root).chownSync(t,!1,e,n)},A.prototype.lchown=function(t,e,n,r){void 0===r&&(r=R);var i=N(r,1);try{t=x(t),F(this.root).chown(t,!0,e,n,i)}catch(t){i(t)}},A.prototype.lchownSync=function(t,e,n){t=x(t),F(this.root).chownSync(t,!0,e,n)},A.prototype.chmod=function(t,e,n){void 0===n&&(n=R);var r=N(n,1);try{var i=T(e,-1);if(i<0)throw new l(c.EINVAL,"Invalid mode.");F(this.root).chmod(x(t),!1,i,r)}catch(t){r(t)}},A.prototype.chmodSync=function(t,e){var n=T(e,-1);if(n<0)throw new l(c.EINVAL,"Invalid mode.");t=x(t),F(this.root).chmodSync(t,!1,n)},A.prototype.lchmod=function(t,e,n){void 0===n&&(n=R);var r=N(n,1);try{var i=T(e,-1);if(i<0)throw new l(c.EINVAL,"Invalid mode.");F(this.root).chmod(x(t),!0,i,r)}catch(t){r(t)}},A.prototype.lchmodSync=function(t,e){var n=T(e,-1);if(n<1)throw new l(c.EINVAL,"Invalid mode.");F(this.root).chmodSync(x(t),!0,n)},A.prototype.utimes=function(t,e,n,r){void 0===r&&(r=R);var i=N(r,1);try{F(this.root).utimes(x(t),L(e),L(n),i)}catch(t){i(t)}},A.prototype.utimesSync=function(t,e,n){F(this.root).utimesSync(x(t),L(e),L(n))},A.prototype.realpath=function(t,e,n){void 0===n&&(n=R);var r="object"==typeof e?e:{},i=N(n="function"==typeof e?e:R,2);try{t=x(t),F(this.root).realpath(t,r,i)}catch(t){i(t)}},A.prototype.realpathSync=function(t,e){return void 0===e&&(e={}),t=x(t),F(this.root).realpathSync(t,e)},A.prototype.watchFile=function(t,e,n){throw new l(c.ENOTSUP)},A.prototype.unwatchFile=function(t,e){throw new l(c.ENOTSUP)},A.prototype.watch=function(t,e,n){throw new l(c.ENOTSUP)},A.prototype.access=function(t,e,n){throw new l(c.ENOTSUP)},A.prototype.accessSync=function(t,e){throw new l(c.ENOTSUP)},A.prototype.createReadStream=function(t,e){throw new l(c.ENOTSUP)},A.prototype.createWriteStream=function(t,e){throw new l(c.ENOTSUP)},A.prototype.wrapCallbacks=function(t){O=t},A.prototype.getFdForFile=function(t){var e=this.nextFd++;return this.fdMap[e]=t,e},A.prototype.fd2file=function(t){var e=this.fdMap[t];if(e)return e;throw new l(c.EBADF,"Invalid file descriptor.")},A.prototype.closeFd=function(t){delete this.fdMap[t]},A.Stats=m;var U=new A,P={},B=A.prototype;function C(){throw new Error("BFS has reached an impossible code path; please file a bug.")}function M(t,e,n){n.existsSync(t)||(M(f.dirname(t),e,n),n.mkdirSync(t,e))}function z(t){var e=j(t),n=e.byteOffset,r=e.byteLength;return 0===n&&r===e.buffer.byteLength?e.buffer:e.buffer.slice(n,n+r)}function j(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function H(e){return e instanceof t?e:e instanceof Uint8Array?Z(e):t.from(e)}function Z(e){return e instanceof t?e:0===e.byteOffset&&e.byteLength===e.buffer.byteLength?V(e.buffer):t.from(e.buffer,e.byteOffset,e.byteLength)}function V(e){return t.from(e)}function Y(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=t.length),e<0||n<0||n>t.length||e>n)throw new TypeError("Invalid slice bounds on buffer of length "+t.length+": ["+e+", "+n+"]");if(0===t.length)return X();var r=j(t),i=t[0],o=(i+1)%255;return t[0]=o,r[0]===o?(r[0]=i,Z(r.slice(e,n))):(t[0]=i,Z(r.subarray(e,n)))}Object.keys(B).forEach(function(t){"function"==typeof U[t]?P[t]=function(){return U[t].apply(U,arguments)}:P[t]=U[t]}),P.changeFSModule=function(t){U=t},P.getFSModule=function(){return U},P.FS=A,P.Stats=A.Stats;var W=null;function X(){return W||(W=t.alloc(0))}function q(e,n){t.isBuffer(e)?n():n(new l(c.EINVAL,"option must be a Buffer."))}var $=Object.freeze({__proto__:null,arrayBuffer2Buffer:V,arrayish2Buffer:H,buffer2ArrayBuffer:z,buffer2Uint8array:j,bufferValidator:q,copyingSlice:Y,deprecationMessage:function(t,e,n){t&&console.warn("["+e+"] Direct file system constructor usage is deprecated for this file system, and will be removed in the next major version. Please use the '"+e+".Create("+JSON.stringify(n)+", callback)' method instead. See https://github.com/jvilk/BrowserFS/issues/176 for more details.")},emptyBuffer:X,fail:C,mkdirpSync:M,uint8Array2Buffer:Z}),J=function(){};J.prototype.supportsLinks=function(){return!1},J.prototype.diskSpace=function(t,e){e(0,0)},J.prototype.openFile=function(t,e,n){throw new l(c.ENOTSUP)},J.prototype.createFile=function(t,e,n,r){throw new l(c.ENOTSUP)},J.prototype.open=function(t,e,n,r){var i=this;this.stat(t,!1,function(o,s){if(o)switch(e.pathNotExistsAction()){case p.CREATE_FILE:return i.stat(f.dirname(t),!1,function(o,s){o?r(o):s&&!s.isDirectory()?r(l.ENOTDIR(f.dirname(t))):i.createFile(t,e,n,r)});case p.THROW_EXCEPTION:return r(l.ENOENT(t));default:return r(new l(c.EINVAL,"Invalid FileFlag object."))}else{if(s&&s.isDirectory())return r(l.EISDIR(t));switch(e.pathExistsAction()){case p.THROW_EXCEPTION:return r(l.EEXIST(t));case p.TRUNCATE_FILE:return i.openFile(t,e,function(t,e){t?r(t):e?e.truncate(0,function(){e.sync(function(){r(null,e)})}):C()});case p.NOP:return i.openFile(t,e,r);default:return r(new l(c.EINVAL,"Invalid FileFlag object."))}}})},J.prototype.rename=function(t,e,n){n(new l(c.ENOTSUP))},J.prototype.renameSync=function(t,e){throw new l(c.ENOTSUP)},J.prototype.stat=function(t,e,n){n(new l(c.ENOTSUP))},J.prototype.statSync=function(t,e){throw new l(c.ENOTSUP)},J.prototype.openFileSync=function(t,e,n){throw new l(c.ENOTSUP)},J.prototype.createFileSync=function(t,e,n){throw new l(c.ENOTSUP)},J.prototype.openSync=function(t,e,n){var r;try{r=this.statSync(t,!1)}catch(r){switch(e.pathNotExistsAction()){case p.CREATE_FILE:if(!this.statSync(f.dirname(t),!1).isDirectory())throw l.ENOTDIR(f.dirname(t));return this.createFileSync(t,e,n);case p.THROW_EXCEPTION:throw l.ENOENT(t);default:throw new l(c.EINVAL,"Invalid FileFlag object.")}}if(r.isDirectory())throw l.EISDIR(t);switch(e.pathExistsAction()){case p.THROW_EXCEPTION:throw l.EEXIST(t);case p.TRUNCATE_FILE:return this.unlinkSync(t),this.createFileSync(t,e,r.mode);case p.NOP:return this.openFileSync(t,e,n);default:throw new l(c.EINVAL,"Invalid FileFlag object.")}},J.prototype.unlink=function(t,e){e(new l(c.ENOTSUP))},J.prototype.unlinkSync=function(t){throw new l(c.ENOTSUP)},J.prototype.rmdir=function(t,e){e(new l(c.ENOTSUP))},J.prototype.rmdirSync=function(t){throw new l(c.ENOTSUP)},J.prototype.mkdir=function(t,e,n){n(new l(c.ENOTSUP))},J.prototype.mkdirSync=function(t,e){throw new l(c.ENOTSUP)},J.prototype.readdir=function(t,e){e(new l(c.ENOTSUP))},J.prototype.readdirSync=function(t){throw new l(c.ENOTSUP)},J.prototype.exists=function(t,e){this.stat(t,null,function(t){e(!t)})},J.prototype.existsSync=function(t){try{return this.statSync(t,!0),!0}catch(t){return!1}},J.prototype.realpath=function(t,e,n){if(this.supportsLinks())for(var r=t.split(f.sep),i=0;i0?"/"+i.join("/"):e)}G.prototype.sync=function(t){t(new l(c.ENOTSUP))},G.prototype.syncSync=function(){throw new l(c.ENOTSUP)},G.prototype.datasync=function(t){this.sync(t)},G.prototype.datasyncSync=function(){return this.syncSync()},G.prototype.chown=function(t,e,n){n(new l(c.ENOTSUP))},G.prototype.chownSync=function(t,e){throw new l(c.ENOTSUP)},G.prototype.chmod=function(t,e){e(new l(c.ENOTSUP))},G.prototype.chmodSync=function(t){throw new l(c.ENOTSUP)},G.prototype.utimes=function(t,e,n){n(new l(c.ENOTSUP))},G.prototype.utimesSync=function(t,e){throw new l(c.ENOTSUP)};var tt=function(t){function e(e,n,r,i){t.call(this),this._fs=e,this._FS=n,this._path=r,this._stream=i}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getPos=function(){},e.prototype.close=function(t){var e=null;try{this.closeSync()}catch(t){e=t}finally{t(e)}},e.prototype.closeSync=function(){try{this._FS.close(this._stream)}catch(t){throw Q(t,this._path)}},e.prototype.stat=function(t){try{t(null,this.statSync())}catch(e){t(e)}},e.prototype.statSync=function(){try{return this._fs.statSync(this._path,!1)}catch(t){throw Q(t,this._path)}},e.prototype.truncate=function(t,e){var n=null;try{this.truncateSync(t)}catch(t){n=t}finally{e(n)}},e.prototype.truncateSync=function(t){try{this._FS.ftruncate(this._stream.fd,t)}catch(t){throw Q(t,this._path)}},e.prototype.write=function(t,e,n,r,i){try{i(null,this.writeSync(t,e,n,r),t)}catch(t){i(t)}},e.prototype.writeSync=function(t,e,n,r){try{var i=j(t),o=null===r?void 0:r;return this._FS.write(this._stream,i,e,n,o)}catch(t){throw Q(t,this._path)}},e.prototype.read=function(t,e,n,r,i){try{i(null,this.readSync(t,e,n,r),t)}catch(t){i(t)}},e.prototype.readSync=function(t,e,n,r){try{var i=j(t),o=null===r?void 0:r;return this._FS.read(this._stream,i,e,n,o)}catch(t){throw Q(t,this._path)}},e.prototype.sync=function(t){t()},e.prototype.syncSync=function(){},e.prototype.chown=function(t,e,n){var r=null;try{this.chownSync(t,e)}catch(t){r=t}finally{n(r)}},e.prototype.chownSync=function(t,e){try{this._FS.fchown(this._stream.fd,t,e)}catch(t){throw Q(t,this._path)}},e.prototype.chmod=function(t,e){var n=null;try{this.chmodSync(t)}catch(t){n=t}finally{e(n)}},e.prototype.chmodSync=function(t){try{this._FS.fchmod(this._stream.fd,t)}catch(t){throw Q(t,this._path)}},e.prototype.utimes=function(t,e,n){var r=null;try{this.utimesSync(t,e)}catch(t){r=t}finally{n(r)}},e.prototype.utimesSync=function(t,e){this._fs.utimesSync(this._path,t,e)},e}(G),et=function(e){function n(t){e.call(this),this._FS=t}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.Create=function(t,e){e(null,new n(t.FS))},n.isAvailable=function(){return!0},n.prototype.getName=function(){return this._FS.DB_NAME()},n.prototype.isReadOnly=function(){return!1},n.prototype.supportsLinks=function(){return!0},n.prototype.supportsProps=function(){return!0},n.prototype.supportsSynch=function(){return!0},n.prototype.renameSync=function(t,e){try{this._FS.rename(t,e)}catch(n){throw n.errno===c.ENOENT?Q(n,this.existsSync(t)?e:t):Q(n)}},n.prototype.statSync=function(t,e){try{var n=e?this._FS.lstat(t):this._FS.stat(t),r=this.modeToFileType(n.mode);return new m(r,n.size,n.mode,n.atime.getTime(),n.mtime.getTime(),n.ctime.getTime())}catch(e){throw Q(e,t)}},n.prototype.openSync=function(t,e,n){try{var r=this._FS.open(t,e.getFlagString(),n);if(this._FS.isDir(r.node.mode))throw this._FS.close(r),l.EISDIR(t);return new tt(this,this._FS,t,r)}catch(e){throw Q(e,t)}},n.prototype.unlinkSync=function(t){try{this._FS.unlink(t)}catch(e){throw Q(e,t)}},n.prototype.rmdirSync=function(t){try{this._FS.rmdir(t)}catch(e){throw Q(e,t)}},n.prototype.mkdirSync=function(t,e){try{this._FS.mkdir(t,e)}catch(e){throw Q(e,t)}},n.prototype.readdirSync=function(t){try{return this._FS.readdir(t).filter(function(t){return"."!==t&&".."!==t})}catch(e){throw Q(e,t)}},n.prototype.truncateSync=function(t,e){try{this._FS.truncate(t,e)}catch(e){throw Q(e,t)}},n.prototype.readFileSync=function(t,e,n){try{var r=Z(this._FS.readFile(t,{flags:n.getFlagString()}));return e?r.toString(e):r}catch(e){throw Q(e,t)}},n.prototype.writeFileSync=function(e,n,r,i,o){try{r&&(n=t.from(n,r));var s=j(n);this._FS.writeFile(e,s,{flags:i.getFlagString(),encoding:"binary"}),this._FS.chmod(e,o)}catch(t){throw Q(t,e)}},n.prototype.chmodSync=function(t,e,n){try{e?this._FS.lchmod(t,n):this._FS.chmod(t,n)}catch(e){throw Q(e,t)}},n.prototype.chownSync=function(t,e,n,r){try{e?this._FS.lchown(t,n,r):this._FS.chown(t,n,r)}catch(e){throw Q(e,t)}},n.prototype.symlinkSync=function(t,e,n){try{this._FS.symlink(t,e)}catch(t){throw Q(t)}},n.prototype.readlinkSync=function(t){try{return this._FS.readlink(t)}catch(e){throw Q(e,t)}},n.prototype.utimesSync=function(t,e,n){try{this._FS.utime(t,e.getTime(),n.getTime())}catch(e){throw Q(e,t)}},n.prototype.modeToFileType=function(t){if(this._FS.isDir(t))return y.DIRECTORY;if(this._FS.isFile(t))return y.FILE;if(this._FS.isLink(t))return y.SYMLINK;throw l.EPERM("Invalid mode: "+t)},n}(K);et.Name="EmscriptenFileSystem",et.Options={FS:{type:"object",description:"The Emscripten file system to use (the `FS` variable)"}};var nt=function(e){function n(t,n,r,i,o){if(e.call(this),this._pos=0,this._dirty=!1,this._fs=t,this._path=n,this._flag=r,this._stat=i,this._buffer=o||X(),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.")}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.getBuffer=function(){return this._buffer},n.prototype.getStats=function(){return this._stat},n.prototype.getFlag=function(){return this._flag},n.prototype.getPath=function(){return this._path},n.prototype.getPos=function(){return this._flag.isAppendable()?this._stat.size:this._pos},n.prototype.advancePos=function(t){return this._pos+=t},n.prototype.setPos=function(t){return this._pos=t},n.prototype.sync=function(t){try{this.syncSync(),t()}catch(e){t(e)}},n.prototype.syncSync=function(){throw new l(c.ENOTSUP)},n.prototype.close=function(t){try{this.closeSync(),t()}catch(e){t(e)}},n.prototype.closeSync=function(){throw new l(c.ENOTSUP)},n.prototype.stat=function(t){try{t(null,m.clone(this._stat))}catch(e){t(e)}},n.prototype.statSync=function(){return m.clone(this._stat)},n.prototype.truncate=function(t,e){try{this.truncateSync(t),this._flag.isSynchronous()&&!P.getRootFS().supportsSynch()&&this.sync(e),e()}catch(t){return e(t)}},n.prototype.truncateSync=function(e){if(this._dirty=!0,!this._flag.isWriteable())throw new l(c.EPERM,"File not opened with a writeable mode.");if(this._stat.mtimeMs=Date.now(),e>this._buffer.length){var n=t.alloc(e-this._buffer.length,0);return this.writeSync(n,0,n.length,this._buffer.length),void(this._flag.isSynchronous()&&P.getRootFS().supportsSynch()&&this.syncSync())}this._stat.size=e;var r=t.alloc(e);this._buffer.copy(r,0,0,e),this._buffer=r,this._flag.isSynchronous()&&P.getRootFS().supportsSynch()&&this.syncSync()},n.prototype.write=function(t,e,n,r,i){try{i(null,this.writeSync(t,e,n,r),t)}catch(t){i(t)}},n.prototype.writeSync=function(e,n,r,i){if(this._dirty=!0,void 0!==i&&null!==i||(i=this.getPos()),!this._flag.isWriteable())throw new l(c.EPERM,"File not opened with a writeable mode.");var o=i+r;if(o>this._stat.size&&(this._stat.size=o,o>this._buffer.length)){var s=t.alloc(o);this._buffer.copy(s),this._buffer=s}var a=e.copy(this._buffer,i,n,n+r);return this._stat.mtimeMs=Date.now(),this._flag.isSynchronous()?(this.syncSync(),a):(this.setPos(i+a),a)},n.prototype.read=function(t,e,n,r,i){try{i(null,this.readSync(t,e,n,r),t)}catch(t){i(t)}},n.prototype.readSync=function(t,e,n,r){if(!this._flag.isReadable())throw new l(c.EPERM,"File not opened with a readable mode.");void 0!==r&&null!==r||(r=this.getPos()),r+n>this._stat.size&&(n=this._stat.size-r);var i=this._buffer.copy(t,e,r,r+n);return this._stat.atimeMs=Date.now(),this._pos=r+n,i},n.prototype.chmod=function(t,e){try{this.chmodSync(t),e()}catch(t){e(t)}},n.prototype.chmodSync=function(t){if(!this._fs.supportsProps())throw new l(c.ENOTSUP);this._dirty=!0,this._stat.chmod(t),this.syncSync()},n.prototype.isDirty=function(){return this._dirty},n.prototype.resetDirty=function(){this._dirty=!1},n}(G),rt=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.sync=function(t){t()},e.prototype.syncSync=function(){},e.prototype.close=function(t){t()},e.prototype.closeSync=function(){},e}(nt),it=function(t,e){return void 0===e&&(e=""),function(n){if("NotFoundError"===n.name)return t(l.ENOENT(e));t(n)}},ot=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.sync=function(t){var e=this;this.isDirty()?this._fs._sync(this.getPath(),this.getBuffer(),this.getStats(),function(n){n||e.resetDirty(),t(n)}):t()},e.prototype.close=function(t){this.sync(t)},e}(nt),st=function(e){function n(t){e.call(this),this._handles={"/":t}}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.Create=function(t,e){e(null,new n(t.handle))},n.isAvailable=function(){return"function"==typeof FileSystemHandle},n.prototype.getName=function(){return n.Name},n.prototype.isReadOnly=function(){return!1},n.prototype.supportsSymlinks=function(){return!1},n.prototype.supportsProps=function(){return!1},n.prototype.supportsSynch=function(){return!1},n.prototype._sync=function(t,e,n,r){var i=this;this.stat(t,!1,function(o,s){n.mtime!==s.mtime?i.writeFile(t,e,null,g.getFileFlag("w"),s.mode,r):r(o)})},n.prototype.rename=function(t,e,n){var r=this;this.getHandle(t,function(i,o){if(i)return n(i);o instanceof FileSystemDirectoryHandle&&r.readdir(t,function(i,o){if(void 0===o&&(o=[]),i)return n(i);r.mkdir(e,"wx",function(i){if(i)return n(i);0===o.length?r.unlink(t,n):o.forEach(function(i){return r.rename(s.join(t,i),s.join(e,i),function(){return r.unlink(t,n)})})})}),o instanceof FileSystemFileHandle&&o.getFile().then(function(i){return r.getHandle(s.dirname(e),function(o,a){if(o)return n(o);a instanceof FileSystemDirectoryHandle&&a.getFileHandle(s.basename(e),{create:!0}).then(function(o){return o.createWritable().then(function(o){return i.arrayBuffer().then(function(i){return o.write(i).then(function(){o.close(),r.unlink(t,n)}).catch(it(n,e))}).catch(it(n,t))}).catch(it(n,e))}).catch(it(n,e))})}).catch(it(n,t))})},n.prototype.writeFile=function(t,e,n,r,i,o,a){var c=this;this.getHandle(s.dirname(t),function(n,i){if(n)return o(n);i instanceof FileSystemDirectoryHandle&&i.getFileHandle(s.basename(t),{create:!0}).then(function(n){return n.createWritable().then(function(n){return n.write(e).then(function(){n.close().catch(it(o,t)),o(null,a?c.newFile(t,r,e):void 0)}).catch(it(o,t))}).catch(it(o,t))}).catch(it(o,t))})},n.prototype.createFile=function(t,e,n,r){this.writeFile(t,X(),null,e,n,r,!0)},n.prototype.stat=function(t,e,n){this.getHandle(t,function(e,r){return e?n(e):r?r instanceof FileSystemDirectoryHandle?n(null,new m(y.DIRECTORY,4096)):void(r instanceof FileSystemFileHandle&&r.getFile().then(function(t){var e=t.lastModified,r=t.size;return n(null,new m(y.FILE,r,void 0,void 0,e))}).catch(it(n,t))):n(l.FileError(c.EINVAL,t))})},n.prototype.exists=function(t,e){this.getHandle(t,function(t){return e(null===t)})},n.prototype.openFile=function(t,e,n){var r=this;this.getHandle(t,function(i,o){if(i)return n(i);o instanceof FileSystemFileHandle&&o.getFile().then(function(i){return i.arrayBuffer().then(function(o){return n(null,r.newFile(t,e,o,i.size,i.lastModified))}).catch(it(n,t))}).catch(it(n,t))})},n.prototype.unlink=function(t,e){this.getHandle(s.dirname(t),function(n,r){if(n)return e(n);r instanceof FileSystemDirectoryHandle&&r.removeEntry(s.basename(t),{recursive:!0}).then(function(){return e(null)}).catch(it(e,t))})},n.prototype.rmdir=function(t,e){this.unlink(t,e)},n.prototype.mkdir=function(t,e,n){var r=this,i=e&&e.flag&&e.flag.includes("w")&&!e.flag.includes("x");this.getHandle(t,function(e,o){if(o&&!i)return n(l.EEXIST(t));r.getHandle(s.dirname(t),function(e,r){if(e)return n(e);r instanceof FileSystemDirectoryHandle&&r.getDirectoryHandle(s.basename(t),{create:!0}).then(function(){return n(null)}).catch(it(n,t))})})},n.prototype.readdir=function(t,e){this.getHandle(t,function(n,r){if(n)return e(n);r instanceof FileSystemDirectoryHandle&&function(t,e,n){var r=[],i=function(){t.next().then(function(t){var n=t.done,o=t.value;if(n)return e(null,r);r.push(o),i()}).catch(it(e,n))};i()}(r.keys(),e,t)})},n.prototype.newFile=function(e,n,r,i,o){return new ot(this,e,n,new m(y.FILE,i||0,void 0,void 0,o||(new Date).getTime()),t.from(r))},n.prototype.getHandle=function(t,e){var n=this;if("/"===t)return e(null,this._handles["/"]);var r="/",i=t.split("/").slice(1),o=function(i){var a=i[0],u=i.slice(1),f=s.join(r,a),h=function(i){if(r=f,n._handles[r]=i,0===u.length)return e(null,n._handles[t]);o(u)},p=n._handles[r];p.getDirectoryHandle(a).then(h).catch(function(t){"TypeMismatchError"===t.name?p.getFileHandle(a).then(h).catch(it(e,f)):"Name is not allowed."===t.message?e(new l(c.ENOENT,t.message,f)):it(e,f)(t)})};o(i)},n}(J);st.Name="FileSystemAccess",st.Options={};var at=function(t,e,n,r,i,o){this.id=t,this.size=e,this.mode=n,this.atime=r,this.mtime=i,this.ctime=o};at.fromBuffer=function(t){if(void 0===t)throw new Error("NO");return new at(t.toString("ascii",30),t.readUInt32LE(0),t.readUInt16LE(4),t.readDoubleLE(6),t.readDoubleLE(14),t.readDoubleLE(22))},at.prototype.toStats=function(){return new m((61440&this.mode)===y.DIRECTORY?y.DIRECTORY:y.FILE,this.size,this.mode,this.atime,this.mtime,this.ctime)},at.prototype.getSize=function(){return 30+this.id.length},at.prototype.toBuffer=function(e){return void 0===e&&(e=t.alloc(this.getSize())),e.writeUInt32LE(this.size,0),e.writeUInt16LE(this.mode,4),e.writeDoubleLE(this.atime,6),e.writeDoubleLE(this.mtime,14),e.writeDoubleLE(this.ctime,22),e.write(this.id,30,this.id.length,"ascii"),e},at.prototype.update=function(t){var e=!1;this.size!==t.size&&(this.size=t.size,e=!0),this.mode!==t.mode&&(this.mode=t.mode,e=!0);var n=t.atime.getTime();this.atime!==n&&(this.atime=n,e=!0);var r=t.mtime.getTime();this.mtime!==r&&(this.mtime=r,e=!0);var i=t.ctime.getTime();return this.ctime!==i&&(this.ctime=i,e=!0),e},at.prototype.isFile=function(){return(61440&this.mode)===y.FILE},at.prototype.isDirectory=function(){return(61440&this.mode)===y.DIRECTORY};var ct=null;function ut(){return ct||(ct=t.from("{}"))}function ft(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function ht(t,e){return!t||(e(t),!1)}function pt(t,e,n){return!t||(e.abort(function(){n(t)}),!1)}var lt=function(t){this.limit=t,this.size=0,this.map=new Map,this.head=null,this.tail=null};lt.prototype.set=function(t,e){var n=this.map.get(t);n?(n.value=e,this.remove(t,n)):this.size>=this.limit&&(this.map.delete(this.tail.key),this.size--,this.tail=this.tail.prev,this.tail.next=null),this.setHead(n||new function(t,e){this.key=t,this.value=e,this.prev=null,this.next=null}(t,e))},lt.prototype.get=function(t){var e=this.map.get(t);return e?(this.remove(t,e),this.setHead(e),e.value):null},lt.prototype.remove=function(t,e){var n=e||this.map.get(t);n&&(null!==n.prev?n.prev.next=n.next:this.head=n.next,null!==n.next?n.next.prev=n.prev:this.tail=n.prev,this.map.delete(t),this.size--)},lt.prototype.removeAll=function(){this.size=0,this.map=new Map,this.head=null,this.tail=null},lt.prototype.setHead=function(t){t.next=this.head,t.prev=null,null!==this.head&&(this.head.prev=t),this.head=t,null===this.tail&&(this.tail=t),this.size++,this.map.set(t.key,t)};var dt=function(t){this.store=t,this.originalData={},this.modifiedKeys=[]};dt.prototype.get=function(t){var e=this.store.get(t);return this.stashOldValue(t,e),e},dt.prototype.put=function(t,e,n){return this.markModified(t),this.store.put(t,e,n)},dt.prototype.del=function(t){this.markModified(t),this.store.del(t)},dt.prototype.commit=function(){},dt.prototype.abort=function(){for(var t=0,e=this.modifiedKeys;t0)throw l.ENOTEMPTY(t);this.removeEntry(t,!0)},n.prototype.mkdirSync=function(e,n){var r=this.store.beginTransaction("readwrite"),i=t.from("{}");this.commitNewFile(r,e,y.DIRECTORY,n,i)},n.prototype.readdirSync=function(t){var e=this.store.beginTransaction("readonly");return Object.keys(this.getDirListing(e,t,this.findINode(e,t)))},n.prototype._syncSync=function(t,e,n){var r=this.store.beginTransaction("readwrite"),i=this._findINode(r,f.dirname(t),f.basename(t)),o=this.getINode(r,t,i),s=o.update(n);try{r.put(o.id,e,!0),s&&r.put(i,o.toBuffer(),!0)}catch(t){throw r.abort(),t}r.commit()},n.prototype.makeRootDirectory=function(){var t=this.store.beginTransaction("readwrite");if(void 0===t.get("/")){var e=(new Date).getTime(),n=new at(ft(),4096,511|y.DIRECTORY,e,e,e);t.put(n.id,ut(),!1),t.put("/",n.toBuffer(),!1),t.commit()}},n.prototype._findINode=function(t,e,n){var r=this,o=function(i){var o=r.getDirListing(t,e,i);if(o[n])return o[n];throw l.ENOENT(f.resolve(e,n))};return"."===e&&(e=i.cwd()),"/"===e?""===n?"/":o(this.getINode(t,e,"/")):o(this.getINode(t,e+f.sep+n,this._findINode(t,f.dirname(e),f.basename(e))))},n.prototype.findINode=function(t,e){return this.getINode(t,e,this._findINode(t,f.dirname(e),f.basename(e)))},n.prototype.getINode=function(t,e,n){var r=t.get(n);if(void 0===r)throw l.ENOENT(e);return at.fromBuffer(r)},n.prototype.getDirListing=function(t,e,n){if(!n.isDirectory())throw l.ENOTDIR(e);var r=t.get(n.id);if(void 0===r)throw l.ENOENT(e);return JSON.parse(r.toString())},n.prototype.addNewNode=function(t,e){for(var n;;)try{return n=ft(),t.put(n,e,!1),n}catch(t){}throw new l(c.EIO,"Unable to commit data to key-value store.")},n.prototype.commitNewFile=function(e,n,r,i,o){var s,a=f.dirname(n),c=f.basename(n),u=this.findINode(e,a),h=this.getDirListing(e,a,u),p=(new Date).getTime();if("/"===n)throw l.EEXIST(n);if(h[c])throw l.EEXIST(n);try{var d=this.addNewNode(e,o);s=new at(d,o.length,i|r,p,p,p);var y=this.addNewNode(e,s.toBuffer());h[c]=y,e.put(u.id,t.from(JSON.stringify(h)),!0)}catch(t){throw e.abort(),t}return e.commit(),s},n.prototype.removeEntry=function(e,n){var r=this.store.beginTransaction("readwrite"),i=f.dirname(e),o=this.findINode(r,i),s=this.getDirListing(r,i,o),a=f.basename(e);if(!s[a])throw l.ENOENT(e);var c=s[a];delete s[a];var u=this.getINode(r,e,c);if(!n&&u.isDirectory())throw l.EISDIR(e);if(n&&!u.isDirectory())throw l.ENOTDIR(e);try{r.del(u.id),r.del(c),r.put(o.id,t.from(JSON.stringify(s)),!0)}catch(t){throw r.abort(),t}r.commit()},n}(K),mt=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.sync=function(t){var e=this;this.isDirty()?this._fs._sync(this.getPath(),this.getBuffer(),this.getStats(),function(n){n||e.resetDirty(),t(n)}):t()},e.prototype.close=function(t){this.sync(t)},e}(nt),wt=function(e){function n(t){e.call(this),this._cache=null,t>0&&(this._cache=new lt(t))}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.isAvailable=function(){return!0},n.prototype.init=function(t,e){this.store=t,this.makeRootDirectory(e)},n.prototype.getName=function(){return this.store.name()},n.prototype.isReadOnly=function(){return!1},n.prototype.supportsSymlinks=function(){return!1},n.prototype.supportsProps=function(){return!1},n.prototype.supportsSynch=function(){return!1},n.prototype.empty=function(t){var e=this;this._cache&&this._cache.removeAll(),this.store.clear(function(n){ht(n,t)&&e.makeRootDirectory(t)})},n.prototype.rename=function(e,n,r){var i=this;if(this._cache){var o=this._cache;this._cache=null,o.removeAll();var s=r;r=function(t){i._cache=o,s(t)}}var a=this.store.beginTransaction("readwrite"),u=f.dirname(e),h=f.basename(e),p=f.dirname(n),d=f.basename(n),y={},g={},m=!1;if(0===(p+"/").indexOf(e+"/"))return r(new l(c.EBUSY,u));var w=function(o){i.findINodeAndDirListing(a,o,function(s,c,f){s?m||(m=!0,a.abort(function(){r(s)})):(y[o]=c,g[o]=f,function(){if(!m&&g.hasOwnProperty(u)&&g.hasOwnProperty(p)){var o=g[u],s=y[u],c=g[p],f=y[p];if(o[h]){var w=o[h];delete o[h];var _=function(){c[d]=w,a.put(s.id,t.from(JSON.stringify(o)),!0,function(e){pt(e,a,r)&&(u===p?a.commit(r):a.put(f.id,t.from(JSON.stringify(c)),!0,function(t){pt(t,a,r)&&a.commit(r)}))})};c[d]?i.getINode(a,n,c[d],function(t,e){pt(t,a,r)&&(e.isFile()?a.del(e.id,function(t){pt(t,a,r)&&a.del(c[d],function(t){pt(t,a,r)&&_()})}):a.abort(function(t){r(l.EPERM(n))}))}):_()}else r(l.ENOENT(e))}}())})};w(u),u!==p&&w(p)},n.prototype.stat=function(t,e,n){var r=this.store.beginTransaction("readonly");this.findINode(r,t,function(t,e){ht(t,n)&&n(null,e.toStats())})},n.prototype.createFile=function(t,e,n,r){var i=this,o=this.store.beginTransaction("readwrite"),s=X();this.commitNewFile(o,t,y.FILE,n,s,function(n,o){ht(n,r)&&r(null,new mt(i,t,e,o.toStats(),s))})},n.prototype.openFile=function(t,e,n){var r=this,i=this.store.beginTransaction("readonly");this.findINode(i,t,function(o,s){ht(o,n)&&i.get(s.id,function(i,o){ht(i,n)&&(void 0===o?n(l.ENOENT(t)):n(null,new mt(r,t,e,s.toStats(),o)))})})},n.prototype.unlink=function(t,e){this.removeEntry(t,!1,e)},n.prototype.rmdir=function(t,e){var n=this;this.readdir(t,function(r,i){r?e(r):i.length>0?e(l.ENOTEMPTY(t)):n.removeEntry(t,!0,e)})},n.prototype.mkdir=function(e,n,r){var i=this.store.beginTransaction("readwrite"),o=t.from("{}");this.commitNewFile(i,e,y.DIRECTORY,n,o,r)},n.prototype.readdir=function(t,e){var n=this,r=this.store.beginTransaction("readonly");this.findINode(r,t,function(i,o){ht(i,e)&&n.getDirListing(r,t,o,function(t,n){ht(t,e)&&e(null,Object.keys(n))})})},n.prototype._sync=function(t,e,n,r){var i=this,o=this.store.beginTransaction("readwrite");this._findINode(o,f.dirname(t),f.basename(t),function(s,a){pt(s,o,r)&&i.getINode(o,t,a,function(t,i){if(pt(t,o,r)){var s=i.update(n);o.put(i.id,e,!0,function(t){pt(t,o,r)&&(s?o.put(a,i.toBuffer(),!0,function(t){pt(t,o,r)&&o.commit(r)}):o.commit(r))})}})})},n.prototype.makeRootDirectory=function(t){var e=this.store.beginTransaction("readwrite");e.get("/",function(n,r){if(n||void 0===r){var i=(new Date).getTime(),o=new at(ft(),4096,511|y.DIRECTORY,i,i,i);e.put(o.id,ut(),!1,function(n){pt(n,e,t)&&e.put("/",o.toBuffer(),!1,function(n){n?e.abort(function(){t(n)}):e.commit(t)})})}else e.commit(t)})},n.prototype._findINode=function(t,e,n,r){var i=this;if(this._cache){var o=this._cache.get(f.join(e,n));if(o)return r(null,o)}var s=function(t,o,s){if(t)r(t);else if(s[n]){var a=s[n];i._cache&&i._cache.set(f.join(e,n),a),r(null,a)}else r(l.ENOENT(f.resolve(e,n)))};"/"===e?""===n?(this._cache&&this._cache.set(f.join(e,n),"/"),r(null,"/")):this.getINode(t,e,"/",function(n,o){ht(n,r)&&i.getDirListing(t,e,o,function(t,e){s(t,0,e)})}):this.findINodeAndDirListing(t,e,s)},n.prototype.findINode=function(t,e,n){var r=this;this._findINode(t,f.dirname(e),f.basename(e),function(i,o){ht(i,n)&&r.getINode(t,e,o,n)})},n.prototype.getINode=function(t,e,n,r){t.get(n,function(t,n){ht(t,r)&&(void 0===n?r(l.ENOENT(e)):r(null,at.fromBuffer(n)))})},n.prototype.getDirListing=function(t,e,n,r){n.isDirectory()?t.get(n.id,function(t,n){if(ht(t,r))try{r(null,JSON.parse(n.toString()))}catch(t){r(l.ENOENT(e))}}):r(l.ENOTDIR(e))},n.prototype.findINodeAndDirListing=function(t,e,n){var r=this;this.findINode(t,e,function(i,o){ht(i,n)&&r.getDirListing(t,e,o,function(t,e){ht(t,n)&&n(null,o,e)})})},n.prototype.addNewNode=function(t,e,n){var r,i=0,o=function(){5==++i?n(new l(c.EIO,"Unable to commit data to key-value store.")):(r=ft(),t.put(r,e,!1,function(t,e){t||!e?o():n(null,r)}))};o()},n.prototype.commitNewFile=function(e,n,r,i,o,s){var a=this,c=f.dirname(n),u=f.basename(n),h=(new Date).getTime();if("/"===n)return s(l.EEXIST(n));this.findINodeAndDirListing(e,c,function(c,f,p){pt(c,e,s)&&(p[u]?e.abort(function(){s(l.EEXIST(n))}):a.addNewNode(e,o,function(n,c){if(pt(n,e,s)){var l=new at(c,o.length,i|r,h,h,h);a.addNewNode(e,l.toBuffer(),function(n,r){pt(n,e,s)&&(p[u]=r,e.put(f.id,t.from(JSON.stringify(p)),!0,function(t){pt(t,e,s)&&e.commit(function(t){pt(t,e,s)&&s(null,l)})}))})}}))})},n.prototype.removeEntry=function(e,n,r){var i=this;this._cache&&this._cache.remove(e);var o=this.store.beginTransaction("readwrite"),s=f.dirname(e),a=f.basename(e);this.findINodeAndDirListing(o,s,function(s,c,u){if(pt(s,o,r))if(u[a]){var f=u[a];delete u[a],i.getINode(o,e,f,function(i,s){pt(i,o,r)&&(!n&&s.isDirectory()?o.abort(function(){r(l.EISDIR(e))}):n&&!s.isDirectory()?o.abort(function(){r(l.ENOTDIR(e))}):o.del(s.id,function(e){pt(e,o,r)&&o.del(f,function(e){pt(e,o,r)&&o.put(c.id,t.from(JSON.stringify(u)),!0,function(t){pt(t,o,r)&&o.commit(r)})})}))})}else o.abort(function(){r(l.ENOENT(e))})})},n}(J),_t=function(){this.store={}};_t.prototype.name=function(){return Et.Name},_t.prototype.clear=function(){this.store={}},_t.prototype.beginTransaction=function(t){return new dt(this)},_t.prototype.get=function(t){return this.store[t]},_t.prototype.put=function(t,e,n){return!(!n&&this.store.hasOwnProperty(t))&&(this.store[t]=e,!0)},_t.prototype.del=function(t){delete this.store[t]};var Et=function(t){function e(){t.call(this,{store:new _t})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){n(null,new e)},e}(gt);Et.Name="InMemory",Et.Options={};var vt=function(){try{return E.indexedDB||E.mozIndexedDB||E.webkitIndexedDB||E.msIndexedDB}catch(t){return null}}();function St(t,e){switch(void 0===e&&(e=t.toString()),t.name){case"NotFoundError":return new l(c.ENOENT,e);case"QuotaExceededError":return new l(c.ENOSPC,e);default:return new l(c.EIO,e)}}function bt(t,e,n){return void 0===e&&(e=c.EIO),void 0===n&&(n=null),function(r){r.preventDefault(),t(new l(e,null!==n?n:void 0))}}var It=function(t,e){this.tx=t,this.store=e};It.prototype.get=function(t,e){try{var n=this.store.get(t);n.onerror=bt(e),n.onsuccess=function(t){var n=t.target.result;e(null,void 0===n?n:V(n))}}catch(t){e(St(t))}};var kt=function(t){function e(e,n){t.call(this,e,n)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.put=function(t,e,n,r){try{var i,o=z(e);(i=n?this.store.put(o,t):this.store.add(o,t)).onerror=bt(r),i.onsuccess=function(t){r(null,!0)}}catch(t){r(St(t))}},e.prototype.del=function(t,e){try{var n=this.store.delete(t);n.onerror=bt(e),n.onsuccess=function(t){e()}}catch(t){e(St(t))}},e.prototype.commit=function(t){setTimeout(t,0)},e.prototype.abort=function(t){var e=null;try{this.tx.abort()}catch(t){e=St(t)}finally{t(e)}},e}(It),Ot=function(t,e){this.db=t,this.storeName=e};Ot.Create=function(t,e){var n=vt.open(t,1);n.onupgradeneeded=function(e){var n=e.target.result;n.objectStoreNames.contains(t)&&n.deleteObjectStore(t),n.createObjectStore(t)},n.onsuccess=function(n){e(null,new Ot(n.target.result,t))},n.onerror=bt(e,c.EACCES)},Ot.prototype.name=function(){return Nt.Name+" - "+this.storeName},Ot.prototype.clear=function(t){try{var e=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).clear();e.onsuccess=function(e){setTimeout(t,0)},e.onerror=bt(t)}catch(e){t(St(e))}},Ot.prototype.beginTransaction=function(t){void 0===t&&(t="readonly");var e=this.db.transaction(this.storeName,t),n=e.objectStore(this.storeName);if("readwrite"===t)return new kt(e,n);if("readonly"===t)return new It(e,n);throw new l(c.EINVAL,"Invalid transaction type.")};var Nt=function(t){function e(e){t.call(this,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){void 0===t&&(t={}),Ot.Create(t.storeName?t.storeName:"browserfs",function(r,i){if(i){var o=new e("number"==typeof t.cacheSize?t.cacheSize:100);o.init(i,function(t){t?n(t):n(null,o)})}else n(r)})},e.isAvailable=function(){try{return void 0!==vt&&null!==vt.open("__browserfs_test__")}catch(t){return!1}},e}(wt);Nt.Name="IndexedDB",Nt.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."}};var Ft=function(t){function e(e){t.call(this),this.mountList=[],this.mntMap={},this.rootFs=e}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){Et.Create({},function(r,i){if(i){var o=new e(i);try{Object.keys(t).forEach(function(e){o.mount(e,t[e])})}catch(r){return n(r)}n(null,o)}else n(r)})},e.isAvailable=function(){return!0},e.prototype.mount=function(t,e){if("/"!==t[0]&&(t="/"+t),t=f.resolve(t),this.mntMap[t])throw new l(c.EINVAL,"Mount point "+t+" is already taken.");M(t,511,this.rootFs),this.mntMap[t]=e,this.mountList.push(t),this.mountList=this.mountList.sort(function(t,e){return e.length-t.length})},e.prototype.umount=function(t){if("/"!==t[0]&&(t="/"+t),t=f.resolve(t),!this.mntMap[t])throw new l(c.EINVAL,"Mount point "+t+" is already unmounted.");for(delete this.mntMap[t],this.mountList.splice(this.mountList.indexOf(t),1);"/"!==t&&0===this.rootFs.readdirSync(t).length;)this.rootFs.rmdirSync(t),t=f.dirname(t)},e.prototype._getFs=function(t){for(var e=this.mountList,n=e.length,r=0;r1?i.length:0))&&(t="/"),{fs:this.mntMap[i],path:t,mountPoint:i}}return{fs:this.rootFs,path:t,mountPoint:"/"}},e.prototype.getName=function(){return e.Name},e.prototype.diskSpace=function(t,e){e(0,0)},e.prototype.isReadOnly=function(){return!1},e.prototype.supportsLinks=function(){return!1},e.prototype.supportsProps=function(){return!1},e.prototype.supportsSynch=function(){return!0},e.prototype.standardizeError=function(t,e,n){var r=t.message.indexOf(e);return-1!==r&&(t.message=t.message.substr(0,r)+n+t.message.substr(r+e.length),t.path=n),t},e.prototype.rename=function(t,e,n){var r=this,i=this._getFs(t),o=this._getFs(e);return i.fs===o.fs?i.fs.rename(i.path,o.path,function(s){s&&r.standardizeError(r.standardizeError(s,i.path,t),o.path,e),n(s)}):P.readFile(t,function(r,i){if(r)return n(r);P.writeFile(e,i,function(e){if(e)return n(e);P.unlink(t,n)})})},e.prototype.renameSync=function(t,e){var n=this._getFs(t),r=this._getFs(e);if(n.fs===r.fs)try{return n.fs.renameSync(n.path,r.path)}catch(i){throw this.standardizeError(this.standardizeError(i,n.path,t),r.path,e),i}var i=P.readFileSync(t);return P.writeFileSync(e,i),P.unlinkSync(t)},e.prototype.readdirSync=function(t){var e=this._getFs(t),n=null;if(e.fs!==this.rootFs)try{n=this.rootFs.readdirSync(t)}catch(t){}try{var r=e.fs.readdirSync(e.path);return null===n?r:r.concat(n.filter(function(t){return-1===r.indexOf(t)}))}catch(r){if(null===n)throw this.standardizeError(r,e.path,t);return n}},e.prototype.readdir=function(t,e){var n=this,r=this._getFs(t);r.fs.readdir(r.path,function(i,o){if(r.fs!==n.rootFs)try{var s=n.rootFs.readdirSync(t);o=o?o.concat(s.filter(function(t){return-1===o.indexOf(t)})):s}catch(o){if(i)return e(n.standardizeError(i,r.path,t))}else if(i)return e(n.standardizeError(i,r.path,t));e(null,o)})},e.prototype.realpathSync=function(t,e){var n=this._getFs(t);try{var r=n.fs.realpathSync(n.path,{});return f.resolve(f.join(n.mountPoint,r))}catch(e){throw this.standardizeError(e,n.path,t)}},e.prototype.realpath=function(t,e,n){var r=this,i=this._getFs(t);i.fs.realpath(i.path,{},function(e,o){e?n(r.standardizeError(e,i.path,t)):n(null,f.resolve(f.join(i.mountPoint,o)))})},e.prototype.rmdirSync=function(t){var e=this._getFs(t);if(this._containsMountPt(t))throw l.ENOTEMPTY(t);try{e.fs.rmdirSync(e.path)}catch(n){throw this.standardizeError(n,e.path,t)}},e.prototype.rmdir=function(t,e){var n=this,r=this._getFs(t);this._containsMountPt(t)?e(l.ENOTEMPTY(t)):r.fs.rmdir(r.path,function(i){e(i?n.standardizeError(i,r.path,t):null)})},e.prototype._containsMountPt=function(t){for(var e=this.mountList,n=e.length,r=0;r=t.length&&i.slice(0,t.length)===t)return!0}return!1},e}(J);function Tt(t,e,n){return e?function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var r=e[0],i=this._getFs(r);e[0]=i.path;try{return i.fs[t].apply(i.fs,e)}catch(t){throw this.standardizeError(t,i.path,r),t}}:function(){for(var e=this,n=[],r=arguments.length;r--;)n[r]=arguments[r];var i=n[0],o=this._getFs(i);if(n[0]=o.path,"function"==typeof n[n.length-1]){var s=n[n.length-1];n[n.length-1]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];t.length>0&&t[0]instanceof l&&e.standardizeError(t[0],o.path,i),s.apply(null,t)}}return o.fs[t].apply(o.fs,n)}}Ft.Name="MountableFileSystem",Ft.Options={};for(var Lt=[["exists","unlink","readlink"],["stat","mkdir","truncate"],["open","readFile","chmod","utimes"],["chown"],["writeFile","appendFile"]],xt=0;xt"},Pt.prototype.getFSUnlocked=function(){return this._fs},Pt.prototype.diskSpace=function(t,e){this._fs.diskSpace(t,e)},Pt.prototype.isReadOnly=function(){return this._fs.isReadOnly()},Pt.prototype.supportsLinks=function(){return this._fs.supportsLinks()},Pt.prototype.supportsProps=function(){return this._fs.supportsProps()},Pt.prototype.supportsSynch=function(){return this._fs.supportsSynch()},Pt.prototype.rename=function(t,e,n){var r=this;this._mu.lock(function(){r._fs.rename(t,e,function(t){r._mu.unlock(),n(t)})})},Pt.prototype.renameSync=function(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.renameSync(t,e)},Pt.prototype.stat=function(t,e,n){var r=this;this._mu.lock(function(){r._fs.stat(t,e,function(t,e){r._mu.unlock(),n(t,e)})})},Pt.prototype.statSync=function(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.statSync(t,e)},Pt.prototype.open=function(t,e,n,r){var i=this;this._mu.lock(function(){i._fs.open(t,e,n,function(t,e){i._mu.unlock(),r(t,e)})})},Pt.prototype.openSync=function(t,e,n){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.openSync(t,e,n)},Pt.prototype.unlink=function(t,e){var n=this;this._mu.lock(function(){n._fs.unlink(t,function(t){n._mu.unlock(),e(t)})})},Pt.prototype.unlinkSync=function(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.unlinkSync(t)},Pt.prototype.rmdir=function(t,e){var n=this;this._mu.lock(function(){n._fs.rmdir(t,function(t){n._mu.unlock(),e(t)})})},Pt.prototype.rmdirSync=function(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.rmdirSync(t)},Pt.prototype.mkdir=function(t,e,n){var r=this;this._mu.lock(function(){r._fs.mkdir(t,e,function(t){r._mu.unlock(),n(t)})})},Pt.prototype.mkdirSync=function(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.mkdirSync(t,e)},Pt.prototype.readdir=function(t,e){var n=this;this._mu.lock(function(){n._fs.readdir(t,function(t,r){n._mu.unlock(),e(t,r)})})},Pt.prototype.readdirSync=function(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.readdirSync(t)},Pt.prototype.exists=function(t,e){var n=this;this._mu.lock(function(){n._fs.exists(t,function(t){n._mu.unlock(),e(t)})})},Pt.prototype.existsSync=function(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.existsSync(t)},Pt.prototype.realpath=function(t,e,n){var r=this;this._mu.lock(function(){r._fs.realpath(t,e,function(t,e){r._mu.unlock(),n(t,e)})})},Pt.prototype.realpathSync=function(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.realpathSync(t,e)},Pt.prototype.truncate=function(t,e,n){var r=this;this._mu.lock(function(){r._fs.truncate(t,e,function(t){r._mu.unlock(),n(t)})})},Pt.prototype.truncateSync=function(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.truncateSync(t,e)},Pt.prototype.readFile=function(t,e,n,r){var i=this;this._mu.lock(function(){i._fs.readFile(t,e,n,function(t,e){i._mu.unlock(),r(t,e)})})},Pt.prototype.readFileSync=function(t,e,n){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.readFileSync(t,e,n)},Pt.prototype.writeFile=function(t,e,n,r,i,o){var s=this;this._mu.lock(function(){s._fs.writeFile(t,e,n,r,i,function(t){s._mu.unlock(),o(t)})})},Pt.prototype.writeFileSync=function(t,e,n,r,i){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.writeFileSync(t,e,n,r,i)},Pt.prototype.appendFile=function(t,e,n,r,i,o){var s=this;this._mu.lock(function(){s._fs.appendFile(t,e,n,r,i,function(t){s._mu.unlock(),o(t)})})},Pt.prototype.appendFileSync=function(t,e,n,r,i){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.appendFileSync(t,e,n,r,i)},Pt.prototype.chmod=function(t,e,n,r){var i=this;this._mu.lock(function(){i._fs.chmod(t,e,n,function(t){i._mu.unlock(),r(t)})})},Pt.prototype.chmodSync=function(t,e,n){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.chmodSync(t,e,n)},Pt.prototype.chown=function(t,e,n,r,i){var o=this;this._mu.lock(function(){o._fs.chown(t,e,n,r,function(t){o._mu.unlock(),i(t)})})},Pt.prototype.chownSync=function(t,e,n,r){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.chownSync(t,e,n,r)},Pt.prototype.utimes=function(t,e,n,r){var i=this;this._mu.lock(function(){i._fs.utimes(t,e,n,function(t){i._mu.unlock(),r(t)})})},Pt.prototype.utimesSync=function(t,e,n){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.utimesSync(t,e,n)},Pt.prototype.link=function(t,e,n){var r=this;this._mu.lock(function(){r._fs.link(t,e,function(t){r._mu.unlock(),n(t)})})},Pt.prototype.linkSync=function(t,e){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.linkSync(t,e)},Pt.prototype.symlink=function(t,e,n,r){var i=this;this._mu.lock(function(){i._fs.symlink(t,e,n,function(t){i._mu.unlock(),r(t)})})},Pt.prototype.symlinkSync=function(t,e,n){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.symlinkSync(t,e,n)},Pt.prototype.readlink=function(t,e){var n=this;this._mu.lock(function(){n._fs.readlink(t,function(t,r){n._mu.unlock(),e(t,r)})})},Pt.prototype.readlinkSync=function(t){if(this._mu.isLocked())throw new Error("invalid sync call");return this._fs.readlinkSync(t)};var Bt="/.deletedFiles.log";function Ct(t){return 146|t}function Mt(t){return g.getFileFlag(t)}var zt=function(t){function e(e,n,r,i,o){t.call(this,e,n,r,i,o)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.sync=function(t){var e=this;this.isDirty()?this._fs._syncAsync(this,function(n){e.resetDirty(),t(n)}):t(null)},e.prototype.syncSync=function(){this.isDirty()&&(this._fs._syncSync(this),this.resetDirty())},e.prototype.close=function(t){this.sync(t)},e.prototype.closeSync=function(){this.syncSync()},e}(nt),jt=function(t){function e(e,n){if(t.call(this),this._isInitialized=!1,this._initializeCallbacks=[],this._deletedFiles={},this._deleteLog="",this._deleteLogUpdatePending=!1,this._deleteLogUpdateNeeded=!1,this._deleteLogError=null,this._writable=e,this._readable=n,this._writable.isReadOnly())throw new l(c.EINVAL,"Writable file system must be writable.")}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.isAvailable=function(){return!0},e.prototype.getOverlayedFileSystems=function(){return{readable:this._readable,writable:this._writable}},e.prototype._syncAsync=function(t,e){var n=this;this.createParentDirectoriesAsync(t.getPath(),function(r){if(r)return e(r);n._writable.writeFile(t.getPath(),t.getBuffer(),null,Mt("w"),t.getStats().mode,e)})},e.prototype._syncSync=function(t){this.createParentDirectories(t.getPath()),this._writable.writeFileSync(t.getPath(),t.getBuffer(),null,Mt("w"),t.getStats().mode)},e.prototype.getName=function(){return Ht.Name},e.prototype._initialize=function(t){var e=this,n=this._initializeCallbacks,r=function(t){e._isInitialized=!t,e._initializeCallbacks=[],n.forEach(function(e){return e(t)})};if(this._isInitialized)return t();n.push(t),1===n.length&&this._writable.readFile(Bt,"utf8",Mt("r"),function(t,n){if(t){if(t.errno!==c.ENOENT)return r(t)}else e._deleteLog=n;e._reparseDeletionLog(),r()})},e.prototype.isReadOnly=function(){return!1},e.prototype.supportsSynch=function(){return this._readable.supportsSynch()&&this._writable.supportsSynch()},e.prototype.supportsLinks=function(){return!1},e.prototype.supportsProps=function(){return this._readable.supportsProps()&&this._writable.supportsProps()},e.prototype.getDeletionLog=function(){return this._deleteLog},e.prototype.restoreDeletionLog=function(t){this._deleteLog=t,this._reparseDeletionLog(),this.updateLog("")},e.prototype.rename=function(t,e,n){var r=this;if(this.checkInitAsync(n)&&!this.checkPathAsync(t,n)&&!this.checkPathAsync(e,n))return t===Bt||e===Bt?n(l.EPERM("Cannot rename deletion log.")):t===e?n():void this.stat(t,!1,function(i,o){return i?n(i):r.stat(e,!1,function(i,s){var a=r;function u(r){var i=r.shift();if(!i)return n();var o=f.resolve(t,i),s=f.resolve(e,i);a.rename(o,s,function(t){if(t)return n(t);u(r)})}var h=511;if(o.isDirectory()){if(i)return i.errno!==c.ENOENT?n(i):r._writable.exists(t,function(i){if(i)return r.createParentDirectoriesAsync(e,function(i){return i?n(i):r._writable.rename(t,e,n)});r.createParentDirectoriesAsync(e,function(i){if(i)return n(i);r._writable.mkdir(e,h,function(e){if(e)return n(e);r.readdir(t,function(e,i){if(e)return n(e);u(i),r.deletePath(t)})})})});if(h=s.mode,!s.isDirectory())return n(l.ENOTDIR(e));r.readdir(e,function(i,o){if(o&&o.length)return n(l.ENOTEMPTY(e));r._readable.readdir(t,function(e,i){if(e)return n(e);u(i),r.deletePath(t)})})}if(s&&s.isDirectory())return n(l.EISDIR(e));r.readFile(t,null,Mt("r"),function(i,s){return i?n(i):r.writeFile(e,s,null,Mt("w"),o.mode,function(e){return e?n(e):r.unlink(t,n)})})})})},e.prototype.renameSync=function(t,e){var n=this;if(this.checkInitialized(),this.checkPath(t),this.checkPath(e),t===Bt||e===Bt)throw l.EPERM("Cannot rename deletion log.");var r=this.statSync(t,!1);if(r.isDirectory()){if(t===e)return;var i=511;if(this.existsSync(e)){var o=this.statSync(e,!1);if(i=o.mode,!o.isDirectory())throw l.ENOTDIR(e);if(this.readdirSync(e).length>0)throw l.ENOTEMPTY(e)}this._writable.existsSync(t)?this._writable.renameSync(t,e):this._writable.existsSync(e)||(this.createParentDirectories(e),this._writable.mkdirSync(e,i)),this._readable.existsSync(t)&&(this._readable.readdirSync(t).forEach(function(r){n.renameSync(f.resolve(t,r),f.resolve(e,r))}),this.deletePath(t))}else{if(this.existsSync(e)&&this.statSync(e,!1).isDirectory())throw l.EISDIR(e);this.writeFileSync(e,this.readFileSync(t,null,Mt("r")),null,Mt("w"),r.mode)}t!==e&&this.existsSync(t)&&this.unlinkSync(t)},e.prototype.stat=function(t,e,n){var r=this;this.checkInitAsync(n)&&this._writable.stat(t,e,function(i,o){if(i&&i.errno===c.ENOENT){if(r._deletedFiles[t])return n(l.ENOENT(t));r._readable.stat(t,e,function(t,e){e&&((e=m.clone(e)).mode=Ct(e.mode)),n(t,e)})}else n(i,o)})},e.prototype.statSync=function(t,e){this.checkInitialized();try{return this._writable.statSync(t,e)}catch(r){if(this._deletedFiles[t])throw l.ENOENT(t);var n=m.clone(this._readable.statSync(t,e));return n.mode=Ct(n.mode),n}},e.prototype.open=function(t,e,n,r){var i=this;this.checkInitAsync(r)&&!this.checkPathAsync(t,r)&&this.stat(t,!0,function(o,s){if(s)switch(e.pathExistsAction()){case p.TRUNCATE_FILE:return i.createParentDirectoriesAsync(t,function(o){if(o)return r(o);i._writable.open(t,e,n,r)});case p.NOP:return i._writable.exists(t,function(o){o?i._writable.open(t,e,n,r):((s=m.clone(s)).mode=n,i._readable.readFile(t,null,Mt("r"),function(n,o){if(n)return r(n);-1===s.size&&(s.size=o.length);var a=new zt(i,t,e,s,o);r(null,a)}))});default:return r(l.EEXIST(t))}else switch(e.pathNotExistsAction()){case p.CREATE_FILE:return i.createParentDirectoriesAsync(t,function(o){return o?r(o):i._writable.open(t,e,n,r)});default:return r(l.ENOENT(t))}})},e.prototype.openSync=function(t,e,n){if(this.checkInitialized(),this.checkPath(t),t===Bt)throw l.EPERM("Cannot open deletion log.");if(this.existsSync(t))switch(e.pathExistsAction()){case p.TRUNCATE_FILE:return this.createParentDirectories(t),this._writable.openSync(t,e,n);case p.NOP:if(this._writable.existsSync(t))return this._writable.openSync(t,e,n);var r=this._readable.readFileSync(t,null,Mt("r")),i=m.clone(this._readable.statSync(t,!1));return i.mode=n,new zt(this,t,e,i,r);default:throw l.EEXIST(t)}else switch(e.pathNotExistsAction()){case p.CREATE_FILE:return this.createParentDirectories(t),this._writable.openSync(t,e,n);default:throw l.ENOENT(t)}},e.prototype.unlink=function(t,e){var n=this;this.checkInitAsync(e)&&!this.checkPathAsync(t,e)&&this.exists(t,function(r){if(!r)return e(l.ENOENT(t));n._writable.exists(t,function(r){if(r)return n._writable.unlink(t,function(r){if(r)return e(r);n.exists(t,function(r){r&&n.deletePath(t),e(null)})});n.deletePath(t),e(null)})})},e.prototype.unlinkSync=function(t){if(this.checkInitialized(),this.checkPath(t),!this.existsSync(t))throw l.ENOENT(t);this._writable.existsSync(t)&&this._writable.unlinkSync(t),this.existsSync(t)&&this.deletePath(t)},e.prototype.rmdir=function(t,e){var n=this;if(this.checkInitAsync(e)){var r=function(){n.readdir(t,function(r,i){return r?e(r):i.length?e(l.ENOTEMPTY(t)):(n.deletePath(t),void e(null))})};this.exists(t,function(i){if(!i)return e(l.ENOENT(t));n._writable.exists(t,function(i){i?n._writable.rmdir(t,function(i){if(i)return e(i);n._readable.exists(t,function(t){t?r():e()})}):r()})})}},e.prototype.rmdirSync=function(t){if(this.checkInitialized(),!this.existsSync(t))throw l.ENOENT(t);if(this._writable.existsSync(t)&&this._writable.rmdirSync(t),this.existsSync(t)){if(this.readdirSync(t).length>0)throw l.ENOTEMPTY(t);this.deletePath(t)}},e.prototype.mkdir=function(t,e,n){var r=this;this.checkInitAsync(n)&&this.exists(t,function(i){if(i)return n(l.EEXIST(t));r.createParentDirectoriesAsync(t,function(i){if(i)return n(i);r._writable.mkdir(t,e,n)})})},e.prototype.mkdirSync=function(t,e){if(this.checkInitialized(),this.existsSync(t))throw l.EEXIST(t);this.createParentDirectories(t),this._writable.mkdirSync(t,e)},e.prototype.readdir=function(t,e){var n=this;this.checkInitAsync(e)&&this.stat(t,!0,function(r,i){return r?e(r):i.isDirectory()?void n._writable.readdir(t,function(r,i){if(r&&"ENOENT"!==r.code)return e(r);!r&&i||(i=[]),n._readable.readdir(t,function(r,o){!r&&o||(o=[]);var s={},a=i.concat(o.filter(function(e){return!n._deletedFiles[t+("/"===t?"":"/")+e]})).filter(function(t){var e=!s[t];return s[t]=!0,e});e(null,a)})}):e(l.ENOTDIR(t))})},e.prototype.readdirSync=function(t){var e=this;if(this.checkInitialized(),!this.statSync(t,!1).isDirectory())throw l.ENOTDIR(t);var n=[];try{n=n.concat(this._writable.readdirSync(t))}catch(t){}try{n=n.concat(this._readable.readdirSync(t).filter(function(n){return!e._deletedFiles[t+("/"===t?"":"/")+n]}))}catch(t){}var r={};return n.filter(function(t){var e=!r[t];return r[t]=!0,e})},e.prototype.exists=function(t,e){var n=this;this.checkInitialized(),this._writable.exists(t,function(r){if(r)return e(!0);n._readable.exists(t,function(r){e(r&&!0!==n._deletedFiles[t])})})},e.prototype.existsSync=function(t){return this.checkInitialized(),this._writable.existsSync(t)||this._readable.existsSync(t)&&!0!==this._deletedFiles[t]},e.prototype.chmod=function(t,e,n,r){var i=this;this.checkInitAsync(r)&&this.operateOnWritableAsync(t,function(o){if(o)return r(o);i._writable.chmod(t,e,n,r)})},e.prototype.chmodSync=function(t,e,n){var r=this;this.checkInitialized(),this.operateOnWritable(t,function(){r._writable.chmodSync(t,e,n)})},e.prototype.chown=function(t,e,n,r,i){var o=this;this.checkInitAsync(i)&&this.operateOnWritableAsync(t,function(s){if(s)return i(s);o._writable.chown(t,e,n,r,i)})},e.prototype.chownSync=function(t,e,n,r){var i=this;this.checkInitialized(),this.operateOnWritable(t,function(){i._writable.chownSync(t,e,n,r)})},e.prototype.utimes=function(t,e,n,r){var i=this;this.checkInitAsync(r)&&this.operateOnWritableAsync(t,function(o){if(o)return r(o);i._writable.utimes(t,e,n,r)})},e.prototype.utimesSync=function(t,e,n){var r=this;this.checkInitialized(),this.operateOnWritable(t,function(){r._writable.utimesSync(t,e,n)})},e.prototype.deletePath=function(t){this._deletedFiles[t]=!0,this.updateLog("d"+t+"\n")},e.prototype.updateLog=function(t){var e=this;this._deleteLog+=t,this._deleteLogUpdatePending?this._deleteLogUpdateNeeded=!0:(this._deleteLogUpdatePending=!0,this._writable.writeFile(Bt,this._deleteLog,"utf8",g.getFileFlag("w"),420,function(t){e._deleteLogUpdatePending=!1,t?e._deleteLogError=t:e._deleteLogUpdateNeeded&&(e._deleteLogUpdateNeeded=!1,e.updateLog(""))}))},e.prototype._reparseDeletionLog=function(){var t=this;this._deletedFiles={},this._deleteLog.split("\n").forEach(function(e){t._deletedFiles[e.slice(1)]="d"===e.slice(0,1)})},e.prototype.checkInitialized=function(){if(!this._isInitialized)throw new l(c.EPERM,"OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.");if(null!==this._deleteLogError){var t=this._deleteLogError;throw this._deleteLogError=null,t}},e.prototype.checkInitAsync=function(t){if(!this._isInitialized)return t(new l(c.EPERM,"OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.")),!1;if(null!==this._deleteLogError){var e=this._deleteLogError;return this._deleteLogError=null,t(e),!1}return!0},e.prototype.checkPath=function(t){if(t===Bt)throw l.EPERM(t)},e.prototype.checkPathAsync=function(t,e){return t===Bt&&(e(l.EPERM(t)),!0)},e.prototype.createParentDirectoriesAsync=function(t,e){var n=f.dirname(t),r=[],i=this;this._writable.stat(n,!1,function t(o,s){o?"/"===n?e(new l(c.EBUSY,"Invariant failed: root does not exist!")):(r.push(n),n=f.dirname(n),i._writable.stat(n,!1,t)):function t(){if(!r.length)return e();var n=r.pop();i._readable.stat(n,!1,function(r,o){if(!o)return e();i._writable.mkdir(n,o.mode,function(n){if(n)return e(n);t()})})}()})},e.prototype.createParentDirectories=function(t){for(var e=this,n=f.dirname(t),r=[];!this._writable.existsSync(n);)r.push(n),n=f.dirname(n);(r=r.reverse()).forEach(function(t){e._writable.mkdirSync(t,e.statSync(t,!1).mode)})},e.prototype.operateOnWritable=function(t,e){if(!this.existsSync(t))throw l.ENOENT(t);this._writable.existsSync(t)||this.copyToWritable(t),e()},e.prototype.operateOnWritableAsync=function(t,e){var n=this;this.exists(t,function(r){if(!r)return e(l.ENOENT(t));n._writable.exists(t,function(r){if(!r)return n.copyToWritableAsync(t,e);e()})})},e.prototype.copyToWritable=function(t){var e=this.statSync(t,!1);e.isDirectory()?this._writable.mkdirSync(t,e.mode):this.writeFileSync(t,this._readable.readFileSync(t,null,Mt("r")),null,Mt("w"),this.statSync(t,!1).mode)},e.prototype.copyToWritableAsync=function(t,e){var n=this;this.stat(t,!1,function(r,i){return r?e(r):i.isDirectory()?n._writable.mkdir(t,i.mode,e):void n._readable.readFile(t,null,Mt("r"),function(r,o){if(r)return e(r);n.writeFile(t,o,null,Mt("w"),i.mode,e)})})},e}(J),Ht=function(t){function e(e,n){t.call(this,new jt(e,n))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){try{var r=new e(t.writable,t.readable);r._initialize(function(t){n(t,r)})}catch(t){n(t)}},e.isAvailable=function(){return jt.isAvailable()},e.prototype.getOverlayedFileSystems=function(){return t.prototype.getFSUnlocked.call(this).getOverlayedFileSystems()},e.prototype.unwrap=function(){return t.prototype.getFSUnlocked.call(this)},e.prototype._initialize=function(e){t.prototype.getFSUnlocked.call(this)._initialize(e)},e}(Pt);Ht.Name="OverlayFS",Ht.Options={writable:{type:"object",description:"The file system to write modified files to."},readable:{type:"object",description:"The file system that initially populates this file system."}};var Zt=function(e,n,r){var i=new XMLHttpRequest;i.open("GET",e,!0);var o=!0;switch(n){case"buffer":i.responseType="arraybuffer";break;case"json":try{i.responseType="json",o="json"===i.responseType}catch(t){o=!1}break;default:return r(new l(c.EINVAL,"Invalid download type: "+n))}i.onreadystatechange=function(e){if(4===i.readyState){if(200!==i.status)return r(new l(c.EIO,"XHR error: response returned code "+i.status));switch(n){case"buffer":return r(null,i.response?t.from(i.response):X());case"json":return r(null,o?i.response:JSON.parse(i.responseText))}}},i.send()},Vt=function(e,n){var r=new XMLHttpRequest;r.open("GET",e,!1);var i=null,o=null;if(r.overrideMimeType("text/plain; charset=x-user-defined"),r.onreadystatechange=function(e){if(4===r.readyState){if(200!==r.status)return void(o=new l(c.EIO,"XHR error: response returned code "+r.status));switch(n){case"buffer":var s=r.responseText;i=t.alloc(s.length);for(var a=0;a0;){var i=void 0,o=r.pop(),s=o[0],a=o[1],c=o[2];for(var u in a)if(a.hasOwnProperty(u)){var f=a[u],h=s+"/"+u;f?(e._index[h]=i=new Gt,r.push([h,f,i])):i=new Kt(new m(y.FILE,-1,365)),c&&(c._ls[u]=i)}}return e},Jt.prototype.fileIterator=function(t){for(var e in this._index)if(this._index.hasOwnProperty(e))for(var n=this._index[e],r=0,i=n.getListing();r0&&"/"!==n.charAt(n.length-1)&&(n+="/"),this.prefixUrl=n,this._index=Jt.fromListing(e),this._requestFileAsyncInternal=qt,this._requestFileSizeAsyncInternal=$t,this._requestFileSyncInternal=Vt,this._requestFileSizeSyncInternal=Yt}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){void 0===t.index&&(t.index="index.json"),"string"==typeof t.index?Zt(t.index,"json",function(r,i){r?n(r):n(null,new e(i,t.baseUrl))}):n(null,new e(t.index,t.baseUrl))},e.isAvailable=function(){return!0},e.prototype.empty=function(){this._index.fileIterator(function(t){t.fileData=null})},e.prototype.getName=function(){return e.Name},e.prototype.diskSpace=function(t,e){e(0,0)},e.prototype.isReadOnly=function(){return!0},e.prototype.supportsLinks=function(){return!1},e.prototype.supportsProps=function(){return!1},e.prototype.supportsSynch=function(){return!0},e.prototype.preloadFile=function(t,e){var n=this._index.getInode(t);if(!Qt(n))throw l.EISDIR(t);if(null===n)throw l.ENOENT(t);var r=n.getData();r.size=e.length,r.fileData=e},e.prototype.stat=function(t,e,n){var r,i=this._index.getInode(t);if(null===i)return n(l.ENOENT(t));Qt(i)?(r=i.getData(),!e&&r.size<0?this._requestFileSizeAsync(t,function(t,e){if(t)return n(t);r.size=e,n(null,m.clone(r))}):n(null,m.clone(r))):te(i)?(r=i.getStats(),n(null,r)):n(l.FileError(c.EINVAL,t))},e.prototype.statSync=function(t,e){var n,r=this._index.getInode(t);if(null===r)throw l.ENOENT(t);if(Qt(r))(n=r.getData()).size<0&&(n.size=this._requestFileSizeSync(t));else{if(!te(r))throw l.FileError(c.EINVAL,t);n=r.getStats()}return n},e.prototype.open=function(t,e,n,r){if(e.isWriteable())return r(new l(c.EPERM,t));var i=this,o=this._index.getInode(t);if(null===o)return r(l.ENOENT(t));if(!Qt(o))return r(l.EISDIR(t));var s=o.getData();switch(e.pathExistsAction()){case p.THROW_EXCEPTION:case p.TRUNCATE_FILE:return r(l.EEXIST(t));case p.NOP:if(s.fileData)return r(null,new rt(i,t,e,m.clone(s),s.fileData));this._requestFileAsync(t,"buffer",function(n,o){return n?r(n):(s.size=o.length,s.fileData=o,r(null,new rt(i,t,e,m.clone(s),o)))});break;default:return r(new l(c.EINVAL,"Invalid FileMode object."))}},e.prototype.openSync=function(t,e,n){if(e.isWriteable())throw new l(c.EPERM,t);var r=this._index.getInode(t);if(null===r)throw l.ENOENT(t);if(!Qt(r))throw l.EISDIR(t);var i=r.getData();switch(e.pathExistsAction()){case p.THROW_EXCEPTION:case p.TRUNCATE_FILE:throw l.EEXIST(t);case p.NOP:if(i.fileData)return new rt(this,t,e,m.clone(i),i.fileData);var o=this._requestFileSync(t,"buffer");return i.size=o.length,i.fileData=o,new rt(this,t,e,m.clone(i),o);default:throw new l(c.EINVAL,"Invalid FileMode object.")}},e.prototype.readdir=function(t,e){try{e(null,this.readdirSync(t))}catch(t){e(t)}},e.prototype.readdirSync=function(t){var e=this._index.getInode(t);if(null===e)throw l.ENOENT(t);if(te(e))return e.getListing();throw l.ENOTDIR(t)},e.prototype.readFile=function(t,e,n,r){var i=r;this.open(t,n,420,function(t,n){if(t)return r(t);r=function(t,e){n.close(function(n){return t||(t=n),i(t,e)})};var o=n.getBuffer();null===e?r(t,Y(o)):function(t,e,n){try{n(null,t.toString(e))}catch(t){n(t)}}(o,e,r)})},e.prototype.readFileSync=function(t,e,n){var r=this.openSync(t,n,420);try{var i=r.getBuffer();return null===e?Y(i):i.toString(e)}finally{r.closeSync()}},e.prototype._getHTTPPath=function(t){return"/"===t.charAt(0)&&(t=t.slice(1)),this.prefixUrl+t},e.prototype._requestFileAsync=function(t,e,n){this._requestFileAsyncInternal(this._getHTTPPath(t),e,n)},e.prototype._requestFileSync=function(t,e){return this._requestFileSyncInternal(this._getHTTPPath(t),e)},e.prototype._requestFileSizeAsync=function(t,e){this._requestFileSizeAsyncInternal(this._getHTTPPath(t),e)},e.prototype._requestFileSizeSync=function(t){return this._requestFileSizeSyncInternal(this._getHTTPPath(t))},e}(J);ee.Name="HTTPRequest",ee.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 ne=function(){};ne.str2byte=function(t,e){for(var n=t.length>e.length?e.length:t.length,r=0;r127){var o=ne.extendedChars.indexOf(t.charAt(r));o>-1&&(i=o+128)}e[i]=r}return n},ne.byte2str=function(t){for(var e=new Array(t.length),n=0;n127?ne.extendedChars[r-128]:String.fromCharCode(r)}return e.join("")},ne.byteLength=function(t){return t.length},ne.extendedChars=["Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","ø","£","Ø","×","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","®","¬","½","¼","¡","«","»","_","_","_","¦","¦","Á","Â","À","©","¦","¦","+","+","¢","¥","+","+","-","-","+","-","+","ã","Ã","+","+","-","-","¦","-","+","¤","ð","Ð","Ê","Ë","È","i","Í","Î","Ï","+","+","_","_","¦","Ì","_","Ó","ß","Ô","Ò","õ","Õ","µ","þ","Þ","Ú","Û","Ù","ý","Ý","¯","´","­","±","_","¾","¶","§","÷","¸","°","¨","·","¹","³","²","_"," "];var re,ie=n(9).inflateRaw,oe={};function se(t,e){return new Date(1980+(e>>9),(e>>5&15)-1,31&e,t>>11,t>>5&63,31&t)}function ae(t,e,n,r){return 0===r?"":e?t.toString("utf8",n,n+r):ne.byte2str(t.slice(n,n+r))}!function(t){t[t.STORED=0]="STORED",t[t.SHRUNK=1]="SHRUNK",t[t.REDUCED_1=2]="REDUCED_1",t[t.REDUCED_2=3]="REDUCED_2",t[t.REDUCED_3=4]="REDUCED_3",t[t.REDUCED_4=5]="REDUCED_4",t[t.IMPLODE=6]="IMPLODE",t[t.DEFLATE=8]="DEFLATE",t[t.DEFLATE64=9]="DEFLATE64",t[t.TERSE_OLD=10]="TERSE_OLD",t[t.BZIP2=12]="BZIP2",t[t.LZMA=14]="LZMA",t[t.TERSE_NEW=18]="TERSE_NEW",t[t.LZ77=19]="LZ77",t[t.WAVPACK=97]="WAVPACK",t[t.PPMD=98]="PPMD"}(re||(re={}));var ce=function(t){if(this.data=t,67324752!==t.readUInt32LE(0))throw new l(c.EINVAL,"Invalid Zip file: Local file header has invalid signature: "+this.data.readUInt32LE(0))};ce.prototype.versionNeeded=function(){return this.data.readUInt16LE(4)},ce.prototype.flags=function(){return this.data.readUInt16LE(6)},ce.prototype.compressionMethod=function(){return this.data.readUInt16LE(8)},ce.prototype.lastModFileTime=function(){return se(this.data.readUInt16LE(10),this.data.readUInt16LE(12))},ce.prototype.rawLastModFileTime=function(){return this.data.readUInt32LE(10)},ce.prototype.crc32=function(){return this.data.readUInt32LE(14)},ce.prototype.fileNameLength=function(){return this.data.readUInt16LE(26)},ce.prototype.extraFieldLength=function(){return this.data.readUInt16LE(28)},ce.prototype.fileName=function(){return ae(this.data,this.useUTF8(),30,this.fileNameLength())},ce.prototype.extraField=function(){var t=30+this.fileNameLength();return this.data.slice(t,t+this.extraFieldLength())},ce.prototype.totalSize=function(){return 30+this.fileNameLength()+this.extraFieldLength()},ce.prototype.useUTF8=function(){return 2048==(2048&this.flags())};var ue=function(t,e,n){this.header=t,this.record=e,this.data=n};ue.prototype.decompress=function(){var t=this.header.compressionMethod(),e=oe[t];if(e)return e(this.data,this.record.compressedSize(),this.record.uncompressedSize(),this.record.flag());var n=re[t];throw n||(n="Unknown: "+t),new l(c.EINVAL,"Invalid compression method on file '"+this.header.fileName()+"': "+n)},ue.prototype.getHeader=function(){return this.header},ue.prototype.getRecord=function(){return this.record},ue.prototype.getRawData=function(){return this.data};var fe=function(t,e){if(this.zipData=t,this.data=e,33639248!==this.data.readUInt32LE(0))throw new l(c.EINVAL,"Invalid Zip file: Central directory record has invalid signature: "+this.data.readUInt32LE(0));this._filename=this.produceFilename()};fe.prototype.versionMadeBy=function(){return this.data.readUInt16LE(4)},fe.prototype.versionNeeded=function(){return this.data.readUInt16LE(6)},fe.prototype.flag=function(){return this.data.readUInt16LE(8)},fe.prototype.compressionMethod=function(){return this.data.readUInt16LE(10)},fe.prototype.lastModFileTime=function(){return se(this.data.readUInt16LE(12),this.data.readUInt16LE(14))},fe.prototype.rawLastModFileTime=function(){return this.data.readUInt32LE(12)},fe.prototype.crc32=function(){return this.data.readUInt32LE(16)},fe.prototype.compressedSize=function(){return this.data.readUInt32LE(20)},fe.prototype.uncompressedSize=function(){return this.data.readUInt32LE(24)},fe.prototype.fileNameLength=function(){return this.data.readUInt16LE(28)},fe.prototype.extraFieldLength=function(){return this.data.readUInt16LE(30)},fe.prototype.fileCommentLength=function(){return this.data.readUInt16LE(32)},fe.prototype.diskNumberStart=function(){return this.data.readUInt16LE(34)},fe.prototype.internalAttributes=function(){return this.data.readUInt16LE(36)},fe.prototype.externalAttributes=function(){return this.data.readUInt32LE(38)},fe.prototype.headerRelativeOffset=function(){return this.data.readUInt32LE(42)},fe.prototype.produceFilename=function(){return ae(this.data,this.useUTF8(),46,this.fileNameLength()).replace(/\\/g,"/")},fe.prototype.fileName=function(){return this._filename},fe.prototype.rawFileName=function(){return this.data.slice(46,46+this.fileNameLength())},fe.prototype.extraField=function(){var t=44+this.fileNameLength();return this.data.slice(t,t+this.extraFieldLength())},fe.prototype.fileComment=function(){var t=46+this.fileNameLength()+this.extraFieldLength();return ae(this.data,this.useUTF8(),t,this.fileCommentLength())},fe.prototype.rawFileComment=function(){var t=46+this.fileNameLength()+this.extraFieldLength();return this.data.slice(t,t+this.fileCommentLength())},fe.prototype.totalSize=function(){return 46+this.fileNameLength()+this.extraFieldLength()+this.fileCommentLength()},fe.prototype.isDirectory=function(){var t=this.fileName();return!!(16&this.externalAttributes())||"/"===t.charAt(t.length-1)},fe.prototype.isFile=function(){return!this.isDirectory()},fe.prototype.useUTF8=function(){return 2048==(2048&this.flag())},fe.prototype.isEncrypted=function(){return 1==(1&this.flag())},fe.prototype.getFileData=function(){var t=this.headerRelativeOffset(),e=new ce(this.zipData.slice(t));return new ue(e,this,this.zipData.slice(t+e.totalSize()))},fe.prototype.getData=function(){return this.getFileData().decompress()},fe.prototype.getRawData=function(){return this.getFileData().getRawData()},fe.prototype.getStats=function(){return new m(y.FILE,this.uncompressedSize(),365,Date.now(),this.lastModFileTime().getTime())};var he=function(t){if(this.data=t,101010256!==this.data.readUInt32LE(0))throw new l(c.EINVAL,"Invalid Zip file: End of central directory record has invalid signature: "+this.data.readUInt32LE(0))};he.prototype.diskNumber=function(){return this.data.readUInt16LE(4)},he.prototype.cdDiskNumber=function(){return this.data.readUInt16LE(6)},he.prototype.cdDiskEntryCount=function(){return this.data.readUInt16LE(8)},he.prototype.cdTotalEntryCount=function(){return this.data.readUInt16LE(10)},he.prototype.cdSize=function(){return this.data.readUInt32LE(12)},he.prototype.cdOffset=function(){return this.data.readUInt32LE(16)},he.prototype.cdZipCommentLength=function(){return this.data.readUInt16LE(20)},he.prototype.cdZipComment=function(){return ae(this.data,!0,22,this.cdZipCommentLength())},he.prototype.rawCdZipComment=function(){return this.data.slice(22,22+this.cdZipCommentLength())};var pe=function(t){function e(e,n){void 0===n&&(n=""),t.call(this),this.name=n,this._index=new Jt,this._directoryEntries=[],this._eocd=null,this._index=e.index,this._directoryEntries=e.directoryEntries,this._eocd=e.eocd,this.data=e.data}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.Create=function(t,n){try{e._computeIndex(t.zipData,function(r,i){if(i){var o=new e(i,t.name);n(null,o)}else n(r)})}catch(t){n(t)}},e.isAvailable=function(){return!0},e.RegisterDecompressionMethod=function(t,e){oe[t]=e},e._getEOCD=function(t){for(var e=Math.min(65557,t.length-1),n=22;n-1},be.prototype.getRockRidgeOffset=function(){return this._rockRidgeOffset},be.prototype.rootCheckForRockRidge=function(t){var e=this.getDirectory(t);this._rockRidgeOffset=e.getDotEntry(t)._getRockRidgeOffset(t),this._rockRidgeOffset>-1&&(this._fileOrDir=null)},be.prototype.length=function(){return this._data[0]},be.prototype.extendedAttributeRecordLength=function(){return this._data[1]},be.prototype.lba=function(){return 2048*this._data.readUInt32LE(2)},be.prototype.dataLength=function(){return this._data.readUInt32LE(10)},be.prototype.recordingDate=function(){return ge(this._data,18)},be.prototype.fileFlags=function(){return this._data[25]},be.prototype.fileUnitSize=function(){return this._data[26]},be.prototype.interleaveGapSize=function(){return this._data[27]},be.prototype.volumeSequenceNumber=function(){return this._data.readUInt16LE(28)},be.prototype.identifier=function(){return this._getString(33,this._data[32])},be.prototype.fileName=function(t){if(this.hasRockRidge()){var e=this._rockRidgeFilename(t);if(null!==e)return e}var n=this.identifier();if(this.isDirectory(t))return n;var r=n.indexOf(";");return-1===r?n:"."===n[r-1]?n.slice(0,r-1):n.slice(0,r)},be.prototype.isDirectory=function(t){var e=!!(2&this.fileFlags());return!e&&this.hasRockRidge()&&(e=this.getSUEntries(t).filter(function(t){return t instanceof Me}).length>0),e},be.prototype.isSymlink=function(t){return this.hasRockRidge()&&this.getSUEntries(t).filter(function(t){return t instanceof Pe}).length>0},be.prototype.getSymlinkPath=function(t){for(var e="",n=this.getSUEntries(t),r=this._getGetString(),i=0,o=n;i1&&"/"===e[e.length-1]?e.slice(0,e.length-1):e},be.prototype.getFile=function(t){if(this.isDirectory(t))throw new Error("Tried to get a File from a directory.");return null===this._fileOrDir&&(this._fileOrDir=t.slice(this.lba(),this.lba()+this.dataLength())),this._fileOrDir},be.prototype.getDirectory=function(t){if(!this.isDirectory(t))throw new Error("Tried to get a Directory from a file.");return null===this._fileOrDir&&(this._fileOrDir=this._constructDirectory(t)),this._fileOrDir},be.prototype.getSUEntries=function(t){return this._suEntries||this._constructSUEntries(t),this._suEntries},be.prototype._rockRidgeFilename=function(t){var e=this.getSUEntries(t).filter(function(t){return t instanceof Ce});if(0===e.length||6&e[0].flags())return null;for(var n="",r=this._getGetString(),i=0,o=e;i0){var n=e[0];if(n instanceof Te&&n.checkBytesPass())for(var r=1;r0?s-4:s;for(n=0;n>16&255,c[f++]=e>>8&255,c[f++]=255&e;2===a&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,c[f++]=255&e);1===a&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e);return c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=0,a=n-i;sa?a:s+16383));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function f(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function h(t,e,n){for(var r,i=[],o=e;o */ e.read=function(t,e,n,r,i){var o,s,a=8*i-r-1,c=(1<>1,f=-7,h=n?i-1:0,p=n?-1:1,l=t[e+h];for(h+=p,o=l&(1<<-f)-1,l>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=p,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=256*s+t[e+h],h+=p,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(l?-1:1);s+=Math.pow(2,r),o-=u}return(l?-1:1)*s*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var s,a,c,u=8*o-i-1,f=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=r?0:o-1,d=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?p/c:p*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[n+l]=255&a,l+=d,a/=256,i-=8);for(s=s<0;t[n+l]=255&s,l+=d,s/=256,u-=8);t[n+l-d]|=128*y}},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){(function(t){function n(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(t){return r.exec(t).slice(1)};function o(t,e){if(t.filter)return t.filter(e);for(var n=[],r=0;r=-1&&!r;i--){var s=i>=0?arguments[i]:t.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(e=s+"/"+e,r="/"===s.charAt(0))}return e=n(o(e.split("/"),function(t){return!!t}),!r).join("/"),(r?"/":"")+e||"."},e.normalize=function(t){var r=e.isAbsolute(t),i="/"===s(t,-1);return(t=n(o(t.split("/"),function(t){return!!t}),!r).join("/"))||r||(t="."),t&&i&&(t+="/"),(r?"/":"")+t},e.isAbsolute=function(t){return"/"===t.charAt(0)},e.join=function(){var t=Array.prototype.slice.call(arguments,0);return e.normalize(o(t,function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},e.relative=function(t,n){function r(t){for(var e=0;e=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=e.resolve(t).substr(1),n=e.resolve(n).substr(1);for(var i=r(t.split("/")),o=r(n.split("/")),s=Math.min(i.length,o.length),a=s,c=0;c=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;let n=r.inflateInit2(this.strm,e.windowBits);if(n!==p)throw new Error(s[n]);if(this.header=new c,r.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=o.string2buf(e.dictionary):"[object ArrayBuffer]"===u.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=r.inflateSetDictionary(this.strm,e.dictionary))!==p))throw new Error(s[n])}function _(t,e){const n=new w(e);if(n.push(t),n.err)throw n.msg||s[n.err];return n.result}w.prototype.push=function(t,e){const n=this.strm,i=this.options.chunkSize,s=this.options.dictionary;let a,c,w;if(this.ended)return!1;for(c=e===~~e?e:!0===e?h:f,"[object ArrayBuffer]"===u.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),(a=r.inflate(n,c))===d&&s&&((a=r.inflateSetDictionary(n,s))===p?a=r.inflate(n,c):a===g&&(a=d));n.avail_in>0&&a===l&&n.state.wrap>0&&0!==t[n.next_in];)r.inflateReset(n),a=r.inflate(n,c);switch(a){case y:case g:case d:case m:return this.onEnd(a),this.ended=!0,!1}if(w=n.avail_out,n.next_out&&(0===n.avail_out||a===l))if("string"===this.options.to){let t=o.utf8border(n.output,n.next_out),e=n.next_out-t,r=o.buf2string(n.output,t);n.next_out=e,n.avail_out=i-e,e&&n.output.set(n.output.subarray(t,t+e),0),this.onData(r)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(a!==p||0!==w){if(a===l)return a=r.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},w.prototype.onData=function(t){this.chunks.push(t)},w.prototype.onEnd=function(t){t===p&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},t.exports.Inflate=w,t.exports.inflate=_,t.exports.inflateRaw=function(t,e){return(e=e||{}).raw=!0,_(t,e)},t.exports.ungzip=_,t.exports.constants=n(0)},function(t,e,n){"use strict";const r=n(11),i=n(12),o=n(13),s=n(14),{Z_FINISH:a,Z_BLOCK:c,Z_TREES:u,Z_OK:f,Z_STREAM_END:h,Z_NEED_DICT:p,Z_STREAM_ERROR:l,Z_DATA_ERROR:d,Z_MEM_ERROR:y,Z_BUF_ERROR:g,Z_DEFLATED:m}=n(0),w=16209,_=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);const E=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<16180||e.mode>16211?1:0},v=t=>{if(E(t))return l;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=16180,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,f},S=t=>{if(E(t))return l;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,v(t)},b=(t,e)=>{let n;if(E(t))return l;const r=t.state;return e<0?(n=0,e=-e):(n=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?l:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=n,r.wbits=e,S(t))},I=(t,e)=>{if(!t)return l;const n=new function(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0};t.state=n,n.strm=t,n.window=null,n.mode=16180;const r=b(t,e);return r!==f&&(t.state=null),r};let k,O,N=!0;const F=t=>{if(N){k=new Int32Array(512),O=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(s(1,t.lens,0,288,k,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;s(2,t.lens,0,32,O,0,t.work,{bits:5}),N=!1}t.lencode=k,t.lenbits=9,t.distcode=O,t.distbits=5},T=(t,e,n,r)=>{let i;const o=t.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(e.subarray(n-o.wsize,n),0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>r&&(i=r),o.window.set(e.subarray(n-r,n-r+i),o.wnext),(r-=i)?(o.window.set(e.subarray(n-r,n),0),o.wnext=r,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whaveI(t,15)),t.exports.inflateInit2=I,t.exports.inflate=((t,e)=>{let n,v,S,b,I,k,O,N,L,x,D,R,A,U,P,B,C,M,z,j,H,Z,V=0;const Y=new Uint8Array(4);let W,X;const q=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(E(t)||!t.output||!t.input&&0!==t.avail_in)return l;16191===(n=t.state).mode&&(n.mode=16192),I=t.next_out,S=t.output,O=t.avail_out,b=t.next_in,v=t.input,k=t.avail_in,N=n.hold,L=n.bits,x=k,D=O,Z=f;t:for(;;)switch(n.mode){case 16180:if(0===n.wrap){n.mode=16192;break}for(;L<16;){if(0===k)break t;k--,N+=v[b++]<>>8&255,n.check=i(n.check,Y,2,0),N=0,L=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&N)<<8)+(N>>8))%31){t.msg="incorrect header check",n.mode=w;break}if((15&N)!==m){t.msg="unknown compression method",n.mode=w;break}if(L-=4,H=8+(15&(N>>>=4)),0===n.wbits&&(n.wbits=H),H>15||H>n.wbits){t.msg="invalid window size",n.mode=w;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(Y[0]=255&N,Y[1]=N>>>8&255,n.check=i(n.check,Y,2,0)),N=0,L=0,n.mode=16182;case 16182:for(;L<32;){if(0===k)break t;k--,N+=v[b++]<>>8&255,Y[2]=N>>>16&255,Y[3]=N>>>24&255,n.check=i(n.check,Y,4,0)),N=0,L=0,n.mode=16183;case 16183:for(;L<16;){if(0===k)break t;k--,N+=v[b++]<>8),512&n.flags&&4&n.wrap&&(Y[0]=255&N,Y[1]=N>>>8&255,n.check=i(n.check,Y,2,0)),N=0,L=0,n.mode=16184;case 16184:if(1024&n.flags){for(;L<16;){if(0===k)break t;k--,N+=v[b++]<>>8&255,n.check=i(n.check,Y,2,0)),N=0,L=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&((R=n.length)>k&&(R=k),R&&(n.head&&(H=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(v.subarray(b,b+R),H)),512&n.flags&&4&n.wrap&&(n.check=i(n.check,v,R,b)),k-=R,b+=R,n.length-=R),n.length))break t;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===k)break t;R=0;do{H=v[b+R++],n.head&&H&&n.length<65536&&(n.head.name+=String.fromCharCode(H))}while(H&&R>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=16191;break;case 16189:for(;L<32;){if(0===k)break t;k--,N+=v[b++]<>>=7&L,L-=7&L,n.mode=16206;break}for(;L<3;){if(0===k)break t;k--,N+=v[b++]<>>=1)){case 0:n.mode=16193;break;case 1:if(F(n),n.mode=16199,e===u){N>>>=2,L-=2;break t}break;case 2:n.mode=16196;break;case 3:t.msg="invalid block type",n.mode=w}N>>>=2,L-=2;break;case 16193:for(N>>>=7&L,L-=7&L;L<32;){if(0===k)break t;k--,N+=v[b++]<>>16^65535)){t.msg="invalid stored block lengths",n.mode=w;break}if(n.length=65535&N,N=0,L=0,n.mode=16194,e===u)break t;case 16194:n.mode=16195;case 16195:if(R=n.length){if(R>k&&(R=k),R>O&&(R=O),0===R)break t;S.set(v.subarray(b,b+R),I),k-=R,b+=R,O-=R,I+=R,n.length-=R;break}n.mode=16191;break;case 16196:for(;L<14;){if(0===k)break t;k--,N+=v[b++]<>>=5,L-=5,n.ndist=1+(31&N),N>>>=5,L-=5,n.ncode=4+(15&N),N>>>=4,L-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=w;break}n.have=0,n.mode=16197;case 16197:for(;n.have>>=3,L-=3}for(;n.have<19;)n.lens[q[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,W={bits:n.lenbits},Z=s(0,n.lens,0,19,n.lencode,0,n.work,W),n.lenbits=W.bits,Z){t.msg="invalid code lengths set",n.mode=w;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>16&255,C=65535&V,!((P=V>>>24)<=L);){if(0===k)break t;k--,N+=v[b++]<>>=P,L-=P,n.lens[n.have++]=C;else{if(16===C){for(X=P+2;L>>=P,L-=P,0===n.have){t.msg="invalid bit length repeat",n.mode=w;break}H=n.lens[n.have-1],R=3+(3&N),N>>>=2,L-=2}else if(17===C){for(X=P+3;L>>=P)),N>>>=3,L-=3}else{for(X=P+7;L>>=P)),N>>>=7,L-=7}if(n.have+R>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=w;break}for(;R--;)n.lens[n.have++]=H}}if(n.mode===w)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=w;break}if(n.lenbits=9,W={bits:n.lenbits},Z=s(1,n.lens,0,n.nlen,n.lencode,0,n.work,W),n.lenbits=W.bits,Z){t.msg="invalid literal/lengths set",n.mode=w;break}if(n.distbits=6,n.distcode=n.distdyn,W={bits:n.distbits},Z=s(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,W),n.distbits=W.bits,Z){t.msg="invalid distances set",n.mode=w;break}if(n.mode=16199,e===u)break t;case 16199:n.mode=16200;case 16200:if(k>=6&&O>=258){t.next_out=I,t.avail_out=O,t.next_in=b,t.avail_in=k,n.hold=N,n.bits=L,o(t,D),I=t.next_out,S=t.output,O=t.avail_out,b=t.next_in,v=t.input,k=t.avail_in,N=n.hold,L=n.bits,16191===n.mode&&(n.back=-1);break}for(n.back=0;B=(V=n.lencode[N&(1<>>16&255,C=65535&V,!((P=V>>>24)<=L);){if(0===k)break t;k--,N+=v[b++]<>M)])>>>16&255,C=65535&V,!(M+(P=V>>>24)<=L);){if(0===k)break t;k--,N+=v[b++]<>>=M,L-=M,n.back+=M}if(N>>>=P,L-=P,n.back+=P,n.length=C,0===B){n.mode=16205;break}if(32&B){n.back=-1,n.mode=16191;break}if(64&B){t.msg="invalid literal/length code",n.mode=w;break}n.extra=15&B,n.mode=16201;case 16201:if(n.extra){for(X=n.extra;L>>=n.extra,L-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;B=(V=n.distcode[N&(1<>>16&255,C=65535&V,!((P=V>>>24)<=L);){if(0===k)break t;k--,N+=v[b++]<>M)])>>>16&255,C=65535&V,!(M+(P=V>>>24)<=L);){if(0===k)break t;k--,N+=v[b++]<>>=M,L-=M,n.back+=M}if(N>>>=P,L-=P,n.back+=P,64&B){t.msg="invalid distance code",n.mode=w;break}n.offset=C,n.extra=15&B,n.mode=16203;case 16203:if(n.extra){for(X=n.extra;L>>=n.extra,L-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=w;break}n.mode=16204;case 16204:if(0===O)break t;if(R=D-O,n.offset>R){if((R=n.offset-R)>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=w;break}R>n.wnext?(R-=n.wnext,A=n.wsize-R):A=n.wnext-R,R>n.length&&(R=n.length),U=n.window}else U=S,A=I-n.offset,R=n.length;R>O&&(R=O),O-=R,n.length-=R;do{S[I++]=U[A++]}while(--R);0===n.length&&(n.mode=16200);break;case 16205:if(0===O)break t;S[I++]=n.length,O--,n.mode=16200;break;case 16206:if(n.wrap){for(;L<32;){if(0===k)break t;k--,N|=v[b++]<{if(E(t))return l;let e=t.state;return e.window&&(e.window=null),t.state=null,f}),t.exports.inflateGetHeader=((t,e)=>{if(E(t))return l;const n=t.state;return 0==(2&n.wrap)?l:(n.head=e,e.done=!1,f)}),t.exports.inflateSetDictionary=((t,e)=>{const n=e.length;let i,o,s;return E(t)?l:0!==(i=t.state).wrap&&16190!==i.mode?l:16190===i.mode&&(o=r(o=1,e,n,0))!==i.check?d:(s=T(t,e,n,n))?(i.mode=16210,y):(i.havedict=1,f)}),t.exports.inflateInfo="pako inflate (from Nodeca project)"},function(t,e,n){"use strict";t.exports=((t,e,n,r)=>{let i=65535&t|0,o=t>>>16&65535|0,s=0;for(;0!==n;){n-=s=n>2e3?2e3:n;do{o=o+(i=i+e[r++]|0)|0}while(--s);i%=65521,o%=65521}return i|o<<16|0})},function(t,e,n){"use strict";const r=new Uint32Array((()=>{let t,e=[];for(var n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e})());t.exports=((t,e,n,i)=>{const o=r,s=i+n;t^=-1;for(let n=i;n>>8^o[255&(t^e[n])];return-1^t})},function(t,e,n){"use strict";t.exports=function(t,e){let n,r,i,o,s,a,c,u,f,h,p,l,d,y,g,m,w,_,E,v,S,b,I,k;const O=t.state;n=t.next_in,I=t.input,r=n+(t.avail_in-5),i=t.next_out,k=t.output,o=i-(e-t.avail_out),s=i+(t.avail_out-257),a=O.dmax,c=O.wsize,u=O.whave,f=O.wnext,h=O.window,p=O.hold,l=O.bits,d=O.lencode,y=O.distcode,g=(1<>>=_=w>>>24,l-=_,0===(_=w>>>16&255))k[i++]=65535&w;else{if(!(16&_)){if(0==(64&_)){w=d[(65535&w)+(p&(1<<_)-1)];continue e}if(32&_){O.mode=16191;break t}t.msg="invalid literal/length code",O.mode=16209;break t}E=65535&w,(_&=15)&&(l<_&&(p+=I[n++]<>>=_,l-=_),l<15&&(p+=I[n++]<>>=_=w>>>24,l-=_,!(16&(_=w>>>16&255))){if(0==(64&_)){w=y[(65535&w)+(p&(1<<_)-1)];continue n}t.msg="invalid distance code",O.mode=16209;break t}if(v=65535&w,l<(_&=15)&&(p+=I[n++]<a){t.msg="invalid distance too far back",O.mode=16209;break t}if(p>>>=_,l-=_,v>(_=i-o)){if((_=v-_)>u&&O.sane){t.msg="invalid distance too far back",O.mode=16209;break t}if(S=0,b=h,0===f){if(S+=c-_,_2;)k[i++]=b[S++],k[i++]=b[S++],k[i++]=b[S++],E-=3;E&&(k[i++]=b[S++],E>1&&(k[i++]=b[S++]))}else{S=i-v;do{k[i++]=k[S++],k[i++]=k[S++],k[i++]=k[S++],E-=3}while(E>2);E&&(k[i++]=k[S++],E>1&&(k[i++]=k[S++]))}break}}break}}while(n>3,p&=(1<<(l-=E<<3))-1,t.next_in=n,t.next_out=i,t.avail_in=n{const p=h.bits;let l,d,y,g,m,w,_=0,E=0,v=0,S=0,b=0,I=0,k=0,O=0,N=0,F=0,T=null;const L=new Uint16Array(16),x=new Uint16Array(16);let D,R,A,U=null;for(_=0;_<=15;_++)L[_]=0;for(E=0;E=1&&0===L[S];S--);if(b>S&&(b=S),0===S)return c[u++]=20971520,c[u++]=20971520,h.bits=1,0;for(v=1;v0&&(0===t||1!==S))return-1;for(x[1]=0,_=1;_<15;_++)x[_+1]=x[_]+L[_];for(E=0;E852||2===t&&N>592)return 1;for(;;){D=_-k,f[E]+1=w?(R=U[f[E]-w],A=T[f[E]-w]):(R=96,A=0),l=1<<_-k,v=d=1<>k)+(d-=l)]=D<<24|R<<16|A|0}while(0!==d);for(l=1<<_-1;F&l;)l>>=1;if(0!==l?(F&=l-1,F+=l):F=0,E++,0==--L[_]){if(_===S)break;_=e[n+f[E]]}if(_>b&&(F&g)!==y){for(0===k&&(k=b),m+=v,O=1<<(I=_-k);I+k852||2===t&&N>592)return 1;c[y=F&g]=b<<24|I<<16|m-u|0}}return 0!==F&&(c[m+F]=_-k<<24|64<<16|0),h.bits=b,0})},function(t,e,n){"use strict";const r=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);t.exports.assign=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const e in n)r(n,e)&&(t[e]=n[e])}}return t},t.exports.flattenChunks=(t=>{let e=0;for(let n=0,r=t.length;n=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;i[254]=i[254]=1,t.exports.string2buf=(t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,n,r,i,o,s=t.length,a=0;for(i=0;i>>6,e[o++]=128|63&n):n<65536?(e[o++]=224|n>>>12,e[o++]=128|n>>>6&63,e[o++]=128|63&n):(e[o++]=240|n>>>18,e[o++]=128|n>>>12&63,e[o++]=128|n>>>6&63,e[o++]=128|63&n);return e});t.exports.buf2string=((t,e)=>{const n=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let o,s;const a=new Array(2*n);for(s=0,o=0;o4)a[s++]=65533,o+=r-1;else{for(e&=2===r?31:3===r?15:7;r>1&&o1?a[s++]=65533:e<65536?a[s++]=e:(e-=65536,a[s++]=55296|e>>10&1023,a[s++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&r)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let n="";for(let r=0;r{(e=e||t.length)>t.length&&(e=t.length);let n=e-1;for(;n>=0&&128==(192&t[n]);)n--;return n<0?e:0===n?e:n+i[t[n]]>e?n:e})},function(t,e,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},function(t,e,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},function(t,e,n){"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}}])}); //# sourceMappingURL=browserfs.min.js.map