j?j:g+f));return 1===d?(b=a[c-1],e.push(k[b>>2]+k[63&b<<4]+"==")):2===d&&(b=(a[c-2]<<8)+a[c-1],e.push(k[b>>10]+k[63&b>>4]+k[63&b<<2]+"=")),e.join("")}c.byteLength=function(a){var b=d(a),c=b[0],e=b[1];return 3*(c+e)/4-e},c.toByteArray=f,c.fromByteArray=j;for(var k=[],l=[],m="undefined"==typeof Uint8Array?Array:Uint8Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,p=n.length;o 0) {
+ throw new Error('Invalid string. Length must be a multiple of 4')
+ }
+
+ // Trim off extra bytes after placeholder bytes are found
+ // See: https://github.com/beatgammit/base64-js/issues/42
+ var validLen = b64.indexOf('=')
+ if (validLen === -1) validLen = len
+
+ var placeHoldersLen = validLen === len
+ ? 0
+ : 4 - (validLen % 4)
+
+ return [validLen, placeHoldersLen]
+}
+
+// base64 is 4/3 + up to two characters of the original data
+function byteLength (b64) {
+ var lens = getLens(b64)
+ var validLen = lens[0]
+ var placeHoldersLen = lens[1]
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
+}
+
+function _byteLength (b64, validLen, placeHoldersLen) {
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
+}
+
+function toByteArray (b64) {
+ var tmp
+ var lens = getLens(b64)
+ var validLen = lens[0]
+ var placeHoldersLen = lens[1]
+
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
+
+ var curByte = 0
+
+ // if there are placeholders, only get up to the last complete 4 chars
+ var len = placeHoldersLen > 0
+ ? validLen - 4
+ : validLen
+
+ var i
+ for (i = 0; i < len; i += 4) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 18) |
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
+ revLookup[b64.charCodeAt(i + 3)]
+ arr[curByte++] = (tmp >> 16) & 0xFF
+ arr[curByte++] = (tmp >> 8) & 0xFF
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ if (placeHoldersLen === 2) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 2) |
+ (revLookup[b64.charCodeAt(i + 1)] >> 4)
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ if (placeHoldersLen === 1) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 10) |
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
+ (revLookup[b64.charCodeAt(i + 2)] >> 2)
+ arr[curByte++] = (tmp >> 8) & 0xFF
+ arr[curByte++] = 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) & 0xFF0000) +
+ ((uint8[i + 1] << 8) & 0xFF00) +
+ (uint8[i + 2] & 0xFF)
+ 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 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]
+ parts.push(
+ lookup[tmp >> 2] +
+ lookup[(tmp << 4) & 0x3F] +
+ '=='
+ )
+ } else if (extraBytes === 2) {
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1]
+ parts.push(
+ lookup[tmp >> 10] +
+ lookup[(tmp >> 4) & 0x3F] +
+ lookup[(tmp << 2) & 0x3F] +
+ '='
+ )
+ }
+
+ return parts.join('')
+}
diff --git a/node_modules/base64-js/package.json b/node_modules/base64-js/package.json
new file mode 100644
index 0000000..c3972e3
--- /dev/null
+++ b/node_modules/base64-js/package.json
@@ -0,0 +1,47 @@
+{
+ "name": "base64-js",
+ "description": "Base64 encoding/decoding in pure JS",
+ "version": "1.5.1",
+ "author": "T. Jameson Little ",
+ "typings": "index.d.ts",
+ "bugs": {
+ "url": "https://github.com/beatgammit/base64-js/issues"
+ },
+ "devDependencies": {
+ "babel-minify": "^0.5.1",
+ "benchmark": "^2.1.4",
+ "browserify": "^16.3.0",
+ "standard": "*",
+ "tape": "4.x"
+ },
+ "homepage": "https://github.com/beatgammit/base64-js",
+ "keywords": [
+ "base64"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/beatgammit/base64-js.git"
+ },
+ "scripts": {
+ "build": "browserify -s base64js -r ./ | minify > base64js.min.js",
+ "lint": "standard",
+ "test": "npm run lint && npm run unit",
+ "unit": "tape test/*.js"
+ },
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ]
+}
diff --git a/node_modules/big-integer/BigInteger.d.ts b/node_modules/big-integer/BigInteger.d.ts
new file mode 100644
index 0000000..df5b865
--- /dev/null
+++ b/node_modules/big-integer/BigInteger.d.ts
@@ -0,0 +1,2393 @@
+/**
+ * Type definitions for BigInteger.js
+ * Definitions by: Tommy Frazier
+ */
+export = bigInt;
+export as namespace bigInt;
+
+declare var bigInt: bigInt.BigIntegerStatic;
+
+declare namespace bigInt {
+ type BigNumber = number | bigint | string | BigInteger;
+
+ interface BigIntegerStatic {
+ /**
+ * Equivalent to bigInt(0).
+ */
+ (): BigInteger;
+
+ /**
+ * Parse a Javascript number into a bigInt.
+ */
+ (number: number): BigInteger;
+
+ /**
+ * Parse a Javascript native bigint into a bigInt.
+ */
+ (number: bigint): BigInteger;
+
+ /**
+ * Parse a string into a bigInt.
+ * Default base is 10.
+ * Default alphabet is "0123456789abcdefghijklmnopqrstuvwxyz".
+ * caseSensitive defaults to false.
+ */
+ (string: string, base?: BigNumber, alphabet?: string, caseSensitive?: boolean): BigInteger;
+
+ /**
+ * no-op.
+ */
+ (bigInt: BigInteger): BigInteger;
+
+ /**
+ * Constructs a bigInt from an array of digits in specified base.
+ * The optional isNegative flag will make the number negative.
+ */
+ fromArray: (digits: BigNumber[], base?: BigNumber, isNegative?: boolean) => BigInteger;
+
+ /**
+ * Finds the greatest common denominator of a and b.
+ */
+ gcd: (a: BigNumber, b: BigNumber) => BigInteger;
+
+
+ /**
+ * Returns true if x is a BigInteger, false otherwise.
+ */
+ isInstance: (x: any) => x is BigInteger;
+
+ /**
+ * Finds the least common multiple of a and b.
+ */
+ lcm: (a: BigNumber, b: BigNumber) => BigInteger;
+
+ /**
+ * Returns the largest of a and b.
+ */
+ max: (a: BigNumber, b: BigNumber) => BigInteger;
+
+ /**
+ * Returns the smallest of a and b.
+ */
+ min: (a: BigNumber, b: BigNumber) => BigInteger;
+
+ /**
+ * Equivalent to bigInt(-1).
+ */
+ minusOne: BigInteger;
+
+ /**
+ * Equivalent to bigInt(1).
+ */
+ one: BigInteger;
+
+ /**
+ * Returns a random number between min and max.
+ */
+ randBetween: (min: BigNumber, max: BigNumber, rng?: () => number) => BigInteger;
+
+ /**
+ * Equivalent to bigInt(0).
+ */
+ zero: BigInteger;
+ }
+
+ interface BigInteger {
+ /**
+ * Returns the absolute value of a bigInt.
+ */
+ abs(): BigInteger;
+
+ /**
+ * Performs addition.
+ */
+ add(number: BigNumber): BigInteger;
+
+ /**
+ * Performs the bitwise AND operation.
+ */
+ and(number: BigNumber): BigInteger;
+
+ /**
+ * Returns the number of digits required to represent a bigInt in binary.
+ */
+ bitLength(): BigInteger;
+
+ /**
+ * Performs a comparison between two numbers. If the numbers are equal, it returns 0.
+ * If the first number is greater, it returns 1. If the first number is lesser, it returns -1.
+ */
+ compare(number: BigNumber): number;
+
+ /**
+ * Performs a comparison between the absolute value of two numbers.
+ */
+ compareAbs(number: BigNumber): number;
+
+ /**
+ * Alias for the compare method.
+ */
+ compareTo(number: BigNumber): number;
+
+ /**
+ * Performs integer division, disregarding the remainder.
+ */
+ divide(number: BigNumber): BigInteger;
+
+ /**
+ * Performs division and returns an object with two properties: quotient and remainder.
+ * The sign of the remainder will match the sign of the dividend.
+ */
+ divmod(number: BigNumber): { quotient: BigInteger, remainder: BigInteger };
+
+ /**
+ * Alias for the equals method.
+ */
+ eq(number: BigNumber): boolean;
+
+ /**
+ * Checks if two numbers are equal.
+ */
+ equals(number: BigNumber): boolean;
+
+ /**
+ * Alias for the greaterOrEquals method.
+ */
+ geq(number: BigNumber): boolean;
+
+ /**
+ * Checks if the first number is greater than the second.
+ */
+ greater(number: BigNumber): boolean;
+
+ /**
+ * Checks if the first number is greater than or equal to the second.
+ */
+ greaterOrEquals(number: BigNumber): boolean;
+
+ /**
+ * Alias for the greater method.
+ */
+ gt(number: BigNumber): boolean;
+
+ /**
+ * Returns true if the first number is divisible by the second number, false otherwise.
+ */
+ isDivisibleBy(number: BigNumber): boolean;
+
+ /**
+ * Returns true if the number is even, false otherwise.
+ */
+ isEven(): boolean;
+
+ /**
+ * Returns true if the number is negative, false otherwise.
+ * Returns false for 0 and true for -0.
+ */
+ isNegative(): boolean;
+
+ /**
+ * Returns true if the number is odd, false otherwise.
+ */
+ isOdd(): boolean;
+
+ /**
+ * Return true if the number is positive, false otherwise.
+ * Returns true for 0 and false for -0.
+ */
+ isPositive(): boolean;
+
+ /**
+ * Returns true if the number is prime, false otherwise.
+ */
+ isPrime(strict?: boolean): boolean;
+
+ /**
+ * Returns true if the number is very likely to be prime, false otherwise.
+ */
+ isProbablePrime(iterations?: number, rng?: () => number): boolean;
+
+ /**
+ * Returns true if the number is 1 or -1, false otherwise.
+ */
+ isUnit(): boolean;
+
+ /**
+ * Return true if the number is 0 or -0, false otherwise.
+ */
+ isZero(): boolean;
+
+ /**
+ * Alias for the lesserOrEquals method.
+ */
+ leq(number: BigNumber): boolean;
+
+ /**
+ * Checks if the first number is lesser than the second.
+ */
+ lesser(number: BigNumber): boolean;
+
+ /**
+ * Checks if the first number is less than or equal to the second.
+ */
+ lesserOrEquals(number: BigNumber): boolean;
+
+ /**
+ * Alias for the lesser method.
+ */
+ lt(number: BigNumber): boolean;
+
+ /**
+ * Alias for the subtract method.
+ */
+ minus(number: BigNumber): BigInteger;
+
+ /**
+ * Performs division and returns the remainder, disregarding the quotient.
+ * The sign of the remainder will match the sign of the dividend.
+ */
+ mod(number: BigNumber): BigInteger;
+
+ /**
+ * Finds the multiplicative inverse of the number modulo mod.
+ */
+ modInv(number: BigNumber): BigInteger;
+
+ /**
+ * Takes the number to the power exp modulo mod.
+ */
+ modPow(exp: BigNumber, mod: BigNumber): BigInteger;
+
+ /**
+ * Performs multiplication.
+ */
+ multiply(number: BigNumber): BigInteger;
+
+ /**
+ * Reverses the sign of the number.
+ */
+ negate(): BigInteger;
+
+ /**
+ * Alias for the notEquals method.
+ */
+ neq(number: BigNumber): boolean;
+
+ /**
+ * Adds one to the number.
+ */
+ next(): BigInteger;
+
+ /**
+ * Performs the bitwise NOT operation.
+ */
+ not(): BigInteger;
+
+ /**
+ * Checks if two numbers are not equal.
+ */
+ notEquals(number: BigNumber): boolean;
+
+ /**
+ * Performs the bitwise OR operation.
+ */
+ or(number: BigNumber): BigInteger;
+
+ /**
+ * Alias for the divide method.
+ */
+ over(number: BigNumber): BigInteger;
+
+ /**
+ * Alias for the add method.
+ */
+ plus(number: BigNumber): BigInteger;
+
+ /**
+ * Performs exponentiation. If the exponent is less than 0, pow returns 0.
+ * bigInt.zero.pow(0) returns 1.
+ */
+ pow(number: BigNumber): BigInteger;
+
+ /**
+ * Subtracts one from the number.
+ */
+ prev(): BigInteger;
+
+ /**
+ * Alias for the mod method.
+ */
+ remainder(number: BigNumber): BigInteger;
+
+ /**
+ * Shifts the number left by n places in its binary representation.
+ * If a negative number is provided, it will shift right.
+ *
+ * Throws an error if number is outside of the range [-9007199254740992, 9007199254740992].
+ */
+ shiftLeft(number: BigNumber): BigInteger;
+
+ /**
+ * Shifts the number right by n places in its binary representation.
+ * If a negative number is provided, it will shift left.
+ *
+ * Throws an error if number is outside of the range [-9007199254740992, 9007199254740992].
+ */
+ shiftRight(number: BigNumber): BigInteger;
+
+ /**
+ * Squares the number.
+ */
+ square(): BigInteger;
+
+ /**
+ * Performs subtraction.
+ */
+ subtract(number: BigNumber): BigInteger;
+
+ /**
+ * Alias for the multiply method.
+ */
+ times(number: BigNumber): BigInteger;
+
+ /**
+ *
+ * Converts a bigInt to an object representing it as an array of integers module the given radix.
+ */
+ toArray(radix: number): BaseArray;
+
+ /**
+ * Converts a bigInt into a native Javascript number. Loses precision for numbers outside the range.
+ */
+ toJSNumber(): number;
+
+ /**
+ * Converts a bigInt to a string.
+ */
+ toString(radix?: number, alphabet?: string): string;
+
+ /**
+ * Converts a bigInt to a string. This method is called behind the scenes in JSON.stringify.
+ */
+ toJSON(): string;
+
+ /**
+ * Converts a bigInt to a native Javascript number. This override allows you to use native
+ * arithmetic operators without explicit conversion.
+ */
+ valueOf(): number;
+
+ /**
+ * Performs the bitwise XOR operation.
+ */
+ xor(number: BigNumber): BigInteger;
+ }
+
+ // Array constant accessors
+ interface BigIntegerStatic {
+ '-999': BigInteger;
+ '-998': BigInteger;
+ '-997': BigInteger;
+ '-996': BigInteger;
+ '-995': BigInteger;
+ '-994': BigInteger;
+ '-993': BigInteger;
+ '-992': BigInteger;
+ '-991': BigInteger;
+ '-990': BigInteger;
+ '-989': BigInteger;
+ '-988': BigInteger;
+ '-987': BigInteger;
+ '-986': BigInteger;
+ '-985': BigInteger;
+ '-984': BigInteger;
+ '-983': BigInteger;
+ '-982': BigInteger;
+ '-981': BigInteger;
+ '-980': BigInteger;
+ '-979': BigInteger;
+ '-978': BigInteger;
+ '-977': BigInteger;
+ '-976': BigInteger;
+ '-975': BigInteger;
+ '-974': BigInteger;
+ '-973': BigInteger;
+ '-972': BigInteger;
+ '-971': BigInteger;
+ '-970': BigInteger;
+ '-969': BigInteger;
+ '-968': BigInteger;
+ '-967': BigInteger;
+ '-966': BigInteger;
+ '-965': BigInteger;
+ '-964': BigInteger;
+ '-963': BigInteger;
+ '-962': BigInteger;
+ '-961': BigInteger;
+ '-960': BigInteger;
+ '-959': BigInteger;
+ '-958': BigInteger;
+ '-957': BigInteger;
+ '-956': BigInteger;
+ '-955': BigInteger;
+ '-954': BigInteger;
+ '-953': BigInteger;
+ '-952': BigInteger;
+ '-951': BigInteger;
+ '-950': BigInteger;
+ '-949': BigInteger;
+ '-948': BigInteger;
+ '-947': BigInteger;
+ '-946': BigInteger;
+ '-945': BigInteger;
+ '-944': BigInteger;
+ '-943': BigInteger;
+ '-942': BigInteger;
+ '-941': BigInteger;
+ '-940': BigInteger;
+ '-939': BigInteger;
+ '-938': BigInteger;
+ '-937': BigInteger;
+ '-936': BigInteger;
+ '-935': BigInteger;
+ '-934': BigInteger;
+ '-933': BigInteger;
+ '-932': BigInteger;
+ '-931': BigInteger;
+ '-930': BigInteger;
+ '-929': BigInteger;
+ '-928': BigInteger;
+ '-927': BigInteger;
+ '-926': BigInteger;
+ '-925': BigInteger;
+ '-924': BigInteger;
+ '-923': BigInteger;
+ '-922': BigInteger;
+ '-921': BigInteger;
+ '-920': BigInteger;
+ '-919': BigInteger;
+ '-918': BigInteger;
+ '-917': BigInteger;
+ '-916': BigInteger;
+ '-915': BigInteger;
+ '-914': BigInteger;
+ '-913': BigInteger;
+ '-912': BigInteger;
+ '-911': BigInteger;
+ '-910': BigInteger;
+ '-909': BigInteger;
+ '-908': BigInteger;
+ '-907': BigInteger;
+ '-906': BigInteger;
+ '-905': BigInteger;
+ '-904': BigInteger;
+ '-903': BigInteger;
+ '-902': BigInteger;
+ '-901': BigInteger;
+ '-900': BigInteger;
+ '-899': BigInteger;
+ '-898': BigInteger;
+ '-897': BigInteger;
+ '-896': BigInteger;
+ '-895': BigInteger;
+ '-894': BigInteger;
+ '-893': BigInteger;
+ '-892': BigInteger;
+ '-891': BigInteger;
+ '-890': BigInteger;
+ '-889': BigInteger;
+ '-888': BigInteger;
+ '-887': BigInteger;
+ '-886': BigInteger;
+ '-885': BigInteger;
+ '-884': BigInteger;
+ '-883': BigInteger;
+ '-882': BigInteger;
+ '-881': BigInteger;
+ '-880': BigInteger;
+ '-879': BigInteger;
+ '-878': BigInteger;
+ '-877': BigInteger;
+ '-876': BigInteger;
+ '-875': BigInteger;
+ '-874': BigInteger;
+ '-873': BigInteger;
+ '-872': BigInteger;
+ '-871': BigInteger;
+ '-870': BigInteger;
+ '-869': BigInteger;
+ '-868': BigInteger;
+ '-867': BigInteger;
+ '-866': BigInteger;
+ '-865': BigInteger;
+ '-864': BigInteger;
+ '-863': BigInteger;
+ '-862': BigInteger;
+ '-861': BigInteger;
+ '-860': BigInteger;
+ '-859': BigInteger;
+ '-858': BigInteger;
+ '-857': BigInteger;
+ '-856': BigInteger;
+ '-855': BigInteger;
+ '-854': BigInteger;
+ '-853': BigInteger;
+ '-852': BigInteger;
+ '-851': BigInteger;
+ '-850': BigInteger;
+ '-849': BigInteger;
+ '-848': BigInteger;
+ '-847': BigInteger;
+ '-846': BigInteger;
+ '-845': BigInteger;
+ '-844': BigInteger;
+ '-843': BigInteger;
+ '-842': BigInteger;
+ '-841': BigInteger;
+ '-840': BigInteger;
+ '-839': BigInteger;
+ '-838': BigInteger;
+ '-837': BigInteger;
+ '-836': BigInteger;
+ '-835': BigInteger;
+ '-834': BigInteger;
+ '-833': BigInteger;
+ '-832': BigInteger;
+ '-831': BigInteger;
+ '-830': BigInteger;
+ '-829': BigInteger;
+ '-828': BigInteger;
+ '-827': BigInteger;
+ '-826': BigInteger;
+ '-825': BigInteger;
+ '-824': BigInteger;
+ '-823': BigInteger;
+ '-822': BigInteger;
+ '-821': BigInteger;
+ '-820': BigInteger;
+ '-819': BigInteger;
+ '-818': BigInteger;
+ '-817': BigInteger;
+ '-816': BigInteger;
+ '-815': BigInteger;
+ '-814': BigInteger;
+ '-813': BigInteger;
+ '-812': BigInteger;
+ '-811': BigInteger;
+ '-810': BigInteger;
+ '-809': BigInteger;
+ '-808': BigInteger;
+ '-807': BigInteger;
+ '-806': BigInteger;
+ '-805': BigInteger;
+ '-804': BigInteger;
+ '-803': BigInteger;
+ '-802': BigInteger;
+ '-801': BigInteger;
+ '-800': BigInteger;
+ '-799': BigInteger;
+ '-798': BigInteger;
+ '-797': BigInteger;
+ '-796': BigInteger;
+ '-795': BigInteger;
+ '-794': BigInteger;
+ '-793': BigInteger;
+ '-792': BigInteger;
+ '-791': BigInteger;
+ '-790': BigInteger;
+ '-789': BigInteger;
+ '-788': BigInteger;
+ '-787': BigInteger;
+ '-786': BigInteger;
+ '-785': BigInteger;
+ '-784': BigInteger;
+ '-783': BigInteger;
+ '-782': BigInteger;
+ '-781': BigInteger;
+ '-780': BigInteger;
+ '-779': BigInteger;
+ '-778': BigInteger;
+ '-777': BigInteger;
+ '-776': BigInteger;
+ '-775': BigInteger;
+ '-774': BigInteger;
+ '-773': BigInteger;
+ '-772': BigInteger;
+ '-771': BigInteger;
+ '-770': BigInteger;
+ '-769': BigInteger;
+ '-768': BigInteger;
+ '-767': BigInteger;
+ '-766': BigInteger;
+ '-765': BigInteger;
+ '-764': BigInteger;
+ '-763': BigInteger;
+ '-762': BigInteger;
+ '-761': BigInteger;
+ '-760': BigInteger;
+ '-759': BigInteger;
+ '-758': BigInteger;
+ '-757': BigInteger;
+ '-756': BigInteger;
+ '-755': BigInteger;
+ '-754': BigInteger;
+ '-753': BigInteger;
+ '-752': BigInteger;
+ '-751': BigInteger;
+ '-750': BigInteger;
+ '-749': BigInteger;
+ '-748': BigInteger;
+ '-747': BigInteger;
+ '-746': BigInteger;
+ '-745': BigInteger;
+ '-744': BigInteger;
+ '-743': BigInteger;
+ '-742': BigInteger;
+ '-741': BigInteger;
+ '-740': BigInteger;
+ '-739': BigInteger;
+ '-738': BigInteger;
+ '-737': BigInteger;
+ '-736': BigInteger;
+ '-735': BigInteger;
+ '-734': BigInteger;
+ '-733': BigInteger;
+ '-732': BigInteger;
+ '-731': BigInteger;
+ '-730': BigInteger;
+ '-729': BigInteger;
+ '-728': BigInteger;
+ '-727': BigInteger;
+ '-726': BigInteger;
+ '-725': BigInteger;
+ '-724': BigInteger;
+ '-723': BigInteger;
+ '-722': BigInteger;
+ '-721': BigInteger;
+ '-720': BigInteger;
+ '-719': BigInteger;
+ '-718': BigInteger;
+ '-717': BigInteger;
+ '-716': BigInteger;
+ '-715': BigInteger;
+ '-714': BigInteger;
+ '-713': BigInteger;
+ '-712': BigInteger;
+ '-711': BigInteger;
+ '-710': BigInteger;
+ '-709': BigInteger;
+ '-708': BigInteger;
+ '-707': BigInteger;
+ '-706': BigInteger;
+ '-705': BigInteger;
+ '-704': BigInteger;
+ '-703': BigInteger;
+ '-702': BigInteger;
+ '-701': BigInteger;
+ '-700': BigInteger;
+ '-699': BigInteger;
+ '-698': BigInteger;
+ '-697': BigInteger;
+ '-696': BigInteger;
+ '-695': BigInteger;
+ '-694': BigInteger;
+ '-693': BigInteger;
+ '-692': BigInteger;
+ '-691': BigInteger;
+ '-690': BigInteger;
+ '-689': BigInteger;
+ '-688': BigInteger;
+ '-687': BigInteger;
+ '-686': BigInteger;
+ '-685': BigInteger;
+ '-684': BigInteger;
+ '-683': BigInteger;
+ '-682': BigInteger;
+ '-681': BigInteger;
+ '-680': BigInteger;
+ '-679': BigInteger;
+ '-678': BigInteger;
+ '-677': BigInteger;
+ '-676': BigInteger;
+ '-675': BigInteger;
+ '-674': BigInteger;
+ '-673': BigInteger;
+ '-672': BigInteger;
+ '-671': BigInteger;
+ '-670': BigInteger;
+ '-669': BigInteger;
+ '-668': BigInteger;
+ '-667': BigInteger;
+ '-666': BigInteger;
+ '-665': BigInteger;
+ '-664': BigInteger;
+ '-663': BigInteger;
+ '-662': BigInteger;
+ '-661': BigInteger;
+ '-660': BigInteger;
+ '-659': BigInteger;
+ '-658': BigInteger;
+ '-657': BigInteger;
+ '-656': BigInteger;
+ '-655': BigInteger;
+ '-654': BigInteger;
+ '-653': BigInteger;
+ '-652': BigInteger;
+ '-651': BigInteger;
+ '-650': BigInteger;
+ '-649': BigInteger;
+ '-648': BigInteger;
+ '-647': BigInteger;
+ '-646': BigInteger;
+ '-645': BigInteger;
+ '-644': BigInteger;
+ '-643': BigInteger;
+ '-642': BigInteger;
+ '-641': BigInteger;
+ '-640': BigInteger;
+ '-639': BigInteger;
+ '-638': BigInteger;
+ '-637': BigInteger;
+ '-636': BigInteger;
+ '-635': BigInteger;
+ '-634': BigInteger;
+ '-633': BigInteger;
+ '-632': BigInteger;
+ '-631': BigInteger;
+ '-630': BigInteger;
+ '-629': BigInteger;
+ '-628': BigInteger;
+ '-627': BigInteger;
+ '-626': BigInteger;
+ '-625': BigInteger;
+ '-624': BigInteger;
+ '-623': BigInteger;
+ '-622': BigInteger;
+ '-621': BigInteger;
+ '-620': BigInteger;
+ '-619': BigInteger;
+ '-618': BigInteger;
+ '-617': BigInteger;
+ '-616': BigInteger;
+ '-615': BigInteger;
+ '-614': BigInteger;
+ '-613': BigInteger;
+ '-612': BigInteger;
+ '-611': BigInteger;
+ '-610': BigInteger;
+ '-609': BigInteger;
+ '-608': BigInteger;
+ '-607': BigInteger;
+ '-606': BigInteger;
+ '-605': BigInteger;
+ '-604': BigInteger;
+ '-603': BigInteger;
+ '-602': BigInteger;
+ '-601': BigInteger;
+ '-600': BigInteger;
+ '-599': BigInteger;
+ '-598': BigInteger;
+ '-597': BigInteger;
+ '-596': BigInteger;
+ '-595': BigInteger;
+ '-594': BigInteger;
+ '-593': BigInteger;
+ '-592': BigInteger;
+ '-591': BigInteger;
+ '-590': BigInteger;
+ '-589': BigInteger;
+ '-588': BigInteger;
+ '-587': BigInteger;
+ '-586': BigInteger;
+ '-585': BigInteger;
+ '-584': BigInteger;
+ '-583': BigInteger;
+ '-582': BigInteger;
+ '-581': BigInteger;
+ '-580': BigInteger;
+ '-579': BigInteger;
+ '-578': BigInteger;
+ '-577': BigInteger;
+ '-576': BigInteger;
+ '-575': BigInteger;
+ '-574': BigInteger;
+ '-573': BigInteger;
+ '-572': BigInteger;
+ '-571': BigInteger;
+ '-570': BigInteger;
+ '-569': BigInteger;
+ '-568': BigInteger;
+ '-567': BigInteger;
+ '-566': BigInteger;
+ '-565': BigInteger;
+ '-564': BigInteger;
+ '-563': BigInteger;
+ '-562': BigInteger;
+ '-561': BigInteger;
+ '-560': BigInteger;
+ '-559': BigInteger;
+ '-558': BigInteger;
+ '-557': BigInteger;
+ '-556': BigInteger;
+ '-555': BigInteger;
+ '-554': BigInteger;
+ '-553': BigInteger;
+ '-552': BigInteger;
+ '-551': BigInteger;
+ '-550': BigInteger;
+ '-549': BigInteger;
+ '-548': BigInteger;
+ '-547': BigInteger;
+ '-546': BigInteger;
+ '-545': BigInteger;
+ '-544': BigInteger;
+ '-543': BigInteger;
+ '-542': BigInteger;
+ '-541': BigInteger;
+ '-540': BigInteger;
+ '-539': BigInteger;
+ '-538': BigInteger;
+ '-537': BigInteger;
+ '-536': BigInteger;
+ '-535': BigInteger;
+ '-534': BigInteger;
+ '-533': BigInteger;
+ '-532': BigInteger;
+ '-531': BigInteger;
+ '-530': BigInteger;
+ '-529': BigInteger;
+ '-528': BigInteger;
+ '-527': BigInteger;
+ '-526': BigInteger;
+ '-525': BigInteger;
+ '-524': BigInteger;
+ '-523': BigInteger;
+ '-522': BigInteger;
+ '-521': BigInteger;
+ '-520': BigInteger;
+ '-519': BigInteger;
+ '-518': BigInteger;
+ '-517': BigInteger;
+ '-516': BigInteger;
+ '-515': BigInteger;
+ '-514': BigInteger;
+ '-513': BigInteger;
+ '-512': BigInteger;
+ '-511': BigInteger;
+ '-510': BigInteger;
+ '-509': BigInteger;
+ '-508': BigInteger;
+ '-507': BigInteger;
+ '-506': BigInteger;
+ '-505': BigInteger;
+ '-504': BigInteger;
+ '-503': BigInteger;
+ '-502': BigInteger;
+ '-501': BigInteger;
+ '-500': BigInteger;
+ '-499': BigInteger;
+ '-498': BigInteger;
+ '-497': BigInteger;
+ '-496': BigInteger;
+ '-495': BigInteger;
+ '-494': BigInteger;
+ '-493': BigInteger;
+ '-492': BigInteger;
+ '-491': BigInteger;
+ '-490': BigInteger;
+ '-489': BigInteger;
+ '-488': BigInteger;
+ '-487': BigInteger;
+ '-486': BigInteger;
+ '-485': BigInteger;
+ '-484': BigInteger;
+ '-483': BigInteger;
+ '-482': BigInteger;
+ '-481': BigInteger;
+ '-480': BigInteger;
+ '-479': BigInteger;
+ '-478': BigInteger;
+ '-477': BigInteger;
+ '-476': BigInteger;
+ '-475': BigInteger;
+ '-474': BigInteger;
+ '-473': BigInteger;
+ '-472': BigInteger;
+ '-471': BigInteger;
+ '-470': BigInteger;
+ '-469': BigInteger;
+ '-468': BigInteger;
+ '-467': BigInteger;
+ '-466': BigInteger;
+ '-465': BigInteger;
+ '-464': BigInteger;
+ '-463': BigInteger;
+ '-462': BigInteger;
+ '-461': BigInteger;
+ '-460': BigInteger;
+ '-459': BigInteger;
+ '-458': BigInteger;
+ '-457': BigInteger;
+ '-456': BigInteger;
+ '-455': BigInteger;
+ '-454': BigInteger;
+ '-453': BigInteger;
+ '-452': BigInteger;
+ '-451': BigInteger;
+ '-450': BigInteger;
+ '-449': BigInteger;
+ '-448': BigInteger;
+ '-447': BigInteger;
+ '-446': BigInteger;
+ '-445': BigInteger;
+ '-444': BigInteger;
+ '-443': BigInteger;
+ '-442': BigInteger;
+ '-441': BigInteger;
+ '-440': BigInteger;
+ '-439': BigInteger;
+ '-438': BigInteger;
+ '-437': BigInteger;
+ '-436': BigInteger;
+ '-435': BigInteger;
+ '-434': BigInteger;
+ '-433': BigInteger;
+ '-432': BigInteger;
+ '-431': BigInteger;
+ '-430': BigInteger;
+ '-429': BigInteger;
+ '-428': BigInteger;
+ '-427': BigInteger;
+ '-426': BigInteger;
+ '-425': BigInteger;
+ '-424': BigInteger;
+ '-423': BigInteger;
+ '-422': BigInteger;
+ '-421': BigInteger;
+ '-420': BigInteger;
+ '-419': BigInteger;
+ '-418': BigInteger;
+ '-417': BigInteger;
+ '-416': BigInteger;
+ '-415': BigInteger;
+ '-414': BigInteger;
+ '-413': BigInteger;
+ '-412': BigInteger;
+ '-411': BigInteger;
+ '-410': BigInteger;
+ '-409': BigInteger;
+ '-408': BigInteger;
+ '-407': BigInteger;
+ '-406': BigInteger;
+ '-405': BigInteger;
+ '-404': BigInteger;
+ '-403': BigInteger;
+ '-402': BigInteger;
+ '-401': BigInteger;
+ '-400': BigInteger;
+ '-399': BigInteger;
+ '-398': BigInteger;
+ '-397': BigInteger;
+ '-396': BigInteger;
+ '-395': BigInteger;
+ '-394': BigInteger;
+ '-393': BigInteger;
+ '-392': BigInteger;
+ '-391': BigInteger;
+ '-390': BigInteger;
+ '-389': BigInteger;
+ '-388': BigInteger;
+ '-387': BigInteger;
+ '-386': BigInteger;
+ '-385': BigInteger;
+ '-384': BigInteger;
+ '-383': BigInteger;
+ '-382': BigInteger;
+ '-381': BigInteger;
+ '-380': BigInteger;
+ '-379': BigInteger;
+ '-378': BigInteger;
+ '-377': BigInteger;
+ '-376': BigInteger;
+ '-375': BigInteger;
+ '-374': BigInteger;
+ '-373': BigInteger;
+ '-372': BigInteger;
+ '-371': BigInteger;
+ '-370': BigInteger;
+ '-369': BigInteger;
+ '-368': BigInteger;
+ '-367': BigInteger;
+ '-366': BigInteger;
+ '-365': BigInteger;
+ '-364': BigInteger;
+ '-363': BigInteger;
+ '-362': BigInteger;
+ '-361': BigInteger;
+ '-360': BigInteger;
+ '-359': BigInteger;
+ '-358': BigInteger;
+ '-357': BigInteger;
+ '-356': BigInteger;
+ '-355': BigInteger;
+ '-354': BigInteger;
+ '-353': BigInteger;
+ '-352': BigInteger;
+ '-351': BigInteger;
+ '-350': BigInteger;
+ '-349': BigInteger;
+ '-348': BigInteger;
+ '-347': BigInteger;
+ '-346': BigInteger;
+ '-345': BigInteger;
+ '-344': BigInteger;
+ '-343': BigInteger;
+ '-342': BigInteger;
+ '-341': BigInteger;
+ '-340': BigInteger;
+ '-339': BigInteger;
+ '-338': BigInteger;
+ '-337': BigInteger;
+ '-336': BigInteger;
+ '-335': BigInteger;
+ '-334': BigInteger;
+ '-333': BigInteger;
+ '-332': BigInteger;
+ '-331': BigInteger;
+ '-330': BigInteger;
+ '-329': BigInteger;
+ '-328': BigInteger;
+ '-327': BigInteger;
+ '-326': BigInteger;
+ '-325': BigInteger;
+ '-324': BigInteger;
+ '-323': BigInteger;
+ '-322': BigInteger;
+ '-321': BigInteger;
+ '-320': BigInteger;
+ '-319': BigInteger;
+ '-318': BigInteger;
+ '-317': BigInteger;
+ '-316': BigInteger;
+ '-315': BigInteger;
+ '-314': BigInteger;
+ '-313': BigInteger;
+ '-312': BigInteger;
+ '-311': BigInteger;
+ '-310': BigInteger;
+ '-309': BigInteger;
+ '-308': BigInteger;
+ '-307': BigInteger;
+ '-306': BigInteger;
+ '-305': BigInteger;
+ '-304': BigInteger;
+ '-303': BigInteger;
+ '-302': BigInteger;
+ '-301': BigInteger;
+ '-300': BigInteger;
+ '-299': BigInteger;
+ '-298': BigInteger;
+ '-297': BigInteger;
+ '-296': BigInteger;
+ '-295': BigInteger;
+ '-294': BigInteger;
+ '-293': BigInteger;
+ '-292': BigInteger;
+ '-291': BigInteger;
+ '-290': BigInteger;
+ '-289': BigInteger;
+ '-288': BigInteger;
+ '-287': BigInteger;
+ '-286': BigInteger;
+ '-285': BigInteger;
+ '-284': BigInteger;
+ '-283': BigInteger;
+ '-282': BigInteger;
+ '-281': BigInteger;
+ '-280': BigInteger;
+ '-279': BigInteger;
+ '-278': BigInteger;
+ '-277': BigInteger;
+ '-276': BigInteger;
+ '-275': BigInteger;
+ '-274': BigInteger;
+ '-273': BigInteger;
+ '-272': BigInteger;
+ '-271': BigInteger;
+ '-270': BigInteger;
+ '-269': BigInteger;
+ '-268': BigInteger;
+ '-267': BigInteger;
+ '-266': BigInteger;
+ '-265': BigInteger;
+ '-264': BigInteger;
+ '-263': BigInteger;
+ '-262': BigInteger;
+ '-261': BigInteger;
+ '-260': BigInteger;
+ '-259': BigInteger;
+ '-258': BigInteger;
+ '-257': BigInteger;
+ '-256': BigInteger;
+ '-255': BigInteger;
+ '-254': BigInteger;
+ '-253': BigInteger;
+ '-252': BigInteger;
+ '-251': BigInteger;
+ '-250': BigInteger;
+ '-249': BigInteger;
+ '-248': BigInteger;
+ '-247': BigInteger;
+ '-246': BigInteger;
+ '-245': BigInteger;
+ '-244': BigInteger;
+ '-243': BigInteger;
+ '-242': BigInteger;
+ '-241': BigInteger;
+ '-240': BigInteger;
+ '-239': BigInteger;
+ '-238': BigInteger;
+ '-237': BigInteger;
+ '-236': BigInteger;
+ '-235': BigInteger;
+ '-234': BigInteger;
+ '-233': BigInteger;
+ '-232': BigInteger;
+ '-231': BigInteger;
+ '-230': BigInteger;
+ '-229': BigInteger;
+ '-228': BigInteger;
+ '-227': BigInteger;
+ '-226': BigInteger;
+ '-225': BigInteger;
+ '-224': BigInteger;
+ '-223': BigInteger;
+ '-222': BigInteger;
+ '-221': BigInteger;
+ '-220': BigInteger;
+ '-219': BigInteger;
+ '-218': BigInteger;
+ '-217': BigInteger;
+ '-216': BigInteger;
+ '-215': BigInteger;
+ '-214': BigInteger;
+ '-213': BigInteger;
+ '-212': BigInteger;
+ '-211': BigInteger;
+ '-210': BigInteger;
+ '-209': BigInteger;
+ '-208': BigInteger;
+ '-207': BigInteger;
+ '-206': BigInteger;
+ '-205': BigInteger;
+ '-204': BigInteger;
+ '-203': BigInteger;
+ '-202': BigInteger;
+ '-201': BigInteger;
+ '-200': BigInteger;
+ '-199': BigInteger;
+ '-198': BigInteger;
+ '-197': BigInteger;
+ '-196': BigInteger;
+ '-195': BigInteger;
+ '-194': BigInteger;
+ '-193': BigInteger;
+ '-192': BigInteger;
+ '-191': BigInteger;
+ '-190': BigInteger;
+ '-189': BigInteger;
+ '-188': BigInteger;
+ '-187': BigInteger;
+ '-186': BigInteger;
+ '-185': BigInteger;
+ '-184': BigInteger;
+ '-183': BigInteger;
+ '-182': BigInteger;
+ '-181': BigInteger;
+ '-180': BigInteger;
+ '-179': BigInteger;
+ '-178': BigInteger;
+ '-177': BigInteger;
+ '-176': BigInteger;
+ '-175': BigInteger;
+ '-174': BigInteger;
+ '-173': BigInteger;
+ '-172': BigInteger;
+ '-171': BigInteger;
+ '-170': BigInteger;
+ '-169': BigInteger;
+ '-168': BigInteger;
+ '-167': BigInteger;
+ '-166': BigInteger;
+ '-165': BigInteger;
+ '-164': BigInteger;
+ '-163': BigInteger;
+ '-162': BigInteger;
+ '-161': BigInteger;
+ '-160': BigInteger;
+ '-159': BigInteger;
+ '-158': BigInteger;
+ '-157': BigInteger;
+ '-156': BigInteger;
+ '-155': BigInteger;
+ '-154': BigInteger;
+ '-153': BigInteger;
+ '-152': BigInteger;
+ '-151': BigInteger;
+ '-150': BigInteger;
+ '-149': BigInteger;
+ '-148': BigInteger;
+ '-147': BigInteger;
+ '-146': BigInteger;
+ '-145': BigInteger;
+ '-144': BigInteger;
+ '-143': BigInteger;
+ '-142': BigInteger;
+ '-141': BigInteger;
+ '-140': BigInteger;
+ '-139': BigInteger;
+ '-138': BigInteger;
+ '-137': BigInteger;
+ '-136': BigInteger;
+ '-135': BigInteger;
+ '-134': BigInteger;
+ '-133': BigInteger;
+ '-132': BigInteger;
+ '-131': BigInteger;
+ '-130': BigInteger;
+ '-129': BigInteger;
+ '-128': BigInteger;
+ '-127': BigInteger;
+ '-126': BigInteger;
+ '-125': BigInteger;
+ '-124': BigInteger;
+ '-123': BigInteger;
+ '-122': BigInteger;
+ '-121': BigInteger;
+ '-120': BigInteger;
+ '-119': BigInteger;
+ '-118': BigInteger;
+ '-117': BigInteger;
+ '-116': BigInteger;
+ '-115': BigInteger;
+ '-114': BigInteger;
+ '-113': BigInteger;
+ '-112': BigInteger;
+ '-111': BigInteger;
+ '-110': BigInteger;
+ '-109': BigInteger;
+ '-108': BigInteger;
+ '-107': BigInteger;
+ '-106': BigInteger;
+ '-105': BigInteger;
+ '-104': BigInteger;
+ '-103': BigInteger;
+ '-102': BigInteger;
+ '-101': BigInteger;
+ '-100': BigInteger;
+ '-99': BigInteger;
+ '-98': BigInteger;
+ '-97': BigInteger;
+ '-96': BigInteger;
+ '-95': BigInteger;
+ '-94': BigInteger;
+ '-93': BigInteger;
+ '-92': BigInteger;
+ '-91': BigInteger;
+ '-90': BigInteger;
+ '-89': BigInteger;
+ '-88': BigInteger;
+ '-87': BigInteger;
+ '-86': BigInteger;
+ '-85': BigInteger;
+ '-84': BigInteger;
+ '-83': BigInteger;
+ '-82': BigInteger;
+ '-81': BigInteger;
+ '-80': BigInteger;
+ '-79': BigInteger;
+ '-78': BigInteger;
+ '-77': BigInteger;
+ '-76': BigInteger;
+ '-75': BigInteger;
+ '-74': BigInteger;
+ '-73': BigInteger;
+ '-72': BigInteger;
+ '-71': BigInteger;
+ '-70': BigInteger;
+ '-69': BigInteger;
+ '-68': BigInteger;
+ '-67': BigInteger;
+ '-66': BigInteger;
+ '-65': BigInteger;
+ '-64': BigInteger;
+ '-63': BigInteger;
+ '-62': BigInteger;
+ '-61': BigInteger;
+ '-60': BigInteger;
+ '-59': BigInteger;
+ '-58': BigInteger;
+ '-57': BigInteger;
+ '-56': BigInteger;
+ '-55': BigInteger;
+ '-54': BigInteger;
+ '-53': BigInteger;
+ '-52': BigInteger;
+ '-51': BigInteger;
+ '-50': BigInteger;
+ '-49': BigInteger;
+ '-48': BigInteger;
+ '-47': BigInteger;
+ '-46': BigInteger;
+ '-45': BigInteger;
+ '-44': BigInteger;
+ '-43': BigInteger;
+ '-42': BigInteger;
+ '-41': BigInteger;
+ '-40': BigInteger;
+ '-39': BigInteger;
+ '-38': BigInteger;
+ '-37': BigInteger;
+ '-36': BigInteger;
+ '-35': BigInteger;
+ '-34': BigInteger;
+ '-33': BigInteger;
+ '-32': BigInteger;
+ '-31': BigInteger;
+ '-30': BigInteger;
+ '-29': BigInteger;
+ '-28': BigInteger;
+ '-27': BigInteger;
+ '-26': BigInteger;
+ '-25': BigInteger;
+ '-24': BigInteger;
+ '-23': BigInteger;
+ '-22': BigInteger;
+ '-21': BigInteger;
+ '-20': BigInteger;
+ '-19': BigInteger;
+ '-18': BigInteger;
+ '-17': BigInteger;
+ '-16': BigInteger;
+ '-15': BigInteger;
+ '-14': BigInteger;
+ '-13': BigInteger;
+ '-12': BigInteger;
+ '-11': BigInteger;
+ '-10': BigInteger;
+ '-9': BigInteger;
+ '-8': BigInteger;
+ '-7': BigInteger;
+ '-6': BigInteger;
+ '-5': BigInteger;
+ '-4': BigInteger;
+ '-3': BigInteger;
+ '-2': BigInteger;
+ '-1': BigInteger;
+ '0': BigInteger;
+ '1': BigInteger;
+ '2': BigInteger;
+ '3': BigInteger;
+ '4': BigInteger;
+ '5': BigInteger;
+ '6': BigInteger;
+ '7': BigInteger;
+ '8': BigInteger;
+ '9': BigInteger;
+ '10': BigInteger;
+ '11': BigInteger;
+ '12': BigInteger;
+ '13': BigInteger;
+ '14': BigInteger;
+ '15': BigInteger;
+ '16': BigInteger;
+ '17': BigInteger;
+ '18': BigInteger;
+ '19': BigInteger;
+ '20': BigInteger;
+ '21': BigInteger;
+ '22': BigInteger;
+ '23': BigInteger;
+ '24': BigInteger;
+ '25': BigInteger;
+ '26': BigInteger;
+ '27': BigInteger;
+ '28': BigInteger;
+ '29': BigInteger;
+ '30': BigInteger;
+ '31': BigInteger;
+ '32': BigInteger;
+ '33': BigInteger;
+ '34': BigInteger;
+ '35': BigInteger;
+ '36': BigInteger;
+ '37': BigInteger;
+ '38': BigInteger;
+ '39': BigInteger;
+ '40': BigInteger;
+ '41': BigInteger;
+ '42': BigInteger;
+ '43': BigInteger;
+ '44': BigInteger;
+ '45': BigInteger;
+ '46': BigInteger;
+ '47': BigInteger;
+ '48': BigInteger;
+ '49': BigInteger;
+ '50': BigInteger;
+ '51': BigInteger;
+ '52': BigInteger;
+ '53': BigInteger;
+ '54': BigInteger;
+ '55': BigInteger;
+ '56': BigInteger;
+ '57': BigInteger;
+ '58': BigInteger;
+ '59': BigInteger;
+ '60': BigInteger;
+ '61': BigInteger;
+ '62': BigInteger;
+ '63': BigInteger;
+ '64': BigInteger;
+ '65': BigInteger;
+ '66': BigInteger;
+ '67': BigInteger;
+ '68': BigInteger;
+ '69': BigInteger;
+ '70': BigInteger;
+ '71': BigInteger;
+ '72': BigInteger;
+ '73': BigInteger;
+ '74': BigInteger;
+ '75': BigInteger;
+ '76': BigInteger;
+ '77': BigInteger;
+ '78': BigInteger;
+ '79': BigInteger;
+ '80': BigInteger;
+ '81': BigInteger;
+ '82': BigInteger;
+ '83': BigInteger;
+ '84': BigInteger;
+ '85': BigInteger;
+ '86': BigInteger;
+ '87': BigInteger;
+ '88': BigInteger;
+ '89': BigInteger;
+ '90': BigInteger;
+ '91': BigInteger;
+ '92': BigInteger;
+ '93': BigInteger;
+ '94': BigInteger;
+ '95': BigInteger;
+ '96': BigInteger;
+ '97': BigInteger;
+ '98': BigInteger;
+ '99': BigInteger;
+ '100': BigInteger;
+ '101': BigInteger;
+ '102': BigInteger;
+ '103': BigInteger;
+ '104': BigInteger;
+ '105': BigInteger;
+ '106': BigInteger;
+ '107': BigInteger;
+ '108': BigInteger;
+ '109': BigInteger;
+ '110': BigInteger;
+ '111': BigInteger;
+ '112': BigInteger;
+ '113': BigInteger;
+ '114': BigInteger;
+ '115': BigInteger;
+ '116': BigInteger;
+ '117': BigInteger;
+ '118': BigInteger;
+ '119': BigInteger;
+ '120': BigInteger;
+ '121': BigInteger;
+ '122': BigInteger;
+ '123': BigInteger;
+ '124': BigInteger;
+ '125': BigInteger;
+ '126': BigInteger;
+ '127': BigInteger;
+ '128': BigInteger;
+ '129': BigInteger;
+ '130': BigInteger;
+ '131': BigInteger;
+ '132': BigInteger;
+ '133': BigInteger;
+ '134': BigInteger;
+ '135': BigInteger;
+ '136': BigInteger;
+ '137': BigInteger;
+ '138': BigInteger;
+ '139': BigInteger;
+ '140': BigInteger;
+ '141': BigInteger;
+ '142': BigInteger;
+ '143': BigInteger;
+ '144': BigInteger;
+ '145': BigInteger;
+ '146': BigInteger;
+ '147': BigInteger;
+ '148': BigInteger;
+ '149': BigInteger;
+ '150': BigInteger;
+ '151': BigInteger;
+ '152': BigInteger;
+ '153': BigInteger;
+ '154': BigInteger;
+ '155': BigInteger;
+ '156': BigInteger;
+ '157': BigInteger;
+ '158': BigInteger;
+ '159': BigInteger;
+ '160': BigInteger;
+ '161': BigInteger;
+ '162': BigInteger;
+ '163': BigInteger;
+ '164': BigInteger;
+ '165': BigInteger;
+ '166': BigInteger;
+ '167': BigInteger;
+ '168': BigInteger;
+ '169': BigInteger;
+ '170': BigInteger;
+ '171': BigInteger;
+ '172': BigInteger;
+ '173': BigInteger;
+ '174': BigInteger;
+ '175': BigInteger;
+ '176': BigInteger;
+ '177': BigInteger;
+ '178': BigInteger;
+ '179': BigInteger;
+ '180': BigInteger;
+ '181': BigInteger;
+ '182': BigInteger;
+ '183': BigInteger;
+ '184': BigInteger;
+ '185': BigInteger;
+ '186': BigInteger;
+ '187': BigInteger;
+ '188': BigInteger;
+ '189': BigInteger;
+ '190': BigInteger;
+ '191': BigInteger;
+ '192': BigInteger;
+ '193': BigInteger;
+ '194': BigInteger;
+ '195': BigInteger;
+ '196': BigInteger;
+ '197': BigInteger;
+ '198': BigInteger;
+ '199': BigInteger;
+ '200': BigInteger;
+ '201': BigInteger;
+ '202': BigInteger;
+ '203': BigInteger;
+ '204': BigInteger;
+ '205': BigInteger;
+ '206': BigInteger;
+ '207': BigInteger;
+ '208': BigInteger;
+ '209': BigInteger;
+ '210': BigInteger;
+ '211': BigInteger;
+ '212': BigInteger;
+ '213': BigInteger;
+ '214': BigInteger;
+ '215': BigInteger;
+ '216': BigInteger;
+ '217': BigInteger;
+ '218': BigInteger;
+ '219': BigInteger;
+ '220': BigInteger;
+ '221': BigInteger;
+ '222': BigInteger;
+ '223': BigInteger;
+ '224': BigInteger;
+ '225': BigInteger;
+ '226': BigInteger;
+ '227': BigInteger;
+ '228': BigInteger;
+ '229': BigInteger;
+ '230': BigInteger;
+ '231': BigInteger;
+ '232': BigInteger;
+ '233': BigInteger;
+ '234': BigInteger;
+ '235': BigInteger;
+ '236': BigInteger;
+ '237': BigInteger;
+ '238': BigInteger;
+ '239': BigInteger;
+ '240': BigInteger;
+ '241': BigInteger;
+ '242': BigInteger;
+ '243': BigInteger;
+ '244': BigInteger;
+ '245': BigInteger;
+ '246': BigInteger;
+ '247': BigInteger;
+ '248': BigInteger;
+ '249': BigInteger;
+ '250': BigInteger;
+ '251': BigInteger;
+ '252': BigInteger;
+ '253': BigInteger;
+ '254': BigInteger;
+ '255': BigInteger;
+ '256': BigInteger;
+ '257': BigInteger;
+ '258': BigInteger;
+ '259': BigInteger;
+ '260': BigInteger;
+ '261': BigInteger;
+ '262': BigInteger;
+ '263': BigInteger;
+ '264': BigInteger;
+ '265': BigInteger;
+ '266': BigInteger;
+ '267': BigInteger;
+ '268': BigInteger;
+ '269': BigInteger;
+ '270': BigInteger;
+ '271': BigInteger;
+ '272': BigInteger;
+ '273': BigInteger;
+ '274': BigInteger;
+ '275': BigInteger;
+ '276': BigInteger;
+ '277': BigInteger;
+ '278': BigInteger;
+ '279': BigInteger;
+ '280': BigInteger;
+ '281': BigInteger;
+ '282': BigInteger;
+ '283': BigInteger;
+ '284': BigInteger;
+ '285': BigInteger;
+ '286': BigInteger;
+ '287': BigInteger;
+ '288': BigInteger;
+ '289': BigInteger;
+ '290': BigInteger;
+ '291': BigInteger;
+ '292': BigInteger;
+ '293': BigInteger;
+ '294': BigInteger;
+ '295': BigInteger;
+ '296': BigInteger;
+ '297': BigInteger;
+ '298': BigInteger;
+ '299': BigInteger;
+ '300': BigInteger;
+ '301': BigInteger;
+ '302': BigInteger;
+ '303': BigInteger;
+ '304': BigInteger;
+ '305': BigInteger;
+ '306': BigInteger;
+ '307': BigInteger;
+ '308': BigInteger;
+ '309': BigInteger;
+ '310': BigInteger;
+ '311': BigInteger;
+ '312': BigInteger;
+ '313': BigInteger;
+ '314': BigInteger;
+ '315': BigInteger;
+ '316': BigInteger;
+ '317': BigInteger;
+ '318': BigInteger;
+ '319': BigInteger;
+ '320': BigInteger;
+ '321': BigInteger;
+ '322': BigInteger;
+ '323': BigInteger;
+ '324': BigInteger;
+ '325': BigInteger;
+ '326': BigInteger;
+ '327': BigInteger;
+ '328': BigInteger;
+ '329': BigInteger;
+ '330': BigInteger;
+ '331': BigInteger;
+ '332': BigInteger;
+ '333': BigInteger;
+ '334': BigInteger;
+ '335': BigInteger;
+ '336': BigInteger;
+ '337': BigInteger;
+ '338': BigInteger;
+ '339': BigInteger;
+ '340': BigInteger;
+ '341': BigInteger;
+ '342': BigInteger;
+ '343': BigInteger;
+ '344': BigInteger;
+ '345': BigInteger;
+ '346': BigInteger;
+ '347': BigInteger;
+ '348': BigInteger;
+ '349': BigInteger;
+ '350': BigInteger;
+ '351': BigInteger;
+ '352': BigInteger;
+ '353': BigInteger;
+ '354': BigInteger;
+ '355': BigInteger;
+ '356': BigInteger;
+ '357': BigInteger;
+ '358': BigInteger;
+ '359': BigInteger;
+ '360': BigInteger;
+ '361': BigInteger;
+ '362': BigInteger;
+ '363': BigInteger;
+ '364': BigInteger;
+ '365': BigInteger;
+ '366': BigInteger;
+ '367': BigInteger;
+ '368': BigInteger;
+ '369': BigInteger;
+ '370': BigInteger;
+ '371': BigInteger;
+ '372': BigInteger;
+ '373': BigInteger;
+ '374': BigInteger;
+ '375': BigInteger;
+ '376': BigInteger;
+ '377': BigInteger;
+ '378': BigInteger;
+ '379': BigInteger;
+ '380': BigInteger;
+ '381': BigInteger;
+ '382': BigInteger;
+ '383': BigInteger;
+ '384': BigInteger;
+ '385': BigInteger;
+ '386': BigInteger;
+ '387': BigInteger;
+ '388': BigInteger;
+ '389': BigInteger;
+ '390': BigInteger;
+ '391': BigInteger;
+ '392': BigInteger;
+ '393': BigInteger;
+ '394': BigInteger;
+ '395': BigInteger;
+ '396': BigInteger;
+ '397': BigInteger;
+ '398': BigInteger;
+ '399': BigInteger;
+ '400': BigInteger;
+ '401': BigInteger;
+ '402': BigInteger;
+ '403': BigInteger;
+ '404': BigInteger;
+ '405': BigInteger;
+ '406': BigInteger;
+ '407': BigInteger;
+ '408': BigInteger;
+ '409': BigInteger;
+ '410': BigInteger;
+ '411': BigInteger;
+ '412': BigInteger;
+ '413': BigInteger;
+ '414': BigInteger;
+ '415': BigInteger;
+ '416': BigInteger;
+ '417': BigInteger;
+ '418': BigInteger;
+ '419': BigInteger;
+ '420': BigInteger;
+ '421': BigInteger;
+ '422': BigInteger;
+ '423': BigInteger;
+ '424': BigInteger;
+ '425': BigInteger;
+ '426': BigInteger;
+ '427': BigInteger;
+ '428': BigInteger;
+ '429': BigInteger;
+ '430': BigInteger;
+ '431': BigInteger;
+ '432': BigInteger;
+ '433': BigInteger;
+ '434': BigInteger;
+ '435': BigInteger;
+ '436': BigInteger;
+ '437': BigInteger;
+ '438': BigInteger;
+ '439': BigInteger;
+ '440': BigInteger;
+ '441': BigInteger;
+ '442': BigInteger;
+ '443': BigInteger;
+ '444': BigInteger;
+ '445': BigInteger;
+ '446': BigInteger;
+ '447': BigInteger;
+ '448': BigInteger;
+ '449': BigInteger;
+ '450': BigInteger;
+ '451': BigInteger;
+ '452': BigInteger;
+ '453': BigInteger;
+ '454': BigInteger;
+ '455': BigInteger;
+ '456': BigInteger;
+ '457': BigInteger;
+ '458': BigInteger;
+ '459': BigInteger;
+ '460': BigInteger;
+ '461': BigInteger;
+ '462': BigInteger;
+ '463': BigInteger;
+ '464': BigInteger;
+ '465': BigInteger;
+ '466': BigInteger;
+ '467': BigInteger;
+ '468': BigInteger;
+ '469': BigInteger;
+ '470': BigInteger;
+ '471': BigInteger;
+ '472': BigInteger;
+ '473': BigInteger;
+ '474': BigInteger;
+ '475': BigInteger;
+ '476': BigInteger;
+ '477': BigInteger;
+ '478': BigInteger;
+ '479': BigInteger;
+ '480': BigInteger;
+ '481': BigInteger;
+ '482': BigInteger;
+ '483': BigInteger;
+ '484': BigInteger;
+ '485': BigInteger;
+ '486': BigInteger;
+ '487': BigInteger;
+ '488': BigInteger;
+ '489': BigInteger;
+ '490': BigInteger;
+ '491': BigInteger;
+ '492': BigInteger;
+ '493': BigInteger;
+ '494': BigInteger;
+ '495': BigInteger;
+ '496': BigInteger;
+ '497': BigInteger;
+ '498': BigInteger;
+ '499': BigInteger;
+ '500': BigInteger;
+ '501': BigInteger;
+ '502': BigInteger;
+ '503': BigInteger;
+ '504': BigInteger;
+ '505': BigInteger;
+ '506': BigInteger;
+ '507': BigInteger;
+ '508': BigInteger;
+ '509': BigInteger;
+ '510': BigInteger;
+ '511': BigInteger;
+ '512': BigInteger;
+ '513': BigInteger;
+ '514': BigInteger;
+ '515': BigInteger;
+ '516': BigInteger;
+ '517': BigInteger;
+ '518': BigInteger;
+ '519': BigInteger;
+ '520': BigInteger;
+ '521': BigInteger;
+ '522': BigInteger;
+ '523': BigInteger;
+ '524': BigInteger;
+ '525': BigInteger;
+ '526': BigInteger;
+ '527': BigInteger;
+ '528': BigInteger;
+ '529': BigInteger;
+ '530': BigInteger;
+ '531': BigInteger;
+ '532': BigInteger;
+ '533': BigInteger;
+ '534': BigInteger;
+ '535': BigInteger;
+ '536': BigInteger;
+ '537': BigInteger;
+ '538': BigInteger;
+ '539': BigInteger;
+ '540': BigInteger;
+ '541': BigInteger;
+ '542': BigInteger;
+ '543': BigInteger;
+ '544': BigInteger;
+ '545': BigInteger;
+ '546': BigInteger;
+ '547': BigInteger;
+ '548': BigInteger;
+ '549': BigInteger;
+ '550': BigInteger;
+ '551': BigInteger;
+ '552': BigInteger;
+ '553': BigInteger;
+ '554': BigInteger;
+ '555': BigInteger;
+ '556': BigInteger;
+ '557': BigInteger;
+ '558': BigInteger;
+ '559': BigInteger;
+ '560': BigInteger;
+ '561': BigInteger;
+ '562': BigInteger;
+ '563': BigInteger;
+ '564': BigInteger;
+ '565': BigInteger;
+ '566': BigInteger;
+ '567': BigInteger;
+ '568': BigInteger;
+ '569': BigInteger;
+ '570': BigInteger;
+ '571': BigInteger;
+ '572': BigInteger;
+ '573': BigInteger;
+ '574': BigInteger;
+ '575': BigInteger;
+ '576': BigInteger;
+ '577': BigInteger;
+ '578': BigInteger;
+ '579': BigInteger;
+ '580': BigInteger;
+ '581': BigInteger;
+ '582': BigInteger;
+ '583': BigInteger;
+ '584': BigInteger;
+ '585': BigInteger;
+ '586': BigInteger;
+ '587': BigInteger;
+ '588': BigInteger;
+ '589': BigInteger;
+ '590': BigInteger;
+ '591': BigInteger;
+ '592': BigInteger;
+ '593': BigInteger;
+ '594': BigInteger;
+ '595': BigInteger;
+ '596': BigInteger;
+ '597': BigInteger;
+ '598': BigInteger;
+ '599': BigInteger;
+ '600': BigInteger;
+ '601': BigInteger;
+ '602': BigInteger;
+ '603': BigInteger;
+ '604': BigInteger;
+ '605': BigInteger;
+ '606': BigInteger;
+ '607': BigInteger;
+ '608': BigInteger;
+ '609': BigInteger;
+ '610': BigInteger;
+ '611': BigInteger;
+ '612': BigInteger;
+ '613': BigInteger;
+ '614': BigInteger;
+ '615': BigInteger;
+ '616': BigInteger;
+ '617': BigInteger;
+ '618': BigInteger;
+ '619': BigInteger;
+ '620': BigInteger;
+ '621': BigInteger;
+ '622': BigInteger;
+ '623': BigInteger;
+ '624': BigInteger;
+ '625': BigInteger;
+ '626': BigInteger;
+ '627': BigInteger;
+ '628': BigInteger;
+ '629': BigInteger;
+ '630': BigInteger;
+ '631': BigInteger;
+ '632': BigInteger;
+ '633': BigInteger;
+ '634': BigInteger;
+ '635': BigInteger;
+ '636': BigInteger;
+ '637': BigInteger;
+ '638': BigInteger;
+ '639': BigInteger;
+ '640': BigInteger;
+ '641': BigInteger;
+ '642': BigInteger;
+ '643': BigInteger;
+ '644': BigInteger;
+ '645': BigInteger;
+ '646': BigInteger;
+ '647': BigInteger;
+ '648': BigInteger;
+ '649': BigInteger;
+ '650': BigInteger;
+ '651': BigInteger;
+ '652': BigInteger;
+ '653': BigInteger;
+ '654': BigInteger;
+ '655': BigInteger;
+ '656': BigInteger;
+ '657': BigInteger;
+ '658': BigInteger;
+ '659': BigInteger;
+ '660': BigInteger;
+ '661': BigInteger;
+ '662': BigInteger;
+ '663': BigInteger;
+ '664': BigInteger;
+ '665': BigInteger;
+ '666': BigInteger;
+ '667': BigInteger;
+ '668': BigInteger;
+ '669': BigInteger;
+ '670': BigInteger;
+ '671': BigInteger;
+ '672': BigInteger;
+ '673': BigInteger;
+ '674': BigInteger;
+ '675': BigInteger;
+ '676': BigInteger;
+ '677': BigInteger;
+ '678': BigInteger;
+ '679': BigInteger;
+ '680': BigInteger;
+ '681': BigInteger;
+ '682': BigInteger;
+ '683': BigInteger;
+ '684': BigInteger;
+ '685': BigInteger;
+ '686': BigInteger;
+ '687': BigInteger;
+ '688': BigInteger;
+ '689': BigInteger;
+ '690': BigInteger;
+ '691': BigInteger;
+ '692': BigInteger;
+ '693': BigInteger;
+ '694': BigInteger;
+ '695': BigInteger;
+ '696': BigInteger;
+ '697': BigInteger;
+ '698': BigInteger;
+ '699': BigInteger;
+ '700': BigInteger;
+ '701': BigInteger;
+ '702': BigInteger;
+ '703': BigInteger;
+ '704': BigInteger;
+ '705': BigInteger;
+ '706': BigInteger;
+ '707': BigInteger;
+ '708': BigInteger;
+ '709': BigInteger;
+ '710': BigInteger;
+ '711': BigInteger;
+ '712': BigInteger;
+ '713': BigInteger;
+ '714': BigInteger;
+ '715': BigInteger;
+ '716': BigInteger;
+ '717': BigInteger;
+ '718': BigInteger;
+ '719': BigInteger;
+ '720': BigInteger;
+ '721': BigInteger;
+ '722': BigInteger;
+ '723': BigInteger;
+ '724': BigInteger;
+ '725': BigInteger;
+ '726': BigInteger;
+ '727': BigInteger;
+ '728': BigInteger;
+ '729': BigInteger;
+ '730': BigInteger;
+ '731': BigInteger;
+ '732': BigInteger;
+ '733': BigInteger;
+ '734': BigInteger;
+ '735': BigInteger;
+ '736': BigInteger;
+ '737': BigInteger;
+ '738': BigInteger;
+ '739': BigInteger;
+ '740': BigInteger;
+ '741': BigInteger;
+ '742': BigInteger;
+ '743': BigInteger;
+ '744': BigInteger;
+ '745': BigInteger;
+ '746': BigInteger;
+ '747': BigInteger;
+ '748': BigInteger;
+ '749': BigInteger;
+ '750': BigInteger;
+ '751': BigInteger;
+ '752': BigInteger;
+ '753': BigInteger;
+ '754': BigInteger;
+ '755': BigInteger;
+ '756': BigInteger;
+ '757': BigInteger;
+ '758': BigInteger;
+ '759': BigInteger;
+ '760': BigInteger;
+ '761': BigInteger;
+ '762': BigInteger;
+ '763': BigInteger;
+ '764': BigInteger;
+ '765': BigInteger;
+ '766': BigInteger;
+ '767': BigInteger;
+ '768': BigInteger;
+ '769': BigInteger;
+ '770': BigInteger;
+ '771': BigInteger;
+ '772': BigInteger;
+ '773': BigInteger;
+ '774': BigInteger;
+ '775': BigInteger;
+ '776': BigInteger;
+ '777': BigInteger;
+ '778': BigInteger;
+ '779': BigInteger;
+ '780': BigInteger;
+ '781': BigInteger;
+ '782': BigInteger;
+ '783': BigInteger;
+ '784': BigInteger;
+ '785': BigInteger;
+ '786': BigInteger;
+ '787': BigInteger;
+ '788': BigInteger;
+ '789': BigInteger;
+ '790': BigInteger;
+ '791': BigInteger;
+ '792': BigInteger;
+ '793': BigInteger;
+ '794': BigInteger;
+ '795': BigInteger;
+ '796': BigInteger;
+ '797': BigInteger;
+ '798': BigInteger;
+ '799': BigInteger;
+ '800': BigInteger;
+ '801': BigInteger;
+ '802': BigInteger;
+ '803': BigInteger;
+ '804': BigInteger;
+ '805': BigInteger;
+ '806': BigInteger;
+ '807': BigInteger;
+ '808': BigInteger;
+ '809': BigInteger;
+ '810': BigInteger;
+ '811': BigInteger;
+ '812': BigInteger;
+ '813': BigInteger;
+ '814': BigInteger;
+ '815': BigInteger;
+ '816': BigInteger;
+ '817': BigInteger;
+ '818': BigInteger;
+ '819': BigInteger;
+ '820': BigInteger;
+ '821': BigInteger;
+ '822': BigInteger;
+ '823': BigInteger;
+ '824': BigInteger;
+ '825': BigInteger;
+ '826': BigInteger;
+ '827': BigInteger;
+ '828': BigInteger;
+ '829': BigInteger;
+ '830': BigInteger;
+ '831': BigInteger;
+ '832': BigInteger;
+ '833': BigInteger;
+ '834': BigInteger;
+ '835': BigInteger;
+ '836': BigInteger;
+ '837': BigInteger;
+ '838': BigInteger;
+ '839': BigInteger;
+ '840': BigInteger;
+ '841': BigInteger;
+ '842': BigInteger;
+ '843': BigInteger;
+ '844': BigInteger;
+ '845': BigInteger;
+ '846': BigInteger;
+ '847': BigInteger;
+ '848': BigInteger;
+ '849': BigInteger;
+ '850': BigInteger;
+ '851': BigInteger;
+ '852': BigInteger;
+ '853': BigInteger;
+ '854': BigInteger;
+ '855': BigInteger;
+ '856': BigInteger;
+ '857': BigInteger;
+ '858': BigInteger;
+ '859': BigInteger;
+ '860': BigInteger;
+ '861': BigInteger;
+ '862': BigInteger;
+ '863': BigInteger;
+ '864': BigInteger;
+ '865': BigInteger;
+ '866': BigInteger;
+ '867': BigInteger;
+ '868': BigInteger;
+ '869': BigInteger;
+ '870': BigInteger;
+ '871': BigInteger;
+ '872': BigInteger;
+ '873': BigInteger;
+ '874': BigInteger;
+ '875': BigInteger;
+ '876': BigInteger;
+ '877': BigInteger;
+ '878': BigInteger;
+ '879': BigInteger;
+ '880': BigInteger;
+ '881': BigInteger;
+ '882': BigInteger;
+ '883': BigInteger;
+ '884': BigInteger;
+ '885': BigInteger;
+ '886': BigInteger;
+ '887': BigInteger;
+ '888': BigInteger;
+ '889': BigInteger;
+ '890': BigInteger;
+ '891': BigInteger;
+ '892': BigInteger;
+ '893': BigInteger;
+ '894': BigInteger;
+ '895': BigInteger;
+ '896': BigInteger;
+ '897': BigInteger;
+ '898': BigInteger;
+ '899': BigInteger;
+ '900': BigInteger;
+ '901': BigInteger;
+ '902': BigInteger;
+ '903': BigInteger;
+ '904': BigInteger;
+ '905': BigInteger;
+ '906': BigInteger;
+ '907': BigInteger;
+ '908': BigInteger;
+ '909': BigInteger;
+ '910': BigInteger;
+ '911': BigInteger;
+ '912': BigInteger;
+ '913': BigInteger;
+ '914': BigInteger;
+ '915': BigInteger;
+ '916': BigInteger;
+ '917': BigInteger;
+ '918': BigInteger;
+ '919': BigInteger;
+ '920': BigInteger;
+ '921': BigInteger;
+ '922': BigInteger;
+ '923': BigInteger;
+ '924': BigInteger;
+ '925': BigInteger;
+ '926': BigInteger;
+ '927': BigInteger;
+ '928': BigInteger;
+ '929': BigInteger;
+ '930': BigInteger;
+ '931': BigInteger;
+ '932': BigInteger;
+ '933': BigInteger;
+ '934': BigInteger;
+ '935': BigInteger;
+ '936': BigInteger;
+ '937': BigInteger;
+ '938': BigInteger;
+ '939': BigInteger;
+ '940': BigInteger;
+ '941': BigInteger;
+ '942': BigInteger;
+ '943': BigInteger;
+ '944': BigInteger;
+ '945': BigInteger;
+ '946': BigInteger;
+ '947': BigInteger;
+ '948': BigInteger;
+ '949': BigInteger;
+ '950': BigInteger;
+ '951': BigInteger;
+ '952': BigInteger;
+ '953': BigInteger;
+ '954': BigInteger;
+ '955': BigInteger;
+ '956': BigInteger;
+ '957': BigInteger;
+ '958': BigInteger;
+ '959': BigInteger;
+ '960': BigInteger;
+ '961': BigInteger;
+ '962': BigInteger;
+ '963': BigInteger;
+ '964': BigInteger;
+ '965': BigInteger;
+ '966': BigInteger;
+ '967': BigInteger;
+ '968': BigInteger;
+ '969': BigInteger;
+ '970': BigInteger;
+ '971': BigInteger;
+ '972': BigInteger;
+ '973': BigInteger;
+ '974': BigInteger;
+ '975': BigInteger;
+ '976': BigInteger;
+ '977': BigInteger;
+ '978': BigInteger;
+ '979': BigInteger;
+ '980': BigInteger;
+ '981': BigInteger;
+ '982': BigInteger;
+ '983': BigInteger;
+ '984': BigInteger;
+ '985': BigInteger;
+ '986': BigInteger;
+ '987': BigInteger;
+ '988': BigInteger;
+ '989': BigInteger;
+ '990': BigInteger;
+ '991': BigInteger;
+ '992': BigInteger;
+ '993': BigInteger;
+ '994': BigInteger;
+ '995': BigInteger;
+ '996': BigInteger;
+ '997': BigInteger;
+ '998': BigInteger;
+ '999': BigInteger;
+ }
+
+ interface BaseArray {
+ value: number[],
+ isNegative: boolean
+ }
+}
diff --git a/node_modules/big-integer/BigInteger.js b/node_modules/big-integer/BigInteger.js
new file mode 100644
index 0000000..87e43df
--- /dev/null
+++ b/node_modules/big-integer/BigInteger.js
@@ -0,0 +1,1453 @@
+var bigInt = (function (undefined) {
+ "use strict";
+
+ var BASE = 1e7,
+ LOG_BASE = 7,
+ MAX_INT = 9007199254740992,
+ MAX_INT_ARR = smallToArray(MAX_INT),
+ DEFAULT_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
+
+ var supportsNativeBigInt = typeof BigInt === "function";
+
+ function Integer(v, radix, alphabet, caseSensitive) {
+ if (typeof v === "undefined") return Integer[0];
+ if (typeof radix !== "undefined") return +radix === 10 && !alphabet ? parseValue(v) : parseBase(v, radix, alphabet, caseSensitive);
+ return parseValue(v);
+ }
+
+ function BigInteger(value, sign) {
+ this.value = value;
+ this.sign = sign;
+ this.isSmall = false;
+ }
+ BigInteger.prototype = Object.create(Integer.prototype);
+
+ function SmallInteger(value) {
+ this.value = value;
+ this.sign = value < 0;
+ this.isSmall = true;
+ }
+ SmallInteger.prototype = Object.create(Integer.prototype);
+
+ function NativeBigInt(value) {
+ this.value = value;
+ }
+ NativeBigInt.prototype = Object.create(Integer.prototype);
+
+ function isPrecise(n) {
+ return -MAX_INT < n && n < MAX_INT;
+ }
+
+ function smallToArray(n) { // For performance reasons doesn't reference BASE, need to change this function if BASE changes
+ if (n < 1e7)
+ return [n];
+ if (n < 1e14)
+ return [n % 1e7, Math.floor(n / 1e7)];
+ return [n % 1e7, Math.floor(n / 1e7) % 1e7, Math.floor(n / 1e14)];
+ }
+
+ function arrayToSmall(arr) { // If BASE changes this function may need to change
+ trim(arr);
+ var length = arr.length;
+ if (length < 4 && compareAbs(arr, MAX_INT_ARR) < 0) {
+ switch (length) {
+ case 0: return 0;
+ case 1: return arr[0];
+ case 2: return arr[0] + arr[1] * BASE;
+ default: return arr[0] + (arr[1] + arr[2] * BASE) * BASE;
+ }
+ }
+ return arr;
+ }
+
+ function trim(v) {
+ var i = v.length;
+ while (v[--i] === 0);
+ v.length = i + 1;
+ }
+
+ function createArray(length) { // function shamelessly stolen from Yaffle's library https://github.com/Yaffle/BigInteger
+ var x = new Array(length);
+ var i = -1;
+ while (++i < length) {
+ x[i] = 0;
+ }
+ return x;
+ }
+
+ function truncate(n) {
+ if (n > 0) return Math.floor(n);
+ return Math.ceil(n);
+ }
+
+ function add(a, b) { // assumes a and b are arrays with a.length >= b.length
+ var l_a = a.length,
+ l_b = b.length,
+ r = new Array(l_a),
+ carry = 0,
+ base = BASE,
+ sum, i;
+ for (i = 0; i < l_b; i++) {
+ sum = a[i] + b[i] + carry;
+ carry = sum >= base ? 1 : 0;
+ r[i] = sum - carry * base;
+ }
+ while (i < l_a) {
+ sum = a[i] + carry;
+ carry = sum === base ? 1 : 0;
+ r[i++] = sum - carry * base;
+ }
+ if (carry > 0) r.push(carry);
+ return r;
+ }
+
+ function addAny(a, b) {
+ if (a.length >= b.length) return add(a, b);
+ return add(b, a);
+ }
+
+ function addSmall(a, carry) { // assumes a is array, carry is number with 0 <= carry < MAX_INT
+ var l = a.length,
+ r = new Array(l),
+ base = BASE,
+ sum, i;
+ for (i = 0; i < l; i++) {
+ sum = a[i] - base + carry;
+ carry = Math.floor(sum / base);
+ r[i] = sum - carry * base;
+ carry += 1;
+ }
+ while (carry > 0) {
+ r[i++] = carry % base;
+ carry = Math.floor(carry / base);
+ }
+ return r;
+ }
+
+ BigInteger.prototype.add = function (v) {
+ var n = parseValue(v);
+ if (this.sign !== n.sign) {
+ return this.subtract(n.negate());
+ }
+ var a = this.value, b = n.value;
+ if (n.isSmall) {
+ return new BigInteger(addSmall(a, Math.abs(b)), this.sign);
+ }
+ return new BigInteger(addAny(a, b), this.sign);
+ };
+ BigInteger.prototype.plus = BigInteger.prototype.add;
+
+ SmallInteger.prototype.add = function (v) {
+ var n = parseValue(v);
+ var a = this.value;
+ if (a < 0 !== n.sign) {
+ return this.subtract(n.negate());
+ }
+ var b = n.value;
+ if (n.isSmall) {
+ if (isPrecise(a + b)) return new SmallInteger(a + b);
+ b = smallToArray(Math.abs(b));
+ }
+ return new BigInteger(addSmall(b, Math.abs(a)), a < 0);
+ };
+ SmallInteger.prototype.plus = SmallInteger.prototype.add;
+
+ NativeBigInt.prototype.add = function (v) {
+ return new NativeBigInt(this.value + parseValue(v).value);
+ }
+ NativeBigInt.prototype.plus = NativeBigInt.prototype.add;
+
+ function subtract(a, b) { // assumes a and b are arrays with a >= b
+ var a_l = a.length,
+ b_l = b.length,
+ r = new Array(a_l),
+ borrow = 0,
+ base = BASE,
+ i, difference;
+ for (i = 0; i < b_l; i++) {
+ difference = a[i] - borrow - b[i];
+ if (difference < 0) {
+ difference += base;
+ borrow = 1;
+ } else borrow = 0;
+ r[i] = difference;
+ }
+ for (i = b_l; i < a_l; i++) {
+ difference = a[i] - borrow;
+ if (difference < 0) difference += base;
+ else {
+ r[i++] = difference;
+ break;
+ }
+ r[i] = difference;
+ }
+ for (; i < a_l; i++) {
+ r[i] = a[i];
+ }
+ trim(r);
+ return r;
+ }
+
+ function subtractAny(a, b, sign) {
+ var value;
+ if (compareAbs(a, b) >= 0) {
+ value = subtract(a, b);
+ } else {
+ value = subtract(b, a);
+ sign = !sign;
+ }
+ value = arrayToSmall(value);
+ if (typeof value === "number") {
+ if (sign) value = -value;
+ return new SmallInteger(value);
+ }
+ return new BigInteger(value, sign);
+ }
+
+ function subtractSmall(a, b, sign) { // assumes a is array, b is number with 0 <= b < MAX_INT
+ var l = a.length,
+ r = new Array(l),
+ carry = -b,
+ base = BASE,
+ i, difference;
+ for (i = 0; i < l; i++) {
+ difference = a[i] + carry;
+ carry = Math.floor(difference / base);
+ difference %= base;
+ r[i] = difference < 0 ? difference + base : difference;
+ }
+ r = arrayToSmall(r);
+ if (typeof r === "number") {
+ if (sign) r = -r;
+ return new SmallInteger(r);
+ } return new BigInteger(r, sign);
+ }
+
+ BigInteger.prototype.subtract = function (v) {
+ var n = parseValue(v);
+ if (this.sign !== n.sign) {
+ return this.add(n.negate());
+ }
+ var a = this.value, b = n.value;
+ if (n.isSmall)
+ return subtractSmall(a, Math.abs(b), this.sign);
+ return subtractAny(a, b, this.sign);
+ };
+ BigInteger.prototype.minus = BigInteger.prototype.subtract;
+
+ SmallInteger.prototype.subtract = function (v) {
+ var n = parseValue(v);
+ var a = this.value;
+ if (a < 0 !== n.sign) {
+ return this.add(n.negate());
+ }
+ var b = n.value;
+ if (n.isSmall) {
+ return new SmallInteger(a - b);
+ }
+ return subtractSmall(b, Math.abs(a), a >= 0);
+ };
+ SmallInteger.prototype.minus = SmallInteger.prototype.subtract;
+
+ NativeBigInt.prototype.subtract = function (v) {
+ return new NativeBigInt(this.value - parseValue(v).value);
+ }
+ NativeBigInt.prototype.minus = NativeBigInt.prototype.subtract;
+
+ BigInteger.prototype.negate = function () {
+ return new BigInteger(this.value, !this.sign);
+ };
+ SmallInteger.prototype.negate = function () {
+ var sign = this.sign;
+ var small = new SmallInteger(-this.value);
+ small.sign = !sign;
+ return small;
+ };
+ NativeBigInt.prototype.negate = function () {
+ return new NativeBigInt(-this.value);
+ }
+
+ BigInteger.prototype.abs = function () {
+ return new BigInteger(this.value, false);
+ };
+ SmallInteger.prototype.abs = function () {
+ return new SmallInteger(Math.abs(this.value));
+ };
+ NativeBigInt.prototype.abs = function () {
+ return new NativeBigInt(this.value >= 0 ? this.value : -this.value);
+ }
+
+
+ function multiplyLong(a, b) {
+ var a_l = a.length,
+ b_l = b.length,
+ l = a_l + b_l,
+ r = createArray(l),
+ base = BASE,
+ product, carry, i, a_i, b_j;
+ for (i = 0; i < a_l; ++i) {
+ a_i = a[i];
+ for (var j = 0; j < b_l; ++j) {
+ b_j = b[j];
+ product = a_i * b_j + r[i + j];
+ carry = Math.floor(product / base);
+ r[i + j] = product - carry * base;
+ r[i + j + 1] += carry;
+ }
+ }
+ trim(r);
+ return r;
+ }
+
+ function multiplySmall(a, b) { // assumes a is array, b is number with |b| < BASE
+ var l = a.length,
+ r = new Array(l),
+ base = BASE,
+ carry = 0,
+ product, i;
+ for (i = 0; i < l; i++) {
+ product = a[i] * b + carry;
+ carry = Math.floor(product / base);
+ r[i] = product - carry * base;
+ }
+ while (carry > 0) {
+ r[i++] = carry % base;
+ carry = Math.floor(carry / base);
+ }
+ return r;
+ }
+
+ function shiftLeft(x, n) {
+ var r = [];
+ while (n-- > 0) r.push(0);
+ return r.concat(x);
+ }
+
+ function multiplyKaratsuba(x, y) {
+ var n = Math.max(x.length, y.length);
+
+ if (n <= 30) return multiplyLong(x, y);
+ n = Math.ceil(n / 2);
+
+ var b = x.slice(n),
+ a = x.slice(0, n),
+ d = y.slice(n),
+ c = y.slice(0, n);
+
+ var ac = multiplyKaratsuba(a, c),
+ bd = multiplyKaratsuba(b, d),
+ abcd = multiplyKaratsuba(addAny(a, b), addAny(c, d));
+
+ var product = addAny(addAny(ac, shiftLeft(subtract(subtract(abcd, ac), bd), n)), shiftLeft(bd, 2 * n));
+ trim(product);
+ return product;
+ }
+
+ // The following function is derived from a surface fit of a graph plotting the performance difference
+ // between long multiplication and karatsuba multiplication versus the lengths of the two arrays.
+ function useKaratsuba(l1, l2) {
+ return -0.012 * l1 - 0.012 * l2 + 0.000015 * l1 * l2 > 0;
+ }
+
+ BigInteger.prototype.multiply = function (v) {
+ var n = parseValue(v),
+ a = this.value, b = n.value,
+ sign = this.sign !== n.sign,
+ abs;
+ if (n.isSmall) {
+ if (b === 0) return Integer[0];
+ if (b === 1) return this;
+ if (b === -1) return this.negate();
+ abs = Math.abs(b);
+ if (abs < BASE) {
+ return new BigInteger(multiplySmall(a, abs), sign);
+ }
+ b = smallToArray(abs);
+ }
+ if (useKaratsuba(a.length, b.length)) // Karatsuba is only faster for certain array sizes
+ return new BigInteger(multiplyKaratsuba(a, b), sign);
+ return new BigInteger(multiplyLong(a, b), sign);
+ };
+
+ BigInteger.prototype.times = BigInteger.prototype.multiply;
+
+ function multiplySmallAndArray(a, b, sign) { // a >= 0
+ if (a < BASE) {
+ return new BigInteger(multiplySmall(b, a), sign);
+ }
+ return new BigInteger(multiplyLong(b, smallToArray(a)), sign);
+ }
+ SmallInteger.prototype._multiplyBySmall = function (a) {
+ if (isPrecise(a.value * this.value)) {
+ return new SmallInteger(a.value * this.value);
+ }
+ return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign);
+ };
+ BigInteger.prototype._multiplyBySmall = function (a) {
+ if (a.value === 0) return Integer[0];
+ if (a.value === 1) return this;
+ if (a.value === -1) return this.negate();
+ return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign);
+ };
+ SmallInteger.prototype.multiply = function (v) {
+ return parseValue(v)._multiplyBySmall(this);
+ };
+ SmallInteger.prototype.times = SmallInteger.prototype.multiply;
+
+ NativeBigInt.prototype.multiply = function (v) {
+ return new NativeBigInt(this.value * parseValue(v).value);
+ }
+ NativeBigInt.prototype.times = NativeBigInt.prototype.multiply;
+
+ function square(a) {
+ //console.assert(2 * BASE * BASE < MAX_INT);
+ var l = a.length,
+ r = createArray(l + l),
+ base = BASE,
+ product, carry, i, a_i, a_j;
+ for (i = 0; i < l; i++) {
+ a_i = a[i];
+ carry = 0 - a_i * a_i;
+ for (var j = i; j < l; j++) {
+ a_j = a[j];
+ product = 2 * (a_i * a_j) + r[i + j] + carry;
+ carry = Math.floor(product / base);
+ r[i + j] = product - carry * base;
+ }
+ r[i + l] = carry;
+ }
+ trim(r);
+ return r;
+ }
+
+ BigInteger.prototype.square = function () {
+ return new BigInteger(square(this.value), false);
+ };
+
+ SmallInteger.prototype.square = function () {
+ var value = this.value * this.value;
+ if (isPrecise(value)) return new SmallInteger(value);
+ return new BigInteger(square(smallToArray(Math.abs(this.value))), false);
+ };
+
+ NativeBigInt.prototype.square = function (v) {
+ return new NativeBigInt(this.value * this.value);
+ }
+
+ function divMod1(a, b) { // Left over from previous version. Performs faster than divMod2 on smaller input sizes.
+ var a_l = a.length,
+ b_l = b.length,
+ base = BASE,
+ result = createArray(b.length),
+ divisorMostSignificantDigit = b[b_l - 1],
+ // normalization
+ lambda = Math.ceil(base / (2 * divisorMostSignificantDigit)),
+ remainder = multiplySmall(a, lambda),
+ divisor = multiplySmall(b, lambda),
+ quotientDigit, shift, carry, borrow, i, l, q;
+ if (remainder.length <= a_l) remainder.push(0);
+ divisor.push(0);
+ divisorMostSignificantDigit = divisor[b_l - 1];
+ for (shift = a_l - b_l; shift >= 0; shift--) {
+ quotientDigit = base - 1;
+ if (remainder[shift + b_l] !== divisorMostSignificantDigit) {
+ quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit);
+ }
+ // quotientDigit <= base - 1
+ carry = 0;
+ borrow = 0;
+ l = divisor.length;
+ for (i = 0; i < l; i++) {
+ carry += quotientDigit * divisor[i];
+ q = Math.floor(carry / base);
+ borrow += remainder[shift + i] - (carry - q * base);
+ carry = q;
+ if (borrow < 0) {
+ remainder[shift + i] = borrow + base;
+ borrow = -1;
+ } else {
+ remainder[shift + i] = borrow;
+ borrow = 0;
+ }
+ }
+ while (borrow !== 0) {
+ quotientDigit -= 1;
+ carry = 0;
+ for (i = 0; i < l; i++) {
+ carry += remainder[shift + i] - base + divisor[i];
+ if (carry < 0) {
+ remainder[shift + i] = carry + base;
+ carry = 0;
+ } else {
+ remainder[shift + i] = carry;
+ carry = 1;
+ }
+ }
+ borrow += carry;
+ }
+ result[shift] = quotientDigit;
+ }
+ // denormalization
+ remainder = divModSmall(remainder, lambda)[0];
+ return [arrayToSmall(result), arrayToSmall(remainder)];
+ }
+
+ function divMod2(a, b) { // Implementation idea shamelessly stolen from Silent Matt's library http://silentmatt.com/biginteger/
+ // Performs faster than divMod1 on larger input sizes.
+ var a_l = a.length,
+ b_l = b.length,
+ result = [],
+ part = [],
+ base = BASE,
+ guess, xlen, highx, highy, check;
+ while (a_l) {
+ part.unshift(a[--a_l]);
+ trim(part);
+ if (compareAbs(part, b) < 0) {
+ result.push(0);
+ continue;
+ }
+ xlen = part.length;
+ highx = part[xlen - 1] * base + part[xlen - 2];
+ highy = b[b_l - 1] * base + b[b_l - 2];
+ if (xlen > b_l) {
+ highx = (highx + 1) * base;
+ }
+ guess = Math.ceil(highx / highy);
+ do {
+ check = multiplySmall(b, guess);
+ if (compareAbs(check, part) <= 0) break;
+ guess--;
+ } while (guess);
+ result.push(guess);
+ part = subtract(part, check);
+ }
+ result.reverse();
+ return [arrayToSmall(result), arrayToSmall(part)];
+ }
+
+ function divModSmall(value, lambda) {
+ var length = value.length,
+ quotient = createArray(length),
+ base = BASE,
+ i, q, remainder, divisor;
+ remainder = 0;
+ for (i = length - 1; i >= 0; --i) {
+ divisor = remainder * base + value[i];
+ q = truncate(divisor / lambda);
+ remainder = divisor - q * lambda;
+ quotient[i] = q | 0;
+ }
+ return [quotient, remainder | 0];
+ }
+
+ function divModAny(self, v) {
+ var value, n = parseValue(v);
+ if (supportsNativeBigInt) {
+ return [new NativeBigInt(self.value / n.value), new NativeBigInt(self.value % n.value)];
+ }
+ var a = self.value, b = n.value;
+ var quotient;
+ if (b === 0) throw new Error("Cannot divide by zero");
+ if (self.isSmall) {
+ if (n.isSmall) {
+ return [new SmallInteger(truncate(a / b)), new SmallInteger(a % b)];
+ }
+ return [Integer[0], self];
+ }
+ if (n.isSmall) {
+ if (b === 1) return [self, Integer[0]];
+ if (b == -1) return [self.negate(), Integer[0]];
+ var abs = Math.abs(b);
+ if (abs < BASE) {
+ value = divModSmall(a, abs);
+ quotient = arrayToSmall(value[0]);
+ var remainder = value[1];
+ if (self.sign) remainder = -remainder;
+ if (typeof quotient === "number") {
+ if (self.sign !== n.sign) quotient = -quotient;
+ return [new SmallInteger(quotient), new SmallInteger(remainder)];
+ }
+ return [new BigInteger(quotient, self.sign !== n.sign), new SmallInteger(remainder)];
+ }
+ b = smallToArray(abs);
+ }
+ var comparison = compareAbs(a, b);
+ if (comparison === -1) return [Integer[0], self];
+ if (comparison === 0) return [Integer[self.sign === n.sign ? 1 : -1], Integer[0]];
+
+ // divMod1 is faster on smaller input sizes
+ if (a.length + b.length <= 200)
+ value = divMod1(a, b);
+ else value = divMod2(a, b);
+
+ quotient = value[0];
+ var qSign = self.sign !== n.sign,
+ mod = value[1],
+ mSign = self.sign;
+ if (typeof quotient === "number") {
+ if (qSign) quotient = -quotient;
+ quotient = new SmallInteger(quotient);
+ } else quotient = new BigInteger(quotient, qSign);
+ if (typeof mod === "number") {
+ if (mSign) mod = -mod;
+ mod = new SmallInteger(mod);
+ } else mod = new BigInteger(mod, mSign);
+ return [quotient, mod];
+ }
+
+ BigInteger.prototype.divmod = function (v) {
+ var result = divModAny(this, v);
+ return {
+ quotient: result[0],
+ remainder: result[1]
+ };
+ };
+ NativeBigInt.prototype.divmod = SmallInteger.prototype.divmod = BigInteger.prototype.divmod;
+
+
+ BigInteger.prototype.divide = function (v) {
+ return divModAny(this, v)[0];
+ };
+ NativeBigInt.prototype.over = NativeBigInt.prototype.divide = function (v) {
+ return new NativeBigInt(this.value / parseValue(v).value);
+ };
+ SmallInteger.prototype.over = SmallInteger.prototype.divide = BigInteger.prototype.over = BigInteger.prototype.divide;
+
+ BigInteger.prototype.mod = function (v) {
+ return divModAny(this, v)[1];
+ };
+ NativeBigInt.prototype.mod = NativeBigInt.prototype.remainder = function (v) {
+ return new NativeBigInt(this.value % parseValue(v).value);
+ };
+ SmallInteger.prototype.remainder = SmallInteger.prototype.mod = BigInteger.prototype.remainder = BigInteger.prototype.mod;
+
+ BigInteger.prototype.pow = function (v) {
+ var n = parseValue(v),
+ a = this.value,
+ b = n.value,
+ value, x, y;
+ if (b === 0) return Integer[1];
+ if (a === 0) return Integer[0];
+ if (a === 1) return Integer[1];
+ if (a === -1) return n.isEven() ? Integer[1] : Integer[-1];
+ if (n.sign) {
+ return Integer[0];
+ }
+ if (!n.isSmall) throw new Error("The exponent " + n.toString() + " is too large.");
+ if (this.isSmall) {
+ if (isPrecise(value = Math.pow(a, b)))
+ return new SmallInteger(truncate(value));
+ }
+ x = this;
+ y = Integer[1];
+ while (true) {
+ if (b & 1 === 1) {
+ y = y.times(x);
+ --b;
+ }
+ if (b === 0) break;
+ b /= 2;
+ x = x.square();
+ }
+ return y;
+ };
+ SmallInteger.prototype.pow = BigInteger.prototype.pow;
+
+ NativeBigInt.prototype.pow = function (v) {
+ var n = parseValue(v);
+ var a = this.value, b = n.value;
+ var _0 = BigInt(0), _1 = BigInt(1), _2 = BigInt(2);
+ if (b === _0) return Integer[1];
+ if (a === _0) return Integer[0];
+ if (a === _1) return Integer[1];
+ if (a === BigInt(-1)) return n.isEven() ? Integer[1] : Integer[-1];
+ if (n.isNegative()) return new NativeBigInt(_0);
+ var x = this;
+ var y = Integer[1];
+ while (true) {
+ if ((b & _1) === _1) {
+ y = y.times(x);
+ --b;
+ }
+ if (b === _0) break;
+ b /= _2;
+ x = x.square();
+ }
+ return y;
+ }
+
+ BigInteger.prototype.modPow = function (exp, mod) {
+ exp = parseValue(exp);
+ mod = parseValue(mod);
+ if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0");
+ var r = Integer[1],
+ base = this.mod(mod);
+ if (exp.isNegative()) {
+ exp = exp.multiply(Integer[-1]);
+ base = base.modInv(mod);
+ }
+ while (exp.isPositive()) {
+ if (base.isZero()) return Integer[0];
+ if (exp.isOdd()) r = r.multiply(base).mod(mod);
+ exp = exp.divide(2);
+ base = base.square().mod(mod);
+ }
+ return r;
+ };
+ NativeBigInt.prototype.modPow = SmallInteger.prototype.modPow = BigInteger.prototype.modPow;
+
+ function compareAbs(a, b) {
+ if (a.length !== b.length) {
+ return a.length > b.length ? 1 : -1;
+ }
+ for (var i = a.length - 1; i >= 0; i--) {
+ if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1;
+ }
+ return 0;
+ }
+
+ BigInteger.prototype.compareAbs = function (v) {
+ var n = parseValue(v),
+ a = this.value,
+ b = n.value;
+ if (n.isSmall) return 1;
+ return compareAbs(a, b);
+ };
+ SmallInteger.prototype.compareAbs = function (v) {
+ var n = parseValue(v),
+ a = Math.abs(this.value),
+ b = n.value;
+ if (n.isSmall) {
+ b = Math.abs(b);
+ return a === b ? 0 : a > b ? 1 : -1;
+ }
+ return -1;
+ };
+ NativeBigInt.prototype.compareAbs = function (v) {
+ var a = this.value;
+ var b = parseValue(v).value;
+ a = a >= 0 ? a : -a;
+ b = b >= 0 ? b : -b;
+ return a === b ? 0 : a > b ? 1 : -1;
+ }
+
+ BigInteger.prototype.compare = function (v) {
+ // See discussion about comparison with Infinity:
+ // https://github.com/peterolson/BigInteger.js/issues/61
+ if (v === Infinity) {
+ return -1;
+ }
+ if (v === -Infinity) {
+ return 1;
+ }
+
+ var n = parseValue(v),
+ a = this.value,
+ b = n.value;
+ if (this.sign !== n.sign) {
+ return n.sign ? 1 : -1;
+ }
+ if (n.isSmall) {
+ return this.sign ? -1 : 1;
+ }
+ return compareAbs(a, b) * (this.sign ? -1 : 1);
+ };
+ BigInteger.prototype.compareTo = BigInteger.prototype.compare;
+
+ SmallInteger.prototype.compare = function (v) {
+ if (v === Infinity) {
+ return -1;
+ }
+ if (v === -Infinity) {
+ return 1;
+ }
+
+ var n = parseValue(v),
+ a = this.value,
+ b = n.value;
+ if (n.isSmall) {
+ return a == b ? 0 : a > b ? 1 : -1;
+ }
+ if (a < 0 !== n.sign) {
+ return a < 0 ? -1 : 1;
+ }
+ return a < 0 ? 1 : -1;
+ };
+ SmallInteger.prototype.compareTo = SmallInteger.prototype.compare;
+
+ NativeBigInt.prototype.compare = function (v) {
+ if (v === Infinity) {
+ return -1;
+ }
+ if (v === -Infinity) {
+ return 1;
+ }
+ var a = this.value;
+ var b = parseValue(v).value;
+ return a === b ? 0 : a > b ? 1 : -1;
+ }
+ NativeBigInt.prototype.compareTo = NativeBigInt.prototype.compare;
+
+ BigInteger.prototype.equals = function (v) {
+ return this.compare(v) === 0;
+ };
+ NativeBigInt.prototype.eq = NativeBigInt.prototype.equals = SmallInteger.prototype.eq = SmallInteger.prototype.equals = BigInteger.prototype.eq = BigInteger.prototype.equals;
+
+ BigInteger.prototype.notEquals = function (v) {
+ return this.compare(v) !== 0;
+ };
+ NativeBigInt.prototype.neq = NativeBigInt.prototype.notEquals = SmallInteger.prototype.neq = SmallInteger.prototype.notEquals = BigInteger.prototype.neq = BigInteger.prototype.notEquals;
+
+ BigInteger.prototype.greater = function (v) {
+ return this.compare(v) > 0;
+ };
+ NativeBigInt.prototype.gt = NativeBigInt.prototype.greater = SmallInteger.prototype.gt = SmallInteger.prototype.greater = BigInteger.prototype.gt = BigInteger.prototype.greater;
+
+ BigInteger.prototype.lesser = function (v) {
+ return this.compare(v) < 0;
+ };
+ NativeBigInt.prototype.lt = NativeBigInt.prototype.lesser = SmallInteger.prototype.lt = SmallInteger.prototype.lesser = BigInteger.prototype.lt = BigInteger.prototype.lesser;
+
+ BigInteger.prototype.greaterOrEquals = function (v) {
+ return this.compare(v) >= 0;
+ };
+ NativeBigInt.prototype.geq = NativeBigInt.prototype.greaterOrEquals = SmallInteger.prototype.geq = SmallInteger.prototype.greaterOrEquals = BigInteger.prototype.geq = BigInteger.prototype.greaterOrEquals;
+
+ BigInteger.prototype.lesserOrEquals = function (v) {
+ return this.compare(v) <= 0;
+ };
+ NativeBigInt.prototype.leq = NativeBigInt.prototype.lesserOrEquals = SmallInteger.prototype.leq = SmallInteger.prototype.lesserOrEquals = BigInteger.prototype.leq = BigInteger.prototype.lesserOrEquals;
+
+ BigInteger.prototype.isEven = function () {
+ return (this.value[0] & 1) === 0;
+ };
+ SmallInteger.prototype.isEven = function () {
+ return (this.value & 1) === 0;
+ };
+ NativeBigInt.prototype.isEven = function () {
+ return (this.value & BigInt(1)) === BigInt(0);
+ }
+
+ BigInteger.prototype.isOdd = function () {
+ return (this.value[0] & 1) === 1;
+ };
+ SmallInteger.prototype.isOdd = function () {
+ return (this.value & 1) === 1;
+ };
+ NativeBigInt.prototype.isOdd = function () {
+ return (this.value & BigInt(1)) === BigInt(1);
+ }
+
+ BigInteger.prototype.isPositive = function () {
+ return !this.sign;
+ };
+ SmallInteger.prototype.isPositive = function () {
+ return this.value > 0;
+ };
+ NativeBigInt.prototype.isPositive = SmallInteger.prototype.isPositive;
+
+ BigInteger.prototype.isNegative = function () {
+ return this.sign;
+ };
+ SmallInteger.prototype.isNegative = function () {
+ return this.value < 0;
+ };
+ NativeBigInt.prototype.isNegative = SmallInteger.prototype.isNegative;
+
+ BigInteger.prototype.isUnit = function () {
+ return false;
+ };
+ SmallInteger.prototype.isUnit = function () {
+ return Math.abs(this.value) === 1;
+ };
+ NativeBigInt.prototype.isUnit = function () {
+ return this.abs().value === BigInt(1);
+ }
+
+ BigInteger.prototype.isZero = function () {
+ return false;
+ };
+ SmallInteger.prototype.isZero = function () {
+ return this.value === 0;
+ };
+ NativeBigInt.prototype.isZero = function () {
+ return this.value === BigInt(0);
+ }
+
+ BigInteger.prototype.isDivisibleBy = function (v) {
+ var n = parseValue(v);
+ if (n.isZero()) return false;
+ if (n.isUnit()) return true;
+ if (n.compareAbs(2) === 0) return this.isEven();
+ return this.mod(n).isZero();
+ };
+ NativeBigInt.prototype.isDivisibleBy = SmallInteger.prototype.isDivisibleBy = BigInteger.prototype.isDivisibleBy;
+
+ function isBasicPrime(v) {
+ var n = v.abs();
+ if (n.isUnit()) return false;
+ if (n.equals(2) || n.equals(3) || n.equals(5)) return true;
+ if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false;
+ if (n.lesser(49)) return true;
+ // we don't know if it's prime: let the other functions figure it out
+ }
+
+ function millerRabinTest(n, a) {
+ var nPrev = n.prev(),
+ b = nPrev,
+ r = 0,
+ d, t, i, x;
+ while (b.isEven()) b = b.divide(2), r++;
+ next: for (i = 0; i < a.length; i++) {
+ if (n.lesser(a[i])) continue;
+ x = bigInt(a[i]).modPow(b, n);
+ if (x.isUnit() || x.equals(nPrev)) continue;
+ for (d = r - 1; d != 0; d--) {
+ x = x.square().mod(n);
+ if (x.isUnit()) return false;
+ if (x.equals(nPrev)) continue next;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ // Set "strict" to true to force GRH-supported lower bound of 2*log(N)^2
+ BigInteger.prototype.isPrime = function (strict) {
+ var isPrime = isBasicPrime(this);
+ if (isPrime !== undefined) return isPrime;
+ var n = this.abs();
+ var bits = n.bitLength();
+ if (bits <= 64)
+ return millerRabinTest(n, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]);
+ var logN = Math.log(2) * bits.toJSNumber();
+ var t = Math.ceil((strict === true) ? (2 * Math.pow(logN, 2)) : logN);
+ for (var a = [], i = 0; i < t; i++) {
+ a.push(bigInt(i + 2));
+ }
+ return millerRabinTest(n, a);
+ };
+ NativeBigInt.prototype.isPrime = SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime;
+
+ BigInteger.prototype.isProbablePrime = function (iterations, rng) {
+ var isPrime = isBasicPrime(this);
+ if (isPrime !== undefined) return isPrime;
+ var n = this.abs();
+ var t = iterations === undefined ? 5 : iterations;
+ for (var a = [], i = 0; i < t; i++) {
+ a.push(bigInt.randBetween(2, n.minus(2), rng));
+ }
+ return millerRabinTest(n, a);
+ };
+ NativeBigInt.prototype.isProbablePrime = SmallInteger.prototype.isProbablePrime = BigInteger.prototype.isProbablePrime;
+
+ BigInteger.prototype.modInv = function (n) {
+ var t = bigInt.zero, newT = bigInt.one, r = parseValue(n), newR = this.abs(), q, lastT, lastR;
+ while (!newR.isZero()) {
+ q = r.divide(newR);
+ lastT = t;
+ lastR = r;
+ t = newT;
+ r = newR;
+ newT = lastT.subtract(q.multiply(newT));
+ newR = lastR.subtract(q.multiply(newR));
+ }
+ if (!r.isUnit()) throw new Error(this.toString() + " and " + n.toString() + " are not co-prime");
+ if (t.compare(0) === -1) {
+ t = t.add(n);
+ }
+ if (this.isNegative()) {
+ return t.negate();
+ }
+ return t;
+ };
+
+ NativeBigInt.prototype.modInv = SmallInteger.prototype.modInv = BigInteger.prototype.modInv;
+
+ BigInteger.prototype.next = function () {
+ var value = this.value;
+ if (this.sign) {
+ return subtractSmall(value, 1, this.sign);
+ }
+ return new BigInteger(addSmall(value, 1), this.sign);
+ };
+ SmallInteger.prototype.next = function () {
+ var value = this.value;
+ if (value + 1 < MAX_INT) return new SmallInteger(value + 1);
+ return new BigInteger(MAX_INT_ARR, false);
+ };
+ NativeBigInt.prototype.next = function () {
+ return new NativeBigInt(this.value + BigInt(1));
+ }
+
+ BigInteger.prototype.prev = function () {
+ var value = this.value;
+ if (this.sign) {
+ return new BigInteger(addSmall(value, 1), true);
+ }
+ return subtractSmall(value, 1, this.sign);
+ };
+ SmallInteger.prototype.prev = function () {
+ var value = this.value;
+ if (value - 1 > -MAX_INT) return new SmallInteger(value - 1);
+ return new BigInteger(MAX_INT_ARR, true);
+ };
+ NativeBigInt.prototype.prev = function () {
+ return new NativeBigInt(this.value - BigInt(1));
+ }
+
+ var powersOfTwo = [1];
+ while (2 * powersOfTwo[powersOfTwo.length - 1] <= BASE) powersOfTwo.push(2 * powersOfTwo[powersOfTwo.length - 1]);
+ var powers2Length = powersOfTwo.length, highestPower2 = powersOfTwo[powers2Length - 1];
+
+ function shift_isSmall(n) {
+ return Math.abs(n) <= BASE;
+ }
+
+ BigInteger.prototype.shiftLeft = function (v) {
+ var n = parseValue(v).toJSNumber();
+ if (!shift_isSmall(n)) {
+ throw new Error(String(n) + " is too large for shifting.");
+ }
+ if (n < 0) return this.shiftRight(-n);
+ var result = this;
+ if (result.isZero()) return result;
+ while (n >= powers2Length) {
+ result = result.multiply(highestPower2);
+ n -= powers2Length - 1;
+ }
+ return result.multiply(powersOfTwo[n]);
+ };
+ NativeBigInt.prototype.shiftLeft = SmallInteger.prototype.shiftLeft = BigInteger.prototype.shiftLeft;
+
+ BigInteger.prototype.shiftRight = function (v) {
+ var remQuo;
+ var n = parseValue(v).toJSNumber();
+ if (!shift_isSmall(n)) {
+ throw new Error(String(n) + " is too large for shifting.");
+ }
+ if (n < 0) return this.shiftLeft(-n);
+ var result = this;
+ while (n >= powers2Length) {
+ if (result.isZero() || (result.isNegative() && result.isUnit())) return result;
+ remQuo = divModAny(result, highestPower2);
+ result = remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
+ n -= powers2Length - 1;
+ }
+ remQuo = divModAny(result, powersOfTwo[n]);
+ return remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
+ };
+ NativeBigInt.prototype.shiftRight = SmallInteger.prototype.shiftRight = BigInteger.prototype.shiftRight;
+
+ function bitwise(x, y, fn) {
+ y = parseValue(y);
+ var xSign = x.isNegative(), ySign = y.isNegative();
+ var xRem = xSign ? x.not() : x,
+ yRem = ySign ? y.not() : y;
+ var xDigit = 0, yDigit = 0;
+ var xDivMod = null, yDivMod = null;
+ var result = [];
+ while (!xRem.isZero() || !yRem.isZero()) {
+ xDivMod = divModAny(xRem, highestPower2);
+ xDigit = xDivMod[1].toJSNumber();
+ if (xSign) {
+ xDigit = highestPower2 - 1 - xDigit; // two's complement for negative numbers
+ }
+
+ yDivMod = divModAny(yRem, highestPower2);
+ yDigit = yDivMod[1].toJSNumber();
+ if (ySign) {
+ yDigit = highestPower2 - 1 - yDigit; // two's complement for negative numbers
+ }
+
+ xRem = xDivMod[0];
+ yRem = yDivMod[0];
+ result.push(fn(xDigit, yDigit));
+ }
+ var sum = fn(xSign ? 1 : 0, ySign ? 1 : 0) !== 0 ? bigInt(-1) : bigInt(0);
+ for (var i = result.length - 1; i >= 0; i -= 1) {
+ sum = sum.multiply(highestPower2).add(bigInt(result[i]));
+ }
+ return sum;
+ }
+
+ BigInteger.prototype.not = function () {
+ return this.negate().prev();
+ };
+ NativeBigInt.prototype.not = SmallInteger.prototype.not = BigInteger.prototype.not;
+
+ BigInteger.prototype.and = function (n) {
+ return bitwise(this, n, function (a, b) { return a & b; });
+ };
+ NativeBigInt.prototype.and = SmallInteger.prototype.and = BigInteger.prototype.and;
+
+ BigInteger.prototype.or = function (n) {
+ return bitwise(this, n, function (a, b) { return a | b; });
+ };
+ NativeBigInt.prototype.or = SmallInteger.prototype.or = BigInteger.prototype.or;
+
+ BigInteger.prototype.xor = function (n) {
+ return bitwise(this, n, function (a, b) { return a ^ b; });
+ };
+ NativeBigInt.prototype.xor = SmallInteger.prototype.xor = BigInteger.prototype.xor;
+
+ var LOBMASK_I = 1 << 30, LOBMASK_BI = (BASE & -BASE) * (BASE & -BASE) | LOBMASK_I;
+ function roughLOB(n) { // get lowestOneBit (rough)
+ // SmallInteger: return Min(lowestOneBit(n), 1 << 30)
+ // BigInteger: return Min(lowestOneBit(n), 1 << 14) [BASE=1e7]
+ var v = n.value,
+ x = typeof v === "number" ? v | LOBMASK_I :
+ typeof v === "bigint" ? v | BigInt(LOBMASK_I) :
+ v[0] + v[1] * BASE | LOBMASK_BI;
+ return x & -x;
+ }
+
+ function integerLogarithm(value, base) {
+ if (base.compareTo(value) <= 0) {
+ var tmp = integerLogarithm(value, base.square(base));
+ var p = tmp.p;
+ var e = tmp.e;
+ var t = p.multiply(base);
+ return t.compareTo(value) <= 0 ? { p: t, e: e * 2 + 1 } : { p: p, e: e * 2 };
+ }
+ return { p: bigInt(1), e: 0 };
+ }
+
+ BigInteger.prototype.bitLength = function () {
+ var n = this;
+ if (n.compareTo(bigInt(0)) < 0) {
+ n = n.negate().subtract(bigInt(1));
+ }
+ if (n.compareTo(bigInt(0)) === 0) {
+ return bigInt(0);
+ }
+ return bigInt(integerLogarithm(n, bigInt(2)).e).add(bigInt(1));
+ }
+ NativeBigInt.prototype.bitLength = SmallInteger.prototype.bitLength = BigInteger.prototype.bitLength;
+
+ function max(a, b) {
+ a = parseValue(a);
+ b = parseValue(b);
+ return a.greater(b) ? a : b;
+ }
+ function min(a, b) {
+ a = parseValue(a);
+ b = parseValue(b);
+ return a.lesser(b) ? a : b;
+ }
+ function gcd(a, b) {
+ a = parseValue(a).abs();
+ b = parseValue(b).abs();
+ if (a.equals(b)) return a;
+ if (a.isZero()) return b;
+ if (b.isZero()) return a;
+ var c = Integer[1], d, t;
+ while (a.isEven() && b.isEven()) {
+ d = min(roughLOB(a), roughLOB(b));
+ a = a.divide(d);
+ b = b.divide(d);
+ c = c.multiply(d);
+ }
+ while (a.isEven()) {
+ a = a.divide(roughLOB(a));
+ }
+ do {
+ while (b.isEven()) {
+ b = b.divide(roughLOB(b));
+ }
+ if (a.greater(b)) {
+ t = b; b = a; a = t;
+ }
+ b = b.subtract(a);
+ } while (!b.isZero());
+ return c.isUnit() ? a : a.multiply(c);
+ }
+ function lcm(a, b) {
+ a = parseValue(a).abs();
+ b = parseValue(b).abs();
+ return a.divide(gcd(a, b)).multiply(b);
+ }
+ function randBetween(a, b, rng) {
+ a = parseValue(a);
+ b = parseValue(b);
+ var usedRNG = rng || Math.random;
+ var low = min(a, b), high = max(a, b);
+ var range = high.subtract(low).add(1);
+ if (range.isSmall) return low.add(Math.floor(usedRNG() * range));
+ var digits = toBase(range, BASE).value;
+ var result = [], restricted = true;
+ for (var i = 0; i < digits.length; i++) {
+ var top = restricted ? digits[i] + (i + 1 < digits.length ? digits[i + 1] / BASE : 0) : BASE;
+ var digit = truncate(usedRNG() * top);
+ result.push(digit);
+ if (digit < digits[i]) restricted = false;
+ }
+ return low.add(Integer.fromArray(result, BASE, false));
+ }
+
+ var parseBase = function (text, base, alphabet, caseSensitive) {
+ alphabet = alphabet || DEFAULT_ALPHABET;
+ text = String(text);
+ if (!caseSensitive) {
+ text = text.toLowerCase();
+ alphabet = alphabet.toLowerCase();
+ }
+ var length = text.length;
+ var i;
+ var absBase = Math.abs(base);
+ var alphabetValues = {};
+ for (i = 0; i < alphabet.length; i++) {
+ alphabetValues[alphabet[i]] = i;
+ }
+ for (i = 0; i < length; i++) {
+ var c = text[i];
+ if (c === "-") continue;
+ if (c in alphabetValues) {
+ if (alphabetValues[c] >= absBase) {
+ if (c === "1" && absBase === 1) continue;
+ throw new Error(c + " is not a valid digit in base " + base + ".");
+ }
+ }
+ }
+ base = parseValue(base);
+ var digits = [];
+ var isNegative = text[0] === "-";
+ for (i = isNegative ? 1 : 0; i < text.length; i++) {
+ var c = text[i];
+ if (c in alphabetValues) digits.push(parseValue(alphabetValues[c]));
+ else if (c === "<") {
+ var start = i;
+ do { i++; } while (text[i] !== ">" && i < text.length);
+ digits.push(parseValue(text.slice(start + 1, i)));
+ }
+ else throw new Error(c + " is not a valid character");
+ }
+ return parseBaseFromArray(digits, base, isNegative);
+ };
+
+ function parseBaseFromArray(digits, base, isNegative) {
+ var val = Integer[0], pow = Integer[1], i;
+ for (i = digits.length - 1; i >= 0; i--) {
+ val = val.add(digits[i].times(pow));
+ pow = pow.times(base);
+ }
+ return isNegative ? val.negate() : val;
+ }
+
+ function stringify(digit, alphabet) {
+ alphabet = alphabet || DEFAULT_ALPHABET;
+ if (digit < alphabet.length) {
+ return alphabet[digit];
+ }
+ return "<" + digit + ">";
+ }
+
+ function toBase(n, base) {
+ base = bigInt(base);
+ if (base.isZero()) {
+ if (n.isZero()) return { value: [0], isNegative: false };
+ throw new Error("Cannot convert nonzero numbers to base 0.");
+ }
+ if (base.equals(-1)) {
+ if (n.isZero()) return { value: [0], isNegative: false };
+ if (n.isNegative())
+ return {
+ value: [].concat.apply([], Array.apply(null, Array(-n.toJSNumber()))
+ .map(Array.prototype.valueOf, [1, 0])
+ ),
+ isNegative: false
+ };
+
+ var arr = Array.apply(null, Array(n.toJSNumber() - 1))
+ .map(Array.prototype.valueOf, [0, 1]);
+ arr.unshift([1]);
+ return {
+ value: [].concat.apply([], arr),
+ isNegative: false
+ };
+ }
+
+ var neg = false;
+ if (n.isNegative() && base.isPositive()) {
+ neg = true;
+ n = n.abs();
+ }
+ if (base.isUnit()) {
+ if (n.isZero()) return { value: [0], isNegative: false };
+
+ return {
+ value: Array.apply(null, Array(n.toJSNumber()))
+ .map(Number.prototype.valueOf, 1),
+ isNegative: neg
+ };
+ }
+ var out = [];
+ var left = n, divmod;
+ while (left.isNegative() || left.compareAbs(base) >= 0) {
+ divmod = left.divmod(base);
+ left = divmod.quotient;
+ var digit = divmod.remainder;
+ if (digit.isNegative()) {
+ digit = base.minus(digit).abs();
+ left = left.next();
+ }
+ out.push(digit.toJSNumber());
+ }
+ out.push(left.toJSNumber());
+ return { value: out.reverse(), isNegative: neg };
+ }
+
+ function toBaseString(n, base, alphabet) {
+ var arr = toBase(n, base);
+ return (arr.isNegative ? "-" : "") + arr.value.map(function (x) {
+ return stringify(x, alphabet);
+ }).join('');
+ }
+
+ BigInteger.prototype.toArray = function (radix) {
+ return toBase(this, radix);
+ };
+
+ SmallInteger.prototype.toArray = function (radix) {
+ return toBase(this, radix);
+ };
+
+ NativeBigInt.prototype.toArray = function (radix) {
+ return toBase(this, radix);
+ };
+
+ BigInteger.prototype.toString = function (radix, alphabet) {
+ if (radix === undefined) radix = 10;
+ if (radix !== 10 || alphabet) return toBaseString(this, radix, alphabet);
+ var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit;
+ while (--l >= 0) {
+ digit = String(v[l]);
+ str += zeros.slice(digit.length) + digit;
+ }
+ var sign = this.sign ? "-" : "";
+ return sign + str;
+ };
+
+ SmallInteger.prototype.toString = function (radix, alphabet) {
+ if (radix === undefined) radix = 10;
+ if (radix != 10 || alphabet) return toBaseString(this, radix, alphabet);
+ return String(this.value);
+ };
+
+ NativeBigInt.prototype.toString = SmallInteger.prototype.toString;
+
+ NativeBigInt.prototype.toJSON = BigInteger.prototype.toJSON = SmallInteger.prototype.toJSON = function () { return this.toString(); }
+
+ BigInteger.prototype.valueOf = function () {
+ return parseInt(this.toString(), 10);
+ };
+ BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf;
+
+ SmallInteger.prototype.valueOf = function () {
+ return this.value;
+ };
+ SmallInteger.prototype.toJSNumber = SmallInteger.prototype.valueOf;
+ NativeBigInt.prototype.valueOf = NativeBigInt.prototype.toJSNumber = function () {
+ return parseInt(this.toString(), 10);
+ }
+
+ function parseStringValue(v) {
+ if (isPrecise(+v)) {
+ var x = +v;
+ if (x === truncate(x))
+ return supportsNativeBigInt ? new NativeBigInt(BigInt(x)) : new SmallInteger(x);
+ throw new Error("Invalid integer: " + v);
+ }
+ var sign = v[0] === "-";
+ if (sign) v = v.slice(1);
+ var split = v.split(/e/i);
+ if (split.length > 2) throw new Error("Invalid integer: " + split.join("e"));
+ if (split.length === 2) {
+ var exp = split[1];
+ if (exp[0] === "+") exp = exp.slice(1);
+ exp = +exp;
+ if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent.");
+ var text = split[0];
+ var decimalPlace = text.indexOf(".");
+ if (decimalPlace >= 0) {
+ exp -= text.length - decimalPlace - 1;
+ text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1);
+ }
+ if (exp < 0) throw new Error("Cannot include negative exponent part for integers");
+ text += (new Array(exp + 1)).join("0");
+ v = text;
+ }
+ var isValid = /^([0-9][0-9]*)$/.test(v);
+ if (!isValid) throw new Error("Invalid integer: " + v);
+ if (supportsNativeBigInt) {
+ return new NativeBigInt(BigInt(sign ? "-" + v : v));
+ }
+ var r = [], max = v.length, l = LOG_BASE, min = max - l;
+ while (max > 0) {
+ r.push(+v.slice(min, max));
+ min -= l;
+ if (min < 0) min = 0;
+ max -= l;
+ }
+ trim(r);
+ return new BigInteger(r, sign);
+ }
+
+ function parseNumberValue(v) {
+ if (supportsNativeBigInt) {
+ return new NativeBigInt(BigInt(v));
+ }
+ if (isPrecise(v)) {
+ if (v !== truncate(v)) throw new Error(v + " is not an integer.");
+ return new SmallInteger(v);
+ }
+ return parseStringValue(v.toString());
+ }
+
+ function parseValue(v) {
+ if (typeof v === "number") {
+ return parseNumberValue(v);
+ }
+ if (typeof v === "string") {
+ return parseStringValue(v);
+ }
+ if (typeof v === "bigint") {
+ return new NativeBigInt(v);
+ }
+ return v;
+ }
+ // Pre-define numbers in range [-999,999]
+ for (var i = 0; i < 1000; i++) {
+ Integer[i] = parseValue(i);
+ if (i > 0) Integer[-i] = parseValue(-i);
+ }
+ // Backwards compatibility
+ Integer.one = Integer[1];
+ Integer.zero = Integer[0];
+ Integer.minusOne = Integer[-1];
+ Integer.max = max;
+ Integer.min = min;
+ Integer.gcd = gcd;
+ Integer.lcm = lcm;
+ Integer.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger || x instanceof NativeBigInt; };
+ Integer.randBetween = randBetween;
+
+ Integer.fromArray = function (digits, base, isNegative) {
+ return parseBaseFromArray(digits.map(parseValue), parseValue(base || 10), isNegative);
+ };
+
+ return Integer;
+})();
+
+// Node.js check
+if (typeof module !== "undefined" && module.hasOwnProperty("exports")) {
+ module.exports = bigInt;
+}
+
+//amd check
+if (typeof define === "function" && define.amd) {
+ define( function () {
+ return bigInt;
+ });
+}
diff --git a/node_modules/big-integer/BigInteger.min.js b/node_modules/big-integer/BigInteger.min.js
new file mode 100644
index 0000000..a960fa6
--- /dev/null
+++ b/node_modules/big-integer/BigInteger.min.js
@@ -0,0 +1 @@
+var bigInt=function(undefined){"use strict";var BASE=1e7,LOG_BASE=7,MAX_INT=9007199254740992,MAX_INT_ARR=smallToArray(MAX_INT),DEFAULT_ALPHABET="0123456789abcdefghijklmnopqrstuvwxyz";var supportsNativeBigInt=typeof BigInt==="function";function Integer(v,radix,alphabet,caseSensitive){if(typeof v==="undefined")return Integer[0];if(typeof radix!=="undefined")return+radix===10&&!alphabet?parseValue(v):parseBase(v,radix,alphabet,caseSensitive);return parseValue(v)}function BigInteger(value,sign){this.value=value;this.sign=sign;this.isSmall=false}BigInteger.prototype=Object.create(Integer.prototype);function SmallInteger(value){this.value=value;this.sign=value<0;this.isSmall=true}SmallInteger.prototype=Object.create(Integer.prototype);function NativeBigInt(value){this.value=value}NativeBigInt.prototype=Object.create(Integer.prototype);function isPrecise(n){return-MAX_INT0)return Math.floor(n);return Math.ceil(n)}function add(a,b){var l_a=a.length,l_b=b.length,r=new Array(l_a),carry=0,base=BASE,sum,i;for(i=0;i=base?1:0;r[i]=sum-carry*base}while(i0)r.push(carry);return r}function addAny(a,b){if(a.length>=b.length)return add(a,b);return add(b,a)}function addSmall(a,carry){var l=a.length,r=new Array(l),base=BASE,sum,i;for(i=0;i0){r[i++]=carry%base;carry=Math.floor(carry/base)}return r}BigInteger.prototype.add=function(v){var n=parseValue(v);if(this.sign!==n.sign){return this.subtract(n.negate())}var a=this.value,b=n.value;if(n.isSmall){return new BigInteger(addSmall(a,Math.abs(b)),this.sign)}return new BigInteger(addAny(a,b),this.sign)};BigInteger.prototype.plus=BigInteger.prototype.add;SmallInteger.prototype.add=function(v){var n=parseValue(v);var a=this.value;if(a<0!==n.sign){return this.subtract(n.negate())}var b=n.value;if(n.isSmall){if(isPrecise(a+b))return new SmallInteger(a+b);b=smallToArray(Math.abs(b))}return new BigInteger(addSmall(b,Math.abs(a)),a<0)};SmallInteger.prototype.plus=SmallInteger.prototype.add;NativeBigInt.prototype.add=function(v){return new NativeBigInt(this.value+parseValue(v).value)};NativeBigInt.prototype.plus=NativeBigInt.prototype.add;function subtract(a,b){var a_l=a.length,b_l=b.length,r=new Array(a_l),borrow=0,base=BASE,i,difference;for(i=0;i=0){value=subtract(a,b)}else{value=subtract(b,a);sign=!sign}value=arrayToSmall(value);if(typeof value==="number"){if(sign)value=-value;return new SmallInteger(value)}return new BigInteger(value,sign)}function subtractSmall(a,b,sign){var l=a.length,r=new Array(l),carry=-b,base=BASE,i,difference;for(i=0;i=0)};SmallInteger.prototype.minus=SmallInteger.prototype.subtract;NativeBigInt.prototype.subtract=function(v){return new NativeBigInt(this.value-parseValue(v).value)};NativeBigInt.prototype.minus=NativeBigInt.prototype.subtract;BigInteger.prototype.negate=function(){return new BigInteger(this.value,!this.sign)};SmallInteger.prototype.negate=function(){var sign=this.sign;var small=new SmallInteger(-this.value);small.sign=!sign;return small};NativeBigInt.prototype.negate=function(){return new NativeBigInt(-this.value)};BigInteger.prototype.abs=function(){return new BigInteger(this.value,false)};SmallInteger.prototype.abs=function(){return new SmallInteger(Math.abs(this.value))};NativeBigInt.prototype.abs=function(){return new NativeBigInt(this.value>=0?this.value:-this.value)};function multiplyLong(a,b){var a_l=a.length,b_l=b.length,l=a_l+b_l,r=createArray(l),base=BASE,product,carry,i,a_i,b_j;for(i=0;i0){r[i++]=carry%base;carry=Math.floor(carry/base)}return r}function shiftLeft(x,n){var r=[];while(n-- >0)r.push(0);return r.concat(x)}function multiplyKaratsuba(x,y){var n=Math.max(x.length,y.length);if(n<=30)return multiplyLong(x,y);n=Math.ceil(n/2);var b=x.slice(n),a=x.slice(0,n),d=y.slice(n),c=y.slice(0,n);var ac=multiplyKaratsuba(a,c),bd=multiplyKaratsuba(b,d),abcd=multiplyKaratsuba(addAny(a,b),addAny(c,d));var product=addAny(addAny(ac,shiftLeft(subtract(subtract(abcd,ac),bd),n)),shiftLeft(bd,2*n));trim(product);return product}function useKaratsuba(l1,l2){return-.012*l1-.012*l2+15e-6*l1*l2>0}BigInteger.prototype.multiply=function(v){var n=parseValue(v),a=this.value,b=n.value,sign=this.sign!==n.sign,abs;if(n.isSmall){if(b===0)return Integer[0];if(b===1)return this;if(b===-1)return this.negate();abs=Math.abs(b);if(abs =0;shift--){quotientDigit=base-1;if(remainder[shift+b_l]!==divisorMostSignificantDigit){quotientDigit=Math.floor((remainder[shift+b_l]*base+remainder[shift+b_l-1])/divisorMostSignificantDigit)}carry=0;borrow=0;l=divisor.length;for(i=0;ib_l){highx=(highx+1)*base}guess=Math.ceil(highx/highy);do{check=multiplySmall(b,guess);if(compareAbs(check,part)<=0)break;guess--}while(guess);result.push(guess);part=subtract(part,check)}result.reverse();return[arrayToSmall(result),arrayToSmall(part)]}function divModSmall(value,lambda){var length=value.length,quotient=createArray(length),base=BASE,i,q,remainder,divisor;remainder=0;for(i=length-1;i>=0;--i){divisor=remainder*base+value[i];q=truncate(divisor/lambda);remainder=divisor-q*lambda;quotient[i]=q|0}return[quotient,remainder|0]}function divModAny(self,v){var value,n=parseValue(v);if(supportsNativeBigInt){return[new NativeBigInt(self.value/n.value),new NativeBigInt(self.value%n.value)]}var a=self.value,b=n.value;var quotient;if(b===0)throw new Error("Cannot divide by zero");if(self.isSmall){if(n.isSmall){return[new SmallInteger(truncate(a/b)),new SmallInteger(a%b)]}return[Integer[0],self]}if(n.isSmall){if(b===1)return[self,Integer[0]];if(b==-1)return[self.negate(),Integer[0]];var abs=Math.abs(b);if(abs b.length?1:-1}for(var i=a.length-1;i>=0;i--){if(a[i]!==b[i])return a[i]>b[i]?1:-1}return 0}BigInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=this.value,b=n.value;if(n.isSmall)return 1;return compareAbs(a,b)};SmallInteger.prototype.compareAbs=function(v){var n=parseValue(v),a=Math.abs(this.value),b=n.value;if(n.isSmall){b=Math.abs(b);return a===b?0:a>b?1:-1}return-1};NativeBigInt.prototype.compareAbs=function(v){var a=this.value;var b=parseValue(v).value;a=a>=0?a:-a;b=b>=0?b:-b;return a===b?0:a>b?1:-1};BigInteger.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var n=parseValue(v),a=this.value,b=n.value;if(this.sign!==n.sign){return n.sign?1:-1}if(n.isSmall){return this.sign?-1:1}return compareAbs(a,b)*(this.sign?-1:1)};BigInteger.prototype.compareTo=BigInteger.prototype.compare;SmallInteger.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var n=parseValue(v),a=this.value,b=n.value;if(n.isSmall){return a==b?0:a>b?1:-1}if(a<0!==n.sign){return a<0?-1:1}return a<0?1:-1};SmallInteger.prototype.compareTo=SmallInteger.prototype.compare;NativeBigInt.prototype.compare=function(v){if(v===Infinity){return-1}if(v===-Infinity){return 1}var a=this.value;var b=parseValue(v).value;return a===b?0:a>b?1:-1};NativeBigInt.prototype.compareTo=NativeBigInt.prototype.compare;BigInteger.prototype.equals=function(v){return this.compare(v)===0};NativeBigInt.prototype.eq=NativeBigInt.prototype.equals=SmallInteger.prototype.eq=SmallInteger.prototype.equals=BigInteger.prototype.eq=BigInteger.prototype.equals;BigInteger.prototype.notEquals=function(v){return this.compare(v)!==0};NativeBigInt.prototype.neq=NativeBigInt.prototype.notEquals=SmallInteger.prototype.neq=SmallInteger.prototype.notEquals=BigInteger.prototype.neq=BigInteger.prototype.notEquals;BigInteger.prototype.greater=function(v){return this.compare(v)>0};NativeBigInt.prototype.gt=NativeBigInt.prototype.greater=SmallInteger.prototype.gt=SmallInteger.prototype.greater=BigInteger.prototype.gt=BigInteger.prototype.greater;BigInteger.prototype.lesser=function(v){return this.compare(v)<0};NativeBigInt.prototype.lt=NativeBigInt.prototype.lesser=SmallInteger.prototype.lt=SmallInteger.prototype.lesser=BigInteger.prototype.lt=BigInteger.prototype.lesser;BigInteger.prototype.greaterOrEquals=function(v){return this.compare(v)>=0};NativeBigInt.prototype.geq=NativeBigInt.prototype.greaterOrEquals=SmallInteger.prototype.geq=SmallInteger.prototype.greaterOrEquals=BigInteger.prototype.geq=BigInteger.prototype.greaterOrEquals;BigInteger.prototype.lesserOrEquals=function(v){return this.compare(v)<=0};NativeBigInt.prototype.leq=NativeBigInt.prototype.lesserOrEquals=SmallInteger.prototype.leq=SmallInteger.prototype.lesserOrEquals=BigInteger.prototype.leq=BigInteger.prototype.lesserOrEquals;BigInteger.prototype.isEven=function(){return(this.value[0]&1)===0};SmallInteger.prototype.isEven=function(){return(this.value&1)===0};NativeBigInt.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)};BigInteger.prototype.isOdd=function(){return(this.value[0]&1)===1};SmallInteger.prototype.isOdd=function(){return(this.value&1)===1};NativeBigInt.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)};BigInteger.prototype.isPositive=function(){return!this.sign};SmallInteger.prototype.isPositive=function(){return this.value>0};NativeBigInt.prototype.isPositive=SmallInteger.prototype.isPositive;BigInteger.prototype.isNegative=function(){return this.sign};SmallInteger.prototype.isNegative=function(){return this.value<0};NativeBigInt.prototype.isNegative=SmallInteger.prototype.isNegative;BigInteger.prototype.isUnit=function(){return false};SmallInteger.prototype.isUnit=function(){return Math.abs(this.value)===1};NativeBigInt.prototype.isUnit=function(){return this.abs().value===BigInt(1)};BigInteger.prototype.isZero=function(){return false};SmallInteger.prototype.isZero=function(){return this.value===0};NativeBigInt.prototype.isZero=function(){return this.value===BigInt(0)};BigInteger.prototype.isDivisibleBy=function(v){var n=parseValue(v);if(n.isZero())return false;if(n.isUnit())return true;if(n.compareAbs(2)===0)return this.isEven();return this.mod(n).isZero()};NativeBigInt.prototype.isDivisibleBy=SmallInteger.prototype.isDivisibleBy=BigInteger.prototype.isDivisibleBy;function isBasicPrime(v){var n=v.abs();if(n.isUnit())return false;if(n.equals(2)||n.equals(3)||n.equals(5))return true;if(n.isEven()||n.isDivisibleBy(3)||n.isDivisibleBy(5))return false;if(n.lesser(49))return true}function millerRabinTest(n,a){var nPrev=n.prev(),b=nPrev,r=0,d,t,i,x;while(b.isEven())b=b.divide(2),r++;next:for(i=0;i-MAX_INT)return new SmallInteger(value-1);return new BigInteger(MAX_INT_ARR,true)};NativeBigInt.prototype.prev=function(){return new NativeBigInt(this.value-BigInt(1))};var powersOfTwo=[1];while(2*powersOfTwo[powersOfTwo.length-1]<=BASE)powersOfTwo.push(2*powersOfTwo[powersOfTwo.length-1]);var powers2Length=powersOfTwo.length,highestPower2=powersOfTwo[powers2Length-1];function shift_isSmall(n){return Math.abs(n)<=BASE}BigInteger.prototype.shiftLeft=function(v){var n=parseValue(v).toJSNumber();if(!shift_isSmall(n)){throw new Error(String(n)+" is too large for shifting.")}if(n<0)return this.shiftRight(-n);var result=this;if(result.isZero())return result;while(n>=powers2Length){result=result.multiply(highestPower2);n-=powers2Length-1}return result.multiply(powersOfTwo[n])};NativeBigInt.prototype.shiftLeft=SmallInteger.prototype.shiftLeft=BigInteger.prototype.shiftLeft;BigInteger.prototype.shiftRight=function(v){var remQuo;var n=parseValue(v).toJSNumber();if(!shift_isSmall(n)){throw new Error(String(n)+" is too large for shifting.")}if(n<0)return this.shiftLeft(-n);var result=this;while(n>=powers2Length){if(result.isZero()||result.isNegative()&&result.isUnit())return result;remQuo=divModAny(result,highestPower2);result=remQuo[1].isNegative()?remQuo[0].prev():remQuo[0];n-=powers2Length-1}remQuo=divModAny(result,powersOfTwo[n]);return remQuo[1].isNegative()?remQuo[0].prev():remQuo[0]};NativeBigInt.prototype.shiftRight=SmallInteger.prototype.shiftRight=BigInteger.prototype.shiftRight;function bitwise(x,y,fn){y=parseValue(y);var xSign=x.isNegative(),ySign=y.isNegative();var xRem=xSign?x.not():x,yRem=ySign?y.not():y;var xDigit=0,yDigit=0;var xDivMod=null,yDivMod=null;var result=[];while(!xRem.isZero()||!yRem.isZero()){xDivMod=divModAny(xRem,highestPower2);xDigit=xDivMod[1].toJSNumber();if(xSign){xDigit=highestPower2-1-xDigit}yDivMod=divModAny(yRem,highestPower2);yDigit=yDivMod[1].toJSNumber();if(ySign){yDigit=highestPower2-1-yDigit}xRem=xDivMod[0];yRem=yDivMod[0];result.push(fn(xDigit,yDigit))}var sum=fn(xSign?1:0,ySign?1:0)!==0?bigInt(-1):bigInt(0);for(var i=result.length-1;i>=0;i-=1){sum=sum.multiply(highestPower2).add(bigInt(result[i]))}return sum}BigInteger.prototype.not=function(){return this.negate().prev()};NativeBigInt.prototype.not=SmallInteger.prototype.not=BigInteger.prototype.not;BigInteger.prototype.and=function(n){return bitwise(this,n,function(a,b){return a&b})};NativeBigInt.prototype.and=SmallInteger.prototype.and=BigInteger.prototype.and;BigInteger.prototype.or=function(n){return bitwise(this,n,function(a,b){return a|b})};NativeBigInt.prototype.or=SmallInteger.prototype.or=BigInteger.prototype.or;BigInteger.prototype.xor=function(n){return bitwise(this,n,function(a,b){return a^b})};NativeBigInt.prototype.xor=SmallInteger.prototype.xor=BigInteger.prototype.xor;var LOBMASK_I=1<<30,LOBMASK_BI=(BASE&-BASE)*(BASE&-BASE)|LOBMASK_I;function roughLOB(n){var v=n.value,x=typeof v==="number"?v|LOBMASK_I:typeof v==="bigint"?v|BigInt(LOBMASK_I):v[0]+v[1]*BASE|LOBMASK_BI;return x&-x}function integerLogarithm(value,base){if(base.compareTo(value)<=0){var tmp=integerLogarithm(value,base.square(base));var p=tmp.p;var e=tmp.e;var t=p.multiply(base);return t.compareTo(value)<=0?{p:t,e:e*2+1}:{p:p,e:e*2}}return{p:bigInt(1),e:0}}BigInteger.prototype.bitLength=function(){var n=this;if(n.compareTo(bigInt(0))<0){n=n.negate().subtract(bigInt(1))}if(n.compareTo(bigInt(0))===0){return bigInt(0)}return bigInt(integerLogarithm(n,bigInt(2)).e).add(bigInt(1))};NativeBigInt.prototype.bitLength=SmallInteger.prototype.bitLength=BigInteger.prototype.bitLength;function max(a,b){a=parseValue(a);b=parseValue(b);return a.greater(b)?a:b}function min(a,b){a=parseValue(a);b=parseValue(b);return a.lesser(b)?a:b}function gcd(a,b){a=parseValue(a).abs();b=parseValue(b).abs();if(a.equals(b))return a;if(a.isZero())return b;if(b.isZero())return a;var c=Integer[1],d,t;while(a.isEven()&&b.isEven()){d=min(roughLOB(a),roughLOB(b));a=a.divide(d);b=b.divide(d);c=c.multiply(d)}while(a.isEven()){a=a.divide(roughLOB(a))}do{while(b.isEven()){b=b.divide(roughLOB(b))}if(a.greater(b)){t=b;b=a;a=t}b=b.subtract(a)}while(!b.isZero());return c.isUnit()?a:a.multiply(c)}function lcm(a,b){a=parseValue(a).abs();b=parseValue(b).abs();return a.divide(gcd(a,b)).multiply(b)}function randBetween(a,b,rng){a=parseValue(a);b=parseValue(b);var usedRNG=rng||Math.random;var low=min(a,b),high=max(a,b);var range=high.subtract(low).add(1);if(range.isSmall)return low.add(Math.floor(usedRNG()*range));var digits=toBase(range,BASE).value;var result=[],restricted=true;for(var i=0;i=absBase){if(c==="1"&&absBase===1)continue;throw new Error(c+" is not a valid digit in base "+base+".")}}}base=parseValue(base);var digits=[];var isNegative=text[0]==="-";for(i=isNegative?1:0;i"&&i=0;i--){val=val.add(digits[i].times(pow));pow=pow.times(base)}return isNegative?val.negate():val}function stringify(digit,alphabet){alphabet=alphabet||DEFAULT_ALPHABET;if(digit"}function toBase(n,base){base=bigInt(base);if(base.isZero()){if(n.isZero())return{value:[0],isNegative:false};throw new Error("Cannot convert nonzero numbers to base 0.")}if(base.equals(-1)){if(n.isZero())return{value:[0],isNegative:false};if(n.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-n.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:false};var arr=Array.apply(null,Array(n.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);arr.unshift([1]);return{value:[].concat.apply([],arr),isNegative:false}}var neg=false;if(n.isNegative()&&base.isPositive()){neg=true;n=n.abs()}if(base.isUnit()){if(n.isZero())return{value:[0],isNegative:false};return{value:Array.apply(null,Array(n.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:neg}}var out=[];var left=n,divmod;while(left.isNegative()||left.compareAbs(base)>=0){divmod=left.divmod(base);left=divmod.quotient;var digit=divmod.remainder;if(digit.isNegative()){digit=base.minus(digit).abs();left=left.next()}out.push(digit.toJSNumber())}out.push(left.toJSNumber());return{value:out.reverse(),isNegative:neg}}function toBaseString(n,base,alphabet){var arr=toBase(n,base);return(arr.isNegative?"-":"")+arr.value.map(function(x){return stringify(x,alphabet)}).join("")}BigInteger.prototype.toArray=function(radix){return toBase(this,radix)};SmallInteger.prototype.toArray=function(radix){return toBase(this,radix)};NativeBigInt.prototype.toArray=function(radix){return toBase(this,radix)};BigInteger.prototype.toString=function(radix,alphabet){if(radix===undefined)radix=10;if(radix!==10||alphabet)return toBaseString(this,radix,alphabet);var v=this.value,l=v.length,str=String(v[--l]),zeros="0000000",digit;while(--l>=0){digit=String(v[l]);str+=zeros.slice(digit.length)+digit}var sign=this.sign?"-":"";return sign+str};SmallInteger.prototype.toString=function(radix,alphabet){if(radix===undefined)radix=10;if(radix!=10||alphabet)return toBaseString(this,radix,alphabet);return String(this.value)};NativeBigInt.prototype.toString=SmallInteger.prototype.toString;NativeBigInt.prototype.toJSON=BigInteger.prototype.toJSON=SmallInteger.prototype.toJSON=function(){return this.toString()};BigInteger.prototype.valueOf=function(){return parseInt(this.toString(),10)};BigInteger.prototype.toJSNumber=BigInteger.prototype.valueOf;SmallInteger.prototype.valueOf=function(){return this.value};SmallInteger.prototype.toJSNumber=SmallInteger.prototype.valueOf;NativeBigInt.prototype.valueOf=NativeBigInt.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};function parseStringValue(v){if(isPrecise(+v)){var x=+v;if(x===truncate(x))return supportsNativeBigInt?new NativeBigInt(BigInt(x)):new SmallInteger(x);throw new Error("Invalid integer: "+v)}var sign=v[0]==="-";if(sign)v=v.slice(1);var split=v.split(/e/i);if(split.length>2)throw new Error("Invalid integer: "+split.join("e"));if(split.length===2){var exp=split[1];if(exp[0]==="+")exp=exp.slice(1);exp=+exp;if(exp!==truncate(exp)||!isPrecise(exp))throw new Error("Invalid integer: "+exp+" is not a valid exponent.");var text=split[0];var decimalPlace=text.indexOf(".");if(decimalPlace>=0){exp-=text.length-decimalPlace-1;text=text.slice(0,decimalPlace)+text.slice(decimalPlace+1)}if(exp<0)throw new Error("Cannot include negative exponent part for integers");text+=new Array(exp+1).join("0");v=text}var isValid=/^([0-9][0-9]*)$/.test(v);if(!isValid)throw new Error("Invalid integer: "+v);if(supportsNativeBigInt){return new NativeBigInt(BigInt(sign?"-"+v:v))}var r=[],max=v.length,l=LOG_BASE,min=max-l;while(max>0){r.push(+v.slice(min,max));min-=l;if(min<0)min=0;max-=l}trim(r);return new BigInteger(r,sign)}function parseNumberValue(v){if(supportsNativeBigInt){return new NativeBigInt(BigInt(v))}if(isPrecise(v)){if(v!==truncate(v))throw new Error(v+" is not an integer.");return new SmallInteger(v)}return parseStringValue(v.toString())}function parseValue(v){if(typeof v==="number"){return parseNumberValue(v)}if(typeof v==="string"){return parseStringValue(v)}if(typeof v==="bigint"){return new NativeBigInt(v)}return v}for(var i=0;i<1e3;i++){Integer[i]=parseValue(i);if(i>0)Integer[-i]=parseValue(-i)}Integer.one=Integer[1];Integer.zero=Integer[0];Integer.minusOne=Integer[-1];Integer.max=max;Integer.min=min;Integer.gcd=gcd;Integer.lcm=lcm;Integer.isInstance=function(x){return x instanceof BigInteger||x instanceof SmallInteger||x instanceof NativeBigInt};Integer.randBetween=randBetween;Integer.fromArray=function(digits,base,isNegative){return parseBaseFromArray(digits.map(parseValue),parseValue(base||10),isNegative)};return Integer}();if(typeof module!=="undefined"&&module.hasOwnProperty("exports")){module.exports=bigInt}if(typeof define==="function"&&define.amd){define(function(){return bigInt})}
\ No newline at end of file
diff --git a/node_modules/big-integer/LICENSE b/node_modules/big-integer/LICENSE
new file mode 100644
index 0000000..3ce22da
--- /dev/null
+++ b/node_modules/big-integer/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+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 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.
+
+For more information, please refer to
diff --git a/node_modules/big-integer/README.md b/node_modules/big-integer/README.md
new file mode 100644
index 0000000..42a6cd4
--- /dev/null
+++ b/node_modules/big-integer/README.md
@@ -0,0 +1,589 @@
+# BigInteger.js [![Build Status][travis-img]][travis-url] [![Coverage Status][coveralls-img]][coveralls-url] [![Monthly Downloads][downloads-img]][downloads-url]
+
+[travis-url]: https://travis-ci.org/peterolson/BigInteger.js
+[travis-img]: https://travis-ci.org/peterolson/BigInteger.js.svg?branch=master
+[coveralls-url]: https://coveralls.io/github/peterolson/BigInteger.js?branch=master
+[coveralls-img]: https://coveralls.io/repos/peterolson/BigInteger.js/badge.svg?branch=master&service=github
+[downloads-url]: https://www.npmjs.com/package/big-integer
+[downloads-img]: https://img.shields.io/npm/dm/big-integer.svg
+
+**BigInteger.js** is an arbitrary-length integer library for Javascript, allowing arithmetic operations on integers of unlimited size, notwithstanding memory and time limitations.
+
+**Update (December 2, 2018):** [`BigInt` is being added as a native feature of JavaScript](https://tc39.github.io/proposal-bigint/). This library now works as a polyfill: if the environment supports the native `BigInt`, this library acts as a thin wrapper over the native implementation.
+
+## Installation
+
+If you are using a browser, you can download [BigInteger.js from GitHub](http://peterolson.github.com/BigInteger.js/BigInteger.min.js) or just hotlink to it:
+
+
+
+If you are using node, you can install BigInteger with [npm](https://npmjs.org/).
+
+ npm install big-integer
+
+Then you can include it in your code:
+
+ var bigInt = require("big-integer");
+
+
+## Usage
+### `bigInt(number, [base], [alphabet], [caseSensitive])`
+
+You can create a bigInt by calling the `bigInt` function. You can pass in
+
+ - a string, which it will parse as an bigInt and throw an `"Invalid integer"` error if the parsing fails.
+ - a Javascript number, which it will parse as an bigInt and throw an `"Invalid integer"` error if the parsing fails.
+ - another bigInt.
+ - nothing, and it will return `bigInt.zero`.
+
+ If you provide a second parameter, then it will parse `number` as a number in base `base`. Note that `base` can be any bigInt (even negative or zero). The letters "a-z" and "A-Z" will be interpreted as the numbers 10 to 35. Higher digits can be specified in angle brackets (`<` and `>`). The default `base` is `10`.
+
+ You can specify a custom alphabet for base conversion with the third parameter. The default `alphabet` is `"0123456789abcdefghijklmnopqrstuvwxyz"`.
+
+ The fourth parameter specifies whether or not the number string should be case-sensitive, i.e. whether `a` and `A` should be treated as different digits. By default `caseSensitive` is `false`.
+
+Examples:
+
+ var zero = bigInt();
+ var ninetyThree = bigInt(93);
+ var largeNumber = bigInt("75643564363473453456342378564387956906736546456235345");
+ var googol = bigInt("1e100");
+ var bigNumber = bigInt(largeNumber);
+
+ var maximumByte = bigInt("FF", 16);
+ var fiftyFiveGoogol = bigInt("<55>0", googol);
+
+Note that Javascript numbers larger than `9007199254740992` and smaller than `-9007199254740992` are not precisely represented numbers and will not produce exact results. If you are dealing with numbers outside that range, it is better to pass in strings.
+
+### Method Chaining
+
+Note that bigInt operations return bigInts, which allows you to chain methods, for example:
+
+ var salary = bigInt(dollarsPerHour).times(hoursWorked).plus(randomBonuses)
+
+### Constants
+
+There are three named constants already stored that you do not have to construct with the `bigInt` function yourself:
+
+ - `bigInt.one`, equivalent to `bigInt(1)`
+ - `bigInt.zero`, equivalent to `bigInt(0)`
+ - `bigInt.minusOne`, equivalent to `bigInt(-1)`
+
+The numbers from -999 to 999 are also already prestored and can be accessed using `bigInt[index]`, for example:
+
+ - `bigInt[-999]`, equivalent to `bigInt(-999)`
+ - `bigInt[256]`, equivalent to `bigInt(256)`
+
+### Methods
+
+#### `abs()`
+
+Returns the absolute value of a bigInt.
+
+ - `bigInt(-45).abs()` => `45`
+ - `bigInt(45).abs()` => `45`
+
+#### `add(number)`
+
+Performs addition.
+
+ - `bigInt(5).add(7)` => `12`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Addition)
+
+#### `and(number)`
+
+Performs the bitwise AND operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).
+
+ - `bigInt(6).and(3)` => `2`
+ - `bigInt(6).and(-3)` => `4`
+
+#### `bitLength()`
+
+Returns the number of digits required to represent a bigInt in binary.
+
+ - `bigInt(5)` => `3` (since 5 is `101` in binary, which is three digits long)
+
+#### `compare(number)`
+
+Performs a comparison between two numbers. If the numbers are equal, it returns `0`. If the first number is greater, it returns `1`. If the first number is lesser, it returns `-1`.
+
+ - `bigInt(5).compare(5)` => `0`
+ - `bigInt(5).compare(4)` => `1`
+ - `bigInt(4).compare(5)` => `-1`
+
+#### `compareAbs(number)`
+
+Performs a comparison between the absolute value of two numbers.
+
+ - `bigInt(5).compareAbs(-5)` => `0`
+ - `bigInt(5).compareAbs(4)` => `1`
+ - `bigInt(4).compareAbs(-5)` => `-1`
+
+#### `compareTo(number)`
+
+Alias for the `compare` method.
+
+#### `divide(number)`
+
+Performs integer division, disregarding the remainder.
+
+ - `bigInt(59).divide(5)` => `11`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
+
+#### `divmod(number)`
+
+Performs division and returns an object with two properties: `quotient` and `remainder`. The sign of the remainder will match the sign of the dividend.
+
+ - `bigInt(59).divmod(5)` => `{quotient: bigInt(11), remainder: bigInt(4) }`
+ - `bigInt(-5).divmod(2)` => `{quotient: bigInt(-2), remainder: bigInt(-1) }`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
+
+#### `eq(number)`
+
+Alias for the `equals` method.
+
+#### `equals(number)`
+
+Checks if two numbers are equal.
+
+ - `bigInt(5).equals(5)` => `true`
+ - `bigInt(4).equals(7)` => `false`
+
+#### `geq(number)`
+
+Alias for the `greaterOrEquals` method.
+
+
+#### `greater(number)`
+
+Checks if the first number is greater than the second.
+
+ - `bigInt(5).greater(6)` => `false`
+ - `bigInt(5).greater(5)` => `false`
+ - `bigInt(5).greater(4)` => `true`
+
+#### `greaterOrEquals(number)`
+
+Checks if the first number is greater than or equal to the second.
+
+ - `bigInt(5).greaterOrEquals(6)` => `false`
+ - `bigInt(5).greaterOrEquals(5)` => `true`
+ - `bigInt(5).greaterOrEquals(4)` => `true`
+
+#### `gt(number)`
+
+Alias for the `greater` method.
+
+#### `isDivisibleBy(number)`
+
+Returns `true` if the first number is divisible by the second number, `false` otherwise.
+
+ - `bigInt(999).isDivisibleBy(333)` => `true`
+ - `bigInt(99).isDivisibleBy(5)` => `false`
+
+#### `isEven()`
+
+Returns `true` if the number is even, `false` otherwise.
+
+ - `bigInt(6).isEven()` => `true`
+ - `bigInt(3).isEven()` => `false`
+
+#### `isNegative()`
+
+Returns `true` if the number is negative, `false` otherwise.
+Returns `false` for `0` and `-0`.
+
+ - `bigInt(-23).isNegative()` => `true`
+ - `bigInt(50).isNegative()` => `false`
+
+#### `isOdd()`
+
+Returns `true` if the number is odd, `false` otherwise.
+
+ - `bigInt(13).isOdd()` => `true`
+ - `bigInt(40).isOdd()` => `false`
+
+#### `isPositive()`
+
+Return `true` if the number is positive, `false` otherwise.
+Returns `false` for `0` and `-0`.
+
+ - `bigInt(54).isPositive()` => `true`
+ - `bigInt(-1).isPositive()` => `false`
+
+#### `isPrime(strict?)`
+
+Returns `true` if the number is prime, `false` otherwise.
+Set "strict" boolean to true to force GRH-supported lower bound of 2*log(N)^2.
+
+ - `bigInt(5).isPrime()` => `true`
+ - `bigInt(6).isPrime()` => `false`
+
+#### `isProbablePrime([iterations], [rng])`
+
+Returns `true` if the number is very likely to be prime, `false` otherwise.
+Supplying `iterations` is optional - it determines the number of iterations of the test (default: `5`). The more iterations, the lower chance of getting a false positive.
+This uses the [Miller Rabin test](https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test).
+
+ - `bigInt(5).isProbablePrime()` => `true`
+ - `bigInt(49).isProbablePrime()` => `false`
+ - `bigInt(1729).isProbablePrime()` => `false`
+
+Note that this function is not deterministic, since it relies on random sampling of factors, so the result for some numbers is not always the same - unless you pass a predictable random number generator as `rng`. The behavior and requirements are the same as with `randBetween`.
+
+ - `bigInt(1729).isProbablePrime(1, () => 0.1)` => `false`
+ - `bigInt(1729).isProbablePrime(1, () => 0.2)` => `true`
+
+If the number is composite then the Miller–Rabin primality test declares the number probably prime with a probability at most `4` to the power `−iterations`.
+If the number is prime, this function always returns `true`.
+
+#### `isUnit()`
+
+Returns `true` if the number is `1` or `-1`, `false` otherwise.
+
+ - `bigInt.one.isUnit()` => `true`
+ - `bigInt.minusOne.isUnit()` => `true`
+ - `bigInt(5).isUnit()` => `false`
+
+#### `isZero()`
+
+Return `true` if the number is `0` or `-0`, `false` otherwise.
+
+ - `bigInt.zero.isZero()` => `true`
+ - `bigInt("-0").isZero()` => `true`
+ - `bigInt(50).isZero()` => `false`
+
+#### `leq(number)`
+
+Alias for the `lesserOrEquals` method.
+
+#### `lesser(number)`
+
+Checks if the first number is lesser than the second.
+
+ - `bigInt(5).lesser(6)` => `true`
+ - `bigInt(5).lesser(5)` => `false`
+ - `bigInt(5).lesser(4)` => `false`
+
+#### `lesserOrEquals(number)`
+
+Checks if the first number is less than or equal to the second.
+
+ - `bigInt(5).lesserOrEquals(6)` => `true`
+ - `bigInt(5).lesserOrEquals(5)` => `true`
+ - `bigInt(5).lesserOrEquals(4)` => `false`
+
+#### `lt(number)`
+
+Alias for the `lesser` method.
+
+#### `minus(number)`
+
+Alias for the `subtract` method.
+
+ - `bigInt(3).minus(5)` => `-2`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Subtraction)
+
+#### `mod(number)`
+
+Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend.
+
+ - `bigInt(59).mod(5)` => `4`
+ - `bigInt(-5).mod(2)` => `-1`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
+
+#### `modInv(mod)`
+
+Finds the [multiplicative inverse](https://en.wikipedia.org/wiki/Modular_multiplicative_inverse) of the number modulo `mod`.
+
+ - `bigInt(3).modInv(11)` => `4`
+ - `bigInt(42).modInv(2017)` => `1969`
+
+#### `modPow(exp, mod)`
+
+Takes the number to the power `exp` modulo `mod`.
+
+ - `bigInt(10).modPow(3, 30)` => `10`
+
+#### `multiply(number)`
+
+Performs multiplication.
+
+ - `bigInt(111).multiply(111)` => `12321`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Multiplication)
+
+#### `neq(number)`
+
+Alias for the `notEquals` method.
+
+#### `next()`
+
+Adds one to the number.
+
+ - `bigInt(6).next()` => `7`
+
+#### `not()`
+
+Performs the bitwise NOT operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).
+
+ - `bigInt(10).not()` => `-11`
+ - `bigInt(0).not()` => `-1`
+
+#### `notEquals(number)`
+
+Checks if two numbers are not equal.
+
+ - `bigInt(5).notEquals(5)` => `false`
+ - `bigInt(4).notEquals(7)` => `true`
+
+#### `or(number)`
+
+Performs the bitwise OR operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).
+
+ - `bigInt(13).or(10)` => `15`
+ - `bigInt(13).or(-8)` => `-3`
+
+#### `over(number)`
+
+Alias for the `divide` method.
+
+ - `bigInt(59).over(5)` => `11`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
+
+#### `plus(number)`
+
+Alias for the `add` method.
+
+ - `bigInt(5).plus(7)` => `12`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Addition)
+
+#### `pow(number)`
+
+Performs exponentiation. If the exponent is less than `0`, `pow` returns `0`. `bigInt.zero.pow(0)` returns `1`.
+
+ - `bigInt(16).pow(16)` => `18446744073709551616`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Exponentiation)
+
+#### `prev(number)`
+
+Subtracts one from the number.
+
+ - `bigInt(6).prev()` => `5`
+
+#### `remainder(number)`
+
+Alias for the `mod` method.
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
+
+#### `shiftLeft(n)`
+
+Shifts the number left by `n` places in its binary representation. If a negative number is provided, it will shift right. Throws an error if `n` is outside of the range `[-9007199254740992, 9007199254740992]`.
+
+ - `bigInt(8).shiftLeft(2)` => `32`
+ - `bigInt(8).shiftLeft(-2)` => `2`
+
+#### `shiftRight(n)`
+
+Shifts the number right by `n` places in its binary representation. If a negative number is provided, it will shift left. Throws an error if `n` is outside of the range `[-9007199254740992, 9007199254740992]`.
+
+ - `bigInt(8).shiftRight(2)` => `2`
+ - `bigInt(8).shiftRight(-2)` => `32`
+
+#### `square()`
+
+Squares the number
+
+ - `bigInt(3).square()` => `9`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Squaring)
+
+#### `subtract(number)`
+
+Performs subtraction.
+
+ - `bigInt(3).subtract(5)` => `-2`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Subtraction)
+
+#### `times(number)`
+
+Alias for the `multiply` method.
+
+ - `bigInt(111).times(111)` => `12321`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Multiplication)
+
+#### `toArray(radix)`
+
+Converts a bigInt into an object with the properties "value" and "isNegative." "Value" is an array of integers modulo the given radix. "isNegative" is a boolean that represents the sign of the result.
+
+ - `bigInt("1e9").toArray(10)` => {
+ value: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ isNegative: false
+ }
+ - `bigInt("1e9").toArray(16)` => {
+ value: [3, 11, 9, 10, 12, 10, 0, 0],
+ isNegative: false
+ }
+ - `bigInt(567890).toArray(100)` => {
+ value: [56, 78, 90],
+ isNegative: false
+ }
+
+Negative bases are supported.
+
+ - `bigInt(12345).toArray(-10)` => {
+ value: [2, 8, 4, 6, 5],
+ isNegative: false
+ }
+
+Base 1 and base -1 are also supported.
+
+ - `bigInt(-15).toArray(1)` => {
+ value: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
+ isNegative: true
+ }
+ - `bigInt(-15).toArray(-1)` => {
+ value: [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
+ 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],
+ isNegative: false
+ }
+
+Base 0 is only allowed for the number zero.
+
+ - `bigInt(0).toArray(0)` => {
+ value: [0],
+ isNegative: false
+ }
+ - `bigInt(1).toArray(0)` => `Error: Cannot convert nonzero numbers to base 0.`
+
+#### `toJSNumber()`
+
+Converts a bigInt into a native Javascript number. Loses precision for numbers outside the range `[-9007199254740992, 9007199254740992]`.
+
+ - `bigInt("18446744073709551616").toJSNumber()` => `18446744073709552000`
+
+#### `xor(number)`
+
+Performs the bitwise XOR operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).
+
+ - `bigInt(12).xor(5)` => `9`
+ - `bigInt(12).xor(-5)` => `-9`
+
+### Static Methods
+
+#### `fromArray(digits, base = 10, isNegative?)`
+
+Constructs a bigInt from an array of digits in base `base`. The optional `isNegative` flag will make the number negative.
+
+ - `bigInt.fromArray([1, 2, 3, 4, 5], 10)` => `12345`
+ - `bigInt.fromArray([1, 0, 0], 2, true)` => `-4`
+
+#### `gcd(a, b)`
+
+Finds the greatest common denominator of `a` and `b`.
+
+ - `bigInt.gcd(42,56)` => `14`
+
+#### `isInstance(x)`
+
+Returns `true` if `x` is a BigInteger, `false` otherwise.
+
+ - `bigInt.isInstance(bigInt(14))` => `true`
+ - `bigInt.isInstance(14)` => `false`
+
+#### `lcm(a,b)`
+
+Finds the least common multiple of `a` and `b`.
+
+ - `bigInt.lcm(21, 6)` => `42`
+
+#### `max(a,b)`
+
+Returns the largest of `a` and `b`.
+
+ - `bigInt.max(77, 432)` => `432`
+
+#### `min(a,b)`
+
+Returns the smallest of `a` and `b`.
+
+ - `bigInt.min(77, 432)` => `77`
+
+#### `randBetween(min, max, [rng])`
+
+Returns a random number between `min` and `max`, optionally using `rng` to generate randomness.
+
+ - `bigInt.randBetween("-1e100", "1e100")` => (for example) `8494907165436643479673097939554427056789510374838494147955756275846226209006506706784609314471378745`
+
+`rng` should take no arguments and return a `number` between 0 and 1. It defaults to `Math.random`.
+
+ - `bigInt.randBetween("-1e100", "1e100", () => 0.5)` => (always) `50000005000000500000050000005000000500000050000005000000500000050000005000000500000050000005000000`
+
+
+### Override Methods
+
+#### `toString(radix = 10, [alphabet])`
+
+Converts a bigInt to a string. There is an optional radix parameter (which defaults to 10) that converts the number to the given radix. Digits in the range `10-35` will use the letters `a-z`.
+
+ - `bigInt("1e9").toString()` => `"1000000000"`
+ - `bigInt("1e9").toString(16)` => `"3b9aca00"`
+
+ You can use a custom base alphabet with the second parameter. The default `alphabet` is `"0123456789abcdefghijklmnopqrstuvwxyz"`.
+
+ - `bigInt("5").toString(2, "aA")` => `"AaA"`
+
+**Note that arithmetical operators will trigger the `valueOf` function rather than the `toString` function.** When converting a bigInteger to a string, you should use the `toString` method or the `String` function instead of adding the empty string.
+
+ - `bigInt("999999999999999999").toString()` => `"999999999999999999"`
+ - `String(bigInt("999999999999999999"))` => `"999999999999999999"`
+ - `bigInt("999999999999999999") + ""` => `1000000000000000000`
+
+Bases larger than 36 are supported. If a digit is greater than or equal to 36, it will be enclosed in angle brackets.
+
+ - `bigInt(567890).toString(100)` => `"<56><78><90>"`
+
+Negative bases are also supported.
+
+ - `bigInt(12345).toString(-10)` => `"28465"`
+
+Base 1 and base -1 are also supported.
+
+ - `bigInt(-15).toString(1)` => `"-111111111111111"`
+ - `bigInt(-15).toString(-1)` => `"101010101010101010101010101010"`
+
+Base 0 is only allowed for the number zero.
+
+ - `bigInt(0).toString(0)` => `0`
+ - `bigInt(1).toString(0)` => `Error: Cannot convert nonzero numbers to base 0.`
+
+[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#toString)
+
+#### `valueOf()`
+
+Converts a bigInt to a native Javascript number. This override allows you to use native arithmetic operators without explicit conversion:
+
+ - `bigInt("100") + bigInt("200") === 300; //true`
+
+## Contributors
+
+To contribute, just fork the project, make some changes, and submit a pull request. Please verify that the unit tests pass before submitting.
+
+The unit tests are contained in the `spec/spec.js` file. You can run them locally by opening the `spec/SpecRunner.html` or file or running `npm test`. You can also [run the tests online from GitHub](http://peterolson.github.io/BigInteger.js/spec/SpecRunner.html).
+
+There are performance benchmarks that can be viewed from the `benchmarks/index.html` page. You can [run them online from GitHub](http://peterolson.github.io/BigInteger.js/benchmark/).
+
+## License
+
+This project is public domain. For more details, read about the [Unlicense](http://unlicense.org/).
diff --git a/node_modules/big-integer/bower.json b/node_modules/big-integer/bower.json
new file mode 100644
index 0000000..c744605
--- /dev/null
+++ b/node_modules/big-integer/bower.json
@@ -0,0 +1,29 @@
+{
+ "name": "big-integer",
+ "description": "An arbitrary length integer library for Javascript",
+ "main": "./BigInteger.js",
+ "authors": [
+ "Peter Olson"
+ ],
+ "license": "Unlicense",
+ "keywords": [
+ "math",
+ "big",
+ "bignum",
+ "bigint",
+ "biginteger",
+ "integer",
+ "arbitrary",
+ "precision",
+ "arithmetic"
+ ],
+ "homepage": "https://github.com/peterolson/BigInteger.js",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "coverage",
+ "tests"
+ ]
+}
diff --git a/node_modules/big-integer/package.json b/node_modules/big-integer/package.json
new file mode 100644
index 0000000..093bf9d
--- /dev/null
+++ b/node_modules/big-integer/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "big-integer",
+ "version": "1.6.52",
+ "author": "Peter Olson ",
+ "description": "An arbitrary length integer library for Javascript",
+ "contributors": [],
+ "bin": {},
+ "scripts": {
+ "test": "tsc && karma start my.conf.js && node spec/tsDefinitions.js",
+ "minify": "uglifyjs BigInteger.js -o BigInteger.min.js"
+ },
+ "main": "./BigInteger",
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:peterolson/BigInteger.js.git"
+ },
+ "keywords": [
+ "math",
+ "big",
+ "bignum",
+ "bigint",
+ "biginteger",
+ "integer",
+ "arbitrary",
+ "precision",
+ "arithmetic"
+ ],
+ "devDependencies": {
+ "@types/lodash": "^4.14.175",
+ "@types/node": "^7.10.2",
+ "coveralls": "^3.0.6",
+ "jasmine": "3.5.0",
+ "jasmine-core": "^3.5.0",
+ "karma": "^6.3.4",
+ "karma-cli": "^2.0.0",
+ "karma-coverage": "^2.0.3",
+ "karma-jasmine": "^4.0.1",
+ "karma-phantomjs-launcher": "^1.0.4",
+ "lodash": "^4.17.21",
+ "typescript": "^5.3.2",
+ "uglify-js": "^3.17.4"
+ },
+ "license": "Unlicense",
+ "engines": {
+ "node": ">=0.6"
+ },
+ "typings": "./BigInteger.d.ts"
+}
diff --git a/node_modules/big-integer/tsconfig.json b/node_modules/big-integer/tsconfig.json
new file mode 100644
index 0000000..e5eea42
--- /dev/null
+++ b/node_modules/big-integer/tsconfig.json
@@ -0,0 +1,24 @@
+{
+ "compilerOptions": {
+ "target": "esnext",
+ "module": "commonjs",
+ "lib": [
+ "es6"
+ ],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": false,
+ "baseUrl": "./",
+ "moduleResolution": "node",
+ "allowJs": true,
+ "typeRoots": [
+ "./"
+ ],
+ "types": [],
+ "forceConsistentCasingInFileNames": true
+ },
+ "files": [
+ "BigInteger.d.ts",
+ "spec/tsDefinitions.ts"
+ ]
+}
diff --git a/node_modules/bplist-parser/.editorconfig b/node_modules/bplist-parser/.editorconfig
new file mode 100644
index 0000000..c6812c1
--- /dev/null
+++ b/node_modules/bplist-parser/.editorconfig
@@ -0,0 +1,12 @@
+; EditorConfig file: https://EditorConfig.org
+; Install the "EditorConfig" plugin into your editor to use
+
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = true
diff --git a/node_modules/bplist-parser/.eslintignore b/node_modules/bplist-parser/.eslintignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/node_modules/bplist-parser/.eslintignore
@@ -0,0 +1 @@
+node_modules
diff --git a/node_modules/bplist-parser/.eslintrc.js b/node_modules/bplist-parser/.eslintrc.js
new file mode 100644
index 0000000..d5bac76
--- /dev/null
+++ b/node_modules/bplist-parser/.eslintrc.js
@@ -0,0 +1,296 @@
+module.exports = {
+ "env": {
+ "mocha": true,
+ "node": true,
+ "commonjs": true,
+ "es6": true
+ },
+ "extends": "eslint:recommended",
+ "globals": {
+ "Atomics": "readonly",
+ "SharedArrayBuffer": "readonly"
+ },
+ "parserOptions": {
+ "ecmaVersion": 2018
+ },
+ "rules": {
+ "accessor-pairs": "error",
+ "array-bracket-newline": "error",
+ "array-bracket-spacing": "off",
+ "array-callback-return": "error",
+ "array-element-newline": "off",
+ "arrow-body-style": "error",
+ "arrow-parens": "error",
+ "arrow-spacing": "error",
+ "block-scoped-var": "error",
+ "block-spacing": "error",
+ "brace-style": [
+ "error",
+ "1tbs"
+ ],
+ "callback-return": "off",
+ "camelcase": "off",
+ "capitalized-comments": "off",
+ "class-methods-use-this": "error",
+ "comma-dangle": "error",
+ "comma-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": false
+ }
+ ],
+ "comma-style": "error",
+ "complexity": "error",
+ "computed-property-spacing": [
+ "error",
+ "never"
+ ],
+ "consistent-return": "off",
+ "consistent-this": "error",
+ "curly": "off",
+ "default-case": "error",
+ "dot-location": "error",
+ "dot-notation": "off",
+ "eol-last": "error",
+ "eqeqeq": "off",
+ "func-call-spacing": "error",
+ "func-name-matching": "error",
+ "func-names": "off",
+ "func-style": [
+ "error",
+ "declaration"
+ ],
+ "function-paren-newline": "error",
+ "generator-star-spacing": "error",
+ "global-require": "error",
+ "guard-for-in": "error",
+ "handle-callback-err": "error",
+ "id-blacklist": "error",
+ "id-length": "off",
+ "id-match": "error",
+ "implicit-arrow-linebreak": "error",
+ "indent": "off",
+ "indent-legacy": "off",
+ "init-declarations": "off",
+ "jsx-quotes": "error",
+ "key-spacing": "off",
+ "keyword-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": true
+ }
+ ],
+ "line-comment-position": "off",
+ "linebreak-style": [
+ "error",
+ "unix"
+ ],
+ "lines-around-comment": "error",
+ "lines-around-directive": "error",
+ "lines-between-class-members": "error",
+ "max-classes-per-file": "error",
+ "max-depth": "error",
+ "max-len": "off",
+ "max-lines": "off",
+ "max-lines-per-function": "off",
+ "max-nested-callbacks": "error",
+ "max-params": "error",
+ "max-statements": "off",
+ "max-statements-per-line": "error",
+ "multiline-comment-style": [
+ "error",
+ "separate-lines"
+ ],
+ "multiline-ternary": "error",
+ "new-cap": "error",
+ "new-parens": "error",
+ "newline-after-var": "off",
+ "newline-before-return": "off",
+ "newline-per-chained-call": "error",
+ "no-alert": "error",
+ "no-array-constructor": "error",
+ "no-async-promise-executor": "error",
+ "no-await-in-loop": "error",
+ "no-bitwise": "off",
+ "no-buffer-constructor": "error",
+ "no-caller": "error",
+ "no-catch-shadow": "error",
+ "no-confusing-arrow": "error",
+ "no-continue": "error",
+ "no-div-regex": "error",
+ "no-duplicate-imports": "error",
+ "no-else-return": "error",
+ "no-empty-function": "error",
+ "no-eq-null": "error",
+ "no-eval": "error",
+ "no-extend-native": "error",
+ "no-extra-bind": "error",
+ "no-extra-label": "error",
+ "no-extra-parens": "off",
+ "no-floating-decimal": "error",
+ "no-implicit-coercion": "error",
+ "no-implicit-globals": "error",
+ "no-implied-eval": "error",
+ "no-inline-comments": "off",
+ "no-invalid-this": "error",
+ "no-iterator": "error",
+ "no-label-var": "error",
+ "no-labels": "error",
+ "no-lone-blocks": "error",
+ "no-lonely-if": "error",
+ "no-loop-func": "error",
+ "no-magic-numbers": "off",
+ "no-misleading-character-class": "error",
+ "no-mixed-operators": "off",
+ "no-mixed-requires": "error",
+ "no-multi-assign": "off",
+ "no-multi-spaces": [
+ "error",
+ {
+ "ignoreEOLComments": true
+ }
+ ],
+ "no-multi-str": "error",
+ "no-multiple-empty-lines": "error",
+ "no-native-reassign": "error",
+ "no-negated-condition": "error",
+ "no-negated-in-lhs": "error",
+ "no-nested-ternary": "error",
+ "no-new": "error",
+ "no-new-func": "error",
+ "no-new-object": "error",
+ "no-new-require": "error",
+ "no-new-wrappers": "error",
+ "no-octal-escape": "error",
+ "no-param-reassign": "off",
+ "no-path-concat": "error",
+ "no-plusplus": [
+ "error",
+ {
+ "allowForLoopAfterthoughts": true
+ }
+ ],
+ "no-process-env": "error",
+ "no-process-exit": "error",
+ "no-proto": "error",
+ "no-prototype-builtins": "error",
+ "no-restricted-globals": "error",
+ "no-restricted-imports": "error",
+ "no-restricted-modules": "error",
+ "no-restricted-properties": "error",
+ "no-restricted-syntax": "error",
+ "no-return-assign": "error",
+ "no-return-await": "error",
+ "no-script-url": "error",
+ "no-self-compare": "error",
+ "no-sequences": "error",
+ "no-shadow": "off",
+ "no-shadow-restricted-names": "error",
+ "no-spaced-func": "error",
+ // "no-sync": "error",
+ "no-tabs": "error",
+ "no-template-curly-in-string": "error",
+ "no-ternary": "error",
+ "no-throw-literal": "error",
+ "no-trailing-spaces": "error",
+ "no-undef-init": "error",
+ "no-undefined": "error",
+ "no-underscore-dangle": "error",
+ "no-unmodified-loop-condition": "error",
+ "no-unneeded-ternary": "error",
+ "no-unused-expressions": "error",
+ "no-use-before-define": "off",
+ "no-useless-call": "error",
+ "no-useless-catch": "error",
+ "no-useless-computed-key": "error",
+ "no-useless-concat": "error",
+ "no-useless-constructor": "error",
+ "no-useless-rename": "error",
+ "no-useless-return": "error",
+ "no-var": "error",
+ "no-void": "error",
+ "no-warning-comments": "error",
+ "no-whitespace-before-property": "error",
+ "no-with": "error",
+ "nonblock-statement-body-position": "error",
+ "object-curly-newline": "error",
+ "object-curly-spacing": [
+ "error",
+ "never"
+ ],
+ "object-property-newline": "error",
+ "object-shorthand": "error",
+ "one-var": "off",
+ "one-var-declaration-per-line": "error",
+ "operator-assignment": [
+ "error",
+ "always"
+ ],
+ "operator-linebreak": "error",
+ "padded-blocks": "off",
+ "padding-line-between-statements": "error",
+ "prefer-arrow-callback": "off",
+ "prefer-const": "error",
+ "prefer-destructuring": "error",
+ "prefer-named-capture-group": "error",
+ "prefer-numeric-literals": "error",
+ "prefer-object-spread": "error",
+ "prefer-promise-reject-errors": "error",
+ "prefer-reflect": "error",
+ "prefer-rest-params": "error",
+ "prefer-spread": "error",
+ "prefer-template": "off",
+ "quote-props": "off",
+ "quotes": "off",
+ "radix": "error",
+ "require-atomic-updates": "error",
+ "require-await": "error",
+ "require-jsdoc": "off",
+ "require-unicode-regexp": "error",
+ "rest-spread-spacing": "error",
+ "semi": "error",
+ "semi-spacing": [
+ "error",
+ {
+ "after": true,
+ "before": false
+ }
+ ],
+ "semi-style": [
+ "error",
+ "last"
+ ],
+ "sort-imports": "error",
+ "sort-keys": "error",
+ "sort-vars": "error",
+ "space-before-blocks": "error",
+ "space-before-function-paren": "off",
+ "space-in-parens": [
+ "error",
+ "never"
+ ],
+ "space-infix-ops": "off",
+ "space-unary-ops": "error",
+ "spaced-comment": "off",
+ "strict": "error",
+ "switch-colon-spacing": "error",
+ "symbol-description": "error",
+ "template-curly-spacing": "error",
+ "template-tag-spacing": "error",
+ "unicode-bom": [
+ "error",
+ "never"
+ ],
+ "valid-jsdoc": "error",
+ "vars-on-top": "error",
+ "wrap-iife": "error",
+ "wrap-regex": "error",
+ "yield-star-spacing": "error",
+ "yoda": [
+ "error",
+ "never"
+ ]
+ }
+};
diff --git a/node_modules/bplist-parser/README.md b/node_modules/bplist-parser/README.md
new file mode 100644
index 0000000..eb54064
--- /dev/null
+++ b/node_modules/bplist-parser/README.md
@@ -0,0 +1,48 @@
+# bplist-parser
+
+Binary Mac OS X Plist (property list) parser.
+
+## Installation
+
+```bash
+$ npm install bplist-parser
+```
+
+## Quick Examples
+
+```javascript
+const bplist = require('bplist-parser');
+
+(async () => {
+
+ const obj = await bplist.parseFile('myPlist.bplist');
+
+ console.log(JSON.stringify(obj));
+
+})();
+```
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2012 Near Infinity Corporation
+
+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.
diff --git a/node_modules/bplist-parser/bplistParser.d.ts b/node_modules/bplist-parser/bplistParser.d.ts
new file mode 100644
index 0000000..1064269
--- /dev/null
+++ b/node_modules/bplist-parser/bplistParser.d.ts
@@ -0,0 +1,8 @@
+declare namespace bPlistParser {
+ type CallbackFunction = (error: Error|null, result: [T]) => void
+ export function parseFile(fileNameOrBuffer: string|Buffer, callback?: CallbackFunction): Promise<[T]>
+ export function parseFileSync(fileNameOrBuffer: string|Buffer): [T]
+ export function parseBuffer(buffer: string|Buffer): [T]
+}
+
+export = bPlistParser
diff --git a/node_modules/bplist-parser/bplistParser.js b/node_modules/bplist-parser/bplistParser.js
new file mode 100644
index 0000000..f6fb983
--- /dev/null
+++ b/node_modules/bplist-parser/bplistParser.js
@@ -0,0 +1,373 @@
+/* eslint-disable no-console */
+
+'use strict';
+
+// adapted from https://github.com/3breadt/dd-plist
+
+const fs = require('fs');
+const bigInt = require('big-integer');
+const debug = false;
+
+exports.maxObjectSize = 100 * 1000 * 1000; // 100Meg
+exports.maxObjectCount = 32768;
+
+// EPOCH = new SimpleDateFormat("yyyy MM dd zzz").parse("2001 01 01 GMT").getTime();
+// ...but that's annoying in a static initializer because it can throw exceptions, ick.
+// So we just hardcode the correct value.
+const EPOCH = 978307200000;
+
+// UID object definition
+const UID = exports.UID = function(id) {
+ this.UID = id;
+};
+
+exports.parseFile = function (fileNameOrBuffer, callback) {
+ return new Promise(function (resolve, reject) {
+ function tryParseBuffer(buffer) {
+ let err = null;
+ let result;
+ try {
+ result = parseBuffer(buffer);
+ resolve(result);
+ } catch (ex) {
+ err = ex;
+ reject(err);
+ } finally {
+ if (callback) callback(err, result);
+ }
+ }
+
+ if (Buffer.isBuffer(fileNameOrBuffer)) {
+ return tryParseBuffer(fileNameOrBuffer);
+ }
+ fs.readFile(fileNameOrBuffer, function (err, data) {
+ if (err) {
+ reject(err);
+ return callback(err);
+ }
+ tryParseBuffer(data);
+ });
+ });
+};
+
+exports.parseFileSync = function (fileNameOrBuffer) {
+ if (!Buffer.isBuffer(fileNameOrBuffer)) {
+ fileNameOrBuffer = fs.readFileSync(fileNameOrBuffer);
+ }
+ return parseBuffer(fileNameOrBuffer);
+};
+
+const parseBuffer = exports.parseBuffer = function (buffer) {
+ // check header
+ const header = buffer.slice(0, 'bplist'.length).toString('utf8');
+ if (header !== 'bplist') {
+ throw new Error("Invalid binary plist. Expected 'bplist' at offset 0.");
+ }
+
+ // Handle trailer, last 32 bytes of the file
+ const trailer = buffer.slice(buffer.length - 32, buffer.length);
+ // 6 null bytes (index 0 to 5)
+ const offsetSize = trailer.readUInt8(6);
+ if (debug) {
+ console.log("offsetSize: " + offsetSize);
+ }
+ const objectRefSize = trailer.readUInt8(7);
+ if (debug) {
+ console.log("objectRefSize: " + objectRefSize);
+ }
+ const numObjects = readUInt64BE(trailer, 8);
+ if (debug) {
+ console.log("numObjects: " + numObjects);
+ }
+ const topObject = readUInt64BE(trailer, 16);
+ if (debug) {
+ console.log("topObject: " + topObject);
+ }
+ const offsetTableOffset = readUInt64BE(trailer, 24);
+ if (debug) {
+ console.log("offsetTableOffset: " + offsetTableOffset);
+ }
+
+ if (numObjects > exports.maxObjectCount) {
+ throw new Error("maxObjectCount exceeded");
+ }
+
+ // Handle offset table
+ const offsetTable = [];
+
+ for (let i = 0; i < numObjects; i++) {
+ const offsetBytes = buffer.slice(offsetTableOffset + i * offsetSize, offsetTableOffset + (i + 1) * offsetSize);
+ offsetTable[i] = readUInt(offsetBytes, 0);
+ if (debug) {
+ console.log("Offset for Object #" + i + " is " + offsetTable[i] + " [" + offsetTable[i].toString(16) + "]");
+ }
+ }
+
+ // Parses an object inside the currently parsed binary property list.
+ // For the format specification check
+ //
+ // Apple's binary property list parser implementation .
+ function parseObject(tableOffset) {
+ const offset = offsetTable[tableOffset];
+ const type = buffer[offset];
+ const objType = (type & 0xF0) >> 4; //First 4 bits
+ const objInfo = (type & 0x0F); //Second 4 bits
+ switch (objType) {
+ case 0x0:
+ return parseSimple();
+ case 0x1:
+ return parseInteger();
+ case 0x8:
+ return parseUID();
+ case 0x2:
+ return parseReal();
+ case 0x3:
+ return parseDate();
+ case 0x4:
+ return parseData();
+ case 0x5: // ASCII
+ return parsePlistString();
+ case 0x6: // UTF-16
+ return parsePlistString(true);
+ case 0xA:
+ return parseArray();
+ case 0xD:
+ return parseDictionary();
+ default:
+ throw new Error("Unhandled type 0x" + objType.toString(16));
+ }
+
+ function parseSimple() {
+ //Simple
+ switch (objInfo) {
+ case 0x0: // null
+ return null;
+ case 0x8: // false
+ return false;
+ case 0x9: // true
+ return true;
+ case 0xF: // filler byte
+ return null;
+ default:
+ throw new Error("Unhandled simple type 0x" + objType.toString(16));
+ }
+ }
+
+ function bufferToHexString(buffer) {
+ let str = '';
+ let i;
+ for (i = 0; i < buffer.length; i++) {
+ if (buffer[i] != 0x00) {
+ break;
+ }
+ }
+ for (; i < buffer.length; i++) {
+ const part = '00' + buffer[i].toString(16);
+ str += part.substr(part.length - 2);
+ }
+ return str;
+ }
+
+ function parseInteger() {
+ const length = Math.pow(2, objInfo);
+ if (length < exports.maxObjectSize) {
+ const data = buffer.slice(offset + 1, offset + 1 + length);
+ if (length === 16) {
+ const str = bufferToHexString(data);
+ return bigInt(str, 16);
+ }
+ return data.reduce((acc, curr) => {
+ acc <<= 8;
+ acc |= curr & 255;
+ return acc;
+ });
+ }
+ throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
+
+ }
+
+ function parseUID() {
+ const length = objInfo + 1;
+ if (length < exports.maxObjectSize) {
+ return new UID(readUInt(buffer.slice(offset + 1, offset + 1 + length)));
+ }
+ throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
+ }
+
+ function parseReal() {
+ const length = Math.pow(2, objInfo);
+ if (length < exports.maxObjectSize) {
+ const realBuffer = buffer.slice(offset + 1, offset + 1 + length);
+ if (length === 4) {
+ return realBuffer.readFloatBE(0);
+ }
+ if (length === 8) {
+ return realBuffer.readDoubleBE(0);
+ }
+ } else {
+ throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
+ }
+ }
+
+ function parseDate() {
+ if (objInfo != 0x3) {
+ console.error("Unknown date type :" + objInfo + ". Parsing anyway...");
+ }
+ const dateBuffer = buffer.slice(offset + 1, offset + 9);
+ return new Date(EPOCH + (1000 * dateBuffer.readDoubleBE(0)));
+ }
+
+ function parseData() {
+ let dataoffset = 1;
+ let length = objInfo;
+ if (objInfo == 0xF) {
+ const int_type = buffer[offset + 1];
+ const intType = (int_type & 0xF0) / 0x10;
+ if (intType != 0x1) {
+ console.error("0x4: UNEXPECTED LENGTH-INT TYPE! " + intType);
+ }
+ const intInfo = int_type & 0x0F;
+ const intLength = Math.pow(2, intInfo);
+ dataoffset = 2 + intLength;
+ if (intLength < 3) {
+ length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+ } else {
+ length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+ }
+ }
+ if (length < exports.maxObjectSize) {
+ return buffer.slice(offset + dataoffset, offset + dataoffset + length);
+ }
+ throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
+ }
+
+ function parsePlistString (isUtf16) {
+ isUtf16 = isUtf16 || 0;
+ let enc = "utf8";
+ let length = objInfo;
+ let stroffset = 1;
+ if (objInfo == 0xF) {
+ const int_type = buffer[offset + 1];
+ const intType = (int_type & 0xF0) / 0x10;
+ if (intType != 0x1) {
+ console.error("UNEXPECTED LENGTH-INT TYPE! " + intType);
+ }
+ const intInfo = int_type & 0x0F;
+ const intLength = Math.pow(2, intInfo);
+ stroffset = 2 + intLength;
+ if (intLength < 3) {
+ length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+ } else {
+ length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+ }
+ }
+ // length is String length -> to get byte length multiply by 2, as 1 character takes 2 bytes in UTF-16
+ length *= (isUtf16 + 1);
+ if (length < exports.maxObjectSize) {
+ let plistString = Buffer.from(buffer.slice(offset + stroffset, offset + stroffset + length));
+ if (isUtf16) {
+ plistString = swapBytes(plistString);
+ enc = "ucs2";
+ }
+ return plistString.toString(enc);
+ }
+ throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available.");
+ }
+
+ function parseArray() {
+ let length = objInfo;
+ let arrayoffset = 1;
+ if (objInfo == 0xF) {
+ const int_type = buffer[offset + 1];
+ const intType = (int_type & 0xF0) / 0x10;
+ if (intType != 0x1) {
+ console.error("0xa: UNEXPECTED LENGTH-INT TYPE! " + intType);
+ }
+ const intInfo = int_type & 0x0F;
+ const intLength = Math.pow(2, intInfo);
+ arrayoffset = 2 + intLength;
+ if (intLength < 3) {
+ length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+ } else {
+ length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+ }
+ }
+ if (length * objectRefSize > exports.maxObjectSize) {
+ throw new Error("Too little heap space available!");
+ }
+ const array = [];
+ for (let i = 0; i < length; i++) {
+ const objRef = readUInt(buffer.slice(offset + arrayoffset + i * objectRefSize, offset + arrayoffset + (i + 1) * objectRefSize));
+ array[i] = parseObject(objRef);
+ }
+ return array;
+ }
+
+ function parseDictionary() {
+ let length = objInfo;
+ let dictoffset = 1;
+ if (objInfo == 0xF) {
+ const int_type = buffer[offset + 1];
+ const intType = (int_type & 0xF0) / 0x10;
+ if (intType != 0x1) {
+ console.error("0xD: UNEXPECTED LENGTH-INT TYPE! " + intType);
+ }
+ const intInfo = int_type & 0x0F;
+ const intLength = Math.pow(2, intInfo);
+ dictoffset = 2 + intLength;
+ if (intLength < 3) {
+ length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+ } else {
+ length = readUInt(buffer.slice(offset + 2, offset + 2 + intLength));
+ }
+ }
+ if (length * 2 * objectRefSize > exports.maxObjectSize) {
+ throw new Error("Too little heap space available!");
+ }
+ if (debug) {
+ console.log("Parsing dictionary #" + tableOffset);
+ }
+ const dict = {};
+ for (let i = 0; i < length; i++) {
+ const keyRef = readUInt(buffer.slice(offset + dictoffset + i * objectRefSize, offset + dictoffset + (i + 1) * objectRefSize));
+ const valRef = readUInt(buffer.slice(offset + dictoffset + (length * objectRefSize) + i * objectRefSize, offset + dictoffset + (length * objectRefSize) + (i + 1) * objectRefSize));
+ const key = parseObject(keyRef);
+ const val = parseObject(valRef);
+ if (debug) {
+ console.log(" DICT #" + tableOffset + ": Mapped " + key + " to " + val);
+ }
+ dict[key] = val;
+ }
+ return dict;
+ }
+ }
+
+ return [ parseObject(topObject) ];
+};
+
+function readUInt(buffer, start) {
+ start = start || 0;
+
+ let l = 0;
+ for (let i = start; i < buffer.length; i++) {
+ l <<= 8;
+ l |= buffer[i] & 0xFF;
+ }
+ return l;
+}
+
+// we're just going to toss the high order bits because javascript doesn't have 64-bit ints
+function readUInt64BE(buffer, start) {
+ const data = buffer.slice(start, start + 8);
+ return data.readUInt32BE(4, 8);
+}
+
+function swapBytes(buffer) {
+ const len = buffer.length;
+ for (let i = 0; i < len; i += 2) {
+ const a = buffer[i];
+ buffer[i] = buffer[i+1];
+ buffer[i+1] = a;
+ }
+ return buffer;
+}
diff --git a/node_modules/bplist-parser/package.json b/node_modules/bplist-parser/package.json
new file mode 100644
index 0000000..7ea058b
--- /dev/null
+++ b/node_modules/bplist-parser/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "bplist-parser",
+ "version": "0.3.2",
+ "description": "Binary plist parser.",
+ "main": "bplistParser.js",
+ "scripts": {
+ "test": "mocha test"
+ },
+ "keywords": [
+ "bplist",
+ "plist",
+ "parser"
+ ],
+ "author": "Joe Ferner ",
+ "contributors": [
+ "Brett Zamir"
+ ],
+ "license": "MIT",
+ "devDependencies": {
+ "eslint": "6.5.x",
+ "mocha": "6.2.x"
+ },
+ "homepage": "https://github.com/nearinfinity/node-bplist-parser",
+ "bugs": "https://github.com/nearinfinity/node-bplist-parser/issues",
+ "engines": {
+ "node": ">= 5.10.0"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/nearinfinity/node-bplist-parser.git"
+ },
+ "dependencies": {
+ "big-integer": "1.6.x"
+ }
+}
diff --git a/node_modules/brace-expansion/.github/FUNDING.yml b/node_modules/brace-expansion/.github/FUNDING.yml
new file mode 100644
index 0000000..79d1eaf
--- /dev/null
+++ b/node_modules/brace-expansion/.github/FUNDING.yml
@@ -0,0 +1,2 @@
+tidelift: "npm/brace-expansion"
+patreon: juliangruber
diff --git a/node_modules/brace-expansion/LICENSE b/node_modules/brace-expansion/LICENSE
new file mode 100644
index 0000000..de32266
--- /dev/null
+++ b/node_modules/brace-expansion/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2013 Julian Gruber
+
+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.
diff --git a/node_modules/brace-expansion/README.md b/node_modules/brace-expansion/README.md
new file mode 100644
index 0000000..bda4ed3
--- /dev/null
+++ b/node_modules/brace-expansion/README.md
@@ -0,0 +1,157 @@
+# brace-expansion
+
+[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
+as known from sh/bash, in JavaScript.
+
+[](http://travis-ci.org/juliangruber/brace-expansion)
+[](https://www.npmjs.org/package/brace-expansion)
+[](https://greenkeeper.io/)
+
+[](https://ci.testling.com/juliangruber/brace-expansion)
+
+## Example
+
+```js
+var expand = require('brace-expansion');
+
+expand('file-{a,b,c}.jpg')
+// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
+
+expand('-v{,,}')
+// => ['-v', '-v', '-v']
+
+expand('file{0..2}.jpg')
+// => ['file0.jpg', 'file1.jpg', 'file2.jpg']
+
+expand('file-{a..c}.jpg')
+// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
+
+expand('file{2..0}.jpg')
+// => ['file2.jpg', 'file1.jpg', 'file0.jpg']
+
+expand('file{0..4..2}.jpg')
+// => ['file0.jpg', 'file2.jpg', 'file4.jpg']
+
+expand('file-{a..e..2}.jpg')
+// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
+
+expand('file{00..10..5}.jpg')
+// => ['file00.jpg', 'file05.jpg', 'file10.jpg']
+
+expand('{{A..C},{a..c}}')
+// => ['A', 'B', 'C', 'a', 'b', 'c']
+
+expand('ppp{,config,oe{,conf}}')
+// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
+```
+
+## API
+
+```js
+var expand = require('brace-expansion');
+```
+
+### var expanded = expand(str, [options])
+
+Return an array of all possible and valid expansions of `str`. If none are
+found, `[str]` is returned.
+
+The `options` object can provide a `max` value to cap the number
+of expansions allowed. This is limited to `100_000` by default,
+to prevent DoS attacks.
+
+```js
+const expansions = expand('{1..100}'.repeat(5), {
+ max: 100,
+})
+// expansions.length will be 100, not 100^5
+```
+
+The `options` object can also provide a `maxLength` value to cap the
+total number of characters across all expansions. This is limited to
+`4_000_000` by default, to prevent memory exhaustion from inputs whose
+result count stays under `max` while each result grows very long.
+
+```js
+const expansions = expand('{a,b}'.repeat(1500), {
+ maxLength: 10_000,
+})
+```
+
+Valid expansions are:
+
+```js
+/^(.*,)+(.+)?$/
+// {a,b,...}
+```
+
+A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
+
+```js
+/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
+// {x..y[..incr]}
+```
+
+A numeric sequence from `x` to `y` inclusive, with optional increment.
+If `x` or `y` start with a leading `0`, all the numbers will be padded
+to have equal length. Negative numbers and backwards iteration work too.
+
+```js
+/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
+// {x..y[..incr]}
+```
+
+An alphabetic sequence from `x` to `y` inclusive, with optional increment.
+`x` and `y` must be exactly one character, and if given, `incr` must be a
+number.
+
+For compatibility reasons, the string `${` is not eligible for brace expansion.
+
+## Installation
+
+With [npm](https://npmjs.org) do:
+
+```bash
+npm install brace-expansion
+```
+
+## Contributors
+
+- [Julian Gruber](https://github.com/juliangruber)
+- [Isaac Z. Schlueter](https://github.com/isaacs)
+
+## Sponsors
+
+This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!
+
+Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
+
+## Security contact information
+
+To report a security vulnerability, please use the
+[Tidelift security contact](https://tidelift.com/security).
+Tidelift will coordinate the fix and disclosure.
+
+## License
+
+(MIT)
+
+Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
+
+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.
diff --git a/node_modules/brace-expansion/index.js b/node_modules/brace-expansion/index.js
new file mode 100644
index 0000000..3e0975d
--- /dev/null
+++ b/node_modules/brace-expansion/index.js
@@ -0,0 +1,394 @@
+var balanced = require('balanced-match');
+
+module.exports = expandTop;
+
+var escSlash = '\0SLASH'+Math.random()+'\0';
+var escOpen = '\0OPEN'+Math.random()+'\0';
+var escClose = '\0CLOSE'+Math.random()+'\0';
+var escComma = '\0COMMA'+Math.random()+'\0';
+var escPeriod = '\0PERIOD'+Math.random()+'\0';
+
+var EXPANSION_MAX = 100000
+
+// `EXPANSION_MAX` caps the *number* of expansions, but not their length. An
+// input like `'{a,b}'.repeat(1500)` stays under that count - its output is
+// truncated to 100k results - while making every result ~1500 characters
+// long. The result set, and the intermediate arrays built while combining
+// brace sets, then grow large enough to exhaust memory and crash the process
+// (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of
+// characters the accumulator may hold at any point, so memory stays flat no
+// matter how many brace groups are chained. The limit sits well above any
+// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
+// characters) so legitimate input is unaffected.
+var EXPANSION_MAX_LENGTH = 4000000
+
+// `expand` recurses once per level of brace *nesting* - both when expanding a
+// set's comma members and when re-wrapping a set whose body is a single part.
+// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one
+// level per chained group), which left nesting depth unbounded: about 3,100
+// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack
+// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser
+// will follow nesting. It sits far above any realistic pattern and well below
+// the depth at which the stack runs out.
+var EXPANSION_MAX_DEPTH = 1000
+
+// Bash keeps a quirk where a brace group followed by a comma set still expands
+// (`{a},b}`). The parser implements it by rewriting the string and restarting
+// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`
+// full passes over a string that itself grows by one `escClose` sentinel each
+// time - quadratic in `n`, with a ~26x constant from the sentinel's length.
+// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27
+// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many
+// times the scan may restart. Real `{a},b}` input needs a handful.
+var EXPANSION_MAX_REWRITES = 1000
+
+function numeric(str) {
+ return parseInt(str, 10) == str
+ ? parseInt(str, 10)
+ : str.charCodeAt(0);
+}
+
+function escapeBraces(str) {
+ return str.split('\\\\').join(escSlash)
+ .split('\\{').join(escOpen)
+ .split('\\}').join(escClose)
+ .split('\\,').join(escComma)
+ .split('\\.').join(escPeriod);
+}
+
+function unescapeBraces(str) {
+ return str.split(escSlash).join('\\')
+ .split(escOpen).join('{')
+ .split(escClose).join('}')
+ .split(escComma).join(',')
+ .split(escPeriod).join('.');
+}
+
+
+// Like `target.push(...items)` but doesn't overflow the stack
+function pushAll(target, items) {
+ for (var i = 0; i < items.length; i++) {
+ target.push(items[i]);
+ }
+}
+
+// Basically just str.split(","), but handling cases
+// where we have nested braced sections, which should be
+// treated as individual members, like {a,{b,c},d}
+function parseCommaParts(str) {
+ var parts = [];
+
+ // Walk the brace groups iteratively. Recursing on `post` once per group let a
+ // chain of them exhaust the stack - the parsing-side counterpart to
+ // the `expand` overflow fixed for CVE-2026-14257, and not something `max` or
+ // `maxLength` can bound, since it happens before expansion.
+ //
+ // The part the next chunk continues
+ var carry = '';
+
+ for (;;) {
+ var m = balanced('{', '}', str);
+
+ if (!m) {
+ var tail = str.split(',');
+ tail[0] = carry + tail[0];
+ pushAll(parts, tail);
+ return parts;
+ }
+
+ var pre = m.pre;
+ var body = m.body;
+ var post = m.post;
+ var p = pre.split(',');
+
+ p[0] = carry + p[0];
+ p[p.length-1] += '{' + body + '}';
+
+ if (!post.length) {
+ pushAll(parts, p);
+ return parts;
+ }
+
+ carry = p.pop();
+ pushAll(parts, p);
+ str = post;
+ }
+}
+
+function expandTop(str, options) {
+ if (!str)
+ return [];
+
+ options = options || {};
+ var max = options.max == null ? EXPANSION_MAX : options.max;
+ var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
+ var maxDepth = options.maxDepth == null ? EXPANSION_MAX_DEPTH : options.maxDepth;
+ var maxRewrites = options.maxRewrites == null ? EXPANSION_MAX_REWRITES : options.maxRewrites;
+
+ // I don't know why Bash 4.3 does this, but it does.
+ // Anything starting with {} will have the first two bytes preserved
+ // but *only* at the top level, so {},a}b will not expand to anything,
+ // but a{},b}c will be expanded to [a}c,abc].
+ // One could argue that this is a bug in Bash, but since the goal of
+ // this module is to match Bash's rules, we escape a leading {}
+ if (str.substr(0, 2) === '{}') {
+ str = '\\{\\}' + str.substr(2);
+ }
+
+ return expand(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
+}
+
+function embrace(str) {
+ return '{' + str + '}';
+}
+function isPadded(el) {
+ return /^-?0\d/.test(el);
+}
+
+function lte(i, y) {
+ return i <= y;
+}
+function gte(i, y) {
+ return i >= y;
+}
+
+// Build `{ acc[a] + pre + values[v] }` for every combination, capping the
+// number of results at `max` and the total number of characters at `maxLength`.
+// This is the one place output grows, so bounding it here keeps the single
+// accumulator - and therefore memory - flat regardless of how many brace groups
+// are combined (CVE-2026-14257).
+function combine(
+ acc,
+ pre,
+ values,
+ max,
+ maxLength,
+ dropEmpties
+) {
+ var out = []
+ var length = 0
+ for (var a = 0; a < acc.length; a++) {
+ for (var v = 0; v < values.length; v++) {
+ if (out.length >= max) return out
+ var expansion = acc[a] + pre + values[v]
+ // Bash drops empty results at the top level. Skip them before they count
+ // against `max`, so `max` bounds the number of *kept* results.
+ if (dropEmpties && !expansion) continue
+ if (length + expansion.length > maxLength) return out
+ out.push(expansion)
+ length += expansion.length
+ }
+ }
+ return out
+}
+
+// The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)
+// sequence body.
+function expandSequence(
+ body,
+ isAlphaSequence,
+ max,
+ maxLength
+) {
+ var n = body.split(/\.\./)
+ var N = []
+ // A sequence body always splits into two or three parts, but the compiler
+ // can't know that.
+ /* c8 ignore start */
+ if (n[0] === undefined || n[1] === undefined) {
+ return N
+ }
+ /* c8 ignore stop */
+ var x = numeric(n[0])
+ var y = numeric(n[1])
+ var width = Math.max(n[0].length, n[1].length)
+ var incr =
+ n.length === 3 && n[2] !== undefined ?
+ Math.max(Math.abs(numeric(n[2])), 1)
+ : 1
+ var test = lte
+ var reverse = y < x
+ if (reverse) {
+ incr *= -1
+ test = gte
+ }
+ var pad = n.some(isPadded)
+
+ var length = 0
+ for (var i = x; test(i, y) && N.length < max; i += incr) {
+ var c
+ if (isAlphaSequence) {
+ c = String.fromCharCode(i)
+ if (c === '\\') {
+ c = ''
+ }
+ } else {
+ c = String(i)
+ if (pad) {
+ var need = width - c.length
+ if (need > 0) {
+ var z = new Array(need + 1).join('0')
+ if (i < 0) {
+ c = '-' + z + c.slice(1)
+ } else {
+ c = z + c
+ }
+ }
+ }
+ }
+ if (length + c.length > maxLength) break
+ N.push(c)
+ length += c.length
+ }
+ return N
+}
+
+function expand(
+ str,
+ max,
+ maxLength,
+ maxDepth,
+ depth,
+ maxRewrites,
+ isTop
+) {
+ // Too deeply nested to keep following: treat the rest as literal, the same
+ // way a group that cannot expand is already handled. Truncating rather than
+ // throwing keeps expansion total, matching `max` and `maxLength`.
+ if (depth > maxDepth) {
+ return [str];
+ }
+
+ // Consume the string's top-level brace groups left to right, threading a
+ // running set of combined prefixes (`acc`). Expanding the tail iteratively -
+ // rather than recursing on `m.post` once per group - keeps the native stack
+ // depth constant, so deeply chained input (`'{a,b}'.repeat(3000)`) can no
+ // longer overflow the stack, and leaves a single accumulator whose size
+ // `maxLength` bounds directly (CVE-2026-14257).
+ var acc = ['']
+
+ // Bash drops empty results, but only when the *first* top-level group is a
+ // comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
+ // is on the final strings, so it is applied to whichever `combine` produces
+ // them (the one with no brace set left in the tail).
+ // How many times the `{a},b}` rewrite below has restarted the scan. Each pass
+ // re-reads the whole string, so leaving this unbounded is quadratic.
+ var rewrites = 0
+ var dropEmpties = false
+ var firstGroup = true
+
+ for (;;) {
+ const m = balanced('{', '}', str)
+
+ // No brace set left: the rest of the string is literal.
+ if (!m) {
+ return combine(acc, str, [''], max, maxLength, dropEmpties)
+ }
+
+ // no need to expand pre, since it is guaranteed to be free of brace-sets
+ const pre = m.pre
+
+ if (/\$$/.test(pre)) {
+ acc = combine(
+ acc,
+ pre + '{' + m.body + '}',
+ [''],
+ max,
+ maxLength,
+ dropEmpties && !m.post.length
+ )
+ firstGroup = false
+ if (!m.post.length) break
+ str = m.post
+ continue
+ }
+
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
+ var isSequence = isNumericSequence || isAlphaSequence;
+ var isOptions = m.body.indexOf(',') >= 0;
+ if (!isSequence && !isOptions) {
+ // {a},b}
+ if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
+ rewrites++;
+ str = m.pre + '{' + m.body + escClose + m.post;
+ isTop = true;
+ continue;
+ }
+ // Nothing here expands, so the whole remaining string is literal.
+ return combine(
+ acc,
+ pre + '{' + m.body + '}' + m.post,
+ [''],
+ max,
+ maxLength,
+ dropEmpties
+ )
+ }
+
+ if (firstGroup) {
+ dropEmpties = isTop && !isSequence
+ firstGroup = false
+ }
+
+ var values;
+ if (isSequence) {
+ values = expandSequence(m.body, isAlphaSequence, max, maxLength);
+ } else {
+ var n = parseCommaParts(m.body);
+ if (n.length === 1 && n[0] !== undefined) {
+ // x{{a,b}}y ==> x{a}y x{b}y
+ n = expand(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
+ //XXX is this necessary? Can't seem to hit it in tests.
+ /* c8 ignore start */
+ if (n.length === 1) {
+ acc = combine(
+ acc,
+ pre + n[0],
+ [''],
+ max,
+ maxLength,
+ dropEmpties && !m.post.length
+ )
+ if (!m.post.length) break
+ str = m.post
+ continue
+ }
+ /* c8 ignore stop */
+ }
+
+ // Values that `combine` is going to drop as empty produce no result, so
+ // they must not count against `max` - otherwise `{a,,b}` with `max: 2`
+ // would stop at `['a', '']` and yield one result instead of two. Skipping
+ // them outright keeps `values` bounded while leaving `max` a bound on
+ // *kept* results.
+ var dropsEmpties = dropEmpties && !m.post.length && !pre
+ for (var d = 0; dropsEmpties && d < acc.length; d++) {
+ if (acc[d]) {
+ dropsEmpties = false
+ }
+ }
+
+ values = []
+ var valuesLength = 0
+ outer: for (var j = 0; j < n.length; j++) {
+ var expanded = expand(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false)
+ for (var k = 0; k < expanded.length; k++) {
+ var v = expanded[k]
+ if (dropsEmpties && !v) continue
+ if (values.length >= max || valuesLength + v.length > maxLength) {
+ break outer
+ }
+ values.push(v)
+ valuesLength += v.length
+ }
+ }
+ }
+
+ acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length)
+ if (!m.post.length) break
+ str = m.post
+ }
+
+ return acc
+}
diff --git a/node_modules/brace-expansion/package.json b/node_modules/brace-expansion/package.json
new file mode 100644
index 0000000..4c64599
--- /dev/null
+++ b/node_modules/brace-expansion/package.json
@@ -0,0 +1,49 @@
+{
+ "name": "brace-expansion",
+ "description": "Brace expansion as known from sh/bash",
+ "version": "2.1.7",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/juliangruber/brace-expansion.git"
+ },
+ "homepage": "https://github.com/juliangruber/brace-expansion",
+ "main": "index.js",
+ "scripts": {
+ "test": "tape test/*.js",
+ "gentest": "bash test/generate.sh",
+ "bench": "matcha test/perf/bench.js"
+ },
+ "dependencies": {
+ "balanced-match": "^1.0.0"
+ },
+ "devDependencies": {
+ "@c4312/matcha": "^1.3.1",
+ "tape": "^4.6.0"
+ },
+ "keywords": [],
+ "author": {
+ "name": "Julian Gruber",
+ "email": "mail@juliangruber.com",
+ "url": "http://juliangruber.com"
+ },
+ "license": "MIT",
+ "testling": {
+ "files": "test/*.js",
+ "browsers": [
+ "ie/8..latest",
+ "firefox/20..latest",
+ "firefox/nightly",
+ "chrome/25..latest",
+ "chrome/canary",
+ "opera/12..latest",
+ "opera/next",
+ "safari/5.1..latest",
+ "ipad/6.0..latest",
+ "iphone/6.0..latest",
+ "android-browser/4.2..latest"
+ ]
+ },
+ "publishConfig": {
+ "tag": "2.x"
+ }
+}
diff --git a/node_modules/buffer-crc32/LICENSE b/node_modules/buffer-crc32/LICENSE
new file mode 100644
index 0000000..4cef10e
--- /dev/null
+++ b/node_modules/buffer-crc32/LICENSE
@@ -0,0 +1,19 @@
+The MIT License
+
+Copyright (c) 2013 Brian J. Brennan
+
+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.
diff --git a/node_modules/buffer-crc32/README.md b/node_modules/buffer-crc32/README.md
new file mode 100644
index 0000000..0d9d8b8
--- /dev/null
+++ b/node_modules/buffer-crc32/README.md
@@ -0,0 +1,47 @@
+# buffer-crc32
+
+[](http://travis-ci.org/brianloveswords/buffer-crc32)
+
+crc32 that works with binary data and fancy character sets, outputs
+buffer, signed or unsigned data and has tests.
+
+Derived from the sample CRC implementation in the PNG specification: http://www.w3.org/TR/PNG/#D-CRCAppendix
+
+# install
+```
+npm install buffer-crc32
+```
+
+# example
+```js
+var crc32 = require('buffer-crc32');
+// works with buffers
+var buf = Buffer([0x00, 0x73, 0x75, 0x70, 0x20, 0x62, 0x72, 0x6f, 0x00])
+crc32(buf) // ->
+
+// has convenience methods for getting signed or unsigned ints
+crc32.signed(buf) // -> -1805997238
+crc32.unsigned(buf) // -> 2488970058
+
+// will cast to buffer if given a string, so you can
+// directly use foreign characters safely
+crc32('自動販売機') // ->
+
+// and works in append mode too
+var partialCrc = crc32('hey');
+var partialCrc = crc32(' ', partialCrc);
+var partialCrc = crc32('sup', partialCrc);
+var partialCrc = crc32(' ', partialCrc);
+var finalCrc = crc32('bros', partialCrc); // ->
+```
+
+# tests
+This was tested against the output of zlib's crc32 method. You can run
+the tests with`npm test` (requires tap)
+
+# see also
+https://github.com/alexgorbatchev/node-crc, `crc.buffer.crc32` also
+supports buffer inputs and return unsigned ints (thanks @tjholowaychuk).
+
+# license
+MIT/X11
diff --git a/node_modules/buffer-crc32/index.js b/node_modules/buffer-crc32/index.js
new file mode 100644
index 0000000..6727dd3
--- /dev/null
+++ b/node_modules/buffer-crc32/index.js
@@ -0,0 +1,111 @@
+var Buffer = require('buffer').Buffer;
+
+var CRC_TABLE = [
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
+ 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
+ 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
+ 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
+ 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
+ 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
+ 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
+ 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
+ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
+ 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
+ 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
+ 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
+ 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
+ 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
+ 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
+ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
+ 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
+ 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
+ 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
+ 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
+ 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
+ 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
+ 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
+ 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
+ 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
+ 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
+ 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
+ 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
+ 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
+ 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
+ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
+ 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
+ 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
+ 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
+ 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
+ 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
+ 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
+ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
+ 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
+ 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
+ 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
+ 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
+ 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
+ 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
+ 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
+ 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
+ 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
+ 0x2d02ef8d
+];
+
+if (typeof Int32Array !== 'undefined') {
+ CRC_TABLE = new Int32Array(CRC_TABLE);
+}
+
+function ensureBuffer(input) {
+ if (Buffer.isBuffer(input)) {
+ return input;
+ }
+
+ var hasNewBufferAPI =
+ typeof Buffer.alloc === "function" &&
+ typeof Buffer.from === "function";
+
+ if (typeof input === "number") {
+ return hasNewBufferAPI ? Buffer.alloc(input) : new Buffer(input);
+ }
+ else if (typeof input === "string") {
+ return hasNewBufferAPI ? Buffer.from(input) : new Buffer(input);
+ }
+ else {
+ throw new Error("input must be buffer, number, or string, received " +
+ typeof input);
+ }
+}
+
+function bufferizeInt(num) {
+ var tmp = ensureBuffer(4);
+ tmp.writeInt32BE(num, 0);
+ return tmp;
+}
+
+function _crc32(buf, previous) {
+ buf = ensureBuffer(buf);
+ if (Buffer.isBuffer(previous)) {
+ previous = previous.readUInt32BE(0);
+ }
+ var crc = ~~previous ^ -1;
+ for (var n = 0; n < buf.length; n++) {
+ crc = CRC_TABLE[(crc ^ buf[n]) & 0xff] ^ (crc >>> 8);
+ }
+ return (crc ^ -1);
+}
+
+function crc32() {
+ return bufferizeInt(_crc32.apply(null, arguments));
+}
+crc32.signed = function () {
+ return _crc32.apply(null, arguments);
+};
+crc32.unsigned = function () {
+ return _crc32.apply(null, arguments) >>> 0;
+};
+
+module.exports = crc32;
diff --git a/node_modules/buffer-crc32/package.json b/node_modules/buffer-crc32/package.json
new file mode 100644
index 0000000..e896bec
--- /dev/null
+++ b/node_modules/buffer-crc32/package.json
@@ -0,0 +1,39 @@
+{
+ "author": "Brian J. Brennan ",
+ "name": "buffer-crc32",
+ "description": "A pure javascript CRC32 algorithm that plays nice with binary data",
+ "version": "0.2.13",
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/brianloveswords/buffer-crc32/raw/master/LICENSE"
+ }
+ ],
+ "contributors": [
+ {
+ "name": "Vladimir Kuznetsov",
+ "github": "mistakster"
+ }
+ ],
+ "homepage": "https://github.com/brianloveswords/buffer-crc32",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/brianloveswords/buffer-crc32.git"
+ },
+ "main": "index.js",
+ "scripts": {
+ "test": "./node_modules/.bin/tap tests/*.test.js"
+ },
+ "dependencies": {},
+ "devDependencies": {
+ "tap": "~0.2.5"
+ },
+ "optionalDependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "license": "MIT",
+ "files": [
+ "index.js"
+ ]
+}
diff --git a/node_modules/chownr/LICENSE b/node_modules/chownr/LICENSE
new file mode 100644
index 0000000..19129e3
--- /dev/null
+++ b/node_modules/chownr/LICENSE
@@ -0,0 +1,15 @@
+The ISC License
+
+Copyright (c) Isaac Z. Schlueter and Contributors
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/node_modules/chownr/README.md b/node_modules/chownr/README.md
new file mode 100644
index 0000000..70e9a54
--- /dev/null
+++ b/node_modules/chownr/README.md
@@ -0,0 +1,3 @@
+Like `chown -R`.
+
+Takes the same arguments as `fs.chown()`
diff --git a/node_modules/chownr/chownr.js b/node_modules/chownr/chownr.js
new file mode 100644
index 0000000..0d40932
--- /dev/null
+++ b/node_modules/chownr/chownr.js
@@ -0,0 +1,167 @@
+'use strict'
+const fs = require('fs')
+const path = require('path')
+
+/* istanbul ignore next */
+const LCHOWN = fs.lchown ? 'lchown' : 'chown'
+/* istanbul ignore next */
+const LCHOWNSYNC = fs.lchownSync ? 'lchownSync' : 'chownSync'
+
+/* istanbul ignore next */
+const needEISDIRHandled = fs.lchown &&
+ !process.version.match(/v1[1-9]+\./) &&
+ !process.version.match(/v10\.[6-9]/)
+
+const lchownSync = (path, uid, gid) => {
+ try {
+ return fs[LCHOWNSYNC](path, uid, gid)
+ } catch (er) {
+ if (er.code !== 'ENOENT')
+ throw er
+ }
+}
+
+/* istanbul ignore next */
+const chownSync = (path, uid, gid) => {
+ try {
+ return fs.chownSync(path, uid, gid)
+ } catch (er) {
+ if (er.code !== 'ENOENT')
+ throw er
+ }
+}
+
+/* istanbul ignore next */
+const handleEISDIR =
+ needEISDIRHandled ? (path, uid, gid, cb) => er => {
+ // Node prior to v10 had a very questionable implementation of
+ // fs.lchown, which would always try to call fs.open on a directory
+ // Fall back to fs.chown in those cases.
+ if (!er || er.code !== 'EISDIR')
+ cb(er)
+ else
+ fs.chown(path, uid, gid, cb)
+ }
+ : (_, __, ___, cb) => cb
+
+/* istanbul ignore next */
+const handleEISDirSync =
+ needEISDIRHandled ? (path, uid, gid) => {
+ try {
+ return lchownSync(path, uid, gid)
+ } catch (er) {
+ if (er.code !== 'EISDIR')
+ throw er
+ chownSync(path, uid, gid)
+ }
+ }
+ : (path, uid, gid) => lchownSync(path, uid, gid)
+
+// fs.readdir could only accept an options object as of node v6
+const nodeVersion = process.version
+let readdir = (path, options, cb) => fs.readdir(path, options, cb)
+let readdirSync = (path, options) => fs.readdirSync(path, options)
+/* istanbul ignore next */
+if (/^v4\./.test(nodeVersion))
+ readdir = (path, options, cb) => fs.readdir(path, cb)
+
+const chown = (cpath, uid, gid, cb) => {
+ fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, er => {
+ // Skip ENOENT error
+ cb(er && er.code !== 'ENOENT' ? er : null)
+ }))
+}
+
+const chownrKid = (p, child, uid, gid, cb) => {
+ if (typeof child === 'string')
+ return fs.lstat(path.resolve(p, child), (er, stats) => {
+ // Skip ENOENT error
+ if (er)
+ return cb(er.code !== 'ENOENT' ? er : null)
+ stats.name = child
+ chownrKid(p, stats, uid, gid, cb)
+ })
+
+ if (child.isDirectory()) {
+ chownr(path.resolve(p, child.name), uid, gid, er => {
+ if (er)
+ return cb(er)
+ const cpath = path.resolve(p, child.name)
+ chown(cpath, uid, gid, cb)
+ })
+ } else {
+ const cpath = path.resolve(p, child.name)
+ chown(cpath, uid, gid, cb)
+ }
+}
+
+
+const chownr = (p, uid, gid, cb) => {
+ readdir(p, { withFileTypes: true }, (er, children) => {
+ // any error other than ENOTDIR or ENOTSUP means it's not readable,
+ // or doesn't exist. give up.
+ if (er) {
+ if (er.code === 'ENOENT')
+ return cb()
+ else if (er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP')
+ return cb(er)
+ }
+ if (er || !children.length)
+ return chown(p, uid, gid, cb)
+
+ let len = children.length
+ let errState = null
+ const then = er => {
+ if (errState)
+ return
+ if (er)
+ return cb(errState = er)
+ if (-- len === 0)
+ return chown(p, uid, gid, cb)
+ }
+
+ children.forEach(child => chownrKid(p, child, uid, gid, then))
+ })
+}
+
+const chownrKidSync = (p, child, uid, gid) => {
+ if (typeof child === 'string') {
+ try {
+ const stats = fs.lstatSync(path.resolve(p, child))
+ stats.name = child
+ child = stats
+ } catch (er) {
+ if (er.code === 'ENOENT')
+ return
+ else
+ throw er
+ }
+ }
+
+ if (child.isDirectory())
+ chownrSync(path.resolve(p, child.name), uid, gid)
+
+ handleEISDirSync(path.resolve(p, child.name), uid, gid)
+}
+
+const chownrSync = (p, uid, gid) => {
+ let children
+ try {
+ children = readdirSync(p, { withFileTypes: true })
+ } catch (er) {
+ if (er.code === 'ENOENT')
+ return
+ else if (er.code === 'ENOTDIR' || er.code === 'ENOTSUP')
+ return handleEISDirSync(p, uid, gid)
+ else
+ throw er
+ }
+
+ if (children && children.length)
+ children.forEach(child => chownrKidSync(p, child, uid, gid))
+
+ return handleEISDirSync(p, uid, gid)
+}
+
+module.exports = chownr
+chownr.sync = chownrSync
diff --git a/node_modules/chownr/package.json b/node_modules/chownr/package.json
new file mode 100644
index 0000000..5b0214c
--- /dev/null
+++ b/node_modules/chownr/package.json
@@ -0,0 +1,32 @@
+{
+ "author": "Isaac Z. Schlueter (http://blog.izs.me/)",
+ "name": "chownr",
+ "description": "like `chown -R`",
+ "version": "2.0.0",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/isaacs/chownr.git"
+ },
+ "main": "chownr.js",
+ "files": [
+ "chownr.js"
+ ],
+ "devDependencies": {
+ "mkdirp": "0.3",
+ "rimraf": "^2.7.1",
+ "tap": "^14.10.6"
+ },
+ "tap": {
+ "check-coverage": true
+ },
+ "scripts": {
+ "test": "tap",
+ "preversion": "npm test",
+ "postversion": "npm publish",
+ "prepublishOnly": "git push origin --follow-tags"
+ },
+ "license": "ISC",
+ "engines": {
+ "node": ">=10"
+ }
+}
diff --git a/node_modules/color-convert/CHANGELOG.md b/node_modules/color-convert/CHANGELOG.md
new file mode 100644
index 0000000..0a7bce4
--- /dev/null
+++ b/node_modules/color-convert/CHANGELOG.md
@@ -0,0 +1,54 @@
+# 1.0.0 - 2016-01-07
+
+- Removed: unused speed test
+- Added: Automatic routing between previously unsupported conversions
+([#27](https://github.com/Qix-/color-convert/pull/27))
+- Removed: `xxx2xxx()` and `xxx2xxxRaw()` functions
+([#27](https://github.com/Qix-/color-convert/pull/27))
+- Removed: `convert()` class
+([#27](https://github.com/Qix-/color-convert/pull/27))
+- Changed: all functions to lookup dictionary
+([#27](https://github.com/Qix-/color-convert/pull/27))
+- Changed: `ansi` to `ansi256`
+([#27](https://github.com/Qix-/color-convert/pull/27))
+- Fixed: argument grouping for functions requiring only one argument
+([#27](https://github.com/Qix-/color-convert/pull/27))
+
+# 0.6.0 - 2015-07-23
+
+- Added: methods to handle
+[ANSI](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) 16/256 colors:
+ - rgb2ansi16
+ - rgb2ansi
+ - hsl2ansi16
+ - hsl2ansi
+ - hsv2ansi16
+ - hsv2ansi
+ - hwb2ansi16
+ - hwb2ansi
+ - cmyk2ansi16
+ - cmyk2ansi
+ - keyword2ansi16
+ - keyword2ansi
+ - ansi162rgb
+ - ansi162hsl
+ - ansi162hsv
+ - ansi162hwb
+ - ansi162cmyk
+ - ansi162keyword
+ - ansi2rgb
+ - ansi2hsl
+ - ansi2hsv
+ - ansi2hwb
+ - ansi2cmyk
+ - ansi2keyword
+([#18](https://github.com/harthur/color-convert/pull/18))
+
+# 0.5.3 - 2015-06-02
+
+- Fixed: hsl2hsv does not return `NaN` anymore when using `[0,0,0]`
+([#15](https://github.com/harthur/color-convert/issues/15))
+
+---
+
+Check out commit logs for older releases
diff --git a/node_modules/color-convert/LICENSE b/node_modules/color-convert/LICENSE
new file mode 100644
index 0000000..5b4c386
--- /dev/null
+++ b/node_modules/color-convert/LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2011-2016 Heather Arthur
+
+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.
+
diff --git a/node_modules/color-convert/README.md b/node_modules/color-convert/README.md
new file mode 100644
index 0000000..d4b08fc
--- /dev/null
+++ b/node_modules/color-convert/README.md
@@ -0,0 +1,68 @@
+# color-convert
+
+[](https://travis-ci.org/Qix-/color-convert)
+
+Color-convert is a color conversion library for JavaScript and node.
+It converts all ways between `rgb`, `hsl`, `hsv`, `hwb`, `cmyk`, `ansi`, `ansi16`, `hex` strings, and CSS `keyword`s (will round to closest):
+
+```js
+var convert = require('color-convert');
+
+convert.rgb.hsl(140, 200, 100); // [96, 48, 59]
+convert.keyword.rgb('blue'); // [0, 0, 255]
+
+var rgbChannels = convert.rgb.channels; // 3
+var cmykChannels = convert.cmyk.channels; // 4
+var ansiChannels = convert.ansi16.channels; // 1
+```
+
+# Install
+
+```console
+$ npm install color-convert
+```
+
+# API
+
+Simply get the property of the _from_ and _to_ conversion that you're looking for.
+
+All functions have a rounded and unrounded variant. By default, return values are rounded. To get the unrounded (raw) results, simply tack on `.raw` to the function.
+
+All 'from' functions have a hidden property called `.channels` that indicates the number of channels the function expects (not including alpha).
+
+```js
+var convert = require('color-convert');
+
+// Hex to LAB
+convert.hex.lab('DEADBF'); // [ 76, 21, -2 ]
+convert.hex.lab.raw('DEADBF'); // [ 75.56213190997677, 20.653827952644754, -2.290532499330533 ]
+
+// RGB to CMYK
+convert.rgb.cmyk(167, 255, 4); // [ 35, 0, 98, 0 ]
+convert.rgb.cmyk.raw(167, 255, 4); // [ 34.509803921568626, 0, 98.43137254901961, 0 ]
+```
+
+### Arrays
+All functions that accept multiple arguments also support passing an array.
+
+Note that this does **not** apply to functions that convert from a color that only requires one value (e.g. `keyword`, `ansi256`, `hex`, etc.)
+
+```js
+var convert = require('color-convert');
+
+convert.rgb.hex(123, 45, 67); // '7B2D43'
+convert.rgb.hex([123, 45, 67]); // '7B2D43'
+```
+
+## Routing
+
+Conversions that don't have an _explicitly_ defined conversion (in [conversions.js](conversions.js)), but can be converted by means of sub-conversions (e.g. XYZ -> **RGB** -> CMYK), are automatically routed together. This allows just about any color model supported by `color-convert` to be converted to any other model, so long as a sub-conversion path exists. This is also true for conversions requiring more than one step in between (e.g. LCH -> **LAB** -> **XYZ** -> **RGB** -> Hex).
+
+Keep in mind that extensive conversions _may_ result in a loss of precision, and exist only to be complete. For a list of "direct" (single-step) conversions, see [conversions.js](conversions.js).
+
+# Contribute
+
+If there is a new model you would like to support, or want to add a direct conversion between two existing models, please send us a pull request.
+
+# License
+Copyright © 2011-2016, Heather Arthur and Josh Junon. Licensed under the [MIT License](LICENSE).
diff --git a/node_modules/color-convert/conversions.js b/node_modules/color-convert/conversions.js
new file mode 100644
index 0000000..2657f26
--- /dev/null
+++ b/node_modules/color-convert/conversions.js
@@ -0,0 +1,839 @@
+/* MIT license */
+/* eslint-disable no-mixed-operators */
+const cssKeywords = require('color-name');
+
+// NOTE: conversions should only return primitive values (i.e. arrays, or
+// values that give correct `typeof` results).
+// do not use box values types (i.e. Number(), String(), etc.)
+
+const reverseKeywords = {};
+for (const key of Object.keys(cssKeywords)) {
+ reverseKeywords[cssKeywords[key]] = key;
+}
+
+const convert = {
+ rgb: {channels: 3, labels: 'rgb'},
+ hsl: {channels: 3, labels: 'hsl'},
+ hsv: {channels: 3, labels: 'hsv'},
+ hwb: {channels: 3, labels: 'hwb'},
+ cmyk: {channels: 4, labels: 'cmyk'},
+ xyz: {channels: 3, labels: 'xyz'},
+ lab: {channels: 3, labels: 'lab'},
+ lch: {channels: 3, labels: 'lch'},
+ hex: {channels: 1, labels: ['hex']},
+ keyword: {channels: 1, labels: ['keyword']},
+ ansi16: {channels: 1, labels: ['ansi16']},
+ ansi256: {channels: 1, labels: ['ansi256']},
+ hcg: {channels: 3, labels: ['h', 'c', 'g']},
+ apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
+ gray: {channels: 1, labels: ['gray']}
+};
+
+module.exports = convert;
+
+// Hide .channels and .labels properties
+for (const model of Object.keys(convert)) {
+ if (!('channels' in convert[model])) {
+ throw new Error('missing channels property: ' + model);
+ }
+
+ if (!('labels' in convert[model])) {
+ throw new Error('missing channel labels property: ' + model);
+ }
+
+ if (convert[model].labels.length !== convert[model].channels) {
+ throw new Error('channel and label counts mismatch: ' + model);
+ }
+
+ const {channels, labels} = convert[model];
+ delete convert[model].channels;
+ delete convert[model].labels;
+ Object.defineProperty(convert[model], 'channels', {value: channels});
+ Object.defineProperty(convert[model], 'labels', {value: labels});
+}
+
+convert.rgb.hsl = function (rgb) {
+ const r = rgb[0] / 255;
+ const g = rgb[1] / 255;
+ const b = rgb[2] / 255;
+ const min = Math.min(r, g, b);
+ const max = Math.max(r, g, b);
+ const delta = max - min;
+ let h;
+ let s;
+
+ if (max === min) {
+ h = 0;
+ } else if (r === max) {
+ h = (g - b) / delta;
+ } else if (g === max) {
+ h = 2 + (b - r) / delta;
+ } else if (b === max) {
+ h = 4 + (r - g) / delta;
+ }
+
+ h = Math.min(h * 60, 360);
+
+ if (h < 0) {
+ h += 360;
+ }
+
+ const l = (min + max) / 2;
+
+ if (max === min) {
+ s = 0;
+ } else if (l <= 0.5) {
+ s = delta / (max + min);
+ } else {
+ s = delta / (2 - max - min);
+ }
+
+ return [h, s * 100, l * 100];
+};
+
+convert.rgb.hsv = function (rgb) {
+ let rdif;
+ let gdif;
+ let bdif;
+ let h;
+ let s;
+
+ const r = rgb[0] / 255;
+ const g = rgb[1] / 255;
+ const b = rgb[2] / 255;
+ const v = Math.max(r, g, b);
+ const diff = v - Math.min(r, g, b);
+ const diffc = function (c) {
+ return (v - c) / 6 / diff + 1 / 2;
+ };
+
+ if (diff === 0) {
+ h = 0;
+ s = 0;
+ } else {
+ s = diff / v;
+ rdif = diffc(r);
+ gdif = diffc(g);
+ bdif = diffc(b);
+
+ if (r === v) {
+ h = bdif - gdif;
+ } else if (g === v) {
+ h = (1 / 3) + rdif - bdif;
+ } else if (b === v) {
+ h = (2 / 3) + gdif - rdif;
+ }
+
+ if (h < 0) {
+ h += 1;
+ } else if (h > 1) {
+ h -= 1;
+ }
+ }
+
+ return [
+ h * 360,
+ s * 100,
+ v * 100
+ ];
+};
+
+convert.rgb.hwb = function (rgb) {
+ const r = rgb[0];
+ const g = rgb[1];
+ let b = rgb[2];
+ const h = convert.rgb.hsl(rgb)[0];
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
+
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
+
+ return [h, w * 100, b * 100];
+};
+
+convert.rgb.cmyk = function (rgb) {
+ const r = rgb[0] / 255;
+ const g = rgb[1] / 255;
+ const b = rgb[2] / 255;
+
+ const k = Math.min(1 - r, 1 - g, 1 - b);
+ const c = (1 - r - k) / (1 - k) || 0;
+ const m = (1 - g - k) / (1 - k) || 0;
+ const y = (1 - b - k) / (1 - k) || 0;
+
+ return [c * 100, m * 100, y * 100, k * 100];
+};
+
+function comparativeDistance(x, y) {
+ /*
+ See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
+ */
+ return (
+ ((x[0] - y[0]) ** 2) +
+ ((x[1] - y[1]) ** 2) +
+ ((x[2] - y[2]) ** 2)
+ );
+}
+
+convert.rgb.keyword = function (rgb) {
+ const reversed = reverseKeywords[rgb];
+ if (reversed) {
+ return reversed;
+ }
+
+ let currentClosestDistance = Infinity;
+ let currentClosestKeyword;
+
+ for (const keyword of Object.keys(cssKeywords)) {
+ const value = cssKeywords[keyword];
+
+ // Compute comparative distance
+ const distance = comparativeDistance(rgb, value);
+
+ // Check if its less, if so set as closest
+ if (distance < currentClosestDistance) {
+ currentClosestDistance = distance;
+ currentClosestKeyword = keyword;
+ }
+ }
+
+ return currentClosestKeyword;
+};
+
+convert.keyword.rgb = function (keyword) {
+ return cssKeywords[keyword];
+};
+
+convert.rgb.xyz = function (rgb) {
+ let r = rgb[0] / 255;
+ let g = rgb[1] / 255;
+ let b = rgb[2] / 255;
+
+ // Assume sRGB
+ r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
+ g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
+ b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
+
+ const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
+ const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
+ const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
+
+ return [x * 100, y * 100, z * 100];
+};
+
+convert.rgb.lab = function (rgb) {
+ const xyz = convert.rgb.xyz(rgb);
+ let x = xyz[0];
+ let y = xyz[1];
+ let z = xyz[2];
+
+ x /= 95.047;
+ y /= 100;
+ z /= 108.883;
+
+ x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
+ y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
+ z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
+
+ const l = (116 * y) - 16;
+ const a = 500 * (x - y);
+ const b = 200 * (y - z);
+
+ return [l, a, b];
+};
+
+convert.hsl.rgb = function (hsl) {
+ const h = hsl[0] / 360;
+ const s = hsl[1] / 100;
+ const l = hsl[2] / 100;
+ let t2;
+ let t3;
+ let val;
+
+ if (s === 0) {
+ val = l * 255;
+ return [val, val, val];
+ }
+
+ if (l < 0.5) {
+ t2 = l * (1 + s);
+ } else {
+ t2 = l + s - l * s;
+ }
+
+ const t1 = 2 * l - t2;
+
+ const rgb = [0, 0, 0];
+ for (let i = 0; i < 3; i++) {
+ t3 = h + 1 / 3 * -(i - 1);
+ if (t3 < 0) {
+ t3++;
+ }
+
+ if (t3 > 1) {
+ t3--;
+ }
+
+ if (6 * t3 < 1) {
+ val = t1 + (t2 - t1) * 6 * t3;
+ } else if (2 * t3 < 1) {
+ val = t2;
+ } else if (3 * t3 < 2) {
+ val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
+ } else {
+ val = t1;
+ }
+
+ rgb[i] = val * 255;
+ }
+
+ return rgb;
+};
+
+convert.hsl.hsv = function (hsl) {
+ const h = hsl[0];
+ let s = hsl[1] / 100;
+ let l = hsl[2] / 100;
+ let smin = s;
+ const lmin = Math.max(l, 0.01);
+
+ l *= 2;
+ s *= (l <= 1) ? l : 2 - l;
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
+ const v = (l + s) / 2;
+ const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
+
+ return [h, sv * 100, v * 100];
+};
+
+convert.hsv.rgb = function (hsv) {
+ const h = hsv[0] / 60;
+ const s = hsv[1] / 100;
+ let v = hsv[2] / 100;
+ const hi = Math.floor(h) % 6;
+
+ const f = h - Math.floor(h);
+ const p = 255 * v * (1 - s);
+ const q = 255 * v * (1 - (s * f));
+ const t = 255 * v * (1 - (s * (1 - f)));
+ v *= 255;
+
+ switch (hi) {
+ case 0:
+ return [v, t, p];
+ case 1:
+ return [q, v, p];
+ case 2:
+ return [p, v, t];
+ case 3:
+ return [p, q, v];
+ case 4:
+ return [t, p, v];
+ case 5:
+ return [v, p, q];
+ }
+};
+
+convert.hsv.hsl = function (hsv) {
+ const h = hsv[0];
+ const s = hsv[1] / 100;
+ const v = hsv[2] / 100;
+ const vmin = Math.max(v, 0.01);
+ let sl;
+ let l;
+
+ l = (2 - s) * v;
+ const lmin = (2 - s) * vmin;
+ sl = s * vmin;
+ sl /= (lmin <= 1) ? lmin : 2 - lmin;
+ sl = sl || 0;
+ l /= 2;
+
+ return [h, sl * 100, l * 100];
+};
+
+// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
+convert.hwb.rgb = function (hwb) {
+ const h = hwb[0] / 360;
+ let wh = hwb[1] / 100;
+ let bl = hwb[2] / 100;
+ const ratio = wh + bl;
+ let f;
+
+ // Wh + bl cant be > 1
+ if (ratio > 1) {
+ wh /= ratio;
+ bl /= ratio;
+ }
+
+ const i = Math.floor(6 * h);
+ const v = 1 - bl;
+ f = 6 * h - i;
+
+ if ((i & 0x01) !== 0) {
+ f = 1 - f;
+ }
+
+ const n = wh + f * (v - wh); // Linear interpolation
+
+ let r;
+ let g;
+ let b;
+ /* eslint-disable max-statements-per-line,no-multi-spaces */
+ switch (i) {
+ default:
+ case 6:
+ case 0: r = v; g = n; b = wh; break;
+ case 1: r = n; g = v; b = wh; break;
+ case 2: r = wh; g = v; b = n; break;
+ case 3: r = wh; g = n; b = v; break;
+ case 4: r = n; g = wh; b = v; break;
+ case 5: r = v; g = wh; b = n; break;
+ }
+ /* eslint-enable max-statements-per-line,no-multi-spaces */
+
+ return [r * 255, g * 255, b * 255];
+};
+
+convert.cmyk.rgb = function (cmyk) {
+ const c = cmyk[0] / 100;
+ const m = cmyk[1] / 100;
+ const y = cmyk[2] / 100;
+ const k = cmyk[3] / 100;
+
+ const r = 1 - Math.min(1, c * (1 - k) + k);
+ const g = 1 - Math.min(1, m * (1 - k) + k);
+ const b = 1 - Math.min(1, y * (1 - k) + k);
+
+ return [r * 255, g * 255, b * 255];
+};
+
+convert.xyz.rgb = function (xyz) {
+ const x = xyz[0] / 100;
+ const y = xyz[1] / 100;
+ const z = xyz[2] / 100;
+ let r;
+ let g;
+ let b;
+
+ r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
+ g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
+ b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
+
+ // Assume sRGB
+ r = r > 0.0031308
+ ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
+ : r * 12.92;
+
+ g = g > 0.0031308
+ ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
+ : g * 12.92;
+
+ b = b > 0.0031308
+ ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
+ : b * 12.92;
+
+ r = Math.min(Math.max(0, r), 1);
+ g = Math.min(Math.max(0, g), 1);
+ b = Math.min(Math.max(0, b), 1);
+
+ return [r * 255, g * 255, b * 255];
+};
+
+convert.xyz.lab = function (xyz) {
+ let x = xyz[0];
+ let y = xyz[1];
+ let z = xyz[2];
+
+ x /= 95.047;
+ y /= 100;
+ z /= 108.883;
+
+ x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
+ y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
+ z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
+
+ const l = (116 * y) - 16;
+ const a = 500 * (x - y);
+ const b = 200 * (y - z);
+
+ return [l, a, b];
+};
+
+convert.lab.xyz = function (lab) {
+ const l = lab[0];
+ const a = lab[1];
+ const b = lab[2];
+ let x;
+ let y;
+ let z;
+
+ y = (l + 16) / 116;
+ x = a / 500 + y;
+ z = y - b / 200;
+
+ const y2 = y ** 3;
+ const x2 = x ** 3;
+ const z2 = z ** 3;
+ y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
+ x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
+ z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
+
+ x *= 95.047;
+ y *= 100;
+ z *= 108.883;
+
+ return [x, y, z];
+};
+
+convert.lab.lch = function (lab) {
+ const l = lab[0];
+ const a = lab[1];
+ const b = lab[2];
+ let h;
+
+ const hr = Math.atan2(b, a);
+ h = hr * 360 / 2 / Math.PI;
+
+ if (h < 0) {
+ h += 360;
+ }
+
+ const c = Math.sqrt(a * a + b * b);
+
+ return [l, c, h];
+};
+
+convert.lch.lab = function (lch) {
+ const l = lch[0];
+ const c = lch[1];
+ const h = lch[2];
+
+ const hr = h / 360 * 2 * Math.PI;
+ const a = c * Math.cos(hr);
+ const b = c * Math.sin(hr);
+
+ return [l, a, b];
+};
+
+convert.rgb.ansi16 = function (args, saturation = null) {
+ const [r, g, b] = args;
+ let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
+
+ value = Math.round(value / 50);
+
+ if (value === 0) {
+ return 30;
+ }
+
+ let ansi = 30
+ + ((Math.round(b / 255) << 2)
+ | (Math.round(g / 255) << 1)
+ | Math.round(r / 255));
+
+ if (value === 2) {
+ ansi += 60;
+ }
+
+ return ansi;
+};
+
+convert.hsv.ansi16 = function (args) {
+ // Optimization here; we already know the value and don't need to get
+ // it converted for us.
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
+};
+
+convert.rgb.ansi256 = function (args) {
+ const r = args[0];
+ const g = args[1];
+ const b = args[2];
+
+ // We use the extended greyscale palette here, with the exception of
+ // black and white. normal palette only has 4 greyscale shades.
+ if (r === g && g === b) {
+ if (r < 8) {
+ return 16;
+ }
+
+ if (r > 248) {
+ return 231;
+ }
+
+ return Math.round(((r - 8) / 247) * 24) + 232;
+ }
+
+ const ansi = 16
+ + (36 * Math.round(r / 255 * 5))
+ + (6 * Math.round(g / 255 * 5))
+ + Math.round(b / 255 * 5);
+
+ return ansi;
+};
+
+convert.ansi16.rgb = function (args) {
+ let color = args % 10;
+
+ // Handle greyscale
+ if (color === 0 || color === 7) {
+ if (args > 50) {
+ color += 3.5;
+ }
+
+ color = color / 10.5 * 255;
+
+ return [color, color, color];
+ }
+
+ const mult = (~~(args > 50) + 1) * 0.5;
+ const r = ((color & 1) * mult) * 255;
+ const g = (((color >> 1) & 1) * mult) * 255;
+ const b = (((color >> 2) & 1) * mult) * 255;
+
+ return [r, g, b];
+};
+
+convert.ansi256.rgb = function (args) {
+ // Handle greyscale
+ if (args >= 232) {
+ const c = (args - 232) * 10 + 8;
+ return [c, c, c];
+ }
+
+ args -= 16;
+
+ let rem;
+ const r = Math.floor(args / 36) / 5 * 255;
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
+ const b = (rem % 6) / 5 * 255;
+
+ return [r, g, b];
+};
+
+convert.rgb.hex = function (args) {
+ const integer = ((Math.round(args[0]) & 0xFF) << 16)
+ + ((Math.round(args[1]) & 0xFF) << 8)
+ + (Math.round(args[2]) & 0xFF);
+
+ const string = integer.toString(16).toUpperCase();
+ return '000000'.substring(string.length) + string;
+};
+
+convert.hex.rgb = function (args) {
+ const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
+ if (!match) {
+ return [0, 0, 0];
+ }
+
+ let colorString = match[0];
+
+ if (match[0].length === 3) {
+ colorString = colorString.split('').map(char => {
+ return char + char;
+ }).join('');
+ }
+
+ const integer = parseInt(colorString, 16);
+ const r = (integer >> 16) & 0xFF;
+ const g = (integer >> 8) & 0xFF;
+ const b = integer & 0xFF;
+
+ return [r, g, b];
+};
+
+convert.rgb.hcg = function (rgb) {
+ const r = rgb[0] / 255;
+ const g = rgb[1] / 255;
+ const b = rgb[2] / 255;
+ const max = Math.max(Math.max(r, g), b);
+ const min = Math.min(Math.min(r, g), b);
+ const chroma = (max - min);
+ let grayscale;
+ let hue;
+
+ if (chroma < 1) {
+ grayscale = min / (1 - chroma);
+ } else {
+ grayscale = 0;
+ }
+
+ if (chroma <= 0) {
+ hue = 0;
+ } else
+ if (max === r) {
+ hue = ((g - b) / chroma) % 6;
+ } else
+ if (max === g) {
+ hue = 2 + (b - r) / chroma;
+ } else {
+ hue = 4 + (r - g) / chroma;
+ }
+
+ hue /= 6;
+ hue %= 1;
+
+ return [hue * 360, chroma * 100, grayscale * 100];
+};
+
+convert.hsl.hcg = function (hsl) {
+ const s = hsl[1] / 100;
+ const l = hsl[2] / 100;
+
+ const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
+
+ let f = 0;
+ if (c < 1.0) {
+ f = (l - 0.5 * c) / (1.0 - c);
+ }
+
+ return [hsl[0], c * 100, f * 100];
+};
+
+convert.hsv.hcg = function (hsv) {
+ const s = hsv[1] / 100;
+ const v = hsv[2] / 100;
+
+ const c = s * v;
+ let f = 0;
+
+ if (c < 1.0) {
+ f = (v - c) / (1 - c);
+ }
+
+ return [hsv[0], c * 100, f * 100];
+};
+
+convert.hcg.rgb = function (hcg) {
+ const h = hcg[0] / 360;
+ const c = hcg[1] / 100;
+ const g = hcg[2] / 100;
+
+ if (c === 0.0) {
+ return [g * 255, g * 255, g * 255];
+ }
+
+ const pure = [0, 0, 0];
+ const hi = (h % 1) * 6;
+ const v = hi % 1;
+ const w = 1 - v;
+ let mg = 0;
+
+ /* eslint-disable max-statements-per-line */
+ switch (Math.floor(hi)) {
+ case 0:
+ pure[0] = 1; pure[1] = v; pure[2] = 0; break;
+ case 1:
+ pure[0] = w; pure[1] = 1; pure[2] = 0; break;
+ case 2:
+ pure[0] = 0; pure[1] = 1; pure[2] = v; break;
+ case 3:
+ pure[0] = 0; pure[1] = w; pure[2] = 1; break;
+ case 4:
+ pure[0] = v; pure[1] = 0; pure[2] = 1; break;
+ default:
+ pure[0] = 1; pure[1] = 0; pure[2] = w;
+ }
+ /* eslint-enable max-statements-per-line */
+
+ mg = (1.0 - c) * g;
+
+ return [
+ (c * pure[0] + mg) * 255,
+ (c * pure[1] + mg) * 255,
+ (c * pure[2] + mg) * 255
+ ];
+};
+
+convert.hcg.hsv = function (hcg) {
+ const c = hcg[1] / 100;
+ const g = hcg[2] / 100;
+
+ const v = c + g * (1.0 - c);
+ let f = 0;
+
+ if (v > 0.0) {
+ f = c / v;
+ }
+
+ return [hcg[0], f * 100, v * 100];
+};
+
+convert.hcg.hsl = function (hcg) {
+ const c = hcg[1] / 100;
+ const g = hcg[2] / 100;
+
+ const l = g * (1.0 - c) + 0.5 * c;
+ let s = 0;
+
+ if (l > 0.0 && l < 0.5) {
+ s = c / (2 * l);
+ } else
+ if (l >= 0.5 && l < 1.0) {
+ s = c / (2 * (1 - l));
+ }
+
+ return [hcg[0], s * 100, l * 100];
+};
+
+convert.hcg.hwb = function (hcg) {
+ const c = hcg[1] / 100;
+ const g = hcg[2] / 100;
+ const v = c + g * (1.0 - c);
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
+};
+
+convert.hwb.hcg = function (hwb) {
+ const w = hwb[1] / 100;
+ const b = hwb[2] / 100;
+ const v = 1 - b;
+ const c = v - w;
+ let g = 0;
+
+ if (c < 1) {
+ g = (v - c) / (1 - c);
+ }
+
+ return [hwb[0], c * 100, g * 100];
+};
+
+convert.apple.rgb = function (apple) {
+ return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
+};
+
+convert.rgb.apple = function (rgb) {
+ return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
+};
+
+convert.gray.rgb = function (args) {
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
+};
+
+convert.gray.hsl = function (args) {
+ return [0, 0, args[0]];
+};
+
+convert.gray.hsv = convert.gray.hsl;
+
+convert.gray.hwb = function (gray) {
+ return [0, 100, gray[0]];
+};
+
+convert.gray.cmyk = function (gray) {
+ return [0, 0, 0, gray[0]];
+};
+
+convert.gray.lab = function (gray) {
+ return [gray[0], 0, 0];
+};
+
+convert.gray.hex = function (gray) {
+ const val = Math.round(gray[0] / 100 * 255) & 0xFF;
+ const integer = (val << 16) + (val << 8) + val;
+
+ const string = integer.toString(16).toUpperCase();
+ return '000000'.substring(string.length) + string;
+};
+
+convert.rgb.gray = function (rgb) {
+ const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
+ return [val / 255 * 100];
+};
diff --git a/node_modules/color-convert/index.js b/node_modules/color-convert/index.js
new file mode 100644
index 0000000..b648e57
--- /dev/null
+++ b/node_modules/color-convert/index.js
@@ -0,0 +1,81 @@
+const conversions = require('./conversions');
+const route = require('./route');
+
+const convert = {};
+
+const models = Object.keys(conversions);
+
+function wrapRaw(fn) {
+ const wrappedFn = function (...args) {
+ const arg0 = args[0];
+ if (arg0 === undefined || arg0 === null) {
+ return arg0;
+ }
+
+ if (arg0.length > 1) {
+ args = arg0;
+ }
+
+ return fn(args);
+ };
+
+ // Preserve .conversion property if there is one
+ if ('conversion' in fn) {
+ wrappedFn.conversion = fn.conversion;
+ }
+
+ return wrappedFn;
+}
+
+function wrapRounded(fn) {
+ const wrappedFn = function (...args) {
+ const arg0 = args[0];
+
+ if (arg0 === undefined || arg0 === null) {
+ return arg0;
+ }
+
+ if (arg0.length > 1) {
+ args = arg0;
+ }
+
+ const result = fn(args);
+
+ // We're assuming the result is an array here.
+ // see notice in conversions.js; don't use box types
+ // in conversion functions.
+ if (typeof result === 'object') {
+ for (let len = result.length, i = 0; i < len; i++) {
+ result[i] = Math.round(result[i]);
+ }
+ }
+
+ return result;
+ };
+
+ // Preserve .conversion property if there is one
+ if ('conversion' in fn) {
+ wrappedFn.conversion = fn.conversion;
+ }
+
+ return wrappedFn;
+}
+
+models.forEach(fromModel => {
+ convert[fromModel] = {};
+
+ Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
+ Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
+
+ const routes = route(fromModel);
+ const routeModels = Object.keys(routes);
+
+ routeModels.forEach(toModel => {
+ const fn = routes[toModel];
+
+ convert[fromModel][toModel] = wrapRounded(fn);
+ convert[fromModel][toModel].raw = wrapRaw(fn);
+ });
+});
+
+module.exports = convert;
diff --git a/node_modules/color-convert/package.json b/node_modules/color-convert/package.json
new file mode 100644
index 0000000..6e48000
--- /dev/null
+++ b/node_modules/color-convert/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "color-convert",
+ "description": "Plain color conversion functions",
+ "version": "2.0.1",
+ "author": "Heather Arthur ",
+ "license": "MIT",
+ "repository": "Qix-/color-convert",
+ "scripts": {
+ "pretest": "xo",
+ "test": "node test/basic.js"
+ },
+ "engines": {
+ "node": ">=7.0.0"
+ },
+ "keywords": [
+ "color",
+ "colour",
+ "convert",
+ "converter",
+ "conversion",
+ "rgb",
+ "hsl",
+ "hsv",
+ "hwb",
+ "cmyk",
+ "ansi",
+ "ansi16"
+ ],
+ "files": [
+ "index.js",
+ "conversions.js",
+ "route.js"
+ ],
+ "xo": {
+ "rules": {
+ "default-case": 0,
+ "no-inline-comments": 0,
+ "operator-linebreak": 0
+ }
+ },
+ "devDependencies": {
+ "chalk": "^2.4.2",
+ "xo": "^0.24.0"
+ },
+ "dependencies": {
+ "color-name": "~1.1.4"
+ }
+}
diff --git a/node_modules/color-convert/route.js b/node_modules/color-convert/route.js
new file mode 100644
index 0000000..1a08521
--- /dev/null
+++ b/node_modules/color-convert/route.js
@@ -0,0 +1,97 @@
+const conversions = require('./conversions');
+
+/*
+ This function routes a model to all other models.
+
+ all functions that are routed have a property `.conversion` attached
+ to the returned synthetic function. This property is an array
+ of strings, each with the steps in between the 'from' and 'to'
+ color models (inclusive).
+
+ conversions that are not possible simply are not included.
+*/
+
+function buildGraph() {
+ const graph = {};
+ // https://jsperf.com/object-keys-vs-for-in-with-closure/3
+ const models = Object.keys(conversions);
+
+ for (let len = models.length, i = 0; i < len; i++) {
+ graph[models[i]] = {
+ // http://jsperf.com/1-vs-infinity
+ // micro-opt, but this is simple.
+ distance: -1,
+ parent: null
+ };
+ }
+
+ return graph;
+}
+
+// https://en.wikipedia.org/wiki/Breadth-first_search
+function deriveBFS(fromModel) {
+ const graph = buildGraph();
+ const queue = [fromModel]; // Unshift -> queue -> pop
+
+ graph[fromModel].distance = 0;
+
+ while (queue.length) {
+ const current = queue.pop();
+ const adjacents = Object.keys(conversions[current]);
+
+ for (let len = adjacents.length, i = 0; i < len; i++) {
+ const adjacent = adjacents[i];
+ const node = graph[adjacent];
+
+ if (node.distance === -1) {
+ node.distance = graph[current].distance + 1;
+ node.parent = current;
+ queue.unshift(adjacent);
+ }
+ }
+ }
+
+ return graph;
+}
+
+function link(from, to) {
+ return function (args) {
+ return to(from(args));
+ };
+}
+
+function wrapConversion(toModel, graph) {
+ const path = [graph[toModel].parent, toModel];
+ let fn = conversions[graph[toModel].parent][toModel];
+
+ let cur = graph[toModel].parent;
+ while (graph[cur].parent) {
+ path.unshift(graph[cur].parent);
+ fn = link(conversions[graph[cur].parent][cur], fn);
+ cur = graph[cur].parent;
+ }
+
+ fn.conversion = path;
+ return fn;
+}
+
+module.exports = function (fromModel) {
+ const graph = deriveBFS(fromModel);
+ const conversion = {};
+
+ const models = Object.keys(graph);
+ for (let len = models.length, i = 0; i < len; i++) {
+ const toModel = models[i];
+ const node = graph[toModel];
+
+ if (node.parent === null) {
+ // No possible conversion, or this node is the source model.
+ continue;
+ }
+
+ conversion[toModel] = wrapConversion(toModel, graph);
+ }
+
+ return conversion;
+};
+
diff --git a/node_modules/color-name/LICENSE b/node_modules/color-name/LICENSE
new file mode 100644
index 0000000..c6b1001
--- /dev/null
+++ b/node_modules/color-name/LICENSE
@@ -0,0 +1,8 @@
+The MIT License (MIT)
+Copyright (c) 2015 Dmitry Ivanov
+
+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.
\ No newline at end of file
diff --git a/node_modules/color-name/README.md b/node_modules/color-name/README.md
new file mode 100644
index 0000000..932b979
--- /dev/null
+++ b/node_modules/color-name/README.md
@@ -0,0 +1,11 @@
+A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors.
+
+[](https://nodei.co/npm/color-name/)
+
+
+```js
+var colors = require('color-name');
+colors.red //[255,0,0]
+```
+
+
diff --git a/node_modules/color-name/index.js b/node_modules/color-name/index.js
new file mode 100644
index 0000000..b7c198a
--- /dev/null
+++ b/node_modules/color-name/index.js
@@ -0,0 +1,152 @@
+'use strict'
+
+module.exports = {
+ "aliceblue": [240, 248, 255],
+ "antiquewhite": [250, 235, 215],
+ "aqua": [0, 255, 255],
+ "aquamarine": [127, 255, 212],
+ "azure": [240, 255, 255],
+ "beige": [245, 245, 220],
+ "bisque": [255, 228, 196],
+ "black": [0, 0, 0],
+ "blanchedalmond": [255, 235, 205],
+ "blue": [0, 0, 255],
+ "blueviolet": [138, 43, 226],
+ "brown": [165, 42, 42],
+ "burlywood": [222, 184, 135],
+ "cadetblue": [95, 158, 160],
+ "chartreuse": [127, 255, 0],
+ "chocolate": [210, 105, 30],
+ "coral": [255, 127, 80],
+ "cornflowerblue": [100, 149, 237],
+ "cornsilk": [255, 248, 220],
+ "crimson": [220, 20, 60],
+ "cyan": [0, 255, 255],
+ "darkblue": [0, 0, 139],
+ "darkcyan": [0, 139, 139],
+ "darkgoldenrod": [184, 134, 11],
+ "darkgray": [169, 169, 169],
+ "darkgreen": [0, 100, 0],
+ "darkgrey": [169, 169, 169],
+ "darkkhaki": [189, 183, 107],
+ "darkmagenta": [139, 0, 139],
+ "darkolivegreen": [85, 107, 47],
+ "darkorange": [255, 140, 0],
+ "darkorchid": [153, 50, 204],
+ "darkred": [139, 0, 0],
+ "darksalmon": [233, 150, 122],
+ "darkseagreen": [143, 188, 143],
+ "darkslateblue": [72, 61, 139],
+ "darkslategray": [47, 79, 79],
+ "darkslategrey": [47, 79, 79],
+ "darkturquoise": [0, 206, 209],
+ "darkviolet": [148, 0, 211],
+ "deeppink": [255, 20, 147],
+ "deepskyblue": [0, 191, 255],
+ "dimgray": [105, 105, 105],
+ "dimgrey": [105, 105, 105],
+ "dodgerblue": [30, 144, 255],
+ "firebrick": [178, 34, 34],
+ "floralwhite": [255, 250, 240],
+ "forestgreen": [34, 139, 34],
+ "fuchsia": [255, 0, 255],
+ "gainsboro": [220, 220, 220],
+ "ghostwhite": [248, 248, 255],
+ "gold": [255, 215, 0],
+ "goldenrod": [218, 165, 32],
+ "gray": [128, 128, 128],
+ "green": [0, 128, 0],
+ "greenyellow": [173, 255, 47],
+ "grey": [128, 128, 128],
+ "honeydew": [240, 255, 240],
+ "hotpink": [255, 105, 180],
+ "indianred": [205, 92, 92],
+ "indigo": [75, 0, 130],
+ "ivory": [255, 255, 240],
+ "khaki": [240, 230, 140],
+ "lavender": [230, 230, 250],
+ "lavenderblush": [255, 240, 245],
+ "lawngreen": [124, 252, 0],
+ "lemonchiffon": [255, 250, 205],
+ "lightblue": [173, 216, 230],
+ "lightcoral": [240, 128, 128],
+ "lightcyan": [224, 255, 255],
+ "lightgoldenrodyellow": [250, 250, 210],
+ "lightgray": [211, 211, 211],
+ "lightgreen": [144, 238, 144],
+ "lightgrey": [211, 211, 211],
+ "lightpink": [255, 182, 193],
+ "lightsalmon": [255, 160, 122],
+ "lightseagreen": [32, 178, 170],
+ "lightskyblue": [135, 206, 250],
+ "lightslategray": [119, 136, 153],
+ "lightslategrey": [119, 136, 153],
+ "lightsteelblue": [176, 196, 222],
+ "lightyellow": [255, 255, 224],
+ "lime": [0, 255, 0],
+ "limegreen": [50, 205, 50],
+ "linen": [250, 240, 230],
+ "magenta": [255, 0, 255],
+ "maroon": [128, 0, 0],
+ "mediumaquamarine": [102, 205, 170],
+ "mediumblue": [0, 0, 205],
+ "mediumorchid": [186, 85, 211],
+ "mediumpurple": [147, 112, 219],
+ "mediumseagreen": [60, 179, 113],
+ "mediumslateblue": [123, 104, 238],
+ "mediumspringgreen": [0, 250, 154],
+ "mediumturquoise": [72, 209, 204],
+ "mediumvioletred": [199, 21, 133],
+ "midnightblue": [25, 25, 112],
+ "mintcream": [245, 255, 250],
+ "mistyrose": [255, 228, 225],
+ "moccasin": [255, 228, 181],
+ "navajowhite": [255, 222, 173],
+ "navy": [0, 0, 128],
+ "oldlace": [253, 245, 230],
+ "olive": [128, 128, 0],
+ "olivedrab": [107, 142, 35],
+ "orange": [255, 165, 0],
+ "orangered": [255, 69, 0],
+ "orchid": [218, 112, 214],
+ "palegoldenrod": [238, 232, 170],
+ "palegreen": [152, 251, 152],
+ "paleturquoise": [175, 238, 238],
+ "palevioletred": [219, 112, 147],
+ "papayawhip": [255, 239, 213],
+ "peachpuff": [255, 218, 185],
+ "peru": [205, 133, 63],
+ "pink": [255, 192, 203],
+ "plum": [221, 160, 221],
+ "powderblue": [176, 224, 230],
+ "purple": [128, 0, 128],
+ "rebeccapurple": [102, 51, 153],
+ "red": [255, 0, 0],
+ "rosybrown": [188, 143, 143],
+ "royalblue": [65, 105, 225],
+ "saddlebrown": [139, 69, 19],
+ "salmon": [250, 128, 114],
+ "sandybrown": [244, 164, 96],
+ "seagreen": [46, 139, 87],
+ "seashell": [255, 245, 238],
+ "sienna": [160, 82, 45],
+ "silver": [192, 192, 192],
+ "skyblue": [135, 206, 235],
+ "slateblue": [106, 90, 205],
+ "slategray": [112, 128, 144],
+ "slategrey": [112, 128, 144],
+ "snow": [255, 250, 250],
+ "springgreen": [0, 255, 127],
+ "steelblue": [70, 130, 180],
+ "tan": [210, 180, 140],
+ "teal": [0, 128, 128],
+ "thistle": [216, 191, 216],
+ "tomato": [255, 99, 71],
+ "turquoise": [64, 224, 208],
+ "violet": [238, 130, 238],
+ "wheat": [245, 222, 179],
+ "white": [255, 255, 255],
+ "whitesmoke": [245, 245, 245],
+ "yellow": [255, 255, 0],
+ "yellowgreen": [154, 205, 50]
+};
diff --git a/node_modules/color-name/package.json b/node_modules/color-name/package.json
new file mode 100644
index 0000000..782dd82
--- /dev/null
+++ b/node_modules/color-name/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "color-name",
+ "version": "1.1.4",
+ "description": "A list of color names and its values",
+ "main": "index.js",
+ "files": [
+ "index.js"
+ ],
+ "scripts": {
+ "test": "node test.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:colorjs/color-name.git"
+ },
+ "keywords": [
+ "color-name",
+ "color",
+ "color-keyword",
+ "keyword"
+ ],
+ "author": "DY ",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/colorjs/color-name/issues"
+ },
+ "homepage": "https://github.com/colorjs/color-name"
+}
diff --git a/node_modules/commander/LICENSE b/node_modules/commander/LICENSE
new file mode 100644
index 0000000..10f997a
--- /dev/null
+++ b/node_modules/commander/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2011 TJ Holowaychuk
+
+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.
diff --git a/node_modules/commander/Readme.md b/node_modules/commander/Readme.md
new file mode 100644
index 0000000..ed19cff
--- /dev/null
+++ b/node_modules/commander/Readme.md
@@ -0,0 +1,1129 @@
+# Commander.js
+
+[](https://github.com/tj/commander.js/actions?query=workflow%3A%22build%22)
+[](https://www.npmjs.org/package/commander)
+[](https://npmcharts.com/compare/commander?minimal=true)
+[](https://packagephobia.now.sh/result?p=commander)
+
+The complete solution for [node.js](http://nodejs.org) command-line interfaces.
+
+Read this in other languages: English | [简体中文](./Readme_zh-CN.md)
+
+- [Commander.js](#commanderjs)
+ - [Installation](#installation)
+ - [Quick Start](#quick-start)
+ - [Declaring _program_ variable](#declaring-program-variable)
+ - [Options](#options)
+ - [Common option types, boolean and value](#common-option-types-boolean-and-value)
+ - [Default option value](#default-option-value)
+ - [Other option types, negatable boolean and boolean|value](#other-option-types-negatable-boolean-and-booleanvalue)
+ - [Required option](#required-option)
+ - [Variadic option](#variadic-option)
+ - [Version option](#version-option)
+ - [More configuration](#more-configuration)
+ - [Custom option processing](#custom-option-processing)
+ - [Commands](#commands)
+ - [Command-arguments](#command-arguments)
+ - [More configuration](#more-configuration-1)
+ - [Custom argument processing](#custom-argument-processing)
+ - [Action handler](#action-handler)
+ - [Stand-alone executable (sub)commands](#stand-alone-executable-subcommands)
+ - [Life cycle hooks](#life-cycle-hooks)
+ - [Automated help](#automated-help)
+ - [Custom help](#custom-help)
+ - [Display help after errors](#display-help-after-errors)
+ - [Display help from code](#display-help-from-code)
+ - [.name](#name)
+ - [.usage](#usage)
+ - [.description and .summary](#description-and-summary)
+ - [.helpOption(flags, description)](#helpoptionflags-description)
+ - [.addHelpCommand()](#addhelpcommand)
+ - [More configuration](#more-configuration-2)
+ - [Custom event listeners](#custom-event-listeners)
+ - [Bits and pieces](#bits-and-pieces)
+ - [.parse() and .parseAsync()](#parse-and-parseasync)
+ - [Parsing Configuration](#parsing-configuration)
+ - [Legacy options as properties](#legacy-options-as-properties)
+ - [TypeScript](#typescript)
+ - [createCommand()](#createcommand)
+ - [Node options such as `--harmony`](#node-options-such-as---harmony)
+ - [Debugging stand-alone executable subcommands](#debugging-stand-alone-executable-subcommands)
+ - [Display error](#display-error)
+ - [Override exit and output handling](#override-exit-and-output-handling)
+ - [Additional documentation](#additional-documentation)
+ - [Support](#support)
+ - [Commander for enterprise](#commander-for-enterprise)
+
+For information about terms used in this document see: [terminology](./docs/terminology.md)
+
+## Installation
+
+```sh
+npm install commander
+```
+
+## Quick Start
+
+You write code to describe your command line interface.
+Commander looks after parsing the arguments into options and command-arguments,
+displays usage errors for problems, and implements a help system.
+
+Commander is strict and displays an error for unrecognised options.
+The two most used option types are a boolean option, and an option which takes its value from the following argument.
+
+Example file: [split.js](./examples/split.js)
+
+```js
+const { program } = require('commander');
+
+program
+ .option('--first')
+ .option('-s, --separator ');
+
+program.parse();
+
+const options = program.opts();
+const limit = options.first ? 1 : undefined;
+console.log(program.args[0].split(options.separator, limit));
+```
+
+```console
+$ node split.js -s / --fits a/b/c
+error: unknown option '--fits'
+(Did you mean --first?)
+$ node split.js -s / --first a/b/c
+[ 'a' ]
+```
+
+Here is a more complete program using a subcommand and with descriptions for the help. In a multi-command program, you have an action handler for each command (or stand-alone executables for the commands).
+
+Example file: [string-util.js](./examples/string-util.js)
+
+```js
+const { Command } = require('commander');
+const program = new Command();
+
+program
+ .name('string-util')
+ .description('CLI to some JavaScript string utilities')
+ .version('0.8.0');
+
+program.command('split')
+ .description('Split a string into substrings and display as an array')
+ .argument('', 'string to split')
+ .option('--first', 'display just the first substring')
+ .option('-s, --separator ', 'separator character', ',')
+ .action((str, options) => {
+ const limit = options.first ? 1 : undefined;
+ console.log(str.split(options.separator, limit));
+ });
+
+program.parse();
+```
+
+```console
+$ node string-util.js help split
+Usage: string-util split [options]
+
+Split a string into substrings and display as an array.
+
+Arguments:
+ string string to split
+
+Options:
+ --first display just the first substring
+ -s, --separator separator character (default: ",")
+ -h, --help display help for command
+
+$ node string-util.js split --separator=/ a/b/c
+[ 'a', 'b', 'c' ]
+```
+
+More samples can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.
+
+## Declaring _program_ variable
+
+Commander exports a global object which is convenient for quick programs.
+This is used in the examples in this README for brevity.
+
+```js
+// CommonJS (.cjs)
+const { program } = require('commander');
+```
+
+For larger programs which may use commander in multiple ways, including unit testing, it is better to create a local Command object to use.
+
+```js
+// CommonJS (.cjs)
+const { Command } = require('commander');
+const program = new Command();
+```
+
+```js
+// ECMAScript (.mjs)
+import { Command } from 'commander';
+const program = new Command();
+```
+
+```ts
+// TypeScript (.ts)
+import { Command } from 'commander';
+const program = new Command();
+```
+
+## Options
+
+Options are defined with the `.option()` method, also serving as documentation for the options. Each option can have a short flag (single character) and a long name, separated by a comma or space or vertical bar ('|').
+
+The parsed options can be accessed by calling `.opts()` on a `Command` object, and are passed to the action handler.
+
+Multi-word options such as "--template-engine" are camel-cased, becoming `program.opts().templateEngine` etc.
+
+An option and its option-argument can be separated by a space, or combined into the same argument. The option-argument can follow the short option directly or follow an `=` for a long option.
+
+```sh
+serve -p 80
+serve -p80
+serve --port 80
+serve --port=80
+```
+
+You can use `--` to indicate the end of the options, and any remaining arguments will be used without being interpreted.
+
+By default options on the command line are not positional, and can be specified before or after other arguments.
+
+There are additional related routines for when `.opts()` is not enough:
+
+- `.optsWithGlobals()` returns merged local and global option values
+- `.getOptionValue()` and `.setOptionValue()` work with a single option value
+- `.getOptionValueSource()` and `.setOptionValueWithSource()` include where the option value came from
+
+### Common option types, boolean and value
+
+The two most used option types are a boolean option, and an option which takes its value
+from the following argument (declared with angle brackets like `--expect `). Both are `undefined` unless specified on command line.
+
+Example file: [options-common.js](./examples/options-common.js)
+
+```js
+program
+ .option('-d, --debug', 'output extra debugging')
+ .option('-s, --small', 'small pizza size')
+ .option('-p, --pizza-type ', 'flavour of pizza');
+
+program.parse(process.argv);
+
+const options = program.opts();
+if (options.debug) console.log(options);
+console.log('pizza details:');
+if (options.small) console.log('- small pizza size');
+if (options.pizzaType) console.log(`- ${options.pizzaType}`);
+```
+
+```console
+$ pizza-options -p
+error: option '-p, --pizza-type ' argument missing
+$ pizza-options -d -s -p vegetarian
+{ debug: true, small: true, pizzaType: 'vegetarian' }
+pizza details:
+- small pizza size
+- vegetarian
+$ pizza-options --pizza-type=cheese
+pizza details:
+- cheese
+```
+
+Multiple boolean short options may be combined together following the dash, and may be followed by a single short option taking a value.
+For example `-d -s -p cheese` may be written as `-ds -p cheese` or even `-dsp cheese`.
+
+Options with an expected option-argument are greedy and will consume the following argument whatever the value.
+So `--id -xyz` reads `-xyz` as the option-argument.
+
+`program.parse(arguments)` processes the arguments, leaving any args not consumed by the program options in the `program.args` array. The parameter is optional and defaults to `process.argv`.
+
+### Default option value
+
+You can specify a default value for an option.
+
+Example file: [options-defaults.js](./examples/options-defaults.js)
+
+```js
+program
+ .option('-c, --cheese ', 'add the specified type of cheese', 'blue');
+
+program.parse();
+
+console.log(`cheese: ${program.opts().cheese}`);
+```
+
+```console
+$ pizza-options
+cheese: blue
+$ pizza-options --cheese stilton
+cheese: stilton
+```
+
+### Other option types, negatable boolean and boolean|value
+
+You can define a boolean option long name with a leading `no-` to set the option value to false when used.
+Defined alone this also makes the option true by default.
+
+If you define `--foo` first, adding `--no-foo` does not change the default value from what it would
+otherwise be.
+
+Example file: [options-negatable.js](./examples/options-negatable.js)
+
+```js
+program
+ .option('--no-sauce', 'Remove sauce')
+ .option('--cheese ', 'cheese flavour', 'mozzarella')
+ .option('--no-cheese', 'plain with no cheese')
+ .parse();
+
+const options = program.opts();
+const sauceStr = options.sauce ? 'sauce' : 'no sauce';
+const cheeseStr = (options.cheese === false) ? 'no cheese' : `${options.cheese} cheese`;
+console.log(`You ordered a pizza with ${sauceStr} and ${cheeseStr}`);
+```
+
+```console
+$ pizza-options
+You ordered a pizza with sauce and mozzarella cheese
+$ pizza-options --sauce
+error: unknown option '--sauce'
+$ pizza-options --cheese=blue
+You ordered a pizza with sauce and blue cheese
+$ pizza-options --no-sauce --no-cheese
+You ordered a pizza with no sauce and no cheese
+```
+
+You can specify an option which may be used as a boolean option but may optionally take an option-argument
+(declared with square brackets like `--optional [value]`).
+
+Example file: [options-boolean-or-value.js](./examples/options-boolean-or-value.js)
+
+```js
+program
+ .option('-c, --cheese [type]', 'Add cheese with optional type');
+
+program.parse(process.argv);
+
+const options = program.opts();
+if (options.cheese === undefined) console.log('no cheese');
+else if (options.cheese === true) console.log('add cheese');
+else console.log(`add cheese type ${options.cheese}`);
+```
+
+```console
+$ pizza-options
+no cheese
+$ pizza-options --cheese
+add cheese
+$ pizza-options --cheese mozzarella
+add cheese type mozzarella
+```
+
+Options with an optional option-argument are not greedy and will ignore arguments starting with a dash.
+So `id` behaves as a boolean option for `--id -5`, but you can use a combined form if needed like `--id=-5`.
+
+For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md).
+
+### Required option
+
+You may specify a required (mandatory) option using `.requiredOption()`. The option must have a value after parsing, usually specified on the command line, or perhaps from a default value (say from environment). The method is otherwise the same as `.option()` in format, taking flags and description, and optional default value or custom processing.
+
+Example file: [options-required.js](./examples/options-required.js)
+
+```js
+program
+ .requiredOption('-c, --cheese ', 'pizza must have cheese');
+
+program.parse();
+```
+
+```console
+$ pizza
+error: required option '-c, --cheese ' not specified
+```
+
+### Variadic option
+
+You may make an option variadic by appending `...` to the value placeholder when declaring the option. On the command line you
+can then specify multiple option-arguments, and the parsed option value will be an array. The extra arguments
+are read until the first argument starting with a dash. The special argument `--` stops option processing entirely. If a value
+is specified in the same argument as the option then no further values are read.
+
+Example file: [options-variadic.js](./examples/options-variadic.js)
+
+```js
+program
+ .option('-n, --number ', 'specify numbers')
+ .option('-l, --letter [letters...]', 'specify letters');
+
+program.parse();
+
+console.log('Options: ', program.opts());
+console.log('Remaining arguments: ', program.args);
+```
+
+```console
+$ collect -n 1 2 3 --letter a b c
+Options: { number: [ '1', '2', '3' ], letter: [ 'a', 'b', 'c' ] }
+Remaining arguments: []
+$ collect --letter=A -n80 operand
+Options: { number: [ '80' ], letter: [ 'A' ] }
+Remaining arguments: [ 'operand' ]
+$ collect --letter -n 1 -n 2 3 -- operand
+Options: { number: [ '1', '2', '3' ], letter: true }
+Remaining arguments: [ 'operand' ]
+```
+
+For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md).
+
+### Version option
+
+The optional `version` method adds handling for displaying the command version. The default option flags are `-V` and `--version`, and when present the command prints the version number and exits.
+
+```js
+program.version('0.0.1');
+```
+
+```console
+$ ./examples/pizza -V
+0.0.1
+```
+
+You may change the flags and description by passing additional parameters to the `version` method, using
+the same syntax for flags as the `option` method.
+
+```js
+program.version('0.0.1', '-v, --vers', 'output the current version');
+```
+
+### More configuration
+
+You can add most options using the `.option()` method, but there are some additional features available
+by constructing an `Option` explicitly for less common cases.
+
+Example files: [options-extra.js](./examples/options-extra.js), [options-env.js](./examples/options-env.js), [options-conflicts.js](./examples/options-conflicts.js), [options-implies.js](./examples/options-implies.js)
+
+```js
+program
+ .addOption(new Option('-s, --secret').hideHelp())
+ .addOption(new Option('-t, --timeout ', 'timeout in seconds').default(60, 'one minute'))
+ .addOption(new Option('-d, --drink ', 'drink size').choices(['small', 'medium', 'large']))
+ .addOption(new Option('-p, --port ', 'port number').env('PORT'))
+ .addOption(new Option('--donate [amount]', 'optional donation in dollars').preset('20').argParser(parseFloat))
+ .addOption(new Option('--disable-server', 'disables the server').conflicts('port'))
+ .addOption(new Option('--free-drink', 'small drink included free ').implies({ drink: 'small' }));
+```
+
+```console
+$ extra --help
+Usage: help [options]
+
+Options:
+ -t, --timeout timeout in seconds (default: one minute)
+ -d, --drink drink cup size (choices: "small", "medium", "large")
+ -p, --port port number (env: PORT)
+ --donate [amount] optional donation in dollars (preset: "20")
+ --disable-server disables the server
+ --free-drink small drink included free
+ -h, --help display help for command
+
+$ extra --drink huge
+error: option '-d, --drink ' argument 'huge' is invalid. Allowed choices are small, medium, large.
+
+$ PORT=80 extra --donate --free-drink
+Options: { timeout: 60, donate: 20, port: '80', freeDrink: true, drink: 'small' }
+
+$ extra --disable-server --port 8000
+error: option '--disable-server' cannot be used with option '-p, --port '
+```
+
+Specify a required (mandatory) option using the `Option` method `.makeOptionMandatory()`. This matches the `Command` method [.requiredOption()](#required-option).
+
+### Custom option processing
+
+You may specify a function to do custom processing of option-arguments. The callback function receives two parameters,
+the user specified option-argument and the previous value for the option. It returns the new value for the option.
+
+This allows you to coerce the option-argument to the desired type, or accumulate values, or do entirely custom processing.
+
+You can optionally specify the default/starting value for the option after the function parameter.
+
+Example file: [options-custom-processing.js](./examples/options-custom-processing.js)
+
+```js
+function myParseInt(value, dummyPrevious) {
+ // parseInt takes a string and a radix
+ const parsedValue = parseInt(value, 10);
+ if (isNaN(parsedValue)) {
+ throw new commander.InvalidArgumentError('Not a number.');
+ }
+ return parsedValue;
+}
+
+function increaseVerbosity(dummyValue, previous) {
+ return previous + 1;
+}
+
+function collect(value, previous) {
+ return previous.concat([value]);
+}
+
+function commaSeparatedList(value, dummyPrevious) {
+ return value.split(',');
+}
+
+program
+ .option('-f, --float ', 'float argument', parseFloat)
+ .option('-i, --integer ', 'integer argument', myParseInt)
+ .option('-v, --verbose', 'verbosity that can be increased', increaseVerbosity, 0)
+ .option('-c, --collect ', 'repeatable value', collect, [])
+ .option('-l, --list ', 'comma separated list', commaSeparatedList)
+;
+
+program.parse();
+
+const options = program.opts();
+if (options.float !== undefined) console.log(`float: ${options.float}`);
+if (options.integer !== undefined) console.log(`integer: ${options.integer}`);
+if (options.verbose > 0) console.log(`verbosity: ${options.verbose}`);
+if (options.collect.length > 0) console.log(options.collect);
+if (options.list !== undefined) console.log(options.list);
+```
+
+```console
+$ custom -f 1e2
+float: 100
+$ custom --integer 2
+integer: 2
+$ custom -v -v -v
+verbose: 3
+$ custom -c a -c b -c c
+[ 'a', 'b', 'c' ]
+$ custom --list x,y,z
+[ 'x', 'y', 'z' ]
+```
+
+## Commands
+
+You can specify (sub)commands using `.command()` or `.addCommand()`. There are two ways these can be implemented: using an action handler attached to the command, or as a stand-alone executable file (described in more detail later). The subcommands may be nested ([example](./examples/nestedCommands.js)).
+
+In the first parameter to `.command()` you specify the command name. You may append the command-arguments after the command name, or specify them separately using `.argument()`. The arguments may be `` or `[optional]`, and the last argument may also be `variadic...`.
+
+You can use `.addCommand()` to add an already configured subcommand to the program.
+
+For example:
+
+```js
+// Command implemented using action handler (description is supplied separately to `.command`)
+// Returns new command for configuring.
+program
+ .command('clone [destination]')
+ .description('clone a repository into a newly created directory')
+ .action((source, destination) => {
+ console.log('clone command called');
+ });
+
+// Command implemented using stand-alone executable file, indicated by adding description as second parameter to `.command`.
+// Returns `this` for adding more commands.
+program
+ .command('start ', 'start named service')
+ .command('stop [service]', 'stop named service, or all if no name supplied');
+
+// Command prepared separately.
+// Returns `this` for adding more commands.
+program
+ .addCommand(build.makeBuildCommand());
+```
+
+Configuration options can be passed with the call to `.command()` and `.addCommand()`. Specifying `hidden: true` will
+remove the command from the generated help output. Specifying `isDefault: true` will run the subcommand if no other
+subcommand is specified ([example](./examples/defaultCommand.js)).
+
+You can add alternative names for a command with `.alias()`. ([example](./examples/alias.js))
+
+For safety, `.addCommand()` does not automatically copy the inherited settings from the parent command. There is a helper routine `.copyInheritedSettings()` for copying the settings when they are wanted.
+
+### Command-arguments
+
+For subcommands, you can specify the argument syntax in the call to `.command()` (as shown above). This
+is the only method usable for subcommands implemented using a stand-alone executable, but for other subcommands
+you can instead use the following method.
+
+To configure a command, you can use `.argument()` to specify each expected command-argument.
+You supply the argument name and an optional description. The argument may be `` or `[optional]`.
+You can specify a default value for an optional command-argument.
+
+Example file: [argument.js](./examples/argument.js)
+
+```js
+program
+ .version('0.1.0')
+ .argument('', 'user to login')
+ .argument('[password]', 'password for user, if required', 'no password given')
+ .action((username, password) => {
+ console.log('username:', username);
+ console.log('password:', password);
+ });
+```
+
+ The last argument of a command can be variadic, and only the last argument. To make an argument variadic you
+ append `...` to the argument name. A variadic argument is passed to the action handler as an array. For example:
+
+```js
+program
+ .version('0.1.0')
+ .command('rmdir')
+ .argument('')
+ .action(function (dirs) {
+ dirs.forEach((dir) => {
+ console.log('rmdir %s', dir);
+ });
+ });
+```
+
+There is a convenience method to add multiple arguments at once, but without descriptions:
+
+```js
+program
+ .arguments(' ');
+```
+
+#### More configuration
+
+There are some additional features available by constructing an `Argument` explicitly for less common cases.
+
+Example file: [arguments-extra.js](./examples/arguments-extra.js)
+
+```js
+program
+ .addArgument(new commander.Argument('', 'drink cup size').choices(['small', 'medium', 'large']))
+ .addArgument(new commander.Argument('[timeout]', 'timeout in seconds').default(60, 'one minute'))
+```
+
+#### Custom argument processing
+
+You may specify a function to do custom processing of command-arguments (like for option-arguments).
+The callback function receives two parameters, the user specified command-argument and the previous value for the argument.
+It returns the new value for the argument.
+
+The processed argument values are passed to the action handler, and saved as `.processedArgs`.
+
+You can optionally specify the default/starting value for the argument after the function parameter.
+
+Example file: [arguments-custom-processing.js](./examples/arguments-custom-processing.js)
+
+```js
+program
+ .command('add')
+ .argument('', 'integer argument', myParseInt)
+ .argument('[second]', 'integer argument', myParseInt, 1000)
+ .action((first, second) => {
+ console.log(`${first} + ${second} = ${first + second}`);
+ })
+;
+```
+
+### Action handler
+
+The action handler gets passed a parameter for each command-argument you declared, and two additional parameters
+which are the parsed options and the command object itself.
+
+Example file: [thank.js](./examples/thank.js)
+
+```js
+program
+ .argument('')
+ .option('-t, --title ', 'title to use before name')
+ .option('-d, --debug', 'display some debugging')
+ .action((name, options, command) => {
+ if (options.debug) {
+ console.error('Called %s with options %o', command.name(), options);
+ }
+ const title = options.title ? `${options.title} ` : '';
+ console.log(`Thank-you ${title}${name}`);
+ });
+```
+
+If you prefer, you can work with the command directly and skip declaring the parameters for the action handler. The `this` keyword is set to the running command and can be used from a function expression (but not from an arrow function).
+
+Example file: [action-this.js](./examples/action-this.js)
+
+```js
+program
+ .command('serve')
+ .argument('
+
+```
+
+
+## API
+
+### Parsing
+
+Parsing a plist from filename:
+
+``` javascript
+var fs = require('fs');
+var plist = require('plist');
+
+var obj = plist.parse(fs.readFileSync('myPlist.plist', 'utf8'));
+console.log(JSON.stringify(obj));
+```
+
+Parsing a plist from string payload:
+
+``` javascript
+var plist = require('plist');
+
+var xml =
+ '' +
+ '' +
+ '' +
+ 'metadata ' +
+ '' +
+ 'bundle-identifier ' +
+ 'com.company.app ' +
+ 'bundle-version ' +
+ '0.1.1 ' +
+ 'kind ' +
+ 'software ' +
+ 'title ' +
+ 'AppName ' +
+ ' ' +
+ ' ';
+
+console.log(plist.parse(xml));
+
+// [
+// "metadata",
+// {
+// "bundle-identifier": "com.company.app",
+// "bundle-version": "0.1.1",
+// "kind": "software",
+// "title": "AppName"
+// }
+// ]
+```
+
+### Building
+
+Given an existing JavaScript Object, you can turn it into an XML document
+that complies with the plist DTD:
+
+``` javascript
+var plist = require('plist');
+
+var json = [
+ "metadata",
+ {
+ "bundle-identifier": "com.company.app",
+ "bundle-version": "0.1.1",
+ "kind": "software",
+ "title": "AppName"
+ }
+];
+
+console.log(plist.build(json));
+
+//
+//
+//
+// metadata
+//
+// bundle-identifier
+// com.company.app
+// bundle-version
+// 0.1.1
+// kind
+// software
+// title
+// AppName
+//
+//
+```
+
+## Cross Platform Testing Credits
+
+Much thanks to Sauce Labs for providing free resources that enable cross-browser testing on this project!
+
+[](https://saucelabs.com)
+
+
+## License
+
+[(The MIT License)](LICENSE)
diff --git a/node_modules/plist/dist/plist-build.js b/node_modules/plist/dist/plist-build.js
new file mode 100644
index 0000000..0eeef51
--- /dev/null
+++ b/node_modules/plist/dist/plist-build.js
@@ -0,0 +1,5348 @@
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 0) {
+ throw new Error('Invalid string. Length must be a multiple of 4')
+ }
+
+ // Trim off extra bytes after placeholder bytes are found
+ // See: https://github.com/beatgammit/base64-js/issues/42
+ var validLen = b64.indexOf('=')
+ if (validLen === -1) validLen = len
+
+ var placeHoldersLen = validLen === len
+ ? 0
+ : 4 - (validLen % 4)
+
+ return [validLen, placeHoldersLen]
+}
+
+// base64 is 4/3 + up to two characters of the original data
+function byteLength (b64) {
+ var lens = getLens(b64)
+ var validLen = lens[0]
+ var placeHoldersLen = lens[1]
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
+}
+
+function _byteLength (b64, validLen, placeHoldersLen) {
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
+}
+
+function toByteArray (b64) {
+ var tmp
+ var lens = getLens(b64)
+ var validLen = lens[0]
+ var placeHoldersLen = lens[1]
+
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
+
+ var curByte = 0
+
+ // if there are placeholders, only get up to the last complete 4 chars
+ var len = placeHoldersLen > 0
+ ? validLen - 4
+ : validLen
+
+ var i
+ for (i = 0; i < len; i += 4) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 18) |
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
+ revLookup[b64.charCodeAt(i + 3)]
+ arr[curByte++] = (tmp >> 16) & 0xFF
+ arr[curByte++] = (tmp >> 8) & 0xFF
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ if (placeHoldersLen === 2) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 2) |
+ (revLookup[b64.charCodeAt(i + 1)] >> 4)
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ if (placeHoldersLen === 1) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 10) |
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
+ (revLookup[b64.charCodeAt(i + 2)] >> 2)
+ arr[curByte++] = (tmp >> 8) & 0xFF
+ arr[curByte++] = 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) & 0xFF0000) +
+ ((uint8[i + 1] << 8) & 0xFF00) +
+ (uint8[i + 2] & 0xFF)
+ 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 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]
+ parts.push(
+ lookup[tmp >> 2] +
+ lookup[(tmp << 4) & 0x3F] +
+ '=='
+ )
+ } else if (extraBytes === 2) {
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1]
+ parts.push(
+ lookup[tmp >> 10] +
+ lookup[(tmp >> 4) & 0x3F] +
+ lookup[(tmp << 2) & 0x3F] +
+ '='
+ )
+ }
+
+ return parts.join('')
+}
+
+},{}],3:[function(require,module,exports){
+/*!
+ * Determine if an object is a Buffer
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */
+
+// The _isBuffer check is for Safari 5-7 support, because it's missing
+// Object.prototype.constructor. Remove this eventually
+module.exports = function (obj) {
+ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
+}
+
+function isBuffer (obj) {
+ return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
+}
+
+// For Node v0.10 support. Remove this eventually.
+function isSlowBuffer (obj) {
+ return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
+}
+
+},{}],4:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ module.exports = {
+ Disconnected: 1,
+ Preceding: 2,
+ Following: 4,
+ Contains: 8,
+ ContainedBy: 16,
+ ImplementationSpecific: 32
+ };
+
+}).call(this);
+
+},{}],5:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ module.exports = {
+ Element: 1,
+ Attribute: 2,
+ Text: 3,
+ CData: 4,
+ EntityReference: 5,
+ EntityDeclaration: 6,
+ ProcessingInstruction: 7,
+ Comment: 8,
+ Document: 9,
+ DocType: 10,
+ DocumentFragment: 11,
+ NotationDeclaration: 12,
+ // Numeric codes up to 200 are reserved to W3C for possible future use.
+ // Following are types internal to this library:
+ Declaration: 201,
+ Raw: 202,
+ AttributeDeclaration: 203,
+ ElementDeclaration: 204,
+ Dummy: 205
+ };
+
+}).call(this);
+
+},{}],6:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Copies all enumerable own properties from `sources` to `target`
+ var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject,
+ hasProp = {}.hasOwnProperty;
+
+ assign = function(target, ...sources) {
+ var i, key, len, source;
+ if (isFunction(Object.assign)) {
+ Object.assign.apply(null, arguments);
+ } else {
+ for (i = 0, len = sources.length; i < len; i++) {
+ source = sources[i];
+ if (source != null) {
+ for (key in source) {
+ if (!hasProp.call(source, key)) continue;
+ target[key] = source[key];
+ }
+ }
+ }
+ }
+ return target;
+ };
+
+ // Determines if `val` is a Function object
+ isFunction = function(val) {
+ return !!val && Object.prototype.toString.call(val) === '[object Function]';
+ };
+
+ // Determines if `val` is an Object
+ isObject = function(val) {
+ var ref;
+ return !!val && ((ref = typeof val) === 'function' || ref === 'object');
+ };
+
+ // Determines if `val` is an Array
+ isArray = function(val) {
+ if (isFunction(Array.isArray)) {
+ return Array.isArray(val);
+ } else {
+ return Object.prototype.toString.call(val) === '[object Array]';
+ }
+ };
+
+ // Determines if `val` is an empty Array or an Object with no own properties
+ isEmpty = function(val) {
+ var key;
+ if (isArray(val)) {
+ return !val.length;
+ } else {
+ for (key in val) {
+ if (!hasProp.call(val, key)) continue;
+ return false;
+ }
+ return true;
+ }
+ };
+
+ // Determines if `val` is a plain Object
+ isPlainObject = function(val) {
+ var ctor, proto;
+ return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
+ };
+
+ // Gets the primitive value of an object
+ getValue = function(obj) {
+ if (isFunction(obj.valueOf)) {
+ return obj.valueOf();
+ } else {
+ return obj;
+ }
+ };
+
+ module.exports.assign = assign;
+
+ module.exports.isFunction = isFunction;
+
+ module.exports.isObject = isObject;
+
+ module.exports.isArray = isArray;
+
+ module.exports.isEmpty = isEmpty;
+
+ module.exports.isPlainObject = isPlainObject;
+
+ module.exports.getValue = getValue;
+
+}).call(this);
+
+},{}],7:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ module.exports = {
+ None: 0,
+ OpenTag: 1,
+ InsideTag: 2,
+ CloseTag: 3
+ };
+
+}).call(this);
+
+},{}],8:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLAttribute, XMLNode;
+
+ NodeType = require('./NodeType');
+
+ XMLNode = require('./XMLNode');
+
+ // Represents an attribute
+ module.exports = XMLAttribute = (function() {
+ class XMLAttribute {
+ // Initializes a new instance of `XMLAttribute`
+
+ // `parent` the parent node
+ // `name` attribute target
+ // `value` attribute value
+ constructor(parent, name, value) {
+ this.parent = parent;
+ if (this.parent) {
+ this.options = this.parent.options;
+ this.stringify = this.parent.stringify;
+ }
+ if (name == null) {
+ throw new Error("Missing attribute name. " + this.debugInfo(name));
+ }
+ this.name = this.stringify.name(name);
+ this.value = this.stringify.attValue(value);
+ this.type = NodeType.Attribute;
+ // DOM level 3
+ this.isId = false;
+ this.schemaTypeInfo = null;
+ }
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
+ }
+
+
+ // Returns debug string for this node
+ debugInfo(name) {
+ name = name || this.name;
+ if (name == null) {
+ return "parent: <" + this.parent.name + ">";
+ } else {
+ return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
+ }
+ }
+
+ isEqualNode(node) {
+ if (node.namespaceURI !== this.namespaceURI) {
+ return false;
+ }
+ if (node.prefix !== this.prefix) {
+ return false;
+ }
+ if (node.localName !== this.localName) {
+ return false;
+ }
+ if (node.value !== this.value) {
+ return false;
+ }
+ return true;
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
+ get: function() {
+ return this.type;
+ }
+ });
+
+ Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
+ get: function() {
+ return this.parent;
+ }
+ });
+
+ // DOM level 3
+ Object.defineProperty(XMLAttribute.prototype, 'textContent', {
+ get: function() {
+ return this.value;
+ },
+ set: function(value) {
+ return this.value = value || '';
+ }
+ });
+
+ // DOM level 4
+ Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
+ get: function() {
+ return '';
+ }
+ });
+
+ Object.defineProperty(XMLAttribute.prototype, 'prefix', {
+ get: function() {
+ return '';
+ }
+ });
+
+ Object.defineProperty(XMLAttribute.prototype, 'localName', {
+ get: function() {
+ return this.name;
+ }
+ });
+
+ Object.defineProperty(XMLAttribute.prototype, 'specified', {
+ get: function() {
+ return true;
+ }
+ });
+
+ return XMLAttribute;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./NodeType":5,"./XMLNode":27}],9:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLCData, XMLCharacterData;
+
+ NodeType = require('./NodeType');
+
+ XMLCharacterData = require('./XMLCharacterData');
+
+ // Represents a CDATA node
+ module.exports = XMLCData = class XMLCData extends XMLCharacterData {
+ // Initializes a new instance of `XMLCData`
+
+ // `text` CDATA text
+ constructor(parent, text) {
+ super(parent);
+ if (text == null) {
+ throw new Error("Missing CDATA text. " + this.debugInfo());
+ }
+ this.name = "#cdata-section";
+ this.type = NodeType.CData;
+ this.value = this.stringify.cdata(text);
+ }
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":5,"./XMLCharacterData":10}],10:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var XMLCharacterData, XMLNode;
+
+ XMLNode = require('./XMLNode');
+
+ // Represents a character data node
+ module.exports = XMLCharacterData = (function() {
+ class XMLCharacterData extends XMLNode {
+ // Initializes a new instance of `XMLCharacterData`
+
+ constructor(parent) {
+ super(parent);
+ this.value = '';
+ }
+
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // DOM level 1 functions to be implemented later
+ substringData(offset, count) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ appendData(arg) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ insertData(offset, arg) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ deleteData(offset, count) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ replaceData(offset, count, arg) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ isEqualNode(node) {
+ if (!super.isEqualNode(node)) {
+ return false;
+ }
+ if (node.data !== this.data) {
+ return false;
+ }
+ return true;
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLCharacterData.prototype, 'data', {
+ get: function() {
+ return this.value;
+ },
+ set: function(value) {
+ return this.value = value || '';
+ }
+ });
+
+ Object.defineProperty(XMLCharacterData.prototype, 'length', {
+ get: function() {
+ return this.value.length;
+ }
+ });
+
+ // DOM level 3
+ Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
+ get: function() {
+ return this.value;
+ },
+ set: function(value) {
+ return this.value = value || '';
+ }
+ });
+
+ return XMLCharacterData;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./XMLNode":27}],11:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLCharacterData, XMLComment;
+
+ NodeType = require('./NodeType');
+
+ XMLCharacterData = require('./XMLCharacterData');
+
+ // Represents a comment node
+ module.exports = XMLComment = class XMLComment extends XMLCharacterData {
+ // Initializes a new instance of `XMLComment`
+
+ // `text` comment text
+ constructor(parent, text) {
+ super(parent);
+ if (text == null) {
+ throw new Error("Missing comment text. " + this.debugInfo());
+ }
+ this.name = "#comment";
+ this.type = NodeType.Comment;
+ this.value = this.stringify.comment(text);
+ }
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.comment(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":5,"./XMLCharacterData":10}],12:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
+
+ XMLDOMErrorHandler = require('./XMLDOMErrorHandler');
+
+ XMLDOMStringList = require('./XMLDOMStringList');
+
+ // Implements the DOMConfiguration interface
+ module.exports = XMLDOMConfiguration = (function() {
+ class XMLDOMConfiguration {
+ constructor() {
+ var clonedSelf;
+ this.defaultParams = {
+ "canonical-form": false,
+ "cdata-sections": false,
+ "comments": false,
+ "datatype-normalization": false,
+ "element-content-whitespace": true,
+ "entities": true,
+ "error-handler": new XMLDOMErrorHandler(),
+ "infoset": true,
+ "validate-if-schema": false,
+ "namespaces": true,
+ "namespace-declarations": true,
+ "normalize-characters": false,
+ "schema-location": '',
+ "schema-type": '',
+ "split-cdata-sections": true,
+ "validate": false,
+ "well-formed": true
+ };
+ this.params = clonedSelf = Object.create(this.defaultParams);
+ }
+
+ // Gets the value of a parameter.
+
+ // `name` name of the parameter
+ getParameter(name) {
+ if (this.params.hasOwnProperty(name)) {
+ return this.params[name];
+ } else {
+ return null;
+ }
+ }
+
+ // Checks if setting a parameter to a specific value is supported.
+
+ // `name` name of the parameter
+ // `value` parameter value
+ canSetParameter(name, value) {
+ return true;
+ }
+
+ // Sets the value of a parameter.
+
+ // `name` name of the parameter
+ // `value` new value or null if the user wishes to unset the parameter
+ setParameter(name, value) {
+ if (value != null) {
+ return this.params[name] = value;
+ } else {
+ return delete this.params[name];
+ }
+ }
+
+ };
+
+ // Returns the list of parameter names
+ Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', {
+ get: function() {
+ return new XMLDOMStringList(Object.keys(this.defaultParams));
+ }
+ });
+
+ return XMLDOMConfiguration;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./XMLDOMErrorHandler":13,"./XMLDOMStringList":15}],13:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Represents the error handler for DOM operations
+ var XMLDOMErrorHandler;
+
+ module.exports = XMLDOMErrorHandler = class XMLDOMErrorHandler {
+ // Initializes a new instance of `XMLDOMErrorHandler`
+
+ constructor() {}
+
+ // Called on the error handler when an error occurs.
+
+ // `error` the error message as a string
+ handleError(error) {
+ throw new Error(error);
+ }
+
+ };
+
+}).call(this);
+
+},{}],14:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Implements the DOMImplementation interface
+ var XMLDOMImplementation;
+
+ module.exports = XMLDOMImplementation = class XMLDOMImplementation {
+ // Tests if the DOM implementation implements a specific feature.
+
+ // `feature` package name of the feature to test. In Level 1, the
+ // legal values are "HTML" and "XML" (case-insensitive).
+ // `version` version number of the package name to test.
+ // In Level 1, this is the string "1.0". If the version is
+ // not specified, supporting any version of the feature will
+ // cause the method to return true.
+ hasFeature(feature, version) {
+ return true;
+ }
+
+ // Creates a new document type declaration.
+
+ // `qualifiedName` qualified name of the document type to be created
+ // `publicId` public identifier of the external subset
+ // `systemId` system identifier of the external subset
+ createDocumentType(qualifiedName, publicId, systemId) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ // Creates a new document.
+
+ // `namespaceURI` namespace URI of the document element to create
+ // `qualifiedName` the qualified name of the document to be created
+ // `doctype` the type of document to be created or null
+ createDocument(namespaceURI, qualifiedName, doctype) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ // Creates a new HTML document.
+
+ // `title` document title
+ createHTMLDocument(title) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ // Returns a specialized object which implements the specialized APIs
+ // of the specified feature and version.
+
+ // `feature` name of the feature requested.
+ // `version` version number of the feature to test
+ getFeature(feature, version) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ };
+
+}).call(this);
+
+},{}],15:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Represents a list of string entries
+ var XMLDOMStringList;
+
+ module.exports = XMLDOMStringList = (function() {
+ class XMLDOMStringList {
+ // Initializes a new instance of `XMLDOMStringList`
+ // This is just a wrapper around an ordinary
+ // JS array.
+
+ // `arr` the array of string values
+ constructor(arr) {
+ this.arr = arr || [];
+ }
+
+ // Returns the indexth item in the collection.
+
+ // `index` index into the collection
+ item(index) {
+ return this.arr[index] || null;
+ }
+
+ // Test if a string is part of this DOMStringList.
+
+ // `str` the string to look for
+ contains(str) {
+ return this.arr.indexOf(str) !== -1;
+ }
+
+ };
+
+ // Returns the number of strings in the list.
+ Object.defineProperty(XMLDOMStringList.prototype, 'length', {
+ get: function() {
+ return this.arr.length;
+ }
+ });
+
+ return XMLDOMStringList;
+
+ }).call(this);
+
+}).call(this);
+
+},{}],16:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDTDAttList, XMLNode;
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ // Represents an attribute list
+ module.exports = XMLDTDAttList = class XMLDTDAttList extends XMLNode {
+ // Initializes a new instance of `XMLDTDAttList`
+
+ // `parent` the parent `XMLDocType` element
+ // `elementName` the name of the element containing this attribute
+ // `attributeName` attribute name
+ // `attributeType` type of the attribute
+ // `defaultValueType` default value type (either #REQUIRED, #IMPLIED,
+ // #FIXED or #DEFAULT)
+ // `defaultValue` default value of the attribute
+ // (only used for #FIXED or #DEFAULT)
+ constructor(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ super(parent);
+ if (elementName == null) {
+ throw new Error("Missing DTD element name. " + this.debugInfo());
+ }
+ if (attributeName == null) {
+ throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
+ }
+ if (!attributeType) {
+ throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
+ }
+ if (!defaultValueType) {
+ throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
+ }
+ if (defaultValueType.indexOf('#') !== 0) {
+ defaultValueType = '#' + defaultValueType;
+ }
+ if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
+ throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
+ }
+ if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
+ throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
+ }
+ this.elementName = this.stringify.name(elementName);
+ this.type = NodeType.AttributeDeclaration;
+ this.attributeName = this.stringify.name(attributeName);
+ this.attributeType = this.stringify.dtdAttType(attributeType);
+ if (defaultValue) {
+ this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
+ }
+ this.defaultValueType = defaultValueType;
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":5,"./XMLNode":27}],17:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDTDElement, XMLNode;
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ // Represents an attribute
+ module.exports = XMLDTDElement = class XMLDTDElement extends XMLNode {
+ // Initializes a new instance of `XMLDTDElement`
+
+ // `parent` the parent `XMLDocType` element
+ // `name` element name
+ // `value` element content (defaults to #PCDATA)
+ constructor(parent, name, value) {
+ super(parent);
+ if (name == null) {
+ throw new Error("Missing DTD element name. " + this.debugInfo());
+ }
+ if (!value) {
+ value = '(#PCDATA)';
+ }
+ if (Array.isArray(value)) {
+ value = '(' + value.join(',') + ')';
+ }
+ this.name = this.stringify.name(name);
+ this.type = NodeType.ElementDeclaration;
+ this.value = this.stringify.dtdElementValue(value);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":5,"./XMLNode":27}],18:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDTDEntity, XMLNode, isObject;
+
+ ({isObject} = require('./Utility'));
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ // Represents an entity declaration in the DTD
+ module.exports = XMLDTDEntity = (function() {
+ class XMLDTDEntity extends XMLNode {
+ // Initializes a new instance of `XMLDTDEntity`
+
+ // `parent` the parent `XMLDocType` element
+ // `pe` whether this is a parameter entity or a general entity
+ // defaults to `false` (general entity)
+ // `name` the name of the entity
+ // `value` internal entity value or an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ // `value.nData` notation declaration
+ constructor(parent, pe, name, value) {
+ super(parent);
+ if (name == null) {
+ throw new Error("Missing DTD entity name. " + this.debugInfo(name));
+ }
+ if (value == null) {
+ throw new Error("Missing DTD entity value. " + this.debugInfo(name));
+ }
+ this.pe = !!pe;
+ this.name = this.stringify.name(name);
+ this.type = NodeType.EntityDeclaration;
+ if (!isObject(value)) {
+ this.value = this.stringify.dtdEntityValue(value);
+ this.internal = true;
+ } else {
+ if (!value.pubID && !value.sysID) {
+ throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
+ }
+ if (value.pubID && !value.sysID) {
+ throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
+ }
+ this.internal = false;
+ if (value.pubID != null) {
+ this.pubID = this.stringify.dtdPubID(value.pubID);
+ }
+ if (value.sysID != null) {
+ this.sysID = this.stringify.dtdSysID(value.sysID);
+ }
+ if (value.nData != null) {
+ this.nData = this.stringify.dtdNData(value.nData);
+ }
+ if (this.pe && this.nData) {
+ throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
+ }
+ }
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
+ get: function() {
+ return this.pubID;
+ }
+ });
+
+ Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
+ get: function() {
+ return this.sysID;
+ }
+ });
+
+ Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
+ get: function() {
+ return this.nData || null;
+ }
+ });
+
+ // DOM level 3
+ Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
+ get: function() {
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
+ get: function() {
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
+ get: function() {
+ return null;
+ }
+ });
+
+ return XMLDTDEntity;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./NodeType":5,"./Utility":6,"./XMLNode":27}],19:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDTDNotation, XMLNode;
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ // Represents a NOTATION entry in the DTD
+ module.exports = XMLDTDNotation = (function() {
+ class XMLDTDNotation extends XMLNode {
+ // Initializes a new instance of `XMLDTDNotation`
+
+ // `parent` the parent `XMLDocType` element
+ // `name` the name of the notation
+ // `value` an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ constructor(parent, name, value) {
+ super(parent);
+ if (name == null) {
+ throw new Error("Missing DTD notation name. " + this.debugInfo(name));
+ }
+ if (!value.pubID && !value.sysID) {
+ throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
+ }
+ this.name = this.stringify.name(name);
+ this.type = NodeType.NotationDeclaration;
+ if (value.pubID != null) {
+ this.pubID = this.stringify.dtdPubID(value.pubID);
+ }
+ if (value.sysID != null) {
+ this.sysID = this.stringify.dtdSysID(value.sysID);
+ }
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLDTDNotation.prototype, 'publicId', {
+ get: function() {
+ return this.pubID;
+ }
+ });
+
+ Object.defineProperty(XMLDTDNotation.prototype, 'systemId', {
+ get: function() {
+ return this.sysID;
+ }
+ });
+
+ return XMLDTDNotation;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./NodeType":5,"./XMLNode":27}],20:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDeclaration, XMLNode, isObject;
+
+ ({isObject} = require('./Utility'));
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ // Represents the XML declaration
+ module.exports = XMLDeclaration = class XMLDeclaration extends XMLNode {
+ // Initializes a new instance of `XMLDeclaration`
+
+ // `parent` the document object
+
+ // `version` A version number string, e.g. 1.0
+ // `encoding` Encoding declaration, e.g. UTF-8
+ // `standalone` standalone document declaration: true or false
+ constructor(parent, version, encoding, standalone) {
+ super(parent);
+ // arguments may also be passed as an object
+ if (isObject(version)) {
+ ({version, encoding, standalone} = version);
+ }
+ if (!version) {
+ version = '1.0';
+ }
+ this.type = NodeType.Declaration;
+ this.version = this.stringify.xmlVersion(version);
+ if (encoding != null) {
+ this.encoding = this.stringify.xmlEncoding(encoding);
+ }
+ if (standalone != null) {
+ this.standalone = this.stringify.xmlStandalone(standalone);
+ }
+ }
+
+ // Converts to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":5,"./Utility":6,"./XMLNode":27}],21:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject;
+
+ ({isObject} = require('./Utility'));
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLNamedNodeMap = require('./XMLNamedNodeMap');
+
+ // Represents doctype declaration
+ module.exports = XMLDocType = (function() {
+ class XMLDocType extends XMLNode {
+ // Initializes a new instance of `XMLDocType`
+
+ // `parent` the document object
+
+ // `pubID` public identifier of the external subset
+ // `sysID` system identifier of the external subset
+ constructor(parent, pubID, sysID) {
+ var child, i, len, ref;
+ super(parent);
+ this.type = NodeType.DocType;
+ // set DTD name to the name of the root node
+ if (parent.children) {
+ ref = parent.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ if (child.type === NodeType.Element) {
+ this.name = child.name;
+ break;
+ }
+ }
+ }
+ this.documentObject = parent;
+ // arguments may also be passed as an object
+ if (isObject(pubID)) {
+ ({pubID, sysID} = pubID);
+ }
+ if (sysID == null) {
+ [sysID, pubID] = [pubID, sysID];
+ }
+ if (pubID != null) {
+ this.pubID = this.stringify.dtdPubID(pubID);
+ }
+ if (sysID != null) {
+ this.sysID = this.stringify.dtdSysID(sysID);
+ }
+ }
+
+ // Creates an element type declaration
+
+ // `name` element name
+ // `value` element content (defaults to #PCDATA)
+ element(name, value) {
+ var child;
+ child = new XMLDTDElement(this, name, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates an attribute declaration
+
+ // `elementName` the name of the element containing this attribute
+ // `attributeName` attribute name
+ // `attributeType` type of the attribute (defaults to CDATA)
+ // `defaultValueType` default value type (either #REQUIRED, #IMPLIED, #FIXED or
+ // #DEFAULT) (defaults to #IMPLIED)
+ // `defaultValue` default value of the attribute
+ // (only used for #FIXED or #DEFAULT)
+ attList(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ var child;
+ child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates a general entity declaration
+
+ // `name` the name of the entity
+ // `value` internal entity value or an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ // `value.nData` notation declaration
+ entity(name, value) {
+ var child;
+ child = new XMLDTDEntity(this, false, name, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates a parameter entity declaration
+
+ // `name` the name of the entity
+ // `value` internal entity value or an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ pEntity(name, value) {
+ var child;
+ child = new XMLDTDEntity(this, true, name, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates a NOTATION declaration
+
+ // `name` the name of the notation
+ // `value` an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ notation(name, value) {
+ var child;
+ child = new XMLDTDNotation(this, name, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Converts to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.docType(this, this.options.writer.filterOptions(options));
+ }
+
+ // Aliases
+ ele(name, value) {
+ return this.element(name, value);
+ }
+
+ att(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
+ }
+
+ ent(name, value) {
+ return this.entity(name, value);
+ }
+
+ pent(name, value) {
+ return this.pEntity(name, value);
+ }
+
+ not(name, value) {
+ return this.notation(name, value);
+ }
+
+ up() {
+ return this.root() || this.documentObject;
+ }
+
+ isEqualNode(node) {
+ if (!super.isEqualNode(node)) {
+ return false;
+ }
+ if (node.name !== this.name) {
+ return false;
+ }
+ if (node.publicId !== this.publicId) {
+ return false;
+ }
+ if (node.systemId !== this.systemId) {
+ return false;
+ }
+ return true;
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLDocType.prototype, 'entities', {
+ get: function() {
+ var child, i, len, nodes, ref;
+ nodes = {};
+ ref = this.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ if ((child.type === NodeType.EntityDeclaration) && !child.pe) {
+ nodes[child.name] = child;
+ }
+ }
+ return new XMLNamedNodeMap(nodes);
+ }
+ });
+
+ Object.defineProperty(XMLDocType.prototype, 'notations', {
+ get: function() {
+ var child, i, len, nodes, ref;
+ nodes = {};
+ ref = this.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ if (child.type === NodeType.NotationDeclaration) {
+ nodes[child.name] = child;
+ }
+ }
+ return new XMLNamedNodeMap(nodes);
+ }
+ });
+
+ // DOM level 2
+ Object.defineProperty(XMLDocType.prototype, 'publicId', {
+ get: function() {
+ return this.pubID;
+ }
+ });
+
+ Object.defineProperty(XMLDocType.prototype, 'systemId', {
+ get: function() {
+ return this.sysID;
+ }
+ });
+
+ Object.defineProperty(XMLDocType.prototype, 'internalSubset', {
+ get: function() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+ });
+
+ return XMLDocType;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./NodeType":5,"./Utility":6,"./XMLDTDAttList":16,"./XMLDTDElement":17,"./XMLDTDEntity":18,"./XMLDTDNotation":19,"./XMLNamedNodeMap":26,"./XMLNode":27}],22:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject;
+
+ ({isPlainObject} = require('./Utility'));
+
+ XMLDOMImplementation = require('./XMLDOMImplementation');
+
+ XMLDOMConfiguration = require('./XMLDOMConfiguration');
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ XMLStringifier = require('./XMLStringifier');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ // Represents an XML builder
+ module.exports = XMLDocument = (function() {
+ class XMLDocument extends XMLNode {
+ // Initializes a new instance of `XMLDocument`
+
+ // `options.keepNullNodes` whether nodes with null values will be kept
+ // or ignored: true or false
+ // `options.keepNullAttributes` whether attributes with null values will be
+ // kept or ignored: true or false
+ // `options.ignoreDecorators` whether decorator strings will be ignored when
+ // converting JS objects: true or false
+ // `options.separateArrayItems` whether array items are created as separate
+ // nodes when passed as an object value: true or false
+ // `options.noDoubleEncoding` whether existing html entities are encoded:
+ // true or false
+ // `options.stringify` a set of functions to use for converting values to
+ // strings
+ // `options.writer` the default XML writer to use for converting nodes to
+ // string. If the default writer is not set, the built-in XMLStringWriter
+ // will be used instead.
+ constructor(options) {
+ super(null);
+ this.name = "#document";
+ this.type = NodeType.Document;
+ this.documentURI = null;
+ this.domConfig = new XMLDOMConfiguration();
+ options || (options = {});
+ if (!options.writer) {
+ options.writer = new XMLStringWriter();
+ }
+ this.options = options;
+ this.stringify = new XMLStringifier(options);
+ }
+
+ // Ends the document and passes it to the given XML writer
+
+ // `writer` is either an XML writer or a plain object to pass to the
+ // constructor of the default XML writer. The default writer is assigned when
+ // creating the XML document. Following flags are recognized by the
+ // built-in XMLStringWriter:
+ // `writer.pretty` pretty prints the result
+ // `writer.indent` indentation for pretty print
+ // `writer.offset` how many indentations to add to every line for pretty print
+ // `writer.newline` newline sequence for pretty print
+ end(writer) {
+ var writerOptions;
+ writerOptions = {};
+ if (!writer) {
+ writer = this.options.writer;
+ } else if (isPlainObject(writer)) {
+ writerOptions = writer;
+ writer = this.options.writer;
+ }
+ return writer.document(this, writer.filterOptions(writerOptions));
+ }
+
+ // Converts the XML document to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.document(this, this.options.writer.filterOptions(options));
+ }
+
+ // DOM level 1 functions to be implemented later
+ createElement(tagName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createDocumentFragment() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createTextNode(data) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createComment(data) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createCDATASection(data) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createProcessingInstruction(target, data) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createAttribute(name) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createEntityReference(name) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementsByTagName(tagname) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM level 2 functions to be implemented later
+ importNode(importedNode, deep) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createElementNS(namespaceURI, qualifiedName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createAttributeNS(namespaceURI, qualifiedName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementsByTagNameNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementById(elementId) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM level 3 functions to be implemented later
+ adoptNode(source) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ normalizeDocument() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ renameNode(node, namespaceURI, qualifiedName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM level 4 functions to be implemented later
+ getElementsByClassName(classNames) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createEvent(eventInterface) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createRange() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createNodeIterator(root, whatToShow, filter) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createTreeWalker(root, whatToShow, filter) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLDocument.prototype, 'implementation', {
+ value: new XMLDOMImplementation()
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'doctype', {
+ get: function() {
+ var child, i, len, ref;
+ ref = this.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ if (child.type === NodeType.DocType) {
+ return child;
+ }
+ }
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'documentElement', {
+ get: function() {
+ return this.rootObject || null;
+ }
+ });
+
+ // DOM level 3
+ Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
+ get: function() {
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
+ get: function() {
+ return false;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
+ get: function() {
+ if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
+ return this.children[0].encoding;
+ } else {
+ return null;
+ }
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
+ get: function() {
+ if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
+ return this.children[0].standalone === 'yes';
+ } else {
+ return false;
+ }
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
+ get: function() {
+ if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
+ return this.children[0].version;
+ } else {
+ return "1.0";
+ }
+ }
+ });
+
+ // DOM level 4
+ Object.defineProperty(XMLDocument.prototype, 'URL', {
+ get: function() {
+ return this.documentURI;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'origin', {
+ get: function() {
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'compatMode', {
+ get: function() {
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'characterSet', {
+ get: function() {
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'contentType', {
+ get: function() {
+ return null;
+ }
+ });
+
+ return XMLDocument;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./NodeType":5,"./Utility":6,"./XMLDOMConfiguration":12,"./XMLDOMImplementation":14,"./XMLNode":27,"./XMLStringWriter":32,"./XMLStringifier":33}],23:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, WriterState, XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocument, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction, isObject, isPlainObject,
+ hasProp = {}.hasOwnProperty;
+
+ ({isObject, isFunction, isPlainObject, getValue} = require('./Utility'));
+
+ NodeType = require('./NodeType');
+
+ XMLDocument = require('./XMLDocument');
+
+ XMLElement = require('./XMLElement');
+
+ XMLCData = require('./XMLCData');
+
+ XMLComment = require('./XMLComment');
+
+ XMLRaw = require('./XMLRaw');
+
+ XMLText = require('./XMLText');
+
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+
+ XMLDeclaration = require('./XMLDeclaration');
+
+ XMLDocType = require('./XMLDocType');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLAttribute = require('./XMLAttribute');
+
+ XMLStringifier = require('./XMLStringifier');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ WriterState = require('./WriterState');
+
+ // Represents an XML builder
+ module.exports = XMLDocumentCB = class XMLDocumentCB {
+ // Initializes a new instance of `XMLDocumentCB`
+
+ // `options.keepNullNodes` whether nodes with null values will be kept
+ // or ignored: true or false
+ // `options.keepNullAttributes` whether attributes with null values will be
+ // kept or ignored: true or false
+ // `options.ignoreDecorators` whether decorator strings will be ignored when
+ // converting JS objects: true or false
+ // `options.separateArrayItems` whether array items are created as separate
+ // nodes when passed as an object value: true or false
+ // `options.noDoubleEncoding` whether existing html entities are encoded:
+ // true or false
+ // `options.stringify` a set of functions to use for converting values to
+ // strings
+ // `options.writer` the default XML writer to use for converting nodes to
+ // string. If the default writer is not set, the built-in XMLStringWriter
+ // will be used instead.
+
+ // `onData` the function to be called when a new chunk of XML is output. The
+ // string containing the XML chunk is passed to `onData` as its first
+ // argument, and the current indentation level as its second argument.
+ // `onEnd` the function to be called when the XML document is completed with
+ // `end`. `onEnd` does not receive any arguments.
+ constructor(options, onData, onEnd) {
+ var writerOptions;
+ this.name = "?xml";
+ this.type = NodeType.Document;
+ options || (options = {});
+ writerOptions = {};
+ if (!options.writer) {
+ options.writer = new XMLStringWriter();
+ } else if (isPlainObject(options.writer)) {
+ writerOptions = options.writer;
+ options.writer = new XMLStringWriter();
+ }
+ this.options = options;
+ this.writer = options.writer;
+ this.writerOptions = this.writer.filterOptions(writerOptions);
+ this.stringify = new XMLStringifier(options);
+ this.onDataCallback = onData || function() {};
+ this.onEndCallback = onEnd || function() {};
+ this.currentNode = null;
+ this.currentLevel = -1;
+ this.openTags = {};
+ this.documentStarted = false;
+ this.documentCompleted = false;
+ this.root = null;
+ }
+
+ // Creates a child element node from the given XMLNode
+
+ // `node` the child node
+ createChildNode(node) {
+ var att, attName, attributes, child, i, len, ref, ref1;
+ switch (node.type) {
+ case NodeType.CData:
+ this.cdata(node.value);
+ break;
+ case NodeType.Comment:
+ this.comment(node.value);
+ break;
+ case NodeType.Element:
+ attributes = {};
+ ref = node.attribs;
+ for (attName in ref) {
+ if (!hasProp.call(ref, attName)) continue;
+ att = ref[attName];
+ attributes[attName] = att.value;
+ }
+ this.node(node.name, attributes);
+ break;
+ case NodeType.Dummy:
+ this.dummy();
+ break;
+ case NodeType.Raw:
+ this.raw(node.value);
+ break;
+ case NodeType.Text:
+ this.text(node.value);
+ break;
+ case NodeType.ProcessingInstruction:
+ this.instruction(node.target, node.value);
+ break;
+ default:
+ throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name);
+ }
+ ref1 = node.children;
+ // write child nodes recursively
+ for (i = 0, len = ref1.length; i < len; i++) {
+ child = ref1[i];
+ this.createChildNode(child);
+ if (child.type === NodeType.Element) {
+ this.up();
+ }
+ }
+ return this;
+ }
+
+ // Creates a dummy node
+
+ dummy() {
+ // no-op, just return this
+ return this;
+ }
+
+ // Creates a node
+
+ // `name` name of the node
+ // `attributes` an object containing name/value pairs of attributes
+ // `text` element text
+ node(name, attributes, text) {
+ if (name == null) {
+ throw new Error("Missing node name.");
+ }
+ if (this.root && this.currentLevel === -1) {
+ throw new Error("Document can only have one root node. " + this.debugInfo(name));
+ }
+ this.openCurrent();
+ name = getValue(name);
+ if (attributes == null) {
+ attributes = {};
+ }
+ attributes = getValue(attributes);
+ // swap argument order: text <-> attributes
+ if (!isObject(attributes)) {
+ [text, attributes] = [attributes, text];
+ }
+ this.currentNode = new XMLElement(this, name, attributes);
+ this.currentNode.children = false;
+ this.currentLevel++;
+ this.openTags[this.currentLevel] = this.currentNode;
+ if (text != null) {
+ this.text(text);
+ }
+ return this;
+ }
+
+ // Creates a child element node or an element type declaration when called
+ // inside the DTD
+
+ // `name` name of the node
+ // `attributes` an object containing name/value pairs of attributes
+ // `text` element text
+ element(name, attributes, text) {
+ var child, i, len, oldValidationFlag, ref, root;
+ if (this.currentNode && this.currentNode.type === NodeType.DocType) {
+ this.dtdElement(...arguments);
+ } else {
+ if (Array.isArray(name) || isObject(name) || isFunction(name)) {
+ oldValidationFlag = this.options.noValidation;
+ this.options.noValidation = true;
+ root = new XMLDocument(this.options).element('TEMP_ROOT');
+ root.element(name);
+ this.options.noValidation = oldValidationFlag;
+ ref = root.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ this.createChildNode(child);
+ if (child.type === NodeType.Element) {
+ this.up();
+ }
+ }
+ } else {
+ this.node(name, attributes, text);
+ }
+ }
+ return this;
+ }
+
+ // Adds or modifies an attribute
+
+ // `name` attribute name
+ // `value` attribute value
+ attribute(name, value) {
+ var attName, attValue;
+ if (!this.currentNode || this.currentNode.children) {
+ throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
+ }
+ if (name != null) {
+ name = getValue(name);
+ }
+ if (isObject(name)) { // expand if object
+ for (attName in name) {
+ if (!hasProp.call(name, attName)) continue;
+ attValue = name[attName];
+ this.attribute(attName, attValue);
+ }
+ } else {
+ if (isFunction(value)) {
+ value = value.apply();
+ }
+ if (this.options.keepNullAttributes && (value == null)) {
+ this.currentNode.attribs[name] = new XMLAttribute(this, name, "");
+ } else if (value != null) {
+ this.currentNode.attribs[name] = new XMLAttribute(this, name, value);
+ }
+ }
+ return this;
+ }
+
+ // Creates a text node
+
+ // `value` element text
+ text(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLText(this, value);
+ this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates a CDATA node
+
+ // `value` element text without CDATA delimiters
+ cdata(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLCData(this, value);
+ this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates a comment node
+
+ // `value` comment text
+ comment(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLComment(this, value);
+ this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Adds unescaped raw text
+
+ // `value` text
+ raw(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLRaw(this, value);
+ this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Adds a processing instruction
+
+ // `target` instruction target
+ // `value` instruction value
+ instruction(target, value) {
+ var i, insTarget, insValue, len, node;
+ this.openCurrent();
+ if (target != null) {
+ target = getValue(target);
+ }
+ if (value != null) {
+ value = getValue(value);
+ }
+ if (Array.isArray(target)) { // expand if array
+ for (i = 0, len = target.length; i < len; i++) {
+ insTarget = target[i];
+ this.instruction(insTarget);
+ }
+ } else if (isObject(target)) { // expand if object
+ for (insTarget in target) {
+ if (!hasProp.call(target, insTarget)) continue;
+ insValue = target[insTarget];
+ this.instruction(insTarget, insValue);
+ }
+ } else {
+ if (isFunction(value)) {
+ value = value.apply();
+ }
+ node = new XMLProcessingInstruction(this, target, value);
+ this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ }
+ return this;
+ }
+
+ // Creates the xml declaration
+
+ // `version` A version number string, e.g. 1.0
+ // `encoding` Encoding declaration, e.g. UTF-8
+ // `standalone` standalone document declaration: true or false
+ declaration(version, encoding, standalone) {
+ var node;
+ this.openCurrent();
+ if (this.documentStarted) {
+ throw new Error("declaration() must be the first node.");
+ }
+ node = new XMLDeclaration(this, version, encoding, standalone);
+ this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates the document type declaration
+
+ // `root` the name of the root node
+ // `pubID` the public identifier of the external subset
+ // `sysID` the system identifier of the external subset
+ doctype(root, pubID, sysID) {
+ this.openCurrent();
+ if (root == null) {
+ throw new Error("Missing root node name.");
+ }
+ if (this.root) {
+ throw new Error("dtd() must come before the root node.");
+ }
+ this.currentNode = new XMLDocType(this, pubID, sysID);
+ this.currentNode.rootNodeName = root;
+ this.currentNode.children = false;
+ this.currentLevel++;
+ this.openTags[this.currentLevel] = this.currentNode;
+ return this;
+ }
+
+ // Creates an element type declaration
+
+ // `name` element name
+ // `value` element content (defaults to #PCDATA)
+ dtdElement(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDElement(this, name, value);
+ this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates an attribute declaration
+
+ // `elementName` the name of the element containing this attribute
+ // `attributeName` attribute name
+ // `attributeType` type of the attribute (defaults to CDATA)
+ // `defaultValueType` default value type (either #REQUIRED, #IMPLIED, #FIXED or
+ // #DEFAULT) (defaults to #IMPLIED)
+ // `defaultValue` default value of the attribute
+ // (only used for #FIXED or #DEFAULT)
+ attList(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
+ this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates a general entity declaration
+
+ // `name` the name of the entity
+ // `value` internal entity value or an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ // `value.nData` notation declaration
+ entity(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDEntity(this, false, name, value);
+ this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates a parameter entity declaration
+
+ // `name` the name of the entity
+ // `value` internal entity value or an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ pEntity(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDEntity(this, true, name, value);
+ this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates a NOTATION declaration
+
+ // `name` the name of the notation
+ // `value` an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ notation(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDNotation(this, name, value);
+ this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Gets the parent node
+ up() {
+ if (this.currentLevel < 0) {
+ throw new Error("The document node has no parent.");
+ }
+ if (this.currentNode) {
+ if (this.currentNode.children) {
+ this.closeNode(this.currentNode);
+ } else {
+ this.openNode(this.currentNode);
+ }
+ this.currentNode = null;
+ } else {
+ this.closeNode(this.openTags[this.currentLevel]);
+ }
+ delete this.openTags[this.currentLevel];
+ this.currentLevel--;
+ return this;
+ }
+
+ // Ends the document
+ end() {
+ while (this.currentLevel >= 0) {
+ this.up();
+ }
+ return this.onEnd();
+ }
+
+ // Opens the current parent node
+ openCurrent() {
+ if (this.currentNode) {
+ this.currentNode.children = true;
+ return this.openNode(this.currentNode);
+ }
+ }
+
+ // Writes the opening tag of the current node or the entire node if it has
+ // no child nodes
+ openNode(node) {
+ var att, chunk, name, ref;
+ if (!node.isOpen) {
+ if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) {
+ this.root = node;
+ }
+ chunk = '';
+ if (node.type === NodeType.Element) {
+ this.writerOptions.state = WriterState.OpenTag;
+ chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name;
+ ref = node.attribs;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel);
+ }
+ chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel);
+ this.writerOptions.state = WriterState.InsideTag; // if node.type is NodeType.DocType
+ } else {
+ this.writerOptions.state = WriterState.OpenTag;
+ chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '';
+ }
+ chunk += this.writer.endline(node, this.writerOptions, this.currentLevel);
+ }
+ this.onData(chunk, this.currentLevel);
+ return node.isOpen = true;
+ }
+ }
+
+ // Writes the closing tag of the current node
+ closeNode(node) {
+ var chunk;
+ if (!node.isClosed) {
+ chunk = '';
+ this.writerOptions.state = WriterState.CloseTag;
+ if (node.type === NodeType.Element) {
+ chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '' + node.name + '>' + this.writer.endline(node, this.writerOptions, this.currentLevel); // if node.type is NodeType.DocType
+ } else {
+ chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
+ }
+ this.writerOptions.state = WriterState.None;
+ this.onData(chunk, this.currentLevel);
+ return node.isClosed = true;
+ }
+ }
+
+ // Called when a new chunk of XML is output
+
+ // `chunk` a string containing the XML chunk
+ // `level` current indentation level
+ onData(chunk, level) {
+ this.documentStarted = true;
+ return this.onDataCallback(chunk, level + 1);
+ }
+
+ // Called when the XML document is completed
+ onEnd() {
+ this.documentCompleted = true;
+ return this.onEndCallback();
+ }
+
+ // Returns debug string
+ debugInfo(name) {
+ if (name == null) {
+ return "";
+ } else {
+ return "node: <" + name + ">";
+ }
+ }
+
+ // Node aliases
+ ele() {
+ return this.element(...arguments);
+ }
+
+ nod(name, attributes, text) {
+ return this.node(name, attributes, text);
+ }
+
+ txt(value) {
+ return this.text(value);
+ }
+
+ dat(value) {
+ return this.cdata(value);
+ }
+
+ com(value) {
+ return this.comment(value);
+ }
+
+ ins(target, value) {
+ return this.instruction(target, value);
+ }
+
+ dec(version, encoding, standalone) {
+ return this.declaration(version, encoding, standalone);
+ }
+
+ dtd(root, pubID, sysID) {
+ return this.doctype(root, pubID, sysID);
+ }
+
+ e(name, attributes, text) {
+ return this.element(name, attributes, text);
+ }
+
+ n(name, attributes, text) {
+ return this.node(name, attributes, text);
+ }
+
+ t(value) {
+ return this.text(value);
+ }
+
+ d(value) {
+ return this.cdata(value);
+ }
+
+ c(value) {
+ return this.comment(value);
+ }
+
+ r(value) {
+ return this.raw(value);
+ }
+
+ i(target, value) {
+ return this.instruction(target, value);
+ }
+
+ // Attribute aliases
+ att() {
+ if (this.currentNode && this.currentNode.type === NodeType.DocType) {
+ return this.attList(...arguments);
+ } else {
+ return this.attribute(...arguments);
+ }
+ }
+
+ a() {
+ if (this.currentNode && this.currentNode.type === NodeType.DocType) {
+ return this.attList(...arguments);
+ } else {
+ return this.attribute(...arguments);
+ }
+ }
+
+ // DTD aliases
+ // att() and ele() are defined above
+ ent(name, value) {
+ return this.entity(name, value);
+ }
+
+ pent(name, value) {
+ return this.pEntity(name, value);
+ }
+
+ not(name, value) {
+ return this.notation(name, value);
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":5,"./Utility":6,"./WriterState":7,"./XMLAttribute":8,"./XMLCData":9,"./XMLComment":11,"./XMLDTDAttList":16,"./XMLDTDElement":17,"./XMLDTDEntity":18,"./XMLDTDNotation":19,"./XMLDeclaration":20,"./XMLDocType":21,"./XMLDocument":22,"./XMLElement":25,"./XMLProcessingInstruction":29,"./XMLRaw":30,"./XMLStringWriter":32,"./XMLStringifier":33,"./XMLText":34}],24:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDummy, XMLNode;
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ // Represents a raw node
+ module.exports = XMLDummy = class XMLDummy extends XMLNode {
+ // Initializes a new instance of `XMLDummy`
+
+ // `XMLDummy` is a special node representing a node with
+ // a null value. Dummy nodes are created while recursively
+ // building the XML tree. Simply skipping null values doesn't
+ // work because that would break the recursive chain.
+ constructor(parent) {
+ super(parent);
+ this.type = NodeType.Dummy;
+ }
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return '';
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":5,"./XMLNode":27}],25:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject,
+ hasProp = {}.hasOwnProperty;
+
+ ({isObject, isFunction, getValue} = require('./Utility'));
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ XMLAttribute = require('./XMLAttribute');
+
+ XMLNamedNodeMap = require('./XMLNamedNodeMap');
+
+ // Represents an element of the XML document
+ module.exports = XMLElement = (function() {
+ class XMLElement extends XMLNode {
+ // Initializes a new instance of `XMLElement`
+
+ // `parent` the parent node
+ // `name` element name
+ // `attributes` an object containing name/value pairs of attributes
+ constructor(parent, name, attributes) {
+ var child, j, len, ref;
+ super(parent);
+ if (name == null) {
+ throw new Error("Missing element name. " + this.debugInfo());
+ }
+ this.name = this.stringify.name(name);
+ this.type = NodeType.Element;
+ this.attribs = {};
+ this.schemaTypeInfo = null;
+ if (attributes != null) {
+ this.attribute(attributes);
+ }
+ // set properties if this is the root node
+ if (parent.type === NodeType.Document) {
+ this.isRoot = true;
+ this.documentObject = parent;
+ parent.rootObject = this;
+ // set dtd name
+ if (parent.children) {
+ ref = parent.children;
+ for (j = 0, len = ref.length; j < len; j++) {
+ child = ref[j];
+ if (child.type === NodeType.DocType) {
+ child.name = this.name;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ // Creates and returns a deep clone of `this`
+
+ clone() {
+ var att, attName, clonedSelf, ref;
+ clonedSelf = Object.create(this);
+ // remove document element
+ if (clonedSelf.isRoot) {
+ clonedSelf.documentObject = null;
+ }
+ // clone attributes
+ clonedSelf.attribs = {};
+ ref = this.attribs;
+ for (attName in ref) {
+ if (!hasProp.call(ref, attName)) continue;
+ att = ref[attName];
+ clonedSelf.attribs[attName] = att.clone();
+ }
+ // clone child nodes
+ clonedSelf.children = [];
+ this.children.forEach(function(child) {
+ var clonedChild;
+ clonedChild = child.clone();
+ clonedChild.parent = clonedSelf;
+ return clonedSelf.children.push(clonedChild);
+ });
+ return clonedSelf;
+ }
+
+ // Adds or modifies an attribute
+
+ // `name` attribute name
+ // `value` attribute value
+ attribute(name, value) {
+ var attName, attValue;
+ if (name != null) {
+ name = getValue(name);
+ }
+ if (isObject(name)) { // expand if object
+ for (attName in name) {
+ if (!hasProp.call(name, attName)) continue;
+ attValue = name[attName];
+ this.attribute(attName, attValue);
+ }
+ } else {
+ if (isFunction(value)) {
+ value = value.apply();
+ }
+ if (this.options.keepNullAttributes && (value == null)) {
+ this.attribs[name] = new XMLAttribute(this, name, "");
+ } else if (value != null) {
+ this.attribs[name] = new XMLAttribute(this, name, value);
+ }
+ }
+ return this;
+ }
+
+ // Removes an attribute
+
+ // `name` attribute name
+ removeAttribute(name) {
+ var attName, j, len;
+ // Also defined in DOM level 1
+ // removeAttribute(name) removes an attribute by name.
+ if (name == null) {
+ throw new Error("Missing attribute name. " + this.debugInfo());
+ }
+ name = getValue(name);
+ if (Array.isArray(name)) { // expand if array
+ for (j = 0, len = name.length; j < len; j++) {
+ attName = name[j];
+ delete this.attribs[attName];
+ }
+ } else {
+ delete this.attribs[name];
+ }
+ return this;
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ // `options.allowEmpty` do not self close empty element tags
+ toString(options) {
+ return this.options.writer.element(this, this.options.writer.filterOptions(options));
+ }
+
+ // Aliases
+ att(name, value) {
+ return this.attribute(name, value);
+ }
+
+ a(name, value) {
+ return this.attribute(name, value);
+ }
+
+ // DOM Level 1
+ getAttribute(name) {
+ if (this.attribs.hasOwnProperty(name)) {
+ return this.attribs[name].value;
+ } else {
+ return null;
+ }
+ }
+
+ setAttribute(name, value) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getAttributeNode(name) {
+ if (this.attribs.hasOwnProperty(name)) {
+ return this.attribs[name];
+ } else {
+ return null;
+ }
+ }
+
+ setAttributeNode(newAttr) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ removeAttributeNode(oldAttr) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementsByTagName(name) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM Level 2
+ getAttributeNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ setAttributeNS(namespaceURI, qualifiedName, value) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ removeAttributeNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getAttributeNodeNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ setAttributeNodeNS(newAttr) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementsByTagNameNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ hasAttribute(name) {
+ return this.attribs.hasOwnProperty(name);
+ }
+
+ hasAttributeNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM Level 3
+ setIdAttribute(name, isId) {
+ if (this.attribs.hasOwnProperty(name)) {
+ return this.attribs[name].isId;
+ } else {
+ return isId;
+ }
+ }
+
+ setIdAttributeNS(namespaceURI, localName, isId) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ setIdAttributeNode(idAttr, isId) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM Level 4
+ getElementsByTagName(tagname) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementsByTagNameNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementsByClassName(classNames) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ isEqualNode(node) {
+ var i, j, ref;
+ if (!super.isEqualNode(node)) {
+ return false;
+ }
+ if (node.namespaceURI !== this.namespaceURI) {
+ return false;
+ }
+ if (node.prefix !== this.prefix) {
+ return false;
+ }
+ if (node.localName !== this.localName) {
+ return false;
+ }
+ if (node.attribs.length !== this.attribs.length) {
+ return false;
+ }
+ for (i = j = 0, ref = this.attribs.length - 1; (0 <= ref ? j <= ref : j >= ref); i = 0 <= ref ? ++j : --j) {
+ if (!this.attribs[i].isEqualNode(node.attribs[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLElement.prototype, 'tagName', {
+ get: function() {
+ return this.name;
+ }
+ });
+
+ // DOM level 4
+ Object.defineProperty(XMLElement.prototype, 'namespaceURI', {
+ get: function() {
+ return '';
+ }
+ });
+
+ Object.defineProperty(XMLElement.prototype, 'prefix', {
+ get: function() {
+ return '';
+ }
+ });
+
+ Object.defineProperty(XMLElement.prototype, 'localName', {
+ get: function() {
+ return this.name;
+ }
+ });
+
+ Object.defineProperty(XMLElement.prototype, 'id', {
+ get: function() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+ });
+
+ Object.defineProperty(XMLElement.prototype, 'className', {
+ get: function() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+ });
+
+ Object.defineProperty(XMLElement.prototype, 'classList', {
+ get: function() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+ });
+
+ Object.defineProperty(XMLElement.prototype, 'attributes', {
+ get: function() {
+ if (!this.attributeMap || !this.attributeMap.nodes) {
+ this.attributeMap = new XMLNamedNodeMap(this.attribs);
+ }
+ return this.attributeMap;
+ }
+ });
+
+ return XMLElement;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./NodeType":5,"./Utility":6,"./XMLAttribute":8,"./XMLNamedNodeMap":26,"./XMLNode":27}],26:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Represents a map of nodes accessed by a string key
+ var XMLNamedNodeMap;
+
+ module.exports = XMLNamedNodeMap = (function() {
+ class XMLNamedNodeMap {
+ // Initializes a new instance of `XMLNamedNodeMap`
+ // This is just a wrapper around an ordinary
+ // JS object.
+
+ // `nodes` the object containing nodes.
+ constructor(nodes) {
+ this.nodes = nodes;
+ }
+
+ // Creates and returns a deep clone of `this`
+
+ clone() {
+ // this class should not be cloned since it wraps
+ // around a given object. The calling function should check
+ // whether the wrapped object is null and supply a new object
+ // (from the clone).
+ return this.nodes = null;
+ }
+
+ // DOM Level 1
+ getNamedItem(name) {
+ return this.nodes[name];
+ }
+
+ setNamedItem(node) {
+ var oldNode;
+ oldNode = this.nodes[node.nodeName];
+ this.nodes[node.nodeName] = node;
+ return oldNode || null;
+ }
+
+ removeNamedItem(name) {
+ var oldNode;
+ oldNode = this.nodes[name];
+ delete this.nodes[name];
+ return oldNode || null;
+ }
+
+ item(index) {
+ return this.nodes[Object.keys(this.nodes)[index]] || null;
+ }
+
+ // DOM level 2 functions to be implemented later
+ getNamedItemNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ setNamedItemNS(node) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ removeNamedItemNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ };
+
+
+ // DOM level 1
+ Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
+ get: function() {
+ return Object.keys(this.nodes).length || 0;
+ }
+ });
+
+ return XMLNamedNodeMap;
+
+ }).call(this);
+
+}).call(this);
+
+},{}],27:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject,
+ hasProp = {}.hasOwnProperty,
+ splice = [].splice;
+
+ ({isObject, isFunction, isEmpty, getValue} = require('./Utility'));
+
+ XMLElement = null;
+
+ XMLCData = null;
+
+ XMLComment = null;
+
+ XMLDeclaration = null;
+
+ XMLDocType = null;
+
+ XMLRaw = null;
+
+ XMLText = null;
+
+ XMLProcessingInstruction = null;
+
+ XMLDummy = null;
+
+ NodeType = null;
+
+ XMLNodeList = null;
+
+ XMLNamedNodeMap = null;
+
+ DocumentPosition = null;
+
+ // Represents a generic XMl element
+ module.exports = XMLNode = (function() {
+ class XMLNode {
+ // Initializes a new instance of `XMLNode`
+
+ // `parent` the parent node
+ constructor(parent1) {
+ this.parent = parent1;
+ if (this.parent) {
+ this.options = this.parent.options;
+ this.stringify = this.parent.stringify;
+ }
+ this.value = null;
+ this.children = [];
+ this.baseURI = null;
+ // first execution, load dependencies that are otherwise
+ // circular (so we can't load them at the top)
+ if (!XMLElement) {
+ XMLElement = require('./XMLElement');
+ XMLCData = require('./XMLCData');
+ XMLComment = require('./XMLComment');
+ XMLDeclaration = require('./XMLDeclaration');
+ XMLDocType = require('./XMLDocType');
+ XMLRaw = require('./XMLRaw');
+ XMLText = require('./XMLText');
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+ XMLDummy = require('./XMLDummy');
+ NodeType = require('./NodeType');
+ XMLNodeList = require('./XMLNodeList');
+ XMLNamedNodeMap = require('./XMLNamedNodeMap');
+ DocumentPosition = require('./DocumentPosition');
+ }
+ }
+
+
+ // Sets the parent node of this node and its children recursively
+
+ // `parent` the parent node
+ setParent(parent) {
+ var child, j, len, ref1, results;
+ this.parent = parent;
+ if (parent) {
+ this.options = parent.options;
+ this.stringify = parent.stringify;
+ }
+ ref1 = this.children;
+ results = [];
+ for (j = 0, len = ref1.length; j < len; j++) {
+ child = ref1[j];
+ results.push(child.setParent(this));
+ }
+ return results;
+ }
+
+ // Creates a child element node
+
+ // `name` node name or an object describing the XML tree
+ // `attributes` an object containing name/value pairs of attributes
+ // `text` element text
+ element(name, attributes, text) {
+ var childNode, item, j, k, key, lastChild, len, len1, val;
+ lastChild = null;
+ if (attributes === null && (text == null)) {
+ [attributes, text] = [{}, null];
+ }
+ if (attributes == null) {
+ attributes = {};
+ }
+ attributes = getValue(attributes);
+ // swap argument order: text <-> attributes
+ if (!isObject(attributes)) {
+ [text, attributes] = [attributes, text];
+ }
+ if (name != null) {
+ name = getValue(name);
+ }
+ // expand if array
+ if (Array.isArray(name)) {
+ for (j = 0, len = name.length; j < len; j++) {
+ item = name[j];
+ lastChild = this.element(item);
+ }
+ // evaluate if function
+ } else if (isFunction(name)) {
+ lastChild = this.element(name.apply());
+ // expand if object
+ } else if (isObject(name)) {
+ for (key in name) {
+ if (!hasProp.call(name, key)) continue;
+ val = name[key];
+ if (isFunction(val)) {
+ // evaluate if function
+ val = val.apply();
+ }
+ // assign attributes
+ if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
+ lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
+ // skip empty arrays
+ } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
+ lastChild = this.dummy();
+ // empty objects produce one node
+ } else if (isObject(val) && isEmpty(val)) {
+ lastChild = this.element(key);
+ // skip null and undefined nodes
+ } else if (!this.options.keepNullNodes && (val == null)) {
+ lastChild = this.dummy();
+
+ // expand list by creating child nodes
+ } else if (!this.options.separateArrayItems && Array.isArray(val)) {
+ for (k = 0, len1 = val.length; k < len1; k++) {
+ item = val[k];
+ childNode = {};
+ childNode[key] = item;
+ lastChild = this.element(childNode);
+ }
+
+ // expand child nodes under parent
+ } else if (isObject(val)) {
+ // if the key is #text expand child nodes under this node to support mixed content
+ if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
+ lastChild = this.element(val);
+ } else {
+ lastChild = this.element(key);
+ lastChild.element(val);
+ }
+ } else {
+
+ // text node
+ lastChild = this.element(key, val);
+ }
+ }
+ // skip null nodes
+ } else if (!this.options.keepNullNodes && text === null) {
+ lastChild = this.dummy();
+ } else {
+ // text node
+ if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
+ lastChild = this.text(text);
+ // cdata node
+ } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
+ lastChild = this.cdata(text);
+ // comment node
+ } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
+ lastChild = this.comment(text);
+ // raw text node
+ } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
+ lastChild = this.raw(text);
+ // processing instruction
+ } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
+ lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
+ } else {
+ // element node
+ lastChild = this.node(name, attributes, text);
+ }
+ }
+ if (lastChild == null) {
+ throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
+ }
+ return lastChild;
+ }
+
+ // Creates a child element node before the current node
+
+ // `name` node name or an object describing the XML tree
+ // `attributes` an object containing name/value pairs of attributes
+ // `text` element text
+ insertBefore(name, attributes, text) {
+ var child, i, newChild, refChild, removed;
+ // DOM level 1
+ // insertBefore(newChild, refChild) inserts the child node newChild before refChild
+ if (name != null ? name.type : void 0) {
+ newChild = name;
+ refChild = attributes;
+ newChild.setParent(this);
+ if (refChild) {
+ // temporarily remove children starting *with* refChild
+ i = children.indexOf(refChild);
+ removed = children.splice(i);
+
+ // add the new child
+ children.push(newChild);
+
+ // add back removed children after new child
+ Array.prototype.push.apply(children, removed);
+ } else {
+ children.push(newChild);
+ }
+ return newChild;
+ } else {
+ if (this.isRoot) {
+ throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
+ }
+
+ // temporarily remove children starting *with* this
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i);
+
+ // add the new child
+ child = this.parent.element(name, attributes, text);
+
+ // add back removed children after new child
+ Array.prototype.push.apply(this.parent.children, removed);
+ return child;
+ }
+ }
+
+ // Creates a child element node after the current node
+
+ // `name` node name or an object describing the XML tree
+ // `attributes` an object containing name/value pairs of attributes
+ // `text` element text
+ insertAfter(name, attributes, text) {
+ var child, i, removed;
+ if (this.isRoot) {
+ throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
+ }
+
+ // temporarily remove children starting *after* this
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i + 1);
+
+ // add the new child
+ child = this.parent.element(name, attributes, text);
+
+ // add back removed children after new child
+ Array.prototype.push.apply(this.parent.children, removed);
+ return child;
+ }
+
+ // Deletes a child element node
+
+ remove() {
+ var i, ref1;
+ if (this.isRoot) {
+ throw new Error("Cannot remove the root element. " + this.debugInfo());
+ }
+ i = this.parent.children.indexOf(this);
+ splice.apply(this.parent.children, [i, i - i + 1].concat(ref1 = [])), ref1;
+ return this.parent;
+ }
+
+ // Creates a node
+
+ // `name` name of the node
+ // `attributes` an object containing name/value pairs of attributes
+ // `text` element text
+ node(name, attributes, text) {
+ var child;
+ if (name != null) {
+ name = getValue(name);
+ }
+ attributes || (attributes = {});
+ attributes = getValue(attributes);
+ // swap argument order: text <-> attributes
+ if (!isObject(attributes)) {
+ [text, attributes] = [attributes, text];
+ }
+ child = new XMLElement(this, name, attributes);
+ if (text != null) {
+ child.text(text);
+ }
+ this.children.push(child);
+ return child;
+ }
+
+ // Creates a text node
+
+ // `value` element text
+ text(value) {
+ var child;
+ if (isObject(value)) {
+ this.element(value);
+ }
+ child = new XMLText(this, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates a CDATA node
+
+ // `value` element text without CDATA delimiters
+ cdata(value) {
+ var child;
+ child = new XMLCData(this, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates a comment node
+
+ // `value` comment text
+ comment(value) {
+ var child;
+ child = new XMLComment(this, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates a comment node before the current node
+
+ // `value` comment text
+ commentBefore(value) {
+ var child, i, removed;
+ // temporarily remove children starting *with* this
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i);
+ // add the new child
+ child = this.parent.comment(value);
+ // add back removed children after new child
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ }
+
+ // Creates a comment node after the current node
+
+ // `value` comment text
+ commentAfter(value) {
+ var child, i, removed;
+ // temporarily remove children starting *after* this
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i + 1);
+ // add the new child
+ child = this.parent.comment(value);
+ // add back removed children after new child
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ }
+
+ // Adds unescaped raw text
+
+ // `value` text
+ raw(value) {
+ var child;
+ child = new XMLRaw(this, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Adds a dummy node
+ dummy() {
+ var child;
+ child = new XMLDummy(this);
+ // Normally when a new node is created it is added to the child node collection.
+ // However, dummy nodes are never added to the XML tree. They are created while
+ // converting JS objects to XML nodes in order not to break the recursive function
+ // chain. They can be thought of as invisible nodes. They can be traversed through
+ // by using prev(), next(), up(), etc. functions but they do not exists in the tree.
+
+ // @children.push child
+ return child;
+ }
+
+ // Adds a processing instruction
+
+ // `target` instruction target
+ // `value` instruction value
+ instruction(target, value) {
+ var insTarget, insValue, instruction, j, len;
+ if (target != null) {
+ target = getValue(target);
+ }
+ if (value != null) {
+ value = getValue(value);
+ }
+ if (Array.isArray(target)) { // expand if array
+ for (j = 0, len = target.length; j < len; j++) {
+ insTarget = target[j];
+ this.instruction(insTarget);
+ }
+ } else if (isObject(target)) { // expand if object
+ for (insTarget in target) {
+ if (!hasProp.call(target, insTarget)) continue;
+ insValue = target[insTarget];
+ this.instruction(insTarget, insValue);
+ }
+ } else {
+ if (isFunction(value)) {
+ value = value.apply();
+ }
+ instruction = new XMLProcessingInstruction(this, target, value);
+ this.children.push(instruction);
+ }
+ return this;
+ }
+
+ // Creates a processing instruction node before the current node
+
+ // `target` instruction target
+ // `value` instruction value
+ instructionBefore(target, value) {
+ var child, i, removed;
+ // temporarily remove children starting *with* this
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i);
+ // add the new child
+ child = this.parent.instruction(target, value);
+ // add back removed children after new child
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ }
+
+ // Creates a processing instruction node after the current node
+
+ // `target` instruction target
+ // `value` instruction value
+ instructionAfter(target, value) {
+ var child, i, removed;
+ // temporarily remove children starting *after* this
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i + 1);
+ // add the new child
+ child = this.parent.instruction(target, value);
+ // add back removed children after new child
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ }
+
+ // Creates the xml declaration
+
+ // `version` A version number string, e.g. 1.0
+ // `encoding` Encoding declaration, e.g. UTF-8
+ // `standalone` standalone document declaration: true or false
+ declaration(version, encoding, standalone) {
+ var doc, xmldec;
+ doc = this.document();
+ xmldec = new XMLDeclaration(doc, version, encoding, standalone);
+ // Replace XML declaration if exists, otherwise insert at top
+ if (doc.children.length === 0) {
+ doc.children.unshift(xmldec);
+ } else if (doc.children[0].type === NodeType.Declaration) {
+ doc.children[0] = xmldec;
+ } else {
+ doc.children.unshift(xmldec);
+ }
+ return doc.root() || doc;
+ }
+
+ // Creates the document type declaration
+
+ // `pubID` the public identifier of the external subset
+ // `sysID` the system identifier of the external subset
+ dtd(pubID, sysID) {
+ var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
+ doc = this.document();
+ doctype = new XMLDocType(doc, pubID, sysID);
+ ref1 = doc.children;
+ // Replace DTD if exists
+ for (i = j = 0, len = ref1.length; j < len; i = ++j) {
+ child = ref1[i];
+ if (child.type === NodeType.DocType) {
+ doc.children[i] = doctype;
+ return doctype;
+ }
+ }
+ ref2 = doc.children;
+ // insert before root node if the root node exists
+ for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
+ child = ref2[i];
+ if (child.isRoot) {
+ doc.children.splice(i, 0, doctype);
+ return doctype;
+ }
+ }
+ // otherwise append to end
+ doc.children.push(doctype);
+ return doctype;
+ }
+
+ // Gets the parent node
+ up() {
+ if (this.isRoot) {
+ throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
+ }
+ return this.parent;
+ }
+
+ // Gets the root node
+ root() {
+ var node;
+ node = this;
+ while (node) {
+ if (node.type === NodeType.Document) {
+ return node.rootObject;
+ } else if (node.isRoot) {
+ return node;
+ } else {
+ node = node.parent;
+ }
+ }
+ }
+
+ // Gets the node representing the XML document
+ document() {
+ var node;
+ node = this;
+ while (node) {
+ if (node.type === NodeType.Document) {
+ return node;
+ } else {
+ node = node.parent;
+ }
+ }
+ }
+
+ // Ends the document and converts string
+ end(options) {
+ return this.document().end(options);
+ }
+
+ // Gets the previous node
+ prev() {
+ var i;
+ i = this.parent.children.indexOf(this);
+ if (i < 1) {
+ throw new Error("Already at the first node. " + this.debugInfo());
+ }
+ return this.parent.children[i - 1];
+ }
+
+ // Gets the next node
+ next() {
+ var i;
+ i = this.parent.children.indexOf(this);
+ if (i === -1 || i === this.parent.children.length - 1) {
+ throw new Error("Already at the last node. " + this.debugInfo());
+ }
+ return this.parent.children[i + 1];
+ }
+
+ // Imports cloned root from another XML document
+
+ // `doc` the XML document to insert nodes from
+ importDocument(doc) {
+ var child, clonedRoot, j, len, ref1;
+ clonedRoot = doc.root().clone();
+ clonedRoot.parent = this;
+ clonedRoot.isRoot = false;
+ this.children.push(clonedRoot);
+ // set properties if imported element becomes the root node
+ if (this.type === NodeType.Document) {
+ clonedRoot.isRoot = true;
+ clonedRoot.documentObject = this;
+ this.rootObject = clonedRoot;
+ // set dtd name
+ if (this.children) {
+ ref1 = this.children;
+ for (j = 0, len = ref1.length; j < len; j++) {
+ child = ref1[j];
+ if (child.type === NodeType.DocType) {
+ child.name = clonedRoot.name;
+ break;
+ }
+ }
+ }
+ }
+ return this;
+ }
+
+
+ // Returns debug string for this node
+ debugInfo(name) {
+ var ref1, ref2;
+ name = name || this.name;
+ if ((name == null) && !((ref1 = this.parent) != null ? ref1.name : void 0)) {
+ return "";
+ } else if (name == null) {
+ return "parent: <" + this.parent.name + ">";
+ } else if (!((ref2 = this.parent) != null ? ref2.name : void 0)) {
+ return "node: <" + name + ">";
+ } else {
+ return "node: <" + name + ">, parent: <" + this.parent.name + ">";
+ }
+ }
+
+ // Aliases
+ ele(name, attributes, text) {
+ return this.element(name, attributes, text);
+ }
+
+ nod(name, attributes, text) {
+ return this.node(name, attributes, text);
+ }
+
+ txt(value) {
+ return this.text(value);
+ }
+
+ dat(value) {
+ return this.cdata(value);
+ }
+
+ com(value) {
+ return this.comment(value);
+ }
+
+ ins(target, value) {
+ return this.instruction(target, value);
+ }
+
+ doc() {
+ return this.document();
+ }
+
+ dec(version, encoding, standalone) {
+ return this.declaration(version, encoding, standalone);
+ }
+
+ e(name, attributes, text) {
+ return this.element(name, attributes, text);
+ }
+
+ n(name, attributes, text) {
+ return this.node(name, attributes, text);
+ }
+
+ t(value) {
+ return this.text(value);
+ }
+
+ d(value) {
+ return this.cdata(value);
+ }
+
+ c(value) {
+ return this.comment(value);
+ }
+
+ r(value) {
+ return this.raw(value);
+ }
+
+ i(target, value) {
+ return this.instruction(target, value);
+ }
+
+ u() {
+ return this.up();
+ }
+
+ // can be deprecated in a future release
+ importXMLBuilder(doc) {
+ return this.importDocument(doc);
+ }
+
+ // Adds or modifies an attribute.
+
+ // `name` attribute name
+ // `value` attribute value
+ attribute(name, value) {
+ throw new Error("attribute() applies to element nodes only.");
+ }
+
+ att(name, value) {
+ return this.attribute(name, value);
+ }
+
+ a(name, value) {
+ return this.attribute(name, value);
+ }
+
+ // Removes an attribute
+
+ // `name` attribute name
+ removeAttribute(name) {
+ throw new Error("attribute() applies to element nodes only.");
+ }
+
+ // DOM level 1 functions to be implemented later
+ replaceChild(newChild, oldChild) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ removeChild(oldChild) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ appendChild(newChild) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ hasChildNodes() {
+ return this.children.length !== 0;
+ }
+
+ cloneNode(deep) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ normalize() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM level 2
+ isSupported(feature, version) {
+ return true;
+ }
+
+ hasAttributes() {
+ return this.attribs.length !== 0;
+ }
+
+ // DOM level 3 functions to be implemented later
+ compareDocumentPosition(other) {
+ var ref, res;
+ ref = this;
+ if (ref === other) {
+ return 0;
+ } else if (this.document() !== other.document()) {
+ res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
+ if (Math.random() < 0.5) {
+ res |= DocumentPosition.Preceding;
+ } else {
+ res |= DocumentPosition.Following;
+ }
+ return res;
+ } else if (ref.isAncestor(other)) {
+ return DocumentPosition.Contains | DocumentPosition.Preceding;
+ } else if (ref.isDescendant(other)) {
+ return DocumentPosition.Contains | DocumentPosition.Following;
+ } else if (ref.isPreceding(other)) {
+ return DocumentPosition.Preceding;
+ } else {
+ return DocumentPosition.Following;
+ }
+ }
+
+ isSameNode(other) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ lookupPrefix(namespaceURI) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ isDefaultNamespace(namespaceURI) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ lookupNamespaceURI(prefix) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ isEqualNode(node) {
+ var i, j, ref1;
+ if (node.nodeType !== this.nodeType) {
+ return false;
+ }
+ if (node.children.length !== this.children.length) {
+ return false;
+ }
+ for (i = j = 0, ref1 = this.children.length - 1; (0 <= ref1 ? j <= ref1 : j >= ref1); i = 0 <= ref1 ? ++j : --j) {
+ if (!this.children[i].isEqualNode(node.children[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ getFeature(feature, version) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ setUserData(key, data, handler) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getUserData(key) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // Returns true if other is an inclusive descendant of node,
+ // and false otherwise.
+ contains(other) {
+ if (!other) {
+ return false;
+ }
+ return other === this || this.isDescendant(other);
+ }
+
+ // An object A is called a descendant of an object B, if either A is
+ // a child of B or A is a child of an object C that is a descendant of B.
+ isDescendant(node) {
+ var child, isDescendantChild, j, len, ref1;
+ ref1 = this.children;
+ for (j = 0, len = ref1.length; j < len; j++) {
+ child = ref1[j];
+ if (node === child) {
+ return true;
+ }
+ isDescendantChild = child.isDescendant(node);
+ if (isDescendantChild) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // An object A is called an ancestor of an object B if and only if
+ // B is a descendant of A.
+ isAncestor(node) {
+ return node.isDescendant(this);
+ }
+
+ // An object A is preceding an object B if A and B are in the
+ // same tree and A comes before B in tree order.
+ isPreceding(node) {
+ var nodePos, thisPos;
+ nodePos = this.treePosition(node);
+ thisPos = this.treePosition(this);
+ if (nodePos === -1 || thisPos === -1) {
+ return false;
+ } else {
+ return nodePos < thisPos;
+ }
+ }
+
+ // An object A is folllowing an object B if A and B are in the
+ // same tree and A comes after B in tree order.
+ isFollowing(node) {
+ var nodePos, thisPos;
+ nodePos = this.treePosition(node);
+ thisPos = this.treePosition(this);
+ if (nodePos === -1 || thisPos === -1) {
+ return false;
+ } else {
+ return nodePos > thisPos;
+ }
+ }
+
+ // Returns the preorder position of the given node in the tree, or -1
+ // if the node is not in the tree.
+ treePosition(node) {
+ var found, pos;
+ pos = 0;
+ found = false;
+ this.foreachTreeNode(this.document(), function(childNode) {
+ pos++;
+ if (!found && childNode === node) {
+ return found = true;
+ }
+ });
+ if (found) {
+ return pos;
+ } else {
+ return -1;
+ }
+ }
+
+
+ // Depth-first preorder traversal through the XML tree
+ foreachTreeNode(node, func) {
+ var child, j, len, ref1, res;
+ node || (node = this.document());
+ ref1 = node.children;
+ for (j = 0, len = ref1.length; j < len; j++) {
+ child = ref1[j];
+ if (res = func(child)) {
+ return res;
+ } else {
+ res = this.foreachTreeNode(child, func);
+ if (res) {
+ return res;
+ }
+ }
+ }
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLNode.prototype, 'nodeName', {
+ get: function() {
+ return this.name;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'nodeType', {
+ get: function() {
+ return this.type;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'nodeValue', {
+ get: function() {
+ return this.value;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'parentNode', {
+ get: function() {
+ return this.parent;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'childNodes', {
+ get: function() {
+ if (!this.childNodeList || !this.childNodeList.nodes) {
+ this.childNodeList = new XMLNodeList(this.children);
+ }
+ return this.childNodeList;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'firstChild', {
+ get: function() {
+ return this.children[0] || null;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'lastChild', {
+ get: function() {
+ return this.children[this.children.length - 1] || null;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'previousSibling', {
+ get: function() {
+ var i;
+ i = this.parent.children.indexOf(this);
+ return this.parent.children[i - 1] || null;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'nextSibling', {
+ get: function() {
+ var i;
+ i = this.parent.children.indexOf(this);
+ return this.parent.children[i + 1] || null;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
+ get: function() {
+ return this.document() || null;
+ }
+ });
+
+ // DOM level 3
+ Object.defineProperty(XMLNode.prototype, 'textContent', {
+ get: function() {
+ var child, j, len, ref1, str;
+ if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) {
+ str = '';
+ ref1 = this.children;
+ for (j = 0, len = ref1.length; j < len; j++) {
+ child = ref1[j];
+ if (child.textContent) {
+ str += child.textContent;
+ }
+ }
+ return str;
+ } else {
+ return null;
+ }
+ },
+ set: function(value) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+ });
+
+ return XMLNode;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./DocumentPosition":4,"./NodeType":5,"./Utility":6,"./XMLCData":9,"./XMLComment":11,"./XMLDeclaration":20,"./XMLDocType":21,"./XMLDummy":24,"./XMLElement":25,"./XMLNamedNodeMap":26,"./XMLNodeList":28,"./XMLProcessingInstruction":29,"./XMLRaw":30,"./XMLText":34}],28:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Represents a list of nodes
+ var XMLNodeList;
+
+ module.exports = XMLNodeList = (function() {
+ class XMLNodeList {
+ // Initializes a new instance of `XMLNodeList`
+ // This is just a wrapper around an ordinary
+ // JS array.
+
+ // `nodes` the array containing nodes.
+ constructor(nodes) {
+ this.nodes = nodes;
+ }
+
+ // Creates and returns a deep clone of `this`
+
+ clone() {
+ // this class should not be cloned since it wraps
+ // around a given array. The calling function should check
+ // whether the wrapped array is null and supply a new array
+ // (from the clone).
+ return this.nodes = null;
+ }
+
+ // DOM Level 1
+ item(index) {
+ return this.nodes[index] || null;
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLNodeList.prototype, 'length', {
+ get: function() {
+ return this.nodes.length || 0;
+ }
+ });
+
+ return XMLNodeList;
+
+ }).call(this);
+
+}).call(this);
+
+},{}],29:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLCharacterData, XMLProcessingInstruction;
+
+ NodeType = require('./NodeType');
+
+ XMLCharacterData = require('./XMLCharacterData');
+
+ // Represents a processing instruction
+ module.exports = XMLProcessingInstruction = class XMLProcessingInstruction extends XMLCharacterData {
+ // Initializes a new instance of `XMLProcessingInstruction`
+
+ // `parent` the parent node
+ // `target` instruction target
+ // `value` instruction value
+ constructor(parent, target, value) {
+ super(parent);
+ if (target == null) {
+ throw new Error("Missing instruction target. " + this.debugInfo());
+ }
+ this.type = NodeType.ProcessingInstruction;
+ this.target = this.stringify.insTarget(target);
+ this.name = this.target;
+ if (value) {
+ this.value = this.stringify.insValue(value);
+ }
+ }
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
+ }
+
+ isEqualNode(node) {
+ if (!super.isEqualNode(node)) {
+ return false;
+ }
+ if (node.target !== this.target) {
+ return false;
+ }
+ return true;
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":5,"./XMLCharacterData":10}],30:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLNode, XMLRaw;
+
+ NodeType = require('./NodeType');
+
+ XMLNode = require('./XMLNode');
+
+ // Represents a raw node
+ module.exports = XMLRaw = class XMLRaw extends XMLNode {
+ // Initializes a new instance of `XMLRaw`
+
+ // `text` raw text
+ constructor(parent, text) {
+ super(parent);
+ if (text == null) {
+ throw new Error("Missing raw text. " + this.debugInfo());
+ }
+ this.type = NodeType.Raw;
+ this.value = this.stringify.raw(text);
+ }
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.raw(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":5,"./XMLNode":27}],31:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, WriterState, XMLStreamWriter, XMLWriterBase,
+ hasProp = {}.hasOwnProperty;
+
+ NodeType = require('./NodeType');
+
+ XMLWriterBase = require('./XMLWriterBase');
+
+ WriterState = require('./WriterState');
+
+ // Prints XML nodes to a stream
+ module.exports = XMLStreamWriter = class XMLStreamWriter extends XMLWriterBase {
+ // Initializes a new instance of `XMLStreamWriter`
+
+ // `stream` output stream
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation string
+ // `options.newline` newline sequence
+ // `options.offset` a fixed number of indentations to add to every line
+ // `options.allowEmpty` do not self close empty element tags
+ // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF
+ // `options.spaceBeforeSlash` add a space before the closing slash of empty elements
+ constructor(stream, options) {
+ super(options);
+ this.stream = stream;
+ }
+
+ endline(node, options, level) {
+ if (node.isLastRootNode && options.state === WriterState.CloseTag) {
+ return '';
+ } else {
+ return super.endline(node, options, level);
+ }
+ }
+
+ document(doc, options) {
+ var child, i, j, k, len1, len2, ref, ref1, results;
+ ref = doc.children;
+ // set a flag so that we don't insert a newline after the last root level node
+ for (i = j = 0, len1 = ref.length; j < len1; i = ++j) {
+ child = ref[i];
+ child.isLastRootNode = i === doc.children.length - 1;
+ }
+ options = this.filterOptions(options);
+ ref1 = doc.children;
+ results = [];
+ for (k = 0, len2 = ref1.length; k < len2; k++) {
+ child = ref1[k];
+ results.push(this.writeChildNode(child, options, 0));
+ }
+ return results;
+ }
+
+ cdata(node, options, level) {
+ return this.stream.write(super.cdata(node, options, level));
+ }
+
+ comment(node, options, level) {
+ return this.stream.write(super.comment(node, options, level));
+ }
+
+ declaration(node, options, level) {
+ return this.stream.write(super.declaration(node, options, level));
+ }
+
+ docType(node, options, level) {
+ var child, j, len1, ref;
+ level || (level = 0);
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ this.stream.write(this.indent(node, options, level));
+ this.stream.write(' 0) {
+ this.stream.write(' [');
+ this.stream.write(this.endline(node, options, level));
+ options.state = WriterState.InsideTag;
+ ref = node.children;
+ for (j = 0, len1 = ref.length; j < len1; j++) {
+ child = ref[j];
+ this.writeChildNode(child, options, level + 1);
+ }
+ options.state = WriterState.CloseTag;
+ this.stream.write(']');
+ }
+ // close tag
+ options.state = WriterState.CloseTag;
+ this.stream.write(options.spaceBeforeSlash + '>');
+ this.stream.write(this.endline(node, options, level));
+ options.state = WriterState.None;
+ return this.closeNode(node, options, level);
+ }
+
+ element(node, options, level) {
+ var att, attLen, child, childNodeCount, firstChildNode, j, len, len1, name, prettySuppressed, r, ratt, ref, ref1, ref2, rline;
+ level || (level = 0);
+ // open tag
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '<' + node.name;
+ // attributes
+ if (options.pretty && options.width > 0) {
+ len = r.length;
+ ref = node.attribs;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ ratt = this.attribute(att, options, level);
+ attLen = ratt.length;
+ if (len + attLen > options.width) {
+ rline = this.indent(node, options, level + 1) + ratt;
+ r += this.endline(node, options, level) + rline;
+ len = rline.length;
+ } else {
+ rline = ' ' + ratt;
+ r += rline;
+ len += rline.length;
+ }
+ }
+ } else {
+ ref1 = node.attribs;
+ for (name in ref1) {
+ if (!hasProp.call(ref1, name)) continue;
+ att = ref1[name];
+ r += this.attribute(att, options, level);
+ }
+ }
+ this.stream.write(r);
+ childNodeCount = node.children.length;
+ firstChildNode = childNodeCount === 0 ? null : node.children[0];
+ if (childNodeCount === 0 || node.children.every(function(e) {
+ return (e.type === NodeType.Text || e.type === NodeType.Raw || e.type === NodeType.CData) && e.value === '';
+ })) {
+ // empty element
+ if (options.allowEmpty) {
+ this.stream.write('>');
+ options.state = WriterState.CloseTag;
+ this.stream.write('' + node.name + '>');
+ } else {
+ options.state = WriterState.CloseTag;
+ this.stream.write(options.spaceBeforeSlash + '/>');
+ }
+ } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw || firstChildNode.type === NodeType.CData) && (firstChildNode.value != null)) {
+ // do not indent text-only nodes
+ this.stream.write('>');
+ options.state = WriterState.InsideTag;
+ options.suppressPrettyCount++;
+ prettySuppressed = true;
+ this.writeChildNode(firstChildNode, options, level + 1);
+ options.suppressPrettyCount--;
+ prettySuppressed = false;
+ options.state = WriterState.CloseTag;
+ this.stream.write('' + node.name + '>');
+ } else {
+ this.stream.write('>' + this.endline(node, options, level));
+ options.state = WriterState.InsideTag;
+ ref2 = node.children;
+ // inner tags
+ for (j = 0, len1 = ref2.length; j < len1; j++) {
+ child = ref2[j];
+ this.writeChildNode(child, options, level + 1);
+ }
+ // close tag
+ options.state = WriterState.CloseTag;
+ this.stream.write(this.indent(node, options, level) + '' + node.name + '>');
+ }
+ this.stream.write(this.endline(node, options, level));
+ options.state = WriterState.None;
+ return this.closeNode(node, options, level);
+ }
+
+ processingInstruction(node, options, level) {
+ return this.stream.write(super.processingInstruction(node, options, level));
+ }
+
+ raw(node, options, level) {
+ return this.stream.write(super.raw(node, options, level));
+ }
+
+ text(node, options, level) {
+ return this.stream.write(super.text(node, options, level));
+ }
+
+ dtdAttList(node, options, level) {
+ return this.stream.write(super.dtdAttList(node, options, level));
+ }
+
+ dtdElement(node, options, level) {
+ return this.stream.write(super.dtdElement(node, options, level));
+ }
+
+ dtdEntity(node, options, level) {
+ return this.stream.write(super.dtdEntity(node, options, level));
+ }
+
+ dtdNotation(node, options, level) {
+ return this.stream.write(super.dtdNotation(node, options, level));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":5,"./WriterState":7,"./XMLWriterBase":35}],32:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var XMLStringWriter, XMLWriterBase;
+
+ XMLWriterBase = require('./XMLWriterBase');
+
+ // Prints XML nodes as plain text
+ module.exports = XMLStringWriter = class XMLStringWriter extends XMLWriterBase {
+ // Initializes a new instance of `XMLStringWriter`
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation string
+ // `options.newline` newline sequence
+ // `options.offset` a fixed number of indentations to add to every line
+ // `options.allowEmpty` do not self close empty element tags
+ // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF
+ // `options.spaceBeforeSlash` add a space before the closing slash of empty elements
+ constructor(options) {
+ super(options);
+ }
+
+ document(doc, options) {
+ var child, i, len, r, ref;
+ options = this.filterOptions(options);
+ r = '';
+ ref = doc.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ r += this.writeChildNode(child, options, 0);
+ }
+ // remove trailing newline
+ if (options.pretty && r.slice(-options.newline.length) === options.newline) {
+ r = r.slice(0, -options.newline.length);
+ }
+ return r;
+ }
+
+ };
+
+}).call(this);
+
+},{"./XMLWriterBase":35}],33:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Converts values to strings
+ var XMLStringifier,
+ hasProp = {}.hasOwnProperty;
+
+ module.exports = XMLStringifier = (function() {
+ class XMLStringifier {
+ // Initializes a new instance of `XMLStringifier`
+
+ // `options.version` The version number string of the XML spec to validate against, e.g. 1.0
+ // `options.noDoubleEncoding` whether existing html entities are encoded: true or false
+ // `options.stringify` a set of functions to use for converting values to strings
+ // `options.noValidation` whether values will be validated and escaped or returned as is
+ // `options.invalidCharReplacement` a character to replace invalid characters and disable character validation
+ constructor(options) {
+ var key, ref, value;
+ // Checks whether the given string contains legal characters
+ // Fails with an exception on error
+
+ // `str` the string to check
+ this.assertLegalChar = this.assertLegalChar.bind(this);
+ // Checks whether the given string contains legal characters for a name
+ // Fails with an exception on error
+
+ // `str` the string to check
+ this.assertLegalName = this.assertLegalName.bind(this);
+ options || (options = {});
+ this.options = options;
+ if (!this.options.version) {
+ this.options.version = '1.0';
+ }
+ ref = options.stringify || {};
+ for (key in ref) {
+ if (!hasProp.call(ref, key)) continue;
+ value = ref[key];
+ this[key] = value;
+ }
+ }
+
+ // Defaults
+ name(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalName('' + val || '');
+ }
+
+ text(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar(this.textEscape('' + val || ''));
+ }
+
+ cdata(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ val = '' + val || '';
+ val = val.replace(']]>', ']]]]>');
+ return this.assertLegalChar(val);
+ }
+
+ comment(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ val = '' + val || '';
+ if (val.match(/--/)) {
+ throw new Error("Comment text cannot contain double-hypen: " + val);
+ }
+ return this.assertLegalChar(val);
+ }
+
+ raw(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return '' + val || '';
+ }
+
+ attValue(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar(this.attEscape(val = '' + val || ''));
+ }
+
+ insTarget(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ insValue(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ val = '' + val || '';
+ if (val.match(/\?>/)) {
+ throw new Error("Invalid processing instruction value: " + val);
+ }
+ return this.assertLegalChar(val);
+ }
+
+ xmlVersion(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ val = '' + val || '';
+ if (!val.match(/1\.[0-9]+/)) {
+ throw new Error("Invalid version number: " + val);
+ }
+ return val;
+ }
+
+ xmlEncoding(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ val = '' + val || '';
+ if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
+ throw new Error("Invalid encoding: " + val);
+ }
+ return this.assertLegalChar(val);
+ }
+
+ xmlStandalone(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ if (val) {
+ return "yes";
+ } else {
+ return "no";
+ }
+ }
+
+ dtdPubID(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ dtdSysID(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ dtdElementValue(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ dtdAttType(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ dtdAttDefault(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ dtdEntityValue(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ dtdNData(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ assertLegalChar(str) {
+ var regex, res;
+ if (this.options.noValidation) {
+ return str;
+ }
+ if (this.options.version === '1.0') {
+ // Valid characters from https://www.w3.org/TR/xml/#charsets
+ // any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
+ // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ // This ES5 compatible Regexp has been generated using the "regenerate" NPM module:
+ // let xml_10_InvalidChars = regenerate()
+ // .addRange(0x0000, 0x0008)
+ // .add(0x000B, 0x000C)
+ // .addRange(0x000E, 0x001F)
+ // .addRange(0xD800, 0xDFFF)
+ // .addRange(0xFFFE, 0xFFFF)
+ regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
+ if (this.options.invalidCharReplacement !== void 0) {
+ str = str.replace(regex, this.options.invalidCharReplacement);
+ } else if (res = str.match(regex)) {
+ throw new Error(`Invalid character in string: ${str} at index ${res.index}`);
+ }
+ } else if (this.options.version === '1.1') {
+ // Valid characters from https://www.w3.org/TR/xml11/#charsets
+ // any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
+ // [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ // This ES5 compatible Regexp has been generated using the "regenerate" NPM module:
+ // let xml_11_InvalidChars = regenerate()
+ // .add(0x0000)
+ // .addRange(0xD800, 0xDFFF)
+ // .addRange(0xFFFE, 0xFFFF)
+ regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
+ if (this.options.invalidCharReplacement !== void 0) {
+ str = str.replace(regex, this.options.invalidCharReplacement);
+ } else if (res = str.match(regex)) {
+ throw new Error(`Invalid character in string: ${str} at index ${res.index}`);
+ }
+ }
+ return str;
+ }
+
+ assertLegalName(str) {
+ var regex;
+ if (this.options.noValidation) {
+ return str;
+ }
+ str = this.assertLegalChar(str);
+ regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/;
+ if (!str.match(regex)) {
+ throw new Error(`Invalid character in name: ${str}`);
+ }
+ return str;
+ }
+
+ // Escapes special characters in text
+
+ // See http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping
+
+ // `str` the string to escape
+ textEscape(str) {
+ var ampregex;
+ if (this.options.noValidation) {
+ return str;
+ }
+ ampregex = this.options.noDoubleEncoding ? /(?!&(lt|gt|amp|apos|quot);)&/g : /&/g;
+ return str.replace(ampregex, '&').replace(//g, '>').replace(/\r/g, '
');
+ }
+
+ // Escapes special characters in attribute values
+
+ // See http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping
+
+ // `str` the string to escape
+ attEscape(str) {
+ var ampregex;
+ if (this.options.noValidation) {
+ return str;
+ }
+ ampregex = this.options.noDoubleEncoding ? /(?!&(lt|gt|amp|apos|quot);)&/g : /&/g;
+ return str.replace(ampregex, '&').replace(/ 0) {
+ return new Array(indentLevel).join(options.indent);
+ }
+ }
+ return '';
+ }
+
+ // Returns the newline string
+
+ // `node` current node
+ // `options` writer options
+ // `level` current indentation level
+ endline(node, options, level) {
+ if (!options.pretty || options.suppressPrettyCount) {
+ return '';
+ } else {
+ return options.newline;
+ }
+ }
+
+ attribute(att, options, level) {
+ var r;
+ this.openAttribute(att, options, level);
+ if (options.pretty && options.width > 0) {
+ r = att.name + '="' + att.value + '"';
+ } else {
+ r = ' ' + att.name + '="' + att.value + '"';
+ }
+ this.closeAttribute(att, options, level);
+ return r;
+ }
+
+ cdata(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '' + this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ comment(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '' + this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ declaration(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '';
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ docType(node, options, level) {
+ var child, i, len1, r, ref;
+ level || (level = 0);
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level);
+ r += ' 0) {
+ r += ' [';
+ r += this.endline(node, options, level);
+ options.state = WriterState.InsideTag;
+ ref = node.children;
+ for (i = 0, len1 = ref.length; i < len1; i++) {
+ child = ref[i];
+ r += this.writeChildNode(child, options, level + 1);
+ }
+ options.state = WriterState.CloseTag;
+ r += ']';
+ }
+ // close tag
+ options.state = WriterState.CloseTag;
+ r += options.spaceBeforeSlash + '>';
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ element(node, options, level) {
+ var att, attLen, child, childNodeCount, firstChildNode, i, j, len, len1, len2, name, prettySuppressed, r, ratt, ref, ref1, ref2, ref3, rline;
+ level || (level = 0);
+ prettySuppressed = false;
+ // open tag
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '<' + node.name;
+ // attributes
+ if (options.pretty && options.width > 0) {
+ len = r.length;
+ ref = node.attribs;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ ratt = this.attribute(att, options, level);
+ attLen = ratt.length;
+ if (len + attLen > options.width) {
+ rline = this.indent(node, options, level + 1) + ratt;
+ r += this.endline(node, options, level) + rline;
+ len = rline.length;
+ } else {
+ rline = ' ' + ratt;
+ r += rline;
+ len += rline.length;
+ }
+ }
+ } else {
+ ref1 = node.attribs;
+ for (name in ref1) {
+ if (!hasProp.call(ref1, name)) continue;
+ att = ref1[name];
+ r += this.attribute(att, options, level);
+ }
+ }
+ childNodeCount = node.children.length;
+ firstChildNode = childNodeCount === 0 ? null : node.children[0];
+ if (childNodeCount === 0 || node.children.every(function(e) {
+ return (e.type === NodeType.Text || e.type === NodeType.Raw || e.type === NodeType.CData) && e.value === '';
+ })) {
+ // empty element
+ if (options.allowEmpty) {
+ r += '>';
+ options.state = WriterState.CloseTag;
+ r += '' + node.name + '>' + this.endline(node, options, level);
+ } else {
+ options.state = WriterState.CloseTag;
+ r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
+ }
+ } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw || firstChildNode.type === NodeType.CData) && (firstChildNode.value != null)) {
+ // do not indent text-only nodes
+ r += '>';
+ options.state = WriterState.InsideTag;
+ options.suppressPrettyCount++;
+ prettySuppressed = true;
+ r += this.writeChildNode(firstChildNode, options, level + 1);
+ options.suppressPrettyCount--;
+ prettySuppressed = false;
+ options.state = WriterState.CloseTag;
+ r += '' + node.name + '>' + this.endline(node, options, level);
+ } else {
+ // if ANY are a text node, then suppress pretty now
+ if (options.dontPrettyTextNodes) {
+ ref2 = node.children;
+ for (i = 0, len1 = ref2.length; i < len1; i++) {
+ child = ref2[i];
+ if ((child.type === NodeType.Text || child.type === NodeType.Raw || child.type === NodeType.CData) && (child.value != null)) {
+ options.suppressPrettyCount++;
+ prettySuppressed = true;
+ break;
+ }
+ }
+ }
+ // close the opening tag, after dealing with newline
+ r += '>' + this.endline(node, options, level);
+ options.state = WriterState.InsideTag;
+ ref3 = node.children;
+ // inner tags
+ for (j = 0, len2 = ref3.length; j < len2; j++) {
+ child = ref3[j];
+ r += this.writeChildNode(child, options, level + 1);
+ }
+ // close tag
+ options.state = WriterState.CloseTag;
+ r += this.indent(node, options, level) + '' + node.name + '>';
+ if (prettySuppressed) {
+ options.suppressPrettyCount--;
+ }
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ }
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ writeChildNode(node, options, level) {
+ switch (node.type) {
+ case NodeType.CData:
+ return this.cdata(node, options, level);
+ case NodeType.Comment:
+ return this.comment(node, options, level);
+ case NodeType.Element:
+ return this.element(node, options, level);
+ case NodeType.Raw:
+ return this.raw(node, options, level);
+ case NodeType.Text:
+ return this.text(node, options, level);
+ case NodeType.ProcessingInstruction:
+ return this.processingInstruction(node, options, level);
+ case NodeType.Dummy:
+ return '';
+ case NodeType.Declaration:
+ return this.declaration(node, options, level);
+ case NodeType.DocType:
+ return this.docType(node, options, level);
+ case NodeType.AttributeDeclaration:
+ return this.dtdAttList(node, options, level);
+ case NodeType.ElementDeclaration:
+ return this.dtdElement(node, options, level);
+ case NodeType.EntityDeclaration:
+ return this.dtdEntity(node, options, level);
+ case NodeType.NotationDeclaration:
+ return this.dtdNotation(node, options, level);
+ default:
+ throw new Error("Unknown XML node type: " + node.constructor.name);
+ }
+ }
+
+ processingInstruction(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '';
+ options.state = WriterState.InsideTag;
+ r += node.target;
+ if (node.value) {
+ r += ' ' + node.value;
+ }
+ options.state = WriterState.CloseTag;
+ r += options.spaceBeforeSlash + '?>';
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ raw(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level);
+ options.state = WriterState.InsideTag;
+ r += node.value;
+ options.state = WriterState.CloseTag;
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ text(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level);
+ options.state = WriterState.InsideTag;
+ r += node.value;
+ options.state = WriterState.CloseTag;
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ dtdAttList(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '' + this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ dtdElement(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '' + this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ dtdEntity(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '' + this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ dtdNotation(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '' + this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ openNode(node, options, level) {}
+
+ closeNode(node, options, level) {}
+
+ openAttribute(att, options, level) {}
+
+ closeAttribute(att, options, level) {}
+
+ };
+
+}).call(this);
+
+},{"./NodeType":5,"./Utility":6,"./WriterState":7,"./XMLCData":9,"./XMLComment":11,"./XMLDTDAttList":16,"./XMLDTDElement":17,"./XMLDTDEntity":18,"./XMLDTDNotation":19,"./XMLDeclaration":20,"./XMLDocType":21,"./XMLDummy":24,"./XMLElement":25,"./XMLProcessingInstruction":29,"./XMLRaw":30,"./XMLText":34}],36:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction;
+
+ ({assign, isFunction} = require('./Utility'));
+
+ XMLDOMImplementation = require('./XMLDOMImplementation');
+
+ XMLDocument = require('./XMLDocument');
+
+ XMLDocumentCB = require('./XMLDocumentCB');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ XMLStreamWriter = require('./XMLStreamWriter');
+
+ NodeType = require('./NodeType');
+
+ WriterState = require('./WriterState');
+
+ // Creates a new document and returns the root node for
+ // chain-building the document tree
+
+ // `name` name of the root element
+
+ // `xmldec.version` A version number string, e.g. 1.0
+ // `xmldec.encoding` Encoding declaration, e.g. UTF-8
+ // `xmldec.standalone` standalone document declaration: true or false
+
+ // `doctype.pubID` public identifier of the external subset
+ // `doctype.sysID` system identifier of the external subset
+
+ // `options.headless` whether XML declaration and doctype will be included:
+ // true or false
+ // `options.keepNullNodes` whether nodes with null values will be kept
+ // or ignored: true or false
+ // `options.keepNullAttributes` whether attributes with null values will be
+ // kept or ignored: true or false
+ // `options.ignoreDecorators` whether decorator strings will be ignored when
+ // converting JS objects: true or false
+ // `options.separateArrayItems` whether array items are created as separate
+ // nodes when passed as an object value: true or false
+ // `options.noDoubleEncoding` whether existing html entities are encoded:
+ // true or false
+ // `options.stringify` a set of functions to use for converting values to
+ // strings
+ // `options.writer` the default XML writer to use for converting nodes to
+ // string. If the default writer is not set, the built-in XMLStringWriter
+ // will be used instead.
+ module.exports.create = function(name, xmldec, doctype, options) {
+ var doc, root;
+ if (name == null) {
+ throw new Error("Root element needs a name.");
+ }
+ options = assign({}, xmldec, doctype, options);
+ // create the document node
+ doc = new XMLDocument(options);
+ // add the root node
+ root = doc.element(name);
+ // prolog
+ if (!options.headless) {
+ doc.declaration(options);
+ if ((options.pubID != null) || (options.sysID != null)) {
+ doc.dtd(options);
+ }
+ }
+ return root;
+ };
+
+ // Creates a new document and returns the document node for
+ // chain-building the document tree
+
+ // `options.keepNullNodes` whether nodes with null values will be kept
+ // or ignored: true or false
+ // `options.keepNullAttributes` whether attributes with null values will be
+ // kept or ignored: true or false
+ // `options.ignoreDecorators` whether decorator strings will be ignored when
+ // converting JS objects: true or false
+ // `options.separateArrayItems` whether array items are created as separate
+ // nodes when passed as an object value: true or false
+ // `options.noDoubleEncoding` whether existing html entities are encoded:
+ // true or false
+ // `options.stringify` a set of functions to use for converting values to
+ // strings
+ // `options.writer` the default XML writer to use for converting nodes to
+ // string. If the default writer is not set, the built-in XMLStringWriter
+ // will be used instead.
+
+ // `onData` the function to be called when a new chunk of XML is output. The
+ // string containing the XML chunk is passed to `onData` as its single
+ // argument.
+ // `onEnd` the function to be called when the XML document is completed with
+ // `end`. `onEnd` does not receive any arguments.
+ module.exports.begin = function(options, onData, onEnd) {
+ if (isFunction(options)) {
+ [onData, onEnd] = [options, onData];
+ options = {};
+ }
+ if (onData) {
+ return new XMLDocumentCB(options, onData, onEnd);
+ } else {
+ return new XMLDocument(options);
+ }
+ };
+
+ module.exports.stringWriter = function(options) {
+ return new XMLStringWriter(options);
+ };
+
+ module.exports.streamWriter = function(stream, options) {
+ return new XMLStreamWriter(stream, options);
+ };
+
+ module.exports.implementation = new XMLDOMImplementation();
+
+ module.exports.nodeType = NodeType;
+
+ module.exports.writerState = WriterState;
+
+}).call(this);
+
+},{"./NodeType":5,"./Utility":6,"./WriterState":7,"./XMLDOMImplementation":14,"./XMLDocument":22,"./XMLDocumentCB":23,"./XMLStreamWriter":31,"./XMLStringWriter":32}]},{},[1])(1)
+});
diff --git a/node_modules/plist/dist/plist-parse.js b/node_modules/plist/dist/plist-parse.js
new file mode 100644
index 0000000..6b3e472
--- /dev/null
+++ b/node_modules/plist/dist/plist-parse.js
@@ -0,0 +1,10709 @@
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i,
+ * and raw CDATA nodes.
+ *
+ * @param {Element} node
+ * @returns {Boolean}
+ * @api private
+ */
+
+function shouldIgnoreNode(node) {
+ return (
+ node.nodeType === TEXT_NODE ||
+ node.nodeType === COMMENT_NODE ||
+ node.nodeType === CDATA_NODE
+ );
+}
+
+/**
+ * Check if the node is empty. Some plist file has such node:
+ *
+ * this node shoud be ignored.
+ *
+ * @see https://github.com/TooTallNate/plist.js/issues/66
+ * @param {Element} node
+ * @returns {Boolean}
+ * @api private
+ */
+function isEmptyNode(node) {
+ if (!node.childNodes || node.childNodes.length === 0) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function invariant(test, message) {
+ if (!test) {
+ throw new Error(message);
+ }
+}
+
+/**
+ * Parses a Plist XML string. Returns an Object.
+ *
+ * @param {String} xml - the XML String to decode
+ * @returns {Mixed} the decoded value from the Plist XML
+ * @api public
+ */
+
+function parse(xml) {
+ var doc = new DOMParser().parseFromString(xml, "text/xml");
+ invariant(
+ doc.documentElement.nodeName === "plist",
+ "malformed document. First element should be ",
+ );
+ var plist = parsePlistXML(doc.documentElement);
+
+ // the root node gets interpreted as an Array,
+ // so pull out the inner data first
+ if (plist.length == 1) plist = plist[0];
+
+ return plist;
+}
+
+/**
+ * Convert an XML based plist document into a JSON representation.
+ *
+ * @param {Object} xml_node - current XML node in the plist
+ * @returns {Mixed} built up JSON object
+ * @api private
+ */
+
+function parsePlistXML(node) {
+ var i, new_obj, key, val, new_arr, res, counter, type;
+
+ if (!node) return null;
+
+ if (node.nodeName === "plist") {
+ new_arr = [];
+ if (isEmptyNode(node)) {
+ return new_arr;
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (!shouldIgnoreNode(node.childNodes[i])) {
+ new_arr.push(parsePlistXML(node.childNodes[i]));
+ }
+ }
+ return new_arr;
+ } else if (node.nodeName === "dict") {
+ new_obj = {};
+ key = null;
+ counter = 0;
+ if (isEmptyNode(node)) {
+ return new_obj;
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (shouldIgnoreNode(node.childNodes[i])) continue;
+ if (counter % 2 === 0) {
+ invariant(
+ node.childNodes[i].nodeName === "key",
+ "Missing key while parsing .",
+ );
+ key = parsePlistXML(node.childNodes[i]);
+ } else {
+ invariant(
+ node.childNodes[i].nodeName !== "key",
+ 'Unexpected key "' +
+ parsePlistXML(node.childNodes[i]) +
+ '" while parsing .',
+ );
+ new_obj[key] = parsePlistXML(node.childNodes[i]);
+ }
+ counter += 1;
+ }
+ if (counter % 2 === 1) {
+ new_obj[key] = "";
+ }
+
+ return new_obj;
+ } else if (node.nodeName === "array") {
+ new_arr = [];
+ if (isEmptyNode(node)) {
+ return new_arr;
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (!shouldIgnoreNode(node.childNodes[i])) {
+ res = parsePlistXML(node.childNodes[i]);
+ if (null != res) new_arr.push(res);
+ }
+ }
+ return new_arr;
+ } else if (node.nodeName === "#text") {
+ // TODO: what should we do with text types? (CDATA sections)
+ } else if (node.nodeName === "key") {
+ if (isEmptyNode(node)) {
+ return "";
+ }
+
+ invariant(
+ node.childNodes[0].nodeValue !== "__proto__",
+ "__proto__ keys can lead to prototype pollution. More details on CVE-2022-22912",
+ );
+
+ return node.childNodes[0].nodeValue;
+ } else if (node.nodeName === "string") {
+ res = "";
+ if (isEmptyNode(node)) {
+ return res;
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ var type = node.childNodes[i].nodeType;
+ if (type === TEXT_NODE || type === CDATA_NODE) {
+ res += node.childNodes[i].nodeValue;
+ }
+ }
+ return res;
+ } else if (node.nodeName === "integer") {
+ invariant(!isEmptyNode(node), 'Cannot parse "" as integer.');
+ return parseInt(node.childNodes[0].nodeValue, 10);
+ } else if (node.nodeName === "real") {
+ invariant(!isEmptyNode(node), 'Cannot parse "" as real.');
+ res = "";
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (node.childNodes[i].nodeType === TEXT_NODE) {
+ res += node.childNodes[i].nodeValue;
+ }
+ }
+ return parseFloat(res);
+ } else if (node.nodeName === "data") {
+ res = "";
+ if (isEmptyNode(node)) {
+ return Buffer.from(res, "base64");
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (node.childNodes[i].nodeType === TEXT_NODE) {
+ res += node.childNodes[i].nodeValue.replace(/\s+/g, "");
+ }
+ }
+ return Buffer.from(res, "base64");
+ } else if (node.nodeName === "date") {
+ invariant(!isEmptyNode(node), 'Cannot parse "" as Date.');
+ return new Date(node.childNodes[0].nodeValue);
+ } else if (node.nodeName === "null") {
+ return null;
+ } else if (node.nodeName === "true") {
+ return true;
+ } else if (node.nodeName === "false") {
+ return false;
+ } else {
+ throw new Error("Invalid PLIST tag " + node.nodeName);
+ }
+}
+
+}).call(this)}).call(this,require("buffer").Buffer)
+},{"@xmldom/xmldom":8,"buffer":11}],2:[function(require,module,exports){
+'use strict';
+
+/**
+ * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.
+ *
+ * Works with anything that has a `length` property and index access properties,
+ * including NodeList.
+ *
+ * @param {T[] | { length: number; [number]: T }} list
+ * @param {function (item: T, index: number, list:T[]):boolean} predicate
+ * @param {Partial>?} ac
+ * Allows injecting a custom implementation in tests (`Array.prototype` by default).
+ * @returns {T | undefined}
+ * @template {unknown} T
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
+ * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find
+ */
+function find(list, predicate, ac) {
+ if (ac === undefined) {
+ ac = Array.prototype;
+ }
+ if (list && typeof ac.find === 'function') {
+ return ac.find.call(list, predicate);
+ }
+ for (var i = 0; i < list.length; i++) {
+ if (hasOwn(list, i)) {
+ var item = list[i];
+ if (predicate.call(undefined, item, i, list)) {
+ return item;
+ }
+ }
+ }
+}
+
+/**
+ * "Shallow freezes" an object to render it immutable.
+ * Uses `Object.freeze` if available,
+ * otherwise the immutability is only in the type.
+ *
+ * Is used to create "enum like" objects.
+ *
+ * If `Object.getOwnPropertyDescriptors` is available,
+ * a new object with all properties of object but without any prototype is created and returned
+ * after freezing it.
+ *
+ * @param {T} object
+ * The object to freeze.
+ * @param {Pick} [oc=Object]
+ * `Object` by default,
+ * allows to inject custom object constructor for tests.
+ * @returns {Readonly}
+ * @template {Object} T
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
+ * @prettierignore
+ */
+function freeze(object, oc) {
+ if (oc === undefined) {
+ oc = Object;
+ }
+ if (oc && typeof oc.getOwnPropertyDescriptors === 'function') {
+ object = oc.create(null, oc.getOwnPropertyDescriptors(object));
+ }
+ return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object;
+}
+
+/**
+ * Implementation for `Object.hasOwn` but ES5 compatible.
+ *
+ * @param {any} object
+ * @param {string | number} key
+ * @returns {boolean}
+ */
+function hasOwn(object, key) {
+ return Object.prototype.hasOwnProperty.call(object, key);
+}
+
+/**
+ * Since xmldom can not rely on `Object.assign`,
+ * it uses/provides a simplified version that is sufficient for its needs.
+ *
+ * @param {Object} target
+ * @param {Object | null | undefined} source
+ * @returns {Object}
+ * The target with the merged/overridden properties.
+ * @throws {TypeError}
+ * If target is not an object.
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
+ * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign
+ */
+function assign(target, source) {
+ if (target === null || typeof target !== 'object') {
+ throw new TypeError('target is not an object');
+ }
+ for (var key in source) {
+ if (hasOwn(source, key)) {
+ target[key] = source[key];
+ }
+ }
+ return target;
+}
+
+/**
+ * A number of attributes are boolean attributes.
+ * The presence of a boolean attribute on an element represents the `true` value,
+ * and the absence of the attribute represents the `false` value.
+ *
+ * If the attribute is present, its value must either be the empty string, or a value that is
+ * an ASCII case-insensitive match for the attribute's canonical name,
+ * with no leading or trailing whitespace.
+ *
+ * Note: The values `"true"` and `"false"` are not allowed on boolean attributes.
+ * To represent a `false` value, the attribute has to be omitted altogether.
+ *
+ * @see https://html.spec.whatwg.org/#boolean-attributes
+ * @see https://html.spec.whatwg.org/#attributes-3
+ */
+var HTML_BOOLEAN_ATTRIBUTES = freeze({
+ allowfullscreen: true,
+ async: true,
+ autofocus: true,
+ autoplay: true,
+ checked: true,
+ controls: true,
+ default: true,
+ defer: true,
+ disabled: true,
+ formnovalidate: true,
+ hidden: true,
+ ismap: true,
+ itemscope: true,
+ loop: true,
+ multiple: true,
+ muted: true,
+ nomodule: true,
+ novalidate: true,
+ open: true,
+ playsinline: true,
+ readonly: true,
+ required: true,
+ reversed: true,
+ selected: true,
+});
+
+/**
+ * Check if `name` is matching one of the HTML boolean attribute names.
+ * This method doesn't check if such attributes are allowed in the context of the current
+ * document/parsing.
+ *
+ * @param {string} name
+ * @returns {boolean}
+ * @see {@link HTML_BOOLEAN_ATTRIBUTES}
+ * @see https://html.spec.whatwg.org/#boolean-attributes
+ * @see https://html.spec.whatwg.org/#attributes-3
+ */
+function isHTMLBooleanAttribute(name) {
+ return hasOwn(HTML_BOOLEAN_ATTRIBUTES, name.toLowerCase());
+}
+
+/**
+ * Void elements only have a start tag; end tags must not be specified for void elements.
+ * These elements should be written as self-closing like this: ` `.
+ * This should not be confused with optional tags that HTML allows to omit the end tag for
+ * (like `li`, `tr` and others), which can have content after them,
+ * so they can not be written as self-closing.
+ * xmldom does not have any logic for optional end tags cases,
+ * and will report them as a warning.
+ * Content that would go into the unopened element,
+ * will instead be added as a sibling text node.
+ *
+ * @type {Readonly<{
+ * area: boolean;
+ * col: boolean;
+ * img: boolean;
+ * wbr: boolean;
+ * link: boolean;
+ * hr: boolean;
+ * source: boolean;
+ * br: boolean;
+ * input: boolean;
+ * param: boolean;
+ * meta: boolean;
+ * embed: boolean;
+ * track: boolean;
+ * base: boolean;
+ * }>}
+ * @see https://html.spec.whatwg.org/#void-elements
+ * @see https://html.spec.whatwg.org/#optional-tags
+ */
+var HTML_VOID_ELEMENTS = freeze({
+ area: true,
+ base: true,
+ br: true,
+ col: true,
+ embed: true,
+ hr: true,
+ img: true,
+ input: true,
+ link: true,
+ meta: true,
+ param: true,
+ source: true,
+ track: true,
+ wbr: true,
+});
+
+/**
+ * Check if `tagName` is matching one of the HTML void element names.
+ * This method doesn't check if such tags are allowed in the context of the current
+ * document/parsing.
+ *
+ * @param {string} tagName
+ * @returns {boolean}
+ * @see {@link HTML_VOID_ELEMENTS}
+ * @see https://html.spec.whatwg.org/#void-elements
+ */
+function isHTMLVoidElement(tagName) {
+ return hasOwn(HTML_VOID_ELEMENTS, tagName.toLowerCase());
+}
+
+/**
+ * Tag names that are raw text elements according to HTML spec.
+ * The value denotes whether they are escapable or not.
+ *
+ * @see {@link isHTMLEscapableRawTextElement}
+ * @see {@link isHTMLRawTextElement}
+ * @see https://html.spec.whatwg.org/#raw-text-elements
+ * @see https://html.spec.whatwg.org/#escapable-raw-text-elements
+ */
+var HTML_RAW_TEXT_ELEMENTS = freeze({
+ script: false,
+ style: false,
+ textarea: true,
+ title: true,
+});
+
+/**
+ * Check if `tagName` is matching one of the HTML raw text element names.
+ * This method doesn't check if such tags are allowed in the context of the current
+ * document/parsing.
+ *
+ * @param {string} tagName
+ * @returns {boolean}
+ * @see {@link isHTMLEscapableRawTextElement}
+ * @see {@link HTML_RAW_TEXT_ELEMENTS}
+ * @see https://html.spec.whatwg.org/#raw-text-elements
+ * @see https://html.spec.whatwg.org/#escapable-raw-text-elements
+ */
+function isHTMLRawTextElement(tagName) {
+ var key = tagName.toLowerCase();
+ return hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && !HTML_RAW_TEXT_ELEMENTS[key];
+}
+/**
+ * Check if `tagName` is matching one of the HTML escapable raw text element names.
+ * This method doesn't check if such tags are allowed in the context of the current
+ * document/parsing.
+ *
+ * @param {string} tagName
+ * @returns {boolean}
+ * @see {@link isHTMLRawTextElement}
+ * @see {@link HTML_RAW_TEXT_ELEMENTS}
+ * @see https://html.spec.whatwg.org/#raw-text-elements
+ * @see https://html.spec.whatwg.org/#escapable-raw-text-elements
+ */
+function isHTMLEscapableRawTextElement(tagName) {
+ var key = tagName.toLowerCase();
+ return hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && HTML_RAW_TEXT_ELEMENTS[key];
+}
+/**
+ * Only returns true if `value` matches MIME_TYPE.HTML, which indicates an HTML document.
+ *
+ * @param {string} mimeType
+ * @returns {mimeType is 'text/html'}
+ * @see https://www.iana.org/assignments/media-types/text/html
+ * @see https://en.wikipedia.org/wiki/HTML
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
+ */
+function isHTMLMimeType(mimeType) {
+ return mimeType === MIME_TYPE.HTML;
+}
+/**
+ * For both the `text/html` and the `application/xhtml+xml` namespace the spec defines that the
+ * HTML namespace is provided as the default.
+ *
+ * @param {string} mimeType
+ * @returns {boolean}
+ * @see https://dom.spec.whatwg.org/#dom-document-createelement
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
+ */
+function hasDefaultHTMLNamespace(mimeType) {
+ return isHTMLMimeType(mimeType) || mimeType === MIME_TYPE.XML_XHTML_APPLICATION;
+}
+
+/**
+ * All mime types that are allowed as input to `DOMParser.parseFromString`
+ *
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
+ * MDN
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype
+ * WHATWG HTML Spec
+ * @see {@link DOMParser.prototype.parseFromString}
+ */
+var MIME_TYPE = freeze({
+ /**
+ * `text/html`, the only mime type that triggers treating an XML document as HTML.
+ *
+ * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
+ * @see https://en.wikipedia.org/wiki/HTML Wikipedia
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
+ * WHATWG HTML Spec
+ */
+ HTML: 'text/html',
+
+ /**
+ * `application/xml`, the standard mime type for XML documents.
+ *
+ * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType
+ * registration
+ * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
+ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
+ */
+ XML_APPLICATION: 'application/xml',
+
+ /**
+ * `text/xml`, an alias for `application/xml`.
+ *
+ * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
+ * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
+ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
+ */
+ XML_TEXT: 'text/xml',
+
+ /**
+ * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
+ * but is parsed as an XML document.
+ *
+ * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType
+ * registration
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
+ * @see https://en.wikipedia.org/wiki/XHTML Wikipedia
+ */
+ XML_XHTML_APPLICATION: 'application/xhtml+xml',
+
+ /**
+ * `image/svg+xml`,
+ *
+ * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
+ * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
+ * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
+ */
+ XML_SVG_IMAGE: 'image/svg+xml',
+});
+/**
+ * @typedef {'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}
+ * MimeType
+ */
+/**
+ * @type {MimeType[]}
+ * @private
+ * Basically `Object.values`, which is not available in ES5.
+ */
+var _MIME_TYPES = Object.keys(MIME_TYPE).map(function (key) {
+ return MIME_TYPE[key];
+});
+
+/**
+ * Only returns true if `mimeType` is one of the allowed values for
+ * `DOMParser.parseFromString`.
+ *
+ * @param {string} mimeType
+ * @returns {mimeType is 'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}
+ *
+ */
+function isValidMimeType(mimeType) {
+ return _MIME_TYPES.indexOf(mimeType) > -1;
+}
+/**
+ * Namespaces that are used in this code base.
+ *
+ * @see http://www.w3.org/TR/REC-xml-names
+ */
+var NAMESPACE = freeze({
+ /**
+ * The XHTML namespace.
+ *
+ * @see http://www.w3.org/1999/xhtml
+ */
+ HTML: 'http://www.w3.org/1999/xhtml',
+
+ /**
+ * The SVG namespace.
+ *
+ * @see http://www.w3.org/2000/svg
+ */
+ SVG: 'http://www.w3.org/2000/svg',
+
+ /**
+ * The `xml:` namespace.
+ *
+ * @see http://www.w3.org/XML/1998/namespace
+ */
+ XML: 'http://www.w3.org/XML/1998/namespace',
+
+ /**
+ * The `xmlns:` namespace.
+ *
+ * @see https://www.w3.org/2000/xmlns/
+ */
+ XMLNS: 'http://www.w3.org/2000/xmlns/',
+});
+
+exports.assign = assign;
+exports.find = find;
+exports.freeze = freeze;
+exports.HTML_BOOLEAN_ATTRIBUTES = HTML_BOOLEAN_ATTRIBUTES;
+exports.HTML_RAW_TEXT_ELEMENTS = HTML_RAW_TEXT_ELEMENTS;
+exports.HTML_VOID_ELEMENTS = HTML_VOID_ELEMENTS;
+exports.hasDefaultHTMLNamespace = hasDefaultHTMLNamespace;
+exports.hasOwn = hasOwn;
+exports.isHTMLBooleanAttribute = isHTMLBooleanAttribute;
+exports.isHTMLRawTextElement = isHTMLRawTextElement;
+exports.isHTMLEscapableRawTextElement = isHTMLEscapableRawTextElement;
+exports.isHTMLMimeType = isHTMLMimeType;
+exports.isHTMLVoidElement = isHTMLVoidElement;
+exports.isValidMimeType = isValidMimeType;
+exports.MIME_TYPE = MIME_TYPE;
+exports.NAMESPACE = NAMESPACE;
+
+},{}],3:[function(require,module,exports){
+'use strict';
+
+var conventions = require('./conventions');
+var dom = require('./dom');
+var errors = require('./errors');
+var entities = require('./entities');
+var sax = require('./sax');
+
+var DOMImplementation = dom.DOMImplementation;
+
+var hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;
+var isHTMLMimeType = conventions.isHTMLMimeType;
+var isValidMimeType = conventions.isValidMimeType;
+var MIME_TYPE = conventions.MIME_TYPE;
+var NAMESPACE = conventions.NAMESPACE;
+var ParseError = errors.ParseError;
+
+var XMLReader = sax.XMLReader;
+
+/**
+ * Normalizes line ending according to ,
+ * including some Unicode "newline" characters:
+ *
+ * > XML parsed entities are often stored in computer files which,
+ * > for editing convenience, are organized into lines.
+ * > These lines are typically separated by some combination
+ * > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).
+ * >
+ * > To simplify the tasks of applications, the XML processor must behave
+ * > as if it normalized all line breaks in external parsed entities (including the document entity)
+ * > on input, before parsing, by translating the following to a single #xA character:
+ * >
+ * > 1. the two-character sequence #xD #xA,
+ * > 2. the two-character sequence #xD #x85,
+ * > 3. the single character #x85,
+ * > 4. the single character #x2028,
+ * > 5. the single character #x2029,
+ * > 6. any #xD character that is not immediately followed by #xA or #x85.
+ *
+ * @param {string} input
+ * @returns {string}
+ * @prettierignore
+ */
+function normalizeLineEndings(input) {
+ return input.replace(/\r[\n\u0085]/g, '\n').replace(/[\r\u0085\u2028\u2029]/g, '\n');
+}
+
+/**
+ * @typedef Locator
+ * @property {number} [columnNumber]
+ * @property {number} [lineNumber]
+ */
+
+/**
+ * @typedef DOMParserOptions
+ * @property {typeof assign} [assign]
+ * The method to use instead of `conventions.assign`, which is used to copy values from
+ * `options` before they are used for parsing.
+ * @property {typeof DOMHandler} [domHandler]
+ * For internal testing: The class for creating an instance for handling events from the SAX
+ * parser.
+ * *****Warning: By configuring a faulty implementation, the specified behavior can completely
+ * be broken.*****.
+ * @property {Function} [errorHandler]
+ * DEPRECATED! use `onError` instead.
+ * @property {function(level:ErrorLevel, message:string, context: DOMHandler):void}
+ * [onError]
+ * A function invoked for every error that occurs during parsing.
+ *
+ * If it is not provided, all errors are reported to `console.error`
+ * and only `fatalError`s are thrown as a `ParseError`,
+ * which prevents any further processing.
+ * If the provided method throws, a `ParserError` is thrown,
+ * which prevents any further processing.
+ *
+ * Be aware that many `warning`s are considered an error that prevents further processing in
+ * most implementations.
+ * @property {boolean} [locator=true]
+ * Configures if the nodes created during parsing will have a `lineNumber` and a `columnNumber`
+ * attribute describing their location in the XML string.
+ * Default is true.
+ * @property {(string) => string} [normalizeLineEndings]
+ * used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,
+ * which normalizes line endings according to ,
+ * including some Unicode "newline" characters.
+ * @property {Object} [xmlns]
+ * The XML namespaces that should be assumed when parsing.
+ * The default namespace can be provided by the key that is the empty string.
+ * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,
+ * the default namespace that will be used,
+ * will be overridden according to the specification.
+ * @see {@link normalizeLineEndings}
+ */
+
+/**
+ * The DOMParser interface provides the ability to parse XML or HTML source code from a string
+ * into a DOM `Document`.
+ *
+ * ***xmldom is different from the spec in that it allows an `options` parameter,
+ * to control the behavior***.
+ *
+ * @class
+ * @param {DOMParserOptions} [options]
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
+ */
+function DOMParser(options) {
+ options = options || {};
+ if (options.locator === undefined) {
+ options.locator = true;
+ }
+
+ /**
+ * The method to use instead of `conventions.assign`, which is used to copy values from
+ * `options`
+ * before they are used for parsing.
+ *
+ * @type {conventions.assign}
+ * @private
+ * @see {@link conventions.assign}
+ * @readonly
+ */
+ this.assign = options.assign || conventions.assign;
+
+ /**
+ * For internal testing: The class for creating an instance for handling events from the SAX
+ * parser.
+ * *****Warning: By configuring a faulty implementation, the specified behavior can completely
+ * be broken*****.
+ *
+ * @type {typeof DOMHandler}
+ * @private
+ * @readonly
+ */
+ this.domHandler = options.domHandler || DOMHandler;
+
+ /**
+ * A function that is invoked for every error that occurs during parsing.
+ *
+ * If it is not provided, all errors are reported to `console.error`
+ * and only `fatalError`s are thrown as a `ParseError`,
+ * which prevents any further processing.
+ * If the provided method throws, a `ParserError` is thrown,
+ * which prevents any further processing.
+ *
+ * Be aware that many `warning`s are considered an error that prevents further processing in
+ * most implementations.
+ *
+ * @type {function(level:ErrorLevel, message:string, context: DOMHandler):void}
+ * @see {@link onErrorStopParsing}
+ * @see {@link onWarningStopParsing}
+ */
+ this.onError = options.onError || options.errorHandler;
+ if (options.errorHandler && typeof options.errorHandler !== 'function') {
+ throw new TypeError('errorHandler object is no longer supported, switch to onError!');
+ } else if (options.errorHandler) {
+ options.errorHandler('warning', 'The `errorHandler` option has been deprecated, use `onError` instead!', this);
+ }
+
+ /**
+ * used to replace line endings before parsing, defaults to `normalizeLineEndings`
+ *
+ * @type {(string) => string}
+ * @readonly
+ */
+ this.normalizeLineEndings = options.normalizeLineEndings || normalizeLineEndings;
+
+ /**
+ * Configures if the nodes created during parsing will have a `lineNumber` and a
+ * `columnNumber`
+ * attribute describing their location in the XML string.
+ * Default is true.
+ *
+ * @type {boolean}
+ * @readonly
+ */
+ this.locator = !!options.locator;
+
+ /**
+ * The default namespace can be provided by the key that is the empty string.
+ * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,
+ * the default namespace that will be used,
+ * will be overridden according to the specification.
+ *
+ * @type {Readonly}
+ * @readonly
+ */
+ this.xmlns = this.assign(Object.create(null), options.xmlns);
+}
+
+/**
+ * Parses `source` using the options in the way configured by the `DOMParserOptions` of `this`
+ * `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created,
+ * otherwise an XML `Document` is created.
+ *
+ * __It behaves different from the description in the living standard__:
+ * - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.
+ * - Any unexpected input is reported to `onError` with either a `warning`,
+ * `error` or `fatalError` level.
+ * - Any `fatalError` throws a `ParseError` which prevents further processing.
+ * - Any error thrown by `onError` is converted to a `ParseError` which prevents further
+ * processing - If no `Document` was created during parsing it is reported as a `fatalError`.
+ * *****Warning: By configuring a faulty DOMHandler implementation,
+ * the specified behavior can completely be broken*****.
+ *
+ * @param {string} source
+ * The XML mime type only allows string input!
+ * @param {string} [mimeType='application/xml']
+ * the mimeType or contentType of the document to be created determines the `type` of document
+ * created (XML or HTML)
+ * @returns {Document}
+ * The `Document` node.
+ * @throws {ParseError}
+ * for any `fatalError` or anything that is thrown by `onError`
+ * @throws {TypeError}
+ * for any invalid `mimeType`
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
+ * @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev
+ */
+DOMParser.prototype.parseFromString = function (source, mimeType) {
+ if (!isValidMimeType(mimeType)) {
+ throw new TypeError('DOMParser.parseFromString: the provided mimeType "' + mimeType + '" is not valid.');
+ }
+ var defaultNSMap = this.assign(Object.create(null), this.xmlns);
+ var entityMap = entities.XML_ENTITIES;
+ var defaultNamespace = defaultNSMap[''] || null;
+ if (hasDefaultHTMLNamespace(mimeType)) {
+ entityMap = entities.HTML_ENTITIES;
+ defaultNamespace = NAMESPACE.HTML;
+ } else if (mimeType === MIME_TYPE.XML_SVG_IMAGE) {
+ defaultNamespace = NAMESPACE.SVG;
+ }
+ defaultNSMap[''] = defaultNamespace;
+ defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
+
+ var domBuilder = new this.domHandler({
+ mimeType: mimeType,
+ defaultNamespace: defaultNamespace,
+ onError: this.onError,
+ });
+ var locator = this.locator ? {} : undefined;
+ if (this.locator) {
+ domBuilder.setDocumentLocator(locator);
+ }
+
+ var sax = new XMLReader();
+ sax.errorHandler = domBuilder;
+ sax.domBuilder = domBuilder;
+ var isXml = !conventions.isHTMLMimeType(mimeType);
+ if (isXml && typeof source !== 'string') {
+ sax.errorHandler.fatalError('source is not a string');
+ }
+ sax.parse(this.normalizeLineEndings(String(source)), defaultNSMap, entityMap);
+ if (!domBuilder.doc.documentElement) {
+ sax.errorHandler.fatalError('missing root element');
+ }
+ return domBuilder.doc;
+};
+
+/**
+ * @typedef DOMHandlerOptions
+ * @property {string} [mimeType=MIME_TYPE.XML_APPLICATION]
+ * @property {string | null} [defaultNamespace=null]
+ */
+/**
+ * The class that is used to handle events from the SAX parser to create the related DOM
+ * elements.
+ *
+ * Some methods are only implemented as an empty function,
+ * since they are (at least currently) not relevant for xmldom.
+ *
+ * @class
+ * @param {DOMHandlerOptions} [options]
+ * @see http://www.saxproject.org/apidoc/org/xml/sax/ext/DefaultHandler2.html
+ */
+function DOMHandler(options) {
+ var opt = options || {};
+ /**
+ * The mime type is used to determine if the DOM handler will create an XML or HTML document.
+ * Only if it is set to `text/html` it will create an HTML document.
+ * It defaults to MIME_TYPE.XML_APPLICATION.
+ *
+ * @type {string}
+ * @see {@link MIME_TYPE}
+ * @readonly
+ */
+ this.mimeType = opt.mimeType || MIME_TYPE.XML_APPLICATION;
+
+ /**
+ * The namespace to use to create an XML document.
+ * For the following reasons this is required:
+ * - The SAX API for `startDocument` doesn't offer any way to pass a namespace,
+ * since at that point there is no way for the parser to know what the default namespace from
+ * the document will be.
+ * - When creating using `DOMImplementation.createDocument` it is required to pass a
+ * namespace,
+ * to determine the correct `Document.contentType`, which should match `this.mimeType`.
+ * - When parsing an XML document with the `application/xhtml+xml` mimeType,
+ * the HTML namespace needs to be the default namespace.
+ *
+ * @type {string | null}
+ * @private
+ * @readonly
+ */
+ this.defaultNamespace = opt.defaultNamespace || null;
+
+ /**
+ * @type {boolean}
+ * @private
+ */
+ this.cdata = false;
+
+ /**
+ * The last `Element` that was created by `startElement`.
+ * `endElement` sets it to the `currentElement.parentNode`.
+ *
+ * Note: The sax parser currently sets it to white space text nodes between tags.
+ *
+ * @type {Element | Node | undefined}
+ * @private
+ */
+ this.currentElement = undefined;
+
+ /**
+ * The Document that is created as part of `startDocument`,
+ * and returned by `DOMParser.parseFromString`.
+ *
+ * @type {Document | undefined}
+ * @readonly
+ */
+ this.doc = undefined;
+
+ /**
+ * The locator is stored as part of setDocumentLocator.
+ * It is controlled and mutated by the SAX parser to store the current parsing position.
+ * It is used by DOMHandler to set `columnNumber` and `lineNumber`
+ * on the DOM nodes.
+ *
+ * @type {Readonly | undefined}
+ * @private
+ * @readonly (the
+ * sax parser currently sometimes set's it)
+ */
+ this.locator = undefined;
+ /**
+ * @type {function (level:ErrorLevel ,message:string, context:DOMHandler):void}
+ * @readonly
+ */
+ this.onError = opt.onError;
+}
+
+function position(locator, node) {
+ node.lineNumber = locator.lineNumber;
+ node.columnNumber = locator.columnNumber;
+}
+
+DOMHandler.prototype = {
+ /**
+ * Either creates an XML or an HTML document and stores it under `this.doc`.
+ * If it is an XML document, `this.defaultNamespace` is used to create it,
+ * and it will not contain any `childNodes`.
+ * If it is an HTML document, it will be created without any `childNodes`.
+ *
+ * @see http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
+ */
+ startDocument: function () {
+ var impl = new DOMImplementation();
+ this.doc = isHTMLMimeType(this.mimeType) ? impl.createHTMLDocument(false) : impl.createDocument(this.defaultNamespace, '');
+ },
+ startElement: function (namespaceURI, localName, qName, attrs) {
+ var doc = this.doc;
+ var el = doc.createElementNS(namespaceURI, qName || localName);
+ var len = attrs.length;
+ appendElement(this, el);
+ this.currentElement = el;
+
+ this.locator && position(this.locator, el);
+ for (var i = 0; i < len; i++) {
+ var namespaceURI = attrs.getURI(i);
+ var value = attrs.getValue(i);
+ var qName = attrs.getQName(i);
+ var attr = doc.createAttributeNS(namespaceURI, qName);
+ this.locator && position(attrs.getLocator(i), attr);
+ attr.value = attr.nodeValue = value;
+ el.setAttributeNode(attr);
+ }
+ },
+ endElement: function (namespaceURI, localName, qName) {
+ this.currentElement = this.currentElement.parentNode;
+ },
+ startPrefixMapping: function (prefix, uri) {},
+ endPrefixMapping: function (prefix) {},
+ processingInstruction: function (target, data) {
+ var ins = this.doc.createProcessingInstruction(target, data);
+ this.locator && position(this.locator, ins);
+ appendElement(this, ins);
+ },
+ ignorableWhitespace: function (ch, start, length) {},
+ characters: function (chars, start, length) {
+ chars = _toString.apply(this, arguments);
+ //console.log(chars)
+ if (chars) {
+ if (this.cdata) {
+ var charNode = this.doc.createCDATASection(chars);
+ } else {
+ var charNode = this.doc.createTextNode(chars);
+ }
+ if (this.currentElement) {
+ this.currentElement.appendChild(charNode);
+ } else if (/^\s*$/.test(chars)) {
+ this.doc.appendChild(charNode);
+ //process xml
+ }
+ this.locator && position(this.locator, charNode);
+ }
+ },
+ skippedEntity: function (name) {},
+ endDocument: function () {
+ this.doc.normalize();
+ },
+ /**
+ * Stores the locator to be able to set the `columnNumber` and `lineNumber`
+ * on the created DOM nodes.
+ *
+ * @param {Locator} locator
+ */
+ setDocumentLocator: function (locator) {
+ if (locator) {
+ locator.lineNumber = 0;
+ }
+ this.locator = locator;
+ },
+ //LexicalHandler
+ comment: function (chars, start, length) {
+ chars = _toString.apply(this, arguments);
+ var comm = this.doc.createComment(chars);
+ this.locator && position(this.locator, comm);
+ appendElement(this, comm);
+ },
+
+ startCDATA: function () {
+ //used in characters() methods
+ this.cdata = true;
+ },
+ endCDATA: function () {
+ this.cdata = false;
+ },
+
+ startDTD: function (name, publicId, systemId, internalSubset) {
+ var impl = this.doc.implementation;
+ if (impl && impl.createDocumentType) {
+ var dt = impl.createDocumentType(name, publicId, systemId, internalSubset);
+ this.locator && position(this.locator, dt);
+ appendElement(this, dt);
+ this.doc.doctype = dt;
+ }
+ },
+ reportError: function (level, message) {
+ if (typeof this.onError === 'function') {
+ try {
+ this.onError(level, message, this);
+ } catch (e) {
+ throw new ParseError('Reporting ' + level + ' "' + message + '" caused ' + e, this.locator);
+ }
+ } else {
+ console.error('[xmldom ' + level + ']\t' + message, _locator(this.locator));
+ }
+ },
+ /**
+ * @see http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
+ */
+ warning: function (message) {
+ this.reportError('warning', message);
+ },
+ error: function (message) {
+ this.reportError('error', message);
+ },
+ /**
+ * This function reports a fatal error and throws a ParseError.
+ *
+ * @param {string} message
+ * - The message to be used for reporting and throwing the error.
+ * @returns {never}
+ * This function always throws an error and never returns a value.
+ * @throws {ParseError}
+ * Always throws a ParseError with the provided message.
+ */
+ fatalError: function (message) {
+ this.reportError('fatalError', message);
+ throw new ParseError(message, this.locator);
+ },
+};
+
+function _locator(l) {
+ if (l) {
+ return '\n@#[line:' + l.lineNumber + ',col:' + l.columnNumber + ']';
+ }
+}
+
+function _toString(chars, start, length) {
+ if (typeof chars == 'string') {
+ return chars.substr(start, length);
+ } else {
+ //java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
+ if (chars.length >= start + length || start) {
+ return new java.lang.String(chars, start, length) + '';
+ }
+ return chars;
+ }
+}
+
+/*
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
+ * used method of org.xml.sax.ext.LexicalHandler:
+ * #comment(chars, start, length)
+ * #startCDATA()
+ * #endCDATA()
+ * #startDTD(name, publicId, systemId)
+ *
+ *
+ * IGNORED method of org.xml.sax.ext.LexicalHandler:
+ * #endDTD()
+ * #startEntity(name)
+ * #endEntity(name)
+ *
+ *
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
+ * IGNORED method of org.xml.sax.ext.DeclHandler
+ * #attributeDecl(eName, aName, type, mode, value)
+ * #elementDecl(name, model)
+ * #externalEntityDecl(name, publicId, systemId)
+ * #internalEntityDecl(name, value)
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
+ * IGNORED method of org.xml.sax.EntityResolver2
+ * #resolveEntity(String name,String publicId,String baseURI,String systemId)
+ * #resolveEntity(publicId, systemId)
+ * #getExternalSubset(name, baseURI)
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
+ * IGNORED method of org.xml.sax.DTDHandler
+ * #notationDecl(name, publicId, systemId) {};
+ * #unparsedEntityDecl(name, publicId, systemId, notationName) {};
+ */
+'endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl'.replace(
+ /\w+/g,
+ function (key) {
+ DOMHandler.prototype[key] = function () {
+ return null;
+ };
+ }
+);
+
+/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
+function appendElement(handler, node) {
+ if (!handler.currentElement) {
+ handler.doc.appendChild(node);
+ } else {
+ handler.currentElement.appendChild(node);
+ }
+}
+
+/**
+ * A method that prevents any further parsing when an `error`
+ * with level `error` is reported during parsing.
+ *
+ * @see {@link DOMParserOptions.onError}
+ * @see {@link onWarningStopParsing}
+ */
+function onErrorStopParsing(level) {
+ if (level === 'error') throw 'onErrorStopParsing';
+}
+
+/**
+ * A method that prevents any further parsing when any `error` is reported during parsing.
+ *
+ * @see {@link DOMParserOptions.onError}
+ * @see {@link onErrorStopParsing}
+ */
+function onWarningStopParsing() {
+ throw 'onWarningStopParsing';
+}
+
+exports.__DOMHandler = DOMHandler;
+exports.DOMParser = DOMParser;
+exports.normalizeLineEndings = normalizeLineEndings;
+exports.onErrorStopParsing = onErrorStopParsing;
+exports.onWarningStopParsing = onWarningStopParsing;
+
+},{"./conventions":2,"./dom":4,"./entities":5,"./errors":6,"./sax":9}],4:[function(require,module,exports){
+'use strict';
+
+var conventions = require('./conventions');
+var find = conventions.find;
+var hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;
+var hasOwn = conventions.hasOwn;
+var isHTMLMimeType = conventions.isHTMLMimeType;
+var isHTMLRawTextElement = conventions.isHTMLRawTextElement;
+var isHTMLVoidElement = conventions.isHTMLVoidElement;
+var MIME_TYPE = conventions.MIME_TYPE;
+var NAMESPACE = conventions.NAMESPACE;
+
+/**
+ * Private DOM Constructor symbol
+ *
+ * Internal symbol used for construction of all classes whose constructors should be private.
+ * Currently used for checks in `Node`, `Document`, `Element`, `Attr`, `CharacterData`, `Text`, `Comment`,
+ * `CDATASection`, `DocumentType`, `Notation`, `Entity`, `EntityReference`, `DocumentFragment`, `ProcessingInstruction`
+ * so the constructor can't be used from outside the module.
+ */
+var PDC = Symbol();
+
+var errors = require('./errors');
+var DOMException = errors.DOMException;
+var DOMExceptionName = errors.DOMExceptionName;
+
+var g = require('./grammar');
+
+/**
+ * Checks if the given symbol equals the Private DOM Constructor symbol (PDC)
+ * and throws an Illegal constructor exception when the symbols don't match.
+ * This ensures that the constructor remains private and can't be used outside this module.
+ */
+function checkSymbol(symbol) {
+ if (symbol !== PDC) {
+ throw new TypeError('Illegal constructor');
+ }
+}
+
+/**
+ * A prerequisite for `[].filter`, to drop elements that are empty.
+ *
+ * @param {string} input
+ * The string to be checked.
+ * @returns {boolean}
+ * Returns `true` if the input string is not empty, `false` otherwise.
+ */
+function notEmptyString(input) {
+ return input !== '';
+}
+/**
+ * Splits a string on ASCII whitespace characters (U+0009 TAB, U+000A LF, U+000C FF, U+000D CR,
+ * U+0020 SPACE).
+ * It follows the definition from the infra specification from WHATWG.
+ *
+ * @param {string} input
+ * The string to be split.
+ * @returns {string[]}
+ * An array of the split strings. The array can be empty if the input string is empty or only
+ * contains whitespace characters.
+ * @see {@link https://infra.spec.whatwg.org/#split-on-ascii-whitespace}
+ * @see {@link https://infra.spec.whatwg.org/#ascii-whitespace}
+ */
+function splitOnASCIIWhitespace(input) {
+ // U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE
+ return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : [];
+}
+
+/**
+ * Adds element as a key to current if it is not already present.
+ *
+ * @param {Record} current
+ * The current record object to which the element will be added as a key.
+ * The object's keys are string types and values are either boolean or undefined.
+ * @param {string} element
+ * The string to be added as a key to the current record.
+ * @returns {Record}
+ * The updated record object after the addition of the new element.
+ */
+function orderedSetReducer(current, element) {
+ if (!hasOwn(current, element)) {
+ current[element] = true;
+ }
+ return current;
+}
+
+/**
+ * Converts a string into an ordered set by splitting the input on ASCII whitespace and
+ * ensuring uniqueness of elements.
+ * This follows the definition of an ordered set from the infra specification by WHATWG.
+ *
+ * @param {string} input
+ * The input string to be transformed into an ordered set.
+ * @returns {string[]}
+ * An array of unique strings obtained from the input, preserving the original order.
+ * The array can be empty if the input string is empty or only contains whitespace characters.
+ * @see {@link https://infra.spec.whatwg.org/#ordered-set}
+ */
+function toOrderedSet(input) {
+ if (!input) return [];
+ var list = splitOnASCIIWhitespace(input);
+ return Object.keys(list.reduce(orderedSetReducer, {}));
+}
+
+/**
+ * Uses `list.indexOf` to implement a function that behaves like `Array.prototype.includes`.
+ * This function is used in environments where `Array.prototype.includes` may not be available.
+ *
+ * @param {any[]} list
+ * The array in which to search for the element.
+ * @returns {function(any): boolean}
+ * A function that accepts an element and returns a boolean indicating whether the element is
+ * included in the provided list.
+ */
+function arrayIncludes(list) {
+ return function (element) {
+ return list && list.indexOf(element) !== -1;
+ };
+}
+
+/**
+ * Validates a qualified name based on the criteria provided in the DOM specification by
+ * WHATWG.
+ *
+ * @param {string} qualifiedName
+ * The qualified name to be validated.
+ * @throws {DOMException}
+ * With code {@link DOMException.INVALID_CHARACTER_ERR} if the qualified name contains an
+ * invalid character.
+ * @see {@link https://dom.spec.whatwg.org/#validate}
+ */
+function validateQualifiedName(qualifiedName) {
+ if (!g.QName_exact.test(qualifiedName)) {
+ throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in qualified name "' + qualifiedName + '"');
+ }
+}
+
+/**
+ * Validates a qualified name and the namespace associated with it,
+ * based on the criteria provided in the DOM specification by WHATWG.
+ *
+ * @param {string | null} namespace
+ * The namespace to be validated. It can be a string or null.
+ * @param {string} qualifiedName
+ * The qualified name to be validated.
+ * @returns {[namespace: string | null, prefix: string | null, localName: string]}
+ * Returns a tuple with the namespace,
+ * prefix and local name of the qualified name.
+ * @throws {DOMException}
+ * Throws a DOMException if the qualified name or the namespace is not valid.
+ * @see {@link https://dom.spec.whatwg.org/#validate-and-extract}
+ */
+function validateAndExtract(namespace, qualifiedName) {
+ validateQualifiedName(qualifiedName);
+ namespace = namespace || null;
+ /**
+ * @type {string | null}
+ */
+ var prefix = null;
+ var localName = qualifiedName;
+ if (qualifiedName.indexOf(':') >= 0) {
+ var splitResult = qualifiedName.split(':');
+ prefix = splitResult[0];
+ localName = splitResult[1];
+ }
+ if (prefix !== null && namespace === null) {
+ throw new DOMException(DOMException.NAMESPACE_ERR, 'prefix is non-null and namespace is null');
+ }
+ if (prefix === 'xml' && namespace !== conventions.NAMESPACE.XML) {
+ throw new DOMException(DOMException.NAMESPACE_ERR, 'prefix is "xml" and namespace is not the XML namespace');
+ }
+ if ((prefix === 'xmlns' || qualifiedName === 'xmlns') && namespace !== conventions.NAMESPACE.XMLNS) {
+ throw new DOMException(
+ DOMException.NAMESPACE_ERR,
+ 'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace'
+ );
+ }
+ if (namespace === conventions.NAMESPACE.XMLNS && prefix !== 'xmlns' && qualifiedName !== 'xmlns') {
+ throw new DOMException(
+ DOMException.NAMESPACE_ERR,
+ 'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"'
+ );
+ }
+ return [namespace, prefix, localName];
+}
+
+/**
+ * Copies properties from one object to another.
+ * It only copies the object's own (not inherited) properties.
+ *
+ * @param {Object} src
+ * The source object from which properties are copied.
+ * @param {Object} dest
+ * The destination object to which properties are copied.
+ */
+function copy(src, dest) {
+ for (var p in src) {
+ if (hasOwn(src, p)) {
+ dest[p] = src[p];
+ }
+ }
+}
+
+/**
+ * Extends a class with the properties and methods of a super class.
+ * It uses a form of prototypal inheritance, and establishes the `constructor` property
+ * correctly(?).
+ *
+ * It is not clear to the current maintainers if this implementation is making sense,
+ * since it creates an intermediate prototype function,
+ * which all properties of `Super` are copied onto using `_copy`.
+ *
+ * @param {Object} Class
+ * The class that is to be extended.
+ * @param {Object} Super
+ * The super class from which properties and methods are inherited.
+ * @private
+ */
+function _extends(Class, Super) {
+ var pt = Class.prototype;
+ if (!(pt instanceof Super)) {
+ function t() {}
+ t.prototype = Super.prototype;
+ t = new t();
+ copy(pt, t);
+ Class.prototype = pt = t;
+ }
+ if (pt.constructor != Class) {
+ if (typeof Class != 'function') {
+ console.error('unknown Class:' + Class);
+ }
+ pt.constructor = Class;
+ }
+}
+
+var NodeType = {};
+var ELEMENT_NODE = (NodeType.ELEMENT_NODE = 1);
+var ATTRIBUTE_NODE = (NodeType.ATTRIBUTE_NODE = 2);
+var TEXT_NODE = (NodeType.TEXT_NODE = 3);
+var CDATA_SECTION_NODE = (NodeType.CDATA_SECTION_NODE = 4);
+var ENTITY_REFERENCE_NODE = (NodeType.ENTITY_REFERENCE_NODE = 5);
+var ENTITY_NODE = (NodeType.ENTITY_NODE = 6);
+var PROCESSING_INSTRUCTION_NODE = (NodeType.PROCESSING_INSTRUCTION_NODE = 7);
+var COMMENT_NODE = (NodeType.COMMENT_NODE = 8);
+var DOCUMENT_NODE = (NodeType.DOCUMENT_NODE = 9);
+var DOCUMENT_TYPE_NODE = (NodeType.DOCUMENT_TYPE_NODE = 10);
+var DOCUMENT_FRAGMENT_NODE = (NodeType.DOCUMENT_FRAGMENT_NODE = 11);
+var NOTATION_NODE = (NodeType.NOTATION_NODE = 12);
+
+var DocumentPosition = conventions.freeze({
+ DOCUMENT_POSITION_DISCONNECTED: 1,
+ DOCUMENT_POSITION_PRECEDING: 2,
+ DOCUMENT_POSITION_FOLLOWING: 4,
+ DOCUMENT_POSITION_CONTAINS: 8,
+ DOCUMENT_POSITION_CONTAINED_BY: 16,
+ DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32,
+});
+
+//helper functions for compareDocumentPosition
+/**
+ * Finds the common ancestor in two parent chains.
+ *
+ * @param {Node[]} a
+ * The first parent chain.
+ * @param {Node[]} b
+ * The second parent chain.
+ * @returns {Node}
+ * The common ancestor node if it exists. If there is no common ancestor, the function will
+ * return `null`.
+ */
+function commonAncestor(a, b) {
+ if (b.length < a.length) return commonAncestor(b, a);
+ var c = null;
+ for (var n in a) {
+ if (a[n] !== b[n]) return c;
+ c = a[n];
+ }
+ return c;
+}
+
+/**
+ * Assigns a unique identifier to a document to ensure consistency while comparing unrelated
+ * nodes.
+ *
+ * @param {Document} doc
+ * The document to which a unique identifier is to be assigned.
+ * @returns {string}
+ * The unique identifier of the document. If the document already had a unique identifier, the
+ * function will return the existing one.
+ */
+function docGUID(doc) {
+ if (!doc.guid) doc.guid = Math.random();
+ return doc.guid;
+}
+//-- end of helper functions
+
+/**
+ * The NodeList interface provides the abstraction of an ordered collection of nodes,
+ * without defining or constraining how this collection is implemented.
+ * NodeList objects in the DOM are live.
+ * The items in the NodeList are accessible via an integral index, starting from 0.
+ * You can also access the items of the NodeList with a `for...of` loop.
+ *
+ * @class NodeList
+ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
+ * @constructs NodeList
+ */
+function NodeList() {}
+NodeList.prototype = {
+ /**
+ * The number of nodes in the list. The range of valid child node indices is 0 to length-1
+ * inclusive.
+ *
+ * @type {number}
+ */
+ length: 0,
+ /**
+ * Returns the item at `index`. If index is greater than or equal to the number of nodes in
+ * the list, this returns null.
+ *
+ * @param index
+ * Unsigned long Index into the collection.
+ * @returns {Node | null}
+ * The node at position `index` in the NodeList,
+ * or null if that is not a valid index.
+ */
+ item: function (index) {
+ return index >= 0 && index < this.length ? this[index] : null;
+ },
+ /**
+ * Returns a string representation of the NodeList.
+ *
+ * Accepts the same `options` object as `XMLSerializer.prototype.serializeToString`
+ * (`requireWellFormed`, `splitCDATASections`, `nodeFilter`). Passing a function is treated as
+ * a legacy `nodeFilter` for backward compatibility.
+ *
+ * @param {Object | function} [options]
+ * @param {boolean} [options.requireWellFormed=false]
+ * @param {boolean} [options.splitCDATASections=true]
+ * @param {function} [options.nodeFilter]
+ * @returns {string}
+ */
+ toString: function (options) {
+ var opts;
+ if (typeof options === 'function') {
+ opts = { requireWellFormed: false, splitCDATASections: true, nodeFilter: options };
+ } else if (!!options) {
+ opts = {
+ requireWellFormed: !!options.requireWellFormed,
+ splitCDATASections: options.splitCDATASections !== false,
+ nodeFilter: options.nodeFilter || null,
+ };
+ } else {
+ opts = { requireWellFormed: false, splitCDATASections: true, nodeFilter: null };
+ }
+ for (var buf = [], i = 0; i < this.length; i++) {
+ serializeToString(this[i], buf, null, opts);
+ }
+ return buf.join('');
+ },
+ /**
+ * Filters the NodeList based on a predicate.
+ *
+ * @param {function(Node): boolean} predicate
+ * - A predicate function to filter the NodeList.
+ * @returns {Node[]}
+ * An array of nodes that satisfy the predicate.
+ * @private
+ */
+ filter: function (predicate) {
+ return Array.prototype.filter.call(this, predicate);
+ },
+ /**
+ * Returns the first index at which a given node can be found in the NodeList, or -1 if it is
+ * not present.
+ *
+ * @param {Node} item
+ * - The Node item to locate in the NodeList.
+ * @returns {number}
+ * The first index of the node in the NodeList; -1 if not found.
+ * @private
+ */
+ indexOf: function (item) {
+ return Array.prototype.indexOf.call(this, item);
+ },
+};
+NodeList.prototype[Symbol.iterator] = function () {
+ var me = this;
+ var index = 0;
+
+ return {
+ next: function () {
+ if (index < me.length) {
+ return {
+ value: me[index++],
+ done: false,
+ };
+ } else {
+ return {
+ done: true,
+ };
+ }
+ },
+ return: function () {
+ return {
+ done: true,
+ };
+ },
+ };
+};
+
+/**
+ * Represents a live collection of nodes that is automatically updated when its associated
+ * document changes.
+ *
+ * @class LiveNodeList
+ * @param {Node} node
+ * The associated node.
+ * @param {function} refresh
+ * The function to refresh the live node list.
+ * @augments NodeList
+ * @constructs LiveNodeList
+ */
+function LiveNodeList(node, refresh) {
+ this._node = node;
+ this._refresh = refresh;
+ _updateLiveList(this);
+}
+/**
+ * Updates the live node list.
+ *
+ * @param {LiveNodeList} list
+ * The live node list to update.
+ * @private
+ */
+function _updateLiveList(list) {
+ var inc = list._node._inc || list._node.ownerDocument._inc;
+ if (list._inc !== inc) {
+ var ls = list._refresh(list._node);
+ __set__(list, 'length', ls.length);
+ if (!list.$$length || ls.length < list.$$length) {
+ for (var i = ls.length; i in list; i++) {
+ if (hasOwn(list, i)) {
+ delete list[i];
+ }
+ }
+ }
+ copy(ls, list);
+ list._inc = inc;
+ }
+}
+/**
+ * Returns the node at position `index` in the LiveNodeList, or null if that is not a valid
+ * index.
+ *
+ * @param {number} i
+ * Index into the collection.
+ * @returns {Node | null}
+ * The node at position `index` in the LiveNodeList, or null if that is not a valid index.
+ */
+LiveNodeList.prototype.item = function (i) {
+ _updateLiveList(this);
+ return this[i] || null;
+};
+
+_extends(LiveNodeList, NodeList);
+
+/**
+ * Objects implementing the NamedNodeMap interface are used to represent collections of nodes
+ * that can be accessed by name.
+ * Note that NamedNodeMap does not inherit from NodeList;
+ * NamedNodeMaps are not maintained in any particular order.
+ * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal
+ * index,
+ * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
+ * and does not imply that the DOM specifies an order to these Nodes.
+ * NamedNodeMap objects in the DOM are live.
+ * used for attributes or DocumentType entities
+ *
+ * This implementation only supports property indices, but does not support named properties,
+ * as specified in the living standard.
+ *
+ * @class NamedNodeMap
+ * @see https://dom.spec.whatwg.org/#interface-namednodemap
+ * @see https://webidl.spec.whatwg.org/#dfn-supported-property-names
+ * @constructs NamedNodeMap
+ */
+function NamedNodeMap() {}
+/**
+ * Returns the index of a node within the list.
+ *
+ * @param {Array} list
+ * The list of nodes.
+ * @param {Node} node
+ * The node to find.
+ * @returns {number}
+ * The index of the node within the list, or -1 if not found.
+ * @private
+ */
+function _findNodeIndex(list, node) {
+ var i = 0;
+ while (i < list.length) {
+ if (list[i] === node) {
+ return i;
+ }
+ i++;
+ }
+}
+/**
+ * Adds a new attribute to the list and updates the owner element of the attribute.
+ *
+ * @param {Element} el
+ * The element which will become the owner of the new attribute.
+ * @param {NamedNodeMap} list
+ * The list to which the new attribute will be added.
+ * @param {Attr} newAttr
+ * The new attribute to be added.
+ * @param {Attr} oldAttr
+ * The old attribute to be replaced, or null if no attribute is to be replaced.
+ * @returns {void}
+ * @private
+ */
+function _addNamedNode(el, list, newAttr, oldAttr) {
+ if (oldAttr) {
+ list[_findNodeIndex(list, oldAttr)] = newAttr;
+ } else {
+ list[list.length] = newAttr;
+ list.length++;
+ }
+ if (el) {
+ newAttr.ownerElement = el;
+ var doc = el.ownerDocument;
+ if (doc) {
+ oldAttr && _onRemoveAttribute(doc, el, oldAttr);
+ _onAddAttribute(doc, el, newAttr);
+ }
+ }
+}
+/**
+ * Removes an attribute from the list and updates the owner element of the attribute.
+ *
+ * @param {Element} el
+ * The element which is the current owner of the attribute.
+ * @param {NamedNodeMap} list
+ * The list from which the attribute will be removed.
+ * @param {Attr} attr
+ * The attribute to be removed.
+ * @returns {void}
+ * @private
+ */
+function _removeNamedNode(el, list, attr) {
+ //console.log('remove attr:'+attr)
+ var i = _findNodeIndex(list, attr);
+ if (i >= 0) {
+ var lastIndex = list.length - 1;
+ while (i <= lastIndex) {
+ list[i] = list[++i];
+ }
+ list.length = lastIndex;
+ if (el) {
+ var doc = el.ownerDocument;
+ if (doc) {
+ _onRemoveAttribute(doc, el, attr);
+ }
+ attr.ownerElement = null;
+ }
+ }
+}
+NamedNodeMap.prototype = {
+ length: 0,
+ item: NodeList.prototype.item,
+
+ /**
+ * Get an attribute by name. Note: Name is in lower case in case of HTML namespace and
+ * document.
+ *
+ * @param {string} localName
+ * The local name of the attribute.
+ * @returns {Attr | null}
+ * The attribute with the given local name, or null if no such attribute exists.
+ * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
+ */
+ getNamedItem: function (localName) {
+ if (this._ownerElement && this._ownerElement._isInHTMLDocumentAndNamespace()) {
+ localName = localName.toLowerCase();
+ }
+ var i = 0;
+ while (i < this.length) {
+ var attr = this[i];
+ if (attr.nodeName === localName) {
+ return attr;
+ }
+ i++;
+ }
+ return null;
+ },
+
+ /**
+ * Set an attribute.
+ *
+ * @param {Attr} attr
+ * The attribute to set.
+ * @returns {Attr | null}
+ * The old attribute with the same local name and namespace URI as the new one, or null if no
+ * such attribute exists.
+ * @throws {DOMException}
+ * With code:
+ * - {@link INUSE_ATTRIBUTE_ERR} - If the attribute is already an attribute of another
+ * element.
+ * @see https://dom.spec.whatwg.org/#concept-element-attributes-set
+ */
+ setNamedItem: function (attr) {
+ var el = attr.ownerElement;
+ if (el && el !== this._ownerElement) {
+ throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);
+ }
+ var oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
+ if (oldAttr === attr) {
+ return attr;
+ }
+ _addNamedNode(this._ownerElement, this, attr, oldAttr);
+ return oldAttr;
+ },
+
+ /**
+ * Set an attribute, replacing an existing attribute with the same local name and namespace
+ * URI if one exists.
+ *
+ * @param {Attr} attr
+ * The attribute to set.
+ * @returns {Attr | null}
+ * The old attribute with the same local name and namespace URI as the new one, or null if no
+ * such attribute exists.
+ * @throws {DOMException}
+ * Throws a DOMException with the name "InUseAttributeError" if the attribute is already an
+ * attribute of another element.
+ * @see https://dom.spec.whatwg.org/#concept-element-attributes-set
+ */
+ setNamedItemNS: function (attr) {
+ return this.setNamedItem(attr);
+ },
+
+ /**
+ * Removes an attribute specified by the local name.
+ *
+ * @param {string} localName
+ * The local name of the attribute to be removed.
+ * @returns {Attr}
+ * The attribute node that was removed.
+ * @throws {DOMException}
+ * With code:
+ * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given name is found.
+ * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem
+ * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name
+ */
+ removeNamedItem: function (localName) {
+ var attr = this.getNamedItem(localName);
+ if (!attr) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, localName);
+ }
+ _removeNamedNode(this._ownerElement, this, attr);
+ return attr;
+ },
+
+ /**
+ * Removes an attribute specified by the namespace and local name.
+ *
+ * @param {string | null} namespaceURI
+ * The namespace URI of the attribute to be removed.
+ * @param {string} localName
+ * The local name of the attribute to be removed.
+ * @returns {Attr}
+ * The attribute node that was removed.
+ * @throws {DOMException}
+ * With code:
+ * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given namespace URI and local
+ * name is found.
+ * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns
+ * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace
+ */
+ removeNamedItemNS: function (namespaceURI, localName) {
+ var attr = this.getNamedItemNS(namespaceURI, localName);
+ if (!attr) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, namespaceURI ? namespaceURI + ' : ' + localName : localName);
+ }
+ _removeNamedNode(this._ownerElement, this, attr);
+ return attr;
+ },
+
+ /**
+ * Get an attribute by namespace and local name.
+ *
+ * @param {string | null} namespaceURI
+ * The namespace URI of the attribute.
+ * @param {string} localName
+ * The local name of the attribute.
+ * @returns {Attr | null}
+ * The attribute with the given namespace URI and local name, or null if no such attribute
+ * exists.
+ * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
+ */
+ getNamedItemNS: function (namespaceURI, localName) {
+ if (!namespaceURI) {
+ namespaceURI = null;
+ }
+ var i = 0;
+ while (i < this.length) {
+ var node = this[i];
+ if (node.localName === localName && node.namespaceURI === namespaceURI) {
+ return node;
+ }
+ i++;
+ }
+ return null;
+ },
+};
+NamedNodeMap.prototype[Symbol.iterator] = function () {
+ var me = this;
+ var index = 0;
+
+ return {
+ next: function () {
+ if (index < me.length) {
+ return {
+ value: me[index++],
+ done: false,
+ };
+ } else {
+ return {
+ done: true,
+ };
+ }
+ },
+ return: function () {
+ return {
+ done: true,
+ };
+ },
+ };
+};
+
+/**
+ * The DOMImplementation interface provides a number of methods for performing operations that
+ * are independent of any particular instance of the document object model.
+ *
+ * The DOMImplementation interface represents an object providing methods which are not
+ * dependent on any particular document.
+ * Such an object is returned by the `Document.implementation` property.
+ *
+ * **The individual methods describe the differences compared to the specs**.
+ *
+ * @class DOMImplementation
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core
+ * (Initial)
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
+ * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
+ * @constructs DOMImplementation
+ */
+function DOMImplementation() {}
+
+DOMImplementation.prototype = {
+ /**
+ * Test if the DOM implementation implements a specific feature and version, as specified in
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMFeatures DOM Features}.
+ *
+ * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given
+ * feature is supported. The different implementations fairly diverged in what kind of
+ * features were reported. The latest version of the spec settled to force this method to
+ * always return true, where the functionality was accurate and in use.
+ *
+ * @deprecated
+ * It is deprecated and modern browsers return true in all cases.
+ * @function DOMImplementation#hasFeature
+ * @param {string} feature
+ * The name of the feature to test.
+ * @param {string} [version]
+ * This is the version number of the feature to test.
+ * @returns {boolean}
+ * Always returns true.
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-5CED94D7 DOM Level 3 Core
+ */
+ hasFeature: function (feature, version) {
+ return true;
+ },
+ /**
+ * Creates a DOM Document object of the specified type with its document element. Note that
+ * based on the {@link DocumentType}
+ * given to create the document, the implementation may instantiate specialized
+ * {@link Document} objects that support additional features than the "Core", such as "HTML"
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#DOM2HTML DOM Level 2 HTML}.
+ * On the other hand, setting the {@link DocumentType} after the document was created makes
+ * this very unlikely to happen. Alternatively, specialized {@link Document} creation methods,
+ * such as createHTMLDocument
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#DOM2HTML DOM Level 2 HTML},
+ * can be used to obtain specific types of {@link Document} objects.
+ *
+ * __It behaves slightly different from the description in the living standard__:
+ * - There is no interface/class `XMLDocument`, it returns a `Document`
+ * instance (with it's `type` set to `'xml'`).
+ * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
+ *
+ * @function DOMImplementation.createDocument
+ * @param {string | null} namespaceURI
+ * The
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-namespaceURI namespace URI}
+ * of the document element to create or null.
+ * @param {string | null} qualifiedName
+ * The
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-qualifiedname qualified name}
+ * of the document element to be created or null.
+ * @param {DocumentType | null} [doctype=null]
+ * The type of document to be created or null. When doctype is not null, its
+ * {@link Node#ownerDocument} attribute is set to the document being created. Default is
+ * `null`
+ * @returns {Document}
+ * A new {@link Document} object with its document element. If the NamespaceURI,
+ * qualifiedName, and doctype are null, the returned {@link Document} is empty with no
+ * document element.
+ * @throws {DOMException}
+ * With code:
+ *
+ * - `INVALID_CHARACTER_ERR`: Raised if the specified qualified name is not an XML name
+ * according to {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#XML XML 1.0}.
+ * - `NAMESPACE_ERR`: Raised if the qualifiedName is malformed, if the qualifiedName has a
+ * prefix and the namespaceURI is null, or if the qualifiedName is null and the namespaceURI
+ * is different from null, or if the qualifiedName has a prefix that is "xml" and the
+ * namespaceURI is different from "{@link http://www.w3.org/XML/1998/namespace}"
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#Namespaces XML Namespaces},
+ * or if the DOM implementation does not support the "XML" feature but a non-null namespace
+ * URI was provided, since namespaces were defined by XML.
+ * - `WRONG_DOCUMENT_ERR`: Raised if doctype has already been used with a different document
+ * or was created from a different implementation.
+ * - `NOT_SUPPORTED_ERR`: May be raised if the implementation does not support the feature
+ * "XML" and the language exposed through the Document does not support XML Namespaces (such
+ * as {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#HTML40 HTML 4.01}).
+ * @since DOM Level 2.
+ * @see {@link #createHTMLDocument}
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Living Standard
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-2-Core-DOM-createDocument DOM
+ * Level 3 Core
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM
+ * Level 2 Core (initial)
+ */
+ createDocument: function (namespaceURI, qualifiedName, doctype) {
+ var contentType = MIME_TYPE.XML_APPLICATION;
+ if (namespaceURI === NAMESPACE.HTML) {
+ contentType = MIME_TYPE.XML_XHTML_APPLICATION;
+ } else if (namespaceURI === NAMESPACE.SVG) {
+ contentType = MIME_TYPE.XML_SVG_IMAGE;
+ }
+ var doc = new Document(PDC, { contentType: contentType });
+ doc.implementation = this;
+ doc.childNodes = new NodeList();
+ doc.doctype = doctype || null;
+ if (doctype) {
+ doc.appendChild(doctype);
+ }
+ if (qualifiedName) {
+ var root = doc.createElementNS(namespaceURI, qualifiedName);
+ doc.appendChild(root);
+ }
+ return doc;
+ },
+ /**
+ * Creates an empty DocumentType node. Entity declarations and notations are not made
+ * available. Entity reference expansions and default attribute additions do not occur.
+ *
+ * **This behavior is slightly different from the one in the specs**:
+ * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
+ * - `publicId` and `systemId` contain the raw data including any possible quotes,
+ * so they can always be serialized back to the original value
+ * - `internalSubset` contains the raw string between `[` and `]` if present,
+ * but is not parsed or validated in any form.
+ *
+ * @function DOMImplementation#createDocumentType
+ * @param {string} qualifiedName
+ * The {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-qualifiedname qualified
+ * name} of the document type to be created.
+ * @param {string} [publicId]
+ * The external subset public identifier. Stored verbatim including surrounding quotes.
+ * When serialized with `requireWellFormed: true`, the serializer throws `InvalidStateError`
+ * if the value is non-empty and does not match the XML `PubidLiteral` production
+ * (W3C DOM Parsing §3.2.1.3; XML 1.0 production [12]). Creation-time validation is not
+ * enforced — deferred to a future breaking release.
+ * @param {string} [systemId]
+ * The external subset system identifier. Stored verbatim including surrounding quotes.
+ * When serialized with `requireWellFormed: true`, the serializer throws `InvalidStateError`
+ * if the value is non-empty and does not match the XML `SystemLiteral` production
+ * (W3C DOM Parsing §3.2.1.3; XML 1.0 production [11]). Creation-time validation is not
+ * enforced — deferred to a future breaking release.
+ * @param {string} [internalSubset]
+ * The internal subset or an empty string if it is not present. Stored verbatim.
+ * When serialized with `requireWellFormed: true`, the serializer throws `InvalidStateError`
+ * if the value contains `"]>"`. Creation-time validation is not enforced.
+ * @returns {DocumentType}
+ * A new {@link DocumentType} node with {@link Node#ownerDocument} set to null.
+ * @throws {DOMException}
+ * With code:
+ *
+ * - `INVALID_CHARACTER_ERR`: Raised if the specified qualified name is not an XML name
+ * according to {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#XML XML 1.0}.
+ * - `NAMESPACE_ERR`: Raised if the qualifiedName is malformed.
+ * - `NOT_SUPPORTED_ERR`: May be raised if the implementation does not support the feature
+ * "XML" and the language exposed through the Document does not support XML Namespaces (such
+ * as {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#HTML40 HTML 4.01}).
+ * @since DOM Level 2.
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType
+ * MDN
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living
+ * Standard
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-3-Core-DOM-createDocType DOM
+ * Level 3 Core
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM
+ * Level 2 Core
+ * @see https://github.com/xmldom/xmldom/blob/master/CHANGELOG.md#050
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-Core-DocType-internalSubset
+ * @prettierignore
+ */
+ createDocumentType: function (qualifiedName, publicId, systemId, internalSubset) {
+ validateQualifiedName(qualifiedName);
+ var node = new DocumentType(PDC);
+ node.name = qualifiedName;
+ node.nodeName = qualifiedName;
+ node.publicId = publicId || '';
+ node.systemId = systemId || '';
+ node.internalSubset = internalSubset || '';
+ node.childNodes = new NodeList();
+
+ return node;
+ },
+ /**
+ * Returns an HTML document, that might already have a basic DOM structure.
+ *
+ * __It behaves slightly different from the description in the living standard__:
+ * - If the first argument is `false` no initial nodes are added (steps 3-7 in the specs are
+ * omitted)
+ * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
+ *
+ * @param {string | false} [title]
+ * A string containing the title to give the new HTML document.
+ * @returns {Document}
+ * The HTML document.
+ * @since WHATWG Living Standard.
+ * @see {@link #createDocument}
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
+ * @see https://dom.spec.whatwg.org/#html-document
+ */
+ createHTMLDocument: function (title) {
+ var doc = new Document(PDC, { contentType: MIME_TYPE.HTML });
+ doc.implementation = this;
+ doc.childNodes = new NodeList();
+ if (title !== false) {
+ doc.doctype = this.createDocumentType('html');
+ doc.doctype.ownerDocument = doc;
+ doc.appendChild(doc.doctype);
+ var htmlNode = doc.createElement('html');
+ doc.appendChild(htmlNode);
+ var headNode = doc.createElement('head');
+ htmlNode.appendChild(headNode);
+ if (typeof title === 'string') {
+ var titleNode = doc.createElement('title');
+ titleNode.appendChild(doc.createTextNode(title));
+ headNode.appendChild(titleNode);
+ }
+ htmlNode.appendChild(doc.createElement('body'));
+ }
+ return doc;
+ },
+};
+
+/**
+ * The DOM Node interface is an abstract base class upon which many other DOM API objects are
+ * based, thus letting those object types to be used similarly and often interchangeably. As an
+ * abstract class, there is no such thing as a plain Node object. All objects that implement
+ * Node functionality are based on one of its subclasses. Most notable are Document, Element,
+ * and DocumentFragment.
+ *
+ * In addition, every kind of DOM node is represented by an interface based on Node. These
+ * include Attr, CharacterData (which Text, Comment, CDATASection and ProcessingInstruction are
+ * all based on), and DocumentType.
+ *
+ * In some cases, a particular feature of the base Node interface may not apply to one of its
+ * child interfaces; in that case, the inheriting node may return null or throw an exception,
+ * depending on circumstances. For example, attempting to add children to a node type that
+ * cannot have children will throw an exception.
+ *
+ * **This behavior is slightly different from the in the specs**:
+ * - unimplemented interfaces: `EventTarget`
+ *
+ * @class
+ * @abstract
+ * @param {Symbol} symbol
+ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
+ * @see https://dom.spec.whatwg.org/#node
+ * @prettierignore
+ */
+function Node(symbol) {
+ checkSymbol(symbol);
+}
+
+Node.prototype = {
+ /**
+ * The first child of this node.
+ *
+ * @type {Node | null}
+ */
+ firstChild: null,
+ /**
+ * The last child of this node.
+ *
+ * @type {Node | null}
+ */
+ lastChild: null,
+ /**
+ * The previous sibling of this node.
+ *
+ * @type {Node | null}
+ */
+ previousSibling: null,
+ /**
+ * The next sibling of this node.
+ *
+ * @type {Node | null}
+ */
+ nextSibling: null,
+ /**
+ * The parent node of this node.
+ *
+ * @type {Node | null}
+ */
+ parentNode: null,
+ /**
+ * The parent element of this node.
+ *
+ * @type {Element | null}
+ */
+ get parentElement() {
+ return this.parentNode && this.parentNode.nodeType === this.ELEMENT_NODE ? this.parentNode : null;
+ },
+ /**
+ * The child nodes of this node.
+ *
+ * @type {NodeList}
+ */
+ childNodes: null,
+ /**
+ * The document object associated with this node.
+ *
+ * @type {Document | null}
+ */
+ ownerDocument: null,
+ /**
+ * The value of this node.
+ *
+ * @type {string | null}
+ */
+ nodeValue: null,
+ /**
+ * The namespace URI of this node.
+ *
+ * @type {string | null}
+ */
+ namespaceURI: null,
+ /**
+ * The prefix of the namespace for this node.
+ *
+ * @type {string | null}
+ */
+ prefix: null,
+ /**
+ * The local part of the qualified name of this node.
+ *
+ * @type {string | null}
+ */
+ localName: null,
+ /**
+ * The baseURI is currently always `about:blank`,
+ * since that's what happens when you create a document from scratch.
+ *
+ * @type {'about:blank'}
+ */
+ baseURI: 'about:blank',
+ /**
+ * Is true if this node is part of a document.
+ *
+ * @type {boolean}
+ */
+ get isConnected() {
+ var rootNode = this.getRootNode();
+ return rootNode && rootNode.nodeType === rootNode.DOCUMENT_NODE;
+ },
+ /**
+ * Checks whether `other` is an inclusive descendant of this node.
+ *
+ * @param {Node | null | undefined} other
+ * The node to check.
+ * @returns {boolean}
+ * True if `other` is an inclusive descendant of this node; false otherwise.
+ * @see https://dom.spec.whatwg.org/#dom-node-contains
+ */
+ contains: function (other) {
+ if (!other) return false;
+ var parent = other;
+ do {
+ if (this === parent) return true;
+ parent = parent.parentNode;
+ } while (parent);
+ return false;
+ },
+ /**
+ * @typedef GetRootNodeOptions
+ * @property {boolean} [composed=false]
+ */
+ /**
+ * Searches for the root node of this node.
+ *
+ * **This behavior is slightly different from the in the specs**:
+ * - ignores `options.composed`, since `ShadowRoot`s are unsupported, always returns root.
+ *
+ * @param {GetRootNodeOptions} [options]
+ * @returns {Node}
+ * Root node.
+ * @see https://dom.spec.whatwg.org/#dom-node-getrootnode
+ * @see https://dom.spec.whatwg.org/#concept-shadow-including-root
+ */
+ getRootNode: function (options) {
+ var parent = this;
+ do {
+ if (!parent.parentNode) {
+ return parent;
+ }
+ parent = parent.parentNode;
+ } while (parent);
+ },
+ /**
+ * Checks whether the given node is equal to this node.
+ *
+ * Two nodes are equal when they have the same type, defining characteristics (for the type),
+ * and the same childNodes. The comparison is iterative to avoid stack overflows on
+ * deeply-nested trees. Attribute nodes of each Element pair are also pushed onto the stack
+ * and compared the same way.
+ *
+ * @param {Node} [otherNode]
+ * @returns {boolean}
+ * @see https://dom.spec.whatwg.org/#concept-node-equals
+ * @see ../docs/walk-dom.md.
+ */
+ isEqualNode: function (otherNode) {
+ if (!otherNode) return false;
+
+ // Use an explicit {node, other} pair stack to avoid call-stack overflow on deep trees.
+ // walkDOM cannot be used here — parallel two-tree traversal requires pairing
+ // corresponding nodes at each step across both trees simultaneously.
+ var stack = [{ node: this, other: otherNode }];
+ while (stack.length > 0) {
+ var pair = stack.pop();
+ var node = pair.node;
+ var other = pair.other;
+
+ if (node.nodeType !== other.nodeType) return false;
+
+ switch (node.nodeType) {
+ case node.DOCUMENT_TYPE_NODE:
+ if (node.name !== other.name) return false;
+ if (node.publicId !== other.publicId) return false;
+ if (node.systemId !== other.systemId) return false;
+ break;
+ case node.ELEMENT_NODE:
+ if (node.namespaceURI !== other.namespaceURI) return false;
+ if (node.prefix !== other.prefix) return false;
+ if (node.localName !== other.localName) return false;
+ if (node.attributes.length !== other.attributes.length) return false;
+ for (var i = 0; i < node.attributes.length; i++) {
+ var attr = node.attributes.item(i);
+ var otherAttr = other.getAttributeNodeNS(attr.namespaceURI, attr.localName);
+ if (!otherAttr) return false;
+ stack.push({ node: attr, other: otherAttr });
+ }
+ break;
+ case node.ATTRIBUTE_NODE:
+ if (node.namespaceURI !== other.namespaceURI) return false;
+ if (node.localName !== other.localName) return false;
+ if (node.value !== other.value) return false;
+ break;
+ case node.PROCESSING_INSTRUCTION_NODE:
+ if (node.target !== other.target || node.data !== other.data) return false;
+ break;
+ case node.TEXT_NODE:
+ case node.CDATA_SECTION_NODE:
+ case node.COMMENT_NODE:
+ if (node.data !== other.data) return false;
+ break;
+ }
+
+ if (node.childNodes.length !== other.childNodes.length) return false;
+
+ // Push children in reverse order so index 0 is processed first (LIFO).
+ for (var i = node.childNodes.length - 1; i >= 0; i--) {
+ stack.push({ node: node.childNodes[i], other: other.childNodes[i] });
+ }
+ }
+
+ return true;
+ },
+ /**
+ * Checks whether or not the given node is this node.
+ *
+ * @param {Node} [otherNode]
+ */
+ isSameNode: function (otherNode) {
+ return this === otherNode;
+ },
+ /**
+ * Inserts a node before a reference node as a child of this node.
+ *
+ * @param {Node} newChild
+ * The new child node to be inserted.
+ * @param {Node | null} refChild
+ * The reference node before which newChild will be inserted.
+ * @returns {Node}
+ * The new child node successfully inserted.
+ * @throws {DOMException}
+ * Throws a DOMException if inserting the node would result in a DOM tree that is not
+ * well-formed, or if `child` is provided but is not a child of `parent`.
+ * See {@link _insertBefore} for more details.
+ * @since Modified in DOM L2
+ */
+ insertBefore: function (newChild, refChild) {
+ return _insertBefore(this, newChild, refChild);
+ },
+ /**
+ * Replaces an old child node with a new child node within this node.
+ *
+ * @param {Node} newChild
+ * The new node that is to replace the old node.
+ * If it already exists in the DOM, it is removed from its original position.
+ * @param {Node} oldChild
+ * The existing child node to be replaced.
+ * @returns {Node}
+ * Returns the replaced child node.
+ * @throws {DOMException}
+ * Throws a DOMException if replacing the node would result in a DOM tree that is not
+ * well-formed, or if `oldChild` is not a child of `this`.
+ * This can also occur if the pre-replacement validity assertion fails.
+ * See {@link _insertBefore}, {@link Node.removeChild}, and
+ * {@link assertPreReplacementValidityInDocument} for more details.
+ * @see https://dom.spec.whatwg.org/#concept-node-replace
+ */
+ replaceChild: function (newChild, oldChild) {
+ _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
+ if (oldChild) {
+ this.removeChild(oldChild);
+ }
+ },
+ /**
+ * Removes an existing child node from this node.
+ *
+ * @param {Node} oldChild
+ * The child node to be removed.
+ * @returns {Node}
+ * Returns the removed child node.
+ * @throws {DOMException}
+ * Throws a DOMException if `oldChild` is not a child of `this`.
+ * See {@link _removeChild} for more details.
+ */
+ removeChild: function (oldChild) {
+ return _removeChild(this, oldChild);
+ },
+ /**
+ * Appends a child node to this node.
+ *
+ * @param {Node} newChild
+ * The child node to be appended to this node.
+ * If it already exists in the DOM, it is removed from its original position.
+ * @returns {Node}
+ * Returns the appended child node.
+ * @throws {DOMException}
+ * Throws a DOMException if appending the node would result in a DOM tree that is not
+ * well-formed, or if `newChild` is not a valid Node.
+ * See {@link insertBefore} for more details.
+ */
+ appendChild: function (newChild) {
+ return this.insertBefore(newChild, null);
+ },
+ /**
+ * Determines whether this node has any child nodes.
+ *
+ * @returns {boolean}
+ * Returns true if this node has any child nodes, and false otherwise.
+ */
+ hasChildNodes: function () {
+ return this.firstChild != null;
+ },
+ /**
+ * Creates a copy of the calling node.
+ *
+ * @param {boolean} deep
+ * If true, the contents of the node are recursively copied.
+ * If false, only the node itself (and its attributes, if it is an element) are copied.
+ * @returns {Node}
+ * Returns the newly created copy of the node.
+ * @throws {DOMException}
+ * May throw a DOMException if operations within {@link Element#setAttributeNode} or
+ * {@link Node#appendChild} (which are potentially invoked in this method) do not meet their
+ * specific constraints.
+ * @see {@link cloneNode}
+ */
+ cloneNode: function (deep) {
+ return cloneNode(this.ownerDocument || this, this, deep);
+ },
+ /**
+ * Puts the specified node and all of its subtree into a "normalized" form. In a normalized
+ * subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.
+ *
+ * Specifically, this method merges any adjacent text nodes (i.e., nodes for which `nodeType`
+ * is `TEXT_NODE`) into a single node with the combined data. It also removes any empty text
+ * nodes.
+ *
+ * This method iterativly traverses all child nodes to normalize all descendent nodes within
+ * the subtree.
+ *
+ * @throws {DOMException}
+ * May throw a DOMException if operations within removeChild or appendData (which are
+ * potentially invoked in this method) do not meet their specific constraints.
+ * @since Modified in DOM Level 2
+ * @see {@link Node.removeChild}
+ * @see {@link CharacterData.appendData}
+ * @see ../docs/walk-dom.md.
+ */
+ normalize: function () {
+ walkDOM(this, null, {
+ enter: function (node) {
+ // Merge adjacent text children of node before walkDOM schedules them.
+ // walkDOM reads lastChild/previousSibling after enter returns, so the
+ // surviving post-merge children are what it descends into.
+ var child = node.firstChild;
+ while (child) {
+ var next = child.nextSibling;
+ if (next !== null && next.nodeType === TEXT_NODE && child.nodeType === TEXT_NODE) {
+ node.removeChild(next);
+ child.appendData(next.data);
+ // Do not advance child: re-check new nextSibling for another text run
+ } else {
+ child = next;
+ }
+ }
+ return true; // descend into surviving children
+ },
+ });
+ },
+ /**
+ * Checks whether the DOM implementation implements a specific feature and its version.
+ *
+ * @deprecated
+ * Since `DOMImplementation.hasFeature` is deprecated and always returns true.
+ * @param {string} feature
+ * The package name of the feature to test. This is the same name that can be passed to the
+ * method `hasFeature` on `DOMImplementation`.
+ * @param {string} version
+ * This is the version number of the package name to test.
+ * @returns {boolean}
+ * Returns true in all cases in the current implementation.
+ * @since Introduced in DOM Level 2
+ * @see {@link DOMImplementation.hasFeature}
+ */
+ isSupported: function (feature, version) {
+ return this.ownerDocument.implementation.hasFeature(feature, version);
+ },
+ /**
+ * Look up the prefix associated to the given namespace URI, starting from this node.
+ * **The default namespace declarations are ignored by this method.**
+ * See Namespace Prefix Lookup for details on the algorithm used by this method.
+ *
+ * **This behavior is different from the in the specs**:
+ * - no node type specific handling
+ * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes
+ *
+ * @param {string | null} namespaceURI
+ * The namespace URI for which to find the associated prefix.
+ * @returns {string | null}
+ * The associated prefix, if found; otherwise, null.
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo
+ * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
+ * @see https://github.com/xmldom/xmldom/issues/322
+ * @prettierignore
+ */
+ lookupPrefix: function (namespaceURI) {
+ var el = this;
+ while (el) {
+ var map = el._nsMap;
+ //console.dir(map)
+ if (map) {
+ for (var n in map) {
+ if (hasOwn(map, n) && map[n] === namespaceURI) {
+ return n;
+ }
+ }
+ }
+ el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
+ }
+ return null;
+ },
+ /**
+ * This function is used to look up the namespace URI associated with the given prefix,
+ * starting from this node.
+ *
+ * **This behavior is different from the in the specs**:
+ * - no node type specific handling
+ * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes
+ *
+ * @param {string | null} prefix
+ * The prefix for which to find the associated namespace URI.
+ * @returns {string | null}
+ * The associated namespace URI, if found; otherwise, null.
+ * @since DOM Level 3
+ * @see https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI
+ * @prettierignore
+ */
+ lookupNamespaceURI: function (prefix) {
+ var el = this;
+ while (el) {
+ var map = el._nsMap;
+ //console.dir(map)
+ if (map) {
+ if (hasOwn(map, prefix)) {
+ return map[prefix];
+ }
+ }
+ el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
+ }
+ return null;
+ },
+ /**
+ * Determines whether the given namespace URI is the default namespace.
+ *
+ * The function works by looking up the prefix associated with the given namespace URI. If no
+ * prefix is found (i.e., the namespace URI is not registered in the namespace map of this
+ * node or any of its ancestors), it returns `true`, implying the namespace URI is considered
+ * the default.
+ *
+ * **This behavior is different from the in the specs**:
+ * - no node type specific handling
+ * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes
+ *
+ * @param {string | null} namespaceURI
+ * The namespace URI to be checked.
+ * @returns {boolean}
+ * Returns true if the given namespace URI is the default namespace, false otherwise.
+ * @since DOM Level 3
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isDefaultNamespace
+ * @see https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace
+ * @prettierignore
+ */
+ isDefaultNamespace: function (namespaceURI) {
+ var prefix = this.lookupPrefix(namespaceURI);
+ return prefix == null;
+ },
+ /**
+ * Compares the reference node with a node with regard to their position in the document and
+ * according to the document order.
+ *
+ * @param {Node} other
+ * The node to compare the reference node to.
+ * @returns {number}
+ * Returns how the node is positioned relatively to the reference node according to the
+ * bitmask. 0 if reference node and given node are the same.
+ * @since DOM Level 3
+ * @see https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-compare
+ * @see https://dom.spec.whatwg.org/#dom-node-comparedocumentposition
+ */
+ compareDocumentPosition: function (other) {
+ if (this === other) return 0;
+ var node1 = other;
+ var node2 = this;
+ var attr1 = null;
+ var attr2 = null;
+ if (node1 instanceof Attr) {
+ attr1 = node1;
+ node1 = attr1.ownerElement;
+ }
+ if (node2 instanceof Attr) {
+ attr2 = node2;
+ node2 = attr2.ownerElement;
+ if (attr1 && node1 && node2 === node1) {
+ for (var i = 0, attr; (attr = node2.attributes[i]); i++) {
+ if (attr === attr1)
+ return DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + DocumentPosition.DOCUMENT_POSITION_PRECEDING;
+ if (attr === attr2)
+ return DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
+ }
+ }
+ }
+ if (!node1 || !node2 || node2.ownerDocument !== node1.ownerDocument) {
+ return (
+ DocumentPosition.DOCUMENT_POSITION_DISCONNECTED +
+ DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +
+ (docGUID(node2.ownerDocument) > docGUID(node1.ownerDocument)
+ ? DocumentPosition.DOCUMENT_POSITION_FOLLOWING
+ : DocumentPosition.DOCUMENT_POSITION_PRECEDING)
+ );
+ }
+ if (attr2 && node1 === node2) {
+ return DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;
+ }
+ if (attr1 && node1 === node2) {
+ return DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
+ }
+
+ var chain1 = [];
+ var ancestor1 = node1.parentNode;
+ while (ancestor1) {
+ if (!attr2 && ancestor1 === node2) {
+ return DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
+ }
+ chain1.push(ancestor1);
+ ancestor1 = ancestor1.parentNode;
+ }
+ chain1.reverse();
+
+ var chain2 = [];
+ var ancestor2 = node2.parentNode;
+ while (ancestor2) {
+ if (!attr1 && ancestor2 === node1) {
+ return DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;
+ }
+ chain2.push(ancestor2);
+ ancestor2 = ancestor2.parentNode;
+ }
+ chain2.reverse();
+
+ var ca = commonAncestor(chain1, chain2);
+ for (var n in ca.childNodes) {
+ var child = ca.childNodes[n];
+ if (child === node2) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
+ if (child === node1) return DocumentPosition.DOCUMENT_POSITION_PRECEDING;
+ if (chain2.indexOf(child) >= 0) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
+ if (chain1.indexOf(child) >= 0) return DocumentPosition.DOCUMENT_POSITION_PRECEDING;
+ }
+ return 0;
+ },
+};
+
+/**
+ * Encodes special XML characters to their corresponding entities.
+ *
+ * @param {string} c
+ * The character to be encoded.
+ * @returns {string}
+ * The encoded character.
+ * @private
+ */
+function _xmlEncoder(c) {
+ return (
+ (c == '<' && '<') || (c == '>' && '>') || (c == '&' && '&') || (c == '"' && '"') || '' + c.charCodeAt() + ';'
+ );
+}
+
+copy(NodeType, Node);
+copy(NodeType, Node.prototype);
+copy(DocumentPosition, Node);
+copy(DocumentPosition, Node.prototype);
+
+/**
+ * Visits every node in the subtree rooted at `node` in depth-first pre-order.
+ *
+ * Delegates to {@link walkDOM} for traversal. The `callback` is called on each node;
+ * if it returns a truthy value, traversal stops immediately.
+ *
+ * @param {Node} node
+ * Root of the subtree to visit.
+ * @param {function(Node): *} callback
+ * Called for each node. A truthy return value stops traversal early.
+ */
+function _visitNode(node, callback) {
+ walkDOM(node, null, {
+ enter: function (n) {
+ return callback(n) ? walkDOM.STOP : true;
+ },
+ });
+}
+
+/**
+ * Depth-first pre/post-order DOM tree walker.
+ *
+ * Visits every node in the subtree rooted at `node`. For each node:
+ *
+ * 1. Calls `callbacks.enter(node, context)` before descending into the node's children. The
+ * return value becomes the `context` passed to each child's `enter` call and to the matching
+ * `exit` call.
+ * 2. If `enter` returns `null` or `undefined`, the node's children are skipped;
+ * sibling traversal continues normally.
+ * 3. If `enter` returns `walkDOM.STOP`, the entire traversal is aborted immediately — no
+ * further `enter` or `exit` calls are made.
+ * 4. `lastChild` and `previousSibling` are read **after** `enter` returns, so `enter` may
+ * safely modify the node's own child list before the walker descends. Modifying siblings of
+ * the current node or any other part of the tree produces unpredictable results: nodes already
+ * queued on the stack are visited regardless of DOM changes, and newly inserted nodes outside
+ * the current child list are never visited.
+ * 5. Calls `callbacks.exit(node, context)` (if provided) after all of a node's children have
+ * been visited, passing the same `context` that `enter`
+ * returned for that node.
+ *
+ * This implementation uses an explicit stack and does not recurse — it is safe on arbitrarily
+ * deep trees.
+ *
+ * @param {Node} node
+ * Root of the subtree to walk.
+ * @param {*} context
+ * Initial context value passed to the root node's `enter`.
+ * @param {{ enter: function(Node, *): *, exit?: function(Node, *): void }} callbacks
+ * @returns {void | walkDOM.STOP}
+ * @see ../docs/walk-dom.md.
+ */
+function walkDOM(node, context, callbacks) {
+ // Each stack frame is {node, context, phase}:
+ // walkDOM.ENTER — call enter, then push children
+ // walkDOM.EXIT — call exit
+ var stack = [{ node: node, context: context, phase: walkDOM.ENTER }];
+ while (stack.length > 0) {
+ var frame = stack.pop();
+ if (frame.phase === walkDOM.ENTER) {
+ var childContext = callbacks.enter(frame.node, frame.context);
+ if (childContext === walkDOM.STOP) {
+ return walkDOM.STOP;
+ }
+ // Push exit frame before children so it fires after all children are processed (Last In First Out)
+ stack.push({ node: frame.node, context: childContext, phase: walkDOM.EXIT });
+ if (childContext === null || childContext === undefined) {
+ continue; // skip children
+ }
+ // lastChild is read after enter returns, so enter may modify the child list.
+ var child = frame.node.lastChild;
+ // Traverse from lastChild backwards so that pushing onto the stack
+ // naturally yields firstChild on top (processed first).
+ while (child) {
+ stack.push({ node: child, context: childContext, phase: walkDOM.ENTER });
+ child = child.previousSibling;
+ }
+ } else {
+ // frame.phase === walkDOM.EXIT
+ if (callbacks.exit) {
+ callbacks.exit(frame.node, frame.context);
+ }
+ }
+ }
+}
+
+/**
+ * Sentinel value returned from a `walkDOM` `enter` callback to abort the entire traversal
+ * immediately.
+ *
+ * @type {symbol}
+ */
+walkDOM.STOP = Symbol('walkDOM.STOP');
+/**
+ * Phase constant for a stack frame that has not yet been visited.
+ * The `enter` callback is called and children are scheduled.
+ *
+ * @type {number}
+ */
+walkDOM.ENTER = 0;
+/**
+ * Phase constant for a stack frame whose subtree has been fully visited.
+ * The `exit` callback is called.
+ *
+ * @type {number}
+ */
+walkDOM.EXIT = 1;
+
+/**
+ * @typedef DocumentOptions
+ * @property {string} [contentType=MIME_TYPE.XML_APPLICATION]
+ */
+/**
+ * The Document interface describes the common properties and methods for any kind of document.
+ *
+ * It should usually be created using `new DOMImplementation().createDocument(...)`
+ * or `new DOMImplementation().createHTMLDocument(...)`.
+ *
+ * The constructor is considered a private API and offers to initially set the `contentType`
+ * property via it's options parameter.
+ *
+ * @class
+ * @param {Symbol} symbol
+ * @param {DocumentOptions} [options]
+ * @augments Node
+ * @private
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document
+ * @see https://dom.spec.whatwg.org/#interface-document
+ */
+function Document(symbol, options) {
+ checkSymbol(symbol);
+
+ var opt = options || {};
+ this.ownerDocument = this;
+ /**
+ * The mime type of the document is determined at creation time and can not be modified.
+ *
+ * @type {string}
+ * @see https://dom.spec.whatwg.org/#concept-document-content-type
+ * @see {@link DOMImplementation}
+ * @see {@link MIME_TYPE}
+ * @readonly
+ */
+ this.contentType = opt.contentType || MIME_TYPE.XML_APPLICATION;
+ /**
+ * @type {'html' | 'xml'}
+ * @see https://dom.spec.whatwg.org/#concept-document-type
+ * @see {@link DOMImplementation}
+ * @readonly
+ */
+ this.type = isHTMLMimeType(this.contentType) ? 'html' : 'xml';
+}
+
+/**
+ * Updates the namespace mapping of an element when a new attribute is added.
+ *
+ * @param {Document} doc
+ * The document that the element belongs to.
+ * @param {Element} el
+ * The element to which the attribute is being added.
+ * @param {Attr} newAttr
+ * The new attribute being added.
+ * @private
+ */
+function _onAddAttribute(doc, el, newAttr) {
+ doc && doc._inc++;
+ var ns = newAttr.namespaceURI;
+ if (ns === NAMESPACE.XMLNS) {
+ //update namespace
+ el._nsMap[newAttr.prefix ? newAttr.localName : ''] = newAttr.value;
+ }
+}
+
+/**
+ * Updates the namespace mapping of an element when an attribute is removed.
+ *
+ * @param {Document} doc
+ * The document that the element belongs to.
+ * @param {Element} el
+ * The element from which the attribute is being removed.
+ * @param {Attr} newAttr
+ * The attribute being removed.
+ * @param {boolean} remove
+ * Indicates whether the attribute is to be removed.
+ * @private
+ */
+function _onRemoveAttribute(doc, el, newAttr, remove) {
+ doc && doc._inc++;
+ var ns = newAttr.namespaceURI;
+ if (ns === NAMESPACE.XMLNS) {
+ //update namespace
+ delete el._nsMap[newAttr.prefix ? newAttr.localName : ''];
+ }
+}
+
+/**
+ * Updates `parent.childNodes`, adjusting the indexed items and its `length`.
+ * If `newChild` is provided and has no nextSibling, it will be appended.
+ * Otherwise, it's assumed that an item has been removed or inserted,
+ * and `parent.firstNode` and its `.nextSibling` to re-indexing all child nodes of `parent`.
+ *
+ * @param {Document} doc
+ * The parent document of `el`.
+ * @param {Node} parent
+ * The parent node whose childNodes list needs to be updated.
+ * @param {Node} [newChild]
+ * The new child node to be appended. If not provided, the function assumes a node has been
+ * removed.
+ * @private
+ */
+function _onUpdateChild(doc, parent, newChild) {
+ if (doc && doc._inc) {
+ doc._inc++;
+ var childNodes = parent.childNodes;
+ // assumes nextSibling and previousSibling were already configured upfront
+ if (newChild && !newChild.nextSibling) {
+ // if an item has been appended, we only need to update the last index and the length
+ childNodes[childNodes.length++] = newChild;
+ } else {
+ // otherwise we need to reindex all items,
+ // which can take a while when processing nodes with a lot of children
+ var child = parent.firstChild;
+ var i = 0;
+ while (child) {
+ childNodes[i++] = child;
+ child = child.nextSibling;
+ }
+ childNodes.length = i;
+ delete childNodes[childNodes.length];
+ }
+ }
+}
+
+/**
+ * Removes the connections between `parentNode` and `child`
+ * and any existing `child.previousSibling` or `child.nextSibling`.
+ *
+ * @param {Node} parentNode
+ * The parent node from which the child node is to be removed.
+ * @param {Node} child
+ * The child node to be removed from the parentNode.
+ * @returns {Node}
+ * Returns the child node that was removed.
+ * @throws {DOMException}
+ * With code:
+ * - {@link DOMException.NOT_FOUND_ERR} If the parentNode is not the parent of the child node.
+ * @private
+ * @see https://github.com/xmldom/xmldom/issues/135
+ * @see https://github.com/xmldom/xmldom/issues/145
+ */
+function _removeChild(parentNode, child) {
+ if (parentNode !== child.parentNode) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, "child's parent is not parent");
+ }
+ var oldPreviousSibling = child.previousSibling;
+ var oldNextSibling = child.nextSibling;
+ if (oldPreviousSibling) {
+ oldPreviousSibling.nextSibling = oldNextSibling;
+ } else {
+ parentNode.firstChild = oldNextSibling;
+ }
+ if (oldNextSibling) {
+ oldNextSibling.previousSibling = oldPreviousSibling;
+ } else {
+ parentNode.lastChild = oldPreviousSibling;
+ }
+ _onUpdateChild(parentNode.ownerDocument, parentNode);
+ child.parentNode = null;
+ child.previousSibling = null;
+ child.nextSibling = null;
+ return child;
+}
+
+/**
+ * Returns `true` if `node` can be a parent for insertion.
+ *
+ * @param {Node} node
+ * @returns {boolean}
+ */
+function hasValidParentNodeType(node) {
+ return (
+ node &&
+ (node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE)
+ );
+}
+
+/**
+ * Returns `true` if `node` can be inserted according to it's `nodeType`.
+ *
+ * @param {Node} node
+ * @returns {boolean}
+ */
+function hasInsertableNodeType(node) {
+ return (
+ node &&
+ (node.nodeType === Node.CDATA_SECTION_NODE ||
+ node.nodeType === Node.COMMENT_NODE ||
+ node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||
+ node.nodeType === Node.DOCUMENT_TYPE_NODE ||
+ node.nodeType === Node.ELEMENT_NODE ||
+ node.nodeType === Node.PROCESSING_INSTRUCTION_NODE ||
+ node.nodeType === Node.TEXT_NODE)
+ );
+}
+
+/**
+ * Returns true if `node` is a DOCTYPE node.
+ *
+ * @param {Node} node
+ * @returns {boolean}
+ */
+function isDocTypeNode(node) {
+ return node && node.nodeType === Node.DOCUMENT_TYPE_NODE;
+}
+
+/**
+ * Returns true if the node is an element.
+ *
+ * @param {Node} node
+ * @returns {boolean}
+ */
+function isElementNode(node) {
+ return node && node.nodeType === Node.ELEMENT_NODE;
+}
+/**
+ * Returns true if `node` is a text node.
+ *
+ * @param {Node} node
+ * @returns {boolean}
+ */
+function isTextNode(node) {
+ return node && node.nodeType === Node.TEXT_NODE;
+}
+
+/**
+ * Check if en element node can be inserted before `child`, or at the end if child is falsy,
+ * according to the presence and position of a doctype node on the same level.
+ *
+ * @param {Document} doc
+ * The document node.
+ * @param {Node} child
+ * The node that would become the nextSibling if the element would be inserted.
+ * @returns {boolean}
+ * `true` if an element can be inserted before child.
+ * @private
+ */
+function isElementInsertionPossible(doc, child) {
+ var parentChildNodes = doc.childNodes || [];
+ if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {
+ return false;
+ }
+ var docTypeNode = find(parentChildNodes, isDocTypeNode);
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
+}
+
+/**
+ * Check if en element node can be inserted before `child`, or at the end if child is falsy,
+ * according to the presence and position of a doctype node on the same level.
+ *
+ * @param {Node} doc
+ * The document node.
+ * @param {Node} child
+ * The node that would become the nextSibling if the element would be inserted.
+ * @returns {boolean}
+ * `true` if an element can be inserted before child.
+ * @private
+ */
+function isElementReplacementPossible(doc, child) {
+ var parentChildNodes = doc.childNodes || [];
+
+ function hasElementChildThatIsNotChild(node) {
+ return isElementNode(node) && node !== child;
+ }
+
+ if (find(parentChildNodes, hasElementChildThatIsNotChild)) {
+ return false;
+ }
+ var docTypeNode = find(parentChildNodes, isDocTypeNode);
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
+}
+
+/**
+ * Asserts pre-insertion validity of a node into a parent before a child.
+ * Throws errors for invalid node combinations that would result in an ill-formed DOM.
+ *
+ * @param {Node} parent
+ * The parent node to insert `node` into.
+ * @param {Node} node
+ * The node to insert.
+ * @param {Node | null} child
+ * The node that should become the `nextSibling` of `node`. If null, no sibling is considered.
+ * @throws {DOMException}
+ * With code:
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `parent` is not a Document,
+ * DocumentFragment, or Element node.
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a host-including inclusive
+ * ancestor of `parent`. (Currently not implemented)
+ * - {@link DOMException.NOT_FOUND_ERR} If `child` is non-null and its `parent` is not
+ * `parent`.
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is not a DocumentFragment,
+ * DocumentType, Element, or CharacterData node.
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If either `node` is a Text node and `parent` is
+ * a document, or if `node` is a doctype and `parent` is not a document.
+ * @private
+ * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
+ * @see https://dom.spec.whatwg.org/#concept-node-replace
+ */
+function assertPreInsertionValidity1to5(parent, node, child) {
+ // 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException.
+ if (!hasValidParentNodeType(parent)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType);
+ }
+ // 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a "HierarchyRequestError" DOMException.
+ // not implemented!
+ // 3. If `child` is non-null and its parent is not `parent`, then throw a "NotFoundError" DOMException.
+ if (child && child.parentNode !== parent) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, 'child not in parent');
+ }
+ if (
+ // 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException.
+ !hasInsertableNodeType(node) ||
+ // 5. If either `node` is a Text node and `parent` is a document,
+ // the sax parser currently adds top level text nodes, this will be fixed in 0.9.0
+ // || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)
+ // or `node` is a doctype and `parent` is not a document, then throw a "HierarchyRequestError" DOMException.
+ (isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE)
+ ) {
+ throw new DOMException(
+ DOMException.HIERARCHY_REQUEST_ERR,
+ 'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType
+ );
+ }
+}
+
+/**
+ * Asserts pre-insertion validity of a node into a document before a child.
+ * Throws errors for invalid node combinations that would result in an ill-formed DOM.
+ *
+ * @param {Document} parent
+ * The parent node to insert `node` into.
+ * @param {Node} node
+ * The node to insert.
+ * @param {Node | undefined} child
+ * The node that should become the `nextSibling` of `node`. If undefined, no sibling is
+ * considered.
+ * @returns {Node}
+ * @throws {DOMException}
+ * With code:
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentFragment with more than
+ * one element child or has a Text node child.
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentFragment with one
+ * element child and either `parent` has an element child, `child` is a doctype, or `child` is
+ * non-null and a doctype is following `child`.
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is an Element and `parent` has an
+ * element child, `child` is a doctype, or `child` is non-null and a doctype is following
+ * `child`.
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentType and `parent` has a
+ * doctype child, `child` is non-null and an element is preceding `child`, or `child` is null
+ * and `parent` has an element child.
+ * @private
+ * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
+ * @see https://dom.spec.whatwg.org/#concept-node-replace
+ */
+function assertPreInsertionValidityInDocument(parent, node, child) {
+ var parentChildNodes = parent.childNodes || [];
+ var nodeChildNodes = node.childNodes || [];
+
+ // DocumentFragment
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
+ var nodeChildElements = nodeChildNodes.filter(isElementNode);
+ // If node has more than one element child or has a Text node child.
+ if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');
+ }
+ // Otherwise, if `node` has one element child and either `parent` has an element child,
+ // `child` is a doctype, or `child` is non-null and a doctype is following `child`.
+ if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');
+ }
+ }
+ // Element
+ if (isElementNode(node)) {
+ // `parent` has an element child, `child` is a doctype,
+ // or `child` is non-null and a doctype is following `child`.
+ if (!isElementInsertionPossible(parent, child)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');
+ }
+ }
+ // DocumentType
+ if (isDocTypeNode(node)) {
+ // `parent` has a doctype child,
+ if (find(parentChildNodes, isDocTypeNode)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');
+ }
+ var parentElementChild = find(parentChildNodes, isElementNode);
+ // `child` is non-null and an element is preceding `child`,
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');
+ }
+ // or `child` is null and `parent` has an element child.
+ if (!child && parentElementChild) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present');
+ }
+ }
+}
+
+/**
+ * @param {Document} parent
+ * The parent node to insert `node` into.
+ * @param {Node} node
+ * The node to insert.
+ * @param {Node | undefined} child
+ * the node that should become the `nextSibling` of `node`
+ * @returns {Node}
+ * @throws {DOMException}
+ * For several node combinations that would create a DOM that is not well-formed.
+ * @throws {DOMException}
+ * If `child` is provided but is not a child of `parent`.
+ * @private
+ * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
+ * @see https://dom.spec.whatwg.org/#concept-node-replace
+ */
+function assertPreReplacementValidityInDocument(parent, node, child) {
+ var parentChildNodes = parent.childNodes || [];
+ var nodeChildNodes = node.childNodes || [];
+
+ // DocumentFragment
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
+ var nodeChildElements = nodeChildNodes.filter(isElementNode);
+ // If `node` has more than one element child or has a Text node child.
+ if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');
+ }
+ // Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`.
+ if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');
+ }
+ }
+ // Element
+ if (isElementNode(node)) {
+ // `parent` has an element child that is not `child` or a doctype is following `child`.
+ if (!isElementReplacementPossible(parent, child)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');
+ }
+ }
+ // DocumentType
+ if (isDocTypeNode(node)) {
+ function hasDoctypeChildThatIsNotChild(node) {
+ return isDocTypeNode(node) && node !== child;
+ }
+
+ // `parent` has a doctype child that is not `child`,
+ if (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');
+ }
+ var parentElementChild = find(parentChildNodes, isElementNode);
+ // or an element is preceding `child`.
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');
+ }
+ }
+}
+
+/**
+ * Inserts a node into a parent node before a child node.
+ *
+ * @param {Node} parent
+ * The parent node to insert the node into.
+ * @param {Node} node
+ * The node to insert into the parent.
+ * @param {Node | null} child
+ * The node that should become the next sibling of the node.
+ * If null, the function inserts the node at the end of the children of the parent node.
+ * @param {Function} [_inDocumentAssertion]
+ * An optional function to check pre-insertion validity if parent is a document node.
+ * Defaults to {@link assertPreInsertionValidityInDocument}
+ * @returns {Node}
+ * Returns the inserted node.
+ * @throws {DOMException}
+ * Throws a DOMException if inserting the node would result in a DOM tree that is not
+ * well-formed. See {@link assertPreInsertionValidity1to5},
+ * {@link assertPreInsertionValidityInDocument}.
+ * @throws {DOMException}
+ * Throws a DOMException if child is provided but is not a child of the parent. See
+ * {@link Node.removeChild}
+ * @private
+ * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
+ */
+function _insertBefore(parent, node, child, _inDocumentAssertion) {
+ // To ensure pre-insertion validity of a node into a parent before a child, run these steps:
+ assertPreInsertionValidity1to5(parent, node, child);
+
+ // If parent is a document, and any of the statements below, switched on the interface node implements,
+ // are true, then throw a "HierarchyRequestError" DOMException.
+ if (parent.nodeType === Node.DOCUMENT_NODE) {
+ (_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);
+ }
+
+ var cp = node.parentNode;
+ if (cp) {
+ cp.removeChild(node); //remove and update
+ }
+ if (node.nodeType === DOCUMENT_FRAGMENT_NODE) {
+ var newFirst = node.firstChild;
+ if (newFirst == null) {
+ return node;
+ }
+ var newLast = node.lastChild;
+ } else {
+ newFirst = newLast = node;
+ }
+ var pre = child ? child.previousSibling : parent.lastChild;
+
+ newFirst.previousSibling = pre;
+ newLast.nextSibling = child;
+
+ if (pre) {
+ pre.nextSibling = newFirst;
+ } else {
+ parent.firstChild = newFirst;
+ }
+ if (child == null) {
+ parent.lastChild = newLast;
+ } else {
+ child.previousSibling = newLast;
+ }
+ do {
+ newFirst.parentNode = parent;
+ } while (newFirst !== newLast && (newFirst = newFirst.nextSibling));
+ _onUpdateChild(parent.ownerDocument || parent, parent, node);
+ if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
+ node.firstChild = node.lastChild = null;
+ }
+
+ return node;
+}
+
+Document.prototype = {
+ /**
+ * The implementation that created this document.
+ *
+ * @type DOMImplementation
+ * @readonly
+ */
+ implementation: null,
+ nodeName: '#document',
+ nodeType: DOCUMENT_NODE,
+ /**
+ * The DocumentType node of the document.
+ *
+ * @type DocumentType
+ * @readonly
+ */
+ doctype: null,
+ documentElement: null,
+ _inc: 1,
+
+ insertBefore: function (newChild, refChild) {
+ //raises
+ if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
+ var child = newChild.firstChild;
+ while (child) {
+ var next = child.nextSibling;
+ this.insertBefore(child, refChild);
+ child = next;
+ }
+ return newChild;
+ }
+ _insertBefore(this, newChild, refChild);
+ newChild.ownerDocument = this;
+ if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {
+ this.documentElement = newChild;
+ }
+
+ return newChild;
+ },
+ removeChild: function (oldChild) {
+ var removed = _removeChild(this, oldChild);
+ if (removed === this.documentElement) {
+ this.documentElement = null;
+ }
+ return removed;
+ },
+ replaceChild: function (newChild, oldChild) {
+ //raises
+ _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
+ newChild.ownerDocument = this;
+ if (oldChild) {
+ this.removeChild(oldChild);
+ }
+ if (isElementNode(newChild)) {
+ this.documentElement = newChild;
+ }
+ },
+ /**
+ * Imports a node from another document into this document, creating a new copy owned by this
+ * document. The source node and its subtree are not modified.
+ *
+ * @param {Node} importedNode
+ * The node to import.
+ * @param {boolean} deep
+ * If true, the contents of the node are recursively imported.
+ * If false, only the node itself (and its attributes, if it is an element) are imported.
+ * @returns {Node}
+ * Returns the newly created import of the node.
+ * @see {@link importNode}
+ * @see {@link https://dom.spec.whatwg.org/#dom-document-importnode}
+ */
+ importNode: function (importedNode, deep) {
+ return importNode(this, importedNode, deep);
+ },
+ // Introduced in DOM Level 2:
+ getElementById: function (id) {
+ var rtv = null;
+ _visitNode(this.documentElement, function (node) {
+ if (node.nodeType == ELEMENT_NODE) {
+ if (node.getAttribute('id') == id) {
+ rtv = node;
+ return true;
+ }
+ }
+ });
+ return rtv;
+ },
+
+ /**
+ * Creates a new `Element` that is owned by this `Document`.
+ * In HTML Documents `localName` is the lower cased `tagName`,
+ * otherwise no transformation is being applied.
+ * When `contentType` implies the HTML namespace, it will be set as `namespaceURI`.
+ *
+ * __This implementation differs from the specification:__ - The provided name is not checked
+ * against the `Name` production,
+ * so no related error will be thrown.
+ * - There is no interface `HTMLElement`, it is always an `Element`.
+ * - There is no support for a second argument to indicate using custom elements.
+ *
+ * @param {string} tagName
+ * @returns {Element}
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement
+ * @see https://dom.spec.whatwg.org/#dom-document-createelement
+ * @see https://dom.spec.whatwg.org/#concept-create-element
+ */
+ createElement: function (tagName) {
+ var node = new Element(PDC);
+ node.ownerDocument = this;
+ if (this.type === 'html') {
+ tagName = tagName.toLowerCase();
+ }
+ if (hasDefaultHTMLNamespace(this.contentType)) {
+ node.namespaceURI = NAMESPACE.HTML;
+ }
+ node.nodeName = tagName;
+ node.tagName = tagName;
+ node.localName = tagName;
+ node.childNodes = new NodeList();
+ var attrs = (node.attributes = new NamedNodeMap());
+ attrs._ownerElement = node;
+ return node;
+ },
+ /**
+ * @returns {DocumentFragment}
+ */
+ createDocumentFragment: function () {
+ var node = new DocumentFragment(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ return node;
+ },
+ /**
+ * @param {string} data
+ * @returns {Text}
+ */
+ createTextNode: function (data) {
+ var node = new Text(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.appendData(data);
+ return node;
+ },
+ /**
+ * @param {string} data
+ * @returns {Comment}
+ * @see https://dom.spec.whatwg.org/#dom-document-createcomment
+ * @see https://www.w3.org/TR/xml/#NT-Comment XML 1.0 production [15]
+ * @see https://www.w3.org/TR/DOM-Parsing/#dfn-concept-serialize-xml §3.2.1.3
+ *
+ * Note: no validation is performed at creation time. When the resulting document is
+ * serialized with `requireWellFormed: true`, the serializer throws `InvalidStateError`
+ * if the comment data contains `--` anywhere, ends with `-`, or contains characters
+ * outside the XML Char production (W3C DOM Parsing §3.2.1.3). Without that option the
+ * data is emitted verbatim.
+ */
+ createComment: function (data) {
+ var node = new Comment(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.appendData(data);
+ return node;
+ },
+ /**
+ * Returns a new CDATASection node whose data is `data`.
+ *
+ * __This implementation differs from the specification:__ - calling this method on an HTML
+ * document does not throw `NotSupportedError`.
+ *
+ * @param {string} data
+ * @returns {CDATASection}
+ * @throws {DOMException}
+ * With code `INVALID_CHARACTER_ERR` if `data` contains `"]]>"`.
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection
+ * @see https://dom.spec.whatwg.org/#dom-document-createcdatasection
+ */
+ createCDATASection: function (data) {
+ if (data.indexOf(']]>') !== -1) {
+ throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 'data contains "]]>"');
+ }
+ var node = new CDATASection(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.appendData(data);
+ return node;
+ },
+ /**
+ * Returns a ProcessingInstruction node whose target is target and data is data.
+ *
+ * __This behavior is slightly different from the in the specs__:
+ * - it does not do any input validation on the arguments and doesn't throw
+ * "InvalidCharacterError".
+ *
+ * Note: When the resulting document is serialized with `requireWellFormed: true`, the
+ * serializer throws `InvalidStateError` if `.target` contains `:` or is an ASCII
+ * case-insensitive match for `"xml"`, or if `.data` contains `?>` or characters outside the
+ * XML Char production (W3C DOM Parsing §3.2.1.7). Without that option the data is emitted
+ * verbatim.
+ *
+ * @param {string} target
+ * @param {string} data
+ * @returns {ProcessingInstruction}
+ * @see https://developer.mozilla.org/docs/Web/API/Document/createProcessingInstruction
+ * @see https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
+ * @see https://www.w3.org/TR/DOM-Parsing/#dfn-concept-serialize-xml §3.2.1.7
+ */
+ createProcessingInstruction: function (target, data) {
+ var node = new ProcessingInstruction(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.nodeName = node.target = target;
+ node.nodeValue = node.data = data;
+ return node;
+ },
+ /**
+ * Creates an `Attr` node that is owned by this document.
+ * In HTML Documents `localName` is the lower cased `name`,
+ * otherwise no transformation is being applied.
+ *
+ * __This implementation differs from the specification:__ - The provided name is not checked
+ * against the `Name` production,
+ * so no related error will be thrown.
+ *
+ * @param {string} name
+ * @returns {Attr}
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createAttribute
+ * @see https://dom.spec.whatwg.org/#dom-document-createattribute
+ */
+ createAttribute: function (name) {
+ if (!g.QName_exact.test(name)) {
+ throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in name "' + name + '"');
+ }
+ if (this.type === 'html') {
+ name = name.toLowerCase();
+ }
+ return this._createAttribute(name);
+ },
+ _createAttribute: function (name) {
+ var node = new Attr(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.name = name;
+ node.nodeName = name;
+ node.localName = name;
+ node.specified = true;
+ return node;
+ },
+ /**
+ * Creates an EntityReference object.
+ * The current implementation does not fill the `childNodes` with those of the corresponding
+ * `Entity`
+ *
+ * @deprecated
+ * In DOM Level 4.
+ * @param {string} name
+ * The name of the entity to reference. No namespace well-formedness checks are performed.
+ * @returns {EntityReference}
+ * @throws {DOMException}
+ * With code `INVALID_CHARACTER_ERR` when `name` is not valid.
+ * @throws {DOMException}
+ * with code `NOT_SUPPORTED_ERR` when the document is of type `html`
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE
+ */
+ createEntityReference: function (name) {
+ if (!g.Name.test(name)) {
+ throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 'not a valid xml name "' + name + '"');
+ }
+ if (this.type === 'html') {
+ throw new DOMException('document is an html document', DOMExceptionName.NotSupportedError);
+ }
+
+ var node = new EntityReference(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.nodeName = name;
+ return node;
+ },
+ // Introduced in DOM Level 2:
+ /**
+ * @param {string} namespaceURI
+ * @param {string} qualifiedName
+ * @returns {Element}
+ */
+ createElementNS: function (namespaceURI, qualifiedName) {
+ var validated = validateAndExtract(namespaceURI, qualifiedName);
+ var node = new Element(PDC);
+ var attrs = (node.attributes = new NamedNodeMap());
+ node.childNodes = new NodeList();
+ node.ownerDocument = this;
+ node.nodeName = qualifiedName;
+ node.tagName = qualifiedName;
+ node.namespaceURI = validated[0];
+ node.prefix = validated[1];
+ node.localName = validated[2];
+ attrs._ownerElement = node;
+ return node;
+ },
+ // Introduced in DOM Level 2:
+ /**
+ * @param {string} namespaceURI
+ * @param {string} qualifiedName
+ * @returns {Attr}
+ */
+ createAttributeNS: function (namespaceURI, qualifiedName) {
+ var validated = validateAndExtract(namespaceURI, qualifiedName);
+ var node = new Attr(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.nodeName = qualifiedName;
+ node.name = qualifiedName;
+ node.specified = true;
+ node.namespaceURI = validated[0];
+ node.prefix = validated[1];
+ node.localName = validated[2];
+ return node;
+ },
+};
+_extends(Document, Node);
+
+function Element(symbol) {
+ checkSymbol(symbol);
+
+ this._nsMap = Object.create(null);
+}
+Element.prototype = {
+ nodeType: ELEMENT_NODE,
+ /**
+ * The attributes of this element.
+ *
+ * @type {NamedNodeMap | null}
+ */
+ attributes: null,
+ getQualifiedName: function () {
+ return this.prefix ? this.prefix + ':' + this.localName : this.localName;
+ },
+ _isInHTMLDocumentAndNamespace: function () {
+ return this.ownerDocument.type === 'html' && this.namespaceURI === NAMESPACE.HTML;
+ },
+ /**
+ * Implementaton of Level2 Core function hasAttributes.
+ *
+ * @returns {boolean}
+ * True if attribute list is not empty.
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-NodeHasAttrs
+ */
+ hasAttributes: function () {
+ return !!(this.attributes && this.attributes.length);
+ },
+ hasAttribute: function (name) {
+ return !!this.getAttributeNode(name);
+ },
+ /**
+ * Returns element’s first attribute whose qualified name is `name`, and `null`
+ * if there is no such attribute.
+ *
+ * @param {string} name
+ * @returns {string | null}
+ */
+ getAttribute: function (name) {
+ var attr = this.getAttributeNode(name);
+ return attr ? attr.value : null;
+ },
+ getAttributeNode: function (name) {
+ if (this._isInHTMLDocumentAndNamespace()) {
+ name = name.toLowerCase();
+ }
+ return this.attributes.getNamedItem(name);
+ },
+ /**
+ * Sets the value of element’s first attribute whose qualified name is qualifiedName to value.
+ *
+ * @param {string} name
+ * @param {string} value
+ */
+ setAttribute: function (name, value) {
+ if (this._isInHTMLDocumentAndNamespace()) {
+ name = name.toLowerCase();
+ }
+ var attr = this.getAttributeNode(name);
+ if (attr) {
+ attr.value = attr.nodeValue = '' + value;
+ } else {
+ attr = this.ownerDocument._createAttribute(name);
+ attr.value = attr.nodeValue = '' + value;
+ this.setAttributeNode(attr);
+ }
+ },
+ removeAttribute: function (name) {
+ var attr = this.getAttributeNode(name);
+ attr && this.removeAttributeNode(attr);
+ },
+ setAttributeNode: function (newAttr) {
+ return this.attributes.setNamedItem(newAttr);
+ },
+ setAttributeNodeNS: function (newAttr) {
+ return this.attributes.setNamedItemNS(newAttr);
+ },
+ removeAttributeNode: function (oldAttr) {
+ //console.log(this == oldAttr.ownerElement)
+ return this.attributes.removeNamedItem(oldAttr.nodeName);
+ },
+ //get real attribute name,and remove it by removeAttributeNode
+ removeAttributeNS: function (namespaceURI, localName) {
+ var old = this.getAttributeNodeNS(namespaceURI, localName);
+ old && this.removeAttributeNode(old);
+ },
+
+ hasAttributeNS: function (namespaceURI, localName) {
+ return this.getAttributeNodeNS(namespaceURI, localName) != null;
+ },
+ /**
+ * Returns element’s attribute whose namespace is `namespaceURI` and local name is
+ * `localName`,
+ * or `null` if there is no such attribute.
+ *
+ * @param {string} namespaceURI
+ * @param {string} localName
+ * @returns {string | null}
+ */
+ getAttributeNS: function (namespaceURI, localName) {
+ var attr = this.getAttributeNodeNS(namespaceURI, localName);
+ return attr ? attr.value : null;
+ },
+ /**
+ * Sets the value of element’s attribute whose namespace is `namespaceURI` and local name is
+ * `localName` to value.
+ *
+ * @param {string} namespaceURI
+ * @param {string} qualifiedName
+ * @param {string} value
+ * @see https://dom.spec.whatwg.org/#dom-element-setattributens
+ */
+ setAttributeNS: function (namespaceURI, qualifiedName, value) {
+ var validated = validateAndExtract(namespaceURI, qualifiedName);
+ var localName = validated[2];
+ var attr = this.getAttributeNodeNS(namespaceURI, localName);
+ if (attr) {
+ attr.value = attr.nodeValue = '' + value;
+ } else {
+ attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
+ attr.value = attr.nodeValue = '' + value;
+ this.setAttributeNode(attr);
+ }
+ },
+ getAttributeNodeNS: function (namespaceURI, localName) {
+ return this.attributes.getNamedItemNS(namespaceURI, localName);
+ },
+
+ /**
+ * Returns a LiveNodeList of all child elements which have **all** of the given class name(s).
+ *
+ * Returns an empty list if `classNames` is an empty string or only contains HTML white space
+ * characters.
+ *
+ * Warning: This returns a live LiveNodeList.
+ * Changes in the DOM will reflect in the array as the changes occur.
+ * If an element selected by this array no longer qualifies for the selector,
+ * it will automatically be removed. Be aware of this for iteration purposes.
+ *
+ * @param {string} classNames
+ * Is a string representing the class name(s) to match; multiple class names are separated by
+ * (ASCII-)whitespace.
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
+ * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
+ */
+ getElementsByClassName: function (classNames) {
+ var classNamesSet = toOrderedSet(classNames);
+ return new LiveNodeList(this, function (base) {
+ var ls = [];
+ if (classNamesSet.length > 0) {
+ _visitNode(base, function (node) {
+ if (node !== base && node.nodeType === ELEMENT_NODE) {
+ var nodeClassNames = node.getAttribute('class');
+ // can be null if the attribute does not exist
+ if (nodeClassNames) {
+ // before splitting and iterating just compare them for the most common case
+ var matches = classNames === nodeClassNames;
+ if (!matches) {
+ var nodeClassNamesSet = toOrderedSet(nodeClassNames);
+ matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
+ }
+ if (matches) {
+ ls.push(node);
+ }
+ }
+ }
+ });
+ }
+ return ls;
+ });
+ },
+
+ /**
+ * Returns a LiveNodeList of elements with the given qualifiedName.
+ * Searching for all descendants can be done by passing `*` as `qualifiedName`.
+ *
+ * All descendants of the specified element are searched, but not the element itself.
+ * The returned list is live, which means it updates itself with the DOM tree automatically.
+ * Therefore, there is no need to call `Element.getElementsByTagName()`
+ * with the same element and arguments repeatedly if the DOM changes in between calls.
+ *
+ * When called on an HTML element in an HTML document,
+ * `getElementsByTagName` lower-cases the argument before searching for it.
+ * This is undesirable when trying to match camel-cased SVG elements (such as
+ * ``) in an HTML document.
+ * Instead, use `Element.getElementsByTagNameNS()`,
+ * which preserves the capitalization of the tag name.
+ *
+ * `Element.getElementsByTagName` is similar to `Document.getElementsByTagName()`,
+ * except that it only searches for elements that are descendants of the specified element.
+ *
+ * @param {string} qualifiedName
+ * @returns {LiveNodeList}
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName
+ * @see https://dom.spec.whatwg.org/#concept-getelementsbytagname
+ */
+ getElementsByTagName: function (qualifiedName) {
+ var isHTMLDocument = (this.nodeType === DOCUMENT_NODE ? this : this.ownerDocument).type === 'html';
+ var lowerQualifiedName = qualifiedName.toLowerCase();
+ return new LiveNodeList(this, function (base) {
+ var ls = [];
+ _visitNode(base, function (node) {
+ if (node === base || node.nodeType !== ELEMENT_NODE) {
+ return;
+ }
+ if (qualifiedName === '*') {
+ ls.push(node);
+ } else {
+ var nodeQualifiedName = node.getQualifiedName();
+ var matchingQName = isHTMLDocument && node.namespaceURI === NAMESPACE.HTML ? lowerQualifiedName : qualifiedName;
+ if (nodeQualifiedName === matchingQName) {
+ ls.push(node);
+ }
+ }
+ });
+ return ls;
+ });
+ },
+ getElementsByTagNameNS: function (namespaceURI, localName) {
+ return new LiveNodeList(this, function (base) {
+ var ls = [];
+ _visitNode(base, function (node) {
+ if (
+ node !== base &&
+ node.nodeType === ELEMENT_NODE &&
+ (namespaceURI === '*' || node.namespaceURI === namespaceURI) &&
+ (localName === '*' || node.localName == localName)
+ ) {
+ ls.push(node);
+ }
+ });
+ return ls;
+ });
+ },
+};
+Document.prototype.getElementsByClassName = Element.prototype.getElementsByClassName;
+Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
+Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
+
+_extends(Element, Node);
+function Attr(symbol) {
+ checkSymbol(symbol);
+
+ this.namespaceURI = null;
+ this.prefix = null;
+ this.ownerElement = null;
+}
+Attr.prototype.nodeType = ATTRIBUTE_NODE;
+_extends(Attr, Node);
+
+function CharacterData(symbol) {
+ checkSymbol(symbol);
+}
+CharacterData.prototype = {
+ data: '',
+ substringData: function (offset, count) {
+ return this.data.substring(offset, offset + count);
+ },
+ appendData: function (text) {
+ text = this.data + text;
+ this.nodeValue = this.data = text;
+ this.length = text.length;
+ },
+ insertData: function (offset, text) {
+ this.replaceData(offset, 0, text);
+ },
+ deleteData: function (offset, count) {
+ this.replaceData(offset, count, '');
+ },
+ replaceData: function (offset, count, text) {
+ var start = this.data.substring(0, offset);
+ var end = this.data.substring(offset + count);
+ text = start + text + end;
+ this.nodeValue = this.data = text;
+ this.length = text.length;
+ },
+};
+_extends(CharacterData, Node);
+function Text(symbol) {
+ checkSymbol(symbol);
+}
+Text.prototype = {
+ nodeName: '#text',
+ nodeType: TEXT_NODE,
+ splitText: function (offset) {
+ var text = this.data;
+ var newText = text.substring(offset);
+ text = text.substring(0, offset);
+ this.data = this.nodeValue = text;
+ this.length = text.length;
+ var newNode = this.ownerDocument.createTextNode(newText);
+ if (this.parentNode) {
+ this.parentNode.insertBefore(newNode, this.nextSibling);
+ }
+ return newNode;
+ },
+};
+_extends(Text, CharacterData);
+function Comment(symbol) {
+ checkSymbol(symbol);
+}
+Comment.prototype = {
+ nodeName: '#comment',
+ nodeType: COMMENT_NODE,
+};
+_extends(Comment, CharacterData);
+
+function CDATASection(symbol) {
+ checkSymbol(symbol);
+}
+CDATASection.prototype = {
+ nodeName: '#cdata-section',
+ nodeType: CDATA_SECTION_NODE,
+};
+_extends(CDATASection, Text);
+
+/**
+ * @class DocumentType
+ * @augments Node
+ * @property {string} publicId
+ * The external subset public identifier, stored verbatim (including surrounding quotes).
+ * Declared `readonly` by the WHATWG DOM spec; xmldom does not enforce this constraint —
+ * direct property writes succeed and the written value is serialized verbatim.
+ * When serialized with `requireWellFormed: true`, the serializer validates the value against
+ * the XML `PubidLiteral` production and throws `InvalidStateError` if it does not match.
+ * @property {string} systemId
+ * The external subset system identifier, stored verbatim (including surrounding quotes).
+ * Declared `readonly` by the WHATWG DOM spec; xmldom does not enforce this constraint —
+ * direct property writes succeed and the written value is serialized verbatim.
+ * When serialized with `requireWellFormed: true`, the serializer validates the value against
+ * the XML `SystemLiteral` production and throws `InvalidStateError` if it does not match.
+ * @property {string} internalSubset
+ * The internal subset string (the raw content between `[` and `]`), or an empty string.
+ * Declared `readonly` by the WHATWG DOM spec; xmldom does not enforce this constraint —
+ * direct property writes succeed and the written value is serialized verbatim.
+ * When serialized with `requireWellFormed: true`, the serializer throws `InvalidStateError`
+ * if the value contains `"]>"`.
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DocumentType MDN
+ * @see https://dom.spec.whatwg.org/#interface-documenttype WHATWG DOM
+ * @prettierignore
+ */
+function DocumentType(symbol) {
+ checkSymbol(symbol);
+}
+DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
+_extends(DocumentType, Node);
+
+function Notation(symbol) {
+ checkSymbol(symbol);
+}
+Notation.prototype.nodeType = NOTATION_NODE;
+_extends(Notation, Node);
+
+function Entity(symbol) {
+ checkSymbol(symbol);
+}
+Entity.prototype.nodeType = ENTITY_NODE;
+_extends(Entity, Node);
+
+function EntityReference(symbol) {
+ checkSymbol(symbol);
+}
+EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
+_extends(EntityReference, Node);
+
+function DocumentFragment(symbol) {
+ checkSymbol(symbol);
+}
+DocumentFragment.prototype.nodeName = '#document-fragment';
+DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
+_extends(DocumentFragment, Node);
+
+function ProcessingInstruction(symbol) {
+ checkSymbol(symbol);
+}
+ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
+_extends(ProcessingInstruction, CharacterData);
+function XMLSerializer() {}
+/**
+ * Returns the result of serializing `node` to XML.
+ *
+ * When `options.requireWellFormed` is `true`, the serializer throws `InvalidStateError` for
+ * content that would produce ill-formed XML (e.g. CDATASection data containing `"]]>"`, Text
+ * data containing characters outside the XML Char production, or a Document with no
+ * `documentElement`).
+ *
+ * When `options.splitCDATASections` is `false`, CDATASection data is emitted verbatim even
+ * when it contains `"]]>"`. When `true` (the default), `"]]>"` sequences are split across
+ * concatenated CDATA sections — this behavior is **deprecated** and will be removed in the
+ * next breaking release. Callers should migrate to `{ requireWellFormed: true }`, which throws
+ * `InvalidStateError` instead of transforming.
+ *
+ * __This implementation differs from the specification:__ - CDATASection serialization is not
+ * specified by W3C DOM Parsing or WHATWG DOM Parsing (see
+ * {@link https://github.com/w3c/DOM-Parsing/issues/38 w3c/DOM-Parsing#38}).
+ * When `splitCDATASections` is `true` (the default), `"]]>"` sequences in CDATASection data
+ * are split across concatenated CDATA sections — this mechanism is derived from DOM Level 3
+ * Core and is **deprecated**. The split mechanics will be removed in the next breaking
+ * release. Callers that rely on this behavior should migrate to `{ requireWellFormed: true }`.
+ * - W3C DOM Parsing §3.2.1.1 requires well-formedness checks on Element `localName`s,
+ * prefixes,
+ * and attribute serialization (duplicate attributes, namespace declarations, attribute value
+ * characters) when `requireWellFormed` is `true`. These checks are **not implemented** in this
+ * release — see the tracking issue filed against the next breaking milestone.
+ *
+ * @param {Node} node
+ * @param {Object | function} [options]
+ * Options object, or a legacy nodeFilter function (backward compatible).
+ * @param {boolean} [options.requireWellFormed=false]
+ * When `true`, throws `InvalidStateError` for content that would produce ill-formed XML.
+ * @param {boolean} [options.splitCDATASections=true]
+ * When `true` (default), splits `"]]>"` sequences in CDATASection data across concatenated
+ * CDATA sections. **Deprecated** — will be removed in the next breaking release.
+ * @param {function} [options.nodeFilter]
+ * A filter function applied to each node before serialization.
+ * @returns {string}
+ * @throws {DOMException}
+ * With name `InvalidStateError` when `requireWellFormed` is `true` and any of the following
+ * conditions hold:
+ * - CDATASection data contains `"]]>"`
+ * - Text data contains characters outside the XML Char production
+ * - a Comment node's data contains `--` anywhere or ends with `-`
+ * - a ProcessingInstruction's target contains `:` or is an ASCII case-insensitive match for
+ * `"xml"`, or its data contains `?>` or characters outside the XML Char production
+ * - a DocumentType's `publicId` is non-empty and does not match the XML `PubidLiteral`
+ * production (W3C DOM Parsing §3.2.1.3; XML 1.0 production [12])
+ * - a DocumentType's `systemId` is non-empty and does not match the XML `SystemLiteral`
+ * production (W3C DOM Parsing §3.2.1.3; XML 1.0 production [11])
+ * - a DocumentType's `internalSubset` contains `"]>"`
+ * - the Document has no `documentElement`
+ * @see https://developer.mozilla.org/docs/Web/API/XMLSerializer/serializeToString
+ * @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
+ * @see https://github.com/w3c/DOM-Parsing/issues/84
+ * @prettierignore
+ */
+XMLSerializer.prototype.serializeToString = function (node, options) {
+ return nodeSerializeToString.call(node, options);
+};
+Node.prototype.toString = nodeSerializeToString;
+function nodeSerializeToString(options) {
+ // Normalize the user-supplied options into a single internal opts object so that the
+ // internal serializer always works with a consistent shape rather than positional flags.
+ var opts;
+ if (typeof options === 'function') {
+ opts = { requireWellFormed: false, splitCDATASections: true, nodeFilter: options };
+ } else if (options != null) {
+ opts = {
+ requireWellFormed: !!options.requireWellFormed,
+ splitCDATASections: options.splitCDATASections !== false,
+ nodeFilter: options.nodeFilter || null,
+ };
+ } else {
+ opts = { requireWellFormed: false, splitCDATASections: true, nodeFilter: null };
+ }
+ var buf = [];
+ var refNode = (this.nodeType === DOCUMENT_NODE && this.documentElement) || this;
+ var prefix = refNode.prefix;
+ var uri = refNode.namespaceURI;
+
+ if (uri && prefix == null) {
+ var prefix = refNode.lookupPrefix(uri);
+ if (prefix == null) {
+ var visibleNamespaces = [
+ { namespace: uri, prefix: null },
+ //{namespace:uri,prefix:''}
+ ];
+ }
+ }
+ serializeToString(this, buf, visibleNamespaces, opts);
+ return buf.join('');
+}
+
+function needNamespaceDefine(node, isHTML, visibleNamespaces) {
+ var prefix = node.prefix || '';
+ var uri = node.namespaceURI;
+ // According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,
+ // and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :
+ // > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.
+ // in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)
+ // and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :
+ // > [...] Furthermore, the attribute value [...] must not be an empty string.
+ // so serializing empty namespace value like xmlns:ds="" would produce an invalid XML document.
+ if (!uri) {
+ return false;
+ }
+ if ((prefix === 'xml' && uri === NAMESPACE.XML) || uri === NAMESPACE.XMLNS) {
+ return false;
+ }
+
+ var i = visibleNamespaces.length;
+ while (i--) {
+ var ns = visibleNamespaces[i];
+ // get namespace prefix
+ if (ns.prefix === prefix) {
+ return ns.namespace !== uri;
+ }
+ }
+ return true;
+}
+/**
+ * Literal whitespace other than space that appear in attribute values are serialized as
+ * their entity references, so they will be preserved.
+ * (In contrast to whitespace literals in the input which are normalized to spaces).
+ *
+ * Well-formed constraint: No < in Attribute Values:
+ * > The replacement text of any entity referred to directly or indirectly
+ * > in an attribute value must not contain a <.
+ *
+ * @see https://www.w3.org/TR/xml11/#CleanAttrVals
+ * @see https://www.w3.org/TR/xml11/#NT-AttValue
+ * @see https://www.w3.org/TR/xml11/#AVNormalize
+ * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes
+ * @prettierignore
+ */
+function addSerializedAttribute(buf, qualifiedName, value) {
+ buf.push(' ', qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"');
+}
+
+function serializeToString(node, buf, visibleNamespaces, opts) {
+ if (!visibleNamespaces) {
+ visibleNamespaces = [];
+ }
+ var nodeFilter = opts.nodeFilter;
+ var requireWellFormed = opts.requireWellFormed;
+ var splitCDATASections = opts.splitCDATASections;
+ var doc = node.nodeType === DOCUMENT_NODE ? node : node.ownerDocument;
+ var isHTML = doc.type === 'html';
+
+ walkDOM(
+ node,
+ { ns: visibleNamespaces },
+ {
+ enter: function (n, ctx) {
+ var namespaces = ctx.ns;
+
+ if (nodeFilter) {
+ n = nodeFilter(n);
+ if (n) {
+ if (typeof n == 'string') {
+ buf.push(n);
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ switch (n.nodeType) {
+ case ELEMENT_NODE:
+ var attrs = n.attributes;
+ var len = attrs.length;
+ var nodeName = n.tagName;
+
+ var prefixedNodeName = nodeName;
+ if (!isHTML && !n.prefix && n.namespaceURI) {
+ var defaultNS;
+ // lookup current default ns from `xmlns` attribute
+ for (var ai = 0; ai < attrs.length; ai++) {
+ if (attrs.item(ai).name === 'xmlns') {
+ defaultNS = attrs.item(ai).value;
+ break;
+ }
+ }
+ if (!defaultNS) {
+ // lookup current default ns in visibleNamespaces
+ for (var nsi = namespaces.length - 1; nsi >= 0; nsi--) {
+ var nsEntry = namespaces[nsi];
+ if (nsEntry.prefix === '' && nsEntry.namespace === n.namespaceURI) {
+ defaultNS = nsEntry.namespace;
+ break;
+ }
+ }
+ }
+ if (defaultNS !== n.namespaceURI) {
+ for (var nsi = namespaces.length - 1; nsi >= 0; nsi--) {
+ var nsEntry = namespaces[nsi];
+ if (nsEntry.namespace === n.namespaceURI) {
+ if (nsEntry.prefix) {
+ prefixedNodeName = nsEntry.prefix + ':' + nodeName;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ buf.push('<', prefixedNodeName);
+
+ // Build a fresh namespace snapshot for this element's children.
+ // The slice prevents sibling elements from inheriting each other's declarations.
+ var childNamespaces = namespaces.slice();
+
+ for (var i = 0; i < len; i++) {
+ // add namespaces for attributes
+ var attr = attrs.item(i);
+ if (attr.prefix == 'xmlns') {
+ childNamespaces.push({
+ prefix: attr.localName,
+ namespace: attr.value,
+ });
+ } else if (attr.nodeName == 'xmlns') {
+ childNamespaces.push({ prefix: '', namespace: attr.value });
+ }
+ }
+
+ for (var i = 0; i < len; i++) {
+ var attr = attrs.item(i);
+ if (needNamespaceDefine(attr, isHTML, childNamespaces)) {
+ var attrPrefix = attr.prefix || '';
+ var uri = attr.namespaceURI;
+ addSerializedAttribute(buf, attrPrefix ? 'xmlns:' + attrPrefix : 'xmlns', uri);
+ childNamespaces.push({ prefix: attrPrefix, namespace: uri });
+ }
+ // Apply nodeFilter and serialize the attribute.
+ var filteredAttr = nodeFilter ? nodeFilter(attr) : attr;
+ if (filteredAttr) {
+ if (typeof filteredAttr === 'string') {
+ buf.push(filteredAttr);
+ } else {
+ addSerializedAttribute(buf, filteredAttr.name, filteredAttr.value);
+ }
+ }
+ }
+
+ // add namespace for current node
+ if (nodeName === prefixedNodeName && needNamespaceDefine(n, isHTML, childNamespaces)) {
+ var nodePrefix = n.prefix || '';
+ var uri = n.namespaceURI;
+ addSerializedAttribute(buf, nodePrefix ? 'xmlns:' + nodePrefix : 'xmlns', uri);
+ childNamespaces.push({ prefix: nodePrefix, namespace: uri });
+ }
+
+ // in XML elements can be closed when they have no children
+ var canCloseTag = !n.firstChild;
+ if (canCloseTag && (isHTML || n.namespaceURI === NAMESPACE.HTML)) {
+ // in HTML (doc or ns) only void elements can be closed right away
+ canCloseTag = isHTMLVoidElement(nodeName);
+ }
+ if (canCloseTag) {
+ buf.push('/>');
+ // Self-closing: no children and no closing tag needed from exit.
+ return null;
+ }
+
+ buf.push('>');
+
+ // HTML raw text elements: serialize children as raw data without further descent.
+ if (isHTML && isHTMLRawTextElement(nodeName)) {
+ var child = n.firstChild;
+ while (child) {
+ if (child.data) {
+ buf.push(child.data);
+ } else {
+ serializeToString(child, buf, childNamespaces.slice(), opts);
+ }
+ child = child.nextSibling;
+ }
+ buf.push('', prefixedNodeName, '>');
+ // Children handled manually above; prevent walkDOM from also traversing them.
+ return null;
+ }
+
+ // Return child context so walkDOM descends; exit will emit the closing tag.
+ return { ns: childNamespaces, tag: prefixedNodeName };
+ case DOCUMENT_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ if (requireWellFormed && n.nodeType === DOCUMENT_NODE && n.documentElement == null) {
+ throw new DOMException('The Document has no documentElement', DOMExceptionName.InvalidStateError);
+ }
+ // Pass namespaces through; each child element will slice independently.
+ return { ns: namespaces };
+ case ATTRIBUTE_NODE:
+ addSerializedAttribute(buf, n.name, n.value);
+ return null;
+ case TEXT_NODE:
+ /*
+ * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
+ * except when used as markup delimiters, or within a comment, a processing instruction,
+ * or a CDATA section.
+ * If they are needed elsewhere, they must be escaped using either numeric character
+ * references or the strings `&` and `<` respectively.
+ * The right angle bracket (>) may be represented using the string " > ",
+ * and must, for compatibility, be escaped using either `>`,
+ * or a character reference when it appears in the string `]]>` in content,
+ * when that string is not marking the end of a CDATA section.
+ *
+ * In the content of elements, character data is any string of characters which does not
+ * contain the start-delimiter of any markup and does not include the CDATA-section-close
+ * delimiter, `]]>`.
+ *
+ * @see https://www.w3.org/TR/xml/#NT-CharData
+ * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
+ */
+ if (requireWellFormed && g.InvalidChar.test(n.data)) {
+ throw new DOMException(
+ 'The Text node data contains characters outside the XML Char production',
+ DOMExceptionName.InvalidStateError
+ );
+ }
+ buf.push(n.data.replace(/[<&>]/g, _xmlEncoder));
+ return null;
+ case CDATA_SECTION_NODE:
+ if (requireWellFormed && n.data.indexOf(']]>') !== -1) {
+ throw new DOMException('The CDATASection data contains "]]>"', DOMExceptionName.InvalidStateError);
+ }
+ if (splitCDATASections) {
+ buf.push(g.CDATA_START, n.data.replace(/]]>/g, ']]]]>'), g.CDATA_END);
+ } else {
+ buf.push(g.CDATA_START, n.data, g.CDATA_END);
+ }
+ return null;
+ case COMMENT_NODE:
+ if (requireWellFormed) {
+ if (g.InvalidChar.test(n.data)) {
+ throw new DOMException(
+ 'The comment node data contains characters outside the XML Char production',
+ DOMExceptionName.InvalidStateError
+ );
+ }
+ if (n.data.indexOf('--') !== -1 || n.data[n.data.length - 1] === '-') {
+ throw new DOMException(
+ 'The comment node data contains "--" or ends with "-"',
+ DOMExceptionName.InvalidStateError
+ );
+ }
+ }
+ buf.push(g.COMMENT_START, n.data, g.COMMENT_END);
+ return null;
+ case DOCUMENT_TYPE_NODE:
+ var pubid = n.publicId;
+ var sysid = n.systemId;
+ if (requireWellFormed) {
+ if (pubid && !g.PubidLiteral_match.test(pubid)) {
+ throw new DOMException('DocumentType publicId is not a valid PubidLiteral', DOMExceptionName.InvalidStateError);
+ }
+ if (sysid && sysid !== '.' && !g.SystemLiteral_match.test(sysid)) {
+ throw new DOMException('DocumentType systemId is not a valid SystemLiteral', DOMExceptionName.InvalidStateError);
+ }
+ if (n.internalSubset && n.internalSubset.indexOf(']>') !== -1) {
+ throw new DOMException('DocumentType internalSubset contains "]>"', DOMExceptionName.InvalidStateError);
+ }
+ }
+ buf.push(g.DOCTYPE_DECL_START, ' ', n.name);
+ if (pubid) {
+ buf.push(' ', g.PUBLIC, ' ', pubid);
+ if (sysid && sysid !== '.') {
+ buf.push(' ', sysid);
+ }
+ } else if (sysid && sysid !== '.') {
+ buf.push(' ', g.SYSTEM, ' ', sysid);
+ }
+ if (n.internalSubset) {
+ buf.push(' [', n.internalSubset, ']');
+ }
+ buf.push('>');
+ return null;
+ case PROCESSING_INSTRUCTION_NODE:
+ if (requireWellFormed) {
+ if (n.target.indexOf(':') !== -1 || n.target.toLowerCase() === 'xml') {
+ throw new DOMException('The ProcessingInstruction target is not well-formed', DOMExceptionName.InvalidStateError);
+ }
+ if (g.InvalidChar.test(n.data)) {
+ throw new DOMException(
+ 'The ProcessingInstruction data contains characters outside the XML Char production',
+ DOMExceptionName.InvalidStateError
+ );
+ }
+ if (n.data.indexOf('?>') !== -1) {
+ throw new DOMException('The ProcessingInstruction data contains "?>"', DOMExceptionName.InvalidStateError);
+ }
+ }
+ buf.push('', n.target, ' ', n.data, '?>');
+ return null;
+ case ENTITY_REFERENCE_NODE:
+ buf.push('&', n.nodeName, ';');
+ return null;
+ //case ENTITY_NODE:
+ //case NOTATION_NODE:
+ default:
+ buf.push('??', n.nodeName);
+ return null;
+ }
+ },
+ exit: function (n, childCtx) {
+ // Emit the closing tag for elements that were opened (not self-closed, not raw text).
+ if (childCtx && childCtx.tag) {
+ buf.push('', childCtx.tag, '>');
+ }
+ },
+ }
+ );
+}
+/**
+ * Imports a node from a different document into `doc`, creating a new copy.
+ * Delegates to {@link walkDOM} for traversal. Each node in the subtree is shallow-cloned,
+ * stamped with `doc` as its `ownerDocument`, and detached (`parentNode` set to `null`).
+ * Children are imported recursively when `deep` is `true`; for {@link Attr} nodes `deep` is
+ * always forced to `true`
+ * because an attribute's value lives in a child text node.
+ *
+ * @param {Document} doc
+ * The document that will own the imported node.
+ * @param {Node} node
+ * The node to import.
+ * @param {boolean} deep
+ * If `true`, descendants are imported recursively.
+ * @returns {Node}
+ * The newly imported node, now owned by `doc`.
+ */
+function importNode(doc, node, deep) {
+ var destRoot;
+ walkDOM(node, null, {
+ enter: function (srcNode, destParent) {
+ // Shallow-clone the node and stamp it into the target document.
+ var destNode = srcNode.cloneNode(false);
+ destNode.ownerDocument = doc;
+ destNode.parentNode = null;
+ // capture as the root of the imported subtree or attach to parent.
+ if (destParent === null) {
+ destRoot = destNode;
+ } else {
+ destParent.appendChild(destNode);
+ }
+ // ATTRIBUTE_NODE must always be imported deeply: its value lives in a child text node.
+ var shouldDeep = srcNode.nodeType === ATTRIBUTE_NODE || deep;
+ return shouldDeep ? destNode : null;
+ },
+ });
+ return destRoot;
+}
+
+/**
+ * Creates a copy of a node from an existing one.
+ *
+ * @param {Document} doc
+ * The Document object representing the document that the new node will belong to.
+ * @param {Node} node
+ * The node to clone.
+ * @param {boolean} deep
+ * If true, the contents of the node are recursively copied.
+ * If false, only the node itself (and its attributes, if it is an element) are copied.
+ * @returns {Node}
+ * Returns the newly created copy of the node.
+ * @throws {DOMException}
+ * May throw a DOMException if operations within setAttributeNode or appendChild (which are
+ * potentially invoked in this function) do not meet their specific constraints.
+ */
+function cloneNode(doc, node, deep) {
+ var destRoot;
+ walkDOM(node, null, {
+ enter: function (srcNode, destParent) {
+ // 1. Create a blank node of the same type and copy all scalar own properties.
+ var destNode = new srcNode.constructor(PDC);
+ for (var n in srcNode) {
+ if (hasOwn(srcNode, n)) {
+ var v = srcNode[n];
+ if (typeof v != 'object') {
+ if (v != destNode[n]) {
+ destNode[n] = v;
+ }
+ }
+ }
+ }
+ if (srcNode.childNodes) {
+ destNode.childNodes = new NodeList();
+ }
+ destNode.ownerDocument = doc;
+ // 2. Handle node-type-specific setup.
+ // Attributes are not DOM children, so they are cloned inline here
+ // rather than by walkDOM descent.
+ // ATTRIBUTE_NODE forces deep=true so its own children are walked.
+ var shouldDeep = deep;
+ switch (destNode.nodeType) {
+ case ELEMENT_NODE:
+ var attrs = srcNode.attributes;
+ var attrs2 = (destNode.attributes = new NamedNodeMap());
+ var len = attrs.length;
+ attrs2._ownerElement = destNode;
+ for (var i = 0; i < len; i++) {
+ destNode.setAttributeNode(cloneNode(doc, attrs.item(i), true));
+ }
+ break;
+ case ATTRIBUTE_NODE:
+ shouldDeep = true;
+ }
+ // 3. Attach to parent, or capture as the root of the cloned subtree.
+ if (destParent !== null) {
+ destParent.appendChild(destNode);
+ } else {
+ destRoot = destNode;
+ }
+ // 4. Return destNode as the context for children (causes walkDOM to descend),
+ // or null to skip children (shallow clone).
+ return shouldDeep ? destNode : null;
+ },
+ });
+ return destRoot;
+}
+
+function __set__(object, key, value) {
+ object[key] = value;
+}
+
+// Returns a new array of direct Element children.
+// Passed to LiveNodeList to implement ParentNode.children.
+// https://dom.spec.whatwg.org/#dom-parentnode-children
+function childrenRefresh(node) {
+ var ls = [];
+ var child = node.firstChild;
+ while (child) {
+ if (child.nodeType === ELEMENT_NODE) {
+ ls.push(child);
+ }
+ child = child.nextSibling;
+ }
+ return ls;
+}
+
+//do dynamic
+try {
+ if (Object.defineProperty) {
+ Object.defineProperty(LiveNodeList.prototype, 'length', {
+ get: function () {
+ _updateLiveList(this);
+ return this.$$length;
+ },
+ });
+
+ /**
+ * The text content of this node and its descendants.
+ *
+ * For {@link Element} and {@link DocumentFragment} nodes, returns the concatenation of the
+ * `nodeValue` of every descendant text node, excluding processing instruction and comment
+ * nodes. For all other node types, returns `nodeValue`.
+ *
+ * Setting `textContent` on an element or document fragment replaces all child nodes with a
+ * single text node; on other nodes it sets `data`, `value`, and `nodeValue` directly.
+ *
+ * @type {string | null}
+ * @see {@link https://dom.spec.whatwg.org/#dom-node-textcontent}
+ */
+ Object.defineProperty(Node.prototype, 'textContent', {
+ get: function () {
+ if (this.nodeType === ELEMENT_NODE || this.nodeType === DOCUMENT_FRAGMENT_NODE) {
+ var buf = [];
+ walkDOM(this, null, {
+ enter: function (n) {
+ if (n.nodeType === ELEMENT_NODE || n.nodeType === DOCUMENT_FRAGMENT_NODE) {
+ return true; // enter children
+ }
+ if (n.nodeType === PROCESSING_INSTRUCTION_NODE || n.nodeType === COMMENT_NODE) {
+ return null; // excluded from text content
+ }
+ buf.push(n.nodeValue);
+ },
+ });
+ return buf.join('');
+ }
+ return this.nodeValue;
+ },
+
+ set: function (data) {
+ switch (this.nodeType) {
+ case ELEMENT_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ while (this.firstChild) {
+ this.removeChild(this.firstChild);
+ }
+ if (data || String(data)) {
+ this.appendChild(this.ownerDocument.createTextNode(data));
+ }
+ break;
+
+ default:
+ this.data = data;
+ this.value = data;
+ this.nodeValue = data;
+ }
+ },
+ });
+
+ Object.defineProperty(Element.prototype, 'children', {
+ get: function () {
+ return new LiveNodeList(this, childrenRefresh);
+ },
+ });
+ Object.defineProperty(Document.prototype, 'children', {
+ get: function () {
+ return new LiveNodeList(this, childrenRefresh);
+ },
+ });
+ Object.defineProperty(DocumentFragment.prototype, 'children', {
+ get: function () {
+ return new LiveNodeList(this, childrenRefresh);
+ },
+ });
+
+ __set__ = function (object, key, value) {
+ //console.log(value)
+ object['$$' + key] = value;
+ };
+ }
+} catch (e) {
+ //ie8
+}
+
+exports._updateLiveList = _updateLiveList;
+exports.Attr = Attr;
+exports.CDATASection = CDATASection;
+exports.CharacterData = CharacterData;
+exports.Comment = Comment;
+exports.Document = Document;
+exports.DocumentFragment = DocumentFragment;
+exports.DocumentType = DocumentType;
+exports.DOMImplementation = DOMImplementation;
+exports.Element = Element;
+exports.Entity = Entity;
+exports.EntityReference = EntityReference;
+exports.LiveNodeList = LiveNodeList;
+exports.NamedNodeMap = NamedNodeMap;
+exports.Node = Node;
+exports.NodeList = NodeList;
+exports.Notation = Notation;
+exports.Text = Text;
+exports.ProcessingInstruction = ProcessingInstruction;
+exports.walkDOM = walkDOM;
+exports.XMLSerializer = XMLSerializer;
+
+},{"./conventions":2,"./errors":6,"./grammar":7}],5:[function(require,module,exports){
+'use strict';
+
+var freeze = require('./conventions').freeze;
+
+/**
+ * The entities that are predefined in every XML document.
+ *
+ * @see https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-predefined-ent W3C XML 1.1
+ * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0
+ * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML
+ * Wikipedia
+ */
+exports.XML_ENTITIES = freeze({
+ amp: '&',
+ apos: "'",
+ gt: '>',
+ lt: '<',
+ quot: '"',
+});
+
+/**
+ * A map of all entities that are detected in an HTML document.
+ * They contain all entries from `XML_ENTITIES`.
+ *
+ * @see {@link XML_ENTITIES}
+ * @see {@link DOMParser.parseFromString}
+ * @see {@link DOMImplementation.prototype.createHTMLDocument}
+ * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5)
+ * Spec
+ * @see https://html.spec.whatwg.org/entities.json JSON
+ * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names
+ * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML
+ * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML
+ * Wikipedia (HTML)
+ * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML
+ * Wikpedia (XHTML)
+ */
+exports.HTML_ENTITIES = freeze({
+ Aacute: '\u00C1',
+ aacute: '\u00E1',
+ Abreve: '\u0102',
+ abreve: '\u0103',
+ ac: '\u223E',
+ acd: '\u223F',
+ acE: '\u223E\u0333',
+ Acirc: '\u00C2',
+ acirc: '\u00E2',
+ acute: '\u00B4',
+ Acy: '\u0410',
+ acy: '\u0430',
+ AElig: '\u00C6',
+ aelig: '\u00E6',
+ af: '\u2061',
+ Afr: '\uD835\uDD04',
+ afr: '\uD835\uDD1E',
+ Agrave: '\u00C0',
+ agrave: '\u00E0',
+ alefsym: '\u2135',
+ aleph: '\u2135',
+ Alpha: '\u0391',
+ alpha: '\u03B1',
+ Amacr: '\u0100',
+ amacr: '\u0101',
+ amalg: '\u2A3F',
+ AMP: '\u0026',
+ amp: '\u0026',
+ And: '\u2A53',
+ and: '\u2227',
+ andand: '\u2A55',
+ andd: '\u2A5C',
+ andslope: '\u2A58',
+ andv: '\u2A5A',
+ ang: '\u2220',
+ ange: '\u29A4',
+ angle: '\u2220',
+ angmsd: '\u2221',
+ angmsdaa: '\u29A8',
+ angmsdab: '\u29A9',
+ angmsdac: '\u29AA',
+ angmsdad: '\u29AB',
+ angmsdae: '\u29AC',
+ angmsdaf: '\u29AD',
+ angmsdag: '\u29AE',
+ angmsdah: '\u29AF',
+ angrt: '\u221F',
+ angrtvb: '\u22BE',
+ angrtvbd: '\u299D',
+ angsph: '\u2222',
+ angst: '\u00C5',
+ angzarr: '\u237C',
+ Aogon: '\u0104',
+ aogon: '\u0105',
+ Aopf: '\uD835\uDD38',
+ aopf: '\uD835\uDD52',
+ ap: '\u2248',
+ apacir: '\u2A6F',
+ apE: '\u2A70',
+ ape: '\u224A',
+ apid: '\u224B',
+ apos: '\u0027',
+ ApplyFunction: '\u2061',
+ approx: '\u2248',
+ approxeq: '\u224A',
+ Aring: '\u00C5',
+ aring: '\u00E5',
+ Ascr: '\uD835\uDC9C',
+ ascr: '\uD835\uDCB6',
+ Assign: '\u2254',
+ ast: '\u002A',
+ asymp: '\u2248',
+ asympeq: '\u224D',
+ Atilde: '\u00C3',
+ atilde: '\u00E3',
+ Auml: '\u00C4',
+ auml: '\u00E4',
+ awconint: '\u2233',
+ awint: '\u2A11',
+ backcong: '\u224C',
+ backepsilon: '\u03F6',
+ backprime: '\u2035',
+ backsim: '\u223D',
+ backsimeq: '\u22CD',
+ Backslash: '\u2216',
+ Barv: '\u2AE7',
+ barvee: '\u22BD',
+ Barwed: '\u2306',
+ barwed: '\u2305',
+ barwedge: '\u2305',
+ bbrk: '\u23B5',
+ bbrktbrk: '\u23B6',
+ bcong: '\u224C',
+ Bcy: '\u0411',
+ bcy: '\u0431',
+ bdquo: '\u201E',
+ becaus: '\u2235',
+ Because: '\u2235',
+ because: '\u2235',
+ bemptyv: '\u29B0',
+ bepsi: '\u03F6',
+ bernou: '\u212C',
+ Bernoullis: '\u212C',
+ Beta: '\u0392',
+ beta: '\u03B2',
+ beth: '\u2136',
+ between: '\u226C',
+ Bfr: '\uD835\uDD05',
+ bfr: '\uD835\uDD1F',
+ bigcap: '\u22C2',
+ bigcirc: '\u25EF',
+ bigcup: '\u22C3',
+ bigodot: '\u2A00',
+ bigoplus: '\u2A01',
+ bigotimes: '\u2A02',
+ bigsqcup: '\u2A06',
+ bigstar: '\u2605',
+ bigtriangledown: '\u25BD',
+ bigtriangleup: '\u25B3',
+ biguplus: '\u2A04',
+ bigvee: '\u22C1',
+ bigwedge: '\u22C0',
+ bkarow: '\u290D',
+ blacklozenge: '\u29EB',
+ blacksquare: '\u25AA',
+ blacktriangle: '\u25B4',
+ blacktriangledown: '\u25BE',
+ blacktriangleleft: '\u25C2',
+ blacktriangleright: '\u25B8',
+ blank: '\u2423',
+ blk12: '\u2592',
+ blk14: '\u2591',
+ blk34: '\u2593',
+ block: '\u2588',
+ bne: '\u003D\u20E5',
+ bnequiv: '\u2261\u20E5',
+ bNot: '\u2AED',
+ bnot: '\u2310',
+ Bopf: '\uD835\uDD39',
+ bopf: '\uD835\uDD53',
+ bot: '\u22A5',
+ bottom: '\u22A5',
+ bowtie: '\u22C8',
+ boxbox: '\u29C9',
+ boxDL: '\u2557',
+ boxDl: '\u2556',
+ boxdL: '\u2555',
+ boxdl: '\u2510',
+ boxDR: '\u2554',
+ boxDr: '\u2553',
+ boxdR: '\u2552',
+ boxdr: '\u250C',
+ boxH: '\u2550',
+ boxh: '\u2500',
+ boxHD: '\u2566',
+ boxHd: '\u2564',
+ boxhD: '\u2565',
+ boxhd: '\u252C',
+ boxHU: '\u2569',
+ boxHu: '\u2567',
+ boxhU: '\u2568',
+ boxhu: '\u2534',
+ boxminus: '\u229F',
+ boxplus: '\u229E',
+ boxtimes: '\u22A0',
+ boxUL: '\u255D',
+ boxUl: '\u255C',
+ boxuL: '\u255B',
+ boxul: '\u2518',
+ boxUR: '\u255A',
+ boxUr: '\u2559',
+ boxuR: '\u2558',
+ boxur: '\u2514',
+ boxV: '\u2551',
+ boxv: '\u2502',
+ boxVH: '\u256C',
+ boxVh: '\u256B',
+ boxvH: '\u256A',
+ boxvh: '\u253C',
+ boxVL: '\u2563',
+ boxVl: '\u2562',
+ boxvL: '\u2561',
+ boxvl: '\u2524',
+ boxVR: '\u2560',
+ boxVr: '\u255F',
+ boxvR: '\u255E',
+ boxvr: '\u251C',
+ bprime: '\u2035',
+ Breve: '\u02D8',
+ breve: '\u02D8',
+ brvbar: '\u00A6',
+ Bscr: '\u212C',
+ bscr: '\uD835\uDCB7',
+ bsemi: '\u204F',
+ bsim: '\u223D',
+ bsime: '\u22CD',
+ bsol: '\u005C',
+ bsolb: '\u29C5',
+ bsolhsub: '\u27C8',
+ bull: '\u2022',
+ bullet: '\u2022',
+ bump: '\u224E',
+ bumpE: '\u2AAE',
+ bumpe: '\u224F',
+ Bumpeq: '\u224E',
+ bumpeq: '\u224F',
+ Cacute: '\u0106',
+ cacute: '\u0107',
+ Cap: '\u22D2',
+ cap: '\u2229',
+ capand: '\u2A44',
+ capbrcup: '\u2A49',
+ capcap: '\u2A4B',
+ capcup: '\u2A47',
+ capdot: '\u2A40',
+ CapitalDifferentialD: '\u2145',
+ caps: '\u2229\uFE00',
+ caret: '\u2041',
+ caron: '\u02C7',
+ Cayleys: '\u212D',
+ ccaps: '\u2A4D',
+ Ccaron: '\u010C',
+ ccaron: '\u010D',
+ Ccedil: '\u00C7',
+ ccedil: '\u00E7',
+ Ccirc: '\u0108',
+ ccirc: '\u0109',
+ Cconint: '\u2230',
+ ccups: '\u2A4C',
+ ccupssm: '\u2A50',
+ Cdot: '\u010A',
+ cdot: '\u010B',
+ cedil: '\u00B8',
+ Cedilla: '\u00B8',
+ cemptyv: '\u29B2',
+ cent: '\u00A2',
+ CenterDot: '\u00B7',
+ centerdot: '\u00B7',
+ Cfr: '\u212D',
+ cfr: '\uD835\uDD20',
+ CHcy: '\u0427',
+ chcy: '\u0447',
+ check: '\u2713',
+ checkmark: '\u2713',
+ Chi: '\u03A7',
+ chi: '\u03C7',
+ cir: '\u25CB',
+ circ: '\u02C6',
+ circeq: '\u2257',
+ circlearrowleft: '\u21BA',
+ circlearrowright: '\u21BB',
+ circledast: '\u229B',
+ circledcirc: '\u229A',
+ circleddash: '\u229D',
+ CircleDot: '\u2299',
+ circledR: '\u00AE',
+ circledS: '\u24C8',
+ CircleMinus: '\u2296',
+ CirclePlus: '\u2295',
+ CircleTimes: '\u2297',
+ cirE: '\u29C3',
+ cire: '\u2257',
+ cirfnint: '\u2A10',
+ cirmid: '\u2AEF',
+ cirscir: '\u29C2',
+ ClockwiseContourIntegral: '\u2232',
+ CloseCurlyDoubleQuote: '\u201D',
+ CloseCurlyQuote: '\u2019',
+ clubs: '\u2663',
+ clubsuit: '\u2663',
+ Colon: '\u2237',
+ colon: '\u003A',
+ Colone: '\u2A74',
+ colone: '\u2254',
+ coloneq: '\u2254',
+ comma: '\u002C',
+ commat: '\u0040',
+ comp: '\u2201',
+ compfn: '\u2218',
+ complement: '\u2201',
+ complexes: '\u2102',
+ cong: '\u2245',
+ congdot: '\u2A6D',
+ Congruent: '\u2261',
+ Conint: '\u222F',
+ conint: '\u222E',
+ ContourIntegral: '\u222E',
+ Copf: '\u2102',
+ copf: '\uD835\uDD54',
+ coprod: '\u2210',
+ Coproduct: '\u2210',
+ COPY: '\u00A9',
+ copy: '\u00A9',
+ copysr: '\u2117',
+ CounterClockwiseContourIntegral: '\u2233',
+ crarr: '\u21B5',
+ Cross: '\u2A2F',
+ cross: '\u2717',
+ Cscr: '\uD835\uDC9E',
+ cscr: '\uD835\uDCB8',
+ csub: '\u2ACF',
+ csube: '\u2AD1',
+ csup: '\u2AD0',
+ csupe: '\u2AD2',
+ ctdot: '\u22EF',
+ cudarrl: '\u2938',
+ cudarrr: '\u2935',
+ cuepr: '\u22DE',
+ cuesc: '\u22DF',
+ cularr: '\u21B6',
+ cularrp: '\u293D',
+ Cup: '\u22D3',
+ cup: '\u222A',
+ cupbrcap: '\u2A48',
+ CupCap: '\u224D',
+ cupcap: '\u2A46',
+ cupcup: '\u2A4A',
+ cupdot: '\u228D',
+ cupor: '\u2A45',
+ cups: '\u222A\uFE00',
+ curarr: '\u21B7',
+ curarrm: '\u293C',
+ curlyeqprec: '\u22DE',
+ curlyeqsucc: '\u22DF',
+ curlyvee: '\u22CE',
+ curlywedge: '\u22CF',
+ curren: '\u00A4',
+ curvearrowleft: '\u21B6',
+ curvearrowright: '\u21B7',
+ cuvee: '\u22CE',
+ cuwed: '\u22CF',
+ cwconint: '\u2232',
+ cwint: '\u2231',
+ cylcty: '\u232D',
+ Dagger: '\u2021',
+ dagger: '\u2020',
+ daleth: '\u2138',
+ Darr: '\u21A1',
+ dArr: '\u21D3',
+ darr: '\u2193',
+ dash: '\u2010',
+ Dashv: '\u2AE4',
+ dashv: '\u22A3',
+ dbkarow: '\u290F',
+ dblac: '\u02DD',
+ Dcaron: '\u010E',
+ dcaron: '\u010F',
+ Dcy: '\u0414',
+ dcy: '\u0434',
+ DD: '\u2145',
+ dd: '\u2146',
+ ddagger: '\u2021',
+ ddarr: '\u21CA',
+ DDotrahd: '\u2911',
+ ddotseq: '\u2A77',
+ deg: '\u00B0',
+ Del: '\u2207',
+ Delta: '\u0394',
+ delta: '\u03B4',
+ demptyv: '\u29B1',
+ dfisht: '\u297F',
+ Dfr: '\uD835\uDD07',
+ dfr: '\uD835\uDD21',
+ dHar: '\u2965',
+ dharl: '\u21C3',
+ dharr: '\u21C2',
+ DiacriticalAcute: '\u00B4',
+ DiacriticalDot: '\u02D9',
+ DiacriticalDoubleAcute: '\u02DD',
+ DiacriticalGrave: '\u0060',
+ DiacriticalTilde: '\u02DC',
+ diam: '\u22C4',
+ Diamond: '\u22C4',
+ diamond: '\u22C4',
+ diamondsuit: '\u2666',
+ diams: '\u2666',
+ die: '\u00A8',
+ DifferentialD: '\u2146',
+ digamma: '\u03DD',
+ disin: '\u22F2',
+ div: '\u00F7',
+ divide: '\u00F7',
+ divideontimes: '\u22C7',
+ divonx: '\u22C7',
+ DJcy: '\u0402',
+ djcy: '\u0452',
+ dlcorn: '\u231E',
+ dlcrop: '\u230D',
+ dollar: '\u0024',
+ Dopf: '\uD835\uDD3B',
+ dopf: '\uD835\uDD55',
+ Dot: '\u00A8',
+ dot: '\u02D9',
+ DotDot: '\u20DC',
+ doteq: '\u2250',
+ doteqdot: '\u2251',
+ DotEqual: '\u2250',
+ dotminus: '\u2238',
+ dotplus: '\u2214',
+ dotsquare: '\u22A1',
+ doublebarwedge: '\u2306',
+ DoubleContourIntegral: '\u222F',
+ DoubleDot: '\u00A8',
+ DoubleDownArrow: '\u21D3',
+ DoubleLeftArrow: '\u21D0',
+ DoubleLeftRightArrow: '\u21D4',
+ DoubleLeftTee: '\u2AE4',
+ DoubleLongLeftArrow: '\u27F8',
+ DoubleLongLeftRightArrow: '\u27FA',
+ DoubleLongRightArrow: '\u27F9',
+ DoubleRightArrow: '\u21D2',
+ DoubleRightTee: '\u22A8',
+ DoubleUpArrow: '\u21D1',
+ DoubleUpDownArrow: '\u21D5',
+ DoubleVerticalBar: '\u2225',
+ DownArrow: '\u2193',
+ Downarrow: '\u21D3',
+ downarrow: '\u2193',
+ DownArrowBar: '\u2913',
+ DownArrowUpArrow: '\u21F5',
+ DownBreve: '\u0311',
+ downdownarrows: '\u21CA',
+ downharpoonleft: '\u21C3',
+ downharpoonright: '\u21C2',
+ DownLeftRightVector: '\u2950',
+ DownLeftTeeVector: '\u295E',
+ DownLeftVector: '\u21BD',
+ DownLeftVectorBar: '\u2956',
+ DownRightTeeVector: '\u295F',
+ DownRightVector: '\u21C1',
+ DownRightVectorBar: '\u2957',
+ DownTee: '\u22A4',
+ DownTeeArrow: '\u21A7',
+ drbkarow: '\u2910',
+ drcorn: '\u231F',
+ drcrop: '\u230C',
+ Dscr: '\uD835\uDC9F',
+ dscr: '\uD835\uDCB9',
+ DScy: '\u0405',
+ dscy: '\u0455',
+ dsol: '\u29F6',
+ Dstrok: '\u0110',
+ dstrok: '\u0111',
+ dtdot: '\u22F1',
+ dtri: '\u25BF',
+ dtrif: '\u25BE',
+ duarr: '\u21F5',
+ duhar: '\u296F',
+ dwangle: '\u29A6',
+ DZcy: '\u040F',
+ dzcy: '\u045F',
+ dzigrarr: '\u27FF',
+ Eacute: '\u00C9',
+ eacute: '\u00E9',
+ easter: '\u2A6E',
+ Ecaron: '\u011A',
+ ecaron: '\u011B',
+ ecir: '\u2256',
+ Ecirc: '\u00CA',
+ ecirc: '\u00EA',
+ ecolon: '\u2255',
+ Ecy: '\u042D',
+ ecy: '\u044D',
+ eDDot: '\u2A77',
+ Edot: '\u0116',
+ eDot: '\u2251',
+ edot: '\u0117',
+ ee: '\u2147',
+ efDot: '\u2252',
+ Efr: '\uD835\uDD08',
+ efr: '\uD835\uDD22',
+ eg: '\u2A9A',
+ Egrave: '\u00C8',
+ egrave: '\u00E8',
+ egs: '\u2A96',
+ egsdot: '\u2A98',
+ el: '\u2A99',
+ Element: '\u2208',
+ elinters: '\u23E7',
+ ell: '\u2113',
+ els: '\u2A95',
+ elsdot: '\u2A97',
+ Emacr: '\u0112',
+ emacr: '\u0113',
+ empty: '\u2205',
+ emptyset: '\u2205',
+ EmptySmallSquare: '\u25FB',
+ emptyv: '\u2205',
+ EmptyVerySmallSquare: '\u25AB',
+ emsp: '\u2003',
+ emsp13: '\u2004',
+ emsp14: '\u2005',
+ ENG: '\u014A',
+ eng: '\u014B',
+ ensp: '\u2002',
+ Eogon: '\u0118',
+ eogon: '\u0119',
+ Eopf: '\uD835\uDD3C',
+ eopf: '\uD835\uDD56',
+ epar: '\u22D5',
+ eparsl: '\u29E3',
+ eplus: '\u2A71',
+ epsi: '\u03B5',
+ Epsilon: '\u0395',
+ epsilon: '\u03B5',
+ epsiv: '\u03F5',
+ eqcirc: '\u2256',
+ eqcolon: '\u2255',
+ eqsim: '\u2242',
+ eqslantgtr: '\u2A96',
+ eqslantless: '\u2A95',
+ Equal: '\u2A75',
+ equals: '\u003D',
+ EqualTilde: '\u2242',
+ equest: '\u225F',
+ Equilibrium: '\u21CC',
+ equiv: '\u2261',
+ equivDD: '\u2A78',
+ eqvparsl: '\u29E5',
+ erarr: '\u2971',
+ erDot: '\u2253',
+ Escr: '\u2130',
+ escr: '\u212F',
+ esdot: '\u2250',
+ Esim: '\u2A73',
+ esim: '\u2242',
+ Eta: '\u0397',
+ eta: '\u03B7',
+ ETH: '\u00D0',
+ eth: '\u00F0',
+ Euml: '\u00CB',
+ euml: '\u00EB',
+ euro: '\u20AC',
+ excl: '\u0021',
+ exist: '\u2203',
+ Exists: '\u2203',
+ expectation: '\u2130',
+ ExponentialE: '\u2147',
+ exponentiale: '\u2147',
+ fallingdotseq: '\u2252',
+ Fcy: '\u0424',
+ fcy: '\u0444',
+ female: '\u2640',
+ ffilig: '\uFB03',
+ fflig: '\uFB00',
+ ffllig: '\uFB04',
+ Ffr: '\uD835\uDD09',
+ ffr: '\uD835\uDD23',
+ filig: '\uFB01',
+ FilledSmallSquare: '\u25FC',
+ FilledVerySmallSquare: '\u25AA',
+ fjlig: '\u0066\u006A',
+ flat: '\u266D',
+ fllig: '\uFB02',
+ fltns: '\u25B1',
+ fnof: '\u0192',
+ Fopf: '\uD835\uDD3D',
+ fopf: '\uD835\uDD57',
+ ForAll: '\u2200',
+ forall: '\u2200',
+ fork: '\u22D4',
+ forkv: '\u2AD9',
+ Fouriertrf: '\u2131',
+ fpartint: '\u2A0D',
+ frac12: '\u00BD',
+ frac13: '\u2153',
+ frac14: '\u00BC',
+ frac15: '\u2155',
+ frac16: '\u2159',
+ frac18: '\u215B',
+ frac23: '\u2154',
+ frac25: '\u2156',
+ frac34: '\u00BE',
+ frac35: '\u2157',
+ frac38: '\u215C',
+ frac45: '\u2158',
+ frac56: '\u215A',
+ frac58: '\u215D',
+ frac78: '\u215E',
+ frasl: '\u2044',
+ frown: '\u2322',
+ Fscr: '\u2131',
+ fscr: '\uD835\uDCBB',
+ gacute: '\u01F5',
+ Gamma: '\u0393',
+ gamma: '\u03B3',
+ Gammad: '\u03DC',
+ gammad: '\u03DD',
+ gap: '\u2A86',
+ Gbreve: '\u011E',
+ gbreve: '\u011F',
+ Gcedil: '\u0122',
+ Gcirc: '\u011C',
+ gcirc: '\u011D',
+ Gcy: '\u0413',
+ gcy: '\u0433',
+ Gdot: '\u0120',
+ gdot: '\u0121',
+ gE: '\u2267',
+ ge: '\u2265',
+ gEl: '\u2A8C',
+ gel: '\u22DB',
+ geq: '\u2265',
+ geqq: '\u2267',
+ geqslant: '\u2A7E',
+ ges: '\u2A7E',
+ gescc: '\u2AA9',
+ gesdot: '\u2A80',
+ gesdoto: '\u2A82',
+ gesdotol: '\u2A84',
+ gesl: '\u22DB\uFE00',
+ gesles: '\u2A94',
+ Gfr: '\uD835\uDD0A',
+ gfr: '\uD835\uDD24',
+ Gg: '\u22D9',
+ gg: '\u226B',
+ ggg: '\u22D9',
+ gimel: '\u2137',
+ GJcy: '\u0403',
+ gjcy: '\u0453',
+ gl: '\u2277',
+ gla: '\u2AA5',
+ glE: '\u2A92',
+ glj: '\u2AA4',
+ gnap: '\u2A8A',
+ gnapprox: '\u2A8A',
+ gnE: '\u2269',
+ gne: '\u2A88',
+ gneq: '\u2A88',
+ gneqq: '\u2269',
+ gnsim: '\u22E7',
+ Gopf: '\uD835\uDD3E',
+ gopf: '\uD835\uDD58',
+ grave: '\u0060',
+ GreaterEqual: '\u2265',
+ GreaterEqualLess: '\u22DB',
+ GreaterFullEqual: '\u2267',
+ GreaterGreater: '\u2AA2',
+ GreaterLess: '\u2277',
+ GreaterSlantEqual: '\u2A7E',
+ GreaterTilde: '\u2273',
+ Gscr: '\uD835\uDCA2',
+ gscr: '\u210A',
+ gsim: '\u2273',
+ gsime: '\u2A8E',
+ gsiml: '\u2A90',
+ Gt: '\u226B',
+ GT: '\u003E',
+ gt: '\u003E',
+ gtcc: '\u2AA7',
+ gtcir: '\u2A7A',
+ gtdot: '\u22D7',
+ gtlPar: '\u2995',
+ gtquest: '\u2A7C',
+ gtrapprox: '\u2A86',
+ gtrarr: '\u2978',
+ gtrdot: '\u22D7',
+ gtreqless: '\u22DB',
+ gtreqqless: '\u2A8C',
+ gtrless: '\u2277',
+ gtrsim: '\u2273',
+ gvertneqq: '\u2269\uFE00',
+ gvnE: '\u2269\uFE00',
+ Hacek: '\u02C7',
+ hairsp: '\u200A',
+ half: '\u00BD',
+ hamilt: '\u210B',
+ HARDcy: '\u042A',
+ hardcy: '\u044A',
+ hArr: '\u21D4',
+ harr: '\u2194',
+ harrcir: '\u2948',
+ harrw: '\u21AD',
+ Hat: '\u005E',
+ hbar: '\u210F',
+ Hcirc: '\u0124',
+ hcirc: '\u0125',
+ hearts: '\u2665',
+ heartsuit: '\u2665',
+ hellip: '\u2026',
+ hercon: '\u22B9',
+ Hfr: '\u210C',
+ hfr: '\uD835\uDD25',
+ HilbertSpace: '\u210B',
+ hksearow: '\u2925',
+ hkswarow: '\u2926',
+ hoarr: '\u21FF',
+ homtht: '\u223B',
+ hookleftarrow: '\u21A9',
+ hookrightarrow: '\u21AA',
+ Hopf: '\u210D',
+ hopf: '\uD835\uDD59',
+ horbar: '\u2015',
+ HorizontalLine: '\u2500',
+ Hscr: '\u210B',
+ hscr: '\uD835\uDCBD',
+ hslash: '\u210F',
+ Hstrok: '\u0126',
+ hstrok: '\u0127',
+ HumpDownHump: '\u224E',
+ HumpEqual: '\u224F',
+ hybull: '\u2043',
+ hyphen: '\u2010',
+ Iacute: '\u00CD',
+ iacute: '\u00ED',
+ ic: '\u2063',
+ Icirc: '\u00CE',
+ icirc: '\u00EE',
+ Icy: '\u0418',
+ icy: '\u0438',
+ Idot: '\u0130',
+ IEcy: '\u0415',
+ iecy: '\u0435',
+ iexcl: '\u00A1',
+ iff: '\u21D4',
+ Ifr: '\u2111',
+ ifr: '\uD835\uDD26',
+ Igrave: '\u00CC',
+ igrave: '\u00EC',
+ ii: '\u2148',
+ iiiint: '\u2A0C',
+ iiint: '\u222D',
+ iinfin: '\u29DC',
+ iiota: '\u2129',
+ IJlig: '\u0132',
+ ijlig: '\u0133',
+ Im: '\u2111',
+ Imacr: '\u012A',
+ imacr: '\u012B',
+ image: '\u2111',
+ ImaginaryI: '\u2148',
+ imagline: '\u2110',
+ imagpart: '\u2111',
+ imath: '\u0131',
+ imof: '\u22B7',
+ imped: '\u01B5',
+ Implies: '\u21D2',
+ in: '\u2208',
+ incare: '\u2105',
+ infin: '\u221E',
+ infintie: '\u29DD',
+ inodot: '\u0131',
+ Int: '\u222C',
+ int: '\u222B',
+ intcal: '\u22BA',
+ integers: '\u2124',
+ Integral: '\u222B',
+ intercal: '\u22BA',
+ Intersection: '\u22C2',
+ intlarhk: '\u2A17',
+ intprod: '\u2A3C',
+ InvisibleComma: '\u2063',
+ InvisibleTimes: '\u2062',
+ IOcy: '\u0401',
+ iocy: '\u0451',
+ Iogon: '\u012E',
+ iogon: '\u012F',
+ Iopf: '\uD835\uDD40',
+ iopf: '\uD835\uDD5A',
+ Iota: '\u0399',
+ iota: '\u03B9',
+ iprod: '\u2A3C',
+ iquest: '\u00BF',
+ Iscr: '\u2110',
+ iscr: '\uD835\uDCBE',
+ isin: '\u2208',
+ isindot: '\u22F5',
+ isinE: '\u22F9',
+ isins: '\u22F4',
+ isinsv: '\u22F3',
+ isinv: '\u2208',
+ it: '\u2062',
+ Itilde: '\u0128',
+ itilde: '\u0129',
+ Iukcy: '\u0406',
+ iukcy: '\u0456',
+ Iuml: '\u00CF',
+ iuml: '\u00EF',
+ Jcirc: '\u0134',
+ jcirc: '\u0135',
+ Jcy: '\u0419',
+ jcy: '\u0439',
+ Jfr: '\uD835\uDD0D',
+ jfr: '\uD835\uDD27',
+ jmath: '\u0237',
+ Jopf: '\uD835\uDD41',
+ jopf: '\uD835\uDD5B',
+ Jscr: '\uD835\uDCA5',
+ jscr: '\uD835\uDCBF',
+ Jsercy: '\u0408',
+ jsercy: '\u0458',
+ Jukcy: '\u0404',
+ jukcy: '\u0454',
+ Kappa: '\u039A',
+ kappa: '\u03BA',
+ kappav: '\u03F0',
+ Kcedil: '\u0136',
+ kcedil: '\u0137',
+ Kcy: '\u041A',
+ kcy: '\u043A',
+ Kfr: '\uD835\uDD0E',
+ kfr: '\uD835\uDD28',
+ kgreen: '\u0138',
+ KHcy: '\u0425',
+ khcy: '\u0445',
+ KJcy: '\u040C',
+ kjcy: '\u045C',
+ Kopf: '\uD835\uDD42',
+ kopf: '\uD835\uDD5C',
+ Kscr: '\uD835\uDCA6',
+ kscr: '\uD835\uDCC0',
+ lAarr: '\u21DA',
+ Lacute: '\u0139',
+ lacute: '\u013A',
+ laemptyv: '\u29B4',
+ lagran: '\u2112',
+ Lambda: '\u039B',
+ lambda: '\u03BB',
+ Lang: '\u27EA',
+ lang: '\u27E8',
+ langd: '\u2991',
+ langle: '\u27E8',
+ lap: '\u2A85',
+ Laplacetrf: '\u2112',
+ laquo: '\u00AB',
+ Larr: '\u219E',
+ lArr: '\u21D0',
+ larr: '\u2190',
+ larrb: '\u21E4',
+ larrbfs: '\u291F',
+ larrfs: '\u291D',
+ larrhk: '\u21A9',
+ larrlp: '\u21AB',
+ larrpl: '\u2939',
+ larrsim: '\u2973',
+ larrtl: '\u21A2',
+ lat: '\u2AAB',
+ lAtail: '\u291B',
+ latail: '\u2919',
+ late: '\u2AAD',
+ lates: '\u2AAD\uFE00',
+ lBarr: '\u290E',
+ lbarr: '\u290C',
+ lbbrk: '\u2772',
+ lbrace: '\u007B',
+ lbrack: '\u005B',
+ lbrke: '\u298B',
+ lbrksld: '\u298F',
+ lbrkslu: '\u298D',
+ Lcaron: '\u013D',
+ lcaron: '\u013E',
+ Lcedil: '\u013B',
+ lcedil: '\u013C',
+ lceil: '\u2308',
+ lcub: '\u007B',
+ Lcy: '\u041B',
+ lcy: '\u043B',
+ ldca: '\u2936',
+ ldquo: '\u201C',
+ ldquor: '\u201E',
+ ldrdhar: '\u2967',
+ ldrushar: '\u294B',
+ ldsh: '\u21B2',
+ lE: '\u2266',
+ le: '\u2264',
+ LeftAngleBracket: '\u27E8',
+ LeftArrow: '\u2190',
+ Leftarrow: '\u21D0',
+ leftarrow: '\u2190',
+ LeftArrowBar: '\u21E4',
+ LeftArrowRightArrow: '\u21C6',
+ leftarrowtail: '\u21A2',
+ LeftCeiling: '\u2308',
+ LeftDoubleBracket: '\u27E6',
+ LeftDownTeeVector: '\u2961',
+ LeftDownVector: '\u21C3',
+ LeftDownVectorBar: '\u2959',
+ LeftFloor: '\u230A',
+ leftharpoondown: '\u21BD',
+ leftharpoonup: '\u21BC',
+ leftleftarrows: '\u21C7',
+ LeftRightArrow: '\u2194',
+ Leftrightarrow: '\u21D4',
+ leftrightarrow: '\u2194',
+ leftrightarrows: '\u21C6',
+ leftrightharpoons: '\u21CB',
+ leftrightsquigarrow: '\u21AD',
+ LeftRightVector: '\u294E',
+ LeftTee: '\u22A3',
+ LeftTeeArrow: '\u21A4',
+ LeftTeeVector: '\u295A',
+ leftthreetimes: '\u22CB',
+ LeftTriangle: '\u22B2',
+ LeftTriangleBar: '\u29CF',
+ LeftTriangleEqual: '\u22B4',
+ LeftUpDownVector: '\u2951',
+ LeftUpTeeVector: '\u2960',
+ LeftUpVector: '\u21BF',
+ LeftUpVectorBar: '\u2958',
+ LeftVector: '\u21BC',
+ LeftVectorBar: '\u2952',
+ lEg: '\u2A8B',
+ leg: '\u22DA',
+ leq: '\u2264',
+ leqq: '\u2266',
+ leqslant: '\u2A7D',
+ les: '\u2A7D',
+ lescc: '\u2AA8',
+ lesdot: '\u2A7F',
+ lesdoto: '\u2A81',
+ lesdotor: '\u2A83',
+ lesg: '\u22DA\uFE00',
+ lesges: '\u2A93',
+ lessapprox: '\u2A85',
+ lessdot: '\u22D6',
+ lesseqgtr: '\u22DA',
+ lesseqqgtr: '\u2A8B',
+ LessEqualGreater: '\u22DA',
+ LessFullEqual: '\u2266',
+ LessGreater: '\u2276',
+ lessgtr: '\u2276',
+ LessLess: '\u2AA1',
+ lesssim: '\u2272',
+ LessSlantEqual: '\u2A7D',
+ LessTilde: '\u2272',
+ lfisht: '\u297C',
+ lfloor: '\u230A',
+ Lfr: '\uD835\uDD0F',
+ lfr: '\uD835\uDD29',
+ lg: '\u2276',
+ lgE: '\u2A91',
+ lHar: '\u2962',
+ lhard: '\u21BD',
+ lharu: '\u21BC',
+ lharul: '\u296A',
+ lhblk: '\u2584',
+ LJcy: '\u0409',
+ ljcy: '\u0459',
+ Ll: '\u22D8',
+ ll: '\u226A',
+ llarr: '\u21C7',
+ llcorner: '\u231E',
+ Lleftarrow: '\u21DA',
+ llhard: '\u296B',
+ lltri: '\u25FA',
+ Lmidot: '\u013F',
+ lmidot: '\u0140',
+ lmoust: '\u23B0',
+ lmoustache: '\u23B0',
+ lnap: '\u2A89',
+ lnapprox: '\u2A89',
+ lnE: '\u2268',
+ lne: '\u2A87',
+ lneq: '\u2A87',
+ lneqq: '\u2268',
+ lnsim: '\u22E6',
+ loang: '\u27EC',
+ loarr: '\u21FD',
+ lobrk: '\u27E6',
+ LongLeftArrow: '\u27F5',
+ Longleftarrow: '\u27F8',
+ longleftarrow: '\u27F5',
+ LongLeftRightArrow: '\u27F7',
+ Longleftrightarrow: '\u27FA',
+ longleftrightarrow: '\u27F7',
+ longmapsto: '\u27FC',
+ LongRightArrow: '\u27F6',
+ Longrightarrow: '\u27F9',
+ longrightarrow: '\u27F6',
+ looparrowleft: '\u21AB',
+ looparrowright: '\u21AC',
+ lopar: '\u2985',
+ Lopf: '\uD835\uDD43',
+ lopf: '\uD835\uDD5D',
+ loplus: '\u2A2D',
+ lotimes: '\u2A34',
+ lowast: '\u2217',
+ lowbar: '\u005F',
+ LowerLeftArrow: '\u2199',
+ LowerRightArrow: '\u2198',
+ loz: '\u25CA',
+ lozenge: '\u25CA',
+ lozf: '\u29EB',
+ lpar: '\u0028',
+ lparlt: '\u2993',
+ lrarr: '\u21C6',
+ lrcorner: '\u231F',
+ lrhar: '\u21CB',
+ lrhard: '\u296D',
+ lrm: '\u200E',
+ lrtri: '\u22BF',
+ lsaquo: '\u2039',
+ Lscr: '\u2112',
+ lscr: '\uD835\uDCC1',
+ Lsh: '\u21B0',
+ lsh: '\u21B0',
+ lsim: '\u2272',
+ lsime: '\u2A8D',
+ lsimg: '\u2A8F',
+ lsqb: '\u005B',
+ lsquo: '\u2018',
+ lsquor: '\u201A',
+ Lstrok: '\u0141',
+ lstrok: '\u0142',
+ Lt: '\u226A',
+ LT: '\u003C',
+ lt: '\u003C',
+ ltcc: '\u2AA6',
+ ltcir: '\u2A79',
+ ltdot: '\u22D6',
+ lthree: '\u22CB',
+ ltimes: '\u22C9',
+ ltlarr: '\u2976',
+ ltquest: '\u2A7B',
+ ltri: '\u25C3',
+ ltrie: '\u22B4',
+ ltrif: '\u25C2',
+ ltrPar: '\u2996',
+ lurdshar: '\u294A',
+ luruhar: '\u2966',
+ lvertneqq: '\u2268\uFE00',
+ lvnE: '\u2268\uFE00',
+ macr: '\u00AF',
+ male: '\u2642',
+ malt: '\u2720',
+ maltese: '\u2720',
+ Map: '\u2905',
+ map: '\u21A6',
+ mapsto: '\u21A6',
+ mapstodown: '\u21A7',
+ mapstoleft: '\u21A4',
+ mapstoup: '\u21A5',
+ marker: '\u25AE',
+ mcomma: '\u2A29',
+ Mcy: '\u041C',
+ mcy: '\u043C',
+ mdash: '\u2014',
+ mDDot: '\u223A',
+ measuredangle: '\u2221',
+ MediumSpace: '\u205F',
+ Mellintrf: '\u2133',
+ Mfr: '\uD835\uDD10',
+ mfr: '\uD835\uDD2A',
+ mho: '\u2127',
+ micro: '\u00B5',
+ mid: '\u2223',
+ midast: '\u002A',
+ midcir: '\u2AF0',
+ middot: '\u00B7',
+ minus: '\u2212',
+ minusb: '\u229F',
+ minusd: '\u2238',
+ minusdu: '\u2A2A',
+ MinusPlus: '\u2213',
+ mlcp: '\u2ADB',
+ mldr: '\u2026',
+ mnplus: '\u2213',
+ models: '\u22A7',
+ Mopf: '\uD835\uDD44',
+ mopf: '\uD835\uDD5E',
+ mp: '\u2213',
+ Mscr: '\u2133',
+ mscr: '\uD835\uDCC2',
+ mstpos: '\u223E',
+ Mu: '\u039C',
+ mu: '\u03BC',
+ multimap: '\u22B8',
+ mumap: '\u22B8',
+ nabla: '\u2207',
+ Nacute: '\u0143',
+ nacute: '\u0144',
+ nang: '\u2220\u20D2',
+ nap: '\u2249',
+ napE: '\u2A70\u0338',
+ napid: '\u224B\u0338',
+ napos: '\u0149',
+ napprox: '\u2249',
+ natur: '\u266E',
+ natural: '\u266E',
+ naturals: '\u2115',
+ nbsp: '\u00A0',
+ nbump: '\u224E\u0338',
+ nbumpe: '\u224F\u0338',
+ ncap: '\u2A43',
+ Ncaron: '\u0147',
+ ncaron: '\u0148',
+ Ncedil: '\u0145',
+ ncedil: '\u0146',
+ ncong: '\u2247',
+ ncongdot: '\u2A6D\u0338',
+ ncup: '\u2A42',
+ Ncy: '\u041D',
+ ncy: '\u043D',
+ ndash: '\u2013',
+ ne: '\u2260',
+ nearhk: '\u2924',
+ neArr: '\u21D7',
+ nearr: '\u2197',
+ nearrow: '\u2197',
+ nedot: '\u2250\u0338',
+ NegativeMediumSpace: '\u200B',
+ NegativeThickSpace: '\u200B',
+ NegativeThinSpace: '\u200B',
+ NegativeVeryThinSpace: '\u200B',
+ nequiv: '\u2262',
+ nesear: '\u2928',
+ nesim: '\u2242\u0338',
+ NestedGreaterGreater: '\u226B',
+ NestedLessLess: '\u226A',
+ NewLine: '\u000A',
+ nexist: '\u2204',
+ nexists: '\u2204',
+ Nfr: '\uD835\uDD11',
+ nfr: '\uD835\uDD2B',
+ ngE: '\u2267\u0338',
+ nge: '\u2271',
+ ngeq: '\u2271',
+ ngeqq: '\u2267\u0338',
+ ngeqslant: '\u2A7E\u0338',
+ nges: '\u2A7E\u0338',
+ nGg: '\u22D9\u0338',
+ ngsim: '\u2275',
+ nGt: '\u226B\u20D2',
+ ngt: '\u226F',
+ ngtr: '\u226F',
+ nGtv: '\u226B\u0338',
+ nhArr: '\u21CE',
+ nharr: '\u21AE',
+ nhpar: '\u2AF2',
+ ni: '\u220B',
+ nis: '\u22FC',
+ nisd: '\u22FA',
+ niv: '\u220B',
+ NJcy: '\u040A',
+ njcy: '\u045A',
+ nlArr: '\u21CD',
+ nlarr: '\u219A',
+ nldr: '\u2025',
+ nlE: '\u2266\u0338',
+ nle: '\u2270',
+ nLeftarrow: '\u21CD',
+ nleftarrow: '\u219A',
+ nLeftrightarrow: '\u21CE',
+ nleftrightarrow: '\u21AE',
+ nleq: '\u2270',
+ nleqq: '\u2266\u0338',
+ nleqslant: '\u2A7D\u0338',
+ nles: '\u2A7D\u0338',
+ nless: '\u226E',
+ nLl: '\u22D8\u0338',
+ nlsim: '\u2274',
+ nLt: '\u226A\u20D2',
+ nlt: '\u226E',
+ nltri: '\u22EA',
+ nltrie: '\u22EC',
+ nLtv: '\u226A\u0338',
+ nmid: '\u2224',
+ NoBreak: '\u2060',
+ NonBreakingSpace: '\u00A0',
+ Nopf: '\u2115',
+ nopf: '\uD835\uDD5F',
+ Not: '\u2AEC',
+ not: '\u00AC',
+ NotCongruent: '\u2262',
+ NotCupCap: '\u226D',
+ NotDoubleVerticalBar: '\u2226',
+ NotElement: '\u2209',
+ NotEqual: '\u2260',
+ NotEqualTilde: '\u2242\u0338',
+ NotExists: '\u2204',
+ NotGreater: '\u226F',
+ NotGreaterEqual: '\u2271',
+ NotGreaterFullEqual: '\u2267\u0338',
+ NotGreaterGreater: '\u226B\u0338',
+ NotGreaterLess: '\u2279',
+ NotGreaterSlantEqual: '\u2A7E\u0338',
+ NotGreaterTilde: '\u2275',
+ NotHumpDownHump: '\u224E\u0338',
+ NotHumpEqual: '\u224F\u0338',
+ notin: '\u2209',
+ notindot: '\u22F5\u0338',
+ notinE: '\u22F9\u0338',
+ notinva: '\u2209',
+ notinvb: '\u22F7',
+ notinvc: '\u22F6',
+ NotLeftTriangle: '\u22EA',
+ NotLeftTriangleBar: '\u29CF\u0338',
+ NotLeftTriangleEqual: '\u22EC',
+ NotLess: '\u226E',
+ NotLessEqual: '\u2270',
+ NotLessGreater: '\u2278',
+ NotLessLess: '\u226A\u0338',
+ NotLessSlantEqual: '\u2A7D\u0338',
+ NotLessTilde: '\u2274',
+ NotNestedGreaterGreater: '\u2AA2\u0338',
+ NotNestedLessLess: '\u2AA1\u0338',
+ notni: '\u220C',
+ notniva: '\u220C',
+ notnivb: '\u22FE',
+ notnivc: '\u22FD',
+ NotPrecedes: '\u2280',
+ NotPrecedesEqual: '\u2AAF\u0338',
+ NotPrecedesSlantEqual: '\u22E0',
+ NotReverseElement: '\u220C',
+ NotRightTriangle: '\u22EB',
+ NotRightTriangleBar: '\u29D0\u0338',
+ NotRightTriangleEqual: '\u22ED',
+ NotSquareSubset: '\u228F\u0338',
+ NotSquareSubsetEqual: '\u22E2',
+ NotSquareSuperset: '\u2290\u0338',
+ NotSquareSupersetEqual: '\u22E3',
+ NotSubset: '\u2282\u20D2',
+ NotSubsetEqual: '\u2288',
+ NotSucceeds: '\u2281',
+ NotSucceedsEqual: '\u2AB0\u0338',
+ NotSucceedsSlantEqual: '\u22E1',
+ NotSucceedsTilde: '\u227F\u0338',
+ NotSuperset: '\u2283\u20D2',
+ NotSupersetEqual: '\u2289',
+ NotTilde: '\u2241',
+ NotTildeEqual: '\u2244',
+ NotTildeFullEqual: '\u2247',
+ NotTildeTilde: '\u2249',
+ NotVerticalBar: '\u2224',
+ npar: '\u2226',
+ nparallel: '\u2226',
+ nparsl: '\u2AFD\u20E5',
+ npart: '\u2202\u0338',
+ npolint: '\u2A14',
+ npr: '\u2280',
+ nprcue: '\u22E0',
+ npre: '\u2AAF\u0338',
+ nprec: '\u2280',
+ npreceq: '\u2AAF\u0338',
+ nrArr: '\u21CF',
+ nrarr: '\u219B',
+ nrarrc: '\u2933\u0338',
+ nrarrw: '\u219D\u0338',
+ nRightarrow: '\u21CF',
+ nrightarrow: '\u219B',
+ nrtri: '\u22EB',
+ nrtrie: '\u22ED',
+ nsc: '\u2281',
+ nsccue: '\u22E1',
+ nsce: '\u2AB0\u0338',
+ Nscr: '\uD835\uDCA9',
+ nscr: '\uD835\uDCC3',
+ nshortmid: '\u2224',
+ nshortparallel: '\u2226',
+ nsim: '\u2241',
+ nsime: '\u2244',
+ nsimeq: '\u2244',
+ nsmid: '\u2224',
+ nspar: '\u2226',
+ nsqsube: '\u22E2',
+ nsqsupe: '\u22E3',
+ nsub: '\u2284',
+ nsubE: '\u2AC5\u0338',
+ nsube: '\u2288',
+ nsubset: '\u2282\u20D2',
+ nsubseteq: '\u2288',
+ nsubseteqq: '\u2AC5\u0338',
+ nsucc: '\u2281',
+ nsucceq: '\u2AB0\u0338',
+ nsup: '\u2285',
+ nsupE: '\u2AC6\u0338',
+ nsupe: '\u2289',
+ nsupset: '\u2283\u20D2',
+ nsupseteq: '\u2289',
+ nsupseteqq: '\u2AC6\u0338',
+ ntgl: '\u2279',
+ Ntilde: '\u00D1',
+ ntilde: '\u00F1',
+ ntlg: '\u2278',
+ ntriangleleft: '\u22EA',
+ ntrianglelefteq: '\u22EC',
+ ntriangleright: '\u22EB',
+ ntrianglerighteq: '\u22ED',
+ Nu: '\u039D',
+ nu: '\u03BD',
+ num: '\u0023',
+ numero: '\u2116',
+ numsp: '\u2007',
+ nvap: '\u224D\u20D2',
+ nVDash: '\u22AF',
+ nVdash: '\u22AE',
+ nvDash: '\u22AD',
+ nvdash: '\u22AC',
+ nvge: '\u2265\u20D2',
+ nvgt: '\u003E\u20D2',
+ nvHarr: '\u2904',
+ nvinfin: '\u29DE',
+ nvlArr: '\u2902',
+ nvle: '\u2264\u20D2',
+ nvlt: '\u003C\u20D2',
+ nvltrie: '\u22B4\u20D2',
+ nvrArr: '\u2903',
+ nvrtrie: '\u22B5\u20D2',
+ nvsim: '\u223C\u20D2',
+ nwarhk: '\u2923',
+ nwArr: '\u21D6',
+ nwarr: '\u2196',
+ nwarrow: '\u2196',
+ nwnear: '\u2927',
+ Oacute: '\u00D3',
+ oacute: '\u00F3',
+ oast: '\u229B',
+ ocir: '\u229A',
+ Ocirc: '\u00D4',
+ ocirc: '\u00F4',
+ Ocy: '\u041E',
+ ocy: '\u043E',
+ odash: '\u229D',
+ Odblac: '\u0150',
+ odblac: '\u0151',
+ odiv: '\u2A38',
+ odot: '\u2299',
+ odsold: '\u29BC',
+ OElig: '\u0152',
+ oelig: '\u0153',
+ ofcir: '\u29BF',
+ Ofr: '\uD835\uDD12',
+ ofr: '\uD835\uDD2C',
+ ogon: '\u02DB',
+ Ograve: '\u00D2',
+ ograve: '\u00F2',
+ ogt: '\u29C1',
+ ohbar: '\u29B5',
+ ohm: '\u03A9',
+ oint: '\u222E',
+ olarr: '\u21BA',
+ olcir: '\u29BE',
+ olcross: '\u29BB',
+ oline: '\u203E',
+ olt: '\u29C0',
+ Omacr: '\u014C',
+ omacr: '\u014D',
+ Omega: '\u03A9',
+ omega: '\u03C9',
+ Omicron: '\u039F',
+ omicron: '\u03BF',
+ omid: '\u29B6',
+ ominus: '\u2296',
+ Oopf: '\uD835\uDD46',
+ oopf: '\uD835\uDD60',
+ opar: '\u29B7',
+ OpenCurlyDoubleQuote: '\u201C',
+ OpenCurlyQuote: '\u2018',
+ operp: '\u29B9',
+ oplus: '\u2295',
+ Or: '\u2A54',
+ or: '\u2228',
+ orarr: '\u21BB',
+ ord: '\u2A5D',
+ order: '\u2134',
+ orderof: '\u2134',
+ ordf: '\u00AA',
+ ordm: '\u00BA',
+ origof: '\u22B6',
+ oror: '\u2A56',
+ orslope: '\u2A57',
+ orv: '\u2A5B',
+ oS: '\u24C8',
+ Oscr: '\uD835\uDCAA',
+ oscr: '\u2134',
+ Oslash: '\u00D8',
+ oslash: '\u00F8',
+ osol: '\u2298',
+ Otilde: '\u00D5',
+ otilde: '\u00F5',
+ Otimes: '\u2A37',
+ otimes: '\u2297',
+ otimesas: '\u2A36',
+ Ouml: '\u00D6',
+ ouml: '\u00F6',
+ ovbar: '\u233D',
+ OverBar: '\u203E',
+ OverBrace: '\u23DE',
+ OverBracket: '\u23B4',
+ OverParenthesis: '\u23DC',
+ par: '\u2225',
+ para: '\u00B6',
+ parallel: '\u2225',
+ parsim: '\u2AF3',
+ parsl: '\u2AFD',
+ part: '\u2202',
+ PartialD: '\u2202',
+ Pcy: '\u041F',
+ pcy: '\u043F',
+ percnt: '\u0025',
+ period: '\u002E',
+ permil: '\u2030',
+ perp: '\u22A5',
+ pertenk: '\u2031',
+ Pfr: '\uD835\uDD13',
+ pfr: '\uD835\uDD2D',
+ Phi: '\u03A6',
+ phi: '\u03C6',
+ phiv: '\u03D5',
+ phmmat: '\u2133',
+ phone: '\u260E',
+ Pi: '\u03A0',
+ pi: '\u03C0',
+ pitchfork: '\u22D4',
+ piv: '\u03D6',
+ planck: '\u210F',
+ planckh: '\u210E',
+ plankv: '\u210F',
+ plus: '\u002B',
+ plusacir: '\u2A23',
+ plusb: '\u229E',
+ pluscir: '\u2A22',
+ plusdo: '\u2214',
+ plusdu: '\u2A25',
+ pluse: '\u2A72',
+ PlusMinus: '\u00B1',
+ plusmn: '\u00B1',
+ plussim: '\u2A26',
+ plustwo: '\u2A27',
+ pm: '\u00B1',
+ Poincareplane: '\u210C',
+ pointint: '\u2A15',
+ Popf: '\u2119',
+ popf: '\uD835\uDD61',
+ pound: '\u00A3',
+ Pr: '\u2ABB',
+ pr: '\u227A',
+ prap: '\u2AB7',
+ prcue: '\u227C',
+ prE: '\u2AB3',
+ pre: '\u2AAF',
+ prec: '\u227A',
+ precapprox: '\u2AB7',
+ preccurlyeq: '\u227C',
+ Precedes: '\u227A',
+ PrecedesEqual: '\u2AAF',
+ PrecedesSlantEqual: '\u227C',
+ PrecedesTilde: '\u227E',
+ preceq: '\u2AAF',
+ precnapprox: '\u2AB9',
+ precneqq: '\u2AB5',
+ precnsim: '\u22E8',
+ precsim: '\u227E',
+ Prime: '\u2033',
+ prime: '\u2032',
+ primes: '\u2119',
+ prnap: '\u2AB9',
+ prnE: '\u2AB5',
+ prnsim: '\u22E8',
+ prod: '\u220F',
+ Product: '\u220F',
+ profalar: '\u232E',
+ profline: '\u2312',
+ profsurf: '\u2313',
+ prop: '\u221D',
+ Proportion: '\u2237',
+ Proportional: '\u221D',
+ propto: '\u221D',
+ prsim: '\u227E',
+ prurel: '\u22B0',
+ Pscr: '\uD835\uDCAB',
+ pscr: '\uD835\uDCC5',
+ Psi: '\u03A8',
+ psi: '\u03C8',
+ puncsp: '\u2008',
+ Qfr: '\uD835\uDD14',
+ qfr: '\uD835\uDD2E',
+ qint: '\u2A0C',
+ Qopf: '\u211A',
+ qopf: '\uD835\uDD62',
+ qprime: '\u2057',
+ Qscr: '\uD835\uDCAC',
+ qscr: '\uD835\uDCC6',
+ quaternions: '\u210D',
+ quatint: '\u2A16',
+ quest: '\u003F',
+ questeq: '\u225F',
+ QUOT: '\u0022',
+ quot: '\u0022',
+ rAarr: '\u21DB',
+ race: '\u223D\u0331',
+ Racute: '\u0154',
+ racute: '\u0155',
+ radic: '\u221A',
+ raemptyv: '\u29B3',
+ Rang: '\u27EB',
+ rang: '\u27E9',
+ rangd: '\u2992',
+ range: '\u29A5',
+ rangle: '\u27E9',
+ raquo: '\u00BB',
+ Rarr: '\u21A0',
+ rArr: '\u21D2',
+ rarr: '\u2192',
+ rarrap: '\u2975',
+ rarrb: '\u21E5',
+ rarrbfs: '\u2920',
+ rarrc: '\u2933',
+ rarrfs: '\u291E',
+ rarrhk: '\u21AA',
+ rarrlp: '\u21AC',
+ rarrpl: '\u2945',
+ rarrsim: '\u2974',
+ Rarrtl: '\u2916',
+ rarrtl: '\u21A3',
+ rarrw: '\u219D',
+ rAtail: '\u291C',
+ ratail: '\u291A',
+ ratio: '\u2236',
+ rationals: '\u211A',
+ RBarr: '\u2910',
+ rBarr: '\u290F',
+ rbarr: '\u290D',
+ rbbrk: '\u2773',
+ rbrace: '\u007D',
+ rbrack: '\u005D',
+ rbrke: '\u298C',
+ rbrksld: '\u298E',
+ rbrkslu: '\u2990',
+ Rcaron: '\u0158',
+ rcaron: '\u0159',
+ Rcedil: '\u0156',
+ rcedil: '\u0157',
+ rceil: '\u2309',
+ rcub: '\u007D',
+ Rcy: '\u0420',
+ rcy: '\u0440',
+ rdca: '\u2937',
+ rdldhar: '\u2969',
+ rdquo: '\u201D',
+ rdquor: '\u201D',
+ rdsh: '\u21B3',
+ Re: '\u211C',
+ real: '\u211C',
+ realine: '\u211B',
+ realpart: '\u211C',
+ reals: '\u211D',
+ rect: '\u25AD',
+ REG: '\u00AE',
+ reg: '\u00AE',
+ ReverseElement: '\u220B',
+ ReverseEquilibrium: '\u21CB',
+ ReverseUpEquilibrium: '\u296F',
+ rfisht: '\u297D',
+ rfloor: '\u230B',
+ Rfr: '\u211C',
+ rfr: '\uD835\uDD2F',
+ rHar: '\u2964',
+ rhard: '\u21C1',
+ rharu: '\u21C0',
+ rharul: '\u296C',
+ Rho: '\u03A1',
+ rho: '\u03C1',
+ rhov: '\u03F1',
+ RightAngleBracket: '\u27E9',
+ RightArrow: '\u2192',
+ Rightarrow: '\u21D2',
+ rightarrow: '\u2192',
+ RightArrowBar: '\u21E5',
+ RightArrowLeftArrow: '\u21C4',
+ rightarrowtail: '\u21A3',
+ RightCeiling: '\u2309',
+ RightDoubleBracket: '\u27E7',
+ RightDownTeeVector: '\u295D',
+ RightDownVector: '\u21C2',
+ RightDownVectorBar: '\u2955',
+ RightFloor: '\u230B',
+ rightharpoondown: '\u21C1',
+ rightharpoonup: '\u21C0',
+ rightleftarrows: '\u21C4',
+ rightleftharpoons: '\u21CC',
+ rightrightarrows: '\u21C9',
+ rightsquigarrow: '\u219D',
+ RightTee: '\u22A2',
+ RightTeeArrow: '\u21A6',
+ RightTeeVector: '\u295B',
+ rightthreetimes: '\u22CC',
+ RightTriangle: '\u22B3',
+ RightTriangleBar: '\u29D0',
+ RightTriangleEqual: '\u22B5',
+ RightUpDownVector: '\u294F',
+ RightUpTeeVector: '\u295C',
+ RightUpVector: '\u21BE',
+ RightUpVectorBar: '\u2954',
+ RightVector: '\u21C0',
+ RightVectorBar: '\u2953',
+ ring: '\u02DA',
+ risingdotseq: '\u2253',
+ rlarr: '\u21C4',
+ rlhar: '\u21CC',
+ rlm: '\u200F',
+ rmoust: '\u23B1',
+ rmoustache: '\u23B1',
+ rnmid: '\u2AEE',
+ roang: '\u27ED',
+ roarr: '\u21FE',
+ robrk: '\u27E7',
+ ropar: '\u2986',
+ Ropf: '\u211D',
+ ropf: '\uD835\uDD63',
+ roplus: '\u2A2E',
+ rotimes: '\u2A35',
+ RoundImplies: '\u2970',
+ rpar: '\u0029',
+ rpargt: '\u2994',
+ rppolint: '\u2A12',
+ rrarr: '\u21C9',
+ Rrightarrow: '\u21DB',
+ rsaquo: '\u203A',
+ Rscr: '\u211B',
+ rscr: '\uD835\uDCC7',
+ Rsh: '\u21B1',
+ rsh: '\u21B1',
+ rsqb: '\u005D',
+ rsquo: '\u2019',
+ rsquor: '\u2019',
+ rthree: '\u22CC',
+ rtimes: '\u22CA',
+ rtri: '\u25B9',
+ rtrie: '\u22B5',
+ rtrif: '\u25B8',
+ rtriltri: '\u29CE',
+ RuleDelayed: '\u29F4',
+ ruluhar: '\u2968',
+ rx: '\u211E',
+ Sacute: '\u015A',
+ sacute: '\u015B',
+ sbquo: '\u201A',
+ Sc: '\u2ABC',
+ sc: '\u227B',
+ scap: '\u2AB8',
+ Scaron: '\u0160',
+ scaron: '\u0161',
+ sccue: '\u227D',
+ scE: '\u2AB4',
+ sce: '\u2AB0',
+ Scedil: '\u015E',
+ scedil: '\u015F',
+ Scirc: '\u015C',
+ scirc: '\u015D',
+ scnap: '\u2ABA',
+ scnE: '\u2AB6',
+ scnsim: '\u22E9',
+ scpolint: '\u2A13',
+ scsim: '\u227F',
+ Scy: '\u0421',
+ scy: '\u0441',
+ sdot: '\u22C5',
+ sdotb: '\u22A1',
+ sdote: '\u2A66',
+ searhk: '\u2925',
+ seArr: '\u21D8',
+ searr: '\u2198',
+ searrow: '\u2198',
+ sect: '\u00A7',
+ semi: '\u003B',
+ seswar: '\u2929',
+ setminus: '\u2216',
+ setmn: '\u2216',
+ sext: '\u2736',
+ Sfr: '\uD835\uDD16',
+ sfr: '\uD835\uDD30',
+ sfrown: '\u2322',
+ sharp: '\u266F',
+ SHCHcy: '\u0429',
+ shchcy: '\u0449',
+ SHcy: '\u0428',
+ shcy: '\u0448',
+ ShortDownArrow: '\u2193',
+ ShortLeftArrow: '\u2190',
+ shortmid: '\u2223',
+ shortparallel: '\u2225',
+ ShortRightArrow: '\u2192',
+ ShortUpArrow: '\u2191',
+ shy: '\u00AD',
+ Sigma: '\u03A3',
+ sigma: '\u03C3',
+ sigmaf: '\u03C2',
+ sigmav: '\u03C2',
+ sim: '\u223C',
+ simdot: '\u2A6A',
+ sime: '\u2243',
+ simeq: '\u2243',
+ simg: '\u2A9E',
+ simgE: '\u2AA0',
+ siml: '\u2A9D',
+ simlE: '\u2A9F',
+ simne: '\u2246',
+ simplus: '\u2A24',
+ simrarr: '\u2972',
+ slarr: '\u2190',
+ SmallCircle: '\u2218',
+ smallsetminus: '\u2216',
+ smashp: '\u2A33',
+ smeparsl: '\u29E4',
+ smid: '\u2223',
+ smile: '\u2323',
+ smt: '\u2AAA',
+ smte: '\u2AAC',
+ smtes: '\u2AAC\uFE00',
+ SOFTcy: '\u042C',
+ softcy: '\u044C',
+ sol: '\u002F',
+ solb: '\u29C4',
+ solbar: '\u233F',
+ Sopf: '\uD835\uDD4A',
+ sopf: '\uD835\uDD64',
+ spades: '\u2660',
+ spadesuit: '\u2660',
+ spar: '\u2225',
+ sqcap: '\u2293',
+ sqcaps: '\u2293\uFE00',
+ sqcup: '\u2294',
+ sqcups: '\u2294\uFE00',
+ Sqrt: '\u221A',
+ sqsub: '\u228F',
+ sqsube: '\u2291',
+ sqsubset: '\u228F',
+ sqsubseteq: '\u2291',
+ sqsup: '\u2290',
+ sqsupe: '\u2292',
+ sqsupset: '\u2290',
+ sqsupseteq: '\u2292',
+ squ: '\u25A1',
+ Square: '\u25A1',
+ square: '\u25A1',
+ SquareIntersection: '\u2293',
+ SquareSubset: '\u228F',
+ SquareSubsetEqual: '\u2291',
+ SquareSuperset: '\u2290',
+ SquareSupersetEqual: '\u2292',
+ SquareUnion: '\u2294',
+ squarf: '\u25AA',
+ squf: '\u25AA',
+ srarr: '\u2192',
+ Sscr: '\uD835\uDCAE',
+ sscr: '\uD835\uDCC8',
+ ssetmn: '\u2216',
+ ssmile: '\u2323',
+ sstarf: '\u22C6',
+ Star: '\u22C6',
+ star: '\u2606',
+ starf: '\u2605',
+ straightepsilon: '\u03F5',
+ straightphi: '\u03D5',
+ strns: '\u00AF',
+ Sub: '\u22D0',
+ sub: '\u2282',
+ subdot: '\u2ABD',
+ subE: '\u2AC5',
+ sube: '\u2286',
+ subedot: '\u2AC3',
+ submult: '\u2AC1',
+ subnE: '\u2ACB',
+ subne: '\u228A',
+ subplus: '\u2ABF',
+ subrarr: '\u2979',
+ Subset: '\u22D0',
+ subset: '\u2282',
+ subseteq: '\u2286',
+ subseteqq: '\u2AC5',
+ SubsetEqual: '\u2286',
+ subsetneq: '\u228A',
+ subsetneqq: '\u2ACB',
+ subsim: '\u2AC7',
+ subsub: '\u2AD5',
+ subsup: '\u2AD3',
+ succ: '\u227B',
+ succapprox: '\u2AB8',
+ succcurlyeq: '\u227D',
+ Succeeds: '\u227B',
+ SucceedsEqual: '\u2AB0',
+ SucceedsSlantEqual: '\u227D',
+ SucceedsTilde: '\u227F',
+ succeq: '\u2AB0',
+ succnapprox: '\u2ABA',
+ succneqq: '\u2AB6',
+ succnsim: '\u22E9',
+ succsim: '\u227F',
+ SuchThat: '\u220B',
+ Sum: '\u2211',
+ sum: '\u2211',
+ sung: '\u266A',
+ Sup: '\u22D1',
+ sup: '\u2283',
+ sup1: '\u00B9',
+ sup2: '\u00B2',
+ sup3: '\u00B3',
+ supdot: '\u2ABE',
+ supdsub: '\u2AD8',
+ supE: '\u2AC6',
+ supe: '\u2287',
+ supedot: '\u2AC4',
+ Superset: '\u2283',
+ SupersetEqual: '\u2287',
+ suphsol: '\u27C9',
+ suphsub: '\u2AD7',
+ suplarr: '\u297B',
+ supmult: '\u2AC2',
+ supnE: '\u2ACC',
+ supne: '\u228B',
+ supplus: '\u2AC0',
+ Supset: '\u22D1',
+ supset: '\u2283',
+ supseteq: '\u2287',
+ supseteqq: '\u2AC6',
+ supsetneq: '\u228B',
+ supsetneqq: '\u2ACC',
+ supsim: '\u2AC8',
+ supsub: '\u2AD4',
+ supsup: '\u2AD6',
+ swarhk: '\u2926',
+ swArr: '\u21D9',
+ swarr: '\u2199',
+ swarrow: '\u2199',
+ swnwar: '\u292A',
+ szlig: '\u00DF',
+ Tab: '\u0009',
+ target: '\u2316',
+ Tau: '\u03A4',
+ tau: '\u03C4',
+ tbrk: '\u23B4',
+ Tcaron: '\u0164',
+ tcaron: '\u0165',
+ Tcedil: '\u0162',
+ tcedil: '\u0163',
+ Tcy: '\u0422',
+ tcy: '\u0442',
+ tdot: '\u20DB',
+ telrec: '\u2315',
+ Tfr: '\uD835\uDD17',
+ tfr: '\uD835\uDD31',
+ there4: '\u2234',
+ Therefore: '\u2234',
+ therefore: '\u2234',
+ Theta: '\u0398',
+ theta: '\u03B8',
+ thetasym: '\u03D1',
+ thetav: '\u03D1',
+ thickapprox: '\u2248',
+ thicksim: '\u223C',
+ ThickSpace: '\u205F\u200A',
+ thinsp: '\u2009',
+ ThinSpace: '\u2009',
+ thkap: '\u2248',
+ thksim: '\u223C',
+ THORN: '\u00DE',
+ thorn: '\u00FE',
+ Tilde: '\u223C',
+ tilde: '\u02DC',
+ TildeEqual: '\u2243',
+ TildeFullEqual: '\u2245',
+ TildeTilde: '\u2248',
+ times: '\u00D7',
+ timesb: '\u22A0',
+ timesbar: '\u2A31',
+ timesd: '\u2A30',
+ tint: '\u222D',
+ toea: '\u2928',
+ top: '\u22A4',
+ topbot: '\u2336',
+ topcir: '\u2AF1',
+ Topf: '\uD835\uDD4B',
+ topf: '\uD835\uDD65',
+ topfork: '\u2ADA',
+ tosa: '\u2929',
+ tprime: '\u2034',
+ TRADE: '\u2122',
+ trade: '\u2122',
+ triangle: '\u25B5',
+ triangledown: '\u25BF',
+ triangleleft: '\u25C3',
+ trianglelefteq: '\u22B4',
+ triangleq: '\u225C',
+ triangleright: '\u25B9',
+ trianglerighteq: '\u22B5',
+ tridot: '\u25EC',
+ trie: '\u225C',
+ triminus: '\u2A3A',
+ TripleDot: '\u20DB',
+ triplus: '\u2A39',
+ trisb: '\u29CD',
+ tritime: '\u2A3B',
+ trpezium: '\u23E2',
+ Tscr: '\uD835\uDCAF',
+ tscr: '\uD835\uDCC9',
+ TScy: '\u0426',
+ tscy: '\u0446',
+ TSHcy: '\u040B',
+ tshcy: '\u045B',
+ Tstrok: '\u0166',
+ tstrok: '\u0167',
+ twixt: '\u226C',
+ twoheadleftarrow: '\u219E',
+ twoheadrightarrow: '\u21A0',
+ Uacute: '\u00DA',
+ uacute: '\u00FA',
+ Uarr: '\u219F',
+ uArr: '\u21D1',
+ uarr: '\u2191',
+ Uarrocir: '\u2949',
+ Ubrcy: '\u040E',
+ ubrcy: '\u045E',
+ Ubreve: '\u016C',
+ ubreve: '\u016D',
+ Ucirc: '\u00DB',
+ ucirc: '\u00FB',
+ Ucy: '\u0423',
+ ucy: '\u0443',
+ udarr: '\u21C5',
+ Udblac: '\u0170',
+ udblac: '\u0171',
+ udhar: '\u296E',
+ ufisht: '\u297E',
+ Ufr: '\uD835\uDD18',
+ ufr: '\uD835\uDD32',
+ Ugrave: '\u00D9',
+ ugrave: '\u00F9',
+ uHar: '\u2963',
+ uharl: '\u21BF',
+ uharr: '\u21BE',
+ uhblk: '\u2580',
+ ulcorn: '\u231C',
+ ulcorner: '\u231C',
+ ulcrop: '\u230F',
+ ultri: '\u25F8',
+ Umacr: '\u016A',
+ umacr: '\u016B',
+ uml: '\u00A8',
+ UnderBar: '\u005F',
+ UnderBrace: '\u23DF',
+ UnderBracket: '\u23B5',
+ UnderParenthesis: '\u23DD',
+ Union: '\u22C3',
+ UnionPlus: '\u228E',
+ Uogon: '\u0172',
+ uogon: '\u0173',
+ Uopf: '\uD835\uDD4C',
+ uopf: '\uD835\uDD66',
+ UpArrow: '\u2191',
+ Uparrow: '\u21D1',
+ uparrow: '\u2191',
+ UpArrowBar: '\u2912',
+ UpArrowDownArrow: '\u21C5',
+ UpDownArrow: '\u2195',
+ Updownarrow: '\u21D5',
+ updownarrow: '\u2195',
+ UpEquilibrium: '\u296E',
+ upharpoonleft: '\u21BF',
+ upharpoonright: '\u21BE',
+ uplus: '\u228E',
+ UpperLeftArrow: '\u2196',
+ UpperRightArrow: '\u2197',
+ Upsi: '\u03D2',
+ upsi: '\u03C5',
+ upsih: '\u03D2',
+ Upsilon: '\u03A5',
+ upsilon: '\u03C5',
+ UpTee: '\u22A5',
+ UpTeeArrow: '\u21A5',
+ upuparrows: '\u21C8',
+ urcorn: '\u231D',
+ urcorner: '\u231D',
+ urcrop: '\u230E',
+ Uring: '\u016E',
+ uring: '\u016F',
+ urtri: '\u25F9',
+ Uscr: '\uD835\uDCB0',
+ uscr: '\uD835\uDCCA',
+ utdot: '\u22F0',
+ Utilde: '\u0168',
+ utilde: '\u0169',
+ utri: '\u25B5',
+ utrif: '\u25B4',
+ uuarr: '\u21C8',
+ Uuml: '\u00DC',
+ uuml: '\u00FC',
+ uwangle: '\u29A7',
+ vangrt: '\u299C',
+ varepsilon: '\u03F5',
+ varkappa: '\u03F0',
+ varnothing: '\u2205',
+ varphi: '\u03D5',
+ varpi: '\u03D6',
+ varpropto: '\u221D',
+ vArr: '\u21D5',
+ varr: '\u2195',
+ varrho: '\u03F1',
+ varsigma: '\u03C2',
+ varsubsetneq: '\u228A\uFE00',
+ varsubsetneqq: '\u2ACB\uFE00',
+ varsupsetneq: '\u228B\uFE00',
+ varsupsetneqq: '\u2ACC\uFE00',
+ vartheta: '\u03D1',
+ vartriangleleft: '\u22B2',
+ vartriangleright: '\u22B3',
+ Vbar: '\u2AEB',
+ vBar: '\u2AE8',
+ vBarv: '\u2AE9',
+ Vcy: '\u0412',
+ vcy: '\u0432',
+ VDash: '\u22AB',
+ Vdash: '\u22A9',
+ vDash: '\u22A8',
+ vdash: '\u22A2',
+ Vdashl: '\u2AE6',
+ Vee: '\u22C1',
+ vee: '\u2228',
+ veebar: '\u22BB',
+ veeeq: '\u225A',
+ vellip: '\u22EE',
+ Verbar: '\u2016',
+ verbar: '\u007C',
+ Vert: '\u2016',
+ vert: '\u007C',
+ VerticalBar: '\u2223',
+ VerticalLine: '\u007C',
+ VerticalSeparator: '\u2758',
+ VerticalTilde: '\u2240',
+ VeryThinSpace: '\u200A',
+ Vfr: '\uD835\uDD19',
+ vfr: '\uD835\uDD33',
+ vltri: '\u22B2',
+ vnsub: '\u2282\u20D2',
+ vnsup: '\u2283\u20D2',
+ Vopf: '\uD835\uDD4D',
+ vopf: '\uD835\uDD67',
+ vprop: '\u221D',
+ vrtri: '\u22B3',
+ Vscr: '\uD835\uDCB1',
+ vscr: '\uD835\uDCCB',
+ vsubnE: '\u2ACB\uFE00',
+ vsubne: '\u228A\uFE00',
+ vsupnE: '\u2ACC\uFE00',
+ vsupne: '\u228B\uFE00',
+ Vvdash: '\u22AA',
+ vzigzag: '\u299A',
+ Wcirc: '\u0174',
+ wcirc: '\u0175',
+ wedbar: '\u2A5F',
+ Wedge: '\u22C0',
+ wedge: '\u2227',
+ wedgeq: '\u2259',
+ weierp: '\u2118',
+ Wfr: '\uD835\uDD1A',
+ wfr: '\uD835\uDD34',
+ Wopf: '\uD835\uDD4E',
+ wopf: '\uD835\uDD68',
+ wp: '\u2118',
+ wr: '\u2240',
+ wreath: '\u2240',
+ Wscr: '\uD835\uDCB2',
+ wscr: '\uD835\uDCCC',
+ xcap: '\u22C2',
+ xcirc: '\u25EF',
+ xcup: '\u22C3',
+ xdtri: '\u25BD',
+ Xfr: '\uD835\uDD1B',
+ xfr: '\uD835\uDD35',
+ xhArr: '\u27FA',
+ xharr: '\u27F7',
+ Xi: '\u039E',
+ xi: '\u03BE',
+ xlArr: '\u27F8',
+ xlarr: '\u27F5',
+ xmap: '\u27FC',
+ xnis: '\u22FB',
+ xodot: '\u2A00',
+ Xopf: '\uD835\uDD4F',
+ xopf: '\uD835\uDD69',
+ xoplus: '\u2A01',
+ xotime: '\u2A02',
+ xrArr: '\u27F9',
+ xrarr: '\u27F6',
+ Xscr: '\uD835\uDCB3',
+ xscr: '\uD835\uDCCD',
+ xsqcup: '\u2A06',
+ xuplus: '\u2A04',
+ xutri: '\u25B3',
+ xvee: '\u22C1',
+ xwedge: '\u22C0',
+ Yacute: '\u00DD',
+ yacute: '\u00FD',
+ YAcy: '\u042F',
+ yacy: '\u044F',
+ Ycirc: '\u0176',
+ ycirc: '\u0177',
+ Ycy: '\u042B',
+ ycy: '\u044B',
+ yen: '\u00A5',
+ Yfr: '\uD835\uDD1C',
+ yfr: '\uD835\uDD36',
+ YIcy: '\u0407',
+ yicy: '\u0457',
+ Yopf: '\uD835\uDD50',
+ yopf: '\uD835\uDD6A',
+ Yscr: '\uD835\uDCB4',
+ yscr: '\uD835\uDCCE',
+ YUcy: '\u042E',
+ yucy: '\u044E',
+ Yuml: '\u0178',
+ yuml: '\u00FF',
+ Zacute: '\u0179',
+ zacute: '\u017A',
+ Zcaron: '\u017D',
+ zcaron: '\u017E',
+ Zcy: '\u0417',
+ zcy: '\u0437',
+ Zdot: '\u017B',
+ zdot: '\u017C',
+ zeetrf: '\u2128',
+ ZeroWidthSpace: '\u200B',
+ Zeta: '\u0396',
+ zeta: '\u03B6',
+ Zfr: '\u2128',
+ zfr: '\uD835\uDD37',
+ ZHcy: '\u0416',
+ zhcy: '\u0436',
+ zigrarr: '\u21DD',
+ Zopf: '\u2124',
+ zopf: '\uD835\uDD6B',
+ Zscr: '\uD835\uDCB5',
+ zscr: '\uD835\uDCCF',
+ zwj: '\u200D',
+ zwnj: '\u200C',
+});
+
+/**
+ * @deprecated
+ * Use `HTML_ENTITIES` instead.
+ * @see {@link HTML_ENTITIES}
+ */
+exports.entityMap = exports.HTML_ENTITIES;
+
+},{"./conventions":2}],6:[function(require,module,exports){
+'use strict';
+
+var conventions = require('./conventions');
+
+function extendError(constructor, writableName) {
+ constructor.prototype = Object.create(Error.prototype, {
+ constructor: { value: constructor },
+ name: { value: constructor.name, enumerable: true, writable: writableName },
+ });
+}
+
+var DOMExceptionName = conventions.freeze({
+ /**
+ * the default value as defined by the spec
+ */
+ Error: 'Error',
+ /**
+ * @deprecated
+ * Use RangeError instead.
+ */
+ IndexSizeError: 'IndexSizeError',
+ /**
+ * @deprecated
+ * Just to match the related static code, not part of the spec.
+ */
+ DomstringSizeError: 'DomstringSizeError',
+ HierarchyRequestError: 'HierarchyRequestError',
+ WrongDocumentError: 'WrongDocumentError',
+ InvalidCharacterError: 'InvalidCharacterError',
+ /**
+ * @deprecated
+ * Just to match the related static code, not part of the spec.
+ */
+ NoDataAllowedError: 'NoDataAllowedError',
+ NoModificationAllowedError: 'NoModificationAllowedError',
+ NotFoundError: 'NotFoundError',
+ NotSupportedError: 'NotSupportedError',
+ InUseAttributeError: 'InUseAttributeError',
+ InvalidStateError: 'InvalidStateError',
+ SyntaxError: 'SyntaxError',
+ InvalidModificationError: 'InvalidModificationError',
+ NamespaceError: 'NamespaceError',
+ /**
+ * @deprecated
+ * Use TypeError for invalid arguments,
+ * "NotSupportedError" DOMException for unsupported operations,
+ * and "NotAllowedError" DOMException for denied requests instead.
+ */
+ InvalidAccessError: 'InvalidAccessError',
+ /**
+ * @deprecated
+ * Just to match the related static code, not part of the spec.
+ */
+ ValidationError: 'ValidationError',
+ /**
+ * @deprecated
+ * Use TypeError instead.
+ */
+ TypeMismatchError: 'TypeMismatchError',
+ SecurityError: 'SecurityError',
+ NetworkError: 'NetworkError',
+ AbortError: 'AbortError',
+ /**
+ * @deprecated
+ * Just to match the related static code, not part of the spec.
+ */
+ URLMismatchError: 'URLMismatchError',
+ QuotaExceededError: 'QuotaExceededError',
+ TimeoutError: 'TimeoutError',
+ InvalidNodeTypeError: 'InvalidNodeTypeError',
+ DataCloneError: 'DataCloneError',
+ EncodingError: 'EncodingError',
+ NotReadableError: 'NotReadableError',
+ UnknownError: 'UnknownError',
+ ConstraintError: 'ConstraintError',
+ DataError: 'DataError',
+ TransactionInactiveError: 'TransactionInactiveError',
+ ReadOnlyError: 'ReadOnlyError',
+ VersionError: 'VersionError',
+ OperationError: 'OperationError',
+ NotAllowedError: 'NotAllowedError',
+ OptOutError: 'OptOutError',
+});
+var DOMExceptionNames = Object.keys(DOMExceptionName);
+
+function isValidDomExceptionCode(value) {
+ return typeof value === 'number' && value >= 1 && value <= 25;
+}
+function endsWithError(value) {
+ return typeof value === 'string' && value.substring(value.length - DOMExceptionName.Error.length) === DOMExceptionName.Error;
+}
+/**
+ * DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation
+ * is impossible to perform (either for logical reasons, because data is lost, or because the
+ * implementation has become unstable). In general, DOM methods return specific error values in
+ * ordinary processing situations, such as out-of-bound errors when using NodeList.
+ *
+ * Implementations should raise other exceptions under other circumstances. For example,
+ * implementations should raise an implementation-dependent exception if a null argument is
+ * passed when null was not expected.
+ *
+ * This implementation supports the following usages:
+ * 1. according to the living standard (both arguments are optional):
+ * ```
+ * new DOMException("message (can be empty)", DOMExceptionNames.HierarchyRequestError)
+ * ```
+ * 2. according to previous xmldom implementation (only the first argument is required):
+ * ```
+ * new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "optional message")
+ * ```
+ * both result in the proper name being set.
+ *
+ * @class DOMException
+ * @param {number | string} messageOrCode
+ * The reason why an operation is not acceptable.
+ * If it is a number, it is used to determine the `name`, see
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-258A00AF ExceptionCode}
+ * @param {string | keyof typeof DOMExceptionName | Error} [nameOrMessage]
+ * The `name` to use for the error.
+ * If `messageOrCode` is a number, this arguments is used as the `message` instead.
+ * @augments Error
+ * @see https://webidl.spec.whatwg.org/#idl-DOMException
+ * @see https://webidl.spec.whatwg.org/#dfn-error-names-table
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-17189187
+ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
+ * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
+ */
+function DOMException(messageOrCode, nameOrMessage) {
+ // support old way of passing arguments: first argument is a valid number
+ if (isValidDomExceptionCode(messageOrCode)) {
+ this.name = DOMExceptionNames[messageOrCode];
+ this.message = nameOrMessage || '';
+ } else {
+ this.message = messageOrCode;
+ this.name = endsWithError(nameOrMessage) ? nameOrMessage : DOMExceptionName.Error;
+ }
+ if (Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
+}
+extendError(DOMException, true);
+Object.defineProperties(DOMException.prototype, {
+ code: {
+ enumerable: true,
+ get: function () {
+ var code = DOMExceptionNames.indexOf(this.name);
+ if (isValidDomExceptionCode(code)) return code;
+ return 0;
+ },
+ },
+});
+
+var ExceptionCode = {
+ INDEX_SIZE_ERR: 1,
+ DOMSTRING_SIZE_ERR: 2,
+ HIERARCHY_REQUEST_ERR: 3,
+ WRONG_DOCUMENT_ERR: 4,
+ INVALID_CHARACTER_ERR: 5,
+ NO_DATA_ALLOWED_ERR: 6,
+ NO_MODIFICATION_ALLOWED_ERR: 7,
+ NOT_FOUND_ERR: 8,
+ NOT_SUPPORTED_ERR: 9,
+ INUSE_ATTRIBUTE_ERR: 10,
+ INVALID_STATE_ERR: 11,
+ SYNTAX_ERR: 12,
+ INVALID_MODIFICATION_ERR: 13,
+ NAMESPACE_ERR: 14,
+ INVALID_ACCESS_ERR: 15,
+ VALIDATION_ERR: 16,
+ TYPE_MISMATCH_ERR: 17,
+ SECURITY_ERR: 18,
+ NETWORK_ERR: 19,
+ ABORT_ERR: 20,
+ URL_MISMATCH_ERR: 21,
+ QUOTA_EXCEEDED_ERR: 22,
+ TIMEOUT_ERR: 23,
+ INVALID_NODE_TYPE_ERR: 24,
+ DATA_CLONE_ERR: 25,
+};
+
+var entries = Object.entries(ExceptionCode);
+for (var i = 0; i < entries.length; i++) {
+ var key = entries[i][0];
+ DOMException[key] = entries[i][1];
+}
+
+/**
+ * Creates an error that will not be caught by XMLReader aka the SAX parser.
+ *
+ * @class
+ * @param {string} message
+ * @param {any} [locator]
+ */
+function ParseError(message, locator) {
+ this.message = message;
+ this.locator = locator;
+ if (Error.captureStackTrace) Error.captureStackTrace(this, ParseError);
+}
+extendError(ParseError);
+
+exports.DOMException = DOMException;
+exports.DOMExceptionName = DOMExceptionName;
+exports.ExceptionCode = ExceptionCode;
+exports.ParseError = ParseError;
+
+},{"./conventions":2}],7:[function(require,module,exports){
+'use strict';
+
+/**
+ * Detects relevant unicode support for regular expressions in the runtime.
+ * Should the runtime not accepts the flag `u` or unicode ranges,
+ * character classes without unicode handling will be used.
+ *
+ * @param {typeof RegExp} [RegExpImpl=RegExp]
+ * For testing: the RegExp class.
+ * @returns {boolean}
+ * @see https://node.green/#ES2015-syntax-RegExp--y--and--u--flags
+ */
+function detectUnicodeSupport(RegExpImpl) {
+ try {
+ if (typeof RegExpImpl !== 'function') {
+ RegExpImpl = RegExp;
+ }
+ // eslint-disable-next-line es5/no-unicode-regex,es5/no-unicode-code-point-escape
+ var match = new RegExpImpl('\u{1d306}', 'u').exec('𝌆');
+ return !!match && match[0].length === 2;
+ } catch (error) {}
+ return false;
+}
+var UNICODE_SUPPORT = detectUnicodeSupport();
+
+/**
+ * Removes `[`, `]` and any trailing quantifiers from the source of a RegExp.
+ *
+ * @param {RegExp} regexp
+ */
+function chars(regexp) {
+ if (regexp.source[0] !== '[') {
+ throw new Error(regexp + ' can not be used with chars');
+ }
+ return regexp.source.slice(1, regexp.source.lastIndexOf(']'));
+}
+
+/**
+ * Creates a new character list regular expression,
+ * by removing `search` from the source of `regexp`.
+ *
+ * @param {RegExp} regexp
+ * @param {string} search
+ * The character(s) to remove.
+ * @returns {RegExp}
+ */
+function chars_without(regexp, search) {
+ if (regexp.source[0] !== '[') {
+ throw new Error('/' + regexp.source + '/ can not be used with chars_without');
+ }
+ if (!search || typeof search !== 'string') {
+ throw new Error(JSON.stringify(search) + ' is not a valid search');
+ }
+ if (regexp.source.indexOf(search) === -1) {
+ throw new Error('"' + search + '" is not is /' + regexp.source + '/');
+ }
+ if (search === '-' && regexp.source.indexOf(search) !== 1) {
+ throw new Error('"' + search + '" is not at the first postion of /' + regexp.source + '/');
+ }
+ return new RegExp(regexp.source.replace(search, ''), UNICODE_SUPPORT ? 'u' : '');
+}
+
+/**
+ * Combines and Regular expressions correctly by using `RegExp.source`.
+ *
+ * @param {...(RegExp | string)[]} args
+ * @returns {RegExp}
+ */
+function reg(args) {
+ var self = this;
+ return new RegExp(
+ Array.prototype.slice
+ .call(arguments)
+ .map(function (part) {
+ var isStr = typeof part === 'string';
+ if (isStr && self === undefined && part === '|') {
+ throw new Error('use regg instead of reg to wrap expressions with `|`!');
+ }
+ return isStr ? part : part.source;
+ })
+ .join(''),
+ UNICODE_SUPPORT ? 'mu' : 'm'
+ );
+}
+
+/**
+ * Like `reg` but wraps the expression in `(?:`,`)` to create a non tracking group.
+ *
+ * @param {...(RegExp | string)[]} args
+ * @returns {RegExp}
+ */
+function regg(args) {
+ if (arguments.length === 0) {
+ throw new Error('no parameters provided');
+ }
+ return reg.apply(regg, ['(?:'].concat(Array.prototype.slice.call(arguments), [')']));
+}
+
+// /**
+// * Append ^ to the beginning of the expression.
+// * @param {...(RegExp | string)[]} args
+// * @returns {RegExp}
+// */
+// function reg_start(args) {
+// if (arguments.length === 0) {
+// throw new Error('no parameters provided');
+// }
+// return reg.apply(reg_start, ['^'].concat(Array.prototype.slice.call(arguments)));
+// }
+
+// https://www.w3.org/TR/xml/#document
+// `[1] document ::= prolog element Misc*`
+// https://www.w3.org/TR/xml11/#NT-document
+// `[1] document ::= ( prolog element Misc* ) - ( Char* RestrictedChar Char* )`
+
+/**
+ * A character usually appearing in wrongly converted strings.
+ *
+ * @type {string}
+ * @see https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character
+ * @see https://nodejs.dev/en/api/v18/buffer/#buffers-and-character-encodings
+ * @see https://www.unicode.org/faq/utf_bom.html#BOM
+ * @readonly
+ */
+var UNICODE_REPLACEMENT_CHARACTER = '\uFFFD';
+// https://www.w3.org/TR/xml/#NT-Char
+// any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
+// `[2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]`
+// https://www.w3.org/TR/xml11/#NT-Char
+// `[2] Char ::= [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]`
+// https://www.w3.org/TR/xml11/#NT-RestrictedChar
+// `[2a] RestrictedChar ::= [#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] | [#x86-#x9F]`
+// https://www.w3.org/TR/xml11/#charsets
+var Char = /[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/; // without \u10000-\uEFFFF
+if (UNICODE_SUPPORT) {
+ // eslint-disable-next-line es5/no-unicode-code-point-escape
+ Char = reg('[', chars(Char), '\\u{10000}-\\u{10FFFF}', ']');
+}
+// Negation of Char: matches any character that is NOT a valid XML 1.0 Char.
+// Derived directly from the Char character class above (after the unicode-support extension).
+// XML 1.0 Char production [2]: #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+// @see https://www.w3.org/TR/xml/#NT-Char
+var InvalidChar = new RegExp('[^' + chars(Char) + ']', UNICODE_SUPPORT ? 'u' : '');
+
+var _SChar = /[\x20\x09\x0D\x0A]/;
+var SChar_s = chars(_SChar);
+// https://www.w3.org/TR/xml11/#NT-S
+// `[3] S ::= (#x20 | #x9 | #xD | #xA)+`
+var S = reg(_SChar, '+');
+// optional whitespace described as `S?` in the grammar,
+// simplified to 0-n occurrences of the character class
+// instead of 0-1 occurrences of a non-capturing group around S
+var S_OPT = reg(_SChar, '*');
+
+// https://www.w3.org/TR/xml11/#NT-NameStartChar
+// `[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]`
+var NameStartChar =
+ /[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/; // without \u10000-\uEFFFF
+if (UNICODE_SUPPORT) {
+ // eslint-disable-next-line es5/no-unicode-code-point-escape
+ NameStartChar = reg('[', chars(NameStartChar), '\\u{10000}-\\u{10FFFF}', ']');
+}
+var NameStartChar_s = chars(NameStartChar);
+
+// https://www.w3.org/TR/xml11/#NT-NameChar
+// `[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]`
+var NameChar = reg('[', NameStartChar_s, chars(/[-.0-9\xB7]/), chars(/[\u0300-\u036F\u203F-\u2040]/), ']');
+// https://www.w3.org/TR/xml11/#NT-Name
+// `[5] Name ::= NameStartChar (NameChar)*`
+var Name = reg(NameStartChar, NameChar, '*');
+/*
+https://www.w3.org/TR/xml11/#NT-Names
+`[6] Names ::= Name (#x20 Name)*`
+*/
+
+// https://www.w3.org/TR/xml11/#NT-Nmtoken
+// `[7] Nmtoken ::= (NameChar)+`
+var Nmtoken = reg(NameChar, '+');
+/*
+https://www.w3.org/TR/xml11/#NT-Nmtokens
+`[8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*`
+var Nmtokens = reg(Nmtoken, regg(/\x20/, Nmtoken), '*');
+*/
+
+// https://www.w3.org/TR/xml11/#NT-EntityRef
+// `[68] EntityRef ::= '&' Name ';'` [WFC: Entity Declared] [VC: Entity Declared] [WFC: Parsed Entity] [WFC: No Recursion]
+var EntityRef = reg('&', Name, ';');
+// https://www.w3.org/TR/xml11/#NT-CharRef
+// `[66] CharRef ::= '' [0-9]+ ';' | '' [0-9a-fA-F]+ ';'` [WFC: Legal Character]
+var CharRef = regg(/[0-9]+;|[0-9a-fA-F]+;/);
+
+/*
+https://www.w3.org/TR/xml11/#NT-Reference
+- `[67] Reference ::= EntityRef | CharRef`
+- `[66] CharRef ::= '' [0-9]+ ';' | '' [0-9a-fA-F]+ ';'` [WFC: Legal Character]
+- `[68] EntityRef ::= '&' Name ';'` [WFC: Entity Declared] [VC: Entity Declared] [WFC: Parsed Entity] [WFC: No Recursion]
+*/
+var Reference = regg(EntityRef, '|', CharRef);
+
+// https://www.w3.org/TR/xml11/#NT-PEReference
+// `[69] PEReference ::= '%' Name ';'`
+// [VC: Entity Declared] [WFC: No Recursion] [WFC: In DTD]
+var PEReference = reg('%', Name, ';');
+
+// https://www.w3.org/TR/xml11/#NT-EntityValue
+// `[9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' | "'" ([^%&'] | PEReference | Reference)* "'"`
+var EntityValue = regg(
+ reg('"', regg(/[^%&"]/, '|', PEReference, '|', Reference), '*', '"'),
+ '|',
+ reg("'", regg(/[^%&']/, '|', PEReference, '|', Reference), '*', "'")
+);
+
+// https://www.w3.org/TR/xml11/#NT-AttValue
+// `[10] AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'"`
+var AttValue = regg('"', regg(/[^<&"]/, '|', Reference), '*', '"', '|', "'", regg(/[^<&']/, '|', Reference), '*', "'");
+
+// https://www.w3.org/TR/xml-names/#ns-decl
+// https://www.w3.org/TR/xml-names/#ns-qualnames
+// NameStartChar without ":"
+var NCNameStartChar = chars_without(NameStartChar, ':');
+// https://www.w3.org/TR/xml-names/#orphans
+// `[5] NCNameChar ::= NameChar - ':'`
+// An XML NameChar, minus the ":"
+var NCNameChar = chars_without(NameChar, ':');
+// https://www.w3.org/TR/xml-names/#NT-NCName
+// `[4] NCName ::= Name - (Char* ':' Char*)`
+// An XML Name, minus the ":"
+var NCName = reg(NCNameStartChar, NCNameChar, '*');
+
+/**
+https://www.w3.org/TR/xml-names/#ns-qualnames
+
+```
+[7] QName ::= PrefixedName | UnprefixedName
+ === (NCName ':' NCName) | NCName
+ === NCName (':' NCName)?
+[8] PrefixedName ::= Prefix ':' LocalPart
+ === NCName ':' NCName
+[9] UnprefixedName ::= LocalPart
+ === NCName
+[10] Prefix ::= NCName
+[11] LocalPart ::= NCName
+```
+*/
+var QName = reg(NCName, regg(':', NCName), '?');
+var QName_exact = reg('^', QName, '$');
+var QName_group = reg('(', QName, ')');
+
+// https://www.w3.org/TR/xml11/#NT-SystemLiteral
+// `[11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")`
+var SystemLiteral = regg(/"[^"]*"|'[^']*'/);
+
+/*
+ https://www.w3.org/TR/xml11/#NT-PI
+ ```
+ [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
+ [16] PI ::= '' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
+ ```
+ target /xml/i is not excluded!
+*/
+var PI = reg(/^<\?/, '(', Name, ')', regg(S, '(', Char, '*?)'), '?', /\?>/);
+
+// https://www.w3.org/TR/xml11/#NT-PubidChar
+// `[13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]`
+var PubidChar = /[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/;
+
+// https://www.w3.org/TR/xml11/#NT-PubidLiteral
+// `[12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"`
+var PubidLiteral = regg('"', PubidChar, '*"', '|', "'", chars_without(PubidChar, "'"), "*'");
+
+// https://www.w3.org/TR/xml11/#NT-CharData
+// `[14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)`
+
+var COMMENT_START = '';
+// https://www.w3.org/TR/xml11/#NT-Comment
+// `[15] Comment ::= ''`
+var Comment = reg(COMMENT_START, regg(chars_without(Char, '-'), '|', reg('-', chars_without(Char, '-'))), '*', COMMENT_END);
+
+var PCDATA = '#PCDATA';
+// https://www.w3.org/TR/xml11/#NT-Mixed
+// `[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')'`
+// https://www.w3.org/TR/xml-names/#NT-Mixed
+// `[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? QName)* S? ')*' | '(' S? '#PCDATA' S? ')'`
+// [VC: Proper Group/PE Nesting] [VC: No Duplicate Types]
+var Mixed = regg(
+ reg(/\(/, S_OPT, PCDATA, regg(S_OPT, /\|/, S_OPT, QName), '*', S_OPT, /\)\*/),
+ '|',
+ reg(/\(/, S_OPT, PCDATA, S_OPT, /\)/)
+);
+
+var _children_quantity = /[?*+]?/;
+/*
+ `[49] choice ::= '(' S? cp ( S? '|' S? cp )+ S? ')'` [VC: Proper Group/PE Nesting]
+ `[50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'` [VC: Proper Group/PE Nesting]
+ simplification to solve circular referencing, but doesn't check validity constraint "Proper Group/PE Nesting"
+ var _choice_or_seq = reg('[', NameChar_s, SChar_s, chars(_children_quantity), '()|,]*');
+ ```
+ [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?
+ === (Name | '(' S? cp ( S? '|' S? cp )+ S? ')' | '(' S? cp ( S? ',' S? cp )* S? ')') ('?' | '*' | '+')?
+ !== (Name | [_choice_or_seq]*) ('?' | '*' | '+')?
+ ```
+ simplification to solve circular referencing, but doesn't check validity constraint "Proper Group/PE Nesting"
+ var cp = reg(regg(Name, '|', _choice_or_seq), _children_quantity);
+*/
+/*
+Inefficient regular expression (High)
+This part of the regular expression may cause exponential backtracking on strings starting with '(|' and containing many repetitions of '|'.
+https://github.com/xmldom/xmldom/security/code-scanning/91
+var choice = regg(/\(/, S_OPT, cp, regg(S_OPT, /\|/, S_OPT, cp), '+', S_OPT, /\)/);
+*/
+/*
+Inefficient regular expression (High)
+This part of the regular expression may cause exponential backtracking on strings starting with '(,' and containing many repetitions of ','.
+https://github.com/xmldom/xmldom/security/code-scanning/92
+var seq = regg(/\(/, S_OPT, cp, regg(S_OPT, /,/, S_OPT, cp), '*', S_OPT, /\)/);
+*/
+
+// `[47] children ::= (choice | seq) ('?' | '*' | '+')?`
+// simplification to solve circular referencing, but doesn't check validity constraint "Proper Group/PE Nesting"
+var children = reg(/\([^>]+\)/, _children_quantity /*regg(choice, '|', seq), _children_quantity*/);
+
+// https://www.w3.org/TR/xml11/#NT-contentspec
+// `[46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children`
+var contentspec = regg('EMPTY', '|', 'ANY', '|', Mixed, '|', children);
+
+var ELEMENTDECL_START = ''`
+// https://www.w3.org/TR/xml-names/#NT-elementdecl
+// `[17] elementdecl ::= ''`
+// because of https://www.w3.org/TR/xml11/#NT-PEReference
+// since xmldom is not supporting replacements of PEReferences in the DTD
+// this also supports PEReference in the possible places
+var elementdecl = reg(ELEMENTDECL_START, S, regg(QName, '|', PEReference), S, regg(contentspec, '|', PEReference), S_OPT, '>');
+
+// https://www.w3.org/TR/xml11/#NT-NotationType
+// `[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'`
+// [VC: Notation Attributes] [VC: One Notation Per Element Type] [VC: No Notation on Empty Element] [VC: No Duplicate Tokens]
+var NotationType = reg('NOTATION', S, /\(/, S_OPT, Name, regg(S_OPT, /\|/, S_OPT, Name), '*', S_OPT, /\)/);
+// https://www.w3.org/TR/xml11/#NT-Enumeration
+// `[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'`
+// [VC: Enumeration] [VC: No Duplicate Tokens]
+var Enumeration = reg(/\(/, S_OPT, Nmtoken, regg(S_OPT, /\|/, S_OPT, Nmtoken), '*', S_OPT, /\)/);
+
+// https://www.w3.org/TR/xml11/#NT-EnumeratedType
+// `[57] EnumeratedType ::= NotationType | Enumeration`
+var EnumeratedType = regg(NotationType, '|', Enumeration);
+
+/*
+```
+[55] StringType ::= 'CDATA'
+[56] TokenizedType ::= 'ID' [VC: ID] [VC: One ID per Element Type] [VC: ID Attribute Default]
+ | 'IDREF' [VC: IDREF]
+ | 'IDREFS' [VC: IDREF]
+ | 'ENTITY' [VC: Entity Name]
+ | 'ENTITIES' [VC: Entity Name]
+ | 'NMTOKEN' [VC: Name Token]
+ | 'NMTOKENS' [VC: Name Token]
+ [54] AttType ::= StringType | TokenizedType | EnumeratedType
+```*/
+var AttType = regg(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/, '|', EnumeratedType);
+
+// `[60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)`
+// [WFC: No < in Attribute Values] [WFC: No External Entity References]
+// [VC: Fixed Attribute Default] [VC: Required Attribute] [VC: Attribute Default Value Syntactically Correct]
+var DefaultDecl = regg(/#REQUIRED|#IMPLIED/, '|', regg(regg('#FIXED', S), '?', AttValue));
+
+// https://www.w3.org/TR/xml11/#NT-AttDef
+// [53] AttDef ::= S Name S AttType S DefaultDecl
+// https://www.w3.org/TR/xml-names/#NT-AttDef
+// [1] NSAttName ::= PrefixedAttName | DefaultAttName
+// [2] PrefixedAttName ::= 'xmlns:' NCName [NSC: Reserved Prefixes and Namespace Names]
+// [3] DefaultAttName ::= 'xmlns'
+// [21] AttDef ::= S (QName | NSAttName) S AttType S DefaultDecl
+// === S Name S AttType S DefaultDecl
+// xmldom is not distinguishing between QName and NSAttName on this level
+// to support XML without namespaces in DTD we can not restrict it to QName
+var AttDef = regg(S, Name, S, AttType, S, DefaultDecl);
+
+var ATTLIST_DECL_START = ''`
+// https://www.w3.org/TR/xml-names/#NT-AttlistDecl
+// `[20] AttlistDecl ::= ''`
+// to support XML without namespaces in DTD we can not restrict it to QName
+var AttlistDecl = reg(ATTLIST_DECL_START, S, Name, AttDef, '*', S_OPT, '>');
+
+// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#about:legacy-compat
+var ABOUT_LEGACY_COMPAT = 'about:legacy-compat';
+var ABOUT_LEGACY_COMPAT_SystemLiteral = regg('"' + ABOUT_LEGACY_COMPAT + '"', '|', "'" + ABOUT_LEGACY_COMPAT + "'");
+var SYSTEM = 'SYSTEM';
+var PUBLIC = 'PUBLIC';
+// https://www.w3.org/TR/xml11/#NT-ExternalID
+// `[75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral`
+var ExternalID = regg(regg(SYSTEM, S, SystemLiteral), '|', regg(PUBLIC, S, PubidLiteral, S, SystemLiteral));
+var ExternalID_match = reg(
+ '^',
+ regg(
+ regg(SYSTEM, S, '(?', SystemLiteral, ')'),
+ '|',
+ regg(PUBLIC, S, '(?', PubidLiteral, ')', S, '(?', SystemLiteral, ')')
+ )
+);
+// Full-string anchored matcher for requireWellFormed serializer checks
+// https://w3c.github.io/DOM-Parsing/#xml-serializing-a-document-node
+var PubidLiteral_match = reg('^', PubidLiteral, '$');
+// Full-string anchored matcher for requireWellFormed serializer checks
+// https://w3c.github.io/DOM-Parsing/#xml-serializing-a-document-node
+var SystemLiteral_match = reg('^', SystemLiteral, '$');
+
+// https://www.w3.org/TR/xml11/#NT-NDataDecl
+// `[76] NDataDecl ::= S 'NDATA' S Name` [VC: Notation Declared]
+var NDataDecl = regg(S, 'NDATA', S, Name);
+
+// https://www.w3.org/TR/xml11/#NT-EntityDef
+// `[73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)`
+var EntityDef = regg(EntityValue, '|', regg(ExternalID, NDataDecl, '?'));
+
+var ENTITY_DECL_START = ''`
+var GEDecl = reg(ENTITY_DECL_START, S, Name, S, EntityDef, S_OPT, '>');
+// https://www.w3.org/TR/xml11/#NT-PEDef
+// `[74] PEDef ::= EntityValue | ExternalID`
+var PEDef = regg(EntityValue, '|', ExternalID);
+// https://www.w3.org/TR/xml11/#NT-PEDecl
+// `[72] PEDecl ::= ''`
+var PEDecl = reg(ENTITY_DECL_START, S, '%', S, Name, S, PEDef, S_OPT, '>');
+// https://www.w3.org/TR/xml11/#NT-EntityDecl
+// `[70] EntityDecl ::= GEDecl | PEDecl`
+var EntityDecl = regg(GEDecl, '|', PEDecl);
+
+// https://www.w3.org/TR/xml11/#NT-PublicID
+// `[83] PublicID ::= 'PUBLIC' S PubidLiteral`
+var PublicID = reg(PUBLIC, S, PubidLiteral);
+// https://www.w3.org/TR/xml11/#NT-NotationDecl
+// `[82] NotationDecl ::= ''` [VC: Unique Notation Name]
+var NotationDecl = reg('');
+
+// https://www.w3.org/TR/xml11/#NT-Eq
+// `[25] Eq ::= S? '=' S?`
+var Eq = reg(S_OPT, '=', S_OPT);
+// https://www.w3.org/TR/xml/#NT-VersionNum
+// `[26] VersionNum ::= '1.' [0-9]+`
+// https://www.w3.org/TR/xml11/#NT-VersionNum
+// `[26] VersionNum ::= '1.1'`
+var VersionNum = /1[.]\d+/;
+// https://www.w3.org/TR/xml11/#NT-VersionInfo
+// `[24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')`
+var VersionInfo = reg(S, 'version', Eq, regg("'", VersionNum, "'", '|', '"', VersionNum, '"'));
+// https://www.w3.org/TR/xml11/#NT-EncName
+// `[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*`
+var EncName = /[A-Za-z][-A-Za-z0-9._]*/;
+// https://www.w3.org/TR/xml11/#NT-EncDecl
+// `[80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'" )`
+var EncodingDecl = regg(S, 'encoding', Eq, regg('"', EncName, '"', '|', "'", EncName, "'"));
+// https://www.w3.org/TR/xml11/#NT-SDDecl
+// `[32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))`
+var SDDecl = regg(S, 'standalone', Eq, regg("'", regg('yes', '|', 'no'), "'", '|', '"', regg('yes', '|', 'no'), '"'));
+// https://www.w3.org/TR/xml11/#NT-XMLDecl
+// [23] XMLDecl ::= ''
+var XMLDecl = reg(/^<\?xml/, VersionInfo, EncodingDecl, '?', SDDecl, '?', S_OPT, /\?>/);
+
+/*
+ https://www.w3.org/TR/xml/#NT-markupdecl
+ https://www.w3.org/TR/xml11/#NT-markupdecl
+ `[29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment`
+ var markupdecl = regg(elementdecl, '|', AttlistDecl, '|', EntityDecl, '|', NotationDecl, '|', PI_unsafe, '|', Comment);
+*/
+/*
+ https://www.w3.org/TR/xml-names/#NT-doctypedecl
+`[28a] DeclSep ::= PEReference | S`
+ https://www.w3.org/TR/xml11/#NT-intSubset
+```
+ [28b] intSubset ::= (markupdecl | DeclSep)*
+ === (markupdecl | PEReference | S)*
+```
+ [WFC: PE Between Declarations]
+ var intSubset = reg(regg(markupdecl, '|', PEReference, '|', S), '*');
+*/
+var DOCTYPE_DECL_START = ''`
+ https://www.afterwardsw3.org/TR/xml-names/#NT-doctypedecl
+ `[16] doctypedecl ::= ''`
+ var doctypedecl = reg('');
+*/
+
+var CDATA_START = '';
+var CDStart = //;
+var CData = reg(Char, '*?', CDEnd);
+/*
+ https://www.w3.org/TR/xml/#dt-cdsection
+ `[18] CDSect ::= CDStart CData CDEnd`
+ `[19] CDStart ::= '' Char*))`
+ `[21] CDEnd ::= ']]>'`
+*/
+var CDSect = reg(CDStart, CData);
+
+// unit tested
+exports.chars = chars;
+exports.chars_without = chars_without;
+exports.detectUnicodeSupport = detectUnicodeSupport;
+exports.reg = reg;
+exports.regg = regg;
+exports.ABOUT_LEGACY_COMPAT = ABOUT_LEGACY_COMPAT;
+exports.ABOUT_LEGACY_COMPAT_SystemLiteral = ABOUT_LEGACY_COMPAT_SystemLiteral;
+exports.AttlistDecl = AttlistDecl;
+exports.CDATA_START = CDATA_START;
+exports.CDATA_END = CDATA_END;
+exports.CDSect = CDSect;
+exports.Char = Char;
+exports.Comment = Comment;
+exports.COMMENT_START = COMMENT_START;
+exports.COMMENT_END = COMMENT_END;
+exports.DOCTYPE_DECL_START = DOCTYPE_DECL_START;
+exports.elementdecl = elementdecl;
+exports.EntityDecl = EntityDecl;
+exports.EntityValue = EntityValue;
+exports.ExternalID = ExternalID;
+exports.ExternalID_match = ExternalID_match;
+exports.Name = Name;
+exports.NotationDecl = NotationDecl;
+exports.Reference = Reference;
+exports.PEReference = PEReference;
+exports.PI = PI;
+exports.PUBLIC = PUBLIC;
+exports.PubidLiteral = PubidLiteral;
+exports.PubidLiteral_match = PubidLiteral_match;
+exports.QName = QName;
+exports.QName_exact = QName_exact;
+exports.QName_group = QName_group;
+exports.S = S;
+exports.SChar_s = SChar_s;
+exports.S_OPT = S_OPT;
+exports.SYSTEM = SYSTEM;
+exports.SystemLiteral = SystemLiteral;
+exports.SystemLiteral_match = SystemLiteral_match;
+exports.InvalidChar = InvalidChar;
+exports.UNICODE_REPLACEMENT_CHARACTER = UNICODE_REPLACEMENT_CHARACTER;
+exports.UNICODE_SUPPORT = UNICODE_SUPPORT;
+exports.XMLDecl = XMLDecl;
+
+},{}],8:[function(require,module,exports){
+'use strict';
+var conventions = require('./conventions');
+exports.assign = conventions.assign;
+exports.hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;
+exports.isHTMLMimeType = conventions.isHTMLMimeType;
+exports.isValidMimeType = conventions.isValidMimeType;
+exports.MIME_TYPE = conventions.MIME_TYPE;
+exports.NAMESPACE = conventions.NAMESPACE;
+
+var errors = require('./errors');
+exports.DOMException = errors.DOMException;
+exports.DOMExceptionName = errors.DOMExceptionName;
+exports.ExceptionCode = errors.ExceptionCode;
+exports.ParseError = errors.ParseError;
+
+var dom = require('./dom');
+exports.Attr = dom.Attr;
+exports.CDATASection = dom.CDATASection;
+exports.CharacterData = dom.CharacterData;
+exports.Comment = dom.Comment;
+exports.Document = dom.Document;
+exports.DocumentFragment = dom.DocumentFragment;
+exports.DocumentType = dom.DocumentType;
+exports.DOMImplementation = dom.DOMImplementation;
+exports.Element = dom.Element;
+exports.Entity = dom.Entity;
+exports.EntityReference = dom.EntityReference;
+exports.LiveNodeList = dom.LiveNodeList;
+exports.NamedNodeMap = dom.NamedNodeMap;
+exports.Node = dom.Node;
+exports.NodeList = dom.NodeList;
+exports.Notation = dom.Notation;
+exports.ProcessingInstruction = dom.ProcessingInstruction;
+exports.Text = dom.Text;
+exports.XMLSerializer = dom.XMLSerializer;
+
+var domParser = require('./dom-parser');
+exports.DOMParser = domParser.DOMParser;
+exports.normalizeLineEndings = domParser.normalizeLineEndings;
+exports.onErrorStopParsing = domParser.onErrorStopParsing;
+exports.onWarningStopParsing = domParser.onWarningStopParsing;
+
+},{"./conventions":2,"./dom":4,"./dom-parser":3,"./errors":6}],9:[function(require,module,exports){
+'use strict';
+
+var conventions = require('./conventions');
+var g = require('./grammar');
+var errors = require('./errors');
+
+var isHTMLEscapableRawTextElement = conventions.isHTMLEscapableRawTextElement;
+var isHTMLMimeType = conventions.isHTMLMimeType;
+var isHTMLRawTextElement = conventions.isHTMLRawTextElement;
+var hasOwn = conventions.hasOwn;
+var NAMESPACE = conventions.NAMESPACE;
+var ParseError = errors.ParseError;
+var DOMException = errors.DOMException;
+
+//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
+
+//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
+//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
+var S_TAG = 0; //tag name offerring
+var S_ATTR = 1; //attr name offerring
+var S_ATTR_SPACE = 2; //attr name end and space offer
+var S_EQ = 3; //=space?
+var S_ATTR_NOQUOT_VALUE = 4; //attr value(no quot value only)
+var S_ATTR_END = 5; //attr value end and no space(quot end)
+var S_TAG_SPACE = 6; //(attr value end || tag end ) && (space offer)
+var S_TAG_CLOSE = 7; //closed el
+
+function XMLReader() {}
+
+XMLReader.prototype = {
+ parse: function (source, defaultNSMap, entityMap) {
+ var domBuilder = this.domBuilder;
+ domBuilder.startDocument();
+ _copy(defaultNSMap, (defaultNSMap = Object.create(null)));
+ parse(source, defaultNSMap, entityMap, domBuilder, this.errorHandler);
+ domBuilder.endDocument();
+ },
+};
+
+/**
+ * Detecting everything that might be a reference,
+ * including those without ending `;`, since those are allowed in HTML.
+ * The entityReplacer takes care of verifying and transforming each occurrence,
+ * and reports to the errorHandler on those that are not OK,
+ * depending on the context.
+ */
+var ENTITY_REG = /?\w+;?/g;
+
+function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
+ var isHTML = isHTMLMimeType(domBuilder.mimeType);
+ if (source.indexOf(g.UNICODE_REPLACEMENT_CHARACTER) >= 0) {
+ errorHandler.warning('Unicode replacement character detected, source encoding issues?');
+ }
+
+ function fixedFromCharCode(code) {
+ // String.prototype.fromCharCode does not supports
+ // > 2 bytes unicode chars directly
+ if (code > 0xffff) {
+ code -= 0x10000;
+ var surrogate1 = 0xd800 + (code >> 10),
+ surrogate2 = 0xdc00 + (code & 0x3ff);
+
+ return String.fromCharCode(surrogate1, surrogate2);
+ } else {
+ return String.fromCharCode(code);
+ }
+ }
+
+ function entityReplacer(a) {
+ var complete = a[a.length - 1] === ';' ? a : a + ';';
+ if (!isHTML && complete !== a) {
+ errorHandler.error('EntityRef: expecting ;');
+ return a;
+ }
+ var match = g.Reference.exec(complete);
+ if (!match || match[0].length !== complete.length) {
+ errorHandler.error('entity not matching Reference production: ' + a);
+ return a;
+ }
+ var k = complete.slice(1, -1);
+ if (hasOwn(entityMap, k)) {
+ return entityMap[k];
+ } else if (k.charAt(0) === '#') {
+ return fixedFromCharCode(parseInt(k.substring(1).replace('x', '0x')));
+ } else {
+ errorHandler.error('entity not found:' + a);
+ return a;
+ }
+ }
+
+ function appendText(end) {
+ //has some bugs
+ if (end > start) {
+ var xt = source.substring(start, end).replace(ENTITY_REG, entityReplacer);
+ locator && position(start);
+ domBuilder.characters(xt, 0, end - start);
+ start = end;
+ }
+ }
+
+ var lineStart = 0;
+ var lineEnd = 0;
+ var linePattern = /\r\n?|\n|$/g;
+ var locator = domBuilder.locator;
+
+ function position(p, m) {
+ while (p >= lineEnd && (m = linePattern.exec(source))) {
+ lineStart = lineEnd;
+ lineEnd = m.index + m[0].length;
+ locator.lineNumber++;
+ }
+ locator.columnNumber = p - lineStart + 1;
+ }
+
+ var parseStack = [{ currentNSMap: defaultNSMapCopy }];
+ var unclosedTags = [];
+ var start = 0;
+ while (true) {
+ try {
+ var tagStart = source.indexOf('<', start);
+ if (tagStart < 0) {
+ if (!isHTML && unclosedTags.length > 0) {
+ return errorHandler.fatalError('unclosed xml tag(s): ' + unclosedTags.join(', '));
+ }
+ if (!source.substring(start).match(/^\s*$/)) {
+ var doc = domBuilder.doc;
+ var text = doc.createTextNode(source.substring(start));
+ if (doc.documentElement) {
+ return errorHandler.error('Extra content at the end of the document');
+ }
+ doc.appendChild(text);
+ domBuilder.currentElement = text;
+ }
+ return;
+ }
+ if (tagStart > start) {
+ var fromSource = source.substring(start, tagStart);
+ if (!isHTML && unclosedTags.length === 0) {
+ fromSource = fromSource.replace(new RegExp(g.S_OPT.source, 'g'), '');
+ fromSource && errorHandler.error("Unexpected content outside root element: '" + fromSource + "'");
+ }
+ appendText(tagStart);
+ }
+ switch (source.charAt(tagStart + 1)) {
+ case '/':
+ var end = source.indexOf('>', tagStart + 2);
+ var tagNameRaw = source.substring(tagStart + 2, end > 0 ? end : undefined);
+ if (!tagNameRaw) {
+ return errorHandler.fatalError('end tag name missing');
+ }
+ var tagNameMatch = end > 0 && g.reg('^', g.QName_group, g.S_OPT, '$').exec(tagNameRaw);
+ if (!tagNameMatch) {
+ return errorHandler.fatalError('end tag name contains invalid characters: "' + tagNameRaw + '"');
+ }
+ if (!domBuilder.currentElement && !domBuilder.doc.documentElement) {
+ // not enough information to provide a helpful error message,
+ // but parsing will throw since there is no root element
+ return;
+ }
+ var currentTagName =
+ unclosedTags[unclosedTags.length - 1] ||
+ domBuilder.currentElement.tagName ||
+ domBuilder.doc.documentElement.tagName ||
+ '';
+ if (currentTagName !== tagNameMatch[1]) {
+ var tagNameLower = tagNameMatch[1].toLowerCase();
+ if (!isHTML || currentTagName.toLowerCase() !== tagNameLower) {
+ return errorHandler.fatalError('Opening and ending tag mismatch: "' + currentTagName + '" != "' + tagNameRaw + '"');
+ }
+ }
+ var config = parseStack.pop();
+ unclosedTags.pop();
+ var localNSMap = config.localNSMap;
+ domBuilder.endElement(config.uri, config.localName, currentTagName);
+ if (localNSMap) {
+ for (var prefix in localNSMap) {
+ if (hasOwn(localNSMap, prefix)) {
+ domBuilder.endPrefixMapping(prefix);
+ }
+ }
+ }
+
+ end++;
+ break;
+ // end element
+ case '?': // ...?>
+ locator && position(tagStart);
+ end = parseProcessingInstruction(source, tagStart, domBuilder, errorHandler);
+ break;
+ case '!': // start) {
+ start = end;
+ } else {
+ //Possible sax fallback here, risk of positional error
+ appendText(Math.max(tagStart, start) + 1);
+ }
+ }
+}
+
+function copyLocator(f, t) {
+ t.lineNumber = f.lineNumber;
+ t.columnNumber = f.columnNumber;
+ return t;
+}
+
+/**
+ * @returns
+ * end of the elementStartPart(end of elementEndPart for selfClosed el)
+ * @see {@link #appendElement}
+ */
+function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler, isHTML) {
+ /**
+ * @param {string} qname
+ * @param {string} value
+ * @param {number} startIndex
+ */
+ function addAttribute(qname, value, startIndex) {
+ if (hasOwn(el.attributeNames, qname)) {
+ return errorHandler.fatalError('Attribute ' + qname + ' redefined');
+ }
+ if (!isHTML && value.indexOf('<') >= 0) {
+ return errorHandler.fatalError("Unescaped '<' not allowed in attributes values");
+ }
+ el.addValue(
+ qname,
+ // @see https://www.w3.org/TR/xml/#AVNormalize
+ // since the xmldom sax parser does not "interpret" DTD the following is not implemented:
+ // - recursive replacement of (DTD) entity references
+ // - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA
+ value.replace(/[\t\n\r]/g, ' ').replace(ENTITY_REG, entityReplacer),
+ startIndex
+ );
+ }
+
+ var attrName;
+ var value;
+ var p = ++start;
+ var s = S_TAG; //status
+ while (true) {
+ var c = source.charAt(p);
+ switch (c) {
+ case '=':
+ if (s === S_ATTR) {
+ //attrName
+ attrName = source.slice(start, p);
+ s = S_EQ;
+ } else if (s === S_ATTR_SPACE) {
+ s = S_EQ;
+ } else {
+ //fatalError: equal must after attrName or space after attrName
+ throw new Error('attribute equal must after attrName'); // No known test case
+ }
+ break;
+ case "'":
+ case '"':
+ if (
+ s === S_EQ ||
+ s === S_ATTR //|| s == S_ATTR_SPACE
+ ) {
+ //equal
+ if (s === S_ATTR) {
+ errorHandler.warning('attribute value must after "="');
+ attrName = source.slice(start, p);
+ }
+ start = p + 1;
+ p = source.indexOf(c, start);
+ if (p > 0) {
+ value = source.slice(start, p);
+ addAttribute(attrName, value, start - 1);
+ s = S_ATTR_END;
+ } else {
+ //fatalError: no end quot match
+ throw new Error("attribute value no end '" + c + "' match");
+ }
+ } else if (s == S_ATTR_NOQUOT_VALUE) {
+ value = source.slice(start, p);
+ addAttribute(attrName, value, start);
+ errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ')!!');
+ start = p + 1;
+ s = S_ATTR_END;
+ } else {
+ //fatalError: no equal before
+ throw new Error('attribute value must after "="'); // No known test case
+ }
+ break;
+ case '/':
+ switch (s) {
+ case S_TAG:
+ el.setTagName(source.slice(start, p));
+ case S_ATTR_END:
+ case S_TAG_SPACE:
+ case S_TAG_CLOSE:
+ s = S_TAG_CLOSE;
+ el.closed = true;
+ case S_ATTR_NOQUOT_VALUE:
+ case S_ATTR:
+ break;
+ case S_ATTR_SPACE:
+ el.closed = true;
+ break;
+ //case S_EQ:
+ default:
+ throw new Error("attribute invalid close char('/')"); // No known test case
+ }
+ break;
+ case '': //end document
+ errorHandler.error('unexpected end of input');
+ if (s == S_TAG) {
+ el.setTagName(source.slice(start, p));
+ }
+ return p;
+ case '>':
+ switch (s) {
+ case S_TAG:
+ el.setTagName(source.slice(start, p));
+ case S_ATTR_END:
+ case S_TAG_SPACE:
+ case S_TAG_CLOSE:
+ break; //normal
+ case S_ATTR_NOQUOT_VALUE: //Compatible state
+ case S_ATTR:
+ value = source.slice(start, p);
+ if (value.slice(-1) === '/') {
+ el.closed = true;
+ value = value.slice(0, -1);
+ }
+ case S_ATTR_SPACE:
+ if (s === S_ATTR_SPACE) {
+ value = attrName;
+ }
+ if (s == S_ATTR_NOQUOT_VALUE) {
+ errorHandler.warning('attribute "' + value + '" missed quot(")!');
+ addAttribute(attrName, value, start);
+ } else {
+ if (!isHTML) {
+ errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!');
+ }
+ addAttribute(value, value, start);
+ }
+ break;
+ case S_EQ:
+ if (!isHTML) {
+ return errorHandler.fatalError('AttValue: \' or " expected');
+ }
+ }
+ return p;
+ /*xml space '\x20' | #x9 | #xD | #xA; */
+ case '\u0080':
+ c = ' ';
+ default:
+ if (c <= ' ') {
+ //space
+ switch (s) {
+ case S_TAG:
+ el.setTagName(source.slice(start, p)); //tagName
+ s = S_TAG_SPACE;
+ break;
+ case S_ATTR:
+ attrName = source.slice(start, p);
+ s = S_ATTR_SPACE;
+ break;
+ case S_ATTR_NOQUOT_VALUE:
+ var value = source.slice(start, p);
+ errorHandler.warning('attribute "' + value + '" missed quot(")!!');
+ addAttribute(attrName, value, start);
+ case S_ATTR_END:
+ s = S_TAG_SPACE;
+ break;
+ //case S_TAG_SPACE:
+ //case S_EQ:
+ //case S_ATTR_SPACE:
+ // void();break;
+ //case S_TAG_CLOSE:
+ //ignore warning
+ }
+ } else {
+ //not space
+ //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
+ //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
+ switch (s) {
+ //case S_TAG:void();break;
+ //case S_ATTR:void();break;
+ //case S_ATTR_NOQUOT_VALUE:void();break;
+ case S_ATTR_SPACE:
+ if (!isHTML) {
+ errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!');
+ }
+ addAttribute(attrName, attrName, start);
+ start = p;
+ s = S_ATTR;
+ break;
+ case S_ATTR_END:
+ errorHandler.warning('attribute space is required"' + attrName + '"!!');
+ case S_TAG_SPACE:
+ s = S_ATTR;
+ start = p;
+ break;
+ case S_EQ:
+ s = S_ATTR_NOQUOT_VALUE;
+ start = p;
+ break;
+ case S_TAG_CLOSE:
+ throw new Error("elements closed character '/' and '>' must be connected to");
+ }
+ }
+ } //end outer switch
+ p++;
+ }
+}
+
+/**
+ * @returns
+ * `true` if a new namespace has been defined.
+ */
+function appendElement(el, domBuilder, currentNSMap) {
+ var tagName = el.tagName;
+ var localNSMap = null;
+ var i = el.length;
+ while (i--) {
+ var a = el[i];
+ var qName = a.qName;
+ var value = a.value;
+ var nsp = qName.indexOf(':');
+ if (nsp > 0) {
+ var prefix = (a.prefix = qName.slice(0, nsp));
+ var localName = qName.slice(nsp + 1);
+ var nsPrefix = prefix === 'xmlns' && localName;
+ } else {
+ localName = qName;
+ prefix = null;
+ nsPrefix = qName === 'xmlns' && '';
+ }
+ //can not set prefix,because prefix !== ''
+ a.localName = localName;
+ //prefix == null for no ns prefix attribute
+ if (nsPrefix !== false) {
+ //hack!!
+ if (localNSMap == null) {
+ localNSMap = Object.create(null);
+ _copy(currentNSMap, (currentNSMap = Object.create(null)));
+ }
+ currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
+ a.uri = NAMESPACE.XMLNS;
+ domBuilder.startPrefixMapping(nsPrefix, value);
+ }
+ }
+ var i = el.length;
+ while (i--) {
+ a = el[i];
+ if (a.prefix) {
+ //no prefix attribute has no namespace
+ if (a.prefix === 'xml') {
+ a.uri = NAMESPACE.XML;
+ }
+ if (a.prefix !== 'xmlns') {
+ a.uri = currentNSMap[a.prefix];
+ }
+ }
+ }
+ var nsp = tagName.indexOf(':');
+ if (nsp > 0) {
+ prefix = el.prefix = tagName.slice(0, nsp);
+ localName = el.localName = tagName.slice(nsp + 1);
+ } else {
+ prefix = null; //important!!
+ localName = el.localName = tagName;
+ }
+ //no prefix element has default namespace
+ var ns = (el.uri = currentNSMap[prefix || '']);
+ domBuilder.startElement(ns, localName, tagName, el);
+ //endPrefixMapping and startPrefixMapping have not any help for dom builder
+ //localNSMap = null
+ if (el.closed) {
+ domBuilder.endElement(ns, localName, tagName);
+ if (localNSMap) {
+ for (prefix in localNSMap) {
+ if (hasOwn(localNSMap, prefix)) {
+ domBuilder.endPrefixMapping(prefix);
+ }
+ }
+ }
+ } else {
+ el.currentNSMap = currentNSMap;
+ el.localNSMap = localNSMap;
+ //parseStack.push(el);
+ return true;
+ }
+}
+
+function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
+ // https://html.spec.whatwg.org/#raw-text-elements
+ // https://html.spec.whatwg.org/#escapable-raw-text-elements
+ // https://html.spec.whatwg.org/#cdata-rcdata-restrictions:raw-text-elements
+ // TODO: https://html.spec.whatwg.org/#cdata-rcdata-restrictions
+ var isEscapableRaw = isHTMLEscapableRawTextElement(tagName);
+ if (isEscapableRaw || isHTMLRawTextElement(tagName)) {
+ var elEndStart = source.indexOf('' + tagName + '>', elStartEnd);
+ var text = source.substring(elStartEnd + 1, elEndStart);
+
+ if (isEscapableRaw) {
+ text = text.replace(ENTITY_REG, entityReplacer);
+ }
+ domBuilder.characters(text, 0, text.length);
+ return elEndStart;
+ }
+ return elStartEnd + 1;
+}
+
+function _copy(source, target) {
+ for (var n in source) {
+ if (hasOwn(source, n)) {
+ target[n] = source[n];
+ }
+ }
+}
+
+/**
+ * @typedef ParseUtils
+ * @property {function(relativeIndex: number?): string | undefined} char
+ * Provides look ahead access to a singe character relative to the current index.
+ * @property {function(): number} getIndex
+ * Provides read-only access to the current index.
+ * @property {function(reg: RegExp): string | null} getMatch
+ * Applies the provided regular expression enforcing that it starts at the current index and
+ * returns the complete matching string,
+ * and moves the current index by the length of the matching string.
+ * @property {function(): string} getSource
+ * Provides read-only access to the complete source.
+ * @property {function(places: number?): void} skip
+ * moves the current index by places (defaults to 1)
+ * @property {function(): number} skipBlanks
+ * Moves the current index by the amount of white space that directly follows the current index
+ * and returns the amount of whitespace chars skipped (0..n),
+ * or -1 if the end of the source was reached.
+ * @property {function(): string} substringFromIndex
+ * creates a substring from the current index to the end of `source`
+ * @property {function(compareWith: string): boolean} substringStartsWith
+ * Checks if `source` contains `compareWith`, starting from the current index.
+ * @property {function(compareWith: string): boolean} substringStartsWithCaseInsensitive
+ * Checks if `source` contains `compareWith`, starting from the current index,
+ * comparing the upper case of both sides.
+ * @see {@link parseUtils}
+ */
+
+/**
+ * A temporary scope for parsing and look ahead operations in `source`,
+ * starting from index `start`.
+ *
+ * Some operations move the current index by a number of positions,
+ * after which `getIndex` returns the new index.
+ *
+ * @param {string} source
+ * @param {number} start
+ * @returns {ParseUtils}
+ */
+function parseUtils(source, start) {
+ var index = start;
+
+ function char(n) {
+ n = n || 0;
+ return source.charAt(index + n);
+ }
+
+ function skip(n) {
+ n = n || 1;
+ index += n;
+ }
+
+ function skipBlanks() {
+ var blanks = 0;
+ while (index < source.length) {
+ var c = char();
+ if (c !== ' ' && c !== '\n' && c !== '\t' && c !== '\r') {
+ return blanks;
+ }
+ blanks++;
+ skip();
+ }
+ return -1;
+ }
+ function substringFromIndex() {
+ return source.substring(index);
+ }
+ function substringStartsWith(text) {
+ return source.substring(index, index + text.length) === text;
+ }
+ function substringStartsWithCaseInsensitive(text) {
+ return source.substring(index, index + text.length).toUpperCase() === text.toUpperCase();
+ }
+
+ function getMatch(args) {
+ var expr = g.reg('^', args);
+ var match = expr.exec(substringFromIndex());
+ if (match) {
+ skip(match[0].length);
+ return match[0];
+ }
+ return null;
+ }
+ return {
+ char: char,
+ getIndex: function () {
+ return index;
+ },
+ getMatch: getMatch,
+ getSource: function () {
+ return source;
+ },
+ skip: skip,
+ skipBlanks: skipBlanks,
+ substringFromIndex: substringFromIndex,
+ substringStartsWith: substringStartsWith,
+ substringStartsWithCaseInsensitive: substringStartsWithCaseInsensitive,
+ };
+}
+
+/**
+ * @param {ParseUtils} p
+ * @param {DOMHandler} errorHandler
+ * @returns {string}
+ */
+function parseDoctypeInternalSubset(p, errorHandler) {
+ /**
+ * @param {ParseUtils} p
+ * @param {DOMHandler} errorHandler
+ * @returns {string}
+ */
+ function parsePI(p, errorHandler) {
+ var match = g.PI.exec(p.substringFromIndex());
+ if (!match) {
+ return errorHandler.fatalError('processing instruction is not well-formed at position ' + p.getIndex());
+ }
+ if (match[1].toLowerCase() === 'xml') {
+ return errorHandler.fatalError(
+ 'xml declaration is only allowed at the start of the document, but found at position ' + p.getIndex()
+ );
+ }
+ p.skip(match[0].length);
+ return match[0];
+ }
+ // Parse internal subset
+ var source = p.getSource();
+ if (p.char() === '[') {
+ p.skip(1);
+ var intSubsetStart = p.getIndex();
+ while (p.getIndex() < source.length) {
+ p.skipBlanks();
+ if (p.char() === ']') {
+ var internalSubset = source.substring(intSubsetStart, p.getIndex());
+ p.skip(1);
+ return internalSubset;
+ }
+ var current = null;
+ // Only in external subset
+ // if (char() === '<' && char(1) === '!' && char(2) === '[') {
+ // parseConditionalSections(p, errorHandler);
+ // } else
+ if (p.char() === '<' && p.char(1) === '!') {
+ switch (p.char(2)) {
+ case 'E': // ELEMENT | ENTITY
+ if (p.char(3) === 'L') {
+ current = p.getMatch(g.elementdecl);
+ } else if (p.char(3) === 'N') {
+ current = p.getMatch(g.EntityDecl);
+ }
+ break;
+ case 'A': // ATTRIBUTE
+ current = p.getMatch(g.AttlistDecl);
+ break;
+ case 'N': // NOTATION
+ current = p.getMatch(g.NotationDecl);
+ break;
+ case '-': // COMMENT
+ current = p.getMatch(g.Comment);
+ break;
+ }
+ } else if (p.char() === '<' && p.char(1) === '?') {
+ current = parsePI(p, errorHandler);
+ } else if (p.char() === '%') {
+ current = p.getMatch(g.PEReference);
+ } else {
+ return errorHandler.fatalError('Error detected in Markup declaration');
+ }
+ if (!current) {
+ return errorHandler.fatalError('Error in internal subset at position ' + p.getIndex());
+ }
+ }
+ return errorHandler.fatalError('doctype internal subset is not well-formed, missing ]');
+ }
+}
+
+/**
+ * Called when the parser encounters an element starting with '') {
+ return errorHandler.fatalError('doctype not terminated with > at position ' + p.getIndex());
+ }
+ p.skip(1);
+ domBuilder.startDTD(doctype.name, doctype.publicId, doctype.systemId, doctype.internalSubset);
+ domBuilder.endDTD();
+ return p.getIndex();
+ }
+ default:
+ return errorHandler.fatalError('Not well-formed XML starting with " 0) {
+ return errorHandler.fatalError(
+ 'processing instruction at position ' + start + ' is an xml declaration which is only at the start of the document'
+ );
+ }
+ if (!g.XMLDecl.test(source.substring(start))) {
+ return errorHandler.fatalError('xml declaration is not well-formed');
+ }
+ }
+ domBuilder.processingInstruction(match[1], match[2]);
+ return start + match[0].length;
+}
+
+function ElementAttributes() {
+ this.attributeNames = Object.create(null);
+}
+
+ElementAttributes.prototype = {
+ setTagName: function (tagName) {
+ if (!g.QName_exact.test(tagName)) {
+ throw new Error('invalid tagName:' + tagName);
+ }
+ this.tagName = tagName;
+ },
+ addValue: function (qName, value, offset) {
+ if (!g.QName_exact.test(qName)) {
+ throw new Error('invalid attribute:' + qName);
+ }
+ this.attributeNames[qName] = this.length;
+ this[this.length++] = { qName: qName, value: value, offset: offset };
+ },
+ length: 0,
+ getLocalName: function (i) {
+ return this[i].localName;
+ },
+ getLocator: function (i) {
+ return this[i].locator;
+ },
+ getQName: function (i) {
+ return this[i].qName;
+ },
+ getURI: function (i) {
+ return this[i].uri;
+ },
+ getValue: function (i) {
+ return this[i].value;
+ },
+ // ,getIndex:function(uri, localName)){
+ // if(localName){
+ //
+ // }else{
+ // var qName = uri
+ // }
+ // },
+ // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
+ // getType:function(uri,localName){}
+ // getType:function(i){},
+};
+
+exports.XMLReader = XMLReader;
+exports.parseUtils = parseUtils;
+exports.parseDoctypeCommentOrCData = parseDoctypeCommentOrCData;
+
+},{"./conventions":2,"./errors":6,"./grammar":7}],10:[function(require,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
+}
+
+// Support decoding URL-safe base64 strings, as Node.js does.
+// See: https://en.wikipedia.org/wiki/Base64#URL_applications
+revLookup['-'.charCodeAt(0)] = 62
+revLookup['_'.charCodeAt(0)] = 63
+
+function getLens (b64) {
+ var len = b64.length
+
+ if (len % 4 > 0) {
+ throw new Error('Invalid string. Length must be a multiple of 4')
+ }
+
+ // Trim off extra bytes after placeholder bytes are found
+ // See: https://github.com/beatgammit/base64-js/issues/42
+ var validLen = b64.indexOf('=')
+ if (validLen === -1) validLen = len
+
+ var placeHoldersLen = validLen === len
+ ? 0
+ : 4 - (validLen % 4)
+
+ return [validLen, placeHoldersLen]
+}
+
+// base64 is 4/3 + up to two characters of the original data
+function byteLength (b64) {
+ var lens = getLens(b64)
+ var validLen = lens[0]
+ var placeHoldersLen = lens[1]
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
+}
+
+function _byteLength (b64, validLen, placeHoldersLen) {
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
+}
+
+function toByteArray (b64) {
+ var tmp
+ var lens = getLens(b64)
+ var validLen = lens[0]
+ var placeHoldersLen = lens[1]
+
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
+
+ var curByte = 0
+
+ // if there are placeholders, only get up to the last complete 4 chars
+ var len = placeHoldersLen > 0
+ ? validLen - 4
+ : validLen
+
+ var i
+ for (i = 0; i < len; i += 4) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 18) |
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
+ revLookup[b64.charCodeAt(i + 3)]
+ arr[curByte++] = (tmp >> 16) & 0xFF
+ arr[curByte++] = (tmp >> 8) & 0xFF
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ if (placeHoldersLen === 2) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 2) |
+ (revLookup[b64.charCodeAt(i + 1)] >> 4)
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ if (placeHoldersLen === 1) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 10) |
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
+ (revLookup[b64.charCodeAt(i + 2)] >> 2)
+ arr[curByte++] = (tmp >> 8) & 0xFF
+ arr[curByte++] = 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) & 0xFF0000) +
+ ((uint8[i + 1] << 8) & 0xFF00) +
+ (uint8[i + 2] & 0xFF)
+ 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 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]
+ parts.push(
+ lookup[tmp >> 2] +
+ lookup[(tmp << 4) & 0x3F] +
+ '=='
+ )
+ } else if (extraBytes === 2) {
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1]
+ parts.push(
+ lookup[tmp >> 10] +
+ lookup[(tmp >> 4) & 0x3F] +
+ lookup[(tmp << 2) & 0x3F] +
+ '='
+ )
+ }
+
+ return parts.join('')
+}
+
+},{}],11:[function(require,module,exports){
+(function (Buffer){(function (){
+/*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */
+/* eslint-disable no-proto */
+
+'use strict'
+
+var base64 = require('base64-js')
+var ieee754 = require('ieee754')
+
+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
+ }
+}
+
+Object.defineProperty(Buffer.prototype, 'parent', {
+ enumerable: true,
+ get: function () {
+ if (!Buffer.isBuffer(this)) return undefined
+ return this.buffer
+ }
+})
+
+Object.defineProperty(Buffer.prototype, 'offset', {
+ enumerable: true,
+ get: function () {
+ if (!Buffer.isBuffer(this)) return undefined
+ return this.byteOffset
+ }
+})
+
+function createBuffer (length) {
+ if (length > K_MAX_LENGTH) {
+ throw new RangeError('The value "' + length + '" is invalid for option "size"')
+ }
+ // 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 TypeError(
+ 'The "string" argument must be of type string. Received type number'
+ )
+ }
+ 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 != null &&
+ 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 === 'string') {
+ return fromString(value, encodingOrOffset)
+ }
+
+ if (ArrayBuffer.isView(value)) {
+ return fromArrayLike(value)
+ }
+
+ if (value == null) {
+ throw TypeError(
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
+ 'or Array-like Object. Received type ' + (typeof value)
+ )
+ }
+
+ if (isInstance(value, ArrayBuffer) ||
+ (value && isInstance(value.buffer, ArrayBuffer))) {
+ return fromArrayBuffer(value, encodingOrOffset, length)
+ }
+
+ if (typeof value === 'number') {
+ throw new TypeError(
+ 'The "value" argument must not be of type number. Received type number'
+ )
+ }
+
+ var valueOf = value.valueOf && value.valueOf()
+ if (valueOf != null && valueOf !== value) {
+ return Buffer.from(valueOf, encodingOrOffset, length)
+ }
+
+ var b = fromObject(value)
+ if (b) return b
+
+ if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
+ typeof value[Symbol.toPrimitive] === 'function') {
+ return Buffer.from(
+ value[Symbol.toPrimitive]('string'), encodingOrOffset, length
+ )
+ }
+
+ throw new TypeError(
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
+ 'or Array-like Object. Received type ' + (typeof 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 of type number')
+ } else if (size < 0) {
+ throw new RangeError('The value "' + size + '" is invalid for option "size"')
+ }
+}
+
+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('Unknown encoding: ' + 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 outside of buffer bounds')
+ }
+
+ if (array.byteLength < byteOffset + (length || 0)) {
+ throw new RangeError('"length" is outside of buffer 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.length !== undefined) {
+ 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)
+ }
+}
+
+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 &&
+ b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
+}
+
+Buffer.compare = function compare (a, b) {
+ if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
+ if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
+ throw new TypeError(
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
+ )
+ }
+
+ 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 (isInstance(buf, Uint8Array)) {
+ buf = Buffer.from(buf)
+ }
+ 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 (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
+ return string.byteLength
+ }
+ if (typeof string !== 'string') {
+ throw new TypeError(
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
+ 'Received type ' + typeof string
+ )
+ }
+
+ var len = string.length
+ var mustMatch = (arguments.length > 2 && arguments[2] === true)
+ if (!mustMatch && 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':
+ 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 mustMatch ? -1 : 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.toLocaleString = Buffer.prototype.toString
+
+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
+ str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
+ if (this.length > max) str += ' ... '
+ return ''
+}
+
+Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
+ if (isInstance(target, Uint8Array)) {
+ target = Buffer.from(target, target.offset, target.byteLength)
+ }
+ if (!Buffer.isBuffer(target)) {
+ throw new TypeError(
+ 'The "target" argument must be one of type Buffer or Uint8Array. ' +
+ 'Received type ' + (typeof target)
+ )
+ }
+
+ 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
+ }
+ }
+
+ var strLen = string.length
+
+ 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 (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
+ 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('Index out of range')
+ 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
+
+ if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
+ // Use built-in when available, missing from IE11
+ this.copyWithin(targetStart, start, end)
+ } else if (this === target && start < targetStart && targetStart < end) {
+ // descending copy from end
+ for (var i = len - 1; i >= 0; --i) {
+ target[i + targetStart] = this[i + start]
+ }
+ } else {
+ Uint8Array.prototype.set.call(
+ target,
+ this.subarray(start, end),
+ 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 (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)
+ }
+ if (val.length === 1) {
+ var code = val.charCodeAt(0)
+ if ((encoding === 'utf8' && code < 128) ||
+ encoding === 'latin1') {
+ // Fast path: If `val` fits into a single byte, use that numeric value.
+ val = code
+ }
+ }
+ } 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
+ : Buffer.from(val, encoding)
+ var len = bytes.length
+ if (len === 0) {
+ throw new TypeError('The value "' + val +
+ '" is invalid for argument "value"')
+ }
+ 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 takes equal signs as end of the Base64 encoding
+ str = str.split('=')[0]
+ // 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
+}
+
+// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
+// the `instanceof` check but they should be treated as of that type.
+// See: https://github.com/feross/buffer/issues/166
+function isInstance (obj, type) {
+ return obj instanceof type ||
+ (obj != null && obj.constructor != null && obj.constructor.name != null &&
+ obj.constructor.name === type.name)
+}
+function numberIsNaN (obj) {
+ // For IE11 support
+ return obj !== obj // eslint-disable-line no-self-compare
+}
+
+}).call(this)}).call(this,require("buffer").Buffer)
+},{"base64-js":10,"buffer":11,"ieee754":12}],12:[function(require,module,exports){
+/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */
+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
+}
+
+},{}]},{},[1])(1)
+});
diff --git a/node_modules/plist/dist/plist.js b/node_modules/plist/dist/plist.js
new file mode 100644
index 0000000..1fd3d9e
--- /dev/null
+++ b/node_modules/plist/dist/plist.js
@@ -0,0 +1,15918 @@
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i,
+ * and raw CDATA nodes.
+ *
+ * @param {Element} node
+ * @returns {Boolean}
+ * @api private
+ */
+
+function shouldIgnoreNode(node) {
+ return (
+ node.nodeType === TEXT_NODE ||
+ node.nodeType === COMMENT_NODE ||
+ node.nodeType === CDATA_NODE
+ );
+}
+
+/**
+ * Check if the node is empty. Some plist file has such node:
+ *
+ * this node shoud be ignored.
+ *
+ * @see https://github.com/TooTallNate/plist.js/issues/66
+ * @param {Element} node
+ * @returns {Boolean}
+ * @api private
+ */
+function isEmptyNode(node) {
+ if (!node.childNodes || node.childNodes.length === 0) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function invariant(test, message) {
+ if (!test) {
+ throw new Error(message);
+ }
+}
+
+/**
+ * Parses a Plist XML string. Returns an Object.
+ *
+ * @param {String} xml - the XML String to decode
+ * @returns {Mixed} the decoded value from the Plist XML
+ * @api public
+ */
+
+function parse(xml) {
+ var doc = new DOMParser().parseFromString(xml, "text/xml");
+ invariant(
+ doc.documentElement.nodeName === "plist",
+ "malformed document. First element should be ",
+ );
+ var plist = parsePlistXML(doc.documentElement);
+
+ // the root node gets interpreted as an Array,
+ // so pull out the inner data first
+ if (plist.length == 1) plist = plist[0];
+
+ return plist;
+}
+
+/**
+ * Convert an XML based plist document into a JSON representation.
+ *
+ * @param {Object} xml_node - current XML node in the plist
+ * @returns {Mixed} built up JSON object
+ * @api private
+ */
+
+function parsePlistXML(node) {
+ var i, new_obj, key, val, new_arr, res, counter, type;
+
+ if (!node) return null;
+
+ if (node.nodeName === "plist") {
+ new_arr = [];
+ if (isEmptyNode(node)) {
+ return new_arr;
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (!shouldIgnoreNode(node.childNodes[i])) {
+ new_arr.push(parsePlistXML(node.childNodes[i]));
+ }
+ }
+ return new_arr;
+ } else if (node.nodeName === "dict") {
+ new_obj = {};
+ key = null;
+ counter = 0;
+ if (isEmptyNode(node)) {
+ return new_obj;
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (shouldIgnoreNode(node.childNodes[i])) continue;
+ if (counter % 2 === 0) {
+ invariant(
+ node.childNodes[i].nodeName === "key",
+ "Missing key while parsing .",
+ );
+ key = parsePlistXML(node.childNodes[i]);
+ } else {
+ invariant(
+ node.childNodes[i].nodeName !== "key",
+ 'Unexpected key "' +
+ parsePlistXML(node.childNodes[i]) +
+ '" while parsing .',
+ );
+ new_obj[key] = parsePlistXML(node.childNodes[i]);
+ }
+ counter += 1;
+ }
+ if (counter % 2 === 1) {
+ new_obj[key] = "";
+ }
+
+ return new_obj;
+ } else if (node.nodeName === "array") {
+ new_arr = [];
+ if (isEmptyNode(node)) {
+ return new_arr;
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (!shouldIgnoreNode(node.childNodes[i])) {
+ res = parsePlistXML(node.childNodes[i]);
+ if (null != res) new_arr.push(res);
+ }
+ }
+ return new_arr;
+ } else if (node.nodeName === "#text") {
+ // TODO: what should we do with text types? (CDATA sections)
+ } else if (node.nodeName === "key") {
+ if (isEmptyNode(node)) {
+ return "";
+ }
+
+ invariant(
+ node.childNodes[0].nodeValue !== "__proto__",
+ "__proto__ keys can lead to prototype pollution. More details on CVE-2022-22912",
+ );
+
+ return node.childNodes[0].nodeValue;
+ } else if (node.nodeName === "string") {
+ res = "";
+ if (isEmptyNode(node)) {
+ return res;
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ var type = node.childNodes[i].nodeType;
+ if (type === TEXT_NODE || type === CDATA_NODE) {
+ res += node.childNodes[i].nodeValue;
+ }
+ }
+ return res;
+ } else if (node.nodeName === "integer") {
+ invariant(!isEmptyNode(node), 'Cannot parse "" as integer.');
+ return parseInt(node.childNodes[0].nodeValue, 10);
+ } else if (node.nodeName === "real") {
+ invariant(!isEmptyNode(node), 'Cannot parse "" as real.');
+ res = "";
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (node.childNodes[i].nodeType === TEXT_NODE) {
+ res += node.childNodes[i].nodeValue;
+ }
+ }
+ return parseFloat(res);
+ } else if (node.nodeName === "data") {
+ res = "";
+ if (isEmptyNode(node)) {
+ return Buffer.from(res, "base64");
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (node.childNodes[i].nodeType === TEXT_NODE) {
+ res += node.childNodes[i].nodeValue.replace(/\s+/g, "");
+ }
+ }
+ return Buffer.from(res, "base64");
+ } else if (node.nodeName === "date") {
+ invariant(!isEmptyNode(node), 'Cannot parse "" as Date.');
+ return new Date(node.childNodes[0].nodeValue);
+ } else if (node.nodeName === "null") {
+ return null;
+ } else if (node.nodeName === "true") {
+ return true;
+ } else if (node.nodeName === "false") {
+ return false;
+ } else {
+ throw new Error("Invalid PLIST tag " + node.nodeName);
+ }
+}
+
+}).call(this)}).call(this,require("buffer").Buffer)
+},{"@xmldom/xmldom":10,"buffer":13}],4:[function(require,module,exports){
+'use strict';
+
+/**
+ * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.
+ *
+ * Works with anything that has a `length` property and index access properties,
+ * including NodeList.
+ *
+ * @param {T[] | { length: number; [number]: T }} list
+ * @param {function (item: T, index: number, list:T[]):boolean} predicate
+ * @param {Partial>?} ac
+ * Allows injecting a custom implementation in tests (`Array.prototype` by default).
+ * @returns {T | undefined}
+ * @template {unknown} T
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
+ * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find
+ */
+function find(list, predicate, ac) {
+ if (ac === undefined) {
+ ac = Array.prototype;
+ }
+ if (list && typeof ac.find === 'function') {
+ return ac.find.call(list, predicate);
+ }
+ for (var i = 0; i < list.length; i++) {
+ if (hasOwn(list, i)) {
+ var item = list[i];
+ if (predicate.call(undefined, item, i, list)) {
+ return item;
+ }
+ }
+ }
+}
+
+/**
+ * "Shallow freezes" an object to render it immutable.
+ * Uses `Object.freeze` if available,
+ * otherwise the immutability is only in the type.
+ *
+ * Is used to create "enum like" objects.
+ *
+ * If `Object.getOwnPropertyDescriptors` is available,
+ * a new object with all properties of object but without any prototype is created and returned
+ * after freezing it.
+ *
+ * @param {T} object
+ * The object to freeze.
+ * @param {Pick} [oc=Object]
+ * `Object` by default,
+ * allows to inject custom object constructor for tests.
+ * @returns {Readonly}
+ * @template {Object} T
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
+ * @prettierignore
+ */
+function freeze(object, oc) {
+ if (oc === undefined) {
+ oc = Object;
+ }
+ if (oc && typeof oc.getOwnPropertyDescriptors === 'function') {
+ object = oc.create(null, oc.getOwnPropertyDescriptors(object));
+ }
+ return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object;
+}
+
+/**
+ * Implementation for `Object.hasOwn` but ES5 compatible.
+ *
+ * @param {any} object
+ * @param {string | number} key
+ * @returns {boolean}
+ */
+function hasOwn(object, key) {
+ return Object.prototype.hasOwnProperty.call(object, key);
+}
+
+/**
+ * Since xmldom can not rely on `Object.assign`,
+ * it uses/provides a simplified version that is sufficient for its needs.
+ *
+ * @param {Object} target
+ * @param {Object | null | undefined} source
+ * @returns {Object}
+ * The target with the merged/overridden properties.
+ * @throws {TypeError}
+ * If target is not an object.
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
+ * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign
+ */
+function assign(target, source) {
+ if (target === null || typeof target !== 'object') {
+ throw new TypeError('target is not an object');
+ }
+ for (var key in source) {
+ if (hasOwn(source, key)) {
+ target[key] = source[key];
+ }
+ }
+ return target;
+}
+
+/**
+ * A number of attributes are boolean attributes.
+ * The presence of a boolean attribute on an element represents the `true` value,
+ * and the absence of the attribute represents the `false` value.
+ *
+ * If the attribute is present, its value must either be the empty string, or a value that is
+ * an ASCII case-insensitive match for the attribute's canonical name,
+ * with no leading or trailing whitespace.
+ *
+ * Note: The values `"true"` and `"false"` are not allowed on boolean attributes.
+ * To represent a `false` value, the attribute has to be omitted altogether.
+ *
+ * @see https://html.spec.whatwg.org/#boolean-attributes
+ * @see https://html.spec.whatwg.org/#attributes-3
+ */
+var HTML_BOOLEAN_ATTRIBUTES = freeze({
+ allowfullscreen: true,
+ async: true,
+ autofocus: true,
+ autoplay: true,
+ checked: true,
+ controls: true,
+ default: true,
+ defer: true,
+ disabled: true,
+ formnovalidate: true,
+ hidden: true,
+ ismap: true,
+ itemscope: true,
+ loop: true,
+ multiple: true,
+ muted: true,
+ nomodule: true,
+ novalidate: true,
+ open: true,
+ playsinline: true,
+ readonly: true,
+ required: true,
+ reversed: true,
+ selected: true,
+});
+
+/**
+ * Check if `name` is matching one of the HTML boolean attribute names.
+ * This method doesn't check if such attributes are allowed in the context of the current
+ * document/parsing.
+ *
+ * @param {string} name
+ * @returns {boolean}
+ * @see {@link HTML_BOOLEAN_ATTRIBUTES}
+ * @see https://html.spec.whatwg.org/#boolean-attributes
+ * @see https://html.spec.whatwg.org/#attributes-3
+ */
+function isHTMLBooleanAttribute(name) {
+ return hasOwn(HTML_BOOLEAN_ATTRIBUTES, name.toLowerCase());
+}
+
+/**
+ * Void elements only have a start tag; end tags must not be specified for void elements.
+ * These elements should be written as self-closing like this: ` `.
+ * This should not be confused with optional tags that HTML allows to omit the end tag for
+ * (like `li`, `tr` and others), which can have content after them,
+ * so they can not be written as self-closing.
+ * xmldom does not have any logic for optional end tags cases,
+ * and will report them as a warning.
+ * Content that would go into the unopened element,
+ * will instead be added as a sibling text node.
+ *
+ * @type {Readonly<{
+ * area: boolean;
+ * col: boolean;
+ * img: boolean;
+ * wbr: boolean;
+ * link: boolean;
+ * hr: boolean;
+ * source: boolean;
+ * br: boolean;
+ * input: boolean;
+ * param: boolean;
+ * meta: boolean;
+ * embed: boolean;
+ * track: boolean;
+ * base: boolean;
+ * }>}
+ * @see https://html.spec.whatwg.org/#void-elements
+ * @see https://html.spec.whatwg.org/#optional-tags
+ */
+var HTML_VOID_ELEMENTS = freeze({
+ area: true,
+ base: true,
+ br: true,
+ col: true,
+ embed: true,
+ hr: true,
+ img: true,
+ input: true,
+ link: true,
+ meta: true,
+ param: true,
+ source: true,
+ track: true,
+ wbr: true,
+});
+
+/**
+ * Check if `tagName` is matching one of the HTML void element names.
+ * This method doesn't check if such tags are allowed in the context of the current
+ * document/parsing.
+ *
+ * @param {string} tagName
+ * @returns {boolean}
+ * @see {@link HTML_VOID_ELEMENTS}
+ * @see https://html.spec.whatwg.org/#void-elements
+ */
+function isHTMLVoidElement(tagName) {
+ return hasOwn(HTML_VOID_ELEMENTS, tagName.toLowerCase());
+}
+
+/**
+ * Tag names that are raw text elements according to HTML spec.
+ * The value denotes whether they are escapable or not.
+ *
+ * @see {@link isHTMLEscapableRawTextElement}
+ * @see {@link isHTMLRawTextElement}
+ * @see https://html.spec.whatwg.org/#raw-text-elements
+ * @see https://html.spec.whatwg.org/#escapable-raw-text-elements
+ */
+var HTML_RAW_TEXT_ELEMENTS = freeze({
+ script: false,
+ style: false,
+ textarea: true,
+ title: true,
+});
+
+/**
+ * Check if `tagName` is matching one of the HTML raw text element names.
+ * This method doesn't check if such tags are allowed in the context of the current
+ * document/parsing.
+ *
+ * @param {string} tagName
+ * @returns {boolean}
+ * @see {@link isHTMLEscapableRawTextElement}
+ * @see {@link HTML_RAW_TEXT_ELEMENTS}
+ * @see https://html.spec.whatwg.org/#raw-text-elements
+ * @see https://html.spec.whatwg.org/#escapable-raw-text-elements
+ */
+function isHTMLRawTextElement(tagName) {
+ var key = tagName.toLowerCase();
+ return hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && !HTML_RAW_TEXT_ELEMENTS[key];
+}
+/**
+ * Check if `tagName` is matching one of the HTML escapable raw text element names.
+ * This method doesn't check if such tags are allowed in the context of the current
+ * document/parsing.
+ *
+ * @param {string} tagName
+ * @returns {boolean}
+ * @see {@link isHTMLRawTextElement}
+ * @see {@link HTML_RAW_TEXT_ELEMENTS}
+ * @see https://html.spec.whatwg.org/#raw-text-elements
+ * @see https://html.spec.whatwg.org/#escapable-raw-text-elements
+ */
+function isHTMLEscapableRawTextElement(tagName) {
+ var key = tagName.toLowerCase();
+ return hasOwn(HTML_RAW_TEXT_ELEMENTS, key) && HTML_RAW_TEXT_ELEMENTS[key];
+}
+/**
+ * Only returns true if `value` matches MIME_TYPE.HTML, which indicates an HTML document.
+ *
+ * @param {string} mimeType
+ * @returns {mimeType is 'text/html'}
+ * @see https://www.iana.org/assignments/media-types/text/html
+ * @see https://en.wikipedia.org/wiki/HTML
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
+ */
+function isHTMLMimeType(mimeType) {
+ return mimeType === MIME_TYPE.HTML;
+}
+/**
+ * For both the `text/html` and the `application/xhtml+xml` namespace the spec defines that the
+ * HTML namespace is provided as the default.
+ *
+ * @param {string} mimeType
+ * @returns {boolean}
+ * @see https://dom.spec.whatwg.org/#dom-document-createelement
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
+ */
+function hasDefaultHTMLNamespace(mimeType) {
+ return isHTMLMimeType(mimeType) || mimeType === MIME_TYPE.XML_XHTML_APPLICATION;
+}
+
+/**
+ * All mime types that are allowed as input to `DOMParser.parseFromString`
+ *
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
+ * MDN
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype
+ * WHATWG HTML Spec
+ * @see {@link DOMParser.prototype.parseFromString}
+ */
+var MIME_TYPE = freeze({
+ /**
+ * `text/html`, the only mime type that triggers treating an XML document as HTML.
+ *
+ * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
+ * @see https://en.wikipedia.org/wiki/HTML Wikipedia
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
+ * WHATWG HTML Spec
+ */
+ HTML: 'text/html',
+
+ /**
+ * `application/xml`, the standard mime type for XML documents.
+ *
+ * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType
+ * registration
+ * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
+ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
+ */
+ XML_APPLICATION: 'application/xml',
+
+ /**
+ * `text/xml`, an alias for `application/xml`.
+ *
+ * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
+ * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
+ * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
+ */
+ XML_TEXT: 'text/xml',
+
+ /**
+ * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
+ * but is parsed as an XML document.
+ *
+ * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType
+ * registration
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
+ * @see https://en.wikipedia.org/wiki/XHTML Wikipedia
+ */
+ XML_XHTML_APPLICATION: 'application/xhtml+xml',
+
+ /**
+ * `image/svg+xml`,
+ *
+ * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
+ * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
+ * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
+ */
+ XML_SVG_IMAGE: 'image/svg+xml',
+});
+/**
+ * @typedef {'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}
+ * MimeType
+ */
+/**
+ * @type {MimeType[]}
+ * @private
+ * Basically `Object.values`, which is not available in ES5.
+ */
+var _MIME_TYPES = Object.keys(MIME_TYPE).map(function (key) {
+ return MIME_TYPE[key];
+});
+
+/**
+ * Only returns true if `mimeType` is one of the allowed values for
+ * `DOMParser.parseFromString`.
+ *
+ * @param {string} mimeType
+ * @returns {mimeType is 'application/xhtml+xml' | 'application/xml' | 'image/svg+xml' | 'text/html' | 'text/xml'}
+ *
+ */
+function isValidMimeType(mimeType) {
+ return _MIME_TYPES.indexOf(mimeType) > -1;
+}
+/**
+ * Namespaces that are used in this code base.
+ *
+ * @see http://www.w3.org/TR/REC-xml-names
+ */
+var NAMESPACE = freeze({
+ /**
+ * The XHTML namespace.
+ *
+ * @see http://www.w3.org/1999/xhtml
+ */
+ HTML: 'http://www.w3.org/1999/xhtml',
+
+ /**
+ * The SVG namespace.
+ *
+ * @see http://www.w3.org/2000/svg
+ */
+ SVG: 'http://www.w3.org/2000/svg',
+
+ /**
+ * The `xml:` namespace.
+ *
+ * @see http://www.w3.org/XML/1998/namespace
+ */
+ XML: 'http://www.w3.org/XML/1998/namespace',
+
+ /**
+ * The `xmlns:` namespace.
+ *
+ * @see https://www.w3.org/2000/xmlns/
+ */
+ XMLNS: 'http://www.w3.org/2000/xmlns/',
+});
+
+exports.assign = assign;
+exports.find = find;
+exports.freeze = freeze;
+exports.HTML_BOOLEAN_ATTRIBUTES = HTML_BOOLEAN_ATTRIBUTES;
+exports.HTML_RAW_TEXT_ELEMENTS = HTML_RAW_TEXT_ELEMENTS;
+exports.HTML_VOID_ELEMENTS = HTML_VOID_ELEMENTS;
+exports.hasDefaultHTMLNamespace = hasDefaultHTMLNamespace;
+exports.hasOwn = hasOwn;
+exports.isHTMLBooleanAttribute = isHTMLBooleanAttribute;
+exports.isHTMLRawTextElement = isHTMLRawTextElement;
+exports.isHTMLEscapableRawTextElement = isHTMLEscapableRawTextElement;
+exports.isHTMLMimeType = isHTMLMimeType;
+exports.isHTMLVoidElement = isHTMLVoidElement;
+exports.isValidMimeType = isValidMimeType;
+exports.MIME_TYPE = MIME_TYPE;
+exports.NAMESPACE = NAMESPACE;
+
+},{}],5:[function(require,module,exports){
+'use strict';
+
+var conventions = require('./conventions');
+var dom = require('./dom');
+var errors = require('./errors');
+var entities = require('./entities');
+var sax = require('./sax');
+
+var DOMImplementation = dom.DOMImplementation;
+
+var hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;
+var isHTMLMimeType = conventions.isHTMLMimeType;
+var isValidMimeType = conventions.isValidMimeType;
+var MIME_TYPE = conventions.MIME_TYPE;
+var NAMESPACE = conventions.NAMESPACE;
+var ParseError = errors.ParseError;
+
+var XMLReader = sax.XMLReader;
+
+/**
+ * Normalizes line ending according to ,
+ * including some Unicode "newline" characters:
+ *
+ * > XML parsed entities are often stored in computer files which,
+ * > for editing convenience, are organized into lines.
+ * > These lines are typically separated by some combination
+ * > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).
+ * >
+ * > To simplify the tasks of applications, the XML processor must behave
+ * > as if it normalized all line breaks in external parsed entities (including the document entity)
+ * > on input, before parsing, by translating the following to a single #xA character:
+ * >
+ * > 1. the two-character sequence #xD #xA,
+ * > 2. the two-character sequence #xD #x85,
+ * > 3. the single character #x85,
+ * > 4. the single character #x2028,
+ * > 5. the single character #x2029,
+ * > 6. any #xD character that is not immediately followed by #xA or #x85.
+ *
+ * @param {string} input
+ * @returns {string}
+ * @prettierignore
+ */
+function normalizeLineEndings(input) {
+ return input.replace(/\r[\n\u0085]/g, '\n').replace(/[\r\u0085\u2028\u2029]/g, '\n');
+}
+
+/**
+ * @typedef Locator
+ * @property {number} [columnNumber]
+ * @property {number} [lineNumber]
+ */
+
+/**
+ * @typedef DOMParserOptions
+ * @property {typeof assign} [assign]
+ * The method to use instead of `conventions.assign`, which is used to copy values from
+ * `options` before they are used for parsing.
+ * @property {typeof DOMHandler} [domHandler]
+ * For internal testing: The class for creating an instance for handling events from the SAX
+ * parser.
+ * *****Warning: By configuring a faulty implementation, the specified behavior can completely
+ * be broken.*****.
+ * @property {Function} [errorHandler]
+ * DEPRECATED! use `onError` instead.
+ * @property {function(level:ErrorLevel, message:string, context: DOMHandler):void}
+ * [onError]
+ * A function invoked for every error that occurs during parsing.
+ *
+ * If it is not provided, all errors are reported to `console.error`
+ * and only `fatalError`s are thrown as a `ParseError`,
+ * which prevents any further processing.
+ * If the provided method throws, a `ParserError` is thrown,
+ * which prevents any further processing.
+ *
+ * Be aware that many `warning`s are considered an error that prevents further processing in
+ * most implementations.
+ * @property {boolean} [locator=true]
+ * Configures if the nodes created during parsing will have a `lineNumber` and a `columnNumber`
+ * attribute describing their location in the XML string.
+ * Default is true.
+ * @property {(string) => string} [normalizeLineEndings]
+ * used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,
+ * which normalizes line endings according to ,
+ * including some Unicode "newline" characters.
+ * @property {Object} [xmlns]
+ * The XML namespaces that should be assumed when parsing.
+ * The default namespace can be provided by the key that is the empty string.
+ * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,
+ * the default namespace that will be used,
+ * will be overridden according to the specification.
+ * @see {@link normalizeLineEndings}
+ */
+
+/**
+ * The DOMParser interface provides the ability to parse XML or HTML source code from a string
+ * into a DOM `Document`.
+ *
+ * ***xmldom is different from the spec in that it allows an `options` parameter,
+ * to control the behavior***.
+ *
+ * @class
+ * @param {DOMParserOptions} [options]
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
+ */
+function DOMParser(options) {
+ options = options || {};
+ if (options.locator === undefined) {
+ options.locator = true;
+ }
+
+ /**
+ * The method to use instead of `conventions.assign`, which is used to copy values from
+ * `options`
+ * before they are used for parsing.
+ *
+ * @type {conventions.assign}
+ * @private
+ * @see {@link conventions.assign}
+ * @readonly
+ */
+ this.assign = options.assign || conventions.assign;
+
+ /**
+ * For internal testing: The class for creating an instance for handling events from the SAX
+ * parser.
+ * *****Warning: By configuring a faulty implementation, the specified behavior can completely
+ * be broken*****.
+ *
+ * @type {typeof DOMHandler}
+ * @private
+ * @readonly
+ */
+ this.domHandler = options.domHandler || DOMHandler;
+
+ /**
+ * A function that is invoked for every error that occurs during parsing.
+ *
+ * If it is not provided, all errors are reported to `console.error`
+ * and only `fatalError`s are thrown as a `ParseError`,
+ * which prevents any further processing.
+ * If the provided method throws, a `ParserError` is thrown,
+ * which prevents any further processing.
+ *
+ * Be aware that many `warning`s are considered an error that prevents further processing in
+ * most implementations.
+ *
+ * @type {function(level:ErrorLevel, message:string, context: DOMHandler):void}
+ * @see {@link onErrorStopParsing}
+ * @see {@link onWarningStopParsing}
+ */
+ this.onError = options.onError || options.errorHandler;
+ if (options.errorHandler && typeof options.errorHandler !== 'function') {
+ throw new TypeError('errorHandler object is no longer supported, switch to onError!');
+ } else if (options.errorHandler) {
+ options.errorHandler('warning', 'The `errorHandler` option has been deprecated, use `onError` instead!', this);
+ }
+
+ /**
+ * used to replace line endings before parsing, defaults to `normalizeLineEndings`
+ *
+ * @type {(string) => string}
+ * @readonly
+ */
+ this.normalizeLineEndings = options.normalizeLineEndings || normalizeLineEndings;
+
+ /**
+ * Configures if the nodes created during parsing will have a `lineNumber` and a
+ * `columnNumber`
+ * attribute describing their location in the XML string.
+ * Default is true.
+ *
+ * @type {boolean}
+ * @readonly
+ */
+ this.locator = !!options.locator;
+
+ /**
+ * The default namespace can be provided by the key that is the empty string.
+ * When the `mimeType` for HTML, XHTML or SVG are passed to `parseFromString`,
+ * the default namespace that will be used,
+ * will be overridden according to the specification.
+ *
+ * @type {Readonly}
+ * @readonly
+ */
+ this.xmlns = this.assign(Object.create(null), options.xmlns);
+}
+
+/**
+ * Parses `source` using the options in the way configured by the `DOMParserOptions` of `this`
+ * `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created,
+ * otherwise an XML `Document` is created.
+ *
+ * __It behaves different from the description in the living standard__:
+ * - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.
+ * - Any unexpected input is reported to `onError` with either a `warning`,
+ * `error` or `fatalError` level.
+ * - Any `fatalError` throws a `ParseError` which prevents further processing.
+ * - Any error thrown by `onError` is converted to a `ParseError` which prevents further
+ * processing - If no `Document` was created during parsing it is reported as a `fatalError`.
+ * *****Warning: By configuring a faulty DOMHandler implementation,
+ * the specified behavior can completely be broken*****.
+ *
+ * @param {string} source
+ * The XML mime type only allows string input!
+ * @param {string} [mimeType='application/xml']
+ * the mimeType or contentType of the document to be created determines the `type` of document
+ * created (XML or HTML)
+ * @returns {Document}
+ * The `Document` node.
+ * @throws {ParseError}
+ * for any `fatalError` or anything that is thrown by `onError`
+ * @throws {TypeError}
+ * for any invalid `mimeType`
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
+ * @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev
+ */
+DOMParser.prototype.parseFromString = function (source, mimeType) {
+ if (!isValidMimeType(mimeType)) {
+ throw new TypeError('DOMParser.parseFromString: the provided mimeType "' + mimeType + '" is not valid.');
+ }
+ var defaultNSMap = this.assign(Object.create(null), this.xmlns);
+ var entityMap = entities.XML_ENTITIES;
+ var defaultNamespace = defaultNSMap[''] || null;
+ if (hasDefaultHTMLNamespace(mimeType)) {
+ entityMap = entities.HTML_ENTITIES;
+ defaultNamespace = NAMESPACE.HTML;
+ } else if (mimeType === MIME_TYPE.XML_SVG_IMAGE) {
+ defaultNamespace = NAMESPACE.SVG;
+ }
+ defaultNSMap[''] = defaultNamespace;
+ defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
+
+ var domBuilder = new this.domHandler({
+ mimeType: mimeType,
+ defaultNamespace: defaultNamespace,
+ onError: this.onError,
+ });
+ var locator = this.locator ? {} : undefined;
+ if (this.locator) {
+ domBuilder.setDocumentLocator(locator);
+ }
+
+ var sax = new XMLReader();
+ sax.errorHandler = domBuilder;
+ sax.domBuilder = domBuilder;
+ var isXml = !conventions.isHTMLMimeType(mimeType);
+ if (isXml && typeof source !== 'string') {
+ sax.errorHandler.fatalError('source is not a string');
+ }
+ sax.parse(this.normalizeLineEndings(String(source)), defaultNSMap, entityMap);
+ if (!domBuilder.doc.documentElement) {
+ sax.errorHandler.fatalError('missing root element');
+ }
+ return domBuilder.doc;
+};
+
+/**
+ * @typedef DOMHandlerOptions
+ * @property {string} [mimeType=MIME_TYPE.XML_APPLICATION]
+ * @property {string | null} [defaultNamespace=null]
+ */
+/**
+ * The class that is used to handle events from the SAX parser to create the related DOM
+ * elements.
+ *
+ * Some methods are only implemented as an empty function,
+ * since they are (at least currently) not relevant for xmldom.
+ *
+ * @class
+ * @param {DOMHandlerOptions} [options]
+ * @see http://www.saxproject.org/apidoc/org/xml/sax/ext/DefaultHandler2.html
+ */
+function DOMHandler(options) {
+ var opt = options || {};
+ /**
+ * The mime type is used to determine if the DOM handler will create an XML or HTML document.
+ * Only if it is set to `text/html` it will create an HTML document.
+ * It defaults to MIME_TYPE.XML_APPLICATION.
+ *
+ * @type {string}
+ * @see {@link MIME_TYPE}
+ * @readonly
+ */
+ this.mimeType = opt.mimeType || MIME_TYPE.XML_APPLICATION;
+
+ /**
+ * The namespace to use to create an XML document.
+ * For the following reasons this is required:
+ * - The SAX API for `startDocument` doesn't offer any way to pass a namespace,
+ * since at that point there is no way for the parser to know what the default namespace from
+ * the document will be.
+ * - When creating using `DOMImplementation.createDocument` it is required to pass a
+ * namespace,
+ * to determine the correct `Document.contentType`, which should match `this.mimeType`.
+ * - When parsing an XML document with the `application/xhtml+xml` mimeType,
+ * the HTML namespace needs to be the default namespace.
+ *
+ * @type {string | null}
+ * @private
+ * @readonly
+ */
+ this.defaultNamespace = opt.defaultNamespace || null;
+
+ /**
+ * @type {boolean}
+ * @private
+ */
+ this.cdata = false;
+
+ /**
+ * The last `Element` that was created by `startElement`.
+ * `endElement` sets it to the `currentElement.parentNode`.
+ *
+ * Note: The sax parser currently sets it to white space text nodes between tags.
+ *
+ * @type {Element | Node | undefined}
+ * @private
+ */
+ this.currentElement = undefined;
+
+ /**
+ * The Document that is created as part of `startDocument`,
+ * and returned by `DOMParser.parseFromString`.
+ *
+ * @type {Document | undefined}
+ * @readonly
+ */
+ this.doc = undefined;
+
+ /**
+ * The locator is stored as part of setDocumentLocator.
+ * It is controlled and mutated by the SAX parser to store the current parsing position.
+ * It is used by DOMHandler to set `columnNumber` and `lineNumber`
+ * on the DOM nodes.
+ *
+ * @type {Readonly | undefined}
+ * @private
+ * @readonly (the
+ * sax parser currently sometimes set's it)
+ */
+ this.locator = undefined;
+ /**
+ * @type {function (level:ErrorLevel ,message:string, context:DOMHandler):void}
+ * @readonly
+ */
+ this.onError = opt.onError;
+}
+
+function position(locator, node) {
+ node.lineNumber = locator.lineNumber;
+ node.columnNumber = locator.columnNumber;
+}
+
+DOMHandler.prototype = {
+ /**
+ * Either creates an XML or an HTML document and stores it under `this.doc`.
+ * If it is an XML document, `this.defaultNamespace` is used to create it,
+ * and it will not contain any `childNodes`.
+ * If it is an HTML document, it will be created without any `childNodes`.
+ *
+ * @see http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
+ */
+ startDocument: function () {
+ var impl = new DOMImplementation();
+ this.doc = isHTMLMimeType(this.mimeType) ? impl.createHTMLDocument(false) : impl.createDocument(this.defaultNamespace, '');
+ },
+ startElement: function (namespaceURI, localName, qName, attrs) {
+ var doc = this.doc;
+ var el = doc.createElementNS(namespaceURI, qName || localName);
+ var len = attrs.length;
+ appendElement(this, el);
+ this.currentElement = el;
+
+ this.locator && position(this.locator, el);
+ for (var i = 0; i < len; i++) {
+ var namespaceURI = attrs.getURI(i);
+ var value = attrs.getValue(i);
+ var qName = attrs.getQName(i);
+ var attr = doc.createAttributeNS(namespaceURI, qName);
+ this.locator && position(attrs.getLocator(i), attr);
+ attr.value = attr.nodeValue = value;
+ el.setAttributeNode(attr);
+ }
+ },
+ endElement: function (namespaceURI, localName, qName) {
+ this.currentElement = this.currentElement.parentNode;
+ },
+ startPrefixMapping: function (prefix, uri) {},
+ endPrefixMapping: function (prefix) {},
+ processingInstruction: function (target, data) {
+ var ins = this.doc.createProcessingInstruction(target, data);
+ this.locator && position(this.locator, ins);
+ appendElement(this, ins);
+ },
+ ignorableWhitespace: function (ch, start, length) {},
+ characters: function (chars, start, length) {
+ chars = _toString.apply(this, arguments);
+ //console.log(chars)
+ if (chars) {
+ if (this.cdata) {
+ var charNode = this.doc.createCDATASection(chars);
+ } else {
+ var charNode = this.doc.createTextNode(chars);
+ }
+ if (this.currentElement) {
+ this.currentElement.appendChild(charNode);
+ } else if (/^\s*$/.test(chars)) {
+ this.doc.appendChild(charNode);
+ //process xml
+ }
+ this.locator && position(this.locator, charNode);
+ }
+ },
+ skippedEntity: function (name) {},
+ endDocument: function () {
+ this.doc.normalize();
+ },
+ /**
+ * Stores the locator to be able to set the `columnNumber` and `lineNumber`
+ * on the created DOM nodes.
+ *
+ * @param {Locator} locator
+ */
+ setDocumentLocator: function (locator) {
+ if (locator) {
+ locator.lineNumber = 0;
+ }
+ this.locator = locator;
+ },
+ //LexicalHandler
+ comment: function (chars, start, length) {
+ chars = _toString.apply(this, arguments);
+ var comm = this.doc.createComment(chars);
+ this.locator && position(this.locator, comm);
+ appendElement(this, comm);
+ },
+
+ startCDATA: function () {
+ //used in characters() methods
+ this.cdata = true;
+ },
+ endCDATA: function () {
+ this.cdata = false;
+ },
+
+ startDTD: function (name, publicId, systemId, internalSubset) {
+ var impl = this.doc.implementation;
+ if (impl && impl.createDocumentType) {
+ var dt = impl.createDocumentType(name, publicId, systemId, internalSubset);
+ this.locator && position(this.locator, dt);
+ appendElement(this, dt);
+ this.doc.doctype = dt;
+ }
+ },
+ reportError: function (level, message) {
+ if (typeof this.onError === 'function') {
+ try {
+ this.onError(level, message, this);
+ } catch (e) {
+ throw new ParseError('Reporting ' + level + ' "' + message + '" caused ' + e, this.locator);
+ }
+ } else {
+ console.error('[xmldom ' + level + ']\t' + message, _locator(this.locator));
+ }
+ },
+ /**
+ * @see http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
+ */
+ warning: function (message) {
+ this.reportError('warning', message);
+ },
+ error: function (message) {
+ this.reportError('error', message);
+ },
+ /**
+ * This function reports a fatal error and throws a ParseError.
+ *
+ * @param {string} message
+ * - The message to be used for reporting and throwing the error.
+ * @returns {never}
+ * This function always throws an error and never returns a value.
+ * @throws {ParseError}
+ * Always throws a ParseError with the provided message.
+ */
+ fatalError: function (message) {
+ this.reportError('fatalError', message);
+ throw new ParseError(message, this.locator);
+ },
+};
+
+function _locator(l) {
+ if (l) {
+ return '\n@#[line:' + l.lineNumber + ',col:' + l.columnNumber + ']';
+ }
+}
+
+function _toString(chars, start, length) {
+ if (typeof chars == 'string') {
+ return chars.substr(start, length);
+ } else {
+ //java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
+ if (chars.length >= start + length || start) {
+ return new java.lang.String(chars, start, length) + '';
+ }
+ return chars;
+ }
+}
+
+/*
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
+ * used method of org.xml.sax.ext.LexicalHandler:
+ * #comment(chars, start, length)
+ * #startCDATA()
+ * #endCDATA()
+ * #startDTD(name, publicId, systemId)
+ *
+ *
+ * IGNORED method of org.xml.sax.ext.LexicalHandler:
+ * #endDTD()
+ * #startEntity(name)
+ * #endEntity(name)
+ *
+ *
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
+ * IGNORED method of org.xml.sax.ext.DeclHandler
+ * #attributeDecl(eName, aName, type, mode, value)
+ * #elementDecl(name, model)
+ * #externalEntityDecl(name, publicId, systemId)
+ * #internalEntityDecl(name, value)
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
+ * IGNORED method of org.xml.sax.EntityResolver2
+ * #resolveEntity(String name,String publicId,String baseURI,String systemId)
+ * #resolveEntity(publicId, systemId)
+ * #getExternalSubset(name, baseURI)
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
+ * IGNORED method of org.xml.sax.DTDHandler
+ * #notationDecl(name, publicId, systemId) {};
+ * #unparsedEntityDecl(name, publicId, systemId, notationName) {};
+ */
+'endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl'.replace(
+ /\w+/g,
+ function (key) {
+ DOMHandler.prototype[key] = function () {
+ return null;
+ };
+ }
+);
+
+/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
+function appendElement(handler, node) {
+ if (!handler.currentElement) {
+ handler.doc.appendChild(node);
+ } else {
+ handler.currentElement.appendChild(node);
+ }
+}
+
+/**
+ * A method that prevents any further parsing when an `error`
+ * with level `error` is reported during parsing.
+ *
+ * @see {@link DOMParserOptions.onError}
+ * @see {@link onWarningStopParsing}
+ */
+function onErrorStopParsing(level) {
+ if (level === 'error') throw 'onErrorStopParsing';
+}
+
+/**
+ * A method that prevents any further parsing when any `error` is reported during parsing.
+ *
+ * @see {@link DOMParserOptions.onError}
+ * @see {@link onErrorStopParsing}
+ */
+function onWarningStopParsing() {
+ throw 'onWarningStopParsing';
+}
+
+exports.__DOMHandler = DOMHandler;
+exports.DOMParser = DOMParser;
+exports.normalizeLineEndings = normalizeLineEndings;
+exports.onErrorStopParsing = onErrorStopParsing;
+exports.onWarningStopParsing = onWarningStopParsing;
+
+},{"./conventions":4,"./dom":6,"./entities":7,"./errors":8,"./sax":11}],6:[function(require,module,exports){
+'use strict';
+
+var conventions = require('./conventions');
+var find = conventions.find;
+var hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;
+var hasOwn = conventions.hasOwn;
+var isHTMLMimeType = conventions.isHTMLMimeType;
+var isHTMLRawTextElement = conventions.isHTMLRawTextElement;
+var isHTMLVoidElement = conventions.isHTMLVoidElement;
+var MIME_TYPE = conventions.MIME_TYPE;
+var NAMESPACE = conventions.NAMESPACE;
+
+/**
+ * Private DOM Constructor symbol
+ *
+ * Internal symbol used for construction of all classes whose constructors should be private.
+ * Currently used for checks in `Node`, `Document`, `Element`, `Attr`, `CharacterData`, `Text`, `Comment`,
+ * `CDATASection`, `DocumentType`, `Notation`, `Entity`, `EntityReference`, `DocumentFragment`, `ProcessingInstruction`
+ * so the constructor can't be used from outside the module.
+ */
+var PDC = Symbol();
+
+var errors = require('./errors');
+var DOMException = errors.DOMException;
+var DOMExceptionName = errors.DOMExceptionName;
+
+var g = require('./grammar');
+
+/**
+ * Checks if the given symbol equals the Private DOM Constructor symbol (PDC)
+ * and throws an Illegal constructor exception when the symbols don't match.
+ * This ensures that the constructor remains private and can't be used outside this module.
+ */
+function checkSymbol(symbol) {
+ if (symbol !== PDC) {
+ throw new TypeError('Illegal constructor');
+ }
+}
+
+/**
+ * A prerequisite for `[].filter`, to drop elements that are empty.
+ *
+ * @param {string} input
+ * The string to be checked.
+ * @returns {boolean}
+ * Returns `true` if the input string is not empty, `false` otherwise.
+ */
+function notEmptyString(input) {
+ return input !== '';
+}
+/**
+ * Splits a string on ASCII whitespace characters (U+0009 TAB, U+000A LF, U+000C FF, U+000D CR,
+ * U+0020 SPACE).
+ * It follows the definition from the infra specification from WHATWG.
+ *
+ * @param {string} input
+ * The string to be split.
+ * @returns {string[]}
+ * An array of the split strings. The array can be empty if the input string is empty or only
+ * contains whitespace characters.
+ * @see {@link https://infra.spec.whatwg.org/#split-on-ascii-whitespace}
+ * @see {@link https://infra.spec.whatwg.org/#ascii-whitespace}
+ */
+function splitOnASCIIWhitespace(input) {
+ // U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE
+ return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : [];
+}
+
+/**
+ * Adds element as a key to current if it is not already present.
+ *
+ * @param {Record} current
+ * The current record object to which the element will be added as a key.
+ * The object's keys are string types and values are either boolean or undefined.
+ * @param {string} element
+ * The string to be added as a key to the current record.
+ * @returns {Record}
+ * The updated record object after the addition of the new element.
+ */
+function orderedSetReducer(current, element) {
+ if (!hasOwn(current, element)) {
+ current[element] = true;
+ }
+ return current;
+}
+
+/**
+ * Converts a string into an ordered set by splitting the input on ASCII whitespace and
+ * ensuring uniqueness of elements.
+ * This follows the definition of an ordered set from the infra specification by WHATWG.
+ *
+ * @param {string} input
+ * The input string to be transformed into an ordered set.
+ * @returns {string[]}
+ * An array of unique strings obtained from the input, preserving the original order.
+ * The array can be empty if the input string is empty or only contains whitespace characters.
+ * @see {@link https://infra.spec.whatwg.org/#ordered-set}
+ */
+function toOrderedSet(input) {
+ if (!input) return [];
+ var list = splitOnASCIIWhitespace(input);
+ return Object.keys(list.reduce(orderedSetReducer, {}));
+}
+
+/**
+ * Uses `list.indexOf` to implement a function that behaves like `Array.prototype.includes`.
+ * This function is used in environments where `Array.prototype.includes` may not be available.
+ *
+ * @param {any[]} list
+ * The array in which to search for the element.
+ * @returns {function(any): boolean}
+ * A function that accepts an element and returns a boolean indicating whether the element is
+ * included in the provided list.
+ */
+function arrayIncludes(list) {
+ return function (element) {
+ return list && list.indexOf(element) !== -1;
+ };
+}
+
+/**
+ * Validates a qualified name based on the criteria provided in the DOM specification by
+ * WHATWG.
+ *
+ * @param {string} qualifiedName
+ * The qualified name to be validated.
+ * @throws {DOMException}
+ * With code {@link DOMException.INVALID_CHARACTER_ERR} if the qualified name contains an
+ * invalid character.
+ * @see {@link https://dom.spec.whatwg.org/#validate}
+ */
+function validateQualifiedName(qualifiedName) {
+ if (!g.QName_exact.test(qualifiedName)) {
+ throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in qualified name "' + qualifiedName + '"');
+ }
+}
+
+/**
+ * Validates a qualified name and the namespace associated with it,
+ * based on the criteria provided in the DOM specification by WHATWG.
+ *
+ * @param {string | null} namespace
+ * The namespace to be validated. It can be a string or null.
+ * @param {string} qualifiedName
+ * The qualified name to be validated.
+ * @returns {[namespace: string | null, prefix: string | null, localName: string]}
+ * Returns a tuple with the namespace,
+ * prefix and local name of the qualified name.
+ * @throws {DOMException}
+ * Throws a DOMException if the qualified name or the namespace is not valid.
+ * @see {@link https://dom.spec.whatwg.org/#validate-and-extract}
+ */
+function validateAndExtract(namespace, qualifiedName) {
+ validateQualifiedName(qualifiedName);
+ namespace = namespace || null;
+ /**
+ * @type {string | null}
+ */
+ var prefix = null;
+ var localName = qualifiedName;
+ if (qualifiedName.indexOf(':') >= 0) {
+ var splitResult = qualifiedName.split(':');
+ prefix = splitResult[0];
+ localName = splitResult[1];
+ }
+ if (prefix !== null && namespace === null) {
+ throw new DOMException(DOMException.NAMESPACE_ERR, 'prefix is non-null and namespace is null');
+ }
+ if (prefix === 'xml' && namespace !== conventions.NAMESPACE.XML) {
+ throw new DOMException(DOMException.NAMESPACE_ERR, 'prefix is "xml" and namespace is not the XML namespace');
+ }
+ if ((prefix === 'xmlns' || qualifiedName === 'xmlns') && namespace !== conventions.NAMESPACE.XMLNS) {
+ throw new DOMException(
+ DOMException.NAMESPACE_ERR,
+ 'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace'
+ );
+ }
+ if (namespace === conventions.NAMESPACE.XMLNS && prefix !== 'xmlns' && qualifiedName !== 'xmlns') {
+ throw new DOMException(
+ DOMException.NAMESPACE_ERR,
+ 'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"'
+ );
+ }
+ return [namespace, prefix, localName];
+}
+
+/**
+ * Copies properties from one object to another.
+ * It only copies the object's own (not inherited) properties.
+ *
+ * @param {Object} src
+ * The source object from which properties are copied.
+ * @param {Object} dest
+ * The destination object to which properties are copied.
+ */
+function copy(src, dest) {
+ for (var p in src) {
+ if (hasOwn(src, p)) {
+ dest[p] = src[p];
+ }
+ }
+}
+
+/**
+ * Extends a class with the properties and methods of a super class.
+ * It uses a form of prototypal inheritance, and establishes the `constructor` property
+ * correctly(?).
+ *
+ * It is not clear to the current maintainers if this implementation is making sense,
+ * since it creates an intermediate prototype function,
+ * which all properties of `Super` are copied onto using `_copy`.
+ *
+ * @param {Object} Class
+ * The class that is to be extended.
+ * @param {Object} Super
+ * The super class from which properties and methods are inherited.
+ * @private
+ */
+function _extends(Class, Super) {
+ var pt = Class.prototype;
+ if (!(pt instanceof Super)) {
+ function t() {}
+ t.prototype = Super.prototype;
+ t = new t();
+ copy(pt, t);
+ Class.prototype = pt = t;
+ }
+ if (pt.constructor != Class) {
+ if (typeof Class != 'function') {
+ console.error('unknown Class:' + Class);
+ }
+ pt.constructor = Class;
+ }
+}
+
+var NodeType = {};
+var ELEMENT_NODE = (NodeType.ELEMENT_NODE = 1);
+var ATTRIBUTE_NODE = (NodeType.ATTRIBUTE_NODE = 2);
+var TEXT_NODE = (NodeType.TEXT_NODE = 3);
+var CDATA_SECTION_NODE = (NodeType.CDATA_SECTION_NODE = 4);
+var ENTITY_REFERENCE_NODE = (NodeType.ENTITY_REFERENCE_NODE = 5);
+var ENTITY_NODE = (NodeType.ENTITY_NODE = 6);
+var PROCESSING_INSTRUCTION_NODE = (NodeType.PROCESSING_INSTRUCTION_NODE = 7);
+var COMMENT_NODE = (NodeType.COMMENT_NODE = 8);
+var DOCUMENT_NODE = (NodeType.DOCUMENT_NODE = 9);
+var DOCUMENT_TYPE_NODE = (NodeType.DOCUMENT_TYPE_NODE = 10);
+var DOCUMENT_FRAGMENT_NODE = (NodeType.DOCUMENT_FRAGMENT_NODE = 11);
+var NOTATION_NODE = (NodeType.NOTATION_NODE = 12);
+
+var DocumentPosition = conventions.freeze({
+ DOCUMENT_POSITION_DISCONNECTED: 1,
+ DOCUMENT_POSITION_PRECEDING: 2,
+ DOCUMENT_POSITION_FOLLOWING: 4,
+ DOCUMENT_POSITION_CONTAINS: 8,
+ DOCUMENT_POSITION_CONTAINED_BY: 16,
+ DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32,
+});
+
+//helper functions for compareDocumentPosition
+/**
+ * Finds the common ancestor in two parent chains.
+ *
+ * @param {Node[]} a
+ * The first parent chain.
+ * @param {Node[]} b
+ * The second parent chain.
+ * @returns {Node}
+ * The common ancestor node if it exists. If there is no common ancestor, the function will
+ * return `null`.
+ */
+function commonAncestor(a, b) {
+ if (b.length < a.length) return commonAncestor(b, a);
+ var c = null;
+ for (var n in a) {
+ if (a[n] !== b[n]) return c;
+ c = a[n];
+ }
+ return c;
+}
+
+/**
+ * Assigns a unique identifier to a document to ensure consistency while comparing unrelated
+ * nodes.
+ *
+ * @param {Document} doc
+ * The document to which a unique identifier is to be assigned.
+ * @returns {string}
+ * The unique identifier of the document. If the document already had a unique identifier, the
+ * function will return the existing one.
+ */
+function docGUID(doc) {
+ if (!doc.guid) doc.guid = Math.random();
+ return doc.guid;
+}
+//-- end of helper functions
+
+/**
+ * The NodeList interface provides the abstraction of an ordered collection of nodes,
+ * without defining or constraining how this collection is implemented.
+ * NodeList objects in the DOM are live.
+ * The items in the NodeList are accessible via an integral index, starting from 0.
+ * You can also access the items of the NodeList with a `for...of` loop.
+ *
+ * @class NodeList
+ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
+ * @constructs NodeList
+ */
+function NodeList() {}
+NodeList.prototype = {
+ /**
+ * The number of nodes in the list. The range of valid child node indices is 0 to length-1
+ * inclusive.
+ *
+ * @type {number}
+ */
+ length: 0,
+ /**
+ * Returns the item at `index`. If index is greater than or equal to the number of nodes in
+ * the list, this returns null.
+ *
+ * @param index
+ * Unsigned long Index into the collection.
+ * @returns {Node | null}
+ * The node at position `index` in the NodeList,
+ * or null if that is not a valid index.
+ */
+ item: function (index) {
+ return index >= 0 && index < this.length ? this[index] : null;
+ },
+ /**
+ * Returns a string representation of the NodeList.
+ *
+ * Accepts the same `options` object as `XMLSerializer.prototype.serializeToString`
+ * (`requireWellFormed`, `splitCDATASections`, `nodeFilter`). Passing a function is treated as
+ * a legacy `nodeFilter` for backward compatibility.
+ *
+ * @param {Object | function} [options]
+ * @param {boolean} [options.requireWellFormed=false]
+ * @param {boolean} [options.splitCDATASections=true]
+ * @param {function} [options.nodeFilter]
+ * @returns {string}
+ */
+ toString: function (options) {
+ var opts;
+ if (typeof options === 'function') {
+ opts = { requireWellFormed: false, splitCDATASections: true, nodeFilter: options };
+ } else if (!!options) {
+ opts = {
+ requireWellFormed: !!options.requireWellFormed,
+ splitCDATASections: options.splitCDATASections !== false,
+ nodeFilter: options.nodeFilter || null,
+ };
+ } else {
+ opts = { requireWellFormed: false, splitCDATASections: true, nodeFilter: null };
+ }
+ for (var buf = [], i = 0; i < this.length; i++) {
+ serializeToString(this[i], buf, null, opts);
+ }
+ return buf.join('');
+ },
+ /**
+ * Filters the NodeList based on a predicate.
+ *
+ * @param {function(Node): boolean} predicate
+ * - A predicate function to filter the NodeList.
+ * @returns {Node[]}
+ * An array of nodes that satisfy the predicate.
+ * @private
+ */
+ filter: function (predicate) {
+ return Array.prototype.filter.call(this, predicate);
+ },
+ /**
+ * Returns the first index at which a given node can be found in the NodeList, or -1 if it is
+ * not present.
+ *
+ * @param {Node} item
+ * - The Node item to locate in the NodeList.
+ * @returns {number}
+ * The first index of the node in the NodeList; -1 if not found.
+ * @private
+ */
+ indexOf: function (item) {
+ return Array.prototype.indexOf.call(this, item);
+ },
+};
+NodeList.prototype[Symbol.iterator] = function () {
+ var me = this;
+ var index = 0;
+
+ return {
+ next: function () {
+ if (index < me.length) {
+ return {
+ value: me[index++],
+ done: false,
+ };
+ } else {
+ return {
+ done: true,
+ };
+ }
+ },
+ return: function () {
+ return {
+ done: true,
+ };
+ },
+ };
+};
+
+/**
+ * Represents a live collection of nodes that is automatically updated when its associated
+ * document changes.
+ *
+ * @class LiveNodeList
+ * @param {Node} node
+ * The associated node.
+ * @param {function} refresh
+ * The function to refresh the live node list.
+ * @augments NodeList
+ * @constructs LiveNodeList
+ */
+function LiveNodeList(node, refresh) {
+ this._node = node;
+ this._refresh = refresh;
+ _updateLiveList(this);
+}
+/**
+ * Updates the live node list.
+ *
+ * @param {LiveNodeList} list
+ * The live node list to update.
+ * @private
+ */
+function _updateLiveList(list) {
+ var inc = list._node._inc || list._node.ownerDocument._inc;
+ if (list._inc !== inc) {
+ var ls = list._refresh(list._node);
+ __set__(list, 'length', ls.length);
+ if (!list.$$length || ls.length < list.$$length) {
+ for (var i = ls.length; i in list; i++) {
+ if (hasOwn(list, i)) {
+ delete list[i];
+ }
+ }
+ }
+ copy(ls, list);
+ list._inc = inc;
+ }
+}
+/**
+ * Returns the node at position `index` in the LiveNodeList, or null if that is not a valid
+ * index.
+ *
+ * @param {number} i
+ * Index into the collection.
+ * @returns {Node | null}
+ * The node at position `index` in the LiveNodeList, or null if that is not a valid index.
+ */
+LiveNodeList.prototype.item = function (i) {
+ _updateLiveList(this);
+ return this[i] || null;
+};
+
+_extends(LiveNodeList, NodeList);
+
+/**
+ * Objects implementing the NamedNodeMap interface are used to represent collections of nodes
+ * that can be accessed by name.
+ * Note that NamedNodeMap does not inherit from NodeList;
+ * NamedNodeMaps are not maintained in any particular order.
+ * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal
+ * index,
+ * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
+ * and does not imply that the DOM specifies an order to these Nodes.
+ * NamedNodeMap objects in the DOM are live.
+ * used for attributes or DocumentType entities
+ *
+ * This implementation only supports property indices, but does not support named properties,
+ * as specified in the living standard.
+ *
+ * @class NamedNodeMap
+ * @see https://dom.spec.whatwg.org/#interface-namednodemap
+ * @see https://webidl.spec.whatwg.org/#dfn-supported-property-names
+ * @constructs NamedNodeMap
+ */
+function NamedNodeMap() {}
+/**
+ * Returns the index of a node within the list.
+ *
+ * @param {Array} list
+ * The list of nodes.
+ * @param {Node} node
+ * The node to find.
+ * @returns {number}
+ * The index of the node within the list, or -1 if not found.
+ * @private
+ */
+function _findNodeIndex(list, node) {
+ var i = 0;
+ while (i < list.length) {
+ if (list[i] === node) {
+ return i;
+ }
+ i++;
+ }
+}
+/**
+ * Adds a new attribute to the list and updates the owner element of the attribute.
+ *
+ * @param {Element} el
+ * The element which will become the owner of the new attribute.
+ * @param {NamedNodeMap} list
+ * The list to which the new attribute will be added.
+ * @param {Attr} newAttr
+ * The new attribute to be added.
+ * @param {Attr} oldAttr
+ * The old attribute to be replaced, or null if no attribute is to be replaced.
+ * @returns {void}
+ * @private
+ */
+function _addNamedNode(el, list, newAttr, oldAttr) {
+ if (oldAttr) {
+ list[_findNodeIndex(list, oldAttr)] = newAttr;
+ } else {
+ list[list.length] = newAttr;
+ list.length++;
+ }
+ if (el) {
+ newAttr.ownerElement = el;
+ var doc = el.ownerDocument;
+ if (doc) {
+ oldAttr && _onRemoveAttribute(doc, el, oldAttr);
+ _onAddAttribute(doc, el, newAttr);
+ }
+ }
+}
+/**
+ * Removes an attribute from the list and updates the owner element of the attribute.
+ *
+ * @param {Element} el
+ * The element which is the current owner of the attribute.
+ * @param {NamedNodeMap} list
+ * The list from which the attribute will be removed.
+ * @param {Attr} attr
+ * The attribute to be removed.
+ * @returns {void}
+ * @private
+ */
+function _removeNamedNode(el, list, attr) {
+ //console.log('remove attr:'+attr)
+ var i = _findNodeIndex(list, attr);
+ if (i >= 0) {
+ var lastIndex = list.length - 1;
+ while (i <= lastIndex) {
+ list[i] = list[++i];
+ }
+ list.length = lastIndex;
+ if (el) {
+ var doc = el.ownerDocument;
+ if (doc) {
+ _onRemoveAttribute(doc, el, attr);
+ }
+ attr.ownerElement = null;
+ }
+ }
+}
+NamedNodeMap.prototype = {
+ length: 0,
+ item: NodeList.prototype.item,
+
+ /**
+ * Get an attribute by name. Note: Name is in lower case in case of HTML namespace and
+ * document.
+ *
+ * @param {string} localName
+ * The local name of the attribute.
+ * @returns {Attr | null}
+ * The attribute with the given local name, or null if no such attribute exists.
+ * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
+ */
+ getNamedItem: function (localName) {
+ if (this._ownerElement && this._ownerElement._isInHTMLDocumentAndNamespace()) {
+ localName = localName.toLowerCase();
+ }
+ var i = 0;
+ while (i < this.length) {
+ var attr = this[i];
+ if (attr.nodeName === localName) {
+ return attr;
+ }
+ i++;
+ }
+ return null;
+ },
+
+ /**
+ * Set an attribute.
+ *
+ * @param {Attr} attr
+ * The attribute to set.
+ * @returns {Attr | null}
+ * The old attribute with the same local name and namespace URI as the new one, or null if no
+ * such attribute exists.
+ * @throws {DOMException}
+ * With code:
+ * - {@link INUSE_ATTRIBUTE_ERR} - If the attribute is already an attribute of another
+ * element.
+ * @see https://dom.spec.whatwg.org/#concept-element-attributes-set
+ */
+ setNamedItem: function (attr) {
+ var el = attr.ownerElement;
+ if (el && el !== this._ownerElement) {
+ throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);
+ }
+ var oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
+ if (oldAttr === attr) {
+ return attr;
+ }
+ _addNamedNode(this._ownerElement, this, attr, oldAttr);
+ return oldAttr;
+ },
+
+ /**
+ * Set an attribute, replacing an existing attribute with the same local name and namespace
+ * URI if one exists.
+ *
+ * @param {Attr} attr
+ * The attribute to set.
+ * @returns {Attr | null}
+ * The old attribute with the same local name and namespace URI as the new one, or null if no
+ * such attribute exists.
+ * @throws {DOMException}
+ * Throws a DOMException with the name "InUseAttributeError" if the attribute is already an
+ * attribute of another element.
+ * @see https://dom.spec.whatwg.org/#concept-element-attributes-set
+ */
+ setNamedItemNS: function (attr) {
+ return this.setNamedItem(attr);
+ },
+
+ /**
+ * Removes an attribute specified by the local name.
+ *
+ * @param {string} localName
+ * The local name of the attribute to be removed.
+ * @returns {Attr}
+ * The attribute node that was removed.
+ * @throws {DOMException}
+ * With code:
+ * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given name is found.
+ * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem
+ * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name
+ */
+ removeNamedItem: function (localName) {
+ var attr = this.getNamedItem(localName);
+ if (!attr) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, localName);
+ }
+ _removeNamedNode(this._ownerElement, this, attr);
+ return attr;
+ },
+
+ /**
+ * Removes an attribute specified by the namespace and local name.
+ *
+ * @param {string | null} namespaceURI
+ * The namespace URI of the attribute to be removed.
+ * @param {string} localName
+ * The local name of the attribute to be removed.
+ * @returns {Attr}
+ * The attribute node that was removed.
+ * @throws {DOMException}
+ * With code:
+ * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given namespace URI and local
+ * name is found.
+ * @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns
+ * @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace
+ */
+ removeNamedItemNS: function (namespaceURI, localName) {
+ var attr = this.getNamedItemNS(namespaceURI, localName);
+ if (!attr) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, namespaceURI ? namespaceURI + ' : ' + localName : localName);
+ }
+ _removeNamedNode(this._ownerElement, this, attr);
+ return attr;
+ },
+
+ /**
+ * Get an attribute by namespace and local name.
+ *
+ * @param {string | null} namespaceURI
+ * The namespace URI of the attribute.
+ * @param {string} localName
+ * The local name of the attribute.
+ * @returns {Attr | null}
+ * The attribute with the given namespace URI and local name, or null if no such attribute
+ * exists.
+ * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
+ */
+ getNamedItemNS: function (namespaceURI, localName) {
+ if (!namespaceURI) {
+ namespaceURI = null;
+ }
+ var i = 0;
+ while (i < this.length) {
+ var node = this[i];
+ if (node.localName === localName && node.namespaceURI === namespaceURI) {
+ return node;
+ }
+ i++;
+ }
+ return null;
+ },
+};
+NamedNodeMap.prototype[Symbol.iterator] = function () {
+ var me = this;
+ var index = 0;
+
+ return {
+ next: function () {
+ if (index < me.length) {
+ return {
+ value: me[index++],
+ done: false,
+ };
+ } else {
+ return {
+ done: true,
+ };
+ }
+ },
+ return: function () {
+ return {
+ done: true,
+ };
+ },
+ };
+};
+
+/**
+ * The DOMImplementation interface provides a number of methods for performing operations that
+ * are independent of any particular instance of the document object model.
+ *
+ * The DOMImplementation interface represents an object providing methods which are not
+ * dependent on any particular document.
+ * Such an object is returned by the `Document.implementation` property.
+ *
+ * **The individual methods describe the differences compared to the specs**.
+ *
+ * @class DOMImplementation
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core
+ * (Initial)
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
+ * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
+ * @constructs DOMImplementation
+ */
+function DOMImplementation() {}
+
+DOMImplementation.prototype = {
+ /**
+ * Test if the DOM implementation implements a specific feature and version, as specified in
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMFeatures DOM Features}.
+ *
+ * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given
+ * feature is supported. The different implementations fairly diverged in what kind of
+ * features were reported. The latest version of the spec settled to force this method to
+ * always return true, where the functionality was accurate and in use.
+ *
+ * @deprecated
+ * It is deprecated and modern browsers return true in all cases.
+ * @function DOMImplementation#hasFeature
+ * @param {string} feature
+ * The name of the feature to test.
+ * @param {string} [version]
+ * This is the version number of the feature to test.
+ * @returns {boolean}
+ * Always returns true.
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
+ * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-5CED94D7 DOM Level 3 Core
+ */
+ hasFeature: function (feature, version) {
+ return true;
+ },
+ /**
+ * Creates a DOM Document object of the specified type with its document element. Note that
+ * based on the {@link DocumentType}
+ * given to create the document, the implementation may instantiate specialized
+ * {@link Document} objects that support additional features than the "Core", such as "HTML"
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#DOM2HTML DOM Level 2 HTML}.
+ * On the other hand, setting the {@link DocumentType} after the document was created makes
+ * this very unlikely to happen. Alternatively, specialized {@link Document} creation methods,
+ * such as createHTMLDocument
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#DOM2HTML DOM Level 2 HTML},
+ * can be used to obtain specific types of {@link Document} objects.
+ *
+ * __It behaves slightly different from the description in the living standard__:
+ * - There is no interface/class `XMLDocument`, it returns a `Document`
+ * instance (with it's `type` set to `'xml'`).
+ * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
+ *
+ * @function DOMImplementation.createDocument
+ * @param {string | null} namespaceURI
+ * The
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-namespaceURI namespace URI}
+ * of the document element to create or null.
+ * @param {string | null} qualifiedName
+ * The
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-qualifiedname qualified name}
+ * of the document element to be created or null.
+ * @param {DocumentType | null} [doctype=null]
+ * The type of document to be created or null. When doctype is not null, its
+ * {@link Node#ownerDocument} attribute is set to the document being created. Default is
+ * `null`
+ * @returns {Document}
+ * A new {@link Document} object with its document element. If the NamespaceURI,
+ * qualifiedName, and doctype are null, the returned {@link Document} is empty with no
+ * document element.
+ * @throws {DOMException}
+ * With code:
+ *
+ * - `INVALID_CHARACTER_ERR`: Raised if the specified qualified name is not an XML name
+ * according to {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#XML XML 1.0}.
+ * - `NAMESPACE_ERR`: Raised if the qualifiedName is malformed, if the qualifiedName has a
+ * prefix and the namespaceURI is null, or if the qualifiedName is null and the namespaceURI
+ * is different from null, or if the qualifiedName has a prefix that is "xml" and the
+ * namespaceURI is different from "{@link http://www.w3.org/XML/1998/namespace}"
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#Namespaces XML Namespaces},
+ * or if the DOM implementation does not support the "XML" feature but a non-null namespace
+ * URI was provided, since namespaces were defined by XML.
+ * - `WRONG_DOCUMENT_ERR`: Raised if doctype has already been used with a different document
+ * or was created from a different implementation.
+ * - `NOT_SUPPORTED_ERR`: May be raised if the implementation does not support the feature
+ * "XML" and the language exposed through the Document does not support XML Namespaces (such
+ * as {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#HTML40 HTML 4.01}).
+ * @since DOM Level 2.
+ * @see {@link #createHTMLDocument}
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Living Standard
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-2-Core-DOM-createDocument DOM
+ * Level 3 Core
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM
+ * Level 2 Core (initial)
+ */
+ createDocument: function (namespaceURI, qualifiedName, doctype) {
+ var contentType = MIME_TYPE.XML_APPLICATION;
+ if (namespaceURI === NAMESPACE.HTML) {
+ contentType = MIME_TYPE.XML_XHTML_APPLICATION;
+ } else if (namespaceURI === NAMESPACE.SVG) {
+ contentType = MIME_TYPE.XML_SVG_IMAGE;
+ }
+ var doc = new Document(PDC, { contentType: contentType });
+ doc.implementation = this;
+ doc.childNodes = new NodeList();
+ doc.doctype = doctype || null;
+ if (doctype) {
+ doc.appendChild(doctype);
+ }
+ if (qualifiedName) {
+ var root = doc.createElementNS(namespaceURI, qualifiedName);
+ doc.appendChild(root);
+ }
+ return doc;
+ },
+ /**
+ * Creates an empty DocumentType node. Entity declarations and notations are not made
+ * available. Entity reference expansions and default attribute additions do not occur.
+ *
+ * **This behavior is slightly different from the one in the specs**:
+ * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
+ * - `publicId` and `systemId` contain the raw data including any possible quotes,
+ * so they can always be serialized back to the original value
+ * - `internalSubset` contains the raw string between `[` and `]` if present,
+ * but is not parsed or validated in any form.
+ *
+ * @function DOMImplementation#createDocumentType
+ * @param {string} qualifiedName
+ * The {@link https://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-qualifiedname qualified
+ * name} of the document type to be created.
+ * @param {string} [publicId]
+ * The external subset public identifier. Stored verbatim including surrounding quotes.
+ * When serialized with `requireWellFormed: true`, the serializer throws `InvalidStateError`
+ * if the value is non-empty and does not match the XML `PubidLiteral` production
+ * (W3C DOM Parsing §3.2.1.3; XML 1.0 production [12]). Creation-time validation is not
+ * enforced — deferred to a future breaking release.
+ * @param {string} [systemId]
+ * The external subset system identifier. Stored verbatim including surrounding quotes.
+ * When serialized with `requireWellFormed: true`, the serializer throws `InvalidStateError`
+ * if the value is non-empty and does not match the XML `SystemLiteral` production
+ * (W3C DOM Parsing §3.2.1.3; XML 1.0 production [11]). Creation-time validation is not
+ * enforced — deferred to a future breaking release.
+ * @param {string} [internalSubset]
+ * The internal subset or an empty string if it is not present. Stored verbatim.
+ * When serialized with `requireWellFormed: true`, the serializer throws `InvalidStateError`
+ * if the value contains `"]>"`. Creation-time validation is not enforced.
+ * @returns {DocumentType}
+ * A new {@link DocumentType} node with {@link Node#ownerDocument} set to null.
+ * @throws {DOMException}
+ * With code:
+ *
+ * - `INVALID_CHARACTER_ERR`: Raised if the specified qualified name is not an XML name
+ * according to {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#XML XML 1.0}.
+ * - `NAMESPACE_ERR`: Raised if the qualifiedName is malformed.
+ * - `NOT_SUPPORTED_ERR`: May be raised if the implementation does not support the feature
+ * "XML" and the language exposed through the Document does not support XML Namespaces (such
+ * as {@link https://www.w3.org/TR/DOM-Level-3-Core/references.html#HTML40 HTML 4.01}).
+ * @since DOM Level 2.
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType
+ * MDN
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living
+ * Standard
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Level-3-Core-DOM-createDocType DOM
+ * Level 3 Core
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM
+ * Level 2 Core
+ * @see https://github.com/xmldom/xmldom/blob/master/CHANGELOG.md#050
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-Core-DocType-internalSubset
+ * @prettierignore
+ */
+ createDocumentType: function (qualifiedName, publicId, systemId, internalSubset) {
+ validateQualifiedName(qualifiedName);
+ var node = new DocumentType(PDC);
+ node.name = qualifiedName;
+ node.nodeName = qualifiedName;
+ node.publicId = publicId || '';
+ node.systemId = systemId || '';
+ node.internalSubset = internalSubset || '';
+ node.childNodes = new NodeList();
+
+ return node;
+ },
+ /**
+ * Returns an HTML document, that might already have a basic DOM structure.
+ *
+ * __It behaves slightly different from the description in the living standard__:
+ * - If the first argument is `false` no initial nodes are added (steps 3-7 in the specs are
+ * omitted)
+ * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
+ *
+ * @param {string | false} [title]
+ * A string containing the title to give the new HTML document.
+ * @returns {Document}
+ * The HTML document.
+ * @since WHATWG Living Standard.
+ * @see {@link #createDocument}
+ * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
+ * @see https://dom.spec.whatwg.org/#html-document
+ */
+ createHTMLDocument: function (title) {
+ var doc = new Document(PDC, { contentType: MIME_TYPE.HTML });
+ doc.implementation = this;
+ doc.childNodes = new NodeList();
+ if (title !== false) {
+ doc.doctype = this.createDocumentType('html');
+ doc.doctype.ownerDocument = doc;
+ doc.appendChild(doc.doctype);
+ var htmlNode = doc.createElement('html');
+ doc.appendChild(htmlNode);
+ var headNode = doc.createElement('head');
+ htmlNode.appendChild(headNode);
+ if (typeof title === 'string') {
+ var titleNode = doc.createElement('title');
+ titleNode.appendChild(doc.createTextNode(title));
+ headNode.appendChild(titleNode);
+ }
+ htmlNode.appendChild(doc.createElement('body'));
+ }
+ return doc;
+ },
+};
+
+/**
+ * The DOM Node interface is an abstract base class upon which many other DOM API objects are
+ * based, thus letting those object types to be used similarly and often interchangeably. As an
+ * abstract class, there is no such thing as a plain Node object. All objects that implement
+ * Node functionality are based on one of its subclasses. Most notable are Document, Element,
+ * and DocumentFragment.
+ *
+ * In addition, every kind of DOM node is represented by an interface based on Node. These
+ * include Attr, CharacterData (which Text, Comment, CDATASection and ProcessingInstruction are
+ * all based on), and DocumentType.
+ *
+ * In some cases, a particular feature of the base Node interface may not apply to one of its
+ * child interfaces; in that case, the inheriting node may return null or throw an exception,
+ * depending on circumstances. For example, attempting to add children to a node type that
+ * cannot have children will throw an exception.
+ *
+ * **This behavior is slightly different from the in the specs**:
+ * - unimplemented interfaces: `EventTarget`
+ *
+ * @class
+ * @abstract
+ * @param {Symbol} symbol
+ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
+ * @see https://dom.spec.whatwg.org/#node
+ * @prettierignore
+ */
+function Node(symbol) {
+ checkSymbol(symbol);
+}
+
+Node.prototype = {
+ /**
+ * The first child of this node.
+ *
+ * @type {Node | null}
+ */
+ firstChild: null,
+ /**
+ * The last child of this node.
+ *
+ * @type {Node | null}
+ */
+ lastChild: null,
+ /**
+ * The previous sibling of this node.
+ *
+ * @type {Node | null}
+ */
+ previousSibling: null,
+ /**
+ * The next sibling of this node.
+ *
+ * @type {Node | null}
+ */
+ nextSibling: null,
+ /**
+ * The parent node of this node.
+ *
+ * @type {Node | null}
+ */
+ parentNode: null,
+ /**
+ * The parent element of this node.
+ *
+ * @type {Element | null}
+ */
+ get parentElement() {
+ return this.parentNode && this.parentNode.nodeType === this.ELEMENT_NODE ? this.parentNode : null;
+ },
+ /**
+ * The child nodes of this node.
+ *
+ * @type {NodeList}
+ */
+ childNodes: null,
+ /**
+ * The document object associated with this node.
+ *
+ * @type {Document | null}
+ */
+ ownerDocument: null,
+ /**
+ * The value of this node.
+ *
+ * @type {string | null}
+ */
+ nodeValue: null,
+ /**
+ * The namespace URI of this node.
+ *
+ * @type {string | null}
+ */
+ namespaceURI: null,
+ /**
+ * The prefix of the namespace for this node.
+ *
+ * @type {string | null}
+ */
+ prefix: null,
+ /**
+ * The local part of the qualified name of this node.
+ *
+ * @type {string | null}
+ */
+ localName: null,
+ /**
+ * The baseURI is currently always `about:blank`,
+ * since that's what happens when you create a document from scratch.
+ *
+ * @type {'about:blank'}
+ */
+ baseURI: 'about:blank',
+ /**
+ * Is true if this node is part of a document.
+ *
+ * @type {boolean}
+ */
+ get isConnected() {
+ var rootNode = this.getRootNode();
+ return rootNode && rootNode.nodeType === rootNode.DOCUMENT_NODE;
+ },
+ /**
+ * Checks whether `other` is an inclusive descendant of this node.
+ *
+ * @param {Node | null | undefined} other
+ * The node to check.
+ * @returns {boolean}
+ * True if `other` is an inclusive descendant of this node; false otherwise.
+ * @see https://dom.spec.whatwg.org/#dom-node-contains
+ */
+ contains: function (other) {
+ if (!other) return false;
+ var parent = other;
+ do {
+ if (this === parent) return true;
+ parent = parent.parentNode;
+ } while (parent);
+ return false;
+ },
+ /**
+ * @typedef GetRootNodeOptions
+ * @property {boolean} [composed=false]
+ */
+ /**
+ * Searches for the root node of this node.
+ *
+ * **This behavior is slightly different from the in the specs**:
+ * - ignores `options.composed`, since `ShadowRoot`s are unsupported, always returns root.
+ *
+ * @param {GetRootNodeOptions} [options]
+ * @returns {Node}
+ * Root node.
+ * @see https://dom.spec.whatwg.org/#dom-node-getrootnode
+ * @see https://dom.spec.whatwg.org/#concept-shadow-including-root
+ */
+ getRootNode: function (options) {
+ var parent = this;
+ do {
+ if (!parent.parentNode) {
+ return parent;
+ }
+ parent = parent.parentNode;
+ } while (parent);
+ },
+ /**
+ * Checks whether the given node is equal to this node.
+ *
+ * Two nodes are equal when they have the same type, defining characteristics (for the type),
+ * and the same childNodes. The comparison is iterative to avoid stack overflows on
+ * deeply-nested trees. Attribute nodes of each Element pair are also pushed onto the stack
+ * and compared the same way.
+ *
+ * @param {Node} [otherNode]
+ * @returns {boolean}
+ * @see https://dom.spec.whatwg.org/#concept-node-equals
+ * @see ../docs/walk-dom.md.
+ */
+ isEqualNode: function (otherNode) {
+ if (!otherNode) return false;
+
+ // Use an explicit {node, other} pair stack to avoid call-stack overflow on deep trees.
+ // walkDOM cannot be used here — parallel two-tree traversal requires pairing
+ // corresponding nodes at each step across both trees simultaneously.
+ var stack = [{ node: this, other: otherNode }];
+ while (stack.length > 0) {
+ var pair = stack.pop();
+ var node = pair.node;
+ var other = pair.other;
+
+ if (node.nodeType !== other.nodeType) return false;
+
+ switch (node.nodeType) {
+ case node.DOCUMENT_TYPE_NODE:
+ if (node.name !== other.name) return false;
+ if (node.publicId !== other.publicId) return false;
+ if (node.systemId !== other.systemId) return false;
+ break;
+ case node.ELEMENT_NODE:
+ if (node.namespaceURI !== other.namespaceURI) return false;
+ if (node.prefix !== other.prefix) return false;
+ if (node.localName !== other.localName) return false;
+ if (node.attributes.length !== other.attributes.length) return false;
+ for (var i = 0; i < node.attributes.length; i++) {
+ var attr = node.attributes.item(i);
+ var otherAttr = other.getAttributeNodeNS(attr.namespaceURI, attr.localName);
+ if (!otherAttr) return false;
+ stack.push({ node: attr, other: otherAttr });
+ }
+ break;
+ case node.ATTRIBUTE_NODE:
+ if (node.namespaceURI !== other.namespaceURI) return false;
+ if (node.localName !== other.localName) return false;
+ if (node.value !== other.value) return false;
+ break;
+ case node.PROCESSING_INSTRUCTION_NODE:
+ if (node.target !== other.target || node.data !== other.data) return false;
+ break;
+ case node.TEXT_NODE:
+ case node.CDATA_SECTION_NODE:
+ case node.COMMENT_NODE:
+ if (node.data !== other.data) return false;
+ break;
+ }
+
+ if (node.childNodes.length !== other.childNodes.length) return false;
+
+ // Push children in reverse order so index 0 is processed first (LIFO).
+ for (var i = node.childNodes.length - 1; i >= 0; i--) {
+ stack.push({ node: node.childNodes[i], other: other.childNodes[i] });
+ }
+ }
+
+ return true;
+ },
+ /**
+ * Checks whether or not the given node is this node.
+ *
+ * @param {Node} [otherNode]
+ */
+ isSameNode: function (otherNode) {
+ return this === otherNode;
+ },
+ /**
+ * Inserts a node before a reference node as a child of this node.
+ *
+ * @param {Node} newChild
+ * The new child node to be inserted.
+ * @param {Node | null} refChild
+ * The reference node before which newChild will be inserted.
+ * @returns {Node}
+ * The new child node successfully inserted.
+ * @throws {DOMException}
+ * Throws a DOMException if inserting the node would result in a DOM tree that is not
+ * well-formed, or if `child` is provided but is not a child of `parent`.
+ * See {@link _insertBefore} for more details.
+ * @since Modified in DOM L2
+ */
+ insertBefore: function (newChild, refChild) {
+ return _insertBefore(this, newChild, refChild);
+ },
+ /**
+ * Replaces an old child node with a new child node within this node.
+ *
+ * @param {Node} newChild
+ * The new node that is to replace the old node.
+ * If it already exists in the DOM, it is removed from its original position.
+ * @param {Node} oldChild
+ * The existing child node to be replaced.
+ * @returns {Node}
+ * Returns the replaced child node.
+ * @throws {DOMException}
+ * Throws a DOMException if replacing the node would result in a DOM tree that is not
+ * well-formed, or if `oldChild` is not a child of `this`.
+ * This can also occur if the pre-replacement validity assertion fails.
+ * See {@link _insertBefore}, {@link Node.removeChild}, and
+ * {@link assertPreReplacementValidityInDocument} for more details.
+ * @see https://dom.spec.whatwg.org/#concept-node-replace
+ */
+ replaceChild: function (newChild, oldChild) {
+ _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
+ if (oldChild) {
+ this.removeChild(oldChild);
+ }
+ },
+ /**
+ * Removes an existing child node from this node.
+ *
+ * @param {Node} oldChild
+ * The child node to be removed.
+ * @returns {Node}
+ * Returns the removed child node.
+ * @throws {DOMException}
+ * Throws a DOMException if `oldChild` is not a child of `this`.
+ * See {@link _removeChild} for more details.
+ */
+ removeChild: function (oldChild) {
+ return _removeChild(this, oldChild);
+ },
+ /**
+ * Appends a child node to this node.
+ *
+ * @param {Node} newChild
+ * The child node to be appended to this node.
+ * If it already exists in the DOM, it is removed from its original position.
+ * @returns {Node}
+ * Returns the appended child node.
+ * @throws {DOMException}
+ * Throws a DOMException if appending the node would result in a DOM tree that is not
+ * well-formed, or if `newChild` is not a valid Node.
+ * See {@link insertBefore} for more details.
+ */
+ appendChild: function (newChild) {
+ return this.insertBefore(newChild, null);
+ },
+ /**
+ * Determines whether this node has any child nodes.
+ *
+ * @returns {boolean}
+ * Returns true if this node has any child nodes, and false otherwise.
+ */
+ hasChildNodes: function () {
+ return this.firstChild != null;
+ },
+ /**
+ * Creates a copy of the calling node.
+ *
+ * @param {boolean} deep
+ * If true, the contents of the node are recursively copied.
+ * If false, only the node itself (and its attributes, if it is an element) are copied.
+ * @returns {Node}
+ * Returns the newly created copy of the node.
+ * @throws {DOMException}
+ * May throw a DOMException if operations within {@link Element#setAttributeNode} or
+ * {@link Node#appendChild} (which are potentially invoked in this method) do not meet their
+ * specific constraints.
+ * @see {@link cloneNode}
+ */
+ cloneNode: function (deep) {
+ return cloneNode(this.ownerDocument || this, this, deep);
+ },
+ /**
+ * Puts the specified node and all of its subtree into a "normalized" form. In a normalized
+ * subtree, no text nodes in the subtree are empty and there are no adjacent text nodes.
+ *
+ * Specifically, this method merges any adjacent text nodes (i.e., nodes for which `nodeType`
+ * is `TEXT_NODE`) into a single node with the combined data. It also removes any empty text
+ * nodes.
+ *
+ * This method iterativly traverses all child nodes to normalize all descendent nodes within
+ * the subtree.
+ *
+ * @throws {DOMException}
+ * May throw a DOMException if operations within removeChild or appendData (which are
+ * potentially invoked in this method) do not meet their specific constraints.
+ * @since Modified in DOM Level 2
+ * @see {@link Node.removeChild}
+ * @see {@link CharacterData.appendData}
+ * @see ../docs/walk-dom.md.
+ */
+ normalize: function () {
+ walkDOM(this, null, {
+ enter: function (node) {
+ // Merge adjacent text children of node before walkDOM schedules them.
+ // walkDOM reads lastChild/previousSibling after enter returns, so the
+ // surviving post-merge children are what it descends into.
+ var child = node.firstChild;
+ while (child) {
+ var next = child.nextSibling;
+ if (next !== null && next.nodeType === TEXT_NODE && child.nodeType === TEXT_NODE) {
+ node.removeChild(next);
+ child.appendData(next.data);
+ // Do not advance child: re-check new nextSibling for another text run
+ } else {
+ child = next;
+ }
+ }
+ return true; // descend into surviving children
+ },
+ });
+ },
+ /**
+ * Checks whether the DOM implementation implements a specific feature and its version.
+ *
+ * @deprecated
+ * Since `DOMImplementation.hasFeature` is deprecated and always returns true.
+ * @param {string} feature
+ * The package name of the feature to test. This is the same name that can be passed to the
+ * method `hasFeature` on `DOMImplementation`.
+ * @param {string} version
+ * This is the version number of the package name to test.
+ * @returns {boolean}
+ * Returns true in all cases in the current implementation.
+ * @since Introduced in DOM Level 2
+ * @see {@link DOMImplementation.hasFeature}
+ */
+ isSupported: function (feature, version) {
+ return this.ownerDocument.implementation.hasFeature(feature, version);
+ },
+ /**
+ * Look up the prefix associated to the given namespace URI, starting from this node.
+ * **The default namespace declarations are ignored by this method.**
+ * See Namespace Prefix Lookup for details on the algorithm used by this method.
+ *
+ * **This behavior is different from the in the specs**:
+ * - no node type specific handling
+ * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes
+ *
+ * @param {string | null} namespaceURI
+ * The namespace URI for which to find the associated prefix.
+ * @returns {string | null}
+ * The associated prefix, if found; otherwise, null.
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo
+ * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
+ * @see https://github.com/xmldom/xmldom/issues/322
+ * @prettierignore
+ */
+ lookupPrefix: function (namespaceURI) {
+ var el = this;
+ while (el) {
+ var map = el._nsMap;
+ //console.dir(map)
+ if (map) {
+ for (var n in map) {
+ if (hasOwn(map, n) && map[n] === namespaceURI) {
+ return n;
+ }
+ }
+ }
+ el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
+ }
+ return null;
+ },
+ /**
+ * This function is used to look up the namespace URI associated with the given prefix,
+ * starting from this node.
+ *
+ * **This behavior is different from the in the specs**:
+ * - no node type specific handling
+ * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes
+ *
+ * @param {string | null} prefix
+ * The prefix for which to find the associated namespace URI.
+ * @returns {string | null}
+ * The associated namespace URI, if found; otherwise, null.
+ * @since DOM Level 3
+ * @see https://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespaceURI
+ * @prettierignore
+ */
+ lookupNamespaceURI: function (prefix) {
+ var el = this;
+ while (el) {
+ var map = el._nsMap;
+ //console.dir(map)
+ if (map) {
+ if (hasOwn(map, prefix)) {
+ return map[prefix];
+ }
+ }
+ el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
+ }
+ return null;
+ },
+ /**
+ * Determines whether the given namespace URI is the default namespace.
+ *
+ * The function works by looking up the prefix associated with the given namespace URI. If no
+ * prefix is found (i.e., the namespace URI is not registered in the namespace map of this
+ * node or any of its ancestors), it returns `true`, implying the namespace URI is considered
+ * the default.
+ *
+ * **This behavior is different from the in the specs**:
+ * - no node type specific handling
+ * - uses the internal attribute _nsMap for resolving namespaces that is updated when changing attributes
+ *
+ * @param {string | null} namespaceURI
+ * The namespace URI to be checked.
+ * @returns {boolean}
+ * Returns true if the given namespace URI is the default namespace, false otherwise.
+ * @since DOM Level 3
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isDefaultNamespace
+ * @see https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace
+ * @prettierignore
+ */
+ isDefaultNamespace: function (namespaceURI) {
+ var prefix = this.lookupPrefix(namespaceURI);
+ return prefix == null;
+ },
+ /**
+ * Compares the reference node with a node with regard to their position in the document and
+ * according to the document order.
+ *
+ * @param {Node} other
+ * The node to compare the reference node to.
+ * @returns {number}
+ * Returns how the node is positioned relatively to the reference node according to the
+ * bitmask. 0 if reference node and given node are the same.
+ * @since DOM Level 3
+ * @see https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-compare
+ * @see https://dom.spec.whatwg.org/#dom-node-comparedocumentposition
+ */
+ compareDocumentPosition: function (other) {
+ if (this === other) return 0;
+ var node1 = other;
+ var node2 = this;
+ var attr1 = null;
+ var attr2 = null;
+ if (node1 instanceof Attr) {
+ attr1 = node1;
+ node1 = attr1.ownerElement;
+ }
+ if (node2 instanceof Attr) {
+ attr2 = node2;
+ node2 = attr2.ownerElement;
+ if (attr1 && node1 && node2 === node1) {
+ for (var i = 0, attr; (attr = node2.attributes[i]); i++) {
+ if (attr === attr1)
+ return DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + DocumentPosition.DOCUMENT_POSITION_PRECEDING;
+ if (attr === attr2)
+ return DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
+ }
+ }
+ }
+ if (!node1 || !node2 || node2.ownerDocument !== node1.ownerDocument) {
+ return (
+ DocumentPosition.DOCUMENT_POSITION_DISCONNECTED +
+ DocumentPosition.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +
+ (docGUID(node2.ownerDocument) > docGUID(node1.ownerDocument)
+ ? DocumentPosition.DOCUMENT_POSITION_FOLLOWING
+ : DocumentPosition.DOCUMENT_POSITION_PRECEDING)
+ );
+ }
+ if (attr2 && node1 === node2) {
+ return DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;
+ }
+ if (attr1 && node1 === node2) {
+ return DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
+ }
+
+ var chain1 = [];
+ var ancestor1 = node1.parentNode;
+ while (ancestor1) {
+ if (!attr2 && ancestor1 === node2) {
+ return DocumentPosition.DOCUMENT_POSITION_CONTAINED_BY + DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
+ }
+ chain1.push(ancestor1);
+ ancestor1 = ancestor1.parentNode;
+ }
+ chain1.reverse();
+
+ var chain2 = [];
+ var ancestor2 = node2.parentNode;
+ while (ancestor2) {
+ if (!attr1 && ancestor2 === node1) {
+ return DocumentPosition.DOCUMENT_POSITION_CONTAINS + DocumentPosition.DOCUMENT_POSITION_PRECEDING;
+ }
+ chain2.push(ancestor2);
+ ancestor2 = ancestor2.parentNode;
+ }
+ chain2.reverse();
+
+ var ca = commonAncestor(chain1, chain2);
+ for (var n in ca.childNodes) {
+ var child = ca.childNodes[n];
+ if (child === node2) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
+ if (child === node1) return DocumentPosition.DOCUMENT_POSITION_PRECEDING;
+ if (chain2.indexOf(child) >= 0) return DocumentPosition.DOCUMENT_POSITION_FOLLOWING;
+ if (chain1.indexOf(child) >= 0) return DocumentPosition.DOCUMENT_POSITION_PRECEDING;
+ }
+ return 0;
+ },
+};
+
+/**
+ * Encodes special XML characters to their corresponding entities.
+ *
+ * @param {string} c
+ * The character to be encoded.
+ * @returns {string}
+ * The encoded character.
+ * @private
+ */
+function _xmlEncoder(c) {
+ return (
+ (c == '<' && '<') || (c == '>' && '>') || (c == '&' && '&') || (c == '"' && '"') || '' + c.charCodeAt() + ';'
+ );
+}
+
+copy(NodeType, Node);
+copy(NodeType, Node.prototype);
+copy(DocumentPosition, Node);
+copy(DocumentPosition, Node.prototype);
+
+/**
+ * Visits every node in the subtree rooted at `node` in depth-first pre-order.
+ *
+ * Delegates to {@link walkDOM} for traversal. The `callback` is called on each node;
+ * if it returns a truthy value, traversal stops immediately.
+ *
+ * @param {Node} node
+ * Root of the subtree to visit.
+ * @param {function(Node): *} callback
+ * Called for each node. A truthy return value stops traversal early.
+ */
+function _visitNode(node, callback) {
+ walkDOM(node, null, {
+ enter: function (n) {
+ return callback(n) ? walkDOM.STOP : true;
+ },
+ });
+}
+
+/**
+ * Depth-first pre/post-order DOM tree walker.
+ *
+ * Visits every node in the subtree rooted at `node`. For each node:
+ *
+ * 1. Calls `callbacks.enter(node, context)` before descending into the node's children. The
+ * return value becomes the `context` passed to each child's `enter` call and to the matching
+ * `exit` call.
+ * 2. If `enter` returns `null` or `undefined`, the node's children are skipped;
+ * sibling traversal continues normally.
+ * 3. If `enter` returns `walkDOM.STOP`, the entire traversal is aborted immediately — no
+ * further `enter` or `exit` calls are made.
+ * 4. `lastChild` and `previousSibling` are read **after** `enter` returns, so `enter` may
+ * safely modify the node's own child list before the walker descends. Modifying siblings of
+ * the current node or any other part of the tree produces unpredictable results: nodes already
+ * queued on the stack are visited regardless of DOM changes, and newly inserted nodes outside
+ * the current child list are never visited.
+ * 5. Calls `callbacks.exit(node, context)` (if provided) after all of a node's children have
+ * been visited, passing the same `context` that `enter`
+ * returned for that node.
+ *
+ * This implementation uses an explicit stack and does not recurse — it is safe on arbitrarily
+ * deep trees.
+ *
+ * @param {Node} node
+ * Root of the subtree to walk.
+ * @param {*} context
+ * Initial context value passed to the root node's `enter`.
+ * @param {{ enter: function(Node, *): *, exit?: function(Node, *): void }} callbacks
+ * @returns {void | walkDOM.STOP}
+ * @see ../docs/walk-dom.md.
+ */
+function walkDOM(node, context, callbacks) {
+ // Each stack frame is {node, context, phase}:
+ // walkDOM.ENTER — call enter, then push children
+ // walkDOM.EXIT — call exit
+ var stack = [{ node: node, context: context, phase: walkDOM.ENTER }];
+ while (stack.length > 0) {
+ var frame = stack.pop();
+ if (frame.phase === walkDOM.ENTER) {
+ var childContext = callbacks.enter(frame.node, frame.context);
+ if (childContext === walkDOM.STOP) {
+ return walkDOM.STOP;
+ }
+ // Push exit frame before children so it fires after all children are processed (Last In First Out)
+ stack.push({ node: frame.node, context: childContext, phase: walkDOM.EXIT });
+ if (childContext === null || childContext === undefined) {
+ continue; // skip children
+ }
+ // lastChild is read after enter returns, so enter may modify the child list.
+ var child = frame.node.lastChild;
+ // Traverse from lastChild backwards so that pushing onto the stack
+ // naturally yields firstChild on top (processed first).
+ while (child) {
+ stack.push({ node: child, context: childContext, phase: walkDOM.ENTER });
+ child = child.previousSibling;
+ }
+ } else {
+ // frame.phase === walkDOM.EXIT
+ if (callbacks.exit) {
+ callbacks.exit(frame.node, frame.context);
+ }
+ }
+ }
+}
+
+/**
+ * Sentinel value returned from a `walkDOM` `enter` callback to abort the entire traversal
+ * immediately.
+ *
+ * @type {symbol}
+ */
+walkDOM.STOP = Symbol('walkDOM.STOP');
+/**
+ * Phase constant for a stack frame that has not yet been visited.
+ * The `enter` callback is called and children are scheduled.
+ *
+ * @type {number}
+ */
+walkDOM.ENTER = 0;
+/**
+ * Phase constant for a stack frame whose subtree has been fully visited.
+ * The `exit` callback is called.
+ *
+ * @type {number}
+ */
+walkDOM.EXIT = 1;
+
+/**
+ * @typedef DocumentOptions
+ * @property {string} [contentType=MIME_TYPE.XML_APPLICATION]
+ */
+/**
+ * The Document interface describes the common properties and methods for any kind of document.
+ *
+ * It should usually be created using `new DOMImplementation().createDocument(...)`
+ * or `new DOMImplementation().createHTMLDocument(...)`.
+ *
+ * The constructor is considered a private API and offers to initially set the `contentType`
+ * property via it's options parameter.
+ *
+ * @class
+ * @param {Symbol} symbol
+ * @param {DocumentOptions} [options]
+ * @augments Node
+ * @private
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document
+ * @see https://dom.spec.whatwg.org/#interface-document
+ */
+function Document(symbol, options) {
+ checkSymbol(symbol);
+
+ var opt = options || {};
+ this.ownerDocument = this;
+ /**
+ * The mime type of the document is determined at creation time and can not be modified.
+ *
+ * @type {string}
+ * @see https://dom.spec.whatwg.org/#concept-document-content-type
+ * @see {@link DOMImplementation}
+ * @see {@link MIME_TYPE}
+ * @readonly
+ */
+ this.contentType = opt.contentType || MIME_TYPE.XML_APPLICATION;
+ /**
+ * @type {'html' | 'xml'}
+ * @see https://dom.spec.whatwg.org/#concept-document-type
+ * @see {@link DOMImplementation}
+ * @readonly
+ */
+ this.type = isHTMLMimeType(this.contentType) ? 'html' : 'xml';
+}
+
+/**
+ * Updates the namespace mapping of an element when a new attribute is added.
+ *
+ * @param {Document} doc
+ * The document that the element belongs to.
+ * @param {Element} el
+ * The element to which the attribute is being added.
+ * @param {Attr} newAttr
+ * The new attribute being added.
+ * @private
+ */
+function _onAddAttribute(doc, el, newAttr) {
+ doc && doc._inc++;
+ var ns = newAttr.namespaceURI;
+ if (ns === NAMESPACE.XMLNS) {
+ //update namespace
+ el._nsMap[newAttr.prefix ? newAttr.localName : ''] = newAttr.value;
+ }
+}
+
+/**
+ * Updates the namespace mapping of an element when an attribute is removed.
+ *
+ * @param {Document} doc
+ * The document that the element belongs to.
+ * @param {Element} el
+ * The element from which the attribute is being removed.
+ * @param {Attr} newAttr
+ * The attribute being removed.
+ * @param {boolean} remove
+ * Indicates whether the attribute is to be removed.
+ * @private
+ */
+function _onRemoveAttribute(doc, el, newAttr, remove) {
+ doc && doc._inc++;
+ var ns = newAttr.namespaceURI;
+ if (ns === NAMESPACE.XMLNS) {
+ //update namespace
+ delete el._nsMap[newAttr.prefix ? newAttr.localName : ''];
+ }
+}
+
+/**
+ * Updates `parent.childNodes`, adjusting the indexed items and its `length`.
+ * If `newChild` is provided and has no nextSibling, it will be appended.
+ * Otherwise, it's assumed that an item has been removed or inserted,
+ * and `parent.firstNode` and its `.nextSibling` to re-indexing all child nodes of `parent`.
+ *
+ * @param {Document} doc
+ * The parent document of `el`.
+ * @param {Node} parent
+ * The parent node whose childNodes list needs to be updated.
+ * @param {Node} [newChild]
+ * The new child node to be appended. If not provided, the function assumes a node has been
+ * removed.
+ * @private
+ */
+function _onUpdateChild(doc, parent, newChild) {
+ if (doc && doc._inc) {
+ doc._inc++;
+ var childNodes = parent.childNodes;
+ // assumes nextSibling and previousSibling were already configured upfront
+ if (newChild && !newChild.nextSibling) {
+ // if an item has been appended, we only need to update the last index and the length
+ childNodes[childNodes.length++] = newChild;
+ } else {
+ // otherwise we need to reindex all items,
+ // which can take a while when processing nodes with a lot of children
+ var child = parent.firstChild;
+ var i = 0;
+ while (child) {
+ childNodes[i++] = child;
+ child = child.nextSibling;
+ }
+ childNodes.length = i;
+ delete childNodes[childNodes.length];
+ }
+ }
+}
+
+/**
+ * Removes the connections between `parentNode` and `child`
+ * and any existing `child.previousSibling` or `child.nextSibling`.
+ *
+ * @param {Node} parentNode
+ * The parent node from which the child node is to be removed.
+ * @param {Node} child
+ * The child node to be removed from the parentNode.
+ * @returns {Node}
+ * Returns the child node that was removed.
+ * @throws {DOMException}
+ * With code:
+ * - {@link DOMException.NOT_FOUND_ERR} If the parentNode is not the parent of the child node.
+ * @private
+ * @see https://github.com/xmldom/xmldom/issues/135
+ * @see https://github.com/xmldom/xmldom/issues/145
+ */
+function _removeChild(parentNode, child) {
+ if (parentNode !== child.parentNode) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, "child's parent is not parent");
+ }
+ var oldPreviousSibling = child.previousSibling;
+ var oldNextSibling = child.nextSibling;
+ if (oldPreviousSibling) {
+ oldPreviousSibling.nextSibling = oldNextSibling;
+ } else {
+ parentNode.firstChild = oldNextSibling;
+ }
+ if (oldNextSibling) {
+ oldNextSibling.previousSibling = oldPreviousSibling;
+ } else {
+ parentNode.lastChild = oldPreviousSibling;
+ }
+ _onUpdateChild(parentNode.ownerDocument, parentNode);
+ child.parentNode = null;
+ child.previousSibling = null;
+ child.nextSibling = null;
+ return child;
+}
+
+/**
+ * Returns `true` if `node` can be a parent for insertion.
+ *
+ * @param {Node} node
+ * @returns {boolean}
+ */
+function hasValidParentNodeType(node) {
+ return (
+ node &&
+ (node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE)
+ );
+}
+
+/**
+ * Returns `true` if `node` can be inserted according to it's `nodeType`.
+ *
+ * @param {Node} node
+ * @returns {boolean}
+ */
+function hasInsertableNodeType(node) {
+ return (
+ node &&
+ (node.nodeType === Node.CDATA_SECTION_NODE ||
+ node.nodeType === Node.COMMENT_NODE ||
+ node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||
+ node.nodeType === Node.DOCUMENT_TYPE_NODE ||
+ node.nodeType === Node.ELEMENT_NODE ||
+ node.nodeType === Node.PROCESSING_INSTRUCTION_NODE ||
+ node.nodeType === Node.TEXT_NODE)
+ );
+}
+
+/**
+ * Returns true if `node` is a DOCTYPE node.
+ *
+ * @param {Node} node
+ * @returns {boolean}
+ */
+function isDocTypeNode(node) {
+ return node && node.nodeType === Node.DOCUMENT_TYPE_NODE;
+}
+
+/**
+ * Returns true if the node is an element.
+ *
+ * @param {Node} node
+ * @returns {boolean}
+ */
+function isElementNode(node) {
+ return node && node.nodeType === Node.ELEMENT_NODE;
+}
+/**
+ * Returns true if `node` is a text node.
+ *
+ * @param {Node} node
+ * @returns {boolean}
+ */
+function isTextNode(node) {
+ return node && node.nodeType === Node.TEXT_NODE;
+}
+
+/**
+ * Check if en element node can be inserted before `child`, or at the end if child is falsy,
+ * according to the presence and position of a doctype node on the same level.
+ *
+ * @param {Document} doc
+ * The document node.
+ * @param {Node} child
+ * The node that would become the nextSibling if the element would be inserted.
+ * @returns {boolean}
+ * `true` if an element can be inserted before child.
+ * @private
+ */
+function isElementInsertionPossible(doc, child) {
+ var parentChildNodes = doc.childNodes || [];
+ if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {
+ return false;
+ }
+ var docTypeNode = find(parentChildNodes, isDocTypeNode);
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
+}
+
+/**
+ * Check if en element node can be inserted before `child`, or at the end if child is falsy,
+ * according to the presence and position of a doctype node on the same level.
+ *
+ * @param {Node} doc
+ * The document node.
+ * @param {Node} child
+ * The node that would become the nextSibling if the element would be inserted.
+ * @returns {boolean}
+ * `true` if an element can be inserted before child.
+ * @private
+ */
+function isElementReplacementPossible(doc, child) {
+ var parentChildNodes = doc.childNodes || [];
+
+ function hasElementChildThatIsNotChild(node) {
+ return isElementNode(node) && node !== child;
+ }
+
+ if (find(parentChildNodes, hasElementChildThatIsNotChild)) {
+ return false;
+ }
+ var docTypeNode = find(parentChildNodes, isDocTypeNode);
+ return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
+}
+
+/**
+ * Asserts pre-insertion validity of a node into a parent before a child.
+ * Throws errors for invalid node combinations that would result in an ill-formed DOM.
+ *
+ * @param {Node} parent
+ * The parent node to insert `node` into.
+ * @param {Node} node
+ * The node to insert.
+ * @param {Node | null} child
+ * The node that should become the `nextSibling` of `node`. If null, no sibling is considered.
+ * @throws {DOMException}
+ * With code:
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `parent` is not a Document,
+ * DocumentFragment, or Element node.
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a host-including inclusive
+ * ancestor of `parent`. (Currently not implemented)
+ * - {@link DOMException.NOT_FOUND_ERR} If `child` is non-null and its `parent` is not
+ * `parent`.
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is not a DocumentFragment,
+ * DocumentType, Element, or CharacterData node.
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If either `node` is a Text node and `parent` is
+ * a document, or if `node` is a doctype and `parent` is not a document.
+ * @private
+ * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
+ * @see https://dom.spec.whatwg.org/#concept-node-replace
+ */
+function assertPreInsertionValidity1to5(parent, node, child) {
+ // 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException.
+ if (!hasValidParentNodeType(parent)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType);
+ }
+ // 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a "HierarchyRequestError" DOMException.
+ // not implemented!
+ // 3. If `child` is non-null and its parent is not `parent`, then throw a "NotFoundError" DOMException.
+ if (child && child.parentNode !== parent) {
+ throw new DOMException(DOMException.NOT_FOUND_ERR, 'child not in parent');
+ }
+ if (
+ // 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException.
+ !hasInsertableNodeType(node) ||
+ // 5. If either `node` is a Text node and `parent` is a document,
+ // the sax parser currently adds top level text nodes, this will be fixed in 0.9.0
+ // || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)
+ // or `node` is a doctype and `parent` is not a document, then throw a "HierarchyRequestError" DOMException.
+ (isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE)
+ ) {
+ throw new DOMException(
+ DOMException.HIERARCHY_REQUEST_ERR,
+ 'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType
+ );
+ }
+}
+
+/**
+ * Asserts pre-insertion validity of a node into a document before a child.
+ * Throws errors for invalid node combinations that would result in an ill-formed DOM.
+ *
+ * @param {Document} parent
+ * The parent node to insert `node` into.
+ * @param {Node} node
+ * The node to insert.
+ * @param {Node | undefined} child
+ * The node that should become the `nextSibling` of `node`. If undefined, no sibling is
+ * considered.
+ * @returns {Node}
+ * @throws {DOMException}
+ * With code:
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentFragment with more than
+ * one element child or has a Text node child.
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentFragment with one
+ * element child and either `parent` has an element child, `child` is a doctype, or `child` is
+ * non-null and a doctype is following `child`.
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is an Element and `parent` has an
+ * element child, `child` is a doctype, or `child` is non-null and a doctype is following
+ * `child`.
+ * - {@link DOMException.HIERARCHY_REQUEST_ERR} If `node` is a DocumentType and `parent` has a
+ * doctype child, `child` is non-null and an element is preceding `child`, or `child` is null
+ * and `parent` has an element child.
+ * @private
+ * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
+ * @see https://dom.spec.whatwg.org/#concept-node-replace
+ */
+function assertPreInsertionValidityInDocument(parent, node, child) {
+ var parentChildNodes = parent.childNodes || [];
+ var nodeChildNodes = node.childNodes || [];
+
+ // DocumentFragment
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
+ var nodeChildElements = nodeChildNodes.filter(isElementNode);
+ // If node has more than one element child or has a Text node child.
+ if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');
+ }
+ // Otherwise, if `node` has one element child and either `parent` has an element child,
+ // `child` is a doctype, or `child` is non-null and a doctype is following `child`.
+ if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');
+ }
+ }
+ // Element
+ if (isElementNode(node)) {
+ // `parent` has an element child, `child` is a doctype,
+ // or `child` is non-null and a doctype is following `child`.
+ if (!isElementInsertionPossible(parent, child)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');
+ }
+ }
+ // DocumentType
+ if (isDocTypeNode(node)) {
+ // `parent` has a doctype child,
+ if (find(parentChildNodes, isDocTypeNode)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');
+ }
+ var parentElementChild = find(parentChildNodes, isElementNode);
+ // `child` is non-null and an element is preceding `child`,
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');
+ }
+ // or `child` is null and `parent` has an element child.
+ if (!child && parentElementChild) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present');
+ }
+ }
+}
+
+/**
+ * @param {Document} parent
+ * The parent node to insert `node` into.
+ * @param {Node} node
+ * The node to insert.
+ * @param {Node | undefined} child
+ * the node that should become the `nextSibling` of `node`
+ * @returns {Node}
+ * @throws {DOMException}
+ * For several node combinations that would create a DOM that is not well-formed.
+ * @throws {DOMException}
+ * If `child` is provided but is not a child of `parent`.
+ * @private
+ * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
+ * @see https://dom.spec.whatwg.org/#concept-node-replace
+ */
+function assertPreReplacementValidityInDocument(parent, node, child) {
+ var parentChildNodes = parent.childNodes || [];
+ var nodeChildNodes = node.childNodes || [];
+
+ // DocumentFragment
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
+ var nodeChildElements = nodeChildNodes.filter(isElementNode);
+ // If `node` has more than one element child or has a Text node child.
+ if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');
+ }
+ // Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`.
+ if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');
+ }
+ }
+ // Element
+ if (isElementNode(node)) {
+ // `parent` has an element child that is not `child` or a doctype is following `child`.
+ if (!isElementReplacementPossible(parent, child)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');
+ }
+ }
+ // DocumentType
+ if (isDocTypeNode(node)) {
+ function hasDoctypeChildThatIsNotChild(node) {
+ return isDocTypeNode(node) && node !== child;
+ }
+
+ // `parent` has a doctype child that is not `child`,
+ if (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');
+ }
+ var parentElementChild = find(parentChildNodes, isElementNode);
+ // or an element is preceding `child`.
+ if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
+ throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');
+ }
+ }
+}
+
+/**
+ * Inserts a node into a parent node before a child node.
+ *
+ * @param {Node} parent
+ * The parent node to insert the node into.
+ * @param {Node} node
+ * The node to insert into the parent.
+ * @param {Node | null} child
+ * The node that should become the next sibling of the node.
+ * If null, the function inserts the node at the end of the children of the parent node.
+ * @param {Function} [_inDocumentAssertion]
+ * An optional function to check pre-insertion validity if parent is a document node.
+ * Defaults to {@link assertPreInsertionValidityInDocument}
+ * @returns {Node}
+ * Returns the inserted node.
+ * @throws {DOMException}
+ * Throws a DOMException if inserting the node would result in a DOM tree that is not
+ * well-formed. See {@link assertPreInsertionValidity1to5},
+ * {@link assertPreInsertionValidityInDocument}.
+ * @throws {DOMException}
+ * Throws a DOMException if child is provided but is not a child of the parent. See
+ * {@link Node.removeChild}
+ * @private
+ * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
+ */
+function _insertBefore(parent, node, child, _inDocumentAssertion) {
+ // To ensure pre-insertion validity of a node into a parent before a child, run these steps:
+ assertPreInsertionValidity1to5(parent, node, child);
+
+ // If parent is a document, and any of the statements below, switched on the interface node implements,
+ // are true, then throw a "HierarchyRequestError" DOMException.
+ if (parent.nodeType === Node.DOCUMENT_NODE) {
+ (_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);
+ }
+
+ var cp = node.parentNode;
+ if (cp) {
+ cp.removeChild(node); //remove and update
+ }
+ if (node.nodeType === DOCUMENT_FRAGMENT_NODE) {
+ var newFirst = node.firstChild;
+ if (newFirst == null) {
+ return node;
+ }
+ var newLast = node.lastChild;
+ } else {
+ newFirst = newLast = node;
+ }
+ var pre = child ? child.previousSibling : parent.lastChild;
+
+ newFirst.previousSibling = pre;
+ newLast.nextSibling = child;
+
+ if (pre) {
+ pre.nextSibling = newFirst;
+ } else {
+ parent.firstChild = newFirst;
+ }
+ if (child == null) {
+ parent.lastChild = newLast;
+ } else {
+ child.previousSibling = newLast;
+ }
+ do {
+ newFirst.parentNode = parent;
+ } while (newFirst !== newLast && (newFirst = newFirst.nextSibling));
+ _onUpdateChild(parent.ownerDocument || parent, parent, node);
+ if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
+ node.firstChild = node.lastChild = null;
+ }
+
+ return node;
+}
+
+Document.prototype = {
+ /**
+ * The implementation that created this document.
+ *
+ * @type DOMImplementation
+ * @readonly
+ */
+ implementation: null,
+ nodeName: '#document',
+ nodeType: DOCUMENT_NODE,
+ /**
+ * The DocumentType node of the document.
+ *
+ * @type DocumentType
+ * @readonly
+ */
+ doctype: null,
+ documentElement: null,
+ _inc: 1,
+
+ insertBefore: function (newChild, refChild) {
+ //raises
+ if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
+ var child = newChild.firstChild;
+ while (child) {
+ var next = child.nextSibling;
+ this.insertBefore(child, refChild);
+ child = next;
+ }
+ return newChild;
+ }
+ _insertBefore(this, newChild, refChild);
+ newChild.ownerDocument = this;
+ if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {
+ this.documentElement = newChild;
+ }
+
+ return newChild;
+ },
+ removeChild: function (oldChild) {
+ var removed = _removeChild(this, oldChild);
+ if (removed === this.documentElement) {
+ this.documentElement = null;
+ }
+ return removed;
+ },
+ replaceChild: function (newChild, oldChild) {
+ //raises
+ _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
+ newChild.ownerDocument = this;
+ if (oldChild) {
+ this.removeChild(oldChild);
+ }
+ if (isElementNode(newChild)) {
+ this.documentElement = newChild;
+ }
+ },
+ /**
+ * Imports a node from another document into this document, creating a new copy owned by this
+ * document. The source node and its subtree are not modified.
+ *
+ * @param {Node} importedNode
+ * The node to import.
+ * @param {boolean} deep
+ * If true, the contents of the node are recursively imported.
+ * If false, only the node itself (and its attributes, if it is an element) are imported.
+ * @returns {Node}
+ * Returns the newly created import of the node.
+ * @see {@link importNode}
+ * @see {@link https://dom.spec.whatwg.org/#dom-document-importnode}
+ */
+ importNode: function (importedNode, deep) {
+ return importNode(this, importedNode, deep);
+ },
+ // Introduced in DOM Level 2:
+ getElementById: function (id) {
+ var rtv = null;
+ _visitNode(this.documentElement, function (node) {
+ if (node.nodeType == ELEMENT_NODE) {
+ if (node.getAttribute('id') == id) {
+ rtv = node;
+ return true;
+ }
+ }
+ });
+ return rtv;
+ },
+
+ /**
+ * Creates a new `Element` that is owned by this `Document`.
+ * In HTML Documents `localName` is the lower cased `tagName`,
+ * otherwise no transformation is being applied.
+ * When `contentType` implies the HTML namespace, it will be set as `namespaceURI`.
+ *
+ * __This implementation differs from the specification:__ - The provided name is not checked
+ * against the `Name` production,
+ * so no related error will be thrown.
+ * - There is no interface `HTMLElement`, it is always an `Element`.
+ * - There is no support for a second argument to indicate using custom elements.
+ *
+ * @param {string} tagName
+ * @returns {Element}
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement
+ * @see https://dom.spec.whatwg.org/#dom-document-createelement
+ * @see https://dom.spec.whatwg.org/#concept-create-element
+ */
+ createElement: function (tagName) {
+ var node = new Element(PDC);
+ node.ownerDocument = this;
+ if (this.type === 'html') {
+ tagName = tagName.toLowerCase();
+ }
+ if (hasDefaultHTMLNamespace(this.contentType)) {
+ node.namespaceURI = NAMESPACE.HTML;
+ }
+ node.nodeName = tagName;
+ node.tagName = tagName;
+ node.localName = tagName;
+ node.childNodes = new NodeList();
+ var attrs = (node.attributes = new NamedNodeMap());
+ attrs._ownerElement = node;
+ return node;
+ },
+ /**
+ * @returns {DocumentFragment}
+ */
+ createDocumentFragment: function () {
+ var node = new DocumentFragment(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ return node;
+ },
+ /**
+ * @param {string} data
+ * @returns {Text}
+ */
+ createTextNode: function (data) {
+ var node = new Text(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.appendData(data);
+ return node;
+ },
+ /**
+ * @param {string} data
+ * @returns {Comment}
+ * @see https://dom.spec.whatwg.org/#dom-document-createcomment
+ * @see https://www.w3.org/TR/xml/#NT-Comment XML 1.0 production [15]
+ * @see https://www.w3.org/TR/DOM-Parsing/#dfn-concept-serialize-xml §3.2.1.3
+ *
+ * Note: no validation is performed at creation time. When the resulting document is
+ * serialized with `requireWellFormed: true`, the serializer throws `InvalidStateError`
+ * if the comment data contains `--` anywhere, ends with `-`, or contains characters
+ * outside the XML Char production (W3C DOM Parsing §3.2.1.3). Without that option the
+ * data is emitted verbatim.
+ */
+ createComment: function (data) {
+ var node = new Comment(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.appendData(data);
+ return node;
+ },
+ /**
+ * Returns a new CDATASection node whose data is `data`.
+ *
+ * __This implementation differs from the specification:__ - calling this method on an HTML
+ * document does not throw `NotSupportedError`.
+ *
+ * @param {string} data
+ * @returns {CDATASection}
+ * @throws {DOMException}
+ * With code `INVALID_CHARACTER_ERR` if `data` contains `"]]>"`.
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection
+ * @see https://dom.spec.whatwg.org/#dom-document-createcdatasection
+ */
+ createCDATASection: function (data) {
+ if (data.indexOf(']]>') !== -1) {
+ throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 'data contains "]]>"');
+ }
+ var node = new CDATASection(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.appendData(data);
+ return node;
+ },
+ /**
+ * Returns a ProcessingInstruction node whose target is target and data is data.
+ *
+ * __This behavior is slightly different from the in the specs__:
+ * - it does not do any input validation on the arguments and doesn't throw
+ * "InvalidCharacterError".
+ *
+ * Note: When the resulting document is serialized with `requireWellFormed: true`, the
+ * serializer throws `InvalidStateError` if `.target` contains `:` or is an ASCII
+ * case-insensitive match for `"xml"`, or if `.data` contains `?>` or characters outside the
+ * XML Char production (W3C DOM Parsing §3.2.1.7). Without that option the data is emitted
+ * verbatim.
+ *
+ * @param {string} target
+ * @param {string} data
+ * @returns {ProcessingInstruction}
+ * @see https://developer.mozilla.org/docs/Web/API/Document/createProcessingInstruction
+ * @see https://dom.spec.whatwg.org/#dom-document-createprocessinginstruction
+ * @see https://www.w3.org/TR/DOM-Parsing/#dfn-concept-serialize-xml §3.2.1.7
+ */
+ createProcessingInstruction: function (target, data) {
+ var node = new ProcessingInstruction(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.nodeName = node.target = target;
+ node.nodeValue = node.data = data;
+ return node;
+ },
+ /**
+ * Creates an `Attr` node that is owned by this document.
+ * In HTML Documents `localName` is the lower cased `name`,
+ * otherwise no transformation is being applied.
+ *
+ * __This implementation differs from the specification:__ - The provided name is not checked
+ * against the `Name` production,
+ * so no related error will be thrown.
+ *
+ * @param {string} name
+ * @returns {Attr}
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createAttribute
+ * @see https://dom.spec.whatwg.org/#dom-document-createattribute
+ */
+ createAttribute: function (name) {
+ if (!g.QName_exact.test(name)) {
+ throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 'invalid character in name "' + name + '"');
+ }
+ if (this.type === 'html') {
+ name = name.toLowerCase();
+ }
+ return this._createAttribute(name);
+ },
+ _createAttribute: function (name) {
+ var node = new Attr(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.name = name;
+ node.nodeName = name;
+ node.localName = name;
+ node.specified = true;
+ return node;
+ },
+ /**
+ * Creates an EntityReference object.
+ * The current implementation does not fill the `childNodes` with those of the corresponding
+ * `Entity`
+ *
+ * @deprecated
+ * In DOM Level 4.
+ * @param {string} name
+ * The name of the entity to reference. No namespace well-formedness checks are performed.
+ * @returns {EntityReference}
+ * @throws {DOMException}
+ * With code `INVALID_CHARACTER_ERR` when `name` is not valid.
+ * @throws {DOMException}
+ * with code `NOT_SUPPORTED_ERR` when the document is of type `html`
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE
+ */
+ createEntityReference: function (name) {
+ if (!g.Name.test(name)) {
+ throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 'not a valid xml name "' + name + '"');
+ }
+ if (this.type === 'html') {
+ throw new DOMException('document is an html document', DOMExceptionName.NotSupportedError);
+ }
+
+ var node = new EntityReference(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.nodeName = name;
+ return node;
+ },
+ // Introduced in DOM Level 2:
+ /**
+ * @param {string} namespaceURI
+ * @param {string} qualifiedName
+ * @returns {Element}
+ */
+ createElementNS: function (namespaceURI, qualifiedName) {
+ var validated = validateAndExtract(namespaceURI, qualifiedName);
+ var node = new Element(PDC);
+ var attrs = (node.attributes = new NamedNodeMap());
+ node.childNodes = new NodeList();
+ node.ownerDocument = this;
+ node.nodeName = qualifiedName;
+ node.tagName = qualifiedName;
+ node.namespaceURI = validated[0];
+ node.prefix = validated[1];
+ node.localName = validated[2];
+ attrs._ownerElement = node;
+ return node;
+ },
+ // Introduced in DOM Level 2:
+ /**
+ * @param {string} namespaceURI
+ * @param {string} qualifiedName
+ * @returns {Attr}
+ */
+ createAttributeNS: function (namespaceURI, qualifiedName) {
+ var validated = validateAndExtract(namespaceURI, qualifiedName);
+ var node = new Attr(PDC);
+ node.ownerDocument = this;
+ node.childNodes = new NodeList();
+ node.nodeName = qualifiedName;
+ node.name = qualifiedName;
+ node.specified = true;
+ node.namespaceURI = validated[0];
+ node.prefix = validated[1];
+ node.localName = validated[2];
+ return node;
+ },
+};
+_extends(Document, Node);
+
+function Element(symbol) {
+ checkSymbol(symbol);
+
+ this._nsMap = Object.create(null);
+}
+Element.prototype = {
+ nodeType: ELEMENT_NODE,
+ /**
+ * The attributes of this element.
+ *
+ * @type {NamedNodeMap | null}
+ */
+ attributes: null,
+ getQualifiedName: function () {
+ return this.prefix ? this.prefix + ':' + this.localName : this.localName;
+ },
+ _isInHTMLDocumentAndNamespace: function () {
+ return this.ownerDocument.type === 'html' && this.namespaceURI === NAMESPACE.HTML;
+ },
+ /**
+ * Implementaton of Level2 Core function hasAttributes.
+ *
+ * @returns {boolean}
+ * True if attribute list is not empty.
+ * @see https://www.w3.org/TR/DOM-Level-2-Core/#core-ID-NodeHasAttrs
+ */
+ hasAttributes: function () {
+ return !!(this.attributes && this.attributes.length);
+ },
+ hasAttribute: function (name) {
+ return !!this.getAttributeNode(name);
+ },
+ /**
+ * Returns element’s first attribute whose qualified name is `name`, and `null`
+ * if there is no such attribute.
+ *
+ * @param {string} name
+ * @returns {string | null}
+ */
+ getAttribute: function (name) {
+ var attr = this.getAttributeNode(name);
+ return attr ? attr.value : null;
+ },
+ getAttributeNode: function (name) {
+ if (this._isInHTMLDocumentAndNamespace()) {
+ name = name.toLowerCase();
+ }
+ return this.attributes.getNamedItem(name);
+ },
+ /**
+ * Sets the value of element’s first attribute whose qualified name is qualifiedName to value.
+ *
+ * @param {string} name
+ * @param {string} value
+ */
+ setAttribute: function (name, value) {
+ if (this._isInHTMLDocumentAndNamespace()) {
+ name = name.toLowerCase();
+ }
+ var attr = this.getAttributeNode(name);
+ if (attr) {
+ attr.value = attr.nodeValue = '' + value;
+ } else {
+ attr = this.ownerDocument._createAttribute(name);
+ attr.value = attr.nodeValue = '' + value;
+ this.setAttributeNode(attr);
+ }
+ },
+ removeAttribute: function (name) {
+ var attr = this.getAttributeNode(name);
+ attr && this.removeAttributeNode(attr);
+ },
+ setAttributeNode: function (newAttr) {
+ return this.attributes.setNamedItem(newAttr);
+ },
+ setAttributeNodeNS: function (newAttr) {
+ return this.attributes.setNamedItemNS(newAttr);
+ },
+ removeAttributeNode: function (oldAttr) {
+ //console.log(this == oldAttr.ownerElement)
+ return this.attributes.removeNamedItem(oldAttr.nodeName);
+ },
+ //get real attribute name,and remove it by removeAttributeNode
+ removeAttributeNS: function (namespaceURI, localName) {
+ var old = this.getAttributeNodeNS(namespaceURI, localName);
+ old && this.removeAttributeNode(old);
+ },
+
+ hasAttributeNS: function (namespaceURI, localName) {
+ return this.getAttributeNodeNS(namespaceURI, localName) != null;
+ },
+ /**
+ * Returns element’s attribute whose namespace is `namespaceURI` and local name is
+ * `localName`,
+ * or `null` if there is no such attribute.
+ *
+ * @param {string} namespaceURI
+ * @param {string} localName
+ * @returns {string | null}
+ */
+ getAttributeNS: function (namespaceURI, localName) {
+ var attr = this.getAttributeNodeNS(namespaceURI, localName);
+ return attr ? attr.value : null;
+ },
+ /**
+ * Sets the value of element’s attribute whose namespace is `namespaceURI` and local name is
+ * `localName` to value.
+ *
+ * @param {string} namespaceURI
+ * @param {string} qualifiedName
+ * @param {string} value
+ * @see https://dom.spec.whatwg.org/#dom-element-setattributens
+ */
+ setAttributeNS: function (namespaceURI, qualifiedName, value) {
+ var validated = validateAndExtract(namespaceURI, qualifiedName);
+ var localName = validated[2];
+ var attr = this.getAttributeNodeNS(namespaceURI, localName);
+ if (attr) {
+ attr.value = attr.nodeValue = '' + value;
+ } else {
+ attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
+ attr.value = attr.nodeValue = '' + value;
+ this.setAttributeNode(attr);
+ }
+ },
+ getAttributeNodeNS: function (namespaceURI, localName) {
+ return this.attributes.getNamedItemNS(namespaceURI, localName);
+ },
+
+ /**
+ * Returns a LiveNodeList of all child elements which have **all** of the given class name(s).
+ *
+ * Returns an empty list if `classNames` is an empty string or only contains HTML white space
+ * characters.
+ *
+ * Warning: This returns a live LiveNodeList.
+ * Changes in the DOM will reflect in the array as the changes occur.
+ * If an element selected by this array no longer qualifies for the selector,
+ * it will automatically be removed. Be aware of this for iteration purposes.
+ *
+ * @param {string} classNames
+ * Is a string representing the class name(s) to match; multiple class names are separated by
+ * (ASCII-)whitespace.
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
+ * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
+ */
+ getElementsByClassName: function (classNames) {
+ var classNamesSet = toOrderedSet(classNames);
+ return new LiveNodeList(this, function (base) {
+ var ls = [];
+ if (classNamesSet.length > 0) {
+ _visitNode(base, function (node) {
+ if (node !== base && node.nodeType === ELEMENT_NODE) {
+ var nodeClassNames = node.getAttribute('class');
+ // can be null if the attribute does not exist
+ if (nodeClassNames) {
+ // before splitting and iterating just compare them for the most common case
+ var matches = classNames === nodeClassNames;
+ if (!matches) {
+ var nodeClassNamesSet = toOrderedSet(nodeClassNames);
+ matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
+ }
+ if (matches) {
+ ls.push(node);
+ }
+ }
+ }
+ });
+ }
+ return ls;
+ });
+ },
+
+ /**
+ * Returns a LiveNodeList of elements with the given qualifiedName.
+ * Searching for all descendants can be done by passing `*` as `qualifiedName`.
+ *
+ * All descendants of the specified element are searched, but not the element itself.
+ * The returned list is live, which means it updates itself with the DOM tree automatically.
+ * Therefore, there is no need to call `Element.getElementsByTagName()`
+ * with the same element and arguments repeatedly if the DOM changes in between calls.
+ *
+ * When called on an HTML element in an HTML document,
+ * `getElementsByTagName` lower-cases the argument before searching for it.
+ * This is undesirable when trying to match camel-cased SVG elements (such as
+ * ``) in an HTML document.
+ * Instead, use `Element.getElementsByTagNameNS()`,
+ * which preserves the capitalization of the tag name.
+ *
+ * `Element.getElementsByTagName` is similar to `Document.getElementsByTagName()`,
+ * except that it only searches for elements that are descendants of the specified element.
+ *
+ * @param {string} qualifiedName
+ * @returns {LiveNodeList}
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName
+ * @see https://dom.spec.whatwg.org/#concept-getelementsbytagname
+ */
+ getElementsByTagName: function (qualifiedName) {
+ var isHTMLDocument = (this.nodeType === DOCUMENT_NODE ? this : this.ownerDocument).type === 'html';
+ var lowerQualifiedName = qualifiedName.toLowerCase();
+ return new LiveNodeList(this, function (base) {
+ var ls = [];
+ _visitNode(base, function (node) {
+ if (node === base || node.nodeType !== ELEMENT_NODE) {
+ return;
+ }
+ if (qualifiedName === '*') {
+ ls.push(node);
+ } else {
+ var nodeQualifiedName = node.getQualifiedName();
+ var matchingQName = isHTMLDocument && node.namespaceURI === NAMESPACE.HTML ? lowerQualifiedName : qualifiedName;
+ if (nodeQualifiedName === matchingQName) {
+ ls.push(node);
+ }
+ }
+ });
+ return ls;
+ });
+ },
+ getElementsByTagNameNS: function (namespaceURI, localName) {
+ return new LiveNodeList(this, function (base) {
+ var ls = [];
+ _visitNode(base, function (node) {
+ if (
+ node !== base &&
+ node.nodeType === ELEMENT_NODE &&
+ (namespaceURI === '*' || node.namespaceURI === namespaceURI) &&
+ (localName === '*' || node.localName == localName)
+ ) {
+ ls.push(node);
+ }
+ });
+ return ls;
+ });
+ },
+};
+Document.prototype.getElementsByClassName = Element.prototype.getElementsByClassName;
+Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
+Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
+
+_extends(Element, Node);
+function Attr(symbol) {
+ checkSymbol(symbol);
+
+ this.namespaceURI = null;
+ this.prefix = null;
+ this.ownerElement = null;
+}
+Attr.prototype.nodeType = ATTRIBUTE_NODE;
+_extends(Attr, Node);
+
+function CharacterData(symbol) {
+ checkSymbol(symbol);
+}
+CharacterData.prototype = {
+ data: '',
+ substringData: function (offset, count) {
+ return this.data.substring(offset, offset + count);
+ },
+ appendData: function (text) {
+ text = this.data + text;
+ this.nodeValue = this.data = text;
+ this.length = text.length;
+ },
+ insertData: function (offset, text) {
+ this.replaceData(offset, 0, text);
+ },
+ deleteData: function (offset, count) {
+ this.replaceData(offset, count, '');
+ },
+ replaceData: function (offset, count, text) {
+ var start = this.data.substring(0, offset);
+ var end = this.data.substring(offset + count);
+ text = start + text + end;
+ this.nodeValue = this.data = text;
+ this.length = text.length;
+ },
+};
+_extends(CharacterData, Node);
+function Text(symbol) {
+ checkSymbol(symbol);
+}
+Text.prototype = {
+ nodeName: '#text',
+ nodeType: TEXT_NODE,
+ splitText: function (offset) {
+ var text = this.data;
+ var newText = text.substring(offset);
+ text = text.substring(0, offset);
+ this.data = this.nodeValue = text;
+ this.length = text.length;
+ var newNode = this.ownerDocument.createTextNode(newText);
+ if (this.parentNode) {
+ this.parentNode.insertBefore(newNode, this.nextSibling);
+ }
+ return newNode;
+ },
+};
+_extends(Text, CharacterData);
+function Comment(symbol) {
+ checkSymbol(symbol);
+}
+Comment.prototype = {
+ nodeName: '#comment',
+ nodeType: COMMENT_NODE,
+};
+_extends(Comment, CharacterData);
+
+function CDATASection(symbol) {
+ checkSymbol(symbol);
+}
+CDATASection.prototype = {
+ nodeName: '#cdata-section',
+ nodeType: CDATA_SECTION_NODE,
+};
+_extends(CDATASection, Text);
+
+/**
+ * @class DocumentType
+ * @augments Node
+ * @property {string} publicId
+ * The external subset public identifier, stored verbatim (including surrounding quotes).
+ * Declared `readonly` by the WHATWG DOM spec; xmldom does not enforce this constraint —
+ * direct property writes succeed and the written value is serialized verbatim.
+ * When serialized with `requireWellFormed: true`, the serializer validates the value against
+ * the XML `PubidLiteral` production and throws `InvalidStateError` if it does not match.
+ * @property {string} systemId
+ * The external subset system identifier, stored verbatim (including surrounding quotes).
+ * Declared `readonly` by the WHATWG DOM spec; xmldom does not enforce this constraint —
+ * direct property writes succeed and the written value is serialized verbatim.
+ * When serialized with `requireWellFormed: true`, the serializer validates the value against
+ * the XML `SystemLiteral` production and throws `InvalidStateError` if it does not match.
+ * @property {string} internalSubset
+ * The internal subset string (the raw content between `[` and `]`), or an empty string.
+ * Declared `readonly` by the WHATWG DOM spec; xmldom does not enforce this constraint —
+ * direct property writes succeed and the written value is serialized verbatim.
+ * When serialized with `requireWellFormed: true`, the serializer throws `InvalidStateError`
+ * if the value contains `"]>"`.
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DocumentType MDN
+ * @see https://dom.spec.whatwg.org/#interface-documenttype WHATWG DOM
+ * @prettierignore
+ */
+function DocumentType(symbol) {
+ checkSymbol(symbol);
+}
+DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
+_extends(DocumentType, Node);
+
+function Notation(symbol) {
+ checkSymbol(symbol);
+}
+Notation.prototype.nodeType = NOTATION_NODE;
+_extends(Notation, Node);
+
+function Entity(symbol) {
+ checkSymbol(symbol);
+}
+Entity.prototype.nodeType = ENTITY_NODE;
+_extends(Entity, Node);
+
+function EntityReference(symbol) {
+ checkSymbol(symbol);
+}
+EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
+_extends(EntityReference, Node);
+
+function DocumentFragment(symbol) {
+ checkSymbol(symbol);
+}
+DocumentFragment.prototype.nodeName = '#document-fragment';
+DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
+_extends(DocumentFragment, Node);
+
+function ProcessingInstruction(symbol) {
+ checkSymbol(symbol);
+}
+ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
+_extends(ProcessingInstruction, CharacterData);
+function XMLSerializer() {}
+/**
+ * Returns the result of serializing `node` to XML.
+ *
+ * When `options.requireWellFormed` is `true`, the serializer throws `InvalidStateError` for
+ * content that would produce ill-formed XML (e.g. CDATASection data containing `"]]>"`, Text
+ * data containing characters outside the XML Char production, or a Document with no
+ * `documentElement`).
+ *
+ * When `options.splitCDATASections` is `false`, CDATASection data is emitted verbatim even
+ * when it contains `"]]>"`. When `true` (the default), `"]]>"` sequences are split across
+ * concatenated CDATA sections — this behavior is **deprecated** and will be removed in the
+ * next breaking release. Callers should migrate to `{ requireWellFormed: true }`, which throws
+ * `InvalidStateError` instead of transforming.
+ *
+ * __This implementation differs from the specification:__ - CDATASection serialization is not
+ * specified by W3C DOM Parsing or WHATWG DOM Parsing (see
+ * {@link https://github.com/w3c/DOM-Parsing/issues/38 w3c/DOM-Parsing#38}).
+ * When `splitCDATASections` is `true` (the default), `"]]>"` sequences in CDATASection data
+ * are split across concatenated CDATA sections — this mechanism is derived from DOM Level 3
+ * Core and is **deprecated**. The split mechanics will be removed in the next breaking
+ * release. Callers that rely on this behavior should migrate to `{ requireWellFormed: true }`.
+ * - W3C DOM Parsing §3.2.1.1 requires well-formedness checks on Element `localName`s,
+ * prefixes,
+ * and attribute serialization (duplicate attributes, namespace declarations, attribute value
+ * characters) when `requireWellFormed` is `true`. These checks are **not implemented** in this
+ * release — see the tracking issue filed against the next breaking milestone.
+ *
+ * @param {Node} node
+ * @param {Object | function} [options]
+ * Options object, or a legacy nodeFilter function (backward compatible).
+ * @param {boolean} [options.requireWellFormed=false]
+ * When `true`, throws `InvalidStateError` for content that would produce ill-formed XML.
+ * @param {boolean} [options.splitCDATASections=true]
+ * When `true` (default), splits `"]]>"` sequences in CDATASection data across concatenated
+ * CDATA sections. **Deprecated** — will be removed in the next breaking release.
+ * @param {function} [options.nodeFilter]
+ * A filter function applied to each node before serialization.
+ * @returns {string}
+ * @throws {DOMException}
+ * With name `InvalidStateError` when `requireWellFormed` is `true` and any of the following
+ * conditions hold:
+ * - CDATASection data contains `"]]>"`
+ * - Text data contains characters outside the XML Char production
+ * - a Comment node's data contains `--` anywhere or ends with `-`
+ * - a ProcessingInstruction's target contains `:` or is an ASCII case-insensitive match for
+ * `"xml"`, or its data contains `?>` or characters outside the XML Char production
+ * - a DocumentType's `publicId` is non-empty and does not match the XML `PubidLiteral`
+ * production (W3C DOM Parsing §3.2.1.3; XML 1.0 production [12])
+ * - a DocumentType's `systemId` is non-empty and does not match the XML `SystemLiteral`
+ * production (W3C DOM Parsing §3.2.1.3; XML 1.0 production [11])
+ * - a DocumentType's `internalSubset` contains `"]>"`
+ * - the Document has no `documentElement`
+ * @see https://developer.mozilla.org/docs/Web/API/XMLSerializer/serializeToString
+ * @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
+ * @see https://github.com/w3c/DOM-Parsing/issues/84
+ * @prettierignore
+ */
+XMLSerializer.prototype.serializeToString = function (node, options) {
+ return nodeSerializeToString.call(node, options);
+};
+Node.prototype.toString = nodeSerializeToString;
+function nodeSerializeToString(options) {
+ // Normalize the user-supplied options into a single internal opts object so that the
+ // internal serializer always works with a consistent shape rather than positional flags.
+ var opts;
+ if (typeof options === 'function') {
+ opts = { requireWellFormed: false, splitCDATASections: true, nodeFilter: options };
+ } else if (options != null) {
+ opts = {
+ requireWellFormed: !!options.requireWellFormed,
+ splitCDATASections: options.splitCDATASections !== false,
+ nodeFilter: options.nodeFilter || null,
+ };
+ } else {
+ opts = { requireWellFormed: false, splitCDATASections: true, nodeFilter: null };
+ }
+ var buf = [];
+ var refNode = (this.nodeType === DOCUMENT_NODE && this.documentElement) || this;
+ var prefix = refNode.prefix;
+ var uri = refNode.namespaceURI;
+
+ if (uri && prefix == null) {
+ var prefix = refNode.lookupPrefix(uri);
+ if (prefix == null) {
+ var visibleNamespaces = [
+ { namespace: uri, prefix: null },
+ //{namespace:uri,prefix:''}
+ ];
+ }
+ }
+ serializeToString(this, buf, visibleNamespaces, opts);
+ return buf.join('');
+}
+
+function needNamespaceDefine(node, isHTML, visibleNamespaces) {
+ var prefix = node.prefix || '';
+ var uri = node.namespaceURI;
+ // According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,
+ // and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :
+ // > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.
+ // in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)
+ // and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :
+ // > [...] Furthermore, the attribute value [...] must not be an empty string.
+ // so serializing empty namespace value like xmlns:ds="" would produce an invalid XML document.
+ if (!uri) {
+ return false;
+ }
+ if ((prefix === 'xml' && uri === NAMESPACE.XML) || uri === NAMESPACE.XMLNS) {
+ return false;
+ }
+
+ var i = visibleNamespaces.length;
+ while (i--) {
+ var ns = visibleNamespaces[i];
+ // get namespace prefix
+ if (ns.prefix === prefix) {
+ return ns.namespace !== uri;
+ }
+ }
+ return true;
+}
+/**
+ * Literal whitespace other than space that appear in attribute values are serialized as
+ * their entity references, so they will be preserved.
+ * (In contrast to whitespace literals in the input which are normalized to spaces).
+ *
+ * Well-formed constraint: No < in Attribute Values:
+ * > The replacement text of any entity referred to directly or indirectly
+ * > in an attribute value must not contain a <.
+ *
+ * @see https://www.w3.org/TR/xml11/#CleanAttrVals
+ * @see https://www.w3.org/TR/xml11/#NT-AttValue
+ * @see https://www.w3.org/TR/xml11/#AVNormalize
+ * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes
+ * @prettierignore
+ */
+function addSerializedAttribute(buf, qualifiedName, value) {
+ buf.push(' ', qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"');
+}
+
+function serializeToString(node, buf, visibleNamespaces, opts) {
+ if (!visibleNamespaces) {
+ visibleNamespaces = [];
+ }
+ var nodeFilter = opts.nodeFilter;
+ var requireWellFormed = opts.requireWellFormed;
+ var splitCDATASections = opts.splitCDATASections;
+ var doc = node.nodeType === DOCUMENT_NODE ? node : node.ownerDocument;
+ var isHTML = doc.type === 'html';
+
+ walkDOM(
+ node,
+ { ns: visibleNamespaces },
+ {
+ enter: function (n, ctx) {
+ var namespaces = ctx.ns;
+
+ if (nodeFilter) {
+ n = nodeFilter(n);
+ if (n) {
+ if (typeof n == 'string') {
+ buf.push(n);
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ switch (n.nodeType) {
+ case ELEMENT_NODE:
+ var attrs = n.attributes;
+ var len = attrs.length;
+ var nodeName = n.tagName;
+
+ var prefixedNodeName = nodeName;
+ if (!isHTML && !n.prefix && n.namespaceURI) {
+ var defaultNS;
+ // lookup current default ns from `xmlns` attribute
+ for (var ai = 0; ai < attrs.length; ai++) {
+ if (attrs.item(ai).name === 'xmlns') {
+ defaultNS = attrs.item(ai).value;
+ break;
+ }
+ }
+ if (!defaultNS) {
+ // lookup current default ns in visibleNamespaces
+ for (var nsi = namespaces.length - 1; nsi >= 0; nsi--) {
+ var nsEntry = namespaces[nsi];
+ if (nsEntry.prefix === '' && nsEntry.namespace === n.namespaceURI) {
+ defaultNS = nsEntry.namespace;
+ break;
+ }
+ }
+ }
+ if (defaultNS !== n.namespaceURI) {
+ for (var nsi = namespaces.length - 1; nsi >= 0; nsi--) {
+ var nsEntry = namespaces[nsi];
+ if (nsEntry.namespace === n.namespaceURI) {
+ if (nsEntry.prefix) {
+ prefixedNodeName = nsEntry.prefix + ':' + nodeName;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ buf.push('<', prefixedNodeName);
+
+ // Build a fresh namespace snapshot for this element's children.
+ // The slice prevents sibling elements from inheriting each other's declarations.
+ var childNamespaces = namespaces.slice();
+
+ for (var i = 0; i < len; i++) {
+ // add namespaces for attributes
+ var attr = attrs.item(i);
+ if (attr.prefix == 'xmlns') {
+ childNamespaces.push({
+ prefix: attr.localName,
+ namespace: attr.value,
+ });
+ } else if (attr.nodeName == 'xmlns') {
+ childNamespaces.push({ prefix: '', namespace: attr.value });
+ }
+ }
+
+ for (var i = 0; i < len; i++) {
+ var attr = attrs.item(i);
+ if (needNamespaceDefine(attr, isHTML, childNamespaces)) {
+ var attrPrefix = attr.prefix || '';
+ var uri = attr.namespaceURI;
+ addSerializedAttribute(buf, attrPrefix ? 'xmlns:' + attrPrefix : 'xmlns', uri);
+ childNamespaces.push({ prefix: attrPrefix, namespace: uri });
+ }
+ // Apply nodeFilter and serialize the attribute.
+ var filteredAttr = nodeFilter ? nodeFilter(attr) : attr;
+ if (filteredAttr) {
+ if (typeof filteredAttr === 'string') {
+ buf.push(filteredAttr);
+ } else {
+ addSerializedAttribute(buf, filteredAttr.name, filteredAttr.value);
+ }
+ }
+ }
+
+ // add namespace for current node
+ if (nodeName === prefixedNodeName && needNamespaceDefine(n, isHTML, childNamespaces)) {
+ var nodePrefix = n.prefix || '';
+ var uri = n.namespaceURI;
+ addSerializedAttribute(buf, nodePrefix ? 'xmlns:' + nodePrefix : 'xmlns', uri);
+ childNamespaces.push({ prefix: nodePrefix, namespace: uri });
+ }
+
+ // in XML elements can be closed when they have no children
+ var canCloseTag = !n.firstChild;
+ if (canCloseTag && (isHTML || n.namespaceURI === NAMESPACE.HTML)) {
+ // in HTML (doc or ns) only void elements can be closed right away
+ canCloseTag = isHTMLVoidElement(nodeName);
+ }
+ if (canCloseTag) {
+ buf.push('/>');
+ // Self-closing: no children and no closing tag needed from exit.
+ return null;
+ }
+
+ buf.push('>');
+
+ // HTML raw text elements: serialize children as raw data without further descent.
+ if (isHTML && isHTMLRawTextElement(nodeName)) {
+ var child = n.firstChild;
+ while (child) {
+ if (child.data) {
+ buf.push(child.data);
+ } else {
+ serializeToString(child, buf, childNamespaces.slice(), opts);
+ }
+ child = child.nextSibling;
+ }
+ buf.push('', prefixedNodeName, '>');
+ // Children handled manually above; prevent walkDOM from also traversing them.
+ return null;
+ }
+
+ // Return child context so walkDOM descends; exit will emit the closing tag.
+ return { ns: childNamespaces, tag: prefixedNodeName };
+ case DOCUMENT_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ if (requireWellFormed && n.nodeType === DOCUMENT_NODE && n.documentElement == null) {
+ throw new DOMException('The Document has no documentElement', DOMExceptionName.InvalidStateError);
+ }
+ // Pass namespaces through; each child element will slice independently.
+ return { ns: namespaces };
+ case ATTRIBUTE_NODE:
+ addSerializedAttribute(buf, n.name, n.value);
+ return null;
+ case TEXT_NODE:
+ /*
+ * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
+ * except when used as markup delimiters, or within a comment, a processing instruction,
+ * or a CDATA section.
+ * If they are needed elsewhere, they must be escaped using either numeric character
+ * references or the strings `&` and `<` respectively.
+ * The right angle bracket (>) may be represented using the string " > ",
+ * and must, for compatibility, be escaped using either `>`,
+ * or a character reference when it appears in the string `]]>` in content,
+ * when that string is not marking the end of a CDATA section.
+ *
+ * In the content of elements, character data is any string of characters which does not
+ * contain the start-delimiter of any markup and does not include the CDATA-section-close
+ * delimiter, `]]>`.
+ *
+ * @see https://www.w3.org/TR/xml/#NT-CharData
+ * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
+ */
+ if (requireWellFormed && g.InvalidChar.test(n.data)) {
+ throw new DOMException(
+ 'The Text node data contains characters outside the XML Char production',
+ DOMExceptionName.InvalidStateError
+ );
+ }
+ buf.push(n.data.replace(/[<&>]/g, _xmlEncoder));
+ return null;
+ case CDATA_SECTION_NODE:
+ if (requireWellFormed && n.data.indexOf(']]>') !== -1) {
+ throw new DOMException('The CDATASection data contains "]]>"', DOMExceptionName.InvalidStateError);
+ }
+ if (splitCDATASections) {
+ buf.push(g.CDATA_START, n.data.replace(/]]>/g, ']]]]>'), g.CDATA_END);
+ } else {
+ buf.push(g.CDATA_START, n.data, g.CDATA_END);
+ }
+ return null;
+ case COMMENT_NODE:
+ if (requireWellFormed) {
+ if (g.InvalidChar.test(n.data)) {
+ throw new DOMException(
+ 'The comment node data contains characters outside the XML Char production',
+ DOMExceptionName.InvalidStateError
+ );
+ }
+ if (n.data.indexOf('--') !== -1 || n.data[n.data.length - 1] === '-') {
+ throw new DOMException(
+ 'The comment node data contains "--" or ends with "-"',
+ DOMExceptionName.InvalidStateError
+ );
+ }
+ }
+ buf.push(g.COMMENT_START, n.data, g.COMMENT_END);
+ return null;
+ case DOCUMENT_TYPE_NODE:
+ var pubid = n.publicId;
+ var sysid = n.systemId;
+ if (requireWellFormed) {
+ if (pubid && !g.PubidLiteral_match.test(pubid)) {
+ throw new DOMException('DocumentType publicId is not a valid PubidLiteral', DOMExceptionName.InvalidStateError);
+ }
+ if (sysid && sysid !== '.' && !g.SystemLiteral_match.test(sysid)) {
+ throw new DOMException('DocumentType systemId is not a valid SystemLiteral', DOMExceptionName.InvalidStateError);
+ }
+ if (n.internalSubset && n.internalSubset.indexOf(']>') !== -1) {
+ throw new DOMException('DocumentType internalSubset contains "]>"', DOMExceptionName.InvalidStateError);
+ }
+ }
+ buf.push(g.DOCTYPE_DECL_START, ' ', n.name);
+ if (pubid) {
+ buf.push(' ', g.PUBLIC, ' ', pubid);
+ if (sysid && sysid !== '.') {
+ buf.push(' ', sysid);
+ }
+ } else if (sysid && sysid !== '.') {
+ buf.push(' ', g.SYSTEM, ' ', sysid);
+ }
+ if (n.internalSubset) {
+ buf.push(' [', n.internalSubset, ']');
+ }
+ buf.push('>');
+ return null;
+ case PROCESSING_INSTRUCTION_NODE:
+ if (requireWellFormed) {
+ if (n.target.indexOf(':') !== -1 || n.target.toLowerCase() === 'xml') {
+ throw new DOMException('The ProcessingInstruction target is not well-formed', DOMExceptionName.InvalidStateError);
+ }
+ if (g.InvalidChar.test(n.data)) {
+ throw new DOMException(
+ 'The ProcessingInstruction data contains characters outside the XML Char production',
+ DOMExceptionName.InvalidStateError
+ );
+ }
+ if (n.data.indexOf('?>') !== -1) {
+ throw new DOMException('The ProcessingInstruction data contains "?>"', DOMExceptionName.InvalidStateError);
+ }
+ }
+ buf.push('', n.target, ' ', n.data, '?>');
+ return null;
+ case ENTITY_REFERENCE_NODE:
+ buf.push('&', n.nodeName, ';');
+ return null;
+ //case ENTITY_NODE:
+ //case NOTATION_NODE:
+ default:
+ buf.push('??', n.nodeName);
+ return null;
+ }
+ },
+ exit: function (n, childCtx) {
+ // Emit the closing tag for elements that were opened (not self-closed, not raw text).
+ if (childCtx && childCtx.tag) {
+ buf.push('', childCtx.tag, '>');
+ }
+ },
+ }
+ );
+}
+/**
+ * Imports a node from a different document into `doc`, creating a new copy.
+ * Delegates to {@link walkDOM} for traversal. Each node in the subtree is shallow-cloned,
+ * stamped with `doc` as its `ownerDocument`, and detached (`parentNode` set to `null`).
+ * Children are imported recursively when `deep` is `true`; for {@link Attr} nodes `deep` is
+ * always forced to `true`
+ * because an attribute's value lives in a child text node.
+ *
+ * @param {Document} doc
+ * The document that will own the imported node.
+ * @param {Node} node
+ * The node to import.
+ * @param {boolean} deep
+ * If `true`, descendants are imported recursively.
+ * @returns {Node}
+ * The newly imported node, now owned by `doc`.
+ */
+function importNode(doc, node, deep) {
+ var destRoot;
+ walkDOM(node, null, {
+ enter: function (srcNode, destParent) {
+ // Shallow-clone the node and stamp it into the target document.
+ var destNode = srcNode.cloneNode(false);
+ destNode.ownerDocument = doc;
+ destNode.parentNode = null;
+ // capture as the root of the imported subtree or attach to parent.
+ if (destParent === null) {
+ destRoot = destNode;
+ } else {
+ destParent.appendChild(destNode);
+ }
+ // ATTRIBUTE_NODE must always be imported deeply: its value lives in a child text node.
+ var shouldDeep = srcNode.nodeType === ATTRIBUTE_NODE || deep;
+ return shouldDeep ? destNode : null;
+ },
+ });
+ return destRoot;
+}
+
+/**
+ * Creates a copy of a node from an existing one.
+ *
+ * @param {Document} doc
+ * The Document object representing the document that the new node will belong to.
+ * @param {Node} node
+ * The node to clone.
+ * @param {boolean} deep
+ * If true, the contents of the node are recursively copied.
+ * If false, only the node itself (and its attributes, if it is an element) are copied.
+ * @returns {Node}
+ * Returns the newly created copy of the node.
+ * @throws {DOMException}
+ * May throw a DOMException if operations within setAttributeNode or appendChild (which are
+ * potentially invoked in this function) do not meet their specific constraints.
+ */
+function cloneNode(doc, node, deep) {
+ var destRoot;
+ walkDOM(node, null, {
+ enter: function (srcNode, destParent) {
+ // 1. Create a blank node of the same type and copy all scalar own properties.
+ var destNode = new srcNode.constructor(PDC);
+ for (var n in srcNode) {
+ if (hasOwn(srcNode, n)) {
+ var v = srcNode[n];
+ if (typeof v != 'object') {
+ if (v != destNode[n]) {
+ destNode[n] = v;
+ }
+ }
+ }
+ }
+ if (srcNode.childNodes) {
+ destNode.childNodes = new NodeList();
+ }
+ destNode.ownerDocument = doc;
+ // 2. Handle node-type-specific setup.
+ // Attributes are not DOM children, so they are cloned inline here
+ // rather than by walkDOM descent.
+ // ATTRIBUTE_NODE forces deep=true so its own children are walked.
+ var shouldDeep = deep;
+ switch (destNode.nodeType) {
+ case ELEMENT_NODE:
+ var attrs = srcNode.attributes;
+ var attrs2 = (destNode.attributes = new NamedNodeMap());
+ var len = attrs.length;
+ attrs2._ownerElement = destNode;
+ for (var i = 0; i < len; i++) {
+ destNode.setAttributeNode(cloneNode(doc, attrs.item(i), true));
+ }
+ break;
+ case ATTRIBUTE_NODE:
+ shouldDeep = true;
+ }
+ // 3. Attach to parent, or capture as the root of the cloned subtree.
+ if (destParent !== null) {
+ destParent.appendChild(destNode);
+ } else {
+ destRoot = destNode;
+ }
+ // 4. Return destNode as the context for children (causes walkDOM to descend),
+ // or null to skip children (shallow clone).
+ return shouldDeep ? destNode : null;
+ },
+ });
+ return destRoot;
+}
+
+function __set__(object, key, value) {
+ object[key] = value;
+}
+
+// Returns a new array of direct Element children.
+// Passed to LiveNodeList to implement ParentNode.children.
+// https://dom.spec.whatwg.org/#dom-parentnode-children
+function childrenRefresh(node) {
+ var ls = [];
+ var child = node.firstChild;
+ while (child) {
+ if (child.nodeType === ELEMENT_NODE) {
+ ls.push(child);
+ }
+ child = child.nextSibling;
+ }
+ return ls;
+}
+
+//do dynamic
+try {
+ if (Object.defineProperty) {
+ Object.defineProperty(LiveNodeList.prototype, 'length', {
+ get: function () {
+ _updateLiveList(this);
+ return this.$$length;
+ },
+ });
+
+ /**
+ * The text content of this node and its descendants.
+ *
+ * For {@link Element} and {@link DocumentFragment} nodes, returns the concatenation of the
+ * `nodeValue` of every descendant text node, excluding processing instruction and comment
+ * nodes. For all other node types, returns `nodeValue`.
+ *
+ * Setting `textContent` on an element or document fragment replaces all child nodes with a
+ * single text node; on other nodes it sets `data`, `value`, and `nodeValue` directly.
+ *
+ * @type {string | null}
+ * @see {@link https://dom.spec.whatwg.org/#dom-node-textcontent}
+ */
+ Object.defineProperty(Node.prototype, 'textContent', {
+ get: function () {
+ if (this.nodeType === ELEMENT_NODE || this.nodeType === DOCUMENT_FRAGMENT_NODE) {
+ var buf = [];
+ walkDOM(this, null, {
+ enter: function (n) {
+ if (n.nodeType === ELEMENT_NODE || n.nodeType === DOCUMENT_FRAGMENT_NODE) {
+ return true; // enter children
+ }
+ if (n.nodeType === PROCESSING_INSTRUCTION_NODE || n.nodeType === COMMENT_NODE) {
+ return null; // excluded from text content
+ }
+ buf.push(n.nodeValue);
+ },
+ });
+ return buf.join('');
+ }
+ return this.nodeValue;
+ },
+
+ set: function (data) {
+ switch (this.nodeType) {
+ case ELEMENT_NODE:
+ case DOCUMENT_FRAGMENT_NODE:
+ while (this.firstChild) {
+ this.removeChild(this.firstChild);
+ }
+ if (data || String(data)) {
+ this.appendChild(this.ownerDocument.createTextNode(data));
+ }
+ break;
+
+ default:
+ this.data = data;
+ this.value = data;
+ this.nodeValue = data;
+ }
+ },
+ });
+
+ Object.defineProperty(Element.prototype, 'children', {
+ get: function () {
+ return new LiveNodeList(this, childrenRefresh);
+ },
+ });
+ Object.defineProperty(Document.prototype, 'children', {
+ get: function () {
+ return new LiveNodeList(this, childrenRefresh);
+ },
+ });
+ Object.defineProperty(DocumentFragment.prototype, 'children', {
+ get: function () {
+ return new LiveNodeList(this, childrenRefresh);
+ },
+ });
+
+ __set__ = function (object, key, value) {
+ //console.log(value)
+ object['$$' + key] = value;
+ };
+ }
+} catch (e) {
+ //ie8
+}
+
+exports._updateLiveList = _updateLiveList;
+exports.Attr = Attr;
+exports.CDATASection = CDATASection;
+exports.CharacterData = CharacterData;
+exports.Comment = Comment;
+exports.Document = Document;
+exports.DocumentFragment = DocumentFragment;
+exports.DocumentType = DocumentType;
+exports.DOMImplementation = DOMImplementation;
+exports.Element = Element;
+exports.Entity = Entity;
+exports.EntityReference = EntityReference;
+exports.LiveNodeList = LiveNodeList;
+exports.NamedNodeMap = NamedNodeMap;
+exports.Node = Node;
+exports.NodeList = NodeList;
+exports.Notation = Notation;
+exports.Text = Text;
+exports.ProcessingInstruction = ProcessingInstruction;
+exports.walkDOM = walkDOM;
+exports.XMLSerializer = XMLSerializer;
+
+},{"./conventions":4,"./errors":8,"./grammar":9}],7:[function(require,module,exports){
+'use strict';
+
+var freeze = require('./conventions').freeze;
+
+/**
+ * The entities that are predefined in every XML document.
+ *
+ * @see https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-predefined-ent W3C XML 1.1
+ * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0
+ * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML
+ * Wikipedia
+ */
+exports.XML_ENTITIES = freeze({
+ amp: '&',
+ apos: "'",
+ gt: '>',
+ lt: '<',
+ quot: '"',
+});
+
+/**
+ * A map of all entities that are detected in an HTML document.
+ * They contain all entries from `XML_ENTITIES`.
+ *
+ * @see {@link XML_ENTITIES}
+ * @see {@link DOMParser.parseFromString}
+ * @see {@link DOMImplementation.prototype.createHTMLDocument}
+ * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5)
+ * Spec
+ * @see https://html.spec.whatwg.org/entities.json JSON
+ * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names
+ * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML
+ * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML
+ * Wikipedia (HTML)
+ * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML
+ * Wikpedia (XHTML)
+ */
+exports.HTML_ENTITIES = freeze({
+ Aacute: '\u00C1',
+ aacute: '\u00E1',
+ Abreve: '\u0102',
+ abreve: '\u0103',
+ ac: '\u223E',
+ acd: '\u223F',
+ acE: '\u223E\u0333',
+ Acirc: '\u00C2',
+ acirc: '\u00E2',
+ acute: '\u00B4',
+ Acy: '\u0410',
+ acy: '\u0430',
+ AElig: '\u00C6',
+ aelig: '\u00E6',
+ af: '\u2061',
+ Afr: '\uD835\uDD04',
+ afr: '\uD835\uDD1E',
+ Agrave: '\u00C0',
+ agrave: '\u00E0',
+ alefsym: '\u2135',
+ aleph: '\u2135',
+ Alpha: '\u0391',
+ alpha: '\u03B1',
+ Amacr: '\u0100',
+ amacr: '\u0101',
+ amalg: '\u2A3F',
+ AMP: '\u0026',
+ amp: '\u0026',
+ And: '\u2A53',
+ and: '\u2227',
+ andand: '\u2A55',
+ andd: '\u2A5C',
+ andslope: '\u2A58',
+ andv: '\u2A5A',
+ ang: '\u2220',
+ ange: '\u29A4',
+ angle: '\u2220',
+ angmsd: '\u2221',
+ angmsdaa: '\u29A8',
+ angmsdab: '\u29A9',
+ angmsdac: '\u29AA',
+ angmsdad: '\u29AB',
+ angmsdae: '\u29AC',
+ angmsdaf: '\u29AD',
+ angmsdag: '\u29AE',
+ angmsdah: '\u29AF',
+ angrt: '\u221F',
+ angrtvb: '\u22BE',
+ angrtvbd: '\u299D',
+ angsph: '\u2222',
+ angst: '\u00C5',
+ angzarr: '\u237C',
+ Aogon: '\u0104',
+ aogon: '\u0105',
+ Aopf: '\uD835\uDD38',
+ aopf: '\uD835\uDD52',
+ ap: '\u2248',
+ apacir: '\u2A6F',
+ apE: '\u2A70',
+ ape: '\u224A',
+ apid: '\u224B',
+ apos: '\u0027',
+ ApplyFunction: '\u2061',
+ approx: '\u2248',
+ approxeq: '\u224A',
+ Aring: '\u00C5',
+ aring: '\u00E5',
+ Ascr: '\uD835\uDC9C',
+ ascr: '\uD835\uDCB6',
+ Assign: '\u2254',
+ ast: '\u002A',
+ asymp: '\u2248',
+ asympeq: '\u224D',
+ Atilde: '\u00C3',
+ atilde: '\u00E3',
+ Auml: '\u00C4',
+ auml: '\u00E4',
+ awconint: '\u2233',
+ awint: '\u2A11',
+ backcong: '\u224C',
+ backepsilon: '\u03F6',
+ backprime: '\u2035',
+ backsim: '\u223D',
+ backsimeq: '\u22CD',
+ Backslash: '\u2216',
+ Barv: '\u2AE7',
+ barvee: '\u22BD',
+ Barwed: '\u2306',
+ barwed: '\u2305',
+ barwedge: '\u2305',
+ bbrk: '\u23B5',
+ bbrktbrk: '\u23B6',
+ bcong: '\u224C',
+ Bcy: '\u0411',
+ bcy: '\u0431',
+ bdquo: '\u201E',
+ becaus: '\u2235',
+ Because: '\u2235',
+ because: '\u2235',
+ bemptyv: '\u29B0',
+ bepsi: '\u03F6',
+ bernou: '\u212C',
+ Bernoullis: '\u212C',
+ Beta: '\u0392',
+ beta: '\u03B2',
+ beth: '\u2136',
+ between: '\u226C',
+ Bfr: '\uD835\uDD05',
+ bfr: '\uD835\uDD1F',
+ bigcap: '\u22C2',
+ bigcirc: '\u25EF',
+ bigcup: '\u22C3',
+ bigodot: '\u2A00',
+ bigoplus: '\u2A01',
+ bigotimes: '\u2A02',
+ bigsqcup: '\u2A06',
+ bigstar: '\u2605',
+ bigtriangledown: '\u25BD',
+ bigtriangleup: '\u25B3',
+ biguplus: '\u2A04',
+ bigvee: '\u22C1',
+ bigwedge: '\u22C0',
+ bkarow: '\u290D',
+ blacklozenge: '\u29EB',
+ blacksquare: '\u25AA',
+ blacktriangle: '\u25B4',
+ blacktriangledown: '\u25BE',
+ blacktriangleleft: '\u25C2',
+ blacktriangleright: '\u25B8',
+ blank: '\u2423',
+ blk12: '\u2592',
+ blk14: '\u2591',
+ blk34: '\u2593',
+ block: '\u2588',
+ bne: '\u003D\u20E5',
+ bnequiv: '\u2261\u20E5',
+ bNot: '\u2AED',
+ bnot: '\u2310',
+ Bopf: '\uD835\uDD39',
+ bopf: '\uD835\uDD53',
+ bot: '\u22A5',
+ bottom: '\u22A5',
+ bowtie: '\u22C8',
+ boxbox: '\u29C9',
+ boxDL: '\u2557',
+ boxDl: '\u2556',
+ boxdL: '\u2555',
+ boxdl: '\u2510',
+ boxDR: '\u2554',
+ boxDr: '\u2553',
+ boxdR: '\u2552',
+ boxdr: '\u250C',
+ boxH: '\u2550',
+ boxh: '\u2500',
+ boxHD: '\u2566',
+ boxHd: '\u2564',
+ boxhD: '\u2565',
+ boxhd: '\u252C',
+ boxHU: '\u2569',
+ boxHu: '\u2567',
+ boxhU: '\u2568',
+ boxhu: '\u2534',
+ boxminus: '\u229F',
+ boxplus: '\u229E',
+ boxtimes: '\u22A0',
+ boxUL: '\u255D',
+ boxUl: '\u255C',
+ boxuL: '\u255B',
+ boxul: '\u2518',
+ boxUR: '\u255A',
+ boxUr: '\u2559',
+ boxuR: '\u2558',
+ boxur: '\u2514',
+ boxV: '\u2551',
+ boxv: '\u2502',
+ boxVH: '\u256C',
+ boxVh: '\u256B',
+ boxvH: '\u256A',
+ boxvh: '\u253C',
+ boxVL: '\u2563',
+ boxVl: '\u2562',
+ boxvL: '\u2561',
+ boxvl: '\u2524',
+ boxVR: '\u2560',
+ boxVr: '\u255F',
+ boxvR: '\u255E',
+ boxvr: '\u251C',
+ bprime: '\u2035',
+ Breve: '\u02D8',
+ breve: '\u02D8',
+ brvbar: '\u00A6',
+ Bscr: '\u212C',
+ bscr: '\uD835\uDCB7',
+ bsemi: '\u204F',
+ bsim: '\u223D',
+ bsime: '\u22CD',
+ bsol: '\u005C',
+ bsolb: '\u29C5',
+ bsolhsub: '\u27C8',
+ bull: '\u2022',
+ bullet: '\u2022',
+ bump: '\u224E',
+ bumpE: '\u2AAE',
+ bumpe: '\u224F',
+ Bumpeq: '\u224E',
+ bumpeq: '\u224F',
+ Cacute: '\u0106',
+ cacute: '\u0107',
+ Cap: '\u22D2',
+ cap: '\u2229',
+ capand: '\u2A44',
+ capbrcup: '\u2A49',
+ capcap: '\u2A4B',
+ capcup: '\u2A47',
+ capdot: '\u2A40',
+ CapitalDifferentialD: '\u2145',
+ caps: '\u2229\uFE00',
+ caret: '\u2041',
+ caron: '\u02C7',
+ Cayleys: '\u212D',
+ ccaps: '\u2A4D',
+ Ccaron: '\u010C',
+ ccaron: '\u010D',
+ Ccedil: '\u00C7',
+ ccedil: '\u00E7',
+ Ccirc: '\u0108',
+ ccirc: '\u0109',
+ Cconint: '\u2230',
+ ccups: '\u2A4C',
+ ccupssm: '\u2A50',
+ Cdot: '\u010A',
+ cdot: '\u010B',
+ cedil: '\u00B8',
+ Cedilla: '\u00B8',
+ cemptyv: '\u29B2',
+ cent: '\u00A2',
+ CenterDot: '\u00B7',
+ centerdot: '\u00B7',
+ Cfr: '\u212D',
+ cfr: '\uD835\uDD20',
+ CHcy: '\u0427',
+ chcy: '\u0447',
+ check: '\u2713',
+ checkmark: '\u2713',
+ Chi: '\u03A7',
+ chi: '\u03C7',
+ cir: '\u25CB',
+ circ: '\u02C6',
+ circeq: '\u2257',
+ circlearrowleft: '\u21BA',
+ circlearrowright: '\u21BB',
+ circledast: '\u229B',
+ circledcirc: '\u229A',
+ circleddash: '\u229D',
+ CircleDot: '\u2299',
+ circledR: '\u00AE',
+ circledS: '\u24C8',
+ CircleMinus: '\u2296',
+ CirclePlus: '\u2295',
+ CircleTimes: '\u2297',
+ cirE: '\u29C3',
+ cire: '\u2257',
+ cirfnint: '\u2A10',
+ cirmid: '\u2AEF',
+ cirscir: '\u29C2',
+ ClockwiseContourIntegral: '\u2232',
+ CloseCurlyDoubleQuote: '\u201D',
+ CloseCurlyQuote: '\u2019',
+ clubs: '\u2663',
+ clubsuit: '\u2663',
+ Colon: '\u2237',
+ colon: '\u003A',
+ Colone: '\u2A74',
+ colone: '\u2254',
+ coloneq: '\u2254',
+ comma: '\u002C',
+ commat: '\u0040',
+ comp: '\u2201',
+ compfn: '\u2218',
+ complement: '\u2201',
+ complexes: '\u2102',
+ cong: '\u2245',
+ congdot: '\u2A6D',
+ Congruent: '\u2261',
+ Conint: '\u222F',
+ conint: '\u222E',
+ ContourIntegral: '\u222E',
+ Copf: '\u2102',
+ copf: '\uD835\uDD54',
+ coprod: '\u2210',
+ Coproduct: '\u2210',
+ COPY: '\u00A9',
+ copy: '\u00A9',
+ copysr: '\u2117',
+ CounterClockwiseContourIntegral: '\u2233',
+ crarr: '\u21B5',
+ Cross: '\u2A2F',
+ cross: '\u2717',
+ Cscr: '\uD835\uDC9E',
+ cscr: '\uD835\uDCB8',
+ csub: '\u2ACF',
+ csube: '\u2AD1',
+ csup: '\u2AD0',
+ csupe: '\u2AD2',
+ ctdot: '\u22EF',
+ cudarrl: '\u2938',
+ cudarrr: '\u2935',
+ cuepr: '\u22DE',
+ cuesc: '\u22DF',
+ cularr: '\u21B6',
+ cularrp: '\u293D',
+ Cup: '\u22D3',
+ cup: '\u222A',
+ cupbrcap: '\u2A48',
+ CupCap: '\u224D',
+ cupcap: '\u2A46',
+ cupcup: '\u2A4A',
+ cupdot: '\u228D',
+ cupor: '\u2A45',
+ cups: '\u222A\uFE00',
+ curarr: '\u21B7',
+ curarrm: '\u293C',
+ curlyeqprec: '\u22DE',
+ curlyeqsucc: '\u22DF',
+ curlyvee: '\u22CE',
+ curlywedge: '\u22CF',
+ curren: '\u00A4',
+ curvearrowleft: '\u21B6',
+ curvearrowright: '\u21B7',
+ cuvee: '\u22CE',
+ cuwed: '\u22CF',
+ cwconint: '\u2232',
+ cwint: '\u2231',
+ cylcty: '\u232D',
+ Dagger: '\u2021',
+ dagger: '\u2020',
+ daleth: '\u2138',
+ Darr: '\u21A1',
+ dArr: '\u21D3',
+ darr: '\u2193',
+ dash: '\u2010',
+ Dashv: '\u2AE4',
+ dashv: '\u22A3',
+ dbkarow: '\u290F',
+ dblac: '\u02DD',
+ Dcaron: '\u010E',
+ dcaron: '\u010F',
+ Dcy: '\u0414',
+ dcy: '\u0434',
+ DD: '\u2145',
+ dd: '\u2146',
+ ddagger: '\u2021',
+ ddarr: '\u21CA',
+ DDotrahd: '\u2911',
+ ddotseq: '\u2A77',
+ deg: '\u00B0',
+ Del: '\u2207',
+ Delta: '\u0394',
+ delta: '\u03B4',
+ demptyv: '\u29B1',
+ dfisht: '\u297F',
+ Dfr: '\uD835\uDD07',
+ dfr: '\uD835\uDD21',
+ dHar: '\u2965',
+ dharl: '\u21C3',
+ dharr: '\u21C2',
+ DiacriticalAcute: '\u00B4',
+ DiacriticalDot: '\u02D9',
+ DiacriticalDoubleAcute: '\u02DD',
+ DiacriticalGrave: '\u0060',
+ DiacriticalTilde: '\u02DC',
+ diam: '\u22C4',
+ Diamond: '\u22C4',
+ diamond: '\u22C4',
+ diamondsuit: '\u2666',
+ diams: '\u2666',
+ die: '\u00A8',
+ DifferentialD: '\u2146',
+ digamma: '\u03DD',
+ disin: '\u22F2',
+ div: '\u00F7',
+ divide: '\u00F7',
+ divideontimes: '\u22C7',
+ divonx: '\u22C7',
+ DJcy: '\u0402',
+ djcy: '\u0452',
+ dlcorn: '\u231E',
+ dlcrop: '\u230D',
+ dollar: '\u0024',
+ Dopf: '\uD835\uDD3B',
+ dopf: '\uD835\uDD55',
+ Dot: '\u00A8',
+ dot: '\u02D9',
+ DotDot: '\u20DC',
+ doteq: '\u2250',
+ doteqdot: '\u2251',
+ DotEqual: '\u2250',
+ dotminus: '\u2238',
+ dotplus: '\u2214',
+ dotsquare: '\u22A1',
+ doublebarwedge: '\u2306',
+ DoubleContourIntegral: '\u222F',
+ DoubleDot: '\u00A8',
+ DoubleDownArrow: '\u21D3',
+ DoubleLeftArrow: '\u21D0',
+ DoubleLeftRightArrow: '\u21D4',
+ DoubleLeftTee: '\u2AE4',
+ DoubleLongLeftArrow: '\u27F8',
+ DoubleLongLeftRightArrow: '\u27FA',
+ DoubleLongRightArrow: '\u27F9',
+ DoubleRightArrow: '\u21D2',
+ DoubleRightTee: '\u22A8',
+ DoubleUpArrow: '\u21D1',
+ DoubleUpDownArrow: '\u21D5',
+ DoubleVerticalBar: '\u2225',
+ DownArrow: '\u2193',
+ Downarrow: '\u21D3',
+ downarrow: '\u2193',
+ DownArrowBar: '\u2913',
+ DownArrowUpArrow: '\u21F5',
+ DownBreve: '\u0311',
+ downdownarrows: '\u21CA',
+ downharpoonleft: '\u21C3',
+ downharpoonright: '\u21C2',
+ DownLeftRightVector: '\u2950',
+ DownLeftTeeVector: '\u295E',
+ DownLeftVector: '\u21BD',
+ DownLeftVectorBar: '\u2956',
+ DownRightTeeVector: '\u295F',
+ DownRightVector: '\u21C1',
+ DownRightVectorBar: '\u2957',
+ DownTee: '\u22A4',
+ DownTeeArrow: '\u21A7',
+ drbkarow: '\u2910',
+ drcorn: '\u231F',
+ drcrop: '\u230C',
+ Dscr: '\uD835\uDC9F',
+ dscr: '\uD835\uDCB9',
+ DScy: '\u0405',
+ dscy: '\u0455',
+ dsol: '\u29F6',
+ Dstrok: '\u0110',
+ dstrok: '\u0111',
+ dtdot: '\u22F1',
+ dtri: '\u25BF',
+ dtrif: '\u25BE',
+ duarr: '\u21F5',
+ duhar: '\u296F',
+ dwangle: '\u29A6',
+ DZcy: '\u040F',
+ dzcy: '\u045F',
+ dzigrarr: '\u27FF',
+ Eacute: '\u00C9',
+ eacute: '\u00E9',
+ easter: '\u2A6E',
+ Ecaron: '\u011A',
+ ecaron: '\u011B',
+ ecir: '\u2256',
+ Ecirc: '\u00CA',
+ ecirc: '\u00EA',
+ ecolon: '\u2255',
+ Ecy: '\u042D',
+ ecy: '\u044D',
+ eDDot: '\u2A77',
+ Edot: '\u0116',
+ eDot: '\u2251',
+ edot: '\u0117',
+ ee: '\u2147',
+ efDot: '\u2252',
+ Efr: '\uD835\uDD08',
+ efr: '\uD835\uDD22',
+ eg: '\u2A9A',
+ Egrave: '\u00C8',
+ egrave: '\u00E8',
+ egs: '\u2A96',
+ egsdot: '\u2A98',
+ el: '\u2A99',
+ Element: '\u2208',
+ elinters: '\u23E7',
+ ell: '\u2113',
+ els: '\u2A95',
+ elsdot: '\u2A97',
+ Emacr: '\u0112',
+ emacr: '\u0113',
+ empty: '\u2205',
+ emptyset: '\u2205',
+ EmptySmallSquare: '\u25FB',
+ emptyv: '\u2205',
+ EmptyVerySmallSquare: '\u25AB',
+ emsp: '\u2003',
+ emsp13: '\u2004',
+ emsp14: '\u2005',
+ ENG: '\u014A',
+ eng: '\u014B',
+ ensp: '\u2002',
+ Eogon: '\u0118',
+ eogon: '\u0119',
+ Eopf: '\uD835\uDD3C',
+ eopf: '\uD835\uDD56',
+ epar: '\u22D5',
+ eparsl: '\u29E3',
+ eplus: '\u2A71',
+ epsi: '\u03B5',
+ Epsilon: '\u0395',
+ epsilon: '\u03B5',
+ epsiv: '\u03F5',
+ eqcirc: '\u2256',
+ eqcolon: '\u2255',
+ eqsim: '\u2242',
+ eqslantgtr: '\u2A96',
+ eqslantless: '\u2A95',
+ Equal: '\u2A75',
+ equals: '\u003D',
+ EqualTilde: '\u2242',
+ equest: '\u225F',
+ Equilibrium: '\u21CC',
+ equiv: '\u2261',
+ equivDD: '\u2A78',
+ eqvparsl: '\u29E5',
+ erarr: '\u2971',
+ erDot: '\u2253',
+ Escr: '\u2130',
+ escr: '\u212F',
+ esdot: '\u2250',
+ Esim: '\u2A73',
+ esim: '\u2242',
+ Eta: '\u0397',
+ eta: '\u03B7',
+ ETH: '\u00D0',
+ eth: '\u00F0',
+ Euml: '\u00CB',
+ euml: '\u00EB',
+ euro: '\u20AC',
+ excl: '\u0021',
+ exist: '\u2203',
+ Exists: '\u2203',
+ expectation: '\u2130',
+ ExponentialE: '\u2147',
+ exponentiale: '\u2147',
+ fallingdotseq: '\u2252',
+ Fcy: '\u0424',
+ fcy: '\u0444',
+ female: '\u2640',
+ ffilig: '\uFB03',
+ fflig: '\uFB00',
+ ffllig: '\uFB04',
+ Ffr: '\uD835\uDD09',
+ ffr: '\uD835\uDD23',
+ filig: '\uFB01',
+ FilledSmallSquare: '\u25FC',
+ FilledVerySmallSquare: '\u25AA',
+ fjlig: '\u0066\u006A',
+ flat: '\u266D',
+ fllig: '\uFB02',
+ fltns: '\u25B1',
+ fnof: '\u0192',
+ Fopf: '\uD835\uDD3D',
+ fopf: '\uD835\uDD57',
+ ForAll: '\u2200',
+ forall: '\u2200',
+ fork: '\u22D4',
+ forkv: '\u2AD9',
+ Fouriertrf: '\u2131',
+ fpartint: '\u2A0D',
+ frac12: '\u00BD',
+ frac13: '\u2153',
+ frac14: '\u00BC',
+ frac15: '\u2155',
+ frac16: '\u2159',
+ frac18: '\u215B',
+ frac23: '\u2154',
+ frac25: '\u2156',
+ frac34: '\u00BE',
+ frac35: '\u2157',
+ frac38: '\u215C',
+ frac45: '\u2158',
+ frac56: '\u215A',
+ frac58: '\u215D',
+ frac78: '\u215E',
+ frasl: '\u2044',
+ frown: '\u2322',
+ Fscr: '\u2131',
+ fscr: '\uD835\uDCBB',
+ gacute: '\u01F5',
+ Gamma: '\u0393',
+ gamma: '\u03B3',
+ Gammad: '\u03DC',
+ gammad: '\u03DD',
+ gap: '\u2A86',
+ Gbreve: '\u011E',
+ gbreve: '\u011F',
+ Gcedil: '\u0122',
+ Gcirc: '\u011C',
+ gcirc: '\u011D',
+ Gcy: '\u0413',
+ gcy: '\u0433',
+ Gdot: '\u0120',
+ gdot: '\u0121',
+ gE: '\u2267',
+ ge: '\u2265',
+ gEl: '\u2A8C',
+ gel: '\u22DB',
+ geq: '\u2265',
+ geqq: '\u2267',
+ geqslant: '\u2A7E',
+ ges: '\u2A7E',
+ gescc: '\u2AA9',
+ gesdot: '\u2A80',
+ gesdoto: '\u2A82',
+ gesdotol: '\u2A84',
+ gesl: '\u22DB\uFE00',
+ gesles: '\u2A94',
+ Gfr: '\uD835\uDD0A',
+ gfr: '\uD835\uDD24',
+ Gg: '\u22D9',
+ gg: '\u226B',
+ ggg: '\u22D9',
+ gimel: '\u2137',
+ GJcy: '\u0403',
+ gjcy: '\u0453',
+ gl: '\u2277',
+ gla: '\u2AA5',
+ glE: '\u2A92',
+ glj: '\u2AA4',
+ gnap: '\u2A8A',
+ gnapprox: '\u2A8A',
+ gnE: '\u2269',
+ gne: '\u2A88',
+ gneq: '\u2A88',
+ gneqq: '\u2269',
+ gnsim: '\u22E7',
+ Gopf: '\uD835\uDD3E',
+ gopf: '\uD835\uDD58',
+ grave: '\u0060',
+ GreaterEqual: '\u2265',
+ GreaterEqualLess: '\u22DB',
+ GreaterFullEqual: '\u2267',
+ GreaterGreater: '\u2AA2',
+ GreaterLess: '\u2277',
+ GreaterSlantEqual: '\u2A7E',
+ GreaterTilde: '\u2273',
+ Gscr: '\uD835\uDCA2',
+ gscr: '\u210A',
+ gsim: '\u2273',
+ gsime: '\u2A8E',
+ gsiml: '\u2A90',
+ Gt: '\u226B',
+ GT: '\u003E',
+ gt: '\u003E',
+ gtcc: '\u2AA7',
+ gtcir: '\u2A7A',
+ gtdot: '\u22D7',
+ gtlPar: '\u2995',
+ gtquest: '\u2A7C',
+ gtrapprox: '\u2A86',
+ gtrarr: '\u2978',
+ gtrdot: '\u22D7',
+ gtreqless: '\u22DB',
+ gtreqqless: '\u2A8C',
+ gtrless: '\u2277',
+ gtrsim: '\u2273',
+ gvertneqq: '\u2269\uFE00',
+ gvnE: '\u2269\uFE00',
+ Hacek: '\u02C7',
+ hairsp: '\u200A',
+ half: '\u00BD',
+ hamilt: '\u210B',
+ HARDcy: '\u042A',
+ hardcy: '\u044A',
+ hArr: '\u21D4',
+ harr: '\u2194',
+ harrcir: '\u2948',
+ harrw: '\u21AD',
+ Hat: '\u005E',
+ hbar: '\u210F',
+ Hcirc: '\u0124',
+ hcirc: '\u0125',
+ hearts: '\u2665',
+ heartsuit: '\u2665',
+ hellip: '\u2026',
+ hercon: '\u22B9',
+ Hfr: '\u210C',
+ hfr: '\uD835\uDD25',
+ HilbertSpace: '\u210B',
+ hksearow: '\u2925',
+ hkswarow: '\u2926',
+ hoarr: '\u21FF',
+ homtht: '\u223B',
+ hookleftarrow: '\u21A9',
+ hookrightarrow: '\u21AA',
+ Hopf: '\u210D',
+ hopf: '\uD835\uDD59',
+ horbar: '\u2015',
+ HorizontalLine: '\u2500',
+ Hscr: '\u210B',
+ hscr: '\uD835\uDCBD',
+ hslash: '\u210F',
+ Hstrok: '\u0126',
+ hstrok: '\u0127',
+ HumpDownHump: '\u224E',
+ HumpEqual: '\u224F',
+ hybull: '\u2043',
+ hyphen: '\u2010',
+ Iacute: '\u00CD',
+ iacute: '\u00ED',
+ ic: '\u2063',
+ Icirc: '\u00CE',
+ icirc: '\u00EE',
+ Icy: '\u0418',
+ icy: '\u0438',
+ Idot: '\u0130',
+ IEcy: '\u0415',
+ iecy: '\u0435',
+ iexcl: '\u00A1',
+ iff: '\u21D4',
+ Ifr: '\u2111',
+ ifr: '\uD835\uDD26',
+ Igrave: '\u00CC',
+ igrave: '\u00EC',
+ ii: '\u2148',
+ iiiint: '\u2A0C',
+ iiint: '\u222D',
+ iinfin: '\u29DC',
+ iiota: '\u2129',
+ IJlig: '\u0132',
+ ijlig: '\u0133',
+ Im: '\u2111',
+ Imacr: '\u012A',
+ imacr: '\u012B',
+ image: '\u2111',
+ ImaginaryI: '\u2148',
+ imagline: '\u2110',
+ imagpart: '\u2111',
+ imath: '\u0131',
+ imof: '\u22B7',
+ imped: '\u01B5',
+ Implies: '\u21D2',
+ in: '\u2208',
+ incare: '\u2105',
+ infin: '\u221E',
+ infintie: '\u29DD',
+ inodot: '\u0131',
+ Int: '\u222C',
+ int: '\u222B',
+ intcal: '\u22BA',
+ integers: '\u2124',
+ Integral: '\u222B',
+ intercal: '\u22BA',
+ Intersection: '\u22C2',
+ intlarhk: '\u2A17',
+ intprod: '\u2A3C',
+ InvisibleComma: '\u2063',
+ InvisibleTimes: '\u2062',
+ IOcy: '\u0401',
+ iocy: '\u0451',
+ Iogon: '\u012E',
+ iogon: '\u012F',
+ Iopf: '\uD835\uDD40',
+ iopf: '\uD835\uDD5A',
+ Iota: '\u0399',
+ iota: '\u03B9',
+ iprod: '\u2A3C',
+ iquest: '\u00BF',
+ Iscr: '\u2110',
+ iscr: '\uD835\uDCBE',
+ isin: '\u2208',
+ isindot: '\u22F5',
+ isinE: '\u22F9',
+ isins: '\u22F4',
+ isinsv: '\u22F3',
+ isinv: '\u2208',
+ it: '\u2062',
+ Itilde: '\u0128',
+ itilde: '\u0129',
+ Iukcy: '\u0406',
+ iukcy: '\u0456',
+ Iuml: '\u00CF',
+ iuml: '\u00EF',
+ Jcirc: '\u0134',
+ jcirc: '\u0135',
+ Jcy: '\u0419',
+ jcy: '\u0439',
+ Jfr: '\uD835\uDD0D',
+ jfr: '\uD835\uDD27',
+ jmath: '\u0237',
+ Jopf: '\uD835\uDD41',
+ jopf: '\uD835\uDD5B',
+ Jscr: '\uD835\uDCA5',
+ jscr: '\uD835\uDCBF',
+ Jsercy: '\u0408',
+ jsercy: '\u0458',
+ Jukcy: '\u0404',
+ jukcy: '\u0454',
+ Kappa: '\u039A',
+ kappa: '\u03BA',
+ kappav: '\u03F0',
+ Kcedil: '\u0136',
+ kcedil: '\u0137',
+ Kcy: '\u041A',
+ kcy: '\u043A',
+ Kfr: '\uD835\uDD0E',
+ kfr: '\uD835\uDD28',
+ kgreen: '\u0138',
+ KHcy: '\u0425',
+ khcy: '\u0445',
+ KJcy: '\u040C',
+ kjcy: '\u045C',
+ Kopf: '\uD835\uDD42',
+ kopf: '\uD835\uDD5C',
+ Kscr: '\uD835\uDCA6',
+ kscr: '\uD835\uDCC0',
+ lAarr: '\u21DA',
+ Lacute: '\u0139',
+ lacute: '\u013A',
+ laemptyv: '\u29B4',
+ lagran: '\u2112',
+ Lambda: '\u039B',
+ lambda: '\u03BB',
+ Lang: '\u27EA',
+ lang: '\u27E8',
+ langd: '\u2991',
+ langle: '\u27E8',
+ lap: '\u2A85',
+ Laplacetrf: '\u2112',
+ laquo: '\u00AB',
+ Larr: '\u219E',
+ lArr: '\u21D0',
+ larr: '\u2190',
+ larrb: '\u21E4',
+ larrbfs: '\u291F',
+ larrfs: '\u291D',
+ larrhk: '\u21A9',
+ larrlp: '\u21AB',
+ larrpl: '\u2939',
+ larrsim: '\u2973',
+ larrtl: '\u21A2',
+ lat: '\u2AAB',
+ lAtail: '\u291B',
+ latail: '\u2919',
+ late: '\u2AAD',
+ lates: '\u2AAD\uFE00',
+ lBarr: '\u290E',
+ lbarr: '\u290C',
+ lbbrk: '\u2772',
+ lbrace: '\u007B',
+ lbrack: '\u005B',
+ lbrke: '\u298B',
+ lbrksld: '\u298F',
+ lbrkslu: '\u298D',
+ Lcaron: '\u013D',
+ lcaron: '\u013E',
+ Lcedil: '\u013B',
+ lcedil: '\u013C',
+ lceil: '\u2308',
+ lcub: '\u007B',
+ Lcy: '\u041B',
+ lcy: '\u043B',
+ ldca: '\u2936',
+ ldquo: '\u201C',
+ ldquor: '\u201E',
+ ldrdhar: '\u2967',
+ ldrushar: '\u294B',
+ ldsh: '\u21B2',
+ lE: '\u2266',
+ le: '\u2264',
+ LeftAngleBracket: '\u27E8',
+ LeftArrow: '\u2190',
+ Leftarrow: '\u21D0',
+ leftarrow: '\u2190',
+ LeftArrowBar: '\u21E4',
+ LeftArrowRightArrow: '\u21C6',
+ leftarrowtail: '\u21A2',
+ LeftCeiling: '\u2308',
+ LeftDoubleBracket: '\u27E6',
+ LeftDownTeeVector: '\u2961',
+ LeftDownVector: '\u21C3',
+ LeftDownVectorBar: '\u2959',
+ LeftFloor: '\u230A',
+ leftharpoondown: '\u21BD',
+ leftharpoonup: '\u21BC',
+ leftleftarrows: '\u21C7',
+ LeftRightArrow: '\u2194',
+ Leftrightarrow: '\u21D4',
+ leftrightarrow: '\u2194',
+ leftrightarrows: '\u21C6',
+ leftrightharpoons: '\u21CB',
+ leftrightsquigarrow: '\u21AD',
+ LeftRightVector: '\u294E',
+ LeftTee: '\u22A3',
+ LeftTeeArrow: '\u21A4',
+ LeftTeeVector: '\u295A',
+ leftthreetimes: '\u22CB',
+ LeftTriangle: '\u22B2',
+ LeftTriangleBar: '\u29CF',
+ LeftTriangleEqual: '\u22B4',
+ LeftUpDownVector: '\u2951',
+ LeftUpTeeVector: '\u2960',
+ LeftUpVector: '\u21BF',
+ LeftUpVectorBar: '\u2958',
+ LeftVector: '\u21BC',
+ LeftVectorBar: '\u2952',
+ lEg: '\u2A8B',
+ leg: '\u22DA',
+ leq: '\u2264',
+ leqq: '\u2266',
+ leqslant: '\u2A7D',
+ les: '\u2A7D',
+ lescc: '\u2AA8',
+ lesdot: '\u2A7F',
+ lesdoto: '\u2A81',
+ lesdotor: '\u2A83',
+ lesg: '\u22DA\uFE00',
+ lesges: '\u2A93',
+ lessapprox: '\u2A85',
+ lessdot: '\u22D6',
+ lesseqgtr: '\u22DA',
+ lesseqqgtr: '\u2A8B',
+ LessEqualGreater: '\u22DA',
+ LessFullEqual: '\u2266',
+ LessGreater: '\u2276',
+ lessgtr: '\u2276',
+ LessLess: '\u2AA1',
+ lesssim: '\u2272',
+ LessSlantEqual: '\u2A7D',
+ LessTilde: '\u2272',
+ lfisht: '\u297C',
+ lfloor: '\u230A',
+ Lfr: '\uD835\uDD0F',
+ lfr: '\uD835\uDD29',
+ lg: '\u2276',
+ lgE: '\u2A91',
+ lHar: '\u2962',
+ lhard: '\u21BD',
+ lharu: '\u21BC',
+ lharul: '\u296A',
+ lhblk: '\u2584',
+ LJcy: '\u0409',
+ ljcy: '\u0459',
+ Ll: '\u22D8',
+ ll: '\u226A',
+ llarr: '\u21C7',
+ llcorner: '\u231E',
+ Lleftarrow: '\u21DA',
+ llhard: '\u296B',
+ lltri: '\u25FA',
+ Lmidot: '\u013F',
+ lmidot: '\u0140',
+ lmoust: '\u23B0',
+ lmoustache: '\u23B0',
+ lnap: '\u2A89',
+ lnapprox: '\u2A89',
+ lnE: '\u2268',
+ lne: '\u2A87',
+ lneq: '\u2A87',
+ lneqq: '\u2268',
+ lnsim: '\u22E6',
+ loang: '\u27EC',
+ loarr: '\u21FD',
+ lobrk: '\u27E6',
+ LongLeftArrow: '\u27F5',
+ Longleftarrow: '\u27F8',
+ longleftarrow: '\u27F5',
+ LongLeftRightArrow: '\u27F7',
+ Longleftrightarrow: '\u27FA',
+ longleftrightarrow: '\u27F7',
+ longmapsto: '\u27FC',
+ LongRightArrow: '\u27F6',
+ Longrightarrow: '\u27F9',
+ longrightarrow: '\u27F6',
+ looparrowleft: '\u21AB',
+ looparrowright: '\u21AC',
+ lopar: '\u2985',
+ Lopf: '\uD835\uDD43',
+ lopf: '\uD835\uDD5D',
+ loplus: '\u2A2D',
+ lotimes: '\u2A34',
+ lowast: '\u2217',
+ lowbar: '\u005F',
+ LowerLeftArrow: '\u2199',
+ LowerRightArrow: '\u2198',
+ loz: '\u25CA',
+ lozenge: '\u25CA',
+ lozf: '\u29EB',
+ lpar: '\u0028',
+ lparlt: '\u2993',
+ lrarr: '\u21C6',
+ lrcorner: '\u231F',
+ lrhar: '\u21CB',
+ lrhard: '\u296D',
+ lrm: '\u200E',
+ lrtri: '\u22BF',
+ lsaquo: '\u2039',
+ Lscr: '\u2112',
+ lscr: '\uD835\uDCC1',
+ Lsh: '\u21B0',
+ lsh: '\u21B0',
+ lsim: '\u2272',
+ lsime: '\u2A8D',
+ lsimg: '\u2A8F',
+ lsqb: '\u005B',
+ lsquo: '\u2018',
+ lsquor: '\u201A',
+ Lstrok: '\u0141',
+ lstrok: '\u0142',
+ Lt: '\u226A',
+ LT: '\u003C',
+ lt: '\u003C',
+ ltcc: '\u2AA6',
+ ltcir: '\u2A79',
+ ltdot: '\u22D6',
+ lthree: '\u22CB',
+ ltimes: '\u22C9',
+ ltlarr: '\u2976',
+ ltquest: '\u2A7B',
+ ltri: '\u25C3',
+ ltrie: '\u22B4',
+ ltrif: '\u25C2',
+ ltrPar: '\u2996',
+ lurdshar: '\u294A',
+ luruhar: '\u2966',
+ lvertneqq: '\u2268\uFE00',
+ lvnE: '\u2268\uFE00',
+ macr: '\u00AF',
+ male: '\u2642',
+ malt: '\u2720',
+ maltese: '\u2720',
+ Map: '\u2905',
+ map: '\u21A6',
+ mapsto: '\u21A6',
+ mapstodown: '\u21A7',
+ mapstoleft: '\u21A4',
+ mapstoup: '\u21A5',
+ marker: '\u25AE',
+ mcomma: '\u2A29',
+ Mcy: '\u041C',
+ mcy: '\u043C',
+ mdash: '\u2014',
+ mDDot: '\u223A',
+ measuredangle: '\u2221',
+ MediumSpace: '\u205F',
+ Mellintrf: '\u2133',
+ Mfr: '\uD835\uDD10',
+ mfr: '\uD835\uDD2A',
+ mho: '\u2127',
+ micro: '\u00B5',
+ mid: '\u2223',
+ midast: '\u002A',
+ midcir: '\u2AF0',
+ middot: '\u00B7',
+ minus: '\u2212',
+ minusb: '\u229F',
+ minusd: '\u2238',
+ minusdu: '\u2A2A',
+ MinusPlus: '\u2213',
+ mlcp: '\u2ADB',
+ mldr: '\u2026',
+ mnplus: '\u2213',
+ models: '\u22A7',
+ Mopf: '\uD835\uDD44',
+ mopf: '\uD835\uDD5E',
+ mp: '\u2213',
+ Mscr: '\u2133',
+ mscr: '\uD835\uDCC2',
+ mstpos: '\u223E',
+ Mu: '\u039C',
+ mu: '\u03BC',
+ multimap: '\u22B8',
+ mumap: '\u22B8',
+ nabla: '\u2207',
+ Nacute: '\u0143',
+ nacute: '\u0144',
+ nang: '\u2220\u20D2',
+ nap: '\u2249',
+ napE: '\u2A70\u0338',
+ napid: '\u224B\u0338',
+ napos: '\u0149',
+ napprox: '\u2249',
+ natur: '\u266E',
+ natural: '\u266E',
+ naturals: '\u2115',
+ nbsp: '\u00A0',
+ nbump: '\u224E\u0338',
+ nbumpe: '\u224F\u0338',
+ ncap: '\u2A43',
+ Ncaron: '\u0147',
+ ncaron: '\u0148',
+ Ncedil: '\u0145',
+ ncedil: '\u0146',
+ ncong: '\u2247',
+ ncongdot: '\u2A6D\u0338',
+ ncup: '\u2A42',
+ Ncy: '\u041D',
+ ncy: '\u043D',
+ ndash: '\u2013',
+ ne: '\u2260',
+ nearhk: '\u2924',
+ neArr: '\u21D7',
+ nearr: '\u2197',
+ nearrow: '\u2197',
+ nedot: '\u2250\u0338',
+ NegativeMediumSpace: '\u200B',
+ NegativeThickSpace: '\u200B',
+ NegativeThinSpace: '\u200B',
+ NegativeVeryThinSpace: '\u200B',
+ nequiv: '\u2262',
+ nesear: '\u2928',
+ nesim: '\u2242\u0338',
+ NestedGreaterGreater: '\u226B',
+ NestedLessLess: '\u226A',
+ NewLine: '\u000A',
+ nexist: '\u2204',
+ nexists: '\u2204',
+ Nfr: '\uD835\uDD11',
+ nfr: '\uD835\uDD2B',
+ ngE: '\u2267\u0338',
+ nge: '\u2271',
+ ngeq: '\u2271',
+ ngeqq: '\u2267\u0338',
+ ngeqslant: '\u2A7E\u0338',
+ nges: '\u2A7E\u0338',
+ nGg: '\u22D9\u0338',
+ ngsim: '\u2275',
+ nGt: '\u226B\u20D2',
+ ngt: '\u226F',
+ ngtr: '\u226F',
+ nGtv: '\u226B\u0338',
+ nhArr: '\u21CE',
+ nharr: '\u21AE',
+ nhpar: '\u2AF2',
+ ni: '\u220B',
+ nis: '\u22FC',
+ nisd: '\u22FA',
+ niv: '\u220B',
+ NJcy: '\u040A',
+ njcy: '\u045A',
+ nlArr: '\u21CD',
+ nlarr: '\u219A',
+ nldr: '\u2025',
+ nlE: '\u2266\u0338',
+ nle: '\u2270',
+ nLeftarrow: '\u21CD',
+ nleftarrow: '\u219A',
+ nLeftrightarrow: '\u21CE',
+ nleftrightarrow: '\u21AE',
+ nleq: '\u2270',
+ nleqq: '\u2266\u0338',
+ nleqslant: '\u2A7D\u0338',
+ nles: '\u2A7D\u0338',
+ nless: '\u226E',
+ nLl: '\u22D8\u0338',
+ nlsim: '\u2274',
+ nLt: '\u226A\u20D2',
+ nlt: '\u226E',
+ nltri: '\u22EA',
+ nltrie: '\u22EC',
+ nLtv: '\u226A\u0338',
+ nmid: '\u2224',
+ NoBreak: '\u2060',
+ NonBreakingSpace: '\u00A0',
+ Nopf: '\u2115',
+ nopf: '\uD835\uDD5F',
+ Not: '\u2AEC',
+ not: '\u00AC',
+ NotCongruent: '\u2262',
+ NotCupCap: '\u226D',
+ NotDoubleVerticalBar: '\u2226',
+ NotElement: '\u2209',
+ NotEqual: '\u2260',
+ NotEqualTilde: '\u2242\u0338',
+ NotExists: '\u2204',
+ NotGreater: '\u226F',
+ NotGreaterEqual: '\u2271',
+ NotGreaterFullEqual: '\u2267\u0338',
+ NotGreaterGreater: '\u226B\u0338',
+ NotGreaterLess: '\u2279',
+ NotGreaterSlantEqual: '\u2A7E\u0338',
+ NotGreaterTilde: '\u2275',
+ NotHumpDownHump: '\u224E\u0338',
+ NotHumpEqual: '\u224F\u0338',
+ notin: '\u2209',
+ notindot: '\u22F5\u0338',
+ notinE: '\u22F9\u0338',
+ notinva: '\u2209',
+ notinvb: '\u22F7',
+ notinvc: '\u22F6',
+ NotLeftTriangle: '\u22EA',
+ NotLeftTriangleBar: '\u29CF\u0338',
+ NotLeftTriangleEqual: '\u22EC',
+ NotLess: '\u226E',
+ NotLessEqual: '\u2270',
+ NotLessGreater: '\u2278',
+ NotLessLess: '\u226A\u0338',
+ NotLessSlantEqual: '\u2A7D\u0338',
+ NotLessTilde: '\u2274',
+ NotNestedGreaterGreater: '\u2AA2\u0338',
+ NotNestedLessLess: '\u2AA1\u0338',
+ notni: '\u220C',
+ notniva: '\u220C',
+ notnivb: '\u22FE',
+ notnivc: '\u22FD',
+ NotPrecedes: '\u2280',
+ NotPrecedesEqual: '\u2AAF\u0338',
+ NotPrecedesSlantEqual: '\u22E0',
+ NotReverseElement: '\u220C',
+ NotRightTriangle: '\u22EB',
+ NotRightTriangleBar: '\u29D0\u0338',
+ NotRightTriangleEqual: '\u22ED',
+ NotSquareSubset: '\u228F\u0338',
+ NotSquareSubsetEqual: '\u22E2',
+ NotSquareSuperset: '\u2290\u0338',
+ NotSquareSupersetEqual: '\u22E3',
+ NotSubset: '\u2282\u20D2',
+ NotSubsetEqual: '\u2288',
+ NotSucceeds: '\u2281',
+ NotSucceedsEqual: '\u2AB0\u0338',
+ NotSucceedsSlantEqual: '\u22E1',
+ NotSucceedsTilde: '\u227F\u0338',
+ NotSuperset: '\u2283\u20D2',
+ NotSupersetEqual: '\u2289',
+ NotTilde: '\u2241',
+ NotTildeEqual: '\u2244',
+ NotTildeFullEqual: '\u2247',
+ NotTildeTilde: '\u2249',
+ NotVerticalBar: '\u2224',
+ npar: '\u2226',
+ nparallel: '\u2226',
+ nparsl: '\u2AFD\u20E5',
+ npart: '\u2202\u0338',
+ npolint: '\u2A14',
+ npr: '\u2280',
+ nprcue: '\u22E0',
+ npre: '\u2AAF\u0338',
+ nprec: '\u2280',
+ npreceq: '\u2AAF\u0338',
+ nrArr: '\u21CF',
+ nrarr: '\u219B',
+ nrarrc: '\u2933\u0338',
+ nrarrw: '\u219D\u0338',
+ nRightarrow: '\u21CF',
+ nrightarrow: '\u219B',
+ nrtri: '\u22EB',
+ nrtrie: '\u22ED',
+ nsc: '\u2281',
+ nsccue: '\u22E1',
+ nsce: '\u2AB0\u0338',
+ Nscr: '\uD835\uDCA9',
+ nscr: '\uD835\uDCC3',
+ nshortmid: '\u2224',
+ nshortparallel: '\u2226',
+ nsim: '\u2241',
+ nsime: '\u2244',
+ nsimeq: '\u2244',
+ nsmid: '\u2224',
+ nspar: '\u2226',
+ nsqsube: '\u22E2',
+ nsqsupe: '\u22E3',
+ nsub: '\u2284',
+ nsubE: '\u2AC5\u0338',
+ nsube: '\u2288',
+ nsubset: '\u2282\u20D2',
+ nsubseteq: '\u2288',
+ nsubseteqq: '\u2AC5\u0338',
+ nsucc: '\u2281',
+ nsucceq: '\u2AB0\u0338',
+ nsup: '\u2285',
+ nsupE: '\u2AC6\u0338',
+ nsupe: '\u2289',
+ nsupset: '\u2283\u20D2',
+ nsupseteq: '\u2289',
+ nsupseteqq: '\u2AC6\u0338',
+ ntgl: '\u2279',
+ Ntilde: '\u00D1',
+ ntilde: '\u00F1',
+ ntlg: '\u2278',
+ ntriangleleft: '\u22EA',
+ ntrianglelefteq: '\u22EC',
+ ntriangleright: '\u22EB',
+ ntrianglerighteq: '\u22ED',
+ Nu: '\u039D',
+ nu: '\u03BD',
+ num: '\u0023',
+ numero: '\u2116',
+ numsp: '\u2007',
+ nvap: '\u224D\u20D2',
+ nVDash: '\u22AF',
+ nVdash: '\u22AE',
+ nvDash: '\u22AD',
+ nvdash: '\u22AC',
+ nvge: '\u2265\u20D2',
+ nvgt: '\u003E\u20D2',
+ nvHarr: '\u2904',
+ nvinfin: '\u29DE',
+ nvlArr: '\u2902',
+ nvle: '\u2264\u20D2',
+ nvlt: '\u003C\u20D2',
+ nvltrie: '\u22B4\u20D2',
+ nvrArr: '\u2903',
+ nvrtrie: '\u22B5\u20D2',
+ nvsim: '\u223C\u20D2',
+ nwarhk: '\u2923',
+ nwArr: '\u21D6',
+ nwarr: '\u2196',
+ nwarrow: '\u2196',
+ nwnear: '\u2927',
+ Oacute: '\u00D3',
+ oacute: '\u00F3',
+ oast: '\u229B',
+ ocir: '\u229A',
+ Ocirc: '\u00D4',
+ ocirc: '\u00F4',
+ Ocy: '\u041E',
+ ocy: '\u043E',
+ odash: '\u229D',
+ Odblac: '\u0150',
+ odblac: '\u0151',
+ odiv: '\u2A38',
+ odot: '\u2299',
+ odsold: '\u29BC',
+ OElig: '\u0152',
+ oelig: '\u0153',
+ ofcir: '\u29BF',
+ Ofr: '\uD835\uDD12',
+ ofr: '\uD835\uDD2C',
+ ogon: '\u02DB',
+ Ograve: '\u00D2',
+ ograve: '\u00F2',
+ ogt: '\u29C1',
+ ohbar: '\u29B5',
+ ohm: '\u03A9',
+ oint: '\u222E',
+ olarr: '\u21BA',
+ olcir: '\u29BE',
+ olcross: '\u29BB',
+ oline: '\u203E',
+ olt: '\u29C0',
+ Omacr: '\u014C',
+ omacr: '\u014D',
+ Omega: '\u03A9',
+ omega: '\u03C9',
+ Omicron: '\u039F',
+ omicron: '\u03BF',
+ omid: '\u29B6',
+ ominus: '\u2296',
+ Oopf: '\uD835\uDD46',
+ oopf: '\uD835\uDD60',
+ opar: '\u29B7',
+ OpenCurlyDoubleQuote: '\u201C',
+ OpenCurlyQuote: '\u2018',
+ operp: '\u29B9',
+ oplus: '\u2295',
+ Or: '\u2A54',
+ or: '\u2228',
+ orarr: '\u21BB',
+ ord: '\u2A5D',
+ order: '\u2134',
+ orderof: '\u2134',
+ ordf: '\u00AA',
+ ordm: '\u00BA',
+ origof: '\u22B6',
+ oror: '\u2A56',
+ orslope: '\u2A57',
+ orv: '\u2A5B',
+ oS: '\u24C8',
+ Oscr: '\uD835\uDCAA',
+ oscr: '\u2134',
+ Oslash: '\u00D8',
+ oslash: '\u00F8',
+ osol: '\u2298',
+ Otilde: '\u00D5',
+ otilde: '\u00F5',
+ Otimes: '\u2A37',
+ otimes: '\u2297',
+ otimesas: '\u2A36',
+ Ouml: '\u00D6',
+ ouml: '\u00F6',
+ ovbar: '\u233D',
+ OverBar: '\u203E',
+ OverBrace: '\u23DE',
+ OverBracket: '\u23B4',
+ OverParenthesis: '\u23DC',
+ par: '\u2225',
+ para: '\u00B6',
+ parallel: '\u2225',
+ parsim: '\u2AF3',
+ parsl: '\u2AFD',
+ part: '\u2202',
+ PartialD: '\u2202',
+ Pcy: '\u041F',
+ pcy: '\u043F',
+ percnt: '\u0025',
+ period: '\u002E',
+ permil: '\u2030',
+ perp: '\u22A5',
+ pertenk: '\u2031',
+ Pfr: '\uD835\uDD13',
+ pfr: '\uD835\uDD2D',
+ Phi: '\u03A6',
+ phi: '\u03C6',
+ phiv: '\u03D5',
+ phmmat: '\u2133',
+ phone: '\u260E',
+ Pi: '\u03A0',
+ pi: '\u03C0',
+ pitchfork: '\u22D4',
+ piv: '\u03D6',
+ planck: '\u210F',
+ planckh: '\u210E',
+ plankv: '\u210F',
+ plus: '\u002B',
+ plusacir: '\u2A23',
+ plusb: '\u229E',
+ pluscir: '\u2A22',
+ plusdo: '\u2214',
+ plusdu: '\u2A25',
+ pluse: '\u2A72',
+ PlusMinus: '\u00B1',
+ plusmn: '\u00B1',
+ plussim: '\u2A26',
+ plustwo: '\u2A27',
+ pm: '\u00B1',
+ Poincareplane: '\u210C',
+ pointint: '\u2A15',
+ Popf: '\u2119',
+ popf: '\uD835\uDD61',
+ pound: '\u00A3',
+ Pr: '\u2ABB',
+ pr: '\u227A',
+ prap: '\u2AB7',
+ prcue: '\u227C',
+ prE: '\u2AB3',
+ pre: '\u2AAF',
+ prec: '\u227A',
+ precapprox: '\u2AB7',
+ preccurlyeq: '\u227C',
+ Precedes: '\u227A',
+ PrecedesEqual: '\u2AAF',
+ PrecedesSlantEqual: '\u227C',
+ PrecedesTilde: '\u227E',
+ preceq: '\u2AAF',
+ precnapprox: '\u2AB9',
+ precneqq: '\u2AB5',
+ precnsim: '\u22E8',
+ precsim: '\u227E',
+ Prime: '\u2033',
+ prime: '\u2032',
+ primes: '\u2119',
+ prnap: '\u2AB9',
+ prnE: '\u2AB5',
+ prnsim: '\u22E8',
+ prod: '\u220F',
+ Product: '\u220F',
+ profalar: '\u232E',
+ profline: '\u2312',
+ profsurf: '\u2313',
+ prop: '\u221D',
+ Proportion: '\u2237',
+ Proportional: '\u221D',
+ propto: '\u221D',
+ prsim: '\u227E',
+ prurel: '\u22B0',
+ Pscr: '\uD835\uDCAB',
+ pscr: '\uD835\uDCC5',
+ Psi: '\u03A8',
+ psi: '\u03C8',
+ puncsp: '\u2008',
+ Qfr: '\uD835\uDD14',
+ qfr: '\uD835\uDD2E',
+ qint: '\u2A0C',
+ Qopf: '\u211A',
+ qopf: '\uD835\uDD62',
+ qprime: '\u2057',
+ Qscr: '\uD835\uDCAC',
+ qscr: '\uD835\uDCC6',
+ quaternions: '\u210D',
+ quatint: '\u2A16',
+ quest: '\u003F',
+ questeq: '\u225F',
+ QUOT: '\u0022',
+ quot: '\u0022',
+ rAarr: '\u21DB',
+ race: '\u223D\u0331',
+ Racute: '\u0154',
+ racute: '\u0155',
+ radic: '\u221A',
+ raemptyv: '\u29B3',
+ Rang: '\u27EB',
+ rang: '\u27E9',
+ rangd: '\u2992',
+ range: '\u29A5',
+ rangle: '\u27E9',
+ raquo: '\u00BB',
+ Rarr: '\u21A0',
+ rArr: '\u21D2',
+ rarr: '\u2192',
+ rarrap: '\u2975',
+ rarrb: '\u21E5',
+ rarrbfs: '\u2920',
+ rarrc: '\u2933',
+ rarrfs: '\u291E',
+ rarrhk: '\u21AA',
+ rarrlp: '\u21AC',
+ rarrpl: '\u2945',
+ rarrsim: '\u2974',
+ Rarrtl: '\u2916',
+ rarrtl: '\u21A3',
+ rarrw: '\u219D',
+ rAtail: '\u291C',
+ ratail: '\u291A',
+ ratio: '\u2236',
+ rationals: '\u211A',
+ RBarr: '\u2910',
+ rBarr: '\u290F',
+ rbarr: '\u290D',
+ rbbrk: '\u2773',
+ rbrace: '\u007D',
+ rbrack: '\u005D',
+ rbrke: '\u298C',
+ rbrksld: '\u298E',
+ rbrkslu: '\u2990',
+ Rcaron: '\u0158',
+ rcaron: '\u0159',
+ Rcedil: '\u0156',
+ rcedil: '\u0157',
+ rceil: '\u2309',
+ rcub: '\u007D',
+ Rcy: '\u0420',
+ rcy: '\u0440',
+ rdca: '\u2937',
+ rdldhar: '\u2969',
+ rdquo: '\u201D',
+ rdquor: '\u201D',
+ rdsh: '\u21B3',
+ Re: '\u211C',
+ real: '\u211C',
+ realine: '\u211B',
+ realpart: '\u211C',
+ reals: '\u211D',
+ rect: '\u25AD',
+ REG: '\u00AE',
+ reg: '\u00AE',
+ ReverseElement: '\u220B',
+ ReverseEquilibrium: '\u21CB',
+ ReverseUpEquilibrium: '\u296F',
+ rfisht: '\u297D',
+ rfloor: '\u230B',
+ Rfr: '\u211C',
+ rfr: '\uD835\uDD2F',
+ rHar: '\u2964',
+ rhard: '\u21C1',
+ rharu: '\u21C0',
+ rharul: '\u296C',
+ Rho: '\u03A1',
+ rho: '\u03C1',
+ rhov: '\u03F1',
+ RightAngleBracket: '\u27E9',
+ RightArrow: '\u2192',
+ Rightarrow: '\u21D2',
+ rightarrow: '\u2192',
+ RightArrowBar: '\u21E5',
+ RightArrowLeftArrow: '\u21C4',
+ rightarrowtail: '\u21A3',
+ RightCeiling: '\u2309',
+ RightDoubleBracket: '\u27E7',
+ RightDownTeeVector: '\u295D',
+ RightDownVector: '\u21C2',
+ RightDownVectorBar: '\u2955',
+ RightFloor: '\u230B',
+ rightharpoondown: '\u21C1',
+ rightharpoonup: '\u21C0',
+ rightleftarrows: '\u21C4',
+ rightleftharpoons: '\u21CC',
+ rightrightarrows: '\u21C9',
+ rightsquigarrow: '\u219D',
+ RightTee: '\u22A2',
+ RightTeeArrow: '\u21A6',
+ RightTeeVector: '\u295B',
+ rightthreetimes: '\u22CC',
+ RightTriangle: '\u22B3',
+ RightTriangleBar: '\u29D0',
+ RightTriangleEqual: '\u22B5',
+ RightUpDownVector: '\u294F',
+ RightUpTeeVector: '\u295C',
+ RightUpVector: '\u21BE',
+ RightUpVectorBar: '\u2954',
+ RightVector: '\u21C0',
+ RightVectorBar: '\u2953',
+ ring: '\u02DA',
+ risingdotseq: '\u2253',
+ rlarr: '\u21C4',
+ rlhar: '\u21CC',
+ rlm: '\u200F',
+ rmoust: '\u23B1',
+ rmoustache: '\u23B1',
+ rnmid: '\u2AEE',
+ roang: '\u27ED',
+ roarr: '\u21FE',
+ robrk: '\u27E7',
+ ropar: '\u2986',
+ Ropf: '\u211D',
+ ropf: '\uD835\uDD63',
+ roplus: '\u2A2E',
+ rotimes: '\u2A35',
+ RoundImplies: '\u2970',
+ rpar: '\u0029',
+ rpargt: '\u2994',
+ rppolint: '\u2A12',
+ rrarr: '\u21C9',
+ Rrightarrow: '\u21DB',
+ rsaquo: '\u203A',
+ Rscr: '\u211B',
+ rscr: '\uD835\uDCC7',
+ Rsh: '\u21B1',
+ rsh: '\u21B1',
+ rsqb: '\u005D',
+ rsquo: '\u2019',
+ rsquor: '\u2019',
+ rthree: '\u22CC',
+ rtimes: '\u22CA',
+ rtri: '\u25B9',
+ rtrie: '\u22B5',
+ rtrif: '\u25B8',
+ rtriltri: '\u29CE',
+ RuleDelayed: '\u29F4',
+ ruluhar: '\u2968',
+ rx: '\u211E',
+ Sacute: '\u015A',
+ sacute: '\u015B',
+ sbquo: '\u201A',
+ Sc: '\u2ABC',
+ sc: '\u227B',
+ scap: '\u2AB8',
+ Scaron: '\u0160',
+ scaron: '\u0161',
+ sccue: '\u227D',
+ scE: '\u2AB4',
+ sce: '\u2AB0',
+ Scedil: '\u015E',
+ scedil: '\u015F',
+ Scirc: '\u015C',
+ scirc: '\u015D',
+ scnap: '\u2ABA',
+ scnE: '\u2AB6',
+ scnsim: '\u22E9',
+ scpolint: '\u2A13',
+ scsim: '\u227F',
+ Scy: '\u0421',
+ scy: '\u0441',
+ sdot: '\u22C5',
+ sdotb: '\u22A1',
+ sdote: '\u2A66',
+ searhk: '\u2925',
+ seArr: '\u21D8',
+ searr: '\u2198',
+ searrow: '\u2198',
+ sect: '\u00A7',
+ semi: '\u003B',
+ seswar: '\u2929',
+ setminus: '\u2216',
+ setmn: '\u2216',
+ sext: '\u2736',
+ Sfr: '\uD835\uDD16',
+ sfr: '\uD835\uDD30',
+ sfrown: '\u2322',
+ sharp: '\u266F',
+ SHCHcy: '\u0429',
+ shchcy: '\u0449',
+ SHcy: '\u0428',
+ shcy: '\u0448',
+ ShortDownArrow: '\u2193',
+ ShortLeftArrow: '\u2190',
+ shortmid: '\u2223',
+ shortparallel: '\u2225',
+ ShortRightArrow: '\u2192',
+ ShortUpArrow: '\u2191',
+ shy: '\u00AD',
+ Sigma: '\u03A3',
+ sigma: '\u03C3',
+ sigmaf: '\u03C2',
+ sigmav: '\u03C2',
+ sim: '\u223C',
+ simdot: '\u2A6A',
+ sime: '\u2243',
+ simeq: '\u2243',
+ simg: '\u2A9E',
+ simgE: '\u2AA0',
+ siml: '\u2A9D',
+ simlE: '\u2A9F',
+ simne: '\u2246',
+ simplus: '\u2A24',
+ simrarr: '\u2972',
+ slarr: '\u2190',
+ SmallCircle: '\u2218',
+ smallsetminus: '\u2216',
+ smashp: '\u2A33',
+ smeparsl: '\u29E4',
+ smid: '\u2223',
+ smile: '\u2323',
+ smt: '\u2AAA',
+ smte: '\u2AAC',
+ smtes: '\u2AAC\uFE00',
+ SOFTcy: '\u042C',
+ softcy: '\u044C',
+ sol: '\u002F',
+ solb: '\u29C4',
+ solbar: '\u233F',
+ Sopf: '\uD835\uDD4A',
+ sopf: '\uD835\uDD64',
+ spades: '\u2660',
+ spadesuit: '\u2660',
+ spar: '\u2225',
+ sqcap: '\u2293',
+ sqcaps: '\u2293\uFE00',
+ sqcup: '\u2294',
+ sqcups: '\u2294\uFE00',
+ Sqrt: '\u221A',
+ sqsub: '\u228F',
+ sqsube: '\u2291',
+ sqsubset: '\u228F',
+ sqsubseteq: '\u2291',
+ sqsup: '\u2290',
+ sqsupe: '\u2292',
+ sqsupset: '\u2290',
+ sqsupseteq: '\u2292',
+ squ: '\u25A1',
+ Square: '\u25A1',
+ square: '\u25A1',
+ SquareIntersection: '\u2293',
+ SquareSubset: '\u228F',
+ SquareSubsetEqual: '\u2291',
+ SquareSuperset: '\u2290',
+ SquareSupersetEqual: '\u2292',
+ SquareUnion: '\u2294',
+ squarf: '\u25AA',
+ squf: '\u25AA',
+ srarr: '\u2192',
+ Sscr: '\uD835\uDCAE',
+ sscr: '\uD835\uDCC8',
+ ssetmn: '\u2216',
+ ssmile: '\u2323',
+ sstarf: '\u22C6',
+ Star: '\u22C6',
+ star: '\u2606',
+ starf: '\u2605',
+ straightepsilon: '\u03F5',
+ straightphi: '\u03D5',
+ strns: '\u00AF',
+ Sub: '\u22D0',
+ sub: '\u2282',
+ subdot: '\u2ABD',
+ subE: '\u2AC5',
+ sube: '\u2286',
+ subedot: '\u2AC3',
+ submult: '\u2AC1',
+ subnE: '\u2ACB',
+ subne: '\u228A',
+ subplus: '\u2ABF',
+ subrarr: '\u2979',
+ Subset: '\u22D0',
+ subset: '\u2282',
+ subseteq: '\u2286',
+ subseteqq: '\u2AC5',
+ SubsetEqual: '\u2286',
+ subsetneq: '\u228A',
+ subsetneqq: '\u2ACB',
+ subsim: '\u2AC7',
+ subsub: '\u2AD5',
+ subsup: '\u2AD3',
+ succ: '\u227B',
+ succapprox: '\u2AB8',
+ succcurlyeq: '\u227D',
+ Succeeds: '\u227B',
+ SucceedsEqual: '\u2AB0',
+ SucceedsSlantEqual: '\u227D',
+ SucceedsTilde: '\u227F',
+ succeq: '\u2AB0',
+ succnapprox: '\u2ABA',
+ succneqq: '\u2AB6',
+ succnsim: '\u22E9',
+ succsim: '\u227F',
+ SuchThat: '\u220B',
+ Sum: '\u2211',
+ sum: '\u2211',
+ sung: '\u266A',
+ Sup: '\u22D1',
+ sup: '\u2283',
+ sup1: '\u00B9',
+ sup2: '\u00B2',
+ sup3: '\u00B3',
+ supdot: '\u2ABE',
+ supdsub: '\u2AD8',
+ supE: '\u2AC6',
+ supe: '\u2287',
+ supedot: '\u2AC4',
+ Superset: '\u2283',
+ SupersetEqual: '\u2287',
+ suphsol: '\u27C9',
+ suphsub: '\u2AD7',
+ suplarr: '\u297B',
+ supmult: '\u2AC2',
+ supnE: '\u2ACC',
+ supne: '\u228B',
+ supplus: '\u2AC0',
+ Supset: '\u22D1',
+ supset: '\u2283',
+ supseteq: '\u2287',
+ supseteqq: '\u2AC6',
+ supsetneq: '\u228B',
+ supsetneqq: '\u2ACC',
+ supsim: '\u2AC8',
+ supsub: '\u2AD4',
+ supsup: '\u2AD6',
+ swarhk: '\u2926',
+ swArr: '\u21D9',
+ swarr: '\u2199',
+ swarrow: '\u2199',
+ swnwar: '\u292A',
+ szlig: '\u00DF',
+ Tab: '\u0009',
+ target: '\u2316',
+ Tau: '\u03A4',
+ tau: '\u03C4',
+ tbrk: '\u23B4',
+ Tcaron: '\u0164',
+ tcaron: '\u0165',
+ Tcedil: '\u0162',
+ tcedil: '\u0163',
+ Tcy: '\u0422',
+ tcy: '\u0442',
+ tdot: '\u20DB',
+ telrec: '\u2315',
+ Tfr: '\uD835\uDD17',
+ tfr: '\uD835\uDD31',
+ there4: '\u2234',
+ Therefore: '\u2234',
+ therefore: '\u2234',
+ Theta: '\u0398',
+ theta: '\u03B8',
+ thetasym: '\u03D1',
+ thetav: '\u03D1',
+ thickapprox: '\u2248',
+ thicksim: '\u223C',
+ ThickSpace: '\u205F\u200A',
+ thinsp: '\u2009',
+ ThinSpace: '\u2009',
+ thkap: '\u2248',
+ thksim: '\u223C',
+ THORN: '\u00DE',
+ thorn: '\u00FE',
+ Tilde: '\u223C',
+ tilde: '\u02DC',
+ TildeEqual: '\u2243',
+ TildeFullEqual: '\u2245',
+ TildeTilde: '\u2248',
+ times: '\u00D7',
+ timesb: '\u22A0',
+ timesbar: '\u2A31',
+ timesd: '\u2A30',
+ tint: '\u222D',
+ toea: '\u2928',
+ top: '\u22A4',
+ topbot: '\u2336',
+ topcir: '\u2AF1',
+ Topf: '\uD835\uDD4B',
+ topf: '\uD835\uDD65',
+ topfork: '\u2ADA',
+ tosa: '\u2929',
+ tprime: '\u2034',
+ TRADE: '\u2122',
+ trade: '\u2122',
+ triangle: '\u25B5',
+ triangledown: '\u25BF',
+ triangleleft: '\u25C3',
+ trianglelefteq: '\u22B4',
+ triangleq: '\u225C',
+ triangleright: '\u25B9',
+ trianglerighteq: '\u22B5',
+ tridot: '\u25EC',
+ trie: '\u225C',
+ triminus: '\u2A3A',
+ TripleDot: '\u20DB',
+ triplus: '\u2A39',
+ trisb: '\u29CD',
+ tritime: '\u2A3B',
+ trpezium: '\u23E2',
+ Tscr: '\uD835\uDCAF',
+ tscr: '\uD835\uDCC9',
+ TScy: '\u0426',
+ tscy: '\u0446',
+ TSHcy: '\u040B',
+ tshcy: '\u045B',
+ Tstrok: '\u0166',
+ tstrok: '\u0167',
+ twixt: '\u226C',
+ twoheadleftarrow: '\u219E',
+ twoheadrightarrow: '\u21A0',
+ Uacute: '\u00DA',
+ uacute: '\u00FA',
+ Uarr: '\u219F',
+ uArr: '\u21D1',
+ uarr: '\u2191',
+ Uarrocir: '\u2949',
+ Ubrcy: '\u040E',
+ ubrcy: '\u045E',
+ Ubreve: '\u016C',
+ ubreve: '\u016D',
+ Ucirc: '\u00DB',
+ ucirc: '\u00FB',
+ Ucy: '\u0423',
+ ucy: '\u0443',
+ udarr: '\u21C5',
+ Udblac: '\u0170',
+ udblac: '\u0171',
+ udhar: '\u296E',
+ ufisht: '\u297E',
+ Ufr: '\uD835\uDD18',
+ ufr: '\uD835\uDD32',
+ Ugrave: '\u00D9',
+ ugrave: '\u00F9',
+ uHar: '\u2963',
+ uharl: '\u21BF',
+ uharr: '\u21BE',
+ uhblk: '\u2580',
+ ulcorn: '\u231C',
+ ulcorner: '\u231C',
+ ulcrop: '\u230F',
+ ultri: '\u25F8',
+ Umacr: '\u016A',
+ umacr: '\u016B',
+ uml: '\u00A8',
+ UnderBar: '\u005F',
+ UnderBrace: '\u23DF',
+ UnderBracket: '\u23B5',
+ UnderParenthesis: '\u23DD',
+ Union: '\u22C3',
+ UnionPlus: '\u228E',
+ Uogon: '\u0172',
+ uogon: '\u0173',
+ Uopf: '\uD835\uDD4C',
+ uopf: '\uD835\uDD66',
+ UpArrow: '\u2191',
+ Uparrow: '\u21D1',
+ uparrow: '\u2191',
+ UpArrowBar: '\u2912',
+ UpArrowDownArrow: '\u21C5',
+ UpDownArrow: '\u2195',
+ Updownarrow: '\u21D5',
+ updownarrow: '\u2195',
+ UpEquilibrium: '\u296E',
+ upharpoonleft: '\u21BF',
+ upharpoonright: '\u21BE',
+ uplus: '\u228E',
+ UpperLeftArrow: '\u2196',
+ UpperRightArrow: '\u2197',
+ Upsi: '\u03D2',
+ upsi: '\u03C5',
+ upsih: '\u03D2',
+ Upsilon: '\u03A5',
+ upsilon: '\u03C5',
+ UpTee: '\u22A5',
+ UpTeeArrow: '\u21A5',
+ upuparrows: '\u21C8',
+ urcorn: '\u231D',
+ urcorner: '\u231D',
+ urcrop: '\u230E',
+ Uring: '\u016E',
+ uring: '\u016F',
+ urtri: '\u25F9',
+ Uscr: '\uD835\uDCB0',
+ uscr: '\uD835\uDCCA',
+ utdot: '\u22F0',
+ Utilde: '\u0168',
+ utilde: '\u0169',
+ utri: '\u25B5',
+ utrif: '\u25B4',
+ uuarr: '\u21C8',
+ Uuml: '\u00DC',
+ uuml: '\u00FC',
+ uwangle: '\u29A7',
+ vangrt: '\u299C',
+ varepsilon: '\u03F5',
+ varkappa: '\u03F0',
+ varnothing: '\u2205',
+ varphi: '\u03D5',
+ varpi: '\u03D6',
+ varpropto: '\u221D',
+ vArr: '\u21D5',
+ varr: '\u2195',
+ varrho: '\u03F1',
+ varsigma: '\u03C2',
+ varsubsetneq: '\u228A\uFE00',
+ varsubsetneqq: '\u2ACB\uFE00',
+ varsupsetneq: '\u228B\uFE00',
+ varsupsetneqq: '\u2ACC\uFE00',
+ vartheta: '\u03D1',
+ vartriangleleft: '\u22B2',
+ vartriangleright: '\u22B3',
+ Vbar: '\u2AEB',
+ vBar: '\u2AE8',
+ vBarv: '\u2AE9',
+ Vcy: '\u0412',
+ vcy: '\u0432',
+ VDash: '\u22AB',
+ Vdash: '\u22A9',
+ vDash: '\u22A8',
+ vdash: '\u22A2',
+ Vdashl: '\u2AE6',
+ Vee: '\u22C1',
+ vee: '\u2228',
+ veebar: '\u22BB',
+ veeeq: '\u225A',
+ vellip: '\u22EE',
+ Verbar: '\u2016',
+ verbar: '\u007C',
+ Vert: '\u2016',
+ vert: '\u007C',
+ VerticalBar: '\u2223',
+ VerticalLine: '\u007C',
+ VerticalSeparator: '\u2758',
+ VerticalTilde: '\u2240',
+ VeryThinSpace: '\u200A',
+ Vfr: '\uD835\uDD19',
+ vfr: '\uD835\uDD33',
+ vltri: '\u22B2',
+ vnsub: '\u2282\u20D2',
+ vnsup: '\u2283\u20D2',
+ Vopf: '\uD835\uDD4D',
+ vopf: '\uD835\uDD67',
+ vprop: '\u221D',
+ vrtri: '\u22B3',
+ Vscr: '\uD835\uDCB1',
+ vscr: '\uD835\uDCCB',
+ vsubnE: '\u2ACB\uFE00',
+ vsubne: '\u228A\uFE00',
+ vsupnE: '\u2ACC\uFE00',
+ vsupne: '\u228B\uFE00',
+ Vvdash: '\u22AA',
+ vzigzag: '\u299A',
+ Wcirc: '\u0174',
+ wcirc: '\u0175',
+ wedbar: '\u2A5F',
+ Wedge: '\u22C0',
+ wedge: '\u2227',
+ wedgeq: '\u2259',
+ weierp: '\u2118',
+ Wfr: '\uD835\uDD1A',
+ wfr: '\uD835\uDD34',
+ Wopf: '\uD835\uDD4E',
+ wopf: '\uD835\uDD68',
+ wp: '\u2118',
+ wr: '\u2240',
+ wreath: '\u2240',
+ Wscr: '\uD835\uDCB2',
+ wscr: '\uD835\uDCCC',
+ xcap: '\u22C2',
+ xcirc: '\u25EF',
+ xcup: '\u22C3',
+ xdtri: '\u25BD',
+ Xfr: '\uD835\uDD1B',
+ xfr: '\uD835\uDD35',
+ xhArr: '\u27FA',
+ xharr: '\u27F7',
+ Xi: '\u039E',
+ xi: '\u03BE',
+ xlArr: '\u27F8',
+ xlarr: '\u27F5',
+ xmap: '\u27FC',
+ xnis: '\u22FB',
+ xodot: '\u2A00',
+ Xopf: '\uD835\uDD4F',
+ xopf: '\uD835\uDD69',
+ xoplus: '\u2A01',
+ xotime: '\u2A02',
+ xrArr: '\u27F9',
+ xrarr: '\u27F6',
+ Xscr: '\uD835\uDCB3',
+ xscr: '\uD835\uDCCD',
+ xsqcup: '\u2A06',
+ xuplus: '\u2A04',
+ xutri: '\u25B3',
+ xvee: '\u22C1',
+ xwedge: '\u22C0',
+ Yacute: '\u00DD',
+ yacute: '\u00FD',
+ YAcy: '\u042F',
+ yacy: '\u044F',
+ Ycirc: '\u0176',
+ ycirc: '\u0177',
+ Ycy: '\u042B',
+ ycy: '\u044B',
+ yen: '\u00A5',
+ Yfr: '\uD835\uDD1C',
+ yfr: '\uD835\uDD36',
+ YIcy: '\u0407',
+ yicy: '\u0457',
+ Yopf: '\uD835\uDD50',
+ yopf: '\uD835\uDD6A',
+ Yscr: '\uD835\uDCB4',
+ yscr: '\uD835\uDCCE',
+ YUcy: '\u042E',
+ yucy: '\u044E',
+ Yuml: '\u0178',
+ yuml: '\u00FF',
+ Zacute: '\u0179',
+ zacute: '\u017A',
+ Zcaron: '\u017D',
+ zcaron: '\u017E',
+ Zcy: '\u0417',
+ zcy: '\u0437',
+ Zdot: '\u017B',
+ zdot: '\u017C',
+ zeetrf: '\u2128',
+ ZeroWidthSpace: '\u200B',
+ Zeta: '\u0396',
+ zeta: '\u03B6',
+ Zfr: '\u2128',
+ zfr: '\uD835\uDD37',
+ ZHcy: '\u0416',
+ zhcy: '\u0436',
+ zigrarr: '\u21DD',
+ Zopf: '\u2124',
+ zopf: '\uD835\uDD6B',
+ Zscr: '\uD835\uDCB5',
+ zscr: '\uD835\uDCCF',
+ zwj: '\u200D',
+ zwnj: '\u200C',
+});
+
+/**
+ * @deprecated
+ * Use `HTML_ENTITIES` instead.
+ * @see {@link HTML_ENTITIES}
+ */
+exports.entityMap = exports.HTML_ENTITIES;
+
+},{"./conventions":4}],8:[function(require,module,exports){
+'use strict';
+
+var conventions = require('./conventions');
+
+function extendError(constructor, writableName) {
+ constructor.prototype = Object.create(Error.prototype, {
+ constructor: { value: constructor },
+ name: { value: constructor.name, enumerable: true, writable: writableName },
+ });
+}
+
+var DOMExceptionName = conventions.freeze({
+ /**
+ * the default value as defined by the spec
+ */
+ Error: 'Error',
+ /**
+ * @deprecated
+ * Use RangeError instead.
+ */
+ IndexSizeError: 'IndexSizeError',
+ /**
+ * @deprecated
+ * Just to match the related static code, not part of the spec.
+ */
+ DomstringSizeError: 'DomstringSizeError',
+ HierarchyRequestError: 'HierarchyRequestError',
+ WrongDocumentError: 'WrongDocumentError',
+ InvalidCharacterError: 'InvalidCharacterError',
+ /**
+ * @deprecated
+ * Just to match the related static code, not part of the spec.
+ */
+ NoDataAllowedError: 'NoDataAllowedError',
+ NoModificationAllowedError: 'NoModificationAllowedError',
+ NotFoundError: 'NotFoundError',
+ NotSupportedError: 'NotSupportedError',
+ InUseAttributeError: 'InUseAttributeError',
+ InvalidStateError: 'InvalidStateError',
+ SyntaxError: 'SyntaxError',
+ InvalidModificationError: 'InvalidModificationError',
+ NamespaceError: 'NamespaceError',
+ /**
+ * @deprecated
+ * Use TypeError for invalid arguments,
+ * "NotSupportedError" DOMException for unsupported operations,
+ * and "NotAllowedError" DOMException for denied requests instead.
+ */
+ InvalidAccessError: 'InvalidAccessError',
+ /**
+ * @deprecated
+ * Just to match the related static code, not part of the spec.
+ */
+ ValidationError: 'ValidationError',
+ /**
+ * @deprecated
+ * Use TypeError instead.
+ */
+ TypeMismatchError: 'TypeMismatchError',
+ SecurityError: 'SecurityError',
+ NetworkError: 'NetworkError',
+ AbortError: 'AbortError',
+ /**
+ * @deprecated
+ * Just to match the related static code, not part of the spec.
+ */
+ URLMismatchError: 'URLMismatchError',
+ QuotaExceededError: 'QuotaExceededError',
+ TimeoutError: 'TimeoutError',
+ InvalidNodeTypeError: 'InvalidNodeTypeError',
+ DataCloneError: 'DataCloneError',
+ EncodingError: 'EncodingError',
+ NotReadableError: 'NotReadableError',
+ UnknownError: 'UnknownError',
+ ConstraintError: 'ConstraintError',
+ DataError: 'DataError',
+ TransactionInactiveError: 'TransactionInactiveError',
+ ReadOnlyError: 'ReadOnlyError',
+ VersionError: 'VersionError',
+ OperationError: 'OperationError',
+ NotAllowedError: 'NotAllowedError',
+ OptOutError: 'OptOutError',
+});
+var DOMExceptionNames = Object.keys(DOMExceptionName);
+
+function isValidDomExceptionCode(value) {
+ return typeof value === 'number' && value >= 1 && value <= 25;
+}
+function endsWithError(value) {
+ return typeof value === 'string' && value.substring(value.length - DOMExceptionName.Error.length) === DOMExceptionName.Error;
+}
+/**
+ * DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation
+ * is impossible to perform (either for logical reasons, because data is lost, or because the
+ * implementation has become unstable). In general, DOM methods return specific error values in
+ * ordinary processing situations, such as out-of-bound errors when using NodeList.
+ *
+ * Implementations should raise other exceptions under other circumstances. For example,
+ * implementations should raise an implementation-dependent exception if a null argument is
+ * passed when null was not expected.
+ *
+ * This implementation supports the following usages:
+ * 1. according to the living standard (both arguments are optional):
+ * ```
+ * new DOMException("message (can be empty)", DOMExceptionNames.HierarchyRequestError)
+ * ```
+ * 2. according to previous xmldom implementation (only the first argument is required):
+ * ```
+ * new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "optional message")
+ * ```
+ * both result in the proper name being set.
+ *
+ * @class DOMException
+ * @param {number | string} messageOrCode
+ * The reason why an operation is not acceptable.
+ * If it is a number, it is used to determine the `name`, see
+ * {@link https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-258A00AF ExceptionCode}
+ * @param {string | keyof typeof DOMExceptionName | Error} [nameOrMessage]
+ * The `name` to use for the error.
+ * If `messageOrCode` is a number, this arguments is used as the `message` instead.
+ * @augments Error
+ * @see https://webidl.spec.whatwg.org/#idl-DOMException
+ * @see https://webidl.spec.whatwg.org/#dfn-error-names-table
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-17189187
+ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
+ * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
+ */
+function DOMException(messageOrCode, nameOrMessage) {
+ // support old way of passing arguments: first argument is a valid number
+ if (isValidDomExceptionCode(messageOrCode)) {
+ this.name = DOMExceptionNames[messageOrCode];
+ this.message = nameOrMessage || '';
+ } else {
+ this.message = messageOrCode;
+ this.name = endsWithError(nameOrMessage) ? nameOrMessage : DOMExceptionName.Error;
+ }
+ if (Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
+}
+extendError(DOMException, true);
+Object.defineProperties(DOMException.prototype, {
+ code: {
+ enumerable: true,
+ get: function () {
+ var code = DOMExceptionNames.indexOf(this.name);
+ if (isValidDomExceptionCode(code)) return code;
+ return 0;
+ },
+ },
+});
+
+var ExceptionCode = {
+ INDEX_SIZE_ERR: 1,
+ DOMSTRING_SIZE_ERR: 2,
+ HIERARCHY_REQUEST_ERR: 3,
+ WRONG_DOCUMENT_ERR: 4,
+ INVALID_CHARACTER_ERR: 5,
+ NO_DATA_ALLOWED_ERR: 6,
+ NO_MODIFICATION_ALLOWED_ERR: 7,
+ NOT_FOUND_ERR: 8,
+ NOT_SUPPORTED_ERR: 9,
+ INUSE_ATTRIBUTE_ERR: 10,
+ INVALID_STATE_ERR: 11,
+ SYNTAX_ERR: 12,
+ INVALID_MODIFICATION_ERR: 13,
+ NAMESPACE_ERR: 14,
+ INVALID_ACCESS_ERR: 15,
+ VALIDATION_ERR: 16,
+ TYPE_MISMATCH_ERR: 17,
+ SECURITY_ERR: 18,
+ NETWORK_ERR: 19,
+ ABORT_ERR: 20,
+ URL_MISMATCH_ERR: 21,
+ QUOTA_EXCEEDED_ERR: 22,
+ TIMEOUT_ERR: 23,
+ INVALID_NODE_TYPE_ERR: 24,
+ DATA_CLONE_ERR: 25,
+};
+
+var entries = Object.entries(ExceptionCode);
+for (var i = 0; i < entries.length; i++) {
+ var key = entries[i][0];
+ DOMException[key] = entries[i][1];
+}
+
+/**
+ * Creates an error that will not be caught by XMLReader aka the SAX parser.
+ *
+ * @class
+ * @param {string} message
+ * @param {any} [locator]
+ */
+function ParseError(message, locator) {
+ this.message = message;
+ this.locator = locator;
+ if (Error.captureStackTrace) Error.captureStackTrace(this, ParseError);
+}
+extendError(ParseError);
+
+exports.DOMException = DOMException;
+exports.DOMExceptionName = DOMExceptionName;
+exports.ExceptionCode = ExceptionCode;
+exports.ParseError = ParseError;
+
+},{"./conventions":4}],9:[function(require,module,exports){
+'use strict';
+
+/**
+ * Detects relevant unicode support for regular expressions in the runtime.
+ * Should the runtime not accepts the flag `u` or unicode ranges,
+ * character classes without unicode handling will be used.
+ *
+ * @param {typeof RegExp} [RegExpImpl=RegExp]
+ * For testing: the RegExp class.
+ * @returns {boolean}
+ * @see https://node.green/#ES2015-syntax-RegExp--y--and--u--flags
+ */
+function detectUnicodeSupport(RegExpImpl) {
+ try {
+ if (typeof RegExpImpl !== 'function') {
+ RegExpImpl = RegExp;
+ }
+ // eslint-disable-next-line es5/no-unicode-regex,es5/no-unicode-code-point-escape
+ var match = new RegExpImpl('\u{1d306}', 'u').exec('𝌆');
+ return !!match && match[0].length === 2;
+ } catch (error) {}
+ return false;
+}
+var UNICODE_SUPPORT = detectUnicodeSupport();
+
+/**
+ * Removes `[`, `]` and any trailing quantifiers from the source of a RegExp.
+ *
+ * @param {RegExp} regexp
+ */
+function chars(regexp) {
+ if (regexp.source[0] !== '[') {
+ throw new Error(regexp + ' can not be used with chars');
+ }
+ return regexp.source.slice(1, regexp.source.lastIndexOf(']'));
+}
+
+/**
+ * Creates a new character list regular expression,
+ * by removing `search` from the source of `regexp`.
+ *
+ * @param {RegExp} regexp
+ * @param {string} search
+ * The character(s) to remove.
+ * @returns {RegExp}
+ */
+function chars_without(regexp, search) {
+ if (regexp.source[0] !== '[') {
+ throw new Error('/' + regexp.source + '/ can not be used with chars_without');
+ }
+ if (!search || typeof search !== 'string') {
+ throw new Error(JSON.stringify(search) + ' is not a valid search');
+ }
+ if (regexp.source.indexOf(search) === -1) {
+ throw new Error('"' + search + '" is not is /' + regexp.source + '/');
+ }
+ if (search === '-' && regexp.source.indexOf(search) !== 1) {
+ throw new Error('"' + search + '" is not at the first postion of /' + regexp.source + '/');
+ }
+ return new RegExp(regexp.source.replace(search, ''), UNICODE_SUPPORT ? 'u' : '');
+}
+
+/**
+ * Combines and Regular expressions correctly by using `RegExp.source`.
+ *
+ * @param {...(RegExp | string)[]} args
+ * @returns {RegExp}
+ */
+function reg(args) {
+ var self = this;
+ return new RegExp(
+ Array.prototype.slice
+ .call(arguments)
+ .map(function (part) {
+ var isStr = typeof part === 'string';
+ if (isStr && self === undefined && part === '|') {
+ throw new Error('use regg instead of reg to wrap expressions with `|`!');
+ }
+ return isStr ? part : part.source;
+ })
+ .join(''),
+ UNICODE_SUPPORT ? 'mu' : 'm'
+ );
+}
+
+/**
+ * Like `reg` but wraps the expression in `(?:`,`)` to create a non tracking group.
+ *
+ * @param {...(RegExp | string)[]} args
+ * @returns {RegExp}
+ */
+function regg(args) {
+ if (arguments.length === 0) {
+ throw new Error('no parameters provided');
+ }
+ return reg.apply(regg, ['(?:'].concat(Array.prototype.slice.call(arguments), [')']));
+}
+
+// /**
+// * Append ^ to the beginning of the expression.
+// * @param {...(RegExp | string)[]} args
+// * @returns {RegExp}
+// */
+// function reg_start(args) {
+// if (arguments.length === 0) {
+// throw new Error('no parameters provided');
+// }
+// return reg.apply(reg_start, ['^'].concat(Array.prototype.slice.call(arguments)));
+// }
+
+// https://www.w3.org/TR/xml/#document
+// `[1] document ::= prolog element Misc*`
+// https://www.w3.org/TR/xml11/#NT-document
+// `[1] document ::= ( prolog element Misc* ) - ( Char* RestrictedChar Char* )`
+
+/**
+ * A character usually appearing in wrongly converted strings.
+ *
+ * @type {string}
+ * @see https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character
+ * @see https://nodejs.dev/en/api/v18/buffer/#buffers-and-character-encodings
+ * @see https://www.unicode.org/faq/utf_bom.html#BOM
+ * @readonly
+ */
+var UNICODE_REPLACEMENT_CHARACTER = '\uFFFD';
+// https://www.w3.org/TR/xml/#NT-Char
+// any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
+// `[2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]`
+// https://www.w3.org/TR/xml11/#NT-Char
+// `[2] Char ::= [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]`
+// https://www.w3.org/TR/xml11/#NT-RestrictedChar
+// `[2a] RestrictedChar ::= [#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] | [#x86-#x9F]`
+// https://www.w3.org/TR/xml11/#charsets
+var Char = /[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/; // without \u10000-\uEFFFF
+if (UNICODE_SUPPORT) {
+ // eslint-disable-next-line es5/no-unicode-code-point-escape
+ Char = reg('[', chars(Char), '\\u{10000}-\\u{10FFFF}', ']');
+}
+// Negation of Char: matches any character that is NOT a valid XML 1.0 Char.
+// Derived directly from the Char character class above (after the unicode-support extension).
+// XML 1.0 Char production [2]: #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+// @see https://www.w3.org/TR/xml/#NT-Char
+var InvalidChar = new RegExp('[^' + chars(Char) + ']', UNICODE_SUPPORT ? 'u' : '');
+
+var _SChar = /[\x20\x09\x0D\x0A]/;
+var SChar_s = chars(_SChar);
+// https://www.w3.org/TR/xml11/#NT-S
+// `[3] S ::= (#x20 | #x9 | #xD | #xA)+`
+var S = reg(_SChar, '+');
+// optional whitespace described as `S?` in the grammar,
+// simplified to 0-n occurrences of the character class
+// instead of 0-1 occurrences of a non-capturing group around S
+var S_OPT = reg(_SChar, '*');
+
+// https://www.w3.org/TR/xml11/#NT-NameStartChar
+// `[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]`
+var NameStartChar =
+ /[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/; // without \u10000-\uEFFFF
+if (UNICODE_SUPPORT) {
+ // eslint-disable-next-line es5/no-unicode-code-point-escape
+ NameStartChar = reg('[', chars(NameStartChar), '\\u{10000}-\\u{10FFFF}', ']');
+}
+var NameStartChar_s = chars(NameStartChar);
+
+// https://www.w3.org/TR/xml11/#NT-NameChar
+// `[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]`
+var NameChar = reg('[', NameStartChar_s, chars(/[-.0-9\xB7]/), chars(/[\u0300-\u036F\u203F-\u2040]/), ']');
+// https://www.w3.org/TR/xml11/#NT-Name
+// `[5] Name ::= NameStartChar (NameChar)*`
+var Name = reg(NameStartChar, NameChar, '*');
+/*
+https://www.w3.org/TR/xml11/#NT-Names
+`[6] Names ::= Name (#x20 Name)*`
+*/
+
+// https://www.w3.org/TR/xml11/#NT-Nmtoken
+// `[7] Nmtoken ::= (NameChar)+`
+var Nmtoken = reg(NameChar, '+');
+/*
+https://www.w3.org/TR/xml11/#NT-Nmtokens
+`[8] Nmtokens ::= Nmtoken (#x20 Nmtoken)*`
+var Nmtokens = reg(Nmtoken, regg(/\x20/, Nmtoken), '*');
+*/
+
+// https://www.w3.org/TR/xml11/#NT-EntityRef
+// `[68] EntityRef ::= '&' Name ';'` [WFC: Entity Declared] [VC: Entity Declared] [WFC: Parsed Entity] [WFC: No Recursion]
+var EntityRef = reg('&', Name, ';');
+// https://www.w3.org/TR/xml11/#NT-CharRef
+// `[66] CharRef ::= '' [0-9]+ ';' | '' [0-9a-fA-F]+ ';'` [WFC: Legal Character]
+var CharRef = regg(/[0-9]+;|[0-9a-fA-F]+;/);
+
+/*
+https://www.w3.org/TR/xml11/#NT-Reference
+- `[67] Reference ::= EntityRef | CharRef`
+- `[66] CharRef ::= '' [0-9]+ ';' | '' [0-9a-fA-F]+ ';'` [WFC: Legal Character]
+- `[68] EntityRef ::= '&' Name ';'` [WFC: Entity Declared] [VC: Entity Declared] [WFC: Parsed Entity] [WFC: No Recursion]
+*/
+var Reference = regg(EntityRef, '|', CharRef);
+
+// https://www.w3.org/TR/xml11/#NT-PEReference
+// `[69] PEReference ::= '%' Name ';'`
+// [VC: Entity Declared] [WFC: No Recursion] [WFC: In DTD]
+var PEReference = reg('%', Name, ';');
+
+// https://www.w3.org/TR/xml11/#NT-EntityValue
+// `[9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' | "'" ([^%&'] | PEReference | Reference)* "'"`
+var EntityValue = regg(
+ reg('"', regg(/[^%&"]/, '|', PEReference, '|', Reference), '*', '"'),
+ '|',
+ reg("'", regg(/[^%&']/, '|', PEReference, '|', Reference), '*', "'")
+);
+
+// https://www.w3.org/TR/xml11/#NT-AttValue
+// `[10] AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'"`
+var AttValue = regg('"', regg(/[^<&"]/, '|', Reference), '*', '"', '|', "'", regg(/[^<&']/, '|', Reference), '*', "'");
+
+// https://www.w3.org/TR/xml-names/#ns-decl
+// https://www.w3.org/TR/xml-names/#ns-qualnames
+// NameStartChar without ":"
+var NCNameStartChar = chars_without(NameStartChar, ':');
+// https://www.w3.org/TR/xml-names/#orphans
+// `[5] NCNameChar ::= NameChar - ':'`
+// An XML NameChar, minus the ":"
+var NCNameChar = chars_without(NameChar, ':');
+// https://www.w3.org/TR/xml-names/#NT-NCName
+// `[4] NCName ::= Name - (Char* ':' Char*)`
+// An XML Name, minus the ":"
+var NCName = reg(NCNameStartChar, NCNameChar, '*');
+
+/**
+https://www.w3.org/TR/xml-names/#ns-qualnames
+
+```
+[7] QName ::= PrefixedName | UnprefixedName
+ === (NCName ':' NCName) | NCName
+ === NCName (':' NCName)?
+[8] PrefixedName ::= Prefix ':' LocalPart
+ === NCName ':' NCName
+[9] UnprefixedName ::= LocalPart
+ === NCName
+[10] Prefix ::= NCName
+[11] LocalPart ::= NCName
+```
+*/
+var QName = reg(NCName, regg(':', NCName), '?');
+var QName_exact = reg('^', QName, '$');
+var QName_group = reg('(', QName, ')');
+
+// https://www.w3.org/TR/xml11/#NT-SystemLiteral
+// `[11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")`
+var SystemLiteral = regg(/"[^"]*"|'[^']*'/);
+
+/*
+ https://www.w3.org/TR/xml11/#NT-PI
+ ```
+ [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
+ [16] PI ::= '' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
+ ```
+ target /xml/i is not excluded!
+*/
+var PI = reg(/^<\?/, '(', Name, ')', regg(S, '(', Char, '*?)'), '?', /\?>/);
+
+// https://www.w3.org/TR/xml11/#NT-PubidChar
+// `[13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]`
+var PubidChar = /[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/;
+
+// https://www.w3.org/TR/xml11/#NT-PubidLiteral
+// `[12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"`
+var PubidLiteral = regg('"', PubidChar, '*"', '|', "'", chars_without(PubidChar, "'"), "*'");
+
+// https://www.w3.org/TR/xml11/#NT-CharData
+// `[14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)`
+
+var COMMENT_START = '';
+// https://www.w3.org/TR/xml11/#NT-Comment
+// `[15] Comment ::= ''`
+var Comment = reg(COMMENT_START, regg(chars_without(Char, '-'), '|', reg('-', chars_without(Char, '-'))), '*', COMMENT_END);
+
+var PCDATA = '#PCDATA';
+// https://www.w3.org/TR/xml11/#NT-Mixed
+// `[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')'`
+// https://www.w3.org/TR/xml-names/#NT-Mixed
+// `[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? QName)* S? ')*' | '(' S? '#PCDATA' S? ')'`
+// [VC: Proper Group/PE Nesting] [VC: No Duplicate Types]
+var Mixed = regg(
+ reg(/\(/, S_OPT, PCDATA, regg(S_OPT, /\|/, S_OPT, QName), '*', S_OPT, /\)\*/),
+ '|',
+ reg(/\(/, S_OPT, PCDATA, S_OPT, /\)/)
+);
+
+var _children_quantity = /[?*+]?/;
+/*
+ `[49] choice ::= '(' S? cp ( S? '|' S? cp )+ S? ')'` [VC: Proper Group/PE Nesting]
+ `[50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'` [VC: Proper Group/PE Nesting]
+ simplification to solve circular referencing, but doesn't check validity constraint "Proper Group/PE Nesting"
+ var _choice_or_seq = reg('[', NameChar_s, SChar_s, chars(_children_quantity), '()|,]*');
+ ```
+ [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?
+ === (Name | '(' S? cp ( S? '|' S? cp )+ S? ')' | '(' S? cp ( S? ',' S? cp )* S? ')') ('?' | '*' | '+')?
+ !== (Name | [_choice_or_seq]*) ('?' | '*' | '+')?
+ ```
+ simplification to solve circular referencing, but doesn't check validity constraint "Proper Group/PE Nesting"
+ var cp = reg(regg(Name, '|', _choice_or_seq), _children_quantity);
+*/
+/*
+Inefficient regular expression (High)
+This part of the regular expression may cause exponential backtracking on strings starting with '(|' and containing many repetitions of '|'.
+https://github.com/xmldom/xmldom/security/code-scanning/91
+var choice = regg(/\(/, S_OPT, cp, regg(S_OPT, /\|/, S_OPT, cp), '+', S_OPT, /\)/);
+*/
+/*
+Inefficient regular expression (High)
+This part of the regular expression may cause exponential backtracking on strings starting with '(,' and containing many repetitions of ','.
+https://github.com/xmldom/xmldom/security/code-scanning/92
+var seq = regg(/\(/, S_OPT, cp, regg(S_OPT, /,/, S_OPT, cp), '*', S_OPT, /\)/);
+*/
+
+// `[47] children ::= (choice | seq) ('?' | '*' | '+')?`
+// simplification to solve circular referencing, but doesn't check validity constraint "Proper Group/PE Nesting"
+var children = reg(/\([^>]+\)/, _children_quantity /*regg(choice, '|', seq), _children_quantity*/);
+
+// https://www.w3.org/TR/xml11/#NT-contentspec
+// `[46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children`
+var contentspec = regg('EMPTY', '|', 'ANY', '|', Mixed, '|', children);
+
+var ELEMENTDECL_START = ''`
+// https://www.w3.org/TR/xml-names/#NT-elementdecl
+// `[17] elementdecl ::= ''`
+// because of https://www.w3.org/TR/xml11/#NT-PEReference
+// since xmldom is not supporting replacements of PEReferences in the DTD
+// this also supports PEReference in the possible places
+var elementdecl = reg(ELEMENTDECL_START, S, regg(QName, '|', PEReference), S, regg(contentspec, '|', PEReference), S_OPT, '>');
+
+// https://www.w3.org/TR/xml11/#NT-NotationType
+// `[58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')'`
+// [VC: Notation Attributes] [VC: One Notation Per Element Type] [VC: No Notation on Empty Element] [VC: No Duplicate Tokens]
+var NotationType = reg('NOTATION', S, /\(/, S_OPT, Name, regg(S_OPT, /\|/, S_OPT, Name), '*', S_OPT, /\)/);
+// https://www.w3.org/TR/xml11/#NT-Enumeration
+// `[59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')'`
+// [VC: Enumeration] [VC: No Duplicate Tokens]
+var Enumeration = reg(/\(/, S_OPT, Nmtoken, regg(S_OPT, /\|/, S_OPT, Nmtoken), '*', S_OPT, /\)/);
+
+// https://www.w3.org/TR/xml11/#NT-EnumeratedType
+// `[57] EnumeratedType ::= NotationType | Enumeration`
+var EnumeratedType = regg(NotationType, '|', Enumeration);
+
+/*
+```
+[55] StringType ::= 'CDATA'
+[56] TokenizedType ::= 'ID' [VC: ID] [VC: One ID per Element Type] [VC: ID Attribute Default]
+ | 'IDREF' [VC: IDREF]
+ | 'IDREFS' [VC: IDREF]
+ | 'ENTITY' [VC: Entity Name]
+ | 'ENTITIES' [VC: Entity Name]
+ | 'NMTOKEN' [VC: Name Token]
+ | 'NMTOKENS' [VC: Name Token]
+ [54] AttType ::= StringType | TokenizedType | EnumeratedType
+```*/
+var AttType = regg(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/, '|', EnumeratedType);
+
+// `[60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)`
+// [WFC: No < in Attribute Values] [WFC: No External Entity References]
+// [VC: Fixed Attribute Default] [VC: Required Attribute] [VC: Attribute Default Value Syntactically Correct]
+var DefaultDecl = regg(/#REQUIRED|#IMPLIED/, '|', regg(regg('#FIXED', S), '?', AttValue));
+
+// https://www.w3.org/TR/xml11/#NT-AttDef
+// [53] AttDef ::= S Name S AttType S DefaultDecl
+// https://www.w3.org/TR/xml-names/#NT-AttDef
+// [1] NSAttName ::= PrefixedAttName | DefaultAttName
+// [2] PrefixedAttName ::= 'xmlns:' NCName [NSC: Reserved Prefixes and Namespace Names]
+// [3] DefaultAttName ::= 'xmlns'
+// [21] AttDef ::= S (QName | NSAttName) S AttType S DefaultDecl
+// === S Name S AttType S DefaultDecl
+// xmldom is not distinguishing between QName and NSAttName on this level
+// to support XML without namespaces in DTD we can not restrict it to QName
+var AttDef = regg(S, Name, S, AttType, S, DefaultDecl);
+
+var ATTLIST_DECL_START = ''`
+// https://www.w3.org/TR/xml-names/#NT-AttlistDecl
+// `[20] AttlistDecl ::= ''`
+// to support XML without namespaces in DTD we can not restrict it to QName
+var AttlistDecl = reg(ATTLIST_DECL_START, S, Name, AttDef, '*', S_OPT, '>');
+
+// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#about:legacy-compat
+var ABOUT_LEGACY_COMPAT = 'about:legacy-compat';
+var ABOUT_LEGACY_COMPAT_SystemLiteral = regg('"' + ABOUT_LEGACY_COMPAT + '"', '|', "'" + ABOUT_LEGACY_COMPAT + "'");
+var SYSTEM = 'SYSTEM';
+var PUBLIC = 'PUBLIC';
+// https://www.w3.org/TR/xml11/#NT-ExternalID
+// `[75] ExternalID ::= 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral`
+var ExternalID = regg(regg(SYSTEM, S, SystemLiteral), '|', regg(PUBLIC, S, PubidLiteral, S, SystemLiteral));
+var ExternalID_match = reg(
+ '^',
+ regg(
+ regg(SYSTEM, S, '(?', SystemLiteral, ')'),
+ '|',
+ regg(PUBLIC, S, '(?', PubidLiteral, ')', S, '(?', SystemLiteral, ')')
+ )
+);
+// Full-string anchored matcher for requireWellFormed serializer checks
+// https://w3c.github.io/DOM-Parsing/#xml-serializing-a-document-node
+var PubidLiteral_match = reg('^', PubidLiteral, '$');
+// Full-string anchored matcher for requireWellFormed serializer checks
+// https://w3c.github.io/DOM-Parsing/#xml-serializing-a-document-node
+var SystemLiteral_match = reg('^', SystemLiteral, '$');
+
+// https://www.w3.org/TR/xml11/#NT-NDataDecl
+// `[76] NDataDecl ::= S 'NDATA' S Name` [VC: Notation Declared]
+var NDataDecl = regg(S, 'NDATA', S, Name);
+
+// https://www.w3.org/TR/xml11/#NT-EntityDef
+// `[73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)`
+var EntityDef = regg(EntityValue, '|', regg(ExternalID, NDataDecl, '?'));
+
+var ENTITY_DECL_START = ''`
+var GEDecl = reg(ENTITY_DECL_START, S, Name, S, EntityDef, S_OPT, '>');
+// https://www.w3.org/TR/xml11/#NT-PEDef
+// `[74] PEDef ::= EntityValue | ExternalID`
+var PEDef = regg(EntityValue, '|', ExternalID);
+// https://www.w3.org/TR/xml11/#NT-PEDecl
+// `[72] PEDecl ::= ''`
+var PEDecl = reg(ENTITY_DECL_START, S, '%', S, Name, S, PEDef, S_OPT, '>');
+// https://www.w3.org/TR/xml11/#NT-EntityDecl
+// `[70] EntityDecl ::= GEDecl | PEDecl`
+var EntityDecl = regg(GEDecl, '|', PEDecl);
+
+// https://www.w3.org/TR/xml11/#NT-PublicID
+// `[83] PublicID ::= 'PUBLIC' S PubidLiteral`
+var PublicID = reg(PUBLIC, S, PubidLiteral);
+// https://www.w3.org/TR/xml11/#NT-NotationDecl
+// `[82] NotationDecl ::= ''` [VC: Unique Notation Name]
+var NotationDecl = reg('');
+
+// https://www.w3.org/TR/xml11/#NT-Eq
+// `[25] Eq ::= S? '=' S?`
+var Eq = reg(S_OPT, '=', S_OPT);
+// https://www.w3.org/TR/xml/#NT-VersionNum
+// `[26] VersionNum ::= '1.' [0-9]+`
+// https://www.w3.org/TR/xml11/#NT-VersionNum
+// `[26] VersionNum ::= '1.1'`
+var VersionNum = /1[.]\d+/;
+// https://www.w3.org/TR/xml11/#NT-VersionInfo
+// `[24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')`
+var VersionInfo = reg(S, 'version', Eq, regg("'", VersionNum, "'", '|', '"', VersionNum, '"'));
+// https://www.w3.org/TR/xml11/#NT-EncName
+// `[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*`
+var EncName = /[A-Za-z][-A-Za-z0-9._]*/;
+// https://www.w3.org/TR/xml11/#NT-EncDecl
+// `[80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'" )`
+var EncodingDecl = regg(S, 'encoding', Eq, regg('"', EncName, '"', '|', "'", EncName, "'"));
+// https://www.w3.org/TR/xml11/#NT-SDDecl
+// `[32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))`
+var SDDecl = regg(S, 'standalone', Eq, regg("'", regg('yes', '|', 'no'), "'", '|', '"', regg('yes', '|', 'no'), '"'));
+// https://www.w3.org/TR/xml11/#NT-XMLDecl
+// [23] XMLDecl ::= ''
+var XMLDecl = reg(/^<\?xml/, VersionInfo, EncodingDecl, '?', SDDecl, '?', S_OPT, /\?>/);
+
+/*
+ https://www.w3.org/TR/xml/#NT-markupdecl
+ https://www.w3.org/TR/xml11/#NT-markupdecl
+ `[29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment`
+ var markupdecl = regg(elementdecl, '|', AttlistDecl, '|', EntityDecl, '|', NotationDecl, '|', PI_unsafe, '|', Comment);
+*/
+/*
+ https://www.w3.org/TR/xml-names/#NT-doctypedecl
+`[28a] DeclSep ::= PEReference | S`
+ https://www.w3.org/TR/xml11/#NT-intSubset
+```
+ [28b] intSubset ::= (markupdecl | DeclSep)*
+ === (markupdecl | PEReference | S)*
+```
+ [WFC: PE Between Declarations]
+ var intSubset = reg(regg(markupdecl, '|', PEReference, '|', S), '*');
+*/
+var DOCTYPE_DECL_START = ''`
+ https://www.afterwardsw3.org/TR/xml-names/#NT-doctypedecl
+ `[16] doctypedecl ::= ''`
+ var doctypedecl = reg('');
+*/
+
+var CDATA_START = '';
+var CDStart = //;
+var CData = reg(Char, '*?', CDEnd);
+/*
+ https://www.w3.org/TR/xml/#dt-cdsection
+ `[18] CDSect ::= CDStart CData CDEnd`
+ `[19] CDStart ::= '' Char*))`
+ `[21] CDEnd ::= ']]>'`
+*/
+var CDSect = reg(CDStart, CData);
+
+// unit tested
+exports.chars = chars;
+exports.chars_without = chars_without;
+exports.detectUnicodeSupport = detectUnicodeSupport;
+exports.reg = reg;
+exports.regg = regg;
+exports.ABOUT_LEGACY_COMPAT = ABOUT_LEGACY_COMPAT;
+exports.ABOUT_LEGACY_COMPAT_SystemLiteral = ABOUT_LEGACY_COMPAT_SystemLiteral;
+exports.AttlistDecl = AttlistDecl;
+exports.CDATA_START = CDATA_START;
+exports.CDATA_END = CDATA_END;
+exports.CDSect = CDSect;
+exports.Char = Char;
+exports.Comment = Comment;
+exports.COMMENT_START = COMMENT_START;
+exports.COMMENT_END = COMMENT_END;
+exports.DOCTYPE_DECL_START = DOCTYPE_DECL_START;
+exports.elementdecl = elementdecl;
+exports.EntityDecl = EntityDecl;
+exports.EntityValue = EntityValue;
+exports.ExternalID = ExternalID;
+exports.ExternalID_match = ExternalID_match;
+exports.Name = Name;
+exports.NotationDecl = NotationDecl;
+exports.Reference = Reference;
+exports.PEReference = PEReference;
+exports.PI = PI;
+exports.PUBLIC = PUBLIC;
+exports.PubidLiteral = PubidLiteral;
+exports.PubidLiteral_match = PubidLiteral_match;
+exports.QName = QName;
+exports.QName_exact = QName_exact;
+exports.QName_group = QName_group;
+exports.S = S;
+exports.SChar_s = SChar_s;
+exports.S_OPT = S_OPT;
+exports.SYSTEM = SYSTEM;
+exports.SystemLiteral = SystemLiteral;
+exports.SystemLiteral_match = SystemLiteral_match;
+exports.InvalidChar = InvalidChar;
+exports.UNICODE_REPLACEMENT_CHARACTER = UNICODE_REPLACEMENT_CHARACTER;
+exports.UNICODE_SUPPORT = UNICODE_SUPPORT;
+exports.XMLDecl = XMLDecl;
+
+},{}],10:[function(require,module,exports){
+'use strict';
+var conventions = require('./conventions');
+exports.assign = conventions.assign;
+exports.hasDefaultHTMLNamespace = conventions.hasDefaultHTMLNamespace;
+exports.isHTMLMimeType = conventions.isHTMLMimeType;
+exports.isValidMimeType = conventions.isValidMimeType;
+exports.MIME_TYPE = conventions.MIME_TYPE;
+exports.NAMESPACE = conventions.NAMESPACE;
+
+var errors = require('./errors');
+exports.DOMException = errors.DOMException;
+exports.DOMExceptionName = errors.DOMExceptionName;
+exports.ExceptionCode = errors.ExceptionCode;
+exports.ParseError = errors.ParseError;
+
+var dom = require('./dom');
+exports.Attr = dom.Attr;
+exports.CDATASection = dom.CDATASection;
+exports.CharacterData = dom.CharacterData;
+exports.Comment = dom.Comment;
+exports.Document = dom.Document;
+exports.DocumentFragment = dom.DocumentFragment;
+exports.DocumentType = dom.DocumentType;
+exports.DOMImplementation = dom.DOMImplementation;
+exports.Element = dom.Element;
+exports.Entity = dom.Entity;
+exports.EntityReference = dom.EntityReference;
+exports.LiveNodeList = dom.LiveNodeList;
+exports.NamedNodeMap = dom.NamedNodeMap;
+exports.Node = dom.Node;
+exports.NodeList = dom.NodeList;
+exports.Notation = dom.Notation;
+exports.ProcessingInstruction = dom.ProcessingInstruction;
+exports.Text = dom.Text;
+exports.XMLSerializer = dom.XMLSerializer;
+
+var domParser = require('./dom-parser');
+exports.DOMParser = domParser.DOMParser;
+exports.normalizeLineEndings = domParser.normalizeLineEndings;
+exports.onErrorStopParsing = domParser.onErrorStopParsing;
+exports.onWarningStopParsing = domParser.onWarningStopParsing;
+
+},{"./conventions":4,"./dom":6,"./dom-parser":5,"./errors":8}],11:[function(require,module,exports){
+'use strict';
+
+var conventions = require('./conventions');
+var g = require('./grammar');
+var errors = require('./errors');
+
+var isHTMLEscapableRawTextElement = conventions.isHTMLEscapableRawTextElement;
+var isHTMLMimeType = conventions.isHTMLMimeType;
+var isHTMLRawTextElement = conventions.isHTMLRawTextElement;
+var hasOwn = conventions.hasOwn;
+var NAMESPACE = conventions.NAMESPACE;
+var ParseError = errors.ParseError;
+var DOMException = errors.DOMException;
+
+//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
+
+//S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
+//S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
+var S_TAG = 0; //tag name offerring
+var S_ATTR = 1; //attr name offerring
+var S_ATTR_SPACE = 2; //attr name end and space offer
+var S_EQ = 3; //=space?
+var S_ATTR_NOQUOT_VALUE = 4; //attr value(no quot value only)
+var S_ATTR_END = 5; //attr value end and no space(quot end)
+var S_TAG_SPACE = 6; //(attr value end || tag end ) && (space offer)
+var S_TAG_CLOSE = 7; //closed el
+
+function XMLReader() {}
+
+XMLReader.prototype = {
+ parse: function (source, defaultNSMap, entityMap) {
+ var domBuilder = this.domBuilder;
+ domBuilder.startDocument();
+ _copy(defaultNSMap, (defaultNSMap = Object.create(null)));
+ parse(source, defaultNSMap, entityMap, domBuilder, this.errorHandler);
+ domBuilder.endDocument();
+ },
+};
+
+/**
+ * Detecting everything that might be a reference,
+ * including those without ending `;`, since those are allowed in HTML.
+ * The entityReplacer takes care of verifying and transforming each occurrence,
+ * and reports to the errorHandler on those that are not OK,
+ * depending on the context.
+ */
+var ENTITY_REG = /?\w+;?/g;
+
+function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
+ var isHTML = isHTMLMimeType(domBuilder.mimeType);
+ if (source.indexOf(g.UNICODE_REPLACEMENT_CHARACTER) >= 0) {
+ errorHandler.warning('Unicode replacement character detected, source encoding issues?');
+ }
+
+ function fixedFromCharCode(code) {
+ // String.prototype.fromCharCode does not supports
+ // > 2 bytes unicode chars directly
+ if (code > 0xffff) {
+ code -= 0x10000;
+ var surrogate1 = 0xd800 + (code >> 10),
+ surrogate2 = 0xdc00 + (code & 0x3ff);
+
+ return String.fromCharCode(surrogate1, surrogate2);
+ } else {
+ return String.fromCharCode(code);
+ }
+ }
+
+ function entityReplacer(a) {
+ var complete = a[a.length - 1] === ';' ? a : a + ';';
+ if (!isHTML && complete !== a) {
+ errorHandler.error('EntityRef: expecting ;');
+ return a;
+ }
+ var match = g.Reference.exec(complete);
+ if (!match || match[0].length !== complete.length) {
+ errorHandler.error('entity not matching Reference production: ' + a);
+ return a;
+ }
+ var k = complete.slice(1, -1);
+ if (hasOwn(entityMap, k)) {
+ return entityMap[k];
+ } else if (k.charAt(0) === '#') {
+ return fixedFromCharCode(parseInt(k.substring(1).replace('x', '0x')));
+ } else {
+ errorHandler.error('entity not found:' + a);
+ return a;
+ }
+ }
+
+ function appendText(end) {
+ //has some bugs
+ if (end > start) {
+ var xt = source.substring(start, end).replace(ENTITY_REG, entityReplacer);
+ locator && position(start);
+ domBuilder.characters(xt, 0, end - start);
+ start = end;
+ }
+ }
+
+ var lineStart = 0;
+ var lineEnd = 0;
+ var linePattern = /\r\n?|\n|$/g;
+ var locator = domBuilder.locator;
+
+ function position(p, m) {
+ while (p >= lineEnd && (m = linePattern.exec(source))) {
+ lineStart = lineEnd;
+ lineEnd = m.index + m[0].length;
+ locator.lineNumber++;
+ }
+ locator.columnNumber = p - lineStart + 1;
+ }
+
+ var parseStack = [{ currentNSMap: defaultNSMapCopy }];
+ var unclosedTags = [];
+ var start = 0;
+ while (true) {
+ try {
+ var tagStart = source.indexOf('<', start);
+ if (tagStart < 0) {
+ if (!isHTML && unclosedTags.length > 0) {
+ return errorHandler.fatalError('unclosed xml tag(s): ' + unclosedTags.join(', '));
+ }
+ if (!source.substring(start).match(/^\s*$/)) {
+ var doc = domBuilder.doc;
+ var text = doc.createTextNode(source.substring(start));
+ if (doc.documentElement) {
+ return errorHandler.error('Extra content at the end of the document');
+ }
+ doc.appendChild(text);
+ domBuilder.currentElement = text;
+ }
+ return;
+ }
+ if (tagStart > start) {
+ var fromSource = source.substring(start, tagStart);
+ if (!isHTML && unclosedTags.length === 0) {
+ fromSource = fromSource.replace(new RegExp(g.S_OPT.source, 'g'), '');
+ fromSource && errorHandler.error("Unexpected content outside root element: '" + fromSource + "'");
+ }
+ appendText(tagStart);
+ }
+ switch (source.charAt(tagStart + 1)) {
+ case '/':
+ var end = source.indexOf('>', tagStart + 2);
+ var tagNameRaw = source.substring(tagStart + 2, end > 0 ? end : undefined);
+ if (!tagNameRaw) {
+ return errorHandler.fatalError('end tag name missing');
+ }
+ var tagNameMatch = end > 0 && g.reg('^', g.QName_group, g.S_OPT, '$').exec(tagNameRaw);
+ if (!tagNameMatch) {
+ return errorHandler.fatalError('end tag name contains invalid characters: "' + tagNameRaw + '"');
+ }
+ if (!domBuilder.currentElement && !domBuilder.doc.documentElement) {
+ // not enough information to provide a helpful error message,
+ // but parsing will throw since there is no root element
+ return;
+ }
+ var currentTagName =
+ unclosedTags[unclosedTags.length - 1] ||
+ domBuilder.currentElement.tagName ||
+ domBuilder.doc.documentElement.tagName ||
+ '';
+ if (currentTagName !== tagNameMatch[1]) {
+ var tagNameLower = tagNameMatch[1].toLowerCase();
+ if (!isHTML || currentTagName.toLowerCase() !== tagNameLower) {
+ return errorHandler.fatalError('Opening and ending tag mismatch: "' + currentTagName + '" != "' + tagNameRaw + '"');
+ }
+ }
+ var config = parseStack.pop();
+ unclosedTags.pop();
+ var localNSMap = config.localNSMap;
+ domBuilder.endElement(config.uri, config.localName, currentTagName);
+ if (localNSMap) {
+ for (var prefix in localNSMap) {
+ if (hasOwn(localNSMap, prefix)) {
+ domBuilder.endPrefixMapping(prefix);
+ }
+ }
+ }
+
+ end++;
+ break;
+ // end element
+ case '?': // ...?>
+ locator && position(tagStart);
+ end = parseProcessingInstruction(source, tagStart, domBuilder, errorHandler);
+ break;
+ case '!': // start) {
+ start = end;
+ } else {
+ //Possible sax fallback here, risk of positional error
+ appendText(Math.max(tagStart, start) + 1);
+ }
+ }
+}
+
+function copyLocator(f, t) {
+ t.lineNumber = f.lineNumber;
+ t.columnNumber = f.columnNumber;
+ return t;
+}
+
+/**
+ * @returns
+ * end of the elementStartPart(end of elementEndPart for selfClosed el)
+ * @see {@link #appendElement}
+ */
+function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler, isHTML) {
+ /**
+ * @param {string} qname
+ * @param {string} value
+ * @param {number} startIndex
+ */
+ function addAttribute(qname, value, startIndex) {
+ if (hasOwn(el.attributeNames, qname)) {
+ return errorHandler.fatalError('Attribute ' + qname + ' redefined');
+ }
+ if (!isHTML && value.indexOf('<') >= 0) {
+ return errorHandler.fatalError("Unescaped '<' not allowed in attributes values");
+ }
+ el.addValue(
+ qname,
+ // @see https://www.w3.org/TR/xml/#AVNormalize
+ // since the xmldom sax parser does not "interpret" DTD the following is not implemented:
+ // - recursive replacement of (DTD) entity references
+ // - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA
+ value.replace(/[\t\n\r]/g, ' ').replace(ENTITY_REG, entityReplacer),
+ startIndex
+ );
+ }
+
+ var attrName;
+ var value;
+ var p = ++start;
+ var s = S_TAG; //status
+ while (true) {
+ var c = source.charAt(p);
+ switch (c) {
+ case '=':
+ if (s === S_ATTR) {
+ //attrName
+ attrName = source.slice(start, p);
+ s = S_EQ;
+ } else if (s === S_ATTR_SPACE) {
+ s = S_EQ;
+ } else {
+ //fatalError: equal must after attrName or space after attrName
+ throw new Error('attribute equal must after attrName'); // No known test case
+ }
+ break;
+ case "'":
+ case '"':
+ if (
+ s === S_EQ ||
+ s === S_ATTR //|| s == S_ATTR_SPACE
+ ) {
+ //equal
+ if (s === S_ATTR) {
+ errorHandler.warning('attribute value must after "="');
+ attrName = source.slice(start, p);
+ }
+ start = p + 1;
+ p = source.indexOf(c, start);
+ if (p > 0) {
+ value = source.slice(start, p);
+ addAttribute(attrName, value, start - 1);
+ s = S_ATTR_END;
+ } else {
+ //fatalError: no end quot match
+ throw new Error("attribute value no end '" + c + "' match");
+ }
+ } else if (s == S_ATTR_NOQUOT_VALUE) {
+ value = source.slice(start, p);
+ addAttribute(attrName, value, start);
+ errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ')!!');
+ start = p + 1;
+ s = S_ATTR_END;
+ } else {
+ //fatalError: no equal before
+ throw new Error('attribute value must after "="'); // No known test case
+ }
+ break;
+ case '/':
+ switch (s) {
+ case S_TAG:
+ el.setTagName(source.slice(start, p));
+ case S_ATTR_END:
+ case S_TAG_SPACE:
+ case S_TAG_CLOSE:
+ s = S_TAG_CLOSE;
+ el.closed = true;
+ case S_ATTR_NOQUOT_VALUE:
+ case S_ATTR:
+ break;
+ case S_ATTR_SPACE:
+ el.closed = true;
+ break;
+ //case S_EQ:
+ default:
+ throw new Error("attribute invalid close char('/')"); // No known test case
+ }
+ break;
+ case '': //end document
+ errorHandler.error('unexpected end of input');
+ if (s == S_TAG) {
+ el.setTagName(source.slice(start, p));
+ }
+ return p;
+ case '>':
+ switch (s) {
+ case S_TAG:
+ el.setTagName(source.slice(start, p));
+ case S_ATTR_END:
+ case S_TAG_SPACE:
+ case S_TAG_CLOSE:
+ break; //normal
+ case S_ATTR_NOQUOT_VALUE: //Compatible state
+ case S_ATTR:
+ value = source.slice(start, p);
+ if (value.slice(-1) === '/') {
+ el.closed = true;
+ value = value.slice(0, -1);
+ }
+ case S_ATTR_SPACE:
+ if (s === S_ATTR_SPACE) {
+ value = attrName;
+ }
+ if (s == S_ATTR_NOQUOT_VALUE) {
+ errorHandler.warning('attribute "' + value + '" missed quot(")!');
+ addAttribute(attrName, value, start);
+ } else {
+ if (!isHTML) {
+ errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!');
+ }
+ addAttribute(value, value, start);
+ }
+ break;
+ case S_EQ:
+ if (!isHTML) {
+ return errorHandler.fatalError('AttValue: \' or " expected');
+ }
+ }
+ return p;
+ /*xml space '\x20' | #x9 | #xD | #xA; */
+ case '\u0080':
+ c = ' ';
+ default:
+ if (c <= ' ') {
+ //space
+ switch (s) {
+ case S_TAG:
+ el.setTagName(source.slice(start, p)); //tagName
+ s = S_TAG_SPACE;
+ break;
+ case S_ATTR:
+ attrName = source.slice(start, p);
+ s = S_ATTR_SPACE;
+ break;
+ case S_ATTR_NOQUOT_VALUE:
+ var value = source.slice(start, p);
+ errorHandler.warning('attribute "' + value + '" missed quot(")!!');
+ addAttribute(attrName, value, start);
+ case S_ATTR_END:
+ s = S_TAG_SPACE;
+ break;
+ //case S_TAG_SPACE:
+ //case S_EQ:
+ //case S_ATTR_SPACE:
+ // void();break;
+ //case S_TAG_CLOSE:
+ //ignore warning
+ }
+ } else {
+ //not space
+ //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
+ //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
+ switch (s) {
+ //case S_TAG:void();break;
+ //case S_ATTR:void();break;
+ //case S_ATTR_NOQUOT_VALUE:void();break;
+ case S_ATTR_SPACE:
+ if (!isHTML) {
+ errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!');
+ }
+ addAttribute(attrName, attrName, start);
+ start = p;
+ s = S_ATTR;
+ break;
+ case S_ATTR_END:
+ errorHandler.warning('attribute space is required"' + attrName + '"!!');
+ case S_TAG_SPACE:
+ s = S_ATTR;
+ start = p;
+ break;
+ case S_EQ:
+ s = S_ATTR_NOQUOT_VALUE;
+ start = p;
+ break;
+ case S_TAG_CLOSE:
+ throw new Error("elements closed character '/' and '>' must be connected to");
+ }
+ }
+ } //end outer switch
+ p++;
+ }
+}
+
+/**
+ * @returns
+ * `true` if a new namespace has been defined.
+ */
+function appendElement(el, domBuilder, currentNSMap) {
+ var tagName = el.tagName;
+ var localNSMap = null;
+ var i = el.length;
+ while (i--) {
+ var a = el[i];
+ var qName = a.qName;
+ var value = a.value;
+ var nsp = qName.indexOf(':');
+ if (nsp > 0) {
+ var prefix = (a.prefix = qName.slice(0, nsp));
+ var localName = qName.slice(nsp + 1);
+ var nsPrefix = prefix === 'xmlns' && localName;
+ } else {
+ localName = qName;
+ prefix = null;
+ nsPrefix = qName === 'xmlns' && '';
+ }
+ //can not set prefix,because prefix !== ''
+ a.localName = localName;
+ //prefix == null for no ns prefix attribute
+ if (nsPrefix !== false) {
+ //hack!!
+ if (localNSMap == null) {
+ localNSMap = Object.create(null);
+ _copy(currentNSMap, (currentNSMap = Object.create(null)));
+ }
+ currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
+ a.uri = NAMESPACE.XMLNS;
+ domBuilder.startPrefixMapping(nsPrefix, value);
+ }
+ }
+ var i = el.length;
+ while (i--) {
+ a = el[i];
+ if (a.prefix) {
+ //no prefix attribute has no namespace
+ if (a.prefix === 'xml') {
+ a.uri = NAMESPACE.XML;
+ }
+ if (a.prefix !== 'xmlns') {
+ a.uri = currentNSMap[a.prefix];
+ }
+ }
+ }
+ var nsp = tagName.indexOf(':');
+ if (nsp > 0) {
+ prefix = el.prefix = tagName.slice(0, nsp);
+ localName = el.localName = tagName.slice(nsp + 1);
+ } else {
+ prefix = null; //important!!
+ localName = el.localName = tagName;
+ }
+ //no prefix element has default namespace
+ var ns = (el.uri = currentNSMap[prefix || '']);
+ domBuilder.startElement(ns, localName, tagName, el);
+ //endPrefixMapping and startPrefixMapping have not any help for dom builder
+ //localNSMap = null
+ if (el.closed) {
+ domBuilder.endElement(ns, localName, tagName);
+ if (localNSMap) {
+ for (prefix in localNSMap) {
+ if (hasOwn(localNSMap, prefix)) {
+ domBuilder.endPrefixMapping(prefix);
+ }
+ }
+ }
+ } else {
+ el.currentNSMap = currentNSMap;
+ el.localNSMap = localNSMap;
+ //parseStack.push(el);
+ return true;
+ }
+}
+
+function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
+ // https://html.spec.whatwg.org/#raw-text-elements
+ // https://html.spec.whatwg.org/#escapable-raw-text-elements
+ // https://html.spec.whatwg.org/#cdata-rcdata-restrictions:raw-text-elements
+ // TODO: https://html.spec.whatwg.org/#cdata-rcdata-restrictions
+ var isEscapableRaw = isHTMLEscapableRawTextElement(tagName);
+ if (isEscapableRaw || isHTMLRawTextElement(tagName)) {
+ var elEndStart = source.indexOf('' + tagName + '>', elStartEnd);
+ var text = source.substring(elStartEnd + 1, elEndStart);
+
+ if (isEscapableRaw) {
+ text = text.replace(ENTITY_REG, entityReplacer);
+ }
+ domBuilder.characters(text, 0, text.length);
+ return elEndStart;
+ }
+ return elStartEnd + 1;
+}
+
+function _copy(source, target) {
+ for (var n in source) {
+ if (hasOwn(source, n)) {
+ target[n] = source[n];
+ }
+ }
+}
+
+/**
+ * @typedef ParseUtils
+ * @property {function(relativeIndex: number?): string | undefined} char
+ * Provides look ahead access to a singe character relative to the current index.
+ * @property {function(): number} getIndex
+ * Provides read-only access to the current index.
+ * @property {function(reg: RegExp): string | null} getMatch
+ * Applies the provided regular expression enforcing that it starts at the current index and
+ * returns the complete matching string,
+ * and moves the current index by the length of the matching string.
+ * @property {function(): string} getSource
+ * Provides read-only access to the complete source.
+ * @property {function(places: number?): void} skip
+ * moves the current index by places (defaults to 1)
+ * @property {function(): number} skipBlanks
+ * Moves the current index by the amount of white space that directly follows the current index
+ * and returns the amount of whitespace chars skipped (0..n),
+ * or -1 if the end of the source was reached.
+ * @property {function(): string} substringFromIndex
+ * creates a substring from the current index to the end of `source`
+ * @property {function(compareWith: string): boolean} substringStartsWith
+ * Checks if `source` contains `compareWith`, starting from the current index.
+ * @property {function(compareWith: string): boolean} substringStartsWithCaseInsensitive
+ * Checks if `source` contains `compareWith`, starting from the current index,
+ * comparing the upper case of both sides.
+ * @see {@link parseUtils}
+ */
+
+/**
+ * A temporary scope for parsing and look ahead operations in `source`,
+ * starting from index `start`.
+ *
+ * Some operations move the current index by a number of positions,
+ * after which `getIndex` returns the new index.
+ *
+ * @param {string} source
+ * @param {number} start
+ * @returns {ParseUtils}
+ */
+function parseUtils(source, start) {
+ var index = start;
+
+ function char(n) {
+ n = n || 0;
+ return source.charAt(index + n);
+ }
+
+ function skip(n) {
+ n = n || 1;
+ index += n;
+ }
+
+ function skipBlanks() {
+ var blanks = 0;
+ while (index < source.length) {
+ var c = char();
+ if (c !== ' ' && c !== '\n' && c !== '\t' && c !== '\r') {
+ return blanks;
+ }
+ blanks++;
+ skip();
+ }
+ return -1;
+ }
+ function substringFromIndex() {
+ return source.substring(index);
+ }
+ function substringStartsWith(text) {
+ return source.substring(index, index + text.length) === text;
+ }
+ function substringStartsWithCaseInsensitive(text) {
+ return source.substring(index, index + text.length).toUpperCase() === text.toUpperCase();
+ }
+
+ function getMatch(args) {
+ var expr = g.reg('^', args);
+ var match = expr.exec(substringFromIndex());
+ if (match) {
+ skip(match[0].length);
+ return match[0];
+ }
+ return null;
+ }
+ return {
+ char: char,
+ getIndex: function () {
+ return index;
+ },
+ getMatch: getMatch,
+ getSource: function () {
+ return source;
+ },
+ skip: skip,
+ skipBlanks: skipBlanks,
+ substringFromIndex: substringFromIndex,
+ substringStartsWith: substringStartsWith,
+ substringStartsWithCaseInsensitive: substringStartsWithCaseInsensitive,
+ };
+}
+
+/**
+ * @param {ParseUtils} p
+ * @param {DOMHandler} errorHandler
+ * @returns {string}
+ */
+function parseDoctypeInternalSubset(p, errorHandler) {
+ /**
+ * @param {ParseUtils} p
+ * @param {DOMHandler} errorHandler
+ * @returns {string}
+ */
+ function parsePI(p, errorHandler) {
+ var match = g.PI.exec(p.substringFromIndex());
+ if (!match) {
+ return errorHandler.fatalError('processing instruction is not well-formed at position ' + p.getIndex());
+ }
+ if (match[1].toLowerCase() === 'xml') {
+ return errorHandler.fatalError(
+ 'xml declaration is only allowed at the start of the document, but found at position ' + p.getIndex()
+ );
+ }
+ p.skip(match[0].length);
+ return match[0];
+ }
+ // Parse internal subset
+ var source = p.getSource();
+ if (p.char() === '[') {
+ p.skip(1);
+ var intSubsetStart = p.getIndex();
+ while (p.getIndex() < source.length) {
+ p.skipBlanks();
+ if (p.char() === ']') {
+ var internalSubset = source.substring(intSubsetStart, p.getIndex());
+ p.skip(1);
+ return internalSubset;
+ }
+ var current = null;
+ // Only in external subset
+ // if (char() === '<' && char(1) === '!' && char(2) === '[') {
+ // parseConditionalSections(p, errorHandler);
+ // } else
+ if (p.char() === '<' && p.char(1) === '!') {
+ switch (p.char(2)) {
+ case 'E': // ELEMENT | ENTITY
+ if (p.char(3) === 'L') {
+ current = p.getMatch(g.elementdecl);
+ } else if (p.char(3) === 'N') {
+ current = p.getMatch(g.EntityDecl);
+ }
+ break;
+ case 'A': // ATTRIBUTE
+ current = p.getMatch(g.AttlistDecl);
+ break;
+ case 'N': // NOTATION
+ current = p.getMatch(g.NotationDecl);
+ break;
+ case '-': // COMMENT
+ current = p.getMatch(g.Comment);
+ break;
+ }
+ } else if (p.char() === '<' && p.char(1) === '?') {
+ current = parsePI(p, errorHandler);
+ } else if (p.char() === '%') {
+ current = p.getMatch(g.PEReference);
+ } else {
+ return errorHandler.fatalError('Error detected in Markup declaration');
+ }
+ if (!current) {
+ return errorHandler.fatalError('Error in internal subset at position ' + p.getIndex());
+ }
+ }
+ return errorHandler.fatalError('doctype internal subset is not well-formed, missing ]');
+ }
+}
+
+/**
+ * Called when the parser encounters an element starting with '') {
+ return errorHandler.fatalError('doctype not terminated with > at position ' + p.getIndex());
+ }
+ p.skip(1);
+ domBuilder.startDTD(doctype.name, doctype.publicId, doctype.systemId, doctype.internalSubset);
+ domBuilder.endDTD();
+ return p.getIndex();
+ }
+ default:
+ return errorHandler.fatalError('Not well-formed XML starting with " 0) {
+ return errorHandler.fatalError(
+ 'processing instruction at position ' + start + ' is an xml declaration which is only at the start of the document'
+ );
+ }
+ if (!g.XMLDecl.test(source.substring(start))) {
+ return errorHandler.fatalError('xml declaration is not well-formed');
+ }
+ }
+ domBuilder.processingInstruction(match[1], match[2]);
+ return start + match[0].length;
+}
+
+function ElementAttributes() {
+ this.attributeNames = Object.create(null);
+}
+
+ElementAttributes.prototype = {
+ setTagName: function (tagName) {
+ if (!g.QName_exact.test(tagName)) {
+ throw new Error('invalid tagName:' + tagName);
+ }
+ this.tagName = tagName;
+ },
+ addValue: function (qName, value, offset) {
+ if (!g.QName_exact.test(qName)) {
+ throw new Error('invalid attribute:' + qName);
+ }
+ this.attributeNames[qName] = this.length;
+ this[this.length++] = { qName: qName, value: value, offset: offset };
+ },
+ length: 0,
+ getLocalName: function (i) {
+ return this[i].localName;
+ },
+ getLocator: function (i) {
+ return this[i].locator;
+ },
+ getQName: function (i) {
+ return this[i].qName;
+ },
+ getURI: function (i) {
+ return this[i].uri;
+ },
+ getValue: function (i) {
+ return this[i].value;
+ },
+ // ,getIndex:function(uri, localName)){
+ // if(localName){
+ //
+ // }else{
+ // var qName = uri
+ // }
+ // },
+ // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
+ // getType:function(uri,localName){}
+ // getType:function(i){},
+};
+
+exports.XMLReader = XMLReader;
+exports.parseUtils = parseUtils;
+exports.parseDoctypeCommentOrCData = parseDoctypeCommentOrCData;
+
+},{"./conventions":4,"./errors":8,"./grammar":9}],12:[function(require,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
+}
+
+// Support decoding URL-safe base64 strings, as Node.js does.
+// See: https://en.wikipedia.org/wiki/Base64#URL_applications
+revLookup['-'.charCodeAt(0)] = 62
+revLookup['_'.charCodeAt(0)] = 63
+
+function getLens (b64) {
+ var len = b64.length
+
+ if (len % 4 > 0) {
+ throw new Error('Invalid string. Length must be a multiple of 4')
+ }
+
+ // Trim off extra bytes after placeholder bytes are found
+ // See: https://github.com/beatgammit/base64-js/issues/42
+ var validLen = b64.indexOf('=')
+ if (validLen === -1) validLen = len
+
+ var placeHoldersLen = validLen === len
+ ? 0
+ : 4 - (validLen % 4)
+
+ return [validLen, placeHoldersLen]
+}
+
+// base64 is 4/3 + up to two characters of the original data
+function byteLength (b64) {
+ var lens = getLens(b64)
+ var validLen = lens[0]
+ var placeHoldersLen = lens[1]
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
+}
+
+function _byteLength (b64, validLen, placeHoldersLen) {
+ return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
+}
+
+function toByteArray (b64) {
+ var tmp
+ var lens = getLens(b64)
+ var validLen = lens[0]
+ var placeHoldersLen = lens[1]
+
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
+
+ var curByte = 0
+
+ // if there are placeholders, only get up to the last complete 4 chars
+ var len = placeHoldersLen > 0
+ ? validLen - 4
+ : validLen
+
+ var i
+ for (i = 0; i < len; i += 4) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 18) |
+ (revLookup[b64.charCodeAt(i + 1)] << 12) |
+ (revLookup[b64.charCodeAt(i + 2)] << 6) |
+ revLookup[b64.charCodeAt(i + 3)]
+ arr[curByte++] = (tmp >> 16) & 0xFF
+ arr[curByte++] = (tmp >> 8) & 0xFF
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ if (placeHoldersLen === 2) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 2) |
+ (revLookup[b64.charCodeAt(i + 1)] >> 4)
+ arr[curByte++] = tmp & 0xFF
+ }
+
+ if (placeHoldersLen === 1) {
+ tmp =
+ (revLookup[b64.charCodeAt(i)] << 10) |
+ (revLookup[b64.charCodeAt(i + 1)] << 4) |
+ (revLookup[b64.charCodeAt(i + 2)] >> 2)
+ arr[curByte++] = (tmp >> 8) & 0xFF
+ arr[curByte++] = 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) & 0xFF0000) +
+ ((uint8[i + 1] << 8) & 0xFF00) +
+ (uint8[i + 2] & 0xFF)
+ 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 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]
+ parts.push(
+ lookup[tmp >> 2] +
+ lookup[(tmp << 4) & 0x3F] +
+ '=='
+ )
+ } else if (extraBytes === 2) {
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1]
+ parts.push(
+ lookup[tmp >> 10] +
+ lookup[(tmp >> 4) & 0x3F] +
+ lookup[(tmp << 2) & 0x3F] +
+ '='
+ )
+ }
+
+ return parts.join('')
+}
+
+},{}],13:[function(require,module,exports){
+(function (Buffer){(function (){
+/*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */
+/* eslint-disable no-proto */
+
+'use strict'
+
+var base64 = require('base64-js')
+var ieee754 = require('ieee754')
+
+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
+ }
+}
+
+Object.defineProperty(Buffer.prototype, 'parent', {
+ enumerable: true,
+ get: function () {
+ if (!Buffer.isBuffer(this)) return undefined
+ return this.buffer
+ }
+})
+
+Object.defineProperty(Buffer.prototype, 'offset', {
+ enumerable: true,
+ get: function () {
+ if (!Buffer.isBuffer(this)) return undefined
+ return this.byteOffset
+ }
+})
+
+function createBuffer (length) {
+ if (length > K_MAX_LENGTH) {
+ throw new RangeError('The value "' + length + '" is invalid for option "size"')
+ }
+ // 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 TypeError(
+ 'The "string" argument must be of type string. Received type number'
+ )
+ }
+ 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 != null &&
+ 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 === 'string') {
+ return fromString(value, encodingOrOffset)
+ }
+
+ if (ArrayBuffer.isView(value)) {
+ return fromArrayLike(value)
+ }
+
+ if (value == null) {
+ throw TypeError(
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
+ 'or Array-like Object. Received type ' + (typeof value)
+ )
+ }
+
+ if (isInstance(value, ArrayBuffer) ||
+ (value && isInstance(value.buffer, ArrayBuffer))) {
+ return fromArrayBuffer(value, encodingOrOffset, length)
+ }
+
+ if (typeof value === 'number') {
+ throw new TypeError(
+ 'The "value" argument must not be of type number. Received type number'
+ )
+ }
+
+ var valueOf = value.valueOf && value.valueOf()
+ if (valueOf != null && valueOf !== value) {
+ return Buffer.from(valueOf, encodingOrOffset, length)
+ }
+
+ var b = fromObject(value)
+ if (b) return b
+
+ if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
+ typeof value[Symbol.toPrimitive] === 'function') {
+ return Buffer.from(
+ value[Symbol.toPrimitive]('string'), encodingOrOffset, length
+ )
+ }
+
+ throw new TypeError(
+ 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
+ 'or Array-like Object. Received type ' + (typeof 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 of type number')
+ } else if (size < 0) {
+ throw new RangeError('The value "' + size + '" is invalid for option "size"')
+ }
+}
+
+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('Unknown encoding: ' + 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 outside of buffer bounds')
+ }
+
+ if (array.byteLength < byteOffset + (length || 0)) {
+ throw new RangeError('"length" is outside of buffer 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.length !== undefined) {
+ 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)
+ }
+}
+
+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 &&
+ b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
+}
+
+Buffer.compare = function compare (a, b) {
+ if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
+ if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
+ throw new TypeError(
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
+ )
+ }
+
+ 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 (isInstance(buf, Uint8Array)) {
+ buf = Buffer.from(buf)
+ }
+ 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 (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
+ return string.byteLength
+ }
+ if (typeof string !== 'string') {
+ throw new TypeError(
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
+ 'Received type ' + typeof string
+ )
+ }
+
+ var len = string.length
+ var mustMatch = (arguments.length > 2 && arguments[2] === true)
+ if (!mustMatch && 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':
+ 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 mustMatch ? -1 : 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.toLocaleString = Buffer.prototype.toString
+
+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
+ str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
+ if (this.length > max) str += ' ... '
+ return ''
+}
+
+Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
+ if (isInstance(target, Uint8Array)) {
+ target = Buffer.from(target, target.offset, target.byteLength)
+ }
+ if (!Buffer.isBuffer(target)) {
+ throw new TypeError(
+ 'The "target" argument must be one of type Buffer or Uint8Array. ' +
+ 'Received type ' + (typeof target)
+ )
+ }
+
+ 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
+ }
+ }
+
+ var strLen = string.length
+
+ 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 (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
+ 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('Index out of range')
+ 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
+
+ if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
+ // Use built-in when available, missing from IE11
+ this.copyWithin(targetStart, start, end)
+ } else if (this === target && start < targetStart && targetStart < end) {
+ // descending copy from end
+ for (var i = len - 1; i >= 0; --i) {
+ target[i + targetStart] = this[i + start]
+ }
+ } else {
+ Uint8Array.prototype.set.call(
+ target,
+ this.subarray(start, end),
+ 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 (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)
+ }
+ if (val.length === 1) {
+ var code = val.charCodeAt(0)
+ if ((encoding === 'utf8' && code < 128) ||
+ encoding === 'latin1') {
+ // Fast path: If `val` fits into a single byte, use that numeric value.
+ val = code
+ }
+ }
+ } 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
+ : Buffer.from(val, encoding)
+ var len = bytes.length
+ if (len === 0) {
+ throw new TypeError('The value "' + val +
+ '" is invalid for argument "value"')
+ }
+ 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 takes equal signs as end of the Base64 encoding
+ str = str.split('=')[0]
+ // 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
+}
+
+// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
+// the `instanceof` check but they should be treated as of that type.
+// See: https://github.com/feross/buffer/issues/166
+function isInstance (obj, type) {
+ return obj instanceof type ||
+ (obj != null && obj.constructor != null && obj.constructor.name != null &&
+ obj.constructor.name === type.name)
+}
+function numberIsNaN (obj) {
+ // For IE11 support
+ return obj !== obj // eslint-disable-line no-self-compare
+}
+
+}).call(this)}).call(this,require("buffer").Buffer)
+},{"base64-js":12,"buffer":13,"ieee754":14}],14:[function(require,module,exports){
+/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */
+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
+}
+
+},{}],15:[function(require,module,exports){
+/*!
+ * Determine if an object is a Buffer
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */
+
+// The _isBuffer check is for Safari 5-7 support, because it's missing
+// Object.prototype.constructor. Remove this eventually
+module.exports = function (obj) {
+ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
+}
+
+function isBuffer (obj) {
+ return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
+}
+
+// For Node v0.10 support. Remove this eventually.
+function isSlowBuffer (obj) {
+ return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
+}
+
+},{}],16:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ module.exports = {
+ Disconnected: 1,
+ Preceding: 2,
+ Following: 4,
+ Contains: 8,
+ ContainedBy: 16,
+ ImplementationSpecific: 32
+ };
+
+}).call(this);
+
+},{}],17:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ module.exports = {
+ Element: 1,
+ Attribute: 2,
+ Text: 3,
+ CData: 4,
+ EntityReference: 5,
+ EntityDeclaration: 6,
+ ProcessingInstruction: 7,
+ Comment: 8,
+ Document: 9,
+ DocType: 10,
+ DocumentFragment: 11,
+ NotationDeclaration: 12,
+ // Numeric codes up to 200 are reserved to W3C for possible future use.
+ // Following are types internal to this library:
+ Declaration: 201,
+ Raw: 202,
+ AttributeDeclaration: 203,
+ ElementDeclaration: 204,
+ Dummy: 205
+ };
+
+}).call(this);
+
+},{}],18:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Copies all enumerable own properties from `sources` to `target`
+ var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject,
+ hasProp = {}.hasOwnProperty;
+
+ assign = function(target, ...sources) {
+ var i, key, len, source;
+ if (isFunction(Object.assign)) {
+ Object.assign.apply(null, arguments);
+ } else {
+ for (i = 0, len = sources.length; i < len; i++) {
+ source = sources[i];
+ if (source != null) {
+ for (key in source) {
+ if (!hasProp.call(source, key)) continue;
+ target[key] = source[key];
+ }
+ }
+ }
+ }
+ return target;
+ };
+
+ // Determines if `val` is a Function object
+ isFunction = function(val) {
+ return !!val && Object.prototype.toString.call(val) === '[object Function]';
+ };
+
+ // Determines if `val` is an Object
+ isObject = function(val) {
+ var ref;
+ return !!val && ((ref = typeof val) === 'function' || ref === 'object');
+ };
+
+ // Determines if `val` is an Array
+ isArray = function(val) {
+ if (isFunction(Array.isArray)) {
+ return Array.isArray(val);
+ } else {
+ return Object.prototype.toString.call(val) === '[object Array]';
+ }
+ };
+
+ // Determines if `val` is an empty Array or an Object with no own properties
+ isEmpty = function(val) {
+ var key;
+ if (isArray(val)) {
+ return !val.length;
+ } else {
+ for (key in val) {
+ if (!hasProp.call(val, key)) continue;
+ return false;
+ }
+ return true;
+ }
+ };
+
+ // Determines if `val` is a plain Object
+ isPlainObject = function(val) {
+ var ctor, proto;
+ return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
+ };
+
+ // Gets the primitive value of an object
+ getValue = function(obj) {
+ if (isFunction(obj.valueOf)) {
+ return obj.valueOf();
+ } else {
+ return obj;
+ }
+ };
+
+ module.exports.assign = assign;
+
+ module.exports.isFunction = isFunction;
+
+ module.exports.isObject = isObject;
+
+ module.exports.isArray = isArray;
+
+ module.exports.isEmpty = isEmpty;
+
+ module.exports.isPlainObject = isPlainObject;
+
+ module.exports.getValue = getValue;
+
+}).call(this);
+
+},{}],19:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ module.exports = {
+ None: 0,
+ OpenTag: 1,
+ InsideTag: 2,
+ CloseTag: 3
+ };
+
+}).call(this);
+
+},{}],20:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLAttribute, XMLNode;
+
+ NodeType = require('./NodeType');
+
+ XMLNode = require('./XMLNode');
+
+ // Represents an attribute
+ module.exports = XMLAttribute = (function() {
+ class XMLAttribute {
+ // Initializes a new instance of `XMLAttribute`
+
+ // `parent` the parent node
+ // `name` attribute target
+ // `value` attribute value
+ constructor(parent, name, value) {
+ this.parent = parent;
+ if (this.parent) {
+ this.options = this.parent.options;
+ this.stringify = this.parent.stringify;
+ }
+ if (name == null) {
+ throw new Error("Missing attribute name. " + this.debugInfo(name));
+ }
+ this.name = this.stringify.name(name);
+ this.value = this.stringify.attValue(value);
+ this.type = NodeType.Attribute;
+ // DOM level 3
+ this.isId = false;
+ this.schemaTypeInfo = null;
+ }
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
+ }
+
+
+ // Returns debug string for this node
+ debugInfo(name) {
+ name = name || this.name;
+ if (name == null) {
+ return "parent: <" + this.parent.name + ">";
+ } else {
+ return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
+ }
+ }
+
+ isEqualNode(node) {
+ if (node.namespaceURI !== this.namespaceURI) {
+ return false;
+ }
+ if (node.prefix !== this.prefix) {
+ return false;
+ }
+ if (node.localName !== this.localName) {
+ return false;
+ }
+ if (node.value !== this.value) {
+ return false;
+ }
+ return true;
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
+ get: function() {
+ return this.type;
+ }
+ });
+
+ Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
+ get: function() {
+ return this.parent;
+ }
+ });
+
+ // DOM level 3
+ Object.defineProperty(XMLAttribute.prototype, 'textContent', {
+ get: function() {
+ return this.value;
+ },
+ set: function(value) {
+ return this.value = value || '';
+ }
+ });
+
+ // DOM level 4
+ Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
+ get: function() {
+ return '';
+ }
+ });
+
+ Object.defineProperty(XMLAttribute.prototype, 'prefix', {
+ get: function() {
+ return '';
+ }
+ });
+
+ Object.defineProperty(XMLAttribute.prototype, 'localName', {
+ get: function() {
+ return this.name;
+ }
+ });
+
+ Object.defineProperty(XMLAttribute.prototype, 'specified', {
+ get: function() {
+ return true;
+ }
+ });
+
+ return XMLAttribute;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./NodeType":17,"./XMLNode":39}],21:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLCData, XMLCharacterData;
+
+ NodeType = require('./NodeType');
+
+ XMLCharacterData = require('./XMLCharacterData');
+
+ // Represents a CDATA node
+ module.exports = XMLCData = class XMLCData extends XMLCharacterData {
+ // Initializes a new instance of `XMLCData`
+
+ // `text` CDATA text
+ constructor(parent, text) {
+ super(parent);
+ if (text == null) {
+ throw new Error("Missing CDATA text. " + this.debugInfo());
+ }
+ this.name = "#cdata-section";
+ this.type = NodeType.CData;
+ this.value = this.stringify.cdata(text);
+ }
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":17,"./XMLCharacterData":22}],22:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var XMLCharacterData, XMLNode;
+
+ XMLNode = require('./XMLNode');
+
+ // Represents a character data node
+ module.exports = XMLCharacterData = (function() {
+ class XMLCharacterData extends XMLNode {
+ // Initializes a new instance of `XMLCharacterData`
+
+ constructor(parent) {
+ super(parent);
+ this.value = '';
+ }
+
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // DOM level 1 functions to be implemented later
+ substringData(offset, count) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ appendData(arg) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ insertData(offset, arg) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ deleteData(offset, count) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ replaceData(offset, count, arg) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ isEqualNode(node) {
+ if (!super.isEqualNode(node)) {
+ return false;
+ }
+ if (node.data !== this.data) {
+ return false;
+ }
+ return true;
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLCharacterData.prototype, 'data', {
+ get: function() {
+ return this.value;
+ },
+ set: function(value) {
+ return this.value = value || '';
+ }
+ });
+
+ Object.defineProperty(XMLCharacterData.prototype, 'length', {
+ get: function() {
+ return this.value.length;
+ }
+ });
+
+ // DOM level 3
+ Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
+ get: function() {
+ return this.value;
+ },
+ set: function(value) {
+ return this.value = value || '';
+ }
+ });
+
+ return XMLCharacterData;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./XMLNode":39}],23:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLCharacterData, XMLComment;
+
+ NodeType = require('./NodeType');
+
+ XMLCharacterData = require('./XMLCharacterData');
+
+ // Represents a comment node
+ module.exports = XMLComment = class XMLComment extends XMLCharacterData {
+ // Initializes a new instance of `XMLComment`
+
+ // `text` comment text
+ constructor(parent, text) {
+ super(parent);
+ if (text == null) {
+ throw new Error("Missing comment text. " + this.debugInfo());
+ }
+ this.name = "#comment";
+ this.type = NodeType.Comment;
+ this.value = this.stringify.comment(text);
+ }
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.comment(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":17,"./XMLCharacterData":22}],24:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
+
+ XMLDOMErrorHandler = require('./XMLDOMErrorHandler');
+
+ XMLDOMStringList = require('./XMLDOMStringList');
+
+ // Implements the DOMConfiguration interface
+ module.exports = XMLDOMConfiguration = (function() {
+ class XMLDOMConfiguration {
+ constructor() {
+ var clonedSelf;
+ this.defaultParams = {
+ "canonical-form": false,
+ "cdata-sections": false,
+ "comments": false,
+ "datatype-normalization": false,
+ "element-content-whitespace": true,
+ "entities": true,
+ "error-handler": new XMLDOMErrorHandler(),
+ "infoset": true,
+ "validate-if-schema": false,
+ "namespaces": true,
+ "namespace-declarations": true,
+ "normalize-characters": false,
+ "schema-location": '',
+ "schema-type": '',
+ "split-cdata-sections": true,
+ "validate": false,
+ "well-formed": true
+ };
+ this.params = clonedSelf = Object.create(this.defaultParams);
+ }
+
+ // Gets the value of a parameter.
+
+ // `name` name of the parameter
+ getParameter(name) {
+ if (this.params.hasOwnProperty(name)) {
+ return this.params[name];
+ } else {
+ return null;
+ }
+ }
+
+ // Checks if setting a parameter to a specific value is supported.
+
+ // `name` name of the parameter
+ // `value` parameter value
+ canSetParameter(name, value) {
+ return true;
+ }
+
+ // Sets the value of a parameter.
+
+ // `name` name of the parameter
+ // `value` new value or null if the user wishes to unset the parameter
+ setParameter(name, value) {
+ if (value != null) {
+ return this.params[name] = value;
+ } else {
+ return delete this.params[name];
+ }
+ }
+
+ };
+
+ // Returns the list of parameter names
+ Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', {
+ get: function() {
+ return new XMLDOMStringList(Object.keys(this.defaultParams));
+ }
+ });
+
+ return XMLDOMConfiguration;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./XMLDOMErrorHandler":25,"./XMLDOMStringList":27}],25:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Represents the error handler for DOM operations
+ var XMLDOMErrorHandler;
+
+ module.exports = XMLDOMErrorHandler = class XMLDOMErrorHandler {
+ // Initializes a new instance of `XMLDOMErrorHandler`
+
+ constructor() {}
+
+ // Called on the error handler when an error occurs.
+
+ // `error` the error message as a string
+ handleError(error) {
+ throw new Error(error);
+ }
+
+ };
+
+}).call(this);
+
+},{}],26:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Implements the DOMImplementation interface
+ var XMLDOMImplementation;
+
+ module.exports = XMLDOMImplementation = class XMLDOMImplementation {
+ // Tests if the DOM implementation implements a specific feature.
+
+ // `feature` package name of the feature to test. In Level 1, the
+ // legal values are "HTML" and "XML" (case-insensitive).
+ // `version` version number of the package name to test.
+ // In Level 1, this is the string "1.0". If the version is
+ // not specified, supporting any version of the feature will
+ // cause the method to return true.
+ hasFeature(feature, version) {
+ return true;
+ }
+
+ // Creates a new document type declaration.
+
+ // `qualifiedName` qualified name of the document type to be created
+ // `publicId` public identifier of the external subset
+ // `systemId` system identifier of the external subset
+ createDocumentType(qualifiedName, publicId, systemId) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ // Creates a new document.
+
+ // `namespaceURI` namespace URI of the document element to create
+ // `qualifiedName` the qualified name of the document to be created
+ // `doctype` the type of document to be created or null
+ createDocument(namespaceURI, qualifiedName, doctype) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ // Creates a new HTML document.
+
+ // `title` document title
+ createHTMLDocument(title) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ // Returns a specialized object which implements the specialized APIs
+ // of the specified feature and version.
+
+ // `feature` name of the feature requested.
+ // `version` version number of the feature to test
+ getFeature(feature, version) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ };
+
+}).call(this);
+
+},{}],27:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Represents a list of string entries
+ var XMLDOMStringList;
+
+ module.exports = XMLDOMStringList = (function() {
+ class XMLDOMStringList {
+ // Initializes a new instance of `XMLDOMStringList`
+ // This is just a wrapper around an ordinary
+ // JS array.
+
+ // `arr` the array of string values
+ constructor(arr) {
+ this.arr = arr || [];
+ }
+
+ // Returns the indexth item in the collection.
+
+ // `index` index into the collection
+ item(index) {
+ return this.arr[index] || null;
+ }
+
+ // Test if a string is part of this DOMStringList.
+
+ // `str` the string to look for
+ contains(str) {
+ return this.arr.indexOf(str) !== -1;
+ }
+
+ };
+
+ // Returns the number of strings in the list.
+ Object.defineProperty(XMLDOMStringList.prototype, 'length', {
+ get: function() {
+ return this.arr.length;
+ }
+ });
+
+ return XMLDOMStringList;
+
+ }).call(this);
+
+}).call(this);
+
+},{}],28:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDTDAttList, XMLNode;
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ // Represents an attribute list
+ module.exports = XMLDTDAttList = class XMLDTDAttList extends XMLNode {
+ // Initializes a new instance of `XMLDTDAttList`
+
+ // `parent` the parent `XMLDocType` element
+ // `elementName` the name of the element containing this attribute
+ // `attributeName` attribute name
+ // `attributeType` type of the attribute
+ // `defaultValueType` default value type (either #REQUIRED, #IMPLIED,
+ // #FIXED or #DEFAULT)
+ // `defaultValue` default value of the attribute
+ // (only used for #FIXED or #DEFAULT)
+ constructor(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ super(parent);
+ if (elementName == null) {
+ throw new Error("Missing DTD element name. " + this.debugInfo());
+ }
+ if (attributeName == null) {
+ throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
+ }
+ if (!attributeType) {
+ throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
+ }
+ if (!defaultValueType) {
+ throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
+ }
+ if (defaultValueType.indexOf('#') !== 0) {
+ defaultValueType = '#' + defaultValueType;
+ }
+ if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
+ throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
+ }
+ if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
+ throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
+ }
+ this.elementName = this.stringify.name(elementName);
+ this.type = NodeType.AttributeDeclaration;
+ this.attributeName = this.stringify.name(attributeName);
+ this.attributeType = this.stringify.dtdAttType(attributeType);
+ if (defaultValue) {
+ this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
+ }
+ this.defaultValueType = defaultValueType;
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":17,"./XMLNode":39}],29:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDTDElement, XMLNode;
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ // Represents an attribute
+ module.exports = XMLDTDElement = class XMLDTDElement extends XMLNode {
+ // Initializes a new instance of `XMLDTDElement`
+
+ // `parent` the parent `XMLDocType` element
+ // `name` element name
+ // `value` element content (defaults to #PCDATA)
+ constructor(parent, name, value) {
+ super(parent);
+ if (name == null) {
+ throw new Error("Missing DTD element name. " + this.debugInfo());
+ }
+ if (!value) {
+ value = '(#PCDATA)';
+ }
+ if (Array.isArray(value)) {
+ value = '(' + value.join(',') + ')';
+ }
+ this.name = this.stringify.name(name);
+ this.type = NodeType.ElementDeclaration;
+ this.value = this.stringify.dtdElementValue(value);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":17,"./XMLNode":39}],30:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDTDEntity, XMLNode, isObject;
+
+ ({isObject} = require('./Utility'));
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ // Represents an entity declaration in the DTD
+ module.exports = XMLDTDEntity = (function() {
+ class XMLDTDEntity extends XMLNode {
+ // Initializes a new instance of `XMLDTDEntity`
+
+ // `parent` the parent `XMLDocType` element
+ // `pe` whether this is a parameter entity or a general entity
+ // defaults to `false` (general entity)
+ // `name` the name of the entity
+ // `value` internal entity value or an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ // `value.nData` notation declaration
+ constructor(parent, pe, name, value) {
+ super(parent);
+ if (name == null) {
+ throw new Error("Missing DTD entity name. " + this.debugInfo(name));
+ }
+ if (value == null) {
+ throw new Error("Missing DTD entity value. " + this.debugInfo(name));
+ }
+ this.pe = !!pe;
+ this.name = this.stringify.name(name);
+ this.type = NodeType.EntityDeclaration;
+ if (!isObject(value)) {
+ this.value = this.stringify.dtdEntityValue(value);
+ this.internal = true;
+ } else {
+ if (!value.pubID && !value.sysID) {
+ throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
+ }
+ if (value.pubID && !value.sysID) {
+ throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
+ }
+ this.internal = false;
+ if (value.pubID != null) {
+ this.pubID = this.stringify.dtdPubID(value.pubID);
+ }
+ if (value.sysID != null) {
+ this.sysID = this.stringify.dtdSysID(value.sysID);
+ }
+ if (value.nData != null) {
+ this.nData = this.stringify.dtdNData(value.nData);
+ }
+ if (this.pe && this.nData) {
+ throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
+ }
+ }
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
+ get: function() {
+ return this.pubID;
+ }
+ });
+
+ Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
+ get: function() {
+ return this.sysID;
+ }
+ });
+
+ Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
+ get: function() {
+ return this.nData || null;
+ }
+ });
+
+ // DOM level 3
+ Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
+ get: function() {
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
+ get: function() {
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
+ get: function() {
+ return null;
+ }
+ });
+
+ return XMLDTDEntity;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./NodeType":17,"./Utility":18,"./XMLNode":39}],31:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDTDNotation, XMLNode;
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ // Represents a NOTATION entry in the DTD
+ module.exports = XMLDTDNotation = (function() {
+ class XMLDTDNotation extends XMLNode {
+ // Initializes a new instance of `XMLDTDNotation`
+
+ // `parent` the parent `XMLDocType` element
+ // `name` the name of the notation
+ // `value` an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ constructor(parent, name, value) {
+ super(parent);
+ if (name == null) {
+ throw new Error("Missing DTD notation name. " + this.debugInfo(name));
+ }
+ if (!value.pubID && !value.sysID) {
+ throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
+ }
+ this.name = this.stringify.name(name);
+ this.type = NodeType.NotationDeclaration;
+ if (value.pubID != null) {
+ this.pubID = this.stringify.dtdPubID(value.pubID);
+ }
+ if (value.sysID != null) {
+ this.sysID = this.stringify.dtdSysID(value.sysID);
+ }
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLDTDNotation.prototype, 'publicId', {
+ get: function() {
+ return this.pubID;
+ }
+ });
+
+ Object.defineProperty(XMLDTDNotation.prototype, 'systemId', {
+ get: function() {
+ return this.sysID;
+ }
+ });
+
+ return XMLDTDNotation;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./NodeType":17,"./XMLNode":39}],32:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDeclaration, XMLNode, isObject;
+
+ ({isObject} = require('./Utility'));
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ // Represents the XML declaration
+ module.exports = XMLDeclaration = class XMLDeclaration extends XMLNode {
+ // Initializes a new instance of `XMLDeclaration`
+
+ // `parent` the document object
+
+ // `version` A version number string, e.g. 1.0
+ // `encoding` Encoding declaration, e.g. UTF-8
+ // `standalone` standalone document declaration: true or false
+ constructor(parent, version, encoding, standalone) {
+ super(parent);
+ // arguments may also be passed as an object
+ if (isObject(version)) {
+ ({version, encoding, standalone} = version);
+ }
+ if (!version) {
+ version = '1.0';
+ }
+ this.type = NodeType.Declaration;
+ this.version = this.stringify.xmlVersion(version);
+ if (encoding != null) {
+ this.encoding = this.stringify.xmlEncoding(encoding);
+ }
+ if (standalone != null) {
+ this.standalone = this.stringify.xmlStandalone(standalone);
+ }
+ }
+
+ // Converts to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":17,"./Utility":18,"./XMLNode":39}],33:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject;
+
+ ({isObject} = require('./Utility'));
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLNamedNodeMap = require('./XMLNamedNodeMap');
+
+ // Represents doctype declaration
+ module.exports = XMLDocType = (function() {
+ class XMLDocType extends XMLNode {
+ // Initializes a new instance of `XMLDocType`
+
+ // `parent` the document object
+
+ // `pubID` public identifier of the external subset
+ // `sysID` system identifier of the external subset
+ constructor(parent, pubID, sysID) {
+ var child, i, len, ref;
+ super(parent);
+ this.type = NodeType.DocType;
+ // set DTD name to the name of the root node
+ if (parent.children) {
+ ref = parent.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ if (child.type === NodeType.Element) {
+ this.name = child.name;
+ break;
+ }
+ }
+ }
+ this.documentObject = parent;
+ // arguments may also be passed as an object
+ if (isObject(pubID)) {
+ ({pubID, sysID} = pubID);
+ }
+ if (sysID == null) {
+ [sysID, pubID] = [pubID, sysID];
+ }
+ if (pubID != null) {
+ this.pubID = this.stringify.dtdPubID(pubID);
+ }
+ if (sysID != null) {
+ this.sysID = this.stringify.dtdSysID(sysID);
+ }
+ }
+
+ // Creates an element type declaration
+
+ // `name` element name
+ // `value` element content (defaults to #PCDATA)
+ element(name, value) {
+ var child;
+ child = new XMLDTDElement(this, name, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates an attribute declaration
+
+ // `elementName` the name of the element containing this attribute
+ // `attributeName` attribute name
+ // `attributeType` type of the attribute (defaults to CDATA)
+ // `defaultValueType` default value type (either #REQUIRED, #IMPLIED, #FIXED or
+ // #DEFAULT) (defaults to #IMPLIED)
+ // `defaultValue` default value of the attribute
+ // (only used for #FIXED or #DEFAULT)
+ attList(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ var child;
+ child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates a general entity declaration
+
+ // `name` the name of the entity
+ // `value` internal entity value or an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ // `value.nData` notation declaration
+ entity(name, value) {
+ var child;
+ child = new XMLDTDEntity(this, false, name, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates a parameter entity declaration
+
+ // `name` the name of the entity
+ // `value` internal entity value or an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ pEntity(name, value) {
+ var child;
+ child = new XMLDTDEntity(this, true, name, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates a NOTATION declaration
+
+ // `name` the name of the notation
+ // `value` an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ notation(name, value) {
+ var child;
+ child = new XMLDTDNotation(this, name, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Converts to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.docType(this, this.options.writer.filterOptions(options));
+ }
+
+ // Aliases
+ ele(name, value) {
+ return this.element(name, value);
+ }
+
+ att(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
+ }
+
+ ent(name, value) {
+ return this.entity(name, value);
+ }
+
+ pent(name, value) {
+ return this.pEntity(name, value);
+ }
+
+ not(name, value) {
+ return this.notation(name, value);
+ }
+
+ up() {
+ return this.root() || this.documentObject;
+ }
+
+ isEqualNode(node) {
+ if (!super.isEqualNode(node)) {
+ return false;
+ }
+ if (node.name !== this.name) {
+ return false;
+ }
+ if (node.publicId !== this.publicId) {
+ return false;
+ }
+ if (node.systemId !== this.systemId) {
+ return false;
+ }
+ return true;
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLDocType.prototype, 'entities', {
+ get: function() {
+ var child, i, len, nodes, ref;
+ nodes = {};
+ ref = this.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ if ((child.type === NodeType.EntityDeclaration) && !child.pe) {
+ nodes[child.name] = child;
+ }
+ }
+ return new XMLNamedNodeMap(nodes);
+ }
+ });
+
+ Object.defineProperty(XMLDocType.prototype, 'notations', {
+ get: function() {
+ var child, i, len, nodes, ref;
+ nodes = {};
+ ref = this.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ if (child.type === NodeType.NotationDeclaration) {
+ nodes[child.name] = child;
+ }
+ }
+ return new XMLNamedNodeMap(nodes);
+ }
+ });
+
+ // DOM level 2
+ Object.defineProperty(XMLDocType.prototype, 'publicId', {
+ get: function() {
+ return this.pubID;
+ }
+ });
+
+ Object.defineProperty(XMLDocType.prototype, 'systemId', {
+ get: function() {
+ return this.sysID;
+ }
+ });
+
+ Object.defineProperty(XMLDocType.prototype, 'internalSubset', {
+ get: function() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+ });
+
+ return XMLDocType;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./NodeType":17,"./Utility":18,"./XMLDTDAttList":28,"./XMLDTDElement":29,"./XMLDTDEntity":30,"./XMLDTDNotation":31,"./XMLNamedNodeMap":38,"./XMLNode":39}],34:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject;
+
+ ({isPlainObject} = require('./Utility'));
+
+ XMLDOMImplementation = require('./XMLDOMImplementation');
+
+ XMLDOMConfiguration = require('./XMLDOMConfiguration');
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ XMLStringifier = require('./XMLStringifier');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ // Represents an XML builder
+ module.exports = XMLDocument = (function() {
+ class XMLDocument extends XMLNode {
+ // Initializes a new instance of `XMLDocument`
+
+ // `options.keepNullNodes` whether nodes with null values will be kept
+ // or ignored: true or false
+ // `options.keepNullAttributes` whether attributes with null values will be
+ // kept or ignored: true or false
+ // `options.ignoreDecorators` whether decorator strings will be ignored when
+ // converting JS objects: true or false
+ // `options.separateArrayItems` whether array items are created as separate
+ // nodes when passed as an object value: true or false
+ // `options.noDoubleEncoding` whether existing html entities are encoded:
+ // true or false
+ // `options.stringify` a set of functions to use for converting values to
+ // strings
+ // `options.writer` the default XML writer to use for converting nodes to
+ // string. If the default writer is not set, the built-in XMLStringWriter
+ // will be used instead.
+ constructor(options) {
+ super(null);
+ this.name = "#document";
+ this.type = NodeType.Document;
+ this.documentURI = null;
+ this.domConfig = new XMLDOMConfiguration();
+ options || (options = {});
+ if (!options.writer) {
+ options.writer = new XMLStringWriter();
+ }
+ this.options = options;
+ this.stringify = new XMLStringifier(options);
+ }
+
+ // Ends the document and passes it to the given XML writer
+
+ // `writer` is either an XML writer or a plain object to pass to the
+ // constructor of the default XML writer. The default writer is assigned when
+ // creating the XML document. Following flags are recognized by the
+ // built-in XMLStringWriter:
+ // `writer.pretty` pretty prints the result
+ // `writer.indent` indentation for pretty print
+ // `writer.offset` how many indentations to add to every line for pretty print
+ // `writer.newline` newline sequence for pretty print
+ end(writer) {
+ var writerOptions;
+ writerOptions = {};
+ if (!writer) {
+ writer = this.options.writer;
+ } else if (isPlainObject(writer)) {
+ writerOptions = writer;
+ writer = this.options.writer;
+ }
+ return writer.document(this, writer.filterOptions(writerOptions));
+ }
+
+ // Converts the XML document to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.document(this, this.options.writer.filterOptions(options));
+ }
+
+ // DOM level 1 functions to be implemented later
+ createElement(tagName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createDocumentFragment() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createTextNode(data) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createComment(data) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createCDATASection(data) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createProcessingInstruction(target, data) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createAttribute(name) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createEntityReference(name) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementsByTagName(tagname) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM level 2 functions to be implemented later
+ importNode(importedNode, deep) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createElementNS(namespaceURI, qualifiedName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createAttributeNS(namespaceURI, qualifiedName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementsByTagNameNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementById(elementId) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM level 3 functions to be implemented later
+ adoptNode(source) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ normalizeDocument() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ renameNode(node, namespaceURI, qualifiedName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM level 4 functions to be implemented later
+ getElementsByClassName(classNames) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createEvent(eventInterface) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createRange() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createNodeIterator(root, whatToShow, filter) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ createTreeWalker(root, whatToShow, filter) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLDocument.prototype, 'implementation', {
+ value: new XMLDOMImplementation()
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'doctype', {
+ get: function() {
+ var child, i, len, ref;
+ ref = this.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ if (child.type === NodeType.DocType) {
+ return child;
+ }
+ }
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'documentElement', {
+ get: function() {
+ return this.rootObject || null;
+ }
+ });
+
+ // DOM level 3
+ Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
+ get: function() {
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
+ get: function() {
+ return false;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
+ get: function() {
+ if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
+ return this.children[0].encoding;
+ } else {
+ return null;
+ }
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
+ get: function() {
+ if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
+ return this.children[0].standalone === 'yes';
+ } else {
+ return false;
+ }
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
+ get: function() {
+ if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
+ return this.children[0].version;
+ } else {
+ return "1.0";
+ }
+ }
+ });
+
+ // DOM level 4
+ Object.defineProperty(XMLDocument.prototype, 'URL', {
+ get: function() {
+ return this.documentURI;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'origin', {
+ get: function() {
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'compatMode', {
+ get: function() {
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'characterSet', {
+ get: function() {
+ return null;
+ }
+ });
+
+ Object.defineProperty(XMLDocument.prototype, 'contentType', {
+ get: function() {
+ return null;
+ }
+ });
+
+ return XMLDocument;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./NodeType":17,"./Utility":18,"./XMLDOMConfiguration":24,"./XMLDOMImplementation":26,"./XMLNode":39,"./XMLStringWriter":44,"./XMLStringifier":45}],35:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, WriterState, XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocument, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction, isObject, isPlainObject,
+ hasProp = {}.hasOwnProperty;
+
+ ({isObject, isFunction, isPlainObject, getValue} = require('./Utility'));
+
+ NodeType = require('./NodeType');
+
+ XMLDocument = require('./XMLDocument');
+
+ XMLElement = require('./XMLElement');
+
+ XMLCData = require('./XMLCData');
+
+ XMLComment = require('./XMLComment');
+
+ XMLRaw = require('./XMLRaw');
+
+ XMLText = require('./XMLText');
+
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+
+ XMLDeclaration = require('./XMLDeclaration');
+
+ XMLDocType = require('./XMLDocType');
+
+ XMLDTDAttList = require('./XMLDTDAttList');
+
+ XMLDTDEntity = require('./XMLDTDEntity');
+
+ XMLDTDElement = require('./XMLDTDElement');
+
+ XMLDTDNotation = require('./XMLDTDNotation');
+
+ XMLAttribute = require('./XMLAttribute');
+
+ XMLStringifier = require('./XMLStringifier');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ WriterState = require('./WriterState');
+
+ // Represents an XML builder
+ module.exports = XMLDocumentCB = class XMLDocumentCB {
+ // Initializes a new instance of `XMLDocumentCB`
+
+ // `options.keepNullNodes` whether nodes with null values will be kept
+ // or ignored: true or false
+ // `options.keepNullAttributes` whether attributes with null values will be
+ // kept or ignored: true or false
+ // `options.ignoreDecorators` whether decorator strings will be ignored when
+ // converting JS objects: true or false
+ // `options.separateArrayItems` whether array items are created as separate
+ // nodes when passed as an object value: true or false
+ // `options.noDoubleEncoding` whether existing html entities are encoded:
+ // true or false
+ // `options.stringify` a set of functions to use for converting values to
+ // strings
+ // `options.writer` the default XML writer to use for converting nodes to
+ // string. If the default writer is not set, the built-in XMLStringWriter
+ // will be used instead.
+
+ // `onData` the function to be called when a new chunk of XML is output. The
+ // string containing the XML chunk is passed to `onData` as its first
+ // argument, and the current indentation level as its second argument.
+ // `onEnd` the function to be called when the XML document is completed with
+ // `end`. `onEnd` does not receive any arguments.
+ constructor(options, onData, onEnd) {
+ var writerOptions;
+ this.name = "?xml";
+ this.type = NodeType.Document;
+ options || (options = {});
+ writerOptions = {};
+ if (!options.writer) {
+ options.writer = new XMLStringWriter();
+ } else if (isPlainObject(options.writer)) {
+ writerOptions = options.writer;
+ options.writer = new XMLStringWriter();
+ }
+ this.options = options;
+ this.writer = options.writer;
+ this.writerOptions = this.writer.filterOptions(writerOptions);
+ this.stringify = new XMLStringifier(options);
+ this.onDataCallback = onData || function() {};
+ this.onEndCallback = onEnd || function() {};
+ this.currentNode = null;
+ this.currentLevel = -1;
+ this.openTags = {};
+ this.documentStarted = false;
+ this.documentCompleted = false;
+ this.root = null;
+ }
+
+ // Creates a child element node from the given XMLNode
+
+ // `node` the child node
+ createChildNode(node) {
+ var att, attName, attributes, child, i, len, ref, ref1;
+ switch (node.type) {
+ case NodeType.CData:
+ this.cdata(node.value);
+ break;
+ case NodeType.Comment:
+ this.comment(node.value);
+ break;
+ case NodeType.Element:
+ attributes = {};
+ ref = node.attribs;
+ for (attName in ref) {
+ if (!hasProp.call(ref, attName)) continue;
+ att = ref[attName];
+ attributes[attName] = att.value;
+ }
+ this.node(node.name, attributes);
+ break;
+ case NodeType.Dummy:
+ this.dummy();
+ break;
+ case NodeType.Raw:
+ this.raw(node.value);
+ break;
+ case NodeType.Text:
+ this.text(node.value);
+ break;
+ case NodeType.ProcessingInstruction:
+ this.instruction(node.target, node.value);
+ break;
+ default:
+ throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name);
+ }
+ ref1 = node.children;
+ // write child nodes recursively
+ for (i = 0, len = ref1.length; i < len; i++) {
+ child = ref1[i];
+ this.createChildNode(child);
+ if (child.type === NodeType.Element) {
+ this.up();
+ }
+ }
+ return this;
+ }
+
+ // Creates a dummy node
+
+ dummy() {
+ // no-op, just return this
+ return this;
+ }
+
+ // Creates a node
+
+ // `name` name of the node
+ // `attributes` an object containing name/value pairs of attributes
+ // `text` element text
+ node(name, attributes, text) {
+ if (name == null) {
+ throw new Error("Missing node name.");
+ }
+ if (this.root && this.currentLevel === -1) {
+ throw new Error("Document can only have one root node. " + this.debugInfo(name));
+ }
+ this.openCurrent();
+ name = getValue(name);
+ if (attributes == null) {
+ attributes = {};
+ }
+ attributes = getValue(attributes);
+ // swap argument order: text <-> attributes
+ if (!isObject(attributes)) {
+ [text, attributes] = [attributes, text];
+ }
+ this.currentNode = new XMLElement(this, name, attributes);
+ this.currentNode.children = false;
+ this.currentLevel++;
+ this.openTags[this.currentLevel] = this.currentNode;
+ if (text != null) {
+ this.text(text);
+ }
+ return this;
+ }
+
+ // Creates a child element node or an element type declaration when called
+ // inside the DTD
+
+ // `name` name of the node
+ // `attributes` an object containing name/value pairs of attributes
+ // `text` element text
+ element(name, attributes, text) {
+ var child, i, len, oldValidationFlag, ref, root;
+ if (this.currentNode && this.currentNode.type === NodeType.DocType) {
+ this.dtdElement(...arguments);
+ } else {
+ if (Array.isArray(name) || isObject(name) || isFunction(name)) {
+ oldValidationFlag = this.options.noValidation;
+ this.options.noValidation = true;
+ root = new XMLDocument(this.options).element('TEMP_ROOT');
+ root.element(name);
+ this.options.noValidation = oldValidationFlag;
+ ref = root.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ this.createChildNode(child);
+ if (child.type === NodeType.Element) {
+ this.up();
+ }
+ }
+ } else {
+ this.node(name, attributes, text);
+ }
+ }
+ return this;
+ }
+
+ // Adds or modifies an attribute
+
+ // `name` attribute name
+ // `value` attribute value
+ attribute(name, value) {
+ var attName, attValue;
+ if (!this.currentNode || this.currentNode.children) {
+ throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
+ }
+ if (name != null) {
+ name = getValue(name);
+ }
+ if (isObject(name)) { // expand if object
+ for (attName in name) {
+ if (!hasProp.call(name, attName)) continue;
+ attValue = name[attName];
+ this.attribute(attName, attValue);
+ }
+ } else {
+ if (isFunction(value)) {
+ value = value.apply();
+ }
+ if (this.options.keepNullAttributes && (value == null)) {
+ this.currentNode.attribs[name] = new XMLAttribute(this, name, "");
+ } else if (value != null) {
+ this.currentNode.attribs[name] = new XMLAttribute(this, name, value);
+ }
+ }
+ return this;
+ }
+
+ // Creates a text node
+
+ // `value` element text
+ text(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLText(this, value);
+ this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates a CDATA node
+
+ // `value` element text without CDATA delimiters
+ cdata(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLCData(this, value);
+ this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates a comment node
+
+ // `value` comment text
+ comment(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLComment(this, value);
+ this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Adds unescaped raw text
+
+ // `value` text
+ raw(value) {
+ var node;
+ this.openCurrent();
+ node = new XMLRaw(this, value);
+ this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Adds a processing instruction
+
+ // `target` instruction target
+ // `value` instruction value
+ instruction(target, value) {
+ var i, insTarget, insValue, len, node;
+ this.openCurrent();
+ if (target != null) {
+ target = getValue(target);
+ }
+ if (value != null) {
+ value = getValue(value);
+ }
+ if (Array.isArray(target)) { // expand if array
+ for (i = 0, len = target.length; i < len; i++) {
+ insTarget = target[i];
+ this.instruction(insTarget);
+ }
+ } else if (isObject(target)) { // expand if object
+ for (insTarget in target) {
+ if (!hasProp.call(target, insTarget)) continue;
+ insValue = target[insTarget];
+ this.instruction(insTarget, insValue);
+ }
+ } else {
+ if (isFunction(value)) {
+ value = value.apply();
+ }
+ node = new XMLProcessingInstruction(this, target, value);
+ this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ }
+ return this;
+ }
+
+ // Creates the xml declaration
+
+ // `version` A version number string, e.g. 1.0
+ // `encoding` Encoding declaration, e.g. UTF-8
+ // `standalone` standalone document declaration: true or false
+ declaration(version, encoding, standalone) {
+ var node;
+ this.openCurrent();
+ if (this.documentStarted) {
+ throw new Error("declaration() must be the first node.");
+ }
+ node = new XMLDeclaration(this, version, encoding, standalone);
+ this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates the document type declaration
+
+ // `root` the name of the root node
+ // `pubID` the public identifier of the external subset
+ // `sysID` the system identifier of the external subset
+ doctype(root, pubID, sysID) {
+ this.openCurrent();
+ if (root == null) {
+ throw new Error("Missing root node name.");
+ }
+ if (this.root) {
+ throw new Error("dtd() must come before the root node.");
+ }
+ this.currentNode = new XMLDocType(this, pubID, sysID);
+ this.currentNode.rootNodeName = root;
+ this.currentNode.children = false;
+ this.currentLevel++;
+ this.openTags[this.currentLevel] = this.currentNode;
+ return this;
+ }
+
+ // Creates an element type declaration
+
+ // `name` element name
+ // `value` element content (defaults to #PCDATA)
+ dtdElement(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDElement(this, name, value);
+ this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates an attribute declaration
+
+ // `elementName` the name of the element containing this attribute
+ // `attributeName` attribute name
+ // `attributeType` type of the attribute (defaults to CDATA)
+ // `defaultValueType` default value type (either #REQUIRED, #IMPLIED, #FIXED or
+ // #DEFAULT) (defaults to #IMPLIED)
+ // `defaultValue` default value of the attribute
+ // (only used for #FIXED or #DEFAULT)
+ attList(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
+ this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates a general entity declaration
+
+ // `name` the name of the entity
+ // `value` internal entity value or an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ // `value.nData` notation declaration
+ entity(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDEntity(this, false, name, value);
+ this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates a parameter entity declaration
+
+ // `name` the name of the entity
+ // `value` internal entity value or an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ pEntity(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDEntity(this, true, name, value);
+ this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Creates a NOTATION declaration
+
+ // `name` the name of the notation
+ // `value` an object with external entity details
+ // `value.pubID` public identifier
+ // `value.sysID` system identifier
+ notation(name, value) {
+ var node;
+ this.openCurrent();
+ node = new XMLDTDNotation(this, name, value);
+ this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
+ return this;
+ }
+
+ // Gets the parent node
+ up() {
+ if (this.currentLevel < 0) {
+ throw new Error("The document node has no parent.");
+ }
+ if (this.currentNode) {
+ if (this.currentNode.children) {
+ this.closeNode(this.currentNode);
+ } else {
+ this.openNode(this.currentNode);
+ }
+ this.currentNode = null;
+ } else {
+ this.closeNode(this.openTags[this.currentLevel]);
+ }
+ delete this.openTags[this.currentLevel];
+ this.currentLevel--;
+ return this;
+ }
+
+ // Ends the document
+ end() {
+ while (this.currentLevel >= 0) {
+ this.up();
+ }
+ return this.onEnd();
+ }
+
+ // Opens the current parent node
+ openCurrent() {
+ if (this.currentNode) {
+ this.currentNode.children = true;
+ return this.openNode(this.currentNode);
+ }
+ }
+
+ // Writes the opening tag of the current node or the entire node if it has
+ // no child nodes
+ openNode(node) {
+ var att, chunk, name, ref;
+ if (!node.isOpen) {
+ if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) {
+ this.root = node;
+ }
+ chunk = '';
+ if (node.type === NodeType.Element) {
+ this.writerOptions.state = WriterState.OpenTag;
+ chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name;
+ ref = node.attribs;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel);
+ }
+ chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel);
+ this.writerOptions.state = WriterState.InsideTag; // if node.type is NodeType.DocType
+ } else {
+ this.writerOptions.state = WriterState.OpenTag;
+ chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '';
+ }
+ chunk += this.writer.endline(node, this.writerOptions, this.currentLevel);
+ }
+ this.onData(chunk, this.currentLevel);
+ return node.isOpen = true;
+ }
+ }
+
+ // Writes the closing tag of the current node
+ closeNode(node) {
+ var chunk;
+ if (!node.isClosed) {
+ chunk = '';
+ this.writerOptions.state = WriterState.CloseTag;
+ if (node.type === NodeType.Element) {
+ chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '' + node.name + '>' + this.writer.endline(node, this.writerOptions, this.currentLevel); // if node.type is NodeType.DocType
+ } else {
+ chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
+ }
+ this.writerOptions.state = WriterState.None;
+ this.onData(chunk, this.currentLevel);
+ return node.isClosed = true;
+ }
+ }
+
+ // Called when a new chunk of XML is output
+
+ // `chunk` a string containing the XML chunk
+ // `level` current indentation level
+ onData(chunk, level) {
+ this.documentStarted = true;
+ return this.onDataCallback(chunk, level + 1);
+ }
+
+ // Called when the XML document is completed
+ onEnd() {
+ this.documentCompleted = true;
+ return this.onEndCallback();
+ }
+
+ // Returns debug string
+ debugInfo(name) {
+ if (name == null) {
+ return "";
+ } else {
+ return "node: <" + name + ">";
+ }
+ }
+
+ // Node aliases
+ ele() {
+ return this.element(...arguments);
+ }
+
+ nod(name, attributes, text) {
+ return this.node(name, attributes, text);
+ }
+
+ txt(value) {
+ return this.text(value);
+ }
+
+ dat(value) {
+ return this.cdata(value);
+ }
+
+ com(value) {
+ return this.comment(value);
+ }
+
+ ins(target, value) {
+ return this.instruction(target, value);
+ }
+
+ dec(version, encoding, standalone) {
+ return this.declaration(version, encoding, standalone);
+ }
+
+ dtd(root, pubID, sysID) {
+ return this.doctype(root, pubID, sysID);
+ }
+
+ e(name, attributes, text) {
+ return this.element(name, attributes, text);
+ }
+
+ n(name, attributes, text) {
+ return this.node(name, attributes, text);
+ }
+
+ t(value) {
+ return this.text(value);
+ }
+
+ d(value) {
+ return this.cdata(value);
+ }
+
+ c(value) {
+ return this.comment(value);
+ }
+
+ r(value) {
+ return this.raw(value);
+ }
+
+ i(target, value) {
+ return this.instruction(target, value);
+ }
+
+ // Attribute aliases
+ att() {
+ if (this.currentNode && this.currentNode.type === NodeType.DocType) {
+ return this.attList(...arguments);
+ } else {
+ return this.attribute(...arguments);
+ }
+ }
+
+ a() {
+ if (this.currentNode && this.currentNode.type === NodeType.DocType) {
+ return this.attList(...arguments);
+ } else {
+ return this.attribute(...arguments);
+ }
+ }
+
+ // DTD aliases
+ // att() and ele() are defined above
+ ent(name, value) {
+ return this.entity(name, value);
+ }
+
+ pent(name, value) {
+ return this.pEntity(name, value);
+ }
+
+ not(name, value) {
+ return this.notation(name, value);
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":17,"./Utility":18,"./WriterState":19,"./XMLAttribute":20,"./XMLCData":21,"./XMLComment":23,"./XMLDTDAttList":28,"./XMLDTDElement":29,"./XMLDTDEntity":30,"./XMLDTDNotation":31,"./XMLDeclaration":32,"./XMLDocType":33,"./XMLDocument":34,"./XMLElement":37,"./XMLProcessingInstruction":41,"./XMLRaw":42,"./XMLStringWriter":44,"./XMLStringifier":45,"./XMLText":46}],36:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLDummy, XMLNode;
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ // Represents a raw node
+ module.exports = XMLDummy = class XMLDummy extends XMLNode {
+ // Initializes a new instance of `XMLDummy`
+
+ // `XMLDummy` is a special node representing a node with
+ // a null value. Dummy nodes are created while recursively
+ // building the XML tree. Simply skipping null values doesn't
+ // work because that would break the recursive chain.
+ constructor(parent) {
+ super(parent);
+ this.type = NodeType.Dummy;
+ }
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return '';
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":17,"./XMLNode":39}],37:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject,
+ hasProp = {}.hasOwnProperty;
+
+ ({isObject, isFunction, getValue} = require('./Utility'));
+
+ XMLNode = require('./XMLNode');
+
+ NodeType = require('./NodeType');
+
+ XMLAttribute = require('./XMLAttribute');
+
+ XMLNamedNodeMap = require('./XMLNamedNodeMap');
+
+ // Represents an element of the XML document
+ module.exports = XMLElement = (function() {
+ class XMLElement extends XMLNode {
+ // Initializes a new instance of `XMLElement`
+
+ // `parent` the parent node
+ // `name` element name
+ // `attributes` an object containing name/value pairs of attributes
+ constructor(parent, name, attributes) {
+ var child, j, len, ref;
+ super(parent);
+ if (name == null) {
+ throw new Error("Missing element name. " + this.debugInfo());
+ }
+ this.name = this.stringify.name(name);
+ this.type = NodeType.Element;
+ this.attribs = {};
+ this.schemaTypeInfo = null;
+ if (attributes != null) {
+ this.attribute(attributes);
+ }
+ // set properties if this is the root node
+ if (parent.type === NodeType.Document) {
+ this.isRoot = true;
+ this.documentObject = parent;
+ parent.rootObject = this;
+ // set dtd name
+ if (parent.children) {
+ ref = parent.children;
+ for (j = 0, len = ref.length; j < len; j++) {
+ child = ref[j];
+ if (child.type === NodeType.DocType) {
+ child.name = this.name;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ // Creates and returns a deep clone of `this`
+
+ clone() {
+ var att, attName, clonedSelf, ref;
+ clonedSelf = Object.create(this);
+ // remove document element
+ if (clonedSelf.isRoot) {
+ clonedSelf.documentObject = null;
+ }
+ // clone attributes
+ clonedSelf.attribs = {};
+ ref = this.attribs;
+ for (attName in ref) {
+ if (!hasProp.call(ref, attName)) continue;
+ att = ref[attName];
+ clonedSelf.attribs[attName] = att.clone();
+ }
+ // clone child nodes
+ clonedSelf.children = [];
+ this.children.forEach(function(child) {
+ var clonedChild;
+ clonedChild = child.clone();
+ clonedChild.parent = clonedSelf;
+ return clonedSelf.children.push(clonedChild);
+ });
+ return clonedSelf;
+ }
+
+ // Adds or modifies an attribute
+
+ // `name` attribute name
+ // `value` attribute value
+ attribute(name, value) {
+ var attName, attValue;
+ if (name != null) {
+ name = getValue(name);
+ }
+ if (isObject(name)) { // expand if object
+ for (attName in name) {
+ if (!hasProp.call(name, attName)) continue;
+ attValue = name[attName];
+ this.attribute(attName, attValue);
+ }
+ } else {
+ if (isFunction(value)) {
+ value = value.apply();
+ }
+ if (this.options.keepNullAttributes && (value == null)) {
+ this.attribs[name] = new XMLAttribute(this, name, "");
+ } else if (value != null) {
+ this.attribs[name] = new XMLAttribute(this, name, value);
+ }
+ }
+ return this;
+ }
+
+ // Removes an attribute
+
+ // `name` attribute name
+ removeAttribute(name) {
+ var attName, j, len;
+ // Also defined in DOM level 1
+ // removeAttribute(name) removes an attribute by name.
+ if (name == null) {
+ throw new Error("Missing attribute name. " + this.debugInfo());
+ }
+ name = getValue(name);
+ if (Array.isArray(name)) { // expand if array
+ for (j = 0, len = name.length; j < len; j++) {
+ attName = name[j];
+ delete this.attribs[attName];
+ }
+ } else {
+ delete this.attribs[name];
+ }
+ return this;
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ // `options.allowEmpty` do not self close empty element tags
+ toString(options) {
+ return this.options.writer.element(this, this.options.writer.filterOptions(options));
+ }
+
+ // Aliases
+ att(name, value) {
+ return this.attribute(name, value);
+ }
+
+ a(name, value) {
+ return this.attribute(name, value);
+ }
+
+ // DOM Level 1
+ getAttribute(name) {
+ if (this.attribs.hasOwnProperty(name)) {
+ return this.attribs[name].value;
+ } else {
+ return null;
+ }
+ }
+
+ setAttribute(name, value) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getAttributeNode(name) {
+ if (this.attribs.hasOwnProperty(name)) {
+ return this.attribs[name];
+ } else {
+ return null;
+ }
+ }
+
+ setAttributeNode(newAttr) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ removeAttributeNode(oldAttr) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementsByTagName(name) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM Level 2
+ getAttributeNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ setAttributeNS(namespaceURI, qualifiedName, value) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ removeAttributeNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getAttributeNodeNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ setAttributeNodeNS(newAttr) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementsByTagNameNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ hasAttribute(name) {
+ return this.attribs.hasOwnProperty(name);
+ }
+
+ hasAttributeNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM Level 3
+ setIdAttribute(name, isId) {
+ if (this.attribs.hasOwnProperty(name)) {
+ return this.attribs[name].isId;
+ } else {
+ return isId;
+ }
+ }
+
+ setIdAttributeNS(namespaceURI, localName, isId) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ setIdAttributeNode(idAttr, isId) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM Level 4
+ getElementsByTagName(tagname) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementsByTagNameNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getElementsByClassName(classNames) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ isEqualNode(node) {
+ var i, j, ref;
+ if (!super.isEqualNode(node)) {
+ return false;
+ }
+ if (node.namespaceURI !== this.namespaceURI) {
+ return false;
+ }
+ if (node.prefix !== this.prefix) {
+ return false;
+ }
+ if (node.localName !== this.localName) {
+ return false;
+ }
+ if (node.attribs.length !== this.attribs.length) {
+ return false;
+ }
+ for (i = j = 0, ref = this.attribs.length - 1; (0 <= ref ? j <= ref : j >= ref); i = 0 <= ref ? ++j : --j) {
+ if (!this.attribs[i].isEqualNode(node.attribs[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLElement.prototype, 'tagName', {
+ get: function() {
+ return this.name;
+ }
+ });
+
+ // DOM level 4
+ Object.defineProperty(XMLElement.prototype, 'namespaceURI', {
+ get: function() {
+ return '';
+ }
+ });
+
+ Object.defineProperty(XMLElement.prototype, 'prefix', {
+ get: function() {
+ return '';
+ }
+ });
+
+ Object.defineProperty(XMLElement.prototype, 'localName', {
+ get: function() {
+ return this.name;
+ }
+ });
+
+ Object.defineProperty(XMLElement.prototype, 'id', {
+ get: function() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+ });
+
+ Object.defineProperty(XMLElement.prototype, 'className', {
+ get: function() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+ });
+
+ Object.defineProperty(XMLElement.prototype, 'classList', {
+ get: function() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+ });
+
+ Object.defineProperty(XMLElement.prototype, 'attributes', {
+ get: function() {
+ if (!this.attributeMap || !this.attributeMap.nodes) {
+ this.attributeMap = new XMLNamedNodeMap(this.attribs);
+ }
+ return this.attributeMap;
+ }
+ });
+
+ return XMLElement;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./NodeType":17,"./Utility":18,"./XMLAttribute":20,"./XMLNamedNodeMap":38,"./XMLNode":39}],38:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Represents a map of nodes accessed by a string key
+ var XMLNamedNodeMap;
+
+ module.exports = XMLNamedNodeMap = (function() {
+ class XMLNamedNodeMap {
+ // Initializes a new instance of `XMLNamedNodeMap`
+ // This is just a wrapper around an ordinary
+ // JS object.
+
+ // `nodes` the object containing nodes.
+ constructor(nodes) {
+ this.nodes = nodes;
+ }
+
+ // Creates and returns a deep clone of `this`
+
+ clone() {
+ // this class should not be cloned since it wraps
+ // around a given object. The calling function should check
+ // whether the wrapped object is null and supply a new object
+ // (from the clone).
+ return this.nodes = null;
+ }
+
+ // DOM Level 1
+ getNamedItem(name) {
+ return this.nodes[name];
+ }
+
+ setNamedItem(node) {
+ var oldNode;
+ oldNode = this.nodes[node.nodeName];
+ this.nodes[node.nodeName] = node;
+ return oldNode || null;
+ }
+
+ removeNamedItem(name) {
+ var oldNode;
+ oldNode = this.nodes[name];
+ delete this.nodes[name];
+ return oldNode || null;
+ }
+
+ item(index) {
+ return this.nodes[Object.keys(this.nodes)[index]] || null;
+ }
+
+ // DOM level 2 functions to be implemented later
+ getNamedItemNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ setNamedItemNS(node) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ removeNamedItemNS(namespaceURI, localName) {
+ throw new Error("This DOM method is not implemented.");
+ }
+
+ };
+
+
+ // DOM level 1
+ Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
+ get: function() {
+ return Object.keys(this.nodes).length || 0;
+ }
+ });
+
+ return XMLNamedNodeMap;
+
+ }).call(this);
+
+}).call(this);
+
+},{}],39:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject,
+ hasProp = {}.hasOwnProperty,
+ splice = [].splice;
+
+ ({isObject, isFunction, isEmpty, getValue} = require('./Utility'));
+
+ XMLElement = null;
+
+ XMLCData = null;
+
+ XMLComment = null;
+
+ XMLDeclaration = null;
+
+ XMLDocType = null;
+
+ XMLRaw = null;
+
+ XMLText = null;
+
+ XMLProcessingInstruction = null;
+
+ XMLDummy = null;
+
+ NodeType = null;
+
+ XMLNodeList = null;
+
+ XMLNamedNodeMap = null;
+
+ DocumentPosition = null;
+
+ // Represents a generic XMl element
+ module.exports = XMLNode = (function() {
+ class XMLNode {
+ // Initializes a new instance of `XMLNode`
+
+ // `parent` the parent node
+ constructor(parent1) {
+ this.parent = parent1;
+ if (this.parent) {
+ this.options = this.parent.options;
+ this.stringify = this.parent.stringify;
+ }
+ this.value = null;
+ this.children = [];
+ this.baseURI = null;
+ // first execution, load dependencies that are otherwise
+ // circular (so we can't load them at the top)
+ if (!XMLElement) {
+ XMLElement = require('./XMLElement');
+ XMLCData = require('./XMLCData');
+ XMLComment = require('./XMLComment');
+ XMLDeclaration = require('./XMLDeclaration');
+ XMLDocType = require('./XMLDocType');
+ XMLRaw = require('./XMLRaw');
+ XMLText = require('./XMLText');
+ XMLProcessingInstruction = require('./XMLProcessingInstruction');
+ XMLDummy = require('./XMLDummy');
+ NodeType = require('./NodeType');
+ XMLNodeList = require('./XMLNodeList');
+ XMLNamedNodeMap = require('./XMLNamedNodeMap');
+ DocumentPosition = require('./DocumentPosition');
+ }
+ }
+
+
+ // Sets the parent node of this node and its children recursively
+
+ // `parent` the parent node
+ setParent(parent) {
+ var child, j, len, ref1, results;
+ this.parent = parent;
+ if (parent) {
+ this.options = parent.options;
+ this.stringify = parent.stringify;
+ }
+ ref1 = this.children;
+ results = [];
+ for (j = 0, len = ref1.length; j < len; j++) {
+ child = ref1[j];
+ results.push(child.setParent(this));
+ }
+ return results;
+ }
+
+ // Creates a child element node
+
+ // `name` node name or an object describing the XML tree
+ // `attributes` an object containing name/value pairs of attributes
+ // `text` element text
+ element(name, attributes, text) {
+ var childNode, item, j, k, key, lastChild, len, len1, val;
+ lastChild = null;
+ if (attributes === null && (text == null)) {
+ [attributes, text] = [{}, null];
+ }
+ if (attributes == null) {
+ attributes = {};
+ }
+ attributes = getValue(attributes);
+ // swap argument order: text <-> attributes
+ if (!isObject(attributes)) {
+ [text, attributes] = [attributes, text];
+ }
+ if (name != null) {
+ name = getValue(name);
+ }
+ // expand if array
+ if (Array.isArray(name)) {
+ for (j = 0, len = name.length; j < len; j++) {
+ item = name[j];
+ lastChild = this.element(item);
+ }
+ // evaluate if function
+ } else if (isFunction(name)) {
+ lastChild = this.element(name.apply());
+ // expand if object
+ } else if (isObject(name)) {
+ for (key in name) {
+ if (!hasProp.call(name, key)) continue;
+ val = name[key];
+ if (isFunction(val)) {
+ // evaluate if function
+ val = val.apply();
+ }
+ // assign attributes
+ if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
+ lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
+ // skip empty arrays
+ } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
+ lastChild = this.dummy();
+ // empty objects produce one node
+ } else if (isObject(val) && isEmpty(val)) {
+ lastChild = this.element(key);
+ // skip null and undefined nodes
+ } else if (!this.options.keepNullNodes && (val == null)) {
+ lastChild = this.dummy();
+
+ // expand list by creating child nodes
+ } else if (!this.options.separateArrayItems && Array.isArray(val)) {
+ for (k = 0, len1 = val.length; k < len1; k++) {
+ item = val[k];
+ childNode = {};
+ childNode[key] = item;
+ lastChild = this.element(childNode);
+ }
+
+ // expand child nodes under parent
+ } else if (isObject(val)) {
+ // if the key is #text expand child nodes under this node to support mixed content
+ if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
+ lastChild = this.element(val);
+ } else {
+ lastChild = this.element(key);
+ lastChild.element(val);
+ }
+ } else {
+
+ // text node
+ lastChild = this.element(key, val);
+ }
+ }
+ // skip null nodes
+ } else if (!this.options.keepNullNodes && text === null) {
+ lastChild = this.dummy();
+ } else {
+ // text node
+ if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
+ lastChild = this.text(text);
+ // cdata node
+ } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
+ lastChild = this.cdata(text);
+ // comment node
+ } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
+ lastChild = this.comment(text);
+ // raw text node
+ } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
+ lastChild = this.raw(text);
+ // processing instruction
+ } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
+ lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
+ } else {
+ // element node
+ lastChild = this.node(name, attributes, text);
+ }
+ }
+ if (lastChild == null) {
+ throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
+ }
+ return lastChild;
+ }
+
+ // Creates a child element node before the current node
+
+ // `name` node name or an object describing the XML tree
+ // `attributes` an object containing name/value pairs of attributes
+ // `text` element text
+ insertBefore(name, attributes, text) {
+ var child, i, newChild, refChild, removed;
+ // DOM level 1
+ // insertBefore(newChild, refChild) inserts the child node newChild before refChild
+ if (name != null ? name.type : void 0) {
+ newChild = name;
+ refChild = attributes;
+ newChild.setParent(this);
+ if (refChild) {
+ // temporarily remove children starting *with* refChild
+ i = children.indexOf(refChild);
+ removed = children.splice(i);
+
+ // add the new child
+ children.push(newChild);
+
+ // add back removed children after new child
+ Array.prototype.push.apply(children, removed);
+ } else {
+ children.push(newChild);
+ }
+ return newChild;
+ } else {
+ if (this.isRoot) {
+ throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
+ }
+
+ // temporarily remove children starting *with* this
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i);
+
+ // add the new child
+ child = this.parent.element(name, attributes, text);
+
+ // add back removed children after new child
+ Array.prototype.push.apply(this.parent.children, removed);
+ return child;
+ }
+ }
+
+ // Creates a child element node after the current node
+
+ // `name` node name or an object describing the XML tree
+ // `attributes` an object containing name/value pairs of attributes
+ // `text` element text
+ insertAfter(name, attributes, text) {
+ var child, i, removed;
+ if (this.isRoot) {
+ throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
+ }
+
+ // temporarily remove children starting *after* this
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i + 1);
+
+ // add the new child
+ child = this.parent.element(name, attributes, text);
+
+ // add back removed children after new child
+ Array.prototype.push.apply(this.parent.children, removed);
+ return child;
+ }
+
+ // Deletes a child element node
+
+ remove() {
+ var i, ref1;
+ if (this.isRoot) {
+ throw new Error("Cannot remove the root element. " + this.debugInfo());
+ }
+ i = this.parent.children.indexOf(this);
+ splice.apply(this.parent.children, [i, i - i + 1].concat(ref1 = [])), ref1;
+ return this.parent;
+ }
+
+ // Creates a node
+
+ // `name` name of the node
+ // `attributes` an object containing name/value pairs of attributes
+ // `text` element text
+ node(name, attributes, text) {
+ var child;
+ if (name != null) {
+ name = getValue(name);
+ }
+ attributes || (attributes = {});
+ attributes = getValue(attributes);
+ // swap argument order: text <-> attributes
+ if (!isObject(attributes)) {
+ [text, attributes] = [attributes, text];
+ }
+ child = new XMLElement(this, name, attributes);
+ if (text != null) {
+ child.text(text);
+ }
+ this.children.push(child);
+ return child;
+ }
+
+ // Creates a text node
+
+ // `value` element text
+ text(value) {
+ var child;
+ if (isObject(value)) {
+ this.element(value);
+ }
+ child = new XMLText(this, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates a CDATA node
+
+ // `value` element text without CDATA delimiters
+ cdata(value) {
+ var child;
+ child = new XMLCData(this, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates a comment node
+
+ // `value` comment text
+ comment(value) {
+ var child;
+ child = new XMLComment(this, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Creates a comment node before the current node
+
+ // `value` comment text
+ commentBefore(value) {
+ var child, i, removed;
+ // temporarily remove children starting *with* this
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i);
+ // add the new child
+ child = this.parent.comment(value);
+ // add back removed children after new child
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ }
+
+ // Creates a comment node after the current node
+
+ // `value` comment text
+ commentAfter(value) {
+ var child, i, removed;
+ // temporarily remove children starting *after* this
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i + 1);
+ // add the new child
+ child = this.parent.comment(value);
+ // add back removed children after new child
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ }
+
+ // Adds unescaped raw text
+
+ // `value` text
+ raw(value) {
+ var child;
+ child = new XMLRaw(this, value);
+ this.children.push(child);
+ return this;
+ }
+
+ // Adds a dummy node
+ dummy() {
+ var child;
+ child = new XMLDummy(this);
+ // Normally when a new node is created it is added to the child node collection.
+ // However, dummy nodes are never added to the XML tree. They are created while
+ // converting JS objects to XML nodes in order not to break the recursive function
+ // chain. They can be thought of as invisible nodes. They can be traversed through
+ // by using prev(), next(), up(), etc. functions but they do not exists in the tree.
+
+ // @children.push child
+ return child;
+ }
+
+ // Adds a processing instruction
+
+ // `target` instruction target
+ // `value` instruction value
+ instruction(target, value) {
+ var insTarget, insValue, instruction, j, len;
+ if (target != null) {
+ target = getValue(target);
+ }
+ if (value != null) {
+ value = getValue(value);
+ }
+ if (Array.isArray(target)) { // expand if array
+ for (j = 0, len = target.length; j < len; j++) {
+ insTarget = target[j];
+ this.instruction(insTarget);
+ }
+ } else if (isObject(target)) { // expand if object
+ for (insTarget in target) {
+ if (!hasProp.call(target, insTarget)) continue;
+ insValue = target[insTarget];
+ this.instruction(insTarget, insValue);
+ }
+ } else {
+ if (isFunction(value)) {
+ value = value.apply();
+ }
+ instruction = new XMLProcessingInstruction(this, target, value);
+ this.children.push(instruction);
+ }
+ return this;
+ }
+
+ // Creates a processing instruction node before the current node
+
+ // `target` instruction target
+ // `value` instruction value
+ instructionBefore(target, value) {
+ var child, i, removed;
+ // temporarily remove children starting *with* this
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i);
+ // add the new child
+ child = this.parent.instruction(target, value);
+ // add back removed children after new child
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ }
+
+ // Creates a processing instruction node after the current node
+
+ // `target` instruction target
+ // `value` instruction value
+ instructionAfter(target, value) {
+ var child, i, removed;
+ // temporarily remove children starting *after* this
+ i = this.parent.children.indexOf(this);
+ removed = this.parent.children.splice(i + 1);
+ // add the new child
+ child = this.parent.instruction(target, value);
+ // add back removed children after new child
+ Array.prototype.push.apply(this.parent.children, removed);
+ return this;
+ }
+
+ // Creates the xml declaration
+
+ // `version` A version number string, e.g. 1.0
+ // `encoding` Encoding declaration, e.g. UTF-8
+ // `standalone` standalone document declaration: true or false
+ declaration(version, encoding, standalone) {
+ var doc, xmldec;
+ doc = this.document();
+ xmldec = new XMLDeclaration(doc, version, encoding, standalone);
+ // Replace XML declaration if exists, otherwise insert at top
+ if (doc.children.length === 0) {
+ doc.children.unshift(xmldec);
+ } else if (doc.children[0].type === NodeType.Declaration) {
+ doc.children[0] = xmldec;
+ } else {
+ doc.children.unshift(xmldec);
+ }
+ return doc.root() || doc;
+ }
+
+ // Creates the document type declaration
+
+ // `pubID` the public identifier of the external subset
+ // `sysID` the system identifier of the external subset
+ dtd(pubID, sysID) {
+ var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
+ doc = this.document();
+ doctype = new XMLDocType(doc, pubID, sysID);
+ ref1 = doc.children;
+ // Replace DTD if exists
+ for (i = j = 0, len = ref1.length; j < len; i = ++j) {
+ child = ref1[i];
+ if (child.type === NodeType.DocType) {
+ doc.children[i] = doctype;
+ return doctype;
+ }
+ }
+ ref2 = doc.children;
+ // insert before root node if the root node exists
+ for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
+ child = ref2[i];
+ if (child.isRoot) {
+ doc.children.splice(i, 0, doctype);
+ return doctype;
+ }
+ }
+ // otherwise append to end
+ doc.children.push(doctype);
+ return doctype;
+ }
+
+ // Gets the parent node
+ up() {
+ if (this.isRoot) {
+ throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
+ }
+ return this.parent;
+ }
+
+ // Gets the root node
+ root() {
+ var node;
+ node = this;
+ while (node) {
+ if (node.type === NodeType.Document) {
+ return node.rootObject;
+ } else if (node.isRoot) {
+ return node;
+ } else {
+ node = node.parent;
+ }
+ }
+ }
+
+ // Gets the node representing the XML document
+ document() {
+ var node;
+ node = this;
+ while (node) {
+ if (node.type === NodeType.Document) {
+ return node;
+ } else {
+ node = node.parent;
+ }
+ }
+ }
+
+ // Ends the document and converts string
+ end(options) {
+ return this.document().end(options);
+ }
+
+ // Gets the previous node
+ prev() {
+ var i;
+ i = this.parent.children.indexOf(this);
+ if (i < 1) {
+ throw new Error("Already at the first node. " + this.debugInfo());
+ }
+ return this.parent.children[i - 1];
+ }
+
+ // Gets the next node
+ next() {
+ var i;
+ i = this.parent.children.indexOf(this);
+ if (i === -1 || i === this.parent.children.length - 1) {
+ throw new Error("Already at the last node. " + this.debugInfo());
+ }
+ return this.parent.children[i + 1];
+ }
+
+ // Imports cloned root from another XML document
+
+ // `doc` the XML document to insert nodes from
+ importDocument(doc) {
+ var child, clonedRoot, j, len, ref1;
+ clonedRoot = doc.root().clone();
+ clonedRoot.parent = this;
+ clonedRoot.isRoot = false;
+ this.children.push(clonedRoot);
+ // set properties if imported element becomes the root node
+ if (this.type === NodeType.Document) {
+ clonedRoot.isRoot = true;
+ clonedRoot.documentObject = this;
+ this.rootObject = clonedRoot;
+ // set dtd name
+ if (this.children) {
+ ref1 = this.children;
+ for (j = 0, len = ref1.length; j < len; j++) {
+ child = ref1[j];
+ if (child.type === NodeType.DocType) {
+ child.name = clonedRoot.name;
+ break;
+ }
+ }
+ }
+ }
+ return this;
+ }
+
+
+ // Returns debug string for this node
+ debugInfo(name) {
+ var ref1, ref2;
+ name = name || this.name;
+ if ((name == null) && !((ref1 = this.parent) != null ? ref1.name : void 0)) {
+ return "";
+ } else if (name == null) {
+ return "parent: <" + this.parent.name + ">";
+ } else if (!((ref2 = this.parent) != null ? ref2.name : void 0)) {
+ return "node: <" + name + ">";
+ } else {
+ return "node: <" + name + ">, parent: <" + this.parent.name + ">";
+ }
+ }
+
+ // Aliases
+ ele(name, attributes, text) {
+ return this.element(name, attributes, text);
+ }
+
+ nod(name, attributes, text) {
+ return this.node(name, attributes, text);
+ }
+
+ txt(value) {
+ return this.text(value);
+ }
+
+ dat(value) {
+ return this.cdata(value);
+ }
+
+ com(value) {
+ return this.comment(value);
+ }
+
+ ins(target, value) {
+ return this.instruction(target, value);
+ }
+
+ doc() {
+ return this.document();
+ }
+
+ dec(version, encoding, standalone) {
+ return this.declaration(version, encoding, standalone);
+ }
+
+ e(name, attributes, text) {
+ return this.element(name, attributes, text);
+ }
+
+ n(name, attributes, text) {
+ return this.node(name, attributes, text);
+ }
+
+ t(value) {
+ return this.text(value);
+ }
+
+ d(value) {
+ return this.cdata(value);
+ }
+
+ c(value) {
+ return this.comment(value);
+ }
+
+ r(value) {
+ return this.raw(value);
+ }
+
+ i(target, value) {
+ return this.instruction(target, value);
+ }
+
+ u() {
+ return this.up();
+ }
+
+ // can be deprecated in a future release
+ importXMLBuilder(doc) {
+ return this.importDocument(doc);
+ }
+
+ // Adds or modifies an attribute.
+
+ // `name` attribute name
+ // `value` attribute value
+ attribute(name, value) {
+ throw new Error("attribute() applies to element nodes only.");
+ }
+
+ att(name, value) {
+ return this.attribute(name, value);
+ }
+
+ a(name, value) {
+ return this.attribute(name, value);
+ }
+
+ // Removes an attribute
+
+ // `name` attribute name
+ removeAttribute(name) {
+ throw new Error("attribute() applies to element nodes only.");
+ }
+
+ // DOM level 1 functions to be implemented later
+ replaceChild(newChild, oldChild) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ removeChild(oldChild) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ appendChild(newChild) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ hasChildNodes() {
+ return this.children.length !== 0;
+ }
+
+ cloneNode(deep) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ normalize() {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // DOM level 2
+ isSupported(feature, version) {
+ return true;
+ }
+
+ hasAttributes() {
+ return this.attribs.length !== 0;
+ }
+
+ // DOM level 3 functions to be implemented later
+ compareDocumentPosition(other) {
+ var ref, res;
+ ref = this;
+ if (ref === other) {
+ return 0;
+ } else if (this.document() !== other.document()) {
+ res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
+ if (Math.random() < 0.5) {
+ res |= DocumentPosition.Preceding;
+ } else {
+ res |= DocumentPosition.Following;
+ }
+ return res;
+ } else if (ref.isAncestor(other)) {
+ return DocumentPosition.Contains | DocumentPosition.Preceding;
+ } else if (ref.isDescendant(other)) {
+ return DocumentPosition.Contains | DocumentPosition.Following;
+ } else if (ref.isPreceding(other)) {
+ return DocumentPosition.Preceding;
+ } else {
+ return DocumentPosition.Following;
+ }
+ }
+
+ isSameNode(other) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ lookupPrefix(namespaceURI) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ isDefaultNamespace(namespaceURI) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ lookupNamespaceURI(prefix) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ isEqualNode(node) {
+ var i, j, ref1;
+ if (node.nodeType !== this.nodeType) {
+ return false;
+ }
+ if (node.children.length !== this.children.length) {
+ return false;
+ }
+ for (i = j = 0, ref1 = this.children.length - 1; (0 <= ref1 ? j <= ref1 : j >= ref1); i = 0 <= ref1 ? ++j : --j) {
+ if (!this.children[i].isEqualNode(node.children[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ getFeature(feature, version) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ setUserData(key, data, handler) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ getUserData(key) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+
+ // Returns true if other is an inclusive descendant of node,
+ // and false otherwise.
+ contains(other) {
+ if (!other) {
+ return false;
+ }
+ return other === this || this.isDescendant(other);
+ }
+
+ // An object A is called a descendant of an object B, if either A is
+ // a child of B or A is a child of an object C that is a descendant of B.
+ isDescendant(node) {
+ var child, isDescendantChild, j, len, ref1;
+ ref1 = this.children;
+ for (j = 0, len = ref1.length; j < len; j++) {
+ child = ref1[j];
+ if (node === child) {
+ return true;
+ }
+ isDescendantChild = child.isDescendant(node);
+ if (isDescendantChild) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // An object A is called an ancestor of an object B if and only if
+ // B is a descendant of A.
+ isAncestor(node) {
+ return node.isDescendant(this);
+ }
+
+ // An object A is preceding an object B if A and B are in the
+ // same tree and A comes before B in tree order.
+ isPreceding(node) {
+ var nodePos, thisPos;
+ nodePos = this.treePosition(node);
+ thisPos = this.treePosition(this);
+ if (nodePos === -1 || thisPos === -1) {
+ return false;
+ } else {
+ return nodePos < thisPos;
+ }
+ }
+
+ // An object A is folllowing an object B if A and B are in the
+ // same tree and A comes after B in tree order.
+ isFollowing(node) {
+ var nodePos, thisPos;
+ nodePos = this.treePosition(node);
+ thisPos = this.treePosition(this);
+ if (nodePos === -1 || thisPos === -1) {
+ return false;
+ } else {
+ return nodePos > thisPos;
+ }
+ }
+
+ // Returns the preorder position of the given node in the tree, or -1
+ // if the node is not in the tree.
+ treePosition(node) {
+ var found, pos;
+ pos = 0;
+ found = false;
+ this.foreachTreeNode(this.document(), function(childNode) {
+ pos++;
+ if (!found && childNode === node) {
+ return found = true;
+ }
+ });
+ if (found) {
+ return pos;
+ } else {
+ return -1;
+ }
+ }
+
+
+ // Depth-first preorder traversal through the XML tree
+ foreachTreeNode(node, func) {
+ var child, j, len, ref1, res;
+ node || (node = this.document());
+ ref1 = node.children;
+ for (j = 0, len = ref1.length; j < len; j++) {
+ child = ref1[j];
+ if (res = func(child)) {
+ return res;
+ } else {
+ res = this.foreachTreeNode(child, func);
+ if (res) {
+ return res;
+ }
+ }
+ }
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLNode.prototype, 'nodeName', {
+ get: function() {
+ return this.name;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'nodeType', {
+ get: function() {
+ return this.type;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'nodeValue', {
+ get: function() {
+ return this.value;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'parentNode', {
+ get: function() {
+ return this.parent;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'childNodes', {
+ get: function() {
+ if (!this.childNodeList || !this.childNodeList.nodes) {
+ this.childNodeList = new XMLNodeList(this.children);
+ }
+ return this.childNodeList;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'firstChild', {
+ get: function() {
+ return this.children[0] || null;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'lastChild', {
+ get: function() {
+ return this.children[this.children.length - 1] || null;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'previousSibling', {
+ get: function() {
+ var i;
+ i = this.parent.children.indexOf(this);
+ return this.parent.children[i - 1] || null;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'nextSibling', {
+ get: function() {
+ var i;
+ i = this.parent.children.indexOf(this);
+ return this.parent.children[i + 1] || null;
+ }
+ });
+
+ Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
+ get: function() {
+ return this.document() || null;
+ }
+ });
+
+ // DOM level 3
+ Object.defineProperty(XMLNode.prototype, 'textContent', {
+ get: function() {
+ var child, j, len, ref1, str;
+ if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) {
+ str = '';
+ ref1 = this.children;
+ for (j = 0, len = ref1.length; j < len; j++) {
+ child = ref1[j];
+ if (child.textContent) {
+ str += child.textContent;
+ }
+ }
+ return str;
+ } else {
+ return null;
+ }
+ },
+ set: function(value) {
+ throw new Error("This DOM method is not implemented." + this.debugInfo());
+ }
+ });
+
+ return XMLNode;
+
+ }).call(this);
+
+}).call(this);
+
+},{"./DocumentPosition":16,"./NodeType":17,"./Utility":18,"./XMLCData":21,"./XMLComment":23,"./XMLDeclaration":32,"./XMLDocType":33,"./XMLDummy":36,"./XMLElement":37,"./XMLNamedNodeMap":38,"./XMLNodeList":40,"./XMLProcessingInstruction":41,"./XMLRaw":42,"./XMLText":46}],40:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Represents a list of nodes
+ var XMLNodeList;
+
+ module.exports = XMLNodeList = (function() {
+ class XMLNodeList {
+ // Initializes a new instance of `XMLNodeList`
+ // This is just a wrapper around an ordinary
+ // JS array.
+
+ // `nodes` the array containing nodes.
+ constructor(nodes) {
+ this.nodes = nodes;
+ }
+
+ // Creates and returns a deep clone of `this`
+
+ clone() {
+ // this class should not be cloned since it wraps
+ // around a given array. The calling function should check
+ // whether the wrapped array is null and supply a new array
+ // (from the clone).
+ return this.nodes = null;
+ }
+
+ // DOM Level 1
+ item(index) {
+ return this.nodes[index] || null;
+ }
+
+ };
+
+ // DOM level 1
+ Object.defineProperty(XMLNodeList.prototype, 'length', {
+ get: function() {
+ return this.nodes.length || 0;
+ }
+ });
+
+ return XMLNodeList;
+
+ }).call(this);
+
+}).call(this);
+
+},{}],41:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLCharacterData, XMLProcessingInstruction;
+
+ NodeType = require('./NodeType');
+
+ XMLCharacterData = require('./XMLCharacterData');
+
+ // Represents a processing instruction
+ module.exports = XMLProcessingInstruction = class XMLProcessingInstruction extends XMLCharacterData {
+ // Initializes a new instance of `XMLProcessingInstruction`
+
+ // `parent` the parent node
+ // `target` instruction target
+ // `value` instruction value
+ constructor(parent, target, value) {
+ super(parent);
+ if (target == null) {
+ throw new Error("Missing instruction target. " + this.debugInfo());
+ }
+ this.type = NodeType.ProcessingInstruction;
+ this.target = this.stringify.insTarget(target);
+ this.name = this.target;
+ if (value) {
+ this.value = this.stringify.insValue(value);
+ }
+ }
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
+ }
+
+ isEqualNode(node) {
+ if (!super.isEqualNode(node)) {
+ return false;
+ }
+ if (node.target !== this.target) {
+ return false;
+ }
+ return true;
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":17,"./XMLCharacterData":22}],42:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, XMLNode, XMLRaw;
+
+ NodeType = require('./NodeType');
+
+ XMLNode = require('./XMLNode');
+
+ // Represents a raw node
+ module.exports = XMLRaw = class XMLRaw extends XMLNode {
+ // Initializes a new instance of `XMLRaw`
+
+ // `text` raw text
+ constructor(parent, text) {
+ super(parent);
+ if (text == null) {
+ throw new Error("Missing raw text. " + this.debugInfo());
+ }
+ this.type = NodeType.Raw;
+ this.value = this.stringify.raw(text);
+ }
+
+ // Creates and returns a deep clone of `this`
+ clone() {
+ return Object.create(this);
+ }
+
+ // Converts the XML fragment to string
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation for pretty print
+ // `options.offset` how many indentations to add to every line for pretty print
+ // `options.newline` newline sequence for pretty print
+ toString(options) {
+ return this.options.writer.raw(this, this.options.writer.filterOptions(options));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":17,"./XMLNode":39}],43:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, WriterState, XMLStreamWriter, XMLWriterBase,
+ hasProp = {}.hasOwnProperty;
+
+ NodeType = require('./NodeType');
+
+ XMLWriterBase = require('./XMLWriterBase');
+
+ WriterState = require('./WriterState');
+
+ // Prints XML nodes to a stream
+ module.exports = XMLStreamWriter = class XMLStreamWriter extends XMLWriterBase {
+ // Initializes a new instance of `XMLStreamWriter`
+
+ // `stream` output stream
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation string
+ // `options.newline` newline sequence
+ // `options.offset` a fixed number of indentations to add to every line
+ // `options.allowEmpty` do not self close empty element tags
+ // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF
+ // `options.spaceBeforeSlash` add a space before the closing slash of empty elements
+ constructor(stream, options) {
+ super(options);
+ this.stream = stream;
+ }
+
+ endline(node, options, level) {
+ if (node.isLastRootNode && options.state === WriterState.CloseTag) {
+ return '';
+ } else {
+ return super.endline(node, options, level);
+ }
+ }
+
+ document(doc, options) {
+ var child, i, j, k, len1, len2, ref, ref1, results;
+ ref = doc.children;
+ // set a flag so that we don't insert a newline after the last root level node
+ for (i = j = 0, len1 = ref.length; j < len1; i = ++j) {
+ child = ref[i];
+ child.isLastRootNode = i === doc.children.length - 1;
+ }
+ options = this.filterOptions(options);
+ ref1 = doc.children;
+ results = [];
+ for (k = 0, len2 = ref1.length; k < len2; k++) {
+ child = ref1[k];
+ results.push(this.writeChildNode(child, options, 0));
+ }
+ return results;
+ }
+
+ cdata(node, options, level) {
+ return this.stream.write(super.cdata(node, options, level));
+ }
+
+ comment(node, options, level) {
+ return this.stream.write(super.comment(node, options, level));
+ }
+
+ declaration(node, options, level) {
+ return this.stream.write(super.declaration(node, options, level));
+ }
+
+ docType(node, options, level) {
+ var child, j, len1, ref;
+ level || (level = 0);
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ this.stream.write(this.indent(node, options, level));
+ this.stream.write(' 0) {
+ this.stream.write(' [');
+ this.stream.write(this.endline(node, options, level));
+ options.state = WriterState.InsideTag;
+ ref = node.children;
+ for (j = 0, len1 = ref.length; j < len1; j++) {
+ child = ref[j];
+ this.writeChildNode(child, options, level + 1);
+ }
+ options.state = WriterState.CloseTag;
+ this.stream.write(']');
+ }
+ // close tag
+ options.state = WriterState.CloseTag;
+ this.stream.write(options.spaceBeforeSlash + '>');
+ this.stream.write(this.endline(node, options, level));
+ options.state = WriterState.None;
+ return this.closeNode(node, options, level);
+ }
+
+ element(node, options, level) {
+ var att, attLen, child, childNodeCount, firstChildNode, j, len, len1, name, prettySuppressed, r, ratt, ref, ref1, ref2, rline;
+ level || (level = 0);
+ // open tag
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '<' + node.name;
+ // attributes
+ if (options.pretty && options.width > 0) {
+ len = r.length;
+ ref = node.attribs;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ ratt = this.attribute(att, options, level);
+ attLen = ratt.length;
+ if (len + attLen > options.width) {
+ rline = this.indent(node, options, level + 1) + ratt;
+ r += this.endline(node, options, level) + rline;
+ len = rline.length;
+ } else {
+ rline = ' ' + ratt;
+ r += rline;
+ len += rline.length;
+ }
+ }
+ } else {
+ ref1 = node.attribs;
+ for (name in ref1) {
+ if (!hasProp.call(ref1, name)) continue;
+ att = ref1[name];
+ r += this.attribute(att, options, level);
+ }
+ }
+ this.stream.write(r);
+ childNodeCount = node.children.length;
+ firstChildNode = childNodeCount === 0 ? null : node.children[0];
+ if (childNodeCount === 0 || node.children.every(function(e) {
+ return (e.type === NodeType.Text || e.type === NodeType.Raw || e.type === NodeType.CData) && e.value === '';
+ })) {
+ // empty element
+ if (options.allowEmpty) {
+ this.stream.write('>');
+ options.state = WriterState.CloseTag;
+ this.stream.write('' + node.name + '>');
+ } else {
+ options.state = WriterState.CloseTag;
+ this.stream.write(options.spaceBeforeSlash + '/>');
+ }
+ } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw || firstChildNode.type === NodeType.CData) && (firstChildNode.value != null)) {
+ // do not indent text-only nodes
+ this.stream.write('>');
+ options.state = WriterState.InsideTag;
+ options.suppressPrettyCount++;
+ prettySuppressed = true;
+ this.writeChildNode(firstChildNode, options, level + 1);
+ options.suppressPrettyCount--;
+ prettySuppressed = false;
+ options.state = WriterState.CloseTag;
+ this.stream.write('' + node.name + '>');
+ } else {
+ this.stream.write('>' + this.endline(node, options, level));
+ options.state = WriterState.InsideTag;
+ ref2 = node.children;
+ // inner tags
+ for (j = 0, len1 = ref2.length; j < len1; j++) {
+ child = ref2[j];
+ this.writeChildNode(child, options, level + 1);
+ }
+ // close tag
+ options.state = WriterState.CloseTag;
+ this.stream.write(this.indent(node, options, level) + '' + node.name + '>');
+ }
+ this.stream.write(this.endline(node, options, level));
+ options.state = WriterState.None;
+ return this.closeNode(node, options, level);
+ }
+
+ processingInstruction(node, options, level) {
+ return this.stream.write(super.processingInstruction(node, options, level));
+ }
+
+ raw(node, options, level) {
+ return this.stream.write(super.raw(node, options, level));
+ }
+
+ text(node, options, level) {
+ return this.stream.write(super.text(node, options, level));
+ }
+
+ dtdAttList(node, options, level) {
+ return this.stream.write(super.dtdAttList(node, options, level));
+ }
+
+ dtdElement(node, options, level) {
+ return this.stream.write(super.dtdElement(node, options, level));
+ }
+
+ dtdEntity(node, options, level) {
+ return this.stream.write(super.dtdEntity(node, options, level));
+ }
+
+ dtdNotation(node, options, level) {
+ return this.stream.write(super.dtdNotation(node, options, level));
+ }
+
+ };
+
+}).call(this);
+
+},{"./NodeType":17,"./WriterState":19,"./XMLWriterBase":47}],44:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var XMLStringWriter, XMLWriterBase;
+
+ XMLWriterBase = require('./XMLWriterBase');
+
+ // Prints XML nodes as plain text
+ module.exports = XMLStringWriter = class XMLStringWriter extends XMLWriterBase {
+ // Initializes a new instance of `XMLStringWriter`
+
+ // `options.pretty` pretty prints the result
+ // `options.indent` indentation string
+ // `options.newline` newline sequence
+ // `options.offset` a fixed number of indentations to add to every line
+ // `options.allowEmpty` do not self close empty element tags
+ // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF
+ // `options.spaceBeforeSlash` add a space before the closing slash of empty elements
+ constructor(options) {
+ super(options);
+ }
+
+ document(doc, options) {
+ var child, i, len, r, ref;
+ options = this.filterOptions(options);
+ r = '';
+ ref = doc.children;
+ for (i = 0, len = ref.length; i < len; i++) {
+ child = ref[i];
+ r += this.writeChildNode(child, options, 0);
+ }
+ // remove trailing newline
+ if (options.pretty && r.slice(-options.newline.length) === options.newline) {
+ r = r.slice(0, -options.newline.length);
+ }
+ return r;
+ }
+
+ };
+
+}).call(this);
+
+},{"./XMLWriterBase":47}],45:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ // Converts values to strings
+ var XMLStringifier,
+ hasProp = {}.hasOwnProperty;
+
+ module.exports = XMLStringifier = (function() {
+ class XMLStringifier {
+ // Initializes a new instance of `XMLStringifier`
+
+ // `options.version` The version number string of the XML spec to validate against, e.g. 1.0
+ // `options.noDoubleEncoding` whether existing html entities are encoded: true or false
+ // `options.stringify` a set of functions to use for converting values to strings
+ // `options.noValidation` whether values will be validated and escaped or returned as is
+ // `options.invalidCharReplacement` a character to replace invalid characters and disable character validation
+ constructor(options) {
+ var key, ref, value;
+ // Checks whether the given string contains legal characters
+ // Fails with an exception on error
+
+ // `str` the string to check
+ this.assertLegalChar = this.assertLegalChar.bind(this);
+ // Checks whether the given string contains legal characters for a name
+ // Fails with an exception on error
+
+ // `str` the string to check
+ this.assertLegalName = this.assertLegalName.bind(this);
+ options || (options = {});
+ this.options = options;
+ if (!this.options.version) {
+ this.options.version = '1.0';
+ }
+ ref = options.stringify || {};
+ for (key in ref) {
+ if (!hasProp.call(ref, key)) continue;
+ value = ref[key];
+ this[key] = value;
+ }
+ }
+
+ // Defaults
+ name(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalName('' + val || '');
+ }
+
+ text(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar(this.textEscape('' + val || ''));
+ }
+
+ cdata(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ val = '' + val || '';
+ val = val.replace(']]>', ']]]]>');
+ return this.assertLegalChar(val);
+ }
+
+ comment(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ val = '' + val || '';
+ if (val.match(/--/)) {
+ throw new Error("Comment text cannot contain double-hypen: " + val);
+ }
+ return this.assertLegalChar(val);
+ }
+
+ raw(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return '' + val || '';
+ }
+
+ attValue(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar(this.attEscape(val = '' + val || ''));
+ }
+
+ insTarget(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ insValue(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ val = '' + val || '';
+ if (val.match(/\?>/)) {
+ throw new Error("Invalid processing instruction value: " + val);
+ }
+ return this.assertLegalChar(val);
+ }
+
+ xmlVersion(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ val = '' + val || '';
+ if (!val.match(/1\.[0-9]+/)) {
+ throw new Error("Invalid version number: " + val);
+ }
+ return val;
+ }
+
+ xmlEncoding(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ val = '' + val || '';
+ if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
+ throw new Error("Invalid encoding: " + val);
+ }
+ return this.assertLegalChar(val);
+ }
+
+ xmlStandalone(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ if (val) {
+ return "yes";
+ } else {
+ return "no";
+ }
+ }
+
+ dtdPubID(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ dtdSysID(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ dtdElementValue(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ dtdAttType(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ dtdAttDefault(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ dtdEntityValue(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ dtdNData(val) {
+ if (this.options.noValidation) {
+ return val;
+ }
+ return this.assertLegalChar('' + val || '');
+ }
+
+ assertLegalChar(str) {
+ var regex, res;
+ if (this.options.noValidation) {
+ return str;
+ }
+ if (this.options.version === '1.0') {
+ // Valid characters from https://www.w3.org/TR/xml/#charsets
+ // any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
+ // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ // This ES5 compatible Regexp has been generated using the "regenerate" NPM module:
+ // let xml_10_InvalidChars = regenerate()
+ // .addRange(0x0000, 0x0008)
+ // .add(0x000B, 0x000C)
+ // .addRange(0x000E, 0x001F)
+ // .addRange(0xD800, 0xDFFF)
+ // .addRange(0xFFFE, 0xFFFF)
+ regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
+ if (this.options.invalidCharReplacement !== void 0) {
+ str = str.replace(regex, this.options.invalidCharReplacement);
+ } else if (res = str.match(regex)) {
+ throw new Error(`Invalid character in string: ${str} at index ${res.index}`);
+ }
+ } else if (this.options.version === '1.1') {
+ // Valid characters from https://www.w3.org/TR/xml11/#charsets
+ // any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
+ // [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ // This ES5 compatible Regexp has been generated using the "regenerate" NPM module:
+ // let xml_11_InvalidChars = regenerate()
+ // .add(0x0000)
+ // .addRange(0xD800, 0xDFFF)
+ // .addRange(0xFFFE, 0xFFFF)
+ regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
+ if (this.options.invalidCharReplacement !== void 0) {
+ str = str.replace(regex, this.options.invalidCharReplacement);
+ } else if (res = str.match(regex)) {
+ throw new Error(`Invalid character in string: ${str} at index ${res.index}`);
+ }
+ }
+ return str;
+ }
+
+ assertLegalName(str) {
+ var regex;
+ if (this.options.noValidation) {
+ return str;
+ }
+ str = this.assertLegalChar(str);
+ regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/;
+ if (!str.match(regex)) {
+ throw new Error(`Invalid character in name: ${str}`);
+ }
+ return str;
+ }
+
+ // Escapes special characters in text
+
+ // See http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping
+
+ // `str` the string to escape
+ textEscape(str) {
+ var ampregex;
+ if (this.options.noValidation) {
+ return str;
+ }
+ ampregex = this.options.noDoubleEncoding ? /(?!&(lt|gt|amp|apos|quot);)&/g : /&/g;
+ return str.replace(ampregex, '&').replace(//g, '>').replace(/\r/g, '
');
+ }
+
+ // Escapes special characters in attribute values
+
+ // See http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping
+
+ // `str` the string to escape
+ attEscape(str) {
+ var ampregex;
+ if (this.options.noValidation) {
+ return str;
+ }
+ ampregex = this.options.noDoubleEncoding ? /(?!&(lt|gt|amp|apos|quot);)&/g : /&/g;
+ return str.replace(ampregex, '&').replace(/ 0) {
+ return new Array(indentLevel).join(options.indent);
+ }
+ }
+ return '';
+ }
+
+ // Returns the newline string
+
+ // `node` current node
+ // `options` writer options
+ // `level` current indentation level
+ endline(node, options, level) {
+ if (!options.pretty || options.suppressPrettyCount) {
+ return '';
+ } else {
+ return options.newline;
+ }
+ }
+
+ attribute(att, options, level) {
+ var r;
+ this.openAttribute(att, options, level);
+ if (options.pretty && options.width > 0) {
+ r = att.name + '="' + att.value + '"';
+ } else {
+ r = ' ' + att.name + '="' + att.value + '"';
+ }
+ this.closeAttribute(att, options, level);
+ return r;
+ }
+
+ cdata(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '' + this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ comment(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '' + this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ declaration(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '';
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ docType(node, options, level) {
+ var child, i, len1, r, ref;
+ level || (level = 0);
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level);
+ r += ' 0) {
+ r += ' [';
+ r += this.endline(node, options, level);
+ options.state = WriterState.InsideTag;
+ ref = node.children;
+ for (i = 0, len1 = ref.length; i < len1; i++) {
+ child = ref[i];
+ r += this.writeChildNode(child, options, level + 1);
+ }
+ options.state = WriterState.CloseTag;
+ r += ']';
+ }
+ // close tag
+ options.state = WriterState.CloseTag;
+ r += options.spaceBeforeSlash + '>';
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ element(node, options, level) {
+ var att, attLen, child, childNodeCount, firstChildNode, i, j, len, len1, len2, name, prettySuppressed, r, ratt, ref, ref1, ref2, ref3, rline;
+ level || (level = 0);
+ prettySuppressed = false;
+ // open tag
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '<' + node.name;
+ // attributes
+ if (options.pretty && options.width > 0) {
+ len = r.length;
+ ref = node.attribs;
+ for (name in ref) {
+ if (!hasProp.call(ref, name)) continue;
+ att = ref[name];
+ ratt = this.attribute(att, options, level);
+ attLen = ratt.length;
+ if (len + attLen > options.width) {
+ rline = this.indent(node, options, level + 1) + ratt;
+ r += this.endline(node, options, level) + rline;
+ len = rline.length;
+ } else {
+ rline = ' ' + ratt;
+ r += rline;
+ len += rline.length;
+ }
+ }
+ } else {
+ ref1 = node.attribs;
+ for (name in ref1) {
+ if (!hasProp.call(ref1, name)) continue;
+ att = ref1[name];
+ r += this.attribute(att, options, level);
+ }
+ }
+ childNodeCount = node.children.length;
+ firstChildNode = childNodeCount === 0 ? null : node.children[0];
+ if (childNodeCount === 0 || node.children.every(function(e) {
+ return (e.type === NodeType.Text || e.type === NodeType.Raw || e.type === NodeType.CData) && e.value === '';
+ })) {
+ // empty element
+ if (options.allowEmpty) {
+ r += '>';
+ options.state = WriterState.CloseTag;
+ r += '' + node.name + '>' + this.endline(node, options, level);
+ } else {
+ options.state = WriterState.CloseTag;
+ r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
+ }
+ } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw || firstChildNode.type === NodeType.CData) && (firstChildNode.value != null)) {
+ // do not indent text-only nodes
+ r += '>';
+ options.state = WriterState.InsideTag;
+ options.suppressPrettyCount++;
+ prettySuppressed = true;
+ r += this.writeChildNode(firstChildNode, options, level + 1);
+ options.suppressPrettyCount--;
+ prettySuppressed = false;
+ options.state = WriterState.CloseTag;
+ r += '' + node.name + '>' + this.endline(node, options, level);
+ } else {
+ // if ANY are a text node, then suppress pretty now
+ if (options.dontPrettyTextNodes) {
+ ref2 = node.children;
+ for (i = 0, len1 = ref2.length; i < len1; i++) {
+ child = ref2[i];
+ if ((child.type === NodeType.Text || child.type === NodeType.Raw || child.type === NodeType.CData) && (child.value != null)) {
+ options.suppressPrettyCount++;
+ prettySuppressed = true;
+ break;
+ }
+ }
+ }
+ // close the opening tag, after dealing with newline
+ r += '>' + this.endline(node, options, level);
+ options.state = WriterState.InsideTag;
+ ref3 = node.children;
+ // inner tags
+ for (j = 0, len2 = ref3.length; j < len2; j++) {
+ child = ref3[j];
+ r += this.writeChildNode(child, options, level + 1);
+ }
+ // close tag
+ options.state = WriterState.CloseTag;
+ r += this.indent(node, options, level) + '' + node.name + '>';
+ if (prettySuppressed) {
+ options.suppressPrettyCount--;
+ }
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ }
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ writeChildNode(node, options, level) {
+ switch (node.type) {
+ case NodeType.CData:
+ return this.cdata(node, options, level);
+ case NodeType.Comment:
+ return this.comment(node, options, level);
+ case NodeType.Element:
+ return this.element(node, options, level);
+ case NodeType.Raw:
+ return this.raw(node, options, level);
+ case NodeType.Text:
+ return this.text(node, options, level);
+ case NodeType.ProcessingInstruction:
+ return this.processingInstruction(node, options, level);
+ case NodeType.Dummy:
+ return '';
+ case NodeType.Declaration:
+ return this.declaration(node, options, level);
+ case NodeType.DocType:
+ return this.docType(node, options, level);
+ case NodeType.AttributeDeclaration:
+ return this.dtdAttList(node, options, level);
+ case NodeType.ElementDeclaration:
+ return this.dtdElement(node, options, level);
+ case NodeType.EntityDeclaration:
+ return this.dtdEntity(node, options, level);
+ case NodeType.NotationDeclaration:
+ return this.dtdNotation(node, options, level);
+ default:
+ throw new Error("Unknown XML node type: " + node.constructor.name);
+ }
+ }
+
+ processingInstruction(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '';
+ options.state = WriterState.InsideTag;
+ r += node.target;
+ if (node.value) {
+ r += ' ' + node.value;
+ }
+ options.state = WriterState.CloseTag;
+ r += options.spaceBeforeSlash + '?>';
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ raw(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level);
+ options.state = WriterState.InsideTag;
+ r += node.value;
+ options.state = WriterState.CloseTag;
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ text(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level);
+ options.state = WriterState.InsideTag;
+ r += node.value;
+ options.state = WriterState.CloseTag;
+ r += this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ dtdAttList(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '' + this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ dtdElement(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '' + this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ dtdEntity(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '' + this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ dtdNotation(node, options, level) {
+ var r;
+ this.openNode(node, options, level);
+ options.state = WriterState.OpenTag;
+ r = this.indent(node, options, level) + '' + this.endline(node, options, level);
+ options.state = WriterState.None;
+ this.closeNode(node, options, level);
+ return r;
+ }
+
+ openNode(node, options, level) {}
+
+ closeNode(node, options, level) {}
+
+ openAttribute(att, options, level) {}
+
+ closeAttribute(att, options, level) {}
+
+ };
+
+}).call(this);
+
+},{"./NodeType":17,"./Utility":18,"./WriterState":19,"./XMLCData":21,"./XMLComment":23,"./XMLDTDAttList":28,"./XMLDTDElement":29,"./XMLDTDEntity":30,"./XMLDTDNotation":31,"./XMLDeclaration":32,"./XMLDocType":33,"./XMLDummy":36,"./XMLElement":37,"./XMLProcessingInstruction":41,"./XMLRaw":42,"./XMLText":46}],48:[function(require,module,exports){
+// Generated by CoffeeScript 2.4.1
+(function() {
+ var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction;
+
+ ({assign, isFunction} = require('./Utility'));
+
+ XMLDOMImplementation = require('./XMLDOMImplementation');
+
+ XMLDocument = require('./XMLDocument');
+
+ XMLDocumentCB = require('./XMLDocumentCB');
+
+ XMLStringWriter = require('./XMLStringWriter');
+
+ XMLStreamWriter = require('./XMLStreamWriter');
+
+ NodeType = require('./NodeType');
+
+ WriterState = require('./WriterState');
+
+ // Creates a new document and returns the root node for
+ // chain-building the document tree
+
+ // `name` name of the root element
+
+ // `xmldec.version` A version number string, e.g. 1.0
+ // `xmldec.encoding` Encoding declaration, e.g. UTF-8
+ // `xmldec.standalone` standalone document declaration: true or false
+
+ // `doctype.pubID` public identifier of the external subset
+ // `doctype.sysID` system identifier of the external subset
+
+ // `options.headless` whether XML declaration and doctype will be included:
+ // true or false
+ // `options.keepNullNodes` whether nodes with null values will be kept
+ // or ignored: true or false
+ // `options.keepNullAttributes` whether attributes with null values will be
+ // kept or ignored: true or false
+ // `options.ignoreDecorators` whether decorator strings will be ignored when
+ // converting JS objects: true or false
+ // `options.separateArrayItems` whether array items are created as separate
+ // nodes when passed as an object value: true or false
+ // `options.noDoubleEncoding` whether existing html entities are encoded:
+ // true or false
+ // `options.stringify` a set of functions to use for converting values to
+ // strings
+ // `options.writer` the default XML writer to use for converting nodes to
+ // string. If the default writer is not set, the built-in XMLStringWriter
+ // will be used instead.
+ module.exports.create = function(name, xmldec, doctype, options) {
+ var doc, root;
+ if (name == null) {
+ throw new Error("Root element needs a name.");
+ }
+ options = assign({}, xmldec, doctype, options);
+ // create the document node
+ doc = new XMLDocument(options);
+ // add the root node
+ root = doc.element(name);
+ // prolog
+ if (!options.headless) {
+ doc.declaration(options);
+ if ((options.pubID != null) || (options.sysID != null)) {
+ doc.dtd(options);
+ }
+ }
+ return root;
+ };
+
+ // Creates a new document and returns the document node for
+ // chain-building the document tree
+
+ // `options.keepNullNodes` whether nodes with null values will be kept
+ // or ignored: true or false
+ // `options.keepNullAttributes` whether attributes with null values will be
+ // kept or ignored: true or false
+ // `options.ignoreDecorators` whether decorator strings will be ignored when
+ // converting JS objects: true or false
+ // `options.separateArrayItems` whether array items are created as separate
+ // nodes when passed as an object value: true or false
+ // `options.noDoubleEncoding` whether existing html entities are encoded:
+ // true or false
+ // `options.stringify` a set of functions to use for converting values to
+ // strings
+ // `options.writer` the default XML writer to use for converting nodes to
+ // string. If the default writer is not set, the built-in XMLStringWriter
+ // will be used instead.
+
+ // `onData` the function to be called when a new chunk of XML is output. The
+ // string containing the XML chunk is passed to `onData` as its single
+ // argument.
+ // `onEnd` the function to be called when the XML document is completed with
+ // `end`. `onEnd` does not receive any arguments.
+ module.exports.begin = function(options, onData, onEnd) {
+ if (isFunction(options)) {
+ [onData, onEnd] = [options, onData];
+ options = {};
+ }
+ if (onData) {
+ return new XMLDocumentCB(options, onData, onEnd);
+ } else {
+ return new XMLDocument(options);
+ }
+ };
+
+ module.exports.stringWriter = function(options) {
+ return new XMLStringWriter(options);
+ };
+
+ module.exports.streamWriter = function(stream, options) {
+ return new XMLStreamWriter(stream, options);
+ };
+
+ module.exports.implementation = new XMLDOMImplementation();
+
+ module.exports.nodeType = NodeType;
+
+ module.exports.writerState = WriterState;
+
+}).call(this);
+
+},{"./NodeType":17,"./Utility":18,"./WriterState":19,"./XMLDOMImplementation":26,"./XMLDocument":34,"./XMLDocumentCB":35,"./XMLStreamWriter":43,"./XMLStringWriter":44}]},{},[1])(1)
+});
diff --git a/node_modules/plist/examples/browser/index.html b/node_modules/plist/examples/browser/index.html
new file mode 100644
index 0000000..8ce7d92
--- /dev/null
+++ b/node_modules/plist/examples/browser/index.html
@@ -0,0 +1,14 @@
+
+
+
+ plist.js browser example
+
+
+
+
+
+
+
diff --git a/node_modules/plist/index.js b/node_modules/plist/index.js
new file mode 100644
index 0000000..d7385ae
--- /dev/null
+++ b/node_modules/plist/index.js
@@ -0,0 +1,13 @@
+/**
+ * Parser functions.
+ */
+
+var parserFunctions = require('./lib/parse');
+Object.keys(parserFunctions).forEach(function (k) { exports[k] = parserFunctions[k]; });
+
+/**
+ * Builder functions.
+ */
+
+var builderFunctions = require('./lib/build');
+Object.keys(builderFunctions).forEach(function (k) { exports[k] = builderFunctions[k]; });
diff --git a/node_modules/plist/lib/build.js b/node_modules/plist/lib/build.js
new file mode 100644
index 0000000..c2a84b1
--- /dev/null
+++ b/node_modules/plist/lib/build.js
@@ -0,0 +1,143 @@
+/**
+ * Module dependencies.
+ */
+
+var base64 = require('base64-js');
+var xmlbuilder = require('xmlbuilder');
+
+/**
+ * Module exports.
+ */
+
+exports.build = build;
+
+/**
+ * Accepts a `Date` instance and returns an ISO date string.
+ *
+ * @param {Date} d - Date instance to serialize
+ * @returns {String} ISO date string representation of `d`
+ * @api private
+ */
+
+function ISODateString(d){
+ function pad(n){
+ return n < 10 ? '0' + n : n;
+ }
+ return d.getUTCFullYear()+'-'
+ + pad(d.getUTCMonth()+1)+'-'
+ + pad(d.getUTCDate())+'T'
+ + pad(d.getUTCHours())+':'
+ + pad(d.getUTCMinutes())+':'
+ + pad(d.getUTCSeconds())+'Z';
+}
+
+/**
+ * Returns the internal "type" of `obj` via the
+ * `Object.prototype.toString()` trick.
+ *
+ * @param {Mixed} obj - any value
+ * @returns {String} the internal "type" name
+ * @api private
+ */
+
+var toString = Object.prototype.toString;
+function type (obj) {
+ var m = toString.call(obj).match(/\[object (.*)\]/);
+ return m ? m[1] : m;
+}
+
+/**
+ * Generate an XML plist string from the input object `obj`.
+ *
+ * @param {Object} obj - the object to convert
+ * @param {Object} [opts] - optional options object
+ * @returns {String} converted plist XML string
+ * @api public
+ */
+
+function build (obj, opts) {
+ var XMLHDR = {
+ version: '1.0',
+ encoding: 'UTF-8'
+ };
+
+ var XMLDTD = {
+ pubid: '-//Apple//DTD PLIST 1.0//EN',
+ sysid: 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'
+ };
+
+ var doc = xmlbuilder.create('plist');
+
+ doc.dec(XMLHDR.version, XMLHDR.encoding, XMLHDR.standalone);
+ doc.dtd(XMLDTD.pubid, XMLDTD.sysid);
+ doc.att('version', '1.0');
+
+ walk_obj(obj, doc);
+
+ if (!opts) opts = {};
+ // default `pretty` to `true`
+ opts.pretty = opts.pretty !== false;
+ return doc.end(opts);
+}
+
+/**
+ * depth first, recursive traversal of a javascript object. when complete,
+ * next_child contains a reference to the build XML object.
+ *
+ * @api private
+ */
+
+function walk_obj(next, next_child) {
+ var tag_type, i, prop;
+ var name = type(next);
+
+ if ('Undefined' == name) {
+ return;
+ } else if (Array.isArray(next)) {
+ next_child = next_child.ele('array');
+ for (i = 0; i < next.length; i++) {
+ walk_obj(next[i], next_child);
+ }
+
+ } else if (Buffer.isBuffer(next)) {
+ next_child.ele('data').raw(next.toString('base64'));
+
+ } else if ('Object' == name) {
+ next_child = next_child.ele('dict');
+ for (prop in next) {
+ if (next.hasOwnProperty(prop)) {
+ next_child.ele('key').txt(prop);
+ walk_obj(next[prop], next_child);
+ }
+ }
+
+ } else if ('Number' == name) {
+ // detect if this is an integer or real
+ // TODO: add an ability to force one way or another via a "cast"
+ tag_type = (next % 1 === 0) ? 'integer' : 'real';
+ next_child.ele(tag_type).txt(next.toString());
+
+ } else if ('BigInt' == name) {
+ next_child.ele('integer').txt(next);
+
+ } else if ('Date' == name) {
+ next_child.ele('date').txt(ISODateString(new Date(next)));
+
+ } else if ('Boolean' == name) {
+ next_child.ele(next ? 'true' : 'false');
+
+ } else if ('String' == name) {
+ next_child.ele('string').txt(next);
+
+ } else if ('ArrayBuffer' == name) {
+ next_child.ele('data').raw(base64.fromByteArray(next));
+
+ } else if (next && next.buffer && 'ArrayBuffer' == type(next.buffer)) {
+ // a typed array
+ next_child.ele('data').raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));
+
+ } else if ('Null' === name) {
+ next_child.ele('null').txt('');
+
+ }
+}
diff --git a/node_modules/plist/lib/parse.js b/node_modules/plist/lib/parse.js
new file mode 100644
index 0000000..250f6ca
--- /dev/null
+++ b/node_modules/plist/lib/parse.js
@@ -0,0 +1,208 @@
+/**
+ * Module dependencies.
+ */
+
+const { DOMParser } = require("@xmldom/xmldom");
+
+/**
+ * Module exports.
+ */
+
+exports.parse = parse;
+
+var TEXT_NODE = 3;
+var CDATA_NODE = 4;
+var COMMENT_NODE = 8;
+
+/**
+ * We ignore raw text (usually whitespace), ,
+ * and raw CDATA nodes.
+ *
+ * @param {Element} node
+ * @returns {Boolean}
+ * @api private
+ */
+
+function shouldIgnoreNode(node) {
+ return (
+ node.nodeType === TEXT_NODE ||
+ node.nodeType === COMMENT_NODE ||
+ node.nodeType === CDATA_NODE
+ );
+}
+
+/**
+ * Check if the node is empty. Some plist file has such node:
+ *
+ * this node shoud be ignored.
+ *
+ * @see https://github.com/TooTallNate/plist.js/issues/66
+ * @param {Element} node
+ * @returns {Boolean}
+ * @api private
+ */
+function isEmptyNode(node) {
+ if (!node.childNodes || node.childNodes.length === 0) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+function invariant(test, message) {
+ if (!test) {
+ throw new Error(message);
+ }
+}
+
+/**
+ * Parses a Plist XML string. Returns an Object.
+ *
+ * @param {String} xml - the XML String to decode
+ * @returns {Mixed} the decoded value from the Plist XML
+ * @api public
+ */
+
+function parse(xml) {
+ var doc = new DOMParser().parseFromString(xml, "text/xml");
+ invariant(
+ doc.documentElement.nodeName === "plist",
+ "malformed document. First element should be ",
+ );
+ var plist = parsePlistXML(doc.documentElement);
+
+ // the root node gets interpreted as an Array,
+ // so pull out the inner data first
+ if (plist.length == 1) plist = plist[0];
+
+ return plist;
+}
+
+/**
+ * Convert an XML based plist document into a JSON representation.
+ *
+ * @param {Object} xml_node - current XML node in the plist
+ * @returns {Mixed} built up JSON object
+ * @api private
+ */
+
+function parsePlistXML(node) {
+ var i, new_obj, key, val, new_arr, res, counter, type;
+
+ if (!node) return null;
+
+ if (node.nodeName === "plist") {
+ new_arr = [];
+ if (isEmptyNode(node)) {
+ return new_arr;
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (!shouldIgnoreNode(node.childNodes[i])) {
+ new_arr.push(parsePlistXML(node.childNodes[i]));
+ }
+ }
+ return new_arr;
+ } else if (node.nodeName === "dict") {
+ new_obj = {};
+ key = null;
+ counter = 0;
+ if (isEmptyNode(node)) {
+ return new_obj;
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (shouldIgnoreNode(node.childNodes[i])) continue;
+ if (counter % 2 === 0) {
+ invariant(
+ node.childNodes[i].nodeName === "key",
+ "Missing key while parsing .",
+ );
+ key = parsePlistXML(node.childNodes[i]);
+ } else {
+ invariant(
+ node.childNodes[i].nodeName !== "key",
+ 'Unexpected key "' +
+ parsePlistXML(node.childNodes[i]) +
+ '" while parsing .',
+ );
+ new_obj[key] = parsePlistXML(node.childNodes[i]);
+ }
+ counter += 1;
+ }
+ if (counter % 2 === 1) {
+ new_obj[key] = "";
+ }
+
+ return new_obj;
+ } else if (node.nodeName === "array") {
+ new_arr = [];
+ if (isEmptyNode(node)) {
+ return new_arr;
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (!shouldIgnoreNode(node.childNodes[i])) {
+ res = parsePlistXML(node.childNodes[i]);
+ if (null != res) new_arr.push(res);
+ }
+ }
+ return new_arr;
+ } else if (node.nodeName === "#text") {
+ // TODO: what should we do with text types? (CDATA sections)
+ } else if (node.nodeName === "key") {
+ if (isEmptyNode(node)) {
+ return "";
+ }
+
+ invariant(
+ node.childNodes[0].nodeValue !== "__proto__",
+ "__proto__ keys can lead to prototype pollution. More details on CVE-2022-22912",
+ );
+
+ return node.childNodes[0].nodeValue;
+ } else if (node.nodeName === "string") {
+ res = "";
+ if (isEmptyNode(node)) {
+ return res;
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ var type = node.childNodes[i].nodeType;
+ if (type === TEXT_NODE || type === CDATA_NODE) {
+ res += node.childNodes[i].nodeValue;
+ }
+ }
+ return res;
+ } else if (node.nodeName === "integer") {
+ invariant(!isEmptyNode(node), 'Cannot parse "" as integer.');
+ return parseInt(node.childNodes[0].nodeValue, 10);
+ } else if (node.nodeName === "real") {
+ invariant(!isEmptyNode(node), 'Cannot parse "" as real.');
+ res = "";
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (node.childNodes[i].nodeType === TEXT_NODE) {
+ res += node.childNodes[i].nodeValue;
+ }
+ }
+ return parseFloat(res);
+ } else if (node.nodeName === "data") {
+ res = "";
+ if (isEmptyNode(node)) {
+ return Buffer.from(res, "base64");
+ }
+ for (i = 0; i < node.childNodes.length; i++) {
+ if (node.childNodes[i].nodeType === TEXT_NODE) {
+ res += node.childNodes[i].nodeValue.replace(/\s+/g, "");
+ }
+ }
+ return Buffer.from(res, "base64");
+ } else if (node.nodeName === "date") {
+ invariant(!isEmptyNode(node), 'Cannot parse "" as Date.');
+ return new Date(node.childNodes[0].nodeValue);
+ } else if (node.nodeName === "null") {
+ return null;
+ } else if (node.nodeName === "true") {
+ return true;
+ } else if (node.nodeName === "false") {
+ return false;
+ } else {
+ throw new Error("Invalid PLIST tag " + node.nodeName);
+ }
+}
diff --git a/node_modules/plist/package.json b/node_modules/plist/package.json
new file mode 100644
index 0000000..5c2f093
--- /dev/null
+++ b/node_modules/plist/package.json
@@ -0,0 +1,43 @@
+{
+ "name": "plist",
+ "description": "Apple's property list parser/builder for Node.js and browsers",
+ "version": "3.1.1",
+ "author": "Nathan Rajlich ",
+ "contributors": [
+ "Hans Huebner ",
+ "Pierre Metrailler",
+ "Mike Reinstein ",
+ "Vladimir Tsvang",
+ "Mathieu D'Amours"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/TooTallNate/node-plist.git"
+ },
+ "license": "MIT",
+ "keywords": [
+ "apple",
+ "browser",
+ "mac",
+ "plist",
+ "parser",
+ "xml"
+ ],
+ "main": "index.js",
+ "dependencies": {
+ "@xmldom/xmldom": "^0.9.10",
+ "base64-js": "^1.5.1",
+ "xmlbuilder": "^15.1.1"
+ },
+ "devDependencies": {
+ "browserify": "^17.0.0",
+ "mocha": "^10.2.0",
+ "zuul": "3.12.0"
+ },
+ "scripts": {
+ "test": "make test"
+ },
+ "engines": {
+ "node": ">=10.4.0"
+ }
+}
diff --git a/node_modules/prompts/dist/dateparts/datepart.js b/node_modules/prompts/dist/dateparts/datepart.js
new file mode 100644
index 0000000..b954c5e
--- /dev/null
+++ b/node_modules/prompts/dist/dateparts/datepart.js
@@ -0,0 +1,39 @@
+'use strict';
+
+class DatePart {
+ constructor({
+ token,
+ date,
+ parts,
+ locales
+ }) {
+ this.token = token;
+ this.date = date || new Date();
+ this.parts = parts || [this];
+ this.locales = locales || {};
+ }
+
+ up() {}
+
+ down() {}
+
+ next() {
+ const currentIdx = this.parts.indexOf(this);
+ return this.parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
+ }
+
+ setTo(val) {}
+
+ prev() {
+ let parts = [].concat(this.parts).reverse();
+ const currentIdx = parts.indexOf(this);
+ return parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
+ }
+
+ toString() {
+ return String(this.date);
+ }
+
+}
+
+module.exports = DatePart;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/dateparts/day.js b/node_modules/prompts/dist/dateparts/day.js
new file mode 100644
index 0000000..a525e92
--- /dev/null
+++ b/node_modules/prompts/dist/dateparts/day.js
@@ -0,0 +1,35 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+const pos = n => {
+ n = n % 10;
+ return n === 1 ? 'st' : n === 2 ? 'nd' : n === 3 ? 'rd' : 'th';
+};
+
+class Day extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setDate(this.date.getDate() + 1);
+ }
+
+ down() {
+ this.date.setDate(this.date.getDate() - 1);
+ }
+
+ setTo(val) {
+ this.date.setDate(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let date = this.date.getDate();
+ let day = this.date.getDay();
+ return this.token === 'DD' ? String(date).padStart(2, '0') : this.token === 'Do' ? date + pos(date) : this.token === 'd' ? day + 1 : this.token === 'ddd' ? this.locales.weekdaysShort[day] : this.token === 'dddd' ? this.locales.weekdays[day] : date;
+ }
+
+}
+
+module.exports = Day;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/dateparts/hours.js b/node_modules/prompts/dist/dateparts/hours.js
new file mode 100644
index 0000000..7743632
--- /dev/null
+++ b/node_modules/prompts/dist/dateparts/hours.js
@@ -0,0 +1,30 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Hours extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setHours(this.date.getHours() + 1);
+ }
+
+ down() {
+ this.date.setHours(this.date.getHours() - 1);
+ }
+
+ setTo(val) {
+ this.date.setHours(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let hours = this.date.getHours();
+ if (/h/.test(this.token)) hours = hours % 12 || 12;
+ return this.token.length > 1 ? String(hours).padStart(2, '0') : hours;
+ }
+
+}
+
+module.exports = Hours;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/dateparts/index.js b/node_modules/prompts/dist/dateparts/index.js
new file mode 100644
index 0000000..754516e
--- /dev/null
+++ b/node_modules/prompts/dist/dateparts/index.js
@@ -0,0 +1,13 @@
+'use strict';
+
+module.exports = {
+ DatePart: require('./datepart'),
+ Meridiem: require('./meridiem'),
+ Day: require('./day'),
+ Hours: require('./hours'),
+ Milliseconds: require('./milliseconds'),
+ Minutes: require('./minutes'),
+ Month: require('./month'),
+ Seconds: require('./seconds'),
+ Year: require('./year')
+};
\ No newline at end of file
diff --git a/node_modules/prompts/dist/dateparts/meridiem.js b/node_modules/prompts/dist/dateparts/meridiem.js
new file mode 100644
index 0000000..5bc8dd7
--- /dev/null
+++ b/node_modules/prompts/dist/dateparts/meridiem.js
@@ -0,0 +1,25 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Meridiem extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setHours((this.date.getHours() + 12) % 24);
+ }
+
+ down() {
+ this.up();
+ }
+
+ toString() {
+ let meridiem = this.date.getHours() > 12 ? 'pm' : 'am';
+ return /\A/.test(this.token) ? meridiem.toUpperCase() : meridiem;
+ }
+
+}
+
+module.exports = Meridiem;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/dateparts/milliseconds.js b/node_modules/prompts/dist/dateparts/milliseconds.js
new file mode 100644
index 0000000..3440e3a
--- /dev/null
+++ b/node_modules/prompts/dist/dateparts/milliseconds.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Milliseconds extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setMilliseconds(this.date.getMilliseconds() + 1);
+ }
+
+ down() {
+ this.date.setMilliseconds(this.date.getMilliseconds() - 1);
+ }
+
+ setTo(val) {
+ this.date.setMilliseconds(parseInt(val.substr(-this.token.length)));
+ }
+
+ toString() {
+ return String(this.date.getMilliseconds()).padStart(4, '0').substr(0, this.token.length);
+ }
+
+}
+
+module.exports = Milliseconds;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/dateparts/minutes.js b/node_modules/prompts/dist/dateparts/minutes.js
new file mode 100644
index 0000000..2b8ef1f
--- /dev/null
+++ b/node_modules/prompts/dist/dateparts/minutes.js
@@ -0,0 +1,29 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Minutes extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setMinutes(this.date.getMinutes() + 1);
+ }
+
+ down() {
+ this.date.setMinutes(this.date.getMinutes() - 1);
+ }
+
+ setTo(val) {
+ this.date.setMinutes(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let m = this.date.getMinutes();
+ return this.token.length > 1 ? String(m).padStart(2, '0') : m;
+ }
+
+}
+
+module.exports = Minutes;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/dateparts/month.js b/node_modules/prompts/dist/dateparts/month.js
new file mode 100644
index 0000000..f9d4e13
--- /dev/null
+++ b/node_modules/prompts/dist/dateparts/month.js
@@ -0,0 +1,31 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Month extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setMonth(this.date.getMonth() + 1);
+ }
+
+ down() {
+ this.date.setMonth(this.date.getMonth() - 1);
+ }
+
+ setTo(val) {
+ val = parseInt(val.substr(-2)) - 1;
+ this.date.setMonth(val < 0 ? 0 : val);
+ }
+
+ toString() {
+ let month = this.date.getMonth();
+ let tl = this.token.length;
+ return tl === 2 ? String(month + 1).padStart(2, '0') : tl === 3 ? this.locales.monthsShort[month] : tl === 4 ? this.locales.months[month] : String(month + 1);
+ }
+
+}
+
+module.exports = Month;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/dateparts/seconds.js b/node_modules/prompts/dist/dateparts/seconds.js
new file mode 100644
index 0000000..e16f030
--- /dev/null
+++ b/node_modules/prompts/dist/dateparts/seconds.js
@@ -0,0 +1,29 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Seconds extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setSeconds(this.date.getSeconds() + 1);
+ }
+
+ down() {
+ this.date.setSeconds(this.date.getSeconds() - 1);
+ }
+
+ setTo(val) {
+ this.date.setSeconds(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let s = this.date.getSeconds();
+ return this.token.length > 1 ? String(s).padStart(2, '0') : s;
+ }
+
+}
+
+module.exports = Seconds;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/dateparts/year.js b/node_modules/prompts/dist/dateparts/year.js
new file mode 100644
index 0000000..cd62677
--- /dev/null
+++ b/node_modules/prompts/dist/dateparts/year.js
@@ -0,0 +1,29 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Year extends DatePart {
+ constructor(opts = {}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setFullYear(this.date.getFullYear() + 1);
+ }
+
+ down() {
+ this.date.setFullYear(this.date.getFullYear() - 1);
+ }
+
+ setTo(val) {
+ this.date.setFullYear(val.substr(-4));
+ }
+
+ toString() {
+ let year = String(this.date.getFullYear()).padStart(4, '0');
+ return this.token.length === 2 ? year.substr(-2) : year;
+ }
+
+}
+
+module.exports = Year;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/elements/autocomplete.js b/node_modules/prompts/dist/elements/autocomplete.js
new file mode 100644
index 0000000..60e41bc
--- /dev/null
+++ b/node_modules/prompts/dist/elements/autocomplete.js
@@ -0,0 +1,285 @@
+'use strict';
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('sisteransi'),
+ erase = _require.erase,
+ cursor = _require.cursor;
+
+const _require2 = require('../util'),
+ style = _require2.style,
+ clear = _require2.clear,
+ figures = _require2.figures,
+ wrap = _require2.wrap,
+ entriesToDisplay = _require2.entriesToDisplay;
+
+const getVal = (arr, i) => arr[i] && (arr[i].value || arr[i].title || arr[i]);
+
+const getTitle = (arr, i) => arr[i] && (arr[i].title || arr[i].value || arr[i]);
+
+const getIndex = (arr, valOrTitle) => {
+ const index = arr.findIndex(el => el.value === valOrTitle || el.title === valOrTitle);
+ return index > -1 ? index : undefined;
+};
+/**
+ * TextPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of auto-complete choices objects
+ * @param {Function} [opts.suggest] Filter function. Defaults to sort by title
+ * @param {Number} [opts.limit=10] Max number of results to show
+ * @param {Number} [opts.cursor=0] Cursor start position
+ * @param {String} [opts.style='default'] Render style
+ * @param {String} [opts.fallback] Fallback message - initial to default value
+ * @param {String} [opts.initial] Index of the default value
+ * @param {Boolean} [opts.clearFirst] The first ESCAPE keypress will clear the input
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.noMatches] The no matches found label
+ */
+
+
+class AutocompletePrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.msg = opts.message;
+ this.suggest = opts.suggest;
+ this.choices = opts.choices;
+ this.initial = typeof opts.initial === 'number' ? opts.initial : getIndex(opts.choices, opts.initial);
+ this.select = this.initial || opts.cursor || 0;
+ this.i18n = {
+ noMatches: opts.noMatches || 'no matches found'
+ };
+ this.fallback = opts.fallback || this.initial;
+ this.clearFirst = opts.clearFirst || false;
+ this.suggestions = [];
+ this.input = '';
+ this.limit = opts.limit || 10;
+ this.cursor = 0;
+ this.transform = style.render(opts.style);
+ this.scale = this.transform.scale;
+ this.render = this.render.bind(this);
+ this.complete = this.complete.bind(this);
+ this.clear = clear('', this.out.columns);
+ this.complete(this.render);
+ this.render();
+ }
+
+ set fallback(fb) {
+ this._fb = Number.isSafeInteger(parseInt(fb)) ? parseInt(fb) : fb;
+ }
+
+ get fallback() {
+ let choice;
+ if (typeof this._fb === 'number') choice = this.choices[this._fb];else if (typeof this._fb === 'string') choice = {
+ title: this._fb
+ };
+ return choice || this._fb || {
+ title: this.i18n.noMatches
+ };
+ }
+
+ moveSelect(i) {
+ this.select = i;
+ if (this.suggestions.length > 0) this.value = getVal(this.suggestions, i);else this.value = this.fallback.value;
+ this.fire();
+ }
+
+ complete(cb) {
+ var _this = this;
+
+ return _asyncToGenerator(function* () {
+ const p = _this.completing = _this.suggest(_this.input, _this.choices);
+
+ const suggestions = yield p;
+ if (_this.completing !== p) return;
+ _this.suggestions = suggestions.map((s, i, arr) => ({
+ title: getTitle(arr, i),
+ value: getVal(arr, i),
+ description: s.description
+ }));
+ _this.completing = false;
+ const l = Math.max(suggestions.length - 1, 0);
+
+ _this.moveSelect(Math.min(l, _this.select));
+
+ cb && cb();
+ })();
+ }
+
+ reset() {
+ this.input = '';
+ this.complete(() => {
+ this.moveSelect(this.initial !== void 0 ? this.initial : 0);
+ this.render();
+ });
+ this.render();
+ }
+
+ exit() {
+ if (this.clearFirst && this.input.length > 0) {
+ this.reset();
+ } else {
+ this.done = this.exited = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.exited = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ this.done = true;
+ this.aborted = this.exited = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ _(c, key) {
+ let s1 = this.input.slice(0, this.cursor);
+ let s2 = this.input.slice(this.cursor);
+ this.input = `${s1}${c}${s2}`;
+ this.cursor = s1.length + 1;
+ this.complete(this.render);
+ this.render();
+ }
+
+ delete() {
+ if (this.cursor === 0) return this.bell();
+ let s1 = this.input.slice(0, this.cursor - 1);
+ let s2 = this.input.slice(this.cursor);
+ this.input = `${s1}${s2}`;
+ this.complete(this.render);
+ this.cursor = this.cursor - 1;
+ this.render();
+ }
+
+ deleteForward() {
+ if (this.cursor * this.scale >= this.rendered.length) return this.bell();
+ let s1 = this.input.slice(0, this.cursor);
+ let s2 = this.input.slice(this.cursor + 1);
+ this.input = `${s1}${s2}`;
+ this.complete(this.render);
+ this.render();
+ }
+
+ first() {
+ this.moveSelect(0);
+ this.render();
+ }
+
+ last() {
+ this.moveSelect(this.suggestions.length - 1);
+ this.render();
+ }
+
+ up() {
+ if (this.select === 0) {
+ this.moveSelect(this.suggestions.length - 1);
+ } else {
+ this.moveSelect(this.select - 1);
+ }
+
+ this.render();
+ }
+
+ down() {
+ if (this.select === this.suggestions.length - 1) {
+ this.moveSelect(0);
+ } else {
+ this.moveSelect(this.select + 1);
+ }
+
+ this.render();
+ }
+
+ next() {
+ if (this.select === this.suggestions.length - 1) {
+ this.moveSelect(0);
+ } else this.moveSelect(this.select + 1);
+
+ this.render();
+ }
+
+ nextPage() {
+ this.moveSelect(Math.min(this.select + this.limit, this.suggestions.length - 1));
+ this.render();
+ }
+
+ prevPage() {
+ this.moveSelect(Math.max(this.select - this.limit, 0));
+ this.render();
+ }
+
+ left() {
+ if (this.cursor <= 0) return this.bell();
+ this.cursor = this.cursor - 1;
+ this.render();
+ }
+
+ right() {
+ if (this.cursor * this.scale >= this.rendered.length) return this.bell();
+ this.cursor = this.cursor + 1;
+ this.render();
+ }
+
+ renderOption(v, hovered, isStart, isEnd) {
+ let desc;
+ let prefix = isStart ? figures.arrowUp : isEnd ? figures.arrowDown : ' ';
+ let title = hovered ? color.cyan().underline(v.title) : v.title;
+ prefix = (hovered ? color.cyan(figures.pointer) + ' ' : ' ') + prefix;
+
+ if (v.description) {
+ desc = ` - ${v.description}`;
+
+ if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
+ desc = '\n' + wrap(v.description, {
+ margin: 3,
+ width: this.out.columns
+ });
+ }
+ }
+
+ return prefix + ' ' + title + color.gray(desc || '');
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ let _entriesToDisplay = entriesToDisplay(this.select, this.choices.length, this.limit),
+ startIndex = _entriesToDisplay.startIndex,
+ endIndex = _entriesToDisplay.endIndex;
+
+ this.outputText = [style.symbol(this.done, this.aborted, this.exited), color.bold(this.msg), style.delimiter(this.completing), this.done && this.suggestions[this.select] ? this.suggestions[this.select].title : this.rendered = this.transform.render(this.input)].join(' ');
+
+ if (!this.done) {
+ const suggestions = this.suggestions.slice(startIndex, endIndex).map((item, i) => this.renderOption(item, this.select === i + startIndex, i === 0 && startIndex > 0, i + startIndex === endIndex - 1 && endIndex < this.choices.length)).join('\n');
+ this.outputText += `\n` + (suggestions || color.gray(this.fallback.title));
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+
+}
+
+module.exports = AutocompletePrompt;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/elements/autocompleteMultiselect.js b/node_modules/prompts/dist/elements/autocompleteMultiselect.js
new file mode 100644
index 0000000..ac4af0d
--- /dev/null
+++ b/node_modules/prompts/dist/elements/autocompleteMultiselect.js
@@ -0,0 +1,201 @@
+'use strict';
+
+const color = require('kleur');
+
+const _require = require('sisteransi'),
+ cursor = _require.cursor;
+
+const MultiselectPrompt = require('./multiselect');
+
+const _require2 = require('../util'),
+ clear = _require2.clear,
+ style = _require2.style,
+ figures = _require2.figures;
+/**
+ * MultiselectPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of choice objects
+ * @param {String} [opts.hint] Hint to display
+ * @param {String} [opts.warn] Hint shown for disabled choices
+ * @param {Number} [opts.max] Max choices
+ * @param {Number} [opts.cursor=0] Cursor start position
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+
+
+class AutocompleteMultiselectPrompt extends MultiselectPrompt {
+ constructor(opts = {}) {
+ opts.overrideRender = true;
+ super(opts);
+ this.inputValue = '';
+ this.clear = clear('', this.out.columns);
+ this.filteredOptions = this.value;
+ this.render();
+ }
+
+ last() {
+ this.cursor = this.filteredOptions.length - 1;
+ this.render();
+ }
+
+ next() {
+ this.cursor = (this.cursor + 1) % this.filteredOptions.length;
+ this.render();
+ }
+
+ up() {
+ if (this.cursor === 0) {
+ this.cursor = this.filteredOptions.length - 1;
+ } else {
+ this.cursor--;
+ }
+
+ this.render();
+ }
+
+ down() {
+ if (this.cursor === this.filteredOptions.length - 1) {
+ this.cursor = 0;
+ } else {
+ this.cursor++;
+ }
+
+ this.render();
+ }
+
+ left() {
+ this.filteredOptions[this.cursor].selected = false;
+ this.render();
+ }
+
+ right() {
+ if (this.value.filter(e => e.selected).length >= this.maxChoices) return this.bell();
+ this.filteredOptions[this.cursor].selected = true;
+ this.render();
+ }
+
+ delete() {
+ if (this.inputValue.length) {
+ this.inputValue = this.inputValue.substr(0, this.inputValue.length - 1);
+ this.updateFilteredOptions();
+ }
+ }
+
+ updateFilteredOptions() {
+ const currentHighlight = this.filteredOptions[this.cursor];
+ this.filteredOptions = this.value.filter(v => {
+ if (this.inputValue) {
+ if (typeof v.title === 'string') {
+ if (v.title.toLowerCase().includes(this.inputValue.toLowerCase())) {
+ return true;
+ }
+ }
+
+ if (typeof v.value === 'string') {
+ if (v.value.toLowerCase().includes(this.inputValue.toLowerCase())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ return true;
+ });
+ const newHighlightIndex = this.filteredOptions.findIndex(v => v === currentHighlight);
+ this.cursor = newHighlightIndex < 0 ? 0 : newHighlightIndex;
+ this.render();
+ }
+
+ handleSpaceToggle() {
+ const v = this.filteredOptions[this.cursor];
+
+ if (v.selected) {
+ v.selected = false;
+ this.render();
+ } else if (v.disabled || this.value.filter(e => e.selected).length >= this.maxChoices) {
+ return this.bell();
+ } else {
+ v.selected = true;
+ this.render();
+ }
+ }
+
+ handleInputChange(c) {
+ this.inputValue = this.inputValue + c;
+ this.updateFilteredOptions();
+ }
+
+ _(c, key) {
+ if (c === ' ') {
+ this.handleSpaceToggle();
+ } else {
+ this.handleInputChange(c);
+ }
+ }
+
+ renderInstructions() {
+ if (this.instructions === undefined || this.instructions) {
+ if (typeof this.instructions === 'string') {
+ return this.instructions;
+ }
+
+ return `
+Instructions:
+ ${figures.arrowUp}/${figures.arrowDown}: Highlight option
+ ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection
+ [a,b,c]/delete: Filter choices
+ enter/return: Complete answer
+`;
+ }
+
+ return '';
+ }
+
+ renderCurrentInput() {
+ return `
+Filtered results for: ${this.inputValue ? this.inputValue : color.gray('Enter something to filter')}\n`;
+ }
+
+ renderOption(cursor, v, i) {
+ let title;
+ if (v.disabled) title = cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);else title = cursor === i ? color.cyan().underline(v.title) : v.title;
+ return (v.selected ? color.green(figures.radioOn) : figures.radioOff) + ' ' + title;
+ }
+
+ renderDoneOrInstructions() {
+ if (this.done) {
+ return this.value.filter(e => e.selected).map(v => v.title).join(', ');
+ }
+
+ const output = [color.gray(this.hint), this.renderInstructions(), this.renderCurrentInput()];
+
+ if (this.filteredOptions.length && this.filteredOptions[this.cursor].disabled) {
+ output.push(color.yellow(this.warn));
+ }
+
+ return output.join(' ');
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ super.render(); // print prompt
+
+ let prompt = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.renderDoneOrInstructions()].join(' ');
+
+ if (this.showMinError) {
+ prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
+ this.showMinError = false;
+ }
+
+ prompt += this.renderOptions(this.filteredOptions);
+ this.out.write(this.clear + prompt);
+ this.clear = clear(prompt, this.out.columns);
+ }
+
+}
+
+module.exports = AutocompleteMultiselectPrompt;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/elements/confirm.js b/node_modules/prompts/dist/elements/confirm.js
new file mode 100644
index 0000000..6c342d2
--- /dev/null
+++ b/node_modules/prompts/dist/elements/confirm.js
@@ -0,0 +1,93 @@
+"use strict";
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('../util'),
+ style = _require.style,
+ clear = _require.clear;
+
+const _require2 = require('sisteransi'),
+ erase = _require2.erase,
+ cursor = _require2.cursor;
+/**
+ * ConfirmPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Boolean} [opts.initial] Default value (true/false)
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.yes] The "Yes" label
+ * @param {String} [opts.yesOption] The "Yes" option when choosing between yes/no
+ * @param {String} [opts.no] The "No" label
+ * @param {String} [opts.noOption] The "No" option when choosing between yes/no
+ */
+
+
+class ConfirmPrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.msg = opts.message;
+ this.value = opts.initial;
+ this.initialValue = !!opts.initial;
+ this.yesMsg = opts.yes || 'yes';
+ this.yesOption = opts.yesOption || '(Y/n)';
+ this.noMsg = opts.no || 'no';
+ this.noOption = opts.noOption || '(y/N)';
+ this.render();
+ }
+
+ reset() {
+ this.value = this.initialValue;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ this.value = this.value || false;
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ _(c, key) {
+ if (c.toLowerCase() === 'y') {
+ this.value = true;
+ return this.submit();
+ }
+
+ if (c.toLowerCase() === 'n') {
+ this.value = false;
+ return this.submit();
+ }
+
+ return this.bell();
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+ this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), this.done ? this.value ? this.yesMsg : this.noMsg : color.gray(this.initialValue ? this.yesOption : this.noOption)].join(' ');
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+
+}
+
+module.exports = ConfirmPrompt;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/elements/date.js b/node_modules/prompts/dist/elements/date.js
new file mode 100644
index 0000000..0b254f8
--- /dev/null
+++ b/node_modules/prompts/dist/elements/date.js
@@ -0,0 +1,250 @@
+'use strict';
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('../util'),
+ style = _require.style,
+ clear = _require.clear,
+ figures = _require.figures;
+
+const _require2 = require('sisteransi'),
+ erase = _require2.erase,
+ cursor = _require2.cursor;
+
+const _require3 = require('../dateparts'),
+ DatePart = _require3.DatePart,
+ Meridiem = _require3.Meridiem,
+ Day = _require3.Day,
+ Hours = _require3.Hours,
+ Milliseconds = _require3.Milliseconds,
+ Minutes = _require3.Minutes,
+ Month = _require3.Month,
+ Seconds = _require3.Seconds,
+ Year = _require3.Year;
+
+const regex = /\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g;
+const regexGroups = {
+ 1: ({
+ token
+ }) => token.replace(/\\(.)/g, '$1'),
+ 2: opts => new Day(opts),
+ // Day // TODO
+ 3: opts => new Month(opts),
+ // Month
+ 4: opts => new Year(opts),
+ // Year
+ 5: opts => new Meridiem(opts),
+ // AM/PM // TODO (special)
+ 6: opts => new Hours(opts),
+ // Hours
+ 7: opts => new Minutes(opts),
+ // Minutes
+ 8: opts => new Seconds(opts),
+ // Seconds
+ 9: opts => new Milliseconds(opts) // Fractional seconds
+
+};
+const dfltLocales = {
+ months: 'January,February,March,April,May,June,July,August,September,October,November,December'.split(','),
+ monthsShort: 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(','),
+ weekdays: 'Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday'.split(','),
+ weekdaysShort: 'Sun,Mon,Tue,Wed,Thu,Fri,Sat'.split(',')
+};
+/**
+ * DatePrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Number} [opts.initial] Index of default value
+ * @param {String} [opts.mask] The format mask
+ * @param {object} [opts.locales] The date locales
+ * @param {String} [opts.error] The error message shown on invalid value
+ * @param {Function} [opts.validate] Function to validate the submitted value
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+
+class DatePrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.msg = opts.message;
+ this.cursor = 0;
+ this.typed = '';
+ this.locales = Object.assign(dfltLocales, opts.locales);
+ this._date = opts.initial || new Date();
+ this.errorMsg = opts.error || 'Please Enter A Valid Value';
+
+ this.validator = opts.validate || (() => true);
+
+ this.mask = opts.mask || 'YYYY-MM-DD HH:mm:ss';
+ this.clear = clear('', this.out.columns);
+ this.render();
+ }
+
+ get value() {
+ return this.date;
+ }
+
+ get date() {
+ return this._date;
+ }
+
+ set date(date) {
+ if (date) this._date.setTime(date.getTime());
+ }
+
+ set mask(mask) {
+ let result;
+ this.parts = [];
+
+ while (result = regex.exec(mask)) {
+ let match = result.shift();
+ let idx = result.findIndex(gr => gr != null);
+ this.parts.push(idx in regexGroups ? regexGroups[idx]({
+ token: result[idx] || match,
+ date: this.date,
+ parts: this.parts,
+ locales: this.locales
+ }) : result[idx] || match);
+ }
+
+ let parts = this.parts.reduce((arr, i) => {
+ if (typeof i === 'string' && typeof arr[arr.length - 1] === 'string') arr[arr.length - 1] += i;else arr.push(i);
+ return arr;
+ }, []);
+ this.parts.splice(0);
+ this.parts.push(...parts);
+ this.reset();
+ }
+
+ moveCursor(n) {
+ this.typed = '';
+ this.cursor = n;
+ this.fire();
+ }
+
+ reset() {
+ this.moveCursor(this.parts.findIndex(p => p instanceof DatePart));
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.error = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ validate() {
+ var _this = this;
+
+ return _asyncToGenerator(function* () {
+ let valid = yield _this.validator(_this.value);
+
+ if (typeof valid === 'string') {
+ _this.errorMsg = valid;
+ valid = false;
+ }
+
+ _this.error = !valid;
+ })();
+ }
+
+ submit() {
+ var _this2 = this;
+
+ return _asyncToGenerator(function* () {
+ yield _this2.validate();
+
+ if (_this2.error) {
+ _this2.color = 'red';
+
+ _this2.fire();
+
+ _this2.render();
+
+ return;
+ }
+
+ _this2.done = true;
+ _this2.aborted = false;
+
+ _this2.fire();
+
+ _this2.render();
+
+ _this2.out.write('\n');
+
+ _this2.close();
+ })();
+ }
+
+ up() {
+ this.typed = '';
+ this.parts[this.cursor].up();
+ this.render();
+ }
+
+ down() {
+ this.typed = '';
+ this.parts[this.cursor].down();
+ this.render();
+ }
+
+ left() {
+ let prev = this.parts[this.cursor].prev();
+ if (prev == null) return this.bell();
+ this.moveCursor(this.parts.indexOf(prev));
+ this.render();
+ }
+
+ right() {
+ let next = this.parts[this.cursor].next();
+ if (next == null) return this.bell();
+ this.moveCursor(this.parts.indexOf(next));
+ this.render();
+ }
+
+ next() {
+ let next = this.parts[this.cursor].next();
+ this.moveCursor(next ? this.parts.indexOf(next) : this.parts.findIndex(part => part instanceof DatePart));
+ this.render();
+ }
+
+ _(c) {
+ if (/\d/.test(c)) {
+ this.typed += c;
+ this.parts[this.cursor].setTo(this.typed);
+ this.render();
+ }
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);else this.out.write(clear(this.outputText, this.out.columns));
+ super.render(); // Print prompt
+
+ this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.parts.reduce((arr, p, idx) => arr.concat(idx === this.cursor && !this.done ? color.cyan().underline(p.toString()) : p), []).join('')].join(' '); // Print error
+
+ if (this.error) {
+ this.outputText += this.errorMsg.split('\n').reduce((a, l, i) => a + `\n${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+
+}
+
+module.exports = DatePrompt;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/elements/index.js b/node_modules/prompts/dist/elements/index.js
new file mode 100644
index 0000000..cf0ccc1
--- /dev/null
+++ b/node_modules/prompts/dist/elements/index.js
@@ -0,0 +1,13 @@
+'use strict';
+
+module.exports = {
+ TextPrompt: require('./text'),
+ SelectPrompt: require('./select'),
+ TogglePrompt: require('./toggle'),
+ DatePrompt: require('./date'),
+ NumberPrompt: require('./number'),
+ MultiselectPrompt: require('./multiselect'),
+ AutocompletePrompt: require('./autocomplete'),
+ AutocompleteMultiselectPrompt: require('./autocompleteMultiselect'),
+ ConfirmPrompt: require('./confirm')
+};
\ No newline at end of file
diff --git a/node_modules/prompts/dist/elements/multiselect.js b/node_modules/prompts/dist/elements/multiselect.js
new file mode 100644
index 0000000..2d129ea
--- /dev/null
+++ b/node_modules/prompts/dist/elements/multiselect.js
@@ -0,0 +1,289 @@
+'use strict';
+
+const color = require('kleur');
+
+const _require = require('sisteransi'),
+ cursor = _require.cursor;
+
+const Prompt = require('./prompt');
+
+const _require2 = require('../util'),
+ clear = _require2.clear,
+ figures = _require2.figures,
+ style = _require2.style,
+ wrap = _require2.wrap,
+ entriesToDisplay = _require2.entriesToDisplay;
+/**
+ * MultiselectPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of choice objects
+ * @param {String} [opts.hint] Hint to display
+ * @param {String} [opts.warn] Hint shown for disabled choices
+ * @param {Number} [opts.max] Max choices
+ * @param {Number} [opts.cursor=0] Cursor start position
+ * @param {Number} [opts.optionsPerPage=10] Max options to display at once
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+
+
+class MultiselectPrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.msg = opts.message;
+ this.cursor = opts.cursor || 0;
+ this.scrollIndex = opts.cursor || 0;
+ this.hint = opts.hint || '';
+ this.warn = opts.warn || '- This option is disabled -';
+ this.minSelected = opts.min;
+ this.showMinError = false;
+ this.maxChoices = opts.max;
+ this.instructions = opts.instructions;
+ this.optionsPerPage = opts.optionsPerPage || 10;
+ this.value = opts.choices.map((ch, idx) => {
+ if (typeof ch === 'string') ch = {
+ title: ch,
+ value: idx
+ };
+ return {
+ title: ch && (ch.title || ch.value || ch),
+ description: ch && ch.description,
+ value: ch && (ch.value === undefined ? idx : ch.value),
+ selected: ch && ch.selected,
+ disabled: ch && ch.disabled
+ };
+ });
+ this.clear = clear('', this.out.columns);
+
+ if (!opts.overrideRender) {
+ this.render();
+ }
+ }
+
+ reset() {
+ this.value.map(v => !v.selected);
+ this.cursor = 0;
+ this.fire();
+ this.render();
+ }
+
+ selected() {
+ return this.value.filter(v => v.selected);
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ const selected = this.value.filter(e => e.selected);
+
+ if (this.minSelected && selected.length < this.minSelected) {
+ this.showMinError = true;
+ this.render();
+ } else {
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+ }
+
+ first() {
+ this.cursor = 0;
+ this.render();
+ }
+
+ last() {
+ this.cursor = this.value.length - 1;
+ this.render();
+ }
+
+ next() {
+ this.cursor = (this.cursor + 1) % this.value.length;
+ this.render();
+ }
+
+ up() {
+ if (this.cursor === 0) {
+ this.cursor = this.value.length - 1;
+ } else {
+ this.cursor--;
+ }
+
+ this.render();
+ }
+
+ down() {
+ if (this.cursor === this.value.length - 1) {
+ this.cursor = 0;
+ } else {
+ this.cursor++;
+ }
+
+ this.render();
+ }
+
+ left() {
+ this.value[this.cursor].selected = false;
+ this.render();
+ }
+
+ right() {
+ if (this.value.filter(e => e.selected).length >= this.maxChoices) return this.bell();
+ this.value[this.cursor].selected = true;
+ this.render();
+ }
+
+ handleSpaceToggle() {
+ const v = this.value[this.cursor];
+
+ if (v.selected) {
+ v.selected = false;
+ this.render();
+ } else if (v.disabled || this.value.filter(e => e.selected).length >= this.maxChoices) {
+ return this.bell();
+ } else {
+ v.selected = true;
+ this.render();
+ }
+ }
+
+ toggleAll() {
+ if (this.maxChoices !== undefined || this.value[this.cursor].disabled) {
+ return this.bell();
+ }
+
+ const newSelected = !this.value[this.cursor].selected;
+ this.value.filter(v => !v.disabled).forEach(v => v.selected = newSelected);
+ this.render();
+ }
+
+ _(c, key) {
+ if (c === ' ') {
+ this.handleSpaceToggle();
+ } else if (c === 'a') {
+ this.toggleAll();
+ } else {
+ return this.bell();
+ }
+ }
+
+ renderInstructions() {
+ if (this.instructions === undefined || this.instructions) {
+ if (typeof this.instructions === 'string') {
+ return this.instructions;
+ }
+
+ return '\nInstructions:\n' + ` ${figures.arrowUp}/${figures.arrowDown}: Highlight option\n` + ` ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection\n` + (this.maxChoices === undefined ? ` a: Toggle all\n` : '') + ` enter/return: Complete answer`;
+ }
+
+ return '';
+ }
+
+ renderOption(cursor, v, i, arrowIndicator) {
+ const prefix = (v.selected ? color.green(figures.radioOn) : figures.radioOff) + ' ' + arrowIndicator + ' ';
+ let title, desc;
+
+ if (v.disabled) {
+ title = cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
+ } else {
+ title = cursor === i ? color.cyan().underline(v.title) : v.title;
+
+ if (cursor === i && v.description) {
+ desc = ` - ${v.description}`;
+
+ if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
+ desc = '\n' + wrap(v.description, {
+ margin: prefix.length,
+ width: this.out.columns
+ });
+ }
+ }
+ }
+
+ return prefix + title + color.gray(desc || '');
+ } // shared with autocompleteMultiselect
+
+
+ paginateOptions(options) {
+ if (options.length === 0) {
+ return color.red('No matches for this query.');
+ }
+
+ let _entriesToDisplay = entriesToDisplay(this.cursor, options.length, this.optionsPerPage),
+ startIndex = _entriesToDisplay.startIndex,
+ endIndex = _entriesToDisplay.endIndex;
+
+ let prefix,
+ styledOptions = [];
+
+ for (let i = startIndex; i < endIndex; i++) {
+ if (i === startIndex && startIndex > 0) {
+ prefix = figures.arrowUp;
+ } else if (i === endIndex - 1 && endIndex < options.length) {
+ prefix = figures.arrowDown;
+ } else {
+ prefix = ' ';
+ }
+
+ styledOptions.push(this.renderOption(this.cursor, options[i], i, prefix));
+ }
+
+ return '\n' + styledOptions.join('\n');
+ } // shared with autocomleteMultiselect
+
+
+ renderOptions(options) {
+ if (!this.done) {
+ return this.paginateOptions(options);
+ }
+
+ return '';
+ }
+
+ renderDoneOrInstructions() {
+ if (this.done) {
+ return this.value.filter(e => e.selected).map(v => v.title).join(', ');
+ }
+
+ const output = [color.gray(this.hint), this.renderInstructions()];
+
+ if (this.value[this.cursor].disabled) {
+ output.push(color.yellow(this.warn));
+ }
+
+ return output.join(' ');
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ super.render(); // print prompt
+
+ let prompt = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.renderDoneOrInstructions()].join(' ');
+
+ if (this.showMinError) {
+ prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
+ this.showMinError = false;
+ }
+
+ prompt += this.renderOptions(this.value);
+ this.out.write(this.clear + prompt);
+ this.clear = clear(prompt, this.out.columns);
+ }
+
+}
+
+module.exports = MultiselectPrompt;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/elements/number.js b/node_modules/prompts/dist/elements/number.js
new file mode 100644
index 0000000..fd144af
--- /dev/null
+++ b/node_modules/prompts/dist/elements/number.js
@@ -0,0 +1,250 @@
+"use strict";
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('sisteransi'),
+ cursor = _require.cursor,
+ erase = _require.erase;
+
+const _require2 = require('../util'),
+ style = _require2.style,
+ figures = _require2.figures,
+ clear = _require2.clear,
+ lines = _require2.lines;
+
+const isNumber = /[0-9]/;
+
+const isDef = any => any !== undefined;
+
+const round = (number, precision) => {
+ let factor = Math.pow(10, precision);
+ return Math.round(number * factor) / factor;
+};
+/**
+ * NumberPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {String} [opts.style='default'] Render style
+ * @param {Number} [opts.initial] Default value
+ * @param {Number} [opts.max=+Infinity] Max value
+ * @param {Number} [opts.min=-Infinity] Min value
+ * @param {Boolean} [opts.float=false] Parse input as floats
+ * @param {Number} [opts.round=2] Round floats to x decimals
+ * @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
+ * @param {Function} [opts.validate] Validate function
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.error] The invalid error label
+ */
+
+
+class NumberPrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.transform = style.render(opts.style);
+ this.msg = opts.message;
+ this.initial = isDef(opts.initial) ? opts.initial : '';
+ this.float = !!opts.float;
+ this.round = opts.round || 2;
+ this.inc = opts.increment || 1;
+ this.min = isDef(opts.min) ? opts.min : -Infinity;
+ this.max = isDef(opts.max) ? opts.max : Infinity;
+ this.errorMsg = opts.error || `Please Enter A Valid Value`;
+
+ this.validator = opts.validate || (() => true);
+
+ this.color = `cyan`;
+ this.value = ``;
+ this.typed = ``;
+ this.lastHit = 0;
+ this.render();
+ }
+
+ set value(v) {
+ if (!v && v !== 0) {
+ this.placeholder = true;
+ this.rendered = color.gray(this.transform.render(`${this.initial}`));
+ this._value = ``;
+ } else {
+ this.placeholder = false;
+ this.rendered = this.transform.render(`${round(v, this.round)}`);
+ this._value = round(v, this.round);
+ }
+
+ this.fire();
+ }
+
+ get value() {
+ return this._value;
+ }
+
+ parse(x) {
+ return this.float ? parseFloat(x) : parseInt(x);
+ }
+
+ valid(c) {
+ return c === `-` || c === `.` && this.float || isNumber.test(c);
+ }
+
+ reset() {
+ this.typed = ``;
+ this.value = ``;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ let x = this.value;
+ this.value = x !== `` ? x : this.initial;
+ this.done = this.aborted = true;
+ this.error = false;
+ this.fire();
+ this.render();
+ this.out.write(`\n`);
+ this.close();
+ }
+
+ validate() {
+ var _this = this;
+
+ return _asyncToGenerator(function* () {
+ let valid = yield _this.validator(_this.value);
+
+ if (typeof valid === `string`) {
+ _this.errorMsg = valid;
+ valid = false;
+ }
+
+ _this.error = !valid;
+ })();
+ }
+
+ submit() {
+ var _this2 = this;
+
+ return _asyncToGenerator(function* () {
+ yield _this2.validate();
+
+ if (_this2.error) {
+ _this2.color = `red`;
+
+ _this2.fire();
+
+ _this2.render();
+
+ return;
+ }
+
+ let x = _this2.value;
+ _this2.value = x !== `` ? x : _this2.initial;
+ _this2.done = true;
+ _this2.aborted = false;
+ _this2.error = false;
+
+ _this2.fire();
+
+ _this2.render();
+
+ _this2.out.write(`\n`);
+
+ _this2.close();
+ })();
+ }
+
+ up() {
+ this.typed = ``;
+
+ if (this.value === '') {
+ this.value = this.min - this.inc;
+ }
+
+ if (this.value >= this.max) return this.bell();
+ this.value += this.inc;
+ this.color = `cyan`;
+ this.fire();
+ this.render();
+ }
+
+ down() {
+ this.typed = ``;
+
+ if (this.value === '') {
+ this.value = this.min + this.inc;
+ }
+
+ if (this.value <= this.min) return this.bell();
+ this.value -= this.inc;
+ this.color = `cyan`;
+ this.fire();
+ this.render();
+ }
+
+ delete() {
+ let val = this.value.toString();
+ if (val.length === 0) return this.bell();
+ this.value = this.parse(val = val.slice(0, -1)) || ``;
+
+ if (this.value !== '' && this.value < this.min) {
+ this.value = this.min;
+ }
+
+ this.color = `cyan`;
+ this.fire();
+ this.render();
+ }
+
+ next() {
+ this.value = this.initial;
+ this.fire();
+ this.render();
+ }
+
+ _(c, key) {
+ if (!this.valid(c)) return this.bell();
+ const now = Date.now();
+ if (now - this.lastHit > 1000) this.typed = ``; // 1s elapsed
+
+ this.typed += c;
+ this.lastHit = now;
+ this.color = `cyan`;
+ if (c === `.`) return this.fire();
+ this.value = Math.min(this.parse(this.typed), this.max);
+ if (this.value > this.max) this.value = this.max;
+ if (this.value < this.min) this.value = this.min;
+ this.fire();
+ this.render();
+ }
+
+ render() {
+ if (this.closed) return;
+
+ if (!this.firstRender) {
+ if (this.outputError) this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
+ this.out.write(clear(this.outputText, this.out.columns));
+ }
+
+ super.render();
+ this.outputError = ''; // Print prompt
+
+ this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), !this.done || !this.done && !this.placeholder ? color[this.color]().underline(this.rendered) : this.rendered].join(` `); // Print error
+
+ if (this.error) {
+ this.outputError += this.errorMsg.split(`\n`).reduce((a, l, i) => a + `\n${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore);
+ }
+
+}
+
+module.exports = NumberPrompt;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/elements/prompt.js b/node_modules/prompts/dist/elements/prompt.js
new file mode 100644
index 0000000..7deef04
--- /dev/null
+++ b/node_modules/prompts/dist/elements/prompt.js
@@ -0,0 +1,82 @@
+'use strict';
+
+const readline = require('readline');
+
+const _require = require('../util'),
+ action = _require.action;
+
+const EventEmitter = require('events');
+
+const _require2 = require('sisteransi'),
+ beep = _require2.beep,
+ cursor = _require2.cursor;
+
+const color = require('kleur');
+/**
+ * Base prompt skeleton
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+
+
+class Prompt extends EventEmitter {
+ constructor(opts = {}) {
+ super();
+ this.firstRender = true;
+ this.in = opts.stdin || process.stdin;
+ this.out = opts.stdout || process.stdout;
+
+ this.onRender = (opts.onRender || (() => void 0)).bind(this);
+
+ const rl = readline.createInterface({
+ input: this.in,
+ escapeCodeTimeout: 50
+ });
+ readline.emitKeypressEvents(this.in, rl);
+ if (this.in.isTTY) this.in.setRawMode(true);
+ const isSelect = ['SelectPrompt', 'MultiselectPrompt'].indexOf(this.constructor.name) > -1;
+
+ const keypress = (str, key) => {
+ let a = action(key, isSelect);
+
+ if (a === false) {
+ this._ && this._(str, key);
+ } else if (typeof this[a] === 'function') {
+ this[a](key);
+ } else {
+ this.bell();
+ }
+ };
+
+ this.close = () => {
+ this.out.write(cursor.show);
+ this.in.removeListener('keypress', keypress);
+ if (this.in.isTTY) this.in.setRawMode(false);
+ rl.close();
+ this.emit(this.aborted ? 'abort' : this.exited ? 'exit' : 'submit', this.value);
+ this.closed = true;
+ };
+
+ this.in.on('keypress', keypress);
+ }
+
+ fire() {
+ this.emit('state', {
+ value: this.value,
+ aborted: !!this.aborted,
+ exited: !!this.exited
+ });
+ }
+
+ bell() {
+ this.out.write(beep);
+ }
+
+ render() {
+ this.onRender(color);
+ if (this.firstRender) this.firstRender = false;
+ }
+
+}
+
+module.exports = Prompt;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/elements/select.js b/node_modules/prompts/dist/elements/select.js
new file mode 100644
index 0000000..5e27c69
--- /dev/null
+++ b/node_modules/prompts/dist/elements/select.js
@@ -0,0 +1,190 @@
+'use strict';
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('../util'),
+ style = _require.style,
+ clear = _require.clear,
+ figures = _require.figures,
+ wrap = _require.wrap,
+ entriesToDisplay = _require.entriesToDisplay;
+
+const _require2 = require('sisteransi'),
+ cursor = _require2.cursor;
+/**
+ * SelectPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of choice objects
+ * @param {String} [opts.hint] Hint to display
+ * @param {Number} [opts.initial] Index of default value
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {Number} [opts.optionsPerPage=10] Max options to display at once
+ */
+
+
+class SelectPrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.msg = opts.message;
+ this.hint = opts.hint || '- Use arrow-keys. Return to submit.';
+ this.warn = opts.warn || '- This option is disabled';
+ this.cursor = opts.initial || 0;
+ this.choices = opts.choices.map((ch, idx) => {
+ if (typeof ch === 'string') ch = {
+ title: ch,
+ value: idx
+ };
+ return {
+ title: ch && (ch.title || ch.value || ch),
+ value: ch && (ch.value === undefined ? idx : ch.value),
+ description: ch && ch.description,
+ selected: ch && ch.selected,
+ disabled: ch && ch.disabled
+ };
+ });
+ this.optionsPerPage = opts.optionsPerPage || 10;
+ this.value = (this.choices[this.cursor] || {}).value;
+ this.clear = clear('', this.out.columns);
+ this.render();
+ }
+
+ moveCursor(n) {
+ this.cursor = n;
+ this.value = this.choices[n].value;
+ this.fire();
+ }
+
+ reset() {
+ this.moveCursor(0);
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ if (!this.selection.disabled) {
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ } else this.bell();
+ }
+
+ first() {
+ this.moveCursor(0);
+ this.render();
+ }
+
+ last() {
+ this.moveCursor(this.choices.length - 1);
+ this.render();
+ }
+
+ up() {
+ if (this.cursor === 0) {
+ this.moveCursor(this.choices.length - 1);
+ } else {
+ this.moveCursor(this.cursor - 1);
+ }
+
+ this.render();
+ }
+
+ down() {
+ if (this.cursor === this.choices.length - 1) {
+ this.moveCursor(0);
+ } else {
+ this.moveCursor(this.cursor + 1);
+ }
+
+ this.render();
+ }
+
+ next() {
+ this.moveCursor((this.cursor + 1) % this.choices.length);
+ this.render();
+ }
+
+ _(c, key) {
+ if (c === ' ') return this.submit();
+ }
+
+ get selection() {
+ return this.choices[this.cursor];
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ let _entriesToDisplay = entriesToDisplay(this.cursor, this.choices.length, this.optionsPerPage),
+ startIndex = _entriesToDisplay.startIndex,
+ endIndex = _entriesToDisplay.endIndex; // Print prompt
+
+
+ this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(false), this.done ? this.selection.title : this.selection.disabled ? color.yellow(this.warn) : color.gray(this.hint)].join(' '); // Print choices
+
+ if (!this.done) {
+ this.outputText += '\n';
+
+ for (let i = startIndex; i < endIndex; i++) {
+ let title,
+ prefix,
+ desc = '',
+ v = this.choices[i]; // Determine whether to display "more choices" indicators
+
+ if (i === startIndex && startIndex > 0) {
+ prefix = figures.arrowUp;
+ } else if (i === endIndex - 1 && endIndex < this.choices.length) {
+ prefix = figures.arrowDown;
+ } else {
+ prefix = ' ';
+ }
+
+ if (v.disabled) {
+ title = this.cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
+ prefix = (this.cursor === i ? color.bold().gray(figures.pointer) + ' ' : ' ') + prefix;
+ } else {
+ title = this.cursor === i ? color.cyan().underline(v.title) : v.title;
+ prefix = (this.cursor === i ? color.cyan(figures.pointer) + ' ' : ' ') + prefix;
+
+ if (v.description && this.cursor === i) {
+ desc = ` - ${v.description}`;
+
+ if (prefix.length + title.length + desc.length >= this.out.columns || v.description.split(/\r?\n/).length > 1) {
+ desc = '\n' + wrap(v.description, {
+ margin: 3,
+ width: this.out.columns
+ });
+ }
+ }
+ }
+
+ this.outputText += `${prefix} ${title}${color.gray(desc)}\n`;
+ }
+ }
+
+ this.out.write(this.outputText);
+ }
+
+}
+
+module.exports = SelectPrompt;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/elements/text.js b/node_modules/prompts/dist/elements/text.js
new file mode 100644
index 0000000..c38a070
--- /dev/null
+++ b/node_modules/prompts/dist/elements/text.js
@@ -0,0 +1,245 @@
+"use strict";
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('sisteransi'),
+ erase = _require.erase,
+ cursor = _require.cursor;
+
+const _require2 = require('../util'),
+ style = _require2.style,
+ clear = _require2.clear,
+ lines = _require2.lines,
+ figures = _require2.figures;
+/**
+ * TextPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {String} [opts.style='default'] Render style
+ * @param {String} [opts.initial] Default value
+ * @param {Function} [opts.validate] Validate function
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.error] The invalid error label
+ */
+
+
+class TextPrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.transform = style.render(opts.style);
+ this.scale = this.transform.scale;
+ this.msg = opts.message;
+ this.initial = opts.initial || ``;
+
+ this.validator = opts.validate || (() => true);
+
+ this.value = ``;
+ this.errorMsg = opts.error || `Please Enter A Valid Value`;
+ this.cursor = Number(!!this.initial);
+ this.cursorOffset = 0;
+ this.clear = clear(``, this.out.columns);
+ this.render();
+ }
+
+ set value(v) {
+ if (!v && this.initial) {
+ this.placeholder = true;
+ this.rendered = color.gray(this.transform.render(this.initial));
+ } else {
+ this.placeholder = false;
+ this.rendered = this.transform.render(v);
+ }
+
+ this._value = v;
+ this.fire();
+ }
+
+ get value() {
+ return this._value;
+ }
+
+ reset() {
+ this.value = ``;
+ this.cursor = Number(!!this.initial);
+ this.cursorOffset = 0;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.value = this.value || this.initial;
+ this.done = this.aborted = true;
+ this.error = false;
+ this.red = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ validate() {
+ var _this = this;
+
+ return _asyncToGenerator(function* () {
+ let valid = yield _this.validator(_this.value);
+
+ if (typeof valid === `string`) {
+ _this.errorMsg = valid;
+ valid = false;
+ }
+
+ _this.error = !valid;
+ })();
+ }
+
+ submit() {
+ var _this2 = this;
+
+ return _asyncToGenerator(function* () {
+ _this2.value = _this2.value || _this2.initial;
+ _this2.cursorOffset = 0;
+ _this2.cursor = _this2.rendered.length;
+ yield _this2.validate();
+
+ if (_this2.error) {
+ _this2.red = true;
+
+ _this2.fire();
+
+ _this2.render();
+
+ return;
+ }
+
+ _this2.done = true;
+ _this2.aborted = false;
+
+ _this2.fire();
+
+ _this2.render();
+
+ _this2.out.write('\n');
+
+ _this2.close();
+ })();
+ }
+
+ next() {
+ if (!this.placeholder) return this.bell();
+ this.value = this.initial;
+ this.cursor = this.rendered.length;
+ this.fire();
+ this.render();
+ }
+
+ moveCursor(n) {
+ if (this.placeholder) return;
+ this.cursor = this.cursor + n;
+ this.cursorOffset += n;
+ }
+
+ _(c, key) {
+ let s1 = this.value.slice(0, this.cursor);
+ let s2 = this.value.slice(this.cursor);
+ this.value = `${s1}${c}${s2}`;
+ this.red = false;
+ this.cursor = this.placeholder ? 0 : s1.length + 1;
+ this.render();
+ }
+
+ delete() {
+ if (this.isCursorAtStart()) return this.bell();
+ let s1 = this.value.slice(0, this.cursor - 1);
+ let s2 = this.value.slice(this.cursor);
+ this.value = `${s1}${s2}`;
+ this.red = false;
+
+ if (this.isCursorAtStart()) {
+ this.cursorOffset = 0;
+ } else {
+ this.cursorOffset++;
+ this.moveCursor(-1);
+ }
+
+ this.render();
+ }
+
+ deleteForward() {
+ if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell();
+ let s1 = this.value.slice(0, this.cursor);
+ let s2 = this.value.slice(this.cursor + 1);
+ this.value = `${s1}${s2}`;
+ this.red = false;
+
+ if (this.isCursorAtEnd()) {
+ this.cursorOffset = 0;
+ } else {
+ this.cursorOffset++;
+ }
+
+ this.render();
+ }
+
+ first() {
+ this.cursor = 0;
+ this.render();
+ }
+
+ last() {
+ this.cursor = this.value.length;
+ this.render();
+ }
+
+ left() {
+ if (this.cursor <= 0 || this.placeholder) return this.bell();
+ this.moveCursor(-1);
+ this.render();
+ }
+
+ right() {
+ if (this.cursor * this.scale >= this.rendered.length || this.placeholder) return this.bell();
+ this.moveCursor(1);
+ this.render();
+ }
+
+ isCursorAtStart() {
+ return this.cursor === 0 || this.placeholder && this.cursor === 1;
+ }
+
+ isCursorAtEnd() {
+ return this.cursor === this.rendered.length || this.placeholder && this.cursor === this.rendered.length + 1;
+ }
+
+ render() {
+ if (this.closed) return;
+
+ if (!this.firstRender) {
+ if (this.outputError) this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
+ this.out.write(clear(this.outputText, this.out.columns));
+ }
+
+ super.render();
+ this.outputError = '';
+ this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), this.red ? color.red(this.rendered) : this.rendered].join(` `);
+
+ if (this.error) {
+ this.outputError += this.errorMsg.split(`\n`).reduce((a, l, i) => a + `\n${i ? ' ' : figures.pointerSmall} ${color.red().italic(l)}`, ``);
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore + cursor.move(this.cursorOffset, 0));
+ }
+
+}
+
+module.exports = TextPrompt;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/elements/toggle.js b/node_modules/prompts/dist/elements/toggle.js
new file mode 100644
index 0000000..d942f60
--- /dev/null
+++ b/node_modules/prompts/dist/elements/toggle.js
@@ -0,0 +1,124 @@
+"use strict";
+
+const color = require('kleur');
+
+const Prompt = require('./prompt');
+
+const _require = require('../util'),
+ style = _require.style,
+ clear = _require.clear;
+
+const _require2 = require('sisteransi'),
+ cursor = _require2.cursor,
+ erase = _require2.erase;
+/**
+ * TogglePrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Boolean} [opts.initial=false] Default value
+ * @param {String} [opts.active='no'] Active label
+ * @param {String} [opts.inactive='off'] Inactive label
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+
+
+class TogglePrompt extends Prompt {
+ constructor(opts = {}) {
+ super(opts);
+ this.msg = opts.message;
+ this.value = !!opts.initial;
+ this.active = opts.active || 'on';
+ this.inactive = opts.inactive || 'off';
+ this.initialValue = this.value;
+ this.render();
+ }
+
+ reset() {
+ this.value = this.initialValue;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ deactivate() {
+ if (this.value === false) return this.bell();
+ this.value = false;
+ this.render();
+ }
+
+ activate() {
+ if (this.value === true) return this.bell();
+ this.value = true;
+ this.render();
+ }
+
+ delete() {
+ this.deactivate();
+ }
+
+ left() {
+ this.deactivate();
+ }
+
+ right() {
+ this.activate();
+ }
+
+ down() {
+ this.deactivate();
+ }
+
+ up() {
+ this.activate();
+ }
+
+ next() {
+ this.value = !this.value;
+ this.fire();
+ this.render();
+ }
+
+ _(c, key) {
+ if (c === ' ') {
+ this.value = !this.value;
+ } else if (c === '1') {
+ this.value = true;
+ } else if (c === '0') {
+ this.value = false;
+ } else return this.bell();
+
+ this.render();
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+ this.outputText = [style.symbol(this.done, this.aborted), color.bold(this.msg), style.delimiter(this.done), this.value ? this.inactive : color.cyan().underline(this.inactive), color.gray('/'), this.value ? color.cyan().underline(this.active) : this.active].join(' ');
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+
+}
+
+module.exports = TogglePrompt;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/index.js b/node_modules/prompts/dist/index.js
new file mode 100644
index 0000000..f30e9e7
--- /dev/null
+++ b/node_modules/prompts/dist/index.js
@@ -0,0 +1,154 @@
+'use strict';
+
+function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
+
+function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
+
+function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+
+function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+
+const prompts = require('./prompts');
+
+const passOn = ['suggest', 'format', 'onState', 'validate', 'onRender', 'type'];
+
+const noop = () => {};
+/**
+ * Prompt for a series of questions
+ * @param {Array|Object} questions Single question object or Array of question objects
+ * @param {Function} [onSubmit] Callback function called on prompt submit
+ * @param {Function} [onCancel] Callback function called on cancel/abort
+ * @returns {Object} Object with values from user input
+ */
+
+
+function prompt() {
+ return _prompt.apply(this, arguments);
+}
+
+function _prompt() {
+ _prompt = _asyncToGenerator(function* (questions = [], {
+ onSubmit = noop,
+ onCancel = noop
+ } = {}) {
+ const answers = {};
+ const override = prompt._override || {};
+ questions = [].concat(questions);
+ let answer, question, quit, name, type, lastPrompt;
+
+ const getFormattedAnswer = /*#__PURE__*/function () {
+ var _ref = _asyncToGenerator(function* (question, answer, skipValidation = false) {
+ if (!skipValidation && question.validate && question.validate(answer) !== true) {
+ return;
+ }
+
+ return question.format ? yield question.format(answer, answers) : answer;
+ });
+
+ return function getFormattedAnswer(_x, _x2) {
+ return _ref.apply(this, arguments);
+ };
+ }();
+
+ var _iterator = _createForOfIteratorHelper(questions),
+ _step;
+
+ try {
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
+ question = _step.value;
+ var _question = question;
+ name = _question.name;
+ type = _question.type;
+
+ // evaluate type first and skip if type is a falsy value
+ if (typeof type === 'function') {
+ type = yield type(answer, _objectSpread({}, answers), question);
+ question['type'] = type;
+ }
+
+ if (!type) continue; // if property is a function, invoke it unless it's a special function
+
+ for (let key in question) {
+ if (passOn.includes(key)) continue;
+ let value = question[key];
+ question[key] = typeof value === 'function' ? yield value(answer, _objectSpread({}, answers), lastPrompt) : value;
+ }
+
+ lastPrompt = question;
+
+ if (typeof question.message !== 'string') {
+ throw new Error('prompt message is required');
+ } // update vars in case they changed
+
+
+ var _question2 = question;
+ name = _question2.name;
+ type = _question2.type;
+
+ if (prompts[type] === void 0) {
+ throw new Error(`prompt type (${type}) is not defined`);
+ }
+
+ if (override[question.name] !== undefined) {
+ answer = yield getFormattedAnswer(question, override[question.name]);
+
+ if (answer !== undefined) {
+ answers[name] = answer;
+ continue;
+ }
+ }
+
+ try {
+ // Get the injected answer if there is one or prompt the user
+ answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : yield prompts[type](question);
+ answers[name] = answer = yield getFormattedAnswer(question, answer, true);
+ quit = yield onSubmit(question, answer, answers);
+ } catch (err) {
+ quit = !(yield onCancel(question, answers));
+ }
+
+ if (quit) return answers;
+ }
+ } catch (err) {
+ _iterator.e(err);
+ } finally {
+ _iterator.f();
+ }
+
+ return answers;
+ });
+ return _prompt.apply(this, arguments);
+}
+
+function getInjectedAnswer(injected, deafultValue) {
+ const answer = injected.shift();
+
+ if (answer instanceof Error) {
+ throw answer;
+ }
+
+ return answer === undefined ? deafultValue : answer;
+}
+
+function inject(answers) {
+ prompt._injected = (prompt._injected || []).concat(answers);
+}
+
+function override(answers) {
+ prompt._override = Object.assign({}, answers);
+}
+
+module.exports = Object.assign(prompt, {
+ prompt,
+ prompts,
+ inject,
+ override
+});
\ No newline at end of file
diff --git a/node_modules/prompts/dist/prompts.js b/node_modules/prompts/dist/prompts.js
new file mode 100644
index 0000000..31f2648
--- /dev/null
+++ b/node_modules/prompts/dist/prompts.js
@@ -0,0 +1,222 @@
+'use strict';
+
+const $ = exports;
+
+const el = require('./elements');
+
+const noop = v => v;
+
+function toPrompt(type, args, opts = {}) {
+ return new Promise((res, rej) => {
+ const p = new el[type](args);
+ const onAbort = opts.onAbort || noop;
+ const onSubmit = opts.onSubmit || noop;
+ const onExit = opts.onExit || noop;
+ p.on('state', args.onState || noop);
+ p.on('submit', x => res(onSubmit(x)));
+ p.on('exit', x => res(onExit(x)));
+ p.on('abort', x => rej(onAbort(x)));
+ });
+}
+/**
+ * Text prompt
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {function} [args.onState] On state change callback
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.text = args => toPrompt('TextPrompt', args);
+/**
+ * Password prompt with masked input
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {function} [args.onState] On state change callback
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.password = args => {
+ args.style = 'password';
+ return $.text(args);
+};
+/**
+ * Prompt where input is invisible, like sudo
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {function} [args.onState] On state change callback
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.invisible = args => {
+ args.style = 'invisible';
+ return $.text(args);
+};
+/**
+ * Number prompt
+ * @param {string} args.message Prompt message to display
+ * @param {number} args.initial Default number value
+ * @param {function} [args.onState] On state change callback
+ * @param {number} [args.max] Max value
+ * @param {number} [args.min] Min value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {Boolean} [opts.float=false] Parse input as floats
+ * @param {Number} [opts.round=2] Round floats to x decimals
+ * @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.number = args => toPrompt('NumberPrompt', args);
+/**
+ * Date prompt
+ * @param {string} args.message Prompt message to display
+ * @param {number} args.initial Default number value
+ * @param {function} [args.onState] On state change callback
+ * @param {number} [args.max] Max value
+ * @param {number} [args.min] Min value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {Boolean} [opts.float=false] Parse input as floats
+ * @param {Number} [opts.round=2] Round floats to x decimals
+ * @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.date = args => toPrompt('DatePrompt', args);
+/**
+ * Classic yes/no prompt
+ * @param {string} args.message Prompt message to display
+ * @param {boolean} [args.initial=false] Default value
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.confirm = args => toPrompt('ConfirmPrompt', args);
+/**
+ * List prompt, split intput string by `seperator`
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {string} [args.separator] String separator
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input, in form of an `Array`
+ */
+
+
+$.list = args => {
+ const sep = args.separator || ',';
+ return toPrompt('TextPrompt', args, {
+ onSubmit: str => str.split(sep).map(s => s.trim())
+ });
+};
+/**
+ * Toggle/switch prompt
+ * @param {string} args.message Prompt message to display
+ * @param {boolean} [args.initial=false] Default value
+ * @param {string} [args.active="on"] Text for `active` state
+ * @param {string} [args.inactive="off"] Text for `inactive` state
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.toggle = args => toPrompt('TogglePrompt', args);
+/**
+ * Interactive select prompt
+ * @param {string} args.message Prompt message to display
+ * @param {Array} args.choices Array of choices objects `[{ title, value }, ...]`
+ * @param {number} [args.initial] Index of default value
+ * @param {String} [args.hint] Hint to display
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.select = args => toPrompt('SelectPrompt', args);
+/**
+ * Interactive multi-select / autocompleteMultiselect prompt
+ * @param {string} args.message Prompt message to display
+ * @param {Array} args.choices Array of choices objects `[{ title, value, [selected] }, ...]`
+ * @param {number} [args.max] Max select
+ * @param {string} [args.hint] Hint to display user
+ * @param {Number} [args.cursor=0] Cursor start position
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.multiselect = args => {
+ args.choices = [].concat(args.choices || []);
+
+ const toSelected = items => items.filter(item => item.selected).map(item => item.value);
+
+ return toPrompt('MultiselectPrompt', args, {
+ onAbort: toSelected,
+ onSubmit: toSelected
+ });
+};
+
+$.autocompleteMultiselect = args => {
+ args.choices = [].concat(args.choices || []);
+
+ const toSelected = items => items.filter(item => item.selected).map(item => item.value);
+
+ return toPrompt('AutocompleteMultiselectPrompt', args, {
+ onAbort: toSelected,
+ onSubmit: toSelected
+ });
+};
+
+const byTitle = (input, choices) => Promise.resolve(choices.filter(item => item.title.slice(0, input.length).toLowerCase() === input.toLowerCase()));
+/**
+ * Interactive auto-complete prompt
+ * @param {string} args.message Prompt message to display
+ * @param {Array} args.choices Array of auto-complete choices objects `[{ title, value }, ...]`
+ * @param {Function} [args.suggest] Function to filter results based on user input. Defaults to sort by `title`
+ * @param {number} [args.limit=10] Max number of results to show
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {String} [args.initial] Index of the default value
+ * @param {boolean} [opts.clearFirst] The first ESCAPE keypress will clear the input
+ * @param {String} [args.fallback] Fallback message - defaults to initial value
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+
+
+$.autocomplete = args => {
+ args.suggest = args.suggest || byTitle;
+ args.choices = [].concat(args.choices || []);
+ return toPrompt('AutocompletePrompt', args);
+};
\ No newline at end of file
diff --git a/node_modules/prompts/dist/util/action.js b/node_modules/prompts/dist/util/action.js
new file mode 100644
index 0000000..c36b7db
--- /dev/null
+++ b/node_modules/prompts/dist/util/action.js
@@ -0,0 +1,38 @@
+'use strict';
+
+module.exports = (key, isSelect) => {
+ if (key.meta && key.name !== 'escape') return;
+
+ if (key.ctrl) {
+ if (key.name === 'a') return 'first';
+ if (key.name === 'c') return 'abort';
+ if (key.name === 'd') return 'abort';
+ if (key.name === 'e') return 'last';
+ if (key.name === 'g') return 'reset';
+ }
+
+ if (isSelect) {
+ if (key.name === 'j') return 'down';
+ if (key.name === 'k') return 'up';
+ }
+
+ if (key.name === 'return') return 'submit';
+ if (key.name === 'enter') return 'submit'; // ctrl + J
+
+ if (key.name === 'backspace') return 'delete';
+ if (key.name === 'delete') return 'deleteForward';
+ if (key.name === 'abort') return 'abort';
+ if (key.name === 'escape') return 'exit';
+ if (key.name === 'tab') return 'next';
+ if (key.name === 'pagedown') return 'nextPage';
+ if (key.name === 'pageup') return 'prevPage'; // TODO create home() in prompt types (e.g. TextPrompt)
+
+ if (key.name === 'home') return 'home'; // TODO create end() in prompt types (e.g. TextPrompt)
+
+ if (key.name === 'end') return 'end';
+ if (key.name === 'up') return 'up';
+ if (key.name === 'down') return 'down';
+ if (key.name === 'right') return 'right';
+ if (key.name === 'left') return 'left';
+ return false;
+};
\ No newline at end of file
diff --git a/node_modules/prompts/dist/util/clear.js b/node_modules/prompts/dist/util/clear.js
new file mode 100644
index 0000000..5a313be
--- /dev/null
+++ b/node_modules/prompts/dist/util/clear.js
@@ -0,0 +1,42 @@
+'use strict';
+
+function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
+
+function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
+
+function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
+
+const strip = require('./strip');
+
+const _require = require('sisteransi'),
+ erase = _require.erase,
+ cursor = _require.cursor;
+
+const width = str => [...strip(str)].length;
+/**
+ * @param {string} prompt
+ * @param {number} perLine
+ */
+
+
+module.exports = function (prompt, perLine) {
+ if (!perLine) return erase.line + cursor.to(0);
+ let rows = 0;
+ const lines = prompt.split(/\r?\n/);
+
+ var _iterator = _createForOfIteratorHelper(lines),
+ _step;
+
+ try {
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
+ let line = _step.value;
+ rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / perLine);
+ }
+ } catch (err) {
+ _iterator.e(err);
+ } finally {
+ _iterator.f();
+ }
+
+ return erase.lines(rows);
+};
\ No newline at end of file
diff --git a/node_modules/prompts/dist/util/entriesToDisplay.js b/node_modules/prompts/dist/util/entriesToDisplay.js
new file mode 100644
index 0000000..fbb963a
--- /dev/null
+++ b/node_modules/prompts/dist/util/entriesToDisplay.js
@@ -0,0 +1,21 @@
+'use strict';
+/**
+ * Determine what entries should be displayed on the screen, based on the
+ * currently selected index and the maximum visible. Used in list-based
+ * prompts like `select` and `multiselect`.
+ *
+ * @param {number} cursor the currently selected entry
+ * @param {number} total the total entries available to display
+ * @param {number} [maxVisible] the number of entries that can be displayed
+ */
+
+module.exports = (cursor, total, maxVisible) => {
+ maxVisible = maxVisible || total;
+ let startIndex = Math.min(total - maxVisible, cursor - Math.floor(maxVisible / 2));
+ if (startIndex < 0) startIndex = 0;
+ let endIndex = Math.min(startIndex + maxVisible, total);
+ return {
+ startIndex,
+ endIndex
+ };
+};
\ No newline at end of file
diff --git a/node_modules/prompts/dist/util/figures.js b/node_modules/prompts/dist/util/figures.js
new file mode 100644
index 0000000..036ec50
--- /dev/null
+++ b/node_modules/prompts/dist/util/figures.js
@@ -0,0 +1,32 @@
+'use strict';
+
+const main = {
+ arrowUp: '↑',
+ arrowDown: '↓',
+ arrowLeft: '←',
+ arrowRight: '→',
+ radioOn: '◉',
+ radioOff: '◯',
+ tick: '✔',
+ cross: '✖',
+ ellipsis: '…',
+ pointerSmall: '›',
+ line: '─',
+ pointer: '❯'
+};
+const win = {
+ arrowUp: main.arrowUp,
+ arrowDown: main.arrowDown,
+ arrowLeft: main.arrowLeft,
+ arrowRight: main.arrowRight,
+ radioOn: '(*)',
+ radioOff: '( )',
+ tick: '√',
+ cross: '×',
+ ellipsis: '...',
+ pointerSmall: '»',
+ line: '─',
+ pointer: '>'
+};
+const figures = process.platform === 'win32' ? win : main;
+module.exports = figures;
\ No newline at end of file
diff --git a/node_modules/prompts/dist/util/index.js b/node_modules/prompts/dist/util/index.js
new file mode 100644
index 0000000..dbfe75e
--- /dev/null
+++ b/node_modules/prompts/dist/util/index.js
@@ -0,0 +1,12 @@
+'use strict';
+
+module.exports = {
+ action: require('./action'),
+ clear: require('./clear'),
+ style: require('./style'),
+ strip: require('./strip'),
+ figures: require('./figures'),
+ lines: require('./lines'),
+ wrap: require('./wrap'),
+ entriesToDisplay: require('./entriesToDisplay')
+};
\ No newline at end of file
diff --git a/node_modules/prompts/dist/util/lines.js b/node_modules/prompts/dist/util/lines.js
new file mode 100644
index 0000000..54a939a
--- /dev/null
+++ b/node_modules/prompts/dist/util/lines.js
@@ -0,0 +1,14 @@
+'use strict';
+
+const strip = require('./strip');
+/**
+ * @param {string} msg
+ * @param {number} perLine
+ */
+
+
+module.exports = function (msg, perLine) {
+ let lines = String(strip(msg) || '').split(/\r?\n/);
+ if (!perLine) return lines.length;
+ return lines.map(l => Math.ceil(l.length / perLine)).reduce((a, b) => a + b);
+};
\ No newline at end of file
diff --git a/node_modules/prompts/dist/util/strip.js b/node_modules/prompts/dist/util/strip.js
new file mode 100644
index 0000000..dd289a0
--- /dev/null
+++ b/node_modules/prompts/dist/util/strip.js
@@ -0,0 +1,7 @@
+'use strict';
+
+module.exports = str => {
+ const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))'].join('|');
+ const RGX = new RegExp(pattern, 'g');
+ return typeof str === 'string' ? str.replace(RGX, '') : str;
+};
\ No newline at end of file
diff --git a/node_modules/prompts/dist/util/style.js b/node_modules/prompts/dist/util/style.js
new file mode 100644
index 0000000..ed1a49b
--- /dev/null
+++ b/node_modules/prompts/dist/util/style.js
@@ -0,0 +1,51 @@
+'use strict';
+
+const c = require('kleur');
+
+const figures = require('./figures'); // rendering user input.
+
+
+const styles = Object.freeze({
+ password: {
+ scale: 1,
+ render: input => '*'.repeat(input.length)
+ },
+ emoji: {
+ scale: 2,
+ render: input => '😃'.repeat(input.length)
+ },
+ invisible: {
+ scale: 0,
+ render: input => ''
+ },
+ default: {
+ scale: 1,
+ render: input => `${input}`
+ }
+});
+
+const render = type => styles[type] || styles.default; // icon to signalize a prompt.
+
+
+const symbols = Object.freeze({
+ aborted: c.red(figures.cross),
+ done: c.green(figures.tick),
+ exited: c.yellow(figures.cross),
+ default: c.cyan('?')
+});
+
+const symbol = (done, aborted, exited) => aborted ? symbols.aborted : exited ? symbols.exited : done ? symbols.done : symbols.default; // between the question and the user's input.
+
+
+const delimiter = completing => c.gray(completing ? figures.ellipsis : figures.pointerSmall);
+
+const item = (expandable, expanded) => c.gray(expandable ? expanded ? figures.pointerSmall : '+' : figures.line);
+
+module.exports = {
+ styles,
+ render,
+ symbols,
+ symbol,
+ delimiter,
+ item
+};
\ No newline at end of file
diff --git a/node_modules/prompts/dist/util/wrap.js b/node_modules/prompts/dist/util/wrap.js
new file mode 100644
index 0000000..da5e67c
--- /dev/null
+++ b/node_modules/prompts/dist/util/wrap.js
@@ -0,0 +1,16 @@
+'use strict';
+/**
+ * @param {string} msg The message to wrap
+ * @param {object} opts
+ * @param {number|string} [opts.margin] Left margin
+ * @param {number} opts.width Maximum characters per line including the margin
+ */
+
+module.exports = (msg, opts = {}) => {
+ const tab = Number.isSafeInteger(parseInt(opts.margin)) ? new Array(parseInt(opts.margin)).fill(' ').join('') : opts.margin || '';
+ const width = opts.width;
+ return (msg || '').split(/\r?\n/g).map(line => line.split(/\s+/g).reduce((arr, w) => {
+ if (w.length + tab.length >= width || arr[arr.length - 1].length + w.length + 1 < width) arr[arr.length - 1] += ` ${w}`;else arr.push(`${tab}${w}`);
+ return arr;
+ }, [tab]).join('\n')).join('\n');
+};
\ No newline at end of file
diff --git a/node_modules/prompts/index.js b/node_modules/prompts/index.js
new file mode 100644
index 0000000..3479956
--- /dev/null
+++ b/node_modules/prompts/index.js
@@ -0,0 +1,14 @@
+function isNodeLT(tar) {
+ tar = (Array.isArray(tar) ? tar : tar.split('.')).map(Number);
+ let i=0, src=process.versions.node.split('.').map(Number);
+ for (; i < tar.length; i++) {
+ if (src[i] > tar[i]) return false;
+ if (tar[i] > src[i]) return true;
+ }
+ return false;
+}
+
+module.exports =
+ isNodeLT('8.6.0')
+ ? require('./dist/index.js')
+ : require('./lib/index.js');
diff --git a/node_modules/prompts/lib/dateparts/datepart.js b/node_modules/prompts/lib/dateparts/datepart.js
new file mode 100644
index 0000000..62b893b
--- /dev/null
+++ b/node_modules/prompts/lib/dateparts/datepart.js
@@ -0,0 +1,35 @@
+'use strict';
+
+class DatePart {
+ constructor({token, date, parts, locales}) {
+ this.token = token;
+ this.date = date || new Date();
+ this.parts = parts || [this];
+ this.locales = locales || {};
+ }
+
+ up() {}
+
+ down() {}
+
+ next() {
+ const currentIdx = this.parts.indexOf(this);
+ return this.parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
+ }
+
+ setTo(val) {}
+
+ prev() {
+ let parts = [].concat(this.parts).reverse();
+ const currentIdx = parts.indexOf(this);
+ return parts.find((part, idx) => idx > currentIdx && part instanceof DatePart);
+ }
+
+ toString() {
+ return String(this.date);
+ }
+}
+
+module.exports = DatePart;
+
+
diff --git a/node_modules/prompts/lib/dateparts/day.js b/node_modules/prompts/lib/dateparts/day.js
new file mode 100644
index 0000000..5db84fe
--- /dev/null
+++ b/node_modules/prompts/lib/dateparts/day.js
@@ -0,0 +1,42 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+const pos = n => {
+ n = n % 10;
+ return n === 1 ? 'st'
+ : n === 2 ? 'nd'
+ : n === 3 ? 'rd'
+ : 'th';
+}
+
+class Day extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setDate(this.date.getDate() + 1);
+ }
+
+ down() {
+ this.date.setDate(this.date.getDate() - 1);
+ }
+
+ setTo(val) {
+ this.date.setDate(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let date = this.date.getDate();
+ let day = this.date.getDay();
+ return this.token === 'DD' ? String(date).padStart(2, '0')
+ : this.token === 'Do' ? date + pos(date)
+ : this.token === 'd' ? day + 1
+ : this.token === 'ddd' ? this.locales.weekdaysShort[day]
+ : this.token === 'dddd' ? this.locales.weekdays[day]
+ : date;
+ }
+}
+
+module.exports = Day;
diff --git a/node_modules/prompts/lib/dateparts/hours.js b/node_modules/prompts/lib/dateparts/hours.js
new file mode 100644
index 0000000..171b3d2
--- /dev/null
+++ b/node_modules/prompts/lib/dateparts/hours.js
@@ -0,0 +1,30 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Hours extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setHours(this.date.getHours() + 1);
+ }
+
+ down() {
+ this.date.setHours(this.date.getHours() - 1);
+ }
+
+ setTo(val) {
+ this.date.setHours(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let hours = this.date.getHours();
+ if (/h/.test(this.token))
+ hours = (hours % 12) || 12;
+ return this.token.length > 1 ? String(hours).padStart(2, '0') : hours;
+ }
+}
+
+module.exports = Hours;
diff --git a/node_modules/prompts/lib/dateparts/index.js b/node_modules/prompts/lib/dateparts/index.js
new file mode 100644
index 0000000..dc0cc95
--- /dev/null
+++ b/node_modules/prompts/lib/dateparts/index.js
@@ -0,0 +1,13 @@
+'use strict';
+
+module.exports = {
+ DatePart: require('./datepart'),
+ Meridiem: require('./meridiem'),
+ Day: require('./day'),
+ Hours: require('./hours'),
+ Milliseconds: require('./milliseconds'),
+ Minutes: require('./minutes'),
+ Month: require('./month'),
+ Seconds: require('./seconds'),
+ Year: require('./year'),
+}
diff --git a/node_modules/prompts/lib/dateparts/meridiem.js b/node_modules/prompts/lib/dateparts/meridiem.js
new file mode 100644
index 0000000..8488677
--- /dev/null
+++ b/node_modules/prompts/lib/dateparts/meridiem.js
@@ -0,0 +1,24 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Meridiem extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setHours((this.date.getHours() + 12) % 24);
+ }
+
+ down() {
+ this.up();
+ }
+
+ toString() {
+ let meridiem = this.date.getHours() > 12 ? 'pm' : 'am';
+ return /\A/.test(this.token) ? meridiem.toUpperCase() : meridiem;
+ }
+}
+
+module.exports = Meridiem;
diff --git a/node_modules/prompts/lib/dateparts/milliseconds.js b/node_modules/prompts/lib/dateparts/milliseconds.js
new file mode 100644
index 0000000..8984270
--- /dev/null
+++ b/node_modules/prompts/lib/dateparts/milliseconds.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Milliseconds extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setMilliseconds(this.date.getMilliseconds() + 1);
+ }
+
+ down() {
+ this.date.setMilliseconds(this.date.getMilliseconds() - 1);
+ }
+
+ setTo(val) {
+ this.date.setMilliseconds(parseInt(val.substr(-(this.token.length))));
+ }
+
+ toString() {
+ return String(this.date.getMilliseconds()).padStart(4, '0')
+ .substr(0, this.token.length);
+ }
+}
+
+module.exports = Milliseconds;
diff --git a/node_modules/prompts/lib/dateparts/minutes.js b/node_modules/prompts/lib/dateparts/minutes.js
new file mode 100644
index 0000000..aa1d8f7
--- /dev/null
+++ b/node_modules/prompts/lib/dateparts/minutes.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Minutes extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setMinutes(this.date.getMinutes() + 1);
+ }
+
+ down() {
+ this.date.setMinutes(this.date.getMinutes() - 1);
+ }
+
+ setTo(val) {
+ this.date.setMinutes(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let m = this.date.getMinutes();
+ return this.token.length > 1 ? String(m).padStart(2, '0') : m;
+ }
+}
+
+module.exports = Minutes;
diff --git a/node_modules/prompts/lib/dateparts/month.js b/node_modules/prompts/lib/dateparts/month.js
new file mode 100644
index 0000000..f656455
--- /dev/null
+++ b/node_modules/prompts/lib/dateparts/month.js
@@ -0,0 +1,33 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Month extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setMonth(this.date.getMonth() + 1);
+ }
+
+ down() {
+ this.date.setMonth(this.date.getMonth() - 1);
+ }
+
+ setTo(val) {
+ val = parseInt(val.substr(-2)) - 1;
+ this.date.setMonth(val < 0 ? 0 : val);
+ }
+
+ toString() {
+ let month = this.date.getMonth();
+ let tl = this.token.length;
+ return tl === 2 ? String(month + 1).padStart(2, '0')
+ : tl === 3 ? this.locales.monthsShort[month]
+ : tl === 4 ? this.locales.months[month]
+ : String(month + 1);
+ }
+}
+
+module.exports = Month;
diff --git a/node_modules/prompts/lib/dateparts/seconds.js b/node_modules/prompts/lib/dateparts/seconds.js
new file mode 100644
index 0000000..0c1a1a4
--- /dev/null
+++ b/node_modules/prompts/lib/dateparts/seconds.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Seconds extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setSeconds(this.date.getSeconds() + 1);
+ }
+
+ down() {
+ this.date.setSeconds(this.date.getSeconds() - 1);
+ }
+
+ setTo(val) {
+ this.date.setSeconds(parseInt(val.substr(-2)));
+ }
+
+ toString() {
+ let s = this.date.getSeconds();
+ return this.token.length > 1 ? String(s).padStart(2, '0') : s;
+ }
+}
+
+module.exports = Seconds;
diff --git a/node_modules/prompts/lib/dateparts/year.js b/node_modules/prompts/lib/dateparts/year.js
new file mode 100644
index 0000000..f068e43
--- /dev/null
+++ b/node_modules/prompts/lib/dateparts/year.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const DatePart = require('./datepart');
+
+class Year extends DatePart {
+ constructor(opts={}) {
+ super(opts);
+ }
+
+ up() {
+ this.date.setFullYear(this.date.getFullYear() + 1);
+ }
+
+ down() {
+ this.date.setFullYear(this.date.getFullYear() - 1);
+ }
+
+ setTo(val) {
+ this.date.setFullYear(val.substr(-4));
+ }
+
+ toString() {
+ let year = String(this.date.getFullYear()).padStart(4, '0');
+ return this.token.length === 2 ? year.substr(-2) : year;
+ }
+}
+
+module.exports = Year;
diff --git a/node_modules/prompts/lib/elements/autocomplete.js b/node_modules/prompts/lib/elements/autocomplete.js
new file mode 100644
index 0000000..8e06da2
--- /dev/null
+++ b/node_modules/prompts/lib/elements/autocomplete.js
@@ -0,0 +1,264 @@
+'use strict';
+
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { erase, cursor } = require('sisteransi');
+const { style, clear, figures, wrap, entriesToDisplay } = require('../util');
+
+const getVal = (arr, i) => arr[i] && (arr[i].value || arr[i].title || arr[i]);
+const getTitle = (arr, i) => arr[i] && (arr[i].title || arr[i].value || arr[i]);
+const getIndex = (arr, valOrTitle) => {
+ const index = arr.findIndex(el => el.value === valOrTitle || el.title === valOrTitle);
+ return index > -1 ? index : undefined;
+};
+
+/**
+ * TextPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of auto-complete choices objects
+ * @param {Function} [opts.suggest] Filter function. Defaults to sort by title
+ * @param {Number} [opts.limit=10] Max number of results to show
+ * @param {Number} [opts.cursor=0] Cursor start position
+ * @param {String} [opts.style='default'] Render style
+ * @param {String} [opts.fallback] Fallback message - initial to default value
+ * @param {String} [opts.initial] Index of the default value
+ * @param {Boolean} [opts.clearFirst] The first ESCAPE keypress will clear the input
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.noMatches] The no matches found label
+ */
+class AutocompletePrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.msg = opts.message;
+ this.suggest = opts.suggest;
+ this.choices = opts.choices;
+ this.initial = typeof opts.initial === 'number'
+ ? opts.initial
+ : getIndex(opts.choices, opts.initial);
+ this.select = this.initial || opts.cursor || 0;
+ this.i18n = { noMatches: opts.noMatches || 'no matches found' };
+ this.fallback = opts.fallback || this.initial;
+ this.clearFirst = opts.clearFirst || false;
+ this.suggestions = [];
+ this.input = '';
+ this.limit = opts.limit || 10;
+ this.cursor = 0;
+ this.transform = style.render(opts.style);
+ this.scale = this.transform.scale;
+ this.render = this.render.bind(this);
+ this.complete = this.complete.bind(this);
+ this.clear = clear('', this.out.columns);
+ this.complete(this.render);
+ this.render();
+ }
+
+ set fallback(fb) {
+ this._fb = Number.isSafeInteger(parseInt(fb)) ? parseInt(fb) : fb;
+ }
+
+ get fallback() {
+ let choice;
+ if (typeof this._fb === 'number')
+ choice = this.choices[this._fb];
+ else if (typeof this._fb === 'string')
+ choice = { title: this._fb };
+ return choice || this._fb || { title: this.i18n.noMatches };
+ }
+
+ moveSelect(i) {
+ this.select = i;
+ if (this.suggestions.length > 0)
+ this.value = getVal(this.suggestions, i);
+ else this.value = this.fallback.value;
+ this.fire();
+ }
+
+ async complete(cb) {
+ const p = (this.completing = this.suggest(this.input, this.choices));
+ const suggestions = await p;
+
+ if (this.completing !== p) return;
+ this.suggestions = suggestions
+ .map((s, i, arr) => ({ title: getTitle(arr, i), value: getVal(arr, i), description: s.description }));
+ this.completing = false;
+ const l = Math.max(suggestions.length - 1, 0);
+ this.moveSelect(Math.min(l, this.select));
+
+ cb && cb();
+ }
+
+ reset() {
+ this.input = '';
+ this.complete(() => {
+ this.moveSelect(this.initial !== void 0 ? this.initial : 0);
+ this.render();
+ });
+ this.render();
+ }
+
+ exit() {
+ if (this.clearFirst && this.input.length > 0) {
+ this.reset();
+ } else {
+ this.done = this.exited = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.exited = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ this.done = true;
+ this.aborted = this.exited = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ _(c, key) {
+ let s1 = this.input.slice(0, this.cursor);
+ let s2 = this.input.slice(this.cursor);
+ this.input = `${s1}${c}${s2}`;
+ this.cursor = s1.length+1;
+ this.complete(this.render);
+ this.render();
+ }
+
+ delete() {
+ if (this.cursor === 0) return this.bell();
+ let s1 = this.input.slice(0, this.cursor-1);
+ let s2 = this.input.slice(this.cursor);
+ this.input = `${s1}${s2}`;
+ this.complete(this.render);
+ this.cursor = this.cursor-1;
+ this.render();
+ }
+
+ deleteForward() {
+ if(this.cursor*this.scale >= this.rendered.length) return this.bell();
+ let s1 = this.input.slice(0, this.cursor);
+ let s2 = this.input.slice(this.cursor+1);
+ this.input = `${s1}${s2}`;
+ this.complete(this.render);
+ this.render();
+ }
+
+ first() {
+ this.moveSelect(0);
+ this.render();
+ }
+
+ last() {
+ this.moveSelect(this.suggestions.length - 1);
+ this.render();
+ }
+
+ up() {
+ if (this.select === 0) {
+ this.moveSelect(this.suggestions.length - 1);
+ } else {
+ this.moveSelect(this.select - 1);
+ }
+ this.render();
+ }
+
+ down() {
+ if (this.select === this.suggestions.length - 1) {
+ this.moveSelect(0);
+ } else {
+ this.moveSelect(this.select + 1);
+ }
+ this.render();
+ }
+
+ next() {
+ if (this.select === this.suggestions.length - 1) {
+ this.moveSelect(0);
+ } else this.moveSelect(this.select + 1);
+ this.render();
+ }
+
+ nextPage() {
+ this.moveSelect(Math.min(this.select + this.limit, this.suggestions.length - 1));
+ this.render();
+ }
+
+ prevPage() {
+ this.moveSelect(Math.max(this.select - this.limit, 0));
+ this.render();
+ }
+
+ left() {
+ if (this.cursor <= 0) return this.bell();
+ this.cursor = this.cursor-1;
+ this.render();
+ }
+
+ right() {
+ if (this.cursor*this.scale >= this.rendered.length) return this.bell();
+ this.cursor = this.cursor+1;
+ this.render();
+ }
+
+ renderOption(v, hovered, isStart, isEnd) {
+ let desc;
+ let prefix = isStart ? figures.arrowUp : isEnd ? figures.arrowDown : ' ';
+ let title = hovered ? color.cyan().underline(v.title) : v.title;
+ prefix = (hovered ? color.cyan(figures.pointer) + ' ' : ' ') + prefix;
+ if (v.description) {
+ desc = ` - ${v.description}`;
+ if (prefix.length + title.length + desc.length >= this.out.columns
+ || v.description.split(/\r?\n/).length > 1) {
+ desc = '\n' + wrap(v.description, { margin: 3, width: this.out.columns })
+ }
+ }
+ return prefix + ' ' + title + color.gray(desc || '');
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ let { startIndex, endIndex } = entriesToDisplay(this.select, this.choices.length, this.limit);
+
+ this.outputText = [
+ style.symbol(this.done, this.aborted, this.exited),
+ color.bold(this.msg),
+ style.delimiter(this.completing),
+ this.done && this.suggestions[this.select]
+ ? this.suggestions[this.select].title
+ : this.rendered = this.transform.render(this.input)
+ ].join(' ');
+
+ if (!this.done) {
+ const suggestions = this.suggestions
+ .slice(startIndex, endIndex)
+ .map((item, i) => this.renderOption(item,
+ this.select === i + startIndex,
+ i === 0 && startIndex > 0,
+ i + startIndex === endIndex - 1 && endIndex < this.choices.length))
+ .join('\n');
+ this.outputText += `\n` + (suggestions || color.gray(this.fallback.title));
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+}
+
+module.exports = AutocompletePrompt;
diff --git a/node_modules/prompts/lib/elements/autocompleteMultiselect.js b/node_modules/prompts/lib/elements/autocompleteMultiselect.js
new file mode 100644
index 0000000..b64510f
--- /dev/null
+++ b/node_modules/prompts/lib/elements/autocompleteMultiselect.js
@@ -0,0 +1,194 @@
+'use strict';
+
+const color = require('kleur');
+const { cursor } = require('sisteransi');
+const MultiselectPrompt = require('./multiselect');
+const { clear, style, figures } = require('../util');
+/**
+ * MultiselectPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of choice objects
+ * @param {String} [opts.hint] Hint to display
+ * @param {String} [opts.warn] Hint shown for disabled choices
+ * @param {Number} [opts.max] Max choices
+ * @param {Number} [opts.cursor=0] Cursor start position
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+class AutocompleteMultiselectPrompt extends MultiselectPrompt {
+ constructor(opts={}) {
+ opts.overrideRender = true;
+ super(opts);
+ this.inputValue = '';
+ this.clear = clear('', this.out.columns);
+ this.filteredOptions = this.value;
+ this.render();
+ }
+
+ last() {
+ this.cursor = this.filteredOptions.length - 1;
+ this.render();
+ }
+ next() {
+ this.cursor = (this.cursor + 1) % this.filteredOptions.length;
+ this.render();
+ }
+
+ up() {
+ if (this.cursor === 0) {
+ this.cursor = this.filteredOptions.length - 1;
+ } else {
+ this.cursor--;
+ }
+ this.render();
+ }
+
+ down() {
+ if (this.cursor === this.filteredOptions.length - 1) {
+ this.cursor = 0;
+ } else {
+ this.cursor++;
+ }
+ this.render();
+ }
+
+ left() {
+ this.filteredOptions[this.cursor].selected = false;
+ this.render();
+ }
+
+ right() {
+ if (this.value.filter(e => e.selected).length >= this.maxChoices) return this.bell();
+ this.filteredOptions[this.cursor].selected = true;
+ this.render();
+ }
+
+ delete() {
+ if (this.inputValue.length) {
+ this.inputValue = this.inputValue.substr(0, this.inputValue.length - 1);
+ this.updateFilteredOptions();
+ }
+ }
+
+ updateFilteredOptions() {
+ const currentHighlight = this.filteredOptions[this.cursor];
+ this.filteredOptions = this.value
+ .filter(v => {
+ if (this.inputValue) {
+ if (typeof v.title === 'string') {
+ if (v.title.toLowerCase().includes(this.inputValue.toLowerCase())) {
+ return true;
+ }
+ }
+ if (typeof v.value === 'string') {
+ if (v.value.toLowerCase().includes(this.inputValue.toLowerCase())) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+ });
+ const newHighlightIndex = this.filteredOptions.findIndex(v => v === currentHighlight)
+ this.cursor = newHighlightIndex < 0 ? 0 : newHighlightIndex;
+ this.render();
+ }
+
+ handleSpaceToggle() {
+ const v = this.filteredOptions[this.cursor];
+
+ if (v.selected) {
+ v.selected = false;
+ this.render();
+ } else if (v.disabled || this.value.filter(e => e.selected).length >= this.maxChoices) {
+ return this.bell();
+ } else {
+ v.selected = true;
+ this.render();
+ }
+ }
+
+ handleInputChange(c) {
+ this.inputValue = this.inputValue + c;
+ this.updateFilteredOptions();
+ }
+
+ _(c, key) {
+ if (c === ' ') {
+ this.handleSpaceToggle();
+ } else {
+ this.handleInputChange(c);
+ }
+ }
+
+ renderInstructions() {
+ if (this.instructions === undefined || this.instructions) {
+ if (typeof this.instructions === 'string') {
+ return this.instructions;
+ }
+ return `
+Instructions:
+ ${figures.arrowUp}/${figures.arrowDown}: Highlight option
+ ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection
+ [a,b,c]/delete: Filter choices
+ enter/return: Complete answer
+`;
+ }
+ return '';
+ }
+
+ renderCurrentInput() {
+ return `
+Filtered results for: ${this.inputValue ? this.inputValue : color.gray('Enter something to filter')}\n`;
+ }
+
+ renderOption(cursor, v, i) {
+ let title;
+ if (v.disabled) title = cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
+ else title = cursor === i ? color.cyan().underline(v.title) : v.title;
+ return (v.selected ? color.green(figures.radioOn) : figures.radioOff) + ' ' + title
+ }
+
+ renderDoneOrInstructions() {
+ if (this.done) {
+ return this.value
+ .filter(e => e.selected)
+ .map(v => v.title)
+ .join(', ');
+ }
+
+ const output = [color.gray(this.hint), this.renderInstructions(), this.renderCurrentInput()];
+
+ if (this.filteredOptions.length && this.filteredOptions[this.cursor].disabled) {
+ output.push(color.yellow(this.warn));
+ }
+ return output.join(' ');
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ super.render();
+
+ // print prompt
+
+ let prompt = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(false),
+ this.renderDoneOrInstructions()
+ ].join(' ');
+
+ if (this.showMinError) {
+ prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
+ this.showMinError = false;
+ }
+ prompt += this.renderOptions(this.filteredOptions);
+
+ this.out.write(this.clear + prompt);
+ this.clear = clear(prompt, this.out.columns);
+ }
+}
+
+module.exports = AutocompleteMultiselectPrompt;
diff --git a/node_modules/prompts/lib/elements/confirm.js b/node_modules/prompts/lib/elements/confirm.js
new file mode 100644
index 0000000..7a9173f
--- /dev/null
+++ b/node_modules/prompts/lib/elements/confirm.js
@@ -0,0 +1,89 @@
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { style, clear } = require('../util');
+const { erase, cursor } = require('sisteransi');
+
+/**
+ * ConfirmPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Boolean} [opts.initial] Default value (true/false)
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.yes] The "Yes" label
+ * @param {String} [opts.yesOption] The "Yes" option when choosing between yes/no
+ * @param {String} [opts.no] The "No" label
+ * @param {String} [opts.noOption] The "No" option when choosing between yes/no
+ */
+class ConfirmPrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.msg = opts.message;
+ this.value = opts.initial;
+ this.initialValue = !!opts.initial;
+ this.yesMsg = opts.yes || 'yes';
+ this.yesOption = opts.yesOption || '(Y/n)';
+ this.noMsg = opts.no || 'no';
+ this.noOption = opts.noOption || '(y/N)';
+ this.render();
+ }
+
+ reset() {
+ this.value = this.initialValue;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ this.value = this.value || false;
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ _(c, key) {
+ if (c.toLowerCase() === 'y') {
+ this.value = true;
+ return this.submit();
+ }
+ if (c.toLowerCase() === 'n') {
+ this.value = false;
+ return this.submit();
+ }
+ return this.bell();
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ this.outputText = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(this.done),
+ this.done ? (this.value ? this.yesMsg : this.noMsg)
+ : color.gray(this.initialValue ? this.yesOption : this.noOption)
+ ].join(' ');
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+}
+
+module.exports = ConfirmPrompt;
diff --git a/node_modules/prompts/lib/elements/date.js b/node_modules/prompts/lib/elements/date.js
new file mode 100644
index 0000000..71ff608
--- /dev/null
+++ b/node_modules/prompts/lib/elements/date.js
@@ -0,0 +1,209 @@
+'use strict';
+
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { style, clear, figures } = require('../util');
+const { erase, cursor } = require('sisteransi');
+const { DatePart, Meridiem, Day, Hours, Milliseconds, Minutes, Month, Seconds, Year } = require('../dateparts');
+
+const regex = /\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g;
+const regexGroups = {
+ 1: ({token}) => token.replace(/\\(.)/g, '$1'),
+ 2: (opts) => new Day(opts), // Day // TODO
+ 3: (opts) => new Month(opts), // Month
+ 4: (opts) => new Year(opts), // Year
+ 5: (opts) => new Meridiem(opts), // AM/PM // TODO (special)
+ 6: (opts) => new Hours(opts), // Hours
+ 7: (opts) => new Minutes(opts), // Minutes
+ 8: (opts) => new Seconds(opts), // Seconds
+ 9: (opts) => new Milliseconds(opts), // Fractional seconds
+}
+
+const dfltLocales = {
+ months: 'January,February,March,April,May,June,July,August,September,October,November,December'.split(','),
+ monthsShort: 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(','),
+ weekdays: 'Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday'.split(','),
+ weekdaysShort: 'Sun,Mon,Tue,Wed,Thu,Fri,Sat'.split(',')
+}
+
+
+/**
+ * DatePrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Number} [opts.initial] Index of default value
+ * @param {String} [opts.mask] The format mask
+ * @param {object} [opts.locales] The date locales
+ * @param {String} [opts.error] The error message shown on invalid value
+ * @param {Function} [opts.validate] Function to validate the submitted value
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+class DatePrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.msg = opts.message;
+ this.cursor = 0;
+ this.typed = '';
+ this.locales = Object.assign(dfltLocales, opts.locales);
+ this._date = opts.initial || new Date();
+ this.errorMsg = opts.error || 'Please Enter A Valid Value';
+ this.validator = opts.validate || (() => true);
+ this.mask = opts.mask || 'YYYY-MM-DD HH:mm:ss';
+ this.clear = clear('', this.out.columns);
+ this.render();
+ }
+
+ get value() {
+ return this.date
+ }
+
+ get date() {
+ return this._date;
+ }
+
+ set date(date) {
+ if (date) this._date.setTime(date.getTime());
+ }
+
+ set mask(mask) {
+ let result;
+ this.parts = [];
+ while(result = regex.exec(mask)) {
+ let match = result.shift();
+ let idx = result.findIndex(gr => gr != null);
+ this.parts.push(idx in regexGroups
+ ? regexGroups[idx]({ token: result[idx] || match, date: this.date, parts: this.parts, locales: this.locales })
+ : result[idx] || match);
+ }
+
+ let parts = this.parts.reduce((arr, i) => {
+ if (typeof i === 'string' && typeof arr[arr.length - 1] === 'string')
+ arr[arr.length - 1] += i;
+ else arr.push(i);
+ return arr;
+ }, []);
+
+ this.parts.splice(0);
+ this.parts.push(...parts);
+ this.reset();
+ }
+
+ moveCursor(n) {
+ this.typed = '';
+ this.cursor = n;
+ this.fire();
+ }
+
+ reset() {
+ this.moveCursor(this.parts.findIndex(p => p instanceof DatePart));
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.error = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ async validate() {
+ let valid = await this.validator(this.value);
+ if (typeof valid === 'string') {
+ this.errorMsg = valid;
+ valid = false;
+ }
+ this.error = !valid;
+ }
+
+ async submit() {
+ await this.validate();
+ if (this.error) {
+ this.color = 'red';
+ this.fire();
+ this.render();
+ return;
+ }
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ up() {
+ this.typed = '';
+ this.parts[this.cursor].up();
+ this.render();
+ }
+
+ down() {
+ this.typed = '';
+ this.parts[this.cursor].down();
+ this.render();
+ }
+
+ left() {
+ let prev = this.parts[this.cursor].prev();
+ if (prev == null) return this.bell();
+ this.moveCursor(this.parts.indexOf(prev));
+ this.render();
+ }
+
+ right() {
+ let next = this.parts[this.cursor].next();
+ if (next == null) return this.bell();
+ this.moveCursor(this.parts.indexOf(next));
+ this.render();
+ }
+
+ next() {
+ let next = this.parts[this.cursor].next();
+ this.moveCursor(next
+ ? this.parts.indexOf(next)
+ : this.parts.findIndex((part) => part instanceof DatePart));
+ this.render();
+ }
+
+ _(c) {
+ if (/\d/.test(c)) {
+ this.typed += c;
+ this.parts[this.cursor].setTo(this.typed);
+ this.render();
+ }
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ // Print prompt
+ this.outputText = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(false),
+ this.parts.reduce((arr, p, idx) => arr.concat(idx === this.cursor && !this.done ? color.cyan().underline(p.toString()) : p), [])
+ .join('')
+ ].join(' ');
+
+ // Print error
+ if (this.error) {
+ this.outputText += this.errorMsg.split('\n').reduce(
+ (a, l, i) => a + `\n${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+}
+
+module.exports = DatePrompt;
diff --git a/node_modules/prompts/lib/elements/index.js b/node_modules/prompts/lib/elements/index.js
new file mode 100644
index 0000000..2556dd0
--- /dev/null
+++ b/node_modules/prompts/lib/elements/index.js
@@ -0,0 +1,13 @@
+'use strict';
+
+module.exports = {
+ TextPrompt: require('./text'),
+ SelectPrompt: require('./select'),
+ TogglePrompt: require('./toggle'),
+ DatePrompt: require('./date'),
+ NumberPrompt: require('./number'),
+ MultiselectPrompt: require('./multiselect'),
+ AutocompletePrompt: require('./autocomplete'),
+ AutocompleteMultiselectPrompt: require('./autocompleteMultiselect'),
+ ConfirmPrompt: require('./confirm')
+};
diff --git a/node_modules/prompts/lib/elements/multiselect.js b/node_modules/prompts/lib/elements/multiselect.js
new file mode 100644
index 0000000..99b393f
--- /dev/null
+++ b/node_modules/prompts/lib/elements/multiselect.js
@@ -0,0 +1,271 @@
+'use strict';
+
+const color = require('kleur');
+const { cursor } = require('sisteransi');
+const Prompt = require('./prompt');
+const { clear, figures, style, wrap, entriesToDisplay } = require('../util');
+
+/**
+ * MultiselectPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of choice objects
+ * @param {String} [opts.hint] Hint to display
+ * @param {String} [opts.warn] Hint shown for disabled choices
+ * @param {Number} [opts.max] Max choices
+ * @param {Number} [opts.cursor=0] Cursor start position
+ * @param {Number} [opts.optionsPerPage=10] Max options to display at once
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+class MultiselectPrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.msg = opts.message;
+ this.cursor = opts.cursor || 0;
+ this.scrollIndex = opts.cursor || 0;
+ this.hint = opts.hint || '';
+ this.warn = opts.warn || '- This option is disabled -';
+ this.minSelected = opts.min;
+ this.showMinError = false;
+ this.maxChoices = opts.max;
+ this.instructions = opts.instructions;
+ this.optionsPerPage = opts.optionsPerPage || 10;
+ this.value = opts.choices.map((ch, idx) => {
+ if (typeof ch === 'string')
+ ch = {title: ch, value: idx};
+ return {
+ title: ch && (ch.title || ch.value || ch),
+ description: ch && ch.description,
+ value: ch && (ch.value === undefined ? idx : ch.value),
+ selected: ch && ch.selected,
+ disabled: ch && ch.disabled
+ };
+ });
+ this.clear = clear('', this.out.columns);
+ if (!opts.overrideRender) {
+ this.render();
+ }
+ }
+
+ reset() {
+ this.value.map(v => !v.selected);
+ this.cursor = 0;
+ this.fire();
+ this.render();
+ }
+
+ selected() {
+ return this.value.filter(v => v.selected);
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ const selected = this.value
+ .filter(e => e.selected);
+ if (this.minSelected && selected.length < this.minSelected) {
+ this.showMinError = true;
+ this.render();
+ } else {
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+ }
+
+ first() {
+ this.cursor = 0;
+ this.render();
+ }
+
+ last() {
+ this.cursor = this.value.length - 1;
+ this.render();
+ }
+ next() {
+ this.cursor = (this.cursor + 1) % this.value.length;
+ this.render();
+ }
+
+ up() {
+ if (this.cursor === 0) {
+ this.cursor = this.value.length - 1;
+ } else {
+ this.cursor--;
+ }
+ this.render();
+ }
+
+ down() {
+ if (this.cursor === this.value.length - 1) {
+ this.cursor = 0;
+ } else {
+ this.cursor++;
+ }
+ this.render();
+ }
+
+ left() {
+ this.value[this.cursor].selected = false;
+ this.render();
+ }
+
+ right() {
+ if (this.value.filter(e => e.selected).length >= this.maxChoices) return this.bell();
+ this.value[this.cursor].selected = true;
+ this.render();
+ }
+
+ handleSpaceToggle() {
+ const v = this.value[this.cursor];
+
+ if (v.selected) {
+ v.selected = false;
+ this.render();
+ } else if (v.disabled || this.value.filter(e => e.selected).length >= this.maxChoices) {
+ return this.bell();
+ } else {
+ v.selected = true;
+ this.render();
+ }
+ }
+
+ toggleAll() {
+ if (this.maxChoices !== undefined || this.value[this.cursor].disabled) {
+ return this.bell();
+ }
+
+ const newSelected = !this.value[this.cursor].selected;
+ this.value.filter(v => !v.disabled).forEach(v => v.selected = newSelected);
+ this.render();
+ }
+
+ _(c, key) {
+ if (c === ' ') {
+ this.handleSpaceToggle();
+ } else if (c === 'a') {
+ this.toggleAll();
+ } else {
+ return this.bell();
+ }
+ }
+
+ renderInstructions() {
+ if (this.instructions === undefined || this.instructions) {
+ if (typeof this.instructions === 'string') {
+ return this.instructions;
+ }
+ return '\nInstructions:\n'
+ + ` ${figures.arrowUp}/${figures.arrowDown}: Highlight option\n`
+ + ` ${figures.arrowLeft}/${figures.arrowRight}/[space]: Toggle selection\n`
+ + (this.maxChoices === undefined ? ` a: Toggle all\n` : '')
+ + ` enter/return: Complete answer`;
+ }
+ return '';
+ }
+
+ renderOption(cursor, v, i, arrowIndicator) {
+ const prefix = (v.selected ? color.green(figures.radioOn) : figures.radioOff) + ' ' + arrowIndicator + ' ';
+ let title, desc;
+
+ if (v.disabled) {
+ title = cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
+ } else {
+ title = cursor === i ? color.cyan().underline(v.title) : v.title;
+ if (cursor === i && v.description) {
+ desc = ` - ${v.description}`;
+ if (prefix.length + title.length + desc.length >= this.out.columns
+ || v.description.split(/\r?\n/).length > 1) {
+ desc = '\n' + wrap(v.description, { margin: prefix.length, width: this.out.columns });
+ }
+ }
+ }
+
+ return prefix + title + color.gray(desc || '');
+ }
+
+ // shared with autocompleteMultiselect
+ paginateOptions(options) {
+ if (options.length === 0) {
+ return color.red('No matches for this query.');
+ }
+
+ let { startIndex, endIndex } = entriesToDisplay(this.cursor, options.length, this.optionsPerPage);
+ let prefix, styledOptions = [];
+
+ for (let i = startIndex; i < endIndex; i++) {
+ if (i === startIndex && startIndex > 0) {
+ prefix = figures.arrowUp;
+ } else if (i === endIndex - 1 && endIndex < options.length) {
+ prefix = figures.arrowDown;
+ } else {
+ prefix = ' ';
+ }
+ styledOptions.push(this.renderOption(this.cursor, options[i], i, prefix));
+ }
+
+ return '\n' + styledOptions.join('\n');
+ }
+
+ // shared with autocomleteMultiselect
+ renderOptions(options) {
+ if (!this.done) {
+ return this.paginateOptions(options);
+ }
+ return '';
+ }
+
+ renderDoneOrInstructions() {
+ if (this.done) {
+ return this.value
+ .filter(e => e.selected)
+ .map(v => v.title)
+ .join(', ');
+ }
+
+ const output = [color.gray(this.hint), this.renderInstructions()];
+
+ if (this.value[this.cursor].disabled) {
+ output.push(color.yellow(this.warn));
+ }
+ return output.join(' ');
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ super.render();
+
+ // print prompt
+ let prompt = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(false),
+ this.renderDoneOrInstructions()
+ ].join(' ');
+ if (this.showMinError) {
+ prompt += color.red(`You must select a minimum of ${this.minSelected} choices.`);
+ this.showMinError = false;
+ }
+ prompt += this.renderOptions(this.value);
+
+ this.out.write(this.clear + prompt);
+ this.clear = clear(prompt, this.out.columns);
+ }
+}
+
+module.exports = MultiselectPrompt;
diff --git a/node_modules/prompts/lib/elements/number.js b/node_modules/prompts/lib/elements/number.js
new file mode 100644
index 0000000..dc3efe9
--- /dev/null
+++ b/node_modules/prompts/lib/elements/number.js
@@ -0,0 +1,213 @@
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { cursor, erase } = require('sisteransi');
+const { style, figures, clear, lines } = require('../util');
+
+const isNumber = /[0-9]/;
+const isDef = any => any !== undefined;
+const round = (number, precision) => {
+ let factor = Math.pow(10, precision);
+ return Math.round(number * factor) / factor;
+}
+
+/**
+ * NumberPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {String} [opts.style='default'] Render style
+ * @param {Number} [opts.initial] Default value
+ * @param {Number} [opts.max=+Infinity] Max value
+ * @param {Number} [opts.min=-Infinity] Min value
+ * @param {Boolean} [opts.float=false] Parse input as floats
+ * @param {Number} [opts.round=2] Round floats to x decimals
+ * @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
+ * @param {Function} [opts.validate] Validate function
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.error] The invalid error label
+ */
+class NumberPrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.transform = style.render(opts.style);
+ this.msg = opts.message;
+ this.initial = isDef(opts.initial) ? opts.initial : '';
+ this.float = !!opts.float;
+ this.round = opts.round || 2;
+ this.inc = opts.increment || 1;
+ this.min = isDef(opts.min) ? opts.min : -Infinity;
+ this.max = isDef(opts.max) ? opts.max : Infinity;
+ this.errorMsg = opts.error || `Please Enter A Valid Value`;
+ this.validator = opts.validate || (() => true);
+ this.color = `cyan`;
+ this.value = ``;
+ this.typed = ``;
+ this.lastHit = 0;
+ this.render();
+ }
+
+ set value(v) {
+ if (!v && v !== 0) {
+ this.placeholder = true;
+ this.rendered = color.gray(this.transform.render(`${this.initial}`));
+ this._value = ``;
+ } else {
+ this.placeholder = false;
+ this.rendered = this.transform.render(`${round(v, this.round)}`);
+ this._value = round(v, this.round);
+ }
+ this.fire();
+ }
+
+ get value() {
+ return this._value;
+ }
+
+ parse(x) {
+ return this.float ? parseFloat(x) : parseInt(x);
+ }
+
+ valid(c) {
+ return c === `-` || c === `.` && this.float || isNumber.test(c)
+ }
+
+ reset() {
+ this.typed = ``;
+ this.value = ``;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ let x = this.value;
+ this.value = x !== `` ? x : this.initial;
+ this.done = this.aborted = true;
+ this.error = false;
+ this.fire();
+ this.render();
+ this.out.write(`\n`);
+ this.close();
+ }
+
+ async validate() {
+ let valid = await this.validator(this.value);
+ if (typeof valid === `string`) {
+ this.errorMsg = valid;
+ valid = false;
+ }
+ this.error = !valid;
+ }
+
+ async submit() {
+ await this.validate();
+ if (this.error) {
+ this.color = `red`;
+ this.fire();
+ this.render();
+ return;
+ }
+ let x = this.value;
+ this.value = x !== `` ? x : this.initial;
+ this.done = true;
+ this.aborted = false;
+ this.error = false;
+ this.fire();
+ this.render();
+ this.out.write(`\n`);
+ this.close();
+ }
+
+ up() {
+ this.typed = ``;
+ if(this.value === '') {
+ this.value = this.min - this.inc;
+ }
+ if (this.value >= this.max) return this.bell();
+ this.value += this.inc;
+ this.color = `cyan`;
+ this.fire();
+ this.render();
+ }
+
+ down() {
+ this.typed = ``;
+ if(this.value === '') {
+ this.value = this.min + this.inc;
+ }
+ if (this.value <= this.min) return this.bell();
+ this.value -= this.inc;
+ this.color = `cyan`;
+ this.fire();
+ this.render();
+ }
+
+ delete() {
+ let val = this.value.toString();
+ if (val.length === 0) return this.bell();
+ this.value = this.parse((val = val.slice(0, -1))) || ``;
+ if (this.value !== '' && this.value < this.min) {
+ this.value = this.min;
+ }
+ this.color = `cyan`;
+ this.fire();
+ this.render();
+ }
+
+ next() {
+ this.value = this.initial;
+ this.fire();
+ this.render();
+ }
+
+ _(c, key) {
+ if (!this.valid(c)) return this.bell();
+
+ const now = Date.now();
+ if (now - this.lastHit > 1000) this.typed = ``; // 1s elapsed
+ this.typed += c;
+ this.lastHit = now;
+ this.color = `cyan`;
+
+ if (c === `.`) return this.fire();
+
+ this.value = Math.min(this.parse(this.typed), this.max);
+ if (this.value > this.max) this.value = this.max;
+ if (this.value < this.min) this.value = this.min;
+ this.fire();
+ this.render();
+ }
+
+ render() {
+ if (this.closed) return;
+ if (!this.firstRender) {
+ if (this.outputError)
+ this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
+ this.out.write(clear(this.outputText, this.out.columns));
+ }
+ super.render();
+ this.outputError = '';
+
+ // Print prompt
+ this.outputText = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(this.done),
+ !this.done || (!this.done && !this.placeholder)
+ ? color[this.color]().underline(this.rendered) : this.rendered
+ ].join(` `);
+
+ // Print error
+ if (this.error) {
+ this.outputError += this.errorMsg.split(`\n`)
+ .reduce((a, l, i) => a + `\n${i ? ` ` : figures.pointerSmall} ${color.red().italic(l)}`, ``);
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore);
+ }
+}
+
+module.exports = NumberPrompt;
diff --git a/node_modules/prompts/lib/elements/prompt.js b/node_modules/prompts/lib/elements/prompt.js
new file mode 100644
index 0000000..b793330
--- /dev/null
+++ b/node_modules/prompts/lib/elements/prompt.js
@@ -0,0 +1,68 @@
+'use strict';
+
+const readline = require('readline');
+const { action } = require('../util');
+const EventEmitter = require('events');
+const { beep, cursor } = require('sisteransi');
+const color = require('kleur');
+
+/**
+ * Base prompt skeleton
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+class Prompt extends EventEmitter {
+ constructor(opts={}) {
+ super();
+
+ this.firstRender = true;
+ this.in = opts.stdin || process.stdin;
+ this.out = opts.stdout || process.stdout;
+ this.onRender = (opts.onRender || (() => void 0)).bind(this);
+ const rl = readline.createInterface({ input:this.in, escapeCodeTimeout:50 });
+ readline.emitKeypressEvents(this.in, rl);
+
+ if (this.in.isTTY) this.in.setRawMode(true);
+ const isSelect = [ 'SelectPrompt', 'MultiselectPrompt' ].indexOf(this.constructor.name) > -1;
+ const keypress = (str, key) => {
+ let a = action(key, isSelect);
+ if (a === false) {
+ this._ && this._(str, key);
+ } else if (typeof this[a] === 'function') {
+ this[a](key);
+ } else {
+ this.bell();
+ }
+ };
+
+ this.close = () => {
+ this.out.write(cursor.show);
+ this.in.removeListener('keypress', keypress);
+ if (this.in.isTTY) this.in.setRawMode(false);
+ rl.close();
+ this.emit(this.aborted ? 'abort' : this.exited ? 'exit' : 'submit', this.value);
+ this.closed = true;
+ };
+
+ this.in.on('keypress', keypress);
+ }
+
+ fire() {
+ this.emit('state', {
+ value: this.value,
+ aborted: !!this.aborted,
+ exited: !!this.exited
+ });
+ }
+
+ bell() {
+ this.out.write(beep);
+ }
+
+ render() {
+ this.onRender(color);
+ if (this.firstRender) this.firstRender = false;
+ }
+}
+
+module.exports = Prompt;
diff --git a/node_modules/prompts/lib/elements/select.js b/node_modules/prompts/lib/elements/select.js
new file mode 100644
index 0000000..6d6727f
--- /dev/null
+++ b/node_modules/prompts/lib/elements/select.js
@@ -0,0 +1,175 @@
+'use strict';
+
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { style, clear, figures, wrap, entriesToDisplay } = require('../util');
+const { cursor } = require('sisteransi');
+
+/**
+ * SelectPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Array} opts.choices Array of choice objects
+ * @param {String} [opts.hint] Hint to display
+ * @param {Number} [opts.initial] Index of default value
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {Number} [opts.optionsPerPage=10] Max options to display at once
+ */
+class SelectPrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.msg = opts.message;
+ this.hint = opts.hint || '- Use arrow-keys. Return to submit.';
+ this.warn = opts.warn || '- This option is disabled';
+ this.cursor = opts.initial || 0;
+ this.choices = opts.choices.map((ch, idx) => {
+ if (typeof ch === 'string')
+ ch = {title: ch, value: idx};
+ return {
+ title: ch && (ch.title || ch.value || ch),
+ value: ch && (ch.value === undefined ? idx : ch.value),
+ description: ch && ch.description,
+ selected: ch && ch.selected,
+ disabled: ch && ch.disabled
+ };
+ });
+ this.optionsPerPage = opts.optionsPerPage || 10;
+ this.value = (this.choices[this.cursor] || {}).value;
+ this.clear = clear('', this.out.columns);
+ this.render();
+ }
+
+ moveCursor(n) {
+ this.cursor = n;
+ this.value = this.choices[n].value;
+ this.fire();
+ }
+
+ reset() {
+ this.moveCursor(0);
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ if (!this.selection.disabled) {
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ } else
+ this.bell();
+ }
+
+ first() {
+ this.moveCursor(0);
+ this.render();
+ }
+
+ last() {
+ this.moveCursor(this.choices.length - 1);
+ this.render();
+ }
+
+ up() {
+ if (this.cursor === 0) {
+ this.moveCursor(this.choices.length - 1);
+ } else {
+ this.moveCursor(this.cursor - 1);
+ }
+ this.render();
+ }
+
+ down() {
+ if (this.cursor === this.choices.length - 1) {
+ this.moveCursor(0);
+ } else {
+ this.moveCursor(this.cursor + 1);
+ }
+ this.render();
+ }
+
+ next() {
+ this.moveCursor((this.cursor + 1) % this.choices.length);
+ this.render();
+ }
+
+ _(c, key) {
+ if (c === ' ') return this.submit();
+ }
+
+ get selection() {
+ return this.choices[this.cursor];
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ let { startIndex, endIndex } = entriesToDisplay(this.cursor, this.choices.length, this.optionsPerPage);
+
+ // Print prompt
+ this.outputText = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(false),
+ this.done ? this.selection.title : this.selection.disabled
+ ? color.yellow(this.warn) : color.gray(this.hint)
+ ].join(' ');
+
+ // Print choices
+ if (!this.done) {
+ this.outputText += '\n';
+ for (let i = startIndex; i < endIndex; i++) {
+ let title, prefix, desc = '', v = this.choices[i];
+
+ // Determine whether to display "more choices" indicators
+ if (i === startIndex && startIndex > 0) {
+ prefix = figures.arrowUp;
+ } else if (i === endIndex - 1 && endIndex < this.choices.length) {
+ prefix = figures.arrowDown;
+ } else {
+ prefix = ' ';
+ }
+
+ if (v.disabled) {
+ title = this.cursor === i ? color.gray().underline(v.title) : color.strikethrough().gray(v.title);
+ prefix = (this.cursor === i ? color.bold().gray(figures.pointer) + ' ' : ' ') + prefix;
+ } else {
+ title = this.cursor === i ? color.cyan().underline(v.title) : v.title;
+ prefix = (this.cursor === i ? color.cyan(figures.pointer) + ' ' : ' ') + prefix;
+ if (v.description && this.cursor === i) {
+ desc = ` - ${v.description}`;
+ if (prefix.length + title.length + desc.length >= this.out.columns
+ || v.description.split(/\r?\n/).length > 1) {
+ desc = '\n' + wrap(v.description, { margin: 3, width: this.out.columns });
+ }
+ }
+ }
+
+ this.outputText += `${prefix} ${title}${color.gray(desc)}\n`;
+ }
+ }
+
+ this.out.write(this.outputText);
+ }
+}
+
+module.exports = SelectPrompt;
diff --git a/node_modules/prompts/lib/elements/text.js b/node_modules/prompts/lib/elements/text.js
new file mode 100644
index 0000000..ee78181
--- /dev/null
+++ b/node_modules/prompts/lib/elements/text.js
@@ -0,0 +1,208 @@
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { erase, cursor } = require('sisteransi');
+const { style, clear, lines, figures } = require('../util');
+
+/**
+ * TextPrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {String} [opts.style='default'] Render style
+ * @param {String} [opts.initial] Default value
+ * @param {Function} [opts.validate] Validate function
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ * @param {String} [opts.error] The invalid error label
+ */
+class TextPrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.transform = style.render(opts.style);
+ this.scale = this.transform.scale;
+ this.msg = opts.message;
+ this.initial = opts.initial || ``;
+ this.validator = opts.validate || (() => true);
+ this.value = ``;
+ this.errorMsg = opts.error || `Please Enter A Valid Value`;
+ this.cursor = Number(!!this.initial);
+ this.cursorOffset = 0;
+ this.clear = clear(``, this.out.columns);
+ this.render();
+ }
+
+ set value(v) {
+ if (!v && this.initial) {
+ this.placeholder = true;
+ this.rendered = color.gray(this.transform.render(this.initial));
+ } else {
+ this.placeholder = false;
+ this.rendered = this.transform.render(v);
+ }
+ this._value = v;
+ this.fire();
+ }
+
+ get value() {
+ return this._value;
+ }
+
+ reset() {
+ this.value = ``;
+ this.cursor = Number(!!this.initial);
+ this.cursorOffset = 0;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.value = this.value || this.initial;
+ this.done = this.aborted = true;
+ this.error = false;
+ this.red = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ async validate() {
+ let valid = await this.validator(this.value);
+ if (typeof valid === `string`) {
+ this.errorMsg = valid;
+ valid = false;
+ }
+ this.error = !valid;
+ }
+
+ async submit() {
+ this.value = this.value || this.initial;
+ this.cursorOffset = 0;
+ this.cursor = this.rendered.length;
+ await this.validate();
+ if (this.error) {
+ this.red = true;
+ this.fire();
+ this.render();
+ return;
+ }
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ next() {
+ if (!this.placeholder) return this.bell();
+ this.value = this.initial;
+ this.cursor = this.rendered.length;
+ this.fire();
+ this.render();
+ }
+
+ moveCursor(n) {
+ if (this.placeholder) return;
+ this.cursor = this.cursor+n;
+ this.cursorOffset += n;
+ }
+
+ _(c, key) {
+ let s1 = this.value.slice(0, this.cursor);
+ let s2 = this.value.slice(this.cursor);
+ this.value = `${s1}${c}${s2}`;
+ this.red = false;
+ this.cursor = this.placeholder ? 0 : s1.length+1;
+ this.render();
+ }
+
+ delete() {
+ if (this.isCursorAtStart()) return this.bell();
+ let s1 = this.value.slice(0, this.cursor-1);
+ let s2 = this.value.slice(this.cursor);
+ this.value = `${s1}${s2}`;
+ this.red = false;
+ if (this.isCursorAtStart()) {
+ this.cursorOffset = 0
+ } else {
+ this.cursorOffset++;
+ this.moveCursor(-1);
+ }
+ this.render();
+ }
+
+ deleteForward() {
+ if(this.cursor*this.scale >= this.rendered.length || this.placeholder) return this.bell();
+ let s1 = this.value.slice(0, this.cursor);
+ let s2 = this.value.slice(this.cursor+1);
+ this.value = `${s1}${s2}`;
+ this.red = false;
+ if (this.isCursorAtEnd()) {
+ this.cursorOffset = 0;
+ } else {
+ this.cursorOffset++;
+ }
+ this.render();
+ }
+
+ first() {
+ this.cursor = 0;
+ this.render();
+ }
+
+ last() {
+ this.cursor = this.value.length;
+ this.render();
+ }
+
+ left() {
+ if (this.cursor <= 0 || this.placeholder) return this.bell();
+ this.moveCursor(-1);
+ this.render();
+ }
+
+ right() {
+ if (this.cursor*this.scale >= this.rendered.length || this.placeholder) return this.bell();
+ this.moveCursor(1);
+ this.render();
+ }
+
+ isCursorAtStart() {
+ return this.cursor === 0 || (this.placeholder && this.cursor === 1);
+ }
+
+ isCursorAtEnd() {
+ return this.cursor === this.rendered.length || (this.placeholder && this.cursor === this.rendered.length + 1)
+ }
+
+ render() {
+ if (this.closed) return;
+ if (!this.firstRender) {
+ if (this.outputError)
+ this.out.write(cursor.down(lines(this.outputError, this.out.columns) - 1) + clear(this.outputError, this.out.columns));
+ this.out.write(clear(this.outputText, this.out.columns));
+ }
+ super.render();
+ this.outputError = '';
+
+ this.outputText = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(this.done),
+ this.red ? color.red(this.rendered) : this.rendered
+ ].join(` `);
+
+ if (this.error) {
+ this.outputError += this.errorMsg.split(`\n`)
+ .reduce((a, l, i) => a + `\n${i ? ' ' : figures.pointerSmall} ${color.red().italic(l)}`, ``);
+ }
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText + cursor.save + this.outputError + cursor.restore + cursor.move(this.cursorOffset, 0));
+ }
+}
+
+module.exports = TextPrompt;
\ No newline at end of file
diff --git a/node_modules/prompts/lib/elements/toggle.js b/node_modules/prompts/lib/elements/toggle.js
new file mode 100644
index 0000000..bad612c
--- /dev/null
+++ b/node_modules/prompts/lib/elements/toggle.js
@@ -0,0 +1,118 @@
+const color = require('kleur');
+const Prompt = require('./prompt');
+const { style, clear } = require('../util');
+const { cursor, erase } = require('sisteransi');
+
+/**
+ * TogglePrompt Base Element
+ * @param {Object} opts Options
+ * @param {String} opts.message Message
+ * @param {Boolean} [opts.initial=false] Default value
+ * @param {String} [opts.active='no'] Active label
+ * @param {String} [opts.inactive='off'] Inactive label
+ * @param {Stream} [opts.stdin] The Readable stream to listen to
+ * @param {Stream} [opts.stdout] The Writable stream to write readline data to
+ */
+class TogglePrompt extends Prompt {
+ constructor(opts={}) {
+ super(opts);
+ this.msg = opts.message;
+ this.value = !!opts.initial;
+ this.active = opts.active || 'on';
+ this.inactive = opts.inactive || 'off';
+ this.initialValue = this.value;
+ this.render();
+ }
+
+ reset() {
+ this.value = this.initialValue;
+ this.fire();
+ this.render();
+ }
+
+ exit() {
+ this.abort();
+ }
+
+ abort() {
+ this.done = this.aborted = true;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ submit() {
+ this.done = true;
+ this.aborted = false;
+ this.fire();
+ this.render();
+ this.out.write('\n');
+ this.close();
+ }
+
+ deactivate() {
+ if (this.value === false) return this.bell();
+ this.value = false;
+ this.render();
+ }
+
+ activate() {
+ if (this.value === true) return this.bell();
+ this.value = true;
+ this.render();
+ }
+
+ delete() {
+ this.deactivate();
+ }
+ left() {
+ this.deactivate();
+ }
+ right() {
+ this.activate();
+ }
+ down() {
+ this.deactivate();
+ }
+ up() {
+ this.activate();
+ }
+
+ next() {
+ this.value = !this.value;
+ this.fire();
+ this.render();
+ }
+
+ _(c, key) {
+ if (c === ' ') {
+ this.value = !this.value;
+ } else if (c === '1') {
+ this.value = true;
+ } else if (c === '0') {
+ this.value = false;
+ } else return this.bell();
+ this.render();
+ }
+
+ render() {
+ if (this.closed) return;
+ if (this.firstRender) this.out.write(cursor.hide);
+ else this.out.write(clear(this.outputText, this.out.columns));
+ super.render();
+
+ this.outputText = [
+ style.symbol(this.done, this.aborted),
+ color.bold(this.msg),
+ style.delimiter(this.done),
+ this.value ? this.inactive : color.cyan().underline(this.inactive),
+ color.gray('/'),
+ this.value ? color.cyan().underline(this.active) : this.active
+ ].join(' ');
+
+ this.out.write(erase.line + cursor.to(0) + this.outputText);
+ }
+}
+
+module.exports = TogglePrompt;
diff --git a/node_modules/prompts/lib/index.js b/node_modules/prompts/lib/index.js
new file mode 100644
index 0000000..a5374d5
--- /dev/null
+++ b/node_modules/prompts/lib/index.js
@@ -0,0 +1,98 @@
+'use strict';
+
+const prompts = require('./prompts');
+
+const passOn = ['suggest', 'format', 'onState', 'validate', 'onRender', 'type'];
+const noop = () => {};
+
+/**
+ * Prompt for a series of questions
+ * @param {Array|Object} questions Single question object or Array of question objects
+ * @param {Function} [onSubmit] Callback function called on prompt submit
+ * @param {Function} [onCancel] Callback function called on cancel/abort
+ * @returns {Object} Object with values from user input
+ */
+async function prompt(questions=[], { onSubmit=noop, onCancel=noop }={}) {
+ const answers = {};
+ const override = prompt._override || {};
+ questions = [].concat(questions);
+ let answer, question, quit, name, type, lastPrompt;
+
+ const getFormattedAnswer = async (question, answer, skipValidation = false) => {
+ if (!skipValidation && question.validate && question.validate(answer) !== true) {
+ return;
+ }
+ return question.format ? await question.format(answer, answers) : answer
+ };
+
+ for (question of questions) {
+ ({ name, type } = question);
+
+ // evaluate type first and skip if type is a falsy value
+ if (typeof type === 'function') {
+ type = await type(answer, { ...answers }, question)
+ question['type'] = type
+ }
+ if (!type) continue;
+
+ // if property is a function, invoke it unless it's a special function
+ for (let key in question) {
+ if (passOn.includes(key)) continue;
+ let value = question[key];
+ question[key] = typeof value === 'function' ? await value(answer, { ...answers }, lastPrompt) : value;
+ }
+
+ lastPrompt = question;
+
+ if (typeof question.message !== 'string') {
+ throw new Error('prompt message is required');
+ }
+
+ // update vars in case they changed
+ ({ name, type } = question);
+
+ if (prompts[type] === void 0) {
+ throw new Error(`prompt type (${type}) is not defined`);
+ }
+
+ if (override[question.name] !== undefined) {
+ answer = await getFormattedAnswer(question, override[question.name]);
+ if (answer !== undefined) {
+ answers[name] = answer;
+ continue;
+ }
+ }
+
+ try {
+ // Get the injected answer if there is one or prompt the user
+ answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : await prompts[type](question);
+ answers[name] = answer = await getFormattedAnswer(question, answer, true);
+ quit = await onSubmit(question, answer, answers);
+ } catch (err) {
+ quit = !(await onCancel(question, answers));
+ }
+
+ if (quit) return answers;
+ }
+
+ return answers;
+}
+
+function getInjectedAnswer(injected, deafultValue) {
+ const answer = injected.shift();
+ if (answer instanceof Error) {
+ throw answer;
+ }
+
+ return (answer === undefined) ? deafultValue : answer;
+}
+
+function inject(answers) {
+ prompt._injected = (prompt._injected || []).concat(answers);
+}
+
+function override(answers) {
+ prompt._override = Object.assign({}, answers);
+}
+
+module.exports = Object.assign(prompt, { prompt, prompts, inject, override });
diff --git a/node_modules/prompts/lib/prompts.js b/node_modules/prompts/lib/prompts.js
new file mode 100644
index 0000000..9f62556
--- /dev/null
+++ b/node_modules/prompts/lib/prompts.js
@@ -0,0 +1,206 @@
+'use strict';
+const $ = exports;
+const el = require('./elements');
+const noop = v => v;
+
+function toPrompt(type, args, opts={}) {
+ return new Promise((res, rej) => {
+ const p = new el[type](args);
+ const onAbort = opts.onAbort || noop;
+ const onSubmit = opts.onSubmit || noop;
+ const onExit = opts.onExit || noop;
+ p.on('state', args.onState || noop);
+ p.on('submit', x => res(onSubmit(x)));
+ p.on('exit', x => res(onExit(x)));
+ p.on('abort', x => rej(onAbort(x)));
+ });
+}
+
+/**
+ * Text prompt
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {function} [args.onState] On state change callback
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.text = args => toPrompt('TextPrompt', args);
+
+/**
+ * Password prompt with masked input
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {function} [args.onState] On state change callback
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.password = args => {
+ args.style = 'password';
+ return $.text(args);
+};
+
+/**
+ * Prompt where input is invisible, like sudo
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {function} [args.onState] On state change callback
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.invisible = args => {
+ args.style = 'invisible';
+ return $.text(args);
+};
+
+/**
+ * Number prompt
+ * @param {string} args.message Prompt message to display
+ * @param {number} args.initial Default number value
+ * @param {function} [args.onState] On state change callback
+ * @param {number} [args.max] Max value
+ * @param {number} [args.min] Min value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {Boolean} [opts.float=false] Parse input as floats
+ * @param {Number} [opts.round=2] Round floats to x decimals
+ * @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.number = args => toPrompt('NumberPrompt', args);
+
+/**
+ * Date prompt
+ * @param {string} args.message Prompt message to display
+ * @param {number} args.initial Default number value
+ * @param {function} [args.onState] On state change callback
+ * @param {number} [args.max] Max value
+ * @param {number} [args.min] Min value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {Boolean} [opts.float=false] Parse input as floats
+ * @param {Number} [opts.round=2] Round floats to x decimals
+ * @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
+ * @param {function} [args.validate] Function to validate user input
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.date = args => toPrompt('DatePrompt', args);
+
+/**
+ * Classic yes/no prompt
+ * @param {string} args.message Prompt message to display
+ * @param {boolean} [args.initial=false] Default value
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.confirm = args => toPrompt('ConfirmPrompt', args);
+
+/**
+ * List prompt, split intput string by `seperator`
+ * @param {string} args.message Prompt message to display
+ * @param {string} [args.initial] Default string value
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {string} [args.separator] String separator
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input, in form of an `Array`
+ */
+$.list = args => {
+ const sep = args.separator || ',';
+ return toPrompt('TextPrompt', args, {
+ onSubmit: str => str.split(sep).map(s => s.trim())
+ });
+};
+
+/**
+ * Toggle/switch prompt
+ * @param {string} args.message Prompt message to display
+ * @param {boolean} [args.initial=false] Default value
+ * @param {string} [args.active="on"] Text for `active` state
+ * @param {string} [args.inactive="off"] Text for `inactive` state
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.toggle = args => toPrompt('TogglePrompt', args);
+
+/**
+ * Interactive select prompt
+ * @param {string} args.message Prompt message to display
+ * @param {Array} args.choices Array of choices objects `[{ title, value }, ...]`
+ * @param {number} [args.initial] Index of default value
+ * @param {String} [args.hint] Hint to display
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.select = args => toPrompt('SelectPrompt', args);
+
+/**
+ * Interactive multi-select / autocompleteMultiselect prompt
+ * @param {string} args.message Prompt message to display
+ * @param {Array} args.choices Array of choices objects `[{ title, value, [selected] }, ...]`
+ * @param {number} [args.max] Max select
+ * @param {string} [args.hint] Hint to display user
+ * @param {Number} [args.cursor=0] Cursor start position
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.multiselect = args => {
+ args.choices = [].concat(args.choices || []);
+ const toSelected = items => items.filter(item => item.selected).map(item => item.value);
+ return toPrompt('MultiselectPrompt', args, {
+ onAbort: toSelected,
+ onSubmit: toSelected
+ });
+};
+
+$.autocompleteMultiselect = args => {
+ args.choices = [].concat(args.choices || []);
+ const toSelected = items => items.filter(item => item.selected).map(item => item.value);
+ return toPrompt('AutocompleteMultiselectPrompt', args, {
+ onAbort: toSelected,
+ onSubmit: toSelected
+ });
+};
+
+const byTitle = (input, choices) => Promise.resolve(
+ choices.filter(item => item.title.slice(0, input.length).toLowerCase() === input.toLowerCase())
+);
+
+/**
+ * Interactive auto-complete prompt
+ * @param {string} args.message Prompt message to display
+ * @param {Array} args.choices Array of auto-complete choices objects `[{ title, value }, ...]`
+ * @param {Function} [args.suggest] Function to filter results based on user input. Defaults to sort by `title`
+ * @param {number} [args.limit=10] Max number of results to show
+ * @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
+ * @param {String} [args.initial] Index of the default value
+ * @param {boolean} [opts.clearFirst] The first ESCAPE keypress will clear the input
+ * @param {String} [args.fallback] Fallback message - defaults to initial value
+ * @param {function} [args.onState] On state change callback
+ * @param {Stream} [args.stdin] The Readable stream to listen to
+ * @param {Stream} [args.stdout] The Writable stream to write readline data to
+ * @returns {Promise} Promise with user input
+ */
+$.autocomplete = args => {
+ args.suggest = args.suggest || byTitle;
+ args.choices = [].concat(args.choices || []);
+ return toPrompt('AutocompletePrompt', args);
+};
diff --git a/node_modules/prompts/lib/util/action.js b/node_modules/prompts/lib/util/action.js
new file mode 100644
index 0000000..fefbd94
--- /dev/null
+++ b/node_modules/prompts/lib/util/action.js
@@ -0,0 +1,39 @@
+'use strict';
+
+module.exports = (key, isSelect) => {
+ if (key.meta && key.name !== 'escape') return;
+
+ if (key.ctrl) {
+ if (key.name === 'a') return 'first';
+ if (key.name === 'c') return 'abort';
+ if (key.name === 'd') return 'abort';
+ if (key.name === 'e') return 'last';
+ if (key.name === 'g') return 'reset';
+ }
+
+ if (isSelect) {
+ if (key.name === 'j') return 'down';
+ if (key.name === 'k') return 'up';
+ }
+
+ if (key.name === 'return') return 'submit';
+ if (key.name === 'enter') return 'submit'; // ctrl + J
+ if (key.name === 'backspace') return 'delete';
+ if (key.name === 'delete') return 'deleteForward';
+ if (key.name === 'abort') return 'abort';
+ if (key.name === 'escape') return 'exit';
+ if (key.name === 'tab') return 'next';
+ if (key.name === 'pagedown') return 'nextPage';
+ if (key.name === 'pageup') return 'prevPage';
+ // TODO create home() in prompt types (e.g. TextPrompt)
+ if (key.name === 'home') return 'home';
+ // TODO create end() in prompt types (e.g. TextPrompt)
+ if (key.name === 'end') return 'end';
+
+ if (key.name === 'up') return 'up';
+ if (key.name === 'down') return 'down';
+ if (key.name === 'right') return 'right';
+ if (key.name === 'left') return 'left';
+
+ return false;
+};
diff --git a/node_modules/prompts/lib/util/clear.js b/node_modules/prompts/lib/util/clear.js
new file mode 100644
index 0000000..e4772d5
--- /dev/null
+++ b/node_modules/prompts/lib/util/clear.js
@@ -0,0 +1,22 @@
+'use strict';
+
+const strip = require('./strip');
+const { erase, cursor } = require('sisteransi');
+
+const width = str => [...strip(str)].length;
+
+/**
+ * @param {string} prompt
+ * @param {number} perLine
+ */
+module.exports = function(prompt, perLine) {
+ if (!perLine) return erase.line + cursor.to(0);
+
+ let rows = 0;
+ const lines = prompt.split(/\r?\n/);
+ for (let line of lines) {
+ rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / perLine);
+ }
+
+ return erase.lines(rows);
+};
diff --git a/node_modules/prompts/lib/util/entriesToDisplay.js b/node_modules/prompts/lib/util/entriesToDisplay.js
new file mode 100644
index 0000000..5f6efbb
--- /dev/null
+++ b/node_modules/prompts/lib/util/entriesToDisplay.js
@@ -0,0 +1,21 @@
+'use strict';
+
+/**
+ * Determine what entries should be displayed on the screen, based on the
+ * currently selected index and the maximum visible. Used in list-based
+ * prompts like `select` and `multiselect`.
+ *
+ * @param {number} cursor the currently selected entry
+ * @param {number} total the total entries available to display
+ * @param {number} [maxVisible] the number of entries that can be displayed
+ */
+module.exports = (cursor, total, maxVisible) => {
+ maxVisible = maxVisible || total;
+
+ let startIndex = Math.min(total- maxVisible, cursor - Math.floor(maxVisible / 2));
+ if (startIndex < 0) startIndex = 0;
+
+ let endIndex = Math.min(startIndex + maxVisible, total);
+
+ return { startIndex, endIndex };
+};
diff --git a/node_modules/prompts/lib/util/figures.js b/node_modules/prompts/lib/util/figures.js
new file mode 100644
index 0000000..cd31b88
--- /dev/null
+++ b/node_modules/prompts/lib/util/figures.js
@@ -0,0 +1,33 @@
+'use strict';
+
+ const main = {
+ arrowUp: '↑',
+ arrowDown: '↓',
+ arrowLeft: '←',
+ arrowRight: '→',
+ radioOn: '◉',
+ radioOff: '◯',
+ tick: '✔',
+ cross: '✖',
+ ellipsis: '…',
+ pointerSmall: '›',
+ line: '─',
+ pointer: '❯'
+};
+const win = {
+ arrowUp: main.arrowUp,
+ arrowDown: main.arrowDown,
+ arrowLeft: main.arrowLeft,
+ arrowRight: main.arrowRight,
+ radioOn: '(*)',
+ radioOff: '( )',
+ tick: '√',
+ cross: '×',
+ ellipsis: '...',
+ pointerSmall: '»',
+ line: '─',
+ pointer: '>'
+};
+const figures = process.platform === 'win32' ? win : main;
+
+ module.exports = figures;
diff --git a/node_modules/prompts/lib/util/index.js b/node_modules/prompts/lib/util/index.js
new file mode 100644
index 0000000..f815986
--- /dev/null
+++ b/node_modules/prompts/lib/util/index.js
@@ -0,0 +1,12 @@
+'use strict';
+
+module.exports = {
+ action: require('./action'),
+ clear: require('./clear'),
+ style: require('./style'),
+ strip: require('./strip'),
+ figures: require('./figures'),
+ lines: require('./lines'),
+ wrap: require('./wrap'),
+ entriesToDisplay: require('./entriesToDisplay')
+};
diff --git a/node_modules/prompts/lib/util/lines.js b/node_modules/prompts/lib/util/lines.js
new file mode 100644
index 0000000..de30419
--- /dev/null
+++ b/node_modules/prompts/lib/util/lines.js
@@ -0,0 +1,15 @@
+'use strict';
+
+const strip = require('./strip');
+
+/**
+ * @param {string} msg
+ * @param {number} perLine
+ */
+module.exports = function (msg, perLine) {
+ let lines = String(strip(msg) || '').split(/\r?\n/);
+
+ if (!perLine) return lines.length;
+ return lines.map(l => Math.ceil(l.length / perLine))
+ .reduce((a, b) => a + b);
+};
diff --git a/node_modules/prompts/lib/util/strip.js b/node_modules/prompts/lib/util/strip.js
new file mode 100644
index 0000000..8ebf4cb
--- /dev/null
+++ b/node_modules/prompts/lib/util/strip.js
@@ -0,0 +1,11 @@
+'use strict';
+
+module.exports = str => {
+ const pattern = [
+ '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
+ '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))'
+ ].join('|');
+
+ const RGX = new RegExp(pattern, 'g');
+ return typeof str === 'string' ? str.replace(RGX, '') : str;
+};
diff --git a/node_modules/prompts/lib/util/style.js b/node_modules/prompts/lib/util/style.js
new file mode 100644
index 0000000..1851cc7
--- /dev/null
+++ b/node_modules/prompts/lib/util/style.js
@@ -0,0 +1,40 @@
+'use strict';
+
+const c = require('kleur');
+const figures = require('./figures');
+
+// rendering user input.
+const styles = Object.freeze({
+ password: { scale: 1, render: input => '*'.repeat(input.length) },
+ emoji: { scale: 2, render: input => '😃'.repeat(input.length) },
+ invisible: { scale: 0, render: input => '' },
+ default: { scale: 1, render: input => `${input}` }
+});
+const render = type => styles[type] || styles.default;
+
+// icon to signalize a prompt.
+const symbols = Object.freeze({
+ aborted: c.red(figures.cross),
+ done: c.green(figures.tick),
+ exited: c.yellow(figures.cross),
+ default: c.cyan('?')
+});
+
+const symbol = (done, aborted, exited) =>
+ aborted ? symbols.aborted : exited ? symbols.exited : done ? symbols.done : symbols.default;
+
+// between the question and the user's input.
+const delimiter = completing =>
+ c.gray(completing ? figures.ellipsis : figures.pointerSmall);
+
+const item = (expandable, expanded) =>
+ c.gray(expandable ? (expanded ? figures.pointerSmall : '+') : figures.line);
+
+module.exports = {
+ styles,
+ render,
+ symbols,
+ symbol,
+ delimiter,
+ item
+};
diff --git a/node_modules/prompts/lib/util/wrap.js b/node_modules/prompts/lib/util/wrap.js
new file mode 100644
index 0000000..43b5399
--- /dev/null
+++ b/node_modules/prompts/lib/util/wrap.js
@@ -0,0 +1,27 @@
+'use strict';
+
+/**
+ * @param {string} msg The message to wrap
+ * @param {object} opts
+ * @param {number|string} [opts.margin] Left margin
+ * @param {number} opts.width Maximum characters per line including the margin
+ */
+module.exports = (msg, opts = {}) => {
+ const tab = Number.isSafeInteger(parseInt(opts.margin))
+ ? new Array(parseInt(opts.margin)).fill(' ').join('')
+ : (opts.margin || '');
+
+ const width = opts.width;
+
+ return (msg || '').split(/\r?\n/g)
+ .map(line => line
+ .split(/\s+/g)
+ .reduce((arr, w) => {
+ if (w.length + tab.length >= width || arr[arr.length - 1].length + w.length + 1 < width)
+ arr[arr.length - 1] += ` ${w}`;
+ else arr.push(`${tab}${w}`);
+ return arr;
+ }, [ tab ])
+ .join('\n'))
+ .join('\n');
+};
diff --git a/node_modules/prompts/license b/node_modules/prompts/license
new file mode 100644
index 0000000..13dc83c
--- /dev/null
+++ b/node_modules/prompts/license
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Terkel Gjervig Nielsen
+
+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.
diff --git a/node_modules/prompts/node_modules/kleur/index.js b/node_modules/prompts/node_modules/kleur/index.js
new file mode 100644
index 0000000..0bc6ec9
--- /dev/null
+++ b/node_modules/prompts/node_modules/kleur/index.js
@@ -0,0 +1,104 @@
+'use strict';
+
+const { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = process.env;
+
+const $ = {
+ enabled: !NODE_DISABLE_COLORS && TERM !== 'dumb' && FORCE_COLOR !== '0',
+
+ // modifiers
+ reset: init(0, 0),
+ bold: init(1, 22),
+ dim: init(2, 22),
+ italic: init(3, 23),
+ underline: init(4, 24),
+ inverse: init(7, 27),
+ hidden: init(8, 28),
+ strikethrough: init(9, 29),
+
+ // colors
+ black: init(30, 39),
+ red: init(31, 39),
+ green: init(32, 39),
+ yellow: init(33, 39),
+ blue: init(34, 39),
+ magenta: init(35, 39),
+ cyan: init(36, 39),
+ white: init(37, 39),
+ gray: init(90, 39),
+ grey: init(90, 39),
+
+ // background colors
+ bgBlack: init(40, 49),
+ bgRed: init(41, 49),
+ bgGreen: init(42, 49),
+ bgYellow: init(43, 49),
+ bgBlue: init(44, 49),
+ bgMagenta: init(45, 49),
+ bgCyan: init(46, 49),
+ bgWhite: init(47, 49)
+};
+
+function run(arr, str) {
+ let i=0, tmp, beg='', end='';
+ for (; i < arr.length; i++) {
+ tmp = arr[i];
+ beg += tmp.open;
+ end += tmp.close;
+ if (str.includes(tmp.close)) {
+ str = str.replace(tmp.rgx, tmp.close + tmp.open);
+ }
+ }
+ return beg + str + end;
+}
+
+function chain(has, keys) {
+ let ctx = { has, keys };
+
+ ctx.reset = $.reset.bind(ctx);
+ ctx.bold = $.bold.bind(ctx);
+ ctx.dim = $.dim.bind(ctx);
+ ctx.italic = $.italic.bind(ctx);
+ ctx.underline = $.underline.bind(ctx);
+ ctx.inverse = $.inverse.bind(ctx);
+ ctx.hidden = $.hidden.bind(ctx);
+ ctx.strikethrough = $.strikethrough.bind(ctx);
+
+ ctx.black = $.black.bind(ctx);
+ ctx.red = $.red.bind(ctx);
+ ctx.green = $.green.bind(ctx);
+ ctx.yellow = $.yellow.bind(ctx);
+ ctx.blue = $.blue.bind(ctx);
+ ctx.magenta = $.magenta.bind(ctx);
+ ctx.cyan = $.cyan.bind(ctx);
+ ctx.white = $.white.bind(ctx);
+ ctx.gray = $.gray.bind(ctx);
+ ctx.grey = $.grey.bind(ctx);
+
+ ctx.bgBlack = $.bgBlack.bind(ctx);
+ ctx.bgRed = $.bgRed.bind(ctx);
+ ctx.bgGreen = $.bgGreen.bind(ctx);
+ ctx.bgYellow = $.bgYellow.bind(ctx);
+ ctx.bgBlue = $.bgBlue.bind(ctx);
+ ctx.bgMagenta = $.bgMagenta.bind(ctx);
+ ctx.bgCyan = $.bgCyan.bind(ctx);
+ ctx.bgWhite = $.bgWhite.bind(ctx);
+
+ return ctx;
+}
+
+function init(open, close) {
+ let blk = {
+ open: `\x1b[${open}m`,
+ close: `\x1b[${close}m`,
+ rgx: new RegExp(`\\x1b\\[${close}m`, 'g')
+ };
+ return function (txt) {
+ if (this !== void 0 && this.has !== void 0) {
+ this.has.includes(open) || (this.has.push(open),this.keys.push(blk));
+ return txt === void 0 ? this : $.enabled ? run(this.keys, txt+'') : txt+'';
+ }
+ return txt === void 0 ? chain([open], [blk]) : $.enabled ? run([blk], txt+'') : txt+'';
+ };
+}
+
+module.exports = $;
diff --git a/node_modules/prompts/node_modules/kleur/kleur.d.ts b/node_modules/prompts/node_modules/kleur/kleur.d.ts
new file mode 100644
index 0000000..fdc26ca
--- /dev/null
+++ b/node_modules/prompts/node_modules/kleur/kleur.d.ts
@@ -0,0 +1,45 @@
+// Originally by: Rogier Schouten
+// Adapted by: Madhav Varshney
+declare namespace kleur {
+ interface Color {
+ (x: string | number): string;
+ (): Kleur;
+ }
+
+ interface Kleur {
+ // Colors
+ black: Color;
+ red: Color;
+ green: Color;
+ yellow: Color;
+ blue: Color;
+ magenta: Color;
+ cyan: Color;
+ white: Color;
+ gray: Color;
+ grey: Color;
+
+ // Backgrounds
+ bgBlack: Color;
+ bgRed: Color;
+ bgGreen: Color;
+ bgYellow: Color;
+ bgBlue: Color;
+ bgMagenta: Color;
+ bgCyan: Color;
+ bgWhite: Color;
+
+ // Modifiers
+ reset: Color;
+ bold: Color;
+ dim: Color;
+ italic: Color;
+ underline: Color;
+ inverse: Color;
+ hidden: Color;
+ strikethrough: Color;
+ }
+}
+
+declare let kleur: kleur.Kleur & { enabled: boolean };
+export = kleur;
diff --git a/node_modules/prompts/node_modules/kleur/license b/node_modules/prompts/node_modules/kleur/license
new file mode 100644
index 0000000..a3f96f8
--- /dev/null
+++ b/node_modules/prompts/node_modules/kleur/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Luke Edwards (lukeed.com)
+
+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.
diff --git a/node_modules/prompts/node_modules/kleur/package.json b/node_modules/prompts/node_modules/kleur/package.json
new file mode 100644
index 0000000..a81931e
--- /dev/null
+++ b/node_modules/prompts/node_modules/kleur/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "kleur",
+ "version": "3.0.3",
+ "repository": "lukeed/kleur",
+ "description": "The fastest Node.js library for formatting terminal text with ANSI colors~!",
+ "license": "MIT",
+ "files": [
+ "*.js",
+ "*.d.ts"
+ ],
+ "author": {
+ "name": "Luke Edwards",
+ "email": "luke.edwards05@gmail.com",
+ "url": "lukeed.com"
+ },
+ "scripts": {
+ "test": "tape test/*.js | tap-spec"
+ },
+ "engines": {
+ "node": ">=6"
+ },
+ "keywords": [
+ "ansi",
+ "cli",
+ "color",
+ "colors",
+ "console",
+ "terminal"
+ ],
+ "types": "kleur.d.ts",
+ "devDependencies": {
+ "tap-spec": "^5.0.0",
+ "tape": "^4.9.1"
+ }
+}
diff --git a/node_modules/prompts/node_modules/kleur/readme.md b/node_modules/prompts/node_modules/kleur/readme.md
new file mode 100644
index 0000000..6926f1e
--- /dev/null
+++ b/node_modules/prompts/node_modules/kleur/readme.md
@@ -0,0 +1,172 @@
+
+
+
+
+
+
+The fastest Node.js library for formatting terminal text with ANSI colors~!
+
+## Features
+
+* No dependencies
+* Super [lightweight](#load-time) & [performant](#performance)
+* Supports [nested](#nested-methods) & [chained](#chained-methods) colors
+* No `String.prototype` modifications
+* Conditional [color support](#conditional-support)
+* Familiar [API](#api)
+
+---
+
+As of `v3.0` the Chalk-style syntax (magical getter) is no longer used. If you need or require that syntax, consider using [`ansi-colors`](https://github.com/doowb/ansi-colors), which maintains `chalk` parity.
+
+---
+
+
+## Install
+
+```
+$ npm install --save kleur
+```
+
+
+## Usage
+
+```js
+const { red, white, blue, bold } = require('kleur');
+
+// basic usage
+red('red text');
+
+// chained methods
+blue().bold().underline('howdy partner');
+
+// nested methods
+bold(`${ white().bgRed('[ERROR]') } ${ red().italic('Something happened')}`);
+```
+
+### Chained Methods
+
+```js
+console.log(bold().red('this is a bold red message'));
+console.log(bold().italic('this is a bold italicized message'));
+console.log(bold().yellow().bgRed().italic('this is a bold yellow italicized message'));
+console.log(green().bold().underline('this is a bold green underlined message'));
+```
+
+
+
+### Nested Methods
+
+```js
+const { yellow, red, cyan } = require('kleur');
+
+console.log(yellow(`foo ${red().bold('red')} bar ${cyan('cyan')} baz`));
+console.log(yellow('foo ' + red().bold('red') + ' bar ' + cyan('cyan') + ' baz'));
+```
+
+
+
+
+### Conditional Support
+
+Toggle color support as needed; `kleur` includes simple auto-detection which may not cover all cases.
+
+```js
+const kleur = require('kleur');
+
+// manually disable
+kleur.enabled = false;
+
+// or use another library to detect support
+kleur.enabled = require('color-support').level;
+
+console.log(kleur.red('I will only be colored red if the terminal supports colors'));
+```
+
+
+## API
+
+Any `kleur` method returns a `String` when invoked with input; otherwise chaining is expected.
+
+> It's up to the developer to pass the output to destinations like `console.log`, `process.stdout.write`, etc.
+
+The methods below are grouped by type for legibility purposes only. They each can be [chained](#chained-methods) or [nested](#nested-methods) with one another.
+
+***Colors:***
+> black — red — green — yellow — blue — magenta — cyan — white — gray — grey
+
+***Backgrounds:***
+> bgBlack — bgRed — bgGreen — bgYellow — bgBlue — bgMagenta — bgCyan — bgWhite
+
+***Modifiers:***
+> reset — bold — dim — italic* — underline — inverse — hidden — strikethrough*
+
+* Not widely supported
+
+
+## Benchmarks
+
+> Using Node v10.13.0
+
+### Load time
+
+```
+chalk :: 14.543ms
+kleur :: 0.474ms
+ansi-colors :: 1.923ms
+```
+
+### Performance
+
+```
+# All Colors
+ ansi-colors x 199,381 ops/sec ±1.04% (96 runs sampled)
+ chalk x 12,107 ops/sec ±2.07% (87 runs sampled)
+ kleur x 715,334 ops/sec ±0.30% (93 runs sampled)
+
+# Stacked colors
+ ansi-colors x 24,494 ops/sec ±1.03% (93 runs sampled)
+ chalk x 2,650 ops/sec ±2.06% (85 runs sampled)
+ kleur x 75,798 ops/sec ±0.19% (97 runs sampled)
+
+# Nested colors
+ ansi-colors x 77,766 ops/sec ±0.32% (94 runs sampled)
+ chalk x 5,596 ops/sec ±1.85% (86 runs sampled)
+ kleur x 137,660 ops/sec ±0.31% (93 runs sampled)
+```
+
+
+## Credits
+
+This project originally forked [Brian Woodward](https://github.com/doowb)'s awesome [`ansi-colors`](https://github.com/doowb/ansi-colors) library.
+
+Beginning with `kleur@3.0`, the Chalk-style syntax (magical getter) has been replaced with function calls per key:
+
+```js
+// Old:
+c.red.bold.underline('old');
+
+// New:
+c.red().bold().underline('new');
+```
+> As I work more with Rust, the newer syntax feels so much better & more natural!
+
+If you prefer the old syntax, you may migrate to `ansi-colors`. Versions below `kleur@3.0` have been deprecated.
+
+
+## License
+
+MIT © [Luke Edwards](https://lukeed.com)
diff --git a/node_modules/prompts/package.json b/node_modules/prompts/package.json
new file mode 100644
index 0000000..f7ba84b
--- /dev/null
+++ b/node_modules/prompts/package.json
@@ -0,0 +1,53 @@
+{
+ "name": "prompts",
+ "version": "2.4.2",
+ "description": "Lightweight, beautiful and user-friendly prompts",
+ "license": "MIT",
+ "repository": "terkelg/prompts",
+ "main": "index.js",
+ "author": {
+ "name": "Terkel Gjervig",
+ "email": "terkel@terkel.com",
+ "url": "https://terkel.com"
+ },
+ "files": [
+ "lib",
+ "dist",
+ "index.js"
+ ],
+ "scripts": {
+ "start": "node lib/index.js",
+ "build": "babel lib -d dist",
+ "prepublishOnly": "npm run build",
+ "test": "tape test/*.js | tap-spec"
+ },
+ "keywords": [
+ "ui",
+ "prompts",
+ "cli",
+ "prompt",
+ "interface",
+ "command-line",
+ "input",
+ "command",
+ "stdin",
+ "menu",
+ "ask",
+ "interact"
+ ],
+ "dependencies": {
+ "kleur": "^3.0.3",
+ "sisteransi": "^1.0.5"
+ },
+ "devDependencies": {
+ "@babel/cli": "^7.12.1",
+ "@babel/core": "^7.12.3",
+ "@babel/plugin-proposal-object-rest-spread": "^7.12.1",
+ "@babel/preset-env": "^7.12.1",
+ "tap-spec": "^2.2.2",
+ "tape": "^4.13.3"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+}
diff --git a/node_modules/prompts/readme.md b/node_modules/prompts/readme.md
new file mode 100755
index 0000000..4a8b065
--- /dev/null
+++ b/node_modules/prompts/readme.md
@@ -0,0 +1,882 @@
+
+
+
+
+❯ Prompts
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Lightweight, beautiful and user-friendly interactive prompts
+ >_ Easy to use CLI prompts to enquire users for information▌
+
+
+
+
+* **Simple**: prompts has [no big dependencies](http://npm.anvaka.com/#/view/2d/prompts) nor is it broken into a [dozen](http://npm.anvaka.com/#/view/2d/inquirer) tiny modules that only work well together.
+* **User friendly**: prompt uses layout and colors to create beautiful cli interfaces.
+* **Promised**: uses promises and `async`/`await`. No callback hell.
+* **Flexible**: all prompts are independent and can be used on their own.
+* **Testable**: provides a way to submit answers programmatically.
+* **Unified**: consistent experience across all [prompts](#-types).
+
+
+
+
+
+## ❯ Install
+
+```
+$ npm install --save prompts
+```
+
+> This package supports Node 6 and above
+
+
+
+## ❯ Usage
+
+
+
+```js
+const prompts = require('prompts');
+
+(async () => {
+ const response = await prompts({
+ type: 'number',
+ name: 'value',
+ message: 'How old are you?',
+ validate: value => value < 18 ? `Nightclub is 18+ only` : true
+ });
+
+ console.log(response); // => { value: 24 }
+})();
+```
+
+> See [`example.js`](https://github.com/terkelg/prompts/blob/master/example.js) for more options.
+
+
+
+
+
+## ❯ Examples
+
+### Single Prompt
+
+Prompt with a single prompt object. Returns an object with the response.
+
+```js
+const prompts = require('prompts');
+
+(async () => {
+ const response = await prompts({
+ type: 'text',
+ name: 'meaning',
+ message: 'What is the meaning of life?'
+ });
+
+ console.log(response.meaning);
+})();
+```
+
+### Prompt Chain
+
+Prompt with a list of prompt objects. Returns an object with the responses.
+Make sure to give each prompt a unique `name` property to prevent overwriting values.
+
+```js
+const prompts = require('prompts');
+
+const questions = [
+ {
+ type: 'text',
+ name: 'username',
+ message: 'What is your GitHub username?'
+ },
+ {
+ type: 'number',
+ name: 'age',
+ message: 'How old are you?'
+ },
+ {
+ type: 'text',
+ name: 'about',
+ message: 'Tell something about yourself',
+ initial: 'Why should I?'
+ }
+];
+
+(async () => {
+ const response = await prompts(questions);
+
+ // => response => { username, age, about }
+})();
+```
+
+### Dynamic Prompts
+
+Prompt properties can be functions too.
+Prompt Objects with `type` set to `falsy` values are skipped.
+
+```js
+const prompts = require('prompts');
+
+const questions = [
+ {
+ type: 'text',
+ name: 'dish',
+ message: 'Do you like pizza?'
+ },
+ {
+ type: prev => prev == 'pizza' ? 'text' : null,
+ name: 'topping',
+ message: 'Name a topping'
+ }
+];
+
+(async () => {
+ const response = await prompts(questions);
+})();
+```
+
+
+
+
+
+## ❯ API
+
+### prompts(prompts, options)
+
+Type: `Function`
+Returns: `Object`
+
+Prompter function which takes your [prompt objects](#-prompt-objects) and returns an object with responses.
+
+
+#### prompts
+
+Type: `Array|Object`
+
+Array of [prompt objects](#-prompt-objects).
+ These are the questions the user will be prompted. You can see the list of supported [prompt types here](#-types).
+
+Prompts can be submitted (return , enter ) or canceled (esc , abort , ctrl +c , ctrl +d ). No property is being defined on the returned response object when a prompt is canceled.
+
+#### options.onSubmit
+
+Type: `Function`
+Default: `() => {}`
+
+Callback that's invoked after each prompt submission.
+Its signature is `(prompt, answer, answers)` where `prompt` is the current prompt object, `answer` the user answer to the current question and `answers` the user answers so far. Async functions are supported.
+
+Return `true` to quit the prompt chain and return all collected responses so far, otherwise continue to iterate prompt objects.
+
+**Example:**
+```js
+(async () => {
+ const questions = [{ ... }];
+ const onSubmit = (prompt, answer) => console.log(`Thanks I got ${answer} from ${prompt.name}`);
+ const response = await prompts(questions, { onSubmit });
+})();
+```
+
+#### options.onCancel
+
+Type: `Function`
+Default: `() => {}`
+
+Callback that's invoked when the user cancels/exits the prompt.
+Its signature is `(prompt, answers)` where `prompt` is the current prompt object and `answers` the user answers so far. Async functions are supported.
+
+Return `true` to continue and prevent the prompt loop from aborting.
+On cancel responses collected so far are returned.
+
+**Example:**
+```js
+(async () => {
+ const questions = [{ ... }];
+ const onCancel = prompt => {
+ console.log('Never stop prompting!');
+ return true;
+ }
+ const response = await prompts(questions, { onCancel });
+})();
+```
+
+### override
+
+Type: `Function`
+
+Preanswer questions by passing an object with answers to `prompts.override`.
+Powerful when combined with arguments of process.
+
+**Example**
+```js
+const prompts = require('prompts');
+prompts.override(require('yargs').argv);
+
+(async () => {
+ const response = await prompts([
+ {
+ type: 'text',
+ name: 'twitter',
+ message: `What's your twitter handle?`
+ },
+ {
+ type: 'multiselect',
+ name: 'color',
+ message: 'Pick colors',
+ choices: [
+ { title: 'Red', value: '#ff0000' },
+ { title: 'Green', value: '#00ff00' },
+ { title: 'Blue', value: '#0000ff' }
+ ],
+ }
+ ]);
+
+ console.log(response);
+})();
+```
+
+### inject(values)
+
+Type: `Function`
+
+Programmatically inject responses. This enables you to prepare the responses ahead of time.
+If any injected value is found the prompt is immediately resolved with the injected value.
+This feature is intended for testing only.
+
+#### values
+
+Type: `Array`
+
+Array with values to inject. Resolved values are removed from the internal inject array.
+Each value can be an array of values in order to provide answers for a question asked multiple times.
+If a value is an instance of `Error` it will simulate the user cancelling/exiting the prompt.
+
+**Example:**
+```js
+const prompts = require('prompts');
+
+prompts.inject([ '@terkelg', ['#ff0000', '#0000ff'] ]);
+
+(async () => {
+ const response = await prompts([
+ {
+ type: 'text',
+ name: 'twitter',
+ message: `What's your twitter handle?`
+ },
+ {
+ type: 'multiselect',
+ name: 'color',
+ message: 'Pick colors',
+ choices: [
+ { title: 'Red', value: '#ff0000' },
+ { title: 'Green', value: '#00ff00' },
+ { title: 'Blue', value: '#0000ff' }
+ ],
+ }
+ ]);
+
+ // => { twitter: 'terkelg', color: [ '#ff0000', '#0000ff' ] }
+})();
+```
+
+
+
+
+## ❯ Prompt Objects
+
+Prompts Objects are JavaScript objects that define the "questions" and the [type of prompt](#-types).
+Almost all prompt objects have the following properties:
+
+```js
+{
+ type: String | Function,
+ name: String | Function,
+ message: String | Function,
+ initial: String | Function | Async Function
+ format: Function | Async Function,
+ onRender: Function
+ onState: Function
+ stdin: Readable
+ stdout: Writeable
+}
+```
+
+Each property be of type `function` and will be invoked right before prompting the user.
+
+The function signature is `(prev, values, prompt)`, where `prev` is the value from the previous prompt,
+`values` is the response object with all values collected so far and `prompt` is the previous prompt object.
+
+**Function example:**
+```js
+{
+ type: prev => prev > 3 ? 'confirm' : null,
+ name: 'confirm',
+ message: (prev, values) => `Please confirm that you eat ${values.dish} times ${prev} a day?`
+}
+```
+
+The above prompt will be skipped if the value of the previous prompt is less than 3.
+
+### type
+
+Type: `String|Function`
+
+Defines the type of prompt to display. See the list of [prompt types](#-types) for valid values.
+
+If `type` is a falsy value the prompter will skip that question.
+```js
+{
+ type: null,
+ name: 'forgetme',
+ message: `I'll never be shown anyway`,
+}
+```
+
+### name
+
+Type: `String|Function`
+
+The response will be saved under this key/property in the returned response object.
+In case you have multiple prompts with the same name only the latest response will be stored.
+
+> Make sure to give prompts unique names if you don't want to overwrite previous values.
+
+### message
+
+Type: `String|Function`
+
+The message to be displayed to the user.
+
+### initial
+
+Type: `String|Function`
+
+Optional default prompt value. Async functions are supported too.
+
+### format
+
+Type: `Function`
+
+Receive the user input and return the formatted value to be used inside the program.
+The value returned will be added to the response object.
+
+The function signature is `(val, values)`, where `val` is the value from the current prompt and
+`values` is the current response object in case you need to format based on previous responses.
+
+**Example:**
+```js
+{
+ type: 'number',
+ name: 'price',
+ message: 'Enter price',
+ format: val => Intl.NumberFormat(undefined, { style: 'currency', currency: 'USD' }).format(val);
+}
+```
+
+### onRender
+
+Type: `Function`
+
+Callback for when the prompt is rendered.
+The function receives [kleur](https://github.com/lukeed/kleur) as its first argument and `this` refers to the current prompt.
+
+**Example:**
+```js
+{
+ type: 'number',
+ message: 'This message will be overridden',
+ onRender(kleur) {
+ this.msg = kleur.cyan('Enter a number');
+ }
+}
+```
+
+### onState
+
+Type: `Function`
+
+Callback for when the state of the current prompt changes.
+The function signature is `(state)` where `state` is an object with a snapshot of the current state.
+The state object has two properties `value` and `aborted`. E.g `{ value: 'This is ', aborted: false }`
+
+### stdin and stdout
+
+Type: `Stream`
+
+By default, prompts uses `process.stdin` for receiving input and `process.stdout` for writing output.
+If you need to use different streams, for instance `process.stderr`, you can set these with the `stdin` and `stdout` properties.
+
+
+
+
+
+## ❯ Types
+
+* [text](#textmessage-initial-style)
+* [password](#passwordmessage-initial)
+* [invisible](#invisiblemessage-initial)
+* [number](#numbermessage-initial-max-min-style)
+* [confirm](#confirmmessage-initial)
+* [list](#listmessage-initial)
+* [toggle](#togglemessage-initial-active-inactive)
+* [select](#selectmessage-choices-initial-hint-warn)
+* [multiselect](#multiselectmessage-choices-initial-max-hint-warn)
+* [autocompleteMultiselect](#multiselectmessage-choices-initial-max-hint-warn)
+* [autocomplete](#autocompletemessage-choices-initial-suggest-limit-style)
+* [date](#datemessage-initial-warn)
+
+***
+
+### text(message, [initial], [style])
+> Text prompt for free text input.
+
+Hit tab to autocomplete to `initial` value when provided.
+
+#### Example
+
+
+```js
+{
+ type: 'text',
+ name: 'value',
+ message: `What's your twitter handle?`
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `string` | Default string value |
+| style | `string` | Render style (`default`, `password`, `invisible`, `emoji`). Defaults to `default` |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| validate | `function` | Receive user input. Should return `true` if the value is valid, and an error message `String` otherwise. If `false` is returned, a default error message is shown |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### password(message, [initial])
+> Password prompt with masked input.
+
+This prompt is a similar to a prompt of type `'text'` with `style` set to `'password'`.
+
+#### Example
+
+
+```js
+{
+ type: 'password',
+ name: 'value',
+ message: 'Tell me a secret'
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `string` | Default string value |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| validate | `function` | Receive user input. Should return `true` if the value is valid, and an error message `String` otherwise. If `false` is returned, a default error message is shown |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### invisible(message, [initial])
+> Prompts user for invisible text input.
+
+This prompt is working like `sudo` where the input is invisible.
+This prompt is a similar to a prompt of type `'text'` with style set to `'invisible'`.
+
+#### Example
+
+
+```js
+{
+ type: 'invisible',
+ name: 'value',
+ message: 'Enter password'
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `string` | Default string value |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| validate | `function` | Receive user input. Should return `true` if the value is valid, and an error message `String` otherwise. If `false` is returned, a default error message is shown |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### number(message, initial, [max], [min], [style])
+> Prompts user for number input.
+
+You can type in numbers and use up /down to increase/decrease the value. Only numbers are allowed as input. Hit tab to autocomplete to `initial` value when provided.
+
+#### Example
+
+
+```js
+{
+ type: 'number',
+ name: 'value',
+ message: 'How old are you?',
+ initial: 0,
+ style: 'default',
+ min: 2,
+ max: 10
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `number` | Default number value |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| validate | `function` | Receive user input. Should return `true` if the value is valid, and an error message `String` otherwise. If `false` is returned, a default error message is shown |
+| max | `number` | Max value. Defaults to `Infinity` |
+| min | `number` | Min value. Defaults to `-infinity` |
+| float | `boolean` | Allow floating point inputs. Defaults to `false` |
+| round | `number` | Round `float` values to x decimals. Defaults to `2` |
+| increment | `number` | Increment step when using arrow keys. Defaults to `1` |
+| style | `string` | Render style (`default`, `password`, `invisible`, `emoji`). Defaults to `default` |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### confirm(message, [initial])
+> Classic yes/no prompt.
+
+Hit y or n to confirm/reject.
+
+#### Example
+
+
+```js
+{
+ type: 'confirm',
+ name: 'value',
+ message: 'Can you confirm?',
+ initial: true
+}
+```
+
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `boolean` | Default value. Default is `false` |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### list(message, [initial])
+> List prompt that return an array.
+
+Similar to the `text` prompt, but the output is an `Array` containing the
+string separated by `separator`.
+
+```js
+{
+ type: 'list',
+ name: 'value',
+ message: 'Enter keywords',
+ initial: '',
+ separator: ','
+}
+```
+
+
+
+
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `boolean` | Default value |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| separator | `string` | String separator. Will trim all white-spaces from start and end of string. Defaults to `','` |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### toggle(message, [initial], [active], [inactive])
+> Interactive toggle/switch prompt.
+
+Use tab or arrow keys /tab /space to switch between options.
+
+#### Example
+
+
+```js
+{
+ type: 'toggle',
+ name: 'value',
+ message: 'Can you confirm?',
+ initial: true,
+ active: 'yes',
+ inactive: 'no'
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `boolean` | Default value. Defaults to `false` |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| active | `string` | Text for `active` state. Defaults to `'on'` |
+| inactive | `string` | Text for `inactive` state. Defaults to `'off'` |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### select(message, choices, [initial], [hint], [warn])
+> Interactive select prompt.
+
+Use up /down to navigate. Use tab to cycle the list.
+
+#### Example
+
+
+```js
+{
+ type: 'select',
+ name: 'value',
+ message: 'Pick a color',
+ choices: [
+ { title: 'Red', description: 'This option has a description', value: '#ff0000' },
+ { title: 'Green', value: '#00ff00', disabled: true },
+ { title: 'Blue', value: '#0000ff' }
+ ],
+ initial: 1
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `number` | Index of default value |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| hint | `string` | Hint to display to the user |
+| warn | `string` | Message to display when selecting a disabled option |
+| choices | `Array` | Array of strings or choices objects `[{ title, description, value, disabled }, ...]`. The choice's index in the array will be used as its value if it is not specified. |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### multiselect(message, choices, [initial], [max], [hint], [warn])
+### autocompleteMultiselect(same)
+> Interactive multi-select prompt.
+> Autocomplete is a searchable multiselect prompt with the same options. Useful for long lists.
+
+Use space to toggle select/unselect and up /down to navigate. Use tab to cycle the list. You can also use right to select and left to deselect.
+By default this prompt returns an `array` containing the **values** of the selected items - not their display title.
+
+#### Example
+
+
+```js
+{
+ type: 'multiselect',
+ name: 'value',
+ message: 'Pick colors',
+ choices: [
+ { title: 'Red', value: '#ff0000' },
+ { title: 'Green', value: '#00ff00', disabled: true },
+ { title: 'Blue', value: '#0000ff', selected: true }
+ ],
+ max: 2,
+ hint: '- Space to select. Return to submit'
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| instructions | `string` or `boolean` | Prompt instructions to display |
+| choices | `Array` | Array of strings or choices objects `[{ title, value, disabled }, ...]`. The choice's index in the array will be used as its value if it is not specified. |
+| optionsPerPage | `number` | Number of options displayed per page (default: 10) |
+| min | `number` | Min select - will display error |
+| max | `number` | Max select |
+| hint | `string` | Hint to display to the user |
+| warn | `string` | Message to display when selecting a disabled option |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+This is one of the few prompts that don't take a initial value.
+If you want to predefine selected values, give the choice object an `selected` property of `true`.
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### autocomplete(message, choices, [initial], [suggest], [limit], [style])
+> Interactive auto complete prompt.
+
+The prompt will list options based on user input. Type to filter the list.
+Use ⇧ /⇩ to navigate. Use tab to cycle the result. Use Page Up /Page Down (on Mac: fn + ⇧ / ⇩ ) to change page. Hit enter to select the highlighted item below the prompt.
+
+The default suggests function is sorting based on the `title` property of the choices.
+You can overwrite how choices are being filtered by passing your own suggest function.
+
+#### Example
+
+
+```js
+{
+ type: 'autocomplete',
+ name: 'value',
+ message: 'Pick your favorite actor',
+ choices: [
+ { title: 'Cage' },
+ { title: 'Clooney', value: 'silver-fox' },
+ { title: 'Gyllenhaal' },
+ { title: 'Gibson' },
+ { title: 'Grant' }
+ ]
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| format | `function` | Receive user input. The returned value will be added to the response object |
+| choices | `Array` | Array of auto-complete choices objects `[{ title, value }, ...]` |
+| suggest | `function` | Filter function. Defaults to sort by `title` property. `suggest` should always return a promise. Filters using `title` by default |
+| limit | `number` | Max number of results to show. Defaults to `10` |
+| style | `string` | Render style (`default`, `password`, `invisible`, `emoji`). Defaults to `'default'` |
+| initial | `string \| number` | Default initial value |
+| clearFirst | `boolean` | The first ESCAPE keypress will clear the input |
+| fallback | `string` | Fallback message when no match is found. Defaults to `initial` value if provided |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with three properties: `value`, `aborted` and `exited` |
+
+Example on what a `suggest` function might look like:
+```js
+const suggestByTitle = (input, choices) =>
+ Promise.resolve(choices.filter(i => i.title.slice(0, input.length) === input))
+```
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+### date(message, [initial], [warn])
+> Interactive date prompt.
+
+Use left /right /tab to navigate. Use up /down to change date.
+
+#### Example
+
+
+```js
+{
+ type: 'date',
+ name: 'value',
+ message: 'Pick a date',
+ initial: new Date(1997, 09, 12),
+ validate: date => date > Date.now() ? 'Not in the future' : true
+}
+```
+
+#### Options
+| Param | Type | Description |
+| ----- | :--: | ----------- |
+| message | `string` | Prompt message to display |
+| initial | `date` | Default date |
+| locales | `object` | Use to define custom locales. See below for an example. |
+| mask | `string` | The format mask of the date. See below for more information. Default: `YYYY-MM-DD HH:mm:ss` |
+| validate | `function` | Receive user input. Should return `true` if the value is valid, and an error message `String` otherwise. If `false` is returned, a default error message is shown |
+| onRender | `function` | On render callback. Keyword `this` refers to the current prompt |
+| onState | `function` | On state change callback. Function signature is an `object` with two properties: `value` and `aborted` |
+
+Default locales:
+
+```javascript
+{
+ months: [
+ 'January', 'February', 'March', 'April',
+ 'May', 'June', 'July', 'August',
+ 'September', 'October', 'November', 'December'
+ ],
+ monthsShort: [
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
+ ],
+ weekdays: [
+ 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
+ 'Thursday', 'Friday', 'Saturday'
+ ],
+ weekdaysShort: [
+ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
+ ]
+}
+```
+>**Formatting**: See full list of formatting options in the [wiki](https://github.com/terkelg/prompts/wiki/Date-Time-Formatting)
+
+
+
+**↑ back to:** [Prompt types](#-types)
+
+***
+
+## ❯ Credit
+Many of the prompts are based on the work of [derhuerst](https://github.com/derhuerst).
+
+
+## ❯ License
+
+MIT © [Terkel Gjervig](https://terkel.com)
diff --git a/node_modules/readable-stream/CONTRIBUTING.md b/node_modules/readable-stream/CONTRIBUTING.md
new file mode 100644
index 0000000..f478d58
--- /dev/null
+++ b/node_modules/readable-stream/CONTRIBUTING.md
@@ -0,0 +1,38 @@
+# Developer's Certificate of Origin 1.1
+
+By making a contribution to this project, I certify that:
+
+* (a) The contribution was created in whole or in part by me and I
+ have the right to submit it under the open source license
+ indicated in the file; or
+
+* (b) The contribution is based upon previous work that, to the best
+ of my knowledge, is covered under an appropriate open source
+ license and I have the right under that license to submit that
+ work with modifications, whether created in whole or in part
+ by me, under the same open source license (unless I am
+ permitted to submit under a different license), as indicated
+ in the file; or
+
+* (c) The contribution was provided directly to me by some other
+ person who certified (a), (b) or (c) and I have not modified
+ it.
+
+* (d) I understand and agree that this project and the contribution
+ are public and that a record of the contribution (including all
+ personal information I submit with it, including my sign-off) is
+ maintained indefinitely and may be redistributed consistent with
+ this project or the open source license(s) involved.
+
+## Moderation Policy
+
+The [Node.js Moderation Policy] applies to this WG.
+
+## Code of Conduct
+
+The [Node.js Code of Conduct][] applies to this WG.
+
+[Node.js Code of Conduct]:
+https://github.com/nodejs/node/blob/master/CODE_OF_CONDUCT.md
+[Node.js Moderation Policy]:
+https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md
diff --git a/node_modules/readable-stream/GOVERNANCE.md b/node_modules/readable-stream/GOVERNANCE.md
new file mode 100644
index 0000000..16ffb93
--- /dev/null
+++ b/node_modules/readable-stream/GOVERNANCE.md
@@ -0,0 +1,136 @@
+### Streams Working Group
+
+The Node.js Streams is jointly governed by a Working Group
+(WG)
+that is responsible for high-level guidance of the project.
+
+The WG has final authority over this project including:
+
+* Technical direction
+* Project governance and process (including this policy)
+* Contribution policy
+* GitHub repository hosting
+* Conduct guidelines
+* Maintaining the list of additional Collaborators
+
+For the current list of WG members, see the project
+[README.md](./README.md#current-project-team-members).
+
+### Collaborators
+
+The readable-stream GitHub repository is
+maintained by the WG and additional Collaborators who are added by the
+WG on an ongoing basis.
+
+Individuals making significant and valuable contributions are made
+Collaborators and given commit-access to the project. These
+individuals are identified by the WG and their addition as
+Collaborators is discussed during the WG meeting.
+
+_Note:_ If you make a significant contribution and are not considered
+for commit-access log an issue or contact a WG member directly and it
+will be brought up in the next WG meeting.
+
+Modifications of the contents of the readable-stream repository are
+made on
+a collaborative basis. Anybody with a GitHub account may propose a
+modification via pull request and it will be considered by the project
+Collaborators. All pull requests must be reviewed and accepted by a
+Collaborator with sufficient expertise who is able to take full
+responsibility for the change. In the case of pull requests proposed
+by an existing Collaborator, an additional Collaborator is required
+for sign-off. Consensus should be sought if additional Collaborators
+participate and there is disagreement around a particular
+modification. See _Consensus Seeking Process_ below for further detail
+on the consensus model used for governance.
+
+Collaborators may opt to elevate significant or controversial
+modifications, or modifications that have not found consensus to the
+WG for discussion by assigning the ***WG-agenda*** tag to a pull
+request or issue. The WG should serve as the final arbiter where
+required.
+
+For the current list of Collaborators, see the project
+[README.md](./README.md#members).
+
+### WG Membership
+
+WG seats are not time-limited. There is no fixed size of the WG.
+However, the expected target is between 6 and 12, to ensure adequate
+coverage of important areas of expertise, balanced with the ability to
+make decisions efficiently.
+
+There is no specific set of requirements or qualifications for WG
+membership beyond these rules.
+
+The WG may add additional members to the WG by unanimous consensus.
+
+A WG member may be removed from the WG by voluntary resignation, or by
+unanimous consensus of all other WG members.
+
+Changes to WG membership should be posted in the agenda, and may be
+suggested as any other agenda item (see "WG Meetings" below).
+
+If an addition or removal is proposed during a meeting, and the full
+WG is not in attendance to participate, then the addition or removal
+is added to the agenda for the subsequent meeting. This is to ensure
+that all members are given the opportunity to participate in all
+membership decisions. If a WG member is unable to attend a meeting
+where a planned membership decision is being made, then their consent
+is assumed.
+
+No more than 1/3 of the WG members may be affiliated with the same
+employer. If removal or resignation of a WG member, or a change of
+employment by a WG member, creates a situation where more than 1/3 of
+the WG membership shares an employer, then the situation must be
+immediately remedied by the resignation or removal of one or more WG
+members affiliated with the over-represented employer(s).
+
+### WG Meetings
+
+The WG meets occasionally on a Google Hangout On Air. A designated moderator
+approved by the WG runs the meeting. Each meeting should be
+published to YouTube.
+
+Items are added to the WG agenda that are considered contentious or
+are modifications of governance, contribution policy, WG membership,
+or release process.
+
+The intention of the agenda is not to approve or review all patches;
+that should happen continuously on GitHub and be handled by the larger
+group of Collaborators.
+
+Any community member or contributor can ask that something be added to
+the next meeting's agenda by logging a GitHub Issue. Any Collaborator,
+WG member or the moderator can add the item to the agenda by adding
+the ***WG-agenda*** tag to the issue.
+
+Prior to each WG meeting the moderator will share the Agenda with
+members of the WG. WG members can add any items they like to the
+agenda at the beginning of each meeting. The moderator and the WG
+cannot veto or remove items.
+
+The WG may invite persons or representatives from certain projects to
+participate in a non-voting capacity.
+
+The moderator is responsible for summarizing the discussion of each
+agenda item and sends it as a pull request after the meeting.
+
+### Consensus Seeking Process
+
+The WG follows a
+[Consensus
+Seeking](http://en.wikipedia.org/wiki/Consensus-seeking_decision-making)
+decision-making model.
+
+When an agenda item has appeared to reach a consensus the moderator
+will ask "Does anyone object?" as a final call for dissent from the
+consensus.
+
+If an agenda item cannot reach a consensus a WG member can call for
+either a closing vote or a vote to table the issue to the next
+meeting. The call for a vote must be seconded by a majority of the WG
+or else the discussion will continue. Simple majority wins.
+
+Note that changes to WG membership require a majority consensus. See
+"WG Membership" above.
diff --git a/node_modules/readable-stream/LICENSE b/node_modules/readable-stream/LICENSE
new file mode 100644
index 0000000..2873b3b
--- /dev/null
+++ b/node_modules/readable-stream/LICENSE
@@ -0,0 +1,47 @@
+Node.js is licensed for use as follows:
+
+"""
+Copyright Node.js contributors. All rights reserved.
+
+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.
+"""
+
+This license applies to parts of Node.js originating from the
+https://github.com/joyent/node repository:
+
+"""
+Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+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.
+"""
diff --git a/node_modules/readable-stream/README.md b/node_modules/readable-stream/README.md
new file mode 100644
index 0000000..19117c1
--- /dev/null
+++ b/node_modules/readable-stream/README.md
@@ -0,0 +1,106 @@
+# readable-stream
+
+***Node.js core streams for userland*** [](https://travis-ci.com/nodejs/readable-stream)
+
+
+[](https://nodei.co/npm/readable-stream/)
+[](https://nodei.co/npm/readable-stream/)
+
+
+[](https://saucelabs.com/u/readabe-stream)
+
+```bash
+npm install --save readable-stream
+```
+
+This package is a mirror of the streams implementations in Node.js.
+
+Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.18.1/docs/api/stream.html).
+
+If you want to guarantee a stable streams base, regardless of what version of
+Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
+
+As of version 2.0.0 **readable-stream** uses semantic versioning.
+
+## Version 3.x.x
+
+v3.x.x of `readable-stream` is a cut from Node 10. This version supports Node 6, 8, and 10, as well as evergreen browsers, IE 11 and latest Safari. The breaking changes introduced by v3 are composed by the combined breaking changes in [Node v9](https://nodejs.org/en/blog/release/v9.0.0/) and [Node v10](https://nodejs.org/en/blog/release/v10.0.0/), as follows:
+
+1. Error codes: https://github.com/nodejs/node/pull/13310,
+ https://github.com/nodejs/node/pull/13291,
+ https://github.com/nodejs/node/pull/16589,
+ https://github.com/nodejs/node/pull/15042,
+ https://github.com/nodejs/node/pull/15665,
+ https://github.com/nodejs/readable-stream/pull/344
+2. 'readable' have precedence over flowing
+ https://github.com/nodejs/node/pull/18994
+3. make virtual methods errors consistent
+ https://github.com/nodejs/node/pull/18813
+4. updated streams error handling
+ https://github.com/nodejs/node/pull/18438
+5. writable.end should return this.
+ https://github.com/nodejs/node/pull/18780
+6. readable continues to read when push('')
+ https://github.com/nodejs/node/pull/18211
+7. add custom inspect to BufferList
+ https://github.com/nodejs/node/pull/17907
+8. always defer 'readable' with nextTick
+ https://github.com/nodejs/node/pull/17979
+
+## Version 2.x.x
+v2.x.x of `readable-stream` is a cut of the stream module from Node 8 (there have been no semver-major changes from Node 4 to 8). This version supports all Node.js versions from 0.8, as well as evergreen browsers and IE 10 & 11.
+
+### Big Thanks
+
+Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs][sauce]
+
+# Usage
+
+You can swap your `require('stream')` with `require('readable-stream')`
+without any changes, if you are just using one of the main classes and
+functions.
+
+```js
+const {
+ Readable,
+ Writable,
+ Transform,
+ Duplex,
+ pipeline,
+ finished
+} = require('readable-stream')
+````
+
+Note that `require('stream')` will return `Stream`, while
+`require('readable-stream')` will return `Readable`. We discourage using
+whatever is exported directly, but rather use one of the properties as
+shown in the example above.
+
+# Streams Working Group
+
+`readable-stream` is maintained by the Streams Working Group, which
+oversees the development and maintenance of the Streams API within
+Node.js. The responsibilities of the Streams Working Group include:
+
+* Addressing stream issues on the Node.js issue tracker.
+* Authoring and editing stream documentation within the Node.js project.
+* Reviewing changes to stream subclasses within the Node.js project.
+* Redirecting changes to streams from the Node.js project to this
+ project.
+* Assisting in the implementation of stream providers within Node.js.
+* Recommending versions of `readable-stream` to be included in Node.js.
+* Messaging about the future of streams to give the community advance
+ notice of changes.
+
+
+## Team Members
+
+* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) <calvin.metcalf@gmail.com>
+ - Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
+* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <mathiasbuus@gmail.com>
+* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) <matteo.collina@gmail.com>
+ - Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E
+* **Irina Shestak** ([@lrlna](https://github.com/lrlna)) <shestak.irina@gmail.com>
+* **Yoshua Wyuts** ([@yoshuawuyts](https://github.com/yoshuawuyts)) <yoshuawuyts@gmail.com>
+
+[sauce]: https://saucelabs.com
diff --git a/node_modules/readable-stream/errors-browser.js b/node_modules/readable-stream/errors-browser.js
new file mode 100644
index 0000000..fb8e73e
--- /dev/null
+++ b/node_modules/readable-stream/errors-browser.js
@@ -0,0 +1,127 @@
+'use strict';
+
+function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
+
+var codes = {};
+
+function createErrorType(code, message, Base) {
+ if (!Base) {
+ Base = Error;
+ }
+
+ function getMessage(arg1, arg2, arg3) {
+ if (typeof message === 'string') {
+ return message;
+ } else {
+ return message(arg1, arg2, arg3);
+ }
+ }
+
+ var NodeError =
+ /*#__PURE__*/
+ function (_Base) {
+ _inheritsLoose(NodeError, _Base);
+
+ function NodeError(arg1, arg2, arg3) {
+ return _Base.call(this, getMessage(arg1, arg2, arg3)) || this;
+ }
+
+ return NodeError;
+ }(Base);
+
+ NodeError.prototype.name = Base.name;
+ NodeError.prototype.code = code;
+ codes[code] = NodeError;
+} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
+
+
+function oneOf(expected, thing) {
+ if (Array.isArray(expected)) {
+ var len = expected.length;
+ expected = expected.map(function (i) {
+ return String(i);
+ });
+
+ if (len > 2) {
+ return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
+ } else if (len === 2) {
+ return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
+ } else {
+ return "of ".concat(thing, " ").concat(expected[0]);
+ }
+ } else {
+ return "of ".concat(thing, " ").concat(String(expected));
+ }
+} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
+
+
+function startsWith(str, search, pos) {
+ return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
+} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
+
+
+function endsWith(str, search, this_len) {
+ if (this_len === undefined || this_len > str.length) {
+ this_len = str.length;
+ }
+
+ return str.substring(this_len - search.length, this_len) === search;
+} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
+
+
+function includes(str, search, start) {
+ if (typeof start !== 'number') {
+ start = 0;
+ }
+
+ if (start + search.length > str.length) {
+ return false;
+ } else {
+ return str.indexOf(search, start) !== -1;
+ }
+}
+
+createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
+ return 'The value "' + value + '" is invalid for option "' + name + '"';
+}, TypeError);
+createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
+ // determiner: 'must be' or 'must not be'
+ var determiner;
+
+ if (typeof expected === 'string' && startsWith(expected, 'not ')) {
+ determiner = 'must not be';
+ expected = expected.replace(/^not /, '');
+ } else {
+ determiner = 'must be';
+ }
+
+ var msg;
+
+ if (endsWith(name, ' argument')) {
+ // For cases like 'first argument'
+ msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
+ } else {
+ var type = includes(name, '.') ? 'property' : 'argument';
+ msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
+ }
+
+ msg += ". Received type ".concat(typeof actual);
+ return msg;
+}, TypeError);
+createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
+createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
+ return 'The ' + name + ' method is not implemented';
+});
+createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
+createErrorType('ERR_STREAM_DESTROYED', function (name) {
+ return 'Cannot call ' + name + ' after a stream was destroyed';
+});
+createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
+createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
+createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
+createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
+createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
+ return 'Unknown encoding: ' + arg;
+}, TypeError);
+createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
+module.exports.codes = codes;
diff --git a/node_modules/readable-stream/errors.js b/node_modules/readable-stream/errors.js
new file mode 100644
index 0000000..8471526
--- /dev/null
+++ b/node_modules/readable-stream/errors.js
@@ -0,0 +1,116 @@
+'use strict';
+
+const codes = {};
+
+function createErrorType(code, message, Base) {
+ if (!Base) {
+ Base = Error
+ }
+
+ function getMessage (arg1, arg2, arg3) {
+ if (typeof message === 'string') {
+ return message
+ } else {
+ return message(arg1, arg2, arg3)
+ }
+ }
+
+ class NodeError extends Base {
+ constructor (arg1, arg2, arg3) {
+ super(getMessage(arg1, arg2, arg3));
+ }
+ }
+
+ NodeError.prototype.name = Base.name;
+ NodeError.prototype.code = code;
+
+ codes[code] = NodeError;
+}
+
+// https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
+function oneOf(expected, thing) {
+ if (Array.isArray(expected)) {
+ const len = expected.length;
+ expected = expected.map((i) => String(i));
+ if (len > 2) {
+ return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +
+ expected[len - 1];
+ } else if (len === 2) {
+ return `one of ${thing} ${expected[0]} or ${expected[1]}`;
+ } else {
+ return `of ${thing} ${expected[0]}`;
+ }
+ } else {
+ return `of ${thing} ${String(expected)}`;
+ }
+}
+
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
+function startsWith(str, search, pos) {
+ return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
+}
+
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
+function endsWith(str, search, this_len) {
+ if (this_len === undefined || this_len > str.length) {
+ this_len = str.length;
+ }
+ return str.substring(this_len - search.length, this_len) === search;
+}
+
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
+function includes(str, search, start) {
+ if (typeof start !== 'number') {
+ start = 0;
+ }
+
+ if (start + search.length > str.length) {
+ return false;
+ } else {
+ return str.indexOf(search, start) !== -1;
+ }
+}
+
+createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
+ return 'The value "' + value + '" is invalid for option "' + name + '"'
+}, TypeError);
+createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
+ // determiner: 'must be' or 'must not be'
+ let determiner;
+ if (typeof expected === 'string' && startsWith(expected, 'not ')) {
+ determiner = 'must not be';
+ expected = expected.replace(/^not /, '');
+ } else {
+ determiner = 'must be';
+ }
+
+ let msg;
+ if (endsWith(name, ' argument')) {
+ // For cases like 'first argument'
+ msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;
+ } else {
+ const type = includes(name, '.') ? 'property' : 'argument';
+ msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, 'type')}`;
+ }
+
+ msg += `. Received type ${typeof actual}`;
+ return msg;
+}, TypeError);
+createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
+createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
+ return 'The ' + name + ' method is not implemented'
+});
+createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
+createErrorType('ERR_STREAM_DESTROYED', function (name) {
+ return 'Cannot call ' + name + ' after a stream was destroyed';
+});
+createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
+createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
+createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
+createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
+createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
+ return 'Unknown encoding: ' + arg
+}, TypeError);
+createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
+
+module.exports.codes = codes;
diff --git a/node_modules/readable-stream/experimentalWarning.js b/node_modules/readable-stream/experimentalWarning.js
new file mode 100644
index 0000000..78e8414
--- /dev/null
+++ b/node_modules/readable-stream/experimentalWarning.js
@@ -0,0 +1,17 @@
+'use strict'
+
+var experimentalWarnings = new Set();
+
+function emitExperimentalWarning(feature) {
+ if (experimentalWarnings.has(feature)) return;
+ var msg = feature + ' is an experimental feature. This feature could ' +
+ 'change at any time';
+ experimentalWarnings.add(feature);
+ process.emitWarning(msg, 'ExperimentalWarning');
+}
+
+function noop() {}
+
+module.exports.emitExperimentalWarning = process.emitWarning
+ ? emitExperimentalWarning
+ : noop;
diff --git a/node_modules/readable-stream/lib/_stream_duplex.js b/node_modules/readable-stream/lib/_stream_duplex.js
new file mode 100644
index 0000000..19abfa6
--- /dev/null
+++ b/node_modules/readable-stream/lib/_stream_duplex.js
@@ -0,0 +1,126 @@
+// 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.
+
+// 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 Readable = require('./_stream_readable');
+var Writable = require('./_stream_writable');
+require('inherits')(Duplex, Readable);
+{
+ // Allow the keys array to be GC'ed.
+ 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);
+ this.allowHalfOpen = true;
+ if (options) {
+ if (options.readable === false) this.readable = false;
+ if (options.writable === false) this.writable = false;
+ if (options.allowHalfOpen === false) {
+ this.allowHalfOpen = false;
+ this.once('end', onend);
+ }
+ }
+}
+Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._writableState.highWaterMark;
+ }
+});
+Object.defineProperty(Duplex.prototype, 'writableBuffer', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._writableState && this._writableState.getBuffer();
+ }
+});
+Object.defineProperty(Duplex.prototype, 'writableLength', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._writableState.length;
+ }
+});
+
+// the no-half-open enforcer
+function onend() {
+ // If the writable side ended, then we're ok.
+ if (this._writableState.ended) return;
+
+ // no more data can be written.
+ // But allow more writes to happen in this tick.
+ process.nextTick(onEndNT, this);
+}
+function onEndNT(self) {
+ self.end();
+}
+Object.defineProperty(Duplex.prototype, 'destroyed', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ if (this._readableState === undefined || this._writableState === undefined) {
+ return false;
+ }
+ return this._readableState.destroyed && this._writableState.destroyed;
+ },
+ set: function set(value) {
+ // we ignore the value if the stream
+ // has not been initialized yet
+ if (this._readableState === undefined || this._writableState === undefined) {
+ return;
+ }
+
+ // backward compatibility, the user is explicitly
+ // managing destroyed
+ this._readableState.destroyed = value;
+ this._writableState.destroyed = value;
+ }
+});
\ No newline at end of file
diff --git a/node_modules/readable-stream/lib/_stream_passthrough.js b/node_modules/readable-stream/lib/_stream_passthrough.js
new file mode 100644
index 0000000..24a6bdd
--- /dev/null
+++ b/node_modules/readable-stream/lib/_stream_passthrough.js
@@ -0,0 +1,37 @@
+// 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.
+
+// 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 = require('./_stream_transform');
+require('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);
+};
\ No newline at end of file
diff --git a/node_modules/readable-stream/lib/_stream_readable.js b/node_modules/readable-stream/lib/_stream_readable.js
new file mode 100644
index 0000000..df1f608
--- /dev/null
+++ b/node_modules/readable-stream/lib/_stream_readable.js
@@ -0,0 +1,1027 @@
+// 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.
+
+'use strict';
+
+module.exports = Readable;
+
+/**/
+var Duplex;
+/* */
+
+Readable.ReadableState = ReadableState;
+
+/**/
+var EE = require('events').EventEmitter;
+var EElistenerCount = function EElistenerCount(emitter, type) {
+ return emitter.listeners(type).length;
+};
+/* */
+
+/**/
+var Stream = require('./internal/streams/stream');
+/* */
+
+var Buffer = require('buffer').Buffer;
+var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
+function _uint8ArrayToBuffer(chunk) {
+ return Buffer.from(chunk);
+}
+function _isUint8Array(obj) {
+ return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
+}
+
+/**/
+var debugUtil = require('util');
+var debug;
+if (debugUtil && debugUtil.debuglog) {
+ debug = debugUtil.debuglog('stream');
+} else {
+ debug = function debug() {};
+}
+/* */
+
+var BufferList = require('./internal/streams/buffer_list');
+var destroyImpl = require('./internal/streams/destroy');
+var _require = require('./internal/streams/state'),
+ getHighWaterMark = _require.getHighWaterMark;
+var _require$codes = require('../errors').codes,
+ ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
+ ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF,
+ ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
+ ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
+
+// Lazy loaded to improve the startup performance.
+var StringDecoder;
+var createReadableStreamAsyncIterator;
+var from;
+require('inherits')(Readable, Stream);
+var errorOrDestroy = destroyImpl.errorOrDestroy;
+var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
+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);
+
+ // 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 (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
+}
+function ReadableState(options, stream, isDuplex) {
+ Duplex = Duplex || require('./_stream_duplex');
+ options = options || {};
+
+ // Duplex streams are both readable and writable, but share
+ // the same options object.
+ // However, some cases require setting options to different
+ // values for the readable and the writable sides of the duplex stream.
+ // These options can be provided separately as readableXXX and writableXXX.
+ if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex;
+
+ // 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 (isDuplex) 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"
+ this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex);
+
+ // 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 event 'readable'/'data' is emitted
+ // 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 read 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;
+ this.paused = true;
+
+ // Should close be emitted on destroy. Defaults to true.
+ this.emitClose = options.emitClose !== false;
+
+ // Should .destroy() be called after 'end' (and potentially 'finish')
+ this.autoDestroy = !!options.autoDestroy;
+
+ // has it been destroyed
+ this.destroyed = 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';
+
+ // 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 = require('string_decoder/').StringDecoder;
+ this.decoder = new StringDecoder(options.encoding);
+ this.encoding = options.encoding;
+ }
+}
+function Readable(options) {
+ Duplex = Duplex || require('./_stream_duplex');
+ if (!(this instanceof Readable)) return new Readable(options);
+
+ // Checking for a Stream.Duplex instance is faster here instead of inside
+ // the ReadableState constructor, at least with V8 6.5
+ var isDuplex = this instanceof Duplex;
+ this._readableState = new ReadableState(options, this, isDuplex);
+
+ // legacy
+ this.readable = true;
+ if (options) {
+ if (typeof options.read === 'function') this._read = options.read;
+ if (typeof options.destroy === 'function') this._destroy = options.destroy;
+ }
+ Stream.call(this);
+}
+Object.defineProperty(Readable.prototype, 'destroyed', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ if (this._readableState === undefined) {
+ return false;
+ }
+ return this._readableState.destroyed;
+ },
+ set: function set(value) {
+ // we ignore the value if the stream
+ // has not been initialized yet
+ if (!this._readableState) {
+ return;
+ }
+
+ // backward compatibility, the user is explicitly
+ // managing destroyed
+ this._readableState.destroyed = value;
+ }
+});
+Readable.prototype.destroy = destroyImpl.destroy;
+Readable.prototype._undestroy = destroyImpl.undestroy;
+Readable.prototype._destroy = function (err, cb) {
+ cb(err);
+};
+
+// 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;
+ var skipChunkCheck;
+ if (!state.objectMode) {
+ if (typeof chunk === 'string') {
+ encoding = encoding || state.defaultEncoding;
+ if (encoding !== state.encoding) {
+ chunk = Buffer.from(chunk, encoding);
+ encoding = '';
+ }
+ skipChunkCheck = true;
+ }
+ } else {
+ skipChunkCheck = true;
+ }
+ return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
+};
+
+// Unshift should *always* be something directly out of read()
+Readable.prototype.unshift = function (chunk) {
+ return readableAddChunk(this, chunk, null, true, false);
+};
+function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
+ debug('readableAddChunk', chunk);
+ var state = stream._readableState;
+ if (chunk === null) {
+ state.reading = false;
+ onEofChunk(stream, state);
+ } else {
+ var er;
+ if (!skipChunkCheck) er = chunkInvalid(state, chunk);
+ if (er) {
+ errorOrDestroy(stream, er);
+ } else if (state.objectMode || chunk && chunk.length > 0) {
+ if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
+ chunk = _uint8ArrayToBuffer(chunk);
+ }
+ if (addToFront) {
+ if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);
+ } else if (state.ended) {
+ errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
+ } else if (state.destroyed) {
+ return false;
+ } else {
+ state.reading = false;
+ if (state.decoder && !encoding) {
+ chunk = state.decoder.write(chunk);
+ if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
+ } else {
+ addChunk(stream, state, chunk, false);
+ }
+ }
+ } else if (!addToFront) {
+ state.reading = false;
+ maybeReadMore(stream, state);
+ }
+ }
+
+ // We can push more data if we are below the highWaterMark.
+ // 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.
+ return !state.ended && (state.length < state.highWaterMark || state.length === 0);
+}
+function addChunk(stream, state, chunk, addToFront) {
+ if (state.flowing && state.length === 0 && !state.sync) {
+ state.awaitDrain = 0;
+ stream.emit('data', chunk);
+ } 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);
+}
+function chunkInvalid(state, chunk) {
+ var er;
+ if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
+ er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk);
+ }
+ return er;
+}
+Readable.prototype.isPaused = function () {
+ return this._readableState.flowing === false;
+};
+
+// backwards compatibility.
+Readable.prototype.setEncoding = function (enc) {
+ if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
+ var decoder = new StringDecoder(enc);
+ this._readableState.decoder = decoder;
+ // If setEncoding(null), decoder.encoding equals utf8
+ this._readableState.encoding = this._readableState.decoder.encoding;
+
+ // Iterate over current buffer to convert already stored Buffers:
+ var p = this._readableState.buffer.head;
+ var content = '';
+ while (p !== null) {
+ content += decoder.write(p.data);
+ p = p.next;
+ }
+ this._readableState.buffer.clear();
+ if (content !== '') this._readableState.buffer.push(content);
+ this._readableState.length = content.length;
+ return this;
+};
+
+// Don't raise the hwm > 1GB
+var MAX_HWM = 0x40000000;
+function computeNewHighWaterMark(n) {
+ if (n >= MAX_HWM) {
+ // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
+ 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.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || 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 = state.length <= state.highWaterMark;
+ n = 0;
+ } else {
+ state.length -= n;
+ state.awaitDrain = 0;
+ }
+ 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 onEofChunk(stream, state) {
+ debug('onEofChunk');
+ 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;
+ if (state.sync) {
+ // if we are sync, wait until next tick to emit the data.
+ // Otherwise we risk emitting data in the flow()
+ // the readable code triggers during a read() call
+ emitReadable(stream);
+ } else {
+ // emit 'readable' now to make sure it gets picked up.
+ state.needReadable = false;
+ if (!state.emittedReadable) {
+ state.emittedReadable = true;
+ 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;
+ debug('emitReadable', state.needReadable, state.emittedReadable);
+ state.needReadable = false;
+ if (!state.emittedReadable) {
+ debug('emitReadable', state.flowing);
+ state.emittedReadable = true;
+ process.nextTick(emitReadable_, stream);
+ }
+}
+function emitReadable_(stream) {
+ var state = stream._readableState;
+ debug('emitReadable_', state.destroyed, state.length, state.ended);
+ if (!state.destroyed && (state.length || state.ended)) {
+ stream.emit('readable');
+ state.emittedReadable = false;
+ }
+
+ // The stream needs another readable event if
+ // 1. It is not flowing, as the flow mechanism will take
+ // care of it.
+ // 2. It is not ended.
+ // 3. It is below the highWaterMark, so we can schedule
+ // another readable later.
+ state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
+ 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;
+ process.nextTick(maybeReadMore_, stream, state);
+ }
+}
+function maybeReadMore_(stream, state) {
+ // Attempt to read more data if we should.
+ //
+ // The conditions for reading more data are (one of):
+ // - Not enough data buffered (state.length < state.highWaterMark). The loop
+ // is responsible for filling the buffer with enough data if such data
+ // is available. If highWaterMark is 0 and we are not in the flowing mode
+ // we should _not_ attempt to buffer any extra data. We'll get more data
+ // when the stream consumer calls read() instead.
+ // - No data in the buffer, and the stream is in flowing mode. In this mode
+ // the loop below is responsible for ensuring read() is called. Failing to
+ // call read here would abort the flow and there's no other mechanism for
+ // continuing the flow if the stream consumer has just subscribed to the
+ // 'data' event.
+ //
+ // In addition to the above conditions to keep reading data, the following
+ // conditions prevent the data from being read:
+ // - The stream has ended (state.ended).
+ // - There is already a pending 'read' operation (state.reading). This is a
+ // case where the the stream has called the implementation defined _read()
+ // method, but they are processing the call asynchronously and have _not_
+ // called push() with new data. In this case we skip performing more
+ // read()s. The execution ends in this method again after the _read() ends
+ // up calling push() with more data.
+ while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
+ var len = state.length;
+ debug('maybeReadMore read 0');
+ stream.read(0);
+ if (len === state.length)
+ // didn't get any data, stop spinning.
+ break;
+ }
+ 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) {
+ errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));
+};
+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 : unpipe;
+ if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);
+ dest.on('unpipe', onunpipe);
+ function onunpipe(readable, unpipeInfo) {
+ debug('onunpipe');
+ if (readable === src) {
+ if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
+ unpipeInfo.hasUnpiped = true;
+ 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', unpipe);
+ 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();
+ }
+ src.on('data', ondata);
+ function ondata(chunk) {
+ debug('ondata');
+ var ret = dest.write(chunk);
+ debug('dest.write', ret);
+ if (ret === false) {
+ // 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', state.awaitDrain);
+ state.awaitDrain++;
+ }
+ 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) errorOrDestroy(dest, 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 pipeOnDrainFunctionResult() {
+ 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;
+ var unpipeInfo = {
+ hasUnpiped: false
+ };
+
+ // 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, unpipeInfo);
+ 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, {
+ hasUnpiped: false
+ });
+ 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, unpipeInfo);
+ 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);
+ var state = this._readableState;
+ if (ev === 'data') {
+ // update readableListening so that resume() may be a no-op
+ // a few lines down. This is needed to support once('readable').
+ state.readableListening = this.listenerCount('readable') > 0;
+
+ // Try start flowing on next tick if stream isn't explicitly paused
+ if (state.flowing !== false) this.resume();
+ } else if (ev === 'readable') {
+ if (!state.endEmitted && !state.readableListening) {
+ state.readableListening = state.needReadable = true;
+ state.flowing = false;
+ state.emittedReadable = false;
+ debug('on readable', state.length, state.reading);
+ if (state.length) {
+ emitReadable(this);
+ } else if (!state.reading) {
+ process.nextTick(nReadingNextTick, this);
+ }
+ }
+ }
+ return res;
+};
+Readable.prototype.addListener = Readable.prototype.on;
+Readable.prototype.removeListener = function (ev, fn) {
+ var res = Stream.prototype.removeListener.call(this, ev, fn);
+ if (ev === 'readable') {
+ // We need to check if there is someone still listening to
+ // readable and reset the state. However this needs to happen
+ // after readable has been emitted but before I/O (nextTick) to
+ // support once('readable', fn) cycles. This means that calling
+ // resume within the same tick will have no
+ // effect.
+ process.nextTick(updateReadableListening, this);
+ }
+ return res;
+};
+Readable.prototype.removeAllListeners = function (ev) {
+ var res = Stream.prototype.removeAllListeners.apply(this, arguments);
+ if (ev === 'readable' || ev === undefined) {
+ // We need to check if there is someone still listening to
+ // readable and reset the state. However this needs to happen
+ // after readable has been emitted but before I/O (nextTick) to
+ // support once('readable', fn) cycles. This means that calling
+ // resume within the same tick will have no
+ // effect.
+ process.nextTick(updateReadableListening, this);
+ }
+ return res;
+};
+function updateReadableListening(self) {
+ var state = self._readableState;
+ state.readableListening = self.listenerCount('readable') > 0;
+ if (state.resumeScheduled && !state.paused) {
+ // flowing needs to be set to true now, otherwise
+ // the upcoming resume will not flow.
+ state.flowing = true;
+
+ // crude way to check if we should resume
+ } else if (self.listenerCount('data') > 0) {
+ self.resume();
+ }
+}
+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');
+ // we flow only if there is no one listening
+ // for readable, but we still have to call
+ // resume()
+ state.flowing = !state.readableListening;
+ resume(this, state);
+ }
+ state.paused = false;
+ return this;
+};
+function resume(stream, state) {
+ if (!state.resumeScheduled) {
+ state.resumeScheduled = true;
+ process.nextTick(resume_, stream, state);
+ }
+}
+function resume_(stream, state) {
+ debug('resume', state.reading);
+ if (!state.reading) {
+ stream.read(0);
+ }
+ state.resumeScheduled = false;
+ 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 (this._readableState.flowing !== false) {
+ debug('pause');
+ this._readableState.flowing = false;
+ this.emit('pause');
+ }
+ this._readableState.paused = true;
+ 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 _this = this;
+ var state = this._readableState;
+ var paused = false;
+ stream.on('end', function () {
+ debug('wrapped end');
+ if (state.decoder && !state.ended) {
+ var chunk = state.decoder.end();
+ if (chunk && chunk.length) _this.push(chunk);
+ }
+ _this.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 = _this.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 methodWrap(method) {
+ return function methodWrapReturnFunction() {
+ return stream[method].apply(stream, arguments);
+ };
+ }(i);
+ }
+ }
+
+ // proxy certain important events.
+ for (var n = 0; n < kProxyEvents.length; n++) {
+ stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
+ }
+
+ // when we try to consume some more bytes, simply unpause the
+ // underlying stream.
+ this._read = function (n) {
+ debug('wrapped _read', n);
+ if (paused) {
+ paused = false;
+ stream.resume();
+ }
+ };
+ return this;
+};
+if (typeof Symbol === 'function') {
+ Readable.prototype[Symbol.asyncIterator] = function () {
+ if (createReadableStreamAsyncIterator === undefined) {
+ createReadableStreamAsyncIterator = require('./internal/streams/async_iterator');
+ }
+ return createReadableStreamAsyncIterator(this);
+ };
+}
+Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._readableState.highWaterMark;
+ }
+});
+Object.defineProperty(Readable.prototype, 'readableBuffer', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._readableState && this._readableState.buffer;
+ }
+});
+Object.defineProperty(Readable.prototype, 'readableFlowing', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._readableState.flowing;
+ },
+ set: function set(state) {
+ if (this._readableState) {
+ this._readableState.flowing = state;
+ }
+ }
+});
+
+// exposed for testing purposes only.
+Readable._fromList = fromList;
+Object.defineProperty(Readable.prototype, 'readableLength', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._readableState.length;
+ }
+});
+
+// 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.first();else ret = state.buffer.concat(state.length);
+ state.buffer.clear();
+ } else {
+ // read part of list
+ ret = state.buffer.consume(n, state.decoder);
+ }
+ return ret;
+}
+function endReadable(stream) {
+ var state = stream._readableState;
+ debug('endReadable', state.endEmitted);
+ if (!state.endEmitted) {
+ state.ended = true;
+ process.nextTick(endReadableNT, state, stream);
+ }
+}
+function endReadableNT(state, stream) {
+ debug('endReadableNT', state.endEmitted, state.length);
+
+ // Check that we didn't get one last unshift.
+ if (!state.endEmitted && state.length === 0) {
+ state.endEmitted = true;
+ stream.readable = false;
+ stream.emit('end');
+ if (state.autoDestroy) {
+ // In case of duplex streams we need a way to detect
+ // if the writable side is ready for autoDestroy as well
+ var wState = stream._writableState;
+ if (!wState || wState.autoDestroy && wState.finished) {
+ stream.destroy();
+ }
+ }
+ }
+}
+if (typeof Symbol === 'function') {
+ Readable.from = function (iterable, opts) {
+ if (from === undefined) {
+ from = require('./internal/streams/from');
+ }
+ return from(Readable, iterable, opts);
+ };
+}
+function indexOf(xs, x) {
+ for (var i = 0, l = xs.length; i < l; i++) {
+ if (xs[i] === x) return i;
+ }
+ return -1;
+}
\ No newline at end of file
diff --git a/node_modules/readable-stream/lib/_stream_transform.js b/node_modules/readable-stream/lib/_stream_transform.js
new file mode 100644
index 0000000..1ccb715
--- /dev/null
+++ b/node_modules/readable-stream/lib/_stream_transform.js
@@ -0,0 +1,190 @@
+// 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.
+
+// 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 _require$codes = require('../errors').codes,
+ ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
+ ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
+ ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING,
+ ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
+var Duplex = require('./_stream_duplex');
+require('inherits')(Transform, Duplex);
+function afterTransform(er, data) {
+ var ts = this._transformState;
+ ts.transforming = false;
+ var cb = ts.writecb;
+ if (cb === null) {
+ return this.emit('error', new ERR_MULTIPLE_CALLBACK());
+ }
+ ts.writechunk = null;
+ ts.writecb = null;
+ if (data != null)
+ // single equals check for both `null` and `undefined`
+ this.push(data);
+ cb(er);
+ var rs = this._readableState;
+ rs.reading = false;
+ if (rs.needReadable || rs.length < rs.highWaterMark) {
+ this._read(rs.highWaterMark);
+ }
+}
+function Transform(options) {
+ if (!(this instanceof Transform)) return new Transform(options);
+ Duplex.call(this, options);
+ this._transformState = {
+ afterTransform: afterTransform.bind(this),
+ needTransform: false,
+ transforming: false,
+ writecb: null,
+ writechunk: null,
+ writeencoding: null
+ };
+
+ // 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.on('prefinish', prefinish);
+}
+function prefinish() {
+ var _this = this;
+ if (typeof this._flush === 'function' && !this._readableState.destroyed) {
+ this._flush(function (er, data) {
+ done(_this, er, data);
+ });
+ } else {
+ done(this, null, null);
+ }
+}
+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) {
+ cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()'));
+};
+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.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;
+ }
+};
+Transform.prototype._destroy = function (err, cb) {
+ Duplex.prototype._destroy.call(this, err, function (err2) {
+ cb(err2);
+ });
+};
+function done(stream, er, data) {
+ if (er) return stream.emit('error', er);
+ if (data != null)
+ // single equals check for both `null` and `undefined`
+ stream.push(data);
+
+ // TODO(BridgeAR): Write a test for these two error cases
+ // if there's nothing in the write buffer, then that means
+ // that nothing more will ever be provided
+ if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0();
+ if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING();
+ return stream.push(null);
+}
\ No newline at end of file
diff --git a/node_modules/readable-stream/lib/_stream_writable.js b/node_modules/readable-stream/lib/_stream_writable.js
new file mode 100644
index 0000000..292415e
--- /dev/null
+++ b/node_modules/readable-stream/lib/_stream_writable.js
@@ -0,0 +1,641 @@
+// 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.
+
+// 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;
+
+/* */
+function WriteReq(chunk, encoding, cb) {
+ this.chunk = chunk;
+ this.encoding = encoding;
+ this.callback = cb;
+ this.next = null;
+}
+
+// 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 () {
+ onCorkedFinish(_this, state);
+ };
+}
+/* */
+
+/**/
+var Duplex;
+/* */
+
+Writable.WritableState = WritableState;
+
+/**/
+var internalUtil = {
+ deprecate: require('util-deprecate')
+};
+/* */
+
+/**/
+var Stream = require('./internal/streams/stream');
+/* */
+
+var Buffer = require('buffer').Buffer;
+var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
+function _uint8ArrayToBuffer(chunk) {
+ return Buffer.from(chunk);
+}
+function _isUint8Array(obj) {
+ return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
+}
+var destroyImpl = require('./internal/streams/destroy');
+var _require = require('./internal/streams/state'),
+ getHighWaterMark = _require.getHighWaterMark;
+var _require$codes = require('../errors').codes,
+ ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE,
+ ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
+ ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK,
+ ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE,
+ ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED,
+ ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES,
+ ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END,
+ ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
+var errorOrDestroy = destroyImpl.errorOrDestroy;
+require('inherits')(Writable, Stream);
+function nop() {}
+function WritableState(options, stream, isDuplex) {
+ Duplex = Duplex || require('./_stream_duplex');
+ options = options || {};
+
+ // Duplex streams are both readable and writable, but share
+ // the same options object.
+ // However, some cases require setting options to different
+ // values for the readable and the writable sides of the duplex stream,
+ // e.g. options.readableObjectMode vs. options.writableObjectMode, etc.
+ if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex;
+
+ // object stream flag to indicate whether or not this stream
+ // contains buffers or objects.
+ this.objectMode = !!options.objectMode;
+ if (isDuplex) 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()
+ this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex);
+
+ // if _final has been called
+ this.finalCalled = false;
+
+ // 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;
+
+ // has it been destroyed
+ this.destroyed = 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;
+
+ // Should close be emitted on destroy. Defaults to true.
+ this.emitClose = options.emitClose !== false;
+
+ // Should .destroy() be called after 'finish' (and potentially 'end')
+ this.autoDestroy = !!options.autoDestroy;
+
+ // 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 writableStateBufferGetter() {
+ return this.getBuffer();
+ }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
+ });
+ } 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 value(object) {
+ if (realHasInstance.call(this, object)) return true;
+ if (this !== Writable) return false;
+ return object && object._writableState instanceof WritableState;
+ }
+ });
+} else {
+ realHasInstance = function realHasInstance(object) {
+ return object instanceof this;
+ };
+}
+function Writable(options) {
+ Duplex = Duplex || require('./_stream_duplex');
+
+ // 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.
+
+ // Checking for a Stream.Duplex instance is faster here instead of inside
+ // the WritableState constructor, at least with V8 6.5
+ var isDuplex = this instanceof Duplex;
+ if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options);
+ this._writableState = new WritableState(options, this, isDuplex);
+
+ // legacy.
+ this.writable = true;
+ if (options) {
+ if (typeof options.write === 'function') this._write = options.write;
+ if (typeof options.writev === 'function') this._writev = options.writev;
+ if (typeof options.destroy === 'function') this._destroy = options.destroy;
+ if (typeof options.final === 'function') this._final = options.final;
+ }
+ Stream.call(this);
+}
+
+// Otherwise people can pipe Writable streams, which is just wrong.
+Writable.prototype.pipe = function () {
+ errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
+};
+function writeAfterEnd(stream, cb) {
+ var er = new ERR_STREAM_WRITE_AFTER_END();
+ // TODO: defer error events consistently everywhere, not just the cb
+ errorOrDestroy(stream, er);
+ process.nextTick(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 er;
+ if (chunk === null) {
+ er = new ERR_STREAM_NULL_VALUES();
+ } else if (typeof chunk !== 'string' && !state.objectMode) {
+ er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk);
+ }
+ if (er) {
+ errorOrDestroy(stream, er);
+ process.nextTick(cb, er);
+ return false;
+ }
+ return true;
+}
+Writable.prototype.write = function (chunk, encoding, cb) {
+ var state = this._writableState;
+ var ret = false;
+ var isBuf = !state.objectMode && _isUint8Array(chunk);
+ if (isBuf && !Buffer.isBuffer(chunk)) {
+ chunk = _uint8ArrayToBuffer(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.ending) 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 () {
+ this._writableState.corked++;
+};
+Writable.prototype.uncork = function () {
+ var state = this._writableState;
+ if (state.corked) {
+ state.corked--;
+ if (!state.writing && !state.corked && !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 ERR_UNKNOWN_ENCODING(encoding);
+ this._writableState.defaultEncoding = encoding;
+ return this;
+};
+Object.defineProperty(Writable.prototype, 'writableBuffer', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._writableState && this._writableState.getBuffer();
+ }
+});
+function decodeChunk(state, chunk, encoding) {
+ if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
+ chunk = Buffer.from(chunk, encoding);
+ }
+ return chunk;
+}
+Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._writableState.highWaterMark;
+ }
+});
+
+// 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) {
+ var newChunk = decodeChunk(state, chunk, encoding);
+ if (chunk !== newChunk) {
+ isBuf = true;
+ encoding = 'buffer';
+ chunk = newChunk;
+ }
+ }
+ 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 = {
+ chunk: chunk,
+ encoding: encoding,
+ isBuf: isBuf,
+ callback: cb,
+ next: null
+ };
+ 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 (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else 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) {
+ // defer the callback if we are being called synchronously
+ // to avoid piling up things on the stack
+ process.nextTick(cb, er);
+ // this can emit finish, and it will always happen
+ // after error
+ process.nextTick(finishMaybe, stream, state);
+ stream._writableState.errorEmitted = true;
+ errorOrDestroy(stream, er);
+ } else {
+ // the caller expect this to happen before if
+ // it is async
+ cb(er);
+ stream._writableState.errorEmitted = true;
+ errorOrDestroy(stream, er);
+ // this can emit finish, but finish must
+ // always follow error
+ finishMaybe(stream, state);
+ }
+}
+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;
+ if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK();
+ 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) || stream.destroyed;
+ if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
+ clearBuffer(stream, state);
+ }
+ if (sync) {
+ process.nextTick(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;
+ var allBuffers = true;
+ while (entry) {
+ buffer[count] = entry;
+ if (!entry.isBuf) allBuffers = false;
+ entry = entry.next;
+ count += 1;
+ }
+ buffer.allBuffers = allBuffers;
+ 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);
+ }
+ state.bufferedRequestCount = 0;
+ } 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;
+ state.bufferedRequestCount--;
+ // 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.bufferedRequest = entry;
+ state.bufferProcessing = false;
+}
+Writable.prototype._write = function (chunk, encoding, cb) {
+ cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()'));
+};
+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) endWritable(this, state, cb);
+ return this;
+};
+Object.defineProperty(Writable.prototype, 'writableLength', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ return this._writableState.length;
+ }
+});
+function needFinish(state) {
+ return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
+}
+function callFinal(stream, state) {
+ stream._final(function (err) {
+ state.pendingcb--;
+ if (err) {
+ errorOrDestroy(stream, err);
+ }
+ state.prefinished = true;
+ stream.emit('prefinish');
+ finishMaybe(stream, state);
+ });
+}
+function prefinish(stream, state) {
+ if (!state.prefinished && !state.finalCalled) {
+ if (typeof stream._final === 'function' && !state.destroyed) {
+ state.pendingcb++;
+ state.finalCalled = true;
+ process.nextTick(callFinal, stream, state);
+ } else {
+ state.prefinished = true;
+ stream.emit('prefinish');
+ }
+ }
+}
+function finishMaybe(stream, state) {
+ var need = needFinish(state);
+ if (need) {
+ prefinish(stream, state);
+ if (state.pendingcb === 0) {
+ state.finished = true;
+ stream.emit('finish');
+ if (state.autoDestroy) {
+ // In case of duplex streams we need a way to detect
+ // if the readable side is ready for autoDestroy as well
+ var rState = stream._readableState;
+ if (!rState || rState.autoDestroy && rState.endEmitted) {
+ stream.destroy();
+ }
+ }
+ }
+ }
+ return need;
+}
+function endWritable(stream, state, cb) {
+ state.ending = true;
+ finishMaybe(stream, state);
+ if (cb) {
+ if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
+ }
+ state.ended = true;
+ stream.writable = false;
+}
+function onCorkedFinish(corkReq, state, err) {
+ var entry = corkReq.entry;
+ corkReq.entry = null;
+ while (entry) {
+ var cb = entry.callback;
+ state.pendingcb--;
+ cb(err);
+ entry = entry.next;
+ }
+
+ // reuse the free corkReq.
+ state.corkedRequestsFree.next = corkReq;
+}
+Object.defineProperty(Writable.prototype, 'destroyed', {
+ // making it explicit this property is not enumerable
+ // because otherwise some prototype manipulation in
+ // userland will fail
+ enumerable: false,
+ get: function get() {
+ if (this._writableState === undefined) {
+ return false;
+ }
+ return this._writableState.destroyed;
+ },
+ set: function set(value) {
+ // we ignore the value if the stream
+ // has not been initialized yet
+ if (!this._writableState) {
+ return;
+ }
+
+ // backward compatibility, the user is explicitly
+ // managing destroyed
+ this._writableState.destroyed = value;
+ }
+});
+Writable.prototype.destroy = destroyImpl.destroy;
+Writable.prototype._undestroy = destroyImpl.undestroy;
+Writable.prototype._destroy = function (err, cb) {
+ cb(err);
+};
\ No newline at end of file
diff --git a/node_modules/readable-stream/lib/internal/streams/async_iterator.js b/node_modules/readable-stream/lib/internal/streams/async_iterator.js
new file mode 100644
index 0000000..742c5a4
--- /dev/null
+++ b/node_modules/readable-stream/lib/internal/streams/async_iterator.js
@@ -0,0 +1,180 @@
+'use strict';
+
+var _Object$setPrototypeO;
+function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
+function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
+var finished = require('./end-of-stream');
+var kLastResolve = Symbol('lastResolve');
+var kLastReject = Symbol('lastReject');
+var kError = Symbol('error');
+var kEnded = Symbol('ended');
+var kLastPromise = Symbol('lastPromise');
+var kHandlePromise = Symbol('handlePromise');
+var kStream = Symbol('stream');
+function createIterResult(value, done) {
+ return {
+ value: value,
+ done: done
+ };
+}
+function readAndResolve(iter) {
+ var resolve = iter[kLastResolve];
+ if (resolve !== null) {
+ var data = iter[kStream].read();
+ // we defer if data is null
+ // we can be expecting either 'end' or
+ // 'error'
+ if (data !== null) {
+ iter[kLastPromise] = null;
+ iter[kLastResolve] = null;
+ iter[kLastReject] = null;
+ resolve(createIterResult(data, false));
+ }
+ }
+}
+function onReadable(iter) {
+ // we wait for the next tick, because it might
+ // emit an error with process.nextTick
+ process.nextTick(readAndResolve, iter);
+}
+function wrapForNext(lastPromise, iter) {
+ return function (resolve, reject) {
+ lastPromise.then(function () {
+ if (iter[kEnded]) {
+ resolve(createIterResult(undefined, true));
+ return;
+ }
+ iter[kHandlePromise](resolve, reject);
+ }, reject);
+ };
+}
+var AsyncIteratorPrototype = Object.getPrototypeOf(function () {});
+var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
+ get stream() {
+ return this[kStream];
+ },
+ next: function next() {
+ var _this = this;
+ // if we have detected an error in the meanwhile
+ // reject straight away
+ var error = this[kError];
+ if (error !== null) {
+ return Promise.reject(error);
+ }
+ if (this[kEnded]) {
+ return Promise.resolve(createIterResult(undefined, true));
+ }
+ if (this[kStream].destroyed) {
+ // We need to defer via nextTick because if .destroy(err) is
+ // called, the error will be emitted via nextTick, and
+ // we cannot guarantee that there is no error lingering around
+ // waiting to be emitted.
+ return new Promise(function (resolve, reject) {
+ process.nextTick(function () {
+ if (_this[kError]) {
+ reject(_this[kError]);
+ } else {
+ resolve(createIterResult(undefined, true));
+ }
+ });
+ });
+ }
+
+ // if we have multiple next() calls
+ // we will wait for the previous Promise to finish
+ // this logic is optimized to support for await loops,
+ // where next() is only called once at a time
+ var lastPromise = this[kLastPromise];
+ var promise;
+ if (lastPromise) {
+ promise = new Promise(wrapForNext(lastPromise, this));
+ } else {
+ // fast path needed to support multiple this.push()
+ // without triggering the next() queue
+ var data = this[kStream].read();
+ if (data !== null) {
+ return Promise.resolve(createIterResult(data, false));
+ }
+ promise = new Promise(this[kHandlePromise]);
+ }
+ this[kLastPromise] = promise;
+ return promise;
+ }
+}, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () {
+ return this;
+}), _defineProperty(_Object$setPrototypeO, "return", function _return() {
+ var _this2 = this;
+ // destroy(err, cb) is a private API
+ // we can guarantee we have that here, because we control the
+ // Readable class this is attached to
+ return new Promise(function (resolve, reject) {
+ _this2[kStream].destroy(null, function (err) {
+ if (err) {
+ reject(err);
+ return;
+ }
+ resolve(createIterResult(undefined, true));
+ });
+ });
+}), _Object$setPrototypeO), AsyncIteratorPrototype);
+var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) {
+ var _Object$create;
+ var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
+ value: stream,
+ writable: true
+ }), _defineProperty(_Object$create, kLastResolve, {
+ value: null,
+ writable: true
+ }), _defineProperty(_Object$create, kLastReject, {
+ value: null,
+ writable: true
+ }), _defineProperty(_Object$create, kError, {
+ value: null,
+ writable: true
+ }), _defineProperty(_Object$create, kEnded, {
+ value: stream._readableState.endEmitted,
+ writable: true
+ }), _defineProperty(_Object$create, kHandlePromise, {
+ value: function value(resolve, reject) {
+ var data = iterator[kStream].read();
+ if (data) {
+ iterator[kLastPromise] = null;
+ iterator[kLastResolve] = null;
+ iterator[kLastReject] = null;
+ resolve(createIterResult(data, false));
+ } else {
+ iterator[kLastResolve] = resolve;
+ iterator[kLastReject] = reject;
+ }
+ },
+ writable: true
+ }), _Object$create));
+ iterator[kLastPromise] = null;
+ finished(stream, function (err) {
+ if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
+ var reject = iterator[kLastReject];
+ // reject if we are waiting for data in the Promise
+ // returned by next() and store the error
+ if (reject !== null) {
+ iterator[kLastPromise] = null;
+ iterator[kLastResolve] = null;
+ iterator[kLastReject] = null;
+ reject(err);
+ }
+ iterator[kError] = err;
+ return;
+ }
+ var resolve = iterator[kLastResolve];
+ if (resolve !== null) {
+ iterator[kLastPromise] = null;
+ iterator[kLastResolve] = null;
+ iterator[kLastReject] = null;
+ resolve(createIterResult(undefined, true));
+ }
+ iterator[kEnded] = true;
+ });
+ stream.on('readable', onReadable.bind(null, iterator));
+ return iterator;
+};
+module.exports = createReadableStreamAsyncIterator;
\ No newline at end of file
diff --git a/node_modules/readable-stream/lib/internal/streams/buffer_list.js b/node_modules/readable-stream/lib/internal/streams/buffer_list.js
new file mode 100644
index 0000000..69bda49
--- /dev/null
+++ b/node_modules/readable-stream/lib/internal/streams/buffer_list.js
@@ -0,0 +1,183 @@
+'use strict';
+
+function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
+function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
+function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
+function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
+var _require = require('buffer'),
+ Buffer = _require.Buffer;
+var _require2 = require('util'),
+ inspect = _require2.inspect;
+var custom = inspect && inspect.custom || 'inspect';
+function copyBuffer(src, target, offset) {
+ Buffer.prototype.copy.call(src, target, offset);
+}
+module.exports = /*#__PURE__*/function () {
+ function BufferList() {
+ _classCallCheck(this, BufferList);
+ this.head = null;
+ this.tail = null;
+ this.length = 0;
+ }
+ _createClass(BufferList, [{
+ key: "push",
+ value: function push(v) {
+ var entry = {
+ data: v,
+ next: null
+ };
+ if (this.length > 0) this.tail.next = entry;else this.head = entry;
+ this.tail = entry;
+ ++this.length;
+ }
+ }, {
+ key: "unshift",
+ value: function unshift(v) {
+ var entry = {
+ data: v,
+ next: this.head
+ };
+ if (this.length === 0) this.tail = entry;
+ this.head = entry;
+ ++this.length;
+ }
+ }, {
+ key: "shift",
+ value: function shift() {
+ 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;
+ }
+ }, {
+ key: "clear",
+ value: function clear() {
+ this.head = this.tail = null;
+ this.length = 0;
+ }
+ }, {
+ key: "join",
+ value: function join(s) {
+ if (this.length === 0) return '';
+ var p = this.head;
+ var ret = '' + p.data;
+ while (p = p.next) ret += s + p.data;
+ return ret;
+ }
+ }, {
+ key: "concat",
+ value: function concat(n) {
+ if (this.length === 0) return Buffer.alloc(0);
+ var ret = Buffer.allocUnsafe(n >>> 0);
+ var p = this.head;
+ var i = 0;
+ while (p) {
+ copyBuffer(p.data, ret, i);
+ i += p.data.length;
+ p = p.next;
+ }
+ return ret;
+ }
+
+ // Consumes a specified amount of bytes or characters from the buffered data.
+ }, {
+ key: "consume",
+ value: function consume(n, hasStrings) {
+ var ret;
+ if (n < this.head.data.length) {
+ // `slice` is the same for buffers and strings.
+ ret = this.head.data.slice(0, n);
+ this.head.data = this.head.data.slice(n);
+ } else if (n === this.head.data.length) {
+ // First chunk is a perfect match.
+ ret = this.shift();
+ } else {
+ // Result spans more than one buffer.
+ ret = hasStrings ? this._getString(n) : this._getBuffer(n);
+ }
+ return ret;
+ }
+ }, {
+ key: "first",
+ value: function first() {
+ return this.head.data;
+ }
+
+ // Consumes a specified amount of characters from the buffered data.
+ }, {
+ key: "_getString",
+ value: function _getString(n) {
+ var p = this.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) this.head = p.next;else this.head = this.tail = null;
+ } else {
+ this.head = p;
+ p.data = str.slice(nb);
+ }
+ break;
+ }
+ ++c;
+ }
+ this.length -= c;
+ return ret;
+ }
+
+ // Consumes a specified amount of bytes from the buffered data.
+ }, {
+ key: "_getBuffer",
+ value: function _getBuffer(n) {
+ var ret = Buffer.allocUnsafe(n);
+ var p = this.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) this.head = p.next;else this.head = this.tail = null;
+ } else {
+ this.head = p;
+ p.data = buf.slice(nb);
+ }
+ break;
+ }
+ ++c;
+ }
+ this.length -= c;
+ return ret;
+ }
+
+ // Make sure the linked list only shows the minimal necessary information.
+ }, {
+ key: custom,
+ value: function value(_, options) {
+ return inspect(this, _objectSpread(_objectSpread({}, options), {}, {
+ // Only inspect one level.
+ depth: 0,
+ // It should not recurse.
+ customInspect: false
+ }));
+ }
+ }]);
+ return BufferList;
+}();
\ No newline at end of file
diff --git a/node_modules/readable-stream/lib/internal/streams/destroy.js b/node_modules/readable-stream/lib/internal/streams/destroy.js
new file mode 100644
index 0000000..31a17c4
--- /dev/null
+++ b/node_modules/readable-stream/lib/internal/streams/destroy.js
@@ -0,0 +1,96 @@
+'use strict';
+
+// undocumented cb() API, needed for core, not for public API
+function destroy(err, cb) {
+ var _this = this;
+ var readableDestroyed = this._readableState && this._readableState.destroyed;
+ var writableDestroyed = this._writableState && this._writableState.destroyed;
+ if (readableDestroyed || writableDestroyed) {
+ if (cb) {
+ cb(err);
+ } else if (err) {
+ if (!this._writableState) {
+ process.nextTick(emitErrorNT, this, err);
+ } else if (!this._writableState.errorEmitted) {
+ this._writableState.errorEmitted = true;
+ process.nextTick(emitErrorNT, this, err);
+ }
+ }
+ return this;
+ }
+
+ // we set destroyed to true before firing error callbacks in order
+ // to make it re-entrance safe in case destroy() is called within callbacks
+
+ if (this._readableState) {
+ this._readableState.destroyed = true;
+ }
+
+ // if this is a duplex stream mark the writable part as destroyed as well
+ if (this._writableState) {
+ this._writableState.destroyed = true;
+ }
+ this._destroy(err || null, function (err) {
+ if (!cb && err) {
+ if (!_this._writableState) {
+ process.nextTick(emitErrorAndCloseNT, _this, err);
+ } else if (!_this._writableState.errorEmitted) {
+ _this._writableState.errorEmitted = true;
+ process.nextTick(emitErrorAndCloseNT, _this, err);
+ } else {
+ process.nextTick(emitCloseNT, _this);
+ }
+ } else if (cb) {
+ process.nextTick(emitCloseNT, _this);
+ cb(err);
+ } else {
+ process.nextTick(emitCloseNT, _this);
+ }
+ });
+ return this;
+}
+function emitErrorAndCloseNT(self, err) {
+ emitErrorNT(self, err);
+ emitCloseNT(self);
+}
+function emitCloseNT(self) {
+ if (self._writableState && !self._writableState.emitClose) return;
+ if (self._readableState && !self._readableState.emitClose) return;
+ self.emit('close');
+}
+function undestroy() {
+ if (this._readableState) {
+ this._readableState.destroyed = false;
+ this._readableState.reading = false;
+ this._readableState.ended = false;
+ this._readableState.endEmitted = false;
+ }
+ if (this._writableState) {
+ this._writableState.destroyed = false;
+ this._writableState.ended = false;
+ this._writableState.ending = false;
+ this._writableState.finalCalled = false;
+ this._writableState.prefinished = false;
+ this._writableState.finished = false;
+ this._writableState.errorEmitted = false;
+ }
+}
+function emitErrorNT(self, err) {
+ self.emit('error', err);
+}
+function errorOrDestroy(stream, err) {
+ // We have tests that rely on errors being emitted
+ // in the same tick, so changing this is semver major.
+ // For now when you opt-in to autoDestroy we allow
+ // the error to be emitted nextTick. In a future
+ // semver major update we should change the default to this.
+
+ var rState = stream._readableState;
+ var wState = stream._writableState;
+ if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
+}
+module.exports = {
+ destroy: destroy,
+ undestroy: undestroy,
+ errorOrDestroy: errorOrDestroy
+};
\ No newline at end of file
diff --git a/node_modules/readable-stream/lib/internal/streams/end-of-stream.js b/node_modules/readable-stream/lib/internal/streams/end-of-stream.js
new file mode 100644
index 0000000..59c671b
--- /dev/null
+++ b/node_modules/readable-stream/lib/internal/streams/end-of-stream.js
@@ -0,0 +1,86 @@
+// Ported from https://github.com/mafintosh/end-of-stream with
+// permission from the author, Mathias Buus (@mafintosh).
+
+'use strict';
+
+var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE;
+function once(callback) {
+ var called = false;
+ return function () {
+ if (called) return;
+ called = true;
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
+ args[_key] = arguments[_key];
+ }
+ callback.apply(this, args);
+ };
+}
+function noop() {}
+function isRequest(stream) {
+ return stream.setHeader && typeof stream.abort === 'function';
+}
+function eos(stream, opts, callback) {
+ if (typeof opts === 'function') return eos(stream, null, opts);
+ if (!opts) opts = {};
+ callback = once(callback || noop);
+ var readable = opts.readable || opts.readable !== false && stream.readable;
+ var writable = opts.writable || opts.writable !== false && stream.writable;
+ var onlegacyfinish = function onlegacyfinish() {
+ if (!stream.writable) onfinish();
+ };
+ var writableEnded = stream._writableState && stream._writableState.finished;
+ var onfinish = function onfinish() {
+ writable = false;
+ writableEnded = true;
+ if (!readable) callback.call(stream);
+ };
+ var readableEnded = stream._readableState && stream._readableState.endEmitted;
+ var onend = function onend() {
+ readable = false;
+ readableEnded = true;
+ if (!writable) callback.call(stream);
+ };
+ var onerror = function onerror(err) {
+ callback.call(stream, err);
+ };
+ var onclose = function onclose() {
+ var err;
+ if (readable && !readableEnded) {
+ if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
+ return callback.call(stream, err);
+ }
+ if (writable && !writableEnded) {
+ if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE();
+ return callback.call(stream, err);
+ }
+ };
+ var onrequest = function onrequest() {
+ stream.req.on('finish', onfinish);
+ };
+ if (isRequest(stream)) {
+ stream.on('complete', onfinish);
+ stream.on('abort', onclose);
+ if (stream.req) onrequest();else stream.on('request', onrequest);
+ } else if (writable && !stream._writableState) {
+ // legacy streams
+ stream.on('end', onlegacyfinish);
+ stream.on('close', onlegacyfinish);
+ }
+ stream.on('end', onend);
+ stream.on('finish', onfinish);
+ if (opts.error !== false) stream.on('error', onerror);
+ stream.on('close', onclose);
+ return function () {
+ stream.removeListener('complete', onfinish);
+ stream.removeListener('abort', onclose);
+ stream.removeListener('request', onrequest);
+ if (stream.req) stream.req.removeListener('finish', onfinish);
+ stream.removeListener('end', onlegacyfinish);
+ stream.removeListener('close', onlegacyfinish);
+ stream.removeListener('finish', onfinish);
+ stream.removeListener('end', onend);
+ stream.removeListener('error', onerror);
+ stream.removeListener('close', onclose);
+ };
+}
+module.exports = eos;
\ No newline at end of file
diff --git a/node_modules/readable-stream/lib/internal/streams/from-browser.js b/node_modules/readable-stream/lib/internal/streams/from-browser.js
new file mode 100644
index 0000000..a4ce56f
--- /dev/null
+++ b/node_modules/readable-stream/lib/internal/streams/from-browser.js
@@ -0,0 +1,3 @@
+module.exports = function () {
+ throw new Error('Readable.from is not available in the browser')
+};
diff --git a/node_modules/readable-stream/lib/internal/streams/from.js b/node_modules/readable-stream/lib/internal/streams/from.js
new file mode 100644
index 0000000..0a34ee9
--- /dev/null
+++ b/node_modules/readable-stream/lib/internal/streams/from.js
@@ -0,0 +1,52 @@
+'use strict';
+
+function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
+function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
+function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
+function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
+function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
+function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
+function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
+var ERR_INVALID_ARG_TYPE = require('../../../errors').codes.ERR_INVALID_ARG_TYPE;
+function from(Readable, iterable, opts) {
+ var iterator;
+ if (iterable && typeof iterable.next === 'function') {
+ iterator = iterable;
+ } else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();else throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable);
+ var readable = new Readable(_objectSpread({
+ objectMode: true
+ }, opts));
+ // Reading boolean to protect against _read
+ // being called before last iteration completion.
+ var reading = false;
+ readable._read = function () {
+ if (!reading) {
+ reading = true;
+ next();
+ }
+ };
+ function next() {
+ return _next2.apply(this, arguments);
+ }
+ function _next2() {
+ _next2 = _asyncToGenerator(function* () {
+ try {
+ var _yield$iterator$next = yield iterator.next(),
+ value = _yield$iterator$next.value,
+ done = _yield$iterator$next.done;
+ if (done) {
+ readable.push(null);
+ } else if (readable.push(yield value)) {
+ next();
+ } else {
+ reading = false;
+ }
+ } catch (err) {
+ readable.destroy(err);
+ }
+ });
+ return _next2.apply(this, arguments);
+ }
+ return readable;
+}
+module.exports = from;
diff --git a/node_modules/readable-stream/lib/internal/streams/pipeline.js b/node_modules/readable-stream/lib/internal/streams/pipeline.js
new file mode 100644
index 0000000..e6f3924
--- /dev/null
+++ b/node_modules/readable-stream/lib/internal/streams/pipeline.js
@@ -0,0 +1,86 @@
+// Ported from https://github.com/mafintosh/pump with
+// permission from the author, Mathias Buus (@mafintosh).
+
+'use strict';
+
+var eos;
+function once(callback) {
+ var called = false;
+ return function () {
+ if (called) return;
+ called = true;
+ callback.apply(void 0, arguments);
+ };
+}
+var _require$codes = require('../../../errors').codes,
+ ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS,
+ ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
+function noop(err) {
+ // Rethrow the error if it exists to avoid swallowing it
+ if (err) throw err;
+}
+function isRequest(stream) {
+ return stream.setHeader && typeof stream.abort === 'function';
+}
+function destroyer(stream, reading, writing, callback) {
+ callback = once(callback);
+ var closed = false;
+ stream.on('close', function () {
+ closed = true;
+ });
+ if (eos === undefined) eos = require('./end-of-stream');
+ eos(stream, {
+ readable: reading,
+ writable: writing
+ }, function (err) {
+ if (err) return callback(err);
+ closed = true;
+ callback();
+ });
+ var destroyed = false;
+ return function (err) {
+ if (closed) return;
+ if (destroyed) return;
+ destroyed = true;
+
+ // request.destroy just do .end - .abort is what we want
+ if (isRequest(stream)) return stream.abort();
+ if (typeof stream.destroy === 'function') return stream.destroy();
+ callback(err || new ERR_STREAM_DESTROYED('pipe'));
+ };
+}
+function call(fn) {
+ fn();
+}
+function pipe(from, to) {
+ return from.pipe(to);
+}
+function popCallback(streams) {
+ if (!streams.length) return noop;
+ if (typeof streams[streams.length - 1] !== 'function') return noop;
+ return streams.pop();
+}
+function pipeline() {
+ for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) {
+ streams[_key] = arguments[_key];
+ }
+ var callback = popCallback(streams);
+ if (Array.isArray(streams[0])) streams = streams[0];
+ if (streams.length < 2) {
+ throw new ERR_MISSING_ARGS('streams');
+ }
+ var error;
+ var destroys = streams.map(function (stream, i) {
+ var reading = i < streams.length - 1;
+ var writing = i > 0;
+ return destroyer(stream, reading, writing, function (err) {
+ if (!error) error = err;
+ if (err) destroys.forEach(call);
+ if (reading) return;
+ destroys.forEach(call);
+ callback(error);
+ });
+ });
+ return streams.reduce(pipe);
+}
+module.exports = pipeline;
\ No newline at end of file
diff --git a/node_modules/readable-stream/lib/internal/streams/state.js b/node_modules/readable-stream/lib/internal/streams/state.js
new file mode 100644
index 0000000..3fbf892
--- /dev/null
+++ b/node_modules/readable-stream/lib/internal/streams/state.js
@@ -0,0 +1,22 @@
+'use strict';
+
+var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;
+function highWaterMarkFrom(options, isDuplex, duplexKey) {
+ return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
+}
+function getHighWaterMark(state, options, duplexKey, isDuplex) {
+ var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
+ if (hwm != null) {
+ if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
+ var name = isDuplex ? duplexKey : 'highWaterMark';
+ throw new ERR_INVALID_OPT_VALUE(name, hwm);
+ }
+ return Math.floor(hwm);
+ }
+
+ // Default value
+ return state.objectMode ? 16 : 16 * 1024;
+}
+module.exports = {
+ getHighWaterMark: getHighWaterMark
+};
\ No newline at end of file
diff --git a/node_modules/readable-stream/lib/internal/streams/stream-browser.js b/node_modules/readable-stream/lib/internal/streams/stream-browser.js
new file mode 100644
index 0000000..9332a3f
--- /dev/null
+++ b/node_modules/readable-stream/lib/internal/streams/stream-browser.js
@@ -0,0 +1 @@
+module.exports = require('events').EventEmitter;
diff --git a/node_modules/readable-stream/lib/internal/streams/stream.js b/node_modules/readable-stream/lib/internal/streams/stream.js
new file mode 100644
index 0000000..ce2ad5b
--- /dev/null
+++ b/node_modules/readable-stream/lib/internal/streams/stream.js
@@ -0,0 +1 @@
+module.exports = require('stream');
diff --git a/node_modules/readable-stream/package.json b/node_modules/readable-stream/package.json
new file mode 100644
index 0000000..ade59e7
--- /dev/null
+++ b/node_modules/readable-stream/package.json
@@ -0,0 +1,68 @@
+{
+ "name": "readable-stream",
+ "version": "3.6.2",
+ "description": "Streams3, a user-land copy of the stream library from Node.js",
+ "main": "readable.js",
+ "engines": {
+ "node": ">= 6"
+ },
+ "dependencies": {
+ "inherits": "^2.0.3",
+ "string_decoder": "^1.1.1",
+ "util-deprecate": "^1.0.1"
+ },
+ "devDependencies": {
+ "@babel/cli": "^7.2.0",
+ "@babel/core": "^7.2.0",
+ "@babel/polyfill": "^7.0.0",
+ "@babel/preset-env": "^7.2.0",
+ "airtap": "0.0.9",
+ "assert": "^1.4.0",
+ "bl": "^2.0.0",
+ "deep-strict-equal": "^0.2.0",
+ "events.once": "^2.0.2",
+ "glob": "^7.1.2",
+ "gunzip-maybe": "^1.4.1",
+ "hyperquest": "^2.1.3",
+ "lolex": "^2.6.0",
+ "nyc": "^11.0.0",
+ "pump": "^3.0.0",
+ "rimraf": "^2.6.2",
+ "tap": "^12.0.0",
+ "tape": "^4.9.0",
+ "tar-fs": "^1.16.2",
+ "util-promisify": "^2.1.0"
+ },
+ "scripts": {
+ "test": "tap -J --no-esm test/parallel/*.js test/ours/*.js",
+ "ci": "TAP=1 tap --no-esm test/parallel/*.js test/ours/*.js | tee test.tap",
+ "test-browsers": "airtap --sauce-connect --loopback airtap.local -- test/browser.js",
+ "test-browser-local": "airtap --open --local -- test/browser.js",
+ "cover": "nyc npm test",
+ "report": "nyc report --reporter=lcov",
+ "update-browser-errors": "babel -o errors-browser.js errors.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/nodejs/readable-stream"
+ },
+ "keywords": [
+ "readable",
+ "stream",
+ "pipe"
+ ],
+ "browser": {
+ "util": false,
+ "worker_threads": false,
+ "./errors": "./errors-browser.js",
+ "./readable.js": "./readable-browser.js",
+ "./lib/internal/streams/from.js": "./lib/internal/streams/from-browser.js",
+ "./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js"
+ },
+ "nyc": {
+ "include": [
+ "lib/**.js"
+ ]
+ },
+ "license": "MIT"
+}
diff --git a/node_modules/readable-stream/readable-browser.js b/node_modules/readable-stream/readable-browser.js
new file mode 100644
index 0000000..adbf60d
--- /dev/null
+++ b/node_modules/readable-stream/readable-browser.js
@@ -0,0 +1,9 @@
+exports = module.exports = require('./lib/_stream_readable.js');
+exports.Stream = exports;
+exports.Readable = exports;
+exports.Writable = require('./lib/_stream_writable.js');
+exports.Duplex = require('./lib/_stream_duplex.js');
+exports.Transform = require('./lib/_stream_transform.js');
+exports.PassThrough = require('./lib/_stream_passthrough.js');
+exports.finished = require('./lib/internal/streams/end-of-stream.js');
+exports.pipeline = require('./lib/internal/streams/pipeline.js');
diff --git a/node_modules/readable-stream/readable.js b/node_modules/readable-stream/readable.js
new file mode 100644
index 0000000..9e0ca12
--- /dev/null
+++ b/node_modules/readable-stream/readable.js
@@ -0,0 +1,16 @@
+var Stream = require('stream');
+if (process.env.READABLE_STREAM === 'disable' && Stream) {
+ module.exports = Stream.Readable;
+ Object.assign(module.exports, Stream);
+ module.exports.Stream = Stream;
+} else {
+ exports = module.exports = require('./lib/_stream_readable.js');
+ exports.Stream = Stream || exports;
+ exports.Readable = exports;
+ exports.Writable = require('./lib/_stream_writable.js');
+ exports.Duplex = require('./lib/_stream_duplex.js');
+ exports.Transform = require('./lib/_stream_transform.js');
+ exports.PassThrough = require('./lib/_stream_passthrough.js');
+ exports.finished = require('./lib/internal/streams/end-of-stream.js');
+ exports.pipeline = require('./lib/internal/streams/pipeline.js');
+}
diff --git a/node_modules/rimraf/LICENSE b/node_modules/rimraf/LICENSE
new file mode 100644
index 0000000..1493534
--- /dev/null
+++ b/node_modules/rimraf/LICENSE
@@ -0,0 +1,15 @@
+The ISC License
+
+Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/node_modules/rimraf/README.md b/node_modules/rimraf/README.md
new file mode 100644
index 0000000..0f57b05
--- /dev/null
+++ b/node_modules/rimraf/README.md
@@ -0,0 +1,214 @@
+The [UNIX command]() `rm -rf` for node.
+
+Install with `npm install rimraf`.
+
+## Major Changes from v3 to v4
+
+- The function returns a `Promise` instead of taking a callback.
+- Globbing requires the `--glob` option to be set. (Removed in
+ 4.0 and 4.1, opt-in support added in 4.2.)
+- Functions take arrays of paths, as well as a single path.
+- Native implementation used by default when available, except on
+ Windows, where this implementation is faster and more reliable.
+- New implementation on Windows, falling back to "move then
+ remove" strategy when exponential backoff for `EBUSY` fails to
+ resolve the situation.
+- Simplified implementation on Posix, since the Windows
+ affordances are not necessary there.
+- As of 4.3, return/resolve value is boolean instead of undefined
+
+## API
+
+Hybrid module, load either with `import` or `require()`.
+
+```js
+// default export is the main rimraf function, or use named imports
+import rimraf from 'rimraf'
+// or
+const rimraf = require('rimraf')
+
+// other strategies exported as well
+import { rimraf, rimrafSync, native, nativeSync } from 'rimraf'
+// or
+const { rimraf, rimrafSync, native, nativeSync } = require('rimraf')
+```
+
+All removal functions return a boolean indicating that all
+entries were successfully removed.
+
+The only case in which this will not return `true` is if
+something was omitted from the removal via a `filter` option.
+
+### `rimraf(f, [opts]) -> Promise`
+
+This first parameter is a path or array of paths. The second
+argument is an options object.
+
+Options:
+
+- `preserveRoot`: If set to boolean `false`, then allow the
+ recursive removal of the root directory. Otherwise, this is
+ not allowed.
+- `tmp`: Windows only. Temp folder to use to place files and
+ folders for the "move then remove" fallback. Must be on the
+ same physical device as the path being deleted. Defaults to
+ `os.tmpdir()` when that is on the same drive letter as the path
+ being deleted, or `${drive}:\temp` if present, or `${drive}:\`
+ if not.
+- `maxRetries`: Windows and Native only. Maximum number of
+ retry attempts in case of `EBUSY`, `EMFILE`, and `ENFILE`
+ errors. Default `10` for Windows implementation, `0` for Native
+ implementation.
+- `backoff`: Windows only. Rate of exponential backoff for async
+ removal in case of `EBUSY`, `EMFILE`, and `ENFILE` errors.
+ Should be a number greater than 1. Default `1.2`
+- `maxBackoff`: Windows only. Maximum total backoff time in ms to
+ attempt asynchronous retries in case of `EBUSY`, `EMFILE`, and
+ `ENFILE` errors. Default `200`. With the default `1.2` backoff
+ rate, this results in 14 retries, with the final retry being
+ delayed 33ms.
+- `retryDelay`: Native only. Time to wait between retries, using
+ linear backoff. Default `100`.
+- `signal` Pass in an AbortSignal to cancel the directory
+ removal. This is useful when removing large folder structures,
+ if you'd like to limit the amount of time spent.
+
+ Using a `signal` option prevents the use of Node's built-in
+ `fs.rm` because that implementation does not support abort
+ signals.
+
+- `filter` Method that returns a boolean indicating whether that
+ path should be deleted. With async rimraf methods, this may
+ return a Promise that resolves to a boolean. (Since Promises
+ are truthy, returning a Promise from a sync filter is the same
+ as just not filtering anything.)
+
+ The first argument to the filter is the path string. The
+ second argument is either a `Dirent` or `Stats` object for that
+ path. (The first path explored will be a `Stats`, the rest
+ will be `Dirent`.)
+
+ If a filter method is provided, it will _only_ remove entries
+ if the filter returns (or resolves to) a truthy value. Omitting
+ a directory will still allow its children to be removed, unless
+ they are also filtered out, but any parents of a filtered entry
+ will not be removed, since the directory would not be empty in
+ that case.
+
+ Using a filter method prevents the use of Node's built-in
+ `fs.rm` because that implementation does not support filtering.
+
+Any other options are provided to the native Node.js `fs.rm` implementation
+when that is used.
+
+This will attempt to choose the best implementation, based on Node.js
+version and `process.platform`. To force a specific implementation, use
+one of the other functions provided.
+
+### `rimraf.sync(f, [opts])` `rimraf.rimrafSync(f, [opts])`
+
+Synchronous form of `rimraf()`
+
+Note that, unlike many file system operations, the synchronous form will
+typically be significantly _slower_ than the async form, because recursive
+deletion is extremely parallelizable.
+
+### `rimraf.native(f, [opts])`
+
+Uses the built-in `fs.rm` implementation that Node.js provides. This is
+used by default on Node.js versions greater than or equal to `14.14.0`.
+
+### `rimraf.nativeSync(f, [opts])` `rimraf.native.sync(f, [opts])`
+
+Synchronous form of `rimraf.native`
+
+### `rimraf.manual(f, [opts])`
+
+Use the JavaScript implementation appropriate for your operating system.
+
+### `rimraf.manualSync(f, [opts])` `rimraf.manualSync(f, opts)`
+
+Synchronous form of `rimraf.manual()`
+
+### `rimraf.windows(f, [opts])`
+
+JavaScript implementation of file removal appropriate for Windows
+platforms. Works around `unlink` and `rmdir` not being atomic
+operations, and `EPERM` when deleting files with certain
+permission modes.
+
+First deletes all non-directory files within the tree, and then
+removes all directories, which should ideally be empty by that
+time. When an `ENOTEMPTY` is raised in the second pass, falls
+back to the `rimraf.moveRemove` strategy as needed.
+
+### `rimraf.windows.sync(path, [opts])` `rimraf.windowsSync(path, [opts])`
+
+Synchronous form of `rimraf.windows()`
+
+### `rimraf.moveRemove(path, [opts])`
+
+Moves all files and folders to the parent directory of `path`
+with a temporary filename prior to attempting to remove them.
+
+Note that, in cases where the operation fails, this _may_ leave
+files lying around in the parent directory with names like
+`.file-basename.txt.0.123412341`. Until the Windows kernel
+provides a way to perform atomic `unlink` and `rmdir` operations,
+this is unfortunately unavoidable.
+
+To move files to a different temporary directory other than the
+parent, provide `opts.tmp`. Note that this _must_ be on the same
+physical device as the folder being deleted, or else the
+operation will fail.
+
+This is the slowest strategy, but most reliable on Windows
+platforms. Used as a last-ditch fallback by `rimraf.windows()`.
+
+### `rimraf.moveRemove.sync(path, [opts])` `rimraf.moveRemoveSync(path, [opts])`
+
+Synchronous form of `rimraf.moveRemove()`
+
+### Command Line Interface
+
+```
+rimraf version 4.3.0
+
+Usage: rimraf [ ...]
+Deletes all files and folders at "path", recursively.
+
+Options:
+ -- Treat all subsequent arguments as paths
+ -h --help Display this usage info
+ --preserve-root Do not remove '/' recursively (default)
+ --no-preserve-root Do not treat '/' specially
+ -G --no-glob Treat arguments as literal paths, not globs (default)
+ -g --glob Treat arguments as glob patterns
+ -v --verbose Be verbose when deleting files, showing them as
+ they are removed. Not compatible with --impl=native
+ -V --no-verbose Be silent when deleting files, showing nothing as
+ they are removed (default)
+ -i --interactive Ask for confirmation before deleting anything
+ Not compatible with --impl=native
+ -I --no-interactive Do not ask for confirmation before deleting
+
+ --impl= Specify the implementation to use:
+ rimraf: choose the best option (default)
+ native: the built-in implementation in Node.js
+ manual: the platform-specific JS implementation
+ posix: the Posix JS implementation
+ windows: the Windows JS implementation (falls back to
+ move-remove on ENOTEMPTY)
+ move-remove: a slow reliable Windows fallback
+
+Implementation-specific options:
+ --tmp= Temp file folder for 'move-remove' implementation
+ --max-retries= maxRetries for 'native' and 'windows' implementations
+ --retry-delay= retryDelay for 'native' implementation, default 100
+ --backoff= Exponential backoff factor for retries (default: 1.2)
+```
+
+## mkdirp
+
+If you need to _create_ a directory recursively, check out
+[mkdirp](https://github.com/isaacs/node-mkdirp).
diff --git a/node_modules/rimraf/dist/cjs/package.json b/node_modules/rimraf/dist/cjs/package.json
new file mode 100644
index 0000000..ea8c28b
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/package.json
@@ -0,0 +1,84 @@
+{
+ "name": "rimraf",
+ "version": "4.4.1",
+ "main": "./dist/cjs/src/index-cjs.js",
+ "module": "./dist/mjs/index.js",
+ "types": "./dist/mjs/index.d.ts",
+ "bin": "./dist/cjs/src/bin.js",
+ "exports": {
+ ".": {
+ "import": {
+ "types": "./dist/mjs/index.d.ts",
+ "default": "./dist/mjs/index.js"
+ },
+ "require": {
+ "types": "./dist/cjs/src/index.d.ts",
+ "default": "./dist/cjs/src/index-cjs.js"
+ }
+ }
+ },
+ "files": [
+ "dist"
+ ],
+ "description": "A deep deletion module for node (like `rm -rf`)",
+ "author": "Isaac Z. Schlueter (http://blog.izs.me/)",
+ "license": "ISC",
+ "repository": "git://github.com/isaacs/rimraf.git",
+ "scripts": {
+ "preversion": "npm test",
+ "postversion": "npm publish",
+ "prepublishOnly": "git push origin --follow-tags",
+ "preprepare": "rm -rf dist",
+ "prepare": "tsc -p tsconfig.json && tsc -p tsconfig-esm.json",
+ "postprepare": "bash fixup.sh",
+ "pretest": "npm run prepare",
+ "presnap": "npm run prepare",
+ "test": "c8 tap",
+ "snap": "c8 tap",
+ "format": "prettier --write . --loglevel warn",
+ "benchmark": "node benchmark/index.js",
+ "typedoc": "typedoc --tsconfig tsconfig-esm.json ./src/*.ts"
+ },
+ "prettier": {
+ "semi": false,
+ "printWidth": 80,
+ "tabWidth": 2,
+ "useTabs": false,
+ "singleQuote": true,
+ "jsxSingleQuote": false,
+ "bracketSameLine": true,
+ "arrowParens": "avoid",
+ "endOfLine": "lf"
+ },
+ "devDependencies": {
+ "@types/node": "^18.11.9",
+ "@types/tap": "^15.0.7",
+ "c8": "^7.12.0",
+ "eslint-config-prettier": "^8.6.0",
+ "mkdirp": "1",
+ "prettier": "^2.8.2",
+ "tap": "^16.3.4",
+ "ts-node": "^10.9.1",
+ "typedoc": "^0.23.21",
+ "typescript": "^4.9.3"
+ },
+ "tap": {
+ "coverage": false,
+ "libtap-settings": "libtap-settings.js",
+ "node-arg": [
+ "--no-warnings",
+ "--loader",
+ "ts-node/esm"
+ ],
+ "ts": false
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "dependencies": {
+ "glob": "^9.2.0"
+ }
+}
diff --git a/node_modules/rimraf/dist/cjs/src/bin.d.ts b/node_modules/rimraf/dist/cjs/src/bin.d.ts
new file mode 100644
index 0000000..ecc2fcb
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/bin.d.ts
@@ -0,0 +1,8 @@
+#!/usr/bin/env node
+export declare const help: string;
+declare const main: {
+ (...args: string[]): Promise<1 | 0>;
+ help: string;
+};
+export default main;
+//# sourceMappingURL=bin.d.ts.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/bin.d.ts.map b/node_modules/rimraf/dist/cjs/src/bin.d.ts.map
new file mode 100644
index 0000000..7f1fee6
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/bin.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../../src/bin.ts"],"names":[],"mappings":";AAQA,eAAO,MAAM,IAAI,QAkChB,CAAA;AA6ED,QAAA,MAAM,IAAI;cAAmB,MAAM,EAAE;;CAoIpC,CAAA;AAGD,eAAe,IAAI,CAAA"}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/bin.js b/node_modules/rimraf/dist/cjs/src/bin.js
new file mode 100755
index 0000000..bbff722
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/bin.js
@@ -0,0 +1,260 @@
+#!/usr/bin/env node
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.help = void 0;
+const package_json_1 = require("../package.json");
+const index_cjs_js_1 = __importDefault(require("./index-cjs.js"));
+const runHelpForUsage = () => console.error('run `rimraf --help` for usage information');
+exports.help = `rimraf version ${package_json_1.version}
+
+Usage: rimraf [ ...]
+Deletes all files and folders at "path", recursively.
+
+Options:
+ -- Treat all subsequent arguments as paths
+ -h --help Display this usage info
+ --preserve-root Do not remove '/' recursively (default)
+ --no-preserve-root Do not treat '/' specially
+ -G --no-glob Treat arguments as literal paths, not globs (default)
+ -g --glob Treat arguments as glob patterns
+ -v --verbose Be verbose when deleting files, showing them as
+ they are removed. Not compatible with --impl=native
+ -V --no-verbose Be silent when deleting files, showing nothing as
+ they are removed (default)
+ -i --interactive Ask for confirmation before deleting anything
+ Not compatible with --impl=native
+ -I --no-interactive Do not ask for confirmation before deleting
+
+ --impl= Specify the implementation to use:
+ rimraf: choose the best option (default)
+ native: the built-in implementation in Node.js
+ manual: the platform-specific JS implementation
+ posix: the Posix JS implementation
+ windows: the Windows JS implementation (falls back to
+ move-remove on ENOTEMPTY)
+ move-remove: a slow reliable Windows fallback
+
+Implementation-specific options:
+ --tmp= Temp file folder for 'move-remove' implementation
+ --max-retries= maxRetries for 'native' and 'windows' implementations
+ --retry-delay= retryDelay for 'native' implementation, default 100
+ --backoff= Exponential backoff factor for retries (default: 1.2)
+`;
+const path_1 = require("path");
+const cwd = process.cwd();
+const readline_1 = require("readline");
+const prompt = async (rl, q) => new Promise(res => rl.question(q, res));
+const interactiveRimraf = async (impl, paths, opt) => {
+ const existingFilter = opt.filter || (() => true);
+ let allRemaining = false;
+ let noneRemaining = false;
+ const queue = [];
+ let processing = false;
+ const processQueue = async () => {
+ if (processing)
+ return;
+ processing = true;
+ let next;
+ while ((next = queue.shift())) {
+ await next();
+ }
+ processing = false;
+ };
+ const oneAtATime = (fn) => async (s, e) => {
+ const p = new Promise(res => {
+ queue.push(async () => {
+ const result = await fn(s, e);
+ res(result);
+ return result;
+ });
+ });
+ processQueue();
+ return p;
+ };
+ const rl = (0, readline_1.createInterface)({
+ input: process.stdin,
+ output: process.stdout,
+ });
+ opt.filter = oneAtATime(async (path, ent) => {
+ if (noneRemaining) {
+ return false;
+ }
+ while (!allRemaining) {
+ const a = (await prompt(rl, `rm? ${(0, path_1.relative)(cwd, path)}\n[(Yes)/No/All/Quit] > `)).trim();
+ if (/^n/i.test(a)) {
+ return false;
+ }
+ else if (/^a/i.test(a)) {
+ allRemaining = true;
+ break;
+ }
+ else if (/^q/i.test(a)) {
+ noneRemaining = true;
+ return false;
+ }
+ else if (a === '' || /^y/i.test(a)) {
+ break;
+ }
+ else {
+ continue;
+ }
+ }
+ return existingFilter(path, ent);
+ });
+ await impl(paths, opt);
+ rl.close();
+};
+const main = async (...args) => {
+ const verboseFilter = (s) => {
+ console.log((0, path_1.relative)(cwd, s));
+ return true;
+ };
+ if (process.env.__RIMRAF_TESTING_BIN_FAIL__ === '1') {
+ throw new Error('simulated rimraf failure');
+ }
+ const opt = {};
+ const paths = [];
+ let dashdash = false;
+ let impl = index_cjs_js_1.default;
+ let interactive = false;
+ for (const arg of args) {
+ if (dashdash) {
+ paths.push(arg);
+ continue;
+ }
+ if (arg === '--') {
+ dashdash = true;
+ continue;
+ }
+ else if (arg === '-rf' || arg === '-fr') {
+ // this never did anything, but people put it there I guess
+ continue;
+ }
+ else if (arg === '-h' || arg === '--help') {
+ console.log(exports.help);
+ return 0;
+ }
+ else if (arg === '--interactive' || arg === '-i') {
+ interactive = true;
+ continue;
+ }
+ else if (arg === '--no-interactive' || arg === '-I') {
+ interactive = false;
+ continue;
+ }
+ else if (arg === '--verbose' || arg === '-v') {
+ opt.filter = verboseFilter;
+ continue;
+ }
+ else if (arg === '--no-verbose' || arg === '-V') {
+ opt.filter = undefined;
+ continue;
+ }
+ else if (arg === '-g' || arg === '--glob') {
+ opt.glob = true;
+ continue;
+ }
+ else if (arg === '-G' || arg === '--no-glob') {
+ opt.glob = false;
+ continue;
+ }
+ else if (arg === '--preserve-root') {
+ opt.preserveRoot = true;
+ continue;
+ }
+ else if (arg === '--no-preserve-root') {
+ opt.preserveRoot = false;
+ continue;
+ }
+ else if (/^--tmp=/.test(arg)) {
+ const val = arg.substring('--tmp='.length);
+ opt.tmp = val;
+ continue;
+ }
+ else if (/^--max-retries=/.test(arg)) {
+ const val = +arg.substring('--max-retries='.length);
+ opt.maxRetries = val;
+ continue;
+ }
+ else if (/^--retry-delay=/.test(arg)) {
+ const val = +arg.substring('--retry-delay='.length);
+ opt.retryDelay = val;
+ continue;
+ }
+ else if (/^--backoff=/.test(arg)) {
+ const val = +arg.substring('--backoff='.length);
+ opt.backoff = val;
+ continue;
+ }
+ else if (/^--impl=/.test(arg)) {
+ const val = arg.substring('--impl='.length);
+ switch (val) {
+ case 'rimraf':
+ impl = index_cjs_js_1.default;
+ continue;
+ case 'native':
+ case 'manual':
+ case 'posix':
+ case 'windows':
+ impl = index_cjs_js_1.default[val];
+ continue;
+ case 'move-remove':
+ impl = index_cjs_js_1.default.moveRemove;
+ continue;
+ default:
+ console.error(`unknown implementation: ${val}`);
+ runHelpForUsage();
+ return 1;
+ }
+ }
+ else if (/^-/.test(arg)) {
+ console.error(`unknown option: ${arg}`);
+ runHelpForUsage();
+ return 1;
+ }
+ else {
+ paths.push(arg);
+ }
+ }
+ if (opt.preserveRoot !== false) {
+ for (const path of paths.map(p => (0, path_1.resolve)(p))) {
+ if (path === (0, path_1.parse)(path).root) {
+ console.error(`rimraf: it is dangerous to operate recursively on '/'`);
+ console.error('use --no-preserve-root to override this failsafe');
+ return 1;
+ }
+ }
+ }
+ if (!paths.length) {
+ console.error('rimraf: must provide a path to remove');
+ runHelpForUsage();
+ return 1;
+ }
+ if (impl === index_cjs_js_1.default.native && (interactive || opt.filter)) {
+ console.error('native implementation does not support -v or -i');
+ runHelpForUsage();
+ return 1;
+ }
+ if (interactive) {
+ await interactiveRimraf(impl, paths, opt);
+ }
+ else {
+ await impl(paths, opt);
+ }
+ return 0;
+};
+main.help = exports.help;
+exports.default = main;
+if (typeof require === 'function' &&
+ typeof module === 'object' &&
+ require.main === module) {
+ const args = process.argv.slice(2);
+ main(...args).then(code => process.exit(code), er => {
+ console.error(er);
+ process.exit(1);
+ });
+}
+//# sourceMappingURL=bin.js.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/bin.js.map b/node_modules/rimraf/dist/cjs/src/bin.js.map
new file mode 100644
index 0000000..cef95f1
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/bin.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../../src/bin.ts"],"names":[],"mappings":";;;;;;;AACA,kDAAyC;AACzC,kEAAmC;AAGnC,MAAM,eAAe,GAAG,GAAG,EAAE,CAC3B,OAAO,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAA;AAE/C,QAAA,IAAI,GAAG,kBAAkB,sBAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkC5C,CAAA;AAED,+BAA+C;AAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;AAEzB,uCAAqD;AAGrD,MAAM,MAAM,GAAG,KAAK,EAAE,EAAa,EAAE,CAAS,EAAE,EAAE,CAChD,IAAI,OAAO,CAAS,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;AAEjD,MAAM,iBAAiB,GAAG,KAAK,EAC7B,IAA6E,EAC7E,KAAe,EACf,GAAuB,EACvB,EAAE;IACF,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;IACjD,IAAI,YAAY,GAAG,KAAK,CAAA;IACxB,IAAI,aAAa,GAAG,KAAK,CAAA;IACzB,MAAM,KAAK,GAA+B,EAAE,CAAA;IAC5C,IAAI,UAAU,GAAG,KAAK,CAAA;IACtB,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;QAC9B,IAAI,UAAU;YAAE,OAAM;QACtB,UAAU,GAAG,IAAI,CAAA;QACjB,IAAI,IAA0C,CAAA;QAC9C,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE;YAC7B,MAAM,IAAI,EAAE,CAAA;SACb;QACD,UAAU,GAAG,KAAK,CAAA;IACpB,CAAC,CAAA;IACD,MAAM,UAAU,GACd,CAAC,EAAsD,EAAE,EAAE,CAC3D,KAAK,EAAE,CAAS,EAAE,CAAiB,EAAoB,EAAE;QACvD,MAAM,CAAC,GAAG,IAAI,OAAO,CAAU,GAAG,CAAC,EAAE;YACnC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;gBACpB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;gBAC7B,GAAG,CAAC,MAAM,CAAC,CAAA;gBACX,OAAO,MAAM,CAAA;YACf,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,YAAY,EAAE,CAAA;QACd,OAAO,CAAC,CAAA;IACV,CAAC,CAAA;IACH,MAAM,EAAE,GAAG,IAAA,0BAAe,EAAC;QACzB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAA;IACF,GAAG,CAAC,MAAM,GAAG,UAAU,CACrB,KAAK,EAAE,IAAY,EAAE,GAAmB,EAAoB,EAAE;QAC5D,IAAI,aAAa,EAAE;YACjB,OAAO,KAAK,CAAA;SACb;QACD,OAAO,CAAC,YAAY,EAAE;YACpB,MAAM,CAAC,GAAG,CACR,MAAM,MAAM,CAAC,EAAE,EAAE,OAAO,IAAA,eAAQ,EAAC,GAAG,EAAE,IAAI,CAAC,0BAA0B,CAAC,CACvE,CAAC,IAAI,EAAE,CAAA;YACR,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;gBACjB,OAAO,KAAK,CAAA;aACb;iBAAM,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;gBACxB,YAAY,GAAG,IAAI,CAAA;gBACnB,MAAK;aACN;iBAAM,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;gBACxB,aAAa,GAAG,IAAI,CAAA;gBACpB,OAAO,KAAK,CAAA;aACb;iBAAM,IAAI,CAAC,KAAK,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;gBACpC,MAAK;aACN;iBAAM;gBACL,SAAQ;aACT;SACF;QACD,OAAO,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAClC,CAAC,CACF,CAAA;IACD,MAAM,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACtB,EAAE,CAAC,KAAK,EAAE,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,IAAI,GAAG,KAAK,EAAE,GAAG,IAAc,EAAE,EAAE;IACvC,MAAM,aAAa,GAAG,CAAC,CAAS,EAAE,EAAE;QAClC,OAAO,CAAC,GAAG,CAAC,IAAA,eAAQ,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAA;QAC7B,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,GAAG,EAAE;QACnD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;KAC5C;IAED,MAAM,GAAG,GAAuB,EAAE,CAAA;IAClC,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAI,QAAQ,GAAG,KAAK,CAAA;IACpB,IAAI,IAAI,GAGgB,sBAAM,CAAA;IAE9B,IAAI,WAAW,GAAG,KAAK,CAAA;IAEvB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,IAAI,QAAQ,EAAE;YACZ,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACf,SAAQ;SACT;QACD,IAAI,GAAG,KAAK,IAAI,EAAE;YAChB,QAAQ,GAAG,IAAI,CAAA;YACf,SAAQ;SACT;aAAM,IAAI,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,KAAK,EAAE;YACzC,2DAA2D;YAC3D,SAAQ;SACT;aAAM,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,QAAQ,EAAE;YAC3C,OAAO,CAAC,GAAG,CAAC,YAAI,CAAC,CAAA;YACjB,OAAO,CAAC,CAAA;SACT;aAAM,IAAI,GAAG,KAAK,eAAe,IAAI,GAAG,KAAK,IAAI,EAAE;YAClD,WAAW,GAAG,IAAI,CAAA;YAClB,SAAQ;SACT;aAAM,IAAI,GAAG,KAAK,kBAAkB,IAAI,GAAG,KAAK,IAAI,EAAE;YACrD,WAAW,GAAG,KAAK,CAAA;YACnB,SAAQ;SACT;aAAM,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,IAAI,EAAE;YAC9C,GAAG,CAAC,MAAM,GAAG,aAAa,CAAA;YAC1B,SAAQ;SACT;aAAM,IAAI,GAAG,KAAK,cAAc,IAAI,GAAG,KAAK,IAAI,EAAE;YACjD,GAAG,CAAC,MAAM,GAAG,SAAS,CAAA;YACtB,SAAQ;SACT;aAAM,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,QAAQ,EAAE;YAC3C,GAAG,CAAC,IAAI,GAAG,IAAI,CAAA;YACf,SAAQ;SACT;aAAM,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,WAAW,EAAE;YAC9C,GAAG,CAAC,IAAI,GAAG,KAAK,CAAA;YAChB,SAAQ;SACT;aAAM,IAAI,GAAG,KAAK,iBAAiB,EAAE;YACpC,GAAG,CAAC,YAAY,GAAG,IAAI,CAAA;YACvB,SAAQ;SACT;aAAM,IAAI,GAAG,KAAK,oBAAoB,EAAE;YACvC,GAAG,CAAC,YAAY,GAAG,KAAK,CAAA;YACxB,SAAQ;SACT;aAAM,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAC9B,MAAM,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;YAC1C,GAAG,CAAC,GAAG,GAAG,GAAG,CAAA;YACb,SAAQ;SACT;aAAM,IAAI,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACtC,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;YACnD,GAAG,CAAC,UAAU,GAAG,GAAG,CAAA;YACpB,SAAQ;SACT;aAAM,IAAI,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACtC,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;YACnD,GAAG,CAAC,UAAU,GAAG,GAAG,CAAA;YACpB,SAAQ;SACT;aAAM,IAAI,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAClC,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;YAC/C,GAAG,CAAC,OAAO,GAAG,GAAG,CAAA;YACjB,SAAQ;SACT;aAAM,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;YAC3C,QAAQ,GAAG,EAAE;gBACX,KAAK,QAAQ;oBACX,IAAI,GAAG,sBAAM,CAAA;oBACb,SAAQ;gBACV,KAAK,QAAQ,CAAC;gBACd,KAAK,QAAQ,CAAC;gBACd,KAAK,OAAO,CAAC;gBACb,KAAK,SAAS;oBACZ,IAAI,GAAG,sBAAM,CAAC,GAAG,CAAC,CAAA;oBAClB,SAAQ;gBACV,KAAK,aAAa;oBAChB,IAAI,GAAG,sBAAM,CAAC,UAAU,CAAA;oBACxB,SAAQ;gBACV;oBACE,OAAO,CAAC,KAAK,CAAC,2BAA2B,GAAG,EAAE,CAAC,CAAA;oBAC/C,eAAe,EAAE,CAAA;oBACjB,OAAO,CAAC,CAAA;aACX;SACF;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACzB,OAAO,CAAC,KAAK,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAA;YACvC,eAAe,EAAE,CAAA;YACjB,OAAO,CAAC,CAAA;SACT;aAAM;YACL,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;SAChB;KACF;IAED,IAAI,GAAG,CAAC,YAAY,KAAK,KAAK,EAAE;QAC9B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,cAAO,EAAC,CAAC,CAAC,CAAC,EAAE;YAC7C,IAAI,IAAI,KAAK,IAAA,YAAK,EAAC,IAAI,CAAC,CAAC,IAAI,EAAE;gBAC7B,OAAO,CAAC,KAAK,CAAC,uDAAuD,CAAC,CAAA;gBACtE,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAA;gBACjE,OAAO,CAAC,CAAA;aACT;SACF;KACF;IAED,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QACjB,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAA;QACtD,eAAe,EAAE,CAAA;QACjB,OAAO,CAAC,CAAA;KACT;IAED,IAAI,IAAI,KAAK,sBAAM,CAAC,MAAM,IAAI,CAAC,WAAW,IAAI,GAAG,CAAC,MAAM,CAAC,EAAE;QACzD,OAAO,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAA;QAChE,eAAe,EAAE,CAAA;QACjB,OAAO,CAAC,CAAA;KACT;IAED,IAAI,WAAW,EAAE;QACf,MAAM,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;KAC1C;SAAM;QACL,MAAM,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;KACvB;IAED,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AACD,IAAI,CAAC,IAAI,GAAG,YAAI,CAAA;AAEhB,kBAAe,IAAI,CAAA;AAEnB,IACE,OAAO,OAAO,KAAK,UAAU;IAC7B,OAAO,MAAM,KAAK,QAAQ;IAC1B,OAAO,CAAC,IAAI,KAAK,MAAM,EACvB;IACA,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAClC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAChB,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAC1B,EAAE,CAAC,EAAE;QACH,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,CACF,CAAA;CACF","sourcesContent":["#!/usr/bin/env node\nimport { version } from '../package.json'\nimport rimraf from './index-cjs.js'\nimport type { RimrafAsyncOptions } from './index.js'\n\nconst runHelpForUsage = () =>\n console.error('run `rimraf --help` for usage information')\n\nexport const help = `rimraf version ${version}\n\nUsage: rimraf [ ...]\nDeletes all files and folders at \"path\", recursively.\n\nOptions:\n -- Treat all subsequent arguments as paths\n -h --help Display this usage info\n --preserve-root Do not remove '/' recursively (default)\n --no-preserve-root Do not treat '/' specially\n -G --no-glob Treat arguments as literal paths, not globs (default)\n -g --glob Treat arguments as glob patterns\n -v --verbose Be verbose when deleting files, showing them as\n they are removed. Not compatible with --impl=native\n -V --no-verbose Be silent when deleting files, showing nothing as\n they are removed (default)\n -i --interactive Ask for confirmation before deleting anything\n Not compatible with --impl=native\n -I --no-interactive Do not ask for confirmation before deleting\n\n --impl= Specify the implementation to use:\n rimraf: choose the best option (default)\n native: the built-in implementation in Node.js\n manual: the platform-specific JS implementation\n posix: the Posix JS implementation\n windows: the Windows JS implementation (falls back to\n move-remove on ENOTEMPTY)\n move-remove: a slow reliable Windows fallback\n\nImplementation-specific options:\n --tmp= Temp file folder for 'move-remove' implementation\n --max-retries= maxRetries for 'native' and 'windows' implementations\n --retry-delay= retryDelay for 'native' implementation, default 100\n --backoff= Exponential backoff factor for retries (default: 1.2)\n`\n\nimport { parse, relative, resolve } from 'path'\nconst cwd = process.cwd()\n\nimport { createInterface, Interface } from 'readline'\nimport { Dirent, Stats } from 'fs'\n\nconst prompt = async (rl: Interface, q: string) =>\n new Promise(res => rl.question(q, res))\n\nconst interactiveRimraf = async (\n impl: (path: string | string[], opt?: RimrafAsyncOptions) => Promise,\n paths: string[],\n opt: RimrafAsyncOptions\n) => {\n const existingFilter = opt.filter || (() => true)\n let allRemaining = false\n let noneRemaining = false\n const queue: (() => Promise)[] = []\n let processing = false\n const processQueue = async () => {\n if (processing) return\n processing = true\n let next: (() => Promise) | undefined\n while ((next = queue.shift())) {\n await next()\n }\n processing = false\n }\n const oneAtATime =\n (fn: (s: string, e: Dirent | Stats) => Promise) =>\n async (s: string, e: Dirent | Stats): Promise => {\n const p = new Promise(res => {\n queue.push(async () => {\n const result = await fn(s, e)\n res(result)\n return result\n })\n })\n processQueue()\n return p\n }\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n })\n opt.filter = oneAtATime(\n async (path: string, ent: Dirent | Stats): Promise => {\n if (noneRemaining) {\n return false\n }\n while (!allRemaining) {\n const a = (\n await prompt(rl, `rm? ${relative(cwd, path)}\\n[(Yes)/No/All/Quit] > `)\n ).trim()\n if (/^n/i.test(a)) {\n return false\n } else if (/^a/i.test(a)) {\n allRemaining = true\n break\n } else if (/^q/i.test(a)) {\n noneRemaining = true\n return false\n } else if (a === '' || /^y/i.test(a)) {\n break\n } else {\n continue\n }\n }\n return existingFilter(path, ent)\n }\n )\n await impl(paths, opt)\n rl.close()\n}\n\nconst main = async (...args: string[]) => {\n const verboseFilter = (s: string) => {\n console.log(relative(cwd, s))\n return true\n }\n\n if (process.env.__RIMRAF_TESTING_BIN_FAIL__ === '1') {\n throw new Error('simulated rimraf failure')\n }\n\n const opt: RimrafAsyncOptions = {}\n const paths: string[] = []\n let dashdash = false\n let impl: (\n path: string | string[],\n opt?: RimrafAsyncOptions\n ) => Promise = rimraf\n\n let interactive = false\n\n for (const arg of args) {\n if (dashdash) {\n paths.push(arg)\n continue\n }\n if (arg === '--') {\n dashdash = true\n continue\n } else if (arg === '-rf' || arg === '-fr') {\n // this never did anything, but people put it there I guess\n continue\n } else if (arg === '-h' || arg === '--help') {\n console.log(help)\n return 0\n } else if (arg === '--interactive' || arg === '-i') {\n interactive = true\n continue\n } else if (arg === '--no-interactive' || arg === '-I') {\n interactive = false\n continue\n } else if (arg === '--verbose' || arg === '-v') {\n opt.filter = verboseFilter\n continue\n } else if (arg === '--no-verbose' || arg === '-V') {\n opt.filter = undefined\n continue\n } else if (arg === '-g' || arg === '--glob') {\n opt.glob = true\n continue\n } else if (arg === '-G' || arg === '--no-glob') {\n opt.glob = false\n continue\n } else if (arg === '--preserve-root') {\n opt.preserveRoot = true\n continue\n } else if (arg === '--no-preserve-root') {\n opt.preserveRoot = false\n continue\n } else if (/^--tmp=/.test(arg)) {\n const val = arg.substring('--tmp='.length)\n opt.tmp = val\n continue\n } else if (/^--max-retries=/.test(arg)) {\n const val = +arg.substring('--max-retries='.length)\n opt.maxRetries = val\n continue\n } else if (/^--retry-delay=/.test(arg)) {\n const val = +arg.substring('--retry-delay='.length)\n opt.retryDelay = val\n continue\n } else if (/^--backoff=/.test(arg)) {\n const val = +arg.substring('--backoff='.length)\n opt.backoff = val\n continue\n } else if (/^--impl=/.test(arg)) {\n const val = arg.substring('--impl='.length)\n switch (val) {\n case 'rimraf':\n impl = rimraf\n continue\n case 'native':\n case 'manual':\n case 'posix':\n case 'windows':\n impl = rimraf[val]\n continue\n case 'move-remove':\n impl = rimraf.moveRemove\n continue\n default:\n console.error(`unknown implementation: ${val}`)\n runHelpForUsage()\n return 1\n }\n } else if (/^-/.test(arg)) {\n console.error(`unknown option: ${arg}`)\n runHelpForUsage()\n return 1\n } else {\n paths.push(arg)\n }\n }\n\n if (opt.preserveRoot !== false) {\n for (const path of paths.map(p => resolve(p))) {\n if (path === parse(path).root) {\n console.error(`rimraf: it is dangerous to operate recursively on '/'`)\n console.error('use --no-preserve-root to override this failsafe')\n return 1\n }\n }\n }\n\n if (!paths.length) {\n console.error('rimraf: must provide a path to remove')\n runHelpForUsage()\n return 1\n }\n\n if (impl === rimraf.native && (interactive || opt.filter)) {\n console.error('native implementation does not support -v or -i')\n runHelpForUsage()\n return 1\n }\n\n if (interactive) {\n await interactiveRimraf(impl, paths, opt)\n } else {\n await impl(paths, opt)\n }\n\n return 0\n}\nmain.help = help\n\nexport default main\n\nif (\n typeof require === 'function' &&\n typeof module === 'object' &&\n require.main === module\n) {\n const args = process.argv.slice(2)\n main(...args).then(\n code => process.exit(code),\n er => {\n console.error(er)\n process.exit(1)\n }\n )\n}\n"]}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/default-tmp.d.ts b/node_modules/rimraf/dist/cjs/src/default-tmp.d.ts
new file mode 100644
index 0000000..a68e925
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/default-tmp.d.ts
@@ -0,0 +1,3 @@
+export declare const defaultTmp: (path: string) => Promise;
+export declare const defaultTmpSync: (path: string) => string;
+//# sourceMappingURL=default-tmp.d.ts.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/default-tmp.d.ts.map b/node_modules/rimraf/dist/cjs/src/default-tmp.d.ts.map
new file mode 100644
index 0000000..91a1672
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/default-tmp.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"default-tmp.d.ts","sourceRoot":"","sources":["../../../src/default-tmp.ts"],"names":[],"mappings":"AAiEA,eAAO,MAAM,UAAU,SAnCc,MAAM,oBAoCe,CAAA;AAC1D,eAAO,MAAM,cAAc,SArBQ,MAAM,WAsByB,CAAA"}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/default-tmp.js b/node_modules/rimraf/dist/cjs/src/default-tmp.js
new file mode 100644
index 0000000..ae90878
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/default-tmp.js
@@ -0,0 +1,61 @@
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.defaultTmpSync = exports.defaultTmp = void 0;
+// The default temporary folder location for use in the windows algorithm.
+// It's TEMPting to use dirname(path), since that's guaranteed to be on the
+// same device. However, this means that:
+// rimraf(path).then(() => rimraf(dirname(path)))
+// will often fail with EBUSY, because the parent dir contains
+// marked-for-deletion directory entries (which do not show up in readdir).
+// The approach here is to use os.tmpdir() if it's on the same drive letter,
+// or resolve(path, '\\temp') if it exists, or the root of the drive if not.
+// On Posix (not that you'd be likely to use the windows algorithm there),
+// it uses os.tmpdir() always.
+const os_1 = require("os");
+const path_1 = require("path");
+const fs_js_1 = require("./fs.js");
+const platform_js_1 = __importDefault(require("./platform.js"));
+const { stat } = fs_js_1.promises;
+const isDirSync = (path) => {
+ try {
+ return (0, fs_js_1.statSync)(path).isDirectory();
+ }
+ catch (er) {
+ return false;
+ }
+};
+const isDir = (path) => stat(path).then(st => st.isDirectory(), () => false);
+const win32DefaultTmp = async (path) => {
+ const { root } = (0, path_1.parse)(path);
+ const tmp = (0, os_1.tmpdir)();
+ const { root: tmpRoot } = (0, path_1.parse)(tmp);
+ if (root.toLowerCase() === tmpRoot.toLowerCase()) {
+ return tmp;
+ }
+ const driveTmp = (0, path_1.resolve)(root, '/temp');
+ if (await isDir(driveTmp)) {
+ return driveTmp;
+ }
+ return root;
+};
+const win32DefaultTmpSync = (path) => {
+ const { root } = (0, path_1.parse)(path);
+ const tmp = (0, os_1.tmpdir)();
+ const { root: tmpRoot } = (0, path_1.parse)(tmp);
+ if (root.toLowerCase() === tmpRoot.toLowerCase()) {
+ return tmp;
+ }
+ const driveTmp = (0, path_1.resolve)(root, '/temp');
+ if (isDirSync(driveTmp)) {
+ return driveTmp;
+ }
+ return root;
+};
+const posixDefaultTmp = async () => (0, os_1.tmpdir)();
+const posixDefaultTmpSync = () => (0, os_1.tmpdir)();
+exports.defaultTmp = platform_js_1.default === 'win32' ? win32DefaultTmp : posixDefaultTmp;
+exports.defaultTmpSync = platform_js_1.default === 'win32' ? win32DefaultTmpSync : posixDefaultTmpSync;
+//# sourceMappingURL=default-tmp.js.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/default-tmp.js.map b/node_modules/rimraf/dist/cjs/src/default-tmp.js.map
new file mode 100644
index 0000000..e16a510
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/default-tmp.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"default-tmp.js","sourceRoot":"","sources":["../../../src/default-tmp.ts"],"names":[],"mappings":";;;;;;AAAA,0EAA0E;AAC1E,2EAA2E;AAC3E,0CAA0C;AAC1C,iDAAiD;AACjD,8DAA8D;AAC9D,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,0EAA0E;AAC1E,8BAA8B;AAC9B,2BAA2B;AAC3B,+BAAqC;AACrC,mCAA4C;AAC5C,gEAAoC;AACpC,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAQ,CAAA;AAEzB,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE;IACjC,IAAI;QACF,OAAO,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;KACpC;IAAC,OAAO,EAAE,EAAE;QACX,OAAO,KAAK,CAAA;KACb;AACH,CAAC,CAAA;AAED,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAC7B,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CACb,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,EACtB,GAAG,EAAE,CAAC,KAAK,CACZ,CAAA;AAEH,MAAM,eAAe,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC7C,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,YAAK,EAAC,IAAI,CAAC,CAAA;IAC5B,MAAM,GAAG,GAAG,IAAA,WAAM,GAAE,CAAA;IACpB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAA,YAAK,EAAC,GAAG,CAAC,CAAA;IACpC,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,WAAW,EAAE,EAAE;QAChD,OAAO,GAAG,CAAA;KACX;IAED,MAAM,QAAQ,GAAG,IAAA,cAAO,EAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACvC,IAAI,MAAM,KAAK,CAAC,QAAQ,CAAC,EAAE;QACzB,OAAO,QAAQ,CAAA;KAChB;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,EAAE;IAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,YAAK,EAAC,IAAI,CAAC,CAAA;IAC5B,MAAM,GAAG,GAAG,IAAA,WAAM,GAAE,CAAA;IACpB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAA,YAAK,EAAC,GAAG,CAAC,CAAA;IACpC,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,WAAW,EAAE,EAAE;QAChD,OAAO,GAAG,CAAA;KACX;IAED,MAAM,QAAQ,GAAG,IAAA,cAAO,EAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACvC,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE;QACvB,OAAO,QAAQ,CAAA;KAChB;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE,CAAC,IAAA,WAAM,GAAE,CAAA;AAC5C,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,IAAA,WAAM,GAAE,CAAA;AAE7B,QAAA,UAAU,GACrB,qBAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAA;AAC7C,QAAA,cAAc,GACzB,qBAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAA","sourcesContent":["// The default temporary folder location for use in the windows algorithm.\n// It's TEMPting to use dirname(path), since that's guaranteed to be on the\n// same device. However, this means that:\n// rimraf(path).then(() => rimraf(dirname(path)))\n// will often fail with EBUSY, because the parent dir contains\n// marked-for-deletion directory entries (which do not show up in readdir).\n// The approach here is to use os.tmpdir() if it's on the same drive letter,\n// or resolve(path, '\\\\temp') if it exists, or the root of the drive if not.\n// On Posix (not that you'd be likely to use the windows algorithm there),\n// it uses os.tmpdir() always.\nimport { tmpdir } from 'os'\nimport { parse, resolve } from 'path'\nimport { promises, statSync } from './fs.js'\nimport platform from './platform.js'\nconst { stat } = promises\n\nconst isDirSync = (path: string) => {\n try {\n return statSync(path).isDirectory()\n } catch (er) {\n return false\n }\n}\n\nconst isDir = (path: string) =>\n stat(path).then(\n st => st.isDirectory(),\n () => false\n )\n\nconst win32DefaultTmp = async (path: string) => {\n const { root } = parse(path)\n const tmp = tmpdir()\n const { root: tmpRoot } = parse(tmp)\n if (root.toLowerCase() === tmpRoot.toLowerCase()) {\n return tmp\n }\n\n const driveTmp = resolve(root, '/temp')\n if (await isDir(driveTmp)) {\n return driveTmp\n }\n\n return root\n}\n\nconst win32DefaultTmpSync = (path: string) => {\n const { root } = parse(path)\n const tmp = tmpdir()\n const { root: tmpRoot } = parse(tmp)\n if (root.toLowerCase() === tmpRoot.toLowerCase()) {\n return tmp\n }\n\n const driveTmp = resolve(root, '/temp')\n if (isDirSync(driveTmp)) {\n return driveTmp\n }\n\n return root\n}\n\nconst posixDefaultTmp = async () => tmpdir()\nconst posixDefaultTmpSync = () => tmpdir()\n\nexport const defaultTmp =\n platform === 'win32' ? win32DefaultTmp : posixDefaultTmp\nexport const defaultTmpSync =\n platform === 'win32' ? win32DefaultTmpSync : posixDefaultTmpSync\n"]}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/fix-eperm.d.ts b/node_modules/rimraf/dist/cjs/src/fix-eperm.d.ts
new file mode 100644
index 0000000..20e76a8
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/fix-eperm.d.ts
@@ -0,0 +1,3 @@
+export declare const fixEPERM: (fn: (path: string) => Promise) => (path: string) => Promise;
+export declare const fixEPERMSync: (fn: (path: string) => any) => (path: string) => any;
+//# sourceMappingURL=fix-eperm.d.ts.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/fix-eperm.d.ts.map b/node_modules/rimraf/dist/cjs/src/fix-eperm.d.ts.map
new file mode 100644
index 0000000..5b26530
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/fix-eperm.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"fix-eperm.d.ts","sourceRoot":"","sources":["../../../src/fix-eperm.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,cACP,MAAM,KAAK,QAAQ,GAAG,CAAC,YAAkB,MAAM,iBAsB1D,CAAA;AAEH,eAAO,MAAM,YAAY,cAAe,MAAM,KAAK,GAAG,YAAY,MAAM,QAsBvE,CAAA"}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/fix-eperm.js b/node_modules/rimraf/dist/cjs/src/fix-eperm.js
new file mode 100644
index 0000000..7baecb7
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/fix-eperm.js
@@ -0,0 +1,58 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.fixEPERMSync = exports.fixEPERM = void 0;
+const fs_js_1 = require("./fs.js");
+const { chmod } = fs_js_1.promises;
+const fixEPERM = (fn) => async (path) => {
+ try {
+ return await fn(path);
+ }
+ catch (er) {
+ const fer = er;
+ if (fer?.code === 'ENOENT') {
+ return;
+ }
+ if (fer?.code === 'EPERM') {
+ try {
+ await chmod(path, 0o666);
+ }
+ catch (er2) {
+ const fer2 = er2;
+ if (fer2?.code === 'ENOENT') {
+ return;
+ }
+ throw er;
+ }
+ return await fn(path);
+ }
+ throw er;
+ }
+};
+exports.fixEPERM = fixEPERM;
+const fixEPERMSync = (fn) => (path) => {
+ try {
+ return fn(path);
+ }
+ catch (er) {
+ const fer = er;
+ if (fer?.code === 'ENOENT') {
+ return;
+ }
+ if (fer?.code === 'EPERM') {
+ try {
+ (0, fs_js_1.chmodSync)(path, 0o666);
+ }
+ catch (er2) {
+ const fer2 = er2;
+ if (fer2?.code === 'ENOENT') {
+ return;
+ }
+ throw er;
+ }
+ return fn(path);
+ }
+ throw er;
+ }
+};
+exports.fixEPERMSync = fixEPERMSync;
+//# sourceMappingURL=fix-eperm.js.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/fix-eperm.js.map b/node_modules/rimraf/dist/cjs/src/fix-eperm.js.map
new file mode 100644
index 0000000..c5eb902
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/fix-eperm.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"fix-eperm.js","sourceRoot":"","sources":["../../../src/fix-eperm.ts"],"names":[],"mappings":";;;AAAA,mCAA6C;AAC7C,MAAM,EAAE,KAAK,EAAE,GAAG,gBAAQ,CAAA;AAEnB,MAAM,QAAQ,GACnB,CAAC,EAAkC,EAAE,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;IAC7D,IAAI;QACF,OAAO,MAAM,EAAE,CAAC,IAAI,CAAC,CAAA;KACtB;IAAC,OAAO,EAAE,EAAE;QACX,MAAM,GAAG,GAAG,EAA2B,CAAA;QACvC,IAAI,GAAG,EAAE,IAAI,KAAK,QAAQ,EAAE;YAC1B,OAAM;SACP;QACD,IAAI,GAAG,EAAE,IAAI,KAAK,OAAO,EAAE;YACzB,IAAI;gBACF,MAAM,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;aACzB;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,IAAI,GAAG,GAA4B,CAAA;gBACzC,IAAI,IAAI,EAAE,IAAI,KAAK,QAAQ,EAAE;oBAC3B,OAAM;iBACP;gBACD,MAAM,EAAE,CAAA;aACT;YACD,OAAO,MAAM,EAAE,CAAC,IAAI,CAAC,CAAA;SACtB;QACD,MAAM,EAAE,CAAA;KACT;AACH,CAAC,CAAA;AAvBU,QAAA,QAAQ,YAuBlB;AAEI,MAAM,YAAY,GAAG,CAAC,EAAyB,EAAE,EAAE,CAAC,CAAC,IAAY,EAAE,EAAE;IAC1E,IAAI;QACF,OAAO,EAAE,CAAC,IAAI,CAAC,CAAA;KAChB;IAAC,OAAO,EAAE,EAAE;QACX,MAAM,GAAG,GAAG,EAA2B,CAAA;QACvC,IAAI,GAAG,EAAE,IAAI,KAAK,QAAQ,EAAE;YAC1B,OAAM;SACP;QACD,IAAI,GAAG,EAAE,IAAI,KAAK,OAAO,EAAE;YACzB,IAAI;gBACF,IAAA,iBAAS,EAAC,IAAI,EAAE,KAAK,CAAC,CAAA;aACvB;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,IAAI,GAAG,GAA4B,CAAA;gBACzC,IAAI,IAAI,EAAE,IAAI,KAAK,QAAQ,EAAE;oBAC3B,OAAM;iBACP;gBACD,MAAM,EAAE,CAAA;aACT;YACD,OAAO,EAAE,CAAC,IAAI,CAAC,CAAA;SAChB;QACD,MAAM,EAAE,CAAA;KACT;AACH,CAAC,CAAA;AAtBY,QAAA,YAAY,gBAsBxB","sourcesContent":["import { chmodSync, promises } from './fs.js'\nconst { chmod } = promises\n\nexport const fixEPERM =\n (fn: (path: string) => Promise) => async (path: string) => {\n try {\n return await fn(path)\n } catch (er) {\n const fer = er as NodeJS.ErrnoException\n if (fer?.code === 'ENOENT') {\n return\n }\n if (fer?.code === 'EPERM') {\n try {\n await chmod(path, 0o666)\n } catch (er2) {\n const fer2 = er2 as NodeJS.ErrnoException\n if (fer2?.code === 'ENOENT') {\n return\n }\n throw er\n }\n return await fn(path)\n }\n throw er\n }\n }\n\nexport const fixEPERMSync = (fn: (path: string) => any) => (path: string) => {\n try {\n return fn(path)\n } catch (er) {\n const fer = er as NodeJS.ErrnoException\n if (fer?.code === 'ENOENT') {\n return\n }\n if (fer?.code === 'EPERM') {\n try {\n chmodSync(path, 0o666)\n } catch (er2) {\n const fer2 = er2 as NodeJS.ErrnoException\n if (fer2?.code === 'ENOENT') {\n return\n }\n throw er\n }\n return fn(path)\n }\n throw er\n }\n}\n"]}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/fs.d.ts b/node_modules/rimraf/dist/cjs/src/fs.d.ts
new file mode 100644
index 0000000..9e4e95b
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/fs.d.ts
@@ -0,0 +1,17 @@
+import fs, { Dirent } from 'fs';
+export { chmodSync, mkdirSync, renameSync, rmdirSync, rmSync, statSync, lstatSync, unlinkSync, } from 'fs';
+export declare const readdirSync: (path: fs.PathLike) => Dirent[];
+export declare const promises: {
+ chmod: (path: fs.PathLike, mode: fs.Mode) => Promise;
+ mkdir: (path: fs.PathLike, options?: fs.Mode | (fs.MakeDirectoryOptions & {
+ recursive?: boolean | null;
+ }) | undefined | null) => Promise;
+ readdir: (path: fs.PathLike) => Promise;
+ rename: (oldPath: fs.PathLike, newPath: fs.PathLike) => Promise;
+ rm: (path: fs.PathLike, options: fs.RmOptions) => Promise;
+ rmdir: (path: fs.PathLike) => Promise;
+ stat: (path: fs.PathLike) => Promise;
+ lstat: (path: fs.PathLike) => Promise;
+ unlink: (path: fs.PathLike) => Promise;
+};
+//# sourceMappingURL=fs.d.ts.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/fs.d.ts.map b/node_modules/rimraf/dist/cjs/src/fs.d.ts.map
new file mode 100644
index 0000000..cfa05e2
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/fs.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/fs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,IAAI,CAAA;AAG/B,OAAO,EACL,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,GACX,MAAM,IAAI,CAAA;AAGX,eAAO,MAAM,WAAW,SAAU,GAAG,QAAQ,KAAG,MAAM,EACf,CAAA;AA6DvC,eAAO,MAAM,QAAQ;kBAtDA,GAAG,QAAQ,QAAQ,GAAG,IAAI,KAAG,QAAQ,IAAI,CAAC;kBAMvD,GAAG,QAAQ,YAEb,GAAG,IAAI,GACP,CAAC,GAAG,oBAAoB,GAAG;QAAE,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;KAAE,CAAC,GAC1D,SAAS,GACT,IAAI,KACP,QAAQ,MAAM,GAAG,SAAS,CAAC;oBAKP,GAAG,QAAQ,KAAG,QAAQ,MAAM,EAAE,CAAC;sBAO7B,GAAG,QAAQ,WAAW,GAAG,QAAQ,KAAG,QAAQ,IAAI,CAAC;eAKxD,GAAG,QAAQ,WAAW,GAAG,SAAS,KAAG,QAAQ,IAAI,CAAC;kBAK/C,GAAG,QAAQ,KAAG,QAAQ,IAAI,CAAC;iBAK5B,GAAG,QAAQ,KAAG,QAAQ,GAAG,KAAK,CAAC;kBAK9B,GAAG,QAAQ,KAAG,QAAQ,GAAG,KAAK,CAAC;mBAK9B,GAAG,QAAQ,KAAG,QAAQ,IAAI,CAAC;CAehD,CAAA"}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/fs.js b/node_modules/rimraf/dist/cjs/src/fs.js
new file mode 100644
index 0000000..df79f9b
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/fs.js
@@ -0,0 +1,46 @@
+"use strict";
+// promisify ourselves, because older nodes don't have fs.promises
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.promises = exports.readdirSync = exports.unlinkSync = exports.lstatSync = exports.statSync = exports.rmSync = exports.rmdirSync = exports.renameSync = exports.mkdirSync = exports.chmodSync = void 0;
+const fs_1 = __importDefault(require("fs"));
+// sync ones just take the sync version from node
+var fs_2 = require("fs");
+Object.defineProperty(exports, "chmodSync", { enumerable: true, get: function () { return fs_2.chmodSync; } });
+Object.defineProperty(exports, "mkdirSync", { enumerable: true, get: function () { return fs_2.mkdirSync; } });
+Object.defineProperty(exports, "renameSync", { enumerable: true, get: function () { return fs_2.renameSync; } });
+Object.defineProperty(exports, "rmdirSync", { enumerable: true, get: function () { return fs_2.rmdirSync; } });
+Object.defineProperty(exports, "rmSync", { enumerable: true, get: function () { return fs_2.rmSync; } });
+Object.defineProperty(exports, "statSync", { enumerable: true, get: function () { return fs_2.statSync; } });
+Object.defineProperty(exports, "lstatSync", { enumerable: true, get: function () { return fs_2.lstatSync; } });
+Object.defineProperty(exports, "unlinkSync", { enumerable: true, get: function () { return fs_2.unlinkSync; } });
+const fs_3 = require("fs");
+const readdirSync = (path) => (0, fs_3.readdirSync)(path, { withFileTypes: true });
+exports.readdirSync = readdirSync;
+// unrolled for better inlining, this seems to get better performance
+// than something like:
+// const makeCb = (res, rej) => (er, ...d) => er ? rej(er) : res(...d)
+// which would be a bit cleaner.
+const chmod = (path, mode) => new Promise((res, rej) => fs_1.default.chmod(path, mode, (er, ...d) => (er ? rej(er) : res(...d))));
+const mkdir = (path, options) => new Promise((res, rej) => fs_1.default.mkdir(path, options, (er, made) => (er ? rej(er) : res(made))));
+const readdir = (path) => new Promise((res, rej) => fs_1.default.readdir(path, { withFileTypes: true }, (er, data) => er ? rej(er) : res(data)));
+const rename = (oldPath, newPath) => new Promise((res, rej) => fs_1.default.rename(oldPath, newPath, (er, ...d) => (er ? rej(er) : res(...d))));
+const rm = (path, options) => new Promise((res, rej) => fs_1.default.rm(path, options, (er, ...d) => (er ? rej(er) : res(...d))));
+const rmdir = (path) => new Promise((res, rej) => fs_1.default.rmdir(path, (er, ...d) => (er ? rej(er) : res(...d))));
+const stat = (path) => new Promise((res, rej) => fs_1.default.stat(path, (er, data) => (er ? rej(er) : res(data))));
+const lstat = (path) => new Promise((res, rej) => fs_1.default.lstat(path, (er, data) => (er ? rej(er) : res(data))));
+const unlink = (path) => new Promise((res, rej) => fs_1.default.unlink(path, (er, ...d) => (er ? rej(er) : res(...d))));
+exports.promises = {
+ chmod,
+ mkdir,
+ readdir,
+ rename,
+ rm,
+ rmdir,
+ stat,
+ lstat,
+ unlink,
+};
+//# sourceMappingURL=fs.js.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/fs.js.map b/node_modules/rimraf/dist/cjs/src/fs.js.map
new file mode 100644
index 0000000..96dacf6
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/fs.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/fs.ts"],"names":[],"mappings":";AAAA,kEAAkE;;;;;;AAElE,4CAA+B;AAE/B,iDAAiD;AACjD,yBASW;AART,+FAAA,SAAS,OAAA;AACT,+FAAA,SAAS,OAAA;AACT,gGAAA,UAAU,OAAA;AACV,+FAAA,SAAS,OAAA;AACT,4FAAA,MAAM,OAAA;AACN,8FAAA,QAAQ,OAAA;AACR,+FAAA,SAAS,OAAA;AACT,gGAAA,UAAU,OAAA;AAGZ,2BAA0C;AACnC,MAAM,WAAW,GAAG,CAAC,IAAiB,EAAY,EAAE,CACzD,IAAA,gBAAM,EAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;AAD1B,QAAA,WAAW,eACe;AAEvC,qEAAqE;AACrE,uBAAuB;AACvB,sEAAsE;AACtE,gCAAgC;AAEhC,MAAM,KAAK,GAAG,CAAC,IAAiB,EAAE,IAAa,EAAiB,EAAE,CAChE,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CACvB,YAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,GAAG,CAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACtE,CAAA;AAEH,MAAM,KAAK,GAAG,CACZ,IAAiB,EACjB,OAIQ,EACqB,EAAE,CAC/B,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CACvB,YAAE,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAClE,CAAA;AAEH,MAAM,OAAO,GAAG,CAAC,IAAiB,EAAqB,EAAE,CACvD,IAAI,OAAO,CAAW,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CACjC,YAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CACrD,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CACzB,CACF,CAAA;AAEH,MAAM,MAAM,GAAG,CAAC,OAAoB,EAAE,OAAoB,EAAiB,EAAE,CAC3E,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CACvB,YAAE,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,GAAG,CAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAC7E,CAAA;AAEH,MAAM,EAAE,GAAG,CAAC,IAAiB,EAAE,OAAqB,EAAiB,EAAE,CACrE,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CACvB,YAAE,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,GAAG,CAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACtE,CAAA;AAEH,MAAM,KAAK,GAAG,CAAC,IAAiB,EAAiB,EAAE,CACjD,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CACvB,YAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,GAAG,CAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAChE,CAAA;AAEH,MAAM,IAAI,GAAG,CAAC,IAAiB,EAAqB,EAAE,CACpD,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CACvB,YAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CACxD,CAAA;AAEH,MAAM,KAAK,GAAG,CAAC,IAAiB,EAAqB,EAAE,CACrD,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CACvB,YAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CACzD,CAAA;AAEH,MAAM,MAAM,GAAG,CAAC,IAAiB,EAAiB,EAAE,CAClD,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CACvB,YAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,GAAG,CAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACjE,CAAA;AAEU,QAAA,QAAQ,GAAG;IACtB,KAAK;IACL,KAAK;IACL,OAAO;IACP,MAAM;IACN,EAAE;IACF,KAAK;IACL,IAAI;IACJ,KAAK;IACL,MAAM;CACP,CAAA","sourcesContent":["// promisify ourselves, because older nodes don't have fs.promises\n\nimport fs, { Dirent } from 'fs'\n\n// sync ones just take the sync version from node\nexport {\n chmodSync,\n mkdirSync,\n renameSync,\n rmdirSync,\n rmSync,\n statSync,\n lstatSync,\n unlinkSync,\n} from 'fs'\n\nimport { readdirSync as rdSync } from 'fs'\nexport const readdirSync = (path: fs.PathLike): Dirent[] =>\n rdSync(path, { withFileTypes: true })\n\n// unrolled for better inlining, this seems to get better performance\n// than something like:\n// const makeCb = (res, rej) => (er, ...d) => er ? rej(er) : res(...d)\n// which would be a bit cleaner.\n\nconst chmod = (path: fs.PathLike, mode: fs.Mode): Promise =>\n new Promise((res, rej) =>\n fs.chmod(path, mode, (er, ...d: any[]) => (er ? rej(er) : res(...d)))\n )\n\nconst mkdir = (\n path: fs.PathLike,\n options?:\n | fs.Mode\n | (fs.MakeDirectoryOptions & { recursive?: boolean | null })\n | undefined\n | null\n): Promise =>\n new Promise((res, rej) =>\n fs.mkdir(path, options, (er, made) => (er ? rej(er) : res(made)))\n )\n\nconst readdir = (path: fs.PathLike): Promise =>\n new Promise((res, rej) =>\n fs.readdir(path, { withFileTypes: true }, (er, data) =>\n er ? rej(er) : res(data)\n )\n )\n\nconst rename = (oldPath: fs.PathLike, newPath: fs.PathLike): Promise =>\n new Promise((res, rej) =>\n fs.rename(oldPath, newPath, (er, ...d: any[]) => (er ? rej(er) : res(...d)))\n )\n\nconst rm = (path: fs.PathLike, options: fs.RmOptions): Promise =>\n new Promise((res, rej) =>\n fs.rm(path, options, (er, ...d: any[]) => (er ? rej(er) : res(...d)))\n )\n\nconst rmdir = (path: fs.PathLike): Promise =>\n new Promise((res, rej) =>\n fs.rmdir(path, (er, ...d: any[]) => (er ? rej(er) : res(...d)))\n )\n\nconst stat = (path: fs.PathLike): Promise =>\n new Promise((res, rej) =>\n fs.stat(path, (er, data) => (er ? rej(er) : res(data)))\n )\n\nconst lstat = (path: fs.PathLike): Promise =>\n new Promise((res, rej) =>\n fs.lstat(path, (er, data) => (er ? rej(er) : res(data)))\n )\n\nconst unlink = (path: fs.PathLike): Promise =>\n new Promise((res, rej) =>\n fs.unlink(path, (er, ...d: any[]) => (er ? rej(er) : res(...d)))\n )\n\nexport const promises = {\n chmod,\n mkdir,\n readdir,\n rename,\n rm,\n rmdir,\n stat,\n lstat,\n unlink,\n}\n"]}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/ignore-enoent.d.ts b/node_modules/rimraf/dist/cjs/src/ignore-enoent.d.ts
new file mode 100644
index 0000000..f158cc2
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/ignore-enoent.d.ts
@@ -0,0 +1,3 @@
+export declare const ignoreENOENT: (p: Promise) => Promise;
+export declare const ignoreENOENTSync: (fn: () => any) => any;
+//# sourceMappingURL=ignore-enoent.d.ts.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/ignore-enoent.d.ts.map b/node_modules/rimraf/dist/cjs/src/ignore-enoent.d.ts.map
new file mode 100644
index 0000000..f184512
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/ignore-enoent.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"ignore-enoent.d.ts","sourceRoot":"","sources":["../../../src/ignore-enoent.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,MAAa,QAAQ,GAAG,CAAC,iBAK9C,CAAA;AAEJ,eAAO,MAAM,gBAAgB,OAAQ,MAAM,GAAG,QAQ7C,CAAA"}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/ignore-enoent.js b/node_modules/rimraf/dist/cjs/src/ignore-enoent.js
new file mode 100644
index 0000000..0259534
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/ignore-enoent.js
@@ -0,0 +1,21 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.ignoreENOENTSync = exports.ignoreENOENT = void 0;
+const ignoreENOENT = async (p) => p.catch(er => {
+ if (er.code !== 'ENOENT') {
+ throw er;
+ }
+});
+exports.ignoreENOENT = ignoreENOENT;
+const ignoreENOENTSync = (fn) => {
+ try {
+ return fn();
+ }
+ catch (er) {
+ if (er?.code !== 'ENOENT') {
+ throw er;
+ }
+ }
+};
+exports.ignoreENOENTSync = ignoreENOENTSync;
+//# sourceMappingURL=ignore-enoent.js.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/ignore-enoent.js.map b/node_modules/rimraf/dist/cjs/src/ignore-enoent.js.map
new file mode 100644
index 0000000..1850326
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/ignore-enoent.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"ignore-enoent.js","sourceRoot":"","sources":["../../../src/ignore-enoent.ts"],"names":[],"mappings":";;;AAAO,MAAM,YAAY,GAAG,KAAK,EAAE,CAAe,EAAE,EAAE,CACpD,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;IACX,IAAI,EAAE,CAAC,IAAI,KAAK,QAAQ,EAAE;QACxB,MAAM,EAAE,CAAA;KACT;AACH,CAAC,CAAC,CAAA;AALS,QAAA,YAAY,gBAKrB;AAEG,MAAM,gBAAgB,GAAG,CAAC,EAAa,EAAE,EAAE;IAChD,IAAI;QACF,OAAO,EAAE,EAAE,CAAA;KACZ;IAAC,OAAO,EAAE,EAAE;QACX,IAAK,EAA4B,EAAE,IAAI,KAAK,QAAQ,EAAE;YACpD,MAAM,EAAE,CAAA;SACT;KACF;AACH,CAAC,CAAA;AARY,QAAA,gBAAgB,oBAQ5B","sourcesContent":["export const ignoreENOENT = async (p: Promise) =>\n p.catch(er => {\n if (er.code !== 'ENOENT') {\n throw er\n }\n })\n\nexport const ignoreENOENTSync = (fn: () => any) => {\n try {\n return fn()\n } catch (er) {\n if ((er as NodeJS.ErrnoException)?.code !== 'ENOENT') {\n throw er\n }\n }\n}\n"]}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/index-cjs.d.ts b/node_modules/rimraf/dist/cjs/src/index-cjs.d.ts
new file mode 100644
index 0000000..82e25cd
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/index-cjs.d.ts
@@ -0,0 +1,57 @@
+declare const _default: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ rimraf: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ rimrafSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ manual: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+ manualSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ native: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+ nativeSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ posix: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+ posixSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ windows: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+ windowsSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ moveRemove: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+ moveRemoveSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+} & {
+ default: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ rimraf: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ rimrafSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ manual: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+ manualSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ native: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+ nativeSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ posix: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+ posixSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ windows: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+ windowsSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ moveRemove: ((path: string | string[], opt?: import("./index.js").RimrafAsyncOptions | undefined) => Promise) & {
+ sync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+ moveRemoveSync: (path: string | string[], opt?: import("./index.js").RimrafSyncOptions | undefined) => boolean;
+ };
+};
+export = _default;
+//# sourceMappingURL=index-cjs.d.ts.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/index-cjs.d.ts.map b/node_modules/rimraf/dist/cjs/src/index-cjs.d.ts.map
new file mode 100644
index 0000000..f9581c8
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/index-cjs.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"index-cjs.d.ts","sourceRoot":"","sources":["../../../src/index-cjs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kBAAmD"}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/index-cjs.js b/node_modules/rimraf/dist/cjs/src/index-cjs.js
new file mode 100644
index 0000000..e96e51a
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/index-cjs.js
@@ -0,0 +1,7 @@
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+const index_js_1 = __importDefault(require("./index.js"));
+module.exports = Object.assign(index_js_1.default, { default: index_js_1.default });
+//# sourceMappingURL=index-cjs.js.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/index-cjs.js.map b/node_modules/rimraf/dist/cjs/src/index-cjs.js.map
new file mode 100644
index 0000000..c0feb8b
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/index-cjs.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index-cjs.js","sourceRoot":"","sources":["../../../src/index-cjs.ts"],"names":[],"mappings":";;;;AAAA,0DAA+B;AAE/B,iBAAS,MAAM,CAAC,MAAM,CAAC,kBAAM,EAAE,EAAE,OAAO,EAAE,kBAAM,EAAE,CAAC,CAAA","sourcesContent":["import rimraf from './index.js'\n\nexport = Object.assign(rimraf, { default: rimraf })\n"]}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/index.d.ts b/node_modules/rimraf/dist/cjs/src/index.d.ts
new file mode 100644
index 0000000..2b659f2
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/index.d.ts
@@ -0,0 +1,71 @@
+///
+import { GlobOptions } from 'glob';
+export interface RimrafAsyncOptions {
+ preserveRoot?: boolean;
+ tmp?: string;
+ maxRetries?: number;
+ retryDelay?: number;
+ backoff?: number;
+ maxBackoff?: number;
+ signal?: AbortSignal;
+ glob?: boolean | GlobOptions;
+ filter?: ((path: string, ent: Dirent | Stats) => boolean) | ((path: string, ent: Dirent | Stats) => Promise);
+}
+export interface RimrafSyncOptions extends RimrafAsyncOptions {
+ filter?: (path: string, ent: Dirent | Stats) => boolean;
+}
+export type RimrafOptions = RimrafSyncOptions | RimrafAsyncOptions;
+export declare const isRimrafOptions: (o: any) => o is RimrafOptions;
+export declare const assertRimrafOptions: (o: any) => void;
+import { Dirent, Stats } from 'fs';
+export declare const nativeSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+export declare const native: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise) & {
+ sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+};
+export declare const manualSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+export declare const manual: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise) & {
+ sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+};
+export declare const windowsSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+export declare const windows: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise) & {
+ sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+};
+export declare const posixSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+export declare const posix: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise) & {
+ sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+};
+export declare const moveRemoveSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+export declare const moveRemove: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise) & {
+ sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+};
+export declare const rimrafSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+export declare const sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+export declare const rimraf: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise) & {
+ rimraf: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise) & {
+ sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+ };
+ sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+ rimrafSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+ manual: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise) & {
+ sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+ };
+ manualSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+ native: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise) & {
+ sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+ };
+ nativeSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+ posix: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise) & {
+ sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+ };
+ posixSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+ windows: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise) & {
+ sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+ };
+ windowsSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+ moveRemove: ((path: string | string[], opt?: RimrafAsyncOptions) => Promise) & {
+ sync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+ };
+ moveRemoveSync: (path: string | string[], opt?: RimrafSyncOptions) => boolean;
+};
+export default rimraf;
+//# sourceMappingURL=index.d.ts.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/index.d.ts.map b/node_modules/rimraf/dist/cjs/src/index.d.ts.map
new file mode 100644
index 0000000..bd2c8a2
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/index.d.ts.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";AAGA,OAAO,EAAQ,WAAW,EAAY,MAAM,MAAM,CAAA;AAElD,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,IAAI,CAAC,EAAE,OAAO,GAAG,WAAW,CAAA;IAC5B,MAAM,CAAC,EACH,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,KAAK,OAAO,CAAC,GAChD,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;CAC9D;AAED,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,KAAK,OAAO,CAAA;CACxD;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;AAKlE,eAAO,MAAM,eAAe,MAAO,GAAG,uBAUH,CAAA;AAEnC,eAAO,MAAM,mBAAmB,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAM7C,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,IAAI,CAAA;AA2ClC,eAAO,MAAM,UAAU,SAdd,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAcF,CAAA;AACpD,eAAO,MAAM,MAAM,UAjCT,MAAM,GAAG,MAAM,EAAE,QACjB,kBAAkB,KACvB,QAAQ,OAAO,CAAC;iBAgBZ,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;CAegB,CAAA;AAE7E,eAAO,MAAM,UAAU,SAjBd,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAiBF,CAAA;AACpD,eAAO,MAAM,MAAM,UApCT,MAAM,GAAG,MAAM,EAAE,QACjB,kBAAkB,KACvB,QAAQ,OAAO,CAAC;iBAgBZ,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;CAkBgB,CAAA;AAE7E,eAAO,MAAM,WAAW,SApBf,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAoBA,CAAA;AACtD,eAAO,MAAM,OAAO,UAvCV,MAAM,GAAG,MAAM,EAAE,QACjB,kBAAkB,KACvB,QAAQ,OAAO,CAAC;iBAgBZ,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;CAqBmB,CAAA;AAEhF,eAAO,MAAM,SAAS,SAvBb,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAuBJ,CAAA;AAClD,eAAO,MAAM,KAAK,UA1CR,MAAM,GAAG,MAAM,EAAE,QACjB,kBAAkB,KACvB,QAAQ,OAAO,CAAC;iBAgBZ,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;CAwBa,CAAA;AAE1E,eAAO,MAAM,cAAc,SA1BlB,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OA0BM,CAAA;AAC5D,eAAO,MAAM,UAAU,UA7Cb,MAAM,GAAG,MAAM,EAAE,QACjB,kBAAkB,KACvB,QAAQ,OAAO,CAAC;iBAgBZ,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;CA6B3D,CAAA;AAEF,eAAO,MAAM,UAAU,SA/Bd,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAiCrD,CAAA;AACD,eAAO,MAAM,IAAI,SAlCR,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAkCxB,CAAA;AAE9B,eAAO,MAAM,MAAM,UAtDT,MAAM,GAAG,MAAM,EAAE,QACjB,kBAAkB,KACvB,QAAQ,OAAO,CAAC;oBAFX,MAAM,GAAG,MAAM,EAAE,QACjB,kBAAkB,KACvB,QAAQ,OAAO,CAAC;qBAgBZ,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;;iBAApD,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;uBAApD,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;oBAlBnD,MAAM,GAAG,MAAM,EAAE,QACjB,kBAAkB,KACvB,QAAQ,OAAO,CAAC;qBAgBZ,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;;uBAApD,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;oBAlBnD,MAAM,GAAG,MAAM,EAAE,QACjB,kBAAkB,KACvB,QAAQ,OAAO,CAAC;qBAgBZ,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;;uBAApD,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;mBAlBnD,MAAM,GAAG,MAAM,EAAE,QACjB,kBAAkB,KACvB,QAAQ,OAAO,CAAC;qBAgBZ,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;;sBAApD,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;qBAlBnD,MAAM,GAAG,MAAM,EAAE,QACjB,kBAAkB,KACvB,QAAQ,OAAO,CAAC;qBAgBZ,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;;wBAApD,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;wBAlBnD,MAAM,GAAG,MAAM,EAAE,QACjB,kBAAkB,KACvB,QAAQ,OAAO,CAAC;qBAgBZ,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;;2BAApD,MAAM,GAAG,MAAM,EAAE,QAAQ,iBAAiB,KAAG,OAAO;CAwD5D,CAAA;AAGD,eAAe,MAAM,CAAA"}
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/index.js b/node_modules/rimraf/dist/cjs/src/index.js
new file mode 100644
index 0000000..da9f4a3
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/index.js
@@ -0,0 +1,92 @@
+"use strict";
+var __importDefault = (this && this.__importDefault) || function (mod) {
+ return (mod && mod.__esModule) ? mod : { "default": mod };
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.rimraf = exports.sync = exports.rimrafSync = exports.moveRemove = exports.moveRemoveSync = exports.posix = exports.posixSync = exports.windows = exports.windowsSync = exports.manual = exports.manualSync = exports.native = exports.nativeSync = exports.assertRimrafOptions = exports.isRimrafOptions = void 0;
+const opt_arg_js_1 = require("./opt-arg.js");
+const path_arg_js_1 = __importDefault(require("./path-arg.js"));
+const glob_1 = require("glob");
+const typeOrUndef = (val, t) => typeof val === 'undefined' || typeof val === t;
+const isRimrafOptions = (o) => !!o &&
+ typeof o === 'object' &&
+ typeOrUndef(o.preserveRoot, 'boolean') &&
+ typeOrUndef(o.tmp, 'string') &&
+ typeOrUndef(o.maxRetries, 'number') &&
+ typeOrUndef(o.retryDelay, 'number') &&
+ typeOrUndef(o.backoff, 'number') &&
+ typeOrUndef(o.maxBackoff, 'number') &&
+ (typeOrUndef(o.glob, 'boolean') || (o.glob && typeof o.glob === 'object')) &&
+ typeOrUndef(o.filter, 'function');
+exports.isRimrafOptions = isRimrafOptions;
+const assertRimrafOptions = (o) => {
+ if (!(0, exports.isRimrafOptions)(o)) {
+ throw new Error('invalid rimraf options');
+ }
+};
+exports.assertRimrafOptions = assertRimrafOptions;
+const rimraf_manual_js_1 = require("./rimraf-manual.js");
+const rimraf_move_remove_js_1 = require("./rimraf-move-remove.js");
+const rimraf_native_js_1 = require("./rimraf-native.js");
+const rimraf_posix_js_1 = require("./rimraf-posix.js");
+const rimraf_windows_js_1 = require("./rimraf-windows.js");
+const use_native_js_1 = require("./use-native.js");
+const wrap = (fn) => async (path, opt) => {
+ const options = (0, opt_arg_js_1.optArg)(opt);
+ if (options.glob) {
+ path = await (0, glob_1.glob)(path, options.glob);
+ }
+ if (Array.isArray(path)) {
+ return !!(await Promise.all(path.map(p => fn((0, path_arg_js_1.default)(p, options), options)))).reduce((a, b) => a && b, true);
+ }
+ else {
+ return !!(await fn((0, path_arg_js_1.default)(path, options), options));
+ }
+};
+const wrapSync = (fn) => (path, opt) => {
+ const options = (0, opt_arg_js_1.optArgSync)(opt);
+ if (options.glob) {
+ path = (0, glob_1.globSync)(path, options.glob);
+ }
+ if (Array.isArray(path)) {
+ return !!path
+ .map(p => fn((0, path_arg_js_1.default)(p, options), options))
+ .reduce((a, b) => a && b, true);
+ }
+ else {
+ return !!fn((0, path_arg_js_1.default)(path, options), options);
+ }
+};
+exports.nativeSync = wrapSync(rimraf_native_js_1.rimrafNativeSync);
+exports.native = Object.assign(wrap(rimraf_native_js_1.rimrafNative), { sync: exports.nativeSync });
+exports.manualSync = wrapSync(rimraf_manual_js_1.rimrafManualSync);
+exports.manual = Object.assign(wrap(rimraf_manual_js_1.rimrafManual), { sync: exports.manualSync });
+exports.windowsSync = wrapSync(rimraf_windows_js_1.rimrafWindowsSync);
+exports.windows = Object.assign(wrap(rimraf_windows_js_1.rimrafWindows), { sync: exports.windowsSync });
+exports.posixSync = wrapSync(rimraf_posix_js_1.rimrafPosixSync);
+exports.posix = Object.assign(wrap(rimraf_posix_js_1.rimrafPosix), { sync: exports.posixSync });
+exports.moveRemoveSync = wrapSync(rimraf_move_remove_js_1.rimrafMoveRemoveSync);
+exports.moveRemove = Object.assign(wrap(rimraf_move_remove_js_1.rimrafMoveRemove), {
+ sync: exports.moveRemoveSync,
+});
+exports.rimrafSync = wrapSync((path, opt) => (0, use_native_js_1.useNativeSync)(opt) ? (0, rimraf_native_js_1.rimrafNativeSync)(path, opt) : (0, rimraf_manual_js_1.rimrafManualSync)(path, opt));
+exports.sync = exports.rimrafSync;
+exports.rimraf = Object.assign(wrap((path, opt) => (0, use_native_js_1.useNative)(opt) ? (0, rimraf_native_js_1.rimrafNative)(path, opt) : (0, rimraf_manual_js_1.rimrafManual)(path, opt)), {
+ // this weirdness because it's easier than explicitly declaring
+ rimraf: exports.manual,
+ sync: exports.rimrafSync,
+ rimrafSync: exports.rimrafSync,
+ manual: exports.manual,
+ manualSync: exports.manualSync,
+ native: exports.native,
+ nativeSync: exports.nativeSync,
+ posix: exports.posix,
+ posixSync: exports.posixSync,
+ windows: exports.windows,
+ windowsSync: exports.windowsSync,
+ moveRemove: exports.moveRemove,
+ moveRemoveSync: exports.moveRemoveSync,
+});
+exports.rimraf.rimraf = exports.rimraf;
+exports.default = exports.rimraf;
+//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/node_modules/rimraf/dist/cjs/src/index.js.map b/node_modules/rimraf/dist/cjs/src/index.js.map
new file mode 100644
index 0000000..fedfb49
--- /dev/null
+++ b/node_modules/rimraf/dist/cjs/src/index.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAiD;AACjD,gEAAmC;AAEnC,+BAAkD;AAsBlD,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAE,CAAS,EAAE,EAAE,CAC1C,OAAO,GAAG,KAAK,WAAW,IAAI,OAAO,GAAG,KAAK,CAAC,CAAA;AAEzC,MAAM,eAAe,GAAG,CAAC,CAAM,EAAsB,EAAE,CAC5D,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,QAAQ;IACrB,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,SAAS,CAAC;IACtC,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC;IAC5B,WAAW,CAAC,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC;IACnC,WAAW,CAAC,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC;IACnC,WAAW,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC;IAChC,WAAW,CAAC,CAAC,CAAC,UAAU,EAAE,QAAQ,CAAC;IACnC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;IAC1E,WAAW,CAAC,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAVtB,QAAA,eAAe,mBAUO;AAE5B,MAAM,mBAAmB,GAAqB,CACnD,CAAM,EACsB,EAAE;IAC9B,IAAI,CAAC,IAAA,uBAAe,EAAC,CAAC,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;KAC1C;AACH,CAAC,CAAA;AANY,QAAA,mBAAmB,uBAM/B;AAGD,yDAAmE;AACnE,mEAAgF;AAChF,yDAAmE;AACnE,uDAAgE;AAChE,2DAAsE;AACtE,mDAA0D;AAE1D,MAAM,IAAI,GACR,CAAC,EAA0D,EAAE,EAAE,CAC/D,KAAK,EACH,IAAuB,EACvB,GAAwB,EACN,EAAE;IACpB,MAAM,OAAO,GAAG,IAAA,mBAAM,EAAC,GAAG,CAAC,CAAA;IAC3B,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,IAAI,GAAG,MAAM,IAAA,WAAI,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;KACtC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACvB,OAAO,CAAC,CAAC,CACP,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAA,qBAAO,EAAC,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CACnE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;KACjC;SAAM;QACL,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,IAAA,qBAAO,EAAC,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA;KACrD;AACH,CAAC,CAAA;AAEH,MAAM,QAAQ,GACZ,CAAC,EAAgD,EAAE,EAAE,CACrD,CAAC,IAAuB,EAAE,GAAuB,EAAW,EAAE;IAC5D,MAAM,OAAO,GAAG,IAAA,uBAAU,EAAC,GAAG,CAAC,CAAA;IAC/B,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,IAAI,GAAG,IAAA,eAAQ,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;KACpC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACvB,OAAO,CAAC,CAAC,IAAI;aACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAA,qBAAO,EAAC,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;aAC1C,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;KAClC;SAAM;QACL,OAAO,CAAC,CAAC,EAAE,CAAC,IAAA,qBAAO,EAAC,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAA;KAC7C;AACH,CAAC,CAAA;AAEU,QAAA,UAAU,GAAG,QAAQ,CAAC,mCAAgB,CAAC,CAAA;AACvC,QAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,+BAAY,CAAC,EAAE,EAAE,IAAI,EAAE,kBAAU,EAAE,CAAC,CAAA;AAEhE,QAAA,UAAU,GAAG,QAAQ,CAAC,mCAAgB,CAAC,CAAA;AACvC,QAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,+BAAY,CAAC,EAAE,EAAE,IAAI,EAAE,kBAAU,EAAE,CAAC,CAAA;AAEhE,QAAA,WAAW,GAAG,QAAQ,CAAC,qCAAiB,CAAC,CAAA;AACzC,QAAA,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iCAAa,CAAC,EAAE,EAAE,IAAI,EAAE,mBAAW,EAAE,CAAC,CAAA;AAEnE,QAAA,SAAS,GAAG,QAAQ,CAAC,iCAAe,CAAC,CAAA;AACrC,QAAA,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,6BAAW,CAAC,EAAE,EAAE,IAAI,EAAE,iBAAS,EAAE,CAAC,CAAA;AAE7D,QAAA,cAAc,GAAG,QAAQ,CAAC,4CAAoB,CAAC,CAAA;AAC/C,QAAA,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,wCAAgB,CAAC,EAAE;IAC9D,IAAI,EAAE,sBAAc;CACrB,CAAC,CAAA;AAEW,QAAA,UAAU,GAAG,QAAQ,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAC/C,IAAA,6BAAa,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,mCAAgB,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,mCAAgB,EAAC,IAAI,EAAE,GAAG,CAAC,CAC/E,CAAA;AACY,QAAA,IAAI,GAAG,kBAAU,CAAA;AAEjB,QAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CACjC,IAAI,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CACjB,IAAA,yBAAS,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,+BAAY,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,+BAAY,EAAC,IAAI,EAAE,GAAG,CAAC,CACnE,EACD;IACE,+DAA+D;IAC/D,MAAM,EAAE,cAAM;IACd,IAAI,EAAE,kBAAU;IAChB,UAAU,EAAE,kBAAU;IACtB,MAAM,EAAN,cAAM;IACN,UAAU,EAAV,kBAAU;IACV,MAAM,EAAN,cAAM;IACN,UAAU,EAAV,kBAAU;IACV,KAAK,EAAL,aAAK;IACL,SAAS,EAAT,iBAAS;IACT,OAAO,EAAP,eAAO;IACP,WAAW,EAAX,mBAAW;IACX,UAAU,EAAV,kBAAU;IACV,cAAc,EAAd,sBAAc;CACf,CACF,CAAA;AACD,cAAM,CAAC,MAAM,GAAG,cAAM,CAAA;AAEtB,kBAAe,cAAM,CAAA","sourcesContent":["import { optArg, optArgSync } from './opt-arg.js'\nimport pathArg from './path-arg.js'\n\nimport { glob, GlobOptions, globSync } from 'glob'\n\nexport interface RimrafAsyncOptions {\n preserveRoot?: boolean\n tmp?: string\n maxRetries?: number\n retryDelay?: number\n backoff?: number\n maxBackoff?: number\n signal?: AbortSignal\n glob?: boolean | GlobOptions\n filter?:\n | ((path: string, ent: Dirent | Stats) => boolean)\n | ((path: string, ent: Dirent | Stats) => Promise)\n}\n\nexport interface RimrafSyncOptions extends RimrafAsyncOptions {\n filter?: (path: string, ent: Dirent | Stats) => boolean\n}\n\nexport type RimrafOptions = RimrafSyncOptions | RimrafAsyncOptions\n\nconst typeOrUndef = (val: any, t: string) =>\n typeof val === 'undefined' || typeof val === t\n\nexport const isRimrafOptions = (o: any): o is RimrafOptions =>\n !!o &&\n typeof o === 'object' &&\n typeOrUndef(o.preserveRoot, 'boolean') &&\n typeOrUndef(o.tmp, 'string') &&\n typeOrUndef(o.maxRetries, 'number') &&\n typeOrUndef(o.retryDelay, 'number') &&\n typeOrUndef(o.backoff, 'number') &&\n typeOrUndef(o.maxBackoff, 'number') &&\n (typeOrUndef(o.glob, 'boolean') || (o.glob && typeof o.glob === 'object')) &&\n typeOrUndef(o.filter, 'function')\n\nexport const assertRimrafOptions: (o: any) => void = (\n o: any\n): asserts o is RimrafOptions => {\n if (!isRimrafOptions(o)) {\n throw new Error('invalid rimraf options')\n }\n}\n\nimport { Dirent, Stats } from 'fs'\nimport { rimrafManual, rimrafManualSync } from './rimraf-manual.js'\nimport { rimrafMoveRemove, rimrafMoveRemoveSync } from './rimraf-move-remove.js'\nimport { rimrafNative, rimrafNativeSync } from './rimraf-native.js'\nimport { rimrafPosix, rimrafPosixSync } from './rimraf-posix.js'\nimport { rimrafWindows, rimrafWindowsSync } from './rimraf-windows.js'\nimport { useNative, useNativeSync } from './use-native.js'\n\nconst wrap =\n (fn: (p: string, o: RimrafAsyncOptions) => Promise) =>\n async (\n path: string | string[],\n opt?: RimrafAsyncOptions\n ): Promise