"use strict";Object.defineProperty(exports,"__esModule",{value:!0});varr=Symbol?Symbol("__ES6-PROMISIFY--CUSTOM-ARGUMENTS__"):"__ES6-PROMISIFY--CUSTOM-ARGUMENTS__";functiono(e){if("function"!=typeofe)thrownewTypeError("Argument to promisify must be a function");varn=e[r],t=o.Promise||Promise;if("function"!=typeoft)thrownewError("No Promise implementation found; do you need a polyfill?");returnfunction(){for(varr=this,o=arguments.length,i=Array(o),f=0;f<o;f++)i[f]=arguments[f];returnnewt(function(o,t){i.push(function(r){if(r)returnt(r);for(vare=arguments.length,i=Array(e>1?e-1:0),f=1;f<e;f++)i[f-1]=arguments[f];if(1===i.length||!n)returno(i[0]);varu={};i.forEach(function(r,o){vare=n[o];e&&(u[e]=r)}),o(u)}),e.call.apply(e,[r].concat(i))})}}o.argumentNames=r,o.Promise=void0,exports.promisify=o;
vart={};["9:EBADF:bad file descriptor","10:EBUSY:resource busy or locked","18:EINVAL:invalid argument","27:ENOTDIR:not a directory","28:EISDIR:illegal operation on a directory","34:ENOENT:no such file or directory","47:EEXIST:file already exists","50:EPERM:operation not permitted","51:ELOOP:too many symbolic links encountered","53:ENOTEMPTY:directory not empty","55:EIO:i/o error","1000:ENOTMOUNTED:not mounted","1001:EFILESYSTEMERROR:missing super node, use 'FORMAT' flag to format filesystem.","1002:ENOATTR:attribute does not exist"].forEach(function(e){varo=+(e=e.split(":"))[0],r=e[1],i=e[2];functions(t,e){Error.call(this),this.name=r,this.code=r,this.errno=o,this.message=t||i,e&&(this.path=e),this.stack=newError(this.message).stack}s.prototype=Object.create(Error.prototype),s.prototype.constructor=s,s.prototype.toString=function(){vart=this.path?", '"+this.path+"'":"";returnthis.name+": "+this.message+t},t[r]=t[o]=s}),module.exports=t;
"use strict";exports.byteLength=u,exports.toByteArray=i,exports.fromByteArray=d;for(varr=[],t=[],e="undefined"!=typeofUint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,a=n.length;o<a;++o)r[o]=n[o],t[n.charCodeAt(o)]=o;functionh(r){vart=r.length;if(t%4>0)thrownewError("Invalid string. Length must be a multiple of 4");vare=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}functionu(r){vart=h(r),e=t[0],n=t[1];return3*(e+n)/4-n}functionc(r,t,e){return3*(t+e)/4-e}functioni(r){for(varn,o=h(r),a=o[0],u=o[1],i=newe(c(r,a,u)),f=0,A=u>0?a-4:a,d=0;d<A;d+=4)n=t[r.charCodeAt(d)]<<18|t[r.charCodeAt(d+1)]<<12|t[r.charCodeAt(d+2)]<<6|t[r.charCodeAt(d+3)],i[f++]=n>>16&255,i[f++]=n>>8&255,i[f++]=255&n;return2===u&&(n=t[r.charCodeAt(d)]<<2|t[r.charCodeAt(d+1)]>>4,i[f++]=255&n),1===u&&(n=t[r.charCodeAt(d)]<<10|t[r.charCodeAt(d+1)]<<4|t[r.charCodeAt(d+2)]>>2,i[f++]=n>>8&255,i[f++]=255&n),i}functionf(t){returnr[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}functionA(r,t,e){for(varn,o=[],a=t;a<e;a+=3)n=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(255&r[a+2]),o.push(f(n));returno.join("")}functiond(t){for(vare,n=t.length,o=n%3,a=[],h=0,u=n-o;h<u;h+=16383)a.push(A(t,h,h+16383>u?u:h+16383));return1===o?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),a.join("")}t["-".charCodeAt(0)]=62,t["_".charCodeAt(0)]=63;
vart=arguments[3],r=require("base64-js"),e=require("ieee754"),n=require("isarray");functioni(){try{vart=newUint8Array(1);returnt.__proto__={__proto__:Uint8Array.prototype,foo:function(){return42}},42===t.foo()&&"function"==typeoft.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}functiono(){returnf.TYPED_ARRAY_SUPPORT?2147483647:1073741823}functionu(t,r){if(o()<r)thrownewRangeError("Invalid typed array length");returnf.TYPED_ARRAY_SUPPORT?(t=newUint8Array(r)).__proto__=f.prototype:(null===t&&(t=newf(r)),t.length=r),t}functionf(t,r,e){if(!(f.TYPED_ARRAY_SUPPORT||thisinstanceoff))returnnewf(t,r,e);if("number"==typeoft){if("string"==typeofr)thrownewError("If encoding is specified then the first argument must be a string");returnc(this,t)}returns(this,t,r,e)}functions(t,r,e,n){if("number"==typeofr)thrownewTypeError('"value" argument must not be a number');return"undefined"!=typeofArrayBuffer&&rinstanceofArrayBuffer?g(t,r,e,n):"string"==typeofr?l(t,r,e):y(t,r)}functionh(t){if("number"!=typeoft)thrownewTypeError('"size" argument must be a number');if(t<0)thrownewRangeError('"size" argument must not be negative')}functiona(t,r,e,n){returnh(r),r<=0?u(t,r):void0!==e?"string"==typeofn?u(t,r).fill(e,n):u(t,r).fill(e):u(t,r)}functionc(t,r){if(h(r),t=u(t,r<0?0:0|w(r)),!f.TYPED_ARRAY_SUPPORT)for(vare=0;e<r;++e)t[e]=0;returnt}functionl(t,r,e){if("string"==typeofe&&""!==e||(e="utf8"),!f.isEncoding(e))thrownewTypeError('"encoding" must be a valid string encoding');varn=0|v(r,e),i=(t=u(t,n)).write(r,e);returni!==n&&(t=t.slice(0,i)),t}functionp(t,r){vare=r.length<0?0:0|w(r.length);t=u(t,e);for(varn=0;n<e;n+=1)t[n]=255&r[n];returnt}functiong(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)thrownewRangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))thrownewRangeError("'length' is out of bounds");returnr=void0===e&&void0===n?newUint8Array(r):void0===n?newUint8Array(r,e):newUint8Array(r,e,n),f.TYPED_ARRAY_SUPPORT?(t=r).__proto__=f.prototype:t=p(t,r),t}functiony(t,r){if(f.isBuffer(r)){vare=0|w(r.length);return0===(t=u(t,e)).length?t:(r.copy(t,0,0,e),t)}if(r){if("undefined"!=typeofArrayBuffer&&r.bufferinstanceofArrayBuffer||"length"inr)return"number"!=typeofr.length||W(r.length)?u(t,0):p(t,r);if("Buffer"===r.type&&n(r.data))returnp(t,r.data)}thrownewTypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}functionw(t){if(t>=o())thrownewRangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return0|t}functiond(t){return+t!=t&&(t=0),f.alloc(+t)}functionv(t,r){if(f.isBuffer(t))returnt.length;if("undefined"!=typeofArrayBuffer&&"function"==typeofArrayBuffer.isView&&(ArrayBuffer.isView(t)||tinstanceofArrayBuffer))returnt.byteLength;"string"!=typeoft&&(t=""+t);vare=t.length;if(0===e)return0;for(varn=!1;;)switch(r){case"ascii":case"latin1":case"binary":returne;case"utf8":case"utf-8":casevoid0:return$(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return2*e;case"hex":returne>>>1;case"base64":returnK(t).length;default:if(n)return$(t).length;r=(""+r).toLowerCase(),n=!0}}functionE(t,r,e){varn=!1;if((void0===r||r<0)&&(r=0),r>this.length)return"";if((void0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":returnx(this,r,e);case"utf8":case"utf-8":returnY(this,r,e);case"ascii":returnL(this,r,e);case"latin1":case"binary":returnD(this,r,e);case"base64":returnS(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":returnC(this,r,e);default:if(n)thrownewTypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}functionb(t,r,e){varn=t[r];t[r]=t[e],t[e]=n}functionR(t,r,e,n,i){if(0===t.length)return-1;if("string"==typeofe?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}elseif(e<0){if(!i)return-1;e=0}if("string"==typeofr&&(r=f.from(r,n)),f.
vart=arguments[3],n=require("../constants.js").FILE_SYSTEM_NAME,e=require("../constants.js").FILE_STORE_NAME,i=require("../constants.js").WSQL_VERSION,o=require("../constants.js").WSQL_SIZE,r=require("../constants.js").WSQL_DESC,u=require("../errors.js"),a=require("../buffer.js"),c=require("base64-arraybuffer");functions(t,n){vare=this;this.getTransaction=function(i){e.transaction?i(e.transaction):t[n?"readTransaction":"transaction"](function(t){e.transaction=t,i(t)})}}functionf(t,n,i){functiono(t,n){vare=0===n.rows.length?null:n.rows.item(0).data;i(null,e)}functionr(t,n){i(n)}t(function(t){t.executeSql("SELECT data FROM "+e+" WHERE id = ? LIMIT 1;",[n],o,r)})}functionE(t,n,i,o){functionr(){o(null)}functionu(t,n){o(n)}t(function(t){t.executeSql("INSERT OR REPLACE INTO "+e+" (id, data) VALUES (?, ?);",[n,i],r,u)})}functiond(t){this.name=t||n,this.db=null}s.prototype.clear=function(t){functionn(n,e){t(e)}functioni(){t(null)}this.getTransaction(function(t){t.executeSql("DELETE FROM "+e+";",[],i,n)})},s.prototype.getObject=function(t,n){f(this.getTransaction,t,function(t,e){if(t)returnn(t);try{e&&(e=JSON.parse(e))}catch(t){returnn(t)}n(null,e)})},s.prototype.getBuffer=function(t,n){f(this.getTransaction,t,function(t,e){if(t)returnn(t);if(e||""===e){vari=c.decode(e);e=newa(i)}n(null,e)})},s.prototype.putObject=function(t,n,e){vari=JSON.stringify(n);E(this.getTransaction,t,i,e)},s.prototype.putBuffer=function(t,n,e){vari=c.encode(n.buffer);E(this.getTransaction,t,i,e)},s.prototype.delete=function(t,n){functioni(){n(null)}functiono(t,e){n(e)}this.getTransaction(function(n){n.executeSql("DELETE FROM "+e+" WHERE id = ?;",[t],i,o)})},d.isSupported=function(){return!!t.openDatabase},d.prototype.open=function(n){vara=this;if(a.db)returnn();varc=t.openDatabase(a.name,i,r,o);functions(t,e){5===e.code&&n(newu.EINVAL("WebSQL cannot be accessed. If private browsing is enabled, disable it.")),n(e)}functionf(){a.db=c,n()}c?c.transaction(function(t){t.executeSql("CREATE TABLE IF NOT EXISTS "+e+" (id unique, data TEXT);",[],function(t){t.executeSql("CREATE INDEX IF NOT EXISTS idx_"+e+"_id on "+e+" (id);",[],f,s)},s)}):n("[WebSQL] Unable to open database.")},d.prototype.getReadOnlyContext=function(){returnnews(this.db,!0)},d.prototype.getReadWriteContext=function(){returnnews(this.db,!1)},module.exports=d;
vart,e,n=module.exports={};functionr(){thrownewError("setTimeout has not been defined")}functiono(){thrownewError("clearTimeout has not been defined")}functioni(e){if(t===setTimeout)returnsetTimeout(e,0);if((t===r||!t)&&setTimeout)returnt=setTimeout,setTimeout(e,0);try{returnt(e,0)}catch(n){try{returnt.call(null,e,0)}catch(n){returnt.call(this,e,0)}}}functionu(t){if(e===clearTimeout)returnclearTimeout(t);if((e===o||!e)&&clearTimeout)returne=clearTimeout,clearTimeout(t);try{returne(t)}catch(n){try{returne.call(null,t)}catch(n){returne.call(this,t)}}}!function(){try{t="function"==typeofsetTimeout?setTimeout:r}catch(e){t=r}try{e="function"==typeofclearTimeout?clearTimeout:o}catch(t){e=o}}();varc,s=[],l=!1,a=-1;functionf(){l&&c&&(l=!1,c.length?s=c.concat(s):a=-1,s.length&&h())}functionh(){if(!l){vart=i(f);l=!0;for(vare=s.length;e;){for(c=s,s=[];++a<e;)c&&c[a].run();a=-1,e=s.length}c=null,l=!1,u(t)}}functionm(t,e){this.fun=t,this.array=e}functionp(){}n.nextTick=function(t){vare=newArray(arguments.length-1);if(arguments.length>1)for(varn=1;n<arguments.length;n++)e[n-1]=arguments[n];s.push(newm(t,e)),1!==s.length||l||i(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(t){return[]},n.binding=function(t){thrownewError("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){thrownewError("process.chdir is not supported")},n.umask=function(){return0};
vart=require("../constants.js").FILE_SYSTEM_NAME,e=require("../../lib/async.js").setImmediate,o=function(){vart={};returnfunction(e){returnt.hasOwnProperty(e)||(t[e]={}),t[e]}}();functionn(t,e){this.readOnly=e,this.objectStore=t}functionr(e){this.name=e||t}n.prototype.clear=function(t){if(this.readOnly)e(function(){t("[MemoryContext] Error: write operation on read only context")});else{varo=this.objectStore;Object.keys(o).forEach(function(t){deleteo[t]}),e(t)}},n.prototype.getObject=n.prototype.getBuffer=function(t,o){varn=this;e(function(){o(null,n.objectStore[t])})},n.prototype.putObject=n.prototype.putBuffer=function(t,o,n){this.readOnly?e(function(){n("[MemoryContext] Error: write operation on read only context")}):(this.objectStore[t]=o,e(n))},n.prototype.delete=function(t,o){this.readOnly?e(function(){o("[MemoryContext] Error: write operation on read only context")}):(deletethis.objectStore[t],e(o))},r.isSupported=function(){return!0},r.prototype.open=function(t){this.db=o(this.name),e(t)},r.prototype.getReadOnlyContext=function(){returnnewn(this.db,!0)},r.prototype.getReadWriteContext=function(){returnnewn(this.db,!1)},module.exports=r;
varr=require("./indexeddb.js"),e=require("./websql.js"),o=require("./memory.js");module.exports={IndexedDB:r,WebSQL:e,Memory:o,Default:r,Fallback:function(){if(r.isSupported())returnr;if(e.isSupported())returne;functiono(){throw"[Filer Error] Your browser doesn't support IndexedDB or WebSQL."}returno.isSupported=function(){return!1},o}()};
varr=require("process");functiont(r,t){for(vare=0,n=r.length-1;n>=0;n--){vars=r[n];"."===s?r.splice(n,1):".."===s?(r.splice(n,1),e++):e&&(r.splice(n,1),e--)}if(t)for(;e--;e)r.unshift("..");returnr}vare=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,n=function(r){returne.exec(r).slice(1)};functions(r,t){if(r.filter)returnr.filter(t);for(vare=[],n=0;n<r.length;n++)t(r[n],n,r)&&e.push(r[n]);returne}exports.resolve=function(){for(vare="",n=!1,o=arguments.length-1;o>=-1&&!n;o--){vari=o>=0?arguments[o]:r.cwd();if("string"!=typeofi)thrownewTypeError("Arguments to path.resolve must be strings");i&&(e=i+"/"+e,n="/"===i.charAt(0))}return(n?"/":"")+(e=t(s(e.split("/"),function(r){return!!r}),!n).join("/"))||"."},exports.normalize=function(r){vare=exports.isAbsolute(r),n="/"===o(r,-1);return(r=t(s(r.split("/"),function(r){return!!r}),!e).join("/"))||e||(r="."),r&&n&&(r+="/"),(e?"/":"")+r},exports.isAbsolute=function(r){return"/"===r.charAt(0)},exports.join=function(){varr=Array.prototype.slice.call(arguments,0);returnexports.normalize(s(r,function(r,t){if("string"!=typeofr)thrownewTypeError("Arguments to path.join must be strings");returnr}).join("/"))},exports.relative=function(r,t){functione(r){for(vart=0;t<r.length&&""===r[t];t++);for(vare=r.length-1;e>=0&&""===r[e];e--);returnt>e?[]:r.slice(t,e-t+1)}r=exports.resolve(r).substr(1),t=exports.resolve(t).substr(1);for(varn=e(r.split("/")),s=e(t.split("/")),o=Math.min(n.length,s.length),i=o,u=0;u<o;u++)if(n[u]!==s[u]){i=u;break}varl=[];for(u=i;u<n.length;u++)l.push("..");return(l=l.concat(s.slice(i))).join("/")},exports.sep="/",exports.delimiter=":",exports.dirname=function(r){vart=n(r),e=t[0],s=t[1];returne||s?(s&&(s=s.substr(0,s.length-1)),e+s):"."},exports.basename=function(r,t){vare=n(r)[2];returnt&&e.substr(-1*t.length)===t&&(e=e.substr(0,e.length-t.length)),e},exports.extname=function(r){returnn(r)[3]};varo="b"==="ab".substr(-1)?function(r,t,e){returnr.substr(t,e)}:function(r,t,e){returnt<0&&(t=r.length+t),r.substr(t,e)};
vare=require("../lib/eventemitter.js"),t=require("./path.js"),n=require("../lib/intercom.js");functionr(){e.call(this);varr,i,o=this,s=!1;functionc(e){(i===e||s&&0===e.indexOf(r))&&o.trigger("change","change",e)}o.start=function(e,o,a){if(!i){if(t.isNull(e))thrownewError("Path must be a string without null bytes.");i=t.normalize(e),(s=!0===a)&&(r="/"===i?"/":i+"/"),n.getInstance().on("change",c)}},o.close=function(){n.getInstance().off("change",c),o.removeAllListeners("change")}}r.prototype=newe,r.prototype.constructor=r,module.exports=r;
varn=require("../../lib/nodash.js"),e=require("../path.js"),t=e.normalize,i=e.dirname,o=e.basename,a=e.isAbsolute,u=e.isNull,r=require("../constants.js"),c=r.NODE_TYPE_FILE,f=r.NODE_TYPE_DIRECTORY,s=r.NODE_TYPE_SYMBOLIC_LINK,l=r.NODE_TYPE_META,d=r.FULL_READ_WRITE_EXEC_PERMISSIONS,p=r.ROOT_DIRECTORY_NAME,m=r.SUPER_NODE_ID,E=r.SYMLOOP_MAX,w=r.O_READ,g=r.O_WRITE,b=r.O_CREATE,O=r.O_EXCLUSIVE,v=r.O_APPEND,N=r.O_FLAGS,h=r.XATTR_CREATE,I=r.XATTR_REPLACE,A=r.FS_NOMTIME,y=r.FS_NOCTIME,D=require("../encoding.js"),T=require("../errors.js"),j=require("../directory-entry.js"),L=require("../open-file-description.js"),R=require("../super-node.js"),_=require("../node.js"),V=require("../stats.js"),F=require("../buffer.js"),B=require("../shared.js"),x=B.validateInteger;functionS(e,t,i,o,a){varu=e.flags;n(u).contains(y)&&deleteo.ctime,n(u).contains(A)&&deleteo.mtime;varr=!1;functionc(n){e.changes.push({event:"change",path:t}),a(n)}o.ctime&&(i.ctime=o.ctime,i.atime=o.ctime,r=!0),o.atime&&(i.atime=o.atime,r=!0),o.mtime&&(i.mtime=o.mtime,r=!0),r?e.putObject(i.id,i,c):c()}functionP(n,e,a,u){if(a!==f&&a!==c)returnu(newT.EINVAL("type must be a directory or file",e));e=t(e);varr,s,l,d=o(e),p=i(e);functionm(t,i){!t&&i?u(newT.EEXIST("path name already exists",e)):!t||tinstanceofT.ENOENT?n.getObject(r.data,E):u(t)}functionE(e,t){e?u(e):(s=t,_.create({guid:n.guid,type:a},function(e,t){e?u(e):((l=t).nlinks+=1,n.putObject(l.id,l,g))}))}functionw(e){if(e)u(e);else{vart=Date.now();S(n,p,l,{mtime:t,ctime:t},u)}}functiong(e){e?u(e):(s[d]=newj(l.id,a),n.putObject(r.data,s,w))}k(n,p,function(t,i){t?u(t):i.type!==f?u(newT.ENOTDIR("a component of the path prefix is not a directory",e)):(r=i,k(n,e,m))})}functionk(e,a,u){if(!(a=t(a)))returnu(newT.ENOENT("path is an empty string"));varr=o(a),c=i(a),d=0;functionw(n,t){n?u(n):t&&t.type===l&&t.rnode?e.getObject(t.rnode,g):u(newT.EFILESYSTEMERROR)}functiong(n,e){n?u(n):e?u(null,e):u(newT.ENOENT)}functionb(n,t){n?u(n):t.type===f&&t.data?e.getObject(t.data,O):u(newT.ENOTDIR("a component of the path prefix is not a directory",a))}functionO(t,i){if(t)u(t);elseif(n(i).has(r)){varo=i[r].id;e.getObject(o,v)}elseu(newT.ENOENT(null,a))}functionv(n,f){varl;n?u(n):f.type===s?++d>E?u(newT.ELOOP(null,a)):(l=f.data,l=t(l),c=i(l),r=o(l),p===r?e.getObject(m,w):k(e,c,b)):u(null,f)}p===r?e.getObject(m,w):k(e,c,b)}functionC(n,e,t,i,o,a,u){varr=t.xattrs;a===h&&r.hasOwnProperty(i)?u(newT.EEXIST("attribute already exists",e)):a!==I||r.hasOwnProperty(i)?(r[i]=o,n.putObject(t.id,t,function(i){i?u(i):S(n,e,t,{ctime:Date.now()},u)})):u(newT.ENOATTR(null,e))}functionX(n,e){vart,i,o;functiona(o){o?e(o):_.create({guid:n.guid,id:t.rnode,type:f},function(t,o){t?e(t):((i=o).nlinks+=1,n.putObject(i.id,i,u))})}functionu(t){t?e(t):(o={},n.putObject(i.data,o,e))}n.getObject(m,function(i,o){!i&&o?e():!i||iinstanceofT.ENOENT?R.create({guid:n.guid},function(i,o){i?e(i):(t=o,n.putObject(t.id,t,a))}):e(i)})}functionM(n,e,a){e=t(e);varu,r,c,s,l=o(e),d=i(e);functionp(e,t){e?a(e):(c=t,n.getObject(c.data,m))}functionm(e,t){e?a(e):(s=t,_.create({guid:n.guid,type:f},function(e,t){e?a(e):((u=t).nlinks+=1,n.putObject(u.id,u,E))}))}functionE(e){e?a(e):(r={},n.putObject(u.data,r,g))}functionw(e){if(e)a(e);else{vart=Date.now();S(n,d,c,{mtime:t,ctime:t},a)}}functiong(e){e?a(e):(s[l]=newj(u.id,f),n.putObject(c.data,s,w))}k(n,e,function(t,i){!t&&i?a(newT.EEXIST(null,e)):!t||tinstanceofT.ENOENT?k(n,d,p):a(t)})}functionq(e,a,u){a=t(a);varr,c,s,l=o(a),d=i(a);functionm(t,i){t?u(t):p===l?u(newT.EBUSY(null,a)):n(i).has(l)?(r=(s=i)[l].id,e.getObject(r,E)):u(newT.ENOENT(null,a))}functionE(n,t){n?u(n):t.type!==f?u(newT.ENOTDIR(null,a)):(r=t,e.getObject(r.data,w))}functionw(t,i){t?u(t):n(i).size()>0?u(newT.ENOTEMPTY(null,a)):(deletes[l],e.putObject(c.data,s,g))}functiong(n){if(n)u(n);else{vart=Date.now();S(e,d,c,{mtime:t,ctime:t},b)}}functionb(n){n?u(n):e.delete(r.id,O)}functionO(n){n?u(n):e.delete(r.data,u)}k(e,d,function(n,t){n?u(n):(c=t,e.getObject(c.data,m))})}functionz(e,a,u,r){a=t(a);varl,d,m,w,v,N
vare=require("../../lib/nodash.js"),t=require("es6-promisify"),r=t.promisify,n=require("../path.js").isNull,i=require("../shared.js").nop,o=require("../constants.js"),a=o.FILE_SYSTEM_NAME,u=o.FS_FORMAT,s=o.FS_READY,c=o.FS_PENDING,l=o.FS_ERROR,f=o.FS_NODUPEIDCHECK,d=require("../providers/index.js"),p=require("../shell/shell.js"),h=require("../../lib/intercom.js"),v=require("../fs-watcher.js"),m=require("../errors.js"),y=require("../shared.js").guid,R=o.STDIN,g=o.STDOUT,E=o.STDERR,S=o.FIRST_DESCRIPTOR,w=require("./implementation.js");functionx(e){return"function"==typeofe?e:function(e){if(e)throwe}}functionF(e){e&&console.error("Filer error: ",e)}functionq(t,j){j=j||F;varD=(t=t||{}).flags,O=t.guid?t.guid:y,b=t.provider||newd.Default(t.name||a),C=t.name||b.name,T=e(D).contains(u),I=this;I.readyState=c,I.name=C,I.error=null,I.stdin=R,I.stdout=g,I.stderr=E,I.constants=o.fsConstants,this.Shell=p.bind(void0,this);vark={},_=S;Object.defineProperty(this,"openFiles",{get:function(){returnk}}),this.allocDescriptor=function(e){vart=_++;returnk[t]=e,t},this.releaseDescriptor=function(e){deletek[e]};varN=[];functionM(t){returnfunction(r){e(D).contains(f)?r(null,O()):functione(r){varn=O();t.getObject(n,function(t,i){t?r(t):i?e(r):r(null,n)})}(r)}}this.queueOrRun=function(e){vart;returns==I.readyState?e.call(I):l==I.readyState?t=newm.EFILESYSTEMERROR("unknown error"):N.push(e),t},this.watch=function(e,t,r){if(n(e))thrownewError("Path must be a string without null bytes.");"function"==typeoft&&(r=t,t={}),t=t||{},r=r||i;varo=newv;returno.start(e,!1,t.recursive),o.on("change",r),o},b.open(function(e){functiont(e){functiont(e){vart=b[e]();returnt.flags=D,t.changes=[],t.guid=M(t),t.close=function(){vare=t.changes;!function(e){if(e.length){vart=h.getInstance();e.forEach(function(e){t.emit(e.event,e.path)})}}(e),e.length=0},t}I.provider={openReadWriteContext:function(){returnt("getReadWriteContext")},openReadOnlyContext:function(){returnt("getReadOnlyContext")}},I.readyState=e?l:s,N.forEach(function(e){e.call(this)}.bind(I)),N=null,j(e,I)}if(e)returnt(e);varr=b.getReadWriteContext();r.guid=M(r),T?r.clear(function(e){if(e)returnt(e);w.ensureRootDirectory(r,t)}):w.ensureRootDirectory(r,t)}),q.prototype.promises={},["open","chmod","fchmod","chown","fchown","close","mknod","mkdir","rmdir","stat","fstat","link","unlink","read","readFile","write","writeFile","appendFile","exists","lseek","readdir","rename","readlink","symlink","lstat","truncate","ftruncate","utimes","futimes","setxattr","getxattr","fsetxattr","fgetxattr","removexattr","fremovexattr"].forEach(function(e){q.prototype[e]=function(){vart=this,r=Array.prototype.slice.call(arguments,0),n=r.length-1,i="function"!=typeofr[n],o=x(r[n]),a=t.queueOrRun(function(){vara=t.provider.openReadWriteContext();if(l===t.readyState){varu=newm.EFILESYSTEMERROR("filesystem unavailable, operation canceled");returno.call(t,u)}functions(){a.close(),o.apply(t,arguments)}i?r.push(s):r[n]=s;varc=[t,a].concat(r);w[e].apply(null,c)});a&&o(a)},q.prototype.promises[e]=r(q.prototype[e].bind(I))})}q.providers=d,module.exports=q;