diff --git a/.gitignore b/.gitignore
index 92949a4..8ac8783 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@ node_modules/
coverage/
packages/**/dist/
+
+lerna-debug\.log
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 4c895f0..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "packages/wasa"]
- path = packages/wasa
- url = git@github.com:WebAssemblyOS/wasa.git
diff --git a/.travis.yml.bk b/.travis.yml
similarity index 60%
rename from .travis.yml.bk
rename to .travis.yml
index b3540ac..1863a3a 100644
--- a/.travis.yml.bk
+++ b/.travis.yml
@@ -1,3 +1,6 @@
language: node_js
node_js:
- "11"
+
+script:
+ - npm run ci
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 01866b8..7b88fe2 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -4,11 +4,80 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
+ {
+ "type": "node",
+ "request": "attach",
+ "name": "Attach to Remote",
+ "address": "127.0.0.1",
+ "port": 9229,
+ "localRoot": "${workspaceFolder}",
+ "remoteRoot": "Absolute path to the remote directory containing the program"
+ },
+ {
+ "type": "node",
+ "request": "launch",
+ "name": "Launch via NPM",
+ "runtimeExecutable": "npm",
+ "runtimeArgs": [
+ "run-script",
+ "debug"
+ ],
+ "port": 9229
+ },
+ {
+ "type": "node",
+ "request": "launch",
+ "name": "AssemblyScript",
+ "args": [
+ "${workspaceFolder}/packages/assemblyscript/bin/wasm-asc.ts",
+ "echo.ts"
+ ],
+ "runtimeArgs": [
+ "-r",
+ "ts-node/register",
+ "--inspect-brk"
+ ],
+ "cwd": "${workspaceFolder}/packages/assemblyscript"
+ },
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229
- }
+ },
+ {
+ "name": "Jest debug AssemblyScript",
+ "type": "node",
+ "request": "launch",
+ "address": "localhost",
+ "protocol": "inspector",
+ "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/lerna",
+ "runtimeArgs": [
+ "exec",
+ "--scope",
+ "assemblyscript",
+ "--",
+ "node"
+ ],
+ "args": [
+ "${workspaceRoot}/node_modules/jest/bin/jest.js",
+ "--runInBand",
+ "--no-cache",
+ "packages/assemblyscript"
+ ]
+ },
+ {
+ "name": "Jest",
+ "type": "node",
+ "request": "launch",
+ "runtimeExecutable": "node",
+ "args": [
+ "${workspaceRoot}/node_modules/jest/bin/jest.js",
+ "--",
+ "--runInBand",
+ "--no-cache",
+ "${fileDirname}"
+ ]
+ },
]
-}
+}
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..aa65b49
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,4 @@
+{
+ "editor.formatOnSave": true,
+ "typescript.tsdk": "node_modules/typescript/lib"
+}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..0b57da0
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,13 @@
+{
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
+ // for the documentation about the tasks.json format
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "type": "npm",
+ "script": "install",
+ "path": "packages/assemblyscript/",
+ "problemMatcher": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..2d3b01b
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,94 @@
+# Citizen Code of Conduct
+
+## 1. Purpose
+
+A primary goal of Wasmos is to be inclusive to the largest number of contributors, with the most varied and diverse backgrounds possible. As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof).
+
+This code of conduct outlines our expectations for all those who participate in our community, as well as the consequences for unacceptable behavior.
+
+We invite all those who participate in Wasmos to help us create safe and positive experiences for everyone.
+
+## 2. Open [Source/Culture/Tech] Citizenship
+
+A supplemental goal of this Code of Conduct is to increase open [source/culture/tech] citizenship by encouraging participants to recognize and strengthen the relationships between our actions and their effects on our community.
+
+Communities mirror the societies in which they exist and positive action is essential to counteract the many forms of inequality and abuses of power that exist in society.
+
+If you see someone who is making an extra effort to ensure our community is welcoming, friendly, and encourages all participants to contribute to the fullest extent, we want to know.
+
+## 3. Expected Behavior
+
+The following behaviors are expected and requested of all community members:
+
+ * Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community.
+ * Exercise consideration and respect in your speech and actions.
+ * Attempt collaboration before conflict.
+ * Refrain from demeaning, discriminatory, or harassing behavior and speech.
+ * Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential.
+ * Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations.
+
+## 4. Unacceptable Behavior
+
+The following behaviors are considered harassment and are unacceptable within our community:
+
+ * Violence, threats of violence or violent language directed against another person.
+ * Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language.
+ * Posting or displaying sexually explicit or violent material.
+ * Posting or threatening to post other people's personally identifying information ("doxing").
+ * Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability.
+ * Inappropriate photography or recording.
+ * Inappropriate physical contact. You should have someone's consent before touching them.
+ * Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances.
+ * Deliberate intimidation, stalking or following (online or in person).
+ * Advocating for, or encouraging, any of the above behavior.
+ * Sustained disruption of community events, including talks and presentations.
+
+## 5. Weapons Policy
+
+No weapons will be allowed at Wasmos events, community spaces, or in other spaces covered by the scope of this Code of Conduct. Weapons include but are not limited to guns, explosives (including fireworks), and large knives such as those used for hunting or display, as well as any other item used for the purpose of causing injury or harm to others. Anyone seen in possession of one of these items will be asked to leave immediately, and will only be allowed to return without the weapon. Community members are further expected to comply with all state and local laws on this matter.
+
+## 6. Consequences of Unacceptable Behavior
+
+Unacceptable behavior from any community member, including sponsors and those with decision-making authority, will not be tolerated.
+
+Anyone asked to stop unacceptable behavior is expected to comply immediately.
+
+If a community member engages in unacceptable behavior, the community organizers may take any action they deem appropriate, up to and including a temporary ban or permanent expulsion from the community without warning (and without refund in the case of a paid event).
+
+## 7. Reporting Guidelines
+
+If you are subject to or witness unacceptable behavior, or have any other concerns, please notify a community organizer as soon as possible. willem at cs.umd.edu.
+
+
+
+Additionally, community organizers are available to help community members engage with local law enforcement or to otherwise help those experiencing unacceptable behavior feel safe. In the context of in-person events, organizers will also provide escorts as desired by the person experiencing distress.
+
+## 8. Addressing Grievances
+
+If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify WebAssemblyOS with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies.
+
+
+
+## 9. Scope
+
+We expect all community participants (contributors, paid or otherwise; sponsors; and other guests) to abide by this Code of Conduct in all community venues--online and in-person--as well as in all one-on-one communications pertaining to community business.
+
+This code of conduct and its related procedures also applies to unacceptable behavior occurring outside the scope of community activities when such behavior has the potential to adversely affect the safety and well-being of community members.
+
+## 10. Contact info
+
+willem at cs.umd.edu
+
+## 11. License and attribution
+
+The Citizen Code of Conduct is distributed by [Stumptown Syndicate](http://stumptownsyndicate.org) under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/).
+
+Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy).
+
+_Revision 2.3. Posted 6 March 2017._
+
+_Revision 2.2. Posted 4 February 2016._
+
+_Revision 2.1. Posted 23 June 2014._
+
+_Revision 2.0, adopted by the [Stumptown Syndicate](http://stumptownsyndicate.org) board on 10 January 2013. Posted 17 March 2013._
diff --git a/README.md b/README.md
index eb7d4b8..a6b3ad1 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,26 @@
## Wasm OS
-
This is a kernel for running AssemblyScript/WebAssembly applications.
It provides the following.
-0. Synchronous file system
-0. Implements the node `process` module.
-0. Shared Memory between kernel threads to allow for atomic `wait/notify` for syscalls.
-0. Networking interface for P2P applications.
+1. Synchronous file system
+1. Implements the node `process` module.
+1. Shared Memory between kernel threads to allow for atomic `wait/notify` for syscalls.
+1. Networking interface for P2P applications.
+
+## Project Setup
+
+This project is [](https://lernajs.io/), which allows this repo to host multiple project in one repo, making it a "mono-repo." The key idea is that each package in the repo must be a stand alone, but it makes it easy to have them depend on each other and you can use a scoping package name. For example, this project needs a wrapper around the assemblyscript compiler, which is conveniently called `@wasmos/assemblyscript.`
+
+This project also uses a git submodule for `wasa`, a fork of [jedisct1/wasa](https://github.com/jedisct1/wasa), which is a library for interacting with the new [wasi](https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/), WebAssembly Interface, a core API imported by the runtime.
+
+# First step
+
+After cloning,
+```
+npm install
+npm run bootstrap
+```
+
+This installs all of the top level dependencies, e.g. `typescript` and `jest`, and then installs each lerna package. This includes creating symlinks for local dependencies.
diff --git a/as-pect.config.js b/as-pect.config.js
index eb4c824..032ef3b 100644
--- a/as-pect.config.js
+++ b/as-pect.config.js
@@ -2,29 +2,30 @@ module.exports = {
/**
* A set of globs passed to the glob package that qualify typescript files for testing.
*/
- include: ["assembly/__tests__/**/*.spec.ts"],
+ include: [
+ "packages/*/assembly/__tests__/**/*.spec.ts"
+ ],
/**
* A set of globs passed to the glob package that quality files to be added to each test.
*/
- add: ["assembly/__tests__/**/*.include.ts"],
+ add: ["packages/assemblyscript/assembly/__tests__/wasa.include.ts"],
/**
* All the compiler flags needed for this test suite. Make sure that a binary file is output.
*/
flags: {
"--validate": [],
"--debug": [],
- "--measure": [],
/** This is required. Do not change this. */
- "--binaryFile": ["output.wasm"],
+ "--binaryFile": ["output.wasm"]
},
/**
* A set of regexp that will disclude source files from testing.
*/
- disclude: [],
+ disclude: [/packages\/.*node_module/i],
/**
* Add your required AssemblyScript imports here.
*/
- imports: {},
+ imports: {}
/**
* Add a custom reporter here if you want one
*/
diff --git a/assembly/bin/echo.ts b/assembly/bin/echo.ts
deleted file mode 100644
index 8d212e4..0000000
--- a/assembly/bin/echo.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import 'allocator/arena';
-
-export {memory}
-
-export function addHello(s: string): string {
- return "hello ".concat(s);
-}
diff --git a/assembly/fs/index.ts b/assembly/fs/index.ts
deleted file mode 100644
index 880af62..0000000
--- a/assembly/fs/index.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * This is the interface assemblyscript programs will use to access the filesystem.
- */
-
- export class File {
-
- }
-
-declare function open(path: string): File;
-
-declare function close(f: File): void;
-
-declare function write(f: File, c: Uint8Array | string): void;
-
-declare function read(f: File, bytes: number): Uint8Array;
diff --git a/assembly/index.vue b/assembly/index.vue
deleted file mode 100644
index a198560..0000000
--- a/assembly/index.vue
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
diff --git a/assembly/os/index.ts b/assembly/os/index.ts
deleted file mode 100644
index 354f240..0000000
--- a/assembly/os/index.ts
+++ /dev/null
@@ -1,454 +0,0 @@
-// # OS
-//
-//
-//
-// > Stability: 2 - Stable
-//
-// The `os` module provides a number of operating system-related utility methods.
-// It can be accessed using:
-//
-// ```js
-// const os = require('os');
-// ```
-//
-// ## os.EOL
-//
-//
-// * {string}
-//
-// A string constant defining the operating system-specific end-of-line marker:
-//
-// * `\n` on POSIX
-// * `\r\n` on Windows
-//
-// ## os.arch()
-//
-//
-// * Returns: {string}
-//
-// The `os.arch()` method returns a string identifying the operating system CPU
-// architecture for which the Node.js binary was compiled.
-//
-// The current possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,
-// `'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, `'x32'`, and `'x64'`.
-//
-// Equivalent to [`process.arch`][].
-//
-// ## os.constants
-//
-//
-// * {Object}
-//
-// Returns an object containing commonly used operating system specific constants
-// for error codes, process signals, and so on. The specific constants currently
-// defined are described in [OS Constants](#os_os_constants_1).
-//
-// ## os.cpus()
-//
-//
-// * Returns: {Object[]}
-//
-// The `os.cpus()` method returns an array of objects containing information about
-// each logical CPU core.
-//
-// The properties included on each object include:
-//
-// * `model` {string}
-// * `speed` {number} (in MHz)
-// * `times` {Object}
-// * `user` {number} The number of milliseconds the CPU has spent in user mode.
-// * `nice` {number} The number of milliseconds the CPU has spent in nice mode.
-// * `sys` {number} The number of milliseconds the CPU has spent in sys mode.
-// * `idle` {number} The number of milliseconds the CPU has spent in idle mode.
-// * `irq` {number} The number of milliseconds the CPU has spent in irq mode.
-//
-//
-// ```js
-// [
-// {
-// model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
-// speed: 2926,
-// times: {
-// user: 252020,
-// nice: 0,
-// sys: 30340,
-// idle: 1070356870,
-// irq: 0
-// }
-// },
-// {
-// model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
-// speed: 2926,
-// times: {
-// user: 306960,
-// nice: 0,
-// sys: 26980,
-// idle: 1071569080,
-// irq: 0
-// }
-// },
-// {
-// model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
-// speed: 2926,
-// times: {
-// user: 248450,
-// nice: 0,
-// sys: 21750,
-// idle: 1070919370,
-// irq: 0
-// }
-// },
-// {
-// model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
-// speed: 2926,
-// times: {
-// user: 256880,
-// nice: 0,
-// sys: 19430,
-// idle: 1070905480,
-// irq: 20
-// }
-// },
-// {
-// model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
-// speed: 2926,
-// times: {
-// user: 511580,
-// nice: 20,
-// sys: 40900,
-// idle: 1070842510,
-// irq: 0
-// }
-// },
-// {
-// model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
-// speed: 2926,
-// times: {
-// user: 291660,
-// nice: 0,
-// sys: 34360,
-// idle: 1070888000,
-// irq: 10
-// }
-// },
-// {
-// model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
-// speed: 2926,
-// times: {
-// user: 308260,
-// nice: 0,
-// sys: 55410,
-// idle: 1071129970,
-// irq: 880
-// }
-// },
-// {
-// model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
-// speed: 2926,
-// times: {
-// user: 266450,
-// nice: 1480,
-// sys: 34920,
-// idle: 1072572010,
-// irq: 30
-// }
-// }
-// ]
-// ```
-//
-// Because `nice` values are UNIX-specific, on Windows the `nice` values of all
-// processors are always 0.
-//
-// ## os.endianness()
-//
-//
-// * Returns: {string}
-//
-// The `os.endianness()` method returns a string identifying the endianness of the
-// CPU *for which the Node.js binary was compiled*.
-//
-// Possible values are:
-//
-// * `'BE'` for big endian
-// * `'LE'` for little endian.
-//
-// ## os.freemem()
-//
-//
-// * Returns: {integer}
-//
-// The `os.freemem()` method returns the amount of free system memory in bytes as
-// an integer.
-//
-// ## os.getPriority([pid])
-//
-//
-// * `pid` {integer} The process ID to retrieve scheduling priority for.
-// **Default** `0`.
-// * Returns: {integer}
-//
-// The `os.getPriority()` method returns the scheduling priority for the process
-// specified by `pid`. If `pid` is not provided, or is `0`, the priority of the
-// current process is returned.
-//
-// ## os.homedir()
-//
-//
-// * Returns: {string}
-//
-// The `os.homedir()` method returns the home directory of the current user as a
-// string.
-//
-// ## os.hostname()
-//
-//
-// * Returns: {string}
-//
-// The `os.hostname()` method returns the hostname of the operating system as a
-// string.
-//
-// ## os.loadavg()
-//
-//
-// * Returns: {number[]}
-//
-// The `os.loadavg()` method returns an array containing the 1, 5, and 15 minute
-// load averages.
-//
-// The load average is a measure of system activity, calculated by the operating
-// system and expressed as a fractional number. As a rule of thumb, the load
-// average should ideally be less than the number of logical CPUs in the system.
-//
-// The load average is a UNIX-specific concept with no real equivalent on
-// Windows platforms. On Windows, the return value is always `[0, 0, 0]`.
-//
-// ## os.networkInterfaces()
-//
-//
-// * Returns: {Object}
-//
-// The `os.networkInterfaces()` method returns an object containing only network
-// interfaces that have been assigned a network address.
-//
-// Each key on the returned object identifies a network interface. The associated
-// value is an array of objects that each describe an assigned network address.
-//
-// The properties available on the assigned network address object include:
-//
-// * `address` {string} The assigned IPv4 or IPv6 address
-// * `netmask` {string} The IPv4 or IPv6 network mask
-// * `family` {string} Either `IPv4` or `IPv6`
-// * `mac` {string} The MAC address of the network interface
-// * `internal` {boolean} `true` if the network interface is a loopback or
-// similar interface that is not remotely accessible; otherwise `false`
-// * `scopeid` {number} The numeric IPv6 scope ID (only specified when `family`
-// is `IPv6`)
-// * `cidr` {string} The assigned IPv4 or IPv6 address with the routing prefix
-// in CIDR notation. If the `netmask` is invalid, this property is set
-// to `null`.
-//
-//
-// ```js
-// {
-// lo: [
-// {
-// address: '127.0.0.1',
-// netmask: '255.0.0.0',
-// family: 'IPv4',
-// mac: '00:00:00:00:00:00',
-// internal: true,
-// cidr: '127.0.0.1/8'
-// },
-// {
-// address: '::1',
-// netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
-// family: 'IPv6',
-// mac: '00:00:00:00:00:00',
-// scopeid: 0,
-// internal: true,
-// cidr: '::1/128'
-// }
-// ],
-// eth0: [
-// {
-// address: '192.168.1.108',
-// netmask: '255.255.255.0',
-// family: 'IPv4',
-// mac: '01:02:03:0a:0b:0c',
-// internal: false,
-// cidr: '192.168.1.108/24'
-// },
-// {
-// address: 'fe80::a00:27ff:fe4e:66a1',
-// netmask: 'ffff:ffff:ffff:ffff::',
-// family: 'IPv6',
-// mac: '01:02:03:0a:0b:0c',
-// scopeid: 1,
-// internal: false,
-// cidr: 'fe80::a00:27ff:fe4e:66a1/64'
-// }
-// ]
-// }
-// ```
-//
-// ## os.platform()
-//
-//
-// * Returns: {string}
-//
-// The `os.platform()` method returns a string identifying the operating system
-// platform as set during compile time of Node.js.
-//
-// Currently possible values are:
-//
-// * `'aix'`
-// * `'darwin'`
-// * `'freebsd'`
-// * `'linux'`
-// * `'openbsd'`
-// * `'sunos'`
-// * `'win32'`
-//
-// Equivalent to [`process.platform`][].
-//
-// The value `'android'` may also be returned if the Node.js is built on the
-// Android operating system. However, Android support in Node.js is considered
-// [to be experimental][Android building] at this time.
-//
-// ## os.release()
-//
-//
-// * Returns: {string}
-//
-// The `os.release()` method returns a string identifying the operating system
-// release.
-//
-// On POSIX systems, the operating system release is determined by calling
-// [uname(3)][]. On Windows, `GetVersionExW()` is used. Please see
-// https://en.wikipedia.org/wiki/Uname#Examples for more information.
-//
-// ## os.setPriority([pid, ]priority)
-//
-//
-// * `pid` {integer} The process ID to set scheduling priority for.
-// **Default** `0`.
-// * `priority` {integer} The scheduling priority to assign to the process.
-//
-// The `os.setPriority()` method attempts to set the scheduling priority for the
-// process specified by `pid`. If `pid` is not provided, or is `0`, the priority
-// of the current process is used.
-//
-// The `priority` input must be an integer between `-20` (high priority) and `19`
-// (low priority). Due to differences between Unix priority levels and Windows
-// priority classes, `priority` is mapped to one of six priority constants in
-// `os.constants.priority`. When retrieving a process priority level, this range
-// mapping may cause the return value to be slightly different on Windows. To avoid
-// confusion, it is recommended to set `priority` to one of the priority constants.
-//
-// On Windows setting priority to `PRIORITY_HIGHEST` requires elevated user,
-// otherwise the set priority will be silently reduced to `PRIORITY_HIGH`.
-//
-// ## os.tmpdir()
-//
-//
-// * Returns: {string}
-//
-// The `os.tmpdir()` method returns a string specifying the operating system's
-// default directory for temporary files.
-//
-// ## os.totalmem()
-//
-//
-// * Returns: {integer}
-//
-// The `os.totalmem()` method returns the total amount of system memory in bytes
-// as an integer.
-//
-// ## os.type()
-//
-//
-// * Returns: {string}
-//
-// The `os.type()` method returns a string identifying the operating system name
-// as returned by [uname(3)][]. For example, `'Linux'` on Linux, `'Darwin'` on
-// macOS, and `'Windows_NT'` on Windows.
-//
-// Please see https://en.wikipedia.org/wiki/Uname#Examples for additional
-// information about the output of running [uname(3)][] on various operating
-// systems.
-//
-// ## os.uptime()
-//
-//
-// * Returns: {integer}
-//
-// The `os.uptime()` method returns the system uptime in number of seconds.
-//
-// ## os.userInfo([options])
-//
-//
-// * `options` {Object}
-// * `encoding` {string} Character encoding used to interpret resulting strings.
-// If `encoding` is set to `'buffer'`, the `username`, `shell`, and `homedir`
-// values will be `Buffer` instances. **Default:** `'utf8'`.
-// * Returns: {Object}
-//
-// The `os.userInfo()` method returns information about the currently effective
-// user — on POSIX platforms, this is typically a subset of the password file. The
-// returned object includes the `username`, `uid`, `gid`, `shell`, and `homedir`.
-// On Windows, the `uid` and `gid` fields are `-1`, and `shell` is `null`.
-//
-// The value of `homedir` returned by `os.userInfo()` is provided by the operating
-// system. This differs from the result of `os.homedir()`, which queries several
-// environment variables for the home directory before falling back to the
-// operating system response.
-//
-// Throws a [`SystemError`][] if a user has no `username` or `homedir`.
diff --git a/dist/assembly.zip b/dist/assembly.zip
deleted file mode 100644
index 9cf1752..0000000
Binary files a/dist/assembly.zip and /dev/null differ
diff --git a/dist/build.zip b/dist/build.zip
deleted file mode 100644
index bc5d266..0000000
Binary files a/dist/build.zip and /dev/null differ
diff --git a/dist/index.html b/dist/index.html
deleted file mode 100644
index 4faf06f..0000000
--- a/dist/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
- Terminal basic example
-
-
-
-
-
-
-
diff --git a/dist/index.js b/dist/index.js
deleted file mode 100644
index 6313ce0..0000000
--- a/dist/index.js
+++ /dev/null
@@ -1,25079 +0,0 @@
-/******/ (function(modules) { // webpackBootstrap
-/******/ // The module cache
-/******/ var installedModules = {};
-/******/
-/******/ // The require function
-/******/ function __webpack_require__(moduleId) {
-/******/
-/******/ // Check if module is in cache
-/******/ if(installedModules[moduleId]) {
-/******/ return installedModules[moduleId].exports;
-/******/ }
-/******/ // Create a new module (and put it into the cache)
-/******/ var module = installedModules[moduleId] = {
-/******/ i: moduleId,
-/******/ l: false,
-/******/ exports: {}
-/******/ };
-/******/
-/******/ // Execute the module function
-/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
-/******/
-/******/ // Flag the module as loaded
-/******/ module.l = true;
-/******/
-/******/ // Return the exports of the module
-/******/ return module.exports;
-/******/ }
-/******/
-/******/
-/******/ // expose the modules object (__webpack_modules__)
-/******/ __webpack_require__.m = modules;
-/******/
-/******/ // expose the module cache
-/******/ __webpack_require__.c = installedModules;
-/******/
-/******/ // define getter function for harmony exports
-/******/ __webpack_require__.d = function(exports, name, getter) {
-/******/ if(!__webpack_require__.o(exports, name)) {
-/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
-/******/ }
-/******/ };
-/******/
-/******/ // define __esModule on exports
-/******/ __webpack_require__.r = function(exports) {
-/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
-/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
-/******/ }
-/******/ Object.defineProperty(exports, '__esModule', { value: true });
-/******/ };
-/******/
-/******/ // create a fake namespace object
-/******/ // mode & 1: value is a module id, require it
-/******/ // mode & 2: merge all properties of value into the ns
-/******/ // mode & 4: return value when already ns object
-/******/ // mode & 8|1: behave like require
-/******/ __webpack_require__.t = function(value, mode) {
-/******/ if(mode & 1) value = __webpack_require__(value);
-/******/ if(mode & 8) return value;
-/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
-/******/ var ns = Object.create(null);
-/******/ __webpack_require__.r(ns);
-/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
-/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
-/******/ return ns;
-/******/ };
-/******/
-/******/ // getDefaultExport function for compatibility with non-harmony modules
-/******/ __webpack_require__.n = function(module) {
-/******/ var getter = module && module.__esModule ?
-/******/ function getDefault() { return module['default']; } :
-/******/ function getModuleExports() { return module; };
-/******/ __webpack_require__.d(getter, 'a', getter);
-/******/ return getter;
-/******/ };
-/******/
-/******/ // Object.prototype.hasOwnProperty.call
-/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
-/******/
-/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "";
-/******/
-/******/
-/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = "./src/index.ts");
-/******/ })
-/************************************************************************/
-/******/ ({
-
-/***/ "./node_modules/browserfs/dist/browserfs.js":
-/*!**************************************************!*\
- !*** ./node_modules/browserfs/dist/browserfs.js ***!
- \**************************************************/
-/*! no static exports found */
-/***/ (function(module, exports) {
-
-(function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory();
- else if(typeof define === 'function' && define.amd)
- define([], factory);
- else if(typeof exports === 'object')
- exports["BrowserFS"] = factory();
- else
- root["BrowserFS"] = factory();
-})(this, function() {
-return /******/ (function(modules) { // webpackBootstrap
-/******/ // The module cache
-/******/ var installedModules = {};
-/******/
-/******/ // The require function
-/******/ function __webpack_require__(moduleId) {
-/******/
-/******/ // Check if module is in cache
-/******/ if(installedModules[moduleId])
-/******/ return installedModules[moduleId].exports;
-/******/
-/******/ // Create a new module (and put it into the cache)
-/******/ var module = installedModules[moduleId] = {
-/******/ exports: {},
-/******/ id: moduleId,
-/******/ loaded: false
-/******/ };
-/******/
-/******/ // Execute the module function
-/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
-/******/
-/******/ // Flag the module as loaded
-/******/ module.loaded = true;
-/******/
-/******/ // Return the exports of the module
-/******/ return module.exports;
-/******/ }
-/******/
-/******/
-/******/ // expose the modules object (__webpack_modules__)
-/******/ __webpack_require__.m = modules;
-/******/
-/******/ // expose the module cache
-/******/ __webpack_require__.c = installedModules;
-/******/
-/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "";
-/******/
-/******/ // Load entry module and return exports
-/******/ return __webpack_require__(0);
-/******/ })
-/************************************************************************/
-/******/ ([
-/* 0 */
-/***/ function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(Buffer, global, module, process) {'use strict';
-
- Object.defineProperty(exports, '__esModule', { value: true });
-
- var buffer = __webpack_require__(2);
- var path = __webpack_require__(9);
-
- /**
- * Standard libc error codes. Add more to this enum and ErrorStrings as they are
- * needed.
- * @url http://www.gnu.org/software/libc/manual/html_node/Error-Codes.html
- */
- /**
- * Standard libc error codes. Add more to this enum and ErrorStrings as they are
- * needed.
- * @url http://www.gnu.org/software/libc/manual/html_node/Error-Codes.html
- */ var ErrorCode;
- (function (ErrorCode) {
- ErrorCode[ErrorCode["EPERM"] = 1] = "EPERM";
- ErrorCode[ErrorCode["ENOENT"] = 2] = "ENOENT";
- ErrorCode[ErrorCode["EIO"] = 5] = "EIO";
- ErrorCode[ErrorCode["EBADF"] = 9] = "EBADF";
- ErrorCode[ErrorCode["EACCES"] = 13] = "EACCES";
- ErrorCode[ErrorCode["EBUSY"] = 16] = "EBUSY";
- ErrorCode[ErrorCode["EEXIST"] = 17] = "EEXIST";
- ErrorCode[ErrorCode["ENOTDIR"] = 20] = "ENOTDIR";
- ErrorCode[ErrorCode["EISDIR"] = 21] = "EISDIR";
- ErrorCode[ErrorCode["EINVAL"] = 22] = "EINVAL";
- ErrorCode[ErrorCode["EFBIG"] = 27] = "EFBIG";
- ErrorCode[ErrorCode["ENOSPC"] = 28] = "ENOSPC";
- ErrorCode[ErrorCode["EROFS"] = 30] = "EROFS";
- ErrorCode[ErrorCode["ENOTEMPTY"] = 39] = "ENOTEMPTY";
- ErrorCode[ErrorCode["ENOTSUP"] = 95] = "ENOTSUP";
- })(ErrorCode || (ErrorCode = {}));
- /* tslint:disable:variable-name */
- /**
- * Strings associated with each error code.
- * @hidden
- */
- var ErrorStrings = {};
- ErrorStrings[ErrorCode.EPERM] = 'Operation not permitted.';
- ErrorStrings[ErrorCode.ENOENT] = 'No such file or directory.';
- ErrorStrings[ErrorCode.EIO] = 'Input/output error.';
- ErrorStrings[ErrorCode.EBADF] = 'Bad file descriptor.';
- ErrorStrings[ErrorCode.EACCES] = 'Permission denied.';
- ErrorStrings[ErrorCode.EBUSY] = 'Resource busy or locked.';
- ErrorStrings[ErrorCode.EEXIST] = 'File exists.';
- ErrorStrings[ErrorCode.ENOTDIR] = 'File is not a directory.';
- ErrorStrings[ErrorCode.EISDIR] = 'File is a directory.';
- ErrorStrings[ErrorCode.EINVAL] = 'Invalid argument.';
- ErrorStrings[ErrorCode.EFBIG] = 'File is too big.';
- ErrorStrings[ErrorCode.ENOSPC] = 'No space left on disk.';
- ErrorStrings[ErrorCode.EROFS] = 'Cannot modify a read-only file system.';
- ErrorStrings[ErrorCode.ENOTEMPTY] = 'Directory is not empty.';
- ErrorStrings[ErrorCode.ENOTSUP] = 'Operation is not supported.';
- /* tslint:enable:variable-name */
- /**
- * Represents a BrowserFS error. Passed back to applications after a failed
- * call to the BrowserFS API.
- */
- var ApiError = (function (Error) {
- function ApiError(type, message, path$$1) {
- if ( message === void 0 ) message = ErrorStrings[type];
-
- Error.call(this, message);
- // Unsupported.
- this.syscall = "";
- this.errno = type;
- this.code = ErrorCode[type];
- this.path = path$$1;
- this.stack = new Error().stack;
- this.message = "Error: " + (this.code) + ": " + message + (this.path ? (", '" + (this.path) + "'") : '');
- }
-
- if ( Error ) ApiError.__proto__ = Error;
- ApiError.prototype = Object.create( Error && Error.prototype );
- ApiError.prototype.constructor = ApiError;
- ApiError.fromJSON = function fromJSON (json) {
- var err = new ApiError(0);
- err.errno = json.errno;
- err.code = json.code;
- err.path = json.path;
- err.stack = json.stack;
- err.message = json.message;
- return err;
- };
- /**
- * Creates an ApiError object from a buffer.
- */
- ApiError.fromBuffer = function fromBuffer (buffer$$1, i) {
- if ( i === void 0 ) i = 0;
-
- return ApiError.fromJSON(JSON.parse(buffer$$1.toString('utf8', i + 4, i + 4 + buffer$$1.readUInt32LE(i))));
- };
- ApiError.FileError = function FileError (code, p) {
- return new ApiError(code, ErrorStrings[code], p);
- };
- ApiError.ENOENT = function ENOENT (path$$1) {
- return this.FileError(ErrorCode.ENOENT, path$$1);
- };
- ApiError.EEXIST = function EEXIST (path$$1) {
- return this.FileError(ErrorCode.EEXIST, path$$1);
- };
- ApiError.EISDIR = function EISDIR (path$$1) {
- return this.FileError(ErrorCode.EISDIR, path$$1);
- };
- ApiError.ENOTDIR = function ENOTDIR (path$$1) {
- return this.FileError(ErrorCode.ENOTDIR, path$$1);
- };
- ApiError.EPERM = function EPERM (path$$1) {
- return this.FileError(ErrorCode.EPERM, path$$1);
- };
- ApiError.ENOTEMPTY = function ENOTEMPTY (path$$1) {
- return this.FileError(ErrorCode.ENOTEMPTY, path$$1);
- };
- /**
- * @return A friendly error message.
- */
- ApiError.prototype.toString = function toString () {
- return this.message;
- };
- ApiError.prototype.toJSON = function toJSON () {
- return {
- errno: this.errno,
- code: this.code,
- path: this.path,
- stack: this.stack,
- message: this.message
- };
- };
- /**
- * Writes the API error into a buffer.
- */
- ApiError.prototype.writeToBuffer = function writeToBuffer (buffer$$1, i) {
- if ( buffer$$1 === void 0 ) buffer$$1 = Buffer.alloc(this.bufferSize());
- if ( i === void 0 ) i = 0;
-
- var bytesWritten = buffer$$1.write(JSON.stringify(this.toJSON()), i + 4);
- buffer$$1.writeUInt32LE(bytesWritten, i);
- return buffer$$1;
- };
- /**
- * The size of the API error in buffer-form in bytes.
- */
- ApiError.prototype.bufferSize = function bufferSize () {
- // 4 bytes for string length.
- return 4 + Buffer.byteLength(JSON.stringify(this.toJSON()));
- };
-
- return ApiError;
- }(Error));
-
-
- var api_error = Object.freeze({
- get ErrorCode () { return ErrorCode; },
- ErrorStrings: ErrorStrings,
- ApiError: ApiError
- });
-
- var ActionType;
- (function (ActionType) {
- // Indicates that the code should not do anything.
- ActionType[ActionType["NOP"] = 0] = "NOP";
- // Indicates that the code should throw an exception.
- ActionType[ActionType["THROW_EXCEPTION"] = 1] = "THROW_EXCEPTION";
- // Indicates that the code should truncate the file, but only if it is a file.
- ActionType[ActionType["TRUNCATE_FILE"] = 2] = "TRUNCATE_FILE";
- // Indicates that the code should create the file.
- ActionType[ActionType["CREATE_FILE"] = 3] = "CREATE_FILE";
- })(ActionType || (ActionType = {}));
- /**
- * Represents one of the following file flags. A convenience object.
- *
- * * `'r'` - Open file for reading. An exception occurs if the file does not exist.
- * * `'r+'` - Open file for reading and writing. An exception occurs if the file does not exist.
- * * `'rs'` - Open file for reading in synchronous mode. Instructs the filesystem to not cache writes.
- * * `'rs+'` - Open file for reading and writing, and opens the file in synchronous mode.
- * * `'w'` - Open file for writing. The file is created (if it does not exist) or truncated (if it exists).
- * * `'wx'` - Like 'w' but opens the file in exclusive mode.
- * * `'w+'` - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).
- * * `'wx+'` - Like 'w+' but opens the file in exclusive mode.
- * * `'a'` - Open file for appending. The file is created if it does not exist.
- * * `'ax'` - Like 'a' but opens the file in exclusive mode.
- * * `'a+'` - Open file for reading and appending. The file is created if it does not exist.
- * * `'ax+'` - Like 'a+' but opens the file in exclusive mode.
- *
- * Exclusive mode ensures that the file path is newly created.
- */
- var FileFlag = function FileFlag(flagStr) {
- this.flagStr = flagStr;
- if (FileFlag.validFlagStrs.indexOf(flagStr) < 0) {
- throw new ApiError(ErrorCode.EINVAL, "Invalid flag: " + flagStr);
- }
- };
- /**
- * Get an object representing the given file flag.
- * @param modeStr The string representing the flag
- * @return The FileFlag object representing the flag
- * @throw when the flag string is invalid
- */
- FileFlag.getFileFlag = function getFileFlag (flagStr) {
- // Check cache first.
- if (FileFlag.flagCache.hasOwnProperty(flagStr)) {
- return FileFlag.flagCache[flagStr];
- }
- return FileFlag.flagCache[flagStr] = new FileFlag(flagStr);
- };
- /**
- * Get the underlying flag string for this flag.
- */
- FileFlag.prototype.getFlagString = function getFlagString () {
- return this.flagStr;
- };
- /**
- * Returns true if the file is readable.
- */
- FileFlag.prototype.isReadable = function isReadable () {
- return this.flagStr.indexOf('r') !== -1 || this.flagStr.indexOf('+') !== -1;
- };
- /**
- * Returns true if the file is writeable.
- */
- FileFlag.prototype.isWriteable = function isWriteable () {
- return this.flagStr.indexOf('w') !== -1 || this.flagStr.indexOf('a') !== -1 || this.flagStr.indexOf('+') !== -1;
- };
- /**
- * Returns true if the file mode should truncate.
- */
- FileFlag.prototype.isTruncating = function isTruncating () {
- return this.flagStr.indexOf('w') !== -1;
- };
- /**
- * Returns true if the file is appendable.
- */
- FileFlag.prototype.isAppendable = function isAppendable () {
- return this.flagStr.indexOf('a') !== -1;
- };
- /**
- * Returns true if the file is open in synchronous mode.
- */
- FileFlag.prototype.isSynchronous = function isSynchronous () {
- return this.flagStr.indexOf('s') !== -1;
- };
- /**
- * Returns true if the file is open in exclusive mode.
- */
- FileFlag.prototype.isExclusive = function isExclusive () {
- return this.flagStr.indexOf('x') !== -1;
- };
- /**
- * Returns one of the static fields on this object that indicates the
- * appropriate response to the path existing.
- */
- FileFlag.prototype.pathExistsAction = function pathExistsAction () {
- if (this.isExclusive()) {
- return ActionType.THROW_EXCEPTION;
- }
- else if (this.isTruncating()) {
- return ActionType.TRUNCATE_FILE;
- }
- else {
- return ActionType.NOP;
- }
- };
- /**
- * Returns one of the static fields on this object that indicates the
- * appropriate response to the path not existing.
- */
- FileFlag.prototype.pathNotExistsAction = function pathNotExistsAction () {
- if ((this.isWriteable() || this.isAppendable()) && this.flagStr !== 'r+') {
- return ActionType.CREATE_FILE;
- }
- else {
- return ActionType.THROW_EXCEPTION;
- }
- };
- // Contains cached FileMode instances.
- FileFlag.flagCache = {};
- // Array of valid mode strings.
- FileFlag.validFlagStrs = ['r', 'r+', 'rs', 'rs+', 'w', 'wx', 'w+', 'wx+', 'a', 'ax', 'a+', 'ax+'];
-
- /**
- * Indicates the type of the given file. Applied to 'mode'.
- */
- var FileType;
- (function (FileType) {
- FileType[FileType["FILE"] = 32768] = "FILE";
- FileType[FileType["DIRECTORY"] = 16384] = "DIRECTORY";
- FileType[FileType["SYMLINK"] = 40960] = "SYMLINK";
- })(FileType || (FileType = {}));
- /**
- * Emulation of Node's `fs.Stats` object.
- *
- * Attribute descriptions are from `man 2 stat'
- * @see http://nodejs.org/api/fs.html#fs_class_fs_stats
- * @see http://man7.org/linux/man-pages/man2/stat.2.html
- */
- var Stats = function Stats(itemType, size, mode, atime, mtime, ctime) {
- if ( atime === void 0 ) atime = new Date();
- if ( mtime === void 0 ) mtime = new Date();
- if ( ctime === void 0 ) ctime = new Date();
-
- this.size = size;
- this.atime = atime;
- this.mtime = mtime;
- this.ctime = ctime;
- /**
- * UNSUPPORTED ATTRIBUTES
- * I assume no one is going to need these details, although we could fake
- * appropriate values if need be.
- */
- // ID of device containing file
- this.dev = 0;
- // inode number
- this.ino = 0;
- // device ID (if special file)
- this.rdev = 0;
- // number of hard links
- this.nlink = 1;
- // blocksize for file system I/O
- this.blksize = 4096;
- // @todo Maybe support these? atm, it's a one-user filesystem.
- // user ID of owner
- this.uid = 0;
- // group ID of owner
- this.gid = 0;
- // time file was created (currently unsupported)
- this.birthtime = new Date(0);
- // XXX: Some file systems stash data on stats objects.
- this.fileData = null;
- if (!mode) {
- switch (itemType) {
- case FileType.FILE:
- this.mode = 0x1a4;
- break;
- case FileType.DIRECTORY:
- default:
- this.mode = 0x1ff;
- }
- }
- else {
- this.mode = mode;
- }
- // number of 512B blocks allocated
- this.blocks = Math.ceil(size / 512);
- // Check if mode also includes top-most bits, which indicate the file's
- // type.
- if (this.mode < 0x1000) {
- this.mode |= itemType;
- }
- };
- Stats.fromBuffer = function fromBuffer (buffer$$1) {
- var size = buffer$$1.readUInt32LE(0), mode = buffer$$1.readUInt32LE(4), atime = buffer$$1.readDoubleLE(8), mtime = buffer$$1.readDoubleLE(16), ctime = buffer$$1.readDoubleLE(24);
- return new Stats(mode & 0xF000, size, mode & 0xFFF, new Date(atime), new Date(mtime), new Date(ctime));
- };
- Stats.prototype.toBuffer = function toBuffer () {
- var buffer$$1 = Buffer.alloc(32);
- buffer$$1.writeUInt32LE(this.size, 0);
- buffer$$1.writeUInt32LE(this.mode, 4);
- buffer$$1.writeDoubleLE(this.atime.getTime(), 8);
- buffer$$1.writeDoubleLE(this.mtime.getTime(), 16);
- buffer$$1.writeDoubleLE(this.ctime.getTime(), 24);
- return buffer$$1;
- };
- /**
- * **Nonstandard**: Clone the stats object.
- * @return [BrowserFS.node.fs.Stats]
- */
- Stats.prototype.clone = function clone () {
- return new Stats(this.mode & 0xF000, this.size, this.mode & 0xFFF, this.atime, this.mtime, this.ctime);
- };
- /**
- * @return [Boolean] True if this item is a file.
- */
- Stats.prototype.isFile = function isFile () {
- return (this.mode & 0xF000) === FileType.FILE;
- };
- /**
- * @return [Boolean] True if this item is a directory.
- */
- Stats.prototype.isDirectory = function isDirectory () {
- return (this.mode & 0xF000) === FileType.DIRECTORY;
- };
- /**
- * @return [Boolean] True if this item is a symbolic link (only valid through lstat)
- */
- Stats.prototype.isSymbolicLink = function isSymbolicLink () {
- return (this.mode & 0xF000) === FileType.SYMLINK;
- };
- /**
- * Change the mode of the file. We use this helper function to prevent messing
- * up the type of the file, which is encoded in mode.
- */
- Stats.prototype.chmod = function chmod (mode) {
- this.mode = (this.mode & 0xF000) | mode;
- };
- // We don't support the following types of files.
- Stats.prototype.isSocket = function isSocket () {
- return false;
- };
- Stats.prototype.isBlockDevice = function isBlockDevice () {
- return false;
- };
- Stats.prototype.isCharacterDevice = function isCharacterDevice () {
- return false;
- };
- Stats.prototype.isFIFO = function isFIFO () {
- return false;
- };
-
- /**
- * Wraps a callback function. Used for unit testing. Defaults to a NOP.
- * @hidden
- */
- var wrapCb = function (cb, numArgs) {
- return cb;
- };
- /**
- * @hidden
- */
- function assertRoot(fs) {
- if (fs) {
- return fs;
- }
- throw new ApiError(ErrorCode.EIO, "Initialize BrowserFS with a file system using BrowserFS.initialize(filesystem)");
- }
- /**
- * @hidden
- */
- function normalizeMode(mode, def) {
- switch (typeof mode) {
- case 'number':
- // (path, flag, mode, cb?)
- return mode;
- case 'string':
- // (path, flag, modeString, cb?)
- var trueMode = parseInt(mode, 8);
- if (!isNaN(trueMode)) {
- return trueMode;
- }
- // Invalid string.
- return def;
- default:
- return def;
- }
- }
- /**
- * @hidden
- */
- function normalizeTime(time) {
- if (time instanceof Date) {
- return time;
- }
- else if (typeof time === 'number') {
- return new Date(time * 1000);
- }
- else {
- throw new ApiError(ErrorCode.EINVAL, "Invalid time.");
- }
- }
- /**
- * @hidden
- */
- function normalizePath(p) {
- // Node doesn't allow null characters in paths.
- if (p.indexOf('\u0000') >= 0) {
- throw new ApiError(ErrorCode.EINVAL, 'Path must be a string without null bytes.');
- }
- else if (p === '') {
- throw new ApiError(ErrorCode.EINVAL, 'Path must not be empty.');
- }
- return path.resolve(p);
- }
- /**
- * @hidden
- */
- function normalizeOptions(options, defEnc, defFlag, defMode) {
- switch (typeof options) {
- case 'object':
- return {
- encoding: typeof options['encoding'] !== 'undefined' ? options['encoding'] : defEnc,
- flag: typeof options['flag'] !== 'undefined' ? options['flag'] : defFlag,
- mode: normalizeMode(options['mode'], defMode)
- };
- case 'string':
- return {
- encoding: options,
- flag: defFlag,
- mode: defMode
- };
- default:
- return {
- encoding: defEnc,
- flag: defFlag,
- mode: defMode
- };
- }
- }
- /**
- * The default callback is a NOP.
- * @hidden
- * @private
- */
- function nopCb() {
- // NOP.
- }
- /**
- * The node frontend to all filesystems.
- * This layer handles:
- *
- * * Sanity checking inputs.
- * * Normalizing paths.
- * * Resetting stack depth for asynchronous operations which may not go through
- * the browser by wrapping all input callbacks using `setImmediate`.
- * * Performing the requested operation through the filesystem or the file
- * descriptor, as appropriate.
- * * Handling optional arguments and setting default arguments.
- * @see http://nodejs.org/api/fs.html
- */
- var FS = function FS() {
- /* tslint:enable:variable-name */
- this.F_OK = 0;
- this.R_OK = 4;
- this.W_OK = 2;
- this.X_OK = 1;
- this.root = null;
- this.fdMap = {};
- this.nextFd = 100;
- };
- FS.prototype.initialize = function initialize (rootFS) {
- if (!rootFS.constructor.isAvailable()) {
- throw new ApiError(ErrorCode.EINVAL, 'Tried to instantiate BrowserFS with an unavailable file system.');
- }
- return this.root = rootFS;
- };
- /**
- * converts Date or number to a fractional UNIX timestamp
- * Grabbed from NodeJS sources (lib/fs.js)
- */
- FS.prototype._toUnixTimestamp = function _toUnixTimestamp (time) {
- if (typeof time === 'number') {
- return time;
- }
- else if (time instanceof Date) {
- return time.getTime() / 1000;
- }
- throw new Error("Cannot parse time: " + time);
- };
- /**
- * **NONSTANDARD**: Grab the FileSystem instance that backs this API.
- * @return [BrowserFS.FileSystem | null] Returns null if the file system has
- * not been initialized.
- */
- FS.prototype.getRootFS = function getRootFS () {
- if (this.root) {
- return this.root;
- }
- else {
- return null;
- }
- };
- // FILE OR DIRECTORY METHODS
- /**
- * Asynchronous rename. No arguments other than a possible exception are given
- * to the completion callback.
- * @param oldPath
- * @param newPath
- * @param callback
- */
- FS.prototype.rename = function rename (oldPath, newPath, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- assertRoot(this.root).rename(normalizePath(oldPath), normalizePath(newPath), newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous rename.
- * @param oldPath
- * @param newPath
- */
- FS.prototype.renameSync = function renameSync (oldPath, newPath) {
- assertRoot(this.root).renameSync(normalizePath(oldPath), normalizePath(newPath));
- };
- /**
- * Test whether or not the given path exists by checking with the file system.
- * Then call the callback argument with either true or false.
- * @example Sample invocation
- * fs.exists('/etc/passwd', function (exists) {
- * util.debug(exists ? "it's there" : "no passwd!");
- * });
- * @param path
- * @param callback
- */
- FS.prototype.exists = function exists (path$$1, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- return assertRoot(this.root).exists(normalizePath(path$$1), newCb);
- }
- catch (e) {
- // Doesn't return an error. If something bad happens, we assume it just
- // doesn't exist.
- return newCb(false);
- }
- };
- /**
- * Test whether or not the given path exists by checking with the file system.
- * @param path
- * @return [boolean]
- */
- FS.prototype.existsSync = function existsSync (path$$1) {
- try {
- return assertRoot(this.root).existsSync(normalizePath(path$$1));
- }
- catch (e) {
- // Doesn't return an error. If something bad happens, we assume it just
- // doesn't exist.
- return false;
- }
- };
- /**
- * Asynchronous `stat`.
- * @param path
- * @param callback
- */
- FS.prototype.stat = function stat (path$$1, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 2);
- try {
- return assertRoot(this.root).stat(normalizePath(path$$1), false, newCb);
- }
- catch (e) {
- return newCb(e);
- }
- };
- /**
- * Synchronous `stat`.
- * @param path
- * @return [BrowserFS.node.fs.Stats]
- */
- FS.prototype.statSync = function statSync (path$$1) {
- return assertRoot(this.root).statSync(normalizePath(path$$1), false);
- };
- /**
- * Asynchronous `lstat`.
- * `lstat()` is identical to `stat()`, except that if path is a symbolic link,
- * then the link itself is stat-ed, not the file that it refers to.
- * @param path
- * @param callback
- */
- FS.prototype.lstat = function lstat (path$$1, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 2);
- try {
- return assertRoot(this.root).stat(normalizePath(path$$1), true, newCb);
- }
- catch (e) {
- return newCb(e);
- }
- };
- /**
- * Synchronous `lstat`.
- * `lstat()` is identical to `stat()`, except that if path is a symbolic link,
- * then the link itself is stat-ed, not the file that it refers to.
- * @param path
- * @return [BrowserFS.node.fs.Stats]
- */
- FS.prototype.lstatSync = function lstatSync (path$$1) {
- return assertRoot(this.root).statSync(normalizePath(path$$1), true);
- };
- FS.prototype.truncate = function truncate (path$$1, arg2, cb) {
- if ( arg2 === void 0 ) arg2 = 0;
- if ( cb === void 0 ) cb = nopCb;
-
- var len = 0;
- if (typeof arg2 === 'function') {
- cb = arg2;
- }
- else if (typeof arg2 === 'number') {
- len = arg2;
- }
- var newCb = wrapCb(cb, 1);
- try {
- if (len < 0) {
- throw new ApiError(ErrorCode.EINVAL);
- }
- return assertRoot(this.root).truncate(normalizePath(path$$1), len, newCb);
- }
- catch (e) {
- return newCb(e);
- }
- };
- /**
- * Synchronous `truncate`.
- * @param path
- * @param len
- */
- FS.prototype.truncateSync = function truncateSync (path$$1, len) {
- if ( len === void 0 ) len = 0;
-
- if (len < 0) {
- throw new ApiError(ErrorCode.EINVAL);
- }
- return assertRoot(this.root).truncateSync(normalizePath(path$$1), len);
- };
- /**
- * Asynchronous `unlink`.
- * @param path
- * @param callback
- */
- FS.prototype.unlink = function unlink (path$$1, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- return assertRoot(this.root).unlink(normalizePath(path$$1), newCb);
- }
- catch (e) {
- return newCb(e);
- }
- };
- /**
- * Synchronous `unlink`.
- * @param path
- */
- FS.prototype.unlinkSync = function unlinkSync (path$$1) {
- return assertRoot(this.root).unlinkSync(normalizePath(path$$1));
- };
- FS.prototype.open = function open (path$$1, flag, arg2, cb) {
- var this$1 = this;
- if ( cb === void 0 ) cb = nopCb;
-
- var mode = normalizeMode(arg2, 0x1a4);
- cb = typeof arg2 === 'function' ? arg2 : cb;
- var newCb = wrapCb(cb, 2);
- try {
- assertRoot(this.root).open(normalizePath(path$$1), FileFlag.getFileFlag(flag), mode, function (e, file) {
- if (file) {
- newCb(e, this$1.getFdForFile(file));
- }
- else {
- newCb(e);
- }
- });
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous file open.
- * @see http://www.manpagez.com/man/2/open/
- * @param path
- * @param flags
- * @param mode defaults to `0644`
- * @return [BrowserFS.File]
- */
- FS.prototype.openSync = function openSync (path$$1, flag, mode) {
- if ( mode === void 0 ) mode = 0x1a4;
-
- return this.getFdForFile(assertRoot(this.root).openSync(normalizePath(path$$1), FileFlag.getFileFlag(flag), normalizeMode(mode, 0x1a4)));
- };
- FS.prototype.readFile = function readFile (filename, arg2, cb) {
- if ( arg2 === void 0 ) arg2 = {};
- if ( cb === void 0 ) cb = nopCb;
-
- var options = normalizeOptions(arg2, null, 'r', null);
- cb = typeof arg2 === 'function' ? arg2 : cb;
- var newCb = wrapCb(cb, 2);
- try {
- var flag = FileFlag.getFileFlag(options['flag']);
- if (!flag.isReadable()) {
- return newCb(new ApiError(ErrorCode.EINVAL, 'Flag passed to readFile must allow for reading.'));
- }
- return assertRoot(this.root).readFile(normalizePath(filename), options.encoding, flag, newCb);
- }
- catch (e) {
- return newCb(e);
- }
- };
- FS.prototype.readFileSync = function readFileSync (filename, arg2) {
- if ( arg2 === void 0 ) arg2 = {};
-
- var options = normalizeOptions(arg2, null, 'r', null);
- var flag = FileFlag.getFileFlag(options.flag);
- if (!flag.isReadable()) {
- throw new ApiError(ErrorCode.EINVAL, 'Flag passed to readFile must allow for reading.');
- }
- return assertRoot(this.root).readFileSync(normalizePath(filename), options.encoding, flag);
- };
- FS.prototype.writeFile = function writeFile (filename, data, arg3, cb) {
- if ( arg3 === void 0 ) arg3 = {};
- if ( cb === void 0 ) cb = nopCb;
-
- var options = normalizeOptions(arg3, 'utf8', 'w', 0x1a4);
- cb = typeof arg3 === 'function' ? arg3 : cb;
- var newCb = wrapCb(cb, 1);
- try {
- var flag = FileFlag.getFileFlag(options.flag);
- if (!flag.isWriteable()) {
- return newCb(new ApiError(ErrorCode.EINVAL, 'Flag passed to writeFile must allow for writing.'));
- }
- return assertRoot(this.root).writeFile(normalizePath(filename), data, options.encoding, flag, options.mode, newCb);
- }
- catch (e) {
- return newCb(e);
- }
- };
- FS.prototype.writeFileSync = function writeFileSync (filename, data, arg3) {
- var options = normalizeOptions(arg3, 'utf8', 'w', 0x1a4);
- var flag = FileFlag.getFileFlag(options.flag);
- if (!flag.isWriteable()) {
- throw new ApiError(ErrorCode.EINVAL, 'Flag passed to writeFile must allow for writing.');
- }
- return assertRoot(this.root).writeFileSync(normalizePath(filename), data, options.encoding, flag, options.mode);
- };
- FS.prototype.appendFile = function appendFile (filename, data, arg3, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var options = normalizeOptions(arg3, 'utf8', 'a', 0x1a4);
- cb = typeof arg3 === 'function' ? arg3 : cb;
- var newCb = wrapCb(cb, 1);
- try {
- var flag = FileFlag.getFileFlag(options.flag);
- if (!flag.isAppendable()) {
- return newCb(new ApiError(ErrorCode.EINVAL, 'Flag passed to appendFile must allow for appending.'));
- }
- assertRoot(this.root).appendFile(normalizePath(filename), data, options.encoding, flag, options.mode, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- FS.prototype.appendFileSync = function appendFileSync (filename, data, arg3) {
- var options = normalizeOptions(arg3, 'utf8', 'a', 0x1a4);
- var flag = FileFlag.getFileFlag(options.flag);
- if (!flag.isAppendable()) {
- throw new ApiError(ErrorCode.EINVAL, 'Flag passed to appendFile must allow for appending.');
- }
- return assertRoot(this.root).appendFileSync(normalizePath(filename), data, options.encoding, flag, options.mode);
- };
- // FILE DESCRIPTOR METHODS
- /**
- * Asynchronous `fstat`.
- * `fstat()` is identical to `stat()`, except that the file to be stat-ed is
- * specified by the file descriptor `fd`.
- * @param fd
- * @param callback
- */
- FS.prototype.fstat = function fstat (fd, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 2);
- try {
- var file = this.fd2file(fd);
- file.stat(newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `fstat`.
- * `fstat()` is identical to `stat()`, except that the file to be stat-ed is
- * specified by the file descriptor `fd`.
- * @param fd
- * @return [BrowserFS.node.fs.Stats]
- */
- FS.prototype.fstatSync = function fstatSync (fd) {
- return this.fd2file(fd).statSync();
- };
- /**
- * Asynchronous close.
- * @param fd
- * @param callback
- */
- FS.prototype.close = function close (fd, cb) {
- var this$1 = this;
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- this.fd2file(fd).close(function (e) {
- if (!e) {
- this$1.closeFd(fd);
- }
- newCb(e);
- });
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous close.
- * @param fd
- */
- FS.prototype.closeSync = function closeSync (fd) {
- this.fd2file(fd).closeSync();
- this.closeFd(fd);
- };
- FS.prototype.ftruncate = function ftruncate (fd, arg2, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var length = typeof arg2 === 'number' ? arg2 : 0;
- cb = typeof arg2 === 'function' ? arg2 : cb;
- var newCb = wrapCb(cb, 1);
- try {
- var file = this.fd2file(fd);
- if (length < 0) {
- throw new ApiError(ErrorCode.EINVAL);
- }
- file.truncate(length, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous ftruncate.
- * @param fd
- * @param len
- */
- FS.prototype.ftruncateSync = function ftruncateSync (fd, len) {
- if ( len === void 0 ) len = 0;
-
- var file = this.fd2file(fd);
- if (len < 0) {
- throw new ApiError(ErrorCode.EINVAL);
- }
- file.truncateSync(len);
- };
- /**
- * Asynchronous fsync.
- * @param fd
- * @param callback
- */
- FS.prototype.fsync = function fsync (fd, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- this.fd2file(fd).sync(newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous fsync.
- * @param fd
- */
- FS.prototype.fsyncSync = function fsyncSync (fd) {
- this.fd2file(fd).syncSync();
- };
- /**
- * Asynchronous fdatasync.
- * @param fd
- * @param callback
- */
- FS.prototype.fdatasync = function fdatasync (fd, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- this.fd2file(fd).datasync(newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous fdatasync.
- * @param fd
- */
- FS.prototype.fdatasyncSync = function fdatasyncSync (fd) {
- this.fd2file(fd).datasyncSync();
- };
- FS.prototype.write = function write (fd, arg2, arg3, arg4, arg5, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var buffer$$1, offset, length, position = null;
- if (typeof arg2 === 'string') {
- // Signature 1: (fd, string, [position?, [encoding?]], cb?)
- var encoding = 'utf8';
- switch (typeof arg3) {
- case 'function':
- // (fd, string, cb)
- cb = arg3;
- break;
- case 'number':
- // (fd, string, position, encoding?, cb?)
- position = arg3;
- encoding = typeof arg4 === 'string' ? arg4 : 'utf8';
- cb = typeof arg5 === 'function' ? arg5 : cb;
- break;
- default:
- // ...try to find the callback and get out of here!
- cb = typeof arg4 === 'function' ? arg4 : typeof arg5 === 'function' ? arg5 : cb;
- return cb(new ApiError(ErrorCode.EINVAL, 'Invalid arguments.'));
- }
- buffer$$1 = Buffer.from(arg2, encoding);
- offset = 0;
- length = buffer$$1.length;
- }
- else {
- // Signature 2: (fd, buffer, offset, length, position?, cb?)
- buffer$$1 = arg2;
- offset = arg3;
- length = arg4;
- position = typeof arg5 === 'number' ? arg5 : null;
- cb = typeof arg5 === 'function' ? arg5 : cb;
- }
- var newCb = wrapCb(cb, 3);
- try {
- var file = this.fd2file(fd);
- if (position === undefined || position === null) {
- position = file.getPos();
- }
- file.write(buffer$$1, offset, length, position, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- FS.prototype.writeSync = function writeSync (fd, arg2, arg3, arg4, arg5) {
- var buffer$$1, offset = 0, length, position;
- if (typeof arg2 === 'string') {
- // Signature 1: (fd, string, [position?, [encoding?]])
- position = typeof arg3 === 'number' ? arg3 : null;
- var encoding = typeof arg4 === 'string' ? arg4 : 'utf8';
- offset = 0;
- buffer$$1 = Buffer.from(arg2, encoding);
- length = buffer$$1.length;
- }
- else {
- // Signature 2: (fd, buffer, offset, length, position?)
- buffer$$1 = arg2;
- offset = arg3;
- length = arg4;
- position = typeof arg5 === 'number' ? arg5 : null;
- }
- var file = this.fd2file(fd);
- if (position === undefined || position === null) {
- position = file.getPos();
- }
- return file.writeSync(buffer$$1, offset, length, position);
- };
- FS.prototype.read = function read (fd, arg2, arg3, arg4, arg5, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var position, offset, length, buffer$$1, newCb;
- if (typeof arg2 === 'number') {
- // legacy interface
- // (fd, length, position, encoding, callback)
- length = arg2;
- position = arg3;
- var encoding = arg4;
- cb = typeof arg5 === 'function' ? arg5 : cb;
- offset = 0;
- buffer$$1 = Buffer.alloc(length);
- // XXX: Inefficient.
- // Wrap the cb so we shelter upper layers of the API from these
- // shenanigans.
- newCb = wrapCb(function (err, bytesRead, buf) {
- if (err) {
- return cb(err);
- }
- cb(err, buf.toString(encoding), bytesRead);
- }, 3);
- }
- else {
- buffer$$1 = arg2;
- offset = arg3;
- length = arg4;
- position = arg5;
- newCb = wrapCb(cb, 3);
- }
- try {
- var file = this.fd2file(fd);
- if (position === undefined || position === null) {
- position = file.getPos();
- }
- file.read(buffer$$1, offset, length, position, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- FS.prototype.readSync = function readSync (fd, arg2, arg3, arg4, arg5) {
- var shenanigans = false;
- var buffer$$1, offset, length, position, encoding = 'utf8';
- if (typeof arg2 === 'number') {
- length = arg2;
- position = arg3;
- encoding = arg4;
- offset = 0;
- buffer$$1 = Buffer.alloc(length);
- shenanigans = true;
- }
- else {
- buffer$$1 = arg2;
- offset = arg3;
- length = arg4;
- position = arg5;
- }
- var file = this.fd2file(fd);
- if (position === undefined || position === null) {
- position = file.getPos();
- }
- var rv = file.readSync(buffer$$1, offset, length, position);
- if (!shenanigans) {
- return rv;
- }
- else {
- return [buffer$$1.toString(encoding), rv];
- }
- };
- /**
- * Asynchronous `fchown`.
- * @param fd
- * @param uid
- * @param gid
- * @param callback
- */
- FS.prototype.fchown = function fchown (fd, uid, gid, callback) {
- if ( callback === void 0 ) callback = nopCb;
-
- var newCb = wrapCb(callback, 1);
- try {
- this.fd2file(fd).chown(uid, gid, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `fchown`.
- * @param fd
- * @param uid
- * @param gid
- */
- FS.prototype.fchownSync = function fchownSync (fd, uid, gid) {
- this.fd2file(fd).chownSync(uid, gid);
- };
- /**
- * Asynchronous `fchmod`.
- * @param fd
- * @param mode
- * @param callback
- */
- FS.prototype.fchmod = function fchmod (fd, mode, cb) {
- var newCb = wrapCb(cb, 1);
- try {
- var numMode = typeof mode === 'string' ? parseInt(mode, 8) : mode;
- this.fd2file(fd).chmod(numMode, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `fchmod`.
- * @param fd
- * @param mode
- */
- FS.prototype.fchmodSync = function fchmodSync (fd, mode) {
- var numMode = typeof mode === 'string' ? parseInt(mode, 8) : mode;
- this.fd2file(fd).chmodSync(numMode);
- };
- /**
- * Change the file timestamps of a file referenced by the supplied file
- * descriptor.
- * @param fd
- * @param atime
- * @param mtime
- * @param callback
- */
- FS.prototype.futimes = function futimes (fd, atime, mtime, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- var file = this.fd2file(fd);
- if (typeof atime === 'number') {
- atime = new Date(atime * 1000);
- }
- if (typeof mtime === 'number') {
- mtime = new Date(mtime * 1000);
- }
- file.utimes(atime, mtime, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Change the file timestamps of a file referenced by the supplied file
- * descriptor.
- * @param fd
- * @param atime
- * @param mtime
- */
- FS.prototype.futimesSync = function futimesSync (fd, atime, mtime) {
- this.fd2file(fd).utimesSync(normalizeTime(atime), normalizeTime(mtime));
- };
- // DIRECTORY-ONLY METHODS
- /**
- * Asynchronous `rmdir`.
- * @param path
- * @param callback
- */
- FS.prototype.rmdir = function rmdir (path$$1, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- path$$1 = normalizePath(path$$1);
- assertRoot(this.root).rmdir(path$$1, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `rmdir`.
- * @param path
- */
- FS.prototype.rmdirSync = function rmdirSync (path$$1) {
- path$$1 = normalizePath(path$$1);
- return assertRoot(this.root).rmdirSync(path$$1);
- };
- /**
- * Asynchronous `mkdir`.
- * @param path
- * @param mode defaults to `0777`
- * @param callback
- */
- FS.prototype.mkdir = function mkdir (path$$1, mode, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- if (typeof mode === 'function') {
- cb = mode;
- mode = 0x1ff;
- }
- var newCb = wrapCb(cb, 1);
- try {
- path$$1 = normalizePath(path$$1);
- assertRoot(this.root).mkdir(path$$1, mode, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `mkdir`.
- * @param path
- * @param mode defaults to `0777`
- */
- FS.prototype.mkdirSync = function mkdirSync (path$$1, mode) {
- assertRoot(this.root).mkdirSync(normalizePath(path$$1), normalizeMode(mode, 0x1ff));
- };
- /**
- * Asynchronous `readdir`. Reads the contents of a directory.
- * The callback gets two arguments `(err, files)` where `files` is an array of
- * the names of the files in the directory excluding `'.'` and `'..'`.
- * @param path
- * @param callback
- */
- FS.prototype.readdir = function readdir (path$$1, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 2);
- try {
- path$$1 = normalizePath(path$$1);
- assertRoot(this.root).readdir(path$$1, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `readdir`. Reads the contents of a directory.
- * @param path
- * @return [String[]]
- */
- FS.prototype.readdirSync = function readdirSync (path$$1) {
- path$$1 = normalizePath(path$$1);
- return assertRoot(this.root).readdirSync(path$$1);
- };
- // SYMLINK METHODS
- /**
- * Asynchronous `link`.
- * @param srcpath
- * @param dstpath
- * @param callback
- */
- FS.prototype.link = function link (srcpath, dstpath, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- srcpath = normalizePath(srcpath);
- dstpath = normalizePath(dstpath);
- assertRoot(this.root).link(srcpath, dstpath, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `link`.
- * @param srcpath
- * @param dstpath
- */
- FS.prototype.linkSync = function linkSync (srcpath, dstpath) {
- srcpath = normalizePath(srcpath);
- dstpath = normalizePath(dstpath);
- return assertRoot(this.root).linkSync(srcpath, dstpath);
- };
- FS.prototype.symlink = function symlink (srcpath, dstpath, arg3, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var type = typeof arg3 === 'string' ? arg3 : 'file';
- cb = typeof arg3 === 'function' ? arg3 : cb;
- var newCb = wrapCb(cb, 1);
- try {
- if (type !== 'file' && type !== 'dir') {
- return newCb(new ApiError(ErrorCode.EINVAL, "Invalid type: " + type));
- }
- srcpath = normalizePath(srcpath);
- dstpath = normalizePath(dstpath);
- assertRoot(this.root).symlink(srcpath, dstpath, type, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `symlink`.
- * @param srcpath
- * @param dstpath
- * @param type can be either `'dir'` or `'file'` (default is `'file'`)
- */
- FS.prototype.symlinkSync = function symlinkSync (srcpath, dstpath, type) {
- if (!type) {
- type = 'file';
- }
- else if (type !== 'file' && type !== 'dir') {
- throw new ApiError(ErrorCode.EINVAL, "Invalid type: " + type);
- }
- srcpath = normalizePath(srcpath);
- dstpath = normalizePath(dstpath);
- return assertRoot(this.root).symlinkSync(srcpath, dstpath, type);
- };
- /**
- * Asynchronous readlink.
- * @param path
- * @param callback
- */
- FS.prototype.readlink = function readlink (path$$1, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 2);
- try {
- path$$1 = normalizePath(path$$1);
- assertRoot(this.root).readlink(path$$1, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous readlink.
- * @param path
- * @return [String]
- */
- FS.prototype.readlinkSync = function readlinkSync (path$$1) {
- path$$1 = normalizePath(path$$1);
- return assertRoot(this.root).readlinkSync(path$$1);
- };
- // PROPERTY OPERATIONS
- /**
- * Asynchronous `chown`.
- * @param path
- * @param uid
- * @param gid
- * @param callback
- */
- FS.prototype.chown = function chown (path$$1, uid, gid, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- path$$1 = normalizePath(path$$1);
- assertRoot(this.root).chown(path$$1, false, uid, gid, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `chown`.
- * @param path
- * @param uid
- * @param gid
- */
- FS.prototype.chownSync = function chownSync (path$$1, uid, gid) {
- path$$1 = normalizePath(path$$1);
- assertRoot(this.root).chownSync(path$$1, false, uid, gid);
- };
- /**
- * Asynchronous `lchown`.
- * @param path
- * @param uid
- * @param gid
- * @param callback
- */
- FS.prototype.lchown = function lchown (path$$1, uid, gid, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- path$$1 = normalizePath(path$$1);
- assertRoot(this.root).chown(path$$1, true, uid, gid, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `lchown`.
- * @param path
- * @param uid
- * @param gid
- */
- FS.prototype.lchownSync = function lchownSync (path$$1, uid, gid) {
- path$$1 = normalizePath(path$$1);
- assertRoot(this.root).chownSync(path$$1, true, uid, gid);
- };
- /**
- * Asynchronous `chmod`.
- * @param path
- * @param mode
- * @param callback
- */
- FS.prototype.chmod = function chmod (path$$1, mode, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- var numMode = normalizeMode(mode, -1);
- if (numMode < 0) {
- throw new ApiError(ErrorCode.EINVAL, "Invalid mode.");
- }
- assertRoot(this.root).chmod(normalizePath(path$$1), false, numMode, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `chmod`.
- * @param path
- * @param mode
- */
- FS.prototype.chmodSync = function chmodSync (path$$1, mode) {
- var numMode = normalizeMode(mode, -1);
- if (numMode < 0) {
- throw new ApiError(ErrorCode.EINVAL, "Invalid mode.");
- }
- path$$1 = normalizePath(path$$1);
- assertRoot(this.root).chmodSync(path$$1, false, numMode);
- };
- /**
- * Asynchronous `lchmod`.
- * @param path
- * @param mode
- * @param callback
- */
- FS.prototype.lchmod = function lchmod (path$$1, mode, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- var numMode = normalizeMode(mode, -1);
- if (numMode < 0) {
- throw new ApiError(ErrorCode.EINVAL, "Invalid mode.");
- }
- assertRoot(this.root).chmod(normalizePath(path$$1), true, numMode, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `lchmod`.
- * @param path
- * @param mode
- */
- FS.prototype.lchmodSync = function lchmodSync (path$$1, mode) {
- var numMode = normalizeMode(mode, -1);
- if (numMode < 1) {
- throw new ApiError(ErrorCode.EINVAL, "Invalid mode.");
- }
- assertRoot(this.root).chmodSync(normalizePath(path$$1), true, numMode);
- };
- /**
- * Change file timestamps of the file referenced by the supplied path.
- * @param path
- * @param atime
- * @param mtime
- * @param callback
- */
- FS.prototype.utimes = function utimes (path$$1, atime, mtime, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var newCb = wrapCb(cb, 1);
- try {
- assertRoot(this.root).utimes(normalizePath(path$$1), normalizeTime(atime), normalizeTime(mtime), newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Change file timestamps of the file referenced by the supplied path.
- * @param path
- * @param atime
- * @param mtime
- */
- FS.prototype.utimesSync = function utimesSync (path$$1, atime, mtime) {
- assertRoot(this.root).utimesSync(normalizePath(path$$1), normalizeTime(atime), normalizeTime(mtime));
- };
- FS.prototype.realpath = function realpath (path$$1, arg2, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- var cache = typeof (arg2) === 'object' ? arg2 : {};
- cb = typeof (arg2) === 'function' ? arg2 : nopCb;
- var newCb = wrapCb(cb, 2);
- try {
- path$$1 = normalizePath(path$$1);
- assertRoot(this.root).realpath(path$$1, cache, newCb);
- }
- catch (e) {
- newCb(e);
- }
- };
- /**
- * Synchronous `realpath`.
- * @param path
- * @param cache An object literal of mapped paths that can be used to
- * force a specific path resolution or avoid additional `fs.stat` calls for
- * known real paths.
- * @return [String]
- */
- FS.prototype.realpathSync = function realpathSync (path$$1, cache) {
- if ( cache === void 0 ) cache = {};
-
- path$$1 = normalizePath(path$$1);
- return assertRoot(this.root).realpathSync(path$$1, cache);
- };
- FS.prototype.watchFile = function watchFile (filename, arg2, listener) {
- if ( listener === void 0 ) listener = nopCb;
-
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- FS.prototype.unwatchFile = function unwatchFile (filename, listener) {
- if ( listener === void 0 ) listener = nopCb;
-
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- FS.prototype.watch = function watch (filename, arg2, listener) {
- if ( listener === void 0 ) listener = nopCb;
-
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- FS.prototype.access = function access (path$$1, arg2, cb) {
- if ( cb === void 0 ) cb = nopCb;
-
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- FS.prototype.accessSync = function accessSync (path$$1, mode) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- FS.prototype.createReadStream = function createReadStream (path$$1, options) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- FS.prototype.createWriteStream = function createWriteStream (path$$1, options) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- /**
- * For unit testing. Passes all incoming callbacks to cbWrapper for wrapping.
- */
- FS.prototype.wrapCallbacks = function wrapCallbacks (cbWrapper) {
- wrapCb = cbWrapper;
- };
- FS.prototype.getFdForFile = function getFdForFile (file) {
- var fd = this.nextFd++;
- this.fdMap[fd] = file;
- return fd;
- };
- FS.prototype.fd2file = function fd2file (fd) {
- var rv = this.fdMap[fd];
- if (rv) {
- return rv;
- }
- else {
- throw new ApiError(ErrorCode.EBADF, 'Invalid file descriptor.');
- }
- };
- FS.prototype.closeFd = function closeFd (fd) {
- delete this.fdMap[fd];
- };
-
- /* tslint:disable:variable-name */
- // Exported fs.Stats.
- FS.Stats = Stats;
-
- // Manually export the individual public functions of fs.
- // Required because some code will invoke functions off of the module.
- // e.g.:
- // let writeFile = fs.writeFile;
- // writeFile(...)
- /**
- * @hidden
- */
- var fs = new FS();
- /**
- * @hidden
- */
- var _fsMock = {};
- /**
- * @hidden
- */
- var fsProto = FS.prototype;
- Object.keys(fsProto).forEach(function (key) {
- if (typeof fs[key] === 'function') {
- _fsMock[key] = function () {
- return fs[key].apply(fs, arguments);
- };
- }
- else {
- _fsMock[key] = fs[key];
- }
- });
- _fsMock['changeFSModule'] = function (newFs) {
- fs = newFs;
- };
- _fsMock['getFSModule'] = function () {
- return fs;
- };
- _fsMock['FS'] = FS;
-
- /*
- * Levenshtein distance, from the `js-levenshtein` NPM module.
- * Copied here to avoid complexity of adding another CommonJS module dependency.
- */
- function _min(d0, d1, d2, bx, ay) {
- return d0 < d1 || d2 < d1
- ? d0 > d2
- ? d2 + 1
- : d0 + 1
- : bx === ay
- ? d1
- : d1 + 1;
- }
- /**
- * Calculates levenshtein distance.
- * @param a
- * @param b
- */
- function levenshtein(a, b) {
- if (a === b) {
- return 0;
- }
- if (a.length > b.length) {
- var tmp = a;
- a = b;
- b = tmp;
- }
- var la = a.length;
- var lb = b.length;
- while (la > 0 && (a.charCodeAt(la - 1) === b.charCodeAt(lb - 1))) {
- la--;
- lb--;
- }
- var offset = 0;
- while (offset < la && (a.charCodeAt(offset) === b.charCodeAt(offset))) {
- offset++;
- }
- la -= offset;
- lb -= offset;
- if (la === 0 || lb === 1) {
- return lb;
- }
- var vector = new Array(la << 1);
- for (var y = 0; y < la;) {
- vector[la + y] = a.charCodeAt(offset + y);
- vector[y] = ++y;
- }
- var x;
- var d0;
- var d1;
- var d2;
- var d3;
- for (x = 0; (x + 3) < lb;) {
- var bx0 = b.charCodeAt(offset + (d0 = x));
- var bx1 = b.charCodeAt(offset + (d1 = x + 1));
- var bx2 = b.charCodeAt(offset + (d2 = x + 2));
- var bx3 = b.charCodeAt(offset + (d3 = x + 3));
- var dd$1 = (x += 4);
- for (var y$1 = 0; y$1 < la;) {
- var ay = vector[la + y$1];
- var dy = vector[y$1];
- d0 = _min(dy, d0, d1, bx0, ay);
- d1 = _min(d0, d1, d2, bx1, ay);
- d2 = _min(d1, d2, d3, bx2, ay);
- dd$1 = _min(d2, d3, dd$1, bx3, ay);
- vector[y$1++] = dd$1;
- d3 = d2;
- d2 = d1;
- d1 = d0;
- d0 = dy;
- }
- }
- var dd = 0;
- for (; x < lb;) {
- var bx0$1 = b.charCodeAt(offset + (d0 = x));
- dd = ++x;
- for (var y$2 = 0; y$2 < la; y$2++) {
- var dy$1 = vector[y$2];
- vector[y$2] = dd = dy$1 < d0 || dd < d0
- ? dy$1 > dd ? dd + 1 : dy$1 + 1
- : bx0$1 === vector[la + y$2]
- ? d0
- : d0 + 1;
- d0 = dy$1;
- }
- }
- return dd;
- }
-
- function deprecationMessage(print, fsName, opts) {
- if (print) {
- console.warn(("[" + fsName + "] Direct file system constructor usage is deprecated for this file system, and will be removed in the next major version. Please use the '" + fsName + ".Create(" + (JSON.stringify(opts)) + ", callback)' method instead. See https://github.com/jvilk/BrowserFS/issues/176 for more details."));
- }
- }
- /**
- * Checks for any IE version, including IE11 which removed MSIE from the
- * userAgent string.
- * @hidden
- */
- var isIE = typeof navigator !== "undefined" && !!(/(msie) ([\w.]+)/.exec(navigator.userAgent.toLowerCase()) || navigator.userAgent.indexOf('Trident') !== -1);
- /**
- * Check if we're in a web worker.
- * @hidden
- */
- var isWebWorker = typeof window === "undefined";
- /**
- * Throws an exception. Called on code paths that should be impossible.
- * @hidden
- */
- function fail() {
- throw new Error("BFS has reached an impossible code path; please file a bug.");
- }
- /**
- * Synchronous recursive makedir.
- * @hidden
- */
- function mkdirpSync(p, mode, fs) {
- if (!fs.existsSync(p)) {
- mkdirpSync(path.dirname(p), mode, fs);
- fs.mkdirSync(p, mode);
- }
- }
- /**
- * Converts a buffer into an array buffer. Attempts to do so in a
- * zero-copy manner, e.g. the array references the same memory.
- * @hidden
- */
- function buffer2ArrayBuffer(buff) {
- var u8 = buffer2Uint8array(buff), u8offset = u8.byteOffset, u8Len = u8.byteLength;
- if (u8offset === 0 && u8Len === u8.buffer.byteLength) {
- return u8.buffer;
- }
- else {
- return u8.buffer.slice(u8offset, u8offset + u8Len);
- }
- }
- /**
- * Converts a buffer into a Uint8Array. Attempts to do so in a
- * zero-copy manner, e.g. the array references the same memory.
- * @hidden
- */
- function buffer2Uint8array(buff) {
- if (buff instanceof Uint8Array) {
- // BFS & Node v4.0 buffers *are* Uint8Arrays.
- return buff;
- }
- else {
- // Uint8Arrays can be constructed from arrayish numbers.
- // At this point, we assume this isn't a BFS array.
- return new Uint8Array(buff);
- }
- }
- /**
- * Converts the given arrayish object into a Buffer. Attempts to
- * be zero-copy.
- * @hidden
- */
- function arrayish2Buffer(arr) {
- if (arr instanceof Buffer) {
- return arr;
- }
- else if (arr instanceof Uint8Array) {
- return uint8Array2Buffer(arr);
- }
- else {
- return Buffer.from(arr);
- }
- }
- /**
- * Converts the given Uint8Array into a Buffer. Attempts to be zero-copy.
- * @hidden
- */
- function uint8Array2Buffer(u8) {
- if (u8 instanceof Buffer) {
- return u8;
- }
- else if (u8.byteOffset === 0 && u8.byteLength === u8.buffer.byteLength) {
- return arrayBuffer2Buffer(u8.buffer);
- }
- else {
- return Buffer.from(u8.buffer, u8.byteOffset, u8.byteLength);
- }
- }
- /**
- * Converts the given array buffer into a Buffer. Attempts to be
- * zero-copy.
- * @hidden
- */
- function arrayBuffer2Buffer(ab) {
- return Buffer.from(ab);
- }
- /**
- * Copies a slice of the given buffer
- * @hidden
- */
- function copyingSlice(buff, start, end) {
- if ( start === void 0 ) start = 0;
- if ( end === void 0 ) end = buff.length;
-
- if (start < 0 || end < 0 || end > buff.length || start > end) {
- throw new TypeError(("Invalid slice bounds on buffer of length " + (buff.length) + ": [" + start + ", " + end + "]"));
- }
- if (buff.length === 0) {
- // Avoid s0 corner case in ArrayBuffer case.
- return emptyBuffer();
- }
- else {
- var u8 = buffer2Uint8array(buff), s0 = buff[0], newS0 = (s0 + 1) % 0xFF;
- buff[0] = newS0;
- if (u8[0] === newS0) {
- // Same memory. Revert & copy.
- u8[0] = s0;
- return uint8Array2Buffer(u8.slice(start, end));
- }
- else {
- // Revert.
- buff[0] = s0;
- return uint8Array2Buffer(u8.subarray(start, end));
- }
- }
- }
- /**
- * @hidden
- */
- var emptyBuff = null;
- /**
- * Returns an empty buffer.
- * @hidden
- */
- function emptyBuffer() {
- if (emptyBuff) {
- return emptyBuff;
- }
- return emptyBuff = Buffer.alloc(0);
- }
- /**
- * Option validator for a Buffer file system option.
- * @hidden
- */
- function bufferValidator(v, cb) {
- if (Buffer.isBuffer(v)) {
- cb();
- }
- else {
- cb(new ApiError(ErrorCode.EINVAL, "option must be a Buffer."));
- }
- }
- /**
- * Checks that the given options object is valid for the file system options.
- * @hidden
- */
- function checkOptions(fsType, opts, cb) {
- var optsInfo = fsType.Options;
- var fsName = fsType.Name;
- var pendingValidators = 0;
- var callbackCalled = false;
- var loopEnded = false;
- function validatorCallback(e) {
- if (!callbackCalled) {
- if (e) {
- callbackCalled = true;
- cb(e);
- }
- pendingValidators--;
- if (pendingValidators === 0 && loopEnded) {
- cb();
- }
- }
- }
- // Check for required options.
- var loop = function ( optName ) {
- if (optsInfo.hasOwnProperty(optName)) {
- var opt = optsInfo[optName];
- var providedValue = opts[optName];
- if (providedValue === undefined || providedValue === null) {
- if (!opt.optional) {
- // Required option, not provided.
- // Any incorrect options provided? Which ones are close to the provided one?
- // (edit distance 5 === close)
- var incorrectOptions = Object.keys(opts).filter(function (o) { return !(o in optsInfo); }).map(function (a) {
- return { str: a, distance: levenshtein(optName, a) };
- }).filter(function (o) { return o.distance < 5; }).sort(function (a, b) { return a.distance - b.distance; });
- // Validators may be synchronous.
- if (callbackCalled) {
- return {};
- }
- callbackCalled = true;
- return { v: cb(new ApiError(ErrorCode.EINVAL, ("[" + fsName + "] Required option '" + optName + "' not provided." + (incorrectOptions.length > 0 ? (" You provided unrecognized option '" + (incorrectOptions[0].str) + "'; perhaps you meant to type '" + optName + "'.") : '') + "\nOption description: " + (opt.description)))) };
- }
- // Else: Optional option, not provided. That is OK.
- }
- else {
- // Option provided! Check type.
- var typeMatches = false;
- if (Array.isArray(opt.type)) {
- typeMatches = opt.type.indexOf(typeof (providedValue)) !== -1;
- }
- else {
- typeMatches = typeof (providedValue) === opt.type;
- }
- if (!typeMatches) {
- // Validators may be synchronous.
- if (callbackCalled) {
- return {};
- }
- callbackCalled = true;
- return { v: cb(new ApiError(ErrorCode.EINVAL, ("[" + fsName + "] Value provided for option " + optName + " is not the proper type. Expected " + (Array.isArray(opt.type) ? ("one of {" + (opt.type.join(", ")) + "}") : opt.type) + ", but received " + (typeof (providedValue)) + "\nOption description: " + (opt.description)))) };
- }
- else if (opt.validator) {
- pendingValidators++;
- opt.validator(providedValue, validatorCallback);
- }
- // Otherwise: All good!
- }
- }
- };
-
- for (var optName in optsInfo) {
- var returned = loop( optName );
-
- if ( returned ) return returned.v;
- }
- loopEnded = true;
- if (pendingValidators === 0 && !callbackCalled) {
- cb();
- }
- }
-
-
- var BFSUtils = Object.freeze({
- deprecationMessage: deprecationMessage,
- isIE: isIE,
- isWebWorker: isWebWorker,
- fail: fail,
- mkdirpSync: mkdirpSync,
- buffer2ArrayBuffer: buffer2ArrayBuffer,
- buffer2Uint8array: buffer2Uint8array,
- arrayish2Buffer: arrayish2Buffer,
- uint8Array2Buffer: uint8Array2Buffer,
- arrayBuffer2Buffer: arrayBuffer2Buffer,
- copyingSlice: copyingSlice,
- emptyBuffer: emptyBuffer,
- bufferValidator: bufferValidator,
- checkOptions: checkOptions
- });
-
- var BFSEmscriptenStreamOps = function BFSEmscriptenStreamOps(fs) {
- this.fs = fs;
- this.nodefs = fs.getNodeFS();
- this.FS = fs.getFS();
- this.PATH = fs.getPATH();
- this.ERRNO_CODES = fs.getERRNO_CODES();
- };
- BFSEmscriptenStreamOps.prototype.open = function open (stream) {
- var path$$1 = this.fs.realPath(stream.node);
- var FS = this.FS;
- try {
- if (FS.isFile(stream.node.mode)) {
- stream.nfd = this.nodefs.openSync(path$$1, this.fs.flagsToPermissionString(stream.flags));
- }
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- throw new FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- };
- BFSEmscriptenStreamOps.prototype.close = function close (stream) {
- var FS = this.FS;
- try {
- if (FS.isFile(stream.node.mode) && stream.nfd) {
- this.nodefs.closeSync(stream.nfd);
- }
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- throw new FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- };
- BFSEmscriptenStreamOps.prototype.read = function read (stream, buffer$$1, offset, length, position) {
- // Avoid copying overhead by reading directly into buffer.
- try {
- return this.nodefs.readSync(stream.nfd, uint8Array2Buffer(buffer$$1), offset, length, position);
- }
- catch (e) {
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- };
- BFSEmscriptenStreamOps.prototype.write = function write (stream, buffer$$1, offset, length, position) {
- // Avoid copying overhead.
- try {
- return this.nodefs.writeSync(stream.nfd, uint8Array2Buffer(buffer$$1), offset, length, position);
- }
- catch (e) {
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- };
- BFSEmscriptenStreamOps.prototype.llseek = function llseek (stream, offset, whence) {
- var position = offset;
- if (whence === 1) {
- position += stream.position;
- }
- else if (whence === 2) {
- if (this.FS.isFile(stream.node.mode)) {
- try {
- var stat = this.nodefs.fstatSync(stream.nfd);
- position += stat.size;
- }
- catch (e) {
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- }
- }
- if (position < 0) {
- throw new this.FS.ErrnoError(this.ERRNO_CODES.EINVAL);
- }
- stream.position = position;
- return position;
- };
- var BFSEmscriptenNodeOps = function BFSEmscriptenNodeOps(fs) {
- this.fs = fs;
- this.nodefs = fs.getNodeFS();
- this.FS = fs.getFS();
- this.PATH = fs.getPATH();
- this.ERRNO_CODES = fs.getERRNO_CODES();
- };
- BFSEmscriptenNodeOps.prototype.getattr = function getattr (node) {
- var path$$1 = this.fs.realPath(node);
- var stat;
- try {
- stat = this.nodefs.lstatSync(path$$1);
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- return {
- dev: stat.dev,
- ino: stat.ino,
- mode: stat.mode,
- nlink: stat.nlink,
- uid: stat.uid,
- gid: stat.gid,
- rdev: stat.rdev,
- size: stat.size,
- atime: stat.atime,
- mtime: stat.mtime,
- ctime: stat.ctime,
- blksize: stat.blksize,
- blocks: stat.blocks
- };
- };
- BFSEmscriptenNodeOps.prototype.setattr = function setattr (node, attr) {
- var path$$1 = this.fs.realPath(node);
- try {
- if (attr.mode !== undefined) {
- this.nodefs.chmodSync(path$$1, attr.mode);
- // update the common node structure mode as well
- node.mode = attr.mode;
- }
- if (attr.timestamp !== undefined) {
- var date = new Date(attr.timestamp);
- this.nodefs.utimesSync(path$$1, date, date);
- }
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- // Ignore not supported errors. Emscripten does utimesSync when it
- // writes files, but never really requires the value to be set.
- if (e.code !== "ENOTSUP") {
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- }
- if (attr.size !== undefined) {
- try {
- this.nodefs.truncateSync(path$$1, attr.size);
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- }
- };
- BFSEmscriptenNodeOps.prototype.lookup = function lookup (parent, name) {
- var path$$1 = this.PATH.join2(this.fs.realPath(parent), name);
- var mode = this.fs.getMode(path$$1);
- return this.fs.createNode(parent, name, mode);
- };
- BFSEmscriptenNodeOps.prototype.mknod = function mknod (parent, name, mode, dev) {
- var node = this.fs.createNode(parent, name, mode, dev);
- // create the backing node for this in the fs root as well
- var path$$1 = this.fs.realPath(node);
- try {
- if (this.FS.isDir(node.mode)) {
- this.nodefs.mkdirSync(path$$1, node.mode);
- }
- else {
- this.nodefs.writeFileSync(path$$1, '', { mode: node.mode });
- }
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- return node;
- };
- BFSEmscriptenNodeOps.prototype.rename = function rename (oldNode, newDir, newName) {
- var oldPath = this.fs.realPath(oldNode);
- var newPath = this.PATH.join2(this.fs.realPath(newDir), newName);
- try {
- this.nodefs.renameSync(oldPath, newPath);
- // This logic is missing from the original NodeFS,
- // causing Emscripten's filesystem to think that the old file still exists.
- oldNode.name = newName;
- oldNode.parent = newDir;
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- };
- BFSEmscriptenNodeOps.prototype.unlink = function unlink (parent, name) {
- var path$$1 = this.PATH.join2(this.fs.realPath(parent), name);
- try {
- this.nodefs.unlinkSync(path$$1);
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- };
- BFSEmscriptenNodeOps.prototype.rmdir = function rmdir (parent, name) {
- var path$$1 = this.PATH.join2(this.fs.realPath(parent), name);
- try {
- this.nodefs.rmdirSync(path$$1);
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- };
- BFSEmscriptenNodeOps.prototype.readdir = function readdir (node) {
- var path$$1 = this.fs.realPath(node);
- try {
- // Node does not list . and .. in directory listings,
- // but Emscripten expects it.
- var contents = this.nodefs.readdirSync(path$$1);
- contents.push('.', '..');
- return contents;
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- };
- BFSEmscriptenNodeOps.prototype.symlink = function symlink (parent, newName, oldPath) {
- var newPath = this.PATH.join2(this.fs.realPath(parent), newName);
- try {
- this.nodefs.symlinkSync(oldPath, newPath);
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- };
- BFSEmscriptenNodeOps.prototype.readlink = function readlink (node) {
- var path$$1 = this.fs.realPath(node);
- try {
- return this.nodefs.readlinkSync(path$$1);
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- };
- var BFSEmscriptenFS = function BFSEmscriptenFS(_FS, _PATH, _ERRNO_CODES, nodefs) {
- if ( _FS === void 0 ) _FS = self['FS'];
- if ( _PATH === void 0 ) _PATH = self['PATH'];
- if ( _ERRNO_CODES === void 0 ) _ERRNO_CODES = self['ERRNO_CODES'];
- if ( nodefs === void 0 ) nodefs = _fsMock;
-
- // This maps the integer permission modes from http://linux.die.net/man/3/open
- // to node.js-specific file open permission strings at http://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback
- this.flagsToPermissionStringMap = {
- 0 /*O_RDONLY*/: 'r',
- 1 /*O_WRONLY*/: 'r+',
- 2 /*O_RDWR*/: 'r+',
- 64 /*O_CREAT*/: 'r',
- 65 /*O_WRONLY|O_CREAT*/: 'r+',
- 66 /*O_RDWR|O_CREAT*/: 'r+',
- 129 /*O_WRONLY|O_EXCL*/: 'rx+',
- 193 /*O_WRONLY|O_CREAT|O_EXCL*/: 'rx+',
- 514 /*O_RDWR|O_TRUNC*/: 'w+',
- 577 /*O_WRONLY|O_CREAT|O_TRUNC*/: 'w',
- 578 /*O_CREAT|O_RDWR|O_TRUNC*/: 'w+',
- 705 /*O_WRONLY|O_CREAT|O_EXCL|O_TRUNC*/: 'wx',
- 706 /*O_RDWR|O_CREAT|O_EXCL|O_TRUNC*/: 'wx+',
- 1024 /*O_APPEND*/: 'a',
- 1025 /*O_WRONLY|O_APPEND*/: 'a',
- 1026 /*O_RDWR|O_APPEND*/: 'a+',
- 1089 /*O_WRONLY|O_CREAT|O_APPEND*/: 'a',
- 1090 /*O_RDWR|O_CREAT|O_APPEND*/: 'a+',
- 1153 /*O_WRONLY|O_EXCL|O_APPEND*/: 'ax',
- 1154 /*O_RDWR|O_EXCL|O_APPEND*/: 'ax+',
- 1217 /*O_WRONLY|O_CREAT|O_EXCL|O_APPEND*/: 'ax',
- 1218 /*O_RDWR|O_CREAT|O_EXCL|O_APPEND*/: 'ax+',
- 4096 /*O_RDONLY|O_DSYNC*/: 'rs',
- 4098 /*O_RDWR|O_DSYNC*/: 'rs+'
- };
- this.nodefs = nodefs;
- this.FS = _FS;
- this.PATH = _PATH;
- this.ERRNO_CODES = _ERRNO_CODES;
- this.node_ops = new BFSEmscriptenNodeOps(this);
- this.stream_ops = new BFSEmscriptenStreamOps(this);
- };
- BFSEmscriptenFS.prototype.mount = function mount (m) {
- return this.createNode(null, '/', this.getMode(m.opts.root), 0);
- };
- BFSEmscriptenFS.prototype.createNode = function createNode (parent, name, mode, dev) {
- var FS = this.FS;
- if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {
- throw new FS.ErrnoError(this.ERRNO_CODES.EINVAL);
- }
- var node = FS.createNode(parent, name, mode);
- node.node_ops = this.node_ops;
- node.stream_ops = this.stream_ops;
- return node;
- };
- BFSEmscriptenFS.prototype.getMode = function getMode (path$$1) {
- var stat;
- try {
- stat = this.nodefs.lstatSync(path$$1);
- }
- catch (e) {
- if (!e.code) {
- throw e;
- }
- throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);
- }
- return stat.mode;
- };
- BFSEmscriptenFS.prototype.realPath = function realPath (node) {
- var parts = [];
- while (node.parent !== node) {
- parts.push(node.name);
- node = node.parent;
- }
- parts.push(node.mount.opts.root);
- parts.reverse();
- return this.PATH.join.apply(null, parts);
- };
- BFSEmscriptenFS.prototype.flagsToPermissionString = function flagsToPermissionString (flags) {
- var parsedFlags = (typeof flags === "string") ? parseInt(flags, 10) : flags;
- parsedFlags &= 0x1FFF;
- if (parsedFlags in this.flagsToPermissionStringMap) {
- return this.flagsToPermissionStringMap[parsedFlags];
- }
- else {
- return flags;
- }
- };
- BFSEmscriptenFS.prototype.getNodeFS = function getNodeFS () {
- return this.nodefs;
- };
- BFSEmscriptenFS.prototype.getFS = function getFS () {
- return this.FS;
- };
- BFSEmscriptenFS.prototype.getPATH = function getPATH () {
- return this.PATH;
- };
- BFSEmscriptenFS.prototype.getERRNO_CODES = function getERRNO_CODES () {
- return this.ERRNO_CODES;
- };
-
- /**
- * Basic filesystem class. Most filesystems should extend this class, as it
- * provides default implementations for a handful of methods.
- */
- var BaseFileSystem = function BaseFileSystem () {};
-
- BaseFileSystem.prototype.supportsLinks = function supportsLinks () {
- return false;
- };
- BaseFileSystem.prototype.diskSpace = function diskSpace (p, cb) {
- cb(0, 0);
- };
- /**
- * Opens the file at path p with the given flag. The file must exist.
- * @param p The path to open.
- * @param flag The flag to use when opening the file.
- */
- BaseFileSystem.prototype.openFile = function openFile (p, flag, cb) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- /**
- * Create the file at path p with the given mode. Then, open it with the given
- * flag.
- */
- BaseFileSystem.prototype.createFile = function createFile (p, flag, mode, cb) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFileSystem.prototype.open = function open (p, flag, mode, cb) {
- var this$1 = this;
-
- var mustBeFile = function (e, stats) {
- if (e) {
- // File does not exist.
- switch (flag.pathNotExistsAction()) {
- case ActionType.CREATE_FILE:
- // Ensure parent exists.
- return this$1.stat(path.dirname(p), false, function (e, parentStats) {
- if (e) {
- cb(e);
- }
- else if (parentStats && !parentStats.isDirectory()) {
- cb(ApiError.ENOTDIR(path.dirname(p)));
- }
- else {
- this$1.createFile(p, flag, mode, cb);
- }
- });
- case ActionType.THROW_EXCEPTION:
- return cb(ApiError.ENOENT(p));
- default:
- return cb(new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.'));
- }
- }
- else {
- // File exists.
- if (stats && stats.isDirectory()) {
- return cb(ApiError.EISDIR(p));
- }
- switch (flag.pathExistsAction()) {
- case ActionType.THROW_EXCEPTION:
- return cb(ApiError.EEXIST(p));
- case ActionType.TRUNCATE_FILE:
- // NOTE: In a previous implementation, we deleted the file and
- // re-created it. However, this created a race condition if another
- // asynchronous request was trying to read the file, as the file
- // would not exist for a small period of time.
- return this$1.openFile(p, flag, function (e, fd) {
- if (e) {
- cb(e);
- }
- else if (fd) {
- fd.truncate(0, function () {
- fd.sync(function () {
- cb(null, fd);
- });
- });
- }
- else {
- fail();
- }
- });
- case ActionType.NOP:
- return this$1.openFile(p, flag, cb);
- default:
- return cb(new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.'));
- }
- }
- };
- this.stat(p, false, mustBeFile);
- };
- BaseFileSystem.prototype.rename = function rename (oldPath, newPath, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFileSystem.prototype.renameSync = function renameSync (oldPath, newPath) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFileSystem.prototype.stat = function stat (p, isLstat, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFileSystem.prototype.statSync = function statSync (p, isLstat) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- /**
- * Opens the file at path p with the given flag. The file must exist.
- * @param p The path to open.
- * @param flag The flag to use when opening the file.
- * @return A File object corresponding to the opened file.
- */
- BaseFileSystem.prototype.openFileSync = function openFileSync (p, flag, mode) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- /**
- * Create the file at path p with the given mode. Then, open it with the given
- * flag.
- */
- BaseFileSystem.prototype.createFileSync = function createFileSync (p, flag, mode) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFileSystem.prototype.openSync = function openSync (p, flag, mode) {
- // Check if the path exists, and is a file.
- var stats;
- try {
- stats = this.statSync(p, false);
- }
- catch (e) {
- // File does not exist.
- switch (flag.pathNotExistsAction()) {
- case ActionType.CREATE_FILE:
- // Ensure parent exists.
- var parentStats = this.statSync(path.dirname(p), false);
- if (!parentStats.isDirectory()) {
- throw ApiError.ENOTDIR(path.dirname(p));
- }
- return this.createFileSync(p, flag, mode);
- case ActionType.THROW_EXCEPTION:
- throw ApiError.ENOENT(p);
- default:
- throw new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.');
- }
- }
- // File exists.
- if (stats.isDirectory()) {
- throw ApiError.EISDIR(p);
- }
- switch (flag.pathExistsAction()) {
- case ActionType.THROW_EXCEPTION:
- throw ApiError.EEXIST(p);
- case ActionType.TRUNCATE_FILE:
- // Delete file.
- this.unlinkSync(p);
- // Create file. Use the same mode as the old file.
- // Node itself modifies the ctime when this occurs, so this action
- // will preserve that behavior if the underlying file system
- // supports those properties.
- return this.createFileSync(p, flag, stats.mode);
- case ActionType.NOP:
- return this.openFileSync(p, flag, mode);
- default:
- throw new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.');
- }
- };
- BaseFileSystem.prototype.unlink = function unlink (p, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFileSystem.prototype.unlinkSync = function unlinkSync (p) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFileSystem.prototype.rmdir = function rmdir (p, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFileSystem.prototype.rmdirSync = function rmdirSync (p) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFileSystem.prototype.mkdir = function mkdir (p, mode, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFileSystem.prototype.mkdirSync = function mkdirSync (p, mode) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFileSystem.prototype.readdir = function readdir (p, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFileSystem.prototype.readdirSync = function readdirSync (p) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFileSystem.prototype.exists = function exists (p, cb) {
- this.stat(p, null, function (err) {
- cb(!err);
- });
- };
- BaseFileSystem.prototype.existsSync = function existsSync (p) {
- try {
- this.statSync(p, true);
- return true;
- }
- catch (e) {
- return false;
- }
- };
- BaseFileSystem.prototype.realpath = function realpath (p, cache, cb) {
- if (this.supportsLinks()) {
- // The path could contain symlinks. Split up the path,
- // resolve any symlinks, return the resolved string.
- var splitPath = p.split(path.sep);
- // TODO: Simpler to just pass through file, find sep and such.
- for (var i = 0; i < splitPath.length; i++) {
- var addPaths = splitPath.slice(0, i + 1);
- splitPath[i] = path.join.apply(null, addPaths);
- }
- }
- else {
- // No symlinks. We just need to verify that it exists.
- this.exists(p, function (doesExist) {
- if (doesExist) {
- cb(null, p);
- }
- else {
- cb(ApiError.ENOENT(p));
- }
- });
- }
- };
- BaseFileSystem.prototype.realpathSync = function realpathSync (p, cache) {
- if (this.supportsLinks()) {
- // The path could contain symlinks. Split up the path,
- // resolve any symlinks, return the resolved string.
- var splitPath = p.split(path.sep);
- // TODO: Simpler to just pass through file, find sep and such.
- for (var i = 0; i < splitPath.length; i++) {
- var addPaths = splitPath.slice(0, i + 1);
- splitPath[i] = path.join.apply(path, addPaths);
- }
- return splitPath.join(path.sep);
- }
- else {
- // No symlinks. We just need to verify that it exists.
- if (this.existsSync(p)) {
- return p;
- }
- else {
- throw ApiError.ENOENT(p);
- }
- }
- };
- BaseFileSystem.prototype.truncate = function truncate (p, len, cb) {
- this.open(p, FileFlag.getFileFlag('r+'), 0x1a4, (function (er, fd) {
- if (er) {
- return cb(er);
- }
- fd.truncate(len, (function (er) {
- fd.close((function (er2) {
- cb(er || er2);
- }));
- }));
- }));
- };
- BaseFileSystem.prototype.truncateSync = function truncateSync (p, len) {
- var fd = this.openSync(p, FileFlag.getFileFlag('r+'), 0x1a4);
- // Need to safely close FD, regardless of whether or not truncate succeeds.
- try {
- fd.truncateSync(len);
- }
- catch (e) {
- throw e;
- }
- finally {
- fd.closeSync();
- }
- };
- BaseFileSystem.prototype.readFile = function readFile (fname, encoding, flag, cb) {
- // Wrap cb in file closing code.
- var oldCb = cb;
- // Get file.
- this.open(fname, flag, 0x1a4, function (err, fd) {
- if (err) {
- return cb(err);
- }
- cb = function (err, arg) {
- fd.close(function (err2) {
- if (!err) {
- err = err2;
- }
- return oldCb(err, arg);
- });
- };
- fd.stat(function (err, stat) {
- if (err) {
- return cb(err);
- }
- // Allocate buffer.
- var buf = Buffer.alloc(stat.size);
- fd.read(buf, 0, stat.size, 0, function (err) {
- if (err) {
- return cb(err);
- }
- else if (encoding === null) {
- return cb(err, buf);
- }
- try {
- cb(null, buf.toString(encoding));
- }
- catch (e) {
- cb(e);
- }
- });
- });
- });
- };
- BaseFileSystem.prototype.readFileSync = function readFileSync (fname, encoding, flag) {
- // Get file.
- var fd = this.openSync(fname, flag, 0x1a4);
- try {
- var stat = fd.statSync();
- // Allocate buffer.
- var buf = Buffer.alloc(stat.size);
- fd.readSync(buf, 0, stat.size, 0);
- fd.closeSync();
- if (encoding === null) {
- return buf;
- }
- return buf.toString(encoding);
- }
- finally {
- fd.closeSync();
- }
- };
- BaseFileSystem.prototype.writeFile = function writeFile (fname, data, encoding, flag, mode, cb) {
- // Wrap cb in file closing code.
- var oldCb = cb;
- // Get file.
- this.open(fname, flag, 0x1a4, function (err, fd) {
- if (err) {
- return cb(err);
- }
- cb = function (err) {
- fd.close(function (err2) {
- oldCb(err ? err : err2);
- });
- };
- try {
- if (typeof data === 'string') {
- data = Buffer.from(data, encoding);
- }
- }
- catch (e) {
- return cb(e);
- }
- // Write into file.
- fd.write(data, 0, data.length, 0, cb);
- });
- };
- BaseFileSystem.prototype.writeFileSync = function writeFileSync (fname, data, encoding, flag, mode) {
- // Get file.
- var fd = this.openSync(fname, flag, mode);
- try {
- if (typeof data === 'string') {
- data = Buffer.from(data, encoding);
- }
- // Write into file.
- fd.writeSync(data, 0, data.length, 0);
- }
- finally {
- fd.closeSync();
- }
- };
- BaseFileSystem.prototype.appendFile = function appendFile (fname, data, encoding, flag, mode, cb) {
- // Wrap cb in file closing code.
- var oldCb = cb;
- this.open(fname, flag, mode, function (err, fd) {
- if (err) {
- return cb(err);
- }
- cb = function (err) {
- fd.close(function (err2) {
- oldCb(err ? err : err2);
- });
- };
- if (typeof data === 'string') {
- data = Buffer.from(data, encoding);
- }
- fd.write(data, 0, data.length, null, cb);
- });
- };
- BaseFileSystem.prototype.appendFileSync = function appendFileSync (fname, data, encoding, flag, mode) {
- var fd = this.openSync(fname, flag, mode);
- try {
- if (typeof data === 'string') {
- data = Buffer.from(data, encoding);
- }
- fd.writeSync(data, 0, data.length, null);
- }
- finally {
- fd.closeSync();
- }
- };
- BaseFileSystem.prototype.chmod = function chmod (p, isLchmod, mode, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFileSystem.prototype.chmodSync = function chmodSync (p, isLchmod, mode) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFileSystem.prototype.chown = function chown (p, isLchown, uid, gid, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFileSystem.prototype.chownSync = function chownSync (p, isLchown, uid, gid) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFileSystem.prototype.utimes = function utimes (p, atime, mtime, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFileSystem.prototype.utimesSync = function utimesSync (p, atime, mtime) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFileSystem.prototype.link = function link (srcpath, dstpath, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFileSystem.prototype.linkSync = function linkSync (srcpath, dstpath) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFileSystem.prototype.symlink = function symlink (srcpath, dstpath, type, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFileSystem.prototype.symlinkSync = function symlinkSync (srcpath, dstpath, type) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFileSystem.prototype.readlink = function readlink (p, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFileSystem.prototype.readlinkSync = function readlinkSync (p) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- /**
- * Implements the asynchronous API in terms of the synchronous API.
- * @class SynchronousFileSystem
- */
- var SynchronousFileSystem = (function (BaseFileSystem) {
- function SynchronousFileSystem () {
- BaseFileSystem.apply(this, arguments);
- }
-
- if ( BaseFileSystem ) SynchronousFileSystem.__proto__ = BaseFileSystem;
- SynchronousFileSystem.prototype = Object.create( BaseFileSystem && BaseFileSystem.prototype );
- SynchronousFileSystem.prototype.constructor = SynchronousFileSystem;
-
- SynchronousFileSystem.prototype.supportsSynch = function supportsSynch () {
- return true;
- };
- SynchronousFileSystem.prototype.rename = function rename (oldPath, newPath, cb) {
- try {
- this.renameSync(oldPath, newPath);
- cb();
- }
- catch (e) {
- cb(e);
- }
- };
- SynchronousFileSystem.prototype.stat = function stat (p, isLstat, cb) {
- try {
- cb(null, this.statSync(p, isLstat));
- }
- catch (e) {
- cb(e);
- }
- };
- SynchronousFileSystem.prototype.open = function open (p, flags, mode, cb) {
- try {
- cb(null, this.openSync(p, flags, mode));
- }
- catch (e) {
- cb(e);
- }
- };
- SynchronousFileSystem.prototype.unlink = function unlink (p, cb) {
- try {
- this.unlinkSync(p);
- cb();
- }
- catch (e) {
- cb(e);
- }
- };
- SynchronousFileSystem.prototype.rmdir = function rmdir (p, cb) {
- try {
- this.rmdirSync(p);
- cb();
- }
- catch (e) {
- cb(e);
- }
- };
- SynchronousFileSystem.prototype.mkdir = function mkdir (p, mode, cb) {
- try {
- this.mkdirSync(p, mode);
- cb();
- }
- catch (e) {
- cb(e);
- }
- };
- SynchronousFileSystem.prototype.readdir = function readdir (p, cb) {
- try {
- cb(null, this.readdirSync(p));
- }
- catch (e) {
- cb(e);
- }
- };
- SynchronousFileSystem.prototype.chmod = function chmod (p, isLchmod, mode, cb) {
- try {
- this.chmodSync(p, isLchmod, mode);
- cb();
- }
- catch (e) {
- cb(e);
- }
- };
- SynchronousFileSystem.prototype.chown = function chown (p, isLchown, uid, gid, cb) {
- try {
- this.chownSync(p, isLchown, uid, gid);
- cb();
- }
- catch (e) {
- cb(e);
- }
- };
- SynchronousFileSystem.prototype.utimes = function utimes (p, atime, mtime, cb) {
- try {
- this.utimesSync(p, atime, mtime);
- cb();
- }
- catch (e) {
- cb(e);
- }
- };
- SynchronousFileSystem.prototype.link = function link (srcpath, dstpath, cb) {
- try {
- this.linkSync(srcpath, dstpath);
- cb();
- }
- catch (e) {
- cb(e);
- }
- };
- SynchronousFileSystem.prototype.symlink = function symlink (srcpath, dstpath, type, cb) {
- try {
- this.symlinkSync(srcpath, dstpath, type);
- cb();
- }
- catch (e) {
- cb(e);
- }
- };
- SynchronousFileSystem.prototype.readlink = function readlink (p, cb) {
- try {
- cb(null, this.readlinkSync(p));
- }
- catch (e) {
- cb(e);
- }
- };
-
- return SynchronousFileSystem;
- }(BaseFileSystem));
-
- /**
- * Base class that contains shared implementations of functions for the file
- * object.
- */
- var BaseFile = function BaseFile () {};
-
- BaseFile.prototype.sync = function sync (cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFile.prototype.syncSync = function syncSync () {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFile.prototype.datasync = function datasync (cb) {
- this.sync(cb);
- };
- BaseFile.prototype.datasyncSync = function datasyncSync () {
- return this.syncSync();
- };
- BaseFile.prototype.chown = function chown (uid, gid, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFile.prototype.chownSync = function chownSync (uid, gid) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFile.prototype.chmod = function chmod (mode, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFile.prototype.chmodSync = function chmodSync (mode) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- BaseFile.prototype.utimes = function utimes (atime, mtime, cb) {
- cb(new ApiError(ErrorCode.ENOTSUP));
- };
- BaseFile.prototype.utimesSync = function utimesSync (atime, mtime) {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
-
- /**
- * An implementation of the File interface that operates on a file that is
- * completely in-memory. PreloadFiles are backed by a Buffer.
- *
- * This is also an abstract class, as it lacks an implementation of 'sync' and
- * 'close'. Each filesystem that wishes to use this file representation must
- * extend this class and implement those two methods.
- * @todo 'close' lever that disables functionality once closed.
- */
- var PreloadFile = (function (BaseFile$$1) {
- function PreloadFile(_fs, _path, _flag, _stat, contents) {
- BaseFile$$1.call(this);
- this._pos = 0;
- this._dirty = false;
- this._fs = _fs;
- this._path = _path;
- this._flag = _flag;
- this._stat = _stat;
- if (contents) {
- this._buffer = contents;
- }
- else {
- // Empty buffer. It'll expand once we write stuff to it.
- this._buffer = emptyBuffer();
- }
- // Note: This invariant is *not* maintained once the file starts getting
- // modified.
- // Note: Only actually matters if file is readable, as writeable modes may
- // truncate/append to file.
- if (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."));
- }
- }
-
- if ( BaseFile$$1 ) PreloadFile.__proto__ = BaseFile$$1;
- PreloadFile.prototype = Object.create( BaseFile$$1 && BaseFile$$1.prototype );
- PreloadFile.prototype.constructor = PreloadFile;
- /**
- * NONSTANDARD: Get the underlying buffer for this file. !!DO NOT MUTATE!! Will mess up dirty tracking.
- */
- PreloadFile.prototype.getBuffer = function getBuffer () {
- return this._buffer;
- };
- /**
- * NONSTANDARD: Get underlying stats for this file. !!DO NOT MUTATE!!
- */
- PreloadFile.prototype.getStats = function getStats () {
- return this._stat;
- };
- PreloadFile.prototype.getFlag = function getFlag () {
- return this._flag;
- };
- /**
- * Get the path to this file.
- * @return [String] The path to the file.
- */
- PreloadFile.prototype.getPath = function getPath () {
- return this._path;
- };
- /**
- * Get the current file position.
- *
- * We emulate the following bug mentioned in the Node documentation:
- * > On Linux, positional writes don't work when the file is opened in append
- * mode. The kernel ignores the position argument and always appends the data
- * to the end of the file.
- * @return [Number] The current file position.
- */
- PreloadFile.prototype.getPos = function getPos () {
- if (this._flag.isAppendable()) {
- return this._stat.size;
- }
- return this._pos;
- };
- /**
- * Advance the current file position by the indicated number of positions.
- * @param [Number] delta
- */
- PreloadFile.prototype.advancePos = function advancePos (delta) {
- return this._pos += delta;
- };
- /**
- * Set the file position.
- * @param [Number] newPos
- */
- PreloadFile.prototype.setPos = function setPos (newPos) {
- return this._pos = newPos;
- };
- /**
- * **Core**: Asynchronous sync. Must be implemented by subclasses of this
- * class.
- * @param [Function(BrowserFS.ApiError)] cb
- */
- PreloadFile.prototype.sync = function sync (cb) {
- try {
- this.syncSync();
- cb();
- }
- catch (e) {
- cb(e);
- }
- };
- /**
- * **Core**: Synchronous sync.
- */
- PreloadFile.prototype.syncSync = function syncSync () {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- /**
- * **Core**: Asynchronous close. Must be implemented by subclasses of this
- * class.
- * @param [Function(BrowserFS.ApiError)] cb
- */
- PreloadFile.prototype.close = function close (cb) {
- try {
- this.closeSync();
- cb();
- }
- catch (e) {
- cb(e);
- }
- };
- /**
- * **Core**: Synchronous close.
- */
- PreloadFile.prototype.closeSync = function closeSync () {
- throw new ApiError(ErrorCode.ENOTSUP);
- };
- /**
- * Asynchronous `stat`.
- * @param [Function(BrowserFS.ApiError, BrowserFS.node.fs.Stats)] cb
- */
- PreloadFile.prototype.stat = function stat (cb) {
- try {
- cb(null, this._stat.clone());
- }
- catch (e) {
- cb(e);
- }
- };
- /**
- * Synchronous `stat`.
- */
- PreloadFile.prototype.statSync = function statSync () {
- return this._stat.clone();
- };
- /**
- * Asynchronous truncate.
- * @param [Number] len
- * @param [Function(BrowserFS.ApiError)] cb
- */
- PreloadFile.prototype.truncate = function truncate (len, cb) {
- try {
- this.truncateSync(len);
- if (this._flag.isSynchronous() && !_fsMock.getRootFS().supportsSynch()) {
- this.sync(cb);
- }
- cb();
- }
- catch (e) {
- return cb(e);
- }
- };
- /**
- * Synchronous truncate.
- * @param [Number] len
- */
- PreloadFile.prototype.truncateSync = function truncateSync (len) {
- this._dirty = true;
- if (!this._flag.isWriteable()) {
- throw new ApiError(ErrorCode.EPERM, 'File not opened with a writeable mode.');
- }
- this._stat.mtime = new Date();
- if (len > this._buffer.length) {
- var buf = Buffer.alloc(len - this._buffer.length, 0);
- // Write will set @_stat.size for us.
- this.writeSync(buf, 0, buf.length, this._buffer.length);
- if (this._flag.isSynchronous() && _fsMock.getRootFS().supportsSynch()) {
- this.syncSync();
- }
- return;
- }
- this._stat.size = len;
- // Truncate buffer to 'len'.
- var newBuff = Buffer.alloc(len);
- this._buffer.copy(newBuff, 0, 0, len);
- this._buffer = newBuff;
- if (this._flag.isSynchronous() && _fsMock.getRootFS().supportsSynch()) {
- this.syncSync();
- }
- };
- /**
- * Write buffer to the file.
- * Note that it is unsafe to use fs.write multiple times on the same file
- * without waiting for the callback.
- * @param [BrowserFS.node.Buffer] buffer Buffer containing the data to write to
- * the file.
- * @param [Number] offset Offset in the buffer to start reading data from.
- * @param [Number] length The amount of bytes to write to the file.
- * @param [Number] position Offset from the beginning of the file where this
- * data should be written. If position is null, the data will be written at
- * the current position.
- * @param [Function(BrowserFS.ApiError, Number, BrowserFS.node.Buffer)]
- * cb The number specifies the number of bytes written into the file.
- */
- PreloadFile.prototype.write = function write (buffer$$1, offset, length, position, cb) {
- try {
- cb(null, this.writeSync(buffer$$1, offset, length, position), buffer$$1);
- }
- catch (e) {
- cb(e);
- }
- };
- /**
- * Write buffer to the file.
- * Note that it is unsafe to use fs.writeSync multiple times on the same file
- * without waiting for the callback.
- * @param [BrowserFS.node.Buffer] buffer Buffer containing the data to write to
- * the file.
- * @param [Number] offset Offset in the buffer to start reading data from.
- * @param [Number] length The amount of bytes to write to the file.
- * @param [Number] position Offset from the beginning of the file where this
- * data should be written. If position is null, the data will be written at
- * the current position.
- * @return [Number]
- */
- PreloadFile.prototype.writeSync = function writeSync (buffer$$1, offset, length, position) {
- this._dirty = true;
- if (position === undefined || position === null) {
- position = this.getPos();
- }
- if (!this._flag.isWriteable()) {
- throw new ApiError(ErrorCode.EPERM, 'File not opened with a writeable mode.');
- }
- var endFp = position + length;
- if (endFp > this._stat.size) {
- this._stat.size = endFp;
- if (endFp > this._buffer.length) {
- // Extend the buffer!
- var newBuff = Buffer.alloc(endFp);
- this._buffer.copy(newBuff);
- this._buffer = newBuff;
- }
- }
- var len = buffer$$1.copy(this._buffer, position, offset, offset + length);
- this._stat.mtime = new Date();
- if (this._flag.isSynchronous()) {
- this.syncSync();
- return len;
- }
- this.setPos(position + len);
- return len;
- };
- /**
- * Read data from the file.
- * @param [BrowserFS.node.Buffer] buffer The buffer that the data will be
- * written to.
- * @param [Number] offset The offset within the buffer where writing will
- * start.
- * @param [Number] length An integer specifying the number of bytes to read.
- * @param [Number] position An integer specifying where to begin reading from
- * in the file. If position is null, data will be read from the current file
- * position.
- * @param [Function(BrowserFS.ApiError, Number, BrowserFS.node.Buffer)] cb The
- * number is the number of bytes read
- */
- PreloadFile.prototype.read = function read (buffer$$1, offset, length, position, cb) {
- try {
- cb(null, this.readSync(buffer$$1, offset, length, position), buffer$$1);
- }
- catch (e) {
- cb(e);
- }
- };
- /**
- * Read data from the file.
- * @param [BrowserFS.node.Buffer] buffer The buffer that the data will be
- * written to.
- * @param [Number] offset The offset within the buffer where writing will
- * start.
- * @param [Number] length An integer specifying the number of bytes to read.
- * @param [Number] position An integer specifying where to begin reading from
- * in the file. If position is null, data will be read from the current file
- * position.
- * @return [Number]
- */
- PreloadFile.prototype.readSync = function readSync (buffer$$1, offset, length, position) {
- if (!this._flag.isReadable()) {
- throw new ApiError(ErrorCode.EPERM, 'File not opened with a readable mode.');
- }
- if (position === undefined || position === null) {
- position = this.getPos();
- }
- var endRead = position + length;
- if (endRead > this._stat.size) {
- length = this._stat.size - position;
- }
- var rv = this._buffer.copy(buffer$$1, offset, position, position + length);
- this._stat.atime = new Date();
- this._pos = position + length;
- return rv;
- };
- /**
- * Asynchronous `fchmod`.
- * @param [Number|String] mode
- * @param [Function(BrowserFS.ApiError)] cb
- */
- PreloadFile.prototype.chmod = function chmod (mode, cb) {
- try {
- this.chmodSync(mode);
- cb();
- }
- catch (e) {
- cb(e);
- }
- };
- /**
- * Asynchronous `fchmod`.
- * @param [Number] mode
- */
- PreloadFile.prototype.chmodSync = function chmodSync (mode) {
- if (!this._fs.supportsProps()) {
- throw new ApiError(ErrorCode.ENOTSUP);
- }
- this._dirty = true;
- this._stat.chmod(mode);
- this.syncSync();
- };
- PreloadFile.prototype.isDirty = function isDirty () {
- return this._dirty;
- };
- /**
- * Resets the dirty bit. Should only be called after a sync has completed successfully.
- */
- PreloadFile.prototype.resetDirty = function resetDirty () {
- this._dirty = false;
- };
-
- return PreloadFile;
- }(BaseFile));
-
- /**
- * File class for the InMemory and XHR file systems.
- * Doesn't sync to anything, so it works nicely for memory-only files.
- */
- var NoSyncFile = (function (PreloadFile) {
- function NoSyncFile(_fs, _path, _flag, _stat, contents) {
- PreloadFile.call(this, _fs, _path, _flag, _stat, contents);
- }
-
- if ( PreloadFile ) NoSyncFile.__proto__ = PreloadFile;
- NoSyncFile.prototype = Object.create( PreloadFile && PreloadFile.prototype );
- NoSyncFile.prototype.constructor = NoSyncFile;
- /**
- * Asynchronous sync. Doesn't do anything, simply calls the cb.
- * @param [Function(BrowserFS.ApiError)] cb
- */
- NoSyncFile.prototype.sync = function sync (cb) {
- cb();
- };
- /**
- * Synchronous sync. Doesn't do anything.
- */
- NoSyncFile.prototype.syncSync = function syncSync () {
- // NOP.
- };
- /**
- * Asynchronous close. Doesn't do anything, simply calls the cb.
- * @param [Function(BrowserFS.ApiError)] cb
- */
- NoSyncFile.prototype.close = function close (cb) {
- cb();
- };
- /**
- * Synchronous close. Doesn't do anything.
- */
- NoSyncFile.prototype.closeSync = function closeSync () {
- // NOP.
- };
-
- return NoSyncFile;
- }(PreloadFile));
-
- /**
- * We define our own file to interpose on syncSync() for mirroring purposes.
- */
- var MirrorFile = (function (PreloadFile$$1) {
- function MirrorFile(fs, path$$1, flag, stat, data) {
- PreloadFile$$1.call(this, fs, path$$1, flag, stat, data);
- }
-
- if ( PreloadFile$$1 ) MirrorFile.__proto__ = PreloadFile$$1;
- MirrorFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );
- MirrorFile.prototype.constructor = MirrorFile;
- MirrorFile.prototype.syncSync = function syncSync () {
- if (this.isDirty()) {
- this._fs._syncSync(this);
- this.resetDirty();
- }
- };
- MirrorFile.prototype.closeSync = function closeSync () {
- this.syncSync();
- };
-
- return MirrorFile;
- }(PreloadFile));
- /**
- * AsyncMirrorFS mirrors a synchronous filesystem into an asynchronous filesystem
- * by:
- *
- * * Performing operations over the in-memory copy, while asynchronously pipelining them
- * to the backing store.
- * * During application loading, the contents of the async file system can be reloaded into
- * the synchronous store, if desired.
- *
- * The two stores will be kept in sync. The most common use-case is to pair a synchronous
- * in-memory filesystem with an asynchronous backing store.
- *
- * Example: Mirroring an IndexedDB file system to an in memory file system. Now, you can use
- * IndexedDB synchronously.
- *
- * ```javascript
- * BrowserFS.configure({
- * fs: "AsyncMirror",
- * options: {
- * sync: { fs: "InMemory" },
- * async: { fs: "IndexedDB" }
- * }
- * }, function(e) {
- * // BrowserFS is initialized and ready-to-use!
- * });
- * ```
- *
- * Or, alternatively:
- *
- * ```javascript
- * BrowserFS.FileSystem.IndexedDB.Create(function(e, idbfs) {
- * BrowserFS.FileSystem.InMemory.Create(function(e, inMemory) {
- * BrowserFS.FileSystem.AsyncMirror({
- * sync: inMemory, async: idbfs
- * }, function(e, mirrored) {
- * BrowserFS.initialize(mirrored);
- * });
- * });
- * });
- * ```
- */
- var AsyncMirror = (function (SynchronousFileSystem$$1) {
- function AsyncMirror(sync, async, deprecateMsg) {
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- SynchronousFileSystem$$1.call(this);
- /**
- * Queue of pending asynchronous operations.
- */
- this._queue = [];
- this._queueRunning = false;
- this._isInitialized = false;
- this._initializeCallbacks = [];
- this._sync = sync;
- this._async = async;
- if (!sync.supportsSynch()) {
- throw new Error("The first argument to AsyncMirror needs to be a synchronous file system.");
- }
- deprecationMessage(deprecateMsg, AsyncMirror.Name, { sync: "sync file system instance", async: "async file system instance" });
- }
-
- if ( SynchronousFileSystem$$1 ) AsyncMirror.__proto__ = SynchronousFileSystem$$1;
- AsyncMirror.prototype = Object.create( SynchronousFileSystem$$1 && SynchronousFileSystem$$1.prototype );
- AsyncMirror.prototype.constructor = AsyncMirror;
- /**
- * Constructs and initializes an AsyncMirror file system with the given options.
- */
- AsyncMirror.Create = function Create (opts, cb) {
- try {
- var fs = new AsyncMirror(opts.sync, opts.async, false);
- fs.initialize(function (e) {
- if (e) {
- cb(e);
- }
- else {
- cb(null, fs);
- }
- }, false);
- }
- catch (e) {
- cb(e);
- }
- };
- AsyncMirror.isAvailable = function isAvailable () {
- return true;
- };
- AsyncMirror.prototype.getName = function getName () {
- return AsyncMirror.Name;
- };
- AsyncMirror.prototype._syncSync = function _syncSync (fd) {
- this._sync.writeFileSync(fd.getPath(), fd.getBuffer(), null, FileFlag.getFileFlag('w'), fd.getStats().mode);
- this.enqueueOp({
- apiMethod: 'writeFile',
- arguments: [fd.getPath(), fd.getBuffer(), null, fd.getFlag(), fd.getStats().mode]
- });
- };
- /**
- * Called once to load up files from async storage into sync storage.
- */
- AsyncMirror.prototype.initialize = function initialize (userCb, deprecateMsg) {
- var this$1 = this;
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- if (deprecateMsg) {
- console.warn("[AsyncMirror] AsyncMirror.initialize() is deprecated and will be removed in the next major version. Please use 'AsyncMirror.Create({ sync: (sync file system instance), async: (async file system instance)}, cb)' to create and initialize AsyncMirror instances.");
- }
- var callbacks = this._initializeCallbacks;
- var end = function (e) {
- this$1._isInitialized = !e;
- this$1._initializeCallbacks = [];
- callbacks.forEach(function (cb) { return cb(e); });
- };
- if (!this._isInitialized) {
- // First call triggers initialization, the rest wait.
- if (callbacks.push(userCb) === 1) {
- var copyDirectory = function (p, mode, cb) {
- if (p !== '/') {
- this$1._sync.mkdirSync(p, mode);
- }
- this$1._async.readdir(p, function (err, files) {
- var i = 0;
- // NOTE: This function must not be in a lexically nested statement,
- // such as an if or while statement. Safari refuses to run the
- // script since it is undefined behavior.
- function copyNextFile(err) {
- if (err) {
- cb(err);
- }
- else if (i < files.length) {
- copyItem(path.join(p, files[i]), copyNextFile);
- i++;
- }
- else {
- cb();
- }
- }
- if (err) {
- cb(err);
- }
- else {
- copyNextFile();
- }
- });
- }, copyFile = function (p, mode, cb) {
- this$1._async.readFile(p, null, FileFlag.getFileFlag('r'), function (err, data) {
- if (err) {
- cb(err);
- }
- else {
- try {
- this$1._sync.writeFileSync(p, data, null, FileFlag.getFileFlag('w'), mode);
- }
- catch (e) {
- err = e;
- }
- finally {
- cb(err);
- }
- }
- });
- }, copyItem = function (p, cb) {
- this$1._async.stat(p, false, function (err, stats) {
- if (err) {
- cb(err);
- }
- else if (stats.isDirectory()) {
- copyDirectory(p, stats.mode, cb);
- }
- else {
- copyFile(p, stats.mode, cb);
- }
- });
- };
- copyDirectory('/', 0, end);
- }
- }
- else {
- userCb();
- }
- };
- AsyncMirror.prototype.isReadOnly = function isReadOnly () { return false; };
- AsyncMirror.prototype.supportsSynch = function supportsSynch () { return true; };
- AsyncMirror.prototype.supportsLinks = function supportsLinks () { return false; };
- AsyncMirror.prototype.supportsProps = function supportsProps () { return this._sync.supportsProps() && this._async.supportsProps(); };
- AsyncMirror.prototype.renameSync = function renameSync (oldPath, newPath) {
- this.checkInitialized();
- this._sync.renameSync(oldPath, newPath);
- this.enqueueOp({
- apiMethod: 'rename',
- arguments: [oldPath, newPath]
- });
- };
- AsyncMirror.prototype.statSync = function statSync (p, isLstat) {
- this.checkInitialized();
- return this._sync.statSync(p, isLstat);
- };
- AsyncMirror.prototype.openSync = function openSync (p, flag, mode) {
- this.checkInitialized();
- // Sanity check: Is this open/close permitted?
- var fd = this._sync.openSync(p, flag, mode);
- fd.closeSync();
- return new MirrorFile(this, p, flag, this._sync.statSync(p, false), this._sync.readFileSync(p, null, FileFlag.getFileFlag('r')));
- };
- AsyncMirror.prototype.unlinkSync = function unlinkSync (p) {
- this.checkInitialized();
- this._sync.unlinkSync(p);
- this.enqueueOp({
- apiMethod: 'unlink',
- arguments: [p]
- });
- };
- AsyncMirror.prototype.rmdirSync = function rmdirSync (p) {
- this.checkInitialized();
- this._sync.rmdirSync(p);
- this.enqueueOp({
- apiMethod: 'rmdir',
- arguments: [p]
- });
- };
- AsyncMirror.prototype.mkdirSync = function mkdirSync (p, mode) {
- this.checkInitialized();
- this._sync.mkdirSync(p, mode);
- this.enqueueOp({
- apiMethod: 'mkdir',
- arguments: [p, mode]
- });
- };
- AsyncMirror.prototype.readdirSync = function readdirSync (p) {
- this.checkInitialized();
- return this._sync.readdirSync(p);
- };
- AsyncMirror.prototype.existsSync = function existsSync (p) {
- this.checkInitialized();
- return this._sync.existsSync(p);
- };
- AsyncMirror.prototype.chmodSync = function chmodSync (p, isLchmod, mode) {
- this.checkInitialized();
- this._sync.chmodSync(p, isLchmod, mode);
- this.enqueueOp({
- apiMethod: 'chmod',
- arguments: [p, isLchmod, mode]
- });
- };
- AsyncMirror.prototype.chownSync = function chownSync (p, isLchown, uid, gid) {
- this.checkInitialized();
- this._sync.chownSync(p, isLchown, uid, gid);
- this.enqueueOp({
- apiMethod: 'chown',
- arguments: [p, isLchown, uid, gid]
- });
- };
- AsyncMirror.prototype.utimesSync = function utimesSync (p, atime, mtime) {
- this.checkInitialized();
- this._sync.utimesSync(p, atime, mtime);
- this.enqueueOp({
- apiMethod: 'utimes',
- arguments: [p, atime, mtime]
- });
- };
- AsyncMirror.prototype.checkInitialized = function checkInitialized () {
- if (!this._isInitialized) {
- throw new ApiError(ErrorCode.EPERM, "AsyncMirrorFS is not initialized. Please initialize AsyncMirrorFS using its initialize() method before using it.");
- }
- };
- AsyncMirror.prototype.enqueueOp = function enqueueOp (op) {
- var this$1 = this;
-
- this._queue.push(op);
- if (!this._queueRunning) {
- this._queueRunning = true;
- var doNextOp = function (err) {
- if (err) {
- console.error(("WARNING: File system has desynchronized. Received following error: " + err + "\n$"));
- }
- if (this$1._queue.length > 0) {
- var op = this$1._queue.shift(), args = op.arguments;
- args.push(doNextOp);
- this$1._async[op.apiMethod].apply(this$1._async, args);
- }
- else {
- this$1._queueRunning = false;
- }
- };
- doNextOp();
- }
- };
-
- return AsyncMirror;
- }(SynchronousFileSystem));
-
- AsyncMirror.Name = "AsyncMirror";
- AsyncMirror.Options = {
- sync: {
- type: "object",
- description: "The synchronous file system to mirror the asynchronous file system to."
- },
- async: {
- type: "object",
- description: "The asynchronous file system to mirror."
- }
- };
-
- /**
- * A faster alternative to `Function#apply`, this function invokes `func`
- * with the `this` binding of `thisArg` and the arguments of `args`.
- *
- * @private
- * @param {Function} func The function to invoke.
- * @param {*} thisArg The `this` binding of `func`.
- * @param {Array} args The arguments to invoke `func` with.
- * @returns {*} Returns the result of `func`.
- */
- function apply(func, thisArg, args) {
- switch (args.length) {
- case 0: return func.call(thisArg);
- case 1: return func.call(thisArg, args[0]);
- case 2: return func.call(thisArg, args[0], args[1]);
- case 3: return func.call(thisArg, args[0], args[1], args[2]);
- }
- return func.apply(thisArg, args);
- }
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
-
- /**
- * A specialized version of `baseRest` which transforms the rest array.
- *
- * @private
- * @param {Function} func The function to apply a rest parameter to.
- * @param {number} [start=func.length-1] The start position of the rest parameter.
- * @param {Function} transform The rest array transform.
- * @returns {Function} Returns the new function.
- */
- function overRest$1(func, start, transform) {
- start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
- return function() {
- var args = arguments,
- index = -1,
- length = nativeMax(args.length - start, 0),
- array = Array(length);
-
- while (++index < length) {
- array[index] = args[start + index];
- }
- index = -1;
- var otherArgs = Array(start + 1);
- while (++index < start) {
- otherArgs[index] = args[index];
- }
- otherArgs[start] = transform(array);
- return apply(func, this, otherArgs);
- };
- }
-
- /**
- * This method returns the first argument it receives.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Util
- * @param {*} value Any value.
- * @returns {*} Returns `value`.
- * @example
- *
- * var object = { 'a': 1 };
- *
- * console.log(_.identity(object) === object);
- * // => true
- */
- function identity(value) {
- return value;
- }
-
- // Lodash rest function without function.toString()
- // remappings
- function rest(func, start) {
- return overRest$1(func, start, identity);
- }
-
- var initialParams = function (fn) {
- return rest(function (args/*..., callback*/) {
- var callback = args.pop();
- fn.call(this, args, callback);
- });
- };
-
- function applyEach$1(eachfn) {
- return rest(function(fns, args) {
- var go = initialParams(function(args, callback) {
- var that = this;
- return eachfn(fns, function (fn, cb) {
- fn.apply(that, args.concat(cb));
- }, callback);
- });
- if (args.length) {
- return go.apply(this, args);
- }
- else {
- return go;
- }
- });
- }
-
- /** Detect free variable `global` from Node.js. */
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
-
- /** Detect free variable `self`. */
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
-
- /** Used as a reference to the global object. */
- var root = freeGlobal || freeSelf || Function('return this')();
-
- /** Built-in value references. */
- var Symbol$1 = root.Symbol;
-
- /** Used for built-in method references. */
- var objectProto = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
-
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
- * of values.
- */
- var nativeObjectToString = objectProto.toString;
-
- /** Built-in value references. */
- var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
-
- /**
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the raw `toStringTag`.
- */
- function getRawTag(value) {
- var isOwn = hasOwnProperty.call(value, symToStringTag$1),
- tag = value[symToStringTag$1];
-
- try {
- value[symToStringTag$1] = undefined;
- var unmasked = true;
- } catch (e) {}
-
- var result = nativeObjectToString.call(value);
- if (unmasked) {
- if (isOwn) {
- value[symToStringTag$1] = tag;
- } else {
- delete value[symToStringTag$1];
- }
- }
- return result;
- }
-
- /** Used for built-in method references. */
- var objectProto$1 = Object.prototype;
-
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
- * of values.
- */
- var nativeObjectToString$1 = objectProto$1.toString;
-
- /**
- * Converts `value` to a string using `Object.prototype.toString`.
- *
- * @private
- * @param {*} value The value to convert.
- * @returns {string} Returns the converted string.
- */
- function objectToString(value) {
- return nativeObjectToString$1.call(value);
- }
-
- /** `Object#toString` result references. */
- var nullTag = '[object Null]';
- var undefinedTag = '[object Undefined]';
-
- /** Built-in value references. */
- var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
-
- /**
- * The base implementation of `getTag` without fallbacks for buggy environments.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the `toStringTag`.
- */
- function baseGetTag(value) {
- if (value == null) {
- return value === undefined ? undefinedTag : nullTag;
- }
- return (symToStringTag && symToStringTag in Object(value))
- ? getRawTag(value)
- : objectToString(value);
- }
-
- /**
- * Checks if `value` is the
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(_.noop);
- * // => true
- *
- * _.isObject(null);
- * // => false
- */
- function isObject(value) {
- var type = typeof value;
- return value != null && (type == 'object' || type == 'function');
- }
-
- /** `Object#toString` result references. */
- var asyncTag = '[object AsyncFunction]';
- var funcTag = '[object Function]';
- var genTag = '[object GeneratorFunction]';
- var proxyTag = '[object Proxy]';
-
- /**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
- function isFunction(value) {
- if (!isObject(value)) {
- return false;
- }
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
- var tag = baseGetTag(value);
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
- }
-
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER = 9007199254740991;
-
- /**
- * Checks if `value` is a valid array-like length.
- *
- * **Note:** This method is loosely based on
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
- * @example
- *
- * _.isLength(3);
- * // => true
- *
- * _.isLength(Number.MIN_VALUE);
- * // => false
- *
- * _.isLength(Infinity);
- * // => false
- *
- * _.isLength('3');
- * // => false
- */
- function isLength(value) {
- return typeof value == 'number' &&
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
- }
-
- /**
- * Checks if `value` is array-like. A value is considered array-like if it's
- * not a function and has a `value.length` that's an integer greater than or
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
- * @example
- *
- * _.isArrayLike([1, 2, 3]);
- * // => true
- *
- * _.isArrayLike(document.body.children);
- * // => true
- *
- * _.isArrayLike('abc');
- * // => true
- *
- * _.isArrayLike(_.noop);
- * // => false
- */
- function isArrayLike(value) {
- return value != null && isLength(value.length) && !isFunction(value);
- }
-
- // A temporary value used to identify if the loop should be broken.
- // See #1064, #1293
- var breakLoop = {};
-
- /**
- * This method returns `undefined`.
- *
- * @static
- * @memberOf _
- * @since 2.3.0
- * @category Util
- * @example
- *
- * _.times(2, _.noop);
- * // => [undefined, undefined]
- */
- function noop() {
- // No operation performed.
- }
-
- function once(fn) {
- return function () {
- if (fn === null) { return; }
- var callFn = fn;
- fn = null;
- callFn.apply(this, arguments);
- };
- }
-
- var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
-
- var getIterator = function (coll) {
- return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
- };
-
- /**
- * The base implementation of `_.times` without support for iteratee shorthands
- * or max array length checks.
- *
- * @private
- * @param {number} n The number of times to invoke `iteratee`.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the array of results.
- */
- function baseTimes(n, iteratee) {
- var index = -1,
- result = Array(n);
-
- while (++index < n) {
- result[index] = iteratee(index);
- }
- return result;
- }
-
- /**
- * Checks if `value` is object-like. A value is object-like if it's not `null`
- * and has a `typeof` result of "object".
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
- * @example
- *
- * _.isObjectLike({});
- * // => true
- *
- * _.isObjectLike([1, 2, 3]);
- * // => true
- *
- * _.isObjectLike(_.noop);
- * // => false
- *
- * _.isObjectLike(null);
- * // => false
- */
- function isObjectLike(value) {
- return value != null && typeof value == 'object';
- }
-
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]';
-
- /**
- * The base implementation of `_.isArguments`.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
- */
- function baseIsArguments(value) {
- return isObjectLike(value) && baseGetTag(value) == argsTag;
- }
-
- /** Used for built-in method references. */
- var objectProto$3 = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
-
- /** Built-in value references. */
- var propertyIsEnumerable = objectProto$3.propertyIsEnumerable;
-
- /**
- * Checks if `value` is likely an `arguments` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
- * else `false`.
- * @example
- *
- * _.isArguments(function() { return arguments; }());
- * // => true
- *
- * _.isArguments([1, 2, 3]);
- * // => false
- */
- var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
- return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') &&
- !propertyIsEnumerable.call(value, 'callee');
- };
-
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(document.body.children);
- * // => false
- *
- * _.isArray('abc');
- * // => false
- *
- * _.isArray(_.noop);
- * // => false
- */
- var isArray = Array.isArray;
-
- /**
- * This method returns `false`.
- *
- * @static
- * @memberOf _
- * @since 4.13.0
- * @category Util
- * @returns {boolean} Returns `false`.
- * @example
- *
- * _.times(2, _.stubFalse);
- * // => [false, false]
- */
- function stubFalse() {
- return false;
- }
-
- /** Detect free variable `exports`. */
- var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
-
- /** Detect free variable `module`. */
- var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
-
- /** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports = freeModule && freeModule.exports === freeExports;
-
- /** Built-in value references. */
- var Buffer$1 = moduleExports ? root.Buffer : undefined;
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : undefined;
-
- /**
- * Checks if `value` is a buffer.
- *
- * @static
- * @memberOf _
- * @since 4.3.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
- * @example
- *
- * _.isBuffer(new Buffer(2));
- * // => true
- *
- * _.isBuffer(new Uint8Array(2));
- * // => false
- */
- var isBuffer = nativeIsBuffer || stubFalse;
-
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
-
- /** Used to detect unsigned integer values. */
- var reIsUint = /^(?:0|[1-9]\d*)$/;
-
- /**
- * Checks if `value` is a valid array-like index.
- *
- * @private
- * @param {*} value The value to check.
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
- */
- function isIndex(value, length) {
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
- return !!length &&
- (typeof value == 'number' || reIsUint.test(value)) &&
- (value > -1 && value % 1 == 0 && value < length);
- }
-
- /** `Object#toString` result references. */
- var argsTag$1 = '[object Arguments]';
- var arrayTag = '[object Array]';
- var boolTag = '[object Boolean]';
- var dateTag = '[object Date]';
- var errorTag = '[object Error]';
- var funcTag$1 = '[object Function]';
- var mapTag = '[object Map]';
- var numberTag = '[object Number]';
- var objectTag = '[object Object]';
- var regexpTag = '[object RegExp]';
- var setTag = '[object Set]';
- var stringTag = '[object String]';
- var weakMapTag = '[object WeakMap]';
-
- var arrayBufferTag = '[object ArrayBuffer]';
- var dataViewTag = '[object DataView]';
- var float32Tag = '[object Float32Array]';
- var float64Tag = '[object Float64Array]';
- var int8Tag = '[object Int8Array]';
- var int16Tag = '[object Int16Array]';
- var int32Tag = '[object Int32Array]';
- var uint8Tag = '[object Uint8Array]';
- var uint8ClampedTag = '[object Uint8ClampedArray]';
- var uint16Tag = '[object Uint16Array]';
- var uint32Tag = '[object Uint32Array]';
-
- /** Used to identify `toStringTag` values of typed arrays. */
- var typedArrayTags = {};
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
- typedArrayTags[uint32Tag] = true;
- typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
- typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
- typedArrayTags[mapTag] = typedArrayTags[numberTag] =
- typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
- typedArrayTags[setTag] = typedArrayTags[stringTag] =
- typedArrayTags[weakMapTag] = false;
-
- /**
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
- */
- function baseIsTypedArray(value) {
- return isObjectLike(value) &&
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
- }
-
- /**
- * The base implementation of `_.unary` without support for storing metadata.
- *
- * @private
- * @param {Function} func The function to cap arguments for.
- * @returns {Function} Returns the new capped function.
- */
- function baseUnary(func) {
- return function(value) {
- return func(value);
- };
- }
-
- /** Detect free variable `exports`. */
- var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
-
- /** Detect free variable `module`. */
- var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
-
- /** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
-
- /** Detect free variable `process` from Node.js. */
- var freeProcess = moduleExports$1 && freeGlobal.process;
-
- /** Used to access faster Node.js helpers. */
- var nodeUtil = (function() {
- try {
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
- } catch (e) {}
- }());
-
- /* Node.js helper references. */
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
-
- /**
- * Checks if `value` is classified as a typed array.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
- * @example
- *
- * _.isTypedArray(new Uint8Array);
- * // => true
- *
- * _.isTypedArray([]);
- * // => false
- */
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
-
- /** Used for built-in method references. */
- var objectProto$2 = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
-
- /**
- * Creates an array of the enumerable property names of the array-like `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @param {boolean} inherited Specify returning inherited property names.
- * @returns {Array} Returns the array of property names.
- */
- function arrayLikeKeys(value, inherited) {
- var isArr = isArray(value),
- isArg = !isArr && isArguments(value),
- isBuff = !isArr && !isArg && isBuffer(value),
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
- skipIndexes = isArr || isArg || isBuff || isType,
- result = skipIndexes ? baseTimes(value.length, String) : [],
- length = result.length;
-
- for (var key in value) {
- if ((inherited || hasOwnProperty$1.call(value, key)) &&
- !(skipIndexes && (
- // Safari 9 has enumerable `arguments.length` in strict mode.
- key == 'length' ||
- // Node.js 0.10 has enumerable non-index properties on buffers.
- (isBuff && (key == 'offset' || key == 'parent')) ||
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
- // Skip index properties.
- isIndex(key, length)
- ))) {
- result.push(key);
- }
- }
- return result;
- }
-
- /** Used for built-in method references. */
- var objectProto$5 = Object.prototype;
-
- /**
- * Checks if `value` is likely a prototype object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
- */
- function isPrototype(value) {
- var Ctor = value && value.constructor,
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;
-
- return value === proto;
- }
-
- /**
- * Creates a unary function that invokes `func` with its argument transformed.
- *
- * @private
- * @param {Function} func The function to wrap.
- * @param {Function} transform The argument transform.
- * @returns {Function} Returns the new function.
- */
- function overArg(func, transform) {
- return function(arg) {
- return func(transform(arg));
- };
- }
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeKeys = overArg(Object.keys, Object);
-
- /** Used for built-in method references. */
- var objectProto$4 = Object.prototype;
-
- /** Used to check objects for own properties. */
- var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
-
- /**
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function baseKeys(object) {
- if (!isPrototype(object)) {
- return nativeKeys(object);
- }
- var result = [];
- for (var key in Object(object)) {
- if (hasOwnProperty$3.call(object, key) && key != 'constructor') {
- result.push(key);
- }
- }
- return result;
- }
-
- /**
- * Creates an array of the own enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects. See the
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
- * for more details.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keys(new Foo);
- * // => ['a', 'b'] (iteration order is not guaranteed)
- *
- * _.keys('hi');
- * // => ['0', '1']
- */
- function keys(object) {
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
- }
-
- function createArrayIterator(coll) {
- var i = -1;
- var len = coll.length;
- return function next() {
- return ++i < len ? {value: coll[i], key: i} : null;
- }
- }
-
- function createES2015Iterator(iterator) {
- var i = -1;
- return function next() {
- var item = iterator.next();
- if (item.done)
- { return null; }
- i++;
- return {value: item.value, key: i};
- }
- }
-
- function createObjectIterator(obj) {
- var okeys = keys(obj);
- var i = -1;
- var len = okeys.length;
- return function next() {
- var key = okeys[++i];
- return i < len ? {value: obj[key], key: key} : null;
- };
- }
-
- function iterator(coll) {
- if (isArrayLike(coll)) {
- return createArrayIterator(coll);
- }
-
- var iterator = getIterator(coll);
- return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
- }
-
- function onlyOnce(fn) {
- return function() {
- if (fn === null) { throw new Error("Callback was already called."); }
- var callFn = fn;
- fn = null;
- callFn.apply(this, arguments);
- };
- }
-
- function _eachOfLimit(limit) {
- return function (obj, iteratee, callback) {
- callback = once(callback || noop);
- if (limit <= 0 || !obj) {
- return callback(null);
- }
- var nextElem = iterator(obj);
- var done = false;
- var running = 0;
-
- function iterateeCallback(err, value) {
- running -= 1;
- if (err) {
- done = true;
- callback(err);
- }
- else if (value === breakLoop || (done && running <= 0)) {
- done = true;
- return callback(null);
- }
- else {
- replenish();
- }
- }
-
- function replenish () {
- while (running < limit && !done) {
- var elem = nextElem();
- if (elem === null) {
- done = true;
- if (running <= 0) {
- callback(null);
- }
- return;
- }
- running += 1;
- iteratee(elem.value, elem.key, onlyOnce(iterateeCallback));
- }
- }
-
- replenish();
- };
- }
-
- /**
- * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name eachOfLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.eachOf]{@link module:Collections.eachOf}
- * @alias forEachOfLimit
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A function to apply to each
- * item in `coll`. The `key` is the item's key, or index in the case of an
- * array. The iteratee is passed a `callback(err)` which must be called once it
- * has completed. If no error has occurred, the callback should be run without
- * arguments or with an explicit `null` argument. Invoked with
- * (item, key, callback).
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- */
- function eachOfLimit(coll, limit, iteratee, callback) {
- _eachOfLimit(limit)(coll, iteratee, callback);
- }
-
- function doLimit(fn, limit) {
- return function (iterable, iteratee, callback) {
- return fn(iterable, limit, iteratee, callback);
- };
- }
-
- // eachOf implementation optimized for array-likes
- function eachOfArrayLike(coll, iteratee, callback) {
- callback = once(callback || noop);
- var index = 0,
- completed = 0,
- length = coll.length;
- if (length === 0) {
- callback(null);
- }
-
- function iteratorCallback(err, value) {
- if (err) {
- callback(err);
- } else if ((++completed === length) || value === breakLoop) {
- callback(null);
- }
- }
-
- for (; index < length; index++) {
- iteratee(coll[index], index, onlyOnce(iteratorCallback));
- }
- }
-
- // a generic version of eachOf which can handle array, object, and iterator cases.
- var eachOfGeneric = doLimit(eachOfLimit, Infinity);
-
- /**
- * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
- * to the iteratee.
- *
- * @name eachOf
- * @static
- * @memberOf module:Collections
- * @method
- * @alias forEachOf
- * @category Collection
- * @see [async.each]{@link module:Collections.each}
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each
- * item in `coll`. The `key` is the item's key, or index in the case of an
- * array. The iteratee is passed a `callback(err)` which must be called once it
- * has completed. If no error has occurred, the callback should be run without
- * arguments or with an explicit `null` argument. Invoked with
- * (item, key, callback).
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- * @example
- *
- * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
- * var configs = {};
- *
- * async.forEachOf(obj, function (value, key, callback) {
- * fs.readFile(__dirname + value, "utf8", function (err, data) {
- * if (err) return callback(err);
- * try {
- * configs[key] = JSON.parse(data);
- * } catch (e) {
- * return callback(e);
- * }
- * callback();
- * });
- * }, function (err) {
- * if (err) console.error(err.message);
- * // configs is now a map of JSON data
- * doSomethingWith(configs);
- * });
- */
- var eachOf = function(coll, iteratee, callback) {
- var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric;
- eachOfImplementation(coll, iteratee, callback);
- };
-
- function doParallel(fn) {
- return function (obj, iteratee, callback) {
- return fn(eachOf, obj, iteratee, callback);
- };
- }
-
- function _asyncMap(eachfn, arr, iteratee, callback) {
- callback = callback || noop;
- arr = arr || [];
- var results = [];
- var counter = 0;
-
- eachfn(arr, function (value, _, callback) {
- var index = counter++;
- iteratee(value, function (err, v) {
- results[index] = v;
- callback(err);
- });
- }, function (err) {
- callback(err, results);
- });
- }
-
- /**
- * Produces a new collection of values by mapping each value in `coll` through
- * the `iteratee` function. The `iteratee` is called with an item from `coll`
- * and a callback for when it has finished processing. Each of these callback
- * takes 2 arguments: an `error`, and the transformed item from `coll`. If
- * `iteratee` passes an error to its callback, the main `callback` (for the
- * `map` function) is immediately called with the error.
- *
- * Note, that since this function applies the `iteratee` to each item in
- * parallel, there is no guarantee that the `iteratee` functions will complete
- * in order. However, the results array will be in the same order as the
- * original `coll`.
- *
- * If `map` is passed an Object, the results will be an Array. The results
- * will roughly be in the order of the original Objects' keys (but this can
- * vary across JavaScript engines)
- *
- * @name map
- * @static
- * @memberOf module:Collections
- * @method
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a
- * transformed item. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Results is an Array of the
- * transformed items from the `coll`. Invoked with (err, results).
- * @example
- *
- * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
- * // results is now an array of stats for each file
- * });
- */
- var map = doParallel(_asyncMap);
-
- /**
- * Applies the provided arguments to each function in the array, calling
- * `callback` after all functions have completed. If you only provide the first
- * argument, `fns`, then it will return a function which lets you pass in the
- * arguments as if it were a single function call. If more arguments are
- * provided, `callback` is required while `args` is still optional.
- *
- * @name applyEach
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Array|Iterable|Object} fns - A collection of asynchronous functions
- * to all call with the same arguments
- * @param {...*} [args] - any number of separate arguments to pass to the
- * function.
- * @param {Function} [callback] - the final argument should be the callback,
- * called when all functions have completed processing.
- * @returns {Function} - If only the first argument, `fns`, is provided, it will
- * return a function which lets you pass in the arguments as if it were a single
- * function call. The signature is `(..args, callback)`. If invoked with any
- * arguments, `callback` is required.
- * @example
- *
- * async.applyEach([enableSearch, updateSchema], 'bucket', callback);
- *
- * // partial application example:
- * async.each(
- * buckets,
- * async.applyEach([enableSearch, updateSchema]),
- * callback
- * );
- */
- applyEach$1(map);
-
- function doParallelLimit(fn) {
- return function (obj, limit, iteratee, callback) {
- return fn(_eachOfLimit(limit), obj, iteratee, callback);
- };
- }
-
- /**
- * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.
- *
- * @name mapLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.map]{@link module:Collections.map}
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a transformed
- * item. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Results is an array of the
- * transformed items from the `coll`. Invoked with (err, results).
- */
- var mapLimit = doParallelLimit(_asyncMap);
-
- /**
- * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.
- *
- * @name mapSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.map]{@link module:Collections.map}
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a
- * transformed item. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Results is an array of the
- * transformed items from the `coll`. Invoked with (err, results).
- */
- var mapSeries = doLimit(mapLimit, 1);
-
- /**
- * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
- *
- * @name applyEachSeries
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.applyEach]{@link module:ControlFlow.applyEach}
- * @category Control Flow
- * @param {Array|Iterable|Object} fns - A collection of asynchronous functions to all
- * call with the same arguments
- * @param {...*} [args] - any number of separate arguments to pass to the
- * function.
- * @param {Function} [callback] - the final argument should be the callback,
- * called when all functions have completed processing.
- * @returns {Function} - If only the first argument is provided, it will return
- * a function which lets you pass in the arguments as if it were a single
- * function call.
- */
- applyEach$1(mapSeries);
-
- /**
- * Creates a continuation function with some arguments already applied.
- *
- * Useful as a shorthand when combined with other control flow functions. Any
- * arguments passed to the returned function are added to the arguments
- * originally passed to apply.
- *
- * @name apply
- * @static
- * @memberOf module:Utils
- * @method
- * @category Util
- * @param {Function} function - The function you want to eventually apply all
- * arguments to. Invokes with (arguments...).
- * @param {...*} arguments... - Any number of arguments to automatically apply
- * when the continuation is called.
- * @example
- *
- * // using apply
- * async.parallel([
- * async.apply(fs.writeFile, 'testfile1', 'test1'),
- * async.apply(fs.writeFile, 'testfile2', 'test2')
- * ]);
- *
- *
- * // the same process without using apply
- * async.parallel([
- * function(callback) {
- * fs.writeFile('testfile1', 'test1', callback);
- * },
- * function(callback) {
- * fs.writeFile('testfile2', 'test2', callback);
- * }
- * ]);
- *
- * // It's possible to pass any number of additional arguments when calling the
- * // continuation:
- *
- * node> var fn = async.apply(sys.puts, 'one');
- * node> fn('two', 'three');
- * one
- * two
- * three
- */
- rest(function(fn, args) {
- return rest(function(callArgs) {
- return fn.apply(null, args.concat(callArgs));
- });
- });
-
- /**
- * A specialized version of `_.forEach` for arrays without support for
- * iteratee shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns `array`.
- */
- function arrayEach(array, iteratee) {
- var index = -1,
- length = array == null ? 0 : array.length;
-
- while (++index < length) {
- if (iteratee(array[index], index, array) === false) {
- break;
- }
- }
- return array;
- }
-
- /**
- * Creates a base function for methods like `_.forIn` and `_.forOwn`.
- *
- * @private
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseFor(fromRight) {
- return function(object, iteratee, keysFunc) {
- var index = -1,
- iterable = Object(object),
- props = keysFunc(object),
- length = props.length;
-
- while (length--) {
- var key = props[fromRight ? length : ++index];
- if (iteratee(iterable[key], key, iterable) === false) {
- break;
- }
- }
- return object;
- };
- }
-
- /**
- * The base implementation of `baseForOwn` which iterates over `object`
- * properties returned by `keysFunc` and invokes `iteratee` for each property.
- * Iteratee functions may exit iteration early by explicitly returning `false`.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {Function} keysFunc The function to get the keys of `object`.
- * @returns {Object} Returns `object`.
- */
- var baseFor = createBaseFor();
-
- /**
- * The base implementation of `_.forOwn` without support for iteratee shorthands.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Object} Returns `object`.
- */
- function baseForOwn(object, iteratee) {
- return object && baseFor(object, iteratee, keys);
- }
-
- /**
- * The base implementation of `_.findIndex` and `_.findLastIndex` without
- * support for iteratee shorthands.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {Function} predicate The function invoked per iteration.
- * @param {number} fromIndex The index to search from.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function baseFindIndex(array, predicate, fromIndex, fromRight) {
- var length = array.length,
- index = fromIndex + (fromRight ? 1 : -1);
-
- while ((fromRight ? index-- : ++index < length)) {
- if (predicate(array[index], index, array)) {
- return index;
- }
- }
- return -1;
- }
-
- /**
- * The base implementation of `_.isNaN` without support for number objects.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
- */
- function baseIsNaN(value) {
- return value !== value;
- }
-
- /**
- * A specialized version of `_.indexOf` which performs strict equality
- * comparisons of values, i.e. `===`.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {*} value The value to search for.
- * @param {number} fromIndex The index to search from.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function strictIndexOf(array, value, fromIndex) {
- var index = fromIndex - 1,
- length = array.length;
-
- while (++index < length) {
- if (array[index] === value) {
- return index;
- }
- }
- return -1;
- }
-
- /**
- * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {*} value The value to search for.
- * @param {number} fromIndex The index to search from.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function baseIndexOf(array, value, fromIndex) {
- return value === value
- ? strictIndexOf(array, value, fromIndex)
- : baseFindIndex(array, baseIsNaN, fromIndex);
- }
-
- /**
- * Determines the best order for running the functions in `tasks`, based on
- * their requirements. Each function can optionally depend on other functions
- * being completed first, and each function is run as soon as its requirements
- * are satisfied.
- *
- * If any of the functions pass an error to their callback, the `auto` sequence
- * will stop. Further tasks will not execute (so any other functions depending
- * on it will not run), and the main `callback` is immediately called with the
- * error.
- *
- * Functions also receive an object containing the results of functions which
- * have completed so far as the first argument, if they have dependencies. If a
- * task function has no dependencies, it will only be passed a callback.
- *
- * @name auto
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Object} tasks - An object. Each of its properties is either a
- * function or an array of requirements, with the function itself the last item
- * in the array. The object's key of a property serves as the name of the task
- * defined by that property, i.e. can be used when specifying requirements for
- * other tasks. The function receives one or two arguments:
- * * a `results` object, containing the results of the previously executed
- * functions, only passed if the task has any dependencies,
- * * a `callback(err, result)` function, which must be called when finished,
- * passing an `error` (which can be `null`) and the result of the function's
- * execution.
- * @param {number} [concurrency=Infinity] - An optional `integer` for
- * determining the maximum number of tasks that can be run in parallel. By
- * default, as many as possible.
- * @param {Function} [callback] - An optional callback which is called when all
- * the tasks have been completed. It receives the `err` argument if any `tasks`
- * pass an error to their callback. Results are always returned; however, if an
- * error occurs, no further `tasks` will be performed, and the results object
- * will only contain partial results. Invoked with (err, results).
- * @returns undefined
- * @example
- *
- * async.auto({
- * // this function will just be passed a callback
- * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
- * showData: ['readData', function(results, cb) {
- * // results.readData is the file's contents
- * // ...
- * }]
- * }, callback);
- *
- * async.auto({
- * get_data: function(callback) {
- * console.log('in get_data');
- * // async code to get some data
- * callback(null, 'data', 'converted to array');
- * },
- * make_folder: function(callback) {
- * console.log('in make_folder');
- * // async code to create a directory to store a file in
- * // this is run at the same time as getting the data
- * callback(null, 'folder');
- * },
- * write_file: ['get_data', 'make_folder', function(results, callback) {
- * console.log('in write_file', JSON.stringify(results));
- * // once there is some data and the directory exists,
- * // write the data to a file in the directory
- * callback(null, 'filename');
- * }],
- * email_link: ['write_file', function(results, callback) {
- * console.log('in email_link', JSON.stringify(results));
- * // once the file is written let's email a link to it...
- * // results.write_file contains the filename returned by write_file.
- * callback(null, {'file':results.write_file, 'email':'user@example.com'});
- * }]
- * }, function(err, results) {
- * console.log('err = ', err);
- * console.log('results = ', results);
- * });
- */
-
- /**
- * A specialized version of `_.map` for arrays without support for iteratee
- * shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
-
- /**
- * The base implementation of `_.slice` without an iteratee call guard.
- *
- * @private
- * @param {Array} array The array to slice.
- * @param {number} [start=0] The start position.
- * @param {number} [end=array.length] The end position.
- * @returns {Array} Returns the slice of `array`.
- */
-
- /**
- * Converts an ASCII `string` to an array.
- *
- * @private
- * @param {string} string The string to convert.
- * @returns {Array} Returns the converted array.
- */
-
- /** Used to compose unicode character classes. */
-
- /** Used to compose unicode character classes. */
- var rsAstralRange$1 = '\\ud800-\\udfff';
- var rsComboMarksRange$1 = '\\u0300-\\u036f';
- var reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f';
- var rsComboSymbolsRange$1 = '\\u20d0-\\u20ff';
- var rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1;
- var rsVarRange$1 = '\\ufe0e\\ufe0f';
-
- /** Used to compose unicode capture groups. */
- var rsAstral = '[' + rsAstralRange$1 + ']';
- var rsCombo = '[' + rsComboRange$1 + ']';
- var rsFitz = '\\ud83c[\\udffb-\\udfff]';
- var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')';
- var rsNonAstral = '[^' + rsAstralRange$1 + ']';
- var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
- var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
- var rsZWJ$1 = '\\u200d';
-
- /** Used to compose unicode regexes. */
- var reOptMod = rsModifier + '?';
- var rsOptVar = '[' + rsVarRange$1 + ']?';
- var rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*';
- var rsSeq = rsOptVar + reOptMod + rsOptJoin;
- var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
-
- var hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
- var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
-
- function fallback(fn) {
- setTimeout(fn, 0);
- }
-
- function wrap(defer) {
- return rest(function (fn, args) {
- defer(function () {
- fn.apply(null, args);
- });
- });
- }
-
- var _defer;
-
- if (hasSetImmediate) {
- _defer = setImmediate;
- } else if (hasNextTick) {
- _defer = process.nextTick;
- } else {
- _defer = fallback;
- }
-
- wrap(_defer);
-
- // Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation
- // used for queues. This implementation assumes that the node provided by the user can be modified
- // to adjust the next and last properties. We implement only the minimal functionality
- // for queue support.
-
- /**
- * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
- *
- * @name eachOfSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.eachOf]{@link module:Collections.eachOf}
- * @alias forEachOfSeries
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`. The
- * `key` is the item's key, or index in the case of an array. The iteratee is
- * passed a `callback(err)` which must be called once it has completed. If no
- * error has occurred, the callback should be run without arguments or with an
- * explicit `null` argument. Invoked with (item, key, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. Invoked with (err).
- */
- var eachOfSeries = doLimit(eachOfLimit, 1);
-
- /**
- * Reduces `coll` into a single value using an async `iteratee` to return each
- * successive step. `memo` is the initial state of the reduction. This function
- * only operates in series.
- *
- * For performance reasons, it may make sense to split a call to this function
- * into a parallel map, and then use the normal `Array.prototype.reduce` on the
- * results. This function is for situations where each step in the reduction
- * needs to be async; if you can get the data before reducing it, then it's
- * probably a good idea to do so.
- *
- * @name reduce
- * @static
- * @memberOf module:Collections
- * @method
- * @alias inject
- * @alias foldl
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {*} memo - The initial state of the reduction.
- * @param {Function} iteratee - A function applied to each item in the
- * array to produce the next step in the reduction. The `iteratee` is passed a
- * `callback(err, reduction)` which accepts an optional error as its first
- * argument, and the state of the reduction as the second. If an error is
- * passed to the callback, the reduction is stopped and the main `callback` is
- * immediately called with the error. Invoked with (memo, item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result is the reduced value. Invoked with
- * (err, result).
- * @example
- *
- * async.reduce([1,2,3], 0, function(memo, item, callback) {
- * // pointless async:
- * process.nextTick(function() {
- * callback(null, memo + item)
- * });
- * }, function(err, result) {
- * // result is now equal to the last value of memo, which is 6
- * });
- */
- function reduce(coll, memo, iteratee, callback) {
- callback = once(callback || noop);
- eachOfSeries(coll, function(x, i, callback) {
- iteratee(memo, x, function(err, v) {
- memo = v;
- callback(err);
- });
- }, function(err) {
- callback(err, memo);
- });
- }
-
- /**
- * Version of the compose function that is more natural to read. Each function
- * consumes the return value of the previous function. It is the equivalent of
- * [compose]{@link module:ControlFlow.compose} with the arguments reversed.
- *
- * Each function is executed with the `this` binding of the composed function.
- *
- * @name seq
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.compose]{@link module:ControlFlow.compose}
- * @category Control Flow
- * @param {...Function} functions - the asynchronous functions to compose
- * @returns {Function} a function that composes the `functions` in order
- * @example
- *
- * // Requires lodash (or underscore), express3 and dresende's orm2.
- * // Part of an app, that fetches cats of the logged user.
- * // This example uses `seq` function to avoid overnesting and error
- * // handling clutter.
- * app.get('/cats', function(request, response) {
- * var User = request.models.User;
- * async.seq(
- * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))
- * function(user, fn) {
- * user.getCats(fn); // 'getCats' has signature (callback(err, data))
- * }
- * )(req.session.user_id, function (err, cats) {
- * if (err) {
- * console.error(err);
- * response.json({ status: 'error', message: err.message });
- * } else {
- * response.json({ status: 'ok', message: 'Cats found', data: cats });
- * }
- * });
- * });
- */
- var seq = rest(function seq(functions) {
- return rest(function(args) {
- var that = this;
-
- var cb = args[args.length - 1];
- if (typeof cb == 'function') {
- args.pop();
- } else {
- cb = noop;
- }
-
- reduce(functions, args, function(newargs, fn, cb) {
- fn.apply(that, newargs.concat(rest(function(err, nextargs) {
- cb(err, nextargs);
- })));
- },
- function(err, results) {
- cb.apply(that, [err].concat(results));
- });
- });
- });
-
- /**
- * Creates a function which is a composition of the passed asynchronous
- * functions. Each function consumes the return value of the function that
- * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
- * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
- *
- * Each function is executed with the `this` binding of the composed function.
- *
- * @name compose
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {...Function} functions - the asynchronous functions to compose
- * @returns {Function} an asynchronous function that is the composed
- * asynchronous `functions`
- * @example
- *
- * function add1(n, callback) {
- * setTimeout(function () {
- * callback(null, n + 1);
- * }, 10);
- * }
- *
- * function mul3(n, callback) {
- * setTimeout(function () {
- * callback(null, n * 3);
- * }, 10);
- * }
- *
- * var add1mul3 = async.compose(mul3, add1);
- * add1mul3(4, function (err, result) {
- * // result now equals 15
- * });
- */
- rest(function(args) {
- return seq.apply(null, args.reverse());
- });
-
- /**
- * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
- * the concatenated list. The `iteratee`s are called in parallel, and the
- * results are concatenated as they return. There is no guarantee that the
- * results array will be returned in the original order of `coll` passed to the
- * `iteratee` function.
- *
- * @name concat
- * @static
- * @memberOf module:Collections
- * @method
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, results)` which must be called once
- * it has completed with an error (which can be `null`) and an array of results.
- * Invoked with (item, callback).
- * @param {Function} [callback(err)] - A callback which is called after all the
- * `iteratee` functions have finished, or an error occurs. Results is an array
- * containing the concatenated results of the `iteratee` function. Invoked with
- * (err, results).
- * @example
- *
- * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
- * // files is now a list of filenames that exist in the 3 directories
- * });
- */
-
- /**
- * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
- *
- * @name concatSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.concat]{@link module:Collections.concat}
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, results)` which must be called once
- * it has completed with an error (which can be `null`) and an array of results.
- * Invoked with (item, callback).
- * @param {Function} [callback(err)] - A callback which is called after all the
- * `iteratee` functions have finished, or an error occurs. Results is an array
- * containing the concatenated results of the `iteratee` function. Invoked with
- * (err, results).
- */
-
- /**
- * Returns a function that when called, calls-back with the values provided.
- * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
- * [`auto`]{@link module:ControlFlow.auto}.
- *
- * @name constant
- * @static
- * @memberOf module:Utils
- * @method
- * @category Util
- * @param {...*} arguments... - Any number of arguments to automatically invoke
- * callback with.
- * @returns {Function} Returns a function that when invoked, automatically
- * invokes the callback with the previous given arguments.
- * @example
- *
- * async.waterfall([
- * async.constant(42),
- * function (value, next) {
- * // value === 42
- * },
- * //...
- * ], callback);
- *
- * async.waterfall([
- * async.constant(filename, "utf8"),
- * fs.readFile,
- * function (fileData, next) {
- * //...
- * }
- * //...
- * ], callback);
- *
- * async.auto({
- * hostname: async.constant("https://server.net/"),
- * port: findFreePort,
- * launchServer: ["hostname", "port", function (options, cb) {
- * startServer(options, cb);
- * }],
- * //...
- * }, callback);
- */
- rest(function(values) {
- var args = [null].concat(values);
- return initialParams(function (ignoredArgs, callback) {
- return callback.apply(this, args);
- });
- });
-
- /**
- * Returns the first value in `coll` that passes an async truth test. The
- * `iteratee` is applied in parallel, meaning the first iteratee to return
- * `true` will fire the detect `callback` with that result. That means the
- * result might not be the first item in the original `coll` (in terms of order)
- * that passes the test.
-
- * If order within the original `coll` is important, then look at
- * [`detectSeries`]{@link module:Collections.detectSeries}.
- *
- * @name detect
- * @static
- * @memberOf module:Collections
- * @method
- * @alias find
- * @category Collections
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, truthValue)` which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the `iteratee` functions have finished.
- * Result will be the first item in the array that passes the truth test
- * (iteratee) or the value `undefined` if none passed. Invoked with
- * (err, result).
- * @example
- *
- * async.detect(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, result) {
- * // result now equals the first file in the list that exists
- * });
- */
-
- /**
- * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name detectLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.detect]{@link module:Collections.detect}
- * @alias findLimit
- * @category Collections
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, truthValue)` which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the `iteratee` functions have finished.
- * Result will be the first item in the array that passes the truth test
- * (iteratee) or the value `undefined` if none passed. Invoked with
- * (err, result).
- */
-
- /**
- * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
- *
- * @name detectSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.detect]{@link module:Collections.detect}
- * @alias findSeries
- * @category Collections
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The iteratee is passed a `callback(err, truthValue)` which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the `iteratee` functions have finished.
- * Result will be the first item in the array that passes the truth test
- * (iteratee) or the value `undefined` if none passed. Invoked with
- * (err, result).
- */
-
- function consoleFunc(name) {
- return rest(function (fn, args) {
- fn.apply(null, args.concat(rest(function (err, args) {
- if (typeof console === 'object') {
- if (err) {
- if (console.error) {
- console.error(err);
- }
- }
- else if (console[name]) {
- arrayEach(args, function (x) {
- console[name](x);
- });
- }
- }
- })));
- });
- }
-
- /**
- * Logs the result of an `async` function to the `console` using `console.dir`
- * to display the properties of the resulting object. Only works in Node.js or
- * in browsers that support `console.dir` and `console.error` (such as FF and
- * Chrome). If multiple arguments are returned from the async function,
- * `console.dir` is called on each argument in order.
- *
- * @name dir
- * @static
- * @memberOf module:Utils
- * @method
- * @category Util
- * @param {Function} function - The function you want to eventually apply all
- * arguments to.
- * @param {...*} arguments... - Any number of arguments to apply to the function.
- * @example
- *
- * // in a module
- * var hello = function(name, callback) {
- * setTimeout(function() {
- * callback(null, {hello: name});
- * }, 1000);
- * };
- *
- * // in the node repl
- * node> async.dir(hello, 'world');
- * {hello: 'world'}
- */
- consoleFunc('dir');
-
- function _withoutIndex(iteratee) {
- return function (value, index, callback) {
- return iteratee(value, callback);
- };
- }
-
- /**
- * Applies the function `iteratee` to each item in `coll`, in parallel.
- * The `iteratee` is called with an item from the list, and a callback for when
- * it has finished. If the `iteratee` passes an error to its `callback`, the
- * main `callback` (for the `each` function) is immediately called with the
- * error.
- *
- * Note, that since this function applies `iteratee` to each item in parallel,
- * there is no guarantee that the iteratee functions will complete in order.
- *
- * @name each
- * @static
- * @memberOf module:Collections
- * @method
- * @alias forEach
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each item
- * in `coll`. The iteratee is passed a `callback(err)` which must be called once
- * it has completed. If no error has occurred, the `callback` should be run
- * without arguments or with an explicit `null` argument. The array index is not
- * passed to the iteratee. Invoked with (item, callback). If you need the index,
- * use `eachOf`.
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- * @example
- *
- * // assuming openFiles is an array of file names and saveFile is a function
- * // to save the modified contents of that file:
- *
- * async.each(openFiles, saveFile, function(err){
- * // if any of the saves produced an error, err would equal that error
- * });
- *
- * // assuming openFiles is an array of file names
- * async.each(openFiles, function(file, callback) {
- *
- * // Perform operation on file here.
- * console.log('Processing file ' + file);
- *
- * if( file.length > 32 ) {
- * console.log('This file name is too long');
- * callback('File name too long');
- * } else {
- * // Do work to process file here
- * console.log('File processed');
- * callback();
- * }
- * }, function(err) {
- * // if any of the file processing produced an error, err would equal that error
- * if( err ) {
- * // One of the iterations produced an error.
- * // All processing will now stop.
- * console.log('A file failed to process');
- * } else {
- * console.log('All files have been processed successfully');
- * }
- * });
- */
- function eachLimit(coll, iteratee, callback) {
- eachOf(coll, _withoutIndex(iteratee), callback);
- }
-
- /**
- * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
- *
- * @name eachSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.each]{@link module:Collections.each}
- * @alias forEachSeries
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each
- * item in `coll`. The iteratee is passed a `callback(err)` which must be called
- * once it has completed. If no error has occurred, the `callback` should be run
- * without arguments or with an explicit `null` argument. The array index is
- * not passed to the iteratee. Invoked with (item, callback). If you need the
- * index, use `eachOfSeries`.
- * @param {Function} [callback] - A callback which is called when all
- * `iteratee` functions have finished, or an error occurs. Invoked with (err).
- */
-
- /**
- * Returns `true` if every element in `coll` satisfies an async test. If any
- * iteratee call returns `false`, the main `callback` is immediately called.
- *
- * @name every
- * @static
- * @memberOf module:Collections
- * @method
- * @alias all
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in the
- * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
- * which must be called with a boolean argument once it has completed. Invoked
- * with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result will be either `true` or `false`
- * depending on the values of the async tests. Invoked with (err, result).
- * @example
- *
- * async.every(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, result) {
- * // if result is true then every file exists
- * });
- */
-
- /**
- * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
- *
- * @name everyLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.every]{@link module:Collections.every}
- * @alias allLimit
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in the
- * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
- * which must be called with a boolean argument once it has completed. Invoked
- * with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result will be either `true` or `false`
- * depending on the values of the async tests. Invoked with (err, result).
- */
-
- /**
- * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
- *
- * @name everySeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.every]{@link module:Collections.every}
- * @alias allSeries
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in the
- * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
- * which must be called with a boolean argument once it has completed. Invoked
- * with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Result will be either `true` or `false`
- * depending on the values of the async tests. Invoked with (err, result).
- */
-
- /**
- * The base implementation of `_.property` without support for deep paths.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new accessor function.
- */
-
- /**
- * Returns a new array of all the values in `coll` which pass an async truth
- * test. This operation is performed in parallel, but the results array will be
- * in the same order as the original.
- *
- * @name filter
- * @static
- * @memberOf module:Collections
- * @method
- * @alias select
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- * @example
- *
- * async.filter(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, results) {
- * // results now equals an array of the existing files
- * });
- */
-
- /**
- * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name filterLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.filter]{@link module:Collections.filter}
- * @alias selectLimit
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- */
-
- /**
- * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
- *
- * @name filterSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.filter]{@link module:Collections.filter}
- * @alias selectSeries
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results)
- */
-
- /**
- * Logs the result of an `async` function to the `console`. Only works in
- * Node.js or in browsers that support `console.log` and `console.error` (such
- * as FF and Chrome). If multiple arguments are returned from the async
- * function, `console.log` is called on each argument in order.
- *
- * @name log
- * @static
- * @memberOf module:Utils
- * @method
- * @category Util
- * @param {Function} function - The function you want to eventually apply all
- * arguments to.
- * @param {...*} arguments... - Any number of arguments to apply to the function.
- * @example
- *
- * // in a module
- * var hello = function(name, callback) {
- * setTimeout(function() {
- * callback(null, 'hello ' + name);
- * }, 1000);
- * };
- *
- * // in the node repl
- * node> async.log(hello, 'world');
- * 'hello world'
- */
- consoleFunc('log');
-
- /**
- * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
- *
- * Produces a new Object by mapping each value of `obj` through the `iteratee`
- * function. The `iteratee` is called each `value` and `key` from `obj` and a
- * callback for when it has finished processing. Each of these callbacks takes
- * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
- * passes an error to its callback, the main `callback` (for the `mapValues`
- * function) is immediately called with the error.
- *
- * Note, the order of the keys in the result is not guaranteed. The keys will
- * be roughly in the order they complete, (but this is very engine-specific)
- *
- * @name mapValues
- * @static
- * @memberOf module:Collections
- * @method
- * @category Collection
- * @param {Object} obj - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each value and key in
- * `coll`. The iteratee is passed a `callback(err, transformed)` which must be
- * called once it has completed with an error (which can be `null`) and a
- * transformed value. Invoked with (value, key, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. `result` is a new object consisting
- * of each key from `obj`, with each transformed value on the right-hand side.
- * Invoked with (err, result).
- * @example
- *
- * async.mapValues({
- * f1: 'file1',
- * f2: 'file2',
- * f3: 'file3'
- * }, function (file, key, callback) {
- * fs.stat(file, callback);
- * }, function(err, result) {
- * // result is now a map of stats for each file, e.g.
- * // {
- * // f1: [stats for file1],
- * // f2: [stats for file2],
- * // f3: [stats for file3]
- * // }
- * });
- */
-
- /**
- * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.
- *
- * @name mapValuesSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.mapValues]{@link module:Collections.mapValues}
- * @category Collection
- * @param {Object} obj - A collection to iterate over.
- * @param {Function} iteratee - A function to apply to each value in `obj`.
- * The iteratee is passed a `callback(err, transformed)` which must be called
- * once it has completed with an error (which can be `null`) and a
- * transformed value. Invoked with (value, key, callback).
- * @param {Function} [callback] - A callback which is called when all `iteratee`
- * functions have finished, or an error occurs. `result` is a new object consisting
- * of each key from `obj`, with each transformed value on the right-hand side.
- * Invoked with (err, result).
- */
-
- /**
- * Calls `callback` on a later loop around the event loop. In Node.js this just
- * calls `setImmediate`. In the browser it will use `setImmediate` if
- * available, otherwise `setTimeout(callback, 0)`, which means other higher
- * priority events may precede the execution of `callback`.
- *
- * This is used internally for browser-compatibility purposes.
- *
- * @name nextTick
- * @static
- * @memberOf module:Utils
- * @method
- * @alias setImmediate
- * @category Util
- * @param {Function} callback - The function to call on a later loop around
- * the event loop. Invoked with (args...).
- * @param {...*} args... - any number of additional arguments to pass to the
- * callback on the next tick.
- * @example
- *
- * var call_order = [];
- * async.nextTick(function() {
- * call_order.push('two');
- * // call_order now equals ['one','two']
- * });
- * call_order.push('one');
- *
- * async.setImmediate(function (a, b, c) {
- * // a, b, and c equal 1, 2, and 3
- * }, 1, 2, 3);
- */
- var _defer$1;
-
- if (hasNextTick) {
- _defer$1 = process.nextTick;
- } else if (hasSetImmediate) {
- _defer$1 = setImmediate;
- } else {
- _defer$1 = fallback;
- }
-
- wrap(_defer$1);
-
- /**
- * Calls `callback` on a later loop around the event loop. In Node.js this just
- * calls `setImmediate`. In the browser it will use `setImmediate` if
- * available, otherwise `setTimeout(callback, 0)`, which means other higher
- * priority events may precede the execution of `callback`.
- *
- * This is used internally for browser-compatibility purposes.
- *
- * @name setImmediate
- * @static
- * @memberOf module:Utils
- * @method
- * @alias nextTick
- * @category Util
- * @param {Function} callback - The function to call on a later loop around
- * the event loop. Invoked with (args...).
- * @param {...*} args... - any number of additional arguments to pass to the
- * callback on the next tick.
- * @example
- *
- * var call_order = [];
- * async.nextTick(function() {
- * call_order.push('two');
- * // call_order now equals ['one','two']
- * });
- * call_order.push('one');
- *
- * async.setImmediate(function (a, b, c) {
- * // a, b, and c equal 1, 2, and 3
- * }, 1, 2, 3);
- */
-
- /**
- * A queue of tasks for the worker function to complete.
- * @typedef {Object} QueueObject
- * @memberOf module:ControlFlow
- * @property {Function} length - a function returning the number of items
- * waiting to be processed. Invoke with `queue.length()`.
- * @property {boolean} started - a boolean indicating whether or not any
- * items have been pushed and processed by the queue.
- * @property {Function} running - a function returning the number of items
- * currently being processed. Invoke with `queue.running()`.
- * @property {Function} workersList - a function returning the array of items
- * currently being processed. Invoke with `queue.workersList()`.
- * @property {Function} idle - a function returning false if there are items
- * waiting or being processed, or true if not. Invoke with `queue.idle()`.
- * @property {number} concurrency - an integer for determining how many `worker`
- * functions should be run in parallel. This property can be changed after a
- * `queue` is created to alter the concurrency on-the-fly.
- * @property {Function} push - add a new task to the `queue`. Calls `callback`
- * once the `worker` has finished processing the task. Instead of a single task,
- * a `tasks` array can be submitted. The respective callback is used for every
- * task in the list. Invoke with `queue.push(task, [callback])`,
- * @property {Function} unshift - add a new task to the front of the `queue`.
- * Invoke with `queue.unshift(task, [callback])`.
- * @property {Function} saturated - a callback that is called when the number of
- * running workers hits the `concurrency` limit, and further tasks will be
- * queued.
- * @property {Function} unsaturated - a callback that is called when the number
- * of running workers is less than the `concurrency` & `buffer` limits, and
- * further tasks will not be queued.
- * @property {number} buffer - A minimum threshold buffer in order to say that
- * the `queue` is `unsaturated`.
- * @property {Function} empty - a callback that is called when the last item
- * from the `queue` is given to a `worker`.
- * @property {Function} drain - a callback that is called when the last item
- * from the `queue` has returned from the `worker`.
- * @property {Function} error - a callback that is called when a task errors.
- * Has the signature `function(error, task)`.
- * @property {boolean} paused - a boolean for determining whether the queue is
- * in a paused state.
- * @property {Function} pause - a function that pauses the processing of tasks
- * until `resume()` is called. Invoke with `queue.pause()`.
- * @property {Function} resume - a function that resumes the processing of
- * queued tasks when the queue is paused. Invoke with `queue.resume()`.
- * @property {Function} kill - a function that removes the `drain` callback and
- * empties remaining tasks from the queue forcing it to go idle. Invoke with `queue.kill()`.
- */
-
- /**
- * Creates a `queue` object with the specified `concurrency`. Tasks added to the
- * `queue` are processed in parallel (up to the `concurrency` limit). If all
- * `worker`s are in progress, the task is queued until one becomes available.
- * Once a `worker` completes a `task`, that `task`'s callback is called.
- *
- * @name queue
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Function} worker - An asynchronous function for processing a queued
- * task, which must call its `callback(err)` argument when finished, with an
- * optional `error` as an argument. If you want to handle errors from an
- * individual task, pass a callback to `q.push()`. Invoked with
- * (task, callback).
- * @param {number} [concurrency=1] - An `integer` for determining how many
- * `worker` functions should be run in parallel. If omitted, the concurrency
- * defaults to `1`. If the concurrency is `0`, an error is thrown.
- * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can
- * attached as certain properties to listen for specific events during the
- * lifecycle of the queue.
- * @example
- *
- * // create a queue object with concurrency 2
- * var q = async.queue(function(task, callback) {
- * console.log('hello ' + task.name);
- * callback();
- * }, 2);
- *
- * // assign a callback
- * q.drain = function() {
- * console.log('all items have been processed');
- * };
- *
- * // add some items to the queue
- * q.push({name: 'foo'}, function(err) {
- * console.log('finished processing foo');
- * });
- * q.push({name: 'bar'}, function (err) {
- * console.log('finished processing bar');
- * });
- *
- * // add some items to the queue (batch-wise)
- * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
- * console.log('finished processing item');
- * });
- *
- * // add some items to the front of the queue
- * q.unshift({name: 'bar'}, function (err) {
- * console.log('finished processing bar');
- * });
- */
-
- /**
- * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and
- * completed in ascending priority order.
- *
- * @name priorityQueue
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.queue]{@link module:ControlFlow.queue}
- * @category Control Flow
- * @param {Function} worker - An asynchronous function for processing a queued
- * task, which must call its `callback(err)` argument when finished, with an
- * optional `error` as an argument. If you want to handle errors from an
- * individual task, pass a callback to `q.push()`. Invoked with
- * (task, callback).
- * @param {number} concurrency - An `integer` for determining how many `worker`
- * functions should be run in parallel. If omitted, the concurrency defaults to
- * `1`. If the concurrency is `0`, an error is thrown.
- * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two
- * differences between `queue` and `priorityQueue` objects:
- * * `push(task, priority, [callback])` - `priority` should be a number. If an
- * array of `tasks` is given, all tasks will be assigned the same priority.
- * * The `unshift` method was removed.
- */
-
- /**
- * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
- *
- * @name reject
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.filter]{@link module:Collections.filter}
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- * @example
- *
- * async.reject(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, results) {
- * // results now equals an array of missing files
- * createFiles(results);
- * });
- */
-
- /**
- * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
- * time.
- *
- * @name rejectLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.reject]{@link module:Collections.reject}
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- */
-
- /**
- * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
- *
- * @name rejectSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.reject]{@link module:Collections.reject}
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in `coll`.
- * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
- * with a boolean argument once it has completed. Invoked with (item, callback).
- * @param {Function} [callback] - A callback which is called after all the
- * `iteratee` functions have finished. Invoked with (err, results).
- */
-
- /**
- * Creates a function that returns `value`.
- *
- * @static
- * @memberOf _
- * @since 2.4.0
- * @category Util
- * @param {*} value The value to return from the new function.
- * @returns {Function} Returns the new constant function.
- * @example
- *
- * var objects = _.times(2, _.constant({ 'a': 1 }));
- *
- * console.log(objects);
- * // => [{ 'a': 1 }, { 'a': 1 }]
- *
- * console.log(objects[0] === objects[1]);
- * // => true
- */
-
- /**
- * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method wraps a task and makes it
- * retryable, rather than immediately calling it with retries.
- *
- * @name retryable
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.retry]{@link module:ControlFlow.retry}
- * @category Control Flow
- * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
- * options, exactly the same as from `retry`
- * @param {Function} task - the asynchronous function to wrap
- * @returns {Functions} The wrapped function, which when invoked, will retry on
- * an error, based on the parameters specified in `opts`.
- * @example
- *
- * async.auto({
- * dep1: async.retryable(3, getFromFlakyService),
- * process: ["dep1", async.retryable(3, function (results, cb) {
- * maybeProcessData(results.dep1, cb);
- * })]
- * }, callback);
- */
-
- /**
- * Returns `true` if at least one element in the `coll` satisfies an async test.
- * If any iteratee call returns `true`, the main `callback` is immediately
- * called.
- *
- * @name some
- * @static
- * @memberOf module:Collections
- * @method
- * @alias any
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in the array
- * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
- * be called with a boolean argument once it has completed. Invoked with
- * (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the iteratee functions have finished.
- * Result will be either `true` or `false` depending on the values of the async
- * tests. Invoked with (err, result).
- * @example
- *
- * async.some(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, result) {
- * // if result is true then at least one of the files exists
- * });
- */
-
- /**
- * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
- *
- * @name someLimit
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.some]{@link module:Collections.some}
- * @alias anyLimit
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {number} limit - The maximum number of async operations at a time.
- * @param {Function} iteratee - A truth test to apply to each item in the array
- * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
- * be called with a boolean argument once it has completed. Invoked with
- * (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the iteratee functions have finished.
- * Result will be either `true` or `false` depending on the values of the async
- * tests. Invoked with (err, result).
- */
-
- /**
- * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
- *
- * @name someSeries
- * @static
- * @memberOf module:Collections
- * @method
- * @see [async.some]{@link module:Collections.some}
- * @alias anySeries
- * @category Collection
- * @param {Array|Iterable|Object} coll - A collection to iterate over.
- * @param {Function} iteratee - A truth test to apply to each item in the array
- * in parallel. The iteratee is passed a `callback(err, truthValue)` which must
- * be called with a boolean argument once it has completed. Invoked with
- * (item, callback).
- * @param {Function} [callback] - A callback which is called as soon as any
- * iteratee returns `true`, or after all the iteratee functions have finished.
- * Result will be either `true` or `false` depending on the values of the async
- * tests. Invoked with (err, result).
- */
-
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeCeil = Math.ceil;
- var nativeMax$1 = Math.max;
-
- /**
- * Calls the `iteratee` function `n` times, and accumulates results in the same
- * manner you would use with [map]{@link module:Collections.map}.
- *
- * @name times
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.map]{@link module:Collections.map}
- * @category Control Flow
- * @param {number} n - The number of times to run the function.
- * @param {Function} iteratee - The function to call `n` times. Invoked with the
- * iteration index and a callback (n, next).
- * @param {Function} callback - see {@link module:Collections.map}.
- * @example
- *
- * // Pretend this is some complicated async factory
- * var createUser = function(id, callback) {
- * callback(null, {
- * id: 'user' + id
- * });
- * };
- *
- * // generate 5 users
- * async.times(5, function(n, next) {
- * createUser(n, function(err, user) {
- * next(err, user);
- * });
- * }, function(err, users) {
- * // we should now have 5 users
- * });
- */
-
- /**
- * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.
- *
- * @name timesSeries
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @see [async.times]{@link module:ControlFlow.times}
- * @category Control Flow
- * @param {number} n - The number of times to run the function.
- * @param {Function} iteratee - The function to call `n` times. Invoked with the
- * iteration index and a callback (n, next).
- * @param {Function} callback - see {@link module:Collections.map}.
- */
-
- /**
- * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
- * unmemoized form. Handy for testing.
- *
- * @name unmemoize
- * @static
- * @memberOf module:Utils
- * @method
- * @see [async.memoize]{@link module:Utils.memoize}
- * @category Util
- * @param {Function} fn - the memoized function
- * @returns {Function} a function that calls the original unmemoized function
- */
-
- /**
- * Runs the `tasks` array of functions in series, each passing their results to
- * the next in the array. However, if any of the `tasks` pass an error to their
- * own callback, the next function is not executed, and the main `callback` is
- * immediately called with the error.
- *
- * @name waterfall
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Array} tasks - An array of functions to run, each function is passed
- * a `callback(err, result1, result2, ...)` it must call on completion. The
- * first argument is an error (which can be `null`) and any further arguments
- * will be passed as arguments in order to the next task.
- * @param {Function} [callback] - An optional callback to run once all the
- * functions have completed. This will be passed the results of the last task's
- * callback. Invoked with (err, [results]).
- * @returns undefined
- * @example
- *
- * async.waterfall([
- * function(callback) {
- * callback(null, 'one', 'two');
- * },
- * function(arg1, arg2, callback) {
- * // arg1 now equals 'one' and arg2 now equals 'two'
- * callback(null, 'three');
- * },
- * function(arg1, callback) {
- * // arg1 now equals 'three'
- * callback(null, 'done');
- * }
- * ], function (err, result) {
- * // result now equals 'done'
- * });
- *
- * // Or, with named functions:
- * async.waterfall([
- * myFirstFunction,
- * mySecondFunction,
- * myLastFunction,
- * ], function (err, result) {
- * // result now equals 'done'
- * });
- * function myFirstFunction(callback) {
- * callback(null, 'one', 'two');
- * }
- * function mySecondFunction(arg1, arg2, callback) {
- * // arg1 now equals 'one' and arg2 now equals 'two'
- * callback(null, 'three');
- * }
- * function myLastFunction(arg1, callback) {
- * // arg1 now equals 'three'
- * callback(null, 'done');
- * }
- */
-
- /**
- * Async is a utility module which provides straight-forward, powerful functions
- * for working with asynchronous JavaScript. Although originally designed for
- * use with [Node.js](http://nodejs.org) and installable via
- * `npm install --save async`, it can also be used directly in the browser.
- * @module async
- */
-
- /**
- * A collection of `async` functions for manipulating collections, such as
- * arrays and objects.
- * @module Collections
- */
-
- /**
- * A collection of `async` functions for controlling the flow through a script.
- * @module ControlFlow
- */
-
- /**
- * A collection of `async` utility functions.
- * @module Utils
- */
-
- /**
- * @hidden
- */
- var errorCodeLookup;
- /**
- * Lazily construct error code lookup, since DropboxJS might be loaded *after* BrowserFS (or not at all!)
- * @hidden
- */
- function constructErrorCodeLookup() {
- if (errorCodeLookup) {
- return;
- }
- errorCodeLookup = {};
- // This indicates a network transmission error on modern browsers. Internet Explorer might cause this code to be reported on some API server errors.
- errorCodeLookup[Dropbox.ApiError.NETWORK_ERROR] = ErrorCode.EIO;
- // This happens when the contentHash parameter passed to a Dropbox.Client#readdir or Dropbox.Client#stat matches the most recent content, so the API call response is omitted, to save bandwidth.
- // errorCodeLookup[Dropbox.ApiError.NO_CONTENT];
- // The error property on {Dropbox.ApiError#response} should indicate which input parameter is invalid and why.
- errorCodeLookup[Dropbox.ApiError.INVALID_PARAM] = ErrorCode.EINVAL;
- // The OAuth token used for the request will never become valid again, so the user should be re-authenticated.
- errorCodeLookup[Dropbox.ApiError.INVALID_TOKEN] = ErrorCode.EPERM;
- // This indicates a bug in dropbox.js and should never occur under normal circumstances.
- // ^ Actually, that's false. This occurs when you try to move folders to themselves, or move a file over another file.
- errorCodeLookup[Dropbox.ApiError.OAUTH_ERROR] = ErrorCode.EPERM;
- // This happens when trying to read from a non-existing file, readdir a non-existing directory, write a file into a non-existing directory, etc.
- errorCodeLookup[Dropbox.ApiError.NOT_FOUND] = ErrorCode.ENOENT;
- // This indicates a bug in dropbox.js and should never occur under normal circumstances.
- errorCodeLookup[Dropbox.ApiError.INVALID_METHOD] = ErrorCode.EINVAL;
- // This happens when a Dropbox.Client#readdir or Dropbox.Client#stat call would return more than a maximum amount of directory entries.
- errorCodeLookup[Dropbox.ApiError.NOT_ACCEPTABLE] = ErrorCode.EINVAL;
- // This is used by some backend methods to indicate that the client needs to download server-side changes and perform conflict resolution. Under normal usage, errors with this code should never surface to the code using dropbox.js.
- errorCodeLookup[Dropbox.ApiError.CONFLICT] = ErrorCode.EINVAL;
- // Status value indicating that the application is making too many requests.
- errorCodeLookup[Dropbox.ApiError.RATE_LIMITED] = ErrorCode.EBUSY;
- // The request should be retried after some time.
- errorCodeLookup[Dropbox.ApiError.SERVER_ERROR] = ErrorCode.EBUSY;
- // Status value indicating that the user's Dropbox is over its storage quota.
- errorCodeLookup[Dropbox.ApiError.OVER_QUOTA] = ErrorCode.ENOSPC;
- }
- /**
- * @hidden
- */
- function isFileInfo(cache) {
- return cache && cache.stat.isFile;
- }
- /**
- * @hidden
- */
- function isDirInfo(cache) {
- return cache && cache.stat.isFolder;
- }
- /**
- * @hidden
- */
- function isArrayBuffer(ab) {
- // Accept null / undefined, too.
- return ab === null || ab === undefined || (typeof (ab) === 'object' && typeof (ab['byteLength']) === 'number');
- }
- /**
- * Wraps a Dropbox client and caches operations.
- * @hidden
- */
- var CachedDropboxClient = function CachedDropboxClient(client) {
- this._cache = {};
- this._client = client;
- };
- CachedDropboxClient.prototype.readdir = function readdir (p, cb) {
- var this$1 = this;
-
- var cacheInfo = this.getCachedDirInfo(p);
- this._wrap(function (interceptCb) {
- if (cacheInfo !== null && cacheInfo.contents) {
- this$1._client.readdir(p, {
- contentHash: cacheInfo.stat.contentHash
- }, interceptCb);
- }
- else {
- this$1._client.readdir(p, interceptCb);
- }
- }, function (err, filenames, stat, folderEntries) {
- if (err) {
- if (err.status === Dropbox.ApiError.NO_CONTENT && cacheInfo !== null) {
- cb(null, cacheInfo.contents.slice(0));
- }
- else {
- cb(err);
- }
- }
- else {
- this$1.updateCachedDirInfo(p, stat, filenames.slice(0));
- folderEntries.forEach(function (entry) {
- this$1.updateCachedInfo(path.join(p, entry.name), entry);
- });
- cb(null, filenames);
- }
- });
- };
- CachedDropboxClient.prototype.remove = function remove (p, cb) {
- var this$1 = this;
-
- this._wrap(function (interceptCb) {
- this$1._client.remove(p, interceptCb);
- }, function (err, stat) {
- if (!err) {
- this$1.updateCachedInfo(p, stat);
- }
- cb(err);
- });
- };
- CachedDropboxClient.prototype.move = function move (src, dest, cb) {
- var this$1 = this;
-
- this._wrap(function (interceptCb) {
- this$1._client.move(src, dest, interceptCb);
- }, function (err, stat) {
- if (!err) {
- this$1.deleteCachedInfo(src);
- this$1.updateCachedInfo(dest, stat);
- }
- cb(err);
- });
- };
- CachedDropboxClient.prototype.stat = function stat (p, cb) {
- var this$1 = this;
-
- this._wrap(function (interceptCb) {
- this$1._client.stat(p, interceptCb);
- }, function (err, stat) {
- if (!err) {
- this$1.updateCachedInfo(p, stat);
- }
- cb(err, stat);
- });
- };
- CachedDropboxClient.prototype.readFile = function readFile (p, cb) {
- var this$1 = this;
-
- var cacheInfo = this.getCachedFileInfo(p);
- if (cacheInfo !== null && cacheInfo.contents !== null) {
- // Try to use cached info; issue a stat to see if contents are up-to-date.
- this.stat(p, function (error, stat) {
- if (error) {
- cb(error);
- }
- else if (stat.contentHash === cacheInfo.stat.contentHash) {
- // No file changes.
- cb(error, cacheInfo.contents.slice(0), cacheInfo.stat);
- }
- else {
- // File changes; rerun to trigger actual readFile.
- this$1.readFile(p, cb);
- }
- });
- }
- else {
- this._wrap(function (interceptCb) {
- this$1._client.readFile(p, { arrayBuffer: true }, interceptCb);
- }, function (err, contents, stat) {
- if (!err) {
- this$1.updateCachedInfo(p, stat, contents.slice(0));
- }
- cb(err, contents, stat);
- });
- }
- };
- CachedDropboxClient.prototype.writeFile = function writeFile (p, contents, cb) {
- var this$1 = this;
-
- this._wrap(function (interceptCb) {
- this$1._client.writeFile(p, contents, interceptCb);
- }, function (err, stat) {
- if (!err) {
- this$1.updateCachedInfo(p, stat, contents.slice(0));
- }
- cb(err, stat);
- });
- };
- CachedDropboxClient.prototype.mkdir = function mkdir (p, cb) {
- var this$1 = this;
-
- this._wrap(function (interceptCb) {
- this$1._client.mkdir(p, interceptCb);
- }, function (err, stat) {
- if (!err) {
- this$1.updateCachedInfo(p, stat, []);
- }
- cb(err);
- });
- };
- /**
- * Wraps an operation such that we retry a failed operation 3 times.
- * Necessary to deal with Dropbox rate limiting.
- *
- * @param performOp Function that performs the operation. Will be called up to three times.
- * @param cb Called when the operation succeeds, fails in a non-temporary manner, or fails three times.
- */
- CachedDropboxClient.prototype._wrap = function _wrap (performOp, cb) {
- var numRun = 0;
- var interceptCb = function (error) {
- // Timeout duration, in seconds.
- var timeoutDuration = 2;
- if (error && 3 > (++numRun)) {
- switch (error.status) {
- case Dropbox.ApiError.SERVER_ERROR:
- case Dropbox.ApiError.NETWORK_ERROR:
- case Dropbox.ApiError.RATE_LIMITED:
- setTimeout(function () {
- performOp(interceptCb);
- }, timeoutDuration * 1000);
- break;
- default:
- cb.apply(null, arguments);
- break;
- }
- }
- else {
- cb.apply(null, arguments);
- }
- };
- performOp(interceptCb);
- };
- CachedDropboxClient.prototype.getCachedInfo = function getCachedInfo (p) {
- return this._cache[p.toLowerCase()];
- };
- CachedDropboxClient.prototype.putCachedInfo = function putCachedInfo (p, cache) {
- this._cache[p.toLowerCase()] = cache;
- };
- CachedDropboxClient.prototype.deleteCachedInfo = function deleteCachedInfo (p) {
- delete this._cache[p.toLowerCase()];
- };
- CachedDropboxClient.prototype.getCachedDirInfo = function getCachedDirInfo (p) {
- var info = this.getCachedInfo(p);
- if (isDirInfo(info)) {
- return info;
- }
- else {
- return null;
- }
- };
- CachedDropboxClient.prototype.getCachedFileInfo = function getCachedFileInfo (p) {
- var info = this.getCachedInfo(p);
- if (isFileInfo(info)) {
- return info;
- }
- else {
- return null;
- }
- };
- CachedDropboxClient.prototype.updateCachedDirInfo = function updateCachedDirInfo (p, stat, contents) {
- if ( contents === void 0 ) contents = null;
-
- var cachedInfo = this.getCachedInfo(p);
- // Dropbox uses the *contentHash* property for directories.
- // Ignore stat objects w/o a contentHash defined; those actually exist!!!
- // (Example: readdir returns an array of stat objs; stat objs for dirs in that context have no contentHash)
- if (stat.contentHash !== null && (cachedInfo === undefined || cachedInfo.stat.contentHash !== stat.contentHash)) {
- this.putCachedInfo(p, {
- stat: stat,
- contents: contents
- });
- }
- };
- CachedDropboxClient.prototype.updateCachedFileInfo = function updateCachedFileInfo (p, stat, contents) {
- if ( contents === void 0 ) contents = null;
-
- var cachedInfo = this.getCachedInfo(p);
- // Dropbox uses the *versionTag* property for files.
- // Ignore stat objects w/o a versionTag defined.
- if (stat.versionTag !== null && (cachedInfo === undefined || cachedInfo.stat.versionTag !== stat.versionTag)) {
- this.putCachedInfo(p, {
- stat: stat,
- contents: contents
- });
- }
- };
- CachedDropboxClient.prototype.updateCachedInfo = function updateCachedInfo (p, stat, contents) {
- if ( contents === void 0 ) contents = null;
-
- if (stat.isFile && isArrayBuffer(contents)) {
- this.updateCachedFileInfo(p, stat, contents);
- }
- else if (stat.isFolder && Array.isArray(contents)) {
- this.updateCachedDirInfo(p, stat, contents);
- }
- };
- var DropboxFile = (function (PreloadFile$$1) {
- function DropboxFile(_fs, _path, _flag, _stat, contents) {
- PreloadFile$$1.call(this, _fs, _path, _flag, _stat, contents);
- }
-
- if ( PreloadFile$$1 ) DropboxFile.__proto__ = PreloadFile$$1;
- DropboxFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );
- DropboxFile.prototype.constructor = DropboxFile;
- DropboxFile.prototype.sync = function sync (cb) {
- var this$1 = this;
-
- if (this.isDirty()) {
- var buffer$$1 = this.getBuffer(), arrayBuffer = buffer2ArrayBuffer(buffer$$1);
- this._fs._writeFileStrict(this.getPath(), arrayBuffer, function (e) {
- if (!e) {
- this$1.resetDirty();
- }
- cb(e);
- });
- }
- else {
- cb();
- }
- };
- DropboxFile.prototype.close = function close (cb) {
- this.sync(cb);
- };
-
- return DropboxFile;
- }(PreloadFile));
- /**
- * A read/write file system backed by Dropbox cloud storage.
- *
- * Uses the Dropbox V1 API.
- *
- * NOTE: You must use the v0.10 version of the [Dropbox JavaScript SDK](https://www.npmjs.com/package/dropbox).
- */
- var DropboxFileSystem = (function (BaseFileSystem$$1) {
- function DropboxFileSystem(client, deprecateMsg) {
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- BaseFileSystem$$1.call(this);
- this._client = new CachedDropboxClient(client);
- deprecationMessage(deprecateMsg, DropboxFileSystem.Name, { client: "authenticated dropbox client instance" });
- constructErrorCodeLookup();
- }
-
- if ( BaseFileSystem$$1 ) DropboxFileSystem.__proto__ = BaseFileSystem$$1;
- DropboxFileSystem.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );
- DropboxFileSystem.prototype.constructor = DropboxFileSystem;
- /**
- * Creates a new DropboxFileSystem instance with the given options.
- * Must be given an *authenticated* DropboxJS client from the old v0.10 version of the Dropbox JS SDK.
- */
- DropboxFileSystem.Create = function Create (opts, cb) {
- cb(null, new DropboxFileSystem(opts.client, false));
- };
- DropboxFileSystem.isAvailable = function isAvailable () {
- // Checks if the Dropbox library is loaded.
- return typeof Dropbox !== 'undefined';
- };
- DropboxFileSystem.prototype.getName = function getName () {
- return DropboxFileSystem.Name;
- };
- DropboxFileSystem.prototype.isReadOnly = function isReadOnly () {
- return false;
- };
- // Dropbox doesn't support symlinks, properties, or synchronous calls
- DropboxFileSystem.prototype.supportsSymlinks = function supportsSymlinks () {
- return false;
- };
- DropboxFileSystem.prototype.supportsProps = function supportsProps () {
- return false;
- };
- DropboxFileSystem.prototype.supportsSynch = function supportsSynch () {
- return false;
- };
- DropboxFileSystem.prototype.empty = function empty (mainCb) {
- var this$1 = this;
-
- this._client.readdir('/', function (error, files) {
- if (error) {
- mainCb(this$1.convert(error, '/'));
- }
- else {
- var deleteFile = function (file, cb) {
- var p = path.join('/', file);
- this$1._client.remove(p, function (err) {
- cb(err ? this$1.convert(err, p) : null);
- });
- };
- var finished = function (err) {
- if (err) {
- mainCb(err);
- }
- else {
- mainCb();
- }
- };
- // XXX: typing is to get around overly-restrictive ErrorCallback typing.
- eachLimit(files, deleteFile, finished);
- }
- });
- };
- DropboxFileSystem.prototype.rename = function rename (oldPath, newPath, cb) {
- var this$1 = this;
-
- this._client.move(oldPath, newPath, function (error) {
- if (error) {
- // the move is permitted if newPath is a file.
- // Check if this is the case, and remove if so.
- this$1._client.stat(newPath, function (error2, stat) {
- if (error2 || stat.isFolder) {
- var missingPath = error.response.error.indexOf(oldPath) > -1 ? oldPath : newPath;
- cb(this$1.convert(error, missingPath));
- }
- else {
- // Delete file, repeat rename.
- this$1._client.remove(newPath, function (error2) {
- if (error2) {
- cb(this$1.convert(error2, newPath));
- }
- else {
- this$1.rename(oldPath, newPath, cb);
- }
- });
- }
- });
- }
- else {
- cb();
- }
- });
- };
- DropboxFileSystem.prototype.stat = function stat (path$$1, isLstat, cb) {
- var this$1 = this;
-
- // Ignore lstat case -- Dropbox doesn't support symlinks
- // Stat the file
- this._client.stat(path$$1, function (error, stat) {
- if (error) {
- cb(this$1.convert(error, path$$1));
- }
- else if (stat && stat.isRemoved) {
- // Dropbox keeps track of deleted files, so if a file has existed in the
- // past but doesn't any longer, you wont get an error
- cb(ApiError.FileError(ErrorCode.ENOENT, path$$1));
- }
- else {
- var stats = new Stats(this$1._statType(stat), stat.size);
- return cb(null, stats);
- }
- });
- };
- DropboxFileSystem.prototype.open = function open (path$$1, flags, mode, cb) {
- var this$1 = this;
-
- // Try and get the file's contents
- this._client.readFile(path$$1, function (error, content, dbStat) {
- if (error) {
- // If the file's being opened for reading and doesn't exist, return an
- // error
- if (flags.isReadable()) {
- cb(this$1.convert(error, path$$1));
- }
- else {
- switch (error.status) {
- // If it's being opened for writing or appending, create it so that
- // it can be written to
- case Dropbox.ApiError.NOT_FOUND:
- var ab = new ArrayBuffer(0);
- return this$1._writeFileStrict(path$$1, ab, function (error2, stat) {
- if (error2) {
- cb(error2);
- }
- else {
- var file = this$1._makeFile(path$$1, flags, stat, arrayBuffer2Buffer(ab));
- cb(null, file);
- }
- });
- default:
- return cb(this$1.convert(error, path$$1));
- }
- }
- }
- else {
- // No error
- var buffer$$1;
- // Dropbox.js seems to set `content` to `null` rather than to an empty
- // buffer when reading an empty file. Not sure why this is.
- if (content === null) {
- buffer$$1 = emptyBuffer();
- }
- else {
- buffer$$1 = arrayBuffer2Buffer(content);
- }
- var file = this$1._makeFile(path$$1, flags, dbStat, buffer$$1);
- return cb(null, file);
- }
- });
- };
- DropboxFileSystem.prototype._writeFileStrict = function _writeFileStrict (p, data, cb) {
- var this$1 = this;
-
- var parent = path.dirname(p);
- this.stat(parent, false, function (error, stat) {
- if (error) {
- cb(ApiError.FileError(ErrorCode.ENOENT, parent));
- }
- else {
- this$1._client.writeFile(p, data, function (error2, stat) {
- if (error2) {
- cb(this$1.convert(error2, p));
- }
- else {
- cb(null, stat);
- }
- });
- }
- });
- };
- /**
- * Private
- * Returns a BrowserFS object representing the type of a Dropbox.js stat object
- */
- DropboxFileSystem.prototype._statType = function _statType (stat) {
- return stat.isFile ? FileType.FILE : FileType.DIRECTORY;
- };
- /**
- * Private
- * Returns a BrowserFS object representing a File, created from the data
- * returned by calls to the Dropbox API.
- */
- DropboxFileSystem.prototype._makeFile = function _makeFile (path$$1, flag, stat, buffer$$1) {
- var type = this._statType(stat);
- var stats = new Stats(type, stat.size);
- return new DropboxFile(this, path$$1, flag, stats, buffer$$1);
- };
- /**
- * Private
- * Delete a file or directory from Dropbox
- * isFile should reflect which call was made to remove the it (`unlink` or
- * `rmdir`). If this doesn't match what's actually at `path`, an error will be
- * returned
- */
- DropboxFileSystem.prototype._remove = function _remove (path$$1, cb, isFile) {
- var this$1 = this;
-
- this._client.stat(path$$1, function (error, stat) {
- if (error) {
- cb(this$1.convert(error, path$$1));
- }
- else {
- if (stat.isFile && !isFile) {
- cb(ApiError.FileError(ErrorCode.ENOTDIR, path$$1));
- }
- else if (!stat.isFile && isFile) {
- cb(ApiError.FileError(ErrorCode.EISDIR, path$$1));
- }
- else {
- this$1._client.remove(path$$1, function (error) {
- if (error) {
- cb(this$1.convert(error, path$$1));
- }
- else {
- cb(null);
- }
- });
- }
- }
- });
- };
- /**
- * Delete a file
- */
- DropboxFileSystem.prototype.unlink = function unlink (path$$1, cb) {
- this._remove(path$$1, cb, true);
- };
- /**
- * Delete a directory
- */
- DropboxFileSystem.prototype.rmdir = function rmdir (path$$1, cb) {
- this._remove(path$$1, cb, false);
- };
- /**
- * Create a directory
- */
- DropboxFileSystem.prototype.mkdir = function mkdir (p, mode, cb) {
- var this$1 = this;
-
- // Dropbox.js' client.mkdir() behaves like `mkdir -p`, i.e. it creates a
- // directory and all its ancestors if they don't exist.
- // Node's fs.mkdir() behaves like `mkdir`, i.e. it throws an error if an attempt
- // is made to create a directory without a parent.
- // To handle this inconsistency, a check for the existence of `path`'s parent
- // must be performed before it is created, and an error thrown if it does
- // not exist
- var parent = path.dirname(p);
- this._client.stat(parent, function (error, stat) {
- if (error) {
- cb(this$1.convert(error, parent));
- }
- else {
- this$1._client.mkdir(p, function (error) {
- if (error) {
- cb(ApiError.FileError(ErrorCode.EEXIST, p));
- }
- else {
- cb(null);
- }
- });
- }
- });
- };
- /**
- * Get the names of the files in a directory
- */
- DropboxFileSystem.prototype.readdir = function readdir (path$$1, cb) {
- var this$1 = this;
-
- this._client.readdir(path$$1, function (error, files) {
- if (error) {
- return cb(this$1.convert(error));
- }
- else {
- return cb(null, files);
- }
- });
- };
- /**
- * Converts a Dropbox-JS error into a BFS error.
- */
- DropboxFileSystem.prototype.convert = function convert (err, path$$1) {
- if ( path$$1 === void 0 ) path$$1 = null;
-
- var errorCode = errorCodeLookup[err.status];
- if (errorCode === undefined) {
- errorCode = ErrorCode.EIO;
- }
- if (!path$$1) {
- return new ApiError(errorCode);
- }
- else {
- return ApiError.FileError(errorCode, path$$1);
- }
- };
-
- return DropboxFileSystem;
- }(BaseFileSystem));
-
- DropboxFileSystem.Name = "Dropbox";
- DropboxFileSystem.Options = {
- client: {
- type: "object",
- description: "An *authenticated* Dropbox client. Must be from the 0.10 JS SDK.",
- validator: function (opt, cb) {
- if (opt.isAuthenticated && opt.isAuthenticated()) {
- cb();
- }
- else {
- cb(new ApiError(ErrorCode.EINVAL, "'client' option must be an authenticated Dropbox client from the v0.10 JS SDK."));
- }
- }
- }
- };
-
- /**
- * @hidden
- */
- function convertError(e, path$$1) {
- if ( path$$1 === void 0 ) path$$1 = '';
-
- var errno = e.errno;
- var parent = e.node;
- var paths = [];
- while (parent) {
- paths.unshift(parent.name);
- if (parent === parent.parent) {
- break;
- }
- parent = parent.parent;
- }
- return new ApiError(errno, ErrorStrings[errno], paths.length > 0 ? '/' + paths.join('/') : path$$1);
- }
- var EmscriptenFile = (function (BaseFile$$1) {
- function EmscriptenFile(_fs, _FS, _path, _stream) {
- BaseFile$$1.call(this);
- this._fs = _fs;
- this._FS = _FS;
- this._path = _path;
- this._stream = _stream;
- }
-
- if ( BaseFile$$1 ) EmscriptenFile.__proto__ = BaseFile$$1;
- EmscriptenFile.prototype = Object.create( BaseFile$$1 && BaseFile$$1.prototype );
- EmscriptenFile.prototype.constructor = EmscriptenFile;
- EmscriptenFile.prototype.getPos = function getPos () {
- return undefined;
- };
- EmscriptenFile.prototype.close = function close (cb) {
- var err = null;
- try {
- this.closeSync();
- }
- catch (e) {
- err = e;
- }
- finally {
- cb(err);
- }
- };
- EmscriptenFile.prototype.closeSync = function closeSync () {
- try {
- this._FS.close(this._stream);
- }
- catch (e) {
- throw convertError(e, this._path);
- }
- };
- EmscriptenFile.prototype.stat = function stat (cb) {
- try {
- cb(null, this.statSync());
- }
- catch (e) {
- cb(e);
- }
- };
- EmscriptenFile.prototype.statSync = function statSync () {
- try {
- return this._fs.statSync(this._path, false);
- }
- catch (e) {
- throw convertError(e, this._path);
- }
- };
- EmscriptenFile.prototype.truncate = function truncate (len, cb) {
- var err = null;
- try {
- this.truncateSync(len);
- }
- catch (e) {
- err = e;
- }
- finally {
- cb(err);
- }
- };
- EmscriptenFile.prototype.truncateSync = function truncateSync (len) {
- try {
- this._FS.ftruncate(this._stream.fd, len);
- }
- catch (e) {
- throw convertError(e, this._path);
- }
- };
- EmscriptenFile.prototype.write = function write (buffer$$1, offset, length, position, cb) {
- try {
- cb(null, this.writeSync(buffer$$1, offset, length, position), buffer$$1);
- }
- catch (e) {
- cb(e);
- }
- };
- EmscriptenFile.prototype.writeSync = function writeSync (buffer$$1, offset, length, position) {
- try {
- var u8 = buffer2Uint8array(buffer$$1);
- // Emscripten is particular about what position is set to.
- var emPosition = position === null ? undefined : position;
- return this._FS.write(this._stream, u8, offset, length, emPosition);
- }
- catch (e) {
- throw convertError(e, this._path);
- }
- };
- EmscriptenFile.prototype.read = function read (buffer$$1, offset, length, position, cb) {
- try {
- cb(null, this.readSync(buffer$$1, offset, length, position), buffer$$1);
- }
- catch (e) {
- cb(e);
- }
- };
- EmscriptenFile.prototype.readSync = function readSync (buffer$$1, offset, length, position) {
- try {
- var u8 = buffer2Uint8array(buffer$$1);
- // Emscripten is particular about what position is set to.
- var emPosition = position === null ? undefined : position;
- return this._FS.read(this._stream, u8, offset, length, emPosition);
- }
- catch (e) {
- throw convertError(e, this._path);
- }
- };
- EmscriptenFile.prototype.sync = function sync (cb) {
- // NOP.
- cb();
- };
- EmscriptenFile.prototype.syncSync = function syncSync () {
- // NOP.
- };
- EmscriptenFile.prototype.chown = function chown (uid, gid, cb) {
- var err = null;
- try {
- this.chownSync(uid, gid);
- }
- catch (e) {
- err = e;
- }
- finally {
- cb(err);
- }
- };
- EmscriptenFile.prototype.chownSync = function chownSync (uid, gid) {
- try {
- this._FS.fchown(this._stream.fd, uid, gid);
- }
- catch (e) {
- throw convertError(e, this._path);
- }
- };
- EmscriptenFile.prototype.chmod = function chmod (mode, cb) {
- var err = null;
- try {
- this.chmodSync(mode);
- }
- catch (e) {
- err = e;
- }
- finally {
- cb(err);
- }
- };
- EmscriptenFile.prototype.chmodSync = function chmodSync (mode) {
- try {
- this._FS.fchmod(this._stream.fd, mode);
- }
- catch (e) {
- throw convertError(e, this._path);
- }
- };
- EmscriptenFile.prototype.utimes = function utimes (atime, mtime, cb) {
- var err = null;
- try {
- this.utimesSync(atime, mtime);
- }
- catch (e) {
- err = e;
- }
- finally {
- cb(err);
- }
- };
- EmscriptenFile.prototype.utimesSync = function utimesSync (atime, mtime) {
- this._fs.utimesSync(this._path, atime, mtime);
- };
-
- return EmscriptenFile;
- }(BaseFile));
- /**
- * Mounts an Emscripten file system into the BrowserFS file system.
- */
- var EmscriptenFileSystem = (function (SynchronousFileSystem$$1) {
- function EmscriptenFileSystem(_FS) {
- SynchronousFileSystem$$1.call(this);
- this._FS = _FS;
- }
-
- if ( SynchronousFileSystem$$1 ) EmscriptenFileSystem.__proto__ = SynchronousFileSystem$$1;
- EmscriptenFileSystem.prototype = Object.create( SynchronousFileSystem$$1 && SynchronousFileSystem$$1.prototype );
- EmscriptenFileSystem.prototype.constructor = EmscriptenFileSystem;
- /**
- * Create an EmscriptenFileSystem instance with the given options.
- */
- EmscriptenFileSystem.Create = function Create (opts, cb) {
- cb(null, new EmscriptenFileSystem(opts.FS));
- };
- EmscriptenFileSystem.isAvailable = function isAvailable () { return true; };
- EmscriptenFileSystem.prototype.getName = function getName () { return this._FS.DB_NAME(); };
- EmscriptenFileSystem.prototype.isReadOnly = function isReadOnly () { return false; };
- EmscriptenFileSystem.prototype.supportsLinks = function supportsLinks () { return true; };
- EmscriptenFileSystem.prototype.supportsProps = function supportsProps () { return true; };
- EmscriptenFileSystem.prototype.supportsSynch = function supportsSynch () { return true; };
- EmscriptenFileSystem.prototype.renameSync = function renameSync (oldPath, newPath) {
- try {
- this._FS.rename(oldPath, newPath);
- }
- catch (e) {
- if (e.errno === ErrorCode.ENOENT) {
- throw convertError(e, this.existsSync(oldPath) ? newPath : oldPath);
- }
- else {
- throw convertError(e);
- }
- }
- };
- EmscriptenFileSystem.prototype.statSync = function statSync (p, isLstat) {
- try {
- var stats = isLstat ? this._FS.lstat(p) : this._FS.stat(p);
- var itemType = this.modeToFileType(stats.mode);
- return new Stats(itemType, stats.size, stats.mode, stats.atime, stats.mtime, stats.ctime);
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.openSync = function openSync (p, flag, mode) {
- try {
- var stream = this._FS.open(p, flag.getFlagString(), mode);
- if (this._FS.isDir(stream.node.mode)) {
- this._FS.close(stream);
- throw ApiError.EISDIR(p);
- }
- return new EmscriptenFile(this, this._FS, p, stream);
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.unlinkSync = function unlinkSync (p) {
- try {
- this._FS.unlink(p);
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.rmdirSync = function rmdirSync (p) {
- try {
- this._FS.rmdir(p);
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.mkdirSync = function mkdirSync (p, mode) {
- try {
- this._FS.mkdir(p, mode);
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.readdirSync = function readdirSync (p) {
- try {
- // Emscripten returns items for '.' and '..'. Node does not.
- return this._FS.readdir(p).filter(function (p) { return p !== '.' && p !== '..'; });
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.truncateSync = function truncateSync (p, len) {
- try {
- this._FS.truncate(p, len);
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.readFileSync = function readFileSync (p, encoding, flag) {
- try {
- var data = this._FS.readFile(p, { flags: flag.getFlagString() });
- var buff = uint8Array2Buffer(data);
- if (encoding) {
- return buff.toString(encoding);
- }
- else {
- return buff;
- }
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.writeFileSync = function writeFileSync (p, data, encoding, flag, mode) {
- try {
- if (encoding) {
- data = Buffer.from(data, encoding);
- }
- var u8 = buffer2Uint8array(data);
- this._FS.writeFile(p, u8, { flags: flag.getFlagString(), encoding: 'binary' });
- this._FS.chmod(p, mode);
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.chmodSync = function chmodSync (p, isLchmod, mode) {
- try {
- isLchmod ? this._FS.lchmod(p, mode) : this._FS.chmod(p, mode);
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.chownSync = function chownSync (p, isLchown, uid, gid) {
- try {
- isLchown ? this._FS.lchown(p, uid, gid) : this._FS.chown(p, uid, gid);
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.symlinkSync = function symlinkSync (srcpath, dstpath, type) {
- try {
- this._FS.symlink(srcpath, dstpath);
- }
- catch (e) {
- throw convertError(e);
- }
- };
- EmscriptenFileSystem.prototype.readlinkSync = function readlinkSync (p) {
- try {
- return this._FS.readlink(p);
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.utimesSync = function utimesSync (p, atime, mtime) {
- try {
- this._FS.utime(p, atime.getTime(), mtime.getTime());
- }
- catch (e) {
- throw convertError(e, p);
- }
- };
- EmscriptenFileSystem.prototype.modeToFileType = function modeToFileType (mode) {
- if (this._FS.isDir(mode)) {
- return FileType.DIRECTORY;
- }
- else if (this._FS.isFile(mode)) {
- return FileType.FILE;
- }
- else if (this._FS.isLink(mode)) {
- return FileType.SYMLINK;
- }
- else {
- throw ApiError.EPERM(("Invalid mode: " + mode));
- }
- };
-
- return EmscriptenFileSystem;
- }(SynchronousFileSystem));
-
- EmscriptenFileSystem.Name = "EmscriptenFileSystem";
- EmscriptenFileSystem.Options = {
- FS: {
- type: "object",
- description: "The Emscripten file system to use (the `FS` variable)"
- }
- };
-
- /**
- * The FolderAdapter file system wraps a file system, and scopes all interactions to a subfolder of that file system.
- *
- * Example: Given a file system `foo` with folder `bar` and file `bar/baz`...
- *
- * ```javascript
- * BrowserFS.configure({
- * fs: "FolderAdapter",
- * options: {
- * folder: "bar",
- * wrapped: foo
- * }
- * }, function(e) {
- * var fs = BrowserFS.BFSRequire('fs');
- * fs.readdirSync('/'); // ['baz']
- * });
- * ```
- */
- var FolderAdapter = (function (BaseFileSystem$$1) {
- function FolderAdapter(folder, wrapped) {
- BaseFileSystem$$1.call(this);
- this._folder = folder;
- this._wrapped = wrapped;
- }
-
- if ( BaseFileSystem$$1 ) FolderAdapter.__proto__ = BaseFileSystem$$1;
- FolderAdapter.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );
- FolderAdapter.prototype.constructor = FolderAdapter;
- /**
- * Creates a FolderAdapter instance with the given options.
- */
- FolderAdapter.Create = function Create (opts, cb) {
- cb(null, new FolderAdapter(opts.folder, opts.wrapped));
- };
- FolderAdapter.isAvailable = function isAvailable () {
- return true;
- };
- /**
- * Initialize the file system. Ensures that the wrapped file system
- * has the given folder.
- */
- FolderAdapter.prototype.initialize = function initialize (cb) {
- var this$1 = this;
-
- this._wrapped.exists(this._folder, function (exists) {
- if (exists) {
- cb();
- }
- else if (this$1._wrapped.isReadOnly()) {
- cb(ApiError.ENOENT(this$1._folder));
- }
- else {
- this$1._wrapped.mkdir(this$1._folder, 0x1ff, cb);
- }
- });
- };
- FolderAdapter.prototype.getName = function getName () { return this._wrapped.getName(); };
- FolderAdapter.prototype.isReadOnly = function isReadOnly () { return this._wrapped.isReadOnly(); };
- FolderAdapter.prototype.supportsProps = function supportsProps () { return this._wrapped.supportsProps(); };
- FolderAdapter.prototype.supportsSynch = function supportsSynch () { return this._wrapped.supportsSynch(); };
- FolderAdapter.prototype.supportsLinks = function supportsLinks () { return false; };
-
- return FolderAdapter;
- }(BaseFileSystem));
-
- FolderAdapter.Name = "FolderAdapter";
- FolderAdapter.Options = {
- folder: {
- type: "string",
- description: "The folder to use as the root directory"
- },
- wrapped: {
- type: "object",
- description: "The file system to wrap"
- }
- };
- /**
- * @hidden
- */
- function translateError(folder, e) {
- if (e !== null && typeof e === 'object') {
- var err = e;
- var p = err.path;
- if (p) {
- p = '/' + path.relative(folder, p);
- err.message = err.message.replace(err.path, p);
- err.path = p;
- }
- }
- return e;
- }
- /**
- * @hidden
- */
- function wrapCallback(folder, cb) {
- if (typeof cb === 'function') {
- return function (err) {
- if (arguments.length > 0) {
- arguments[0] = translateError(folder, err);
- }
- cb.apply(null, arguments);
- };
- }
- else {
- return cb;
- }
- }
- /**
- * @hidden
- */
- function wrapFunction(name, wrapFirst, wrapSecond) {
- if (name.slice(name.length - 4) !== 'Sync') {
- // Async function. Translate error in callback.
- return function () {
- if (arguments.length > 0) {
- if (wrapFirst) {
- arguments[0] = path.join(this._folder, arguments[0]);
- }
- if (wrapSecond) {
- arguments[1] = path.join(this._folder, arguments[1]);
- }
- arguments[arguments.length - 1] = wrapCallback(this._folder, arguments[arguments.length - 1]);
- }
- return this._wrapped[name].apply(this._wrapped, arguments);
- };
- }
- else {
- // Sync function. Translate error in catch.
- return function () {
- try {
- if (wrapFirst) {
- arguments[0] = path.join(this._folder, arguments[0]);
- }
- if (wrapSecond) {
- arguments[1] = path.join(this._folder, arguments[1]);
- }
- return this._wrapped[name].apply(this._wrapped, arguments);
- }
- catch (e) {
- throw translateError(this._folder, e);
- }
- };
- }
- }
- // First argument is a path.
- ['diskSpace', 'stat', 'statSync', 'open', 'openSync', 'unlink', 'unlinkSync',
- 'rmdir', 'rmdirSync', 'mkdir', 'mkdirSync', 'readdir', 'readdirSync', 'exists',
- 'existsSync', 'realpath', 'realpathSync', 'truncate', 'truncateSync', 'readFile',
- 'readFileSync', 'writeFile', 'writeFileSync', 'appendFile', 'appendFileSync',
- 'chmod', 'chmodSync', 'chown', 'chownSync', 'utimes', 'utimesSync', 'readlink',
- 'readlinkSync'].forEach(function (name) {
- FolderAdapter.prototype[name] = wrapFunction(name, true, false);
- });
- // First and second arguments are paths.
- ['rename', 'renameSync', 'link', 'linkSync', 'symlink', 'symlinkSync'].forEach(function (name) {
- FolderAdapter.prototype[name] = wrapFunction(name, true, true);
- });
-
- /**
- * @hidden
- */
- var toExport;
- if (typeof (window) !== 'undefined') {
- toExport = window;
- }
- else if (typeof (self) !== 'undefined') {
- toExport = self;
- }
- else {
- toExport = global;
- }
- var global$1 = toExport;
-
- /**
- * @hidden
- */
- function isDirectoryEntry(entry) {
- return entry.isDirectory;
- }
- /**
- * @hidden
- */
- var _getFS = global$1.webkitRequestFileSystem || global$1.requestFileSystem || null;
- /**
- * @hidden
- */
- function _requestQuota(type, size, success, errorCallback) {
- // We cast navigator and window to '' because everything here is
- // nonstandard functionality, despite the fact that Chrome has the only
- // implementation of the HTML5FS and is likely driving the standardization
- // process. Thus, these objects defined off of navigator and window are not
- // present in the DefinitelyTyped TypeScript typings for FileSystem.
- if (typeof navigator['webkitPersistentStorage'] !== 'undefined') {
- switch (type) {
- case global$1.PERSISTENT:
- navigator.webkitPersistentStorage.requestQuota(size, success, errorCallback);
- break;
- case global$1.TEMPORARY:
- navigator.webkitTemporaryStorage.requestQuota(size, success, errorCallback);
- break;
- default:
- errorCallback(new TypeError(("Invalid storage type: " + type)));
- break;
- }
- }
- else {
- global$1.webkitStorageInfo.requestQuota(type, size, success, errorCallback);
- }
- }
- /**
- * @hidden
- */
- function _toArray(list) {
- return Array.prototype.slice.call(list || [], 0);
- }
- /**
- * Converts the given DOMError into an appropriate ApiError.
- * @url https://developer.mozilla.org/en-US/docs/Web/API/DOMError
- * @hidden
- */
- function convertError$1(err, p, expectedDir) {
- switch (err.name) {
- /* The user agent failed to create a file or directory due to the existence of a file or
- directory with the same path. */
- case "PathExistsError":
- return ApiError.EEXIST(p);
- /* The operation failed because it would cause the application to exceed its storage quota. */
- case 'QuotaExceededError':
- return ApiError.FileError(ErrorCode.ENOSPC, p);
- /* A required file or directory could not be found at the time an operation was processed. */
- case 'NotFoundError':
- return ApiError.ENOENT(p);
- /* This is a security error code to be used in situations not covered by any other error codes.
- - A required file was unsafe for access within a Web application
- - Too many calls are being made on filesystem resources */
- case 'SecurityError':
- return ApiError.FileError(ErrorCode.EACCES, p);
- /* The modification requested was illegal. Examples of invalid modifications include moving a
- directory into its own child, moving a file into its parent directory without changing its name,
- or copying a directory to a path occupied by a file. */
- case 'InvalidModificationError':
- return ApiError.FileError(ErrorCode.EPERM, p);
- /* The user has attempted to look up a file or directory, but the Entry found is of the wrong type
- [e.g. is a DirectoryEntry when the user requested a FileEntry]. */
- case 'TypeMismatchError':
- return ApiError.FileError(expectedDir ? ErrorCode.ENOTDIR : ErrorCode.EISDIR, p);
- /* A path or URL supplied to the API was malformed. */
- case "EncodingError":
- /* An operation depended on state cached in an interface object, but that state that has changed
- since it was read from disk. */
- case "InvalidStateError":
- /* The user attempted to write to a file or directory which could not be modified due to the state
- of the underlying filesystem. */
- case "NoModificationAllowedError":
- default:
- return ApiError.FileError(ErrorCode.EINVAL, p);
- }
- }
- // A note about getFile and getDirectory options:
- // These methods are called at numerous places in this file, and are passed
- // some combination of these two options:
- // - create: If true, the entry will be created if it doesn't exist.
- // If false, an error will be thrown if it doesn't exist.
- // - exclusive: If true, only create the entry if it doesn't already exist,
- // and throw an error if it does.
- var HTML5FSFile = (function (PreloadFile$$1) {
- function HTML5FSFile(fs, entry, path$$1, flag, stat, contents) {
- PreloadFile$$1.call(this, fs, path$$1, flag, stat, contents);
- this._entry = entry;
- }
-
- if ( PreloadFile$$1 ) HTML5FSFile.__proto__ = PreloadFile$$1;
- HTML5FSFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );
- HTML5FSFile.prototype.constructor = HTML5FSFile;
- HTML5FSFile.prototype.sync = function sync (cb) {
- var this$1 = this;
-
- if (!this.isDirty()) {
- return cb();
- }
- this._entry.createWriter(function (writer) {
- var buffer$$1 = this$1.getBuffer();
- var blob = new Blob([buffer2ArrayBuffer(buffer$$1)]);
- var length = blob.size;
- writer.onwriteend = function (err) {
- writer.onwriteend = null;
- writer.onerror = null;
- writer.truncate(length);
- this$1.resetDirty();
- cb();
- };
- writer.onerror = function (err) {
- cb(convertError$1(err, this$1.getPath(), false));
- };
- writer.write(blob);
- });
- };
- HTML5FSFile.prototype.close = function close (cb) {
- this.sync(cb);
- };
-
- return HTML5FSFile;
- }(PreloadFile));
- /**
- * A read-write filesystem backed by the HTML5 FileSystem API.
- *
- * As the HTML5 FileSystem is only implemented in Blink, this interface is
- * only available in Chrome.
- */
- var HTML5FS = (function (BaseFileSystem$$1) {
- function HTML5FS(size, type, deprecateMsg) {
- if ( size === void 0 ) size = 5;
- if ( type === void 0 ) type = global$1.PERSISTENT;
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- BaseFileSystem$$1.call(this);
- // Convert MB to bytes.
- this.size = 1024 * 1024 * size;
- this.type = type;
- deprecationMessage(deprecateMsg, HTML5FS.Name, { size: size, type: type });
- }
-
- if ( BaseFileSystem$$1 ) HTML5FS.__proto__ = BaseFileSystem$$1;
- HTML5FS.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );
- HTML5FS.prototype.constructor = HTML5FS;
- /**
- * Creates an HTML5FS instance with the given options.
- */
- HTML5FS.Create = function Create (opts, cb) {
- var fs = new HTML5FS(opts.size, opts.type, false);
- fs.allocate(function (e) { return e ? cb(e) : cb(null, fs); }, false);
- };
- HTML5FS.isAvailable = function isAvailable () {
- return !!_getFS;
- };
- HTML5FS.prototype.getName = function getName () {
- return HTML5FS.Name;
- };
- HTML5FS.prototype.isReadOnly = function isReadOnly () {
- return false;
- };
- HTML5FS.prototype.supportsSymlinks = function supportsSymlinks () {
- return false;
- };
- HTML5FS.prototype.supportsProps = function supportsProps () {
- return false;
- };
- HTML5FS.prototype.supportsSynch = function supportsSynch () {
- return false;
- };
- /**
- * **Deprecated. Please use Create() method instead to create and allocate an HTML5FS.**
- *
- * Requests a storage quota from the browser to back this FS.
- * Must be called before file system can be used!
- */
- HTML5FS.prototype.allocate = function allocate (cb, deprecateMsg) {
- var this$1 = this;
- if ( cb === void 0 ) cb = function () { };
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- if (deprecateMsg) {
- console.warn(("[HTML5FS] HTML5FS.allocate() is deprecated and will be removed in the next major release. Please use 'HTML5FS.Create({type: " + (this.type) + ", size: " + (this.size) + "}, cb)' to create and allocate HTML5FS instances."));
- }
- var success = function (fs) {
- this$1.fs = fs;
- cb();
- };
- var error = function (err) {
- cb(convertError$1(err, "/", true));
- };
- if (this.type === global$1.PERSISTENT) {
- _requestQuota(this.type, this.size, function (granted) {
- _getFS(this$1.type, granted, success, error);
- }, error);
- }
- else {
- _getFS(this.type, this.size, success, error);
- }
- };
- /**
- * Deletes everything in the FS. Used for testing.
- * Karma clears the storage after you quit it but not between runs of the test
- * suite, and the tests expect an empty FS every time.
- */
- HTML5FS.prototype.empty = function empty (mainCb) {
- // Get a list of all entries in the root directory to delete them
- this._readdir('/', function (err, entries) {
- if (err) {
- console.error('Failed to empty FS');
- mainCb(err);
- }
- else {
- // Called when every entry has been operated on
- var finished = function (er) {
- if (err) {
- console.error("Failed to empty FS");
- mainCb(err);
- }
- else {
- mainCb();
- }
- };
- // Removes files and recursively removes directories
- var deleteEntry = function (entry, cb) {
- var succ = function () {
- cb();
- };
- var error = function (err) {
- cb(convertError$1(err, entry.fullPath, !entry.isDirectory));
- };
- if (isDirectoryEntry(entry)) {
- entry.removeRecursively(succ, error);
- }
- else {
- entry.remove(succ, error);
- }
- };
- // Loop through the entries and remove them, then call the callback
- // when they're all finished.
- eachLimit(entries, deleteEntry, finished);
- }
- });
- };
- HTML5FS.prototype.rename = function rename (oldPath, newPath, cb) {
- var this$1 = this;
-
- var semaphore = 2;
- var successCount = 0;
- var root = this.fs.root;
- var currentPath = oldPath;
- var error = function (err) {
- if (--semaphore <= 0) {
- cb(convertError$1(err, currentPath, false));
- }
- };
- var success = function (file) {
- if (++successCount === 2) {
- return cb(new ApiError(ErrorCode.EINVAL, "Something was identified as both a file and a directory. This should never happen."));
- }
- // SPECIAL CASE: If newPath === oldPath, and the path exists, then
- // this operation trivially succeeds.
- if (oldPath === newPath) {
- return cb();
- }
- // Get the new parent directory.
- currentPath = path.dirname(newPath);
- root.getDirectory(currentPath, {}, function (parentDir) {
- currentPath = path.basename(newPath);
- file.moveTo(parentDir, currentPath, function (entry) { cb(); }, function (err) {
- // SPECIAL CASE: If oldPath is a directory, and newPath is a
- // file, rename should delete the file and perform the move.
- if (file.isDirectory) {
- currentPath = newPath;
- // Unlink only works on files. Try to delete newPath.
- this$1.unlink(newPath, function (e) {
- if (e) {
- // newPath is probably a directory.
- error(err);
- }
- else {
- // Recur, now that newPath doesn't exist.
- this$1.rename(oldPath, newPath, cb);
- }
- });
- }
- else {
- error(err);
- }
- });
- }, error);
- };
- // We don't know if oldPath is a *file* or a *directory*, and there's no
- // way to stat items. So launch both requests, see which one succeeds.
- root.getFile(oldPath, {}, success, error);
- root.getDirectory(oldPath, {}, success, error);
- };
- HTML5FS.prototype.stat = function stat (path$$1, isLstat, cb) {
- var this$1 = this;
-
- // Throw an error if the entry doesn't exist, because then there's nothing
- // to stat.
- var opts = {
- create: false
- };
- // Called when the path has been successfully loaded as a file.
- var loadAsFile = function (entry) {
- var fileFromEntry = function (file) {
- var stat = new Stats(FileType.FILE, file.size);
- cb(null, stat);
- };
- entry.file(fileFromEntry, failedToLoad);
- };
- // Called when the path has been successfully loaded as a directory.
- var loadAsDir = function (dir$$1) {
- // Directory entry size can't be determined from the HTML5 FS API, and is
- // implementation-dependant anyway, so a dummy value is used.
- var size = 4096;
- var stat = new Stats(FileType.DIRECTORY, size);
- cb(null, stat);
- };
- // Called when the path couldn't be opened as a directory or a file.
- var failedToLoad = function (err) {
- cb(convertError$1(err, path$$1, false /* Unknown / irrelevant */));
- };
- // Called when the path couldn't be opened as a file, but might still be a
- // directory.
- var failedToLoadAsFile = function () {
- this$1.fs.root.getDirectory(path$$1, opts, loadAsDir, failedToLoad);
- };
- // No method currently exists to determine whether a path refers to a
- // directory or a file, so this implementation tries both and uses the first
- // one that succeeds.
- this.fs.root.getFile(path$$1, opts, loadAsFile, failedToLoadAsFile);
- };
- HTML5FS.prototype.open = function open (p, flags, mode, cb) {
- var this$1 = this;
-
- // XXX: err is a DOMError
- var error = function (err) {
- if (err.name === 'InvalidModificationError' && flags.isExclusive()) {
- cb(ApiError.EEXIST(p));
- }
- else {
- cb(convertError$1(err, p, false));
- }
- };
- this.fs.root.getFile(p, {
- create: flags.pathNotExistsAction() === ActionType.CREATE_FILE,
- exclusive: flags.isExclusive()
- }, function (entry) {
- // Try to fetch corresponding file.
- entry.file(function (file) {
- var reader = new FileReader();
- reader.onloadend = function (event) {
- var bfsFile = this$1._makeFile(p, entry, flags, file, reader.result);
- cb(null, bfsFile);
- };
- reader.onerror = function (ev) {
- error(reader.error);
- };
- reader.readAsArrayBuffer(file);
- }, error);
- }, error);
- };
- HTML5FS.prototype.unlink = function unlink (path$$1, cb) {
- this._remove(path$$1, cb, true);
- };
- HTML5FS.prototype.rmdir = function rmdir (path$$1, cb) {
- var this$1 = this;
-
- // Check if directory is non-empty, first.
- this.readdir(path$$1, function (e, files) {
- if (e) {
- cb(e);
- }
- else if (files.length > 0) {
- cb(ApiError.ENOTEMPTY(path$$1));
- }
- else {
- this$1._remove(path$$1, cb, false);
- }
- });
- };
- HTML5FS.prototype.mkdir = function mkdir (path$$1, mode, cb) {
- // Create the directory, but throw an error if it already exists, as per
- // mkdir(1)
- var opts = {
- create: true,
- exclusive: true
- };
- var success = function (dir$$1) {
- cb();
- };
- var error = function (err) {
- cb(convertError$1(err, path$$1, true));
- };
- this.fs.root.getDirectory(path$$1, opts, success, error);
- };
- /**
- * Map _readdir's list of `FileEntry`s to their names and return that.
- */
- HTML5FS.prototype.readdir = function readdir (path$$1, cb) {
- this._readdir(path$$1, function (e, entries) {
- if (entries) {
- var rv = [];
- for (var i = 0, list = entries; i < list.length; i += 1) {
- var entry = list[i];
-
- rv.push(entry.name);
- }
- cb(null, rv);
- }
- else {
- return cb(e);
- }
- });
- };
- /**
- * Returns a BrowserFS object representing a File.
- */
- HTML5FS.prototype._makeFile = function _makeFile (path$$1, entry, flag, stat, data) {
- if ( data === void 0 ) data = new ArrayBuffer(0);
-
- var stats = new Stats(FileType.FILE, stat.size);
- var buffer$$1 = arrayBuffer2Buffer(data);
- return new HTML5FSFile(this, entry, path$$1, flag, stats, buffer$$1);
- };
- /**
- * Returns an array of `FileEntry`s. Used internally by empty and readdir.
- */
- HTML5FS.prototype._readdir = function _readdir (path$$1, cb) {
- var error = function (err) {
- cb(convertError$1(err, path$$1, true));
- };
- // Grab the requested directory.
- this.fs.root.getDirectory(path$$1, { create: false }, function (dirEntry) {
- var reader = dirEntry.createReader();
- var entries = [];
- // Call the reader.readEntries() until no more results are returned.
- var readEntries = function () {
- reader.readEntries((function (results) {
- if (results.length) {
- entries = entries.concat(_toArray(results));
- readEntries();
- }
- else {
- cb(null, entries);
- }
- }), error);
- };
- readEntries();
- }, error);
- };
- /**
- * Delete a file or directory from the file system
- * isFile should reflect which call was made to remove the it (`unlink` or
- * `rmdir`). If this doesn't match what's actually at `path`, an error will be
- * returned
- */
- HTML5FS.prototype._remove = function _remove (path$$1, cb, isFile) {
- var success = function (entry) {
- var succ = function () {
- cb();
- };
- var err = function (err) {
- cb(convertError$1(err, path$$1, !isFile));
- };
- entry.remove(succ, err);
- };
- var error = function (err) {
- cb(convertError$1(err, path$$1, !isFile));
- };
- // Deleting the entry, so don't create it
- var opts = {
- create: false
- };
- if (isFile) {
- this.fs.root.getFile(path$$1, opts, success, error);
- }
- else {
- this.fs.root.getDirectory(path$$1, opts, success, error);
- }
- };
-
- return HTML5FS;
- }(BaseFileSystem));
-
- HTML5FS.Name = "HTML5FS";
- HTML5FS.Options = {
- size: {
- type: "number",
- optional: true,
- description: "Storage quota to request, in megabytes. Allocated value may be less. Defaults to 5."
- },
- type: {
- type: "number",
- optional: true,
- description: "window.PERSISTENT or window.TEMPORARY. Defaults to PERSISTENT."
- }
- };
-
- /**
- * Generic inode definition that can easily be serialized.
- */
- var Inode = function Inode(id, size, mode, atime, mtime, ctime) {
- this.id = id;
- this.size = size;
- this.mode = mode;
- this.atime = atime;
- this.mtime = mtime;
- this.ctime = ctime;
- };
- /**
- * Converts the buffer into an Inode.
- */
- Inode.fromBuffer = function fromBuffer (buffer$$1) {
- if (buffer$$1 === undefined) {
- throw new Error("NO");
- }
- return new Inode(buffer$$1.toString('ascii', 30), buffer$$1.readUInt32LE(0), buffer$$1.readUInt16LE(4), buffer$$1.readDoubleLE(6), buffer$$1.readDoubleLE(14), buffer$$1.readDoubleLE(22));
- };
- /**
- * Handy function that converts the Inode to a Node Stats object.
- */
- Inode.prototype.toStats = function toStats () {
- return new Stats((this.mode & 0xF000) === FileType.DIRECTORY ? FileType.DIRECTORY : FileType.FILE, this.size, this.mode, new Date(this.atime), new Date(this.mtime), new Date(this.ctime));
- };
- /**
- * Get the size of this Inode, in bytes.
- */
- Inode.prototype.getSize = function getSize () {
- // ASSUMPTION: ID is ASCII (1 byte per char).
- return 30 + this.id.length;
- };
- /**
- * Writes the inode into the start of the buffer.
- */
- Inode.prototype.toBuffer = function toBuffer (buff) {
- if ( buff === void 0 ) buff = Buffer.alloc(this.getSize());
-
- buff.writeUInt32LE(this.size, 0);
- buff.writeUInt16LE(this.mode, 4);
- buff.writeDoubleLE(this.atime, 6);
- buff.writeDoubleLE(this.mtime, 14);
- buff.writeDoubleLE(this.ctime, 22);
- buff.write(this.id, 30, this.id.length, 'ascii');
- return buff;
- };
- /**
- * Updates the Inode using information from the stats object. Used by file
- * systems at sync time, e.g.:
- * - Program opens file and gets a File object.
- * - Program mutates file. File object is responsible for maintaining
- * metadata changes locally -- typically in a Stats object.
- * - Program closes file. File object's metadata changes are synced with the
- * file system.
- * @return True if any changes have occurred.
- */
- Inode.prototype.update = function update (stats) {
- var hasChanged = false;
- if (this.size !== stats.size) {
- this.size = stats.size;
- hasChanged = true;
- }
- if (this.mode !== stats.mode) {
- this.mode = stats.mode;
- hasChanged = true;
- }
- var atimeMs = stats.atime.getTime();
- if (this.atime !== atimeMs) {
- this.atime = atimeMs;
- hasChanged = true;
- }
- var mtimeMs = stats.mtime.getTime();
- if (this.mtime !== mtimeMs) {
- this.mtime = mtimeMs;
- hasChanged = true;
- }
- var ctimeMs = stats.ctime.getTime();
- if (this.ctime !== ctimeMs) {
- this.ctime = ctimeMs;
- hasChanged = true;
- }
- return hasChanged;
- };
- // XXX: Copied from Stats. Should reconcile these two into something more
- // compact.
- /**
- * @return [Boolean] True if this item is a file.
- */
- Inode.prototype.isFile = function isFile () {
- return (this.mode & 0xF000) === FileType.FILE;
- };
- /**
- * @return [Boolean] True if this item is a directory.
- */
- Inode.prototype.isDirectory = function isDirectory () {
- return (this.mode & 0xF000) === FileType.DIRECTORY;
- };
-
- /**
- * @hidden
- */
- var ROOT_NODE_ID = "/";
- /**
- * @hidden
- */
- var emptyDirNode = null;
- /**
- * Returns an empty directory node.
- * @hidden
- */
- function getEmptyDirNode() {
- if (emptyDirNode) {
- return emptyDirNode;
- }
- return emptyDirNode = Buffer.from("{}");
- }
- /**
- * Generates a random ID.
- * @hidden
- */
- function GenerateRandomID() {
- // From http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
- var r = Math.random() * 16 | 0;
- var v = c === 'x' ? r : (r & 0x3 | 0x8);
- return v.toString(16);
- });
- }
- /**
- * Helper function. Checks if 'e' is defined. If so, it triggers the callback
- * with 'e' and returns false. Otherwise, returns true.
- * @hidden
- */
- function noError(e, cb) {
- if (e) {
- cb(e);
- return false;
- }
- return true;
- }
- /**
- * Helper function. Checks if 'e' is defined. If so, it aborts the transaction,
- * triggers the callback with 'e', and returns false. Otherwise, returns true.
- * @hidden
- */
- function noErrorTx(e, tx, cb) {
- if (e) {
- tx.abort(function () {
- cb(e);
- });
- return false;
- }
- return true;
- }
- /**
- * A simple RW transaction for simple synchronous key-value stores.
- */
- var SimpleSyncRWTransaction = function SimpleSyncRWTransaction(store) {
- this.store = store;
- /**
- * Stores data in the keys we modify prior to modifying them.
- * Allows us to roll back commits.
- */
- this.originalData = {};
- /**
- * List of keys modified in this transaction, if any.
- */
- this.modifiedKeys = [];
- };
- SimpleSyncRWTransaction.prototype.get = function get (key) {
- var val = this.store.get(key);
- this.stashOldValue(key, val);
- return val;
- };
- SimpleSyncRWTransaction.prototype.put = function put (key, data, overwrite) {
- this.markModified(key);
- return this.store.put(key, data, overwrite);
- };
- SimpleSyncRWTransaction.prototype.del = function del (key) {
- this.markModified(key);
- this.store.del(key);
- };
- SimpleSyncRWTransaction.prototype.commit = function commit () { };
- SimpleSyncRWTransaction.prototype.abort = function abort () {
- var this$1 = this;
-
- // Rollback old values.
- for (var i = 0, list = this$1.modifiedKeys; i < list.length; i += 1) {
- var key = list[i];
-
- var value = this$1.originalData[key];
- if (!value) {
- // Key didn't exist.
- this$1.store.del(key);
- }
- else {
- // Key existed. Store old value.
- this$1.store.put(key, value, true);
- }
- }
- };
- /**
- * Stashes given key value pair into `originalData` if it doesn't already
- * exist. Allows us to stash values the program is requesting anyway to
- * prevent needless `get` requests if the program modifies the data later
- * on during the transaction.
- */
- SimpleSyncRWTransaction.prototype.stashOldValue = function stashOldValue (key, value) {
- // Keep only the earliest value in the transaction.
- if (!this.originalData.hasOwnProperty(key)) {
- this.originalData[key] = value;
- }
- };
- /**
- * Marks the given key as modified, and stashes its value if it has not been
- * stashed already.
- */
- SimpleSyncRWTransaction.prototype.markModified = function markModified (key) {
- if (this.modifiedKeys.indexOf(key) === -1) {
- this.modifiedKeys.push(key);
- if (!this.originalData.hasOwnProperty(key)) {
- this.originalData[key] = this.store.get(key);
- }
- }
- };
- var SyncKeyValueFile = (function (PreloadFile$$1) {
- function SyncKeyValueFile(_fs, _path, _flag, _stat, contents) {
- PreloadFile$$1.call(this, _fs, _path, _flag, _stat, contents);
- }
-
- if ( PreloadFile$$1 ) SyncKeyValueFile.__proto__ = PreloadFile$$1;
- SyncKeyValueFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );
- SyncKeyValueFile.prototype.constructor = SyncKeyValueFile;
- SyncKeyValueFile.prototype.syncSync = function syncSync () {
- if (this.isDirty()) {
- this._fs._syncSync(this.getPath(), this.getBuffer(), this.getStats());
- this.resetDirty();
- }
- };
- SyncKeyValueFile.prototype.closeSync = function closeSync () {
- this.syncSync();
- };
-
- return SyncKeyValueFile;
- }(PreloadFile));
- /**
- * A "Synchronous key-value file system". Stores data to/retrieves data from an
- * underlying key-value store.
- *
- * We use a unique ID for each node in the file system. The root node has a
- * fixed ID.
- * @todo Introduce Node ID caching.
- * @todo Check modes.
- */
- var SyncKeyValueFileSystem = (function (SynchronousFileSystem$$1) {
- function SyncKeyValueFileSystem(options) {
- SynchronousFileSystem$$1.call(this);
- this.store = options.store;
- // INVARIANT: Ensure that the root exists.
- this.makeRootDirectory();
- }
-
- if ( SynchronousFileSystem$$1 ) SyncKeyValueFileSystem.__proto__ = SynchronousFileSystem$$1;
- SyncKeyValueFileSystem.prototype = Object.create( SynchronousFileSystem$$1 && SynchronousFileSystem$$1.prototype );
- SyncKeyValueFileSystem.prototype.constructor = SyncKeyValueFileSystem;
- SyncKeyValueFileSystem.isAvailable = function isAvailable () { return true; };
-
- SyncKeyValueFileSystem.prototype.getName = function getName () { return this.store.name(); };
- SyncKeyValueFileSystem.prototype.isReadOnly = function isReadOnly () { return false; };
- SyncKeyValueFileSystem.prototype.supportsSymlinks = function supportsSymlinks () { return false; };
- SyncKeyValueFileSystem.prototype.supportsProps = function supportsProps () { return false; };
- SyncKeyValueFileSystem.prototype.supportsSynch = function supportsSynch () { return true; };
- /**
- * Delete all contents stored in the file system.
- */
- SyncKeyValueFileSystem.prototype.empty = function empty () {
- this.store.clear();
- // INVARIANT: Root always exists.
- this.makeRootDirectory();
- };
- SyncKeyValueFileSystem.prototype.renameSync = function renameSync (oldPath, newPath) {
- var tx = this.store.beginTransaction('readwrite'), oldParent = path.dirname(oldPath), oldName = path.basename(oldPath), newParent = path.dirname(newPath), newName = path.basename(newPath),
- // Remove oldPath from parent's directory listing.
- oldDirNode = this.findINode(tx, oldParent), oldDirList = this.getDirListing(tx, oldParent, oldDirNode);
- if (!oldDirList[oldName]) {
- throw ApiError.ENOENT(oldPath);
- }
- var nodeId = oldDirList[oldName];
- delete oldDirList[oldName];
- // Invariant: Can't move a folder inside itself.
- // This funny little hack ensures that the check passes only if oldPath
- // is a subpath of newParent. We append '/' to avoid matching folders that
- // are a substring of the bottom-most folder in the path.
- if ((newParent + '/').indexOf(oldPath + '/') === 0) {
- throw new ApiError(ErrorCode.EBUSY, oldParent);
- }
- // Add newPath to parent's directory listing.
- var newDirNode, newDirList;
- if (newParent === oldParent) {
- // Prevent us from re-grabbing the same directory listing, which still
- // contains oldName.
- newDirNode = oldDirNode;
- newDirList = oldDirList;
- }
- else {
- newDirNode = this.findINode(tx, newParent);
- newDirList = this.getDirListing(tx, newParent, newDirNode);
- }
- if (newDirList[newName]) {
- // If it's a file, delete it.
- var newNameNode = this.getINode(tx, newPath, newDirList[newName]);
- if (newNameNode.isFile()) {
- try {
- tx.del(newNameNode.id);
- tx.del(newDirList[newName]);
- }
- catch (e) {
- tx.abort();
- throw e;
- }
- }
- else {
- // If it's a directory, throw a permissions error.
- throw ApiError.EPERM(newPath);
- }
- }
- newDirList[newName] = nodeId;
- // Commit the two changed directory listings.
- try {
- tx.put(oldDirNode.id, Buffer.from(JSON.stringify(oldDirList)), true);
- tx.put(newDirNode.id, Buffer.from(JSON.stringify(newDirList)), true);
- }
- catch (e) {
- tx.abort();
- throw e;
- }
- tx.commit();
- };
- SyncKeyValueFileSystem.prototype.statSync = function statSync (p, isLstat) {
- // Get the inode to the item, convert it into a Stats object.
- return this.findINode(this.store.beginTransaction('readonly'), p).toStats();
- };
- SyncKeyValueFileSystem.prototype.createFileSync = function createFileSync (p, flag, mode) {
- var tx = this.store.beginTransaction('readwrite'), data = emptyBuffer(), newFile = this.commitNewFile(tx, p, FileType.FILE, mode, data);
- // Open the file.
- return new SyncKeyValueFile(this, p, flag, newFile.toStats(), data);
- };
- SyncKeyValueFileSystem.prototype.openFileSync = function openFileSync (p, flag) {
- var tx = this.store.beginTransaction('readonly'), node = this.findINode(tx, p), data = tx.get(node.id);
- if (data === undefined) {
- throw ApiError.ENOENT(p);
- }
- return new SyncKeyValueFile(this, p, flag, node.toStats(), data);
- };
- SyncKeyValueFileSystem.prototype.unlinkSync = function unlinkSync (p) {
- this.removeEntry(p, false);
- };
- SyncKeyValueFileSystem.prototype.rmdirSync = function rmdirSync (p) {
- // Check first if directory is empty.
- if (this.readdirSync(p).length > 0) {
- throw ApiError.ENOTEMPTY(p);
- }
- else {
- this.removeEntry(p, true);
- }
- };
- SyncKeyValueFileSystem.prototype.mkdirSync = function mkdirSync (p, mode) {
- var tx = this.store.beginTransaction('readwrite'), data = Buffer.from('{}');
- this.commitNewFile(tx, p, FileType.DIRECTORY, mode, data);
- };
- SyncKeyValueFileSystem.prototype.readdirSync = function readdirSync (p) {
- var tx = this.store.beginTransaction('readonly');
- return Object.keys(this.getDirListing(tx, p, this.findINode(tx, p)));
- };
- SyncKeyValueFileSystem.prototype._syncSync = function _syncSync (p, data, stats) {
- // @todo Ensure mtime updates properly, and use that to determine if a data
- // update is required.
- var tx = this.store.beginTransaction('readwrite'),
- // We use the _findInode helper because we actually need the INode id.
- fileInodeId = this._findINode(tx, path.dirname(p), path.basename(p)), fileInode = this.getINode(tx, p, fileInodeId), inodeChanged = fileInode.update(stats);
- try {
- // Sync data.
- tx.put(fileInode.id, data, true);
- // Sync metadata.
- if (inodeChanged) {
- tx.put(fileInodeId, fileInode.toBuffer(), true);
- }
- }
- catch (e) {
- tx.abort();
- throw e;
- }
- tx.commit();
- };
- /**
- * Checks if the root directory exists. Creates it if it doesn't.
- */
- SyncKeyValueFileSystem.prototype.makeRootDirectory = function makeRootDirectory () {
- var tx = this.store.beginTransaction('readwrite');
- if (tx.get(ROOT_NODE_ID) === undefined) {
- // Create new inode.
- var currTime = (new Date()).getTime(),
- // Mode 0666
- dirInode = new Inode(GenerateRandomID(), 4096, 511 | FileType.DIRECTORY, currTime, currTime, currTime);
- // If the root doesn't exist, the first random ID shouldn't exist,
- // either.
- tx.put(dirInode.id, getEmptyDirNode(), false);
- tx.put(ROOT_NODE_ID, dirInode.toBuffer(), false);
- tx.commit();
- }
- };
- /**
- * Helper function for findINode.
- * @param parent The parent directory of the file we are attempting to find.
- * @param filename The filename of the inode we are attempting to find, minus
- * the parent.
- * @return string The ID of the file's inode in the file system.
- */
- SyncKeyValueFileSystem.prototype._findINode = function _findINode (tx, parent, filename) {
- var this$1 = this;
-
- var readDirectory = function (inode) {
- // Get the root's directory listing.
- var dirList = this$1.getDirListing(tx, parent, inode);
- // Get the file's ID.
- if (dirList[filename]) {
- return dirList[filename];
- }
- else {
- throw ApiError.ENOENT(path.resolve(parent, filename));
- }
- };
- if (parent === '/') {
- if (filename === '') {
- // BASE CASE #1: Return the root's ID.
- return ROOT_NODE_ID;
- }
- else {
- // BASE CASE #2: Find the item in the root ndoe.
- return readDirectory(this.getINode(tx, parent, ROOT_NODE_ID));
- }
- }
- else {
- return readDirectory(this.getINode(tx, parent + path.sep + filename, this._findINode(tx, path.dirname(parent), path.basename(parent))));
- }
- };
- /**
- * Finds the Inode of the given path.
- * @param p The path to look up.
- * @return The Inode of the path p.
- * @todo memoize/cache
- */
- SyncKeyValueFileSystem.prototype.findINode = function findINode (tx, p) {
- return this.getINode(tx, p, this._findINode(tx, path.dirname(p), path.basename(p)));
- };
- /**
- * Given the ID of a node, retrieves the corresponding Inode.
- * @param tx The transaction to use.
- * @param p The corresponding path to the file (used for error messages).
- * @param id The ID to look up.
- */
- SyncKeyValueFileSystem.prototype.getINode = function getINode (tx, p, id) {
- var inode = tx.get(id);
- if (inode === undefined) {
- throw ApiError.ENOENT(p);
- }
- return Inode.fromBuffer(inode);
- };
- /**
- * Given the Inode of a directory, retrieves the corresponding directory
- * listing.
- */
- SyncKeyValueFileSystem.prototype.getDirListing = function getDirListing (tx, p, inode) {
- if (!inode.isDirectory()) {
- throw ApiError.ENOTDIR(p);
- }
- var data = tx.get(inode.id);
- if (data === undefined) {
- throw ApiError.ENOENT(p);
- }
- return JSON.parse(data.toString());
- };
- /**
- * Creates a new node under a random ID. Retries 5 times before giving up in
- * the exceedingly unlikely chance that we try to reuse a random GUID.
- * @return The GUID that the data was stored under.
- */
- SyncKeyValueFileSystem.prototype.addNewNode = function addNewNode (tx, data) {
- var retries = 0;
- var currId;
- while (retries < 5) {
- try {
- currId = GenerateRandomID();
- tx.put(currId, data, false);
- return currId;
- }
- catch (e) {
- // Ignore and reroll.
- }
- }
- throw new ApiError(ErrorCode.EIO, 'Unable to commit data to key-value store.');
- };
- /**
- * Commits a new file (well, a FILE or a DIRECTORY) to the file system with
- * the given mode.
- * Note: This will commit the transaction.
- * @param p The path to the new file.
- * @param type The type of the new file.
- * @param mode The mode to create the new file with.
- * @param data The data to store at the file's data node.
- * @return The Inode for the new file.
- */
- SyncKeyValueFileSystem.prototype.commitNewFile = function commitNewFile (tx, p, type, mode, data) {
- var parentDir = path.dirname(p), fname = path.basename(p), parentNode = this.findINode(tx, parentDir), dirListing = this.getDirListing(tx, parentDir, parentNode), currTime = (new Date()).getTime();
- // Invariant: The root always exists.
- // If we don't check this prior to taking steps below, we will create a
- // file with name '' in root should p == '/'.
- if (p === '/') {
- throw ApiError.EEXIST(p);
- }
- // Check if file already exists.
- if (dirListing[fname]) {
- throw ApiError.EEXIST(p);
- }
- var fileNode;
- try {
- // Commit data.
- var dataId = this.addNewNode(tx, data);
- fileNode = new Inode(dataId, data.length, mode | type, currTime, currTime, currTime);
- // Commit file node.
- var fileNodeId = this.addNewNode(tx, fileNode.toBuffer());
- // Update and commit parent directory listing.
- dirListing[fname] = fileNodeId;
- tx.put(parentNode.id, Buffer.from(JSON.stringify(dirListing)), true);
- }
- catch (e) {
- tx.abort();
- throw e;
- }
- tx.commit();
- return fileNode;
- };
- /**
- * Remove all traces of the given path from the file system.
- * @param p The path to remove from the file system.
- * @param isDir Does the path belong to a directory, or a file?
- * @todo Update mtime.
- */
- SyncKeyValueFileSystem.prototype.removeEntry = function removeEntry (p, isDir) {
- var tx = this.store.beginTransaction('readwrite'), parent = path.dirname(p), parentNode = this.findINode(tx, parent), parentListing = this.getDirListing(tx, parent, parentNode), fileName = path.basename(p);
- if (!parentListing[fileName]) {
- throw ApiError.ENOENT(p);
- }
- // Remove from directory listing of parent.
- var fileNodeId = parentListing[fileName];
- delete parentListing[fileName];
- // Get file inode.
- var fileNode = this.getINode(tx, p, fileNodeId);
- if (!isDir && fileNode.isDirectory()) {
- throw ApiError.EISDIR(p);
- }
- else if (isDir && !fileNode.isDirectory()) {
- throw ApiError.ENOTDIR(p);
- }
- try {
- // Delete data.
- tx.del(fileNode.id);
- // Delete node.
- tx.del(fileNodeId);
- // Update directory listing.
- tx.put(parentNode.id, Buffer.from(JSON.stringify(parentListing)), true);
- }
- catch (e) {
- tx.abort();
- throw e;
- }
- // Success.
- tx.commit();
- };
-
- return SyncKeyValueFileSystem;
- }(SynchronousFileSystem));
- var AsyncKeyValueFile = (function (PreloadFile$$1) {
- function AsyncKeyValueFile(_fs, _path, _flag, _stat, contents) {
- PreloadFile$$1.call(this, _fs, _path, _flag, _stat, contents);
- }
-
- if ( PreloadFile$$1 ) AsyncKeyValueFile.__proto__ = PreloadFile$$1;
- AsyncKeyValueFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );
- AsyncKeyValueFile.prototype.constructor = AsyncKeyValueFile;
- AsyncKeyValueFile.prototype.sync = function sync (cb) {
- var this$1 = this;
-
- if (this.isDirty()) {
- this._fs._sync(this.getPath(), this.getBuffer(), this.getStats(), function (e) {
- if (!e) {
- this$1.resetDirty();
- }
- cb(e);
- });
- }
- else {
- cb();
- }
- };
- AsyncKeyValueFile.prototype.close = function close (cb) {
- this.sync(cb);
- };
-
- return AsyncKeyValueFile;
- }(PreloadFile));
- /**
- * An "Asynchronous key-value file system". Stores data to/retrieves data from
- * an underlying asynchronous key-value store.
- */
- var AsyncKeyValueFileSystem = (function (BaseFileSystem$$1) {
- function AsyncKeyValueFileSystem () {
- BaseFileSystem$$1.apply(this, arguments);
- }
-
- if ( BaseFileSystem$$1 ) AsyncKeyValueFileSystem.__proto__ = BaseFileSystem$$1;
- AsyncKeyValueFileSystem.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );
- AsyncKeyValueFileSystem.prototype.constructor = AsyncKeyValueFileSystem;
-
- AsyncKeyValueFileSystem.isAvailable = function isAvailable () { return true; };
- /**
- * Initializes the file system. Typically called by subclasses' async
- * constructors.
- */
- AsyncKeyValueFileSystem.prototype.init = function init (store, cb) {
- this.store = store;
- // INVARIANT: Ensure that the root exists.
- this.makeRootDirectory(cb);
- };
- AsyncKeyValueFileSystem.prototype.getName = function getName () { return this.store.name(); };
- AsyncKeyValueFileSystem.prototype.isReadOnly = function isReadOnly () { return false; };
- AsyncKeyValueFileSystem.prototype.supportsSymlinks = function supportsSymlinks () { return false; };
- AsyncKeyValueFileSystem.prototype.supportsProps = function supportsProps () { return false; };
- AsyncKeyValueFileSystem.prototype.supportsSynch = function supportsSynch () { return false; };
- /**
- * Delete all contents stored in the file system.
- */
- AsyncKeyValueFileSystem.prototype.empty = function empty (cb) {
- var this$1 = this;
-
- this.store.clear(function (e) {
- if (noError(e, cb)) {
- // INVARIANT: Root always exists.
- this$1.makeRootDirectory(cb);
- }
- });
- };
- AsyncKeyValueFileSystem.prototype.rename = function rename (oldPath, newPath, cb) {
- var this$1 = this;
-
- var tx = this.store.beginTransaction('readwrite');
- var oldParent = path.dirname(oldPath), oldName = path.basename(oldPath);
- var newParent = path.dirname(newPath), newName = path.basename(newPath);
- var inodes = {};
- var lists = {};
- var errorOccurred = false;
- // Invariant: Can't move a folder inside itself.
- // This funny little hack ensures that the check passes only if oldPath
- // is a subpath of newParent. We append '/' to avoid matching folders that
- // are a substring of the bottom-most folder in the path.
- if ((newParent + '/').indexOf(oldPath + '/') === 0) {
- return cb(new ApiError(ErrorCode.EBUSY, oldParent));
- }
- /**
- * Responsible for Phase 2 of the rename operation: Modifying and
- * committing the directory listings. Called once we have successfully
- * retrieved both the old and new parent's inodes and listings.
- */
- var theOleSwitcharoo = function () {
- // Sanity check: Ensure both paths are present, and no error has occurred.
- if (errorOccurred || !lists.hasOwnProperty(oldParent) || !lists.hasOwnProperty(newParent)) {
- return;
- }
- var oldParentList = lists[oldParent], oldParentINode = inodes[oldParent], newParentList = lists[newParent], newParentINode = inodes[newParent];
- // Delete file from old parent.
- if (!oldParentList[oldName]) {
- cb(ApiError.ENOENT(oldPath));
- }
- else {
- var fileId = oldParentList[oldName];
- delete oldParentList[oldName];
- // Finishes off the renaming process by adding the file to the new
- // parent.
- var completeRename = function () {
- newParentList[newName] = fileId;
- // Commit old parent's list.
- tx.put(oldParentINode.id, Buffer.from(JSON.stringify(oldParentList)), true, function (e) {
- if (noErrorTx(e, tx, cb)) {
- if (oldParent === newParent) {
- // DONE!
- tx.commit(cb);
- }
- else {
- // Commit new parent's list.
- tx.put(newParentINode.id, Buffer.from(JSON.stringify(newParentList)), true, function (e) {
- if (noErrorTx(e, tx, cb)) {
- tx.commit(cb);
- }
- });
- }
- }
- });
- };
- if (newParentList[newName]) {
- // 'newPath' already exists. Check if it's a file or a directory, and
- // act accordingly.
- this$1.getINode(tx, newPath, newParentList[newName], function (e, inode) {
- if (noErrorTx(e, tx, cb)) {
- if (inode.isFile()) {
- // Delete the file and continue.
- tx.del(inode.id, function (e) {
- if (noErrorTx(e, tx, cb)) {
- tx.del(newParentList[newName], function (e) {
- if (noErrorTx(e, tx, cb)) {
- completeRename();
- }
- });
- }
- });
- }
- else {
- // Can't overwrite a directory using rename.
- tx.abort(function (e) {
- cb(ApiError.EPERM(newPath));
- });
- }
- }
- });
- }
- else {
- completeRename();
- }
- }
- };
- /**
- * Grabs a path's inode and directory listing, and shoves it into the
- * inodes and lists hashes.
- */
- var processInodeAndListings = function (p) {
- this$1.findINodeAndDirListing(tx, p, function (e, node, dirList) {
- if (e) {
- if (!errorOccurred) {
- errorOccurred = true;
- tx.abort(function () {
- cb(e);
- });
- }
- // If error has occurred already, just stop here.
- }
- else {
- inodes[p] = node;
- lists[p] = dirList;
- theOleSwitcharoo();
- }
- });
- };
- processInodeAndListings(oldParent);
- if (oldParent !== newParent) {
- processInodeAndListings(newParent);
- }
- };
- AsyncKeyValueFileSystem.prototype.stat = function stat (p, isLstat, cb) {
- var tx = this.store.beginTransaction('readonly');
- this.findINode(tx, p, function (e, inode) {
- if (noError(e, cb)) {
- cb(null, inode.toStats());
- }
- });
- };
- AsyncKeyValueFileSystem.prototype.createFile = function createFile (p, flag, mode, cb) {
- var this$1 = this;
-
- var tx = this.store.beginTransaction('readwrite'), data = emptyBuffer();
- this.commitNewFile(tx, p, FileType.FILE, mode, data, function (e, newFile) {
- if (noError(e, cb)) {
- cb(null, new AsyncKeyValueFile(this$1, p, flag, newFile.toStats(), data));
- }
- });
- };
- AsyncKeyValueFileSystem.prototype.openFile = function openFile (p, flag, cb) {
- var this$1 = this;
-
- var tx = this.store.beginTransaction('readonly');
- // Step 1: Grab the file's inode.
- this.findINode(tx, p, function (e, inode) {
- if (noError(e, cb)) {
- // Step 2: Grab the file's data.
- tx.get(inode.id, function (e, data) {
- if (noError(e, cb)) {
- if (data === undefined) {
- cb(ApiError.ENOENT(p));
- }
- else {
- cb(null, new AsyncKeyValueFile(this$1, p, flag, inode.toStats(), data));
- }
- }
- });
- }
- });
- };
- AsyncKeyValueFileSystem.prototype.unlink = function unlink (p, cb) {
- this.removeEntry(p, false, cb);
- };
- AsyncKeyValueFileSystem.prototype.rmdir = function rmdir (p, cb) {
- var this$1 = this;
-
- // Check first if directory is empty.
- this.readdir(p, function (err, files) {
- if (err) {
- cb(err);
- }
- else if (files.length > 0) {
- cb(ApiError.ENOTEMPTY(p));
- }
- else {
- this$1.removeEntry(p, true, cb);
- }
- });
- };
- AsyncKeyValueFileSystem.prototype.mkdir = function mkdir (p, mode, cb) {
- var tx = this.store.beginTransaction('readwrite'), data = Buffer.from('{}');
- this.commitNewFile(tx, p, FileType.DIRECTORY, mode, data, cb);
- };
- AsyncKeyValueFileSystem.prototype.readdir = function readdir (p, cb) {
- var this$1 = this;
-
- var tx = this.store.beginTransaction('readonly');
- this.findINode(tx, p, function (e, inode) {
- if (noError(e, cb)) {
- this$1.getDirListing(tx, p, inode, function (e, dirListing) {
- if (noError(e, cb)) {
- cb(null, Object.keys(dirListing));
- }
- });
- }
- });
- };
- AsyncKeyValueFileSystem.prototype._sync = function _sync (p, data, stats, cb) {
- var this$1 = this;
-
- // @todo Ensure mtime updates properly, and use that to determine if a data
- // update is required.
- var tx = this.store.beginTransaction('readwrite');
- // Step 1: Get the file node's ID.
- this._findINode(tx, path.dirname(p), path.basename(p), function (e, fileInodeId) {
- if (noErrorTx(e, tx, cb)) {
- // Step 2: Get the file inode.
- this$1.getINode(tx, p, fileInodeId, function (e, fileInode) {
- if (noErrorTx(e, tx, cb)) {
- var inodeChanged = fileInode.update(stats);
- // Step 3: Sync the data.
- tx.put(fileInode.id, data, true, function (e) {
- if (noErrorTx(e, tx, cb)) {
- // Step 4: Sync the metadata (if it changed)!
- if (inodeChanged) {
- tx.put(fileInodeId, fileInode.toBuffer(), true, function (e) {
- if (noErrorTx(e, tx, cb)) {
- tx.commit(cb);
- }
- });
- }
- else {
- // No need to sync metadata; return.
- tx.commit(cb);
- }
- }
- });
- }
- });
- }
- });
- };
- /**
- * Checks if the root directory exists. Creates it if it doesn't.
- */
- AsyncKeyValueFileSystem.prototype.makeRootDirectory = function makeRootDirectory (cb) {
- var tx = this.store.beginTransaction('readwrite');
- tx.get(ROOT_NODE_ID, function (e, data) {
- if (e || data === undefined) {
- // Create new inode.
- var currTime = (new Date()).getTime(),
- // Mode 0666
- dirInode = new Inode(GenerateRandomID(), 4096, 511 | FileType.DIRECTORY, currTime, currTime, currTime);
- // If the root doesn't exist, the first random ID shouldn't exist,
- // either.
- tx.put(dirInode.id, getEmptyDirNode(), false, function (e) {
- if (noErrorTx(e, tx, cb)) {
- tx.put(ROOT_NODE_ID, dirInode.toBuffer(), false, function (e) {
- if (e) {
- tx.abort(function () { cb(e); });
- }
- else {
- tx.commit(cb);
- }
- });
- }
- });
- }
- else {
- // We're good.
- tx.commit(cb);
- }
- });
- };
- /**
- * Helper function for findINode.
- * @param parent The parent directory of the file we are attempting to find.
- * @param filename The filename of the inode we are attempting to find, minus
- * the parent.
- * @param cb Passed an error or the ID of the file's inode in the file system.
- */
- AsyncKeyValueFileSystem.prototype._findINode = function _findINode (tx, parent, filename, cb) {
- var this$1 = this;
-
- var handleDirectoryListings = function (e, inode, dirList) {
- if (e) {
- cb(e);
- }
- else if (dirList[filename]) {
- cb(null, dirList[filename]);
- }
- else {
- cb(ApiError.ENOENT(path.resolve(parent, filename)));
- }
- };
- if (parent === '/') {
- if (filename === '') {
- // BASE CASE #1: Return the root's ID.
- cb(null, ROOT_NODE_ID);
- }
- else {
- // BASE CASE #2: Find the item in the root node.
- this.getINode(tx, parent, ROOT_NODE_ID, function (e, inode) {
- if (noError(e, cb)) {
- this$1.getDirListing(tx, parent, inode, function (e, dirList) {
- // handle_directory_listings will handle e for us.
- handleDirectoryListings(e, inode, dirList);
- });
- }
- });
- }
- }
- else {
- // Get the parent directory's INode, and find the file in its directory
- // listing.
- this.findINodeAndDirListing(tx, parent, handleDirectoryListings);
- }
- };
- /**
- * Finds the Inode of the given path.
- * @param p The path to look up.
- * @param cb Passed an error or the Inode of the path p.
- * @todo memoize/cache
- */
- AsyncKeyValueFileSystem.prototype.findINode = function findINode (tx, p, cb) {
- var this$1 = this;
-
- this._findINode(tx, path.dirname(p), path.basename(p), function (e, id) {
- if (noError(e, cb)) {
- this$1.getINode(tx, p, id, cb);
- }
- });
- };
- /**
- * Given the ID of a node, retrieves the corresponding Inode.
- * @param tx The transaction to use.
- * @param p The corresponding path to the file (used for error messages).
- * @param id The ID to look up.
- * @param cb Passed an error or the inode under the given id.
- */
- AsyncKeyValueFileSystem.prototype.getINode = function getINode (tx, p, id, cb) {
- tx.get(id, function (e, data) {
- if (noError(e, cb)) {
- if (data === undefined) {
- cb(ApiError.ENOENT(p));
- }
- else {
- cb(null, Inode.fromBuffer(data));
- }
- }
- });
- };
- /**
- * Given the Inode of a directory, retrieves the corresponding directory
- * listing.
- */
- AsyncKeyValueFileSystem.prototype.getDirListing = function getDirListing (tx, p, inode, cb) {
- if (!inode.isDirectory()) {
- cb(ApiError.ENOTDIR(p));
- }
- else {
- tx.get(inode.id, function (e, data) {
- if (noError(e, cb)) {
- try {
- cb(null, JSON.parse(data.toString()));
- }
- catch (e) {
- // Occurs when data is undefined, or corresponds to something other
- // than a directory listing. The latter should never occur unless
- // the file system is corrupted.
- cb(ApiError.ENOENT(p));
- }
- }
- });
- }
- };
- /**
- * Given a path to a directory, retrieves the corresponding INode and
- * directory listing.
- */
- AsyncKeyValueFileSystem.prototype.findINodeAndDirListing = function findINodeAndDirListing (tx, p, cb) {
- var this$1 = this;
-
- this.findINode(tx, p, function (e, inode) {
- if (noError(e, cb)) {
- this$1.getDirListing(tx, p, inode, function (e, listing) {
- if (noError(e, cb)) {
- cb(null, inode, listing);
- }
- });
- }
- });
- };
- /**
- * Adds a new node under a random ID. Retries 5 times before giving up in
- * the exceedingly unlikely chance that we try to reuse a random GUID.
- * @param cb Passed an error or the GUID that the data was stored under.
- */
- AsyncKeyValueFileSystem.prototype.addNewNode = function addNewNode (tx, data, cb) {
- var retries = 0, currId;
- var reroll = function () {
- if (++retries === 5) {
- // Max retries hit. Return with an error.
- cb(new ApiError(ErrorCode.EIO, 'Unable to commit data to key-value store.'));
- }
- else {
- // Try again.
- currId = GenerateRandomID();
- tx.put(currId, data, false, function (e, committed) {
- if (e || !committed) {
- reroll();
- }
- else {
- // Successfully stored under 'currId'.
- cb(null, currId);
- }
- });
- }
- };
- reroll();
- };
- /**
- * Commits a new file (well, a FILE or a DIRECTORY) to the file system with
- * the given mode.
- * Note: This will commit the transaction.
- * @param p The path to the new file.
- * @param type The type of the new file.
- * @param mode The mode to create the new file with.
- * @param data The data to store at the file's data node.
- * @param cb Passed an error or the Inode for the new file.
- */
- AsyncKeyValueFileSystem.prototype.commitNewFile = function commitNewFile (tx, p, type, mode, data, cb) {
- var this$1 = this;
-
- var parentDir = path.dirname(p), fname = path.basename(p), currTime = (new Date()).getTime();
- // Invariant: The root always exists.
- // If we don't check this prior to taking steps below, we will create a
- // file with name '' in root should p == '/'.
- if (p === '/') {
- return cb(ApiError.EEXIST(p));
- }
- // Let's build a pyramid of code!
- // Step 1: Get the parent directory's inode and directory listing
- this.findINodeAndDirListing(tx, parentDir, function (e, parentNode, dirListing) {
- if (noErrorTx(e, tx, cb)) {
- if (dirListing[fname]) {
- // File already exists.
- tx.abort(function () {
- cb(ApiError.EEXIST(p));
- });
- }
- else {
- // Step 2: Commit data to store.
- this$1.addNewNode(tx, data, function (e, dataId) {
- if (noErrorTx(e, tx, cb)) {
- // Step 3: Commit the file's inode to the store.
- var fileInode = new Inode(dataId, data.length, mode | type, currTime, currTime, currTime);
- this$1.addNewNode(tx, fileInode.toBuffer(), function (e, fileInodeId) {
- if (noErrorTx(e, tx, cb)) {
- // Step 4: Update parent directory's listing.
- dirListing[fname] = fileInodeId;
- tx.put(parentNode.id, Buffer.from(JSON.stringify(dirListing)), true, function (e) {
- if (noErrorTx(e, tx, cb)) {
- // Step 5: Commit and return the new inode.
- tx.commit(function (e) {
- if (noErrorTx(e, tx, cb)) {
- cb(null, fileInode);
- }
- });
- }
- });
- }
- });
- }
- });
- }
- }
- });
- };
- /**
- * Remove all traces of the given path from the file system.
- * @param p The path to remove from the file system.
- * @param isDir Does the path belong to a directory, or a file?
- * @todo Update mtime.
- */
- AsyncKeyValueFileSystem.prototype.removeEntry = function removeEntry (p, isDir, cb) {
- var this$1 = this;
-
- var tx = this.store.beginTransaction('readwrite'), parent = path.dirname(p), fileName = path.basename(p);
- // Step 1: Get parent directory's node and directory listing.
- this.findINodeAndDirListing(tx, parent, function (e, parentNode, parentListing) {
- if (noErrorTx(e, tx, cb)) {
- if (!parentListing[fileName]) {
- tx.abort(function () {
- cb(ApiError.ENOENT(p));
- });
- }
- else {
- // Remove from directory listing of parent.
- var fileNodeId = parentListing[fileName];
- delete parentListing[fileName];
- // Step 2: Get file inode.
- this$1.getINode(tx, p, fileNodeId, function (e, fileNode) {
- if (noErrorTx(e, tx, cb)) {
- if (!isDir && fileNode.isDirectory()) {
- tx.abort(function () {
- cb(ApiError.EISDIR(p));
- });
- }
- else if (isDir && !fileNode.isDirectory()) {
- tx.abort(function () {
- cb(ApiError.ENOTDIR(p));
- });
- }
- else {
- // Step 3: Delete data.
- tx.del(fileNode.id, function (e) {
- if (noErrorTx(e, tx, cb)) {
- // Step 4: Delete node.
- tx.del(fileNodeId, function (e) {
- if (noErrorTx(e, tx, cb)) {
- // Step 5: Update directory listing.
- tx.put(parentNode.id, Buffer.from(JSON.stringify(parentListing)), true, function (e) {
- if (noErrorTx(e, tx, cb)) {
- tx.commit(cb);
- }
- });
- }
- });
- }
- });
- }
- }
- });
- }
- }
- });
- };
-
- return AsyncKeyValueFileSystem;
- }(BaseFileSystem));
-
- /**
- * A simple in-memory key-value store backed by a JavaScript object.
- */
- var InMemoryStore = function InMemoryStore() {
- this.store = {};
- };
- InMemoryStore.prototype.name = function name () { return InMemoryFileSystem.Name; };
- InMemoryStore.prototype.clear = function clear () { this.store = {}; };
- InMemoryStore.prototype.beginTransaction = function beginTransaction (type) {
- return new SimpleSyncRWTransaction(this);
- };
- InMemoryStore.prototype.get = function get (key) {
- return this.store[key];
- };
- InMemoryStore.prototype.put = function put (key, data, overwrite) {
- if (!overwrite && this.store.hasOwnProperty(key)) {
- return false;
- }
- this.store[key] = data;
- return true;
- };
- InMemoryStore.prototype.del = function del (key) {
- delete this.store[key];
- };
- /**
- * A simple in-memory file system backed by an InMemoryStore.
- * Files are not persisted across page loads.
- */
- var InMemoryFileSystem = (function (SyncKeyValueFileSystem$$1) {
- function InMemoryFileSystem() {
- SyncKeyValueFileSystem$$1.call(this, { store: new InMemoryStore() });
- }
-
- if ( SyncKeyValueFileSystem$$1 ) InMemoryFileSystem.__proto__ = SyncKeyValueFileSystem$$1;
- InMemoryFileSystem.prototype = Object.create( SyncKeyValueFileSystem$$1 && SyncKeyValueFileSystem$$1.prototype );
- InMemoryFileSystem.prototype.constructor = InMemoryFileSystem;
- /**
- * Creates an InMemoryFileSystem instance.
- */
- InMemoryFileSystem.Create = function Create (options, cb) {
- cb(null, new InMemoryFileSystem());
- };
-
- return InMemoryFileSystem;
- }(SyncKeyValueFileSystem));
-
- InMemoryFileSystem.Name = "InMemory";
- InMemoryFileSystem.Options = {};
-
- /**
- * Get the indexedDB constructor for the current browser.
- * @hidden
- */
- var indexedDB = global$1.indexedDB ||
- global$1.mozIndexedDB ||
- global$1.webkitIndexedDB ||
- global$1.msIndexedDB;
- /**
- * Converts a DOMException or a DOMError from an IndexedDB event into a
- * standardized BrowserFS API error.
- * @hidden
- */
- function convertError$2(e, message) {
- if ( message === void 0 ) message = e.toString();
-
- switch (e.name) {
- case "NotFoundError":
- return new ApiError(ErrorCode.ENOENT, message);
- case "QuotaExceededError":
- return new ApiError(ErrorCode.ENOSPC, message);
- default:
- // The rest do not seem to map cleanly to standard error codes.
- return new ApiError(ErrorCode.EIO, message);
- }
- }
- /**
- * Produces a new onerror handler for IDB. Our errors are always fatal, so we
- * handle them generically: Call the user-supplied callback with a translated
- * version of the error, and let the error bubble up.
- * @hidden
- */
- function onErrorHandler(cb, code, message) {
- if ( code === void 0 ) code = ErrorCode.EIO;
- if ( message === void 0 ) message = null;
-
- return function (e) {
- // Prevent the error from canceling the transaction.
- e.preventDefault();
- cb(new ApiError(code, message !== null ? message : undefined));
- };
- }
- /**
- * @hidden
- */
- var IndexedDBROTransaction = function IndexedDBROTransaction(tx, store) {
- this.tx = tx;
- this.store = store;
- };
- IndexedDBROTransaction.prototype.get = function get (key, cb) {
- try {
- var r = this.store.get(key);
- r.onerror = onErrorHandler(cb);
- r.onsuccess = function (event) {
- // IDB returns the value 'undefined' when you try to get keys that
- // don't exist. The caller expects this behavior.
- var result = event.target.result;
- if (result === undefined) {
- cb(null, result);
- }
- else {
- // IDB data is stored as an ArrayBuffer
- cb(null, arrayBuffer2Buffer(result));
- }
- };
- }
- catch (e) {
- cb(convertError$2(e));
- }
- };
- /**
- * @hidden
- */
- var IndexedDBRWTransaction = (function (IndexedDBROTransaction) {
- function IndexedDBRWTransaction(tx, store) {
- IndexedDBROTransaction.call(this, tx, store);
- }
-
- if ( IndexedDBROTransaction ) IndexedDBRWTransaction.__proto__ = IndexedDBROTransaction;
- IndexedDBRWTransaction.prototype = Object.create( IndexedDBROTransaction && IndexedDBROTransaction.prototype );
- IndexedDBRWTransaction.prototype.constructor = IndexedDBRWTransaction;
- IndexedDBRWTransaction.prototype.put = function put (key, data, overwrite, cb) {
- try {
- var arraybuffer = buffer2ArrayBuffer(data);
- var r;
- if (overwrite) {
- r = this.store.put(arraybuffer, key);
- }
- else {
- // 'add' will never overwrite an existing key.
- r = this.store.add(arraybuffer, key);
- }
- // XXX: NEED TO RETURN FALSE WHEN ADD HAS A KEY CONFLICT. NO ERROR.
- r.onerror = onErrorHandler(cb);
- r.onsuccess = function (event) {
- cb(null, true);
- };
- }
- catch (e) {
- cb(convertError$2(e));
- }
- };
- IndexedDBRWTransaction.prototype.del = function del (key, cb) {
- try {
- // NOTE: IE8 has a bug with identifiers named 'delete' unless used as a string
- // like this.
- // http://stackoverflow.com/a/26479152
- var r = this.store['delete'](key);
- r.onerror = onErrorHandler(cb);
- r.onsuccess = function (event) {
- cb();
- };
- }
- catch (e) {
- cb(convertError$2(e));
- }
- };
- IndexedDBRWTransaction.prototype.commit = function commit (cb) {
- // Return to the event loop to commit the transaction.
- setTimeout(cb, 0);
- };
- IndexedDBRWTransaction.prototype.abort = function abort (cb) {
- var _e = null;
- try {
- this.tx.abort();
- }
- catch (e) {
- _e = convertError$2(e);
- }
- finally {
- cb(_e);
- }
- };
-
- return IndexedDBRWTransaction;
- }(IndexedDBROTransaction));
- var IndexedDBStore = function IndexedDBStore(cb, storeName) {
- var this$1 = this;
- if ( storeName === void 0 ) storeName = 'browserfs';
-
- this.storeName = storeName;
- var openReq = indexedDB.open(this.storeName, 1);
- openReq.onupgradeneeded = function (event) {
- var db = event.target.result;
- // Huh. This should never happen; we're at version 1. Why does another
- // database exist?
- if (db.objectStoreNames.contains(this$1.storeName)) {
- db.deleteObjectStore(this$1.storeName);
- }
- db.createObjectStore(this$1.storeName);
- };
- openReq.onsuccess = function (event) {
- this$1.db = event.target.result;
- cb(null, this$1);
- };
- openReq.onerror = onErrorHandler(cb, ErrorCode.EACCES);
- };
- IndexedDBStore.prototype.name = function name () {
- return IndexedDBFileSystem.Name + " - " + this.storeName;
- };
- IndexedDBStore.prototype.clear = function clear (cb) {
- try {
- var tx = this.db.transaction(this.storeName, 'readwrite'), objectStore = tx.objectStore(this.storeName), r = objectStore.clear();
- r.onsuccess = function (event) {
- // Use setTimeout to commit transaction.
- setTimeout(cb, 0);
- };
- r.onerror = onErrorHandler(cb);
- }
- catch (e) {
- cb(convertError$2(e));
- }
- };
- IndexedDBStore.prototype.beginTransaction = function beginTransaction (type) {
- if ( type === void 0 ) type = 'readonly';
-
- var tx = this.db.transaction(this.storeName, type), objectStore = tx.objectStore(this.storeName);
- if (type === 'readwrite') {
- return new IndexedDBRWTransaction(tx, objectStore);
- }
- else if (type === 'readonly') {
- return new IndexedDBROTransaction(tx, objectStore);
- }
- else {
- throw new ApiError(ErrorCode.EINVAL, 'Invalid transaction type.');
- }
- };
- /**
- * A file system that uses the IndexedDB key value file system.
- */
- var IndexedDBFileSystem = (function (AsyncKeyValueFileSystem$$1) {
- function IndexedDBFileSystem(cb, storeName, deprecateMsg) {
- var this$1 = this;
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- AsyncKeyValueFileSystem$$1.call(this);
- this.store = new IndexedDBStore(function (e) {
- if (e) {
- cb(e);
- }
- else {
- this$1.init(this$1.store, function (e) {
- cb(e, this$1);
- });
- }
- }, storeName);
- deprecationMessage(deprecateMsg, IndexedDBFileSystem.Name, { storeName: storeName });
- }
-
- if ( AsyncKeyValueFileSystem$$1 ) IndexedDBFileSystem.__proto__ = AsyncKeyValueFileSystem$$1;
- IndexedDBFileSystem.prototype = Object.create( AsyncKeyValueFileSystem$$1 && AsyncKeyValueFileSystem$$1.prototype );
- IndexedDBFileSystem.prototype.constructor = IndexedDBFileSystem;
- /**
- * Constructs an IndexedDB file system with the given options.
- */
- IndexedDBFileSystem.Create = function Create (opts, cb) {
- // tslint:disable-next-line:no-unused-new
- new IndexedDBFileSystem(cb, opts.storeName, false);
- // tslint:enable-next-line:no-unused-new
- };
- IndexedDBFileSystem.isAvailable = function isAvailable () {
- // In Safari's private browsing mode, indexedDB.open returns NULL.
- // In Firefox, it throws an exception.
- // In Chrome, it "just works", and clears the database when you leave the page.
- // Untested: Opera, IE.
- try {
- return typeof indexedDB !== 'undefined' && null !== indexedDB.open("__browserfs_test__");
- }
- catch (e) {
- return false;
- }
- };
-
- return IndexedDBFileSystem;
- }(AsyncKeyValueFileSystem));
-
- IndexedDBFileSystem.Name = "IndexedDB";
- IndexedDBFileSystem.Options = {
- storeName: {
- type: "string",
- optional: true,
- description: "The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name."
- }
- };
-
- /**
- * Some versions of FF and all versions of IE do not support the full range of
- * 16-bit numbers encoded as characters, as they enforce UTF-16 restrictions.
- * @url http://stackoverflow.com/questions/11170716/are-there-any-characters-that-are-not-allowed-in-localstorage/11173673#11173673
- * @hidden
- */
- var supportsBinaryString = false;
- var binaryEncoding;
- try {
- global$1.localStorage.setItem("__test__", String.fromCharCode(0xD800));
- supportsBinaryString = global$1.localStorage.getItem("__test__") === String.fromCharCode(0xD800);
- }
- catch (e) {
- // IE throws an exception.
- supportsBinaryString = false;
- }
- binaryEncoding = supportsBinaryString ? 'binary_string' : 'binary_string_ie';
- if (!Buffer.isEncoding(binaryEncoding)) {
- // Fallback for non BrowserFS implementations of buffer that lack a
- // binary_string format.
- binaryEncoding = "base64";
- }
- /**
- * A synchronous key-value store backed by localStorage.
- */
- var LocalStorageStore = function LocalStorageStore () {};
-
- LocalStorageStore.prototype.name = function name () {
- return LocalStorageFileSystem.Name;
- };
- LocalStorageStore.prototype.clear = function clear () {
- global$1.localStorage.clear();
- };
- LocalStorageStore.prototype.beginTransaction = function beginTransaction (type) {
- // No need to differentiate.
- return new SimpleSyncRWTransaction(this);
- };
- LocalStorageStore.prototype.get = function get (key) {
- try {
- var data = global$1.localStorage.getItem(key);
- if (data !== null) {
- return Buffer.from(data, binaryEncoding);
- }
- }
- catch (e) {
- // Do nothing.
- }
- // Key doesn't exist, or a failure occurred.
- return undefined;
- };
- LocalStorageStore.prototype.put = function put (key, data, overwrite) {
- try {
- if (!overwrite && global$1.localStorage.getItem(key) !== null) {
- // Don't want to overwrite the key!
- return false;
- }
- global$1.localStorage.setItem(key, data.toString(binaryEncoding));
- return true;
- }
- catch (e) {
- throw new ApiError(ErrorCode.ENOSPC, "LocalStorage is full.");
- }
- };
- LocalStorageStore.prototype.del = function del (key) {
- try {
- global$1.localStorage.removeItem(key);
- }
- catch (e) {
- throw new ApiError(ErrorCode.EIO, "Unable to delete key " + key + ": " + e);
- }
- };
- /**
- * A synchronous file system backed by localStorage. Connects our
- * LocalStorageStore to our SyncKeyValueFileSystem.
- */
- var LocalStorageFileSystem = (function (SyncKeyValueFileSystem$$1) {
- function LocalStorageFileSystem() { SyncKeyValueFileSystem$$1.call(this, { store: new LocalStorageStore() }); }
-
- if ( SyncKeyValueFileSystem$$1 ) LocalStorageFileSystem.__proto__ = SyncKeyValueFileSystem$$1;
- LocalStorageFileSystem.prototype = Object.create( SyncKeyValueFileSystem$$1 && SyncKeyValueFileSystem$$1.prototype );
- LocalStorageFileSystem.prototype.constructor = LocalStorageFileSystem;
- /**
- * Creates a LocalStorageFileSystem instance.
- */
- LocalStorageFileSystem.Create = function Create (options, cb) {
- cb(null, new LocalStorageFileSystem());
- };
- LocalStorageFileSystem.isAvailable = function isAvailable () {
- return typeof global$1.localStorage !== 'undefined';
- };
-
- return LocalStorageFileSystem;
- }(SyncKeyValueFileSystem));
-
- LocalStorageFileSystem.Name = "LocalStorage";
- LocalStorageFileSystem.Options = {};
-
- /**
- * The MountableFileSystem allows you to mount multiple backend types or
- * multiple instantiations of the same backend into a single file system tree.
- * The file systems do not need to know about each other; all interactions are
- * automatically facilitated through this interface.
- *
- * For example, if a file system is mounted at /mnt/blah, and a request came in
- * for /mnt/blah/foo.txt, the file system would see a request for /foo.txt.
- *
- * You can mount file systems when you configure the file system:
- * ```javascript
- * BrowserFS.configure({
- * fs: "MountableFileSystem",
- * options: {
- * '/data': { fs: 'XmlHttpRequest', options: { index: "http://mysite.com/files/index.json" } },
- * '/home': { fs: 'LocalStorage' }
- * }
- * }, function(e) {
- *
- * });
- * ```
- *
- * For advanced users, you can also mount file systems *after* MFS is constructed:
- * ```javascript
- * BrowserFS.FileSystem.XmlHttpRequest.Create({
- * index: "http://mysite.com/files/index.json"
- * }, function(e, xhrfs) {
- * BrowserFS.FileSystem.MountableFileSystem.Create({
- * '/data': xhrfs
- * }, function(e, mfs) {
- * BrowserFS.initialize(mfs);
- *
- * // Added after-the-fact...
- * BrowserFS.FileSystem.LocalStorage.Create(function(e, lsfs) {
- * mfs.mount('/home', lsfs);
- * });
- * });
- * });
- * ```
- *
- * Since MountableFileSystem simply proxies requests to mounted file systems, it supports all of the operations that the mounted file systems support.
- *
- * With no mounted file systems, `MountableFileSystem` acts as a simple `InMemory` filesystem.
- */
- var MountableFileSystem = (function (BaseFileSystem$$1) {
- function MountableFileSystem() {
- BaseFileSystem$$1.call(this);
- // Contains the list of mount points in mntMap, sorted by string length in decreasing order.
- // Ensures that we scan the most specific mount points for a match first, which lets us
- // nest mount points.
- this.mountList = [];
- this.mntMap = {};
- // The InMemory file system serves purely to provide directory listings for
- // mounted file systems.
- this.rootFs = new InMemoryFileSystem();
- }
-
- if ( BaseFileSystem$$1 ) MountableFileSystem.__proto__ = BaseFileSystem$$1;
- MountableFileSystem.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );
- MountableFileSystem.prototype.constructor = MountableFileSystem;
- /**
- * Creates a MountableFileSystem instance with the given options.
- */
- MountableFileSystem.Create = function Create (opts, cb) {
- var fs = new MountableFileSystem();
- Object.keys(opts).forEach(function (mountPoint) {
- fs.mount(mountPoint, opts[mountPoint]);
- });
- cb(null, fs);
- };
- MountableFileSystem.isAvailable = function isAvailable () {
- return true;
- };
- /**
- * Mounts the file system at the given mount point.
- */
- MountableFileSystem.prototype.mount = function mount (mountPoint, fs) {
- if (mountPoint[0] !== '/') {
- mountPoint = "/" + mountPoint;
- }
- mountPoint = path.resolve(mountPoint);
- if (this.mntMap[mountPoint]) {
- throw new ApiError(ErrorCode.EINVAL, "Mount point " + mountPoint + " is already taken.");
- }
- mkdirpSync(mountPoint, 0x1ff, this.rootFs);
- this.mntMap[mountPoint] = fs;
- this.mountList.push(mountPoint);
- this.mountList = this.mountList.sort(function (a, b) { return b.length - a.length; });
- };
- MountableFileSystem.prototype.umount = function umount (mountPoint) {
- var this$1 = this;
-
- if (mountPoint[0] !== '/') {
- mountPoint = "/" + mountPoint;
- }
- mountPoint = path.resolve(mountPoint);
- if (!this.mntMap[mountPoint]) {
- throw new ApiError(ErrorCode.EINVAL, "Mount point " + mountPoint + " is already unmounted.");
- }
- delete this.mntMap[mountPoint];
- this.mountList.splice(this.mountList.indexOf(mountPoint), 1);
- while (mountPoint !== '/') {
- if (this$1.rootFs.readdirSync(mountPoint).length === 0) {
- this$1.rootFs.rmdirSync(mountPoint);
- mountPoint = path.dirname(mountPoint);
- }
- else {
- break;
- }
- }
- };
- /**
- * Returns the file system that the path points to.
- */
- MountableFileSystem.prototype._getFs = function _getFs (path$$1) {
- var this$1 = this;
-
- var mountList = this.mountList, len = mountList.length;
- for (var i = 0; i < len; i++) {
- var mountPoint = mountList[i];
- // We know path is normalized, so it is a substring of the mount point.
- if (mountPoint.length <= path$$1.length && path$$1.indexOf(mountPoint) === 0) {
- path$$1 = path$$1.substr(mountPoint.length > 1 ? mountPoint.length : 0);
- if (path$$1 === '') {
- path$$1 = '/';
- }
- return { fs: this$1.mntMap[mountPoint], path: path$$1 };
- }
- }
- // Query our root file system.
- return { fs: this.rootFs, path: path$$1 };
- };
- // Global information methods
- MountableFileSystem.prototype.getName = function getName () {
- return MountableFileSystem.Name;
- };
- MountableFileSystem.prototype.diskSpace = function diskSpace (path$$1, cb) {
- cb(0, 0);
- };
- MountableFileSystem.prototype.isReadOnly = function isReadOnly () {
- return false;
- };
- MountableFileSystem.prototype.supportsLinks = function supportsLinks () {
- // I'm not ready for cross-FS links yet.
- return false;
- };
- MountableFileSystem.prototype.supportsProps = function supportsProps () {
- return false;
- };
- MountableFileSystem.prototype.supportsSynch = function supportsSynch () {
- return true;
- };
- /**
- * Fixes up error messages so they mention the mounted file location relative
- * to the MFS root, not to the particular FS's root.
- * Mutates the input error, and returns it.
- */
- MountableFileSystem.prototype.standardizeError = function standardizeError (err, path$$1, realPath) {
- var index = err.message.indexOf(path$$1);
- if (index !== -1) {
- err.message = err.message.substr(0, index) + realPath + err.message.substr(index + path$$1.length);
- err.path = realPath;
- }
- return err;
- };
- // The following methods involve multiple file systems, and thus have custom
- // logic.
- // Note that we go through the Node API to use its robust default argument
- // processing.
- MountableFileSystem.prototype.rename = function rename (oldPath, newPath, cb) {
- var this$1 = this;
-
- // Scenario 1: old and new are on same FS.
- var fs1rv = this._getFs(oldPath);
- var fs2rv = this._getFs(newPath);
- if (fs1rv.fs === fs2rv.fs) {
- return fs1rv.fs.rename(fs1rv.path, fs2rv.path, function (e) {
- if (e) {
- this$1.standardizeError(this$1.standardizeError(e, fs1rv.path, oldPath), fs2rv.path, newPath);
- }
- cb(e);
- });
- }
- // Scenario 2: Different file systems.
- // Read old file, write new file, delete old file.
- return _fsMock.readFile(oldPath, function (err, data) {
- if (err) {
- return cb(err);
- }
- _fsMock.writeFile(newPath, data, function (err) {
- if (err) {
- return cb(err);
- }
- _fsMock.unlink(oldPath, cb);
- });
- });
- };
- MountableFileSystem.prototype.renameSync = function renameSync (oldPath, newPath) {
- // Scenario 1: old and new are on same FS.
- var fs1rv = this._getFs(oldPath);
- var fs2rv = this._getFs(newPath);
- if (fs1rv.fs === fs2rv.fs) {
- try {
- return fs1rv.fs.renameSync(fs1rv.path, fs2rv.path);
- }
- catch (e) {
- this.standardizeError(this.standardizeError(e, fs1rv.path, oldPath), fs2rv.path, newPath);
- throw e;
- }
- }
- // Scenario 2: Different file systems.
- var data = _fsMock.readFileSync(oldPath);
- _fsMock.writeFileSync(newPath, data);
- return _fsMock.unlinkSync(oldPath);
- };
- MountableFileSystem.prototype.readdirSync = function readdirSync (p) {
- var fsInfo = this._getFs(p);
- // If null, rootfs did not have the directory
- // (or the target FS is the root fs).
- var rv = null;
- // Mount points are all defined in the root FS.
- // Ensure that we list those, too.
- if (fsInfo.fs !== this.rootFs) {
- try {
- rv = this.rootFs.readdirSync(p);
- }
- catch (e) {
- // Ignore.
- }
- }
- try {
- var rv2 = fsInfo.fs.readdirSync(fsInfo.path);
- if (rv === null) {
- return rv2;
- }
- else {
- // Filter out duplicates.
- return rv2.concat(rv.filter(function (val) { return rv2.indexOf(val) === -1; }));
- }
- }
- catch (e) {
- if (rv === null) {
- throw this.standardizeError(e, fsInfo.path, p);
- }
- else {
- // The root FS had something.
- return rv;
- }
- }
- };
- MountableFileSystem.prototype.readdir = function readdir (p, cb) {
- var this$1 = this;
-
- var fsInfo = this._getFs(p);
- fsInfo.fs.readdir(fsInfo.path, function (err, files) {
- if (fsInfo.fs !== this$1.rootFs) {
- try {
- var rv = this$1.rootFs.readdirSync(p);
- if (files) {
- // Filter out duplicates.
- files = files.concat(rv.filter(function (val) { return files.indexOf(val) === -1; }));
- }
- else {
- files = rv;
- }
- }
- catch (e) {
- // Root FS and target FS did not have directory.
- if (err) {
- return cb(this$1.standardizeError(err, fsInfo.path, p));
- }
- }
- }
- else if (err) {
- // Root FS and target FS are the same, and did not have directory.
- return cb(this$1.standardizeError(err, fsInfo.path, p));
- }
- cb(null, files);
- });
- };
- MountableFileSystem.prototype.rmdirSync = function rmdirSync (p) {
- var fsInfo = this._getFs(p);
- if (this._containsMountPt(p)) {
- throw ApiError.ENOTEMPTY(p);
- }
- else {
- try {
- fsInfo.fs.rmdirSync(fsInfo.path);
- }
- catch (e) {
- throw this.standardizeError(e, fsInfo.path, p);
- }
- }
- };
- MountableFileSystem.prototype.rmdir = function rmdir (p, cb) {
- var this$1 = this;
-
- var fsInfo = this._getFs(p);
- if (this._containsMountPt(p)) {
- cb(ApiError.ENOTEMPTY(p));
- }
- else {
- fsInfo.fs.rmdir(fsInfo.path, function (err) {
- cb(err ? this$1.standardizeError(err, fsInfo.path, p) : null);
- });
- }
- };
- /**
- * Returns true if the given path contains a mount point.
- */
- MountableFileSystem.prototype._containsMountPt = function _containsMountPt (p) {
- var mountPoints = this.mountList, len = mountPoints.length;
- for (var i = 0; i < len; i++) {
- var pt = mountPoints[i];
- if (pt.length >= p.length && pt.slice(0, p.length) === p) {
- return true;
- }
- }
- return false;
- };
-
- return MountableFileSystem;
- }(BaseFileSystem));
-
- MountableFileSystem.Name = "MountableFileSystem";
- MountableFileSystem.Options = {};
- /**
- * Tricky: Define all of the functions that merely forward arguments to the
- * relevant file system, or return/throw an error.
- * Take advantage of the fact that the *first* argument is always the path, and
- * the *last* is the callback function (if async).
- * @todo Can use numArgs to make proxying more efficient.
- * @hidden
- */
- function defineFcn(name, isSync, numArgs) {
- if (isSync) {
- return function () {
- var args = [], len = arguments.length;
- while ( len-- ) args[ len ] = arguments[ len ];
-
- var path$$1 = args[0];
- var rv = this._getFs(path$$1);
- args[0] = rv.path;
- try {
- return rv.fs[name].apply(rv.fs, args);
- }
- catch (e) {
- this.standardizeError(e, rv.path, path$$1);
- throw e;
- }
- };
- }
- else {
- return function () {
- var this$1 = this;
- var args = [], len = arguments.length;
- while ( len-- ) args[ len ] = arguments[ len ];
-
- var path$$1 = args[0];
- var rv = this._getFs(path$$1);
- args[0] = rv.path;
- if (typeof args[args.length - 1] === 'function') {
- var cb = args[args.length - 1];
- args[args.length - 1] = function () {
- var args = [], len = arguments.length;
- while ( len-- ) args[ len ] = arguments[ len ];
-
- if (args.length > 0 && args[0] instanceof ApiError) {
- this$1.standardizeError(args[0], rv.path, path$$1);
- }
- cb.apply(null, args);
- };
- }
- return rv.fs[name].apply(rv.fs, args);
- };
- }
- }
- /**
- * @hidden
- */
- var fsCmdMap = [
- // 1 arg functions
- ['exists', 'unlink', 'readlink'],
- // 2 arg functions
- ['stat', 'mkdir', 'realpath', 'truncate'],
- // 3 arg functions
- ['open', 'readFile', 'chmod', 'utimes'],
- // 4 arg functions
- ['chown'],
- // 5 arg functions
- ['writeFile', 'appendFile']
- ];
- for (var i = 0; i < fsCmdMap.length; i++) {
- var cmds = fsCmdMap[i];
- for (var i$1 = 0, list = cmds; i$1 < list.length; i$1 += 1) {
- var fnName = list[i$1];
-
- MountableFileSystem.prototype[fnName] = defineFcn(fnName, false, i + 1);
- MountableFileSystem.prototype[fnName + 'Sync'] = defineFcn(fnName + 'Sync', true, i + 1);
- }
- }
-
- /**
- * @hidden
- */
- var bfsSetImmediate;
- if (typeof (setImmediate) !== "undefined") {
- bfsSetImmediate = setImmediate;
- }
- else {
- var gScope = global$1;
- var timeouts = [];
- var messageName = "zero-timeout-message";
- var canUsePostMessage = function () {
- if (typeof gScope.importScripts !== 'undefined' || !gScope.postMessage) {
- return false;
- }
- var postMessageIsAsync = true;
- var oldOnMessage = gScope.onmessage;
- gScope.onmessage = function () {
- postMessageIsAsync = false;
- };
- gScope.postMessage('', '*');
- gScope.onmessage = oldOnMessage;
- return postMessageIsAsync;
- };
- if (canUsePostMessage()) {
- bfsSetImmediate = function (fn) {
- timeouts.push(fn);
- gScope.postMessage(messageName, "*");
- };
- var handleMessage = function (event) {
- if (event.source === self && event.data === messageName) {
- if (event.stopPropagation) {
- event.stopPropagation();
- }
- else {
- event.cancelBubble = true;
- }
- if (timeouts.length > 0) {
- var fn = timeouts.shift();
- return fn();
- }
- }
- };
- if (gScope.addEventListener) {
- gScope.addEventListener('message', handleMessage, true);
- }
- else {
- gScope.attachEvent('onmessage', handleMessage);
- }
- }
- else if (gScope.MessageChannel) {
- // WebWorker MessageChannel
- var channel = new gScope.MessageChannel();
- channel.port1.onmessage = function (event) {
- if (timeouts.length > 0) {
- return timeouts.shift()();
- }
- };
- bfsSetImmediate = function (fn) {
- timeouts.push(fn);
- channel.port2.postMessage('');
- };
- }
- else {
- bfsSetImmediate = function (fn) {
- return setTimeout(fn, 0);
- };
- }
- }
- var setImmediate$3 = bfsSetImmediate;
-
- /**
- * Non-recursive mutex
- * @hidden
- */
- var Mutex = function Mutex() {
- this._locked = false;
- this._waiters = [];
- };
- Mutex.prototype.lock = function lock (cb) {
- if (this._locked) {
- this._waiters.push(cb);
- return;
- }
- this._locked = true;
- cb();
- };
- Mutex.prototype.unlock = function unlock () {
- if (!this._locked) {
- throw new Error('unlock of a non-locked mutex');
- }
- var next = this._waiters.shift();
- // don't unlock - we want to queue up next for the
- // _end_ of the current task execution, but we don't
- // want it to be called inline with whatever the
- // current stack is. This way we still get the nice
- // behavior that an unlock immediately followed by a
- // lock won't cause starvation.
- if (next) {
- setImmediate$3(next);
- return;
- }
- this._locked = false;
- };
- Mutex.prototype.tryLock = function tryLock () {
- if (this._locked) {
- return false;
- }
- this._locked = true;
- return true;
- };
- Mutex.prototype.isLocked = function isLocked () {
- return this._locked;
- };
-
- /**
- * This class serializes access to an underlying async filesystem.
- * For example, on an OverlayFS instance with an async lower
- * directory operations like rename and rmdir may involve multiple
- * requests involving both the upper and lower filesystems -- they
- * are not executed in a single atomic step. OverlayFS uses this
- * LockedFS to avoid having to reason about the correctness of
- * multiple requests interleaving.
- */
- var LockedFS = function LockedFS(fs) {
- this._fs = fs;
- this._mu = new Mutex();
- };
- LockedFS.prototype.getName = function getName () {
- return 'LockedFS<' + this._fs.getName() + '>';
- };
- LockedFS.prototype.getFSUnlocked = function getFSUnlocked () {
- return this._fs;
- };
- LockedFS.prototype.initialize = function initialize (cb) {
- // FIXME: check to see if FS supports initialization
- this._fs.initialize(cb);
- };
- LockedFS.prototype.diskSpace = function diskSpace (p, cb) {
- // FIXME: should this lock?
- this._fs.diskSpace(p, cb);
- };
- LockedFS.prototype.isReadOnly = function isReadOnly () {
- return this._fs.isReadOnly();
- };
- LockedFS.prototype.supportsLinks = function supportsLinks () {
- return this._fs.supportsLinks();
- };
- LockedFS.prototype.supportsProps = function supportsProps () {
- return this._fs.supportsProps();
- };
- LockedFS.prototype.supportsSynch = function supportsSynch () {
- return this._fs.supportsSynch();
- };
- LockedFS.prototype.rename = function rename (oldPath, newPath, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.rename(oldPath, newPath, function (err) {
- this$1._mu.unlock();
- cb(err);
- });
- });
- };
- LockedFS.prototype.renameSync = function renameSync (oldPath, newPath) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.renameSync(oldPath, newPath);
- };
- LockedFS.prototype.stat = function stat (p, isLstat, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.stat(p, isLstat, function (err, stat) {
- this$1._mu.unlock();
- cb(err, stat);
- });
- });
- };
- LockedFS.prototype.statSync = function statSync (p, isLstat) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.statSync(p, isLstat);
- };
- LockedFS.prototype.open = function open (p, flag, mode, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.open(p, flag, mode, function (err, fd) {
- this$1._mu.unlock();
- cb(err, fd);
- });
- });
- };
- LockedFS.prototype.openSync = function openSync (p, flag, mode) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.openSync(p, flag, mode);
- };
- LockedFS.prototype.unlink = function unlink (p, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.unlink(p, function (err) {
- this$1._mu.unlock();
- cb(err);
- });
- });
- };
- LockedFS.prototype.unlinkSync = function unlinkSync (p) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.unlinkSync(p);
- };
- LockedFS.prototype.rmdir = function rmdir (p, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.rmdir(p, function (err) {
- this$1._mu.unlock();
- cb(err);
- });
- });
- };
- LockedFS.prototype.rmdirSync = function rmdirSync (p) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.rmdirSync(p);
- };
- LockedFS.prototype.mkdir = function mkdir (p, mode, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.mkdir(p, mode, function (err) {
- this$1._mu.unlock();
- cb(err);
- });
- });
- };
- LockedFS.prototype.mkdirSync = function mkdirSync (p, mode) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.mkdirSync(p, mode);
- };
- LockedFS.prototype.readdir = function readdir (p, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.readdir(p, function (err, files) {
- this$1._mu.unlock();
- cb(err, files);
- });
- });
- };
- LockedFS.prototype.readdirSync = function readdirSync (p) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.readdirSync(p);
- };
- LockedFS.prototype.exists = function exists (p, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.exists(p, function (exists) {
- this$1._mu.unlock();
- cb(exists);
- });
- });
- };
- LockedFS.prototype.existsSync = function existsSync (p) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.existsSync(p);
- };
- LockedFS.prototype.realpath = function realpath (p, cache, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.realpath(p, cache, function (err, resolvedPath) {
- this$1._mu.unlock();
- cb(err, resolvedPath);
- });
- });
- };
- LockedFS.prototype.realpathSync = function realpathSync (p, cache) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.realpathSync(p, cache);
- };
- LockedFS.prototype.truncate = function truncate (p, len, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.truncate(p, len, function (err) {
- this$1._mu.unlock();
- cb(err);
- });
- });
- };
- LockedFS.prototype.truncateSync = function truncateSync (p, len) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.truncateSync(p, len);
- };
- LockedFS.prototype.readFile = function readFile (fname, encoding, flag, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.readFile(fname, encoding, flag, function (err, data) {
- this$1._mu.unlock();
- cb(err, data);
- });
- });
- };
- LockedFS.prototype.readFileSync = function readFileSync (fname, encoding, flag) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.readFileSync(fname, encoding, flag);
- };
- LockedFS.prototype.writeFile = function writeFile (fname, data, encoding, flag, mode, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.writeFile(fname, data, encoding, flag, mode, function (err) {
- this$1._mu.unlock();
- cb(err);
- });
- });
- };
- LockedFS.prototype.writeFileSync = function writeFileSync (fname, data, encoding, flag, mode) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.writeFileSync(fname, data, encoding, flag, mode);
- };
- LockedFS.prototype.appendFile = function appendFile (fname, data, encoding, flag, mode, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.appendFile(fname, data, encoding, flag, mode, function (err) {
- this$1._mu.unlock();
- cb(err);
- });
- });
- };
- LockedFS.prototype.appendFileSync = function appendFileSync (fname, data, encoding, flag, mode) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.appendFileSync(fname, data, encoding, flag, mode);
- };
- LockedFS.prototype.chmod = function chmod (p, isLchmod, mode, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.chmod(p, isLchmod, mode, function (err) {
- this$1._mu.unlock();
- cb(err);
- });
- });
- };
- LockedFS.prototype.chmodSync = function chmodSync (p, isLchmod, mode) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.chmodSync(p, isLchmod, mode);
- };
- LockedFS.prototype.chown = function chown (p, isLchown, uid, gid, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.chown(p, isLchown, uid, gid, function (err) {
- this$1._mu.unlock();
- cb(err);
- });
- });
- };
- LockedFS.prototype.chownSync = function chownSync (p, isLchown, uid, gid) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.chownSync(p, isLchown, uid, gid);
- };
- LockedFS.prototype.utimes = function utimes (p, atime, mtime, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.utimes(p, atime, mtime, function (err) {
- this$1._mu.unlock();
- cb(err);
- });
- });
- };
- LockedFS.prototype.utimesSync = function utimesSync (p, atime, mtime) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.utimesSync(p, atime, mtime);
- };
- LockedFS.prototype.link = function link (srcpath, dstpath, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.link(srcpath, dstpath, function (err) {
- this$1._mu.unlock();
- cb(err);
- });
- });
- };
- LockedFS.prototype.linkSync = function linkSync (srcpath, dstpath) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.linkSync(srcpath, dstpath);
- };
- LockedFS.prototype.symlink = function symlink (srcpath, dstpath, type, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.symlink(srcpath, dstpath, type, function (err) {
- this$1._mu.unlock();
- cb(err);
- });
- });
- };
- LockedFS.prototype.symlinkSync = function symlinkSync (srcpath, dstpath, type) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.symlinkSync(srcpath, dstpath, type);
- };
- LockedFS.prototype.readlink = function readlink (p, cb) {
- var this$1 = this;
-
- this._mu.lock(function () {
- this$1._fs.readlink(p, function (err, linkString) {
- this$1._mu.unlock();
- cb(err, linkString);
- });
- });
- };
- LockedFS.prototype.readlinkSync = function readlinkSync (p) {
- if (this._mu.isLocked()) {
- throw new Error('invalid sync call');
- }
- return this._fs.readlinkSync(p);
- };
-
- /**
- * @hidden
- */
- var deletionLogPath = '/.deletedFiles.log';
- /**
- * Given a read-only mode, makes it writable.
- * @hidden
- */
- function makeModeWritable(mode) {
- return 146 | mode;
- }
- /**
- * @hidden
- */
- function getFlag(f) {
- return FileFlag.getFileFlag(f);
- }
- /**
- * Overlays a RO file to make it writable.
- */
- var OverlayFile = (function (PreloadFile$$1) {
- function OverlayFile(fs, path$$1, flag, stats, data) {
- PreloadFile$$1.call(this, fs, path$$1, flag, stats, data);
- }
-
- if ( PreloadFile$$1 ) OverlayFile.__proto__ = PreloadFile$$1;
- OverlayFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );
- OverlayFile.prototype.constructor = OverlayFile;
- OverlayFile.prototype.sync = function sync (cb) {
- var this$1 = this;
-
- if (!this.isDirty()) {
- cb(null);
- return;
- }
- this._fs._syncAsync(this, function (err) {
- this$1.resetDirty();
- cb(err);
- });
- };
- OverlayFile.prototype.syncSync = function syncSync () {
- if (this.isDirty()) {
- this._fs._syncSync(this);
- this.resetDirty();
- }
- };
- OverlayFile.prototype.close = function close (cb) {
- this.sync(cb);
- };
- OverlayFile.prototype.closeSync = function closeSync () {
- this.syncSync();
- };
-
- return OverlayFile;
- }(PreloadFile));
- /**
- * *INTERNAL, DO NOT USE DIRECTLY!*
- *
- * Core OverlayFS class that contains no locking whatsoever. We wrap these objects
- * in a LockedFS to prevent races.
- */
- var UnlockedOverlayFS = (function (BaseFileSystem$$1) {
- function UnlockedOverlayFS(writable, readable) {
- BaseFileSystem$$1.call(this);
- this._isInitialized = false;
- this._initializeCallbacks = [];
- this._deletedFiles = {};
- this._deleteLog = '';
- // If 'true', we have scheduled a delete log update.
- this._deleteLogUpdatePending = false;
- // If 'true', a delete log update is needed after the scheduled delete log
- // update finishes.
- this._deleteLogUpdateNeeded = false;
- // If there was an error updating the delete log...
- this._deleteLogError = null;
- this._writable = writable;
- this._readable = readable;
- if (this._writable.isReadOnly()) {
- throw new ApiError(ErrorCode.EINVAL, "Writable file system must be writable.");
- }
- }
-
- if ( BaseFileSystem$$1 ) UnlockedOverlayFS.__proto__ = BaseFileSystem$$1;
- UnlockedOverlayFS.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );
- UnlockedOverlayFS.prototype.constructor = UnlockedOverlayFS;
- UnlockedOverlayFS.isAvailable = function isAvailable () {
- return true;
- };
- UnlockedOverlayFS.prototype.getOverlayedFileSystems = function getOverlayedFileSystems () {
- return {
- readable: this._readable,
- writable: this._writable
- };
- };
- UnlockedOverlayFS.prototype._syncAsync = function _syncAsync (file, cb) {
- var this$1 = this;
-
- this.createParentDirectoriesAsync(file.getPath(), function (err) {
- if (err) {
- return cb(err);
- }
- this$1._writable.writeFile(file.getPath(), file.getBuffer(), null, getFlag('w'), file.getStats().mode, cb);
- });
- };
- UnlockedOverlayFS.prototype._syncSync = function _syncSync (file) {
- this.createParentDirectories(file.getPath());
- this._writable.writeFileSync(file.getPath(), file.getBuffer(), null, getFlag('w'), file.getStats().mode);
- };
- UnlockedOverlayFS.prototype.getName = function getName () {
- return OverlayFS.Name;
- };
- /**
- * Called once to load up metadata stored on the writable file system.
- */
- UnlockedOverlayFS.prototype.initialize = function initialize (cb) {
- var this$1 = this;
-
- var callbackArray = this._initializeCallbacks;
- var end = function (e) {
- this$1._isInitialized = !e;
- this$1._initializeCallbacks = [];
- callbackArray.forEach((function (cb) { return cb(e); }));
- };
- // if we're already initialized, immediately invoke the callback
- if (this._isInitialized) {
- return cb();
- }
- callbackArray.push(cb);
- // The first call to initialize initializes, the rest wait for it to complete.
- if (callbackArray.length !== 1) {
- return;
- }
- // Read deletion log, process into metadata.
- this._writable.readFile(deletionLogPath, 'utf8', getFlag('r'), function (err, data) {
- if (err) {
- // ENOENT === Newly-instantiated file system, and thus empty log.
- if (err.errno !== ErrorCode.ENOENT) {
- return end(err);
- }
- }
- else {
- this$1._deleteLog = data;
- }
- this$1._reparseDeletionLog();
- end();
- });
- };
- UnlockedOverlayFS.prototype.isReadOnly = function isReadOnly () { return false; };
- UnlockedOverlayFS.prototype.supportsSynch = function supportsSynch () { return this._readable.supportsSynch() && this._writable.supportsSynch(); };
- UnlockedOverlayFS.prototype.supportsLinks = function supportsLinks () { return false; };
- UnlockedOverlayFS.prototype.supportsProps = function supportsProps () { return this._readable.supportsProps() && this._writable.supportsProps(); };
- UnlockedOverlayFS.prototype.getDeletionLog = function getDeletionLog () {
- return this._deleteLog;
- };
- UnlockedOverlayFS.prototype.restoreDeletionLog = function restoreDeletionLog (log) {
- this._deleteLog = log;
- this._reparseDeletionLog();
- this.updateLog('');
- };
- UnlockedOverlayFS.prototype.rename = function rename (oldPath, newPath, cb) {
- var this$1 = this;
-
- if (!this.checkInitAsync(cb) || this.checkPathAsync(oldPath, cb) || this.checkPathAsync(newPath, cb)) {
- return;
- }
- if (oldPath === deletionLogPath || newPath === deletionLogPath) {
- return cb(ApiError.EPERM('Cannot rename deletion log.'));
- }
- // nothing to do if paths match
- if (oldPath === newPath) {
- return cb();
- }
- this.stat(oldPath, false, function (oldErr, oldStats) {
- if (oldErr) {
- return cb(oldErr);
- }
- return this$1.stat(newPath, false, function (newErr, newStats) {
- var self = this$1;
- // precondition: both oldPath and newPath exist and are dirs.
- // decreases: |files|
- // Need to move *every file/folder* currently stored on
- // readable to its new location on writable.
- function copyDirContents(files) {
- var file = files.shift();
- if (!file) {
- return cb();
- }
- var oldFile = path.resolve(oldPath, file);
- var newFile = path.resolve(newPath, file);
- // Recursion! Should work for any nested files / folders.
- self.rename(oldFile, newFile, function (err) {
- if (err) {
- return cb(err);
- }
- copyDirContents(files);
- });
- }
- var mode = 511;
- // from linux's rename(2) manpage: oldpath can specify a
- // directory. In this case, newpath must either not exist, or
- // it must specify an empty directory.
- if (oldStats.isDirectory()) {
- if (newErr) {
- if (newErr.errno !== ErrorCode.ENOENT) {
- return cb(newErr);
- }
- return this$1._writable.exists(oldPath, function (exists) {
- // simple case - both old and new are on the writable layer
- if (exists) {
- return this$1._writable.rename(oldPath, newPath, cb);
- }
- this$1._writable.mkdir(newPath, mode, function (mkdirErr) {
- if (mkdirErr) {
- return cb(mkdirErr);
- }
- this$1._readable.readdir(oldPath, function (err, files) {
- if (err) {
- return cb();
- }
- copyDirContents(files);
- });
- });
- });
- }
- mode = newStats.mode;
- if (!newStats.isDirectory()) {
- return cb(ApiError.ENOTDIR(newPath));
- }
- this$1.readdir(newPath, function (readdirErr, files) {
- if (files && files.length) {
- return cb(ApiError.ENOTEMPTY(newPath));
- }
- this$1._readable.readdir(oldPath, function (err, files) {
- if (err) {
- return cb();
- }
- copyDirContents(files);
- });
- });
- }
- if (newStats && newStats.isDirectory()) {
- return cb(ApiError.EISDIR(newPath));
- }
- this$1.readFile(oldPath, null, getFlag('r'), function (err, data) {
- if (err) {
- return cb(err);
- }
- return this$1.writeFile(newPath, data, null, getFlag('w'), oldStats.mode, function (err) {
- if (err) {
- return cb(err);
- }
- return this$1.unlink(oldPath, cb);
- });
- });
- });
- });
- };
- UnlockedOverlayFS.prototype.renameSync = function renameSync (oldPath, newPath) {
- var this$1 = this;
-
- this.checkInitialized();
- this.checkPath(oldPath);
- this.checkPath(newPath);
- if (oldPath === deletionLogPath || newPath === deletionLogPath) {
- throw ApiError.EPERM('Cannot rename deletion log.');
- }
- // Write newPath using oldPath's contents, delete oldPath.
- var oldStats = this.statSync(oldPath, false);
- if (oldStats.isDirectory()) {
- // Optimization: Don't bother moving if old === new.
- if (oldPath === newPath) {
- return;
- }
- var mode = 511;
- if (this.existsSync(newPath)) {
- var stats = this.statSync(newPath, false);
- mode = stats.mode;
- if (stats.isDirectory()) {
- if (this.readdirSync(newPath).length > 0) {
- throw ApiError.ENOTEMPTY(newPath);
- }
- }
- else {
- throw ApiError.ENOTDIR(newPath);
- }
- }
- // Take care of writable first. Move any files there, or create an empty directory
- // if it doesn't exist.
- if (this._writable.existsSync(oldPath)) {
- this._writable.renameSync(oldPath, newPath);
- }
- else if (!this._writable.existsSync(newPath)) {
- this._writable.mkdirSync(newPath, mode);
- }
- // Need to move *every file/folder* currently stored on readable to its new location
- // on writable.
- if (this._readable.existsSync(oldPath)) {
- this._readable.readdirSync(oldPath).forEach(function (name) {
- // Recursion! Should work for any nested files / folders.
- this$1.renameSync(path.resolve(oldPath, name), path.resolve(newPath, name));
- });
- }
- }
- else {
- if (this.existsSync(newPath) && this.statSync(newPath, false).isDirectory()) {
- throw ApiError.EISDIR(newPath);
- }
- this.writeFileSync(newPath, this.readFileSync(oldPath, null, getFlag('r')), null, getFlag('w'), oldStats.mode);
- }
- if (oldPath !== newPath && this.existsSync(oldPath)) {
- this.unlinkSync(oldPath);
- }
- };
- UnlockedOverlayFS.prototype.stat = function stat (p, isLstat, cb) {
- var this$1 = this;
-
- if (!this.checkInitAsync(cb)) {
- return;
- }
- this._writable.stat(p, isLstat, function (err, stat) {
- if (err && err.errno === ErrorCode.ENOENT) {
- if (this$1._deletedFiles[p]) {
- cb(ApiError.ENOENT(p));
- }
- this$1._readable.stat(p, isLstat, function (err, stat) {
- if (stat) {
- // Make the oldStat's mode writable. Preserve the topmost
- // part of the mode, which specifies if it is a file or a
- // directory.
- stat = stat.clone();
- stat.mode = makeModeWritable(stat.mode);
- }
- cb(err, stat);
- });
- }
- else {
- cb(err, stat);
- }
- });
- };
- UnlockedOverlayFS.prototype.statSync = function statSync (p, isLstat) {
- this.checkInitialized();
- try {
- return this._writable.statSync(p, isLstat);
- }
- catch (e) {
- if (this._deletedFiles[p]) {
- throw ApiError.ENOENT(p);
- }
- var oldStat = this._readable.statSync(p, isLstat).clone();
- // Make the oldStat's mode writable. Preserve the topmost part of the
- // mode, which specifies if it is a file or a directory.
- oldStat.mode = makeModeWritable(oldStat.mode);
- return oldStat;
- }
- };
- UnlockedOverlayFS.prototype.open = function open (p, flag, mode, cb) {
- var this$1 = this;
-
- if (!this.checkInitAsync(cb) || this.checkPathAsync(p, cb)) {
- return;
- }
- this.stat(p, false, function (err, stats) {
- if (stats) {
- switch (flag.pathExistsAction()) {
- case ActionType.TRUNCATE_FILE:
- return this$1.createParentDirectoriesAsync(p, function (err) {
- if (err) {
- return cb(err);
- }
- this$1._writable.open(p, flag, mode, cb);
- });
- case ActionType.NOP:
- return this$1._writable.exists(p, function (exists) {
- if (exists) {
- this$1._writable.open(p, flag, mode, cb);
- }
- else {
- // at this point we know the stats object we got is from
- // the readable FS.
- stats = stats.clone();
- stats.mode = mode;
- this$1._readable.readFile(p, null, getFlag('r'), function (readFileErr, data) {
- if (readFileErr) {
- return cb(readFileErr);
- }
- if (stats.size === -1) {
- stats.size = data.length;
- }
- var f = new OverlayFile(this$1, p, flag, stats, data);
- cb(null, f);
- });
- }
- });
- default:
- return cb(ApiError.EEXIST(p));
- }
- }
- else {
- switch (flag.pathNotExistsAction()) {
- case ActionType.CREATE_FILE:
- return this$1.createParentDirectoriesAsync(p, function (err) {
- if (err) {
- return cb(err);
- }
- return this$1._writable.open(p, flag, mode, cb);
- });
- default:
- return cb(ApiError.ENOENT(p));
- }
- }
- });
- };
- UnlockedOverlayFS.prototype.openSync = function openSync (p, flag, mode) {
- this.checkInitialized();
- this.checkPath(p);
- if (p === deletionLogPath) {
- throw ApiError.EPERM('Cannot open deletion log.');
- }
- if (this.existsSync(p)) {
- switch (flag.pathExistsAction()) {
- case ActionType.TRUNCATE_FILE:
- this.createParentDirectories(p);
- return this._writable.openSync(p, flag, mode);
- case ActionType.NOP:
- if (this._writable.existsSync(p)) {
- return this._writable.openSync(p, flag, mode);
- }
- else {
- // Create an OverlayFile.
- var buf = this._readable.readFileSync(p, null, getFlag('r'));
- var stats = this._readable.statSync(p, false).clone();
- stats.mode = mode;
- return new OverlayFile(this, p, flag, stats, buf);
- }
- default:
- throw ApiError.EEXIST(p);
- }
- }
- else {
- switch (flag.pathNotExistsAction()) {
- case ActionType.CREATE_FILE:
- this.createParentDirectories(p);
- return this._writable.openSync(p, flag, mode);
- default:
- throw ApiError.ENOENT(p);
- }
- }
- };
- UnlockedOverlayFS.prototype.unlink = function unlink (p, cb) {
- var this$1 = this;
-
- if (!this.checkInitAsync(cb) || this.checkPathAsync(p, cb)) {
- return;
- }
- this.exists(p, function (exists) {
- if (!exists) {
- return cb(ApiError.ENOENT(p));
- }
- this$1._writable.exists(p, function (writableExists) {
- if (writableExists) {
- return this$1._writable.unlink(p, function (err) {
- if (err) {
- return cb(err);
- }
- this$1.exists(p, function (readableExists) {
- if (readableExists) {
- this$1.deletePath(p);
- }
- cb(null);
- });
- });
- }
- else {
- // if this only exists on the readable FS, add it to the
- // delete map.
- this$1.deletePath(p);
- cb(null);
- }
- });
- });
- };
- UnlockedOverlayFS.prototype.unlinkSync = function unlinkSync (p) {
- this.checkInitialized();
- this.checkPath(p);
- if (this.existsSync(p)) {
- if (this._writable.existsSync(p)) {
- this._writable.unlinkSync(p);
- }
- // if it still exists add to the delete log
- if (this.existsSync(p)) {
- this.deletePath(p);
- }
- }
- else {
- throw ApiError.ENOENT(p);
- }
- };
- UnlockedOverlayFS.prototype.rmdir = function rmdir (p, cb) {
- var this$1 = this;
-
- if (!this.checkInitAsync(cb)) {
- return;
- }
- var rmdirLower = function () {
- this$1.readdir(p, function (err, files) {
- if (err) {
- return cb(err);
- }
- if (files.length) {
- return cb(ApiError.ENOTEMPTY(p));
- }
- this$1.deletePath(p);
- cb(null);
- });
- };
- this.exists(p, function (exists) {
- if (!exists) {
- return cb(ApiError.ENOENT(p));
- }
- this$1._writable.exists(p, function (writableExists) {
- if (writableExists) {
- this$1._writable.rmdir(p, function (err) {
- if (err) {
- return cb(err);
- }
- this$1._readable.exists(p, function (readableExists) {
- if (readableExists) {
- rmdirLower();
- }
- else {
- cb();
- }
- });
- });
- }
- else {
- rmdirLower();
- }
- });
- });
- };
- UnlockedOverlayFS.prototype.rmdirSync = function rmdirSync (p) {
- this.checkInitialized();
- if (this.existsSync(p)) {
- if (this._writable.existsSync(p)) {
- this._writable.rmdirSync(p);
- }
- if (this.existsSync(p)) {
- // Check if directory is empty.
- if (this.readdirSync(p).length > 0) {
- throw ApiError.ENOTEMPTY(p);
- }
- else {
- this.deletePath(p);
- }
- }
- }
- else {
- throw ApiError.ENOENT(p);
- }
- };
- UnlockedOverlayFS.prototype.mkdir = function mkdir (p, mode, cb) {
- var this$1 = this;
-
- if (!this.checkInitAsync(cb)) {
- return;
- }
- this.exists(p, function (exists) {
- if (exists) {
- return cb(ApiError.EEXIST(p));
- }
- // The below will throw should any of the parent directories
- // fail to exist on _writable.
- this$1.createParentDirectoriesAsync(p, function (err) {
- if (err) {
- return cb(err);
- }
- this$1._writable.mkdir(p, mode, cb);
- });
- });
- };
- UnlockedOverlayFS.prototype.mkdirSync = function mkdirSync (p, mode) {
- this.checkInitialized();
- if (this.existsSync(p)) {
- throw ApiError.EEXIST(p);
- }
- else {
- // The below will throw should any of the parent directories fail to exist
- // on _writable.
- this.createParentDirectories(p);
- this._writable.mkdirSync(p, mode);
- }
- };
- UnlockedOverlayFS.prototype.readdir = function readdir (p, cb) {
- var this$1 = this;
-
- if (!this.checkInitAsync(cb)) {
- return;
- }
- this.stat(p, false, function (err, dirStats) {
- if (err) {
- return cb(err);
- }
- if (!dirStats.isDirectory()) {
- return cb(ApiError.ENOTDIR(p));
- }
- this$1._writable.readdir(p, function (err, wFiles) {
- if (err && err.code !== 'ENOENT') {
- return cb(err);
- }
- else if (err || !wFiles) {
- wFiles = [];
- }
- this$1._readable.readdir(p, function (err, rFiles) {
- // if the directory doesn't exist on the lower FS set rFiles
- // here to simplify the following code.
- if (err || !rFiles) {
- rFiles = [];
- }
- // Readdir in both, check delete log on read-only file system's files, merge, return.
- var seenMap = {};
- var filtered = wFiles.concat(rFiles.filter(function (fPath) { return !this$1._deletedFiles[(p + "/" + fPath)]; })).filter(function (fPath) {
- // Remove duplicates.
- var result = !seenMap[fPath];
- seenMap[fPath] = true;
- return result;
- });
- cb(null, filtered);
- });
- });
- });
- };
- UnlockedOverlayFS.prototype.readdirSync = function readdirSync (p) {
- var this$1 = this;
-
- this.checkInitialized();
- var dirStats = this.statSync(p, false);
- if (!dirStats.isDirectory()) {
- throw ApiError.ENOTDIR(p);
- }
- // Readdir in both, check delete log on RO file system's listing, merge, return.
- var contents = [];
- try {
- contents = contents.concat(this._writable.readdirSync(p));
- }
- catch (e) {
- // NOP.
- }
- try {
- contents = contents.concat(this._readable.readdirSync(p).filter(function (fPath) { return !this$1._deletedFiles[(p + "/" + fPath)]; }));
- }
- catch (e) {
- // NOP.
- }
- var seenMap = {};
- return contents.filter(function (fileP) {
- var result = !seenMap[fileP];
- seenMap[fileP] = true;
- return result;
- });
- };
- UnlockedOverlayFS.prototype.exists = function exists (p, cb) {
- var this$1 = this;
-
- // Cannot pass an error back to callback, so throw an exception instead
- // if not initialized.
- this.checkInitialized();
- this._writable.exists(p, function (existsWritable) {
- if (existsWritable) {
- return cb(true);
- }
- this$1._readable.exists(p, function (existsReadable) {
- cb(existsReadable && this$1._deletedFiles[p] !== true);
- });
- });
- };
- UnlockedOverlayFS.prototype.existsSync = function existsSync (p) {
- this.checkInitialized();
- return this._writable.existsSync(p) || (this._readable.existsSync(p) && this._deletedFiles[p] !== true);
- };
- UnlockedOverlayFS.prototype.chmod = function chmod (p, isLchmod, mode, cb) {
- var this$1 = this;
-
- if (!this.checkInitAsync(cb)) {
- return;
- }
- this.operateOnWritableAsync(p, function (err) {
- if (err) {
- return cb(err);
- }
- else {
- this$1._writable.chmod(p, isLchmod, mode, cb);
- }
- });
- };
- UnlockedOverlayFS.prototype.chmodSync = function chmodSync (p, isLchmod, mode) {
- var this$1 = this;
-
- this.checkInitialized();
- this.operateOnWritable(p, function () {
- this$1._writable.chmodSync(p, isLchmod, mode);
- });
- };
- UnlockedOverlayFS.prototype.chown = function chown (p, isLchmod, uid, gid, cb) {
- var this$1 = this;
-
- if (!this.checkInitAsync(cb)) {
- return;
- }
- this.operateOnWritableAsync(p, function (err) {
- if (err) {
- return cb(err);
- }
- else {
- this$1._writable.chown(p, isLchmod, uid, gid, cb);
- }
- });
- };
- UnlockedOverlayFS.prototype.chownSync = function chownSync (p, isLchown, uid, gid) {
- var this$1 = this;
-
- this.checkInitialized();
- this.operateOnWritable(p, function () {
- this$1._writable.chownSync(p, isLchown, uid, gid);
- });
- };
- UnlockedOverlayFS.prototype.utimes = function utimes (p, atime, mtime, cb) {
- var this$1 = this;
-
- if (!this.checkInitAsync(cb)) {
- return;
- }
- this.operateOnWritableAsync(p, function (err) {
- if (err) {
- return cb(err);
- }
- else {
- this$1._writable.utimes(p, atime, mtime, cb);
- }
- });
- };
- UnlockedOverlayFS.prototype.utimesSync = function utimesSync (p, atime, mtime) {
- var this$1 = this;
-
- this.checkInitialized();
- this.operateOnWritable(p, function () {
- this$1._writable.utimesSync(p, atime, mtime);
- });
- };
- UnlockedOverlayFS.prototype.deletePath = function deletePath (p) {
- this._deletedFiles[p] = true;
- this.updateLog(("d" + p + "\n"));
- };
- UnlockedOverlayFS.prototype.updateLog = function updateLog (addition) {
- var this$1 = this;
-
- this._deleteLog += addition;
- if (this._deleteLogUpdatePending) {
- this._deleteLogUpdateNeeded = true;
- }
- else {
- this._deleteLogUpdatePending = true;
- this._writable.writeFile(deletionLogPath, this._deleteLog, 'utf8', FileFlag.getFileFlag('w'), 420, function (e) {
- this$1._deleteLogUpdatePending = false;
- if (e) {
- this$1._deleteLogError = e;
- }
- else if (this$1._deleteLogUpdateNeeded) {
- this$1._deleteLogUpdateNeeded = false;
- this$1.updateLog('');
- }
- });
- }
- };
- UnlockedOverlayFS.prototype._reparseDeletionLog = function _reparseDeletionLog () {
- var this$1 = this;
-
- this._deletedFiles = {};
- this._deleteLog.split('\n').forEach(function (path$$1) {
- // If the log entry begins w/ 'd', it's a deletion.
- this$1._deletedFiles[path$$1.slice(1)] = path$$1.slice(0, 1) === 'd';
- });
- };
- UnlockedOverlayFS.prototype.checkInitialized = function checkInitialized () {
- if (!this._isInitialized) {
- throw new ApiError(ErrorCode.EPERM, "OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.");
- }
- else if (this._deleteLogError !== null) {
- var e = this._deleteLogError;
- this._deleteLogError = null;
- throw e;
- }
- };
- UnlockedOverlayFS.prototype.checkInitAsync = function checkInitAsync (cb) {
- if (!this._isInitialized) {
- cb(new ApiError(ErrorCode.EPERM, "OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it."));
- return false;
- }
- else if (this._deleteLogError !== null) {
- var e = this._deleteLogError;
- this._deleteLogError = null;
- cb(e);
- return false;
- }
- return true;
- };
- UnlockedOverlayFS.prototype.checkPath = function checkPath (p) {
- if (p === deletionLogPath) {
- throw ApiError.EPERM(p);
- }
- };
- UnlockedOverlayFS.prototype.checkPathAsync = function checkPathAsync (p, cb) {
- if (p === deletionLogPath) {
- cb(ApiError.EPERM(p));
- return true;
- }
- return false;
- };
- UnlockedOverlayFS.prototype.createParentDirectoriesAsync = function createParentDirectoriesAsync (p, cb) {
- var parent = path.dirname(p);
- var toCreate = [];
- var self = this;
- this._writable.stat(parent, false, statDone);
- function statDone(err, stat) {
- if (err) {
- toCreate.push(parent);
- parent = path.dirname(parent);
- self._writable.stat(parent, false, statDone);
- }
- else {
- createParents();
- }
- }
- function createParents() {
- if (!toCreate.length) {
- return cb();
- }
- var dir = toCreate.pop();
- self._readable.stat(dir, false, function (err, stats) {
- // stop if we couldn't read the dir
- if (!stats) {
- return cb();
- }
- self._writable.mkdir(dir, stats.mode, function (err) {
- if (err) {
- return cb(err);
- }
- createParents();
- });
- });
- }
- };
- /**
- * With the given path, create the needed parent directories on the writable storage
- * should they not exist. Use modes from the read-only storage.
- */
- UnlockedOverlayFS.prototype.createParentDirectories = function createParentDirectories (p) {
- var this$1 = this;
-
- var parent = path.dirname(p), toCreate = [];
- while (!this._writable.existsSync(parent)) {
- toCreate.push(parent);
- parent = path.dirname(parent);
- }
- toCreate = toCreate.reverse();
- toCreate.forEach(function (p) {
- this$1._writable.mkdirSync(p, this$1.statSync(p, false).mode);
- });
- };
- /**
- * Helper function:
- * - Ensures p is on writable before proceeding. Throws an error if it doesn't exist.
- * - Calls f to perform operation on writable.
- */
- UnlockedOverlayFS.prototype.operateOnWritable = function operateOnWritable (p, f) {
- if (this.existsSync(p)) {
- if (!this._writable.existsSync(p)) {
- // File is on readable storage. Copy to writable storage before
- // changing its mode.
- this.copyToWritable(p);
- }
- f();
- }
- else {
- throw ApiError.ENOENT(p);
- }
- };
- UnlockedOverlayFS.prototype.operateOnWritableAsync = function operateOnWritableAsync (p, cb) {
- var this$1 = this;
-
- this.exists(p, function (exists) {
- if (!exists) {
- return cb(ApiError.ENOENT(p));
- }
- this$1._writable.exists(p, function (existsWritable) {
- if (existsWritable) {
- cb();
- }
- else {
- return this$1.copyToWritableAsync(p, cb);
- }
- });
- });
- };
- /**
- * Copy from readable to writable storage.
- * PRECONDITION: File does not exist on writable storage.
- */
- UnlockedOverlayFS.prototype.copyToWritable = function copyToWritable (p) {
- var pStats = this.statSync(p, false);
- if (pStats.isDirectory()) {
- this._writable.mkdirSync(p, pStats.mode);
- }
- else {
- this.writeFileSync(p, this._readable.readFileSync(p, null, getFlag('r')), null, getFlag('w'), this.statSync(p, false).mode);
- }
- };
- UnlockedOverlayFS.prototype.copyToWritableAsync = function copyToWritableAsync (p, cb) {
- var this$1 = this;
-
- this.stat(p, false, function (err, pStats) {
- if (err) {
- return cb(err);
- }
- if (pStats.isDirectory()) {
- return this$1._writable.mkdir(p, pStats.mode, cb);
- }
- // need to copy file.
- this$1._readable.readFile(p, null, getFlag('r'), function (err, data) {
- if (err) {
- return cb(err);
- }
- this$1.writeFile(p, data, null, getFlag('w'), pStats.mode, cb);
- });
- });
- };
-
- return UnlockedOverlayFS;
- }(BaseFileSystem));
- /**
- * OverlayFS makes a read-only filesystem writable by storing writes on a second,
- * writable file system. Deletes are persisted via metadata stored on the writable
- * file system.
- */
- var OverlayFS = (function (LockedFS$$1) {
- function OverlayFS(writable, readable, deprecateMsg) {
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- LockedFS$$1.call(this, new UnlockedOverlayFS(writable, readable));
- deprecationMessage(deprecateMsg, OverlayFS.Name, { readable: "readable file system", writable: "writable file system" });
- }
-
- if ( LockedFS$$1 ) OverlayFS.__proto__ = LockedFS$$1;
- OverlayFS.prototype = Object.create( LockedFS$$1 && LockedFS$$1.prototype );
- OverlayFS.prototype.constructor = OverlayFS;
- /**
- * Constructs and initializes an OverlayFS instance with the given options.
- */
- OverlayFS.Create = function Create (opts, cb) {
- try {
- var fs = new OverlayFS(opts.writable, opts.readable, false);
- fs.initialize(function (e) {
- cb(e, fs);
- }, false);
- }
- catch (e) {
- cb(e);
- }
- };
- OverlayFS.isAvailable = function isAvailable () {
- return UnlockedOverlayFS.isAvailable();
- };
- /**
- * **Deprecated. Please use OverlayFS.Create() to construct and initialize OverlayFS instances.**
- */
- OverlayFS.prototype.initialize = function initialize (cb, deprecateMsg) {
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- if (deprecateMsg) {
- console.warn("[OverlayFS] OverlayFS.initialize() is deprecated and will be removed in the next major release. Please use 'OverlayFS.Create({readable: readable file system instance, writable: writable file system instance}, cb)' to create and initialize OverlayFS instances.");
- }
- LockedFS$$1.prototype.initialize.call(this, cb);
- };
- OverlayFS.prototype.getOverlayedFileSystems = function getOverlayedFileSystems () {
- return LockedFS$$1.prototype.getFSUnlocked.call(this).getOverlayedFileSystems();
- };
- OverlayFS.prototype.unwrap = function unwrap () {
- return LockedFS$$1.prototype.getFSUnlocked.call(this);
- };
-
- return OverlayFS;
- }(LockedFS));
-
- OverlayFS.Name = "OverlayFS";
- OverlayFS.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."
- }
- };
-
- /**
- * @hidden
- */
- var SpecialArgType;
- (function (SpecialArgType) {
- // Callback
- SpecialArgType[SpecialArgType["CB"] = 0] = "CB";
- // File descriptor
- SpecialArgType[SpecialArgType["FD"] = 1] = "FD";
- // API error
- SpecialArgType[SpecialArgType["API_ERROR"] = 2] = "API_ERROR";
- // Stats object
- SpecialArgType[SpecialArgType["STATS"] = 3] = "STATS";
- // Initial probe for file system information.
- SpecialArgType[SpecialArgType["PROBE"] = 4] = "PROBE";
- // FileFlag object.
- SpecialArgType[SpecialArgType["FILEFLAG"] = 5] = "FILEFLAG";
- // Buffer object.
- SpecialArgType[SpecialArgType["BUFFER"] = 6] = "BUFFER";
- // Generic Error object.
- SpecialArgType[SpecialArgType["ERROR"] = 7] = "ERROR";
- })(SpecialArgType || (SpecialArgType = {}));
- /**
- * Converts callback arguments into ICallbackArgument objects, and back
- * again.
- * @hidden
- */
- var CallbackArgumentConverter = function CallbackArgumentConverter() {
- this._callbacks = {};
- this._nextId = 0;
- };
- CallbackArgumentConverter.prototype.toRemoteArg = function toRemoteArg (cb) {
- var id = this._nextId++;
- this._callbacks[id] = cb;
- return {
- type: SpecialArgType.CB,
- id: id
- };
- };
- CallbackArgumentConverter.prototype.toLocalArg = function toLocalArg (id) {
- var cb = this._callbacks[id];
- delete this._callbacks[id];
- return cb;
- };
- /**
- * @hidden
- */
- var FileDescriptorArgumentConverter = function FileDescriptorArgumentConverter() {
- this._fileDescriptors = {};
- this._nextId = 0;
- };
- FileDescriptorArgumentConverter.prototype.toRemoteArg = function toRemoteArg (fd, p, flag, cb) {
- var id = this._nextId++;
- var data;
- var stat;
- this._fileDescriptors[id] = fd;
- // Extract needed information asynchronously.
- fd.stat(function (err, stats) {
- if (err) {
- cb(err);
- }
- else {
- stat = bufferToTransferrableObject(stats.toBuffer());
- // If it's a readable flag, we need to grab contents.
- if (flag.isReadable()) {
- fd.read(Buffer.alloc(stats.size), 0, stats.size, 0, function (err, bytesRead, buff) {
- if (err) {
- cb(err);
- }
- else {
- data = bufferToTransferrableObject(buff);
- cb(null, {
- type: SpecialArgType.FD,
- id: id,
- data: data,
- stat: stat,
- path: p,
- flag: flag.getFlagString()
- });
- }
- });
- }
- else {
- // File is not readable, which means writing to it will append or
- // truncate/replace existing contents. Return an empty arraybuffer.
- cb(null, {
- type: SpecialArgType.FD,
- id: id,
- data: new ArrayBuffer(0),
- stat: stat,
- path: p,
- flag: flag.getFlagString()
- });
- }
- }
- });
- };
- FileDescriptorArgumentConverter.prototype.applyFdAPIRequest = function applyFdAPIRequest (request, cb) {
- var this$1 = this;
-
- var fdArg = request.args[0];
- this._applyFdChanges(fdArg, function (err, fd) {
- if (err) {
- cb(err);
- }
- else {
- // Apply method on now-changed file descriptor.
- fd[request.method](function (e) {
- if (request.method === 'close') {
- delete this$1._fileDescriptors[fdArg.id];
- }
- cb(e);
- });
- }
- });
- };
- FileDescriptorArgumentConverter.prototype._applyFdChanges = function _applyFdChanges (remoteFd, cb) {
- var fd = this._fileDescriptors[remoteFd.id], data = transferrableObjectToBuffer(remoteFd.data), remoteStats = Stats.fromBuffer(transferrableObjectToBuffer(remoteFd.stat));
- // Write data if the file is writable.
- var flag = FileFlag.getFileFlag(remoteFd.flag);
- if (flag.isWriteable()) {
- // Appendable: Write to end of file.
- // Writeable: Replace entire contents of file.
- fd.write(data, 0, data.length, flag.isAppendable() ? fd.getPos() : 0, function (e) {
- function applyStatChanges() {
- // Check if mode changed.
- fd.stat(function (e, stats) {
- if (e) {
- cb(e);
- }
- else {
- if (stats.mode !== remoteStats.mode) {
- fd.chmod(remoteStats.mode, function (e) {
- cb(e, fd);
- });
- }
- else {
- cb(e, fd);
- }
- }
- });
- }
- if (e) {
- cb(e);
- }
- else {
- // If writeable & not appendable, we need to ensure file contents are
- // identical to those from the remote FD. Thus, we truncate to the
- // length of the remote file.
- if (!flag.isAppendable()) {
- fd.truncate(data.length, function () {
- applyStatChanges();
- });
- }
- else {
- applyStatChanges();
- }
- }
- });
- }
- else {
- cb(null, fd);
- }
- };
- /**
- * @hidden
- */
- function apiErrorLocal2Remote(e) {
- return {
- type: SpecialArgType.API_ERROR,
- errorData: bufferToTransferrableObject(e.writeToBuffer())
- };
- }
- /**
- * @hidden
- */
- function apiErrorRemote2Local(e) {
- return ApiError.fromBuffer(transferrableObjectToBuffer(e.errorData));
- }
- /**
- * @hidden
- */
- function errorLocal2Remote(e) {
- return {
- type: SpecialArgType.ERROR,
- name: e.name,
- message: e.message,
- stack: e.stack
- };
- }
- /**
- * @hidden
- */
- function errorRemote2Local(e) {
- var cnstr = global$1[e.name];
- if (typeof (cnstr) !== 'function') {
- cnstr = Error;
- }
- var err = new cnstr(e.message);
- err.stack = e.stack;
- return err;
- }
- /**
- * @hidden
- */
- function statsLocal2Remote(stats) {
- return {
- type: SpecialArgType.STATS,
- statsData: bufferToTransferrableObject(stats.toBuffer())
- };
- }
- /**
- * @hidden
- */
- function statsRemote2Local(stats) {
- return Stats.fromBuffer(transferrableObjectToBuffer(stats.statsData));
- }
- /**
- * @hidden
- */
- function fileFlagLocal2Remote(flag) {
- return {
- type: SpecialArgType.FILEFLAG,
- flagStr: flag.getFlagString()
- };
- }
- /**
- * @hidden
- */
- function fileFlagRemote2Local(remoteFlag) {
- return FileFlag.getFileFlag(remoteFlag.flagStr);
- }
- /**
- * @hidden
- */
- function bufferToTransferrableObject(buff) {
- return buffer2ArrayBuffer(buff);
- }
- /**
- * @hidden
- */
- function transferrableObjectToBuffer(buff) {
- return arrayBuffer2Buffer(buff);
- }
- /**
- * @hidden
- */
- function bufferLocal2Remote(buff) {
- return {
- type: SpecialArgType.BUFFER,
- data: bufferToTransferrableObject(buff)
- };
- }
- /**
- * @hidden
- */
- function bufferRemote2Local(buffArg) {
- return transferrableObjectToBuffer(buffArg.data);
- }
- /**
- * @hidden
- */
- function isAPIRequest(data) {
- return data && typeof data === 'object' && data.hasOwnProperty('browserfsMessage') && data['browserfsMessage'];
- }
- /**
- * @hidden
- */
- function isAPIResponse(data) {
- return data && typeof data === 'object' && data.hasOwnProperty('browserfsMessage') && data['browserfsMessage'];
- }
- /**
- * Represents a remote file in a different worker/thread.
- */
- var WorkerFile = (function (PreloadFile$$1) {
- function WorkerFile(_fs, _path, _flag, _stat, remoteFdId, contents) {
- PreloadFile$$1.call(this, _fs, _path, _flag, _stat, contents);
- this._remoteFdId = remoteFdId;
- }
-
- if ( PreloadFile$$1 ) WorkerFile.__proto__ = PreloadFile$$1;
- WorkerFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );
- WorkerFile.prototype.constructor = WorkerFile;
- WorkerFile.prototype.getRemoteFdId = function getRemoteFdId () {
- return this._remoteFdId;
- };
- /**
- * @hidden
- */
- WorkerFile.prototype.toRemoteArg = function toRemoteArg () {
- return {
- type: SpecialArgType.FD,
- id: this._remoteFdId,
- data: bufferToTransferrableObject(this.getBuffer()),
- stat: bufferToTransferrableObject(this.getStats().toBuffer()),
- path: this.getPath(),
- flag: this.getFlag().getFlagString()
- };
- };
- WorkerFile.prototype.sync = function sync (cb) {
- this._syncClose('sync', cb);
- };
- WorkerFile.prototype.close = function close (cb) {
- this._syncClose('close', cb);
- };
- WorkerFile.prototype._syncClose = function _syncClose (type, cb) {
- var this$1 = this;
-
- if (this.isDirty()) {
- this._fs.syncClose(type, this, function (e) {
- if (!e) {
- this$1.resetDirty();
- }
- cb(e);
- });
- }
- else {
- cb();
- }
- };
-
- return WorkerFile;
- }(PreloadFile));
- /**
- * WorkerFS lets you access a BrowserFS instance that is running in a different
- * JavaScript context (e.g. access BrowserFS in one of your WebWorkers, or
- * access BrowserFS running on the main page from a WebWorker).
- *
- * For example, to have a WebWorker access files in the main browser thread,
- * do the following:
- *
- * MAIN BROWSER THREAD:
- *
- * ```javascript
- * // Listen for remote file system requests.
- * BrowserFS.FileSystem.WorkerFS.attachRemoteListener(webWorkerObject);
- * ```
- *
- * WEBWORKER THREAD:
- *
- * ```javascript
- * // Set the remote file system as the root file system.
- * BrowserFS.configure({ fs: "WorkerFS", options: { worker: self }}, function(e) {
- * // Ready!
- * });
- * ```
- *
- * Note that synchronous operations are not permitted on the WorkerFS, regardless
- * of the configuration option of the remote FS.
- */
- var WorkerFS = (function (BaseFileSystem$$1) {
- function WorkerFS(worker, deprecateMsg) {
- var this$1 = this;
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- BaseFileSystem$$1.call(this);
- this._callbackConverter = new CallbackArgumentConverter();
- this._isInitialized = false;
- this._isReadOnly = false;
- this._supportLinks = false;
- this._supportProps = false;
- this._worker = worker;
- deprecationMessage(deprecateMsg, WorkerFS.Name, { worker: "Web Worker instance" });
- this._worker.addEventListener('message', function (e) {
- var resp = e.data;
- if (isAPIResponse(resp)) {
- var i;
- var args = resp.args;
- var fixedArgs = new Array(args.length);
- // Dispatch event to correct id.
- for (i = 0; i < fixedArgs.length; i++) {
- fixedArgs[i] = this$1._argRemote2Local(args[i]);
- }
- this$1._callbackConverter.toLocalArg(resp.cbId).apply(null, fixedArgs);
- }
- });
- }
-
- if ( BaseFileSystem$$1 ) WorkerFS.__proto__ = BaseFileSystem$$1;
- WorkerFS.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );
- WorkerFS.prototype.constructor = WorkerFS;
- WorkerFS.Create = function Create (opts, cb) {
- var fs = new WorkerFS(opts.worker, false);
- fs.initialize(function () {
- cb(null, fs);
- });
- };
- WorkerFS.isAvailable = function isAvailable () {
- return typeof (importScripts) !== 'undefined' || typeof (Worker) !== 'undefined';
- };
- /**
- * Attaches a listener to the remote worker for file system requests.
- */
- WorkerFS.attachRemoteListener = function attachRemoteListener (worker) {
- var fdConverter = new FileDescriptorArgumentConverter();
- function argLocal2Remote(arg, requestArgs, cb) {
- switch (typeof arg) {
- case 'object':
- if (arg instanceof Stats) {
- cb(null, statsLocal2Remote(arg));
- }
- else if (arg instanceof ApiError) {
- cb(null, apiErrorLocal2Remote(arg));
- }
- else if (arg instanceof BaseFile) {
- // Pass in p and flags from original request.
- cb(null, fdConverter.toRemoteArg(arg, requestArgs[0], requestArgs[1], cb));
- }
- else if (arg instanceof FileFlag) {
- cb(null, fileFlagLocal2Remote(arg));
- }
- else if (arg instanceof Buffer) {
- cb(null, bufferLocal2Remote(arg));
- }
- else if (arg instanceof Error) {
- cb(null, errorLocal2Remote(arg));
- }
- else {
- cb(null, arg);
- }
- break;
- default:
- cb(null, arg);
- break;
- }
- }
- function argRemote2Local(arg, fixedRequestArgs) {
- if (!arg) {
- return arg;
- }
- switch (typeof arg) {
- case 'object':
- if (typeof arg['type'] === 'number') {
- var specialArg = arg;
- switch (specialArg.type) {
- case SpecialArgType.CB:
- var cbId = arg.id;
- return function () {
- var arguments$1 = arguments;
-
- var i;
- var fixedArgs = new Array(arguments.length);
- var message, countdown = arguments.length;
- function abortAndSendError(err) {
- if (countdown > 0) {
- countdown = -1;
- message = {
- browserfsMessage: true,
- cbId: cbId,
- args: [apiErrorLocal2Remote(err)]
- };
- worker.postMessage(message);
- }
- }
- for (i = 0; i < arguments.length; i++) {
- // Capture i and argument.
- (function (i, arg) {
- argLocal2Remote(arg, fixedRequestArgs, function (err, fixedArg) {
- fixedArgs[i] = fixedArg;
- if (err) {
- abortAndSendError(err);
- }
- else if (--countdown === 0) {
- message = {
- browserfsMessage: true,
- cbId: cbId,
- args: fixedArgs
- };
- worker.postMessage(message);
- }
- });
- })(i, arguments$1[i]);
- }
- if (arguments.length === 0) {
- message = {
- browserfsMessage: true,
- cbId: cbId,
- args: fixedArgs
- };
- worker.postMessage(message);
- }
- };
- case SpecialArgType.API_ERROR:
- return apiErrorRemote2Local(specialArg);
- case SpecialArgType.STATS:
- return statsRemote2Local(specialArg);
- case SpecialArgType.FILEFLAG:
- return fileFlagRemote2Local(specialArg);
- case SpecialArgType.BUFFER:
- return bufferRemote2Local(specialArg);
- case SpecialArgType.ERROR:
- return errorRemote2Local(specialArg);
- default:
- // No idea what this is.
- return arg;
- }
- }
- else {
- return arg;
- }
- default:
- return arg;
- }
- }
- worker.addEventListener('message', function (e) {
- var request = e.data;
- if (isAPIRequest(request)) {
- var args = request.args, fixedArgs = new Array(args.length);
- switch (request.method) {
- case 'close':
- case 'sync':
- (function () {
- // File descriptor-relative methods.
- var remoteCb = args[1];
- fdConverter.applyFdAPIRequest(request, function (err) {
- // Send response.
- var response = {
- browserfsMessage: true,
- cbId: remoteCb.id,
- args: err ? [apiErrorLocal2Remote(err)] : []
- };
- worker.postMessage(response);
- });
- })();
- break;
- case 'probe':
- (function () {
- var rootFs = _fsMock.getRootFS(), remoteCb = args[1], probeResponse = {
- type: SpecialArgType.PROBE,
- isReadOnly: rootFs.isReadOnly(),
- supportsLinks: rootFs.supportsLinks(),
- supportsProps: rootFs.supportsProps()
- }, response = {
- browserfsMessage: true,
- cbId: remoteCb.id,
- args: [probeResponse]
- };
- worker.postMessage(response);
- })();
- break;
- default:
- // File system methods.
- for (var i = 0; i < args.length; i++) {
- fixedArgs[i] = argRemote2Local(args[i], fixedArgs);
- }
- var rootFS = _fsMock.getRootFS();
- rootFS[request.method].apply(rootFS, fixedArgs);
- break;
- }
- }
- });
- };
- WorkerFS.prototype.getName = function getName () {
- return WorkerFS.Name;
- };
- /**
- * **Deprecated. Please use WorkerFS.Create() method to construct and initialize WorkerFS instances.**
- *
- * Called once both local and remote sides are set up.
- */
- WorkerFS.prototype.initialize = function initialize (cb) {
- var this$1 = this;
-
- if (!this._isInitialized) {
- var message = {
- browserfsMessage: true,
- method: 'probe',
- args: [this._argLocal2Remote(emptyBuffer()), this._callbackConverter.toRemoteArg(function (probeResponse) {
- this$1._isInitialized = true;
- this$1._isReadOnly = probeResponse.isReadOnly;
- this$1._supportLinks = probeResponse.supportsLinks;
- this$1._supportProps = probeResponse.supportsProps;
- cb();
- })]
- };
- this._worker.postMessage(message);
- }
- else {
- cb();
- }
- };
- WorkerFS.prototype.isReadOnly = function isReadOnly () { return this._isReadOnly; };
- WorkerFS.prototype.supportsSynch = function supportsSynch () { return false; };
- WorkerFS.prototype.supportsLinks = function supportsLinks () { return this._supportLinks; };
- WorkerFS.prototype.supportsProps = function supportsProps () { return this._supportProps; };
- WorkerFS.prototype.rename = function rename (oldPath, newPath, cb) {
- this._rpc('rename', arguments);
- };
- WorkerFS.prototype.stat = function stat (p, isLstat, cb) {
- this._rpc('stat', arguments);
- };
- WorkerFS.prototype.open = function open (p, flag, mode, cb) {
- this._rpc('open', arguments);
- };
- WorkerFS.prototype.unlink = function unlink (p, cb) {
- this._rpc('unlink', arguments);
- };
- WorkerFS.prototype.rmdir = function rmdir (p, cb) {
- this._rpc('rmdir', arguments);
- };
- WorkerFS.prototype.mkdir = function mkdir (p, mode, cb) {
- this._rpc('mkdir', arguments);
- };
- WorkerFS.prototype.readdir = function readdir (p, cb) {
- this._rpc('readdir', arguments);
- };
- WorkerFS.prototype.exists = function exists (p, cb) {
- this._rpc('exists', arguments);
- };
- WorkerFS.prototype.realpath = function realpath (p, cache, cb) {
- this._rpc('realpath', arguments);
- };
- WorkerFS.prototype.truncate = function truncate (p, len, cb) {
- this._rpc('truncate', arguments);
- };
- WorkerFS.prototype.readFile = function readFile (fname, encoding, flag, cb) {
- this._rpc('readFile', arguments);
- };
- WorkerFS.prototype.writeFile = function writeFile (fname, data, encoding, flag, mode, cb) {
- this._rpc('writeFile', arguments);
- };
- WorkerFS.prototype.appendFile = function appendFile (fname, data, encoding, flag, mode, cb) {
- this._rpc('appendFile', arguments);
- };
- WorkerFS.prototype.chmod = function chmod (p, isLchmod, mode, cb) {
- this._rpc('chmod', arguments);
- };
- WorkerFS.prototype.chown = function chown (p, isLchown, uid, gid, cb) {
- this._rpc('chown', arguments);
- };
- WorkerFS.prototype.utimes = function utimes (p, atime, mtime, cb) {
- this._rpc('utimes', arguments);
- };
- WorkerFS.prototype.link = function link (srcpath, dstpath, cb) {
- this._rpc('link', arguments);
- };
- WorkerFS.prototype.symlink = function symlink (srcpath, dstpath, type, cb) {
- this._rpc('symlink', arguments);
- };
- WorkerFS.prototype.readlink = function readlink (p, cb) {
- this._rpc('readlink', arguments);
- };
- WorkerFS.prototype.syncClose = function syncClose (method, fd, cb) {
- this._worker.postMessage({
- browserfsMessage: true,
- method: method,
- args: [fd.toRemoteArg(), this._callbackConverter.toRemoteArg(cb)]
- });
- };
- WorkerFS.prototype._argRemote2Local = function _argRemote2Local (arg) {
- if (!arg) {
- return arg;
- }
- switch (typeof arg) {
- case 'object':
- if (typeof arg['type'] === 'number') {
- var specialArg = arg;
- switch (specialArg.type) {
- case SpecialArgType.API_ERROR:
- return apiErrorRemote2Local(specialArg);
- case SpecialArgType.FD:
- var fdArg = specialArg;
- return new WorkerFile(this, fdArg.path, FileFlag.getFileFlag(fdArg.flag), Stats.fromBuffer(transferrableObjectToBuffer(fdArg.stat)), fdArg.id, transferrableObjectToBuffer(fdArg.data));
- case SpecialArgType.STATS:
- return statsRemote2Local(specialArg);
- case SpecialArgType.FILEFLAG:
- return fileFlagRemote2Local(specialArg);
- case SpecialArgType.BUFFER:
- return bufferRemote2Local(specialArg);
- case SpecialArgType.ERROR:
- return errorRemote2Local(specialArg);
- default:
- return arg;
- }
- }
- else {
- return arg;
- }
- default:
- return arg;
- }
- };
- WorkerFS.prototype._rpc = function _rpc (methodName, args) {
- var this$1 = this;
-
- var fixedArgs = new Array(args.length);
- for (var i = 0; i < args.length; i++) {
- fixedArgs[i] = this$1._argLocal2Remote(args[i]);
- }
- var message = {
- browserfsMessage: true,
- method: methodName,
- args: fixedArgs
- };
- this._worker.postMessage(message);
- };
- /**
- * Converts a local argument into a remote argument. Public so WorkerFile objects can call it.
- */
- WorkerFS.prototype._argLocal2Remote = function _argLocal2Remote (arg) {
- if (!arg) {
- return arg;
- }
- switch (typeof arg) {
- case "object":
- if (arg instanceof Stats) {
- return statsLocal2Remote(arg);
- }
- else if (arg instanceof ApiError) {
- return apiErrorLocal2Remote(arg);
- }
- else if (arg instanceof WorkerFile) {
- return arg.toRemoteArg();
- }
- else if (arg instanceof FileFlag) {
- return fileFlagLocal2Remote(arg);
- }
- else if (arg instanceof Buffer) {
- return bufferLocal2Remote(arg);
- }
- else if (arg instanceof Error) {
- return errorLocal2Remote(arg);
- }
- else {
- return "Unknown argument";
- }
- case "function":
- return this._callbackConverter.toRemoteArg(arg);
- default:
- return arg;
- }
- };
-
- return WorkerFS;
- }(BaseFileSystem));
-
- WorkerFS.Name = "WorkerFS";
- WorkerFS.Options = {
- worker: {
- type: "object",
- description: "The target worker that you want to connect to, or the current worker if in a worker context.",
- validator: function (v, cb) {
- // Check for a `postMessage` function.
- if (v['postMessage']) {
- cb();
- }
- else {
- cb(new ApiError(ErrorCode.EINVAL, "option must be a Web Worker instance."));
- }
- }
- }
- };
-
- /**
- * Contains utility methods for performing a variety of tasks with
- * XmlHttpRequest across browsers.
- */
- function asyncDownloadFileModern(p, type, cb) {
- var req = new XMLHttpRequest();
- req.open('GET', p, true);
- var jsonSupported = true;
- switch (type) {
- case 'buffer':
- req.responseType = 'arraybuffer';
- break;
- case 'json':
- // Some browsers don't support the JSON response type.
- // They either reset responseType, or throw an exception.
- // @see https://github.com/Modernizr/Modernizr/blob/master/src/testXhrType.js
- try {
- req.responseType = 'json';
- jsonSupported = req.responseType === 'json';
- }
- catch (e) {
- jsonSupported = false;
- }
- break;
- default:
- return cb(new ApiError(ErrorCode.EINVAL, "Invalid download type: " + type));
- }
- req.onreadystatechange = function (e) {
- if (req.readyState === 4) {
- if (req.status === 200) {
- switch (type) {
- case 'buffer':
- // XXX: WebKit-based browsers return *null* when XHRing an empty file.
- return cb(null, req.response ? Buffer.from(req.response) : emptyBuffer());
- case 'json':
- if (jsonSupported) {
- return cb(null, req.response);
- }
- else {
- return cb(null, JSON.parse(req.responseText));
- }
- }
- }
- else {
- return cb(new ApiError(req.status, "XHR error."));
- }
- }
- };
- req.send();
- }
- function syncDownloadFileModern(p, type) {
- var req = new XMLHttpRequest();
- req.open('GET', p, false);
- // On most platforms, we cannot set the responseType of synchronous downloads.
- // @todo Test for this; IE10 allows this, as do older versions of Chrome/FF.
- var data = null;
- var err = null;
- // Classic hack to download binary data as a string.
- req.overrideMimeType('text/plain; charset=x-user-defined');
- req.onreadystatechange = function (e) {
- if (req.readyState === 4) {
- if (req.status === 200) {
- switch (type) {
- case 'buffer':
- // Convert the text into a buffer.
- var text = req.responseText;
- data = Buffer.alloc(text.length);
- // Throw away the upper bits of each character.
- for (var i = 0; i < text.length; i++) {
- // This will automatically throw away the upper bit of each
- // character for us.
- data[i] = text.charCodeAt(i);
- }
- return;
- case 'json':
- data = JSON.parse(req.responseText);
- return;
- }
- }
- else {
- err = new ApiError(req.status, "XHR error.");
- return;
- }
- }
- };
- req.send();
- if (err) {
- throw err;
- }
- return data;
- }
- function syncDownloadFileIE10(p, type) {
- var req = new XMLHttpRequest();
- req.open('GET', p, false);
- switch (type) {
- case 'buffer':
- req.responseType = 'arraybuffer';
- break;
- case 'json':
- // IE10 does not support the JSON type.
- break;
- default:
- throw new ApiError(ErrorCode.EINVAL, "Invalid download type: " + type);
- }
- var data;
- var err;
- req.onreadystatechange = function (e) {
- if (req.readyState === 4) {
- if (req.status === 200) {
- switch (type) {
- case 'buffer':
- data = Buffer.from(req.response);
- break;
- case 'json':
- data = JSON.parse(req.response);
- break;
- }
- }
- else {
- err = new ApiError(req.status, "XHR error.");
- }
- }
- };
- req.send();
- if (err) {
- throw err;
- }
- return data;
- }
- /**
- * @hidden
- */
- function getFileSize(async, p, cb) {
- var req = new XMLHttpRequest();
- req.open('HEAD', p, async);
- req.onreadystatechange = function (e) {
- if (req.readyState === 4) {
- if (req.status === 200) {
- try {
- return cb(null, parseInt(req.getResponseHeader('Content-Length') || '-1', 10));
- }
- catch (e) {
- // In the event that the header isn't present or there is an error...
- return cb(new ApiError(ErrorCode.EIO, "XHR HEAD error: Could not read content-length."));
- }
- }
- else {
- return cb(new ApiError(req.status, "XHR HEAD error."));
- }
- }
- };
- req.send();
- }
- /**
- * Asynchronously download a file as a buffer or a JSON object.
- * Note that the third function signature with a non-specialized type is
- * invalid, but TypeScript requires it when you specialize string arguments to
- * constants.
- * @hidden
- */
- var asyncDownloadFile = asyncDownloadFileModern;
- /**
- * Synchronously download a file as a buffer or a JSON object.
- * Note that the third function signature with a non-specialized type is
- * invalid, but TypeScript requires it when you specialize string arguments to
- * constants.
- * @hidden
- */
- var syncDownloadFile = (isIE && typeof Blob !== 'undefined') ? syncDownloadFileIE10 : syncDownloadFileModern;
- /**
- * Synchronously retrieves the size of the given file in bytes.
- * @hidden
- */
- function getFileSizeSync(p) {
- var rv = -1;
- getFileSize(false, p, function (err, size) {
- if (err) {
- throw err;
- }
- rv = size;
- });
- return rv;
- }
- /**
- * Asynchronously retrieves the size of the given file in bytes.
- * @hidden
- */
- function getFileSizeAsync(p, cb) {
- getFileSize(true, p, cb);
- }
-
- /**
- * A simple class for storing a filesystem index. Assumes that all paths passed
- * to it are *absolute* paths.
- *
- * Can be used as a partial or a full index, although care must be taken if used
- * for the former purpose, especially when directories are concerned.
- */
- var FileIndex = function FileIndex() {
- // _index is a single-level key,value store that maps *directory* paths to
- // DirInodes. File information is only contained in DirInodes themselves.
- this._index = {};
- // Create the root directory.
- this.addPath('/', new DirInode());
- };
- /**
- * Static method for constructing indices from a JSON listing.
- * @param listing Directory listing generated by tools/XHRIndexer.coffee
- * @return A new FileIndex object.
- */
- FileIndex.fromListing = function fromListing (listing) {
- var idx = new FileIndex();
- // Add a root DirNode.
- var rootInode = new DirInode();
- idx._index['/'] = rootInode;
- var queue = [['', listing, rootInode]];
- while (queue.length > 0) {
- var inode = (void 0);
- var next = queue.pop();
- var pwd = next[0];
- var tree = next[1];
- var parent = next[2];
- for (var node in tree) {
- if (tree.hasOwnProperty(node)) {
- var children = tree[node];
- var name = pwd + "/" + node;
- if (children) {
- idx._index[name] = inode = new DirInode();
- queue.push([name, children, inode]);
- }
- else {
- // This inode doesn't have correct size information, noted with -1.
- inode = new FileInode(new Stats(FileType.FILE, -1, 0x16D));
- }
- if (parent) {
- parent._ls[node] = inode;
- }
- }
- }
- }
- return idx;
- };
- /**
- * Runs the given function over all files in the index.
- */
- FileIndex.prototype.fileIterator = function fileIterator (cb) {
- var this$1 = this;
-
- for (var path$$1 in this$1._index) {
- if (this$1._index.hasOwnProperty(path$$1)) {
- var dir = this$1._index[path$$1];
- var files = dir.getListing();
- for (var i = 0, list = files; i < list.length; i += 1) {
- var file = list[i];
-
- var item = dir.getItem(file);
- if (isFileInode(item)) {
- cb(item.getData());
- }
- }
- }
- }
- };
- /**
- * Adds the given absolute path to the index if it is not already in the index.
- * Creates any needed parent directories.
- * @param path The path to add to the index.
- * @param inode The inode for the
- * path to add.
- * @return 'True' if it was added or already exists, 'false' if there
- * was an issue adding it (e.g. item in path is a file, item exists but is
- * different).
- * @todo If adding fails and implicitly creates directories, we do not clean up
- * the new empty directories.
- */
- FileIndex.prototype.addPath = function addPath (path$$1, inode) {
- if (!inode) {
- throw new Error('Inode must be specified');
- }
- if (path$$1[0] !== '/') {
- throw new Error('Path must be absolute, got: ' + path$$1);
- }
- // Check if it already exists.
- if (this._index.hasOwnProperty(path$$1)) {
- return this._index[path$$1] === inode;
- }
- var splitPath = this._split_path(path$$1);
- var dirpath = splitPath[0];
- var itemname = splitPath[1];
- // Try to add to its parent directory first.
- var parent = this._index[dirpath];
- if (parent === undefined && path$$1 !== '/') {
- // Create parent.
- parent = new DirInode();
- if (!this.addPath(dirpath, parent)) {
- return false;
- }
- }
- // Add myself to my parent.
- if (path$$1 !== '/') {
- if (!parent.addItem(itemname, inode)) {
- return false;
- }
- }
- // If I'm a directory, add myself to the index.
- if (isDirInode(inode)) {
- this._index[path$$1] = inode;
- }
- return true;
- };
- /**
- * Adds the given absolute path to the index if it is not already in the index.
- * The path is added without special treatment (no joining of adjacent separators, etc).
- * Creates any needed parent directories.
- * @param path The path to add to the index.
- * @param inode The inode for the
- * path to add.
- * @return 'True' if it was added or already exists, 'false' if there
- * was an issue adding it (e.g. item in path is a file, item exists but is
- * different).
- * @todo If adding fails and implicitly creates directories, we do not clean up
- * the new empty directories.
- */
- FileIndex.prototype.addPathFast = function addPathFast (path$$1, inode) {
- var itemNameMark = path$$1.lastIndexOf('/');
- var parentPath = itemNameMark === 0 ? "/" : path$$1.substring(0, itemNameMark);
- var itemName = path$$1.substring(itemNameMark + 1);
- // Try to add to its parent directory first.
- var parent = this._index[parentPath];
- if (parent === undefined) {
- // Create parent.
- parent = new DirInode();
- this.addPathFast(parentPath, parent);
- }
- if (!parent.addItem(itemName, inode)) {
- return false;
- }
- // If adding a directory, add to the index as well.
- if (inode.isDir()) {
- this._index[path$$1] = inode;
- }
- return true;
- };
- /**
- * Removes the given path. Can be a file or a directory.
- * @return The removed item,
- * or null if it did not exist.
- */
- FileIndex.prototype.removePath = function removePath (path$$1) {
- var this$1 = this;
-
- var splitPath = this._split_path(path$$1);
- var dirpath = splitPath[0];
- var itemname = splitPath[1];
- // Try to remove it from its parent directory first.
- var parent = this._index[dirpath];
- if (parent === undefined) {
- return null;
- }
- // Remove myself from my parent.
- var inode = parent.remItem(itemname);
- if (inode === null) {
- return null;
- }
- // If I'm a directory, remove myself from the index, and remove my children.
- if (isDirInode(inode)) {
- var children = inode.getListing();
- for (var i = 0, list = children; i < list.length; i += 1) {
- var child = list[i];
-
- this$1.removePath(path$$1 + '/' + child);
- }
- // Remove the directory from the index, unless it's the root.
- if (path$$1 !== '/') {
- delete this._index[path$$1];
- }
- }
- return inode;
- };
- /**
- * Retrieves the directory listing of the given path.
- * @return An array of files in the given path, or 'null' if it does not exist.
- */
- FileIndex.prototype.ls = function ls (path$$1) {
- var item = this._index[path$$1];
- if (item === undefined) {
- return null;
- }
- return item.getListing();
- };
- /**
- * Returns the inode of the given item.
- * @return Returns null if the item does not exist.
- */
- FileIndex.prototype.getInode = function getInode (path$$1) {
- var splitPath = this._split_path(path$$1);
- var dirpath = splitPath[0];
- var itemname = splitPath[1];
- // Retrieve from its parent directory.
- var parent = this._index[dirpath];
- if (parent === undefined) {
- return null;
- }
- // Root case
- if (dirpath === path$$1) {
- return parent;
- }
- return parent.getItem(itemname);
- };
- /**
- * Split into a (directory path, item name) pair
- */
- FileIndex.prototype._split_path = function _split_path (p) {
- var dirpath = path.dirname(p);
- var itemname = p.substr(dirpath.length + (dirpath === "/" ? 0 : 1));
- return [dirpath, itemname];
- };
- /**
- * Inode for a file. Stores an arbitrary (filesystem-specific) data payload.
- */
- var FileInode = function FileInode(data) {
- this.data = data;
- };
- FileInode.prototype.isFile = function isFile () { return true; };
- FileInode.prototype.isDir = function isDir () { return false; };
- FileInode.prototype.getData = function getData () { return this.data; };
- FileInode.prototype.setData = function setData (data) { this.data = data; };
- /**
- * Inode for a directory. Currently only contains the directory listing.
- */
- var DirInode = function DirInode(data) {
- if ( data === void 0 ) data = null;
-
- this.data = data;
- this._ls = {};
- };
- DirInode.prototype.isFile = function isFile () {
- return false;
- };
- DirInode.prototype.isDir = function isDir () {
- return true;
- };
- DirInode.prototype.getData = function getData () { return this.data; };
- /**
- * Return a Stats object for this inode.
- * @todo Should probably remove this at some point. This isn't the
- * responsibility of the FileIndex.
- */
- DirInode.prototype.getStats = function getStats () {
- return new Stats(FileType.DIRECTORY, 4096, 0x16D);
- };
- /**
- * Returns the directory listing for this directory. Paths in the directory are
- * relative to the directory's path.
- * @return The directory listing for this directory.
- */
- DirInode.prototype.getListing = function getListing () {
- return Object.keys(this._ls);
- };
- /**
- * Returns the inode for the indicated item, or null if it does not exist.
- * @param p Name of item in this directory.
- */
- DirInode.prototype.getItem = function getItem (p) {
- var item = this._ls[p];
- return item ? item : null;
- };
- /**
- * Add the given item to the directory listing. Note that the given inode is
- * not copied, and will be mutated by the DirInode if it is a DirInode.
- * @param p Item name to add to the directory listing.
- * @param inode The inode for the
- * item to add to the directory inode.
- * @return True if it was added, false if it already existed.
- */
- DirInode.prototype.addItem = function addItem (p, inode) {
- if (p in this._ls) {
- return false;
- }
- this._ls[p] = inode;
- return true;
- };
- /**
- * Removes the given item from the directory listing.
- * @param p Name of item to remove from the directory listing.
- * @return Returns the item
- * removed, or null if the item did not exist.
- */
- DirInode.prototype.remItem = function remItem (p) {
- var item = this._ls[p];
- if (item === undefined) {
- return null;
- }
- delete this._ls[p];
- return item;
- };
- /**
- * @hidden
- */
- function isFileInode(inode) {
- return !!inode && inode.isFile();
- }
- /**
- * @hidden
- */
- function isDirInode(inode) {
- return !!inode && inode.isDir();
- }
-
- /**
- * Try to convert the given buffer into a string, and pass it to the callback.
- * Optimization that removes the needed try/catch into a helper function, as
- * this is an uncommon case.
- * @hidden
- */
- function tryToString(buff, encoding, cb) {
- try {
- cb(null, buff.toString(encoding));
- }
- catch (e) {
- cb(e);
- }
- }
- /**
- * A simple filesystem backed by XMLHttpRequests. You must create a directory listing using the
- * `make_xhrfs_index` tool provided by BrowserFS.
- *
- * If you install BrowserFS globally with `npm i -g browserfs`, you can generate a listing by
- * running `make_xhrfs_index` in your terminal in the directory you would like to index:
- *
- * ```
- * make_xhrfs_index > index.json
- * ```
- *
- * Listings objects look like the following:
- *
- * ```json
- * {
- * "home": {
- * "jvilk": {
- * "someFile.txt": null,
- * "someDir": {
- * // Empty directory
- * }
- * }
- * }
- * }
- * ```
- *
- * *This example has the folder `/home/jvilk` with subfile `someFile.txt` and subfolder `someDir`.*
- */
- var XmlHttpRequest = (function (BaseFileSystem$$1) {
- function XmlHttpRequest(listingUrlOrObj, prefixUrl, deprecateMsg) {
- if ( prefixUrl === void 0 ) prefixUrl = '';
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- BaseFileSystem$$1.call(this);
- if (!listingUrlOrObj) {
- listingUrlOrObj = 'index.json';
- }
- // prefix_url must end in a directory separator.
- if (prefixUrl.length > 0 && prefixUrl.charAt(prefixUrl.length - 1) !== '/') {
- prefixUrl = prefixUrl + '/';
- }
- this.prefixUrl = prefixUrl;
- var listing = null;
- if (typeof (listingUrlOrObj) === "string") {
- listing = this._requestFileSync(listingUrlOrObj, 'json');
- if (!listing) {
- throw new Error("Unable to find listing at URL: ${listingUrlOrObj}");
- }
- }
- else {
- listing = listingUrlOrObj;
- }
- deprecationMessage(deprecateMsg, XmlHttpRequest.Name, { index: typeof (listingUrlOrObj) === "string" ? listingUrlOrObj : "file index as an object", baseUrl: prefixUrl });
- this._index = FileIndex.fromListing(listing);
- }
-
- if ( BaseFileSystem$$1 ) XmlHttpRequest.__proto__ = BaseFileSystem$$1;
- XmlHttpRequest.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );
- XmlHttpRequest.prototype.constructor = XmlHttpRequest;
- /**
- * Construct an XmlHttpRequest file system backend with the given options.
- */
- XmlHttpRequest.Create = function Create (opts, cb) {
- if (opts.index === undefined) {
- opts.index = "index.json";
- }
- if (typeof (opts.index) === "string") {
- XmlHttpRequest.FromURL(opts.index, cb, opts.baseUrl, false);
- }
- else {
- cb(null, new XmlHttpRequest(opts.index, opts.baseUrl, false));
- }
- };
- XmlHttpRequest.isAvailable = function isAvailable () {
- return typeof (XMLHttpRequest) !== "undefined" && XMLHttpRequest !== null;
- };
- /**
- * **Deprecated. Please use XmlHttpRequest.Create() method instead to construct XmlHttpRequest objects.**
- *
- * Constructs an XmlHttpRequest object using the directory listing at the given URL.
- * Uses the base URL as the URL prefix for fetched files.
- * @param cb Called when the file system has been instantiated, or if an error occurs.
- */
- XmlHttpRequest.FromURL = function FromURL (url, cb, baseUrl, deprecateMsg) {
- if ( baseUrl === void 0 ) baseUrl = url.slice(0, url.lastIndexOf('/') + 1);
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- if (deprecateMsg) {
- console.warn(("[XmlHttpRequest] XmlHttpRequest.FromURL() is deprecated and will be removed in the next major release. Please use 'XmlHttpRequest.Create({ index: \"" + url + "\", baseUrl: \"" + baseUrl + "\" }, cb)' instead."));
- }
- asyncDownloadFile(url, "json", function (e, data) {
- if (e) {
- cb(e);
- }
- else {
- cb(null, new XmlHttpRequest(data, baseUrl, false));
- }
- });
- };
- XmlHttpRequest.prototype.empty = function empty () {
- this._index.fileIterator(function (file) {
- file.fileData = null;
- });
- };
- XmlHttpRequest.prototype.getName = function getName () {
- return XmlHttpRequest.Name;
- };
- XmlHttpRequest.prototype.diskSpace = function diskSpace (path$$1, cb) {
- // Read-only file system. We could calculate the total space, but that's not
- // important right now.
- cb(0, 0);
- };
- XmlHttpRequest.prototype.isReadOnly = function isReadOnly () {
- return true;
- };
- XmlHttpRequest.prototype.supportsLinks = function supportsLinks () {
- return false;
- };
- XmlHttpRequest.prototype.supportsProps = function supportsProps () {
- return false;
- };
- XmlHttpRequest.prototype.supportsSynch = function supportsSynch () {
- return true;
- };
- /**
- * Special XHR function: Preload the given file into the index.
- * @param [String] path
- * @param [BrowserFS.Buffer] buffer
- */
- XmlHttpRequest.prototype.preloadFile = function preloadFile (path$$1, buffer$$1) {
- var inode = this._index.getInode(path$$1);
- if (isFileInode(inode)) {
- if (inode === null) {
- throw ApiError.ENOENT(path$$1);
- }
- var stats = inode.getData();
- stats.size = buffer$$1.length;
- stats.fileData = buffer$$1;
- }
- else {
- throw ApiError.EISDIR(path$$1);
- }
- };
- XmlHttpRequest.prototype.stat = function stat (path$$1, isLstat, cb) {
- var inode = this._index.getInode(path$$1);
- if (inode === null) {
- return cb(ApiError.ENOENT(path$$1));
- }
- var stats;
- if (isFileInode(inode)) {
- stats = inode.getData();
- // At this point, a non-opened file will still have default stats from the listing.
- if (stats.size < 0) {
- this._requestFileSizeAsync(path$$1, function (e, size) {
- if (e) {
- return cb(e);
- }
- stats.size = size;
- cb(null, stats.clone());
- });
- }
- else {
- cb(null, stats.clone());
- }
- }
- else if (isDirInode(inode)) {
- stats = inode.getStats();
- cb(null, stats);
- }
- else {
- cb(ApiError.FileError(ErrorCode.EINVAL, path$$1));
- }
- };
- XmlHttpRequest.prototype.statSync = function statSync (path$$1, isLstat) {
- var inode = this._index.getInode(path$$1);
- if (inode === null) {
- throw ApiError.ENOENT(path$$1);
- }
- var stats;
- if (isFileInode(inode)) {
- stats = inode.getData();
- // At this point, a non-opened file will still have default stats from the listing.
- if (stats.size < 0) {
- stats.size = this._requestFileSizeSync(path$$1);
- }
- }
- else if (isDirInode(inode)) {
- stats = inode.getStats();
- }
- else {
- throw ApiError.FileError(ErrorCode.EINVAL, path$$1);
- }
- return stats;
- };
- XmlHttpRequest.prototype.open = function open (path$$1, flags, mode, cb) {
- // INVARIANT: You can't write to files on this file system.
- if (flags.isWriteable()) {
- return cb(new ApiError(ErrorCode.EPERM, path$$1));
- }
- var self = this;
- // Check if the path exists, and is a file.
- var inode = this._index.getInode(path$$1);
- if (inode === null) {
- return cb(ApiError.ENOENT(path$$1));
- }
- if (isFileInode(inode)) {
- var stats = inode.getData();
- switch (flags.pathExistsAction()) {
- case ActionType.THROW_EXCEPTION:
- case ActionType.TRUNCATE_FILE:
- return cb(ApiError.EEXIST(path$$1));
- case ActionType.NOP:
- // Use existing file contents.
- // XXX: Uh, this maintains the previously-used flag.
- if (stats.fileData) {
- return cb(null, new NoSyncFile(self, path$$1, flags, stats.clone(), stats.fileData));
- }
- // @todo be lazier about actually requesting the file
- this._requestFileAsync(path$$1, 'buffer', function (err, buffer$$1) {
- if (err) {
- return cb(err);
- }
- // we don't initially have file sizes
- stats.size = buffer$$1.length;
- stats.fileData = buffer$$1;
- return cb(null, new NoSyncFile(self, path$$1, flags, stats.clone(), buffer$$1));
- });
- break;
- default:
- return cb(new ApiError(ErrorCode.EINVAL, 'Invalid FileMode object.'));
- }
- }
- else {
- return cb(ApiError.EISDIR(path$$1));
- }
- };
- XmlHttpRequest.prototype.openSync = function openSync (path$$1, flags, mode) {
- // INVARIANT: You can't write to files on this file system.
- if (flags.isWriteable()) {
- throw new ApiError(ErrorCode.EPERM, path$$1);
- }
- // Check if the path exists, and is a file.
- var inode = this._index.getInode(path$$1);
- if (inode === null) {
- throw ApiError.ENOENT(path$$1);
- }
- if (isFileInode(inode)) {
- var stats = inode.getData();
- switch (flags.pathExistsAction()) {
- case ActionType.THROW_EXCEPTION:
- case ActionType.TRUNCATE_FILE:
- throw ApiError.EEXIST(path$$1);
- case ActionType.NOP:
- // Use existing file contents.
- // XXX: Uh, this maintains the previously-used flag.
- if (stats.fileData) {
- return new NoSyncFile(this, path$$1, flags, stats.clone(), stats.fileData);
- }
- // @todo be lazier about actually requesting the file
- var buffer$$1 = this._requestFileSync(path$$1, 'buffer');
- // we don't initially have file sizes
- stats.size = buffer$$1.length;
- stats.fileData = buffer$$1;
- return new NoSyncFile(this, path$$1, flags, stats.clone(), buffer$$1);
- default:
- throw new ApiError(ErrorCode.EINVAL, 'Invalid FileMode object.');
- }
- }
- else {
- throw ApiError.EISDIR(path$$1);
- }
- };
- XmlHttpRequest.prototype.readdir = function readdir (path$$1, cb) {
- try {
- cb(null, this.readdirSync(path$$1));
- }
- catch (e) {
- cb(e);
- }
- };
- XmlHttpRequest.prototype.readdirSync = function readdirSync (path$$1) {
- // Check if it exists.
- var inode = this._index.getInode(path$$1);
- if (inode === null) {
- throw ApiError.ENOENT(path$$1);
- }
- else if (isDirInode(inode)) {
- return inode.getListing();
- }
- else {
- throw ApiError.ENOTDIR(path$$1);
- }
- };
- /**
- * We have the entire file as a buffer; optimize readFile.
- */
- XmlHttpRequest.prototype.readFile = function readFile (fname, encoding, flag, cb) {
- // Wrap cb in file closing code.
- var oldCb = cb;
- // Get file.
- this.open(fname, flag, 0x1a4, function (err, fd) {
- if (err) {
- return cb(err);
- }
- cb = function (err, arg) {
- fd.close(function (err2) {
- if (!err) {
- err = err2;
- }
- return oldCb(err, arg);
- });
- };
- var fdCast = fd;
- var fdBuff = fdCast.getBuffer();
- if (encoding === null) {
- cb(err, copyingSlice(fdBuff));
- }
- else {
- tryToString(fdBuff, encoding, cb);
- }
- });
- };
- /**
- * Specially-optimized readfile.
- */
- XmlHttpRequest.prototype.readFileSync = function readFileSync (fname, encoding, flag) {
- // Get file.
- var fd = this.openSync(fname, flag, 0x1a4);
- try {
- var fdCast = fd;
- var fdBuff = fdCast.getBuffer();
- if (encoding === null) {
- return copyingSlice(fdBuff);
- }
- return fdBuff.toString(encoding);
- }
- finally {
- fd.closeSync();
- }
- };
- XmlHttpRequest.prototype.getXhrPath = function getXhrPath (filePath) {
- if (filePath.charAt(0) === '/') {
- filePath = filePath.slice(1);
- }
- return this.prefixUrl + filePath;
- };
- XmlHttpRequest.prototype._requestFileAsync = function _requestFileAsync (p, type, cb) {
- asyncDownloadFile(this.getXhrPath(p), type, cb);
- };
- XmlHttpRequest.prototype._requestFileSync = function _requestFileSync (p, type) {
- return syncDownloadFile(this.getXhrPath(p), type);
- };
- /**
- * Only requests the HEAD content, for the file size.
- */
- XmlHttpRequest.prototype._requestFileSizeAsync = function _requestFileSizeAsync (path$$1, cb) {
- getFileSizeAsync(this.getXhrPath(path$$1), cb);
- };
- XmlHttpRequest.prototype._requestFileSizeSync = function _requestFileSizeSync (path$$1) {
- return getFileSizeSync(this.getXhrPath(path$$1));
- };
-
- return XmlHttpRequest;
- }(BaseFileSystem));
-
- XmlHttpRequest.Name = "XmlHttpRequest";
- XmlHttpRequest.Options = {
- index: {
- type: ["string", "object"],
- optional: true,
- description: "URL to a file index as a JSON file or the file index object itself, generated with the make_xhrfs_index script. Defaults to `index.json`."
- },
- baseUrl: {
- type: "string",
- optional: true,
- description: "Used as the URL prefix for fetched files. Default: Fetch files relative to the index."
- }
- };
-
- /**
- * (Nonstandard) String utility function for 8-bit ASCII with the extended
- * character set. Unlike the ASCII above, we do not mask the high bits.
- *
- * Placed into a separate file so it can be used with other Buffer implementations.
- * @see http://en.wikipedia.org/wiki/Extended_ASCII
- */
- /**
- * (Nonstandard) String utility function for 8-bit ASCII with the extended
- * character set. Unlike the ASCII above, we do not mask the high bits.
- *
- * Placed into a separate file so it can be used with other Buffer implementations.
- * @see http://en.wikipedia.org/wiki/Extended_ASCII
- */ var ExtendedASCII = function ExtendedASCII () {};
-
- ExtendedASCII.str2byte = function str2byte (str, buf) {
- var length = str.length > buf.length ? buf.length : str.length;
- for (var i = 0; i < length; i++) {
- var charCode = str.charCodeAt(i);
- if (charCode > 0x7F) {
- // Check if extended ASCII.
- var charIdx = ExtendedASCII.extendedChars.indexOf(str.charAt(i));
- if (charIdx > -1) {
- charCode = charIdx + 0x80;
- }
- // Otherwise, keep it as-is.
- }
- buf[charCode] = i;
- }
- return length;
- };
- ExtendedASCII.byte2str = function byte2str (buff) {
- var chars = new Array(buff.length);
- for (var i = 0; i < buff.length; i++) {
- var charCode = buff[i];
- if (charCode > 0x7F) {
- chars[i] = ExtendedASCII.extendedChars[charCode - 128];
- }
- else {
- chars[i] = String.fromCharCode(charCode);
- }
- }
- return chars.join('');
- };
- ExtendedASCII.byteLength = function byteLength (str) { return str.length; };
-
- ExtendedASCII.extendedChars = ['\u00C7', '\u00FC', '\u00E9', '\u00E2', '\u00E4',
- '\u00E0', '\u00E5', '\u00E7', '\u00EA', '\u00EB', '\u00E8', '\u00EF',
- '\u00EE', '\u00EC', '\u00C4', '\u00C5', '\u00C9', '\u00E6', '\u00C6',
- '\u00F4', '\u00F6', '\u00F2', '\u00FB', '\u00F9', '\u00FF', '\u00D6',
- '\u00DC', '\u00F8', '\u00A3', '\u00D8', '\u00D7', '\u0192', '\u00E1',
- '\u00ED', '\u00F3', '\u00FA', '\u00F1', '\u00D1', '\u00AA', '\u00BA',
- '\u00BF', '\u00AE', '\u00AC', '\u00BD', '\u00BC', '\u00A1', '\u00AB',
- '\u00BB', '_', '_', '_', '\u00A6', '\u00A6', '\u00C1', '\u00C2', '\u00C0',
- '\u00A9', '\u00A6', '\u00A6', '+', '+', '\u00A2', '\u00A5', '+', '+', '-',
- '-', '+', '-', '+', '\u00E3', '\u00C3', '+', '+', '-', '-', '\u00A6', '-',
- '+', '\u00A4', '\u00F0', '\u00D0', '\u00CA', '\u00CB', '\u00C8', 'i',
- '\u00CD', '\u00CE', '\u00CF', '+', '+', '_', '_', '\u00A6', '\u00CC', '_',
- '\u00D3', '\u00DF', '\u00D4', '\u00D2', '\u00F5', '\u00D5', '\u00B5',
- '\u00FE', '\u00DE', '\u00DA', '\u00DB', '\u00D9', '\u00FD', '\u00DD',
- '\u00AF', '\u00B4', '\u00AD', '\u00B1', '_', '\u00BE', '\u00B6', '\u00A7',
- '\u00F7', '\u00B8', '\u00B0', '\u00A8', '\u00B7', '\u00B9', '\u00B3',
- '\u00B2', '_', ' '];
-
- /**
- * @hidden
- */
- var inflateRaw = __webpack_require__(31).inflateRaw;
- /**
- * Maps CompressionMethod => function that decompresses.
- * @hidden
- */
- var decompressionMethods = {};
- /**
- * 4.4.2.2: Indicates the compatibiltiy of a file's external attributes.
- */
- var ExternalFileAttributeType;
- (function (ExternalFileAttributeType) {
- ExternalFileAttributeType[ExternalFileAttributeType["MSDOS"] = 0] = "MSDOS";
- ExternalFileAttributeType[ExternalFileAttributeType["AMIGA"] = 1] = "AMIGA";
- ExternalFileAttributeType[ExternalFileAttributeType["OPENVMS"] = 2] = "OPENVMS";
- ExternalFileAttributeType[ExternalFileAttributeType["UNIX"] = 3] = "UNIX";
- ExternalFileAttributeType[ExternalFileAttributeType["VM_CMS"] = 4] = "VM_CMS";
- ExternalFileAttributeType[ExternalFileAttributeType["ATARI_ST"] = 5] = "ATARI_ST";
- ExternalFileAttributeType[ExternalFileAttributeType["OS2_HPFS"] = 6] = "OS2_HPFS";
- ExternalFileAttributeType[ExternalFileAttributeType["MAC"] = 7] = "MAC";
- ExternalFileAttributeType[ExternalFileAttributeType["Z_SYSTEM"] = 8] = "Z_SYSTEM";
- ExternalFileAttributeType[ExternalFileAttributeType["CP_M"] = 9] = "CP_M";
- ExternalFileAttributeType[ExternalFileAttributeType["NTFS"] = 10] = "NTFS";
- ExternalFileAttributeType[ExternalFileAttributeType["MVS"] = 11] = "MVS";
- ExternalFileAttributeType[ExternalFileAttributeType["VSE"] = 12] = "VSE";
- ExternalFileAttributeType[ExternalFileAttributeType["ACORN_RISC"] = 13] = "ACORN_RISC";
- ExternalFileAttributeType[ExternalFileAttributeType["VFAT"] = 14] = "VFAT";
- ExternalFileAttributeType[ExternalFileAttributeType["ALT_MVS"] = 15] = "ALT_MVS";
- ExternalFileAttributeType[ExternalFileAttributeType["BEOS"] = 16] = "BEOS";
- ExternalFileAttributeType[ExternalFileAttributeType["TANDEM"] = 17] = "TANDEM";
- ExternalFileAttributeType[ExternalFileAttributeType["OS_400"] = 18] = "OS_400";
- ExternalFileAttributeType[ExternalFileAttributeType["OSX"] = 19] = "OSX";
- })(ExternalFileAttributeType || (ExternalFileAttributeType = {}));
- /**
- * 4.4.5
- */
- var CompressionMethod;
- (function (CompressionMethod) {
- CompressionMethod[CompressionMethod["STORED"] = 0] = "STORED";
- CompressionMethod[CompressionMethod["SHRUNK"] = 1] = "SHRUNK";
- CompressionMethod[CompressionMethod["REDUCED_1"] = 2] = "REDUCED_1";
- CompressionMethod[CompressionMethod["REDUCED_2"] = 3] = "REDUCED_2";
- CompressionMethod[CompressionMethod["REDUCED_3"] = 4] = "REDUCED_3";
- CompressionMethod[CompressionMethod["REDUCED_4"] = 5] = "REDUCED_4";
- CompressionMethod[CompressionMethod["IMPLODE"] = 6] = "IMPLODE";
- CompressionMethod[CompressionMethod["DEFLATE"] = 8] = "DEFLATE";
- CompressionMethod[CompressionMethod["DEFLATE64"] = 9] = "DEFLATE64";
- CompressionMethod[CompressionMethod["TERSE_OLD"] = 10] = "TERSE_OLD";
- CompressionMethod[CompressionMethod["BZIP2"] = 12] = "BZIP2";
- CompressionMethod[CompressionMethod["LZMA"] = 14] = "LZMA";
- CompressionMethod[CompressionMethod["TERSE_NEW"] = 18] = "TERSE_NEW";
- CompressionMethod[CompressionMethod["LZ77"] = 19] = "LZ77";
- CompressionMethod[CompressionMethod["WAVPACK"] = 97] = "WAVPACK";
- CompressionMethod[CompressionMethod["PPMD"] = 98] = "PPMD"; // PPMd version I, Rev 1
- })(CompressionMethod || (CompressionMethod = {}));
- /**
- * Converts the input time and date in MS-DOS format into a JavaScript Date
- * object.
- * @hidden
- */
- function msdos2date(time, date) {
- // MS-DOS Date
- // |0 0 0 0 0|0 0 0 0|0 0 0 0 0 0 0
- // D (1-31) M (1-23) Y (from 1980)
- var day = date & 0x1F;
- // JS date is 0-indexed, DOS is 1-indexed.
- var month = ((date >> 5) & 0xF) - 1;
- var year = (date >> 9) + 1980;
- // MS DOS Time
- // |0 0 0 0 0|0 0 0 0 0 0|0 0 0 0 0
- // Second Minute Hour
- var second = time & 0x1F;
- var minute = (time >> 5) & 0x3F;
- var hour = time >> 11;
- return new Date(year, month, day, hour, minute, second);
- }
- /**
- * Safely returns the string from the buffer, even if it is 0 bytes long.
- * (Normally, calling toString() on a buffer with start === end causes an
- * exception).
- * @hidden
- */
- function safeToString(buff, useUTF8, start, length) {
- if (length === 0) {
- return "";
- }
- else if (useUTF8) {
- return buff.toString('utf8', start, start + length);
- }
- else {
- return ExtendedASCII.byte2str(buff.slice(start, start + length));
- }
- }
- /*
- 4.3.6 Overall .ZIP file format:
-
- [local file header 1]
- [encryption header 1]
- [file data 1]
- [data descriptor 1]
- .
- .
- .
- [local file header n]
- [encryption header n]
- [file data n]
- [data descriptor n]
- [archive decryption header]
- [archive extra data record]
- [central directory header 1]
- .
- .
- .
- [central directory header n]
- [zip64 end of central directory record]
- [zip64 end of central directory locator]
- [end of central directory record]
- */
- /**
- * 4.3.7 Local file header:
- *
- * local file header signature 4 bytes (0x04034b50)
- * version needed to extract 2 bytes
- * general purpose bit flag 2 bytes
- * compression method 2 bytes
- * last mod file time 2 bytes
- * last mod file date 2 bytes
- * crc-32 4 bytes
- * compressed size 4 bytes
- * uncompressed size 4 bytes
- * file name length 2 bytes
- * extra field length 2 bytes
- *
- * file name (variable size)
- * extra field (variable size)
- */
- var FileHeader = function FileHeader(data) {
- this.data = data;
- if (data.readUInt32LE(0) !== 0x04034b50) {
- throw new ApiError(ErrorCode.EINVAL, "Invalid Zip file: Local file header has invalid signature: " + this.data.readUInt32LE(0));
- }
- };
- FileHeader.prototype.versionNeeded = function versionNeeded () { return this.data.readUInt16LE(4); };
- FileHeader.prototype.flags = function flags () { return this.data.readUInt16LE(6); };
- FileHeader.prototype.compressionMethod = function compressionMethod () { return this.data.readUInt16LE(8); };
- FileHeader.prototype.lastModFileTime = function lastModFileTime () {
- // Time and date is in MS-DOS format.
- return msdos2date(this.data.readUInt16LE(10), this.data.readUInt16LE(12));
- };
- FileHeader.prototype.rawLastModFileTime = function rawLastModFileTime () {
- return this.data.readUInt32LE(10);
- };
- FileHeader.prototype.crc32 = function crc32 () { return this.data.readUInt32LE(14); };
- /**
- * These two values are COMPLETELY USELESS.
- *
- * Section 4.4.9:
- *If bit 3 of the general purpose bit flag is set,
- *these fields are set to zero in the local header and the
- *correct values are put in the data descriptor and
- *in the central directory.
- *
- * So we'll just use the central directory's values.
- */
- // public compressedSize(): number { return this.data.readUInt32LE(18); }
- // public uncompressedSize(): number { return this.data.readUInt32LE(22); }
- FileHeader.prototype.fileNameLength = function fileNameLength () { return this.data.readUInt16LE(26); };
- FileHeader.prototype.extraFieldLength = function extraFieldLength () { return this.data.readUInt16LE(28); };
- FileHeader.prototype.fileName = function fileName () {
- return safeToString(this.data, this.useUTF8(), 30, this.fileNameLength());
- };
- FileHeader.prototype.extraField = function extraField () {
- var start = 30 + this.fileNameLength();
- return this.data.slice(start, start + this.extraFieldLength());
- };
- FileHeader.prototype.totalSize = function totalSize () { return 30 + this.fileNameLength() + this.extraFieldLength(); };
- FileHeader.prototype.useUTF8 = function useUTF8 () { return (this.flags() & 0x800) === 0x800; };
- /**
- * 4.3.8 File data
- *
- * Immediately following the local header for a file
- * SHOULD be placed the compressed or stored data for the file.
- * If the file is encrypted, the encryption header for the file
- * SHOULD be placed after the local header and before the file
- * data. The series of [local file header][encryption header]
- * [file data][data descriptor] repeats for each file in the
- * .ZIP archive.
- *
- * Zero-byte files, directories, and other file types that
- * contain no content MUST not include file data.
- */
- var FileData = function FileData(header, record, data) {
- this.header = header;
- this.record = record;
- this.data = data;
- };
- FileData.prototype.decompress = function decompress () {
- // Check the compression
- var compressionMethod = this.header.compressionMethod();
- var fcn = decompressionMethods[compressionMethod];
- if (fcn) {
- return fcn(this.data, this.record.compressedSize(), this.record.uncompressedSize(), this.record.flag());
- }
- else {
- var name = CompressionMethod[compressionMethod];
- if (!name) {
- name = "Unknown: " + compressionMethod;
- }
- throw new ApiError(ErrorCode.EINVAL, ("Invalid compression method on file '" + (this.header.fileName()) + "': " + name));
- }
- };
- FileData.prototype.getHeader = function getHeader () {
- return this.header;
- };
- FileData.prototype.getRecord = function getRecord () {
- return this.record;
- };
- FileData.prototype.getRawData = function getRawData () {
- return this.data;
- };
- /**
- * 4.3.9 Data descriptor:
- *
- * crc-32 4 bytes
- * compressed size 4 bytes
- * uncompressed size 4 bytes
- */
- var DataDescriptor = function DataDescriptor(data) {
- this.data = data;
- };
- DataDescriptor.prototype.crc32 = function crc32 () { return this.data.readUInt32LE(0); };
- DataDescriptor.prototype.compressedSize = function compressedSize () { return this.data.readUInt32LE(4); };
- DataDescriptor.prototype.uncompressedSize = function uncompressedSize () { return this.data.readUInt32LE(8); };
- /*
- ` 4.3.10 Archive decryption header:
-
- 4.3.10.1 The Archive Decryption Header is introduced in version 6.2
- of the ZIP format specification. This record exists in support
- of the Central Directory Encryption Feature implemented as part of
- the Strong Encryption Specification as described in this document.
- When the Central Directory Structure is encrypted, this decryption
- header MUST precede the encrypted data segment.
- */
- /**
- * 4.3.11 Archive extra data record:
- *
- * archive extra data signature 4 bytes (0x08064b50)
- * extra field length 4 bytes
- * extra field data (variable size)
- *
- * 4.3.11.1 The Archive Extra Data Record is introduced in version 6.2
- * of the ZIP format specification. This record MAY be used in support
- * of the Central Directory Encryption Feature implemented as part of
- * the Strong Encryption Specification as described in this document.
- * When present, this record MUST immediately precede the central
- * directory data structure.
- */
- var ArchiveExtraDataRecord = function ArchiveExtraDataRecord(data) {
- this.data = data;
- if (this.data.readUInt32LE(0) !== 0x08064b50) {
- throw new ApiError(ErrorCode.EINVAL, "Invalid archive extra data record signature: " + this.data.readUInt32LE(0));
- }
- };
- ArchiveExtraDataRecord.prototype.length = function length () { return this.data.readUInt32LE(4); };
- ArchiveExtraDataRecord.prototype.extraFieldData = function extraFieldData () { return this.data.slice(8, 8 + this.length()); };
- /**
- * 4.3.13 Digital signature:
- *
- * header signature 4 bytes (0x05054b50)
- * size of data 2 bytes
- * signature data (variable size)
- *
- * With the introduction of the Central Directory Encryption
- * feature in version 6.2 of this specification, the Central
- * Directory Structure MAY be stored both compressed and encrypted.
- * Although not required, it is assumed when encrypting the
- * Central Directory Structure, that it will be compressed
- * for greater storage efficiency. Information on the
- * Central Directory Encryption feature can be found in the section
- * describing the Strong Encryption Specification. The Digital
- * Signature record will be neither compressed nor encrypted.
- */
- var DigitalSignature = function DigitalSignature(data) {
- this.data = data;
- if (this.data.readUInt32LE(0) !== 0x05054b50) {
- throw new ApiError(ErrorCode.EINVAL, "Invalid digital signature signature: " + this.data.readUInt32LE(0));
- }
- };
- DigitalSignature.prototype.size = function size () { return this.data.readUInt16LE(4); };
- DigitalSignature.prototype.signatureData = function signatureData () { return this.data.slice(6, 6 + this.size()); };
- /**
- * 4.3.12 Central directory structure:
- *
- * central file header signature 4 bytes (0x02014b50)
- * version made by 2 bytes
- * version needed to extract 2 bytes
- * general purpose bit flag 2 bytes
- * compression method 2 bytes
- * last mod file time 2 bytes
- * last mod file date 2 bytes
- * crc-32 4 bytes
- * compressed size 4 bytes
- * uncompressed size 4 bytes
- * file name length 2 bytes
- * extra field length 2 bytes
- * file comment length 2 bytes
- * disk number start 2 bytes
- * internal file attributes 2 bytes
- * external file attributes 4 bytes
- * relative offset of local header 4 bytes
- *
- * file name (variable size)
- * extra field (variable size)
- * file comment (variable size)
- */
- var CentralDirectory = function CentralDirectory(zipData, data) {
- this.zipData = zipData;
- this.data = data;
- // Sanity check.
- if (this.data.readUInt32LE(0) !== 0x02014b50) {
- throw new ApiError(ErrorCode.EINVAL, ("Invalid Zip file: Central directory record has invalid signature: " + (this.data.readUInt32LE(0))));
- }
- this._filename = this.produceFilename();
- };
- CentralDirectory.prototype.versionMadeBy = function versionMadeBy () { return this.data.readUInt16LE(4); };
- CentralDirectory.prototype.versionNeeded = function versionNeeded () { return this.data.readUInt16LE(6); };
- CentralDirectory.prototype.flag = function flag () { return this.data.readUInt16LE(8); };
- CentralDirectory.prototype.compressionMethod = function compressionMethod () { return this.data.readUInt16LE(10); };
- CentralDirectory.prototype.lastModFileTime = function lastModFileTime () {
- // Time and date is in MS-DOS format.
- return msdos2date(this.data.readUInt16LE(12), this.data.readUInt16LE(14));
- };
- CentralDirectory.prototype.rawLastModFileTime = function rawLastModFileTime () {
- return this.data.readUInt32LE(12);
- };
- CentralDirectory.prototype.crc32 = function crc32 () { return this.data.readUInt32LE(16); };
- CentralDirectory.prototype.compressedSize = function compressedSize () { return this.data.readUInt32LE(20); };
- CentralDirectory.prototype.uncompressedSize = function uncompressedSize () { return this.data.readUInt32LE(24); };
- CentralDirectory.prototype.fileNameLength = function fileNameLength () { return this.data.readUInt16LE(28); };
- CentralDirectory.prototype.extraFieldLength = function extraFieldLength () { return this.data.readUInt16LE(30); };
- CentralDirectory.prototype.fileCommentLength = function fileCommentLength () { return this.data.readUInt16LE(32); };
- CentralDirectory.prototype.diskNumberStart = function diskNumberStart () { return this.data.readUInt16LE(34); };
- CentralDirectory.prototype.internalAttributes = function internalAttributes () { return this.data.readUInt16LE(36); };
- CentralDirectory.prototype.externalAttributes = function externalAttributes () { return this.data.readUInt32LE(38); };
- CentralDirectory.prototype.headerRelativeOffset = function headerRelativeOffset () { return this.data.readUInt32LE(42); };
- CentralDirectory.prototype.produceFilename = function produceFilename () {
- /*
- 4.4.17.1 claims:
- * All slashes are forward ('/') slashes.
- * Filename doesn't begin with a slash.
- * No drive letters or any nonsense like that.
- * If filename is missing, the input came from standard input.
-
- Unfortunately, this isn't true in practice. Some Windows zip utilities use
- a backslash here, but the correct Unix-style path in file headers.
-
- To avoid seeking all over the file to recover the known-good filenames
- from file headers, we simply convert '/' to '\' here.
- */
- var fileName = safeToString(this.data, this.useUTF8(), 46, this.fileNameLength());
- return fileName.replace(/\\/g, "/");
- };
- CentralDirectory.prototype.fileName = function fileName () {
- return this._filename;
- };
- CentralDirectory.prototype.rawFileName = function rawFileName () {
- return this.data.slice(46, 46 + this.fileNameLength());
- };
- CentralDirectory.prototype.extraField = function extraField () {
- var start = 44 + this.fileNameLength();
- return this.data.slice(start, start + this.extraFieldLength());
- };
- CentralDirectory.prototype.fileComment = function fileComment () {
- var start = 46 + this.fileNameLength() + this.extraFieldLength();
- return safeToString(this.data, this.useUTF8(), start, this.fileCommentLength());
- };
- CentralDirectory.prototype.rawFileComment = function rawFileComment () {
- var start = 46 + this.fileNameLength() + this.extraFieldLength();
- return this.data.slice(start, start + this.fileCommentLength());
- };
- CentralDirectory.prototype.totalSize = function totalSize () {
- return 46 + this.fileNameLength() + this.extraFieldLength() + this.fileCommentLength();
- };
- CentralDirectory.prototype.isDirectory = function isDirectory () {
- // NOTE: This assumes that the zip file implementation uses the lower byte
- // of external attributes for DOS attributes for
- // backwards-compatibility. This is not mandated, but appears to be
- // commonplace.
- // According to the spec, the layout of external attributes is
- // platform-dependent.
- // If that fails, we also check if the name of the file ends in '/',
- // which is what Java's ZipFile implementation does.
- var fileName = this.fileName();
- return (this.externalAttributes() & 0x10 ? true : false) || (fileName.charAt(fileName.length - 1) === '/');
- };
- CentralDirectory.prototype.isFile = function isFile () { return !this.isDirectory(); };
- CentralDirectory.prototype.useUTF8 = function useUTF8 () { return (this.flag() & 0x800) === 0x800; };
- CentralDirectory.prototype.isEncrypted = function isEncrypted () { return (this.flag() & 0x1) === 0x1; };
- CentralDirectory.prototype.getFileData = function getFileData () {
- // Need to grab the header before we can figure out where the actual
- // compressed data starts.
- var start = this.headerRelativeOffset();
- var header = new FileHeader(this.zipData.slice(start));
- return new FileData(header, this, this.zipData.slice(start + header.totalSize()));
- };
- CentralDirectory.prototype.getData = function getData () {
- return this.getFileData().decompress();
- };
- CentralDirectory.prototype.getRawData = function getRawData () {
- return this.getFileData().getRawData();
- };
- CentralDirectory.prototype.getStats = function getStats () {
- return new Stats(FileType.FILE, this.uncompressedSize(), 0x16D, new Date(), this.lastModFileTime());
- };
- /**
- * 4.3.16: end of central directory record
- * end of central dir signature 4 bytes (0x06054b50)
- * number of this disk 2 bytes
- * number of the disk with the
- * start of the central directory 2 bytes
- * total number of entries in the
- * central directory on this disk 2 bytes
- * total number of entries in
- * the central directory 2 bytes
- * size of the central directory 4 bytes
- * offset of start of central
- * directory with respect to
- * the starting disk number 4 bytes
- * .ZIP file comment length 2 bytes
- * .ZIP file comment (variable size)
- */
- var EndOfCentralDirectory = function EndOfCentralDirectory(data) {
- this.data = data;
- if (this.data.readUInt32LE(0) !== 0x06054b50) {
- throw new ApiError(ErrorCode.EINVAL, ("Invalid Zip file: End of central directory record has invalid signature: " + (this.data.readUInt32LE(0))));
- }
- };
- EndOfCentralDirectory.prototype.diskNumber = function diskNumber () { return this.data.readUInt16LE(4); };
- EndOfCentralDirectory.prototype.cdDiskNumber = function cdDiskNumber () { return this.data.readUInt16LE(6); };
- EndOfCentralDirectory.prototype.cdDiskEntryCount = function cdDiskEntryCount () { return this.data.readUInt16LE(8); };
- EndOfCentralDirectory.prototype.cdTotalEntryCount = function cdTotalEntryCount () { return this.data.readUInt16LE(10); };
- EndOfCentralDirectory.prototype.cdSize = function cdSize () { return this.data.readUInt32LE(12); };
- EndOfCentralDirectory.prototype.cdOffset = function cdOffset () { return this.data.readUInt32LE(16); };
- EndOfCentralDirectory.prototype.cdZipCommentLength = function cdZipCommentLength () { return this.data.readUInt16LE(20); };
- EndOfCentralDirectory.prototype.cdZipComment = function cdZipComment () {
- // Assuming UTF-8. The specification doesn't specify.
- return safeToString(this.data, true, 22, this.cdZipCommentLength());
- };
- EndOfCentralDirectory.prototype.rawCdZipComment = function rawCdZipComment () {
- return this.data.slice(22, 22 + this.cdZipCommentLength());
- };
- /**
- * Contains the table of contents of a Zip file.
- */
- var ZipTOC = function ZipTOC(index, directoryEntries, eocd, data) {
- this.index = index;
- this.directoryEntries = directoryEntries;
- this.eocd = eocd;
- this.data = data;
- };
- /**
- * Zip file-backed filesystem
- * Implemented according to the standard:
- * http://www.pkware.com/documents/casestudies/APPNOTE.TXT
- *
- * While there are a few zip libraries for JavaScript (e.g. JSZip and zip.js),
- * they are not a good match for BrowserFS. In particular, these libraries
- * perform a lot of unneeded data copying, and eagerly decompress every file
- * in the zip file upon loading to check the CRC32. They also eagerly decode
- * strings. Furthermore, these libraries duplicate functionality already present
- * in BrowserFS (e.g. UTF-8 decoding and binary data manipulation).
- *
- * This filesystem takes advantage of BrowserFS's Buffer implementation, which
- * efficiently represents the zip file in memory (in both ArrayBuffer-enabled
- * browsers *and* non-ArrayBuffer browsers), and which can neatly be 'sliced'
- * without copying data. Each struct defined in the standard is represented with
- * a buffer slice pointing to an offset in the zip file, and has getters for
- * each field. As we anticipate that this data will not be read often, we choose
- * not to store each struct field in the JavaScript object; instead, to reduce
- * memory consumption, we retrieve it directly from the binary data each time it
- * is requested.
- *
- * When the filesystem is instantiated, we determine the directory structure
- * of the zip file as quickly as possible. We lazily decompress and check the
- * CRC32 of files. We do not cache decompressed files; if this is a desired
- * feature, it is best implemented as a generic file system wrapper that can
- * cache data from arbitrary file systems.
- *
- * For inflation, we use `pako`'s implementation:
- * https://github.com/nodeca/pako
- *
- * Current limitations:
- * * No encryption.
- * * No ZIP64 support.
- * * Read-only.
- * Write support would require that we:
- * - Keep track of changed/new files.
- * - Compress changed files, and generate appropriate metadata for each.
- * - Update file offsets for other files in the zip file.
- * - Stream it out to a location.
- * This isn't that bad, so we might do this at a later date.
- */
- var ZipFS = (function (SynchronousFileSystem$$1) {
- function ZipFS(input, name, deprecateMsg) {
- if ( name === void 0 ) name = '';
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- SynchronousFileSystem$$1.call(this);
- this.name = name;
- this._index = new FileIndex();
- this._directoryEntries = [];
- this._eocd = null;
- deprecationMessage(deprecateMsg, ZipFS.Name, { zipData: "zip data as a Buffer", name: name });
- if (input instanceof ZipTOC) {
- this._index = input.index;
- this._directoryEntries = input.directoryEntries;
- this._eocd = input.eocd;
- this.data = input.data;
- }
- else {
- this.data = input;
- this.populateIndex();
- }
- }
-
- if ( SynchronousFileSystem$$1 ) ZipFS.__proto__ = SynchronousFileSystem$$1;
- ZipFS.prototype = Object.create( SynchronousFileSystem$$1 && SynchronousFileSystem$$1.prototype );
- ZipFS.prototype.constructor = ZipFS;
- /**
- * Constructs a ZipFS instance with the given options.
- */
- ZipFS.Create = function Create (opts, cb) {
- try {
- ZipFS.computeIndex(opts.zipData, function (zipTOC) {
- var fs = new ZipFS(zipTOC, opts.name, false);
- cb(null, fs);
- }, false);
- }
- catch (e) {
- cb(e);
- }
- };
- ZipFS.isAvailable = function isAvailable () { return true; };
- ZipFS.RegisterDecompressionMethod = function RegisterDecompressionMethod (m, fcn) {
- decompressionMethods[m] = fcn;
- };
- /**
- * **Deprecated. Please use ZipFS.Create() method instead.**
- */
- ZipFS.computeIndex = function computeIndex (data, cb, deprecateMsg) {
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- // TODO: Refactor to plumb errors through. Right now, they throw.
- if (deprecateMsg) {
- console.warn("[ZipFS] ZipFS.computeIndex is now deprecated, and will be removed in the next major release. Please update your code to use 'ZipFS.Create({ zipData: zip file as a Buffer}, cb)' instead.");
- }
- var index = new FileIndex();
- var eocd = ZipFS.getEOCD(data);
- if (eocd.diskNumber() !== eocd.cdDiskNumber()) {
- throw new ApiError(ErrorCode.EINVAL, "ZipFS does not support spanned zip files.");
- }
- var cdPtr = eocd.cdOffset();
- if (cdPtr === 0xFFFFFFFF) {
- throw new ApiError(ErrorCode.EINVAL, "ZipFS does not support Zip64.");
- }
- var cdEnd = cdPtr + eocd.cdSize();
- ZipFS.computeIndexResponsive(data, index, cdPtr, cdEnd, cb, [], eocd);
- };
- /**
- * Locates the end of central directory record at the end of the file.
- * Throws an exception if it cannot be found.
- */
- ZipFS.getEOCD = function getEOCD (data) {
- // Unfortunately, the comment is variable size and up to 64K in size.
- // We assume that the magic signature does not appear in the comment, and
- // in the bytes between the comment and the signature. Other ZIP
- // implementations make this same assumption, since the alternative is to
- // read thread every entry in the file to get to it. :(
- // These are *negative* offsets from the end of the file.
- var startOffset = 22;
- var endOffset = Math.min(startOffset + 0xFFFF, data.length - 1);
- // There's not even a byte alignment guarantee on the comment so we need to
- // search byte by byte. *grumble grumble*
- for (var i = startOffset; i < endOffset; i++) {
- // Magic number: EOCD Signature
- if (data.readUInt32LE(data.length - i) === 0x06054b50) {
- return new EndOfCentralDirectory(data.slice(data.length - i));
- }
- }
- throw new ApiError(ErrorCode.EINVAL, "Invalid ZIP file: Could not locate End of Central Directory signature.");
- };
- ZipFS.addToIndex = function addToIndex (cd, index) {
- // Paths must be absolute, yet zip file paths are always relative to the
- // zip root. So we append '/' and call it a day.
- var filename = cd.fileName();
- if (filename.charAt(0) === '/') {
- throw new Error("WHY IS THIS ABSOLUTE");
- }
- // XXX: For the file index, strip the trailing '/'.
- if (filename.charAt(filename.length - 1) === '/') {
- filename = filename.substr(0, filename.length - 1);
- }
- if (cd.isDirectory()) {
- index.addPathFast('/' + filename, new DirInode(cd));
- }
- else {
- index.addPathFast('/' + filename, new FileInode(cd));
- }
- };
- ZipFS.computeIndexResponsive = function computeIndexResponsive (data, index, cdPtr, cdEnd, cb, cdEntries, eocd) {
- if (cdPtr < cdEnd) {
- var count = 0;
- while (count++ < 200 && cdPtr < cdEnd) {
- var cd = new CentralDirectory(data, data.slice(cdPtr));
- ZipFS.addToIndex(cd, index);
- cdPtr += cd.totalSize();
- cdEntries.push(cd);
- }
- setImmediate$3(function () {
- ZipFS.computeIndexResponsive(data, index, cdPtr, cdEnd, cb, cdEntries, eocd);
- });
- }
- else {
- cb(new ZipTOC(index, cdEntries, eocd, data));
- }
- };
- ZipFS.prototype.getName = function getName () {
- return ZipFS.Name + (this.name !== '' ? (" " + (this.name)) : '');
- };
- /**
- * Get the CentralDirectory object for the given path.
- */
- ZipFS.prototype.getCentralDirectoryEntry = function getCentralDirectoryEntry (path$$1) {
- var inode = this._index.getInode(path$$1);
- if (inode === null) {
- throw ApiError.ENOENT(path$$1);
- }
- if (isFileInode(inode)) {
- return inode.getData();
- }
- else if (isDirInode(inode)) {
- return inode.getData();
- }
- else {
- // Should never occur.
- throw ApiError.EPERM(("Invalid inode: " + inode));
- }
- };
- ZipFS.prototype.getCentralDirectoryEntryAt = function getCentralDirectoryEntryAt (index) {
- var dirEntry = this._directoryEntries[index];
- if (!dirEntry) {
- throw new RangeError(("Invalid directory index: " + index + "."));
- }
- return dirEntry;
- };
- ZipFS.prototype.getNumberOfCentralDirectoryEntries = function getNumberOfCentralDirectoryEntries () {
- return this._directoryEntries.length;
- };
- ZipFS.prototype.getEndOfCentralDirectory = function getEndOfCentralDirectory () {
- return this._eocd;
- };
- ZipFS.prototype.diskSpace = function diskSpace (path$$1, cb) {
- // Read-only file system.
- cb(this.data.length, 0);
- };
- ZipFS.prototype.isReadOnly = function isReadOnly () {
- return true;
- };
- ZipFS.prototype.supportsLinks = function supportsLinks () {
- return false;
- };
- ZipFS.prototype.supportsProps = function supportsProps () {
- return false;
- };
- ZipFS.prototype.supportsSynch = function supportsSynch () {
- return true;
- };
- ZipFS.prototype.statSync = function statSync (path$$1, isLstat) {
- var inode = this._index.getInode(path$$1);
- if (inode === null) {
- throw ApiError.ENOENT(path$$1);
- }
- var stats;
- if (isFileInode(inode)) {
- stats = inode.getData().getStats();
- }
- else if (isDirInode(inode)) {
- stats = inode.getStats();
- }
- else {
- throw new ApiError(ErrorCode.EINVAL, "Invalid inode.");
- }
- return stats;
- };
- ZipFS.prototype.openSync = function openSync (path$$1, flags, mode) {
- // INVARIANT: Cannot write to RO file systems.
- if (flags.isWriteable()) {
- throw new ApiError(ErrorCode.EPERM, path$$1);
- }
- // Check if the path exists, and is a file.
- var inode = this._index.getInode(path$$1);
- if (!inode) {
- throw ApiError.ENOENT(path$$1);
- }
- else if (isFileInode(inode)) {
- var cdRecord = inode.getData();
- var stats = cdRecord.getStats();
- switch (flags.pathExistsAction()) {
- case ActionType.THROW_EXCEPTION:
- case ActionType.TRUNCATE_FILE:
- throw ApiError.EEXIST(path$$1);
- case ActionType.NOP:
- return new NoSyncFile(this, path$$1, flags, stats, cdRecord.getData());
- default:
- throw new ApiError(ErrorCode.EINVAL, 'Invalid FileMode object.');
- }
- }
- else {
- throw ApiError.EISDIR(path$$1);
- }
- };
- ZipFS.prototype.readdirSync = function readdirSync (path$$1) {
- // Check if it exists.
- var inode = this._index.getInode(path$$1);
- if (!inode) {
- throw ApiError.ENOENT(path$$1);
- }
- else if (isDirInode(inode)) {
- return inode.getListing();
- }
- else {
- throw ApiError.ENOTDIR(path$$1);
- }
- };
- /**
- * Specially-optimized readfile.
- */
- ZipFS.prototype.readFileSync = function readFileSync (fname, encoding, flag) {
- // Get file.
- var fd = this.openSync(fname, flag, 0x1a4);
- try {
- var fdCast = fd;
- var fdBuff = fdCast.getBuffer();
- if (encoding === null) {
- return copyingSlice(fdBuff);
- }
- return fdBuff.toString(encoding);
- }
- finally {
- fd.closeSync();
- }
- };
- ZipFS.prototype.populateIndex = function populateIndex () {
- var this$1 = this;
-
- var eocd = this._eocd = ZipFS.getEOCD(this.data);
- if (eocd.diskNumber() !== eocd.cdDiskNumber()) {
- throw new ApiError(ErrorCode.EINVAL, "ZipFS does not support spanned zip files.");
- }
- var cdPtr = eocd.cdOffset();
- if (cdPtr === 0xFFFFFFFF) {
- throw new ApiError(ErrorCode.EINVAL, "ZipFS does not support Zip64.");
- }
- var cdEnd = cdPtr + eocd.cdSize();
- while (cdPtr < cdEnd) {
- var cd = new CentralDirectory(this$1.data, this$1.data.slice(cdPtr));
- cdPtr += cd.totalSize();
- ZipFS.addToIndex(cd, this$1._index);
- this$1._directoryEntries.push(cd);
- }
- };
-
- return ZipFS;
- }(SynchronousFileSystem));
-
- ZipFS.Name = "ZipFS";
- ZipFS.Options = {
- zipData: {
- type: "object",
- description: "The zip file as a Buffer object.",
- validator: bufferValidator
- },
- name: {
- type: "string",
- optional: true,
- description: "The name of the zip file (optional)."
- }
- };
- ZipFS.CompressionMethod = CompressionMethod;
- ZipFS.RegisterDecompressionMethod(CompressionMethod.DEFLATE, function (data, compressedSize, uncompressedSize) {
- return arrayish2Buffer(inflateRaw(data.slice(0, compressedSize), { chunkSize: uncompressedSize }));
- });
- ZipFS.RegisterDecompressionMethod(CompressionMethod.STORED, function (data, compressedSize, uncompressedSize) {
- return copyingSlice(data, 0, uncompressedSize);
- });
-
- /**
- * @hidden
- */
- var rockRidgeIdentifier = "IEEE_P1282";
- /**
- * @hidden
- */
- function getASCIIString(data, startIndex, length) {
- return data.toString('ascii', startIndex, startIndex + length).trim();
- }
- /**
- * @hidden
- */
- function getJolietString(data, startIndex, length) {
- if (length === 1) {
- // Special: Root, parent, current directory are still a single byte.
- return String.fromCharCode(data[startIndex]);
- }
- // UTF16-BE, which isn't natively supported by NodeJS Buffers.
- // Length should be even, but pessimistically floor just in case.
- var pairs = Math.floor(length / 2);
- var chars = new Array(pairs);
- for (var i = 0; i < pairs; i++) {
- var pos = startIndex + (i << 1);
- chars[i] = String.fromCharCode(data[pos + 1] | (data[pos] << 8));
- }
- return chars.join('');
- }
- /**
- * @hidden
- */
- function getDate(data, startIndex) {
- var year = parseInt(getASCIIString(data, startIndex, 4), 10);
- var mon = parseInt(getASCIIString(data, startIndex + 4, 2), 10);
- var day = parseInt(getASCIIString(data, startIndex + 6, 2), 10);
- var hour = parseInt(getASCIIString(data, startIndex + 8, 2), 10);
- var min = parseInt(getASCIIString(data, startIndex + 10, 2), 10);
- var sec = parseInt(getASCIIString(data, startIndex + 12, 2), 10);
- var hundrethsSec = parseInt(getASCIIString(data, startIndex + 14, 2), 10);
- // Last is a time-zone offset, but JavaScript dates don't support time zones well.
- return new Date(year, mon, day, hour, min, sec, hundrethsSec * 100);
- }
- /**
- * @hidden
- */
- function getShortFormDate(data, startIndex) {
- var yearsSince1900 = data[startIndex];
- var month = data[startIndex + 1];
- var day = data[startIndex + 2];
- var hour = data[startIndex + 3];
- var minute = data[startIndex + 4];
- var second = data[startIndex + 5];
- // JavaScript's Date support isn't so great; ignore timezone.
- // const offsetFromGMT = this._data[24];
- return new Date(yearsSince1900, month - 1, day, hour, minute, second);
- }
- /**
- * @hidden
- */
- function constructSystemUseEntry(bigData, i) {
- var data = bigData.slice(i);
- var sue = new SystemUseEntry(data);
- switch (sue.signatureWord()) {
- case 17221 /* CE */:
- return new CEEntry(data);
- case 20548 /* PD */:
- return new PDEntry(data);
- case 21328 /* SP */:
- return new SPEntry(data);
- case 21332 /* ST */:
- return new STEntry(data);
- case 17746 /* ER */:
- return new EREntry(data);
- case 17747 /* ES */:
- return new ESEntry(data);
- case 20568 /* PX */:
- return new PXEntry(data);
- case 20558 /* PN */:
- return new PNEntry(data);
- case 21324 /* SL */:
- return new SLEntry(data);
- case 20045 /* NM */:
- return new NMEntry(data);
- case 17228 /* CL */:
- return new CLEntry(data);
- case 20556 /* PL */:
- return new PLEntry(data);
- case 21061 /* RE */:
- return new REEntry(data);
- case 21574 /* TF */:
- return new TFEntry(data);
- case 21318 /* SF */:
- return new SFEntry(data);
- case 21074 /* RR */:
- return new RREntry(data);
- default:
- return sue;
- }
- }
- /**
- * @hidden
- */
- function constructSystemUseEntries(data, i, len, isoData) {
- // If the remaining allocated space following the last recorded System Use Entry in a System
- // Use field or Continuation Area is less than four bytes long, it cannot contain a System
- // Use Entry and shall be ignored
- len = len - 4;
- var entries = new Array();
- while (i < len) {
- var entry = constructSystemUseEntry(data, i);
- var length = entry.length();
- if (length === 0) {
- // Invalid SU section; prevent infinite loop.
- return entries;
- }
- i += length;
- if (entry instanceof STEntry) {
- // ST indicates the end of entries.
- break;
- }
- if (entry instanceof CEEntry) {
- entries = entries.concat(entry.getEntries(isoData));
- }
- else {
- entries.push(entry);
- }
- }
- return entries;
- }
- /**
- * @hidden
- */
- var VolumeDescriptor = function VolumeDescriptor(data) {
- this._data = data;
- };
- VolumeDescriptor.prototype.type = function type () {
- return this._data[0];
- };
- VolumeDescriptor.prototype.standardIdentifier = function standardIdentifier () {
- return getASCIIString(this._data, 1, 5);
- };
- VolumeDescriptor.prototype.version = function version () {
- return this._data[6];
- };
- VolumeDescriptor.prototype.data = function data () {
- return this._data.slice(7, 2048);
- };
- /**
- * @hidden
- */
- var PrimaryOrSupplementaryVolumeDescriptor = (function (VolumeDescriptor) {
- function PrimaryOrSupplementaryVolumeDescriptor(data) {
- VolumeDescriptor.call(this, data);
- this._root = null;
- }
-
- if ( VolumeDescriptor ) PrimaryOrSupplementaryVolumeDescriptor.__proto__ = VolumeDescriptor;
- PrimaryOrSupplementaryVolumeDescriptor.prototype = Object.create( VolumeDescriptor && VolumeDescriptor.prototype );
- PrimaryOrSupplementaryVolumeDescriptor.prototype.constructor = PrimaryOrSupplementaryVolumeDescriptor;
- PrimaryOrSupplementaryVolumeDescriptor.prototype.systemIdentifier = function systemIdentifier () {
- return this._getString32(8);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeIdentifier = function volumeIdentifier () {
- return this._getString32(40);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeSpaceSize = function volumeSpaceSize () {
- return this._data.readUInt32LE(80);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeSetSize = function volumeSetSize () {
- return this._data.readUInt16LE(120);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeSequenceNumber = function volumeSequenceNumber () {
- return this._data.readUInt16LE(124);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.logicalBlockSize = function logicalBlockSize () {
- return this._data.readUInt16LE(128);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.pathTableSize = function pathTableSize () {
- return this._data.readUInt32LE(132);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.locationOfTypeLPathTable = function locationOfTypeLPathTable () {
- return this._data.readUInt32LE(140);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.locationOfOptionalTypeLPathTable = function locationOfOptionalTypeLPathTable () {
- return this._data.readUInt32LE(144);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.locationOfTypeMPathTable = function locationOfTypeMPathTable () {
- return this._data.readUInt32BE(148);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.locationOfOptionalTypeMPathTable = function locationOfOptionalTypeMPathTable () {
- return this._data.readUInt32BE(152);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.rootDirectoryEntry = function rootDirectoryEntry (isoData) {
- if (this._root === null) {
- this._root = this._constructRootDirectoryRecord(this._data.slice(156));
- this._root.rootCheckForRockRidge(isoData);
- }
- return this._root;
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeSetIdentifier = function volumeSetIdentifier () {
- return this._getString(190, 128);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.publisherIdentifier = function publisherIdentifier () {
- return this._getString(318, 128);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.dataPreparerIdentifier = function dataPreparerIdentifier () {
- return this._getString(446, 128);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.applicationIdentifier = function applicationIdentifier () {
- return this._getString(574, 128);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.copyrightFileIdentifier = function copyrightFileIdentifier () {
- return this._getString(702, 38);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.abstractFileIdentifier = function abstractFileIdentifier () {
- return this._getString(740, 36);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.bibliographicFileIdentifier = function bibliographicFileIdentifier () {
- return this._getString(776, 37);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeCreationDate = function volumeCreationDate () {
- return getDate(this._data, 813);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeModificationDate = function volumeModificationDate () {
- return getDate(this._data, 830);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeExpirationDate = function volumeExpirationDate () {
- return getDate(this._data, 847);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeEffectiveDate = function volumeEffectiveDate () {
- return getDate(this._data, 864);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.fileStructureVersion = function fileStructureVersion () {
- return this._data[881];
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.applicationUsed = function applicationUsed () {
- return this._data.slice(883, 883 + 512);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype.reserved = function reserved () {
- return this._data.slice(1395, 1395 + 653);
- };
- PrimaryOrSupplementaryVolumeDescriptor.prototype._getString32 = function _getString32 (idx) {
- return this._getString(idx, 32);
- };
-
- return PrimaryOrSupplementaryVolumeDescriptor;
- }(VolumeDescriptor));
- /**
- * @hidden
- */
- var PrimaryVolumeDescriptor = (function (PrimaryOrSupplementaryVolumeDescriptor) {
- function PrimaryVolumeDescriptor(data) {
- PrimaryOrSupplementaryVolumeDescriptor.call(this, data);
- if (this.type() !== 1 /* PrimaryVolumeDescriptor */) {
- throw new ApiError(ErrorCode.EIO, "Invalid primary volume descriptor.");
- }
- }
-
- if ( PrimaryOrSupplementaryVolumeDescriptor ) PrimaryVolumeDescriptor.__proto__ = PrimaryOrSupplementaryVolumeDescriptor;
- PrimaryVolumeDescriptor.prototype = Object.create( PrimaryOrSupplementaryVolumeDescriptor && PrimaryOrSupplementaryVolumeDescriptor.prototype );
- PrimaryVolumeDescriptor.prototype.constructor = PrimaryVolumeDescriptor;
- PrimaryVolumeDescriptor.prototype.name = function name () {
- return "ISO9660";
- };
- PrimaryVolumeDescriptor.prototype._constructRootDirectoryRecord = function _constructRootDirectoryRecord (data) {
- return new ISODirectoryRecord(data, -1);
- };
- PrimaryVolumeDescriptor.prototype._getString = function _getString (idx, len) {
- return this._getString(idx, len);
- };
-
- return PrimaryVolumeDescriptor;
- }(PrimaryOrSupplementaryVolumeDescriptor));
- /**
- * @hidden
- */
- var SupplementaryVolumeDescriptor = (function (PrimaryOrSupplementaryVolumeDescriptor) {
- function SupplementaryVolumeDescriptor(data) {
- PrimaryOrSupplementaryVolumeDescriptor.call(this, data);
- if (this.type() !== 2 /* SupplementaryVolumeDescriptor */) {
- throw new ApiError(ErrorCode.EIO, "Invalid supplementary volume descriptor.");
- }
- var escapeSequence = this.escapeSequence();
- var third = escapeSequence[2];
- // Third character identifies what 'level' of the UCS specification to follow.
- // We ignore it.
- if (escapeSequence[0] !== 0x25 || escapeSequence[1] !== 0x2F ||
- (third !== 0x40 && third !== 0x43 && third !== 0x45)) {
- throw new ApiError(ErrorCode.EIO, ("Unrecognized escape sequence for SupplementaryVolumeDescriptor: " + (escapeSequence.toString())));
- }
- }
-
- if ( PrimaryOrSupplementaryVolumeDescriptor ) SupplementaryVolumeDescriptor.__proto__ = PrimaryOrSupplementaryVolumeDescriptor;
- SupplementaryVolumeDescriptor.prototype = Object.create( PrimaryOrSupplementaryVolumeDescriptor && PrimaryOrSupplementaryVolumeDescriptor.prototype );
- SupplementaryVolumeDescriptor.prototype.constructor = SupplementaryVolumeDescriptor;
- SupplementaryVolumeDescriptor.prototype.name = function name () {
- return "Joliet";
- };
- SupplementaryVolumeDescriptor.prototype.escapeSequence = function escapeSequence () {
- return this._data.slice(88, 120);
- };
- SupplementaryVolumeDescriptor.prototype._constructRootDirectoryRecord = function _constructRootDirectoryRecord (data) {
- return new JolietDirectoryRecord(data, -1);
- };
- SupplementaryVolumeDescriptor.prototype._getString = function _getString (idx, len) {
- return getJolietString(this._data, idx, len);
- };
-
- return SupplementaryVolumeDescriptor;
- }(PrimaryOrSupplementaryVolumeDescriptor));
- /**
- * @hidden
- */
- var DirectoryRecord = function DirectoryRecord(data, rockRidgeOffset) {
- this._suEntries = null;
- this._fileOrDir = null;
- this._data = data;
- this._rockRidgeOffset = rockRidgeOffset;
- };
- DirectoryRecord.prototype.hasRockRidge = function hasRockRidge () {
- return this._rockRidgeOffset > -1;
- };
- DirectoryRecord.prototype.getRockRidgeOffset = function getRockRidgeOffset () {
- return this._rockRidgeOffset;
- };
- /**
- * !!ONLY VALID ON ROOT NODE!!
- * Checks if Rock Ridge is enabled, and sets the offset.
- */
- DirectoryRecord.prototype.rootCheckForRockRidge = function rootCheckForRockRidge (isoData) {
- var dir = this.getDirectory(isoData);
- this._rockRidgeOffset = dir.getDotEntry(isoData)._getRockRidgeOffset(isoData);
- if (this._rockRidgeOffset > -1) {
- // Wipe out directory. Start over with RR knowledge.
- this._fileOrDir = null;
- }
- };
- DirectoryRecord.prototype.length = function length () {
- return this._data[0];
- };
- DirectoryRecord.prototype.extendedAttributeRecordLength = function extendedAttributeRecordLength () {
- return this._data[1];
- };
- DirectoryRecord.prototype.lba = function lba () {
- return this._data.readUInt32LE(2) * 2048;
- };
- DirectoryRecord.prototype.dataLength = function dataLength () {
- return this._data.readUInt32LE(10);
- };
- DirectoryRecord.prototype.recordingDate = function recordingDate () {
- return getShortFormDate(this._data, 18);
- };
- DirectoryRecord.prototype.fileFlags = function fileFlags () {
- return this._data[25];
- };
- DirectoryRecord.prototype.fileUnitSize = function fileUnitSize () {
- return this._data[26];
- };
- DirectoryRecord.prototype.interleaveGapSize = function interleaveGapSize () {
- return this._data[27];
- };
- DirectoryRecord.prototype.volumeSequenceNumber = function volumeSequenceNumber () {
- return this._data.readUInt16LE(28);
- };
- DirectoryRecord.prototype.identifier = function identifier () {
- return this._getString(33, this._data[32]);
- };
- DirectoryRecord.prototype.fileName = function fileName (isoData) {
- if (this.hasRockRidge()) {
- var fn = this._rockRidgeFilename(isoData);
- if (fn !== null) {
- return fn;
- }
- }
- var ident = this.identifier();
- if (this.isDirectory(isoData)) {
- return ident;
- }
- // Files:
- // - MUST have 0x2E (.) separating the name from the extension
- // - MUST have 0x3B (;) separating the file name and extension from the version
- // Gets expanded to two-byte char in Unicode directory records.
- var versionSeparator = ident.indexOf(';');
- if (versionSeparator === -1) {
- // Some Joliet filenames lack the version separator, despite the standard
- // specifying that it should be there.
- return ident;
- }
- else if (ident[versionSeparator - 1] === '.') {
- // Empty extension. Do not include '.' in the filename.
- return ident.slice(0, versionSeparator - 1);
- }
- else {
- // Include up to version separator.
- return ident.slice(0, versionSeparator);
- }
- };
- DirectoryRecord.prototype.isDirectory = function isDirectory (isoData) {
- var rv = !!(this.fileFlags() & 2 /* Directory */);
- // If it lacks the Directory flag, it may still be a directory if we've exceeded the directory
- // depth limit. Rock Ridge marks these as files and adds a special attribute.
- if (!rv && this.hasRockRidge()) {
- rv = this.getSUEntries(isoData).filter(function (e) { return e instanceof CLEntry; }).length > 0;
- }
- return rv;
- };
- DirectoryRecord.prototype.isSymlink = function isSymlink (isoData) {
- return this.hasRockRidge() && this.getSUEntries(isoData).filter(function (e) { return e instanceof SLEntry; }).length > 0;
- };
- DirectoryRecord.prototype.getSymlinkPath = function getSymlinkPath (isoData) {
- var p = "";
- var entries = this.getSUEntries(isoData);
- var getStr = this._getGetString();
- for (var i = 0, list = entries; i < list.length; i += 1) {
- var entry = list[i];
-
- if (entry instanceof SLEntry) {
- var components = entry.componentRecords();
- for (var i$1 = 0, list$1 = components; i$1 < list$1.length; i$1 += 1) {
- var component = list$1[i$1];
-
- var flags = component.flags();
- if (flags & 2 /* CURRENT */) {
- p += "./";
- }
- else if (flags & 4 /* PARENT */) {
- p += "../";
- }
- else if (flags & 8 /* ROOT */) {
- p += "/";
- }
- else {
- p += component.content(getStr);
- if (!(flags & 1 /* CONTINUE */)) {
- p += '/';
- }
- }
- }
- if (!entry.continueFlag()) {
- // We are done with this link.
- break;
- }
- }
- }
- if (p.length > 1 && p[p.length - 1] === '/') {
- // Trim trailing '/'.
- return p.slice(0, p.length - 1);
- }
- else {
- return p;
- }
- };
- DirectoryRecord.prototype.getFile = function getFile (isoData) {
- if (this.isDirectory(isoData)) {
- throw new Error("Tried to get a File from a directory.");
- }
- if (this._fileOrDir === null) {
- this._fileOrDir = isoData.slice(this.lba(), this.lba() + this.dataLength());
- }
- return this._fileOrDir;
- };
- DirectoryRecord.prototype.getDirectory = function getDirectory (isoData) {
- if (!this.isDirectory(isoData)) {
- throw new Error("Tried to get a Directory from a file.");
- }
- if (this._fileOrDir === null) {
- this._fileOrDir = this._constructDirectory(isoData);
- }
- return this._fileOrDir;
- };
- DirectoryRecord.prototype.getSUEntries = function getSUEntries (isoData) {
- if (!this._suEntries) {
- this._constructSUEntries(isoData);
- }
- return this._suEntries;
- };
- DirectoryRecord.prototype._rockRidgeFilename = function _rockRidgeFilename (isoData) {
- var nmEntries = this.getSUEntries(isoData).filter(function (e) { return e instanceof NMEntry; });
- if (nmEntries.length === 0 || nmEntries[0].flags() & (2 /* CURRENT */ | 4 /* PARENT */)) {
- return null;
- }
- var str = '';
- var getString = this._getGetString();
- for (var i = 0, list = nmEntries; i < list.length; i += 1) {
- var e = list[i];
-
- str += e.name(getString);
- if (!(e.flags() & 1 /* CONTINUE */)) {
- break;
- }
- }
- return str;
- };
- DirectoryRecord.prototype._constructSUEntries = function _constructSUEntries (isoData) {
- var i = 33 + this._data[32];
- if (i % 2 === 1) {
- // Skip padding field.
- i++;
- }
- i += this._rockRidgeOffset;
- this._suEntries = constructSystemUseEntries(this._data, i, this.length(), isoData);
- };
- /**
- * !!ONLY VALID ON FIRST ENTRY OF ROOT DIRECTORY!!
- * Returns -1 if rock ridge is not enabled. Otherwise, returns the offset
- * at which system use fields begin.
- */
- DirectoryRecord.prototype._getRockRidgeOffset = function _getRockRidgeOffset (isoData) {
- // In the worst case, we get some garbage SU entries.
- // Fudge offset to 0 before proceeding.
- this._rockRidgeOffset = 0;
- var suEntries = this.getSUEntries(isoData);
- if (suEntries.length > 0) {
- var spEntry = suEntries[0];
- if (spEntry instanceof SPEntry && spEntry.checkBytesPass()) {
- // SUSP is in use.
- for (var i = 1; i < suEntries.length; i++) {
- var entry = suEntries[i];
- if (entry instanceof RREntry || (entry instanceof EREntry && entry.extensionIdentifier() === rockRidgeIdentifier)) {
- // Rock Ridge is in use!
- return spEntry.bytesSkipped();
- }
- }
- }
- }
- // Failed.
- this._rockRidgeOffset = -1;
- return -1;
- };
- /**
- * @hidden
- */
- var ISODirectoryRecord = (function (DirectoryRecord) {
- function ISODirectoryRecord(data, rockRidgeOffset) {
- DirectoryRecord.call(this, data, rockRidgeOffset);
- }
-
- if ( DirectoryRecord ) ISODirectoryRecord.__proto__ = DirectoryRecord;
- ISODirectoryRecord.prototype = Object.create( DirectoryRecord && DirectoryRecord.prototype );
- ISODirectoryRecord.prototype.constructor = ISODirectoryRecord;
- ISODirectoryRecord.prototype._getString = function _getString (i, len) {
- return getASCIIString(this._data, i, len);
- };
- ISODirectoryRecord.prototype._constructDirectory = function _constructDirectory (isoData) {
- return new ISODirectory(this, isoData);
- };
- ISODirectoryRecord.prototype._getGetString = function _getGetString () {
- return getASCIIString;
- };
-
- return ISODirectoryRecord;
- }(DirectoryRecord));
- /**
- * @hidden
- */
- var JolietDirectoryRecord = (function (DirectoryRecord) {
- function JolietDirectoryRecord(data, rockRidgeOffset) {
- DirectoryRecord.call(this, data, rockRidgeOffset);
- }
-
- if ( DirectoryRecord ) JolietDirectoryRecord.__proto__ = DirectoryRecord;
- JolietDirectoryRecord.prototype = Object.create( DirectoryRecord && DirectoryRecord.prototype );
- JolietDirectoryRecord.prototype.constructor = JolietDirectoryRecord;
- JolietDirectoryRecord.prototype._getString = function _getString (i, len) {
- return getJolietString(this._data, i, len);
- };
- JolietDirectoryRecord.prototype._constructDirectory = function _constructDirectory (isoData) {
- return new JolietDirectory(this, isoData);
- };
- JolietDirectoryRecord.prototype._getGetString = function _getGetString () {
- return getJolietString;
- };
-
- return JolietDirectoryRecord;
- }(DirectoryRecord));
- /**
- * @hidden
- */
- var SystemUseEntry = function SystemUseEntry(data) {
- this._data = data;
- };
- SystemUseEntry.prototype.signatureWord = function signatureWord () {
- return this._data.readUInt16BE(0);
- };
- SystemUseEntry.prototype.signatureWordString = function signatureWordString () {
- return getASCIIString(this._data, 0, 2);
- };
- SystemUseEntry.prototype.length = function length () {
- return this._data[2];
- };
- SystemUseEntry.prototype.suVersion = function suVersion () {
- return this._data[3];
- };
- /**
- * Continuation entry.
- * @hidden
- */
- var CEEntry = (function (SystemUseEntry) {
- function CEEntry(data) {
- SystemUseEntry.call(this, data);
- this._entries = null;
- }
-
- if ( SystemUseEntry ) CEEntry.__proto__ = SystemUseEntry;
- CEEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- CEEntry.prototype.constructor = CEEntry;
- /**
- * Logical block address of the continuation area.
- */
- CEEntry.prototype.continuationLba = function continuationLba () {
- return this._data.readUInt32LE(4);
- };
- /**
- * Offset into the logical block.
- */
- CEEntry.prototype.continuationLbaOffset = function continuationLbaOffset () {
- return this._data.readUInt32LE(12);
- };
- /**
- * Length of the continuation area.
- */
- CEEntry.prototype.continuationLength = function continuationLength () {
- return this._data.readUInt32LE(20);
- };
- CEEntry.prototype.getEntries = function getEntries (isoData) {
- if (!this._entries) {
- var start = this.continuationLba() * 2048 + this.continuationLbaOffset();
- this._entries = constructSystemUseEntries(isoData, start, this.continuationLength(), isoData);
- }
- return this._entries;
- };
-
- return CEEntry;
- }(SystemUseEntry));
- /**
- * Padding entry.
- * @hidden
- */
- var PDEntry = (function (SystemUseEntry) {
- function PDEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) PDEntry.__proto__ = SystemUseEntry;
- PDEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- PDEntry.prototype.constructor = PDEntry;
-
- return PDEntry;
- }(SystemUseEntry));
- /**
- * Identifies that SUSP is in-use.
- * @hidden
- */
- var SPEntry = (function (SystemUseEntry) {
- function SPEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) SPEntry.__proto__ = SystemUseEntry;
- SPEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- SPEntry.prototype.constructor = SPEntry;
- SPEntry.prototype.checkBytesPass = function checkBytesPass () {
- return this._data[4] === 0xBE && this._data[5] === 0xEF;
- };
- SPEntry.prototype.bytesSkipped = function bytesSkipped () {
- return this._data[6];
- };
-
- return SPEntry;
- }(SystemUseEntry));
- /**
- * Identifies the end of the SUSP entries.
- * @hidden
- */
- var STEntry = (function (SystemUseEntry) {
- function STEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) STEntry.__proto__ = SystemUseEntry;
- STEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- STEntry.prototype.constructor = STEntry;
-
- return STEntry;
- }(SystemUseEntry));
- /**
- * Specifies system-specific extensions to SUSP.
- * @hidden
- */
- var EREntry = (function (SystemUseEntry) {
- function EREntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) EREntry.__proto__ = SystemUseEntry;
- EREntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- EREntry.prototype.constructor = EREntry;
- EREntry.prototype.identifierLength = function identifierLength () {
- return this._data[4];
- };
- EREntry.prototype.descriptorLength = function descriptorLength () {
- return this._data[5];
- };
- EREntry.prototype.sourceLength = function sourceLength () {
- return this._data[6];
- };
- EREntry.prototype.extensionVersion = function extensionVersion () {
- return this._data[7];
- };
- EREntry.prototype.extensionIdentifier = function extensionIdentifier () {
- return getASCIIString(this._data, 8, this.identifierLength());
- };
- EREntry.prototype.extensionDescriptor = function extensionDescriptor () {
- return getASCIIString(this._data, 8 + this.identifierLength(), this.descriptorLength());
- };
- EREntry.prototype.extensionSource = function extensionSource () {
- return getASCIIString(this._data, 8 + this.identifierLength() + this.descriptorLength(), this.sourceLength());
- };
-
- return EREntry;
- }(SystemUseEntry));
- /**
- * @hidden
- */
- var ESEntry = (function (SystemUseEntry) {
- function ESEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) ESEntry.__proto__ = SystemUseEntry;
- ESEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- ESEntry.prototype.constructor = ESEntry;
- ESEntry.prototype.extensionSequence = function extensionSequence () {
- return this._data[4];
- };
-
- return ESEntry;
- }(SystemUseEntry));
- /**
- * RockRidge: Marks that RockRidge is in use [deprecated]
- * @hidden
- */
- var RREntry = (function (SystemUseEntry) {
- function RREntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) RREntry.__proto__ = SystemUseEntry;
- RREntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- RREntry.prototype.constructor = RREntry;
-
- return RREntry;
- }(SystemUseEntry));
- /**
- * RockRidge: Records POSIX file attributes.
- * @hidden
- */
- var PXEntry = (function (SystemUseEntry) {
- function PXEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) PXEntry.__proto__ = SystemUseEntry;
- PXEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- PXEntry.prototype.constructor = PXEntry;
- PXEntry.prototype.mode = function mode () {
- return this._data.readUInt32LE(4);
- };
- PXEntry.prototype.fileLinks = function fileLinks () {
- return this._data.readUInt32LE(12);
- };
- PXEntry.prototype.uid = function uid () {
- return this._data.readUInt32LE(20);
- };
- PXEntry.prototype.gid = function gid () {
- return this._data.readUInt32LE(28);
- };
- PXEntry.prototype.inode = function inode () {
- return this._data.readUInt32LE(36);
- };
-
- return PXEntry;
- }(SystemUseEntry));
- /**
- * RockRidge: Records POSIX device number.
- * @hidden
- */
- var PNEntry = (function (SystemUseEntry) {
- function PNEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) PNEntry.__proto__ = SystemUseEntry;
- PNEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- PNEntry.prototype.constructor = PNEntry;
- PNEntry.prototype.devTHigh = function devTHigh () {
- return this._data.readUInt32LE(4);
- };
- PNEntry.prototype.devTLow = function devTLow () {
- return this._data.readUInt32LE(12);
- };
-
- return PNEntry;
- }(SystemUseEntry));
- /**
- * RockRidge: Records symbolic link
- * @hidden
- */
- var SLEntry = (function (SystemUseEntry) {
- function SLEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) SLEntry.__proto__ = SystemUseEntry;
- SLEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- SLEntry.prototype.constructor = SLEntry;
- SLEntry.prototype.flags = function flags () {
- return this._data[4];
- };
- SLEntry.prototype.continueFlag = function continueFlag () {
- return this.flags() & 0x1;
- };
- SLEntry.prototype.componentRecords = function componentRecords () {
- var this$1 = this;
-
- var records = new Array();
- var i = 5;
- while (i < this.length()) {
- var record = new SLComponentRecord(this$1._data.slice(i));
- records.push(record);
- i += record.length();
- }
- return records;
- };
-
- return SLEntry;
- }(SystemUseEntry));
- /**
- * @hidden
- */
- var SLComponentRecord = function SLComponentRecord(data) {
- this._data = data;
- };
- SLComponentRecord.prototype.flags = function flags () {
- return this._data[0];
- };
- SLComponentRecord.prototype.length = function length () {
- return 2 + this.componentLength();
- };
- SLComponentRecord.prototype.componentLength = function componentLength () {
- return this._data[1];
- };
- SLComponentRecord.prototype.content = function content (getString) {
- return getString(this._data, 2, this.componentLength());
- };
- /**
- * RockRidge: Records alternate file name
- * @hidden
- */
- var NMEntry = (function (SystemUseEntry) {
- function NMEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) NMEntry.__proto__ = SystemUseEntry;
- NMEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- NMEntry.prototype.constructor = NMEntry;
- NMEntry.prototype.flags = function flags () {
- return this._data[4];
- };
- NMEntry.prototype.name = function name (getString) {
- return getString(this._data, 5, this.length() - 5);
- };
-
- return NMEntry;
- }(SystemUseEntry));
- /**
- * RockRidge: Records child link
- * @hidden
- */
- var CLEntry = (function (SystemUseEntry) {
- function CLEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) CLEntry.__proto__ = SystemUseEntry;
- CLEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- CLEntry.prototype.constructor = CLEntry;
- CLEntry.prototype.childDirectoryLba = function childDirectoryLba () {
- return this._data.readUInt32LE(4);
- };
-
- return CLEntry;
- }(SystemUseEntry));
- /**
- * RockRidge: Records parent link.
- * @hidden
- */
- var PLEntry = (function (SystemUseEntry) {
- function PLEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) PLEntry.__proto__ = SystemUseEntry;
- PLEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- PLEntry.prototype.constructor = PLEntry;
- PLEntry.prototype.parentDirectoryLba = function parentDirectoryLba () {
- return this._data.readUInt32LE(4);
- };
-
- return PLEntry;
- }(SystemUseEntry));
- /**
- * RockRidge: Records relocated directory.
- * @hidden
- */
- var REEntry = (function (SystemUseEntry) {
- function REEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) REEntry.__proto__ = SystemUseEntry;
- REEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- REEntry.prototype.constructor = REEntry;
-
- return REEntry;
- }(SystemUseEntry));
- /**
- * RockRidge: Records file timestamps
- * @hidden
- */
- var TFEntry = (function (SystemUseEntry) {
- function TFEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) TFEntry.__proto__ = SystemUseEntry;
- TFEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- TFEntry.prototype.constructor = TFEntry;
- TFEntry.prototype.flags = function flags () {
- return this._data[4];
- };
- TFEntry.prototype.creation = function creation () {
- if (this.flags() & 1 /* CREATION */) {
- if (this._longFormDates()) {
- return getDate(this._data, 5);
- }
- else {
- return getShortFormDate(this._data, 5);
- }
- }
- else {
- return null;
- }
- };
- TFEntry.prototype.modify = function modify () {
- if (this.flags() & 2 /* MODIFY */) {
- var previousDates = (this.flags() & 1 /* CREATION */) ? 1 : 0;
- if (this._longFormDates) {
- return getDate(this._data, 5 + (previousDates * 17));
- }
- else {
- return getShortFormDate(this._data, 5 + (previousDates * 7));
- }
- }
- else {
- return null;
- }
- };
- TFEntry.prototype.access = function access () {
- if (this.flags() & 4 /* ACCESS */) {
- var previousDates = (this.flags() & 1 /* CREATION */) ? 1 : 0;
- previousDates += (this.flags() & 2 /* MODIFY */) ? 1 : 0;
- if (this._longFormDates) {
- return getDate(this._data, 5 + (previousDates * 17));
- }
- else {
- return getShortFormDate(this._data, 5 + (previousDates * 7));
- }
- }
- else {
- return null;
- }
- };
- TFEntry.prototype.backup = function backup () {
- if (this.flags() & 16 /* BACKUP */) {
- var previousDates = (this.flags() & 1 /* CREATION */) ? 1 : 0;
- previousDates += (this.flags() & 2 /* MODIFY */) ? 1 : 0;
- previousDates += (this.flags() & 4 /* ACCESS */) ? 1 : 0;
- if (this._longFormDates) {
- return getDate(this._data, 5 + (previousDates * 17));
- }
- else {
- return getShortFormDate(this._data, 5 + (previousDates * 7));
- }
- }
- else {
- return null;
- }
- };
- TFEntry.prototype.expiration = function expiration () {
- if (this.flags() & 32 /* EXPIRATION */) {
- var previousDates = (this.flags() & 1 /* CREATION */) ? 1 : 0;
- previousDates += (this.flags() & 2 /* MODIFY */) ? 1 : 0;
- previousDates += (this.flags() & 4 /* ACCESS */) ? 1 : 0;
- previousDates += (this.flags() & 16 /* BACKUP */) ? 1 : 0;
- if (this._longFormDates) {
- return getDate(this._data, 5 + (previousDates * 17));
- }
- else {
- return getShortFormDate(this._data, 5 + (previousDates * 7));
- }
- }
- else {
- return null;
- }
- };
- TFEntry.prototype.effective = function effective () {
- if (this.flags() & 64 /* EFFECTIVE */) {
- var previousDates = (this.flags() & 1 /* CREATION */) ? 1 : 0;
- previousDates += (this.flags() & 2 /* MODIFY */) ? 1 : 0;
- previousDates += (this.flags() & 4 /* ACCESS */) ? 1 : 0;
- previousDates += (this.flags() & 16 /* BACKUP */) ? 1 : 0;
- previousDates += (this.flags() & 32 /* EXPIRATION */) ? 1 : 0;
- if (this._longFormDates) {
- return getDate(this._data, 5 + (previousDates * 17));
- }
- else {
- return getShortFormDate(this._data, 5 + (previousDates * 7));
- }
- }
- else {
- return null;
- }
- };
- TFEntry.prototype._longFormDates = function _longFormDates () {
- return !!(this.flags() && 128 /* LONG_FORM */);
- };
-
- return TFEntry;
- }(SystemUseEntry));
- /**
- * RockRidge: File data in sparse format.
- * @hidden
- */
- var SFEntry = (function (SystemUseEntry) {
- function SFEntry(data) {
- SystemUseEntry.call(this, data);
- }
-
- if ( SystemUseEntry ) SFEntry.__proto__ = SystemUseEntry;
- SFEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );
- SFEntry.prototype.constructor = SFEntry;
- SFEntry.prototype.virtualSizeHigh = function virtualSizeHigh () {
- return this._data.readUInt32LE(4);
- };
- SFEntry.prototype.virtualSizeLow = function virtualSizeLow () {
- return this._data.readUInt32LE(12);
- };
- SFEntry.prototype.tableDepth = function tableDepth () {
- return this._data[20];
- };
-
- return SFEntry;
- }(SystemUseEntry));
- /**
- * @hidden
- */
- var Directory = function Directory(record, isoData) {
- var this$1 = this;
-
- this._fileList = [];
- this._fileMap = {};
- this._record = record;
- var i = record.lba();
- var iLimit = i + record.dataLength();
- if (!(record.fileFlags() & 2 /* Directory */)) {
- // Must have a CL entry.
- var cl = record.getSUEntries(isoData).filter(function (e) { return e instanceof CLEntry; })[0];
- i = cl.childDirectoryLba() * 2048;
- iLimit = Infinity;
- }
- while (i < iLimit) {
- var len = isoData[i];
- // Zero-padding between sectors.
- // TODO: Could optimize this to seek to nearest-sector upon
- // seeing a 0.
- if (len === 0) {
- i++;
- continue;
- }
- var r = this$1._constructDirectoryRecord(isoData.slice(i));
- var fname = r.fileName(isoData);
- // Skip '.' and '..' entries.
- if (fname !== '\u0000' && fname !== '\u0001') {
- // Skip relocated entries.
- if (!r.hasRockRidge() || r.getSUEntries(isoData).filter(function (e) { return e instanceof REEntry; }).length === 0) {
- this$1._fileMap[fname] = r;
- this$1._fileList.push(fname);
- }
- }
- else if (iLimit === Infinity) {
- // First entry contains needed data.
- iLimit = i + r.dataLength();
- }
- i += r.length();
- }
- };
- /**
- * Get the record with the given name.
- * Returns undefined if not present.
- */
- Directory.prototype.getRecord = function getRecord (name) {
- return this._fileMap[name];
- };
- Directory.prototype.getFileList = function getFileList () {
- return this._fileList;
- };
- Directory.prototype.getDotEntry = function getDotEntry (isoData) {
- return this._constructDirectoryRecord(isoData.slice(this._record.lba()));
- };
- /**
- * @hidden
- */
- var ISODirectory = (function (Directory) {
- function ISODirectory(record, isoData) {
- Directory.call(this, record, isoData);
- }
-
- if ( Directory ) ISODirectory.__proto__ = Directory;
- ISODirectory.prototype = Object.create( Directory && Directory.prototype );
- ISODirectory.prototype.constructor = ISODirectory;
- ISODirectory.prototype._constructDirectoryRecord = function _constructDirectoryRecord (data) {
- return new ISODirectoryRecord(data, this._record.getRockRidgeOffset());
- };
-
- return ISODirectory;
- }(Directory));
- /**
- * @hidden
- */
- var JolietDirectory = (function (Directory) {
- function JolietDirectory(record, isoData) {
- Directory.call(this, record, isoData);
- }
-
- if ( Directory ) JolietDirectory.__proto__ = Directory;
- JolietDirectory.prototype = Object.create( Directory && Directory.prototype );
- JolietDirectory.prototype.constructor = JolietDirectory;
- JolietDirectory.prototype._constructDirectoryRecord = function _constructDirectoryRecord (data) {
- return new JolietDirectoryRecord(data, this._record.getRockRidgeOffset());
- };
-
- return JolietDirectory;
- }(Directory));
- /**
- * Mounts an ISO file as a read-only file system.
- *
- * Supports:
- * * Vanilla ISO9660 ISOs
- * * Microsoft Joliet and Rock Ridge extensions to the ISO9660 standard
- */
- var IsoFS = (function (SynchronousFileSystem$$1) {
- function IsoFS(data, name, deprecateMsg) {
- var this$1 = this;
- if ( name === void 0 ) name = "";
- if ( deprecateMsg === void 0 ) deprecateMsg = true;
-
- SynchronousFileSystem$$1.call(this);
- this._data = data;
- deprecationMessage(deprecateMsg, IsoFS.Name, { data: "ISO data as a Buffer", name: name });
- // Skip first 16 sectors.
- var vdTerminatorFound = false;
- var i = 16 * 2048;
- var candidateVDs = new Array();
- while (!vdTerminatorFound) {
- var slice = data.slice(i);
- var vd = new VolumeDescriptor(slice);
- switch (vd.type()) {
- case 1 /* PrimaryVolumeDescriptor */:
- candidateVDs.push(new PrimaryVolumeDescriptor(slice));
- break;
- case 2 /* SupplementaryVolumeDescriptor */:
- candidateVDs.push(new SupplementaryVolumeDescriptor(slice));
- break;
- case 255 /* VolumeDescriptorSetTerminator */:
- vdTerminatorFound = true;
- break;
- }
- i += 2048;
- }
- if (candidateVDs.length === 0) {
- throw new ApiError(ErrorCode.EIO, "Unable to find a suitable volume descriptor.");
- }
- candidateVDs.forEach(function (v) {
- // Take an SVD over a PVD.
- if (!this$1._pvd || this$1._pvd.type() !== 2 /* SupplementaryVolumeDescriptor */) {
- this$1._pvd = v;
- }
- });
- this._root = this._pvd.rootDirectoryEntry(data);
- this._name = name;
- }
-
- if ( SynchronousFileSystem$$1 ) IsoFS.__proto__ = SynchronousFileSystem$$1;
- IsoFS.prototype = Object.create( SynchronousFileSystem$$1 && SynchronousFileSystem$$1.prototype );
- IsoFS.prototype.constructor = IsoFS;
- /**
- * Creates an IsoFS instance with the given options.
- */
- IsoFS.Create = function Create (opts, cb) {
- var fs;
- var e;
- try {
- fs = new IsoFS(opts.data, opts.name, false);
- }
- catch (e) {
- e = e;
- }
- finally {
- cb(e, fs);
- }
- };
- IsoFS.isAvailable = function isAvailable () {
- return true;
- };
- IsoFS.prototype.getName = function getName () {
- var name = "IsoFS" + (this._name) + (this._pvd ? ("-" + (this._pvd.name())) : '');
- if (this._root && this._root.hasRockRidge()) {
- name += "-RockRidge";
- }
- return name;
- };
- IsoFS.prototype.diskSpace = function diskSpace (path$$1, cb) {
- // Read-only file system.
- cb(this._data.length, 0);
- };
- IsoFS.prototype.isReadOnly = function isReadOnly () {
- return true;
- };
- IsoFS.prototype.supportsLinks = function supportsLinks () {
- return false;
- };
- IsoFS.prototype.supportsProps = function supportsProps () {
- return false;
- };
- IsoFS.prototype.supportsSynch = function supportsSynch () {
- return true;
- };
- IsoFS.prototype.statSync = function statSync (p, isLstat) {
- var record = this._getDirectoryRecord(p);
- if (record === null) {
- throw ApiError.ENOENT(p);
- }
- return this._getStats(p, record);
- };
- IsoFS.prototype.openSync = function openSync (p, flags, mode) {
- // INVARIANT: Cannot write to RO file systems.
- if (flags.isWriteable()) {
- throw new ApiError(ErrorCode.EPERM, p);
- }
- // Check if the path exists, and is a file.
- var record = this._getDirectoryRecord(p);
- if (!record) {
- throw ApiError.ENOENT(p);
- }
- else if (record.isSymlink(this._data)) {
- return this.openSync(path.resolve(p, record.getSymlinkPath(this._data)), flags, mode);
- }
- else if (!record.isDirectory(this._data)) {
- var data = record.getFile(this._data);
- var stats = this._getStats(p, record);
- switch (flags.pathExistsAction()) {
- case ActionType.THROW_EXCEPTION:
- case ActionType.TRUNCATE_FILE:
- throw ApiError.EEXIST(p);
- case ActionType.NOP:
- return new NoSyncFile(this, p, flags, stats, data);
- default:
- throw new ApiError(ErrorCode.EINVAL, 'Invalid FileMode object.');
- }
- }
- else {
- throw ApiError.EISDIR(p);
- }
- };
- IsoFS.prototype.readdirSync = function readdirSync (path$$1) {
- // Check if it exists.
- var record = this._getDirectoryRecord(path$$1);
- if (!record) {
- throw ApiError.ENOENT(path$$1);
- }
- else if (record.isDirectory(this._data)) {
- return record.getDirectory(this._data).getFileList().slice(0);
- }
- else {
- throw ApiError.ENOTDIR(path$$1);
- }
- };
- /**
- * Specially-optimized readfile.
- */
- IsoFS.prototype.readFileSync = function readFileSync (fname, encoding, flag) {
- // Get file.
- var fd = this.openSync(fname, flag, 0x1a4);
- try {
- var fdCast = fd;
- var fdBuff = fdCast.getBuffer();
- if (encoding === null) {
- return copyingSlice(fdBuff);
- }
- return fdBuff.toString(encoding);
- }
- finally {
- fd.closeSync();
- }
- };
- IsoFS.prototype._getDirectoryRecord = function _getDirectoryRecord (path$$1) {
- var this$1 = this;
-
- // Special case.
- if (path$$1 === '/') {
- return this._root;
- }
- var components = path$$1.split('/').slice(1);
- var dir = this._root;
- for (var i = 0, list = components; i < list.length; i += 1) {
- var component = list[i];
-
- if (dir.isDirectory(this$1._data)) {
- dir = dir.getDirectory(this$1._data).getRecord(component);
- if (!dir) {
- return null;
- }
- }
- else {
- return null;
- }
- }
- return dir;
- };
- IsoFS.prototype._getStats = function _getStats (p, record) {
- if (record.isSymlink(this._data)) {
- var newP = path.resolve(p, record.getSymlinkPath(this._data));
- var dirRec = this._getDirectoryRecord(newP);
- if (!dirRec) {
- return null;
- }
- return this._getStats(newP, dirRec);
- }
- else {
- var len = record.dataLength();
- var mode = 0x16D;
- var date = record.recordingDate();
- var atime = date;
- var mtime = date;
- var ctime = date;
- if (record.hasRockRidge()) {
- var entries = record.getSUEntries(this._data);
- for (var i = 0, list = entries; i < list.length; i += 1) {
- var entry = list[i];
-
- if (entry instanceof PXEntry) {
- mode = entry.mode();
- }
- else if (entry instanceof TFEntry) {
- var flags = entry.flags();
- if (flags & 4 /* ACCESS */) {
- atime = entry.access();
- }
- if (flags & 2 /* MODIFY */) {
- mtime = entry.modify();
- }
- if (flags & 1 /* CREATION */) {
- ctime = entry.creation();
- }
- }
- }
- }
- // Mask out writeable flags. This is a RO file system.
- mode = mode & 0x16D;
- return new Stats(record.isDirectory(this._data) ? FileType.DIRECTORY : FileType.FILE, len, mode, atime, mtime, ctime);
- }
- };
-
- return IsoFS;
- }(SynchronousFileSystem));
-
- IsoFS.Name = "IsoFS";
- IsoFS.Options = {
- data: {
- type: "object",
- description: "The ISO file in a buffer",
- validator: bufferValidator
- }
- };
-
- // Monkey-patch `Create` functions to check options before file system initialization.
- [AsyncMirror, DropboxFileSystem, EmscriptenFileSystem, FolderAdapter, HTML5FS, InMemoryFileSystem, IndexedDBFileSystem, IsoFS, LocalStorageFileSystem, MountableFileSystem, OverlayFS, WorkerFS, XmlHttpRequest, ZipFS].forEach(function (fsType) {
- var create = fsType.Create;
- fsType.Create = function (opts, cb) {
- var oneArg = typeof (opts) === "function";
- var normalizedCb = oneArg ? opts : cb;
- var normalizedOpts = oneArg ? {} : opts;
- function wrappedCb(e) {
- if (e) {
- normalizedCb(e);
- }
- else {
- create.call(fsType, normalizedOpts, normalizedCb);
- }
- }
- checkOptions(fsType, normalizedOpts, wrappedCb);
- };
- });
- /**
- * @hidden
- */
- var Backends = { AsyncMirror: AsyncMirror, Dropbox: DropboxFileSystem, Emscripten: EmscriptenFileSystem, FolderAdapter: FolderAdapter, HTML5FS: HTML5FS, InMemory: InMemoryFileSystem, IndexedDB: IndexedDBFileSystem, IsoFS: IsoFS, LocalStorage: LocalStorageFileSystem, MountableFileSystem: MountableFileSystem, OverlayFS: OverlayFS, WorkerFS: WorkerFS, XmlHttpRequest: XmlHttpRequest, ZipFS: ZipFS };
-
- /**
- * BrowserFS's main module. This is exposed in the browser via the BrowserFS global.
- * Due to limitations in typedoc, we document these functions in ./typedoc.ts.
- */
- if (process['initializeTTYs']) {
- process['initializeTTYs']();
- }
- /**
- * Installs BFSRequire as global `require`, a Node Buffer polyfill as the global `Buffer` variable,
- * and a Node process polyfill as the global `process` variable.
- */
- function install(obj) {
- obj.Buffer = Buffer;
- obj.process = process;
- var oldRequire = obj.require ? obj.require : null;
- // Monkey-patch require for Node-style code.
- obj.require = function (arg) {
- var rv = BFSRequire(arg);
- if (!rv) {
- return oldRequire.apply(null, Array.prototype.slice.call(arguments, 0));
- }
- else {
- return rv;
- }
- };
- }
- /**
- * @hidden
- */
- function registerFileSystem(name, fs) {
- Backends[name] = fs;
- }
- function BFSRequire(module) {
- switch (module) {
- case 'fs':
- return _fsMock;
- case 'path':
- return path;
- case 'buffer':
- // The 'buffer' module has 'Buffer' as a property.
- return buffer;
- case 'process':
- return process;
- case 'bfs_utils':
- return BFSUtils;
- default:
- return Backends[module];
- }
- }
- /**
- * Initializes BrowserFS with the given root file system.
- */
- function initialize(rootfs) {
- return _fsMock.initialize(rootfs);
- }
- /**
- * Creates a file system with the given configuration, and initializes BrowserFS with it.
- * See the FileSystemConfiguration type for more info on the configuration object.
- */
- function configure(config, cb) {
- getFileSystem(config, function (e, fs) {
- if (fs) {
- initialize(fs);
- cb();
- }
- else {
- cb(e);
- }
- });
- }
- /**
- * Retrieve a file system with the given configuration.
- * @param config A FileSystemConfiguration object. See FileSystemConfiguration for details.
- * @param cb Called when the file system is constructed, or when an error occurs.
- */
- function getFileSystem(config, cb) {
- var fsName = config['fs'];
- if (!fsName) {
- return cb(new ApiError(ErrorCode.EPERM, 'Missing "fs" property on configuration object.'));
- }
- var options = config['options'];
- var waitCount = 0;
- var called = false;
- function finish() {
- if (!called) {
- called = true;
- var fsc = Backends[fsName];
- if (!fsc) {
- cb(new ApiError(ErrorCode.EPERM, ("File system " + fsName + " is not available in BrowserFS.")));
- }
- else {
- fsc.Create(options, cb);
- }
- }
- }
- if (options !== null && typeof (options) === "object") {
- var finishedIterating = false;
- var props = Object.keys(options).filter(function (k) { return k !== 'fs'; });
- // Check recursively if other fields have 'fs' properties.
- props.forEach(function (p) {
- var d = options[p];
- if (d !== null && typeof (d) === "object" && d['fs']) {
- waitCount++;
- getFileSystem(d, function (e, fs) {
- waitCount--;
- if (e) {
- if (called) {
- return;
- }
- called = true;
- cb(e);
- }
- else {
- options[p] = fs;
- if (waitCount === 0 && finishedIterating) {
- finish();
- }
- }
- });
- }
- });
- finishedIterating = true;
- }
- if (waitCount === 0) {
- finish();
- }
- }
-
- /**
- * BrowserFS's main entry point.
- * It installs all of the needed polyfills, and requires() the main module.
- */
- // IE substr does not support negative indices
- if ('ab'.substr(-1) !== 'b') {
- String.prototype.substr = function (substr) {
- return function (start, length) {
- // did we get a negative start, calculate how much it is from the
- // beginning of the string
- if (start < 0) {
- start = this.length + start;
- }
- // call the original function
- return substr.call(this, start, length);
- };
- }(String.prototype.substr);
- }
- // Polyfill for Uint8Array.prototype.slice.
- // Safari and some other browsers do not define it.
- if (typeof (ArrayBuffer) !== 'undefined' && typeof (Uint8Array) !== 'undefined') {
- if (!Uint8Array.prototype['slice']) {
- Uint8Array.prototype.slice = function (start, end) {
- if ( start === void 0 ) start = 0;
- if ( end === void 0 ) end = this.length;
-
- var self = this;
- if (start < 0) {
- start = this.length + start;
- if (start < 0) {
- start = 0;
- }
- }
- if (end < 0) {
- end = this.length + end;
- if (end < 0) {
- end = 0;
- }
- }
- if (end < start) {
- end = start;
- }
- return new Uint8Array(self.buffer, self.byteOffset + start, end - start);
- };
- }
- }
-
- exports.install = install;
- exports.registerFileSystem = registerFileSystem;
- exports.BFSRequire = BFSRequire;
- exports.initialize = initialize;
- exports.configure = configure;
- exports.getFileSystem = getFileSystem;
- exports.EmscriptenFS = BFSEmscriptenFS;
- exports.FileSystem = Backends;
- exports.Errors = api_error;
- exports.setImmediate = setImmediate$3;
-
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1), (function() { return this; }()), __webpack_require__(5)(module), __webpack_require__(6)))
-
-/***/ },
-/* 1 */
-/***/ function(module, exports, __webpack_require__) {
-
- module.exports = __webpack_require__(2).Buffer;
-
-
-/***/ },
-/* 2 */
-/***/ function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
- * The buffer module from node.js, for the browser.
- *
- * @author Feross Aboukhadijeh
- * @license MIT
- */
- /* eslint-disable no-proto */
-
- 'use strict'
-
- var base64 = __webpack_require__(3)
- var ieee754 = __webpack_require__(4)
-
- exports.Buffer = Buffer
- exports.SlowBuffer = SlowBuffer
- exports.INSPECT_MAX_BYTES = 50
-
- var K_MAX_LENGTH = 0x7fffffff
- exports.kMaxLength = K_MAX_LENGTH
-
- /**
- * If `Buffer.TYPED_ARRAY_SUPPORT`:
- * === true Use Uint8Array implementation (fastest)
- * === false Print warning and recommend using `buffer` v4.x which has an Object
- * implementation (most compatible, even IE6)
- *
- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
- * Opera 11.6+, iOS 4.2+.
- *
- * We report that the browser does not support typed arrays if the are not subclassable
- * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
- * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
- * for __proto__ and has a buggy typed array implementation.
- */
- Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
-
- if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
- typeof console.error === 'function') {
- console.error(
- 'This browser lacks typed array (Uint8Array) support which is required by ' +
- '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
- )
- }
-
- function typedArraySupport () {
- // Can typed array instances can be augmented?
- try {
- var arr = new Uint8Array(1)
- arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
- return arr.foo() === 42
- } catch (e) {
- return false
- }
- }
-
- function createBuffer (length) {
- if (length > K_MAX_LENGTH) {
- throw new RangeError('Invalid typed array length')
- }
- // Return an augmented `Uint8Array` instance
- var buf = new Uint8Array(length)
- buf.__proto__ = Buffer.prototype
- return buf
- }
-
- /**
- * The Buffer constructor returns instances of `Uint8Array` that have their
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
- * returns a single octet.
- *
- * The `Uint8Array` prototype remains unmodified.
- */
-
- function Buffer (arg, encodingOrOffset, length) {
- // Common case.
- if (typeof arg === 'number') {
- if (typeof encodingOrOffset === 'string') {
- throw new Error(
- 'If encoding is specified then the first argument must be a string'
- )
- }
- return allocUnsafe(arg)
- }
- return from(arg, encodingOrOffset, length)
- }
-
- // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
- if (typeof Symbol !== 'undefined' && Symbol.species &&
- Buffer[Symbol.species] === Buffer) {
- Object.defineProperty(Buffer, Symbol.species, {
- value: null,
- configurable: true,
- enumerable: false,
- writable: false
- })
- }
-
- Buffer.poolSize = 8192 // not used by this implementation
-
- function from (value, encodingOrOffset, length) {
- if (typeof value === 'number') {
- throw new TypeError('"value" argument must not be a number')
- }
-
- if (isArrayBuffer(value)) {
- return fromArrayBuffer(value, encodingOrOffset, length)
- }
-
- if (typeof value === 'string') {
- return fromString(value, encodingOrOffset)
- }
-
- return fromObject(value)
- }
-
- /**
- * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
- * if value is a number.
- * Buffer.from(str[, encoding])
- * Buffer.from(array)
- * Buffer.from(buffer)
- * Buffer.from(arrayBuffer[, byteOffset[, length]])
- **/
- Buffer.from = function (value, encodingOrOffset, length) {
- return from(value, encodingOrOffset, length)
- }
-
- // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
- // https://github.com/feross/buffer/pull/148
- Buffer.prototype.__proto__ = Uint8Array.prototype
- Buffer.__proto__ = Uint8Array
-
- function assertSize (size) {
- if (typeof size !== 'number') {
- throw new TypeError('"size" argument must be a number')
- } else if (size < 0) {
- throw new RangeError('"size" argument must not be negative')
- }
- }
-
- function alloc (size, fill, encoding) {
- assertSize(size)
- if (size <= 0) {
- return createBuffer(size)
- }
- if (fill !== undefined) {
- // Only pay attention to encoding if it's a string. This
- // prevents accidentally sending in a number that would
- // be interpretted as a start offset.
- return typeof encoding === 'string'
- ? createBuffer(size).fill(fill, encoding)
- : createBuffer(size).fill(fill)
- }
- return createBuffer(size)
- }
-
- /**
- * Creates a new filled Buffer instance.
- * alloc(size[, fill[, encoding]])
- **/
- Buffer.alloc = function (size, fill, encoding) {
- return alloc(size, fill, encoding)
- }
-
- function allocUnsafe (size) {
- assertSize(size)
- return createBuffer(size < 0 ? 0 : checked(size) | 0)
- }
-
- /**
- * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
- * */
- Buffer.allocUnsafe = function (size) {
- return allocUnsafe(size)
- }
- /**
- * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
- */
- Buffer.allocUnsafeSlow = function (size) {
- return allocUnsafe(size)
- }
-
- function fromString (string, encoding) {
- if (typeof encoding !== 'string' || encoding === '') {
- encoding = 'utf8'
- }
-
- if (!Buffer.isEncoding(encoding)) {
- throw new TypeError('"encoding" must be a valid string encoding')
- }
-
- var length = byteLength(string, encoding) | 0
- var buf = createBuffer(length)
-
- var actual = buf.write(string, encoding)
-
- if (actual !== length) {
- // Writing a hex string, for example, that contains invalid characters will
- // cause everything after the first invalid character to be ignored. (e.g.
- // 'abxxcd' will be treated as 'ab')
- buf = buf.slice(0, actual)
- }
-
- return buf
- }
-
- function fromArrayLike (array) {
- var length = array.length < 0 ? 0 : checked(array.length) | 0
- var buf = createBuffer(length)
- for (var i = 0; i < length; i += 1) {
- buf[i] = array[i] & 255
- }
- return buf
- }
-
- function fromArrayBuffer (array, byteOffset, length) {
- if (byteOffset < 0 || array.byteLength < byteOffset) {
- throw new RangeError('\'offset\' is out of bounds')
- }
-
- if (array.byteLength < byteOffset + (length || 0)) {
- throw new RangeError('\'length\' is out of bounds')
- }
-
- var buf
- if (byteOffset === undefined && length === undefined) {
- buf = new Uint8Array(array)
- } else if (length === undefined) {
- buf = new Uint8Array(array, byteOffset)
- } else {
- buf = new Uint8Array(array, byteOffset, length)
- }
-
- // Return an augmented `Uint8Array` instance
- buf.__proto__ = Buffer.prototype
- return buf
- }
-
- function fromObject (obj) {
- if (Buffer.isBuffer(obj)) {
- var len = checked(obj.length) | 0
- var buf = createBuffer(len)
-
- if (buf.length === 0) {
- return buf
- }
-
- obj.copy(buf, 0, 0, len)
- return buf
- }
-
- if (obj) {
- if (isArrayBufferView(obj) || 'length' in obj) {
- if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
- return createBuffer(0)
- }
- return fromArrayLike(obj)
- }
-
- if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
- return fromArrayLike(obj.data)
- }
- }
-
- throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
- }
-
- function checked (length) {
- // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
- // length is NaN (which is otherwise coerced to zero.)
- if (length >= K_MAX_LENGTH) {
- throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
- 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
- }
- return length | 0
- }
-
- function SlowBuffer (length) {
- if (+length != length) { // eslint-disable-line eqeqeq
- length = 0
- }
- return Buffer.alloc(+length)
- }
-
- Buffer.isBuffer = function isBuffer (b) {
- return b != null && b._isBuffer === true
- }
-
- Buffer.compare = function compare (a, b) {
- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
- throw new TypeError('Arguments must be Buffers')
- }
-
- if (a === b) return 0
-
- var x = a.length
- var y = b.length
-
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
- if (a[i] !== b[i]) {
- x = a[i]
- y = b[i]
- break
- }
- }
-
- if (x < y) return -1
- if (y < x) return 1
- return 0
- }
-
- Buffer.isEncoding = function isEncoding (encoding) {
- switch (String(encoding).toLowerCase()) {
- case 'hex':
- case 'utf8':
- case 'utf-8':
- case 'ascii':
- case 'latin1':
- case 'binary':
- case 'base64':
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return true
- default:
- return false
- }
- }
-
- Buffer.concat = function concat (list, length) {
- if (!Array.isArray(list)) {
- throw new TypeError('"list" argument must be an Array of Buffers')
- }
-
- if (list.length === 0) {
- return Buffer.alloc(0)
- }
-
- var i
- if (length === undefined) {
- length = 0
- for (i = 0; i < list.length; ++i) {
- length += list[i].length
- }
- }
-
- var buffer = Buffer.allocUnsafe(length)
- var pos = 0
- for (i = 0; i < list.length; ++i) {
- var buf = list[i]
- if (!Buffer.isBuffer(buf)) {
- throw new TypeError('"list" argument must be an Array of Buffers')
- }
- buf.copy(buffer, pos)
- pos += buf.length
- }
- return buffer
- }
-
- function byteLength (string, encoding) {
- if (Buffer.isBuffer(string)) {
- return string.length
- }
- if (isArrayBufferView(string) || isArrayBuffer(string)) {
- return string.byteLength
- }
- if (typeof string !== 'string') {
- string = '' + string
- }
-
- var len = string.length
- if (len === 0) return 0
-
- // Use a for loop to avoid recursion
- var loweredCase = false
- for (;;) {
- switch (encoding) {
- case 'ascii':
- case 'latin1':
- case 'binary':
- return len
- case 'utf8':
- case 'utf-8':
- case undefined:
- return utf8ToBytes(string).length
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return len * 2
- case 'hex':
- return len >>> 1
- case 'base64':
- return base64ToBytes(string).length
- default:
- if (loweredCase) return utf8ToBytes(string).length // assume utf8
- encoding = ('' + encoding).toLowerCase()
- loweredCase = true
- }
- }
- }
- Buffer.byteLength = byteLength
-
- function slowToString (encoding, start, end) {
- var loweredCase = false
-
- // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
- // property of a typed array.
-
- // This behaves neither like String nor Uint8Array in that we set start/end
- // to their upper/lower bounds if the value passed is out of range.
- // undefined is handled specially as per ECMA-262 6th Edition,
- // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
- if (start === undefined || start < 0) {
- start = 0
- }
- // Return early if start > this.length. Done here to prevent potential uint32
- // coercion fail below.
- if (start > this.length) {
- return ''
- }
-
- if (end === undefined || end > this.length) {
- end = this.length
- }
-
- if (end <= 0) {
- return ''
- }
-
- // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
- end >>>= 0
- start >>>= 0
-
- if (end <= start) {
- return ''
- }
-
- if (!encoding) encoding = 'utf8'
-
- while (true) {
- switch (encoding) {
- case 'hex':
- return hexSlice(this, start, end)
-
- case 'utf8':
- case 'utf-8':
- return utf8Slice(this, start, end)
-
- case 'ascii':
- return asciiSlice(this, start, end)
-
- case 'latin1':
- case 'binary':
- return latin1Slice(this, start, end)
-
- case 'base64':
- return base64Slice(this, start, end)
-
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return utf16leSlice(this, start, end)
-
- default:
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
- encoding = (encoding + '').toLowerCase()
- loweredCase = true
- }
- }
- }
-
- // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
- // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
- // reliably in a browserify context because there could be multiple different
- // copies of the 'buffer' package in use. This method works even for Buffer
- // instances that were created from another copy of the `buffer` package.
- // See: https://github.com/feross/buffer/issues/154
- Buffer.prototype._isBuffer = true
-
- function swap (b, n, m) {
- var i = b[n]
- b[n] = b[m]
- b[m] = i
- }
-
- Buffer.prototype.swap16 = function swap16 () {
- var len = this.length
- if (len % 2 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 16-bits')
- }
- for (var i = 0; i < len; i += 2) {
- swap(this, i, i + 1)
- }
- return this
- }
-
- Buffer.prototype.swap32 = function swap32 () {
- var len = this.length
- if (len % 4 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 32-bits')
- }
- for (var i = 0; i < len; i += 4) {
- swap(this, i, i + 3)
- swap(this, i + 1, i + 2)
- }
- return this
- }
-
- Buffer.prototype.swap64 = function swap64 () {
- var len = this.length
- if (len % 8 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 64-bits')
- }
- for (var i = 0; i < len; i += 8) {
- swap(this, i, i + 7)
- swap(this, i + 1, i + 6)
- swap(this, i + 2, i + 5)
- swap(this, i + 3, i + 4)
- }
- return this
- }
-
- Buffer.prototype.toString = function toString () {
- var length = this.length
- if (length === 0) return ''
- if (arguments.length === 0) return utf8Slice(this, 0, length)
- return slowToString.apply(this, arguments)
- }
-
- Buffer.prototype.equals = function equals (b) {
- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
- if (this === b) return true
- return Buffer.compare(this, b) === 0
- }
-
- Buffer.prototype.inspect = function inspect () {
- var str = ''
- var max = exports.INSPECT_MAX_BYTES
- if (this.length > 0) {
- str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
- if (this.length > max) str += ' ... '
- }
- return ''
- }
-
- Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
- if (!Buffer.isBuffer(target)) {
- throw new TypeError('Argument must be a Buffer')
- }
-
- if (start === undefined) {
- start = 0
- }
- if (end === undefined) {
- end = target ? target.length : 0
- }
- if (thisStart === undefined) {
- thisStart = 0
- }
- if (thisEnd === undefined) {
- thisEnd = this.length
- }
-
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
- throw new RangeError('out of range index')
- }
-
- if (thisStart >= thisEnd && start >= end) {
- return 0
- }
- if (thisStart >= thisEnd) {
- return -1
- }
- if (start >= end) {
- return 1
- }
-
- start >>>= 0
- end >>>= 0
- thisStart >>>= 0
- thisEnd >>>= 0
-
- if (this === target) return 0
-
- var x = thisEnd - thisStart
- var y = end - start
- var len = Math.min(x, y)
-
- var thisCopy = this.slice(thisStart, thisEnd)
- var targetCopy = target.slice(start, end)
-
- for (var i = 0; i < len; ++i) {
- if (thisCopy[i] !== targetCopy[i]) {
- x = thisCopy[i]
- y = targetCopy[i]
- break
- }
- }
-
- if (x < y) return -1
- if (y < x) return 1
- return 0
- }
-
- // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
- // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
- //
- // Arguments:
- // - buffer - a Buffer to search
- // - val - a string, Buffer, or number
- // - byteOffset - an index into `buffer`; will be clamped to an int32
- // - encoding - an optional encoding, relevant is val is a string
- // - dir - true for indexOf, false for lastIndexOf
- function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
- // Empty buffer means no match
- if (buffer.length === 0) return -1
-
- // Normalize byteOffset
- if (typeof byteOffset === 'string') {
- encoding = byteOffset
- byteOffset = 0
- } else if (byteOffset > 0x7fffffff) {
- byteOffset = 0x7fffffff
- } else if (byteOffset < -0x80000000) {
- byteOffset = -0x80000000
- }
- byteOffset = +byteOffset // Coerce to Number.
- if (numberIsNaN(byteOffset)) {
- // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
- byteOffset = dir ? 0 : (buffer.length - 1)
- }
-
- // Normalize byteOffset: negative offsets start from the end of the buffer
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset
- if (byteOffset >= buffer.length) {
- if (dir) return -1
- else byteOffset = buffer.length - 1
- } else if (byteOffset < 0) {
- if (dir) byteOffset = 0
- else return -1
- }
-
- // Normalize val
- if (typeof val === 'string') {
- val = Buffer.from(val, encoding)
- }
-
- // Finally, search either indexOf (if dir is true) or lastIndexOf
- if (Buffer.isBuffer(val)) {
- // Special case: looking for empty string/buffer always fails
- if (val.length === 0) {
- return -1
- }
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
- } else if (typeof val === 'number') {
- val = val & 0xFF // Search for a byte value [0-255]
- if (typeof Uint8Array.prototype.indexOf === 'function') {
- if (dir) {
- return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
- } else {
- return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
- }
- }
- return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
- }
-
- throw new TypeError('val must be string, number or Buffer')
- }
-
- function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
- var indexSize = 1
- var arrLength = arr.length
- var valLength = val.length
-
- if (encoding !== undefined) {
- encoding = String(encoding).toLowerCase()
- if (encoding === 'ucs2' || encoding === 'ucs-2' ||
- encoding === 'utf16le' || encoding === 'utf-16le') {
- if (arr.length < 2 || val.length < 2) {
- return -1
- }
- indexSize = 2
- arrLength /= 2
- valLength /= 2
- byteOffset /= 2
- }
- }
-
- function read (buf, i) {
- if (indexSize === 1) {
- return buf[i]
- } else {
- return buf.readUInt16BE(i * indexSize)
- }
- }
-
- var i
- if (dir) {
- var foundIndex = -1
- for (i = byteOffset; i < arrLength; i++) {
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
- if (foundIndex === -1) foundIndex = i
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
- } else {
- if (foundIndex !== -1) i -= i - foundIndex
- foundIndex = -1
- }
- }
- } else {
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
- for (i = byteOffset; i >= 0; i--) {
- var found = true
- for (var j = 0; j < valLength; j++) {
- if (read(arr, i + j) !== read(val, j)) {
- found = false
- break
- }
- }
- if (found) return i
- }
- }
-
- return -1
- }
-
- Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
- return this.indexOf(val, byteOffset, encoding) !== -1
- }
-
- Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
- }
-
- Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
- }
-
- function hexWrite (buf, string, offset, length) {
- offset = Number(offset) || 0
- var remaining = buf.length - offset
- if (!length) {
- length = remaining
- } else {
- length = Number(length)
- if (length > remaining) {
- length = remaining
- }
- }
-
- // must be an even number of digits
- var strLen = string.length
- if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
-
- if (length > strLen / 2) {
- length = strLen / 2
- }
- for (var i = 0; i < length; ++i) {
- var parsed = parseInt(string.substr(i * 2, 2), 16)
- if (numberIsNaN(parsed)) return i
- buf[offset + i] = parsed
- }
- return i
- }
-
- function utf8Write (buf, string, offset, length) {
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
- }
-
- function asciiWrite (buf, string, offset, length) {
- return blitBuffer(asciiToBytes(string), buf, offset, length)
- }
-
- function latin1Write (buf, string, offset, length) {
- return asciiWrite(buf, string, offset, length)
- }
-
- function base64Write (buf, string, offset, length) {
- return blitBuffer(base64ToBytes(string), buf, offset, length)
- }
-
- function ucs2Write (buf, string, offset, length) {
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
- }
-
- Buffer.prototype.write = function write (string, offset, length, encoding) {
- // Buffer#write(string)
- if (offset === undefined) {
- encoding = 'utf8'
- length = this.length
- offset = 0
- // Buffer#write(string, encoding)
- } else if (length === undefined && typeof offset === 'string') {
- encoding = offset
- length = this.length
- offset = 0
- // Buffer#write(string, offset[, length][, encoding])
- } else if (isFinite(offset)) {
- offset = offset >>> 0
- if (isFinite(length)) {
- length = length >>> 0
- if (encoding === undefined) encoding = 'utf8'
- } else {
- encoding = length
- length = undefined
- }
- } else {
- throw new Error(
- 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
- )
- }
-
- var remaining = this.length - offset
- if (length === undefined || length > remaining) length = remaining
-
- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
- throw new RangeError('Attempt to write outside buffer bounds')
- }
-
- if (!encoding) encoding = 'utf8'
-
- var loweredCase = false
- for (;;) {
- switch (encoding) {
- case 'hex':
- return hexWrite(this, string, offset, length)
-
- case 'utf8':
- case 'utf-8':
- return utf8Write(this, string, offset, length)
-
- case 'ascii':
- return asciiWrite(this, string, offset, length)
-
- case 'latin1':
- case 'binary':
- return latin1Write(this, string, offset, length)
-
- case 'base64':
- // Warning: maxLength not taken into account in base64Write
- return base64Write(this, string, offset, length)
-
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return ucs2Write(this, string, offset, length)
-
- default:
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
- encoding = ('' + encoding).toLowerCase()
- loweredCase = true
- }
- }
- }
-
- Buffer.prototype.toJSON = function toJSON () {
- return {
- type: 'Buffer',
- data: Array.prototype.slice.call(this._arr || this, 0)
- }
- }
-
- function base64Slice (buf, start, end) {
- if (start === 0 && end === buf.length) {
- return base64.fromByteArray(buf)
- } else {
- return base64.fromByteArray(buf.slice(start, end))
- }
- }
-
- function utf8Slice (buf, start, end) {
- end = Math.min(buf.length, end)
- var res = []
-
- var i = start
- while (i < end) {
- var firstByte = buf[i]
- var codePoint = null
- var bytesPerSequence = (firstByte > 0xEF) ? 4
- : (firstByte > 0xDF) ? 3
- : (firstByte > 0xBF) ? 2
- : 1
-
- if (i + bytesPerSequence <= end) {
- var secondByte, thirdByte, fourthByte, tempCodePoint
-
- switch (bytesPerSequence) {
- case 1:
- if (firstByte < 0x80) {
- codePoint = firstByte
- }
- break
- case 2:
- secondByte = buf[i + 1]
- if ((secondByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
- if (tempCodePoint > 0x7F) {
- codePoint = tempCodePoint
- }
- }
- break
- case 3:
- secondByte = buf[i + 1]
- thirdByte = buf[i + 2]
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
- codePoint = tempCodePoint
- }
- }
- break
- case 4:
- secondByte = buf[i + 1]
- thirdByte = buf[i + 2]
- fourthByte = buf[i + 3]
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
- codePoint = tempCodePoint
- }
- }
- }
- }
-
- if (codePoint === null) {
- // we did not generate a valid codePoint so insert a
- // replacement char (U+FFFD) and advance only 1 byte
- codePoint = 0xFFFD
- bytesPerSequence = 1
- } else if (codePoint > 0xFFFF) {
- // encode to utf16 (surrogate pair dance)
- codePoint -= 0x10000
- res.push(codePoint >>> 10 & 0x3FF | 0xD800)
- codePoint = 0xDC00 | codePoint & 0x3FF
- }
-
- res.push(codePoint)
- i += bytesPerSequence
- }
-
- return decodeCodePointsArray(res)
- }
-
- // Based on http://stackoverflow.com/a/22747272/680742, the browser with
- // the lowest limit is Chrome, with 0x10000 args.
- // We go 1 magnitude less, for safety
- var MAX_ARGUMENTS_LENGTH = 0x1000
-
- function decodeCodePointsArray (codePoints) {
- var len = codePoints.length
- if (len <= MAX_ARGUMENTS_LENGTH) {
- return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
- }
-
- // Decode in chunks to avoid "call stack size exceeded".
- var res = ''
- var i = 0
- while (i < len) {
- res += String.fromCharCode.apply(
- String,
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
- )
- }
- return res
- }
-
- function asciiSlice (buf, start, end) {
- var ret = ''
- end = Math.min(buf.length, end)
-
- for (var i = start; i < end; ++i) {
- ret += String.fromCharCode(buf[i] & 0x7F)
- }
- return ret
- }
-
- function latin1Slice (buf, start, end) {
- var ret = ''
- end = Math.min(buf.length, end)
-
- for (var i = start; i < end; ++i) {
- ret += String.fromCharCode(buf[i])
- }
- return ret
- }
-
- function hexSlice (buf, start, end) {
- var len = buf.length
-
- if (!start || start < 0) start = 0
- if (!end || end < 0 || end > len) end = len
-
- var out = ''
- for (var i = start; i < end; ++i) {
- out += toHex(buf[i])
- }
- return out
- }
-
- function utf16leSlice (buf, start, end) {
- var bytes = buf.slice(start, end)
- var res = ''
- for (var i = 0; i < bytes.length; i += 2) {
- res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
- }
- return res
- }
-
- Buffer.prototype.slice = function slice (start, end) {
- var len = this.length
- start = ~~start
- end = end === undefined ? len : ~~end
-
- if (start < 0) {
- start += len
- if (start < 0) start = 0
- } else if (start > len) {
- start = len
- }
-
- if (end < 0) {
- end += len
- if (end < 0) end = 0
- } else if (end > len) {
- end = len
- }
-
- if (end < start) end = start
-
- var newBuf = this.subarray(start, end)
- // Return an augmented `Uint8Array` instance
- newBuf.__proto__ = Buffer.prototype
- return newBuf
- }
-
- /*
- * Need to make sure that buffer isn't trying to write out of bounds.
- */
- function checkOffset (offset, ext, length) {
- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
- }
-
- Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
-
- var val = this[offset]
- var mul = 1
- var i = 0
- while (++i < byteLength && (mul *= 0x100)) {
- val += this[offset + i] * mul
- }
-
- return val
- }
-
- Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) {
- checkOffset(offset, byteLength, this.length)
- }
-
- var val = this[offset + --byteLength]
- var mul = 1
- while (byteLength > 0 && (mul *= 0x100)) {
- val += this[offset + --byteLength] * mul
- }
-
- return val
- }
-
- Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 1, this.length)
- return this[offset]
- }
-
- Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 2, this.length)
- return this[offset] | (this[offset + 1] << 8)
- }
-
- Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 2, this.length)
- return (this[offset] << 8) | this[offset + 1]
- }
-
- Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
-
- return ((this[offset]) |
- (this[offset + 1] << 8) |
- (this[offset + 2] << 16)) +
- (this[offset + 3] * 0x1000000)
- }
-
- Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
-
- return (this[offset] * 0x1000000) +
- ((this[offset + 1] << 16) |
- (this[offset + 2] << 8) |
- this[offset + 3])
- }
-
- Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
-
- var val = this[offset]
- var mul = 1
- var i = 0
- while (++i < byteLength && (mul *= 0x100)) {
- val += this[offset + i] * mul
- }
- mul *= 0x80
-
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
-
- return val
- }
-
- Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
-
- var i = byteLength
- var mul = 1
- var val = this[offset + --i]
- while (i > 0 && (mul *= 0x100)) {
- val += this[offset + --i] * mul
- }
- mul *= 0x80
-
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
-
- return val
- }
-
- Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 1, this.length)
- if (!(this[offset] & 0x80)) return (this[offset])
- return ((0xff - this[offset] + 1) * -1)
- }
-
- Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 2, this.length)
- var val = this[offset] | (this[offset + 1] << 8)
- return (val & 0x8000) ? val | 0xFFFF0000 : val
- }
-
- Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 2, this.length)
- var val = this[offset + 1] | (this[offset] << 8)
- return (val & 0x8000) ? val | 0xFFFF0000 : val
- }
-
- Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
-
- return (this[offset]) |
- (this[offset + 1] << 8) |
- (this[offset + 2] << 16) |
- (this[offset + 3] << 24)
- }
-
- Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
-
- return (this[offset] << 24) |
- (this[offset + 1] << 16) |
- (this[offset + 2] << 8) |
- (this[offset + 3])
- }
-
- Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ieee754.read(this, offset, true, 23, 4)
- }
-
- Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ieee754.read(this, offset, false, 23, 4)
- }
-
- Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 8, this.length)
- return ieee754.read(this, offset, true, 52, 8)
- }
-
- Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 8, this.length)
- return ieee754.read(this, offset, false, 52, 8)
- }
-
- function checkInt (buf, value, offset, ext, max, min) {
- if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
- if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
- }
-
- Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) {
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
- checkInt(this, value, offset, byteLength, maxBytes, 0)
- }
-
- var mul = 1
- var i = 0
- this[offset] = value & 0xFF
- while (++i < byteLength && (mul *= 0x100)) {
- this[offset + i] = (value / mul) & 0xFF
- }
-
- return offset + byteLength
- }
-
- Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) {
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
- checkInt(this, value, offset, byteLength, maxBytes, 0)
- }
-
- var i = byteLength - 1
- var mul = 1
- this[offset + i] = value & 0xFF
- while (--i >= 0 && (mul *= 0x100)) {
- this[offset + i] = (value / mul) & 0xFF
- }
-
- return offset + byteLength
- }
-
- Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
- this[offset] = (value & 0xff)
- return offset + 1
- }
-
- Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- return offset + 2
- }
-
- Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
- this[offset] = (value >>> 8)
- this[offset + 1] = (value & 0xff)
- return offset + 2
- }
-
- Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
- this[offset + 3] = (value >>> 24)
- this[offset + 2] = (value >>> 16)
- this[offset + 1] = (value >>> 8)
- this[offset] = (value & 0xff)
- return offset + 4
- }
-
- Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
- this[offset] = (value >>> 24)
- this[offset + 1] = (value >>> 16)
- this[offset + 2] = (value >>> 8)
- this[offset + 3] = (value & 0xff)
- return offset + 4
- }
-
- Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- var limit = Math.pow(2, (8 * byteLength) - 1)
-
- checkInt(this, value, offset, byteLength, limit - 1, -limit)
- }
-
- var i = 0
- var mul = 1
- var sub = 0
- this[offset] = value & 0xFF
- while (++i < byteLength && (mul *= 0x100)) {
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
- sub = 1
- }
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
- }
-
- return offset + byteLength
- }
-
- Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- var limit = Math.pow(2, (8 * byteLength) - 1)
-
- checkInt(this, value, offset, byteLength, limit - 1, -limit)
- }
-
- var i = byteLength - 1
- var mul = 1
- var sub = 0
- this[offset + i] = value & 0xFF
- while (--i >= 0 && (mul *= 0x100)) {
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
- sub = 1
- }
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
- }
-
- return offset + byteLength
- }
-
- Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
- if (value < 0) value = 0xff + value + 1
- this[offset] = (value & 0xff)
- return offset + 1
- }
-
- Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- return offset + 2
- }
-
- Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
- this[offset] = (value >>> 8)
- this[offset + 1] = (value & 0xff)
- return offset + 2
- }
-
- Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- this[offset + 2] = (value >>> 16)
- this[offset + 3] = (value >>> 24)
- return offset + 4
- }
-
- Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
- if (value < 0) value = 0xffffffff + value + 1
- this[offset] = (value >>> 24)
- this[offset + 1] = (value >>> 16)
- this[offset + 2] = (value >>> 8)
- this[offset + 3] = (value & 0xff)
- return offset + 4
- }
-
- function checkIEEE754 (buf, value, offset, ext, max, min) {
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
- if (offset < 0) throw new RangeError('Index out of range')
- }
-
- function writeFloat (buf, value, offset, littleEndian, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
- }
- ieee754.write(buf, value, offset, littleEndian, 23, 4)
- return offset + 4
- }
-
- Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
- return writeFloat(this, value, offset, true, noAssert)
- }
-
- Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
- return writeFloat(this, value, offset, false, noAssert)
- }
-
- function writeDouble (buf, value, offset, littleEndian, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
- }
- ieee754.write(buf, value, offset, littleEndian, 52, 8)
- return offset + 8
- }
-
- Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
- return writeDouble(this, value, offset, true, noAssert)
- }
-
- Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
- return writeDouble(this, value, offset, false, noAssert)
- }
-
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
- Buffer.prototype.copy = function copy (target, targetStart, start, end) {
- if (!start) start = 0
- if (!end && end !== 0) end = this.length
- if (targetStart >= target.length) targetStart = target.length
- if (!targetStart) targetStart = 0
- if (end > 0 && end < start) end = start
-
- // Copy 0 bytes; we're done
- if (end === start) return 0
- if (target.length === 0 || this.length === 0) return 0
-
- // Fatal error conditions
- if (targetStart < 0) {
- throw new RangeError('targetStart out of bounds')
- }
- if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
- if (end < 0) throw new RangeError('sourceEnd out of bounds')
-
- // Are we oob?
- if (end > this.length) end = this.length
- if (target.length - targetStart < end - start) {
- end = target.length - targetStart + start
- }
-
- var len = end - start
- var i
-
- if (this === target && start < targetStart && targetStart < end) {
- // descending copy from end
- for (i = len - 1; i >= 0; --i) {
- target[i + targetStart] = this[i + start]
- }
- } else if (len < 1000) {
- // ascending copy from start
- for (i = 0; i < len; ++i) {
- target[i + targetStart] = this[i + start]
- }
- } else {
- Uint8Array.prototype.set.call(
- target,
- this.subarray(start, start + len),
- targetStart
- )
- }
-
- return len
- }
-
- // Usage:
- // buffer.fill(number[, offset[, end]])
- // buffer.fill(buffer[, offset[, end]])
- // buffer.fill(string[, offset[, end]][, encoding])
- Buffer.prototype.fill = function fill (val, start, end, encoding) {
- // Handle string cases:
- if (typeof val === 'string') {
- if (typeof start === 'string') {
- encoding = start
- start = 0
- end = this.length
- } else if (typeof end === 'string') {
- encoding = end
- end = this.length
- }
- if (val.length === 1) {
- var code = val.charCodeAt(0)
- if (code < 256) {
- val = code
- }
- }
- if (encoding !== undefined && typeof encoding !== 'string') {
- throw new TypeError('encoding must be a string')
- }
- if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
- throw new TypeError('Unknown encoding: ' + encoding)
- }
- } else if (typeof val === 'number') {
- val = val & 255
- }
-
- // Invalid ranges are not set to a default, so can range check early.
- if (start < 0 || this.length < start || this.length < end) {
- throw new RangeError('Out of range index')
- }
-
- if (end <= start) {
- return this
- }
-
- start = start >>> 0
- end = end === undefined ? this.length : end >>> 0
-
- if (!val) val = 0
-
- var i
- if (typeof val === 'number') {
- for (i = start; i < end; ++i) {
- this[i] = val
- }
- } else {
- var bytes = Buffer.isBuffer(val)
- ? val
- : new Buffer(val, encoding)
- var len = bytes.length
- for (i = 0; i < end - start; ++i) {
- this[i + start] = bytes[i % len]
- }
- }
-
- return this
- }
-
- // HELPER FUNCTIONS
- // ================
-
- var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
-
- function base64clean (str) {
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
- str = str.trim().replace(INVALID_BASE64_RE, '')
- // Node converts strings with length < 2 to ''
- if (str.length < 2) return ''
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
- while (str.length % 4 !== 0) {
- str = str + '='
- }
- return str
- }
-
- function toHex (n) {
- if (n < 16) return '0' + n.toString(16)
- return n.toString(16)
- }
-
- function utf8ToBytes (string, units) {
- units = units || Infinity
- var codePoint
- var length = string.length
- var leadSurrogate = null
- var bytes = []
-
- for (var i = 0; i < length; ++i) {
- codePoint = string.charCodeAt(i)
-
- // is surrogate component
- if (codePoint > 0xD7FF && codePoint < 0xE000) {
- // last char was a lead
- if (!leadSurrogate) {
- // no lead yet
- if (codePoint > 0xDBFF) {
- // unexpected trail
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- continue
- } else if (i + 1 === length) {
- // unpaired lead
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- continue
- }
-
- // valid lead
- leadSurrogate = codePoint
-
- continue
- }
-
- // 2 leads in a row
- if (codePoint < 0xDC00) {
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- leadSurrogate = codePoint
- continue
- }
-
- // valid surrogate pair
- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
- } else if (leadSurrogate) {
- // valid bmp char, but last char was a lead
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- }
-
- leadSurrogate = null
-
- // encode utf8
- if (codePoint < 0x80) {
- if ((units -= 1) < 0) break
- bytes.push(codePoint)
- } else if (codePoint < 0x800) {
- if ((units -= 2) < 0) break
- bytes.push(
- codePoint >> 0x6 | 0xC0,
- codePoint & 0x3F | 0x80
- )
- } else if (codePoint < 0x10000) {
- if ((units -= 3) < 0) break
- bytes.push(
- codePoint >> 0xC | 0xE0,
- codePoint >> 0x6 & 0x3F | 0x80,
- codePoint & 0x3F | 0x80
- )
- } else if (codePoint < 0x110000) {
- if ((units -= 4) < 0) break
- bytes.push(
- codePoint >> 0x12 | 0xF0,
- codePoint >> 0xC & 0x3F | 0x80,
- codePoint >> 0x6 & 0x3F | 0x80,
- codePoint & 0x3F | 0x80
- )
- } else {
- throw new Error('Invalid code point')
- }
- }
-
- return bytes
- }
-
- function asciiToBytes (str) {
- var byteArray = []
- for (var i = 0; i < str.length; ++i) {
- // Node's code seems to be doing this and not & 0x7F..
- byteArray.push(str.charCodeAt(i) & 0xFF)
- }
- return byteArray
- }
-
- function utf16leToBytes (str, units) {
- var c, hi, lo
- var byteArray = []
- for (var i = 0; i < str.length; ++i) {
- if ((units -= 2) < 0) break
-
- c = str.charCodeAt(i)
- hi = c >> 8
- lo = c % 256
- byteArray.push(lo)
- byteArray.push(hi)
- }
-
- return byteArray
- }
-
- function base64ToBytes (str) {
- return base64.toByteArray(base64clean(str))
- }
-
- function blitBuffer (src, dst, offset, length) {
- for (var i = 0; i < length; ++i) {
- if ((i + offset >= dst.length) || (i >= src.length)) break
- dst[i + offset] = src[i]
- }
- return i
- }
-
- // ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check
- // but they should be treated as valid. See: https://github.com/feross/buffer/issues/166
- function isArrayBuffer (obj) {
- return obj instanceof ArrayBuffer ||
- (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&
- typeof obj.byteLength === 'number')
- }
-
- // Node 0.10 supports `ArrayBuffer` but lacks `ArrayBuffer.isView`
- function isArrayBufferView (obj) {
- return (typeof ArrayBuffer.isView === 'function') && ArrayBuffer.isView(obj)
- }
-
- function numberIsNaN (obj) {
- return obj !== obj // eslint-disable-line no-self-compare
- }
-
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)))
-
-/***/ },
-/* 3 */
-/***/ function(module, exports) {
-
- 'use strict'
-
- exports.byteLength = byteLength
- exports.toByteArray = toByteArray
- exports.fromByteArray = fromByteArray
-
- var lookup = []
- var revLookup = []
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
-
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
- for (var i = 0, len = code.length; i < len; ++i) {
- lookup[i] = code[i]
- revLookup[code.charCodeAt(i)] = i
- }
-
- revLookup['-'.charCodeAt(0)] = 62
- revLookup['_'.charCodeAt(0)] = 63
-
- function placeHoldersCount (b64) {
- var len = b64.length
- if (len % 4 > 0) {
- throw new Error('Invalid string. Length must be a multiple of 4')
- }
-
- // the number of equal signs (place holders)
- // if there are two placeholders, than the two characters before it
- // represent one byte
- // if there is only one, then the three characters before it represent 2 bytes
- // this is just a cheap hack to not do indexOf twice
- return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
- }
-
- function byteLength (b64) {
- // base64 is 4/3 + up to two characters of the original data
- return b64.length * 3 / 4 - placeHoldersCount(b64)
- }
-
- function toByteArray (b64) {
- var i, j, l, tmp, placeHolders, arr
- var len = b64.length
- placeHolders = placeHoldersCount(b64)
-
- arr = new Arr(len * 3 / 4 - placeHolders)
-
- // if there are placeholders, only get up to the last complete 4 chars
- l = placeHolders > 0 ? len - 4 : len
-
- var L = 0
-
- for (i = 0, j = 0; i < l; i += 4, j += 3) {
- tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
- arr[L++] = (tmp >> 16) & 0xFF
- arr[L++] = (tmp >> 8) & 0xFF
- arr[L++] = tmp & 0xFF
- }
-
- if (placeHolders === 2) {
- tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
- arr[L++] = tmp & 0xFF
- } else if (placeHolders === 1) {
- tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
- arr[L++] = (tmp >> 8) & 0xFF
- arr[L++] = tmp & 0xFF
- }
-
- return arr
- }
-
- function tripletToBase64 (num) {
- return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
- }
-
- function encodeChunk (uint8, start, end) {
- var tmp
- var output = []
- for (var i = start; i < end; i += 3) {
- tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
- output.push(tripletToBase64(tmp))
- }
- return output.join('')
- }
-
- function fromByteArray (uint8) {
- var tmp
- var len = uint8.length
- var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
- var output = ''
- var parts = []
- var maxChunkLength = 16383 // must be multiple of 3
-
- // go through the array every three bytes, we'll deal with trailing stuff later
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
- }
-
- // pad the end with zeros, but make sure to not forget the extra bytes
- if (extraBytes === 1) {
- tmp = uint8[len - 1]
- output += lookup[tmp >> 2]
- output += lookup[(tmp << 4) & 0x3F]
- output += '=='
- } else if (extraBytes === 2) {
- tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
- output += lookup[tmp >> 10]
- output += lookup[(tmp >> 4) & 0x3F]
- output += lookup[(tmp << 2) & 0x3F]
- output += '='
- }
-
- parts.push(output)
-
- return parts.join('')
- }
-
-
-/***/ },
-/* 4 */
-/***/ function(module, exports) {
-
- exports.read = function (buffer, offset, isLE, mLen, nBytes) {
- var e, m
- var eLen = nBytes * 8 - mLen - 1
- var eMax = (1 << eLen) - 1
- var eBias = eMax >> 1
- var nBits = -7
- var i = isLE ? (nBytes - 1) : 0
- var d = isLE ? -1 : 1
- var s = buffer[offset + i]
-
- i += d
-
- e = s & ((1 << (-nBits)) - 1)
- s >>= (-nBits)
- nBits += eLen
- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
-
- m = e & ((1 << (-nBits)) - 1)
- e >>= (-nBits)
- nBits += mLen
- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
-
- if (e === 0) {
- e = 1 - eBias
- } else if (e === eMax) {
- return m ? NaN : ((s ? -1 : 1) * Infinity)
- } else {
- m = m + Math.pow(2, mLen)
- e = e - eBias
- }
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
- }
-
- exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
- var e, m, c
- var eLen = nBytes * 8 - mLen - 1
- var eMax = (1 << eLen) - 1
- var eBias = eMax >> 1
- var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
- var i = isLE ? 0 : (nBytes - 1)
- var d = isLE ? 1 : -1
- var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
-
- value = Math.abs(value)
-
- if (isNaN(value) || value === Infinity) {
- m = isNaN(value) ? 1 : 0
- e = eMax
- } else {
- e = Math.floor(Math.log(value) / Math.LN2)
- if (value * (c = Math.pow(2, -e)) < 1) {
- e--
- c *= 2
- }
- if (e + eBias >= 1) {
- value += rt / c
- } else {
- value += rt * Math.pow(2, 1 - eBias)
- }
- if (value * c >= 2) {
- e++
- c /= 2
- }
-
- if (e + eBias >= eMax) {
- m = 0
- e = eMax
- } else if (e + eBias >= 1) {
- m = (value * c - 1) * Math.pow(2, mLen)
- e = e + eBias
- } else {
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
- e = 0
- }
- }
-
- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
-
- e = (e << mLen) | m
- eLen += mLen
- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
-
- buffer[offset + i - d] |= s * 128
- }
-
-
-/***/ },
-/* 5 */
-/***/ function(module, exports) {
-
- module.exports = function(module) {
- if(!module.webpackPolyfill) {
- module.deprecate = function() {};
- module.paths = [];
- // module.parent = undefined by default
- module.children = [];
- module.webpackPolyfill = 1;
- }
- return module;
- }
-
-
-/***/ },
-/* 6 */
-/***/ function(module, exports, __webpack_require__) {
-
- "use strict";
- var Process = __webpack_require__(7);
- var process = new Process(), processProxy = {};
- function defineKey(key) {
- if (processProxy[key]) {
- // Probably a builtin Object property we don't care about.
- return;
- }
- if (typeof process[key] === 'function') {
- processProxy[key] = function () {
- return process[key].apply(process, arguments);
- };
- }
- else {
- processProxy[key] = process[key];
- }
- }
- for (var key in process) {
- // Don't check if process.hasOwnProperty; we want to also expose objects
- // up the prototype hierarchy.
- defineKey(key);
- }
- // Special key: Ensure we update public-facing values of stdin/stdout/stderr.
- processProxy.initializeTTYs = function () {
- if (process.stdin === null) {
- process.initializeTTYs();
- processProxy.stdin = process.stdin;
- processProxy.stdout = process.stdout;
- processProxy.stderr = process.stderr;
- }
- };
- process.nextTick(function () {
- processProxy.initializeTTYs();
- });
- module.exports = processProxy;
-
-
-/***/ },
-/* 7 */
-/***/ function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(__dirname) {"use strict";
- var __extends = (this && this.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- var events = __webpack_require__(8);
- // Path depends on process. Avoid a circular reference by dynamically including path when we need it.
- var path = null;
- var Item = (function () {
- function Item(fun, array) {
- this.fun = fun;
- this.array = array;
- }
- Item.prototype.run = function () {
- this.fun.apply(null, this.array);
- };
- return Item;
- }());
- /**
- * Contains a queue of Items for process.nextTick.
- * Inspired by node-process: https://github.com/defunctzombie/node-process
- */
- var NextTickQueue = (function () {
- function NextTickQueue() {
- this._queue = [];
- this._draining = false;
- // Used/assigned by the drainQueue function.
- this._currentQueue = null;
- this._queueIndex = -1;
- }
- NextTickQueue.prototype.push = function (item) {
- var _this = this;
- if (this._queue.push(item) === 1 && !this._draining) {
- setTimeout(function () { return _this._drainQueue(); }, 0);
- }
- };
- NextTickQueue.prototype._cleanUpNextTick = function () {
- this._draining = false;
- if (this._currentQueue && this._currentQueue.length) {
- this._queue = this._currentQueue.concat(this._queue);
- }
- else {
- this._queueIndex = -1;
- }
- if (this._queue.length) {
- this._drainQueue();
- }
- };
- NextTickQueue.prototype._drainQueue = function () {
- var _this = this;
- if (this._draining) {
- return;
- }
- // If an Item throws an unhandled exception, this function will clean things up.
- var timeout = setTimeout(function () { return _this._cleanUpNextTick(); });
- this._draining = true;
- var len = this._queue.length;
- while (len) {
- this._currentQueue = this._queue;
- this._queue = [];
- while (++this._queueIndex < len) {
- if (this._currentQueue) {
- this._currentQueue[this._queueIndex].run();
- }
- }
- this._queueIndex = -1;
- len = this._queue.length;
- }
- this._currentQueue = null;
- this._draining = false;
- clearTimeout(timeout);
- };
- return NextTickQueue;
- }());
- /**
- * Partial implementation of Node's `process` module.
- * We implement the portions that are relevant for the filesystem.
- * @see http://nodejs.org/api/process.html
- * @class
- */
- var Process = (function (_super) {
- __extends(Process, _super);
- function Process() {
- _super.apply(this, arguments);
- this.startTime = Date.now();
- this._cwd = '/';
- /**
- * Returns what platform you are running on.
- * @return [String]
- */
- this.platform = 'browser';
- this.argv = [];
- this.execArgv = [];
- this.stdout = null;
- this.stderr = null;
- this.stdin = null;
- this.domain = null;
- this._queue = new NextTickQueue();
- this.execPath = __dirname;
- this.env = {};
- this.exitCode = 0;
- this._gid = 1;
- this._uid = 1;
- this.version = 'v5.0';
- this.versions = {
- http_parser: '0.0',
- node: '5.0',
- v8: '0.0',
- uv: '0.0',
- zlib: '0.0',
- ares: '0.0',
- icu: '0.0',
- modules: '0',
- openssl: '0.0'
- };
- this.config = {
- target_defaults: { cflags: [],
- default_configuration: 'Release',
- defines: [],
- include_dirs: [],
- libraries: [] },
- variables: { clang: 0,
- host_arch: 'x32',
- node_install_npm: false,
- node_install_waf: false,
- node_prefix: '',
- node_shared_cares: false,
- node_shared_http_parser: false,
- node_shared_libuv: false,
- node_shared_zlib: false,
- node_shared_v8: false,
- node_use_dtrace: false,
- node_use_etw: false,
- node_use_openssl: false,
- node_shared_openssl: false,
- strict_aliasing: false,
- target_arch: 'x32',
- v8_use_snapshot: false,
- v8_no_strict_aliasing: 0,
- visibility: '' } };
- this.pid = (Math.random() * 1000) | 0;
- this.title = 'node';
- this.arch = 'x32';
- this._mask = 18;
- // Undefined in main thread. Worker-only.
- this.connected = undefined;
- }
- /**
- * Changes the current working directory.
- *
- * **Note**: BrowserFS does not validate that the directory actually exists.
- *
- * @example Usage example
- * console.log('Starting directory: ' + process.cwd());
- * process.chdir('/tmp');
- * console.log('New directory: ' + process.cwd());
- * @param [String] dir The directory to change to.
- */
- Process.prototype.chdir = function (dir) {
- // XXX: Circular dependency hack.
- if (path === null) {
- path = __webpack_require__(9);
- }
- this._cwd = path.resolve(dir);
- };
- /**
- * Returns the current working directory.
- * @example Usage example
- * console.log('Current directory: ' + process.cwd());
- * @return [String] The current working directory.
- */
- Process.prototype.cwd = function () {
- return this._cwd;
- };
- /**
- * Number of seconds BrowserFS has been running.
- * @return [Number]
- */
- Process.prototype.uptime = function () {
- return ((Date.now() - this.startTime) / 1000) | 0;
- };
- Process.prototype.nextTick = function (fun) {
- var args = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- args[_i - 1] = arguments[_i];
- }
- this._queue.push(new Item(fun, args));
- };
- Process.prototype.abort = function () {
- this.emit('abort');
- };
- Process.prototype.exit = function (code) {
- this.exitCode = code;
- this.emit('exit', [code]);
- };
- Process.prototype.getgid = function () {
- return this._gid;
- };
- Process.prototype.setgid = function (gid) {
- if (typeof gid === 'number') {
- this._gid = gid;
- }
- else {
- this._gid = 1;
- }
- };
- Process.prototype.getuid = function () {
- return this._uid;
- };
- Process.prototype.setuid = function (uid) {
- if (typeof uid === 'number') {
- this._uid = uid;
- }
- else {
- this._uid = 1;
- }
- };
- Process.prototype.kill = function (pid, signal) {
- this.emit('kill', [pid, signal]);
- };
- Process.prototype.memoryUsage = function () {
- return { rss: 0, heapTotal: 0, heapUsed: 0 };
- };
- Process.prototype.umask = function (mask) {
- if (mask === void 0) { mask = this._mask; }
- var oldMask = this._mask;
- this._mask = mask;
- this.emit('umask', [mask]);
- return oldMask;
- };
- Process.prototype.hrtime = function () {
- var timeinfo;
- if (typeof performance !== 'undefined') {
- timeinfo = performance.now();
- }
- else if (Date['now']) {
- timeinfo = Date.now();
- }
- else {
- timeinfo = (new Date()).getTime();
- }
- var secs = (timeinfo / 1000) | 0;
- timeinfo -= secs * 1000;
- timeinfo = (timeinfo * 1000000) | 0;
- return [secs, timeinfo];
- };
- /**
- * [BFS only] Initialize the TTY devices.
- */
- Process.prototype.initializeTTYs = function () {
- // Guard against multiple invocations.
- if (this.stdout === null) {
- var TTY = __webpack_require__(10);
- this.stdout = new TTY();
- this.stderr = new TTY();
- this.stdin = new TTY();
- }
- };
- /**
- * Worker-only function; irrelevant here.
- */
- Process.prototype.disconnect = function () {
- };
- return Process;
- }(events.EventEmitter));
- module.exports = Process;
-
- /* WEBPACK VAR INJECTION */}.call(exports, "/"))
-
-/***/ },
-/* 8 */
-/***/ function(module, exports) {
-
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- function EventEmitter() {
- this._events = this._events || {};
- this._maxListeners = this._maxListeners || undefined;
- }
- module.exports = EventEmitter;
-
- // Backwards-compat with node 0.10.x
- EventEmitter.EventEmitter = EventEmitter;
-
- EventEmitter.prototype._events = undefined;
- EventEmitter.prototype._maxListeners = undefined;
-
- // By default EventEmitters will print a warning if more than 10 listeners are
- // added to it. This is a useful default which helps finding memory leaks.
- EventEmitter.defaultMaxListeners = 10;
-
- // Obviously not all Emitters should be limited to 10. This function allows
- // that to be increased. Set to zero for unlimited.
- EventEmitter.prototype.setMaxListeners = function(n) {
- if (!isNumber(n) || n < 0 || isNaN(n))
- throw TypeError('n must be a positive number');
- this._maxListeners = n;
- return this;
- };
-
- EventEmitter.prototype.emit = function(type) {
- var er, handler, len, args, i, listeners;
-
- if (!this._events)
- this._events = {};
-
- // If there is no 'error' event listener then throw.
- if (type === 'error') {
- if (!this._events.error ||
- (isObject(this._events.error) && !this._events.error.length)) {
- er = arguments[1];
- if (er instanceof Error) {
- throw er; // Unhandled 'error' event
- } else {
- // At least give some kind of context to the user
- var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
- err.context = er;
- throw err;
- }
- }
- }
-
- handler = this._events[type];
-
- if (isUndefined(handler))
- return false;
-
- if (isFunction(handler)) {
- switch (arguments.length) {
- // fast cases
- case 1:
- handler.call(this);
- break;
- case 2:
- handler.call(this, arguments[1]);
- break;
- case 3:
- handler.call(this, arguments[1], arguments[2]);
- break;
- // slower
- default:
- args = Array.prototype.slice.call(arguments, 1);
- handler.apply(this, args);
- }
- } else if (isObject(handler)) {
- args = Array.prototype.slice.call(arguments, 1);
- listeners = handler.slice();
- len = listeners.length;
- for (i = 0; i < len; i++)
- listeners[i].apply(this, args);
- }
-
- return true;
- };
-
- EventEmitter.prototype.addListener = function(type, listener) {
- var m;
-
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
-
- if (!this._events)
- this._events = {};
-
- // To avoid recursion in the case that type === "newListener"! Before
- // adding it to the listeners, first emit "newListener".
- if (this._events.newListener)
- this.emit('newListener', type,
- isFunction(listener.listener) ?
- listener.listener : listener);
-
- if (!this._events[type])
- // Optimize the case of one listener. Don't need the extra array object.
- this._events[type] = listener;
- else if (isObject(this._events[type]))
- // If we've already got an array, just append.
- this._events[type].push(listener);
- else
- // Adding the second element, need to change to array.
- this._events[type] = [this._events[type], listener];
-
- // Check for listener leak
- if (isObject(this._events[type]) && !this._events[type].warned) {
- if (!isUndefined(this._maxListeners)) {
- m = this._maxListeners;
- } else {
- m = EventEmitter.defaultMaxListeners;
- }
-
- if (m && m > 0 && this._events[type].length > m) {
- this._events[type].warned = true;
- console.error('(node) warning: possible EventEmitter memory ' +
- 'leak detected. %d listeners added. ' +
- 'Use emitter.setMaxListeners() to increase limit.',
- this._events[type].length);
- if (typeof console.trace === 'function') {
- // not supported in IE 10
- console.trace();
- }
- }
- }
-
- return this;
- };
-
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
-
- EventEmitter.prototype.once = function(type, listener) {
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
-
- var fired = false;
-
- function g() {
- this.removeListener(type, g);
-
- if (!fired) {
- fired = true;
- listener.apply(this, arguments);
- }
- }
-
- g.listener = listener;
- this.on(type, g);
-
- return this;
- };
-
- // emits a 'removeListener' event iff the listener was removed
- EventEmitter.prototype.removeListener = function(type, listener) {
- var list, position, length, i;
-
- if (!isFunction(listener))
- throw TypeError('listener must be a function');
-
- if (!this._events || !this._events[type])
- return this;
-
- list = this._events[type];
- length = list.length;
- position = -1;
-
- if (list === listener ||
- (isFunction(list.listener) && list.listener === listener)) {
- delete this._events[type];
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
-
- } else if (isObject(list)) {
- for (i = length; i-- > 0;) {
- if (list[i] === listener ||
- (list[i].listener && list[i].listener === listener)) {
- position = i;
- break;
- }
- }
-
- if (position < 0)
- return this;
-
- if (list.length === 1) {
- list.length = 0;
- delete this._events[type];
- } else {
- list.splice(position, 1);
- }
-
- if (this._events.removeListener)
- this.emit('removeListener', type, listener);
- }
-
- return this;
- };
-
- EventEmitter.prototype.removeAllListeners = function(type) {
- var key, listeners;
-
- if (!this._events)
- return this;
-
- // not listening for removeListener, no need to emit
- if (!this._events.removeListener) {
- if (arguments.length === 0)
- this._events = {};
- else if (this._events[type])
- delete this._events[type];
- return this;
- }
-
- // emit removeListener for all listeners on all events
- if (arguments.length === 0) {
- for (key in this._events) {
- if (key === 'removeListener') continue;
- this.removeAllListeners(key);
- }
- this.removeAllListeners('removeListener');
- this._events = {};
- return this;
- }
-
- listeners = this._events[type];
-
- if (isFunction(listeners)) {
- this.removeListener(type, listeners);
- } else if (listeners) {
- // LIFO order
- while (listeners.length)
- this.removeListener(type, listeners[listeners.length - 1]);
- }
- delete this._events[type];
-
- return this;
- };
-
- EventEmitter.prototype.listeners = function(type) {
- var ret;
- if (!this._events || !this._events[type])
- ret = [];
- else if (isFunction(this._events[type]))
- ret = [this._events[type]];
- else
- ret = this._events[type].slice();
- return ret;
- };
-
- EventEmitter.prototype.listenerCount = function(type) {
- if (this._events) {
- var evlistener = this._events[type];
-
- if (isFunction(evlistener))
- return 1;
- else if (evlistener)
- return evlistener.length;
- }
- return 0;
- };
-
- EventEmitter.listenerCount = function(emitter, type) {
- return emitter.listenerCount(type);
- };
-
- function isFunction(arg) {
- return typeof arg === 'function';
- }
-
- function isNumber(arg) {
- return typeof arg === 'number';
- }
-
- function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
- }
-
- function isUndefined(arg) {
- return arg === void 0;
- }
-
-
-/***/ },
-/* 9 */
-/***/ function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(process) {"use strict";
- // Split a filename into [root, dir, basename, ext], unix version
- // 'root' is just a slash, or nothing.
- var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
- function posixSplitPath(filename) {
- var out = splitPathRe.exec(filename);
- out.shift();
- return out;
- }
- /**
- * Emulates Node's `path` module. This module contains utilities for handling and
- * transforming file paths. **All** of these methods perform only string
- * transformations. The file system is not consulted to check whether paths are
- * valid.
- * @see http://nodejs.org/api/path.html
- * @class
- */
- var path = (function () {
- function path() {
- }
- /**
- * Normalize a string path, taking care of '..' and '.' parts.
- *
- * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
- * @example Usage example
- * path.normalize('/foo/bar//baz/asdf/quux/..')
- * // returns
- * '/foo/bar/baz/asdf'
- * @param [String] p The path to normalize.
- * @return [String]
- */
- path.normalize = function (p) {
- // Special case: '' -> '.'
- if (p === '') {
- p = '.';
- }
- // It's very important to know if the path is relative or not, since it
- // changes how we process .. and reconstruct the split string.
- var absolute = p.charAt(0) === path.sep;
- // Remove repeated //s
- p = path._removeDuplicateSeps(p);
- // Try to remove as many '../' as possible, and remove '.' completely.
- var components = p.split(path.sep);
- var goodComponents = [];
- for (var idx = 0; idx < components.length; idx++) {
- var c = components[idx];
- if (c === '.') {
- continue;
- }
- else if (c === '..' && (absolute || (!absolute && goodComponents.length > 0 && goodComponents[0] !== '..'))) {
- // In the absolute case: Path is relative to root, so we may pop even if
- // goodComponents is empty (e.g. /../ => /)
- // In the relative case: We're getting rid of a directory that preceded
- // it (e.g. /foo/../bar -> /bar)
- goodComponents.pop();
- }
- else {
- goodComponents.push(c);
- }
- }
- // Add in '.' when it's a relative path with no other nonempty components.
- // Possible results: '.' and './' (input: [''] or [])
- // @todo Can probably simplify this logic.
- if (!absolute && goodComponents.length < 2) {
- switch (goodComponents.length) {
- case 1:
- if (goodComponents[0] === '') {
- goodComponents.unshift('.');
- }
- break;
- default:
- goodComponents.push('.');
- }
- }
- p = goodComponents.join(path.sep);
- if (absolute && p.charAt(0) !== path.sep) {
- p = path.sep + p;
- }
- return p;
- };
- /**
- * Join all arguments together and normalize the resulting path.
- *
- * Arguments must be strings.
- * @example Usage
- * path.join('/foo', 'bar', 'baz/asdf', 'quux', '..')
- * // returns
- * '/foo/bar/baz/asdf'
- *
- * path.join('foo', {}, 'bar')
- * // throws exception
- * TypeError: Arguments to path.join must be strings
- * @param [String,...] paths Each component of the path
- * @return [String]
- */
- path.join = function () {
- var paths = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- paths[_i - 0] = arguments[_i];
- }
- // Required: Prune any non-strings from the path. I also prune empty segments
- // so we can do a simple join of the array.
- var processed = [];
- for (var i = 0; i < paths.length; i++) {
- var segment = paths[i];
- if (typeof segment !== 'string') {
- throw new TypeError("Invalid argument type to path.join: " + (typeof segment));
- }
- else if (segment !== '') {
- processed.push(segment);
- }
- }
- return path.normalize(processed.join(path.sep));
- };
- /**
- * Resolves to to an absolute path.
- *
- * If to isn't already absolute from arguments are prepended in right to left
- * order, until an absolute path is found. If after using all from paths still
- * no absolute path is found, the current working directory is used as well.
- * The resulting path is normalized, and trailing slashes are removed unless
- * the path gets resolved to the root directory. Non-string arguments are
- * ignored.
- *
- * Another way to think of it is as a sequence of cd commands in a shell.
- *
- * path.resolve('foo/bar', '/tmp/file/', '..', 'a/../subfile')
- *
- * Is similar to:
- *
- * cd foo/bar
- * cd /tmp/file/
- * cd ..
- * cd a/../subfile
- * pwd
- *
- * The difference is that the different paths don't need to exist and may also
- * be files.
- * @example Usage example
- * path.resolve('/foo/bar', './baz')
- * // returns
- * '/foo/bar/baz'
- *
- * path.resolve('/foo/bar', '/tmp/file/')
- * // returns
- * '/tmp/file'
- *
- * path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')
- * // if currently in /home/myself/node, it returns
- * '/home/myself/node/wwwroot/static_files/gif/image.gif'
- * @param [String,...] paths
- * @return [String]
- */
- path.resolve = function () {
- var paths = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- paths[_i - 0] = arguments[_i];
- }
- // Monitor for invalid paths, throw out empty paths, and look for the *last*
- // absolute path that we see.
- var processed = [];
- for (var i = 0; i < paths.length; i++) {
- var p = paths[i];
- if (typeof p !== 'string') {
- throw new TypeError("Invalid argument type to path.join: " + (typeof p));
- }
- else if (p !== '') {
- // Remove anything that has occurred before this absolute path, as it
- // doesn't matter.
- if (p.charAt(0) === path.sep) {
- processed = [];
- }
- processed.push(p);
- }
- }
- // Special: Remove trailing slash unless it's the root
- var resolved = path.normalize(processed.join(path.sep));
- if (resolved.length > 1 && resolved.charAt(resolved.length - 1) === path.sep) {
- return resolved.substr(0, resolved.length - 1);
- }
- // Special: If it doesn't start with '/', it's relative and we need to append
- // the current directory.
- if (resolved.charAt(0) !== path.sep) {
- // Remove ./, since we're going to append the current directory.
- if (resolved.charAt(0) === '.' && (resolved.length === 1 || resolved.charAt(1) === path.sep)) {
- resolved = resolved.length === 1 ? '' : resolved.substr(2);
- }
- // Append the current directory, which *must* be an absolute path.
- var cwd = process.cwd();
- if (resolved !== '') {
- // cwd will never end in a /... unless it's the root.
- resolved = this.normalize(cwd + (cwd !== '/' ? path.sep : '') + resolved);
- }
- else {
- resolved = cwd;
- }
- }
- return resolved;
- };
- /**
- * Solve the relative path from from to to.
- *
- * At times we have two absolute paths, and we need to derive the relative path
- * from one to the other. This is actually the reverse transform of
- * path.resolve, which means we see that:
- *
- * path.resolve(from, path.relative(from, to)) == path.resolve(to)
- *
- * @example Usage example
- * path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb')
- * // returns
- * '..\\..\\impl\\bbb'
- *
- * path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb')
- * // returns
- * '../../impl/bbb'
- * @param [String] from
- * @param [String] to
- * @return [String]
- */
- path.relative = function (from, to) {
- var i;
- // Alright. Let's resolve these two to absolute paths and remove any
- // weirdness.
- from = path.resolve(from);
- to = path.resolve(to);
- var fromSegs = from.split(path.sep);
- var toSegs = to.split(path.sep);
- // Remove the first segment on both, as it's '' (both are absolute paths)
- toSegs.shift();
- fromSegs.shift();
- // There are two segments to this path:
- // * Going *up* the directory hierarchy with '..'
- // * Going *down* the directory hierarchy with foo/baz/bat.
- var upCount = 0;
- var downSegs = [];
- // Figure out how many things in 'from' are shared with 'to'.
- for (i = 0; i < fromSegs.length; i++) {
- var seg = fromSegs[i];
- if (seg === toSegs[i]) {
- continue;
- }
- // The rest of 'from', including the current element, indicates how many
- // directories we need to go up.
- upCount = fromSegs.length - i;
- break;
- }
- // The rest of 'to' indicates where we need to change to. We place this
- // outside of the loop, as toSegs.length may be greater than fromSegs.length.
- downSegs = toSegs.slice(i);
- // Special case: If 'from' is '/'
- if (fromSegs.length === 1 && fromSegs[0] === '') {
- upCount = 0;
- }
- // upCount can't be greater than the number of fromSegs
- // (cd .. from / is still /)
- if (upCount > fromSegs.length) {
- upCount = fromSegs.length;
- }
- // Create the final string!
- var rv = '';
- for (i = 0; i < upCount; i++) {
- rv += '../';
- }
- rv += downSegs.join(path.sep);
- // Special case: Remove trailing '/'. Happens if it's all up and no down.
- if (rv.length > 1 && rv.charAt(rv.length - 1) === path.sep) {
- rv = rv.substr(0, rv.length - 1);
- }
- return rv;
- };
- /**
- * Return the directory name of a path. Similar to the Unix `dirname` command.
- *
- * Note that BrowserFS does not validate if the path is actually a valid
- * directory.
- * @example Usage example
- * path.dirname('/foo/bar/baz/asdf/quux')
- * // returns
- * '/foo/bar/baz/asdf'
- * @param [String] p The path to get the directory name of.
- * @return [String]
- */
- path.dirname = function (p) {
- // We get rid of //, but we don't modify anything else (e.g. any extraneous .
- // and ../ are kept intact)
- p = path._removeDuplicateSeps(p);
- var absolute = p.charAt(0) === path.sep;
- var sections = p.split(path.sep);
- // Do 1 if it's /foo/bar, 2 if it's /foo/bar/
- if (sections.pop() === '' && sections.length > 0) {
- sections.pop();
- }
- // # of sections needs to be > 1 if absolute, since the first section is '' for '/'.
- // If not absolute, the first section is the first part of the path, and is OK
- // to return.
- if (sections.length > 1 || (sections.length === 1 && !absolute)) {
- return sections.join(path.sep);
- }
- else if (absolute) {
- return path.sep;
- }
- else {
- return '.';
- }
- };
- /**
- * Return the last portion of a path. Similar to the Unix basename command.
- * @example Usage example
- * path.basename('/foo/bar/baz/asdf/quux.html')
- * // returns
- * 'quux.html'
- *
- * path.basename('/foo/bar/baz/asdf/quux.html', '.html')
- * // returns
- * 'quux'
- * @param [String] p
- * @param [String?] ext
- * @return [String]
- */
- path.basename = function (p, ext) {
- if (ext === void 0) { ext = ""; }
- // Special case: Normalize will modify this to '.'
- if (p === '') {
- return p;
- }
- // Normalize the string first to remove any weirdness.
- p = path.normalize(p);
- // Get the last part of the string.
- var sections = p.split(path.sep);
- var lastPart = sections[sections.length - 1];
- // Special case: If it's empty, then we have a string like so: foo/
- // Meaning, 'foo' is guaranteed to be a directory.
- if (lastPart === '' && sections.length > 1) {
- return sections[sections.length - 2];
- }
- // Remove the extension, if need be.
- if (ext.length > 0) {
- var lastPartExt = lastPart.substr(lastPart.length - ext.length);
- if (lastPartExt === ext) {
- return lastPart.substr(0, lastPart.length - ext.length);
- }
- }
- return lastPart;
- };
- /**
- * Return the extension of the path, from the last '.' to end of string in the
- * last portion of the path. If there is no '.' in the last portion of the path
- * or the first character of it is '.', then it returns an empty string.
- * @example Usage example
- * path.extname('index.html')
- * // returns
- * '.html'
- *
- * path.extname('index.')
- * // returns
- * '.'
- *
- * path.extname('index')
- * // returns
- * ''
- * @param [String] p
- * @return [String]
- */
- path.extname = function (p) {
- p = path.normalize(p);
- var sections = p.split(path.sep);
- p = sections.pop();
- // Special case: foo/file.ext/ should return '.ext'
- if (p === '' && sections.length > 0) {
- p = sections.pop();
- }
- if (p === '..') {
- return '';
- }
- var i = p.lastIndexOf('.');
- if (i === -1 || i === 0) {
- return '';
- }
- return p.substr(i);
- };
- /**
- * Checks if the given path is an absolute path.
- *
- * Despite not being documented, this is a tested part of Node's path API.
- * @param [String] p
- * @return [Boolean] True if the path appears to be an absolute path.
- */
- path.isAbsolute = function (p) {
- return p.length > 0 && p.charAt(0) === path.sep;
- };
- /**
- * Unknown. Undocumented.
- */
- path._makeLong = function (p) {
- return p;
- };
- /**
- * Returns an object from a path string.
- */
- path.parse = function (p) {
- var allParts = posixSplitPath(p);
- return {
- root: allParts[0],
- dir: allParts[0] + allParts[1].slice(0, -1),
- base: allParts[2],
- ext: allParts[3],
- name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
- };
- };
- path.format = function (pathObject) {
- if (pathObject === null || typeof pathObject !== 'object') {
- throw new TypeError("Parameter 'pathObject' must be an object, not " + typeof pathObject);
- }
- var root = pathObject.root || '';
- if (typeof root !== 'string') {
- throw new TypeError("'pathObject.root' must be a string or undefined, not " +
- typeof pathObject.root);
- }
- var dir = pathObject.dir ? pathObject.dir + path.sep : '';
- var base = pathObject.base || '';
- return dir + base;
- };
- path._removeDuplicateSeps = function (p) {
- p = p.replace(this._replaceRegex, this.sep);
- return p;
- };
- // The platform-specific file separator. BrowserFS uses `/`.
- path.sep = '/';
- path._replaceRegex = new RegExp("//+", 'g');
- // The platform-specific path delimiter. BrowserFS uses `:`.
- path.delimiter = ':';
- path.posix = path;
- // XXX: Typing hack. We don't actually support win32.
- path.win32 = path;
- return path;
- }());
- var _ = path;
- module.exports = path;
-
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
-
-/***/ },
-/* 10 */
-/***/ function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(Buffer) {"use strict";
- var __extends = (this && this.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- var stream = __webpack_require__(11);
- var TTY = (function (_super) {
- __extends(TTY, _super);
- function TTY() {
- _super.call(this);
- this.isRaw = false;
- this.columns = 80;
- this.rows = 120;
- this.isTTY = true;
- this._bufferedWrites = [];
- this._waitingForWrites = false;
- }
- /**
- * Toggle raw mode.
- */
- TTY.prototype.setRawMode = function (mode) {
- if (this.isRaw !== mode) {
- this.isRaw = mode;
- // [BFS] TTY implementations can use this to change their event emitting
- // patterns.
- this.emit('modeChange');
- }
- };
- /**
- * [BFS] Update the number of columns available on the terminal.
- */
- TTY.prototype.changeColumns = function (columns) {
- if (columns !== this.columns) {
- this.columns = columns;
- // Resize event.
- this.emit('resize');
- }
- };
- /**
- * [BFS] Update the number of rows available on the terminal.
- */
- TTY.prototype.changeRows = function (rows) {
- if (rows !== this.rows) {
- this.rows = rows;
- // Resize event.
- this.emit('resize');
- }
- };
- /**
- * Returns 'true' if the given object is a TTY.
- */
- TTY.isatty = function (fd) {
- return fd && fd instanceof TTY;
- };
- TTY.prototype._write = function (chunk, encoding, cb) {
- var error;
- try {
- var data;
- if (typeof (chunk) === 'string') {
- data = new Buffer(chunk, encoding);
- }
- else {
- data = chunk;
- }
- this._bufferedWrites.push(data);
- if (this._waitingForWrites) {
- this._read(1024);
- }
- }
- catch (e) {
- error = e;
- }
- finally {
- cb(error);
- }
- };
- TTY.prototype._read = function (size) {
- // Size is advisory -- we can ignore it.
- if (this._bufferedWrites.length === 0) {
- this._waitingForWrites = true;
- }
- else {
- while (this._bufferedWrites.length > 0) {
- this._waitingForWrites = this.push(this._bufferedWrites.shift());
- if (!this._waitingForWrites) {
- break;
- }
- }
- }
- };
- return TTY;
- }(stream.Duplex));
- module.exports = TTY;
-
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)))
-
-/***/ },
-/* 11 */
-/***/ function(module, exports, __webpack_require__) {
-
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- module.exports = Stream;
-
- var EE = __webpack_require__(8).EventEmitter;
- var inherits = __webpack_require__(12);
-
- inherits(Stream, EE);
- Stream.Readable = __webpack_require__(13);
- Stream.Writable = __webpack_require__(27);
- Stream.Duplex = __webpack_require__(28);
- Stream.Transform = __webpack_require__(29);
- Stream.PassThrough = __webpack_require__(30);
-
- // Backwards-compat with node 0.4.x
- Stream.Stream = Stream;
-
-
-
- // old-style streams. Note that the pipe method (the only relevant
- // part of this class) is overridden in the Readable class.
-
- function Stream() {
- EE.call(this);
- }
-
- Stream.prototype.pipe = function(dest, options) {
- var source = this;
-
- function ondata(chunk) {
- if (dest.writable) {
- if (false === dest.write(chunk) && source.pause) {
- source.pause();
- }
- }
- }
-
- source.on('data', ondata);
-
- function ondrain() {
- if (source.readable && source.resume) {
- source.resume();
- }
- }
-
- dest.on('drain', ondrain);
-
- // If the 'end' option is not supplied, dest.end() will be called when
- // source gets the 'end' or 'close' events. Only dest.end() once.
- if (!dest._isStdio && (!options || options.end !== false)) {
- source.on('end', onend);
- source.on('close', onclose);
- }
-
- var didOnEnd = false;
- function onend() {
- if (didOnEnd) return;
- didOnEnd = true;
-
- dest.end();
- }
-
-
- function onclose() {
- if (didOnEnd) return;
- didOnEnd = true;
-
- if (typeof dest.destroy === 'function') dest.destroy();
- }
-
- // don't leave dangling pipes when there are errors.
- function onerror(er) {
- cleanup();
- if (EE.listenerCount(this, 'error') === 0) {
- throw er; // Unhandled stream error in pipe.
- }
- }
-
- source.on('error', onerror);
- dest.on('error', onerror);
-
- // remove all the event listeners that were added.
- function cleanup() {
- source.removeListener('data', ondata);
- dest.removeListener('drain', ondrain);
-
- source.removeListener('end', onend);
- source.removeListener('close', onclose);
-
- source.removeListener('error', onerror);
- dest.removeListener('error', onerror);
-
- source.removeListener('end', cleanup);
- source.removeListener('close', cleanup);
-
- dest.removeListener('close', cleanup);
- }
-
- source.on('end', cleanup);
- source.on('close', cleanup);
-
- dest.on('close', cleanup);
-
- dest.emit('pipe', source);
-
- // Allow for unix-like usage: A.pipe(B).pipe(C)
- return dest;
- };
-
-
-/***/ },
-/* 12 */
-/***/ function(module, exports) {
-
- if (typeof Object.create === 'function') {
- // implementation from standard node.js 'util' module
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- };
- } else {
- // old school shim for old browsers
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- var TempCtor = function () {}
- TempCtor.prototype = superCtor.prototype
- ctor.prototype = new TempCtor()
- ctor.prototype.constructor = ctor
- }
- }
-
-
-/***/ },
-/* 13 */
-/***/ function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(process) {var Stream = (function (){
- try {
- return __webpack_require__(11); // hack to fix a circular dependency issue when used with browserify
- } catch(_){}
- }());
- exports = module.exports = __webpack_require__(14);
- exports.Stream = Stream || exports;
- exports.Readable = exports;
- exports.Writable = __webpack_require__(22);
- exports.Duplex = __webpack_require__(21);
- exports.Transform = __webpack_require__(25);
- exports.PassThrough = __webpack_require__(26);
-
- if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) {
- module.exports = Stream;
- }
-
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
-
-/***/ },
-/* 14 */
-/***/ function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(process) {'use strict';
-
- module.exports = Readable;
-
- /**/
- var processNextTick = __webpack_require__(15);
- /**/
-
- /**/
- var isArray = __webpack_require__(16);
- /**/
-
- /**/
- var Duplex;
- /**/
-
- Readable.ReadableState = ReadableState;
-
- /**/
- var EE = __webpack_require__(8).EventEmitter;
-
- var EElistenerCount = function (emitter, type) {
- return emitter.listeners(type).length;
- };
- /**/
-
- /**/
- var Stream;
- (function () {
- try {
- Stream = __webpack_require__(11);
- } catch (_) {} finally {
- if (!Stream) Stream = __webpack_require__(8).EventEmitter;
- }
- })();
- /**/
-
- var Buffer = __webpack_require__(2).Buffer;
- /**/
- var bufferShim = __webpack_require__(17);
- /**/
-
- /**/
- var util = __webpack_require__(18);
- util.inherits = __webpack_require__(12);
- /**/
-
- /**/
- var debugUtil = __webpack_require__(19);
- var debug = void 0;
- if (debugUtil && debugUtil.debuglog) {
- debug = debugUtil.debuglog('stream');
- } else {
- debug = function () {};
- }
- /**/
-
- var BufferList = __webpack_require__(20);
- var StringDecoder;
-
- util.inherits(Readable, Stream);
-
- function prependListener(emitter, event, fn) {
- // Sadly this is not cacheable as some libraries bundle their own
- // event emitter implementation with them.
- if (typeof emitter.prependListener === 'function') {
- return emitter.prependListener(event, fn);
- } else {
- // This is a hack to make sure that our error handler is attached before any
- // userland ones. NEVER DO THIS. This is here only because this code needs
- // to continue to work with older versions of Node.js that do not include
- // the prependListener() method. The goal is to eventually remove this hack.
- if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
- }
- }
-
- function ReadableState(options, stream) {
- Duplex = Duplex || __webpack_require__(21);
-
- options = options || {};
-
- // object stream flag. Used to make read(n) ignore n and to
- // make all the buffer merging and length checks go away
- this.objectMode = !!options.objectMode;
-
- if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
-
- // the point at which it stops calling _read() to fill the buffer
- // Note: 0 is a valid value, means "don't call _read preemptively ever"
- var hwm = options.highWaterMark;
- var defaultHwm = this.objectMode ? 16 : 16 * 1024;
- this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
-
- // cast to ints.
- this.highWaterMark = ~~this.highWaterMark;
-
- // A linked list is used to store data chunks instead of an array because the
- // linked list can remove elements from the beginning faster than
- // array.shift()
- this.buffer = new BufferList();
- this.length = 0;
- this.pipes = null;
- this.pipesCount = 0;
- this.flowing = null;
- this.ended = false;
- this.endEmitted = false;
- this.reading = false;
-
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, because any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
-
- // whenever we return null, then we set a flag to say
- // that we're awaiting a 'readable' event emission.
- this.needReadable = false;
- this.emittedReadable = false;
- this.readableListening = false;
- this.resumeScheduled = false;
-
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
-
- // when piping, we only care about 'readable' events that happen
- // after read()ing all the bytes and not getting any pushback.
- this.ranOut = false;
-
- // the number of writers that are awaiting a drain event in .pipe()s
- this.awaitDrain = 0;
-
- // if true, a maybeReadMore has been scheduled
- this.readingMore = false;
-
- this.decoder = null;
- this.encoding = null;
- if (options.encoding) {
- if (!StringDecoder) StringDecoder = __webpack_require__(24).StringDecoder;
- this.decoder = new StringDecoder(options.encoding);
- this.encoding = options.encoding;
- }
- }
-
- function Readable(options) {
- Duplex = Duplex || __webpack_require__(21);
-
- if (!(this instanceof Readable)) return new Readable(options);
-
- this._readableState = new ReadableState(options, this);
-
- // legacy
- this.readable = true;
-
- if (options && typeof options.read === 'function') this._read = options.read;
-
- Stream.call(this);
- }
-
- // Manually shove something into the read() buffer.
- // This returns true if the highWaterMark has not been hit yet,
- // similar to how Writable.write() returns true if you should
- // write() some more.
- Readable.prototype.push = function (chunk, encoding) {
- var state = this._readableState;
-
- if (!state.objectMode && typeof chunk === 'string') {
- encoding = encoding || state.defaultEncoding;
- if (encoding !== state.encoding) {
- chunk = bufferShim.from(chunk, encoding);
- encoding = '';
- }
- }
-
- return readableAddChunk(this, state, chunk, encoding, false);
- };
-
- // Unshift should *always* be something directly out of read()
- Readable.prototype.unshift = function (chunk) {
- var state = this._readableState;
- return readableAddChunk(this, state, chunk, '', true);
- };
-
- Readable.prototype.isPaused = function () {
- return this._readableState.flowing === false;
- };
-
- function readableAddChunk(stream, state, chunk, encoding, addToFront) {
- var er = chunkInvalid(state, chunk);
- if (er) {
- stream.emit('error', er);
- } else if (chunk === null) {
- state.reading = false;
- onEofChunk(stream, state);
- } else if (state.objectMode || chunk && chunk.length > 0) {
- if (state.ended && !addToFront) {
- var e = new Error('stream.push() after EOF');
- stream.emit('error', e);
- } else if (state.endEmitted && addToFront) {
- var _e = new Error('stream.unshift() after end event');
- stream.emit('error', _e);
- } else {
- var skipAdd;
- if (state.decoder && !addToFront && !encoding) {
- chunk = state.decoder.write(chunk);
- skipAdd = !state.objectMode && chunk.length === 0;
- }
-
- if (!addToFront) state.reading = false;
-
- // Don't add to the buffer if we've decoded to an empty string chunk and
- // we're not in object mode
- if (!skipAdd) {
- // if we want the data now, just emit it.
- if (state.flowing && state.length === 0 && !state.sync) {
- stream.emit('data', chunk);
- stream.read(0);
- } else {
- // update the buffer info.
- state.length += state.objectMode ? 1 : chunk.length;
- if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
-
- if (state.needReadable) emitReadable(stream);
- }
- }
-
- maybeReadMore(stream, state);
- }
- } else if (!addToFront) {
- state.reading = false;
- }
-
- return needMoreData(state);
- }
-
- // if it's past the high water mark, we can push in some more.
- // Also, if we have no data yet, we can stand some
- // more bytes. This is to work around cases where hwm=0,
- // such as the repl. Also, if the push() triggered a
- // readable event, and the user called read(largeNumber) such that
- // needReadable was set, then we ought to push more, so that another
- // 'readable' event will be triggered.
- function needMoreData(state) {
- return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
- }
-
- // backwards compatibility.
- Readable.prototype.setEncoding = function (enc) {
- if (!StringDecoder) StringDecoder = __webpack_require__(24).StringDecoder;
- this._readableState.decoder = new StringDecoder(enc);
- this._readableState.encoding = enc;
- return this;
- };
-
- // Don't raise the hwm > 8MB
- var MAX_HWM = 0x800000;
- function computeNewHighWaterMark(n) {
- if (n >= MAX_HWM) {
- n = MAX_HWM;
- } else {
- // Get the next highest power of 2 to prevent increasing hwm excessively in
- // tiny amounts
- n--;
- n |= n >>> 1;
- n |= n >>> 2;
- n |= n >>> 4;
- n |= n >>> 8;
- n |= n >>> 16;
- n++;
- }
- return n;
- }
-
- // This function is designed to be inlinable, so please take care when making
- // changes to the function body.
- function howMuchToRead(n, state) {
- if (n <= 0 || state.length === 0 && state.ended) return 0;
- if (state.objectMode) return 1;
- if (n !== n) {
- // Only flow one buffer at a time
- if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
- }
- // If we're asking for more than the current hwm, then raise the hwm.
- if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
- if (n <= state.length) return n;
- // Don't have enough
- if (!state.ended) {
- state.needReadable = true;
- return 0;
- }
- return state.length;
- }
-
- // you can override either this method, or the async _read(n) below.
- Readable.prototype.read = function (n) {
- debug('read', n);
- n = parseInt(n, 10);
- var state = this._readableState;
- var nOrig = n;
-
- if (n !== 0) state.emittedReadable = false;
-
- // if we're doing read(0) to trigger a readable event, but we
- // already have a bunch of data in the buffer, then just trigger
- // the 'readable' event and move on.
- if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
- debug('read: emitReadable', state.length, state.ended);
- if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
- return null;
- }
-
- n = howMuchToRead(n, state);
-
- // if we've ended, and we're now clear, then finish it up.
- if (n === 0 && state.ended) {
- if (state.length === 0) endReadable(this);
- return null;
- }
-
- // All the actual chunk generation logic needs to be
- // *below* the call to _read. The reason is that in certain
- // synthetic stream cases, such as passthrough streams, _read
- // may be a completely synchronous operation which may change
- // the state of the read buffer, providing enough data when
- // before there was *not* enough.
- //
- // So, the steps are:
- // 1. Figure out what the state of things will be after we do
- // a read from the buffer.
- //
- // 2. If that resulting state will trigger a _read, then call _read.
- // Note that this may be asynchronous, or synchronous. Yes, it is
- // deeply ugly to write APIs this way, but that still doesn't mean
- // that the Readable class should behave improperly, as streams are
- // designed to be sync/async agnostic.
- // Take note if the _read call is sync or async (ie, if the read call
- // has returned yet), so that we know whether or not it's safe to emit
- // 'readable' etc.
- //
- // 3. Actually pull the requested chunks out of the buffer and return.
-
- // if we need a readable event, then we need to do some reading.
- var doRead = state.needReadable;
- debug('need readable', doRead);
-
- // if we currently have less than the highWaterMark, then also read some
- if (state.length === 0 || state.length - n < state.highWaterMark) {
- doRead = true;
- debug('length less than watermark', doRead);
- }
-
- // however, if we've ended, then there's no point, and if we're already
- // reading, then it's unnecessary.
- if (state.ended || state.reading) {
- doRead = false;
- debug('reading or ended', doRead);
- } else if (doRead) {
- debug('do read');
- state.reading = true;
- state.sync = true;
- // if the length is currently zero, then we *need* a readable event.
- if (state.length === 0) state.needReadable = true;
- // call internal read method
- this._read(state.highWaterMark);
- state.sync = false;
- // If _read pushed data synchronously, then `reading` will be false,
- // and we need to re-evaluate how much data we can return to the user.
- if (!state.reading) n = howMuchToRead(nOrig, state);
- }
-
- var ret;
- if (n > 0) ret = fromList(n, state);else ret = null;
-
- if (ret === null) {
- state.needReadable = true;
- n = 0;
- } else {
- state.length -= n;
- }
-
- if (state.length === 0) {
- // If we have nothing in the buffer, then we want to know
- // as soon as we *do* get something into the buffer.
- if (!state.ended) state.needReadable = true;
-
- // If we tried to read() past the EOF, then emit end on the next tick.
- if (nOrig !== n && state.ended) endReadable(this);
- }
-
- if (ret !== null) this.emit('data', ret);
-
- return ret;
- };
-
- function chunkInvalid(state, chunk) {
- var er = null;
- if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
- er = new TypeError('Invalid non-string/buffer chunk');
- }
- return er;
- }
-
- function onEofChunk(stream, state) {
- if (state.ended) return;
- if (state.decoder) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) {
- state.buffer.push(chunk);
- state.length += state.objectMode ? 1 : chunk.length;
- }
- }
- state.ended = true;
-
- // emit 'readable' now to make sure it gets picked up.
- emitReadable(stream);
- }
-
- // Don't emit readable right away in sync mode, because this can trigger
- // another read() call => stack overflow. This way, it might trigger
- // a nextTick recursion warning, but that's not so bad.
- function emitReadable(stream) {
- var state = stream._readableState;
- state.needReadable = false;
- if (!state.emittedReadable) {
- debug('emitReadable', state.flowing);
- state.emittedReadable = true;
- if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
- }
- }
-
- function emitReadable_(stream) {
- debug('emit readable');
- stream.emit('readable');
- flow(stream);
- }
-
- // at this point, the user has presumably seen the 'readable' event,
- // and called read() to consume some data. that may have triggered
- // in turn another _read(n) call, in which case reading = true if
- // it's in progress.
- // However, if we're not ended, or reading, and the length < hwm,
- // then go ahead and try to read some more preemptively.
- function maybeReadMore(stream, state) {
- if (!state.readingMore) {
- state.readingMore = true;
- processNextTick(maybeReadMore_, stream, state);
- }
- }
-
- function maybeReadMore_(stream, state) {
- var len = state.length;
- while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
- debug('maybeReadMore read 0');
- stream.read(0);
- if (len === state.length)
- // didn't get any data, stop spinning.
- break;else len = state.length;
- }
- state.readingMore = false;
- }
-
- // abstract method. to be overridden in specific implementation classes.
- // call cb(er, data) where data is <= n in length.
- // for virtual (non-string, non-buffer) streams, "length" is somewhat
- // arbitrary, and perhaps not very meaningful.
- Readable.prototype._read = function (n) {
- this.emit('error', new Error('_read() is not implemented'));
- };
-
- Readable.prototype.pipe = function (dest, pipeOpts) {
- var src = this;
- var state = this._readableState;
-
- switch (state.pipesCount) {
- case 0:
- state.pipes = dest;
- break;
- case 1:
- state.pipes = [state.pipes, dest];
- break;
- default:
- state.pipes.push(dest);
- break;
- }
- state.pipesCount += 1;
- debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
-
- var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
-
- var endFn = doEnd ? onend : cleanup;
- if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
-
- dest.on('unpipe', onunpipe);
- function onunpipe(readable) {
- debug('onunpipe');
- if (readable === src) {
- cleanup();
- }
- }
-
- function onend() {
- debug('onend');
- dest.end();
- }
-
- // when the dest drains, it reduces the awaitDrain counter
- // on the source. This would be more elegant with a .once()
- // handler in flow(), but adding and removing repeatedly is
- // too slow.
- var ondrain = pipeOnDrain(src);
- dest.on('drain', ondrain);
-
- var cleanedUp = false;
- function cleanup() {
- debug('cleanup');
- // cleanup event handlers once the pipe is broken
- dest.removeListener('close', onclose);
- dest.removeListener('finish', onfinish);
- dest.removeListener('drain', ondrain);
- dest.removeListener('error', onerror);
- dest.removeListener('unpipe', onunpipe);
- src.removeListener('end', onend);
- src.removeListener('end', cleanup);
- src.removeListener('data', ondata);
-
- cleanedUp = true;
-
- // if the reader is waiting for a drain event from this
- // specific writer, then it would cause it to never start
- // flowing again.
- // So, if this is awaiting a drain, then we just call it now.
- // If we don't know, then assume that we are waiting for one.
- if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
- }
-
- // If the user pushes more data while we're writing to dest then we'll end up
- // in ondata again. However, we only want to increase awaitDrain once because
- // dest will only emit one 'drain' event for the multiple writes.
- // => Introduce a guard on increasing awaitDrain.
- var increasedAwaitDrain = false;
- src.on('data', ondata);
- function ondata(chunk) {
- debug('ondata');
- increasedAwaitDrain = false;
- var ret = dest.write(chunk);
- if (false === ret && !increasedAwaitDrain) {
- // If the user unpiped during `dest.write()`, it is possible
- // to get stuck in a permanently paused state if that write
- // also returned false.
- // => Check whether `dest` is still a piping destination.
- if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
- debug('false write response, pause', src._readableState.awaitDrain);
- src._readableState.awaitDrain++;
- increasedAwaitDrain = true;
- }
- src.pause();
- }
- }
-
- // if the dest has an error, then stop piping into it.
- // however, don't suppress the throwing behavior for this.
- function onerror(er) {
- debug('onerror', er);
- unpipe();
- dest.removeListener('error', onerror);
- if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
- }
-
- // Make sure our error handler is attached before userland ones.
- prependListener(dest, 'error', onerror);
-
- // Both close and finish should trigger unpipe, but only once.
- function onclose() {
- dest.removeListener('finish', onfinish);
- unpipe();
- }
- dest.once('close', onclose);
- function onfinish() {
- debug('onfinish');
- dest.removeListener('close', onclose);
- unpipe();
- }
- dest.once('finish', onfinish);
-
- function unpipe() {
- debug('unpipe');
- src.unpipe(dest);
- }
-
- // tell the dest that it's being piped to
- dest.emit('pipe', src);
-
- // start the flow if it hasn't been started already.
- if (!state.flowing) {
- debug('pipe resume');
- src.resume();
- }
-
- return dest;
- };
-
- function pipeOnDrain(src) {
- return function () {
- var state = src._readableState;
- debug('pipeOnDrain', state.awaitDrain);
- if (state.awaitDrain) state.awaitDrain--;
- if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
- state.flowing = true;
- flow(src);
- }
- };
- }
-
- Readable.prototype.unpipe = function (dest) {
- var state = this._readableState;
-
- // if we're not piping anywhere, then do nothing.
- if (state.pipesCount === 0) return this;
-
- // just one destination. most common case.
- if (state.pipesCount === 1) {
- // passed in one, but it's not the right one.
- if (dest && dest !== state.pipes) return this;
-
- if (!dest) dest = state.pipes;
-
- // got a match.
- state.pipes = null;
- state.pipesCount = 0;
- state.flowing = false;
- if (dest) dest.emit('unpipe', this);
- return this;
- }
-
- // slow case. multiple pipe destinations.
-
- if (!dest) {
- // remove all.
- var dests = state.pipes;
- var len = state.pipesCount;
- state.pipes = null;
- state.pipesCount = 0;
- state.flowing = false;
-
- for (var i = 0; i < len; i++) {
- dests[i].emit('unpipe', this);
- }return this;
- }
-
- // try to find the right one.
- var index = indexOf(state.pipes, dest);
- if (index === -1) return this;
-
- state.pipes.splice(index, 1);
- state.pipesCount -= 1;
- if (state.pipesCount === 1) state.pipes = state.pipes[0];
-
- dest.emit('unpipe', this);
-
- return this;
- };
-
- // set up data events if they are asked for
- // Ensure readable listeners eventually get something
- Readable.prototype.on = function (ev, fn) {
- var res = Stream.prototype.on.call(this, ev, fn);
-
- if (ev === 'data') {
- // Start flowing on next tick if stream isn't explicitly paused
- if (this._readableState.flowing !== false) this.resume();
- } else if (ev === 'readable') {
- var state = this._readableState;
- if (!state.endEmitted && !state.readableListening) {
- state.readableListening = state.needReadable = true;
- state.emittedReadable = false;
- if (!state.reading) {
- processNextTick(nReadingNextTick, this);
- } else if (state.length) {
- emitReadable(this, state);
- }
- }
- }
-
- return res;
- };
- Readable.prototype.addListener = Readable.prototype.on;
-
- function nReadingNextTick(self) {
- debug('readable nexttick read 0');
- self.read(0);
- }
-
- // pause() and resume() are remnants of the legacy readable stream API
- // If the user uses them, then switch into old mode.
- Readable.prototype.resume = function () {
- var state = this._readableState;
- if (!state.flowing) {
- debug('resume');
- state.flowing = true;
- resume(this, state);
- }
- return this;
- };
-
- function resume(stream, state) {
- if (!state.resumeScheduled) {
- state.resumeScheduled = true;
- processNextTick(resume_, stream, state);
- }
- }
-
- function resume_(stream, state) {
- if (!state.reading) {
- debug('resume read 0');
- stream.read(0);
- }
-
- state.resumeScheduled = false;
- state.awaitDrain = 0;
- stream.emit('resume');
- flow(stream);
- if (state.flowing && !state.reading) stream.read(0);
- }
-
- Readable.prototype.pause = function () {
- debug('call pause flowing=%j', this._readableState.flowing);
- if (false !== this._readableState.flowing) {
- debug('pause');
- this._readableState.flowing = false;
- this.emit('pause');
- }
- return this;
- };
-
- function flow(stream) {
- var state = stream._readableState;
- debug('flow', state.flowing);
- while (state.flowing && stream.read() !== null) {}
- }
-
- // wrap an old-style stream as the async data source.
- // This is *not* part of the readable stream interface.
- // It is an ugly unfortunate mess of history.
- Readable.prototype.wrap = function (stream) {
- var state = this._readableState;
- var paused = false;
-
- var self = this;
- stream.on('end', function () {
- debug('wrapped end');
- if (state.decoder && !state.ended) {
- var chunk = state.decoder.end();
- if (chunk && chunk.length) self.push(chunk);
- }
-
- self.push(null);
- });
-
- stream.on('data', function (chunk) {
- debug('wrapped data');
- if (state.decoder) chunk = state.decoder.write(chunk);
-
- // don't skip over falsy values in objectMode
- if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
-
- var ret = self.push(chunk);
- if (!ret) {
- paused = true;
- stream.pause();
- }
- });
-
- // proxy all the other methods.
- // important when wrapping filters and duplexes.
- for (var i in stream) {
- if (this[i] === undefined && typeof stream[i] === 'function') {
- this[i] = function (method) {
- return function () {
- return stream[method].apply(stream, arguments);
- };
- }(i);
- }
- }
-
- // proxy certain important events.
- var events = ['error', 'close', 'destroy', 'pause', 'resume'];
- forEach(events, function (ev) {
- stream.on(ev, self.emit.bind(self, ev));
- });
-
- // when we try to consume some more bytes, simply unpause the
- // underlying stream.
- self._read = function (n) {
- debug('wrapped _read', n);
- if (paused) {
- paused = false;
- stream.resume();
- }
- };
-
- return self;
- };
-
- // exposed for testing purposes only.
- Readable._fromList = fromList;
-
- // Pluck off n bytes from an array of buffers.
- // Length is the combined lengths of all the buffers in the list.
- // This function is designed to be inlinable, so please take care when making
- // changes to the function body.
- function fromList(n, state) {
- // nothing buffered
- if (state.length === 0) return null;
-
- var ret;
- if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
- // read it all, truncate the list
- if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
- state.buffer.clear();
- } else {
- // read part of list
- ret = fromListPartial(n, state.buffer, state.decoder);
- }
-
- return ret;
- }
-
- // Extracts only enough buffered data to satisfy the amount requested.
- // This function is designed to be inlinable, so please take care when making
- // changes to the function body.
- function fromListPartial(n, list, hasStrings) {
- var ret;
- if (n < list.head.data.length) {
- // slice is the same for buffers and strings
- ret = list.head.data.slice(0, n);
- list.head.data = list.head.data.slice(n);
- } else if (n === list.head.data.length) {
- // first chunk is a perfect match
- ret = list.shift();
- } else {
- // result spans more than one buffer
- ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
- }
- return ret;
- }
-
- // Copies a specified amount of characters from the list of buffered data
- // chunks.
- // This function is designed to be inlinable, so please take care when making
- // changes to the function body.
- function copyFromBufferString(n, list) {
- var p = list.head;
- var c = 1;
- var ret = p.data;
- n -= ret.length;
- while (p = p.next) {
- var str = p.data;
- var nb = n > str.length ? str.length : n;
- if (nb === str.length) ret += str;else ret += str.slice(0, n);
- n -= nb;
- if (n === 0) {
- if (nb === str.length) {
- ++c;
- if (p.next) list.head = p.next;else list.head = list.tail = null;
- } else {
- list.head = p;
- p.data = str.slice(nb);
- }
- break;
- }
- ++c;
- }
- list.length -= c;
- return ret;
- }
-
- // Copies a specified amount of bytes from the list of buffered data chunks.
- // This function is designed to be inlinable, so please take care when making
- // changes to the function body.
- function copyFromBuffer(n, list) {
- var ret = bufferShim.allocUnsafe(n);
- var p = list.head;
- var c = 1;
- p.data.copy(ret);
- n -= p.data.length;
- while (p = p.next) {
- var buf = p.data;
- var nb = n > buf.length ? buf.length : n;
- buf.copy(ret, ret.length - n, 0, nb);
- n -= nb;
- if (n === 0) {
- if (nb === buf.length) {
- ++c;
- if (p.next) list.head = p.next;else list.head = list.tail = null;
- } else {
- list.head = p;
- p.data = buf.slice(nb);
- }
- break;
- }
- ++c;
- }
- list.length -= c;
- return ret;
- }
-
- function endReadable(stream) {
- var state = stream._readableState;
-
- // If we get here before consuming all the bytes, then that is a
- // bug in node. Should never happen.
- if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
-
- if (!state.endEmitted) {
- state.ended = true;
- processNextTick(endReadableNT, state, stream);
- }
- }
-
- function endReadableNT(state, stream) {
- // Check that we didn't get one last unshift.
- if (!state.endEmitted && state.length === 0) {
- state.endEmitted = true;
- stream.readable = false;
- stream.emit('end');
- }
- }
-
- function forEach(xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
-
- function indexOf(xs, x) {
- for (var i = 0, l = xs.length; i < l; i++) {
- if (xs[i] === x) return i;
- }
- return -1;
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
-
-/***/ },
-/* 15 */
-/***/ function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(process) {'use strict';
-
- if (!process.version ||
- process.version.indexOf('v0.') === 0 ||
- process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
- module.exports = nextTick;
- } else {
- module.exports = process.nextTick;
- }
-
- function nextTick(fn, arg1, arg2, arg3) {
- if (typeof fn !== 'function') {
- throw new TypeError('"callback" argument must be a function');
- }
- var len = arguments.length;
- var args, i;
- switch (len) {
- case 0:
- case 1:
- return process.nextTick(fn);
- case 2:
- return process.nextTick(function afterTickOne() {
- fn.call(null, arg1);
- });
- case 3:
- return process.nextTick(function afterTickTwo() {
- fn.call(null, arg1, arg2);
- });
- case 4:
- return process.nextTick(function afterTickThree() {
- fn.call(null, arg1, arg2, arg3);
- });
- default:
- args = new Array(len - 1);
- i = 0;
- while (i < args.length) {
- args[i++] = arguments[i];
- }
- return process.nextTick(function afterTick() {
- fn.apply(null, args);
- });
- }
- }
-
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
-
-/***/ },
-/* 16 */
-/***/ function(module, exports) {
-
- var toString = {}.toString;
-
- module.exports = Array.isArray || function (arr) {
- return toString.call(arr) == '[object Array]';
- };
-
-
-/***/ },
-/* 17 */
-/***/ function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(global) {'use strict';
-
- var buffer = __webpack_require__(2);
- var Buffer = buffer.Buffer;
- var SlowBuffer = buffer.SlowBuffer;
- var MAX_LEN = buffer.kMaxLength || 2147483647;
- exports.alloc = function alloc(size, fill, encoding) {
- if (typeof Buffer.alloc === 'function') {
- return Buffer.alloc(size, fill, encoding);
- }
- if (typeof encoding === 'number') {
- throw new TypeError('encoding must not be number');
- }
- if (typeof size !== 'number') {
- throw new TypeError('size must be a number');
- }
- if (size > MAX_LEN) {
- throw new RangeError('size is too large');
- }
- var enc = encoding;
- var _fill = fill;
- if (_fill === undefined) {
- enc = undefined;
- _fill = 0;
- }
- var buf = new Buffer(size);
- if (typeof _fill === 'string') {
- var fillBuf = new Buffer(_fill, enc);
- var flen = fillBuf.length;
- var i = -1;
- while (++i < size) {
- buf[i] = fillBuf[i % flen];
- }
- } else {
- buf.fill(_fill);
- }
- return buf;
- }
- exports.allocUnsafe = function allocUnsafe(size) {
- if (typeof Buffer.allocUnsafe === 'function') {
- return Buffer.allocUnsafe(size);
- }
- if (typeof size !== 'number') {
- throw new TypeError('size must be a number');
- }
- if (size > MAX_LEN) {
- throw new RangeError('size is too large');
- }
- return new Buffer(size);
- }
- exports.from = function from(value, encodingOrOffset, length) {
- if (typeof Buffer.from === 'function' && (!global.Uint8Array || Uint8Array.from !== Buffer.from)) {
- return Buffer.from(value, encodingOrOffset, length);
- }
- if (typeof value === 'number') {
- throw new TypeError('"value" argument must not be a number');
- }
- if (typeof value === 'string') {
- return new Buffer(value, encodingOrOffset);
- }
- if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
- var offset = encodingOrOffset;
- if (arguments.length === 1) {
- return new Buffer(value);
- }
- if (typeof offset === 'undefined') {
- offset = 0;
- }
- var len = length;
- if (typeof len === 'undefined') {
- len = value.byteLength - offset;
- }
- if (offset >= value.byteLength) {
- throw new RangeError('\'offset\' is out of bounds');
- }
- if (len > value.byteLength - offset) {
- throw new RangeError('\'length\' is out of bounds');
- }
- return new Buffer(value.slice(offset, offset + len));
- }
- if (Buffer.isBuffer(value)) {
- var out = new Buffer(value.length);
- value.copy(out, 0, 0, value.length);
- return out;
- }
- if (value) {
- if (Array.isArray(value) || (typeof ArrayBuffer !== 'undefined' && value.buffer instanceof ArrayBuffer) || 'length' in value) {
- return new Buffer(value);
- }
- if (value.type === 'Buffer' && Array.isArray(value.data)) {
- return new Buffer(value.data);
- }
- }
-
- throw new TypeError('First argument must be a string, Buffer, ' + 'ArrayBuffer, Array, or array-like object.');
- }
- exports.allocUnsafeSlow = function allocUnsafeSlow(size) {
- if (typeof Buffer.allocUnsafeSlow === 'function') {
- return Buffer.allocUnsafeSlow(size);
- }
- if (typeof size !== 'number') {
- throw new TypeError('size must be a number');
- }
- if (size >= MAX_LEN) {
- throw new RangeError('size is too large');
- }
- return new SlowBuffer(size);
- }
-
- /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
-
-/***/ },
-/* 18 */
-/***/ function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- // NOTE: These type checking functions intentionally don't use `instanceof`
- // because it is fragile and can be easily faked with `Object.create()`.
-
- function isArray(arg) {
- if (Array.isArray) {
- return Array.isArray(arg);
- }
- return objectToString(arg) === '[object Array]';
- }
- exports.isArray = isArray;
-
- function isBoolean(arg) {
- return typeof arg === 'boolean';
- }
- exports.isBoolean = isBoolean;
-
- function isNull(arg) {
- return arg === null;
- }
- exports.isNull = isNull;
-
- function isNullOrUndefined(arg) {
- return arg == null;
- }
- exports.isNullOrUndefined = isNullOrUndefined;
-
- function isNumber(arg) {
- return typeof arg === 'number';
- }
- exports.isNumber = isNumber;
-
- function isString(arg) {
- return typeof arg === 'string';
- }
- exports.isString = isString;
-
- function isSymbol(arg) {
- return typeof arg === 'symbol';
- }
- exports.isSymbol = isSymbol;
-
- function isUndefined(arg) {
- return arg === void 0;
- }
- exports.isUndefined = isUndefined;
-
- function isRegExp(re) {
- return objectToString(re) === '[object RegExp]';
- }
- exports.isRegExp = isRegExp;
-
- function isObject(arg) {
- return typeof arg === 'object' && arg !== null;
- }
- exports.isObject = isObject;
-
- function isDate(d) {
- return objectToString(d) === '[object Date]';
- }
- exports.isDate = isDate;
-
- function isError(e) {
- return (objectToString(e) === '[object Error]' || e instanceof Error);
- }
- exports.isError = isError;
-
- function isFunction(arg) {
- return typeof arg === 'function';
- }
- exports.isFunction = isFunction;
-
- function isPrimitive(arg) {
- return arg === null ||
- typeof arg === 'boolean' ||
- typeof arg === 'number' ||
- typeof arg === 'string' ||
- typeof arg === 'symbol' || // ES6 symbol
- typeof arg === 'undefined';
- }
- exports.isPrimitive = isPrimitive;
-
- exports.isBuffer = Buffer.isBuffer;
-
- function objectToString(o) {
- return Object.prototype.toString.call(o);
- }
-
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)))
-
-/***/ },
-/* 19 */
-/***/ function(module, exports) {
-
- /* (ignored) */
-
-/***/ },
-/* 20 */
-/***/ function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var Buffer = __webpack_require__(2).Buffer;
- /**/
- var bufferShim = __webpack_require__(17);
- /**/
-
- module.exports = BufferList;
-
- function BufferList() {
- this.head = null;
- this.tail = null;
- this.length = 0;
- }
-
- BufferList.prototype.push = function (v) {
- var entry = { data: v, next: null };
- if (this.length > 0) this.tail.next = entry;else this.head = entry;
- this.tail = entry;
- ++this.length;
- };
-
- BufferList.prototype.unshift = function (v) {
- var entry = { data: v, next: this.head };
- if (this.length === 0) this.tail = entry;
- this.head = entry;
- ++this.length;
- };
-
- BufferList.prototype.shift = function () {
- if (this.length === 0) return;
- var ret = this.head.data;
- if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
- --this.length;
- return ret;
- };
-
- BufferList.prototype.clear = function () {
- this.head = this.tail = null;
- this.length = 0;
- };
-
- BufferList.prototype.join = function (s) {
- if (this.length === 0) return '';
- var p = this.head;
- var ret = '' + p.data;
- while (p = p.next) {
- ret += s + p.data;
- }return ret;
- };
-
- BufferList.prototype.concat = function (n) {
- if (this.length === 0) return bufferShim.alloc(0);
- if (this.length === 1) return this.head.data;
- var ret = bufferShim.allocUnsafe(n >>> 0);
- var p = this.head;
- var i = 0;
- while (p) {
- p.data.copy(ret, i);
- i += p.data.length;
- p = p.next;
- }
- return ret;
- };
-
-/***/ },
-/* 21 */
-/***/ function(module, exports, __webpack_require__) {
-
- // a duplex stream is just a stream that is both readable and writable.
- // Since JS doesn't have multiple prototypal inheritance, this class
- // prototypally inherits from Readable, and then parasitically from
- // Writable.
-
- 'use strict';
-
- /**/
-
- var objectKeys = Object.keys || function (obj) {
- var keys = [];
- for (var key in obj) {
- keys.push(key);
- }return keys;
- };
- /**/
-
- module.exports = Duplex;
-
- /**/
- var processNextTick = __webpack_require__(15);
- /**/
-
- /**/
- var util = __webpack_require__(18);
- util.inherits = __webpack_require__(12);
- /**/
-
- var Readable = __webpack_require__(14);
- var Writable = __webpack_require__(22);
-
- util.inherits(Duplex, Readable);
-
- var keys = objectKeys(Writable.prototype);
- for (var v = 0; v < keys.length; v++) {
- var method = keys[v];
- if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
- }
-
- function Duplex(options) {
- if (!(this instanceof Duplex)) return new Duplex(options);
-
- Readable.call(this, options);
- Writable.call(this, options);
-
- if (options && options.readable === false) this.readable = false;
-
- if (options && options.writable === false) this.writable = false;
-
- this.allowHalfOpen = true;
- if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
-
- this.once('end', onend);
- }
-
- // the no-half-open enforcer
- function onend() {
- // if we allow half-open state, or if the writable side ended,
- // then we're ok.
- if (this.allowHalfOpen || this._writableState.ended) return;
-
- // no more data can be written.
- // But allow more writes to happen in this tick.
- processNextTick(onEndNT, this);
- }
-
- function onEndNT(self) {
- self.end();
- }
-
- function forEach(xs, f) {
- for (var i = 0, l = xs.length; i < l; i++) {
- f(xs[i], i);
- }
- }
-
-/***/ },
-/* 22 */
-/***/ function(module, exports, __webpack_require__) {
-
- /* WEBPACK VAR INJECTION */(function(process) {// A bit simpler than readable streams.
- // Implement an async ._write(chunk, encoding, cb), and it'll handle all
- // the drain event emission and buffering.
-
- 'use strict';
-
- module.exports = Writable;
-
- /**/
- var processNextTick = __webpack_require__(15);
- /**/
-
- /**/
- var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
- /**/
-
- /**/
- var Duplex;
- /**/
-
- Writable.WritableState = WritableState;
-
- /**/
- var util = __webpack_require__(18);
- util.inherits = __webpack_require__(12);
- /**/
-
- /**/
- var internalUtil = {
- deprecate: __webpack_require__(23)
- };
- /**/
-
- /**/
- var Stream;
- (function () {
- try {
- Stream = __webpack_require__(11);
- } catch (_) {} finally {
- if (!Stream) Stream = __webpack_require__(8).EventEmitter;
- }
- })();
- /**/
-
- var Buffer = __webpack_require__(2).Buffer;
- /**/
- var bufferShim = __webpack_require__(17);
- /**/
-
- util.inherits(Writable, Stream);
-
- function nop() {}
-
- function WriteReq(chunk, encoding, cb) {
- this.chunk = chunk;
- this.encoding = encoding;
- this.callback = cb;
- this.next = null;
- }
-
- function WritableState(options, stream) {
- Duplex = Duplex || __webpack_require__(21);
-
- options = options || {};
-
- // object stream flag to indicate whether or not this stream
- // contains buffers or objects.
- this.objectMode = !!options.objectMode;
-
- if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
-
- // the point at which write() starts returning false
- // Note: 0 is a valid value, means that we always return false if
- // the entire buffer is not flushed immediately on write()
- var hwm = options.highWaterMark;
- var defaultHwm = this.objectMode ? 16 : 16 * 1024;
- this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
-
- // cast to ints.
- this.highWaterMark = ~~this.highWaterMark;
-
- // drain event flag.
- this.needDrain = false;
- // at the start of calling end()
- this.ending = false;
- // when end() has been called, and returned
- this.ended = false;
- // when 'finish' is emitted
- this.finished = false;
-
- // should we decode strings into buffers before passing to _write?
- // this is here so that some node-core streams can optimize string
- // handling at a lower level.
- var noDecode = options.decodeStrings === false;
- this.decodeStrings = !noDecode;
-
- // Crypto is kind of old and crusty. Historically, its default string
- // encoding is 'binary' so we have to make this configurable.
- // Everything else in the universe uses 'utf8', though.
- this.defaultEncoding = options.defaultEncoding || 'utf8';
-
- // not an actual buffer we keep track of, but a measurement
- // of how much we're waiting to get pushed to some underlying
- // socket or file.
- this.length = 0;
-
- // a flag to see when we're in the middle of a write.
- this.writing = false;
-
- // when true all writes will be buffered until .uncork() call
- this.corked = 0;
-
- // a flag to be able to tell if the onwrite cb is called immediately,
- // or on a later tick. We set this to true at first, because any
- // actions that shouldn't happen until "later" should generally also
- // not happen before the first write call.
- this.sync = true;
-
- // a flag to know if we're processing previously buffered items, which
- // may call the _write() callback in the same tick, so that we don't
- // end up in an overlapped onwrite situation.
- this.bufferProcessing = false;
-
- // the callback that's passed to _write(chunk,cb)
- this.onwrite = function (er) {
- onwrite(stream, er);
- };
-
- // the callback that the user supplies to write(chunk,encoding,cb)
- this.writecb = null;
-
- // the amount that is being written when _write is called.
- this.writelen = 0;
-
- this.bufferedRequest = null;
- this.lastBufferedRequest = null;
-
- // number of pending user-supplied write callbacks
- // this must be 0 before 'finish' can be emitted
- this.pendingcb = 0;
-
- // emit prefinish if the only thing we're waiting for is _write cbs
- // This is relevant for synchronous Transform streams
- this.prefinished = false;
-
- // True if the error was already emitted and should not be thrown again
- this.errorEmitted = false;
-
- // count buffered requests
- this.bufferedRequestCount = 0;
-
- // allocate the first CorkedRequest, there is always
- // one allocated and free to use, and we maintain at most two
- this.corkedRequestsFree = new CorkedRequest(this);
- }
-
- WritableState.prototype.getBuffer = function getBuffer() {
- var current = this.bufferedRequest;
- var out = [];
- while (current) {
- out.push(current);
- current = current.next;
- }
- return out;
- };
-
- (function () {
- try {
- Object.defineProperty(WritableState.prototype, 'buffer', {
- get: internalUtil.deprecate(function () {
- return this.getBuffer();
- }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')
- });
- } catch (_) {}
- })();
-
- // Test _writableState for inheritance to account for Duplex streams,
- // whose prototype chain only points to Readable.
- var realHasInstance;
- if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
- realHasInstance = Function.prototype[Symbol.hasInstance];
- Object.defineProperty(Writable, Symbol.hasInstance, {
- value: function (object) {
- if (realHasInstance.call(this, object)) return true;
-
- return object && object._writableState instanceof WritableState;
- }
- });
- } else {
- realHasInstance = function (object) {
- return object instanceof this;
- };
- }
-
- function Writable(options) {
- Duplex = Duplex || __webpack_require__(21);
-
- // Writable ctor is applied to Duplexes, too.
- // `realHasInstance` is necessary because using plain `instanceof`
- // would return false, as no `_writableState` property is attached.
-
- // Trying to use the custom `instanceof` for Writable here will also break the
- // Node.js LazyTransform implementation, which has a non-trivial getter for
- // `_writableState` that would lead to infinite recursion.
- if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
- return new Writable(options);
- }
-
- this._writableState = new WritableState(options, this);
-
- // legacy.
- this.writable = true;
-
- if (options) {
- if (typeof options.write === 'function') this._write = options.write;
-
- if (typeof options.writev === 'function') this._writev = options.writev;
- }
-
- Stream.call(this);
- }
-
- // Otherwise people can pipe Writable streams, which is just wrong.
- Writable.prototype.pipe = function () {
- this.emit('error', new Error('Cannot pipe, not readable'));
- };
-
- function writeAfterEnd(stream, cb) {
- var er = new Error('write after end');
- // TODO: defer error events consistently everywhere, not just the cb
- stream.emit('error', er);
- processNextTick(cb, er);
- }
-
- // Checks that a user-supplied chunk is valid, especially for the particular
- // mode the stream is in. Currently this means that `null` is never accepted
- // and undefined/non-string values are only allowed in object mode.
- function validChunk(stream, state, chunk, cb) {
- var valid = true;
- var er = false;
-
- if (chunk === null) {
- er = new TypeError('May not write null values to stream');
- } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
- er = new TypeError('Invalid non-string/buffer chunk');
- }
- if (er) {
- stream.emit('error', er);
- processNextTick(cb, er);
- valid = false;
- }
- return valid;
- }
-
- Writable.prototype.write = function (chunk, encoding, cb) {
- var state = this._writableState;
- var ret = false;
- var isBuf = Buffer.isBuffer(chunk);
-
- if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
-
- if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
-
- if (typeof cb !== 'function') cb = nop;
-
- if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
- state.pendingcb++;
- ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
- }
-
- return ret;
- };
-
- Writable.prototype.cork = function () {
- var state = this._writableState;
-
- state.corked++;
- };
-
- Writable.prototype.uncork = function () {
- var state = this._writableState;
-
- if (state.corked) {
- state.corked--;
-
- if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
- }
- };
-
- Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
- // node::ParseEncoding() requires lower case.
- if (typeof encoding === 'string') encoding = encoding.toLowerCase();
- if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
- this._writableState.defaultEncoding = encoding;
- return this;
- };
-
- function decodeChunk(state, chunk, encoding) {
- if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
- chunk = bufferShim.from(chunk, encoding);
- }
- return chunk;
- }
-
- // if we're already writing something, then just put this
- // in the queue, and wait our turn. Otherwise, call _write
- // If we return false, then we need a drain event, so set that flag.
- function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
- if (!isBuf) {
- chunk = decodeChunk(state, chunk, encoding);
- if (Buffer.isBuffer(chunk)) encoding = 'buffer';
- }
- var len = state.objectMode ? 1 : chunk.length;
-
- state.length += len;
-
- var ret = state.length < state.highWaterMark;
- // we must ensure that previous needDrain will not be reset to false.
- if (!ret) state.needDrain = true;
-
- if (state.writing || state.corked) {
- var last = state.lastBufferedRequest;
- state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
- if (last) {
- last.next = state.lastBufferedRequest;
- } else {
- state.bufferedRequest = state.lastBufferedRequest;
- }
- state.bufferedRequestCount += 1;
- } else {
- doWrite(stream, state, false, len, chunk, encoding, cb);
- }
-
- return ret;
- }
-
- function doWrite(stream, state, writev, len, chunk, encoding, cb) {
- state.writelen = len;
- state.writecb = cb;
- state.writing = true;
- state.sync = true;
- if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
- state.sync = false;
- }
-
- function onwriteError(stream, state, sync, er, cb) {
- --state.pendingcb;
- if (sync) processNextTick(cb, er);else cb(er);
-
- stream._writableState.errorEmitted = true;
- stream.emit('error', er);
- }
-
- function onwriteStateUpdate(state) {
- state.writing = false;
- state.writecb = null;
- state.length -= state.writelen;
- state.writelen = 0;
- }
-
- function onwrite(stream, er) {
- var state = stream._writableState;
- var sync = state.sync;
- var cb = state.writecb;
-
- onwriteStateUpdate(state);
-
- if (er) onwriteError(stream, state, sync, er, cb);else {
- // Check if we're actually ready to finish, but don't emit yet
- var finished = needFinish(state);
-
- if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
- clearBuffer(stream, state);
- }
-
- if (sync) {
- /**/
- asyncWrite(afterWrite, stream, state, finished, cb);
- /**/
- } else {
- afterWrite(stream, state, finished, cb);
- }
- }
- }
-
- function afterWrite(stream, state, finished, cb) {
- if (!finished) onwriteDrain(stream, state);
- state.pendingcb--;
- cb();
- finishMaybe(stream, state);
- }
-
- // Must force callback to be called on nextTick, so that we don't
- // emit 'drain' before the write() consumer gets the 'false' return
- // value, and has a chance to attach a 'drain' listener.
- function onwriteDrain(stream, state) {
- if (state.length === 0 && state.needDrain) {
- state.needDrain = false;
- stream.emit('drain');
- }
- }
-
- // if there's something in the buffer waiting, then process it
- function clearBuffer(stream, state) {
- state.bufferProcessing = true;
- var entry = state.bufferedRequest;
-
- if (stream._writev && entry && entry.next) {
- // Fast case, write everything using _writev()
- var l = state.bufferedRequestCount;
- var buffer = new Array(l);
- var holder = state.corkedRequestsFree;
- holder.entry = entry;
-
- var count = 0;
- while (entry) {
- buffer[count] = entry;
- entry = entry.next;
- count += 1;
- }
-
- doWrite(stream, state, true, state.length, buffer, '', holder.finish);
-
- // doWrite is almost always async, defer these to save a bit of time
- // as the hot path ends with doWrite
- state.pendingcb++;
- state.lastBufferedRequest = null;
- if (holder.next) {
- state.corkedRequestsFree = holder.next;
- holder.next = null;
- } else {
- state.corkedRequestsFree = new CorkedRequest(state);
- }
- } else {
- // Slow case, write chunks one-by-one
- while (entry) {
- var chunk = entry.chunk;
- var encoding = entry.encoding;
- var cb = entry.callback;
- var len = state.objectMode ? 1 : chunk.length;
-
- doWrite(stream, state, false, len, chunk, encoding, cb);
- entry = entry.next;
- // if we didn't call the onwrite immediately, then
- // it means that we need to wait until it does.
- // also, that means that the chunk and cb are currently
- // being processed, so move the buffer counter past them.
- if (state.writing) {
- break;
- }
- }
-
- if (entry === null) state.lastBufferedRequest = null;
- }
-
- state.bufferedRequestCount = 0;
- state.bufferedRequest = entry;
- state.bufferProcessing = false;
- }
-
- Writable.prototype._write = function (chunk, encoding, cb) {
- cb(new Error('_write() is not implemented'));
- };
-
- Writable.prototype._writev = null;
-
- Writable.prototype.end = function (chunk, encoding, cb) {
- var state = this._writableState;
-
- if (typeof chunk === 'function') {
- cb = chunk;
- chunk = null;
- encoding = null;
- } else if (typeof encoding === 'function') {
- cb = encoding;
- encoding = null;
- }
-
- if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
-
- // .end() fully uncorks
- if (state.corked) {
- state.corked = 1;
- this.uncork();
- }
-
- // ignore unnecessary end() calls.
- if (!state.ending && !state.finished) endWritable(this, state, cb);
- };
-
- function needFinish(state) {
- return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
- }
-
- function prefinish(stream, state) {
- if (!state.prefinished) {
- state.prefinished = true;
- stream.emit('prefinish');
- }
- }
-
- function finishMaybe(stream, state) {
- var need = needFinish(state);
- if (need) {
- if (state.pendingcb === 0) {
- prefinish(stream, state);
- state.finished = true;
- stream.emit('finish');
- } else {
- prefinish(stream, state);
- }
- }
- return need;
- }
-
- function endWritable(stream, state, cb) {
- state.ending = true;
- finishMaybe(stream, state);
- if (cb) {
- if (state.finished) processNextTick(cb);else stream.once('finish', cb);
- }
- state.ended = true;
- stream.writable = false;
- }
-
- // It seems a linked list but it is not
- // there will be only 2 of these for each stream
- function CorkedRequest(state) {
- var _this = this;
-
- this.next = null;
- this.entry = null;
- this.finish = function (err) {
- var entry = _this.entry;
- _this.entry = null;
- while (entry) {
- var cb = entry.callback;
- state.pendingcb--;
- cb(err);
- entry = entry.next;
- }
- if (state.corkedRequestsFree) {
- state.corkedRequestsFree.next = _this;
- } else {
- state.corkedRequestsFree = _this;
- }
- };
- }
- /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))
-
-/***/ },
-/* 23 */
-/***/ function(module, exports) {
-
- /* WEBPACK VAR INJECTION */(function(global) {
- /**
- * Module exports.
- */
-
- module.exports = deprecate;
-
- /**
- * Mark that a method should not be used.
- * Returns a modified function which warns once by default.
- *
- * If `localStorage.noDeprecation = true` is set, then it is a no-op.
- *
- * If `localStorage.throwDeprecation = true` is set, then deprecated functions
- * will throw an Error when invoked.
- *
- * If `localStorage.traceDeprecation = true` is set, then deprecated functions
- * will invoke `console.trace()` instead of `console.error()`.
- *
- * @param {Function} fn - the function to deprecate
- * @param {String} msg - the string to print to the console when `fn` is invoked
- * @returns {Function} a new "deprecated" version of `fn`
- * @api public
- */
-
- function deprecate (fn, msg) {
- if (config('noDeprecation')) {
- return fn;
- }
-
- var warned = false;
- function deprecated() {
- if (!warned) {
- if (config('throwDeprecation')) {
- throw new Error(msg);
- } else if (config('traceDeprecation')) {
- console.trace(msg);
- } else {
- console.warn(msg);
- }
- warned = true;
- }
- return fn.apply(this, arguments);
- }
-
- return deprecated;
- }
-
- /**
- * Checks `localStorage` for boolean values for the given `name`.
- *
- * @param {String} name
- * @returns {Boolean}
- * @api private
- */
-
- function config (name) {
- // accessing global.localStorage can trigger a DOMException in sandboxed iframes
- try {
- if (!global.localStorage) return false;
- } catch (_) {
- return false;
- }
- var val = global.localStorage[name];
- if (null == val) return false;
- return String(val).toLowerCase() === 'true';
- }
-
- /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
-
-/***/ },
-/* 24 */
-/***/ function(module, exports, __webpack_require__) {
-
- // Copyright Joyent, Inc. and other Node contributors.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a
- // copy of this software and associated documentation files (the
- // "Software"), to deal in the Software without restriction, including
- // without limitation the rights to use, copy, modify, merge, publish,
- // distribute, sublicense, and/or sell copies of the Software, and to permit
- // persons to whom the Software is furnished to do so, subject to the
- // following conditions:
- //
- // The above copyright notice and this permission notice shall be included
- // in all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- var Buffer = __webpack_require__(2).Buffer;
-
- var isBufferEncoding = Buffer.isEncoding
- || function(encoding) {
- switch (encoding && encoding.toLowerCase()) {
- case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true;
- default: return false;
- }
- }
-
-
- function assertEncoding(encoding) {
- if (encoding && !isBufferEncoding(encoding)) {
- throw new Error('Unknown encoding: ' + encoding);
- }
- }
-
- // StringDecoder provides an interface for efficiently splitting a series of
- // buffers into a series of JS strings without breaking apart multi-byte
- // characters. CESU-8 is handled as part of the UTF-8 encoding.
- //
- // @TODO Handling all encodings inside a single object makes it very difficult
- // to reason about this code, so it should be split up in the future.
- // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
- // points as used by CESU-8.
- var StringDecoder = exports.StringDecoder = function(encoding) {
- this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
- assertEncoding(encoding);
- switch (this.encoding) {
- case 'utf8':
- // CESU-8 represents each of Surrogate Pair by 3-bytes
- this.surrogateSize = 3;
- break;
- case 'ucs2':
- case 'utf16le':
- // UTF-16 represents each of Surrogate Pair by 2-bytes
- this.surrogateSize = 2;
- this.detectIncompleteChar = utf16DetectIncompleteChar;
- break;
- case 'base64':
- // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
- this.surrogateSize = 3;
- this.detectIncompleteChar = base64DetectIncompleteChar;
- break;
- default:
- this.write = passThroughWrite;
- return;
- }
-
- // Enough space to store all bytes of a single character. UTF-8 needs 4
- // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
- this.charBuffer = new Buffer(6);
- // Number of bytes received for the current incomplete multi-byte character.
- this.charReceived = 0;
- // Number of bytes expected for the current incomplete multi-byte character.
- this.charLength = 0;
- };
-
-
- // write decodes the given buffer and returns it as JS string that is
- // guaranteed to not contain any partial multi-byte characters. Any partial
- // character found at the end of the buffer is buffered up, and will be
- // returned when calling write again with the remaining bytes.
- //
- // Note: Converting a Buffer containing an orphan surrogate to a String
- // currently works, but converting a String to a Buffer (via `new Buffer`, or
- // Buffer#write) will replace incomplete surrogates with the unicode
- // replacement character. See https://codereview.chromium.org/121173009/ .
- StringDecoder.prototype.write = function(buffer) {
- var charStr = '';
- // if our last write ended with an incomplete multibyte character
- while (this.charLength) {
- // determine how many remaining bytes this buffer has to offer for this char
- var available = (buffer.length >= this.charLength - this.charReceived) ?
- this.charLength - this.charReceived :
- buffer.length;
-
- // add the new bytes to the char buffer
- buffer.copy(this.charBuffer, this.charReceived, 0, available);
- this.charReceived += available;
-
- if (this.charReceived < this.charLength) {
- // still not enough chars in this buffer? wait for more ...
- return '';
- }
-
- // remove bytes belonging to the current character from the buffer
- buffer = buffer.slice(available, buffer.length);
-
- // get the character that was split
- charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
-
- // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
- var charCode = charStr.charCodeAt(charStr.length - 1);
- if (charCode >= 0xD800 && charCode <= 0xDBFF) {
- this.charLength += this.surrogateSize;
- charStr = '';
- continue;
- }
- this.charReceived = this.charLength = 0;
-
- // if there are no more bytes in this buffer, just emit our char
- if (buffer.length === 0) {
- return charStr;
- }
- break;
- }
-
- // determine and set charLength / charReceived
- this.detectIncompleteChar(buffer);
-
- var end = buffer.length;
- if (this.charLength) {
- // buffer the incomplete character bytes we got
- buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
- end -= this.charReceived;
- }
-
- charStr += buffer.toString(this.encoding, 0, end);
-
- var end = charStr.length - 1;
- var charCode = charStr.charCodeAt(end);
- // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
- if (charCode >= 0xD800 && charCode <= 0xDBFF) {
- var size = this.surrogateSize;
- this.charLength += size;
- this.charReceived += size;
- this.charBuffer.copy(this.charBuffer, size, 0, size);
- buffer.copy(this.charBuffer, 0, 0, size);
- return charStr.substring(0, end);
- }
-
- // or just emit the charStr
- return charStr;
- };
-
- // detectIncompleteChar determines if there is an incomplete UTF-8 character at
- // the end of the given buffer. If so, it sets this.charLength to the byte
- // length that character, and sets this.charReceived to the number of bytes
- // that are available for this character.
- StringDecoder.prototype.detectIncompleteChar = function(buffer) {
- // determine how many bytes we have to check at the end of this buffer
- var i = (buffer.length >= 3) ? 3 : buffer.length;
-
- // Figure out if one of the last i bytes of our buffer announces an
- // incomplete char.
- for (; i > 0; i--) {
- var c = buffer[buffer.length - i];
-
- // See http://en.wikipedia.org/wiki/UTF-8#Description
-
- // 110XXXXX
- if (i == 1 && c >> 5 == 0x06) {
- this.charLength = 2;
- break;
- }
-
- // 1110XXXX
- if (i <= 2 && c >> 4 == 0x0E) {
- this.charLength = 3;
- break;
- }
-
- // 11110XXX
- if (i <= 3 && c >> 3 == 0x1E) {
- this.charLength = 4;
- break;
- }
- }
- this.charReceived = i;
- };
-
- StringDecoder.prototype.end = function(buffer) {
- var res = '';
- if (buffer && buffer.length)
- res = this.write(buffer);
-
- if (this.charReceived) {
- var cr = this.charReceived;
- var buf = this.charBuffer;
- var enc = this.encoding;
- res += buf.slice(0, cr).toString(enc);
- }
-
- return res;
- };
-
- function passThroughWrite(buffer) {
- return buffer.toString(this.encoding);
- }
-
- function utf16DetectIncompleteChar(buffer) {
- this.charReceived = buffer.length % 2;
- this.charLength = this.charReceived ? 2 : 0;
- }
-
- function base64DetectIncompleteChar(buffer) {
- this.charReceived = buffer.length % 3;
- this.charLength = this.charReceived ? 3 : 0;
- }
-
-
-/***/ },
-/* 25 */
-/***/ function(module, exports, __webpack_require__) {
-
- // a transform stream is a readable/writable stream where you do
- // something with the data. Sometimes it's called a "filter",
- // but that's not a great name for it, since that implies a thing where
- // some bits pass through, and others are simply ignored. (That would
- // be a valid example of a transform, of course.)
- //
- // While the output is causally related to the input, it's not a
- // necessarily symmetric or synchronous transformation. For example,
- // a zlib stream might take multiple plain-text writes(), and then
- // emit a single compressed chunk some time in the future.
- //
- // Here's how this works:
- //
- // The Transform stream has all the aspects of the readable and writable
- // stream classes. When you write(chunk), that calls _write(chunk,cb)
- // internally, and returns false if there's a lot of pending writes
- // buffered up. When you call read(), that calls _read(n) until
- // there's enough pending readable data buffered up.
- //
- // In a transform stream, the written data is placed in a buffer. When
- // _read(n) is called, it transforms the queued up data, calling the
- // buffered _write cb's as it consumes chunks. If consuming a single
- // written chunk would result in multiple output chunks, then the first
- // outputted bit calls the readcb, and subsequent chunks just go into
- // the read buffer, and will cause it to emit 'readable' if necessary.
- //
- // This way, back-pressure is actually determined by the reading side,
- // since _read has to be called to start processing a new chunk. However,
- // a pathological inflate type of transform can cause excessive buffering
- // here. For example, imagine a stream where every byte of input is
- // interpreted as an integer from 0-255, and then results in that many
- // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
- // 1kb of data being output. In this case, you could write a very small
- // amount of input, and end up with a very large amount of output. In
- // such a pathological inflating mechanism, there'd be no way to tell
- // the system to stop doing the transform. A single 4MB write could
- // cause the system to run out of memory.
- //
- // However, even in such a pathological case, only a single written chunk
- // would be consumed, and then the rest would wait (un-transformed) until
- // the results of the previous transformed chunk were consumed.
-
- 'use strict';
-
- module.exports = Transform;
-
- var Duplex = __webpack_require__(21);
-
- /**/
- var util = __webpack_require__(18);
- util.inherits = __webpack_require__(12);
- /**/
-
- util.inherits(Transform, Duplex);
-
- function TransformState(stream) {
- this.afterTransform = function (er, data) {
- return afterTransform(stream, er, data);
- };
-
- this.needTransform = false;
- this.transforming = false;
- this.writecb = null;
- this.writechunk = null;
- this.writeencoding = null;
- }
-
- function afterTransform(stream, er, data) {
- var ts = stream._transformState;
- ts.transforming = false;
-
- var cb = ts.writecb;
-
- if (!cb) return stream.emit('error', new Error('no writecb in Transform class'));
-
- ts.writechunk = null;
- ts.writecb = null;
-
- if (data !== null && data !== undefined) stream.push(data);
-
- cb(er);
-
- var rs = stream._readableState;
- rs.reading = false;
- if (rs.needReadable || rs.length < rs.highWaterMark) {
- stream._read(rs.highWaterMark);
- }
- }
-
- function Transform(options) {
- if (!(this instanceof Transform)) return new Transform(options);
-
- Duplex.call(this, options);
-
- this._transformState = new TransformState(this);
-
- var stream = this;
-
- // start out asking for a readable event once data is transformed.
- this._readableState.needReadable = true;
-
- // we have implemented the _read method, and done the other things
- // that Readable wants before the first _read call, so unset the
- // sync guard flag.
- this._readableState.sync = false;
-
- if (options) {
- if (typeof options.transform === 'function') this._transform = options.transform;
-
- if (typeof options.flush === 'function') this._flush = options.flush;
- }
-
- // When the writable side finishes, then flush out anything remaining.
- this.once('prefinish', function () {
- if (typeof this._flush === 'function') this._flush(function (er, data) {
- done(stream, er, data);
- });else done(stream);
- });
- }
-
- Transform.prototype.push = function (chunk, encoding) {
- this._transformState.needTransform = false;
- return Duplex.prototype.push.call(this, chunk, encoding);
- };
-
- // This is the part where you do stuff!
- // override this function in implementation classes.
- // 'chunk' is an input chunk.
- //
- // Call `push(newChunk)` to pass along transformed output
- // to the readable side. You may call 'push' zero or more times.
- //
- // Call `cb(err)` when you are done with this chunk. If you pass
- // an error, then that'll put the hurt on the whole operation. If you
- // never call cb(), then you'll never get another chunk.
- Transform.prototype._transform = function (chunk, encoding, cb) {
- throw new Error('_transform() is not implemented');
- };
-
- Transform.prototype._write = function (chunk, encoding, cb) {
- var ts = this._transformState;
- ts.writecb = cb;
- ts.writechunk = chunk;
- ts.writeencoding = encoding;
- if (!ts.transforming) {
- var rs = this._readableState;
- if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
- }
- };
-
- // Doesn't matter what the args are here.
- // _transform does all the work.
- // That we got here means that the readable side wants more data.
- Transform.prototype._read = function (n) {
- var ts = this._transformState;
-
- if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
- ts.transforming = true;
- this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
- } else {
- // mark that we need a transform, so that any data that comes in
- // will get processed, now that we've asked for it.
- ts.needTransform = true;
- }
- };
-
- function done(stream, er, data) {
- if (er) return stream.emit('error', er);
-
- if (data !== null && data !== undefined) stream.push(data);
-
- // if there's nothing in the write buffer, then that means
- // that nothing more will ever be provided
- var ws = stream._writableState;
- var ts = stream._transformState;
-
- if (ws.length) throw new Error('Calling transform done when ws.length != 0');
-
- if (ts.transforming) throw new Error('Calling transform done when still transforming');
-
- return stream.push(null);
- }
-
-/***/ },
-/* 26 */
-/***/ function(module, exports, __webpack_require__) {
-
- // a passthrough stream.
- // basically just the most minimal sort of Transform stream.
- // Every written chunk gets output as-is.
-
- 'use strict';
-
- module.exports = PassThrough;
-
- var Transform = __webpack_require__(25);
-
- /**/
- var util = __webpack_require__(18);
- util.inherits = __webpack_require__(12);
- /**/
-
- util.inherits(PassThrough, Transform);
-
- function PassThrough(options) {
- if (!(this instanceof PassThrough)) return new PassThrough(options);
-
- Transform.call(this, options);
- }
-
- PassThrough.prototype._transform = function (chunk, encoding, cb) {
- cb(null, chunk);
- };
-
-/***/ },
-/* 27 */
-/***/ function(module, exports, __webpack_require__) {
-
- module.exports = __webpack_require__(22)
-
-
-/***/ },
-/* 28 */
-/***/ function(module, exports, __webpack_require__) {
-
- module.exports = __webpack_require__(21)
-
-
-/***/ },
-/* 29 */
-/***/ function(module, exports, __webpack_require__) {
-
- module.exports = __webpack_require__(25)
-
-
-/***/ },
-/* 30 */
-/***/ function(module, exports, __webpack_require__) {
-
- module.exports = __webpack_require__(26)
-
-
-/***/ },
-/* 31 */
-/***/ function(module, exports, __webpack_require__) {
-
- 'use strict';
-
-
- var zlib_inflate = __webpack_require__(32);
- var utils = __webpack_require__(33);
- var strings = __webpack_require__(38);
- var c = __webpack_require__(39);
- var msg = __webpack_require__(40);
- var ZStream = __webpack_require__(41);
- var GZheader = __webpack_require__(42);
-
- var toString = Object.prototype.toString;
-
- /**
- * class Inflate
- *
- * Generic JS-style wrapper for zlib calls. If you don't need
- * streaming behaviour - use more simple functions: [[inflate]]
- * and [[inflateRaw]].
- **/
-
- /* internal
- * inflate.chunks -> Array
- *
- * Chunks of output data, if [[Inflate#onData]] not overriden.
- **/
-
- /**
- * Inflate.result -> Uint8Array|Array|String
- *
- * Uncompressed result, generated by default [[Inflate#onData]]
- * and [[Inflate#onEnd]] handlers. Filled after you push last chunk
- * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you
- * push a chunk with explicit flush (call [[Inflate#push]] with
- * `Z_SYNC_FLUSH` param).
- **/
-
- /**
- * Inflate.err -> Number
- *
- * Error code after inflate finished. 0 (Z_OK) on success.
- * Should be checked if broken data possible.
- **/
-
- /**
- * Inflate.msg -> String
- *
- * Error message, if [[Inflate.err]] != 0
- **/
-
-
- /**
- * new Inflate(options)
- * - options (Object): zlib inflate options.
- *
- * Creates new inflator instance with specified params. Throws exception
- * on bad params. Supported options:
- *
- * - `windowBits`
- * - `dictionary`
- *
- * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
- * for more information on these.
- *
- * Additional options, for internal needs:
- *
- * - `chunkSize` - size of generated data chunks (16K by default)
- * - `raw` (Boolean) - do raw inflate
- * - `to` (String) - if equal to 'string', then result will be converted
- * from utf8 to utf16 (javascript) string. When string output requested,
- * chunk length can differ from `chunkSize`, depending on content.
- *
- * By default, when no options set, autodetect deflate/gzip data format via
- * wrapper header.
- *
- * ##### Example:
- *
- * ```javascript
- * var pako = require('pako')
- * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
- * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
- *
- * var inflate = new pako.Inflate({ level: 3});
- *
- * inflate.push(chunk1, false);
- * inflate.push(chunk2, true); // true -> last chunk
- *
- * if (inflate.err) { throw new Error(inflate.err); }
- *
- * console.log(inflate.result);
- * ```
- **/
- function Inflate(options) {
- if (!(this instanceof Inflate)) return new Inflate(options);
-
- this.options = utils.assign({
- chunkSize: 16384,
- windowBits: 0,
- to: ''
- }, options || {});
-
- var opt = this.options;
-
- // Force window size for `raw` data, if not set directly,
- // because we have no header for autodetect.
- if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {
- opt.windowBits = -opt.windowBits;
- if (opt.windowBits === 0) { opt.windowBits = -15; }
- }
-
- // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate
- if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&
- !(options && options.windowBits)) {
- opt.windowBits += 32;
- }
-
- // Gzip header has no info about windows size, we can do autodetect only
- // for deflate. So, if window size not set, force it to max when gzip possible
- if ((opt.windowBits > 15) && (opt.windowBits < 48)) {
- // bit 3 (16) -> gzipped data
- // bit 4 (32) -> autodetect gzip/deflate
- if ((opt.windowBits & 15) === 0) {
- opt.windowBits |= 15;
- }
- }
-
- this.err = 0; // error code, if happens (0 = Z_OK)
- this.msg = ''; // error message
- this.ended = false; // used to avoid multiple onEnd() calls
- this.chunks = []; // chunks of compressed data
-
- this.strm = new ZStream();
- this.strm.avail_out = 0;
-
- var status = zlib_inflate.inflateInit2(
- this.strm,
- opt.windowBits
- );
-
- if (status !== c.Z_OK) {
- throw new Error(msg[status]);
- }
-
- this.header = new GZheader();
-
- zlib_inflate.inflateGetHeader(this.strm, this.header);
- }
-
- /**
- * Inflate#push(data[, mode]) -> Boolean
- * - data (Uint8Array|Array|ArrayBuffer|String): input data
- * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
- * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.
- *
- * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with
- * new output chunks. Returns `true` on success. The last data block must have
- * mode Z_FINISH (or `true`). That will flush internal pending buffers and call
- * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you
- * can use mode Z_SYNC_FLUSH, keeping the decompression context.
- *
- * On fail call [[Inflate#onEnd]] with error code and return false.
- *
- * We strongly recommend to use `Uint8Array` on input for best speed (output
- * format is detected automatically). Also, don't skip last param and always
- * use the same type in your code (boolean or number). That will improve JS speed.
- *
- * For regular `Array`-s make sure all elements are [0..255].
- *
- * ##### Example
- *
- * ```javascript
- * push(chunk, false); // push one of data chunks
- * ...
- * push(chunk, true); // push last chunk
- * ```
- **/
- Inflate.prototype.push = function (data, mode) {
- var strm = this.strm;
- var chunkSize = this.options.chunkSize;
- var dictionary = this.options.dictionary;
- var status, _mode;
- var next_out_utf8, tail, utf8str;
- var dict;
-
- // Flag to properly process Z_BUF_ERROR on testing inflate call
- // when we check that all output data was flushed.
- var allowBufError = false;
-
- if (this.ended) { return false; }
- _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);
-
- // Convert data if needed
- if (typeof data === 'string') {
- // Only binary strings can be decompressed on practice
- strm.input = strings.binstring2buf(data);
- } else if (toString.call(data) === '[object ArrayBuffer]') {
- strm.input = new Uint8Array(data);
- } else {
- strm.input = data;
- }
-
- strm.next_in = 0;
- strm.avail_in = strm.input.length;
-
- do {
- if (strm.avail_out === 0) {
- strm.output = new utils.Buf8(chunkSize);
- strm.next_out = 0;
- strm.avail_out = chunkSize;
- }
-
- status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */
-
- if (status === c.Z_NEED_DICT && dictionary) {
- // Convert data if needed
- if (typeof dictionary === 'string') {
- dict = strings.string2buf(dictionary);
- } else if (toString.call(dictionary) === '[object ArrayBuffer]') {
- dict = new Uint8Array(dictionary);
- } else {
- dict = dictionary;
- }
-
- status = zlib_inflate.inflateSetDictionary(this.strm, dict);
-
- }
-
- if (status === c.Z_BUF_ERROR && allowBufError === true) {
- status = c.Z_OK;
- allowBufError = false;
- }
-
- if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
- this.onEnd(status);
- this.ended = true;
- return false;
- }
-
- if (strm.next_out) {
- if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {
-
- if (this.options.to === 'string') {
-
- next_out_utf8 = strings.utf8border(strm.output, strm.next_out);
-
- tail = strm.next_out - next_out_utf8;
- utf8str = strings.buf2string(strm.output, next_out_utf8);
-
- // move tail
- strm.next_out = tail;
- strm.avail_out = chunkSize - tail;
- if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }
-
- this.onData(utf8str);
-
- } else {
- this.onData(utils.shrinkBuf(strm.output, strm.next_out));
- }
- }
- }
-
- // When no more input data, we should check that internal inflate buffers
- // are flushed. The only way to do it when avail_out = 0 - run one more
- // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.
- // Here we set flag to process this error properly.
- //
- // NOTE. Deflate does not return error in this case and does not needs such
- // logic.
- if (strm.avail_in === 0 && strm.avail_out === 0) {
- allowBufError = true;
- }
-
- } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);
-
- if (status === c.Z_STREAM_END) {
- _mode = c.Z_FINISH;
- }
-
- // Finalize on the last chunk.
- if (_mode === c.Z_FINISH) {
- status = zlib_inflate.inflateEnd(this.strm);
- this.onEnd(status);
- this.ended = true;
- return status === c.Z_OK;
- }
-
- // callback interim results if Z_SYNC_FLUSH.
- if (_mode === c.Z_SYNC_FLUSH) {
- this.onEnd(c.Z_OK);
- strm.avail_out = 0;
- return true;
- }
-
- return true;
- };
-
-
- /**
- * Inflate#onData(chunk) -> Void
- * - chunk (Uint8Array|Array|String): ouput data. Type of array depends
- * on js engine support. When string output requested, each chunk
- * will be string.
- *
- * By default, stores data blocks in `chunks[]` property and glue
- * those in `onEnd`. Override this handler, if you need another behaviour.
- **/
- Inflate.prototype.onData = function (chunk) {
- this.chunks.push(chunk);
- };
-
-
- /**
- * Inflate#onEnd(status) -> Void
- * - status (Number): inflate status. 0 (Z_OK) on success,
- * other if not.
- *
- * Called either after you tell inflate that the input stream is
- * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
- * or if an error happened. By default - join collected chunks,
- * free memory and fill `results` / `err` properties.
- **/
- Inflate.prototype.onEnd = function (status) {
- // On success - join
- if (status === c.Z_OK) {
- if (this.options.to === 'string') {
- // Glue & convert here, until we teach pako to send
- // utf8 alligned strings to onData
- this.result = this.chunks.join('');
- } else {
- this.result = utils.flattenChunks(this.chunks);
- }
- }
- this.chunks = [];
- this.err = status;
- this.msg = this.strm.msg;
- };
-
-
- /**
- * inflate(data[, options]) -> Uint8Array|Array|String
- * - data (Uint8Array|Array|String): input data to decompress.
- * - options (Object): zlib inflate options.
- *
- * Decompress `data` with inflate/ungzip and `options`. Autodetect
- * format via wrapper header by default. That's why we don't provide
- * separate `ungzip` method.
- *
- * Supported options are:
- *
- * - windowBits
- *
- * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
- * for more information.
- *
- * Sugar (options):
- *
- * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
- * negative windowBits implicitly.
- * - `to` (String) - if equal to 'string', then result will be converted
- * from utf8 to utf16 (javascript) string. When string output requested,
- * chunk length can differ from `chunkSize`, depending on content.
- *
- *
- * ##### Example:
- *
- * ```javascript
- * var pako = require('pako')
- * , input = pako.deflate([1,2,3,4,5,6,7,8,9])
- * , output;
- *
- * try {
- * output = pako.inflate(input);
- * } catch (err)
- * console.log(err);
- * }
- * ```
- **/
- function inflate(input, options) {
- var inflator = new Inflate(options);
-
- inflator.push(input, true);
-
- // That will never happens, if you don't cheat with options :)
- if (inflator.err) { throw inflator.msg || msg[inflator.err]; }
-
- return inflator.result;
- }
-
-
- /**
- * inflateRaw(data[, options]) -> Uint8Array|Array|String
- * - data (Uint8Array|Array|String): input data to decompress.
- * - options (Object): zlib inflate options.
- *
- * The same as [[inflate]], but creates raw data, without wrapper
- * (header and adler32 crc).
- **/
- function inflateRaw(input, options) {
- options = options || {};
- options.raw = true;
- return inflate(input, options);
- }
-
-
- /**
- * ungzip(data[, options]) -> Uint8Array|Array|String
- * - data (Uint8Array|Array|String): input data to decompress.
- * - options (Object): zlib inflate options.
- *
- * Just shortcut to [[inflate]], because it autodetects format
- * by header.content. Done for convenience.
- **/
-
-
- exports.Inflate = Inflate;
- exports.inflate = inflate;
- exports.inflateRaw = inflateRaw;
- exports.ungzip = inflate;
-
-
-/***/ },
-/* 32 */
-/***/ function(module, exports, __webpack_require__) {
-
- 'use strict';
-
-
- var utils = __webpack_require__(33);
- var adler32 = __webpack_require__(34);
- var crc32 = __webpack_require__(35);
- var inflate_fast = __webpack_require__(36);
- var inflate_table = __webpack_require__(37);
-
- var CODES = 0;
- var LENS = 1;
- var DISTS = 2;
-
- /* Public constants ==========================================================*/
- /* ===========================================================================*/
-
-
- /* Allowed flush values; see deflate() and inflate() below for details */
- //var Z_NO_FLUSH = 0;
- //var Z_PARTIAL_FLUSH = 1;
- //var Z_SYNC_FLUSH = 2;
- //var Z_FULL_FLUSH = 3;
- var Z_FINISH = 4;
- var Z_BLOCK = 5;
- var Z_TREES = 6;
-
-
- /* Return codes for the compression/decompression functions. Negative values
- * are errors, positive values are used for special but normal events.
- */
- var Z_OK = 0;
- var Z_STREAM_END = 1;
- var Z_NEED_DICT = 2;
- //var Z_ERRNO = -1;
- var Z_STREAM_ERROR = -2;
- var Z_DATA_ERROR = -3;
- var Z_MEM_ERROR = -4;
- var Z_BUF_ERROR = -5;
- //var Z_VERSION_ERROR = -6;
-
- /* The deflate compression method */
- var Z_DEFLATED = 8;
-
-
- /* STATES ====================================================================*/
- /* ===========================================================================*/
-
-
- var HEAD = 1; /* i: waiting for magic header */
- var FLAGS = 2; /* i: waiting for method and flags (gzip) */
- var TIME = 3; /* i: waiting for modification time (gzip) */
- var OS = 4; /* i: waiting for extra flags and operating system (gzip) */
- var EXLEN = 5; /* i: waiting for extra length (gzip) */
- var EXTRA = 6; /* i: waiting for extra bytes (gzip) */
- var NAME = 7; /* i: waiting for end of file name (gzip) */
- var COMMENT = 8; /* i: waiting for end of comment (gzip) */
- var HCRC = 9; /* i: waiting for header crc (gzip) */
- var DICTID = 10; /* i: waiting for dictionary check value */
- var DICT = 11; /* waiting for inflateSetDictionary() call */
- var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
- var TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */
- var STORED = 14; /* i: waiting for stored size (length and complement) */
- var COPY_ = 15; /* i/o: same as COPY below, but only first time in */
- var COPY = 16; /* i/o: waiting for input or output to copy stored block */
- var TABLE = 17; /* i: waiting for dynamic block table lengths */
- var LENLENS = 18; /* i: waiting for code length code lengths */
- var CODELENS = 19; /* i: waiting for length/lit and distance code lengths */
- var LEN_ = 20; /* i: same as LEN below, but only first time in */
- var LEN = 21; /* i: waiting for length/lit/eob code */
- var LENEXT = 22; /* i: waiting for length extra bits */
- var DIST = 23; /* i: waiting for distance code */
- var DISTEXT = 24; /* i: waiting for distance extra bits */
- var MATCH = 25; /* o: waiting for output space to copy string */
- var LIT = 26; /* o: waiting for output space to write literal */
- var CHECK = 27; /* i: waiting for 32-bit check value */
- var LENGTH = 28; /* i: waiting for 32-bit length (gzip) */
- var DONE = 29; /* finished check, done -- remain here until reset */
- var BAD = 30; /* got a data error -- remain here until reset */
- var MEM = 31; /* got an inflate() memory error -- remain here until reset */
- var SYNC = 32; /* looking for synchronization bytes to restart inflate() */
-
- /* ===========================================================================*/
-
-
-
- var ENOUGH_LENS = 852;
- var ENOUGH_DISTS = 592;
- //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
-
- var MAX_WBITS = 15;
- /* 32K LZ77 window */
- var DEF_WBITS = MAX_WBITS;
-
-
- function zswap32(q) {
- return (((q >>> 24) & 0xff) +
- ((q >>> 8) & 0xff00) +
- ((q & 0xff00) << 8) +
- ((q & 0xff) << 24));
- }
-
-
- function InflateState() {
- this.mode = 0; /* current inflate mode */
- this.last = false; /* true if processing last block */
- this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */
- this.havedict = false; /* true if dictionary provided */
- this.flags = 0; /* gzip header method and flags (0 if zlib) */
- this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */
- this.check = 0; /* protected copy of check value */
- this.total = 0; /* protected copy of output count */
- // TODO: may be {}
- this.head = null; /* where to save gzip header information */
-
- /* sliding window */
- this.wbits = 0; /* log base 2 of requested window size */
- this.wsize = 0; /* window size or zero if not using window */
- this.whave = 0; /* valid bytes in the window */
- this.wnext = 0; /* window write index */
- this.window = null; /* allocated sliding window, if needed */
-
- /* bit accumulator */
- this.hold = 0; /* input bit accumulator */
- this.bits = 0; /* number of bits in "in" */
-
- /* for string and stored block copying */
- this.length = 0; /* literal or length of data to copy */
- this.offset = 0; /* distance back to copy string from */
-
- /* for table and code decoding */
- this.extra = 0; /* extra bits needed */
-
- /* fixed and dynamic code tables */
- this.lencode = null; /* starting table for length/literal codes */
- this.distcode = null; /* starting table for distance codes */
- this.lenbits = 0; /* index bits for lencode */
- this.distbits = 0; /* index bits for distcode */
-
- /* dynamic table building */
- this.ncode = 0; /* number of code length code lengths */
- this.nlen = 0; /* number of length code lengths */
- this.ndist = 0; /* number of distance code lengths */
- this.have = 0; /* number of code lengths in lens[] */
- this.next = null; /* next available space in codes[] */
-
- this.lens = new utils.Buf16(320); /* temporary storage for code lengths */
- this.work = new utils.Buf16(288); /* work area for code table building */
-
- /*
- because we don't have pointers in js, we use lencode and distcode directly
- as buffers so we don't need codes
- */
- //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */
- this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */
- this.distdyn = null; /* dynamic table for distance codes (JS specific) */
- this.sane = 0; /* if false, allow invalid distance too far */
- this.back = 0; /* bits back of last unprocessed length/lit */
- this.was = 0; /* initial length of match */
- }
-
- function inflateResetKeep(strm) {
- var state;
-
- if (!strm || !strm.state) { return Z_STREAM_ERROR; }
- state = strm.state;
- strm.total_in = strm.total_out = state.total = 0;
- strm.msg = ''; /*Z_NULL*/
- if (state.wrap) { /* to support ill-conceived Java test suite */
- strm.adler = state.wrap & 1;
- }
- state.mode = HEAD;
- state.last = 0;
- state.havedict = 0;
- state.dmax = 32768;
- state.head = null/*Z_NULL*/;
- state.hold = 0;
- state.bits = 0;
- //state.lencode = state.distcode = state.next = state.codes;
- state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);
- state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);
-
- state.sane = 1;
- state.back = -1;
- //Tracev((stderr, "inflate: reset\n"));
- return Z_OK;
- }
-
- function inflateReset(strm) {
- var state;
-
- if (!strm || !strm.state) { return Z_STREAM_ERROR; }
- state = strm.state;
- state.wsize = 0;
- state.whave = 0;
- state.wnext = 0;
- return inflateResetKeep(strm);
-
- }
-
- function inflateReset2(strm, windowBits) {
- var wrap;
- var state;
-
- /* get the state */
- if (!strm || !strm.state) { return Z_STREAM_ERROR; }
- state = strm.state;
-
- /* extract wrap request from windowBits parameter */
- if (windowBits < 0) {
- wrap = 0;
- windowBits = -windowBits;
- }
- else {
- wrap = (windowBits >> 4) + 1;
- if (windowBits < 48) {
- windowBits &= 15;
- }
- }
-
- /* set number of window bits, free window if different */
- if (windowBits && (windowBits < 8 || windowBits > 15)) {
- return Z_STREAM_ERROR;
- }
- if (state.window !== null && state.wbits !== windowBits) {
- state.window = null;
- }
-
- /* update state and reset the rest of it */
- state.wrap = wrap;
- state.wbits = windowBits;
- return inflateReset(strm);
- }
-
- function inflateInit2(strm, windowBits) {
- var ret;
- var state;
-
- if (!strm) { return Z_STREAM_ERROR; }
- //strm.msg = Z_NULL; /* in case we return an error */
-
- state = new InflateState();
-
- //if (state === Z_NULL) return Z_MEM_ERROR;
- //Tracev((stderr, "inflate: allocated\n"));
- strm.state = state;
- state.window = null/*Z_NULL*/;
- ret = inflateReset2(strm, windowBits);
- if (ret !== Z_OK) {
- strm.state = null/*Z_NULL*/;
- }
- return ret;
- }
-
- function inflateInit(strm) {
- return inflateInit2(strm, DEF_WBITS);
- }
-
-
- /*
- Return state with length and distance decoding tables and index sizes set to
- fixed code decoding. Normally this returns fixed tables from inffixed.h.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
- var virgin = true;
-
- var lenfix, distfix; // We have no pointers in JS, so keep tables separate
-
- function fixedtables(state) {
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- var sym;
-
- lenfix = new utils.Buf32(512);
- distfix = new utils.Buf32(32);
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) { state.lens[sym++] = 8; }
- while (sym < 256) { state.lens[sym++] = 9; }
- while (sym < 280) { state.lens[sym++] = 7; }
- while (sym < 288) { state.lens[sym++] = 8; }
-
- inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });
-
- /* distance table */
- sym = 0;
- while (sym < 32) { state.lens[sym++] = 5; }
-
- inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });
-
- /* do this just once */
- virgin = false;
- }
-
- state.lencode = lenfix;
- state.lenbits = 9;
- state.distcode = distfix;
- state.distbits = 5;
- }
-
-
- /*
- Update the window with the last wsize (normally 32K) bytes written before
- returning. If window does not exist yet, create it. This is only called
- when a window is already in use, or when output has been written during this
- inflate call, but the end of the deflate stream has not been reached yet.
- It is also called to create a window for dictionary data when a dictionary
- is loaded.
-
- Providing output buffers larger than 32K to inflate() should provide a speed
- advantage, since only the last 32K of output is copied to the sliding window
- upon return from inflate(), and since all distances after the first 32K of
- output will fall in the output data, making match copies simpler and faster.
- The advantage may be dependent on the size of the processor's data caches.
- */
- function updatewindow(strm, src, end, copy) {
- var dist;
- var state = strm.state;
-
- /* if it hasn't been done already, allocate space for the window */
- if (state.window === null) {
- state.wsize = 1 << state.wbits;
- state.wnext = 0;
- state.whave = 0;
-
- state.window = new utils.Buf8(state.wsize);
- }
-
- /* copy state->wsize or less output bytes into the circular window */
- if (copy >= state.wsize) {
- utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
- state.wnext = 0;
- state.whave = state.wsize;
- }
- else {
- dist = state.wsize - state.wnext;
- if (dist > copy) {
- dist = copy;
- }
- //zmemcpy(state->window + state->wnext, end - copy, dist);
- utils.arraySet(state.window, src, end - copy, dist, state.wnext);
- copy -= dist;
- if (copy) {
- //zmemcpy(state->window, end - copy, copy);
- utils.arraySet(state.window, src, end - copy, copy, 0);
- state.wnext = copy;
- state.whave = state.wsize;
- }
- else {
- state.wnext += dist;
- if (state.wnext === state.wsize) { state.wnext = 0; }
- if (state.whave < state.wsize) { state.whave += dist; }
- }
- }
- return 0;
- }
-
- function inflate(strm, flush) {
- var state;
- var input, output; // input/output buffers
- var next; /* next input INDEX */
- var put; /* next output INDEX */
- var have, left; /* available input and output */
- var hold; /* bit buffer */
- var bits; /* bits in bit buffer */
- var _in, _out; /* save starting available input and output */
- var copy; /* number of stored or match bytes to copy */
- var from; /* where to copy match bytes from */
- var from_source;
- var here = 0; /* current decoding table entry */
- var here_bits, here_op, here_val; // paked "here" denormalized (JS specific)
- //var last; /* parent table entry */
- var last_bits, last_op, last_val; // paked "last" denormalized (JS specific)
- var len; /* length to copy for repeats, bits to drop */
- var ret; /* return code */
- var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */
- var opts;
-
- var n; // temporary var for NEED_BITS
-
- var order = /* permutation of code lengths */
- [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];
-
-
- if (!strm || !strm.state || !strm.output ||
- (!strm.input && strm.avail_in !== 0)) {
- return Z_STREAM_ERROR;
- }
-
- state = strm.state;
- if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */
-
-
- //--- LOAD() ---
- put = strm.next_out;
- output = strm.output;
- left = strm.avail_out;
- next = strm.next_in;
- input = strm.input;
- have = strm.avail_in;
- hold = state.hold;
- bits = state.bits;
- //---
-
- _in = have;
- _out = left;
- ret = Z_OK;
-
- inf_leave: // goto emulation
- for (;;) {
- switch (state.mode) {
- case HEAD:
- if (state.wrap === 0) {
- state.mode = TYPEDO;
- break;
- }
- //=== NEEDBITS(16);
- while (bits < 16) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */
- state.check = 0/*crc32(0L, Z_NULL, 0)*/;
- //=== CRC2(state.check, hold);
- hbuf[0] = hold & 0xff;
- hbuf[1] = (hold >>> 8) & 0xff;
- state.check = crc32(state.check, hbuf, 2, 0);
- //===//
-
- //=== INITBITS();
- hold = 0;
- bits = 0;
- //===//
- state.mode = FLAGS;
- break;
- }
- state.flags = 0; /* expect zlib header */
- if (state.head) {
- state.head.done = false;
- }
- if (!(state.wrap & 1) || /* check if zlib header allowed */
- (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {
- strm.msg = 'incorrect header check';
- state.mode = BAD;
- break;
- }
- if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {
- strm.msg = 'unknown compression method';
- state.mode = BAD;
- break;
- }
- //--- DROPBITS(4) ---//
- hold >>>= 4;
- bits -= 4;
- //---//
- len = (hold & 0x0f)/*BITS(4)*/ + 8;
- if (state.wbits === 0) {
- state.wbits = len;
- }
- else if (len > state.wbits) {
- strm.msg = 'invalid window size';
- state.mode = BAD;
- break;
- }
- state.dmax = 1 << len;
- //Tracev((stderr, "inflate: zlib header ok\n"));
- strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
- state.mode = hold & 0x200 ? DICTID : TYPE;
- //=== INITBITS();
- hold = 0;
- bits = 0;
- //===//
- break;
- case FLAGS:
- //=== NEEDBITS(16); */
- while (bits < 16) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- state.flags = hold;
- if ((state.flags & 0xff) !== Z_DEFLATED) {
- strm.msg = 'unknown compression method';
- state.mode = BAD;
- break;
- }
- if (state.flags & 0xe000) {
- strm.msg = 'unknown header flags set';
- state.mode = BAD;
- break;
- }
- if (state.head) {
- state.head.text = ((hold >> 8) & 1);
- }
- if (state.flags & 0x0200) {
- //=== CRC2(state.check, hold);
- hbuf[0] = hold & 0xff;
- hbuf[1] = (hold >>> 8) & 0xff;
- state.check = crc32(state.check, hbuf, 2, 0);
- //===//
- }
- //=== INITBITS();
- hold = 0;
- bits = 0;
- //===//
- state.mode = TIME;
- /* falls through */
- case TIME:
- //=== NEEDBITS(32); */
- while (bits < 32) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- if (state.head) {
- state.head.time = hold;
- }
- if (state.flags & 0x0200) {
- //=== CRC4(state.check, hold)
- hbuf[0] = hold & 0xff;
- hbuf[1] = (hold >>> 8) & 0xff;
- hbuf[2] = (hold >>> 16) & 0xff;
- hbuf[3] = (hold >>> 24) & 0xff;
- state.check = crc32(state.check, hbuf, 4, 0);
- //===
- }
- //=== INITBITS();
- hold = 0;
- bits = 0;
- //===//
- state.mode = OS;
- /* falls through */
- case OS:
- //=== NEEDBITS(16); */
- while (bits < 16) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- if (state.head) {
- state.head.xflags = (hold & 0xff);
- state.head.os = (hold >> 8);
- }
- if (state.flags & 0x0200) {
- //=== CRC2(state.check, hold);
- hbuf[0] = hold & 0xff;
- hbuf[1] = (hold >>> 8) & 0xff;
- state.check = crc32(state.check, hbuf, 2, 0);
- //===//
- }
- //=== INITBITS();
- hold = 0;
- bits = 0;
- //===//
- state.mode = EXLEN;
- /* falls through */
- case EXLEN:
- if (state.flags & 0x0400) {
- //=== NEEDBITS(16); */
- while (bits < 16) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- state.length = hold;
- if (state.head) {
- state.head.extra_len = hold;
- }
- if (state.flags & 0x0200) {
- //=== CRC2(state.check, hold);
- hbuf[0] = hold & 0xff;
- hbuf[1] = (hold >>> 8) & 0xff;
- state.check = crc32(state.check, hbuf, 2, 0);
- //===//
- }
- //=== INITBITS();
- hold = 0;
- bits = 0;
- //===//
- }
- else if (state.head) {
- state.head.extra = null/*Z_NULL*/;
- }
- state.mode = EXTRA;
- /* falls through */
- case EXTRA:
- if (state.flags & 0x0400) {
- copy = state.length;
- if (copy > have) { copy = have; }
- if (copy) {
- if (state.head) {
- len = state.head.extra_len - state.length;
- if (!state.head.extra) {
- // Use untyped array for more conveniend processing later
- state.head.extra = new Array(state.head.extra_len);
- }
- utils.arraySet(
- state.head.extra,
- input,
- next,
- // extra field is limited to 65536 bytes
- // - no need for additional size check
- copy,
- /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
- len
- );
- //zmemcpy(state.head.extra + len, next,
- // len + copy > state.head.extra_max ?
- // state.head.extra_max - len : copy);
- }
- if (state.flags & 0x0200) {
- state.check = crc32(state.check, input, copy, next);
- }
- have -= copy;
- next += copy;
- state.length -= copy;
- }
- if (state.length) { break inf_leave; }
- }
- state.length = 0;
- state.mode = NAME;
- /* falls through */
- case NAME:
- if (state.flags & 0x0800) {
- if (have === 0) { break inf_leave; }
- copy = 0;
- do {
- // TODO: 2 or 1 bytes?
- len = input[next + copy++];
- /* use constant limit because in js we should not preallocate memory */
- if (state.head && len &&
- (state.length < 65536 /*state.head.name_max*/)) {
- state.head.name += String.fromCharCode(len);
- }
- } while (len && copy < have);
-
- if (state.flags & 0x0200) {
- state.check = crc32(state.check, input, copy, next);
- }
- have -= copy;
- next += copy;
- if (len) { break inf_leave; }
- }
- else if (state.head) {
- state.head.name = null;
- }
- state.length = 0;
- state.mode = COMMENT;
- /* falls through */
- case COMMENT:
- if (state.flags & 0x1000) {
- if (have === 0) { break inf_leave; }
- copy = 0;
- do {
- len = input[next + copy++];
- /* use constant limit because in js we should not preallocate memory */
- if (state.head && len &&
- (state.length < 65536 /*state.head.comm_max*/)) {
- state.head.comment += String.fromCharCode(len);
- }
- } while (len && copy < have);
- if (state.flags & 0x0200) {
- state.check = crc32(state.check, input, copy, next);
- }
- have -= copy;
- next += copy;
- if (len) { break inf_leave; }
- }
- else if (state.head) {
- state.head.comment = null;
- }
- state.mode = HCRC;
- /* falls through */
- case HCRC:
- if (state.flags & 0x0200) {
- //=== NEEDBITS(16); */
- while (bits < 16) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- if (hold !== (state.check & 0xffff)) {
- strm.msg = 'header crc mismatch';
- state.mode = BAD;
- break;
- }
- //=== INITBITS();
- hold = 0;
- bits = 0;
- //===//
- }
- if (state.head) {
- state.head.hcrc = ((state.flags >> 9) & 1);
- state.head.done = true;
- }
- strm.adler = state.check = 0;
- state.mode = TYPE;
- break;
- case DICTID:
- //=== NEEDBITS(32); */
- while (bits < 32) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- strm.adler = state.check = zswap32(hold);
- //=== INITBITS();
- hold = 0;
- bits = 0;
- //===//
- state.mode = DICT;
- /* falls through */
- case DICT:
- if (state.havedict === 0) {
- //--- RESTORE() ---
- strm.next_out = put;
- strm.avail_out = left;
- strm.next_in = next;
- strm.avail_in = have;
- state.hold = hold;
- state.bits = bits;
- //---
- return Z_NEED_DICT;
- }
- strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
- state.mode = TYPE;
- /* falls through */
- case TYPE:
- if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }
- /* falls through */
- case TYPEDO:
- if (state.last) {
- //--- BYTEBITS() ---//
- hold >>>= bits & 7;
- bits -= bits & 7;
- //---//
- state.mode = CHECK;
- break;
- }
- //=== NEEDBITS(3); */
- while (bits < 3) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- state.last = (hold & 0x01)/*BITS(1)*/;
- //--- DROPBITS(1) ---//
- hold >>>= 1;
- bits -= 1;
- //---//
-
- switch ((hold & 0x03)/*BITS(2)*/) {
- case 0: /* stored block */
- //Tracev((stderr, "inflate: stored block%s\n",
- // state.last ? " (last)" : ""));
- state.mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- //Tracev((stderr, "inflate: fixed codes block%s\n",
- // state.last ? " (last)" : ""));
- state.mode = LEN_; /* decode codes */
- if (flush === Z_TREES) {
- //--- DROPBITS(2) ---//
- hold >>>= 2;
- bits -= 2;
- //---//
- break inf_leave;
- }
- break;
- case 2: /* dynamic block */
- //Tracev((stderr, "inflate: dynamic codes block%s\n",
- // state.last ? " (last)" : ""));
- state.mode = TABLE;
- break;
- case 3:
- strm.msg = 'invalid block type';
- state.mode = BAD;
- }
- //--- DROPBITS(2) ---//
- hold >>>= 2;
- bits -= 2;
- //---//
- break;
- case STORED:
- //--- BYTEBITS() ---// /* go to byte boundary */
- hold >>>= bits & 7;
- bits -= bits & 7;
- //---//
- //=== NEEDBITS(32); */
- while (bits < 32) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {
- strm.msg = 'invalid stored block lengths';
- state.mode = BAD;
- break;
- }
- state.length = hold & 0xffff;
- //Tracev((stderr, "inflate: stored length %u\n",
- // state.length));
- //=== INITBITS();
- hold = 0;
- bits = 0;
- //===//
- state.mode = COPY_;
- if (flush === Z_TREES) { break inf_leave; }
- /* falls through */
- case COPY_:
- state.mode = COPY;
- /* falls through */
- case COPY:
- copy = state.length;
- if (copy) {
- if (copy > have) { copy = have; }
- if (copy > left) { copy = left; }
- if (copy === 0) { break inf_leave; }
- //--- zmemcpy(put, next, copy); ---
- utils.arraySet(output, input, next, copy, put);
- //---//
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state.length -= copy;
- break;
- }
- //Tracev((stderr, "inflate: stored end\n"));
- state.mode = TYPE;
- break;
- case TABLE:
- //=== NEEDBITS(14); */
- while (bits < 14) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;
- //--- DROPBITS(5) ---//
- hold >>>= 5;
- bits -= 5;
- //---//
- state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;
- //--- DROPBITS(5) ---//
- hold >>>= 5;
- bits -= 5;
- //---//
- state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;
- //--- DROPBITS(4) ---//
- hold >>>= 4;
- bits -= 4;
- //---//
- //#ifndef PKZIP_BUG_WORKAROUND
- if (state.nlen > 286 || state.ndist > 30) {
- strm.msg = 'too many length or distance symbols';
- state.mode = BAD;
- break;
- }
- //#endif
- //Tracev((stderr, "inflate: table sizes ok\n"));
- state.have = 0;
- state.mode = LENLENS;
- /* falls through */
- case LENLENS:
- while (state.have < state.ncode) {
- //=== NEEDBITS(3);
- while (bits < 3) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);
- //--- DROPBITS(3) ---//
- hold >>>= 3;
- bits -= 3;
- //---//
- }
- while (state.have < 19) {
- state.lens[order[state.have++]] = 0;
- }
- // We have separate tables & no pointers. 2 commented lines below not needed.
- //state.next = state.codes;
- //state.lencode = state.next;
- // Switch to use dynamic table
- state.lencode = state.lendyn;
- state.lenbits = 7;
-
- opts = { bits: state.lenbits };
- ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
- state.lenbits = opts.bits;
-
- if (ret) {
- strm.msg = 'invalid code lengths set';
- state.mode = BAD;
- break;
- }
- //Tracev((stderr, "inflate: code lengths ok\n"));
- state.have = 0;
- state.mode = CODELENS;
- /* falls through */
- case CODELENS:
- while (state.have < state.nlen + state.ndist) {
- for (;;) {
- here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/
- here_bits = here >>> 24;
- here_op = (here >>> 16) & 0xff;
- here_val = here & 0xffff;
-
- if ((here_bits) <= bits) { break; }
- //--- PULLBYTE() ---//
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- //---//
- }
- if (here_val < 16) {
- //--- DROPBITS(here.bits) ---//
- hold >>>= here_bits;
- bits -= here_bits;
- //---//
- state.lens[state.have++] = here_val;
- }
- else {
- if (here_val === 16) {
- //=== NEEDBITS(here.bits + 2);
- n = here_bits + 2;
- while (bits < n) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- //--- DROPBITS(here.bits) ---//
- hold >>>= here_bits;
- bits -= here_bits;
- //---//
- if (state.have === 0) {
- strm.msg = 'invalid bit length repeat';
- state.mode = BAD;
- break;
- }
- len = state.lens[state.have - 1];
- copy = 3 + (hold & 0x03);//BITS(2);
- //--- DROPBITS(2) ---//
- hold >>>= 2;
- bits -= 2;
- //---//
- }
- else if (here_val === 17) {
- //=== NEEDBITS(here.bits + 3);
- n = here_bits + 3;
- while (bits < n) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- //--- DROPBITS(here.bits) ---//
- hold >>>= here_bits;
- bits -= here_bits;
- //---//
- len = 0;
- copy = 3 + (hold & 0x07);//BITS(3);
- //--- DROPBITS(3) ---//
- hold >>>= 3;
- bits -= 3;
- //---//
- }
- else {
- //=== NEEDBITS(here.bits + 7);
- n = here_bits + 7;
- while (bits < n) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- //--- DROPBITS(here.bits) ---//
- hold >>>= here_bits;
- bits -= here_bits;
- //---//
- len = 0;
- copy = 11 + (hold & 0x7f);//BITS(7);
- //--- DROPBITS(7) ---//
- hold >>>= 7;
- bits -= 7;
- //---//
- }
- if (state.have + copy > state.nlen + state.ndist) {
- strm.msg = 'invalid bit length repeat';
- state.mode = BAD;
- break;
- }
- while (copy--) {
- state.lens[state.have++] = len;
- }
- }
- }
-
- /* handle error breaks in while */
- if (state.mode === BAD) { break; }
-
- /* check for end-of-block code (better have one) */
- if (state.lens[256] === 0) {
- strm.msg = 'invalid code -- missing end-of-block';
- state.mode = BAD;
- break;
- }
-
- /* build code tables -- note: do not change the lenbits or distbits
- values here (9 and 6) without reading the comments in inftrees.h
- concerning the ENOUGH constants, which depend on those values */
- state.lenbits = 9;
-
- opts = { bits: state.lenbits };
- ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);
- // We have separate tables & no pointers. 2 commented lines below not needed.
- // state.next_index = opts.table_index;
- state.lenbits = opts.bits;
- // state.lencode = state.next;
-
- if (ret) {
- strm.msg = 'invalid literal/lengths set';
- state.mode = BAD;
- break;
- }
-
- state.distbits = 6;
- //state.distcode.copy(state.codes);
- // Switch to use dynamic table
- state.distcode = state.distdyn;
- opts = { bits: state.distbits };
- ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);
- // We have separate tables & no pointers. 2 commented lines below not needed.
- // state.next_index = opts.table_index;
- state.distbits = opts.bits;
- // state.distcode = state.next;
-
- if (ret) {
- strm.msg = 'invalid distances set';
- state.mode = BAD;
- break;
- }
- //Tracev((stderr, 'inflate: codes ok\n'));
- state.mode = LEN_;
- if (flush === Z_TREES) { break inf_leave; }
- /* falls through */
- case LEN_:
- state.mode = LEN;
- /* falls through */
- case LEN:
- if (have >= 6 && left >= 258) {
- //--- RESTORE() ---
- strm.next_out = put;
- strm.avail_out = left;
- strm.next_in = next;
- strm.avail_in = have;
- state.hold = hold;
- state.bits = bits;
- //---
- inflate_fast(strm, _out);
- //--- LOAD() ---
- put = strm.next_out;
- output = strm.output;
- left = strm.avail_out;
- next = strm.next_in;
- input = strm.input;
- have = strm.avail_in;
- hold = state.hold;
- bits = state.bits;
- //---
-
- if (state.mode === TYPE) {
- state.back = -1;
- }
- break;
- }
- state.back = 0;
- for (;;) {
- here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/
- here_bits = here >>> 24;
- here_op = (here >>> 16) & 0xff;
- here_val = here & 0xffff;
-
- if (here_bits <= bits) { break; }
- //--- PULLBYTE() ---//
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- //---//
- }
- if (here_op && (here_op & 0xf0) === 0) {
- last_bits = here_bits;
- last_op = here_op;
- last_val = here_val;
- for (;;) {
- here = state.lencode[last_val +
- ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];
- here_bits = here >>> 24;
- here_op = (here >>> 16) & 0xff;
- here_val = here & 0xffff;
-
- if ((last_bits + here_bits) <= bits) { break; }
- //--- PULLBYTE() ---//
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- //---//
- }
- //--- DROPBITS(last.bits) ---//
- hold >>>= last_bits;
- bits -= last_bits;
- //---//
- state.back += last_bits;
- }
- //--- DROPBITS(here.bits) ---//
- hold >>>= here_bits;
- bits -= here_bits;
- //---//
- state.back += here_bits;
- state.length = here_val;
- if (here_op === 0) {
- //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
- // "inflate: literal '%c'\n" :
- // "inflate: literal 0x%02x\n", here.val));
- state.mode = LIT;
- break;
- }
- if (here_op & 32) {
- //Tracevv((stderr, "inflate: end of block\n"));
- state.back = -1;
- state.mode = TYPE;
- break;
- }
- if (here_op & 64) {
- strm.msg = 'invalid literal/length code';
- state.mode = BAD;
- break;
- }
- state.extra = here_op & 15;
- state.mode = LENEXT;
- /* falls through */
- case LENEXT:
- if (state.extra) {
- //=== NEEDBITS(state.extra);
- n = state.extra;
- while (bits < n) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;
- //--- DROPBITS(state.extra) ---//
- hold >>>= state.extra;
- bits -= state.extra;
- //---//
- state.back += state.extra;
- }
- //Tracevv((stderr, "inflate: length %u\n", state.length));
- state.was = state.length;
- state.mode = DIST;
- /* falls through */
- case DIST:
- for (;;) {
- here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/
- here_bits = here >>> 24;
- here_op = (here >>> 16) & 0xff;
- here_val = here & 0xffff;
-
- if ((here_bits) <= bits) { break; }
- //--- PULLBYTE() ---//
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- //---//
- }
- if ((here_op & 0xf0) === 0) {
- last_bits = here_bits;
- last_op = here_op;
- last_val = here_val;
- for (;;) {
- here = state.distcode[last_val +
- ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];
- here_bits = here >>> 24;
- here_op = (here >>> 16) & 0xff;
- here_val = here & 0xffff;
-
- if ((last_bits + here_bits) <= bits) { break; }
- //--- PULLBYTE() ---//
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- //---//
- }
- //--- DROPBITS(last.bits) ---//
- hold >>>= last_bits;
- bits -= last_bits;
- //---//
- state.back += last_bits;
- }
- //--- DROPBITS(here.bits) ---//
- hold >>>= here_bits;
- bits -= here_bits;
- //---//
- state.back += here_bits;
- if (here_op & 64) {
- strm.msg = 'invalid distance code';
- state.mode = BAD;
- break;
- }
- state.offset = here_val;
- state.extra = (here_op) & 15;
- state.mode = DISTEXT;
- /* falls through */
- case DISTEXT:
- if (state.extra) {
- //=== NEEDBITS(state.extra);
- n = state.extra;
- while (bits < n) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;
- //--- DROPBITS(state.extra) ---//
- hold >>>= state.extra;
- bits -= state.extra;
- //---//
- state.back += state.extra;
- }
- //#ifdef INFLATE_STRICT
- if (state.offset > state.dmax) {
- strm.msg = 'invalid distance too far back';
- state.mode = BAD;
- break;
- }
- //#endif
- //Tracevv((stderr, "inflate: distance %u\n", state.offset));
- state.mode = MATCH;
- /* falls through */
- case MATCH:
- if (left === 0) { break inf_leave; }
- copy = _out - left;
- if (state.offset > copy) { /* copy from window */
- copy = state.offset - copy;
- if (copy > state.whave) {
- if (state.sane) {
- strm.msg = 'invalid distance too far back';
- state.mode = BAD;
- break;
- }
- // (!) This block is disabled in zlib defailts,
- // don't enable it for binary compatibility
- //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
- // Trace((stderr, "inflate.c too far\n"));
- // copy -= state.whave;
- // if (copy > state.length) { copy = state.length; }
- // if (copy > left) { copy = left; }
- // left -= copy;
- // state.length -= copy;
- // do {
- // output[put++] = 0;
- // } while (--copy);
- // if (state.length === 0) { state.mode = LEN; }
- // break;
- //#endif
- }
- if (copy > state.wnext) {
- copy -= state.wnext;
- from = state.wsize - copy;
- }
- else {
- from = state.wnext - copy;
- }
- if (copy > state.length) { copy = state.length; }
- from_source = state.window;
- }
- else { /* copy from output */
- from_source = output;
- from = put - state.offset;
- copy = state.length;
- }
- if (copy > left) { copy = left; }
- left -= copy;
- state.length -= copy;
- do {
- output[put++] = from_source[from++];
- } while (--copy);
- if (state.length === 0) { state.mode = LEN; }
- break;
- case LIT:
- if (left === 0) { break inf_leave; }
- output[put++] = state.length;
- left--;
- state.mode = LEN;
- break;
- case CHECK:
- if (state.wrap) {
- //=== NEEDBITS(32);
- while (bits < 32) {
- if (have === 0) { break inf_leave; }
- have--;
- // Use '|' insdead of '+' to make sure that result is signed
- hold |= input[next++] << bits;
- bits += 8;
- }
- //===//
- _out -= left;
- strm.total_out += _out;
- state.total += _out;
- if (_out) {
- strm.adler = state.check =
- /*UPDATE(state.check, put - _out, _out);*/
- (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));
-
- }
- _out = left;
- // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
- if ((state.flags ? hold : zswap32(hold)) !== state.check) {
- strm.msg = 'incorrect data check';
- state.mode = BAD;
- break;
- }
- //=== INITBITS();
- hold = 0;
- bits = 0;
- //===//
- //Tracev((stderr, "inflate: check matches trailer\n"));
- }
- state.mode = LENGTH;
- /* falls through */
- case LENGTH:
- if (state.wrap && state.flags) {
- //=== NEEDBITS(32);
- while (bits < 32) {
- if (have === 0) { break inf_leave; }
- have--;
- hold += input[next++] << bits;
- bits += 8;
- }
- //===//
- if (hold !== (state.total & 0xffffffff)) {
- strm.msg = 'incorrect length check';
- state.mode = BAD;
- break;
- }
- //=== INITBITS();
- hold = 0;
- bits = 0;
- //===//
- //Tracev((stderr, "inflate: length matches trailer\n"));
- }
- state.mode = DONE;
- /* falls through */
- case DONE:
- ret = Z_STREAM_END;
- break inf_leave;
- case BAD:
- ret = Z_DATA_ERROR;
- break inf_leave;
- case MEM:
- return Z_MEM_ERROR;
- case SYNC:
- /* falls through */
- default:
- return Z_STREAM_ERROR;
- }
- }
-
- // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave"
-
- /*
- Return from inflate(), updating the total counts and the check value.
- If there was no progress during the inflate() call, return a buffer
- error. Call updatewindow() to create and/or update the window state.
- Note: a memory error from inflate() is non-recoverable.
- */
-
- //--- RESTORE() ---
- strm.next_out = put;
- strm.avail_out = left;
- strm.next_in = next;
- strm.avail_in = have;
- state.hold = hold;
- state.bits = bits;
- //---
-
- if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&
- (state.mode < CHECK || flush !== Z_FINISH))) {
- if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {
- state.mode = MEM;
- return Z_MEM_ERROR;
- }
- }
- _in -= strm.avail_in;
- _out -= strm.avail_out;
- strm.total_in += _in;
- strm.total_out += _out;
- state.total += _out;
- if (state.wrap && _out) {
- strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
- (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));
- }
- strm.data_type = state.bits + (state.last ? 64 : 0) +
- (state.mode === TYPE ? 128 : 0) +
- (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
- if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {
- ret = Z_BUF_ERROR;
- }
- return ret;
- }
-
- function inflateEnd(strm) {
-
- if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {
- return Z_STREAM_ERROR;
- }
-
- var state = strm.state;
- if (state.window) {
- state.window = null;
- }
- strm.state = null;
- return Z_OK;
- }
-
- function inflateGetHeader(strm, head) {
- var state;
-
- /* check state */
- if (!strm || !strm.state) { return Z_STREAM_ERROR; }
- state = strm.state;
- if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }
-
- /* save header structure */
- state.head = head;
- head.done = false;
- return Z_OK;
- }
-
- function inflateSetDictionary(strm, dictionary) {
- var dictLength = dictionary.length;
-
- var state;
- var dictid;
- var ret;
-
- /* check state */
- if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }
- state = strm.state;
-
- if (state.wrap !== 0 && state.mode !== DICT) {
- return Z_STREAM_ERROR;
- }
-
- /* check for correct dictionary identifier */
- if (state.mode === DICT) {
- dictid = 1; /* adler32(0, null, 0)*/
- /* dictid = adler32(dictid, dictionary, dictLength); */
- dictid = adler32(dictid, dictionary, dictLength, 0);
- if (dictid !== state.check) {
- return Z_DATA_ERROR;
- }
- }
- /* copy dictionary to window using updatewindow(), which will amend the
- existing dictionary if appropriate */
- ret = updatewindow(strm, dictionary, dictLength, dictLength);
- if (ret) {
- state.mode = MEM;
- return Z_MEM_ERROR;
- }
- state.havedict = 1;
- // Tracev((stderr, "inflate: dictionary set\n"));
- return Z_OK;
- }
-
- exports.inflateReset = inflateReset;
- exports.inflateReset2 = inflateReset2;
- exports.inflateResetKeep = inflateResetKeep;
- exports.inflateInit = inflateInit;
- exports.inflateInit2 = inflateInit2;
- exports.inflate = inflate;
- exports.inflateEnd = inflateEnd;
- exports.inflateGetHeader = inflateGetHeader;
- exports.inflateSetDictionary = inflateSetDictionary;
- exports.inflateInfo = 'pako inflate (from Nodeca project)';
-
- /* Not implemented
- exports.inflateCopy = inflateCopy;
- exports.inflateGetDictionary = inflateGetDictionary;
- exports.inflateMark = inflateMark;
- exports.inflatePrime = inflatePrime;
- exports.inflateSync = inflateSync;
- exports.inflateSyncPoint = inflateSyncPoint;
- exports.inflateUndermine = inflateUndermine;
- */
-
-
-/***/ },
-/* 33 */
-/***/ function(module, exports) {
-
- 'use strict';
-
-
- var TYPED_OK = (typeof Uint8Array !== 'undefined') &&
- (typeof Uint16Array !== 'undefined') &&
- (typeof Int32Array !== 'undefined');
-
-
- exports.assign = function (obj /*from1, from2, from3, ...*/) {
- var sources = Array.prototype.slice.call(arguments, 1);
- while (sources.length) {
- var source = sources.shift();
- if (!source) { continue; }
-
- if (typeof source !== 'object') {
- throw new TypeError(source + 'must be non-object');
- }
-
- for (var p in source) {
- if (source.hasOwnProperty(p)) {
- obj[p] = source[p];
- }
- }
- }
-
- return obj;
- };
-
-
- // reduce buffer size, avoiding mem copy
- exports.shrinkBuf = function (buf, size) {
- if (buf.length === size) { return buf; }
- if (buf.subarray) { return buf.subarray(0, size); }
- buf.length = size;
- return buf;
- };
-
-
- var fnTyped = {
- arraySet: function (dest, src, src_offs, len, dest_offs) {
- if (src.subarray && dest.subarray) {
- dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
- return;
- }
- // Fallback to ordinary array
- for (var i = 0; i < len; i++) {
- dest[dest_offs + i] = src[src_offs + i];
- }
- },
- // Join array of chunks to single array.
- flattenChunks: function (chunks) {
- var i, l, len, pos, chunk, result;
-
- // calculate data length
- len = 0;
- for (i = 0, l = chunks.length; i < l; i++) {
- len += chunks[i].length;
- }
-
- // join chunks
- result = new Uint8Array(len);
- pos = 0;
- for (i = 0, l = chunks.length; i < l; i++) {
- chunk = chunks[i];
- result.set(chunk, pos);
- pos += chunk.length;
- }
-
- return result;
- }
- };
-
- var fnUntyped = {
- arraySet: function (dest, src, src_offs, len, dest_offs) {
- for (var i = 0; i < len; i++) {
- dest[dest_offs + i] = src[src_offs + i];
- }
- },
- // Join array of chunks to single array.
- flattenChunks: function (chunks) {
- return [].concat.apply([], chunks);
- }
- };
-
-
- // Enable/Disable typed arrays use, for testing
- //
- exports.setTyped = function (on) {
- if (on) {
- exports.Buf8 = Uint8Array;
- exports.Buf16 = Uint16Array;
- exports.Buf32 = Int32Array;
- exports.assign(exports, fnTyped);
- } else {
- exports.Buf8 = Array;
- exports.Buf16 = Array;
- exports.Buf32 = Array;
- exports.assign(exports, fnUntyped);
- }
- };
-
- exports.setTyped(TYPED_OK);
-
-
-/***/ },
-/* 34 */
-/***/ function(module, exports) {
-
- 'use strict';
-
- // Note: adler32 takes 12% for level 0 and 2% for level 6.
- // It doesn't worth to make additional optimizationa as in original.
- // Small size is preferable.
-
- function adler32(adler, buf, len, pos) {
- var s1 = (adler & 0xffff) |0,
- s2 = ((adler >>> 16) & 0xffff) |0,
- n = 0;
-
- while (len !== 0) {
- // Set limit ~ twice less than 5552, to keep
- // s2 in 31-bits, because we force signed ints.
- // in other case %= will fail.
- n = len > 2000 ? 2000 : len;
- len -= n;
-
- do {
- s1 = (s1 + buf[pos++]) |0;
- s2 = (s2 + s1) |0;
- } while (--n);
-
- s1 %= 65521;
- s2 %= 65521;
- }
-
- return (s1 | (s2 << 16)) |0;
- }
-
-
- module.exports = adler32;
-
-
-/***/ },
-/* 35 */
-/***/ function(module, exports) {
-
- 'use strict';
-
- // Note: we can't get significant speed boost here.
- // So write code to minimize size - no pregenerated tables
- // and array tools dependencies.
-
-
- // Use ordinary array, since untyped makes no boost here
- function makeTable() {
- var c, table = [];
-
- for (var n = 0; n < 256; n++) {
- c = n;
- for (var k = 0; k < 8; k++) {
- c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
- }
- table[n] = c;
- }
-
- return table;
- }
-
- // Create table on load. Just 255 signed longs. Not a problem.
- var crcTable = makeTable();
-
-
- function crc32(crc, buf, len, pos) {
- var t = crcTable,
- end = pos + len;
-
- crc ^= -1;
-
- for (var i = pos; i < end; i++) {
- crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
- }
-
- return (crc ^ (-1)); // >>> 0;
- }
-
-
- module.exports = crc32;
-
-
-/***/ },
-/* 36 */
-/***/ function(module, exports) {
-
- 'use strict';
-
- // See state defs from inflate.js
- var BAD = 30; /* got a data error -- remain here until reset */
- var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
-
- /*
- Decode literal, length, and distance codes and write out the resulting
- literal and match bytes until either not enough input or output is
- available, an end-of-block is encountered, or a data error is encountered.
- When large enough input and output buffers are supplied to inflate(), for
- example, a 16K input buffer and a 64K output buffer, more than 95% of the
- inflate execution time is spent in this routine.
-
- Entry assumptions:
-
- state.mode === LEN
- strm.avail_in >= 6
- strm.avail_out >= 258
- start >= strm.avail_out
- state.bits < 8
-
- On return, state.mode is one of:
-
- LEN -- ran out of enough output space or enough available input
- TYPE -- reached end of block code, inflate() to interpret next block
- BAD -- error in block data
-
- Notes:
-
- - The maximum input bits used by a length/distance pair is 15 bits for the
- length code, 5 bits for the length extra, 15 bits for the distance code,
- and 13 bits for the distance extra. This totals 48 bits, or six bytes.
- Therefore if strm.avail_in >= 6, then there is enough input to avoid
- checking for available input while decoding.
-
- - The maximum bytes that a single length/distance pair can output is 258
- bytes, which is the maximum length that can be coded. inflate_fast()
- requires strm.avail_out >= 258 for each loop to avoid checking for
- output space.
- */
- module.exports = function inflate_fast(strm, start) {
- var state;
- var _in; /* local strm.input */
- var last; /* have enough input while in < last */
- var _out; /* local strm.output */
- var beg; /* inflate()'s initial strm.output */
- var end; /* while out < end, enough space available */
- //#ifdef INFLATE_STRICT
- var dmax; /* maximum distance from zlib header */
- //#endif
- var wsize; /* window size or zero if not using window */
- var whave; /* valid bytes in the window */
- var wnext; /* window write index */
- // Use `s_window` instead `window`, avoid conflict with instrumentation tools
- var s_window; /* allocated sliding window, if wsize != 0 */
- var hold; /* local strm.hold */
- var bits; /* local strm.bits */
- var lcode; /* local strm.lencode */
- var dcode; /* local strm.distcode */
- var lmask; /* mask for first level of length codes */
- var dmask; /* mask for first level of distance codes */
- var here; /* retrieved table entry */
- var op; /* code bits, operation, extra bits, or */
- /* window position, window bytes to copy */
- var len; /* match length, unused bytes */
- var dist; /* match distance */
- var from; /* where to copy match from */
- var from_source;
-
-
- var input, output; // JS specific, because we have no pointers
-
- /* copy state to local variables */
- state = strm.state;
- //here = state.here;
- _in = strm.next_in;
- input = strm.input;
- last = _in + (strm.avail_in - 5);
- _out = strm.next_out;
- output = strm.output;
- beg = _out - (start - strm.avail_out);
- end = _out + (strm.avail_out - 257);
- //#ifdef INFLATE_STRICT
- dmax = state.dmax;
- //#endif
- wsize = state.wsize;
- whave = state.whave;
- wnext = state.wnext;
- s_window = state.window;
- hold = state.hold;
- bits = state.bits;
- lcode = state.lencode;
- dcode = state.distcode;
- lmask = (1 << state.lenbits) - 1;
- dmask = (1 << state.distbits) - 1;
-
-
- /* decode literals and length/distances until end-of-block or not enough
- input data or output space */
-
- top:
- do {
- if (bits < 15) {
- hold += input[_in++] << bits;
- bits += 8;
- hold += input[_in++] << bits;
- bits += 8;
- }
-
- here = lcode[hold & lmask];
-
- dolen:
- for (;;) { // Goto emulation
- op = here >>> 24/*here.bits*/;
- hold >>>= op;
- bits -= op;
- op = (here >>> 16) & 0xff/*here.op*/;
- if (op === 0) { /* literal */
- //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
- // "inflate: literal '%c'\n" :
- // "inflate: literal 0x%02x\n", here.val));
- output[_out++] = here & 0xffff/*here.val*/;
- }
- else if (op & 16) { /* length base */
- len = here & 0xffff/*here.val*/;
- op &= 15; /* number of extra bits */
- if (op) {
- if (bits < op) {
- hold += input[_in++] << bits;
- bits += 8;
- }
- len += hold & ((1 << op) - 1);
- hold >>>= op;
- bits -= op;
- }
- //Tracevv((stderr, "inflate: length %u\n", len));
- if (bits < 15) {
- hold += input[_in++] << bits;
- bits += 8;
- hold += input[_in++] << bits;
- bits += 8;
- }
- here = dcode[hold & dmask];
-
- dodist:
- for (;;) { // goto emulation
- op = here >>> 24/*here.bits*/;
- hold >>>= op;
- bits -= op;
- op = (here >>> 16) & 0xff/*here.op*/;
-
- if (op & 16) { /* distance base */
- dist = here & 0xffff/*here.val*/;
- op &= 15; /* number of extra bits */
- if (bits < op) {
- hold += input[_in++] << bits;
- bits += 8;
- if (bits < op) {
- hold += input[_in++] << bits;
- bits += 8;
- }
- }
- dist += hold & ((1 << op) - 1);
- //#ifdef INFLATE_STRICT
- if (dist > dmax) {
- strm.msg = 'invalid distance too far back';
- state.mode = BAD;
- break top;
- }
- //#endif
- hold >>>= op;
- bits -= op;
- //Tracevv((stderr, "inflate: distance %u\n", dist));
- op = _out - beg; /* max distance in output */
- if (dist > op) { /* see if copy from window */
- op = dist - op; /* distance back in window */
- if (op > whave) {
- if (state.sane) {
- strm.msg = 'invalid distance too far back';
- state.mode = BAD;
- break top;
- }
-
- // (!) This block is disabled in zlib defailts,
- // don't enable it for binary compatibility
- //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
- // if (len <= op - whave) {
- // do {
- // output[_out++] = 0;
- // } while (--len);
- // continue top;
- // }
- // len -= op - whave;
- // do {
- // output[_out++] = 0;
- // } while (--op > whave);
- // if (op === 0) {
- // from = _out - dist;
- // do {
- // output[_out++] = output[from++];
- // } while (--len);
- // continue top;
- // }
- //#endif
- }
- from = 0; // window index
- from_source = s_window;
- if (wnext === 0) { /* very common case */
- from += wsize - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- output[_out++] = s_window[from++];
- } while (--op);
- from = _out - dist; /* rest from output */
- from_source = output;
- }
- }
- else if (wnext < op) { /* wrap around window */
- from += wsize + wnext - op;
- op -= wnext;
- if (op < len) { /* some from end of window */
- len -= op;
- do {
- output[_out++] = s_window[from++];
- } while (--op);
- from = 0;
- if (wnext < len) { /* some from start of window */
- op = wnext;
- len -= op;
- do {
- output[_out++] = s_window[from++];
- } while (--op);
- from = _out - dist; /* rest from output */
- from_source = output;
- }
- }
- }
- else { /* contiguous in window */
- from += wnext - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- output[_out++] = s_window[from++];
- } while (--op);
- from = _out - dist; /* rest from output */
- from_source = output;
- }
- }
- while (len > 2) {
- output[_out++] = from_source[from++];
- output[_out++] = from_source[from++];
- output[_out++] = from_source[from++];
- len -= 3;
- }
- if (len) {
- output[_out++] = from_source[from++];
- if (len > 1) {
- output[_out++] = from_source[from++];
- }
- }
- }
- else {
- from = _out - dist; /* copy direct from output */
- do { /* minimum length is three */
- output[_out++] = output[from++];
- output[_out++] = output[from++];
- output[_out++] = output[from++];
- len -= 3;
- } while (len > 2);
- if (len) {
- output[_out++] = output[from++];
- if (len > 1) {
- output[_out++] = output[from++];
- }
- }
- }
- }
- else if ((op & 64) === 0) { /* 2nd level distance code */
- here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];
- continue dodist;
- }
- else {
- strm.msg = 'invalid distance code';
- state.mode = BAD;
- break top;
- }
-
- break; // need to emulate goto via "continue"
- }
- }
- else if ((op & 64) === 0) { /* 2nd level length code */
- here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];
- continue dolen;
- }
- else if (op & 32) { /* end-of-block */
- //Tracevv((stderr, "inflate: end of block\n"));
- state.mode = TYPE;
- break top;
- }
- else {
- strm.msg = 'invalid literal/length code';
- state.mode = BAD;
- break top;
- }
-
- break; // need to emulate goto via "continue"
- }
- } while (_in < last && _out < end);
-
- /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
- len = bits >> 3;
- _in -= len;
- bits -= len << 3;
- hold &= (1 << bits) - 1;
-
- /* update state and return */
- strm.next_in = _in;
- strm.next_out = _out;
- strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));
- strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));
- state.hold = hold;
- state.bits = bits;
- return;
- };
-
-
-/***/ },
-/* 37 */
-/***/ function(module, exports, __webpack_require__) {
-
- 'use strict';
-
-
- var utils = __webpack_require__(33);
-
- var MAXBITS = 15;
- var ENOUGH_LENS = 852;
- var ENOUGH_DISTS = 592;
- //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
-
- var CODES = 0;
- var LENS = 1;
- var DISTS = 2;
-
- var lbase = [ /* Length codes 257..285 base */
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
- 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
- ];
-
- var lext = [ /* Length codes 257..285 extra */
- 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78
- ];
-
- var dbase = [ /* Distance codes 0..29 base */
- 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
- 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
- 8193, 12289, 16385, 24577, 0, 0
- ];
-
- var dext = [ /* Distance codes 0..29 extra */
- 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
- 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
- 28, 28, 29, 29, 64, 64
- ];
-
- module.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)
- {
- var bits = opts.bits;
- //here = opts.here; /* table entry for duplication */
-
- var len = 0; /* a code's length in bits */
- var sym = 0; /* index of code symbols */
- var min = 0, max = 0; /* minimum and maximum code lengths */
- var root = 0; /* number of index bits for root table */
- var curr = 0; /* number of index bits for current table */
- var drop = 0; /* code bits to drop for sub-table */
- var left = 0; /* number of prefix codes available */
- var used = 0; /* code entries in table used */
- var huff = 0; /* Huffman code */
- var incr; /* for incrementing code, index */
- var fill; /* index for replicating entries */
- var low; /* low bits for current root entry */
- var mask; /* mask for low root bits */
- var next; /* next available space in table */
- var base = null; /* base value table to use */
- var base_index = 0;
- // var shoextra; /* extra bits table to use */
- var end; /* use base and extra for symbol > end */
- var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */
- var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */
- var extra = null;
- var extra_index = 0;
-
- var here_bits, here_op, here_val;
-
- /*
- Process a set of code lengths to create a canonical Huffman code. The
- code lengths are lens[0..codes-1]. Each length corresponds to the
- symbols 0..codes-1. The Huffman code is generated by first sorting the
- symbols by length from short to long, and retaining the symbol order
- for codes with equal lengths. Then the code starts with all zero bits
- for the first code of the shortest length, and the codes are integer
- increments for the same length, and zeros are appended as the length
- increases. For the deflate format, these bits are stored backwards
- from their more natural integer increment ordering, and so when the
- decoding tables are built in the large loop below, the integer codes
- are incremented backwards.
-
- This routine assumes, but does not check, that all of the entries in
- lens[] are in the range 0..MAXBITS. The caller must assure this.
- 1..MAXBITS is interpreted as that code length. zero means that that
- symbol does not occur in this code.
-
- The codes are sorted by computing a count of codes for each length,
- creating from that a table of starting indices for each length in the
- sorted table, and then entering the symbols in order in the sorted
- table. The sorted table is work[], with that space being provided by
- the caller.
-
- The length counts are used for other purposes as well, i.e. finding
- the minimum and maximum length codes, determining if there are any
- codes at all, checking for a valid set of lengths, and looking ahead
- at length counts to determine sub-table sizes when building the
- decoding tables.
- */
-
- /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
- for (len = 0; len <= MAXBITS; len++) {
- count[len] = 0;
- }
- for (sym = 0; sym < codes; sym++) {
- count[lens[lens_index + sym]]++;
- }
-
- /* bound code lengths, force root to be within code lengths */
- root = bits;
- for (max = MAXBITS; max >= 1; max--) {
- if (count[max] !== 0) { break; }
- }
- if (root > max) {
- root = max;
- }
- if (max === 0) { /* no symbols to code at all */
- //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */
- //table.bits[opts.table_index] = 1; //here.bits = (var char)1;
- //table.val[opts.table_index++] = 0; //here.val = (var short)0;
- table[table_index++] = (1 << 24) | (64 << 16) | 0;
-
-
- //table.op[opts.table_index] = 64;
- //table.bits[opts.table_index] = 1;
- //table.val[opts.table_index++] = 0;
- table[table_index++] = (1 << 24) | (64 << 16) | 0;
-
- opts.bits = 1;
- return 0; /* no symbols, but wait for decoding to report error */
- }
- for (min = 1; min < max; min++) {
- if (count[min] !== 0) { break; }
- }
- if (root < min) {
- root = min;
- }
-
- /* check for an over-subscribed or incomplete set of lengths */
- left = 1;
- for (len = 1; len <= MAXBITS; len++) {
- left <<= 1;
- left -= count[len];
- if (left < 0) {
- return -1;
- } /* over-subscribed */
- }
- if (left > 0 && (type === CODES || max !== 1)) {
- return -1; /* incomplete set */
- }
-
- /* generate offsets into symbol table for each length for sorting */
- offs[1] = 0;
- for (len = 1; len < MAXBITS; len++) {
- offs[len + 1] = offs[len] + count[len];
- }
-
- /* sort symbols by length, by symbol order within each length */
- for (sym = 0; sym < codes; sym++) {
- if (lens[lens_index + sym] !== 0) {
- work[offs[lens[lens_index + sym]]++] = sym;
- }
- }
-
- /*
- Create and fill in decoding tables. In this loop, the table being
- filled is at next and has curr index bits. The code being used is huff
- with length len. That code is converted to an index by dropping drop
- bits off of the bottom. For codes where len is less than drop + curr,
- those top drop + curr - len bits are incremented through all values to
- fill the table with replicated entries.
-
- root is the number of index bits for the root table. When len exceeds
- root, sub-tables are created pointed to by the root entry with an index
- of the low root bits of huff. This is saved in low to check for when a
- new sub-table should be started. drop is zero when the root table is
- being filled, and drop is root when sub-tables are being filled.
-
- When a new sub-table is needed, it is necessary to look ahead in the
- code lengths to determine what size sub-table is needed. The length
- counts are used for this, and so count[] is decremented as codes are
- entered in the tables.
-
- used keeps track of how many table entries have been allocated from the
- provided *table space. It is checked for LENS and DIST tables against
- the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
- the initial root table size constants. See the comments in inftrees.h
- for more information.
-
- sym increments through all symbols, and the loop terminates when
- all codes of length max, i.e. all codes, have been processed. This
- routine permits incomplete codes, so another loop after this one fills
- in the rest of the decoding tables with invalid code markers.
- */
-
- /* set up for code type */
- // poor man optimization - use if-else instead of switch,
- // to avoid deopts in old v8
- if (type === CODES) {
- base = extra = work; /* dummy value--not used */
- end = 19;
-
- } else if (type === LENS) {
- base = lbase;
- base_index -= 257;
- extra = lext;
- extra_index -= 257;
- end = 256;
-
- } else { /* DISTS */
- base = dbase;
- extra = dext;
- end = -1;
- }
-
- /* initialize opts for loop */
- huff = 0; /* starting code */
- sym = 0; /* starting code symbol */
- len = min; /* starting code length */
- next = table_index; /* current table to fill in */
- curr = root; /* current table index bits */
- drop = 0; /* current bits to drop from code for index */
- low = -1; /* trigger new sub-table when len > root */
- used = 1 << root; /* use root table entries */
- mask = used - 1; /* mask for comparing low */
-
- /* check available table space */
- if ((type === LENS && used > ENOUGH_LENS) ||
- (type === DISTS && used > ENOUGH_DISTS)) {
- return 1;
- }
-
- /* process all codes and make table entries */
- for (;;) {
- /* create table entry */
- here_bits = len - drop;
- if (work[sym] < end) {
- here_op = 0;
- here_val = work[sym];
- }
- else if (work[sym] > end) {
- here_op = extra[extra_index + work[sym]];
- here_val = base[base_index + work[sym]];
- }
- else {
- here_op = 32 + 64; /* end of block */
- here_val = 0;
- }
-
- /* replicate for those indices with low len bits equal to huff */
- incr = 1 << (len - drop);
- fill = 1 << curr;
- min = fill; /* save offset to next table */
- do {
- fill -= incr;
- table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;
- } while (fill !== 0);
-
- /* backwards increment the len-bit code huff */
- incr = 1 << (len - 1);
- while (huff & incr) {
- incr >>= 1;
- }
- if (incr !== 0) {
- huff &= incr - 1;
- huff += incr;
- } else {
- huff = 0;
- }
-
- /* go to next symbol, update count, len */
- sym++;
- if (--count[len] === 0) {
- if (len === max) { break; }
- len = lens[lens_index + work[sym]];
- }
-
- /* create new sub-table if needed */
- if (len > root && (huff & mask) !== low) {
- /* if first time, transition to sub-tables */
- if (drop === 0) {
- drop = root;
- }
-
- /* increment past last table */
- next += min; /* here min is 1 << curr */
-
- /* determine length of next table */
- curr = len - drop;
- left = 1 << curr;
- while (curr + drop < max) {
- left -= count[curr + drop];
- if (left <= 0) { break; }
- curr++;
- left <<= 1;
- }
-
- /* check for enough space */
- used += 1 << curr;
- if ((type === LENS && used > ENOUGH_LENS) ||
- (type === DISTS && used > ENOUGH_DISTS)) {
- return 1;
- }
-
- /* point entry in root table to sub-table */
- low = huff & mask;
- /*table.op[low] = curr;
- table.bits[low] = root;
- table.val[low] = next - opts.table_index;*/
- table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;
- }
- }
-
- /* fill in remaining table entry if code is incomplete (guaranteed to have
- at most one remaining entry, since if the code is incomplete, the
- maximum code length that was allowed to get this far is one bit) */
- if (huff !== 0) {
- //table.op[next + huff] = 64; /* invalid code marker */
- //table.bits[next + huff] = len - drop;
- //table.val[next + huff] = 0;
- table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;
- }
-
- /* set return parameters */
- //opts.table_index += used;
- opts.bits = root;
- return 0;
- };
-
-
-/***/ },
-/* 38 */
-/***/ function(module, exports, __webpack_require__) {
-
- // String encode/decode helpers
- 'use strict';
-
-
- var utils = __webpack_require__(33);
-
-
- // Quick check if we can use fast array to bin string conversion
- //
- // - apply(Array) can fail on Android 2.2
- // - apply(Uint8Array) can fail on iOS 5.1 Safary
- //
- var STR_APPLY_OK = true;
- var STR_APPLY_UIA_OK = true;
-
- try { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }
- try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }
-
-
- // Table with utf8 lengths (calculated by first byte of sequence)
- // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
- // because max possible codepoint is 0x10ffff
- var _utf8len = new utils.Buf8(256);
- for (var q = 0; q < 256; q++) {
- _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);
- }
- _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start
-
-
- // convert string to array (typed, when possible)
- exports.string2buf = function (str) {
- var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;
-
- // count binary size
- for (m_pos = 0; m_pos < str_len; m_pos++) {
- c = str.charCodeAt(m_pos);
- if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
- c2 = str.charCodeAt(m_pos + 1);
- if ((c2 & 0xfc00) === 0xdc00) {
- c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
- m_pos++;
- }
- }
- buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
- }
-
- // allocate buffer
- buf = new utils.Buf8(buf_len);
-
- // convert
- for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
- c = str.charCodeAt(m_pos);
- if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
- c2 = str.charCodeAt(m_pos + 1);
- if ((c2 & 0xfc00) === 0xdc00) {
- c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
- m_pos++;
- }
- }
- if (c < 0x80) {
- /* one byte */
- buf[i++] = c;
- } else if (c < 0x800) {
- /* two bytes */
- buf[i++] = 0xC0 | (c >>> 6);
- buf[i++] = 0x80 | (c & 0x3f);
- } else if (c < 0x10000) {
- /* three bytes */
- buf[i++] = 0xE0 | (c >>> 12);
- buf[i++] = 0x80 | (c >>> 6 & 0x3f);
- buf[i++] = 0x80 | (c & 0x3f);
- } else {
- /* four bytes */
- buf[i++] = 0xf0 | (c >>> 18);
- buf[i++] = 0x80 | (c >>> 12 & 0x3f);
- buf[i++] = 0x80 | (c >>> 6 & 0x3f);
- buf[i++] = 0x80 | (c & 0x3f);
- }
- }
-
- return buf;
- };
-
- // Helper (used in 2 places)
- function buf2binstring(buf, len) {
- // use fallback for big arrays to avoid stack overflow
- if (len < 65537) {
- if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {
- return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));
- }
- }
-
- var result = '';
- for (var i = 0; i < len; i++) {
- result += String.fromCharCode(buf[i]);
- }
- return result;
- }
-
-
- // Convert byte array to binary string
- exports.buf2binstring = function (buf) {
- return buf2binstring(buf, buf.length);
- };
-
-
- // Convert binary string (typed, when possible)
- exports.binstring2buf = function (str) {
- var buf = new utils.Buf8(str.length);
- for (var i = 0, len = buf.length; i < len; i++) {
- buf[i] = str.charCodeAt(i);
- }
- return buf;
- };
-
-
- // convert array to string
- exports.buf2string = function (buf, max) {
- var i, out, c, c_len;
- var len = max || buf.length;
-
- // Reserve max possible length (2 words per char)
- // NB: by unknown reasons, Array is significantly faster for
- // String.fromCharCode.apply than Uint16Array.
- var utf16buf = new Array(len * 2);
-
- for (out = 0, i = 0; i < len;) {
- c = buf[i++];
- // quick process ascii
- if (c < 0x80) { utf16buf[out++] = c; continue; }
-
- c_len = _utf8len[c];
- // skip 5 & 6 byte codes
- if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }
-
- // apply mask on first byte
- c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;
- // join the rest
- while (c_len > 1 && i < len) {
- c = (c << 6) | (buf[i++] & 0x3f);
- c_len--;
- }
-
- // terminated by end of string?
- if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }
-
- if (c < 0x10000) {
- utf16buf[out++] = c;
- } else {
- c -= 0x10000;
- utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);
- utf16buf[out++] = 0xdc00 | (c & 0x3ff);
- }
- }
-
- return buf2binstring(utf16buf, out);
- };
-
-
- // Calculate max possible position in utf8 buffer,
- // that will not break sequence. If that's not possible
- // - (very small limits) return max size as is.
- //
- // buf[] - utf8 bytes array
- // max - length limit (mandatory);
- exports.utf8border = function (buf, max) {
- var pos;
-
- max = max || buf.length;
- if (max > buf.length) { max = buf.length; }
-
- // go back from last position, until start of sequence found
- pos = max - 1;
- while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }
-
- // Fuckup - very small and broken sequence,
- // return max, because we should return something anyway.
- if (pos < 0) { return max; }
-
- // If we came to start of buffer - that means vuffer is too small,
- // return max too.
- if (pos === 0) { return max; }
-
- return (pos + _utf8len[buf[pos]] > max) ? pos : max;
- };
-
-
-/***/ },
-/* 39 */
-/***/ function(module, exports) {
-
- 'use strict';
-
-
- module.exports = {
-
- /* Allowed flush values; see deflate() and inflate() below for details */
- 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,
-
- /* Return codes for the compression/decompression functions. Negative values
- * are errors, positive values are used for special but normal events.
- */
- 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_VERSION_ERROR: -6,
-
- /* compression levels */
- 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,
-
- /* Possible values of the data_type field (though see inflate()) */
- Z_BINARY: 0,
- Z_TEXT: 1,
- //Z_ASCII: 1, // = Z_TEXT (deprecated)
- Z_UNKNOWN: 2,
-
- /* The deflate compression method */
- Z_DEFLATED: 8
- //Z_NULL: null // Use -1 or null inline, depending on var type
- };
-
-
-/***/ },
-/* 40 */
-/***/ function(module, exports) {
-
- 'use strict';
-
- module.exports = {
- 2: 'need dictionary', /* Z_NEED_DICT 2 */
- 1: 'stream end', /* Z_STREAM_END 1 */
- 0: '', /* Z_OK 0 */
- '-1': 'file error', /* Z_ERRNO (-1) */
- '-2': 'stream error', /* Z_STREAM_ERROR (-2) */
- '-3': 'data error', /* Z_DATA_ERROR (-3) */
- '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */
- '-5': 'buffer error', /* Z_BUF_ERROR (-5) */
- '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */
- };
-
-
-/***/ },
-/* 41 */
-/***/ function(module, exports) {
-
- 'use strict';
-
-
- function ZStream() {
- /* next input byte */
- this.input = null; // JS specific, because we have no pointers
- this.next_in = 0;
- /* number of bytes available at input */
- this.avail_in = 0;
- /* total number of input bytes read so far */
- this.total_in = 0;
- /* next output byte should be put there */
- this.output = null; // JS specific, because we have no pointers
- this.next_out = 0;
- /* remaining free space at output */
- this.avail_out = 0;
- /* total number of bytes output so far */
- this.total_out = 0;
- /* last error message, NULL if no error */
- this.msg = ''/*Z_NULL*/;
- /* not visible by applications */
- this.state = null;
- /* best guess about the data type: binary or text */
- this.data_type = 2/*Z_UNKNOWN*/;
- /* adler32 value of the uncompressed data */
- this.adler = 0;
- }
-
- module.exports = ZStream;
-
-
-/***/ },
-/* 42 */
-/***/ function(module, exports) {
-
- 'use strict';
-
-
- function GZheader() {
- /* true if compressed data believed to be text */
- this.text = 0;
- /* modification time */
- this.time = 0;
- /* extra flags (not used when writing a gzip file) */
- this.xflags = 0;
- /* operating system */
- this.os = 0;
- /* pointer to extra field or Z_NULL if none */
- this.extra = null;
- /* extra field length (valid if extra != Z_NULL) */
- this.extra_len = 0; // Actually, we don't need it in JS,
- // but leave for few code modifications
-
- //
- // Setup limits is not necessary because in js we should not preallocate memory
- // for inflate use constant limit in 65536 bytes
- //
-
- /* space at extra (only when reading header) */
- // this.extra_max = 0;
- /* pointer to zero-terminated file name or Z_NULL */
- this.name = '';
- /* space at name (only when reading header) */
- // this.name_max = 0;
- /* pointer to zero-terminated comment or Z_NULL */
- this.comment = '';
- /* space at comment (only when reading header) */
- // this.comm_max = 0;
- /* true if there was or will be a header crc */
- this.hcrc = 0;
- /* true when done reading gzip header (not used when writing a gzip file) */
- this.done = false;
- }
-
- module.exports = GZheader;
-
-
-/***/ }
-/******/ ])
-});
-;
-//# sourceMappingURL=browserfs.js.map
-
-/***/ }),
-
-/***/ "./node_modules/browserfs/dist/shims/bufferGlobal.js":
-/*!***********************************************************!*\
- !*** ./node_modules/browserfs/dist/shims/bufferGlobal.js ***!
- \***********************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-/* WEBPACK VAR INJECTION */(function(BrowserFS) {module.exports = BrowserFS.BFSRequire('buffer').Buffer;
-
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! bfsGlobal */ "./node_modules/browserfs/dist/browserfs.js")))
-
-/***/ }),
-
-/***/ "./node_modules/browserfs/dist/shims/fs.js":
-/*!*************************************************!*\
- !*** ./node_modules/browserfs/dist/shims/fs.js ***!
- \*************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-/* WEBPACK VAR INJECTION */(function(BrowserFS) {module.exports = BrowserFS.BFSRequire('fs');
-
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! bfsGlobal */ "./node_modules/browserfs/dist/browserfs.js")))
-
-/***/ }),
-
-/***/ "./node_modules/webpack/buildin/global.js":
-/*!***********************************!*\
- !*** (webpack)/buildin/global.js ***!
- \***********************************/
-/*! no static exports found */
-/***/ (function(module, exports) {
-
-var g;
-
-// This works in non-strict mode
-g = (function() {
- return this;
-})();
-
-try {
- // This works if eval is allowed (see CSP)
- g = g || new Function("return this")();
-} catch (e) {
- // This works if the window reference is available
- if (typeof window === "object") g = window;
-}
-
-// g can still be undefined, but nothing to do about it...
-// We return undefined, instead of nothing here, so it's
-// easier to handle this case. if(!global) { ...}
-
-module.exports = g;
-
-
-/***/ }),
-
-/***/ "./src/fs.ts":
-/*!*******************!*\
- !*** ./src/fs.ts ***!
- \*******************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-/* WEBPACK VAR INJECTION */(function(global, Buffer) {
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- result["default"] = mod;
- return result;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const BrowserFS = __importStar(__webpack_require__(/*! browserfs */ "./node_modules/browserfs/dist/browserfs.js"));
-const util_1 = __webpack_require__(/*! ./util */ "./src/util.ts");
-function init(root = "assembly.zip") {
- return __awaiter(this, void 0, void 0, function* () {
- BrowserFS.install(global || window);
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
- let zipData;
- if (typeof root === "string") {
- let response = yield fetch(root);
- zipData = yield response.arrayBuffer();
- }
- else {
- zipData = root;
- }
- BrowserFS.configure({
- fs: "MountableFileSystem",
- options: {
- "/": {
- fs: "OverlayFS",
- options: {
- readable: {
- fs: "ZipFS",
- options: {
- // Wrap as Buffer object.
- zipData: Buffer.from(zipData)
- }
- },
- writable: {
- fs: "InMemory",
- options: {}
- }
- }
- },
- }
- }, function (e) {
- if (e) {
- // An error occurred.
- reject(e);
- }
- resolve();
- });
- }));
- });
-}
-exports.init = init;
-function attachWorker(worker) {
- BrowserFS.FileSystem.WorkerFS.attachRemoteListener(worker);
-}
-exports.attachWorker = attachWorker;
-function initWorker() {
- return __awaiter(this, void 0, void 0, function* () {
- yield util_1.promisfy(BrowserFS.configure)({ fs: "WorkerFS", options: { worker: self } });
- });
-}
-exports.initWorker = initWorker;
-// import * as _fs from "fs";
-// export * from "fs-extra";
-
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"), __webpack_require__(/*! bufferGlobal */ "./node_modules/browserfs/dist/shims/bufferGlobal.js")))
-
-/***/ }),
-
-/***/ "./src/index.ts":
-/*!**********************!*\
- !*** ./src/index.ts ***!
- \**********************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-///
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- result["default"] = mod;
- return result;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const fs_1 = __webpack_require__(/*! ./fs */ "./src/fs.ts");
-const fs = __importStar(__webpack_require__(/*! fs */ "./node_modules/browserfs/dist/shims/fs.js"));
-const util_1 = __webpack_require__(/*! ./util */ "./src/util.ts");
-window.URL = window.URL || window.webkitURL;
-let worker;
-function main() {
- return __awaiter(this, void 0, void 0, function* () {
- yield fs_1.init("./assembly.zip");
- // (window as any).kernel = new Kernel();
- window.fs = fs;
- console.log(yield util_1.promisfy(fs.readdir)("."));
- // fs.readdirSync(".").map(async(dir)=> console.log(dir + "/" + await promisfy(fs.readdir)(dir)));
- let workerSource = yield util_1.promisfy(fs.readFile)("./worker.js");
- console.log(workerSource.toString());
- worker = new Worker("./worker.js");
- window.worker = worker;
- fs_1.attachWorker(window.worker);
- window.worker.onmessage = console.log;
- worker.postMessage({ path: "/assembly/echo.ts" });
- // worker.onmessage
- // await fs.access.__promisify__("/assembly/bin/echo.ts")
- });
-}
-main();
-
-
-/***/ }),
-
-/***/ "./src/util.ts":
-/*!*********************!*\
- !*** ./src/util.ts ***!
- \*********************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-// type asyncCallback = (...args: any[], fn: (err: any, contents: T) => T) => void;
-function promisfy(fn) {
- return (...args) => new Promise((resolve, reject) => {
- fn(...args, (err, contents) => {
- if (err)
- reject(err);
- resolve(contents);
- });
- });
-}
-exports.promisfy = promisfy;
-
-
-/***/ })
-
-/******/ });
-//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/dist/index.js.map b/dist/index.js.map
deleted file mode 100644
index cd47459..0000000
--- a/dist/index.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/browserfs/dist/browserfs.js","webpack:///./node_modules/browserfs/dist/shims/bufferGlobal.js","webpack:///./node_modules/browserfs/dist/shims/fs.js","webpack:///(webpack)/buildin/global.js","webpack:///./src/fs.ts","webpack:///./src/index.ts","webpack:///./src/util.ts"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;AClFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,oCAAoC;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA,wEAAwE;;AAExE,+CAA+C,cAAc;;AAE7D;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,8BAA8B;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,GAAG;;;AAGH;AACA,oBAAoB,kBAAkB,EAAE;AACxC;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,gCAAgC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,4BAA4B;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,QAAQ;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,cAAc;AAC9B;AACA;AACA;AACA;AACA;AACA,0BAA0B,UAAU;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB;AACA;AACA,0BAA0B,UAAU;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8DAA8D;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mFAAmF,yBAAyB,EAAE;AAC9G,iCAAiC;AACjC,sBAAsB,uBAAuB,uBAAuB,EAAE,wBAAwB,gCAAgC,EAAE;AAChI;AACA;AACA;AACA;AACA;AACA,6BAA6B,mNAAmN;AAChP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,6KAA6K,8BAA8B;AACxO;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qDAAqD,kBAAkB;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC,8BAA8B;AAC9B;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,sBAAsB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,sBAAsB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC,gBAAgB;AAChB;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT,OAAO;AACP,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6DAA6D,yEAAyE;AACtI;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,+JAA+J,wEAAwE;AACvO;AACA;AACA;AACA;AACA;AACA,8CAA8C,cAAc,EAAE;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gEAAgE,cAAc;AAC9E,sEAAsE,aAAa;AACnF,sEAAsE,cAAc;AACpF,sEAAsE,kEAAkE;AACxI;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB,YAAY,EAAE;AACd,YAAY,MAAM;AAClB,cAAc,EAAE;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,EAAE;AAChB;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,OAAO;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;;AAEJ;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,OAAO;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,2BAA2B,QAAQ;AACnC;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB,cAAc,MAAM;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA;AACA,8BAA8B,kBAAkB,EAAE;AAClD;AACA;AACA;AACA;AACA;AACA,+CAA+C,kBAAkB,EAAE;AACnE;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,QAAQ;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,YAAY,OAAO;AACnB,cAAc,QAAQ;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ,EAAE;;AAEF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,YAAY,QAAQ;AACpB,cAAc,MAAM;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB,YAAY,SAAS;AACrB,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,cAAc,MAAM;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,cAAc,MAAM;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,6BAA6B,uBAAuB;AACpD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc,aAAa;AAC3B;AACA,iBAAiB;AACjB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,0BAA0B;AACrD;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,2BAA2B,iDAAiD;AAC5E;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,2BAA2B,gCAAgC;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA,WAAW,gBAAgB;AAC3B;AACA;AACA;;AAEA;AACA;;AAEA;AACA,kBAAkB,8BAA8B;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA,MAAM;AACN;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,sBAAsB;AAClC;AACA,YAAY,KAAK;AACjB;AACA,YAAY,SAAS;AACrB;AACA,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,wBAAwB,6BAA6B;AACrD;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA,YAAY,sBAAsB;AAClC,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;;AAEA;AACA,wBAAwB,6BAA6B;AACrD;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;;AAEA;AACA,8BAA8B,mCAAmC;AACjE;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA,YAAY,sBAAsB;AAClC;AACA,YAAY,KAAK;AACjB;AACA,YAAY,SAAS;AACrB;AACA,cAAc,SAAS;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA,YAAY,MAAM;AAClB,YAAY,SAAS;AACrB,cAAc,MAAM;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB,YAAY,SAAS;AACrB,cAAc,OAAO;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB,cAAc,OAAO;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY,MAAM;AAClB,YAAY,SAAS;AACrB,YAAY,OAAO;AACnB,YAAY,QAAQ;AACpB,cAAc,OAAO;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,QAAQ;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY,MAAM;AAClB,YAAY,EAAE;AACd,YAAY,OAAO;AACnB,cAAc,OAAO;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,MAAM;AAClB,YAAY,EAAE;AACd,YAAY,OAAO;AACnB,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB;AACA;AACA,YAAY,SAAS;AACrB;AACA,iEAAiE;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,4BAA4B,sDAAsD;AAClF,SAAS;AACT,KAAK;AACL;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY,MAAM;AAClB,YAAY,SAAS;AACrB,cAAc,MAAM;AACpB;;AAEA;AACA;AACA;AACA;AACA,YAAY,MAAM;AAClB,YAAY,OAAO;AACnB,YAAY,OAAO;AACnB,cAAc,MAAM;AACpB;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,cAAc,MAAM;AACpB;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,gDAAgD,EAAE;AAClD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;;AAEA;;AAEA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,2BAA2B,gCAAgC;AAC3D;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,EAAE;AACd,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA,MAAM;AACN;;AAEA;AACA;AACA;AACA,cAAc,iCAAiC;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,YAAY,YAAY;AACxB,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA;AACA,+BAA+B,wCAAwC;AACvE,aAAa;AACb,+BAA+B,kDAAkD;AACjF;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU;AACV;AACA;;AAEA;AACA;AACA;AACA,cAAc;AACd,UAAU;AACV;AACA;AACA,UAAU;AACV,MAAM;AACN,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,YAAY;AACxB,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,2BAA2B,gCAAgC;AAC3D;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA,oDAAoD,mCAAmC;AACvF,aAAa,8BAA8B;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,KAAK;AACjB;AACA,cAAc,SAAS;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,MAAM;AACN,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,qBAAqB,sCAAsC;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA,KAAK;AACL;;AAEA;AACA,2BAA2B,gCAAgC;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,2BAA2B,gCAAgC;AAC3D;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA,UAAU;AACV,MAAM;AACN;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;AACA,4BAA4B,YAAY;AACxC,SAAS;AACT;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;;AAEA;AACA,yBAAyB,8BAA8B;AACvD;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA,KAAK;AACL;;AAEA;AACA,0BAA0B,+BAA+B;AACzD;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;;AAEA;AACA,0BAA0B,+BAA+B;AACzD;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,cAAc,SAAS;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA,KAAK;AACL;;AAEA;AACA,2BAA2B,gCAAgC;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB;AACA;AACA,YAAY,SAAS;AACrB;AACA;;AAEA;AACA,2BAA2B,gCAAgC;AAC3D;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA,YAAY,SAAS;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0BAA0B,6BAA6B;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA,8BAA8B,mCAAmC;AACjE;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA,EAAE;AACF;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,cAAc,OAAO;AACrB;AACA,eAAe,SAAS;AACxB;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,SAAS;AACxB;AACA,eAAe,SAAS;AACxB;AACA,eAAe,SAAS;AACxB;AACA,eAAe,OAAO;AACtB;AACA;AACA,eAAe,SAAS;AACxB;AACA;AACA;AACA,eAAe,SAAS;AACxB;AACA,eAAe,SAAS;AACxB;AACA;AACA,eAAe,SAAS;AACxB;AACA;AACA,eAAe,OAAO;AACtB;AACA,eAAe,SAAS;AACxB;AACA,eAAe,SAAS;AACxB;AACA,eAAe,SAAS;AACxB;AACA,eAAe,QAAQ;AACvB;AACA,eAAe,SAAS;AACxB;AACA,eAAe,SAAS;AACxB;AACA,eAAe,SAAS;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB;AACA;AACA,cAAc,+BAA+B;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,YAAY;AACxB;AACA,KAAK;AACL,YAAY,YAAY;AACxB;AACA,KAAK;AACL;AACA;AACA,aAAa,YAAY,EAAE,YAAY,EAAE,YAAY;AACrD;AACA,KAAK;AACL;AACA;AACA,eAAe,YAAY;AAC3B;AACA,KAAK;AACL;;AAEA;AACA,8BAA8B,+BAA+B;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB;AACA;AACA,cAAc,+BAA+B;AAC7C;AACA;AACA;AACA;AACA;;AAEA;AACA,+BAA+B,gCAAgC;AAC/D;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA,KAAK;AACL;;AAEA;AACA,2BAA2B,gCAAgC;AAC3D;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA,YAAY,sBAAsB;AAClC,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB;AACA;AACA,YAAY,SAAS;AACrB;AACA;;AAEA;AACA,2BAA2B,gCAAgC;AAC3D;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA,YAAY,SAAS;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,EAAE;AACd,cAAc,SAAS;AACvB;AACA;AACA,yCAAyC,SAAS;AAClD;AACA;AACA,YAAY,SAAS,GAAG,SAAS;AACjC;AACA;AACA;AACA;;AAEA;AACA,kCAAkC,+BAA+B;AACjE;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA,YAAY,cAAc,UAAU,sBAAsB;AAC1D;AACA,YAAY,SAAS;AACrB,cAAc,UAAU;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA,KAAK;AACL;;AAEA;AACA,yBAAyB,8BAA8B;AACvD;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;;AAEA;AACA,yBAAyB,8BAA8B;AACvD;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA,YAAY,sBAAsB;AAClC,YAAY,SAAS;AACrB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,oCAAoC,6BAA6B;AACjE;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB;AACA,YAAY,SAAS,iBAAiB,6BAA6B;AACnE;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA,KAAK;AACL;;AAEA;AACA,wBAAwB,+BAA+B;AACvD;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA,YAAY,OAAO;AACnB,YAAY,SAAS;AACrB;AACA,YAAY,SAAS,iBAAiB,6BAA6B;AACnE;;AAEA;AACA,uBAAuB,2BAA2B;AAClD;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,YAAY,SAAS;AACrB,cAAc,SAAS;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,MAAM;AAClB;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,0BAA0B;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA,mCAAmC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA,UAAU;AACV;AACA;AACA;AACA,yCAAyC,oBAAoB;AAC7D,UAAU;AACV;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sDAAsD;AACtD,wDAAwD;AACxD;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,mEAAmE,kDAAkD;AACrH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iEAAiE,aAAa;AAC9E,mEAAmE,2BAA2B;AAC9F,yEAAyE,cAAc;AACvF,+EAA+E,aAAa;AAC5F,+EAA+E,aAAa;AAC5F,+EAA+E,aAAa;AAC5F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6DAA6D,gCAAgC,EAAE;AAC/F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,8BAA8B;AAC5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,kDAAkD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,0BAA0B;AAC1B,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA,4DAA4D,gCAAgC;AAC5F,kEAAkE,mCAAmC;AACrG,wEAAwE,sCAAsC;AAC9G,wEAAwE,sCAAsC;AAC9G,wEAAwE,cAAc;;AAEtF;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,yDAAyD,yBAAyB;AAClF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,iCAAiC,EAAE;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gDAAgD;AAChD;;AAEA;AACA,kJAAkJ,qDAAqD;AACvM;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C;AAC9C;AACA,uEAAuE,MAAM,EAAE;AAC/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA,kBAAkB;AAClB,cAAc;AACd;AACA;AACA;AACA,iCAAiC;AACjC,sCAAsC;AACtC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gDAAgD,iBAAiB;AACjE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6CAA6C,gBAAgB;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gEAAgE;AAChE;AACA;;AAEA;AACA,gDAAgD,iBAAiB;AACjE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,mEAAmE,aAAa;;AAEhF,qEAAqE,0BAA0B;AAC/F,2EAA2E,cAAc;AACzF,uFAAuF,cAAc;AACrG,iFAAiF,cAAc;AAC/F,iFAAiF,aAAa;AAC9F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kFAAkF;AAClF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,oEAAoE,aAAa;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sEAAsE,0BAA0B;AAChG,4EAA4E,cAAc;AAC1F,wFAAwF,cAAc;AACtG,kFAAkF,cAAc;AAChG,kFAAkF,cAAc;AAChG;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA,kFAAkF;AAClF;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA,iEAAiE;AACjE;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,kBAAkB;AAClB;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uDAAuD,OAAO,EAAE;AAChE;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C;AAC9C;AACA,sCAAsC;AACtC;AACA,8BAA8B;AAC9B;AACA,sBAAsB;AACtB;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kDAAkD;AAClD;AACA,0CAA0C;AAC1C;AACA,kCAAkC;AAClC;AACA;AACA,sBAAsB;AACtB;AACA;AACA,UAAU;AACV;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,kDAAkD,gCAAgC;AAClF,oDAAoD,iBAAiB;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C,6BAA6B;AAC5E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA,UAAU;AACV,qEAAqE,uBAAuB;AAC5F;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,uCAAuC,iCAAiC,EAAE;;AAElH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;;AAEA;AACA;AACA;AACA,0DAA0D;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,iCAAiC,8CAA8C,EAAE;AACnG,kBAAkB;AAClB;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,OAAO;AACP,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+DAA+D,4BAA4B,EAAE;AAC7F;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,wBAAwB,SAAS;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6DAA6D,gCAAgC,EAAE;AAC/F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wEAAwE,kCAAkC,EAAE;AAC5G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,SAAS;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,qBAAqB;AACrC;AACA,mCAAmC,mBAAmB;AACtD;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mDAAmD,cAAc,EAAE;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA,sEAAsE,cAAc;AACpF,4EAA4E,yEAAyE;AACrJ,4EAA4E,cAAc;AAC1F,4EAA4E,yEAAyE;AACrJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC,8BAA8B;AAC9B,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB,kBAAkB;AAClB,cAAc;AACd,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B,sBAAsB;AACtB;AACA;AACA;AACA;AACA,cAAc;AACd,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kFAAkF,iDAAiD,EAAE;AACrI;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA,kBAAkB;AAClB,cAAc;AACd,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+FAA+F,iDAAiD,EAAE;AAClJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,UAAU;AACV;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,2DAA2D,qEAAqE;AAChI;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,yJAAyJ,iFAAiF;AAC1O;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,wCAAwC;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B;AAC9B;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,2BAA2B,gBAAgB;AACtE;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0DAA0D,gCAAgC;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,sBAAsB;AAClD;AACA;AACA;AACA;AACA,UAAU;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gDAAgD,sBAAsB;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C;AAC9C,0CAA0C;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B;AAC9B,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B;AAC9B;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA,wCAAwC,iBAAiB;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6DAA6D,yBAAyB;AACtF,mEAAmE,cAAc;AACjF,mEAAmE,2BAA2B;AAC9F,mEAAmE,2BAA2B;AAC9F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,wBAAwB,iBAAiB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,iBAAiB;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,0CAA0C,iBAAiB;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,iBAAiB;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kDAAkD,aAAa;AAC/D,gDAAgD,cAAc;AAC9D,oDAAoD,kBAAkB;AACtE,wDAAwD,kBAAkB;AAC1E;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD,kBAAkB;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mEAAmE,gBAAgB;AACnF;AACA;AACA;AACA;AACA;AACA,gEAAgE,iHAAiH;AACjL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,sKAAsK,uDAAuD;AAC7N;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,oBAAoB,YAAY;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,iBAAiB;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uDAAuD,mBAAmB;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,8DAA8D;AAChE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gEAAgE;AAChE,EAAE,8CAA8C;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kEAAkE,kCAAkC;AACpG,kDAAkD,kCAAkC;AACpF,0EAA0E,kCAAkC;AAC5G;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kDAAkD,mCAAmC;AACrF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,mCAAmC;AACzE,wCAAwC,mCAAmC;AAC3E,oEAAoE,mCAAmC;AACvG,wEAAwE,mCAAmC;AAC3G;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0DAA0D,6DAA6D;AACvH,sDAAsD,yCAAyC;AAC/F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sDAAsD,kCAAkC;AACxF,wEAAwE,kCAAkC;AAC1G,4EAA4E,kCAAkC;AAC9G;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gEAAgE,kCAAkC;AAClG,gFAAgF,8CAA8C;AAC9H;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sDAAsD,kCAAkC;AACxF,wEAAwE,4CAA4C;AACpH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wEAAwE,kCAAkC;AAC1G,wEAAwE,kCAAkC;AAC1G,sDAAsD,kCAAkC;AACxF,gFAAgF,mCAAmC;AACnH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wDAAwD,mCAAmC;AAC3F,0EAA0E,mCAAmC;AAC7G,8EAA8E,mCAAmC;AACjH,0EAA0E,mCAAmC;AAC7G,8EAA8E,mCAAmC;AACjH,gFAAgF,mCAAmC;AACnH,4EAA4E,mCAAmC;AAC/G,kFAAkF,mCAAmC;AACrH,kFAAkF,mCAAmC;AACrH,sFAAsF,mCAAmC;AACzH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0DAA0D,4BAA4B;AACtF,4DAA4D,wCAAwC;AACpG,oEAAoE,oCAAoC;AACxG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uEAAuE,kCAAkC;AACzG,2EAA2E,kCAAkC;AAC7G,mFAAmF,kCAAkC;AACrH,qFAAqF,mCAAmC;AACxH,+DAA+D,mCAAmC;AAClG,mEAAmE,mCAAmC;AACtG,uFAAuF,mCAAmC;AAC1H;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4DAA4D;AAC5D;AACA;AACA;AACA;AACA;AACA,uDAAuD;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,uDAAuD,8CAA8C;AACrG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA,kDAAkD,aAAa;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,sKAAsK,+BAA+B;AACrM;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,eAAe;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uEAAuE,8BAA8B;AACrG,EAAE;AACF;AACA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,WAAW;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAiD;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA,4CAA4C;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8DAA8D,6BAA6B,EAAE;AAC7F;AACA;AACA;AACA;AACA,mFAAmF,6BAA6B,EAAE;AAClH;AACA;AACA;AACA;AACA;AACA,oCAAoC,iBAAiB;AACrD;;AAEA;AACA;AACA,mDAAmD,qBAAqB;AACxE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qEAAqE,6BAA6B,EAAE;AACpG;AACA;AACA;AACA;AACA;AACA,sCAAsC,iBAAiB;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,sBAAsB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oEAAoE,6BAA6B,EAAE;AACnG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mFAAmF,6BAA6B,EAAE;AAClH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uDAAuD,2CAA2C;AAClG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C,iBAAiB;AAC5D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gDAAgD,iBAAiB;AACjE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA,iBAAiB;;AAEjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+DAA+D,mBAAmB,EAAE;AACpF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,6BAA6B,oDAAoD,aAAa,EAAE;;AAEhG,OAAO;AACP;AACA;;AAEA;;;AAGA,OAAO;AACP;AACA;;AAEA,+CAA+C;AAC/C;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,sBAAsB,mDAAmD;AACzE;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kBAAkB,YAAY;AAC9B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA,wCAAwC,SAAS;AACjD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,gBAAgB,iBAAiB;AACjC;AACA;AACA;;AAEA;AACA;AACA,cAAc,iBAAiB;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB,SAAS;AAC3B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB,SAAS;AAC3B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB,SAAS;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iDAAiD,EAAE;AACnD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA,kBAAkB,SAAS;AAC3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C;AAC1C;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA;AACA,yBAAyB,eAAe;AACxC;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA,yBAAyB,QAAQ;AACjC;AACA,sBAAsB,eAAe;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,kBAAkB,YAAY;AAC9B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA,UAAU;AACV;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,sBAAsB,SAAS;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,sBAAsB,SAAS;AAC/B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,sBAAsB,SAAS;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,kBAAkB,kBAAkB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB;AACnB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,sBAAsB,QAAQ;AAC9B;AACA;AACA,IAAI;AACJ;AACA,gBAAgB,SAAS;AACzB;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA,oBAAoB,SAAS;AAC7B;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA,gBAAgB,iBAAiB;AACjC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB,YAAY;AAC9B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,kBAAkB,gBAAgB;AAClC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,kBAAkB,gBAAgB;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,kBAAkB,YAAY;AAC9B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,6BAA6B;;AAE7B,OAAO;AACP;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,mCAAmC,SAAS;AAC5C;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA,qBAAqB,OAAO;AAC5B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,sBAAsB,SAAS;AAC/B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,2CAA2C,UAAU;AACrD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,SAAS,WAAW;;AAEpB;AACA;AACA;AACA,SAAS,WAAW;;AAEpB;AACA;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA,SAAS,WAAW;;AAEpB;AACA;AACA,SAAS,UAAU;;AAEnB;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;;;AAGA,OAAO;AACP;AACA;;AAEA,kDAAkD;AAClD;AACA;AACA,oBAAoB,sBAAsB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,4BAA4B,EAAE;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C,iCAAiC,EAAE;AAClF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA,gCAAgC;AAChC,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,uBAAuB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,+BAA+B,mBAAmB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA,EAAE;AACF;;AAEA,6BAA6B;;AAE7B,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA,gBAAgB,SAAS;AACzB;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,IAAI;AACJ,qBAAqB,SAAS;AAC9B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,MAAM;AACN;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA,gDAAgD;AAChD;AACA;AACA,4CAA4C,IAAI;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0EAA0E;AAC1E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,yBAAyB;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,uBAAuB;AAChD;AACA;AACA;AACA;AACA;AACA,wBAAwB,kBAAkB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,uBAAuB;AAChD;AACA;AACA;AACA;AACA;AACA,wBAAwB,kBAAkB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,qBAAqB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,aAAa;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,UAAU;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;;AAEA,6BAA6B;;AAE7B,OAAO;AACP;AACA;;AAEA,+CAA+C;AAC/C;AACA;AACA,oBAAoB,sBAAsB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;;AAEA,6BAA6B;;AAE7B,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;;AAIA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA,gDAAgD;AAChD;AACA,oCAAoC;AACpC,IAAI;AACJ,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,6BAA6B;;AAE7B,OAAO;AACP;AACA;;AAEA,gDAAgD;;AAEhD;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa;AACjB;AACA;AACA,EAAE;AACF;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA,4EAA4E,6EAA6E;AACzJ;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA,uDAAuD;;AAEvD;AACA;AACA;;AAEA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6EAA6E;AAC7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,8DAA8D;AAC9D;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,uCAAuC;;AAEvC;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4DAA4D;AAC5D;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,gDAAgD;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,oBAAoB,SAAS;AAC7B;AACA,MAAM;AACN;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,IAAI;;AAEJ;AACA;AACA;;AAEA;AACA,6EAA6E;;AAE7E;AACA;AACA;AACA;AACA;AACA,IAAI;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,oDAAoD;AACpD;AACA,oDAAoD,iEAAiE;AACrH;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uCAAuC;AACvC;AACA;AACA;AACA;AACA,wCAAwC;AACxC,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC;AACxC,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iCAAiC,OAAO;AACxC;AACA;AACA;;AAEA;AACA,iCAAiC,OAAO;AACxC;AACA;AACA;AACA;AACA,6BAA6B;;AAE7B,OAAO;AACP;AACA;;AAEA,gDAAgD;;AAEhD;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;;AAEA,6BAA6B;;AAE7B,OAAO;AACP;AACA;;AAEA,kBAAkB;;AAElB;AACA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA,+CAA+C;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,6BAA6B,4BAA4B,aAAa,EAAE;;AAExE,OAAO;AACP;AACA;;AAEA,+CAA+C;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA,6BAA6B;;AAE7B,OAAO;AACP;AACA;;AAEA;;AAEA,OAAO;AACP;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB;AAChB,+CAA+C;AAC/C;AACA;AACA;;AAEA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,uDAAuD;AACvD;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA,gBAAgB,iBAAiB;AACjC;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,iCAAiC,OAAO;AACxC;AACA;AACA;;AAEA,OAAO;AACP;AACA;;AAEA,gDAAgD;AAChD;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI,aAAa;AACjB;AACA;AACA,EAAE;AACF;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR,MAAM;AACN,IAAI;AACJ,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,IAAI;AACJ,EAAE;AACF;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,kCAAkC;;AAElC;;AAEA,4CAA4C;AAC5C;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,oDAAoD;AACpD;AACA;;AAEA;AACA;AACA,qCAAqC;;AAErC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA,qDAAqD;AACrD;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,6CAA6C;AAC7C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,6BAA6B;;AAE7B,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB,YAAY,OAAO;AACnB,cAAc,SAAS;AACvB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,YAAY,OAAO;AACnB,cAAc;AACd;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;;AAEA,6BAA6B,4BAA4B,aAAa,EAAE;;AAExE,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAS,OAAO;AAChB;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C,YAAY;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM,EAAE;AACR,IAAI;AACJ;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA,OAAO;AACP;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,OAAO;AACP;AACA;;AAEA;;;AAGA,OAAO;AACP;AACA;;AAEA;;;AAGA,OAAO;AACP;AACA;;AAEA;;;AAGA,OAAO;AACP;AACA;;AAEA;;;AAGA,OAAO;AACP;AACA;;AAEA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,UAAU;AAC9C;AACA;AACA,+BAA+B;AAC/B;AACA,sBAAsB,8BAA8B;AACpD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI,eAAe;;AAEnB;;AAEA;AACA;AACA;AACA;AACA,gCAAgC,sBAAsB;AACtD;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB;AACnB,oBAAoB;AACpB,uBAAuB;AACvB,oBAAoB;;AAEpB;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,oBAAoB,cAAc;AAClC;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA,IAAI;AACJ;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,uDAAuD;;AAEvD;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA,QAAQ;AACR;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,sBAAsB,kEAAkE;;AAExF;;AAEA,UAAU;AACV;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAI;;AAEJ;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,sBAAsB,yCAAyC;;AAE/D;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;;AAGA,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;;;AAGA,iBAAiB;AACjB,kBAAkB;AAClB,iBAAiB;AACjB,eAAe;AACf,kBAAkB;AAClB,kBAAkB;AAClB,iBAAiB;AACjB,oBAAoB;AACpB,iBAAiB;AACjB,oBAAoB;AACpB,kBAAkB;AAClB,sBAAsB;AACtB,wBAAwB;AACxB,wBAAwB;AACxB,uBAAuB;AACvB,sBAAsB;AACtB,uBAAuB;AACvB,yBAAyB;AACzB,0BAA0B;AAC1B,0BAA0B;AAC1B,yBAAyB;AACzB,4BAA4B;AAC5B,0BAA0B;AAC1B,6BAA6B;AAC7B,2BAA2B;AAC3B,yBAAyB;AACzB,mBAAmB;AACnB,oBAAoB;AACpB,kBAAkB;AAClB,iBAAiB;AACjB,iBAAiB;AACjB,kBAAkB;;AAElB;;;;AAIA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA,iBAAiB;AACjB,qBAAqB;AACrB,iBAAiB;AACjB,yBAAyB;AACzB,kBAAkB;AAClB,iBAAiB;AACjB,kBAAkB;AAClB,kBAAkB;AAClB;AACA,oBAAoB;;AAEpB;AACA,kBAAkB;AAClB,kBAAkB;AAClB,kBAAkB;AAClB,kBAAkB;AAClB,sBAAsB;;AAEtB;AACA,iBAAiB;AACjB,iBAAiB;;AAEjB;AACA,mBAAmB;AACnB,mBAAmB;;AAEnB;AACA,kBAAkB;;AAElB;AACA,uBAAuB;AACvB,wBAAwB;AACxB,oBAAoB;AACpB,qBAAqB;;AAErB;AACA,kBAAkB;AAClB,iBAAiB;AACjB,kBAAkB;AAClB,iBAAiB;AACjB,oBAAoB;;AAEpB,oCAAoC;AACpC,oCAAoC;;AAEpC;AACA;AACA;AACA;AACA,0CAA0C;AAC1C,sBAAsB;AACtB,uBAAuB;AACvB,iBAAiB;AACjB,iBAAiB;AACjB,gBAAgB;AAChB;;AAEA;AACA;;AAEA,8BAA8B,uBAAuB;AACrD;AACA;AACA,iBAAiB;AACjB,oBAAoB;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,8BAA8B,uBAAuB;AACrD;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,8BAA8B,uBAAuB;AACrD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,eAAe,uBAAuB;AACtC,uBAAuB;;AAEvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,qBAAqB;;AAErB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,wBAAwB,uBAAuB;AAC/C,wBAAwB,uBAAuB;AAC/C,wBAAwB,uBAAuB;AAC/C,wBAAwB,uBAAuB;;AAE/C,wEAAwE,UAAU;;AAElF;AACA;AACA,uBAAuB,uBAAuB;;AAE9C,wEAAwE,UAAU;;AAElF;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,iBAAiB;AAC1D,uCAAuC,qBAAqB;AAC5D;AACA;AACA;AACA;;AAEA;AACA;AACA,qBAAqB;AACrB,YAAY;AACZ,WAAW;AACX,kBAAkB;AAClB,YAAY;AACZ,YAAY;AACZ,iBAAiB;AACjB,YAAY;AACZ,YAAY;AACZ;AACA,gBAAgB;AAChB,oCAAoC;AACpC,cAAc;AACd,oCAAoC;AACpC,WAAW;AACX,WAAW;AACX,gCAAgC;AAChC;;AAEA,SAAS;;AAET;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA,6BAA6B,qBAAqB,EAAE;;;AAGpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA,iDAAiD;AACjD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,aAAa;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;;AAEV;AACA;AACA;AACA;AACA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B;AAC5B;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,iBAAiB;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,iBAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,aAAa;AACxC,2BAA2B,aAAa;AACxC,0BAA0B,iBAAiB;AAC3C,wCAAwC;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA,yDAAyD;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe;AACf;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB,mEAAmE;AACnE;AACA;AACA;;AAEA,qCAAqC,OAAO;AAC5C;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,iBAAiB;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,iBAAiB;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,iBAAiB;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uCAAuC;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,gCAAgC,OAAO;;AAEvC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,iBAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,iEAAiE;AACjE;AACA;AACA;;AAEA,iCAAiC,OAAO;AACxC;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;;AAEA,iDAAiD,OAAO;AACxD;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,mEAAmE;AACnE;AACA;AACA;;AAEA,mCAAmC,OAAO;AAC1C;AACA,0BAA0B,iBAAiB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;;AAEA,iDAAiD,OAAO;AACxD;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,iBAAiB;AACzC;AACA,iCAAiC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uCAAuC,qBAAqB;AAC5D,+BAA+B,aAAa;AAC5C;AACA;AACA;AACA;AACA,cAAc;AACd,sCAAsC,kBAAkB;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,qBAAqB;AACxD;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,yBAAyB,aAAa;AACtC;AACA;AACA;AACA;AACA,QAAQ;AACR,gCAAgC,kBAAkB;AAClD;AACA;AACA,wBAAwB,iBAAiB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uDAAuD;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,iBAAiB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kFAAkF;AAClF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,8BAA8B,uBAAuB;AACrD;AACA,gCAAgC,uBAAuB;;AAEvD;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,8DAA8D,uBAAuB;AACrF;;AAEA;AACA;AACA;;AAEA;AACA;AACA,gBAAgB;AAChB,yDAAyD;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;;;AAGA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA,mBAAmB,UAAU;;AAE7B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA,6BAA6B,YAAY;AACzC,sBAAsB,8BAA8B;AACpD;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,SAAS;AAC7B;AACA;AACA,IAAI;AACJ;AACA;AACA;;AAEA;AACA;AACA,mCAAmC,OAAO;AAC1C;AACA;;AAEA;AACA;AACA;AACA,mCAAmC,OAAO;AAC1C;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,oBAAoB,SAAS;AAC7B;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;;AAEA;;;AAGA,OAAO;AACP;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAM;;AAEN;AACA;AACA;;AAEA;AACA;;;AAGA;;;AAGA,OAAO;AACP;AACA;;AAEA;;AAEA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA,kBAAkB,SAAS;AAC3B;AACA,oBAAoB,OAAO;AAC3B;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;;AAEA;;AAEA,oBAAoB,SAAS;AAC7B;AACA;;AAEA,uBAAuB;AACvB;;;AAGA;;;AAGA,OAAO;AACP;AACA;;AAEA;;AAEA;AACA,cAAc;AACd,eAAe;;AAEf;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,YAAY;AACZ,YAAY;AACZ,WAAW;AACX,WAAW;AACX;AACA,YAAY;AACZ;AACA,aAAa;AACb,aAAa;AACb,aAAa;AACb;AACA,gBAAgB;AAChB,YAAY;AACZ,YAAY;AACZ,aAAa;AACb,aAAa;AACb,aAAa;AACb,aAAa;AACb,YAAY;AACZ,UAAU;AACV;AACA,WAAW;AACX,YAAY;AACZ,YAAY;AACZ;;;AAGA,qBAAqB;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,YAAY,GAAG;AACf;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,GAAG;AACnB;AACA;AACA;AACA;;AAEA,yBAAyB;AACzB;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B,6BAA6B;AAC7B,8BAA8B;AAC9B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA,oBAAoB;AACpB;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA,iCAAiC;AACjC;AACA,gCAAgC;AAChC;AACA;AACA;AACA,oBAAoB;AACpB,sCAAsC;AACtC;AACA;AACA;AACA,qCAAqC;AACrC;AACA;AACA,gCAAgC;AAChC;AACA;AACA;AACA,oBAAoB;AACpB;AACA,qCAAqC;AACrC;AACA;AACA;AACA;AACA,sBAAsB;AACtB,wCAAwC;AACxC;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA,gCAAgC;AAChC;AACA;AACA;AACA,oBAAoB;AACpB,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC;AAClC,mBAAmB;AACnB;AACA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iBAAiB;AACjB;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,aAAa;AACb;AACA,IAAI;;AAEJ;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;;;AAGA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,0BAA0B;;AAE1B,eAAe;AACf,eAAe;AACf,wBAAwB;AACxB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,YAAY;AACZ,YAAY;AACZ,WAAW;AACX,YAAY;AACZ,YAAY;AACZ,mBAAmB;AACnB;AACA,kBAAkB;AAClB,WAAW;AACX,4CAA4C,eAAe;AAC3D,2CAA2C,eAAe;AAC1D;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,gBAAgB,gBAAgB;AAChC;AACA;AACA,gBAAgB,aAAa;AAC7B;AACA;;AAEA;AACA;AACA,sBAAsB,UAAU;AAChC,4BAA4B,OAAO;AACnC;AACA;AACA;AACA;AACA,mBAAmB;AACnB,uCAAuC,2BAA2B;AAClE,wCAAwC;AACxC,yCAAyC;AACzC;;;AAGA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA,gBAAgB,WAAW;AAC3B,4BAA4B,OAAO;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA,gBAAgB,gBAAgB;AAChC;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,eAAe;AACf;;AAEA;AACA;AACA,gBAAgB,eAAe;AAC/B;AACA;;AAEA;AACA,gBAAgB,aAAa;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;;AAEA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA,IAAI,OAAO;AACX;AACA;AACA;AACA;;AAEA;AACA,YAAY;AACZ,WAAW;AACX,aAAa;AACb,sBAAsB;AACtB,eAAe;AACf,YAAY;AACZ,YAAY;AACZ,oBAAoB;AACpB,mBAAmB;;AAEnB;AACA;AACA;AACA;AACA;;AAEA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;;AAEA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA,MAAM;;AAEN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;;AAEA;AACA;AACA;AACA,yBAAyB,OAAO;AAChC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,mBAAmB;;AAEnB;AACA;AACA;AACA;AACA;AACA,yBAAyB,OAAO;AAChC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,gDAAgD;AAChD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kCAAkC;AAClC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;AACA;;;AAGA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAM,wCAAwC,EAAE,aAAa,sBAAsB;AACnF,MAAM,oDAAoD,EAAE,aAAa,0BAA0B;;;AAGnG;AACA;AACA;AACA;AACA,gBAAgB,SAAS;AACzB;AACA;AACA,mCAAmC;;;AAGnC;AACA;AACA;;AAEA;AACA,kBAAkB,iBAAiB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,yBAAyB,aAAa;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kBAAkB,SAAS;AAC3B;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA,oCAAoC,SAAS;AAC7C;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,uBAAuB,SAAS;AAChC;AACA;AACA,oBAAoB,qBAAqB,UAAU;;AAEnD;AACA;AACA,qBAAqB,0BAA0B,gBAAgB,UAAU;;AAEzE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,qBAAqB,0BAA0B,UAAU;;AAEzD;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,0BAA0B,kBAAkB;;AAE5C;AACA;AACA,mDAAmD,OAAO;;AAE1D;AACA;AACA,iBAAiB,YAAY;;AAE7B;AACA;AACA,mBAAmB,YAAY;;AAE/B;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;;;AAGA;;AAEA,2BAA2B;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA,OAAO;AACP;AACA;;AAEA;;;AAGA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;AAGA,OAAO;AACP;AACA;;AAEA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;AAGA;AACA;AACA,CAAC;AACD;AACA,qC;;;;;;;;;;;ACnrwBA;;;;;;;;;;;;;ACAA;;;;;;;;;;;;;ACAA;;AAEA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;;AAEA;AACA;AACA,4CAA4C;;AAE5C;;;;;;;;;;;;;ACnBA,sDAAa;AACb;AACA;AACA,mCAAmC,MAAM,6BAA6B,EAAE,YAAY,WAAW,EAAE;AACjG,kCAAkC,MAAM,iCAAiC,EAAE,YAAY,WAAW,EAAE;AACpG,+BAA+B,iEAAiE,uBAAuB,EAAE,4BAA4B;AACrJ;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,cAAc;AAC5D,+BAA+B,mBAAO,CAAC,6DAAW;AAClD,eAAe,mBAAO,CAAC,6BAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,2BAA2B,eAAe,EAAE;AAChG,KAAK;AACL;AACA;AACA;AACA;;;;;;;;;;;;;;ACzEa;AACb;AACA;AACA;AACA,mCAAmC,MAAM,6BAA6B,EAAE,YAAY,WAAW,EAAE;AACjG,kCAAkC,MAAM,iCAAiC,EAAE,YAAY,WAAW,EAAE;AACpG,+BAA+B,iEAAiE,uBAAuB,EAAE,4BAA4B;AACrJ;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,cAAc;AAC5D,aAAa,mBAAO,CAAC,yBAAM;AAC3B,wBAAwB,mBAAO,CAAC,qDAAI;AACpC,eAAe,mBAAO,CAAC,6BAAQ;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,4BAA4B;AACxD;AACA;AACA,KAAK;AACL;AACA;;;;;;;;;;;;;ACzCa;AACb,8CAA8C,cAAc;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA","file":"index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.ts\");\n","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"BrowserFS\"] = factory();\n\telse\n\t\troot[\"BrowserFS\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(Buffer, global, module, process) {'use strict';\n\t\n\tObject.defineProperty(exports, '__esModule', { value: true });\n\t\n\tvar buffer = __webpack_require__(2);\n\tvar path = __webpack_require__(9);\n\t\n\t/**\n\t * Standard libc error codes. Add more to this enum and ErrorStrings as they are\n\t * needed.\n\t * @url http://www.gnu.org/software/libc/manual/html_node/Error-Codes.html\n\t */\n\t/**\n\t * Standard libc error codes. Add more to this enum and ErrorStrings as they are\n\t * needed.\n\t * @url http://www.gnu.org/software/libc/manual/html_node/Error-Codes.html\n\t */ var ErrorCode;\n\t(function (ErrorCode) {\n\t ErrorCode[ErrorCode[\"EPERM\"] = 1] = \"EPERM\";\n\t ErrorCode[ErrorCode[\"ENOENT\"] = 2] = \"ENOENT\";\n\t ErrorCode[ErrorCode[\"EIO\"] = 5] = \"EIO\";\n\t ErrorCode[ErrorCode[\"EBADF\"] = 9] = \"EBADF\";\n\t ErrorCode[ErrorCode[\"EACCES\"] = 13] = \"EACCES\";\n\t ErrorCode[ErrorCode[\"EBUSY\"] = 16] = \"EBUSY\";\n\t ErrorCode[ErrorCode[\"EEXIST\"] = 17] = \"EEXIST\";\n\t ErrorCode[ErrorCode[\"ENOTDIR\"] = 20] = \"ENOTDIR\";\n\t ErrorCode[ErrorCode[\"EISDIR\"] = 21] = \"EISDIR\";\n\t ErrorCode[ErrorCode[\"EINVAL\"] = 22] = \"EINVAL\";\n\t ErrorCode[ErrorCode[\"EFBIG\"] = 27] = \"EFBIG\";\n\t ErrorCode[ErrorCode[\"ENOSPC\"] = 28] = \"ENOSPC\";\n\t ErrorCode[ErrorCode[\"EROFS\"] = 30] = \"EROFS\";\n\t ErrorCode[ErrorCode[\"ENOTEMPTY\"] = 39] = \"ENOTEMPTY\";\n\t ErrorCode[ErrorCode[\"ENOTSUP\"] = 95] = \"ENOTSUP\";\n\t})(ErrorCode || (ErrorCode = {}));\n\t/* tslint:disable:variable-name */\n\t/**\n\t * Strings associated with each error code.\n\t * @hidden\n\t */\n\tvar ErrorStrings = {};\n\tErrorStrings[ErrorCode.EPERM] = 'Operation not permitted.';\n\tErrorStrings[ErrorCode.ENOENT] = 'No such file or directory.';\n\tErrorStrings[ErrorCode.EIO] = 'Input/output error.';\n\tErrorStrings[ErrorCode.EBADF] = 'Bad file descriptor.';\n\tErrorStrings[ErrorCode.EACCES] = 'Permission denied.';\n\tErrorStrings[ErrorCode.EBUSY] = 'Resource busy or locked.';\n\tErrorStrings[ErrorCode.EEXIST] = 'File exists.';\n\tErrorStrings[ErrorCode.ENOTDIR] = 'File is not a directory.';\n\tErrorStrings[ErrorCode.EISDIR] = 'File is a directory.';\n\tErrorStrings[ErrorCode.EINVAL] = 'Invalid argument.';\n\tErrorStrings[ErrorCode.EFBIG] = 'File is too big.';\n\tErrorStrings[ErrorCode.ENOSPC] = 'No space left on disk.';\n\tErrorStrings[ErrorCode.EROFS] = 'Cannot modify a read-only file system.';\n\tErrorStrings[ErrorCode.ENOTEMPTY] = 'Directory is not empty.';\n\tErrorStrings[ErrorCode.ENOTSUP] = 'Operation is not supported.';\n\t/* tslint:enable:variable-name */\n\t/**\n\t * Represents a BrowserFS error. Passed back to applications after a failed\n\t * call to the BrowserFS API.\n\t */\n\tvar ApiError = (function (Error) {\n\t function ApiError(type, message, path$$1) {\n\t if ( message === void 0 ) message = ErrorStrings[type];\n\t\n\t Error.call(this, message);\n\t // Unsupported.\n\t this.syscall = \"\";\n\t this.errno = type;\n\t this.code = ErrorCode[type];\n\t this.path = path$$1;\n\t this.stack = new Error().stack;\n\t this.message = \"Error: \" + (this.code) + \": \" + message + (this.path ? (\", '\" + (this.path) + \"'\") : '');\n\t }\n\t\n\t if ( Error ) ApiError.__proto__ = Error;\n\t ApiError.prototype = Object.create( Error && Error.prototype );\n\t ApiError.prototype.constructor = ApiError;\n\t ApiError.fromJSON = function fromJSON (json) {\n\t var err = new ApiError(0);\n\t err.errno = json.errno;\n\t err.code = json.code;\n\t err.path = json.path;\n\t err.stack = json.stack;\n\t err.message = json.message;\n\t return err;\n\t };\n\t /**\n\t * Creates an ApiError object from a buffer.\n\t */\n\t ApiError.fromBuffer = function fromBuffer (buffer$$1, i) {\n\t if ( i === void 0 ) i = 0;\n\t\n\t return ApiError.fromJSON(JSON.parse(buffer$$1.toString('utf8', i + 4, i + 4 + buffer$$1.readUInt32LE(i))));\n\t };\n\t ApiError.FileError = function FileError (code, p) {\n\t return new ApiError(code, ErrorStrings[code], p);\n\t };\n\t ApiError.ENOENT = function ENOENT (path$$1) {\n\t return this.FileError(ErrorCode.ENOENT, path$$1);\n\t };\n\t ApiError.EEXIST = function EEXIST (path$$1) {\n\t return this.FileError(ErrorCode.EEXIST, path$$1);\n\t };\n\t ApiError.EISDIR = function EISDIR (path$$1) {\n\t return this.FileError(ErrorCode.EISDIR, path$$1);\n\t };\n\t ApiError.ENOTDIR = function ENOTDIR (path$$1) {\n\t return this.FileError(ErrorCode.ENOTDIR, path$$1);\n\t };\n\t ApiError.EPERM = function EPERM (path$$1) {\n\t return this.FileError(ErrorCode.EPERM, path$$1);\n\t };\n\t ApiError.ENOTEMPTY = function ENOTEMPTY (path$$1) {\n\t return this.FileError(ErrorCode.ENOTEMPTY, path$$1);\n\t };\n\t /**\n\t * @return A friendly error message.\n\t */\n\t ApiError.prototype.toString = function toString () {\n\t return this.message;\n\t };\n\t ApiError.prototype.toJSON = function toJSON () {\n\t return {\n\t errno: this.errno,\n\t code: this.code,\n\t path: this.path,\n\t stack: this.stack,\n\t message: this.message\n\t };\n\t };\n\t /**\n\t * Writes the API error into a buffer.\n\t */\n\t ApiError.prototype.writeToBuffer = function writeToBuffer (buffer$$1, i) {\n\t if ( buffer$$1 === void 0 ) buffer$$1 = Buffer.alloc(this.bufferSize());\n\t if ( i === void 0 ) i = 0;\n\t\n\t var bytesWritten = buffer$$1.write(JSON.stringify(this.toJSON()), i + 4);\n\t buffer$$1.writeUInt32LE(bytesWritten, i);\n\t return buffer$$1;\n\t };\n\t /**\n\t * The size of the API error in buffer-form in bytes.\n\t */\n\t ApiError.prototype.bufferSize = function bufferSize () {\n\t // 4 bytes for string length.\n\t return 4 + Buffer.byteLength(JSON.stringify(this.toJSON()));\n\t };\n\t\n\t return ApiError;\n\t }(Error));\n\t\n\t\n\tvar api_error = Object.freeze({\n\t\tget ErrorCode () { return ErrorCode; },\n\t\tErrorStrings: ErrorStrings,\n\t\tApiError: ApiError\n\t});\n\t\n\tvar ActionType;\n\t(function (ActionType) {\n\t // Indicates that the code should not do anything.\n\t ActionType[ActionType[\"NOP\"] = 0] = \"NOP\";\n\t // Indicates that the code should throw an exception.\n\t ActionType[ActionType[\"THROW_EXCEPTION\"] = 1] = \"THROW_EXCEPTION\";\n\t // Indicates that the code should truncate the file, but only if it is a file.\n\t ActionType[ActionType[\"TRUNCATE_FILE\"] = 2] = \"TRUNCATE_FILE\";\n\t // Indicates that the code should create the file.\n\t ActionType[ActionType[\"CREATE_FILE\"] = 3] = \"CREATE_FILE\";\n\t})(ActionType || (ActionType = {}));\n\t/**\n\t * Represents one of the following file flags. A convenience object.\n\t *\n\t * * `'r'` - Open file for reading. An exception occurs if the file does not exist.\n\t * * `'r+'` - Open file for reading and writing. An exception occurs if the file does not exist.\n\t * * `'rs'` - Open file for reading in synchronous mode. Instructs the filesystem to not cache writes.\n\t * * `'rs+'` - Open file for reading and writing, and opens the file in synchronous mode.\n\t * * `'w'` - Open file for writing. The file is created (if it does not exist) or truncated (if it exists).\n\t * * `'wx'` - Like 'w' but opens the file in exclusive mode.\n\t * * `'w+'` - Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists).\n\t * * `'wx+'` - Like 'w+' but opens the file in exclusive mode.\n\t * * `'a'` - Open file for appending. The file is created if it does not exist.\n\t * * `'ax'` - Like 'a' but opens the file in exclusive mode.\n\t * * `'a+'` - Open file for reading and appending. The file is created if it does not exist.\n\t * * `'ax+'` - Like 'a+' but opens the file in exclusive mode.\n\t *\n\t * Exclusive mode ensures that the file path is newly created.\n\t */\n\tvar FileFlag = function FileFlag(flagStr) {\n\t this.flagStr = flagStr;\n\t if (FileFlag.validFlagStrs.indexOf(flagStr) < 0) {\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid flag: \" + flagStr);\n\t }\n\t};\n\t/**\n\t * Get an object representing the given file flag.\n\t * @param modeStr The string representing the flag\n\t * @return The FileFlag object representing the flag\n\t * @throw when the flag string is invalid\n\t */\n\tFileFlag.getFileFlag = function getFileFlag (flagStr) {\n\t // Check cache first.\n\t if (FileFlag.flagCache.hasOwnProperty(flagStr)) {\n\t return FileFlag.flagCache[flagStr];\n\t }\n\t return FileFlag.flagCache[flagStr] = new FileFlag(flagStr);\n\t};\n\t/**\n\t * Get the underlying flag string for this flag.\n\t */\n\tFileFlag.prototype.getFlagString = function getFlagString () {\n\t return this.flagStr;\n\t};\n\t/**\n\t * Returns true if the file is readable.\n\t */\n\tFileFlag.prototype.isReadable = function isReadable () {\n\t return this.flagStr.indexOf('r') !== -1 || this.flagStr.indexOf('+') !== -1;\n\t};\n\t/**\n\t * Returns true if the file is writeable.\n\t */\n\tFileFlag.prototype.isWriteable = function isWriteable () {\n\t return this.flagStr.indexOf('w') !== -1 || this.flagStr.indexOf('a') !== -1 || this.flagStr.indexOf('+') !== -1;\n\t};\n\t/**\n\t * Returns true if the file mode should truncate.\n\t */\n\tFileFlag.prototype.isTruncating = function isTruncating () {\n\t return this.flagStr.indexOf('w') !== -1;\n\t};\n\t/**\n\t * Returns true if the file is appendable.\n\t */\n\tFileFlag.prototype.isAppendable = function isAppendable () {\n\t return this.flagStr.indexOf('a') !== -1;\n\t};\n\t/**\n\t * Returns true if the file is open in synchronous mode.\n\t */\n\tFileFlag.prototype.isSynchronous = function isSynchronous () {\n\t return this.flagStr.indexOf('s') !== -1;\n\t};\n\t/**\n\t * Returns true if the file is open in exclusive mode.\n\t */\n\tFileFlag.prototype.isExclusive = function isExclusive () {\n\t return this.flagStr.indexOf('x') !== -1;\n\t};\n\t/**\n\t * Returns one of the static fields on this object that indicates the\n\t * appropriate response to the path existing.\n\t */\n\tFileFlag.prototype.pathExistsAction = function pathExistsAction () {\n\t if (this.isExclusive()) {\n\t return ActionType.THROW_EXCEPTION;\n\t }\n\t else if (this.isTruncating()) {\n\t return ActionType.TRUNCATE_FILE;\n\t }\n\t else {\n\t return ActionType.NOP;\n\t }\n\t};\n\t/**\n\t * Returns one of the static fields on this object that indicates the\n\t * appropriate response to the path not existing.\n\t */\n\tFileFlag.prototype.pathNotExistsAction = function pathNotExistsAction () {\n\t if ((this.isWriteable() || this.isAppendable()) && this.flagStr !== 'r+') {\n\t return ActionType.CREATE_FILE;\n\t }\n\t else {\n\t return ActionType.THROW_EXCEPTION;\n\t }\n\t};\n\t// Contains cached FileMode instances.\n\tFileFlag.flagCache = {};\n\t// Array of valid mode strings.\n\tFileFlag.validFlagStrs = ['r', 'r+', 'rs', 'rs+', 'w', 'wx', 'w+', 'wx+', 'a', 'ax', 'a+', 'ax+'];\n\t\n\t/**\n\t * Indicates the type of the given file. Applied to 'mode'.\n\t */\n\tvar FileType;\n\t(function (FileType) {\n\t FileType[FileType[\"FILE\"] = 32768] = \"FILE\";\n\t FileType[FileType[\"DIRECTORY\"] = 16384] = \"DIRECTORY\";\n\t FileType[FileType[\"SYMLINK\"] = 40960] = \"SYMLINK\";\n\t})(FileType || (FileType = {}));\n\t/**\n\t * Emulation of Node's `fs.Stats` object.\n\t *\n\t * Attribute descriptions are from `man 2 stat'\n\t * @see http://nodejs.org/api/fs.html#fs_class_fs_stats\n\t * @see http://man7.org/linux/man-pages/man2/stat.2.html\n\t */\n\tvar Stats = function Stats(itemType, size, mode, atime, mtime, ctime) {\n\t if ( atime === void 0 ) atime = new Date();\n\t if ( mtime === void 0 ) mtime = new Date();\n\t if ( ctime === void 0 ) ctime = new Date();\n\t\n\t this.size = size;\n\t this.atime = atime;\n\t this.mtime = mtime;\n\t this.ctime = ctime;\n\t /**\n\t * UNSUPPORTED ATTRIBUTES\n\t * I assume no one is going to need these details, although we could fake\n\t * appropriate values if need be.\n\t */\n\t // ID of device containing file\n\t this.dev = 0;\n\t // inode number\n\t this.ino = 0;\n\t // device ID (if special file)\n\t this.rdev = 0;\n\t // number of hard links\n\t this.nlink = 1;\n\t // blocksize for file system I/O\n\t this.blksize = 4096;\n\t // @todo Maybe support these? atm, it's a one-user filesystem.\n\t // user ID of owner\n\t this.uid = 0;\n\t // group ID of owner\n\t this.gid = 0;\n\t // time file was created (currently unsupported)\n\t this.birthtime = new Date(0);\n\t // XXX: Some file systems stash data on stats objects.\n\t this.fileData = null;\n\t if (!mode) {\n\t switch (itemType) {\n\t case FileType.FILE:\n\t this.mode = 0x1a4;\n\t break;\n\t case FileType.DIRECTORY:\n\t default:\n\t this.mode = 0x1ff;\n\t }\n\t }\n\t else {\n\t this.mode = mode;\n\t }\n\t // number of 512B blocks allocated\n\t this.blocks = Math.ceil(size / 512);\n\t // Check if mode also includes top-most bits, which indicate the file's\n\t // type.\n\t if (this.mode < 0x1000) {\n\t this.mode |= itemType;\n\t }\n\t};\n\tStats.fromBuffer = function fromBuffer (buffer$$1) {\n\t var size = buffer$$1.readUInt32LE(0), mode = buffer$$1.readUInt32LE(4), atime = buffer$$1.readDoubleLE(8), mtime = buffer$$1.readDoubleLE(16), ctime = buffer$$1.readDoubleLE(24);\n\t return new Stats(mode & 0xF000, size, mode & 0xFFF, new Date(atime), new Date(mtime), new Date(ctime));\n\t};\n\tStats.prototype.toBuffer = function toBuffer () {\n\t var buffer$$1 = Buffer.alloc(32);\n\t buffer$$1.writeUInt32LE(this.size, 0);\n\t buffer$$1.writeUInt32LE(this.mode, 4);\n\t buffer$$1.writeDoubleLE(this.atime.getTime(), 8);\n\t buffer$$1.writeDoubleLE(this.mtime.getTime(), 16);\n\t buffer$$1.writeDoubleLE(this.ctime.getTime(), 24);\n\t return buffer$$1;\n\t};\n\t/**\n\t * **Nonstandard**: Clone the stats object.\n\t * @return [BrowserFS.node.fs.Stats]\n\t */\n\tStats.prototype.clone = function clone () {\n\t return new Stats(this.mode & 0xF000, this.size, this.mode & 0xFFF, this.atime, this.mtime, this.ctime);\n\t};\n\t/**\n\t * @return [Boolean] True if this item is a file.\n\t */\n\tStats.prototype.isFile = function isFile () {\n\t return (this.mode & 0xF000) === FileType.FILE;\n\t};\n\t/**\n\t * @return [Boolean] True if this item is a directory.\n\t */\n\tStats.prototype.isDirectory = function isDirectory () {\n\t return (this.mode & 0xF000) === FileType.DIRECTORY;\n\t};\n\t/**\n\t * @return [Boolean] True if this item is a symbolic link (only valid through lstat)\n\t */\n\tStats.prototype.isSymbolicLink = function isSymbolicLink () {\n\t return (this.mode & 0xF000) === FileType.SYMLINK;\n\t};\n\t/**\n\t * Change the mode of the file. We use this helper function to prevent messing\n\t * up the type of the file, which is encoded in mode.\n\t */\n\tStats.prototype.chmod = function chmod (mode) {\n\t this.mode = (this.mode & 0xF000) | mode;\n\t};\n\t// We don't support the following types of files.\n\tStats.prototype.isSocket = function isSocket () {\n\t return false;\n\t};\n\tStats.prototype.isBlockDevice = function isBlockDevice () {\n\t return false;\n\t};\n\tStats.prototype.isCharacterDevice = function isCharacterDevice () {\n\t return false;\n\t};\n\tStats.prototype.isFIFO = function isFIFO () {\n\t return false;\n\t};\n\t\n\t/**\n\t * Wraps a callback function. Used for unit testing. Defaults to a NOP.\n\t * @hidden\n\t */\n\tvar wrapCb = function (cb, numArgs) {\n\t return cb;\n\t};\n\t/**\n\t * @hidden\n\t */\n\tfunction assertRoot(fs) {\n\t if (fs) {\n\t return fs;\n\t }\n\t throw new ApiError(ErrorCode.EIO, \"Initialize BrowserFS with a file system using BrowserFS.initialize(filesystem)\");\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction normalizeMode(mode, def) {\n\t switch (typeof mode) {\n\t case 'number':\n\t // (path, flag, mode, cb?)\n\t return mode;\n\t case 'string':\n\t // (path, flag, modeString, cb?)\n\t var trueMode = parseInt(mode, 8);\n\t if (!isNaN(trueMode)) {\n\t return trueMode;\n\t }\n\t // Invalid string.\n\t return def;\n\t default:\n\t return def;\n\t }\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction normalizeTime(time) {\n\t if (time instanceof Date) {\n\t return time;\n\t }\n\t else if (typeof time === 'number') {\n\t return new Date(time * 1000);\n\t }\n\t else {\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid time.\");\n\t }\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction normalizePath(p) {\n\t // Node doesn't allow null characters in paths.\n\t if (p.indexOf('\\u0000') >= 0) {\n\t throw new ApiError(ErrorCode.EINVAL, 'Path must be a string without null bytes.');\n\t }\n\t else if (p === '') {\n\t throw new ApiError(ErrorCode.EINVAL, 'Path must not be empty.');\n\t }\n\t return path.resolve(p);\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction normalizeOptions(options, defEnc, defFlag, defMode) {\n\t switch (typeof options) {\n\t case 'object':\n\t return {\n\t encoding: typeof options['encoding'] !== 'undefined' ? options['encoding'] : defEnc,\n\t flag: typeof options['flag'] !== 'undefined' ? options['flag'] : defFlag,\n\t mode: normalizeMode(options['mode'], defMode)\n\t };\n\t case 'string':\n\t return {\n\t encoding: options,\n\t flag: defFlag,\n\t mode: defMode\n\t };\n\t default:\n\t return {\n\t encoding: defEnc,\n\t flag: defFlag,\n\t mode: defMode\n\t };\n\t }\n\t}\n\t/**\n\t * The default callback is a NOP.\n\t * @hidden\n\t * @private\n\t */\n\tfunction nopCb() {\n\t // NOP.\n\t}\n\t/**\n\t * The node frontend to all filesystems.\n\t * This layer handles:\n\t *\n\t * * Sanity checking inputs.\n\t * * Normalizing paths.\n\t * * Resetting stack depth for asynchronous operations which may not go through\n\t * the browser by wrapping all input callbacks using `setImmediate`.\n\t * * Performing the requested operation through the filesystem or the file\n\t * descriptor, as appropriate.\n\t * * Handling optional arguments and setting default arguments.\n\t * @see http://nodejs.org/api/fs.html\n\t */\n\tvar FS = function FS() {\n\t /* tslint:enable:variable-name */\n\t this.F_OK = 0;\n\t this.R_OK = 4;\n\t this.W_OK = 2;\n\t this.X_OK = 1;\n\t this.root = null;\n\t this.fdMap = {};\n\t this.nextFd = 100;\n\t};\n\tFS.prototype.initialize = function initialize (rootFS) {\n\t if (!rootFS.constructor.isAvailable()) {\n\t throw new ApiError(ErrorCode.EINVAL, 'Tried to instantiate BrowserFS with an unavailable file system.');\n\t }\n\t return this.root = rootFS;\n\t};\n\t/**\n\t * converts Date or number to a fractional UNIX timestamp\n\t * Grabbed from NodeJS sources (lib/fs.js)\n\t */\n\tFS.prototype._toUnixTimestamp = function _toUnixTimestamp (time) {\n\t if (typeof time === 'number') {\n\t return time;\n\t }\n\t else if (time instanceof Date) {\n\t return time.getTime() / 1000;\n\t }\n\t throw new Error(\"Cannot parse time: \" + time);\n\t};\n\t/**\n\t * **NONSTANDARD**: Grab the FileSystem instance that backs this API.\n\t * @return [BrowserFS.FileSystem | null] Returns null if the file system has\n\t * not been initialized.\n\t */\n\tFS.prototype.getRootFS = function getRootFS () {\n\t if (this.root) {\n\t return this.root;\n\t }\n\t else {\n\t return null;\n\t }\n\t};\n\t// FILE OR DIRECTORY METHODS\n\t/**\n\t * Asynchronous rename. No arguments other than a possible exception are given\n\t * to the completion callback.\n\t * @param oldPath\n\t * @param newPath\n\t * @param callback\n\t */\n\tFS.prototype.rename = function rename (oldPath, newPath, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t assertRoot(this.root).rename(normalizePath(oldPath), normalizePath(newPath), newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous rename.\n\t * @param oldPath\n\t * @param newPath\n\t */\n\tFS.prototype.renameSync = function renameSync (oldPath, newPath) {\n\t assertRoot(this.root).renameSync(normalizePath(oldPath), normalizePath(newPath));\n\t};\n\t/**\n\t * Test whether or not the given path exists by checking with the file system.\n\t * Then call the callback argument with either true or false.\n\t * @example Sample invocation\n\t * fs.exists('/etc/passwd', function (exists) {\n\t * util.debug(exists ? \"it's there\" : \"no passwd!\");\n\t * });\n\t * @param path\n\t * @param callback\n\t */\n\tFS.prototype.exists = function exists (path$$1, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t return assertRoot(this.root).exists(normalizePath(path$$1), newCb);\n\t }\n\t catch (e) {\n\t // Doesn't return an error. If something bad happens, we assume it just\n\t // doesn't exist.\n\t return newCb(false);\n\t }\n\t};\n\t/**\n\t * Test whether or not the given path exists by checking with the file system.\n\t * @param path\n\t * @return [boolean]\n\t */\n\tFS.prototype.existsSync = function existsSync (path$$1) {\n\t try {\n\t return assertRoot(this.root).existsSync(normalizePath(path$$1));\n\t }\n\t catch (e) {\n\t // Doesn't return an error. If something bad happens, we assume it just\n\t // doesn't exist.\n\t return false;\n\t }\n\t};\n\t/**\n\t * Asynchronous `stat`.\n\t * @param path\n\t * @param callback\n\t */\n\tFS.prototype.stat = function stat (path$$1, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 2);\n\t try {\n\t return assertRoot(this.root).stat(normalizePath(path$$1), false, newCb);\n\t }\n\t catch (e) {\n\t return newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `stat`.\n\t * @param path\n\t * @return [BrowserFS.node.fs.Stats]\n\t */\n\tFS.prototype.statSync = function statSync (path$$1) {\n\t return assertRoot(this.root).statSync(normalizePath(path$$1), false);\n\t};\n\t/**\n\t * Asynchronous `lstat`.\n\t * `lstat()` is identical to `stat()`, except that if path is a symbolic link,\n\t * then the link itself is stat-ed, not the file that it refers to.\n\t * @param path\n\t * @param callback\n\t */\n\tFS.prototype.lstat = function lstat (path$$1, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 2);\n\t try {\n\t return assertRoot(this.root).stat(normalizePath(path$$1), true, newCb);\n\t }\n\t catch (e) {\n\t return newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `lstat`.\n\t * `lstat()` is identical to `stat()`, except that if path is a symbolic link,\n\t * then the link itself is stat-ed, not the file that it refers to.\n\t * @param path\n\t * @return [BrowserFS.node.fs.Stats]\n\t */\n\tFS.prototype.lstatSync = function lstatSync (path$$1) {\n\t return assertRoot(this.root).statSync(normalizePath(path$$1), true);\n\t};\n\tFS.prototype.truncate = function truncate (path$$1, arg2, cb) {\n\t if ( arg2 === void 0 ) arg2 = 0;\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var len = 0;\n\t if (typeof arg2 === 'function') {\n\t cb = arg2;\n\t }\n\t else if (typeof arg2 === 'number') {\n\t len = arg2;\n\t }\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t if (len < 0) {\n\t throw new ApiError(ErrorCode.EINVAL);\n\t }\n\t return assertRoot(this.root).truncate(normalizePath(path$$1), len, newCb);\n\t }\n\t catch (e) {\n\t return newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `truncate`.\n\t * @param path\n\t * @param len\n\t */\n\tFS.prototype.truncateSync = function truncateSync (path$$1, len) {\n\t if ( len === void 0 ) len = 0;\n\t\n\t if (len < 0) {\n\t throw new ApiError(ErrorCode.EINVAL);\n\t }\n\t return assertRoot(this.root).truncateSync(normalizePath(path$$1), len);\n\t};\n\t/**\n\t * Asynchronous `unlink`.\n\t * @param path\n\t * @param callback\n\t */\n\tFS.prototype.unlink = function unlink (path$$1, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t return assertRoot(this.root).unlink(normalizePath(path$$1), newCb);\n\t }\n\t catch (e) {\n\t return newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `unlink`.\n\t * @param path\n\t */\n\tFS.prototype.unlinkSync = function unlinkSync (path$$1) {\n\t return assertRoot(this.root).unlinkSync(normalizePath(path$$1));\n\t};\n\tFS.prototype.open = function open (path$$1, flag, arg2, cb) {\n\t var this$1 = this;\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var mode = normalizeMode(arg2, 0x1a4);\n\t cb = typeof arg2 === 'function' ? arg2 : cb;\n\t var newCb = wrapCb(cb, 2);\n\t try {\n\t assertRoot(this.root).open(normalizePath(path$$1), FileFlag.getFileFlag(flag), mode, function (e, file) {\n\t if (file) {\n\t newCb(e, this$1.getFdForFile(file));\n\t }\n\t else {\n\t newCb(e);\n\t }\n\t });\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous file open.\n\t * @see http://www.manpagez.com/man/2/open/\n\t * @param path\n\t * @param flags\n\t * @param mode defaults to `0644`\n\t * @return [BrowserFS.File]\n\t */\n\tFS.prototype.openSync = function openSync (path$$1, flag, mode) {\n\t if ( mode === void 0 ) mode = 0x1a4;\n\t\n\t return this.getFdForFile(assertRoot(this.root).openSync(normalizePath(path$$1), FileFlag.getFileFlag(flag), normalizeMode(mode, 0x1a4)));\n\t};\n\tFS.prototype.readFile = function readFile (filename, arg2, cb) {\n\t if ( arg2 === void 0 ) arg2 = {};\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var options = normalizeOptions(arg2, null, 'r', null);\n\t cb = typeof arg2 === 'function' ? arg2 : cb;\n\t var newCb = wrapCb(cb, 2);\n\t try {\n\t var flag = FileFlag.getFileFlag(options['flag']);\n\t if (!flag.isReadable()) {\n\t return newCb(new ApiError(ErrorCode.EINVAL, 'Flag passed to readFile must allow for reading.'));\n\t }\n\t return assertRoot(this.root).readFile(normalizePath(filename), options.encoding, flag, newCb);\n\t }\n\t catch (e) {\n\t return newCb(e);\n\t }\n\t};\n\tFS.prototype.readFileSync = function readFileSync (filename, arg2) {\n\t if ( arg2 === void 0 ) arg2 = {};\n\t\n\t var options = normalizeOptions(arg2, null, 'r', null);\n\t var flag = FileFlag.getFileFlag(options.flag);\n\t if (!flag.isReadable()) {\n\t throw new ApiError(ErrorCode.EINVAL, 'Flag passed to readFile must allow for reading.');\n\t }\n\t return assertRoot(this.root).readFileSync(normalizePath(filename), options.encoding, flag);\n\t};\n\tFS.prototype.writeFile = function writeFile (filename, data, arg3, cb) {\n\t if ( arg3 === void 0 ) arg3 = {};\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var options = normalizeOptions(arg3, 'utf8', 'w', 0x1a4);\n\t cb = typeof arg3 === 'function' ? arg3 : cb;\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t var flag = FileFlag.getFileFlag(options.flag);\n\t if (!flag.isWriteable()) {\n\t return newCb(new ApiError(ErrorCode.EINVAL, 'Flag passed to writeFile must allow for writing.'));\n\t }\n\t return assertRoot(this.root).writeFile(normalizePath(filename), data, options.encoding, flag, options.mode, newCb);\n\t }\n\t catch (e) {\n\t return newCb(e);\n\t }\n\t};\n\tFS.prototype.writeFileSync = function writeFileSync (filename, data, arg3) {\n\t var options = normalizeOptions(arg3, 'utf8', 'w', 0x1a4);\n\t var flag = FileFlag.getFileFlag(options.flag);\n\t if (!flag.isWriteable()) {\n\t throw new ApiError(ErrorCode.EINVAL, 'Flag passed to writeFile must allow for writing.');\n\t }\n\t return assertRoot(this.root).writeFileSync(normalizePath(filename), data, options.encoding, flag, options.mode);\n\t};\n\tFS.prototype.appendFile = function appendFile (filename, data, arg3, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var options = normalizeOptions(arg3, 'utf8', 'a', 0x1a4);\n\t cb = typeof arg3 === 'function' ? arg3 : cb;\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t var flag = FileFlag.getFileFlag(options.flag);\n\t if (!flag.isAppendable()) {\n\t return newCb(new ApiError(ErrorCode.EINVAL, 'Flag passed to appendFile must allow for appending.'));\n\t }\n\t assertRoot(this.root).appendFile(normalizePath(filename), data, options.encoding, flag, options.mode, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\tFS.prototype.appendFileSync = function appendFileSync (filename, data, arg3) {\n\t var options = normalizeOptions(arg3, 'utf8', 'a', 0x1a4);\n\t var flag = FileFlag.getFileFlag(options.flag);\n\t if (!flag.isAppendable()) {\n\t throw new ApiError(ErrorCode.EINVAL, 'Flag passed to appendFile must allow for appending.');\n\t }\n\t return assertRoot(this.root).appendFileSync(normalizePath(filename), data, options.encoding, flag, options.mode);\n\t};\n\t// FILE DESCRIPTOR METHODS\n\t/**\n\t * Asynchronous `fstat`.\n\t * `fstat()` is identical to `stat()`, except that the file to be stat-ed is\n\t * specified by the file descriptor `fd`.\n\t * @param fd\n\t * @param callback\n\t */\n\tFS.prototype.fstat = function fstat (fd, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 2);\n\t try {\n\t var file = this.fd2file(fd);\n\t file.stat(newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `fstat`.\n\t * `fstat()` is identical to `stat()`, except that the file to be stat-ed is\n\t * specified by the file descriptor `fd`.\n\t * @param fd\n\t * @return [BrowserFS.node.fs.Stats]\n\t */\n\tFS.prototype.fstatSync = function fstatSync (fd) {\n\t return this.fd2file(fd).statSync();\n\t};\n\t/**\n\t * Asynchronous close.\n\t * @param fd\n\t * @param callback\n\t */\n\tFS.prototype.close = function close (fd, cb) {\n\t var this$1 = this;\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t this.fd2file(fd).close(function (e) {\n\t if (!e) {\n\t this$1.closeFd(fd);\n\t }\n\t newCb(e);\n\t });\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous close.\n\t * @param fd\n\t */\n\tFS.prototype.closeSync = function closeSync (fd) {\n\t this.fd2file(fd).closeSync();\n\t this.closeFd(fd);\n\t};\n\tFS.prototype.ftruncate = function ftruncate (fd, arg2, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var length = typeof arg2 === 'number' ? arg2 : 0;\n\t cb = typeof arg2 === 'function' ? arg2 : cb;\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t var file = this.fd2file(fd);\n\t if (length < 0) {\n\t throw new ApiError(ErrorCode.EINVAL);\n\t }\n\t file.truncate(length, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous ftruncate.\n\t * @param fd\n\t * @param len\n\t */\n\tFS.prototype.ftruncateSync = function ftruncateSync (fd, len) {\n\t if ( len === void 0 ) len = 0;\n\t\n\t var file = this.fd2file(fd);\n\t if (len < 0) {\n\t throw new ApiError(ErrorCode.EINVAL);\n\t }\n\t file.truncateSync(len);\n\t};\n\t/**\n\t * Asynchronous fsync.\n\t * @param fd\n\t * @param callback\n\t */\n\tFS.prototype.fsync = function fsync (fd, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t this.fd2file(fd).sync(newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous fsync.\n\t * @param fd\n\t */\n\tFS.prototype.fsyncSync = function fsyncSync (fd) {\n\t this.fd2file(fd).syncSync();\n\t};\n\t/**\n\t * Asynchronous fdatasync.\n\t * @param fd\n\t * @param callback\n\t */\n\tFS.prototype.fdatasync = function fdatasync (fd, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t this.fd2file(fd).datasync(newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous fdatasync.\n\t * @param fd\n\t */\n\tFS.prototype.fdatasyncSync = function fdatasyncSync (fd) {\n\t this.fd2file(fd).datasyncSync();\n\t};\n\tFS.prototype.write = function write (fd, arg2, arg3, arg4, arg5, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var buffer$$1, offset, length, position = null;\n\t if (typeof arg2 === 'string') {\n\t // Signature 1: (fd, string, [position?, [encoding?]], cb?)\n\t var encoding = 'utf8';\n\t switch (typeof arg3) {\n\t case 'function':\n\t // (fd, string, cb)\n\t cb = arg3;\n\t break;\n\t case 'number':\n\t // (fd, string, position, encoding?, cb?)\n\t position = arg3;\n\t encoding = typeof arg4 === 'string' ? arg4 : 'utf8';\n\t cb = typeof arg5 === 'function' ? arg5 : cb;\n\t break;\n\t default:\n\t // ...try to find the callback and get out of here!\n\t cb = typeof arg4 === 'function' ? arg4 : typeof arg5 === 'function' ? arg5 : cb;\n\t return cb(new ApiError(ErrorCode.EINVAL, 'Invalid arguments.'));\n\t }\n\t buffer$$1 = Buffer.from(arg2, encoding);\n\t offset = 0;\n\t length = buffer$$1.length;\n\t }\n\t else {\n\t // Signature 2: (fd, buffer, offset, length, position?, cb?)\n\t buffer$$1 = arg2;\n\t offset = arg3;\n\t length = arg4;\n\t position = typeof arg5 === 'number' ? arg5 : null;\n\t cb = typeof arg5 === 'function' ? arg5 : cb;\n\t }\n\t var newCb = wrapCb(cb, 3);\n\t try {\n\t var file = this.fd2file(fd);\n\t if (position === undefined || position === null) {\n\t position = file.getPos();\n\t }\n\t file.write(buffer$$1, offset, length, position, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\tFS.prototype.writeSync = function writeSync (fd, arg2, arg3, arg4, arg5) {\n\t var buffer$$1, offset = 0, length, position;\n\t if (typeof arg2 === 'string') {\n\t // Signature 1: (fd, string, [position?, [encoding?]])\n\t position = typeof arg3 === 'number' ? arg3 : null;\n\t var encoding = typeof arg4 === 'string' ? arg4 : 'utf8';\n\t offset = 0;\n\t buffer$$1 = Buffer.from(arg2, encoding);\n\t length = buffer$$1.length;\n\t }\n\t else {\n\t // Signature 2: (fd, buffer, offset, length, position?)\n\t buffer$$1 = arg2;\n\t offset = arg3;\n\t length = arg4;\n\t position = typeof arg5 === 'number' ? arg5 : null;\n\t }\n\t var file = this.fd2file(fd);\n\t if (position === undefined || position === null) {\n\t position = file.getPos();\n\t }\n\t return file.writeSync(buffer$$1, offset, length, position);\n\t};\n\tFS.prototype.read = function read (fd, arg2, arg3, arg4, arg5, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var position, offset, length, buffer$$1, newCb;\n\t if (typeof arg2 === 'number') {\n\t // legacy interface\n\t // (fd, length, position, encoding, callback)\n\t length = arg2;\n\t position = arg3;\n\t var encoding = arg4;\n\t cb = typeof arg5 === 'function' ? arg5 : cb;\n\t offset = 0;\n\t buffer$$1 = Buffer.alloc(length);\n\t // XXX: Inefficient.\n\t // Wrap the cb so we shelter upper layers of the API from these\n\t // shenanigans.\n\t newCb = wrapCb(function (err, bytesRead, buf) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t cb(err, buf.toString(encoding), bytesRead);\n\t }, 3);\n\t }\n\t else {\n\t buffer$$1 = arg2;\n\t offset = arg3;\n\t length = arg4;\n\t position = arg5;\n\t newCb = wrapCb(cb, 3);\n\t }\n\t try {\n\t var file = this.fd2file(fd);\n\t if (position === undefined || position === null) {\n\t position = file.getPos();\n\t }\n\t file.read(buffer$$1, offset, length, position, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\tFS.prototype.readSync = function readSync (fd, arg2, arg3, arg4, arg5) {\n\t var shenanigans = false;\n\t var buffer$$1, offset, length, position, encoding = 'utf8';\n\t if (typeof arg2 === 'number') {\n\t length = arg2;\n\t position = arg3;\n\t encoding = arg4;\n\t offset = 0;\n\t buffer$$1 = Buffer.alloc(length);\n\t shenanigans = true;\n\t }\n\t else {\n\t buffer$$1 = arg2;\n\t offset = arg3;\n\t length = arg4;\n\t position = arg5;\n\t }\n\t var file = this.fd2file(fd);\n\t if (position === undefined || position === null) {\n\t position = file.getPos();\n\t }\n\t var rv = file.readSync(buffer$$1, offset, length, position);\n\t if (!shenanigans) {\n\t return rv;\n\t }\n\t else {\n\t return [buffer$$1.toString(encoding), rv];\n\t }\n\t};\n\t/**\n\t * Asynchronous `fchown`.\n\t * @param fd\n\t * @param uid\n\t * @param gid\n\t * @param callback\n\t */\n\tFS.prototype.fchown = function fchown (fd, uid, gid, callback) {\n\t if ( callback === void 0 ) callback = nopCb;\n\t\n\t var newCb = wrapCb(callback, 1);\n\t try {\n\t this.fd2file(fd).chown(uid, gid, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `fchown`.\n\t * @param fd\n\t * @param uid\n\t * @param gid\n\t */\n\tFS.prototype.fchownSync = function fchownSync (fd, uid, gid) {\n\t this.fd2file(fd).chownSync(uid, gid);\n\t};\n\t/**\n\t * Asynchronous `fchmod`.\n\t * @param fd\n\t * @param mode\n\t * @param callback\n\t */\n\tFS.prototype.fchmod = function fchmod (fd, mode, cb) {\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t var numMode = typeof mode === 'string' ? parseInt(mode, 8) : mode;\n\t this.fd2file(fd).chmod(numMode, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `fchmod`.\n\t * @param fd\n\t * @param mode\n\t */\n\tFS.prototype.fchmodSync = function fchmodSync (fd, mode) {\n\t var numMode = typeof mode === 'string' ? parseInt(mode, 8) : mode;\n\t this.fd2file(fd).chmodSync(numMode);\n\t};\n\t/**\n\t * Change the file timestamps of a file referenced by the supplied file\n\t * descriptor.\n\t * @param fd\n\t * @param atime\n\t * @param mtime\n\t * @param callback\n\t */\n\tFS.prototype.futimes = function futimes (fd, atime, mtime, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t var file = this.fd2file(fd);\n\t if (typeof atime === 'number') {\n\t atime = new Date(atime * 1000);\n\t }\n\t if (typeof mtime === 'number') {\n\t mtime = new Date(mtime * 1000);\n\t }\n\t file.utimes(atime, mtime, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Change the file timestamps of a file referenced by the supplied file\n\t * descriptor.\n\t * @param fd\n\t * @param atime\n\t * @param mtime\n\t */\n\tFS.prototype.futimesSync = function futimesSync (fd, atime, mtime) {\n\t this.fd2file(fd).utimesSync(normalizeTime(atime), normalizeTime(mtime));\n\t};\n\t// DIRECTORY-ONLY METHODS\n\t/**\n\t * Asynchronous `rmdir`.\n\t * @param path\n\t * @param callback\n\t */\n\tFS.prototype.rmdir = function rmdir (path$$1, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t path$$1 = normalizePath(path$$1);\n\t assertRoot(this.root).rmdir(path$$1, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `rmdir`.\n\t * @param path\n\t */\n\tFS.prototype.rmdirSync = function rmdirSync (path$$1) {\n\t path$$1 = normalizePath(path$$1);\n\t return assertRoot(this.root).rmdirSync(path$$1);\n\t};\n\t/**\n\t * Asynchronous `mkdir`.\n\t * @param path\n\t * @param mode defaults to `0777`\n\t * @param callback\n\t */\n\tFS.prototype.mkdir = function mkdir (path$$1, mode, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t if (typeof mode === 'function') {\n\t cb = mode;\n\t mode = 0x1ff;\n\t }\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t path$$1 = normalizePath(path$$1);\n\t assertRoot(this.root).mkdir(path$$1, mode, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `mkdir`.\n\t * @param path\n\t * @param mode defaults to `0777`\n\t */\n\tFS.prototype.mkdirSync = function mkdirSync (path$$1, mode) {\n\t assertRoot(this.root).mkdirSync(normalizePath(path$$1), normalizeMode(mode, 0x1ff));\n\t};\n\t/**\n\t * Asynchronous `readdir`. Reads the contents of a directory.\n\t * The callback gets two arguments `(err, files)` where `files` is an array of\n\t * the names of the files in the directory excluding `'.'` and `'..'`.\n\t * @param path\n\t * @param callback\n\t */\n\tFS.prototype.readdir = function readdir (path$$1, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 2);\n\t try {\n\t path$$1 = normalizePath(path$$1);\n\t assertRoot(this.root).readdir(path$$1, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `readdir`. Reads the contents of a directory.\n\t * @param path\n\t * @return [String[]]\n\t */\n\tFS.prototype.readdirSync = function readdirSync (path$$1) {\n\t path$$1 = normalizePath(path$$1);\n\t return assertRoot(this.root).readdirSync(path$$1);\n\t};\n\t// SYMLINK METHODS\n\t/**\n\t * Asynchronous `link`.\n\t * @param srcpath\n\t * @param dstpath\n\t * @param callback\n\t */\n\tFS.prototype.link = function link (srcpath, dstpath, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t srcpath = normalizePath(srcpath);\n\t dstpath = normalizePath(dstpath);\n\t assertRoot(this.root).link(srcpath, dstpath, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `link`.\n\t * @param srcpath\n\t * @param dstpath\n\t */\n\tFS.prototype.linkSync = function linkSync (srcpath, dstpath) {\n\t srcpath = normalizePath(srcpath);\n\t dstpath = normalizePath(dstpath);\n\t return assertRoot(this.root).linkSync(srcpath, dstpath);\n\t};\n\tFS.prototype.symlink = function symlink (srcpath, dstpath, arg3, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var type = typeof arg3 === 'string' ? arg3 : 'file';\n\t cb = typeof arg3 === 'function' ? arg3 : cb;\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t if (type !== 'file' && type !== 'dir') {\n\t return newCb(new ApiError(ErrorCode.EINVAL, \"Invalid type: \" + type));\n\t }\n\t srcpath = normalizePath(srcpath);\n\t dstpath = normalizePath(dstpath);\n\t assertRoot(this.root).symlink(srcpath, dstpath, type, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `symlink`.\n\t * @param srcpath\n\t * @param dstpath\n\t * @param type can be either `'dir'` or `'file'` (default is `'file'`)\n\t */\n\tFS.prototype.symlinkSync = function symlinkSync (srcpath, dstpath, type) {\n\t if (!type) {\n\t type = 'file';\n\t }\n\t else if (type !== 'file' && type !== 'dir') {\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid type: \" + type);\n\t }\n\t srcpath = normalizePath(srcpath);\n\t dstpath = normalizePath(dstpath);\n\t return assertRoot(this.root).symlinkSync(srcpath, dstpath, type);\n\t};\n\t/**\n\t * Asynchronous readlink.\n\t * @param path\n\t * @param callback\n\t */\n\tFS.prototype.readlink = function readlink (path$$1, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 2);\n\t try {\n\t path$$1 = normalizePath(path$$1);\n\t assertRoot(this.root).readlink(path$$1, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous readlink.\n\t * @param path\n\t * @return [String]\n\t */\n\tFS.prototype.readlinkSync = function readlinkSync (path$$1) {\n\t path$$1 = normalizePath(path$$1);\n\t return assertRoot(this.root).readlinkSync(path$$1);\n\t};\n\t// PROPERTY OPERATIONS\n\t/**\n\t * Asynchronous `chown`.\n\t * @param path\n\t * @param uid\n\t * @param gid\n\t * @param callback\n\t */\n\tFS.prototype.chown = function chown (path$$1, uid, gid, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t path$$1 = normalizePath(path$$1);\n\t assertRoot(this.root).chown(path$$1, false, uid, gid, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `chown`.\n\t * @param path\n\t * @param uid\n\t * @param gid\n\t */\n\tFS.prototype.chownSync = function chownSync (path$$1, uid, gid) {\n\t path$$1 = normalizePath(path$$1);\n\t assertRoot(this.root).chownSync(path$$1, false, uid, gid);\n\t};\n\t/**\n\t * Asynchronous `lchown`.\n\t * @param path\n\t * @param uid\n\t * @param gid\n\t * @param callback\n\t */\n\tFS.prototype.lchown = function lchown (path$$1, uid, gid, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t path$$1 = normalizePath(path$$1);\n\t assertRoot(this.root).chown(path$$1, true, uid, gid, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `lchown`.\n\t * @param path\n\t * @param uid\n\t * @param gid\n\t */\n\tFS.prototype.lchownSync = function lchownSync (path$$1, uid, gid) {\n\t path$$1 = normalizePath(path$$1);\n\t assertRoot(this.root).chownSync(path$$1, true, uid, gid);\n\t};\n\t/**\n\t * Asynchronous `chmod`.\n\t * @param path\n\t * @param mode\n\t * @param callback\n\t */\n\tFS.prototype.chmod = function chmod (path$$1, mode, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t var numMode = normalizeMode(mode, -1);\n\t if (numMode < 0) {\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid mode.\");\n\t }\n\t assertRoot(this.root).chmod(normalizePath(path$$1), false, numMode, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `chmod`.\n\t * @param path\n\t * @param mode\n\t */\n\tFS.prototype.chmodSync = function chmodSync (path$$1, mode) {\n\t var numMode = normalizeMode(mode, -1);\n\t if (numMode < 0) {\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid mode.\");\n\t }\n\t path$$1 = normalizePath(path$$1);\n\t assertRoot(this.root).chmodSync(path$$1, false, numMode);\n\t};\n\t/**\n\t * Asynchronous `lchmod`.\n\t * @param path\n\t * @param mode\n\t * @param callback\n\t */\n\tFS.prototype.lchmod = function lchmod (path$$1, mode, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t var numMode = normalizeMode(mode, -1);\n\t if (numMode < 0) {\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid mode.\");\n\t }\n\t assertRoot(this.root).chmod(normalizePath(path$$1), true, numMode, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `lchmod`.\n\t * @param path\n\t * @param mode\n\t */\n\tFS.prototype.lchmodSync = function lchmodSync (path$$1, mode) {\n\t var numMode = normalizeMode(mode, -1);\n\t if (numMode < 1) {\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid mode.\");\n\t }\n\t assertRoot(this.root).chmodSync(normalizePath(path$$1), true, numMode);\n\t};\n\t/**\n\t * Change file timestamps of the file referenced by the supplied path.\n\t * @param path\n\t * @param atime\n\t * @param mtime\n\t * @param callback\n\t */\n\tFS.prototype.utimes = function utimes (path$$1, atime, mtime, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var newCb = wrapCb(cb, 1);\n\t try {\n\t assertRoot(this.root).utimes(normalizePath(path$$1), normalizeTime(atime), normalizeTime(mtime), newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Change file timestamps of the file referenced by the supplied path.\n\t * @param path\n\t * @param atime\n\t * @param mtime\n\t */\n\tFS.prototype.utimesSync = function utimesSync (path$$1, atime, mtime) {\n\t assertRoot(this.root).utimesSync(normalizePath(path$$1), normalizeTime(atime), normalizeTime(mtime));\n\t};\n\tFS.prototype.realpath = function realpath (path$$1, arg2, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t var cache = typeof (arg2) === 'object' ? arg2 : {};\n\t cb = typeof (arg2) === 'function' ? arg2 : nopCb;\n\t var newCb = wrapCb(cb, 2);\n\t try {\n\t path$$1 = normalizePath(path$$1);\n\t assertRoot(this.root).realpath(path$$1, cache, newCb);\n\t }\n\t catch (e) {\n\t newCb(e);\n\t }\n\t};\n\t/**\n\t * Synchronous `realpath`.\n\t * @param path\n\t * @param cache An object literal of mapped paths that can be used to\n\t * force a specific path resolution or avoid additional `fs.stat` calls for\n\t * known real paths.\n\t * @return [String]\n\t */\n\tFS.prototype.realpathSync = function realpathSync (path$$1, cache) {\n\t if ( cache === void 0 ) cache = {};\n\t\n\t path$$1 = normalizePath(path$$1);\n\t return assertRoot(this.root).realpathSync(path$$1, cache);\n\t};\n\tFS.prototype.watchFile = function watchFile (filename, arg2, listener) {\n\t if ( listener === void 0 ) listener = nopCb;\n\t\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tFS.prototype.unwatchFile = function unwatchFile (filename, listener) {\n\t if ( listener === void 0 ) listener = nopCb;\n\t\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tFS.prototype.watch = function watch (filename, arg2, listener) {\n\t if ( listener === void 0 ) listener = nopCb;\n\t\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tFS.prototype.access = function access (path$$1, arg2, cb) {\n\t if ( cb === void 0 ) cb = nopCb;\n\t\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tFS.prototype.accessSync = function accessSync (path$$1, mode) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tFS.prototype.createReadStream = function createReadStream (path$$1, options) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tFS.prototype.createWriteStream = function createWriteStream (path$$1, options) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\t/**\n\t * For unit testing. Passes all incoming callbacks to cbWrapper for wrapping.\n\t */\n\tFS.prototype.wrapCallbacks = function wrapCallbacks (cbWrapper) {\n\t wrapCb = cbWrapper;\n\t};\n\tFS.prototype.getFdForFile = function getFdForFile (file) {\n\t var fd = this.nextFd++;\n\t this.fdMap[fd] = file;\n\t return fd;\n\t};\n\tFS.prototype.fd2file = function fd2file (fd) {\n\t var rv = this.fdMap[fd];\n\t if (rv) {\n\t return rv;\n\t }\n\t else {\n\t throw new ApiError(ErrorCode.EBADF, 'Invalid file descriptor.');\n\t }\n\t};\n\tFS.prototype.closeFd = function closeFd (fd) {\n\t delete this.fdMap[fd];\n\t};\n\t\n\t/* tslint:disable:variable-name */\n\t// Exported fs.Stats.\n\tFS.Stats = Stats;\n\t\n\t// Manually export the individual public functions of fs.\n\t// Required because some code will invoke functions off of the module.\n\t// e.g.:\n\t// let writeFile = fs.writeFile;\n\t// writeFile(...)\n\t/**\n\t * @hidden\n\t */\n\tvar fs = new FS();\n\t/**\n\t * @hidden\n\t */\n\tvar _fsMock = {};\n\t/**\n\t * @hidden\n\t */\n\tvar fsProto = FS.prototype;\n\tObject.keys(fsProto).forEach(function (key) {\n\t if (typeof fs[key] === 'function') {\n\t _fsMock[key] = function () {\n\t return fs[key].apply(fs, arguments);\n\t };\n\t }\n\t else {\n\t _fsMock[key] = fs[key];\n\t }\n\t});\n\t_fsMock['changeFSModule'] = function (newFs) {\n\t fs = newFs;\n\t};\n\t_fsMock['getFSModule'] = function () {\n\t return fs;\n\t};\n\t_fsMock['FS'] = FS;\n\t\n\t/*\n\t * Levenshtein distance, from the `js-levenshtein` NPM module.\n\t * Copied here to avoid complexity of adding another CommonJS module dependency.\n\t */\n\tfunction _min(d0, d1, d2, bx, ay) {\n\t return d0 < d1 || d2 < d1\n\t ? d0 > d2\n\t ? d2 + 1\n\t : d0 + 1\n\t : bx === ay\n\t ? d1\n\t : d1 + 1;\n\t}\n\t/**\n\t * Calculates levenshtein distance.\n\t * @param a\n\t * @param b\n\t */\n\tfunction levenshtein(a, b) {\n\t if (a === b) {\n\t return 0;\n\t }\n\t if (a.length > b.length) {\n\t var tmp = a;\n\t a = b;\n\t b = tmp;\n\t }\n\t var la = a.length;\n\t var lb = b.length;\n\t while (la > 0 && (a.charCodeAt(la - 1) === b.charCodeAt(lb - 1))) {\n\t la--;\n\t lb--;\n\t }\n\t var offset = 0;\n\t while (offset < la && (a.charCodeAt(offset) === b.charCodeAt(offset))) {\n\t offset++;\n\t }\n\t la -= offset;\n\t lb -= offset;\n\t if (la === 0 || lb === 1) {\n\t return lb;\n\t }\n\t var vector = new Array(la << 1);\n\t for (var y = 0; y < la;) {\n\t vector[la + y] = a.charCodeAt(offset + y);\n\t vector[y] = ++y;\n\t }\n\t var x;\n\t var d0;\n\t var d1;\n\t var d2;\n\t var d3;\n\t for (x = 0; (x + 3) < lb;) {\n\t var bx0 = b.charCodeAt(offset + (d0 = x));\n\t var bx1 = b.charCodeAt(offset + (d1 = x + 1));\n\t var bx2 = b.charCodeAt(offset + (d2 = x + 2));\n\t var bx3 = b.charCodeAt(offset + (d3 = x + 3));\n\t var dd$1 = (x += 4);\n\t for (var y$1 = 0; y$1 < la;) {\n\t var ay = vector[la + y$1];\n\t var dy = vector[y$1];\n\t d0 = _min(dy, d0, d1, bx0, ay);\n\t d1 = _min(d0, d1, d2, bx1, ay);\n\t d2 = _min(d1, d2, d3, bx2, ay);\n\t dd$1 = _min(d2, d3, dd$1, bx3, ay);\n\t vector[y$1++] = dd$1;\n\t d3 = d2;\n\t d2 = d1;\n\t d1 = d0;\n\t d0 = dy;\n\t }\n\t }\n\t var dd = 0;\n\t for (; x < lb;) {\n\t var bx0$1 = b.charCodeAt(offset + (d0 = x));\n\t dd = ++x;\n\t for (var y$2 = 0; y$2 < la; y$2++) {\n\t var dy$1 = vector[y$2];\n\t vector[y$2] = dd = dy$1 < d0 || dd < d0\n\t ? dy$1 > dd ? dd + 1 : dy$1 + 1\n\t : bx0$1 === vector[la + y$2]\n\t ? d0\n\t : d0 + 1;\n\t d0 = dy$1;\n\t }\n\t }\n\t return dd;\n\t}\n\t\n\tfunction deprecationMessage(print, fsName, opts) {\n\t if (print) {\n\t console.warn((\"[\" + fsName + \"] Direct file system constructor usage is deprecated for this file system, and will be removed in the next major version. Please use the '\" + fsName + \".Create(\" + (JSON.stringify(opts)) + \", callback)' method instead. See https://github.com/jvilk/BrowserFS/issues/176 for more details.\"));\n\t }\n\t}\n\t/**\n\t * Checks for any IE version, including IE11 which removed MSIE from the\n\t * userAgent string.\n\t * @hidden\n\t */\n\tvar isIE = typeof navigator !== \"undefined\" && !!(/(msie) ([\\w.]+)/.exec(navigator.userAgent.toLowerCase()) || navigator.userAgent.indexOf('Trident') !== -1);\n\t/**\n\t * Check if we're in a web worker.\n\t * @hidden\n\t */\n\tvar isWebWorker = typeof window === \"undefined\";\n\t/**\n\t * Throws an exception. Called on code paths that should be impossible.\n\t * @hidden\n\t */\n\tfunction fail() {\n\t throw new Error(\"BFS has reached an impossible code path; please file a bug.\");\n\t}\n\t/**\n\t * Synchronous recursive makedir.\n\t * @hidden\n\t */\n\tfunction mkdirpSync(p, mode, fs) {\n\t if (!fs.existsSync(p)) {\n\t mkdirpSync(path.dirname(p), mode, fs);\n\t fs.mkdirSync(p, mode);\n\t }\n\t}\n\t/**\n\t * Converts a buffer into an array buffer. Attempts to do so in a\n\t * zero-copy manner, e.g. the array references the same memory.\n\t * @hidden\n\t */\n\tfunction buffer2ArrayBuffer(buff) {\n\t var u8 = buffer2Uint8array(buff), u8offset = u8.byteOffset, u8Len = u8.byteLength;\n\t if (u8offset === 0 && u8Len === u8.buffer.byteLength) {\n\t return u8.buffer;\n\t }\n\t else {\n\t return u8.buffer.slice(u8offset, u8offset + u8Len);\n\t }\n\t}\n\t/**\n\t * Converts a buffer into a Uint8Array. Attempts to do so in a\n\t * zero-copy manner, e.g. the array references the same memory.\n\t * @hidden\n\t */\n\tfunction buffer2Uint8array(buff) {\n\t if (buff instanceof Uint8Array) {\n\t // BFS & Node v4.0 buffers *are* Uint8Arrays.\n\t return buff;\n\t }\n\t else {\n\t // Uint8Arrays can be constructed from arrayish numbers.\n\t // At this point, we assume this isn't a BFS array.\n\t return new Uint8Array(buff);\n\t }\n\t}\n\t/**\n\t * Converts the given arrayish object into a Buffer. Attempts to\n\t * be zero-copy.\n\t * @hidden\n\t */\n\tfunction arrayish2Buffer(arr) {\n\t if (arr instanceof Buffer) {\n\t return arr;\n\t }\n\t else if (arr instanceof Uint8Array) {\n\t return uint8Array2Buffer(arr);\n\t }\n\t else {\n\t return Buffer.from(arr);\n\t }\n\t}\n\t/**\n\t * Converts the given Uint8Array into a Buffer. Attempts to be zero-copy.\n\t * @hidden\n\t */\n\tfunction uint8Array2Buffer(u8) {\n\t if (u8 instanceof Buffer) {\n\t return u8;\n\t }\n\t else if (u8.byteOffset === 0 && u8.byteLength === u8.buffer.byteLength) {\n\t return arrayBuffer2Buffer(u8.buffer);\n\t }\n\t else {\n\t return Buffer.from(u8.buffer, u8.byteOffset, u8.byteLength);\n\t }\n\t}\n\t/**\n\t * Converts the given array buffer into a Buffer. Attempts to be\n\t * zero-copy.\n\t * @hidden\n\t */\n\tfunction arrayBuffer2Buffer(ab) {\n\t return Buffer.from(ab);\n\t}\n\t/**\n\t * Copies a slice of the given buffer\n\t * @hidden\n\t */\n\tfunction copyingSlice(buff, start, end) {\n\t if ( start === void 0 ) start = 0;\n\t if ( end === void 0 ) end = buff.length;\n\t\n\t if (start < 0 || end < 0 || end > buff.length || start > end) {\n\t throw new TypeError((\"Invalid slice bounds on buffer of length \" + (buff.length) + \": [\" + start + \", \" + end + \"]\"));\n\t }\n\t if (buff.length === 0) {\n\t // Avoid s0 corner case in ArrayBuffer case.\n\t return emptyBuffer();\n\t }\n\t else {\n\t var u8 = buffer2Uint8array(buff), s0 = buff[0], newS0 = (s0 + 1) % 0xFF;\n\t buff[0] = newS0;\n\t if (u8[0] === newS0) {\n\t // Same memory. Revert & copy.\n\t u8[0] = s0;\n\t return uint8Array2Buffer(u8.slice(start, end));\n\t }\n\t else {\n\t // Revert.\n\t buff[0] = s0;\n\t return uint8Array2Buffer(u8.subarray(start, end));\n\t }\n\t }\n\t}\n\t/**\n\t * @hidden\n\t */\n\tvar emptyBuff = null;\n\t/**\n\t * Returns an empty buffer.\n\t * @hidden\n\t */\n\tfunction emptyBuffer() {\n\t if (emptyBuff) {\n\t return emptyBuff;\n\t }\n\t return emptyBuff = Buffer.alloc(0);\n\t}\n\t/**\n\t * Option validator for a Buffer file system option.\n\t * @hidden\n\t */\n\tfunction bufferValidator(v, cb) {\n\t if (Buffer.isBuffer(v)) {\n\t cb();\n\t }\n\t else {\n\t cb(new ApiError(ErrorCode.EINVAL, \"option must be a Buffer.\"));\n\t }\n\t}\n\t/**\n\t * Checks that the given options object is valid for the file system options.\n\t * @hidden\n\t */\n\tfunction checkOptions(fsType, opts, cb) {\n\t var optsInfo = fsType.Options;\n\t var fsName = fsType.Name;\n\t var pendingValidators = 0;\n\t var callbackCalled = false;\n\t var loopEnded = false;\n\t function validatorCallback(e) {\n\t if (!callbackCalled) {\n\t if (e) {\n\t callbackCalled = true;\n\t cb(e);\n\t }\n\t pendingValidators--;\n\t if (pendingValidators === 0 && loopEnded) {\n\t cb();\n\t }\n\t }\n\t }\n\t // Check for required options.\n\t var loop = function ( optName ) {\n\t if (optsInfo.hasOwnProperty(optName)) {\n\t var opt = optsInfo[optName];\n\t var providedValue = opts[optName];\n\t if (providedValue === undefined || providedValue === null) {\n\t if (!opt.optional) {\n\t // Required option, not provided.\n\t // Any incorrect options provided? Which ones are close to the provided one?\n\t // (edit distance 5 === close)\n\t var incorrectOptions = Object.keys(opts).filter(function (o) { return !(o in optsInfo); }).map(function (a) {\n\t return { str: a, distance: levenshtein(optName, a) };\n\t }).filter(function (o) { return o.distance < 5; }).sort(function (a, b) { return a.distance - b.distance; });\n\t // Validators may be synchronous.\n\t if (callbackCalled) {\n\t return {};\n\t }\n\t callbackCalled = true;\n\t return { v: cb(new ApiError(ErrorCode.EINVAL, (\"[\" + fsName + \"] Required option '\" + optName + \"' not provided.\" + (incorrectOptions.length > 0 ? (\" You provided unrecognized option '\" + (incorrectOptions[0].str) + \"'; perhaps you meant to type '\" + optName + \"'.\") : '') + \"\\nOption description: \" + (opt.description)))) };\n\t }\n\t // Else: Optional option, not provided. That is OK.\n\t }\n\t else {\n\t // Option provided! Check type.\n\t var typeMatches = false;\n\t if (Array.isArray(opt.type)) {\n\t typeMatches = opt.type.indexOf(typeof (providedValue)) !== -1;\n\t }\n\t else {\n\t typeMatches = typeof (providedValue) === opt.type;\n\t }\n\t if (!typeMatches) {\n\t // Validators may be synchronous.\n\t if (callbackCalled) {\n\t return {};\n\t }\n\t callbackCalled = true;\n\t return { v: cb(new ApiError(ErrorCode.EINVAL, (\"[\" + fsName + \"] Value provided for option \" + optName + \" is not the proper type. Expected \" + (Array.isArray(opt.type) ? (\"one of {\" + (opt.type.join(\", \")) + \"}\") : opt.type) + \", but received \" + (typeof (providedValue)) + \"\\nOption description: \" + (opt.description)))) };\n\t }\n\t else if (opt.validator) {\n\t pendingValidators++;\n\t opt.validator(providedValue, validatorCallback);\n\t }\n\t // Otherwise: All good!\n\t }\n\t }\n\t };\n\t\n\t for (var optName in optsInfo) {\n\t var returned = loop( optName );\n\t\n\t if ( returned ) return returned.v;\n\t }\n\t loopEnded = true;\n\t if (pendingValidators === 0 && !callbackCalled) {\n\t cb();\n\t }\n\t}\n\t\n\t\n\tvar BFSUtils = Object.freeze({\n\t\tdeprecationMessage: deprecationMessage,\n\t\tisIE: isIE,\n\t\tisWebWorker: isWebWorker,\n\t\tfail: fail,\n\t\tmkdirpSync: mkdirpSync,\n\t\tbuffer2ArrayBuffer: buffer2ArrayBuffer,\n\t\tbuffer2Uint8array: buffer2Uint8array,\n\t\tarrayish2Buffer: arrayish2Buffer,\n\t\tuint8Array2Buffer: uint8Array2Buffer,\n\t\tarrayBuffer2Buffer: arrayBuffer2Buffer,\n\t\tcopyingSlice: copyingSlice,\n\t\temptyBuffer: emptyBuffer,\n\t\tbufferValidator: bufferValidator,\n\t\tcheckOptions: checkOptions\n\t});\n\t\n\tvar BFSEmscriptenStreamOps = function BFSEmscriptenStreamOps(fs) {\n\t this.fs = fs;\n\t this.nodefs = fs.getNodeFS();\n\t this.FS = fs.getFS();\n\t this.PATH = fs.getPATH();\n\t this.ERRNO_CODES = fs.getERRNO_CODES();\n\t};\n\tBFSEmscriptenStreamOps.prototype.open = function open (stream) {\n\t var path$$1 = this.fs.realPath(stream.node);\n\t var FS = this.FS;\n\t try {\n\t if (FS.isFile(stream.node.mode)) {\n\t stream.nfd = this.nodefs.openSync(path$$1, this.fs.flagsToPermissionString(stream.flags));\n\t }\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t throw new FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t};\n\tBFSEmscriptenStreamOps.prototype.close = function close (stream) {\n\t var FS = this.FS;\n\t try {\n\t if (FS.isFile(stream.node.mode) && stream.nfd) {\n\t this.nodefs.closeSync(stream.nfd);\n\t }\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t throw new FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t};\n\tBFSEmscriptenStreamOps.prototype.read = function read (stream, buffer$$1, offset, length, position) {\n\t // Avoid copying overhead by reading directly into buffer.\n\t try {\n\t return this.nodefs.readSync(stream.nfd, uint8Array2Buffer(buffer$$1), offset, length, position);\n\t }\n\t catch (e) {\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t};\n\tBFSEmscriptenStreamOps.prototype.write = function write (stream, buffer$$1, offset, length, position) {\n\t // Avoid copying overhead.\n\t try {\n\t return this.nodefs.writeSync(stream.nfd, uint8Array2Buffer(buffer$$1), offset, length, position);\n\t }\n\t catch (e) {\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t};\n\tBFSEmscriptenStreamOps.prototype.llseek = function llseek (stream, offset, whence) {\n\t var position = offset;\n\t if (whence === 1) {\n\t position += stream.position;\n\t }\n\t else if (whence === 2) {\n\t if (this.FS.isFile(stream.node.mode)) {\n\t try {\n\t var stat = this.nodefs.fstatSync(stream.nfd);\n\t position += stat.size;\n\t }\n\t catch (e) {\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t }\n\t }\n\t if (position < 0) {\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES.EINVAL);\n\t }\n\t stream.position = position;\n\t return position;\n\t};\n\tvar BFSEmscriptenNodeOps = function BFSEmscriptenNodeOps(fs) {\n\t this.fs = fs;\n\t this.nodefs = fs.getNodeFS();\n\t this.FS = fs.getFS();\n\t this.PATH = fs.getPATH();\n\t this.ERRNO_CODES = fs.getERRNO_CODES();\n\t};\n\tBFSEmscriptenNodeOps.prototype.getattr = function getattr (node) {\n\t var path$$1 = this.fs.realPath(node);\n\t var stat;\n\t try {\n\t stat = this.nodefs.lstatSync(path$$1);\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t return {\n\t dev: stat.dev,\n\t ino: stat.ino,\n\t mode: stat.mode,\n\t nlink: stat.nlink,\n\t uid: stat.uid,\n\t gid: stat.gid,\n\t rdev: stat.rdev,\n\t size: stat.size,\n\t atime: stat.atime,\n\t mtime: stat.mtime,\n\t ctime: stat.ctime,\n\t blksize: stat.blksize,\n\t blocks: stat.blocks\n\t };\n\t};\n\tBFSEmscriptenNodeOps.prototype.setattr = function setattr (node, attr) {\n\t var path$$1 = this.fs.realPath(node);\n\t try {\n\t if (attr.mode !== undefined) {\n\t this.nodefs.chmodSync(path$$1, attr.mode);\n\t // update the common node structure mode as well\n\t node.mode = attr.mode;\n\t }\n\t if (attr.timestamp !== undefined) {\n\t var date = new Date(attr.timestamp);\n\t this.nodefs.utimesSync(path$$1, date, date);\n\t }\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t // Ignore not supported errors. Emscripten does utimesSync when it\n\t // writes files, but never really requires the value to be set.\n\t if (e.code !== \"ENOTSUP\") {\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t }\n\t if (attr.size !== undefined) {\n\t try {\n\t this.nodefs.truncateSync(path$$1, attr.size);\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t }\n\t};\n\tBFSEmscriptenNodeOps.prototype.lookup = function lookup (parent, name) {\n\t var path$$1 = this.PATH.join2(this.fs.realPath(parent), name);\n\t var mode = this.fs.getMode(path$$1);\n\t return this.fs.createNode(parent, name, mode);\n\t};\n\tBFSEmscriptenNodeOps.prototype.mknod = function mknod (parent, name, mode, dev) {\n\t var node = this.fs.createNode(parent, name, mode, dev);\n\t // create the backing node for this in the fs root as well\n\t var path$$1 = this.fs.realPath(node);\n\t try {\n\t if (this.FS.isDir(node.mode)) {\n\t this.nodefs.mkdirSync(path$$1, node.mode);\n\t }\n\t else {\n\t this.nodefs.writeFileSync(path$$1, '', { mode: node.mode });\n\t }\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t return node;\n\t};\n\tBFSEmscriptenNodeOps.prototype.rename = function rename (oldNode, newDir, newName) {\n\t var oldPath = this.fs.realPath(oldNode);\n\t var newPath = this.PATH.join2(this.fs.realPath(newDir), newName);\n\t try {\n\t this.nodefs.renameSync(oldPath, newPath);\n\t // This logic is missing from the original NodeFS,\n\t // causing Emscripten's filesystem to think that the old file still exists.\n\t oldNode.name = newName;\n\t oldNode.parent = newDir;\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t};\n\tBFSEmscriptenNodeOps.prototype.unlink = function unlink (parent, name) {\n\t var path$$1 = this.PATH.join2(this.fs.realPath(parent), name);\n\t try {\n\t this.nodefs.unlinkSync(path$$1);\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t};\n\tBFSEmscriptenNodeOps.prototype.rmdir = function rmdir (parent, name) {\n\t var path$$1 = this.PATH.join2(this.fs.realPath(parent), name);\n\t try {\n\t this.nodefs.rmdirSync(path$$1);\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t};\n\tBFSEmscriptenNodeOps.prototype.readdir = function readdir (node) {\n\t var path$$1 = this.fs.realPath(node);\n\t try {\n\t // Node does not list . and .. in directory listings,\n\t // but Emscripten expects it.\n\t var contents = this.nodefs.readdirSync(path$$1);\n\t contents.push('.', '..');\n\t return contents;\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t};\n\tBFSEmscriptenNodeOps.prototype.symlink = function symlink (parent, newName, oldPath) {\n\t var newPath = this.PATH.join2(this.fs.realPath(parent), newName);\n\t try {\n\t this.nodefs.symlinkSync(oldPath, newPath);\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t};\n\tBFSEmscriptenNodeOps.prototype.readlink = function readlink (node) {\n\t var path$$1 = this.fs.realPath(node);\n\t try {\n\t return this.nodefs.readlinkSync(path$$1);\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t};\n\tvar BFSEmscriptenFS = function BFSEmscriptenFS(_FS, _PATH, _ERRNO_CODES, nodefs) {\n\t if ( _FS === void 0 ) _FS = self['FS'];\n\t if ( _PATH === void 0 ) _PATH = self['PATH'];\n\t if ( _ERRNO_CODES === void 0 ) _ERRNO_CODES = self['ERRNO_CODES'];\n\t if ( nodefs === void 0 ) nodefs = _fsMock;\n\t\n\t // This maps the integer permission modes from http://linux.die.net/man/3/open\n\t // to node.js-specific file open permission strings at http://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback\n\t this.flagsToPermissionStringMap = {\n\t 0 /*O_RDONLY*/: 'r',\n\t 1 /*O_WRONLY*/: 'r+',\n\t 2 /*O_RDWR*/: 'r+',\n\t 64 /*O_CREAT*/: 'r',\n\t 65 /*O_WRONLY|O_CREAT*/: 'r+',\n\t 66 /*O_RDWR|O_CREAT*/: 'r+',\n\t 129 /*O_WRONLY|O_EXCL*/: 'rx+',\n\t 193 /*O_WRONLY|O_CREAT|O_EXCL*/: 'rx+',\n\t 514 /*O_RDWR|O_TRUNC*/: 'w+',\n\t 577 /*O_WRONLY|O_CREAT|O_TRUNC*/: 'w',\n\t 578 /*O_CREAT|O_RDWR|O_TRUNC*/: 'w+',\n\t 705 /*O_WRONLY|O_CREAT|O_EXCL|O_TRUNC*/: 'wx',\n\t 706 /*O_RDWR|O_CREAT|O_EXCL|O_TRUNC*/: 'wx+',\n\t 1024 /*O_APPEND*/: 'a',\n\t 1025 /*O_WRONLY|O_APPEND*/: 'a',\n\t 1026 /*O_RDWR|O_APPEND*/: 'a+',\n\t 1089 /*O_WRONLY|O_CREAT|O_APPEND*/: 'a',\n\t 1090 /*O_RDWR|O_CREAT|O_APPEND*/: 'a+',\n\t 1153 /*O_WRONLY|O_EXCL|O_APPEND*/: 'ax',\n\t 1154 /*O_RDWR|O_EXCL|O_APPEND*/: 'ax+',\n\t 1217 /*O_WRONLY|O_CREAT|O_EXCL|O_APPEND*/: 'ax',\n\t 1218 /*O_RDWR|O_CREAT|O_EXCL|O_APPEND*/: 'ax+',\n\t 4096 /*O_RDONLY|O_DSYNC*/: 'rs',\n\t 4098 /*O_RDWR|O_DSYNC*/: 'rs+'\n\t };\n\t this.nodefs = nodefs;\n\t this.FS = _FS;\n\t this.PATH = _PATH;\n\t this.ERRNO_CODES = _ERRNO_CODES;\n\t this.node_ops = new BFSEmscriptenNodeOps(this);\n\t this.stream_ops = new BFSEmscriptenStreamOps(this);\n\t};\n\tBFSEmscriptenFS.prototype.mount = function mount (m) {\n\t return this.createNode(null, '/', this.getMode(m.opts.root), 0);\n\t};\n\tBFSEmscriptenFS.prototype.createNode = function createNode (parent, name, mode, dev) {\n\t var FS = this.FS;\n\t if (!FS.isDir(mode) && !FS.isFile(mode) && !FS.isLink(mode)) {\n\t throw new FS.ErrnoError(this.ERRNO_CODES.EINVAL);\n\t }\n\t var node = FS.createNode(parent, name, mode);\n\t node.node_ops = this.node_ops;\n\t node.stream_ops = this.stream_ops;\n\t return node;\n\t};\n\tBFSEmscriptenFS.prototype.getMode = function getMode (path$$1) {\n\t var stat;\n\t try {\n\t stat = this.nodefs.lstatSync(path$$1);\n\t }\n\t catch (e) {\n\t if (!e.code) {\n\t throw e;\n\t }\n\t throw new this.FS.ErrnoError(this.ERRNO_CODES[e.code]);\n\t }\n\t return stat.mode;\n\t};\n\tBFSEmscriptenFS.prototype.realPath = function realPath (node) {\n\t var parts = [];\n\t while (node.parent !== node) {\n\t parts.push(node.name);\n\t node = node.parent;\n\t }\n\t parts.push(node.mount.opts.root);\n\t parts.reverse();\n\t return this.PATH.join.apply(null, parts);\n\t};\n\tBFSEmscriptenFS.prototype.flagsToPermissionString = function flagsToPermissionString (flags) {\n\t var parsedFlags = (typeof flags === \"string\") ? parseInt(flags, 10) : flags;\n\t parsedFlags &= 0x1FFF;\n\t if (parsedFlags in this.flagsToPermissionStringMap) {\n\t return this.flagsToPermissionStringMap[parsedFlags];\n\t }\n\t else {\n\t return flags;\n\t }\n\t};\n\tBFSEmscriptenFS.prototype.getNodeFS = function getNodeFS () {\n\t return this.nodefs;\n\t};\n\tBFSEmscriptenFS.prototype.getFS = function getFS () {\n\t return this.FS;\n\t};\n\tBFSEmscriptenFS.prototype.getPATH = function getPATH () {\n\t return this.PATH;\n\t};\n\tBFSEmscriptenFS.prototype.getERRNO_CODES = function getERRNO_CODES () {\n\t return this.ERRNO_CODES;\n\t};\n\t\n\t/**\n\t * Basic filesystem class. Most filesystems should extend this class, as it\n\t * provides default implementations for a handful of methods.\n\t */\n\tvar BaseFileSystem = function BaseFileSystem () {};\n\t\n\tBaseFileSystem.prototype.supportsLinks = function supportsLinks () {\n\t return false;\n\t};\n\tBaseFileSystem.prototype.diskSpace = function diskSpace (p, cb) {\n\t cb(0, 0);\n\t};\n\t/**\n\t * Opens the file at path p with the given flag. The file must exist.\n\t * @param p The path to open.\n\t * @param flag The flag to use when opening the file.\n\t */\n\tBaseFileSystem.prototype.openFile = function openFile (p, flag, cb) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\t/**\n\t * Create the file at path p with the given mode. Then, open it with the given\n\t * flag.\n\t */\n\tBaseFileSystem.prototype.createFile = function createFile (p, flag, mode, cb) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFileSystem.prototype.open = function open (p, flag, mode, cb) {\n\t var this$1 = this;\n\t\n\t var mustBeFile = function (e, stats) {\n\t if (e) {\n\t // File does not exist.\n\t switch (flag.pathNotExistsAction()) {\n\t case ActionType.CREATE_FILE:\n\t // Ensure parent exists.\n\t return this$1.stat(path.dirname(p), false, function (e, parentStats) {\n\t if (e) {\n\t cb(e);\n\t }\n\t else if (parentStats && !parentStats.isDirectory()) {\n\t cb(ApiError.ENOTDIR(path.dirname(p)));\n\t }\n\t else {\n\t this$1.createFile(p, flag, mode, cb);\n\t }\n\t });\n\t case ActionType.THROW_EXCEPTION:\n\t return cb(ApiError.ENOENT(p));\n\t default:\n\t return cb(new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.'));\n\t }\n\t }\n\t else {\n\t // File exists.\n\t if (stats && stats.isDirectory()) {\n\t return cb(ApiError.EISDIR(p));\n\t }\n\t switch (flag.pathExistsAction()) {\n\t case ActionType.THROW_EXCEPTION:\n\t return cb(ApiError.EEXIST(p));\n\t case ActionType.TRUNCATE_FILE:\n\t // NOTE: In a previous implementation, we deleted the file and\n\t // re-created it. However, this created a race condition if another\n\t // asynchronous request was trying to read the file, as the file\n\t // would not exist for a small period of time.\n\t return this$1.openFile(p, flag, function (e, fd) {\n\t if (e) {\n\t cb(e);\n\t }\n\t else if (fd) {\n\t fd.truncate(0, function () {\n\t fd.sync(function () {\n\t cb(null, fd);\n\t });\n\t });\n\t }\n\t else {\n\t fail();\n\t }\n\t });\n\t case ActionType.NOP:\n\t return this$1.openFile(p, flag, cb);\n\t default:\n\t return cb(new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.'));\n\t }\n\t }\n\t };\n\t this.stat(p, false, mustBeFile);\n\t};\n\tBaseFileSystem.prototype.rename = function rename (oldPath, newPath, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFileSystem.prototype.renameSync = function renameSync (oldPath, newPath) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFileSystem.prototype.stat = function stat (p, isLstat, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFileSystem.prototype.statSync = function statSync (p, isLstat) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\t/**\n\t * Opens the file at path p with the given flag. The file must exist.\n\t * @param p The path to open.\n\t * @param flag The flag to use when opening the file.\n\t * @return A File object corresponding to the opened file.\n\t */\n\tBaseFileSystem.prototype.openFileSync = function openFileSync (p, flag, mode) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\t/**\n\t * Create the file at path p with the given mode. Then, open it with the given\n\t * flag.\n\t */\n\tBaseFileSystem.prototype.createFileSync = function createFileSync (p, flag, mode) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFileSystem.prototype.openSync = function openSync (p, flag, mode) {\n\t // Check if the path exists, and is a file.\n\t var stats;\n\t try {\n\t stats = this.statSync(p, false);\n\t }\n\t catch (e) {\n\t // File does not exist.\n\t switch (flag.pathNotExistsAction()) {\n\t case ActionType.CREATE_FILE:\n\t // Ensure parent exists.\n\t var parentStats = this.statSync(path.dirname(p), false);\n\t if (!parentStats.isDirectory()) {\n\t throw ApiError.ENOTDIR(path.dirname(p));\n\t }\n\t return this.createFileSync(p, flag, mode);\n\t case ActionType.THROW_EXCEPTION:\n\t throw ApiError.ENOENT(p);\n\t default:\n\t throw new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.');\n\t }\n\t }\n\t // File exists.\n\t if (stats.isDirectory()) {\n\t throw ApiError.EISDIR(p);\n\t }\n\t switch (flag.pathExistsAction()) {\n\t case ActionType.THROW_EXCEPTION:\n\t throw ApiError.EEXIST(p);\n\t case ActionType.TRUNCATE_FILE:\n\t // Delete file.\n\t this.unlinkSync(p);\n\t // Create file. Use the same mode as the old file.\n\t // Node itself modifies the ctime when this occurs, so this action\n\t // will preserve that behavior if the underlying file system\n\t // supports those properties.\n\t return this.createFileSync(p, flag, stats.mode);\n\t case ActionType.NOP:\n\t return this.openFileSync(p, flag, mode);\n\t default:\n\t throw new ApiError(ErrorCode.EINVAL, 'Invalid FileFlag object.');\n\t }\n\t};\n\tBaseFileSystem.prototype.unlink = function unlink (p, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFileSystem.prototype.unlinkSync = function unlinkSync (p) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFileSystem.prototype.rmdir = function rmdir (p, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFileSystem.prototype.rmdirSync = function rmdirSync (p) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFileSystem.prototype.mkdir = function mkdir (p, mode, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFileSystem.prototype.mkdirSync = function mkdirSync (p, mode) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFileSystem.prototype.readdir = function readdir (p, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFileSystem.prototype.readdirSync = function readdirSync (p) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFileSystem.prototype.exists = function exists (p, cb) {\n\t this.stat(p, null, function (err) {\n\t cb(!err);\n\t });\n\t};\n\tBaseFileSystem.prototype.existsSync = function existsSync (p) {\n\t try {\n\t this.statSync(p, true);\n\t return true;\n\t }\n\t catch (e) {\n\t return false;\n\t }\n\t};\n\tBaseFileSystem.prototype.realpath = function realpath (p, cache, cb) {\n\t if (this.supportsLinks()) {\n\t // The path could contain symlinks. Split up the path,\n\t // resolve any symlinks, return the resolved string.\n\t var splitPath = p.split(path.sep);\n\t // TODO: Simpler to just pass through file, find sep and such.\n\t for (var i = 0; i < splitPath.length; i++) {\n\t var addPaths = splitPath.slice(0, i + 1);\n\t splitPath[i] = path.join.apply(null, addPaths);\n\t }\n\t }\n\t else {\n\t // No symlinks. We just need to verify that it exists.\n\t this.exists(p, function (doesExist) {\n\t if (doesExist) {\n\t cb(null, p);\n\t }\n\t else {\n\t cb(ApiError.ENOENT(p));\n\t }\n\t });\n\t }\n\t};\n\tBaseFileSystem.prototype.realpathSync = function realpathSync (p, cache) {\n\t if (this.supportsLinks()) {\n\t // The path could contain symlinks. Split up the path,\n\t // resolve any symlinks, return the resolved string.\n\t var splitPath = p.split(path.sep);\n\t // TODO: Simpler to just pass through file, find sep and such.\n\t for (var i = 0; i < splitPath.length; i++) {\n\t var addPaths = splitPath.slice(0, i + 1);\n\t splitPath[i] = path.join.apply(path, addPaths);\n\t }\n\t return splitPath.join(path.sep);\n\t }\n\t else {\n\t // No symlinks. We just need to verify that it exists.\n\t if (this.existsSync(p)) {\n\t return p;\n\t }\n\t else {\n\t throw ApiError.ENOENT(p);\n\t }\n\t }\n\t};\n\tBaseFileSystem.prototype.truncate = function truncate (p, len, cb) {\n\t this.open(p, FileFlag.getFileFlag('r+'), 0x1a4, (function (er, fd) {\n\t if (er) {\n\t return cb(er);\n\t }\n\t fd.truncate(len, (function (er) {\n\t fd.close((function (er2) {\n\t cb(er || er2);\n\t }));\n\t }));\n\t }));\n\t};\n\tBaseFileSystem.prototype.truncateSync = function truncateSync (p, len) {\n\t var fd = this.openSync(p, FileFlag.getFileFlag('r+'), 0x1a4);\n\t // Need to safely close FD, regardless of whether or not truncate succeeds.\n\t try {\n\t fd.truncateSync(len);\n\t }\n\t catch (e) {\n\t throw e;\n\t }\n\t finally {\n\t fd.closeSync();\n\t }\n\t};\n\tBaseFileSystem.prototype.readFile = function readFile (fname, encoding, flag, cb) {\n\t // Wrap cb in file closing code.\n\t var oldCb = cb;\n\t // Get file.\n\t this.open(fname, flag, 0x1a4, function (err, fd) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t cb = function (err, arg) {\n\t fd.close(function (err2) {\n\t if (!err) {\n\t err = err2;\n\t }\n\t return oldCb(err, arg);\n\t });\n\t };\n\t fd.stat(function (err, stat) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t // Allocate buffer.\n\t var buf = Buffer.alloc(stat.size);\n\t fd.read(buf, 0, stat.size, 0, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t else if (encoding === null) {\n\t return cb(err, buf);\n\t }\n\t try {\n\t cb(null, buf.toString(encoding));\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t });\n\t });\n\t });\n\t};\n\tBaseFileSystem.prototype.readFileSync = function readFileSync (fname, encoding, flag) {\n\t // Get file.\n\t var fd = this.openSync(fname, flag, 0x1a4);\n\t try {\n\t var stat = fd.statSync();\n\t // Allocate buffer.\n\t var buf = Buffer.alloc(stat.size);\n\t fd.readSync(buf, 0, stat.size, 0);\n\t fd.closeSync();\n\t if (encoding === null) {\n\t return buf;\n\t }\n\t return buf.toString(encoding);\n\t }\n\t finally {\n\t fd.closeSync();\n\t }\n\t};\n\tBaseFileSystem.prototype.writeFile = function writeFile (fname, data, encoding, flag, mode, cb) {\n\t // Wrap cb in file closing code.\n\t var oldCb = cb;\n\t // Get file.\n\t this.open(fname, flag, 0x1a4, function (err, fd) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t cb = function (err) {\n\t fd.close(function (err2) {\n\t oldCb(err ? err : err2);\n\t });\n\t };\n\t try {\n\t if (typeof data === 'string') {\n\t data = Buffer.from(data, encoding);\n\t }\n\t }\n\t catch (e) {\n\t return cb(e);\n\t }\n\t // Write into file.\n\t fd.write(data, 0, data.length, 0, cb);\n\t });\n\t};\n\tBaseFileSystem.prototype.writeFileSync = function writeFileSync (fname, data, encoding, flag, mode) {\n\t // Get file.\n\t var fd = this.openSync(fname, flag, mode);\n\t try {\n\t if (typeof data === 'string') {\n\t data = Buffer.from(data, encoding);\n\t }\n\t // Write into file.\n\t fd.writeSync(data, 0, data.length, 0);\n\t }\n\t finally {\n\t fd.closeSync();\n\t }\n\t};\n\tBaseFileSystem.prototype.appendFile = function appendFile (fname, data, encoding, flag, mode, cb) {\n\t // Wrap cb in file closing code.\n\t var oldCb = cb;\n\t this.open(fname, flag, mode, function (err, fd) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t cb = function (err) {\n\t fd.close(function (err2) {\n\t oldCb(err ? err : err2);\n\t });\n\t };\n\t if (typeof data === 'string') {\n\t data = Buffer.from(data, encoding);\n\t }\n\t fd.write(data, 0, data.length, null, cb);\n\t });\n\t};\n\tBaseFileSystem.prototype.appendFileSync = function appendFileSync (fname, data, encoding, flag, mode) {\n\t var fd = this.openSync(fname, flag, mode);\n\t try {\n\t if (typeof data === 'string') {\n\t data = Buffer.from(data, encoding);\n\t }\n\t fd.writeSync(data, 0, data.length, null);\n\t }\n\t finally {\n\t fd.closeSync();\n\t }\n\t};\n\tBaseFileSystem.prototype.chmod = function chmod (p, isLchmod, mode, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFileSystem.prototype.chmodSync = function chmodSync (p, isLchmod, mode) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFileSystem.prototype.chown = function chown (p, isLchown, uid, gid, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFileSystem.prototype.chownSync = function chownSync (p, isLchown, uid, gid) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFileSystem.prototype.utimes = function utimes (p, atime, mtime, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFileSystem.prototype.utimesSync = function utimesSync (p, atime, mtime) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFileSystem.prototype.link = function link (srcpath, dstpath, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFileSystem.prototype.linkSync = function linkSync (srcpath, dstpath) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFileSystem.prototype.symlink = function symlink (srcpath, dstpath, type, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFileSystem.prototype.symlinkSync = function symlinkSync (srcpath, dstpath, type) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFileSystem.prototype.readlink = function readlink (p, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFileSystem.prototype.readlinkSync = function readlinkSync (p) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\t/**\n\t * Implements the asynchronous API in terms of the synchronous API.\n\t * @class SynchronousFileSystem\n\t */\n\tvar SynchronousFileSystem = (function (BaseFileSystem) {\n\t function SynchronousFileSystem () {\n\t BaseFileSystem.apply(this, arguments);\n\t }\n\t\n\t if ( BaseFileSystem ) SynchronousFileSystem.__proto__ = BaseFileSystem;\n\t SynchronousFileSystem.prototype = Object.create( BaseFileSystem && BaseFileSystem.prototype );\n\t SynchronousFileSystem.prototype.constructor = SynchronousFileSystem;\n\t\n\t SynchronousFileSystem.prototype.supportsSynch = function supportsSynch () {\n\t return true;\n\t };\n\t SynchronousFileSystem.prototype.rename = function rename (oldPath, newPath, cb) {\n\t try {\n\t this.renameSync(oldPath, newPath);\n\t cb();\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t SynchronousFileSystem.prototype.stat = function stat (p, isLstat, cb) {\n\t try {\n\t cb(null, this.statSync(p, isLstat));\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t SynchronousFileSystem.prototype.open = function open (p, flags, mode, cb) {\n\t try {\n\t cb(null, this.openSync(p, flags, mode));\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t SynchronousFileSystem.prototype.unlink = function unlink (p, cb) {\n\t try {\n\t this.unlinkSync(p);\n\t cb();\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t SynchronousFileSystem.prototype.rmdir = function rmdir (p, cb) {\n\t try {\n\t this.rmdirSync(p);\n\t cb();\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t SynchronousFileSystem.prototype.mkdir = function mkdir (p, mode, cb) {\n\t try {\n\t this.mkdirSync(p, mode);\n\t cb();\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t SynchronousFileSystem.prototype.readdir = function readdir (p, cb) {\n\t try {\n\t cb(null, this.readdirSync(p));\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t SynchronousFileSystem.prototype.chmod = function chmod (p, isLchmod, mode, cb) {\n\t try {\n\t this.chmodSync(p, isLchmod, mode);\n\t cb();\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t SynchronousFileSystem.prototype.chown = function chown (p, isLchown, uid, gid, cb) {\n\t try {\n\t this.chownSync(p, isLchown, uid, gid);\n\t cb();\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t SynchronousFileSystem.prototype.utimes = function utimes (p, atime, mtime, cb) {\n\t try {\n\t this.utimesSync(p, atime, mtime);\n\t cb();\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t SynchronousFileSystem.prototype.link = function link (srcpath, dstpath, cb) {\n\t try {\n\t this.linkSync(srcpath, dstpath);\n\t cb();\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t SynchronousFileSystem.prototype.symlink = function symlink (srcpath, dstpath, type, cb) {\n\t try {\n\t this.symlinkSync(srcpath, dstpath, type);\n\t cb();\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t SynchronousFileSystem.prototype.readlink = function readlink (p, cb) {\n\t try {\n\t cb(null, this.readlinkSync(p));\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t\n\t return SynchronousFileSystem;\n\t}(BaseFileSystem));\n\t\n\t/**\n\t * Base class that contains shared implementations of functions for the file\n\t * object.\n\t */\n\tvar BaseFile = function BaseFile () {};\n\t\n\tBaseFile.prototype.sync = function sync (cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFile.prototype.syncSync = function syncSync () {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFile.prototype.datasync = function datasync (cb) {\n\t this.sync(cb);\n\t};\n\tBaseFile.prototype.datasyncSync = function datasyncSync () {\n\t return this.syncSync();\n\t};\n\tBaseFile.prototype.chown = function chown (uid, gid, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFile.prototype.chownSync = function chownSync (uid, gid) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFile.prototype.chmod = function chmod (mode, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFile.prototype.chmodSync = function chmodSync (mode) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\tBaseFile.prototype.utimes = function utimes (atime, mtime, cb) {\n\t cb(new ApiError(ErrorCode.ENOTSUP));\n\t};\n\tBaseFile.prototype.utimesSync = function utimesSync (atime, mtime) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t};\n\t\n\t/**\n\t * An implementation of the File interface that operates on a file that is\n\t * completely in-memory. PreloadFiles are backed by a Buffer.\n\t *\n\t * This is also an abstract class, as it lacks an implementation of 'sync' and\n\t * 'close'. Each filesystem that wishes to use this file representation must\n\t * extend this class and implement those two methods.\n\t * @todo 'close' lever that disables functionality once closed.\n\t */\n\tvar PreloadFile = (function (BaseFile$$1) {\n\t function PreloadFile(_fs, _path, _flag, _stat, contents) {\n\t BaseFile$$1.call(this);\n\t this._pos = 0;\n\t this._dirty = false;\n\t this._fs = _fs;\n\t this._path = _path;\n\t this._flag = _flag;\n\t this._stat = _stat;\n\t if (contents) {\n\t this._buffer = contents;\n\t }\n\t else {\n\t // Empty buffer. It'll expand once we write stuff to it.\n\t this._buffer = emptyBuffer();\n\t }\n\t // Note: This invariant is *not* maintained once the file starts getting\n\t // modified.\n\t // Note: Only actually matters if file is readable, as writeable modes may\n\t // truncate/append to file.\n\t if (this._stat.size !== this._buffer.length && this._flag.isReadable()) {\n\t throw new Error((\"Invalid buffer: Buffer is \" + (this._buffer.length) + \" long, yet Stats object specifies that file is \" + (this._stat.size) + \" long.\"));\n\t }\n\t }\n\t\n\t if ( BaseFile$$1 ) PreloadFile.__proto__ = BaseFile$$1;\n\t PreloadFile.prototype = Object.create( BaseFile$$1 && BaseFile$$1.prototype );\n\t PreloadFile.prototype.constructor = PreloadFile;\n\t /**\n\t * NONSTANDARD: Get the underlying buffer for this file. !!DO NOT MUTATE!! Will mess up dirty tracking.\n\t */\n\t PreloadFile.prototype.getBuffer = function getBuffer () {\n\t return this._buffer;\n\t };\n\t /**\n\t * NONSTANDARD: Get underlying stats for this file. !!DO NOT MUTATE!!\n\t */\n\t PreloadFile.prototype.getStats = function getStats () {\n\t return this._stat;\n\t };\n\t PreloadFile.prototype.getFlag = function getFlag () {\n\t return this._flag;\n\t };\n\t /**\n\t * Get the path to this file.\n\t * @return [String] The path to the file.\n\t */\n\t PreloadFile.prototype.getPath = function getPath () {\n\t return this._path;\n\t };\n\t /**\n\t * Get the current file position.\n\t *\n\t * We emulate the following bug mentioned in the Node documentation:\n\t * > On Linux, positional writes don't work when the file is opened in append\n\t * mode. The kernel ignores the position argument and always appends the data\n\t * to the end of the file.\n\t * @return [Number] The current file position.\n\t */\n\t PreloadFile.prototype.getPos = function getPos () {\n\t if (this._flag.isAppendable()) {\n\t return this._stat.size;\n\t }\n\t return this._pos;\n\t };\n\t /**\n\t * Advance the current file position by the indicated number of positions.\n\t * @param [Number] delta\n\t */\n\t PreloadFile.prototype.advancePos = function advancePos (delta) {\n\t return this._pos += delta;\n\t };\n\t /**\n\t * Set the file position.\n\t * @param [Number] newPos\n\t */\n\t PreloadFile.prototype.setPos = function setPos (newPos) {\n\t return this._pos = newPos;\n\t };\n\t /**\n\t * **Core**: Asynchronous sync. Must be implemented by subclasses of this\n\t * class.\n\t * @param [Function(BrowserFS.ApiError)] cb\n\t */\n\t PreloadFile.prototype.sync = function sync (cb) {\n\t try {\n\t this.syncSync();\n\t cb();\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t /**\n\t * **Core**: Synchronous sync.\n\t */\n\t PreloadFile.prototype.syncSync = function syncSync () {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t };\n\t /**\n\t * **Core**: Asynchronous close. Must be implemented by subclasses of this\n\t * class.\n\t * @param [Function(BrowserFS.ApiError)] cb\n\t */\n\t PreloadFile.prototype.close = function close (cb) {\n\t try {\n\t this.closeSync();\n\t cb();\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t /**\n\t * **Core**: Synchronous close.\n\t */\n\t PreloadFile.prototype.closeSync = function closeSync () {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t };\n\t /**\n\t * Asynchronous `stat`.\n\t * @param [Function(BrowserFS.ApiError, BrowserFS.node.fs.Stats)] cb\n\t */\n\t PreloadFile.prototype.stat = function stat (cb) {\n\t try {\n\t cb(null, this._stat.clone());\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t /**\n\t * Synchronous `stat`.\n\t */\n\t PreloadFile.prototype.statSync = function statSync () {\n\t return this._stat.clone();\n\t };\n\t /**\n\t * Asynchronous truncate.\n\t * @param [Number] len\n\t * @param [Function(BrowserFS.ApiError)] cb\n\t */\n\t PreloadFile.prototype.truncate = function truncate (len, cb) {\n\t try {\n\t this.truncateSync(len);\n\t if (this._flag.isSynchronous() && !_fsMock.getRootFS().supportsSynch()) {\n\t this.sync(cb);\n\t }\n\t cb();\n\t }\n\t catch (e) {\n\t return cb(e);\n\t }\n\t };\n\t /**\n\t * Synchronous truncate.\n\t * @param [Number] len\n\t */\n\t PreloadFile.prototype.truncateSync = function truncateSync (len) {\n\t this._dirty = true;\n\t if (!this._flag.isWriteable()) {\n\t throw new ApiError(ErrorCode.EPERM, 'File not opened with a writeable mode.');\n\t }\n\t this._stat.mtime = new Date();\n\t if (len > this._buffer.length) {\n\t var buf = Buffer.alloc(len - this._buffer.length, 0);\n\t // Write will set @_stat.size for us.\n\t this.writeSync(buf, 0, buf.length, this._buffer.length);\n\t if (this._flag.isSynchronous() && _fsMock.getRootFS().supportsSynch()) {\n\t this.syncSync();\n\t }\n\t return;\n\t }\n\t this._stat.size = len;\n\t // Truncate buffer to 'len'.\n\t var newBuff = Buffer.alloc(len);\n\t this._buffer.copy(newBuff, 0, 0, len);\n\t this._buffer = newBuff;\n\t if (this._flag.isSynchronous() && _fsMock.getRootFS().supportsSynch()) {\n\t this.syncSync();\n\t }\n\t };\n\t /**\n\t * Write buffer to the file.\n\t * Note that it is unsafe to use fs.write multiple times on the same file\n\t * without waiting for the callback.\n\t * @param [BrowserFS.node.Buffer] buffer Buffer containing the data to write to\n\t * the file.\n\t * @param [Number] offset Offset in the buffer to start reading data from.\n\t * @param [Number] length The amount of bytes to write to the file.\n\t * @param [Number] position Offset from the beginning of the file where this\n\t * data should be written. If position is null, the data will be written at\n\t * the current position.\n\t * @param [Function(BrowserFS.ApiError, Number, BrowserFS.node.Buffer)]\n\t * cb The number specifies the number of bytes written into the file.\n\t */\n\t PreloadFile.prototype.write = function write (buffer$$1, offset, length, position, cb) {\n\t try {\n\t cb(null, this.writeSync(buffer$$1, offset, length, position), buffer$$1);\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t /**\n\t * Write buffer to the file.\n\t * Note that it is unsafe to use fs.writeSync multiple times on the same file\n\t * without waiting for the callback.\n\t * @param [BrowserFS.node.Buffer] buffer Buffer containing the data to write to\n\t * the file.\n\t * @param [Number] offset Offset in the buffer to start reading data from.\n\t * @param [Number] length The amount of bytes to write to the file.\n\t * @param [Number] position Offset from the beginning of the file where this\n\t * data should be written. If position is null, the data will be written at\n\t * the current position.\n\t * @return [Number]\n\t */\n\t PreloadFile.prototype.writeSync = function writeSync (buffer$$1, offset, length, position) {\n\t this._dirty = true;\n\t if (position === undefined || position === null) {\n\t position = this.getPos();\n\t }\n\t if (!this._flag.isWriteable()) {\n\t throw new ApiError(ErrorCode.EPERM, 'File not opened with a writeable mode.');\n\t }\n\t var endFp = position + length;\n\t if (endFp > this._stat.size) {\n\t this._stat.size = endFp;\n\t if (endFp > this._buffer.length) {\n\t // Extend the buffer!\n\t var newBuff = Buffer.alloc(endFp);\n\t this._buffer.copy(newBuff);\n\t this._buffer = newBuff;\n\t }\n\t }\n\t var len = buffer$$1.copy(this._buffer, position, offset, offset + length);\n\t this._stat.mtime = new Date();\n\t if (this._flag.isSynchronous()) {\n\t this.syncSync();\n\t return len;\n\t }\n\t this.setPos(position + len);\n\t return len;\n\t };\n\t /**\n\t * Read data from the file.\n\t * @param [BrowserFS.node.Buffer] buffer The buffer that the data will be\n\t * written to.\n\t * @param [Number] offset The offset within the buffer where writing will\n\t * start.\n\t * @param [Number] length An integer specifying the number of bytes to read.\n\t * @param [Number] position An integer specifying where to begin reading from\n\t * in the file. If position is null, data will be read from the current file\n\t * position.\n\t * @param [Function(BrowserFS.ApiError, Number, BrowserFS.node.Buffer)] cb The\n\t * number is the number of bytes read\n\t */\n\t PreloadFile.prototype.read = function read (buffer$$1, offset, length, position, cb) {\n\t try {\n\t cb(null, this.readSync(buffer$$1, offset, length, position), buffer$$1);\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t /**\n\t * Read data from the file.\n\t * @param [BrowserFS.node.Buffer] buffer The buffer that the data will be\n\t * written to.\n\t * @param [Number] offset The offset within the buffer where writing will\n\t * start.\n\t * @param [Number] length An integer specifying the number of bytes to read.\n\t * @param [Number] position An integer specifying where to begin reading from\n\t * in the file. If position is null, data will be read from the current file\n\t * position.\n\t * @return [Number]\n\t */\n\t PreloadFile.prototype.readSync = function readSync (buffer$$1, offset, length, position) {\n\t if (!this._flag.isReadable()) {\n\t throw new ApiError(ErrorCode.EPERM, 'File not opened with a readable mode.');\n\t }\n\t if (position === undefined || position === null) {\n\t position = this.getPos();\n\t }\n\t var endRead = position + length;\n\t if (endRead > this._stat.size) {\n\t length = this._stat.size - position;\n\t }\n\t var rv = this._buffer.copy(buffer$$1, offset, position, position + length);\n\t this._stat.atime = new Date();\n\t this._pos = position + length;\n\t return rv;\n\t };\n\t /**\n\t * Asynchronous `fchmod`.\n\t * @param [Number|String] mode\n\t * @param [Function(BrowserFS.ApiError)] cb\n\t */\n\t PreloadFile.prototype.chmod = function chmod (mode, cb) {\n\t try {\n\t this.chmodSync(mode);\n\t cb();\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t /**\n\t * Asynchronous `fchmod`.\n\t * @param [Number] mode\n\t */\n\t PreloadFile.prototype.chmodSync = function chmodSync (mode) {\n\t if (!this._fs.supportsProps()) {\n\t throw new ApiError(ErrorCode.ENOTSUP);\n\t }\n\t this._dirty = true;\n\t this._stat.chmod(mode);\n\t this.syncSync();\n\t };\n\t PreloadFile.prototype.isDirty = function isDirty () {\n\t return this._dirty;\n\t };\n\t /**\n\t * Resets the dirty bit. Should only be called after a sync has completed successfully.\n\t */\n\t PreloadFile.prototype.resetDirty = function resetDirty () {\n\t this._dirty = false;\n\t };\n\t\n\t return PreloadFile;\n\t}(BaseFile));\n\t\n\t/**\n\t * File class for the InMemory and XHR file systems.\n\t * Doesn't sync to anything, so it works nicely for memory-only files.\n\t */\n\tvar NoSyncFile = (function (PreloadFile) {\n\t function NoSyncFile(_fs, _path, _flag, _stat, contents) {\n\t PreloadFile.call(this, _fs, _path, _flag, _stat, contents);\n\t }\n\t\n\t if ( PreloadFile ) NoSyncFile.__proto__ = PreloadFile;\n\t NoSyncFile.prototype = Object.create( PreloadFile && PreloadFile.prototype );\n\t NoSyncFile.prototype.constructor = NoSyncFile;\n\t /**\n\t * Asynchronous sync. Doesn't do anything, simply calls the cb.\n\t * @param [Function(BrowserFS.ApiError)] cb\n\t */\n\t NoSyncFile.prototype.sync = function sync (cb) {\n\t cb();\n\t };\n\t /**\n\t * Synchronous sync. Doesn't do anything.\n\t */\n\t NoSyncFile.prototype.syncSync = function syncSync () {\n\t // NOP.\n\t };\n\t /**\n\t * Asynchronous close. Doesn't do anything, simply calls the cb.\n\t * @param [Function(BrowserFS.ApiError)] cb\n\t */\n\t NoSyncFile.prototype.close = function close (cb) {\n\t cb();\n\t };\n\t /**\n\t * Synchronous close. Doesn't do anything.\n\t */\n\t NoSyncFile.prototype.closeSync = function closeSync () {\n\t // NOP.\n\t };\n\t\n\t return NoSyncFile;\n\t}(PreloadFile));\n\t\n\t/**\n\t * We define our own file to interpose on syncSync() for mirroring purposes.\n\t */\n\tvar MirrorFile = (function (PreloadFile$$1) {\n\t function MirrorFile(fs, path$$1, flag, stat, data) {\n\t PreloadFile$$1.call(this, fs, path$$1, flag, stat, data);\n\t }\n\t\n\t if ( PreloadFile$$1 ) MirrorFile.__proto__ = PreloadFile$$1;\n\t MirrorFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );\n\t MirrorFile.prototype.constructor = MirrorFile;\n\t MirrorFile.prototype.syncSync = function syncSync () {\n\t if (this.isDirty()) {\n\t this._fs._syncSync(this);\n\t this.resetDirty();\n\t }\n\t };\n\t MirrorFile.prototype.closeSync = function closeSync () {\n\t this.syncSync();\n\t };\n\t\n\t return MirrorFile;\n\t}(PreloadFile));\n\t/**\n\t * AsyncMirrorFS mirrors a synchronous filesystem into an asynchronous filesystem\n\t * by:\n\t *\n\t * * Performing operations over the in-memory copy, while asynchronously pipelining them\n\t * to the backing store.\n\t * * During application loading, the contents of the async file system can be reloaded into\n\t * the synchronous store, if desired.\n\t *\n\t * The two stores will be kept in sync. The most common use-case is to pair a synchronous\n\t * in-memory filesystem with an asynchronous backing store.\n\t *\n\t * Example: Mirroring an IndexedDB file system to an in memory file system. Now, you can use\n\t * IndexedDB synchronously.\n\t *\n\t * ```javascript\n\t * BrowserFS.configure({\n\t * fs: \"AsyncMirror\",\n\t * options: {\n\t * sync: { fs: \"InMemory\" },\n\t * async: { fs: \"IndexedDB\" }\n\t * }\n\t * }, function(e) {\n\t * // BrowserFS is initialized and ready-to-use!\n\t * });\n\t * ```\n\t *\n\t * Or, alternatively:\n\t *\n\t * ```javascript\n\t * BrowserFS.FileSystem.IndexedDB.Create(function(e, idbfs) {\n\t * BrowserFS.FileSystem.InMemory.Create(function(e, inMemory) {\n\t * BrowserFS.FileSystem.AsyncMirror({\n\t * sync: inMemory, async: idbfs\n\t * }, function(e, mirrored) {\n\t * BrowserFS.initialize(mirrored);\n\t * });\n\t * });\n\t * });\n\t * ```\n\t */\n\tvar AsyncMirror = (function (SynchronousFileSystem$$1) {\n\t function AsyncMirror(sync, async, deprecateMsg) {\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t SynchronousFileSystem$$1.call(this);\n\t /**\n\t * Queue of pending asynchronous operations.\n\t */\n\t this._queue = [];\n\t this._queueRunning = false;\n\t this._isInitialized = false;\n\t this._initializeCallbacks = [];\n\t this._sync = sync;\n\t this._async = async;\n\t if (!sync.supportsSynch()) {\n\t throw new Error(\"The first argument to AsyncMirror needs to be a synchronous file system.\");\n\t }\n\t deprecationMessage(deprecateMsg, AsyncMirror.Name, { sync: \"sync file system instance\", async: \"async file system instance\" });\n\t }\n\t\n\t if ( SynchronousFileSystem$$1 ) AsyncMirror.__proto__ = SynchronousFileSystem$$1;\n\t AsyncMirror.prototype = Object.create( SynchronousFileSystem$$1 && SynchronousFileSystem$$1.prototype );\n\t AsyncMirror.prototype.constructor = AsyncMirror;\n\t /**\n\t * Constructs and initializes an AsyncMirror file system with the given options.\n\t */\n\t AsyncMirror.Create = function Create (opts, cb) {\n\t try {\n\t var fs = new AsyncMirror(opts.sync, opts.async, false);\n\t fs.initialize(function (e) {\n\t if (e) {\n\t cb(e);\n\t }\n\t else {\n\t cb(null, fs);\n\t }\n\t }, false);\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t AsyncMirror.isAvailable = function isAvailable () {\n\t return true;\n\t };\n\t AsyncMirror.prototype.getName = function getName () {\n\t return AsyncMirror.Name;\n\t };\n\t AsyncMirror.prototype._syncSync = function _syncSync (fd) {\n\t this._sync.writeFileSync(fd.getPath(), fd.getBuffer(), null, FileFlag.getFileFlag('w'), fd.getStats().mode);\n\t this.enqueueOp({\n\t apiMethod: 'writeFile',\n\t arguments: [fd.getPath(), fd.getBuffer(), null, fd.getFlag(), fd.getStats().mode]\n\t });\n\t };\n\t /**\n\t * Called once to load up files from async storage into sync storage.\n\t */\n\t AsyncMirror.prototype.initialize = function initialize (userCb, deprecateMsg) {\n\t var this$1 = this;\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t if (deprecateMsg) {\n\t console.warn(\"[AsyncMirror] AsyncMirror.initialize() is deprecated and will be removed in the next major version. Please use 'AsyncMirror.Create({ sync: (sync file system instance), async: (async file system instance)}, cb)' to create and initialize AsyncMirror instances.\");\n\t }\n\t var callbacks = this._initializeCallbacks;\n\t var end = function (e) {\n\t this$1._isInitialized = !e;\n\t this$1._initializeCallbacks = [];\n\t callbacks.forEach(function (cb) { return cb(e); });\n\t };\n\t if (!this._isInitialized) {\n\t // First call triggers initialization, the rest wait.\n\t if (callbacks.push(userCb) === 1) {\n\t var copyDirectory = function (p, mode, cb) {\n\t if (p !== '/') {\n\t this$1._sync.mkdirSync(p, mode);\n\t }\n\t this$1._async.readdir(p, function (err, files) {\n\t var i = 0;\n\t // NOTE: This function must not be in a lexically nested statement,\n\t // such as an if or while statement. Safari refuses to run the\n\t // script since it is undefined behavior.\n\t function copyNextFile(err) {\n\t if (err) {\n\t cb(err);\n\t }\n\t else if (i < files.length) {\n\t copyItem(path.join(p, files[i]), copyNextFile);\n\t i++;\n\t }\n\t else {\n\t cb();\n\t }\n\t }\n\t if (err) {\n\t cb(err);\n\t }\n\t else {\n\t copyNextFile();\n\t }\n\t });\n\t }, copyFile = function (p, mode, cb) {\n\t this$1._async.readFile(p, null, FileFlag.getFileFlag('r'), function (err, data) {\n\t if (err) {\n\t cb(err);\n\t }\n\t else {\n\t try {\n\t this$1._sync.writeFileSync(p, data, null, FileFlag.getFileFlag('w'), mode);\n\t }\n\t catch (e) {\n\t err = e;\n\t }\n\t finally {\n\t cb(err);\n\t }\n\t }\n\t });\n\t }, copyItem = function (p, cb) {\n\t this$1._async.stat(p, false, function (err, stats) {\n\t if (err) {\n\t cb(err);\n\t }\n\t else if (stats.isDirectory()) {\n\t copyDirectory(p, stats.mode, cb);\n\t }\n\t else {\n\t copyFile(p, stats.mode, cb);\n\t }\n\t });\n\t };\n\t copyDirectory('/', 0, end);\n\t }\n\t }\n\t else {\n\t userCb();\n\t }\n\t };\n\t AsyncMirror.prototype.isReadOnly = function isReadOnly () { return false; };\n\t AsyncMirror.prototype.supportsSynch = function supportsSynch () { return true; };\n\t AsyncMirror.prototype.supportsLinks = function supportsLinks () { return false; };\n\t AsyncMirror.prototype.supportsProps = function supportsProps () { return this._sync.supportsProps() && this._async.supportsProps(); };\n\t AsyncMirror.prototype.renameSync = function renameSync (oldPath, newPath) {\n\t this.checkInitialized();\n\t this._sync.renameSync(oldPath, newPath);\n\t this.enqueueOp({\n\t apiMethod: 'rename',\n\t arguments: [oldPath, newPath]\n\t });\n\t };\n\t AsyncMirror.prototype.statSync = function statSync (p, isLstat) {\n\t this.checkInitialized();\n\t return this._sync.statSync(p, isLstat);\n\t };\n\t AsyncMirror.prototype.openSync = function openSync (p, flag, mode) {\n\t this.checkInitialized();\n\t // Sanity check: Is this open/close permitted?\n\t var fd = this._sync.openSync(p, flag, mode);\n\t fd.closeSync();\n\t return new MirrorFile(this, p, flag, this._sync.statSync(p, false), this._sync.readFileSync(p, null, FileFlag.getFileFlag('r')));\n\t };\n\t AsyncMirror.prototype.unlinkSync = function unlinkSync (p) {\n\t this.checkInitialized();\n\t this._sync.unlinkSync(p);\n\t this.enqueueOp({\n\t apiMethod: 'unlink',\n\t arguments: [p]\n\t });\n\t };\n\t AsyncMirror.prototype.rmdirSync = function rmdirSync (p) {\n\t this.checkInitialized();\n\t this._sync.rmdirSync(p);\n\t this.enqueueOp({\n\t apiMethod: 'rmdir',\n\t arguments: [p]\n\t });\n\t };\n\t AsyncMirror.prototype.mkdirSync = function mkdirSync (p, mode) {\n\t this.checkInitialized();\n\t this._sync.mkdirSync(p, mode);\n\t this.enqueueOp({\n\t apiMethod: 'mkdir',\n\t arguments: [p, mode]\n\t });\n\t };\n\t AsyncMirror.prototype.readdirSync = function readdirSync (p) {\n\t this.checkInitialized();\n\t return this._sync.readdirSync(p);\n\t };\n\t AsyncMirror.prototype.existsSync = function existsSync (p) {\n\t this.checkInitialized();\n\t return this._sync.existsSync(p);\n\t };\n\t AsyncMirror.prototype.chmodSync = function chmodSync (p, isLchmod, mode) {\n\t this.checkInitialized();\n\t this._sync.chmodSync(p, isLchmod, mode);\n\t this.enqueueOp({\n\t apiMethod: 'chmod',\n\t arguments: [p, isLchmod, mode]\n\t });\n\t };\n\t AsyncMirror.prototype.chownSync = function chownSync (p, isLchown, uid, gid) {\n\t this.checkInitialized();\n\t this._sync.chownSync(p, isLchown, uid, gid);\n\t this.enqueueOp({\n\t apiMethod: 'chown',\n\t arguments: [p, isLchown, uid, gid]\n\t });\n\t };\n\t AsyncMirror.prototype.utimesSync = function utimesSync (p, atime, mtime) {\n\t this.checkInitialized();\n\t this._sync.utimesSync(p, atime, mtime);\n\t this.enqueueOp({\n\t apiMethod: 'utimes',\n\t arguments: [p, atime, mtime]\n\t });\n\t };\n\t AsyncMirror.prototype.checkInitialized = function checkInitialized () {\n\t if (!this._isInitialized) {\n\t throw new ApiError(ErrorCode.EPERM, \"AsyncMirrorFS is not initialized. Please initialize AsyncMirrorFS using its initialize() method before using it.\");\n\t }\n\t };\n\t AsyncMirror.prototype.enqueueOp = function enqueueOp (op) {\n\t var this$1 = this;\n\t\n\t this._queue.push(op);\n\t if (!this._queueRunning) {\n\t this._queueRunning = true;\n\t var doNextOp = function (err) {\n\t if (err) {\n\t console.error((\"WARNING: File system has desynchronized. Received following error: \" + err + \"\\n$\"));\n\t }\n\t if (this$1._queue.length > 0) {\n\t var op = this$1._queue.shift(), args = op.arguments;\n\t args.push(doNextOp);\n\t this$1._async[op.apiMethod].apply(this$1._async, args);\n\t }\n\t else {\n\t this$1._queueRunning = false;\n\t }\n\t };\n\t doNextOp();\n\t }\n\t };\n\t\n\t return AsyncMirror;\n\t}(SynchronousFileSystem));\n\t\n\tAsyncMirror.Name = \"AsyncMirror\";\n\tAsyncMirror.Options = {\n\t sync: {\n\t type: \"object\",\n\t description: \"The synchronous file system to mirror the asynchronous file system to.\"\n\t },\n\t async: {\n\t type: \"object\",\n\t description: \"The asynchronous file system to mirror.\"\n\t }\n\t};\n\t\n\t/**\n\t * A faster alternative to `Function#apply`, this function invokes `func`\n\t * with the `this` binding of `thisArg` and the arguments of `args`.\n\t *\n\t * @private\n\t * @param {Function} func The function to invoke.\n\t * @param {*} thisArg The `this` binding of `func`.\n\t * @param {Array} args The arguments to invoke `func` with.\n\t * @returns {*} Returns the result of `func`.\n\t */\n\tfunction apply(func, thisArg, args) {\n\t switch (args.length) {\n\t case 0: return func.call(thisArg);\n\t case 1: return func.call(thisArg, args[0]);\n\t case 2: return func.call(thisArg, args[0], args[1]);\n\t case 3: return func.call(thisArg, args[0], args[1], args[2]);\n\t }\n\t return func.apply(thisArg, args);\n\t}\n\t\n\t/* Built-in method references for those with the same name as other `lodash` methods. */\n\tvar nativeMax = Math.max;\n\t\n\t/**\n\t * A specialized version of `baseRest` which transforms the rest array.\n\t *\n\t * @private\n\t * @param {Function} func The function to apply a rest parameter to.\n\t * @param {number} [start=func.length-1] The start position of the rest parameter.\n\t * @param {Function} transform The rest array transform.\n\t * @returns {Function} Returns the new function.\n\t */\n\tfunction overRest$1(func, start, transform) {\n\t start = nativeMax(start === undefined ? (func.length - 1) : start, 0);\n\t return function() {\n\t var args = arguments,\n\t index = -1,\n\t length = nativeMax(args.length - start, 0),\n\t array = Array(length);\n\t\n\t while (++index < length) {\n\t array[index] = args[start + index];\n\t }\n\t index = -1;\n\t var otherArgs = Array(start + 1);\n\t while (++index < start) {\n\t otherArgs[index] = args[index];\n\t }\n\t otherArgs[start] = transform(array);\n\t return apply(func, this, otherArgs);\n\t };\n\t}\n\t\n\t/**\n\t * This method returns the first argument it receives.\n\t *\n\t * @static\n\t * @since 0.1.0\n\t * @memberOf _\n\t * @category Util\n\t * @param {*} value Any value.\n\t * @returns {*} Returns `value`.\n\t * @example\n\t *\n\t * var object = { 'a': 1 };\n\t *\n\t * console.log(_.identity(object) === object);\n\t * // => true\n\t */\n\tfunction identity(value) {\n\t return value;\n\t}\n\t\n\t// Lodash rest function without function.toString()\n\t// remappings\n\tfunction rest(func, start) {\n\t return overRest$1(func, start, identity);\n\t}\n\t\n\tvar initialParams = function (fn) {\n\t return rest(function (args/*..., callback*/) {\n\t var callback = args.pop();\n\t fn.call(this, args, callback);\n\t });\n\t};\n\t\n\tfunction applyEach$1(eachfn) {\n\t return rest(function(fns, args) {\n\t var go = initialParams(function(args, callback) {\n\t var that = this;\n\t return eachfn(fns, function (fn, cb) {\n\t fn.apply(that, args.concat(cb));\n\t }, callback);\n\t });\n\t if (args.length) {\n\t return go.apply(this, args);\n\t }\n\t else {\n\t return go;\n\t }\n\t });\n\t}\n\t\n\t/** Detect free variable `global` from Node.js. */\n\tvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\t\n\t/** Detect free variable `self`. */\n\tvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\t\n\t/** Used as a reference to the global object. */\n\tvar root = freeGlobal || freeSelf || Function('return this')();\n\t\n\t/** Built-in value references. */\n\tvar Symbol$1 = root.Symbol;\n\t\n\t/** Used for built-in method references. */\n\tvar objectProto = Object.prototype;\n\t\n\t/** Used to check objects for own properties. */\n\tvar hasOwnProperty = objectProto.hasOwnProperty;\n\t\n\t/**\n\t * Used to resolve the\n\t * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n\t * of values.\n\t */\n\tvar nativeObjectToString = objectProto.toString;\n\t\n\t/** Built-in value references. */\n\tvar symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;\n\t\n\t/**\n\t * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n\t *\n\t * @private\n\t * @param {*} value The value to query.\n\t * @returns {string} Returns the raw `toStringTag`.\n\t */\n\tfunction getRawTag(value) {\n\t var isOwn = hasOwnProperty.call(value, symToStringTag$1),\n\t tag = value[symToStringTag$1];\n\t\n\t try {\n\t value[symToStringTag$1] = undefined;\n\t var unmasked = true;\n\t } catch (e) {}\n\t\n\t var result = nativeObjectToString.call(value);\n\t if (unmasked) {\n\t if (isOwn) {\n\t value[symToStringTag$1] = tag;\n\t } else {\n\t delete value[symToStringTag$1];\n\t }\n\t }\n\t return result;\n\t}\n\t\n\t/** Used for built-in method references. */\n\tvar objectProto$1 = Object.prototype;\n\t\n\t/**\n\t * Used to resolve the\n\t * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n\t * of values.\n\t */\n\tvar nativeObjectToString$1 = objectProto$1.toString;\n\t\n\t/**\n\t * Converts `value` to a string using `Object.prototype.toString`.\n\t *\n\t * @private\n\t * @param {*} value The value to convert.\n\t * @returns {string} Returns the converted string.\n\t */\n\tfunction objectToString(value) {\n\t return nativeObjectToString$1.call(value);\n\t}\n\t\n\t/** `Object#toString` result references. */\n\tvar nullTag = '[object Null]';\n\tvar undefinedTag = '[object Undefined]';\n\t\n\t/** Built-in value references. */\n\tvar symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;\n\t\n\t/**\n\t * The base implementation of `getTag` without fallbacks for buggy environments.\n\t *\n\t * @private\n\t * @param {*} value The value to query.\n\t * @returns {string} Returns the `toStringTag`.\n\t */\n\tfunction baseGetTag(value) {\n\t if (value == null) {\n\t return value === undefined ? undefinedTag : nullTag;\n\t }\n\t return (symToStringTag && symToStringTag in Object(value))\n\t ? getRawTag(value)\n\t : objectToString(value);\n\t}\n\t\n\t/**\n\t * Checks if `value` is the\n\t * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n\t * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n\t *\n\t * @static\n\t * @memberOf _\n\t * @since 0.1.0\n\t * @category Lang\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n\t * @example\n\t *\n\t * _.isObject({});\n\t * // => true\n\t *\n\t * _.isObject([1, 2, 3]);\n\t * // => true\n\t *\n\t * _.isObject(_.noop);\n\t * // => true\n\t *\n\t * _.isObject(null);\n\t * // => false\n\t */\n\tfunction isObject(value) {\n\t var type = typeof value;\n\t return value != null && (type == 'object' || type == 'function');\n\t}\n\t\n\t/** `Object#toString` result references. */\n\tvar asyncTag = '[object AsyncFunction]';\n\tvar funcTag = '[object Function]';\n\tvar genTag = '[object GeneratorFunction]';\n\tvar proxyTag = '[object Proxy]';\n\t\n\t/**\n\t * Checks if `value` is classified as a `Function` object.\n\t *\n\t * @static\n\t * @memberOf _\n\t * @since 0.1.0\n\t * @category Lang\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n\t * @example\n\t *\n\t * _.isFunction(_);\n\t * // => true\n\t *\n\t * _.isFunction(/abc/);\n\t * // => false\n\t */\n\tfunction isFunction(value) {\n\t if (!isObject(value)) {\n\t return false;\n\t }\n\t // The use of `Object#toString` avoids issues with the `typeof` operator\n\t // in Safari 9 which returns 'object' for typed arrays and other constructors.\n\t var tag = baseGetTag(value);\n\t return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;\n\t}\n\t\n\t/** Used as references for various `Number` constants. */\n\tvar MAX_SAFE_INTEGER = 9007199254740991;\n\t\n\t/**\n\t * Checks if `value` is a valid array-like length.\n\t *\n\t * **Note:** This method is loosely based on\n\t * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n\t *\n\t * @static\n\t * @memberOf _\n\t * @since 4.0.0\n\t * @category Lang\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n\t * @example\n\t *\n\t * _.isLength(3);\n\t * // => true\n\t *\n\t * _.isLength(Number.MIN_VALUE);\n\t * // => false\n\t *\n\t * _.isLength(Infinity);\n\t * // => false\n\t *\n\t * _.isLength('3');\n\t * // => false\n\t */\n\tfunction isLength(value) {\n\t return typeof value == 'number' &&\n\t value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n\t}\n\t\n\t/**\n\t * Checks if `value` is array-like. A value is considered array-like if it's\n\t * not a function and has a `value.length` that's an integer greater than or\n\t * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n\t *\n\t * @static\n\t * @memberOf _\n\t * @since 4.0.0\n\t * @category Lang\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n\t * @example\n\t *\n\t * _.isArrayLike([1, 2, 3]);\n\t * // => true\n\t *\n\t * _.isArrayLike(document.body.children);\n\t * // => true\n\t *\n\t * _.isArrayLike('abc');\n\t * // => true\n\t *\n\t * _.isArrayLike(_.noop);\n\t * // => false\n\t */\n\tfunction isArrayLike(value) {\n\t return value != null && isLength(value.length) && !isFunction(value);\n\t}\n\t\n\t// A temporary value used to identify if the loop should be broken.\n\t// See #1064, #1293\n\tvar breakLoop = {};\n\t\n\t/**\n\t * This method returns `undefined`.\n\t *\n\t * @static\n\t * @memberOf _\n\t * @since 2.3.0\n\t * @category Util\n\t * @example\n\t *\n\t * _.times(2, _.noop);\n\t * // => [undefined, undefined]\n\t */\n\tfunction noop() {\n\t // No operation performed.\n\t}\n\t\n\tfunction once(fn) {\n\t return function () {\n\t if (fn === null) { return; }\n\t var callFn = fn;\n\t fn = null;\n\t callFn.apply(this, arguments);\n\t };\n\t}\n\t\n\tvar iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;\n\t\n\tvar getIterator = function (coll) {\n\t return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();\n\t};\n\t\n\t/**\n\t * The base implementation of `_.times` without support for iteratee shorthands\n\t * or max array length checks.\n\t *\n\t * @private\n\t * @param {number} n The number of times to invoke `iteratee`.\n\t * @param {Function} iteratee The function invoked per iteration.\n\t * @returns {Array} Returns the array of results.\n\t */\n\tfunction baseTimes(n, iteratee) {\n\t var index = -1,\n\t result = Array(n);\n\t\n\t while (++index < n) {\n\t result[index] = iteratee(index);\n\t }\n\t return result;\n\t}\n\t\n\t/**\n\t * Checks if `value` is object-like. A value is object-like if it's not `null`\n\t * and has a `typeof` result of \"object\".\n\t *\n\t * @static\n\t * @memberOf _\n\t * @since 4.0.0\n\t * @category Lang\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n\t * @example\n\t *\n\t * _.isObjectLike({});\n\t * // => true\n\t *\n\t * _.isObjectLike([1, 2, 3]);\n\t * // => true\n\t *\n\t * _.isObjectLike(_.noop);\n\t * // => false\n\t *\n\t * _.isObjectLike(null);\n\t * // => false\n\t */\n\tfunction isObjectLike(value) {\n\t return value != null && typeof value == 'object';\n\t}\n\t\n\t/** `Object#toString` result references. */\n\tvar argsTag = '[object Arguments]';\n\t\n\t/**\n\t * The base implementation of `_.isArguments`.\n\t *\n\t * @private\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n\t */\n\tfunction baseIsArguments(value) {\n\t return isObjectLike(value) && baseGetTag(value) == argsTag;\n\t}\n\t\n\t/** Used for built-in method references. */\n\tvar objectProto$3 = Object.prototype;\n\t\n\t/** Used to check objects for own properties. */\n\tvar hasOwnProperty$2 = objectProto$3.hasOwnProperty;\n\t\n\t/** Built-in value references. */\n\tvar propertyIsEnumerable = objectProto$3.propertyIsEnumerable;\n\t\n\t/**\n\t * Checks if `value` is likely an `arguments` object.\n\t *\n\t * @static\n\t * @memberOf _\n\t * @since 0.1.0\n\t * @category Lang\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n\t * else `false`.\n\t * @example\n\t *\n\t * _.isArguments(function() { return arguments; }());\n\t * // => true\n\t *\n\t * _.isArguments([1, 2, 3]);\n\t * // => false\n\t */\n\tvar isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {\n\t return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') &&\n\t !propertyIsEnumerable.call(value, 'callee');\n\t};\n\t\n\t/**\n\t * Checks if `value` is classified as an `Array` object.\n\t *\n\t * @static\n\t * @memberOf _\n\t * @since 0.1.0\n\t * @category Lang\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n\t * @example\n\t *\n\t * _.isArray([1, 2, 3]);\n\t * // => true\n\t *\n\t * _.isArray(document.body.children);\n\t * // => false\n\t *\n\t * _.isArray('abc');\n\t * // => false\n\t *\n\t * _.isArray(_.noop);\n\t * // => false\n\t */\n\tvar isArray = Array.isArray;\n\t\n\t/**\n\t * This method returns `false`.\n\t *\n\t * @static\n\t * @memberOf _\n\t * @since 4.13.0\n\t * @category Util\n\t * @returns {boolean} Returns `false`.\n\t * @example\n\t *\n\t * _.times(2, _.stubFalse);\n\t * // => [false, false]\n\t */\n\tfunction stubFalse() {\n\t return false;\n\t}\n\t\n\t/** Detect free variable `exports`. */\n\tvar freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\t\n\t/** Detect free variable `module`. */\n\tvar freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;\n\t\n\t/** Detect the popular CommonJS extension `module.exports`. */\n\tvar moduleExports = freeModule && freeModule.exports === freeExports;\n\t\n\t/** Built-in value references. */\n\tvar Buffer$1 = moduleExports ? root.Buffer : undefined;\n\t\n\t/* Built-in method references for those with the same name as other `lodash` methods. */\n\tvar nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : undefined;\n\t\n\t/**\n\t * Checks if `value` is a buffer.\n\t *\n\t * @static\n\t * @memberOf _\n\t * @since 4.3.0\n\t * @category Lang\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.\n\t * @example\n\t *\n\t * _.isBuffer(new Buffer(2));\n\t * // => true\n\t *\n\t * _.isBuffer(new Uint8Array(2));\n\t * // => false\n\t */\n\tvar isBuffer = nativeIsBuffer || stubFalse;\n\t\n\t/** Used as references for various `Number` constants. */\n\tvar MAX_SAFE_INTEGER$1 = 9007199254740991;\n\t\n\t/** Used to detect unsigned integer values. */\n\tvar reIsUint = /^(?:0|[1-9]\\d*)$/;\n\t\n\t/**\n\t * Checks if `value` is a valid array-like index.\n\t *\n\t * @private\n\t * @param {*} value The value to check.\n\t * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n\t * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n\t */\n\tfunction isIndex(value, length) {\n\t length = length == null ? MAX_SAFE_INTEGER$1 : length;\n\t return !!length &&\n\t (typeof value == 'number' || reIsUint.test(value)) &&\n\t (value > -1 && value % 1 == 0 && value < length);\n\t}\n\t\n\t/** `Object#toString` result references. */\n\tvar argsTag$1 = '[object Arguments]';\n\tvar arrayTag = '[object Array]';\n\tvar boolTag = '[object Boolean]';\n\tvar dateTag = '[object Date]';\n\tvar errorTag = '[object Error]';\n\tvar funcTag$1 = '[object Function]';\n\tvar mapTag = '[object Map]';\n\tvar numberTag = '[object Number]';\n\tvar objectTag = '[object Object]';\n\tvar regexpTag = '[object RegExp]';\n\tvar setTag = '[object Set]';\n\tvar stringTag = '[object String]';\n\tvar weakMapTag = '[object WeakMap]';\n\t\n\tvar arrayBufferTag = '[object ArrayBuffer]';\n\tvar dataViewTag = '[object DataView]';\n\tvar float32Tag = '[object Float32Array]';\n\tvar float64Tag = '[object Float64Array]';\n\tvar int8Tag = '[object Int8Array]';\n\tvar int16Tag = '[object Int16Array]';\n\tvar int32Tag = '[object Int32Array]';\n\tvar uint8Tag = '[object Uint8Array]';\n\tvar uint8ClampedTag = '[object Uint8ClampedArray]';\n\tvar uint16Tag = '[object Uint16Array]';\n\tvar uint32Tag = '[object Uint32Array]';\n\t\n\t/** Used to identify `toStringTag` values of typed arrays. */\n\tvar typedArrayTags = {};\n\ttypedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\n\ttypedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\n\ttypedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\n\ttypedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\n\ttypedArrayTags[uint32Tag] = true;\n\ttypedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =\n\ttypedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\n\ttypedArrayTags[dataViewTag] = typedArrayTags[dateTag] =\n\ttypedArrayTags[errorTag] = typedArrayTags[funcTag$1] =\n\ttypedArrayTags[mapTag] = typedArrayTags[numberTag] =\n\ttypedArrayTags[objectTag] = typedArrayTags[regexpTag] =\n\ttypedArrayTags[setTag] = typedArrayTags[stringTag] =\n\ttypedArrayTags[weakMapTag] = false;\n\t\n\t/**\n\t * The base implementation of `_.isTypedArray` without Node.js optimizations.\n\t *\n\t * @private\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n\t */\n\tfunction baseIsTypedArray(value) {\n\t return isObjectLike(value) &&\n\t isLength(value.length) && !!typedArrayTags[baseGetTag(value)];\n\t}\n\t\n\t/**\n\t * The base implementation of `_.unary` without support for storing metadata.\n\t *\n\t * @private\n\t * @param {Function} func The function to cap arguments for.\n\t * @returns {Function} Returns the new capped function.\n\t */\n\tfunction baseUnary(func) {\n\t return function(value) {\n\t return func(value);\n\t };\n\t}\n\t\n\t/** Detect free variable `exports`. */\n\tvar freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;\n\t\n\t/** Detect free variable `module`. */\n\tvar freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;\n\t\n\t/** Detect the popular CommonJS extension `module.exports`. */\n\tvar moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;\n\t\n\t/** Detect free variable `process` from Node.js. */\n\tvar freeProcess = moduleExports$1 && freeGlobal.process;\n\t\n\t/** Used to access faster Node.js helpers. */\n\tvar nodeUtil = (function() {\n\t try {\n\t return freeProcess && freeProcess.binding && freeProcess.binding('util');\n\t } catch (e) {}\n\t}());\n\t\n\t/* Node.js helper references. */\n\tvar nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;\n\t\n\t/**\n\t * Checks if `value` is classified as a typed array.\n\t *\n\t * @static\n\t * @memberOf _\n\t * @since 3.0.0\n\t * @category Lang\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.\n\t * @example\n\t *\n\t * _.isTypedArray(new Uint8Array);\n\t * // => true\n\t *\n\t * _.isTypedArray([]);\n\t * // => false\n\t */\n\tvar isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;\n\t\n\t/** Used for built-in method references. */\n\tvar objectProto$2 = Object.prototype;\n\t\n\t/** Used to check objects for own properties. */\n\tvar hasOwnProperty$1 = objectProto$2.hasOwnProperty;\n\t\n\t/**\n\t * Creates an array of the enumerable property names of the array-like `value`.\n\t *\n\t * @private\n\t * @param {*} value The value to query.\n\t * @param {boolean} inherited Specify returning inherited property names.\n\t * @returns {Array} Returns the array of property names.\n\t */\n\tfunction arrayLikeKeys(value, inherited) {\n\t var isArr = isArray(value),\n\t isArg = !isArr && isArguments(value),\n\t isBuff = !isArr && !isArg && isBuffer(value),\n\t isType = !isArr && !isArg && !isBuff && isTypedArray(value),\n\t skipIndexes = isArr || isArg || isBuff || isType,\n\t result = skipIndexes ? baseTimes(value.length, String) : [],\n\t length = result.length;\n\t\n\t for (var key in value) {\n\t if ((inherited || hasOwnProperty$1.call(value, key)) &&\n\t !(skipIndexes && (\n\t // Safari 9 has enumerable `arguments.length` in strict mode.\n\t key == 'length' ||\n\t // Node.js 0.10 has enumerable non-index properties on buffers.\n\t (isBuff && (key == 'offset' || key == 'parent')) ||\n\t // PhantomJS 2 has enumerable non-index properties on typed arrays.\n\t (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||\n\t // Skip index properties.\n\t isIndex(key, length)\n\t ))) {\n\t result.push(key);\n\t }\n\t }\n\t return result;\n\t}\n\t\n\t/** Used for built-in method references. */\n\tvar objectProto$5 = Object.prototype;\n\t\n\t/**\n\t * Checks if `value` is likely a prototype object.\n\t *\n\t * @private\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.\n\t */\n\tfunction isPrototype(value) {\n\t var Ctor = value && value.constructor,\n\t proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;\n\t\n\t return value === proto;\n\t}\n\t\n\t/**\n\t * Creates a unary function that invokes `func` with its argument transformed.\n\t *\n\t * @private\n\t * @param {Function} func The function to wrap.\n\t * @param {Function} transform The argument transform.\n\t * @returns {Function} Returns the new function.\n\t */\n\tfunction overArg(func, transform) {\n\t return function(arg) {\n\t return func(transform(arg));\n\t };\n\t}\n\t\n\t/* Built-in method references for those with the same name as other `lodash` methods. */\n\tvar nativeKeys = overArg(Object.keys, Object);\n\t\n\t/** Used for built-in method references. */\n\tvar objectProto$4 = Object.prototype;\n\t\n\t/** Used to check objects for own properties. */\n\tvar hasOwnProperty$3 = objectProto$4.hasOwnProperty;\n\t\n\t/**\n\t * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.\n\t *\n\t * @private\n\t * @param {Object} object The object to query.\n\t * @returns {Array} Returns the array of property names.\n\t */\n\tfunction baseKeys(object) {\n\t if (!isPrototype(object)) {\n\t return nativeKeys(object);\n\t }\n\t var result = [];\n\t for (var key in Object(object)) {\n\t if (hasOwnProperty$3.call(object, key) && key != 'constructor') {\n\t result.push(key);\n\t }\n\t }\n\t return result;\n\t}\n\t\n\t/**\n\t * Creates an array of the own enumerable property names of `object`.\n\t *\n\t * **Note:** Non-object values are coerced to objects. See the\n\t * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)\n\t * for more details.\n\t *\n\t * @static\n\t * @since 0.1.0\n\t * @memberOf _\n\t * @category Object\n\t * @param {Object} object The object to query.\n\t * @returns {Array} Returns the array of property names.\n\t * @example\n\t *\n\t * function Foo() {\n\t * this.a = 1;\n\t * this.b = 2;\n\t * }\n\t *\n\t * Foo.prototype.c = 3;\n\t *\n\t * _.keys(new Foo);\n\t * // => ['a', 'b'] (iteration order is not guaranteed)\n\t *\n\t * _.keys('hi');\n\t * // => ['0', '1']\n\t */\n\tfunction keys(object) {\n\t return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);\n\t}\n\t\n\tfunction createArrayIterator(coll) {\n\t var i = -1;\n\t var len = coll.length;\n\t return function next() {\n\t return ++i < len ? {value: coll[i], key: i} : null;\n\t }\n\t}\n\t\n\tfunction createES2015Iterator(iterator) {\n\t var i = -1;\n\t return function next() {\n\t var item = iterator.next();\n\t if (item.done)\n\t { return null; }\n\t i++;\n\t return {value: item.value, key: i};\n\t }\n\t}\n\t\n\tfunction createObjectIterator(obj) {\n\t var okeys = keys(obj);\n\t var i = -1;\n\t var len = okeys.length;\n\t return function next() {\n\t var key = okeys[++i];\n\t return i < len ? {value: obj[key], key: key} : null;\n\t };\n\t}\n\t\n\tfunction iterator(coll) {\n\t if (isArrayLike(coll)) {\n\t return createArrayIterator(coll);\n\t }\n\t\n\t var iterator = getIterator(coll);\n\t return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);\n\t}\n\t\n\tfunction onlyOnce(fn) {\n\t return function() {\n\t if (fn === null) { throw new Error(\"Callback was already called.\"); }\n\t var callFn = fn;\n\t fn = null;\n\t callFn.apply(this, arguments);\n\t };\n\t}\n\t\n\tfunction _eachOfLimit(limit) {\n\t return function (obj, iteratee, callback) {\n\t callback = once(callback || noop);\n\t if (limit <= 0 || !obj) {\n\t return callback(null);\n\t }\n\t var nextElem = iterator(obj);\n\t var done = false;\n\t var running = 0;\n\t\n\t function iterateeCallback(err, value) {\n\t running -= 1;\n\t if (err) {\n\t done = true;\n\t callback(err);\n\t }\n\t else if (value === breakLoop || (done && running <= 0)) {\n\t done = true;\n\t return callback(null);\n\t }\n\t else {\n\t replenish();\n\t }\n\t }\n\t\n\t function replenish () {\n\t while (running < limit && !done) {\n\t var elem = nextElem();\n\t if (elem === null) {\n\t done = true;\n\t if (running <= 0) {\n\t callback(null);\n\t }\n\t return;\n\t }\n\t running += 1;\n\t iteratee(elem.value, elem.key, onlyOnce(iterateeCallback));\n\t }\n\t }\n\t\n\t replenish();\n\t };\n\t}\n\t\n\t/**\n\t * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a\n\t * time.\n\t *\n\t * @name eachOfLimit\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.eachOf]{@link module:Collections.eachOf}\n\t * @alias forEachOfLimit\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {number} limit - The maximum number of async operations at a time.\n\t * @param {Function} iteratee - A function to apply to each\n\t * item in `coll`. The `key` is the item's key, or index in the case of an\n\t * array. The iteratee is passed a `callback(err)` which must be called once it\n\t * has completed. If no error has occurred, the callback should be run without\n\t * arguments or with an explicit `null` argument. Invoked with\n\t * (item, key, callback).\n\t * @param {Function} [callback] - A callback which is called when all\n\t * `iteratee` functions have finished, or an error occurs. Invoked with (err).\n\t */\n\tfunction eachOfLimit(coll, limit, iteratee, callback) {\n\t _eachOfLimit(limit)(coll, iteratee, callback);\n\t}\n\t\n\tfunction doLimit(fn, limit) {\n\t return function (iterable, iteratee, callback) {\n\t return fn(iterable, limit, iteratee, callback);\n\t };\n\t}\n\t\n\t// eachOf implementation optimized for array-likes\n\tfunction eachOfArrayLike(coll, iteratee, callback) {\n\t callback = once(callback || noop);\n\t var index = 0,\n\t completed = 0,\n\t length = coll.length;\n\t if (length === 0) {\n\t callback(null);\n\t }\n\t\n\t function iteratorCallback(err, value) {\n\t if (err) {\n\t callback(err);\n\t } else if ((++completed === length) || value === breakLoop) {\n\t callback(null);\n\t }\n\t }\n\t\n\t for (; index < length; index++) {\n\t iteratee(coll[index], index, onlyOnce(iteratorCallback));\n\t }\n\t}\n\t\n\t// a generic version of eachOf which can handle array, object, and iterator cases.\n\tvar eachOfGeneric = doLimit(eachOfLimit, Infinity);\n\t\n\t/**\n\t * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument\n\t * to the iteratee.\n\t *\n\t * @name eachOf\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @alias forEachOf\n\t * @category Collection\n\t * @see [async.each]{@link module:Collections.each}\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A function to apply to each\n\t * item in `coll`. The `key` is the item's key, or index in the case of an\n\t * array. The iteratee is passed a `callback(err)` which must be called once it\n\t * has completed. If no error has occurred, the callback should be run without\n\t * arguments or with an explicit `null` argument. Invoked with\n\t * (item, key, callback).\n\t * @param {Function} [callback] - A callback which is called when all\n\t * `iteratee` functions have finished, or an error occurs. Invoked with (err).\n\t * @example\n\t *\n\t * var obj = {dev: \"/dev.json\", test: \"/test.json\", prod: \"/prod.json\"};\n\t * var configs = {};\n\t *\n\t * async.forEachOf(obj, function (value, key, callback) {\n\t * fs.readFile(__dirname + value, \"utf8\", function (err, data) {\n\t * if (err) return callback(err);\n\t * try {\n\t * configs[key] = JSON.parse(data);\n\t * } catch (e) {\n\t * return callback(e);\n\t * }\n\t * callback();\n\t * });\n\t * }, function (err) {\n\t * if (err) console.error(err.message);\n\t * // configs is now a map of JSON data\n\t * doSomethingWith(configs);\n\t * });\n\t */\n\tvar eachOf = function(coll, iteratee, callback) {\n\t var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric;\n\t eachOfImplementation(coll, iteratee, callback);\n\t};\n\t\n\tfunction doParallel(fn) {\n\t return function (obj, iteratee, callback) {\n\t return fn(eachOf, obj, iteratee, callback);\n\t };\n\t}\n\t\n\tfunction _asyncMap(eachfn, arr, iteratee, callback) {\n\t callback = callback || noop;\n\t arr = arr || [];\n\t var results = [];\n\t var counter = 0;\n\t\n\t eachfn(arr, function (value, _, callback) {\n\t var index = counter++;\n\t iteratee(value, function (err, v) {\n\t results[index] = v;\n\t callback(err);\n\t });\n\t }, function (err) {\n\t callback(err, results);\n\t });\n\t}\n\t\n\t/**\n\t * Produces a new collection of values by mapping each value in `coll` through\n\t * the `iteratee` function. The `iteratee` is called with an item from `coll`\n\t * and a callback for when it has finished processing. Each of these callback\n\t * takes 2 arguments: an `error`, and the transformed item from `coll`. If\n\t * `iteratee` passes an error to its callback, the main `callback` (for the\n\t * `map` function) is immediately called with the error.\n\t *\n\t * Note, that since this function applies the `iteratee` to each item in\n\t * parallel, there is no guarantee that the `iteratee` functions will complete\n\t * in order. However, the results array will be in the same order as the\n\t * original `coll`.\n\t *\n\t * If `map` is passed an Object, the results will be an Array. The results\n\t * will roughly be in the order of the original Objects' keys (but this can\n\t * vary across JavaScript engines)\n\t *\n\t * @name map\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A function to apply to each item in `coll`.\n\t * The iteratee is passed a `callback(err, transformed)` which must be called\n\t * once it has completed with an error (which can be `null`) and a\n\t * transformed item. Invoked with (item, callback).\n\t * @param {Function} [callback] - A callback which is called when all `iteratee`\n\t * functions have finished, or an error occurs. Results is an Array of the\n\t * transformed items from the `coll`. Invoked with (err, results).\n\t * @example\n\t *\n\t * async.map(['file1','file2','file3'], fs.stat, function(err, results) {\n\t * // results is now an array of stats for each file\n\t * });\n\t */\n\tvar map = doParallel(_asyncMap);\n\t\n\t/**\n\t * Applies the provided arguments to each function in the array, calling\n\t * `callback` after all functions have completed. If you only provide the first\n\t * argument, `fns`, then it will return a function which lets you pass in the\n\t * arguments as if it were a single function call. If more arguments are\n\t * provided, `callback` is required while `args` is still optional.\n\t *\n\t * @name applyEach\n\t * @static\n\t * @memberOf module:ControlFlow\n\t * @method\n\t * @category Control Flow\n\t * @param {Array|Iterable|Object} fns - A collection of asynchronous functions\n\t * to all call with the same arguments\n\t * @param {...*} [args] - any number of separate arguments to pass to the\n\t * function.\n\t * @param {Function} [callback] - the final argument should be the callback,\n\t * called when all functions have completed processing.\n\t * @returns {Function} - If only the first argument, `fns`, is provided, it will\n\t * return a function which lets you pass in the arguments as if it were a single\n\t * function call. The signature is `(..args, callback)`. If invoked with any\n\t * arguments, `callback` is required.\n\t * @example\n\t *\n\t * async.applyEach([enableSearch, updateSchema], 'bucket', callback);\n\t *\n\t * // partial application example:\n\t * async.each(\n\t * buckets,\n\t * async.applyEach([enableSearch, updateSchema]),\n\t * callback\n\t * );\n\t */\n\tapplyEach$1(map);\n\t\n\tfunction doParallelLimit(fn) {\n\t return function (obj, limit, iteratee, callback) {\n\t return fn(_eachOfLimit(limit), obj, iteratee, callback);\n\t };\n\t}\n\t\n\t/**\n\t * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.\n\t *\n\t * @name mapLimit\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.map]{@link module:Collections.map}\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {number} limit - The maximum number of async operations at a time.\n\t * @param {Function} iteratee - A function to apply to each item in `coll`.\n\t * The iteratee is passed a `callback(err, transformed)` which must be called\n\t * once it has completed with an error (which can be `null`) and a transformed\n\t * item. Invoked with (item, callback).\n\t * @param {Function} [callback] - A callback which is called when all `iteratee`\n\t * functions have finished, or an error occurs. Results is an array of the\n\t * transformed items from the `coll`. Invoked with (err, results).\n\t */\n\tvar mapLimit = doParallelLimit(_asyncMap);\n\t\n\t/**\n\t * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.\n\t *\n\t * @name mapSeries\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.map]{@link module:Collections.map}\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A function to apply to each item in `coll`.\n\t * The iteratee is passed a `callback(err, transformed)` which must be called\n\t * once it has completed with an error (which can be `null`) and a\n\t * transformed item. Invoked with (item, callback).\n\t * @param {Function} [callback] - A callback which is called when all `iteratee`\n\t * functions have finished, or an error occurs. Results is an array of the\n\t * transformed items from the `coll`. Invoked with (err, results).\n\t */\n\tvar mapSeries = doLimit(mapLimit, 1);\n\t\n\t/**\n\t * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.\n\t *\n\t * @name applyEachSeries\n\t * @static\n\t * @memberOf module:ControlFlow\n\t * @method\n\t * @see [async.applyEach]{@link module:ControlFlow.applyEach}\n\t * @category Control Flow\n\t * @param {Array|Iterable|Object} fns - A collection of asynchronous functions to all\n\t * call with the same arguments\n\t * @param {...*} [args] - any number of separate arguments to pass to the\n\t * function.\n\t * @param {Function} [callback] - the final argument should be the callback,\n\t * called when all functions have completed processing.\n\t * @returns {Function} - If only the first argument is provided, it will return\n\t * a function which lets you pass in the arguments as if it were a single\n\t * function call.\n\t */\n\tapplyEach$1(mapSeries);\n\t\n\t/**\n\t * Creates a continuation function with some arguments already applied.\n\t *\n\t * Useful as a shorthand when combined with other control flow functions. Any\n\t * arguments passed to the returned function are added to the arguments\n\t * originally passed to apply.\n\t *\n\t * @name apply\n\t * @static\n\t * @memberOf module:Utils\n\t * @method\n\t * @category Util\n\t * @param {Function} function - The function you want to eventually apply all\n\t * arguments to. Invokes with (arguments...).\n\t * @param {...*} arguments... - Any number of arguments to automatically apply\n\t * when the continuation is called.\n\t * @example\n\t *\n\t * // using apply\n\t * async.parallel([\n\t * async.apply(fs.writeFile, 'testfile1', 'test1'),\n\t * async.apply(fs.writeFile, 'testfile2', 'test2')\n\t * ]);\n\t *\n\t *\n\t * // the same process without using apply\n\t * async.parallel([\n\t * function(callback) {\n\t * fs.writeFile('testfile1', 'test1', callback);\n\t * },\n\t * function(callback) {\n\t * fs.writeFile('testfile2', 'test2', callback);\n\t * }\n\t * ]);\n\t *\n\t * // It's possible to pass any number of additional arguments when calling the\n\t * // continuation:\n\t *\n\t * node> var fn = async.apply(sys.puts, 'one');\n\t * node> fn('two', 'three');\n\t * one\n\t * two\n\t * three\n\t */\n\trest(function(fn, args) {\n\t return rest(function(callArgs) {\n\t return fn.apply(null, args.concat(callArgs));\n\t });\n\t});\n\t\n\t/**\n\t * A specialized version of `_.forEach` for arrays without support for\n\t * iteratee shorthands.\n\t *\n\t * @private\n\t * @param {Array} [array] The array to iterate over.\n\t * @param {Function} iteratee The function invoked per iteration.\n\t * @returns {Array} Returns `array`.\n\t */\n\tfunction arrayEach(array, iteratee) {\n\t var index = -1,\n\t length = array == null ? 0 : array.length;\n\t\n\t while (++index < length) {\n\t if (iteratee(array[index], index, array) === false) {\n\t break;\n\t }\n\t }\n\t return array;\n\t}\n\t\n\t/**\n\t * Creates a base function for methods like `_.forIn` and `_.forOwn`.\n\t *\n\t * @private\n\t * @param {boolean} [fromRight] Specify iterating from right to left.\n\t * @returns {Function} Returns the new base function.\n\t */\n\tfunction createBaseFor(fromRight) {\n\t return function(object, iteratee, keysFunc) {\n\t var index = -1,\n\t iterable = Object(object),\n\t props = keysFunc(object),\n\t length = props.length;\n\t\n\t while (length--) {\n\t var key = props[fromRight ? length : ++index];\n\t if (iteratee(iterable[key], key, iterable) === false) {\n\t break;\n\t }\n\t }\n\t return object;\n\t };\n\t}\n\t\n\t/**\n\t * The base implementation of `baseForOwn` which iterates over `object`\n\t * properties returned by `keysFunc` and invokes `iteratee` for each property.\n\t * Iteratee functions may exit iteration early by explicitly returning `false`.\n\t *\n\t * @private\n\t * @param {Object} object The object to iterate over.\n\t * @param {Function} iteratee The function invoked per iteration.\n\t * @param {Function} keysFunc The function to get the keys of `object`.\n\t * @returns {Object} Returns `object`.\n\t */\n\tvar baseFor = createBaseFor();\n\t\n\t/**\n\t * The base implementation of `_.forOwn` without support for iteratee shorthands.\n\t *\n\t * @private\n\t * @param {Object} object The object to iterate over.\n\t * @param {Function} iteratee The function invoked per iteration.\n\t * @returns {Object} Returns `object`.\n\t */\n\tfunction baseForOwn(object, iteratee) {\n\t return object && baseFor(object, iteratee, keys);\n\t}\n\t\n\t/**\n\t * The base implementation of `_.findIndex` and `_.findLastIndex` without\n\t * support for iteratee shorthands.\n\t *\n\t * @private\n\t * @param {Array} array The array to inspect.\n\t * @param {Function} predicate The function invoked per iteration.\n\t * @param {number} fromIndex The index to search from.\n\t * @param {boolean} [fromRight] Specify iterating from right to left.\n\t * @returns {number} Returns the index of the matched value, else `-1`.\n\t */\n\tfunction baseFindIndex(array, predicate, fromIndex, fromRight) {\n\t var length = array.length,\n\t index = fromIndex + (fromRight ? 1 : -1);\n\t\n\t while ((fromRight ? index-- : ++index < length)) {\n\t if (predicate(array[index], index, array)) {\n\t return index;\n\t }\n\t }\n\t return -1;\n\t}\n\t\n\t/**\n\t * The base implementation of `_.isNaN` without support for number objects.\n\t *\n\t * @private\n\t * @param {*} value The value to check.\n\t * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.\n\t */\n\tfunction baseIsNaN(value) {\n\t return value !== value;\n\t}\n\t\n\t/**\n\t * A specialized version of `_.indexOf` which performs strict equality\n\t * comparisons of values, i.e. `===`.\n\t *\n\t * @private\n\t * @param {Array} array The array to inspect.\n\t * @param {*} value The value to search for.\n\t * @param {number} fromIndex The index to search from.\n\t * @returns {number} Returns the index of the matched value, else `-1`.\n\t */\n\tfunction strictIndexOf(array, value, fromIndex) {\n\t var index = fromIndex - 1,\n\t length = array.length;\n\t\n\t while (++index < length) {\n\t if (array[index] === value) {\n\t return index;\n\t }\n\t }\n\t return -1;\n\t}\n\t\n\t/**\n\t * The base implementation of `_.indexOf` without `fromIndex` bounds checks.\n\t *\n\t * @private\n\t * @param {Array} array The array to inspect.\n\t * @param {*} value The value to search for.\n\t * @param {number} fromIndex The index to search from.\n\t * @returns {number} Returns the index of the matched value, else `-1`.\n\t */\n\tfunction baseIndexOf(array, value, fromIndex) {\n\t return value === value\n\t ? strictIndexOf(array, value, fromIndex)\n\t : baseFindIndex(array, baseIsNaN, fromIndex);\n\t}\n\t\n\t/**\n\t * Determines the best order for running the functions in `tasks`, based on\n\t * their requirements. Each function can optionally depend on other functions\n\t * being completed first, and each function is run as soon as its requirements\n\t * are satisfied.\n\t *\n\t * If any of the functions pass an error to their callback, the `auto` sequence\n\t * will stop. Further tasks will not execute (so any other functions depending\n\t * on it will not run), and the main `callback` is immediately called with the\n\t * error.\n\t *\n\t * Functions also receive an object containing the results of functions which\n\t * have completed so far as the first argument, if they have dependencies. If a\n\t * task function has no dependencies, it will only be passed a callback.\n\t *\n\t * @name auto\n\t * @static\n\t * @memberOf module:ControlFlow\n\t * @method\n\t * @category Control Flow\n\t * @param {Object} tasks - An object. Each of its properties is either a\n\t * function or an array of requirements, with the function itself the last item\n\t * in the array. The object's key of a property serves as the name of the task\n\t * defined by that property, i.e. can be used when specifying requirements for\n\t * other tasks. The function receives one or two arguments:\n\t * * a `results` object, containing the results of the previously executed\n\t * functions, only passed if the task has any dependencies,\n\t * * a `callback(err, result)` function, which must be called when finished,\n\t * passing an `error` (which can be `null`) and the result of the function's\n\t * execution.\n\t * @param {number} [concurrency=Infinity] - An optional `integer` for\n\t * determining the maximum number of tasks that can be run in parallel. By\n\t * default, as many as possible.\n\t * @param {Function} [callback] - An optional callback which is called when all\n\t * the tasks have been completed. It receives the `err` argument if any `tasks`\n\t * pass an error to their callback. Results are always returned; however, if an\n\t * error occurs, no further `tasks` will be performed, and the results object\n\t * will only contain partial results. Invoked with (err, results).\n\t * @returns undefined\n\t * @example\n\t *\n\t * async.auto({\n\t * // this function will just be passed a callback\n\t * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),\n\t * showData: ['readData', function(results, cb) {\n\t * // results.readData is the file's contents\n\t * // ...\n\t * }]\n\t * }, callback);\n\t *\n\t * async.auto({\n\t * get_data: function(callback) {\n\t * console.log('in get_data');\n\t * // async code to get some data\n\t * callback(null, 'data', 'converted to array');\n\t * },\n\t * make_folder: function(callback) {\n\t * console.log('in make_folder');\n\t * // async code to create a directory to store a file in\n\t * // this is run at the same time as getting the data\n\t * callback(null, 'folder');\n\t * },\n\t * write_file: ['get_data', 'make_folder', function(results, callback) {\n\t * console.log('in write_file', JSON.stringify(results));\n\t * // once there is some data and the directory exists,\n\t * // write the data to a file in the directory\n\t * callback(null, 'filename');\n\t * }],\n\t * email_link: ['write_file', function(results, callback) {\n\t * console.log('in email_link', JSON.stringify(results));\n\t * // once the file is written let's email a link to it...\n\t * // results.write_file contains the filename returned by write_file.\n\t * callback(null, {'file':results.write_file, 'email':'user@example.com'});\n\t * }]\n\t * }, function(err, results) {\n\t * console.log('err = ', err);\n\t * console.log('results = ', results);\n\t * });\n\t */\n\t\n\t/**\n\t * A specialized version of `_.map` for arrays without support for iteratee\n\t * shorthands.\n\t *\n\t * @private\n\t * @param {Array} [array] The array to iterate over.\n\t * @param {Function} iteratee The function invoked per iteration.\n\t * @returns {Array} Returns the new mapped array.\n\t */\n\t\n\t/**\n\t * The base implementation of `_.slice` without an iteratee call guard.\n\t *\n\t * @private\n\t * @param {Array} array The array to slice.\n\t * @param {number} [start=0] The start position.\n\t * @param {number} [end=array.length] The end position.\n\t * @returns {Array} Returns the slice of `array`.\n\t */\n\t\n\t/**\n\t * Converts an ASCII `string` to an array.\n\t *\n\t * @private\n\t * @param {string} string The string to convert.\n\t * @returns {Array} Returns the converted array.\n\t */\n\t\n\t/** Used to compose unicode character classes. */\n\t\n\t/** Used to compose unicode character classes. */\n\tvar rsAstralRange$1 = '\\\\ud800-\\\\udfff';\n\tvar rsComboMarksRange$1 = '\\\\u0300-\\\\u036f';\n\tvar reComboHalfMarksRange$1 = '\\\\ufe20-\\\\ufe2f';\n\tvar rsComboSymbolsRange$1 = '\\\\u20d0-\\\\u20ff';\n\tvar rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1;\n\tvar rsVarRange$1 = '\\\\ufe0e\\\\ufe0f';\n\t\n\t/** Used to compose unicode capture groups. */\n\tvar rsAstral = '[' + rsAstralRange$1 + ']';\n\tvar rsCombo = '[' + rsComboRange$1 + ']';\n\tvar rsFitz = '\\\\ud83c[\\\\udffb-\\\\udfff]';\n\tvar rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')';\n\tvar rsNonAstral = '[^' + rsAstralRange$1 + ']';\n\tvar rsRegional = '(?:\\\\ud83c[\\\\udde6-\\\\uddff]){2}';\n\tvar rsSurrPair = '[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]';\n\tvar rsZWJ$1 = '\\\\u200d';\n\t\n\t/** Used to compose unicode regexes. */\n\tvar reOptMod = rsModifier + '?';\n\tvar rsOptVar = '[' + rsVarRange$1 + ']?';\n\tvar rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*';\n\tvar rsSeq = rsOptVar + reOptMod + rsOptJoin;\n\tvar rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';\n\t\n\tvar hasSetImmediate = typeof setImmediate === 'function' && setImmediate;\n\tvar hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';\n\t\n\tfunction fallback(fn) {\n\t setTimeout(fn, 0);\n\t}\n\t\n\tfunction wrap(defer) {\n\t return rest(function (fn, args) {\n\t defer(function () {\n\t fn.apply(null, args);\n\t });\n\t });\n\t}\n\t\n\tvar _defer;\n\t\n\tif (hasSetImmediate) {\n\t _defer = setImmediate;\n\t} else if (hasNextTick) {\n\t _defer = process.nextTick;\n\t} else {\n\t _defer = fallback;\n\t}\n\t\n\twrap(_defer);\n\t\n\t// Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation\n\t// used for queues. This implementation assumes that the node provided by the user can be modified\n\t// to adjust the next and last properties. We implement only the minimal functionality\n\t// for queue support.\n\t\n\t/**\n\t * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.\n\t *\n\t * @name eachOfSeries\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.eachOf]{@link module:Collections.eachOf}\n\t * @alias forEachOfSeries\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A function to apply to each item in `coll`. The\n\t * `key` is the item's key, or index in the case of an array. The iteratee is\n\t * passed a `callback(err)` which must be called once it has completed. If no\n\t * error has occurred, the callback should be run without arguments or with an\n\t * explicit `null` argument. Invoked with (item, key, callback).\n\t * @param {Function} [callback] - A callback which is called when all `iteratee`\n\t * functions have finished, or an error occurs. Invoked with (err).\n\t */\n\tvar eachOfSeries = doLimit(eachOfLimit, 1);\n\t\n\t/**\n\t * Reduces `coll` into a single value using an async `iteratee` to return each\n\t * successive step. `memo` is the initial state of the reduction. This function\n\t * only operates in series.\n\t *\n\t * For performance reasons, it may make sense to split a call to this function\n\t * into a parallel map, and then use the normal `Array.prototype.reduce` on the\n\t * results. This function is for situations where each step in the reduction\n\t * needs to be async; if you can get the data before reducing it, then it's\n\t * probably a good idea to do so.\n\t *\n\t * @name reduce\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @alias inject\n\t * @alias foldl\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {*} memo - The initial state of the reduction.\n\t * @param {Function} iteratee - A function applied to each item in the\n\t * array to produce the next step in the reduction. The `iteratee` is passed a\n\t * `callback(err, reduction)` which accepts an optional error as its first\n\t * argument, and the state of the reduction as the second. If an error is\n\t * passed to the callback, the reduction is stopped and the main `callback` is\n\t * immediately called with the error. Invoked with (memo, item, callback).\n\t * @param {Function} [callback] - A callback which is called after all the\n\t * `iteratee` functions have finished. Result is the reduced value. Invoked with\n\t * (err, result).\n\t * @example\n\t *\n\t * async.reduce([1,2,3], 0, function(memo, item, callback) {\n\t * // pointless async:\n\t * process.nextTick(function() {\n\t * callback(null, memo + item)\n\t * });\n\t * }, function(err, result) {\n\t * // result is now equal to the last value of memo, which is 6\n\t * });\n\t */\n\tfunction reduce(coll, memo, iteratee, callback) {\n\t callback = once(callback || noop);\n\t eachOfSeries(coll, function(x, i, callback) {\n\t iteratee(memo, x, function(err, v) {\n\t memo = v;\n\t callback(err);\n\t });\n\t }, function(err) {\n\t callback(err, memo);\n\t });\n\t}\n\t\n\t/**\n\t * Version of the compose function that is more natural to read. Each function\n\t * consumes the return value of the previous function. It is the equivalent of\n\t * [compose]{@link module:ControlFlow.compose} with the arguments reversed.\n\t *\n\t * Each function is executed with the `this` binding of the composed function.\n\t *\n\t * @name seq\n\t * @static\n\t * @memberOf module:ControlFlow\n\t * @method\n\t * @see [async.compose]{@link module:ControlFlow.compose}\n\t * @category Control Flow\n\t * @param {...Function} functions - the asynchronous functions to compose\n\t * @returns {Function} a function that composes the `functions` in order\n\t * @example\n\t *\n\t * // Requires lodash (or underscore), express3 and dresende's orm2.\n\t * // Part of an app, that fetches cats of the logged user.\n\t * // This example uses `seq` function to avoid overnesting and error\n\t * // handling clutter.\n\t * app.get('/cats', function(request, response) {\n\t * var User = request.models.User;\n\t * async.seq(\n\t * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))\n\t * function(user, fn) {\n\t * user.getCats(fn); // 'getCats' has signature (callback(err, data))\n\t * }\n\t * )(req.session.user_id, function (err, cats) {\n\t * if (err) {\n\t * console.error(err);\n\t * response.json({ status: 'error', message: err.message });\n\t * } else {\n\t * response.json({ status: 'ok', message: 'Cats found', data: cats });\n\t * }\n\t * });\n\t * });\n\t */\n\tvar seq = rest(function seq(functions) {\n\t return rest(function(args) {\n\t var that = this;\n\t\n\t var cb = args[args.length - 1];\n\t if (typeof cb == 'function') {\n\t args.pop();\n\t } else {\n\t cb = noop;\n\t }\n\t\n\t reduce(functions, args, function(newargs, fn, cb) {\n\t fn.apply(that, newargs.concat(rest(function(err, nextargs) {\n\t cb(err, nextargs);\n\t })));\n\t },\n\t function(err, results) {\n\t cb.apply(that, [err].concat(results));\n\t });\n\t });\n\t});\n\t\n\t/**\n\t * Creates a function which is a composition of the passed asynchronous\n\t * functions. Each function consumes the return value of the function that\n\t * follows. Composing functions `f()`, `g()`, and `h()` would produce the result\n\t * of `f(g(h()))`, only this version uses callbacks to obtain the return values.\n\t *\n\t * Each function is executed with the `this` binding of the composed function.\n\t *\n\t * @name compose\n\t * @static\n\t * @memberOf module:ControlFlow\n\t * @method\n\t * @category Control Flow\n\t * @param {...Function} functions - the asynchronous functions to compose\n\t * @returns {Function} an asynchronous function that is the composed\n\t * asynchronous `functions`\n\t * @example\n\t *\n\t * function add1(n, callback) {\n\t * setTimeout(function () {\n\t * callback(null, n + 1);\n\t * }, 10);\n\t * }\n\t *\n\t * function mul3(n, callback) {\n\t * setTimeout(function () {\n\t * callback(null, n * 3);\n\t * }, 10);\n\t * }\n\t *\n\t * var add1mul3 = async.compose(mul3, add1);\n\t * add1mul3(4, function (err, result) {\n\t * // result now equals 15\n\t * });\n\t */\n\trest(function(args) {\n\t return seq.apply(null, args.reverse());\n\t});\n\t\n\t/**\n\t * Applies `iteratee` to each item in `coll`, concatenating the results. Returns\n\t * the concatenated list. The `iteratee`s are called in parallel, and the\n\t * results are concatenated as they return. There is no guarantee that the\n\t * results array will be returned in the original order of `coll` passed to the\n\t * `iteratee` function.\n\t *\n\t * @name concat\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A function to apply to each item in `coll`.\n\t * The iteratee is passed a `callback(err, results)` which must be called once\n\t * it has completed with an error (which can be `null`) and an array of results.\n\t * Invoked with (item, callback).\n\t * @param {Function} [callback(err)] - A callback which is called after all the\n\t * `iteratee` functions have finished, or an error occurs. Results is an array\n\t * containing the concatenated results of the `iteratee` function. Invoked with\n\t * (err, results).\n\t * @example\n\t *\n\t * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {\n\t * // files is now a list of filenames that exist in the 3 directories\n\t * });\n\t */\n\t\n\t/**\n\t * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.\n\t *\n\t * @name concatSeries\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.concat]{@link module:Collections.concat}\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A function to apply to each item in `coll`.\n\t * The iteratee is passed a `callback(err, results)` which must be called once\n\t * it has completed with an error (which can be `null`) and an array of results.\n\t * Invoked with (item, callback).\n\t * @param {Function} [callback(err)] - A callback which is called after all the\n\t * `iteratee` functions have finished, or an error occurs. Results is an array\n\t * containing the concatenated results of the `iteratee` function. Invoked with\n\t * (err, results).\n\t */\n\t\n\t/**\n\t * Returns a function that when called, calls-back with the values provided.\n\t * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to\n\t * [`auto`]{@link module:ControlFlow.auto}.\n\t *\n\t * @name constant\n\t * @static\n\t * @memberOf module:Utils\n\t * @method\n\t * @category Util\n\t * @param {...*} arguments... - Any number of arguments to automatically invoke\n\t * callback with.\n\t * @returns {Function} Returns a function that when invoked, automatically\n\t * invokes the callback with the previous given arguments.\n\t * @example\n\t *\n\t * async.waterfall([\n\t * async.constant(42),\n\t * function (value, next) {\n\t * // value === 42\n\t * },\n\t * //...\n\t * ], callback);\n\t *\n\t * async.waterfall([\n\t * async.constant(filename, \"utf8\"),\n\t * fs.readFile,\n\t * function (fileData, next) {\n\t * //...\n\t * }\n\t * //...\n\t * ], callback);\n\t *\n\t * async.auto({\n\t * hostname: async.constant(\"https://server.net/\"),\n\t * port: findFreePort,\n\t * launchServer: [\"hostname\", \"port\", function (options, cb) {\n\t * startServer(options, cb);\n\t * }],\n\t * //...\n\t * }, callback);\n\t */\n\trest(function(values) {\n\t var args = [null].concat(values);\n\t return initialParams(function (ignoredArgs, callback) {\n\t return callback.apply(this, args);\n\t });\n\t});\n\t\n\t/**\n\t * Returns the first value in `coll` that passes an async truth test. The\n\t * `iteratee` is applied in parallel, meaning the first iteratee to return\n\t * `true` will fire the detect `callback` with that result. That means the\n\t * result might not be the first item in the original `coll` (in terms of order)\n\t * that passes the test.\n\t\n\t * If order within the original `coll` is important, then look at\n\t * [`detectSeries`]{@link module:Collections.detectSeries}.\n\t *\n\t * @name detect\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @alias find\n\t * @category Collections\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A truth test to apply to each item in `coll`.\n\t * The iteratee is passed a `callback(err, truthValue)` which must be called\n\t * with a boolean argument once it has completed. Invoked with (item, callback).\n\t * @param {Function} [callback] - A callback which is called as soon as any\n\t * iteratee returns `true`, or after all the `iteratee` functions have finished.\n\t * Result will be the first item in the array that passes the truth test\n\t * (iteratee) or the value `undefined` if none passed. Invoked with\n\t * (err, result).\n\t * @example\n\t *\n\t * async.detect(['file1','file2','file3'], function(filePath, callback) {\n\t * fs.access(filePath, function(err) {\n\t * callback(null, !err)\n\t * });\n\t * }, function(err, result) {\n\t * // result now equals the first file in the list that exists\n\t * });\n\t */\n\t\n\t/**\n\t * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a\n\t * time.\n\t *\n\t * @name detectLimit\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.detect]{@link module:Collections.detect}\n\t * @alias findLimit\n\t * @category Collections\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {number} limit - The maximum number of async operations at a time.\n\t * @param {Function} iteratee - A truth test to apply to each item in `coll`.\n\t * The iteratee is passed a `callback(err, truthValue)` which must be called\n\t * with a boolean argument once it has completed. Invoked with (item, callback).\n\t * @param {Function} [callback] - A callback which is called as soon as any\n\t * iteratee returns `true`, or after all the `iteratee` functions have finished.\n\t * Result will be the first item in the array that passes the truth test\n\t * (iteratee) or the value `undefined` if none passed. Invoked with\n\t * (err, result).\n\t */\n\t\n\t/**\n\t * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.\n\t *\n\t * @name detectSeries\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.detect]{@link module:Collections.detect}\n\t * @alias findSeries\n\t * @category Collections\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A truth test to apply to each item in `coll`.\n\t * The iteratee is passed a `callback(err, truthValue)` which must be called\n\t * with a boolean argument once it has completed. Invoked with (item, callback).\n\t * @param {Function} [callback] - A callback which is called as soon as any\n\t * iteratee returns `true`, or after all the `iteratee` functions have finished.\n\t * Result will be the first item in the array that passes the truth test\n\t * (iteratee) or the value `undefined` if none passed. Invoked with\n\t * (err, result).\n\t */\n\t\n\tfunction consoleFunc(name) {\n\t return rest(function (fn, args) {\n\t fn.apply(null, args.concat(rest(function (err, args) {\n\t if (typeof console === 'object') {\n\t if (err) {\n\t if (console.error) {\n\t console.error(err);\n\t }\n\t }\n\t else if (console[name]) {\n\t arrayEach(args, function (x) {\n\t console[name](x);\n\t });\n\t }\n\t }\n\t })));\n\t });\n\t}\n\t\n\t/**\n\t * Logs the result of an `async` function to the `console` using `console.dir`\n\t * to display the properties of the resulting object. Only works in Node.js or\n\t * in browsers that support `console.dir` and `console.error` (such as FF and\n\t * Chrome). If multiple arguments are returned from the async function,\n\t * `console.dir` is called on each argument in order.\n\t *\n\t * @name dir\n\t * @static\n\t * @memberOf module:Utils\n\t * @method\n\t * @category Util\n\t * @param {Function} function - The function you want to eventually apply all\n\t * arguments to.\n\t * @param {...*} arguments... - Any number of arguments to apply to the function.\n\t * @example\n\t *\n\t * // in a module\n\t * var hello = function(name, callback) {\n\t * setTimeout(function() {\n\t * callback(null, {hello: name});\n\t * }, 1000);\n\t * };\n\t *\n\t * // in the node repl\n\t * node> async.dir(hello, 'world');\n\t * {hello: 'world'}\n\t */\n\tconsoleFunc('dir');\n\t\n\tfunction _withoutIndex(iteratee) {\n\t return function (value, index, callback) {\n\t return iteratee(value, callback);\n\t };\n\t}\n\t\n\t/**\n\t * Applies the function `iteratee` to each item in `coll`, in parallel.\n\t * The `iteratee` is called with an item from the list, and a callback for when\n\t * it has finished. If the `iteratee` passes an error to its `callback`, the\n\t * main `callback` (for the `each` function) is immediately called with the\n\t * error.\n\t *\n\t * Note, that since this function applies `iteratee` to each item in parallel,\n\t * there is no guarantee that the iteratee functions will complete in order.\n\t *\n\t * @name each\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @alias forEach\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A function to apply to each item\n\t * in `coll`. The iteratee is passed a `callback(err)` which must be called once\n\t * it has completed. If no error has occurred, the `callback` should be run\n\t * without arguments or with an explicit `null` argument. The array index is not\n\t * passed to the iteratee. Invoked with (item, callback). If you need the index,\n\t * use `eachOf`.\n\t * @param {Function} [callback] - A callback which is called when all\n\t * `iteratee` functions have finished, or an error occurs. Invoked with (err).\n\t * @example\n\t *\n\t * // assuming openFiles is an array of file names and saveFile is a function\n\t * // to save the modified contents of that file:\n\t *\n\t * async.each(openFiles, saveFile, function(err){\n\t * // if any of the saves produced an error, err would equal that error\n\t * });\n\t *\n\t * // assuming openFiles is an array of file names\n\t * async.each(openFiles, function(file, callback) {\n\t *\n\t * // Perform operation on file here.\n\t * console.log('Processing file ' + file);\n\t *\n\t * if( file.length > 32 ) {\n\t * console.log('This file name is too long');\n\t * callback('File name too long');\n\t * } else {\n\t * // Do work to process file here\n\t * console.log('File processed');\n\t * callback();\n\t * }\n\t * }, function(err) {\n\t * // if any of the file processing produced an error, err would equal that error\n\t * if( err ) {\n\t * // One of the iterations produced an error.\n\t * // All processing will now stop.\n\t * console.log('A file failed to process');\n\t * } else {\n\t * console.log('All files have been processed successfully');\n\t * }\n\t * });\n\t */\n\tfunction eachLimit(coll, iteratee, callback) {\n\t eachOf(coll, _withoutIndex(iteratee), callback);\n\t}\n\t\n\t/**\n\t * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.\n\t *\n\t * @name eachSeries\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.each]{@link module:Collections.each}\n\t * @alias forEachSeries\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A function to apply to each\n\t * item in `coll`. The iteratee is passed a `callback(err)` which must be called\n\t * once it has completed. If no error has occurred, the `callback` should be run\n\t * without arguments or with an explicit `null` argument. The array index is\n\t * not passed to the iteratee. Invoked with (item, callback). If you need the\n\t * index, use `eachOfSeries`.\n\t * @param {Function} [callback] - A callback which is called when all\n\t * `iteratee` functions have finished, or an error occurs. Invoked with (err).\n\t */\n\t\n\t/**\n\t * Returns `true` if every element in `coll` satisfies an async test. If any\n\t * iteratee call returns `false`, the main `callback` is immediately called.\n\t *\n\t * @name every\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @alias all\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A truth test to apply to each item in the\n\t * collection in parallel. The iteratee is passed a `callback(err, truthValue)`\n\t * which must be called with a boolean argument once it has completed. Invoked\n\t * with (item, callback).\n\t * @param {Function} [callback] - A callback which is called after all the\n\t * `iteratee` functions have finished. Result will be either `true` or `false`\n\t * depending on the values of the async tests. Invoked with (err, result).\n\t * @example\n\t *\n\t * async.every(['file1','file2','file3'], function(filePath, callback) {\n\t * fs.access(filePath, function(err) {\n\t * callback(null, !err)\n\t * });\n\t * }, function(err, result) {\n\t * // if result is true then every file exists\n\t * });\n\t */\n\t\n\t/**\n\t * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.\n\t *\n\t * @name everyLimit\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.every]{@link module:Collections.every}\n\t * @alias allLimit\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {number} limit - The maximum number of async operations at a time.\n\t * @param {Function} iteratee - A truth test to apply to each item in the\n\t * collection in parallel. The iteratee is passed a `callback(err, truthValue)`\n\t * which must be called with a boolean argument once it has completed. Invoked\n\t * with (item, callback).\n\t * @param {Function} [callback] - A callback which is called after all the\n\t * `iteratee` functions have finished. Result will be either `true` or `false`\n\t * depending on the values of the async tests. Invoked with (err, result).\n\t */\n\t\n\t/**\n\t * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.\n\t *\n\t * @name everySeries\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.every]{@link module:Collections.every}\n\t * @alias allSeries\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A truth test to apply to each item in the\n\t * collection in parallel. The iteratee is passed a `callback(err, truthValue)`\n\t * which must be called with a boolean argument once it has completed. Invoked\n\t * with (item, callback).\n\t * @param {Function} [callback] - A callback which is called after all the\n\t * `iteratee` functions have finished. Result will be either `true` or `false`\n\t * depending on the values of the async tests. Invoked with (err, result).\n\t */\n\t\n\t/**\n\t * The base implementation of `_.property` without support for deep paths.\n\t *\n\t * @private\n\t * @param {string} key The key of the property to get.\n\t * @returns {Function} Returns the new accessor function.\n\t */\n\t\n\t/**\n\t * Returns a new array of all the values in `coll` which pass an async truth\n\t * test. This operation is performed in parallel, but the results array will be\n\t * in the same order as the original.\n\t *\n\t * @name filter\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @alias select\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A truth test to apply to each item in `coll`.\n\t * The `iteratee` is passed a `callback(err, truthValue)`, which must be called\n\t * with a boolean argument once it has completed. Invoked with (item, callback).\n\t * @param {Function} [callback] - A callback which is called after all the\n\t * `iteratee` functions have finished. Invoked with (err, results).\n\t * @example\n\t *\n\t * async.filter(['file1','file2','file3'], function(filePath, callback) {\n\t * fs.access(filePath, function(err) {\n\t * callback(null, !err)\n\t * });\n\t * }, function(err, results) {\n\t * // results now equals an array of the existing files\n\t * });\n\t */\n\t\n\t/**\n\t * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a\n\t * time.\n\t *\n\t * @name filterLimit\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.filter]{@link module:Collections.filter}\n\t * @alias selectLimit\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {number} limit - The maximum number of async operations at a time.\n\t * @param {Function} iteratee - A truth test to apply to each item in `coll`.\n\t * The `iteratee` is passed a `callback(err, truthValue)`, which must be called\n\t * with a boolean argument once it has completed. Invoked with (item, callback).\n\t * @param {Function} [callback] - A callback which is called after all the\n\t * `iteratee` functions have finished. Invoked with (err, results).\n\t */\n\t\n\t/**\n\t * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.\n\t *\n\t * @name filterSeries\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.filter]{@link module:Collections.filter}\n\t * @alias selectSeries\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A truth test to apply to each item in `coll`.\n\t * The `iteratee` is passed a `callback(err, truthValue)`, which must be called\n\t * with a boolean argument once it has completed. Invoked with (item, callback).\n\t * @param {Function} [callback] - A callback which is called after all the\n\t * `iteratee` functions have finished. Invoked with (err, results)\n\t */\n\t\n\t/**\n\t * Logs the result of an `async` function to the `console`. Only works in\n\t * Node.js or in browsers that support `console.log` and `console.error` (such\n\t * as FF and Chrome). If multiple arguments are returned from the async\n\t * function, `console.log` is called on each argument in order.\n\t *\n\t * @name log\n\t * @static\n\t * @memberOf module:Utils\n\t * @method\n\t * @category Util\n\t * @param {Function} function - The function you want to eventually apply all\n\t * arguments to.\n\t * @param {...*} arguments... - Any number of arguments to apply to the function.\n\t * @example\n\t *\n\t * // in a module\n\t * var hello = function(name, callback) {\n\t * setTimeout(function() {\n\t * callback(null, 'hello ' + name);\n\t * }, 1000);\n\t * };\n\t *\n\t * // in the node repl\n\t * node> async.log(hello, 'world');\n\t * 'hello world'\n\t */\n\tconsoleFunc('log');\n\t\n\t/**\n\t * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.\n\t *\n\t * Produces a new Object by mapping each value of `obj` through the `iteratee`\n\t * function. The `iteratee` is called each `value` and `key` from `obj` and a\n\t * callback for when it has finished processing. Each of these callbacks takes\n\t * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`\n\t * passes an error to its callback, the main `callback` (for the `mapValues`\n\t * function) is immediately called with the error.\n\t *\n\t * Note, the order of the keys in the result is not guaranteed. The keys will\n\t * be roughly in the order they complete, (but this is very engine-specific)\n\t *\n\t * @name mapValues\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @category Collection\n\t * @param {Object} obj - A collection to iterate over.\n\t * @param {Function} iteratee - A function to apply to each value and key in\n\t * `coll`. The iteratee is passed a `callback(err, transformed)` which must be\n\t * called once it has completed with an error (which can be `null`) and a\n\t * transformed value. Invoked with (value, key, callback).\n\t * @param {Function} [callback] - A callback which is called when all `iteratee`\n\t * functions have finished, or an error occurs. `result` is a new object consisting\n\t * of each key from `obj`, with each transformed value on the right-hand side.\n\t * Invoked with (err, result).\n\t * @example\n\t *\n\t * async.mapValues({\n\t * f1: 'file1',\n\t * f2: 'file2',\n\t * f3: 'file3'\n\t * }, function (file, key, callback) {\n\t * fs.stat(file, callback);\n\t * }, function(err, result) {\n\t * // result is now a map of stats for each file, e.g.\n\t * // {\n\t * // f1: [stats for file1],\n\t * // f2: [stats for file2],\n\t * // f3: [stats for file3]\n\t * // }\n\t * });\n\t */\n\t\n\t/**\n\t * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.\n\t *\n\t * @name mapValuesSeries\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.mapValues]{@link module:Collections.mapValues}\n\t * @category Collection\n\t * @param {Object} obj - A collection to iterate over.\n\t * @param {Function} iteratee - A function to apply to each value in `obj`.\n\t * The iteratee is passed a `callback(err, transformed)` which must be called\n\t * once it has completed with an error (which can be `null`) and a\n\t * transformed value. Invoked with (value, key, callback).\n\t * @param {Function} [callback] - A callback which is called when all `iteratee`\n\t * functions have finished, or an error occurs. `result` is a new object consisting\n\t * of each key from `obj`, with each transformed value on the right-hand side.\n\t * Invoked with (err, result).\n\t */\n\t\n\t/**\n\t * Calls `callback` on a later loop around the event loop. In Node.js this just\n\t * calls `setImmediate`. In the browser it will use `setImmediate` if\n\t * available, otherwise `setTimeout(callback, 0)`, which means other higher\n\t * priority events may precede the execution of `callback`.\n\t *\n\t * This is used internally for browser-compatibility purposes.\n\t *\n\t * @name nextTick\n\t * @static\n\t * @memberOf module:Utils\n\t * @method\n\t * @alias setImmediate\n\t * @category Util\n\t * @param {Function} callback - The function to call on a later loop around\n\t * the event loop. Invoked with (args...).\n\t * @param {...*} args... - any number of additional arguments to pass to the\n\t * callback on the next tick.\n\t * @example\n\t *\n\t * var call_order = [];\n\t * async.nextTick(function() {\n\t * call_order.push('two');\n\t * // call_order now equals ['one','two']\n\t * });\n\t * call_order.push('one');\n\t *\n\t * async.setImmediate(function (a, b, c) {\n\t * // a, b, and c equal 1, 2, and 3\n\t * }, 1, 2, 3);\n\t */\n\tvar _defer$1;\n\t\n\tif (hasNextTick) {\n\t _defer$1 = process.nextTick;\n\t} else if (hasSetImmediate) {\n\t _defer$1 = setImmediate;\n\t} else {\n\t _defer$1 = fallback;\n\t}\n\t\n\twrap(_defer$1);\n\t\n\t/**\n\t * Calls `callback` on a later loop around the event loop. In Node.js this just\n\t * calls `setImmediate`. In the browser it will use `setImmediate` if\n\t * available, otherwise `setTimeout(callback, 0)`, which means other higher\n\t * priority events may precede the execution of `callback`.\n\t *\n\t * This is used internally for browser-compatibility purposes.\n\t *\n\t * @name setImmediate\n\t * @static\n\t * @memberOf module:Utils\n\t * @method\n\t * @alias nextTick\n\t * @category Util\n\t * @param {Function} callback - The function to call on a later loop around\n\t * the event loop. Invoked with (args...).\n\t * @param {...*} args... - any number of additional arguments to pass to the\n\t * callback on the next tick.\n\t * @example\n\t *\n\t * var call_order = [];\n\t * async.nextTick(function() {\n\t * call_order.push('two');\n\t * // call_order now equals ['one','two']\n\t * });\n\t * call_order.push('one');\n\t *\n\t * async.setImmediate(function (a, b, c) {\n\t * // a, b, and c equal 1, 2, and 3\n\t * }, 1, 2, 3);\n\t */\n\t\n\t/**\n\t * A queue of tasks for the worker function to complete.\n\t * @typedef {Object} QueueObject\n\t * @memberOf module:ControlFlow\n\t * @property {Function} length - a function returning the number of items\n\t * waiting to be processed. Invoke with `queue.length()`.\n\t * @property {boolean} started - a boolean indicating whether or not any\n\t * items have been pushed and processed by the queue.\n\t * @property {Function} running - a function returning the number of items\n\t * currently being processed. Invoke with `queue.running()`.\n\t * @property {Function} workersList - a function returning the array of items\n\t * currently being processed. Invoke with `queue.workersList()`.\n\t * @property {Function} idle - a function returning false if there are items\n\t * waiting or being processed, or true if not. Invoke with `queue.idle()`.\n\t * @property {number} concurrency - an integer for determining how many `worker`\n\t * functions should be run in parallel. This property can be changed after a\n\t * `queue` is created to alter the concurrency on-the-fly.\n\t * @property {Function} push - add a new task to the `queue`. Calls `callback`\n\t * once the `worker` has finished processing the task. Instead of a single task,\n\t * a `tasks` array can be submitted. The respective callback is used for every\n\t * task in the list. Invoke with `queue.push(task, [callback])`,\n\t * @property {Function} unshift - add a new task to the front of the `queue`.\n\t * Invoke with `queue.unshift(task, [callback])`.\n\t * @property {Function} saturated - a callback that is called when the number of\n\t * running workers hits the `concurrency` limit, and further tasks will be\n\t * queued.\n\t * @property {Function} unsaturated - a callback that is called when the number\n\t * of running workers is less than the `concurrency` & `buffer` limits, and\n\t * further tasks will not be queued.\n\t * @property {number} buffer - A minimum threshold buffer in order to say that\n\t * the `queue` is `unsaturated`.\n\t * @property {Function} empty - a callback that is called when the last item\n\t * from the `queue` is given to a `worker`.\n\t * @property {Function} drain - a callback that is called when the last item\n\t * from the `queue` has returned from the `worker`.\n\t * @property {Function} error - a callback that is called when a task errors.\n\t * Has the signature `function(error, task)`.\n\t * @property {boolean} paused - a boolean for determining whether the queue is\n\t * in a paused state.\n\t * @property {Function} pause - a function that pauses the processing of tasks\n\t * until `resume()` is called. Invoke with `queue.pause()`.\n\t * @property {Function} resume - a function that resumes the processing of\n\t * queued tasks when the queue is paused. Invoke with `queue.resume()`.\n\t * @property {Function} kill - a function that removes the `drain` callback and\n\t * empties remaining tasks from the queue forcing it to go idle. Invoke with `queue.kill()`.\n\t */\n\t\n\t/**\n\t * Creates a `queue` object with the specified `concurrency`. Tasks added to the\n\t * `queue` are processed in parallel (up to the `concurrency` limit). If all\n\t * `worker`s are in progress, the task is queued until one becomes available.\n\t * Once a `worker` completes a `task`, that `task`'s callback is called.\n\t *\n\t * @name queue\n\t * @static\n\t * @memberOf module:ControlFlow\n\t * @method\n\t * @category Control Flow\n\t * @param {Function} worker - An asynchronous function for processing a queued\n\t * task, which must call its `callback(err)` argument when finished, with an\n\t * optional `error` as an argument. If you want to handle errors from an\n\t * individual task, pass a callback to `q.push()`. Invoked with\n\t * (task, callback).\n\t * @param {number} [concurrency=1] - An `integer` for determining how many\n\t * `worker` functions should be run in parallel. If omitted, the concurrency\n\t * defaults to `1`. If the concurrency is `0`, an error is thrown.\n\t * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can\n\t * attached as certain properties to listen for specific events during the\n\t * lifecycle of the queue.\n\t * @example\n\t *\n\t * // create a queue object with concurrency 2\n\t * var q = async.queue(function(task, callback) {\n\t * console.log('hello ' + task.name);\n\t * callback();\n\t * }, 2);\n\t *\n\t * // assign a callback\n\t * q.drain = function() {\n\t * console.log('all items have been processed');\n\t * };\n\t *\n\t * // add some items to the queue\n\t * q.push({name: 'foo'}, function(err) {\n\t * console.log('finished processing foo');\n\t * });\n\t * q.push({name: 'bar'}, function (err) {\n\t * console.log('finished processing bar');\n\t * });\n\t *\n\t * // add some items to the queue (batch-wise)\n\t * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {\n\t * console.log('finished processing item');\n\t * });\n\t *\n\t * // add some items to the front of the queue\n\t * q.unshift({name: 'bar'}, function (err) {\n\t * console.log('finished processing bar');\n\t * });\n\t */\n\t\n\t/**\n\t * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and\n\t * completed in ascending priority order.\n\t *\n\t * @name priorityQueue\n\t * @static\n\t * @memberOf module:ControlFlow\n\t * @method\n\t * @see [async.queue]{@link module:ControlFlow.queue}\n\t * @category Control Flow\n\t * @param {Function} worker - An asynchronous function for processing a queued\n\t * task, which must call its `callback(err)` argument when finished, with an\n\t * optional `error` as an argument. If you want to handle errors from an\n\t * individual task, pass a callback to `q.push()`. Invoked with\n\t * (task, callback).\n\t * @param {number} concurrency - An `integer` for determining how many `worker`\n\t * functions should be run in parallel. If omitted, the concurrency defaults to\n\t * `1`. If the concurrency is `0`, an error is thrown.\n\t * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two\n\t * differences between `queue` and `priorityQueue` objects:\n\t * * `push(task, priority, [callback])` - `priority` should be a number. If an\n\t * array of `tasks` is given, all tasks will be assigned the same priority.\n\t * * The `unshift` method was removed.\n\t */\n\t\n\t/**\n\t * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.\n\t *\n\t * @name reject\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.filter]{@link module:Collections.filter}\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A truth test to apply to each item in `coll`.\n\t * The `iteratee` is passed a `callback(err, truthValue)`, which must be called\n\t * with a boolean argument once it has completed. Invoked with (item, callback).\n\t * @param {Function} [callback] - A callback which is called after all the\n\t * `iteratee` functions have finished. Invoked with (err, results).\n\t * @example\n\t *\n\t * async.reject(['file1','file2','file3'], function(filePath, callback) {\n\t * fs.access(filePath, function(err) {\n\t * callback(null, !err)\n\t * });\n\t * }, function(err, results) {\n\t * // results now equals an array of missing files\n\t * createFiles(results);\n\t * });\n\t */\n\t\n\t/**\n\t * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a\n\t * time.\n\t *\n\t * @name rejectLimit\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.reject]{@link module:Collections.reject}\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {number} limit - The maximum number of async operations at a time.\n\t * @param {Function} iteratee - A truth test to apply to each item in `coll`.\n\t * The `iteratee` is passed a `callback(err, truthValue)`, which must be called\n\t * with a boolean argument once it has completed. Invoked with (item, callback).\n\t * @param {Function} [callback] - A callback which is called after all the\n\t * `iteratee` functions have finished. Invoked with (err, results).\n\t */\n\t\n\t/**\n\t * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.\n\t *\n\t * @name rejectSeries\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.reject]{@link module:Collections.reject}\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A truth test to apply to each item in `coll`.\n\t * The `iteratee` is passed a `callback(err, truthValue)`, which must be called\n\t * with a boolean argument once it has completed. Invoked with (item, callback).\n\t * @param {Function} [callback] - A callback which is called after all the\n\t * `iteratee` functions have finished. Invoked with (err, results).\n\t */\n\t\n\t/**\n\t * Creates a function that returns `value`.\n\t *\n\t * @static\n\t * @memberOf _\n\t * @since 2.4.0\n\t * @category Util\n\t * @param {*} value The value to return from the new function.\n\t * @returns {Function} Returns the new constant function.\n\t * @example\n\t *\n\t * var objects = _.times(2, _.constant({ 'a': 1 }));\n\t *\n\t * console.log(objects);\n\t * // => [{ 'a': 1 }, { 'a': 1 }]\n\t *\n\t * console.log(objects[0] === objects[1]);\n\t * // => true\n\t */\n\t\n\t/**\n\t * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method wraps a task and makes it\n\t * retryable, rather than immediately calling it with retries.\n\t *\n\t * @name retryable\n\t * @static\n\t * @memberOf module:ControlFlow\n\t * @method\n\t * @see [async.retry]{@link module:ControlFlow.retry}\n\t * @category Control Flow\n\t * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional\n\t * options, exactly the same as from `retry`\n\t * @param {Function} task - the asynchronous function to wrap\n\t * @returns {Functions} The wrapped function, which when invoked, will retry on\n\t * an error, based on the parameters specified in `opts`.\n\t * @example\n\t *\n\t * async.auto({\n\t * dep1: async.retryable(3, getFromFlakyService),\n\t * process: [\"dep1\", async.retryable(3, function (results, cb) {\n\t * maybeProcessData(results.dep1, cb);\n\t * })]\n\t * }, callback);\n\t */\n\t\n\t/**\n\t * Returns `true` if at least one element in the `coll` satisfies an async test.\n\t * If any iteratee call returns `true`, the main `callback` is immediately\n\t * called.\n\t *\n\t * @name some\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @alias any\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A truth test to apply to each item in the array\n\t * in parallel. The iteratee is passed a `callback(err, truthValue)` which must\n\t * be called with a boolean argument once it has completed. Invoked with\n\t * (item, callback).\n\t * @param {Function} [callback] - A callback which is called as soon as any\n\t * iteratee returns `true`, or after all the iteratee functions have finished.\n\t * Result will be either `true` or `false` depending on the values of the async\n\t * tests. Invoked with (err, result).\n\t * @example\n\t *\n\t * async.some(['file1','file2','file3'], function(filePath, callback) {\n\t * fs.access(filePath, function(err) {\n\t * callback(null, !err)\n\t * });\n\t * }, function(err, result) {\n\t * // if result is true then at least one of the files exists\n\t * });\n\t */\n\t\n\t/**\n\t * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.\n\t *\n\t * @name someLimit\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.some]{@link module:Collections.some}\n\t * @alias anyLimit\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {number} limit - The maximum number of async operations at a time.\n\t * @param {Function} iteratee - A truth test to apply to each item in the array\n\t * in parallel. The iteratee is passed a `callback(err, truthValue)` which must\n\t * be called with a boolean argument once it has completed. Invoked with\n\t * (item, callback).\n\t * @param {Function} [callback] - A callback which is called as soon as any\n\t * iteratee returns `true`, or after all the iteratee functions have finished.\n\t * Result will be either `true` or `false` depending on the values of the async\n\t * tests. Invoked with (err, result).\n\t */\n\t\n\t/**\n\t * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.\n\t *\n\t * @name someSeries\n\t * @static\n\t * @memberOf module:Collections\n\t * @method\n\t * @see [async.some]{@link module:Collections.some}\n\t * @alias anySeries\n\t * @category Collection\n\t * @param {Array|Iterable|Object} coll - A collection to iterate over.\n\t * @param {Function} iteratee - A truth test to apply to each item in the array\n\t * in parallel. The iteratee is passed a `callback(err, truthValue)` which must\n\t * be called with a boolean argument once it has completed. Invoked with\n\t * (item, callback).\n\t * @param {Function} [callback] - A callback which is called as soon as any\n\t * iteratee returns `true`, or after all the iteratee functions have finished.\n\t * Result will be either `true` or `false` depending on the values of the async\n\t * tests. Invoked with (err, result).\n\t */\n\t\n\t/* Built-in method references for those with the same name as other `lodash` methods. */\n\tvar nativeCeil = Math.ceil;\n\tvar nativeMax$1 = Math.max;\n\t\n\t/**\n\t * Calls the `iteratee` function `n` times, and accumulates results in the same\n\t * manner you would use with [map]{@link module:Collections.map}.\n\t *\n\t * @name times\n\t * @static\n\t * @memberOf module:ControlFlow\n\t * @method\n\t * @see [async.map]{@link module:Collections.map}\n\t * @category Control Flow\n\t * @param {number} n - The number of times to run the function.\n\t * @param {Function} iteratee - The function to call `n` times. Invoked with the\n\t * iteration index and a callback (n, next).\n\t * @param {Function} callback - see {@link module:Collections.map}.\n\t * @example\n\t *\n\t * // Pretend this is some complicated async factory\n\t * var createUser = function(id, callback) {\n\t * callback(null, {\n\t * id: 'user' + id\n\t * });\n\t * };\n\t *\n\t * // generate 5 users\n\t * async.times(5, function(n, next) {\n\t * createUser(n, function(err, user) {\n\t * next(err, user);\n\t * });\n\t * }, function(err, users) {\n\t * // we should now have 5 users\n\t * });\n\t */\n\t\n\t/**\n\t * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.\n\t *\n\t * @name timesSeries\n\t * @static\n\t * @memberOf module:ControlFlow\n\t * @method\n\t * @see [async.times]{@link module:ControlFlow.times}\n\t * @category Control Flow\n\t * @param {number} n - The number of times to run the function.\n\t * @param {Function} iteratee - The function to call `n` times. Invoked with the\n\t * iteration index and a callback (n, next).\n\t * @param {Function} callback - see {@link module:Collections.map}.\n\t */\n\t\n\t/**\n\t * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,\n\t * unmemoized form. Handy for testing.\n\t *\n\t * @name unmemoize\n\t * @static\n\t * @memberOf module:Utils\n\t * @method\n\t * @see [async.memoize]{@link module:Utils.memoize}\n\t * @category Util\n\t * @param {Function} fn - the memoized function\n\t * @returns {Function} a function that calls the original unmemoized function\n\t */\n\t\n\t/**\n\t * Runs the `tasks` array of functions in series, each passing their results to\n\t * the next in the array. However, if any of the `tasks` pass an error to their\n\t * own callback, the next function is not executed, and the main `callback` is\n\t * immediately called with the error.\n\t *\n\t * @name waterfall\n\t * @static\n\t * @memberOf module:ControlFlow\n\t * @method\n\t * @category Control Flow\n\t * @param {Array} tasks - An array of functions to run, each function is passed\n\t * a `callback(err, result1, result2, ...)` it must call on completion. The\n\t * first argument is an error (which can be `null`) and any further arguments\n\t * will be passed as arguments in order to the next task.\n\t * @param {Function} [callback] - An optional callback to run once all the\n\t * functions have completed. This will be passed the results of the last task's\n\t * callback. Invoked with (err, [results]).\n\t * @returns undefined\n\t * @example\n\t *\n\t * async.waterfall([\n\t * function(callback) {\n\t * callback(null, 'one', 'two');\n\t * },\n\t * function(arg1, arg2, callback) {\n\t * // arg1 now equals 'one' and arg2 now equals 'two'\n\t * callback(null, 'three');\n\t * },\n\t * function(arg1, callback) {\n\t * // arg1 now equals 'three'\n\t * callback(null, 'done');\n\t * }\n\t * ], function (err, result) {\n\t * // result now equals 'done'\n\t * });\n\t *\n\t * // Or, with named functions:\n\t * async.waterfall([\n\t * myFirstFunction,\n\t * mySecondFunction,\n\t * myLastFunction,\n\t * ], function (err, result) {\n\t * // result now equals 'done'\n\t * });\n\t * function myFirstFunction(callback) {\n\t * callback(null, 'one', 'two');\n\t * }\n\t * function mySecondFunction(arg1, arg2, callback) {\n\t * // arg1 now equals 'one' and arg2 now equals 'two'\n\t * callback(null, 'three');\n\t * }\n\t * function myLastFunction(arg1, callback) {\n\t * // arg1 now equals 'three'\n\t * callback(null, 'done');\n\t * }\n\t */\n\t\n\t/**\n\t * Async is a utility module which provides straight-forward, powerful functions\n\t * for working with asynchronous JavaScript. Although originally designed for\n\t * use with [Node.js](http://nodejs.org) and installable via\n\t * `npm install --save async`, it can also be used directly in the browser.\n\t * @module async\n\t */\n\t\n\t/**\n\t * A collection of `async` functions for manipulating collections, such as\n\t * arrays and objects.\n\t * @module Collections\n\t */\n\t\n\t/**\n\t * A collection of `async` functions for controlling the flow through a script.\n\t * @module ControlFlow\n\t */\n\t\n\t /**\n\t * A collection of `async` utility functions.\n\t * @module Utils\n\t */\n\t\n\t/**\n\t * @hidden\n\t */\n\tvar errorCodeLookup;\n\t/**\n\t * Lazily construct error code lookup, since DropboxJS might be loaded *after* BrowserFS (or not at all!)\n\t * @hidden\n\t */\n\tfunction constructErrorCodeLookup() {\n\t if (errorCodeLookup) {\n\t return;\n\t }\n\t errorCodeLookup = {};\n\t // This indicates a network transmission error on modern browsers. Internet Explorer might cause this code to be reported on some API server errors.\n\t errorCodeLookup[Dropbox.ApiError.NETWORK_ERROR] = ErrorCode.EIO;\n\t // This happens when the contentHash parameter passed to a Dropbox.Client#readdir or Dropbox.Client#stat matches the most recent content, so the API call response is omitted, to save bandwidth.\n\t // errorCodeLookup[Dropbox.ApiError.NO_CONTENT];\n\t // The error property on {Dropbox.ApiError#response} should indicate which input parameter is invalid and why.\n\t errorCodeLookup[Dropbox.ApiError.INVALID_PARAM] = ErrorCode.EINVAL;\n\t // The OAuth token used for the request will never become valid again, so the user should be re-authenticated.\n\t errorCodeLookup[Dropbox.ApiError.INVALID_TOKEN] = ErrorCode.EPERM;\n\t // This indicates a bug in dropbox.js and should never occur under normal circumstances.\n\t // ^ Actually, that's false. This occurs when you try to move folders to themselves, or move a file over another file.\n\t errorCodeLookup[Dropbox.ApiError.OAUTH_ERROR] = ErrorCode.EPERM;\n\t // This happens when trying to read from a non-existing file, readdir a non-existing directory, write a file into a non-existing directory, etc.\n\t errorCodeLookup[Dropbox.ApiError.NOT_FOUND] = ErrorCode.ENOENT;\n\t // This indicates a bug in dropbox.js and should never occur under normal circumstances.\n\t errorCodeLookup[Dropbox.ApiError.INVALID_METHOD] = ErrorCode.EINVAL;\n\t // This happens when a Dropbox.Client#readdir or Dropbox.Client#stat call would return more than a maximum amount of directory entries.\n\t errorCodeLookup[Dropbox.ApiError.NOT_ACCEPTABLE] = ErrorCode.EINVAL;\n\t // This is used by some backend methods to indicate that the client needs to download server-side changes and perform conflict resolution. Under normal usage, errors with this code should never surface to the code using dropbox.js.\n\t errorCodeLookup[Dropbox.ApiError.CONFLICT] = ErrorCode.EINVAL;\n\t // Status value indicating that the application is making too many requests.\n\t errorCodeLookup[Dropbox.ApiError.RATE_LIMITED] = ErrorCode.EBUSY;\n\t // The request should be retried after some time.\n\t errorCodeLookup[Dropbox.ApiError.SERVER_ERROR] = ErrorCode.EBUSY;\n\t // Status value indicating that the user's Dropbox is over its storage quota.\n\t errorCodeLookup[Dropbox.ApiError.OVER_QUOTA] = ErrorCode.ENOSPC;\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction isFileInfo(cache) {\n\t return cache && cache.stat.isFile;\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction isDirInfo(cache) {\n\t return cache && cache.stat.isFolder;\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction isArrayBuffer(ab) {\n\t // Accept null / undefined, too.\n\t return ab === null || ab === undefined || (typeof (ab) === 'object' && typeof (ab['byteLength']) === 'number');\n\t}\n\t/**\n\t * Wraps a Dropbox client and caches operations.\n\t * @hidden\n\t */\n\tvar CachedDropboxClient = function CachedDropboxClient(client) {\n\t this._cache = {};\n\t this._client = client;\n\t};\n\tCachedDropboxClient.prototype.readdir = function readdir (p, cb) {\n\t var this$1 = this;\n\t\n\t var cacheInfo = this.getCachedDirInfo(p);\n\t this._wrap(function (interceptCb) {\n\t if (cacheInfo !== null && cacheInfo.contents) {\n\t this$1._client.readdir(p, {\n\t contentHash: cacheInfo.stat.contentHash\n\t }, interceptCb);\n\t }\n\t else {\n\t this$1._client.readdir(p, interceptCb);\n\t }\n\t }, function (err, filenames, stat, folderEntries) {\n\t if (err) {\n\t if (err.status === Dropbox.ApiError.NO_CONTENT && cacheInfo !== null) {\n\t cb(null, cacheInfo.contents.slice(0));\n\t }\n\t else {\n\t cb(err);\n\t }\n\t }\n\t else {\n\t this$1.updateCachedDirInfo(p, stat, filenames.slice(0));\n\t folderEntries.forEach(function (entry) {\n\t this$1.updateCachedInfo(path.join(p, entry.name), entry);\n\t });\n\t cb(null, filenames);\n\t }\n\t });\n\t};\n\tCachedDropboxClient.prototype.remove = function remove (p, cb) {\n\t var this$1 = this;\n\t\n\t this._wrap(function (interceptCb) {\n\t this$1._client.remove(p, interceptCb);\n\t }, function (err, stat) {\n\t if (!err) {\n\t this$1.updateCachedInfo(p, stat);\n\t }\n\t cb(err);\n\t });\n\t};\n\tCachedDropboxClient.prototype.move = function move (src, dest, cb) {\n\t var this$1 = this;\n\t\n\t this._wrap(function (interceptCb) {\n\t this$1._client.move(src, dest, interceptCb);\n\t }, function (err, stat) {\n\t if (!err) {\n\t this$1.deleteCachedInfo(src);\n\t this$1.updateCachedInfo(dest, stat);\n\t }\n\t cb(err);\n\t });\n\t};\n\tCachedDropboxClient.prototype.stat = function stat (p, cb) {\n\t var this$1 = this;\n\t\n\t this._wrap(function (interceptCb) {\n\t this$1._client.stat(p, interceptCb);\n\t }, function (err, stat) {\n\t if (!err) {\n\t this$1.updateCachedInfo(p, stat);\n\t }\n\t cb(err, stat);\n\t });\n\t};\n\tCachedDropboxClient.prototype.readFile = function readFile (p, cb) {\n\t var this$1 = this;\n\t\n\t var cacheInfo = this.getCachedFileInfo(p);\n\t if (cacheInfo !== null && cacheInfo.contents !== null) {\n\t // Try to use cached info; issue a stat to see if contents are up-to-date.\n\t this.stat(p, function (error, stat) {\n\t if (error) {\n\t cb(error);\n\t }\n\t else if (stat.contentHash === cacheInfo.stat.contentHash) {\n\t // No file changes.\n\t cb(error, cacheInfo.contents.slice(0), cacheInfo.stat);\n\t }\n\t else {\n\t // File changes; rerun to trigger actual readFile.\n\t this$1.readFile(p, cb);\n\t }\n\t });\n\t }\n\t else {\n\t this._wrap(function (interceptCb) {\n\t this$1._client.readFile(p, { arrayBuffer: true }, interceptCb);\n\t }, function (err, contents, stat) {\n\t if (!err) {\n\t this$1.updateCachedInfo(p, stat, contents.slice(0));\n\t }\n\t cb(err, contents, stat);\n\t });\n\t }\n\t};\n\tCachedDropboxClient.prototype.writeFile = function writeFile (p, contents, cb) {\n\t var this$1 = this;\n\t\n\t this._wrap(function (interceptCb) {\n\t this$1._client.writeFile(p, contents, interceptCb);\n\t }, function (err, stat) {\n\t if (!err) {\n\t this$1.updateCachedInfo(p, stat, contents.slice(0));\n\t }\n\t cb(err, stat);\n\t });\n\t};\n\tCachedDropboxClient.prototype.mkdir = function mkdir (p, cb) {\n\t var this$1 = this;\n\t\n\t this._wrap(function (interceptCb) {\n\t this$1._client.mkdir(p, interceptCb);\n\t }, function (err, stat) {\n\t if (!err) {\n\t this$1.updateCachedInfo(p, stat, []);\n\t }\n\t cb(err);\n\t });\n\t};\n\t/**\n\t * Wraps an operation such that we retry a failed operation 3 times.\n\t * Necessary to deal with Dropbox rate limiting.\n\t *\n\t * @param performOp Function that performs the operation. Will be called up to three times.\n\t * @param cb Called when the operation succeeds, fails in a non-temporary manner, or fails three times.\n\t */\n\tCachedDropboxClient.prototype._wrap = function _wrap (performOp, cb) {\n\t var numRun = 0;\n\t var interceptCb = function (error) {\n\t // Timeout duration, in seconds.\n\t var timeoutDuration = 2;\n\t if (error && 3 > (++numRun)) {\n\t switch (error.status) {\n\t case Dropbox.ApiError.SERVER_ERROR:\n\t case Dropbox.ApiError.NETWORK_ERROR:\n\t case Dropbox.ApiError.RATE_LIMITED:\n\t setTimeout(function () {\n\t performOp(interceptCb);\n\t }, timeoutDuration * 1000);\n\t break;\n\t default:\n\t cb.apply(null, arguments);\n\t break;\n\t }\n\t }\n\t else {\n\t cb.apply(null, arguments);\n\t }\n\t };\n\t performOp(interceptCb);\n\t};\n\tCachedDropboxClient.prototype.getCachedInfo = function getCachedInfo (p) {\n\t return this._cache[p.toLowerCase()];\n\t};\n\tCachedDropboxClient.prototype.putCachedInfo = function putCachedInfo (p, cache) {\n\t this._cache[p.toLowerCase()] = cache;\n\t};\n\tCachedDropboxClient.prototype.deleteCachedInfo = function deleteCachedInfo (p) {\n\t delete this._cache[p.toLowerCase()];\n\t};\n\tCachedDropboxClient.prototype.getCachedDirInfo = function getCachedDirInfo (p) {\n\t var info = this.getCachedInfo(p);\n\t if (isDirInfo(info)) {\n\t return info;\n\t }\n\t else {\n\t return null;\n\t }\n\t};\n\tCachedDropboxClient.prototype.getCachedFileInfo = function getCachedFileInfo (p) {\n\t var info = this.getCachedInfo(p);\n\t if (isFileInfo(info)) {\n\t return info;\n\t }\n\t else {\n\t return null;\n\t }\n\t};\n\tCachedDropboxClient.prototype.updateCachedDirInfo = function updateCachedDirInfo (p, stat, contents) {\n\t if ( contents === void 0 ) contents = null;\n\t\n\t var cachedInfo = this.getCachedInfo(p);\n\t // Dropbox uses the *contentHash* property for directories.\n\t // Ignore stat objects w/o a contentHash defined; those actually exist!!!\n\t // (Example: readdir returns an array of stat objs; stat objs for dirs in that context have no contentHash)\n\t if (stat.contentHash !== null && (cachedInfo === undefined || cachedInfo.stat.contentHash !== stat.contentHash)) {\n\t this.putCachedInfo(p, {\n\t stat: stat,\n\t contents: contents\n\t });\n\t }\n\t};\n\tCachedDropboxClient.prototype.updateCachedFileInfo = function updateCachedFileInfo (p, stat, contents) {\n\t if ( contents === void 0 ) contents = null;\n\t\n\t var cachedInfo = this.getCachedInfo(p);\n\t // Dropbox uses the *versionTag* property for files.\n\t // Ignore stat objects w/o a versionTag defined.\n\t if (stat.versionTag !== null && (cachedInfo === undefined || cachedInfo.stat.versionTag !== stat.versionTag)) {\n\t this.putCachedInfo(p, {\n\t stat: stat,\n\t contents: contents\n\t });\n\t }\n\t};\n\tCachedDropboxClient.prototype.updateCachedInfo = function updateCachedInfo (p, stat, contents) {\n\t if ( contents === void 0 ) contents = null;\n\t\n\t if (stat.isFile && isArrayBuffer(contents)) {\n\t this.updateCachedFileInfo(p, stat, contents);\n\t }\n\t else if (stat.isFolder && Array.isArray(contents)) {\n\t this.updateCachedDirInfo(p, stat, contents);\n\t }\n\t};\n\tvar DropboxFile = (function (PreloadFile$$1) {\n\t function DropboxFile(_fs, _path, _flag, _stat, contents) {\n\t PreloadFile$$1.call(this, _fs, _path, _flag, _stat, contents);\n\t }\n\t\n\t if ( PreloadFile$$1 ) DropboxFile.__proto__ = PreloadFile$$1;\n\t DropboxFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );\n\t DropboxFile.prototype.constructor = DropboxFile;\n\t DropboxFile.prototype.sync = function sync (cb) {\n\t var this$1 = this;\n\t\n\t if (this.isDirty()) {\n\t var buffer$$1 = this.getBuffer(), arrayBuffer = buffer2ArrayBuffer(buffer$$1);\n\t this._fs._writeFileStrict(this.getPath(), arrayBuffer, function (e) {\n\t if (!e) {\n\t this$1.resetDirty();\n\t }\n\t cb(e);\n\t });\n\t }\n\t else {\n\t cb();\n\t }\n\t };\n\t DropboxFile.prototype.close = function close (cb) {\n\t this.sync(cb);\n\t };\n\t\n\t return DropboxFile;\n\t}(PreloadFile));\n\t/**\n\t * A read/write file system backed by Dropbox cloud storage.\n\t *\n\t * Uses the Dropbox V1 API.\n\t *\n\t * NOTE: You must use the v0.10 version of the [Dropbox JavaScript SDK](https://www.npmjs.com/package/dropbox).\n\t */\n\tvar DropboxFileSystem = (function (BaseFileSystem$$1) {\n\t function DropboxFileSystem(client, deprecateMsg) {\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t BaseFileSystem$$1.call(this);\n\t this._client = new CachedDropboxClient(client);\n\t deprecationMessage(deprecateMsg, DropboxFileSystem.Name, { client: \"authenticated dropbox client instance\" });\n\t constructErrorCodeLookup();\n\t }\n\t\n\t if ( BaseFileSystem$$1 ) DropboxFileSystem.__proto__ = BaseFileSystem$$1;\n\t DropboxFileSystem.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );\n\t DropboxFileSystem.prototype.constructor = DropboxFileSystem;\n\t /**\n\t * Creates a new DropboxFileSystem instance with the given options.\n\t * Must be given an *authenticated* DropboxJS client from the old v0.10 version of the Dropbox JS SDK.\n\t */\n\t DropboxFileSystem.Create = function Create (opts, cb) {\n\t cb(null, new DropboxFileSystem(opts.client, false));\n\t };\n\t DropboxFileSystem.isAvailable = function isAvailable () {\n\t // Checks if the Dropbox library is loaded.\n\t return typeof Dropbox !== 'undefined';\n\t };\n\t DropboxFileSystem.prototype.getName = function getName () {\n\t return DropboxFileSystem.Name;\n\t };\n\t DropboxFileSystem.prototype.isReadOnly = function isReadOnly () {\n\t return false;\n\t };\n\t // Dropbox doesn't support symlinks, properties, or synchronous calls\n\t DropboxFileSystem.prototype.supportsSymlinks = function supportsSymlinks () {\n\t return false;\n\t };\n\t DropboxFileSystem.prototype.supportsProps = function supportsProps () {\n\t return false;\n\t };\n\t DropboxFileSystem.prototype.supportsSynch = function supportsSynch () {\n\t return false;\n\t };\n\t DropboxFileSystem.prototype.empty = function empty (mainCb) {\n\t var this$1 = this;\n\t\n\t this._client.readdir('/', function (error, files) {\n\t if (error) {\n\t mainCb(this$1.convert(error, '/'));\n\t }\n\t else {\n\t var deleteFile = function (file, cb) {\n\t var p = path.join('/', file);\n\t this$1._client.remove(p, function (err) {\n\t cb(err ? this$1.convert(err, p) : null);\n\t });\n\t };\n\t var finished = function (err) {\n\t if (err) {\n\t mainCb(err);\n\t }\n\t else {\n\t mainCb();\n\t }\n\t };\n\t // XXX: typing is to get around overly-restrictive ErrorCallback typing.\n\t eachLimit(files, deleteFile, finished);\n\t }\n\t });\n\t };\n\t DropboxFileSystem.prototype.rename = function rename (oldPath, newPath, cb) {\n\t var this$1 = this;\n\t\n\t this._client.move(oldPath, newPath, function (error) {\n\t if (error) {\n\t // the move is permitted if newPath is a file.\n\t // Check if this is the case, and remove if so.\n\t this$1._client.stat(newPath, function (error2, stat) {\n\t if (error2 || stat.isFolder) {\n\t var missingPath = error.response.error.indexOf(oldPath) > -1 ? oldPath : newPath;\n\t cb(this$1.convert(error, missingPath));\n\t }\n\t else {\n\t // Delete file, repeat rename.\n\t this$1._client.remove(newPath, function (error2) {\n\t if (error2) {\n\t cb(this$1.convert(error2, newPath));\n\t }\n\t else {\n\t this$1.rename(oldPath, newPath, cb);\n\t }\n\t });\n\t }\n\t });\n\t }\n\t else {\n\t cb();\n\t }\n\t });\n\t };\n\t DropboxFileSystem.prototype.stat = function stat (path$$1, isLstat, cb) {\n\t var this$1 = this;\n\t\n\t // Ignore lstat case -- Dropbox doesn't support symlinks\n\t // Stat the file\n\t this._client.stat(path$$1, function (error, stat) {\n\t if (error) {\n\t cb(this$1.convert(error, path$$1));\n\t }\n\t else if (stat && stat.isRemoved) {\n\t // Dropbox keeps track of deleted files, so if a file has existed in the\n\t // past but doesn't any longer, you wont get an error\n\t cb(ApiError.FileError(ErrorCode.ENOENT, path$$1));\n\t }\n\t else {\n\t var stats = new Stats(this$1._statType(stat), stat.size);\n\t return cb(null, stats);\n\t }\n\t });\n\t };\n\t DropboxFileSystem.prototype.open = function open (path$$1, flags, mode, cb) {\n\t var this$1 = this;\n\t\n\t // Try and get the file's contents\n\t this._client.readFile(path$$1, function (error, content, dbStat) {\n\t if (error) {\n\t // If the file's being opened for reading and doesn't exist, return an\n\t // error\n\t if (flags.isReadable()) {\n\t cb(this$1.convert(error, path$$1));\n\t }\n\t else {\n\t switch (error.status) {\n\t // If it's being opened for writing or appending, create it so that\n\t // it can be written to\n\t case Dropbox.ApiError.NOT_FOUND:\n\t var ab = new ArrayBuffer(0);\n\t return this$1._writeFileStrict(path$$1, ab, function (error2, stat) {\n\t if (error2) {\n\t cb(error2);\n\t }\n\t else {\n\t var file = this$1._makeFile(path$$1, flags, stat, arrayBuffer2Buffer(ab));\n\t cb(null, file);\n\t }\n\t });\n\t default:\n\t return cb(this$1.convert(error, path$$1));\n\t }\n\t }\n\t }\n\t else {\n\t // No error\n\t var buffer$$1;\n\t // Dropbox.js seems to set `content` to `null` rather than to an empty\n\t // buffer when reading an empty file. Not sure why this is.\n\t if (content === null) {\n\t buffer$$1 = emptyBuffer();\n\t }\n\t else {\n\t buffer$$1 = arrayBuffer2Buffer(content);\n\t }\n\t var file = this$1._makeFile(path$$1, flags, dbStat, buffer$$1);\n\t return cb(null, file);\n\t }\n\t });\n\t };\n\t DropboxFileSystem.prototype._writeFileStrict = function _writeFileStrict (p, data, cb) {\n\t var this$1 = this;\n\t\n\t var parent = path.dirname(p);\n\t this.stat(parent, false, function (error, stat) {\n\t if (error) {\n\t cb(ApiError.FileError(ErrorCode.ENOENT, parent));\n\t }\n\t else {\n\t this$1._client.writeFile(p, data, function (error2, stat) {\n\t if (error2) {\n\t cb(this$1.convert(error2, p));\n\t }\n\t else {\n\t cb(null, stat);\n\t }\n\t });\n\t }\n\t });\n\t };\n\t /**\n\t * Private\n\t * Returns a BrowserFS object representing the type of a Dropbox.js stat object\n\t */\n\t DropboxFileSystem.prototype._statType = function _statType (stat) {\n\t return stat.isFile ? FileType.FILE : FileType.DIRECTORY;\n\t };\n\t /**\n\t * Private\n\t * Returns a BrowserFS object representing a File, created from the data\n\t * returned by calls to the Dropbox API.\n\t */\n\t DropboxFileSystem.prototype._makeFile = function _makeFile (path$$1, flag, stat, buffer$$1) {\n\t var type = this._statType(stat);\n\t var stats = new Stats(type, stat.size);\n\t return new DropboxFile(this, path$$1, flag, stats, buffer$$1);\n\t };\n\t /**\n\t * Private\n\t * Delete a file or directory from Dropbox\n\t * isFile should reflect which call was made to remove the it (`unlink` or\n\t * `rmdir`). If this doesn't match what's actually at `path`, an error will be\n\t * returned\n\t */\n\t DropboxFileSystem.prototype._remove = function _remove (path$$1, cb, isFile) {\n\t var this$1 = this;\n\t\n\t this._client.stat(path$$1, function (error, stat) {\n\t if (error) {\n\t cb(this$1.convert(error, path$$1));\n\t }\n\t else {\n\t if (stat.isFile && !isFile) {\n\t cb(ApiError.FileError(ErrorCode.ENOTDIR, path$$1));\n\t }\n\t else if (!stat.isFile && isFile) {\n\t cb(ApiError.FileError(ErrorCode.EISDIR, path$$1));\n\t }\n\t else {\n\t this$1._client.remove(path$$1, function (error) {\n\t if (error) {\n\t cb(this$1.convert(error, path$$1));\n\t }\n\t else {\n\t cb(null);\n\t }\n\t });\n\t }\n\t }\n\t });\n\t };\n\t /**\n\t * Delete a file\n\t */\n\t DropboxFileSystem.prototype.unlink = function unlink (path$$1, cb) {\n\t this._remove(path$$1, cb, true);\n\t };\n\t /**\n\t * Delete a directory\n\t */\n\t DropboxFileSystem.prototype.rmdir = function rmdir (path$$1, cb) {\n\t this._remove(path$$1, cb, false);\n\t };\n\t /**\n\t * Create a directory\n\t */\n\t DropboxFileSystem.prototype.mkdir = function mkdir (p, mode, cb) {\n\t var this$1 = this;\n\t\n\t // Dropbox.js' client.mkdir() behaves like `mkdir -p`, i.e. it creates a\n\t // directory and all its ancestors if they don't exist.\n\t // Node's fs.mkdir() behaves like `mkdir`, i.e. it throws an error if an attempt\n\t // is made to create a directory without a parent.\n\t // To handle this inconsistency, a check for the existence of `path`'s parent\n\t // must be performed before it is created, and an error thrown if it does\n\t // not exist\n\t var parent = path.dirname(p);\n\t this._client.stat(parent, function (error, stat) {\n\t if (error) {\n\t cb(this$1.convert(error, parent));\n\t }\n\t else {\n\t this$1._client.mkdir(p, function (error) {\n\t if (error) {\n\t cb(ApiError.FileError(ErrorCode.EEXIST, p));\n\t }\n\t else {\n\t cb(null);\n\t }\n\t });\n\t }\n\t });\n\t };\n\t /**\n\t * Get the names of the files in a directory\n\t */\n\t DropboxFileSystem.prototype.readdir = function readdir (path$$1, cb) {\n\t var this$1 = this;\n\t\n\t this._client.readdir(path$$1, function (error, files) {\n\t if (error) {\n\t return cb(this$1.convert(error));\n\t }\n\t else {\n\t return cb(null, files);\n\t }\n\t });\n\t };\n\t /**\n\t * Converts a Dropbox-JS error into a BFS error.\n\t */\n\t DropboxFileSystem.prototype.convert = function convert (err, path$$1) {\n\t if ( path$$1 === void 0 ) path$$1 = null;\n\t\n\t var errorCode = errorCodeLookup[err.status];\n\t if (errorCode === undefined) {\n\t errorCode = ErrorCode.EIO;\n\t }\n\t if (!path$$1) {\n\t return new ApiError(errorCode);\n\t }\n\t else {\n\t return ApiError.FileError(errorCode, path$$1);\n\t }\n\t };\n\t\n\t return DropboxFileSystem;\n\t}(BaseFileSystem));\n\t\n\tDropboxFileSystem.Name = \"Dropbox\";\n\tDropboxFileSystem.Options = {\n\t client: {\n\t type: \"object\",\n\t description: \"An *authenticated* Dropbox client. Must be from the 0.10 JS SDK.\",\n\t validator: function (opt, cb) {\n\t if (opt.isAuthenticated && opt.isAuthenticated()) {\n\t cb();\n\t }\n\t else {\n\t cb(new ApiError(ErrorCode.EINVAL, \"'client' option must be an authenticated Dropbox client from the v0.10 JS SDK.\"));\n\t }\n\t }\n\t }\n\t};\n\t\n\t/**\n\t * @hidden\n\t */\n\tfunction convertError(e, path$$1) {\n\t if ( path$$1 === void 0 ) path$$1 = '';\n\t\n\t var errno = e.errno;\n\t var parent = e.node;\n\t var paths = [];\n\t while (parent) {\n\t paths.unshift(parent.name);\n\t if (parent === parent.parent) {\n\t break;\n\t }\n\t parent = parent.parent;\n\t }\n\t return new ApiError(errno, ErrorStrings[errno], paths.length > 0 ? '/' + paths.join('/') : path$$1);\n\t}\n\tvar EmscriptenFile = (function (BaseFile$$1) {\n\t function EmscriptenFile(_fs, _FS, _path, _stream) {\n\t BaseFile$$1.call(this);\n\t this._fs = _fs;\n\t this._FS = _FS;\n\t this._path = _path;\n\t this._stream = _stream;\n\t }\n\t\n\t if ( BaseFile$$1 ) EmscriptenFile.__proto__ = BaseFile$$1;\n\t EmscriptenFile.prototype = Object.create( BaseFile$$1 && BaseFile$$1.prototype );\n\t EmscriptenFile.prototype.constructor = EmscriptenFile;\n\t EmscriptenFile.prototype.getPos = function getPos () {\n\t return undefined;\n\t };\n\t EmscriptenFile.prototype.close = function close (cb) {\n\t var err = null;\n\t try {\n\t this.closeSync();\n\t }\n\t catch (e) {\n\t err = e;\n\t }\n\t finally {\n\t cb(err);\n\t }\n\t };\n\t EmscriptenFile.prototype.closeSync = function closeSync () {\n\t try {\n\t this._FS.close(this._stream);\n\t }\n\t catch (e) {\n\t throw convertError(e, this._path);\n\t }\n\t };\n\t EmscriptenFile.prototype.stat = function stat (cb) {\n\t try {\n\t cb(null, this.statSync());\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t EmscriptenFile.prototype.statSync = function statSync () {\n\t try {\n\t return this._fs.statSync(this._path, false);\n\t }\n\t catch (e) {\n\t throw convertError(e, this._path);\n\t }\n\t };\n\t EmscriptenFile.prototype.truncate = function truncate (len, cb) {\n\t var err = null;\n\t try {\n\t this.truncateSync(len);\n\t }\n\t catch (e) {\n\t err = e;\n\t }\n\t finally {\n\t cb(err);\n\t }\n\t };\n\t EmscriptenFile.prototype.truncateSync = function truncateSync (len) {\n\t try {\n\t this._FS.ftruncate(this._stream.fd, len);\n\t }\n\t catch (e) {\n\t throw convertError(e, this._path);\n\t }\n\t };\n\t EmscriptenFile.prototype.write = function write (buffer$$1, offset, length, position, cb) {\n\t try {\n\t cb(null, this.writeSync(buffer$$1, offset, length, position), buffer$$1);\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t EmscriptenFile.prototype.writeSync = function writeSync (buffer$$1, offset, length, position) {\n\t try {\n\t var u8 = buffer2Uint8array(buffer$$1);\n\t // Emscripten is particular about what position is set to.\n\t var emPosition = position === null ? undefined : position;\n\t return this._FS.write(this._stream, u8, offset, length, emPosition);\n\t }\n\t catch (e) {\n\t throw convertError(e, this._path);\n\t }\n\t };\n\t EmscriptenFile.prototype.read = function read (buffer$$1, offset, length, position, cb) {\n\t try {\n\t cb(null, this.readSync(buffer$$1, offset, length, position), buffer$$1);\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t EmscriptenFile.prototype.readSync = function readSync (buffer$$1, offset, length, position) {\n\t try {\n\t var u8 = buffer2Uint8array(buffer$$1);\n\t // Emscripten is particular about what position is set to.\n\t var emPosition = position === null ? undefined : position;\n\t return this._FS.read(this._stream, u8, offset, length, emPosition);\n\t }\n\t catch (e) {\n\t throw convertError(e, this._path);\n\t }\n\t };\n\t EmscriptenFile.prototype.sync = function sync (cb) {\n\t // NOP.\n\t cb();\n\t };\n\t EmscriptenFile.prototype.syncSync = function syncSync () {\n\t // NOP.\n\t };\n\t EmscriptenFile.prototype.chown = function chown (uid, gid, cb) {\n\t var err = null;\n\t try {\n\t this.chownSync(uid, gid);\n\t }\n\t catch (e) {\n\t err = e;\n\t }\n\t finally {\n\t cb(err);\n\t }\n\t };\n\t EmscriptenFile.prototype.chownSync = function chownSync (uid, gid) {\n\t try {\n\t this._FS.fchown(this._stream.fd, uid, gid);\n\t }\n\t catch (e) {\n\t throw convertError(e, this._path);\n\t }\n\t };\n\t EmscriptenFile.prototype.chmod = function chmod (mode, cb) {\n\t var err = null;\n\t try {\n\t this.chmodSync(mode);\n\t }\n\t catch (e) {\n\t err = e;\n\t }\n\t finally {\n\t cb(err);\n\t }\n\t };\n\t EmscriptenFile.prototype.chmodSync = function chmodSync (mode) {\n\t try {\n\t this._FS.fchmod(this._stream.fd, mode);\n\t }\n\t catch (e) {\n\t throw convertError(e, this._path);\n\t }\n\t };\n\t EmscriptenFile.prototype.utimes = function utimes (atime, mtime, cb) {\n\t var err = null;\n\t try {\n\t this.utimesSync(atime, mtime);\n\t }\n\t catch (e) {\n\t err = e;\n\t }\n\t finally {\n\t cb(err);\n\t }\n\t };\n\t EmscriptenFile.prototype.utimesSync = function utimesSync (atime, mtime) {\n\t this._fs.utimesSync(this._path, atime, mtime);\n\t };\n\t\n\t return EmscriptenFile;\n\t}(BaseFile));\n\t/**\n\t * Mounts an Emscripten file system into the BrowserFS file system.\n\t */\n\tvar EmscriptenFileSystem = (function (SynchronousFileSystem$$1) {\n\t function EmscriptenFileSystem(_FS) {\n\t SynchronousFileSystem$$1.call(this);\n\t this._FS = _FS;\n\t }\n\t\n\t if ( SynchronousFileSystem$$1 ) EmscriptenFileSystem.__proto__ = SynchronousFileSystem$$1;\n\t EmscriptenFileSystem.prototype = Object.create( SynchronousFileSystem$$1 && SynchronousFileSystem$$1.prototype );\n\t EmscriptenFileSystem.prototype.constructor = EmscriptenFileSystem;\n\t /**\n\t * Create an EmscriptenFileSystem instance with the given options.\n\t */\n\t EmscriptenFileSystem.Create = function Create (opts, cb) {\n\t cb(null, new EmscriptenFileSystem(opts.FS));\n\t };\n\t EmscriptenFileSystem.isAvailable = function isAvailable () { return true; };\n\t EmscriptenFileSystem.prototype.getName = function getName () { return this._FS.DB_NAME(); };\n\t EmscriptenFileSystem.prototype.isReadOnly = function isReadOnly () { return false; };\n\t EmscriptenFileSystem.prototype.supportsLinks = function supportsLinks () { return true; };\n\t EmscriptenFileSystem.prototype.supportsProps = function supportsProps () { return true; };\n\t EmscriptenFileSystem.prototype.supportsSynch = function supportsSynch () { return true; };\n\t EmscriptenFileSystem.prototype.renameSync = function renameSync (oldPath, newPath) {\n\t try {\n\t this._FS.rename(oldPath, newPath);\n\t }\n\t catch (e) {\n\t if (e.errno === ErrorCode.ENOENT) {\n\t throw convertError(e, this.existsSync(oldPath) ? newPath : oldPath);\n\t }\n\t else {\n\t throw convertError(e);\n\t }\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.statSync = function statSync (p, isLstat) {\n\t try {\n\t var stats = isLstat ? this._FS.lstat(p) : this._FS.stat(p);\n\t var itemType = this.modeToFileType(stats.mode);\n\t return new Stats(itemType, stats.size, stats.mode, stats.atime, stats.mtime, stats.ctime);\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.openSync = function openSync (p, flag, mode) {\n\t try {\n\t var stream = this._FS.open(p, flag.getFlagString(), mode);\n\t if (this._FS.isDir(stream.node.mode)) {\n\t this._FS.close(stream);\n\t throw ApiError.EISDIR(p);\n\t }\n\t return new EmscriptenFile(this, this._FS, p, stream);\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.unlinkSync = function unlinkSync (p) {\n\t try {\n\t this._FS.unlink(p);\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.rmdirSync = function rmdirSync (p) {\n\t try {\n\t this._FS.rmdir(p);\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.mkdirSync = function mkdirSync (p, mode) {\n\t try {\n\t this._FS.mkdir(p, mode);\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.readdirSync = function readdirSync (p) {\n\t try {\n\t // Emscripten returns items for '.' and '..'. Node does not.\n\t return this._FS.readdir(p).filter(function (p) { return p !== '.' && p !== '..'; });\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.truncateSync = function truncateSync (p, len) {\n\t try {\n\t this._FS.truncate(p, len);\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.readFileSync = function readFileSync (p, encoding, flag) {\n\t try {\n\t var data = this._FS.readFile(p, { flags: flag.getFlagString() });\n\t var buff = uint8Array2Buffer(data);\n\t if (encoding) {\n\t return buff.toString(encoding);\n\t }\n\t else {\n\t return buff;\n\t }\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.writeFileSync = function writeFileSync (p, data, encoding, flag, mode) {\n\t try {\n\t if (encoding) {\n\t data = Buffer.from(data, encoding);\n\t }\n\t var u8 = buffer2Uint8array(data);\n\t this._FS.writeFile(p, u8, { flags: flag.getFlagString(), encoding: 'binary' });\n\t this._FS.chmod(p, mode);\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.chmodSync = function chmodSync (p, isLchmod, mode) {\n\t try {\n\t isLchmod ? this._FS.lchmod(p, mode) : this._FS.chmod(p, mode);\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.chownSync = function chownSync (p, isLchown, uid, gid) {\n\t try {\n\t isLchown ? this._FS.lchown(p, uid, gid) : this._FS.chown(p, uid, gid);\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.symlinkSync = function symlinkSync (srcpath, dstpath, type) {\n\t try {\n\t this._FS.symlink(srcpath, dstpath);\n\t }\n\t catch (e) {\n\t throw convertError(e);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.readlinkSync = function readlinkSync (p) {\n\t try {\n\t return this._FS.readlink(p);\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.utimesSync = function utimesSync (p, atime, mtime) {\n\t try {\n\t this._FS.utime(p, atime.getTime(), mtime.getTime());\n\t }\n\t catch (e) {\n\t throw convertError(e, p);\n\t }\n\t };\n\t EmscriptenFileSystem.prototype.modeToFileType = function modeToFileType (mode) {\n\t if (this._FS.isDir(mode)) {\n\t return FileType.DIRECTORY;\n\t }\n\t else if (this._FS.isFile(mode)) {\n\t return FileType.FILE;\n\t }\n\t else if (this._FS.isLink(mode)) {\n\t return FileType.SYMLINK;\n\t }\n\t else {\n\t throw ApiError.EPERM((\"Invalid mode: \" + mode));\n\t }\n\t };\n\t\n\t return EmscriptenFileSystem;\n\t}(SynchronousFileSystem));\n\t\n\tEmscriptenFileSystem.Name = \"EmscriptenFileSystem\";\n\tEmscriptenFileSystem.Options = {\n\t FS: {\n\t type: \"object\",\n\t description: \"The Emscripten file system to use (the `FS` variable)\"\n\t }\n\t};\n\t\n\t/**\n\t * The FolderAdapter file system wraps a file system, and scopes all interactions to a subfolder of that file system.\n\t *\n\t * Example: Given a file system `foo` with folder `bar` and file `bar/baz`...\n\t *\n\t * ```javascript\n\t * BrowserFS.configure({\n\t * fs: \"FolderAdapter\",\n\t * options: {\n\t * folder: \"bar\",\n\t * wrapped: foo\n\t * }\n\t * }, function(e) {\n\t * var fs = BrowserFS.BFSRequire('fs');\n\t * fs.readdirSync('/'); // ['baz']\n\t * });\n\t * ```\n\t */\n\tvar FolderAdapter = (function (BaseFileSystem$$1) {\n\t function FolderAdapter(folder, wrapped) {\n\t BaseFileSystem$$1.call(this);\n\t this._folder = folder;\n\t this._wrapped = wrapped;\n\t }\n\t\n\t if ( BaseFileSystem$$1 ) FolderAdapter.__proto__ = BaseFileSystem$$1;\n\t FolderAdapter.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );\n\t FolderAdapter.prototype.constructor = FolderAdapter;\n\t /**\n\t * Creates a FolderAdapter instance with the given options.\n\t */\n\t FolderAdapter.Create = function Create (opts, cb) {\n\t cb(null, new FolderAdapter(opts.folder, opts.wrapped));\n\t };\n\t FolderAdapter.isAvailable = function isAvailable () {\n\t return true;\n\t };\n\t /**\n\t * Initialize the file system. Ensures that the wrapped file system\n\t * has the given folder.\n\t */\n\t FolderAdapter.prototype.initialize = function initialize (cb) {\n\t var this$1 = this;\n\t\n\t this._wrapped.exists(this._folder, function (exists) {\n\t if (exists) {\n\t cb();\n\t }\n\t else if (this$1._wrapped.isReadOnly()) {\n\t cb(ApiError.ENOENT(this$1._folder));\n\t }\n\t else {\n\t this$1._wrapped.mkdir(this$1._folder, 0x1ff, cb);\n\t }\n\t });\n\t };\n\t FolderAdapter.prototype.getName = function getName () { return this._wrapped.getName(); };\n\t FolderAdapter.prototype.isReadOnly = function isReadOnly () { return this._wrapped.isReadOnly(); };\n\t FolderAdapter.prototype.supportsProps = function supportsProps () { return this._wrapped.supportsProps(); };\n\t FolderAdapter.prototype.supportsSynch = function supportsSynch () { return this._wrapped.supportsSynch(); };\n\t FolderAdapter.prototype.supportsLinks = function supportsLinks () { return false; };\n\t\n\t return FolderAdapter;\n\t}(BaseFileSystem));\n\t\n\tFolderAdapter.Name = \"FolderAdapter\";\n\tFolderAdapter.Options = {\n\t folder: {\n\t type: \"string\",\n\t description: \"The folder to use as the root directory\"\n\t },\n\t wrapped: {\n\t type: \"object\",\n\t description: \"The file system to wrap\"\n\t }\n\t};\n\t/**\n\t * @hidden\n\t */\n\tfunction translateError(folder, e) {\n\t if (e !== null && typeof e === 'object') {\n\t var err = e;\n\t var p = err.path;\n\t if (p) {\n\t p = '/' + path.relative(folder, p);\n\t err.message = err.message.replace(err.path, p);\n\t err.path = p;\n\t }\n\t }\n\t return e;\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction wrapCallback(folder, cb) {\n\t if (typeof cb === 'function') {\n\t return function (err) {\n\t if (arguments.length > 0) {\n\t arguments[0] = translateError(folder, err);\n\t }\n\t cb.apply(null, arguments);\n\t };\n\t }\n\t else {\n\t return cb;\n\t }\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction wrapFunction(name, wrapFirst, wrapSecond) {\n\t if (name.slice(name.length - 4) !== 'Sync') {\n\t // Async function. Translate error in callback.\n\t return function () {\n\t if (arguments.length > 0) {\n\t if (wrapFirst) {\n\t arguments[0] = path.join(this._folder, arguments[0]);\n\t }\n\t if (wrapSecond) {\n\t arguments[1] = path.join(this._folder, arguments[1]);\n\t }\n\t arguments[arguments.length - 1] = wrapCallback(this._folder, arguments[arguments.length - 1]);\n\t }\n\t return this._wrapped[name].apply(this._wrapped, arguments);\n\t };\n\t }\n\t else {\n\t // Sync function. Translate error in catch.\n\t return function () {\n\t try {\n\t if (wrapFirst) {\n\t arguments[0] = path.join(this._folder, arguments[0]);\n\t }\n\t if (wrapSecond) {\n\t arguments[1] = path.join(this._folder, arguments[1]);\n\t }\n\t return this._wrapped[name].apply(this._wrapped, arguments);\n\t }\n\t catch (e) {\n\t throw translateError(this._folder, e);\n\t }\n\t };\n\t }\n\t}\n\t// First argument is a path.\n\t['diskSpace', 'stat', 'statSync', 'open', 'openSync', 'unlink', 'unlinkSync',\n\t 'rmdir', 'rmdirSync', 'mkdir', 'mkdirSync', 'readdir', 'readdirSync', 'exists',\n\t 'existsSync', 'realpath', 'realpathSync', 'truncate', 'truncateSync', 'readFile',\n\t 'readFileSync', 'writeFile', 'writeFileSync', 'appendFile', 'appendFileSync',\n\t 'chmod', 'chmodSync', 'chown', 'chownSync', 'utimes', 'utimesSync', 'readlink',\n\t 'readlinkSync'].forEach(function (name) {\n\t FolderAdapter.prototype[name] = wrapFunction(name, true, false);\n\t});\n\t// First and second arguments are paths.\n\t['rename', 'renameSync', 'link', 'linkSync', 'symlink', 'symlinkSync'].forEach(function (name) {\n\t FolderAdapter.prototype[name] = wrapFunction(name, true, true);\n\t});\n\t\n\t/**\n\t * @hidden\n\t */\n\tvar toExport;\n\tif (typeof (window) !== 'undefined') {\n\t toExport = window;\n\t}\n\telse if (typeof (self) !== 'undefined') {\n\t toExport = self;\n\t}\n\telse {\n\t toExport = global;\n\t}\n\tvar global$1 = toExport;\n\t\n\t/**\n\t * @hidden\n\t */\n\tfunction isDirectoryEntry(entry) {\n\t return entry.isDirectory;\n\t}\n\t/**\n\t * @hidden\n\t */\n\tvar _getFS = global$1.webkitRequestFileSystem || global$1.requestFileSystem || null;\n\t/**\n\t * @hidden\n\t */\n\tfunction _requestQuota(type, size, success, errorCallback) {\n\t // We cast navigator and window to '' because everything here is\n\t // nonstandard functionality, despite the fact that Chrome has the only\n\t // implementation of the HTML5FS and is likely driving the standardization\n\t // process. Thus, these objects defined off of navigator and window are not\n\t // present in the DefinitelyTyped TypeScript typings for FileSystem.\n\t if (typeof navigator['webkitPersistentStorage'] !== 'undefined') {\n\t switch (type) {\n\t case global$1.PERSISTENT:\n\t navigator.webkitPersistentStorage.requestQuota(size, success, errorCallback);\n\t break;\n\t case global$1.TEMPORARY:\n\t navigator.webkitTemporaryStorage.requestQuota(size, success, errorCallback);\n\t break;\n\t default:\n\t errorCallback(new TypeError((\"Invalid storage type: \" + type)));\n\t break;\n\t }\n\t }\n\t else {\n\t global$1.webkitStorageInfo.requestQuota(type, size, success, errorCallback);\n\t }\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction _toArray(list) {\n\t return Array.prototype.slice.call(list || [], 0);\n\t}\n\t/**\n\t * Converts the given DOMError into an appropriate ApiError.\n\t * @url https://developer.mozilla.org/en-US/docs/Web/API/DOMError\n\t * @hidden\n\t */\n\tfunction convertError$1(err, p, expectedDir) {\n\t switch (err.name) {\n\t /* The user agent failed to create a file or directory due to the existence of a file or\n\t directory with the same path. */\n\t case \"PathExistsError\":\n\t return ApiError.EEXIST(p);\n\t /* The operation failed because it would cause the application to exceed its storage quota. */\n\t case 'QuotaExceededError':\n\t return ApiError.FileError(ErrorCode.ENOSPC, p);\n\t /* A required file or directory could not be found at the time an operation was processed. */\n\t case 'NotFoundError':\n\t return ApiError.ENOENT(p);\n\t /* This is a security error code to be used in situations not covered by any other error codes.\n\t - A required file was unsafe for access within a Web application\n\t - Too many calls are being made on filesystem resources */\n\t case 'SecurityError':\n\t return ApiError.FileError(ErrorCode.EACCES, p);\n\t /* The modification requested was illegal. Examples of invalid modifications include moving a\n\t directory into its own child, moving a file into its parent directory without changing its name,\n\t or copying a directory to a path occupied by a file. */\n\t case 'InvalidModificationError':\n\t return ApiError.FileError(ErrorCode.EPERM, p);\n\t /* The user has attempted to look up a file or directory, but the Entry found is of the wrong type\n\t [e.g. is a DirectoryEntry when the user requested a FileEntry]. */\n\t case 'TypeMismatchError':\n\t return ApiError.FileError(expectedDir ? ErrorCode.ENOTDIR : ErrorCode.EISDIR, p);\n\t /* A path or URL supplied to the API was malformed. */\n\t case \"EncodingError\":\n\t /* An operation depended on state cached in an interface object, but that state that has changed\n\t since it was read from disk. */\n\t case \"InvalidStateError\":\n\t /* The user attempted to write to a file or directory which could not be modified due to the state\n\t of the underlying filesystem. */\n\t case \"NoModificationAllowedError\":\n\t default:\n\t return ApiError.FileError(ErrorCode.EINVAL, p);\n\t }\n\t}\n\t// A note about getFile and getDirectory options:\n\t// These methods are called at numerous places in this file, and are passed\n\t// some combination of these two options:\n\t// - create: If true, the entry will be created if it doesn't exist.\n\t// If false, an error will be thrown if it doesn't exist.\n\t// - exclusive: If true, only create the entry if it doesn't already exist,\n\t// and throw an error if it does.\n\tvar HTML5FSFile = (function (PreloadFile$$1) {\n\t function HTML5FSFile(fs, entry, path$$1, flag, stat, contents) {\n\t PreloadFile$$1.call(this, fs, path$$1, flag, stat, contents);\n\t this._entry = entry;\n\t }\n\t\n\t if ( PreloadFile$$1 ) HTML5FSFile.__proto__ = PreloadFile$$1;\n\t HTML5FSFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );\n\t HTML5FSFile.prototype.constructor = HTML5FSFile;\n\t HTML5FSFile.prototype.sync = function sync (cb) {\n\t var this$1 = this;\n\t\n\t if (!this.isDirty()) {\n\t return cb();\n\t }\n\t this._entry.createWriter(function (writer) {\n\t var buffer$$1 = this$1.getBuffer();\n\t var blob = new Blob([buffer2ArrayBuffer(buffer$$1)]);\n\t var length = blob.size;\n\t writer.onwriteend = function (err) {\n\t writer.onwriteend = null;\n\t writer.onerror = null;\n\t writer.truncate(length);\n\t this$1.resetDirty();\n\t cb();\n\t };\n\t writer.onerror = function (err) {\n\t cb(convertError$1(err, this$1.getPath(), false));\n\t };\n\t writer.write(blob);\n\t });\n\t };\n\t HTML5FSFile.prototype.close = function close (cb) {\n\t this.sync(cb);\n\t };\n\t\n\t return HTML5FSFile;\n\t}(PreloadFile));\n\t/**\n\t * A read-write filesystem backed by the HTML5 FileSystem API.\n\t *\n\t * As the HTML5 FileSystem is only implemented in Blink, this interface is\n\t * only available in Chrome.\n\t */\n\tvar HTML5FS = (function (BaseFileSystem$$1) {\n\t function HTML5FS(size, type, deprecateMsg) {\n\t if ( size === void 0 ) size = 5;\n\t if ( type === void 0 ) type = global$1.PERSISTENT;\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t BaseFileSystem$$1.call(this);\n\t // Convert MB to bytes.\n\t this.size = 1024 * 1024 * size;\n\t this.type = type;\n\t deprecationMessage(deprecateMsg, HTML5FS.Name, { size: size, type: type });\n\t }\n\t\n\t if ( BaseFileSystem$$1 ) HTML5FS.__proto__ = BaseFileSystem$$1;\n\t HTML5FS.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );\n\t HTML5FS.prototype.constructor = HTML5FS;\n\t /**\n\t * Creates an HTML5FS instance with the given options.\n\t */\n\t HTML5FS.Create = function Create (opts, cb) {\n\t var fs = new HTML5FS(opts.size, opts.type, false);\n\t fs.allocate(function (e) { return e ? cb(e) : cb(null, fs); }, false);\n\t };\n\t HTML5FS.isAvailable = function isAvailable () {\n\t return !!_getFS;\n\t };\n\t HTML5FS.prototype.getName = function getName () {\n\t return HTML5FS.Name;\n\t };\n\t HTML5FS.prototype.isReadOnly = function isReadOnly () {\n\t return false;\n\t };\n\t HTML5FS.prototype.supportsSymlinks = function supportsSymlinks () {\n\t return false;\n\t };\n\t HTML5FS.prototype.supportsProps = function supportsProps () {\n\t return false;\n\t };\n\t HTML5FS.prototype.supportsSynch = function supportsSynch () {\n\t return false;\n\t };\n\t /**\n\t * **Deprecated. Please use Create() method instead to create and allocate an HTML5FS.**\n\t *\n\t * Requests a storage quota from the browser to back this FS.\n\t * Must be called before file system can be used!\n\t */\n\t HTML5FS.prototype.allocate = function allocate (cb, deprecateMsg) {\n\t var this$1 = this;\n\t if ( cb === void 0 ) cb = function () { };\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t if (deprecateMsg) {\n\t console.warn((\"[HTML5FS] HTML5FS.allocate() is deprecated and will be removed in the next major release. Please use 'HTML5FS.Create({type: \" + (this.type) + \", size: \" + (this.size) + \"}, cb)' to create and allocate HTML5FS instances.\"));\n\t }\n\t var success = function (fs) {\n\t this$1.fs = fs;\n\t cb();\n\t };\n\t var error = function (err) {\n\t cb(convertError$1(err, \"/\", true));\n\t };\n\t if (this.type === global$1.PERSISTENT) {\n\t _requestQuota(this.type, this.size, function (granted) {\n\t _getFS(this$1.type, granted, success, error);\n\t }, error);\n\t }\n\t else {\n\t _getFS(this.type, this.size, success, error);\n\t }\n\t };\n\t /**\n\t * Deletes everything in the FS. Used for testing.\n\t * Karma clears the storage after you quit it but not between runs of the test\n\t * suite, and the tests expect an empty FS every time.\n\t */\n\t HTML5FS.prototype.empty = function empty (mainCb) {\n\t // Get a list of all entries in the root directory to delete them\n\t this._readdir('/', function (err, entries) {\n\t if (err) {\n\t console.error('Failed to empty FS');\n\t mainCb(err);\n\t }\n\t else {\n\t // Called when every entry has been operated on\n\t var finished = function (er) {\n\t if (err) {\n\t console.error(\"Failed to empty FS\");\n\t mainCb(err);\n\t }\n\t else {\n\t mainCb();\n\t }\n\t };\n\t // Removes files and recursively removes directories\n\t var deleteEntry = function (entry, cb) {\n\t var succ = function () {\n\t cb();\n\t };\n\t var error = function (err) {\n\t cb(convertError$1(err, entry.fullPath, !entry.isDirectory));\n\t };\n\t if (isDirectoryEntry(entry)) {\n\t entry.removeRecursively(succ, error);\n\t }\n\t else {\n\t entry.remove(succ, error);\n\t }\n\t };\n\t // Loop through the entries and remove them, then call the callback\n\t // when they're all finished.\n\t eachLimit(entries, deleteEntry, finished);\n\t }\n\t });\n\t };\n\t HTML5FS.prototype.rename = function rename (oldPath, newPath, cb) {\n\t var this$1 = this;\n\t\n\t var semaphore = 2;\n\t var successCount = 0;\n\t var root = this.fs.root;\n\t var currentPath = oldPath;\n\t var error = function (err) {\n\t if (--semaphore <= 0) {\n\t cb(convertError$1(err, currentPath, false));\n\t }\n\t };\n\t var success = function (file) {\n\t if (++successCount === 2) {\n\t return cb(new ApiError(ErrorCode.EINVAL, \"Something was identified as both a file and a directory. This should never happen.\"));\n\t }\n\t // SPECIAL CASE: If newPath === oldPath, and the path exists, then\n\t // this operation trivially succeeds.\n\t if (oldPath === newPath) {\n\t return cb();\n\t }\n\t // Get the new parent directory.\n\t currentPath = path.dirname(newPath);\n\t root.getDirectory(currentPath, {}, function (parentDir) {\n\t currentPath = path.basename(newPath);\n\t file.moveTo(parentDir, currentPath, function (entry) { cb(); }, function (err) {\n\t // SPECIAL CASE: If oldPath is a directory, and newPath is a\n\t // file, rename should delete the file and perform the move.\n\t if (file.isDirectory) {\n\t currentPath = newPath;\n\t // Unlink only works on files. Try to delete newPath.\n\t this$1.unlink(newPath, function (e) {\n\t if (e) {\n\t // newPath is probably a directory.\n\t error(err);\n\t }\n\t else {\n\t // Recur, now that newPath doesn't exist.\n\t this$1.rename(oldPath, newPath, cb);\n\t }\n\t });\n\t }\n\t else {\n\t error(err);\n\t }\n\t });\n\t }, error);\n\t };\n\t // We don't know if oldPath is a *file* or a *directory*, and there's no\n\t // way to stat items. So launch both requests, see which one succeeds.\n\t root.getFile(oldPath, {}, success, error);\n\t root.getDirectory(oldPath, {}, success, error);\n\t };\n\t HTML5FS.prototype.stat = function stat (path$$1, isLstat, cb) {\n\t var this$1 = this;\n\t\n\t // Throw an error if the entry doesn't exist, because then there's nothing\n\t // to stat.\n\t var opts = {\n\t create: false\n\t };\n\t // Called when the path has been successfully loaded as a file.\n\t var loadAsFile = function (entry) {\n\t var fileFromEntry = function (file) {\n\t var stat = new Stats(FileType.FILE, file.size);\n\t cb(null, stat);\n\t };\n\t entry.file(fileFromEntry, failedToLoad);\n\t };\n\t // Called when the path has been successfully loaded as a directory.\n\t var loadAsDir = function (dir$$1) {\n\t // Directory entry size can't be determined from the HTML5 FS API, and is\n\t // implementation-dependant anyway, so a dummy value is used.\n\t var size = 4096;\n\t var stat = new Stats(FileType.DIRECTORY, size);\n\t cb(null, stat);\n\t };\n\t // Called when the path couldn't be opened as a directory or a file.\n\t var failedToLoad = function (err) {\n\t cb(convertError$1(err, path$$1, false /* Unknown / irrelevant */));\n\t };\n\t // Called when the path couldn't be opened as a file, but might still be a\n\t // directory.\n\t var failedToLoadAsFile = function () {\n\t this$1.fs.root.getDirectory(path$$1, opts, loadAsDir, failedToLoad);\n\t };\n\t // No method currently exists to determine whether a path refers to a\n\t // directory or a file, so this implementation tries both and uses the first\n\t // one that succeeds.\n\t this.fs.root.getFile(path$$1, opts, loadAsFile, failedToLoadAsFile);\n\t };\n\t HTML5FS.prototype.open = function open (p, flags, mode, cb) {\n\t var this$1 = this;\n\t\n\t // XXX: err is a DOMError\n\t var error = function (err) {\n\t if (err.name === 'InvalidModificationError' && flags.isExclusive()) {\n\t cb(ApiError.EEXIST(p));\n\t }\n\t else {\n\t cb(convertError$1(err, p, false));\n\t }\n\t };\n\t this.fs.root.getFile(p, {\n\t create: flags.pathNotExistsAction() === ActionType.CREATE_FILE,\n\t exclusive: flags.isExclusive()\n\t }, function (entry) {\n\t // Try to fetch corresponding file.\n\t entry.file(function (file) {\n\t var reader = new FileReader();\n\t reader.onloadend = function (event) {\n\t var bfsFile = this$1._makeFile(p, entry, flags, file, reader.result);\n\t cb(null, bfsFile);\n\t };\n\t reader.onerror = function (ev) {\n\t error(reader.error);\n\t };\n\t reader.readAsArrayBuffer(file);\n\t }, error);\n\t }, error);\n\t };\n\t HTML5FS.prototype.unlink = function unlink (path$$1, cb) {\n\t this._remove(path$$1, cb, true);\n\t };\n\t HTML5FS.prototype.rmdir = function rmdir (path$$1, cb) {\n\t var this$1 = this;\n\t\n\t // Check if directory is non-empty, first.\n\t this.readdir(path$$1, function (e, files) {\n\t if (e) {\n\t cb(e);\n\t }\n\t else if (files.length > 0) {\n\t cb(ApiError.ENOTEMPTY(path$$1));\n\t }\n\t else {\n\t this$1._remove(path$$1, cb, false);\n\t }\n\t });\n\t };\n\t HTML5FS.prototype.mkdir = function mkdir (path$$1, mode, cb) {\n\t // Create the directory, but throw an error if it already exists, as per\n\t // mkdir(1)\n\t var opts = {\n\t create: true,\n\t exclusive: true\n\t };\n\t var success = function (dir$$1) {\n\t cb();\n\t };\n\t var error = function (err) {\n\t cb(convertError$1(err, path$$1, true));\n\t };\n\t this.fs.root.getDirectory(path$$1, opts, success, error);\n\t };\n\t /**\n\t * Map _readdir's list of `FileEntry`s to their names and return that.\n\t */\n\t HTML5FS.prototype.readdir = function readdir (path$$1, cb) {\n\t this._readdir(path$$1, function (e, entries) {\n\t if (entries) {\n\t var rv = [];\n\t for (var i = 0, list = entries; i < list.length; i += 1) {\n\t var entry = list[i];\n\t\n\t rv.push(entry.name);\n\t }\n\t cb(null, rv);\n\t }\n\t else {\n\t return cb(e);\n\t }\n\t });\n\t };\n\t /**\n\t * Returns a BrowserFS object representing a File.\n\t */\n\t HTML5FS.prototype._makeFile = function _makeFile (path$$1, entry, flag, stat, data) {\n\t if ( data === void 0 ) data = new ArrayBuffer(0);\n\t\n\t var stats = new Stats(FileType.FILE, stat.size);\n\t var buffer$$1 = arrayBuffer2Buffer(data);\n\t return new HTML5FSFile(this, entry, path$$1, flag, stats, buffer$$1);\n\t };\n\t /**\n\t * Returns an array of `FileEntry`s. Used internally by empty and readdir.\n\t */\n\t HTML5FS.prototype._readdir = function _readdir (path$$1, cb) {\n\t var error = function (err) {\n\t cb(convertError$1(err, path$$1, true));\n\t };\n\t // Grab the requested directory.\n\t this.fs.root.getDirectory(path$$1, { create: false }, function (dirEntry) {\n\t var reader = dirEntry.createReader();\n\t var entries = [];\n\t // Call the reader.readEntries() until no more results are returned.\n\t var readEntries = function () {\n\t reader.readEntries((function (results) {\n\t if (results.length) {\n\t entries = entries.concat(_toArray(results));\n\t readEntries();\n\t }\n\t else {\n\t cb(null, entries);\n\t }\n\t }), error);\n\t };\n\t readEntries();\n\t }, error);\n\t };\n\t /**\n\t * Delete a file or directory from the file system\n\t * isFile should reflect which call was made to remove the it (`unlink` or\n\t * `rmdir`). If this doesn't match what's actually at `path`, an error will be\n\t * returned\n\t */\n\t HTML5FS.prototype._remove = function _remove (path$$1, cb, isFile) {\n\t var success = function (entry) {\n\t var succ = function () {\n\t cb();\n\t };\n\t var err = function (err) {\n\t cb(convertError$1(err, path$$1, !isFile));\n\t };\n\t entry.remove(succ, err);\n\t };\n\t var error = function (err) {\n\t cb(convertError$1(err, path$$1, !isFile));\n\t };\n\t // Deleting the entry, so don't create it\n\t var opts = {\n\t create: false\n\t };\n\t if (isFile) {\n\t this.fs.root.getFile(path$$1, opts, success, error);\n\t }\n\t else {\n\t this.fs.root.getDirectory(path$$1, opts, success, error);\n\t }\n\t };\n\t\n\t return HTML5FS;\n\t}(BaseFileSystem));\n\t\n\tHTML5FS.Name = \"HTML5FS\";\n\tHTML5FS.Options = {\n\t size: {\n\t type: \"number\",\n\t optional: true,\n\t description: \"Storage quota to request, in megabytes. Allocated value may be less. Defaults to 5.\"\n\t },\n\t type: {\n\t type: \"number\",\n\t optional: true,\n\t description: \"window.PERSISTENT or window.TEMPORARY. Defaults to PERSISTENT.\"\n\t }\n\t};\n\t\n\t/**\n\t * Generic inode definition that can easily be serialized.\n\t */\n\tvar Inode = function Inode(id, size, mode, atime, mtime, ctime) {\n\t this.id = id;\n\t this.size = size;\n\t this.mode = mode;\n\t this.atime = atime;\n\t this.mtime = mtime;\n\t this.ctime = ctime;\n\t};\n\t/**\n\t * Converts the buffer into an Inode.\n\t */\n\tInode.fromBuffer = function fromBuffer (buffer$$1) {\n\t if (buffer$$1 === undefined) {\n\t throw new Error(\"NO\");\n\t }\n\t return new Inode(buffer$$1.toString('ascii', 30), buffer$$1.readUInt32LE(0), buffer$$1.readUInt16LE(4), buffer$$1.readDoubleLE(6), buffer$$1.readDoubleLE(14), buffer$$1.readDoubleLE(22));\n\t};\n\t/**\n\t * Handy function that converts the Inode to a Node Stats object.\n\t */\n\tInode.prototype.toStats = function toStats () {\n\t return new Stats((this.mode & 0xF000) === FileType.DIRECTORY ? FileType.DIRECTORY : FileType.FILE, this.size, this.mode, new Date(this.atime), new Date(this.mtime), new Date(this.ctime));\n\t};\n\t/**\n\t * Get the size of this Inode, in bytes.\n\t */\n\tInode.prototype.getSize = function getSize () {\n\t // ASSUMPTION: ID is ASCII (1 byte per char).\n\t return 30 + this.id.length;\n\t};\n\t/**\n\t * Writes the inode into the start of the buffer.\n\t */\n\tInode.prototype.toBuffer = function toBuffer (buff) {\n\t if ( buff === void 0 ) buff = Buffer.alloc(this.getSize());\n\t\n\t buff.writeUInt32LE(this.size, 0);\n\t buff.writeUInt16LE(this.mode, 4);\n\t buff.writeDoubleLE(this.atime, 6);\n\t buff.writeDoubleLE(this.mtime, 14);\n\t buff.writeDoubleLE(this.ctime, 22);\n\t buff.write(this.id, 30, this.id.length, 'ascii');\n\t return buff;\n\t};\n\t/**\n\t * Updates the Inode using information from the stats object. Used by file\n\t * systems at sync time, e.g.:\n\t * - Program opens file and gets a File object.\n\t * - Program mutates file. File object is responsible for maintaining\n\t * metadata changes locally -- typically in a Stats object.\n\t * - Program closes file. File object's metadata changes are synced with the\n\t * file system.\n\t * @return True if any changes have occurred.\n\t */\n\tInode.prototype.update = function update (stats) {\n\t var hasChanged = false;\n\t if (this.size !== stats.size) {\n\t this.size = stats.size;\n\t hasChanged = true;\n\t }\n\t if (this.mode !== stats.mode) {\n\t this.mode = stats.mode;\n\t hasChanged = true;\n\t }\n\t var atimeMs = stats.atime.getTime();\n\t if (this.atime !== atimeMs) {\n\t this.atime = atimeMs;\n\t hasChanged = true;\n\t }\n\t var mtimeMs = stats.mtime.getTime();\n\t if (this.mtime !== mtimeMs) {\n\t this.mtime = mtimeMs;\n\t hasChanged = true;\n\t }\n\t var ctimeMs = stats.ctime.getTime();\n\t if (this.ctime !== ctimeMs) {\n\t this.ctime = ctimeMs;\n\t hasChanged = true;\n\t }\n\t return hasChanged;\n\t};\n\t// XXX: Copied from Stats. Should reconcile these two into something more\n\t// compact.\n\t/**\n\t * @return [Boolean] True if this item is a file.\n\t */\n\tInode.prototype.isFile = function isFile () {\n\t return (this.mode & 0xF000) === FileType.FILE;\n\t};\n\t/**\n\t * @return [Boolean] True if this item is a directory.\n\t */\n\tInode.prototype.isDirectory = function isDirectory () {\n\t return (this.mode & 0xF000) === FileType.DIRECTORY;\n\t};\n\t\n\t/**\n\t * @hidden\n\t */\n\tvar ROOT_NODE_ID = \"/\";\n\t/**\n\t * @hidden\n\t */\n\tvar emptyDirNode = null;\n\t/**\n\t * Returns an empty directory node.\n\t * @hidden\n\t */\n\tfunction getEmptyDirNode() {\n\t if (emptyDirNode) {\n\t return emptyDirNode;\n\t }\n\t return emptyDirNode = Buffer.from(\"{}\");\n\t}\n\t/**\n\t * Generates a random ID.\n\t * @hidden\n\t */\n\tfunction GenerateRandomID() {\n\t // From http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript\n\t return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n\t var r = Math.random() * 16 | 0;\n\t var v = c === 'x' ? r : (r & 0x3 | 0x8);\n\t return v.toString(16);\n\t });\n\t}\n\t/**\n\t * Helper function. Checks if 'e' is defined. If so, it triggers the callback\n\t * with 'e' and returns false. Otherwise, returns true.\n\t * @hidden\n\t */\n\tfunction noError(e, cb) {\n\t if (e) {\n\t cb(e);\n\t return false;\n\t }\n\t return true;\n\t}\n\t/**\n\t * Helper function. Checks if 'e' is defined. If so, it aborts the transaction,\n\t * triggers the callback with 'e', and returns false. Otherwise, returns true.\n\t * @hidden\n\t */\n\tfunction noErrorTx(e, tx, cb) {\n\t if (e) {\n\t tx.abort(function () {\n\t cb(e);\n\t });\n\t return false;\n\t }\n\t return true;\n\t}\n\t/**\n\t * A simple RW transaction for simple synchronous key-value stores.\n\t */\n\tvar SimpleSyncRWTransaction = function SimpleSyncRWTransaction(store) {\n\t this.store = store;\n\t /**\n\t * Stores data in the keys we modify prior to modifying them.\n\t * Allows us to roll back commits.\n\t */\n\t this.originalData = {};\n\t /**\n\t * List of keys modified in this transaction, if any.\n\t */\n\t this.modifiedKeys = [];\n\t};\n\tSimpleSyncRWTransaction.prototype.get = function get (key) {\n\t var val = this.store.get(key);\n\t this.stashOldValue(key, val);\n\t return val;\n\t};\n\tSimpleSyncRWTransaction.prototype.put = function put (key, data, overwrite) {\n\t this.markModified(key);\n\t return this.store.put(key, data, overwrite);\n\t};\n\tSimpleSyncRWTransaction.prototype.del = function del (key) {\n\t this.markModified(key);\n\t this.store.del(key);\n\t};\n\tSimpleSyncRWTransaction.prototype.commit = function commit () { };\n\tSimpleSyncRWTransaction.prototype.abort = function abort () {\n\t var this$1 = this;\n\t\n\t // Rollback old values.\n\t for (var i = 0, list = this$1.modifiedKeys; i < list.length; i += 1) {\n\t var key = list[i];\n\t\n\t var value = this$1.originalData[key];\n\t if (!value) {\n\t // Key didn't exist.\n\t this$1.store.del(key);\n\t }\n\t else {\n\t // Key existed. Store old value.\n\t this$1.store.put(key, value, true);\n\t }\n\t }\n\t};\n\t/**\n\t * Stashes given key value pair into `originalData` if it doesn't already\n\t * exist. Allows us to stash values the program is requesting anyway to\n\t * prevent needless `get` requests if the program modifies the data later\n\t * on during the transaction.\n\t */\n\tSimpleSyncRWTransaction.prototype.stashOldValue = function stashOldValue (key, value) {\n\t // Keep only the earliest value in the transaction.\n\t if (!this.originalData.hasOwnProperty(key)) {\n\t this.originalData[key] = value;\n\t }\n\t};\n\t/**\n\t * Marks the given key as modified, and stashes its value if it has not been\n\t * stashed already.\n\t */\n\tSimpleSyncRWTransaction.prototype.markModified = function markModified (key) {\n\t if (this.modifiedKeys.indexOf(key) === -1) {\n\t this.modifiedKeys.push(key);\n\t if (!this.originalData.hasOwnProperty(key)) {\n\t this.originalData[key] = this.store.get(key);\n\t }\n\t }\n\t};\n\tvar SyncKeyValueFile = (function (PreloadFile$$1) {\n\t function SyncKeyValueFile(_fs, _path, _flag, _stat, contents) {\n\t PreloadFile$$1.call(this, _fs, _path, _flag, _stat, contents);\n\t }\n\t\n\t if ( PreloadFile$$1 ) SyncKeyValueFile.__proto__ = PreloadFile$$1;\n\t SyncKeyValueFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );\n\t SyncKeyValueFile.prototype.constructor = SyncKeyValueFile;\n\t SyncKeyValueFile.prototype.syncSync = function syncSync () {\n\t if (this.isDirty()) {\n\t this._fs._syncSync(this.getPath(), this.getBuffer(), this.getStats());\n\t this.resetDirty();\n\t }\n\t };\n\t SyncKeyValueFile.prototype.closeSync = function closeSync () {\n\t this.syncSync();\n\t };\n\t\n\t return SyncKeyValueFile;\n\t}(PreloadFile));\n\t/**\n\t * A \"Synchronous key-value file system\". Stores data to/retrieves data from an\n\t * underlying key-value store.\n\t *\n\t * We use a unique ID for each node in the file system. The root node has a\n\t * fixed ID.\n\t * @todo Introduce Node ID caching.\n\t * @todo Check modes.\n\t */\n\tvar SyncKeyValueFileSystem = (function (SynchronousFileSystem$$1) {\n\t function SyncKeyValueFileSystem(options) {\n\t SynchronousFileSystem$$1.call(this);\n\t this.store = options.store;\n\t // INVARIANT: Ensure that the root exists.\n\t this.makeRootDirectory();\n\t }\n\t\n\t if ( SynchronousFileSystem$$1 ) SyncKeyValueFileSystem.__proto__ = SynchronousFileSystem$$1;\n\t SyncKeyValueFileSystem.prototype = Object.create( SynchronousFileSystem$$1 && SynchronousFileSystem$$1.prototype );\n\t SyncKeyValueFileSystem.prototype.constructor = SyncKeyValueFileSystem;\n\t SyncKeyValueFileSystem.isAvailable = function isAvailable () { return true; };\n\t\n\t SyncKeyValueFileSystem.prototype.getName = function getName () { return this.store.name(); };\n\t SyncKeyValueFileSystem.prototype.isReadOnly = function isReadOnly () { return false; };\n\t SyncKeyValueFileSystem.prototype.supportsSymlinks = function supportsSymlinks () { return false; };\n\t SyncKeyValueFileSystem.prototype.supportsProps = function supportsProps () { return false; };\n\t SyncKeyValueFileSystem.prototype.supportsSynch = function supportsSynch () { return true; };\n\t /**\n\t * Delete all contents stored in the file system.\n\t */\n\t SyncKeyValueFileSystem.prototype.empty = function empty () {\n\t this.store.clear();\n\t // INVARIANT: Root always exists.\n\t this.makeRootDirectory();\n\t };\n\t SyncKeyValueFileSystem.prototype.renameSync = function renameSync (oldPath, newPath) {\n\t var tx = this.store.beginTransaction('readwrite'), oldParent = path.dirname(oldPath), oldName = path.basename(oldPath), newParent = path.dirname(newPath), newName = path.basename(newPath), \n\t // Remove oldPath from parent's directory listing.\n\t oldDirNode = this.findINode(tx, oldParent), oldDirList = this.getDirListing(tx, oldParent, oldDirNode);\n\t if (!oldDirList[oldName]) {\n\t throw ApiError.ENOENT(oldPath);\n\t }\n\t var nodeId = oldDirList[oldName];\n\t delete oldDirList[oldName];\n\t // Invariant: Can't move a folder inside itself.\n\t // This funny little hack ensures that the check passes only if oldPath\n\t // is a subpath of newParent. We append '/' to avoid matching folders that\n\t // are a substring of the bottom-most folder in the path.\n\t if ((newParent + '/').indexOf(oldPath + '/') === 0) {\n\t throw new ApiError(ErrorCode.EBUSY, oldParent);\n\t }\n\t // Add newPath to parent's directory listing.\n\t var newDirNode, newDirList;\n\t if (newParent === oldParent) {\n\t // Prevent us from re-grabbing the same directory listing, which still\n\t // contains oldName.\n\t newDirNode = oldDirNode;\n\t newDirList = oldDirList;\n\t }\n\t else {\n\t newDirNode = this.findINode(tx, newParent);\n\t newDirList = this.getDirListing(tx, newParent, newDirNode);\n\t }\n\t if (newDirList[newName]) {\n\t // If it's a file, delete it.\n\t var newNameNode = this.getINode(tx, newPath, newDirList[newName]);\n\t if (newNameNode.isFile()) {\n\t try {\n\t tx.del(newNameNode.id);\n\t tx.del(newDirList[newName]);\n\t }\n\t catch (e) {\n\t tx.abort();\n\t throw e;\n\t }\n\t }\n\t else {\n\t // If it's a directory, throw a permissions error.\n\t throw ApiError.EPERM(newPath);\n\t }\n\t }\n\t newDirList[newName] = nodeId;\n\t // Commit the two changed directory listings.\n\t try {\n\t tx.put(oldDirNode.id, Buffer.from(JSON.stringify(oldDirList)), true);\n\t tx.put(newDirNode.id, Buffer.from(JSON.stringify(newDirList)), true);\n\t }\n\t catch (e) {\n\t tx.abort();\n\t throw e;\n\t }\n\t tx.commit();\n\t };\n\t SyncKeyValueFileSystem.prototype.statSync = function statSync (p, isLstat) {\n\t // Get the inode to the item, convert it into a Stats object.\n\t return this.findINode(this.store.beginTransaction('readonly'), p).toStats();\n\t };\n\t SyncKeyValueFileSystem.prototype.createFileSync = function createFileSync (p, flag, mode) {\n\t var tx = this.store.beginTransaction('readwrite'), data = emptyBuffer(), newFile = this.commitNewFile(tx, p, FileType.FILE, mode, data);\n\t // Open the file.\n\t return new SyncKeyValueFile(this, p, flag, newFile.toStats(), data);\n\t };\n\t SyncKeyValueFileSystem.prototype.openFileSync = function openFileSync (p, flag) {\n\t var tx = this.store.beginTransaction('readonly'), node = this.findINode(tx, p), data = tx.get(node.id);\n\t if (data === undefined) {\n\t throw ApiError.ENOENT(p);\n\t }\n\t return new SyncKeyValueFile(this, p, flag, node.toStats(), data);\n\t };\n\t SyncKeyValueFileSystem.prototype.unlinkSync = function unlinkSync (p) {\n\t this.removeEntry(p, false);\n\t };\n\t SyncKeyValueFileSystem.prototype.rmdirSync = function rmdirSync (p) {\n\t // Check first if directory is empty.\n\t if (this.readdirSync(p).length > 0) {\n\t throw ApiError.ENOTEMPTY(p);\n\t }\n\t else {\n\t this.removeEntry(p, true);\n\t }\n\t };\n\t SyncKeyValueFileSystem.prototype.mkdirSync = function mkdirSync (p, mode) {\n\t var tx = this.store.beginTransaction('readwrite'), data = Buffer.from('{}');\n\t this.commitNewFile(tx, p, FileType.DIRECTORY, mode, data);\n\t };\n\t SyncKeyValueFileSystem.prototype.readdirSync = function readdirSync (p) {\n\t var tx = this.store.beginTransaction('readonly');\n\t return Object.keys(this.getDirListing(tx, p, this.findINode(tx, p)));\n\t };\n\t SyncKeyValueFileSystem.prototype._syncSync = function _syncSync (p, data, stats) {\n\t // @todo Ensure mtime updates properly, and use that to determine if a data\n\t // update is required.\n\t var tx = this.store.beginTransaction('readwrite'), \n\t // We use the _findInode helper because we actually need the INode id.\n\t fileInodeId = this._findINode(tx, path.dirname(p), path.basename(p)), fileInode = this.getINode(tx, p, fileInodeId), inodeChanged = fileInode.update(stats);\n\t try {\n\t // Sync data.\n\t tx.put(fileInode.id, data, true);\n\t // Sync metadata.\n\t if (inodeChanged) {\n\t tx.put(fileInodeId, fileInode.toBuffer(), true);\n\t }\n\t }\n\t catch (e) {\n\t tx.abort();\n\t throw e;\n\t }\n\t tx.commit();\n\t };\n\t /**\n\t * Checks if the root directory exists. Creates it if it doesn't.\n\t */\n\t SyncKeyValueFileSystem.prototype.makeRootDirectory = function makeRootDirectory () {\n\t var tx = this.store.beginTransaction('readwrite');\n\t if (tx.get(ROOT_NODE_ID) === undefined) {\n\t // Create new inode.\n\t var currTime = (new Date()).getTime(), \n\t // Mode 0666\n\t dirInode = new Inode(GenerateRandomID(), 4096, 511 | FileType.DIRECTORY, currTime, currTime, currTime);\n\t // If the root doesn't exist, the first random ID shouldn't exist,\n\t // either.\n\t tx.put(dirInode.id, getEmptyDirNode(), false);\n\t tx.put(ROOT_NODE_ID, dirInode.toBuffer(), false);\n\t tx.commit();\n\t }\n\t };\n\t /**\n\t * Helper function for findINode.\n\t * @param parent The parent directory of the file we are attempting to find.\n\t * @param filename The filename of the inode we are attempting to find, minus\n\t * the parent.\n\t * @return string The ID of the file's inode in the file system.\n\t */\n\t SyncKeyValueFileSystem.prototype._findINode = function _findINode (tx, parent, filename) {\n\t var this$1 = this;\n\t\n\t var readDirectory = function (inode) {\n\t // Get the root's directory listing.\n\t var dirList = this$1.getDirListing(tx, parent, inode);\n\t // Get the file's ID.\n\t if (dirList[filename]) {\n\t return dirList[filename];\n\t }\n\t else {\n\t throw ApiError.ENOENT(path.resolve(parent, filename));\n\t }\n\t };\n\t if (parent === '/') {\n\t if (filename === '') {\n\t // BASE CASE #1: Return the root's ID.\n\t return ROOT_NODE_ID;\n\t }\n\t else {\n\t // BASE CASE #2: Find the item in the root ndoe.\n\t return readDirectory(this.getINode(tx, parent, ROOT_NODE_ID));\n\t }\n\t }\n\t else {\n\t return readDirectory(this.getINode(tx, parent + path.sep + filename, this._findINode(tx, path.dirname(parent), path.basename(parent))));\n\t }\n\t };\n\t /**\n\t * Finds the Inode of the given path.\n\t * @param p The path to look up.\n\t * @return The Inode of the path p.\n\t * @todo memoize/cache\n\t */\n\t SyncKeyValueFileSystem.prototype.findINode = function findINode (tx, p) {\n\t return this.getINode(tx, p, this._findINode(tx, path.dirname(p), path.basename(p)));\n\t };\n\t /**\n\t * Given the ID of a node, retrieves the corresponding Inode.\n\t * @param tx The transaction to use.\n\t * @param p The corresponding path to the file (used for error messages).\n\t * @param id The ID to look up.\n\t */\n\t SyncKeyValueFileSystem.prototype.getINode = function getINode (tx, p, id) {\n\t var inode = tx.get(id);\n\t if (inode === undefined) {\n\t throw ApiError.ENOENT(p);\n\t }\n\t return Inode.fromBuffer(inode);\n\t };\n\t /**\n\t * Given the Inode of a directory, retrieves the corresponding directory\n\t * listing.\n\t */\n\t SyncKeyValueFileSystem.prototype.getDirListing = function getDirListing (tx, p, inode) {\n\t if (!inode.isDirectory()) {\n\t throw ApiError.ENOTDIR(p);\n\t }\n\t var data = tx.get(inode.id);\n\t if (data === undefined) {\n\t throw ApiError.ENOENT(p);\n\t }\n\t return JSON.parse(data.toString());\n\t };\n\t /**\n\t * Creates a new node under a random ID. Retries 5 times before giving up in\n\t * the exceedingly unlikely chance that we try to reuse a random GUID.\n\t * @return The GUID that the data was stored under.\n\t */\n\t SyncKeyValueFileSystem.prototype.addNewNode = function addNewNode (tx, data) {\n\t var retries = 0;\n\t var currId;\n\t while (retries < 5) {\n\t try {\n\t currId = GenerateRandomID();\n\t tx.put(currId, data, false);\n\t return currId;\n\t }\n\t catch (e) {\n\t // Ignore and reroll.\n\t }\n\t }\n\t throw new ApiError(ErrorCode.EIO, 'Unable to commit data to key-value store.');\n\t };\n\t /**\n\t * Commits a new file (well, a FILE or a DIRECTORY) to the file system with\n\t * the given mode.\n\t * Note: This will commit the transaction.\n\t * @param p The path to the new file.\n\t * @param type The type of the new file.\n\t * @param mode The mode to create the new file with.\n\t * @param data The data to store at the file's data node.\n\t * @return The Inode for the new file.\n\t */\n\t SyncKeyValueFileSystem.prototype.commitNewFile = function commitNewFile (tx, p, type, mode, data) {\n\t var parentDir = path.dirname(p), fname = path.basename(p), parentNode = this.findINode(tx, parentDir), dirListing = this.getDirListing(tx, parentDir, parentNode), currTime = (new Date()).getTime();\n\t // Invariant: The root always exists.\n\t // If we don't check this prior to taking steps below, we will create a\n\t // file with name '' in root should p == '/'.\n\t if (p === '/') {\n\t throw ApiError.EEXIST(p);\n\t }\n\t // Check if file already exists.\n\t if (dirListing[fname]) {\n\t throw ApiError.EEXIST(p);\n\t }\n\t var fileNode;\n\t try {\n\t // Commit data.\n\t var dataId = this.addNewNode(tx, data);\n\t fileNode = new Inode(dataId, data.length, mode | type, currTime, currTime, currTime);\n\t // Commit file node.\n\t var fileNodeId = this.addNewNode(tx, fileNode.toBuffer());\n\t // Update and commit parent directory listing.\n\t dirListing[fname] = fileNodeId;\n\t tx.put(parentNode.id, Buffer.from(JSON.stringify(dirListing)), true);\n\t }\n\t catch (e) {\n\t tx.abort();\n\t throw e;\n\t }\n\t tx.commit();\n\t return fileNode;\n\t };\n\t /**\n\t * Remove all traces of the given path from the file system.\n\t * @param p The path to remove from the file system.\n\t * @param isDir Does the path belong to a directory, or a file?\n\t * @todo Update mtime.\n\t */\n\t SyncKeyValueFileSystem.prototype.removeEntry = function removeEntry (p, isDir) {\n\t var tx = this.store.beginTransaction('readwrite'), parent = path.dirname(p), parentNode = this.findINode(tx, parent), parentListing = this.getDirListing(tx, parent, parentNode), fileName = path.basename(p);\n\t if (!parentListing[fileName]) {\n\t throw ApiError.ENOENT(p);\n\t }\n\t // Remove from directory listing of parent.\n\t var fileNodeId = parentListing[fileName];\n\t delete parentListing[fileName];\n\t // Get file inode.\n\t var fileNode = this.getINode(tx, p, fileNodeId);\n\t if (!isDir && fileNode.isDirectory()) {\n\t throw ApiError.EISDIR(p);\n\t }\n\t else if (isDir && !fileNode.isDirectory()) {\n\t throw ApiError.ENOTDIR(p);\n\t }\n\t try {\n\t // Delete data.\n\t tx.del(fileNode.id);\n\t // Delete node.\n\t tx.del(fileNodeId);\n\t // Update directory listing.\n\t tx.put(parentNode.id, Buffer.from(JSON.stringify(parentListing)), true);\n\t }\n\t catch (e) {\n\t tx.abort();\n\t throw e;\n\t }\n\t // Success.\n\t tx.commit();\n\t };\n\t\n\t return SyncKeyValueFileSystem;\n\t}(SynchronousFileSystem));\n\tvar AsyncKeyValueFile = (function (PreloadFile$$1) {\n\t function AsyncKeyValueFile(_fs, _path, _flag, _stat, contents) {\n\t PreloadFile$$1.call(this, _fs, _path, _flag, _stat, contents);\n\t }\n\t\n\t if ( PreloadFile$$1 ) AsyncKeyValueFile.__proto__ = PreloadFile$$1;\n\t AsyncKeyValueFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );\n\t AsyncKeyValueFile.prototype.constructor = AsyncKeyValueFile;\n\t AsyncKeyValueFile.prototype.sync = function sync (cb) {\n\t var this$1 = this;\n\t\n\t if (this.isDirty()) {\n\t this._fs._sync(this.getPath(), this.getBuffer(), this.getStats(), function (e) {\n\t if (!e) {\n\t this$1.resetDirty();\n\t }\n\t cb(e);\n\t });\n\t }\n\t else {\n\t cb();\n\t }\n\t };\n\t AsyncKeyValueFile.prototype.close = function close (cb) {\n\t this.sync(cb);\n\t };\n\t\n\t return AsyncKeyValueFile;\n\t}(PreloadFile));\n\t/**\n\t * An \"Asynchronous key-value file system\". Stores data to/retrieves data from\n\t * an underlying asynchronous key-value store.\n\t */\n\tvar AsyncKeyValueFileSystem = (function (BaseFileSystem$$1) {\n\t function AsyncKeyValueFileSystem () {\n\t BaseFileSystem$$1.apply(this, arguments);\n\t }\n\t\n\t if ( BaseFileSystem$$1 ) AsyncKeyValueFileSystem.__proto__ = BaseFileSystem$$1;\n\t AsyncKeyValueFileSystem.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );\n\t AsyncKeyValueFileSystem.prototype.constructor = AsyncKeyValueFileSystem;\n\t\n\t AsyncKeyValueFileSystem.isAvailable = function isAvailable () { return true; };\n\t /**\n\t * Initializes the file system. Typically called by subclasses' async\n\t * constructors.\n\t */\n\t AsyncKeyValueFileSystem.prototype.init = function init (store, cb) {\n\t this.store = store;\n\t // INVARIANT: Ensure that the root exists.\n\t this.makeRootDirectory(cb);\n\t };\n\t AsyncKeyValueFileSystem.prototype.getName = function getName () { return this.store.name(); };\n\t AsyncKeyValueFileSystem.prototype.isReadOnly = function isReadOnly () { return false; };\n\t AsyncKeyValueFileSystem.prototype.supportsSymlinks = function supportsSymlinks () { return false; };\n\t AsyncKeyValueFileSystem.prototype.supportsProps = function supportsProps () { return false; };\n\t AsyncKeyValueFileSystem.prototype.supportsSynch = function supportsSynch () { return false; };\n\t /**\n\t * Delete all contents stored in the file system.\n\t */\n\t AsyncKeyValueFileSystem.prototype.empty = function empty (cb) {\n\t var this$1 = this;\n\t\n\t this.store.clear(function (e) {\n\t if (noError(e, cb)) {\n\t // INVARIANT: Root always exists.\n\t this$1.makeRootDirectory(cb);\n\t }\n\t });\n\t };\n\t AsyncKeyValueFileSystem.prototype.rename = function rename (oldPath, newPath, cb) {\n\t var this$1 = this;\n\t\n\t var tx = this.store.beginTransaction('readwrite');\n\t var oldParent = path.dirname(oldPath), oldName = path.basename(oldPath);\n\t var newParent = path.dirname(newPath), newName = path.basename(newPath);\n\t var inodes = {};\n\t var lists = {};\n\t var errorOccurred = false;\n\t // Invariant: Can't move a folder inside itself.\n\t // This funny little hack ensures that the check passes only if oldPath\n\t // is a subpath of newParent. We append '/' to avoid matching folders that\n\t // are a substring of the bottom-most folder in the path.\n\t if ((newParent + '/').indexOf(oldPath + '/') === 0) {\n\t return cb(new ApiError(ErrorCode.EBUSY, oldParent));\n\t }\n\t /**\n\t * Responsible for Phase 2 of the rename operation: Modifying and\n\t * committing the directory listings. Called once we have successfully\n\t * retrieved both the old and new parent's inodes and listings.\n\t */\n\t var theOleSwitcharoo = function () {\n\t // Sanity check: Ensure both paths are present, and no error has occurred.\n\t if (errorOccurred || !lists.hasOwnProperty(oldParent) || !lists.hasOwnProperty(newParent)) {\n\t return;\n\t }\n\t var oldParentList = lists[oldParent], oldParentINode = inodes[oldParent], newParentList = lists[newParent], newParentINode = inodes[newParent];\n\t // Delete file from old parent.\n\t if (!oldParentList[oldName]) {\n\t cb(ApiError.ENOENT(oldPath));\n\t }\n\t else {\n\t var fileId = oldParentList[oldName];\n\t delete oldParentList[oldName];\n\t // Finishes off the renaming process by adding the file to the new\n\t // parent.\n\t var completeRename = function () {\n\t newParentList[newName] = fileId;\n\t // Commit old parent's list.\n\t tx.put(oldParentINode.id, Buffer.from(JSON.stringify(oldParentList)), true, function (e) {\n\t if (noErrorTx(e, tx, cb)) {\n\t if (oldParent === newParent) {\n\t // DONE!\n\t tx.commit(cb);\n\t }\n\t else {\n\t // Commit new parent's list.\n\t tx.put(newParentINode.id, Buffer.from(JSON.stringify(newParentList)), true, function (e) {\n\t if (noErrorTx(e, tx, cb)) {\n\t tx.commit(cb);\n\t }\n\t });\n\t }\n\t }\n\t });\n\t };\n\t if (newParentList[newName]) {\n\t // 'newPath' already exists. Check if it's a file or a directory, and\n\t // act accordingly.\n\t this$1.getINode(tx, newPath, newParentList[newName], function (e, inode) {\n\t if (noErrorTx(e, tx, cb)) {\n\t if (inode.isFile()) {\n\t // Delete the file and continue.\n\t tx.del(inode.id, function (e) {\n\t if (noErrorTx(e, tx, cb)) {\n\t tx.del(newParentList[newName], function (e) {\n\t if (noErrorTx(e, tx, cb)) {\n\t completeRename();\n\t }\n\t });\n\t }\n\t });\n\t }\n\t else {\n\t // Can't overwrite a directory using rename.\n\t tx.abort(function (e) {\n\t cb(ApiError.EPERM(newPath));\n\t });\n\t }\n\t }\n\t });\n\t }\n\t else {\n\t completeRename();\n\t }\n\t }\n\t };\n\t /**\n\t * Grabs a path's inode and directory listing, and shoves it into the\n\t * inodes and lists hashes.\n\t */\n\t var processInodeAndListings = function (p) {\n\t this$1.findINodeAndDirListing(tx, p, function (e, node, dirList) {\n\t if (e) {\n\t if (!errorOccurred) {\n\t errorOccurred = true;\n\t tx.abort(function () {\n\t cb(e);\n\t });\n\t }\n\t // If error has occurred already, just stop here.\n\t }\n\t else {\n\t inodes[p] = node;\n\t lists[p] = dirList;\n\t theOleSwitcharoo();\n\t }\n\t });\n\t };\n\t processInodeAndListings(oldParent);\n\t if (oldParent !== newParent) {\n\t processInodeAndListings(newParent);\n\t }\n\t };\n\t AsyncKeyValueFileSystem.prototype.stat = function stat (p, isLstat, cb) {\n\t var tx = this.store.beginTransaction('readonly');\n\t this.findINode(tx, p, function (e, inode) {\n\t if (noError(e, cb)) {\n\t cb(null, inode.toStats());\n\t }\n\t });\n\t };\n\t AsyncKeyValueFileSystem.prototype.createFile = function createFile (p, flag, mode, cb) {\n\t var this$1 = this;\n\t\n\t var tx = this.store.beginTransaction('readwrite'), data = emptyBuffer();\n\t this.commitNewFile(tx, p, FileType.FILE, mode, data, function (e, newFile) {\n\t if (noError(e, cb)) {\n\t cb(null, new AsyncKeyValueFile(this$1, p, flag, newFile.toStats(), data));\n\t }\n\t });\n\t };\n\t AsyncKeyValueFileSystem.prototype.openFile = function openFile (p, flag, cb) {\n\t var this$1 = this;\n\t\n\t var tx = this.store.beginTransaction('readonly');\n\t // Step 1: Grab the file's inode.\n\t this.findINode(tx, p, function (e, inode) {\n\t if (noError(e, cb)) {\n\t // Step 2: Grab the file's data.\n\t tx.get(inode.id, function (e, data) {\n\t if (noError(e, cb)) {\n\t if (data === undefined) {\n\t cb(ApiError.ENOENT(p));\n\t }\n\t else {\n\t cb(null, new AsyncKeyValueFile(this$1, p, flag, inode.toStats(), data));\n\t }\n\t }\n\t });\n\t }\n\t });\n\t };\n\t AsyncKeyValueFileSystem.prototype.unlink = function unlink (p, cb) {\n\t this.removeEntry(p, false, cb);\n\t };\n\t AsyncKeyValueFileSystem.prototype.rmdir = function rmdir (p, cb) {\n\t var this$1 = this;\n\t\n\t // Check first if directory is empty.\n\t this.readdir(p, function (err, files) {\n\t if (err) {\n\t cb(err);\n\t }\n\t else if (files.length > 0) {\n\t cb(ApiError.ENOTEMPTY(p));\n\t }\n\t else {\n\t this$1.removeEntry(p, true, cb);\n\t }\n\t });\n\t };\n\t AsyncKeyValueFileSystem.prototype.mkdir = function mkdir (p, mode, cb) {\n\t var tx = this.store.beginTransaction('readwrite'), data = Buffer.from('{}');\n\t this.commitNewFile(tx, p, FileType.DIRECTORY, mode, data, cb);\n\t };\n\t AsyncKeyValueFileSystem.prototype.readdir = function readdir (p, cb) {\n\t var this$1 = this;\n\t\n\t var tx = this.store.beginTransaction('readonly');\n\t this.findINode(tx, p, function (e, inode) {\n\t if (noError(e, cb)) {\n\t this$1.getDirListing(tx, p, inode, function (e, dirListing) {\n\t if (noError(e, cb)) {\n\t cb(null, Object.keys(dirListing));\n\t }\n\t });\n\t }\n\t });\n\t };\n\t AsyncKeyValueFileSystem.prototype._sync = function _sync (p, data, stats, cb) {\n\t var this$1 = this;\n\t\n\t // @todo Ensure mtime updates properly, and use that to determine if a data\n\t // update is required.\n\t var tx = this.store.beginTransaction('readwrite');\n\t // Step 1: Get the file node's ID.\n\t this._findINode(tx, path.dirname(p), path.basename(p), function (e, fileInodeId) {\n\t if (noErrorTx(e, tx, cb)) {\n\t // Step 2: Get the file inode.\n\t this$1.getINode(tx, p, fileInodeId, function (e, fileInode) {\n\t if (noErrorTx(e, tx, cb)) {\n\t var inodeChanged = fileInode.update(stats);\n\t // Step 3: Sync the data.\n\t tx.put(fileInode.id, data, true, function (e) {\n\t if (noErrorTx(e, tx, cb)) {\n\t // Step 4: Sync the metadata (if it changed)!\n\t if (inodeChanged) {\n\t tx.put(fileInodeId, fileInode.toBuffer(), true, function (e) {\n\t if (noErrorTx(e, tx, cb)) {\n\t tx.commit(cb);\n\t }\n\t });\n\t }\n\t else {\n\t // No need to sync metadata; return.\n\t tx.commit(cb);\n\t }\n\t }\n\t });\n\t }\n\t });\n\t }\n\t });\n\t };\n\t /**\n\t * Checks if the root directory exists. Creates it if it doesn't.\n\t */\n\t AsyncKeyValueFileSystem.prototype.makeRootDirectory = function makeRootDirectory (cb) {\n\t var tx = this.store.beginTransaction('readwrite');\n\t tx.get(ROOT_NODE_ID, function (e, data) {\n\t if (e || data === undefined) {\n\t // Create new inode.\n\t var currTime = (new Date()).getTime(), \n\t // Mode 0666\n\t dirInode = new Inode(GenerateRandomID(), 4096, 511 | FileType.DIRECTORY, currTime, currTime, currTime);\n\t // If the root doesn't exist, the first random ID shouldn't exist,\n\t // either.\n\t tx.put(dirInode.id, getEmptyDirNode(), false, function (e) {\n\t if (noErrorTx(e, tx, cb)) {\n\t tx.put(ROOT_NODE_ID, dirInode.toBuffer(), false, function (e) {\n\t if (e) {\n\t tx.abort(function () { cb(e); });\n\t }\n\t else {\n\t tx.commit(cb);\n\t }\n\t });\n\t }\n\t });\n\t }\n\t else {\n\t // We're good.\n\t tx.commit(cb);\n\t }\n\t });\n\t };\n\t /**\n\t * Helper function for findINode.\n\t * @param parent The parent directory of the file we are attempting to find.\n\t * @param filename The filename of the inode we are attempting to find, minus\n\t * the parent.\n\t * @param cb Passed an error or the ID of the file's inode in the file system.\n\t */\n\t AsyncKeyValueFileSystem.prototype._findINode = function _findINode (tx, parent, filename, cb) {\n\t var this$1 = this;\n\t\n\t var handleDirectoryListings = function (e, inode, dirList) {\n\t if (e) {\n\t cb(e);\n\t }\n\t else if (dirList[filename]) {\n\t cb(null, dirList[filename]);\n\t }\n\t else {\n\t cb(ApiError.ENOENT(path.resolve(parent, filename)));\n\t }\n\t };\n\t if (parent === '/') {\n\t if (filename === '') {\n\t // BASE CASE #1: Return the root's ID.\n\t cb(null, ROOT_NODE_ID);\n\t }\n\t else {\n\t // BASE CASE #2: Find the item in the root node.\n\t this.getINode(tx, parent, ROOT_NODE_ID, function (e, inode) {\n\t if (noError(e, cb)) {\n\t this$1.getDirListing(tx, parent, inode, function (e, dirList) {\n\t // handle_directory_listings will handle e for us.\n\t handleDirectoryListings(e, inode, dirList);\n\t });\n\t }\n\t });\n\t }\n\t }\n\t else {\n\t // Get the parent directory's INode, and find the file in its directory\n\t // listing.\n\t this.findINodeAndDirListing(tx, parent, handleDirectoryListings);\n\t }\n\t };\n\t /**\n\t * Finds the Inode of the given path.\n\t * @param p The path to look up.\n\t * @param cb Passed an error or the Inode of the path p.\n\t * @todo memoize/cache\n\t */\n\t AsyncKeyValueFileSystem.prototype.findINode = function findINode (tx, p, cb) {\n\t var this$1 = this;\n\t\n\t this._findINode(tx, path.dirname(p), path.basename(p), function (e, id) {\n\t if (noError(e, cb)) {\n\t this$1.getINode(tx, p, id, cb);\n\t }\n\t });\n\t };\n\t /**\n\t * Given the ID of a node, retrieves the corresponding Inode.\n\t * @param tx The transaction to use.\n\t * @param p The corresponding path to the file (used for error messages).\n\t * @param id The ID to look up.\n\t * @param cb Passed an error or the inode under the given id.\n\t */\n\t AsyncKeyValueFileSystem.prototype.getINode = function getINode (tx, p, id, cb) {\n\t tx.get(id, function (e, data) {\n\t if (noError(e, cb)) {\n\t if (data === undefined) {\n\t cb(ApiError.ENOENT(p));\n\t }\n\t else {\n\t cb(null, Inode.fromBuffer(data));\n\t }\n\t }\n\t });\n\t };\n\t /**\n\t * Given the Inode of a directory, retrieves the corresponding directory\n\t * listing.\n\t */\n\t AsyncKeyValueFileSystem.prototype.getDirListing = function getDirListing (tx, p, inode, cb) {\n\t if (!inode.isDirectory()) {\n\t cb(ApiError.ENOTDIR(p));\n\t }\n\t else {\n\t tx.get(inode.id, function (e, data) {\n\t if (noError(e, cb)) {\n\t try {\n\t cb(null, JSON.parse(data.toString()));\n\t }\n\t catch (e) {\n\t // Occurs when data is undefined, or corresponds to something other\n\t // than a directory listing. The latter should never occur unless\n\t // the file system is corrupted.\n\t cb(ApiError.ENOENT(p));\n\t }\n\t }\n\t });\n\t }\n\t };\n\t /**\n\t * Given a path to a directory, retrieves the corresponding INode and\n\t * directory listing.\n\t */\n\t AsyncKeyValueFileSystem.prototype.findINodeAndDirListing = function findINodeAndDirListing (tx, p, cb) {\n\t var this$1 = this;\n\t\n\t this.findINode(tx, p, function (e, inode) {\n\t if (noError(e, cb)) {\n\t this$1.getDirListing(tx, p, inode, function (e, listing) {\n\t if (noError(e, cb)) {\n\t cb(null, inode, listing);\n\t }\n\t });\n\t }\n\t });\n\t };\n\t /**\n\t * Adds a new node under a random ID. Retries 5 times before giving up in\n\t * the exceedingly unlikely chance that we try to reuse a random GUID.\n\t * @param cb Passed an error or the GUID that the data was stored under.\n\t */\n\t AsyncKeyValueFileSystem.prototype.addNewNode = function addNewNode (tx, data, cb) {\n\t var retries = 0, currId;\n\t var reroll = function () {\n\t if (++retries === 5) {\n\t // Max retries hit. Return with an error.\n\t cb(new ApiError(ErrorCode.EIO, 'Unable to commit data to key-value store.'));\n\t }\n\t else {\n\t // Try again.\n\t currId = GenerateRandomID();\n\t tx.put(currId, data, false, function (e, committed) {\n\t if (e || !committed) {\n\t reroll();\n\t }\n\t else {\n\t // Successfully stored under 'currId'.\n\t cb(null, currId);\n\t }\n\t });\n\t }\n\t };\n\t reroll();\n\t };\n\t /**\n\t * Commits a new file (well, a FILE or a DIRECTORY) to the file system with\n\t * the given mode.\n\t * Note: This will commit the transaction.\n\t * @param p The path to the new file.\n\t * @param type The type of the new file.\n\t * @param mode The mode to create the new file with.\n\t * @param data The data to store at the file's data node.\n\t * @param cb Passed an error or the Inode for the new file.\n\t */\n\t AsyncKeyValueFileSystem.prototype.commitNewFile = function commitNewFile (tx, p, type, mode, data, cb) {\n\t var this$1 = this;\n\t\n\t var parentDir = path.dirname(p), fname = path.basename(p), currTime = (new Date()).getTime();\n\t // Invariant: The root always exists.\n\t // If we don't check this prior to taking steps below, we will create a\n\t // file with name '' in root should p == '/'.\n\t if (p === '/') {\n\t return cb(ApiError.EEXIST(p));\n\t }\n\t // Let's build a pyramid of code!\n\t // Step 1: Get the parent directory's inode and directory listing\n\t this.findINodeAndDirListing(tx, parentDir, function (e, parentNode, dirListing) {\n\t if (noErrorTx(e, tx, cb)) {\n\t if (dirListing[fname]) {\n\t // File already exists.\n\t tx.abort(function () {\n\t cb(ApiError.EEXIST(p));\n\t });\n\t }\n\t else {\n\t // Step 2: Commit data to store.\n\t this$1.addNewNode(tx, data, function (e, dataId) {\n\t if (noErrorTx(e, tx, cb)) {\n\t // Step 3: Commit the file's inode to the store.\n\t var fileInode = new Inode(dataId, data.length, mode | type, currTime, currTime, currTime);\n\t this$1.addNewNode(tx, fileInode.toBuffer(), function (e, fileInodeId) {\n\t if (noErrorTx(e, tx, cb)) {\n\t // Step 4: Update parent directory's listing.\n\t dirListing[fname] = fileInodeId;\n\t tx.put(parentNode.id, Buffer.from(JSON.stringify(dirListing)), true, function (e) {\n\t if (noErrorTx(e, tx, cb)) {\n\t // Step 5: Commit and return the new inode.\n\t tx.commit(function (e) {\n\t if (noErrorTx(e, tx, cb)) {\n\t cb(null, fileInode);\n\t }\n\t });\n\t }\n\t });\n\t }\n\t });\n\t }\n\t });\n\t }\n\t }\n\t });\n\t };\n\t /**\n\t * Remove all traces of the given path from the file system.\n\t * @param p The path to remove from the file system.\n\t * @param isDir Does the path belong to a directory, or a file?\n\t * @todo Update mtime.\n\t */\n\t AsyncKeyValueFileSystem.prototype.removeEntry = function removeEntry (p, isDir, cb) {\n\t var this$1 = this;\n\t\n\t var tx = this.store.beginTransaction('readwrite'), parent = path.dirname(p), fileName = path.basename(p);\n\t // Step 1: Get parent directory's node and directory listing.\n\t this.findINodeAndDirListing(tx, parent, function (e, parentNode, parentListing) {\n\t if (noErrorTx(e, tx, cb)) {\n\t if (!parentListing[fileName]) {\n\t tx.abort(function () {\n\t cb(ApiError.ENOENT(p));\n\t });\n\t }\n\t else {\n\t // Remove from directory listing of parent.\n\t var fileNodeId = parentListing[fileName];\n\t delete parentListing[fileName];\n\t // Step 2: Get file inode.\n\t this$1.getINode(tx, p, fileNodeId, function (e, fileNode) {\n\t if (noErrorTx(e, tx, cb)) {\n\t if (!isDir && fileNode.isDirectory()) {\n\t tx.abort(function () {\n\t cb(ApiError.EISDIR(p));\n\t });\n\t }\n\t else if (isDir && !fileNode.isDirectory()) {\n\t tx.abort(function () {\n\t cb(ApiError.ENOTDIR(p));\n\t });\n\t }\n\t else {\n\t // Step 3: Delete data.\n\t tx.del(fileNode.id, function (e) {\n\t if (noErrorTx(e, tx, cb)) {\n\t // Step 4: Delete node.\n\t tx.del(fileNodeId, function (e) {\n\t if (noErrorTx(e, tx, cb)) {\n\t // Step 5: Update directory listing.\n\t tx.put(parentNode.id, Buffer.from(JSON.stringify(parentListing)), true, function (e) {\n\t if (noErrorTx(e, tx, cb)) {\n\t tx.commit(cb);\n\t }\n\t });\n\t }\n\t });\n\t }\n\t });\n\t }\n\t }\n\t });\n\t }\n\t }\n\t });\n\t };\n\t\n\t return AsyncKeyValueFileSystem;\n\t}(BaseFileSystem));\n\t\n\t/**\n\t * A simple in-memory key-value store backed by a JavaScript object.\n\t */\n\tvar InMemoryStore = function InMemoryStore() {\n\t this.store = {};\n\t};\n\tInMemoryStore.prototype.name = function name () { return InMemoryFileSystem.Name; };\n\tInMemoryStore.prototype.clear = function clear () { this.store = {}; };\n\tInMemoryStore.prototype.beginTransaction = function beginTransaction (type) {\n\t return new SimpleSyncRWTransaction(this);\n\t};\n\tInMemoryStore.prototype.get = function get (key) {\n\t return this.store[key];\n\t};\n\tInMemoryStore.prototype.put = function put (key, data, overwrite) {\n\t if (!overwrite && this.store.hasOwnProperty(key)) {\n\t return false;\n\t }\n\t this.store[key] = data;\n\t return true;\n\t};\n\tInMemoryStore.prototype.del = function del (key) {\n\t delete this.store[key];\n\t};\n\t/**\n\t * A simple in-memory file system backed by an InMemoryStore.\n\t * Files are not persisted across page loads.\n\t */\n\tvar InMemoryFileSystem = (function (SyncKeyValueFileSystem$$1) {\n\t function InMemoryFileSystem() {\n\t SyncKeyValueFileSystem$$1.call(this, { store: new InMemoryStore() });\n\t }\n\t\n\t if ( SyncKeyValueFileSystem$$1 ) InMemoryFileSystem.__proto__ = SyncKeyValueFileSystem$$1;\n\t InMemoryFileSystem.prototype = Object.create( SyncKeyValueFileSystem$$1 && SyncKeyValueFileSystem$$1.prototype );\n\t InMemoryFileSystem.prototype.constructor = InMemoryFileSystem;\n\t /**\n\t * Creates an InMemoryFileSystem instance.\n\t */\n\t InMemoryFileSystem.Create = function Create (options, cb) {\n\t cb(null, new InMemoryFileSystem());\n\t };\n\t\n\t return InMemoryFileSystem;\n\t}(SyncKeyValueFileSystem));\n\t\n\tInMemoryFileSystem.Name = \"InMemory\";\n\tInMemoryFileSystem.Options = {};\n\t\n\t/**\n\t * Get the indexedDB constructor for the current browser.\n\t * @hidden\n\t */\n\tvar indexedDB = global$1.indexedDB ||\n\t global$1.mozIndexedDB ||\n\t global$1.webkitIndexedDB ||\n\t global$1.msIndexedDB;\n\t/**\n\t * Converts a DOMException or a DOMError from an IndexedDB event into a\n\t * standardized BrowserFS API error.\n\t * @hidden\n\t */\n\tfunction convertError$2(e, message) {\n\t if ( message === void 0 ) message = e.toString();\n\t\n\t switch (e.name) {\n\t case \"NotFoundError\":\n\t return new ApiError(ErrorCode.ENOENT, message);\n\t case \"QuotaExceededError\":\n\t return new ApiError(ErrorCode.ENOSPC, message);\n\t default:\n\t // The rest do not seem to map cleanly to standard error codes.\n\t return new ApiError(ErrorCode.EIO, message);\n\t }\n\t}\n\t/**\n\t * Produces a new onerror handler for IDB. Our errors are always fatal, so we\n\t * handle them generically: Call the user-supplied callback with a translated\n\t * version of the error, and let the error bubble up.\n\t * @hidden\n\t */\n\tfunction onErrorHandler(cb, code, message) {\n\t if ( code === void 0 ) code = ErrorCode.EIO;\n\t if ( message === void 0 ) message = null;\n\t\n\t return function (e) {\n\t // Prevent the error from canceling the transaction.\n\t e.preventDefault();\n\t cb(new ApiError(code, message !== null ? message : undefined));\n\t };\n\t}\n\t/**\n\t * @hidden\n\t */\n\tvar IndexedDBROTransaction = function IndexedDBROTransaction(tx, store) {\n\t this.tx = tx;\n\t this.store = store;\n\t};\n\tIndexedDBROTransaction.prototype.get = function get (key, cb) {\n\t try {\n\t var r = this.store.get(key);\n\t r.onerror = onErrorHandler(cb);\n\t r.onsuccess = function (event) {\n\t // IDB returns the value 'undefined' when you try to get keys that\n\t // don't exist. The caller expects this behavior.\n\t var result = event.target.result;\n\t if (result === undefined) {\n\t cb(null, result);\n\t }\n\t else {\n\t // IDB data is stored as an ArrayBuffer\n\t cb(null, arrayBuffer2Buffer(result));\n\t }\n\t };\n\t }\n\t catch (e) {\n\t cb(convertError$2(e));\n\t }\n\t};\n\t/**\n\t * @hidden\n\t */\n\tvar IndexedDBRWTransaction = (function (IndexedDBROTransaction) {\n\t function IndexedDBRWTransaction(tx, store) {\n\t IndexedDBROTransaction.call(this, tx, store);\n\t }\n\t\n\t if ( IndexedDBROTransaction ) IndexedDBRWTransaction.__proto__ = IndexedDBROTransaction;\n\t IndexedDBRWTransaction.prototype = Object.create( IndexedDBROTransaction && IndexedDBROTransaction.prototype );\n\t IndexedDBRWTransaction.prototype.constructor = IndexedDBRWTransaction;\n\t IndexedDBRWTransaction.prototype.put = function put (key, data, overwrite, cb) {\n\t try {\n\t var arraybuffer = buffer2ArrayBuffer(data);\n\t var r;\n\t if (overwrite) {\n\t r = this.store.put(arraybuffer, key);\n\t }\n\t else {\n\t // 'add' will never overwrite an existing key.\n\t r = this.store.add(arraybuffer, key);\n\t }\n\t // XXX: NEED TO RETURN FALSE WHEN ADD HAS A KEY CONFLICT. NO ERROR.\n\t r.onerror = onErrorHandler(cb);\n\t r.onsuccess = function (event) {\n\t cb(null, true);\n\t };\n\t }\n\t catch (e) {\n\t cb(convertError$2(e));\n\t }\n\t };\n\t IndexedDBRWTransaction.prototype.del = function del (key, cb) {\n\t try {\n\t // NOTE: IE8 has a bug with identifiers named 'delete' unless used as a string\n\t // like this.\n\t // http://stackoverflow.com/a/26479152\n\t var r = this.store['delete'](key);\n\t r.onerror = onErrorHandler(cb);\n\t r.onsuccess = function (event) {\n\t cb();\n\t };\n\t }\n\t catch (e) {\n\t cb(convertError$2(e));\n\t }\n\t };\n\t IndexedDBRWTransaction.prototype.commit = function commit (cb) {\n\t // Return to the event loop to commit the transaction.\n\t setTimeout(cb, 0);\n\t };\n\t IndexedDBRWTransaction.prototype.abort = function abort (cb) {\n\t var _e = null;\n\t try {\n\t this.tx.abort();\n\t }\n\t catch (e) {\n\t _e = convertError$2(e);\n\t }\n\t finally {\n\t cb(_e);\n\t }\n\t };\n\t\n\t return IndexedDBRWTransaction;\n\t}(IndexedDBROTransaction));\n\tvar IndexedDBStore = function IndexedDBStore(cb, storeName) {\n\t var this$1 = this;\n\t if ( storeName === void 0 ) storeName = 'browserfs';\n\t\n\t this.storeName = storeName;\n\t var openReq = indexedDB.open(this.storeName, 1);\n\t openReq.onupgradeneeded = function (event) {\n\t var db = event.target.result;\n\t // Huh. This should never happen; we're at version 1. Why does another\n\t // database exist?\n\t if (db.objectStoreNames.contains(this$1.storeName)) {\n\t db.deleteObjectStore(this$1.storeName);\n\t }\n\t db.createObjectStore(this$1.storeName);\n\t };\n\t openReq.onsuccess = function (event) {\n\t this$1.db = event.target.result;\n\t cb(null, this$1);\n\t };\n\t openReq.onerror = onErrorHandler(cb, ErrorCode.EACCES);\n\t};\n\tIndexedDBStore.prototype.name = function name () {\n\t return IndexedDBFileSystem.Name + \" - \" + this.storeName;\n\t};\n\tIndexedDBStore.prototype.clear = function clear (cb) {\n\t try {\n\t var tx = this.db.transaction(this.storeName, 'readwrite'), objectStore = tx.objectStore(this.storeName), r = objectStore.clear();\n\t r.onsuccess = function (event) {\n\t // Use setTimeout to commit transaction.\n\t setTimeout(cb, 0);\n\t };\n\t r.onerror = onErrorHandler(cb);\n\t }\n\t catch (e) {\n\t cb(convertError$2(e));\n\t }\n\t};\n\tIndexedDBStore.prototype.beginTransaction = function beginTransaction (type) {\n\t if ( type === void 0 ) type = 'readonly';\n\t\n\t var tx = this.db.transaction(this.storeName, type), objectStore = tx.objectStore(this.storeName);\n\t if (type === 'readwrite') {\n\t return new IndexedDBRWTransaction(tx, objectStore);\n\t }\n\t else if (type === 'readonly') {\n\t return new IndexedDBROTransaction(tx, objectStore);\n\t }\n\t else {\n\t throw new ApiError(ErrorCode.EINVAL, 'Invalid transaction type.');\n\t }\n\t};\n\t/**\n\t * A file system that uses the IndexedDB key value file system.\n\t */\n\tvar IndexedDBFileSystem = (function (AsyncKeyValueFileSystem$$1) {\n\t function IndexedDBFileSystem(cb, storeName, deprecateMsg) {\n\t var this$1 = this;\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t AsyncKeyValueFileSystem$$1.call(this);\n\t this.store = new IndexedDBStore(function (e) {\n\t if (e) {\n\t cb(e);\n\t }\n\t else {\n\t this$1.init(this$1.store, function (e) {\n\t cb(e, this$1);\n\t });\n\t }\n\t }, storeName);\n\t deprecationMessage(deprecateMsg, IndexedDBFileSystem.Name, { storeName: storeName });\n\t }\n\t\n\t if ( AsyncKeyValueFileSystem$$1 ) IndexedDBFileSystem.__proto__ = AsyncKeyValueFileSystem$$1;\n\t IndexedDBFileSystem.prototype = Object.create( AsyncKeyValueFileSystem$$1 && AsyncKeyValueFileSystem$$1.prototype );\n\t IndexedDBFileSystem.prototype.constructor = IndexedDBFileSystem;\n\t /**\n\t * Constructs an IndexedDB file system with the given options.\n\t */\n\t IndexedDBFileSystem.Create = function Create (opts, cb) {\n\t // tslint:disable-next-line:no-unused-new\n\t new IndexedDBFileSystem(cb, opts.storeName, false);\n\t // tslint:enable-next-line:no-unused-new\n\t };\n\t IndexedDBFileSystem.isAvailable = function isAvailable () {\n\t // In Safari's private browsing mode, indexedDB.open returns NULL.\n\t // In Firefox, it throws an exception.\n\t // In Chrome, it \"just works\", and clears the database when you leave the page.\n\t // Untested: Opera, IE.\n\t try {\n\t return typeof indexedDB !== 'undefined' && null !== indexedDB.open(\"__browserfs_test__\");\n\t }\n\t catch (e) {\n\t return false;\n\t }\n\t };\n\t\n\t return IndexedDBFileSystem;\n\t}(AsyncKeyValueFileSystem));\n\t\n\tIndexedDBFileSystem.Name = \"IndexedDB\";\n\tIndexedDBFileSystem.Options = {\n\t storeName: {\n\t type: \"string\",\n\t optional: true,\n\t description: \"The name of this file system. You can have multiple IndexedDB file systems operating at once, but each must have a different name.\"\n\t }\n\t};\n\t\n\t/**\n\t * Some versions of FF and all versions of IE do not support the full range of\n\t * 16-bit numbers encoded as characters, as they enforce UTF-16 restrictions.\n\t * @url http://stackoverflow.com/questions/11170716/are-there-any-characters-that-are-not-allowed-in-localstorage/11173673#11173673\n\t * @hidden\n\t */\n\tvar supportsBinaryString = false;\n\tvar binaryEncoding;\n\ttry {\n\t global$1.localStorage.setItem(\"__test__\", String.fromCharCode(0xD800));\n\t supportsBinaryString = global$1.localStorage.getItem(\"__test__\") === String.fromCharCode(0xD800);\n\t}\n\tcatch (e) {\n\t // IE throws an exception.\n\t supportsBinaryString = false;\n\t}\n\tbinaryEncoding = supportsBinaryString ? 'binary_string' : 'binary_string_ie';\n\tif (!Buffer.isEncoding(binaryEncoding)) {\n\t // Fallback for non BrowserFS implementations of buffer that lack a\n\t // binary_string format.\n\t binaryEncoding = \"base64\";\n\t}\n\t/**\n\t * A synchronous key-value store backed by localStorage.\n\t */\n\tvar LocalStorageStore = function LocalStorageStore () {};\n\t\n\tLocalStorageStore.prototype.name = function name () {\n\t return LocalStorageFileSystem.Name;\n\t};\n\tLocalStorageStore.prototype.clear = function clear () {\n\t global$1.localStorage.clear();\n\t};\n\tLocalStorageStore.prototype.beginTransaction = function beginTransaction (type) {\n\t // No need to differentiate.\n\t return new SimpleSyncRWTransaction(this);\n\t};\n\tLocalStorageStore.prototype.get = function get (key) {\n\t try {\n\t var data = global$1.localStorage.getItem(key);\n\t if (data !== null) {\n\t return Buffer.from(data, binaryEncoding);\n\t }\n\t }\n\t catch (e) {\n\t // Do nothing.\n\t }\n\t // Key doesn't exist, or a failure occurred.\n\t return undefined;\n\t};\n\tLocalStorageStore.prototype.put = function put (key, data, overwrite) {\n\t try {\n\t if (!overwrite && global$1.localStorage.getItem(key) !== null) {\n\t // Don't want to overwrite the key!\n\t return false;\n\t }\n\t global$1.localStorage.setItem(key, data.toString(binaryEncoding));\n\t return true;\n\t }\n\t catch (e) {\n\t throw new ApiError(ErrorCode.ENOSPC, \"LocalStorage is full.\");\n\t }\n\t};\n\tLocalStorageStore.prototype.del = function del (key) {\n\t try {\n\t global$1.localStorage.removeItem(key);\n\t }\n\t catch (e) {\n\t throw new ApiError(ErrorCode.EIO, \"Unable to delete key \" + key + \": \" + e);\n\t }\n\t};\n\t/**\n\t * A synchronous file system backed by localStorage. Connects our\n\t * LocalStorageStore to our SyncKeyValueFileSystem.\n\t */\n\tvar LocalStorageFileSystem = (function (SyncKeyValueFileSystem$$1) {\n\t function LocalStorageFileSystem() { SyncKeyValueFileSystem$$1.call(this, { store: new LocalStorageStore() }); }\n\t\n\t if ( SyncKeyValueFileSystem$$1 ) LocalStorageFileSystem.__proto__ = SyncKeyValueFileSystem$$1;\n\t LocalStorageFileSystem.prototype = Object.create( SyncKeyValueFileSystem$$1 && SyncKeyValueFileSystem$$1.prototype );\n\t LocalStorageFileSystem.prototype.constructor = LocalStorageFileSystem;\n\t /**\n\t * Creates a LocalStorageFileSystem instance.\n\t */\n\t LocalStorageFileSystem.Create = function Create (options, cb) {\n\t cb(null, new LocalStorageFileSystem());\n\t };\n\t LocalStorageFileSystem.isAvailable = function isAvailable () {\n\t return typeof global$1.localStorage !== 'undefined';\n\t };\n\t\n\t return LocalStorageFileSystem;\n\t}(SyncKeyValueFileSystem));\n\t\n\tLocalStorageFileSystem.Name = \"LocalStorage\";\n\tLocalStorageFileSystem.Options = {};\n\t\n\t/**\n\t * The MountableFileSystem allows you to mount multiple backend types or\n\t * multiple instantiations of the same backend into a single file system tree.\n\t * The file systems do not need to know about each other; all interactions are\n\t * automatically facilitated through this interface.\n\t *\n\t * For example, if a file system is mounted at /mnt/blah, and a request came in\n\t * for /mnt/blah/foo.txt, the file system would see a request for /foo.txt.\n\t *\n\t * You can mount file systems when you configure the file system:\n\t * ```javascript\n\t * BrowserFS.configure({\n\t * fs: \"MountableFileSystem\",\n\t * options: {\n\t * '/data': { fs: 'XmlHttpRequest', options: { index: \"http://mysite.com/files/index.json\" } },\n\t * '/home': { fs: 'LocalStorage' }\n\t * }\n\t * }, function(e) {\n\t *\n\t * });\n\t * ```\n\t *\n\t * For advanced users, you can also mount file systems *after* MFS is constructed:\n\t * ```javascript\n\t * BrowserFS.FileSystem.XmlHttpRequest.Create({\n\t * index: \"http://mysite.com/files/index.json\"\n\t * }, function(e, xhrfs) {\n\t * BrowserFS.FileSystem.MountableFileSystem.Create({\n\t * '/data': xhrfs\n\t * }, function(e, mfs) {\n\t * BrowserFS.initialize(mfs);\n\t *\n\t * // Added after-the-fact...\n\t * BrowserFS.FileSystem.LocalStorage.Create(function(e, lsfs) {\n\t * mfs.mount('/home', lsfs);\n\t * });\n\t * });\n\t * });\n\t * ```\n\t *\n\t * Since MountableFileSystem simply proxies requests to mounted file systems, it supports all of the operations that the mounted file systems support.\n\t *\n\t * With no mounted file systems, `MountableFileSystem` acts as a simple `InMemory` filesystem.\n\t */\n\tvar MountableFileSystem = (function (BaseFileSystem$$1) {\n\t function MountableFileSystem() {\n\t BaseFileSystem$$1.call(this);\n\t // Contains the list of mount points in mntMap, sorted by string length in decreasing order.\n\t // Ensures that we scan the most specific mount points for a match first, which lets us\n\t // nest mount points.\n\t this.mountList = [];\n\t this.mntMap = {};\n\t // The InMemory file system serves purely to provide directory listings for\n\t // mounted file systems.\n\t this.rootFs = new InMemoryFileSystem();\n\t }\n\t\n\t if ( BaseFileSystem$$1 ) MountableFileSystem.__proto__ = BaseFileSystem$$1;\n\t MountableFileSystem.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );\n\t MountableFileSystem.prototype.constructor = MountableFileSystem;\n\t /**\n\t * Creates a MountableFileSystem instance with the given options.\n\t */\n\t MountableFileSystem.Create = function Create (opts, cb) {\n\t var fs = new MountableFileSystem();\n\t Object.keys(opts).forEach(function (mountPoint) {\n\t fs.mount(mountPoint, opts[mountPoint]);\n\t });\n\t cb(null, fs);\n\t };\n\t MountableFileSystem.isAvailable = function isAvailable () {\n\t return true;\n\t };\n\t /**\n\t * Mounts the file system at the given mount point.\n\t */\n\t MountableFileSystem.prototype.mount = function mount (mountPoint, fs) {\n\t if (mountPoint[0] !== '/') {\n\t mountPoint = \"/\" + mountPoint;\n\t }\n\t mountPoint = path.resolve(mountPoint);\n\t if (this.mntMap[mountPoint]) {\n\t throw new ApiError(ErrorCode.EINVAL, \"Mount point \" + mountPoint + \" is already taken.\");\n\t }\n\t mkdirpSync(mountPoint, 0x1ff, this.rootFs);\n\t this.mntMap[mountPoint] = fs;\n\t this.mountList.push(mountPoint);\n\t this.mountList = this.mountList.sort(function (a, b) { return b.length - a.length; });\n\t };\n\t MountableFileSystem.prototype.umount = function umount (mountPoint) {\n\t var this$1 = this;\n\t\n\t if (mountPoint[0] !== '/') {\n\t mountPoint = \"/\" + mountPoint;\n\t }\n\t mountPoint = path.resolve(mountPoint);\n\t if (!this.mntMap[mountPoint]) {\n\t throw new ApiError(ErrorCode.EINVAL, \"Mount point \" + mountPoint + \" is already unmounted.\");\n\t }\n\t delete this.mntMap[mountPoint];\n\t this.mountList.splice(this.mountList.indexOf(mountPoint), 1);\n\t while (mountPoint !== '/') {\n\t if (this$1.rootFs.readdirSync(mountPoint).length === 0) {\n\t this$1.rootFs.rmdirSync(mountPoint);\n\t mountPoint = path.dirname(mountPoint);\n\t }\n\t else {\n\t break;\n\t }\n\t }\n\t };\n\t /**\n\t * Returns the file system that the path points to.\n\t */\n\t MountableFileSystem.prototype._getFs = function _getFs (path$$1) {\n\t var this$1 = this;\n\t\n\t var mountList = this.mountList, len = mountList.length;\n\t for (var i = 0; i < len; i++) {\n\t var mountPoint = mountList[i];\n\t // We know path is normalized, so it is a substring of the mount point.\n\t if (mountPoint.length <= path$$1.length && path$$1.indexOf(mountPoint) === 0) {\n\t path$$1 = path$$1.substr(mountPoint.length > 1 ? mountPoint.length : 0);\n\t if (path$$1 === '') {\n\t path$$1 = '/';\n\t }\n\t return { fs: this$1.mntMap[mountPoint], path: path$$1 };\n\t }\n\t }\n\t // Query our root file system.\n\t return { fs: this.rootFs, path: path$$1 };\n\t };\n\t // Global information methods\n\t MountableFileSystem.prototype.getName = function getName () {\n\t return MountableFileSystem.Name;\n\t };\n\t MountableFileSystem.prototype.diskSpace = function diskSpace (path$$1, cb) {\n\t cb(0, 0);\n\t };\n\t MountableFileSystem.prototype.isReadOnly = function isReadOnly () {\n\t return false;\n\t };\n\t MountableFileSystem.prototype.supportsLinks = function supportsLinks () {\n\t // I'm not ready for cross-FS links yet.\n\t return false;\n\t };\n\t MountableFileSystem.prototype.supportsProps = function supportsProps () {\n\t return false;\n\t };\n\t MountableFileSystem.prototype.supportsSynch = function supportsSynch () {\n\t return true;\n\t };\n\t /**\n\t * Fixes up error messages so they mention the mounted file location relative\n\t * to the MFS root, not to the particular FS's root.\n\t * Mutates the input error, and returns it.\n\t */\n\t MountableFileSystem.prototype.standardizeError = function standardizeError (err, path$$1, realPath) {\n\t var index = err.message.indexOf(path$$1);\n\t if (index !== -1) {\n\t err.message = err.message.substr(0, index) + realPath + err.message.substr(index + path$$1.length);\n\t err.path = realPath;\n\t }\n\t return err;\n\t };\n\t // The following methods involve multiple file systems, and thus have custom\n\t // logic.\n\t // Note that we go through the Node API to use its robust default argument\n\t // processing.\n\t MountableFileSystem.prototype.rename = function rename (oldPath, newPath, cb) {\n\t var this$1 = this;\n\t\n\t // Scenario 1: old and new are on same FS.\n\t var fs1rv = this._getFs(oldPath);\n\t var fs2rv = this._getFs(newPath);\n\t if (fs1rv.fs === fs2rv.fs) {\n\t return fs1rv.fs.rename(fs1rv.path, fs2rv.path, function (e) {\n\t if (e) {\n\t this$1.standardizeError(this$1.standardizeError(e, fs1rv.path, oldPath), fs2rv.path, newPath);\n\t }\n\t cb(e);\n\t });\n\t }\n\t // Scenario 2: Different file systems.\n\t // Read old file, write new file, delete old file.\n\t return _fsMock.readFile(oldPath, function (err, data) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t _fsMock.writeFile(newPath, data, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t _fsMock.unlink(oldPath, cb);\n\t });\n\t });\n\t };\n\t MountableFileSystem.prototype.renameSync = function renameSync (oldPath, newPath) {\n\t // Scenario 1: old and new are on same FS.\n\t var fs1rv = this._getFs(oldPath);\n\t var fs2rv = this._getFs(newPath);\n\t if (fs1rv.fs === fs2rv.fs) {\n\t try {\n\t return fs1rv.fs.renameSync(fs1rv.path, fs2rv.path);\n\t }\n\t catch (e) {\n\t this.standardizeError(this.standardizeError(e, fs1rv.path, oldPath), fs2rv.path, newPath);\n\t throw e;\n\t }\n\t }\n\t // Scenario 2: Different file systems.\n\t var data = _fsMock.readFileSync(oldPath);\n\t _fsMock.writeFileSync(newPath, data);\n\t return _fsMock.unlinkSync(oldPath);\n\t };\n\t MountableFileSystem.prototype.readdirSync = function readdirSync (p) {\n\t var fsInfo = this._getFs(p);\n\t // If null, rootfs did not have the directory\n\t // (or the target FS is the root fs).\n\t var rv = null;\n\t // Mount points are all defined in the root FS.\n\t // Ensure that we list those, too.\n\t if (fsInfo.fs !== this.rootFs) {\n\t try {\n\t rv = this.rootFs.readdirSync(p);\n\t }\n\t catch (e) {\n\t // Ignore.\n\t }\n\t }\n\t try {\n\t var rv2 = fsInfo.fs.readdirSync(fsInfo.path);\n\t if (rv === null) {\n\t return rv2;\n\t }\n\t else {\n\t // Filter out duplicates.\n\t return rv2.concat(rv.filter(function (val) { return rv2.indexOf(val) === -1; }));\n\t }\n\t }\n\t catch (e) {\n\t if (rv === null) {\n\t throw this.standardizeError(e, fsInfo.path, p);\n\t }\n\t else {\n\t // The root FS had something.\n\t return rv;\n\t }\n\t }\n\t };\n\t MountableFileSystem.prototype.readdir = function readdir (p, cb) {\n\t var this$1 = this;\n\t\n\t var fsInfo = this._getFs(p);\n\t fsInfo.fs.readdir(fsInfo.path, function (err, files) {\n\t if (fsInfo.fs !== this$1.rootFs) {\n\t try {\n\t var rv = this$1.rootFs.readdirSync(p);\n\t if (files) {\n\t // Filter out duplicates.\n\t files = files.concat(rv.filter(function (val) { return files.indexOf(val) === -1; }));\n\t }\n\t else {\n\t files = rv;\n\t }\n\t }\n\t catch (e) {\n\t // Root FS and target FS did not have directory.\n\t if (err) {\n\t return cb(this$1.standardizeError(err, fsInfo.path, p));\n\t }\n\t }\n\t }\n\t else if (err) {\n\t // Root FS and target FS are the same, and did not have directory.\n\t return cb(this$1.standardizeError(err, fsInfo.path, p));\n\t }\n\t cb(null, files);\n\t });\n\t };\n\t MountableFileSystem.prototype.rmdirSync = function rmdirSync (p) {\n\t var fsInfo = this._getFs(p);\n\t if (this._containsMountPt(p)) {\n\t throw ApiError.ENOTEMPTY(p);\n\t }\n\t else {\n\t try {\n\t fsInfo.fs.rmdirSync(fsInfo.path);\n\t }\n\t catch (e) {\n\t throw this.standardizeError(e, fsInfo.path, p);\n\t }\n\t }\n\t };\n\t MountableFileSystem.prototype.rmdir = function rmdir (p, cb) {\n\t var this$1 = this;\n\t\n\t var fsInfo = this._getFs(p);\n\t if (this._containsMountPt(p)) {\n\t cb(ApiError.ENOTEMPTY(p));\n\t }\n\t else {\n\t fsInfo.fs.rmdir(fsInfo.path, function (err) {\n\t cb(err ? this$1.standardizeError(err, fsInfo.path, p) : null);\n\t });\n\t }\n\t };\n\t /**\n\t * Returns true if the given path contains a mount point.\n\t */\n\t MountableFileSystem.prototype._containsMountPt = function _containsMountPt (p) {\n\t var mountPoints = this.mountList, len = mountPoints.length;\n\t for (var i = 0; i < len; i++) {\n\t var pt = mountPoints[i];\n\t if (pt.length >= p.length && pt.slice(0, p.length) === p) {\n\t return true;\n\t }\n\t }\n\t return false;\n\t };\n\t\n\t return MountableFileSystem;\n\t}(BaseFileSystem));\n\t\n\tMountableFileSystem.Name = \"MountableFileSystem\";\n\tMountableFileSystem.Options = {};\n\t/**\n\t * Tricky: Define all of the functions that merely forward arguments to the\n\t * relevant file system, or return/throw an error.\n\t * Take advantage of the fact that the *first* argument is always the path, and\n\t * the *last* is the callback function (if async).\n\t * @todo Can use numArgs to make proxying more efficient.\n\t * @hidden\n\t */\n\tfunction defineFcn(name, isSync, numArgs) {\n\t if (isSync) {\n\t return function () {\n\t var args = [], len = arguments.length;\n\t while ( len-- ) args[ len ] = arguments[ len ];\n\t\n\t var path$$1 = args[0];\n\t var rv = this._getFs(path$$1);\n\t args[0] = rv.path;\n\t try {\n\t return rv.fs[name].apply(rv.fs, args);\n\t }\n\t catch (e) {\n\t this.standardizeError(e, rv.path, path$$1);\n\t throw e;\n\t }\n\t };\n\t }\n\t else {\n\t return function () {\n\t var this$1 = this;\n\t var args = [], len = arguments.length;\n\t while ( len-- ) args[ len ] = arguments[ len ];\n\t\n\t var path$$1 = args[0];\n\t var rv = this._getFs(path$$1);\n\t args[0] = rv.path;\n\t if (typeof args[args.length - 1] === 'function') {\n\t var cb = args[args.length - 1];\n\t args[args.length - 1] = function () {\n\t var args = [], len = arguments.length;\n\t while ( len-- ) args[ len ] = arguments[ len ];\n\t\n\t if (args.length > 0 && args[0] instanceof ApiError) {\n\t this$1.standardizeError(args[0], rv.path, path$$1);\n\t }\n\t cb.apply(null, args);\n\t };\n\t }\n\t return rv.fs[name].apply(rv.fs, args);\n\t };\n\t }\n\t}\n\t/**\n\t * @hidden\n\t */\n\tvar fsCmdMap = [\n\t // 1 arg functions\n\t ['exists', 'unlink', 'readlink'],\n\t // 2 arg functions\n\t ['stat', 'mkdir', 'realpath', 'truncate'],\n\t // 3 arg functions\n\t ['open', 'readFile', 'chmod', 'utimes'],\n\t // 4 arg functions\n\t ['chown'],\n\t // 5 arg functions\n\t ['writeFile', 'appendFile']\n\t];\n\tfor (var i = 0; i < fsCmdMap.length; i++) {\n\t var cmds = fsCmdMap[i];\n\t for (var i$1 = 0, list = cmds; i$1 < list.length; i$1 += 1) {\n\t var fnName = list[i$1];\n\t\n\t MountableFileSystem.prototype[fnName] = defineFcn(fnName, false, i + 1);\n\t MountableFileSystem.prototype[fnName + 'Sync'] = defineFcn(fnName + 'Sync', true, i + 1);\n\t }\n\t}\n\t\n\t/**\n\t * @hidden\n\t */\n\tvar bfsSetImmediate;\n\tif (typeof (setImmediate) !== \"undefined\") {\n\t bfsSetImmediate = setImmediate;\n\t}\n\telse {\n\t var gScope = global$1;\n\t var timeouts = [];\n\t var messageName = \"zero-timeout-message\";\n\t var canUsePostMessage = function () {\n\t if (typeof gScope.importScripts !== 'undefined' || !gScope.postMessage) {\n\t return false;\n\t }\n\t var postMessageIsAsync = true;\n\t var oldOnMessage = gScope.onmessage;\n\t gScope.onmessage = function () {\n\t postMessageIsAsync = false;\n\t };\n\t gScope.postMessage('', '*');\n\t gScope.onmessage = oldOnMessage;\n\t return postMessageIsAsync;\n\t };\n\t if (canUsePostMessage()) {\n\t bfsSetImmediate = function (fn) {\n\t timeouts.push(fn);\n\t gScope.postMessage(messageName, \"*\");\n\t };\n\t var handleMessage = function (event) {\n\t if (event.source === self && event.data === messageName) {\n\t if (event.stopPropagation) {\n\t event.stopPropagation();\n\t }\n\t else {\n\t event.cancelBubble = true;\n\t }\n\t if (timeouts.length > 0) {\n\t var fn = timeouts.shift();\n\t return fn();\n\t }\n\t }\n\t };\n\t if (gScope.addEventListener) {\n\t gScope.addEventListener('message', handleMessage, true);\n\t }\n\t else {\n\t gScope.attachEvent('onmessage', handleMessage);\n\t }\n\t }\n\t else if (gScope.MessageChannel) {\n\t // WebWorker MessageChannel\n\t var channel = new gScope.MessageChannel();\n\t channel.port1.onmessage = function (event) {\n\t if (timeouts.length > 0) {\n\t return timeouts.shift()();\n\t }\n\t };\n\t bfsSetImmediate = function (fn) {\n\t timeouts.push(fn);\n\t channel.port2.postMessage('');\n\t };\n\t }\n\t else {\n\t bfsSetImmediate = function (fn) {\n\t return setTimeout(fn, 0);\n\t };\n\t }\n\t}\n\tvar setImmediate$3 = bfsSetImmediate;\n\t\n\t/**\n\t * Non-recursive mutex\n\t * @hidden\n\t */\n\tvar Mutex = function Mutex() {\n\t this._locked = false;\n\t this._waiters = [];\n\t};\n\tMutex.prototype.lock = function lock (cb) {\n\t if (this._locked) {\n\t this._waiters.push(cb);\n\t return;\n\t }\n\t this._locked = true;\n\t cb();\n\t};\n\tMutex.prototype.unlock = function unlock () {\n\t if (!this._locked) {\n\t throw new Error('unlock of a non-locked mutex');\n\t }\n\t var next = this._waiters.shift();\n\t // don't unlock - we want to queue up next for the\n\t // _end_ of the current task execution, but we don't\n\t // want it to be called inline with whatever the\n\t // current stack is. This way we still get the nice\n\t // behavior that an unlock immediately followed by a\n\t // lock won't cause starvation.\n\t if (next) {\n\t setImmediate$3(next);\n\t return;\n\t }\n\t this._locked = false;\n\t};\n\tMutex.prototype.tryLock = function tryLock () {\n\t if (this._locked) {\n\t return false;\n\t }\n\t this._locked = true;\n\t return true;\n\t};\n\tMutex.prototype.isLocked = function isLocked () {\n\t return this._locked;\n\t};\n\t\n\t/**\n\t * This class serializes access to an underlying async filesystem.\n\t * For example, on an OverlayFS instance with an async lower\n\t * directory operations like rename and rmdir may involve multiple\n\t * requests involving both the upper and lower filesystems -- they\n\t * are not executed in a single atomic step. OverlayFS uses this\n\t * LockedFS to avoid having to reason about the correctness of\n\t * multiple requests interleaving.\n\t */\n\tvar LockedFS = function LockedFS(fs) {\n\t this._fs = fs;\n\t this._mu = new Mutex();\n\t};\n\tLockedFS.prototype.getName = function getName () {\n\t return 'LockedFS<' + this._fs.getName() + '>';\n\t};\n\tLockedFS.prototype.getFSUnlocked = function getFSUnlocked () {\n\t return this._fs;\n\t};\n\tLockedFS.prototype.initialize = function initialize (cb) {\n\t // FIXME: check to see if FS supports initialization\n\t this._fs.initialize(cb);\n\t};\n\tLockedFS.prototype.diskSpace = function diskSpace (p, cb) {\n\t // FIXME: should this lock?\n\t this._fs.diskSpace(p, cb);\n\t};\n\tLockedFS.prototype.isReadOnly = function isReadOnly () {\n\t return this._fs.isReadOnly();\n\t};\n\tLockedFS.prototype.supportsLinks = function supportsLinks () {\n\t return this._fs.supportsLinks();\n\t};\n\tLockedFS.prototype.supportsProps = function supportsProps () {\n\t return this._fs.supportsProps();\n\t};\n\tLockedFS.prototype.supportsSynch = function supportsSynch () {\n\t return this._fs.supportsSynch();\n\t};\n\tLockedFS.prototype.rename = function rename (oldPath, newPath, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.rename(oldPath, newPath, function (err) {\n\t this$1._mu.unlock();\n\t cb(err);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.renameSync = function renameSync (oldPath, newPath) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.renameSync(oldPath, newPath);\n\t};\n\tLockedFS.prototype.stat = function stat (p, isLstat, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.stat(p, isLstat, function (err, stat) {\n\t this$1._mu.unlock();\n\t cb(err, stat);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.statSync = function statSync (p, isLstat) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.statSync(p, isLstat);\n\t};\n\tLockedFS.prototype.open = function open (p, flag, mode, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.open(p, flag, mode, function (err, fd) {\n\t this$1._mu.unlock();\n\t cb(err, fd);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.openSync = function openSync (p, flag, mode) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.openSync(p, flag, mode);\n\t};\n\tLockedFS.prototype.unlink = function unlink (p, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.unlink(p, function (err) {\n\t this$1._mu.unlock();\n\t cb(err);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.unlinkSync = function unlinkSync (p) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.unlinkSync(p);\n\t};\n\tLockedFS.prototype.rmdir = function rmdir (p, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.rmdir(p, function (err) {\n\t this$1._mu.unlock();\n\t cb(err);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.rmdirSync = function rmdirSync (p) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.rmdirSync(p);\n\t};\n\tLockedFS.prototype.mkdir = function mkdir (p, mode, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.mkdir(p, mode, function (err) {\n\t this$1._mu.unlock();\n\t cb(err);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.mkdirSync = function mkdirSync (p, mode) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.mkdirSync(p, mode);\n\t};\n\tLockedFS.prototype.readdir = function readdir (p, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.readdir(p, function (err, files) {\n\t this$1._mu.unlock();\n\t cb(err, files);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.readdirSync = function readdirSync (p) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.readdirSync(p);\n\t};\n\tLockedFS.prototype.exists = function exists (p, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.exists(p, function (exists) {\n\t this$1._mu.unlock();\n\t cb(exists);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.existsSync = function existsSync (p) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.existsSync(p);\n\t};\n\tLockedFS.prototype.realpath = function realpath (p, cache, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.realpath(p, cache, function (err, resolvedPath) {\n\t this$1._mu.unlock();\n\t cb(err, resolvedPath);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.realpathSync = function realpathSync (p, cache) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.realpathSync(p, cache);\n\t};\n\tLockedFS.prototype.truncate = function truncate (p, len, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.truncate(p, len, function (err) {\n\t this$1._mu.unlock();\n\t cb(err);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.truncateSync = function truncateSync (p, len) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.truncateSync(p, len);\n\t};\n\tLockedFS.prototype.readFile = function readFile (fname, encoding, flag, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.readFile(fname, encoding, flag, function (err, data) {\n\t this$1._mu.unlock();\n\t cb(err, data);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.readFileSync = function readFileSync (fname, encoding, flag) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.readFileSync(fname, encoding, flag);\n\t};\n\tLockedFS.prototype.writeFile = function writeFile (fname, data, encoding, flag, mode, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.writeFile(fname, data, encoding, flag, mode, function (err) {\n\t this$1._mu.unlock();\n\t cb(err);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.writeFileSync = function writeFileSync (fname, data, encoding, flag, mode) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.writeFileSync(fname, data, encoding, flag, mode);\n\t};\n\tLockedFS.prototype.appendFile = function appendFile (fname, data, encoding, flag, mode, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.appendFile(fname, data, encoding, flag, mode, function (err) {\n\t this$1._mu.unlock();\n\t cb(err);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.appendFileSync = function appendFileSync (fname, data, encoding, flag, mode) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.appendFileSync(fname, data, encoding, flag, mode);\n\t};\n\tLockedFS.prototype.chmod = function chmod (p, isLchmod, mode, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.chmod(p, isLchmod, mode, function (err) {\n\t this$1._mu.unlock();\n\t cb(err);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.chmodSync = function chmodSync (p, isLchmod, mode) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.chmodSync(p, isLchmod, mode);\n\t};\n\tLockedFS.prototype.chown = function chown (p, isLchown, uid, gid, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.chown(p, isLchown, uid, gid, function (err) {\n\t this$1._mu.unlock();\n\t cb(err);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.chownSync = function chownSync (p, isLchown, uid, gid) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.chownSync(p, isLchown, uid, gid);\n\t};\n\tLockedFS.prototype.utimes = function utimes (p, atime, mtime, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.utimes(p, atime, mtime, function (err) {\n\t this$1._mu.unlock();\n\t cb(err);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.utimesSync = function utimesSync (p, atime, mtime) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.utimesSync(p, atime, mtime);\n\t};\n\tLockedFS.prototype.link = function link (srcpath, dstpath, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.link(srcpath, dstpath, function (err) {\n\t this$1._mu.unlock();\n\t cb(err);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.linkSync = function linkSync (srcpath, dstpath) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.linkSync(srcpath, dstpath);\n\t};\n\tLockedFS.prototype.symlink = function symlink (srcpath, dstpath, type, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.symlink(srcpath, dstpath, type, function (err) {\n\t this$1._mu.unlock();\n\t cb(err);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.symlinkSync = function symlinkSync (srcpath, dstpath, type) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.symlinkSync(srcpath, dstpath, type);\n\t};\n\tLockedFS.prototype.readlink = function readlink (p, cb) {\n\t var this$1 = this;\n\t\n\t this._mu.lock(function () {\n\t this$1._fs.readlink(p, function (err, linkString) {\n\t this$1._mu.unlock();\n\t cb(err, linkString);\n\t });\n\t });\n\t};\n\tLockedFS.prototype.readlinkSync = function readlinkSync (p) {\n\t if (this._mu.isLocked()) {\n\t throw new Error('invalid sync call');\n\t }\n\t return this._fs.readlinkSync(p);\n\t};\n\t\n\t/**\n\t * @hidden\n\t */\n\tvar deletionLogPath = '/.deletedFiles.log';\n\t/**\n\t * Given a read-only mode, makes it writable.\n\t * @hidden\n\t */\n\tfunction makeModeWritable(mode) {\n\t return 146 | mode;\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction getFlag(f) {\n\t return FileFlag.getFileFlag(f);\n\t}\n\t/**\n\t * Overlays a RO file to make it writable.\n\t */\n\tvar OverlayFile = (function (PreloadFile$$1) {\n\t function OverlayFile(fs, path$$1, flag, stats, data) {\n\t PreloadFile$$1.call(this, fs, path$$1, flag, stats, data);\n\t }\n\t\n\t if ( PreloadFile$$1 ) OverlayFile.__proto__ = PreloadFile$$1;\n\t OverlayFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );\n\t OverlayFile.prototype.constructor = OverlayFile;\n\t OverlayFile.prototype.sync = function sync (cb) {\n\t var this$1 = this;\n\t\n\t if (!this.isDirty()) {\n\t cb(null);\n\t return;\n\t }\n\t this._fs._syncAsync(this, function (err) {\n\t this$1.resetDirty();\n\t cb(err);\n\t });\n\t };\n\t OverlayFile.prototype.syncSync = function syncSync () {\n\t if (this.isDirty()) {\n\t this._fs._syncSync(this);\n\t this.resetDirty();\n\t }\n\t };\n\t OverlayFile.prototype.close = function close (cb) {\n\t this.sync(cb);\n\t };\n\t OverlayFile.prototype.closeSync = function closeSync () {\n\t this.syncSync();\n\t };\n\t\n\t return OverlayFile;\n\t}(PreloadFile));\n\t/**\n\t * *INTERNAL, DO NOT USE DIRECTLY!*\n\t *\n\t * Core OverlayFS class that contains no locking whatsoever. We wrap these objects\n\t * in a LockedFS to prevent races.\n\t */\n\tvar UnlockedOverlayFS = (function (BaseFileSystem$$1) {\n\t function UnlockedOverlayFS(writable, readable) {\n\t BaseFileSystem$$1.call(this);\n\t this._isInitialized = false;\n\t this._initializeCallbacks = [];\n\t this._deletedFiles = {};\n\t this._deleteLog = '';\n\t // If 'true', we have scheduled a delete log update.\n\t this._deleteLogUpdatePending = false;\n\t // If 'true', a delete log update is needed after the scheduled delete log\n\t // update finishes.\n\t this._deleteLogUpdateNeeded = false;\n\t // If there was an error updating the delete log...\n\t this._deleteLogError = null;\n\t this._writable = writable;\n\t this._readable = readable;\n\t if (this._writable.isReadOnly()) {\n\t throw new ApiError(ErrorCode.EINVAL, \"Writable file system must be writable.\");\n\t }\n\t }\n\t\n\t if ( BaseFileSystem$$1 ) UnlockedOverlayFS.__proto__ = BaseFileSystem$$1;\n\t UnlockedOverlayFS.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );\n\t UnlockedOverlayFS.prototype.constructor = UnlockedOverlayFS;\n\t UnlockedOverlayFS.isAvailable = function isAvailable () {\n\t return true;\n\t };\n\t UnlockedOverlayFS.prototype.getOverlayedFileSystems = function getOverlayedFileSystems () {\n\t return {\n\t readable: this._readable,\n\t writable: this._writable\n\t };\n\t };\n\t UnlockedOverlayFS.prototype._syncAsync = function _syncAsync (file, cb) {\n\t var this$1 = this;\n\t\n\t this.createParentDirectoriesAsync(file.getPath(), function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t this$1._writable.writeFile(file.getPath(), file.getBuffer(), null, getFlag('w'), file.getStats().mode, cb);\n\t });\n\t };\n\t UnlockedOverlayFS.prototype._syncSync = function _syncSync (file) {\n\t this.createParentDirectories(file.getPath());\n\t this._writable.writeFileSync(file.getPath(), file.getBuffer(), null, getFlag('w'), file.getStats().mode);\n\t };\n\t UnlockedOverlayFS.prototype.getName = function getName () {\n\t return OverlayFS.Name;\n\t };\n\t /**\n\t * Called once to load up metadata stored on the writable file system.\n\t */\n\t UnlockedOverlayFS.prototype.initialize = function initialize (cb) {\n\t var this$1 = this;\n\t\n\t var callbackArray = this._initializeCallbacks;\n\t var end = function (e) {\n\t this$1._isInitialized = !e;\n\t this$1._initializeCallbacks = [];\n\t callbackArray.forEach((function (cb) { return cb(e); }));\n\t };\n\t // if we're already initialized, immediately invoke the callback\n\t if (this._isInitialized) {\n\t return cb();\n\t }\n\t callbackArray.push(cb);\n\t // The first call to initialize initializes, the rest wait for it to complete.\n\t if (callbackArray.length !== 1) {\n\t return;\n\t }\n\t // Read deletion log, process into metadata.\n\t this._writable.readFile(deletionLogPath, 'utf8', getFlag('r'), function (err, data) {\n\t if (err) {\n\t // ENOENT === Newly-instantiated file system, and thus empty log.\n\t if (err.errno !== ErrorCode.ENOENT) {\n\t return end(err);\n\t }\n\t }\n\t else {\n\t this$1._deleteLog = data;\n\t }\n\t this$1._reparseDeletionLog();\n\t end();\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.isReadOnly = function isReadOnly () { return false; };\n\t UnlockedOverlayFS.prototype.supportsSynch = function supportsSynch () { return this._readable.supportsSynch() && this._writable.supportsSynch(); };\n\t UnlockedOverlayFS.prototype.supportsLinks = function supportsLinks () { return false; };\n\t UnlockedOverlayFS.prototype.supportsProps = function supportsProps () { return this._readable.supportsProps() && this._writable.supportsProps(); };\n\t UnlockedOverlayFS.prototype.getDeletionLog = function getDeletionLog () {\n\t return this._deleteLog;\n\t };\n\t UnlockedOverlayFS.prototype.restoreDeletionLog = function restoreDeletionLog (log) {\n\t this._deleteLog = log;\n\t this._reparseDeletionLog();\n\t this.updateLog('');\n\t };\n\t UnlockedOverlayFS.prototype.rename = function rename (oldPath, newPath, cb) {\n\t var this$1 = this;\n\t\n\t if (!this.checkInitAsync(cb) || this.checkPathAsync(oldPath, cb) || this.checkPathAsync(newPath, cb)) {\n\t return;\n\t }\n\t if (oldPath === deletionLogPath || newPath === deletionLogPath) {\n\t return cb(ApiError.EPERM('Cannot rename deletion log.'));\n\t }\n\t // nothing to do if paths match\n\t if (oldPath === newPath) {\n\t return cb();\n\t }\n\t this.stat(oldPath, false, function (oldErr, oldStats) {\n\t if (oldErr) {\n\t return cb(oldErr);\n\t }\n\t return this$1.stat(newPath, false, function (newErr, newStats) {\n\t var self = this$1;\n\t // precondition: both oldPath and newPath exist and are dirs.\n\t // decreases: |files|\n\t // Need to move *every file/folder* currently stored on\n\t // readable to its new location on writable.\n\t function copyDirContents(files) {\n\t var file = files.shift();\n\t if (!file) {\n\t return cb();\n\t }\n\t var oldFile = path.resolve(oldPath, file);\n\t var newFile = path.resolve(newPath, file);\n\t // Recursion! Should work for any nested files / folders.\n\t self.rename(oldFile, newFile, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t copyDirContents(files);\n\t });\n\t }\n\t var mode = 511;\n\t // from linux's rename(2) manpage: oldpath can specify a\n\t // directory. In this case, newpath must either not exist, or\n\t // it must specify an empty directory.\n\t if (oldStats.isDirectory()) {\n\t if (newErr) {\n\t if (newErr.errno !== ErrorCode.ENOENT) {\n\t return cb(newErr);\n\t }\n\t return this$1._writable.exists(oldPath, function (exists) {\n\t // simple case - both old and new are on the writable layer\n\t if (exists) {\n\t return this$1._writable.rename(oldPath, newPath, cb);\n\t }\n\t this$1._writable.mkdir(newPath, mode, function (mkdirErr) {\n\t if (mkdirErr) {\n\t return cb(mkdirErr);\n\t }\n\t this$1._readable.readdir(oldPath, function (err, files) {\n\t if (err) {\n\t return cb();\n\t }\n\t copyDirContents(files);\n\t });\n\t });\n\t });\n\t }\n\t mode = newStats.mode;\n\t if (!newStats.isDirectory()) {\n\t return cb(ApiError.ENOTDIR(newPath));\n\t }\n\t this$1.readdir(newPath, function (readdirErr, files) {\n\t if (files && files.length) {\n\t return cb(ApiError.ENOTEMPTY(newPath));\n\t }\n\t this$1._readable.readdir(oldPath, function (err, files) {\n\t if (err) {\n\t return cb();\n\t }\n\t copyDirContents(files);\n\t });\n\t });\n\t }\n\t if (newStats && newStats.isDirectory()) {\n\t return cb(ApiError.EISDIR(newPath));\n\t }\n\t this$1.readFile(oldPath, null, getFlag('r'), function (err, data) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t return this$1.writeFile(newPath, data, null, getFlag('w'), oldStats.mode, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t return this$1.unlink(oldPath, cb);\n\t });\n\t });\n\t });\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.renameSync = function renameSync (oldPath, newPath) {\n\t var this$1 = this;\n\t\n\t this.checkInitialized();\n\t this.checkPath(oldPath);\n\t this.checkPath(newPath);\n\t if (oldPath === deletionLogPath || newPath === deletionLogPath) {\n\t throw ApiError.EPERM('Cannot rename deletion log.');\n\t }\n\t // Write newPath using oldPath's contents, delete oldPath.\n\t var oldStats = this.statSync(oldPath, false);\n\t if (oldStats.isDirectory()) {\n\t // Optimization: Don't bother moving if old === new.\n\t if (oldPath === newPath) {\n\t return;\n\t }\n\t var mode = 511;\n\t if (this.existsSync(newPath)) {\n\t var stats = this.statSync(newPath, false);\n\t mode = stats.mode;\n\t if (stats.isDirectory()) {\n\t if (this.readdirSync(newPath).length > 0) {\n\t throw ApiError.ENOTEMPTY(newPath);\n\t }\n\t }\n\t else {\n\t throw ApiError.ENOTDIR(newPath);\n\t }\n\t }\n\t // Take care of writable first. Move any files there, or create an empty directory\n\t // if it doesn't exist.\n\t if (this._writable.existsSync(oldPath)) {\n\t this._writable.renameSync(oldPath, newPath);\n\t }\n\t else if (!this._writable.existsSync(newPath)) {\n\t this._writable.mkdirSync(newPath, mode);\n\t }\n\t // Need to move *every file/folder* currently stored on readable to its new location\n\t // on writable.\n\t if (this._readable.existsSync(oldPath)) {\n\t this._readable.readdirSync(oldPath).forEach(function (name) {\n\t // Recursion! Should work for any nested files / folders.\n\t this$1.renameSync(path.resolve(oldPath, name), path.resolve(newPath, name));\n\t });\n\t }\n\t }\n\t else {\n\t if (this.existsSync(newPath) && this.statSync(newPath, false).isDirectory()) {\n\t throw ApiError.EISDIR(newPath);\n\t }\n\t this.writeFileSync(newPath, this.readFileSync(oldPath, null, getFlag('r')), null, getFlag('w'), oldStats.mode);\n\t }\n\t if (oldPath !== newPath && this.existsSync(oldPath)) {\n\t this.unlinkSync(oldPath);\n\t }\n\t };\n\t UnlockedOverlayFS.prototype.stat = function stat (p, isLstat, cb) {\n\t var this$1 = this;\n\t\n\t if (!this.checkInitAsync(cb)) {\n\t return;\n\t }\n\t this._writable.stat(p, isLstat, function (err, stat) {\n\t if (err && err.errno === ErrorCode.ENOENT) {\n\t if (this$1._deletedFiles[p]) {\n\t cb(ApiError.ENOENT(p));\n\t }\n\t this$1._readable.stat(p, isLstat, function (err, stat) {\n\t if (stat) {\n\t // Make the oldStat's mode writable. Preserve the topmost\n\t // part of the mode, which specifies if it is a file or a\n\t // directory.\n\t stat = stat.clone();\n\t stat.mode = makeModeWritable(stat.mode);\n\t }\n\t cb(err, stat);\n\t });\n\t }\n\t else {\n\t cb(err, stat);\n\t }\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.statSync = function statSync (p, isLstat) {\n\t this.checkInitialized();\n\t try {\n\t return this._writable.statSync(p, isLstat);\n\t }\n\t catch (e) {\n\t if (this._deletedFiles[p]) {\n\t throw ApiError.ENOENT(p);\n\t }\n\t var oldStat = this._readable.statSync(p, isLstat).clone();\n\t // Make the oldStat's mode writable. Preserve the topmost part of the\n\t // mode, which specifies if it is a file or a directory.\n\t oldStat.mode = makeModeWritable(oldStat.mode);\n\t return oldStat;\n\t }\n\t };\n\t UnlockedOverlayFS.prototype.open = function open (p, flag, mode, cb) {\n\t var this$1 = this;\n\t\n\t if (!this.checkInitAsync(cb) || this.checkPathAsync(p, cb)) {\n\t return;\n\t }\n\t this.stat(p, false, function (err, stats) {\n\t if (stats) {\n\t switch (flag.pathExistsAction()) {\n\t case ActionType.TRUNCATE_FILE:\n\t return this$1.createParentDirectoriesAsync(p, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t this$1._writable.open(p, flag, mode, cb);\n\t });\n\t case ActionType.NOP:\n\t return this$1._writable.exists(p, function (exists) {\n\t if (exists) {\n\t this$1._writable.open(p, flag, mode, cb);\n\t }\n\t else {\n\t // at this point we know the stats object we got is from\n\t // the readable FS.\n\t stats = stats.clone();\n\t stats.mode = mode;\n\t this$1._readable.readFile(p, null, getFlag('r'), function (readFileErr, data) {\n\t if (readFileErr) {\n\t return cb(readFileErr);\n\t }\n\t if (stats.size === -1) {\n\t stats.size = data.length;\n\t }\n\t var f = new OverlayFile(this$1, p, flag, stats, data);\n\t cb(null, f);\n\t });\n\t }\n\t });\n\t default:\n\t return cb(ApiError.EEXIST(p));\n\t }\n\t }\n\t else {\n\t switch (flag.pathNotExistsAction()) {\n\t case ActionType.CREATE_FILE:\n\t return this$1.createParentDirectoriesAsync(p, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t return this$1._writable.open(p, flag, mode, cb);\n\t });\n\t default:\n\t return cb(ApiError.ENOENT(p));\n\t }\n\t }\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.openSync = function openSync (p, flag, mode) {\n\t this.checkInitialized();\n\t this.checkPath(p);\n\t if (p === deletionLogPath) {\n\t throw ApiError.EPERM('Cannot open deletion log.');\n\t }\n\t if (this.existsSync(p)) {\n\t switch (flag.pathExistsAction()) {\n\t case ActionType.TRUNCATE_FILE:\n\t this.createParentDirectories(p);\n\t return this._writable.openSync(p, flag, mode);\n\t case ActionType.NOP:\n\t if (this._writable.existsSync(p)) {\n\t return this._writable.openSync(p, flag, mode);\n\t }\n\t else {\n\t // Create an OverlayFile.\n\t var buf = this._readable.readFileSync(p, null, getFlag('r'));\n\t var stats = this._readable.statSync(p, false).clone();\n\t stats.mode = mode;\n\t return new OverlayFile(this, p, flag, stats, buf);\n\t }\n\t default:\n\t throw ApiError.EEXIST(p);\n\t }\n\t }\n\t else {\n\t switch (flag.pathNotExistsAction()) {\n\t case ActionType.CREATE_FILE:\n\t this.createParentDirectories(p);\n\t return this._writable.openSync(p, flag, mode);\n\t default:\n\t throw ApiError.ENOENT(p);\n\t }\n\t }\n\t };\n\t UnlockedOverlayFS.prototype.unlink = function unlink (p, cb) {\n\t var this$1 = this;\n\t\n\t if (!this.checkInitAsync(cb) || this.checkPathAsync(p, cb)) {\n\t return;\n\t }\n\t this.exists(p, function (exists) {\n\t if (!exists) {\n\t return cb(ApiError.ENOENT(p));\n\t }\n\t this$1._writable.exists(p, function (writableExists) {\n\t if (writableExists) {\n\t return this$1._writable.unlink(p, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t this$1.exists(p, function (readableExists) {\n\t if (readableExists) {\n\t this$1.deletePath(p);\n\t }\n\t cb(null);\n\t });\n\t });\n\t }\n\t else {\n\t // if this only exists on the readable FS, add it to the\n\t // delete map.\n\t this$1.deletePath(p);\n\t cb(null);\n\t }\n\t });\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.unlinkSync = function unlinkSync (p) {\n\t this.checkInitialized();\n\t this.checkPath(p);\n\t if (this.existsSync(p)) {\n\t if (this._writable.existsSync(p)) {\n\t this._writable.unlinkSync(p);\n\t }\n\t // if it still exists add to the delete log\n\t if (this.existsSync(p)) {\n\t this.deletePath(p);\n\t }\n\t }\n\t else {\n\t throw ApiError.ENOENT(p);\n\t }\n\t };\n\t UnlockedOverlayFS.prototype.rmdir = function rmdir (p, cb) {\n\t var this$1 = this;\n\t\n\t if (!this.checkInitAsync(cb)) {\n\t return;\n\t }\n\t var rmdirLower = function () {\n\t this$1.readdir(p, function (err, files) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t if (files.length) {\n\t return cb(ApiError.ENOTEMPTY(p));\n\t }\n\t this$1.deletePath(p);\n\t cb(null);\n\t });\n\t };\n\t this.exists(p, function (exists) {\n\t if (!exists) {\n\t return cb(ApiError.ENOENT(p));\n\t }\n\t this$1._writable.exists(p, function (writableExists) {\n\t if (writableExists) {\n\t this$1._writable.rmdir(p, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t this$1._readable.exists(p, function (readableExists) {\n\t if (readableExists) {\n\t rmdirLower();\n\t }\n\t else {\n\t cb();\n\t }\n\t });\n\t });\n\t }\n\t else {\n\t rmdirLower();\n\t }\n\t });\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.rmdirSync = function rmdirSync (p) {\n\t this.checkInitialized();\n\t if (this.existsSync(p)) {\n\t if (this._writable.existsSync(p)) {\n\t this._writable.rmdirSync(p);\n\t }\n\t if (this.existsSync(p)) {\n\t // Check if directory is empty.\n\t if (this.readdirSync(p).length > 0) {\n\t throw ApiError.ENOTEMPTY(p);\n\t }\n\t else {\n\t this.deletePath(p);\n\t }\n\t }\n\t }\n\t else {\n\t throw ApiError.ENOENT(p);\n\t }\n\t };\n\t UnlockedOverlayFS.prototype.mkdir = function mkdir (p, mode, cb) {\n\t var this$1 = this;\n\t\n\t if (!this.checkInitAsync(cb)) {\n\t return;\n\t }\n\t this.exists(p, function (exists) {\n\t if (exists) {\n\t return cb(ApiError.EEXIST(p));\n\t }\n\t // The below will throw should any of the parent directories\n\t // fail to exist on _writable.\n\t this$1.createParentDirectoriesAsync(p, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t this$1._writable.mkdir(p, mode, cb);\n\t });\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.mkdirSync = function mkdirSync (p, mode) {\n\t this.checkInitialized();\n\t if (this.existsSync(p)) {\n\t throw ApiError.EEXIST(p);\n\t }\n\t else {\n\t // The below will throw should any of the parent directories fail to exist\n\t // on _writable.\n\t this.createParentDirectories(p);\n\t this._writable.mkdirSync(p, mode);\n\t }\n\t };\n\t UnlockedOverlayFS.prototype.readdir = function readdir (p, cb) {\n\t var this$1 = this;\n\t\n\t if (!this.checkInitAsync(cb)) {\n\t return;\n\t }\n\t this.stat(p, false, function (err, dirStats) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t if (!dirStats.isDirectory()) {\n\t return cb(ApiError.ENOTDIR(p));\n\t }\n\t this$1._writable.readdir(p, function (err, wFiles) {\n\t if (err && err.code !== 'ENOENT') {\n\t return cb(err);\n\t }\n\t else if (err || !wFiles) {\n\t wFiles = [];\n\t }\n\t this$1._readable.readdir(p, function (err, rFiles) {\n\t // if the directory doesn't exist on the lower FS set rFiles\n\t // here to simplify the following code.\n\t if (err || !rFiles) {\n\t rFiles = [];\n\t }\n\t // Readdir in both, check delete log on read-only file system's files, merge, return.\n\t var seenMap = {};\n\t var filtered = wFiles.concat(rFiles.filter(function (fPath) { return !this$1._deletedFiles[(p + \"/\" + fPath)]; })).filter(function (fPath) {\n\t // Remove duplicates.\n\t var result = !seenMap[fPath];\n\t seenMap[fPath] = true;\n\t return result;\n\t });\n\t cb(null, filtered);\n\t });\n\t });\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.readdirSync = function readdirSync (p) {\n\t var this$1 = this;\n\t\n\t this.checkInitialized();\n\t var dirStats = this.statSync(p, false);\n\t if (!dirStats.isDirectory()) {\n\t throw ApiError.ENOTDIR(p);\n\t }\n\t // Readdir in both, check delete log on RO file system's listing, merge, return.\n\t var contents = [];\n\t try {\n\t contents = contents.concat(this._writable.readdirSync(p));\n\t }\n\t catch (e) {\n\t // NOP.\n\t }\n\t try {\n\t contents = contents.concat(this._readable.readdirSync(p).filter(function (fPath) { return !this$1._deletedFiles[(p + \"/\" + fPath)]; }));\n\t }\n\t catch (e) {\n\t // NOP.\n\t }\n\t var seenMap = {};\n\t return contents.filter(function (fileP) {\n\t var result = !seenMap[fileP];\n\t seenMap[fileP] = true;\n\t return result;\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.exists = function exists (p, cb) {\n\t var this$1 = this;\n\t\n\t // Cannot pass an error back to callback, so throw an exception instead\n\t // if not initialized.\n\t this.checkInitialized();\n\t this._writable.exists(p, function (existsWritable) {\n\t if (existsWritable) {\n\t return cb(true);\n\t }\n\t this$1._readable.exists(p, function (existsReadable) {\n\t cb(existsReadable && this$1._deletedFiles[p] !== true);\n\t });\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.existsSync = function existsSync (p) {\n\t this.checkInitialized();\n\t return this._writable.existsSync(p) || (this._readable.existsSync(p) && this._deletedFiles[p] !== true);\n\t };\n\t UnlockedOverlayFS.prototype.chmod = function chmod (p, isLchmod, mode, cb) {\n\t var this$1 = this;\n\t\n\t if (!this.checkInitAsync(cb)) {\n\t return;\n\t }\n\t this.operateOnWritableAsync(p, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t else {\n\t this$1._writable.chmod(p, isLchmod, mode, cb);\n\t }\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.chmodSync = function chmodSync (p, isLchmod, mode) {\n\t var this$1 = this;\n\t\n\t this.checkInitialized();\n\t this.operateOnWritable(p, function () {\n\t this$1._writable.chmodSync(p, isLchmod, mode);\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.chown = function chown (p, isLchmod, uid, gid, cb) {\n\t var this$1 = this;\n\t\n\t if (!this.checkInitAsync(cb)) {\n\t return;\n\t }\n\t this.operateOnWritableAsync(p, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t else {\n\t this$1._writable.chown(p, isLchmod, uid, gid, cb);\n\t }\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.chownSync = function chownSync (p, isLchown, uid, gid) {\n\t var this$1 = this;\n\t\n\t this.checkInitialized();\n\t this.operateOnWritable(p, function () {\n\t this$1._writable.chownSync(p, isLchown, uid, gid);\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.utimes = function utimes (p, atime, mtime, cb) {\n\t var this$1 = this;\n\t\n\t if (!this.checkInitAsync(cb)) {\n\t return;\n\t }\n\t this.operateOnWritableAsync(p, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t else {\n\t this$1._writable.utimes(p, atime, mtime, cb);\n\t }\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.utimesSync = function utimesSync (p, atime, mtime) {\n\t var this$1 = this;\n\t\n\t this.checkInitialized();\n\t this.operateOnWritable(p, function () {\n\t this$1._writable.utimesSync(p, atime, mtime);\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.deletePath = function deletePath (p) {\n\t this._deletedFiles[p] = true;\n\t this.updateLog((\"d\" + p + \"\\n\"));\n\t };\n\t UnlockedOverlayFS.prototype.updateLog = function updateLog (addition) {\n\t var this$1 = this;\n\t\n\t this._deleteLog += addition;\n\t if (this._deleteLogUpdatePending) {\n\t this._deleteLogUpdateNeeded = true;\n\t }\n\t else {\n\t this._deleteLogUpdatePending = true;\n\t this._writable.writeFile(deletionLogPath, this._deleteLog, 'utf8', FileFlag.getFileFlag('w'), 420, function (e) {\n\t this$1._deleteLogUpdatePending = false;\n\t if (e) {\n\t this$1._deleteLogError = e;\n\t }\n\t else if (this$1._deleteLogUpdateNeeded) {\n\t this$1._deleteLogUpdateNeeded = false;\n\t this$1.updateLog('');\n\t }\n\t });\n\t }\n\t };\n\t UnlockedOverlayFS.prototype._reparseDeletionLog = function _reparseDeletionLog () {\n\t var this$1 = this;\n\t\n\t this._deletedFiles = {};\n\t this._deleteLog.split('\\n').forEach(function (path$$1) {\n\t // If the log entry begins w/ 'd', it's a deletion.\n\t this$1._deletedFiles[path$$1.slice(1)] = path$$1.slice(0, 1) === 'd';\n\t });\n\t };\n\t UnlockedOverlayFS.prototype.checkInitialized = function checkInitialized () {\n\t if (!this._isInitialized) {\n\t throw new ApiError(ErrorCode.EPERM, \"OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.\");\n\t }\n\t else if (this._deleteLogError !== null) {\n\t var e = this._deleteLogError;\n\t this._deleteLogError = null;\n\t throw e;\n\t }\n\t };\n\t UnlockedOverlayFS.prototype.checkInitAsync = function checkInitAsync (cb) {\n\t if (!this._isInitialized) {\n\t cb(new ApiError(ErrorCode.EPERM, \"OverlayFS is not initialized. Please initialize OverlayFS using its initialize() method before using it.\"));\n\t return false;\n\t }\n\t else if (this._deleteLogError !== null) {\n\t var e = this._deleteLogError;\n\t this._deleteLogError = null;\n\t cb(e);\n\t return false;\n\t }\n\t return true;\n\t };\n\t UnlockedOverlayFS.prototype.checkPath = function checkPath (p) {\n\t if (p === deletionLogPath) {\n\t throw ApiError.EPERM(p);\n\t }\n\t };\n\t UnlockedOverlayFS.prototype.checkPathAsync = function checkPathAsync (p, cb) {\n\t if (p === deletionLogPath) {\n\t cb(ApiError.EPERM(p));\n\t return true;\n\t }\n\t return false;\n\t };\n\t UnlockedOverlayFS.prototype.createParentDirectoriesAsync = function createParentDirectoriesAsync (p, cb) {\n\t var parent = path.dirname(p);\n\t var toCreate = [];\n\t var self = this;\n\t this._writable.stat(parent, false, statDone);\n\t function statDone(err, stat) {\n\t if (err) {\n\t toCreate.push(parent);\n\t parent = path.dirname(parent);\n\t self._writable.stat(parent, false, statDone);\n\t }\n\t else {\n\t createParents();\n\t }\n\t }\n\t function createParents() {\n\t if (!toCreate.length) {\n\t return cb();\n\t }\n\t var dir = toCreate.pop();\n\t self._readable.stat(dir, false, function (err, stats) {\n\t // stop if we couldn't read the dir\n\t if (!stats) {\n\t return cb();\n\t }\n\t self._writable.mkdir(dir, stats.mode, function (err) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t createParents();\n\t });\n\t });\n\t }\n\t };\n\t /**\n\t * With the given path, create the needed parent directories on the writable storage\n\t * should they not exist. Use modes from the read-only storage.\n\t */\n\t UnlockedOverlayFS.prototype.createParentDirectories = function createParentDirectories (p) {\n\t var this$1 = this;\n\t\n\t var parent = path.dirname(p), toCreate = [];\n\t while (!this._writable.existsSync(parent)) {\n\t toCreate.push(parent);\n\t parent = path.dirname(parent);\n\t }\n\t toCreate = toCreate.reverse();\n\t toCreate.forEach(function (p) {\n\t this$1._writable.mkdirSync(p, this$1.statSync(p, false).mode);\n\t });\n\t };\n\t /**\n\t * Helper function:\n\t * - Ensures p is on writable before proceeding. Throws an error if it doesn't exist.\n\t * - Calls f to perform operation on writable.\n\t */\n\t UnlockedOverlayFS.prototype.operateOnWritable = function operateOnWritable (p, f) {\n\t if (this.existsSync(p)) {\n\t if (!this._writable.existsSync(p)) {\n\t // File is on readable storage. Copy to writable storage before\n\t // changing its mode.\n\t this.copyToWritable(p);\n\t }\n\t f();\n\t }\n\t else {\n\t throw ApiError.ENOENT(p);\n\t }\n\t };\n\t UnlockedOverlayFS.prototype.operateOnWritableAsync = function operateOnWritableAsync (p, cb) {\n\t var this$1 = this;\n\t\n\t this.exists(p, function (exists) {\n\t if (!exists) {\n\t return cb(ApiError.ENOENT(p));\n\t }\n\t this$1._writable.exists(p, function (existsWritable) {\n\t if (existsWritable) {\n\t cb();\n\t }\n\t else {\n\t return this$1.copyToWritableAsync(p, cb);\n\t }\n\t });\n\t });\n\t };\n\t /**\n\t * Copy from readable to writable storage.\n\t * PRECONDITION: File does not exist on writable storage.\n\t */\n\t UnlockedOverlayFS.prototype.copyToWritable = function copyToWritable (p) {\n\t var pStats = this.statSync(p, false);\n\t if (pStats.isDirectory()) {\n\t this._writable.mkdirSync(p, pStats.mode);\n\t }\n\t else {\n\t this.writeFileSync(p, this._readable.readFileSync(p, null, getFlag('r')), null, getFlag('w'), this.statSync(p, false).mode);\n\t }\n\t };\n\t UnlockedOverlayFS.prototype.copyToWritableAsync = function copyToWritableAsync (p, cb) {\n\t var this$1 = this;\n\t\n\t this.stat(p, false, function (err, pStats) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t if (pStats.isDirectory()) {\n\t return this$1._writable.mkdir(p, pStats.mode, cb);\n\t }\n\t // need to copy file.\n\t this$1._readable.readFile(p, null, getFlag('r'), function (err, data) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t this$1.writeFile(p, data, null, getFlag('w'), pStats.mode, cb);\n\t });\n\t });\n\t };\n\t\n\t return UnlockedOverlayFS;\n\t}(BaseFileSystem));\n\t/**\n\t * OverlayFS makes a read-only filesystem writable by storing writes on a second,\n\t * writable file system. Deletes are persisted via metadata stored on the writable\n\t * file system.\n\t */\n\tvar OverlayFS = (function (LockedFS$$1) {\n\t function OverlayFS(writable, readable, deprecateMsg) {\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t LockedFS$$1.call(this, new UnlockedOverlayFS(writable, readable));\n\t deprecationMessage(deprecateMsg, OverlayFS.Name, { readable: \"readable file system\", writable: \"writable file system\" });\n\t }\n\t\n\t if ( LockedFS$$1 ) OverlayFS.__proto__ = LockedFS$$1;\n\t OverlayFS.prototype = Object.create( LockedFS$$1 && LockedFS$$1.prototype );\n\t OverlayFS.prototype.constructor = OverlayFS;\n\t /**\n\t * Constructs and initializes an OverlayFS instance with the given options.\n\t */\n\t OverlayFS.Create = function Create (opts, cb) {\n\t try {\n\t var fs = new OverlayFS(opts.writable, opts.readable, false);\n\t fs.initialize(function (e) {\n\t cb(e, fs);\n\t }, false);\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t OverlayFS.isAvailable = function isAvailable () {\n\t return UnlockedOverlayFS.isAvailable();\n\t };\n\t /**\n\t * **Deprecated. Please use OverlayFS.Create() to construct and initialize OverlayFS instances.**\n\t */\n\t OverlayFS.prototype.initialize = function initialize (cb, deprecateMsg) {\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t if (deprecateMsg) {\n\t console.warn(\"[OverlayFS] OverlayFS.initialize() is deprecated and will be removed in the next major release. Please use 'OverlayFS.Create({readable: readable file system instance, writable: writable file system instance}, cb)' to create and initialize OverlayFS instances.\");\n\t }\n\t LockedFS$$1.prototype.initialize.call(this, cb);\n\t };\n\t OverlayFS.prototype.getOverlayedFileSystems = function getOverlayedFileSystems () {\n\t return LockedFS$$1.prototype.getFSUnlocked.call(this).getOverlayedFileSystems();\n\t };\n\t OverlayFS.prototype.unwrap = function unwrap () {\n\t return LockedFS$$1.prototype.getFSUnlocked.call(this);\n\t };\n\t\n\t return OverlayFS;\n\t}(LockedFS));\n\t\n\tOverlayFS.Name = \"OverlayFS\";\n\tOverlayFS.Options = {\n\t writable: {\n\t type: \"object\",\n\t description: \"The file system to write modified files to.\"\n\t },\n\t readable: {\n\t type: \"object\",\n\t description: \"The file system that initially populates this file system.\"\n\t }\n\t};\n\t\n\t/**\n\t * @hidden\n\t */\n\tvar SpecialArgType;\n\t(function (SpecialArgType) {\n\t // Callback\n\t SpecialArgType[SpecialArgType[\"CB\"] = 0] = \"CB\";\n\t // File descriptor\n\t SpecialArgType[SpecialArgType[\"FD\"] = 1] = \"FD\";\n\t // API error\n\t SpecialArgType[SpecialArgType[\"API_ERROR\"] = 2] = \"API_ERROR\";\n\t // Stats object\n\t SpecialArgType[SpecialArgType[\"STATS\"] = 3] = \"STATS\";\n\t // Initial probe for file system information.\n\t SpecialArgType[SpecialArgType[\"PROBE\"] = 4] = \"PROBE\";\n\t // FileFlag object.\n\t SpecialArgType[SpecialArgType[\"FILEFLAG\"] = 5] = \"FILEFLAG\";\n\t // Buffer object.\n\t SpecialArgType[SpecialArgType[\"BUFFER\"] = 6] = \"BUFFER\";\n\t // Generic Error object.\n\t SpecialArgType[SpecialArgType[\"ERROR\"] = 7] = \"ERROR\";\n\t})(SpecialArgType || (SpecialArgType = {}));\n\t/**\n\t * Converts callback arguments into ICallbackArgument objects, and back\n\t * again.\n\t * @hidden\n\t */\n\tvar CallbackArgumentConverter = function CallbackArgumentConverter() {\n\t this._callbacks = {};\n\t this._nextId = 0;\n\t};\n\tCallbackArgumentConverter.prototype.toRemoteArg = function toRemoteArg (cb) {\n\t var id = this._nextId++;\n\t this._callbacks[id] = cb;\n\t return {\n\t type: SpecialArgType.CB,\n\t id: id\n\t };\n\t};\n\tCallbackArgumentConverter.prototype.toLocalArg = function toLocalArg (id) {\n\t var cb = this._callbacks[id];\n\t delete this._callbacks[id];\n\t return cb;\n\t};\n\t/**\n\t * @hidden\n\t */\n\tvar FileDescriptorArgumentConverter = function FileDescriptorArgumentConverter() {\n\t this._fileDescriptors = {};\n\t this._nextId = 0;\n\t};\n\tFileDescriptorArgumentConverter.prototype.toRemoteArg = function toRemoteArg (fd, p, flag, cb) {\n\t var id = this._nextId++;\n\t var data;\n\t var stat;\n\t this._fileDescriptors[id] = fd;\n\t // Extract needed information asynchronously.\n\t fd.stat(function (err, stats) {\n\t if (err) {\n\t cb(err);\n\t }\n\t else {\n\t stat = bufferToTransferrableObject(stats.toBuffer());\n\t // If it's a readable flag, we need to grab contents.\n\t if (flag.isReadable()) {\n\t fd.read(Buffer.alloc(stats.size), 0, stats.size, 0, function (err, bytesRead, buff) {\n\t if (err) {\n\t cb(err);\n\t }\n\t else {\n\t data = bufferToTransferrableObject(buff);\n\t cb(null, {\n\t type: SpecialArgType.FD,\n\t id: id,\n\t data: data,\n\t stat: stat,\n\t path: p,\n\t flag: flag.getFlagString()\n\t });\n\t }\n\t });\n\t }\n\t else {\n\t // File is not readable, which means writing to it will append or\n\t // truncate/replace existing contents. Return an empty arraybuffer.\n\t cb(null, {\n\t type: SpecialArgType.FD,\n\t id: id,\n\t data: new ArrayBuffer(0),\n\t stat: stat,\n\t path: p,\n\t flag: flag.getFlagString()\n\t });\n\t }\n\t }\n\t });\n\t};\n\tFileDescriptorArgumentConverter.prototype.applyFdAPIRequest = function applyFdAPIRequest (request, cb) {\n\t var this$1 = this;\n\t\n\t var fdArg = request.args[0];\n\t this._applyFdChanges(fdArg, function (err, fd) {\n\t if (err) {\n\t cb(err);\n\t }\n\t else {\n\t // Apply method on now-changed file descriptor.\n\t fd[request.method](function (e) {\n\t if (request.method === 'close') {\n\t delete this$1._fileDescriptors[fdArg.id];\n\t }\n\t cb(e);\n\t });\n\t }\n\t });\n\t};\n\tFileDescriptorArgumentConverter.prototype._applyFdChanges = function _applyFdChanges (remoteFd, cb) {\n\t var fd = this._fileDescriptors[remoteFd.id], data = transferrableObjectToBuffer(remoteFd.data), remoteStats = Stats.fromBuffer(transferrableObjectToBuffer(remoteFd.stat));\n\t // Write data if the file is writable.\n\t var flag = FileFlag.getFileFlag(remoteFd.flag);\n\t if (flag.isWriteable()) {\n\t // Appendable: Write to end of file.\n\t // Writeable: Replace entire contents of file.\n\t fd.write(data, 0, data.length, flag.isAppendable() ? fd.getPos() : 0, function (e) {\n\t function applyStatChanges() {\n\t // Check if mode changed.\n\t fd.stat(function (e, stats) {\n\t if (e) {\n\t cb(e);\n\t }\n\t else {\n\t if (stats.mode !== remoteStats.mode) {\n\t fd.chmod(remoteStats.mode, function (e) {\n\t cb(e, fd);\n\t });\n\t }\n\t else {\n\t cb(e, fd);\n\t }\n\t }\n\t });\n\t }\n\t if (e) {\n\t cb(e);\n\t }\n\t else {\n\t // If writeable & not appendable, we need to ensure file contents are\n\t // identical to those from the remote FD. Thus, we truncate to the\n\t // length of the remote file.\n\t if (!flag.isAppendable()) {\n\t fd.truncate(data.length, function () {\n\t applyStatChanges();\n\t });\n\t }\n\t else {\n\t applyStatChanges();\n\t }\n\t }\n\t });\n\t }\n\t else {\n\t cb(null, fd);\n\t }\n\t};\n\t/**\n\t * @hidden\n\t */\n\tfunction apiErrorLocal2Remote(e) {\n\t return {\n\t type: SpecialArgType.API_ERROR,\n\t errorData: bufferToTransferrableObject(e.writeToBuffer())\n\t };\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction apiErrorRemote2Local(e) {\n\t return ApiError.fromBuffer(transferrableObjectToBuffer(e.errorData));\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction errorLocal2Remote(e) {\n\t return {\n\t type: SpecialArgType.ERROR,\n\t name: e.name,\n\t message: e.message,\n\t stack: e.stack\n\t };\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction errorRemote2Local(e) {\n\t var cnstr = global$1[e.name];\n\t if (typeof (cnstr) !== 'function') {\n\t cnstr = Error;\n\t }\n\t var err = new cnstr(e.message);\n\t err.stack = e.stack;\n\t return err;\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction statsLocal2Remote(stats) {\n\t return {\n\t type: SpecialArgType.STATS,\n\t statsData: bufferToTransferrableObject(stats.toBuffer())\n\t };\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction statsRemote2Local(stats) {\n\t return Stats.fromBuffer(transferrableObjectToBuffer(stats.statsData));\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction fileFlagLocal2Remote(flag) {\n\t return {\n\t type: SpecialArgType.FILEFLAG,\n\t flagStr: flag.getFlagString()\n\t };\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction fileFlagRemote2Local(remoteFlag) {\n\t return FileFlag.getFileFlag(remoteFlag.flagStr);\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction bufferToTransferrableObject(buff) {\n\t return buffer2ArrayBuffer(buff);\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction transferrableObjectToBuffer(buff) {\n\t return arrayBuffer2Buffer(buff);\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction bufferLocal2Remote(buff) {\n\t return {\n\t type: SpecialArgType.BUFFER,\n\t data: bufferToTransferrableObject(buff)\n\t };\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction bufferRemote2Local(buffArg) {\n\t return transferrableObjectToBuffer(buffArg.data);\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction isAPIRequest(data) {\n\t return data && typeof data === 'object' && data.hasOwnProperty('browserfsMessage') && data['browserfsMessage'];\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction isAPIResponse(data) {\n\t return data && typeof data === 'object' && data.hasOwnProperty('browserfsMessage') && data['browserfsMessage'];\n\t}\n\t/**\n\t * Represents a remote file in a different worker/thread.\n\t */\n\tvar WorkerFile = (function (PreloadFile$$1) {\n\t function WorkerFile(_fs, _path, _flag, _stat, remoteFdId, contents) {\n\t PreloadFile$$1.call(this, _fs, _path, _flag, _stat, contents);\n\t this._remoteFdId = remoteFdId;\n\t }\n\t\n\t if ( PreloadFile$$1 ) WorkerFile.__proto__ = PreloadFile$$1;\n\t WorkerFile.prototype = Object.create( PreloadFile$$1 && PreloadFile$$1.prototype );\n\t WorkerFile.prototype.constructor = WorkerFile;\n\t WorkerFile.prototype.getRemoteFdId = function getRemoteFdId () {\n\t return this._remoteFdId;\n\t };\n\t /**\n\t * @hidden\n\t */\n\t WorkerFile.prototype.toRemoteArg = function toRemoteArg () {\n\t return {\n\t type: SpecialArgType.FD,\n\t id: this._remoteFdId,\n\t data: bufferToTransferrableObject(this.getBuffer()),\n\t stat: bufferToTransferrableObject(this.getStats().toBuffer()),\n\t path: this.getPath(),\n\t flag: this.getFlag().getFlagString()\n\t };\n\t };\n\t WorkerFile.prototype.sync = function sync (cb) {\n\t this._syncClose('sync', cb);\n\t };\n\t WorkerFile.prototype.close = function close (cb) {\n\t this._syncClose('close', cb);\n\t };\n\t WorkerFile.prototype._syncClose = function _syncClose (type, cb) {\n\t var this$1 = this;\n\t\n\t if (this.isDirty()) {\n\t this._fs.syncClose(type, this, function (e) {\n\t if (!e) {\n\t this$1.resetDirty();\n\t }\n\t cb(e);\n\t });\n\t }\n\t else {\n\t cb();\n\t }\n\t };\n\t\n\t return WorkerFile;\n\t}(PreloadFile));\n\t/**\n\t * WorkerFS lets you access a BrowserFS instance that is running in a different\n\t * JavaScript context (e.g. access BrowserFS in one of your WebWorkers, or\n\t * access BrowserFS running on the main page from a WebWorker).\n\t *\n\t * For example, to have a WebWorker access files in the main browser thread,\n\t * do the following:\n\t *\n\t * MAIN BROWSER THREAD:\n\t *\n\t * ```javascript\n\t * // Listen for remote file system requests.\n\t * BrowserFS.FileSystem.WorkerFS.attachRemoteListener(webWorkerObject);\n\t * ```\n\t *\n\t * WEBWORKER THREAD:\n\t *\n\t * ```javascript\n\t * // Set the remote file system as the root file system.\n\t * BrowserFS.configure({ fs: \"WorkerFS\", options: { worker: self }}, function(e) {\n\t * // Ready!\n\t * });\n\t * ```\n\t *\n\t * Note that synchronous operations are not permitted on the WorkerFS, regardless\n\t * of the configuration option of the remote FS.\n\t */\n\tvar WorkerFS = (function (BaseFileSystem$$1) {\n\t function WorkerFS(worker, deprecateMsg) {\n\t var this$1 = this;\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t BaseFileSystem$$1.call(this);\n\t this._callbackConverter = new CallbackArgumentConverter();\n\t this._isInitialized = false;\n\t this._isReadOnly = false;\n\t this._supportLinks = false;\n\t this._supportProps = false;\n\t this._worker = worker;\n\t deprecationMessage(deprecateMsg, WorkerFS.Name, { worker: \"Web Worker instance\" });\n\t this._worker.addEventListener('message', function (e) {\n\t var resp = e.data;\n\t if (isAPIResponse(resp)) {\n\t var i;\n\t var args = resp.args;\n\t var fixedArgs = new Array(args.length);\n\t // Dispatch event to correct id.\n\t for (i = 0; i < fixedArgs.length; i++) {\n\t fixedArgs[i] = this$1._argRemote2Local(args[i]);\n\t }\n\t this$1._callbackConverter.toLocalArg(resp.cbId).apply(null, fixedArgs);\n\t }\n\t });\n\t }\n\t\n\t if ( BaseFileSystem$$1 ) WorkerFS.__proto__ = BaseFileSystem$$1;\n\t WorkerFS.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );\n\t WorkerFS.prototype.constructor = WorkerFS;\n\t WorkerFS.Create = function Create (opts, cb) {\n\t var fs = new WorkerFS(opts.worker, false);\n\t fs.initialize(function () {\n\t cb(null, fs);\n\t });\n\t };\n\t WorkerFS.isAvailable = function isAvailable () {\n\t return typeof (importScripts) !== 'undefined' || typeof (Worker) !== 'undefined';\n\t };\n\t /**\n\t * Attaches a listener to the remote worker for file system requests.\n\t */\n\t WorkerFS.attachRemoteListener = function attachRemoteListener (worker) {\n\t var fdConverter = new FileDescriptorArgumentConverter();\n\t function argLocal2Remote(arg, requestArgs, cb) {\n\t switch (typeof arg) {\n\t case 'object':\n\t if (arg instanceof Stats) {\n\t cb(null, statsLocal2Remote(arg));\n\t }\n\t else if (arg instanceof ApiError) {\n\t cb(null, apiErrorLocal2Remote(arg));\n\t }\n\t else if (arg instanceof BaseFile) {\n\t // Pass in p and flags from original request.\n\t cb(null, fdConverter.toRemoteArg(arg, requestArgs[0], requestArgs[1], cb));\n\t }\n\t else if (arg instanceof FileFlag) {\n\t cb(null, fileFlagLocal2Remote(arg));\n\t }\n\t else if (arg instanceof Buffer) {\n\t cb(null, bufferLocal2Remote(arg));\n\t }\n\t else if (arg instanceof Error) {\n\t cb(null, errorLocal2Remote(arg));\n\t }\n\t else {\n\t cb(null, arg);\n\t }\n\t break;\n\t default:\n\t cb(null, arg);\n\t break;\n\t }\n\t }\n\t function argRemote2Local(arg, fixedRequestArgs) {\n\t if (!arg) {\n\t return arg;\n\t }\n\t switch (typeof arg) {\n\t case 'object':\n\t if (typeof arg['type'] === 'number') {\n\t var specialArg = arg;\n\t switch (specialArg.type) {\n\t case SpecialArgType.CB:\n\t var cbId = arg.id;\n\t return function () {\n\t var arguments$1 = arguments;\n\t\n\t var i;\n\t var fixedArgs = new Array(arguments.length);\n\t var message, countdown = arguments.length;\n\t function abortAndSendError(err) {\n\t if (countdown > 0) {\n\t countdown = -1;\n\t message = {\n\t browserfsMessage: true,\n\t cbId: cbId,\n\t args: [apiErrorLocal2Remote(err)]\n\t };\n\t worker.postMessage(message);\n\t }\n\t }\n\t for (i = 0; i < arguments.length; i++) {\n\t // Capture i and argument.\n\t (function (i, arg) {\n\t argLocal2Remote(arg, fixedRequestArgs, function (err, fixedArg) {\n\t fixedArgs[i] = fixedArg;\n\t if (err) {\n\t abortAndSendError(err);\n\t }\n\t else if (--countdown === 0) {\n\t message = {\n\t browserfsMessage: true,\n\t cbId: cbId,\n\t args: fixedArgs\n\t };\n\t worker.postMessage(message);\n\t }\n\t });\n\t })(i, arguments$1[i]);\n\t }\n\t if (arguments.length === 0) {\n\t message = {\n\t browserfsMessage: true,\n\t cbId: cbId,\n\t args: fixedArgs\n\t };\n\t worker.postMessage(message);\n\t }\n\t };\n\t case SpecialArgType.API_ERROR:\n\t return apiErrorRemote2Local(specialArg);\n\t case SpecialArgType.STATS:\n\t return statsRemote2Local(specialArg);\n\t case SpecialArgType.FILEFLAG:\n\t return fileFlagRemote2Local(specialArg);\n\t case SpecialArgType.BUFFER:\n\t return bufferRemote2Local(specialArg);\n\t case SpecialArgType.ERROR:\n\t return errorRemote2Local(specialArg);\n\t default:\n\t // No idea what this is.\n\t return arg;\n\t }\n\t }\n\t else {\n\t return arg;\n\t }\n\t default:\n\t return arg;\n\t }\n\t }\n\t worker.addEventListener('message', function (e) {\n\t var request = e.data;\n\t if (isAPIRequest(request)) {\n\t var args = request.args, fixedArgs = new Array(args.length);\n\t switch (request.method) {\n\t case 'close':\n\t case 'sync':\n\t (function () {\n\t // File descriptor-relative methods.\n\t var remoteCb = args[1];\n\t fdConverter.applyFdAPIRequest(request, function (err) {\n\t // Send response.\n\t var response = {\n\t browserfsMessage: true,\n\t cbId: remoteCb.id,\n\t args: err ? [apiErrorLocal2Remote(err)] : []\n\t };\n\t worker.postMessage(response);\n\t });\n\t })();\n\t break;\n\t case 'probe':\n\t (function () {\n\t var rootFs = _fsMock.getRootFS(), remoteCb = args[1], probeResponse = {\n\t type: SpecialArgType.PROBE,\n\t isReadOnly: rootFs.isReadOnly(),\n\t supportsLinks: rootFs.supportsLinks(),\n\t supportsProps: rootFs.supportsProps()\n\t }, response = {\n\t browserfsMessage: true,\n\t cbId: remoteCb.id,\n\t args: [probeResponse]\n\t };\n\t worker.postMessage(response);\n\t })();\n\t break;\n\t default:\n\t // File system methods.\n\t for (var i = 0; i < args.length; i++) {\n\t fixedArgs[i] = argRemote2Local(args[i], fixedArgs);\n\t }\n\t var rootFS = _fsMock.getRootFS();\n\t rootFS[request.method].apply(rootFS, fixedArgs);\n\t break;\n\t }\n\t }\n\t });\n\t };\n\t WorkerFS.prototype.getName = function getName () {\n\t return WorkerFS.Name;\n\t };\n\t /**\n\t * **Deprecated. Please use WorkerFS.Create() method to construct and initialize WorkerFS instances.**\n\t *\n\t * Called once both local and remote sides are set up.\n\t */\n\t WorkerFS.prototype.initialize = function initialize (cb) {\n\t var this$1 = this;\n\t\n\t if (!this._isInitialized) {\n\t var message = {\n\t browserfsMessage: true,\n\t method: 'probe',\n\t args: [this._argLocal2Remote(emptyBuffer()), this._callbackConverter.toRemoteArg(function (probeResponse) {\n\t this$1._isInitialized = true;\n\t this$1._isReadOnly = probeResponse.isReadOnly;\n\t this$1._supportLinks = probeResponse.supportsLinks;\n\t this$1._supportProps = probeResponse.supportsProps;\n\t cb();\n\t })]\n\t };\n\t this._worker.postMessage(message);\n\t }\n\t else {\n\t cb();\n\t }\n\t };\n\t WorkerFS.prototype.isReadOnly = function isReadOnly () { return this._isReadOnly; };\n\t WorkerFS.prototype.supportsSynch = function supportsSynch () { return false; };\n\t WorkerFS.prototype.supportsLinks = function supportsLinks () { return this._supportLinks; };\n\t WorkerFS.prototype.supportsProps = function supportsProps () { return this._supportProps; };\n\t WorkerFS.prototype.rename = function rename (oldPath, newPath, cb) {\n\t this._rpc('rename', arguments);\n\t };\n\t WorkerFS.prototype.stat = function stat (p, isLstat, cb) {\n\t this._rpc('stat', arguments);\n\t };\n\t WorkerFS.prototype.open = function open (p, flag, mode, cb) {\n\t this._rpc('open', arguments);\n\t };\n\t WorkerFS.prototype.unlink = function unlink (p, cb) {\n\t this._rpc('unlink', arguments);\n\t };\n\t WorkerFS.prototype.rmdir = function rmdir (p, cb) {\n\t this._rpc('rmdir', arguments);\n\t };\n\t WorkerFS.prototype.mkdir = function mkdir (p, mode, cb) {\n\t this._rpc('mkdir', arguments);\n\t };\n\t WorkerFS.prototype.readdir = function readdir (p, cb) {\n\t this._rpc('readdir', arguments);\n\t };\n\t WorkerFS.prototype.exists = function exists (p, cb) {\n\t this._rpc('exists', arguments);\n\t };\n\t WorkerFS.prototype.realpath = function realpath (p, cache, cb) {\n\t this._rpc('realpath', arguments);\n\t };\n\t WorkerFS.prototype.truncate = function truncate (p, len, cb) {\n\t this._rpc('truncate', arguments);\n\t };\n\t WorkerFS.prototype.readFile = function readFile (fname, encoding, flag, cb) {\n\t this._rpc('readFile', arguments);\n\t };\n\t WorkerFS.prototype.writeFile = function writeFile (fname, data, encoding, flag, mode, cb) {\n\t this._rpc('writeFile', arguments);\n\t };\n\t WorkerFS.prototype.appendFile = function appendFile (fname, data, encoding, flag, mode, cb) {\n\t this._rpc('appendFile', arguments);\n\t };\n\t WorkerFS.prototype.chmod = function chmod (p, isLchmod, mode, cb) {\n\t this._rpc('chmod', arguments);\n\t };\n\t WorkerFS.prototype.chown = function chown (p, isLchown, uid, gid, cb) {\n\t this._rpc('chown', arguments);\n\t };\n\t WorkerFS.prototype.utimes = function utimes (p, atime, mtime, cb) {\n\t this._rpc('utimes', arguments);\n\t };\n\t WorkerFS.prototype.link = function link (srcpath, dstpath, cb) {\n\t this._rpc('link', arguments);\n\t };\n\t WorkerFS.prototype.symlink = function symlink (srcpath, dstpath, type, cb) {\n\t this._rpc('symlink', arguments);\n\t };\n\t WorkerFS.prototype.readlink = function readlink (p, cb) {\n\t this._rpc('readlink', arguments);\n\t };\n\t WorkerFS.prototype.syncClose = function syncClose (method, fd, cb) {\n\t this._worker.postMessage({\n\t browserfsMessage: true,\n\t method: method,\n\t args: [fd.toRemoteArg(), this._callbackConverter.toRemoteArg(cb)]\n\t });\n\t };\n\t WorkerFS.prototype._argRemote2Local = function _argRemote2Local (arg) {\n\t if (!arg) {\n\t return arg;\n\t }\n\t switch (typeof arg) {\n\t case 'object':\n\t if (typeof arg['type'] === 'number') {\n\t var specialArg = arg;\n\t switch (specialArg.type) {\n\t case SpecialArgType.API_ERROR:\n\t return apiErrorRemote2Local(specialArg);\n\t case SpecialArgType.FD:\n\t var fdArg = specialArg;\n\t return new WorkerFile(this, fdArg.path, FileFlag.getFileFlag(fdArg.flag), Stats.fromBuffer(transferrableObjectToBuffer(fdArg.stat)), fdArg.id, transferrableObjectToBuffer(fdArg.data));\n\t case SpecialArgType.STATS:\n\t return statsRemote2Local(specialArg);\n\t case SpecialArgType.FILEFLAG:\n\t return fileFlagRemote2Local(specialArg);\n\t case SpecialArgType.BUFFER:\n\t return bufferRemote2Local(specialArg);\n\t case SpecialArgType.ERROR:\n\t return errorRemote2Local(specialArg);\n\t default:\n\t return arg;\n\t }\n\t }\n\t else {\n\t return arg;\n\t }\n\t default:\n\t return arg;\n\t }\n\t };\n\t WorkerFS.prototype._rpc = function _rpc (methodName, args) {\n\t var this$1 = this;\n\t\n\t var fixedArgs = new Array(args.length);\n\t for (var i = 0; i < args.length; i++) {\n\t fixedArgs[i] = this$1._argLocal2Remote(args[i]);\n\t }\n\t var message = {\n\t browserfsMessage: true,\n\t method: methodName,\n\t args: fixedArgs\n\t };\n\t this._worker.postMessage(message);\n\t };\n\t /**\n\t * Converts a local argument into a remote argument. Public so WorkerFile objects can call it.\n\t */\n\t WorkerFS.prototype._argLocal2Remote = function _argLocal2Remote (arg) {\n\t if (!arg) {\n\t return arg;\n\t }\n\t switch (typeof arg) {\n\t case \"object\":\n\t if (arg instanceof Stats) {\n\t return statsLocal2Remote(arg);\n\t }\n\t else if (arg instanceof ApiError) {\n\t return apiErrorLocal2Remote(arg);\n\t }\n\t else if (arg instanceof WorkerFile) {\n\t return arg.toRemoteArg();\n\t }\n\t else if (arg instanceof FileFlag) {\n\t return fileFlagLocal2Remote(arg);\n\t }\n\t else if (arg instanceof Buffer) {\n\t return bufferLocal2Remote(arg);\n\t }\n\t else if (arg instanceof Error) {\n\t return errorLocal2Remote(arg);\n\t }\n\t else {\n\t return \"Unknown argument\";\n\t }\n\t case \"function\":\n\t return this._callbackConverter.toRemoteArg(arg);\n\t default:\n\t return arg;\n\t }\n\t };\n\t\n\t return WorkerFS;\n\t}(BaseFileSystem));\n\t\n\tWorkerFS.Name = \"WorkerFS\";\n\tWorkerFS.Options = {\n\t worker: {\n\t type: \"object\",\n\t description: \"The target worker that you want to connect to, or the current worker if in a worker context.\",\n\t validator: function (v, cb) {\n\t // Check for a `postMessage` function.\n\t if (v['postMessage']) {\n\t cb();\n\t }\n\t else {\n\t cb(new ApiError(ErrorCode.EINVAL, \"option must be a Web Worker instance.\"));\n\t }\n\t }\n\t }\n\t};\n\t\n\t/**\n\t * Contains utility methods for performing a variety of tasks with\n\t * XmlHttpRequest across browsers.\n\t */\n\tfunction asyncDownloadFileModern(p, type, cb) {\n\t var req = new XMLHttpRequest();\n\t req.open('GET', p, true);\n\t var jsonSupported = true;\n\t switch (type) {\n\t case 'buffer':\n\t req.responseType = 'arraybuffer';\n\t break;\n\t case 'json':\n\t // Some browsers don't support the JSON response type.\n\t // They either reset responseType, or throw an exception.\n\t // @see https://github.com/Modernizr/Modernizr/blob/master/src/testXhrType.js\n\t try {\n\t req.responseType = 'json';\n\t jsonSupported = req.responseType === 'json';\n\t }\n\t catch (e) {\n\t jsonSupported = false;\n\t }\n\t break;\n\t default:\n\t return cb(new ApiError(ErrorCode.EINVAL, \"Invalid download type: \" + type));\n\t }\n\t req.onreadystatechange = function (e) {\n\t if (req.readyState === 4) {\n\t if (req.status === 200) {\n\t switch (type) {\n\t case 'buffer':\n\t // XXX: WebKit-based browsers return *null* when XHRing an empty file.\n\t return cb(null, req.response ? Buffer.from(req.response) : emptyBuffer());\n\t case 'json':\n\t if (jsonSupported) {\n\t return cb(null, req.response);\n\t }\n\t else {\n\t return cb(null, JSON.parse(req.responseText));\n\t }\n\t }\n\t }\n\t else {\n\t return cb(new ApiError(req.status, \"XHR error.\"));\n\t }\n\t }\n\t };\n\t req.send();\n\t}\n\tfunction syncDownloadFileModern(p, type) {\n\t var req = new XMLHttpRequest();\n\t req.open('GET', p, false);\n\t // On most platforms, we cannot set the responseType of synchronous downloads.\n\t // @todo Test for this; IE10 allows this, as do older versions of Chrome/FF.\n\t var data = null;\n\t var err = null;\n\t // Classic hack to download binary data as a string.\n\t req.overrideMimeType('text/plain; charset=x-user-defined');\n\t req.onreadystatechange = function (e) {\n\t if (req.readyState === 4) {\n\t if (req.status === 200) {\n\t switch (type) {\n\t case 'buffer':\n\t // Convert the text into a buffer.\n\t var text = req.responseText;\n\t data = Buffer.alloc(text.length);\n\t // Throw away the upper bits of each character.\n\t for (var i = 0; i < text.length; i++) {\n\t // This will automatically throw away the upper bit of each\n\t // character for us.\n\t data[i] = text.charCodeAt(i);\n\t }\n\t return;\n\t case 'json':\n\t data = JSON.parse(req.responseText);\n\t return;\n\t }\n\t }\n\t else {\n\t err = new ApiError(req.status, \"XHR error.\");\n\t return;\n\t }\n\t }\n\t };\n\t req.send();\n\t if (err) {\n\t throw err;\n\t }\n\t return data;\n\t}\n\tfunction syncDownloadFileIE10(p, type) {\n\t var req = new XMLHttpRequest();\n\t req.open('GET', p, false);\n\t switch (type) {\n\t case 'buffer':\n\t req.responseType = 'arraybuffer';\n\t break;\n\t case 'json':\n\t // IE10 does not support the JSON type.\n\t break;\n\t default:\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid download type: \" + type);\n\t }\n\t var data;\n\t var err;\n\t req.onreadystatechange = function (e) {\n\t if (req.readyState === 4) {\n\t if (req.status === 200) {\n\t switch (type) {\n\t case 'buffer':\n\t data = Buffer.from(req.response);\n\t break;\n\t case 'json':\n\t data = JSON.parse(req.response);\n\t break;\n\t }\n\t }\n\t else {\n\t err = new ApiError(req.status, \"XHR error.\");\n\t }\n\t }\n\t };\n\t req.send();\n\t if (err) {\n\t throw err;\n\t }\n\t return data;\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction getFileSize(async, p, cb) {\n\t var req = new XMLHttpRequest();\n\t req.open('HEAD', p, async);\n\t req.onreadystatechange = function (e) {\n\t if (req.readyState === 4) {\n\t if (req.status === 200) {\n\t try {\n\t return cb(null, parseInt(req.getResponseHeader('Content-Length') || '-1', 10));\n\t }\n\t catch (e) {\n\t // In the event that the header isn't present or there is an error...\n\t return cb(new ApiError(ErrorCode.EIO, \"XHR HEAD error: Could not read content-length.\"));\n\t }\n\t }\n\t else {\n\t return cb(new ApiError(req.status, \"XHR HEAD error.\"));\n\t }\n\t }\n\t };\n\t req.send();\n\t}\n\t/**\n\t * Asynchronously download a file as a buffer or a JSON object.\n\t * Note that the third function signature with a non-specialized type is\n\t * invalid, but TypeScript requires it when you specialize string arguments to\n\t * constants.\n\t * @hidden\n\t */\n\tvar asyncDownloadFile = asyncDownloadFileModern;\n\t/**\n\t * Synchronously download a file as a buffer or a JSON object.\n\t * Note that the third function signature with a non-specialized type is\n\t * invalid, but TypeScript requires it when you specialize string arguments to\n\t * constants.\n\t * @hidden\n\t */\n\tvar syncDownloadFile = (isIE && typeof Blob !== 'undefined') ? syncDownloadFileIE10 : syncDownloadFileModern;\n\t/**\n\t * Synchronously retrieves the size of the given file in bytes.\n\t * @hidden\n\t */\n\tfunction getFileSizeSync(p) {\n\t var rv = -1;\n\t getFileSize(false, p, function (err, size) {\n\t if (err) {\n\t throw err;\n\t }\n\t rv = size;\n\t });\n\t return rv;\n\t}\n\t/**\n\t * Asynchronously retrieves the size of the given file in bytes.\n\t * @hidden\n\t */\n\tfunction getFileSizeAsync(p, cb) {\n\t getFileSize(true, p, cb);\n\t}\n\t\n\t/**\n\t * A simple class for storing a filesystem index. Assumes that all paths passed\n\t * to it are *absolute* paths.\n\t *\n\t * Can be used as a partial or a full index, although care must be taken if used\n\t * for the former purpose, especially when directories are concerned.\n\t */\n\tvar FileIndex = function FileIndex() {\n\t // _index is a single-level key,value store that maps *directory* paths to\n\t // DirInodes. File information is only contained in DirInodes themselves.\n\t this._index = {};\n\t // Create the root directory.\n\t this.addPath('/', new DirInode());\n\t};\n\t/**\n\t * Static method for constructing indices from a JSON listing.\n\t * @param listing Directory listing generated by tools/XHRIndexer.coffee\n\t * @return A new FileIndex object.\n\t */\n\tFileIndex.fromListing = function fromListing (listing) {\n\t var idx = new FileIndex();\n\t // Add a root DirNode.\n\t var rootInode = new DirInode();\n\t idx._index['/'] = rootInode;\n\t var queue = [['', listing, rootInode]];\n\t while (queue.length > 0) {\n\t var inode = (void 0);\n\t var next = queue.pop();\n\t var pwd = next[0];\n\t var tree = next[1];\n\t var parent = next[2];\n\t for (var node in tree) {\n\t if (tree.hasOwnProperty(node)) {\n\t var children = tree[node];\n\t var name = pwd + \"/\" + node;\n\t if (children) {\n\t idx._index[name] = inode = new DirInode();\n\t queue.push([name, children, inode]);\n\t }\n\t else {\n\t // This inode doesn't have correct size information, noted with -1.\n\t inode = new FileInode(new Stats(FileType.FILE, -1, 0x16D));\n\t }\n\t if (parent) {\n\t parent._ls[node] = inode;\n\t }\n\t }\n\t }\n\t }\n\t return idx;\n\t};\n\t/**\n\t * Runs the given function over all files in the index.\n\t */\n\tFileIndex.prototype.fileIterator = function fileIterator (cb) {\n\t var this$1 = this;\n\t\n\t for (var path$$1 in this$1._index) {\n\t if (this$1._index.hasOwnProperty(path$$1)) {\n\t var dir = this$1._index[path$$1];\n\t var files = dir.getListing();\n\t for (var i = 0, list = files; i < list.length; i += 1) {\n\t var file = list[i];\n\t\n\t var item = dir.getItem(file);\n\t if (isFileInode(item)) {\n\t cb(item.getData());\n\t }\n\t }\n\t }\n\t }\n\t};\n\t/**\n\t * Adds the given absolute path to the index if it is not already in the index.\n\t * Creates any needed parent directories.\n\t * @param path The path to add to the index.\n\t * @param inode The inode for the\n\t * path to add.\n\t * @return 'True' if it was added or already exists, 'false' if there\n\t * was an issue adding it (e.g. item in path is a file, item exists but is\n\t * different).\n\t * @todo If adding fails and implicitly creates directories, we do not clean up\n\t * the new empty directories.\n\t */\n\tFileIndex.prototype.addPath = function addPath (path$$1, inode) {\n\t if (!inode) {\n\t throw new Error('Inode must be specified');\n\t }\n\t if (path$$1[0] !== '/') {\n\t throw new Error('Path must be absolute, got: ' + path$$1);\n\t }\n\t // Check if it already exists.\n\t if (this._index.hasOwnProperty(path$$1)) {\n\t return this._index[path$$1] === inode;\n\t }\n\t var splitPath = this._split_path(path$$1);\n\t var dirpath = splitPath[0];\n\t var itemname = splitPath[1];\n\t // Try to add to its parent directory first.\n\t var parent = this._index[dirpath];\n\t if (parent === undefined && path$$1 !== '/') {\n\t // Create parent.\n\t parent = new DirInode();\n\t if (!this.addPath(dirpath, parent)) {\n\t return false;\n\t }\n\t }\n\t // Add myself to my parent.\n\t if (path$$1 !== '/') {\n\t if (!parent.addItem(itemname, inode)) {\n\t return false;\n\t }\n\t }\n\t // If I'm a directory, add myself to the index.\n\t if (isDirInode(inode)) {\n\t this._index[path$$1] = inode;\n\t }\n\t return true;\n\t};\n\t/**\n\t * Adds the given absolute path to the index if it is not already in the index.\n\t * The path is added without special treatment (no joining of adjacent separators, etc).\n\t * Creates any needed parent directories.\n\t * @param path The path to add to the index.\n\t * @param inode The inode for the\n\t * path to add.\n\t * @return 'True' if it was added or already exists, 'false' if there\n\t * was an issue adding it (e.g. item in path is a file, item exists but is\n\t * different).\n\t * @todo If adding fails and implicitly creates directories, we do not clean up\n\t * the new empty directories.\n\t */\n\tFileIndex.prototype.addPathFast = function addPathFast (path$$1, inode) {\n\t var itemNameMark = path$$1.lastIndexOf('/');\n\t var parentPath = itemNameMark === 0 ? \"/\" : path$$1.substring(0, itemNameMark);\n\t var itemName = path$$1.substring(itemNameMark + 1);\n\t // Try to add to its parent directory first.\n\t var parent = this._index[parentPath];\n\t if (parent === undefined) {\n\t // Create parent.\n\t parent = new DirInode();\n\t this.addPathFast(parentPath, parent);\n\t }\n\t if (!parent.addItem(itemName, inode)) {\n\t return false;\n\t }\n\t // If adding a directory, add to the index as well.\n\t if (inode.isDir()) {\n\t this._index[path$$1] = inode;\n\t }\n\t return true;\n\t};\n\t/**\n\t * Removes the given path. Can be a file or a directory.\n\t * @return The removed item,\n\t * or null if it did not exist.\n\t */\n\tFileIndex.prototype.removePath = function removePath (path$$1) {\n\t var this$1 = this;\n\t\n\t var splitPath = this._split_path(path$$1);\n\t var dirpath = splitPath[0];\n\t var itemname = splitPath[1];\n\t // Try to remove it from its parent directory first.\n\t var parent = this._index[dirpath];\n\t if (parent === undefined) {\n\t return null;\n\t }\n\t // Remove myself from my parent.\n\t var inode = parent.remItem(itemname);\n\t if (inode === null) {\n\t return null;\n\t }\n\t // If I'm a directory, remove myself from the index, and remove my children.\n\t if (isDirInode(inode)) {\n\t var children = inode.getListing();\n\t for (var i = 0, list = children; i < list.length; i += 1) {\n\t var child = list[i];\n\t\n\t this$1.removePath(path$$1 + '/' + child);\n\t }\n\t // Remove the directory from the index, unless it's the root.\n\t if (path$$1 !== '/') {\n\t delete this._index[path$$1];\n\t }\n\t }\n\t return inode;\n\t};\n\t/**\n\t * Retrieves the directory listing of the given path.\n\t * @return An array of files in the given path, or 'null' if it does not exist.\n\t */\n\tFileIndex.prototype.ls = function ls (path$$1) {\n\t var item = this._index[path$$1];\n\t if (item === undefined) {\n\t return null;\n\t }\n\t return item.getListing();\n\t};\n\t/**\n\t * Returns the inode of the given item.\n\t * @return Returns null if the item does not exist.\n\t */\n\tFileIndex.prototype.getInode = function getInode (path$$1) {\n\t var splitPath = this._split_path(path$$1);\n\t var dirpath = splitPath[0];\n\t var itemname = splitPath[1];\n\t // Retrieve from its parent directory.\n\t var parent = this._index[dirpath];\n\t if (parent === undefined) {\n\t return null;\n\t }\n\t // Root case\n\t if (dirpath === path$$1) {\n\t return parent;\n\t }\n\t return parent.getItem(itemname);\n\t};\n\t/**\n\t * Split into a (directory path, item name) pair\n\t */\n\tFileIndex.prototype._split_path = function _split_path (p) {\n\t var dirpath = path.dirname(p);\n\t var itemname = p.substr(dirpath.length + (dirpath === \"/\" ? 0 : 1));\n\t return [dirpath, itemname];\n\t};\n\t/**\n\t * Inode for a file. Stores an arbitrary (filesystem-specific) data payload.\n\t */\n\tvar FileInode = function FileInode(data) {\n\t this.data = data;\n\t};\n\tFileInode.prototype.isFile = function isFile () { return true; };\n\tFileInode.prototype.isDir = function isDir () { return false; };\n\tFileInode.prototype.getData = function getData () { return this.data; };\n\tFileInode.prototype.setData = function setData (data) { this.data = data; };\n\t/**\n\t * Inode for a directory. Currently only contains the directory listing.\n\t */\n\tvar DirInode = function DirInode(data) {\n\t if ( data === void 0 ) data = null;\n\t\n\t this.data = data;\n\t this._ls = {};\n\t};\n\tDirInode.prototype.isFile = function isFile () {\n\t return false;\n\t};\n\tDirInode.prototype.isDir = function isDir () {\n\t return true;\n\t};\n\tDirInode.prototype.getData = function getData () { return this.data; };\n\t/**\n\t * Return a Stats object for this inode.\n\t * @todo Should probably remove this at some point. This isn't the\n\t * responsibility of the FileIndex.\n\t */\n\tDirInode.prototype.getStats = function getStats () {\n\t return new Stats(FileType.DIRECTORY, 4096, 0x16D);\n\t};\n\t/**\n\t * Returns the directory listing for this directory. Paths in the directory are\n\t * relative to the directory's path.\n\t * @return The directory listing for this directory.\n\t */\n\tDirInode.prototype.getListing = function getListing () {\n\t return Object.keys(this._ls);\n\t};\n\t/**\n\t * Returns the inode for the indicated item, or null if it does not exist.\n\t * @param p Name of item in this directory.\n\t */\n\tDirInode.prototype.getItem = function getItem (p) {\n\t var item = this._ls[p];\n\t return item ? item : null;\n\t};\n\t/**\n\t * Add the given item to the directory listing. Note that the given inode is\n\t * not copied, and will be mutated by the DirInode if it is a DirInode.\n\t * @param p Item name to add to the directory listing.\n\t * @param inode The inode for the\n\t * item to add to the directory inode.\n\t * @return True if it was added, false if it already existed.\n\t */\n\tDirInode.prototype.addItem = function addItem (p, inode) {\n\t if (p in this._ls) {\n\t return false;\n\t }\n\t this._ls[p] = inode;\n\t return true;\n\t};\n\t/**\n\t * Removes the given item from the directory listing.\n\t * @param p Name of item to remove from the directory listing.\n\t * @return Returns the item\n\t * removed, or null if the item did not exist.\n\t */\n\tDirInode.prototype.remItem = function remItem (p) {\n\t var item = this._ls[p];\n\t if (item === undefined) {\n\t return null;\n\t }\n\t delete this._ls[p];\n\t return item;\n\t};\n\t/**\n\t * @hidden\n\t */\n\tfunction isFileInode(inode) {\n\t return !!inode && inode.isFile();\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction isDirInode(inode) {\n\t return !!inode && inode.isDir();\n\t}\n\t\n\t/**\n\t * Try to convert the given buffer into a string, and pass it to the callback.\n\t * Optimization that removes the needed try/catch into a helper function, as\n\t * this is an uncommon case.\n\t * @hidden\n\t */\n\tfunction tryToString(buff, encoding, cb) {\n\t try {\n\t cb(null, buff.toString(encoding));\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t}\n\t/**\n\t * A simple filesystem backed by XMLHttpRequests. You must create a directory listing using the\n\t * `make_xhrfs_index` tool provided by BrowserFS.\n\t *\n\t * If you install BrowserFS globally with `npm i -g browserfs`, you can generate a listing by\n\t * running `make_xhrfs_index` in your terminal in the directory you would like to index:\n\t *\n\t * ```\n\t * make_xhrfs_index > index.json\n\t * ```\n\t *\n\t * Listings objects look like the following:\n\t *\n\t * ```json\n\t * {\n\t * \"home\": {\n\t * \"jvilk\": {\n\t * \"someFile.txt\": null,\n\t * \"someDir\": {\n\t * // Empty directory\n\t * }\n\t * }\n\t * }\n\t * }\n\t * ```\n\t *\n\t * *This example has the folder `/home/jvilk` with subfile `someFile.txt` and subfolder `someDir`.*\n\t */\n\tvar XmlHttpRequest = (function (BaseFileSystem$$1) {\n\t function XmlHttpRequest(listingUrlOrObj, prefixUrl, deprecateMsg) {\n\t if ( prefixUrl === void 0 ) prefixUrl = '';\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t BaseFileSystem$$1.call(this);\n\t if (!listingUrlOrObj) {\n\t listingUrlOrObj = 'index.json';\n\t }\n\t // prefix_url must end in a directory separator.\n\t if (prefixUrl.length > 0 && prefixUrl.charAt(prefixUrl.length - 1) !== '/') {\n\t prefixUrl = prefixUrl + '/';\n\t }\n\t this.prefixUrl = prefixUrl;\n\t var listing = null;\n\t if (typeof (listingUrlOrObj) === \"string\") {\n\t listing = this._requestFileSync(listingUrlOrObj, 'json');\n\t if (!listing) {\n\t throw new Error(\"Unable to find listing at URL: ${listingUrlOrObj}\");\n\t }\n\t }\n\t else {\n\t listing = listingUrlOrObj;\n\t }\n\t deprecationMessage(deprecateMsg, XmlHttpRequest.Name, { index: typeof (listingUrlOrObj) === \"string\" ? listingUrlOrObj : \"file index as an object\", baseUrl: prefixUrl });\n\t this._index = FileIndex.fromListing(listing);\n\t }\n\t\n\t if ( BaseFileSystem$$1 ) XmlHttpRequest.__proto__ = BaseFileSystem$$1;\n\t XmlHttpRequest.prototype = Object.create( BaseFileSystem$$1 && BaseFileSystem$$1.prototype );\n\t XmlHttpRequest.prototype.constructor = XmlHttpRequest;\n\t /**\n\t * Construct an XmlHttpRequest file system backend with the given options.\n\t */\n\t XmlHttpRequest.Create = function Create (opts, cb) {\n\t if (opts.index === undefined) {\n\t opts.index = \"index.json\";\n\t }\n\t if (typeof (opts.index) === \"string\") {\n\t XmlHttpRequest.FromURL(opts.index, cb, opts.baseUrl, false);\n\t }\n\t else {\n\t cb(null, new XmlHttpRequest(opts.index, opts.baseUrl, false));\n\t }\n\t };\n\t XmlHttpRequest.isAvailable = function isAvailable () {\n\t return typeof (XMLHttpRequest) !== \"undefined\" && XMLHttpRequest !== null;\n\t };\n\t /**\n\t * **Deprecated. Please use XmlHttpRequest.Create() method instead to construct XmlHttpRequest objects.**\n\t *\n\t * Constructs an XmlHttpRequest object using the directory listing at the given URL.\n\t * Uses the base URL as the URL prefix for fetched files.\n\t * @param cb Called when the file system has been instantiated, or if an error occurs.\n\t */\n\t XmlHttpRequest.FromURL = function FromURL (url, cb, baseUrl, deprecateMsg) {\n\t if ( baseUrl === void 0 ) baseUrl = url.slice(0, url.lastIndexOf('/') + 1);\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t if (deprecateMsg) {\n\t console.warn((\"[XmlHttpRequest] XmlHttpRequest.FromURL() is deprecated and will be removed in the next major release. Please use 'XmlHttpRequest.Create({ index: \\\"\" + url + \"\\\", baseUrl: \\\"\" + baseUrl + \"\\\" }, cb)' instead.\"));\n\t }\n\t asyncDownloadFile(url, \"json\", function (e, data) {\n\t if (e) {\n\t cb(e);\n\t }\n\t else {\n\t cb(null, new XmlHttpRequest(data, baseUrl, false));\n\t }\n\t });\n\t };\n\t XmlHttpRequest.prototype.empty = function empty () {\n\t this._index.fileIterator(function (file) {\n\t file.fileData = null;\n\t });\n\t };\n\t XmlHttpRequest.prototype.getName = function getName () {\n\t return XmlHttpRequest.Name;\n\t };\n\t XmlHttpRequest.prototype.diskSpace = function diskSpace (path$$1, cb) {\n\t // Read-only file system. We could calculate the total space, but that's not\n\t // important right now.\n\t cb(0, 0);\n\t };\n\t XmlHttpRequest.prototype.isReadOnly = function isReadOnly () {\n\t return true;\n\t };\n\t XmlHttpRequest.prototype.supportsLinks = function supportsLinks () {\n\t return false;\n\t };\n\t XmlHttpRequest.prototype.supportsProps = function supportsProps () {\n\t return false;\n\t };\n\t XmlHttpRequest.prototype.supportsSynch = function supportsSynch () {\n\t return true;\n\t };\n\t /**\n\t * Special XHR function: Preload the given file into the index.\n\t * @param [String] path\n\t * @param [BrowserFS.Buffer] buffer\n\t */\n\t XmlHttpRequest.prototype.preloadFile = function preloadFile (path$$1, buffer$$1) {\n\t var inode = this._index.getInode(path$$1);\n\t if (isFileInode(inode)) {\n\t if (inode === null) {\n\t throw ApiError.ENOENT(path$$1);\n\t }\n\t var stats = inode.getData();\n\t stats.size = buffer$$1.length;\n\t stats.fileData = buffer$$1;\n\t }\n\t else {\n\t throw ApiError.EISDIR(path$$1);\n\t }\n\t };\n\t XmlHttpRequest.prototype.stat = function stat (path$$1, isLstat, cb) {\n\t var inode = this._index.getInode(path$$1);\n\t if (inode === null) {\n\t return cb(ApiError.ENOENT(path$$1));\n\t }\n\t var stats;\n\t if (isFileInode(inode)) {\n\t stats = inode.getData();\n\t // At this point, a non-opened file will still have default stats from the listing.\n\t if (stats.size < 0) {\n\t this._requestFileSizeAsync(path$$1, function (e, size) {\n\t if (e) {\n\t return cb(e);\n\t }\n\t stats.size = size;\n\t cb(null, stats.clone());\n\t });\n\t }\n\t else {\n\t cb(null, stats.clone());\n\t }\n\t }\n\t else if (isDirInode(inode)) {\n\t stats = inode.getStats();\n\t cb(null, stats);\n\t }\n\t else {\n\t cb(ApiError.FileError(ErrorCode.EINVAL, path$$1));\n\t }\n\t };\n\t XmlHttpRequest.prototype.statSync = function statSync (path$$1, isLstat) {\n\t var inode = this._index.getInode(path$$1);\n\t if (inode === null) {\n\t throw ApiError.ENOENT(path$$1);\n\t }\n\t var stats;\n\t if (isFileInode(inode)) {\n\t stats = inode.getData();\n\t // At this point, a non-opened file will still have default stats from the listing.\n\t if (stats.size < 0) {\n\t stats.size = this._requestFileSizeSync(path$$1);\n\t }\n\t }\n\t else if (isDirInode(inode)) {\n\t stats = inode.getStats();\n\t }\n\t else {\n\t throw ApiError.FileError(ErrorCode.EINVAL, path$$1);\n\t }\n\t return stats;\n\t };\n\t XmlHttpRequest.prototype.open = function open (path$$1, flags, mode, cb) {\n\t // INVARIANT: You can't write to files on this file system.\n\t if (flags.isWriteable()) {\n\t return cb(new ApiError(ErrorCode.EPERM, path$$1));\n\t }\n\t var self = this;\n\t // Check if the path exists, and is a file.\n\t var inode = this._index.getInode(path$$1);\n\t if (inode === null) {\n\t return cb(ApiError.ENOENT(path$$1));\n\t }\n\t if (isFileInode(inode)) {\n\t var stats = inode.getData();\n\t switch (flags.pathExistsAction()) {\n\t case ActionType.THROW_EXCEPTION:\n\t case ActionType.TRUNCATE_FILE:\n\t return cb(ApiError.EEXIST(path$$1));\n\t case ActionType.NOP:\n\t // Use existing file contents.\n\t // XXX: Uh, this maintains the previously-used flag.\n\t if (stats.fileData) {\n\t return cb(null, new NoSyncFile(self, path$$1, flags, stats.clone(), stats.fileData));\n\t }\n\t // @todo be lazier about actually requesting the file\n\t this._requestFileAsync(path$$1, 'buffer', function (err, buffer$$1) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t // we don't initially have file sizes\n\t stats.size = buffer$$1.length;\n\t stats.fileData = buffer$$1;\n\t return cb(null, new NoSyncFile(self, path$$1, flags, stats.clone(), buffer$$1));\n\t });\n\t break;\n\t default:\n\t return cb(new ApiError(ErrorCode.EINVAL, 'Invalid FileMode object.'));\n\t }\n\t }\n\t else {\n\t return cb(ApiError.EISDIR(path$$1));\n\t }\n\t };\n\t XmlHttpRequest.prototype.openSync = function openSync (path$$1, flags, mode) {\n\t // INVARIANT: You can't write to files on this file system.\n\t if (flags.isWriteable()) {\n\t throw new ApiError(ErrorCode.EPERM, path$$1);\n\t }\n\t // Check if the path exists, and is a file.\n\t var inode = this._index.getInode(path$$1);\n\t if (inode === null) {\n\t throw ApiError.ENOENT(path$$1);\n\t }\n\t if (isFileInode(inode)) {\n\t var stats = inode.getData();\n\t switch (flags.pathExistsAction()) {\n\t case ActionType.THROW_EXCEPTION:\n\t case ActionType.TRUNCATE_FILE:\n\t throw ApiError.EEXIST(path$$1);\n\t case ActionType.NOP:\n\t // Use existing file contents.\n\t // XXX: Uh, this maintains the previously-used flag.\n\t if (stats.fileData) {\n\t return new NoSyncFile(this, path$$1, flags, stats.clone(), stats.fileData);\n\t }\n\t // @todo be lazier about actually requesting the file\n\t var buffer$$1 = this._requestFileSync(path$$1, 'buffer');\n\t // we don't initially have file sizes\n\t stats.size = buffer$$1.length;\n\t stats.fileData = buffer$$1;\n\t return new NoSyncFile(this, path$$1, flags, stats.clone(), buffer$$1);\n\t default:\n\t throw new ApiError(ErrorCode.EINVAL, 'Invalid FileMode object.');\n\t }\n\t }\n\t else {\n\t throw ApiError.EISDIR(path$$1);\n\t }\n\t };\n\t XmlHttpRequest.prototype.readdir = function readdir (path$$1, cb) {\n\t try {\n\t cb(null, this.readdirSync(path$$1));\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t XmlHttpRequest.prototype.readdirSync = function readdirSync (path$$1) {\n\t // Check if it exists.\n\t var inode = this._index.getInode(path$$1);\n\t if (inode === null) {\n\t throw ApiError.ENOENT(path$$1);\n\t }\n\t else if (isDirInode(inode)) {\n\t return inode.getListing();\n\t }\n\t else {\n\t throw ApiError.ENOTDIR(path$$1);\n\t }\n\t };\n\t /**\n\t * We have the entire file as a buffer; optimize readFile.\n\t */\n\t XmlHttpRequest.prototype.readFile = function readFile (fname, encoding, flag, cb) {\n\t // Wrap cb in file closing code.\n\t var oldCb = cb;\n\t // Get file.\n\t this.open(fname, flag, 0x1a4, function (err, fd) {\n\t if (err) {\n\t return cb(err);\n\t }\n\t cb = function (err, arg) {\n\t fd.close(function (err2) {\n\t if (!err) {\n\t err = err2;\n\t }\n\t return oldCb(err, arg);\n\t });\n\t };\n\t var fdCast = fd;\n\t var fdBuff = fdCast.getBuffer();\n\t if (encoding === null) {\n\t cb(err, copyingSlice(fdBuff));\n\t }\n\t else {\n\t tryToString(fdBuff, encoding, cb);\n\t }\n\t });\n\t };\n\t /**\n\t * Specially-optimized readfile.\n\t */\n\t XmlHttpRequest.prototype.readFileSync = function readFileSync (fname, encoding, flag) {\n\t // Get file.\n\t var fd = this.openSync(fname, flag, 0x1a4);\n\t try {\n\t var fdCast = fd;\n\t var fdBuff = fdCast.getBuffer();\n\t if (encoding === null) {\n\t return copyingSlice(fdBuff);\n\t }\n\t return fdBuff.toString(encoding);\n\t }\n\t finally {\n\t fd.closeSync();\n\t }\n\t };\n\t XmlHttpRequest.prototype.getXhrPath = function getXhrPath (filePath) {\n\t if (filePath.charAt(0) === '/') {\n\t filePath = filePath.slice(1);\n\t }\n\t return this.prefixUrl + filePath;\n\t };\n\t XmlHttpRequest.prototype._requestFileAsync = function _requestFileAsync (p, type, cb) {\n\t asyncDownloadFile(this.getXhrPath(p), type, cb);\n\t };\n\t XmlHttpRequest.prototype._requestFileSync = function _requestFileSync (p, type) {\n\t return syncDownloadFile(this.getXhrPath(p), type);\n\t };\n\t /**\n\t * Only requests the HEAD content, for the file size.\n\t */\n\t XmlHttpRequest.prototype._requestFileSizeAsync = function _requestFileSizeAsync (path$$1, cb) {\n\t getFileSizeAsync(this.getXhrPath(path$$1), cb);\n\t };\n\t XmlHttpRequest.prototype._requestFileSizeSync = function _requestFileSizeSync (path$$1) {\n\t return getFileSizeSync(this.getXhrPath(path$$1));\n\t };\n\t\n\t return XmlHttpRequest;\n\t}(BaseFileSystem));\n\t\n\tXmlHttpRequest.Name = \"XmlHttpRequest\";\n\tXmlHttpRequest.Options = {\n\t index: {\n\t type: [\"string\", \"object\"],\n\t optional: true,\n\t description: \"URL to a file index as a JSON file or the file index object itself, generated with the make_xhrfs_index script. Defaults to `index.json`.\"\n\t },\n\t baseUrl: {\n\t type: \"string\",\n\t optional: true,\n\t description: \"Used as the URL prefix for fetched files. Default: Fetch files relative to the index.\"\n\t }\n\t};\n\t\n\t/**\n\t * (Nonstandard) String utility function for 8-bit ASCII with the extended\n\t * character set. Unlike the ASCII above, we do not mask the high bits.\n\t *\n\t * Placed into a separate file so it can be used with other Buffer implementations.\n\t * @see http://en.wikipedia.org/wiki/Extended_ASCII\n\t */\n\t/**\n\t * (Nonstandard) String utility function for 8-bit ASCII with the extended\n\t * character set. Unlike the ASCII above, we do not mask the high bits.\n\t *\n\t * Placed into a separate file so it can be used with other Buffer implementations.\n\t * @see http://en.wikipedia.org/wiki/Extended_ASCII\n\t */ var ExtendedASCII = function ExtendedASCII () {};\n\t\n\t ExtendedASCII.str2byte = function str2byte (str, buf) {\n\t var length = str.length > buf.length ? buf.length : str.length;\n\t for (var i = 0; i < length; i++) {\n\t var charCode = str.charCodeAt(i);\n\t if (charCode > 0x7F) {\n\t // Check if extended ASCII.\n\t var charIdx = ExtendedASCII.extendedChars.indexOf(str.charAt(i));\n\t if (charIdx > -1) {\n\t charCode = charIdx + 0x80;\n\t }\n\t // Otherwise, keep it as-is.\n\t }\n\t buf[charCode] = i;\n\t }\n\t return length;\n\t};\n\tExtendedASCII.byte2str = function byte2str (buff) {\n\t var chars = new Array(buff.length);\n\t for (var i = 0; i < buff.length; i++) {\n\t var charCode = buff[i];\n\t if (charCode > 0x7F) {\n\t chars[i] = ExtendedASCII.extendedChars[charCode - 128];\n\t }\n\t else {\n\t chars[i] = String.fromCharCode(charCode);\n\t }\n\t }\n\t return chars.join('');\n\t};\n\tExtendedASCII.byteLength = function byteLength (str) { return str.length; };\n\t\n\t ExtendedASCII.extendedChars = ['\\u00C7', '\\u00FC', '\\u00E9', '\\u00E2', '\\u00E4',\n\t '\\u00E0', '\\u00E5', '\\u00E7', '\\u00EA', '\\u00EB', '\\u00E8', '\\u00EF',\n\t '\\u00EE', '\\u00EC', '\\u00C4', '\\u00C5', '\\u00C9', '\\u00E6', '\\u00C6',\n\t '\\u00F4', '\\u00F6', '\\u00F2', '\\u00FB', '\\u00F9', '\\u00FF', '\\u00D6',\n\t '\\u00DC', '\\u00F8', '\\u00A3', '\\u00D8', '\\u00D7', '\\u0192', '\\u00E1',\n\t '\\u00ED', '\\u00F3', '\\u00FA', '\\u00F1', '\\u00D1', '\\u00AA', '\\u00BA',\n\t '\\u00BF', '\\u00AE', '\\u00AC', '\\u00BD', '\\u00BC', '\\u00A1', '\\u00AB',\n\t '\\u00BB', '_', '_', '_', '\\u00A6', '\\u00A6', '\\u00C1', '\\u00C2', '\\u00C0',\n\t '\\u00A9', '\\u00A6', '\\u00A6', '+', '+', '\\u00A2', '\\u00A5', '+', '+', '-',\n\t '-', '+', '-', '+', '\\u00E3', '\\u00C3', '+', '+', '-', '-', '\\u00A6', '-',\n\t '+', '\\u00A4', '\\u00F0', '\\u00D0', '\\u00CA', '\\u00CB', '\\u00C8', 'i',\n\t '\\u00CD', '\\u00CE', '\\u00CF', '+', '+', '_', '_', '\\u00A6', '\\u00CC', '_',\n\t '\\u00D3', '\\u00DF', '\\u00D4', '\\u00D2', '\\u00F5', '\\u00D5', '\\u00B5',\n\t '\\u00FE', '\\u00DE', '\\u00DA', '\\u00DB', '\\u00D9', '\\u00FD', '\\u00DD',\n\t '\\u00AF', '\\u00B4', '\\u00AD', '\\u00B1', '_', '\\u00BE', '\\u00B6', '\\u00A7',\n\t '\\u00F7', '\\u00B8', '\\u00B0', '\\u00A8', '\\u00B7', '\\u00B9', '\\u00B3',\n\t '\\u00B2', '_', ' '];\n\t\n\t/**\n\t * @hidden\n\t */\n\tvar inflateRaw = __webpack_require__(31).inflateRaw;\n\t/**\n\t * Maps CompressionMethod => function that decompresses.\n\t * @hidden\n\t */\n\tvar decompressionMethods = {};\n\t/**\n\t * 4.4.2.2: Indicates the compatibiltiy of a file's external attributes.\n\t */\n\tvar ExternalFileAttributeType;\n\t(function (ExternalFileAttributeType) {\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"MSDOS\"] = 0] = \"MSDOS\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"AMIGA\"] = 1] = \"AMIGA\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"OPENVMS\"] = 2] = \"OPENVMS\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"UNIX\"] = 3] = \"UNIX\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"VM_CMS\"] = 4] = \"VM_CMS\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"ATARI_ST\"] = 5] = \"ATARI_ST\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"OS2_HPFS\"] = 6] = \"OS2_HPFS\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"MAC\"] = 7] = \"MAC\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"Z_SYSTEM\"] = 8] = \"Z_SYSTEM\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"CP_M\"] = 9] = \"CP_M\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"NTFS\"] = 10] = \"NTFS\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"MVS\"] = 11] = \"MVS\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"VSE\"] = 12] = \"VSE\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"ACORN_RISC\"] = 13] = \"ACORN_RISC\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"VFAT\"] = 14] = \"VFAT\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"ALT_MVS\"] = 15] = \"ALT_MVS\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"BEOS\"] = 16] = \"BEOS\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"TANDEM\"] = 17] = \"TANDEM\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"OS_400\"] = 18] = \"OS_400\";\n\t ExternalFileAttributeType[ExternalFileAttributeType[\"OSX\"] = 19] = \"OSX\";\n\t})(ExternalFileAttributeType || (ExternalFileAttributeType = {}));\n\t/**\n\t * 4.4.5\n\t */\n\tvar CompressionMethod;\n\t(function (CompressionMethod) {\n\t CompressionMethod[CompressionMethod[\"STORED\"] = 0] = \"STORED\";\n\t CompressionMethod[CompressionMethod[\"SHRUNK\"] = 1] = \"SHRUNK\";\n\t CompressionMethod[CompressionMethod[\"REDUCED_1\"] = 2] = \"REDUCED_1\";\n\t CompressionMethod[CompressionMethod[\"REDUCED_2\"] = 3] = \"REDUCED_2\";\n\t CompressionMethod[CompressionMethod[\"REDUCED_3\"] = 4] = \"REDUCED_3\";\n\t CompressionMethod[CompressionMethod[\"REDUCED_4\"] = 5] = \"REDUCED_4\";\n\t CompressionMethod[CompressionMethod[\"IMPLODE\"] = 6] = \"IMPLODE\";\n\t CompressionMethod[CompressionMethod[\"DEFLATE\"] = 8] = \"DEFLATE\";\n\t CompressionMethod[CompressionMethod[\"DEFLATE64\"] = 9] = \"DEFLATE64\";\n\t CompressionMethod[CompressionMethod[\"TERSE_OLD\"] = 10] = \"TERSE_OLD\";\n\t CompressionMethod[CompressionMethod[\"BZIP2\"] = 12] = \"BZIP2\";\n\t CompressionMethod[CompressionMethod[\"LZMA\"] = 14] = \"LZMA\";\n\t CompressionMethod[CompressionMethod[\"TERSE_NEW\"] = 18] = \"TERSE_NEW\";\n\t CompressionMethod[CompressionMethod[\"LZ77\"] = 19] = \"LZ77\";\n\t CompressionMethod[CompressionMethod[\"WAVPACK\"] = 97] = \"WAVPACK\";\n\t CompressionMethod[CompressionMethod[\"PPMD\"] = 98] = \"PPMD\"; // PPMd version I, Rev 1\n\t})(CompressionMethod || (CompressionMethod = {}));\n\t/**\n\t * Converts the input time and date in MS-DOS format into a JavaScript Date\n\t * object.\n\t * @hidden\n\t */\n\tfunction msdos2date(time, date) {\n\t // MS-DOS Date\n\t // |0 0 0 0 0|0 0 0 0|0 0 0 0 0 0 0\n\t // D (1-31) M (1-23) Y (from 1980)\n\t var day = date & 0x1F;\n\t // JS date is 0-indexed, DOS is 1-indexed.\n\t var month = ((date >> 5) & 0xF) - 1;\n\t var year = (date >> 9) + 1980;\n\t // MS DOS Time\n\t // |0 0 0 0 0|0 0 0 0 0 0|0 0 0 0 0\n\t // Second Minute Hour\n\t var second = time & 0x1F;\n\t var minute = (time >> 5) & 0x3F;\n\t var hour = time >> 11;\n\t return new Date(year, month, day, hour, minute, second);\n\t}\n\t/**\n\t * Safely returns the string from the buffer, even if it is 0 bytes long.\n\t * (Normally, calling toString() on a buffer with start === end causes an\n\t * exception).\n\t * @hidden\n\t */\n\tfunction safeToString(buff, useUTF8, start, length) {\n\t if (length === 0) {\n\t return \"\";\n\t }\n\t else if (useUTF8) {\n\t return buff.toString('utf8', start, start + length);\n\t }\n\t else {\n\t return ExtendedASCII.byte2str(buff.slice(start, start + length));\n\t }\n\t}\n\t/*\n\t 4.3.6 Overall .ZIP file format:\n\t\n\t [local file header 1]\n\t [encryption header 1]\n\t [file data 1]\n\t [data descriptor 1]\n\t .\n\t .\n\t .\n\t [local file header n]\n\t [encryption header n]\n\t [file data n]\n\t [data descriptor n]\n\t [archive decryption header]\n\t [archive extra data record]\n\t [central directory header 1]\n\t .\n\t .\n\t .\n\t [central directory header n]\n\t [zip64 end of central directory record]\n\t [zip64 end of central directory locator]\n\t [end of central directory record]\n\t*/\n\t/**\n\t * 4.3.7 Local file header:\n\t *\n\t * local file header signature 4 bytes (0x04034b50)\n\t * version needed to extract 2 bytes\n\t * general purpose bit flag 2 bytes\n\t * compression method 2 bytes\n\t * last mod file time 2 bytes\n\t * last mod file date 2 bytes\n\t * crc-32 4 bytes\n\t * compressed size 4 bytes\n\t * uncompressed size 4 bytes\n\t * file name length 2 bytes\n\t * extra field length 2 bytes\n\t *\n\t * file name (variable size)\n\t * extra field (variable size)\n\t */\n\tvar FileHeader = function FileHeader(data) {\n\t this.data = data;\n\t if (data.readUInt32LE(0) !== 0x04034b50) {\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid Zip file: Local file header has invalid signature: \" + this.data.readUInt32LE(0));\n\t }\n\t };\n\t FileHeader.prototype.versionNeeded = function versionNeeded () { return this.data.readUInt16LE(4); };\n\t FileHeader.prototype.flags = function flags () { return this.data.readUInt16LE(6); };\n\t FileHeader.prototype.compressionMethod = function compressionMethod () { return this.data.readUInt16LE(8); };\n\t FileHeader.prototype.lastModFileTime = function lastModFileTime () {\n\t // Time and date is in MS-DOS format.\n\t return msdos2date(this.data.readUInt16LE(10), this.data.readUInt16LE(12));\n\t };\n\t FileHeader.prototype.rawLastModFileTime = function rawLastModFileTime () {\n\t return this.data.readUInt32LE(10);\n\t };\n\t FileHeader.prototype.crc32 = function crc32 () { return this.data.readUInt32LE(14); };\n\t /**\n\t * These two values are COMPLETELY USELESS.\n\t *\n\t * Section 4.4.9:\n\t *If bit 3 of the general purpose bit flag is set,\n\t *these fields are set to zero in the local header and the\n\t *correct values are put in the data descriptor and\n\t *in the central directory.\n\t *\n\t * So we'll just use the central directory's values.\n\t */\n\t // public compressedSize(): number { return this.data.readUInt32LE(18); }\n\t // public uncompressedSize(): number { return this.data.readUInt32LE(22); }\n\t FileHeader.prototype.fileNameLength = function fileNameLength () { return this.data.readUInt16LE(26); };\n\t FileHeader.prototype.extraFieldLength = function extraFieldLength () { return this.data.readUInt16LE(28); };\n\t FileHeader.prototype.fileName = function fileName () {\n\t return safeToString(this.data, this.useUTF8(), 30, this.fileNameLength());\n\t };\n\t FileHeader.prototype.extraField = function extraField () {\n\t var start = 30 + this.fileNameLength();\n\t return this.data.slice(start, start + this.extraFieldLength());\n\t };\n\t FileHeader.prototype.totalSize = function totalSize () { return 30 + this.fileNameLength() + this.extraFieldLength(); };\n\t FileHeader.prototype.useUTF8 = function useUTF8 () { return (this.flags() & 0x800) === 0x800; };\n\t/**\n\t * 4.3.8 File data\n\t *\n\t * Immediately following the local header for a file\n\t * SHOULD be placed the compressed or stored data for the file.\n\t * If the file is encrypted, the encryption header for the file\n\t * SHOULD be placed after the local header and before the file\n\t * data. The series of [local file header][encryption header]\n\t * [file data][data descriptor] repeats for each file in the\n\t * .ZIP archive.\n\t *\n\t * Zero-byte files, directories, and other file types that\n\t * contain no content MUST not include file data.\n\t */\n\tvar FileData = function FileData(header, record, data) {\n\t this.header = header;\n\t this.record = record;\n\t this.data = data;\n\t };\n\t FileData.prototype.decompress = function decompress () {\n\t // Check the compression\n\t var compressionMethod = this.header.compressionMethod();\n\t var fcn = decompressionMethods[compressionMethod];\n\t if (fcn) {\n\t return fcn(this.data, this.record.compressedSize(), this.record.uncompressedSize(), this.record.flag());\n\t }\n\t else {\n\t var name = CompressionMethod[compressionMethod];\n\t if (!name) {\n\t name = \"Unknown: \" + compressionMethod;\n\t }\n\t throw new ApiError(ErrorCode.EINVAL, (\"Invalid compression method on file '\" + (this.header.fileName()) + \"': \" + name));\n\t }\n\t };\n\t FileData.prototype.getHeader = function getHeader () {\n\t return this.header;\n\t };\n\t FileData.prototype.getRecord = function getRecord () {\n\t return this.record;\n\t };\n\t FileData.prototype.getRawData = function getRawData () {\n\t return this.data;\n\t };\n\t/**\n\t * 4.3.9 Data descriptor:\n\t *\n\t * crc-32 4 bytes\n\t * compressed size 4 bytes\n\t * uncompressed size 4 bytes\n\t */\n\tvar DataDescriptor = function DataDescriptor(data) {\n\t this.data = data;\n\t };\n\t DataDescriptor.prototype.crc32 = function crc32 () { return this.data.readUInt32LE(0); };\n\t DataDescriptor.prototype.compressedSize = function compressedSize () { return this.data.readUInt32LE(4); };\n\t DataDescriptor.prototype.uncompressedSize = function uncompressedSize () { return this.data.readUInt32LE(8); };\n\t/*\n\t` 4.3.10 Archive decryption header:\n\t\n\t 4.3.10.1 The Archive Decryption Header is introduced in version 6.2\n\t of the ZIP format specification. This record exists in support\n\t of the Central Directory Encryption Feature implemented as part of\n\t the Strong Encryption Specification as described in this document.\n\t When the Central Directory Structure is encrypted, this decryption\n\t header MUST precede the encrypted data segment.\n\t */\n\t/**\n\t * 4.3.11 Archive extra data record:\n\t *\n\t * archive extra data signature 4 bytes (0x08064b50)\n\t * extra field length 4 bytes\n\t * extra field data (variable size)\n\t *\n\t * 4.3.11.1 The Archive Extra Data Record is introduced in version 6.2\n\t * of the ZIP format specification. This record MAY be used in support\n\t * of the Central Directory Encryption Feature implemented as part of\n\t * the Strong Encryption Specification as described in this document.\n\t * When present, this record MUST immediately precede the central\n\t * directory data structure.\n\t */\n\tvar ArchiveExtraDataRecord = function ArchiveExtraDataRecord(data) {\n\t this.data = data;\n\t if (this.data.readUInt32LE(0) !== 0x08064b50) {\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid archive extra data record signature: \" + this.data.readUInt32LE(0));\n\t }\n\t };\n\t ArchiveExtraDataRecord.prototype.length = function length () { return this.data.readUInt32LE(4); };\n\t ArchiveExtraDataRecord.prototype.extraFieldData = function extraFieldData () { return this.data.slice(8, 8 + this.length()); };\n\t/**\n\t * 4.3.13 Digital signature:\n\t *\n\t * header signature 4 bytes (0x05054b50)\n\t * size of data 2 bytes\n\t * signature data (variable size)\n\t *\n\t * With the introduction of the Central Directory Encryption\n\t * feature in version 6.2 of this specification, the Central\n\t * Directory Structure MAY be stored both compressed and encrypted.\n\t * Although not required, it is assumed when encrypting the\n\t * Central Directory Structure, that it will be compressed\n\t * for greater storage efficiency. Information on the\n\t * Central Directory Encryption feature can be found in the section\n\t * describing the Strong Encryption Specification. The Digital\n\t * Signature record will be neither compressed nor encrypted.\n\t */\n\tvar DigitalSignature = function DigitalSignature(data) {\n\t this.data = data;\n\t if (this.data.readUInt32LE(0) !== 0x05054b50) {\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid digital signature signature: \" + this.data.readUInt32LE(0));\n\t }\n\t };\n\t DigitalSignature.prototype.size = function size () { return this.data.readUInt16LE(4); };\n\t DigitalSignature.prototype.signatureData = function signatureData () { return this.data.slice(6, 6 + this.size()); };\n\t/**\n\t * 4.3.12 Central directory structure:\n\t *\n\t * central file header signature 4 bytes (0x02014b50)\n\t * version made by 2 bytes\n\t * version needed to extract 2 bytes\n\t * general purpose bit flag 2 bytes\n\t * compression method 2 bytes\n\t * last mod file time 2 bytes\n\t * last mod file date 2 bytes\n\t * crc-32 4 bytes\n\t * compressed size 4 bytes\n\t * uncompressed size 4 bytes\n\t * file name length 2 bytes\n\t * extra field length 2 bytes\n\t * file comment length 2 bytes\n\t * disk number start 2 bytes\n\t * internal file attributes 2 bytes\n\t * external file attributes 4 bytes\n\t * relative offset of local header 4 bytes\n\t *\n\t * file name (variable size)\n\t * extra field (variable size)\n\t * file comment (variable size)\n\t */\n\tvar CentralDirectory = function CentralDirectory(zipData, data) {\n\t this.zipData = zipData;\n\t this.data = data;\n\t // Sanity check.\n\t if (this.data.readUInt32LE(0) !== 0x02014b50) {\n\t throw new ApiError(ErrorCode.EINVAL, (\"Invalid Zip file: Central directory record has invalid signature: \" + (this.data.readUInt32LE(0))));\n\t }\n\t this._filename = this.produceFilename();\n\t };\n\t CentralDirectory.prototype.versionMadeBy = function versionMadeBy () { return this.data.readUInt16LE(4); };\n\t CentralDirectory.prototype.versionNeeded = function versionNeeded () { return this.data.readUInt16LE(6); };\n\t CentralDirectory.prototype.flag = function flag () { return this.data.readUInt16LE(8); };\n\t CentralDirectory.prototype.compressionMethod = function compressionMethod () { return this.data.readUInt16LE(10); };\n\t CentralDirectory.prototype.lastModFileTime = function lastModFileTime () {\n\t // Time and date is in MS-DOS format.\n\t return msdos2date(this.data.readUInt16LE(12), this.data.readUInt16LE(14));\n\t };\n\t CentralDirectory.prototype.rawLastModFileTime = function rawLastModFileTime () {\n\t return this.data.readUInt32LE(12);\n\t };\n\t CentralDirectory.prototype.crc32 = function crc32 () { return this.data.readUInt32LE(16); };\n\t CentralDirectory.prototype.compressedSize = function compressedSize () { return this.data.readUInt32LE(20); };\n\t CentralDirectory.prototype.uncompressedSize = function uncompressedSize () { return this.data.readUInt32LE(24); };\n\t CentralDirectory.prototype.fileNameLength = function fileNameLength () { return this.data.readUInt16LE(28); };\n\t CentralDirectory.prototype.extraFieldLength = function extraFieldLength () { return this.data.readUInt16LE(30); };\n\t CentralDirectory.prototype.fileCommentLength = function fileCommentLength () { return this.data.readUInt16LE(32); };\n\t CentralDirectory.prototype.diskNumberStart = function diskNumberStart () { return this.data.readUInt16LE(34); };\n\t CentralDirectory.prototype.internalAttributes = function internalAttributes () { return this.data.readUInt16LE(36); };\n\t CentralDirectory.prototype.externalAttributes = function externalAttributes () { return this.data.readUInt32LE(38); };\n\t CentralDirectory.prototype.headerRelativeOffset = function headerRelativeOffset () { return this.data.readUInt32LE(42); };\n\t CentralDirectory.prototype.produceFilename = function produceFilename () {\n\t /*\n\t 4.4.17.1 claims:\n\t * All slashes are forward ('/') slashes.\n\t * Filename doesn't begin with a slash.\n\t * No drive letters or any nonsense like that.\n\t * If filename is missing, the input came from standard input.\n\t \n\t Unfortunately, this isn't true in practice. Some Windows zip utilities use\n\t a backslash here, but the correct Unix-style path in file headers.\n\t \n\t To avoid seeking all over the file to recover the known-good filenames\n\t from file headers, we simply convert '/' to '\\' here.\n\t */\n\t var fileName = safeToString(this.data, this.useUTF8(), 46, this.fileNameLength());\n\t return fileName.replace(/\\\\/g, \"/\");\n\t };\n\t CentralDirectory.prototype.fileName = function fileName () {\n\t return this._filename;\n\t };\n\t CentralDirectory.prototype.rawFileName = function rawFileName () {\n\t return this.data.slice(46, 46 + this.fileNameLength());\n\t };\n\t CentralDirectory.prototype.extraField = function extraField () {\n\t var start = 44 + this.fileNameLength();\n\t return this.data.slice(start, start + this.extraFieldLength());\n\t };\n\t CentralDirectory.prototype.fileComment = function fileComment () {\n\t var start = 46 + this.fileNameLength() + this.extraFieldLength();\n\t return safeToString(this.data, this.useUTF8(), start, this.fileCommentLength());\n\t };\n\t CentralDirectory.prototype.rawFileComment = function rawFileComment () {\n\t var start = 46 + this.fileNameLength() + this.extraFieldLength();\n\t return this.data.slice(start, start + this.fileCommentLength());\n\t };\n\t CentralDirectory.prototype.totalSize = function totalSize () {\n\t return 46 + this.fileNameLength() + this.extraFieldLength() + this.fileCommentLength();\n\t };\n\t CentralDirectory.prototype.isDirectory = function isDirectory () {\n\t // NOTE: This assumes that the zip file implementation uses the lower byte\n\t // of external attributes for DOS attributes for\n\t // backwards-compatibility. This is not mandated, but appears to be\n\t // commonplace.\n\t // According to the spec, the layout of external attributes is\n\t // platform-dependent.\n\t // If that fails, we also check if the name of the file ends in '/',\n\t // which is what Java's ZipFile implementation does.\n\t var fileName = this.fileName();\n\t return (this.externalAttributes() & 0x10 ? true : false) || (fileName.charAt(fileName.length - 1) === '/');\n\t };\n\t CentralDirectory.prototype.isFile = function isFile () { return !this.isDirectory(); };\n\t CentralDirectory.prototype.useUTF8 = function useUTF8 () { return (this.flag() & 0x800) === 0x800; };\n\t CentralDirectory.prototype.isEncrypted = function isEncrypted () { return (this.flag() & 0x1) === 0x1; };\n\t CentralDirectory.prototype.getFileData = function getFileData () {\n\t // Need to grab the header before we can figure out where the actual\n\t // compressed data starts.\n\t var start = this.headerRelativeOffset();\n\t var header = new FileHeader(this.zipData.slice(start));\n\t return new FileData(header, this, this.zipData.slice(start + header.totalSize()));\n\t };\n\t CentralDirectory.prototype.getData = function getData () {\n\t return this.getFileData().decompress();\n\t };\n\t CentralDirectory.prototype.getRawData = function getRawData () {\n\t return this.getFileData().getRawData();\n\t };\n\t CentralDirectory.prototype.getStats = function getStats () {\n\t return new Stats(FileType.FILE, this.uncompressedSize(), 0x16D, new Date(), this.lastModFileTime());\n\t };\n\t/**\n\t * 4.3.16: end of central directory record\n\t * end of central dir signature 4 bytes (0x06054b50)\n\t * number of this disk 2 bytes\n\t * number of the disk with the\n\t * start of the central directory 2 bytes\n\t * total number of entries in the\n\t * central directory on this disk 2 bytes\n\t * total number of entries in\n\t * the central directory 2 bytes\n\t * size of the central directory 4 bytes\n\t * offset of start of central\n\t * directory with respect to\n\t * the starting disk number 4 bytes\n\t * .ZIP file comment length 2 bytes\n\t * .ZIP file comment (variable size)\n\t */\n\tvar EndOfCentralDirectory = function EndOfCentralDirectory(data) {\n\t this.data = data;\n\t if (this.data.readUInt32LE(0) !== 0x06054b50) {\n\t throw new ApiError(ErrorCode.EINVAL, (\"Invalid Zip file: End of central directory record has invalid signature: \" + (this.data.readUInt32LE(0))));\n\t }\n\t };\n\t EndOfCentralDirectory.prototype.diskNumber = function diskNumber () { return this.data.readUInt16LE(4); };\n\t EndOfCentralDirectory.prototype.cdDiskNumber = function cdDiskNumber () { return this.data.readUInt16LE(6); };\n\t EndOfCentralDirectory.prototype.cdDiskEntryCount = function cdDiskEntryCount () { return this.data.readUInt16LE(8); };\n\t EndOfCentralDirectory.prototype.cdTotalEntryCount = function cdTotalEntryCount () { return this.data.readUInt16LE(10); };\n\t EndOfCentralDirectory.prototype.cdSize = function cdSize () { return this.data.readUInt32LE(12); };\n\t EndOfCentralDirectory.prototype.cdOffset = function cdOffset () { return this.data.readUInt32LE(16); };\n\t EndOfCentralDirectory.prototype.cdZipCommentLength = function cdZipCommentLength () { return this.data.readUInt16LE(20); };\n\t EndOfCentralDirectory.prototype.cdZipComment = function cdZipComment () {\n\t // Assuming UTF-8. The specification doesn't specify.\n\t return safeToString(this.data, true, 22, this.cdZipCommentLength());\n\t };\n\t EndOfCentralDirectory.prototype.rawCdZipComment = function rawCdZipComment () {\n\t return this.data.slice(22, 22 + this.cdZipCommentLength());\n\t };\n\t/**\n\t * Contains the table of contents of a Zip file.\n\t */\n\tvar ZipTOC = function ZipTOC(index, directoryEntries, eocd, data) {\n\t this.index = index;\n\t this.directoryEntries = directoryEntries;\n\t this.eocd = eocd;\n\t this.data = data;\n\t };\n\t/**\n\t * Zip file-backed filesystem\n\t * Implemented according to the standard:\n\t * http://www.pkware.com/documents/casestudies/APPNOTE.TXT\n\t *\n\t * While there are a few zip libraries for JavaScript (e.g. JSZip and zip.js),\n\t * they are not a good match for BrowserFS. In particular, these libraries\n\t * perform a lot of unneeded data copying, and eagerly decompress every file\n\t * in the zip file upon loading to check the CRC32. They also eagerly decode\n\t * strings. Furthermore, these libraries duplicate functionality already present\n\t * in BrowserFS (e.g. UTF-8 decoding and binary data manipulation).\n\t *\n\t * This filesystem takes advantage of BrowserFS's Buffer implementation, which\n\t * efficiently represents the zip file in memory (in both ArrayBuffer-enabled\n\t * browsers *and* non-ArrayBuffer browsers), and which can neatly be 'sliced'\n\t * without copying data. Each struct defined in the standard is represented with\n\t * a buffer slice pointing to an offset in the zip file, and has getters for\n\t * each field. As we anticipate that this data will not be read often, we choose\n\t * not to store each struct field in the JavaScript object; instead, to reduce\n\t * memory consumption, we retrieve it directly from the binary data each time it\n\t * is requested.\n\t *\n\t * When the filesystem is instantiated, we determine the directory structure\n\t * of the zip file as quickly as possible. We lazily decompress and check the\n\t * CRC32 of files. We do not cache decompressed files; if this is a desired\n\t * feature, it is best implemented as a generic file system wrapper that can\n\t * cache data from arbitrary file systems.\n\t *\n\t * For inflation, we use `pako`'s implementation:\n\t * https://github.com/nodeca/pako\n\t *\n\t * Current limitations:\n\t * * No encryption.\n\t * * No ZIP64 support.\n\t * * Read-only.\n\t * Write support would require that we:\n\t * - Keep track of changed/new files.\n\t * - Compress changed files, and generate appropriate metadata for each.\n\t * - Update file offsets for other files in the zip file.\n\t * - Stream it out to a location.\n\t * This isn't that bad, so we might do this at a later date.\n\t */\n\tvar ZipFS = (function (SynchronousFileSystem$$1) {\n\t function ZipFS(input, name, deprecateMsg) {\n\t if ( name === void 0 ) name = '';\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t SynchronousFileSystem$$1.call(this);\n\t this.name = name;\n\t this._index = new FileIndex();\n\t this._directoryEntries = [];\n\t this._eocd = null;\n\t deprecationMessage(deprecateMsg, ZipFS.Name, { zipData: \"zip data as a Buffer\", name: name });\n\t if (input instanceof ZipTOC) {\n\t this._index = input.index;\n\t this._directoryEntries = input.directoryEntries;\n\t this._eocd = input.eocd;\n\t this.data = input.data;\n\t }\n\t else {\n\t this.data = input;\n\t this.populateIndex();\n\t }\n\t }\n\t\n\t if ( SynchronousFileSystem$$1 ) ZipFS.__proto__ = SynchronousFileSystem$$1;\n\t ZipFS.prototype = Object.create( SynchronousFileSystem$$1 && SynchronousFileSystem$$1.prototype );\n\t ZipFS.prototype.constructor = ZipFS;\n\t /**\n\t * Constructs a ZipFS instance with the given options.\n\t */\n\t ZipFS.Create = function Create (opts, cb) {\n\t try {\n\t ZipFS.computeIndex(opts.zipData, function (zipTOC) {\n\t var fs = new ZipFS(zipTOC, opts.name, false);\n\t cb(null, fs);\n\t }, false);\n\t }\n\t catch (e) {\n\t cb(e);\n\t }\n\t };\n\t ZipFS.isAvailable = function isAvailable () { return true; };\n\t ZipFS.RegisterDecompressionMethod = function RegisterDecompressionMethod (m, fcn) {\n\t decompressionMethods[m] = fcn;\n\t };\n\t /**\n\t * **Deprecated. Please use ZipFS.Create() method instead.**\n\t */\n\t ZipFS.computeIndex = function computeIndex (data, cb, deprecateMsg) {\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t // TODO: Refactor to plumb errors through. Right now, they throw.\n\t if (deprecateMsg) {\n\t console.warn(\"[ZipFS] ZipFS.computeIndex is now deprecated, and will be removed in the next major release. Please update your code to use 'ZipFS.Create({ zipData: zip file as a Buffer}, cb)' instead.\");\n\t }\n\t var index = new FileIndex();\n\t var eocd = ZipFS.getEOCD(data);\n\t if (eocd.diskNumber() !== eocd.cdDiskNumber()) {\n\t throw new ApiError(ErrorCode.EINVAL, \"ZipFS does not support spanned zip files.\");\n\t }\n\t var cdPtr = eocd.cdOffset();\n\t if (cdPtr === 0xFFFFFFFF) {\n\t throw new ApiError(ErrorCode.EINVAL, \"ZipFS does not support Zip64.\");\n\t }\n\t var cdEnd = cdPtr + eocd.cdSize();\n\t ZipFS.computeIndexResponsive(data, index, cdPtr, cdEnd, cb, [], eocd);\n\t };\n\t /**\n\t * Locates the end of central directory record at the end of the file.\n\t * Throws an exception if it cannot be found.\n\t */\n\t ZipFS.getEOCD = function getEOCD (data) {\n\t // Unfortunately, the comment is variable size and up to 64K in size.\n\t // We assume that the magic signature does not appear in the comment, and\n\t // in the bytes between the comment and the signature. Other ZIP\n\t // implementations make this same assumption, since the alternative is to\n\t // read thread every entry in the file to get to it. :(\n\t // These are *negative* offsets from the end of the file.\n\t var startOffset = 22;\n\t var endOffset = Math.min(startOffset + 0xFFFF, data.length - 1);\n\t // There's not even a byte alignment guarantee on the comment so we need to\n\t // search byte by byte. *grumble grumble*\n\t for (var i = startOffset; i < endOffset; i++) {\n\t // Magic number: EOCD Signature\n\t if (data.readUInt32LE(data.length - i) === 0x06054b50) {\n\t return new EndOfCentralDirectory(data.slice(data.length - i));\n\t }\n\t }\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid ZIP file: Could not locate End of Central Directory signature.\");\n\t };\n\t ZipFS.addToIndex = function addToIndex (cd, index) {\n\t // Paths must be absolute, yet zip file paths are always relative to the\n\t // zip root. So we append '/' and call it a day.\n\t var filename = cd.fileName();\n\t if (filename.charAt(0) === '/') {\n\t throw new Error(\"WHY IS THIS ABSOLUTE\");\n\t }\n\t // XXX: For the file index, strip the trailing '/'.\n\t if (filename.charAt(filename.length - 1) === '/') {\n\t filename = filename.substr(0, filename.length - 1);\n\t }\n\t if (cd.isDirectory()) {\n\t index.addPathFast('/' + filename, new DirInode(cd));\n\t }\n\t else {\n\t index.addPathFast('/' + filename, new FileInode(cd));\n\t }\n\t };\n\t ZipFS.computeIndexResponsive = function computeIndexResponsive (data, index, cdPtr, cdEnd, cb, cdEntries, eocd) {\n\t if (cdPtr < cdEnd) {\n\t var count = 0;\n\t while (count++ < 200 && cdPtr < cdEnd) {\n\t var cd = new CentralDirectory(data, data.slice(cdPtr));\n\t ZipFS.addToIndex(cd, index);\n\t cdPtr += cd.totalSize();\n\t cdEntries.push(cd);\n\t }\n\t setImmediate$3(function () {\n\t ZipFS.computeIndexResponsive(data, index, cdPtr, cdEnd, cb, cdEntries, eocd);\n\t });\n\t }\n\t else {\n\t cb(new ZipTOC(index, cdEntries, eocd, data));\n\t }\n\t };\n\t ZipFS.prototype.getName = function getName () {\n\t return ZipFS.Name + (this.name !== '' ? (\" \" + (this.name)) : '');\n\t };\n\t /**\n\t * Get the CentralDirectory object for the given path.\n\t */\n\t ZipFS.prototype.getCentralDirectoryEntry = function getCentralDirectoryEntry (path$$1) {\n\t var inode = this._index.getInode(path$$1);\n\t if (inode === null) {\n\t throw ApiError.ENOENT(path$$1);\n\t }\n\t if (isFileInode(inode)) {\n\t return inode.getData();\n\t }\n\t else if (isDirInode(inode)) {\n\t return inode.getData();\n\t }\n\t else {\n\t // Should never occur.\n\t throw ApiError.EPERM((\"Invalid inode: \" + inode));\n\t }\n\t };\n\t ZipFS.prototype.getCentralDirectoryEntryAt = function getCentralDirectoryEntryAt (index) {\n\t var dirEntry = this._directoryEntries[index];\n\t if (!dirEntry) {\n\t throw new RangeError((\"Invalid directory index: \" + index + \".\"));\n\t }\n\t return dirEntry;\n\t };\n\t ZipFS.prototype.getNumberOfCentralDirectoryEntries = function getNumberOfCentralDirectoryEntries () {\n\t return this._directoryEntries.length;\n\t };\n\t ZipFS.prototype.getEndOfCentralDirectory = function getEndOfCentralDirectory () {\n\t return this._eocd;\n\t };\n\t ZipFS.prototype.diskSpace = function diskSpace (path$$1, cb) {\n\t // Read-only file system.\n\t cb(this.data.length, 0);\n\t };\n\t ZipFS.prototype.isReadOnly = function isReadOnly () {\n\t return true;\n\t };\n\t ZipFS.prototype.supportsLinks = function supportsLinks () {\n\t return false;\n\t };\n\t ZipFS.prototype.supportsProps = function supportsProps () {\n\t return false;\n\t };\n\t ZipFS.prototype.supportsSynch = function supportsSynch () {\n\t return true;\n\t };\n\t ZipFS.prototype.statSync = function statSync (path$$1, isLstat) {\n\t var inode = this._index.getInode(path$$1);\n\t if (inode === null) {\n\t throw ApiError.ENOENT(path$$1);\n\t }\n\t var stats;\n\t if (isFileInode(inode)) {\n\t stats = inode.getData().getStats();\n\t }\n\t else if (isDirInode(inode)) {\n\t stats = inode.getStats();\n\t }\n\t else {\n\t throw new ApiError(ErrorCode.EINVAL, \"Invalid inode.\");\n\t }\n\t return stats;\n\t };\n\t ZipFS.prototype.openSync = function openSync (path$$1, flags, mode) {\n\t // INVARIANT: Cannot write to RO file systems.\n\t if (flags.isWriteable()) {\n\t throw new ApiError(ErrorCode.EPERM, path$$1);\n\t }\n\t // Check if the path exists, and is a file.\n\t var inode = this._index.getInode(path$$1);\n\t if (!inode) {\n\t throw ApiError.ENOENT(path$$1);\n\t }\n\t else if (isFileInode(inode)) {\n\t var cdRecord = inode.getData();\n\t var stats = cdRecord.getStats();\n\t switch (flags.pathExistsAction()) {\n\t case ActionType.THROW_EXCEPTION:\n\t case ActionType.TRUNCATE_FILE:\n\t throw ApiError.EEXIST(path$$1);\n\t case ActionType.NOP:\n\t return new NoSyncFile(this, path$$1, flags, stats, cdRecord.getData());\n\t default:\n\t throw new ApiError(ErrorCode.EINVAL, 'Invalid FileMode object.');\n\t }\n\t }\n\t else {\n\t throw ApiError.EISDIR(path$$1);\n\t }\n\t };\n\t ZipFS.prototype.readdirSync = function readdirSync (path$$1) {\n\t // Check if it exists.\n\t var inode = this._index.getInode(path$$1);\n\t if (!inode) {\n\t throw ApiError.ENOENT(path$$1);\n\t }\n\t else if (isDirInode(inode)) {\n\t return inode.getListing();\n\t }\n\t else {\n\t throw ApiError.ENOTDIR(path$$1);\n\t }\n\t };\n\t /**\n\t * Specially-optimized readfile.\n\t */\n\t ZipFS.prototype.readFileSync = function readFileSync (fname, encoding, flag) {\n\t // Get file.\n\t var fd = this.openSync(fname, flag, 0x1a4);\n\t try {\n\t var fdCast = fd;\n\t var fdBuff = fdCast.getBuffer();\n\t if (encoding === null) {\n\t return copyingSlice(fdBuff);\n\t }\n\t return fdBuff.toString(encoding);\n\t }\n\t finally {\n\t fd.closeSync();\n\t }\n\t };\n\t ZipFS.prototype.populateIndex = function populateIndex () {\n\t var this$1 = this;\n\t\n\t var eocd = this._eocd = ZipFS.getEOCD(this.data);\n\t if (eocd.diskNumber() !== eocd.cdDiskNumber()) {\n\t throw new ApiError(ErrorCode.EINVAL, \"ZipFS does not support spanned zip files.\");\n\t }\n\t var cdPtr = eocd.cdOffset();\n\t if (cdPtr === 0xFFFFFFFF) {\n\t throw new ApiError(ErrorCode.EINVAL, \"ZipFS does not support Zip64.\");\n\t }\n\t var cdEnd = cdPtr + eocd.cdSize();\n\t while (cdPtr < cdEnd) {\n\t var cd = new CentralDirectory(this$1.data, this$1.data.slice(cdPtr));\n\t cdPtr += cd.totalSize();\n\t ZipFS.addToIndex(cd, this$1._index);\n\t this$1._directoryEntries.push(cd);\n\t }\n\t };\n\t\n\t return ZipFS;\n\t}(SynchronousFileSystem));\n\t\n\tZipFS.Name = \"ZipFS\";\n\tZipFS.Options = {\n\t zipData: {\n\t type: \"object\",\n\t description: \"The zip file as a Buffer object.\",\n\t validator: bufferValidator\n\t },\n\t name: {\n\t type: \"string\",\n\t optional: true,\n\t description: \"The name of the zip file (optional).\"\n\t }\n\t};\n\tZipFS.CompressionMethod = CompressionMethod;\n\tZipFS.RegisterDecompressionMethod(CompressionMethod.DEFLATE, function (data, compressedSize, uncompressedSize) {\n\t return arrayish2Buffer(inflateRaw(data.slice(0, compressedSize), { chunkSize: uncompressedSize }));\n\t});\n\tZipFS.RegisterDecompressionMethod(CompressionMethod.STORED, function (data, compressedSize, uncompressedSize) {\n\t return copyingSlice(data, 0, uncompressedSize);\n\t});\n\t\n\t/**\n\t * @hidden\n\t */\n\tvar rockRidgeIdentifier = \"IEEE_P1282\";\n\t/**\n\t * @hidden\n\t */\n\tfunction getASCIIString(data, startIndex, length) {\n\t return data.toString('ascii', startIndex, startIndex + length).trim();\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction getJolietString(data, startIndex, length) {\n\t if (length === 1) {\n\t // Special: Root, parent, current directory are still a single byte.\n\t return String.fromCharCode(data[startIndex]);\n\t }\n\t // UTF16-BE, which isn't natively supported by NodeJS Buffers.\n\t // Length should be even, but pessimistically floor just in case.\n\t var pairs = Math.floor(length / 2);\n\t var chars = new Array(pairs);\n\t for (var i = 0; i < pairs; i++) {\n\t var pos = startIndex + (i << 1);\n\t chars[i] = String.fromCharCode(data[pos + 1] | (data[pos] << 8));\n\t }\n\t return chars.join('');\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction getDate(data, startIndex) {\n\t var year = parseInt(getASCIIString(data, startIndex, 4), 10);\n\t var mon = parseInt(getASCIIString(data, startIndex + 4, 2), 10);\n\t var day = parseInt(getASCIIString(data, startIndex + 6, 2), 10);\n\t var hour = parseInt(getASCIIString(data, startIndex + 8, 2), 10);\n\t var min = parseInt(getASCIIString(data, startIndex + 10, 2), 10);\n\t var sec = parseInt(getASCIIString(data, startIndex + 12, 2), 10);\n\t var hundrethsSec = parseInt(getASCIIString(data, startIndex + 14, 2), 10);\n\t // Last is a time-zone offset, but JavaScript dates don't support time zones well.\n\t return new Date(year, mon, day, hour, min, sec, hundrethsSec * 100);\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction getShortFormDate(data, startIndex) {\n\t var yearsSince1900 = data[startIndex];\n\t var month = data[startIndex + 1];\n\t var day = data[startIndex + 2];\n\t var hour = data[startIndex + 3];\n\t var minute = data[startIndex + 4];\n\t var second = data[startIndex + 5];\n\t // JavaScript's Date support isn't so great; ignore timezone.\n\t // const offsetFromGMT = this._data[24];\n\t return new Date(yearsSince1900, month - 1, day, hour, minute, second);\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction constructSystemUseEntry(bigData, i) {\n\t var data = bigData.slice(i);\n\t var sue = new SystemUseEntry(data);\n\t switch (sue.signatureWord()) {\n\t case 17221 /* CE */:\n\t return new CEEntry(data);\n\t case 20548 /* PD */:\n\t return new PDEntry(data);\n\t case 21328 /* SP */:\n\t return new SPEntry(data);\n\t case 21332 /* ST */:\n\t return new STEntry(data);\n\t case 17746 /* ER */:\n\t return new EREntry(data);\n\t case 17747 /* ES */:\n\t return new ESEntry(data);\n\t case 20568 /* PX */:\n\t return new PXEntry(data);\n\t case 20558 /* PN */:\n\t return new PNEntry(data);\n\t case 21324 /* SL */:\n\t return new SLEntry(data);\n\t case 20045 /* NM */:\n\t return new NMEntry(data);\n\t case 17228 /* CL */:\n\t return new CLEntry(data);\n\t case 20556 /* PL */:\n\t return new PLEntry(data);\n\t case 21061 /* RE */:\n\t return new REEntry(data);\n\t case 21574 /* TF */:\n\t return new TFEntry(data);\n\t case 21318 /* SF */:\n\t return new SFEntry(data);\n\t case 21074 /* RR */:\n\t return new RREntry(data);\n\t default:\n\t return sue;\n\t }\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction constructSystemUseEntries(data, i, len, isoData) {\n\t // If the remaining allocated space following the last recorded System Use Entry in a System\n\t // Use field or Continuation Area is less than four bytes long, it cannot contain a System\n\t // Use Entry and shall be ignored\n\t len = len - 4;\n\t var entries = new Array();\n\t while (i < len) {\n\t var entry = constructSystemUseEntry(data, i);\n\t var length = entry.length();\n\t if (length === 0) {\n\t // Invalid SU section; prevent infinite loop.\n\t return entries;\n\t }\n\t i += length;\n\t if (entry instanceof STEntry) {\n\t // ST indicates the end of entries.\n\t break;\n\t }\n\t if (entry instanceof CEEntry) {\n\t entries = entries.concat(entry.getEntries(isoData));\n\t }\n\t else {\n\t entries.push(entry);\n\t }\n\t }\n\t return entries;\n\t}\n\t/**\n\t * @hidden\n\t */\n\tvar VolumeDescriptor = function VolumeDescriptor(data) {\n\t this._data = data;\n\t};\n\tVolumeDescriptor.prototype.type = function type () {\n\t return this._data[0];\n\t};\n\tVolumeDescriptor.prototype.standardIdentifier = function standardIdentifier () {\n\t return getASCIIString(this._data, 1, 5);\n\t};\n\tVolumeDescriptor.prototype.version = function version () {\n\t return this._data[6];\n\t};\n\tVolumeDescriptor.prototype.data = function data () {\n\t return this._data.slice(7, 2048);\n\t};\n\t/**\n\t * @hidden\n\t */\n\tvar PrimaryOrSupplementaryVolumeDescriptor = (function (VolumeDescriptor) {\n\t function PrimaryOrSupplementaryVolumeDescriptor(data) {\n\t VolumeDescriptor.call(this, data);\n\t this._root = null;\n\t }\n\t\n\t if ( VolumeDescriptor ) PrimaryOrSupplementaryVolumeDescriptor.__proto__ = VolumeDescriptor;\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype = Object.create( VolumeDescriptor && VolumeDescriptor.prototype );\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.constructor = PrimaryOrSupplementaryVolumeDescriptor;\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.systemIdentifier = function systemIdentifier () {\n\t return this._getString32(8);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeIdentifier = function volumeIdentifier () {\n\t return this._getString32(40);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeSpaceSize = function volumeSpaceSize () {\n\t return this._data.readUInt32LE(80);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeSetSize = function volumeSetSize () {\n\t return this._data.readUInt16LE(120);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeSequenceNumber = function volumeSequenceNumber () {\n\t return this._data.readUInt16LE(124);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.logicalBlockSize = function logicalBlockSize () {\n\t return this._data.readUInt16LE(128);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.pathTableSize = function pathTableSize () {\n\t return this._data.readUInt32LE(132);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.locationOfTypeLPathTable = function locationOfTypeLPathTable () {\n\t return this._data.readUInt32LE(140);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.locationOfOptionalTypeLPathTable = function locationOfOptionalTypeLPathTable () {\n\t return this._data.readUInt32LE(144);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.locationOfTypeMPathTable = function locationOfTypeMPathTable () {\n\t return this._data.readUInt32BE(148);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.locationOfOptionalTypeMPathTable = function locationOfOptionalTypeMPathTable () {\n\t return this._data.readUInt32BE(152);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.rootDirectoryEntry = function rootDirectoryEntry (isoData) {\n\t if (this._root === null) {\n\t this._root = this._constructRootDirectoryRecord(this._data.slice(156));\n\t this._root.rootCheckForRockRidge(isoData);\n\t }\n\t return this._root;\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeSetIdentifier = function volumeSetIdentifier () {\n\t return this._getString(190, 128);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.publisherIdentifier = function publisherIdentifier () {\n\t return this._getString(318, 128);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.dataPreparerIdentifier = function dataPreparerIdentifier () {\n\t return this._getString(446, 128);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.applicationIdentifier = function applicationIdentifier () {\n\t return this._getString(574, 128);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.copyrightFileIdentifier = function copyrightFileIdentifier () {\n\t return this._getString(702, 38);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.abstractFileIdentifier = function abstractFileIdentifier () {\n\t return this._getString(740, 36);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.bibliographicFileIdentifier = function bibliographicFileIdentifier () {\n\t return this._getString(776, 37);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeCreationDate = function volumeCreationDate () {\n\t return getDate(this._data, 813);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeModificationDate = function volumeModificationDate () {\n\t return getDate(this._data, 830);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeExpirationDate = function volumeExpirationDate () {\n\t return getDate(this._data, 847);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.volumeEffectiveDate = function volumeEffectiveDate () {\n\t return getDate(this._data, 864);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.fileStructureVersion = function fileStructureVersion () {\n\t return this._data[881];\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.applicationUsed = function applicationUsed () {\n\t return this._data.slice(883, 883 + 512);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype.reserved = function reserved () {\n\t return this._data.slice(1395, 1395 + 653);\n\t };\n\t PrimaryOrSupplementaryVolumeDescriptor.prototype._getString32 = function _getString32 (idx) {\n\t return this._getString(idx, 32);\n\t };\n\t\n\t return PrimaryOrSupplementaryVolumeDescriptor;\n\t}(VolumeDescriptor));\n\t/**\n\t * @hidden\n\t */\n\tvar PrimaryVolumeDescriptor = (function (PrimaryOrSupplementaryVolumeDescriptor) {\n\t function PrimaryVolumeDescriptor(data) {\n\t PrimaryOrSupplementaryVolumeDescriptor.call(this, data);\n\t if (this.type() !== 1 /* PrimaryVolumeDescriptor */) {\n\t throw new ApiError(ErrorCode.EIO, \"Invalid primary volume descriptor.\");\n\t }\n\t }\n\t\n\t if ( PrimaryOrSupplementaryVolumeDescriptor ) PrimaryVolumeDescriptor.__proto__ = PrimaryOrSupplementaryVolumeDescriptor;\n\t PrimaryVolumeDescriptor.prototype = Object.create( PrimaryOrSupplementaryVolumeDescriptor && PrimaryOrSupplementaryVolumeDescriptor.prototype );\n\t PrimaryVolumeDescriptor.prototype.constructor = PrimaryVolumeDescriptor;\n\t PrimaryVolumeDescriptor.prototype.name = function name () {\n\t return \"ISO9660\";\n\t };\n\t PrimaryVolumeDescriptor.prototype._constructRootDirectoryRecord = function _constructRootDirectoryRecord (data) {\n\t return new ISODirectoryRecord(data, -1);\n\t };\n\t PrimaryVolumeDescriptor.prototype._getString = function _getString (idx, len) {\n\t return this._getString(idx, len);\n\t };\n\t\n\t return PrimaryVolumeDescriptor;\n\t}(PrimaryOrSupplementaryVolumeDescriptor));\n\t/**\n\t * @hidden\n\t */\n\tvar SupplementaryVolumeDescriptor = (function (PrimaryOrSupplementaryVolumeDescriptor) {\n\t function SupplementaryVolumeDescriptor(data) {\n\t PrimaryOrSupplementaryVolumeDescriptor.call(this, data);\n\t if (this.type() !== 2 /* SupplementaryVolumeDescriptor */) {\n\t throw new ApiError(ErrorCode.EIO, \"Invalid supplementary volume descriptor.\");\n\t }\n\t var escapeSequence = this.escapeSequence();\n\t var third = escapeSequence[2];\n\t // Third character identifies what 'level' of the UCS specification to follow.\n\t // We ignore it.\n\t if (escapeSequence[0] !== 0x25 || escapeSequence[1] !== 0x2F ||\n\t (third !== 0x40 && third !== 0x43 && third !== 0x45)) {\n\t throw new ApiError(ErrorCode.EIO, (\"Unrecognized escape sequence for SupplementaryVolumeDescriptor: \" + (escapeSequence.toString())));\n\t }\n\t }\n\t\n\t if ( PrimaryOrSupplementaryVolumeDescriptor ) SupplementaryVolumeDescriptor.__proto__ = PrimaryOrSupplementaryVolumeDescriptor;\n\t SupplementaryVolumeDescriptor.prototype = Object.create( PrimaryOrSupplementaryVolumeDescriptor && PrimaryOrSupplementaryVolumeDescriptor.prototype );\n\t SupplementaryVolumeDescriptor.prototype.constructor = SupplementaryVolumeDescriptor;\n\t SupplementaryVolumeDescriptor.prototype.name = function name () {\n\t return \"Joliet\";\n\t };\n\t SupplementaryVolumeDescriptor.prototype.escapeSequence = function escapeSequence () {\n\t return this._data.slice(88, 120);\n\t };\n\t SupplementaryVolumeDescriptor.prototype._constructRootDirectoryRecord = function _constructRootDirectoryRecord (data) {\n\t return new JolietDirectoryRecord(data, -1);\n\t };\n\t SupplementaryVolumeDescriptor.prototype._getString = function _getString (idx, len) {\n\t return getJolietString(this._data, idx, len);\n\t };\n\t\n\t return SupplementaryVolumeDescriptor;\n\t}(PrimaryOrSupplementaryVolumeDescriptor));\n\t/**\n\t * @hidden\n\t */\n\tvar DirectoryRecord = function DirectoryRecord(data, rockRidgeOffset) {\n\t this._suEntries = null;\n\t this._fileOrDir = null;\n\t this._data = data;\n\t this._rockRidgeOffset = rockRidgeOffset;\n\t};\n\tDirectoryRecord.prototype.hasRockRidge = function hasRockRidge () {\n\t return this._rockRidgeOffset > -1;\n\t};\n\tDirectoryRecord.prototype.getRockRidgeOffset = function getRockRidgeOffset () {\n\t return this._rockRidgeOffset;\n\t};\n\t/**\n\t * !!ONLY VALID ON ROOT NODE!!\n\t * Checks if Rock Ridge is enabled, and sets the offset.\n\t */\n\tDirectoryRecord.prototype.rootCheckForRockRidge = function rootCheckForRockRidge (isoData) {\n\t var dir = this.getDirectory(isoData);\n\t this._rockRidgeOffset = dir.getDotEntry(isoData)._getRockRidgeOffset(isoData);\n\t if (this._rockRidgeOffset > -1) {\n\t // Wipe out directory. Start over with RR knowledge.\n\t this._fileOrDir = null;\n\t }\n\t};\n\tDirectoryRecord.prototype.length = function length () {\n\t return this._data[0];\n\t};\n\tDirectoryRecord.prototype.extendedAttributeRecordLength = function extendedAttributeRecordLength () {\n\t return this._data[1];\n\t};\n\tDirectoryRecord.prototype.lba = function lba () {\n\t return this._data.readUInt32LE(2) * 2048;\n\t};\n\tDirectoryRecord.prototype.dataLength = function dataLength () {\n\t return this._data.readUInt32LE(10);\n\t};\n\tDirectoryRecord.prototype.recordingDate = function recordingDate () {\n\t return getShortFormDate(this._data, 18);\n\t};\n\tDirectoryRecord.prototype.fileFlags = function fileFlags () {\n\t return this._data[25];\n\t};\n\tDirectoryRecord.prototype.fileUnitSize = function fileUnitSize () {\n\t return this._data[26];\n\t};\n\tDirectoryRecord.prototype.interleaveGapSize = function interleaveGapSize () {\n\t return this._data[27];\n\t};\n\tDirectoryRecord.prototype.volumeSequenceNumber = function volumeSequenceNumber () {\n\t return this._data.readUInt16LE(28);\n\t};\n\tDirectoryRecord.prototype.identifier = function identifier () {\n\t return this._getString(33, this._data[32]);\n\t};\n\tDirectoryRecord.prototype.fileName = function fileName (isoData) {\n\t if (this.hasRockRidge()) {\n\t var fn = this._rockRidgeFilename(isoData);\n\t if (fn !== null) {\n\t return fn;\n\t }\n\t }\n\t var ident = this.identifier();\n\t if (this.isDirectory(isoData)) {\n\t return ident;\n\t }\n\t // Files:\n\t // - MUST have 0x2E (.) separating the name from the extension\n\t // - MUST have 0x3B (;) separating the file name and extension from the version\n\t // Gets expanded to two-byte char in Unicode directory records.\n\t var versionSeparator = ident.indexOf(';');\n\t if (versionSeparator === -1) {\n\t // Some Joliet filenames lack the version separator, despite the standard\n\t // specifying that it should be there.\n\t return ident;\n\t }\n\t else if (ident[versionSeparator - 1] === '.') {\n\t // Empty extension. Do not include '.' in the filename.\n\t return ident.slice(0, versionSeparator - 1);\n\t }\n\t else {\n\t // Include up to version separator.\n\t return ident.slice(0, versionSeparator);\n\t }\n\t};\n\tDirectoryRecord.prototype.isDirectory = function isDirectory (isoData) {\n\t var rv = !!(this.fileFlags() & 2 /* Directory */);\n\t // If it lacks the Directory flag, it may still be a directory if we've exceeded the directory\n\t // depth limit. Rock Ridge marks these as files and adds a special attribute.\n\t if (!rv && this.hasRockRidge()) {\n\t rv = this.getSUEntries(isoData).filter(function (e) { return e instanceof CLEntry; }).length > 0;\n\t }\n\t return rv;\n\t};\n\tDirectoryRecord.prototype.isSymlink = function isSymlink (isoData) {\n\t return this.hasRockRidge() && this.getSUEntries(isoData).filter(function (e) { return e instanceof SLEntry; }).length > 0;\n\t};\n\tDirectoryRecord.prototype.getSymlinkPath = function getSymlinkPath (isoData) {\n\t var p = \"\";\n\t var entries = this.getSUEntries(isoData);\n\t var getStr = this._getGetString();\n\t for (var i = 0, list = entries; i < list.length; i += 1) {\n\t var entry = list[i];\n\t\n\t if (entry instanceof SLEntry) {\n\t var components = entry.componentRecords();\n\t for (var i$1 = 0, list$1 = components; i$1 < list$1.length; i$1 += 1) {\n\t var component = list$1[i$1];\n\t\n\t var flags = component.flags();\n\t if (flags & 2 /* CURRENT */) {\n\t p += \"./\";\n\t }\n\t else if (flags & 4 /* PARENT */) {\n\t p += \"../\";\n\t }\n\t else if (flags & 8 /* ROOT */) {\n\t p += \"/\";\n\t }\n\t else {\n\t p += component.content(getStr);\n\t if (!(flags & 1 /* CONTINUE */)) {\n\t p += '/';\n\t }\n\t }\n\t }\n\t if (!entry.continueFlag()) {\n\t // We are done with this link.\n\t break;\n\t }\n\t }\n\t }\n\t if (p.length > 1 && p[p.length - 1] === '/') {\n\t // Trim trailing '/'.\n\t return p.slice(0, p.length - 1);\n\t }\n\t else {\n\t return p;\n\t }\n\t};\n\tDirectoryRecord.prototype.getFile = function getFile (isoData) {\n\t if (this.isDirectory(isoData)) {\n\t throw new Error(\"Tried to get a File from a directory.\");\n\t }\n\t if (this._fileOrDir === null) {\n\t this._fileOrDir = isoData.slice(this.lba(), this.lba() + this.dataLength());\n\t }\n\t return this._fileOrDir;\n\t};\n\tDirectoryRecord.prototype.getDirectory = function getDirectory (isoData) {\n\t if (!this.isDirectory(isoData)) {\n\t throw new Error(\"Tried to get a Directory from a file.\");\n\t }\n\t if (this._fileOrDir === null) {\n\t this._fileOrDir = this._constructDirectory(isoData);\n\t }\n\t return this._fileOrDir;\n\t};\n\tDirectoryRecord.prototype.getSUEntries = function getSUEntries (isoData) {\n\t if (!this._suEntries) {\n\t this._constructSUEntries(isoData);\n\t }\n\t return this._suEntries;\n\t};\n\tDirectoryRecord.prototype._rockRidgeFilename = function _rockRidgeFilename (isoData) {\n\t var nmEntries = this.getSUEntries(isoData).filter(function (e) { return e instanceof NMEntry; });\n\t if (nmEntries.length === 0 || nmEntries[0].flags() & (2 /* CURRENT */ | 4 /* PARENT */)) {\n\t return null;\n\t }\n\t var str = '';\n\t var getString = this._getGetString();\n\t for (var i = 0, list = nmEntries; i < list.length; i += 1) {\n\t var e = list[i];\n\t\n\t str += e.name(getString);\n\t if (!(e.flags() & 1 /* CONTINUE */)) {\n\t break;\n\t }\n\t }\n\t return str;\n\t};\n\tDirectoryRecord.prototype._constructSUEntries = function _constructSUEntries (isoData) {\n\t var i = 33 + this._data[32];\n\t if (i % 2 === 1) {\n\t // Skip padding field.\n\t i++;\n\t }\n\t i += this._rockRidgeOffset;\n\t this._suEntries = constructSystemUseEntries(this._data, i, this.length(), isoData);\n\t};\n\t/**\n\t * !!ONLY VALID ON FIRST ENTRY OF ROOT DIRECTORY!!\n\t * Returns -1 if rock ridge is not enabled. Otherwise, returns the offset\n\t * at which system use fields begin.\n\t */\n\tDirectoryRecord.prototype._getRockRidgeOffset = function _getRockRidgeOffset (isoData) {\n\t // In the worst case, we get some garbage SU entries.\n\t // Fudge offset to 0 before proceeding.\n\t this._rockRidgeOffset = 0;\n\t var suEntries = this.getSUEntries(isoData);\n\t if (suEntries.length > 0) {\n\t var spEntry = suEntries[0];\n\t if (spEntry instanceof SPEntry && spEntry.checkBytesPass()) {\n\t // SUSP is in use.\n\t for (var i = 1; i < suEntries.length; i++) {\n\t var entry = suEntries[i];\n\t if (entry instanceof RREntry || (entry instanceof EREntry && entry.extensionIdentifier() === rockRidgeIdentifier)) {\n\t // Rock Ridge is in use!\n\t return spEntry.bytesSkipped();\n\t }\n\t }\n\t }\n\t }\n\t // Failed.\n\t this._rockRidgeOffset = -1;\n\t return -1;\n\t};\n\t/**\n\t * @hidden\n\t */\n\tvar ISODirectoryRecord = (function (DirectoryRecord) {\n\t function ISODirectoryRecord(data, rockRidgeOffset) {\n\t DirectoryRecord.call(this, data, rockRidgeOffset);\n\t }\n\t\n\t if ( DirectoryRecord ) ISODirectoryRecord.__proto__ = DirectoryRecord;\n\t ISODirectoryRecord.prototype = Object.create( DirectoryRecord && DirectoryRecord.prototype );\n\t ISODirectoryRecord.prototype.constructor = ISODirectoryRecord;\n\t ISODirectoryRecord.prototype._getString = function _getString (i, len) {\n\t return getASCIIString(this._data, i, len);\n\t };\n\t ISODirectoryRecord.prototype._constructDirectory = function _constructDirectory (isoData) {\n\t return new ISODirectory(this, isoData);\n\t };\n\t ISODirectoryRecord.prototype._getGetString = function _getGetString () {\n\t return getASCIIString;\n\t };\n\t\n\t return ISODirectoryRecord;\n\t}(DirectoryRecord));\n\t/**\n\t * @hidden\n\t */\n\tvar JolietDirectoryRecord = (function (DirectoryRecord) {\n\t function JolietDirectoryRecord(data, rockRidgeOffset) {\n\t DirectoryRecord.call(this, data, rockRidgeOffset);\n\t }\n\t\n\t if ( DirectoryRecord ) JolietDirectoryRecord.__proto__ = DirectoryRecord;\n\t JolietDirectoryRecord.prototype = Object.create( DirectoryRecord && DirectoryRecord.prototype );\n\t JolietDirectoryRecord.prototype.constructor = JolietDirectoryRecord;\n\t JolietDirectoryRecord.prototype._getString = function _getString (i, len) {\n\t return getJolietString(this._data, i, len);\n\t };\n\t JolietDirectoryRecord.prototype._constructDirectory = function _constructDirectory (isoData) {\n\t return new JolietDirectory(this, isoData);\n\t };\n\t JolietDirectoryRecord.prototype._getGetString = function _getGetString () {\n\t return getJolietString;\n\t };\n\t\n\t return JolietDirectoryRecord;\n\t}(DirectoryRecord));\n\t/**\n\t * @hidden\n\t */\n\tvar SystemUseEntry = function SystemUseEntry(data) {\n\t this._data = data;\n\t};\n\tSystemUseEntry.prototype.signatureWord = function signatureWord () {\n\t return this._data.readUInt16BE(0);\n\t};\n\tSystemUseEntry.prototype.signatureWordString = function signatureWordString () {\n\t return getASCIIString(this._data, 0, 2);\n\t};\n\tSystemUseEntry.prototype.length = function length () {\n\t return this._data[2];\n\t};\n\tSystemUseEntry.prototype.suVersion = function suVersion () {\n\t return this._data[3];\n\t};\n\t/**\n\t * Continuation entry.\n\t * @hidden\n\t */\n\tvar CEEntry = (function (SystemUseEntry) {\n\t function CEEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t this._entries = null;\n\t }\n\t\n\t if ( SystemUseEntry ) CEEntry.__proto__ = SystemUseEntry;\n\t CEEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t CEEntry.prototype.constructor = CEEntry;\n\t /**\n\t * Logical block address of the continuation area.\n\t */\n\t CEEntry.prototype.continuationLba = function continuationLba () {\n\t return this._data.readUInt32LE(4);\n\t };\n\t /**\n\t * Offset into the logical block.\n\t */\n\t CEEntry.prototype.continuationLbaOffset = function continuationLbaOffset () {\n\t return this._data.readUInt32LE(12);\n\t };\n\t /**\n\t * Length of the continuation area.\n\t */\n\t CEEntry.prototype.continuationLength = function continuationLength () {\n\t return this._data.readUInt32LE(20);\n\t };\n\t CEEntry.prototype.getEntries = function getEntries (isoData) {\n\t if (!this._entries) {\n\t var start = this.continuationLba() * 2048 + this.continuationLbaOffset();\n\t this._entries = constructSystemUseEntries(isoData, start, this.continuationLength(), isoData);\n\t }\n\t return this._entries;\n\t };\n\t\n\t return CEEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * Padding entry.\n\t * @hidden\n\t */\n\tvar PDEntry = (function (SystemUseEntry) {\n\t function PDEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) PDEntry.__proto__ = SystemUseEntry;\n\t PDEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t PDEntry.prototype.constructor = PDEntry;\n\t\n\t return PDEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * Identifies that SUSP is in-use.\n\t * @hidden\n\t */\n\tvar SPEntry = (function (SystemUseEntry) {\n\t function SPEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) SPEntry.__proto__ = SystemUseEntry;\n\t SPEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t SPEntry.prototype.constructor = SPEntry;\n\t SPEntry.prototype.checkBytesPass = function checkBytesPass () {\n\t return this._data[4] === 0xBE && this._data[5] === 0xEF;\n\t };\n\t SPEntry.prototype.bytesSkipped = function bytesSkipped () {\n\t return this._data[6];\n\t };\n\t\n\t return SPEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * Identifies the end of the SUSP entries.\n\t * @hidden\n\t */\n\tvar STEntry = (function (SystemUseEntry) {\n\t function STEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) STEntry.__proto__ = SystemUseEntry;\n\t STEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t STEntry.prototype.constructor = STEntry;\n\t\n\t return STEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * Specifies system-specific extensions to SUSP.\n\t * @hidden\n\t */\n\tvar EREntry = (function (SystemUseEntry) {\n\t function EREntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) EREntry.__proto__ = SystemUseEntry;\n\t EREntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t EREntry.prototype.constructor = EREntry;\n\t EREntry.prototype.identifierLength = function identifierLength () {\n\t return this._data[4];\n\t };\n\t EREntry.prototype.descriptorLength = function descriptorLength () {\n\t return this._data[5];\n\t };\n\t EREntry.prototype.sourceLength = function sourceLength () {\n\t return this._data[6];\n\t };\n\t EREntry.prototype.extensionVersion = function extensionVersion () {\n\t return this._data[7];\n\t };\n\t EREntry.prototype.extensionIdentifier = function extensionIdentifier () {\n\t return getASCIIString(this._data, 8, this.identifierLength());\n\t };\n\t EREntry.prototype.extensionDescriptor = function extensionDescriptor () {\n\t return getASCIIString(this._data, 8 + this.identifierLength(), this.descriptorLength());\n\t };\n\t EREntry.prototype.extensionSource = function extensionSource () {\n\t return getASCIIString(this._data, 8 + this.identifierLength() + this.descriptorLength(), this.sourceLength());\n\t };\n\t\n\t return EREntry;\n\t}(SystemUseEntry));\n\t/**\n\t * @hidden\n\t */\n\tvar ESEntry = (function (SystemUseEntry) {\n\t function ESEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) ESEntry.__proto__ = SystemUseEntry;\n\t ESEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t ESEntry.prototype.constructor = ESEntry;\n\t ESEntry.prototype.extensionSequence = function extensionSequence () {\n\t return this._data[4];\n\t };\n\t\n\t return ESEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * RockRidge: Marks that RockRidge is in use [deprecated]\n\t * @hidden\n\t */\n\tvar RREntry = (function (SystemUseEntry) {\n\t function RREntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) RREntry.__proto__ = SystemUseEntry;\n\t RREntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t RREntry.prototype.constructor = RREntry;\n\t\n\t return RREntry;\n\t}(SystemUseEntry));\n\t/**\n\t * RockRidge: Records POSIX file attributes.\n\t * @hidden\n\t */\n\tvar PXEntry = (function (SystemUseEntry) {\n\t function PXEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) PXEntry.__proto__ = SystemUseEntry;\n\t PXEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t PXEntry.prototype.constructor = PXEntry;\n\t PXEntry.prototype.mode = function mode () {\n\t return this._data.readUInt32LE(4);\n\t };\n\t PXEntry.prototype.fileLinks = function fileLinks () {\n\t return this._data.readUInt32LE(12);\n\t };\n\t PXEntry.prototype.uid = function uid () {\n\t return this._data.readUInt32LE(20);\n\t };\n\t PXEntry.prototype.gid = function gid () {\n\t return this._data.readUInt32LE(28);\n\t };\n\t PXEntry.prototype.inode = function inode () {\n\t return this._data.readUInt32LE(36);\n\t };\n\t\n\t return PXEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * RockRidge: Records POSIX device number.\n\t * @hidden\n\t */\n\tvar PNEntry = (function (SystemUseEntry) {\n\t function PNEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) PNEntry.__proto__ = SystemUseEntry;\n\t PNEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t PNEntry.prototype.constructor = PNEntry;\n\t PNEntry.prototype.devTHigh = function devTHigh () {\n\t return this._data.readUInt32LE(4);\n\t };\n\t PNEntry.prototype.devTLow = function devTLow () {\n\t return this._data.readUInt32LE(12);\n\t };\n\t\n\t return PNEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * RockRidge: Records symbolic link\n\t * @hidden\n\t */\n\tvar SLEntry = (function (SystemUseEntry) {\n\t function SLEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) SLEntry.__proto__ = SystemUseEntry;\n\t SLEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t SLEntry.prototype.constructor = SLEntry;\n\t SLEntry.prototype.flags = function flags () {\n\t return this._data[4];\n\t };\n\t SLEntry.prototype.continueFlag = function continueFlag () {\n\t return this.flags() & 0x1;\n\t };\n\t SLEntry.prototype.componentRecords = function componentRecords () {\n\t var this$1 = this;\n\t\n\t var records = new Array();\n\t var i = 5;\n\t while (i < this.length()) {\n\t var record = new SLComponentRecord(this$1._data.slice(i));\n\t records.push(record);\n\t i += record.length();\n\t }\n\t return records;\n\t };\n\t\n\t return SLEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * @hidden\n\t */\n\tvar SLComponentRecord = function SLComponentRecord(data) {\n\t this._data = data;\n\t};\n\tSLComponentRecord.prototype.flags = function flags () {\n\t return this._data[0];\n\t};\n\tSLComponentRecord.prototype.length = function length () {\n\t return 2 + this.componentLength();\n\t};\n\tSLComponentRecord.prototype.componentLength = function componentLength () {\n\t return this._data[1];\n\t};\n\tSLComponentRecord.prototype.content = function content (getString) {\n\t return getString(this._data, 2, this.componentLength());\n\t};\n\t/**\n\t * RockRidge: Records alternate file name\n\t * @hidden\n\t */\n\tvar NMEntry = (function (SystemUseEntry) {\n\t function NMEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) NMEntry.__proto__ = SystemUseEntry;\n\t NMEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t NMEntry.prototype.constructor = NMEntry;\n\t NMEntry.prototype.flags = function flags () {\n\t return this._data[4];\n\t };\n\t NMEntry.prototype.name = function name (getString) {\n\t return getString(this._data, 5, this.length() - 5);\n\t };\n\t\n\t return NMEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * RockRidge: Records child link\n\t * @hidden\n\t */\n\tvar CLEntry = (function (SystemUseEntry) {\n\t function CLEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) CLEntry.__proto__ = SystemUseEntry;\n\t CLEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t CLEntry.prototype.constructor = CLEntry;\n\t CLEntry.prototype.childDirectoryLba = function childDirectoryLba () {\n\t return this._data.readUInt32LE(4);\n\t };\n\t\n\t return CLEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * RockRidge: Records parent link.\n\t * @hidden\n\t */\n\tvar PLEntry = (function (SystemUseEntry) {\n\t function PLEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) PLEntry.__proto__ = SystemUseEntry;\n\t PLEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t PLEntry.prototype.constructor = PLEntry;\n\t PLEntry.prototype.parentDirectoryLba = function parentDirectoryLba () {\n\t return this._data.readUInt32LE(4);\n\t };\n\t\n\t return PLEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * RockRidge: Records relocated directory.\n\t * @hidden\n\t */\n\tvar REEntry = (function (SystemUseEntry) {\n\t function REEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) REEntry.__proto__ = SystemUseEntry;\n\t REEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t REEntry.prototype.constructor = REEntry;\n\t\n\t return REEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * RockRidge: Records file timestamps\n\t * @hidden\n\t */\n\tvar TFEntry = (function (SystemUseEntry) {\n\t function TFEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) TFEntry.__proto__ = SystemUseEntry;\n\t TFEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t TFEntry.prototype.constructor = TFEntry;\n\t TFEntry.prototype.flags = function flags () {\n\t return this._data[4];\n\t };\n\t TFEntry.prototype.creation = function creation () {\n\t if (this.flags() & 1 /* CREATION */) {\n\t if (this._longFormDates()) {\n\t return getDate(this._data, 5);\n\t }\n\t else {\n\t return getShortFormDate(this._data, 5);\n\t }\n\t }\n\t else {\n\t return null;\n\t }\n\t };\n\t TFEntry.prototype.modify = function modify () {\n\t if (this.flags() & 2 /* MODIFY */) {\n\t var previousDates = (this.flags() & 1 /* CREATION */) ? 1 : 0;\n\t if (this._longFormDates) {\n\t return getDate(this._data, 5 + (previousDates * 17));\n\t }\n\t else {\n\t return getShortFormDate(this._data, 5 + (previousDates * 7));\n\t }\n\t }\n\t else {\n\t return null;\n\t }\n\t };\n\t TFEntry.prototype.access = function access () {\n\t if (this.flags() & 4 /* ACCESS */) {\n\t var previousDates = (this.flags() & 1 /* CREATION */) ? 1 : 0;\n\t previousDates += (this.flags() & 2 /* MODIFY */) ? 1 : 0;\n\t if (this._longFormDates) {\n\t return getDate(this._data, 5 + (previousDates * 17));\n\t }\n\t else {\n\t return getShortFormDate(this._data, 5 + (previousDates * 7));\n\t }\n\t }\n\t else {\n\t return null;\n\t }\n\t };\n\t TFEntry.prototype.backup = function backup () {\n\t if (this.flags() & 16 /* BACKUP */) {\n\t var previousDates = (this.flags() & 1 /* CREATION */) ? 1 : 0;\n\t previousDates += (this.flags() & 2 /* MODIFY */) ? 1 : 0;\n\t previousDates += (this.flags() & 4 /* ACCESS */) ? 1 : 0;\n\t if (this._longFormDates) {\n\t return getDate(this._data, 5 + (previousDates * 17));\n\t }\n\t else {\n\t return getShortFormDate(this._data, 5 + (previousDates * 7));\n\t }\n\t }\n\t else {\n\t return null;\n\t }\n\t };\n\t TFEntry.prototype.expiration = function expiration () {\n\t if (this.flags() & 32 /* EXPIRATION */) {\n\t var previousDates = (this.flags() & 1 /* CREATION */) ? 1 : 0;\n\t previousDates += (this.flags() & 2 /* MODIFY */) ? 1 : 0;\n\t previousDates += (this.flags() & 4 /* ACCESS */) ? 1 : 0;\n\t previousDates += (this.flags() & 16 /* BACKUP */) ? 1 : 0;\n\t if (this._longFormDates) {\n\t return getDate(this._data, 5 + (previousDates * 17));\n\t }\n\t else {\n\t return getShortFormDate(this._data, 5 + (previousDates * 7));\n\t }\n\t }\n\t else {\n\t return null;\n\t }\n\t };\n\t TFEntry.prototype.effective = function effective () {\n\t if (this.flags() & 64 /* EFFECTIVE */) {\n\t var previousDates = (this.flags() & 1 /* CREATION */) ? 1 : 0;\n\t previousDates += (this.flags() & 2 /* MODIFY */) ? 1 : 0;\n\t previousDates += (this.flags() & 4 /* ACCESS */) ? 1 : 0;\n\t previousDates += (this.flags() & 16 /* BACKUP */) ? 1 : 0;\n\t previousDates += (this.flags() & 32 /* EXPIRATION */) ? 1 : 0;\n\t if (this._longFormDates) {\n\t return getDate(this._data, 5 + (previousDates * 17));\n\t }\n\t else {\n\t return getShortFormDate(this._data, 5 + (previousDates * 7));\n\t }\n\t }\n\t else {\n\t return null;\n\t }\n\t };\n\t TFEntry.prototype._longFormDates = function _longFormDates () {\n\t return !!(this.flags() && 128 /* LONG_FORM */);\n\t };\n\t\n\t return TFEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * RockRidge: File data in sparse format.\n\t * @hidden\n\t */\n\tvar SFEntry = (function (SystemUseEntry) {\n\t function SFEntry(data) {\n\t SystemUseEntry.call(this, data);\n\t }\n\t\n\t if ( SystemUseEntry ) SFEntry.__proto__ = SystemUseEntry;\n\t SFEntry.prototype = Object.create( SystemUseEntry && SystemUseEntry.prototype );\n\t SFEntry.prototype.constructor = SFEntry;\n\t SFEntry.prototype.virtualSizeHigh = function virtualSizeHigh () {\n\t return this._data.readUInt32LE(4);\n\t };\n\t SFEntry.prototype.virtualSizeLow = function virtualSizeLow () {\n\t return this._data.readUInt32LE(12);\n\t };\n\t SFEntry.prototype.tableDepth = function tableDepth () {\n\t return this._data[20];\n\t };\n\t\n\t return SFEntry;\n\t}(SystemUseEntry));\n\t/**\n\t * @hidden\n\t */\n\tvar Directory = function Directory(record, isoData) {\n\t var this$1 = this;\n\t\n\t this._fileList = [];\n\t this._fileMap = {};\n\t this._record = record;\n\t var i = record.lba();\n\t var iLimit = i + record.dataLength();\n\t if (!(record.fileFlags() & 2 /* Directory */)) {\n\t // Must have a CL entry.\n\t var cl = record.getSUEntries(isoData).filter(function (e) { return e instanceof CLEntry; })[0];\n\t i = cl.childDirectoryLba() * 2048;\n\t iLimit = Infinity;\n\t }\n\t while (i < iLimit) {\n\t var len = isoData[i];\n\t // Zero-padding between sectors.\n\t // TODO: Could optimize this to seek to nearest-sector upon\n\t // seeing a 0.\n\t if (len === 0) {\n\t i++;\n\t continue;\n\t }\n\t var r = this$1._constructDirectoryRecord(isoData.slice(i));\n\t var fname = r.fileName(isoData);\n\t // Skip '.' and '..' entries.\n\t if (fname !== '\\u0000' && fname !== '\\u0001') {\n\t // Skip relocated entries.\n\t if (!r.hasRockRidge() || r.getSUEntries(isoData).filter(function (e) { return e instanceof REEntry; }).length === 0) {\n\t this$1._fileMap[fname] = r;\n\t this$1._fileList.push(fname);\n\t }\n\t }\n\t else if (iLimit === Infinity) {\n\t // First entry contains needed data.\n\t iLimit = i + r.dataLength();\n\t }\n\t i += r.length();\n\t }\n\t};\n\t/**\n\t * Get the record with the given name.\n\t * Returns undefined if not present.\n\t */\n\tDirectory.prototype.getRecord = function getRecord (name) {\n\t return this._fileMap[name];\n\t};\n\tDirectory.prototype.getFileList = function getFileList () {\n\t return this._fileList;\n\t};\n\tDirectory.prototype.getDotEntry = function getDotEntry (isoData) {\n\t return this._constructDirectoryRecord(isoData.slice(this._record.lba()));\n\t};\n\t/**\n\t * @hidden\n\t */\n\tvar ISODirectory = (function (Directory) {\n\t function ISODirectory(record, isoData) {\n\t Directory.call(this, record, isoData);\n\t }\n\t\n\t if ( Directory ) ISODirectory.__proto__ = Directory;\n\t ISODirectory.prototype = Object.create( Directory && Directory.prototype );\n\t ISODirectory.prototype.constructor = ISODirectory;\n\t ISODirectory.prototype._constructDirectoryRecord = function _constructDirectoryRecord (data) {\n\t return new ISODirectoryRecord(data, this._record.getRockRidgeOffset());\n\t };\n\t\n\t return ISODirectory;\n\t}(Directory));\n\t/**\n\t * @hidden\n\t */\n\tvar JolietDirectory = (function (Directory) {\n\t function JolietDirectory(record, isoData) {\n\t Directory.call(this, record, isoData);\n\t }\n\t\n\t if ( Directory ) JolietDirectory.__proto__ = Directory;\n\t JolietDirectory.prototype = Object.create( Directory && Directory.prototype );\n\t JolietDirectory.prototype.constructor = JolietDirectory;\n\t JolietDirectory.prototype._constructDirectoryRecord = function _constructDirectoryRecord (data) {\n\t return new JolietDirectoryRecord(data, this._record.getRockRidgeOffset());\n\t };\n\t\n\t return JolietDirectory;\n\t}(Directory));\n\t/**\n\t * Mounts an ISO file as a read-only file system.\n\t *\n\t * Supports:\n\t * * Vanilla ISO9660 ISOs\n\t * * Microsoft Joliet and Rock Ridge extensions to the ISO9660 standard\n\t */\n\tvar IsoFS = (function (SynchronousFileSystem$$1) {\n\t function IsoFS(data, name, deprecateMsg) {\n\t var this$1 = this;\n\t if ( name === void 0 ) name = \"\";\n\t if ( deprecateMsg === void 0 ) deprecateMsg = true;\n\t\n\t SynchronousFileSystem$$1.call(this);\n\t this._data = data;\n\t deprecationMessage(deprecateMsg, IsoFS.Name, { data: \"ISO data as a Buffer\", name: name });\n\t // Skip first 16 sectors.\n\t var vdTerminatorFound = false;\n\t var i = 16 * 2048;\n\t var candidateVDs = new Array();\n\t while (!vdTerminatorFound) {\n\t var slice = data.slice(i);\n\t var vd = new VolumeDescriptor(slice);\n\t switch (vd.type()) {\n\t case 1 /* PrimaryVolumeDescriptor */:\n\t candidateVDs.push(new PrimaryVolumeDescriptor(slice));\n\t break;\n\t case 2 /* SupplementaryVolumeDescriptor */:\n\t candidateVDs.push(new SupplementaryVolumeDescriptor(slice));\n\t break;\n\t case 255 /* VolumeDescriptorSetTerminator */:\n\t vdTerminatorFound = true;\n\t break;\n\t }\n\t i += 2048;\n\t }\n\t if (candidateVDs.length === 0) {\n\t throw new ApiError(ErrorCode.EIO, \"Unable to find a suitable volume descriptor.\");\n\t }\n\t candidateVDs.forEach(function (v) {\n\t // Take an SVD over a PVD.\n\t if (!this$1._pvd || this$1._pvd.type() !== 2 /* SupplementaryVolumeDescriptor */) {\n\t this$1._pvd = v;\n\t }\n\t });\n\t this._root = this._pvd.rootDirectoryEntry(data);\n\t this._name = name;\n\t }\n\t\n\t if ( SynchronousFileSystem$$1 ) IsoFS.__proto__ = SynchronousFileSystem$$1;\n\t IsoFS.prototype = Object.create( SynchronousFileSystem$$1 && SynchronousFileSystem$$1.prototype );\n\t IsoFS.prototype.constructor = IsoFS;\n\t /**\n\t * Creates an IsoFS instance with the given options.\n\t */\n\t IsoFS.Create = function Create (opts, cb) {\n\t var fs;\n\t var e;\n\t try {\n\t fs = new IsoFS(opts.data, opts.name, false);\n\t }\n\t catch (e) {\n\t e = e;\n\t }\n\t finally {\n\t cb(e, fs);\n\t }\n\t };\n\t IsoFS.isAvailable = function isAvailable () {\n\t return true;\n\t };\n\t IsoFS.prototype.getName = function getName () {\n\t var name = \"IsoFS\" + (this._name) + (this._pvd ? (\"-\" + (this._pvd.name())) : '');\n\t if (this._root && this._root.hasRockRidge()) {\n\t name += \"-RockRidge\";\n\t }\n\t return name;\n\t };\n\t IsoFS.prototype.diskSpace = function diskSpace (path$$1, cb) {\n\t // Read-only file system.\n\t cb(this._data.length, 0);\n\t };\n\t IsoFS.prototype.isReadOnly = function isReadOnly () {\n\t return true;\n\t };\n\t IsoFS.prototype.supportsLinks = function supportsLinks () {\n\t return false;\n\t };\n\t IsoFS.prototype.supportsProps = function supportsProps () {\n\t return false;\n\t };\n\t IsoFS.prototype.supportsSynch = function supportsSynch () {\n\t return true;\n\t };\n\t IsoFS.prototype.statSync = function statSync (p, isLstat) {\n\t var record = this._getDirectoryRecord(p);\n\t if (record === null) {\n\t throw ApiError.ENOENT(p);\n\t }\n\t return this._getStats(p, record);\n\t };\n\t IsoFS.prototype.openSync = function openSync (p, flags, mode) {\n\t // INVARIANT: Cannot write to RO file systems.\n\t if (flags.isWriteable()) {\n\t throw new ApiError(ErrorCode.EPERM, p);\n\t }\n\t // Check if the path exists, and is a file.\n\t var record = this._getDirectoryRecord(p);\n\t if (!record) {\n\t throw ApiError.ENOENT(p);\n\t }\n\t else if (record.isSymlink(this._data)) {\n\t return this.openSync(path.resolve(p, record.getSymlinkPath(this._data)), flags, mode);\n\t }\n\t else if (!record.isDirectory(this._data)) {\n\t var data = record.getFile(this._data);\n\t var stats = this._getStats(p, record);\n\t switch (flags.pathExistsAction()) {\n\t case ActionType.THROW_EXCEPTION:\n\t case ActionType.TRUNCATE_FILE:\n\t throw ApiError.EEXIST(p);\n\t case ActionType.NOP:\n\t return new NoSyncFile(this, p, flags, stats, data);\n\t default:\n\t throw new ApiError(ErrorCode.EINVAL, 'Invalid FileMode object.');\n\t }\n\t }\n\t else {\n\t throw ApiError.EISDIR(p);\n\t }\n\t };\n\t IsoFS.prototype.readdirSync = function readdirSync (path$$1) {\n\t // Check if it exists.\n\t var record = this._getDirectoryRecord(path$$1);\n\t if (!record) {\n\t throw ApiError.ENOENT(path$$1);\n\t }\n\t else if (record.isDirectory(this._data)) {\n\t return record.getDirectory(this._data).getFileList().slice(0);\n\t }\n\t else {\n\t throw ApiError.ENOTDIR(path$$1);\n\t }\n\t };\n\t /**\n\t * Specially-optimized readfile.\n\t */\n\t IsoFS.prototype.readFileSync = function readFileSync (fname, encoding, flag) {\n\t // Get file.\n\t var fd = this.openSync(fname, flag, 0x1a4);\n\t try {\n\t var fdCast = fd;\n\t var fdBuff = fdCast.getBuffer();\n\t if (encoding === null) {\n\t return copyingSlice(fdBuff);\n\t }\n\t return fdBuff.toString(encoding);\n\t }\n\t finally {\n\t fd.closeSync();\n\t }\n\t };\n\t IsoFS.prototype._getDirectoryRecord = function _getDirectoryRecord (path$$1) {\n\t var this$1 = this;\n\t\n\t // Special case.\n\t if (path$$1 === '/') {\n\t return this._root;\n\t }\n\t var components = path$$1.split('/').slice(1);\n\t var dir = this._root;\n\t for (var i = 0, list = components; i < list.length; i += 1) {\n\t var component = list[i];\n\t\n\t if (dir.isDirectory(this$1._data)) {\n\t dir = dir.getDirectory(this$1._data).getRecord(component);\n\t if (!dir) {\n\t return null;\n\t }\n\t }\n\t else {\n\t return null;\n\t }\n\t }\n\t return dir;\n\t };\n\t IsoFS.prototype._getStats = function _getStats (p, record) {\n\t if (record.isSymlink(this._data)) {\n\t var newP = path.resolve(p, record.getSymlinkPath(this._data));\n\t var dirRec = this._getDirectoryRecord(newP);\n\t if (!dirRec) {\n\t return null;\n\t }\n\t return this._getStats(newP, dirRec);\n\t }\n\t else {\n\t var len = record.dataLength();\n\t var mode = 0x16D;\n\t var date = record.recordingDate();\n\t var atime = date;\n\t var mtime = date;\n\t var ctime = date;\n\t if (record.hasRockRidge()) {\n\t var entries = record.getSUEntries(this._data);\n\t for (var i = 0, list = entries; i < list.length; i += 1) {\n\t var entry = list[i];\n\t\n\t if (entry instanceof PXEntry) {\n\t mode = entry.mode();\n\t }\n\t else if (entry instanceof TFEntry) {\n\t var flags = entry.flags();\n\t if (flags & 4 /* ACCESS */) {\n\t atime = entry.access();\n\t }\n\t if (flags & 2 /* MODIFY */) {\n\t mtime = entry.modify();\n\t }\n\t if (flags & 1 /* CREATION */) {\n\t ctime = entry.creation();\n\t }\n\t }\n\t }\n\t }\n\t // Mask out writeable flags. This is a RO file system.\n\t mode = mode & 0x16D;\n\t return new Stats(record.isDirectory(this._data) ? FileType.DIRECTORY : FileType.FILE, len, mode, atime, mtime, ctime);\n\t }\n\t };\n\t\n\t return IsoFS;\n\t}(SynchronousFileSystem));\n\t\n\tIsoFS.Name = \"IsoFS\";\n\tIsoFS.Options = {\n\t data: {\n\t type: \"object\",\n\t description: \"The ISO file in a buffer\",\n\t validator: bufferValidator\n\t }\n\t};\n\t\n\t// Monkey-patch `Create` functions to check options before file system initialization.\n\t[AsyncMirror, DropboxFileSystem, EmscriptenFileSystem, FolderAdapter, HTML5FS, InMemoryFileSystem, IndexedDBFileSystem, IsoFS, LocalStorageFileSystem, MountableFileSystem, OverlayFS, WorkerFS, XmlHttpRequest, ZipFS].forEach(function (fsType) {\n\t var create = fsType.Create;\n\t fsType.Create = function (opts, cb) {\n\t var oneArg = typeof (opts) === \"function\";\n\t var normalizedCb = oneArg ? opts : cb;\n\t var normalizedOpts = oneArg ? {} : opts;\n\t function wrappedCb(e) {\n\t if (e) {\n\t normalizedCb(e);\n\t }\n\t else {\n\t create.call(fsType, normalizedOpts, normalizedCb);\n\t }\n\t }\n\t checkOptions(fsType, normalizedOpts, wrappedCb);\n\t };\n\t});\n\t/**\n\t * @hidden\n\t */\n\tvar Backends = { AsyncMirror: AsyncMirror, Dropbox: DropboxFileSystem, Emscripten: EmscriptenFileSystem, FolderAdapter: FolderAdapter, HTML5FS: HTML5FS, InMemory: InMemoryFileSystem, IndexedDB: IndexedDBFileSystem, IsoFS: IsoFS, LocalStorage: LocalStorageFileSystem, MountableFileSystem: MountableFileSystem, OverlayFS: OverlayFS, WorkerFS: WorkerFS, XmlHttpRequest: XmlHttpRequest, ZipFS: ZipFS };\n\t\n\t/**\n\t * BrowserFS's main module. This is exposed in the browser via the BrowserFS global.\n\t * Due to limitations in typedoc, we document these functions in ./typedoc.ts.\n\t */\n\tif (process['initializeTTYs']) {\n\t process['initializeTTYs']();\n\t}\n\t/**\n\t * Installs BFSRequire as global `require`, a Node Buffer polyfill as the global `Buffer` variable,\n\t * and a Node process polyfill as the global `process` variable.\n\t */\n\tfunction install(obj) {\n\t obj.Buffer = Buffer;\n\t obj.process = process;\n\t var oldRequire = obj.require ? obj.require : null;\n\t // Monkey-patch require for Node-style code.\n\t obj.require = function (arg) {\n\t var rv = BFSRequire(arg);\n\t if (!rv) {\n\t return oldRequire.apply(null, Array.prototype.slice.call(arguments, 0));\n\t }\n\t else {\n\t return rv;\n\t }\n\t };\n\t}\n\t/**\n\t * @hidden\n\t */\n\tfunction registerFileSystem(name, fs) {\n\t Backends[name] = fs;\n\t}\n\tfunction BFSRequire(module) {\n\t switch (module) {\n\t case 'fs':\n\t return _fsMock;\n\t case 'path':\n\t return path;\n\t case 'buffer':\n\t // The 'buffer' module has 'Buffer' as a property.\n\t return buffer;\n\t case 'process':\n\t return process;\n\t case 'bfs_utils':\n\t return BFSUtils;\n\t default:\n\t return Backends[module];\n\t }\n\t}\n\t/**\n\t * Initializes BrowserFS with the given root file system.\n\t */\n\tfunction initialize(rootfs) {\n\t return _fsMock.initialize(rootfs);\n\t}\n\t/**\n\t * Creates a file system with the given configuration, and initializes BrowserFS with it.\n\t * See the FileSystemConfiguration type for more info on the configuration object.\n\t */\n\tfunction configure(config, cb) {\n\t getFileSystem(config, function (e, fs) {\n\t if (fs) {\n\t initialize(fs);\n\t cb();\n\t }\n\t else {\n\t cb(e);\n\t }\n\t });\n\t}\n\t/**\n\t * Retrieve a file system with the given configuration.\n\t * @param config A FileSystemConfiguration object. See FileSystemConfiguration for details.\n\t * @param cb Called when the file system is constructed, or when an error occurs.\n\t */\n\tfunction getFileSystem(config, cb) {\n\t var fsName = config['fs'];\n\t if (!fsName) {\n\t return cb(new ApiError(ErrorCode.EPERM, 'Missing \"fs\" property on configuration object.'));\n\t }\n\t var options = config['options'];\n\t var waitCount = 0;\n\t var called = false;\n\t function finish() {\n\t if (!called) {\n\t called = true;\n\t var fsc = Backends[fsName];\n\t if (!fsc) {\n\t cb(new ApiError(ErrorCode.EPERM, (\"File system \" + fsName + \" is not available in BrowserFS.\")));\n\t }\n\t else {\n\t fsc.Create(options, cb);\n\t }\n\t }\n\t }\n\t if (options !== null && typeof (options) === \"object\") {\n\t var finishedIterating = false;\n\t var props = Object.keys(options).filter(function (k) { return k !== 'fs'; });\n\t // Check recursively if other fields have 'fs' properties.\n\t props.forEach(function (p) {\n\t var d = options[p];\n\t if (d !== null && typeof (d) === \"object\" && d['fs']) {\n\t waitCount++;\n\t getFileSystem(d, function (e, fs) {\n\t waitCount--;\n\t if (e) {\n\t if (called) {\n\t return;\n\t }\n\t called = true;\n\t cb(e);\n\t }\n\t else {\n\t options[p] = fs;\n\t if (waitCount === 0 && finishedIterating) {\n\t finish();\n\t }\n\t }\n\t });\n\t }\n\t });\n\t finishedIterating = true;\n\t }\n\t if (waitCount === 0) {\n\t finish();\n\t }\n\t}\n\t\n\t/**\n\t * BrowserFS's main entry point.\n\t * It installs all of the needed polyfills, and requires() the main module.\n\t */\n\t// IE substr does not support negative indices\n\tif ('ab'.substr(-1) !== 'b') {\n\t String.prototype.substr = function (substr) {\n\t return function (start, length) {\n\t // did we get a negative start, calculate how much it is from the\n\t // beginning of the string\n\t if (start < 0) {\n\t start = this.length + start;\n\t }\n\t // call the original function\n\t return substr.call(this, start, length);\n\t };\n\t }(String.prototype.substr);\n\t}\n\t// Polyfill for Uint8Array.prototype.slice.\n\t// Safari and some other browsers do not define it.\n\tif (typeof (ArrayBuffer) !== 'undefined' && typeof (Uint8Array) !== 'undefined') {\n\t if (!Uint8Array.prototype['slice']) {\n\t Uint8Array.prototype.slice = function (start, end) {\n\t if ( start === void 0 ) start = 0;\n\t if ( end === void 0 ) end = this.length;\n\t\n\t var self = this;\n\t if (start < 0) {\n\t start = this.length + start;\n\t if (start < 0) {\n\t start = 0;\n\t }\n\t }\n\t if (end < 0) {\n\t end = this.length + end;\n\t if (end < 0) {\n\t end = 0;\n\t }\n\t }\n\t if (end < start) {\n\t end = start;\n\t }\n\t return new Uint8Array(self.buffer, self.byteOffset + start, end - start);\n\t };\n\t }\n\t}\n\t\n\texports.install = install;\n\texports.registerFileSystem = registerFileSystem;\n\texports.BFSRequire = BFSRequire;\n\texports.initialize = initialize;\n\texports.configure = configure;\n\texports.getFileSystem = getFileSystem;\n\texports.EmscriptenFS = BFSEmscriptenFS;\n\texports.FileSystem = Backends;\n\texports.Errors = api_error;\n\texports.setImmediate = setImmediate$3;\n\t\n\t/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1), (function() { return this; }()), __webpack_require__(5)(module), __webpack_require__(6)))\n\n/***/ },\n/* 1 */\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __webpack_require__(2).Buffer;\n\n\n/***/ },\n/* 2 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(Buffer) {/*!\n\t * The buffer module from node.js, for the browser.\n\t *\n\t * @author Feross Aboukhadijeh \n\t * @license MIT\n\t */\n\t/* eslint-disable no-proto */\n\t\n\t'use strict'\n\t\n\tvar base64 = __webpack_require__(3)\n\tvar ieee754 = __webpack_require__(4)\n\t\n\texports.Buffer = Buffer\n\texports.SlowBuffer = SlowBuffer\n\texports.INSPECT_MAX_BYTES = 50\n\t\n\tvar K_MAX_LENGTH = 0x7fffffff\n\texports.kMaxLength = K_MAX_LENGTH\n\t\n\t/**\n\t * If `Buffer.TYPED_ARRAY_SUPPORT`:\n\t * === true Use Uint8Array implementation (fastest)\n\t * === false Print warning and recommend using `buffer` v4.x which has an Object\n\t * implementation (most compatible, even IE6)\n\t *\n\t * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n\t * Opera 11.6+, iOS 4.2+.\n\t *\n\t * We report that the browser does not support typed arrays if the are not subclassable\n\t * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n\t * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n\t * for __proto__ and has a buggy typed array implementation.\n\t */\n\tBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\t\n\tif (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&\n\t typeof console.error === 'function') {\n\t console.error(\n\t 'This browser lacks typed array (Uint8Array) support which is required by ' +\n\t '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'\n\t )\n\t}\n\t\n\tfunction typedArraySupport () {\n\t // Can typed array instances can be augmented?\n\t try {\n\t var arr = new Uint8Array(1)\n\t arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n\t return arr.foo() === 42\n\t } catch (e) {\n\t return false\n\t }\n\t}\n\t\n\tfunction createBuffer (length) {\n\t if (length > K_MAX_LENGTH) {\n\t throw new RangeError('Invalid typed array length')\n\t }\n\t // Return an augmented `Uint8Array` instance\n\t var buf = new Uint8Array(length)\n\t buf.__proto__ = Buffer.prototype\n\t return buf\n\t}\n\t\n\t/**\n\t * The Buffer constructor returns instances of `Uint8Array` that have their\n\t * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n\t * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n\t * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n\t * returns a single octet.\n\t *\n\t * The `Uint8Array` prototype remains unmodified.\n\t */\n\t\n\tfunction Buffer (arg, encodingOrOffset, length) {\n\t // Common case.\n\t if (typeof arg === 'number') {\n\t if (typeof encodingOrOffset === 'string') {\n\t throw new Error(\n\t 'If encoding is specified then the first argument must be a string'\n\t )\n\t }\n\t return allocUnsafe(arg)\n\t }\n\t return from(arg, encodingOrOffset, length)\n\t}\n\t\n\t// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n\tif (typeof Symbol !== 'undefined' && Symbol.species &&\n\t Buffer[Symbol.species] === Buffer) {\n\t Object.defineProperty(Buffer, Symbol.species, {\n\t value: null,\n\t configurable: true,\n\t enumerable: false,\n\t writable: false\n\t })\n\t}\n\t\n\tBuffer.poolSize = 8192 // not used by this implementation\n\t\n\tfunction from (value, encodingOrOffset, length) {\n\t if (typeof value === 'number') {\n\t throw new TypeError('\"value\" argument must not be a number')\n\t }\n\t\n\t if (isArrayBuffer(value)) {\n\t return fromArrayBuffer(value, encodingOrOffset, length)\n\t }\n\t\n\t if (typeof value === 'string') {\n\t return fromString(value, encodingOrOffset)\n\t }\n\t\n\t return fromObject(value)\n\t}\n\t\n\t/**\n\t * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n\t * if value is a number.\n\t * Buffer.from(str[, encoding])\n\t * Buffer.from(array)\n\t * Buffer.from(buffer)\n\t * Buffer.from(arrayBuffer[, byteOffset[, length]])\n\t **/\n\tBuffer.from = function (value, encodingOrOffset, length) {\n\t return from(value, encodingOrOffset, length)\n\t}\n\t\n\t// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n\t// https://github.com/feross/buffer/pull/148\n\tBuffer.prototype.__proto__ = Uint8Array.prototype\n\tBuffer.__proto__ = Uint8Array\n\t\n\tfunction assertSize (size) {\n\t if (typeof size !== 'number') {\n\t throw new TypeError('\"size\" argument must be a number')\n\t } else if (size < 0) {\n\t throw new RangeError('\"size\" argument must not be negative')\n\t }\n\t}\n\t\n\tfunction alloc (size, fill, encoding) {\n\t assertSize(size)\n\t if (size <= 0) {\n\t return createBuffer(size)\n\t }\n\t if (fill !== undefined) {\n\t // Only pay attention to encoding if it's a string. This\n\t // prevents accidentally sending in a number that would\n\t // be interpretted as a start offset.\n\t return typeof encoding === 'string'\n\t ? createBuffer(size).fill(fill, encoding)\n\t : createBuffer(size).fill(fill)\n\t }\n\t return createBuffer(size)\n\t}\n\t\n\t/**\n\t * Creates a new filled Buffer instance.\n\t * alloc(size[, fill[, encoding]])\n\t **/\n\tBuffer.alloc = function (size, fill, encoding) {\n\t return alloc(size, fill, encoding)\n\t}\n\t\n\tfunction allocUnsafe (size) {\n\t assertSize(size)\n\t return createBuffer(size < 0 ? 0 : checked(size) | 0)\n\t}\n\t\n\t/**\n\t * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n\t * */\n\tBuffer.allocUnsafe = function (size) {\n\t return allocUnsafe(size)\n\t}\n\t/**\n\t * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n\t */\n\tBuffer.allocUnsafeSlow = function (size) {\n\t return allocUnsafe(size)\n\t}\n\t\n\tfunction fromString (string, encoding) {\n\t if (typeof encoding !== 'string' || encoding === '') {\n\t encoding = 'utf8'\n\t }\n\t\n\t if (!Buffer.isEncoding(encoding)) {\n\t throw new TypeError('\"encoding\" must be a valid string encoding')\n\t }\n\t\n\t var length = byteLength(string, encoding) | 0\n\t var buf = createBuffer(length)\n\t\n\t var actual = buf.write(string, encoding)\n\t\n\t if (actual !== length) {\n\t // Writing a hex string, for example, that contains invalid characters will\n\t // cause everything after the first invalid character to be ignored. (e.g.\n\t // 'abxxcd' will be treated as 'ab')\n\t buf = buf.slice(0, actual)\n\t }\n\t\n\t return buf\n\t}\n\t\n\tfunction fromArrayLike (array) {\n\t var length = array.length < 0 ? 0 : checked(array.length) | 0\n\t var buf = createBuffer(length)\n\t for (var i = 0; i < length; i += 1) {\n\t buf[i] = array[i] & 255\n\t }\n\t return buf\n\t}\n\t\n\tfunction fromArrayBuffer (array, byteOffset, length) {\n\t if (byteOffset < 0 || array.byteLength < byteOffset) {\n\t throw new RangeError('\\'offset\\' is out of bounds')\n\t }\n\t\n\t if (array.byteLength < byteOffset + (length || 0)) {\n\t throw new RangeError('\\'length\\' is out of bounds')\n\t }\n\t\n\t var buf\n\t if (byteOffset === undefined && length === undefined) {\n\t buf = new Uint8Array(array)\n\t } else if (length === undefined) {\n\t buf = new Uint8Array(array, byteOffset)\n\t } else {\n\t buf = new Uint8Array(array, byteOffset, length)\n\t }\n\t\n\t // Return an augmented `Uint8Array` instance\n\t buf.__proto__ = Buffer.prototype\n\t return buf\n\t}\n\t\n\tfunction fromObject (obj) {\n\t if (Buffer.isBuffer(obj)) {\n\t var len = checked(obj.length) | 0\n\t var buf = createBuffer(len)\n\t\n\t if (buf.length === 0) {\n\t return buf\n\t }\n\t\n\t obj.copy(buf, 0, 0, len)\n\t return buf\n\t }\n\t\n\t if (obj) {\n\t if (isArrayBufferView(obj) || 'length' in obj) {\n\t if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {\n\t return createBuffer(0)\n\t }\n\t return fromArrayLike(obj)\n\t }\n\t\n\t if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n\t return fromArrayLike(obj.data)\n\t }\n\t }\n\t\n\t throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n\t}\n\t\n\tfunction checked (length) {\n\t // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n\t // length is NaN (which is otherwise coerced to zero.)\n\t if (length >= K_MAX_LENGTH) {\n\t throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n\t 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n\t }\n\t return length | 0\n\t}\n\t\n\tfunction SlowBuffer (length) {\n\t if (+length != length) { // eslint-disable-line eqeqeq\n\t length = 0\n\t }\n\t return Buffer.alloc(+length)\n\t}\n\t\n\tBuffer.isBuffer = function isBuffer (b) {\n\t return b != null && b._isBuffer === true\n\t}\n\t\n\tBuffer.compare = function compare (a, b) {\n\t if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n\t throw new TypeError('Arguments must be Buffers')\n\t }\n\t\n\t if (a === b) return 0\n\t\n\t var x = a.length\n\t var y = b.length\n\t\n\t for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n\t if (a[i] !== b[i]) {\n\t x = a[i]\n\t y = b[i]\n\t break\n\t }\n\t }\n\t\n\t if (x < y) return -1\n\t if (y < x) return 1\n\t return 0\n\t}\n\t\n\tBuffer.isEncoding = function isEncoding (encoding) {\n\t switch (String(encoding).toLowerCase()) {\n\t case 'hex':\n\t case 'utf8':\n\t case 'utf-8':\n\t case 'ascii':\n\t case 'latin1':\n\t case 'binary':\n\t case 'base64':\n\t case 'ucs2':\n\t case 'ucs-2':\n\t case 'utf16le':\n\t case 'utf-16le':\n\t return true\n\t default:\n\t return false\n\t }\n\t}\n\t\n\tBuffer.concat = function concat (list, length) {\n\t if (!Array.isArray(list)) {\n\t throw new TypeError('\"list\" argument must be an Array of Buffers')\n\t }\n\t\n\t if (list.length === 0) {\n\t return Buffer.alloc(0)\n\t }\n\t\n\t var i\n\t if (length === undefined) {\n\t length = 0\n\t for (i = 0; i < list.length; ++i) {\n\t length += list[i].length\n\t }\n\t }\n\t\n\t var buffer = Buffer.allocUnsafe(length)\n\t var pos = 0\n\t for (i = 0; i < list.length; ++i) {\n\t var buf = list[i]\n\t if (!Buffer.isBuffer(buf)) {\n\t throw new TypeError('\"list\" argument must be an Array of Buffers')\n\t }\n\t buf.copy(buffer, pos)\n\t pos += buf.length\n\t }\n\t return buffer\n\t}\n\t\n\tfunction byteLength (string, encoding) {\n\t if (Buffer.isBuffer(string)) {\n\t return string.length\n\t }\n\t if (isArrayBufferView(string) || isArrayBuffer(string)) {\n\t return string.byteLength\n\t }\n\t if (typeof string !== 'string') {\n\t string = '' + string\n\t }\n\t\n\t var len = string.length\n\t if (len === 0) return 0\n\t\n\t // Use a for loop to avoid recursion\n\t var loweredCase = false\n\t for (;;) {\n\t switch (encoding) {\n\t case 'ascii':\n\t case 'latin1':\n\t case 'binary':\n\t return len\n\t case 'utf8':\n\t case 'utf-8':\n\t case undefined:\n\t return utf8ToBytes(string).length\n\t case 'ucs2':\n\t case 'ucs-2':\n\t case 'utf16le':\n\t case 'utf-16le':\n\t return len * 2\n\t case 'hex':\n\t return len >>> 1\n\t case 'base64':\n\t return base64ToBytes(string).length\n\t default:\n\t if (loweredCase) return utf8ToBytes(string).length // assume utf8\n\t encoding = ('' + encoding).toLowerCase()\n\t loweredCase = true\n\t }\n\t }\n\t}\n\tBuffer.byteLength = byteLength\n\t\n\tfunction slowToString (encoding, start, end) {\n\t var loweredCase = false\n\t\n\t // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n\t // property of a typed array.\n\t\n\t // This behaves neither like String nor Uint8Array in that we set start/end\n\t // to their upper/lower bounds if the value passed is out of range.\n\t // undefined is handled specially as per ECMA-262 6th Edition,\n\t // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n\t if (start === undefined || start < 0) {\n\t start = 0\n\t }\n\t // Return early if start > this.length. Done here to prevent potential uint32\n\t // coercion fail below.\n\t if (start > this.length) {\n\t return ''\n\t }\n\t\n\t if (end === undefined || end > this.length) {\n\t end = this.length\n\t }\n\t\n\t if (end <= 0) {\n\t return ''\n\t }\n\t\n\t // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n\t end >>>= 0\n\t start >>>= 0\n\t\n\t if (end <= start) {\n\t return ''\n\t }\n\t\n\t if (!encoding) encoding = 'utf8'\n\t\n\t while (true) {\n\t switch (encoding) {\n\t case 'hex':\n\t return hexSlice(this, start, end)\n\t\n\t case 'utf8':\n\t case 'utf-8':\n\t return utf8Slice(this, start, end)\n\t\n\t case 'ascii':\n\t return asciiSlice(this, start, end)\n\t\n\t case 'latin1':\n\t case 'binary':\n\t return latin1Slice(this, start, end)\n\t\n\t case 'base64':\n\t return base64Slice(this, start, end)\n\t\n\t case 'ucs2':\n\t case 'ucs-2':\n\t case 'utf16le':\n\t case 'utf-16le':\n\t return utf16leSlice(this, start, end)\n\t\n\t default:\n\t if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n\t encoding = (encoding + '').toLowerCase()\n\t loweredCase = true\n\t }\n\t }\n\t}\n\t\n\t// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)\n\t// to detect a Buffer instance. It's not possible to use `instanceof Buffer`\n\t// reliably in a browserify context because there could be multiple different\n\t// copies of the 'buffer' package in use. This method works even for Buffer\n\t// instances that were created from another copy of the `buffer` package.\n\t// See: https://github.com/feross/buffer/issues/154\n\tBuffer.prototype._isBuffer = true\n\t\n\tfunction swap (b, n, m) {\n\t var i = b[n]\n\t b[n] = b[m]\n\t b[m] = i\n\t}\n\t\n\tBuffer.prototype.swap16 = function swap16 () {\n\t var len = this.length\n\t if (len % 2 !== 0) {\n\t throw new RangeError('Buffer size must be a multiple of 16-bits')\n\t }\n\t for (var i = 0; i < len; i += 2) {\n\t swap(this, i, i + 1)\n\t }\n\t return this\n\t}\n\t\n\tBuffer.prototype.swap32 = function swap32 () {\n\t var len = this.length\n\t if (len % 4 !== 0) {\n\t throw new RangeError('Buffer size must be a multiple of 32-bits')\n\t }\n\t for (var i = 0; i < len; i += 4) {\n\t swap(this, i, i + 3)\n\t swap(this, i + 1, i + 2)\n\t }\n\t return this\n\t}\n\t\n\tBuffer.prototype.swap64 = function swap64 () {\n\t var len = this.length\n\t if (len % 8 !== 0) {\n\t throw new RangeError('Buffer size must be a multiple of 64-bits')\n\t }\n\t for (var i = 0; i < len; i += 8) {\n\t swap(this, i, i + 7)\n\t swap(this, i + 1, i + 6)\n\t swap(this, i + 2, i + 5)\n\t swap(this, i + 3, i + 4)\n\t }\n\t return this\n\t}\n\t\n\tBuffer.prototype.toString = function toString () {\n\t var length = this.length\n\t if (length === 0) return ''\n\t if (arguments.length === 0) return utf8Slice(this, 0, length)\n\t return slowToString.apply(this, arguments)\n\t}\n\t\n\tBuffer.prototype.equals = function equals (b) {\n\t if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n\t if (this === b) return true\n\t return Buffer.compare(this, b) === 0\n\t}\n\t\n\tBuffer.prototype.inspect = function inspect () {\n\t var str = ''\n\t var max = exports.INSPECT_MAX_BYTES\n\t if (this.length > 0) {\n\t str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n\t if (this.length > max) str += ' ... '\n\t }\n\t return ''\n\t}\n\t\n\tBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n\t if (!Buffer.isBuffer(target)) {\n\t throw new TypeError('Argument must be a Buffer')\n\t }\n\t\n\t if (start === undefined) {\n\t start = 0\n\t }\n\t if (end === undefined) {\n\t end = target ? target.length : 0\n\t }\n\t if (thisStart === undefined) {\n\t thisStart = 0\n\t }\n\t if (thisEnd === undefined) {\n\t thisEnd = this.length\n\t }\n\t\n\t if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n\t throw new RangeError('out of range index')\n\t }\n\t\n\t if (thisStart >= thisEnd && start >= end) {\n\t return 0\n\t }\n\t if (thisStart >= thisEnd) {\n\t return -1\n\t }\n\t if (start >= end) {\n\t return 1\n\t }\n\t\n\t start >>>= 0\n\t end >>>= 0\n\t thisStart >>>= 0\n\t thisEnd >>>= 0\n\t\n\t if (this === target) return 0\n\t\n\t var x = thisEnd - thisStart\n\t var y = end - start\n\t var len = Math.min(x, y)\n\t\n\t var thisCopy = this.slice(thisStart, thisEnd)\n\t var targetCopy = target.slice(start, end)\n\t\n\t for (var i = 0; i < len; ++i) {\n\t if (thisCopy[i] !== targetCopy[i]) {\n\t x = thisCopy[i]\n\t y = targetCopy[i]\n\t break\n\t }\n\t }\n\t\n\t if (x < y) return -1\n\t if (y < x) return 1\n\t return 0\n\t}\n\t\n\t// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n\t// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n\t//\n\t// Arguments:\n\t// - buffer - a Buffer to search\n\t// - val - a string, Buffer, or number\n\t// - byteOffset - an index into `buffer`; will be clamped to an int32\n\t// - encoding - an optional encoding, relevant is val is a string\n\t// - dir - true for indexOf, false for lastIndexOf\n\tfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n\t // Empty buffer means no match\n\t if (buffer.length === 0) return -1\n\t\n\t // Normalize byteOffset\n\t if (typeof byteOffset === 'string') {\n\t encoding = byteOffset\n\t byteOffset = 0\n\t } else if (byteOffset > 0x7fffffff) {\n\t byteOffset = 0x7fffffff\n\t } else if (byteOffset < -0x80000000) {\n\t byteOffset = -0x80000000\n\t }\n\t byteOffset = +byteOffset // Coerce to Number.\n\t if (numberIsNaN(byteOffset)) {\n\t // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n\t byteOffset = dir ? 0 : (buffer.length - 1)\n\t }\n\t\n\t // Normalize byteOffset: negative offsets start from the end of the buffer\n\t if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n\t if (byteOffset >= buffer.length) {\n\t if (dir) return -1\n\t else byteOffset = buffer.length - 1\n\t } else if (byteOffset < 0) {\n\t if (dir) byteOffset = 0\n\t else return -1\n\t }\n\t\n\t // Normalize val\n\t if (typeof val === 'string') {\n\t val = Buffer.from(val, encoding)\n\t }\n\t\n\t // Finally, search either indexOf (if dir is true) or lastIndexOf\n\t if (Buffer.isBuffer(val)) {\n\t // Special case: looking for empty string/buffer always fails\n\t if (val.length === 0) {\n\t return -1\n\t }\n\t return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n\t } else if (typeof val === 'number') {\n\t val = val & 0xFF // Search for a byte value [0-255]\n\t if (typeof Uint8Array.prototype.indexOf === 'function') {\n\t if (dir) {\n\t return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n\t } else {\n\t return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n\t }\n\t }\n\t return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n\t }\n\t\n\t throw new TypeError('val must be string, number or Buffer')\n\t}\n\t\n\tfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n\t var indexSize = 1\n\t var arrLength = arr.length\n\t var valLength = val.length\n\t\n\t if (encoding !== undefined) {\n\t encoding = String(encoding).toLowerCase()\n\t if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n\t encoding === 'utf16le' || encoding === 'utf-16le') {\n\t if (arr.length < 2 || val.length < 2) {\n\t return -1\n\t }\n\t indexSize = 2\n\t arrLength /= 2\n\t valLength /= 2\n\t byteOffset /= 2\n\t }\n\t }\n\t\n\t function read (buf, i) {\n\t if (indexSize === 1) {\n\t return buf[i]\n\t } else {\n\t return buf.readUInt16BE(i * indexSize)\n\t }\n\t }\n\t\n\t var i\n\t if (dir) {\n\t var foundIndex = -1\n\t for (i = byteOffset; i < arrLength; i++) {\n\t if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n\t if (foundIndex === -1) foundIndex = i\n\t if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n\t } else {\n\t if (foundIndex !== -1) i -= i - foundIndex\n\t foundIndex = -1\n\t }\n\t }\n\t } else {\n\t if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n\t for (i = byteOffset; i >= 0; i--) {\n\t var found = true\n\t for (var j = 0; j < valLength; j++) {\n\t if (read(arr, i + j) !== read(val, j)) {\n\t found = false\n\t break\n\t }\n\t }\n\t if (found) return i\n\t }\n\t }\n\t\n\t return -1\n\t}\n\t\n\tBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n\t return this.indexOf(val, byteOffset, encoding) !== -1\n\t}\n\t\n\tBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n\t return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n\t}\n\t\n\tBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n\t return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n\t}\n\t\n\tfunction hexWrite (buf, string, offset, length) {\n\t offset = Number(offset) || 0\n\t var remaining = buf.length - offset\n\t if (!length) {\n\t length = remaining\n\t } else {\n\t length = Number(length)\n\t if (length > remaining) {\n\t length = remaining\n\t }\n\t }\n\t\n\t // must be an even number of digits\n\t var strLen = string.length\n\t if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\t\n\t if (length > strLen / 2) {\n\t length = strLen / 2\n\t }\n\t for (var i = 0; i < length; ++i) {\n\t var parsed = parseInt(string.substr(i * 2, 2), 16)\n\t if (numberIsNaN(parsed)) return i\n\t buf[offset + i] = parsed\n\t }\n\t return i\n\t}\n\t\n\tfunction utf8Write (buf, string, offset, length) {\n\t return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n\t}\n\t\n\tfunction asciiWrite (buf, string, offset, length) {\n\t return blitBuffer(asciiToBytes(string), buf, offset, length)\n\t}\n\t\n\tfunction latin1Write (buf, string, offset, length) {\n\t return asciiWrite(buf, string, offset, length)\n\t}\n\t\n\tfunction base64Write (buf, string, offset, length) {\n\t return blitBuffer(base64ToBytes(string), buf, offset, length)\n\t}\n\t\n\tfunction ucs2Write (buf, string, offset, length) {\n\t return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n\t}\n\t\n\tBuffer.prototype.write = function write (string, offset, length, encoding) {\n\t // Buffer#write(string)\n\t if (offset === undefined) {\n\t encoding = 'utf8'\n\t length = this.length\n\t offset = 0\n\t // Buffer#write(string, encoding)\n\t } else if (length === undefined && typeof offset === 'string') {\n\t encoding = offset\n\t length = this.length\n\t offset = 0\n\t // Buffer#write(string, offset[, length][, encoding])\n\t } else if (isFinite(offset)) {\n\t offset = offset >>> 0\n\t if (isFinite(length)) {\n\t length = length >>> 0\n\t if (encoding === undefined) encoding = 'utf8'\n\t } else {\n\t encoding = length\n\t length = undefined\n\t }\n\t } else {\n\t throw new Error(\n\t 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n\t )\n\t }\n\t\n\t var remaining = this.length - offset\n\t if (length === undefined || length > remaining) length = remaining\n\t\n\t if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n\t throw new RangeError('Attempt to write outside buffer bounds')\n\t }\n\t\n\t if (!encoding) encoding = 'utf8'\n\t\n\t var loweredCase = false\n\t for (;;) {\n\t switch (encoding) {\n\t case 'hex':\n\t return hexWrite(this, string, offset, length)\n\t\n\t case 'utf8':\n\t case 'utf-8':\n\t return utf8Write(this, string, offset, length)\n\t\n\t case 'ascii':\n\t return asciiWrite(this, string, offset, length)\n\t\n\t case 'latin1':\n\t case 'binary':\n\t return latin1Write(this, string, offset, length)\n\t\n\t case 'base64':\n\t // Warning: maxLength not taken into account in base64Write\n\t return base64Write(this, string, offset, length)\n\t\n\t case 'ucs2':\n\t case 'ucs-2':\n\t case 'utf16le':\n\t case 'utf-16le':\n\t return ucs2Write(this, string, offset, length)\n\t\n\t default:\n\t if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n\t encoding = ('' + encoding).toLowerCase()\n\t loweredCase = true\n\t }\n\t }\n\t}\n\t\n\tBuffer.prototype.toJSON = function toJSON () {\n\t return {\n\t type: 'Buffer',\n\t data: Array.prototype.slice.call(this._arr || this, 0)\n\t }\n\t}\n\t\n\tfunction base64Slice (buf, start, end) {\n\t if (start === 0 && end === buf.length) {\n\t return base64.fromByteArray(buf)\n\t } else {\n\t return base64.fromByteArray(buf.slice(start, end))\n\t }\n\t}\n\t\n\tfunction utf8Slice (buf, start, end) {\n\t end = Math.min(buf.length, end)\n\t var res = []\n\t\n\t var i = start\n\t while (i < end) {\n\t var firstByte = buf[i]\n\t var codePoint = null\n\t var bytesPerSequence = (firstByte > 0xEF) ? 4\n\t : (firstByte > 0xDF) ? 3\n\t : (firstByte > 0xBF) ? 2\n\t : 1\n\t\n\t if (i + bytesPerSequence <= end) {\n\t var secondByte, thirdByte, fourthByte, tempCodePoint\n\t\n\t switch (bytesPerSequence) {\n\t case 1:\n\t if (firstByte < 0x80) {\n\t codePoint = firstByte\n\t }\n\t break\n\t case 2:\n\t secondByte = buf[i + 1]\n\t if ((secondByte & 0xC0) === 0x80) {\n\t tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n\t if (tempCodePoint > 0x7F) {\n\t codePoint = tempCodePoint\n\t }\n\t }\n\t break\n\t case 3:\n\t secondByte = buf[i + 1]\n\t thirdByte = buf[i + 2]\n\t if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n\t tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n\t if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n\t codePoint = tempCodePoint\n\t }\n\t }\n\t break\n\t case 4:\n\t secondByte = buf[i + 1]\n\t thirdByte = buf[i + 2]\n\t fourthByte = buf[i + 3]\n\t if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n\t tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n\t if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n\t codePoint = tempCodePoint\n\t }\n\t }\n\t }\n\t }\n\t\n\t if (codePoint === null) {\n\t // we did not generate a valid codePoint so insert a\n\t // replacement char (U+FFFD) and advance only 1 byte\n\t codePoint = 0xFFFD\n\t bytesPerSequence = 1\n\t } else if (codePoint > 0xFFFF) {\n\t // encode to utf16 (surrogate pair dance)\n\t codePoint -= 0x10000\n\t res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n\t codePoint = 0xDC00 | codePoint & 0x3FF\n\t }\n\t\n\t res.push(codePoint)\n\t i += bytesPerSequence\n\t }\n\t\n\t return decodeCodePointsArray(res)\n\t}\n\t\n\t// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n\t// the lowest limit is Chrome, with 0x10000 args.\n\t// We go 1 magnitude less, for safety\n\tvar MAX_ARGUMENTS_LENGTH = 0x1000\n\t\n\tfunction decodeCodePointsArray (codePoints) {\n\t var len = codePoints.length\n\t if (len <= MAX_ARGUMENTS_LENGTH) {\n\t return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n\t }\n\t\n\t // Decode in chunks to avoid \"call stack size exceeded\".\n\t var res = ''\n\t var i = 0\n\t while (i < len) {\n\t res += String.fromCharCode.apply(\n\t String,\n\t codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n\t )\n\t }\n\t return res\n\t}\n\t\n\tfunction asciiSlice (buf, start, end) {\n\t var ret = ''\n\t end = Math.min(buf.length, end)\n\t\n\t for (var i = start; i < end; ++i) {\n\t ret += String.fromCharCode(buf[i] & 0x7F)\n\t }\n\t return ret\n\t}\n\t\n\tfunction latin1Slice (buf, start, end) {\n\t var ret = ''\n\t end = Math.min(buf.length, end)\n\t\n\t for (var i = start; i < end; ++i) {\n\t ret += String.fromCharCode(buf[i])\n\t }\n\t return ret\n\t}\n\t\n\tfunction hexSlice (buf, start, end) {\n\t var len = buf.length\n\t\n\t if (!start || start < 0) start = 0\n\t if (!end || end < 0 || end > len) end = len\n\t\n\t var out = ''\n\t for (var i = start; i < end; ++i) {\n\t out += toHex(buf[i])\n\t }\n\t return out\n\t}\n\t\n\tfunction utf16leSlice (buf, start, end) {\n\t var bytes = buf.slice(start, end)\n\t var res = ''\n\t for (var i = 0; i < bytes.length; i += 2) {\n\t res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))\n\t }\n\t return res\n\t}\n\t\n\tBuffer.prototype.slice = function slice (start, end) {\n\t var len = this.length\n\t start = ~~start\n\t end = end === undefined ? len : ~~end\n\t\n\t if (start < 0) {\n\t start += len\n\t if (start < 0) start = 0\n\t } else if (start > len) {\n\t start = len\n\t }\n\t\n\t if (end < 0) {\n\t end += len\n\t if (end < 0) end = 0\n\t } else if (end > len) {\n\t end = len\n\t }\n\t\n\t if (end < start) end = start\n\t\n\t var newBuf = this.subarray(start, end)\n\t // Return an augmented `Uint8Array` instance\n\t newBuf.__proto__ = Buffer.prototype\n\t return newBuf\n\t}\n\t\n\t/*\n\t * Need to make sure that buffer isn't trying to write out of bounds.\n\t */\n\tfunction checkOffset (offset, ext, length) {\n\t if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n\t if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n\t}\n\t\n\tBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n\t offset = offset >>> 0\n\t byteLength = byteLength >>> 0\n\t if (!noAssert) checkOffset(offset, byteLength, this.length)\n\t\n\t var val = this[offset]\n\t var mul = 1\n\t var i = 0\n\t while (++i < byteLength && (mul *= 0x100)) {\n\t val += this[offset + i] * mul\n\t }\n\t\n\t return val\n\t}\n\t\n\tBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n\t offset = offset >>> 0\n\t byteLength = byteLength >>> 0\n\t if (!noAssert) {\n\t checkOffset(offset, byteLength, this.length)\n\t }\n\t\n\t var val = this[offset + --byteLength]\n\t var mul = 1\n\t while (byteLength > 0 && (mul *= 0x100)) {\n\t val += this[offset + --byteLength] * mul\n\t }\n\t\n\t return val\n\t}\n\t\n\tBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 1, this.length)\n\t return this[offset]\n\t}\n\t\n\tBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 2, this.length)\n\t return this[offset] | (this[offset + 1] << 8)\n\t}\n\t\n\tBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 2, this.length)\n\t return (this[offset] << 8) | this[offset + 1]\n\t}\n\t\n\tBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 4, this.length)\n\t\n\t return ((this[offset]) |\n\t (this[offset + 1] << 8) |\n\t (this[offset + 2] << 16)) +\n\t (this[offset + 3] * 0x1000000)\n\t}\n\t\n\tBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 4, this.length)\n\t\n\t return (this[offset] * 0x1000000) +\n\t ((this[offset + 1] << 16) |\n\t (this[offset + 2] << 8) |\n\t this[offset + 3])\n\t}\n\t\n\tBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n\t offset = offset >>> 0\n\t byteLength = byteLength >>> 0\n\t if (!noAssert) checkOffset(offset, byteLength, this.length)\n\t\n\t var val = this[offset]\n\t var mul = 1\n\t var i = 0\n\t while (++i < byteLength && (mul *= 0x100)) {\n\t val += this[offset + i] * mul\n\t }\n\t mul *= 0x80\n\t\n\t if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\t\n\t return val\n\t}\n\t\n\tBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n\t offset = offset >>> 0\n\t byteLength = byteLength >>> 0\n\t if (!noAssert) checkOffset(offset, byteLength, this.length)\n\t\n\t var i = byteLength\n\t var mul = 1\n\t var val = this[offset + --i]\n\t while (i > 0 && (mul *= 0x100)) {\n\t val += this[offset + --i] * mul\n\t }\n\t mul *= 0x80\n\t\n\t if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\t\n\t return val\n\t}\n\t\n\tBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 1, this.length)\n\t if (!(this[offset] & 0x80)) return (this[offset])\n\t return ((0xff - this[offset] + 1) * -1)\n\t}\n\t\n\tBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 2, this.length)\n\t var val = this[offset] | (this[offset + 1] << 8)\n\t return (val & 0x8000) ? val | 0xFFFF0000 : val\n\t}\n\t\n\tBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 2, this.length)\n\t var val = this[offset + 1] | (this[offset] << 8)\n\t return (val & 0x8000) ? val | 0xFFFF0000 : val\n\t}\n\t\n\tBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 4, this.length)\n\t\n\t return (this[offset]) |\n\t (this[offset + 1] << 8) |\n\t (this[offset + 2] << 16) |\n\t (this[offset + 3] << 24)\n\t}\n\t\n\tBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 4, this.length)\n\t\n\t return (this[offset] << 24) |\n\t (this[offset + 1] << 16) |\n\t (this[offset + 2] << 8) |\n\t (this[offset + 3])\n\t}\n\t\n\tBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 4, this.length)\n\t return ieee754.read(this, offset, true, 23, 4)\n\t}\n\t\n\tBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 4, this.length)\n\t return ieee754.read(this, offset, false, 23, 4)\n\t}\n\t\n\tBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 8, this.length)\n\t return ieee754.read(this, offset, true, 52, 8)\n\t}\n\t\n\tBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n\t offset = offset >>> 0\n\t if (!noAssert) checkOffset(offset, 8, this.length)\n\t return ieee754.read(this, offset, false, 52, 8)\n\t}\n\t\n\tfunction checkInt (buf, value, offset, ext, max, min) {\n\t if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n\t if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n\t if (offset + ext > buf.length) throw new RangeError('Index out of range')\n\t}\n\t\n\tBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t byteLength = byteLength >>> 0\n\t if (!noAssert) {\n\t var maxBytes = Math.pow(2, 8 * byteLength) - 1\n\t checkInt(this, value, offset, byteLength, maxBytes, 0)\n\t }\n\t\n\t var mul = 1\n\t var i = 0\n\t this[offset] = value & 0xFF\n\t while (++i < byteLength && (mul *= 0x100)) {\n\t this[offset + i] = (value / mul) & 0xFF\n\t }\n\t\n\t return offset + byteLength\n\t}\n\t\n\tBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t byteLength = byteLength >>> 0\n\t if (!noAssert) {\n\t var maxBytes = Math.pow(2, 8 * byteLength) - 1\n\t checkInt(this, value, offset, byteLength, maxBytes, 0)\n\t }\n\t\n\t var i = byteLength - 1\n\t var mul = 1\n\t this[offset + i] = value & 0xFF\n\t while (--i >= 0 && (mul *= 0x100)) {\n\t this[offset + i] = (value / mul) & 0xFF\n\t }\n\t\n\t return offset + byteLength\n\t}\n\t\n\tBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n\t this[offset] = (value & 0xff)\n\t return offset + 1\n\t}\n\t\n\tBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n\t this[offset] = (value & 0xff)\n\t this[offset + 1] = (value >>> 8)\n\t return offset + 2\n\t}\n\t\n\tBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n\t this[offset] = (value >>> 8)\n\t this[offset + 1] = (value & 0xff)\n\t return offset + 2\n\t}\n\t\n\tBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n\t this[offset + 3] = (value >>> 24)\n\t this[offset + 2] = (value >>> 16)\n\t this[offset + 1] = (value >>> 8)\n\t this[offset] = (value & 0xff)\n\t return offset + 4\n\t}\n\t\n\tBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n\t this[offset] = (value >>> 24)\n\t this[offset + 1] = (value >>> 16)\n\t this[offset + 2] = (value >>> 8)\n\t this[offset + 3] = (value & 0xff)\n\t return offset + 4\n\t}\n\t\n\tBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) {\n\t var limit = Math.pow(2, (8 * byteLength) - 1)\n\t\n\t checkInt(this, value, offset, byteLength, limit - 1, -limit)\n\t }\n\t\n\t var i = 0\n\t var mul = 1\n\t var sub = 0\n\t this[offset] = value & 0xFF\n\t while (++i < byteLength && (mul *= 0x100)) {\n\t if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n\t sub = 1\n\t }\n\t this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n\t }\n\t\n\t return offset + byteLength\n\t}\n\t\n\tBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) {\n\t var limit = Math.pow(2, (8 * byteLength) - 1)\n\t\n\t checkInt(this, value, offset, byteLength, limit - 1, -limit)\n\t }\n\t\n\t var i = byteLength - 1\n\t var mul = 1\n\t var sub = 0\n\t this[offset + i] = value & 0xFF\n\t while (--i >= 0 && (mul *= 0x100)) {\n\t if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n\t sub = 1\n\t }\n\t this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n\t }\n\t\n\t return offset + byteLength\n\t}\n\t\n\tBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n\t if (value < 0) value = 0xff + value + 1\n\t this[offset] = (value & 0xff)\n\t return offset + 1\n\t}\n\t\n\tBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n\t this[offset] = (value & 0xff)\n\t this[offset + 1] = (value >>> 8)\n\t return offset + 2\n\t}\n\t\n\tBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n\t this[offset] = (value >>> 8)\n\t this[offset + 1] = (value & 0xff)\n\t return offset + 2\n\t}\n\t\n\tBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n\t this[offset] = (value & 0xff)\n\t this[offset + 1] = (value >>> 8)\n\t this[offset + 2] = (value >>> 16)\n\t this[offset + 3] = (value >>> 24)\n\t return offset + 4\n\t}\n\t\n\tBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n\t if (value < 0) value = 0xffffffff + value + 1\n\t this[offset] = (value >>> 24)\n\t this[offset + 1] = (value >>> 16)\n\t this[offset + 2] = (value >>> 8)\n\t this[offset + 3] = (value & 0xff)\n\t return offset + 4\n\t}\n\t\n\tfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n\t if (offset + ext > buf.length) throw new RangeError('Index out of range')\n\t if (offset < 0) throw new RangeError('Index out of range')\n\t}\n\t\n\tfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) {\n\t checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n\t }\n\t ieee754.write(buf, value, offset, littleEndian, 23, 4)\n\t return offset + 4\n\t}\n\t\n\tBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n\t return writeFloat(this, value, offset, true, noAssert)\n\t}\n\t\n\tBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n\t return writeFloat(this, value, offset, false, noAssert)\n\t}\n\t\n\tfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n\t value = +value\n\t offset = offset >>> 0\n\t if (!noAssert) {\n\t checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n\t }\n\t ieee754.write(buf, value, offset, littleEndian, 52, 8)\n\t return offset + 8\n\t}\n\t\n\tBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n\t return writeDouble(this, value, offset, true, noAssert)\n\t}\n\t\n\tBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n\t return writeDouble(this, value, offset, false, noAssert)\n\t}\n\t\n\t// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\n\tBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n\t if (!start) start = 0\n\t if (!end && end !== 0) end = this.length\n\t if (targetStart >= target.length) targetStart = target.length\n\t if (!targetStart) targetStart = 0\n\t if (end > 0 && end < start) end = start\n\t\n\t // Copy 0 bytes; we're done\n\t if (end === start) return 0\n\t if (target.length === 0 || this.length === 0) return 0\n\t\n\t // Fatal error conditions\n\t if (targetStart < 0) {\n\t throw new RangeError('targetStart out of bounds')\n\t }\n\t if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n\t if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\t\n\t // Are we oob?\n\t if (end > this.length) end = this.length\n\t if (target.length - targetStart < end - start) {\n\t end = target.length - targetStart + start\n\t }\n\t\n\t var len = end - start\n\t var i\n\t\n\t if (this === target && start < targetStart && targetStart < end) {\n\t // descending copy from end\n\t for (i = len - 1; i >= 0; --i) {\n\t target[i + targetStart] = this[i + start]\n\t }\n\t } else if (len < 1000) {\n\t // ascending copy from start\n\t for (i = 0; i < len; ++i) {\n\t target[i + targetStart] = this[i + start]\n\t }\n\t } else {\n\t Uint8Array.prototype.set.call(\n\t target,\n\t this.subarray(start, start + len),\n\t targetStart\n\t )\n\t }\n\t\n\t return len\n\t}\n\t\n\t// Usage:\n\t// buffer.fill(number[, offset[, end]])\n\t// buffer.fill(buffer[, offset[, end]])\n\t// buffer.fill(string[, offset[, end]][, encoding])\n\tBuffer.prototype.fill = function fill (val, start, end, encoding) {\n\t // Handle string cases:\n\t if (typeof val === 'string') {\n\t if (typeof start === 'string') {\n\t encoding = start\n\t start = 0\n\t end = this.length\n\t } else if (typeof end === 'string') {\n\t encoding = end\n\t end = this.length\n\t }\n\t if (val.length === 1) {\n\t var code = val.charCodeAt(0)\n\t if (code < 256) {\n\t val = code\n\t }\n\t }\n\t if (encoding !== undefined && typeof encoding !== 'string') {\n\t throw new TypeError('encoding must be a string')\n\t }\n\t if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n\t throw new TypeError('Unknown encoding: ' + encoding)\n\t }\n\t } else if (typeof val === 'number') {\n\t val = val & 255\n\t }\n\t\n\t // Invalid ranges are not set to a default, so can range check early.\n\t if (start < 0 || this.length < start || this.length < end) {\n\t throw new RangeError('Out of range index')\n\t }\n\t\n\t if (end <= start) {\n\t return this\n\t }\n\t\n\t start = start >>> 0\n\t end = end === undefined ? this.length : end >>> 0\n\t\n\t if (!val) val = 0\n\t\n\t var i\n\t if (typeof val === 'number') {\n\t for (i = start; i < end; ++i) {\n\t this[i] = val\n\t }\n\t } else {\n\t var bytes = Buffer.isBuffer(val)\n\t ? val\n\t : new Buffer(val, encoding)\n\t var len = bytes.length\n\t for (i = 0; i < end - start; ++i) {\n\t this[i + start] = bytes[i % len]\n\t }\n\t }\n\t\n\t return this\n\t}\n\t\n\t// HELPER FUNCTIONS\n\t// ================\n\t\n\tvar INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\t\n\tfunction base64clean (str) {\n\t // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n\t str = str.trim().replace(INVALID_BASE64_RE, '')\n\t // Node converts strings with length < 2 to ''\n\t if (str.length < 2) return ''\n\t // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n\t while (str.length % 4 !== 0) {\n\t str = str + '='\n\t }\n\t return str\n\t}\n\t\n\tfunction toHex (n) {\n\t if (n < 16) return '0' + n.toString(16)\n\t return n.toString(16)\n\t}\n\t\n\tfunction utf8ToBytes (string, units) {\n\t units = units || Infinity\n\t var codePoint\n\t var length = string.length\n\t var leadSurrogate = null\n\t var bytes = []\n\t\n\t for (var i = 0; i < length; ++i) {\n\t codePoint = string.charCodeAt(i)\n\t\n\t // is surrogate component\n\t if (codePoint > 0xD7FF && codePoint < 0xE000) {\n\t // last char was a lead\n\t if (!leadSurrogate) {\n\t // no lead yet\n\t if (codePoint > 0xDBFF) {\n\t // unexpected trail\n\t if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n\t continue\n\t } else if (i + 1 === length) {\n\t // unpaired lead\n\t if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n\t continue\n\t }\n\t\n\t // valid lead\n\t leadSurrogate = codePoint\n\t\n\t continue\n\t }\n\t\n\t // 2 leads in a row\n\t if (codePoint < 0xDC00) {\n\t if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n\t leadSurrogate = codePoint\n\t continue\n\t }\n\t\n\t // valid surrogate pair\n\t codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n\t } else if (leadSurrogate) {\n\t // valid bmp char, but last char was a lead\n\t if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n\t }\n\t\n\t leadSurrogate = null\n\t\n\t // encode utf8\n\t if (codePoint < 0x80) {\n\t if ((units -= 1) < 0) break\n\t bytes.push(codePoint)\n\t } else if (codePoint < 0x800) {\n\t if ((units -= 2) < 0) break\n\t bytes.push(\n\t codePoint >> 0x6 | 0xC0,\n\t codePoint & 0x3F | 0x80\n\t )\n\t } else if (codePoint < 0x10000) {\n\t if ((units -= 3) < 0) break\n\t bytes.push(\n\t codePoint >> 0xC | 0xE0,\n\t codePoint >> 0x6 & 0x3F | 0x80,\n\t codePoint & 0x3F | 0x80\n\t )\n\t } else if (codePoint < 0x110000) {\n\t if ((units -= 4) < 0) break\n\t bytes.push(\n\t codePoint >> 0x12 | 0xF0,\n\t codePoint >> 0xC & 0x3F | 0x80,\n\t codePoint >> 0x6 & 0x3F | 0x80,\n\t codePoint & 0x3F | 0x80\n\t )\n\t } else {\n\t throw new Error('Invalid code point')\n\t }\n\t }\n\t\n\t return bytes\n\t}\n\t\n\tfunction asciiToBytes (str) {\n\t var byteArray = []\n\t for (var i = 0; i < str.length; ++i) {\n\t // Node's code seems to be doing this and not & 0x7F..\n\t byteArray.push(str.charCodeAt(i) & 0xFF)\n\t }\n\t return byteArray\n\t}\n\t\n\tfunction utf16leToBytes (str, units) {\n\t var c, hi, lo\n\t var byteArray = []\n\t for (var i = 0; i < str.length; ++i) {\n\t if ((units -= 2) < 0) break\n\t\n\t c = str.charCodeAt(i)\n\t hi = c >> 8\n\t lo = c % 256\n\t byteArray.push(lo)\n\t byteArray.push(hi)\n\t }\n\t\n\t return byteArray\n\t}\n\t\n\tfunction base64ToBytes (str) {\n\t return base64.toByteArray(base64clean(str))\n\t}\n\t\n\tfunction blitBuffer (src, dst, offset, length) {\n\t for (var i = 0; i < length; ++i) {\n\t if ((i + offset >= dst.length) || (i >= src.length)) break\n\t dst[i + offset] = src[i]\n\t }\n\t return i\n\t}\n\t\n\t// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check\n\t// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166\n\tfunction isArrayBuffer (obj) {\n\t return obj instanceof ArrayBuffer ||\n\t (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&\n\t typeof obj.byteLength === 'number')\n\t}\n\t\n\t// Node 0.10 supports `ArrayBuffer` but lacks `ArrayBuffer.isView`\n\tfunction isArrayBufferView (obj) {\n\t return (typeof ArrayBuffer.isView === 'function') && ArrayBuffer.isView(obj)\n\t}\n\t\n\tfunction numberIsNaN (obj) {\n\t return obj !== obj // eslint-disable-line no-self-compare\n\t}\n\t\n\t/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)))\n\n/***/ },\n/* 3 */\n/***/ function(module, exports) {\n\n\t'use strict'\n\t\n\texports.byteLength = byteLength\n\texports.toByteArray = toByteArray\n\texports.fromByteArray = fromByteArray\n\t\n\tvar lookup = []\n\tvar revLookup = []\n\tvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\t\n\tvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\n\tfor (var i = 0, len = code.length; i < len; ++i) {\n\t lookup[i] = code[i]\n\t revLookup[code.charCodeAt(i)] = i\n\t}\n\t\n\trevLookup['-'.charCodeAt(0)] = 62\n\trevLookup['_'.charCodeAt(0)] = 63\n\t\n\tfunction placeHoldersCount (b64) {\n\t var len = b64.length\n\t if (len % 4 > 0) {\n\t throw new Error('Invalid string. Length must be a multiple of 4')\n\t }\n\t\n\t // the number of equal signs (place holders)\n\t // if there are two placeholders, than the two characters before it\n\t // represent one byte\n\t // if there is only one, then the three characters before it represent 2 bytes\n\t // this is just a cheap hack to not do indexOf twice\n\t return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0\n\t}\n\t\n\tfunction byteLength (b64) {\n\t // base64 is 4/3 + up to two characters of the original data\n\t return b64.length * 3 / 4 - placeHoldersCount(b64)\n\t}\n\t\n\tfunction toByteArray (b64) {\n\t var i, j, l, tmp, placeHolders, arr\n\t var len = b64.length\n\t placeHolders = placeHoldersCount(b64)\n\t\n\t arr = new Arr(len * 3 / 4 - placeHolders)\n\t\n\t // if there are placeholders, only get up to the last complete 4 chars\n\t l = placeHolders > 0 ? len - 4 : len\n\t\n\t var L = 0\n\t\n\t for (i = 0, j = 0; i < l; i += 4, j += 3) {\n\t tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]\n\t arr[L++] = (tmp >> 16) & 0xFF\n\t arr[L++] = (tmp >> 8) & 0xFF\n\t arr[L++] = tmp & 0xFF\n\t }\n\t\n\t if (placeHolders === 2) {\n\t tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)\n\t arr[L++] = tmp & 0xFF\n\t } else if (placeHolders === 1) {\n\t tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)\n\t arr[L++] = (tmp >> 8) & 0xFF\n\t arr[L++] = tmp & 0xFF\n\t }\n\t\n\t return arr\n\t}\n\t\n\tfunction tripletToBase64 (num) {\n\t return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]\n\t}\n\t\n\tfunction encodeChunk (uint8, start, end) {\n\t var tmp\n\t var output = []\n\t for (var i = start; i < end; i += 3) {\n\t tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])\n\t output.push(tripletToBase64(tmp))\n\t }\n\t return output.join('')\n\t}\n\t\n\tfunction fromByteArray (uint8) {\n\t var tmp\n\t var len = uint8.length\n\t var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n\t var output = ''\n\t var parts = []\n\t var maxChunkLength = 16383 // must be multiple of 3\n\t\n\t // go through the array every three bytes, we'll deal with trailing stuff later\n\t for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n\t parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n\t }\n\t\n\t // pad the end with zeros, but make sure to not forget the extra bytes\n\t if (extraBytes === 1) {\n\t tmp = uint8[len - 1]\n\t output += lookup[tmp >> 2]\n\t output += lookup[(tmp << 4) & 0x3F]\n\t output += '=='\n\t } else if (extraBytes === 2) {\n\t tmp = (uint8[len - 2] << 8) + (uint8[len - 1])\n\t output += lookup[tmp >> 10]\n\t output += lookup[(tmp >> 4) & 0x3F]\n\t output += lookup[(tmp << 2) & 0x3F]\n\t output += '='\n\t }\n\t\n\t parts.push(output)\n\t\n\t return parts.join('')\n\t}\n\n\n/***/ },\n/* 4 */\n/***/ function(module, exports) {\n\n\texports.read = function (buffer, offset, isLE, mLen, nBytes) {\n\t var e, m\n\t var eLen = nBytes * 8 - mLen - 1\n\t var eMax = (1 << eLen) - 1\n\t var eBias = eMax >> 1\n\t var nBits = -7\n\t var i = isLE ? (nBytes - 1) : 0\n\t var d = isLE ? -1 : 1\n\t var s = buffer[offset + i]\n\t\n\t i += d\n\t\n\t e = s & ((1 << (-nBits)) - 1)\n\t s >>= (-nBits)\n\t nBits += eLen\n\t for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}\n\t\n\t m = e & ((1 << (-nBits)) - 1)\n\t e >>= (-nBits)\n\t nBits += mLen\n\t for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}\n\t\n\t if (e === 0) {\n\t e = 1 - eBias\n\t } else if (e === eMax) {\n\t return m ? NaN : ((s ? -1 : 1) * Infinity)\n\t } else {\n\t m = m + Math.pow(2, mLen)\n\t e = e - eBias\n\t }\n\t return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n\t}\n\t\n\texports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n\t var e, m, c\n\t var eLen = nBytes * 8 - mLen - 1\n\t var eMax = (1 << eLen) - 1\n\t var eBias = eMax >> 1\n\t var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n\t var i = isLE ? 0 : (nBytes - 1)\n\t var d = isLE ? 1 : -1\n\t var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\t\n\t value = Math.abs(value)\n\t\n\t if (isNaN(value) || value === Infinity) {\n\t m = isNaN(value) ? 1 : 0\n\t e = eMax\n\t } else {\n\t e = Math.floor(Math.log(value) / Math.LN2)\n\t if (value * (c = Math.pow(2, -e)) < 1) {\n\t e--\n\t c *= 2\n\t }\n\t if (e + eBias >= 1) {\n\t value += rt / c\n\t } else {\n\t value += rt * Math.pow(2, 1 - eBias)\n\t }\n\t if (value * c >= 2) {\n\t e++\n\t c /= 2\n\t }\n\t\n\t if (e + eBias >= eMax) {\n\t m = 0\n\t e = eMax\n\t } else if (e + eBias >= 1) {\n\t m = (value * c - 1) * Math.pow(2, mLen)\n\t e = e + eBias\n\t } else {\n\t m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n\t e = 0\n\t }\n\t }\n\t\n\t for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\t\n\t e = (e << mLen) | m\n\t eLen += mLen\n\t for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\t\n\t buffer[offset + i - d] |= s * 128\n\t}\n\n\n/***/ },\n/* 5 */\n/***/ function(module, exports) {\n\n\tmodule.exports = function(module) {\r\n\t\tif(!module.webpackPolyfill) {\r\n\t\t\tmodule.deprecate = function() {};\r\n\t\t\tmodule.paths = [];\r\n\t\t\t// module.parent = undefined by default\r\n\t\t\tmodule.children = [];\r\n\t\t\tmodule.webpackPolyfill = 1;\r\n\t\t}\r\n\t\treturn module;\r\n\t}\r\n\n\n/***/ },\n/* 6 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t\"use strict\";\n\tvar Process = __webpack_require__(7);\n\tvar process = new Process(), processProxy = {};\n\tfunction defineKey(key) {\n\t if (processProxy[key]) {\n\t // Probably a builtin Object property we don't care about.\n\t return;\n\t }\n\t if (typeof process[key] === 'function') {\n\t processProxy[key] = function () {\n\t return process[key].apply(process, arguments);\n\t };\n\t }\n\t else {\n\t processProxy[key] = process[key];\n\t }\n\t}\n\tfor (var key in process) {\n\t // Don't check if process.hasOwnProperty; we want to also expose objects\n\t // up the prototype hierarchy.\n\t defineKey(key);\n\t}\n\t// Special key: Ensure we update public-facing values of stdin/stdout/stderr.\n\tprocessProxy.initializeTTYs = function () {\n\t if (process.stdin === null) {\n\t process.initializeTTYs();\n\t processProxy.stdin = process.stdin;\n\t processProxy.stdout = process.stdout;\n\t processProxy.stderr = process.stderr;\n\t }\n\t};\n\tprocess.nextTick(function () {\n\t processProxy.initializeTTYs();\n\t});\n\tmodule.exports = processProxy;\n\n\n/***/ },\n/* 7 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(__dirname) {\"use strict\";\n\tvar __extends = (this && this.__extends) || function (d, b) {\n\t for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n\t function __() { this.constructor = d; }\n\t d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n\t};\n\tvar events = __webpack_require__(8);\n\t// Path depends on process. Avoid a circular reference by dynamically including path when we need it.\n\tvar path = null;\n\tvar Item = (function () {\n\t function Item(fun, array) {\n\t this.fun = fun;\n\t this.array = array;\n\t }\n\t Item.prototype.run = function () {\n\t this.fun.apply(null, this.array);\n\t };\n\t return Item;\n\t}());\n\t/**\n\t * Contains a queue of Items for process.nextTick.\n\t * Inspired by node-process: https://github.com/defunctzombie/node-process\n\t */\n\tvar NextTickQueue = (function () {\n\t function NextTickQueue() {\n\t this._queue = [];\n\t this._draining = false;\n\t // Used/assigned by the drainQueue function.\n\t this._currentQueue = null;\n\t this._queueIndex = -1;\n\t }\n\t NextTickQueue.prototype.push = function (item) {\n\t var _this = this;\n\t if (this._queue.push(item) === 1 && !this._draining) {\n\t setTimeout(function () { return _this._drainQueue(); }, 0);\n\t }\n\t };\n\t NextTickQueue.prototype._cleanUpNextTick = function () {\n\t this._draining = false;\n\t if (this._currentQueue && this._currentQueue.length) {\n\t this._queue = this._currentQueue.concat(this._queue);\n\t }\n\t else {\n\t this._queueIndex = -1;\n\t }\n\t if (this._queue.length) {\n\t this._drainQueue();\n\t }\n\t };\n\t NextTickQueue.prototype._drainQueue = function () {\n\t var _this = this;\n\t if (this._draining) {\n\t return;\n\t }\n\t // If an Item throws an unhandled exception, this function will clean things up.\n\t var timeout = setTimeout(function () { return _this._cleanUpNextTick(); });\n\t this._draining = true;\n\t var len = this._queue.length;\n\t while (len) {\n\t this._currentQueue = this._queue;\n\t this._queue = [];\n\t while (++this._queueIndex < len) {\n\t if (this._currentQueue) {\n\t this._currentQueue[this._queueIndex].run();\n\t }\n\t }\n\t this._queueIndex = -1;\n\t len = this._queue.length;\n\t }\n\t this._currentQueue = null;\n\t this._draining = false;\n\t clearTimeout(timeout);\n\t };\n\t return NextTickQueue;\n\t}());\n\t/**\n\t * Partial implementation of Node's `process` module.\n\t * We implement the portions that are relevant for the filesystem.\n\t * @see http://nodejs.org/api/process.html\n\t * @class\n\t */\n\tvar Process = (function (_super) {\n\t __extends(Process, _super);\n\t function Process() {\n\t _super.apply(this, arguments);\n\t this.startTime = Date.now();\n\t this._cwd = '/';\n\t /**\n\t * Returns what platform you are running on.\n\t * @return [String]\n\t */\n\t this.platform = 'browser';\n\t this.argv = [];\n\t this.execArgv = [];\n\t this.stdout = null;\n\t this.stderr = null;\n\t this.stdin = null;\n\t this.domain = null;\n\t this._queue = new NextTickQueue();\n\t this.execPath = __dirname;\n\t this.env = {};\n\t this.exitCode = 0;\n\t this._gid = 1;\n\t this._uid = 1;\n\t this.version = 'v5.0';\n\t this.versions = {\n\t http_parser: '0.0',\n\t node: '5.0',\n\t v8: '0.0',\n\t uv: '0.0',\n\t zlib: '0.0',\n\t ares: '0.0',\n\t icu: '0.0',\n\t modules: '0',\n\t openssl: '0.0'\n\t };\n\t this.config = {\n\t target_defaults: { cflags: [],\n\t default_configuration: 'Release',\n\t defines: [],\n\t include_dirs: [],\n\t libraries: [] },\n\t variables: { clang: 0,\n\t host_arch: 'x32',\n\t node_install_npm: false,\n\t node_install_waf: false,\n\t node_prefix: '',\n\t node_shared_cares: false,\n\t node_shared_http_parser: false,\n\t node_shared_libuv: false,\n\t node_shared_zlib: false,\n\t node_shared_v8: false,\n\t node_use_dtrace: false,\n\t node_use_etw: false,\n\t node_use_openssl: false,\n\t node_shared_openssl: false,\n\t strict_aliasing: false,\n\t target_arch: 'x32',\n\t v8_use_snapshot: false,\n\t v8_no_strict_aliasing: 0,\n\t visibility: '' } };\n\t this.pid = (Math.random() * 1000) | 0;\n\t this.title = 'node';\n\t this.arch = 'x32';\n\t this._mask = 18;\n\t // Undefined in main thread. Worker-only.\n\t this.connected = undefined;\n\t }\n\t /**\n\t * Changes the current working directory.\n\t *\n\t * **Note**: BrowserFS does not validate that the directory actually exists.\n\t *\n\t * @example Usage example\n\t * console.log('Starting directory: ' + process.cwd());\n\t * process.chdir('/tmp');\n\t * console.log('New directory: ' + process.cwd());\n\t * @param [String] dir The directory to change to.\n\t */\n\t Process.prototype.chdir = function (dir) {\n\t // XXX: Circular dependency hack.\n\t if (path === null) {\n\t path = __webpack_require__(9);\n\t }\n\t this._cwd = path.resolve(dir);\n\t };\n\t /**\n\t * Returns the current working directory.\n\t * @example Usage example\n\t * console.log('Current directory: ' + process.cwd());\n\t * @return [String] The current working directory.\n\t */\n\t Process.prototype.cwd = function () {\n\t return this._cwd;\n\t };\n\t /**\n\t * Number of seconds BrowserFS has been running.\n\t * @return [Number]\n\t */\n\t Process.prototype.uptime = function () {\n\t return ((Date.now() - this.startTime) / 1000) | 0;\n\t };\n\t Process.prototype.nextTick = function (fun) {\n\t var args = [];\n\t for (var _i = 1; _i < arguments.length; _i++) {\n\t args[_i - 1] = arguments[_i];\n\t }\n\t this._queue.push(new Item(fun, args));\n\t };\n\t Process.prototype.abort = function () {\n\t this.emit('abort');\n\t };\n\t Process.prototype.exit = function (code) {\n\t this.exitCode = code;\n\t this.emit('exit', [code]);\n\t };\n\t Process.prototype.getgid = function () {\n\t return this._gid;\n\t };\n\t Process.prototype.setgid = function (gid) {\n\t if (typeof gid === 'number') {\n\t this._gid = gid;\n\t }\n\t else {\n\t this._gid = 1;\n\t }\n\t };\n\t Process.prototype.getuid = function () {\n\t return this._uid;\n\t };\n\t Process.prototype.setuid = function (uid) {\n\t if (typeof uid === 'number') {\n\t this._uid = uid;\n\t }\n\t else {\n\t this._uid = 1;\n\t }\n\t };\n\t Process.prototype.kill = function (pid, signal) {\n\t this.emit('kill', [pid, signal]);\n\t };\n\t Process.prototype.memoryUsage = function () {\n\t return { rss: 0, heapTotal: 0, heapUsed: 0 };\n\t };\n\t Process.prototype.umask = function (mask) {\n\t if (mask === void 0) { mask = this._mask; }\n\t var oldMask = this._mask;\n\t this._mask = mask;\n\t this.emit('umask', [mask]);\n\t return oldMask;\n\t };\n\t Process.prototype.hrtime = function () {\n\t var timeinfo;\n\t if (typeof performance !== 'undefined') {\n\t timeinfo = performance.now();\n\t }\n\t else if (Date['now']) {\n\t timeinfo = Date.now();\n\t }\n\t else {\n\t timeinfo = (new Date()).getTime();\n\t }\n\t var secs = (timeinfo / 1000) | 0;\n\t timeinfo -= secs * 1000;\n\t timeinfo = (timeinfo * 1000000) | 0;\n\t return [secs, timeinfo];\n\t };\n\t /**\n\t * [BFS only] Initialize the TTY devices.\n\t */\n\t Process.prototype.initializeTTYs = function () {\n\t // Guard against multiple invocations.\n\t if (this.stdout === null) {\n\t var TTY = __webpack_require__(10);\n\t this.stdout = new TTY();\n\t this.stderr = new TTY();\n\t this.stdin = new TTY();\n\t }\n\t };\n\t /**\n\t * Worker-only function; irrelevant here.\n\t */\n\t Process.prototype.disconnect = function () {\n\t };\n\t return Process;\n\t}(events.EventEmitter));\n\tmodule.exports = Process;\n\t\n\t/* WEBPACK VAR INJECTION */}.call(exports, \"/\"))\n\n/***/ },\n/* 8 */\n/***/ function(module, exports) {\n\n\t// Copyright Joyent, Inc. and other Node contributors.\n\t//\n\t// Permission is hereby granted, free of charge, to any person obtaining a\n\t// copy of this software and associated documentation files (the\n\t// \"Software\"), to deal in the Software without restriction, including\n\t// without limitation the rights to use, copy, modify, merge, publish,\n\t// distribute, sublicense, and/or sell copies of the Software, and to permit\n\t// persons to whom the Software is furnished to do so, subject to the\n\t// following conditions:\n\t//\n\t// The above copyright notice and this permission notice shall be included\n\t// in all copies or substantial portions of the Software.\n\t//\n\t// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n\t// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n\t// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n\t// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n\t// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n\t// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n\t// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\t\n\tfunction EventEmitter() {\n\t this._events = this._events || {};\n\t this._maxListeners = this._maxListeners || undefined;\n\t}\n\tmodule.exports = EventEmitter;\n\t\n\t// Backwards-compat with node 0.10.x\n\tEventEmitter.EventEmitter = EventEmitter;\n\t\n\tEventEmitter.prototype._events = undefined;\n\tEventEmitter.prototype._maxListeners = undefined;\n\t\n\t// By default EventEmitters will print a warning if more than 10 listeners are\n\t// added to it. This is a useful default which helps finding memory leaks.\n\tEventEmitter.defaultMaxListeners = 10;\n\t\n\t// Obviously not all Emitters should be limited to 10. This function allows\n\t// that to be increased. Set to zero for unlimited.\n\tEventEmitter.prototype.setMaxListeners = function(n) {\n\t if (!isNumber(n) || n < 0 || isNaN(n))\n\t throw TypeError('n must be a positive number');\n\t this._maxListeners = n;\n\t return this;\n\t};\n\t\n\tEventEmitter.prototype.emit = function(type) {\n\t var er, handler, len, args, i, listeners;\n\t\n\t if (!this._events)\n\t this._events = {};\n\t\n\t // If there is no 'error' event listener then throw.\n\t if (type === 'error') {\n\t if (!this._events.error ||\n\t (isObject(this._events.error) && !this._events.error.length)) {\n\t er = arguments[1];\n\t if (er instanceof Error) {\n\t throw er; // Unhandled 'error' event\n\t } else {\n\t // At least give some kind of context to the user\n\t var err = new Error('Uncaught, unspecified \"error\" event. (' + er + ')');\n\t err.context = er;\n\t throw err;\n\t }\n\t }\n\t }\n\t\n\t handler = this._events[type];\n\t\n\t if (isUndefined(handler))\n\t return false;\n\t\n\t if (isFunction(handler)) {\n\t switch (arguments.length) {\n\t // fast cases\n\t case 1:\n\t handler.call(this);\n\t break;\n\t case 2:\n\t handler.call(this, arguments[1]);\n\t break;\n\t case 3:\n\t handler.call(this, arguments[1], arguments[2]);\n\t break;\n\t // slower\n\t default:\n\t args = Array.prototype.slice.call(arguments, 1);\n\t handler.apply(this, args);\n\t }\n\t } else if (isObject(handler)) {\n\t args = Array.prototype.slice.call(arguments, 1);\n\t listeners = handler.slice();\n\t len = listeners.length;\n\t for (i = 0; i < len; i++)\n\t listeners[i].apply(this, args);\n\t }\n\t\n\t return true;\n\t};\n\t\n\tEventEmitter.prototype.addListener = function(type, listener) {\n\t var m;\n\t\n\t if (!isFunction(listener))\n\t throw TypeError('listener must be a function');\n\t\n\t if (!this._events)\n\t this._events = {};\n\t\n\t // To avoid recursion in the case that type === \"newListener\"! Before\n\t // adding it to the listeners, first emit \"newListener\".\n\t if (this._events.newListener)\n\t this.emit('newListener', type,\n\t isFunction(listener.listener) ?\n\t listener.listener : listener);\n\t\n\t if (!this._events[type])\n\t // Optimize the case of one listener. Don't need the extra array object.\n\t this._events[type] = listener;\n\t else if (isObject(this._events[type]))\n\t // If we've already got an array, just append.\n\t this._events[type].push(listener);\n\t else\n\t // Adding the second element, need to change to array.\n\t this._events[type] = [this._events[type], listener];\n\t\n\t // Check for listener leak\n\t if (isObject(this._events[type]) && !this._events[type].warned) {\n\t if (!isUndefined(this._maxListeners)) {\n\t m = this._maxListeners;\n\t } else {\n\t m = EventEmitter.defaultMaxListeners;\n\t }\n\t\n\t if (m && m > 0 && this._events[type].length > m) {\n\t this._events[type].warned = true;\n\t console.error('(node) warning: possible EventEmitter memory ' +\n\t 'leak detected. %d listeners added. ' +\n\t 'Use emitter.setMaxListeners() to increase limit.',\n\t this._events[type].length);\n\t if (typeof console.trace === 'function') {\n\t // not supported in IE 10\n\t console.trace();\n\t }\n\t }\n\t }\n\t\n\t return this;\n\t};\n\t\n\tEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\t\n\tEventEmitter.prototype.once = function(type, listener) {\n\t if (!isFunction(listener))\n\t throw TypeError('listener must be a function');\n\t\n\t var fired = false;\n\t\n\t function g() {\n\t this.removeListener(type, g);\n\t\n\t if (!fired) {\n\t fired = true;\n\t listener.apply(this, arguments);\n\t }\n\t }\n\t\n\t g.listener = listener;\n\t this.on(type, g);\n\t\n\t return this;\n\t};\n\t\n\t// emits a 'removeListener' event iff the listener was removed\n\tEventEmitter.prototype.removeListener = function(type, listener) {\n\t var list, position, length, i;\n\t\n\t if (!isFunction(listener))\n\t throw TypeError('listener must be a function');\n\t\n\t if (!this._events || !this._events[type])\n\t return this;\n\t\n\t list = this._events[type];\n\t length = list.length;\n\t position = -1;\n\t\n\t if (list === listener ||\n\t (isFunction(list.listener) && list.listener === listener)) {\n\t delete this._events[type];\n\t if (this._events.removeListener)\n\t this.emit('removeListener', type, listener);\n\t\n\t } else if (isObject(list)) {\n\t for (i = length; i-- > 0;) {\n\t if (list[i] === listener ||\n\t (list[i].listener && list[i].listener === listener)) {\n\t position = i;\n\t break;\n\t }\n\t }\n\t\n\t if (position < 0)\n\t return this;\n\t\n\t if (list.length === 1) {\n\t list.length = 0;\n\t delete this._events[type];\n\t } else {\n\t list.splice(position, 1);\n\t }\n\t\n\t if (this._events.removeListener)\n\t this.emit('removeListener', type, listener);\n\t }\n\t\n\t return this;\n\t};\n\t\n\tEventEmitter.prototype.removeAllListeners = function(type) {\n\t var key, listeners;\n\t\n\t if (!this._events)\n\t return this;\n\t\n\t // not listening for removeListener, no need to emit\n\t if (!this._events.removeListener) {\n\t if (arguments.length === 0)\n\t this._events = {};\n\t else if (this._events[type])\n\t delete this._events[type];\n\t return this;\n\t }\n\t\n\t // emit removeListener for all listeners on all events\n\t if (arguments.length === 0) {\n\t for (key in this._events) {\n\t if (key === 'removeListener') continue;\n\t this.removeAllListeners(key);\n\t }\n\t this.removeAllListeners('removeListener');\n\t this._events = {};\n\t return this;\n\t }\n\t\n\t listeners = this._events[type];\n\t\n\t if (isFunction(listeners)) {\n\t this.removeListener(type, listeners);\n\t } else if (listeners) {\n\t // LIFO order\n\t while (listeners.length)\n\t this.removeListener(type, listeners[listeners.length - 1]);\n\t }\n\t delete this._events[type];\n\t\n\t return this;\n\t};\n\t\n\tEventEmitter.prototype.listeners = function(type) {\n\t var ret;\n\t if (!this._events || !this._events[type])\n\t ret = [];\n\t else if (isFunction(this._events[type]))\n\t ret = [this._events[type]];\n\t else\n\t ret = this._events[type].slice();\n\t return ret;\n\t};\n\t\n\tEventEmitter.prototype.listenerCount = function(type) {\n\t if (this._events) {\n\t var evlistener = this._events[type];\n\t\n\t if (isFunction(evlistener))\n\t return 1;\n\t else if (evlistener)\n\t return evlistener.length;\n\t }\n\t return 0;\n\t};\n\t\n\tEventEmitter.listenerCount = function(emitter, type) {\n\t return emitter.listenerCount(type);\n\t};\n\t\n\tfunction isFunction(arg) {\n\t return typeof arg === 'function';\n\t}\n\t\n\tfunction isNumber(arg) {\n\t return typeof arg === 'number';\n\t}\n\t\n\tfunction isObject(arg) {\n\t return typeof arg === 'object' && arg !== null;\n\t}\n\t\n\tfunction isUndefined(arg) {\n\t return arg === void 0;\n\t}\n\n\n/***/ },\n/* 9 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(process) {\"use strict\";\n\t// Split a filename into [root, dir, basename, ext], unix version\n\t// 'root' is just a slash, or nothing.\n\tvar splitPathRe = /^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;\n\tfunction posixSplitPath(filename) {\n\t var out = splitPathRe.exec(filename);\n\t out.shift();\n\t return out;\n\t}\n\t/**\n\t * Emulates Node's `path` module. This module contains utilities for handling and\n\t * transforming file paths. **All** of these methods perform only string\n\t * transformations. The file system is not consulted to check whether paths are\n\t * valid.\n\t * @see http://nodejs.org/api/path.html\n\t * @class\n\t */\n\tvar path = (function () {\n\t function path() {\n\t }\n\t /**\n\t * Normalize a string path, taking care of '..' and '.' parts.\n\t *\n\t * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.\n\t * @example Usage example\n\t * path.normalize('/foo/bar//baz/asdf/quux/..')\n\t * // returns\n\t * '/foo/bar/baz/asdf'\n\t * @param [String] p The path to normalize.\n\t * @return [String]\n\t */\n\t path.normalize = function (p) {\n\t // Special case: '' -> '.'\n\t if (p === '') {\n\t p = '.';\n\t }\n\t // It's very important to know if the path is relative or not, since it\n\t // changes how we process .. and reconstruct the split string.\n\t var absolute = p.charAt(0) === path.sep;\n\t // Remove repeated //s\n\t p = path._removeDuplicateSeps(p);\n\t // Try to remove as many '../' as possible, and remove '.' completely.\n\t var components = p.split(path.sep);\n\t var goodComponents = [];\n\t for (var idx = 0; idx < components.length; idx++) {\n\t var c = components[idx];\n\t if (c === '.') {\n\t continue;\n\t }\n\t else if (c === '..' && (absolute || (!absolute && goodComponents.length > 0 && goodComponents[0] !== '..'))) {\n\t // In the absolute case: Path is relative to root, so we may pop even if\n\t // goodComponents is empty (e.g. /../ => /)\n\t // In the relative case: We're getting rid of a directory that preceded\n\t // it (e.g. /foo/../bar -> /bar)\n\t goodComponents.pop();\n\t }\n\t else {\n\t goodComponents.push(c);\n\t }\n\t }\n\t // Add in '.' when it's a relative path with no other nonempty components.\n\t // Possible results: '.' and './' (input: [''] or [])\n\t // @todo Can probably simplify this logic.\n\t if (!absolute && goodComponents.length < 2) {\n\t switch (goodComponents.length) {\n\t case 1:\n\t if (goodComponents[0] === '') {\n\t goodComponents.unshift('.');\n\t }\n\t break;\n\t default:\n\t goodComponents.push('.');\n\t }\n\t }\n\t p = goodComponents.join(path.sep);\n\t if (absolute && p.charAt(0) !== path.sep) {\n\t p = path.sep + p;\n\t }\n\t return p;\n\t };\n\t /**\n\t * Join all arguments together and normalize the resulting path.\n\t *\n\t * Arguments must be strings.\n\t * @example Usage\n\t * path.join('/foo', 'bar', 'baz/asdf', 'quux', '..')\n\t * // returns\n\t * '/foo/bar/baz/asdf'\n\t *\n\t * path.join('foo', {}, 'bar')\n\t * // throws exception\n\t * TypeError: Arguments to path.join must be strings\n\t * @param [String,...] paths Each component of the path\n\t * @return [String]\n\t */\n\t path.join = function () {\n\t var paths = [];\n\t for (var _i = 0; _i < arguments.length; _i++) {\n\t paths[_i - 0] = arguments[_i];\n\t }\n\t // Required: Prune any non-strings from the path. I also prune empty segments\n\t // so we can do a simple join of the array.\n\t var processed = [];\n\t for (var i = 0; i < paths.length; i++) {\n\t var segment = paths[i];\n\t if (typeof segment !== 'string') {\n\t throw new TypeError(\"Invalid argument type to path.join: \" + (typeof segment));\n\t }\n\t else if (segment !== '') {\n\t processed.push(segment);\n\t }\n\t }\n\t return path.normalize(processed.join(path.sep));\n\t };\n\t /**\n\t * Resolves to to an absolute path.\n\t *\n\t * If to isn't already absolute from arguments are prepended in right to left\n\t * order, until an absolute path is found. If after using all from paths still\n\t * no absolute path is found, the current working directory is used as well.\n\t * The resulting path is normalized, and trailing slashes are removed unless\n\t * the path gets resolved to the root directory. Non-string arguments are\n\t * ignored.\n\t *\n\t * Another way to think of it is as a sequence of cd commands in a shell.\n\t *\n\t * path.resolve('foo/bar', '/tmp/file/', '..', 'a/../subfile')\n\t *\n\t * Is similar to:\n\t *\n\t * cd foo/bar\n\t * cd /tmp/file/\n\t * cd ..\n\t * cd a/../subfile\n\t * pwd\n\t *\n\t * The difference is that the different paths don't need to exist and may also\n\t * be files.\n\t * @example Usage example\n\t * path.resolve('/foo/bar', './baz')\n\t * // returns\n\t * '/foo/bar/baz'\n\t *\n\t * path.resolve('/foo/bar', '/tmp/file/')\n\t * // returns\n\t * '/tmp/file'\n\t *\n\t * path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif')\n\t * // if currently in /home/myself/node, it returns\n\t * '/home/myself/node/wwwroot/static_files/gif/image.gif'\n\t * @param [String,...] paths\n\t * @return [String]\n\t */\n\t path.resolve = function () {\n\t var paths = [];\n\t for (var _i = 0; _i < arguments.length; _i++) {\n\t paths[_i - 0] = arguments[_i];\n\t }\n\t // Monitor for invalid paths, throw out empty paths, and look for the *last*\n\t // absolute path that we see.\n\t var processed = [];\n\t for (var i = 0; i < paths.length; i++) {\n\t var p = paths[i];\n\t if (typeof p !== 'string') {\n\t throw new TypeError(\"Invalid argument type to path.join: \" + (typeof p));\n\t }\n\t else if (p !== '') {\n\t // Remove anything that has occurred before this absolute path, as it\n\t // doesn't matter.\n\t if (p.charAt(0) === path.sep) {\n\t processed = [];\n\t }\n\t processed.push(p);\n\t }\n\t }\n\t // Special: Remove trailing slash unless it's the root\n\t var resolved = path.normalize(processed.join(path.sep));\n\t if (resolved.length > 1 && resolved.charAt(resolved.length - 1) === path.sep) {\n\t return resolved.substr(0, resolved.length - 1);\n\t }\n\t // Special: If it doesn't start with '/', it's relative and we need to append\n\t // the current directory.\n\t if (resolved.charAt(0) !== path.sep) {\n\t // Remove ./, since we're going to append the current directory.\n\t if (resolved.charAt(0) === '.' && (resolved.length === 1 || resolved.charAt(1) === path.sep)) {\n\t resolved = resolved.length === 1 ? '' : resolved.substr(2);\n\t }\n\t // Append the current directory, which *must* be an absolute path.\n\t var cwd = process.cwd();\n\t if (resolved !== '') {\n\t // cwd will never end in a /... unless it's the root.\n\t resolved = this.normalize(cwd + (cwd !== '/' ? path.sep : '') + resolved);\n\t }\n\t else {\n\t resolved = cwd;\n\t }\n\t }\n\t return resolved;\n\t };\n\t /**\n\t * Solve the relative path from from to to.\n\t *\n\t * At times we have two absolute paths, and we need to derive the relative path\n\t * from one to the other. This is actually the reverse transform of\n\t * path.resolve, which means we see that:\n\t *\n\t * path.resolve(from, path.relative(from, to)) == path.resolve(to)\n\t *\n\t * @example Usage example\n\t * path.relative('C:\\\\orandea\\\\test\\\\aaa', 'C:\\\\orandea\\\\impl\\\\bbb')\n\t * // returns\n\t * '..\\\\..\\\\impl\\\\bbb'\n\t *\n\t * path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb')\n\t * // returns\n\t * '../../impl/bbb'\n\t * @param [String] from\n\t * @param [String] to\n\t * @return [String]\n\t */\n\t path.relative = function (from, to) {\n\t var i;\n\t // Alright. Let's resolve these two to absolute paths and remove any\n\t // weirdness.\n\t from = path.resolve(from);\n\t to = path.resolve(to);\n\t var fromSegs = from.split(path.sep);\n\t var toSegs = to.split(path.sep);\n\t // Remove the first segment on both, as it's '' (both are absolute paths)\n\t toSegs.shift();\n\t fromSegs.shift();\n\t // There are two segments to this path:\n\t // * Going *up* the directory hierarchy with '..'\n\t // * Going *down* the directory hierarchy with foo/baz/bat.\n\t var upCount = 0;\n\t var downSegs = [];\n\t // Figure out how many things in 'from' are shared with 'to'.\n\t for (i = 0; i < fromSegs.length; i++) {\n\t var seg = fromSegs[i];\n\t if (seg === toSegs[i]) {\n\t continue;\n\t }\n\t // The rest of 'from', including the current element, indicates how many\n\t // directories we need to go up.\n\t upCount = fromSegs.length - i;\n\t break;\n\t }\n\t // The rest of 'to' indicates where we need to change to. We place this\n\t // outside of the loop, as toSegs.length may be greater than fromSegs.length.\n\t downSegs = toSegs.slice(i);\n\t // Special case: If 'from' is '/'\n\t if (fromSegs.length === 1 && fromSegs[0] === '') {\n\t upCount = 0;\n\t }\n\t // upCount can't be greater than the number of fromSegs\n\t // (cd .. from / is still /)\n\t if (upCount > fromSegs.length) {\n\t upCount = fromSegs.length;\n\t }\n\t // Create the final string!\n\t var rv = '';\n\t for (i = 0; i < upCount; i++) {\n\t rv += '../';\n\t }\n\t rv += downSegs.join(path.sep);\n\t // Special case: Remove trailing '/'. Happens if it's all up and no down.\n\t if (rv.length > 1 && rv.charAt(rv.length - 1) === path.sep) {\n\t rv = rv.substr(0, rv.length - 1);\n\t }\n\t return rv;\n\t };\n\t /**\n\t * Return the directory name of a path. Similar to the Unix `dirname` command.\n\t *\n\t * Note that BrowserFS does not validate if the path is actually a valid\n\t * directory.\n\t * @example Usage example\n\t * path.dirname('/foo/bar/baz/asdf/quux')\n\t * // returns\n\t * '/foo/bar/baz/asdf'\n\t * @param [String] p The path to get the directory name of.\n\t * @return [String]\n\t */\n\t path.dirname = function (p) {\n\t // We get rid of //, but we don't modify anything else (e.g. any extraneous .\n\t // and ../ are kept intact)\n\t p = path._removeDuplicateSeps(p);\n\t var absolute = p.charAt(0) === path.sep;\n\t var sections = p.split(path.sep);\n\t // Do 1 if it's /foo/bar, 2 if it's /foo/bar/\n\t if (sections.pop() === '' && sections.length > 0) {\n\t sections.pop();\n\t }\n\t // # of sections needs to be > 1 if absolute, since the first section is '' for '/'.\n\t // If not absolute, the first section is the first part of the path, and is OK\n\t // to return.\n\t if (sections.length > 1 || (sections.length === 1 && !absolute)) {\n\t return sections.join(path.sep);\n\t }\n\t else if (absolute) {\n\t return path.sep;\n\t }\n\t else {\n\t return '.';\n\t }\n\t };\n\t /**\n\t * Return the last portion of a path. Similar to the Unix basename command.\n\t * @example Usage example\n\t * path.basename('/foo/bar/baz/asdf/quux.html')\n\t * // returns\n\t * 'quux.html'\n\t *\n\t * path.basename('/foo/bar/baz/asdf/quux.html', '.html')\n\t * // returns\n\t * 'quux'\n\t * @param [String] p\n\t * @param [String?] ext\n\t * @return [String]\n\t */\n\t path.basename = function (p, ext) {\n\t if (ext === void 0) { ext = \"\"; }\n\t // Special case: Normalize will modify this to '.'\n\t if (p === '') {\n\t return p;\n\t }\n\t // Normalize the string first to remove any weirdness.\n\t p = path.normalize(p);\n\t // Get the last part of the string.\n\t var sections = p.split(path.sep);\n\t var lastPart = sections[sections.length - 1];\n\t // Special case: If it's empty, then we have a string like so: foo/\n\t // Meaning, 'foo' is guaranteed to be a directory.\n\t if (lastPart === '' && sections.length > 1) {\n\t return sections[sections.length - 2];\n\t }\n\t // Remove the extension, if need be.\n\t if (ext.length > 0) {\n\t var lastPartExt = lastPart.substr(lastPart.length - ext.length);\n\t if (lastPartExt === ext) {\n\t return lastPart.substr(0, lastPart.length - ext.length);\n\t }\n\t }\n\t return lastPart;\n\t };\n\t /**\n\t * Return the extension of the path, from the last '.' to end of string in the\n\t * last portion of the path. If there is no '.' in the last portion of the path\n\t * or the first character of it is '.', then it returns an empty string.\n\t * @example Usage example\n\t * path.extname('index.html')\n\t * // returns\n\t * '.html'\n\t *\n\t * path.extname('index.')\n\t * // returns\n\t * '.'\n\t *\n\t * path.extname('index')\n\t * // returns\n\t * ''\n\t * @param [String] p\n\t * @return [String]\n\t */\n\t path.extname = function (p) {\n\t p = path.normalize(p);\n\t var sections = p.split(path.sep);\n\t p = sections.pop();\n\t // Special case: foo/file.ext/ should return '.ext'\n\t if (p === '' && sections.length > 0) {\n\t p = sections.pop();\n\t }\n\t if (p === '..') {\n\t return '';\n\t }\n\t var i = p.lastIndexOf('.');\n\t if (i === -1 || i === 0) {\n\t return '';\n\t }\n\t return p.substr(i);\n\t };\n\t /**\n\t * Checks if the given path is an absolute path.\n\t *\n\t * Despite not being documented, this is a tested part of Node's path API.\n\t * @param [String] p\n\t * @return [Boolean] True if the path appears to be an absolute path.\n\t */\n\t path.isAbsolute = function (p) {\n\t return p.length > 0 && p.charAt(0) === path.sep;\n\t };\n\t /**\n\t * Unknown. Undocumented.\n\t */\n\t path._makeLong = function (p) {\n\t return p;\n\t };\n\t /**\n\t * Returns an object from a path string.\n\t */\n\t path.parse = function (p) {\n\t var allParts = posixSplitPath(p);\n\t return {\n\t root: allParts[0],\n\t dir: allParts[0] + allParts[1].slice(0, -1),\n\t base: allParts[2],\n\t ext: allParts[3],\n\t name: allParts[2].slice(0, allParts[2].length - allParts[3].length)\n\t };\n\t };\n\t path.format = function (pathObject) {\n\t if (pathObject === null || typeof pathObject !== 'object') {\n\t throw new TypeError(\"Parameter 'pathObject' must be an object, not \" + typeof pathObject);\n\t }\n\t var root = pathObject.root || '';\n\t if (typeof root !== 'string') {\n\t throw new TypeError(\"'pathObject.root' must be a string or undefined, not \" +\n\t typeof pathObject.root);\n\t }\n\t var dir = pathObject.dir ? pathObject.dir + path.sep : '';\n\t var base = pathObject.base || '';\n\t return dir + base;\n\t };\n\t path._removeDuplicateSeps = function (p) {\n\t p = p.replace(this._replaceRegex, this.sep);\n\t return p;\n\t };\n\t // The platform-specific file separator. BrowserFS uses `/`.\n\t path.sep = '/';\n\t path._replaceRegex = new RegExp(\"//+\", 'g');\n\t // The platform-specific path delimiter. BrowserFS uses `:`.\n\t path.delimiter = ':';\n\t path.posix = path;\n\t // XXX: Typing hack. We don't actually support win32.\n\t path.win32 = path;\n\t return path;\n\t}());\n\tvar _ = path;\n\tmodule.exports = path;\n\t\n\t/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))\n\n/***/ },\n/* 10 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(Buffer) {\"use strict\";\n\tvar __extends = (this && this.__extends) || function (d, b) {\n\t for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n\t function __() { this.constructor = d; }\n\t d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n\t};\n\tvar stream = __webpack_require__(11);\n\tvar TTY = (function (_super) {\n\t __extends(TTY, _super);\n\t function TTY() {\n\t _super.call(this);\n\t this.isRaw = false;\n\t this.columns = 80;\n\t this.rows = 120;\n\t this.isTTY = true;\n\t this._bufferedWrites = [];\n\t this._waitingForWrites = false;\n\t }\n\t /**\n\t * Toggle raw mode.\n\t */\n\t TTY.prototype.setRawMode = function (mode) {\n\t if (this.isRaw !== mode) {\n\t this.isRaw = mode;\n\t // [BFS] TTY implementations can use this to change their event emitting\n\t // patterns.\n\t this.emit('modeChange');\n\t }\n\t };\n\t /**\n\t * [BFS] Update the number of columns available on the terminal.\n\t */\n\t TTY.prototype.changeColumns = function (columns) {\n\t if (columns !== this.columns) {\n\t this.columns = columns;\n\t // Resize event.\n\t this.emit('resize');\n\t }\n\t };\n\t /**\n\t * [BFS] Update the number of rows available on the terminal.\n\t */\n\t TTY.prototype.changeRows = function (rows) {\n\t if (rows !== this.rows) {\n\t this.rows = rows;\n\t // Resize event.\n\t this.emit('resize');\n\t }\n\t };\n\t /**\n\t * Returns 'true' if the given object is a TTY.\n\t */\n\t TTY.isatty = function (fd) {\n\t return fd && fd instanceof TTY;\n\t };\n\t TTY.prototype._write = function (chunk, encoding, cb) {\n\t var error;\n\t try {\n\t var data;\n\t if (typeof (chunk) === 'string') {\n\t data = new Buffer(chunk, encoding);\n\t }\n\t else {\n\t data = chunk;\n\t }\n\t this._bufferedWrites.push(data);\n\t if (this._waitingForWrites) {\n\t this._read(1024);\n\t }\n\t }\n\t catch (e) {\n\t error = e;\n\t }\n\t finally {\n\t cb(error);\n\t }\n\t };\n\t TTY.prototype._read = function (size) {\n\t // Size is advisory -- we can ignore it.\n\t if (this._bufferedWrites.length === 0) {\n\t this._waitingForWrites = true;\n\t }\n\t else {\n\t while (this._bufferedWrites.length > 0) {\n\t this._waitingForWrites = this.push(this._bufferedWrites.shift());\n\t if (!this._waitingForWrites) {\n\t break;\n\t }\n\t }\n\t }\n\t };\n\t return TTY;\n\t}(stream.Duplex));\n\tmodule.exports = TTY;\n\t\n\t/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)))\n\n/***/ },\n/* 11 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t// Copyright Joyent, Inc. and other Node contributors.\n\t//\n\t// Permission is hereby granted, free of charge, to any person obtaining a\n\t// copy of this software and associated documentation files (the\n\t// \"Software\"), to deal in the Software without restriction, including\n\t// without limitation the rights to use, copy, modify, merge, publish,\n\t// distribute, sublicense, and/or sell copies of the Software, and to permit\n\t// persons to whom the Software is furnished to do so, subject to the\n\t// following conditions:\n\t//\n\t// The above copyright notice and this permission notice shall be included\n\t// in all copies or substantial portions of the Software.\n\t//\n\t// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n\t// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n\t// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n\t// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n\t// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n\t// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n\t// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\t\n\tmodule.exports = Stream;\n\t\n\tvar EE = __webpack_require__(8).EventEmitter;\n\tvar inherits = __webpack_require__(12);\n\t\n\tinherits(Stream, EE);\n\tStream.Readable = __webpack_require__(13);\n\tStream.Writable = __webpack_require__(27);\n\tStream.Duplex = __webpack_require__(28);\n\tStream.Transform = __webpack_require__(29);\n\tStream.PassThrough = __webpack_require__(30);\n\t\n\t// Backwards-compat with node 0.4.x\n\tStream.Stream = Stream;\n\t\n\t\n\t\n\t// old-style streams. Note that the pipe method (the only relevant\n\t// part of this class) is overridden in the Readable class.\n\t\n\tfunction Stream() {\n\t EE.call(this);\n\t}\n\t\n\tStream.prototype.pipe = function(dest, options) {\n\t var source = this;\n\t\n\t function ondata(chunk) {\n\t if (dest.writable) {\n\t if (false === dest.write(chunk) && source.pause) {\n\t source.pause();\n\t }\n\t }\n\t }\n\t\n\t source.on('data', ondata);\n\t\n\t function ondrain() {\n\t if (source.readable && source.resume) {\n\t source.resume();\n\t }\n\t }\n\t\n\t dest.on('drain', ondrain);\n\t\n\t // If the 'end' option is not supplied, dest.end() will be called when\n\t // source gets the 'end' or 'close' events. Only dest.end() once.\n\t if (!dest._isStdio && (!options || options.end !== false)) {\n\t source.on('end', onend);\n\t source.on('close', onclose);\n\t }\n\t\n\t var didOnEnd = false;\n\t function onend() {\n\t if (didOnEnd) return;\n\t didOnEnd = true;\n\t\n\t dest.end();\n\t }\n\t\n\t\n\t function onclose() {\n\t if (didOnEnd) return;\n\t didOnEnd = true;\n\t\n\t if (typeof dest.destroy === 'function') dest.destroy();\n\t }\n\t\n\t // don't leave dangling pipes when there are errors.\n\t function onerror(er) {\n\t cleanup();\n\t if (EE.listenerCount(this, 'error') === 0) {\n\t throw er; // Unhandled stream error in pipe.\n\t }\n\t }\n\t\n\t source.on('error', onerror);\n\t dest.on('error', onerror);\n\t\n\t // remove all the event listeners that were added.\n\t function cleanup() {\n\t source.removeListener('data', ondata);\n\t dest.removeListener('drain', ondrain);\n\t\n\t source.removeListener('end', onend);\n\t source.removeListener('close', onclose);\n\t\n\t source.removeListener('error', onerror);\n\t dest.removeListener('error', onerror);\n\t\n\t source.removeListener('end', cleanup);\n\t source.removeListener('close', cleanup);\n\t\n\t dest.removeListener('close', cleanup);\n\t }\n\t\n\t source.on('end', cleanup);\n\t source.on('close', cleanup);\n\t\n\t dest.on('close', cleanup);\n\t\n\t dest.emit('pipe', source);\n\t\n\t // Allow for unix-like usage: A.pipe(B).pipe(C)\n\t return dest;\n\t};\n\n\n/***/ },\n/* 12 */\n/***/ function(module, exports) {\n\n\tif (typeof Object.create === 'function') {\n\t // implementation from standard node.js 'util' module\n\t module.exports = function inherits(ctor, superCtor) {\n\t ctor.super_ = superCtor\n\t ctor.prototype = Object.create(superCtor.prototype, {\n\t constructor: {\n\t value: ctor,\n\t enumerable: false,\n\t writable: true,\n\t configurable: true\n\t }\n\t });\n\t };\n\t} else {\n\t // old school shim for old browsers\n\t module.exports = function inherits(ctor, superCtor) {\n\t ctor.super_ = superCtor\n\t var TempCtor = function () {}\n\t TempCtor.prototype = superCtor.prototype\n\t ctor.prototype = new TempCtor()\n\t ctor.prototype.constructor = ctor\n\t }\n\t}\n\n\n/***/ },\n/* 13 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(process) {var Stream = (function (){\n\t try {\n\t return __webpack_require__(11); // hack to fix a circular dependency issue when used with browserify\n\t } catch(_){}\n\t}());\n\texports = module.exports = __webpack_require__(14);\n\texports.Stream = Stream || exports;\n\texports.Readable = exports;\n\texports.Writable = __webpack_require__(22);\n\texports.Duplex = __webpack_require__(21);\n\texports.Transform = __webpack_require__(25);\n\texports.PassThrough = __webpack_require__(26);\n\t\n\tif (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) {\n\t module.exports = Stream;\n\t}\n\t\n\t/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))\n\n/***/ },\n/* 14 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(process) {'use strict';\n\t\n\tmodule.exports = Readable;\n\t\n\t/**/\n\tvar processNextTick = __webpack_require__(15);\n\t/**/\n\t\n\t/**/\n\tvar isArray = __webpack_require__(16);\n\t/**/\n\t\n\t/**/\n\tvar Duplex;\n\t/**/\n\t\n\tReadable.ReadableState = ReadableState;\n\t\n\t/**/\n\tvar EE = __webpack_require__(8).EventEmitter;\n\t\n\tvar EElistenerCount = function (emitter, type) {\n\t return emitter.listeners(type).length;\n\t};\n\t/**/\n\t\n\t/**/\n\tvar Stream;\n\t(function () {\n\t try {\n\t Stream = __webpack_require__(11);\n\t } catch (_) {} finally {\n\t if (!Stream) Stream = __webpack_require__(8).EventEmitter;\n\t }\n\t})();\n\t/**/\n\t\n\tvar Buffer = __webpack_require__(2).Buffer;\n\t/**/\n\tvar bufferShim = __webpack_require__(17);\n\t/**/\n\t\n\t/**/\n\tvar util = __webpack_require__(18);\n\tutil.inherits = __webpack_require__(12);\n\t/**/\n\t\n\t/**/\n\tvar debugUtil = __webpack_require__(19);\n\tvar debug = void 0;\n\tif (debugUtil && debugUtil.debuglog) {\n\t debug = debugUtil.debuglog('stream');\n\t} else {\n\t debug = function () {};\n\t}\n\t/**/\n\t\n\tvar BufferList = __webpack_require__(20);\n\tvar StringDecoder;\n\t\n\tutil.inherits(Readable, Stream);\n\t\n\tfunction prependListener(emitter, event, fn) {\n\t // Sadly this is not cacheable as some libraries bundle their own\n\t // event emitter implementation with them.\n\t if (typeof emitter.prependListener === 'function') {\n\t return emitter.prependListener(event, fn);\n\t } else {\n\t // This is a hack to make sure that our error handler is attached before any\n\t // userland ones. NEVER DO THIS. This is here only because this code needs\n\t // to continue to work with older versions of Node.js that do not include\n\t // the prependListener() method. The goal is to eventually remove this hack.\n\t if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];\n\t }\n\t}\n\t\n\tfunction ReadableState(options, stream) {\n\t Duplex = Duplex || __webpack_require__(21);\n\t\n\t options = options || {};\n\t\n\t // object stream flag. Used to make read(n) ignore n and to\n\t // make all the buffer merging and length checks go away\n\t this.objectMode = !!options.objectMode;\n\t\n\t if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;\n\t\n\t // the point at which it stops calling _read() to fill the buffer\n\t // Note: 0 is a valid value, means \"don't call _read preemptively ever\"\n\t var hwm = options.highWaterMark;\n\t var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\t this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;\n\t\n\t // cast to ints.\n\t this.highWaterMark = ~~this.highWaterMark;\n\t\n\t // A linked list is used to store data chunks instead of an array because the\n\t // linked list can remove elements from the beginning faster than\n\t // array.shift()\n\t this.buffer = new BufferList();\n\t this.length = 0;\n\t this.pipes = null;\n\t this.pipesCount = 0;\n\t this.flowing = null;\n\t this.ended = false;\n\t this.endEmitted = false;\n\t this.reading = false;\n\t\n\t // a flag to be able to tell if the onwrite cb is called immediately,\n\t // or on a later tick. We set this to true at first, because any\n\t // actions that shouldn't happen until \"later\" should generally also\n\t // not happen before the first write call.\n\t this.sync = true;\n\t\n\t // whenever we return null, then we set a flag to say\n\t // that we're awaiting a 'readable' event emission.\n\t this.needReadable = false;\n\t this.emittedReadable = false;\n\t this.readableListening = false;\n\t this.resumeScheduled = false;\n\t\n\t // Crypto is kind of old and crusty. Historically, its default string\n\t // encoding is 'binary' so we have to make this configurable.\n\t // Everything else in the universe uses 'utf8', though.\n\t this.defaultEncoding = options.defaultEncoding || 'utf8';\n\t\n\t // when piping, we only care about 'readable' events that happen\n\t // after read()ing all the bytes and not getting any pushback.\n\t this.ranOut = false;\n\t\n\t // the number of writers that are awaiting a drain event in .pipe()s\n\t this.awaitDrain = 0;\n\t\n\t // if true, a maybeReadMore has been scheduled\n\t this.readingMore = false;\n\t\n\t this.decoder = null;\n\t this.encoding = null;\n\t if (options.encoding) {\n\t if (!StringDecoder) StringDecoder = __webpack_require__(24).StringDecoder;\n\t this.decoder = new StringDecoder(options.encoding);\n\t this.encoding = options.encoding;\n\t }\n\t}\n\t\n\tfunction Readable(options) {\n\t Duplex = Duplex || __webpack_require__(21);\n\t\n\t if (!(this instanceof Readable)) return new Readable(options);\n\t\n\t this._readableState = new ReadableState(options, this);\n\t\n\t // legacy\n\t this.readable = true;\n\t\n\t if (options && typeof options.read === 'function') this._read = options.read;\n\t\n\t Stream.call(this);\n\t}\n\t\n\t// Manually shove something into the read() buffer.\n\t// This returns true if the highWaterMark has not been hit yet,\n\t// similar to how Writable.write() returns true if you should\n\t// write() some more.\n\tReadable.prototype.push = function (chunk, encoding) {\n\t var state = this._readableState;\n\t\n\t if (!state.objectMode && typeof chunk === 'string') {\n\t encoding = encoding || state.defaultEncoding;\n\t if (encoding !== state.encoding) {\n\t chunk = bufferShim.from(chunk, encoding);\n\t encoding = '';\n\t }\n\t }\n\t\n\t return readableAddChunk(this, state, chunk, encoding, false);\n\t};\n\t\n\t// Unshift should *always* be something directly out of read()\n\tReadable.prototype.unshift = function (chunk) {\n\t var state = this._readableState;\n\t return readableAddChunk(this, state, chunk, '', true);\n\t};\n\t\n\tReadable.prototype.isPaused = function () {\n\t return this._readableState.flowing === false;\n\t};\n\t\n\tfunction readableAddChunk(stream, state, chunk, encoding, addToFront) {\n\t var er = chunkInvalid(state, chunk);\n\t if (er) {\n\t stream.emit('error', er);\n\t } else if (chunk === null) {\n\t state.reading = false;\n\t onEofChunk(stream, state);\n\t } else if (state.objectMode || chunk && chunk.length > 0) {\n\t if (state.ended && !addToFront) {\n\t var e = new Error('stream.push() after EOF');\n\t stream.emit('error', e);\n\t } else if (state.endEmitted && addToFront) {\n\t var _e = new Error('stream.unshift() after end event');\n\t stream.emit('error', _e);\n\t } else {\n\t var skipAdd;\n\t if (state.decoder && !addToFront && !encoding) {\n\t chunk = state.decoder.write(chunk);\n\t skipAdd = !state.objectMode && chunk.length === 0;\n\t }\n\t\n\t if (!addToFront) state.reading = false;\n\t\n\t // Don't add to the buffer if we've decoded to an empty string chunk and\n\t // we're not in object mode\n\t if (!skipAdd) {\n\t // if we want the data now, just emit it.\n\t if (state.flowing && state.length === 0 && !state.sync) {\n\t stream.emit('data', chunk);\n\t stream.read(0);\n\t } else {\n\t // update the buffer info.\n\t state.length += state.objectMode ? 1 : chunk.length;\n\t if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);\n\t\n\t if (state.needReadable) emitReadable(stream);\n\t }\n\t }\n\t\n\t maybeReadMore(stream, state);\n\t }\n\t } else if (!addToFront) {\n\t state.reading = false;\n\t }\n\t\n\t return needMoreData(state);\n\t}\n\t\n\t// if it's past the high water mark, we can push in some more.\n\t// Also, if we have no data yet, we can stand some\n\t// more bytes. This is to work around cases where hwm=0,\n\t// such as the repl. Also, if the push() triggered a\n\t// readable event, and the user called read(largeNumber) such that\n\t// needReadable was set, then we ought to push more, so that another\n\t// 'readable' event will be triggered.\n\tfunction needMoreData(state) {\n\t return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);\n\t}\n\t\n\t// backwards compatibility.\n\tReadable.prototype.setEncoding = function (enc) {\n\t if (!StringDecoder) StringDecoder = __webpack_require__(24).StringDecoder;\n\t this._readableState.decoder = new StringDecoder(enc);\n\t this._readableState.encoding = enc;\n\t return this;\n\t};\n\t\n\t// Don't raise the hwm > 8MB\n\tvar MAX_HWM = 0x800000;\n\tfunction computeNewHighWaterMark(n) {\n\t if (n >= MAX_HWM) {\n\t n = MAX_HWM;\n\t } else {\n\t // Get the next highest power of 2 to prevent increasing hwm excessively in\n\t // tiny amounts\n\t n--;\n\t n |= n >>> 1;\n\t n |= n >>> 2;\n\t n |= n >>> 4;\n\t n |= n >>> 8;\n\t n |= n >>> 16;\n\t n++;\n\t }\n\t return n;\n\t}\n\t\n\t// This function is designed to be inlinable, so please take care when making\n\t// changes to the function body.\n\tfunction howMuchToRead(n, state) {\n\t if (n <= 0 || state.length === 0 && state.ended) return 0;\n\t if (state.objectMode) return 1;\n\t if (n !== n) {\n\t // Only flow one buffer at a time\n\t if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;\n\t }\n\t // If we're asking for more than the current hwm, then raise the hwm.\n\t if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);\n\t if (n <= state.length) return n;\n\t // Don't have enough\n\t if (!state.ended) {\n\t state.needReadable = true;\n\t return 0;\n\t }\n\t return state.length;\n\t}\n\t\n\t// you can override either this method, or the async _read(n) below.\n\tReadable.prototype.read = function (n) {\n\t debug('read', n);\n\t n = parseInt(n, 10);\n\t var state = this._readableState;\n\t var nOrig = n;\n\t\n\t if (n !== 0) state.emittedReadable = false;\n\t\n\t // if we're doing read(0) to trigger a readable event, but we\n\t // already have a bunch of data in the buffer, then just trigger\n\t // the 'readable' event and move on.\n\t if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {\n\t debug('read: emitReadable', state.length, state.ended);\n\t if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);\n\t return null;\n\t }\n\t\n\t n = howMuchToRead(n, state);\n\t\n\t // if we've ended, and we're now clear, then finish it up.\n\t if (n === 0 && state.ended) {\n\t if (state.length === 0) endReadable(this);\n\t return null;\n\t }\n\t\n\t // All the actual chunk generation logic needs to be\n\t // *below* the call to _read. The reason is that in certain\n\t // synthetic stream cases, such as passthrough streams, _read\n\t // may be a completely synchronous operation which may change\n\t // the state of the read buffer, providing enough data when\n\t // before there was *not* enough.\n\t //\n\t // So, the steps are:\n\t // 1. Figure out what the state of things will be after we do\n\t // a read from the buffer.\n\t //\n\t // 2. If that resulting state will trigger a _read, then call _read.\n\t // Note that this may be asynchronous, or synchronous. Yes, it is\n\t // deeply ugly to write APIs this way, but that still doesn't mean\n\t // that the Readable class should behave improperly, as streams are\n\t // designed to be sync/async agnostic.\n\t // Take note if the _read call is sync or async (ie, if the read call\n\t // has returned yet), so that we know whether or not it's safe to emit\n\t // 'readable' etc.\n\t //\n\t // 3. Actually pull the requested chunks out of the buffer and return.\n\t\n\t // if we need a readable event, then we need to do some reading.\n\t var doRead = state.needReadable;\n\t debug('need readable', doRead);\n\t\n\t // if we currently have less than the highWaterMark, then also read some\n\t if (state.length === 0 || state.length - n < state.highWaterMark) {\n\t doRead = true;\n\t debug('length less than watermark', doRead);\n\t }\n\t\n\t // however, if we've ended, then there's no point, and if we're already\n\t // reading, then it's unnecessary.\n\t if (state.ended || state.reading) {\n\t doRead = false;\n\t debug('reading or ended', doRead);\n\t } else if (doRead) {\n\t debug('do read');\n\t state.reading = true;\n\t state.sync = true;\n\t // if the length is currently zero, then we *need* a readable event.\n\t if (state.length === 0) state.needReadable = true;\n\t // call internal read method\n\t this._read(state.highWaterMark);\n\t state.sync = false;\n\t // If _read pushed data synchronously, then `reading` will be false,\n\t // and we need to re-evaluate how much data we can return to the user.\n\t if (!state.reading) n = howMuchToRead(nOrig, state);\n\t }\n\t\n\t var ret;\n\t if (n > 0) ret = fromList(n, state);else ret = null;\n\t\n\t if (ret === null) {\n\t state.needReadable = true;\n\t n = 0;\n\t } else {\n\t state.length -= n;\n\t }\n\t\n\t if (state.length === 0) {\n\t // If we have nothing in the buffer, then we want to know\n\t // as soon as we *do* get something into the buffer.\n\t if (!state.ended) state.needReadable = true;\n\t\n\t // If we tried to read() past the EOF, then emit end on the next tick.\n\t if (nOrig !== n && state.ended) endReadable(this);\n\t }\n\t\n\t if (ret !== null) this.emit('data', ret);\n\t\n\t return ret;\n\t};\n\t\n\tfunction chunkInvalid(state, chunk) {\n\t var er = null;\n\t if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {\n\t er = new TypeError('Invalid non-string/buffer chunk');\n\t }\n\t return er;\n\t}\n\t\n\tfunction onEofChunk(stream, state) {\n\t if (state.ended) return;\n\t if (state.decoder) {\n\t var chunk = state.decoder.end();\n\t if (chunk && chunk.length) {\n\t state.buffer.push(chunk);\n\t state.length += state.objectMode ? 1 : chunk.length;\n\t }\n\t }\n\t state.ended = true;\n\t\n\t // emit 'readable' now to make sure it gets picked up.\n\t emitReadable(stream);\n\t}\n\t\n\t// Don't emit readable right away in sync mode, because this can trigger\n\t// another read() call => stack overflow. This way, it might trigger\n\t// a nextTick recursion warning, but that's not so bad.\n\tfunction emitReadable(stream) {\n\t var state = stream._readableState;\n\t state.needReadable = false;\n\t if (!state.emittedReadable) {\n\t debug('emitReadable', state.flowing);\n\t state.emittedReadable = true;\n\t if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);\n\t }\n\t}\n\t\n\tfunction emitReadable_(stream) {\n\t debug('emit readable');\n\t stream.emit('readable');\n\t flow(stream);\n\t}\n\t\n\t// at this point, the user has presumably seen the 'readable' event,\n\t// and called read() to consume some data. that may have triggered\n\t// in turn another _read(n) call, in which case reading = true if\n\t// it's in progress.\n\t// However, if we're not ended, or reading, and the length < hwm,\n\t// then go ahead and try to read some more preemptively.\n\tfunction maybeReadMore(stream, state) {\n\t if (!state.readingMore) {\n\t state.readingMore = true;\n\t processNextTick(maybeReadMore_, stream, state);\n\t }\n\t}\n\t\n\tfunction maybeReadMore_(stream, state) {\n\t var len = state.length;\n\t while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {\n\t debug('maybeReadMore read 0');\n\t stream.read(0);\n\t if (len === state.length)\n\t // didn't get any data, stop spinning.\n\t break;else len = state.length;\n\t }\n\t state.readingMore = false;\n\t}\n\t\n\t// abstract method. to be overridden in specific implementation classes.\n\t// call cb(er, data) where data is <= n in length.\n\t// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n\t// arbitrary, and perhaps not very meaningful.\n\tReadable.prototype._read = function (n) {\n\t this.emit('error', new Error('_read() is not implemented'));\n\t};\n\t\n\tReadable.prototype.pipe = function (dest, pipeOpts) {\n\t var src = this;\n\t var state = this._readableState;\n\t\n\t switch (state.pipesCount) {\n\t case 0:\n\t state.pipes = dest;\n\t break;\n\t case 1:\n\t state.pipes = [state.pipes, dest];\n\t break;\n\t default:\n\t state.pipes.push(dest);\n\t break;\n\t }\n\t state.pipesCount += 1;\n\t debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);\n\t\n\t var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;\n\t\n\t var endFn = doEnd ? onend : cleanup;\n\t if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);\n\t\n\t dest.on('unpipe', onunpipe);\n\t function onunpipe(readable) {\n\t debug('onunpipe');\n\t if (readable === src) {\n\t cleanup();\n\t }\n\t }\n\t\n\t function onend() {\n\t debug('onend');\n\t dest.end();\n\t }\n\t\n\t // when the dest drains, it reduces the awaitDrain counter\n\t // on the source. This would be more elegant with a .once()\n\t // handler in flow(), but adding and removing repeatedly is\n\t // too slow.\n\t var ondrain = pipeOnDrain(src);\n\t dest.on('drain', ondrain);\n\t\n\t var cleanedUp = false;\n\t function cleanup() {\n\t debug('cleanup');\n\t // cleanup event handlers once the pipe is broken\n\t dest.removeListener('close', onclose);\n\t dest.removeListener('finish', onfinish);\n\t dest.removeListener('drain', ondrain);\n\t dest.removeListener('error', onerror);\n\t dest.removeListener('unpipe', onunpipe);\n\t src.removeListener('end', onend);\n\t src.removeListener('end', cleanup);\n\t src.removeListener('data', ondata);\n\t\n\t cleanedUp = true;\n\t\n\t // if the reader is waiting for a drain event from this\n\t // specific writer, then it would cause it to never start\n\t // flowing again.\n\t // So, if this is awaiting a drain, then we just call it now.\n\t // If we don't know, then assume that we are waiting for one.\n\t if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();\n\t }\n\t\n\t // If the user pushes more data while we're writing to dest then we'll end up\n\t // in ondata again. However, we only want to increase awaitDrain once because\n\t // dest will only emit one 'drain' event for the multiple writes.\n\t // => Introduce a guard on increasing awaitDrain.\n\t var increasedAwaitDrain = false;\n\t src.on('data', ondata);\n\t function ondata(chunk) {\n\t debug('ondata');\n\t increasedAwaitDrain = false;\n\t var ret = dest.write(chunk);\n\t if (false === ret && !increasedAwaitDrain) {\n\t // If the user unpiped during `dest.write()`, it is possible\n\t // to get stuck in a permanently paused state if that write\n\t // also returned false.\n\t // => Check whether `dest` is still a piping destination.\n\t if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {\n\t debug('false write response, pause', src._readableState.awaitDrain);\n\t src._readableState.awaitDrain++;\n\t increasedAwaitDrain = true;\n\t }\n\t src.pause();\n\t }\n\t }\n\t\n\t // if the dest has an error, then stop piping into it.\n\t // however, don't suppress the throwing behavior for this.\n\t function onerror(er) {\n\t debug('onerror', er);\n\t unpipe();\n\t dest.removeListener('error', onerror);\n\t if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);\n\t }\n\t\n\t // Make sure our error handler is attached before userland ones.\n\t prependListener(dest, 'error', onerror);\n\t\n\t // Both close and finish should trigger unpipe, but only once.\n\t function onclose() {\n\t dest.removeListener('finish', onfinish);\n\t unpipe();\n\t }\n\t dest.once('close', onclose);\n\t function onfinish() {\n\t debug('onfinish');\n\t dest.removeListener('close', onclose);\n\t unpipe();\n\t }\n\t dest.once('finish', onfinish);\n\t\n\t function unpipe() {\n\t debug('unpipe');\n\t src.unpipe(dest);\n\t }\n\t\n\t // tell the dest that it's being piped to\n\t dest.emit('pipe', src);\n\t\n\t // start the flow if it hasn't been started already.\n\t if (!state.flowing) {\n\t debug('pipe resume');\n\t src.resume();\n\t }\n\t\n\t return dest;\n\t};\n\t\n\tfunction pipeOnDrain(src) {\n\t return function () {\n\t var state = src._readableState;\n\t debug('pipeOnDrain', state.awaitDrain);\n\t if (state.awaitDrain) state.awaitDrain--;\n\t if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {\n\t state.flowing = true;\n\t flow(src);\n\t }\n\t };\n\t}\n\t\n\tReadable.prototype.unpipe = function (dest) {\n\t var state = this._readableState;\n\t\n\t // if we're not piping anywhere, then do nothing.\n\t if (state.pipesCount === 0) return this;\n\t\n\t // just one destination. most common case.\n\t if (state.pipesCount === 1) {\n\t // passed in one, but it's not the right one.\n\t if (dest && dest !== state.pipes) return this;\n\t\n\t if (!dest) dest = state.pipes;\n\t\n\t // got a match.\n\t state.pipes = null;\n\t state.pipesCount = 0;\n\t state.flowing = false;\n\t if (dest) dest.emit('unpipe', this);\n\t return this;\n\t }\n\t\n\t // slow case. multiple pipe destinations.\n\t\n\t if (!dest) {\n\t // remove all.\n\t var dests = state.pipes;\n\t var len = state.pipesCount;\n\t state.pipes = null;\n\t state.pipesCount = 0;\n\t state.flowing = false;\n\t\n\t for (var i = 0; i < len; i++) {\n\t dests[i].emit('unpipe', this);\n\t }return this;\n\t }\n\t\n\t // try to find the right one.\n\t var index = indexOf(state.pipes, dest);\n\t if (index === -1) return this;\n\t\n\t state.pipes.splice(index, 1);\n\t state.pipesCount -= 1;\n\t if (state.pipesCount === 1) state.pipes = state.pipes[0];\n\t\n\t dest.emit('unpipe', this);\n\t\n\t return this;\n\t};\n\t\n\t// set up data events if they are asked for\n\t// Ensure readable listeners eventually get something\n\tReadable.prototype.on = function (ev, fn) {\n\t var res = Stream.prototype.on.call(this, ev, fn);\n\t\n\t if (ev === 'data') {\n\t // Start flowing on next tick if stream isn't explicitly paused\n\t if (this._readableState.flowing !== false) this.resume();\n\t } else if (ev === 'readable') {\n\t var state = this._readableState;\n\t if (!state.endEmitted && !state.readableListening) {\n\t state.readableListening = state.needReadable = true;\n\t state.emittedReadable = false;\n\t if (!state.reading) {\n\t processNextTick(nReadingNextTick, this);\n\t } else if (state.length) {\n\t emitReadable(this, state);\n\t }\n\t }\n\t }\n\t\n\t return res;\n\t};\n\tReadable.prototype.addListener = Readable.prototype.on;\n\t\n\tfunction nReadingNextTick(self) {\n\t debug('readable nexttick read 0');\n\t self.read(0);\n\t}\n\t\n\t// pause() and resume() are remnants of the legacy readable stream API\n\t// If the user uses them, then switch into old mode.\n\tReadable.prototype.resume = function () {\n\t var state = this._readableState;\n\t if (!state.flowing) {\n\t debug('resume');\n\t state.flowing = true;\n\t resume(this, state);\n\t }\n\t return this;\n\t};\n\t\n\tfunction resume(stream, state) {\n\t if (!state.resumeScheduled) {\n\t state.resumeScheduled = true;\n\t processNextTick(resume_, stream, state);\n\t }\n\t}\n\t\n\tfunction resume_(stream, state) {\n\t if (!state.reading) {\n\t debug('resume read 0');\n\t stream.read(0);\n\t }\n\t\n\t state.resumeScheduled = false;\n\t state.awaitDrain = 0;\n\t stream.emit('resume');\n\t flow(stream);\n\t if (state.flowing && !state.reading) stream.read(0);\n\t}\n\t\n\tReadable.prototype.pause = function () {\n\t debug('call pause flowing=%j', this._readableState.flowing);\n\t if (false !== this._readableState.flowing) {\n\t debug('pause');\n\t this._readableState.flowing = false;\n\t this.emit('pause');\n\t }\n\t return this;\n\t};\n\t\n\tfunction flow(stream) {\n\t var state = stream._readableState;\n\t debug('flow', state.flowing);\n\t while (state.flowing && stream.read() !== null) {}\n\t}\n\t\n\t// wrap an old-style stream as the async data source.\n\t// This is *not* part of the readable stream interface.\n\t// It is an ugly unfortunate mess of history.\n\tReadable.prototype.wrap = function (stream) {\n\t var state = this._readableState;\n\t var paused = false;\n\t\n\t var self = this;\n\t stream.on('end', function () {\n\t debug('wrapped end');\n\t if (state.decoder && !state.ended) {\n\t var chunk = state.decoder.end();\n\t if (chunk && chunk.length) self.push(chunk);\n\t }\n\t\n\t self.push(null);\n\t });\n\t\n\t stream.on('data', function (chunk) {\n\t debug('wrapped data');\n\t if (state.decoder) chunk = state.decoder.write(chunk);\n\t\n\t // don't skip over falsy values in objectMode\n\t if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;\n\t\n\t var ret = self.push(chunk);\n\t if (!ret) {\n\t paused = true;\n\t stream.pause();\n\t }\n\t });\n\t\n\t // proxy all the other methods.\n\t // important when wrapping filters and duplexes.\n\t for (var i in stream) {\n\t if (this[i] === undefined && typeof stream[i] === 'function') {\n\t this[i] = function (method) {\n\t return function () {\n\t return stream[method].apply(stream, arguments);\n\t };\n\t }(i);\n\t }\n\t }\n\t\n\t // proxy certain important events.\n\t var events = ['error', 'close', 'destroy', 'pause', 'resume'];\n\t forEach(events, function (ev) {\n\t stream.on(ev, self.emit.bind(self, ev));\n\t });\n\t\n\t // when we try to consume some more bytes, simply unpause the\n\t // underlying stream.\n\t self._read = function (n) {\n\t debug('wrapped _read', n);\n\t if (paused) {\n\t paused = false;\n\t stream.resume();\n\t }\n\t };\n\t\n\t return self;\n\t};\n\t\n\t// exposed for testing purposes only.\n\tReadable._fromList = fromList;\n\t\n\t// Pluck off n bytes from an array of buffers.\n\t// Length is the combined lengths of all the buffers in the list.\n\t// This function is designed to be inlinable, so please take care when making\n\t// changes to the function body.\n\tfunction fromList(n, state) {\n\t // nothing buffered\n\t if (state.length === 0) return null;\n\t\n\t var ret;\n\t if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {\n\t // read it all, truncate the list\n\t if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);\n\t state.buffer.clear();\n\t } else {\n\t // read part of list\n\t ret = fromListPartial(n, state.buffer, state.decoder);\n\t }\n\t\n\t return ret;\n\t}\n\t\n\t// Extracts only enough buffered data to satisfy the amount requested.\n\t// This function is designed to be inlinable, so please take care when making\n\t// changes to the function body.\n\tfunction fromListPartial(n, list, hasStrings) {\n\t var ret;\n\t if (n < list.head.data.length) {\n\t // slice is the same for buffers and strings\n\t ret = list.head.data.slice(0, n);\n\t list.head.data = list.head.data.slice(n);\n\t } else if (n === list.head.data.length) {\n\t // first chunk is a perfect match\n\t ret = list.shift();\n\t } else {\n\t // result spans more than one buffer\n\t ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);\n\t }\n\t return ret;\n\t}\n\t\n\t// Copies a specified amount of characters from the list of buffered data\n\t// chunks.\n\t// This function is designed to be inlinable, so please take care when making\n\t// changes to the function body.\n\tfunction copyFromBufferString(n, list) {\n\t var p = list.head;\n\t var c = 1;\n\t var ret = p.data;\n\t n -= ret.length;\n\t while (p = p.next) {\n\t var str = p.data;\n\t var nb = n > str.length ? str.length : n;\n\t if (nb === str.length) ret += str;else ret += str.slice(0, n);\n\t n -= nb;\n\t if (n === 0) {\n\t if (nb === str.length) {\n\t ++c;\n\t if (p.next) list.head = p.next;else list.head = list.tail = null;\n\t } else {\n\t list.head = p;\n\t p.data = str.slice(nb);\n\t }\n\t break;\n\t }\n\t ++c;\n\t }\n\t list.length -= c;\n\t return ret;\n\t}\n\t\n\t// Copies a specified amount of bytes from the list of buffered data chunks.\n\t// This function is designed to be inlinable, so please take care when making\n\t// changes to the function body.\n\tfunction copyFromBuffer(n, list) {\n\t var ret = bufferShim.allocUnsafe(n);\n\t var p = list.head;\n\t var c = 1;\n\t p.data.copy(ret);\n\t n -= p.data.length;\n\t while (p = p.next) {\n\t var buf = p.data;\n\t var nb = n > buf.length ? buf.length : n;\n\t buf.copy(ret, ret.length - n, 0, nb);\n\t n -= nb;\n\t if (n === 0) {\n\t if (nb === buf.length) {\n\t ++c;\n\t if (p.next) list.head = p.next;else list.head = list.tail = null;\n\t } else {\n\t list.head = p;\n\t p.data = buf.slice(nb);\n\t }\n\t break;\n\t }\n\t ++c;\n\t }\n\t list.length -= c;\n\t return ret;\n\t}\n\t\n\tfunction endReadable(stream) {\n\t var state = stream._readableState;\n\t\n\t // If we get here before consuming all the bytes, then that is a\n\t // bug in node. Should never happen.\n\t if (state.length > 0) throw new Error('\"endReadable()\" called on non-empty stream');\n\t\n\t if (!state.endEmitted) {\n\t state.ended = true;\n\t processNextTick(endReadableNT, state, stream);\n\t }\n\t}\n\t\n\tfunction endReadableNT(state, stream) {\n\t // Check that we didn't get one last unshift.\n\t if (!state.endEmitted && state.length === 0) {\n\t state.endEmitted = true;\n\t stream.readable = false;\n\t stream.emit('end');\n\t }\n\t}\n\t\n\tfunction forEach(xs, f) {\n\t for (var i = 0, l = xs.length; i < l; i++) {\n\t f(xs[i], i);\n\t }\n\t}\n\t\n\tfunction indexOf(xs, x) {\n\t for (var i = 0, l = xs.length; i < l; i++) {\n\t if (xs[i] === x) return i;\n\t }\n\t return -1;\n\t}\n\t/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))\n\n/***/ },\n/* 15 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(process) {'use strict';\n\t\n\tif (!process.version ||\n\t process.version.indexOf('v0.') === 0 ||\n\t process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {\n\t module.exports = nextTick;\n\t} else {\n\t module.exports = process.nextTick;\n\t}\n\t\n\tfunction nextTick(fn, arg1, arg2, arg3) {\n\t if (typeof fn !== 'function') {\n\t throw new TypeError('\"callback\" argument must be a function');\n\t }\n\t var len = arguments.length;\n\t var args, i;\n\t switch (len) {\n\t case 0:\n\t case 1:\n\t return process.nextTick(fn);\n\t case 2:\n\t return process.nextTick(function afterTickOne() {\n\t fn.call(null, arg1);\n\t });\n\t case 3:\n\t return process.nextTick(function afterTickTwo() {\n\t fn.call(null, arg1, arg2);\n\t });\n\t case 4:\n\t return process.nextTick(function afterTickThree() {\n\t fn.call(null, arg1, arg2, arg3);\n\t });\n\t default:\n\t args = new Array(len - 1);\n\t i = 0;\n\t while (i < args.length) {\n\t args[i++] = arguments[i];\n\t }\n\t return process.nextTick(function afterTick() {\n\t fn.apply(null, args);\n\t });\n\t }\n\t}\n\t\n\t/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))\n\n/***/ },\n/* 16 */\n/***/ function(module, exports) {\n\n\tvar toString = {}.toString;\n\t\n\tmodule.exports = Array.isArray || function (arr) {\n\t return toString.call(arr) == '[object Array]';\n\t};\n\n\n/***/ },\n/* 17 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(global) {'use strict';\n\t\n\tvar buffer = __webpack_require__(2);\n\tvar Buffer = buffer.Buffer;\n\tvar SlowBuffer = buffer.SlowBuffer;\n\tvar MAX_LEN = buffer.kMaxLength || 2147483647;\n\texports.alloc = function alloc(size, fill, encoding) {\n\t if (typeof Buffer.alloc === 'function') {\n\t return Buffer.alloc(size, fill, encoding);\n\t }\n\t if (typeof encoding === 'number') {\n\t throw new TypeError('encoding must not be number');\n\t }\n\t if (typeof size !== 'number') {\n\t throw new TypeError('size must be a number');\n\t }\n\t if (size > MAX_LEN) {\n\t throw new RangeError('size is too large');\n\t }\n\t var enc = encoding;\n\t var _fill = fill;\n\t if (_fill === undefined) {\n\t enc = undefined;\n\t _fill = 0;\n\t }\n\t var buf = new Buffer(size);\n\t if (typeof _fill === 'string') {\n\t var fillBuf = new Buffer(_fill, enc);\n\t var flen = fillBuf.length;\n\t var i = -1;\n\t while (++i < size) {\n\t buf[i] = fillBuf[i % flen];\n\t }\n\t } else {\n\t buf.fill(_fill);\n\t }\n\t return buf;\n\t}\n\texports.allocUnsafe = function allocUnsafe(size) {\n\t if (typeof Buffer.allocUnsafe === 'function') {\n\t return Buffer.allocUnsafe(size);\n\t }\n\t if (typeof size !== 'number') {\n\t throw new TypeError('size must be a number');\n\t }\n\t if (size > MAX_LEN) {\n\t throw new RangeError('size is too large');\n\t }\n\t return new Buffer(size);\n\t}\n\texports.from = function from(value, encodingOrOffset, length) {\n\t if (typeof Buffer.from === 'function' && (!global.Uint8Array || Uint8Array.from !== Buffer.from)) {\n\t return Buffer.from(value, encodingOrOffset, length);\n\t }\n\t if (typeof value === 'number') {\n\t throw new TypeError('\"value\" argument must not be a number');\n\t }\n\t if (typeof value === 'string') {\n\t return new Buffer(value, encodingOrOffset);\n\t }\n\t if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n\t var offset = encodingOrOffset;\n\t if (arguments.length === 1) {\n\t return new Buffer(value);\n\t }\n\t if (typeof offset === 'undefined') {\n\t offset = 0;\n\t }\n\t var len = length;\n\t if (typeof len === 'undefined') {\n\t len = value.byteLength - offset;\n\t }\n\t if (offset >= value.byteLength) {\n\t throw new RangeError('\\'offset\\' is out of bounds');\n\t }\n\t if (len > value.byteLength - offset) {\n\t throw new RangeError('\\'length\\' is out of bounds');\n\t }\n\t return new Buffer(value.slice(offset, offset + len));\n\t }\n\t if (Buffer.isBuffer(value)) {\n\t var out = new Buffer(value.length);\n\t value.copy(out, 0, 0, value.length);\n\t return out;\n\t }\n\t if (value) {\n\t if (Array.isArray(value) || (typeof ArrayBuffer !== 'undefined' && value.buffer instanceof ArrayBuffer) || 'length' in value) {\n\t return new Buffer(value);\n\t }\n\t if (value.type === 'Buffer' && Array.isArray(value.data)) {\n\t return new Buffer(value.data);\n\t }\n\t }\n\t\n\t throw new TypeError('First argument must be a string, Buffer, ' + 'ArrayBuffer, Array, or array-like object.');\n\t}\n\texports.allocUnsafeSlow = function allocUnsafeSlow(size) {\n\t if (typeof Buffer.allocUnsafeSlow === 'function') {\n\t return Buffer.allocUnsafeSlow(size);\n\t }\n\t if (typeof size !== 'number') {\n\t throw new TypeError('size must be a number');\n\t }\n\t if (size >= MAX_LEN) {\n\t throw new RangeError('size is too large');\n\t }\n\t return new SlowBuffer(size);\n\t}\n\t\n\t/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))\n\n/***/ },\n/* 18 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors.\n\t//\n\t// Permission is hereby granted, free of charge, to any person obtaining a\n\t// copy of this software and associated documentation files (the\n\t// \"Software\"), to deal in the Software without restriction, including\n\t// without limitation the rights to use, copy, modify, merge, publish,\n\t// distribute, sublicense, and/or sell copies of the Software, and to permit\n\t// persons to whom the Software is furnished to do so, subject to the\n\t// following conditions:\n\t//\n\t// The above copyright notice and this permission notice shall be included\n\t// in all copies or substantial portions of the Software.\n\t//\n\t// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n\t// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n\t// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n\t// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n\t// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n\t// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n\t// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\t\n\t// NOTE: These type checking functions intentionally don't use `instanceof`\n\t// because it is fragile and can be easily faked with `Object.create()`.\n\t\n\tfunction isArray(arg) {\n\t if (Array.isArray) {\n\t return Array.isArray(arg);\n\t }\n\t return objectToString(arg) === '[object Array]';\n\t}\n\texports.isArray = isArray;\n\t\n\tfunction isBoolean(arg) {\n\t return typeof arg === 'boolean';\n\t}\n\texports.isBoolean = isBoolean;\n\t\n\tfunction isNull(arg) {\n\t return arg === null;\n\t}\n\texports.isNull = isNull;\n\t\n\tfunction isNullOrUndefined(arg) {\n\t return arg == null;\n\t}\n\texports.isNullOrUndefined = isNullOrUndefined;\n\t\n\tfunction isNumber(arg) {\n\t return typeof arg === 'number';\n\t}\n\texports.isNumber = isNumber;\n\t\n\tfunction isString(arg) {\n\t return typeof arg === 'string';\n\t}\n\texports.isString = isString;\n\t\n\tfunction isSymbol(arg) {\n\t return typeof arg === 'symbol';\n\t}\n\texports.isSymbol = isSymbol;\n\t\n\tfunction isUndefined(arg) {\n\t return arg === void 0;\n\t}\n\texports.isUndefined = isUndefined;\n\t\n\tfunction isRegExp(re) {\n\t return objectToString(re) === '[object RegExp]';\n\t}\n\texports.isRegExp = isRegExp;\n\t\n\tfunction isObject(arg) {\n\t return typeof arg === 'object' && arg !== null;\n\t}\n\texports.isObject = isObject;\n\t\n\tfunction isDate(d) {\n\t return objectToString(d) === '[object Date]';\n\t}\n\texports.isDate = isDate;\n\t\n\tfunction isError(e) {\n\t return (objectToString(e) === '[object Error]' || e instanceof Error);\n\t}\n\texports.isError = isError;\n\t\n\tfunction isFunction(arg) {\n\t return typeof arg === 'function';\n\t}\n\texports.isFunction = isFunction;\n\t\n\tfunction isPrimitive(arg) {\n\t return arg === null ||\n\t typeof arg === 'boolean' ||\n\t typeof arg === 'number' ||\n\t typeof arg === 'string' ||\n\t typeof arg === 'symbol' || // ES6 symbol\n\t typeof arg === 'undefined';\n\t}\n\texports.isPrimitive = isPrimitive;\n\t\n\texports.isBuffer = Buffer.isBuffer;\n\t\n\tfunction objectToString(o) {\n\t return Object.prototype.toString.call(o);\n\t}\n\t\n\t/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)))\n\n/***/ },\n/* 19 */\n/***/ function(module, exports) {\n\n\t/* (ignored) */\n\n/***/ },\n/* 20 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\tvar Buffer = __webpack_require__(2).Buffer;\n\t/**/\n\tvar bufferShim = __webpack_require__(17);\n\t/**/\n\t\n\tmodule.exports = BufferList;\n\t\n\tfunction BufferList() {\n\t this.head = null;\n\t this.tail = null;\n\t this.length = 0;\n\t}\n\t\n\tBufferList.prototype.push = function (v) {\n\t var entry = { data: v, next: null };\n\t if (this.length > 0) this.tail.next = entry;else this.head = entry;\n\t this.tail = entry;\n\t ++this.length;\n\t};\n\t\n\tBufferList.prototype.unshift = function (v) {\n\t var entry = { data: v, next: this.head };\n\t if (this.length === 0) this.tail = entry;\n\t this.head = entry;\n\t ++this.length;\n\t};\n\t\n\tBufferList.prototype.shift = function () {\n\t if (this.length === 0) return;\n\t var ret = this.head.data;\n\t if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;\n\t --this.length;\n\t return ret;\n\t};\n\t\n\tBufferList.prototype.clear = function () {\n\t this.head = this.tail = null;\n\t this.length = 0;\n\t};\n\t\n\tBufferList.prototype.join = function (s) {\n\t if (this.length === 0) return '';\n\t var p = this.head;\n\t var ret = '' + p.data;\n\t while (p = p.next) {\n\t ret += s + p.data;\n\t }return ret;\n\t};\n\t\n\tBufferList.prototype.concat = function (n) {\n\t if (this.length === 0) return bufferShim.alloc(0);\n\t if (this.length === 1) return this.head.data;\n\t var ret = bufferShim.allocUnsafe(n >>> 0);\n\t var p = this.head;\n\t var i = 0;\n\t while (p) {\n\t p.data.copy(ret, i);\n\t i += p.data.length;\n\t p = p.next;\n\t }\n\t return ret;\n\t};\n\n/***/ },\n/* 21 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t// a duplex stream is just a stream that is both readable and writable.\n\t// Since JS doesn't have multiple prototypal inheritance, this class\n\t// prototypally inherits from Readable, and then parasitically from\n\t// Writable.\n\t\n\t'use strict';\n\t\n\t/**/\n\t\n\tvar objectKeys = Object.keys || function (obj) {\n\t var keys = [];\n\t for (var key in obj) {\n\t keys.push(key);\n\t }return keys;\n\t};\n\t/**/\n\t\n\tmodule.exports = Duplex;\n\t\n\t/**/\n\tvar processNextTick = __webpack_require__(15);\n\t/**/\n\t\n\t/**/\n\tvar util = __webpack_require__(18);\n\tutil.inherits = __webpack_require__(12);\n\t/**/\n\t\n\tvar Readable = __webpack_require__(14);\n\tvar Writable = __webpack_require__(22);\n\t\n\tutil.inherits(Duplex, Readable);\n\t\n\tvar keys = objectKeys(Writable.prototype);\n\tfor (var v = 0; v < keys.length; v++) {\n\t var method = keys[v];\n\t if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];\n\t}\n\t\n\tfunction Duplex(options) {\n\t if (!(this instanceof Duplex)) return new Duplex(options);\n\t\n\t Readable.call(this, options);\n\t Writable.call(this, options);\n\t\n\t if (options && options.readable === false) this.readable = false;\n\t\n\t if (options && options.writable === false) this.writable = false;\n\t\n\t this.allowHalfOpen = true;\n\t if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;\n\t\n\t this.once('end', onend);\n\t}\n\t\n\t// the no-half-open enforcer\n\tfunction onend() {\n\t // if we allow half-open state, or if the writable side ended,\n\t // then we're ok.\n\t if (this.allowHalfOpen || this._writableState.ended) return;\n\t\n\t // no more data can be written.\n\t // But allow more writes to happen in this tick.\n\t processNextTick(onEndNT, this);\n\t}\n\t\n\tfunction onEndNT(self) {\n\t self.end();\n\t}\n\t\n\tfunction forEach(xs, f) {\n\t for (var i = 0, l = xs.length; i < l; i++) {\n\t f(xs[i], i);\n\t }\n\t}\n\n/***/ },\n/* 22 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(process) {// A bit simpler than readable streams.\n\t// Implement an async ._write(chunk, encoding, cb), and it'll handle all\n\t// the drain event emission and buffering.\n\t\n\t'use strict';\n\t\n\tmodule.exports = Writable;\n\t\n\t/**/\n\tvar processNextTick = __webpack_require__(15);\n\t/**/\n\t\n\t/**/\n\tvar asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;\n\t/**/\n\t\n\t/**/\n\tvar Duplex;\n\t/**/\n\t\n\tWritable.WritableState = WritableState;\n\t\n\t/**/\n\tvar util = __webpack_require__(18);\n\tutil.inherits = __webpack_require__(12);\n\t/**/\n\t\n\t/**/\n\tvar internalUtil = {\n\t deprecate: __webpack_require__(23)\n\t};\n\t/**/\n\t\n\t/**/\n\tvar Stream;\n\t(function () {\n\t try {\n\t Stream = __webpack_require__(11);\n\t } catch (_) {} finally {\n\t if (!Stream) Stream = __webpack_require__(8).EventEmitter;\n\t }\n\t})();\n\t/**/\n\t\n\tvar Buffer = __webpack_require__(2).Buffer;\n\t/**/\n\tvar bufferShim = __webpack_require__(17);\n\t/**/\n\t\n\tutil.inherits(Writable, Stream);\n\t\n\tfunction nop() {}\n\t\n\tfunction WriteReq(chunk, encoding, cb) {\n\t this.chunk = chunk;\n\t this.encoding = encoding;\n\t this.callback = cb;\n\t this.next = null;\n\t}\n\t\n\tfunction WritableState(options, stream) {\n\t Duplex = Duplex || __webpack_require__(21);\n\t\n\t options = options || {};\n\t\n\t // object stream flag to indicate whether or not this stream\n\t // contains buffers or objects.\n\t this.objectMode = !!options.objectMode;\n\t\n\t if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;\n\t\n\t // the point at which write() starts returning false\n\t // Note: 0 is a valid value, means that we always return false if\n\t // the entire buffer is not flushed immediately on write()\n\t var hwm = options.highWaterMark;\n\t var defaultHwm = this.objectMode ? 16 : 16 * 1024;\n\t this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;\n\t\n\t // cast to ints.\n\t this.highWaterMark = ~~this.highWaterMark;\n\t\n\t // drain event flag.\n\t this.needDrain = false;\n\t // at the start of calling end()\n\t this.ending = false;\n\t // when end() has been called, and returned\n\t this.ended = false;\n\t // when 'finish' is emitted\n\t this.finished = false;\n\t\n\t // should we decode strings into buffers before passing to _write?\n\t // this is here so that some node-core streams can optimize string\n\t // handling at a lower level.\n\t var noDecode = options.decodeStrings === false;\n\t this.decodeStrings = !noDecode;\n\t\n\t // Crypto is kind of old and crusty. Historically, its default string\n\t // encoding is 'binary' so we have to make this configurable.\n\t // Everything else in the universe uses 'utf8', though.\n\t this.defaultEncoding = options.defaultEncoding || 'utf8';\n\t\n\t // not an actual buffer we keep track of, but a measurement\n\t // of how much we're waiting to get pushed to some underlying\n\t // socket or file.\n\t this.length = 0;\n\t\n\t // a flag to see when we're in the middle of a write.\n\t this.writing = false;\n\t\n\t // when true all writes will be buffered until .uncork() call\n\t this.corked = 0;\n\t\n\t // a flag to be able to tell if the onwrite cb is called immediately,\n\t // or on a later tick. We set this to true at first, because any\n\t // actions that shouldn't happen until \"later\" should generally also\n\t // not happen before the first write call.\n\t this.sync = true;\n\t\n\t // a flag to know if we're processing previously buffered items, which\n\t // may call the _write() callback in the same tick, so that we don't\n\t // end up in an overlapped onwrite situation.\n\t this.bufferProcessing = false;\n\t\n\t // the callback that's passed to _write(chunk,cb)\n\t this.onwrite = function (er) {\n\t onwrite(stream, er);\n\t };\n\t\n\t // the callback that the user supplies to write(chunk,encoding,cb)\n\t this.writecb = null;\n\t\n\t // the amount that is being written when _write is called.\n\t this.writelen = 0;\n\t\n\t this.bufferedRequest = null;\n\t this.lastBufferedRequest = null;\n\t\n\t // number of pending user-supplied write callbacks\n\t // this must be 0 before 'finish' can be emitted\n\t this.pendingcb = 0;\n\t\n\t // emit prefinish if the only thing we're waiting for is _write cbs\n\t // This is relevant for synchronous Transform streams\n\t this.prefinished = false;\n\t\n\t // True if the error was already emitted and should not be thrown again\n\t this.errorEmitted = false;\n\t\n\t // count buffered requests\n\t this.bufferedRequestCount = 0;\n\t\n\t // allocate the first CorkedRequest, there is always\n\t // one allocated and free to use, and we maintain at most two\n\t this.corkedRequestsFree = new CorkedRequest(this);\n\t}\n\t\n\tWritableState.prototype.getBuffer = function getBuffer() {\n\t var current = this.bufferedRequest;\n\t var out = [];\n\t while (current) {\n\t out.push(current);\n\t current = current.next;\n\t }\n\t return out;\n\t};\n\t\n\t(function () {\n\t try {\n\t Object.defineProperty(WritableState.prototype, 'buffer', {\n\t get: internalUtil.deprecate(function () {\n\t return this.getBuffer();\n\t }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.')\n\t });\n\t } catch (_) {}\n\t})();\n\t\n\t// Test _writableState for inheritance to account for Duplex streams,\n\t// whose prototype chain only points to Readable.\n\tvar realHasInstance;\n\tif (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {\n\t realHasInstance = Function.prototype[Symbol.hasInstance];\n\t Object.defineProperty(Writable, Symbol.hasInstance, {\n\t value: function (object) {\n\t if (realHasInstance.call(this, object)) return true;\n\t\n\t return object && object._writableState instanceof WritableState;\n\t }\n\t });\n\t} else {\n\t realHasInstance = function (object) {\n\t return object instanceof this;\n\t };\n\t}\n\t\n\tfunction Writable(options) {\n\t Duplex = Duplex || __webpack_require__(21);\n\t\n\t // Writable ctor is applied to Duplexes, too.\n\t // `realHasInstance` is necessary because using plain `instanceof`\n\t // would return false, as no `_writableState` property is attached.\n\t\n\t // Trying to use the custom `instanceof` for Writable here will also break the\n\t // Node.js LazyTransform implementation, which has a non-trivial getter for\n\t // `_writableState` that would lead to infinite recursion.\n\t if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {\n\t return new Writable(options);\n\t }\n\t\n\t this._writableState = new WritableState(options, this);\n\t\n\t // legacy.\n\t this.writable = true;\n\t\n\t if (options) {\n\t if (typeof options.write === 'function') this._write = options.write;\n\t\n\t if (typeof options.writev === 'function') this._writev = options.writev;\n\t }\n\t\n\t Stream.call(this);\n\t}\n\t\n\t// Otherwise people can pipe Writable streams, which is just wrong.\n\tWritable.prototype.pipe = function () {\n\t this.emit('error', new Error('Cannot pipe, not readable'));\n\t};\n\t\n\tfunction writeAfterEnd(stream, cb) {\n\t var er = new Error('write after end');\n\t // TODO: defer error events consistently everywhere, not just the cb\n\t stream.emit('error', er);\n\t processNextTick(cb, er);\n\t}\n\t\n\t// Checks that a user-supplied chunk is valid, especially for the particular\n\t// mode the stream is in. Currently this means that `null` is never accepted\n\t// and undefined/non-string values are only allowed in object mode.\n\tfunction validChunk(stream, state, chunk, cb) {\n\t var valid = true;\n\t var er = false;\n\t\n\t if (chunk === null) {\n\t er = new TypeError('May not write null values to stream');\n\t } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {\n\t er = new TypeError('Invalid non-string/buffer chunk');\n\t }\n\t if (er) {\n\t stream.emit('error', er);\n\t processNextTick(cb, er);\n\t valid = false;\n\t }\n\t return valid;\n\t}\n\t\n\tWritable.prototype.write = function (chunk, encoding, cb) {\n\t var state = this._writableState;\n\t var ret = false;\n\t var isBuf = Buffer.isBuffer(chunk);\n\t\n\t if (typeof encoding === 'function') {\n\t cb = encoding;\n\t encoding = null;\n\t }\n\t\n\t if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;\n\t\n\t if (typeof cb !== 'function') cb = nop;\n\t\n\t if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {\n\t state.pendingcb++;\n\t ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);\n\t }\n\t\n\t return ret;\n\t};\n\t\n\tWritable.prototype.cork = function () {\n\t var state = this._writableState;\n\t\n\t state.corked++;\n\t};\n\t\n\tWritable.prototype.uncork = function () {\n\t var state = this._writableState;\n\t\n\t if (state.corked) {\n\t state.corked--;\n\t\n\t if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);\n\t }\n\t};\n\t\n\tWritable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {\n\t // node::ParseEncoding() requires lower case.\n\t if (typeof encoding === 'string') encoding = encoding.toLowerCase();\n\t if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);\n\t this._writableState.defaultEncoding = encoding;\n\t return this;\n\t};\n\t\n\tfunction decodeChunk(state, chunk, encoding) {\n\t if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {\n\t chunk = bufferShim.from(chunk, encoding);\n\t }\n\t return chunk;\n\t}\n\t\n\t// if we're already writing something, then just put this\n\t// in the queue, and wait our turn. Otherwise, call _write\n\t// If we return false, then we need a drain event, so set that flag.\n\tfunction writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {\n\t if (!isBuf) {\n\t chunk = decodeChunk(state, chunk, encoding);\n\t if (Buffer.isBuffer(chunk)) encoding = 'buffer';\n\t }\n\t var len = state.objectMode ? 1 : chunk.length;\n\t\n\t state.length += len;\n\t\n\t var ret = state.length < state.highWaterMark;\n\t // we must ensure that previous needDrain will not be reset to false.\n\t if (!ret) state.needDrain = true;\n\t\n\t if (state.writing || state.corked) {\n\t var last = state.lastBufferedRequest;\n\t state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);\n\t if (last) {\n\t last.next = state.lastBufferedRequest;\n\t } else {\n\t state.bufferedRequest = state.lastBufferedRequest;\n\t }\n\t state.bufferedRequestCount += 1;\n\t } else {\n\t doWrite(stream, state, false, len, chunk, encoding, cb);\n\t }\n\t\n\t return ret;\n\t}\n\t\n\tfunction doWrite(stream, state, writev, len, chunk, encoding, cb) {\n\t state.writelen = len;\n\t state.writecb = cb;\n\t state.writing = true;\n\t state.sync = true;\n\t if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);\n\t state.sync = false;\n\t}\n\t\n\tfunction onwriteError(stream, state, sync, er, cb) {\n\t --state.pendingcb;\n\t if (sync) processNextTick(cb, er);else cb(er);\n\t\n\t stream._writableState.errorEmitted = true;\n\t stream.emit('error', er);\n\t}\n\t\n\tfunction onwriteStateUpdate(state) {\n\t state.writing = false;\n\t state.writecb = null;\n\t state.length -= state.writelen;\n\t state.writelen = 0;\n\t}\n\t\n\tfunction onwrite(stream, er) {\n\t var state = stream._writableState;\n\t var sync = state.sync;\n\t var cb = state.writecb;\n\t\n\t onwriteStateUpdate(state);\n\t\n\t if (er) onwriteError(stream, state, sync, er, cb);else {\n\t // Check if we're actually ready to finish, but don't emit yet\n\t var finished = needFinish(state);\n\t\n\t if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {\n\t clearBuffer(stream, state);\n\t }\n\t\n\t if (sync) {\n\t /**/\n\t asyncWrite(afterWrite, stream, state, finished, cb);\n\t /**/\n\t } else {\n\t afterWrite(stream, state, finished, cb);\n\t }\n\t }\n\t}\n\t\n\tfunction afterWrite(stream, state, finished, cb) {\n\t if (!finished) onwriteDrain(stream, state);\n\t state.pendingcb--;\n\t cb();\n\t finishMaybe(stream, state);\n\t}\n\t\n\t// Must force callback to be called on nextTick, so that we don't\n\t// emit 'drain' before the write() consumer gets the 'false' return\n\t// value, and has a chance to attach a 'drain' listener.\n\tfunction onwriteDrain(stream, state) {\n\t if (state.length === 0 && state.needDrain) {\n\t state.needDrain = false;\n\t stream.emit('drain');\n\t }\n\t}\n\t\n\t// if there's something in the buffer waiting, then process it\n\tfunction clearBuffer(stream, state) {\n\t state.bufferProcessing = true;\n\t var entry = state.bufferedRequest;\n\t\n\t if (stream._writev && entry && entry.next) {\n\t // Fast case, write everything using _writev()\n\t var l = state.bufferedRequestCount;\n\t var buffer = new Array(l);\n\t var holder = state.corkedRequestsFree;\n\t holder.entry = entry;\n\t\n\t var count = 0;\n\t while (entry) {\n\t buffer[count] = entry;\n\t entry = entry.next;\n\t count += 1;\n\t }\n\t\n\t doWrite(stream, state, true, state.length, buffer, '', holder.finish);\n\t\n\t // doWrite is almost always async, defer these to save a bit of time\n\t // as the hot path ends with doWrite\n\t state.pendingcb++;\n\t state.lastBufferedRequest = null;\n\t if (holder.next) {\n\t state.corkedRequestsFree = holder.next;\n\t holder.next = null;\n\t } else {\n\t state.corkedRequestsFree = new CorkedRequest(state);\n\t }\n\t } else {\n\t // Slow case, write chunks one-by-one\n\t while (entry) {\n\t var chunk = entry.chunk;\n\t var encoding = entry.encoding;\n\t var cb = entry.callback;\n\t var len = state.objectMode ? 1 : chunk.length;\n\t\n\t doWrite(stream, state, false, len, chunk, encoding, cb);\n\t entry = entry.next;\n\t // if we didn't call the onwrite immediately, then\n\t // it means that we need to wait until it does.\n\t // also, that means that the chunk and cb are currently\n\t // being processed, so move the buffer counter past them.\n\t if (state.writing) {\n\t break;\n\t }\n\t }\n\t\n\t if (entry === null) state.lastBufferedRequest = null;\n\t }\n\t\n\t state.bufferedRequestCount = 0;\n\t state.bufferedRequest = entry;\n\t state.bufferProcessing = false;\n\t}\n\t\n\tWritable.prototype._write = function (chunk, encoding, cb) {\n\t cb(new Error('_write() is not implemented'));\n\t};\n\t\n\tWritable.prototype._writev = null;\n\t\n\tWritable.prototype.end = function (chunk, encoding, cb) {\n\t var state = this._writableState;\n\t\n\t if (typeof chunk === 'function') {\n\t cb = chunk;\n\t chunk = null;\n\t encoding = null;\n\t } else if (typeof encoding === 'function') {\n\t cb = encoding;\n\t encoding = null;\n\t }\n\t\n\t if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);\n\t\n\t // .end() fully uncorks\n\t if (state.corked) {\n\t state.corked = 1;\n\t this.uncork();\n\t }\n\t\n\t // ignore unnecessary end() calls.\n\t if (!state.ending && !state.finished) endWritable(this, state, cb);\n\t};\n\t\n\tfunction needFinish(state) {\n\t return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;\n\t}\n\t\n\tfunction prefinish(stream, state) {\n\t if (!state.prefinished) {\n\t state.prefinished = true;\n\t stream.emit('prefinish');\n\t }\n\t}\n\t\n\tfunction finishMaybe(stream, state) {\n\t var need = needFinish(state);\n\t if (need) {\n\t if (state.pendingcb === 0) {\n\t prefinish(stream, state);\n\t state.finished = true;\n\t stream.emit('finish');\n\t } else {\n\t prefinish(stream, state);\n\t }\n\t }\n\t return need;\n\t}\n\t\n\tfunction endWritable(stream, state, cb) {\n\t state.ending = true;\n\t finishMaybe(stream, state);\n\t if (cb) {\n\t if (state.finished) processNextTick(cb);else stream.once('finish', cb);\n\t }\n\t state.ended = true;\n\t stream.writable = false;\n\t}\n\t\n\t// It seems a linked list but it is not\n\t// there will be only 2 of these for each stream\n\tfunction CorkedRequest(state) {\n\t var _this = this;\n\t\n\t this.next = null;\n\t this.entry = null;\n\t this.finish = function (err) {\n\t var entry = _this.entry;\n\t _this.entry = null;\n\t while (entry) {\n\t var cb = entry.callback;\n\t state.pendingcb--;\n\t cb(err);\n\t entry = entry.next;\n\t }\n\t if (state.corkedRequestsFree) {\n\t state.corkedRequestsFree.next = _this;\n\t } else {\n\t state.corkedRequestsFree = _this;\n\t }\n\t };\n\t}\n\t/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6)))\n\n/***/ },\n/* 23 */\n/***/ function(module, exports) {\n\n\t/* WEBPACK VAR INJECTION */(function(global) {\n\t/**\n\t * Module exports.\n\t */\n\t\n\tmodule.exports = deprecate;\n\t\n\t/**\n\t * Mark that a method should not be used.\n\t * Returns a modified function which warns once by default.\n\t *\n\t * If `localStorage.noDeprecation = true` is set, then it is a no-op.\n\t *\n\t * If `localStorage.throwDeprecation = true` is set, then deprecated functions\n\t * will throw an Error when invoked.\n\t *\n\t * If `localStorage.traceDeprecation = true` is set, then deprecated functions\n\t * will invoke `console.trace()` instead of `console.error()`.\n\t *\n\t * @param {Function} fn - the function to deprecate\n\t * @param {String} msg - the string to print to the console when `fn` is invoked\n\t * @returns {Function} a new \"deprecated\" version of `fn`\n\t * @api public\n\t */\n\t\n\tfunction deprecate (fn, msg) {\n\t if (config('noDeprecation')) {\n\t return fn;\n\t }\n\t\n\t var warned = false;\n\t function deprecated() {\n\t if (!warned) {\n\t if (config('throwDeprecation')) {\n\t throw new Error(msg);\n\t } else if (config('traceDeprecation')) {\n\t console.trace(msg);\n\t } else {\n\t console.warn(msg);\n\t }\n\t warned = true;\n\t }\n\t return fn.apply(this, arguments);\n\t }\n\t\n\t return deprecated;\n\t}\n\t\n\t/**\n\t * Checks `localStorage` for boolean values for the given `name`.\n\t *\n\t * @param {String} name\n\t * @returns {Boolean}\n\t * @api private\n\t */\n\t\n\tfunction config (name) {\n\t // accessing global.localStorage can trigger a DOMException in sandboxed iframes\n\t try {\n\t if (!global.localStorage) return false;\n\t } catch (_) {\n\t return false;\n\t }\n\t var val = global.localStorage[name];\n\t if (null == val) return false;\n\t return String(val).toLowerCase() === 'true';\n\t}\n\t\n\t/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))\n\n/***/ },\n/* 24 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t// Copyright Joyent, Inc. and other Node contributors.\n\t//\n\t// Permission is hereby granted, free of charge, to any person obtaining a\n\t// copy of this software and associated documentation files (the\n\t// \"Software\"), to deal in the Software without restriction, including\n\t// without limitation the rights to use, copy, modify, merge, publish,\n\t// distribute, sublicense, and/or sell copies of the Software, and to permit\n\t// persons to whom the Software is furnished to do so, subject to the\n\t// following conditions:\n\t//\n\t// The above copyright notice and this permission notice shall be included\n\t// in all copies or substantial portions of the Software.\n\t//\n\t// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n\t// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n\t// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n\t// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n\t// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n\t// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n\t// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\t\n\tvar Buffer = __webpack_require__(2).Buffer;\n\t\n\tvar isBufferEncoding = Buffer.isEncoding\n\t || function(encoding) {\n\t switch (encoding && encoding.toLowerCase()) {\n\t case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true;\n\t default: return false;\n\t }\n\t }\n\t\n\t\n\tfunction assertEncoding(encoding) {\n\t if (encoding && !isBufferEncoding(encoding)) {\n\t throw new Error('Unknown encoding: ' + encoding);\n\t }\n\t}\n\t\n\t// StringDecoder provides an interface for efficiently splitting a series of\n\t// buffers into a series of JS strings without breaking apart multi-byte\n\t// characters. CESU-8 is handled as part of the UTF-8 encoding.\n\t//\n\t// @TODO Handling all encodings inside a single object makes it very difficult\n\t// to reason about this code, so it should be split up in the future.\n\t// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code\n\t// points as used by CESU-8.\n\tvar StringDecoder = exports.StringDecoder = function(encoding) {\n\t this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');\n\t assertEncoding(encoding);\n\t switch (this.encoding) {\n\t case 'utf8':\n\t // CESU-8 represents each of Surrogate Pair by 3-bytes\n\t this.surrogateSize = 3;\n\t break;\n\t case 'ucs2':\n\t case 'utf16le':\n\t // UTF-16 represents each of Surrogate Pair by 2-bytes\n\t this.surrogateSize = 2;\n\t this.detectIncompleteChar = utf16DetectIncompleteChar;\n\t break;\n\t case 'base64':\n\t // Base-64 stores 3 bytes in 4 chars, and pads the remainder.\n\t this.surrogateSize = 3;\n\t this.detectIncompleteChar = base64DetectIncompleteChar;\n\t break;\n\t default:\n\t this.write = passThroughWrite;\n\t return;\n\t }\n\t\n\t // Enough space to store all bytes of a single character. UTF-8 needs 4\n\t // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).\n\t this.charBuffer = new Buffer(6);\n\t // Number of bytes received for the current incomplete multi-byte character.\n\t this.charReceived = 0;\n\t // Number of bytes expected for the current incomplete multi-byte character.\n\t this.charLength = 0;\n\t};\n\t\n\t\n\t// write decodes the given buffer and returns it as JS string that is\n\t// guaranteed to not contain any partial multi-byte characters. Any partial\n\t// character found at the end of the buffer is buffered up, and will be\n\t// returned when calling write again with the remaining bytes.\n\t//\n\t// Note: Converting a Buffer containing an orphan surrogate to a String\n\t// currently works, but converting a String to a Buffer (via `new Buffer`, or\n\t// Buffer#write) will replace incomplete surrogates with the unicode\n\t// replacement character. See https://codereview.chromium.org/121173009/ .\n\tStringDecoder.prototype.write = function(buffer) {\n\t var charStr = '';\n\t // if our last write ended with an incomplete multibyte character\n\t while (this.charLength) {\n\t // determine how many remaining bytes this buffer has to offer for this char\n\t var available = (buffer.length >= this.charLength - this.charReceived) ?\n\t this.charLength - this.charReceived :\n\t buffer.length;\n\t\n\t // add the new bytes to the char buffer\n\t buffer.copy(this.charBuffer, this.charReceived, 0, available);\n\t this.charReceived += available;\n\t\n\t if (this.charReceived < this.charLength) {\n\t // still not enough chars in this buffer? wait for more ...\n\t return '';\n\t }\n\t\n\t // remove bytes belonging to the current character from the buffer\n\t buffer = buffer.slice(available, buffer.length);\n\t\n\t // get the character that was split\n\t charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);\n\t\n\t // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character\n\t var charCode = charStr.charCodeAt(charStr.length - 1);\n\t if (charCode >= 0xD800 && charCode <= 0xDBFF) {\n\t this.charLength += this.surrogateSize;\n\t charStr = '';\n\t continue;\n\t }\n\t this.charReceived = this.charLength = 0;\n\t\n\t // if there are no more bytes in this buffer, just emit our char\n\t if (buffer.length === 0) {\n\t return charStr;\n\t }\n\t break;\n\t }\n\t\n\t // determine and set charLength / charReceived\n\t this.detectIncompleteChar(buffer);\n\t\n\t var end = buffer.length;\n\t if (this.charLength) {\n\t // buffer the incomplete character bytes we got\n\t buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);\n\t end -= this.charReceived;\n\t }\n\t\n\t charStr += buffer.toString(this.encoding, 0, end);\n\t\n\t var end = charStr.length - 1;\n\t var charCode = charStr.charCodeAt(end);\n\t // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character\n\t if (charCode >= 0xD800 && charCode <= 0xDBFF) {\n\t var size = this.surrogateSize;\n\t this.charLength += size;\n\t this.charReceived += size;\n\t this.charBuffer.copy(this.charBuffer, size, 0, size);\n\t buffer.copy(this.charBuffer, 0, 0, size);\n\t return charStr.substring(0, end);\n\t }\n\t\n\t // or just emit the charStr\n\t return charStr;\n\t};\n\t\n\t// detectIncompleteChar determines if there is an incomplete UTF-8 character at\n\t// the end of the given buffer. If so, it sets this.charLength to the byte\n\t// length that character, and sets this.charReceived to the number of bytes\n\t// that are available for this character.\n\tStringDecoder.prototype.detectIncompleteChar = function(buffer) {\n\t // determine how many bytes we have to check at the end of this buffer\n\t var i = (buffer.length >= 3) ? 3 : buffer.length;\n\t\n\t // Figure out if one of the last i bytes of our buffer announces an\n\t // incomplete char.\n\t for (; i > 0; i--) {\n\t var c = buffer[buffer.length - i];\n\t\n\t // See http://en.wikipedia.org/wiki/UTF-8#Description\n\t\n\t // 110XXXXX\n\t if (i == 1 && c >> 5 == 0x06) {\n\t this.charLength = 2;\n\t break;\n\t }\n\t\n\t // 1110XXXX\n\t if (i <= 2 && c >> 4 == 0x0E) {\n\t this.charLength = 3;\n\t break;\n\t }\n\t\n\t // 11110XXX\n\t if (i <= 3 && c >> 3 == 0x1E) {\n\t this.charLength = 4;\n\t break;\n\t }\n\t }\n\t this.charReceived = i;\n\t};\n\t\n\tStringDecoder.prototype.end = function(buffer) {\n\t var res = '';\n\t if (buffer && buffer.length)\n\t res = this.write(buffer);\n\t\n\t if (this.charReceived) {\n\t var cr = this.charReceived;\n\t var buf = this.charBuffer;\n\t var enc = this.encoding;\n\t res += buf.slice(0, cr).toString(enc);\n\t }\n\t\n\t return res;\n\t};\n\t\n\tfunction passThroughWrite(buffer) {\n\t return buffer.toString(this.encoding);\n\t}\n\t\n\tfunction utf16DetectIncompleteChar(buffer) {\n\t this.charReceived = buffer.length % 2;\n\t this.charLength = this.charReceived ? 2 : 0;\n\t}\n\t\n\tfunction base64DetectIncompleteChar(buffer) {\n\t this.charReceived = buffer.length % 3;\n\t this.charLength = this.charReceived ? 3 : 0;\n\t}\n\n\n/***/ },\n/* 25 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t// a transform stream is a readable/writable stream where you do\n\t// something with the data. Sometimes it's called a \"filter\",\n\t// but that's not a great name for it, since that implies a thing where\n\t// some bits pass through, and others are simply ignored. (That would\n\t// be a valid example of a transform, of course.)\n\t//\n\t// While the output is causally related to the input, it's not a\n\t// necessarily symmetric or synchronous transformation. For example,\n\t// a zlib stream might take multiple plain-text writes(), and then\n\t// emit a single compressed chunk some time in the future.\n\t//\n\t// Here's how this works:\n\t//\n\t// The Transform stream has all the aspects of the readable and writable\n\t// stream classes. When you write(chunk), that calls _write(chunk,cb)\n\t// internally, and returns false if there's a lot of pending writes\n\t// buffered up. When you call read(), that calls _read(n) until\n\t// there's enough pending readable data buffered up.\n\t//\n\t// In a transform stream, the written data is placed in a buffer. When\n\t// _read(n) is called, it transforms the queued up data, calling the\n\t// buffered _write cb's as it consumes chunks. If consuming a single\n\t// written chunk would result in multiple output chunks, then the first\n\t// outputted bit calls the readcb, and subsequent chunks just go into\n\t// the read buffer, and will cause it to emit 'readable' if necessary.\n\t//\n\t// This way, back-pressure is actually determined by the reading side,\n\t// since _read has to be called to start processing a new chunk. However,\n\t// a pathological inflate type of transform can cause excessive buffering\n\t// here. For example, imagine a stream where every byte of input is\n\t// interpreted as an integer from 0-255, and then results in that many\n\t// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in\n\t// 1kb of data being output. In this case, you could write a very small\n\t// amount of input, and end up with a very large amount of output. In\n\t// such a pathological inflating mechanism, there'd be no way to tell\n\t// the system to stop doing the transform. A single 4MB write could\n\t// cause the system to run out of memory.\n\t//\n\t// However, even in such a pathological case, only a single written chunk\n\t// would be consumed, and then the rest would wait (un-transformed) until\n\t// the results of the previous transformed chunk were consumed.\n\t\n\t'use strict';\n\t\n\tmodule.exports = Transform;\n\t\n\tvar Duplex = __webpack_require__(21);\n\t\n\t/**/\n\tvar util = __webpack_require__(18);\n\tutil.inherits = __webpack_require__(12);\n\t/**/\n\t\n\tutil.inherits(Transform, Duplex);\n\t\n\tfunction TransformState(stream) {\n\t this.afterTransform = function (er, data) {\n\t return afterTransform(stream, er, data);\n\t };\n\t\n\t this.needTransform = false;\n\t this.transforming = false;\n\t this.writecb = null;\n\t this.writechunk = null;\n\t this.writeencoding = null;\n\t}\n\t\n\tfunction afterTransform(stream, er, data) {\n\t var ts = stream._transformState;\n\t ts.transforming = false;\n\t\n\t var cb = ts.writecb;\n\t\n\t if (!cb) return stream.emit('error', new Error('no writecb in Transform class'));\n\t\n\t ts.writechunk = null;\n\t ts.writecb = null;\n\t\n\t if (data !== null && data !== undefined) stream.push(data);\n\t\n\t cb(er);\n\t\n\t var rs = stream._readableState;\n\t rs.reading = false;\n\t if (rs.needReadable || rs.length < rs.highWaterMark) {\n\t stream._read(rs.highWaterMark);\n\t }\n\t}\n\t\n\tfunction Transform(options) {\n\t if (!(this instanceof Transform)) return new Transform(options);\n\t\n\t Duplex.call(this, options);\n\t\n\t this._transformState = new TransformState(this);\n\t\n\t var stream = this;\n\t\n\t // start out asking for a readable event once data is transformed.\n\t this._readableState.needReadable = true;\n\t\n\t // we have implemented the _read method, and done the other things\n\t // that Readable wants before the first _read call, so unset the\n\t // sync guard flag.\n\t this._readableState.sync = false;\n\t\n\t if (options) {\n\t if (typeof options.transform === 'function') this._transform = options.transform;\n\t\n\t if (typeof options.flush === 'function') this._flush = options.flush;\n\t }\n\t\n\t // When the writable side finishes, then flush out anything remaining.\n\t this.once('prefinish', function () {\n\t if (typeof this._flush === 'function') this._flush(function (er, data) {\n\t done(stream, er, data);\n\t });else done(stream);\n\t });\n\t}\n\t\n\tTransform.prototype.push = function (chunk, encoding) {\n\t this._transformState.needTransform = false;\n\t return Duplex.prototype.push.call(this, chunk, encoding);\n\t};\n\t\n\t// This is the part where you do stuff!\n\t// override this function in implementation classes.\n\t// 'chunk' is an input chunk.\n\t//\n\t// Call `push(newChunk)` to pass along transformed output\n\t// to the readable side. You may call 'push' zero or more times.\n\t//\n\t// Call `cb(err)` when you are done with this chunk. If you pass\n\t// an error, then that'll put the hurt on the whole operation. If you\n\t// never call cb(), then you'll never get another chunk.\n\tTransform.prototype._transform = function (chunk, encoding, cb) {\n\t throw new Error('_transform() is not implemented');\n\t};\n\t\n\tTransform.prototype._write = function (chunk, encoding, cb) {\n\t var ts = this._transformState;\n\t ts.writecb = cb;\n\t ts.writechunk = chunk;\n\t ts.writeencoding = encoding;\n\t if (!ts.transforming) {\n\t var rs = this._readableState;\n\t if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);\n\t }\n\t};\n\t\n\t// Doesn't matter what the args are here.\n\t// _transform does all the work.\n\t// That we got here means that the readable side wants more data.\n\tTransform.prototype._read = function (n) {\n\t var ts = this._transformState;\n\t\n\t if (ts.writechunk !== null && ts.writecb && !ts.transforming) {\n\t ts.transforming = true;\n\t this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);\n\t } else {\n\t // mark that we need a transform, so that any data that comes in\n\t // will get processed, now that we've asked for it.\n\t ts.needTransform = true;\n\t }\n\t};\n\t\n\tfunction done(stream, er, data) {\n\t if (er) return stream.emit('error', er);\n\t\n\t if (data !== null && data !== undefined) stream.push(data);\n\t\n\t // if there's nothing in the write buffer, then that means\n\t // that nothing more will ever be provided\n\t var ws = stream._writableState;\n\t var ts = stream._transformState;\n\t\n\t if (ws.length) throw new Error('Calling transform done when ws.length != 0');\n\t\n\t if (ts.transforming) throw new Error('Calling transform done when still transforming');\n\t\n\t return stream.push(null);\n\t}\n\n/***/ },\n/* 26 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t// a passthrough stream.\n\t// basically just the most minimal sort of Transform stream.\n\t// Every written chunk gets output as-is.\n\t\n\t'use strict';\n\t\n\tmodule.exports = PassThrough;\n\t\n\tvar Transform = __webpack_require__(25);\n\t\n\t/**/\n\tvar util = __webpack_require__(18);\n\tutil.inherits = __webpack_require__(12);\n\t/**/\n\t\n\tutil.inherits(PassThrough, Transform);\n\t\n\tfunction PassThrough(options) {\n\t if (!(this instanceof PassThrough)) return new PassThrough(options);\n\t\n\t Transform.call(this, options);\n\t}\n\t\n\tPassThrough.prototype._transform = function (chunk, encoding, cb) {\n\t cb(null, chunk);\n\t};\n\n/***/ },\n/* 27 */\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __webpack_require__(22)\n\n\n/***/ },\n/* 28 */\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __webpack_require__(21)\n\n\n/***/ },\n/* 29 */\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __webpack_require__(25)\n\n\n/***/ },\n/* 30 */\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __webpack_require__(26)\n\n\n/***/ },\n/* 31 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\t\n\tvar zlib_inflate = __webpack_require__(32);\n\tvar utils = __webpack_require__(33);\n\tvar strings = __webpack_require__(38);\n\tvar c = __webpack_require__(39);\n\tvar msg = __webpack_require__(40);\n\tvar ZStream = __webpack_require__(41);\n\tvar GZheader = __webpack_require__(42);\n\t\n\tvar toString = Object.prototype.toString;\n\t\n\t/**\n\t * class Inflate\n\t *\n\t * Generic JS-style wrapper for zlib calls. If you don't need\n\t * streaming behaviour - use more simple functions: [[inflate]]\n\t * and [[inflateRaw]].\n\t **/\n\t\n\t/* internal\n\t * inflate.chunks -> Array\n\t *\n\t * Chunks of output data, if [[Inflate#onData]] not overriden.\n\t **/\n\t\n\t/**\n\t * Inflate.result -> Uint8Array|Array|String\n\t *\n\t * Uncompressed result, generated by default [[Inflate#onData]]\n\t * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n\t * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n\t * push a chunk with explicit flush (call [[Inflate#push]] with\n\t * `Z_SYNC_FLUSH` param).\n\t **/\n\t\n\t/**\n\t * Inflate.err -> Number\n\t *\n\t * Error code after inflate finished. 0 (Z_OK) on success.\n\t * Should be checked if broken data possible.\n\t **/\n\t\n\t/**\n\t * Inflate.msg -> String\n\t *\n\t * Error message, if [[Inflate.err]] != 0\n\t **/\n\t\n\t\n\t/**\n\t * new Inflate(options)\n\t * - options (Object): zlib inflate options.\n\t *\n\t * Creates new inflator instance with specified params. Throws exception\n\t * on bad params. Supported options:\n\t *\n\t * - `windowBits`\n\t * - `dictionary`\n\t *\n\t * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n\t * for more information on these.\n\t *\n\t * Additional options, for internal needs:\n\t *\n\t * - `chunkSize` - size of generated data chunks (16K by default)\n\t * - `raw` (Boolean) - do raw inflate\n\t * - `to` (String) - if equal to 'string', then result will be converted\n\t * from utf8 to utf16 (javascript) string. When string output requested,\n\t * chunk length can differ from `chunkSize`, depending on content.\n\t *\n\t * By default, when no options set, autodetect deflate/gzip data format via\n\t * wrapper header.\n\t *\n\t * ##### Example:\n\t *\n\t * ```javascript\n\t * var pako = require('pako')\n\t * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n\t * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n\t *\n\t * var inflate = new pako.Inflate({ level: 3});\n\t *\n\t * inflate.push(chunk1, false);\n\t * inflate.push(chunk2, true); // true -> last chunk\n\t *\n\t * if (inflate.err) { throw new Error(inflate.err); }\n\t *\n\t * console.log(inflate.result);\n\t * ```\n\t **/\n\tfunction Inflate(options) {\n\t if (!(this instanceof Inflate)) return new Inflate(options);\n\t\n\t this.options = utils.assign({\n\t chunkSize: 16384,\n\t windowBits: 0,\n\t to: ''\n\t }, options || {});\n\t\n\t var opt = this.options;\n\t\n\t // Force window size for `raw` data, if not set directly,\n\t // because we have no header for autodetect.\n\t if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n\t opt.windowBits = -opt.windowBits;\n\t if (opt.windowBits === 0) { opt.windowBits = -15; }\n\t }\n\t\n\t // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n\t if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n\t !(options && options.windowBits)) {\n\t opt.windowBits += 32;\n\t }\n\t\n\t // Gzip header has no info about windows size, we can do autodetect only\n\t // for deflate. So, if window size not set, force it to max when gzip possible\n\t if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n\t // bit 3 (16) -> gzipped data\n\t // bit 4 (32) -> autodetect gzip/deflate\n\t if ((opt.windowBits & 15) === 0) {\n\t opt.windowBits |= 15;\n\t }\n\t }\n\t\n\t this.err = 0; // error code, if happens (0 = Z_OK)\n\t this.msg = ''; // error message\n\t this.ended = false; // used to avoid multiple onEnd() calls\n\t this.chunks = []; // chunks of compressed data\n\t\n\t this.strm = new ZStream();\n\t this.strm.avail_out = 0;\n\t\n\t var status = zlib_inflate.inflateInit2(\n\t this.strm,\n\t opt.windowBits\n\t );\n\t\n\t if (status !== c.Z_OK) {\n\t throw new Error(msg[status]);\n\t }\n\t\n\t this.header = new GZheader();\n\t\n\t zlib_inflate.inflateGetHeader(this.strm, this.header);\n\t}\n\t\n\t/**\n\t * Inflate#push(data[, mode]) -> Boolean\n\t * - data (Uint8Array|Array|ArrayBuffer|String): input data\n\t * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n\t * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n\t *\n\t * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n\t * new output chunks. Returns `true` on success. The last data block must have\n\t * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n\t * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n\t * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n\t *\n\t * On fail call [[Inflate#onEnd]] with error code and return false.\n\t *\n\t * We strongly recommend to use `Uint8Array` on input for best speed (output\n\t * format is detected automatically). Also, don't skip last param and always\n\t * use the same type in your code (boolean or number). That will improve JS speed.\n\t *\n\t * For regular `Array`-s make sure all elements are [0..255].\n\t *\n\t * ##### Example\n\t *\n\t * ```javascript\n\t * push(chunk, false); // push one of data chunks\n\t * ...\n\t * push(chunk, true); // push last chunk\n\t * ```\n\t **/\n\tInflate.prototype.push = function (data, mode) {\n\t var strm = this.strm;\n\t var chunkSize = this.options.chunkSize;\n\t var dictionary = this.options.dictionary;\n\t var status, _mode;\n\t var next_out_utf8, tail, utf8str;\n\t var dict;\n\t\n\t // Flag to properly process Z_BUF_ERROR on testing inflate call\n\t // when we check that all output data was flushed.\n\t var allowBufError = false;\n\t\n\t if (this.ended) { return false; }\n\t _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);\n\t\n\t // Convert data if needed\n\t if (typeof data === 'string') {\n\t // Only binary strings can be decompressed on practice\n\t strm.input = strings.binstring2buf(data);\n\t } else if (toString.call(data) === '[object ArrayBuffer]') {\n\t strm.input = new Uint8Array(data);\n\t } else {\n\t strm.input = data;\n\t }\n\t\n\t strm.next_in = 0;\n\t strm.avail_in = strm.input.length;\n\t\n\t do {\n\t if (strm.avail_out === 0) {\n\t strm.output = new utils.Buf8(chunkSize);\n\t strm.next_out = 0;\n\t strm.avail_out = chunkSize;\n\t }\n\t\n\t status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */\n\t\n\t if (status === c.Z_NEED_DICT && dictionary) {\n\t // Convert data if needed\n\t if (typeof dictionary === 'string') {\n\t dict = strings.string2buf(dictionary);\n\t } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n\t dict = new Uint8Array(dictionary);\n\t } else {\n\t dict = dictionary;\n\t }\n\t\n\t status = zlib_inflate.inflateSetDictionary(this.strm, dict);\n\t\n\t }\n\t\n\t if (status === c.Z_BUF_ERROR && allowBufError === true) {\n\t status = c.Z_OK;\n\t allowBufError = false;\n\t }\n\t\n\t if (status !== c.Z_STREAM_END && status !== c.Z_OK) {\n\t this.onEnd(status);\n\t this.ended = true;\n\t return false;\n\t }\n\t\n\t if (strm.next_out) {\n\t if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {\n\t\n\t if (this.options.to === 'string') {\n\t\n\t next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\t\n\t tail = strm.next_out - next_out_utf8;\n\t utf8str = strings.buf2string(strm.output, next_out_utf8);\n\t\n\t // move tail\n\t strm.next_out = tail;\n\t strm.avail_out = chunkSize - tail;\n\t if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\t\n\t this.onData(utf8str);\n\t\n\t } else {\n\t this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n\t }\n\t }\n\t }\n\t\n\t // When no more input data, we should check that internal inflate buffers\n\t // are flushed. The only way to do it when avail_out = 0 - run one more\n\t // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n\t // Here we set flag to process this error properly.\n\t //\n\t // NOTE. Deflate does not return error in this case and does not needs such\n\t // logic.\n\t if (strm.avail_in === 0 && strm.avail_out === 0) {\n\t allowBufError = true;\n\t }\n\t\n\t } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);\n\t\n\t if (status === c.Z_STREAM_END) {\n\t _mode = c.Z_FINISH;\n\t }\n\t\n\t // Finalize on the last chunk.\n\t if (_mode === c.Z_FINISH) {\n\t status = zlib_inflate.inflateEnd(this.strm);\n\t this.onEnd(status);\n\t this.ended = true;\n\t return status === c.Z_OK;\n\t }\n\t\n\t // callback interim results if Z_SYNC_FLUSH.\n\t if (_mode === c.Z_SYNC_FLUSH) {\n\t this.onEnd(c.Z_OK);\n\t strm.avail_out = 0;\n\t return true;\n\t }\n\t\n\t return true;\n\t};\n\t\n\t\n\t/**\n\t * Inflate#onData(chunk) -> Void\n\t * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n\t * on js engine support. When string output requested, each chunk\n\t * will be string.\n\t *\n\t * By default, stores data blocks in `chunks[]` property and glue\n\t * those in `onEnd`. Override this handler, if you need another behaviour.\n\t **/\n\tInflate.prototype.onData = function (chunk) {\n\t this.chunks.push(chunk);\n\t};\n\t\n\t\n\t/**\n\t * Inflate#onEnd(status) -> Void\n\t * - status (Number): inflate status. 0 (Z_OK) on success,\n\t * other if not.\n\t *\n\t * Called either after you tell inflate that the input stream is\n\t * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n\t * or if an error happened. By default - join collected chunks,\n\t * free memory and fill `results` / `err` properties.\n\t **/\n\tInflate.prototype.onEnd = function (status) {\n\t // On success - join\n\t if (status === c.Z_OK) {\n\t if (this.options.to === 'string') {\n\t // Glue & convert here, until we teach pako to send\n\t // utf8 alligned strings to onData\n\t this.result = this.chunks.join('');\n\t } else {\n\t this.result = utils.flattenChunks(this.chunks);\n\t }\n\t }\n\t this.chunks = [];\n\t this.err = status;\n\t this.msg = this.strm.msg;\n\t};\n\t\n\t\n\t/**\n\t * inflate(data[, options]) -> Uint8Array|Array|String\n\t * - data (Uint8Array|Array|String): input data to decompress.\n\t * - options (Object): zlib inflate options.\n\t *\n\t * Decompress `data` with inflate/ungzip and `options`. Autodetect\n\t * format via wrapper header by default. That's why we don't provide\n\t * separate `ungzip` method.\n\t *\n\t * Supported options are:\n\t *\n\t * - windowBits\n\t *\n\t * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n\t * for more information.\n\t *\n\t * Sugar (options):\n\t *\n\t * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n\t * negative windowBits implicitly.\n\t * - `to` (String) - if equal to 'string', then result will be converted\n\t * from utf8 to utf16 (javascript) string. When string output requested,\n\t * chunk length can differ from `chunkSize`, depending on content.\n\t *\n\t *\n\t * ##### Example:\n\t *\n\t * ```javascript\n\t * var pako = require('pako')\n\t * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n\t * , output;\n\t *\n\t * try {\n\t * output = pako.inflate(input);\n\t * } catch (err)\n\t * console.log(err);\n\t * }\n\t * ```\n\t **/\n\tfunction inflate(input, options) {\n\t var inflator = new Inflate(options);\n\t\n\t inflator.push(input, true);\n\t\n\t // That will never happens, if you don't cheat with options :)\n\t if (inflator.err) { throw inflator.msg || msg[inflator.err]; }\n\t\n\t return inflator.result;\n\t}\n\t\n\t\n\t/**\n\t * inflateRaw(data[, options]) -> Uint8Array|Array|String\n\t * - data (Uint8Array|Array|String): input data to decompress.\n\t * - options (Object): zlib inflate options.\n\t *\n\t * The same as [[inflate]], but creates raw data, without wrapper\n\t * (header and adler32 crc).\n\t **/\n\tfunction inflateRaw(input, options) {\n\t options = options || {};\n\t options.raw = true;\n\t return inflate(input, options);\n\t}\n\t\n\t\n\t/**\n\t * ungzip(data[, options]) -> Uint8Array|Array|String\n\t * - data (Uint8Array|Array|String): input data to decompress.\n\t * - options (Object): zlib inflate options.\n\t *\n\t * Just shortcut to [[inflate]], because it autodetects format\n\t * by header.content. Done for convenience.\n\t **/\n\t\n\t\n\texports.Inflate = Inflate;\n\texports.inflate = inflate;\n\texports.inflateRaw = inflateRaw;\n\texports.ungzip = inflate;\n\n\n/***/ },\n/* 32 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\t\n\tvar utils = __webpack_require__(33);\n\tvar adler32 = __webpack_require__(34);\n\tvar crc32 = __webpack_require__(35);\n\tvar inflate_fast = __webpack_require__(36);\n\tvar inflate_table = __webpack_require__(37);\n\t\n\tvar CODES = 0;\n\tvar LENS = 1;\n\tvar DISTS = 2;\n\t\n\t/* Public constants ==========================================================*/\n\t/* ===========================================================================*/\n\t\n\t\n\t/* Allowed flush values; see deflate() and inflate() below for details */\n\t//var Z_NO_FLUSH = 0;\n\t//var Z_PARTIAL_FLUSH = 1;\n\t//var Z_SYNC_FLUSH = 2;\n\t//var Z_FULL_FLUSH = 3;\n\tvar Z_FINISH = 4;\n\tvar Z_BLOCK = 5;\n\tvar Z_TREES = 6;\n\t\n\t\n\t/* Return codes for the compression/decompression functions. Negative values\n\t * are errors, positive values are used for special but normal events.\n\t */\n\tvar Z_OK = 0;\n\tvar Z_STREAM_END = 1;\n\tvar Z_NEED_DICT = 2;\n\t//var Z_ERRNO = -1;\n\tvar Z_STREAM_ERROR = -2;\n\tvar Z_DATA_ERROR = -3;\n\tvar Z_MEM_ERROR = -4;\n\tvar Z_BUF_ERROR = -5;\n\t//var Z_VERSION_ERROR = -6;\n\t\n\t/* The deflate compression method */\n\tvar Z_DEFLATED = 8;\n\t\n\t\n\t/* STATES ====================================================================*/\n\t/* ===========================================================================*/\n\t\n\t\n\tvar HEAD = 1; /* i: waiting for magic header */\n\tvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\n\tvar TIME = 3; /* i: waiting for modification time (gzip) */\n\tvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\n\tvar EXLEN = 5; /* i: waiting for extra length (gzip) */\n\tvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\n\tvar NAME = 7; /* i: waiting for end of file name (gzip) */\n\tvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\n\tvar HCRC = 9; /* i: waiting for header crc (gzip) */\n\tvar DICTID = 10; /* i: waiting for dictionary check value */\n\tvar DICT = 11; /* waiting for inflateSetDictionary() call */\n\tvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n\tvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\n\tvar STORED = 14; /* i: waiting for stored size (length and complement) */\n\tvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\n\tvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\n\tvar TABLE = 17; /* i: waiting for dynamic block table lengths */\n\tvar LENLENS = 18; /* i: waiting for code length code lengths */\n\tvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\n\tvar LEN_ = 20; /* i: same as LEN below, but only first time in */\n\tvar LEN = 21; /* i: waiting for length/lit/eob code */\n\tvar LENEXT = 22; /* i: waiting for length extra bits */\n\tvar DIST = 23; /* i: waiting for distance code */\n\tvar DISTEXT = 24; /* i: waiting for distance extra bits */\n\tvar MATCH = 25; /* o: waiting for output space to copy string */\n\tvar LIT = 26; /* o: waiting for output space to write literal */\n\tvar CHECK = 27; /* i: waiting for 32-bit check value */\n\tvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\n\tvar DONE = 29; /* finished check, done -- remain here until reset */\n\tvar BAD = 30; /* got a data error -- remain here until reset */\n\tvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\n\tvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\t\n\t/* ===========================================================================*/\n\t\n\t\n\t\n\tvar ENOUGH_LENS = 852;\n\tvar ENOUGH_DISTS = 592;\n\t//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\t\n\tvar MAX_WBITS = 15;\n\t/* 32K LZ77 window */\n\tvar DEF_WBITS = MAX_WBITS;\n\t\n\t\n\tfunction zswap32(q) {\n\t return (((q >>> 24) & 0xff) +\n\t ((q >>> 8) & 0xff00) +\n\t ((q & 0xff00) << 8) +\n\t ((q & 0xff) << 24));\n\t}\n\t\n\t\n\tfunction InflateState() {\n\t this.mode = 0; /* current inflate mode */\n\t this.last = false; /* true if processing last block */\n\t this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n\t this.havedict = false; /* true if dictionary provided */\n\t this.flags = 0; /* gzip header method and flags (0 if zlib) */\n\t this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n\t this.check = 0; /* protected copy of check value */\n\t this.total = 0; /* protected copy of output count */\n\t // TODO: may be {}\n\t this.head = null; /* where to save gzip header information */\n\t\n\t /* sliding window */\n\t this.wbits = 0; /* log base 2 of requested window size */\n\t this.wsize = 0; /* window size or zero if not using window */\n\t this.whave = 0; /* valid bytes in the window */\n\t this.wnext = 0; /* window write index */\n\t this.window = null; /* allocated sliding window, if needed */\n\t\n\t /* bit accumulator */\n\t this.hold = 0; /* input bit accumulator */\n\t this.bits = 0; /* number of bits in \"in\" */\n\t\n\t /* for string and stored block copying */\n\t this.length = 0; /* literal or length of data to copy */\n\t this.offset = 0; /* distance back to copy string from */\n\t\n\t /* for table and code decoding */\n\t this.extra = 0; /* extra bits needed */\n\t\n\t /* fixed and dynamic code tables */\n\t this.lencode = null; /* starting table for length/literal codes */\n\t this.distcode = null; /* starting table for distance codes */\n\t this.lenbits = 0; /* index bits for lencode */\n\t this.distbits = 0; /* index bits for distcode */\n\t\n\t /* dynamic table building */\n\t this.ncode = 0; /* number of code length code lengths */\n\t this.nlen = 0; /* number of length code lengths */\n\t this.ndist = 0; /* number of distance code lengths */\n\t this.have = 0; /* number of code lengths in lens[] */\n\t this.next = null; /* next available space in codes[] */\n\t\n\t this.lens = new utils.Buf16(320); /* temporary storage for code lengths */\n\t this.work = new utils.Buf16(288); /* work area for code table building */\n\t\n\t /*\n\t because we don't have pointers in js, we use lencode and distcode directly\n\t as buffers so we don't need codes\n\t */\n\t //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */\n\t this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n\t this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n\t this.sane = 0; /* if false, allow invalid distance too far */\n\t this.back = 0; /* bits back of last unprocessed length/lit */\n\t this.was = 0; /* initial length of match */\n\t}\n\t\n\tfunction inflateResetKeep(strm) {\n\t var state;\n\t\n\t if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n\t state = strm.state;\n\t strm.total_in = strm.total_out = state.total = 0;\n\t strm.msg = ''; /*Z_NULL*/\n\t if (state.wrap) { /* to support ill-conceived Java test suite */\n\t strm.adler = state.wrap & 1;\n\t }\n\t state.mode = HEAD;\n\t state.last = 0;\n\t state.havedict = 0;\n\t state.dmax = 32768;\n\t state.head = null/*Z_NULL*/;\n\t state.hold = 0;\n\t state.bits = 0;\n\t //state.lencode = state.distcode = state.next = state.codes;\n\t state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);\n\t state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);\n\t\n\t state.sane = 1;\n\t state.back = -1;\n\t //Tracev((stderr, \"inflate: reset\\n\"));\n\t return Z_OK;\n\t}\n\t\n\tfunction inflateReset(strm) {\n\t var state;\n\t\n\t if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n\t state = strm.state;\n\t state.wsize = 0;\n\t state.whave = 0;\n\t state.wnext = 0;\n\t return inflateResetKeep(strm);\n\t\n\t}\n\t\n\tfunction inflateReset2(strm, windowBits) {\n\t var wrap;\n\t var state;\n\t\n\t /* get the state */\n\t if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n\t state = strm.state;\n\t\n\t /* extract wrap request from windowBits parameter */\n\t if (windowBits < 0) {\n\t wrap = 0;\n\t windowBits = -windowBits;\n\t }\n\t else {\n\t wrap = (windowBits >> 4) + 1;\n\t if (windowBits < 48) {\n\t windowBits &= 15;\n\t }\n\t }\n\t\n\t /* set number of window bits, free window if different */\n\t if (windowBits && (windowBits < 8 || windowBits > 15)) {\n\t return Z_STREAM_ERROR;\n\t }\n\t if (state.window !== null && state.wbits !== windowBits) {\n\t state.window = null;\n\t }\n\t\n\t /* update state and reset the rest of it */\n\t state.wrap = wrap;\n\t state.wbits = windowBits;\n\t return inflateReset(strm);\n\t}\n\t\n\tfunction inflateInit2(strm, windowBits) {\n\t var ret;\n\t var state;\n\t\n\t if (!strm) { return Z_STREAM_ERROR; }\n\t //strm.msg = Z_NULL; /* in case we return an error */\n\t\n\t state = new InflateState();\n\t\n\t //if (state === Z_NULL) return Z_MEM_ERROR;\n\t //Tracev((stderr, \"inflate: allocated\\n\"));\n\t strm.state = state;\n\t state.window = null/*Z_NULL*/;\n\t ret = inflateReset2(strm, windowBits);\n\t if (ret !== Z_OK) {\n\t strm.state = null/*Z_NULL*/;\n\t }\n\t return ret;\n\t}\n\t\n\tfunction inflateInit(strm) {\n\t return inflateInit2(strm, DEF_WBITS);\n\t}\n\t\n\t\n\t/*\n\t Return state with length and distance decoding tables and index sizes set to\n\t fixed code decoding. Normally this returns fixed tables from inffixed.h.\n\t If BUILDFIXED is defined, then instead this routine builds the tables the\n\t first time it's called, and returns those tables the first time and\n\t thereafter. This reduces the size of the code by about 2K bytes, in\n\t exchange for a little execution time. However, BUILDFIXED should not be\n\t used for threaded applications, since the rewriting of the tables and virgin\n\t may not be thread-safe.\n\t */\n\tvar virgin = true;\n\t\n\tvar lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\t\n\tfunction fixedtables(state) {\n\t /* build fixed huffman tables if first call (may not be thread safe) */\n\t if (virgin) {\n\t var sym;\n\t\n\t lenfix = new utils.Buf32(512);\n\t distfix = new utils.Buf32(32);\n\t\n\t /* literal/length table */\n\t sym = 0;\n\t while (sym < 144) { state.lens[sym++] = 8; }\n\t while (sym < 256) { state.lens[sym++] = 9; }\n\t while (sym < 280) { state.lens[sym++] = 7; }\n\t while (sym < 288) { state.lens[sym++] = 8; }\n\t\n\t inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\t\n\t /* distance table */\n\t sym = 0;\n\t while (sym < 32) { state.lens[sym++] = 5; }\n\t\n\t inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\t\n\t /* do this just once */\n\t virgin = false;\n\t }\n\t\n\t state.lencode = lenfix;\n\t state.lenbits = 9;\n\t state.distcode = distfix;\n\t state.distbits = 5;\n\t}\n\t\n\t\n\t/*\n\t Update the window with the last wsize (normally 32K) bytes written before\n\t returning. If window does not exist yet, create it. This is only called\n\t when a window is already in use, or when output has been written during this\n\t inflate call, but the end of the deflate stream has not been reached yet.\n\t It is also called to create a window for dictionary data when a dictionary\n\t is loaded.\n\t\n\t Providing output buffers larger than 32K to inflate() should provide a speed\n\t advantage, since only the last 32K of output is copied to the sliding window\n\t upon return from inflate(), and since all distances after the first 32K of\n\t output will fall in the output data, making match copies simpler and faster.\n\t The advantage may be dependent on the size of the processor's data caches.\n\t */\n\tfunction updatewindow(strm, src, end, copy) {\n\t var dist;\n\t var state = strm.state;\n\t\n\t /* if it hasn't been done already, allocate space for the window */\n\t if (state.window === null) {\n\t state.wsize = 1 << state.wbits;\n\t state.wnext = 0;\n\t state.whave = 0;\n\t\n\t state.window = new utils.Buf8(state.wsize);\n\t }\n\t\n\t /* copy state->wsize or less output bytes into the circular window */\n\t if (copy >= state.wsize) {\n\t utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n\t state.wnext = 0;\n\t state.whave = state.wsize;\n\t }\n\t else {\n\t dist = state.wsize - state.wnext;\n\t if (dist > copy) {\n\t dist = copy;\n\t }\n\t //zmemcpy(state->window + state->wnext, end - copy, dist);\n\t utils.arraySet(state.window, src, end - copy, dist, state.wnext);\n\t copy -= dist;\n\t if (copy) {\n\t //zmemcpy(state->window, end - copy, copy);\n\t utils.arraySet(state.window, src, end - copy, copy, 0);\n\t state.wnext = copy;\n\t state.whave = state.wsize;\n\t }\n\t else {\n\t state.wnext += dist;\n\t if (state.wnext === state.wsize) { state.wnext = 0; }\n\t if (state.whave < state.wsize) { state.whave += dist; }\n\t }\n\t }\n\t return 0;\n\t}\n\t\n\tfunction inflate(strm, flush) {\n\t var state;\n\t var input, output; // input/output buffers\n\t var next; /* next input INDEX */\n\t var put; /* next output INDEX */\n\t var have, left; /* available input and output */\n\t var hold; /* bit buffer */\n\t var bits; /* bits in bit buffer */\n\t var _in, _out; /* save starting available input and output */\n\t var copy; /* number of stored or match bytes to copy */\n\t var from; /* where to copy match bytes from */\n\t var from_source;\n\t var here = 0; /* current decoding table entry */\n\t var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n\t //var last; /* parent table entry */\n\t var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n\t var len; /* length to copy for repeats, bits to drop */\n\t var ret; /* return code */\n\t var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */\n\t var opts;\n\t\n\t var n; // temporary var for NEED_BITS\n\t\n\t var order = /* permutation of code lengths */\n\t [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\t\n\t\n\t if (!strm || !strm.state || !strm.output ||\n\t (!strm.input && strm.avail_in !== 0)) {\n\t return Z_STREAM_ERROR;\n\t }\n\t\n\t state = strm.state;\n\t if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\t\n\t\n\t //--- LOAD() ---\n\t put = strm.next_out;\n\t output = strm.output;\n\t left = strm.avail_out;\n\t next = strm.next_in;\n\t input = strm.input;\n\t have = strm.avail_in;\n\t hold = state.hold;\n\t bits = state.bits;\n\t //---\n\t\n\t _in = have;\n\t _out = left;\n\t ret = Z_OK;\n\t\n\t inf_leave: // goto emulation\n\t for (;;) {\n\t switch (state.mode) {\n\t case HEAD:\n\t if (state.wrap === 0) {\n\t state.mode = TYPEDO;\n\t break;\n\t }\n\t //=== NEEDBITS(16);\n\t while (bits < 16) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n\t state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n\t //=== CRC2(state.check, hold);\n\t hbuf[0] = hold & 0xff;\n\t hbuf[1] = (hold >>> 8) & 0xff;\n\t state.check = crc32(state.check, hbuf, 2, 0);\n\t //===//\n\t\n\t //=== INITBITS();\n\t hold = 0;\n\t bits = 0;\n\t //===//\n\t state.mode = FLAGS;\n\t break;\n\t }\n\t state.flags = 0; /* expect zlib header */\n\t if (state.head) {\n\t state.head.done = false;\n\t }\n\t if (!(state.wrap & 1) || /* check if zlib header allowed */\n\t (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n\t strm.msg = 'incorrect header check';\n\t state.mode = BAD;\n\t break;\n\t }\n\t if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n\t strm.msg = 'unknown compression method';\n\t state.mode = BAD;\n\t break;\n\t }\n\t //--- DROPBITS(4) ---//\n\t hold >>>= 4;\n\t bits -= 4;\n\t //---//\n\t len = (hold & 0x0f)/*BITS(4)*/ + 8;\n\t if (state.wbits === 0) {\n\t state.wbits = len;\n\t }\n\t else if (len > state.wbits) {\n\t strm.msg = 'invalid window size';\n\t state.mode = BAD;\n\t break;\n\t }\n\t state.dmax = 1 << len;\n\t //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n\t strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n\t state.mode = hold & 0x200 ? DICTID : TYPE;\n\t //=== INITBITS();\n\t hold = 0;\n\t bits = 0;\n\t //===//\n\t break;\n\t case FLAGS:\n\t //=== NEEDBITS(16); */\n\t while (bits < 16) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t state.flags = hold;\n\t if ((state.flags & 0xff) !== Z_DEFLATED) {\n\t strm.msg = 'unknown compression method';\n\t state.mode = BAD;\n\t break;\n\t }\n\t if (state.flags & 0xe000) {\n\t strm.msg = 'unknown header flags set';\n\t state.mode = BAD;\n\t break;\n\t }\n\t if (state.head) {\n\t state.head.text = ((hold >> 8) & 1);\n\t }\n\t if (state.flags & 0x0200) {\n\t //=== CRC2(state.check, hold);\n\t hbuf[0] = hold & 0xff;\n\t hbuf[1] = (hold >>> 8) & 0xff;\n\t state.check = crc32(state.check, hbuf, 2, 0);\n\t //===//\n\t }\n\t //=== INITBITS();\n\t hold = 0;\n\t bits = 0;\n\t //===//\n\t state.mode = TIME;\n\t /* falls through */\n\t case TIME:\n\t //=== NEEDBITS(32); */\n\t while (bits < 32) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t if (state.head) {\n\t state.head.time = hold;\n\t }\n\t if (state.flags & 0x0200) {\n\t //=== CRC4(state.check, hold)\n\t hbuf[0] = hold & 0xff;\n\t hbuf[1] = (hold >>> 8) & 0xff;\n\t hbuf[2] = (hold >>> 16) & 0xff;\n\t hbuf[3] = (hold >>> 24) & 0xff;\n\t state.check = crc32(state.check, hbuf, 4, 0);\n\t //===\n\t }\n\t //=== INITBITS();\n\t hold = 0;\n\t bits = 0;\n\t //===//\n\t state.mode = OS;\n\t /* falls through */\n\t case OS:\n\t //=== NEEDBITS(16); */\n\t while (bits < 16) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t if (state.head) {\n\t state.head.xflags = (hold & 0xff);\n\t state.head.os = (hold >> 8);\n\t }\n\t if (state.flags & 0x0200) {\n\t //=== CRC2(state.check, hold);\n\t hbuf[0] = hold & 0xff;\n\t hbuf[1] = (hold >>> 8) & 0xff;\n\t state.check = crc32(state.check, hbuf, 2, 0);\n\t //===//\n\t }\n\t //=== INITBITS();\n\t hold = 0;\n\t bits = 0;\n\t //===//\n\t state.mode = EXLEN;\n\t /* falls through */\n\t case EXLEN:\n\t if (state.flags & 0x0400) {\n\t //=== NEEDBITS(16); */\n\t while (bits < 16) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t state.length = hold;\n\t if (state.head) {\n\t state.head.extra_len = hold;\n\t }\n\t if (state.flags & 0x0200) {\n\t //=== CRC2(state.check, hold);\n\t hbuf[0] = hold & 0xff;\n\t hbuf[1] = (hold >>> 8) & 0xff;\n\t state.check = crc32(state.check, hbuf, 2, 0);\n\t //===//\n\t }\n\t //=== INITBITS();\n\t hold = 0;\n\t bits = 0;\n\t //===//\n\t }\n\t else if (state.head) {\n\t state.head.extra = null/*Z_NULL*/;\n\t }\n\t state.mode = EXTRA;\n\t /* falls through */\n\t case EXTRA:\n\t if (state.flags & 0x0400) {\n\t copy = state.length;\n\t if (copy > have) { copy = have; }\n\t if (copy) {\n\t if (state.head) {\n\t len = state.head.extra_len - state.length;\n\t if (!state.head.extra) {\n\t // Use untyped array for more conveniend processing later\n\t state.head.extra = new Array(state.head.extra_len);\n\t }\n\t utils.arraySet(\n\t state.head.extra,\n\t input,\n\t next,\n\t // extra field is limited to 65536 bytes\n\t // - no need for additional size check\n\t copy,\n\t /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n\t len\n\t );\n\t //zmemcpy(state.head.extra + len, next,\n\t // len + copy > state.head.extra_max ?\n\t // state.head.extra_max - len : copy);\n\t }\n\t if (state.flags & 0x0200) {\n\t state.check = crc32(state.check, input, copy, next);\n\t }\n\t have -= copy;\n\t next += copy;\n\t state.length -= copy;\n\t }\n\t if (state.length) { break inf_leave; }\n\t }\n\t state.length = 0;\n\t state.mode = NAME;\n\t /* falls through */\n\t case NAME:\n\t if (state.flags & 0x0800) {\n\t if (have === 0) { break inf_leave; }\n\t copy = 0;\n\t do {\n\t // TODO: 2 or 1 bytes?\n\t len = input[next + copy++];\n\t /* use constant limit because in js we should not preallocate memory */\n\t if (state.head && len &&\n\t (state.length < 65536 /*state.head.name_max*/)) {\n\t state.head.name += String.fromCharCode(len);\n\t }\n\t } while (len && copy < have);\n\t\n\t if (state.flags & 0x0200) {\n\t state.check = crc32(state.check, input, copy, next);\n\t }\n\t have -= copy;\n\t next += copy;\n\t if (len) { break inf_leave; }\n\t }\n\t else if (state.head) {\n\t state.head.name = null;\n\t }\n\t state.length = 0;\n\t state.mode = COMMENT;\n\t /* falls through */\n\t case COMMENT:\n\t if (state.flags & 0x1000) {\n\t if (have === 0) { break inf_leave; }\n\t copy = 0;\n\t do {\n\t len = input[next + copy++];\n\t /* use constant limit because in js we should not preallocate memory */\n\t if (state.head && len &&\n\t (state.length < 65536 /*state.head.comm_max*/)) {\n\t state.head.comment += String.fromCharCode(len);\n\t }\n\t } while (len && copy < have);\n\t if (state.flags & 0x0200) {\n\t state.check = crc32(state.check, input, copy, next);\n\t }\n\t have -= copy;\n\t next += copy;\n\t if (len) { break inf_leave; }\n\t }\n\t else if (state.head) {\n\t state.head.comment = null;\n\t }\n\t state.mode = HCRC;\n\t /* falls through */\n\t case HCRC:\n\t if (state.flags & 0x0200) {\n\t //=== NEEDBITS(16); */\n\t while (bits < 16) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t if (hold !== (state.check & 0xffff)) {\n\t strm.msg = 'header crc mismatch';\n\t state.mode = BAD;\n\t break;\n\t }\n\t //=== INITBITS();\n\t hold = 0;\n\t bits = 0;\n\t //===//\n\t }\n\t if (state.head) {\n\t state.head.hcrc = ((state.flags >> 9) & 1);\n\t state.head.done = true;\n\t }\n\t strm.adler = state.check = 0;\n\t state.mode = TYPE;\n\t break;\n\t case DICTID:\n\t //=== NEEDBITS(32); */\n\t while (bits < 32) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t strm.adler = state.check = zswap32(hold);\n\t //=== INITBITS();\n\t hold = 0;\n\t bits = 0;\n\t //===//\n\t state.mode = DICT;\n\t /* falls through */\n\t case DICT:\n\t if (state.havedict === 0) {\n\t //--- RESTORE() ---\n\t strm.next_out = put;\n\t strm.avail_out = left;\n\t strm.next_in = next;\n\t strm.avail_in = have;\n\t state.hold = hold;\n\t state.bits = bits;\n\t //---\n\t return Z_NEED_DICT;\n\t }\n\t strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n\t state.mode = TYPE;\n\t /* falls through */\n\t case TYPE:\n\t if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n\t /* falls through */\n\t case TYPEDO:\n\t if (state.last) {\n\t //--- BYTEBITS() ---//\n\t hold >>>= bits & 7;\n\t bits -= bits & 7;\n\t //---//\n\t state.mode = CHECK;\n\t break;\n\t }\n\t //=== NEEDBITS(3); */\n\t while (bits < 3) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t state.last = (hold & 0x01)/*BITS(1)*/;\n\t //--- DROPBITS(1) ---//\n\t hold >>>= 1;\n\t bits -= 1;\n\t //---//\n\t\n\t switch ((hold & 0x03)/*BITS(2)*/) {\n\t case 0: /* stored block */\n\t //Tracev((stderr, \"inflate: stored block%s\\n\",\n\t // state.last ? \" (last)\" : \"\"));\n\t state.mode = STORED;\n\t break;\n\t case 1: /* fixed block */\n\t fixedtables(state);\n\t //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n\t // state.last ? \" (last)\" : \"\"));\n\t state.mode = LEN_; /* decode codes */\n\t if (flush === Z_TREES) {\n\t //--- DROPBITS(2) ---//\n\t hold >>>= 2;\n\t bits -= 2;\n\t //---//\n\t break inf_leave;\n\t }\n\t break;\n\t case 2: /* dynamic block */\n\t //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n\t // state.last ? \" (last)\" : \"\"));\n\t state.mode = TABLE;\n\t break;\n\t case 3:\n\t strm.msg = 'invalid block type';\n\t state.mode = BAD;\n\t }\n\t //--- DROPBITS(2) ---//\n\t hold >>>= 2;\n\t bits -= 2;\n\t //---//\n\t break;\n\t case STORED:\n\t //--- BYTEBITS() ---// /* go to byte boundary */\n\t hold >>>= bits & 7;\n\t bits -= bits & 7;\n\t //---//\n\t //=== NEEDBITS(32); */\n\t while (bits < 32) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n\t strm.msg = 'invalid stored block lengths';\n\t state.mode = BAD;\n\t break;\n\t }\n\t state.length = hold & 0xffff;\n\t //Tracev((stderr, \"inflate: stored length %u\\n\",\n\t // state.length));\n\t //=== INITBITS();\n\t hold = 0;\n\t bits = 0;\n\t //===//\n\t state.mode = COPY_;\n\t if (flush === Z_TREES) { break inf_leave; }\n\t /* falls through */\n\t case COPY_:\n\t state.mode = COPY;\n\t /* falls through */\n\t case COPY:\n\t copy = state.length;\n\t if (copy) {\n\t if (copy > have) { copy = have; }\n\t if (copy > left) { copy = left; }\n\t if (copy === 0) { break inf_leave; }\n\t //--- zmemcpy(put, next, copy); ---\n\t utils.arraySet(output, input, next, copy, put);\n\t //---//\n\t have -= copy;\n\t next += copy;\n\t left -= copy;\n\t put += copy;\n\t state.length -= copy;\n\t break;\n\t }\n\t //Tracev((stderr, \"inflate: stored end\\n\"));\n\t state.mode = TYPE;\n\t break;\n\t case TABLE:\n\t //=== NEEDBITS(14); */\n\t while (bits < 14) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n\t //--- DROPBITS(5) ---//\n\t hold >>>= 5;\n\t bits -= 5;\n\t //---//\n\t state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n\t //--- DROPBITS(5) ---//\n\t hold >>>= 5;\n\t bits -= 5;\n\t //---//\n\t state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n\t //--- DROPBITS(4) ---//\n\t hold >>>= 4;\n\t bits -= 4;\n\t //---//\n\t//#ifndef PKZIP_BUG_WORKAROUND\n\t if (state.nlen > 286 || state.ndist > 30) {\n\t strm.msg = 'too many length or distance symbols';\n\t state.mode = BAD;\n\t break;\n\t }\n\t//#endif\n\t //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n\t state.have = 0;\n\t state.mode = LENLENS;\n\t /* falls through */\n\t case LENLENS:\n\t while (state.have < state.ncode) {\n\t //=== NEEDBITS(3);\n\t while (bits < 3) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n\t //--- DROPBITS(3) ---//\n\t hold >>>= 3;\n\t bits -= 3;\n\t //---//\n\t }\n\t while (state.have < 19) {\n\t state.lens[order[state.have++]] = 0;\n\t }\n\t // We have separate tables & no pointers. 2 commented lines below not needed.\n\t //state.next = state.codes;\n\t //state.lencode = state.next;\n\t // Switch to use dynamic table\n\t state.lencode = state.lendyn;\n\t state.lenbits = 7;\n\t\n\t opts = { bits: state.lenbits };\n\t ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n\t state.lenbits = opts.bits;\n\t\n\t if (ret) {\n\t strm.msg = 'invalid code lengths set';\n\t state.mode = BAD;\n\t break;\n\t }\n\t //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n\t state.have = 0;\n\t state.mode = CODELENS;\n\t /* falls through */\n\t case CODELENS:\n\t while (state.have < state.nlen + state.ndist) {\n\t for (;;) {\n\t here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n\t here_bits = here >>> 24;\n\t here_op = (here >>> 16) & 0xff;\n\t here_val = here & 0xffff;\n\t\n\t if ((here_bits) <= bits) { break; }\n\t //--- PULLBYTE() ---//\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t //---//\n\t }\n\t if (here_val < 16) {\n\t //--- DROPBITS(here.bits) ---//\n\t hold >>>= here_bits;\n\t bits -= here_bits;\n\t //---//\n\t state.lens[state.have++] = here_val;\n\t }\n\t else {\n\t if (here_val === 16) {\n\t //=== NEEDBITS(here.bits + 2);\n\t n = here_bits + 2;\n\t while (bits < n) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t //--- DROPBITS(here.bits) ---//\n\t hold >>>= here_bits;\n\t bits -= here_bits;\n\t //---//\n\t if (state.have === 0) {\n\t strm.msg = 'invalid bit length repeat';\n\t state.mode = BAD;\n\t break;\n\t }\n\t len = state.lens[state.have - 1];\n\t copy = 3 + (hold & 0x03);//BITS(2);\n\t //--- DROPBITS(2) ---//\n\t hold >>>= 2;\n\t bits -= 2;\n\t //---//\n\t }\n\t else if (here_val === 17) {\n\t //=== NEEDBITS(here.bits + 3);\n\t n = here_bits + 3;\n\t while (bits < n) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t //--- DROPBITS(here.bits) ---//\n\t hold >>>= here_bits;\n\t bits -= here_bits;\n\t //---//\n\t len = 0;\n\t copy = 3 + (hold & 0x07);//BITS(3);\n\t //--- DROPBITS(3) ---//\n\t hold >>>= 3;\n\t bits -= 3;\n\t //---//\n\t }\n\t else {\n\t //=== NEEDBITS(here.bits + 7);\n\t n = here_bits + 7;\n\t while (bits < n) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t //--- DROPBITS(here.bits) ---//\n\t hold >>>= here_bits;\n\t bits -= here_bits;\n\t //---//\n\t len = 0;\n\t copy = 11 + (hold & 0x7f);//BITS(7);\n\t //--- DROPBITS(7) ---//\n\t hold >>>= 7;\n\t bits -= 7;\n\t //---//\n\t }\n\t if (state.have + copy > state.nlen + state.ndist) {\n\t strm.msg = 'invalid bit length repeat';\n\t state.mode = BAD;\n\t break;\n\t }\n\t while (copy--) {\n\t state.lens[state.have++] = len;\n\t }\n\t }\n\t }\n\t\n\t /* handle error breaks in while */\n\t if (state.mode === BAD) { break; }\n\t\n\t /* check for end-of-block code (better have one) */\n\t if (state.lens[256] === 0) {\n\t strm.msg = 'invalid code -- missing end-of-block';\n\t state.mode = BAD;\n\t break;\n\t }\n\t\n\t /* build code tables -- note: do not change the lenbits or distbits\n\t values here (9 and 6) without reading the comments in inftrees.h\n\t concerning the ENOUGH constants, which depend on those values */\n\t state.lenbits = 9;\n\t\n\t opts = { bits: state.lenbits };\n\t ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n\t // We have separate tables & no pointers. 2 commented lines below not needed.\n\t // state.next_index = opts.table_index;\n\t state.lenbits = opts.bits;\n\t // state.lencode = state.next;\n\t\n\t if (ret) {\n\t strm.msg = 'invalid literal/lengths set';\n\t state.mode = BAD;\n\t break;\n\t }\n\t\n\t state.distbits = 6;\n\t //state.distcode.copy(state.codes);\n\t // Switch to use dynamic table\n\t state.distcode = state.distdyn;\n\t opts = { bits: state.distbits };\n\t ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n\t // We have separate tables & no pointers. 2 commented lines below not needed.\n\t // state.next_index = opts.table_index;\n\t state.distbits = opts.bits;\n\t // state.distcode = state.next;\n\t\n\t if (ret) {\n\t strm.msg = 'invalid distances set';\n\t state.mode = BAD;\n\t break;\n\t }\n\t //Tracev((stderr, 'inflate: codes ok\\n'));\n\t state.mode = LEN_;\n\t if (flush === Z_TREES) { break inf_leave; }\n\t /* falls through */\n\t case LEN_:\n\t state.mode = LEN;\n\t /* falls through */\n\t case LEN:\n\t if (have >= 6 && left >= 258) {\n\t //--- RESTORE() ---\n\t strm.next_out = put;\n\t strm.avail_out = left;\n\t strm.next_in = next;\n\t strm.avail_in = have;\n\t state.hold = hold;\n\t state.bits = bits;\n\t //---\n\t inflate_fast(strm, _out);\n\t //--- LOAD() ---\n\t put = strm.next_out;\n\t output = strm.output;\n\t left = strm.avail_out;\n\t next = strm.next_in;\n\t input = strm.input;\n\t have = strm.avail_in;\n\t hold = state.hold;\n\t bits = state.bits;\n\t //---\n\t\n\t if (state.mode === TYPE) {\n\t state.back = -1;\n\t }\n\t break;\n\t }\n\t state.back = 0;\n\t for (;;) {\n\t here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n\t here_bits = here >>> 24;\n\t here_op = (here >>> 16) & 0xff;\n\t here_val = here & 0xffff;\n\t\n\t if (here_bits <= bits) { break; }\n\t //--- PULLBYTE() ---//\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t //---//\n\t }\n\t if (here_op && (here_op & 0xf0) === 0) {\n\t last_bits = here_bits;\n\t last_op = here_op;\n\t last_val = here_val;\n\t for (;;) {\n\t here = state.lencode[last_val +\n\t ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n\t here_bits = here >>> 24;\n\t here_op = (here >>> 16) & 0xff;\n\t here_val = here & 0xffff;\n\t\n\t if ((last_bits + here_bits) <= bits) { break; }\n\t //--- PULLBYTE() ---//\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t //---//\n\t }\n\t //--- DROPBITS(last.bits) ---//\n\t hold >>>= last_bits;\n\t bits -= last_bits;\n\t //---//\n\t state.back += last_bits;\n\t }\n\t //--- DROPBITS(here.bits) ---//\n\t hold >>>= here_bits;\n\t bits -= here_bits;\n\t //---//\n\t state.back += here_bits;\n\t state.length = here_val;\n\t if (here_op === 0) {\n\t //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n\t // \"inflate: literal '%c'\\n\" :\n\t // \"inflate: literal 0x%02x\\n\", here.val));\n\t state.mode = LIT;\n\t break;\n\t }\n\t if (here_op & 32) {\n\t //Tracevv((stderr, \"inflate: end of block\\n\"));\n\t state.back = -1;\n\t state.mode = TYPE;\n\t break;\n\t }\n\t if (here_op & 64) {\n\t strm.msg = 'invalid literal/length code';\n\t state.mode = BAD;\n\t break;\n\t }\n\t state.extra = here_op & 15;\n\t state.mode = LENEXT;\n\t /* falls through */\n\t case LENEXT:\n\t if (state.extra) {\n\t //=== NEEDBITS(state.extra);\n\t n = state.extra;\n\t while (bits < n) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n\t //--- DROPBITS(state.extra) ---//\n\t hold >>>= state.extra;\n\t bits -= state.extra;\n\t //---//\n\t state.back += state.extra;\n\t }\n\t //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n\t state.was = state.length;\n\t state.mode = DIST;\n\t /* falls through */\n\t case DIST:\n\t for (;;) {\n\t here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n\t here_bits = here >>> 24;\n\t here_op = (here >>> 16) & 0xff;\n\t here_val = here & 0xffff;\n\t\n\t if ((here_bits) <= bits) { break; }\n\t //--- PULLBYTE() ---//\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t //---//\n\t }\n\t if ((here_op & 0xf0) === 0) {\n\t last_bits = here_bits;\n\t last_op = here_op;\n\t last_val = here_val;\n\t for (;;) {\n\t here = state.distcode[last_val +\n\t ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n\t here_bits = here >>> 24;\n\t here_op = (here >>> 16) & 0xff;\n\t here_val = here & 0xffff;\n\t\n\t if ((last_bits + here_bits) <= bits) { break; }\n\t //--- PULLBYTE() ---//\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t //---//\n\t }\n\t //--- DROPBITS(last.bits) ---//\n\t hold >>>= last_bits;\n\t bits -= last_bits;\n\t //---//\n\t state.back += last_bits;\n\t }\n\t //--- DROPBITS(here.bits) ---//\n\t hold >>>= here_bits;\n\t bits -= here_bits;\n\t //---//\n\t state.back += here_bits;\n\t if (here_op & 64) {\n\t strm.msg = 'invalid distance code';\n\t state.mode = BAD;\n\t break;\n\t }\n\t state.offset = here_val;\n\t state.extra = (here_op) & 15;\n\t state.mode = DISTEXT;\n\t /* falls through */\n\t case DISTEXT:\n\t if (state.extra) {\n\t //=== NEEDBITS(state.extra);\n\t n = state.extra;\n\t while (bits < n) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n\t //--- DROPBITS(state.extra) ---//\n\t hold >>>= state.extra;\n\t bits -= state.extra;\n\t //---//\n\t state.back += state.extra;\n\t }\n\t//#ifdef INFLATE_STRICT\n\t if (state.offset > state.dmax) {\n\t strm.msg = 'invalid distance too far back';\n\t state.mode = BAD;\n\t break;\n\t }\n\t//#endif\n\t //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n\t state.mode = MATCH;\n\t /* falls through */\n\t case MATCH:\n\t if (left === 0) { break inf_leave; }\n\t copy = _out - left;\n\t if (state.offset > copy) { /* copy from window */\n\t copy = state.offset - copy;\n\t if (copy > state.whave) {\n\t if (state.sane) {\n\t strm.msg = 'invalid distance too far back';\n\t state.mode = BAD;\n\t break;\n\t }\n\t// (!) This block is disabled in zlib defailts,\n\t// don't enable it for binary compatibility\n\t//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n\t// Trace((stderr, \"inflate.c too far\\n\"));\n\t// copy -= state.whave;\n\t// if (copy > state.length) { copy = state.length; }\n\t// if (copy > left) { copy = left; }\n\t// left -= copy;\n\t// state.length -= copy;\n\t// do {\n\t// output[put++] = 0;\n\t// } while (--copy);\n\t// if (state.length === 0) { state.mode = LEN; }\n\t// break;\n\t//#endif\n\t }\n\t if (copy > state.wnext) {\n\t copy -= state.wnext;\n\t from = state.wsize - copy;\n\t }\n\t else {\n\t from = state.wnext - copy;\n\t }\n\t if (copy > state.length) { copy = state.length; }\n\t from_source = state.window;\n\t }\n\t else { /* copy from output */\n\t from_source = output;\n\t from = put - state.offset;\n\t copy = state.length;\n\t }\n\t if (copy > left) { copy = left; }\n\t left -= copy;\n\t state.length -= copy;\n\t do {\n\t output[put++] = from_source[from++];\n\t } while (--copy);\n\t if (state.length === 0) { state.mode = LEN; }\n\t break;\n\t case LIT:\n\t if (left === 0) { break inf_leave; }\n\t output[put++] = state.length;\n\t left--;\n\t state.mode = LEN;\n\t break;\n\t case CHECK:\n\t if (state.wrap) {\n\t //=== NEEDBITS(32);\n\t while (bits < 32) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t // Use '|' insdead of '+' to make sure that result is signed\n\t hold |= input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t _out -= left;\n\t strm.total_out += _out;\n\t state.total += _out;\n\t if (_out) {\n\t strm.adler = state.check =\n\t /*UPDATE(state.check, put - _out, _out);*/\n\t (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\t\n\t }\n\t _out = left;\n\t // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n\t if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n\t strm.msg = 'incorrect data check';\n\t state.mode = BAD;\n\t break;\n\t }\n\t //=== INITBITS();\n\t hold = 0;\n\t bits = 0;\n\t //===//\n\t //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n\t }\n\t state.mode = LENGTH;\n\t /* falls through */\n\t case LENGTH:\n\t if (state.wrap && state.flags) {\n\t //=== NEEDBITS(32);\n\t while (bits < 32) {\n\t if (have === 0) { break inf_leave; }\n\t have--;\n\t hold += input[next++] << bits;\n\t bits += 8;\n\t }\n\t //===//\n\t if (hold !== (state.total & 0xffffffff)) {\n\t strm.msg = 'incorrect length check';\n\t state.mode = BAD;\n\t break;\n\t }\n\t //=== INITBITS();\n\t hold = 0;\n\t bits = 0;\n\t //===//\n\t //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n\t }\n\t state.mode = DONE;\n\t /* falls through */\n\t case DONE:\n\t ret = Z_STREAM_END;\n\t break inf_leave;\n\t case BAD:\n\t ret = Z_DATA_ERROR;\n\t break inf_leave;\n\t case MEM:\n\t return Z_MEM_ERROR;\n\t case SYNC:\n\t /* falls through */\n\t default:\n\t return Z_STREAM_ERROR;\n\t }\n\t }\n\t\n\t // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\t\n\t /*\n\t Return from inflate(), updating the total counts and the check value.\n\t If there was no progress during the inflate() call, return a buffer\n\t error. Call updatewindow() to create and/or update the window state.\n\t Note: a memory error from inflate() is non-recoverable.\n\t */\n\t\n\t //--- RESTORE() ---\n\t strm.next_out = put;\n\t strm.avail_out = left;\n\t strm.next_in = next;\n\t strm.avail_in = have;\n\t state.hold = hold;\n\t state.bits = bits;\n\t //---\n\t\n\t if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n\t (state.mode < CHECK || flush !== Z_FINISH))) {\n\t if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n\t state.mode = MEM;\n\t return Z_MEM_ERROR;\n\t }\n\t }\n\t _in -= strm.avail_in;\n\t _out -= strm.avail_out;\n\t strm.total_in += _in;\n\t strm.total_out += _out;\n\t state.total += _out;\n\t if (state.wrap && _out) {\n\t strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n\t (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n\t }\n\t strm.data_type = state.bits + (state.last ? 64 : 0) +\n\t (state.mode === TYPE ? 128 : 0) +\n\t (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n\t if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n\t ret = Z_BUF_ERROR;\n\t }\n\t return ret;\n\t}\n\t\n\tfunction inflateEnd(strm) {\n\t\n\t if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n\t return Z_STREAM_ERROR;\n\t }\n\t\n\t var state = strm.state;\n\t if (state.window) {\n\t state.window = null;\n\t }\n\t strm.state = null;\n\t return Z_OK;\n\t}\n\t\n\tfunction inflateGetHeader(strm, head) {\n\t var state;\n\t\n\t /* check state */\n\t if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n\t state = strm.state;\n\t if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\t\n\t /* save header structure */\n\t state.head = head;\n\t head.done = false;\n\t return Z_OK;\n\t}\n\t\n\tfunction inflateSetDictionary(strm, dictionary) {\n\t var dictLength = dictionary.length;\n\t\n\t var state;\n\t var dictid;\n\t var ret;\n\t\n\t /* check state */\n\t if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n\t state = strm.state;\n\t\n\t if (state.wrap !== 0 && state.mode !== DICT) {\n\t return Z_STREAM_ERROR;\n\t }\n\t\n\t /* check for correct dictionary identifier */\n\t if (state.mode === DICT) {\n\t dictid = 1; /* adler32(0, null, 0)*/\n\t /* dictid = adler32(dictid, dictionary, dictLength); */\n\t dictid = adler32(dictid, dictionary, dictLength, 0);\n\t if (dictid !== state.check) {\n\t return Z_DATA_ERROR;\n\t }\n\t }\n\t /* copy dictionary to window using updatewindow(), which will amend the\n\t existing dictionary if appropriate */\n\t ret = updatewindow(strm, dictionary, dictLength, dictLength);\n\t if (ret) {\n\t state.mode = MEM;\n\t return Z_MEM_ERROR;\n\t }\n\t state.havedict = 1;\n\t // Tracev((stderr, \"inflate: dictionary set\\n\"));\n\t return Z_OK;\n\t}\n\t\n\texports.inflateReset = inflateReset;\n\texports.inflateReset2 = inflateReset2;\n\texports.inflateResetKeep = inflateResetKeep;\n\texports.inflateInit = inflateInit;\n\texports.inflateInit2 = inflateInit2;\n\texports.inflate = inflate;\n\texports.inflateEnd = inflateEnd;\n\texports.inflateGetHeader = inflateGetHeader;\n\texports.inflateSetDictionary = inflateSetDictionary;\n\texports.inflateInfo = 'pako inflate (from Nodeca project)';\n\t\n\t/* Not implemented\n\texports.inflateCopy = inflateCopy;\n\texports.inflateGetDictionary = inflateGetDictionary;\n\texports.inflateMark = inflateMark;\n\texports.inflatePrime = inflatePrime;\n\texports.inflateSync = inflateSync;\n\texports.inflateSyncPoint = inflateSyncPoint;\n\texports.inflateUndermine = inflateUndermine;\n\t*/\n\n\n/***/ },\n/* 33 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t\n\tvar TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n\t (typeof Uint16Array !== 'undefined') &&\n\t (typeof Int32Array !== 'undefined');\n\t\n\t\n\texports.assign = function (obj /*from1, from2, from3, ...*/) {\n\t var sources = Array.prototype.slice.call(arguments, 1);\n\t while (sources.length) {\n\t var source = sources.shift();\n\t if (!source) { continue; }\n\t\n\t if (typeof source !== 'object') {\n\t throw new TypeError(source + 'must be non-object');\n\t }\n\t\n\t for (var p in source) {\n\t if (source.hasOwnProperty(p)) {\n\t obj[p] = source[p];\n\t }\n\t }\n\t }\n\t\n\t return obj;\n\t};\n\t\n\t\n\t// reduce buffer size, avoiding mem copy\n\texports.shrinkBuf = function (buf, size) {\n\t if (buf.length === size) { return buf; }\n\t if (buf.subarray) { return buf.subarray(0, size); }\n\t buf.length = size;\n\t return buf;\n\t};\n\t\n\t\n\tvar fnTyped = {\n\t arraySet: function (dest, src, src_offs, len, dest_offs) {\n\t if (src.subarray && dest.subarray) {\n\t dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n\t return;\n\t }\n\t // Fallback to ordinary array\n\t for (var i = 0; i < len; i++) {\n\t dest[dest_offs + i] = src[src_offs + i];\n\t }\n\t },\n\t // Join array of chunks to single array.\n\t flattenChunks: function (chunks) {\n\t var i, l, len, pos, chunk, result;\n\t\n\t // calculate data length\n\t len = 0;\n\t for (i = 0, l = chunks.length; i < l; i++) {\n\t len += chunks[i].length;\n\t }\n\t\n\t // join chunks\n\t result = new Uint8Array(len);\n\t pos = 0;\n\t for (i = 0, l = chunks.length; i < l; i++) {\n\t chunk = chunks[i];\n\t result.set(chunk, pos);\n\t pos += chunk.length;\n\t }\n\t\n\t return result;\n\t }\n\t};\n\t\n\tvar fnUntyped = {\n\t arraySet: function (dest, src, src_offs, len, dest_offs) {\n\t for (var i = 0; i < len; i++) {\n\t dest[dest_offs + i] = src[src_offs + i];\n\t }\n\t },\n\t // Join array of chunks to single array.\n\t flattenChunks: function (chunks) {\n\t return [].concat.apply([], chunks);\n\t }\n\t};\n\t\n\t\n\t// Enable/Disable typed arrays use, for testing\n\t//\n\texports.setTyped = function (on) {\n\t if (on) {\n\t exports.Buf8 = Uint8Array;\n\t exports.Buf16 = Uint16Array;\n\t exports.Buf32 = Int32Array;\n\t exports.assign(exports, fnTyped);\n\t } else {\n\t exports.Buf8 = Array;\n\t exports.Buf16 = Array;\n\t exports.Buf32 = Array;\n\t exports.assign(exports, fnUntyped);\n\t }\n\t};\n\t\n\texports.setTyped(TYPED_OK);\n\n\n/***/ },\n/* 34 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t// Note: adler32 takes 12% for level 0 and 2% for level 6.\n\t// It doesn't worth to make additional optimizationa as in original.\n\t// Small size is preferable.\n\t\n\tfunction adler32(adler, buf, len, pos) {\n\t var s1 = (adler & 0xffff) |0,\n\t s2 = ((adler >>> 16) & 0xffff) |0,\n\t n = 0;\n\t\n\t while (len !== 0) {\n\t // Set limit ~ twice less than 5552, to keep\n\t // s2 in 31-bits, because we force signed ints.\n\t // in other case %= will fail.\n\t n = len > 2000 ? 2000 : len;\n\t len -= n;\n\t\n\t do {\n\t s1 = (s1 + buf[pos++]) |0;\n\t s2 = (s2 + s1) |0;\n\t } while (--n);\n\t\n\t s1 %= 65521;\n\t s2 %= 65521;\n\t }\n\t\n\t return (s1 | (s2 << 16)) |0;\n\t}\n\t\n\t\n\tmodule.exports = adler32;\n\n\n/***/ },\n/* 35 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t// Note: we can't get significant speed boost here.\n\t// So write code to minimize size - no pregenerated tables\n\t// and array tools dependencies.\n\t\n\t\n\t// Use ordinary array, since untyped makes no boost here\n\tfunction makeTable() {\n\t var c, table = [];\n\t\n\t for (var n = 0; n < 256; n++) {\n\t c = n;\n\t for (var k = 0; k < 8; k++) {\n\t c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n\t }\n\t table[n] = c;\n\t }\n\t\n\t return table;\n\t}\n\t\n\t// Create table on load. Just 255 signed longs. Not a problem.\n\tvar crcTable = makeTable();\n\t\n\t\n\tfunction crc32(crc, buf, len, pos) {\n\t var t = crcTable,\n\t end = pos + len;\n\t\n\t crc ^= -1;\n\t\n\t for (var i = pos; i < end; i++) {\n\t crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n\t }\n\t\n\t return (crc ^ (-1)); // >>> 0;\n\t}\n\t\n\t\n\tmodule.exports = crc32;\n\n\n/***/ },\n/* 36 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t// See state defs from inflate.js\n\tvar BAD = 30; /* got a data error -- remain here until reset */\n\tvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\n\t\n\t/*\n\t Decode literal, length, and distance codes and write out the resulting\n\t literal and match bytes until either not enough input or output is\n\t available, an end-of-block is encountered, or a data error is encountered.\n\t When large enough input and output buffers are supplied to inflate(), for\n\t example, a 16K input buffer and a 64K output buffer, more than 95% of the\n\t inflate execution time is spent in this routine.\n\t\n\t Entry assumptions:\n\t\n\t state.mode === LEN\n\t strm.avail_in >= 6\n\t strm.avail_out >= 258\n\t start >= strm.avail_out\n\t state.bits < 8\n\t\n\t On return, state.mode is one of:\n\t\n\t LEN -- ran out of enough output space or enough available input\n\t TYPE -- reached end of block code, inflate() to interpret next block\n\t BAD -- error in block data\n\t\n\t Notes:\n\t\n\t - The maximum input bits used by a length/distance pair is 15 bits for the\n\t length code, 5 bits for the length extra, 15 bits for the distance code,\n\t and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n\t Therefore if strm.avail_in >= 6, then there is enough input to avoid\n\t checking for available input while decoding.\n\t\n\t - The maximum bytes that a single length/distance pair can output is 258\n\t bytes, which is the maximum length that can be coded. inflate_fast()\n\t requires strm.avail_out >= 258 for each loop to avoid checking for\n\t output space.\n\t */\n\tmodule.exports = function inflate_fast(strm, start) {\n\t var state;\n\t var _in; /* local strm.input */\n\t var last; /* have enough input while in < last */\n\t var _out; /* local strm.output */\n\t var beg; /* inflate()'s initial strm.output */\n\t var end; /* while out < end, enough space available */\n\t//#ifdef INFLATE_STRICT\n\t var dmax; /* maximum distance from zlib header */\n\t//#endif\n\t var wsize; /* window size or zero if not using window */\n\t var whave; /* valid bytes in the window */\n\t var wnext; /* window write index */\n\t // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n\t var s_window; /* allocated sliding window, if wsize != 0 */\n\t var hold; /* local strm.hold */\n\t var bits; /* local strm.bits */\n\t var lcode; /* local strm.lencode */\n\t var dcode; /* local strm.distcode */\n\t var lmask; /* mask for first level of length codes */\n\t var dmask; /* mask for first level of distance codes */\n\t var here; /* retrieved table entry */\n\t var op; /* code bits, operation, extra bits, or */\n\t /* window position, window bytes to copy */\n\t var len; /* match length, unused bytes */\n\t var dist; /* match distance */\n\t var from; /* where to copy match from */\n\t var from_source;\n\t\n\t\n\t var input, output; // JS specific, because we have no pointers\n\t\n\t /* copy state to local variables */\n\t state = strm.state;\n\t //here = state.here;\n\t _in = strm.next_in;\n\t input = strm.input;\n\t last = _in + (strm.avail_in - 5);\n\t _out = strm.next_out;\n\t output = strm.output;\n\t beg = _out - (start - strm.avail_out);\n\t end = _out + (strm.avail_out - 257);\n\t//#ifdef INFLATE_STRICT\n\t dmax = state.dmax;\n\t//#endif\n\t wsize = state.wsize;\n\t whave = state.whave;\n\t wnext = state.wnext;\n\t s_window = state.window;\n\t hold = state.hold;\n\t bits = state.bits;\n\t lcode = state.lencode;\n\t dcode = state.distcode;\n\t lmask = (1 << state.lenbits) - 1;\n\t dmask = (1 << state.distbits) - 1;\n\t\n\t\n\t /* decode literals and length/distances until end-of-block or not enough\n\t input data or output space */\n\t\n\t top:\n\t do {\n\t if (bits < 15) {\n\t hold += input[_in++] << bits;\n\t bits += 8;\n\t hold += input[_in++] << bits;\n\t bits += 8;\n\t }\n\t\n\t here = lcode[hold & lmask];\n\t\n\t dolen:\n\t for (;;) { // Goto emulation\n\t op = here >>> 24/*here.bits*/;\n\t hold >>>= op;\n\t bits -= op;\n\t op = (here >>> 16) & 0xff/*here.op*/;\n\t if (op === 0) { /* literal */\n\t //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n\t // \"inflate: literal '%c'\\n\" :\n\t // \"inflate: literal 0x%02x\\n\", here.val));\n\t output[_out++] = here & 0xffff/*here.val*/;\n\t }\n\t else if (op & 16) { /* length base */\n\t len = here & 0xffff/*here.val*/;\n\t op &= 15; /* number of extra bits */\n\t if (op) {\n\t if (bits < op) {\n\t hold += input[_in++] << bits;\n\t bits += 8;\n\t }\n\t len += hold & ((1 << op) - 1);\n\t hold >>>= op;\n\t bits -= op;\n\t }\n\t //Tracevv((stderr, \"inflate: length %u\\n\", len));\n\t if (bits < 15) {\n\t hold += input[_in++] << bits;\n\t bits += 8;\n\t hold += input[_in++] << bits;\n\t bits += 8;\n\t }\n\t here = dcode[hold & dmask];\n\t\n\t dodist:\n\t for (;;) { // goto emulation\n\t op = here >>> 24/*here.bits*/;\n\t hold >>>= op;\n\t bits -= op;\n\t op = (here >>> 16) & 0xff/*here.op*/;\n\t\n\t if (op & 16) { /* distance base */\n\t dist = here & 0xffff/*here.val*/;\n\t op &= 15; /* number of extra bits */\n\t if (bits < op) {\n\t hold += input[_in++] << bits;\n\t bits += 8;\n\t if (bits < op) {\n\t hold += input[_in++] << bits;\n\t bits += 8;\n\t }\n\t }\n\t dist += hold & ((1 << op) - 1);\n\t//#ifdef INFLATE_STRICT\n\t if (dist > dmax) {\n\t strm.msg = 'invalid distance too far back';\n\t state.mode = BAD;\n\t break top;\n\t }\n\t//#endif\n\t hold >>>= op;\n\t bits -= op;\n\t //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n\t op = _out - beg; /* max distance in output */\n\t if (dist > op) { /* see if copy from window */\n\t op = dist - op; /* distance back in window */\n\t if (op > whave) {\n\t if (state.sane) {\n\t strm.msg = 'invalid distance too far back';\n\t state.mode = BAD;\n\t break top;\n\t }\n\t\n\t// (!) This block is disabled in zlib defailts,\n\t// don't enable it for binary compatibility\n\t//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n\t// if (len <= op - whave) {\n\t// do {\n\t// output[_out++] = 0;\n\t// } while (--len);\n\t// continue top;\n\t// }\n\t// len -= op - whave;\n\t// do {\n\t// output[_out++] = 0;\n\t// } while (--op > whave);\n\t// if (op === 0) {\n\t// from = _out - dist;\n\t// do {\n\t// output[_out++] = output[from++];\n\t// } while (--len);\n\t// continue top;\n\t// }\n\t//#endif\n\t }\n\t from = 0; // window index\n\t from_source = s_window;\n\t if (wnext === 0) { /* very common case */\n\t from += wsize - op;\n\t if (op < len) { /* some from window */\n\t len -= op;\n\t do {\n\t output[_out++] = s_window[from++];\n\t } while (--op);\n\t from = _out - dist; /* rest from output */\n\t from_source = output;\n\t }\n\t }\n\t else if (wnext < op) { /* wrap around window */\n\t from += wsize + wnext - op;\n\t op -= wnext;\n\t if (op < len) { /* some from end of window */\n\t len -= op;\n\t do {\n\t output[_out++] = s_window[from++];\n\t } while (--op);\n\t from = 0;\n\t if (wnext < len) { /* some from start of window */\n\t op = wnext;\n\t len -= op;\n\t do {\n\t output[_out++] = s_window[from++];\n\t } while (--op);\n\t from = _out - dist; /* rest from output */\n\t from_source = output;\n\t }\n\t }\n\t }\n\t else { /* contiguous in window */\n\t from += wnext - op;\n\t if (op < len) { /* some from window */\n\t len -= op;\n\t do {\n\t output[_out++] = s_window[from++];\n\t } while (--op);\n\t from = _out - dist; /* rest from output */\n\t from_source = output;\n\t }\n\t }\n\t while (len > 2) {\n\t output[_out++] = from_source[from++];\n\t output[_out++] = from_source[from++];\n\t output[_out++] = from_source[from++];\n\t len -= 3;\n\t }\n\t if (len) {\n\t output[_out++] = from_source[from++];\n\t if (len > 1) {\n\t output[_out++] = from_source[from++];\n\t }\n\t }\n\t }\n\t else {\n\t from = _out - dist; /* copy direct from output */\n\t do { /* minimum length is three */\n\t output[_out++] = output[from++];\n\t output[_out++] = output[from++];\n\t output[_out++] = output[from++];\n\t len -= 3;\n\t } while (len > 2);\n\t if (len) {\n\t output[_out++] = output[from++];\n\t if (len > 1) {\n\t output[_out++] = output[from++];\n\t }\n\t }\n\t }\n\t }\n\t else if ((op & 64) === 0) { /* 2nd level distance code */\n\t here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n\t continue dodist;\n\t }\n\t else {\n\t strm.msg = 'invalid distance code';\n\t state.mode = BAD;\n\t break top;\n\t }\n\t\n\t break; // need to emulate goto via \"continue\"\n\t }\n\t }\n\t else if ((op & 64) === 0) { /* 2nd level length code */\n\t here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n\t continue dolen;\n\t }\n\t else if (op & 32) { /* end-of-block */\n\t //Tracevv((stderr, \"inflate: end of block\\n\"));\n\t state.mode = TYPE;\n\t break top;\n\t }\n\t else {\n\t strm.msg = 'invalid literal/length code';\n\t state.mode = BAD;\n\t break top;\n\t }\n\t\n\t break; // need to emulate goto via \"continue\"\n\t }\n\t } while (_in < last && _out < end);\n\t\n\t /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n\t len = bits >> 3;\n\t _in -= len;\n\t bits -= len << 3;\n\t hold &= (1 << bits) - 1;\n\t\n\t /* update state and return */\n\t strm.next_in = _in;\n\t strm.next_out = _out;\n\t strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n\t strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n\t state.hold = hold;\n\t state.bits = bits;\n\t return;\n\t};\n\n\n/***/ },\n/* 37 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t'use strict';\n\t\n\t\n\tvar utils = __webpack_require__(33);\n\t\n\tvar MAXBITS = 15;\n\tvar ENOUGH_LENS = 852;\n\tvar ENOUGH_DISTS = 592;\n\t//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\t\n\tvar CODES = 0;\n\tvar LENS = 1;\n\tvar DISTS = 2;\n\t\n\tvar lbase = [ /* Length codes 257..285 base */\n\t 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n\t 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n\t];\n\t\n\tvar lext = [ /* Length codes 257..285 extra */\n\t 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n\t 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n\t];\n\t\n\tvar dbase = [ /* Distance codes 0..29 base */\n\t 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n\t 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n\t 8193, 12289, 16385, 24577, 0, 0\n\t];\n\t\n\tvar dext = [ /* Distance codes 0..29 extra */\n\t 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n\t 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n\t 28, 28, 29, 29, 64, 64\n\t];\n\t\n\tmodule.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n\t{\n\t var bits = opts.bits;\n\t //here = opts.here; /* table entry for duplication */\n\t\n\t var len = 0; /* a code's length in bits */\n\t var sym = 0; /* index of code symbols */\n\t var min = 0, max = 0; /* minimum and maximum code lengths */\n\t var root = 0; /* number of index bits for root table */\n\t var curr = 0; /* number of index bits for current table */\n\t var drop = 0; /* code bits to drop for sub-table */\n\t var left = 0; /* number of prefix codes available */\n\t var used = 0; /* code entries in table used */\n\t var huff = 0; /* Huffman code */\n\t var incr; /* for incrementing code, index */\n\t var fill; /* index for replicating entries */\n\t var low; /* low bits for current root entry */\n\t var mask; /* mask for low root bits */\n\t var next; /* next available space in table */\n\t var base = null; /* base value table to use */\n\t var base_index = 0;\n\t// var shoextra; /* extra bits table to use */\n\t var end; /* use base and extra for symbol > end */\n\t var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n\t var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n\t var extra = null;\n\t var extra_index = 0;\n\t\n\t var here_bits, here_op, here_val;\n\t\n\t /*\n\t Process a set of code lengths to create a canonical Huffman code. The\n\t code lengths are lens[0..codes-1]. Each length corresponds to the\n\t symbols 0..codes-1. The Huffman code is generated by first sorting the\n\t symbols by length from short to long, and retaining the symbol order\n\t for codes with equal lengths. Then the code starts with all zero bits\n\t for the first code of the shortest length, and the codes are integer\n\t increments for the same length, and zeros are appended as the length\n\t increases. For the deflate format, these bits are stored backwards\n\t from their more natural integer increment ordering, and so when the\n\t decoding tables are built in the large loop below, the integer codes\n\t are incremented backwards.\n\t\n\t This routine assumes, but does not check, that all of the entries in\n\t lens[] are in the range 0..MAXBITS. The caller must assure this.\n\t 1..MAXBITS is interpreted as that code length. zero means that that\n\t symbol does not occur in this code.\n\t\n\t The codes are sorted by computing a count of codes for each length,\n\t creating from that a table of starting indices for each length in the\n\t sorted table, and then entering the symbols in order in the sorted\n\t table. The sorted table is work[], with that space being provided by\n\t the caller.\n\t\n\t The length counts are used for other purposes as well, i.e. finding\n\t the minimum and maximum length codes, determining if there are any\n\t codes at all, checking for a valid set of lengths, and looking ahead\n\t at length counts to determine sub-table sizes when building the\n\t decoding tables.\n\t */\n\t\n\t /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n\t for (len = 0; len <= MAXBITS; len++) {\n\t count[len] = 0;\n\t }\n\t for (sym = 0; sym < codes; sym++) {\n\t count[lens[lens_index + sym]]++;\n\t }\n\t\n\t /* bound code lengths, force root to be within code lengths */\n\t root = bits;\n\t for (max = MAXBITS; max >= 1; max--) {\n\t if (count[max] !== 0) { break; }\n\t }\n\t if (root > max) {\n\t root = max;\n\t }\n\t if (max === 0) { /* no symbols to code at all */\n\t //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n\t //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n\t //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n\t table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\t\n\t\n\t //table.op[opts.table_index] = 64;\n\t //table.bits[opts.table_index] = 1;\n\t //table.val[opts.table_index++] = 0;\n\t table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\t\n\t opts.bits = 1;\n\t return 0; /* no symbols, but wait for decoding to report error */\n\t }\n\t for (min = 1; min < max; min++) {\n\t if (count[min] !== 0) { break; }\n\t }\n\t if (root < min) {\n\t root = min;\n\t }\n\t\n\t /* check for an over-subscribed or incomplete set of lengths */\n\t left = 1;\n\t for (len = 1; len <= MAXBITS; len++) {\n\t left <<= 1;\n\t left -= count[len];\n\t if (left < 0) {\n\t return -1;\n\t } /* over-subscribed */\n\t }\n\t if (left > 0 && (type === CODES || max !== 1)) {\n\t return -1; /* incomplete set */\n\t }\n\t\n\t /* generate offsets into symbol table for each length for sorting */\n\t offs[1] = 0;\n\t for (len = 1; len < MAXBITS; len++) {\n\t offs[len + 1] = offs[len] + count[len];\n\t }\n\t\n\t /* sort symbols by length, by symbol order within each length */\n\t for (sym = 0; sym < codes; sym++) {\n\t if (lens[lens_index + sym] !== 0) {\n\t work[offs[lens[lens_index + sym]]++] = sym;\n\t }\n\t }\n\t\n\t /*\n\t Create and fill in decoding tables. In this loop, the table being\n\t filled is at next and has curr index bits. The code being used is huff\n\t with length len. That code is converted to an index by dropping drop\n\t bits off of the bottom. For codes where len is less than drop + curr,\n\t those top drop + curr - len bits are incremented through all values to\n\t fill the table with replicated entries.\n\t\n\t root is the number of index bits for the root table. When len exceeds\n\t root, sub-tables are created pointed to by the root entry with an index\n\t of the low root bits of huff. This is saved in low to check for when a\n\t new sub-table should be started. drop is zero when the root table is\n\t being filled, and drop is root when sub-tables are being filled.\n\t\n\t When a new sub-table is needed, it is necessary to look ahead in the\n\t code lengths to determine what size sub-table is needed. The length\n\t counts are used for this, and so count[] is decremented as codes are\n\t entered in the tables.\n\t\n\t used keeps track of how many table entries have been allocated from the\n\t provided *table space. It is checked for LENS and DIST tables against\n\t the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n\t the initial root table size constants. See the comments in inftrees.h\n\t for more information.\n\t\n\t sym increments through all symbols, and the loop terminates when\n\t all codes of length max, i.e. all codes, have been processed. This\n\t routine permits incomplete codes, so another loop after this one fills\n\t in the rest of the decoding tables with invalid code markers.\n\t */\n\t\n\t /* set up for code type */\n\t // poor man optimization - use if-else instead of switch,\n\t // to avoid deopts in old v8\n\t if (type === CODES) {\n\t base = extra = work; /* dummy value--not used */\n\t end = 19;\n\t\n\t } else if (type === LENS) {\n\t base = lbase;\n\t base_index -= 257;\n\t extra = lext;\n\t extra_index -= 257;\n\t end = 256;\n\t\n\t } else { /* DISTS */\n\t base = dbase;\n\t extra = dext;\n\t end = -1;\n\t }\n\t\n\t /* initialize opts for loop */\n\t huff = 0; /* starting code */\n\t sym = 0; /* starting code symbol */\n\t len = min; /* starting code length */\n\t next = table_index; /* current table to fill in */\n\t curr = root; /* current table index bits */\n\t drop = 0; /* current bits to drop from code for index */\n\t low = -1; /* trigger new sub-table when len > root */\n\t used = 1 << root; /* use root table entries */\n\t mask = used - 1; /* mask for comparing low */\n\t\n\t /* check available table space */\n\t if ((type === LENS && used > ENOUGH_LENS) ||\n\t (type === DISTS && used > ENOUGH_DISTS)) {\n\t return 1;\n\t }\n\t\n\t /* process all codes and make table entries */\n\t for (;;) {\n\t /* create table entry */\n\t here_bits = len - drop;\n\t if (work[sym] < end) {\n\t here_op = 0;\n\t here_val = work[sym];\n\t }\n\t else if (work[sym] > end) {\n\t here_op = extra[extra_index + work[sym]];\n\t here_val = base[base_index + work[sym]];\n\t }\n\t else {\n\t here_op = 32 + 64; /* end of block */\n\t here_val = 0;\n\t }\n\t\n\t /* replicate for those indices with low len bits equal to huff */\n\t incr = 1 << (len - drop);\n\t fill = 1 << curr;\n\t min = fill; /* save offset to next table */\n\t do {\n\t fill -= incr;\n\t table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n\t } while (fill !== 0);\n\t\n\t /* backwards increment the len-bit code huff */\n\t incr = 1 << (len - 1);\n\t while (huff & incr) {\n\t incr >>= 1;\n\t }\n\t if (incr !== 0) {\n\t huff &= incr - 1;\n\t huff += incr;\n\t } else {\n\t huff = 0;\n\t }\n\t\n\t /* go to next symbol, update count, len */\n\t sym++;\n\t if (--count[len] === 0) {\n\t if (len === max) { break; }\n\t len = lens[lens_index + work[sym]];\n\t }\n\t\n\t /* create new sub-table if needed */\n\t if (len > root && (huff & mask) !== low) {\n\t /* if first time, transition to sub-tables */\n\t if (drop === 0) {\n\t drop = root;\n\t }\n\t\n\t /* increment past last table */\n\t next += min; /* here min is 1 << curr */\n\t\n\t /* determine length of next table */\n\t curr = len - drop;\n\t left = 1 << curr;\n\t while (curr + drop < max) {\n\t left -= count[curr + drop];\n\t if (left <= 0) { break; }\n\t curr++;\n\t left <<= 1;\n\t }\n\t\n\t /* check for enough space */\n\t used += 1 << curr;\n\t if ((type === LENS && used > ENOUGH_LENS) ||\n\t (type === DISTS && used > ENOUGH_DISTS)) {\n\t return 1;\n\t }\n\t\n\t /* point entry in root table to sub-table */\n\t low = huff & mask;\n\t /*table.op[low] = curr;\n\t table.bits[low] = root;\n\t table.val[low] = next - opts.table_index;*/\n\t table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n\t }\n\t }\n\t\n\t /* fill in remaining table entry if code is incomplete (guaranteed to have\n\t at most one remaining entry, since if the code is incomplete, the\n\t maximum code length that was allowed to get this far is one bit) */\n\t if (huff !== 0) {\n\t //table.op[next + huff] = 64; /* invalid code marker */\n\t //table.bits[next + huff] = len - drop;\n\t //table.val[next + huff] = 0;\n\t table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n\t }\n\t\n\t /* set return parameters */\n\t //opts.table_index += used;\n\t opts.bits = root;\n\t return 0;\n\t};\n\n\n/***/ },\n/* 38 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t// String encode/decode helpers\n\t'use strict';\n\t\n\t\n\tvar utils = __webpack_require__(33);\n\t\n\t\n\t// Quick check if we can use fast array to bin string conversion\n\t//\n\t// - apply(Array) can fail on Android 2.2\n\t// - apply(Uint8Array) can fail on iOS 5.1 Safary\n\t//\n\tvar STR_APPLY_OK = true;\n\tvar STR_APPLY_UIA_OK = true;\n\t\n\ttry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\n\ttry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\t\n\t\n\t// Table with utf8 lengths (calculated by first byte of sequence)\n\t// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n\t// because max possible codepoint is 0x10ffff\n\tvar _utf8len = new utils.Buf8(256);\n\tfor (var q = 0; q < 256; q++) {\n\t _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n\t}\n\t_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\t\n\t\n\t// convert string to array (typed, when possible)\n\texports.string2buf = function (str) {\n\t var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\t\n\t // count binary size\n\t for (m_pos = 0; m_pos < str_len; m_pos++) {\n\t c = str.charCodeAt(m_pos);\n\t if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n\t c2 = str.charCodeAt(m_pos + 1);\n\t if ((c2 & 0xfc00) === 0xdc00) {\n\t c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n\t m_pos++;\n\t }\n\t }\n\t buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n\t }\n\t\n\t // allocate buffer\n\t buf = new utils.Buf8(buf_len);\n\t\n\t // convert\n\t for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n\t c = str.charCodeAt(m_pos);\n\t if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n\t c2 = str.charCodeAt(m_pos + 1);\n\t if ((c2 & 0xfc00) === 0xdc00) {\n\t c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n\t m_pos++;\n\t }\n\t }\n\t if (c < 0x80) {\n\t /* one byte */\n\t buf[i++] = c;\n\t } else if (c < 0x800) {\n\t /* two bytes */\n\t buf[i++] = 0xC0 | (c >>> 6);\n\t buf[i++] = 0x80 | (c & 0x3f);\n\t } else if (c < 0x10000) {\n\t /* three bytes */\n\t buf[i++] = 0xE0 | (c >>> 12);\n\t buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n\t buf[i++] = 0x80 | (c & 0x3f);\n\t } else {\n\t /* four bytes */\n\t buf[i++] = 0xf0 | (c >>> 18);\n\t buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n\t buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n\t buf[i++] = 0x80 | (c & 0x3f);\n\t }\n\t }\n\t\n\t return buf;\n\t};\n\t\n\t// Helper (used in 2 places)\n\tfunction buf2binstring(buf, len) {\n\t // use fallback for big arrays to avoid stack overflow\n\t if (len < 65537) {\n\t if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n\t return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));\n\t }\n\t }\n\t\n\t var result = '';\n\t for (var i = 0; i < len; i++) {\n\t result += String.fromCharCode(buf[i]);\n\t }\n\t return result;\n\t}\n\t\n\t\n\t// Convert byte array to binary string\n\texports.buf2binstring = function (buf) {\n\t return buf2binstring(buf, buf.length);\n\t};\n\t\n\t\n\t// Convert binary string (typed, when possible)\n\texports.binstring2buf = function (str) {\n\t var buf = new utils.Buf8(str.length);\n\t for (var i = 0, len = buf.length; i < len; i++) {\n\t buf[i] = str.charCodeAt(i);\n\t }\n\t return buf;\n\t};\n\t\n\t\n\t// convert array to string\n\texports.buf2string = function (buf, max) {\n\t var i, out, c, c_len;\n\t var len = max || buf.length;\n\t\n\t // Reserve max possible length (2 words per char)\n\t // NB: by unknown reasons, Array is significantly faster for\n\t // String.fromCharCode.apply than Uint16Array.\n\t var utf16buf = new Array(len * 2);\n\t\n\t for (out = 0, i = 0; i < len;) {\n\t c = buf[i++];\n\t // quick process ascii\n\t if (c < 0x80) { utf16buf[out++] = c; continue; }\n\t\n\t c_len = _utf8len[c];\n\t // skip 5 & 6 byte codes\n\t if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\t\n\t // apply mask on first byte\n\t c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n\t // join the rest\n\t while (c_len > 1 && i < len) {\n\t c = (c << 6) | (buf[i++] & 0x3f);\n\t c_len--;\n\t }\n\t\n\t // terminated by end of string?\n\t if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\t\n\t if (c < 0x10000) {\n\t utf16buf[out++] = c;\n\t } else {\n\t c -= 0x10000;\n\t utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n\t utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n\t }\n\t }\n\t\n\t return buf2binstring(utf16buf, out);\n\t};\n\t\n\t\n\t// Calculate max possible position in utf8 buffer,\n\t// that will not break sequence. If that's not possible\n\t// - (very small limits) return max size as is.\n\t//\n\t// buf[] - utf8 bytes array\n\t// max - length limit (mandatory);\n\texports.utf8border = function (buf, max) {\n\t var pos;\n\t\n\t max = max || buf.length;\n\t if (max > buf.length) { max = buf.length; }\n\t\n\t // go back from last position, until start of sequence found\n\t pos = max - 1;\n\t while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\t\n\t // Fuckup - very small and broken sequence,\n\t // return max, because we should return something anyway.\n\t if (pos < 0) { return max; }\n\t\n\t // If we came to start of buffer - that means vuffer is too small,\n\t // return max too.\n\t if (pos === 0) { return max; }\n\t\n\t return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n\t};\n\n\n/***/ },\n/* 39 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t\n\tmodule.exports = {\n\t\n\t /* Allowed flush values; see deflate() and inflate() below for details */\n\t Z_NO_FLUSH: 0,\n\t Z_PARTIAL_FLUSH: 1,\n\t Z_SYNC_FLUSH: 2,\n\t Z_FULL_FLUSH: 3,\n\t Z_FINISH: 4,\n\t Z_BLOCK: 5,\n\t Z_TREES: 6,\n\t\n\t /* Return codes for the compression/decompression functions. Negative values\n\t * are errors, positive values are used for special but normal events.\n\t */\n\t Z_OK: 0,\n\t Z_STREAM_END: 1,\n\t Z_NEED_DICT: 2,\n\t Z_ERRNO: -1,\n\t Z_STREAM_ERROR: -2,\n\t Z_DATA_ERROR: -3,\n\t //Z_MEM_ERROR: -4,\n\t Z_BUF_ERROR: -5,\n\t //Z_VERSION_ERROR: -6,\n\t\n\t /* compression levels */\n\t Z_NO_COMPRESSION: 0,\n\t Z_BEST_SPEED: 1,\n\t Z_BEST_COMPRESSION: 9,\n\t Z_DEFAULT_COMPRESSION: -1,\n\t\n\t\n\t Z_FILTERED: 1,\n\t Z_HUFFMAN_ONLY: 2,\n\t Z_RLE: 3,\n\t Z_FIXED: 4,\n\t Z_DEFAULT_STRATEGY: 0,\n\t\n\t /* Possible values of the data_type field (though see inflate()) */\n\t Z_BINARY: 0,\n\t Z_TEXT: 1,\n\t //Z_ASCII: 1, // = Z_TEXT (deprecated)\n\t Z_UNKNOWN: 2,\n\t\n\t /* The deflate compression method */\n\t Z_DEFLATED: 8\n\t //Z_NULL: null // Use -1 or null inline, depending on var type\n\t};\n\n\n/***/ },\n/* 40 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\tmodule.exports = {\n\t 2: 'need dictionary', /* Z_NEED_DICT 2 */\n\t 1: 'stream end', /* Z_STREAM_END 1 */\n\t 0: '', /* Z_OK 0 */\n\t '-1': 'file error', /* Z_ERRNO (-1) */\n\t '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n\t '-3': 'data error', /* Z_DATA_ERROR (-3) */\n\t '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n\t '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n\t '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n\t};\n\n\n/***/ },\n/* 41 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t\n\tfunction ZStream() {\n\t /* next input byte */\n\t this.input = null; // JS specific, because we have no pointers\n\t this.next_in = 0;\n\t /* number of bytes available at input */\n\t this.avail_in = 0;\n\t /* total number of input bytes read so far */\n\t this.total_in = 0;\n\t /* next output byte should be put there */\n\t this.output = null; // JS specific, because we have no pointers\n\t this.next_out = 0;\n\t /* remaining free space at output */\n\t this.avail_out = 0;\n\t /* total number of bytes output so far */\n\t this.total_out = 0;\n\t /* last error message, NULL if no error */\n\t this.msg = ''/*Z_NULL*/;\n\t /* not visible by applications */\n\t this.state = null;\n\t /* best guess about the data type: binary or text */\n\t this.data_type = 2/*Z_UNKNOWN*/;\n\t /* adler32 value of the uncompressed data */\n\t this.adler = 0;\n\t}\n\t\n\tmodule.exports = ZStream;\n\n\n/***/ },\n/* 42 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\t\n\tfunction GZheader() {\n\t /* true if compressed data believed to be text */\n\t this.text = 0;\n\t /* modification time */\n\t this.time = 0;\n\t /* extra flags (not used when writing a gzip file) */\n\t this.xflags = 0;\n\t /* operating system */\n\t this.os = 0;\n\t /* pointer to extra field or Z_NULL if none */\n\t this.extra = null;\n\t /* extra field length (valid if extra != Z_NULL) */\n\t this.extra_len = 0; // Actually, we don't need it in JS,\n\t // but leave for few code modifications\n\t\n\t //\n\t // Setup limits is not necessary because in js we should not preallocate memory\n\t // for inflate use constant limit in 65536 bytes\n\t //\n\t\n\t /* space at extra (only when reading header) */\n\t // this.extra_max = 0;\n\t /* pointer to zero-terminated file name or Z_NULL */\n\t this.name = '';\n\t /* space at name (only when reading header) */\n\t // this.name_max = 0;\n\t /* pointer to zero-terminated comment or Z_NULL */\n\t this.comment = '';\n\t /* space at comment (only when reading header) */\n\t // this.comm_max = 0;\n\t /* true if there was or will be a header crc */\n\t this.hcrc = 0;\n\t /* true when done reading gzip header (not used when writing a gzip file) */\n\t this.done = false;\n\t}\n\t\n\tmodule.exports = GZheader;\n\n\n/***/ }\n/******/ ])\n});\n;\n//# sourceMappingURL=browserfs.js.map","module.exports = BrowserFS.BFSRequire('buffer').Buffer;\n","module.exports = BrowserFS.BFSRequire('fs');\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst BrowserFS = __importStar(require(\"browserfs\"));\nconst util_1 = require(\"./util\");\nfunction init(root = \"assembly.zip\") {\n return __awaiter(this, void 0, void 0, function* () {\n BrowserFS.install(global || window);\n return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {\n let zipData;\n if (typeof root === \"string\") {\n let response = yield fetch(root);\n zipData = yield response.arrayBuffer();\n }\n else {\n zipData = root;\n }\n BrowserFS.configure({\n fs: \"MountableFileSystem\",\n options: {\n \"/\": {\n fs: \"OverlayFS\",\n options: {\n readable: {\n fs: \"ZipFS\",\n options: {\n // Wrap as Buffer object.\n zipData: Buffer.from(zipData)\n }\n },\n writable: {\n fs: \"InMemory\",\n options: {}\n }\n }\n },\n }\n }, function (e) {\n if (e) {\n // An error occurred.\n reject(e);\n }\n resolve();\n });\n }));\n });\n}\nexports.init = init;\nfunction attachWorker(worker) {\n BrowserFS.FileSystem.WorkerFS.attachRemoteListener(worker);\n}\nexports.attachWorker = attachWorker;\nfunction initWorker() {\n return __awaiter(this, void 0, void 0, function* () {\n yield util_1.promisfy(BrowserFS.configure)({ fs: \"WorkerFS\", options: { worker: self } });\n });\n}\nexports.initWorker = initWorker;\n// import * as _fs from \"fs\";\n// export * from \"fs-extra\";\n","\"use strict\";\n/// \nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst fs_1 = require(\"./fs\");\nconst fs = __importStar(require(\"fs\"));\nconst util_1 = require(\"./util\");\nwindow.URL = window.URL || window.webkitURL;\nlet worker;\nfunction main() {\n return __awaiter(this, void 0, void 0, function* () {\n yield fs_1.init(\"./assembly.zip\");\n // (window as any).kernel = new Kernel();\n window.fs = fs;\n console.log(yield util_1.promisfy(fs.readdir)(\".\"));\n // fs.readdirSync(\".\").map(async(dir)=> console.log(dir + \"/\" + await promisfy(fs.readdir)(dir)));\n let workerSource = yield util_1.promisfy(fs.readFile)(\"./worker.js\");\n console.log(workerSource.toString());\n worker = new Worker(\"./worker.js\");\n window.worker = worker;\n fs_1.attachWorker(window.worker);\n window.worker.onmessage = console.log;\n worker.postMessage({ path: \"/assembly/echo.ts\" });\n // worker.onmessage\n // await fs.access.__promisify__(\"/assembly/bin/echo.ts\")\n });\n}\nmain();\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n// type asyncCallback = (...args: any[], fn: (err: any, contents: T) => T) => void;\nfunction promisfy(fn) {\n return (...args) => new Promise((resolve, reject) => {\n fn(...args, (err, contents) => {\n if (err)\n reject(err);\n resolve(contents);\n });\n });\n}\nexports.promisfy = promisfy;\n"],"sourceRoot":""}
\ No newline at end of file
diff --git a/dist/main.js b/dist/main.js
deleted file mode 100644
index c0f0e01..0000000
--- a/dist/main.js
+++ /dev/null
@@ -1,171881 +0,0 @@
-/******/ (function(modules) { // webpackBootstrap
-/******/ // The module cache
-/******/ var installedModules = {};
-/******/
-/******/ // The require function
-/******/ function __webpack_require__(moduleId) {
-/******/
-/******/ // Check if module is in cache
-/******/ if(installedModules[moduleId]) {
-/******/ return installedModules[moduleId].exports;
-/******/ }
-/******/ // Create a new module (and put it into the cache)
-/******/ var module = installedModules[moduleId] = {
-/******/ i: moduleId,
-/******/ l: false,
-/******/ exports: {}
-/******/ };
-/******/
-/******/ // Execute the module function
-/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
-/******/
-/******/ // Flag the module as loaded
-/******/ module.l = true;
-/******/
-/******/ // Return the exports of the module
-/******/ return module.exports;
-/******/ }
-/******/
-/******/
-/******/ // expose the modules object (__webpack_modules__)
-/******/ __webpack_require__.m = modules;
-/******/
-/******/ // expose the module cache
-/******/ __webpack_require__.c = installedModules;
-/******/
-/******/ // define getter function for harmony exports
-/******/ __webpack_require__.d = function(exports, name, getter) {
-/******/ if(!__webpack_require__.o(exports, name)) {
-/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
-/******/ }
-/******/ };
-/******/
-/******/ // define __esModule on exports
-/******/ __webpack_require__.r = function(exports) {
-/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
-/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
-/******/ }
-/******/ Object.defineProperty(exports, '__esModule', { value: true });
-/******/ };
-/******/
-/******/ // create a fake namespace object
-/******/ // mode & 1: value is a module id, require it
-/******/ // mode & 2: merge all properties of value into the ns
-/******/ // mode & 4: return value when already ns object
-/******/ // mode & 8|1: behave like require
-/******/ __webpack_require__.t = function(value, mode) {
-/******/ if(mode & 1) value = __webpack_require__(value);
-/******/ if(mode & 8) return value;
-/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
-/******/ var ns = Object.create(null);
-/******/ __webpack_require__.r(ns);
-/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
-/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
-/******/ return ns;
-/******/ };
-/******/
-/******/ // getDefaultExport function for compatibility with non-harmony modules
-/******/ __webpack_require__.n = function(module) {
-/******/ var getter = module && module.__esModule ?
-/******/ function getDefault() { return module['default']; } :
-/******/ function getModuleExports() { return module; };
-/******/ __webpack_require__.d(getter, 'a', getter);
-/******/ return getter;
-/******/ };
-/******/
-/******/ // Object.prototype.hasOwnProperty.call
-/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
-/******/
-/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "";
-/******/
-/******/
-/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 0);
-/******/ })
-/************************************************************************/
-/******/ ({
-
-/***/ "./node_modules/asn1.js/lib/asn1.js":
-/*!******************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1.js ***!
- \******************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var asn1 = exports;
-
-asn1.bignum = __webpack_require__(/*! bn.js */ "./node_modules/bn.js/lib/bn.js");
-
-asn1.define = __webpack_require__(/*! ./asn1/api */ "./node_modules/asn1.js/lib/asn1/api.js").define;
-asn1.base = __webpack_require__(/*! ./asn1/base */ "./node_modules/asn1.js/lib/asn1/base/index.js");
-asn1.constants = __webpack_require__(/*! ./asn1/constants */ "./node_modules/asn1.js/lib/asn1/constants/index.js");
-asn1.decoders = __webpack_require__(/*! ./asn1/decoders */ "./node_modules/asn1.js/lib/asn1/decoders/index.js");
-asn1.encoders = __webpack_require__(/*! ./asn1/encoders */ "./node_modules/asn1.js/lib/asn1/encoders/index.js");
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/api.js":
-/*!**********************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/api.js ***!
- \**********************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var asn1 = __webpack_require__(/*! ../asn1 */ "./node_modules/asn1.js/lib/asn1.js");
-var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
-
-var api = exports;
-
-api.define = function define(name, body) {
- return new Entity(name, body);
-};
-
-function Entity(name, body) {
- this.name = name;
- this.body = body;
-
- this.decoders = {};
- this.encoders = {};
-};
-
-Entity.prototype._createNamed = function createNamed(base) {
- var named;
- try {
- named = __webpack_require__(/*! vm */ "./node_modules/vm-browserify/index.js").runInThisContext(
- '(function ' + this.name + '(entity) {\n' +
- ' this._initNamed(entity);\n' +
- '})'
- );
- } catch (e) {
- named = function (entity) {
- this._initNamed(entity);
- };
- }
- inherits(named, base);
- named.prototype._initNamed = function initnamed(entity) {
- base.call(this, entity);
- };
-
- return new named(this);
-};
-
-Entity.prototype._getDecoder = function _getDecoder(enc) {
- enc = enc || 'der';
- // Lazily create decoder
- if (!this.decoders.hasOwnProperty(enc))
- this.decoders[enc] = this._createNamed(asn1.decoders[enc]);
- return this.decoders[enc];
-};
-
-Entity.prototype.decode = function decode(data, enc, options) {
- return this._getDecoder(enc).decode(data, options);
-};
-
-Entity.prototype._getEncoder = function _getEncoder(enc) {
- enc = enc || 'der';
- // Lazily create encoder
- if (!this.encoders.hasOwnProperty(enc))
- this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
- return this.encoders[enc];
-};
-
-Entity.prototype.encode = function encode(data, enc, /* internal */ reporter) {
- return this._getEncoder(enc).encode(data, reporter);
-};
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/base/buffer.js":
-/*!******************************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/base/buffer.js ***!
- \******************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
-var Reporter = __webpack_require__(/*! ../base */ "./node_modules/asn1.js/lib/asn1/base/index.js").Reporter;
-var Buffer = __webpack_require__(/*! buffer */ "./node_modules/browserfs/dist/shims/buffer.js").Buffer;
-
-function DecoderBuffer(base, options) {
- Reporter.call(this, options);
- if (!Buffer.isBuffer(base)) {
- this.error('Input not Buffer');
- return;
- }
-
- this.base = base;
- this.offset = 0;
- this.length = base.length;
-}
-inherits(DecoderBuffer, Reporter);
-exports.DecoderBuffer = DecoderBuffer;
-
-DecoderBuffer.prototype.save = function save() {
- return { offset: this.offset, reporter: Reporter.prototype.save.call(this) };
-};
-
-DecoderBuffer.prototype.restore = function restore(save) {
- // Return skipped data
- var res = new DecoderBuffer(this.base);
- res.offset = save.offset;
- res.length = this.offset;
-
- this.offset = save.offset;
- Reporter.prototype.restore.call(this, save.reporter);
-
- return res;
-};
-
-DecoderBuffer.prototype.isEmpty = function isEmpty() {
- return this.offset === this.length;
-};
-
-DecoderBuffer.prototype.readUInt8 = function readUInt8(fail) {
- if (this.offset + 1 <= this.length)
- return this.base.readUInt8(this.offset++, true);
- else
- return this.error(fail || 'DecoderBuffer overrun');
-}
-
-DecoderBuffer.prototype.skip = function skip(bytes, fail) {
- if (!(this.offset + bytes <= this.length))
- return this.error(fail || 'DecoderBuffer overrun');
-
- var res = new DecoderBuffer(this.base);
-
- // Share reporter state
- res._reporterState = this._reporterState;
-
- res.offset = this.offset;
- res.length = this.offset + bytes;
- this.offset += bytes;
- return res;
-}
-
-DecoderBuffer.prototype.raw = function raw(save) {
- return this.base.slice(save ? save.offset : this.offset, this.length);
-}
-
-function EncoderBuffer(value, reporter) {
- if (Array.isArray(value)) {
- this.length = 0;
- this.value = value.map(function(item) {
- if (!(item instanceof EncoderBuffer))
- item = new EncoderBuffer(item, reporter);
- this.length += item.length;
- return item;
- }, this);
- } else if (typeof value === 'number') {
- if (!(0 <= value && value <= 0xff))
- return reporter.error('non-byte EncoderBuffer value');
- this.value = value;
- this.length = 1;
- } else if (typeof value === 'string') {
- this.value = value;
- this.length = Buffer.byteLength(value);
- } else if (Buffer.isBuffer(value)) {
- this.value = value;
- this.length = value.length;
- } else {
- return reporter.error('Unsupported type: ' + typeof value);
- }
-}
-exports.EncoderBuffer = EncoderBuffer;
-
-EncoderBuffer.prototype.join = function join(out, offset) {
- if (!out)
- out = new Buffer(this.length);
- if (!offset)
- offset = 0;
-
- if (this.length === 0)
- return out;
-
- if (Array.isArray(this.value)) {
- this.value.forEach(function(item) {
- item.join(out, offset);
- offset += item.length;
- });
- } else {
- if (typeof this.value === 'number')
- out[offset] = this.value;
- else if (typeof this.value === 'string')
- out.write(this.value, offset);
- else if (Buffer.isBuffer(this.value))
- this.value.copy(out, offset);
- offset += this.length;
- }
-
- return out;
-};
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/base/index.js":
-/*!*****************************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/base/index.js ***!
- \*****************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var base = exports;
-
-base.Reporter = __webpack_require__(/*! ./reporter */ "./node_modules/asn1.js/lib/asn1/base/reporter.js").Reporter;
-base.DecoderBuffer = __webpack_require__(/*! ./buffer */ "./node_modules/asn1.js/lib/asn1/base/buffer.js").DecoderBuffer;
-base.EncoderBuffer = __webpack_require__(/*! ./buffer */ "./node_modules/asn1.js/lib/asn1/base/buffer.js").EncoderBuffer;
-base.Node = __webpack_require__(/*! ./node */ "./node_modules/asn1.js/lib/asn1/base/node.js");
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/base/node.js":
-/*!****************************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/base/node.js ***!
- \****************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var Reporter = __webpack_require__(/*! ../base */ "./node_modules/asn1.js/lib/asn1/base/index.js").Reporter;
-var EncoderBuffer = __webpack_require__(/*! ../base */ "./node_modules/asn1.js/lib/asn1/base/index.js").EncoderBuffer;
-var DecoderBuffer = __webpack_require__(/*! ../base */ "./node_modules/asn1.js/lib/asn1/base/index.js").DecoderBuffer;
-var assert = __webpack_require__(/*! minimalistic-assert */ "./node_modules/minimalistic-assert/index.js");
-
-// Supported tags
-var tags = [
- 'seq', 'seqof', 'set', 'setof', 'objid', 'bool',
- 'gentime', 'utctime', 'null_', 'enum', 'int', 'objDesc',
- 'bitstr', 'bmpstr', 'charstr', 'genstr', 'graphstr', 'ia5str', 'iso646str',
- 'numstr', 'octstr', 'printstr', 't61str', 'unistr', 'utf8str', 'videostr'
-];
-
-// Public methods list
-var methods = [
- 'key', 'obj', 'use', 'optional', 'explicit', 'implicit', 'def', 'choice',
- 'any', 'contains'
-].concat(tags);
-
-// Overrided methods list
-var overrided = [
- '_peekTag', '_decodeTag', '_use',
- '_decodeStr', '_decodeObjid', '_decodeTime',
- '_decodeNull', '_decodeInt', '_decodeBool', '_decodeList',
-
- '_encodeComposite', '_encodeStr', '_encodeObjid', '_encodeTime',
- '_encodeNull', '_encodeInt', '_encodeBool'
-];
-
-function Node(enc, parent) {
- var state = {};
- this._baseState = state;
-
- state.enc = enc;
-
- state.parent = parent || null;
- state.children = null;
-
- // State
- state.tag = null;
- state.args = null;
- state.reverseArgs = null;
- state.choice = null;
- state.optional = false;
- state.any = false;
- state.obj = false;
- state.use = null;
- state.useDecoder = null;
- state.key = null;
- state['default'] = null;
- state.explicit = null;
- state.implicit = null;
- state.contains = null;
-
- // Should create new instance on each method
- if (!state.parent) {
- state.children = [];
- this._wrap();
- }
-}
-module.exports = Node;
-
-var stateProps = [
- 'enc', 'parent', 'children', 'tag', 'args', 'reverseArgs', 'choice',
- 'optional', 'any', 'obj', 'use', 'alteredUse', 'key', 'default', 'explicit',
- 'implicit', 'contains'
-];
-
-Node.prototype.clone = function clone() {
- var state = this._baseState;
- var cstate = {};
- stateProps.forEach(function(prop) {
- cstate[prop] = state[prop];
- });
- var res = new this.constructor(cstate.parent);
- res._baseState = cstate;
- return res;
-};
-
-Node.prototype._wrap = function wrap() {
- var state = this._baseState;
- methods.forEach(function(method) {
- this[method] = function _wrappedMethod() {
- var clone = new this.constructor(this);
- state.children.push(clone);
- return clone[method].apply(clone, arguments);
- };
- }, this);
-};
-
-Node.prototype._init = function init(body) {
- var state = this._baseState;
-
- assert(state.parent === null);
- body.call(this);
-
- // Filter children
- state.children = state.children.filter(function(child) {
- return child._baseState.parent === this;
- }, this);
- assert.equal(state.children.length, 1, 'Root node can have only one child');
-};
-
-Node.prototype._useArgs = function useArgs(args) {
- var state = this._baseState;
-
- // Filter children and args
- var children = args.filter(function(arg) {
- return arg instanceof this.constructor;
- }, this);
- args = args.filter(function(arg) {
- return !(arg instanceof this.constructor);
- }, this);
-
- if (children.length !== 0) {
- assert(state.children === null);
- state.children = children;
-
- // Replace parent to maintain backward link
- children.forEach(function(child) {
- child._baseState.parent = this;
- }, this);
- }
- if (args.length !== 0) {
- assert(state.args === null);
- state.args = args;
- state.reverseArgs = args.map(function(arg) {
- if (typeof arg !== 'object' || arg.constructor !== Object)
- return arg;
-
- var res = {};
- Object.keys(arg).forEach(function(key) {
- if (key == (key | 0))
- key |= 0;
- var value = arg[key];
- res[value] = key;
- });
- return res;
- });
- }
-};
-
-//
-// Overrided methods
-//
-
-overrided.forEach(function(method) {
- Node.prototype[method] = function _overrided() {
- var state = this._baseState;
- throw new Error(method + ' not implemented for encoding: ' + state.enc);
- };
-});
-
-//
-// Public methods
-//
-
-tags.forEach(function(tag) {
- Node.prototype[tag] = function _tagMethod() {
- var state = this._baseState;
- var args = Array.prototype.slice.call(arguments);
-
- assert(state.tag === null);
- state.tag = tag;
-
- this._useArgs(args);
-
- return this;
- };
-});
-
-Node.prototype.use = function use(item) {
- assert(item);
- var state = this._baseState;
-
- assert(state.use === null);
- state.use = item;
-
- return this;
-};
-
-Node.prototype.optional = function optional() {
- var state = this._baseState;
-
- state.optional = true;
-
- return this;
-};
-
-Node.prototype.def = function def(val) {
- var state = this._baseState;
-
- assert(state['default'] === null);
- state['default'] = val;
- state.optional = true;
-
- return this;
-};
-
-Node.prototype.explicit = function explicit(num) {
- var state = this._baseState;
-
- assert(state.explicit === null && state.implicit === null);
- state.explicit = num;
-
- return this;
-};
-
-Node.prototype.implicit = function implicit(num) {
- var state = this._baseState;
-
- assert(state.explicit === null && state.implicit === null);
- state.implicit = num;
-
- return this;
-};
-
-Node.prototype.obj = function obj() {
- var state = this._baseState;
- var args = Array.prototype.slice.call(arguments);
-
- state.obj = true;
-
- if (args.length !== 0)
- this._useArgs(args);
-
- return this;
-};
-
-Node.prototype.key = function key(newKey) {
- var state = this._baseState;
-
- assert(state.key === null);
- state.key = newKey;
-
- return this;
-};
-
-Node.prototype.any = function any() {
- var state = this._baseState;
-
- state.any = true;
-
- return this;
-};
-
-Node.prototype.choice = function choice(obj) {
- var state = this._baseState;
-
- assert(state.choice === null);
- state.choice = obj;
- this._useArgs(Object.keys(obj).map(function(key) {
- return obj[key];
- }));
-
- return this;
-};
-
-Node.prototype.contains = function contains(item) {
- var state = this._baseState;
-
- assert(state.use === null);
- state.contains = item;
-
- return this;
-};
-
-//
-// Decoding
-//
-
-Node.prototype._decode = function decode(input, options) {
- var state = this._baseState;
-
- // Decode root node
- if (state.parent === null)
- return input.wrapResult(state.children[0]._decode(input, options));
-
- var result = state['default'];
- var present = true;
-
- var prevKey = null;
- if (state.key !== null)
- prevKey = input.enterKey(state.key);
-
- // Check if tag is there
- if (state.optional) {
- var tag = null;
- if (state.explicit !== null)
- tag = state.explicit;
- else if (state.implicit !== null)
- tag = state.implicit;
- else if (state.tag !== null)
- tag = state.tag;
-
- if (tag === null && !state.any) {
- // Trial and Error
- var save = input.save();
- try {
- if (state.choice === null)
- this._decodeGeneric(state.tag, input, options);
- else
- this._decodeChoice(input, options);
- present = true;
- } catch (e) {
- present = false;
- }
- input.restore(save);
- } else {
- present = this._peekTag(input, tag, state.any);
-
- if (input.isError(present))
- return present;
- }
- }
-
- // Push object on stack
- var prevObj;
- if (state.obj && present)
- prevObj = input.enterObject();
-
- if (present) {
- // Unwrap explicit values
- if (state.explicit !== null) {
- var explicit = this._decodeTag(input, state.explicit);
- if (input.isError(explicit))
- return explicit;
- input = explicit;
- }
-
- var start = input.offset;
-
- // Unwrap implicit and normal values
- if (state.use === null && state.choice === null) {
- if (state.any)
- var save = input.save();
- var body = this._decodeTag(
- input,
- state.implicit !== null ? state.implicit : state.tag,
- state.any
- );
- if (input.isError(body))
- return body;
-
- if (state.any)
- result = input.raw(save);
- else
- input = body;
- }
-
- if (options && options.track && state.tag !== null)
- options.track(input.path(), start, input.length, 'tagged');
-
- if (options && options.track && state.tag !== null)
- options.track(input.path(), input.offset, input.length, 'content');
-
- // Select proper method for tag
- if (state.any)
- result = result;
- else if (state.choice === null)
- result = this._decodeGeneric(state.tag, input, options);
- else
- result = this._decodeChoice(input, options);
-
- if (input.isError(result))
- return result;
-
- // Decode children
- if (!state.any && state.choice === null && state.children !== null) {
- state.children.forEach(function decodeChildren(child) {
- // NOTE: We are ignoring errors here, to let parser continue with other
- // parts of encoded data
- child._decode(input, options);
- });
- }
-
- // Decode contained/encoded by schema, only in bit or octet strings
- if (state.contains && (state.tag === 'octstr' || state.tag === 'bitstr')) {
- var data = new DecoderBuffer(result);
- result = this._getUse(state.contains, input._reporterState.obj)
- ._decode(data, options);
- }
- }
-
- // Pop object
- if (state.obj && present)
- result = input.leaveObject(prevObj);
-
- // Set key
- if (state.key !== null && (result !== null || present === true))
- input.leaveKey(prevKey, state.key, result);
- else if (prevKey !== null)
- input.exitKey(prevKey);
-
- return result;
-};
-
-Node.prototype._decodeGeneric = function decodeGeneric(tag, input, options) {
- var state = this._baseState;
-
- if (tag === 'seq' || tag === 'set')
- return null;
- if (tag === 'seqof' || tag === 'setof')
- return this._decodeList(input, tag, state.args[0], options);
- else if (/str$/.test(tag))
- return this._decodeStr(input, tag, options);
- else if (tag === 'objid' && state.args)
- return this._decodeObjid(input, state.args[0], state.args[1], options);
- else if (tag === 'objid')
- return this._decodeObjid(input, null, null, options);
- else if (tag === 'gentime' || tag === 'utctime')
- return this._decodeTime(input, tag, options);
- else if (tag === 'null_')
- return this._decodeNull(input, options);
- else if (tag === 'bool')
- return this._decodeBool(input, options);
- else if (tag === 'objDesc')
- return this._decodeStr(input, tag, options);
- else if (tag === 'int' || tag === 'enum')
- return this._decodeInt(input, state.args && state.args[0], options);
-
- if (state.use !== null) {
- return this._getUse(state.use, input._reporterState.obj)
- ._decode(input, options);
- } else {
- return input.error('unknown tag: ' + tag);
- }
-};
-
-Node.prototype._getUse = function _getUse(entity, obj) {
-
- var state = this._baseState;
- // Create altered use decoder if implicit is set
- state.useDecoder = this._use(entity, obj);
- assert(state.useDecoder._baseState.parent === null);
- state.useDecoder = state.useDecoder._baseState.children[0];
- if (state.implicit !== state.useDecoder._baseState.implicit) {
- state.useDecoder = state.useDecoder.clone();
- state.useDecoder._baseState.implicit = state.implicit;
- }
- return state.useDecoder;
-};
-
-Node.prototype._decodeChoice = function decodeChoice(input, options) {
- var state = this._baseState;
- var result = null;
- var match = false;
-
- Object.keys(state.choice).some(function(key) {
- var save = input.save();
- var node = state.choice[key];
- try {
- var value = node._decode(input, options);
- if (input.isError(value))
- return false;
-
- result = { type: key, value: value };
- match = true;
- } catch (e) {
- input.restore(save);
- return false;
- }
- return true;
- }, this);
-
- if (!match)
- return input.error('Choice not matched');
-
- return result;
-};
-
-//
-// Encoding
-//
-
-Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
- return new EncoderBuffer(data, this.reporter);
-};
-
-Node.prototype._encode = function encode(data, reporter, parent) {
- var state = this._baseState;
- if (state['default'] !== null && state['default'] === data)
- return;
-
- var result = this._encodeValue(data, reporter, parent);
- if (result === undefined)
- return;
-
- if (this._skipDefault(result, reporter, parent))
- return;
-
- return result;
-};
-
-Node.prototype._encodeValue = function encode(data, reporter, parent) {
- var state = this._baseState;
-
- // Decode root node
- if (state.parent === null)
- return state.children[0]._encode(data, reporter || new Reporter());
-
- var result = null;
-
- // Set reporter to share it with a child class
- this.reporter = reporter;
-
- // Check if data is there
- if (state.optional && data === undefined) {
- if (state['default'] !== null)
- data = state['default']
- else
- return;
- }
-
- // Encode children first
- var content = null;
- var primitive = false;
- if (state.any) {
- // Anything that was given is translated to buffer
- result = this._createEncoderBuffer(data);
- } else if (state.choice) {
- result = this._encodeChoice(data, reporter);
- } else if (state.contains) {
- content = this._getUse(state.contains, parent)._encode(data, reporter);
- primitive = true;
- } else if (state.children) {
- content = state.children.map(function(child) {
- if (child._baseState.tag === 'null_')
- return child._encode(null, reporter, data);
-
- if (child._baseState.key === null)
- return reporter.error('Child should have a key');
- var prevKey = reporter.enterKey(child._baseState.key);
-
- if (typeof data !== 'object')
- return reporter.error('Child expected, but input is not object');
-
- var res = child._encode(data[child._baseState.key], reporter, data);
- reporter.leaveKey(prevKey);
-
- return res;
- }, this).filter(function(child) {
- return child;
- });
- content = this._createEncoderBuffer(content);
- } else {
- if (state.tag === 'seqof' || state.tag === 'setof') {
- // TODO(indutny): this should be thrown on DSL level
- if (!(state.args && state.args.length === 1))
- return reporter.error('Too many args for : ' + state.tag);
-
- if (!Array.isArray(data))
- return reporter.error('seqof/setof, but data is not Array');
-
- var child = this.clone();
- child._baseState.implicit = null;
- content = this._createEncoderBuffer(data.map(function(item) {
- var state = this._baseState;
-
- return this._getUse(state.args[0], data)._encode(item, reporter);
- }, child));
- } else if (state.use !== null) {
- result = this._getUse(state.use, parent)._encode(data, reporter);
- } else {
- content = this._encodePrimitive(state.tag, data);
- primitive = true;
- }
- }
-
- // Encode data itself
- var result;
- if (!state.any && state.choice === null) {
- var tag = state.implicit !== null ? state.implicit : state.tag;
- var cls = state.implicit === null ? 'universal' : 'context';
-
- if (tag === null) {
- if (state.use === null)
- reporter.error('Tag could be omitted only for .use()');
- } else {
- if (state.use === null)
- result = this._encodeComposite(tag, primitive, cls, content);
- }
- }
-
- // Wrap in explicit
- if (state.explicit !== null)
- result = this._encodeComposite(state.explicit, false, 'context', result);
-
- return result;
-};
-
-Node.prototype._encodeChoice = function encodeChoice(data, reporter) {
- var state = this._baseState;
-
- var node = state.choice[data.type];
- if (!node) {
- assert(
- false,
- data.type + ' not found in ' +
- JSON.stringify(Object.keys(state.choice)));
- }
- return node._encode(data.value, reporter);
-};
-
-Node.prototype._encodePrimitive = function encodePrimitive(tag, data) {
- var state = this._baseState;
-
- if (/str$/.test(tag))
- return this._encodeStr(data, tag);
- else if (tag === 'objid' && state.args)
- return this._encodeObjid(data, state.reverseArgs[0], state.args[1]);
- else if (tag === 'objid')
- return this._encodeObjid(data, null, null);
- else if (tag === 'gentime' || tag === 'utctime')
- return this._encodeTime(data, tag);
- else if (tag === 'null_')
- return this._encodeNull();
- else if (tag === 'int' || tag === 'enum')
- return this._encodeInt(data, state.args && state.reverseArgs[0]);
- else if (tag === 'bool')
- return this._encodeBool(data);
- else if (tag === 'objDesc')
- return this._encodeStr(data, tag);
- else
- throw new Error('Unsupported tag: ' + tag);
-};
-
-Node.prototype._isNumstr = function isNumstr(str) {
- return /^[0-9 ]*$/.test(str);
-};
-
-Node.prototype._isPrintstr = function isPrintstr(str) {
- return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str);
-};
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/base/reporter.js":
-/*!********************************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/base/reporter.js ***!
- \********************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
-
-function Reporter(options) {
- this._reporterState = {
- obj: null,
- path: [],
- options: options || {},
- errors: []
- };
-}
-exports.Reporter = Reporter;
-
-Reporter.prototype.isError = function isError(obj) {
- return obj instanceof ReporterError;
-};
-
-Reporter.prototype.save = function save() {
- var state = this._reporterState;
-
- return { obj: state.obj, pathLen: state.path.length };
-};
-
-Reporter.prototype.restore = function restore(data) {
- var state = this._reporterState;
-
- state.obj = data.obj;
- state.path = state.path.slice(0, data.pathLen);
-};
-
-Reporter.prototype.enterKey = function enterKey(key) {
- return this._reporterState.path.push(key);
-};
-
-Reporter.prototype.exitKey = function exitKey(index) {
- var state = this._reporterState;
-
- state.path = state.path.slice(0, index - 1);
-};
-
-Reporter.prototype.leaveKey = function leaveKey(index, key, value) {
- var state = this._reporterState;
-
- this.exitKey(index);
- if (state.obj !== null)
- state.obj[key] = value;
-};
-
-Reporter.prototype.path = function path() {
- return this._reporterState.path.join('/');
-};
-
-Reporter.prototype.enterObject = function enterObject() {
- var state = this._reporterState;
-
- var prev = state.obj;
- state.obj = {};
- return prev;
-};
-
-Reporter.prototype.leaveObject = function leaveObject(prev) {
- var state = this._reporterState;
-
- var now = state.obj;
- state.obj = prev;
- return now;
-};
-
-Reporter.prototype.error = function error(msg) {
- var err;
- var state = this._reporterState;
-
- var inherited = msg instanceof ReporterError;
- if (inherited) {
- err = msg;
- } else {
- err = new ReporterError(state.path.map(function(elem) {
- return '[' + JSON.stringify(elem) + ']';
- }).join(''), msg.message || msg, msg.stack);
- }
-
- if (!state.options.partial)
- throw err;
-
- if (!inherited)
- state.errors.push(err);
-
- return err;
-};
-
-Reporter.prototype.wrapResult = function wrapResult(result) {
- var state = this._reporterState;
- if (!state.options.partial)
- return result;
-
- return {
- result: this.isError(result) ? null : result,
- errors: state.errors
- };
-};
-
-function ReporterError(path, msg) {
- this.path = path;
- this.rethrow(msg);
-};
-inherits(ReporterError, Error);
-
-ReporterError.prototype.rethrow = function rethrow(msg) {
- this.message = msg + ' at: ' + (this.path || '(shallow)');
- if (Error.captureStackTrace)
- Error.captureStackTrace(this, ReporterError);
-
- if (!this.stack) {
- try {
- // IE only adds stack when thrown
- throw new Error(this.message);
- } catch (e) {
- this.stack = e.stack;
- }
- }
- return this;
-};
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/constants/der.js":
-/*!********************************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/constants/der.js ***!
- \********************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var constants = __webpack_require__(/*! ../constants */ "./node_modules/asn1.js/lib/asn1/constants/index.js");
-
-exports.tagClass = {
- 0: 'universal',
- 1: 'application',
- 2: 'context',
- 3: 'private'
-};
-exports.tagClassByName = constants._reverse(exports.tagClass);
-
-exports.tag = {
- 0x00: 'end',
- 0x01: 'bool',
- 0x02: 'int',
- 0x03: 'bitstr',
- 0x04: 'octstr',
- 0x05: 'null_',
- 0x06: 'objid',
- 0x07: 'objDesc',
- 0x08: 'external',
- 0x09: 'real',
- 0x0a: 'enum',
- 0x0b: 'embed',
- 0x0c: 'utf8str',
- 0x0d: 'relativeOid',
- 0x10: 'seq',
- 0x11: 'set',
- 0x12: 'numstr',
- 0x13: 'printstr',
- 0x14: 't61str',
- 0x15: 'videostr',
- 0x16: 'ia5str',
- 0x17: 'utctime',
- 0x18: 'gentime',
- 0x19: 'graphstr',
- 0x1a: 'iso646str',
- 0x1b: 'genstr',
- 0x1c: 'unistr',
- 0x1d: 'charstr',
- 0x1e: 'bmpstr'
-};
-exports.tagByName = constants._reverse(exports.tag);
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/constants/index.js":
-/*!**********************************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/constants/index.js ***!
- \**********************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var constants = exports;
-
-// Helper
-constants._reverse = function reverse(map) {
- var res = {};
-
- Object.keys(map).forEach(function(key) {
- // Convert key to integer if it is stringified
- if ((key | 0) == key)
- key = key | 0;
-
- var value = map[key];
- res[value] = key;
- });
-
- return res;
-};
-
-constants.der = __webpack_require__(/*! ./der */ "./node_modules/asn1.js/lib/asn1/constants/der.js");
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/decoders/der.js":
-/*!*******************************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/decoders/der.js ***!
- \*******************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
-
-var asn1 = __webpack_require__(/*! ../../asn1 */ "./node_modules/asn1.js/lib/asn1.js");
-var base = asn1.base;
-var bignum = asn1.bignum;
-
-// Import DER constants
-var der = asn1.constants.der;
-
-function DERDecoder(entity) {
- this.enc = 'der';
- this.name = entity.name;
- this.entity = entity;
-
- // Construct base tree
- this.tree = new DERNode();
- this.tree._init(entity.body);
-};
-module.exports = DERDecoder;
-
-DERDecoder.prototype.decode = function decode(data, options) {
- if (!(data instanceof base.DecoderBuffer))
- data = new base.DecoderBuffer(data, options);
-
- return this.tree._decode(data, options);
-};
-
-// Tree methods
-
-function DERNode(parent) {
- base.Node.call(this, 'der', parent);
-}
-inherits(DERNode, base.Node);
-
-DERNode.prototype._peekTag = function peekTag(buffer, tag, any) {
- if (buffer.isEmpty())
- return false;
-
- var state = buffer.save();
- var decodedTag = derDecodeTag(buffer, 'Failed to peek tag: "' + tag + '"');
- if (buffer.isError(decodedTag))
- return decodedTag;
-
- buffer.restore(state);
-
- return decodedTag.tag === tag || decodedTag.tagStr === tag ||
- (decodedTag.tagStr + 'of') === tag || any;
-};
-
-DERNode.prototype._decodeTag = function decodeTag(buffer, tag, any) {
- var decodedTag = derDecodeTag(buffer,
- 'Failed to decode tag of "' + tag + '"');
- if (buffer.isError(decodedTag))
- return decodedTag;
-
- var len = derDecodeLen(buffer,
- decodedTag.primitive,
- 'Failed to get length of "' + tag + '"');
-
- // Failure
- if (buffer.isError(len))
- return len;
-
- if (!any &&
- decodedTag.tag !== tag &&
- decodedTag.tagStr !== tag &&
- decodedTag.tagStr + 'of' !== tag) {
- return buffer.error('Failed to match tag: "' + tag + '"');
- }
-
- if (decodedTag.primitive || len !== null)
- return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
-
- // Indefinite length... find END tag
- var state = buffer.save();
- var res = this._skipUntilEnd(
- buffer,
- 'Failed to skip indefinite length body: "' + this.tag + '"');
- if (buffer.isError(res))
- return res;
-
- len = buffer.offset - state.offset;
- buffer.restore(state);
- return buffer.skip(len, 'Failed to match body of: "' + tag + '"');
-};
-
-DERNode.prototype._skipUntilEnd = function skipUntilEnd(buffer, fail) {
- while (true) {
- var tag = derDecodeTag(buffer, fail);
- if (buffer.isError(tag))
- return tag;
- var len = derDecodeLen(buffer, tag.primitive, fail);
- if (buffer.isError(len))
- return len;
-
- var res;
- if (tag.primitive || len !== null)
- res = buffer.skip(len)
- else
- res = this._skipUntilEnd(buffer, fail);
-
- // Failure
- if (buffer.isError(res))
- return res;
-
- if (tag.tagStr === 'end')
- break;
- }
-};
-
-DERNode.prototype._decodeList = function decodeList(buffer, tag, decoder,
- options) {
- var result = [];
- while (!buffer.isEmpty()) {
- var possibleEnd = this._peekTag(buffer, 'end');
- if (buffer.isError(possibleEnd))
- return possibleEnd;
-
- var res = decoder.decode(buffer, 'der', options);
- if (buffer.isError(res) && possibleEnd)
- break;
- result.push(res);
- }
- return result;
-};
-
-DERNode.prototype._decodeStr = function decodeStr(buffer, tag) {
- if (tag === 'bitstr') {
- var unused = buffer.readUInt8();
- if (buffer.isError(unused))
- return unused;
- return { unused: unused, data: buffer.raw() };
- } else if (tag === 'bmpstr') {
- var raw = buffer.raw();
- if (raw.length % 2 === 1)
- return buffer.error('Decoding of string type: bmpstr length mismatch');
-
- var str = '';
- for (var i = 0; i < raw.length / 2; i++) {
- str += String.fromCharCode(raw.readUInt16BE(i * 2));
- }
- return str;
- } else if (tag === 'numstr') {
- var numstr = buffer.raw().toString('ascii');
- if (!this._isNumstr(numstr)) {
- return buffer.error('Decoding of string type: ' +
- 'numstr unsupported characters');
- }
- return numstr;
- } else if (tag === 'octstr') {
- return buffer.raw();
- } else if (tag === 'objDesc') {
- return buffer.raw();
- } else if (tag === 'printstr') {
- var printstr = buffer.raw().toString('ascii');
- if (!this._isPrintstr(printstr)) {
- return buffer.error('Decoding of string type: ' +
- 'printstr unsupported characters');
- }
- return printstr;
- } else if (/str$/.test(tag)) {
- return buffer.raw().toString();
- } else {
- return buffer.error('Decoding of string type: ' + tag + ' unsupported');
- }
-};
-
-DERNode.prototype._decodeObjid = function decodeObjid(buffer, values, relative) {
- var result;
- var identifiers = [];
- var ident = 0;
- while (!buffer.isEmpty()) {
- var subident = buffer.readUInt8();
- ident <<= 7;
- ident |= subident & 0x7f;
- if ((subident & 0x80) === 0) {
- identifiers.push(ident);
- ident = 0;
- }
- }
- if (subident & 0x80)
- identifiers.push(ident);
-
- var first = (identifiers[0] / 40) | 0;
- var second = identifiers[0] % 40;
-
- if (relative)
- result = identifiers;
- else
- result = [first, second].concat(identifiers.slice(1));
-
- if (values) {
- var tmp = values[result.join(' ')];
- if (tmp === undefined)
- tmp = values[result.join('.')];
- if (tmp !== undefined)
- result = tmp;
- }
-
- return result;
-};
-
-DERNode.prototype._decodeTime = function decodeTime(buffer, tag) {
- var str = buffer.raw().toString();
- if (tag === 'gentime') {
- var year = str.slice(0, 4) | 0;
- var mon = str.slice(4, 6) | 0;
- var day = str.slice(6, 8) | 0;
- var hour = str.slice(8, 10) | 0;
- var min = str.slice(10, 12) | 0;
- var sec = str.slice(12, 14) | 0;
- } else if (tag === 'utctime') {
- var year = str.slice(0, 2) | 0;
- var mon = str.slice(2, 4) | 0;
- var day = str.slice(4, 6) | 0;
- var hour = str.slice(6, 8) | 0;
- var min = str.slice(8, 10) | 0;
- var sec = str.slice(10, 12) | 0;
- if (year < 70)
- year = 2000 + year;
- else
- year = 1900 + year;
- } else {
- return buffer.error('Decoding ' + tag + ' time is not supported yet');
- }
-
- return Date.UTC(year, mon - 1, day, hour, min, sec, 0);
-};
-
-DERNode.prototype._decodeNull = function decodeNull(buffer) {
- return null;
-};
-
-DERNode.prototype._decodeBool = function decodeBool(buffer) {
- var res = buffer.readUInt8();
- if (buffer.isError(res))
- return res;
- else
- return res !== 0;
-};
-
-DERNode.prototype._decodeInt = function decodeInt(buffer, values) {
- // Bigint, return as it is (assume big endian)
- var raw = buffer.raw();
- var res = new bignum(raw);
-
- if (values)
- res = values[res.toString(10)] || res;
-
- return res;
-};
-
-DERNode.prototype._use = function use(entity, obj) {
- if (typeof entity === 'function')
- entity = entity(obj);
- return entity._getDecoder('der').tree;
-};
-
-// Utility methods
-
-function derDecodeTag(buf, fail) {
- var tag = buf.readUInt8(fail);
- if (buf.isError(tag))
- return tag;
-
- var cls = der.tagClass[tag >> 6];
- var primitive = (tag & 0x20) === 0;
-
- // Multi-octet tag - load
- if ((tag & 0x1f) === 0x1f) {
- var oct = tag;
- tag = 0;
- while ((oct & 0x80) === 0x80) {
- oct = buf.readUInt8(fail);
- if (buf.isError(oct))
- return oct;
-
- tag <<= 7;
- tag |= oct & 0x7f;
- }
- } else {
- tag &= 0x1f;
- }
- var tagStr = der.tag[tag];
-
- return {
- cls: cls,
- primitive: primitive,
- tag: tag,
- tagStr: tagStr
- };
-}
-
-function derDecodeLen(buf, primitive, fail) {
- var len = buf.readUInt8(fail);
- if (buf.isError(len))
- return len;
-
- // Indefinite form
- if (!primitive && len === 0x80)
- return null;
-
- // Definite form
- if ((len & 0x80) === 0) {
- // Short form
- return len;
- }
-
- // Long form
- var num = len & 0x7f;
- if (num > 4)
- return buf.error('length octect is too long');
-
- len = 0;
- for (var i = 0; i < num; i++) {
- len <<= 8;
- var j = buf.readUInt8(fail);
- if (buf.isError(j))
- return j;
- len |= j;
- }
-
- return len;
-}
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/decoders/index.js":
-/*!*********************************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/decoders/index.js ***!
- \*********************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var decoders = exports;
-
-decoders.der = __webpack_require__(/*! ./der */ "./node_modules/asn1.js/lib/asn1/decoders/der.js");
-decoders.pem = __webpack_require__(/*! ./pem */ "./node_modules/asn1.js/lib/asn1/decoders/pem.js");
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/decoders/pem.js":
-/*!*******************************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/decoders/pem.js ***!
- \*******************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
-var Buffer = __webpack_require__(/*! buffer */ "./node_modules/browserfs/dist/shims/buffer.js").Buffer;
-
-var DERDecoder = __webpack_require__(/*! ./der */ "./node_modules/asn1.js/lib/asn1/decoders/der.js");
-
-function PEMDecoder(entity) {
- DERDecoder.call(this, entity);
- this.enc = 'pem';
-};
-inherits(PEMDecoder, DERDecoder);
-module.exports = PEMDecoder;
-
-PEMDecoder.prototype.decode = function decode(data, options) {
- var lines = data.toString().split(/[\r\n]+/g);
-
- var label = options.label.toUpperCase();
-
- var re = /^-----(BEGIN|END) ([^-]+)-----$/;
- var start = -1;
- var end = -1;
- for (var i = 0; i < lines.length; i++) {
- var match = lines[i].match(re);
- if (match === null)
- continue;
-
- if (match[2] !== label)
- continue;
-
- if (start === -1) {
- if (match[1] !== 'BEGIN')
- break;
- start = i;
- } else {
- if (match[1] !== 'END')
- break;
- end = i;
- break;
- }
- }
- if (start === -1 || end === -1)
- throw new Error('PEM section not found for: ' + label);
-
- var base64 = lines.slice(start + 1, end).join('');
- // Remove excessive symbols
- base64.replace(/[^a-z0-9\+\/=]+/gi, '');
-
- var input = new Buffer(base64, 'base64');
- return DERDecoder.prototype.decode.call(this, input, options);
-};
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/encoders/der.js":
-/*!*******************************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/encoders/der.js ***!
- \*******************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
-var Buffer = __webpack_require__(/*! buffer */ "./node_modules/browserfs/dist/shims/buffer.js").Buffer;
-
-var asn1 = __webpack_require__(/*! ../../asn1 */ "./node_modules/asn1.js/lib/asn1.js");
-var base = asn1.base;
-
-// Import DER constants
-var der = asn1.constants.der;
-
-function DEREncoder(entity) {
- this.enc = 'der';
- this.name = entity.name;
- this.entity = entity;
-
- // Construct base tree
- this.tree = new DERNode();
- this.tree._init(entity.body);
-};
-module.exports = DEREncoder;
-
-DEREncoder.prototype.encode = function encode(data, reporter) {
- return this.tree._encode(data, reporter).join();
-};
-
-// Tree methods
-
-function DERNode(parent) {
- base.Node.call(this, 'der', parent);
-}
-inherits(DERNode, base.Node);
-
-DERNode.prototype._encodeComposite = function encodeComposite(tag,
- primitive,
- cls,
- content) {
- var encodedTag = encodeTag(tag, primitive, cls, this.reporter);
-
- // Short form
- if (content.length < 0x80) {
- var header = new Buffer(2);
- header[0] = encodedTag;
- header[1] = content.length;
- return this._createEncoderBuffer([ header, content ]);
- }
-
- // Long form
- // Count octets required to store length
- var lenOctets = 1;
- for (var i = content.length; i >= 0x100; i >>= 8)
- lenOctets++;
-
- var header = new Buffer(1 + 1 + lenOctets);
- header[0] = encodedTag;
- header[1] = 0x80 | lenOctets;
-
- for (var i = 1 + lenOctets, j = content.length; j > 0; i--, j >>= 8)
- header[i] = j & 0xff;
-
- return this._createEncoderBuffer([ header, content ]);
-};
-
-DERNode.prototype._encodeStr = function encodeStr(str, tag) {
- if (tag === 'bitstr') {
- return this._createEncoderBuffer([ str.unused | 0, str.data ]);
- } else if (tag === 'bmpstr') {
- var buf = new Buffer(str.length * 2);
- for (var i = 0; i < str.length; i++) {
- buf.writeUInt16BE(str.charCodeAt(i), i * 2);
- }
- return this._createEncoderBuffer(buf);
- } else if (tag === 'numstr') {
- if (!this._isNumstr(str)) {
- return this.reporter.error('Encoding of string type: numstr supports ' +
- 'only digits and space');
- }
- return this._createEncoderBuffer(str);
- } else if (tag === 'printstr') {
- if (!this._isPrintstr(str)) {
- return this.reporter.error('Encoding of string type: printstr supports ' +
- 'only latin upper and lower case letters, ' +
- 'digits, space, apostrophe, left and rigth ' +
- 'parenthesis, plus sign, comma, hyphen, ' +
- 'dot, slash, colon, equal sign, ' +
- 'question mark');
- }
- return this._createEncoderBuffer(str);
- } else if (/str$/.test(tag)) {
- return this._createEncoderBuffer(str);
- } else if (tag === 'objDesc') {
- return this._createEncoderBuffer(str);
- } else {
- return this.reporter.error('Encoding of string type: ' + tag +
- ' unsupported');
- }
-};
-
-DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
- if (typeof id === 'string') {
- if (!values)
- return this.reporter.error('string objid given, but no values map found');
- if (!values.hasOwnProperty(id))
- return this.reporter.error('objid not found in values map');
- id = values[id].split(/[\s\.]+/g);
- for (var i = 0; i < id.length; i++)
- id[i] |= 0;
- } else if (Array.isArray(id)) {
- id = id.slice();
- for (var i = 0; i < id.length; i++)
- id[i] |= 0;
- }
-
- if (!Array.isArray(id)) {
- return this.reporter.error('objid() should be either array or string, ' +
- 'got: ' + JSON.stringify(id));
- }
-
- if (!relative) {
- if (id[1] >= 40)
- return this.reporter.error('Second objid identifier OOB');
- id.splice(0, 2, id[0] * 40 + id[1]);
- }
-
- // Count number of octets
- var size = 0;
- for (var i = 0; i < id.length; i++) {
- var ident = id[i];
- for (size++; ident >= 0x80; ident >>= 7)
- size++;
- }
-
- var objid = new Buffer(size);
- var offset = objid.length - 1;
- for (var i = id.length - 1; i >= 0; i--) {
- var ident = id[i];
- objid[offset--] = ident & 0x7f;
- while ((ident >>= 7) > 0)
- objid[offset--] = 0x80 | (ident & 0x7f);
- }
-
- return this._createEncoderBuffer(objid);
-};
-
-function two(num) {
- if (num < 10)
- return '0' + num;
- else
- return num;
-}
-
-DERNode.prototype._encodeTime = function encodeTime(time, tag) {
- var str;
- var date = new Date(time);
-
- if (tag === 'gentime') {
- str = [
- two(date.getFullYear()),
- two(date.getUTCMonth() + 1),
- two(date.getUTCDate()),
- two(date.getUTCHours()),
- two(date.getUTCMinutes()),
- two(date.getUTCSeconds()),
- 'Z'
- ].join('');
- } else if (tag === 'utctime') {
- str = [
- two(date.getFullYear() % 100),
- two(date.getUTCMonth() + 1),
- two(date.getUTCDate()),
- two(date.getUTCHours()),
- two(date.getUTCMinutes()),
- two(date.getUTCSeconds()),
- 'Z'
- ].join('');
- } else {
- this.reporter.error('Encoding ' + tag + ' time is not supported yet');
- }
-
- return this._encodeStr(str, 'octstr');
-};
-
-DERNode.prototype._encodeNull = function encodeNull() {
- return this._createEncoderBuffer('');
-};
-
-DERNode.prototype._encodeInt = function encodeInt(num, values) {
- if (typeof num === 'string') {
- if (!values)
- return this.reporter.error('String int or enum given, but no values map');
- if (!values.hasOwnProperty(num)) {
- return this.reporter.error('Values map doesn\'t contain: ' +
- JSON.stringify(num));
- }
- num = values[num];
- }
-
- // Bignum, assume big endian
- if (typeof num !== 'number' && !Buffer.isBuffer(num)) {
- var numArray = num.toArray();
- if (!num.sign && numArray[0] & 0x80) {
- numArray.unshift(0);
- }
- num = new Buffer(numArray);
- }
-
- if (Buffer.isBuffer(num)) {
- var size = num.length;
- if (num.length === 0)
- size++;
-
- var out = new Buffer(size);
- num.copy(out);
- if (num.length === 0)
- out[0] = 0
- return this._createEncoderBuffer(out);
- }
-
- if (num < 0x80)
- return this._createEncoderBuffer(num);
-
- if (num < 0x100)
- return this._createEncoderBuffer([0, num]);
-
- var size = 1;
- for (var i = num; i >= 0x100; i >>= 8)
- size++;
-
- var out = new Array(size);
- for (var i = out.length - 1; i >= 0; i--) {
- out[i] = num & 0xff;
- num >>= 8;
- }
- if(out[0] & 0x80) {
- out.unshift(0);
- }
-
- return this._createEncoderBuffer(new Buffer(out));
-};
-
-DERNode.prototype._encodeBool = function encodeBool(value) {
- return this._createEncoderBuffer(value ? 0xff : 0);
-};
-
-DERNode.prototype._use = function use(entity, obj) {
- if (typeof entity === 'function')
- entity = entity(obj);
- return entity._getEncoder('der').tree;
-};
-
-DERNode.prototype._skipDefault = function skipDefault(dataBuffer, reporter, parent) {
- var state = this._baseState;
- var i;
- if (state['default'] === null)
- return false;
-
- var data = dataBuffer.join();
- if (state.defaultBuffer === undefined)
- state.defaultBuffer = this._encodeValue(state['default'], reporter, parent).join();
-
- if (data.length !== state.defaultBuffer.length)
- return false;
-
- for (i=0; i < data.length; i++)
- if (data[i] !== state.defaultBuffer[i])
- return false;
-
- return true;
-};
-
-// Utility methods
-
-function encodeTag(tag, primitive, cls, reporter) {
- var res;
-
- if (tag === 'seqof')
- tag = 'seq';
- else if (tag === 'setof')
- tag = 'set';
-
- if (der.tagByName.hasOwnProperty(tag))
- res = der.tagByName[tag];
- else if (typeof tag === 'number' && (tag | 0) === tag)
- res = tag;
- else
- return reporter.error('Unknown tag: ' + tag);
-
- if (res >= 0x1f)
- return reporter.error('Multi-octet tag encoding unsupported');
-
- if (!primitive)
- res |= 0x20;
-
- res |= (der.tagClassByName[cls || 'universal'] << 6);
-
- return res;
-}
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/encoders/index.js":
-/*!*********************************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/encoders/index.js ***!
- \*********************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var encoders = exports;
-
-encoders.der = __webpack_require__(/*! ./der */ "./node_modules/asn1.js/lib/asn1/encoders/der.js");
-encoders.pem = __webpack_require__(/*! ./pem */ "./node_modules/asn1.js/lib/asn1/encoders/pem.js");
-
-
-/***/ }),
-
-/***/ "./node_modules/asn1.js/lib/asn1/encoders/pem.js":
-/*!*******************************************************!*\
- !*** ./node_modules/asn1.js/lib/asn1/encoders/pem.js ***!
- \*******************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-var inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js");
-
-var DEREncoder = __webpack_require__(/*! ./der */ "./node_modules/asn1.js/lib/asn1/encoders/der.js");
-
-function PEMEncoder(entity) {
- DEREncoder.call(this, entity);
- this.enc = 'pem';
-};
-inherits(PEMEncoder, DEREncoder);
-module.exports = PEMEncoder;
-
-PEMEncoder.prototype.encode = function encode(data, options) {
- var buf = DEREncoder.prototype.encode.call(this, data);
-
- var p = buf.toString('base64');
- var out = [ '-----BEGIN ' + options.label + '-----' ];
- for (var i = 0; i < p.length; i += 64)
- out.push(p.slice(i, i + 64));
- out.push('-----END ' + options.label + '-----');
- return out.join('\n');
-};
-
-
-/***/ }),
-
-/***/ "./node_modules/assemblyscript/dist/asc.js":
-/*!*************************************************!*\
- !*** ./node_modules/assemblyscript/dist/asc.js ***!
- \*************************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
-!function(e,n){ true?module.exports=n(function(){try{return __webpack_require__(/*! assemblyscript */ "./node_modules/assemblyscript/index.js")}catch(e){}}()):undefined}("undefined"!=typeof self?self:this,function(__WEBPACK_EXTERNAL_MODULE__10__){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(r,i,function(n){return e[n]}.bind(null,i));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=4)}([function(e,n,t){var r,i;n.nextTick=function(e){setTimeout(e,0)},n.platform=n.arch=n.execPath=n.title="browser",n.pid=1,n.browser=!0,n.env={},n.argv=[],n.binding=function(e){throw new Error("No such module. (Possibly not yet loaded)")},i="/",n.cwd=function(){return i},n.chdir=function(e){r||(r=t(1)),i=r.resolve(e,i)},n.exit=n.kill=n.umask=n.dlopen=n.uptime=n.memoryUsage=n.uvCounters=function(){},n.features={}},function(e,n,t){(function(e){function t(e,n){for(var t=0,r=e.length-1;r>=0;r--){var i=e[r];"."===i?e.splice(r,1):".."===i?(e.splice(r,1),t++):t&&(e.splice(r,1),t--)}if(n)for(;t--;t)e.unshift("..");return e}var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(e){return r.exec(e).slice(1)};function a(e,n){if(e.filter)return e.filter(n);for(var t=[],r=0;r=-1&&!r;i--){var s=i>=0?arguments[i]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,r="/"===s.charAt(0))}return(r?"/":"")+(n=t(a(n.split("/"),function(e){return!!e}),!r).join("/"))||"."},n.normalize=function(e){var r=n.isAbsolute(e),i="/"===s(e,-1);return(e=t(a(e.split("/"),function(e){return!!e}),!r).join("/"))||r||(e="."),e&&i&&(e+="/"),(r?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(a(e,function(e,n){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},n.relative=function(e,t){function r(e){for(var n=0;n=0&&""===e[t];t--);return n>t?[]:e.slice(n,t-n+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var i=r(e.split("/")),a=r(t.split("/")),s=Math.min(i.length,a.length),o=s,l=0;l{try{assemblyscript=__webpack_require__(10)}catch(e){try{__webpack_require__(!function(){var e=new Error("Cannot find module 'ts-node'");throw e.code="MODULE_NOT_FOUND",e}()).register({project:path.join(".","..","src","tsconfig.json")}),__webpack_require__(!function(){var e=new Error("Cannot find module '../src/glue/js'");throw e.code="MODULE_NOT_FOUND",e}()),assemblyscript=__webpack_require__(!function(){var e=new Error("Cannot find module '../src'");throw e.code="MODULE_NOT_FOUND",e}()),isDev=!0}catch(e_ts){try{assemblyscript=eval("require('./assemblyscript')")}catch(e){throw e.stack=e_ts.stack+"\n---\n"+e.stack,e}}}})(),exports.isBundle=!0,exports.isDev=isDev,exports.version=exports.isBundle?"0.5.0":__webpack_require__(!function(){var e=new Error("Cannot find module '../package.json'");throw e.code="MODULE_NOT_FOUND",e}()).version,exports.options=__webpack_require__(11),exports.sourceMapRoot="assemblyscript:///",exports.libraryPrefix=assemblyscript.LIBRARY_PREFIX,exports.defaultOptimizeLevel=2,exports.defaultShrinkLevel=1,exports.libraryFiles=exports.isBundle?Object({"allocator/arena":'/**\n * Arena Memory Allocator\n *\n * Provides a `memory.reset` function to reset the heap to its initial state. A user has to make\n * sure that there are no more references to cleared memory afterwards. Always aligns to 8 bytes.\n *\n * @module std/assembly/allocator/arena\n *//***/\n\nimport { AL_MASK, MAX_SIZE_32 } from "../internal/allocator";\n\nvar startOffset: usize = (HEAP_BASE + AL_MASK) & ~AL_MASK;\nvar offset: usize = startOffset;\n\n// Memory allocator interface\n\n@global export function __memory_allocate(size: usize): usize {\n if (size > MAX_SIZE_32) unreachable();\n var ptr = offset;\n var newPtr = (ptr + max(size, 1) + AL_MASK) & ~AL_MASK;\n var pagesBefore = memory.size();\n if (newPtr > pagesBefore << 16) {\n let pagesNeeded = ((newPtr - ptr + 0xffff) & ~0xffff) >>> 16;\n let pagesWanted = max(pagesBefore, pagesNeeded); // double memory\n if (memory.grow(pagesWanted) < 0) {\n if (memory.grow(pagesNeeded) < 0) {\n unreachable(); // out of memory\n }\n }\n }\n offset = newPtr;\n return ptr;\n}\n\n@global export function __memory_free(ptr: usize): void { /* nop */ }\n\n@global export function __memory_reset(): void {\n offset = startOffset;\n}\n',"allocator/buddy":'/**\n * Buddy Memory Allocator.\n * @module std/assembly/allocator/buddy\n *//***/\n\n/*\n Copyright 2018 Evan Wallace\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the "Software"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n*/// see: https://github.com/evanw/buddy-malloc\n\n/*\n * This file implements a buddy memory allocator, which is an allocator that\n * allocates memory within a fixed linear address range. It spans the address\n * range with a binary tree that tracks free space. Both "malloc" and "free"\n * are O(log N) time where N is the maximum possible number of allocations.\n *\n * The "buddy" term comes from how the tree is used. When memory is allocated,\n * nodes in the tree are split recursively until a node of the appropriate size\n * is reached. Every split results in two child nodes, each of which is the\n * buddy of the other. When a node is freed, the node and its buddy can be\n * merged again if the buddy is also free. This makes the memory available\n * for larger allocations again.\n */\n\n/*\n * Every allocation needs an 8-byte header to store the allocation size while\n * staying 8-byte aligned. The address returned by "malloc" is the address\n * right after this header (i.e. the size occupies the 8 bytes before the\n * returned address).\n */\nconst HEADER_SIZE: usize = 8;\n\n/*\n * The minimum allocation size is 16 bytes because we have an 8-byte header and\n * we need to stay 8-byte aligned.\n */\nconst MIN_ALLOC_LOG2: usize = 4;\nconst MIN_ALLOC: usize = 1 << MIN_ALLOC_LOG2;\n\n/*\n * The maximum allocation size is currently set to 2gb. This is the total size\n * of the heap. It\'s technically also the maximum allocation size because the\n * heap could consist of a single allocation of this size. But of course real\n * heaps will have multiple allocations, so the real maximum allocation limit\n * is at most 1gb.\n */\nconst MAX_ALLOC_LOG2: usize = 30; // 31;\nconst MAX_ALLOC: usize = 1 << MAX_ALLOC_LOG2;\n\n/*\n * Allocations are done in powers of two starting from MIN_ALLOC and ending at\n * MAX_ALLOC inclusive. Each allocation size has a bucket that stores the free\n * list for that allocation size.\n *\n * Given a bucket index, the size of the allocations in that bucket can be\n * found with "(size_t)1 << (MAX_ALLOC_LOG2 - bucket)".\n */\nconst BUCKET_COUNT: usize = MAX_ALLOC_LOG2 - MIN_ALLOC_LOG2 + 1;\n\n/*\n * Free lists are stored as circular doubly-linked lists. Every possible\n * allocation size has an associated free list that is threaded through all\n * currently free blocks of that size. That means MIN_ALLOC must be at least\n * "sizeof(list_t)". MIN_ALLOC is currently 16 bytes, so this will be true for\n * both 32-bit and 64-bit.\n */\n@unmanaged\nclass List {\n prev: List;\n next: List;\n static readonly SIZE: usize = 2 * sizeof();\n}\n\n/*\n * Each bucket corresponds to a certain allocation size and stores a free list\n * for that size. The bucket at index 0 corresponds to an allocation size of\n * MAX_ALLOC (i.e. the whole address space).\n */\nvar BUCKETS_START: usize = HEAP_BASE;\nvar BUCKETS_END: usize = BUCKETS_START + BUCKET_COUNT * List.SIZE;\n\nfunction buckets$get(index: usize): List {\n assert(index < BUCKET_COUNT);\n return changetype(BUCKETS_START + index * List.SIZE);\n}\n\n/*\n * We could initialize the allocator by giving it one free block the size of\n * the entire address space. However, this would cause us to instantly reserve\n * half of the entire address space on the first allocation, since the first\n * split would store a free list entry at the start of the right child of the\n * root. Instead, we have the tree start out small and grow the size of the\n * tree as we use more memory. The size of the tree is tracked by this value.\n */\nvar bucket_limit: usize;\n\n/*\n * This array represents a linearized binary tree of bits. Every possible\n * allocation larger than MIN_ALLOC has a node in this tree (and therefore a\n * bit in this array).\n *\n * Given the index for a node, lineraized binary trees allow you to traverse to\n * the parent node or the child nodes just by doing simple arithmetic on the\n * index:\n *\n * - Move to parent: index = (index - 1) / 2;\n * - Move to left child: index = index * 2 + 1;\n * - Move to right child: index = index * 2 + 2;\n * - Move to sibling: index = ((index - 1) ^ 1) + 1;\n *\n * Each node in this tree can be in one of several states:\n *\n * - UNUSED (both children are UNUSED)\n * - SPLIT (one child is UNUSED and the other child isn\'t)\n * - USED (neither children are UNUSED)\n *\n * These states take two bits to store. However, it turns out we have enough\n * information to distinguish between UNUSED and USED from context, so we only\n * need to store SPLIT or not, which only takes a single bit.\n *\n * Note that we don\'t need to store any nodes for allocations of size MIN_ALLOC\n * since we only ever care about parent nodes.\n */\nconst SPLIT_COUNT: usize = (1 << (BUCKET_COUNT - 1)) / 8;\nvar NODE_IS_SPLIT_START: usize = BUCKETS_END;\nvar NODE_IS_SPLIT_END: usize = NODE_IS_SPLIT_START + SPLIT_COUNT * sizeof();\n\nfunction node_is_split$get(index: usize): i32 {\n assert(index < SPLIT_COUNT);\n return load(NODE_IS_SPLIT_START + index);\n}\n\nfunction node_is_split$set(index: usize, state: i32): void {\n assert(index < SPLIT_COUNT);\n store(NODE_IS_SPLIT_START + index, state);\n}\n\n/*\n * This is the starting address of the address range for this allocator. Every\n * returned allocation will be an offset of this pointer from 0 to MAX_ALLOC.\n */\nvar base_ptr: usize;\n\n/*\n * This is the maximum address that has ever been used by the allocator. It\'s\n * used to know when to call "brk" to request more memory from the kernel.\n */\nvar max_ptr: usize;\n\n/*\n * Make sure all addresses before "new_value" are valid and can be used. Memory\n * is allocated in a 2gb address range but that memory is not reserved up\n * front. It\'s only reserved when it\'s needed by calling this function. This\n * will return false if the memory could not be reserved.\n */\nfunction update_max_ptr(new_value: usize): i32 {\n if (new_value > max_ptr) {\n // if (brk(new_value)) {\n // return 0;\n // }\n let oldPages = memory.size();\n let newPages = (((new_value + 0xffff) & ~0xffff) >>> 16);\n assert(newPages > oldPages);\n if (memory.grow(newPages - oldPages) < 0) {\n return 0;\n }\n // max_ptr = new_value;\n max_ptr = newPages << 16;\n }\n return 1;\n}\n\n/*\n * Initialize a list to empty. Because these are circular lists, an "empty"\n * list is an entry where both links point to itself. This makes insertion\n * and removal simpler because they don\'t need any branches.\n */\nfunction list_init(list: List): void {\n list.prev = list;\n list.next = list;\n}\n\n/*\n * Append the provided entry to the end of the list. This assumes the entry\n * isn\'t in a list already because it overwrites the linked list pointers.\n */\nfunction list_push(list: List, entry: List): void {\n var prev = list.prev;\n entry.prev = prev;\n entry.next = list;\n prev.next = entry;\n list.prev = entry;\n}\n\n/*\n * Remove the provided entry from whichever list it\'s currently in. This\n * assumes that the entry is in a list. You don\'t need to provide the list\n * because the lists are circular, so the list\'s pointers will automatically\n * be updated if the first or last entries are removed.\n */\nfunction list_remove(entry: List): void {\n var prev = entry.prev;\n var next = entry.next;\n prev.next = next;\n next.prev = prev;\n}\n\n/*\n * Remove and return the first entry in the list or NULL if the list is empty.\n */\nfunction list_pop(list: List): List | null {\n var back = list.prev;\n if (back == list) return null;\n list_remove(back);\n return back;\n}\n\n/*\n * This maps from the index of a node to the address of memory that node\n * represents. The bucket can be derived from the index using a loop but is\n * required to be provided here since having them means we can avoid the loop\n * and have this function return in constant time.\n */\nfunction ptr_for_node(index: usize, bucket: usize): usize {\n return base_ptr + ((index - (1 << bucket) + 1) << (MAX_ALLOC_LOG2 - bucket));\n}\n\n/*\n * This maps from an address of memory to the node that represents that\n * address. There are often many nodes that all map to the same address, so\n * the bucket is needed to uniquely identify a node.\n */\nfunction node_for_ptr(ptr: usize, bucket: usize): usize {\n return ((ptr - base_ptr) >> (MAX_ALLOC_LOG2 - bucket)) + (1 << bucket) - 1;\n}\n\n/*\n * Given the index of a node, this returns the "is split" flag of the parent.\n */\nfunction parent_is_split(index: usize): bool {\n index = (index - 1) / 2;\n return ((node_is_split$get(index / 8) >>> (index % 8)) & 1) == 1;\n}\n\n/*\n * Given the index of a node, this flips the "is split" flag of the parent.\n */\nfunction flip_parent_is_split(index: usize): void {\n index = (index - 1) / 2;\n var indexDiv8 = index / 8;\n node_is_split$set(indexDiv8,\n node_is_split$get(indexDiv8) ^ (1 << (index % 8))\n );\n}\n\n/*\n * Given the requested size passed to "malloc", this function returns the index\n * of the smallest bucket that can fit that size.\n */\nfunction bucket_for_request(request: usize): usize {\n var bucket = BUCKET_COUNT - 1;\n var size = MIN_ALLOC;\n\n while (size < request) {\n bucket--;\n size *= 2;\n }\n\n return bucket;\n}\n\n/*\n * The tree is always rooted at the current bucket limit. This call grows the\n * tree by repeatedly doubling it in size until the root lies at the provided\n * bucket index. Each doubling lowers the bucket limit by 1.\n */\nfunction lower_bucket_limit(bucket: usize): u32 {\n while (bucket < bucket_limit) {\n let root = node_for_ptr(base_ptr, bucket_limit);\n let right_child: usize;\n\n /*\n * If the parent isn\'t SPLIT, that means the node at the current bucket\n * limit is UNUSED and our address space is entirely free. In that case,\n * clear the root free list, increase the bucket limit, and add a single\n * block with the newly-expanded address space to the new root free list.\n */\n if (!parent_is_split(root)) {\n list_remove(changetype(base_ptr));\n list_init(buckets$get(--bucket_limit));\n list_push(buckets$get(bucket_limit), changetype(base_ptr));\n continue;\n }\n\n /*\n * Otherwise, the tree is currently in use. Create a parent node for the\n * current root node in the SPLIT state with a right child on the free\n * list. Make sure to reserve the memory for the free list entry before\n * writing to it. Note that we do not need to flip the "is split" flag for\n * our current parent because it\'s already on (we know because we just\n * checked it above).\n */\n right_child = ptr_for_node(root + 1, bucket_limit);\n if (!update_max_ptr(right_child + List.SIZE)) {\n return 0;\n }\n list_push(buckets$get(bucket_limit), changetype(right_child));\n list_init(buckets$get(--bucket_limit));\n\n /*\n * Set the grandparent\'s SPLIT flag so if we need to lower the bucket limit\n * again, we\'ll know that the new root node we just added is in use.\n */\n root = (root - 1) / 2;\n if (root != 0) {\n flip_parent_is_split(root);\n }\n }\n\n return 1;\n}\n\n// Memory allocator interface\n\n@global export function __memory_allocate(request: usize): usize {\n var original_bucket: usize, bucket: usize;\n\n /*\n * Make sure it\'s possible for an allocation of this size to succeed. There\'s\n * a hard-coded limit on the maximum allocation size because of the way this\n * allocator works.\n */\n if (request > MAX_ALLOC - HEADER_SIZE) unreachable();\n\n /*\n * Initialize our global state if this is the first call to "malloc". At the\n * beginning, the tree has a single node that represents the smallest\n * possible allocation size. More memory will be reserved later as needed.\n */\n if (base_ptr == 0) {\n // base_ptr = max_ptr = (uint8_t *)sbrk(0);\n base_ptr = (NODE_IS_SPLIT_END + 7) & ~7; // must be aligned\n max_ptr = memory.size() << 16; // must grow first\n bucket_limit = BUCKET_COUNT - 1;\n if (!update_max_ptr(base_ptr + List.SIZE)) {\n return 0;\n }\n list_init(buckets$get(BUCKET_COUNT - 1));\n list_push(buckets$get(BUCKET_COUNT - 1), changetype(base_ptr));\n }\n\n /*\n * Find the smallest bucket that will fit this request. This doesn\'t check\n * that there\'s space for the request yet.\n */\n bucket = bucket_for_request(request + HEADER_SIZE);\n original_bucket = bucket;\n\n /*\n * Search for a bucket with a non-empty free list that\'s as large or larger\n * than what we need. If there isn\'t an exact match, we\'ll need to split a\n * larger one to get a match.\n */\n while (bucket + 1 != 0) {\n let size: usize, bytes_needed: usize, i: usize;\n let ptr: usize;\n\n /*\n * We may need to grow the tree to be able to fit an allocation of this\n * size. Try to grow the tree and stop here if we can\'t.\n */\n if (!lower_bucket_limit(bucket)) {\n return 0;\n }\n\n /*\n * Try to pop a block off the free list for this bucket. If the free list\n * is empty, we\'re going to have to split a larger block instead.\n */\n ptr = changetype(list_pop(buckets$get(bucket)));\n if (!ptr) {\n /*\n * If we\'re not at the root of the tree or it\'s impossible to grow the\n * tree any more, continue on to the next bucket.\n */\n if (bucket != bucket_limit || bucket == 0) {\n bucket--;\n continue;\n }\n\n /*\n * Otherwise, grow the tree one more level and then pop a block off the\n * free list again. Since we know the root of the tree is used (because\n * the free list was empty), this will add a parent above this node in\n * the SPLIT state and then add the new right child node to the free list\n * for this bucket. Popping the free list will give us this right child.\n */\n if (!lower_bucket_limit(bucket - 1)) {\n return 0;\n }\n ptr = changetype(list_pop(buckets$get(bucket)));\n }\n\n /*\n * Try to expand the address space first before going any further. If we\n * have run out of space, put this block back on the free list and fail.\n */\n size = 1 << (MAX_ALLOC_LOG2 - bucket);\n bytes_needed = bucket < original_bucket ? size / 2 + List.SIZE : size;\n if (!update_max_ptr(ptr + bytes_needed)) {\n list_push(buckets$get(bucket), changetype(ptr));\n return 0;\n }\n\n /*\n * If we got a node off the free list, change the node from UNUSED to USED.\n * This involves flipping our parent\'s "is split" bit because that bit is\n * the exclusive-or of the UNUSED flags of both children, and our UNUSED\n * flag (which isn\'t ever stored explicitly) has just changed.\n *\n * Note that we shouldn\'t ever need to flip the "is split" bit of our\n * grandparent because we know our buddy is USED so it\'s impossible for our\n * grandparent to be UNUSED (if our buddy chunk was UNUSED, our parent\n * wouldn\'t ever have been split in the first place).\n */\n i = node_for_ptr(ptr, bucket);\n if (i != 0) {\n flip_parent_is_split(i);\n }\n\n /*\n * If the node we got is larger than we need, split it down to the correct\n * size and put the new unused child nodes on the free list in the\n * corresponding bucket. This is done by repeatedly moving to the left\n * child, splitting the parent, and then adding the right child to the free\n * list.\n */\n while (bucket < original_bucket) {\n i = i * 2 + 1;\n bucket++;\n flip_parent_is_split(i);\n list_push(\n buckets$get(bucket),\n changetype(ptr_for_node(i + 1, bucket))\n );\n }\n\n /*\n * Now that we have a memory address, write the block header (just the size\n * of the allocation) and return the address immediately after the header.\n */\n store(ptr, request);\n return ptr + HEADER_SIZE;\n }\n\n return 0;\n}\n\n@global export function __memory_free(ptr: usize): void {\n var bucket: usize, i: usize;\n\n /*\n * Ignore any attempts to free a NULL pointer.\n */\n if (!ptr) {\n return;\n }\n\n /*\n * We were given the address returned by "malloc" so get back to the actual\n * address of the node by subtracting off the size of the block header. Then\n * look up the index of the node corresponding to this address.\n */\n ptr = ptr - HEADER_SIZE;\n bucket = bucket_for_request(load(ptr) + HEADER_SIZE);\n i = node_for_ptr(ptr, bucket);\n\n /*\n * Traverse up to the root node, flipping USED blocks to UNUSED and merging\n * UNUSED buddies together into a single UNUSED parent.\n */\n while (i != 0) {\n /*\n * Change this node from UNUSED to USED. This involves flipping our\n * parent\'s "is split" bit because that bit is the exclusive-or of the\n * UNUSED flags of both children, and our UNUSED flag (which isn\'t ever\n * stored explicitly) has just changed.\n */\n flip_parent_is_split(i);\n\n /*\n * If the parent is now SPLIT, that means our buddy is USED, so don\'t merge\n * with it. Instead, stop the iteration here and add ourselves to the free\n * list for our bucket.\n *\n * Also stop here if we\'re at the current root node, even if that root node\n * is now UNUSED. Root nodes don\'t have a buddy so we can\'t merge with one.\n */\n if (parent_is_split(i) || bucket == bucket_limit) {\n break;\n }\n\n /*\n * If we get here, we know our buddy is UNUSED. In this case we should\n * merge with that buddy and continue traversing up to the root node. We\n * need to remove the buddy from its free list here but we don\'t need to\n * add the merged parent to its free list yet. That will be done once after\n * this loop is finished.\n */\n list_remove(changetype(ptr_for_node(((i - 1) ^ 1) + 1, bucket)));\n i = (i - 1) / 2;\n bucket--;\n }\n\n /*\n * Add ourselves to the free list for our bucket. We add to the back of the\n * list because "malloc" takes from the back of the list and we want a "free"\n * followed by a "malloc" of the same size to ideally use the same address\n * for better memory locality.\n */\n list_push(buckets$get(bucket), changetype(ptr_for_node(i, bucket)));\n}\n',"allocator/emscripten":"/**\n * Emscripten Memory Allocator.\n *\n * Uses Emscripten's exported _malloc and _free implementations, i.e., when linking with\n * Emscripten-compiled programs that already provide these. Differs from 'system' in that their\n * names are prefixed with an underscore.\n *\n * @module std/assembly/allocator/emscripten\n *//***/\n\ndeclare function _malloc(size: usize): usize;\ndeclare function _free(ptr: usize): void;\n\n// Memory allocator interface\n\n@global export function __memory_allocate(size: usize): usize {\n return _malloc(size);\n}\n\n@global export function __memory_free(ptr: usize): void {\n _free(ptr);\n}\n","allocator/system":"/**\n * System Memory Allocator.\n *\n * Uses the environment's malloc and free implementations, i.e., when linking with other C-like\n * programs that already provide these.\n *\n * @module std/assembly/allocator/system\n *//***/\n\ndeclare function malloc(size: usize): usize;\ndeclare function free(ptr: usize): void;\n\n// Memory allocator interface\n\n@global export function __memory_allocate(size: usize): usize {\n return malloc(size);\n}\n\n@global export function __memory_free(ptr: usize): void {\n free(ptr);\n}\n","allocator/tlsf":"/**\n * Two-Level Segregate Fit Memory Allocator.\n *\n * A general purpose dynamic memory allocator specifically designed to meet real-time requirements.\n * Always aligns to 8 bytes.\n *\n * @module std/assembly/allocator/tlsf\n *//***/\n\n// ╒══════════════ Block size interpretation (32-bit) ═════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┴─┴─┴─┴─╫─┴─┴─┤\n// │ | FL │ SB = SL + AL │ ◄─ usize\n// └───────────────────────────────────────────────┴─────────╨─────┘\n// FL: first level, SL: second level, AL: alignment, SB: small block\n\nimport {\n AL_BITS,\n AL_SIZE,\n AL_MASK\n} from \"../internal/allocator\";\n\nconst SL_BITS: u32 = 5;\nconst SL_SIZE: usize = 1 << SL_BITS;\n\nconst SB_BITS: usize = (SL_BITS + AL_BITS);\nconst SB_SIZE: usize = 1 << SB_BITS;\n\nconst FL_BITS: u32 = (sizeof() == sizeof()\n ? 30 // ^= up to 1GB per block\n : 32 // ^= up to 4GB per block\n) - SB_BITS;\n\n// ╒════════════════ Block structure layout (32-bit) ══════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┼─┼─┤\n// │ size │L│F│ ◄─┐ info\n// ╞═══════════════════════════════════════════════════════════╧═╧═╡ │ ┐\n// │ if free: ◄ prev │ ◄─┤ usize\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ if free: next ► │ ◄─┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ ... unused free space >= 0 ... │ │ = 0\n// ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤ │\n// │ if free: jump ▲ │ ◄─┘\n// └───────────────────────────────────────────────────────────────┘ MIN SIZE ┘\n// F: FREE, L: LEFT_FREE\n\n/** Tag indicating that this block is free. */\nconst FREE: usize = 1 << 0;\n/** Tag indicating that this block's left block is free. */\nconst LEFT_FREE: usize = 1 << 1;\n/** Mask to obtain all tags. */\nconst TAGS: usize = FREE | LEFT_FREE;\n\n/** Block structure. */\n@unmanaged\nclass Block {\n\n /** Info field holding this block's size and tags. */\n info: usize;\n\n /** End offset of the {@link Block#info} field. User data starts here. */\n static readonly INFO: usize = (sizeof() + AL_MASK) & ~AL_MASK;\n\n /** Previous free block, if any. Only valid if free. */\n prev: Block | null;\n /** Next free block, if any. Only valid if free. */\n next: Block | null;\n\n /** Minimum size of a block, excluding {@link Block#info}. */\n static readonly MIN_SIZE: usize = (3 * sizeof() + AL_MASK) & ~AL_MASK;// prev + next + jump\n\n /** Maximum size of a used block, excluding {@link Block#info}. */\n static readonly MAX_SIZE: usize = 1 << (FL_BITS + SB_BITS);\n\n /** Gets this block's left (free) block in memory. */\n get left(): Block {\n assert(this.info & LEFT_FREE); // must be free to contain a jump\n return assert(\n load(changetype(this) - sizeof())\n ); // can't be null\n }\n\n /** Gets this block's right block in memory. */\n get right(): Block {\n assert(this.info & ~TAGS); // can't skip beyond the tail block\n return assert(\n changetype(\n changetype(this) + Block.INFO + (this.info & ~TAGS)\n )\n ); // can't be null\n }\n}\n\n// ╒════════════════ Root structure layout (32-bit) ═══════════════╕\n// 3 2 1\n// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 bits\n// ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤ ┐\n// │ 0 | flMap S│ ◄────┐\n// ╞═══════════════════════════════════════════════════════════════╡ │\n// │ slMap[0] S │ ◄─┐ │\n// ├───────────────────────────────────────────────────────────────┤ │ │\n// │ slMap[1] │ ◄─┤ │\n// ├───────────────────────────────────────────────────────────────┤ u32 │\n// │ ... │ ◄─┤ │\n// ├───────────────────────────────────────────────────────────────┤ │ │\n// │ slMap[22] P │ ◄─┘ │\n// ╞═══════════════════════════════════════════════════════════════╡ usize\n// │ head[0] │ ◄────┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ ... │ ◄────┤\n// ├───────────────────────────────────────────────────────────────┤ │\n// │ head[736] │ ◄────┤\n// ╞═══════════════════════════════════════════════════════════════╡ │\n// │ tailRef │ ◄────┘\n// └───────────────────────────────────────────────────────────────┘ SIZE ┘\n// S: Small blocks map, P: Possibly padded if 64-bit\n\nassert((1 << SL_BITS) <= 32); // second level must fit into 32 bits\n\n/** Root structure. */\n@unmanaged\nclass Root {\n\n /** First level bitmap. */\n flMap: usize = 0;\n\n /** Start offset of second level maps. */\n private static readonly SL_START: usize = sizeof();\n\n // Using *one* SL map per *FL bit*\n\n /** Gets the second level map for the specified first level. */\n getSLMap(fl: usize): u32 {\n assert(fl < FL_BITS); // fl out of range\n return load(changetype(this) + fl * 4, Root.SL_START);\n }\n\n /** Sets the second level map for the specified first level. */\n setSLMap(fl: usize, value: u32): void {\n assert(fl < FL_BITS); // fl out of range\n store(changetype(this) + fl * 4, value, Root.SL_START);\n }\n\n /** End offset of second level maps. */\n private static readonly SL_END: usize = Root.SL_START + FL_BITS * 4;\n\n // Using *number bits per SL* heads per *FL bit*\n\n /** Start offset of FL/SL heads. */\n private static readonly HL_START: usize = (Root.SL_END + AL_MASK) & ~AL_MASK;\n\n /** Gets the head of the specified first and second level index. */\n getHead(fl: usize, sl: u32): Block | null {\n assert(fl < FL_BITS); // fl out of range\n assert(sl < SL_SIZE); // sl out of range\n return changetype(load(\n changetype(this) + (fl * SL_SIZE + sl) * sizeof()\n , Root.HL_START));\n }\n\n /** Sets the head of the specified first and second level index. */\n setHead(fl: usize, sl: u32, value: Block | null): void {\n assert(fl < FL_BITS); // fl out of range\n assert(sl < SL_SIZE); // sl out of range\n store(\n changetype(this) + (fl * SL_SIZE + sl) * sizeof()\n , changetype(value)\n , Root.HL_START);\n }\n\n /** End offset of FL/SL heads. */\n private static readonly HL_END: usize = (\n Root.HL_START + FL_BITS * SL_SIZE * sizeof()\n );\n\n get tailRef(): usize { return load(0, Root.HL_END); }\n set tailRef(value: usize) { store(0, value, Root.HL_END); }\n\n /** Total size of the {@link Root} structure. */\n static readonly SIZE: usize = Root.HL_END + sizeof();\n\n /** Inserts a previously used block back into the free list. */\n insert(block: Block): void {\n // check as much as possible here to prevent invalid free blocks\n assert(block); // cannot be null\n var blockInfo = block.info;\n assert(blockInfo & FREE); // must be free\n var size: usize;\n assert(\n (size = block.info & ~TAGS) >= Block.MIN_SIZE && size < Block.MAX_SIZE\n ); // must be valid, not necessary to compute yet if noAssert=true\n\n var right: Block = assert(block.right); // can't be null\n var rightInfo = right.info;\n\n // merge with right block if also free\n if (rightInfo & FREE) {\n this.remove(right);\n block.info = (blockInfo += Block.INFO + (rightInfo & ~TAGS));\n right = block.right;\n rightInfo = right.info;\n // jump is set below\n }\n\n // merge with left block if also free\n if (blockInfo & LEFT_FREE) {\n let left: Block = assert(block.left); // can't be null\n let leftInfo = left.info;\n assert(leftInfo & FREE); // must be free according to tags\n this.remove(left);\n left.info = (leftInfo += Block.INFO + (blockInfo & ~TAGS));\n block = left;\n blockInfo = leftInfo;\n // jump is set below\n }\n\n right.info = rightInfo | LEFT_FREE;\n this.setJump(block, right);\n // right is no longer used now, hence rightInfo is not synced\n\n size = blockInfo & ~TAGS;\n assert(size >= Block.MIN_SIZE && size < Block.MAX_SIZE); // must be valid\n\n // mapping_insert\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size / AL_SIZE);\n } else {\n fl = fls(size);\n sl = ((size >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n\n // perform insertion\n var head = this.getHead(fl, sl);\n block.prev = null;\n block.next = head;\n if (head) head.prev = block;\n this.setHead(fl, sl, block);\n\n // update first and second level maps\n this.flMap |= (1 << fl);\n this.setSLMap(fl, this.getSLMap(fl) | (1 << sl));\n }\n\n /**\n * Removes a free block from FL/SL maps. Does not alter left/jump because it\n * is likely that splitting is performed afterwards, invalidating any changes\n * again.\n */\n private remove(block: Block): void {\n var blockInfo = block.info;\n assert(blockInfo & FREE); // must be free\n var size = blockInfo & ~TAGS;\n assert(size >= Block.MIN_SIZE && size < Block.MAX_SIZE); // must be valid\n\n // mapping_insert\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size / AL_SIZE);\n } else {\n fl = fls(size);\n sl = ((size >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n }\n\n // link previous and next free block\n var prev = block.prev;\n var next = block.next;\n if (prev) prev.next = next;\n if (next) next.prev = prev;\n\n // update head if we are removing it\n if (block == this.getHead(fl, sl)) {\n this.setHead(fl, sl, next);\n\n // clear second level map if head is empty now\n if (!next) {\n let slMap = this.getSLMap(fl);\n this.setSLMap(fl, slMap &= ~(1 << sl));\n\n // clear first level map if second level is empty now\n if (!slMap) this.flMap &= ~(1 << fl);\n }\n }\n }\n\n /** Searches for a free block of at least the specified size. */\n search(size: usize): Block | null {\n assert(size >= Block.MIN_SIZE && size < Block.MAX_SIZE);\n\n // mapping_search\n var fl: usize, sl: u32;\n if (size < SB_SIZE) {\n fl = 0;\n sl = (size / AL_SIZE);\n } else {\n // (*) size += (1 << (fls(size) - SL_BITS)) - 1;\n fl = fls(size);\n sl = ((size >> (fl - SL_BITS)) ^ (1 << SL_BITS));\n fl -= SB_BITS - 1;\n // (*) instead of rounding up, use next second level list for better fit\n if (sl < SL_SIZE - 1) ++sl;\n else ++fl, sl = 0;\n }\n\n // search second level\n var slMap = this.getSLMap(fl) & (~0 << sl);\n var head: Block | null;\n if (!slMap) {\n // search next larger first level\n let flMap = this.flMap & (~0 << (fl + 1));\n if (!flMap) {\n head = null;\n } else {\n fl = ffs(flMap);\n slMap = assert(this.getSLMap(fl)); // can't be zero if fl points here\n head = this.getHead(fl, ffs(slMap));\n }\n } else {\n head = this.getHead(fl, ffs(slMap));\n }\n return head;\n }\n\n /** Links a free left with its right block in memory. */\n private setJump(left: Block, right: Block): void {\n assert(left.info & FREE); // must be free\n assert(left.right == right); // right block must match\n assert(right.info & LEFT_FREE); // right block must be tagged as LEFT_FREE\n store(\n changetype(right) - sizeof()\n , left); // last word in left block's (free) data region\n }\n\n /**\n * Uses the specified free block, removing it from internal maps and\n * splitting it if possible, and returns its data pointer.\n */\n use(block: Block, size: usize): usize {\n var blockInfo = block.info;\n assert(blockInfo & FREE); // must be free so we can use it\n assert(size >= Block.MIN_SIZE && size < Block.MAX_SIZE); // must be valid\n assert(!(size & AL_MASK)); // size must be aligned so the new block is\n\n this.remove(block);\n\n // split if the block can hold another MIN_SIZE block\n var remaining = (blockInfo & ~TAGS) - size;\n if (remaining >= Block.INFO + Block.MIN_SIZE) {\n block.info = size | (blockInfo & LEFT_FREE); // also discards FREE\n\n let spare = changetype(\n changetype(block) + Block.INFO + size\n );\n spare.info = (remaining - Block.INFO) | FREE; // not LEFT_FREE\n this.insert(spare); // also sets jump\n\n // otherwise tag block as no longer FREE and right as no longer LEFT_FREE\n } else {\n block.info = blockInfo & ~FREE;\n let right: Block = assert(block.right); // can't be null (tail)\n right.info &= ~LEFT_FREE;\n }\n\n return changetype(block) + Block.INFO;\n }\n\n /** Adds more memory to the pool. */\n addMemory(start: usize, end: usize): bool {\n assert(start <= end);\n assert(!(start & AL_MASK)); // must be aligned\n assert(!(end & AL_MASK)); // must be aligned\n\n var tailRef = this.tailRef;\n var tailInfo: usize = 0;\n if (tailRef) {\n assert(start >= tailRef + sizeof()); // starts after tail\n\n // merge with current tail if adjacent\n if (start - Block.INFO == tailRef) {\n start -= Block.INFO;\n tailInfo = changetype(tailRef).info;\n }\n\n } else {\n assert(start >= changetype(this) + Root.SIZE); // starts after root\n }\n\n // check if size is large enough for a free block and the tail block\n var size = end - start;\n if (size < Block.INFO + Block.MIN_SIZE + Block.INFO) {\n return false;\n }\n\n // left size is total minus its own and the zero-length tail's header\n var leftSize = size - 2 * Block.INFO;\n var left = changetype(start);\n left.info = leftSize | FREE | (tailInfo & LEFT_FREE);\n left.prev = null;\n left.next = null;\n\n // tail is a zero-length used block\n var tail = changetype(start + size - Block.INFO);\n tail.info = 0 | LEFT_FREE;\n this.tailRef = changetype(tail);\n\n this.insert(left); // also merges with free left before tail / sets jump\n\n return true;\n }\n}\n\n/** Determines the first (LSB to MSB) set bit's index of a word. */\nfunction ffs(word: T): T {\n assert(word != 0); // word cannot be 0\n return ctz(word); // differs from ffs only for 0\n}\n\n/** Determines the last (LSB to MSB) set bit's index of a word. */\nfunction fls(word: T): T {\n assert(word != 0); // word cannot be 0\n const inv: T = (sizeof() << 3) - 1;\n return inv - clz(word);\n}\n\n/** Reference to the initialized {@link Root} structure, once initialized. */\nvar ROOT: Root = changetype(0);\n\n// Memory allocator interface\n\n/** Allocates a chunk of memory. */\n@global export function __memory_allocate(size: usize): usize {\n\n // initialize if necessary\n var root = ROOT;\n if (!root) {\n let rootOffset = (HEAP_BASE + AL_MASK) & ~AL_MASK;\n let pagesBefore = memory.size();\n let pagesNeeded = ((((rootOffset + Root.SIZE) + 0xffff) & ~0xffff) >>> 16);\n if (pagesNeeded > pagesBefore && memory.grow(pagesNeeded - pagesBefore) < 0) unreachable();\n ROOT = root = changetype(rootOffset);\n root.tailRef = 0;\n root.flMap = 0;\n for (let fl: usize = 0; fl < FL_BITS; ++fl) {\n root.setSLMap(fl, 0);\n for (let sl: u32 = 0; sl < SL_SIZE; ++sl) {\n root.setHead(fl, sl, null);\n }\n }\n root.addMemory((rootOffset + Root.SIZE + AL_MASK) & ~AL_MASK, memory.size() << 16);\n }\n\n // search for a suitable block\n if (size > Block.MAX_SIZE) unreachable();\n\n // 32-bit MAX_SIZE is 1 << 30 and itself aligned, hence the following can't overflow MAX_SIZE\n size = max((size + AL_MASK) & ~AL_MASK, Block.MIN_SIZE);\n\n var block = root.search(size);\n if (!block) {\n\n // request more memory\n let pagesBefore = memory.size();\n let pagesNeeded = (((size + 0xffff) & ~0xffff) >>> 16);\n let pagesWanted = max(pagesBefore, pagesNeeded); // double memory\n if (memory.grow(pagesWanted) < 0) {\n if (memory.grow(pagesNeeded) < 0) {\n unreachable(); // out of memory\n }\n }\n let pagesAfter = memory.size();\n root.addMemory(pagesBefore << 16, pagesAfter << 16);\n block = assert(root.search(size)); // must be found now\n }\n\n assert((block.info & ~TAGS) >= size);\n return root.use(block, size);\n}\n\n/** Frees the chunk of memory at the specified address. */\n@global export function __memory_free(data: usize): void {\n if (data) {\n let root = ROOT;\n if (root) {\n let block = changetype(data - Block.INFO);\n let blockInfo = block.info;\n assert(!(blockInfo & FREE)); // must be used\n block.info = blockInfo | FREE;\n root.insert(changetype(data - Block.INFO));\n }\n }\n}\n\n@global export function __memory_reset(): void {\n unreachable();\n}\n",array:'import {\n MAX_BLENGTH,\n HEADER_SIZE,\n allocateUnsafe,\n reallocateUnsafe,\n LOAD,\n STORE\n} from "./internal/arraybuffer";\n\nimport {\n allocateUnsafe as allocateUnsafeString,\n freeUnsafe as freeUnsafeString,\n copyUnsafe as copyUnsafeString\n} from "./internal/string";\n\nimport {\n COMPARATOR,\n SORT\n} from "./internal/sort";\n\nimport {\n itoa,\n dtoa,\n itoa_stream,\n dtoa_stream,\n MAX_DOUBLE_LENGTH\n} from "./internal/number";\n\nimport {\n isArray as builtin_isArray\n} from "./builtins";\n\nexport class Array {\n [key: number]: T; // compatibility only\n\n /* @internal */ buffer_: ArrayBuffer;\n /* @internal */ length_: i32;\n\n @inline static isArray(value: U): bool {\n return builtin_isArray(value) && value !== null;\n }\n\n constructor(length: i32 = 0) {\n const MAX_LENGTH = MAX_BLENGTH >>> alignof();\n if (length > MAX_LENGTH) throw new RangeError("Invalid array length");\n var byteLength = length << alignof();\n var buffer = allocateUnsafe(byteLength);\n this.buffer_ = buffer;\n this.length_ = length;\n memory.fill(\n changetype(buffer) + HEADER_SIZE,\n 0,\n byteLength\n );\n }\n\n @inline\n get length(): i32 {\n return this.length_;\n }\n\n set length(length: i32) {\n var buffer = this.buffer_;\n var capacity = buffer.byteLength >>> alignof();\n if (length > capacity) {\n const MAX_LENGTH = MAX_BLENGTH >>> alignof();\n if (length > MAX_LENGTH) throw new RangeError("Invalid array length");\n buffer = reallocateUnsafe(buffer, length << alignof());\n this.buffer_ = buffer;\n }\n this.length_ = length;\n }\n\n every(callbackfn: (element: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (!callbackfn(LOAD(this.buffer_, index), index, this)) return false;\n }\n return true;\n }\n\n findIndex(predicate: (element: T, index: i32, array: Array) => bool): i32 {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (predicate(LOAD(this.buffer_, index), index, this)) return index;\n }\n return -1;\n }\n\n @operator("[]")\n private __get(index: i32): T {\n var buffer = this.buffer_;\n return index < (buffer.byteLength >>> alignof())\n ? LOAD(buffer, index)\n : unreachable();\n }\n\n @operator("{}")\n private __unchecked_get(index: i32): T {\n return LOAD(this.buffer_, index);\n }\n\n @operator("[]=")\n private __set(index: i32, value: T): void {\n var buffer = this.buffer_;\n var capacity = buffer.byteLength >>> alignof();\n if (index >= capacity) {\n const MAX_LENGTH = MAX_BLENGTH >>> alignof();\n if (index >= MAX_LENGTH) throw new Error("Invalid array length");\n buffer = reallocateUnsafe(buffer, (index + 1) << alignof());\n this.buffer_ = buffer;\n this.length_ = index + 1;\n }\n STORE(buffer, index, value);\n if (isManaged()) __gc_link(changetype(this), changetype(value)); // tslint:disable-line\n }\n\n @operator("{}=")\n private __unchecked_set(index: i32, value: T): void {\n STORE(this.buffer_, index, value);\n if (isManaged()) __gc_link(changetype(this), changetype(value)); // tslint:disable-line\n }\n\n fill(value: T, start: i32 = 0, end: i32 = i32.MAX_VALUE): this {\n var buffer = this.buffer_;\n var len = this.length_;\n\n start = start < 0 ? max(len + start, 0) : min(start, len);\n end = end < 0 ? max(len + end, 0) : min(end, len);\n\n if (sizeof() == 1) {\n if (start < end) {\n memory.fill(\n changetype(buffer) + start + HEADER_SIZE,\n value,\n (end - start)\n );\n }\n } else {\n for (; start < end; ++start) {\n STORE(buffer, start, value);\n }\n }\n return this;\n }\n\n @inline\n includes(searchElement: T, fromIndex: i32 = 0): bool {\n return this.indexOf(searchElement, fromIndex) >= 0;\n }\n\n indexOf(searchElement: T, fromIndex: i32 = 0): i32 {\n var length = this.length_;\n if (length == 0 || fromIndex >= length) return -1;\n if (fromIndex < 0) fromIndex = max(length + fromIndex, 0);\n var buffer = this.buffer_;\n while (fromIndex < length) {\n if (LOAD(buffer, fromIndex) == searchElement) return fromIndex;\n ++fromIndex;\n }\n return -1;\n }\n\n lastIndexOf(searchElement: T, fromIndex: i32 = this.length_): i32 {\n var length = this.length_;\n if (length == 0) return -1;\n if (fromIndex < 0) fromIndex = length + fromIndex; // no need to clamp\n else if (fromIndex >= length) fromIndex = length - 1;\n var buffer = this.buffer_;\n while (fromIndex >= 0) { // ^\n if (LOAD(buffer, fromIndex) == searchElement) return fromIndex;\n --fromIndex;\n }\n return -1;\n }\n\n push(element: T): i32 {\n var length = this.length_;\n var buffer = this.buffer_;\n var capacity = buffer.byteLength >>> alignof();\n var newLength = length + 1; // safe only if length is checked\n if (length >= capacity) {\n const MAX_LENGTH = MAX_BLENGTH >>> alignof();\n if (length >= MAX_LENGTH) throw new Error("Invalid array length");\n buffer = reallocateUnsafe(buffer, newLength << alignof());\n this.buffer_ = buffer;\n }\n this.length_ = newLength;\n STORE(buffer, length, element);\n if (isManaged()) __gc_link(changetype(this), changetype(element)); // tslint:disable-line\n return newLength;\n }\n\n concat(items: Array): Array {\n var thisLen = this.length_;\n var otherLen = select(0, items.length_, items === null);\n var outLen = thisLen + otherLen;\n var out = new Array(outLen);\n\n if (thisLen) {\n memory.copy(\n changetype(out.buffer_) + HEADER_SIZE,\n changetype(this.buffer_) + HEADER_SIZE,\n thisLen << alignof()\n );\n }\n if (otherLen) {\n memory.copy(\n changetype(out.buffer_) + HEADER_SIZE + (thisLen << alignof()),\n changetype(items.buffer_) + HEADER_SIZE,\n otherLen << alignof()\n );\n }\n return out;\n }\n\n copyWithin(target: i32, start: i32, end: i32 = i32.MAX_VALUE): this {\n var buffer = this.buffer_;\n var len = this.length_;\n\n end = min(end, len);\n var to = target < 0 ? max(len + target, 0) : min(target, len);\n var from = start < 0 ? max(len + start, 0) : min(start, len);\n var last = end < 0 ? max(len + end, 0) : min(end, len);\n var count = min(last - from, len - to);\n\n if (from < to && to < (from + count)) {\n from += count - 1;\n to += count - 1;\n while (count) {\n STORE(buffer, to, LOAD(buffer, from));\n --from, --to, --count;\n }\n } else {\n memory.copy(\n changetype(buffer) + HEADER_SIZE + (to << alignof()),\n changetype(buffer) + HEADER_SIZE + (from << alignof()),\n count << alignof()\n );\n }\n return this;\n }\n\n pop(): T {\n var length = this.length_;\n if (length < 1) throw new RangeError("Array is empty");\n var element = LOAD(this.buffer_, --length);\n this.length_ = length;\n return element;\n }\n\n forEach(callbackfn: (value: T, index: i32, array: Array) => void): void {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n callbackfn(LOAD(this.buffer_, index), index, this);\n }\n }\n\n map(callbackfn: (value: T, index: i32, array: Array) => U): Array {\n var length = this.length_;\n var result = new Array(length);\n var buffer = result.buffer_;\n for (let index = 0; index < min(length, this.length_); ++index) {\n STORE(buffer, index, callbackfn(LOAD(this.buffer_, index), index, this));\n }\n return result;\n }\n\n filter(callbackfn: (value: T, index: i32, array: Array) => bool): Array {\n var result = new Array();\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n let value = LOAD(this.buffer_, index);\n if (callbackfn(value, index, this)) result.push(value);\n }\n return result;\n }\n\n reduce(\n callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U,\n initialValue: U\n ): U {\n var accum = initialValue;\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n accum = callbackfn(accum, LOAD(this.buffer_, index), index, this);\n }\n return accum;\n }\n\n reduceRight(\n callbackfn: (previousValue: U, currentValue: T, currentIndex: i32, array: Array) => U,\n initialValue: U\n ): U {\n var accum = initialValue;\n for (let index = this.length_ - 1; index >= 0; --index) {\n accum = callbackfn(accum, LOAD(this.buffer_, index), index, this);\n }\n return accum;\n }\n\n shift(): T {\n var length = this.length_;\n if (length < 1) throw new RangeError("Array is empty");\n var buffer = this.buffer_;\n var element = LOAD(buffer, 0);\n var lastIndex = length - 1;\n memory.copy(\n changetype(buffer) + HEADER_SIZE,\n changetype(buffer) + HEADER_SIZE + sizeof(),\n lastIndex << alignof()\n );\n STORE(buffer, lastIndex, null);\n this.length_ = lastIndex;\n return element;\n }\n\n some(callbackfn: (element: T, index: i32, array: Array) => bool): bool {\n for (let index = 0, length = this.length_; index < min(length, this.length_); ++index) {\n if (callbackfn(LOAD(this.buffer_, index), index, this)) return true;\n }\n return false;\n }\n\n unshift(element: T): i32 {\n var buffer = this.buffer_;\n var capacity = buffer.byteLength >>> alignof();\n var length = this.length_;\n var newLength = length + 1; // safe only if length is checked\n if (length >= capacity) {\n const MAX_LENGTH = MAX_BLENGTH >>> alignof();\n if (length >= MAX_LENGTH) throw new Error("Invalid array length");\n buffer = reallocateUnsafe(buffer, newLength << alignof());\n capacity = buffer.byteLength >>> alignof();\n this.buffer_ = buffer;\n }\n memory.copy(\n changetype(buffer) + HEADER_SIZE + sizeof(),\n changetype(buffer) + HEADER_SIZE,\n (capacity - 1) << alignof()\n );\n STORE(buffer, 0, element);\n this.length_ = newLength;\n if (isManaged()) __gc_link(changetype(this), changetype(element)); // tslint:disable-line\n return newLength;\n }\n\n slice(begin: i32 = 0, end: i32 = i32.MAX_VALUE): Array {\n var len = this.length_;\n begin = begin < 0 ? max(begin + len, 0) : min(begin, len);\n end = end < 0 ? max(end + len, 0) : min(end, len);\n len = end - begin;\n var sliced = new Array(len);\n if (len) {\n memory.copy(\n changetype(sliced.buffer_) + HEADER_SIZE,\n changetype(this.buffer_) + HEADER_SIZE + (begin << alignof()),\n len << alignof()\n );\n }\n return sliced;\n }\n\n splice(start: i32, deleteCount: i32 = i32.MAX_VALUE): Array {\n var length = this.length_;\n start = start < 0 ? max(length + start, 0) : min(start, length);\n deleteCount = max(min(deleteCount, length - start), 0);\n var buffer = this.buffer_;\n var spliced = new Array(deleteCount);\n var source = changetype(buffer) + HEADER_SIZE + (start << alignof