diff --git a/browser.js b/browser.js index 9de7b5a89..3be2ed334 100644 --- a/browser.js +++ b/browser.js @@ -6,19 +6,19 @@ * license: MIT (http://opensource.org/licenses/MIT) * author: Heather Arthur * homepage: https://github.com/brainjs/brain.js#readme - * version: 1.1.1 + * version: 1.1.2 * * acorn: * license: MIT (http://opensource.org/licenses/MIT) * maintainers: Marijn Haverbeke , Ingvar Stepanyan * homepage: https://github.com/acornjs/acorn - * version: 5.3.0 + * version: 5.4.1 * * base64-js: * license: MIT (http://opensource.org/licenses/MIT) * author: T. Jameson Little * homepage: https://github.com/beatgammit/base64-js - * version: 1.2.1 + * version: 1.2.3 * * buffer: * license: MIT (http://opensource.org/licenses/MIT) @@ -41,7 +41,7 @@ * license: MIT (http://opensource.org/licenses/MIT) * author: The gpu.js Team * homepage: http://gpu.rocks/ - * version: 1.2.0 + * version: 1.0.0 * * ieee754: * license: BSD-3-Clause (http://opensource.org/licenses/BSD-3-Clause) @@ -67,11 +67,11 @@ * process-nextick-args: * license: MIT (http://opensource.org/licenses/MIT) * homepage: https://github.com/calvinmetcalf/process-nextick-args - * version: 1.0.7 + * version: 2.0.0 * * readable-stream: * license: MIT (http://opensource.org/licenses/MIT) - * version: 2.3.3 + * version: 2.3.4 * * safe-buffer: * license: MIT (http://opensource.org/licenses/MIT) @@ -104,7 +104,7 @@ * * This header is generated by licensify (https://github.com/twada/licensify) */ -(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.brain = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 9 && this.inAsync && this.eatContextual("await")) ? this.lastTokStart : -1; this.labels.push(loopLabel); this.enterLexicalScope(); this.expect(types.parenL); - if (this.type === types.semi) { return this.parseFor(node, null) } + if (this.type === types.semi) { + if (awaitAt > -1) { this.unexpected(awaitAt); } + return this.parseFor(node, null) + } var isLet = this.isLet(); if (this.type === types._var || this.type === types._const || isLet) { var init$1 = this.startNode(), kind = isLet ? "let" : this.value; @@ -5665,19 +5670,32 @@ pp$1.parseForStatement = function(node) { this.parseVar(init$1, true, kind); this.finishNode(init$1, "VariableDeclaration"); if ((this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1 && - !(kind !== "var" && init$1.declarations[0].init)) - { return this.parseForIn(node, init$1) } + !(kind !== "var" && init$1.declarations[0].init)) { + if (this.options.ecmaVersion >= 9) { + if (this.type === types._in) { + if (awaitAt > -1) { this.unexpected(awaitAt); } + } else { node.await = awaitAt > -1; } + } + return this.parseForIn(node, init$1) + } + if (awaitAt > -1) { this.unexpected(awaitAt); } return this.parseFor(node, init$1) } var refDestructuringErrors = new DestructuringErrors; var init = this.parseExpression(true, refDestructuringErrors); if (this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) { + if (this.options.ecmaVersion >= 9) { + if (this.type === types._in) { + if (awaitAt > -1) { this.unexpected(awaitAt); } + } else { node.await = awaitAt > -1; } + } this.toAssignable(init, false, refDestructuringErrors); this.checkLVal(init); return this.parseForIn(node, init) } else { this.checkExpressionErrors(refDestructuringErrors, true); } + if (awaitAt > -1) { this.unexpected(awaitAt); } return this.parseFor(node, init) }; @@ -5948,7 +5966,7 @@ pp$1.parseVarId = function(decl, kind) { pp$1.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) { this.initFunction(node); - if (this.options.ecmaVersion >= 6 && !isAsync) + if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) { node.generator = this.eat(types.star); } if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; } @@ -6041,6 +6059,7 @@ pp$1.parseClassMember = function(classBody) { if (!isGenerator) { if (this.options.ecmaVersion >= 8 && tryContextual("async", true)) { isAsync = true; + isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star); } else if (tryContextual("get")) { method.kind = "get"; } else if (tryContextual("set")) { @@ -6160,7 +6179,7 @@ pp$1.checkPatternExport = function(exports, pat) { { var prop = list[i]; - this$1.checkPatternExport(exports, prop.value); + this$1.checkPatternExport(exports, prop); } } else if (type == "ArrayPattern") { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) { @@ -6168,8 +6187,12 @@ pp$1.checkPatternExport = function(exports, pat) { if (elt) { this$1.checkPatternExport(exports, elt); } } } + else if (type == "Property") + { this.checkPatternExport(exports, pat.value); } else if (type == "AssignmentPattern") { this.checkPatternExport(exports, pat.left); } + else if (type == "RestElement") + { this.checkPatternExport(exports, pat.argument); } else if (type == "ParenthesizedExpression") { this.checkPatternExport(exports, pat.expression); } }; @@ -6318,12 +6341,22 @@ pp$2.toAssignable = function(node, isBinding, refDestructuringErrors) { case "ObjectExpression": node.type = "ObjectPattern"; if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); } - for (var i = 0, list = node.properties; i < list.length; i += 1) - { - var prop = list[i]; + for (var i = 0, list = node.properties; i < list.length; i += 1) { + var prop = list[i]; this$1.toAssignable(prop, isBinding); - } + // Early error: + // AssignmentRestProperty[Yield, Await] : + // `...` DestructuringAssignmentTarget[Yield, Await] + // + // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|. + if ( + prop.type === "RestElement" && + (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern") + ) { + this$1.raise(prop.argument.start, "Unexpected token"); + } + } break case "Property": @@ -6572,6 +6605,8 @@ var pp$3 = Parser.prototype; // strict mode, init properties are also not allowed to be repeated. pp$3.checkPropClash = function(prop, propHash, refDestructuringErrors) { + if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement") + { return } if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) { return } var key = prop.key; @@ -7098,7 +7133,7 @@ pp$3.parseTemplate = function(ref) { pp$3.isAsyncProp = function(prop) { return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && - (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword) && + (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types.star)) && !lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }; @@ -7125,6 +7160,32 @@ pp$3.parseObj = function(isPattern, refDestructuringErrors) { pp$3.parseProperty = function(isPattern, refDestructuringErrors) { var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc; + if (this.options.ecmaVersion >= 9 && this.eat(types.ellipsis)) { + if (isPattern) { + prop.argument = this.parseIdent(false); + if (this.type === types.comma) { + this.raise(this.start, "Comma is not permitted after the rest element"); + } + return this.finishNode(prop, "RestElement") + } + // To disallow parenthesized identifier via `this.toAssignable()`. + if (this.type === types.parenL && refDestructuringErrors) { + if (refDestructuringErrors.parenthesizedAssign < 0) { + refDestructuringErrors.parenthesizedAssign = this.start; + } + if (refDestructuringErrors.parenthesizedBind < 0) { + refDestructuringErrors.parenthesizedBind = this.start; + } + } + // Parse argument. + prop.argument = this.parseMaybeAssign(false, refDestructuringErrors); + // To disallow trailing comma via `this.toAssignable()`. + if (this.type === types.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) { + refDestructuringErrors.trailingComma = this.start; + } + // Finish + return this.finishNode(prop, "SpreadElement") + } if (this.options.ecmaVersion >= 6) { prop.method = false; prop.shorthand = false; @@ -7139,6 +7200,7 @@ pp$3.parseProperty = function(isPattern, refDestructuringErrors) { this.parsePropertyName(prop); if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) { isAsync = true; + isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star); this.parsePropertyName(prop, refDestructuringErrors); } else { isAsync = false; @@ -8152,15 +8214,20 @@ pp$8.readRegexp = function() { } var content = this.input.slice(start, this.pos); ++this.pos; - // Need to use `readWord1` because '\uXXXX' sequences are allowed - // here (don't ask). + var flagsStart = this.pos; var mods = this.readWord1(); + if (this.containsEsc) { this.unexpected(flagsStart); } + var tmp = content, tmpFlags = ""; if (mods) { - var validFlags = /^[gim]*$/; - if (this.options.ecmaVersion >= 6) { validFlags = /^[gimuy]*$/; } - if (this.options.ecmaVersion >= 9) { validFlags = /^[gimsuy]*$/; } - if (!validFlags.test(mods)) { this.raise(start, "Invalid regular expression flag"); } + var validFlags = "gim"; + if (this.options.ecmaVersion >= 6) { validFlags += "uy"; } + if (this.options.ecmaVersion >= 9) { validFlags += "s"; } + for (var i = 0; i < mods.length; i++) { + var mod = mods.charAt(i); + if (validFlags.indexOf(mod) == -1) { this$1.raise(start, "Invalid regular expression flag"); } + if (mods.indexOf(mod, i + 1) > -1) { this$1.raise(start, "Duplicate regular expression flag"); } + } if (mods.indexOf("u") >= 0) { if (regexpUnicodeSupport) { tmpFlags = "u"; @@ -8424,10 +8491,11 @@ pp$8.readEscapedChar = function(inTemplate) { octalStr = octalStr.slice(0, -1); octal = parseInt(octalStr, 8); } - if (octalStr !== "0" && (this.strict || inTemplate)) { - this.invalidStringToken(this.pos - 2, "Octal literal in strict mode"); - } this.pos += octalStr.length - 1; + ch = this.input.charCodeAt(this.pos); + if ((octalStr !== "0" || ch == 56 || ch == 57) && (this.strict || inTemplate)) { + this.invalidStringToken(this.pos - 1 - octalStr.length, "Octal literal in strict mode"); + } return String.fromCharCode(octal) } return String.fromCharCode(ch) @@ -8513,7 +8581,7 @@ pp$8.readWord = function() { // [dammit]: acorn_loose.js // [walk]: util/walk.js -var version = "5.3.0"; +var version = "5.4.1"; // The main exported interface (under `self.acorn` when in the // browser) is a `parse` function that takes a code string and @@ -8599,6 +8667,8 @@ for (var i = 0, len = code.length; i < len; ++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 @@ -8660,7 +8730,7 @@ function encodeChunk (uint8, start, end) { var tmp var output = [] for (var i = start; i < end; i += 3) { - tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) output.push(tripletToBase64(tmp)) } return output.join('') @@ -10911,6 +10981,8 @@ function isUndefined(arg) { },{}],51:[function(require,module,exports){ 'use strict'; +var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } @@ -10940,6 +11012,11 @@ module.exports = function (_FunctionBuilderBase) { return _this; } + _createClass(CPUFunctionBuilder, [{ + key: 'polyfillStandardFunctions', + value: function polyfillStandardFunctions() {} + }]); + return CPUFunctionBuilder; }(FunctionBuilderBase); },{"../function-builder-base":56,"./function-node":52}],52:[function(require,module,exports){ @@ -12038,19 +12115,8 @@ module.exports = function (_BaseFunctionNode) { var utils = require('../../core/utils'); var kernelRunShortcut = require('../kernel-run-shortcut'); -function removeFnNoise(fn) { - if (/^function /.test(fn)) { - fn = fn.substring(9); - } - return fn.replace(/[_]typeof/g, 'typeof'); -} - -function removeNoise(str) { - return str.replace(/[_]typeof/g, 'typeof'); -} - module.exports = function (cpuKernel, name) { - return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + '\n };\n const Utils = utils;\n class ' + (name || 'Kernel') + ' {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(cpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(cpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(cpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n this._kernelString = `' + cpuKernel._kernelString + '`;\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(cpuKernel.build.toString()) + '\n ' + removeFnNoise(cpuKernel.setupParams.toString()) + '\n run () { ' + cpuKernel.kernelString + ' }\n getKernelString() { return this._kernelString; }\n };\n return kernelRunShortcut(new Kernel());\n };'; + return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: function ' + utils.allPropertiesOf.toString() + ',\n clone: function ' + utils.clone.toString() + ',\n /*splitArray: function ' + utils.splitArray.toString() + ',\n getArgumentType: function ' + utils.getArgumentType.toString() + ',\n getOutput: function ' + utils.getOutput.toString() + ',\n dimToTexSize: function ' + utils.dimToTexSize.toString() + ',\n copyFlatten: function ' + utils.copyFlatten.toString() + ',\n flatten: function ' + utils.flatten.toString() + ',\n systemEndianness: \'' + utils.systemEndianness() + '\',\n initWebGl: function ' + utils.initWebGl.toString() + ',\n isArray: function ' + utils.isArray.toString() + '*/\n };\n class ' + (name || 'Kernel') + ' {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(cpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(cpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(cpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n this._kernelString = `' + cpuKernel._kernelString + '`;\n this.output = ' + JSON.stringify(cpuKernel.output) + ';\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + cpuKernel.build.toString() + '\n run () { ' + cpuKernel.kernelString + ' }\n getKernelString() { return this._kernelString; }\n };\n return kernelRunShortcut(new Kernel());\n };'; }; },{"../../core/utils":75,"../kernel-run-shortcut":59}],54:[function(require,module,exports){ 'use strict'; @@ -12810,6 +12876,11 @@ module.exports = function () { } return this.getStringFromFunctionNames(Object.keys(this.nodeMap), opt); } + }, { + key: 'polyfillStandardFunctions', + value: function polyfillStandardFunctions() { + throw new Error('polyfillStandardFunctions not defined on base function builder'); + } }]); return FunctionBuilderBase; @@ -13275,7 +13346,6 @@ module.exports = function () { this.wraparound = null; this.hardcodeConstants = null; this.outputToTexture = null; - this.outputImmutable = null; this.texSize = null; this._canvas = null; this._webGl = null; @@ -13286,6 +13356,7 @@ module.exports = function () { this.addFunction = null; this.functions = null; this.nativeFunctions = null; + this.copyData = true; this.subKernels = null; this.subKernelProperties = null; this.subKernelNames = null; @@ -13464,12 +13535,6 @@ module.exports = function () { this.outputToTexture = flag; return this; } - }, { - key: 'setOutputImmutable', - value: function setOutputImmutable(flag) { - this.outputImmutable = flag; - return this; - } /** * @memberOf BaseKernel# @@ -13548,6 +13613,12 @@ module.exports = function () { this._webGl = webGl; return this; } + }, { + key: 'setCopyData', + value: function setCopyData(copyData) { + this.copyData = copyData; + return this; + } /** * @memberOf BaseKernel# @@ -13754,6 +13825,7 @@ module.exports = function () { this.functionBuilder = functionBuilder; this.fnString = null; this.endianness = utils.systemEndianness(); + this.functionBuilder.polyfillStandardFunctions(); } /** @@ -13855,6 +13927,8 @@ module.exports = function () { },{"../core/utils":75,"./kernel-run-shortcut":59}],61:[function(require,module,exports){ 'use strict'; +var _createClass = 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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } @@ -13873,19 +13947,54 @@ var WebGLFunctionNode = require('./function-node'); * */ module.exports = function (_FunctionBuilderBase) { - _inherits(WebGLFunctionBuilder, _FunctionBuilderBase); + _inherits(WebGLFunctionBuilder, _FunctionBuilderBase); - function WebGLFunctionBuilder() { - _classCallCheck(this, WebGLFunctionBuilder); + function WebGLFunctionBuilder() { + _classCallCheck(this, WebGLFunctionBuilder); - var _this = _possibleConstructorReturn(this, (WebGLFunctionBuilder.__proto__ || Object.getPrototypeOf(WebGLFunctionBuilder)).call(this)); + var _this = _possibleConstructorReturn(this, (WebGLFunctionBuilder.__proto__ || Object.getPrototypeOf(WebGLFunctionBuilder)).call(this)); + + _this.Node = WebGLFunctionNode; + return _this; + } + + //--------------------------------------------------------- + // + // Polyfill stuff + // + //--------------------------------------------------------- + + // Round function used in polyfill + + + _createClass(WebGLFunctionBuilder, [{ + key: 'polyfillStandardFunctions', - _this.Node = WebGLFunctionNode; - return _this; - } - return WebGLFunctionBuilder; + /** + * @memberOf FunctionBuilderBase# + * @function + * @name polyfillStandardFunctions + * + * @desc Polyfill in the missing Math functions (round) + * + */ + value: function polyfillStandardFunctions() { + this.addFunction('round', _round); + } + }], [{ + key: 'round', + value: function round(a) { + return _round(a); + } + }]); + + return WebGLFunctionBuilder; }(FunctionBuilderBase); + +function _round(a) { + return Math.floor(a + 0.5); +} },{"../function-builder-base":56,"./function-node":62}],62:[function(require,module,exports){ 'use strict'; @@ -14929,11 +15038,6 @@ module.exports = function (_FunctionNodeBase) { funcName = funcName.slice(localPrefix.length); } - // if this if grows to more than one, lets use a switch - if (funcName === 'atan2') { - funcName = 'atan'; - } - // Register the function into the called registry if (funcParam.calledFunctions.indexOf(funcName) < 0) { funcParam.calledFunctions.push(funcName); @@ -15121,19 +15225,8 @@ function webGlRegexOptimize(inStr) { var utils = require('../../core/utils'); var kernelRunShortcut = require('../kernel-run-shortcut'); -function removeFnNoise(fn) { - if (/^function /.test(fn)) { - fn = fn.substring(9); - } - return fn.replace(/[_]typeof/g, 'typeof'); -} - -function removeNoise(str) { - return str.replace(/[_]typeof/g, 'typeof'); -} - module.exports = function (gpuKernel, name) { - return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: ' + removeNoise(utils.allPropertiesOf.toString()) + ',\n clone: ' + removeNoise(utils.clone.toString()) + ',\n splitArray: ' + removeNoise(utils.splitArray.toString()) + ',\n getArgumentType: ' + removeNoise(utils.getArgumentType.toString()) + ',\n getDimensions: ' + removeNoise(utils.getDimensions.toString()) + ',\n dimToTexSize: ' + removeNoise(utils.dimToTexSize.toString()) + ',\n flattenTo: ' + removeNoise(utils.flattenTo.toString()) + ',\n flatten2dArrayTo: ' + removeNoise(utils.flatten2dArrayTo.toString()) + ',\n flatten3dArrayTo: ' + removeNoise(utils.flatten3dArrayTo.toString()) + ',\n systemEndianness: \'' + removeNoise(utils.systemEndianness()) + '\',\n initWebGl: ' + removeNoise(utils.initWebGl.toString()) + ',\n isArray: ' + removeNoise(utils.isArray.toString()) + '\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n }\n ' + removeFnNoise(gpuKernel._getFragShaderString.toString()) + '\n ' + removeFnNoise(gpuKernel._getVertShaderString.toString()) + '\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + removeFnNoise(gpuKernel.getUniformLocation.toString()) + '\n ' + removeFnNoise(gpuKernel.setupParams.toString()) + '\n ' + removeFnNoise(gpuKernel.build.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.run.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._addArgument.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getArgumentTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getTextureCache.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.getOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.renderOutput.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.updateMaxTexSize.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel._setupOutputTexture.toString()) + '\n\t\t ' + removeFnNoise(gpuKernel.detachTextureCache.toString()) + '\n };\n return kernelRunShortcut(new Kernel());\n };'; + return '() => {\n ' + kernelRunShortcut.toString() + ';\n const utils = {\n allPropertiesOf: function ' + utils.allPropertiesOf.toString() + ',\n clone: function ' + utils.clone.toString() + ',\n splitArray: function ' + utils.splitArray.toString() + ',\n getArgumentType: function ' + utils.getArgumentType.toString() + ',\n getDimensions: function ' + utils.getDimensions.toString() + ',\n dimToTexSize: function ' + utils.dimToTexSize.toString() + ',\n copyFlatten: function ' + utils.copyFlatten.toString() + ',\n flatten: function ' + utils.flatten.toString() + ',\n systemEndianness: \'' + utils.systemEndianness() + '\',\n initWebGl: function ' + utils.initWebGl.toString() + ',\n isArray: function ' + utils.isArray.toString() + '\n };\n class ' + (name || 'Kernel') + ' {\n constructor() {\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = ' + JSON.stringify(gpuKernel.paramNames) + ';\n this.paramTypes = ' + JSON.stringify(gpuKernel.paramTypes) + ';\n this.texSize = ' + JSON.stringify(gpuKernel.texSize) + ';\n this.output = ' + JSON.stringify(gpuKernel.output) + ';\n this.compiledFragShaderString = `' + gpuKernel.compiledFragShaderString + '`;\n\t\t this.compiledVertShaderString = `' + gpuKernel.compiledVertShaderString + '`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n }\n ' + gpuKernel._getFragShaderString.toString() + '\n ' + gpuKernel._getVertShaderString.toString() + '\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n ' + gpuKernel.getUniformLocation.toString() + '\n ' + gpuKernel.setupParams.toString() + '\n ' + gpuKernel.build.toString() + '\n\t\t ' + gpuKernel.run.toString() + '\n\t\t ' + gpuKernel._addArgument.toString() + '\n\t\t ' + gpuKernel.getArgumentTexture.toString() + '\n\t\t ' + gpuKernel.getTextureCache.toString() + '\n\t\t ' + gpuKernel.getOutputTexture.toString() + '\n\t\t ' + gpuKernel.renderOutput.toString() + '\n };\n return kernelRunShortcut(new Kernel());\n };'; }; },{"../../core/utils":75,"../kernel-run-shortcut":59}],64:[function(require,module,exports){ 'use strict'; @@ -15198,9 +15291,10 @@ module.exports = function (_KernelBase) { _this.subKernelOutputTextures = null; _this.subKernelOutputVariableNames = null; _this.argumentsLength = 0; + _this.ext = null; _this.compiledFragShaderString = null; _this.compiledVertShaderString = null; - _this.drawBuffersMap = null; + _this.extDrawBuffersMap = null; _this.outputTexture = null; _this.maxTexSize = null; if (!_this._webGl) _this._webGl = utils.initWebGl(_this.getCanvas()); @@ -15223,9 +15317,11 @@ module.exports = function (_KernelBase) { key: 'validateOptions', value: function validateOptions() { var isFloatReadPixel = utils.isFloatReadPixelsSupported(); - if (this.floatOutput === true && this.floatOutputForce !== true && !isFloatReadPixel) { + if (this.floatTextures === true && !utils.OES_texture_float) { + throw new Error('Float textures are not supported on this browser'); + } else if (this.floatOutput === true && this.floatOutputForce !== true && !isFloatReadPixel) { throw new Error('Float texture outputs are not supported on this browser'); - } else if (this.floatTextures === undefined) { + } else if (this.floatTextures === undefined && utils.OES_texture_float) { this.floatTextures = true; this.floatOutput = isFloatReadPixel; } @@ -15261,13 +15357,9 @@ module.exports = function (_KernelBase) { } this.texSize = utils.clone(this.output); - } else if (this.floatOutput === undefined) { + } else if (this.floatOutput === undefined && utils.OES_texture_float) { this.floatOutput = true; } - - if (this.floatOutput || this.floatOutputForce) { - this._webGl.getExtension('EXT_color_buffer_float'); - } } }, { key: 'updateMaxTexSize', @@ -15381,12 +15473,25 @@ module.exports = function (_KernelBase) { gl.enableVertexAttribArray(aTexCoordLoc); gl.vertexAttribPointer(aTexCoordLoc, 2, gl.FLOAT, gl.FALSE, 0, texCoordOffset); - if (!this.outputImmutable) { - this._setupOutputTexture(); - } + this.setupOutputTexture(); - if (this.subKernelOutputVariableNames !== null && this.subKernelOutputVariableNames.length > 0 && !this.outputImmutable) { - this._setupSubOutputTextures(this.subKernelOutputVariableNames.length); + if (this.subKernelOutputTextures !== null) { + var extDrawBuffersMap = this.extDrawBuffersMap = [gl.COLOR_ATTACHMENT0]; + for (var i = 0; i < this.subKernelOutputTextures.length; i++) { + var subKernelOutputTexture = this.subKernelOutputTextures[i]; + extDrawBuffersMap.push(gl.COLOR_ATTACHMENT0 + i + 1); + gl.activeTexture(gl.TEXTURE0 + arguments.length + i); + gl.bindTexture(gl.TEXTURE_2D, subKernelOutputTexture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); + if (this.floatOutput) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); + } else { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + } + } } } @@ -15399,7 +15504,7 @@ module.exports = function (_KernelBase) { * *

This method calls a helper method *renderOutput* to return the result.

* - * @returns {Object|Undefined} Result The final output of the program, as float, and as Textures for reuse. + * @returns {Object} Result The final output of the program, as float, and as Textures for reuse. * * */ @@ -15441,22 +15546,16 @@ module.exports = function (_KernelBase) { } gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer); - if (this.outputImmutable) { - this._setupOutputTexture(); - } + //the call to this._addArgument may rewrite the outputTexture, keep this here var outputTexture = this.outputTexture; gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, outputTexture, 0); - if (this.subKernelOutputVariableNames !== null) { - if (this.outputImmutable) { - this.subKernelOutputTextures = []; - this._setupSubOutputTextures(this.subKernelOutputVariableNames.length); - } + if (this.subKernelOutputTextures !== null) { for (var i = 0; i < this.subKernelOutputTextures.length; i++) { var subKernelOutputTexture = this.subKernelOutputTextures[i]; gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i + 1, gl.TEXTURE_2D, subKernelOutputTexture, 0); } - gl.drawBuffers(this.drawBuffersMap); + this.ext.drawBuffersWEBGL(this.extDrawBuffersMap); } gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4); @@ -15466,7 +15565,7 @@ module.exports = function (_KernelBase) { var output = []; output.result = this.renderOutput(outputTexture); for (var _i = 0; _i < this.subKernels.length; _i++) { - output.push(new Texture(this.subKernelOutputTextures[_i], texSize, this.threadDim, this.output, this._webGl)); + output.push(new Texture(this.subKernelOutputTextures[_i], texSize, this.output, this._webGl)); } return output; } else if (this.subKernelProperties !== null) { @@ -15476,7 +15575,7 @@ module.exports = function (_KernelBase) { var _i2 = 0; for (var p in this.subKernelProperties) { if (!this.subKernelProperties.hasOwnProperty(p)) continue; - _output[p] = new Texture(this.subKernelOutputTextures[_i2], texSize, this.threadDim, this.output, this._webGl); + _output[p] = new Texture(this.subKernelOutputTextures[_i2], texSize, this.output, this._webGl); _i2++; } return _output; @@ -15513,7 +15612,7 @@ module.exports = function (_KernelBase) { var threadDim = this.threadDim; var output = this.output; if (this.outputToTexture) { - return new Texture(outputTexture, texSize, this.threadDim, output, this._webGl); + return new Texture(outputTexture, texSize, output, this._webGl); } else { var result = void 0; if (this.floatOutput) { @@ -15545,33 +15644,49 @@ module.exports = function (_KernelBase) { * @function * @name getOutputTexture * - * @desc This return defined outputTexture, which is setup in .build(), or if immutable, is defined in .run() + * @desc This uses *getTextureCache* to get the Texture Cache of the Output * - * @returns {Object} Output Texture Cache + * @returns {Object} Ouptut Texture Cache * */ }, { key: 'getOutputTexture', value: function getOutputTexture() { - return this.outputTexture; + return this.getTextureCache('OUTPUT'); } /** * @memberOf WebGLKernel# * @function - * @name _setupOutputTexture - * @private + * @name detachOutputTexture + * + * @desc Detaches output texture + * + * + */ + + }, { + key: 'detachOutputTexture', + value: function detachOutputTexture() { + this.detachTextureCache('OUTPUT'); + } + + /** + * @memberOf WebGLKernel# + * @function + * @name setupOutputTexture * - * @desc Setup and replace output texture + * @desc Detaches a texture from cache if exists, and sets up output texture */ }, { - key: '_setupOutputTexture', - value: function _setupOutputTexture() { + key: 'setupOutputTexture', + value: function setupOutputTexture() { var gl = this._webGl; var texSize = this.texSize; - this.outputTexture = this._webGl.createTexture(); + this.detachOutputTexture(); + this.outputTexture = this.getOutputTexture(); gl.activeTexture(gl.TEXTURE0 + this.paramNames.length); gl.bindTexture(gl.TEXTURE_2D, this.outputTexture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); @@ -15579,7 +15694,7 @@ module.exports = function (_KernelBase) { gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); if (this.floatOutput) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); } else { gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); } @@ -15587,54 +15702,40 @@ module.exports = function (_KernelBase) { /** * @memberOf WebGLKernel# - * @param length - * @private + * @function + * @name getArgumentTexture + * + * @desc This uses *getTextureCache** to get the Texture Cache of the argument supplied + * + * @param {String} name - Name of the argument + * + * Texture cache for the supplied argument * - * @desc Setup and replace sub-output textures */ }, { - key: '_setupSubOutputTextures', - value: function _setupSubOutputTextures(length) { - var gl = this._webGl; - var texSize = this.texSize; - var drawBuffersMap = this.drawBuffersMap = [gl.COLOR_ATTACHMENT0]; - var textures = this.subKernelOutputTextures = []; - for (var i = 0; i < length; i++) { - var texture = this._webGl.createTexture(); - textures.push(texture); - drawBuffersMap.push(gl.COLOR_ATTACHMENT0 + i + 1); - gl.activeTexture(gl.TEXTURE0 + this.paramNames.length + i); - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - if (this.floatOutput) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null); - } else { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - } - } + key: 'getArgumentTexture', + value: function getArgumentTexture(name) { + return this.getTextureCache('ARGUMENT_' + name); } /** * @memberOf WebGLKernel# + * @name getSubKernelTexture * @function - * @name getArgumentTexture * - * @desc This uses *getTextureCache** to get the Texture Cache of the argument supplied + * @desc This uses *getTextureCache* to get the Texture Cache of the sub-kernel * - * @param {String} name - Name of the argument + * @param {String} name - Name of the subKernel * - * Texture cache for the supplied argument + * @returns {Object} Texture cache for the subKernel * */ }, { - key: 'getArgumentTexture', - value: function getArgumentTexture(name) { - return this.getTextureCache('ARGUMENT_' + name); + key: 'getSubKernelTexture', + value: function getSubKernelTexture(name) { + return this.getTextureCache('SUB_KERNEL_' + name); } /** @@ -15653,6 +15754,10 @@ module.exports = function (_KernelBase) { }, { key: 'getTextureCache', value: function getTextureCache(name) { + if (this.outputToTexture) { + // Don't retain a handle on the output texture, we might need to render on the same texture later + return this._webGl.createTexture(); + } if (this.textureCache.hasOwnProperty(name)) { return this.textureCache[name]; } @@ -15687,10 +15792,12 @@ module.exports = function (_KernelBase) { }, { key: 'getUniformLocation', value: function getUniformLocation(name) { - if (this.programUniformLocationCache.hasOwnProperty(name)) { - return this.programUniformLocationCache[name]; + var location = this.programUniformLocationCache[name]; + if (!location) { + location = this._webGl.getUniformLocation(this.program, name); + this.programUniformLocationCache[name] = location; } - return this.programUniformLocationCache[name] = this._webGl.getUniformLocation(this.program, name); + return location; } /** @@ -15774,7 +15881,7 @@ module.exports = function (_KernelBase) { var buffer = void 0; if (this.floatTextures) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, size[0], size[1], 0, gl.RGBA, gl.FLOAT, valuesFlat); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0], size[1], 0, gl.RGBA, gl.FLOAT, valuesFlat); } else { buffer = new Uint8Array(valuesFlat.buffer); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size[0], size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, buffer); @@ -15823,7 +15930,7 @@ module.exports = function (_KernelBase) { } if (this.floatTextures) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, _size[0], _size[1], 0, gl.RGBA, gl.FLOAT, inputArray); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size[0], _size[1], 0, gl.RGBA, gl.FLOAT, inputArray); } else { var _buffer = new Uint8Array(inputArray.buffer); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, _size[0], _size[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, _buffer); @@ -15843,9 +15950,14 @@ module.exports = function (_KernelBase) { case 'Texture': { var inputTexture = value; - var _dim2 = inputTexture.dimensions; + var _dim2 = utils.getDimensions(inputTexture, true); + var _size2 = inputTexture.size; + if (inputTexture.texture === this.outputTexture) { + this.setupOutputTexture(); + } + gl.activeTexture(gl.TEXTURE0 + this.argumentsLength); gl.bindTexture(gl.TEXTURE_2D, inputTexture.texture); @@ -15879,7 +15991,9 @@ module.exports = function (_KernelBase) { }, { key: '_getHeaderString', value: function _getHeaderString() { - return ''; + return this.subKernels !== null || this.subKernelProperties !== null ? + //webgl2 '#version 300 es\n' : + '#extension GL_EXT_draw_buffers : require\n' : ''; } /** @@ -15943,7 +16057,7 @@ module.exports = function (_KernelBase) { value: function _getTextureCoordinate() { var names = this.subKernelOutputVariableNames; if (names === null || names.length < 1) { - return 'in highp vec2 vTexCoord;\n'; + return 'varying highp vec2 vTexCoord;\n'; } else { return 'out highp vec2 vTexCoord;\n'; } @@ -16136,12 +16250,20 @@ module.exports = function (_KernelBase) { var names = this.subKernelOutputVariableNames; if (names !== null) { result.push('highp float kernelResult = 0.0'); - result.push('layout(location = 0) out highp vec4 data0'); for (var i = 0; i < names.length; i++) { - result.push('highp float ' + names[i] + ' = 0.0', 'layout(location = ' + (i + 1) + ') out highp vec4 data' + (i + 1)); + result.push('highp float ' + names[i] + ' = 0.0'); } + + /* this is v2 prep + result.push('highp float kernelResult = 0.0'); + result.push('layout(location = 0) out highp float fradData0 = 0.0'); + for (let i = 0; i < names.length; i++) { + result.push( + `highp float ${ names[i] } = 0.0`, + `layout(location = ${ i + 1 }) out highp float fragData${ i + 1 } = 0.0` + ); + }*/ } else { - result.push('out highp vec4 data0'); result.push('highp float kernelResult = 0.0'); } @@ -16171,7 +16293,7 @@ module.exports = function (_KernelBase) { } if (this.graphical) { - result.push(' threadId = indexTo3D(index, uOutputDim)', ' kernel()', ' data0 = actualColor'); + result.push(' threadId = indexTo3D(index, uOutputDim)', ' kernel()', ' gl_FragColor = actualColor'); } else if (this.floatOutput) { var channels = ['r', 'g', 'b', 'a']; @@ -16180,13 +16302,13 @@ module.exports = function (_KernelBase) { result.push(' kernel()'); if (names) { - result.push(' data0.' + channels[i] + ' = kernelResult'); + result.push(' gl_FragData[0].' + channels[i] + ' = kernelResult'); for (var j = 0; j < names.length; ++j) { - result.push(' data' + (j + 1) + '.' + channels[i] + ' = ' + names[j]); + result.push(' gl_FragData[' + (j + 1) + '].' + channels[i] + ' = ' + names[j]); } } else { - result.push(' data0.' + channels[i] + ' = kernelResult'); + result.push(' gl_FragColor.' + channels[i] + ' = kernelResult'); } if (i < channels.length - 1) { @@ -16196,12 +16318,12 @@ module.exports = function (_KernelBase) { } else if (names !== null) { result.push(' threadId = indexTo3D(index, uOutputDim)'); result.push(' kernel()'); - result.push(' data0 = encode32(kernelResult)'); + result.push(' gl_FragData[0] = encode32(kernelResult)'); for (var _i3 = 0; _i3 < names.length; _i3++) { - result.push(' data' + (_i3 + 1) + ' = encode32(' + names[_i3] + ')'); + result.push(' gl_FragData[' + (_i3 + 1) + '] = encode32(' + names[_i3] + ')'); } } else { - result.push(' threadId = indexTo3D(index, uOutputDim)', ' kernel()', ' data0 = encode32(kernelResult)'); + result.push(' threadId = indexTo3D(index, uOutputDim)', ' kernel()', ' gl_FragColor = encode32(kernelResult)'); } return this._linesToString(result); @@ -16261,8 +16383,6 @@ module.exports = function (_KernelBase) { }, { key: '_addKernels', value: function _addKernels() { - var _this2 = this; - var builder = this.functionBuilder; var gl = this._webGl; @@ -16281,31 +16401,44 @@ module.exports = function (_KernelBase) { }, this.paramNames, this.paramTypes); if (this.subKernels !== null) { + var ext = this.ext = gl.getExtension('WEBGL_draw_buffers'); + if (!ext) throw new Error('could not instantiate draw buffers extension'); this.subKernelOutputTextures = []; this.subKernelOutputVariableNames = []; - this.subKernels.forEach(function (subKernel) { - return _this2._addSubKernel(subKernel); - }); + for (var i = 0; i < this.subKernels.length; i++) { + var subKernel = this.subKernels[i]; + builder.addSubKernel(subKernel, { + prototypeOnly: false, + constants: this.constants, + output: this.output, + debug: this.debug, + loopMaxIterations: this.loopMaxIterations + }); + this.subKernelOutputTextures.push(this.getSubKernelTexture(i)); + this.subKernelOutputVariableNames.push(subKernel.name + 'Result'); + } } else if (this.subKernelProperties !== null) { + var _ext = this.ext = gl.getExtension('WEBGL_draw_buffers'); + if (!_ext) throw new Error('could not instantiate draw buffers extension'); this.subKernelOutputTextures = []; this.subKernelOutputVariableNames = []; - Object.keys(this.subKernelProperties).forEach(function (property) { - return _this2._addSubKernel(_this2.subKernelProperties[property]); - }); + var _i4 = 0; + for (var p in this.subKernelProperties) { + if (!this.subKernelProperties.hasOwnProperty(p)) continue; + var _subKernel = this.subKernelProperties[p]; + builder.addSubKernel(_subKernel, { + prototypeOnly: false, + constants: this.constants, + output: this.output, + debug: this.debug, + loopMaxIterations: this.loopMaxIterations + }); + this.subKernelOutputTextures.push(this.getSubKernelTexture(p)); + this.subKernelOutputVariableNames.push(_subKernel.name + 'Result'); + _i4++; + } } } - }, { - key: '_addSubKernel', - value: function _addSubKernel(subKernel) { - this.functionBuilder.addSubKernel(subKernel, { - prototypeOnly: false, - constants: this.constants, - output: this.output, - debug: this.debug, - loopMaxIterations: this.loopMaxIterations - }); - this.subKernelOutputVariableNames.push(subKernel.name + 'Result'); - } /** * @memberOf WebGLKernel# @@ -16439,11 +16572,11 @@ module.exports = function (_RunnerBase) { },{"../../core/utils":75,"../runner-base":60,"./function-builder":61,"./kernel":64}],66:[function(require,module,exports){ "use strict"; -module.exports = "#version 300 es\n__HEADER__;\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nconst float LOOP_MAX = __LOOP_MAX__;\n#define EPSILON 0.0000001;\n\n__CONSTANTS__;\n\nin highp vec2 vTexCoord;\n\nvec2 integerMod(vec2 x, float y) {\n vec2 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec3 integerMod(vec3 x, float y) {\n vec3 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec4 integerMod(vec4 x, vec4 y) {\n vec4 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nhighp float integerMod(highp float x, highp float y) {\n highp float res = floor(mod(x, y));\n return res * (res > floor(y) - 1.0 ? 0.0 : 1.0);\n}\n\nhighp int integerMod(highp int x, highp int y) {\n return int(integerMod(float(x), float(y)));\n}\n\n// Here be dragons!\n// DO NOT OPTIMIZE THIS CODE\n// YOU WILL BREAK SOMETHING ON SOMEBODY'S MACHINE\n// LEAVE IT AS IT IS, LEST YOU WASTE YOUR OWN TIME\nconst vec2 MAGIC_VEC = vec2(1.0, -256.0);\nconst vec4 SCALE_FACTOR = vec4(1.0, 256.0, 65536.0, 0.0);\nconst vec4 SCALE_FACTOR_INV = vec4(1.0, 0.00390625, 0.0000152587890625, 0.0); // 1, 1/256, 1/65536\nhighp float decode32(highp vec4 rgba) {\n __DECODE32_ENDIANNESS__;\n rgba *= 255.0;\n vec2 gte128;\n gte128.x = rgba.b >= 128.0 ? 1.0 : 0.0;\n gte128.y = rgba.a >= 128.0 ? 1.0 : 0.0;\n float exponent = 2.0 * rgba.a - 127.0 + dot(gte128, MAGIC_VEC);\n float res = exp2(round(exponent));\n rgba.b = rgba.b - 128.0 * gte128.x;\n res = dot(rgba, SCALE_FACTOR) * exp2(round(exponent-23.0)) + res;\n res *= gte128.y * -2.0 + 1.0;\n return res;\n}\n\nhighp vec4 encode32(highp float f) {\n highp float F = abs(f);\n highp float sign = f < 0.0 ? 1.0 : 0.0;\n highp float exponent = floor(log2(F));\n highp float mantissa = (exp2(-exponent) * F);\n // exponent += floor(log2(mantissa));\n vec4 rgba = vec4(F * exp2(23.0-exponent)) * SCALE_FACTOR_INV;\n rgba.rg = integerMod(rgba.rg, 256.0);\n rgba.b = integerMod(rgba.b, 128.0);\n rgba.a = exponent*0.5 + 63.5;\n rgba.ba += vec2(integerMod(exponent+127.0, 2.0), sign) * 128.0;\n rgba = floor(rgba);\n rgba *= 0.003921569; // 1/255\n __ENCODE32_ENDIANNESS__;\n return rgba;\n}\n// Dragons end here\n\nhighp float index;\nhighp vec3 threadId;\n\nhighp vec3 indexTo3D(highp float idx, highp vec3 texDim) {\n highp float z = floor(idx / (texDim.x * texDim.y));\n idx -= z * texDim.x * texDim.y;\n highp float y = floor(idx / texDim.x);\n highp float x = integerMod(idx, texDim.x);\n return vec3(x, y, z);\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float z, highp float y, highp float x) {\n highp vec3 xyz = vec3(x, y, z);\n xyz = floor(xyz + 0.5);\n __GET_WRAPAROUND__;\n highp float index = round(xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z));\n __GET_TEXTURE_CHANNEL__;\n highp float w = round(texSize.x);\n vec2 st = vec2(integerMod(index, w), float(int(index) / int(w))) + 0.5;\n __GET_TEXTURE_INDEX__;\n highp vec4 texel = texture(tex, st / texSize);\n __GET_RESULT__;\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float y, highp float x) {\n return get(tex, texSize, texDim, 0.0, y, x);\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float x) {\n return get(tex, texSize, texDim, 0.0, 0.0, x);\n}\n\nhighp vec4 actualColor;\nvoid color(float r, float g, float b, float a) {\n actualColor = vec4(r,g,b,a);\n}\n\nvoid color(float r, float g, float b) {\n color(r,g,b,1.0);\n}\n\n__MAIN_PARAMS__;\n__MAIN_CONSTANTS__;\n__KERNEL__;\n\nvoid main(void) {\n index = floor(vTexCoord.s * float(uTexSize.x)) + floor(vTexCoord.t * float(uTexSize.y)) * uTexSize.x;\n __MAIN_RESULT__;\n}"; +module.exports = "__HEADER__;\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nconst float LOOP_MAX = __LOOP_MAX__;\n#define EPSILON 0.0000001;\n\n__CONSTANTS__;\n\nvarying highp vec2 vTexCoord;\n\nvec4 round(vec4 x) {\n return floor(x + 0.5);\n}\n\nhighp float round(highp float x) {\n return floor(x + 0.5);\n}\n\nvec2 integerMod(vec2 x, float y) {\n vec2 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec3 integerMod(vec3 x, float y) {\n vec3 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nvec4 integerMod(vec4 x, vec4 y) {\n vec4 res = floor(mod(x, y));\n return res * step(1.0 - floor(y), -res);\n}\n\nhighp float integerMod(highp float x, highp float y) {\n highp float res = floor(mod(x, y));\n return res * (res > floor(y) - 1.0 ? 0.0 : 1.0);\n}\n\nhighp int integerMod(highp int x, highp int y) {\n return int(integerMod(float(x), float(y)));\n}\n\n// Here be dragons!\n// DO NOT OPTIMIZE THIS CODE\n// YOU WILL BREAK SOMETHING ON SOMEBODY'S MACHINE\n// LEAVE IT AS IT IS, LEST YOU WASTE YOUR OWN TIME\nconst vec2 MAGIC_VEC = vec2(1.0, -256.0);\nconst vec4 SCALE_FACTOR = vec4(1.0, 256.0, 65536.0, 0.0);\nconst vec4 SCALE_FACTOR_INV = vec4(1.0, 0.00390625, 0.0000152587890625, 0.0); // 1, 1/256, 1/65536\nhighp float decode32(highp vec4 rgba) {\n __DECODE32_ENDIANNESS__;\n rgba *= 255.0;\n vec2 gte128;\n gte128.x = rgba.b >= 128.0 ? 1.0 : 0.0;\n gte128.y = rgba.a >= 128.0 ? 1.0 : 0.0;\n float exponent = 2.0 * rgba.a - 127.0 + dot(gte128, MAGIC_VEC);\n float res = exp2(round(exponent));\n rgba.b = rgba.b - 128.0 * gte128.x;\n res = dot(rgba, SCALE_FACTOR) * exp2(round(exponent-23.0)) + res;\n res *= gte128.y * -2.0 + 1.0;\n return res;\n}\n\nhighp vec4 encode32(highp float f) {\n highp float F = abs(f);\n highp float sign = f < 0.0 ? 1.0 : 0.0;\n highp float exponent = floor(log2(F));\n highp float mantissa = (exp2(-exponent) * F);\n // exponent += floor(log2(mantissa));\n vec4 rgba = vec4(F * exp2(23.0-exponent)) * SCALE_FACTOR_INV;\n rgba.rg = integerMod(rgba.rg, 256.0);\n rgba.b = integerMod(rgba.b, 128.0);\n rgba.a = exponent*0.5 + 63.5;\n rgba.ba += vec2(integerMod(exponent+127.0, 2.0), sign) * 128.0;\n rgba = floor(rgba);\n rgba *= 0.003921569; // 1/255\n __ENCODE32_ENDIANNESS__;\n return rgba;\n}\n// Dragons end here\n\nhighp float index;\nhighp vec3 threadId;\n\nhighp vec3 indexTo3D(highp float idx, highp vec3 texDim) {\n highp float z = floor(idx / (texDim.x * texDim.y));\n idx -= z * texDim.x * texDim.y;\n highp float y = floor(idx / texDim.x);\n highp float x = integerMod(idx, texDim.x);\n return vec3(x, y, z);\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float z, highp float y, highp float x) {\n highp vec3 xyz = vec3(x, y, z);\n xyz = floor(xyz + 0.5);\n __GET_WRAPAROUND__;\n highp float index = round(xyz.x + texDim.x * (xyz.y + texDim.y * xyz.z));\n __GET_TEXTURE_CHANNEL__;\n highp float w = round(texSize.x);\n vec2 st = vec2(integerMod(index, w), float(int(index) / int(w))) + 0.5;\n __GET_TEXTURE_INDEX__;\n highp vec4 texel = texture2D(tex, st / texSize);\n __GET_RESULT__;\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float y, highp float x) {\n return get(tex, texSize, texDim, 0.0, y, x);\n}\n\nhighp float get(highp sampler2D tex, highp vec2 texSize, highp vec3 texDim, highp float x) {\n return get(tex, texSize, texDim, 0.0, 0.0, x);\n}\n\nhighp vec4 actualColor;\nvoid color(float r, float g, float b, float a) {\n actualColor = vec4(r,g,b,a);\n}\n\nvoid color(float r, float g, float b) {\n color(r,g,b,1.0);\n}\n\n__MAIN_PARAMS__;\n__MAIN_CONSTANTS__;\n__KERNEL__;\n\nvoid main(void) {\n index = floor(vTexCoord.s * float(uTexSize.x)) + floor(vTexCoord.t * float(uTexSize.y)) * uTexSize.x;\n __MAIN_RESULT__;\n}"; },{}],67:[function(require,module,exports){ "use strict"; -module.exports = "#version 300 es\nprecision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nin highp vec2 aPos;\nin highp vec2 aTexCoord;\n\nout highp vec2 vTexCoord;\nuniform vec2 ratio;\n\nvoid main(void) {\n gl_Position = vec4((aPos + vec2(1)) * ratio + vec2(-1), 0, 1);\n vTexCoord = aTexCoord;\n}"; +module.exports = "precision highp float;\nprecision highp int;\nprecision highp sampler2D;\n\nattribute highp vec2 aPos;\nattribute highp vec2 aTexCoord;\n\nvarying highp vec2 vTexCoord;\nuniform vec2 ratio;\n\nvoid main(void) {\n gl_Position = vec4((aPos + vec2(1)) * ratio + vec2(-1), 0, 1);\n vTexCoord = aTexCoord;\n}"; },{}],68:[function(require,module,exports){ 'use strict'; @@ -16484,7 +16617,6 @@ module.exports = function (_WebGLKernel) { * */ value: function validateOptions() { - this._webGl.getExtension('EXT_color_buffer_float'); this.texSize = utils.dimToTexSize({ floatTextures: this.floatTextures, floatOutput: this.floatOutput @@ -17045,18 +17177,16 @@ module.exports = function () { /** * @desc WebGl Texture implementation in JS * @constructor Texture - * @param {Object} texture - * @param {Array} size - * @param dimensions + * @param {Object} texture + * @param {Array} size * @param {Array} output * @param {Object} webGl */ - function Texture(texture, size, dimensions, output, webGl) { + function Texture(texture, size, output, webGl) { _classCallCheck(this, Texture); this.texture = texture; this.size = size; - this.dimensions = dimensions; this.output = output; this.webGl = webGl; this.kernel = null; @@ -17314,7 +17444,17 @@ var UtilsCore = function () { } // Create a new canvas DOM - return canvasObj.getContext('webgl2', UtilsCore.initWebGlDefaultOptions()); + var webGl = canvasObj.getContext('experimental-webgl', UtilsCore.initWebGlDefaultOptions()) || canvasObj.getContext('webgl', UtilsCore.initWebGlDefaultOptions()); + + if (webGl) { + // Get the extension that is needed + webGl.OES_texture_float = webGl.getExtension('OES_texture_float'); + webGl.OES_texture_float_linear = webGl.getExtension('OES_texture_float_linear'); + webGl.OES_element_index_uint = webGl.getExtension('OES_element_index_uint'); + } + + // Returns the canvas + return webGl; } }]); @@ -17330,7 +17470,17 @@ var UtilsCore = function () { var _isCanvasSupported = typeof document !== 'undefined' ? UtilsCore.isCanvas(document.createElement('canvas')) : false; var _testingWebGl = UtilsCore.initWebGl(UtilsCore.initCanvas()); var _isWebGlSupported = UtilsCore.isWebGl(_testingWebGl); -var _isWebGlDrawBuffersSupported = _isWebGlSupported; +var _isWebGlDrawBuffersSupported = _isWebGlSupported && Boolean(_testingWebGl.getExtension('WEBGL_draw_buffers')); + +if (_isWebGlSupported) { + UtilsCore.OES_texture_float = _testingWebGl.OES_texture_float; + UtilsCore.OES_texture_float_linear = _testingWebGl.OES_texture_float_linear; + UtilsCore.OES_element_index_uint = _testingWebGl.OES_element_index_uint; +} else { + UtilsCore.OES_texture_float = false; + UtilsCore.OES_texture_float_linear = false; + UtilsCore.OES_element_index_uint = false; +} module.exports = UtilsCore; },{}],75:[function(require,module,exports){ @@ -18132,9 +18282,9 @@ module.exports = Array.isArray || function (arr) { if (!process.version || process.version.indexOf('v0.') === 0 || process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { - module.exports = nextTick; + module.exports = { nextTick: nextTick }; } else { - module.exports = process.nextTick; + module.exports = process } function nextTick(fn, arg1, arg2, arg3) { @@ -18171,6 +18321,7 @@ function nextTick(fn, arg1, arg2, arg3) { } } + }).call(this,require('_process')) },{"_process":82}],82:[function(require,module,exports){ // shim for using process in browser @@ -18392,7 +18543,7 @@ module.exports = require('./lib/_stream_duplex.js'); /**/ -var processNextTick = require('process-nextick-args'); +var processNextTick = require('process-nextick-args').nextTick; /**/ /**/ @@ -18561,7 +18712,7 @@ PassThrough.prototype._transform = function (chunk, encoding, cb) { /**/ -var processNextTick = require('process-nextick-args'); +var processNextTick = require('process-nextick-args').nextTick; /**/ module.exports = Readable; @@ -18588,9 +18739,8 @@ var EElistenerCount = function (emitter, type) { var Stream = require('./internal/streams/stream'); /**/ -// TODO(bmeurer): Change this back to const once hole checks are -// properly optimized away early in Ignition+TurboFan. /**/ + var Buffer = require('safe-buffer').Buffer; var OurUint8Array = global.Uint8Array || function () {}; function _uint8ArrayToBuffer(chunk) { @@ -18599,6 +18749,7 @@ function _uint8ArrayToBuffer(chunk) { function _isUint8Array(obj) { return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } + /**/ /**/ @@ -18627,15 +18778,13 @@ 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); - } else { - // This is a hack to make sure that our error handler is attached before any - // userland ones. NEVER DO THIS. This is here only because this code needs - // to continue to work with older versions of Node.js that do not include - // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; - } + 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 (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; } function ReadableState(options, stream) { @@ -18643,17 +18792,26 @@ function ReadableState(options, stream) { 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. + var 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 (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + 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" var hwm = options.highWaterMark; + var readableHwm = options.readableHighWaterMark; var defaultHwm = this.objectMode ? 16 : 16 * 1024; - this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; // cast to ints. this.highWaterMark = Math.floor(this.highWaterMark); @@ -19348,18 +19506,19 @@ function flow(stream) { // 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; - var self = this; stream.on('end', function () { debug('wrapped end'); if (state.decoder && !state.ended) { var chunk = state.decoder.end(); - if (chunk && chunk.length) self.push(chunk); + if (chunk && chunk.length) _this.push(chunk); } - self.push(null); + _this.push(null); }); stream.on('data', function (chunk) { @@ -19369,7 +19528,7 @@ Readable.prototype.wrap = function (stream) { // don't skip over falsy values in objectMode if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; - var ret = self.push(chunk); + var ret = _this.push(chunk); if (!ret) { paused = true; stream.pause(); @@ -19390,12 +19549,12 @@ Readable.prototype.wrap = function (stream) { // proxy certain important events. for (var n = 0; n < kProxyEvents.length; n++) { - stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n])); + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); } // when we try to consume some more bytes, simply unpause the // underlying stream. - self._read = function (n) { + this._read = function (n) { debug('wrapped _read', n); if (paused) { paused = false; @@ -19403,7 +19562,7 @@ Readable.prototype.wrap = function (stream) { } }; - return self; + return this; }; // exposed for testing purposes only. @@ -19621,39 +19780,28 @@ util.inherits = require('inherits'); util.inherits(Transform, Duplex); -function TransformState(stream) { - this.afterTransform = function (er, data) { - return afterTransform(stream, er, data); - }; - - this.needTransform = false; - this.transforming = false; - this.writecb = null; - this.writechunk = null; - this.writeencoding = null; -} - -function afterTransform(stream, er, data) { - var ts = stream._transformState; +function afterTransform(er, data) { + var ts = this._transformState; ts.transforming = false; var cb = ts.writecb; if (!cb) { - return stream.emit('error', new Error('write callback called multiple times')); + return this.emit('error', new Error('write callback called multiple times')); } ts.writechunk = null; ts.writecb = null; - if (data !== null && data !== undefined) stream.push(data); + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); cb(er); - var rs = stream._readableState; + var rs = this._readableState; rs.reading = false; if (rs.needReadable || rs.length < rs.highWaterMark) { - stream._read(rs.highWaterMark); + this._read(rs.highWaterMark); } } @@ -19662,9 +19810,14 @@ function Transform(options) { Duplex.call(this, options); - this._transformState = new TransformState(this); - - var stream = this; + 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; @@ -19681,11 +19834,19 @@ function Transform(options) { } // When the writable side finishes, then flush out anything remaining. - this.once('prefinish', function () { - if (typeof this._flush === 'function') this._flush(function (er, data) { - done(stream, er, data); - });else done(stream); - }); + this.on('prefinish', prefinish); +} + +function prefinish() { + var _this = this; + + if (typeof this._flush === 'function') { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } } Transform.prototype.push = function (chunk, encoding) { @@ -19735,27 +19896,25 @@ Transform.prototype._read = function (n) { }; Transform.prototype._destroy = function (err, cb) { - var _this = this; + var _this2 = this; Duplex.prototype._destroy.call(this, err, function (err2) { cb(err2); - _this.emit('close'); + _this2.emit('close'); }); }; function done(stream, er, data) { if (er) return stream.emit('error', er); - if (data !== null && data !== undefined) stream.push(data); + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); // if there's nothing in the write buffer, then that means // that nothing more will ever be provided - var ws = stream._writableState; - var ts = stream._transformState; - - if (ws.length) throw new Error('Calling transform done when ws.length != 0'); + if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); - if (ts.transforming) throw new Error('Calling transform done when still transforming'); + if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); return stream.push(null); } @@ -19790,7 +19949,7 @@ function done(stream, er, data) { /**/ -var processNextTick = require('process-nextick-args'); +var processNextTick = require('process-nextick-args').nextTick; /**/ module.exports = Writable; @@ -19842,6 +20001,7 @@ var Stream = require('./internal/streams/stream'); /**/ /**/ + var Buffer = require('safe-buffer').Buffer; var OurUint8Array = global.Uint8Array || function () {}; function _uint8ArrayToBuffer(chunk) { @@ -19850,6 +20010,7 @@ function _uint8ArrayToBuffer(chunk) { function _isUint8Array(obj) { return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; } + /**/ var destroyImpl = require('./internal/streams/destroy'); @@ -19863,18 +20024,27 @@ function WritableState(options, stream) { 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. + var isDuplex = stream instanceof Duplex; + // object stream flag to indicate whether or not this stream // contains buffers or objects. this.objectMode = !!options.objectMode; - if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + 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() var hwm = options.highWaterMark; + var writableHwm = options.writableHighWaterMark; var defaultHwm = this.objectMode ? 16 : 16 * 1024; - this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; // cast to ints. this.highWaterMark = Math.floor(this.highWaterMark); @@ -19988,6 +20158,7 @@ if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.protot Object.defineProperty(Writable, Symbol.hasInstance, { value: function (object) { if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; return object && object._writableState instanceof WritableState; } @@ -20065,7 +20236,7 @@ function validChunk(stream, state, chunk, cb) { Writable.prototype.write = function (chunk, encoding, cb) { var state = this._writableState; var ret = false; - var isBuf = _isUint8Array(chunk) && !state.objectMode; + var isBuf = !state.objectMode && _isUint8Array(chunk); if (isBuf && !Buffer.isBuffer(chunk)) { chunk = _uint8ArrayToBuffer(chunk); @@ -20277,6 +20448,7 @@ function clearBuffer(stream, state) { } else { state.corkedRequestsFree = new CorkedRequest(state); } + state.bufferedRequestCount = 0; } else { // Slow case, write chunks one-by-one while (entry) { @@ -20287,6 +20459,7 @@ function clearBuffer(stream, state) { 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 @@ -20299,7 +20472,6 @@ function clearBuffer(stream, state) { if (entry === null) state.lastBufferedRequest = null; } - state.bufferedRequestCount = 0; state.bufferedRequest = entry; state.bufferProcessing = false; } @@ -20429,12 +20601,10 @@ Writable.prototype._destroy = function (err, cb) { },{"./_stream_duplex":84,"./internal/streams/destroy":90,"./internal/streams/stream":91,"_process":82,"core-util-is":49,"inherits":78,"process-nextick-args":81,"safe-buffer":97,"util-deprecate":102}],89:[function(require,module,exports){ 'use strict'; -/**/ - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Buffer = require('safe-buffer').Buffer; -/**/ +var util = require('util'); function copyBuffer(src, target, offset) { src.copy(target, offset); @@ -20501,12 +20671,19 @@ module.exports = function () { return BufferList; }(); -},{"safe-buffer":97}],90:[function(require,module,exports){ + +if (util && util.inspect && util.inspect.custom) { + module.exports.prototype[util.inspect.custom] = function () { + var obj = util.inspect({ length: this.length }); + return this.constructor.name + ' ' + obj; + }; +} +},{"safe-buffer":97,"util":47}],90:[function(require,module,exports){ 'use strict'; /**/ -var processNextTick = require('process-nextick-args'); +var processNextTick = require('process-nextick-args').nextTick; /**/ // undocumented cb() API, needed for core, not for public API @@ -20522,7 +20699,7 @@ function destroy(err, cb) { } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { processNextTick(emitErrorNT, this, err); } - return; + return this; } // we set destroyed to true before firing error callbacks in order @@ -20547,6 +20724,8 @@ function destroy(err, cb) { cb(err); } }); + + return this; } function undestroy() { diff --git a/browser.min.js b/browser.min.js index ffc07ec50..7e7d4a3db 100644 --- a/browser.min.js +++ b/browser.min.js @@ -6,19 +6,19 @@ * license: MIT (http://opensource.org/licenses/MIT) * author: Heather Arthur * homepage: https://github.com/brainjs/brain.js#readme - * version: 1.1.0 + * version: 1.1.2 * * acorn: * license: MIT (http://opensource.org/licenses/MIT) * maintainers: Marijn Haverbeke , Ingvar Stepanyan * homepage: https://github.com/acornjs/acorn - * version: 5.3.0 + * version: 5.4.1 * * base64-js: * license: MIT (http://opensource.org/licenses/MIT) * author: T. Jameson Little * homepage: https://github.com/beatgammit/base64-js - * version: 1.2.1 + * version: 1.2.3 * * buffer: * license: MIT (http://opensource.org/licenses/MIT) @@ -41,7 +41,7 @@ * license: MIT (http://opensource.org/licenses/MIT) * author: The gpu.js Team * homepage: http://gpu.rocks/ - * version: 1.2.0 + * version: 1.0.0 * * ieee754: * license: BSD-3-Clause (http://opensource.org/licenses/BSD-3-Clause) @@ -67,11 +67,11 @@ * process-nextick-args: * license: MIT (http://opensource.org/licenses/MIT) * homepage: https://github.com/calvinmetcalf/process-nextick-args - * version: 1.0.7 + * version: 2.0.0 * * readable-stream: * license: MIT (http://opensource.org/licenses/MIT) - * version: 2.3.3 + * version: 2.3.4 * * safe-buffer: * license: MIT (http://opensource.org/licenses/MIT) @@ -104,7 +104,7 @@ * * This header is generated by licensify (https://github.com/twada/licensify) */ -(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.brain = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o0;e--){var r=Math.floor(Math.random()*(e+1)),s=t[e];t[e]=t[r],t[r]=s}return t}function crossValidate(t,e,r,s,a){a=a||4;var i=e.length/a;if(e.constructor===Array)shuffleArray(e);else{var o={};shuffleArray(Object.keys(e)).forEach(function(t){o[t]=e[t]}),e=o}for(var n={error:0,trainTime:0,testTime:0,iterations:0,trainError:0},l={truePos:0,trueNeg:0,falsePos:0,falseNeg:0,total:0},f=[],u=[],c=void 0,h=void 0,P=0;Pu&&(t=n,u=i)}return t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=likely; @@ -116,7 +116,7 @@ "use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _toConsumableArray(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e0?t:0}function calcDeltasLeakyRelu(t,e){return e>0?t:.01*t}function calcDeltasTanh(t,e){return(1-e*e)*t}function calcError(t,e){for(var r=0,a=0;a0&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,e);var r=_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return r.forwardPropagate=[],r.backwardPropagate=[],r.changesPropagate=[],r.biasesPropagate=[],r.gpu=new _gpu2.default({mode:t.mode}),r}return _inherits(e,t),_createClass(e,[{key:"_initialize",value:function(t){_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"_initialize",this).call(this,t),this.buildRunInput(),this.buildCalculateDeltas(),this.buildGetChanges(),this.buildChangeBiases(),this.buildGetMSE()}},{key:"setActivation",value:function(){}},{key:"_trainPattern",value:function(t,e,r){return r=r||this.trainOpts.learningRate,this.runInput(t),this.calculateDeltas(e),this.getChanges(r),this.changeBiases(r),this.getMSE(this.errors[this.outputLayer])[0]}},{key:"buildRunInput",value:function(){var t=null;switch(this.activation){case"sigmoid":t=weightedSumSigmoid;break;case"relu":t=weightedSumRelu;break;case"leaky-relu":t=weightedSumLeakyRelu;break;case"tanh":t=weightedSumTanh;break;default:throw new Error("unknown activation "+this.activation)}for(var e=1;e<=this.outputLayer;e++)this.forwardPropagate[e]=this.gpu.createKernel(t,{output:[this.sizes[e]],outputToTexture:!0,constants:{size:this.sizes[e-1]}})}},{key:"runInput",value:function(t){var e=void 0;this.outputs[0]=t;for(var r=1;r<=this.outputLayer;r++)this.outputs[r]=this.forwardPropagate[r](this.weights[r],this.biases[r],t),e=t=this.outputs[r];return e}},{key:"buildCalculateDeltas",value:function(){var t=null;switch(this.activation){case"sigmoid":t=calcDeltasSigmoid;break;case"relu":t=calcDeltasRelu;break;case"leaky-relu":t=calcDeltasLeakyRelu;break;case"tanh":t=calcDeltasTanh;break;default:throw new Error("unknown activation "+this.activation)}for(var e=this.outputLayer;e>0;e--)e===this.outputLayer?this.backwardPropagate[e]=this.gpu.createKernelMap({error:_gpu2.default.alias("calcErrorOutput",calcErrorOutput),deltas:_gpu2.default.alias("calcDeltas",t)},function(e,r){var a=e[this.thread.x];return t(calcErrorOutput(a,r),a)},{output:[this.sizes[e]],outputToTexture:!0}):this.backwardPropagate[e]=this.gpu.createKernelMap({error:_gpu2.default.alias("calcError",calcError),deltas:_gpu2.default.alias("calcDeltas",t)},function(e,r,a){var u=r[this.thread.x];return t(calcError(e,a),u)},{output:[this.sizes[e]],outputToTexture:!0,constants:{size:this.deltas[e+1].length}})}},{key:"calculateDeltas",value:function(t,e){for(var r=this.outputLayer;r>0;r--){var a=void 0;a=r===this.outputLayer?this.backwardPropagate[r](this.outputs[r],t):this.backwardPropagate[r](this.weights[r+1],this.outputs[r],this.deltas[r+1]),this.deltas[r]=a.deltas,this.errors[r]=a.error}}},{key:"buildGetChanges",value:function(){for(var t=1;t<=this.outputLayer;t++)this.changesPropagate[t]=this.gpu.createKernelMap({weights:_gpu2.default.alias("addWeights",addWeights),changes:_gpu2.default.alias("calcChanges",calcChanges)},function(t,e,r,a,u,i){return addWeights(calcChanges(a,e,t,u,i),r)},{output:[this.sizes[t-1],this.sizes[t]],outputToTexture:!0,constants:{size:this.outputs[t-1].length}})}},{key:"getChanges",value:function(t){for(var e=1;e<=this.outputLayer;e++){var r=this.changesPropagate[e](this.outputs[e-1],this.deltas[e],this.weights[e],this.changes[e],t,this.trainOpts.momentum);this.changes[e]=r.changes,this.weights[e]=r.weights}}},{key:"buildChangeBiases",value:function(){for(var t=1;t<=this.outputLayer;t++)this.biasesPropagate[t]=this.gpu.createKernel(addBiases,{output:[this.sizes[t]],outputToTexture:!0})}},{key:"changeBiases",value:function(t){for(var e=1;e<=this.outputLayer;e++)this.biases[e]=this.biasesPropagate[e](this.biases[e],this.deltas[e],t)}},{key:"buildGetMSE",value:function(){this.getMSE=this.gpu.createKernel(mse,{output:[1],constants:{size:this.sizes[this.outputLayer]}})}},{key:"run",value:function(t){if(!this.isRunnable)return null;this.inputLookup&&(t=_lookup2.default.toArray(this.inputLookup,t));var e=[].concat(_toConsumableArray(this.runInput(t).toArray(this.gpu)));return this.outputLookup&&(e=_lookup2.default.toHash(this.outputLookup,e)),e}},{key:"_formatData",value:function(t){var e=this;if(!Array.isArray(t)){var r=[];r.push(t),t=r}var a=t[0].input;return Array.isArray(a)||a instanceof Float32Array||(this.inputLookup||(this.inputLookup=_lookup2.default.buildLookup(t.map(function(t){return t.input}))),t=t.map(function(t){var r=_lookup2.default.toArray(e.inputLookup,t.input);return Object.assign({},t,{input:r})},this)),Array.isArray(t[0].output)||(this.outputLookup||(this.outputLookup=_lookup2.default.buildLookup(t.map(function(t){return t.output}))),t=t.map(function(t){var r=_lookup2.default.toArray(e.outputLookup,t.output);return Object.assign({},t,{output:r})},this)),t}},{key:"toFunction",value:function(){throw new Error("not implemented on NeuralNetworkGPU")}}]),e}(_neuralNetwork2.default);exports.default=NeuralNetworkGPU; },{"./lookup":3,"./neural-network":5,"gpu.js":76}],5:[function(require,module,exports){ -"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _toConsumableArray(t){if(Array.isArray(t)){for(var i=0,e=Array(t.length);i0&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,t),Object.assign(this,this.constructor.defaults,i),this.hiddenSizes=i.hiddenLayers,this.trainOpts={},this._updateTrainingOptions(Object.assign({},this.constructor.trainDefaults,i)),this.sizes=null,this.outputLayer=null,this.biases=null,this.weights=null,this.outputs=null,this.deltas=null,this.changes=null,this.errors=null,this.constructor.prototype.hasOwnProperty("runInput")||(this.runInput=null),this.constructor.prototype.hasOwnProperty("calculateDeltas")||(this.calculateDeltas=null)}return _createClass(t,null,[{key:"_validateTrainingOptions",value:function(i){var e={iterations:function(t){return"number"==typeof t&&t>0},errorThresh:function(t){return"number"==typeof t&&t>0&&t<1},log:function(t){return"function"==typeof t||"boolean"==typeof t},logPeriod:function(t){return"number"==typeof t&&t>0},learningRate:function(t){return"number"==typeof t&&t>0&&t<1},momentum:function(t){return"number"==typeof t&&t>0&&t<1},callback:function(t){return"function"==typeof t||null===t},callbackPeriod:function(t){return"number"==typeof t&&t>0},timeout:function(t){return"number"==typeof t&&t>0}};Object.keys(t.trainDefaults).forEach(function(t){if(e.hasOwnProperty(t)&&!e[t](i[t]))throw new Error("["+t+", "+i[t]+"] is out of normal training range, your network will probably not train.")})}},{key:"trainDefaults",get:function(){return{iterations:2e4,errorThresh:.005,log:!1,logPeriod:10,learningRate:.3,momentum:.1,callback:null,callbackPeriod:10,timeout:1/0}}},{key:"defaults",get:function(){return{binaryThresh:.5,hiddenLayers:[3],activation:"sigmoid"}}}]),_createClass(t,[{key:"_initialize",value:function(){if(!this.sizes)throw new Error("Sizes must be set before initializing");this.outputLayer=this.sizes.length-1,this.biases=[],this.weights=[],this.outputs=[],this.deltas=[],this.changes=[],this.errors=[];for(var t=0;t<=this.outputLayer;t++){var i=this.sizes[t];if(this.deltas[t]=(0,_zeros2.default)(i),this.errors[t]=(0,_zeros2.default)(i),this.outputs[t]=(0,_zeros2.default)(i),t>0){this.biases[t]=(0,_randos2.default)(i),this.weights[t]=new Array(i),this.changes[t]=new Array(i);for(var e=0;e=this.trainOpts.iterations||i.error<=this.trainOpts.errorThresh||Date.now()>=e)&&(i.iterations++,i.error=this._calculateTrainingError(t),this.trainOpts.log&&i.iterations%this.trainOpts.logPeriod==0&&this.trainOpts.log("iterations: "+i.iterations+", training error: "+i.error),this.trainOpts.callback&&i.iterations%this.trainOpts.callbackPeriod==0&&this.trainOpts.callback(Object.assign(i)),!0)}},{key:"_prepTraining",value:function(t,i){this._updateTrainingOptions(i),t=this._formatData(t);var e=Date.now()+this.trainOpts.timeout,r={error:1,iterations:0};return this._verifyIsInitialized(t),{data:t,status:r,endTime:e}}},{key:"train",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=void 0,r=void 0,s=this._prepTraining(t,i);for(t=s.data,e=s.status,r=s.endTime;this._trainingTick(t,e,r););return e}},{key:"trainAsync",value:function(t){var i=this,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=void 0,s=void 0,a=this._prepTraining(t,e);return t=a.data,r=a.status,s=a.endTime,new Promise(function(e,a){try{var n=new _thaw2.default(new Array(i.trainOpts.iterations),{delay:!0,each:function(){return i._trainingTick(t,r,s)||n.stop()},done:function(){return e(r)}});n.tick()}catch(t){a({trainError:t,status:r})}})}},{key:"_trainPattern",value:function(t,i){return this.runInput(t),this.calculateDeltas(i),this._adjustWeights(),(0,_mse2.default)(this.errors[this.outputLayer])}},{key:"_calculateDeltasSigmoid",value:function(t){for(var i=this.outputLayer;i>=0;i--)for(var e=0;e=0;i--)for(var e=0;e0?s:0}}},{key:"_calculateDeltasLeakyRelu",value:function(t){for(var i=this.outputLayer;i>=0;i--)for(var e=0;e0?s:.01*s}}},{key:"_calculateDeltasTanh",value:function(t){for(var i=this.outputLayer;i>=0;i--)for(var e=0;ei.binaryThresh?1:0,f=p[0]):(c=l.indexOf((0,_max2.default)(l)),f=p.indexOf((0,_max2.default)(p))),c!==f){var v=t[h];Object.assign(v,{actual:c,expected:f}),u.push(v)}e&&(0===c&&0===f?n++:1===c&&1===f?a++:0===c&&1===f?s++:1===c&&0===f&&r++);var y=l.map(function(t,i){return p[i]-t});o+=(0,_mse2.default)(y)}(h);var l=o/t.length,p={error:l,misclasses:u};return e&&Object.assign(p,{trueNeg:n,truePos:a,falseNeg:s,falsePos:r,total:t.length,precision:a/(a+r),recall:a/(a+s),accuracy:(n+a)/t.length}),p}},{key:"toJSON",value:function(){for(var t=[],i=0;i<=this.outputLayer;i++){t[i]={};var e=void 0;e=0===i&&this.inputLookup?Object.keys(this.inputLookup):i===this.outputLayer&&this.outputLookup?Object.keys(this.outputLookup):(0,_range2.default)(0,this.sizes[i]);for(var r=0;r0){t[i][s].bias=this.biases[i][r],t[i][s].weights={};for(var a in t[i-1]){var n=a;1===i&&this.inputLookup&&(n=this.inputLookup[a]),t[i][s].weights[a]=this.weights[i][r][n]}}}}return{sizes:this.sizes,layers:t,outputLookup:!!this.outputLookup,inputLookup:!!this.inputLookup,activation:this.activation,trainOpts:this._getTrainOptsJSON()}}},{key:"fromJSON",value:function(t){this.sizes=t.sizes,this._initialize();for(var i=0;i<=this.outputLayer;i++){var e=t.layers[i];if(0!==i||e[0]&&!t.inputLookup?i!==this.outputLayer||e[0]&&!t.outputLookup||(this.outputLookup=_lookup2.default.lookupFromHash(e)):this.inputLookup=_lookup2.default.lookupFromHash(e),i>0){var r=Object.keys(e);this.sizes[i]=r.length;for(var s in r){var a=r[s];this.biases[i][s]=e[a].bias,this.weights[i][s]=(0,_toArray2.default)(e[a].weights)}}}return this._updateTrainingOptions(t.trainOpts),this.setActivation(),this}},{key:"toFunction",value:function(){function t(e,r,s){if(0===r)return"string"==typeof s?"input['"+s+"']":"input["+s+"]";var a=e[r],n=a[s],u=[n.bias];for(var o in n.weights)n.weights[o]<0?u.push(n.weights[o]+"*("+t(e,r-1,o)+")"):u.push("+"+n.weights[o]+"*("+t(e,r-1,o)+")");switch(i){case"sigmoid":return"1/(1+1/Math.exp("+u.join("")+"))";case"relu":return"var sum = "+u.join("")+";(sum < 0 ? 0 : sum);";case"leaky-relu":return"var sum = "+u.join("")+";(sum < 0 ? 0 : 0.01 * sum);";case"tanh":return"Math.tanh("+u.join("")+");";default:throw new Error("unknown activation type "+i)}}var i=this.activation,e=this.toJSON().layers,r=[],s=void 0;for(var a in e[e.length-1])r.push(t(e,e.length-1,a));return s=this.outputLookup?"{"+Object.keys(this.outputLookup).map(function(t,i){return"'"+t+"':"+r[i]})+"}":"["+r.join(",")+"]",new Function("input","return "+s)}},{key:"createTrainStream",value:function(t){return t=t||{},t.neuralNetwork=this,this.setActivation(),this.trainStream=new _trainStream2.default(t),this.trainStream}},{key:"isRunnable",get:function(){var t=this;if(!this.runInput)return console.error("Activation function has not been initialized, did you run train()?"),!1;var i=["sizes","outputLayer","biases","weights","outputs","deltas","changes","errors"].filter(function(i){return null===t[i]});return!(i.length>0)||(console.error("Some settings have not been initialized correctly, did you run train()? Found issues with: "+i.join(", ")),!1)}}]),t}();exports.default=NeuralNetwork; +"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _toConsumableArray(t){if(Array.isArray(t)){for(var i=0,e=Array(t.length);i0&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,t),Object.assign(this,this.constructor.defaults,i),this.hiddenSizes=i.hiddenLayers,this.trainOpts={},this._updateTrainingOptions(Object.assign({},this.constructor.trainDefaults,i)),this.sizes=null,this.outputLayer=null,this.biases=null,this.weights=null,this.outputs=null,this.deltas=null,this.changes=null,this.errors=null,this.constructor.prototype.hasOwnProperty("runInput")||(this.runInput=null),this.constructor.prototype.hasOwnProperty("calculateDeltas")||(this.calculateDeltas=null)}return _createClass(t,null,[{key:"_validateTrainingOptions",value:function(i){var e={iterations:function(t){return"number"==typeof t&&t>0},errorThresh:function(t){return"number"==typeof t&&t>0&&t<1},log:function(t){return"function"==typeof t||"boolean"==typeof t},logPeriod:function(t){return"number"==typeof t&&t>0},learningRate:function(t){return"number"==typeof t&&t>0&&t<1},momentum:function(t){return"number"==typeof t&&t>0&&t<1},callback:function(t){return"function"==typeof t||null===t},callbackPeriod:function(t){return"number"==typeof t&&t>0},timeout:function(t){return"number"==typeof t&&t>0}};Object.keys(t.trainDefaults).forEach(function(t){if(e.hasOwnProperty(t)&&!e[t](i[t]))throw new Error("["+t+", "+i[t]+"] is out of normal training range, your network will probably not train.")})}},{key:"trainDefaults",get:function(){return{iterations:2e4,errorThresh:.005,log:!1,logPeriod:10,learningRate:.3,momentum:.1,callback:null,callbackPeriod:10,timeout:1/0}}},{key:"defaults",get:function(){return{binaryThresh:.5,hiddenLayers:[3],activation:"sigmoid"}}}]),_createClass(t,[{key:"_initialize",value:function(){if(!this.sizes)throw new Error("Sizes must be set before initializing");this.outputLayer=this.sizes.length-1,this.biases=[],this.weights=[],this.outputs=[],this.deltas=[],this.changes=[],this.errors=[];for(var t=0;t<=this.outputLayer;t++){var i=this.sizes[t];if(this.deltas[t]=(0,_zeros2.default)(i),this.errors[t]=(0,_zeros2.default)(i),this.outputs[t]=(0,_zeros2.default)(i),t>0){this.biases[t]=(0,_randos2.default)(i),this.weights[t]=new Array(i),this.changes[t]=new Array(i);for(var e=0;e=this.trainOpts.iterations||i.error<=this.trainOpts.errorThresh||Date.now()>=e)&&(i.iterations++,i.error=this._calculateTrainingError(t),this.trainOpts.log&&i.iterations%this.trainOpts.logPeriod==0&&this.trainOpts.log("iterations: "+i.iterations+", training error: "+i.error),this.trainOpts.callback&&i.iterations%this.trainOpts.callbackPeriod==0&&this.trainOpts.callback(Object.assign(i)),!0)}},{key:"_prepTraining",value:function(t,i){this._updateTrainingOptions(i),t=this._formatData(t);var e=Date.now()+this.trainOpts.timeout,r={error:1,iterations:0};return this._verifyIsInitialized(t),{data:t,status:r,endTime:e}}},{key:"train",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},e=void 0,r=void 0,s=this._prepTraining(t,i);for(t=s.data,e=s.status,r=s.endTime;this._trainingTick(t,e,r););return e}},{key:"trainAsync",value:function(t){var i=this,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=void 0,s=void 0,a=this._prepTraining(t,e);return t=a.data,r=a.status,s=a.endTime,new Promise(function(e,a){try{var n=new _thaw2.default(new Array(i.trainOpts.iterations),{delay:!0,each:function(){return i._trainingTick(t,r,s)||n.stop()},done:function(){return e(r)}});n.tick()}catch(t){a({trainError:t,status:r})}})}},{key:"_trainPattern",value:function(t,i){return this.runInput(t),this.calculateDeltas(i),this._adjustWeights(),(0,_mse2.default)(this.errors[this.outputLayer])}},{key:"_calculateDeltasSigmoid",value:function(t){for(var i=this.outputLayer;i>=0;i--)for(var e=0;e=0;i--)for(var e=0;e0?s:0}}},{key:"_calculateDeltasLeakyRelu",value:function(t){for(var i=this.outputLayer;i>=0;i--)for(var e=0;e0?s:.01*s}}},{key:"_calculateDeltasTanh",value:function(t){for(var i=this.outputLayer;i>=0;i--)for(var e=0;ei.binaryThresh?1:0,f=p[0]):(c=l.indexOf((0,_max2.default)(l)),f=p.indexOf((0,_max2.default)(p))),c!==f){var v=t[h];Object.assign(v,{actual:c,expected:f}),u.push(v)}e&&(0===c&&0===f?n++:1===c&&1===f?a++:0===c&&1===f?s++:1===c&&0===f&&r++);var y=l.map(function(t,i){return p[i]-t});o+=(0,_mse2.default)(y)}(h);var l=o/t.length,p={error:l,misclasses:u};return e&&Object.assign(p,{trueNeg:n,truePos:a,falseNeg:s,falsePos:r,total:t.length,precision:a/(a+r),recall:a/(a+s),accuracy:(n+a)/t.length}),p}},{key:"toJSON",value:function(){for(var t=[],i=0;i<=this.outputLayer;i++){t[i]={};var e=void 0;e=0===i&&this.inputLookup?Object.keys(this.inputLookup):i===this.outputLayer&&this.outputLookup?Object.keys(this.outputLookup):(0,_range2.default)(0,this.sizes[i]);for(var r=0;r0){t[i][s].bias=this.biases[i][r],t[i][s].weights={};for(var a in t[i-1]){var n=a;1===i&&this.inputLookup&&(n=this.inputLookup[a]),t[i][s].weights[a]=this.weights[i][r][n]}}}}return{sizes:this.sizes,layers:t,outputLookup:!!this.outputLookup,inputLookup:!!this.inputLookup,activation:this.activation,trainOpts:this._getTrainOptsJSON()}}},{key:"fromJSON",value:function(t){this.sizes=t.sizes,this._initialize();for(var i=0;i<=this.outputLayer;i++){var e=t.layers[i];if(0!==i||e[0]&&!t.inputLookup?i!==this.outputLayer||e[0]&&!t.outputLookup||(this.outputLookup=_lookup2.default.lookupFromHash(e)):this.inputLookup=_lookup2.default.lookupFromHash(e),i>0){var r=Object.keys(e);this.sizes[i]=r.length;for(var s in r){var a=r[s];this.biases[i][s]=e[a].bias,this.weights[i][s]=(0,_toArray2.default)(e[a].weights)}}}return t.hasOwnProperty("trainOpts")&&this._updateTrainingOptions(t.trainOpts),this.setActivation(this.activation||"sigmoid"),this}},{key:"toFunction",value:function(){function t(e,r,s){if(0===r)return"string"==typeof s?"input['"+s+"']":"input["+s+"]";var a=e[r],n=a[s],u=[n.bias];for(var o in n.weights)n.weights[o]<0?u.push(n.weights[o]+"*("+t(e,r-1,o)+")"):u.push("+"+n.weights[o]+"*("+t(e,r-1,o)+")");switch(i){case"sigmoid":return"1/(1+1/Math.exp("+u.join("")+"))";case"relu":return"var sum = "+u.join("")+";(sum < 0 ? 0 : sum);";case"leaky-relu":return"var sum = "+u.join("")+";(sum < 0 ? 0 : 0.01 * sum);";case"tanh":return"Math.tanh("+u.join("")+");";default:throw new Error("unknown activation type "+i)}}var i=this.activation,e=this.toJSON().layers,r=[],s=void 0;for(var a in e[e.length-1])r.push(t(e,e.length-1,a));return s=this.outputLookup?"{"+Object.keys(this.outputLookup).map(function(t,i){return"'"+t+"':"+r[i]})+"}":"["+r.join(",")+"]",new Function("input","return "+s)}},{key:"createTrainStream",value:function(t){return t=t||{},t.neuralNetwork=this,this.setActivation(),this.trainStream=new _trainStream2.default(t),this.trainStream}},{key:"isRunnable",get:function(){var t=this;if(!this.runInput)return console.error("Activation function has not been initialized, did you run train()?"),!1;var i=["sizes","outputLayer","biases","weights","outputs","deltas","changes","errors"].filter(function(i){return null===t[i]});return!(i.length>0)||(console.error("Some settings have not been initialized correctly, did you run train()? Found issues with: "+i.join(", ")),!1)}}]),t}();exports.default=NeuralNetwork; },{"./lookup":3,"./train-stream":33,"./utilities/max":35,"./utilities/mse":36,"./utilities/randos":40,"./utilities/range":41,"./utilities/to-array":42,"./utilities/zeros":43,"thaw.js":100}],6:[function(require,module,exports){ "use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;rt)return!1;if((s+=e[i+1])>=t)return!0}}function s(t,s){return t<65?36===t:t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&C.test(String.fromCharCode(t)):!1!==s&&e(t,_)))}function i(t,s){return t<48?36===t:t<58||!(t<65)&&(t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&L.test(String.fromCharCode(t)):!1!==s&&(e(t,_)||e(t,P)))))}function r(t,e){return new T(t,{beforeExpr:!0,binop:e})}function n(t,e){return void 0===e&&(e={}),e.keyword=t,R[t]=new T(t,e)}function a(t){return 10===t||13===t||8232===t||8233===t}function o(t,e){return q.call(t,e)}function h(t,e){for(var s=1,i=0;;){D.lastIndex=i;var r=D.exec(t);if(!(r&&r.index=2015&&(e.ecmaVersion-=2009),null==e.allowReserved&&(e.allowReserved=e.ecmaVersion<5),z(e.onToken)){var i=e.onToken;e.onToken=function(t){return i.push(t)}}return z(e.onComment)&&(e.onComment=c(e,e.onComment)),e}function c(t,e){return function(s,i,r,n,a,o){var h={type:s?"Block":"Line",value:i,start:r,end:n};t.locations&&(h.loc=new W(this,a,o)),t.ranges&&(h.range=[r,n]),e.push(h)}}function l(t){return new RegExp("^(?:"+t.replace(/ /g,"|")+")$")}function u(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1}function d(t,e,s,i){return t.type=e,t.end=s,this.options.locations&&(t.loc.end=i),this.options.ranges&&(t.range[1]=s),t}function f(t,e,s,i){try{return new RegExp(t,e)}catch(t){if(void 0!==s)throw t instanceof SyntaxError&&i.raise(s,"Error parsing regular expression: "+t.message),t}}function m(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function x(t,e){return new $(e,t).parse()}function y(t,e,s){var i=new $(s,t,e);return i.nextToken(),i.parseExpression()}function v(t,e){return new $(e,t)}function b(e,s,i){t.parse_dammit=e,t.LooseParser=s,t.pluginsLoose=i}var g={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},k="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",w={5:k,6:k+" const class extends export import super"},E=/^in(stanceof)?$/,A="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿕ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞮꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",S="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",C=new RegExp("["+A+"]"),L=new RegExp("["+A+S+"]");A=S=null;var _=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,449,56,264,8,2,36,18,0,50,29,881,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,0,32,6124,20,754,9486,1,3071,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,10591,541],P=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,838,7,2,7,17,9,57,21,2,13,19882,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239],T=function(t,e){void 0===e&&(e={}),this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=e.binop||null,this.updateContext=null},N={beforeExpr:!0},I={startsExpr:!0},R={},V={num:new T("num",I),regexp:new T("regexp",I),string:new T("string",I),name:new T("name",I),eof:new T("eof"),bracketL:new T("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new T("]"),braceL:new T("{",{beforeExpr:!0,startsExpr:!0}),braceR:new T("}"),parenL:new T("(",{beforeExpr:!0,startsExpr:!0}),parenR:new T(")"),comma:new T(",",N),semi:new T(";",N),colon:new T(":",N),dot:new T("."),question:new T("?",N),arrow:new T("=>",N),template:new T("template"),invalidTemplate:new T("invalidTemplate"),ellipsis:new T("...",N),backQuote:new T("`",I),dollarBraceL:new T("${",{beforeExpr:!0,startsExpr:!0}),eq:new T("=",{beforeExpr:!0,isAssign:!0}),assign:new T("_=",{beforeExpr:!0,isAssign:!0}),incDec:new T("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new T("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:r("||",1),logicalAND:r("&&",2),bitwiseOR:r("|",3),bitwiseXOR:r("^",4),bitwiseAND:r("&",5),equality:r("==/!=/===/!==",6),relational:r("/<=/>=",7),bitShift:r("<>/>>>",8),plusMin:new T("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:r("%",10),star:r("*",10),slash:r("/",10),starstar:new T("**",{beforeExpr:!0}),_break:n("break"),_case:n("case",N),_catch:n("catch"),_continue:n("continue"),_debugger:n("debugger"),_default:n("default",N),_do:n("do",{isLoop:!0,beforeExpr:!0}),_else:n("else",N),_finally:n("finally"),_for:n("for",{isLoop:!0}),_function:n("function",I),_if:n("if"),_return:n("return",N),_switch:n("switch"),_throw:n("throw",N),_try:n("try"),_var:n("var"),_const:n("const"),_while:n("while",{isLoop:!0}),_with:n("with"),_new:n("new",{beforeExpr:!0,startsExpr:!0}),_this:n("this",I),_super:n("super",I),_class:n("class",I),_extends:n("extends",N),_export:n("export"),_import:n("import"),_null:n("null",I),_true:n("true",I),_false:n("false",I),_in:n("in",{beforeExpr:!0,binop:7}),_instanceof:n("instanceof",{beforeExpr:!0,binop:7}),_typeof:n("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:n("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:n("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},F=/\r\n?|\n|\u2028|\u2029/,D=new RegExp(F.source,"g"),B=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,O=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,M=Object.prototype,q=M.hasOwnProperty,U=M.toString,z=Array.isArray||function(t){return"[object Array]"===U.call(t)},j=function(t,e){this.line=t,this.column=e};j.prototype.offset=function(t){return new j(this.line,this.column+t)};var W=function(t,e,s){this.start=e,this.end=s,null!==t.sourceFile&&(this.source=t.sourceFile)},G={ecmaVersion:7,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowHashBang:!1,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1,plugins:{}},Y={},$=function(t,e,s){this.options=t=p(t),this.sourceFile=t.sourceFile,this.keywords=l(w[t.ecmaVersion>=6?6:5]);var i="";if(!t.allowReserved){for(var r=t.ecmaVersion;!(i=g[r]);r--);"module"==t.sourceType&&(i+=" await")}this.reservedWords=l(i);var n=(i?i+" ":"")+g.strict;this.reservedWordsStrict=l(n),this.reservedWordsStrictBind=l(n+" "+g.strictBind),this.input=String(e),this.containsEsc=!1,this.loadPlugins(t.plugins),s?(this.pos=s,this.lineStart=this.input.lastIndexOf("\n",s-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(F).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=V.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule="module"===t.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.inFunction=this.inGenerator=this.inAsync=!1,this.yieldPos=this.awaitPos=0,this.labels=[],0===this.pos&&t.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterFunctionScope()};$.prototype.isKeyword=function(t){return this.keywords.test(t)},$.prototype.isReservedWord=function(t){return this.reservedWords.test(t)},$.prototype.extend=function(t,e){this[t]=e(this[t])},$.prototype.loadPlugins=function(t){var e=this;for(var s in t){var i=Y[s];if(!i)throw new Error("Plugin '"+s+"' not found");i(e,t[s])}},$.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};var Q=$.prototype,H=/^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;Q.strictDirective=function(t){for(var e=this;;){O.lastIndex=t,t+=O.exec(e.input)[0].length;var s=H.exec(e.input.slice(t));if(!s)return!1;if("use strict"==(s[1]||s[2]))return!0;t+=s[0].length}},Q.eat=function(t){return this.type===t&&(this.next(),!0)},Q.isContextual=function(t){return this.type===V.name&&this.value===t&&!this.containsEsc},Q.eatContextual=function(t){return!!this.isContextual(t)&&(this.next(),!0)},Q.expectContextual=function(t){this.eatContextual(t)||this.unexpected()},Q.canInsertSemicolon=function(){return this.type===V.eof||this.type===V.braceR||F.test(this.input.slice(this.lastTokEnd,this.start))},Q.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Q.semicolon=function(){this.eat(V.semi)||this.insertSemicolon()||this.unexpected()},Q.afterTrailingComma=function(t,e){if(this.type==t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0},Q.expect=function(t){this.eat(t)||this.unexpected()},Q.unexpected=function(t){this.raise(null!=t?t:this.start,"Unexpected token")},Q.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var s=e?t.parenthesizedAssign:t.parenthesizedBind;s>-1&&this.raiseRecoverable(s,"Parenthesized pattern")}},Q.checkExpressionErrors=function(t,e){if(!t)return!1;var s=t.shorthandAssign,i=t.doubleProto;if(!e)return s>=0||i>=0;s>=0&&this.raise(s,"Shorthand property assignments are valid only in destructuring patterns"),i>=0&&this.raiseRecoverable(i,"Redefinition of __proto__ property")},Q.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos=6&&(t.sourceType=this.options.sourceType),this.finishNode(t,"Program")};var K={kind:"loop"},J={kind:"switch"};X.isLet=function(){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;O.lastIndex=this.pos;var t=O.exec(this.input),e=this.pos+t[0].length,r=this.input.charCodeAt(e);if(91===r||123==r)return!0;if(s(r,!0)){for(var n=e+1;i(this.input.charCodeAt(n),!0);)++n;var a=this.input.slice(e,n);if(!E.test(a))return!0}return!1},X.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;O.lastIndex=this.pos;var t=O.exec(this.input),e=this.pos+t[0].length;return!(F.test(this.input.slice(this.pos,e))||"function"!==this.input.slice(e,e+8)||e+8!=this.input.length&&i(this.input.charAt(e+8)))},X.parseStatement=function(t,e,s){var i,r=this.type,n=this.startNode();switch(this.isLet()&&(r=V._var,i="let"),r){case V._break:case V._continue:return this.parseBreakContinueStatement(n,r.keyword);case V._debugger:return this.parseDebuggerStatement(n);case V._do:return this.parseDoStatement(n);case V._for:return this.parseForStatement(n);case V._function:return!t&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1);case V._class:return t||this.unexpected(),this.parseClass(n,!0);case V._if:return this.parseIfStatement(n);case V._return:return this.parseReturnStatement(n);case V._switch:return this.parseSwitchStatement(n);case V._throw:return this.parseThrowStatement(n);case V._try:return this.parseTryStatement(n);case V._const:case V._var:return i=i||this.value,t||"var"==i||this.unexpected(),this.parseVarStatement(n,i);case V._while:return this.parseWhileStatement(n);case V._with:return this.parseWithStatement(n);case V.braceL:return this.parseBlock();case V.semi:return this.parseEmptyStatement(n);case V._export:case V._import:return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===V._import?this.parseImport(n):this.parseExport(n,s);default:if(this.isAsyncFunction())return t||this.unexpected(),this.next(),this.parseFunctionStatement(n,!0);var a=this.value,o=this.parseExpression();return r===V.name&&"Identifier"===o.type&&this.eat(V.colon)?this.parseLabeledStatement(n,a,o):this.parseExpressionStatement(n,o)}},X.parseBreakContinueStatement=function(t,e){var s=this,i="break"==e;this.next(),this.eat(V.semi)||this.insertSemicolon()?t.label=null:this.type!==V.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var r=0;r=6?this.eat(V.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")},X.parseForStatement=function(t){if(this.next(),this.labels.push(K),this.enterLexicalScope(),this.expect(V.parenL),this.type===V.semi)return this.parseFor(t,null);var e=this.isLet();if(this.type===V._var||this.type===V._const||e){var s=this.startNode(),i=e?"let":this.value;return this.next(),this.parseVar(s,!0,i),this.finishNode(s,"VariableDeclaration"),!(this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual("of"))||1!==s.declarations.length||"var"!==i&&s.declarations[0].init?this.parseFor(t,s):this.parseForIn(t,s)}var r=new u,n=this.parseExpression(!0,r);return this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual("of")?(this.toAssignable(n,!1,r),this.checkLVal(n),this.parseForIn(t,n)):(this.checkExpressionErrors(r,!0),this.parseFor(t,n))},X.parseFunctionStatement=function(t,e){return this.next(),this.parseFunction(t,!0,!1,e)},X.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement(!this.strict&&this.type==V._function),t.alternate=this.eat(V._else)?this.parseStatement(!this.strict&&this.type==V._function):null,this.finishNode(t,"IfStatement")},X.parseReturnStatement=function(t){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(V.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")},X.parseSwitchStatement=function(t){var e=this;this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(V.braceL),this.labels.push(J),this.enterLexicalScope();for(var s,i=!1;this.type!=V.braceR;)if(e.type===V._case||e.type===V._default){var r=e.type===V._case;s&&e.finishNode(s,"SwitchCase"),t.cases.push(s=e.startNode()),s.consequent=[],e.next(),r?s.test=e.parseExpression():(i&&e.raiseRecoverable(e.lastTokStart,"Multiple default clauses"),i=!0,s.test=null),e.expect(V.colon)}else s||e.unexpected(),s.consequent.push(e.parseStatement(!0));return this.exitLexicalScope(),s&&this.finishNode(s,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")},X.parseThrowStatement=function(t){return this.next(),F.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var Z=[];X.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===V._catch){var e=this.startNode();this.next(),this.expect(V.parenL),e.param=this.parseBindingAtom(),this.enterLexicalScope(),this.checkLVal(e.param,"let"),this.expect(V.parenR),e.body=this.parseBlock(!1),this.exitLexicalScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(V._finally)?this.parseBlock():null,t.handler||t.finalizer||this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")},X.parseVarStatement=function(t,e){return this.next(),this.parseVar(t,!1,e),this.semicolon(),this.finishNode(t,"VariableDeclaration")},X.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(K),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"WhileStatement")},X.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement(!1),this.finishNode(t,"WithStatement")},X.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")},X.parseLabeledStatement=function(t,e,s){for(var i=this,r=0,n=i.labels;r=0;o--){var h=i.labels[o];if(h.statementStart!=t.start)break;h.statementStart=i.start,h.kind=a}return this.labels.push({name:e,kind:a,statementStart:this.start}),t.body=this.parseStatement(!0),("ClassDeclaration"==t.body.type||"VariableDeclaration"==t.body.type&&"var"!=t.body.kind||"FunctionDeclaration"==t.body.type&&(this.strict||t.body.generator))&&this.raiseRecoverable(t.body.start,"Invalid labeled declaration"),this.labels.pop(),t.label=s,this.finishNode(t,"LabeledStatement")},X.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")},X.parseBlock=function(t){var e=this;void 0===t&&(t=!0);var s=this.startNode();for(s.body=[],this.expect(V.braceL),t&&this.enterLexicalScope();!this.eat(V.braceR);){var i=e.parseStatement(!0);s.body.push(i)}return t&&this.exitLexicalScope(),this.finishNode(s,"BlockStatement")},X.parseFor=function(t,e){return t.init=e,this.expect(V.semi),t.test=this.type===V.semi?null:this.parseExpression(),this.expect(V.semi),t.update=this.type===V.parenR?null:this.parseExpression(),this.expect(V.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"ForStatement")},X.parseForIn=function(t,e){var s=this.type===V._in?"ForInStatement":"ForOfStatement";return this.next(),"ForInStatement"==s&&("AssignmentPattern"===e.type||"VariableDeclaration"===e.type&&null!=e.declarations[0].init&&(this.strict||"Identifier"!==e.declarations[0].id.type))&&this.raise(e.start,"Invalid assignment in for-in loop head"),t.left=e,t.right="ForInStatement"==s?this.parseExpression():this.parseMaybeAssign(),this.expect(V.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,s)},X.parseVar=function(t,e,s){var i=this;for(t.declarations=[],t.kind=s;;){var r=i.startNode();if(i.parseVarId(r,s),i.eat(V.eq)?r.init=i.parseMaybeAssign(e):"const"!==s||i.type===V._in||i.options.ecmaVersion>=6&&i.isContextual("of")?"Identifier"==r.id.type||e&&(i.type===V._in||i.isContextual("of"))?r.init=null:i.raise(i.lastTokEnd,"Complex binding patterns require an initialization value"):i.unexpected(),t.declarations.push(i.finishNode(r,"VariableDeclarator")),!i.eat(V.comma))break}return t},X.parseVarId=function(t,e){t.id=this.parseBindingAtom(e),this.checkLVal(t.id,e,!1)},X.parseFunction=function(t,e,s,i){this.initFunction(t),this.options.ecmaVersion>=6&&!i&&(t.generator=this.eat(V.star)),this.options.ecmaVersion>=8&&(t.async=!!i),e&&(t.id="nullableID"===e&&this.type!=V.name?null:this.parseIdent(),t.id&&this.checkLVal(t.id,"var"));var r=this.inGenerator,n=this.inAsync,a=this.yieldPos,o=this.awaitPos,h=this.inFunction;return this.inGenerator=t.generator,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),e||(t.id=this.type==V.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,s),this.inGenerator=r,this.inAsync=n,this.yieldPos=a,this.awaitPos=o,this.inFunction=h,this.finishNode(t,e?"FunctionDeclaration":"FunctionExpression")},X.parseFunctionParams=function(t){this.expect(V.parenL),t.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},X.parseClass=function(t,e){var s=this;this.next(),this.parseClassId(t,e),this.parseClassSuper(t);var i=this.startNode(),r=!1;for(i.body=[],this.expect(V.braceL);!this.eat(V.braceR);){var n=s.parseClassMember(i);n&&"MethodDefinition"===n.type&&"constructor"===n.kind&&(r&&s.raise(n.start,"Duplicate constructor in the same class"),r=!0)}return t.body=this.finishNode(i,"ClassBody"),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")},X.parseClassMember=function(t){var e=this;if(this.eat(V.semi))return null;var s=this.startNode(),i=function(t,i){void 0===i&&(i=!1);var r=e.start,n=e.startLoc;return!!e.eatContextual(t)&&(!(e.type===V.parenL||i&&e.canInsertSemicolon())||(s.key&&e.unexpected(),s.computed=!1,s.key=e.startNodeAt(r,n),s.key.name=t,e.finishNode(s.key,"Identifier"),!1))};s.kind="method",s.static=i("static");var r=this.eat(V.star),n=!1;r||(this.options.ecmaVersion>=8&&i("async",!0)?n=!0:i("get")?s.kind="get":i("set")&&(s.kind="set")),s.key||this.parsePropertyName(s);var a=s.key;return s.computed||s.static||!("Identifier"===a.type&&"constructor"===a.name||"Literal"===a.type&&"constructor"===a.value)?s.static&&"Identifier"===a.type&&"prototype"===a.name&&this.raise(a.start,"Classes may not have a static property named prototype"):("method"!==s.kind&&this.raise(a.start,"Constructor can't have get/set modifier"),r&&this.raise(a.start,"Constructor can't be a generator"),n&&this.raise(a.start,"Constructor can't be an async method"),s.kind="constructor"),this.parseClassMethod(t,s,r,n),"get"===s.kind&&0!==s.value.params.length&&this.raiseRecoverable(s.value.start,"getter should have no params"),"set"===s.kind&&1!==s.value.params.length&&this.raiseRecoverable(s.value.start,"setter should have exactly one param"),"set"===s.kind&&"RestElement"===s.value.params[0].type&&this.raiseRecoverable(s.value.params[0].start,"Setter cannot use rest params"),s},X.parseClassMethod=function(t,e,s,i){e.value=this.parseMethod(s,i),t.body.push(this.finishNode(e,"MethodDefinition"))},X.parseClassId=function(t,e){t.id=this.type===V.name?this.parseIdent():!0===e?this.unexpected():null},X.parseClassSuper=function(t){t.superClass=this.eat(V._extends)?this.parseExprSubscripts():null},X.parseExport=function(t,e){var s=this;if(this.next(),this.eat(V.star))return this.expectContextual("from"),this.type!==V.string&&this.unexpected(),t.source=this.parseExprAtom(),this.semicolon(),this.finishNode(t,"ExportAllDeclaration");if(this.eat(V._default)){this.checkExport(e,"default",this.lastTokStart);var i;if(this.type===V._function||(i=this.isAsyncFunction())){var r=this.startNode();this.next(),i&&this.next(),t.declaration=this.parseFunction(r,"nullableID",!1,i)}else if(this.type===V._class){var n=this.startNode();t.declaration=this.parseClass(n,"nullableID")}else t.declaration=this.parseMaybeAssign(),this.semicolon();return this.finishNode(t,"ExportDefaultDeclaration")}if(this.shouldParseExportStatement())t.declaration=this.parseStatement(!0),"VariableDeclaration"===t.declaration.type?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id.name,t.declaration.id.start),t.specifiers=[],t.source=null;else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==V.string&&this.unexpected(),t.source=this.parseExprAtom();else{for(var a=0,o=t.specifiers;a=6&&t)switch(t.type){case"Identifier":this.inAsync&&"await"===t.name&&this.raise(t.start,"Can not use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",s&&this.checkPatternErrors(s,!0);for(var r=0,n=t.properties;r=6&&(t.computed||t.method||t.shorthand))){var i,r=t.key;switch(r.type){case"Identifier":i=r.name;break;case"Literal":i=String(r.value);break;default:return}var n=t.kind;if(this.options.ecmaVersion>=6)return void("__proto__"===i&&"init"===n&&(e.proto&&(s&&s.doubleProto<0?s.doubleProto=r.start:this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),e.proto=!0));i="$"+i;var a=e[i];if(a){var o;o="init"===n?this.strict&&a.init||a.get||a.set:a.init||a[n],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else a=e[i]={init:!1,get:!1,set:!1};a[n]=!0}},et.parseExpression=function(t,e){var s=this,i=this.start,r=this.startLoc,n=this.parseMaybeAssign(t,e);if(this.type===V.comma){var a=this.startNodeAt(i,r);for(a.expressions=[n];this.eat(V.comma);)a.expressions.push(s.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return n},et.parseMaybeAssign=function(t,e,s){if(this.inGenerator&&this.isContextual("yield"))return this.parseYield();var i=!1,r=-1,n=-1;e?(r=e.parenthesizedAssign,n=e.trailingComma,e.parenthesizedAssign=e.trailingComma=-1):(e=new u,i=!0);var a=this.start,o=this.startLoc;this.type!=V.parenL&&this.type!=V.name||(this.potentialArrowAt=this.start);var h=this.parseMaybeConditional(t,e);if(s&&(h=s.call(this,h,a,o)),this.type.isAssign){var p=this.startNodeAt(a,o);return p.operator=this.value,p.left=this.type===V.eq?this.toAssignable(h,!1,e):h,i||u.call(e),e.shorthandAssign=-1,this.checkLVal(h),this.next(),p.right=this.parseMaybeAssign(t),this.finishNode(p,"AssignmentExpression")}return i&&this.checkExpressionErrors(e,!0),r>-1&&(e.parenthesizedAssign=r),n>-1&&(e.trailingComma=n),h},et.parseMaybeConditional=function(t,e){var s=this.start,i=this.startLoc,r=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return r;if(this.eat(V.question)){var n=this.startNodeAt(s,i);return n.test=r,n.consequent=this.parseMaybeAssign(),this.expect(V.colon),n.alternate=this.parseMaybeAssign(t),this.finishNode(n,"ConditionalExpression")}return r},et.parseExprOps=function(t,e){var s=this.start,i=this.startLoc,r=this.parseMaybeUnary(e,!1);return this.checkExpressionErrors(e)?r:r.start==s&&"ArrowFunctionExpression"===r.type?r:this.parseExprOp(r,s,i,-1,t)},et.parseExprOp=function(t,e,s,i,r){var n=this.type.binop;if(null!=n&&(!r||this.type!==V._in)&&n>i){var a=this.type===V.logicalOR||this.type===V.logicalAND,o=this.value;this.next();var h=this.start,p=this.startLoc,c=this.parseExprOp(this.parseMaybeUnary(null,!1),h,p,n,r),l=this.buildBinary(e,s,t,c,o,a);return this.parseExprOp(l,e,s,i,r)}return t},et.buildBinary=function(t,e,s,i,r,n){var a=this.startNodeAt(t,e);return a.left=s,a.operator=r,a.right=i,this.finishNode(a,n?"LogicalExpression":"BinaryExpression")},et.parseMaybeUnary=function(t,e){var s,i=this,r=this.start,n=this.startLoc;if(this.inAsync&&this.isContextual("await"))s=this.parseAwait(),e=!0;else if(this.type.prefix){var a=this.startNode(),o=this.type===V.incDec;a.operator=this.value,a.prefix=!0,this.next(),a.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(t,!0),o?this.checkLVal(a.argument):this.strict&&"delete"===a.operator&&"Identifier"===a.argument.type?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):e=!0,s=this.finishNode(a,o?"UpdateExpression":"UnaryExpression")}else{if(s=this.parseExprSubscripts(t),this.checkExpressionErrors(t))return s;for(;this.type.postfix&&!this.canInsertSemicolon();){var h=i.startNodeAt(r,n);h.operator=i.value,h.prefix=!1,h.argument=s,i.checkLVal(s),i.next(),s=i.finishNode(h,"UpdateExpression")}}return!e&&this.eat(V.starstar)?this.buildBinary(r,n,s,this.parseMaybeUnary(null,!1),"**",!1):s},et.parseExprSubscripts=function(t){var e=this.start,s=this.startLoc,i=this.parseExprAtom(t),r="ArrowFunctionExpression"===i.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd);if(this.checkExpressionErrors(t)||r)return i;var n=this.parseSubscripts(i,e,s);return t&&"MemberExpression"===n.type&&(t.parenthesizedAssign>=n.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=n.start&&(t.parenthesizedBind=-1)),n},et.parseSubscripts=function(t,e,s,i){for(var r=this,n=this.options.ecmaVersion>=8&&"Identifier"===t.type&&"async"===t.name&&this.lastTokEnd==t.end&&!this.canInsertSemicolon()&&"async"===this.input.slice(t.start,t.end),a=void 0;;)if((a=r.eat(V.bracketL))||r.eat(V.dot)){var o=r.startNodeAt(e,s);o.object=t,o.property=a?r.parseExpression():r.parseIdent(!0),o.computed=!!a,a&&r.expect(V.bracketR),t=r.finishNode(o,"MemberExpression")}else if(!i&&r.eat(V.parenL)){var h=new u,p=r.yieldPos,c=r.awaitPos;r.yieldPos=0,r.awaitPos=0;var l=r.parseExprList(V.parenR,r.options.ecmaVersion>=8,!1,h);if(n&&!r.canInsertSemicolon()&&r.eat(V.arrow))return r.checkPatternErrors(h,!1),r.checkYieldAwaitInDefaultParams(),r.yieldPos=p,r.awaitPos=c,r.parseArrowExpression(r.startNodeAt(e,s),l,!0);r.checkExpressionErrors(h,!0),r.yieldPos=p||r.yieldPos,r.awaitPos=c||r.awaitPos;var d=r.startNodeAt(e,s);d.callee=t,d.arguments=l,t=r.finishNode(d,"CallExpression")}else{if(r.type!==V.backQuote)return t;var f=r.startNodeAt(e,s);f.tag=t,f.quasi=r.parseTemplate({isTagged:!0}),t=r.finishNode(f,"TaggedTemplateExpression")}},et.parseExprAtom=function(t){var e,s=this.potentialArrowAt==this.start;switch(this.type){case V._super:return this.inFunction||this.raise(this.start,"'super' outside of function or class"),e=this.startNode(),this.next(),this.type!==V.dot&&this.type!==V.bracketL&&this.type!==V.parenL&&this.unexpected(),this.finishNode(e,"Super");case V._this:return e=this.startNode(),this.next(),this.finishNode(e,"ThisExpression");case V.name:var i=this.start,r=this.startLoc,n=this.containsEsc,a=this.parseIdent(this.type!==V.name);if(this.options.ecmaVersion>=8&&!n&&"async"===a.name&&!this.canInsertSemicolon()&&this.eat(V._function))return this.parseFunction(this.startNodeAt(i,r),!1,!1,!0);if(s&&!this.canInsertSemicolon()){if(this.eat(V.arrow))return this.parseArrowExpression(this.startNodeAt(i,r),[a],!1);if(this.options.ecmaVersion>=8&&"async"===a.name&&this.type===V.name&&!n)return a=this.parseIdent(),!this.canInsertSemicolon()&&this.eat(V.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(i,r),[a],!0)}return a;case V.regexp:var o=this.value;return e=this.parseLiteral(o.value),e.regex={pattern:o.pattern,flags:o.flags},e;case V.num:case V.string:return this.parseLiteral(this.value);case V._null:case V._true:case V._false:return e=this.startNode(),e.value=this.type===V._null?null:this.type===V._true,e.raw=this.type.keyword,this.next(),this.finishNode(e,"Literal");case V.parenL:var h=this.start,p=this.parseParenAndDistinguishExpression(s);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(t.parenthesizedAssign=h),t.parenthesizedBind<0&&(t.parenthesizedBind=h)),p;case V.bracketL:return e=this.startNode(),this.next(),e.elements=this.parseExprList(V.bracketR,!0,!0,t),this.finishNode(e,"ArrayExpression");case V.braceL:return this.parseObj(!1,t);case V._function:return e=this.startNode(),this.next(),this.parseFunction(e,!1);case V._class:return this.parseClass(this.startNode(),!1);case V._new:return this.parseNew();case V.backQuote:return this.parseTemplate();default:this.unexpected()}},et.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),this.next(),this.finishNode(e,"Literal")},et.parseParenExpression=function(){this.expect(V.parenL);var t=this.parseExpression();return this.expect(V.parenR),t},et.parseParenAndDistinguishExpression=function(t){var e,s=this,i=this.start,r=this.startLoc,n=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,h=this.startLoc,p=[],c=!0,l=!1,d=new u,f=this.yieldPos,m=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==V.parenR;){if(c?c=!1:s.expect(V.comma),n&&s.afterTrailingComma(V.parenR,!0)){l=!0;break}if(s.type===V.ellipsis){a=s.start,p.push(s.parseParenItem(s.parseRestBinding())),s.type===V.comma&&s.raise(s.start,"Comma is not permitted after the rest element");break}p.push(s.parseMaybeAssign(!1,d,s.parseParenItem))}var x=this.start,y=this.startLoc;if(this.expect(V.parenR),t&&!this.canInsertSemicolon()&&this.eat(V.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=m,this.parseParenArrowList(i,r,p);p.length&&!l||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,p.length>1?(e=this.startNodeAt(o,h),e.expressions=p,this.finishNodeAt(e,"SequenceExpression",x,y)):e=p[0]}else e=this.parseParenExpression();if(this.options.preserveParens){var v=this.startNodeAt(i,r);return v.expression=e,this.finishNode(v,"ParenthesizedExpression")}return e},et.parseParenItem=function(t){return t},et.parseParenArrowList=function(t,e,s){return this.parseArrowExpression(this.startNodeAt(t,e),s)};var st=[];et.parseNew=function(){var t=this.startNode(),e=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(V.dot)){t.meta=e;var s=this.containsEsc;return t.property=this.parseIdent(!0),("target"!==t.property.name||s)&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is new.target"),this.inFunction||this.raiseRecoverable(t.start,"new.target can only be used in functions"),this.finishNode(t,"MetaProperty")}var i=this.start,r=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(),i,r,!0),this.eat(V.parenL)?t.arguments=this.parseExprList(V.parenR,this.options.ecmaVersion>=8,!1):t.arguments=st,this.finishNode(t,"NewExpression")},et.parseTemplateElement=function(t){var e=t.isTagged,s=this.startNode();return this.type===V.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),s.value={raw:this.value,cooked:null}):s.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),s.tail=this.type===V.backQuote,this.finishNode(s,"TemplateElement")},et.parseTemplate=function(t){var e=this;void 0===t&&(t={});var s=t.isTagged;void 0===s&&(s=!1);var i=this.startNode();this.next(),i.expressions=[];var r=this.parseTemplateElement({isTagged:s});for(i.quasis=[r];!r.tail;)e.expect(V.dollarBraceL),i.expressions.push(e.parseExpression()),e.expect(V.braceR),i.quasis.push(r=e.parseTemplateElement({isTagged:s}));return this.next(),this.finishNode(i,"TemplateLiteral")},et.isAsyncProp=function(t){return!t.computed&&"Identifier"===t.key.type&&"async"===t.key.name&&(this.type===V.name||this.type===V.num||this.type===V.string||this.type===V.bracketL||this.type.keyword)&&!F.test(this.input.slice(this.lastTokEnd,this.start))},et.parseObj=function(t,e){var s=this,i=this.startNode(),r=!0,n={};for(i.properties=[],this.next();!this.eat(V.braceR);){if(r)r=!1;else if(s.expect(V.comma),s.afterTrailingComma(V.braceR))break;var a=s.parseProperty(t,e);t||s.checkPropClash(a,n,e),i.properties.push(a)}return this.finishNode(i,t?"ObjectPattern":"ObjectExpression")},et.parseProperty=function(t,e){var s,i,r,n,a=this.startNode();this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(t||e)&&(r=this.start,n=this.startLoc),t||(s=this.eat(V.star)));var o=this.containsEsc;return this.parsePropertyName(a),!t&&!o&&this.options.ecmaVersion>=8&&!s&&this.isAsyncProp(a)?(i=!0,this.parsePropertyName(a,e)):i=!1,this.parsePropertyValue(a,t,s,i,r,n,e,o),this.finishNode(a,"Property")},et.parsePropertyValue=function(t,e,s,i,r,n,a,o){if((s||i)&&this.type===V.colon&&this.unexpected(),this.eat(V.colon))t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),t.kind="init";else if(this.options.ecmaVersion>=6&&this.type===V.parenL)e&&this.unexpected(),t.kind="init",t.method=!0,t.value=this.parseMethod(s,i);else if(e||o||!(this.options.ecmaVersion>=5)||t.computed||"Identifier"!==t.key.type||"get"!==t.key.name&&"set"!==t.key.name||this.type==V.comma||this.type==V.braceR)this.options.ecmaVersion>=6&&!t.computed&&"Identifier"===t.key.type?(this.checkUnreserved(t.key),t.kind="init",e?t.value=this.parseMaybeDefault(r,n,t.key):this.type===V.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),t.value=this.parseMaybeDefault(r,n,t.key)):t.value=t.key,t.shorthand=!0):this.unexpected();else{(s||i)&&this.unexpected(),t.kind=t.key.name,this.parsePropertyName(t),t.value=this.parseMethod(!1);var h="get"===t.kind?0:1;if(t.value.params.length!==h){var p=t.value.start;"get"===t.kind?this.raiseRecoverable(p,"getter should have no params"):this.raiseRecoverable(p,"setter should have exactly one param")}else"set"===t.kind&&"RestElement"===t.value.params[0].type&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")}},et.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(V.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(V.bracketR),t.key;t.computed=!1}return t.key=this.type===V.num||this.type===V.string?this.parseExprAtom():this.parseIdent(!0)},et.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=!1,t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)},et.parseMethod=function(t,e){var s=this.startNode(),i=this.inGenerator,r=this.inAsync,n=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.initFunction(s),this.options.ecmaVersion>=6&&(s.generator=t),this.options.ecmaVersion>=8&&(s.async=!!e),this.inGenerator=s.generator,this.inAsync=s.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),this.expect(V.parenL),s.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(s,!1),this.inGenerator=i,this.inAsync=r,this.yieldPos=n,this.awaitPos=a,this.inFunction=o,this.finishNode(s,"FunctionExpression")},et.parseArrowExpression=function(t,e,s){var i=this.inGenerator,r=this.inAsync,n=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.enterFunctionScope(),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!s),this.inGenerator=!1,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0),this.inGenerator=i,this.inAsync=r,this.yieldPos=n,this.awaitPos=a,this.inFunction=o,this.finishNode(t,"ArrowFunctionExpression")},et.parseFunctionBody=function(t,e){var s=e&&this.type!==V.braceL,i=this.strict,r=!1;if(s)t.body=this.parseMaybeAssign(),t.expression=!0,this.checkParams(t,!1);else{var n=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);i&&!n||(r=this.strictDirective(this.end))&&n&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list");var a=this.labels;this.labels=[],r&&(this.strict=!0),this.checkParams(t,!i&&!r&&!e&&this.isSimpleParamList(t.params)),t.body=this.parseBlock(!1),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=a}this.exitFunctionScope(),this.strict&&t.id&&this.checkLVal(t.id,"none"),this.strict=i},et.isSimpleParamList=function(t){for(var e=0,s=t;e0;)e[s]=arguments[s+1];for(var i=0,r=e;i=1;e--){var s=t.context[e];if("function"===s.token)return s.generator}return!1},ct.updateContext=function(t){var e,s=this.type;s.keyword&&t==V.dot?this.exprAllowed=!1:(e=s.updateContext)?e.call(this,t):this.exprAllowed=s.beforeExpr},V.parenR.updateContext=V.braceR.updateContext=function(){if(1==this.context.length)return void(this.exprAllowed=!0);var t=this.context.pop();t===pt.b_stat&&"function"===this.curContext().token&&(t=this.context.pop()),this.exprAllowed=!t.isExpr},V.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?pt.b_stat:pt.b_expr),this.exprAllowed=!0},V.dollarBraceL.updateContext=function(){this.context.push(pt.b_tmpl),this.exprAllowed=!0},V.parenL.updateContext=function(t){var e=t===V._if||t===V._for||t===V._with||t===V._while;this.context.push(e?pt.p_stat:pt.p_expr),this.exprAllowed=!0},V.incDec.updateContext=function(){},V._function.updateContext=V._class.updateContext=function(t){t.beforeExpr&&t!==V.semi&&t!==V._else&&(t!==V.colon&&t!==V.braceL||this.curContext()!==pt.b_stat)?this.context.push(pt.f_expr):this.context.push(pt.f_stat),this.exprAllowed=!1},V.backQuote.updateContext=function(){this.curContext()===pt.q_tmpl?this.context.pop():this.context.push(pt.q_tmpl),this.exprAllowed=!1},V.star.updateContext=function(t){if(t==V._function){var e=this.context.length-1;this.context[e]===pt.f_expr?this.context[e]=pt.f_expr_gen:this.context[e]=pt.f_gen}this.exprAllowed=!0},V.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&("of"==this.value&&!this.exprAllowed||"yield"==this.value&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var lt=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new W(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},ut=$.prototype,dt="object"==typeof Packages&&"[object JavaPackage]"==Object.prototype.toString.call(Packages);ut.next=function(){this.options.onToken&&this.options.onToken(new lt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},ut.getToken=function(){return this.next(),new lt(this)},"undefined"!=typeof Symbol&&(ut[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===V.eof,value:e}}}}),ut.curContext=function(){return this.context[this.context.length-1]},ut.nextToken=function(){var t=this.curContext();return t&&t.preserveSpace||this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length?this.finishToken(V.eof):t.override?t.override(this):void this.readToken(this.fullCharCodeAtPos())},ut.readToken=function(t){return s(t,this.options.ecmaVersion>=6)||92===t?this.readWord():this.getTokenFromCode(t)},ut.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos);return t<=55295||t>=57344?t:(t<<10)+this.input.charCodeAt(this.pos+1)-56613888},ut.skipBlockComment=function(){var t=this,e=this.options.onComment&&this.curPosition(),s=this.pos,i=this.input.indexOf("*/",this.pos+=2);if(-1===i&&this.raise(this.pos-2,"Unterminated comment"),this.pos=i+2,this.options.locations){D.lastIndex=s;for(var r;(r=D.exec(this.input))&&r.index8&&e<14||e>=5760&&B.test(String.fromCharCode(e))))break t;++t.pos}}},ut.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var s=this.type;this.type=t,this.value=e,this.updateContext(s)},ut.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===t&&46===e?(this.pos+=3,this.finishToken(V.ellipsis)):(++this.pos,this.finishToken(V.dot))},ut.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===t?this.finishOp(V.assign,2):this.finishOp(V.slash,1)},ut.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),s=1,i=42===t?V.star:V.modulo;return this.options.ecmaVersion>=7&&42==t&&42===e&&(++s,i=V.starstar,e=this.input.charCodeAt(this.pos+2)),61===e?this.finishOp(V.assign,s+1):this.finishOp(i,s)},ut.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?this.finishOp(124===t?V.logicalOR:V.logicalAND,2):61===e?this.finishOp(V.assign,2):this.finishOp(124===t?V.bitwiseOR:V.bitwiseAND,1)},ut.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(V.assign,2):this.finishOp(V.bitwiseXOR,1)},ut.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?45!=e||this.inModule||62!=this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!F.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(V.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===e?this.finishOp(V.assign,2):this.finishOp(V.plusMin,1)},ut.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),s=1;return e===t?(s=62===t&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+s)?this.finishOp(V.assign,s+1):this.finishOp(V.bitShift,s)):33!=e||60!=t||this.inModule||45!=this.input.charCodeAt(this.pos+2)||45!=this.input.charCodeAt(this.pos+3)?(61===e&&(s=2),this.finishOp(V.relational,s)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},ut.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return 61===e?this.finishOp(V.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===t&&62===e&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(V.arrow)):this.finishOp(61===t?V.eq:V.prefix,1)},ut.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(V.parenL);case 41:return++this.pos,this.finishToken(V.parenR);case 59:return++this.pos,this.finishToken(V.semi);case 44:return++this.pos,this.finishToken(V.comma);case 91:return++this.pos,this.finishToken(V.bracketL);case 93:return++this.pos,this.finishToken(V.bracketR);case 123:return++this.pos,this.finishToken(V.braceL);case 125:return++this.pos,this.finishToken(V.braceR);case 58:return++this.pos,this.finishToken(V.colon);case 63:return++this.pos,this.finishToken(V.question);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(V.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(120===e||88===e)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===e||79===e)return this.readRadixNumber(8);if(98===e||66===e)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 126:return this.finishOp(V.prefix,1)}this.raise(this.pos,"Unexpected character '"+m(t)+"'")},ut.finishOp=function(t,e){var s=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,s)};var ft=!!f("￿","u");ut.readRegexp=function(){for(var t,e,s=this,i=this.pos;;){s.pos>=s.input.length&&s.raise(i,"Unterminated regular expression");var r=s.input.charAt(s.pos);if(F.test(r)&&s.raise(i,"Unterminated regular expression"),t)t=!1;else{if("["===r)e=!0;else if("]"===r&&e)e=!1;else if("/"===r&&!e)break;t="\\"===r}++s.pos}var n=this.input.slice(i,this.pos);++this.pos;var a=this.readWord1(),o=n,h="";if(a){var p=/^[gim]*$/;this.options.ecmaVersion>=6&&(p=/^[gimuy]*$/),this.options.ecmaVersion>=9&&(p=/^[gimsuy]*$/),p.test(a)||this.raise(i,"Invalid regular expression flag"),a.indexOf("u")>=0&&(ft?h="u":(o=o.replace(/\\u\{([0-9a-fA-F]+)\}/g,function(t,e,r){return e=Number("0x"+e),e>1114111&&s.raise(i+r+3,"Code point out of bounds"),"x"}),o=o.replace(/\\u([a-fA-F0-9]{4})|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"),h=h.replace("u","")))}var c=null;return dt||(f(o,h,i,this),c=f(n,a)),this.finishToken(V.regexp,{pattern:n,flags:a,value:c})},ut.readInt=function(t,e){for(var s=this,i=this.pos,r=0,n=0,a=null==e?1/0:e;n=97?o-97+10:o>=65?o-65+10:o>=48&&o<=57?o-48:1/0)>=t)break;++s.pos,r=r*t+h}return this.pos===i||null!=e&&this.pos-i!==e?null:r},ut.readRadixNumber=function(t){this.pos+=2;var e=this.readInt(t);return null==e&&this.raise(this.start+2,"Expected number in radix "+t),s(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(V.num,e)},ut.readNumber=function(t){var e=this.pos;t||null!==this.readInt(10)||this.raise(e,"Invalid number");var i=this.pos-e>=2&&48===this.input.charCodeAt(e);i&&this.strict&&this.raise(e,"Invalid number"),i&&/[89]/.test(this.input.slice(e,this.pos))&&(i=!1);var r=this.input.charCodeAt(this.pos) -;46!==r||i||(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),69!==r&&101!==r||i||(r=this.input.charCodeAt(++this.pos),43!==r&&45!==r||++this.pos,null===this.readInt(10)&&this.raise(e,"Invalid number")),s(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var n=this.input.slice(e,this.pos),a=i?parseInt(n,8):parseFloat(n);return this.finishToken(V.num,a)},ut.readCodePoint=function(){var t,e=this.input.charCodeAt(this.pos);if(123===e){this.options.ecmaVersion<6&&this.unexpected();var s=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(s,"Code point out of bounds")}else t=this.readHexChar(4);return t},ut.readString=function(t){for(var e=this,s="",i=++this.pos;;){e.pos>=e.input.length&&e.raise(e.start,"Unterminated string constant");var r=e.input.charCodeAt(e.pos);if(r===t)break;92===r?(s+=e.input.slice(i,e.pos),s+=e.readEscapedChar(!1),i=e.pos):(a(r)&&e.raise(e.start,"Unterminated string constant"),++e.pos)}return s+=this.input.slice(i,this.pos++),this.finishToken(V.string,s)};var mt={};ut.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t!==mt)throw t;this.readInvalidTemplateToken()}this.inTemplateElement=!1},ut.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw mt;this.raise(t,e)},ut.readTmplToken=function(){for(var t=this,e="",s=this.pos;;){t.pos>=t.input.length&&t.raise(t.start,"Unterminated template");var i=t.input.charCodeAt(t.pos);if(96===i||36===i&&123===t.input.charCodeAt(t.pos+1))return t.pos!==t.start||t.type!==V.template&&t.type!==V.invalidTemplate?(e+=t.input.slice(s,t.pos),t.finishToken(V.template,e)):36===i?(t.pos+=2,t.finishToken(V.dollarBraceL)):(++t.pos,t.finishToken(V.backQuote));if(92===i)e+=t.input.slice(s,t.pos),e+=t.readEscapedChar(!0),s=t.pos;else if(a(i)){switch(e+=t.input.slice(s,t.pos),++t.pos,i){case 13:10===t.input.charCodeAt(t.pos)&&++t.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(i)}t.options.locations&&(++t.curLine,t.lineStart=t.pos),s=t.pos}else++t.pos}},ut.readInvalidTemplateToken=function(){for(var t=this;this.pos=48&&e<=55){var s=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(s,8);return i>255&&(s=s.slice(0,-1),i=parseInt(s,8)),"0"!==s&&(this.strict||t)&&this.invalidStringToken(this.pos-2,"Octal literal in strict mode"),this.pos+=s.length-1,String.fromCharCode(i)}return String.fromCharCode(e)}},ut.readHexChar=function(t){var e=this.pos,s=this.readInt(16,t);return null===s&&this.invalidStringToken(e,"Bad character escape sequence"),s},ut.readWord1=function(){var t=this;this.containsEsc=!1;for(var e="",r=!0,n=this.pos,a=this.options.ecmaVersion>=6;this.post)return!1;if((s+=e[i+1])>=t)return!0}}function s(t,s){return t<65?36===t:t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&C.test(String.fromCharCode(t)):!1!==s&&e(t,_)))}function i(t,s){return t<48?36===t:t<58||!(t<65)&&(t<91||(t<97?95===t:t<123||(t<=65535?t>=170&&L.test(String.fromCharCode(t)):!1!==s&&(e(t,_)||e(t,P)))))}function r(t,e){return new T(t,{beforeExpr:!0,binop:e})}function n(t,e){return void 0===e&&(e={}),e.keyword=t,R[t]=new T(t,e)}function a(t){return 10===t||13===t||8232===t||8233===t}function o(t,e){return q.call(t,e)}function h(t,e){for(var s=1,i=0;;){D.lastIndex=i;var r=D.exec(t);if(!(r&&r.index=2015&&(e.ecmaVersion-=2009),null==e.allowReserved&&(e.allowReserved=e.ecmaVersion<5),U(e.onToken)){var i=e.onToken;e.onToken=function(t){return i.push(t)}}return U(e.onComment)&&(e.onComment=c(e,e.onComment)),e}function c(t,e){return function(s,i,r,n,a,o){var h={type:s?"Block":"Line",value:i,start:r,end:n};t.locations&&(h.loc=new W(this,a,o)),t.ranges&&(h.range=[r,n]),e.push(h)}}function l(t){return new RegExp("^(?:"+t.replace(/ /g,"|")+")$")}function u(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1}function d(t,e,s,i){return t.type=e,t.end=s,this.options.locations&&(t.loc.end=i),this.options.ranges&&(t.range[1]=s),t}function f(t,e,s,i){try{return new RegExp(t,e)}catch(t){if(void 0!==s)throw t instanceof SyntaxError&&i.raise(s,"Error parsing regular expression: "+t.message),t}}function m(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function x(t,e){return new Q(e,t).parse()}function y(t,e,s){var i=new Q(s,t,e);return i.nextToken(),i.parseExpression()}function v(t,e){return new Q(e,t)}function g(e,s,i){t.parse_dammit=e,t.LooseParser=s,t.pluginsLoose=i}var b={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},k="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",w={5:k,6:k+" const class extends export import super"},E=/^in(stanceof)?$/,A="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿕ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞮꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",S="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",C=new RegExp("["+A+"]"),L=new RegExp("["+A+S+"]");A=S=null;var _=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,449,56,264,8,2,36,18,0,50,29,881,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,0,32,6124,20,754,9486,1,3071,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,10591,541],P=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,838,7,2,7,17,9,57,21,2,13,19882,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239],T=function(t,e){void 0===e&&(e={}),this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=e.binop||null,this.updateContext=null},N={beforeExpr:!0},I={startsExpr:!0},R={},V={num:new T("num",I),regexp:new T("regexp",I),string:new T("string",I),name:new T("name",I),eof:new T("eof"),bracketL:new T("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new T("]"),braceL:new T("{",{beforeExpr:!0,startsExpr:!0}),braceR:new T("}"),parenL:new T("(",{beforeExpr:!0,startsExpr:!0}),parenR:new T(")"),comma:new T(",",N),semi:new T(";",N),colon:new T(":",N),dot:new T("."),question:new T("?",N),arrow:new T("=>",N),template:new T("template"),invalidTemplate:new T("invalidTemplate"),ellipsis:new T("...",N),backQuote:new T("`",I),dollarBraceL:new T("${",{beforeExpr:!0,startsExpr:!0}),eq:new T("=",{beforeExpr:!0,isAssign:!0}),assign:new T("_=",{beforeExpr:!0,isAssign:!0}),incDec:new T("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new T("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:r("||",1),logicalAND:r("&&",2),bitwiseOR:r("|",3),bitwiseXOR:r("^",4),bitwiseAND:r("&",5),equality:r("==/!=/===/!==",6),relational:r("/<=/>=",7),bitShift:r("<>/>>>",8),plusMin:new T("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:r("%",10),star:r("*",10),slash:r("/",10),starstar:new T("**",{beforeExpr:!0}),_break:n("break"),_case:n("case",N),_catch:n("catch"),_continue:n("continue"),_debugger:n("debugger"),_default:n("default",N),_do:n("do",{isLoop:!0,beforeExpr:!0}),_else:n("else",N),_finally:n("finally"),_for:n("for",{isLoop:!0}),_function:n("function",I),_if:n("if"),_return:n("return",N),_switch:n("switch"),_throw:n("throw",N),_try:n("try"),_var:n("var"),_const:n("const"),_while:n("while",{isLoop:!0}),_with:n("with"),_new:n("new",{beforeExpr:!0,startsExpr:!0}),_this:n("this",I),_super:n("super",I),_class:n("class",I),_extends:n("extends",N),_export:n("export"),_import:n("import"),_null:n("null",I),_true:n("true",I),_false:n("false",I),_in:n("in",{beforeExpr:!0,binop:7}),_instanceof:n("instanceof",{beforeExpr:!0,binop:7}),_typeof:n("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:n("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:n("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},F=/\r\n?|\n|\u2028|\u2029/,D=new RegExp(F.source,"g"),B=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,O=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,M=Object.prototype,q=M.hasOwnProperty,z=M.toString,U=Array.isArray||function(t){return"[object Array]"===z.call(t)},j=function(t,e){this.line=t,this.column=e};j.prototype.offset=function(t){return new j(this.line,this.column+t)};var W=function(t,e,s){this.start=e,this.end=s,null!==t.sourceFile&&(this.source=t.sourceFile)},G={ecmaVersion:7,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowHashBang:!1,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1,plugins:{}},Y={},Q=function(t,e,s){this.options=t=p(t),this.sourceFile=t.sourceFile,this.keywords=l(w[t.ecmaVersion>=6?6:5]);var i="";if(!t.allowReserved){for(var r=t.ecmaVersion;!(i=b[r]);r--);"module"==t.sourceType&&(i+=" await")}this.reservedWords=l(i);var n=(i?i+" ":"")+b.strict;this.reservedWordsStrict=l(n),this.reservedWordsStrictBind=l(n+" "+b.strictBind),this.input=String(e),this.containsEsc=!1,this.loadPlugins(t.plugins),s?(this.pos=s,this.lineStart=this.input.lastIndexOf("\n",s-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(F).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=V.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule="module"===t.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.inFunction=this.inGenerator=this.inAsync=!1,this.yieldPos=this.awaitPos=0,this.labels=[],0===this.pos&&t.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterFunctionScope()};Q.prototype.isKeyword=function(t){return this.keywords.test(t)},Q.prototype.isReservedWord=function(t){return this.reservedWords.test(t)},Q.prototype.extend=function(t,e){this[t]=e(this[t])},Q.prototype.loadPlugins=function(t){var e=this;for(var s in t){var i=Y[s];if(!i)throw new Error("Plugin '"+s+"' not found");i(e,t[s])}},Q.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};var H=Q.prototype,X=/^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;H.strictDirective=function(t){for(var e=this;;){O.lastIndex=t,t+=O.exec(e.input)[0].length;var s=X.exec(e.input.slice(t));if(!s)return!1;if("use strict"==(s[1]||s[2]))return!0;t+=s[0].length}},H.eat=function(t){return this.type===t&&(this.next(),!0)},H.isContextual=function(t){return this.type===V.name&&this.value===t&&!this.containsEsc},H.eatContextual=function(t){return!!this.isContextual(t)&&(this.next(),!0)},H.expectContextual=function(t){this.eatContextual(t)||this.unexpected()},H.canInsertSemicolon=function(){return this.type===V.eof||this.type===V.braceR||F.test(this.input.slice(this.lastTokEnd,this.start))},H.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},H.semicolon=function(){this.eat(V.semi)||this.insertSemicolon()||this.unexpected()},H.afterTrailingComma=function(t,e){if(this.type==t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0},H.expect=function(t){this.eat(t)||this.unexpected()},H.unexpected=function(t){this.raise(null!=t?t:this.start,"Unexpected token")},H.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var s=e?t.parenthesizedAssign:t.parenthesizedBind;s>-1&&this.raiseRecoverable(s,"Parenthesized pattern")}},H.checkExpressionErrors=function(t,e){if(!t)return!1;var s=t.shorthandAssign,i=t.doubleProto;if(!e)return s>=0||i>=0;s>=0&&this.raise(s,"Shorthand property assignments are valid only in destructuring patterns"),i>=0&&this.raiseRecoverable(i,"Redefinition of __proto__ property")},H.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos=6&&(t.sourceType=this.options.sourceType),this.finishNode(t,"Program")};var K={kind:"loop"},J={kind:"switch"};$.isLet=function(){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;O.lastIndex=this.pos;var t=O.exec(this.input),e=this.pos+t[0].length,r=this.input.charCodeAt(e);if(91===r||123==r)return!0;if(s(r,!0)){for(var n=e+1;i(this.input.charCodeAt(n),!0);)++n;var a=this.input.slice(e,n);if(!E.test(a))return!0}return!1},$.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;O.lastIndex=this.pos;var t=O.exec(this.input),e=this.pos+t[0].length;return!(F.test(this.input.slice(this.pos,e))||"function"!==this.input.slice(e,e+8)||e+8!=this.input.length&&i(this.input.charAt(e+8)))},$.parseStatement=function(t,e,s){var i,r=this.type,n=this.startNode();switch(this.isLet()&&(r=V._var,i="let"),r){case V._break:case V._continue:return this.parseBreakContinueStatement(n,r.keyword);case V._debugger:return this.parseDebuggerStatement(n);case V._do:return this.parseDoStatement(n);case V._for:return this.parseForStatement(n);case V._function:return!t&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1);case V._class:return t||this.unexpected(),this.parseClass(n,!0);case V._if:return this.parseIfStatement(n);case V._return:return this.parseReturnStatement(n);case V._switch:return this.parseSwitchStatement(n);case V._throw:return this.parseThrowStatement(n);case V._try:return this.parseTryStatement(n);case V._const:case V._var:return i=i||this.value,t||"var"==i||this.unexpected(),this.parseVarStatement(n,i);case V._while:return this.parseWhileStatement(n);case V._with:return this.parseWithStatement(n);case V.braceL:return this.parseBlock();case V.semi:return this.parseEmptyStatement(n);case V._export:case V._import:return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===V._import?this.parseImport(n):this.parseExport(n,s);default:if(this.isAsyncFunction())return t||this.unexpected(),this.next(),this.parseFunctionStatement(n,!0);var a=this.value,o=this.parseExpression();return r===V.name&&"Identifier"===o.type&&this.eat(V.colon)?this.parseLabeledStatement(n,a,o):this.parseExpressionStatement(n,o)}},$.parseBreakContinueStatement=function(t,e){var s=this,i="break"==e;this.next(),this.eat(V.semi)||this.insertSemicolon()?t.label=null:this.type!==V.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var r=0;r=6?this.eat(V.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")},$.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.inAsync&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(K),this.enterLexicalScope(),this.expect(V.parenL),this.type===V.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var s=this.isLet();if(this.type===V._var||this.type===V._const||s){var i=this.startNode(),r=s?"let":this.value;return this.next(),(this.parseVar(i,!0,r),this.finishNode(i,"VariableDeclaration"),!(this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual("of"))||1!==i.declarations.length||"var"!==r&&i.declarations[0].init)?(e>-1&&this.unexpected(e),this.parseFor(t,i)):(this.options.ecmaVersion>=9&&(this.type===V._in?e>-1&&this.unexpected(e):t.await=e>-1),this.parseForIn(t,i))}var n=new u,a=this.parseExpression(!0,n);return this.type===V._in||this.options.ecmaVersion>=6&&this.isContextual("of")?(this.options.ecmaVersion>=9&&(this.type===V._in?e>-1&&this.unexpected(e):t.await=e>-1),this.toAssignable(a,!1,n),this.checkLVal(a),this.parseForIn(t,a)):(this.checkExpressionErrors(n,!0),e>-1&&this.unexpected(e),this.parseFor(t,a))},$.parseFunctionStatement=function(t,e){return this.next(),this.parseFunction(t,!0,!1,e)},$.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement(!this.strict&&this.type==V._function),t.alternate=this.eat(V._else)?this.parseStatement(!this.strict&&this.type==V._function):null,this.finishNode(t,"IfStatement")},$.parseReturnStatement=function(t){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(V.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")},$.parseSwitchStatement=function(t){var e=this;this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(V.braceL),this.labels.push(J),this.enterLexicalScope();for(var s,i=!1;this.type!=V.braceR;)if(e.type===V._case||e.type===V._default){var r=e.type===V._case;s&&e.finishNode(s,"SwitchCase"),t.cases.push(s=e.startNode()),s.consequent=[],e.next(),r?s.test=e.parseExpression():(i&&e.raiseRecoverable(e.lastTokStart,"Multiple default clauses"),i=!0,s.test=null),e.expect(V.colon)}else s||e.unexpected(),s.consequent.push(e.parseStatement(!0));return this.exitLexicalScope(),s&&this.finishNode(s,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")},$.parseThrowStatement=function(t){return this.next(),F.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var Z=[];$.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===V._catch){var e=this.startNode();this.next(),this.expect(V.parenL),e.param=this.parseBindingAtom(),this.enterLexicalScope(),this.checkLVal(e.param,"let"),this.expect(V.parenR),e.body=this.parseBlock(!1),this.exitLexicalScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(V._finally)?this.parseBlock():null,t.handler||t.finalizer||this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")},$.parseVarStatement=function(t,e){return this.next(),this.parseVar(t,!1,e),this.semicolon(),this.finishNode(t,"VariableDeclaration")},$.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(K),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"WhileStatement")},$.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement(!1),this.finishNode(t,"WithStatement")},$.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")},$.parseLabeledStatement=function(t,e,s){for(var i=this,r=0,n=i.labels;r=0;o--){var h=i.labels[o];if(h.statementStart!=t.start)break;h.statementStart=i.start,h.kind=a}return this.labels.push({name:e,kind:a,statementStart:this.start}),t.body=this.parseStatement(!0),("ClassDeclaration"==t.body.type||"VariableDeclaration"==t.body.type&&"var"!=t.body.kind||"FunctionDeclaration"==t.body.type&&(this.strict||t.body.generator))&&this.raiseRecoverable(t.body.start,"Invalid labeled declaration"),this.labels.pop(),t.label=s,this.finishNode(t,"LabeledStatement")},$.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")},$.parseBlock=function(t){var e=this;void 0===t&&(t=!0);var s=this.startNode();for(s.body=[],this.expect(V.braceL),t&&this.enterLexicalScope();!this.eat(V.braceR);){var i=e.parseStatement(!0);s.body.push(i)}return t&&this.exitLexicalScope(),this.finishNode(s,"BlockStatement")},$.parseFor=function(t,e){return t.init=e,this.expect(V.semi),t.test=this.type===V.semi?null:this.parseExpression(),this.expect(V.semi),t.update=this.type===V.parenR?null:this.parseExpression(),this.expect(V.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,"ForStatement")},$.parseForIn=function(t,e){var s=this.type===V._in?"ForInStatement":"ForOfStatement";return this.next(),"ForInStatement"==s&&("AssignmentPattern"===e.type||"VariableDeclaration"===e.type&&null!=e.declarations[0].init&&(this.strict||"Identifier"!==e.declarations[0].id.type))&&this.raise(e.start,"Invalid assignment in for-in loop head"),t.left=e,t.right="ForInStatement"==s?this.parseExpression():this.parseMaybeAssign(),this.expect(V.parenR),this.exitLexicalScope(),t.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(t,s)},$.parseVar=function(t,e,s){var i=this;for(t.declarations=[],t.kind=s;;){var r=i.startNode();if(i.parseVarId(r,s),i.eat(V.eq)?r.init=i.parseMaybeAssign(e):"const"!==s||i.type===V._in||i.options.ecmaVersion>=6&&i.isContextual("of")?"Identifier"==r.id.type||e&&(i.type===V._in||i.isContextual("of"))?r.init=null:i.raise(i.lastTokEnd,"Complex binding patterns require an initialization value"):i.unexpected(),t.declarations.push(i.finishNode(r,"VariableDeclarator")),!i.eat(V.comma))break}return t},$.parseVarId=function(t,e){t.id=this.parseBindingAtom(e),this.checkLVal(t.id,e,!1)},$.parseFunction=function(t,e,s,i){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!i)&&(t.generator=this.eat(V.star)),this.options.ecmaVersion>=8&&(t.async=!!i),e&&(t.id="nullableID"===e&&this.type!=V.name?null:this.parseIdent(),t.id&&this.checkLVal(t.id,"var"));var r=this.inGenerator,n=this.inAsync,a=this.yieldPos,o=this.awaitPos,h=this.inFunction;return this.inGenerator=t.generator,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),e||(t.id=this.type==V.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,s),this.inGenerator=r,this.inAsync=n,this.yieldPos=a,this.awaitPos=o,this.inFunction=h,this.finishNode(t,e?"FunctionDeclaration":"FunctionExpression")},$.parseFunctionParams=function(t){this.expect(V.parenL),t.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},$.parseClass=function(t,e){var s=this;this.next(),this.parseClassId(t,e),this.parseClassSuper(t);var i=this.startNode(),r=!1;for(i.body=[],this.expect(V.braceL);!this.eat(V.braceR);){var n=s.parseClassMember(i);n&&"MethodDefinition"===n.type&&"constructor"===n.kind&&(r&&s.raise(n.start,"Duplicate constructor in the same class"),r=!0)}return t.body=this.finishNode(i,"ClassBody"),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")},$.parseClassMember=function(t){var e=this;if(this.eat(V.semi))return null;var s=this.startNode(),i=function(t,i){void 0===i&&(i=!1);var r=e.start,n=e.startLoc;return!!e.eatContextual(t)&&(!(e.type===V.parenL||i&&e.canInsertSemicolon())||(s.key&&e.unexpected(),s.computed=!1,s.key=e.startNodeAt(r,n),s.key.name=t,e.finishNode(s.key,"Identifier"),!1))};s.kind="method",s.static=i("static");var r=this.eat(V.star),n=!1;r||(this.options.ecmaVersion>=8&&i("async",!0)?(n=!0,r=this.options.ecmaVersion>=9&&this.eat(V.star)):i("get")?s.kind="get":i("set")&&(s.kind="set")),s.key||this.parsePropertyName(s);var a=s.key;return s.computed||s.static||!("Identifier"===a.type&&"constructor"===a.name||"Literal"===a.type&&"constructor"===a.value)?s.static&&"Identifier"===a.type&&"prototype"===a.name&&this.raise(a.start,"Classes may not have a static property named prototype"):("method"!==s.kind&&this.raise(a.start,"Constructor can't have get/set modifier"),r&&this.raise(a.start,"Constructor can't be a generator"),n&&this.raise(a.start,"Constructor can't be an async method"),s.kind="constructor"),this.parseClassMethod(t,s,r,n),"get"===s.kind&&0!==s.value.params.length&&this.raiseRecoverable(s.value.start,"getter should have no params"),"set"===s.kind&&1!==s.value.params.length&&this.raiseRecoverable(s.value.start,"setter should have exactly one param"),"set"===s.kind&&"RestElement"===s.value.params[0].type&&this.raiseRecoverable(s.value.params[0].start,"Setter cannot use rest params"),s},$.parseClassMethod=function(t,e,s,i){e.value=this.parseMethod(s,i),t.body.push(this.finishNode(e,"MethodDefinition"))},$.parseClassId=function(t,e){t.id=this.type===V.name?this.parseIdent():!0===e?this.unexpected():null},$.parseClassSuper=function(t){t.superClass=this.eat(V._extends)?this.parseExprSubscripts():null},$.parseExport=function(t,e){var s=this;if(this.next(),this.eat(V.star))return this.expectContextual("from"),this.type!==V.string&&this.unexpected(),t.source=this.parseExprAtom(),this.semicolon(),this.finishNode(t,"ExportAllDeclaration");if(this.eat(V._default)){this.checkExport(e,"default",this.lastTokStart);var i;if(this.type===V._function||(i=this.isAsyncFunction())){var r=this.startNode();this.next(),i&&this.next(),t.declaration=this.parseFunction(r,"nullableID",!1,i)}else if(this.type===V._class){var n=this.startNode();t.declaration=this.parseClass(n,"nullableID")}else t.declaration=this.parseMaybeAssign(),this.semicolon();return this.finishNode(t,"ExportDefaultDeclaration")}if(this.shouldParseExportStatement())t.declaration=this.parseStatement(!0),"VariableDeclaration"===t.declaration.type?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id.name,t.declaration.id.start),t.specifiers=[],t.source=null;else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==V.string&&this.unexpected(),t.source=this.parseExprAtom();else{for(var a=0,o=t.specifiers;a=6&&t)switch(t.type){case"Identifier":this.inAsync&&"await"===t.name&&this.raise(t.start,"Can not use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",s&&this.checkPatternErrors(s,!0);for(var r=0,n=t.properties;r=9&&"SpreadElement"===t.type||this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var i,r=t.key;switch(r.type){case"Identifier":i=r.name;break;case"Literal":i=String(r.value);break;default:return}var n=t.kind;if(this.options.ecmaVersion>=6)return void("__proto__"===i&&"init"===n&&(e.proto&&(s&&s.doubleProto<0?s.doubleProto=r.start:this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),e.proto=!0));i="$"+i;var a=e[i];if(a){var o;o="init"===n?this.strict&&a.init||a.get||a.set:a.init||a[n],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else a=e[i]={init:!1,get:!1,set:!1};a[n]=!0}},et.parseExpression=function(t,e){var s=this,i=this.start,r=this.startLoc,n=this.parseMaybeAssign(t,e);if(this.type===V.comma){var a=this.startNodeAt(i,r);for(a.expressions=[n];this.eat(V.comma);)a.expressions.push(s.parseMaybeAssign(t,e));return this.finishNode(a,"SequenceExpression")}return n},et.parseMaybeAssign=function(t,e,s){if(this.inGenerator&&this.isContextual("yield"))return this.parseYield();var i=!1,r=-1,n=-1;e?(r=e.parenthesizedAssign,n=e.trailingComma,e.parenthesizedAssign=e.trailingComma=-1):(e=new u,i=!0);var a=this.start,o=this.startLoc;this.type!=V.parenL&&this.type!=V.name||(this.potentialArrowAt=this.start);var h=this.parseMaybeConditional(t,e);if(s&&(h=s.call(this,h,a,o)),this.type.isAssign){var p=this.startNodeAt(a,o);return p.operator=this.value,p.left=this.type===V.eq?this.toAssignable(h,!1,e):h,i||u.call(e),e.shorthandAssign=-1,this.checkLVal(h),this.next(),p.right=this.parseMaybeAssign(t),this.finishNode(p,"AssignmentExpression")}return i&&this.checkExpressionErrors(e,!0),r>-1&&(e.parenthesizedAssign=r),n>-1&&(e.trailingComma=n),h},et.parseMaybeConditional=function(t,e){var s=this.start,i=this.startLoc,r=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return r;if(this.eat(V.question)){var n=this.startNodeAt(s,i);return n.test=r,n.consequent=this.parseMaybeAssign(),this.expect(V.colon),n.alternate=this.parseMaybeAssign(t),this.finishNode(n,"ConditionalExpression")}return r},et.parseExprOps=function(t,e){var s=this.start,i=this.startLoc,r=this.parseMaybeUnary(e,!1);return this.checkExpressionErrors(e)?r:r.start==s&&"ArrowFunctionExpression"===r.type?r:this.parseExprOp(r,s,i,-1,t)},et.parseExprOp=function(t,e,s,i,r){var n=this.type.binop;if(null!=n&&(!r||this.type!==V._in)&&n>i){var a=this.type===V.logicalOR||this.type===V.logicalAND,o=this.value;this.next();var h=this.start,p=this.startLoc,c=this.parseExprOp(this.parseMaybeUnary(null,!1),h,p,n,r),l=this.buildBinary(e,s,t,c,o,a);return this.parseExprOp(l,e,s,i,r)}return t},et.buildBinary=function(t,e,s,i,r,n){var a=this.startNodeAt(t,e);return a.left=s,a.operator=r,a.right=i,this.finishNode(a,n?"LogicalExpression":"BinaryExpression")},et.parseMaybeUnary=function(t,e){var s,i=this,r=this.start,n=this.startLoc;if(this.inAsync&&this.isContextual("await"))s=this.parseAwait(),e=!0;else if(this.type.prefix){var a=this.startNode(),o=this.type===V.incDec;a.operator=this.value,a.prefix=!0,this.next(),a.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(t,!0),o?this.checkLVal(a.argument):this.strict&&"delete"===a.operator&&"Identifier"===a.argument.type?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):e=!0,s=this.finishNode(a,o?"UpdateExpression":"UnaryExpression")}else{if(s=this.parseExprSubscripts(t),this.checkExpressionErrors(t))return s;for(;this.type.postfix&&!this.canInsertSemicolon();){var h=i.startNodeAt(r,n);h.operator=i.value,h.prefix=!1,h.argument=s,i.checkLVal(s),i.next(),s=i.finishNode(h,"UpdateExpression")}}return!e&&this.eat(V.starstar)?this.buildBinary(r,n,s,this.parseMaybeUnary(null,!1),"**",!1):s},et.parseExprSubscripts=function(t){var e=this.start,s=this.startLoc,i=this.parseExprAtom(t),r="ArrowFunctionExpression"===i.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd);if(this.checkExpressionErrors(t)||r)return i;var n=this.parseSubscripts(i,e,s);return t&&"MemberExpression"===n.type&&(t.parenthesizedAssign>=n.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=n.start&&(t.parenthesizedBind=-1)),n},et.parseSubscripts=function(t,e,s,i){for(var r=this,n=this.options.ecmaVersion>=8&&"Identifier"===t.type&&"async"===t.name&&this.lastTokEnd==t.end&&!this.canInsertSemicolon()&&"async"===this.input.slice(t.start,t.end),a=void 0;;)if((a=r.eat(V.bracketL))||r.eat(V.dot)){var o=r.startNodeAt(e,s);o.object=t,o.property=a?r.parseExpression():r.parseIdent(!0),o.computed=!!a,a&&r.expect(V.bracketR),t=r.finishNode(o,"MemberExpression")}else if(!i&&r.eat(V.parenL)){var h=new u,p=r.yieldPos,c=r.awaitPos;r.yieldPos=0,r.awaitPos=0;var l=r.parseExprList(V.parenR,r.options.ecmaVersion>=8,!1,h);if(n&&!r.canInsertSemicolon()&&r.eat(V.arrow))return r.checkPatternErrors(h,!1),r.checkYieldAwaitInDefaultParams(),r.yieldPos=p,r.awaitPos=c,r.parseArrowExpression(r.startNodeAt(e,s),l,!0);r.checkExpressionErrors(h,!0),r.yieldPos=p||r.yieldPos,r.awaitPos=c||r.awaitPos;var d=r.startNodeAt(e,s);d.callee=t,d.arguments=l,t=r.finishNode(d,"CallExpression")}else{if(r.type!==V.backQuote)return t;var f=r.startNodeAt(e,s);f.tag=t,f.quasi=r.parseTemplate({isTagged:!0}),t=r.finishNode(f,"TaggedTemplateExpression")}},et.parseExprAtom=function(t){var e,s=this.potentialArrowAt==this.start;switch(this.type){case V._super:return this.inFunction||this.raise(this.start,"'super' outside of function or class"),e=this.startNode(),this.next(),this.type!==V.dot&&this.type!==V.bracketL&&this.type!==V.parenL&&this.unexpected(),this.finishNode(e,"Super");case V._this:return e=this.startNode(),this.next(),this.finishNode(e,"ThisExpression");case V.name:var i=this.start,r=this.startLoc,n=this.containsEsc,a=this.parseIdent(this.type!==V.name);if(this.options.ecmaVersion>=8&&!n&&"async"===a.name&&!this.canInsertSemicolon()&&this.eat(V._function))return this.parseFunction(this.startNodeAt(i,r),!1,!1,!0);if(s&&!this.canInsertSemicolon()){if(this.eat(V.arrow))return this.parseArrowExpression(this.startNodeAt(i,r),[a],!1);if(this.options.ecmaVersion>=8&&"async"===a.name&&this.type===V.name&&!n)return a=this.parseIdent(),!this.canInsertSemicolon()&&this.eat(V.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(i,r),[a],!0)}return a;case V.regexp:var o=this.value;return e=this.parseLiteral(o.value),e.regex={pattern:o.pattern,flags:o.flags},e;case V.num:case V.string:return this.parseLiteral(this.value);case V._null:case V._true:case V._false:return e=this.startNode(),e.value=this.type===V._null?null:this.type===V._true,e.raw=this.type.keyword,this.next(),this.finishNode(e,"Literal");case V.parenL:var h=this.start,p=this.parseParenAndDistinguishExpression(s);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(t.parenthesizedAssign=h),t.parenthesizedBind<0&&(t.parenthesizedBind=h)),p;case V.bracketL:return e=this.startNode(),this.next(),e.elements=this.parseExprList(V.bracketR,!0,!0,t),this.finishNode(e,"ArrayExpression");case V.braceL:return this.parseObj(!1,t);case V._function:return e=this.startNode(),this.next(),this.parseFunction(e,!1);case V._class:return this.parseClass(this.startNode(),!1);case V._new:return this.parseNew();case V.backQuote:return this.parseTemplate();default:this.unexpected()}},et.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),this.next(),this.finishNode(e,"Literal")},et.parseParenExpression=function(){this.expect(V.parenL);var t=this.parseExpression();return this.expect(V.parenR),t},et.parseParenAndDistinguishExpression=function(t){var e,s=this,i=this.start,r=this.startLoc,n=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,h=this.startLoc,p=[],c=!0,l=!1,d=new u,f=this.yieldPos,m=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==V.parenR;){if(c?c=!1:s.expect(V.comma),n&&s.afterTrailingComma(V.parenR,!0)){l=!0;break}if(s.type===V.ellipsis){a=s.start,p.push(s.parseParenItem(s.parseRestBinding())),s.type===V.comma&&s.raise(s.start,"Comma is not permitted after the rest element");break}p.push(s.parseMaybeAssign(!1,d,s.parseParenItem))}var x=this.start,y=this.startLoc;if(this.expect(V.parenR),t&&!this.canInsertSemicolon()&&this.eat(V.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=m,this.parseParenArrowList(i,r,p);p.length&&!l||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,p.length>1?(e=this.startNodeAt(o,h),e.expressions=p,this.finishNodeAt(e,"SequenceExpression",x,y)):e=p[0]}else e=this.parseParenExpression();if(this.options.preserveParens){var v=this.startNodeAt(i,r);return v.expression=e,this.finishNode(v,"ParenthesizedExpression")}return e},et.parseParenItem=function(t){return t},et.parseParenArrowList=function(t,e,s){return this.parseArrowExpression(this.startNodeAt(t,e),s)};var st=[];et.parseNew=function(){var t=this.startNode(),e=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(V.dot)){t.meta=e;var s=this.containsEsc;return t.property=this.parseIdent(!0),("target"!==t.property.name||s)&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is new.target"),this.inFunction||this.raiseRecoverable(t.start,"new.target can only be used in functions"),this.finishNode(t,"MetaProperty")}var i=this.start,r=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(),i,r,!0),this.eat(V.parenL)?t.arguments=this.parseExprList(V.parenR,this.options.ecmaVersion>=8,!1):t.arguments=st,this.finishNode(t,"NewExpression")},et.parseTemplateElement=function(t){var e=t.isTagged,s=this.startNode();return this.type===V.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),s.value={raw:this.value,cooked:null}):s.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),s.tail=this.type===V.backQuote,this.finishNode(s,"TemplateElement")},et.parseTemplate=function(t){var e=this;void 0===t&&(t={});var s=t.isTagged;void 0===s&&(s=!1);var i=this.startNode();this.next(),i.expressions=[];var r=this.parseTemplateElement({isTagged:s});for(i.quasis=[r];!r.tail;)e.expect(V.dollarBraceL),i.expressions.push(e.parseExpression()),e.expect(V.braceR),i.quasis.push(r=e.parseTemplateElement({isTagged:s}));return this.next(),this.finishNode(i,"TemplateLiteral")},et.isAsyncProp=function(t){return!t.computed&&"Identifier"===t.key.type&&"async"===t.key.name&&(this.type===V.name||this.type===V.num||this.type===V.string||this.type===V.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===V.star)&&!F.test(this.input.slice(this.lastTokEnd,this.start))},et.parseObj=function(t,e){var s=this,i=this.startNode(),r=!0,n={};for(i.properties=[],this.next();!this.eat(V.braceR);){if(r)r=!1;else if(s.expect(V.comma),s.afterTrailingComma(V.braceR))break;var a=s.parseProperty(t,e);t||s.checkPropClash(a,n,e),i.properties.push(a)}return this.finishNode(i,t?"ObjectPattern":"ObjectExpression")},et.parseProperty=function(t,e){var s,i,r,n,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(V.ellipsis))return t?(a.argument=this.parseIdent(!1),this.type===V.comma&&this.raise(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(this.type===V.parenL&&e&&(e.parenthesizedAssign<0&&(e.parenthesizedAssign=this.start),e.parenthesizedBind<0&&(e.parenthesizedBind=this.start)),a.argument=this.parseMaybeAssign(!1,e),this.type===V.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(t||e)&&(r=this.start,n=this.startLoc),t||(s=this.eat(V.star)));var o=this.containsEsc;return this.parsePropertyName(a),!t&&!o&&this.options.ecmaVersion>=8&&!s&&this.isAsyncProp(a)?(i=!0,s=this.options.ecmaVersion>=9&&this.eat(V.star),this.parsePropertyName(a,e)):i=!1,this.parsePropertyValue(a,t,s,i,r,n,e,o),this.finishNode(a,"Property")},et.parsePropertyValue=function(t,e,s,i,r,n,a,o){if((s||i)&&this.type===V.colon&&this.unexpected(),this.eat(V.colon))t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),t.kind="init";else if(this.options.ecmaVersion>=6&&this.type===V.parenL)e&&this.unexpected(),t.kind="init",t.method=!0,t.value=this.parseMethod(s,i);else if(e||o||!(this.options.ecmaVersion>=5)||t.computed||"Identifier"!==t.key.type||"get"!==t.key.name&&"set"!==t.key.name||this.type==V.comma||this.type==V.braceR)this.options.ecmaVersion>=6&&!t.computed&&"Identifier"===t.key.type?(this.checkUnreserved(t.key),t.kind="init",e?t.value=this.parseMaybeDefault(r,n,t.key):this.type===V.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),t.value=this.parseMaybeDefault(r,n,t.key)):t.value=t.key,t.shorthand=!0):this.unexpected();else{(s||i)&&this.unexpected(),t.kind=t.key.name,this.parsePropertyName(t),t.value=this.parseMethod(!1);var h="get"===t.kind?0:1;if(t.value.params.length!==h){var p=t.value.start;"get"===t.kind?this.raiseRecoverable(p,"getter should have no params"):this.raiseRecoverable(p,"setter should have exactly one param")}else"set"===t.kind&&"RestElement"===t.value.params[0].type&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")}},et.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(V.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(V.bracketR),t.key;t.computed=!1}return t.key=this.type===V.num||this.type===V.string?this.parseExprAtom():this.parseIdent(!0)},et.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=!1,t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)},et.parseMethod=function(t,e){var s=this.startNode(),i=this.inGenerator,r=this.inAsync,n=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.initFunction(s),this.options.ecmaVersion>=6&&(s.generator=t),this.options.ecmaVersion>=8&&(s.async=!!e),this.inGenerator=s.generator,this.inAsync=s.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),this.expect(V.parenL),s.params=this.parseBindingList(V.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(s,!1),this.inGenerator=i,this.inAsync=r,this.yieldPos=n,this.awaitPos=a,this.inFunction=o,this.finishNode(s,"FunctionExpression")},et.parseArrowExpression=function(t,e,s){var i=this.inGenerator,r=this.inAsync,n=this.yieldPos,a=this.awaitPos,o=this.inFunction;return this.enterFunctionScope(),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!s),this.inGenerator=!1,this.inAsync=t.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0),this.inGenerator=i,this.inAsync=r,this.yieldPos=n,this.awaitPos=a,this.inFunction=o,this.finishNode(t,"ArrowFunctionExpression")},et.parseFunctionBody=function(t,e){var s=e&&this.type!==V.braceL,i=this.strict,r=!1;if(s)t.body=this.parseMaybeAssign(),t.expression=!0,this.checkParams(t,!1);else{var n=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);i&&!n||(r=this.strictDirective(this.end))&&n&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list");var a=this.labels;this.labels=[],r&&(this.strict=!0),this.checkParams(t,!i&&!r&&!e&&this.isSimpleParamList(t.params)),t.body=this.parseBlock(!1),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=a}this.exitFunctionScope(),this.strict&&t.id&&this.checkLVal(t.id,"none"),this.strict=i},et.isSimpleParamList=function(t){for(var e=0,s=t;e0;)e[s]=arguments[s+1];for(var i=0,r=e;i=1;e--){var s=t.context[e];if("function"===s.token)return s.generator}return!1},ct.updateContext=function(t){var e,s=this.type;s.keyword&&t==V.dot?this.exprAllowed=!1:(e=s.updateContext)?e.call(this,t):this.exprAllowed=s.beforeExpr},V.parenR.updateContext=V.braceR.updateContext=function(){if(1==this.context.length)return void(this.exprAllowed=!0);var t=this.context.pop();t===pt.b_stat&&"function"===this.curContext().token&&(t=this.context.pop()),this.exprAllowed=!t.isExpr},V.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?pt.b_stat:pt.b_expr),this.exprAllowed=!0},V.dollarBraceL.updateContext=function(){this.context.push(pt.b_tmpl),this.exprAllowed=!0},V.parenL.updateContext=function(t){var e=t===V._if||t===V._for||t===V._with||t===V._while;this.context.push(e?pt.p_stat:pt.p_expr),this.exprAllowed=!0},V.incDec.updateContext=function(){},V._function.updateContext=V._class.updateContext=function(t){t.beforeExpr&&t!==V.semi&&t!==V._else&&(t!==V.colon&&t!==V.braceL||this.curContext()!==pt.b_stat)?this.context.push(pt.f_expr):this.context.push(pt.f_stat),this.exprAllowed=!1},V.backQuote.updateContext=function(){this.curContext()===pt.q_tmpl?this.context.pop():this.context.push(pt.q_tmpl),this.exprAllowed=!1},V.star.updateContext=function(t){if(t==V._function){var e=this.context.length-1;this.context[e]===pt.f_expr?this.context[e]=pt.f_expr_gen:this.context[e]=pt.f_gen}this.exprAllowed=!0},V.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&("of"==this.value&&!this.exprAllowed||"yield"==this.value&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var lt=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new W(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},ut=Q.prototype,dt="object"==typeof Packages&&"[object JavaPackage]"==Object.prototype.toString.call(Packages);ut.next=function(){this.options.onToken&&this.options.onToken(new lt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},ut.getToken=function(){return this.next(),new lt(this)},"undefined"!=typeof Symbol&&(ut[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===V.eof,value:e}}}}),ut.curContext=function(){return this.context[this.context.length-1]},ut.nextToken=function(){var t=this.curContext();return t&&t.preserveSpace||this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length?this.finishToken(V.eof):t.override?t.override(this):void this.readToken(this.fullCharCodeAtPos())},ut.readToken=function(t){return s(t,this.options.ecmaVersion>=6)||92===t?this.readWord():this.getTokenFromCode(t)},ut.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos);return t<=55295||t>=57344?t:(t<<10)+this.input.charCodeAt(this.pos+1)-56613888},ut.skipBlockComment=function(){var t=this,e=this.options.onComment&&this.curPosition(),s=this.pos,i=this.input.indexOf("*/",this.pos+=2);if(-1===i&&this.raise(this.pos-2,"Unterminated comment"),this.pos=i+2,this.options.locations){D.lastIndex=s;for(var r;(r=D.exec(this.input))&&r.index8&&e<14||e>=5760&&B.test(String.fromCharCode(e))))break t;++t.pos}}},ut.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var s=this.type;this.type=t,this.value=e,this.updateContext(s)},ut.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===t&&46===e?(this.pos+=3,this.finishToken(V.ellipsis)):(++this.pos,this.finishToken(V.dot))},ut.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===t?this.finishOp(V.assign,2):this.finishOp(V.slash,1)},ut.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),s=1,i=42===t?V.star:V.modulo;return this.options.ecmaVersion>=7&&42==t&&42===e&&(++s,i=V.starstar,e=this.input.charCodeAt(this.pos+2)),61===e?this.finishOp(V.assign,s+1):this.finishOp(i,s)},ut.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?this.finishOp(124===t?V.logicalOR:V.logicalAND,2):61===e?this.finishOp(V.assign,2):this.finishOp(124===t?V.bitwiseOR:V.bitwiseAND,1)},ut.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(V.assign,2):this.finishOp(V.bitwiseXOR,1)},ut.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?45!=e||this.inModule||62!=this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!F.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(V.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===e?this.finishOp(V.assign,2):this.finishOp(V.plusMin,1)},ut.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),s=1;return e===t?(s=62===t&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+s)?this.finishOp(V.assign,s+1):this.finishOp(V.bitShift,s)):33!=e||60!=t||this.inModule||45!=this.input.charCodeAt(this.pos+2)||45!=this.input.charCodeAt(this.pos+3)?(61===e&&(s=2),this.finishOp(V.relational,s)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},ut.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return 61===e?this.finishOp(V.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===t&&62===e&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(V.arrow)):this.finishOp(61===t?V.eq:V.prefix,1)},ut.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(V.parenL);case 41:return++this.pos,this.finishToken(V.parenR);case 59:return++this.pos,this.finishToken(V.semi);case 44:return++this.pos,this.finishToken(V.comma);case 91:return++this.pos,this.finishToken(V.bracketL);case 93:return++this.pos,this.finishToken(V.bracketR);case 123:return++this.pos,this.finishToken(V.braceL);case 125:return++this.pos,this.finishToken(V.braceR);case 58:return++this.pos,this.finishToken(V.colon);case 63:return++this.pos,this.finishToken(V.question);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(V.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(120===e||88===e)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===e||79===e)return this.readRadixNumber(8);if(98===e||66===e)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 126:return this.finishOp(V.prefix,1)}this.raise(this.pos,"Unexpected character '"+m(t)+"'")},ut.finishOp=function(t,e){var s=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,s)};var ft=!!f("￿","u");ut.readRegexp=function(){for(var t,e,s=this,i=this.pos;;){s.pos>=s.input.length&&s.raise(i,"Unterminated regular expression");var r=s.input.charAt(s.pos);if(F.test(r)&&s.raise(i,"Unterminated regular expression"),t)t=!1;else{if("["===r)e=!0;else if("]"===r&&e)e=!1;else if("/"===r&&!e)break;t="\\"===r}++s.pos}var n=this.input.slice(i,this.pos);++this.pos;var a=this.pos,o=this.readWord1() +;this.containsEsc&&this.unexpected(a);var h=n,p="";if(o){var c="gim";this.options.ecmaVersion>=6&&(c+="uy"),this.options.ecmaVersion>=9&&(c+="s");for(var l=0;l-1&&s.raise(i,"Duplicate regular expression flag")}o.indexOf("u")>=0&&(ft?p="u":(h=h.replace(/\\u\{([0-9a-fA-F]+)\}/g,function(t,e,r){return e=Number("0x"+e),e>1114111&&s.raise(i+r+3,"Code point out of bounds"),"x"}),h=h.replace(/\\u([a-fA-F0-9]{4})|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"),p=p.replace("u","")))}var d=null;return dt||(f(h,p,i,this),d=f(n,o)),this.finishToken(V.regexp,{pattern:n,flags:o,value:d})},ut.readInt=function(t,e){for(var s=this,i=this.pos,r=0,n=0,a=null==e?1/0:e;n=97?o-97+10:o>=65?o-65+10:o>=48&&o<=57?o-48:1/0)>=t)break;++s.pos,r=r*t+h}return this.pos===i||null!=e&&this.pos-i!==e?null:r},ut.readRadixNumber=function(t){this.pos+=2;var e=this.readInt(t);return null==e&&this.raise(this.start+2,"Expected number in radix "+t),s(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(V.num,e)},ut.readNumber=function(t){var e=this.pos;t||null!==this.readInt(10)||this.raise(e,"Invalid number");var i=this.pos-e>=2&&48===this.input.charCodeAt(e);i&&this.strict&&this.raise(e,"Invalid number"),i&&/[89]/.test(this.input.slice(e,this.pos))&&(i=!1);var r=this.input.charCodeAt(this.pos);46!==r||i||(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),69!==r&&101!==r||i||(r=this.input.charCodeAt(++this.pos),43!==r&&45!==r||++this.pos,null===this.readInt(10)&&this.raise(e,"Invalid number")),s(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var n=this.input.slice(e,this.pos),a=i?parseInt(n,8):parseFloat(n);return this.finishToken(V.num,a)},ut.readCodePoint=function(){var t,e=this.input.charCodeAt(this.pos);if(123===e){this.options.ecmaVersion<6&&this.unexpected();var s=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(s,"Code point out of bounds")}else t=this.readHexChar(4);return t},ut.readString=function(t){for(var e=this,s="",i=++this.pos;;){e.pos>=e.input.length&&e.raise(e.start,"Unterminated string constant");var r=e.input.charCodeAt(e.pos);if(r===t)break;92===r?(s+=e.input.slice(i,e.pos),s+=e.readEscapedChar(!1),i=e.pos):(a(r)&&e.raise(e.start,"Unterminated string constant"),++e.pos)}return s+=this.input.slice(i,this.pos++),this.finishToken(V.string,s)};var mt={};ut.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t!==mt)throw t;this.readInvalidTemplateToken()}this.inTemplateElement=!1},ut.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw mt;this.raise(t,e)},ut.readTmplToken=function(){for(var t=this,e="",s=this.pos;;){t.pos>=t.input.length&&t.raise(t.start,"Unterminated template");var i=t.input.charCodeAt(t.pos);if(96===i||36===i&&123===t.input.charCodeAt(t.pos+1))return t.pos!==t.start||t.type!==V.template&&t.type!==V.invalidTemplate?(e+=t.input.slice(s,t.pos),t.finishToken(V.template,e)):36===i?(t.pos+=2,t.finishToken(V.dollarBraceL)):(++t.pos,t.finishToken(V.backQuote));if(92===i)e+=t.input.slice(s,t.pos),e+=t.readEscapedChar(!0),s=t.pos;else if(a(i)){switch(e+=t.input.slice(s,t.pos),++t.pos,i){case 13:10===t.input.charCodeAt(t.pos)&&++t.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(i)}t.options.locations&&(++t.curLine,t.lineStart=t.pos),s=t.pos}else++t.pos}},ut.readInvalidTemplateToken=function(){for(var t=this;this.pos=48&&e<=55){var s=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(s,8);return i>255&&(s=s.slice(0,-1),i=parseInt(s,8)),this.pos+=s.length-1,e=this.input.charCodeAt(this.pos),"0"===s&&56!=e&&57!=e||!this.strict&&!t||this.invalidStringToken(this.pos-1-s.length,"Octal literal in strict mode"),String.fromCharCode(i)}return String.fromCharCode(e)}},ut.readHexChar=function(t){var e=this.pos,s=this.readInt(16,t);return null===s&&this.invalidStringToken(e,"Bad character escape sequence"),s},ut.readWord1=function(){var t=this;this.containsEsc=!1;for(var e="",r=!0,n=this.pos,a=this.options.ecmaVersion>=6;this.pos0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===o[r-2]?2:"="===o[r-1]?1:0}function byteLength(o){return 3*o.length/4-placeHoldersCount(o)}function toByteArray(o){var r,e,t,u,n,p=o.length;u=placeHoldersCount(o),n=new Arr(3*p/4-u),e=u>0?p-4:p;var a=0;for(r=0;r>16&255,n[a++]=t>>8&255,n[a++]=255&t;return 2===u?(t=revLookup[o.charCodeAt(r)]<<2|revLookup[o.charCodeAt(r+1)]>>4,n[a++]=255&t):1===u&&(t=revLookup[o.charCodeAt(r)]<<10|revLookup[o.charCodeAt(r+1)]<<4|revLookup[o.charCodeAt(r+2)]>>2,n[a++]=t>>8&255,n[a++]=255&t),n}function tripletToBase64(o){return lookup[o>>18&63]+lookup[o>>12&63]+lookup[o>>6&63]+lookup[63&o]}function encodeChunk(o,r,e){for(var t,u=[],n=r;na?a:p+16383));return 1===t?(r=o[e-1],u+=lookup[r>>2],u+=lookup[r<<4&63],u+="=="):2===t&&(r=(o[e-2]<<8)+o[e-1],u+=lookup[r>>10],u+=lookup[r>>4&63],u+=lookup[r<<2&63],u+="="),n.push(u),n.join("")}exports.byteLength=byteLength,exports.toByteArray=toByteArray,exports.fromByteArray=fromByteArray;for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===o[r-2]?2:"="===o[r-1]?1:0}function byteLength(o){return 3*o.length/4-placeHoldersCount(o)}function toByteArray(o){var r,e,t,u,n,p=o.length;u=placeHoldersCount(o),n=new Arr(3*p/4-u),e=u>0?p-4:p;var a=0;for(r=0;r>16&255,n[a++]=t>>8&255,n[a++]=255&t;return 2===u?(t=revLookup[o.charCodeAt(r)]<<2|revLookup[o.charCodeAt(r+1)]>>4,n[a++]=255&t):1===u&&(t=revLookup[o.charCodeAt(r)]<<10|revLookup[o.charCodeAt(r+1)]<<4|revLookup[o.charCodeAt(r+2)]>>2,n[a++]=t>>8&255,n[a++]=255&t),n}function tripletToBase64(o){return lookup[o>>18&63]+lookup[o>>12&63]+lookup[o>>6&63]+lookup[63&o]}function encodeChunk(o,r,e){for(var t,u=[],n=r;na?a:p+16383));return 1===t?(r=o[e-1],u+=lookup[r>>2],u+=lookup[r<<4&63],u+="=="):2===t&&(r=(o[e-2]<<8)+o[e-1],u+=lookup[r>>10],u+=lookup[r>>4&63],u+=lookup[r<<2&63],u+="="),n.push(u),n.join("")}exports.byteLength=byteLength,exports.toByteArray=toByteArray,exports.fromByteArray=fromByteArray;for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(e,t){function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}if(!isFunction(t))throw TypeError("listener must be a function");var n=!1;return i.listener=t,this.on(e,i),this},EventEmitter.prototype.removeListener=function(e,t){var i,n,s,r;if(!isFunction(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=this._events[e],s=i.length,n=-1,i===t||isFunction(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(isObject(i)){for(r=s;r-- >0;)if(i[r]===t||i[r].listener&&i[r].listener===t){n=r;break}if(n<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[e],isFunction(i))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},EventEmitter.prototype.listeners=function(e){return this._events&&this._events[e]?isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[]},EventEmitter.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(isFunction(t))return 1;if(t)return t.length}return 0},EventEmitter.listenerCount=function(e,t){return e.listenerCount(t)}; },{}],51:[function(require,module,exports){ -"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var FunctionBuilderBase=require("../function-builder-base"),CPUFunctionNode=require("./function-node");module.exports=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.Node=CPUFunctionNode,e}return _inherits(t,e),t}(FunctionBuilderBase); +"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var n=0;n0&&e.push(", "),e.push(" "),e.push("user_"),e.push(r)}e.push(") {\n")}for(var a=0;a1){for(var i=null,u=0;u0&&e.push(","),this.astGeneric(t.declarations[n],e,s);return e.push(";"),e}},{key:"astVariableDeclarator",value:function(t,e,s){return this.astGeneric(t.id,e,s),null!==t.init&&(e.push("="),this.astGeneric(t.init,e,s)),e}},{key:"astIfStatement",value:function(t,e,s){return e.push("if ("),this.astGeneric(t.test,e,s),e.push(")"),"BlockStatement"===t.consequent.type?this.astGeneric(t.consequent,e,s):(e.push(" {\n"),this.astGeneric(t.consequent,e,s),e.push("\n}\n")),t.alternate&&(e.push("else "),"BlockStatement"===t.alternate.type?this.astGeneric(t.alternate,e,s):(e.push(" {\n"),this.astGeneric(t.alternate,e,s),e.push("\n}\n"))),e}},{key:"astBreakStatement",value:function(t,e,s){return e.push("break;\n"),e}},{key:"astContinueStatement",value:function(t,e,s){return e.push("continue;\n"),e}},{key:"astLogicalExpression",value:function(t,e,s){return e.push("("),this.astGeneric(t.left,e,s),e.push(t.operator),this.astGeneric(t.right,e,s),e.push(")"),e}},{key:"astUpdateExpression",value:function(t,e,s){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e,s)):(this.astGeneric(t.argument,e,s),e.push(t.operator)),e}},{key:"astUnaryExpression",value:function(t,e,s){return t.prefix?(e.push(t.operator),this.astGeneric(t.argument,e,s)):(this.astGeneric(t.argument,e,s),e.push(t.operator)),e}},{key:"astThisExpression",value:function(t,e,s){return e.push("_this"),e}},{key:"astMemberExpression",value:function(t,e,s){if(t.computed)if("Identifier"===t.object.type)this.astGeneric(t.object,e,s),e.push("["),this.astGeneric(t.property,e,s),e.push("]");else{this.astGeneric(t.object,e,s);var n=e.pop();e.push("]["),this.astGeneric(t.property,e,s),e.push(n)}else{var r=this.astMemberExpressionUnroll(t);switch("Identifier"===t.property.type&&t.computed&&(r="user_"+r),0===r.indexOf("this")&&(r="_"+r),r){case"_this.output.x":e.push(this.output[0]);break;case"_this.output.y":e.push(this.output[1]);break;case"_this.output.z":e.push(this.output[2]);break;default:e.push(r)}}return e}},{key:"astSequenceExpression",value:function(t,e,s){for(var n=0;n0&&e.push(","),this.astGeneric(t.expressions,e,s);return e}},{key:"astCallExpression",value:function(t,e,s){if(t.callee){var n=this.astMemberExpressionUnroll(t.callee);s.calledFunctions.indexOf(n)<0&&s.calledFunctions.push(n),s.hasOwnProperty("funcName")||(s.calledFunctionsArguments[n]=[]);var r=[];s.calledFunctionsArguments[n].push(r),e.push(n),e.push("(");for(var a=0;a0&&e.push(", "),this.astGeneric(i,e,s),"Identifier"===i.type){var u=s.paramNames.indexOf(i.name);-1===u?r.push(null):r.push({name:i.name,type:s.paramTypes[u]})}else r.push(null)}return e.push(")"),e}throw this.astErrorOutput("Unknown CallExpression",t,s)}},{key:"astArrayExpression",value:function(t,e,s){var n=t.elements.length;e.push("new Float32Array(");for(var r=0;r0&&e.push(", ");var a=t.elements[r];this.astGeneric(a,e,s)}return e.push(")"),e}},{key:"astDebuggerStatement",value:function(t,e,s){return e.push("debugger;"),e}}],[{key:"astFunctionPrototype",value:function(t,e,s){if(s.isRootKernel||s.isSubKernel)return e;e.push(s.returnType),e.push(" "),e.push(s.functionName),e.push("(");for(var n=0;n0&&e.push(", "),e.push(s.paramTypes[n]),e.push(" "),e.push("user_"),e.push(s.paramNames[n]);return e.push(");\n"),e}}]),e}(BaseFunctionNode); },{"../../core/utils":75,"../function-node-base":57}],53:[function(require,module,exports){ -"use strict";function removeFnNoise(n){return/^function /.test(n)&&(n=n.substring(9)),n.replace(/[_]typeof/g,"typeof")}function removeNoise(n){return n.replace(/[_]typeof/g,"typeof")}var utils=require("../../core/utils"),kernelRunShortcut=require("../kernel-run-shortcut");module.exports=function(n,t){return"() => {\n "+kernelRunShortcut.toString()+";\n const utils = {\n allPropertiesOf: "+removeNoise(utils.allPropertiesOf.toString())+",\n clone: "+removeNoise(utils.clone.toString())+"\n };\n const Utils = utils;\n class "+(t||"Kernel")+" {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(n.paramNames)+";\n this.paramTypes = "+JSON.stringify(n.paramTypes)+";\n this.texSize = "+JSON.stringify(n.texSize)+";\n this.output = "+JSON.stringify(n.output)+";\n this._kernelString = `"+n._kernelString+"`;\n this.output = "+JSON.stringify(n.output)+";\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+removeFnNoise(n.build.toString())+"\n "+removeFnNoise(n.setupParams.toString())+"\n run () { "+n.kernelString+" }\n getKernelString() { return this._kernelString; }\n };\n return kernelRunShortcut(new Kernel());\n };"}; +"use strict";var utils=require("../../core/utils"),kernelRunShortcut=require("../kernel-run-shortcut");module.exports=function(n,t){return"() => {\n "+kernelRunShortcut.toString()+";\n const utils = {\n allPropertiesOf: function "+utils.allPropertiesOf.toString()+",\n clone: function "+utils.clone.toString()+",\n /*splitArray: function "+utils.splitArray.toString()+",\n getArgumentType: function "+utils.getArgumentType.toString()+",\n getOutput: function "+utils.getOutput.toString()+",\n dimToTexSize: function "+utils.dimToTexSize.toString()+",\n copyFlatten: function "+utils.copyFlatten.toString()+",\n flatten: function "+utils.flatten.toString()+",\n systemEndianness: '"+utils.systemEndianness()+"',\n initWebGl: function "+utils.initWebGl.toString()+",\n isArray: function "+utils.isArray.toString()+"*/\n };\n class "+(t||"Kernel")+" {\n constructor() { \n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(n.paramNames)+";\n this.paramTypes = "+JSON.stringify(n.paramTypes)+";\n this.texSize = "+JSON.stringify(n.texSize)+";\n this.output = "+JSON.stringify(n.output)+";\n this._kernelString = `"+n._kernelString+"`;\n this.output = "+JSON.stringify(n.output)+";\n\t\t this.run = function() {\n this.run = null;\n this.build();\n return this.run.apply(this, arguments);\n }.bind(this);\n this.thread = {\n x: 0,\n y: 0,\n z: 0\n };\n }\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+n.build.toString()+"\n run () { "+n.kernelString+" }\n getKernelString() { return this._kernelString; }\n };\n return kernelRunShortcut(new Kernel());\n };"}; },{"../../core/utils":75,"../kernel-run-shortcut":59}],54:[function(require,module,exports){ "use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var _createClass=function(){function t(t,e){for(var n=0;n0?l.join("\n"):"")+"\n }.bind(this);"}},{key:"toString",value:function(){return kernelString(this)}},{key:"precompileKernelObj",value:function(t){return{threadDim:this.threadDim||(this.threadDim=utils.clone(this.output))}}},{key:"_getLoopMaxString",value:function(){return this.loopMaxIterations?" "+parseInt(this.loopMaxIterations)+";\n":" 1000;\n"}}],[{key:"compileKernel",value:function(t){for(var e=t.threadDim;e.length<3;)e.push(1)}}]),e}(KernelBase); @@ -270,50 +270,49 @@ function EventEmitter(){this._events=this._events||{},this._maxListeners=this._m "use strict";function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,r){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!r||"object"!=typeof r&&"function"!=typeof r?e:r}function _inherits(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function, not "+typeof r);e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),r&&(Object.setPrototypeOf?Object.setPrototypeOf(e,r):e.__proto__=r)}var _createClass=function(){function e(e,r){for(var t=0;t=0||t.push(n)),t}},{key:"addKernel",value:function(n,t,e,i){var o=new this.Node("kernel",n,t,i);return o.setAddFunction(this.addFunction.bind(this)),o.paramNames=e,o.paramTypes=i,o.isRootKernel=!0,this.addFunctionNode(o),o}},{key:"addSubKernel",value:function(n,t,e,i){var o=new this.Node(null,n,t,e,i);return o.setAddFunction(this.addFunction.bind(this)),o.isSubKernel=!0,this.addFunctionNode(o),o}},{key:"getPrototypeString",value:function(n){return this.getPrototypes(n).join("\n")}},{key:"getPrototypes",value:function(n){return this.rootKernel.generate(),n?this.getPrototypesFromFunctionNames(this.traceFunctionCalls(n,[]).reverse()):this.getPrototypesFromFunctionNames(Object.keys(this.nodeMap))}},{key:"getStringFromFunctionNames",value:function(n){for(var t=[],e=0;e=0||t.push(n)),t}},{key:"addKernel",value:function(n,t,e,i){var o=new this.Node("kernel",n,t,i);return o.setAddFunction(this.addFunction.bind(this)),o.paramNames=e,o.paramTypes=i,o.isRootKernel=!0,this.addFunctionNode(o),o}},{key:"addSubKernel",value:function(n,t,e,i){var o=new this.Node(null,n,t,e,i);return o.setAddFunction(this.addFunction.bind(this)),o.isSubKernel=!0,this.addFunctionNode(o),o}},{key:"getPrototypeString",value:function(n){return this.getPrototypes(n).join("\n")}},{key:"getPrototypes",value:function(n){return this.rootKernel.generate(),n?this.getPrototypesFromFunctionNames(this.traceFunctionCalls(n,[]).reverse()):this.getPrototypesFromFunctionNames(Object.keys(this.nodeMap))}},{key:"getStringFromFunctionNames",value:function(n){for(var t=[],e=0;e ("+r.length+","+this.paramNames.length+")";this.paramTypes=r}else if("object"===(void 0===r?"undefined":_typeof(r))){var s=Object.keys(r);if(r.hasOwnProperty("returns")&&(this.returnType=r.returns,s.splice(s.indexOf("returns"),1)),s.length>0&&s.length!==this.paramNames.length)throw"Invalid argument type array length, against function length -> ("+s.length+","+this.paramNames.length+")";this.paramTypes=this.paramNames.map(function(t){return r.hasOwnProperty(t)?r[t]:"float"})}}else this.paramTypes=[];this.returnType||(this.returnType=i||"float")}return _createClass(BaseFunctionNode,[{key:"isIdentifierConstant",value:function(t){return!!this.constants&&this.constants.hasOwnProperty(t)}},{key:"setAddFunction",value:function(t){return this.addFunction=t,this}},{key:"getJsFunction",value:function getJsFunction(){if(this.jsFunction)return this.jsFunction;if(this.jsFunctionString)return this.jsFunction=eval(this.jsFunctionString),this.jsFunction;throw"Missing jsFunction, and jsFunctionString parameter"}},{key:"astMemberExpressionUnroll",value:function(t,n){if("Identifier"===t.type)return t.name;if("ThisExpression"===t.type)return"this";if("MemberExpression"===t.type&&t.object&&t.property)return t.object.hasOwnProperty("name")&&"_"===t.object.name[0]?this.astMemberExpressionUnroll(t.property,n):this.astMemberExpressionUnroll(t.object,n)+"."+this.astMemberExpressionUnroll(t.property,n);if(t.hasOwnProperty("expressions")){var e=t.expressions[0];if("Literal"===e.type&&0===e.value&&2===t.expressions.length)return this.astMemberExpressionUnroll(t.expressions[1])}throw this.astErrorOutput("Unknown CallExpression_unroll",t,n)}},{key:"getJsAST",value:function(t){if(this.jsFunctionAST)return this.jsFunctionAST;if(null===(t=t||acorn))throw"Missing JS to AST parser";var n=t.parse("var "+this.functionName+" = "+this.jsFunctionString+";",{locations:!0});if(null===n)throw"Failed to parse JS code";var e=n.body[0].declarations[0].init;return this.jsFunctionAST=e,e}},{key:"getFunctionString",value:function(){return this.generate(),this.functionString}},{key:"setFunctionString",value:function(t){this.functionString=t}},{key:"getParamType",value:function(t){var n=this.paramNames.indexOf(t);if(-1===n)return null;if(!this.parent)return null;if(this.paramTypes[n])return this.paramTypes[n];for(var e=this.parent.calledFunctionsArguments[this.functionName],r=0;r0&&t.push(", ");var i=s.getParamType(n);switch(i){case"Texture":case"Input":case"Array":t.push("sampler2D");break;default:t.push("float")}t.push(" "),t.push("user_"),t.push(n)}t.push(") {\n");for(var a=0;a1){for(var a=null,u=0;u0&&t.push(","),this.astGeneric(e.declarations[r],t,s);return t.push(";"),t}},{key:"astVariableDeclarator",value:function(e,t,s){return this.astGeneric(e.id,t,s),null!==e.init&&(t.push("="),this.astGeneric(e.init,t,s)),t}},{key:"astIfStatement",value:function(e,t,s){return t.push("if ("),this.astGeneric(e.test,t,s),t.push(")"),"BlockStatement"===e.consequent.type?this.astGeneric(e.consequent,t,s):(t.push(" {\n"),this.astGeneric(e.consequent,t,s),t.push("\n}\n")),e.alternate&&(t.push("else "),"BlockStatement"===e.alternate.type?this.astGeneric(e.alternate,t,s):(t.push(" {\n"),this.astGeneric(e.alternate,t,s),t.push("\n}\n"))),t}},{key:"astBreakStatement",value:function(e,t,s){return t.push("break;\n"),t}},{key:"astContinueStatement",value:function(e,t,s){return t.push("continue;\n"),t}},{key:"astLogicalExpression",value:function(e,t,s){return t.push("("),this.astGeneric(e.left,t,s),t.push(e.operator),this.astGeneric(e.right,t,s),t.push(")"),t}},{key:"astUpdateExpression",value:function(e,t,s){return e.prefix?(t.push(e.operator),this.astGeneric(e.argument,t,s)):(this.astGeneric(e.argument,t,s),t.push(e.operator)),t}},{key:"astUnaryExpression",value:function(e,t,s){return e.prefix?(t.push(e.operator),this.astGeneric(e.argument,t,s)):(this.astGeneric(e.argument,t,s),t.push(e.operator)),t}},{key:"astThisExpression",value:function(e,t,s){return t.push("this"),t}},{key:"astMemberExpression",value:function(e,t,s){if(e.computed)if("Identifier"===e.object.type){var r=e.object.name,n=(s.functionName,!1);if(s.paramNames){var i=s.paramNames.indexOf(r);i>=0&&"float"===s.paramTypes[i]&&(n=!0)}n?(this.astGeneric(e.object,t,s),t.push("[int("),this.astGeneric(e.property,t,s),t.push(")]")):(t.push("get("),this.astGeneric(e.object,t,s),t.push(", vec2("),this.astGeneric(e.object,t,s),t.push("Size[0],"),this.astGeneric(e.object,t,s),t.push("Size[1]), vec3("),this.astGeneric(e.object,t,s),t.push("Dim[0],"),this.astGeneric(e.object,t,s),t.push("Dim[1],"),this.astGeneric(e.object,t,s),t.push("Dim[2]"),t.push("), "),this.astGeneric(e.property,t,s),t.push(")"))}else{this.astGeneric(e.object,t,s);var a=t.pop();t.push(","),this.astGeneric(e.property,t,s),t.push(a)}else{var u=this.astMemberExpressionUnroll(e),o=u.toLowerCase();switch(0===u.indexOf(constantsPrefix)&&(u="constants_"+u.slice(constantsPrefix.length)),o){case"this.thread.x":t.push("threadId.x");break;case"this.thread.y":t.push("threadId.y");break;case"this.thread.z":t.push("threadId.z");break;case"this.output.x":t.push(this.output[0]+".0");break;case"this.output.y":t.push(this.output[1]+".0");break;case"this.output.z":t.push(this.output[2]+".0");break;default:t.push(u)}}return t}},{key:"astSequenceExpression",value:function(e,t,s){for(var r=0;r0&&t.push(","),this.astGeneric(e.expressions,t,s);return t}},{key:"astCallExpression",value:function(e,t,s){if(e.callee){var r=this.astMemberExpressionUnroll(e.callee);0===r.indexOf(jsMathPrefix)&&(r=r.slice(jsMathPrefix.length)),0===r.indexOf(localPrefix)&&(r=r.slice(localPrefix.length)),"atan2"===r&&(r="atan"),s.calledFunctions.indexOf(r)<0&&s.calledFunctions.push(r),s.hasOwnProperty("funcName")||(s.calledFunctionsArguments[r]=[]);var n=[];s.calledFunctionsArguments[r].push(n),t.push(r),t.push("(");for(var i=0;i0&&t.push(", "),this.astGeneric(a,t,s),"Identifier"===a.type){var u=s.paramNames.indexOf(a.name);-1===u?n.push(null):n.push({name:a.name,type:s.paramTypes[u]})}else n.push(null)}return t.push(")"),t}throw this.astErrorOutput("Unknown CallExpression",e,s)}},{key:"astArrayExpression",value:function(e,t,s){var r=e.elements.length;t.push("float["+r+"](");for(var n=0;n0&&t.push(", ");var i=e.elements[n];this.astGeneric(i,t,s)}return t.push(")"),t}},{key:"getFunctionPrototypeString",value:function(){return this.webGlFunctionPrototypeString?this.webGlFunctionPrototypeString:this.webGlFunctionPrototypeString=this.generate()}},{key:"build",value:function(){return this.getFunctionPrototypeString().length>0}}],[{key:"astFunctionPrototype",value:function(e,t,s){if(s.isRootKernel||s.isSubKernel)return t;t.push(s.returnType),t.push(" "),t.push(s.functionName),t.push("(");for(var r=0;r0&&t.push(", "),t.push(s.paramTypes[r]),t.push(" "),t.push("user_"),t.push(s.paramNames[r]);return t.push(");\n"),t}}]),t}(FunctionNodeBase); +"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function isIdentifierKernelParam(e,t,s){return-1!==s.paramNames.indexOf(e)}function ensureIndentifierType(e,t,s,r){var n=s.loc.start;if(!isIdentifierKernelParam(e,r)&&"float"!==t)throw new Error("Error unexpected identifier "+e+" on line "+n.line);if(r.paramTypes[r.paramNames.indexOf(e)]!==t)throw new Error("Error unexpected identifier "+e+" on line "+n.line)}function webGlRegexOptimize(e){return e.replace(DECODE32_ENCODE32,"((").replace(ENCODE32_DECODE32,"((")}var _createClass=function(){function e(e,t){for(var s=0;s0&&t.push(", ");var i=s.getParamType(n);switch(i){case"Texture":case"Input":case"Array":t.push("sampler2D");break;default:t.push("float")}t.push(" "),t.push("user_"),t.push(n)}t.push(") {\n");for(var a=0;a1){for(var a=null,u=0;u0&&t.push(","),this.astGeneric(e.declarations[r],t,s);return t.push(";"),t}},{key:"astVariableDeclarator",value:function(e,t,s){return this.astGeneric(e.id,t,s),null!==e.init&&(t.push("="),this.astGeneric(e.init,t,s)),t}},{key:"astIfStatement",value:function(e,t,s){return t.push("if ("),this.astGeneric(e.test,t,s),t.push(")"),"BlockStatement"===e.consequent.type?this.astGeneric(e.consequent,t,s):(t.push(" {\n"),this.astGeneric(e.consequent,t,s),t.push("\n}\n")),e.alternate&&(t.push("else "),"BlockStatement"===e.alternate.type?this.astGeneric(e.alternate,t,s):(t.push(" {\n"),this.astGeneric(e.alternate,t,s),t.push("\n}\n"))),t}},{key:"astBreakStatement",value:function(e,t,s){return t.push("break;\n"),t}},{key:"astContinueStatement",value:function(e,t,s){return t.push("continue;\n"),t}},{key:"astLogicalExpression",value:function(e,t,s){return t.push("("),this.astGeneric(e.left,t,s),t.push(e.operator),this.astGeneric(e.right,t,s),t.push(")"),t}},{key:"astUpdateExpression",value:function(e,t,s){return e.prefix?(t.push(e.operator),this.astGeneric(e.argument,t,s)):(this.astGeneric(e.argument,t,s),t.push(e.operator)),t}},{key:"astUnaryExpression",value:function(e,t,s){return e.prefix?(t.push(e.operator),this.astGeneric(e.argument,t,s)):(this.astGeneric(e.argument,t,s),t.push(e.operator)),t}},{key:"astThisExpression",value:function(e,t,s){return t.push("this"),t}},{key:"astMemberExpression",value:function(e,t,s){if(e.computed)if("Identifier"===e.object.type){var r=e.object.name,n=(s.functionName,!1);if(s.paramNames){var i=s.paramNames.indexOf(r);i>=0&&"float"===s.paramTypes[i]&&(n=!0)}n?(this.astGeneric(e.object,t,s),t.push("[int("),this.astGeneric(e.property,t,s),t.push(")]")):(t.push("get("),this.astGeneric(e.object,t,s),t.push(", vec2("),this.astGeneric(e.object,t,s),t.push("Size[0],"),this.astGeneric(e.object,t,s),t.push("Size[1]), vec3("),this.astGeneric(e.object,t,s),t.push("Dim[0],"),this.astGeneric(e.object,t,s),t.push("Dim[1],"),this.astGeneric(e.object,t,s),t.push("Dim[2]"),t.push("), "),this.astGeneric(e.property,t,s),t.push(")"))}else{this.astGeneric(e.object,t,s);var a=t.pop();t.push(","),this.astGeneric(e.property,t,s),t.push(a)}else{var u=this.astMemberExpressionUnroll(e),o=u.toLowerCase();switch(0===u.indexOf(constantsPrefix)&&(u="constants_"+u.slice(constantsPrefix.length)),o){case"this.thread.x":t.push("threadId.x");break;case"this.thread.y":t.push("threadId.y");break;case"this.thread.z":t.push("threadId.z");break;case"this.output.x":t.push(this.output[0]+".0");break;case"this.output.y":t.push(this.output[1]+".0");break;case"this.output.z":t.push(this.output[2]+".0");break;default:t.push(u)}}return t}},{key:"astSequenceExpression",value:function(e,t,s){for(var r=0;r0&&t.push(","),this.astGeneric(e.expressions,t,s);return t}},{key:"astCallExpression",value:function(e,t,s){if(e.callee){var r=this.astMemberExpressionUnroll(e.callee);0===r.indexOf(jsMathPrefix)&&(r=r.slice(jsMathPrefix.length)),0===r.indexOf(localPrefix)&&(r=r.slice(localPrefix.length)),s.calledFunctions.indexOf(r)<0&&s.calledFunctions.push(r),s.hasOwnProperty("funcName")||(s.calledFunctionsArguments[r]=[]);var n=[];s.calledFunctionsArguments[r].push(n),t.push(r),t.push("(");for(var i=0;i0&&t.push(", "),this.astGeneric(a,t,s),"Identifier"===a.type){var u=s.paramNames.indexOf(a.name);-1===u?n.push(null):n.push({name:a.name,type:s.paramTypes[u]})}else n.push(null)}return t.push(")"),t}throw this.astErrorOutput("Unknown CallExpression",e,s)}},{key:"astArrayExpression",value:function(e,t,s){var r=e.elements.length;t.push("float["+r+"](");for(var n=0;n0&&t.push(", ");var i=e.elements[n];this.astGeneric(i,t,s)}return t.push(")"),t}},{key:"getFunctionPrototypeString",value:function(){return this.webGlFunctionPrototypeString?this.webGlFunctionPrototypeString:this.webGlFunctionPrototypeString=this.generate()}},{key:"build",value:function(){return this.getFunctionPrototypeString().length>0}}],[{key:"astFunctionPrototype",value:function(e,t,s){if(s.isRootKernel||s.isSubKernel)return t;t.push(s.returnType),t.push(" "),t.push(s.functionName),t.push("(");for(var r=0;r0&&t.push(", "),t.push(s.paramTypes[r]),t.push(" "),t.push("user_"),t.push(s.paramNames[r]);return t.push(");\n"),t}}]),t}(FunctionNodeBase); },{"../../core/utils":75,"../function-node-base":57}],63:[function(require,module,exports){ -"use strict";function removeFnNoise(t){return/^function /.test(t)&&(t=t.substring(9)),t.replace(/[_]typeof/g,"typeof")}function removeNoise(t){return t.replace(/[_]typeof/g,"typeof")}var utils=require("../../core/utils"),kernelRunShortcut=require("../kernel-run-shortcut");module.exports=function(t,e){return"() => {\n "+kernelRunShortcut.toString()+";\n const utils = {\n allPropertiesOf: "+removeNoise(utils.allPropertiesOf.toString())+",\n clone: "+removeNoise(utils.clone.toString())+",\n splitArray: "+removeNoise(utils.splitArray.toString())+",\n getArgumentType: "+removeNoise(utils.getArgumentType.toString())+",\n getDimensions: "+removeNoise(utils.getDimensions.toString())+",\n dimToTexSize: "+removeNoise(utils.dimToTexSize.toString())+",\n flattenTo: "+removeNoise(utils.flattenTo.toString())+",\n flatten2dArrayTo: "+removeNoise(utils.flatten2dArrayTo.toString())+",\n flatten3dArrayTo: "+removeNoise(utils.flatten3dArrayTo.toString())+",\n systemEndianness: '"+removeNoise(utils.systemEndianness())+"',\n initWebGl: "+removeNoise(utils.initWebGl.toString())+",\n isArray: "+removeNoise(utils.isArray.toString())+"\n };\n const Utils = utils;\n const canvases = [];\n const maxTexSizes = {};\n class "+(e||"Kernel")+" {\n constructor() {\n this.maxTexSize = null;\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(t.paramNames)+";\n this.paramTypes = "+JSON.stringify(t.paramTypes)+";\n this.texSize = "+JSON.stringify(t.texSize)+";\n this.output = "+JSON.stringify(t.output)+";\n this.compiledFragShaderString = `"+t.compiledFragShaderString+"`;\n\t\t this.compiledVertShaderString = `"+t.compiledVertShaderString+"`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n\t\t this.subKernelOutputVariableNames = null;\n }\n "+removeFnNoise(t._getFragShaderString.toString())+"\n "+removeFnNoise(t._getVertShaderString.toString())+"\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+removeFnNoise(t.getUniformLocation.toString())+"\n "+removeFnNoise(t.setupParams.toString())+"\n "+removeFnNoise(t.build.toString())+"\n\t\t "+removeFnNoise(t.run.toString())+"\n\t\t "+removeFnNoise(t._addArgument.toString())+"\n\t\t "+removeFnNoise(t.getArgumentTexture.toString())+"\n\t\t "+removeFnNoise(t.getTextureCache.toString())+"\n\t\t "+removeFnNoise(t.getOutputTexture.toString())+"\n\t\t "+removeFnNoise(t.renderOutput.toString())+"\n\t\t "+removeFnNoise(t.updateMaxTexSize.toString())+"\n\t\t "+removeFnNoise(t._setupOutputTexture.toString())+"\n\t\t "+removeFnNoise(t.detachTextureCache.toString())+"\n };\n return kernelRunShortcut(new Kernel());\n };"}; +"use strict";var utils=require("../../core/utils"),kernelRunShortcut=require("../kernel-run-shortcut");module.exports=function(t,n){return"() => {\n "+kernelRunShortcut.toString()+";\n const utils = {\n allPropertiesOf: function "+utils.allPropertiesOf.toString()+",\n clone: function "+utils.clone.toString()+",\n splitArray: function "+utils.splitArray.toString()+",\n getArgumentType: function "+utils.getArgumentType.toString()+",\n getDimensions: function "+utils.getDimensions.toString()+",\n dimToTexSize: function "+utils.dimToTexSize.toString()+",\n copyFlatten: function "+utils.copyFlatten.toString()+",\n flatten: function "+utils.flatten.toString()+",\n systemEndianness: '"+utils.systemEndianness()+"',\n initWebGl: function "+utils.initWebGl.toString()+",\n isArray: function "+utils.isArray.toString()+"\n };\n class "+(n||"Kernel")+" {\n constructor() {\n this.argumentsLength = 0;\n this._canvas = null;\n this._webGl = null;\n this.built = false;\n this.program = null;\n this.paramNames = "+JSON.stringify(t.paramNames)+";\n this.paramTypes = "+JSON.stringify(t.paramTypes)+";\n this.texSize = "+JSON.stringify(t.texSize)+";\n this.output = "+JSON.stringify(t.output)+";\n this.compiledFragShaderString = `"+t.compiledFragShaderString+"`;\n\t\t this.compiledVertShaderString = `"+t.compiledVertShaderString+"`;\n\t\t this.programUniformLocationCache = {};\n\t\t this.textureCache = {};\n\t\t this.subKernelOutputTextures = null;\n }\n "+t._getFragShaderString.toString()+"\n "+t._getVertShaderString.toString()+"\n validateOptions() {}\n setupParams() {}\n setCanvas(canvas) { this._canvas = canvas; return this; }\n setWebGl(webGl) { this._webGl = webGl; return this; }\n "+t.getUniformLocation.toString()+"\n "+t.setupParams.toString()+"\n "+t.build.toString()+"\n\t\t "+t.run.toString()+"\n\t\t "+t._addArgument.toString()+"\n\t\t "+t.getArgumentTexture.toString()+"\n\t\t "+t.getTextureCache.toString()+"\n\t\t "+t.getOutputTexture.toString()+"\n\t\t "+t.renderOutput.toString()+"\n };\n return kernelRunShortcut(new Kernel());\n };"}; },{"../../core/utils":75,"../kernel-run-shortcut":59}],64:[function(require,module,exports){ -"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var r=0;r0&&!this.outputImmutable&&this._setupSubOutputTextures(this.subKernelOutputVariableNames.length)}},{key:"run",value:function(){null===this.program&&this.build.apply(this,arguments);var e=this.paramNames,t=this.paramTypes,r=this.texSize,i=this._webGl;if(i.useProgram(this.program),i.scissor(0,0,r[0],r[1]),!this.hardcodeConstants){var u=this.getUniformLocation("uOutputDim");i.uniform3fv(u,this.threadDim);var n=this.getUniformLocation("uTexSize");i.uniform2fv(n,r)}var a=this.getUniformLocation("ratio");i.uniform2f(a,r[0]/this.maxTexSize[0],r[1]/this.maxTexSize[1]),this.argumentsLength=0;for(var s=0;s0?e.join(";\n")+";\n":"\n"}},{key:"_replaceArtifacts",value:function(e,t){return e.replace(/[ ]*__([A-Z]+[0-9]*([_]?[A-Z])*)__;\n/g,function(e,r){if(t.hasOwnProperty(r))return t[r];throw"unhandled artifact "+r})}},{key:"_addKernels",value:function(){var e=this,t=this.functionBuilder;this._webGl;t.addFunctions(this.functions,{constants:this.constants,output:this.output}),t.addNativeFunctions(this.nativeFunctions),t.addKernel(this.fnString,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations},this.paramNames,this.paramTypes),null!==this.subKernels?(this.subKernelOutputTextures=[],this.subKernelOutputVariableNames=[],this.subKernels.forEach(function(t){return e._addSubKernel(t)})):null!==this.subKernelProperties&&(this.subKernelOutputTextures=[],this.subKernelOutputVariableNames=[],Object.keys(this.subKernelProperties).forEach(function(t){return e._addSubKernel(e.subKernelProperties[t])}))}},{key:"_addSubKernel",value:function(e){this.functionBuilder.addSubKernel(e,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations}),this.subKernelOutputVariableNames.push(e.name+"Result")}},{key:"_getFragShaderString",value:function(e){return null!==this.compiledFragShaderString?this.compiledFragShaderString:this.compiledFragShaderString=this._replaceArtifacts(fragShaderString,this._getFragShaderArtifactMap(e))}},{key:"_getVertShaderString",value:function(e){return null!==this.compiledVertShaderString?this.compiledVertShaderString:this.compiledVertShaderString=vertShaderString}},{key:"toString",value:function(){return kernelString(this)}},{key:"addFunction",value:function(e){this.functionBuilder.addFunction(null,e)}}]),t}(KernelBase); +"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var r=0;r0?e.join(";\n")+";\n":"\n"}},{key:"_replaceArtifacts",value:function(e,t){return e.replace(/[ ]*__([A-Z]+[0-9]*([_]?[A-Z])*)__;\n/g,function(e,r){if(t.hasOwnProperty(r))return t[r];throw"unhandled artifact "+r})}},{key:"_addKernels",value:function(){var e=this.functionBuilder,t=this._webGl;if(e.addFunctions(this.functions,{constants:this.constants,output:this.output}),e.addNativeFunctions(this.nativeFunctions),e.addKernel(this.fnString,{prototypeOnly:!1,constants:this.constants,output:this.output,debug:this.debug,loopMaxIterations:this.loopMaxIterations},this.paramNames,this.paramTypes),null!==this.subKernels){if(!(this.ext=t.getExtension("WEBGL_draw_buffers")))throw new Error("could not instantiate draw buffers extension");this.subKernelOutputTextures=[],this.subKernelOutputVariableNames=[];for(var r=0;r1)for(var r=1;r0?("string"==typeof t||i.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=_uint8ArrayToBuffer(t)),n?i.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):addChunk(e,i,t,!0):i.ended?e.emit("error",new Error("stream.push() after EOF")):(i.reading=!1,i.decoder&&!r?(t=i.decoder.write(t),i.objectMode||0!==t.length?addChunk(e,i,t,!1):maybeReadMore(e,i)):addChunk(e,i,t,!1))):n||(i.reading=!1)}return needMoreData(i)}function addChunk(e,t,r,n){t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&emitReadable(e)),maybeReadMore(e,t)}function chunkInvalid(e,t){var r;return _isUint8Array(t)||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function needMoreData(e){return!e.ended&&(e.needReadable||e.length=MAX_HWM?e=MAX_HWM:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function howMuchToRead(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=computeNewHighWaterMark(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function onEofChunk(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,emitReadable(e)}}function emitReadable(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(debug("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?processNextTick(emitReadable_,e):emitReadable_(e))}function emitReadable_(e){debug("emit readable"),e.emit("readable"),flow(e)}function maybeReadMore(e,t){t.readingMore||(t.readingMore=!0,processNextTick(maybeReadMore_,e,t))}function maybeReadMore_(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=fromListPartial(e,t.buffer,t.decoder),r}function fromListPartial(e,t,r){var n;return ei.length?i.length:e;if(d===i.length?a+=i:a+=i.slice(0,e),0===(e-=d)){d===i.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=i.slice(d));break}++n}return t.length-=n,a}function copyFromBuffer(e,t){var r=Buffer.allocUnsafe(e),n=t.head,a=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var i=n.data,d=e>i.length?i.length:e;if(i.copy(r,r.length-e,0,d),0===(e-=d)){d===i.length?(++a,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=i.slice(d));break}++a}return t.length-=a,r}function endReadable(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,processNextTick(endReadableNT,t,e))}function endReadableNT(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function forEach(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return debug("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?endReadable(this):emitReadable(this),null;if(0===(e=howMuchToRead(e,t))&&t.ended)return 0===t.length&&endReadable(this),null;var n=t.needReadable;debug("need readable",n),(0===t.length||t.length-e0?fromList(e,t):null,null===a?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&endReadable(this)),null!==a&&this.emit("data",a),a},Readable.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},Readable.prototype.pipe=function(e,t){function r(e,t){debug("onunpipe"),e===l&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,a())}function n(){debug("onend"),e.end()}function a(){debug("cleanup"),e.removeListener("close",o),e.removeListener("finish",u),e.removeListener("drain",c),e.removeListener("error",d),e.removeListener("unpipe",r),l.removeListener("end",n),l.removeListener("end",s),l.removeListener("data",i),b=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||c()}function i(t){debug("ondata"),g=!1,!1!==e.write(t)||g||((1===h.pipesCount&&h.pipes===e||h.pipesCount>1&&-1!==indexOf(h.pipes,e))&&!b&&(debug("false write response, pause",l._readableState.awaitDrain),l._readableState.awaitDrain++,g=!0),l.pause())}function d(t){debug("onerror",t),s(),e.removeListener("error",d),0===EElistenerCount(e,"error")&&e.emit("error",t)}function o(){e.removeListener("finish",u),s()}function u(){debug("onfinish"),e.removeListener("close",o),s()}function s(){debug("unpipe"),l.unpipe(e)}var l=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,debug("pipe count=%d opts=%j",h.pipesCount,t);var f=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr,p=f?n:s;h.endEmitted?processNextTick(p):l.once("end",p),e.on("unpipe",r);var c=pipeOnDrain(l);e.on("drain",c);var b=!1,g=!1;return l.on("data",i),prependListener(e,"error",d),e.once("close",o),e.once("finish",u),e.emit("pipe",l),h.flowing||(debug("pipe resume"),l.resume()),e},Readable.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,a=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i0?("string"==typeof t||i.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=_uint8ArrayToBuffer(t)),n?i.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):addChunk(e,i,t,!0):i.ended?e.emit("error",new Error("stream.push() after EOF")):(i.reading=!1,i.decoder&&!r?(t=i.decoder.write(t),i.objectMode||0!==t.length?addChunk(e,i,t,!1):maybeReadMore(e,i)):addChunk(e,i,t,!1))):n||(i.reading=!1)}return needMoreData(i)}function addChunk(e,t,r,n){t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&emitReadable(e)),maybeReadMore(e,t)}function chunkInvalid(e,t){var r;return _isUint8Array(t)||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function needMoreData(e){return!e.ended&&(e.needReadable||e.length=MAX_HWM?e=MAX_HWM:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function howMuchToRead(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=computeNewHighWaterMark(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function onEofChunk(e,t){if(!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,emitReadable(e)}}function emitReadable(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(debug("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?processNextTick(emitReadable_,e):emitReadable_(e))}function emitReadable_(e){debug("emit readable"),e.emit("readable"),flow(e)}function maybeReadMore(e,t){t.readingMore||(t.readingMore=!0,processNextTick(maybeReadMore_,e,t))}function maybeReadMore_(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=fromListPartial(e,t.buffer,t.decoder),r}function fromListPartial(e,t,r){var n;return ei.length?i.length:e;if(d===i.length?a+=i:a+=i.slice(0,e),0===(e-=d)){d===i.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=i.slice(d));break}++n}return t.length-=n,a}function copyFromBuffer(e,t){var r=Buffer.allocUnsafe(e),n=t.head,a=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var i=n.data,d=e>i.length?i.length:e;if(i.copy(r,r.length-e,0,d),0===(e-=d)){d===i.length?(++a,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=i.slice(d));break}++a}return t.length-=a,r}function endReadable(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,processNextTick(endReadableNT,t,e))}function endReadableNT(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function forEach(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return debug("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?endReadable(this):emitReadable(this),null;if(0===(e=howMuchToRead(e,t))&&t.ended)return 0===t.length&&endReadable(this),null;var n=t.needReadable;debug("need readable",n),(0===t.length||t.length-e0?fromList(e,t):null,null===a?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&endReadable(this)),null!==a&&this.emit("data",a),a},Readable.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},Readable.prototype.pipe=function(e,t){function r(e,t){debug("onunpipe"),e===l&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,a())}function n(){debug("onend"),e.end()}function a(){debug("cleanup"),e.removeListener("close",o),e.removeListener("finish",s),e.removeListener("drain",c),e.removeListener("error",d),e.removeListener("unpipe",r),l.removeListener("end",n),l.removeListener("end",u),l.removeListener("data",i),b=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||c()}function i(t){debug("ondata"),g=!1,!1!==e.write(t)||g||((1===h.pipesCount&&h.pipes===e||h.pipesCount>1&&-1!==indexOf(h.pipes,e))&&!b&&(debug("false write response, pause",l._readableState.awaitDrain),l._readableState.awaitDrain++,g=!0),l.pause())}function d(t){debug("onerror",t),u(),e.removeListener("error",d),0===EElistenerCount(e,"error")&&e.emit("error",t)}function o(){e.removeListener("finish",s),u()}function s(){debug("onfinish"),e.removeListener("close",o),u()}function u(){debug("unpipe"),l.unpipe(e)}var l=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,debug("pipe count=%d opts=%j",h.pipesCount,t);var f=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr,p=f?n:u;h.endEmitted?processNextTick(p):l.once("end",p),e.on("unpipe",r);var c=pipeOnDrain(l);e.on("drain",c);var b=!1,g=!1;return l.on("data",i),prependListener(e,"error",d),e.once("close",o),e.once("finish",s),e.emit("pipe",l),h.flowing||(debug("pipe resume"),l.resume()),e},Readable.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,a=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1?setImmediate:processNextTick,Duplex;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var internalUtil={deprecate:require("util-deprecate")},Stream=require("./internal/streams/stream"),Buffer=require("safe-buffer").Buffer,OurUint8Array=global.Uint8Array||function(){},destroyImpl=require("./internal/streams/destroy");util.inherits(Writable,Stream),WritableState.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}();var realHasInstance;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(realHasInstance=Function.prototype[Symbol.hasInstance],Object.defineProperty(Writable,Symbol.hasInstance,{value:function(e){return!!realHasInstance.call(this,e)||e&&e._writableState instanceof WritableState}})):realHasInstance=function(e){return e instanceof this},Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Writable.prototype.write=function(e,t,r){var i=this._writableState,n=!1,o=_isUint8Array(e)&&!i.objectMode;return o&&!Buffer.isBuffer(e)&&(e=_uint8ArrayToBuffer(e)),"function"==typeof t&&(r=t,t=null),o?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=nop),i.ended?writeAfterEnd(this,r):(o||validChunk(this,i,e,r))&&(i.pendingcb++,n=writeOrBuffer(this,i,o,e,t,r)),n},Writable.prototype.cork=function(){this._writableState.corked++},Writable.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||clearBuffer(this,e))},Writable.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Writable.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Writable.prototype._writev=null,Writable.prototype.end=function(e,t,r){var i=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||endWritable(this,i,r)},Object.defineProperty(Writable.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Writable.prototype.destroy=destroyImpl.destroy,Writable.prototype._undestroy=destroyImpl.undestroy,Writable.prototype._destroy=function(e,t){this.end(),t(e)}; +"use strict";function WriteReq(e,t,r){this.chunk=e,this.encoding=t,this.callback=r,this.next=null}function CorkedRequest(e){var t=this;this.next=null,this.entry=null,this.finish=function(){onCorkedFinish(t,e)}}function _uint8ArrayToBuffer(e){return Buffer.from(e)}function _isUint8Array(e){return Buffer.isBuffer(e)||e instanceof OurUint8Array}function nop(){}function WritableState(e,t){Duplex=Duplex||require("./_stream_duplex"),e=e||{};var r=t instanceof Duplex;this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,n=e.writableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:r&&(n||0===n)?n:o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){onwrite(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new CorkedRequest(this)}function Writable(e){if(Duplex=Duplex||require("./_stream_duplex"),!(realHasInstance.call(Writable,this)||this instanceof Duplex))return new Writable(e);this._writableState=new WritableState(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),Stream.call(this)}function writeAfterEnd(e,t){var r=new Error("write after end");e.emit("error",r),processNextTick(t,r)}function validChunk(e,t,r,i){var n=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),processNextTick(i,o),n=!1),n}function decodeChunk(e,t,r){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Buffer.from(t,r)),t}function writeOrBuffer(e,t,r,i,n,o){if(!r){var s=decodeChunk(t,i,n);i!==s&&(r=!0,n="buffer",i=s)}var a=t.objectMode?1:i.length;t.length+=a;var f=t.length-1?setImmediate:processNextTick,Duplex;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var internalUtil={deprecate:require("util-deprecate")},Stream=require("./internal/streams/stream"),Buffer=require("safe-buffer").Buffer,OurUint8Array=global.Uint8Array||function(){},destroyImpl=require("./internal/streams/destroy");util.inherits(Writable,Stream),WritableState.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}();var realHasInstance;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(realHasInstance=Function.prototype[Symbol.hasInstance],Object.defineProperty(Writable,Symbol.hasInstance,{value:function(e){return!!realHasInstance.call(this,e)||this===Writable&&(e&&e._writableState instanceof WritableState)}})):realHasInstance=function(e){return e instanceof this},Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Writable.prototype.write=function(e,t,r){var i=this._writableState,n=!1,o=!i.objectMode&&_isUint8Array(e);return o&&!Buffer.isBuffer(e)&&(e=_uint8ArrayToBuffer(e)),"function"==typeof t&&(r=t,t=null),o?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=nop),i.ended?writeAfterEnd(this,r):(o||validChunk(this,i,e,r))&&(i.pendingcb++,n=writeOrBuffer(this,i,o,e,t,r)),n},Writable.prototype.cork=function(){this._writableState.corked++},Writable.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||clearBuffer(this,e))},Writable.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Writable.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},Writable.prototype._writev=null,Writable.prototype.end=function(e,t,r){var i=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||endWritable(this,i,r)},Object.defineProperty(Writable.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Writable.prototype.destroy=destroyImpl.destroy,Writable.prototype._undestroy=destroyImpl.undestroy,Writable.prototype._destroy=function(e,t){this.end(),t(e)}; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./_stream_duplex":84,"./internal/streams/destroy":90,"./internal/streams/stream":91,"_process":82,"core-util-is":49,"inherits":78,"process-nextick-args":81,"safe-buffer":97,"util-deprecate":102}],89:[function(require,module,exports){ -"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function copyBuffer(t,e,h){t.copy(e,h)}var Buffer=require("safe-buffer").Buffer;module.exports=function(){function t(){_classCallCheck(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,h=""+e.data;e=e.next;)h+=t+e.data;return h},t.prototype.concat=function(t){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var e=Buffer.allocUnsafe(t>>>0),h=this.head,n=0;h;)copyBuffer(h.data,e,n),n+=h.data.length,h=h.next;return e},t}(); +"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function copyBuffer(t,e,i){t.copy(e,i)}var Buffer=require("safe-buffer").Buffer,util=require("util");module.exports=function(){function t(){_classCallCheck(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i},t.prototype.concat=function(t){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var e=Buffer.allocUnsafe(t>>>0),i=this.head,n=0;i;)copyBuffer(i.data,e,n),n+=i.data.length,i=i.next;return e},t}(),util&&util.inspect&&util.inspect.custom&&(module.exports.prototype[util.inspect.custom]=function(){var t=util.inspect({length:this.length});return this.constructor.name+" "+t}); -},{"safe-buffer":97}],90:[function(require,module,exports){ -"use strict";function destroy(t,e){var r=this,i=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;if(i||a)return void(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||processNextTick(emitErrorNT,this,t));this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(processNextTick(emitErrorNT,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)})}function undestroy(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function emitErrorNT(t,e){t.emit("error",e)}var processNextTick=require("process-nextick-args");module.exports={destroy:destroy,undestroy:undestroy}; +},{"safe-buffer":97,"util":47}],90:[function(require,module,exports){ +"use strict";function destroy(t,e){var r=this,i=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return i||a?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||processNextTick(emitErrorNT,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(processNextTick(emitErrorNT,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}),this)}function undestroy(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function emitErrorNT(t,e){t.emit("error",e)}var processNextTick=require("process-nextick-args").nextTick;module.exports={destroy:destroy,undestroy:undestroy}; },{"process-nextick-args":81}],91:[function(require,module,exports){ module.exports=require("events").EventEmitter; },{"events":50}],92:[function(require,module,exports){ "use strict";function _normalizeEncoding(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function normalizeEncoding(t){var e=_normalizeEncoding(t);if("string"!=typeof e&&(Buffer.isEncoding===isEncoding||!isEncoding(t)))throw new Error("Unknown encoding: "+t);return e||t}function StringDecoder(t){this.encoding=normalizeEncoding(t);var e;switch(this.encoding){case"utf16le":this.text=utf16Text,this.end=utf16End,e=4;break;case"utf8":this.fillLast=utf8FillLast,e=4;break;case"base64":this.text=base64Text,this.end=base64End,e=3;break;default:return this.write=simpleWrite,void(this.end=simpleEnd)}this.lastNeed=0,this.lastTotal=0,this.lastChar=Buffer.allocUnsafe(e)}function utf8CheckByte(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1}function utf8CheckIncomplete(t,e,s){var i=e.length-1;if(i=0?(a>0&&(t.lastNeed=a-1),a):--i=0?(a>0&&(t.lastNeed=a-2),a):--i=0?(a>0&&(2===a?a=0:t.lastNeed=a-3),a):0)}function utf8CheckExtraBytes(t,e,s){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(s);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(s+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(s+2)}}function utf8FillLast(t){var e=this.lastTotal-this.lastNeed,s=utf8CheckExtraBytes(this,t,e);return void 0!==s?s:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function utf8Text(t,e){var s=utf8CheckIncomplete(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=s;var i=t.length-(s-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)}function utf8End(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�".repeat(this.lastTotal-this.lastNeed):e}function utf16Text(t,e){if((t.length-e)%2==0){var s=t.toString("utf16le",e);if(s){var i=s.charCodeAt(s.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],s.slice(0,-1)}return s}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function utf16End(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var s=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,s)}return e}function base64Text(t,e){var s=(t.length-e)%3;return 0===s?t.toString("base64",e):(this.lastNeed=3-s,this.lastTotal=3,1===s?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-s))}function base64End(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function simpleWrite(t){return t.toString(this.encoding)}function simpleEnd(t){return t&&t.length?this.write(t):""}var Buffer=require("safe-buffer").Buffer,isEncoding=Buffer.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};exports.StringDecoder=StringDecoder,StringDecoder.prototype.write=function(t){if(0===t.length)return"";var e,s;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";s=this.lastNeed,this.lastNeed=0}else s=0;return s